From 3b6f37dd2c336987251d53a4678396ef38921b3e Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Tue, 12 Apr 2011 19:15:00 +0200 Subject: FFI: Add ctype metamethods and ffi.metatype(). --- doc/ext_ffi_api.html | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'doc/ext_ffi_api.html') diff --git a/doc/ext_ffi_api.html b/doc/ext_ffi_api.html index 5bd4b80c..2b6d1d86 100644 --- a/doc/ext_ffi_api.html +++ b/doc/ext_ffi_api.html @@ -238,6 +238,31 @@ This functions is mainly useful to override the pointer compatibility checks or to convert pointers to addresses or vice versa.

+

ctype = ffi.metatype(ct, metatable)

+

+Creates a ctype object for the given ct and associates it with +a metatable. Only struct/union types, complex numbers +and vectors are allowed. Other types may be wrapped in a +struct, if needed. +

+

+The association with a metatable is permanent and cannot be changed +afterwards. Neither the contents of the metatable nor the +contents of an __index table (if any) may be modified +afterwards. The associated metatable automatically applies to all uses +of this type, no matter how the objects are created or where they +originate from. Note that pre-defined operations on types have +precedence (e.g. declared field names cannot be overriden). +

+

+All standard Lua metamethods are implemented. These are called directly, +without shortcuts and on any mix of types. For binary operations, the +left operand is checked first for a valid ctype metamethod. The +__gc metamethod only applies to struct/union +types and performs an implicit ffi.gc() +call during creation of an instance. +

+

cdata = ffi.gc(cdata, finalizer)

Associates a finalizer with a pointer or aggregate cdata object. The -- cgit v1.2.3-55-g6feb