pub unsafe extern "C" fn JSObjectMakeFunction(
ctx: JSContextRef,
name: JSStringRef,
parameterCount: c_uint,
parameterNames: *const JSStringRef,
body: JSStringRef,
sourceURL: JSStringRef,
startingLineNumber: c_int,
exception: *mut JSValueRef,
) -> JSObjectRef
Expand description
Creates a function with a given script as its body.
ctx
: The execution context to use.name
: AJSStringRef
containing the function’s name. This will be used when converting the function to string. PassNULL
to create an anonymous function.parameterCount
: An integer count of the number of parameter names inparameterNames
.parameterNames
: AJSStringRef
array containing the names of the function’s parameters. PassNULL
ifparameterCount
is0
.body
: AJSStringRef
containing the script to use as the function’s body.sourceURL
AJSStringRef
containing a URL for the script’s source file. This is only used when reporting exceptions. PassNULL
if you do not care to include source file information in exceptions.startingLineNumber
: An integer value specifying the script’s starting line number in the file located atsourceURL
. This is only used when reporting exceptions. The value is one-based, so the first line is line1
and invalid values are clamped to1
.exception
: A pointer to aJSValueRef
in which to store an exception, if any. PassNULL
if you do not care to store an exception.
Returns a JSObjectRef
that is a function, or NULL
if either
body or parameterNames
contains a syntax error. The
object’s prototype will be the default function prototype.
Use this method when you want to execute a script repeatedly, to avoid the cost of re-parsing the script before each execution.