Obsolete since JavaScript 1.8.5
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

This article covers features introduced in SpiderMonkey 1.8

Callback for objects that wrap other objects.

Syntax

typedef JSObject * (*JSObjectOp)(JSContext *cx, JSObject *obj);
Name Type Description
cx JSContext * The context in which the object is being unwrapped.
obj JSObject * The object to unwrap.

Description

If a class has the JSCLASS_IS_EXTENDED bit set in its JSClass.flags and has a non-null JSExtendedClass.wrappedObject, then objects of that class may be wrappers. In a few cases the JavaScript engine will pretend the wrapper isn't there, instead operating on the object it wraps. In these cases the engine calls the JSExtendedClass.wrappedObject callback to get the wrapped object. Most classes do not implement wrappedObject.

The specific cases where this happens are:

The wrappedObject callback implementation must never fail. If it returns null or obj, then the JS engine treats the object as though it were not a wrapper.

Wrapper objects typically have no prototype, do not allow setting __proto__, and inherit properties from the wrapped object rather than the prototype chain (see JSNewResolveOp).