Check the version of JSC header files at compile time.
major version (e.g. 1 for version 1.2.5)
minor version (e.g. 2 for version 1.2.5)
micro version (e.g. 5 for version 1.2.5)
Enum values to specify a mode to check for syntax errors in jsc_context_check_syntax().
mode to check syntax of a script
mode to check syntax of a module
Enum values to specify the result of jsc_context_check_syntax().
no errors
recoverable syntax error
irrecoverable syntax error
unterminated literal error
out of memory error
stack overflow error
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.
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.
a #JSCValue representing the class constructor.
a #JSCClass
the constructor name or %NULL
a #GCallback to be called to create an instance of @jsc_class
user data to pass to @callback
destroy notifier for @user_data
the #GType of the constructor return value
the number of parameter types to follow or 0 if constructor doesn't receive parameters.
a list of #GType<!-- -->s, one for each parameter.
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.
a #JSCValue representing the class constructor.
a #JSCClass
the constructor name or %NULL
a #GCallback to be called to create an instance of @jsc_class
user data to pass to @callback
destroy notifier for @user_data
the #GType of the constructor return 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.
a #JSCValue representing the class constructor.
a #JSCClass
the constructor name or %NULL
a #GCallback to be called to create an instance of @jsc_class
user data to pass to @callback
destroy notifier for @user_data
the #GType of the constructor return value
the number of parameters
a list of #GType<!-- -->s, one for each parameter, or %NULL
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.
a #JSCClass
the method name
a #GCallback to be called to invoke method @name of @jsc_class
user data to pass to @callback
destroy notifier for @user_data
the #GType of the method return value, or %G_TYPE_NONE if the method is void.
the number of parameter types to follow or 0 if the method doesn't receive parameters.
a list of #GType<!-- -->s, one for each parameter.
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.
a #JSCClass
the method name
a #GCallback to be called to invoke method @name of @jsc_class
user data to pass to @callback
destroy notifier for @user_data
the #GType of the method return value, or %G_TYPE_NONE if the method is void.
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.
a #JSCClass
the method name
a #GCallback to be called to invoke method @name of @jsc_class
user data to pass to @callback
destroy notifier for @user_data
the #GType of the method return value, or %G_TYPE_NONE if the method is void.
the number of parameter types to follow or 0 if the method doesn't receive parameters.
a list of #GType<!-- -->s, one for each parameter, or %NULL
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.
a #JSCClass
the property name
the #GType of the property value
a #GCallback to be called to get the property value
a #GCallback to be called to set the property value
user data to pass to @getter and @setter
destroy notifier for @user_data
Get the class name of @jsc_class
the name of @jsc_class
a @JSCClass
Get the parent class of @jsc_class
the parent class of @jsc_class
a @JSCClass
The #JSCContext in which the class was registered.
The name of the class.
The parent class or %NULL in case of final classes.
The type of delete_property in #JSCClassVTable. This is only required when you need to handle
external properties not added to the prototype.
%TRUE if handled or %FALSE to to forward the request to the parent class or prototype chain.
a #JSCClass
a #JSCContext
the @jsc_class instance
the property name
The type of enumerate_properties in #JSCClassVTable. This is only required when you need to handle
external properties not added to the prototype.
a %NULL-terminated array of strings
containing the property names, or %NULL if @instance doesn't have enumerable properties.
a #JSCClass
a #JSCContext
the @jsc_class instance
The type of get_property in #JSCClassVTable. This is only required when you need to handle
external properties not added to the prototype.
a #JSCValue or %NULL to forward the request to
the parent class or prototype chain
a #JSCClass
a #JSCContext
the @jsc_class instance
the property name
The type of has_property in #JSCClassVTable. This is only required when you need to handle
external properties not added to the prototype.
%TRUE if @instance has a property with @name or %FALSE to forward the request
to the parent class or prototype chain.
a #JSCClass
a #JSCContext
the @jsc_class instance
the property name
The type of set_property in #JSCClassVTable. This is only required when you need to handle
external properties not added to the prototype.
%TRUE if handled or %FALSE to forward the request to the parent class or prototype chain.
a #JSCClass
a #JSCContext
the @jsc_class instance
the property name
the #JSCValue to set
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.
a #JSCClassGetPropertyFunction for getting a property.
a #JSCClassSetPropertyFunction for setting a property.
a #JSCClassHasPropertyFunction for querying a property.
a #JSCClassDeletePropertyFunction for deleting a property.
a #JSCClassEnumeratePropertiesFunction for enumerating properties.
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().
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.
the newly created #JSCContext.
Create a new #JSCContext in @virtual_machine.
the newly created #JSCContext.
a #JSCVirtualMachine
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.
the #JSCContext that is currently executing.
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.
a #JSCCheckSyntaxResult
a #JSCContext
a JavaScript script to check
length of @code, or -1 if @code is a nul-terminated string
a #JSCCheckSyntaxMode
the source URI
the starting line number
return location for a #JSCException, or %NULL to ignore
Clear the uncaught exception in @context if any.
a #JSCContext
Evaluate @code in @context.
a #JSCValue representing the last value generated by the script.
a #JSCContext
a JavaScript script to evaluate
length of @code, or -1 if @code is a nul-terminated string
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.
a #JSCValue representing the last value generated by the script.
a #JSCContext
a JavaScript script to evaluate
length of @code, or -1 if @code is a nul-terminated string
an object instance
a #JSCClass or %NULL to use the default
the source URI
the starting line number
return location for a #JSCValue.
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.
a #JSCValue representing the last value generated by the script.
a #JSCContext
a JavaScript script to evaluate
length of @code, or -1 if @code is a nul-terminated string
the source URI
the starting line number
Get the last unhandled exception thrown in @context by API functions calls.
a #JSCException or %NULL if there isn't any
unhandled exception in the #JSCContext.
a #JSCContext
Get a #JSCValue referencing the @context global object
a #JSCValue
a #JSCContext
Get a property of @context global object with @name.
a #JSCValue
a #JSCContext
the value name
Get the #JSCVirtualMachine where @context was created.
the #JSCVirtualMachine where the #JSCContext was created.
a #JSCContext
Remove the last #JSCExceptionHandler previously pushed to @context with
jsc_context_push_exception_handler().
a #JSCContext
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.
a #JSCContext
a #JSCExceptionHandler
user data to pass to @handler
destroy notifier for @user_data
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.
a #JSCClass
a #JSCContext
the class name
a #JSCClass or %NULL
an optional #JSCClassVTable or %NULL
a destroy notifier for class instances
Set a property of @context global object with @name and @value.
a #JSCContext
the value name
a #JSCValue
Throw an exception to @context using the given error message. The created #JSCException
can be retrieved with jsc_context_get_exception().
a #JSCContext
an error message
Throw @exception to @context.
a #JSCContext
a #JSCException
Throw an exception to @context using the given formatted string as error message.
The created #JSCException can be retrieved with jsc_context_get_exception().
a #JSCContext
the string format
the parameters to insert into the format string
Throw an exception to @context using the given error name and message. The created #JSCException
can be retrieved with jsc_context_get_exception().
a #JSCContext
the error name
an error message
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().
a #JSCContext
the error name
the string format
the parameters to insert into the format string
The #JSCVirtualMachine in which the context was created.
JSCException represents a JavaScript exception.
Create a new #JSCException in @context with @message.
a new #JSCException.
a #JSCContext
the error message
Create a new #JSCException in @context using a formatted string
for the message.
a new #JSCException.
a #JSCContext
the string format
the parameters to insert into the format string
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.
a new #JSCException.
a #JSCContext
the string format
the parameters to insert into the format string
Create a new #JSCException in @context with @name and @message.
a new #JSCException.
a #JSCContext
the error name
the error message
Create a new #JSCException in @context with @name and using a formatted string
for the message.
a new #JSCException.
a #JSCContext
the error name
the string format
the parameters to insert into the format string
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.
a new #JSCException.
a #JSCContext
the error name
the string format
the parameters to insert into the format string
Get a string with the exception backtrace.
the exception backtrace string or %NULL.
a #JSCException
Get the column number at which @exception happened.
the column number of @exception.
a #JSCException
Get the line number at which @exception happened.
the line number of @exception.
a #JSCException
Get the error message of @exception.
the @exception error message.
a #JSCException
Get the error name of @exception
the @exception error name.
a #JSCException
Get the source URI of @exception.
the the source URI of @exception, or %NULL.
a #JSCException
Return a report message of @exception, containing all the possible details such us
source URI, line, column and backtrace, and formatted to be printed.
a new string with the exception report
a #JSCException
Get the string representation of @exception error.
the string representation of @exception.
a #JSCException
Function used to handle JavaScript exceptions in a #JSCContext.
a #JSCContext
a #JSCException
user data
JavaScript options allow changing the behavior of the JavaScript engine.
They affect the way the engine works, so the options must be set
at the very beginning of the program execution, before any other JavaScript
API call. Most of the options are only useful for testing and debugging.
Only a few of them are documented; you can use the undocumented options at
your own risk. (You can find the list of options in the WebKit source code).
The API allows to set and get any option using the types defined in #JSCOptionType.
You can also iterate all the available options using jsc_options_foreach() and
passing a #JSCOptionsFunc callback. If your application uses #GOptionContext to handle
command line arguments, you can easily integrate the JSCOptions by adding the
#GOptionGroup returned by jsc_options_get_option_group().
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.
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.
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.
Allows the DFG JIT to be used if %TRUE.
Option type: %JSC_OPTION_BOOLEAN
Default value: %TRUE.
Allows the FTL JIT to be used if %TRUE.
Option type: %JSC_OPTION_BOOLEAN
Default value: %TRUE.
Allows the executable pages to be allocated for JIT and thunks if %TRUE.
Option type: %JSC_OPTION_BOOLEAN
Default value: %TRUE.
Allows the LLINT to be used if %TRUE.
Option type: %JSC_OPTION_BOOLEAN
Default value: %TRUE.
Enum values for options types.
A #gboolean option type.
A #gint option type.
A #guint option type.
A #gsize options type.
A #gdouble options type.
A string option type.
A range string option type.
Function used to iterate options.
Not that @description string is not localized.
%TRUE to stop the iteration, or %FALSE otherwise
the option name
the option #JSCOptionType
the option description, or %NULL
user data
Possible types of the elements contained in a typed array.
Not a typed array, or type unsupported.
Array elements are 8-bit signed integers (int8_t).
Array elements are 16-bit signed integers (int16_t).
Array elements are 32-bit signed integers (int32_t).
Array elements are 64-bit signed integers (int64_t).
Array elements are 8-bit unsigned integers (uint8_t).
Array elements are 8-bit unsigned integers (uint8_t).
Array elements are 16-bit unsigned integers (uint16_t).
Array elements are 32-bit unsigned integers (uint32_t).
Array elements are 64-bit unsigned integers (uint64_t).
Array elements are 32-bit floating point numbers (float).
Array elements are 64-bit floating point numbers (double).
JSCValue represents a reference to a value in a #JSCContext. The JSCValue
protects the referenced value from being garbage collected.
Create a new #JSCValue referencing an array with the given items. If @first_item_type
is %G_TYPE_NONE an empty array is created.
a #JSCValue.
a #JSCContext
#GType of first item, or %G_TYPE_NONE
value of the first item, followed optionally by more type/value pairs, followed by %G_TYPE_NONE.
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);
]|
A #JSCValue, or %NULL in case of exception.
A #JSCContext
Pointer to a region of memory.
Size in bytes of the memory region.
destroy notifier for @user_data.
user data.
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.
a #JSCValue.
a #JSCContext
a #GPtrArray
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.
a #JSCValue.
a #JSCContext
a %NULL-terminated array of strings
Create a new #JSCValue from @value
a #JSCValue.
a #JSCContext
a #gboolean
Create a new #JSCValue referencing a new value created by parsing @json.
a #JSCValue.
a #JSCContext
the JSON string to be parsed
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.
a #JSCValue.
a #JSCContext:
the function name or %NULL
a #GCallback.
user data to pass to @callback.
destroy notifier for @user_data
the #GType of the function return value, or %G_TYPE_NONE if the function is void.
the number of parameter types to follow or 0 if the function doesn't receive parameters.
a list of #GType<!-- -->s, one for each parameter.
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.
a #JSCValue.
a #JSCContext
the function name or %NULL
a #GCallback.
user data to pass to @callback.
destroy notifier for @user_data
the #GType of the function return value, or %G_TYPE_NONE if the function is void.
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.
a #JSCValue.
a #JSCContext
the function name or %NULL
a #GCallback.
user data to pass to @callback.
destroy notifier for @user_data
the #GType of the function return value, or %G_TYPE_NONE if the function is void.
the number of parameters
a list of #GType<!-- -->s, one for each parameter, or %NULL
Create a new #JSCValue referencing <function>null</function> in @context.
a #JSCValue.
a #JSCContext
Create a new #JSCValue from @number.
a #JSCValue.
a #JSCContext
a number
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().
a #JSCValue.
a #JSCContext
an object instance or %NULL
the #JSCClass of @instance
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.
a #JSCValue.
a #JSCContext
a null-terminated string
Create a new #JSCValue from @bytes.
a #JSCValue.
a #JSCContext
a #GBytes
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.
a #JSCValue
a #JSCContext
the type of array elements
number of elements in the array
Create a new #JSCValue referencing <function>undefined</function> in @context.
a #JSCValue.
a #JSCContext
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.
pointer to memory.
A #JSCValue
location where to store the size of the memory region.
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.
size, in bytes.
A #JSCValue
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.
a #JSCValue referencing the newly created object instance.
a #JSCValue
#GType of first parameter, or %G_TYPE_NONE
value of the first parameter, followed optionally by more type/value pairs, followed by %G_TYPE_NONE
Invoke <function>new</function> with constructor referenced by @value. If @n_parameters
is 0 no parameters will be passed to the constructor.
a #JSCValue referencing the newly created object instance.
a #JSCValue
the number of parameters
the #JSCValue<!-- -->s to pass as parameters to the constructor, or %NULL
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
a #JSCValue with the return value of the function.
a #JSCValue
#GType of first parameter, or %G_TYPE_NONE
value of the first parameter, followed optionally by more type/value pairs, followed by %G_TYPE_NONE
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
a #JSCValue with the return value of the function.
a #JSCValue
the number of parameters
the #JSCValue<!-- -->s to pass as parameters to the function, or %NULL
Get the #JSCContext in which @value was created.
the #JSCValue context.
a #JSCValue
Get whether the value referenced by @value is an array.
whether the value is an array.
a #JSCValue
Check whether the @value is an %ArrayBuffer.
whether the value is an %ArrayBuffer
A #JSCValue.
Get whether the value referenced by @value is a boolean.
whether the value is a boolean.
a #JSCValue
Get whether the value referenced by @value is a constructor.
whether the value is a constructor.
a #JSCValue
Get whether the value referenced by @value is a function
whether the value is a function.
a #JSCValue
Get whether the value referenced by @value is <function>null</function>.
whether the value is null.
a #JSCValue
Get whether the value referenced by @value is a number.
whether the value is a number.
a #JSCValue
Get whether the value referenced by @value is an object.
whether the value is an object.
a #JSCValue
Get whether the value referenced by @value is a string
whether the value is a string
a #JSCValue
Determines whether a value is a typed array.
Whether @value is a typed array.
a #JSCValue
Get whether the value referenced by @value is <function>undefined</function>.
whether the value is undefined.
a #JSCValue
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.
a #JSCValue
a #JSCValue.
type of array elements.
offset, in bytes.
number of array elements, or `-1`.
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.
a #JSCValue
the name of the property to define
#JSCValuePropertyFlags
the #GType of the property
a #GCallback to be called to get the property value
a #GCallback to be called to set the property value
user data to pass to @getter and @setter
destroy notifier for @user_data
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.
a #JSCValue
the name of the property to define
#JSCValuePropertyFlags
the default property value
Try to delete property with @name from @value. This function will return %FALSE if
the property was defined without %JSC_VALUE_PROPERTY_CONFIGURABLE flag.
%TRUE if the property was deleted, or %FALSE otherwise.
a #JSCValue
the property name
Get the list of property names of @value. Only properties defined with %JSC_VALUE_PROPERTY_ENUMERABLE
flag will be collected.
a %NULL-terminated array of strings containing the
property names, or %NULL if @value doesn't have enumerable properties. Use g_strfreev() to free.
a #JSCValue
Get property with @name from @value.
the property #JSCValue.
a #JSCValue
the property name
Get property at @index from @value.
the property #JSCValue.
a #JSCValue
the property index
Get whether @value has property with @name.
%TRUE if @value has a property with @name, or %FALSE otherwise
a #JSCValue
the property name
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.
a #JSCValue with the return value of the method.
a #JSCValue
the method name
#GType of first parameter, or %G_TYPE_NONE
value of the first parameter, followed optionally by more type/value pairs, followed by %G_TYPE_NONE
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.
a #JSCValue with the return value of the method.
a #JSCValue
the method name
the number of parameters
the #JSCValue<!-- -->s to pass as parameters to the method, or %NULL
Get whether the value referenced by @value is an instance of class @name.
whether the value is an object instance of class @name.
a #JSCValue
a class name
Set @property with @name on @value.
a #JSCValue
the property name
the #JSCValue to set
Set @property at @index on @value.
a #JSCValue
the property index
the #JSCValue to set
Convert @value to a boolean.
a #gboolean result of the conversion.
a #JSCValue
Convert @value to a double.
a #gdouble result of the conversion.
a #JSCValue
Convert @value to a #gint32.
a #gint32 result of the conversion.
a #JSCValue
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.
a null-terminated JSON string with serialization of @value
a #JSCValue
The number of spaces to indent when nesting.
Convert @value to a string. Use jsc_value_to_string_as_bytes() instead, if you need to
handle strings containing null characters.
a null-terminated string result of the conversion.
a #JSCValue
Convert @value to a string and return the results as #GBytes. This is needed
to handle strings with null characters.
a #GBytes with the result of the conversion.
a #JSCValue
Obtain the %ArrayBuffer for the memory region of the typed array elements.
A #JSCValue
a #JSCValue
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.
pointer to memory.
a #JSCValue
location to return the number of elements contained
Gets the number of elements in a typed array.
number of elements.
a #JSCValue
Gets the offset over the underlying array buffer data.
offset, in bytes.
A #JSCValue
Gets the size of a typed array.
size, in bytes.
a #JSCValue
Gets the type of elements contained in a typed array.
type of the elements, or %JSC_TYPED_ARRAY_NONE if @value is not a typed array.
a #JSCValue
The #JSCContext in which the value was created.
Flags used when defining properties with jsc_value_object_define_property_data() and
jsc_value_object_define_property_accessor().
the type of the property descriptor may be changed and the
property may be deleted from the corresponding object.
the property shows up during enumeration of the properties on
the corresponding object.
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().
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.
Create a new #JSCVirtualMachine.
the newly created #JSCVirtualMachine.
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.
Create a new #JSCWeakValue for the JavaScript value referenced by @value.
a new #JSCWeakValue
a #JSCValue
Get a #JSCValue referencing the JavaScript value of @weak_value.
a new #JSCValue or %NULL if @weak_value was cleared.
a #JSCWeakValue
The #JSCValue referencing the JavaScript value.
This signal is emitted when the JavaScript value is destroyed.
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.
the major version number of the JavaScriptCore library
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.
the micro version number of the JavaScriptCore library
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.
the minor version number of the JavaScriptCore library
Iterates all available options calling @function for each one. Iteration can
stop early if @function returns %FALSE.
a #JSCOptionsFunc callback
callback user data
Get @option as a #gboolean value.
%TRUE if @value has been set or %FALSE if the option doesn't exist
the option identifier
return location for the option value
Get @option as a #gdouble value.
%TRUE if @value has been set or %FALSE if the option doesn't exist
the option identifier
return location for the option value
Get @option as a #gint value.
%TRUE if @value has been set or %FALSE if the option doesn't exist
the option identifier
return location for the option value
Create a #GOptionGroup to handle JSCOptions as command line arguments.
The options will be exposed as command line arguments with the form
<emphasis>--jsc-<option>=<value></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.
a #GOptionGroup for the JSCOptions
Get @option as a range string. The string must be in the
format <emphasis>[!]<low>[:<high>]</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.
%TRUE if @value has been set or %FALSE if the option doesn't exist
the option identifier
return location for the option value
Get @option as a #gsize value.
%TRUE if @value has been set or %FALSE if the option doesn't exist
the option identifier
return location for the option value
Get @option as a string.
%TRUE if @value has been set or %FALSE if the option doesn't exist
the option identifier
return location for the option value
Get @option as a #guint value.
%TRUE if @value has been set or %FALSE if the option doesn't exist
the option identifier
return location for the option value
Set @option as a #gboolean value.
%TRUE if option was correctly set or %FALSE otherwise.
the option identifier
the value to set
Set @option as a #gdouble value.
%TRUE if option was correctly set or %FALSE otherwise.
the option identifier
the value to set
Set @option as a #gint value.
%TRUE if option was correctly set or %FALSE otherwise.
the option identifier
the value to set
Set @option as a range string. The string must be in the
format <emphasis>[!]<low>[:<high>]</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.
%TRUE if option was correctly set or %FALSE otherwise.
the option identifier
the value to set
Set @option as a #gsize value.
%TRUE if option was correctly set or %FALSE otherwise.
the option identifier
the value to set
Set @option as a string.
%TRUE if option was correctly set or %FALSE otherwise.
the option identifier
the value to set
Set @option as a #guint value.
%TRUE if option was correctly set or %FALSE otherwise.
the option identifier
the value to set