JavaScriptCore.Class¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
|---|---|---|---|
w/co |
|||
r/w/co |
|||
r/w/co |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
|---|---|---|---|
parent |
r |
Class Details¶
- class JavaScriptCore.Class(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
A JSSClass represents a custom JavaScript class registered by the user in a
JavaScriptCore.Context. 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 providingGObject.Callbacks to implement them.- add_constructor(name, callback, user_data, return_type, parameter_types)¶
- Parameters:
callback (
GObject.Callback) – aGObject.Callbackto be called to create an instance of selfreturn_type (
GObject.GType) – theGObject.GTypeof the constructor return valueparameter_types ([
GObject.GType] orNone) – a list ofGObject.GTypes, one for each parameter, orNone
- Returns:
a
JavaScriptCore.Valuerepresenting the class constructor.- Return type:
Add a constructor to self. If name is
None, the class name will be used. When new is used with the constructor orJavaScriptCore.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 theJavaScriptCore.Classcontext, 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
JavaScriptCore.Context.set_value() to make the constructor available in the global object.Note that the value returned by callback is adopted by self, and the
GLib.DestroyNotifypassed toJavaScriptCore.Context.register_class() is responsible for disposing of it.
- add_constructor_variadic(name, callback, user_data, return_type)¶
- Parameters:
callback (
GObject.Callback) – aGObject.Callbackto be called to create an instance of selfreturn_type (
GObject.GType) – theGObject.GTypeof the constructor return value
- Returns:
a
JavaScriptCore.Valuerepresenting the class constructor.- Return type:
Add a constructor to self. If name is
None, the class name will be used. When new is used with the constructor orJavaScriptCore.Value.constructor_call() is called, callback is invoked receiving aGLib.PtrArrayofJavaScriptCore.Values as arguments and user_data as the last parameter. When the constructor object is cleared in theJavaScriptCore.Classcontext, 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
JavaScriptCore.Context.set_value() to make the constructor available in the global object.Note that the value returned by callback is adopted by self, and the
GLib.DestroyNotifypassed toJavaScriptCore.Context.register_class() is responsible for disposing of it.
- add_method(name, callback, user_data, return_type, parameter_types)¶
- Parameters:
name (
str) – the method namecallback (
GObject.Callback) – aGObject.Callbackto be called to invoke method name of selfreturn_type (
GObject.GType) – theGObject.GTypeof the method return value, orGObject.TYPE_NONEif the method is void.parameter_types ([
GObject.GType] orNone) – a list ofGObject.GTypes, one for each parameter, orNone
Add method with name to self. When the method is called by JavaScript or
JavaScriptCore.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 theJavaScriptCore.Classcontext, 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
GObject.TYPE_POINTERinstead of the actual boxedGObject.GTypeto ensure that the instance owned byJavaScriptCore.Classis used. If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return aJavaScriptCore.Valuecreated withJavaScriptCore.Value.new_object() that receives the copy as the instance parameter.
- add_method_variadic(name, callback, user_data, return_type)¶
- Parameters:
name (
str) – the method namecallback (
GObject.Callback) – aGObject.Callbackto be called to invoke method name of selfreturn_type (
GObject.GType) – theGObject.GTypeof the method return value, orGObject.TYPE_NONEif the method is void.
Add method with name to self. When the method is called by JavaScript or
JavaScriptCore.Value.object_invoke_method(), callback is called receiving the class instance as first parameter, followed by aGLib.PtrArrayofJavaScriptCore.Values with the method arguments and then user_data as last parameter. When the method is cleared in theJavaScriptCore.Classcontext, 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
GObject.TYPE_POINTERinstead of the actual boxedGObject.GTypeto ensure that the instance owned byJavaScriptCore.Classis used. If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return aJavaScriptCore.Valuecreated withJavaScriptCore.Value.new_object() that receives the copy as the instance parameter.
- add_property(name, property_type, getter, setter, *user_data)¶
- Parameters:
name (
str) – the property nameproperty_type (
GObject.GType) – theGObject.GTypeof the property valuegetter (
GObject.CallbackorNone) – aGObject.Callbackto be called to get the property valuesetter (
GObject.CallbackorNone) – aGObject.Callbackto be called to set the property valueuser_data (
objectorNone) – user data to pass to getter and setter
Add a property with name to self. 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
JavaScriptCore.Classcontext, 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
GObject.TYPE_POINTERinstead of the actual boxedGObject.GTypeto ensure that the instance owned byJavaScriptCore.Classis used. If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return aJavaScriptCore.Valuecreated withJavaScriptCore.Value.new_object() that receives the copy as the instance parameter.
- get_parent()¶
- Returns:
the parent class of self
- Return type:
Get the parent class of self
Property Details¶
- JavaScriptCore.Class.props.context¶
- Name:
context- Type:
- Default Value:
- Flags:
The
JavaScriptCore.Contextin which the class was registered.
- JavaScriptCore.Class.props.name¶
- Name:
name- Type:
- Default Value:
- Flags:
The name of the class.