Movatterモバイル変換


[0]ホーム

URL:


Top  | Description  | Object Hierarchy  | PropertiesHomeUpPrevNext

JSCValue

JSCValue — JavaScript value

Functions

JSCContext *jsc_value_get_context ()
JSCValue *jsc_value_new_undefined ()
gbooleanjsc_value_is_undefined ()
JSCValue *jsc_value_new_null ()
gbooleanjsc_value_is_null ()
JSCValue *jsc_value_new_number ()
gbooleanjsc_value_is_number ()
doublejsc_value_to_double ()
gint32jsc_value_to_int32 ()
JSCValue *jsc_value_new_boolean ()
gbooleanjsc_value_is_boolean ()
gbooleanjsc_value_to_boolean ()
JSCValue *jsc_value_new_string ()
JSCValue *jsc_value_new_string_from_bytes ()
gbooleanjsc_value_is_string ()
char *jsc_value_to_string ()
GBytes *jsc_value_to_string_as_bytes ()
JSCValue *jsc_value_new_array ()
JSCValue *jsc_value_new_array_from_garray ()
JSCValue *jsc_value_new_array_from_strv ()
gbooleanjsc_value_is_array ()
JSCValue *jsc_value_new_object ()
gbooleanjsc_value_is_object ()
gbooleanjsc_value_object_is_instance_of ()
voidjsc_value_object_set_property ()
JSCValue *jsc_value_object_get_property ()
voidjsc_value_object_set_property_at_index ()
JSCValue *jsc_value_object_get_property_at_index ()
gbooleanjsc_value_object_has_property ()
gbooleanjsc_value_object_delete_property ()
gchar **jsc_value_object_enumerate_properties ()
JSCValue *jsc_value_object_invoke_method ()
JSCValue *jsc_value_object_invoke_methodv ()
voidjsc_value_object_define_property_data ()
voidjsc_value_object_define_property_accessor ()
JSCValue *jsc_value_new_function ()
JSCValue *jsc_value_new_functionv ()
JSCValue *jsc_value_new_function_variadic ()
gbooleanjsc_value_is_function ()
JSCValue *jsc_value_function_call ()
JSCValue *jsc_value_function_callv ()
gbooleanjsc_value_is_constructor ()
JSCValue *jsc_value_constructor_call ()
JSCValue *jsc_value_constructor_callv ()
JSCValue *jsc_value_new_from_json ()
char *jsc_value_to_json ()

Properties

JSCContext *contextRead / Write / Construct Only

Types and Values

structJSCValue
enumJSCValuePropertyFlags

Object Hierarchy

GObject╰── JSCValue

Description

JSCValue represents a reference to a value in aJSCContext. The JSCValueprotects the referenced value from being garbage collected.

Functions

jsc_value_get_context ()

JSCContext *jsc_value_get_context (JSCValue *value);

Get theJSCContext in whichvalue was created.

Parameters

value

aJSCValue

 

Returns

theJSCValue context.

[transfer none]


jsc_value_new_undefined ()

JSCValue *jsc_value_new_undefined (JSCContext *context);

Create a newJSCValue referencingundefined incontext.

Parameters

context

aJSCContext

 

Returns

aJSCValue.

[transfer full]


jsc_value_is_undefined ()

gbooleanjsc_value_is_undefined (JSCValue *value);

Get whether the value referenced byvalue isundefined.

Parameters

value

aJSCValue

 

Returns

whether the value is undefined.


jsc_value_new_null ()

JSCValue *jsc_value_new_null (JSCContext *context);

Create a newJSCValue referencingnull incontext.

Parameters

context

aJSCContext

 

Returns

aJSCValue.

[transfer full]


jsc_value_is_null ()

gbooleanjsc_value_is_null (JSCValue *value);

Get whether the value referenced byvalue isnull.

Parameters

value

aJSCValue

 

Returns

whether the value is null.


jsc_value_new_number ()

JSCValue *jsc_value_new_number (JSCContext *context,double number);

Create a newJSCValue fromnumber.

