JS_PropertyStub

Default implementations of the required callbacks in JSClass.

Syntax

bool
JS_PropertyStub(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
                JS::MutableHandleValue vp);

bool
JS_StrictPropertyStub(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
                      JS::MutableHandleValue vp, JS::ObjectOpResult &result); // Added in SpiderMonkey 45

bool
JS_StrictPropertyStub(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
                      bool strict, JS::MutableHandleValue vp); // Obsolete since JSAPI 39

bool
JS_ResolveStub(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
               bool *resolvedp); // Obsolete since JSAPI 37

bool
JS_DeletePropertyStub(JSContext *cx, JS::HandleObject obj, JS::HandleId id,
                      bool *succeeded); // Obsolete since JSAPI 37

bool
JS_EnumerateStub(JSContext *cx, JS::HandleObject obj); // Obsolete since JSAPI 37

bool
JS_ConvertStub(JSContext *cx, JS::HandleObject obj, JSType type,
               JS::MutableHandleValue vp); // Obsolete since JSAPI 37

void
JS_FinalizeStub(JSContext *cx, JSObject *obj); // Obsolete since JSAPI 14

Description

The stub functions are not designed to be called directly by a JSAPI application. Rather, they are convenient stand-ins anywhere the JSAPI requires callbacks of certain types. Examples at JSClass illustrate how stub functions can be used.

JS_PropertyStub is of type JSPropertyOp, the type of getter callback. It can be used in JSClass.addProperty, and JSClass.getProperty. It behaves exactly like a property callback that accepts the default property behavior: it does nothing and returns true.

JS_StrictPropertyStub is of type JSStrictPropertyOp, the type of setter callback. It can be used in JSClass.setProperty. It behaves exactly like a property callback that accepts the default property behavior: it does nothing and returns true.

JS_DeletePropertyStub is of type JSDeletePropertyOp, the type of setter callback. It can be used in JSClass.delProperty. It behaves exactly like a property callback that accepts the default property behavior: it does nothing and returns true.

JS_EnumerateStub is a stub for JSClass.enumerate. It does nothing and returns true.

JS_ResolveStub is a stub for JSClass.resolve. It does nothing and returns true.

JS_ConvertStub is a stub for JSClass.convert. Its behavior is the same as the default conversion behavior for Objects. It attempts to call the object's valueOf and toString functions, in the order determined by the specified type, in accordance with the default DefaultValue algorithm in ES5 §8.12.8.

JS_FinalizeStub is a stub for JSClass.finalize. It does nothing.

See Also

Document Tags and Contributors

 Contributors to this page: arai, fscholz, tschneidereit, Waldo, Jorend, Dria, MMondor
 Last updated by: arai,