mozilla

Revision 109742 of CData

  • Revision slug: Mozilla/js-ctypes/js-ctypes_reference/CData
  • Revision title: CData
  • Revision id: 109742
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment checkpoint; 297 words added, 2 words removed

Revision Content

{{ gecko_minversion_header("1.9.3") }}

{{ draft() }}

CData object represents a C value located in memory.

Method overview

CData address()
String toSource()
String toString()

Properties

Properties of all CData objects

Property Type Description
constructor CType

The data type of the CData object. Read only.

Note: This is never ctypes.void_t or an array type with an unspecified length.
value object The JavaScript equivalent of the CData object's value. This will throw a TypeError exception if the value can't be converted.

Methods

address()

Returns a CData object of the pointer type ctypes.PointerType(dataObject.constructor) whose value points to the C object referred to by the object. This provides a way to get a pointer to the actual data of the C value represented by the CData object.

CData address()
Parameters

None.

Return value

A CData object of the pointer type ctypes.PointerType(dataObject.constructor) whose value points to the C object referred to by the object.

toSource()

Returns the string "t(arg)", where t and arg are implementation-defined JavaScript expressions intended to represent type type of the CData object and its value, respectively.

String toSource()
Parameters

None.

Return value

A string that, ideally, should be able to be evaluated to produce a new CData object containing a copy of the original object. However, this only works if the object's type happens to be bound to an appropriate name in scope.

In theory, in other words, the following JavaScript expression should return a copy of the original CData object:

eval(dataObject.toSource());

Revision Source

<p>{{ gecko_minversion_header("1.9.3") }}</p>
<p>{{ draft() }}</p>
<p>A <code>CData</code> object represents a C value located in memory.</p>
<h2>Method overview</h2>
<table class="standard-table"> <tbody> <tr> <td><span style="font-family: monospace;">CData address()</span><code><br> </code></td> </tr> <tr> <td><code>String toSource()<br> </code></td> </tr> <tr> <td><code>String toString()<br> </code></td> </tr>  </tbody>
</table>
<h2>Properties</h2>
<h3>Properties of all CData objects</h3>
<table class="standard-table" style="width: auto;"> <tbody> <tr> <td class="header">Property</td> <td class="header">Type</td> <td class="header">Description</td> </tr> <tr> <td><code>constructor</code></td> <td><a href="/en/js-ctypes/js-ctypes_reference/CType" title="en/js-ctypes/js-ctypes reference/CType"><code>CType</code></a></td> <td> <p>The data type of the <code>CData</code> object. <strong>Read only.</strong></p> <div class="note"><strong>Note:</strong> This is never <code>ctypes.void_t</code> or an array type with an unspecified length.</div> </td> </tr> <tr> <td><code>value</code></td> <td>object</td> <td>The JavaScript equivalent of the <code>CData</code> object's value. This will throw a <code>TypeError</code> exception if the value can't be converted.</td> </tr>  </tbody>
</table>
<h2>Methods</h2>
<h3>address()</h3>
<p>Returns a <code>CData</code> object of the pointer type <code>ctypes.PointerType(<em>dataObject</em>.constructor)</code> whose value points to the C object referred to by the object. This provides a way to get a pointer to the actual data of the C value represented by the <code>CData</code> object.</p>
<pre>CData address()
</pre>
<h6>Parameters</h6>
<p>None.</p>
<h6>Return value</h6>
<p>A <code>CData</code> object of the pointer type <code>ctypes.PointerType(<em>dataObject</em>.constructor)</code> whose value points to the C object referred to by the object.</p>
<h3>toSource()</h3>
<p>Returns the string "<em>t</em>(<em>arg</em>)", where <em>t</em> and <em>arg</em> are implementation-defined JavaScript expressions intended to represent type type of the CData object and its value, respectively.</p>
<pre>String toSource()
</pre>
<h6>Parameters</h6>
<p>None.</p>
<h6>Return value</h6>
<p>A string that, ideally, should be able to be evaluated to produce a new <code>CData</code> object containing a copy of the original object. However, this only works if the object's type happens to be bound to an appropriate name in scope.</p>
<p>In theory, in other words, the following JavaScript expression should return a copy of the original CData object:</p>
<pre class="brush: js">eval(dataObject.toSource());
</pre>
Revert to this revision