INT_FITS_IN_JSVAL

  • Revision slug: SpiderMonkey/JSAPI_Reference/INT_FITS_IN_JSVAL
  • Revision title: INT_FITS_IN_JSVAL
  • Revision id: 101818
  • Created:
  • Creator: Jorend
  • Is current revision? No
  • Comment style

Revision Content

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

Determines if a specified C integer is safe to pass to INT_TO_JSVAL.

Syntax

INT_FITS_IN_JSVAL(i)
Name Type Description
i int The C integer value to check.

Description

Determines if a specified C integer value, i, lies within the minimum and maximum ranges allowed for a jsval integer. If the value is within range, it can become a valid JS integer, and INT_FITS_IN_JSVAL is TRUE. Otherwise INT_FITS_IN_JSVAL is FALSE.

Example

The following code snippet illustrates how a C variable, item, is conditionally tested in an if statement to see if it is a legal jsval integer value.

if (INT_FITS_IN_JSVAL(item)) {
    /* ... */
} else {
    JS_ReportError(cx, "Integer out of range: %s", item);
}

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

Revision Source

<p>{{template.Jsapi_ref_header("INT_FITS_IN_JSVAL")}}
</p><p>Determines if a specified C integer is safe to pass to <code><a href="en/INT_TO_JSVAL">INT_TO_JSVAL</a></code>.
</p>
<h3 name="Syntax"> Syntax </h3>
<pre class="eval"><b>INT_FITS_IN_JSVAL</b>(i)
</pre>
<table class="fullwidth-table">
<tbody><tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td><code>i</code></td>
<td><code>int</code></td>
<td>The C integer value to check.</td>
</tr>
</tbody></table>
<h3 name="Description"> Description </h3>
<p>Determines if a specified C integer value, <code>i</code>, lies within the minimum and maximum ranges allowed for a <code>jsval</code> integer. If the value is within range, it can become a valid JS integer, and <code>INT_FITS_IN_JSVAL</code> is <code>TRUE</code>. Otherwise <code>INT_FITS_IN_JSVAL</code> is <code>FALSE</code>.
</p>
<h3 name="Example"> Example </h3>
<p>The following code snippet illustrates how a C variable, <code>item</code>, is conditionally tested in an <code>if</code> statement to see if it is a legal <code>jsval</code> integer value.
</p>
<pre class="eval">if (INT_FITS_IN_JSVAL(item)) {
    /* ... */
} else {
    <a href="en/JS_ReportError">JS_ReportError</a>(cx, "Integer out of range: %s", item);
}
</pre>
<p>{{template.LXRSearch("ident", "i", "INT_FITS_IN_JSVAL")}}
</p>
Revert to this revision