JS_FS

  • Revision slug: SpiderMonkey/JSAPI_Reference/JS_FS
  • Revision title: JS_FS
  • Revision id: 312585
  • Created:
  • Creator: tschneidereit
  • Is current revision? Yes
  • Comment

Revision Content

Macros for describing functions, for use with JS_DefineProperties and JS_InitClass.

Syntax

#define JS_FS(name, call, nargs, flags, extra)   ... /* a JSFunctionSpec initializer */

#define JS_FN(name, fastcall, nargs, flags)      ... /* a JSFunctionSpec initializer */

#define JS_FS_END {{ obsolete_inline("js1.8.5") }}... /* defines the end of the JSFunctionSpec array */
Name Type Description
name const char * The JavaScript name for the function. (or index, if JSPROP_INDEX is present in flags?)
call JSNative (in JS_FS only) Pointer to the C/C++ implementation of the function.
fastcall JSFastNative (in JS_FN only) Pointer to the C/C++ implementation of the function.
nargs uint16 The number of arguments the function expects.
flags uint16 The logical OR of zero or more function flags and property attributes.
extra uint32 (in JS_FS only) The number of extra slots the JSNative requires.

Description

Use these macros to define an array of JSFunctionSpecs to pass to JS_DefineFunctions or JS_InitClass.

Each call to JS_FS produces an initializer for a function implemented as a JSNative. Each call to JS_FN produces an initializer for a function implemented as a JSFastNative. These two may both be used in the same array. The last element of the array must be JS_FS_END.

See an example in the JSAPI User Guide.

{{ LXRSearch("ident", "i", "JS_FS") }}
{{ LXRSearch("ident", "i", "JS_FN") }}
{{ LXRSearch("ident", "i", "JS_FS_END") }}

Revision Source

<p>Macros for describing functions, for use with <a class="internal" href="/en/SpiderMonkey/JSAPI_Reference/JS_DefineProperties" title="en/SpiderMonkey/JSAPI Reference/JS DefineProperties"><code>JS_DefineProperties</code></a> and <a class="internal" href="/en/SpiderMonkey/JSAPI_Reference/JS_InitClass" title="en/SpiderMonkey/JSAPI Reference/JS InitClass"><code>JS_InitClass</code></a>.</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="eval">
#define <strong>JS_FS</strong>(name, call, nargs, flags, extra)   ... /* a JSFunctionSpec initializer */

#define <strong>JS_FN</strong>(name, fastcall, nargs, flags)      ... /* a JSFunctionSpec initializer */

#define <strong>JS_FS_END</strong> {{ obsolete_inline("js1.8.5") }}... /* defines the end of the JSFunctionSpec array */
</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&nbsp;char&nbsp;*</code></td>
      <td>The JavaScript name for the function. (or index, if JSPROP_INDEX is present in flags?)</td>
    </tr>
    <tr>
      <td><code>call</code></td>
      <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/JSNative" title="en/SpiderMonkey/JSAPI_Reference/JSNative">JSNative</a></code></td>
      <td><em>(in <code>JS_FS</code> only)</em> Pointer to the C/C++ implementation of the function.</td>
    </tr>
    <tr>
      <td><code>fastcall</code></td>
      <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/JSFastNative" title="en/SpiderMonkey/JSAPI_Reference/JSFastNative">JSFastNative</a></code></td>
      <td><em>(in <code>JS_FN</code> only)</em> Pointer to the C/C++ implementation of the function.</td>
    </tr>
    <tr>
      <td><code>nargs</code></td>
      <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/jsint" title="en/SpiderMonkey/JSAPI_Reference/jsint">uint16</a></code></td>
      <td>The number of arguments the function expects.</td>
    </tr>
    <tr>
      <td><code>flags</code></td>
      <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/jsint" title="en/SpiderMonkey/JSAPI_Reference/jsint">uint16</a></code></td>
      <td>The logical OR of zero or more <a href="/En/SpiderMonkey/JSAPI_Reference/JS_GetFunctionFlags#Function_flags" title="en/SpiderMonkey/JSAPI_Reference/JS_GetFunctionFlags#Function_flags">function flags</a> and <a href="/en/SpiderMonkey/JSAPI_Reference/JS_GetPropertyAttributes#Property_attributes" title="en/SpiderMonkey/JSAPI_Reference/JS_GetPropertyAttributes#Property_attributes">property attributes</a>.</td>
    </tr>
    <tr>
      <td><code>extra</code></td>
      <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/jsint" title="en/SpiderMonkey/JSAPI_Reference/jsint">uint32</a></code></td>
      <td><em>(in <code>JS_FS</code> only)</em> The number of extra slots the <code>JSNative</code> requires.</td>
    </tr>
  </tbody>
</table>
<h2 id="Description" name="Description">Description</h2>
<p>Use these macros to define an array of <code>JSFunctionSpec</code>s to pass to <a class="internal" href="/en/SpiderMonkey/JSAPI_Reference/JS_DefineFunctions" title="en/SpiderMonkey/JSAPI Reference/JS DefineFunctions"><code>JS_DefineFunctions</code></a> or <a class="internal" href="/en/SpiderMonkey/JSAPI_Reference/JS_InitClass" title="en/SpiderMonkey/JSAPI Reference/JS InitClass"><code>JS_InitClass</code></a>.</p>
<p>Each call to <strong><code>JS_FS</code></strong> produces an initializer for a function implemented as a <a href="/en/SpiderMonkey/JSAPI_Reference/JSNative" title="en/SpiderMonkey/JSAPI_Reference/JSNative"><code>JSNative</code></a>. Each call to <strong><code>JS_FN</code></strong> produces an initializer for a function implemented as a <a href="/en/SpiderMonkey/JSAPI_Reference/JSFastNative" title="en/SpiderMonkey/JSAPI_Reference/JSFastNative"><code>JSFastNative</code></a>. These two may both be used in the same array. The last element of the array must be <strong><code>JS_FS_END</code></strong>.</p>
<p>See an example in the <a href="/En/SpiderMonkey/JSAPI_User_Guide#Native_functions" title="En/SpiderMonkey/JSAPI_User_Guide#Native_functions">JSAPI User Guide</a>.</p>
<p>{{ LXRSearch("ident", "i", "JS_FS") }}<br />
  {{ LXRSearch("ident", "i", "JS_FN") }}<br />
  {{ LXRSearch("ident", "i", "JS_FS_END") }}</p>
Revert to this revision