diff options
| author | Mike Pall <mike> | 2011-11-14 14:15:57 +0100 |
|---|---|---|
| committer | Mike Pall <mike> | 2011-11-14 14:18:25 +0100 |
| commit | 71d00a56dbab6c29c0346093dbe530d7b7608be4 (patch) | |
| tree | 5e28e19b4d2f20168d5ee0e4fe500b1e2b233c1c /doc/ext_ffi_api.html | |
| parent | e9eb4fdb4a08baaa2d9190187a6c38d5b3f8b091 (diff) | |
| download | luajit-71d00a56dbab6c29c0346093dbe530d7b7608be4.tar.gz luajit-71d00a56dbab6c29c0346093dbe530d7b7608be4.tar.bz2 luajit-71d00a56dbab6c29c0346093dbe530d7b7608be4.zip | |
FFI: Add callback support (for x86/x64).
Diffstat (limited to 'doc/ext_ffi_api.html')
| -rw-r--r-- | doc/ext_ffi_api.html | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/doc/ext_ffi_api.html b/doc/ext_ffi_api.html index e865a5f7..222c580e 100644 --- a/doc/ext_ffi_api.html +++ b/doc/ext_ffi_api.html | |||
| @@ -78,6 +78,9 @@ corresponding <b>ctype</b>.</li> | |||
| 78 | <li><b>ct</b> — A C type specification which can be used for | 78 | <li><b>ct</b> — A C type specification which can be used for |
| 79 | most of the API functions. Either a <b>cdecl</b>, a <b>ctype</b> or a | 79 | most of the API functions. Either a <b>cdecl</b>, a <b>ctype</b> or a |
| 80 | <b>cdata</b> serving as a template type.</li> | 80 | <b>cdata</b> serving as a template type.</li> |
| 81 | <li><b>cb</b> — A callback object. This is a C data object | ||
| 82 | holding a special function pointer. Calling this function from | ||
| 83 | C code runs an associated Lua function.</li> | ||
| 81 | <li><b>VLA</b> — A variable-length array is declared with a | 84 | <li><b>VLA</b> — A variable-length array is declared with a |
| 82 | <tt>?</tt> instead of the number of elements, e.g. <tt>"int[?]"</tt>. | 85 | <tt>?</tt> instead of the number of elements, e.g. <tt>"int[?]"</tt>. |
| 83 | The number of elements (<tt>nelem</tt>) must be given when it's | 86 | The number of elements (<tt>nelem</tt>) must be given when it's |
| @@ -473,6 +476,31 @@ Contains the target architecture name. Same contents as | |||
| 473 | <a href="ext_jit.html#jit_arch"><tt>jit.arch</tt></a>. | 476 | <a href="ext_jit.html#jit_arch"><tt>jit.arch</tt></a>. |
| 474 | </p> | 477 | </p> |
| 475 | 478 | ||
| 479 | <h2 id="callback">Methods for Callbacks</h2> | ||
| 480 | <p> | ||
| 481 | The C types for <a href="ext_ffi_semantics.html#callback">callbacks</a> | ||
| 482 | have some extra methods: | ||
| 483 | </p> | ||
| 484 | |||
| 485 | <h3 id="callback_free"><tt>cb:free()</tt></h3> | ||
| 486 | <p> | ||
| 487 | Free the resources associated with a callback. The associated Lua | ||
| 488 | function is unanchored and may be garbage collected. The callback | ||
| 489 | function pointer is no longer valid and must not be called anymore | ||
| 490 | (it may be reused by a subsequently created callback). | ||
| 491 | </p> | ||
| 492 | |||
| 493 | <h3 id="callback_set"><tt>cb:set(func)</tt></h3> | ||
| 494 | <p> | ||
| 495 | Associate a new Lua function with a callback. The C type of the | ||
| 496 | callback and the callback function pointer are unchanged. | ||
| 497 | </p> | ||
| 498 | <p> | ||
| 499 | This method is useful to dynamically switch the receiver of callbacks | ||
| 500 | without creating a new callback each time and registering it again (e.g. | ||
| 501 | with a GUI library). | ||
| 502 | </p> | ||
| 503 | |||
| 476 | <h2 id="extended">Extended Standard Library Functions</h2> | 504 | <h2 id="extended">Extended Standard Library Functions</h2> |
| 477 | <p> | 505 | <p> |
| 478 | The following standard library functions have been extended to work | 506 | The following standard library functions have been extended to work |
