JS_PropertyStub

  • Revision slug: SpiderMonkey/JSAPI_Reference/JS_PropertyStub
  • Revision title: JS_PropertyStub
  • Revision id: 68843
  • Created:
  • Creator: Jorend
  • Is current revision? No
  • Comment no wording changes; page display name changed to 'JS_PropertyStub'

Revision Content

{{ Jsapi_ref_header("JS_PropertyStub") }}

Default implementations of the required callbacks in JSClass.

Syntax

JSBool JS_PropertyStub(JSContext *cx, JSObject *obj, jsval id, jsval *vp);

JSBool JS_EnumerateStub(JSContext *cx, JSObject *obj);

JSBool JS_ResolveStub(JSContext *cx, JSObject *obj, jsval id);

JSBool JS_ConvertStub(JSContext *cx, JSObject *obj, JSType type, jsval *vp);

JSBool JS_FinalizeStub(JSContext *cx, JSObject *obj);

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 and setter callbacks. It can be used in JSClass.addProperty, JSClass.getProperty, JSClass.setProperty, JSClass.delProperty, JSPropertySpec.getter and setter, JS_DefineProperty, JS_DefinePropertyWithTinyId, and JS_DefineElement. It behaves exactly like a property callback that accepts the default property behavior: it does nothing and returns JS_TRUE.

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

JS_ResolveStub is a stub for JSClass.resolve. It does nothing and returns JS_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 function, passing an argument specifying the desired type. If the object does not have a valueOf property, JS_ConvertStub produces the original object.

JS_FinalizeStub is a stub for JSClass.finalize. It does nothing and returns JS_TRUE.

{{ LXRSearch("ident", "i", "JS_PropertyStub") }}
{{ LXRSearch("ident", "i", "JS_EnumerateStub") }}
{{ LXRSearch("ident", "i", "JS_ResolveStub") }}
{{ LXRSearch("ident", "i", "JS_ConvertStub") }}
{{ LXRSearch("ident", "i", "JS_FinalizeStub") }}

Revision Source

<p>{{ Jsapi_ref_header("JS_PropertyStub") }}
</p><p>Default implementations of the required callbacks in <code><a href="/en/JSClass" title="en/JSClass">JSClass</a></code>.
</p>
<h2 name="Syntax"> Syntax </h2>
<pre class="eval"><a href="/en/JSBool" title="en/JSBool">JSBool</a> <strong>JS_PropertyStub</strong>(<a href="/en/JSRuntime" title="en/JSRuntime">JSContext</a> *cx, <a href="/en/JSObject" title="en/JSObject">JSObject</a> *obj, <a href="/en/jsval" title="en/jsval">jsval</a> id, <a href="/en/jsval" title="en/jsval">jsval</a> *vp);

<a href="/en/JSBool" title="en/JSBool">JSBool</a> <strong>JS_EnumerateStub</strong>(<a href="/en/JSRuntime" title="en/JSRuntime">JSContext</a> *cx, <a href="/en/JSObject" title="en/JSObject">JSObject</a> *obj);

<a href="/en/JSBool" title="en/JSBool">JSBool</a> <strong>JS_ResolveStub</strong>(<a href="/en/JSRuntime" title="en/JSRuntime">JSContext</a> *cx, <a href="/en/JSObject" title="en/JSObject">JSObject</a> *obj, <a href="/en/jsval" title="en/jsval">jsval</a> id);

<a href="/en/JSBool" title="en/JSBool">JSBool</a> <strong>JS_ConvertStub</strong>(<a href="/en/JSRuntime" title="en/JSRuntime">JSContext</a> *cx, <a href="/en/JSObject" title="en/JSObject">JSObject</a> *obj, <a href="/en/JSType" title="en/JSType">JSType</a> type, <a href="/en/jsval" title="en/jsval">jsval</a> *vp);

<a href="/en/JSBool" title="en/JSBool">JSBool</a> <strong>JS_FinalizeStub</strong>(<a href="/en/JSRuntime" title="en/JSRuntime">JSContext</a> *cx, <a href="/en/JSObject" title="en/JSObject">JSObject</a> *obj);
</pre>
<h2 name="Description"> Description </h2>
<p>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 <code><a href="/en/JSClass#Description" title="en/JSClass#Description">JSClass</a></code> illustrate how stub functions can be used.
</p><p><strong><code>JS_PropertyStub</code></strong> is of type <code><a href="/en/JSClass.addProperty" title="en/JSClass.addProperty">JSPropertyOp</a></code>, the type of getter and setter callbacks. It can be used in <code><a href="/en/JSClass.addProperty" title="en/JSClass.addProperty">JSClass.addProperty</a></code>, <code><a href="/en/JSClass.addProperty" title="en/JSClass.addProperty">JSClass.getProperty</a></code>, <code><a href="/en/JSClass.addProperty" title="en/JSClass.addProperty">JSClass.setProperty</a></code>, <code><a href="/en/JSClass.addProperty" title="en/JSClass.addProperty">JSClass.delProperty</a></code>, <code><a href="/en/JSPropertySpec" title="en/JSPropertySpec">JSPropertySpec</a>.getter</code> and <code>setter</code>, <code><a href="/en/JS_DefineProperty" title="en/JS_DefineProperty">JS_DefineProperty</a></code>, <code><a href="/en/JS_DefinePropertyWithTinyId" title="en/JS_DefinePropertyWithTinyId">JS_DefinePropertyWithTinyId</a></code>, and <code><a href="/en/JS_DefineElement" title="en/JS_DefineElement">JS_DefineElement</a></code>. It behaves exactly like a property callback that accepts the default property behavior: it does nothing and returns <code>JS_TRUE</code>.
</p><p><strong><code>JS_EnumerateStub</code></strong> is a stub for <code><a href="/en/JSClass.enumerate" title="en/JSClass.enumerate">JSClass.enumerate</a></code>. It does nothing and returns <code>JS_TRUE</code>.
</p><p><strong><code>JS_ResolveStub</code></strong> is a stub for <code><a href="/en/JSClass.resolve" title="en/JSClass.resolve">JSClass.resolve</a></code>. It does nothing and returns <code>JS_TRUE</code>.
</p><p><strong><code>JS_ConvertStub</code></strong> is a stub for <code><a href="/en/JSObjectOps.defaultValue" title="en/JSObjectOps.defaultValue">JSClass.convert</a></code>. Its behavior is the same as the default conversion behavior for <code>Object</code>s. It attempts to call the object's <code>valueOf</code> function, passing an argument specifying the desired type. If the object does not have a <code>valueOf</code> property, <code>JS_ConvertStub</code> produces the original object.
</p><p><strong><code>JS_FinalizeStub</code></strong> is a stub for <code><a href="/en/JSClass.finalize" title="en/JSClass.finalize">JSClass.finalize</a></code>. It does nothing and returns <code>JS_TRUE</code>.
</p><p>{{ LXRSearch("ident", "i", "JS_PropertyStub") }}<br>
{{ LXRSearch("ident", "i", "JS_EnumerateStub") }}<br>
{{ LXRSearch("ident", "i", "JS_ResolveStub") }}<br>
{{ LXRSearch("ident", "i", "JS_ConvertStub") }}<br>
{{ LXRSearch("ident", "i", "JS_FinalizeStub") }}
</p>
Revert to this revision