typedef JSBool (*JSNative)(JSContext *cx, JSObject *obj, unsigned int argc, jsval *argv, jsval *rval)
Description
This function signature describes C-level implementations of JavaScript functions in the following situations:
- The
cxpointer is a pointer to an opaqueJSContextstructure, which must be passed to some of the functions in the JavaScript API. This variable holds the interpreter's execution context. - The
objpointer is a pointer to the object in whose context the script executes. While the script is running, thethiskeyword is equal to this object. - The
argcinteger is the number of arguments being passed to the function. - The
argvpointer is a pointer to an array ofjsvalstructures. The array isargcelements in length. - The
rvalpointer is a pointer to a singlejsvalstructure. The function's return value should be written to*rval.
The function returns JS_TRUE if successful; JS_FALSE otherwise. If the function returns JS_FALSE, the current script stops executing and an error message appears.