Constructor
JavaScriptCoreValuenew_functionv
Declaration [src]
JSCValue*
jsc_value_new_functionv (
JSCContext* context,
const char* name,
GCallback callback,
gpointer user_data,
GDestroyNotify destroy_notify,
GType return_type,
guint n_parameters,
GType* parameter_types
)
Description [src]
Create a function in context
. If name
is NULL
an anonymous function will be created.
When the function is called by JavaScript or jsc_value_function_call(), callback
is called
receiving the function parameters and then user_data
as last parameter. When the function is
cleared in context
, destroy_notify
is called with user_data
as parameter.
Note that the value returned by callback
must be fully transferred. In case of boxed types, you could 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 instance parameter.
Parameters
context |
JSCContext |
A |
|
The data is owned by the caller of the function. | |
name |
const char* |
The function name or |
|
The argument can be NULL . | |
The data is owned by the caller of the function. | |
The value is a NUL terminated UTF-8 string. | |
callback |
GCallback |
A |
|
user_data |
gpointer |
User data to pass to |
|
The argument can be NULL . | |
The data is owned by the caller of the function. | |
destroy_notify |
GDestroyNotify |
Destroy notifier for |
|
The argument can be NULL . | |
return_type |
GType |
The |
|
n_parameters |
guint |
The number of parameters. |
|
parameter_types |
An array of GType |
A list of |
|
The argument can be NULL . | |
The length of the array is specified in the n_parameters argument. | |
The data is owned by the caller of the function. |
Return value
Returns: | JSCValue |
A |
|
The caller of the function takes ownership of the data, and is responsible for freeing it. |