Class
JavaScriptCoreValue
Description [src]
final class JavaScriptCore.Value : GObject.Object
{
/* No available fields */
}
JSCValue represents a reference to a value in a JSCContext
. The JSCValue
protects the referenced value from being garbage collected.
Constructors
jsc_value_new_array
Create a new JSCValue
referencing an array with the given items. If first_item_type
is G_TYPE_NONE
an empty array is created.
jsc_value_new_array_from_garray
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
.
jsc_value_new_array_from_strv
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.
jsc_value_new_from_json
Create a new JSCValue
referencing a new value created by parsing json
.
since: 2.28
jsc_value_new_function
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.
jsc_value_new_function_variadic
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.
jsc_value_new_functionv
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.
jsc_value_new_object
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().
jsc_value_new_promise
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.
unstable since: 2.48
jsc_value_new_string
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.
jsc_value_new_typed_array
Create a new typed array containing a given amount of elements.
since: 2.38
Instance methods
jsc_value_array_buffer_get_data
Gets a pointer to memory that contains the array buffer data.
since: 2.38
jsc_value_constructor_call
Invoke value
. If first_parameter_type
is G_TYPE_NONE
no parameters will be passed to the constructor.
jsc_value_constructor_callv
Invoke value
. If n_parameters
is 0 no parameters will be passed to the constructor.
jsc_value_function_call
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.
jsc_value_function_callv
Call function referenced by value
, passing the given parameters
. If n_parameters
is 0 no parameters will be passed to the function.
jsc_value_new_typed_array_with_buffer
Create a new typed array value with elements from an array buffer.
since: 2.38
jsc_value_object_define_property_accessor
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
jsc_value_object_define_property_data
Define or modify a property with property_name
in object referenced by value
. This is equivalent to
JavaScript
jsc_value_object_delete_property
Try to delete property with name
from value
. This function will return FALSE
if
the property was defined without JSC_VALUE_PROPERTY_CONFIGURABLE
flag.
jsc_value_object_enumerate_properties
Get the list of property names of value
. Only properties defined with JSC_VALUE_PROPERTY_ENUMERABLE
flag will be collected.
jsc_value_object_invoke_method
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.
jsc_value_object_invoke_methodv
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.
jsc_value_object_is_instance_of
Get whether the value referenced by value
is an instance of class name
.
jsc_value_to_json
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.
since: 2.28
jsc_value_to_string
Convert value
to a string. Use jsc_value_to_string_as_bytes()
instead, if you need to
handle strings containing null characters.
jsc_value_to_string_as_bytes
Convert value
to a string and return the results as GBytes
. This is needed
to handle strings with null characters.
jsc_value_typed_array_get_buffer
Obtain the %ArrayBuffer for the memory region of the typed array elements.
since: 2.38
jsc_value_typed_array_get_data
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.
since: 2.38
Signals
Signals inherited from GObject (1)
GObject::notify
The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.