Value.functionv


Description:

[ CCode ( has_construct_function = false ) ]
public Value.functionv (Context context, string? name, Callback callback, void* user_data, DestroyNotify? destroy_notify, Type return_type, Type[]? parameter_types)

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 Type to ensure that the instance owned by Class is used. If you really want to return a new copy of the boxed type, use JSC_TYPE_VALUE and return a Value created with Value.object that receives the copy as instance parameter.

Parameters:

context

a Context

name

the function name or null

callback

a ClassSetPropertyCb.

return_type

the Type of the function return value, or g_type_none if the function is void.

parameter_types

a list of Type<!-- -->s, one for each parameter, or null

destroy_notify

destroy notifier for user_data

n_parameters

the number of parameters

user_data

user data to pass to callback.

Returns:

a Value.




2022 vala-language.org