Method

JavaScriptCoreClassadd_constructorv

Declaration [src]

JSCValue*
jsc_class_add_constructorv (
  JSCClass* jsc_class,
  const char* name,
  GCallback callback,
  gpointer user_data,
  GDestroyNotify destroy_notify,
  GType return_type,
  guint n_parameters,
  GType* parameter_types
)

Description [src]

Add a constructor to jsc_class. If name is NULL, the class name will be used. When new is used with the constructor or jsc_value_constructor_call() is called, callback is invoked receiving the parameters and user_data as the last parameter. When the constructor object is cleared in the JSCClass 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 jsc_context_set_value() to make the constructor available in the global object.

Note that the value returned by callback is adopted by jsc_class, and the GDestroyNotify passed to jsc_context_register_class() is responsible for disposing of it.

This method is renamed to jsc_class_add_constructor() in language bindings

Parameters

name

Type: const char*

The constructor name or NULL.

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

Type: GCallback

A GCallback to be called to create an instance of jsc_class.

user_data

Type: gpointer

User data to pass to callback.

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

Type: GDestroyNotify

Destroy notifier for user_data.

The argument can be NULL.
return_type

Type: GType

The GType of the constructor return value.

n_parameters

Type: guint

The number of parameters.

parameter_types

Type: An array of GType

A list of GTypes, one for each parameter, or NULL.

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 method.

Return value

Type: JSCValue

A JSCValue representing the class constructor.

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