JSFunction * JS_CompileFunction(JSContext *cx, JSObject *obj, const char *name, uintN nargs, const char **argnames, const char *body, size_t length, const char *filename, uintN lineno); JSFunction * JS_CompileUCFunction(JSContext *cx, JSObject *obj, const char *name, uintN nargs, const char **argnames, const jschar *body, size_t length, const char *filename, uintN lineno);
| || ||The context in which to compile the function. Requires request. In a |
| || ||Object with which the function is associated.|
| || ||Name to assign the newly compiled function.|
| || ||Number of arguments to pass to the function.|
| || ||Names to assign to the arguments passed to the function.|
| || ||String containing the body of the function to compile.|
| || ||The length, in characters, of |
| || ||Name of file or URL containing the function. Used to report filename or URL in error messages.|
| || ||Line number. Used to report the offending line in the file or URL if an error occurs.|
JS_CompileFunction compiles a function from a text string,
bytes, and optionally associates it with a JS object,
JS_CompileUCFunction is the Unicode version of the function.
name is the name to assign to the newly created function.
nargs is the number of arguments the function takes, and
argnames is a pointer to the first element of an array of names to assign each argument. The number of argument names should match the number of arguments specified in
body is a string containing the source code of the function.
length is the length of the source code in characters.
filename is the name of the file (or URL) containing the function. This information is used in error messages if an error occurs during compilation. Similarly,
lineno is used to report the line number where an error occurred during compilation.
name are non-null, the new function becomes a method of
obj. (A new property is defined on
obj with the given
name and the new
Function object as its value.)
JS_CompileUCFunction return a pointer to the newly compiled function. On error or exception, they return
JSFUN_BOUND_METHOD, JSFUN_GLOBAL_PARENT, JS_CallFunction, JS_CallFunctionName, JS_CallFunctionValue, JS_DecompileFunction, JS_DecompileFunctionBody, JS_DefineFunction, JS_DefineFunctions, JS_GetFunctionObject, JS_NewFunction, JS_SetBranchCallback, JS_ValueToFunction