Top |
JSCValue * | (*JSCClassGetPropertyFunction) () |
gboolean | (*JSCClassSetPropertyFunction) () |
gboolean | (*JSCClassHasPropertyFunction) () |
gboolean | (*JSCClassDeletePropertyFunction) () |
gchar ** | (*JSCClassEnumeratePropertiesFunction) () |
const char * | jsc_class_get_name () |
JSCClass * | jsc_class_get_parent () |
JSCValue * | jsc_class_add_constructor () |
JSCValue * | jsc_class_add_constructorv () |
void | jsc_class_add_method () |
void | jsc_class_add_methodv () |
void | jsc_class_add_property () |
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 GCallbacks to implement them.
JSCValue * (*JSCClassGetPropertyFunction) (JSCClass *jsc_class
,JSCContext *context
,gpointer instance
,const char *name
);
The type of get_property in JSCClassVTable. This is only required when you need to handle external properties not added to the prototype.
gboolean (*JSCClassSetPropertyFunction) (JSCClass *jsc_class
,JSCContext *context
,gpointer instance
,const char *name
,JSCValue *value
);
The type of set_property in JSCClassVTable. This is only required when you need to handle external properties not added to the prototype.
gboolean (*JSCClassHasPropertyFunction) (JSCClass *jsc_class
,JSCContext *context
,gpointer instance
,const char *name
);
The type of has_property in JSCClassVTable. This is only required when you need to handle external properties not added to the prototype.
gboolean (*JSCClassDeletePropertyFunction) (JSCClass *jsc_class
,JSCContext *context
,gpointer instance
,const char *name
);
The type of delete_property in JSCClassVTable. This is only required when you need to handle external properties not added to the prototype.
gchar ** (*JSCClassEnumeratePropertiesFunction) (JSCClass *jsc_class
,JSCContext *context
,gpointer instance
);
The type of enumerate_properties in JSCClassVTable. This is only required when you need to handle external properties not added to the prototype.
const char *
jsc_class_get_name (JSCClass *jsc_class
);
Get the class name of jsc_class
JSCClass *
jsc_class_get_parent (JSCClass *jsc_class
);
Get the parent class of jsc_class
JSCValue * jsc_class_add_constructor (JSCClass *jsc_class
,const char *name
,GCallback callback
,gpointer user_data
,GDestroyNotify destroy_notify
,GType return_type
,guint n_params
,...
);
Add a constructor to jsc_class
. If name
is NULL
, the class name will be used. When new
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, that 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.
[skip]
jsc_class |
a JSCClass |
|
name |
the constructor name or |
[nullable] |
callback |
a GCallback to be called to create an instance of |
[scope async] |
user_data |
user data to pass to |
[closure] |
destroy_notify |
destroy notifier for |
[nullable] |
return_type |
the GType of the constructor return value |
|
n_params |
the number of parameter types to follow or 0 if constructor doesn't receive parameters. |
|
... |
a list of GTypes, one for each parameter. |
JSCValue * jsc_class_add_constructorv (JSCClass *jsc_class
,const char *name
,GCallback callback
,gpointer user_data
,GDestroyNotify destroy_notify
,GType return_type
,guint n_parameters
,GType *parameter_types
);
Add a constructor to jsc_class
. If name
is NULL
, the class name will be used. When new
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, that 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.
[rename-to jsc_class_add_constructor]
jsc_class |
a JSCClass |
|
name |
the constructor name or |
[nullable] |
callback |
a GCallback to be called to create an instance of |
[scope async] |
user_data |
user data to pass to |
[closure] |
destroy_notify |
destroy notifier for |
[nullable] |
return_type |
the GType of the constructor return value |
|
n_parameters |
the number of parameters |
|
parameter_types |
[nullable][array length=n_parameters][element-type GType] |
void jsc_class_add_method (JSCClass *jsc_class
,const char *name
,GCallback callback
,gpointer user_data
,GDestroyNotify destroy_notify
,GType return_type
,guint n_params
,...
);
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.
[skip]
jsc_class |
a JSCClass |
|
name |
the method name |
|
callback |
a GCallback to be called to invoke method |
[scope async] |
user_data |
user data to pass to |
[closure] |
destroy_notify |
destroy notifier for |
[nullable] |
return_type |
the GType of the method return value, or |
|
n_params |
the number of parameter types to follow or 0 if the method doesn't receive parameters. |
|
... |
a list of GTypes, one for each parameter. |
void jsc_class_add_methodv (JSCClass *jsc_class
,const char *name
,GCallback callback
,gpointer user_data
,GDestroyNotify destroy_notify
,GType return_type
,guint n_parameters
,GType *parameter_types
);
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.
[rename-to jsc_class_add_method]
jsc_class |
a JSCClass |
|
name |
the method name |
|
callback |
a GCallback to be called to invoke method |
[scope async] |
user_data |
user data to pass to |
[closure] |
destroy_notify |
destroy notifier for |
[nullable] |
return_type |
the GType of the method return value, or |
|
n_parameters |
the number of parameter types to follow or 0 if the method doesn't receive parameters. |
|
parameter_types |
[nullable][array length=n_parameters][element-type GType] |
void jsc_class_add_property (JSCClass *jsc_class
,const char *name
,GType property_type
,GCallback getter
,GCallback setter
,gpointer user_data
,GDestroyNotify destroy_notify
);
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.
jsc_class |
a JSCClass |
|
name |
the property name |
|
property_type |
the GType of the property value |
|
getter |
a GCallback to be called to get the property value. |
[scope async][nullable] |
setter |
a GCallback to be called to set the property value. |
[scope async][nullable] |
user_data |
user data to pass to |
[closure] |
destroy_notify |
destroy notifier for |
[nullable] |
typedef struct { JSCClassGetPropertyFunction get_property; JSCClassSetPropertyFunction set_property; JSCClassHasPropertyFunction has_property; JSCClassDeletePropertyFunction delete_property; JSCClassEnumeratePropertiesFunction enumerate_properties; } JSCClassVTable;
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.
JSCClassGetPropertyFunction |
a JSCClassGetPropertyFunction for getting a property. |
|
JSCClassSetPropertyFunction |
a JSCClassSetPropertyFunction for setting a property. |
|
JSCClassHasPropertyFunction |
a JSCClassHasPropertyFunction for querying a property. |
|
JSCClassDeletePropertyFunction |
a JSCClassDeletePropertyFunction for deleting a property. |
|
JSCClassEnumeratePropertiesFunction |
a JSCClassEnumeratePropertiesFunction for enumerating properties. |
“context”
property“context” JSCContext *
The JSCContext in which the class was registered.
Flags: Read / Write / Construct Only
“name”
property“name” gchar *
The name of the class.
Flags: Read / Write / Construct Only
Default value: NULL