JSPropertySpec

  • Revision slug: SpiderMonkey/JSAPI_Reference/JSPropertySpec
  • Revision title: JSPropertySpec
  • Revision id: 138991
  • Created:
  • Creator: Jorend
  • Is current revision? No
  • Comment /* Syntax */ for…in

Revision Content

{{template.Jsapi_ref_header("JSPropertySpec")}}

Defines a single property for an object.

Syntax

struct JSPropertySpec {
    const char *name;
    int8 tinyid;
    uint8 flags;
    JSPropertyOp getter;
    JSPropertyOp setter;
};
Name Type Description
name const char * Name to assign the property.
tinyid int8 Unique ID number for the property to aid in resolving getProperty and setProperty method calls.
flags uint8 Property attributes. If 0, no flags are set. Otherwise, the following attributes can be used singly or OR'd together:
getter JSPropertyOp getProperty method for the property.
setter JSPropertyOp setProperty method for the property. Read-only properties should not have a setProperty method.

Description

JSPropertySpec defines the attributes for a single JS property to associate with an object. Generally, you populate an array of JSPropertySpec to define all the properties for an object, and then call JS_DefineProperties to create the properties and assign them to an object.

See Also

{{template.LXRSearch("ident", "i", "JSPropertySpec")}}

{{template.Jsapixref("JSPROP_ENUMERATE")}}, {{template.Jsapixref("JSPROP_EXPORTED")}}, {{template.Jsapixref("JSPROP_INDEX")}}, {{template.Jsapixref("JSPROP_PERMANENT")}}, {{template.Jsapixref("JSPROP_READONLY")}}, {{template.Jsapixref("JS_DefineProperty")}}, {{template.Jsapixref("JS_DefinePropertyWithTinyId")}}, {{template.Jsapixref("JS_DeleteProperty")}}

Revision Source

<p>{{template.Jsapi_ref_header("JSPropertySpec")}}
</p><p>Defines a single property for an object.
</p>
<h3 name="Syntax"> Syntax </h3>
<pre class="eval">struct <b>JSPropertySpec</b> {
    const char *name;
    <a href="en/Int8">int8</a> tinyid;
    <a href="en/Uint8">uint8</a> flags;
    <a href="en/JSPropertyOp">JSPropertyOp</a> getter;
    <a href="en/JSPropertyOp">JSPropertyOp</a> setter;
};
</pre>
<table class="fullwidth-table">
<tbody><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td><code>name</code></td>
<td><code>const char *</code></td>
<td>Name to assign the property.</td>
</tr>
<tr>
<td><code>tinyid</code></td>
<td><code><a href="en/Int8">int8</a></code></td>
<td>Unique ID number for the property to aid in resolving <code>getProperty</code> and <code>setProperty</code> method calls.</td>
</tr>
<tr>
<td><code>flags</code></td>
<td><code><a href="en/Uint8">uint8</a></code></td>
<td>Property attributes.  If <code>0</code>, no flags are set.  Otherwise, the following attributes can be used singly or <code>OR</code>'d together:
<ul><li> <code><a href="en/JSPROP_ENUMERATE">JSPROP_ENUMERATE</a></code>: property is visible to <code>for</code>…<code>in</code> loops.
</li><li> <code><a href="en/JSPROP_READONLY">JSPROP_READONLY</a></code>: property is read-only.
</li><li> <code><a href="en/JSPROP_PERMANENT">JSPROP_PERMANENT</a></code>: property cannot be deleted.
</li><li> <code><a href="en/JSPROP_EXPORTED">JSPROP_EXPORTED</a></code>: property can be exported outside its object.
</li><li> <code><a href="en/JSPROP_INDEX">JSPROP_INDEX</a></code>: property is actually an array element.
</li></ul>
</td>
</tr>
<tr>
<td><code>getter</code></td>
<td><code><a href="en/JSPropertyOp">JSPropertyOp</a></code></td>
<td><code>getProperty</code> method for the property.</td>
</tr>
<tr>
<td><code>setter</code></td>
<td><code><a href="en/JSPropertyOp">JSPropertyOp</a></code></td>
<td><code>setProperty</code> method for the property.  Read-only properties should not have a <code>setProperty</code> method.</td>
</tr>
</tbody></table>
<h3 name="Description"> Description </h3>
<p><code>JSPropertySpec</code> defines the attributes for a single JS property to associate with an object. Generally, you populate an array of <code>JSPropertySpec</code> to define all the properties for an object, and then call <code><a href="en/JS_DefineProperties">JS_DefineProperties</a></code> to create the properties and assign them to an object.
</p>
<h3 name="See_Also"> See Also </h3>
<p>{{template.LXRSearch("ident", "i", "JSPropertySpec")}}
</p><p>{{template.Jsapixref("JSPROP_ENUMERATE")}},
{{template.Jsapixref("JSPROP_EXPORTED")}},
{{template.Jsapixref("JSPROP_INDEX")}},
{{template.Jsapixref("JSPROP_PERMANENT")}},
{{template.Jsapixref("JSPROP_READONLY")}},
{{template.Jsapixref("JS_DefineProperty")}},
{{template.Jsapixref("JS_DefinePropertyWithTinyId")}},
{{template.Jsapixref("JS_DeleteProperty")}}
</p>
Revert to this revision