Method
JavaScriptCoreClassadd_methodv
Declaration [src]
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
)
Description [src]
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.
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 jsc_value_new_object() that receives the copy as the instance parameter.
This method is renamed to jsc_class_add_method() in language bindings.
Parameters
name-
Type:
const char*The method name.
The data is owned by the caller of the method. The value is a NUL terminated UTF-8 string. callback-
Type:
GCallbackA
GCallbackto be called to invoke methodnameofjsc_class. user_data-
Type:
gpointerUser data to pass to
callback.The argument can be NULL.The data is owned by the caller of the method. destroy_notify-
Type:
GDestroyNotifyDestroy notifier for
user_data.The argument can be NULL. return_type-
Type:
GTypeThe
GTypeof the method return value, orG_TYPE_NONEif the method is void. n_parameters-
Type:
guintThe number of parameter types to follow or 0 if the method doesn’t receive parameters.
parameter_types-
Type: An array of
GTypeA list of
GTypes, one for each parameter, orNULL.The argument can be NULL.The length of the array is specified in the n_parametersargument.The data is owned by the caller of the method.