Parameters

context

aJSCContext

 

number

a number

 

Returns

aJSCValue.

[transfer full]


jsc_value_is_number ()

gbooleanjsc_value_is_number (JSCValue *value);

Get whether the value referenced byvalue is a number.

Parameters

value

aJSCValue

 

Returns

whether the value is a number.


jsc_value_to_double ()

doublejsc_value_to_double (JSCValue *value);

Convertvalue to a double.

Parameters

value

aJSCValue

 

Returns

agdouble result of the conversion.


jsc_value_to_int32 ()

gint32jsc_value_to_int32 (JSCValue *value);

Convertvalue to agint32.

Parameters

value

aJSCValue

 

Returns

agint32 result of the conversion.


jsc_value_new_boolean ()

JSCValue *jsc_value_new_boolean (JSCContext *context,gboolean value);

Create a newJSCValue fromvalue

Parameters

context

aJSCContext

 

value

agboolean

 

Returns

aJSCValue.

[transfer full]


jsc_value_is_boolean ()

gbooleanjsc_value_is_boolean (JSCValue *value);

Get whether the value referenced byvalue is a boolean.

Parameters

value

aJSCValue

 

Returns

whether the value is a boolean.


jsc_value_to_boolean ()

gbooleanjsc_value_to_boolean (JSCValue *value);

Convertvalue to a boolean.

Parameters

value

aJSCValue

 

Returns

agboolean result of the conversion.


jsc_value_new_string ()

JSCValue *jsc_value_new_string (JSCContext *context,constchar *string);

Create a newJSCValue fromstring. If you need to create aJSCValue from astring containing null characters, usejsc_value_new_string_from_bytes() instead.

Parameters

context

aJSCContext

 

string

a null-terminated string.

[nullable]

Returns

aJSCValue.

[transfer full]


jsc_value_new_string_from_bytes ()

JSCValue *jsc_value_new_string_from_bytes (JSCContext *context,GBytes *bytes);

Create a newJSCValue frombytes.

Parameters

context

aJSCContext

 

bytes

aGBytes.

[nullable]

Returns

aJSCValue.

[transfer full]


jsc_value_is_string ()

gbooleanjsc_value_is_string (JSCValue *value);

Get whether the value referenced byvalue is a string

Parameters

value

aJSCValue

 

Returns

whether the value is a string


jsc_value_to_string ()

char *jsc_value_to_string (JSCValue *value);

Convertvalue to a string. Usejsc_value_to_string_as_bytes() instead, if you need tohandle strings containing null characters.

Parameters

value

aJSCValue

 

Returns

a null-terminated string result of the conversion.

[transfer full]


jsc_value_to_string_as_bytes ()

GBytes *jsc_value_to_string_as_bytes (JSCValue *value);

Convertvalue to a string and return the results asGBytes. This is neededto handle strings with null characters.

Parameters

value

aJSCValue

 

Returns

aGBytes with the result of the conversion.

[transfer full]


jsc_value_new_array ()

JSCValue *jsc_value_new_array (JSCContext *context,GType first_item_type,...);

Create a newJSCValue referencing an array with the given items. Iffirst_item_typeisG_TYPE_NONE an empty array is created.

[skip]

Parameters

context

aJSCContext

 

first_item_type

GType of first item, orG_TYPE_NONE

 

...

value of the first item, followed optionally by more type/value pairs, followed byG_TYPE_NONE.

 

Returns

aJSCValue.

[transfer full]


jsc_value_new_array_from_garray ()

JSCValue *jsc_value_new_array_from_garray (JSCContext *context,GPtrArray *array);

Create a newJSCValue referencing an array with the items fromarray. IfarrayisNULL or empty a new empty array will be created. Elements ofarray should bepointers to aJSCValue.

Parameters

context

aJSCContext

 

array

aGPtrArray.

[nullable][element-type JSCValue]

Returns

aJSCValue.

[transfer full]


jsc_value_new_array_from_strv ()

JSCValue *jsc_value_new_array_from_strv (JSCContext *context,constchar *const *strv);

