Value.this

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 an #GPtrArray of #JSCValue<!-- -->s with the arguments 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 Context

a #JSCContext

name string

the function name or %NULL

callback GCallback

a #GCallback.

userData void*

user data to pass to @callback.

destroyNotify GDestroyNotify

destroy notifier for @user_data

returnType GType

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

Return Value

a #JSCValue.

Throws

ConstructionException GTK+ fails to create the object.

Meta