From 8b71ab108053c12bc2de9c1de0f786387a2b75e5 Mon Sep 17 00:00:00 2001
From: Mike Pall
Date: Wed, 20 Jun 2012 18:24:49 +0200
Subject: FFI: Check for __new metamethod when calling a constructor.
---
doc/ext_ffi_semantics.html | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
(limited to 'doc/ext_ffi_semantics.html')
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.
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 __new). An error is raised if the metamethod lookup or
+index table lookup fails.
Indexing a cdata object
@@ -669,7 +670,12 @@ to foo.c.
- Constructor: a ctype object can be called and used as a
-constructor.
+constructor. This is equivalent
+to ffi.new(ct, ...), unless a __new metamethod is
+defined. The __new metamethod is called with the ctype object
+plus any other arguments passed to the contructor. Note that you have to
+use ffi.new inside of it, since calling ct(...) would
+cause infinite recursion.
- C function call: a cdata function or cdata function
pointer can be called. The passed arguments are
--
cgit v1.2.3-55-g6feb