It derives from <GObject>.
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 GCallback<!– –>s
to implement them.
The <JSCContext> in which the class was
registered.
Its value is a <JSCContext>, or #f.
It can only be set when the object is made, with #:context. It
cannot be read.
The name of the class.
Its value is a string, or #f.
It can only be set when the object is made, with #:name.
The parent class or #f in case of final classes.
Its value is a <JSCClass>, or #f.
It can only be set when the object is made, with #:parent.
Add a constructor to self. If name is #f, the class
name will be used. When new() is used with the constructor or
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, which needs to be added to an
object as a property to be able to use it. Use 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 GDestroyNotify passed to
jsc_context_register_class() is responsible for disposing of it.
Passed: a <JSCClass>.
Passed: a string, or #f.
the constructor name or #f
Passed: a procedure.
a GCallback to be called to create an
instance of self
See GCallback for how it is called.
Passed: a class, or a GType number.
the GType of the constructor return value
Passed, or left out: a list or vector, each a class, or a GType number,
or #f.
Returned: a <JSCValue>.
a <JSCValue> representing the class constructor.
Not passed: guile-gi gives the length of parameter-types.
Not passed: guile-gi supplies it.
user data to pass to callback
Not passed: guile-gi supplies it.
destroy notifier for user-data
See GDestroyNotify for how it is
called.
the number of parameter types to follow or 0 if constructor doesn’t receive parameters.
a list of GType<!– –>s, one for each parameter.
Add a constructor to self. If name is #f, the class
name will be used. When new() is used with the constructor or
value:constructor-call is called,
callback is invoked receiving a
<GPtrArray> of
<JSCValue><!– –>s as arguments 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, which needs to be added to an
object as a property to be able to use it. Use 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 GDestroyNotify passed to
jsc_context_register_class() is responsible for disposing of it.
Passed: a <JSCClass>.
Passed: a string, or #f.
the constructor name or #f
Passed: a procedure.
a GCallback to be called to create an
instance of self
See GCallback for how it is called.
Passed: a class, or a GType number.
the GType of the constructor return value
Returned: a <JSCValue>.
a <JSCValue> representing the class constructor.
Not passed: guile-gi supplies it.
user data to pass to callback
Not passed: guile-gi supplies it.
destroy notifier for user-data
See GDestroyNotify for how it is
called.
Add method with name to self. When the method is called by
JavaScript or 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.
Note that the value returned by callback must be transfer full. In
case of non-refcounted boxed types, you should use G_TYPE_POINTER
instead of the actual boxed GType to ensure that the instance
owned by <JSCClass> is used. If you really want to
return a new copy of the boxed type, use JSC_TYPE_VALUE and
return a <JSCValue> created with value:new-object that receives the copy as the instance
parameter.
Passed: a <JSCClass>.
Passed: a string.
the method name
Passed: a procedure.
a GCallback to be called to invoke method
name of self
See GCallback for how it is called.
Passed: a class, or a GType number.
the GType of the method return value, or G_TYPE_NONE if
the method is void.
Passed, or left out: a list or vector, each a class, or a GType number,
or #f.
Not passed: guile-gi gives the length of parameter-types.
Not passed: guile-gi supplies it.
user data to pass to callback
Not passed: guile-gi supplies it.
destroy notifier for user-data
See GDestroyNotify for how it is
called.
the number of parameter types to follow or 0 if the method doesn’t receive parameters.
a list of GType<!– –>s, one for each parameter.
Add method with name to self. When the method is called by
JavaScript or value:object-invoke-method, callback is
called receiving the class instance as first parameter, followed by a
<GPtrArray> of
<JSCValue><!– –>s with the method arguments 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.
Note that the value returned by callback must be transfer full. In
case of non-refcounted boxed types, you should use G_TYPE_POINTER
instead of the actual boxed GType to ensure that the instance
owned by <JSCClass> is used. If you really want to
return a new copy of the boxed type, use JSC_TYPE_VALUE and
return a <JSCValue> created with value:new-object that receives the copy as the instance
parameter.
Passed: a <JSCClass>.
Passed: a string.
the method name
Passed: a procedure.
a GCallback to be called to invoke method
name of self
See GCallback for how it is called.
Passed: a class, or a GType number.
the GType of the method return value, or G_TYPE_NONE if
the method is void.
Not passed: guile-gi supplies it.
user data to pass to callback
Not passed: guile-gi supplies it.
destroy notifier for user-data
See GDestroyNotify for how it is
called.
Add a property with name to self. When the property value
is read, 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.
Note that the value returned by getter must be transfer full. In
case of non-refcounted boxed types, you should use G_TYPE_POINTER
instead of the actual boxed GType to ensure that the instance
owned by <JSCClass> is used. If you really want to
return a new copy of the boxed type, use JSC_TYPE_VALUE and
return a <JSCValue> created with value:new-object that receives the copy as the instance
parameter.
Passed: a <JSCClass>.
Passed: a string.
the property name
Passed: a class, or a GType number.
the GType of the property value
Passed, or left out: a procedure, or #f.
a GCallback to be called to get the
property value
See GCallback for how it is called.
Passed, or left out: a procedure, or #f.
a GCallback to be called to set the
property value
See GCallback for how it is called.
Not passed: guile-gi supplies it.
user data to pass to getter and setter
Not passed: guile-gi supplies it.
destroy notifier for user-data
See GDestroyNotify for how it is
called.
Get the class name of self
Passed: a <JSCClass>.
a JSCClass
Returned: a string.
the name of self
Get the parent class of self
Passed: a <JSCClass>.
a JSCClass
Returned: a <JSCClass>.
the parent class of self