Entry: JS_SetPrototype (Function)
Summary: Sets the prototype for an object.
Syntax:
JSBool JS_SetPrototype(JSContext *cx, JSObject *obj,
JSObject *proto);
Argument Type Description
cx JSContext * Pointer to a JS context from which to derive runtime information.
obj JSObject * Pointer to the object for which to set the prototype.
proto JSObject * Pointer to the prototype to use.
Description:
JS_SetPrototype enables you to set the prototype object for a specified object. A prototype object provides properties that are shared by similar JS object instances. Ordinarily you set a prototype for an object when you create the object with JS_NewObject, but if you do not set a prototype at that time, you can later call JS_SetPrototype to do so.
obj is a pointer to an existing JS object, and proto is a pointer to second existing object upon which the first object is based.
If JS_SetPrototype is successful, it returns JS_TRUE. Otherwise, if it cannot create and fill a prototype slot for the object, it returns JS_FALSE.
See also:
|
|
|