Create a native function and assign it as a property to a specified JS object.
JSFunction * JS_DefineFunction(JSContext *cx, JSObject *obj, const char *name, JSNative call, uintN nargs, uintN flags); JSFunction * JS_DefineUCFunction(JSContext *cx, JSObject *obj, const jschar *name, size_t namelen, JSNative call, uintN nargs, uintN attrs);
| || ||The context in which to define the function. Requires request. In a |
| || ||Object for which to define a function as a property (method).|
| || ||Name to assign to the function.|
| || ||The native C/C++ function to be wrapped by the new function.|
| || ||Number of arguments that are passed to the function when it is called.|
| || ||The logical OR of zero or more property attributes.|
JS_NewFunction, then makes it a method of
obj as though by calling
JS_DefineUCFunction is the Unicode version of the function.
name is the name of the property to create in
obj. That is, it is the method name that scripts can use to call the new function. It also becomes the
name property of the new function object and can be accessed using
flags is the logical OR of zero or more property attributes, which apply to the new property.
JS_DefineUCFunction return a pointer to the new function. On error or exception, they return