diff --git a/doc/ext_ffi_semantics.html b/doc/ext_ffi_semantics.html index bacb4fb8..4b498fbe 100644 --- a/doc/ext_ffi_semantics.html +++ b/doc/ext_ffi_semantics.html @@ -590,8 +590,7 @@ ffi.new("struct nested", {x=1,y={2,3}}) --> x = 1, y.a = 2, y.b = 3
All of the standard Lua operators can be applied to cdata objects or a mix of a cdata object and another Lua object. The following list shows -the valid combinations. All other combinations currently raise an -error. +the pre-defined operations.
Reference types are dereferenced before performing each of @@ -600,7 +599,8 @@ C type pointed to by the reference.
The pre-defined operations are always tried first before deferring to a -metamethod for a ctype (if defined). +metamethod or index table (if any) for the corresponding ctype. An error +is raised if the metamethod lookup or index table lookup fails.
+A ctype object can be indexed with a string key, too. The only +pre-defined operation is reading scoped constants of +struct/union types. All other accesses defer +to the corresponding metamethods or index tables (if any). +
+Note: since there's (deliberately) no address-of operator, a cdata object holding a value type is effectively immutable after initialization. The JIT compiler benefits from this fact when applying diff --git a/src/lj_cdata.c b/src/lj_cdata.c index 482add4b..b477ce77 100644 --- a/src/lj_cdata.c +++ b/src/lj_cdata.c @@ -178,6 +178,7 @@ collect_attrib: if (fct && ctype_isconstval(fct->info)) return fct; } + ct = sct; /* Allow resolving metamethods for constructors, too. */ } } if (ctype_isptr(ct->info)) { /* Automatically perform '->'. */