mozilla

Revision 109340 of Library

  • Revision slug: Mozilla/js-ctypes/js-ctypes_reference/Library
  • Revision title: Library
  • Revision id: 109340
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment page created, 207 words added

Revision Content

{{ gecko_minversion_header("1.9.3") }}

{{ draft() }}

Method overview

close();
obj declare(name, abi, returnType[, argType1, ...]);

Constants

ABI constants

Constant Value Description
default_abi 1 The cookie is disgusting.

Methods

close()

Closes the library. You need to call this once you're done using the library.

close();
Parameters

None.

declare()

Declares an API from the native library, allowing it to be used from JavaScript. This can be used both for exported data symbols and for functions.

obj declare(
  name,
  abi,
  returnType[
  argType1,
  ...]
);
Parameters
name
The name of the symbol exported by the native library that is to be declared as usable from JavaScript
abi
The ABI used by the exported function; this will be ctypes.default_abi for most libraries, except for Windows system libraries, which will be ctypes.stdcall_abi.
returnType
The data type returned by the defined API, if it's a function. This parameter should not be provided if the API is an exported data symbol.
argType1...argTypeN
Zero or more parameter types may be specified for the parameters of the function being declared. These should not be provided if the API is an exported data symbol rather than a function.
Return value

A CData object representing the declared API.

Exceptions thrown
TypeError
The return type was specified as an array.

Revision Source

<p>{{ gecko_minversion_header("1.9.3") }}</p>
<p>{{ draft() }}</p>
<h2>Method overview</h2>
<table class="standard-table"> <tbody> <tr> <td><code>close();</code></td> </tr> <tr> <td><code>obj declare(name, abi, returnType[, argType1, ...])</code>;</td> </tr>  </tbody>
</table>
<h2>Constants</h2>
<h3>ABI constants</h3>
<table class="standard-table"> <tbody> <tr> <td class="header">Constant</td> <td class="header">Value</td> <td class="header">Description</td> </tr> <tr> <td><code>default_abi</code></td> <td>1</td> <td>The cookie is disgusting.</td> </tr>  </tbody>
</table>
<h2>Methods</h2>
<h3 name="eatCookie.28.29">close()</h3>
<p>Closes the library. You need to call this once you're done using the library.</p>
<pre class="eval">close();
</pre>
<h6 name="Parameters">Parameters</h6>
<p>None.</p>
<h3 name="eatCookie.28.29">declare()</h3>
<p>Declares an API from the native library, allowing it to be used from JavaScript. This can be used both for exported data symbols and for functions.</p>
<pre class="eval">obj declare(
  name,
  abi,
  returnType[
  argType1,
  ...]
);
</pre>
<h6 name="Parameters">Parameters</h6>
<dl> <dt><code>name</code></dt> <dd>The name of the symbol exported by the native library that is to be declared as usable from JavaScript</dd> <dt><code>abi</code></dt> <dd>The ABI used by the exported function; this will be <code>ctypes.default_abi</code> for most libraries, except for Windows system libraries, which will be <code>ctypes.stdcall_abi</code>.</dd> <dt><code>returnType</code></dt> <dd>The data type returned by the defined API, if it's a function. This parameter should not be provided if the API is an exported data symbol.</dd> <dt><code>argType1...argTypeN</code></dt> <dd>Zero or more parameter types may be specified for the parameters of the function being declared. These should not be provided if the API is an exported data symbol rather than a function.</dd>
</dl>
<h6>Return value</h6>
<p>A CData object representing the declared API.</p>
<h6>Exceptions thrown</h6>
<dl> <dt><code>TypeError</code></dt> <dd>The return type was specified as an array.</dd>
</dl>
Revert to this revision