summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMike Pall <mike>2012-06-20 18:24:49 +0200
committerMike Pall <mike>2012-06-20 18:28:25 +0200
commit8b71ab108053c12bc2de9c1de0f786387a2b75e5 (patch)
tree98be8d9138d3cb13dac67f5f7621b0bf09bb0fc7 /doc
parente9e45313e737579bc6db4f74942bcd66e95532c1 (diff)
downloadluajit2-8b71ab108053c12bc2de9c1de0f786387a2b75e5.tar.gz
FFI: Check for __new metamethod when calling a constructor.
Diffstat (limited to 'doc')
-rw-r--r--doc/ext_ffi_semantics.html12
1 files changed, 9 insertions, 3 deletions
diff --git a/doc/ext_ffi_semantics.html b/doc/ext_ffi_semantics.html
index 4b498fbe..d0613aed 100644
--- a/doc/ext_ffi_semantics.html
+++ b/doc/ext_ffi_semantics.html
@@ -599,8 +599,9 @@ C&nbsp;type pointed to by the reference.
</p>
<p>
The pre-defined operations are always tried first before deferring to a
-metamethod or index table (if any) for the corresponding ctype. An error
-is raised if the metamethod lookup or index table lookup fails.
+metamethod or index table (if any) for the corresponding ctype (except
+for <tt>__new</tt>). An error is raised if the metamethod lookup or
+index table lookup fails.
</p>
<h3 id="cdata_array">Indexing a cdata object</h3>
@@ -669,7 +670,12 @@ to <tt>foo.c</tt>.
<ul>
<li><b>Constructor</b>: a ctype object can be called and used as a
-<a href="ext_ffi_api.html#ffi_new">constructor</a>.</li>
+<a href="ext_ffi_api.html#ffi_new">constructor</a>. This is equivalent
+to <tt>ffi.new(ct, ...)</tt>, unless a <tt>__new</tt> metamethod is
+defined. The <tt>__new</tt> metamethod is called with the ctype object
+plus any other arguments passed to the contructor. Note that you have to
+use <tt>ffi.new</tt> inside of it, since calling <tt>ct(...)</tt> would
+cause infinite recursion.</li>
<li><b>C&nbsp;function call</b>: a cdata function or cdata function
pointer can be called. The passed arguments are