Revision 4047 of js-ctypes reference

  • Revision slug: Mozilla/js-ctypes/js-ctypes_reference
  • Revision title: js-ctypes reference
  • Revision id: 4047
  • Created:
  • Creator: bholley
  • Is current revision? No
  • Comment 198 words added

Revision Content

{{ gecko_minversion_header("2.0") }}{{ draft() }}

There are several steps required to use js-ctypes effectively. This reference presents these topics roughly in the order that you'll need them.

Importing the js-ctypes Module

In order to use js-ctypes, you must import the ctypes.jsm module in your code. This creates a global variable called ctypes.

The Global ctypes Object

You can use the ctypes object to load libraries, construct types, and perform miscellaneous tasks such as type casting.

Working With Libraries

Loading a library with ctypes.open() returns a Library object. This is used mostly to declare native functions provided by the library so that js-ctypes knows how to call them.

Types and Data

To use js-ctypes effectively, it is important to understand the different kinds of objects that the module provides. There are three major categories:

  1. Type Constructors. These are functions that define new types, and thus return a CType object. These include ctypes.PointerType(), ctypes.ArrayType(), ctypes.StructType(), and ctypes.FunctionType().
  2. Types. These

 

This page is sort of a placeholder; I'll sort out how I'm going to structure it soon. For now, here are the links to the subpages covering the various objects involved in using js-ctypes:

{{ tree() }}

Revision Source

<p>{{ gecko_minversion_header("2.0") }}{{ draft() }}</p>
<p>There are several steps required to use js-ctypes effectively. This reference presents these topics roughly in the order that you'll need them.</p>
<h2>Importing the js-ctypes Module</h2>
<p>In order to use js-ctypes, you must <a href="/en/JavaScript_code_modules/ctypes.jsm" title="en/JavaScript code modules/ctypes.jsm">import the <code>ctypes.jsm</code> module</a> in your code. This creates a global variable called <code>ctypes</code>.</p>
<h2>The Global ctypes Object</h2>
<p>You can use the <a href="/en/js-ctypes/js-ctypes_reference/ctypes" title="en/js-ctypes/js-ctypes reference/ctypes"><code>ctypes</code></a> object to load libraries, construct types, and perform miscellaneous tasks such as type casting.</p>
<h2>Working With Libraries</h2>
<p>Loading a library with <a href="/en/js-ctypes/js-ctypes_reference/ctypes#open()" title="en/js-ctypes/js-ctypes reference/ctypes#open()">ctypes.open()</a> returns a <a href="/en/js-ctypes/js-ctypes_reference/Library" title="en/js-ctypes/js-ctypes reference/Library">Library</a> object. This is used mostly to declare native functions provided by the library so that js-ctypes knows how to call them.</p>
<h2>Types and Data</h2>
<p>To use js-ctypes effectively, it is important to understand the different kinds of objects that the module provides. There are three major categories:</p>
<ol> <li><strong>Type Constructors</strong>. These are functions that define new types, and thus return a <a href="/CType" title="CType">CType</a> object. These include ctypes.PointerType(), ctypes.ArrayType(), ctypes.StructType(), and ctypes.FunctionType(). </li> <li>Types. These </li>
</ol>
<p> </p>
<p>This page is sort of a placeholder; I'll sort out how I'm going to structure it soon. For now, here are the links to the subpages covering the various objects involved in using js-ctypes:</p>
<p>{{ tree() }}</p>
Revert to this revision