Create a newJSCValue referencing an array of strings with the items fromstrv. IfarrayisNULL or empty a new empty array will be created.

Parameters

context

aJSCContext

 

strv

aNULL-terminated array of strings.

[array zero-terminated=1][element-type utf8]

Returns

aJSCValue.

[transfer full]


jsc_value_is_array ()

gbooleanjsc_value_is_array (JSCValue *value);

Get whether the value referenced byvalue is an array.

Parameters

value

aJSCValue

 

Returns

whether the value is an array.


jsc_value_new_object ()

JSCValue *jsc_value_new_object (JSCContext *context,gpointer instance,JSCClass *jsc_class);

Create a newJSCValue frominstance. Ifinstance isNULL a new empty object is created.Wheninstance is provided,jsc_class must be provided too.jsc_class takes ownership ofinstance that will be freed by theGDestroyNotify passed tojsc_context_register_class().

Parameters

context

aJSCContext

 

instance

an object instance orNULL.

[nullable][transfer full]

jsc_class

theJSCClass ofinstance.

[nullable]

Returns

aJSCValue.

[transfer full]


jsc_value_is_object ()

gbooleanjsc_value_is_object (JSCValue *value);

Get whether the value referenced byvalue is an object.

Parameters

value

aJSCValue

 

Returns

whether the value is an object.


jsc_value_object_is_instance_of ()

gbooleanjsc_value_object_is_instance_of (JSCValue *value,constchar *name);

Get whether the value referenced byvalue is an instance of classname.

Parameters

value

aJSCValue

 

name

a class name

 

Returns

whether the value is an object instance of classname.


jsc_value_object_set_property ()

voidjsc_value_object_set_property (JSCValue *value,constchar *name,JSCValue *property);

Setproperty withname onvalue.

Parameters

value

aJSCValue

 

name

the property name

 

property

theJSCValue to set

 

jsc_value_object_get_property ()

JSCValue *jsc_value_object_get_property (JSCValue *value,constchar *name);

Get property withname fromvalue.

Parameters

value

aJSCValue

 

name

the property name

 

Returns

the propertyJSCValue.

[transfer full]


jsc_value_object_set_property_at_index ()

voidjsc_value_object_set_property_at_index                               (JSCValue *value,guint index,JSCValue *property);

Setproperty atindex onvalue.

Parameters

value

aJSCValue

 

index

the property index

 

property

theJSCValue to set

 

jsc_value_object_get_property_at_index ()

JSCValue *jsc_value_object_get_property_at_index                               (JSCValue *value,guint index);

Get property atindex fromvalue.

Parameters

value

aJSCValue

 

index

the property index

 

Returns

the propertyJSCValue.

[transfer full]


jsc_value_object_has_property ()

gbooleanjsc_value_object_has_property (JSCValue *value,constchar *name);

Get whethervalue has property withname.

Parameters

value

aJSCValue

 

name

the property name

 

Returns

TRUE ifvaluehas a property withname, orFALSE otherwise


jsc_value_object_delete_property ()

gbooleanjsc_value_object_delete_property (JSCValue *value,constchar *name);

Try to delete property withname fromvalue. This function will returnFALSE ifthe property was defined withoutJSC_VALUE_PROPERTY_CONFIGURABLE flag.

Parameters

value

aJSCValue

 

name

the property name

 

Returns

TRUE if the property was deleted, orFALSE otherwise.


jsc_value_object_enumerate_properties ()

gchar **jsc_value_object_enumerate_properties (JSCValue *value);

Get the list of property names ofvalue. Only properties defined withJSC_VALUE_PROPERTY_ENUMERABLEflag will be collected.

Parameters

value

aJSCValue

 

Returns

aNULL-terminated array of strings containing theproperty names, orNULL ifvaluedoesn't have enumerable properties. Useg_strfreev() to free.

[array zero-terminated=1][transfer full][nullable]


jsc_value_object_invoke_method ()

JSCValue *jsc_value_object_invoke_method (JSCValue *value,constchar *name,GType first_parameter_type,...);

