diff options
Diffstat (limited to 'doc/ext_ffi_api.html')
-rw-r--r-- | doc/ext_ffi_api.html | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/doc/ext_ffi_api.html b/doc/ext_ffi_api.html index 7c2e53dd..9bedd52e 100644 --- a/doc/ext_ffi_api.html +++ b/doc/ext_ffi_api.html | |||
@@ -38,8 +38,6 @@ td.abiparam { font-weight: bold; width: 6em; } | |||
38 | </li><li> | 38 | </li><li> |
39 | <a class="current" href="ext_ffi_api.html">ffi.* API</a> | 39 | <a class="current" href="ext_ffi_api.html">ffi.* API</a> |
40 | </li><li> | 40 | </li><li> |
41 | <a href="ext_ffi_int64.html">64 bit Integers</a> | ||
42 | </li><li> | ||
43 | <a href="ext_ffi_semantics.html">FFI Semantics</a> | 41 | <a href="ext_ffi_semantics.html">FFI Semantics</a> |
44 | </li></ul> | 42 | </li></ul> |
45 | </li><li> | 43 | </li><li> |
@@ -106,7 +104,7 @@ follows: | |||
106 | </p> | 104 | </p> |
107 | <pre class="code"> | 105 | <pre class="code"> |
108 | ffi.cdef[[ | 106 | ffi.cdef[[ |
109 | <span style="color:#00a000;font-weight:bold;">typedef struct foo { int a, b; } foo_t; // Declare a struct and typedef. | 107 | <span style="color:#00a000;">typedef struct foo { int a, b; } foo_t; // Declare a struct and typedef. |
110 | int dofoo(foo_t *f, int n); /* Declare an external C function. */</span> | 108 | int dofoo(foo_t *f, int n); /* Declare an external C function. */</span> |
111 | ]] | 109 | ]] |
112 | </pre> | 110 | </pre> |
@@ -237,12 +235,8 @@ rules</a>. | |||
237 | </p> | 235 | </p> |
238 | <p> | 236 | <p> |
239 | This functions is mainly useful to override the pointer compatibility | 237 | This functions is mainly useful to override the pointer compatibility |
240 | rules or to convert pointers to addresses or vice versa. For maximum | 238 | checks or to convert pointers to addresses or vice versa. |
241 | portability you should convert a pointer to its address as follows: | ||
242 | </p> | 239 | </p> |
243 | <pre class="code"> | ||
244 | local addr = tonumber(ffi.cast("intptr_t", ptr)) | ||
245 | </pre> | ||
246 | 240 | ||
247 | <h2 id="info">C Type Information</h2> | 241 | <h2 id="info">C Type Information</h2> |
248 | <p> | 242 | <p> |
@@ -383,6 +377,45 @@ Contains the target OS name. Same contents as | |||
383 | Contains the target architecture name. Same contents as | 377 | Contains the target architecture name. Same contents as |
384 | <a href="ext_jit.html#jit_arch"><tt>jit.arch</tt></a>. | 378 | <a href="ext_jit.html#jit_arch"><tt>jit.arch</tt></a>. |
385 | </p> | 379 | </p> |
380 | |||
381 | <h2 id="extended">Extended Standard Library Functions</h2> | ||
382 | <p> | ||
383 | The following standard library functions have been extended to work | ||
384 | with cdata objects: | ||
385 | </p> | ||
386 | |||
387 | <h3 id="tonumber"><tt>n = tonumber(cdata)</tt></h3> | ||
388 | <p> | ||
389 | Converts a number cdata object to a <tt>double</tt> and returns it as | ||
390 | a Lua number. This is particularly useful for boxed 64 bit | ||
391 | integer values. Caveat: this conversion may incur a precision loss. | ||
392 | </p> | ||
393 | |||
394 | <h3 id="tostring"><tt>s = tostring(cdata)</tt></h3> | ||
395 | <p> | ||
396 | Returns a string representation of the value of 64 bit integers | ||
397 | (<tt><b>"</b>nnn<b>LL"</b></tt> or <tt><b>"</b>nnn<b>ULL"</b></tt>) or | ||
398 | complex numbers (<tt><b>"</b>re±im<b>i"</b></tt>). Otherwise | ||
399 | returns a string representation of the C type of a ctype object | ||
400 | (<tt><b>"ctype<</b>type<b>>"</b></tt>) or a cdata object | ||
401 | (<tt><b>"cdata<</b>type<b>>: </b>address"</tt>). | ||
402 | </p> | ||
403 | |||
404 | <h2 id="literals">Extensions to the Lua Parser</h2> | ||
405 | <p> | ||
406 | The parser for Lua source code treats numeric literals with the | ||
407 | suffixes <tt>LL</tt> or <tt>ULL</tt> as signed or unsigned 64 bit | ||
408 | integers. Case doesn't matter, but uppercase is recommended for | ||
409 | readability. It handles both decimal (<tt>42LL</tt>) and hexadecimal | ||
410 | (<tt>0x2aLL</tt>) literals. | ||
411 | </p> | ||
412 | <p> | ||
413 | The imaginary part of complex numbers can be specified by suffixing | ||
414 | number literals with <tt>i</tt> or <tt>I</tt>, e.g. <tt>12.5i</tt>. | ||
415 | Caveat: you'll need to use <tt>1i</tt> to get an imaginary part with | ||
416 | the value one, since <tt>i</tt> itself still refers to a variable | ||
417 | named <tt>i</tt>. | ||
418 | </p> | ||
386 | <br class="flush"> | 419 | <br class="flush"> |
387 | </div> | 420 | </div> |
388 | <div id="foot"> | 421 | <div id="foot"> |