JS_GetFunctionFlags

  • Revision slug: SpiderMonkey/JSAPI_Reference/JS_GetFunctionFlags
  • Revision title: JS_GetFunctionFlags
  • Revision id: 89445
  • Created:
  • Creator: Jorend
  • Is current revision? No
  • Comment 127 words added

Revision Content

Get the flags of a given JavaScript function.

Syntax

uintN JS_GetFunctionFlags(JSFunction *fun);
Name Type Description
fun JSFunction * The function to examine.

Description

JS_GetFunctionFlags retrieves the function flags of a given JavaScript function, fun.

Function flags

The JSAPI expresses function flags as a value of type uintN, the bitwise OR of zero or more of the JSFUN flags described below.

The application can set the function flags below when creating a function. See JS_NewFunction, JS_DefineFunction, JS_FS, and JS_FN. Once a function is created, its flags cannot be modified.

Flag Description

JSFUN_FAST_NATIVE

{{ jsapi_minversion_inline("1.8") }} The function is implemented as a C/C++ function implementing the JSFastNative signature.

{{ LXRSearch("ident", "i", "JSFUN_FAST_NATIVE") }}

JSFUN_THISP_STRING

If the this parameter passed to this function is a primitive string, it is not converted to a String object. Instead the string is passed directly to the native. The native should accomodate both String objects and strings as this.

This can be used for a minor performance gain when defining methods on String.prototype.

{{ LXRSearch("ident", "i", "JSFUN_THISP_STRING") }}

JSFUN_THISP_NUMBER

Like JSFUN_THISP_STRING but for numbers.

{{ LXRSearch("ident", "i", "JSFUN_THISP_NUMBER") }}

JSFUN_THISP_BOOLEAN

Like JSFUN_THISP_STRING but for boolean values.

{{ LXRSearch("ident", "i", "JSFUN_THISP_BOOLEAN") }}

JSFUN_BOUND_METHOD

{{ obsolete_inline() }}

{{ LXRSearch("ident", "i", "JSFUN_BOUND_METHOD") }}

The JavaScript engine sometimes sets the following flags on functions written in JavaScript. Applications may not set these flags.

Flag Description

JSFUN_LAMBDA

This flag is present on functions written as function-expressions rather than function-declarations, a grammatical distinction.  See {{ es3_spec("13") }}.

{{ LXRSearch("ident", "i", "JSFUN_LAMBDA") }}

JSFUN_HEAVYWEIGHT For internal engine use.
JSFUN_GETTER {{ obsolete_inline() }} This flag is present on getter functions declared using the obsolete syntax getter function x() {...}.
JSFUN_SETTER {{ obsolete_inline() }} This flag is present on setter functions declared using the obsolete syntax setter function x() {...}.

{{ LXRSearch("ident", "i", "JS_GetFunctionFlags") }}

Revision Source