Invoke method withname on object referenced byvalue, passing the given parameters. Iffirst_parameter_type isG_TYPE_NONE no parameters will be passed to the method.The object instance will be handled automatically even when the method is a custom oneregistered withjsc_class_add_method(), so it should never be passed explicitly as parameterof this function.

This function always returns aJSCValue, in case of void methods aJSCValue referencingundefined is returned.

[skip]

Parameters

value

aJSCValue

 

name

the method name

 

first_parameter_type

GType of first parameter, orG_TYPE_NONE

 

...

value of the first parameter, followed optionally by more type/value pairs, followed byG_TYPE_NONE

 

Returns

aJSCValue with the return value of the method.

[transfer full]


jsc_value_object_invoke_methodv ()

JSCValue *jsc_value_object_invoke_methodv (JSCValue *value,constchar *name,guint n_parameters,JSCValue **parameters);

Invoke method withname on object referenced byvalue, passing the givenparameters. Ifn_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 oneregistered withjsc_class_add_method(), so it should never be passed explicitly as parameterof this function.

This function always returns aJSCValue, in case of void methods aJSCValue referencingundefined is returned.

[rename-to jsc_value_object_invoke_method]

Parameters

value

aJSCValue

 

name

the method name

 

n_parameters

the number of parameters

 

parameters

theJSCValues to pass as parameters to the method, orNULL.

[nullable][array length=n_parameters][element-type JSCValue]

Returns

aJSCValue with the return value of the method.

[transfer full]


jsc_value_object_define_property_data ()

voidjsc_value_object_define_property_data (JSCValue *value,constchar *property_name,JSCValuePropertyFlags flags,JSCValue *property_value);

Define or modify a property withproperty_name in object referenced byvalue. This is equivalent toJavaScriptObject.defineProperty() when used with a data descriptor.

Parameters

value

aJSCValue

 

property_name

the name of the property to define

 

flags

JSCValuePropertyFlags

 

property_value

the default property value.

[nullable]

jsc_value_object_define_property_accessor ()

voidjsc_value_object_define_property_accessor                               (JSCValue *value,constchar *property_name,JSCValuePropertyFlags flags,GType property_type,GCallback getter,GCallback setter,gpointer user_data,GDestroyNotify destroy_notify);

Define or modify a property withproperty_name in object referenced byvalue. When theproperty value needs to be getted or set,getter andsetter callbacks will be called.When the property is cleared in theJSCClass context,destroy_notify is called withuser_data as parameter. This is equivalent to JavaScriptObject.defineProperty()when used with an accessor descriptor.

Note that the value returned bygetter must be fully transferred. In case of boxed types, you could useG_TYPE_POINTER instead of the actual boxedGType to ensure that the instance owned byJSCClass is used.If you really want to return a new copy of the boxed type, useJSC_TYPE_VALUE and return aJSCValue createdwithjsc_value_new_object() that receives the copy as instance parameter.

Parameters

value

aJSCValue

 

property_name

the name of the property to define

 

flags

JSCValuePropertyFlags

 

property_type

theGType of the property

 

getter

aGCallback to be called to get the property value.

[scope async][nullable]

setter

aGCallback to be called to set the property value.

[scope async][nullable]

user_data

user data to pass togetterandsetter.

[closure]

destroy_notify

destroy notifier foruser_data.

[nullable]

jsc_value_new_function ()

JSCValue *jsc_value_new_function (JSCContext *context,constchar *name,GCallback callback,gpointer user_data,GDestroyNotify destroy_notify,GType return_type,guint n_params,...);

Create a function incontext. Ifname isNULL an anonymous function will be created.When the function is called by JavaScript orjsc_value_function_call(),callback is calledreceiving the function parameters and thenuser_data as last parameter. When the function iscleared incontext,destroy_notify is called withuser_data as parameter.

