JavaScript-1.5 Reference

JS_DefineFunctions Function

Summary

Creates one or more functions for a JS object.

Syntax

JSBool JS_DefineFunctions(JSContext *cx, JSObject *obj,
    JSFunctionSpec *fs);
NameTypeDescription
cxJSContext *Pointer to a JS context from which to derive runtime information.
objJSObject *Object for which to define functions.
fsJSFunctionSpec *A null-terminated array of function specifications. Each element of the array defines an individual function, its name, the built-in native C call it wraps, the number of arguments it takes, and its attribute flag.

Description

JS_DefineFunctions creates one or more functions and makes them properties (methods) of a specified object, obj.

fs is a pointer to the first element of an array of JSFunctionSpec. Each array element defines a single function: its name, the native C call wrapped by the function, the number of arguments passed to the function, and its attribute flags. The last element of the array must contain zero values. JS_DefineFunctions creates one function for each non-zero element in the array.

If it successfully creates properties for all the functions specified in the array, JS_DefineFunctions returns JS_TRUE. Otherwise it returns JS_FALSE.

Notes

To define only a single function for an object, call JS_DefineFunction.

See Also

Groups [ Function ]
Documents [ LXR ID Search ]
Entries [ JSFunctionSpec | JS_CallFunction | JS_CallFunctionName | JS_CallFunctionValue | JS_CompileFunction | JS_CompileUCFunction | JS_DecompileFunction | JS_DecompileFunctionBody | JS_DefineConstDoubles | JS_DefineElement | JS_DefineFunction | JS_DefineObject | JS_DefineProperties | JS_DefineProperty | JS_DefinePropertyWithTinyId | JS_GetFunctionName | JS_GetFunctionObject | JS_NewFunction | JS_SetBranchCallback | JS_ValueToFunction ]

This page was generated by APIDOC