JavaScriptCore.Class

g GObject.Object GObject.Object JavaScriptCore.Class JavaScriptCore.Class GObject.Object->JavaScriptCore.Class

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

add_constructor (name, callback, user_data, return_type, parameter_types)

add_constructor_variadic (name, callback, user_data, return_type)

add_method (name, callback, user_data, return_type, parameter_types)

add_method_variadic (name, callback, user_data, return_type)

add_property (name, property_type, getter, setter, *user_data)

get_name ()

get_parent ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

context

JavaScriptCore.Context

w/co

name

str

r/w/co

parent

JavaScriptCore.Class

r/w/co

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class JavaScriptCore.Class(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

JavaScriptCore.ClassClass

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 providing GObject.Callback s to implement them.

add_constructor(name, callback, user_data, return_type, parameter_types)
Parameters:
Returns:

a JavaScriptCore.Value representing the class constructor.

Return type:

JavaScriptCore.Value

Add a constructor to self. If name is None, the class name will be used. When new is used with the constructor or JavaScriptCore.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 JavaScriptCore.Class 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 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.DestroyNotify passed to JavaScriptCore.Context.register_class() is responsible for disposing of it.

add_constructor_variadic(name, callback, user_data, return_type)
Parameters:
Returns:

a JavaScriptCore.Value representing the class constructor.

Return type:

JavaScriptCore.Value

Add a constructor to self. If name is None, the class name will be used. When new is used with the constructor or JavaScriptCore.Value.constructor_call() is called, callback is invoked receiving a GLib.PtrArray of JavaScriptCore.Value s as arguments and user_data as the last parameter. When the constructor object is cleared in the JavaScriptCore.Class 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 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.DestroyNotify passed to JavaScriptCore.Context.register_class() is responsible for disposing of it.

add_method(name, callback, user_data, return_type, parameter_types)
Parameters:

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 the JavaScriptCore.Class 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 GObject.TYPE_POINTER instead of the actual boxed GObject.GType to ensure that the instance owned by JavaScriptCore.Class is used. If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a JavaScriptCore.Value created with JavaScriptCore.Value.new_object() that receives the copy as the instance parameter.

add_method_variadic(name, callback, user_data, return_type)
Parameters:

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 a GLib.PtrArray of JavaScriptCore.Value s with the method arguments and then user_data as last parameter. When the method is cleared in the JavaScriptCore.Class 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 GObject.TYPE_POINTER instead of the actual boxed GObject.GType to ensure that the instance owned by JavaScriptCore.Class is used. If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a JavaScriptCore.Value created with JavaScriptCore.Value.new_object() that receives the copy as the instance parameter.

add_property(name, property_type, getter, setter, *user_data)
Parameters:

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.Class 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 GObject.TYPE_POINTER instead of the actual boxed GObject.GType to ensure that the instance owned by JavaScriptCore.Class is used. If you really want to return a new copy of the boxed type, use #JSC_TYPE_VALUE and return a JavaScriptCore.Value created with JavaScriptCore.Value.new_object() that receives the copy as the instance parameter.

get_name()
Returns:

the name of self

Return type:

str

Get the class name of self

get_parent()
Returns:

the parent class of self

Return type:

JavaScriptCore.Class

Get the parent class of self

Property Details

JavaScriptCore.Class.props.context
Name:

context

Type:

JavaScriptCore.Context

Default Value:

None

Flags:

WRITABLE, CONSTRUCT_ONLY

The JavaScriptCore.Context in which the class was registered.

JavaScriptCore.Class.props.name
Name:

name

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The name of the class.

JavaScriptCore.Class.props.parent
Name:

parent

Type:

JavaScriptCore.Class

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The parent class or None in case of final classes.