Note that the value returned bycallback must be fully transferred. In case of boxed types, you could useG_TYPE_POINTER instead of the actual boxedGType to ensure that the instance owned byJSCClass is used.If you really want to return a new copy of the boxed type, useJSC_TYPE_VALUE and return aJSCValue createdwithjsc_value_new_object() that receives the copy as instance parameter.

[skip]

Parameters

context

aJSCContext:

 

name

the function name orNULL.

[nullable]

callback

aGCallback.

[scope async]

user_data

user data to pass tocallback.

[closure]

destroy_notify

destroy notifier foruser_data.

[nullable]

return_type

theGType of the function return value, orG_TYPE_NONE if the function is void.

 

n_params

the number of parameter types to follow or 0 if the function doesn't receive parameters.

 

...

a list ofGTypes, one for each parameter.

 

Returns

aJSCValue.

[transfer full]


jsc_value_new_functionv ()

JSCValue *jsc_value_new_functionv (JSCContext *context,constchar *name,GCallback callback,gpointer user_data,GDestroyNotify destroy_notify,GType return_type,guint n_parameters,GType *parameter_types);

Create a function incontext. Ifname isNULL an anonymous function will be created.When the function is called by JavaScript orjsc_value_function_call(),callback is calledreceiving the function parameters and thenuser_data as last parameter. When the function iscleared incontext,destroy_notify is called withuser_data as parameter.

Note that the value returned bycallback must be fully transferred. In case of boxed types, you could useG_TYPE_POINTER instead of the actual boxedGType to ensure that the instance owned byJSCClass is used.If you really want to return a new copy of the boxed type, useJSC_TYPE_VALUE and return aJSCValue createdwithjsc_value_new_object() that receives the copy as instance parameter.

[rename-to jsc_value_new_function]

Parameters

context

aJSCContext

 

name

the function name orNULL.

[nullable]

callback

aGCallback.

[scope async]

user_data

user data to pass tocallback.

[closure]

destroy_notify

destroy notifier foruser_data.

[nullable]

return_type

theGType of the function return value, orG_TYPE_NONE if the function is void.

 

n_parameters

the number of parameters

 

parameter_types

a list ofGTypes, one for each parameter, orNULL.

[nullable][array length=n_parameters][element-type GType]

Returns

aJSCValue.

[transfer full]


jsc_value_new_function_variadic ()

JSCValue *jsc_value_new_function_variadic (JSCContext *context,constchar *name,GCallback callback,gpointer user_data,GDestroyNotify destroy_notify,GType return_type);

Create a function incontext. Ifname isNULL an anonymous function will be created.When the function is called by JavaScript orjsc_value_function_call(),callback is calledreceiving anGPtrArray ofJSCValues with the arguments and thenuser_data as last parameter.When the function is cleared incontext,destroy_notify is called withuser_data as parameter.

Note that the value returned bycallback must be fully transferred. In case of boxed types, you could useG_TYPE_POINTER instead of the actual boxedGType to ensure that the instance owned byJSCClass is used.If you really want to return a new copy of the boxed type, useJSC_TYPE_VALUE and return aJSCValue createdwithjsc_value_new_object() that receives the copy as instance parameter.

Parameters

context

aJSCContext

 

name

the function name orNULL.

[nullable]

callback

aGCallback.

[scope async]

user_data

user data to pass tocallback.

[closure]

destroy_notify

destroy notifier foruser_data.

[nullable]

return_type

theGType of the function return value, orG_TYPE_NONE if the function is void.

 

Returns

aJSCValue.

[transfer full]


jsc_value_is_function ()

gbooleanjsc_value_is_function (JSCValue *value);

Get whether the value referenced byvalue is a function

Parameters

value

aJSCValue

 

Returns

whether the value is a function.


jsc_value_function_call ()

JSCValue *jsc_value_function_call (JSCValue *value,GType first_parameter_type,...);

Call function referenced byvalue, passing the given parameters. Iffirst_parameter_typeisG_TYPE_NONE no parameters will be passed to the function.

This function always returns aJSCValue, in case of void functions aJSCValue referencingundefined is returned

[skip]

Parameters

value

aJSCValue

 

