AcornSearch - Acorn and RISC OS information searching
RISC OS Search
containing
"Nutty quip goes here!"
Home  |  About  |  Filebase Archive  |  StrongHelp Manuals  |  Newsgroups  |  Module Database
Entry:     JS_NewFunction (Function)
Summary:     Creates a new JS function that wraps a native C function.
Syntax:
JSFunction * JS_NewFunction(JSContext *cx, JSNative call,
uintN nargs, uintN flags, JSObject *parent,
const char *name);

     Argument     Type     Description
     cx     JSContext *     Pointer to a JS context from which to derive runtime information.
                 
     call     JSNative     Native C function call wrapped by this function. 
                 
     nargs     uintN     Number of arguments that are passed to the underlying C function.
                 
     flags     uintN     Function attributes. 
                 
     parent     JSObject *     Pointer to the parent object for this function.
                 
     name     const char *     Name to assign to the new function. If you do not assign a name to the function, it is assigned the name "anonymous".
                 
Description:
JS_NewFunction creates a new JS function based on the parameters you pass. call is a native C function call that this function wraps. If you are not wrapping a native function, use JS_DefineFunction, instead. nargs is the number of arguments passed to the underlying C function. JS uses this information to allocate space for each argument.

flags lists the attributes to apply to the function. Currently documented attributes, JSFUN_BOUND_METHOD and JSFUN_GLOBAL_PARENT, are deprecated and should no longer be used. They continue to be supported only for existing applications that already depend on them.

parent is the parent object for this function. If a function has no parent, you can set parent to NULLname is the name to assign to the function. If you pass an empty value, JS sets the function's name to anonymous.

If JS_NewFunction is successful, it returns a pointer to the newly created function. Otherwise it returns NULL.


See also:
JSFUN_BOUND_METHOD
JSFUN_GLOBAL_PARENT
JS_CallFunction
JS_CallFunctionName
JS_CallFunctionValue
JS_CompileFunction
JS_CompileUCFunction
JS_DecompileFunction
JS_DecompileFunctionBody
JS_DefineFunction
JS_DefineFunctions
JS_GetFunctionName
JS_GetFunctionObject
JS_SetBranchCallback
JS_ValueToFunction

[sh-index] Back to list of manuals