Declaration [src]

jsc_value_new_function (
  JSCContext* context,
  const char* name,
  GCallback callback,
  gpointer user_data,
  GDestroyNotify destroy_notify,
  GType return_type,
  guint n_params,

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.

This method is not directly available to language bindings.



Type: JSCContext

A JSCContext:

The data is owned by the caller of the function.

Type: const char*

The function name or NULL.

The argument can be NULL.
The data is owned by the caller of the function.
The value is a NUL terminated UTF-8 string.

Type: GCallback

A GCallback.


Type: gpointer

User data to pass to callback.

The argument can be NULL.
The data is owned by the caller of the function.

Type: GDestroyNotify

Destroy notifier for user_data.

The argument can be NULL.

Type: GType

The GType of the function return value, or G_TYPE_NONE if the function is void.


Type: guint

The number of parameter types to follow or 0 if the function doesn’t receive parameters.



A list of GTypes, one for each parameter.

Return value

Type: JSCValue

A JSCValue.

The caller of the function takes ownership of the data, and is responsible for freeing it.