add_constructor


Description:

[ CCode ( cname = "jsc_class_add_constructor_variadic" ) ]
public Value add_constructor (string? name, owned ClassConstructorCb callback, Type return_type)

Add a constructor to this.

If name is null, the class name will be used. When <function>new</function> is used with the constructor or jsc_value_constructor_call is called, callback is invoked receiving a GenericArray of Value <!-- -->s as arguments and user_data as the last parameter. When the constructor object is cleared in the Class context, destroy_notify is called with user_data as parameter.

This function creates the constructor, which needs to be added to an object as a property to be able to use it. Use set_value to make the constructor available in the global object.

Note that the value returned by callback is adopted by this, and the DestroyNotify passed to register_class is responsible for disposing of it.

Parameters:

this

a Class

name

the constructor name or null

callback

a ClassSetPropertyCb to be called to create an instance of this

return_type

the Type of the constructor return value

destroy_notify

destroy notifier for user_data

user_data

user data to pass to callback

Returns:

a Value representing the class constructor.