JavaScript-1.5 Reference

JS_ConstructObject Function

Summary

Instantiates a new object and invokes its constructor.

Syntax

JSObject * JS_ConstructObject(JSContext *cx, JSClass *clasp,
    JSObject *proto, JSObject *parent);
NameTypeDescription
cxJSContext *Pointer to a JS context from which to derive runtime information.
claspJSClass *Pointer to the class to use for the new object.
protoJSObject *Pointer to the prototype object to use for the new class.
parentJSObject *Pointer to which to set the new object's __parent__ property.

Description

JS_ConstructObject instantiates a new object based on a specified class, prototype, and parent object, and then invokes its constructor function. cx is a pointer to a context associated with the runtime in which to establish the new object. clasp is a pointer to an existing class to use for internal methods, such as finalize. proto is an optional pointer to the prototype object with which to associate the new object.

Set proto to NULL to force JS to assign a prototype object for you. In this case, JS_NewObject attempts to assign the new object the prototype object belonging to clasp, if one is defined there. Otherwise, it creates an empty object stub for the prototype.

parent is an optional pointer to an existing object to which to set the new object's parent object property. You can set parent to NULL if you do not want to set the parent property.

On success, JS_ConstructObject returns a pointer to the newly instantiated object. Otherwise it returns NULL.

See Also

Groups [ Function ]
Documents [ LXR ID Search ]
Entries [ JSClass | JS_DefineObject | JS_GetFunctionObject | JS_NewArrayObject | JS_NewObject | JS_ValueToObject ]

This page was generated by APIDOC