diff options
author | Mike Pall <mike> | 2012-06-20 18:24:49 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2012-06-20 18:28:25 +0200 |
commit | 8b71ab108053c12bc2de9c1de0f786387a2b75e5 (patch) | |
tree | 98be8d9138d3cb13dac67f5f7621b0bf09bb0fc7 /doc/ext_ffi_semantics.html | |
parent | e9e45313e737579bc6db4f74942bcd66e95532c1 (diff) | |
download | luajit-8b71ab108053c12bc2de9c1de0f786387a2b75e5.tar.gz luajit-8b71ab108053c12bc2de9c1de0f786387a2b75e5.tar.bz2 luajit-8b71ab108053c12bc2de9c1de0f786387a2b75e5.zip |
FFI: Check for __new metamethod when calling a constructor.
Diffstat (limited to 'doc/ext_ffi_semantics.html')
-rw-r--r-- | doc/ext_ffi_semantics.html | 12 |
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 type pointed to by the reference. | |||
599 | </p> | 599 | </p> |
600 | <p> | 600 | <p> |
601 | The pre-defined operations are always tried first before deferring to a | 601 | The pre-defined operations are always tried first before deferring to a |
602 | metamethod or index table (if any) for the corresponding ctype. An error | 602 | metamethod or index table (if any) for the corresponding ctype (except |
603 | is raised if the metamethod lookup or index table lookup fails. | 603 | for <tt>__new</tt>). An error is raised if the metamethod lookup or |
604 | index table lookup fails. | ||
604 | </p> | 605 | </p> |
605 | 606 | ||
606 | <h3 id="cdata_array">Indexing a cdata object</h3> | 607 | <h3 id="cdata_array">Indexing a cdata object</h3> |
@@ -669,7 +670,12 @@ to <tt>foo.c</tt>. | |||
669 | <ul> | 670 | <ul> |
670 | 671 | ||
671 | <li><b>Constructor</b>: a ctype object can be called and used as a | 672 | <li><b>Constructor</b>: a ctype object can be called and used as a |
672 | <a href="ext_ffi_api.html#ffi_new">constructor</a>.</li> | 673 | <a href="ext_ffi_api.html#ffi_new">constructor</a>. This is equivalent |
674 | to <tt>ffi.new(ct, ...)</tt>, unless a <tt>__new</tt> metamethod is | ||
675 | defined. The <tt>__new</tt> metamethod is called with the ctype object | ||
676 | plus any other arguments passed to the contructor. Note that you have to | ||
677 | use <tt>ffi.new</tt> inside of it, since calling <tt>ct(...)</tt> would | ||
678 | cause infinite recursion.</li> | ||
673 | 679 | ||
674 | <li><b>C function call</b>: a cdata function or cdata function | 680 | <li><b>C function call</b>: a cdata function or cdata function |
675 | pointer can be called. The passed arguments are | 681 | pointer can be called. The passed arguments are |