This article covers features introduced in SpiderMonkey 1.8 (not yet released)
Callback for objects that wrap other objects.
typedef JSObject * (*JSObjectOp)(JSContext *cx, JSObject *obj);
| || ||The context in which the object is being unwrapped.|
| || ||The object to unwrap.|
If a class has the
JSCLASS_IS_EXTENDED bit set in its
JSClass.flags and has a non-null
JSExtendedClass.wrappedObject callback to get the wrapped object. Most classes do not implement
The specific cases where this happens are:
- The default
toStringmethod returns a string that contains the name of the wrapped object's class rather than the wrapper's class.
typeofexpressions and in
JS_TypeOfValue, the type of the wrapped object is returned. (The result may be
- When assigning to
- A wrapper object is strictly equal to the object it wraps, in the sense of
!==. Two wrapper objects that wrap the same object are also strictly equal.
- A wrapper object that wraps an Array is considered an array for the purpose of
Array.concat(which treat array arguments differently from other arguments, per ECMA 262-3 §184.108.40.206).
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