first_parameter_type

GType of first parameter, orG_TYPE_NONE

 

...

value of the first parameter, followed optionally by more type/value pairs, followed byG_TYPE_NONE

 

Returns

aJSCValue with the return value of the function.

[transfer full]


jsc_value_function_callv ()

JSCValue *jsc_value_function_callv (JSCValue *value,guint n_parameters,JSCValue **parameters);

Call function referenced byvalue, passing the givenparameters. Ifn_parametersis 0 no parameters will be passed to the function.

This function always returns aJSCValue, in case of void functions aJSCValue referencingundefined is returned

[rename-to jsc_value_function_call]

Parameters

value

aJSCValue

 

n_parameters

the number of parameters

 

parameters

theJSCValues to pass as parameters to the function, orNULL.

[nullable][array length=n_parameters][element-type JSCValue]

Returns

aJSCValue with the return value of the function.

[transfer full]


jsc_value_is_constructor ()

gbooleanjsc_value_is_constructor (JSCValue *value);

Get whether the value referenced byvalue is a constructor.

Parameters

value

aJSCValue

 

Returns

whether the value is a constructor.


jsc_value_constructor_call ()

JSCValue *jsc_value_constructor_call (JSCValue *value,GType first_parameter_type,...);

Invokenew with constructor referenced byvalue. Iffirst_parameter_typeisG_TYPE_NONE no parameters will be passed to the constructor.

[skip]

Parameters

value

aJSCValue

 

first_parameter_type

GType of first parameter, orG_TYPE_NONE

 

...

value of the first parameter, followed optionally by more type/value pairs, followed byG_TYPE_NONE

 

Returns

aJSCValue referencing the newly created object instance.

[transfer full]


jsc_value_constructor_callv ()

JSCValue *jsc_value_constructor_callv (JSCValue *value,guint n_parameters,JSCValue **parameters);

Invokenew with constructor referenced byvalue. Ifn_parametersis 0 no parameters will be passed to the constructor.

[rename-to jsc_value_constructor_call]

Parameters

value

aJSCValue

 

n_parameters

the number of parameters

 

parameters

theJSCValues to pass as parameters to the constructor, orNULL.

[nullable][array length=n_parameters][element-type JSCValue]

Returns

aJSCValue referencing the newly created object instance.

[transfer full]


jsc_value_new_from_json ()

JSCValue *jsc_value_new_from_json (JSCContext *context,constchar *json);

Create a newJSCValue referencing a new value created by parsingjson.

Parameters

context

aJSCContext

 

json

the JSON string to be parsed

 

Returns

aJSCValue.

[transfer full]

Since:2.28


jsc_value_to_json ()

char *jsc_value_to_json (JSCValue *value,guint indent);

Create a JSON string ofvalue serialization. Ifindent is 0, the resulting JSON willnot contain newlines. The size of the indent is clamped to 10 spaces.

Parameters

value

aJSCValue

 

indent

The number of spaces to indent when nesting.

 

Returns

a null-terminated JSON string with serialization ofvalue.

[transfer full]

Since:2.28

Types and Values

struct JSCValue

struct JSCValue;

enum JSCValuePropertyFlags

Flags used when defining properties withjsc_value_object_define_property_data() andjsc_value_object_define_property_accessor().

Members

JSC_VALUE_PROPERTY_CONFIGURABLE

the type of the property descriptor may be changed and theproperty may be deleted from the corresponding object.

 

JSC_VALUE_PROPERTY_ENUMERABLE

the property shows up during enumeration of the properties onthe corresponding object.

 

JSC_VALUE_PROPERTY_WRITABLE

the value associated with the property may be changed with anassignment operator. This doesn't have any effect when passed tojsc_value_object_define_property_accessor().

 

Property Details

The“context” property

  “context”JSCContext *

TheJSCContext in which the value was created.

Owner: JSCValue

Flags: Read / Write / Construct Only

See Also

JSCContext


Generated by GTK-Doc V1.33.0

[8]ページ先頭

©2009-2025 Movatter.jp