JS DefineFunctions
From MDC
Add native methods to an object.
[edit] Syntax
JSBool JS_DefineFunctions(JSContext *cx, JSObject *obj, JSFunctionSpec *fs);
| Name | Type | Description |
|---|---|---|
cx |
JSContext * |
The context in which to define functions.
Requires request. (In a |
obj |
JSObject * |
The object on which functions are to be defined. |
fs |
JSFunctionSpec * |
A NULL-terminated array of function specifications. Each element of the array defines an individual function. |
[edit] Description
JS_DefineFunctions creates zero or more functions and makes them properties (methods) of a specified object, obj.
fs is a pointer to the first element of an array of JSFunctionSpec records. This array is usually defined as a static global, with each record written using JS_FS or JS_FN. Each array element defines a single function: its name, the native C call wrapped by the function, the number of arguments passed to the function, and its attribute flags. The last element of the array must contain 0 values. (The macro JS_FS_END can be used for the last element.) JS_DefineFunctions creates one function for each non-zero element in the array.
On success, JS_DefineFunctions returns JS_TRUE. On error or exception, it stops defining functions and returns JS_FALSE.
To define a single function on an object, use JS_DefineFunction.
[edit] See Also
LXR ID Search for JS_DefineFunctions
JS_CallFunctionName, JS_DefineConstDoubles, JS_DefineElement, JS_DefineFunction, JS_DefineObject, JS_DefineProperties, JS_DefineProperty, JS_DefinePropertyWithTinyId, JS_NewFunction