JavaScript-1.5 Reference

JS_NewObject Function

Summary

Instantiates a new object.

Syntax

JSObject * JS_NewObject(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_NewObject instantiates a new object based on a specified class, prototype, and parent object. 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_NewObject returns a pointer to the newly instantiated object. Otherwise it returns NULL.

Notes

To create a new object that is a property of an existing object, use JS_DefineObject.

See Also

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

This page was generated by APIDOC