<p>Get the flags of a given JavaScript function.</p>
<h2 name="Syntax">Syntax</h2>
<pre class="eval"><a href="/En/SpiderMonkey/JSAPI_Reference/jsint">uintN</a> <strong>JS_GetFunctionFlags</strong>(<a href="/en/SpiderMonkey/JSAPI_Reference/JSFunction">JSFunction</a> *fun);
</pre>
<table class="fullwidth-table"> <tbody> <tr> <th>Name</th> <th>Type</th> <th>Description</th> </tr> <tr> <td><code>fun</code></td> <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/JSFunction">JSFunction</a> *</code></td> <td>The function to examine.</td> </tr> </tbody>
</table>
<h2 name="Description">Description</h2>
<p><strong><code>JS_GetFunctionFlags</code></strong> retrieves the function flags of a given JavaScript function, <code>fun</code>.</p>
<h3 name="Function_flags">Function flags</h3>
<p>The JSAPI expresses function flags as a value of type <code><a href="/en/SpiderMonkey/JSAPI_Reference/jsint" title="en/jsint">uintN</a></code>, the bitwise OR of zero or more of the <code>JSFUN</code> flags described below.</p>
<p>The application can set the function flags below when creating a function. See <a href="/en/SpiderMonkey/JSAPI_Reference/JS_NewFunction" title="en/SpiderMonkey/JSAPI_Reference/JS_NewFunction"><code>JS_NewFunction</code></a>, <code><a href="/en/SpiderMonkey/JSAPI_Reference/JS_DefineProperty" title="en/JS_DefineProperty">JS_DefineFunction</a></code>, <code><a href="/En/SpiderMonkey/JSAPI_Reference/JS_FS" title="en/JS_FS">JS_FS</a></code>, and <code><a href="/En/SpiderMonkey/JSAPI_Reference/JS_FS" title="en/JS_FN">JS_FN</a></code>. Once a function is created, its flags cannot be modified.</p>
<table class="fullwidth-table"> <tbody> <tr> <th>Flag</th> <th>Description</th> </tr> <tr> <td> <p><code><strong>JSFUN_FAST_NATIVE</strong></code></p> </td> <td> <p>{{ jsapi_minversion_inline("1.8") }} The function is implemented as a C/C++ function implementing the <a href="/en/SpiderMonkey/JSAPI_Reference/JSFastNative" title="en/SpiderMonkey/JSAPI_Reference/JSFastNative"><code>JSFastNative</code></a> signature.</p> <p>{{ LXRSearch("ident", "i", "JSFUN_FAST_NATIVE") }}</p> </td> </tr> <tr> <td> <p><code><strong>JSFUN_THISP_STRING</strong></code></p> </td> <td> <p>If the <code>this</code> parameter passed to this function is a primitive string, it is not converted to a <code>String</code> object. Instead the string is passed directly to the native. The native should accomodate both <code>String</code> objects and strings as <code>this</code>.</p> <p>This can be used for a minor performance gain when defining methods on <code>String.prototype</code>.</p> <p>{{ LXRSearch("ident", "i", "JSFUN_THISP_STRING") }}</p> </td> </tr> <tr> <td> <p><code><strong>JSFUN_THISP_NUMBER</strong></code></p> </td> <td> <p>Like <code>JSFUN_THISP_STRING</code> but for numbers.</p> <p>{{ LXRSearch("ident", "i", "JSFUN_THISP_NUMBER") }}</p> </td> </tr> <tr> <td> <p><code><strong>JSFUN_THISP_BOOLEAN</strong></code></p> </td> <td> <p>Like <code>JSFUN_THISP_STRING</code> but for boolean values.</p> <p>{{ LXRSearch("ident", "i", "JSFUN_THISP_BOOLEAN") }}</p> </td> </tr> <tr> <td><strong><code>JSFUN_BOUND_METHOD</code></strong></td> <td> <p>{{ obsolete_inline() }}</p> <p>{{ LXRSearch("ident", "i", "JSFUN_BOUND_METHOD") }}</p> </td> </tr> </tbody>
</table>
<p>The JavaScript engine sometimes sets the following flags on functions written in JavaScript. Applications may not set these flags.</p>
<table class="fullwidth-table"> <tbody> <tr> <th>Flag</th> <th>Description</th> </tr> <tr> <td> <p><code><strong>JSFUN_LAMBDA</strong></code></p> </td> <td> <p>This flag is present on functions written as function-expressions rather than function-declarations, a grammatical distinction.  See {{ es3_spec("13") }}.</p> <p>{{ LXRSearch("ident", "i", "JSFUN_LAMBDA") }}</p> </td> </tr> <tr> <td><strong><code>JSFUN_HEAVYWEIGHT</code></strong></td> <td>For internal engine use.</td> </tr> <tr> <td><strong><code>JSFUN_GETTER</code></strong></td> <td>{{ obsolete_inline() }} This flag is present on getter functions declared using the obsolete syntax <code>getter function x() {...}</code>.</td> </tr> <tr> <td><strong><code>JSFUN_SETTER</code></strong></td> <td>{{ obsolete_inline() }} This flag is present on setter functions declared using the obsolete syntax <code>setter function x() {...}</code>.</td> </tr> </tbody>
</table>
<p>{{ LXRSearch("ident", "i", "JS_GetFunctionFlags") }}</p>
Revert to this revision