Documentation
¶
Overview ¶
Package javascriptcore was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT
Package javascriptcore was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT
Package javascriptcore was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT
Package javascriptcore was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT
Package javascriptcore was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT
Package javascriptcore was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT
Package javascriptcore was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT
Package javascriptcore was automatically generated by github.com/jwijenbergh/puregotk DO NOT EDIT
Index ¶
- Constants
- func ClassGLibType() types.GType
- func ContextGLibType() types.GType
- func ExceptionGLibType() types.GType
- func GetMajorVersion() uint
- func GetMicroVersion() uint
- func GetMinorVersion() uint
- func OptionsForeach(FunctionVar *OptionsFunc, UserDataVar uintptr)
- func OptionsGetBoolean(OptionVar string, ValueVar *bool) bool
- func OptionsGetDouble(OptionVar string, ValueVar *float64) bool
- func OptionsGetInt(OptionVar string, ValueVar *int) bool
- func OptionsGetOptionGroup() *glib.OptionGroup
- func OptionsGetRangeString(OptionVar string, ValueVar *string) bool
- func OptionsGetSize(OptionVar string, ValueVar *uint) bool
- func OptionsGetString(OptionVar string, ValueVar *string) bool
- func OptionsGetUint(OptionVar string, ValueVar *uint) bool
- func OptionsSetBoolean(OptionVar string, ValueVar bool) bool
- func OptionsSetDouble(OptionVar string, ValueVar float64) bool
- func OptionsSetInt(OptionVar string, ValueVar int) bool
- func OptionsSetRangeString(OptionVar string, ValueVar string) bool
- func OptionsSetSize(OptionVar string, ValueVar uint) bool
- func OptionsSetString(OptionVar string, ValueVar string) bool
- func OptionsSetUint(OptionVar string, ValueVar uint) bool
- func ValueGLibType() types.GType
- func VirtualMachineGLibType() types.GType
- func WeakValueGLibType() types.GType
- type CheckSyntaxMode
- type CheckSyntaxResult
- type Class
- func (x *Class) AddConstructor(NameVar *string, CallbackVar *gobject.Callback, UserDataVar uintptr, ...) *Value
- func (x *Class) AddConstructorVariadic(NameVar *string, CallbackVar *gobject.Callback, UserDataVar uintptr, ...) *Value
- func (x *Class) AddConstructorv(NameVar *string, CallbackVar *gobject.Callback, UserDataVar uintptr, ...) *Value
- func (x *Class) AddMethod(NameVar string, CallbackVar *gobject.Callback, UserDataVar uintptr, ...)
- func (x *Class) AddMethodVariadic(NameVar string, CallbackVar *gobject.Callback, UserDataVar uintptr, ...)
- func (x *Class) AddMethodv(NameVar string, CallbackVar *gobject.Callback, UserDataVar uintptr, ...)
- func (x *Class) AddProperty(NameVar string, PropertyTypeVar types.GType, GetterVar *gobject.Callback, ...)
- func (x *Class) GetName() string
- func (x *Class) GetParent() *Class
- func (x *Class) GetPropertyName() string
- func (c *Class) GoPointer() uintptr
- func (c *Class) SetGoPointer(ptr uintptr)
- func (x *Class) SetPropertyName(value string)
- type ClassClass
- type ClassDeletePropertyFunction
- type ClassEnumeratePropertiesFunction
- type ClassGetPropertyFunction
- type ClassHasPropertyFunction
- type ClassSetPropertyFunction
- type ClassVTable
- func (x *ClassVTable) GetJscReserved0() func()
- func (x *ClassVTable) GetJscReserved1() func()
- func (x *ClassVTable) GetJscReserved2() func()
- func (x *ClassVTable) GetJscReserved3() func()
- func (x *ClassVTable) GetJscReserved4() func()
- func (x *ClassVTable) GetJscReserved5() func()
- func (x *ClassVTable) GetJscReserved6() func()
- func (x *ClassVTable) GetJscReserved7() func()
- func (x *ClassVTable) GoPointer() uintptr
- func (x *ClassVTable) OverrideJscReserved0(cb func())
- func (x *ClassVTable) OverrideJscReserved1(cb func())
- func (x *ClassVTable) OverrideJscReserved2(cb func())
- func (x *ClassVTable) OverrideJscReserved3(cb func())
- func (x *ClassVTable) OverrideJscReserved4(cb func())
- func (x *ClassVTable) OverrideJscReserved5(cb func())
- func (x *ClassVTable) OverrideJscReserved6(cb func())
- func (x *ClassVTable) OverrideJscReserved7(cb func())
- type Context
- func (x *Context) CheckSyntax(CodeVar string, LengthVar int, ModeVar CheckSyntaxMode, UriVar string, ...) CheckSyntaxResult
- func (x *Context) ClearException()
- func (x *Context) Evaluate(CodeVar string, LengthVar int) *Value
- func (x *Context) EvaluateInObject(CodeVar string, LengthVar int, ObjectInstanceVar uintptr, ...) *Value
- func (x *Context) EvaluateWithSourceUri(CodeVar string, LengthVar int, UriVar string, LineNumberVar uint) *Value
- func (x *Context) GetException() *Exception
- func (x *Context) GetGlobalObject() *Value
- func (x *Context) GetValue(NameVar string) *Value
- func (x *Context) GetVirtualMachine() *VirtualMachine
- func (c *Context) GoPointer() uintptr
- func (x *Context) PopExceptionHandler()
- func (x *Context) PushExceptionHandler(HandlerVar *ExceptionHandler, UserDataVar uintptr, ...)
- func (x *Context) RegisterClass(NameVar string, ParentClassVar *Class, VtableVar *ClassVTable, ...) *Class
- func (c *Context) SetGoPointer(ptr uintptr)
- func (x *Context) SetValue(NameVar string, ValueVar *Value)
- func (x *Context) Throw(ErrorMessageVar string)
- func (x *Context) ThrowException(ExceptionVar *Exception)
- func (x *Context) ThrowPrintf(FormatVar string, varArgs ...interface{})
- func (x *Context) ThrowWithName(ErrorNameVar string, ErrorMessageVar string)
- func (x *Context) ThrowWithNamePrintf(ErrorNameVar string, FormatVar string, varArgs ...interface{})
- type ContextClass
- type Exception
- func ExceptionNewFromInternalPtr(ptr uintptr) *Exception
- func NewException(ContextVar *Context, MessageVar string) *Exception
- func NewExceptionPrintf(ContextVar *Context, FormatVar string, varArgs ...interface{}) *Exception
- func NewExceptionVprintf(ContextVar *Context, FormatVar string, ArgsVar []interface{}) *Exception
- func NewExceptionWithName(ContextVar *Context, NameVar string, MessageVar string) *Exception
- func NewExceptionWithNamePrintf(ContextVar *Context, NameVar string, FormatVar string, varArgs ...interface{}) *Exception
- func NewExceptionWithNameVprintf(ContextVar *Context, NameVar string, FormatVar string, ArgsVar []interface{}) *Exception
- func (x *Exception) GetBacktraceString() string
- func (x *Exception) GetColumnNumber() uint
- func (x *Exception) GetLineNumber() uint
- func (x *Exception) GetMessage() string
- func (x *Exception) GetName() string
- func (x *Exception) GetSourceUri() string
- func (c *Exception) GoPointer() uintptr
- func (x *Exception) Report() string
- func (c *Exception) SetGoPointer(ptr uintptr)
- func (x *Exception) ToString() string
- type ExceptionClass
- type ExceptionHandler
- type Executor
- type OptionType
- type OptionsFunc
- type TypedArrayType
- type Value
- func NewValueArray(ContextVar *Context, FirstItemTypeVar types.GType, varArgs ...interface{}) *Value
- func NewValueArrayBuffer(ContextVar *Context, DataVar uintptr, SizeVar uint, ...) *Value
- func NewValueArrayFromGarray(ContextVar *Context, ArrayVar []Value) *Value
- func NewValueArrayFromStrv(ContextVar *Context, StrvVar []string) *Value
- func NewValueBoolean(ContextVar *Context, ValueVar bool) *Value
- func NewValueFromJson(ContextVar *Context, JsonVar string) *Value
- func NewValueFunction(ContextVar *Context, NameVar *string, CallbackVar *gobject.Callback, ...) *Value
- func NewValueFunctionVariadic(ContextVar *Context, NameVar *string, CallbackVar *gobject.Callback, ...) *Value
- func NewValueFunctionv(ContextVar *Context, NameVar *string, CallbackVar *gobject.Callback, ...) *Value
- func NewValueNull(ContextVar *Context) *Value
- func NewValueNumber(ContextVar *Context, NumberVar float64) *Value
- func NewValueObject(ContextVar *Context, InstanceVar uintptr, JscClassVar *Class) *Value
- func NewValuePromise(ContextVar *Context, ExecutorVar *Executor, UserDataVar uintptr) *Value
- func NewValueString(ContextVar *Context, StringVar *string) *Value
- func NewValueStringFromBytes(ContextVar *Context, BytesVar *glib.Bytes) *Value
- func NewValueTypedArray(ContextVar *Context, TypeVar TypedArrayType, LengthVar uint) *Value
- func NewValueUndefined(ContextVar *Context) *Value
- func ValueNewFromInternalPtr(ptr uintptr) *Value
- func (x *Value) ArrayBufferGetData(SizeVar *uint) uintptr
- func (x *Value) ArrayBufferGetSize() uint
- func (x *Value) ConstructorCall(FirstParameterTypeVar types.GType, varArgs ...interface{}) *Value
- func (x *Value) ConstructorCallv(NParametersVar uint, ParametersVar []Value) *Value
- func (x *Value) FunctionCall(FirstParameterTypeVar types.GType, varArgs ...interface{}) *Value
- func (x *Value) FunctionCallv(NParametersVar uint, ParametersVar []Value) *Value
- func (x *Value) GetContext() *Context
- func (c *Value) GoPointer() uintptr
- func (x *Value) IsArray() bool
- func (x *Value) IsArrayBuffer() bool
- func (x *Value) IsBoolean() bool
- func (x *Value) IsConstructor() bool
- func (x *Value) IsFunction() bool
- func (x *Value) IsNull() bool
- func (x *Value) IsNumber() bool
- func (x *Value) IsObject() bool
- func (x *Value) IsString() bool
- func (x *Value) IsTypedArray() bool
- func (x *Value) IsUndefined() bool
- func (x *Value) NewTypedArrayWithBuffer(TypeVar TypedArrayType, OffsetVar uint, LengthVar int) *Value
- func (x *Value) ObjectDefinePropertyAccessor(PropertyNameVar string, FlagsVar ValuePropertyFlags, ...)
- func (x *Value) ObjectDefinePropertyData(PropertyNameVar string, FlagsVar ValuePropertyFlags, PropertyValueVar *Value)
- func (x *Value) ObjectDeleteProperty(NameVar string) bool
- func (x *Value) ObjectEnumerateProperties() []string
- func (x *Value) ObjectGetProperty(NameVar string) *Value
- func (x *Value) ObjectGetPropertyAtIndex(IndexVar uint) *Value
- func (x *Value) ObjectHasProperty(NameVar string) bool
- func (x *Value) ObjectInvokeMethod(NameVar string, FirstParameterTypeVar types.GType, varArgs ...interface{}) *Value
- func (x *Value) ObjectInvokeMethodv(NameVar string, NParametersVar uint, ParametersVar []Value) *Value
- func (x *Value) ObjectIsInstanceOf(NameVar string) bool
- func (x *Value) ObjectSetProperty(NameVar string, PropertyVar *Value)
- func (x *Value) ObjectSetPropertyAtIndex(IndexVar uint, PropertyVar *Value)
- func (c *Value) SetGoPointer(ptr uintptr)
- func (x *Value) ToBoolean() bool
- func (x *Value) ToDouble() float64
- func (x *Value) ToInt32() int32
- func (x *Value) ToJson(IndentVar uint) string
- func (x *Value) ToString() string
- func (x *Value) ToStringAsBytes() *glib.Bytes
- func (x *Value) TypedArrayGetBuffer() *Value
- func (x *Value) TypedArrayGetData(LengthVar *uint) uintptr
- func (x *Value) TypedArrayGetLength() uint
- func (x *Value) TypedArrayGetOffset() uint
- func (x *Value) TypedArrayGetSize() uint
- func (x *Value) TypedArrayGetType() TypedArrayType
- type ValueClass
- type ValuePropertyFlags
- type VirtualMachine
- type VirtualMachineClass
- type WeakValue
- type WeakValueClass
Constants ¶
const ( // Allows the DFG JIT to be used if %TRUE. // Option type: %JSC_OPTION_BOOLEAN // Default value: %TRUE. OPTIONS_USE_DFG string = "useDFGJIT" // Allows the FTL JIT to be used if %TRUE. // Option type: %JSC_OPTION_BOOLEAN // Default value: %TRUE. OPTIONS_USE_FTL string = "useFTLJIT" // Allows the executable pages to be allocated for JIT and thunks if %TRUE. // Option type: %JSC_OPTION_BOOLEAN // Default value: %TRUE. OPTIONS_USE_JIT string = "useJIT" // Allows the LLINT to be used if %TRUE. // Option type: %JSC_OPTION_BOOLEAN // Default value: %TRUE. OPTIONS_USE_LLINT string = "useLLInt" )
const ( // Like jsc_get_major_version(), but from the headers used at // application compile time, rather than from the library linked // against at application run time. MAJOR_VERSION int = 2 // Like jsc_get_micro_version(), but from the headers used at // application compile time, rather than from the library linked // against at application run time. MICRO_VERSION int = 3 // Like jsc_get_minor_version(), but from the headers used at // application compile time, rather than from the library linked // against at application run time. MINOR_VERSION int = 50 )
Variables ¶
This section is empty.
Functions ¶
func ClassGLibType ¶
func ContextGLibType ¶
func ExceptionGLibType ¶
func GetMajorVersion ¶
func GetMajorVersion() uint
Returns the major version number of the JavaScriptCore library. (e.g. in JavaScriptCore version 1.8.3 this is 1.)
This function is in the library, so it represents the JavaScriptCore library your code is running against. Contrast with the #JSC_MAJOR_VERSION macro, which represents the major version of the JavaScriptCore headers you have included when compiling your code.
func GetMicroVersion ¶
func GetMicroVersion() uint
Returns the micro version number of the JavaScriptCore library. (e.g. in JavaScriptCore version 1.8.3 this is 3.)
This function is in the library, so it represents the JavaScriptCore library your code is running against. Contrast with the #JSC_MICRO_VERSION macro, which represents the micro version of the JavaScriptCore headers you have included when compiling your code.
func GetMinorVersion ¶
func GetMinorVersion() uint
Returns the minor version number of the JavaScriptCore library. (e.g. in JavaScriptCore version 1.8.3 this is 8.)
This function is in the library, so it represents the JavaScriptCore library your code is running against. Contrast with the #JSC_MINOR_VERSION macro, which represents the minor version of the JavaScriptCore headers you have included when compiling your code.
func OptionsForeach ¶
func OptionsForeach(FunctionVar *OptionsFunc, UserDataVar uintptr)
Iterates all available options calling @function for each one. Iteration can stop early if @function returns %FALSE.
func OptionsGetBoolean ¶
Get @option as a #gboolean value.
func OptionsGetDouble ¶
Get @option as a #gdouble value.
func OptionsGetInt ¶
Get @option as a #gint value.
func OptionsGetOptionGroup ¶
func OptionsGetOptionGroup() *glib.OptionGroup
Create a #GOptionGroup to handle JSCOptions as command line arguments. The options will be exposed as command line arguments with the form <emphasis>--jsc-&lt;option&gt;=&lt;value&gt;</emphasis>. Each entry in the returned #GOptionGroup is configured to apply the corresponding option during command line parsing. Applications only need to pass the returned group to g_option_context_add_group(), and the rest will be taken care for automatically.
func OptionsGetRangeString ¶
Get @option as a range string. The string must be in the format <emphasis>[!]&lt;low&gt;[:&lt;high&gt;]</emphasis> where low and high are #guint values. Values between low and high (both included) will be considered in the range, unless <emphasis>!</emphasis> is used to invert the range.
func OptionsGetSize ¶
Get @option as a #gsize value.
func OptionsGetString ¶
Get @option as a string.
func OptionsGetUint ¶
Get @option as a #guint value.
func OptionsSetBoolean ¶
Set @option as a #gboolean value.
func OptionsSetDouble ¶
Set @option as a #gdouble value.
func OptionsSetInt ¶
Set @option as a #gint value.
func OptionsSetRangeString ¶
Set @option as a range string. The string must be in the format <emphasis>[!]&lt;low&gt;[:&lt;high&gt;]</emphasis> where low and high are #guint values. Values between low and high (both included) will be considered in the range, unless <emphasis>!</emphasis> is used to invert the range.
func OptionsSetSize ¶
Set @option as a #gsize value.
func OptionsSetString ¶
Set @option as a string.
func OptionsSetUint ¶
Set @option as a #guint value.
func ValueGLibType ¶
func VirtualMachineGLibType ¶
func WeakValueGLibType ¶
Types ¶
type CheckSyntaxMode ¶
type CheckSyntaxMode int
Enum values to specify a mode to check for syntax errors in jsc_context_check_syntax().
const ( // mode to check syntax of a script JscCheckSyntaxModeScriptValue CheckSyntaxMode = 0 // mode to check syntax of a module JscCheckSyntaxModeModuleValue CheckSyntaxMode = 1 )
type CheckSyntaxResult ¶
type CheckSyntaxResult int
Enum values to specify the result of jsc_context_check_syntax().
const ( // no errors JscCheckSyntaxResultSuccessValue CheckSyntaxResult = 0 // recoverable syntax error JscCheckSyntaxResultRecoverableErrorValue CheckSyntaxResult = 1 // irrecoverable syntax error JscCheckSyntaxResultIrrecoverableErrorValue CheckSyntaxResult = 2 // unterminated literal error JscCheckSyntaxResultUnterminatedLiteralErrorValue CheckSyntaxResult = 3 // out of memory error JscCheckSyntaxResultOutOfMemoryErrorValue CheckSyntaxResult = 4 // stack overflow error JscCheckSyntaxResultStackOverflowErrorValue CheckSyntaxResult = 5 )
type Class ¶
A JSSClass represents a custom JavaScript class registered by the user in a #JSCContext. It allows to create new JavaScripts objects whose instances are created by the user using this API. It's possible to add constructors, properties and methods for a JSSClass by providing #GCallback<!-- -->s to implement them.
func ClassNewFromInternalPtr ¶
func (*Class) AddConstructor ¶
func (x *Class) AddConstructor(NameVar *string, CallbackVar *gobject.Callback, UserDataVar uintptr, DestroyNotifyVar *glib.DestroyNotify, ReturnTypeVar types.GType, NParamsVar uint, varArgs ...interface{}) *Value
Add a constructor to @jsc_class. If @name is %NULL, the class name will be used. When <function>new</function> is used with the constructor or jsc_value_constructor_call() is called, @callback is invoked receiving the parameters and @user_data as the last parameter. When the constructor object is cleared in the #JSCClass context, @destroy_notify is called with @user_data as parameter.
This function creates the constructor, which needs to be added to an object as a property to be able to use it. Use jsc_context_set_value() to make the constructor available in the global object.
Note that the value returned by @callback is adopted by @jsc_class, and the #GDestroyNotify passed to jsc_context_register_class() is responsible for disposing of it.
func (*Class) AddConstructorVariadic ¶
func (x *Class) AddConstructorVariadic(NameVar *string, CallbackVar *gobject.Callback, UserDataVar uintptr, DestroyNotifyVar *glib.DestroyNotify, ReturnTypeVar types.GType) *Value
Add a constructor to @jsc_class. If @name is %NULL, the class name will be used. When <function>new</function> is used with the constructor or jsc_value_constructor_call() is called, @callback is invoked receiving a #GPtrArray of #JSCValue<!-- -->s as arguments and @user_data as the last parameter. When the constructor object is cleared in the #JSCClass context, @destroy_notify is called with @user_data as parameter.
This function creates the constructor, which needs to be added to an object as a property to be able to use it. Use jsc_context_set_value() to make the constructor available in the global object.
Note that the value returned by @callback is adopted by @jsc_class, and the #GDestroyNotify passed to jsc_context_register_class() is responsible for disposing of it.
func (*Class) AddConstructorv ¶
func (x *Class) AddConstructorv(NameVar *string, CallbackVar *gobject.Callback, UserDataVar uintptr, DestroyNotifyVar *glib.DestroyNotify, ReturnTypeVar types.GType, NParametersVar uint, ParameterTypesVar []types.GType) *Value
Add a constructor to @jsc_class. If @name is %NULL, the class name will be used. When <function>new</function> is used with the constructor or jsc_value_constructor_call() is called, @callback is invoked receiving the parameters and @user_data as the last parameter. When the constructor object is cleared in the #JSCClass context, @destroy_notify is called with @user_data as parameter.
This function creates the constructor, which needs to be added to an object as a property to be able to use it. Use jsc_context_set_value() to make the constructor available in the global object.
Note that the value returned by @callback is adopted by @jsc_class, and the #GDestroyNotify passed to jsc_context_register_class() is responsible for disposing of it.
func (*Class) AddMethod ¶
func (x *Class) AddMethod(NameVar string, CallbackVar *gobject.Callback, UserDataVar uintptr, DestroyNotifyVar *glib.DestroyNotify, ReturnTypeVar types.GType, NParamsVar uint, varArgs ...interface{})
Add method with @name to @jsc_class. When the method is called by JavaScript or jsc_value_object_invoke_method(), @callback is called receiving the class instance as first parameter, followed by the method parameters and then @user_data as last parameter. When the method is cleared in the #JSCClass context, @destroy_notify is called with @user_data as parameter.
Note that the value returned by @callback must be transfer full. In case of non-refcounted boxed types, you should use %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used. If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created with jsc_value_new_object() that receives the copy as the instance parameter.
func (*Class) AddMethodVariadic ¶
func (x *Class) AddMethodVariadic(NameVar string, CallbackVar *gobject.Callback, UserDataVar uintptr, DestroyNotifyVar *glib.DestroyNotify, ReturnTypeVar types.GType)
Add method with @name to @jsc_class. When the method is called by JavaScript or jsc_value_object_invoke_method(), @callback is called receiving the class instance as first parameter, followed by a #GPtrArray of #JSCValue<!-- -->s with the method arguments and then @user_data as last parameter. When the method is cleared in the #JSCClass context, @destroy_notify is called with @user_data as parameter.
Note that the value returned by @callback must be transfer full. In case of non-refcounted boxed types, you should use %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used. If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created with jsc_value_new_object() that receives the copy as the instance parameter.
func (*Class) AddMethodv ¶
func (x *Class) AddMethodv(NameVar string, CallbackVar *gobject.Callback, UserDataVar uintptr, DestroyNotifyVar *glib.DestroyNotify, ReturnTypeVar types.GType, NParametersVar uint, ParameterTypesVar []types.GType)
Add method with @name to @jsc_class. When the method is called by JavaScript or jsc_value_object_invoke_method(), @callback is called receiving the class instance as first parameter, followed by the method parameters and then @user_data as last parameter. When the method is cleared in the #JSCClass context, @destroy_notify is called with @user_data as parameter.
Note that the value returned by @callback must be transfer full. In case of non-refcounted boxed types, you should use %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used. If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created with jsc_value_new_object() that receives the copy as the instance parameter.
func (*Class) AddProperty ¶
func (x *Class) AddProperty(NameVar string, PropertyTypeVar types.GType, GetterVar *gobject.Callback, SetterVar *gobject.Callback, UserDataVar uintptr, DestroyNotifyVar *glib.DestroyNotify)
Add a property with @name to @jsc_class. When the property value needs to be getted, @getter is called receiving the the class instance as first parameter and @user_data as last parameter. When the property value needs to be set, @setter is called receiving the the class instance as first parameter, followed by the value to be set and then @user_data as the last parameter. When the property is cleared in the #JSCClass context, @destroy_notify is called with @user_data as parameter.
Note that the value returned by @getter must be transfer full. In case of non-refcounted boxed types, you should use %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used. If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created with jsc_value_new_object() that receives the copy as the instance parameter.
func (*Class) GetPropertyName ¶ added in v0.0.4
GetPropertyName gets the "name" property. The name of the class.
func (*Class) SetGoPointer ¶
func (*Class) SetPropertyName ¶ added in v0.0.4
SetPropertyName sets the "name" property. The name of the class.
type ClassClass ¶
type ClassClass struct {
ParentClass gobject.ObjectClass
// contains filtered or unexported fields
}
func (*ClassClass) GoPointer ¶
func (x *ClassClass) GoPointer() uintptr
type ClassDeletePropertyFunction ¶
The type of delete_property in #JSCClassVTable. This is only required when you need to handle external properties not added to the prototype.
type ClassEnumeratePropertiesFunction ¶
The type of enumerate_properties in #JSCClassVTable. This is only required when you need to handle external properties not added to the prototype.
type ClassGetPropertyFunction ¶
The type of get_property in #JSCClassVTable. This is only required when you need to handle external properties not added to the prototype.
type ClassHasPropertyFunction ¶
The type of has_property in #JSCClassVTable. This is only required when you need to handle external properties not added to the prototype.
type ClassSetPropertyFunction ¶
The type of set_property in #JSCClassVTable. This is only required when you need to handle external properties not added to the prototype.
type ClassVTable ¶
type ClassVTable struct {
GetProperty ClassGetPropertyFunction
SetProperty ClassSetPropertyFunction
HasProperty ClassHasPropertyFunction
DeleteProperty ClassDeletePropertyFunction
EnumerateProperties ClassEnumeratePropertiesFunction
// contains filtered or unexported fields
}
Virtual table for a JSCClass. This can be optionally used when registering a #JSCClass in a #JSCContext to provide a custom implementation for the class. All virtual functions are optional and can be set to %NULL to fallback to the default implementation.
func (*ClassVTable) GetJscReserved0 ¶
func (x *ClassVTable) GetJscReserved0() func()
GetJscReserved0 gets the "_jsc_reserved0" callback function.
func (*ClassVTable) GetJscReserved1 ¶
func (x *ClassVTable) GetJscReserved1() func()
GetJscReserved1 gets the "_jsc_reserved1" callback function.
func (*ClassVTable) GetJscReserved2 ¶
func (x *ClassVTable) GetJscReserved2() func()
GetJscReserved2 gets the "_jsc_reserved2" callback function.
func (*ClassVTable) GetJscReserved3 ¶
func (x *ClassVTable) GetJscReserved3() func()
GetJscReserved3 gets the "_jsc_reserved3" callback function.
func (*ClassVTable) GetJscReserved4 ¶
func (x *ClassVTable) GetJscReserved4() func()
GetJscReserved4 gets the "_jsc_reserved4" callback function.
func (*ClassVTable) GetJscReserved5 ¶
func (x *ClassVTable) GetJscReserved5() func()
GetJscReserved5 gets the "_jsc_reserved5" callback function.
func (*ClassVTable) GetJscReserved6 ¶
func (x *ClassVTable) GetJscReserved6() func()
GetJscReserved6 gets the "_jsc_reserved6" callback function.
func (*ClassVTable) GetJscReserved7 ¶
func (x *ClassVTable) GetJscReserved7() func()
GetJscReserved7 gets the "_jsc_reserved7" callback function.
func (*ClassVTable) GoPointer ¶
func (x *ClassVTable) GoPointer() uintptr
func (*ClassVTable) OverrideJscReserved0 ¶
func (x *ClassVTable) OverrideJscReserved0(cb func())
OverrideJscReserved0 sets the "_jsc_reserved0" callback function.
func (*ClassVTable) OverrideJscReserved1 ¶
func (x *ClassVTable) OverrideJscReserved1(cb func())
OverrideJscReserved1 sets the "_jsc_reserved1" callback function.
func (*ClassVTable) OverrideJscReserved2 ¶
func (x *ClassVTable) OverrideJscReserved2(cb func())
OverrideJscReserved2 sets the "_jsc_reserved2" callback function.
func (*ClassVTable) OverrideJscReserved3 ¶
func (x *ClassVTable) OverrideJscReserved3(cb func())
OverrideJscReserved3 sets the "_jsc_reserved3" callback function.
func (*ClassVTable) OverrideJscReserved4 ¶
func (x *ClassVTable) OverrideJscReserved4(cb func())
OverrideJscReserved4 sets the "_jsc_reserved4" callback function.
func (*ClassVTable) OverrideJscReserved5 ¶
func (x *ClassVTable) OverrideJscReserved5(cb func())
OverrideJscReserved5 sets the "_jsc_reserved5" callback function.
func (*ClassVTable) OverrideJscReserved6 ¶
func (x *ClassVTable) OverrideJscReserved6(cb func())
OverrideJscReserved6 sets the "_jsc_reserved6" callback function.
func (*ClassVTable) OverrideJscReserved7 ¶
func (x *ClassVTable) OverrideJscReserved7(cb func())
OverrideJscReserved7 sets the "_jsc_reserved7" callback function.
type Context ¶
JSCContext represents a JavaScript execution context, where all operations take place and where the values will be associated.
When a new context is created, a global object is allocated and the built-in JavaScript objects (Object, Function, String, Array) are populated. You can execute JavaScript in the context by using jsc_context_evaluate() or jsc_context_evaluate_with_source_uri(). It's also possible to register custom objects in the context with jsc_context_register_class().
func ContextGetCurrent ¶
func ContextGetCurrent() *Context
Get the #JSCContext that is currently executing a function. This should only be called within a function or method callback, otherwise %NULL will be returned.
func NewContext ¶
func NewContext() *Context
Create a new #JSCContext. The context is created in a new #JSCVirtualMachine. Use jsc_context_new_with_virtual_machine() to create a new #JSCContext in an existing #JSCVirtualMachine.
func NewContextWithVirtualMachine ¶
func NewContextWithVirtualMachine(VmVar *VirtualMachine) *Context
Create a new #JSCContext in @virtual_machine.
func (*Context) CheckSyntax ¶
func (x *Context) CheckSyntax(CodeVar string, LengthVar int, ModeVar CheckSyntaxMode, UriVar string, LineNumberVar uint, ExceptionVar **Exception) CheckSyntaxResult
Check the given @code in @context for syntax errors. The @line_number is the starting line number in @uri; the value is one-based so the first line is 1. @uri and @line_number are only used to fill the @exception. In case of errors @exception will be set to a new #JSCException with the details. You can pass %NULL to @exception to ignore the error details.
func (*Context) ClearException ¶
func (x *Context) ClearException()
Clear the uncaught exception in @context if any.
func (*Context) EvaluateInObject ¶
func (x *Context) EvaluateInObject(CodeVar string, LengthVar int, ObjectInstanceVar uintptr, ObjectClassVar *Class, UriVar string, LineNumberVar uint, ObjectVar **Value) *Value
Evaluate @code and create an new object where symbols defined in @code will be added as properties, instead of being added to @context global object. The new object is returned as @object parameter. Similar to how jsc_value_new_object() works, if @object_instance is not %NULL @object_class must be provided too. The @line_number is the starting line number in @uri; the value is one-based so the first line is 1. @uri and @line_number will be shown in exceptions and they don't affect the behavior of the script.
func (*Context) EvaluateWithSourceUri ¶
func (x *Context) EvaluateWithSourceUri(CodeVar string, LengthVar int, UriVar string, LineNumberVar uint) *Value
Evaluate @code in @context using @uri as the source URI. The @line_number is the starting line number in @uri; the value is one-based so the first line is 1. @uri and @line_number will be shown in exceptions and they don't affect the behavior of the script.
func (*Context) GetException ¶
Get the last unhandled exception thrown in @context by API functions calls.
func (*Context) GetGlobalObject ¶
Get a #JSCValue referencing the @context global object
func (*Context) GetVirtualMachine ¶
func (x *Context) GetVirtualMachine() *VirtualMachine
Get the #JSCVirtualMachine where @context was created.
func (*Context) PopExceptionHandler ¶
func (x *Context) PopExceptionHandler()
Remove the last #JSCExceptionHandler previously pushed to @context with jsc_context_push_exception_handler().
func (*Context) PushExceptionHandler ¶
func (x *Context) PushExceptionHandler(HandlerVar *ExceptionHandler, UserDataVar uintptr, DestroyNotifyVar *glib.DestroyNotify)
Push an exception handler in @context. Whenever a JavaScript exception happens in the #JSCContext, the given @handler will be called. The default #JSCExceptionHandler simply calls jsc_context_throw_exception() to throw the exception to the #JSCContext. If you don't want to catch the exception, but only get notified about it, call jsc_context_throw_exception() in @handler like the default one does. The last exception handler pushed is the only one used by the #JSCContext, use jsc_context_pop_exception_handler() to remove it and set the previous one. When @handler is removed from the context, @destroy_notify i called with @user_data as parameter.
func (*Context) RegisterClass ¶
func (x *Context) RegisterClass(NameVar string, ParentClassVar *Class, VtableVar *ClassVTable, DestroyNotifyVar *glib.DestroyNotify) *Class
Register a custom class in @context using the given @name. If the new class inherits from another #JSCClass, the parent should be passed as @parent_class, otherwise %NULL should be used. The optional @vtable parameter allows to provide a custom implementation for handling the class, for example, to handle external properties not added to the prototype. When an instance of the #JSCClass is cleared in the context, @destroy_notify is called with the instance as parameter.
func (*Context) SetGoPointer ¶
func (*Context) Throw ¶
Throw an exception to @context using the given error message. The created #JSCException can be retrieved with jsc_context_get_exception().
func (*Context) ThrowException ¶
Throw @exception to @context.
func (*Context) ThrowPrintf ¶
Throw an exception to @context using the given formatted string as error message. The created #JSCException can be retrieved with jsc_context_get_exception().
func (*Context) ThrowWithName ¶
Throw an exception to @context using the given error name and message. The created #JSCException can be retrieved with jsc_context_get_exception().
func (*Context) ThrowWithNamePrintf ¶
func (x *Context) ThrowWithNamePrintf(ErrorNameVar string, FormatVar string, varArgs ...interface{})
Throw an exception to @context using the given error name and the formatted string as error message. The created #JSCException can be retrieved with jsc_context_get_exception().
type ContextClass ¶
type ContextClass struct {
ParentClass gobject.ObjectClass
// contains filtered or unexported fields
}
func (*ContextClass) GoPointer ¶
func (x *ContextClass) GoPointer() uintptr
type Exception ¶
JSCException represents a JavaScript exception.
func NewException ¶
Create a new #JSCException in @context with @message.
func NewExceptionPrintf ¶
Create a new #JSCException in @context using a formatted string for the message.
func NewExceptionVprintf ¶
Create a new #JSCException in @context using a formatted string for the message. This is similar to jsc_exception_new_printf() except that the arguments to the format string are passed as a va_list.
func NewExceptionWithName ¶
Create a new #JSCException in @context with @name and @message.
func NewExceptionWithNamePrintf ¶
func NewExceptionWithNamePrintf(ContextVar *Context, NameVar string, FormatVar string, varArgs ...interface{}) *Exception
Create a new #JSCException in @context with @name and using a formatted string for the message.
func NewExceptionWithNameVprintf ¶
func NewExceptionWithNameVprintf(ContextVar *Context, NameVar string, FormatVar string, ArgsVar []interface{}) *Exception
Create a new #JSCException in @context with @name and using a formatted string for the message. This is similar to jsc_exception_new_with_name_printf() except that the arguments to the format string are passed as a va_list.
func (*Exception) GetBacktraceString ¶
Get a string with the exception backtrace.
func (*Exception) GetColumnNumber ¶
Get the column number at which @exception happened.
func (*Exception) GetLineNumber ¶
Get the line number at which @exception happened.
func (*Exception) GetMessage ¶
Get the error message of @exception.
func (*Exception) GetSourceUri ¶
Get the source URI of @exception.
func (*Exception) Report ¶
Return a report message of @exception, containing all the possible details such us source URI, line, column and backtrace, and formatted to be printed.
func (*Exception) SetGoPointer ¶
type ExceptionClass ¶
type ExceptionClass struct {
ParentClass gobject.ObjectClass
// contains filtered or unexported fields
}
func (*ExceptionClass) GoPointer ¶
func (x *ExceptionClass) GoPointer() uintptr
type ExceptionHandler ¶
Function used to handle JavaScript exceptions in a #JSCContext.
type Executor ¶
A function passed to @jsc_value_new_promise called during initialization
It is called like a JavaScript function, so exceptions raised will not be propagated to the context, but handled by the promise causing a rejection. @resolve and @reject can be reffed for later use to handle async task completion.
type OptionType ¶
type OptionType int
Enum values for options types.
const ( // A #gboolean option type. JscOptionBooleanValue OptionType = 0 // A #gint option type. JscOptionIntValue OptionType = 1 // A #guint option type. JscOptionUintValue OptionType = 2 // A #gsize options type. JscOptionSizeValue OptionType = 3 // A #gdouble options type. JscOptionDoubleValue OptionType = 4 // A string option type. JscOptionStringValue OptionType = 5 // A range string option type. JscOptionRangeStringValue OptionType = 6 )
type OptionsFunc ¶
type OptionsFunc func(string, OptionType, string, uintptr) bool
Function used to iterate options.
Not that @description string is not localized.
type TypedArrayType ¶
type TypedArrayType int
Possible types of the elements contained in a typed array.
const ( // Not a typed array, or type unsupported. JscTypedArrayNoneValue TypedArrayType = 0 // Array elements are 8-bit signed integers (int8_t). JscTypedArrayInt8Value TypedArrayType = 1 // Array elements are 16-bit signed integers (int16_t). JscTypedArrayInt16Value TypedArrayType = 2 // Array elements are 32-bit signed integers (int32_t). JscTypedArrayInt32Value TypedArrayType = 3 // Array elements are 64-bit signed integers (int64_t). JscTypedArrayInt64Value TypedArrayType = 4 // Array elements are 8-bit unsigned integers (uint8_t). JscTypedArrayUint8Value TypedArrayType = 5 // Array elements are 8-bit unsigned integers (uint8_t). JscTypedArrayUint8ClampedValue TypedArrayType = 6 // Array elements are 16-bit unsigned integers (uint16_t). JscTypedArrayUint16Value TypedArrayType = 7 // Array elements are 32-bit unsigned integers (uint32_t). JscTypedArrayUint32Value TypedArrayType = 8 // Array elements are 64-bit unsigned integers (uint64_t). JscTypedArrayUint64Value TypedArrayType = 9 // Array elements are 32-bit floating point numbers (float). JscTypedArrayFloat32Value TypedArrayType = 10 // Array elements are 64-bit floating point numbers (double). JscTypedArrayFloat64Value TypedArrayType = 11 )
type Value ¶
JSCValue represents a reference to a value in a #JSCContext. The JSCValue protects the referenced value from being garbage collected.
func NewValueArray ¶
func NewValueArray(ContextVar *Context, FirstItemTypeVar types.GType, varArgs ...interface{}) *Value
Create a new #JSCValue referencing an array with the given items. If @first_item_type is %G_TYPE_NONE an empty array is created.
func NewValueArrayBuffer ¶
func NewValueArrayBuffer(ContextVar *Context, DataVar uintptr, SizeVar uint, DestroyNotifyVar *glib.DestroyNotify, UserDataVar uintptr) *Value
Creates a new %ArrayBuffer from existing @data in memory.
The @data is not copied: while this allows sharing data with JavaScript efficiently, the caller must ensure that the memory region remains valid until the newly created object is released by JSC.
Optionally, a @destroy_notify callback can be provided, which will be invoked with @user_data as parameter when the %ArrayBuffer object is released. This is intended to be used for freeing resources related to the memory region which contains the data:
|[!<-- language="C" --> GMappedFile *f = g_mapped_file_new (file_path, TRUE, NULL); JSCValue *value = jsc_value_new_array_buffer (context,
g_mapped_file_get_contents (f), g_mapped_file_get_length (f), (GDestroyNotify) g_mapped_file_unref, f);
]|
Note that the @user_data can be the same value as @data:
|[!<-- language="C" --> void *bytes = g_malloc0 (100); JSCValue *value = jsc_value_new_array_buffer (context, bytes, 100, g_free, bytes); ]|
func NewValueArrayFromGarray ¶
Create a new #JSCValue referencing an array with the items from @array. If @array is %NULL or empty a new empty array will be created. Elements of @array should be pointers to a #JSCValue.
func NewValueArrayFromStrv ¶
Create a new #JSCValue referencing an array of strings with the items from @strv. If @array is %NULL or empty a new empty array will be created.
func NewValueBoolean ¶
Create a new #JSCValue from @value
func NewValueFromJson ¶
Create a new #JSCValue referencing a new value created by parsing @json.
func NewValueFunction ¶
func NewValueFunction(ContextVar *Context, NameVar *string, CallbackVar *gobject.Callback, UserDataVar uintptr, DestroyNotifyVar *glib.DestroyNotify, ReturnTypeVar types.GType, NParamsVar uint, varArgs ...interface{}) *Value
Create a function in @context. If @name is %NULL an anonymous function will be created. When the function is called by JavaScript or jsc_value_function_call(), @callback is called receiving the function parameters and then @user_data as last parameter. When the function is cleared in @context, @destroy_notify is called with @user_data as parameter.
Note that the value returned by @callback must be fully transferred. In case of boxed types, you could use %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used. If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created with jsc_value_new_object() that receives the copy as instance parameter.
func NewValueFunctionVariadic ¶
func NewValueFunctionVariadic(ContextVar *Context, NameVar *string, CallbackVar *gobject.Callback, UserDataVar uintptr, DestroyNotifyVar *glib.DestroyNotify, ReturnTypeVar types.GType) *Value
Create a function in @context. If @name is %NULL an anonymous function will be created. When the function is called by JavaScript or jsc_value_function_call(), @callback is called receiving an #GPtrArray of #JSCValue<!-- -->s with the arguments and then @user_data as last parameter. When the function is cleared in @context, @destroy_notify is called with @user_data as parameter.
Note that the value returned by @callback must be fully transferred. In case of boxed types, you could use %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used. If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created with jsc_value_new_object() that receives the copy as instance parameter.
func NewValueFunctionv ¶
func NewValueFunctionv(ContextVar *Context, NameVar *string, CallbackVar *gobject.Callback, UserDataVar uintptr, DestroyNotifyVar *glib.DestroyNotify, ReturnTypeVar types.GType, NParametersVar uint, ParameterTypesVar []types.GType) *Value
Create a function in @context. If @name is %NULL an anonymous function will be created. When the function is called by JavaScript or jsc_value_function_call(), @callback is called receiving the function parameters and then @user_data as last parameter. When the function is cleared in @context, @destroy_notify is called with @user_data as parameter.
Note that the value returned by @callback must be fully transferred. In case of boxed types, you could use %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used. If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created with jsc_value_new_object() that receives the copy as instance parameter.
func NewValueNull ¶
Create a new #JSCValue referencing <function>null</function> in @context.
func NewValueNumber ¶
Create a new #JSCValue from @number.
func NewValueObject ¶
Create a new #JSCValue from @instance. If @instance is %NULL a new empty object is created. When @instance is provided, @jsc_class must be provided too. @jsc_class takes ownership of @instance that will be freed by the #GDestroyNotify passed to jsc_context_register_class().
func NewValuePromise ¶
Creates a new Promise. @executor will be invoked during promise initialization and it receives the @resolve and @reject objects than can be called to resolve or reject the promise. It is called like a JavaScript function, so exceptions raised during the executor invocation will not be propagated to the context, but handled by the promise causing a rejection.
func NewValueString ¶
Create a new #JSCValue from @string. If you need to create a #JSCValue from a string containing null characters, use jsc_value_new_string_from_bytes() instead.
func NewValueStringFromBytes ¶
Create a new #JSCValue from @bytes.
func NewValueTypedArray ¶
func NewValueTypedArray(ContextVar *Context, TypeVar TypedArrayType, LengthVar uint) *Value
Create a new typed array containing a given amount of elements.
Create a #JSCValue referencing a new typed array with space for @length elements of a given @type. As all typed arrays must have an associated `ArrayBuffer`, a new one of suitable size will be allocated to store the elements, which will be initialized to zero.
The @type must *not* be %JSC_TYPED_ARRAY_NONE.
func NewValueUndefined ¶
Create a new #JSCValue referencing <function>undefined</function> in @context.
func ValueNewFromInternalPtr ¶
func (*Value) ArrayBufferGetData ¶
Gets a pointer to memory that contains the array buffer data.
Obtains a pointer to the memory region that holds the contents of the %ArrayBuffer; modifications done to the data will be visible to JavaScript code. If @size is not %NULL, the size in bytes of the memory region will also be stored in the pointed location.
Note that the pointer returned by this function is not guaranteed to remain the same after calls to other JSC API functions. If you plan to access the data of the %ArrayBuffer later, you can keep a reference to the @value and obtain the data pointer at a later point. Keep in mind that if JavaScript code has a chance to run, for example due to main loop events that result in JSC being called, the contents of the memory region might be modified in the meantime. Consider taking a copy of the data and using the copy instead in asynchronous code.
func (*Value) ArrayBufferGetSize ¶
Gets the size in bytes of the array buffer.
Obtains the size in bytes of the memory region that holds the contents of an %ArrayBuffer.
func (*Value) ConstructorCall ¶
Invoke <function>new</function> with constructor referenced by @value. If @first_parameter_type is %G_TYPE_NONE no parameters will be passed to the constructor.
func (*Value) ConstructorCallv ¶
Invoke <function>new</function> with constructor referenced by @value. If @n_parameters is 0 no parameters will be passed to the constructor.
func (*Value) FunctionCall ¶
Call function referenced by @value, passing the given parameters. If @first_parameter_type is %G_TYPE_NONE no parameters will be passed to the function.
This function always returns a #JSCValue, in case of void functions a #JSCValue referencing <function>undefined</function> is returned
func (*Value) FunctionCallv ¶
Call function referenced by @value, passing the given @parameters. If @n_parameters is 0 no parameters will be passed to the function.
This function always returns a #JSCValue, in case of void functions a #JSCValue referencing <function>undefined</function> is returned
func (*Value) GetContext ¶
Get the #JSCContext in which @value was created.
func (*Value) IsArrayBuffer ¶
Check whether the @value is an %ArrayBuffer.
func (*Value) IsConstructor ¶
Get whether the value referenced by @value is a constructor.
func (*Value) IsFunction ¶
Get whether the value referenced by @value is a function
func (*Value) IsNull ¶
Get whether the value referenced by @value is <function>null</function>.
func (*Value) IsTypedArray ¶
Determines whether a value is a typed array.
func (*Value) IsUndefined ¶
Get whether the value referenced by @value is <function>undefined</function>.
func (*Value) NewTypedArrayWithBuffer ¶
func (x *Value) NewTypedArrayWithBuffer(TypeVar TypedArrayType, OffsetVar uint, LengthVar int) *Value
Create a new typed array value with elements from an array buffer.
Create a #JSCValue referencing a new typed array value containing elements of the given @type, where the elements are stored at the memory region represented by the @array_buffer.
The @type must *not* be %JSC_TYPED_ARRAY_NONE.
The @offset and @length parameters can be used to indicate which part of the array buffer can be accessed through the typed array. If both are omitted (passing zero as @offset, and `-1` as @length), the whole @array_buffer is exposed through the typed array. Omitting the @length with a non-zero @offset will expose the remainder of the @array_buffer starting at the indicated offset.
func (*Value) ObjectDefinePropertyAccessor ¶
func (x *Value) ObjectDefinePropertyAccessor(PropertyNameVar string, FlagsVar ValuePropertyFlags, PropertyTypeVar types.GType, GetterVar *gobject.Callback, SetterVar *gobject.Callback, UserDataVar uintptr, DestroyNotifyVar *glib.DestroyNotify)
Define or modify a property with @property_name in object referenced by @value. When the property value needs to be getted or set, @getter and @setter callbacks will be called. When the property is cleared in the #JSCClass context, @destroy_notify is called with @user_data as parameter. This is equivalent to JavaScript <function>Object.defineProperty()</function> when used with an accessor descriptor.
Note that the value returned by @getter must be fully transferred. In case of boxed types, you could use %G_TYPE_POINTER instead of the actual boxed #GType to ensure that the instance owned by #JSCClass is used. If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a #JSCValue created with jsc_value_new_object() that receives the copy as instance parameter.
Note that @getter and @setter are called as functions and not methods, so they don't receive an instance as first parameter. Use jsc_class_add_property() if you want to add property accessor invoked as a method.
func (*Value) ObjectDefinePropertyData ¶
func (x *Value) ObjectDefinePropertyData(PropertyNameVar string, FlagsVar ValuePropertyFlags, PropertyValueVar *Value)
Define or modify a property with @property_name in object referenced by @value. This is equivalent to JavaScript <function>Object.defineProperty()</function> when used with a data descriptor.
func (*Value) ObjectDeleteProperty ¶
Try to delete property with @name from @value. This function will return %FALSE if the property was defined without %JSC_VALUE_PROPERTY_CONFIGURABLE flag.
func (*Value) ObjectEnumerateProperties ¶
Get the list of property names of @value. Only properties defined with %JSC_VALUE_PROPERTY_ENUMERABLE flag will be collected.
func (*Value) ObjectGetProperty ¶
Get property with @name from @value.
func (*Value) ObjectGetPropertyAtIndex ¶
Get property at @index from @value.
func (*Value) ObjectHasProperty ¶
Get whether @value has property with @name.
func (*Value) ObjectInvokeMethod ¶
func (x *Value) ObjectInvokeMethod(NameVar string, FirstParameterTypeVar types.GType, varArgs ...interface{}) *Value
Invoke method with @name on object referenced by @value, passing the given parameters. If @first_parameter_type is %G_TYPE_NONE no parameters will be passed to the method. The object instance will be handled automatically even when the method is a custom one registered with jsc_class_add_method(), so it should never be passed explicitly as parameter of this function.
This function always returns a #JSCValue, in case of void methods a #JSCValue referencing <function>undefined</function> is returned.
func (*Value) ObjectInvokeMethodv ¶
func (x *Value) ObjectInvokeMethodv(NameVar string, NParametersVar uint, ParametersVar []Value) *Value
Invoke method with @name on object referenced by @value, passing the given @parameters. If @n_parameters is 0 no parameters will be passed to the method. The object instance will be handled automatically even when the method is a custom one registered with jsc_class_add_method(), so it should never be passed explicitly as parameter of this function.
This function always returns a #JSCValue, in case of void methods a #JSCValue referencing <function>undefined</function> is returned.
func (*Value) ObjectIsInstanceOf ¶
Get whether the value referenced by @value is an instance of class @name.
func (*Value) ObjectSetProperty ¶
Set @property with @name on @value.
func (*Value) ObjectSetPropertyAtIndex ¶
Set @property at @index on @value.
func (*Value) SetGoPointer ¶
func (*Value) ToJson ¶
Create a JSON string of @value serialization. If @indent is 0, the resulting JSON will not contain newlines. The size of the indent is clamped to 10 spaces.
func (*Value) ToString ¶
Convert @value to a string. Use jsc_value_to_string_as_bytes() instead, if you need to handle strings containing null characters.
func (*Value) ToStringAsBytes ¶
Convert @value to a string and return the results as #GBytes. This is needed to handle strings with null characters.
func (*Value) TypedArrayGetBuffer ¶
Obtain the %ArrayBuffer for the memory region of the typed array elements.
func (*Value) TypedArrayGetData ¶
Obtains a pointer to the memory region that holds the elements of the typed array; modifications done to them will be visible to JavaScript code. If @length is not %NULL, the number of elements contained in the typed array are also stored in the pointed location.
The returned pointer needs to be casted to the appropriate type (see #JSCTypedArrayType), and has the `offset` over the underlying array buffer data applied—that is, points to the first element of the typed array:
|[<!-- language="C" --> if (jsc_value_typed_array_get_type(value) != JSC_TYPED_ARRAY_UINT32)
g_error ("Only arrays of uint32_t are supported");
gsize count = 0; uint32_t *elements = jsc_value_typed_array_get_contents (value, &count); for (gsize i = 0; i < count; i++)
g_print ("index %zu, value %" PRIu32 "\n", i, elements[i]);
]|
Note that the pointer returned by this function is not guaranteed to remain the same after calls to other JSC API functions. See jsc_value_array_buffer_get_data() for details.
func (*Value) TypedArrayGetLength ¶
Gets the number of elements in a typed array.
func (*Value) TypedArrayGetOffset ¶
Gets the offset over the underlying array buffer data.
func (*Value) TypedArrayGetSize ¶
Gets the size of a typed array.
func (*Value) TypedArrayGetType ¶
func (x *Value) TypedArrayGetType() TypedArrayType
Gets the type of elements contained in a typed array.
type ValueClass ¶
type ValueClass struct {
ParentClass gobject.ObjectClass
// contains filtered or unexported fields
}
func (*ValueClass) GoPointer ¶
func (x *ValueClass) GoPointer() uintptr
type ValuePropertyFlags ¶
type ValuePropertyFlags int
Flags used when defining properties with jsc_value_object_define_property_data() and jsc_value_object_define_property_accessor().
const ( // the type of the property descriptor may be changed and the // property may be deleted from the corresponding object. JscValuePropertyConfigurableValue ValuePropertyFlags = 1 // the property shows up during enumeration of the properties on // the corresponding object. JscValuePropertyEnumerableValue ValuePropertyFlags = 2 // the value associated with the property may be changed with an // assignment operator. This doesn't have any effect when passed to jsc_value_object_define_property_accessor(). JscValuePropertyWritableValue ValuePropertyFlags = 4 )
type VirtualMachine ¶
JSCVirtualMachine represents a group of JSCContext<!-- -->s. It allows concurrent JavaScript execution by creating a different instance of JSCVirtualMachine in each thread.
To create a group of JSCContext<!-- -->s pass the same JSCVirtualMachine instance to every JSCContext constructor.
func VirtualMachineNewFromInternalPtr ¶
func VirtualMachineNewFromInternalPtr(ptr uintptr) *VirtualMachine
func (*VirtualMachine) GoPointer ¶
func (c *VirtualMachine) GoPointer() uintptr
func (*VirtualMachine) SetGoPointer ¶
func (c *VirtualMachine) SetGoPointer(ptr uintptr)
type VirtualMachineClass ¶
type VirtualMachineClass struct {
ParentClass gobject.ObjectClass
// contains filtered or unexported fields
}
func (*VirtualMachineClass) GoPointer ¶
func (x *VirtualMachineClass) GoPointer() uintptr
type WeakValue ¶
JSCWeakValue represents a weak reference to a value in a #JSCContext. It can be used to keep a reference to a JavaScript value without protecting it from being garbage collected and without referencing the #JSCContext either.
func NewWeakValue ¶
Create a new #JSCWeakValue for the JavaScript value referenced by @value.
func (*WeakValue) ConnectCleared ¶
This signal is emitted when the JavaScript value is destroyed.
func (*WeakValue) SetGoPointer ¶
type WeakValueClass ¶
type WeakValueClass struct {
ParentClass gobject.ObjectClass
// contains filtered or unexported fields
}
func (*WeakValueClass) GoPointer ¶
func (x *WeakValueClass) GoPointer() uintptr