Visit Mozilla.org

JS CallFunctionName

From MDC

Call a method of an object by name.

[edit] Syntax

JSBool JS_CallFunctionName(JSContext *cx, JSObject *obj,
    const char *name, uintN argc, jsval *argv, jsval *rval);
Name Type Description
cx JSContext * The context in which to call the method.

Requires request. (In a JS_THREADSAFE build, the caller must be in a request on this JSContext.)

obj JSObject * The object on which to call a method. If a method is found and called, obj is passed to it as this.
name const char * The name of the method to call.
argc uintN Number of arguments to pass to the function.
argv jsval * Pointer to the first element of a C array of argument values to pass to the function.
rval jsval * Out parameter. On success, *rval receives the method's return value.

[edit] Description

JS_CallFunctionName executes a function-valued property, name, belonging to a specified JS object, obj.

In argc, indicate the number of arguments passed to the function. In argv, pass a pointer to the actual argument values to use. There should be one value for each argument you pass to the function; the number of arguments you pass may be different from the number of parameters defined for the function.

rval is a pointer to a variable that will hold the function's return value, if any, on successful function execution.

If the called function executes successfully, JS_CallFunctionName returns JS_TRUE. Otherwise it returns JS_FALSE, and the value left in *rval is undefined.

To call a function stored in a jsval, use JS_CallFunctionValue.

[edit] See Also

LXR ID Search for JS_CallFunctionName

JS_CallFunction, JS_GetFunctionObject