summaryrefslogtreecommitdiff
path: root/doc/ext_ffi_semantics.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/ext_ffi_semantics.html')
-rw-r--r--doc/ext_ffi_semantics.html41
1 files changed, 41 insertions, 0 deletions
diff --git a/doc/ext_ffi_semantics.html b/doc/ext_ffi_semantics.html
index 598d44c9..4a1b6c11 100644
--- a/doc/ext_ffi_semantics.html
+++ b/doc/ext_ffi_semantics.html
@@ -70,6 +70,47 @@ TODO
70TODO 70TODO
71</p> 71</p>
72 72
73<h2 id="init">Initializers</h2>
74<p>
75Creating a cdata object with <a href="ffi_ext_api.html#ffi_new">ffi.new()</a>
76or the equivalent constructor syntax always initializes its contents,
77too. Different rules apply, depending on the number of optional
78initializers and the C&nbsp;types involved:
79</p>
80<ul>
81<li>If no initializers are given, the object is filled with zero bytes.</li>
82
83<li>Scalar types (numbers and pointers) accept a single initializer.
84The standard <a href="#convert">C&nbsp;type conversion rules</a>
85apply.</li>
86
87<li>Valarrays (complex numbers and vectors) are treated like scalars
88when a single initializer is given. Otherwise they are treated like
89regular arrays.</li>
90
91<li>Aggregate types (arrays and structs) accept either a single
92compound initializer (Lua table or string) or a flat list of
93initializers.</li>
94
95<li>The elements of an array are initialized, starting at index zero.
96If a single initializer is given for an array, it's repeated for all
97remaining elements. This doesn't happen if two or more initializers
98are given: all remaining uninitialized elements are filled with zero
99bytes.</li>
100
101<li>The fields of a <tt>struct</tt> are initialized in the order of
102their declaration. Uninitialized fields are filled with zero
103bytes.</li>
104
105<li>Only the first field of a <tt>union</tt> can be initialized with a
106flat initializer.</li>
107
108<li>Elements or fields which are aggregates themselves are initialized
109with a <em>single</em> initializer, but this may be a compound
110initializer or a compatible aggregate, of course.</li>
111
112</ul>
113
73<h2 id="clib">C Library Namespaces</h2> 114<h2 id="clib">C Library Namespaces</h2>
74<p> 115<p>
75A C&nbsp;library namespace is a special kind of object which allows 116A C&nbsp;library namespace is a special kind of object which allows