JavaScript-1.5 Reference

JS_SetPrivate Function

Summary

Sets the private data for a JS object.

Syntax

JSBool JS_SetPrivate(JSContext *cx, JSObject *obj, void *data);
NameTypeDescription
cxJSContext *Pointer to a JS context from which to derive runtime information.
objJSObject *Object for which to set private data.
datavoid *Private data for the object.

Description

JS_SetPrivate sets the private data pointer for a specified object, obj. To set private data for an object, the object must be an instance of a class, and the class must include JSCLASS_HAS_PRIVATE in its flag set.

Only a pointer to data is stored with the object. The data pointer is converted to a jsval for storage purposes. You must free this pointer in your finalization code if you allocated storage for it. It is up to your application to maintain the actual data.

If successful, JS_SetPrivate returns JS_TRUE. Otherwise it returns JS_FALSE.

See Also

Groups [ Function ]
Documents [ LXR ID Search ]
Entries [ JSCLASS_HAS_PRIVATE | JSClass | JS_GetInstancePrivate | JS_GetPrivate | JS_InitClass | PRIVATE_TO_JSVAL ]

This page was generated by APIDOC