diff options
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 |