MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See whistlepig.mozilla.org for all notifications.

mozilla

Revision 109346 of Library

  • Revision slug: Mozilla/js-ctypes/js-ctypes_reference/Library
  • Revision title: Library
  • Revision id: 109346
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment 32 words added

Revision Content

{{ gecko_minversion_header("1.9.3") }}

{{ draft() }}

The Library object represents a native library loaded by the ctypes open() method. Its methods let you declare symbols exported by the library, and to manage the library.

Method overview

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

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. See ABI constants.
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. For supported data types, see Data types.
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. For supported data types, see Data types.
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>
<p>The <code>Library</code> object represents a native library loaded by the ctypes <a href="/en/js-ctypes/js-ctypes_reference/ctypes#open()" title="en/js-ctypes/js-ctypes reference/ctypes#open()"><code>open()</code></a> method. Its methods let you declare symbols exported by the library, and to manage the library.</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>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>. See <a href="/en/js-ctypes/js-ctypes_reference#ABI_constants" title="en/js-ctypes/js-ctypes reference#ABI constants">ABI constants</a>.</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. For supported data types, see <a href="/en/js-ctypes/js-ctypes_reference#Data_type_constants" title="en/js-ctypes/js-ctypes reference#Data type constants">Data types</a>.</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. For supported data types, see <a href="/en/js-ctypes/js-ctypes_reference#Data_type_constants" title="en/js-ctypes/js-ctypes reference#Data type constants">Data types</a>.</dd>
</dl>
<h6>Return value</h6>
<p>A <code>CData</code> 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