diff options
Diffstat (limited to 'doc/ext_ffi_semantics.html')
-rw-r--r-- | doc/ext_ffi_semantics.html | 41 |
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 | |||
70 | TODO | 70 | TODO |
71 | </p> | 71 | </p> |
72 | 72 | ||
73 | <h2 id="init">Initializers</h2> | ||
74 | <p> | ||
75 | Creating a cdata object with <a href="ffi_ext_api.html#ffi_new">ffi.new()</a> | ||
76 | or the equivalent constructor syntax always initializes its contents, | ||
77 | too. Different rules apply, depending on the number of optional | ||
78 | initializers and the C 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. | ||
84 | The standard <a href="#convert">C type conversion rules</a> | ||
85 | apply.</li> | ||
86 | |||
87 | <li>Valarrays (complex numbers and vectors) are treated like scalars | ||
88 | when a single initializer is given. Otherwise they are treated like | ||
89 | regular arrays.</li> | ||
90 | |||
91 | <li>Aggregate types (arrays and structs) accept either a single | ||
92 | compound initializer (Lua table or string) or a flat list of | ||
93 | initializers.</li> | ||
94 | |||
95 | <li>The elements of an array are initialized, starting at index zero. | ||
96 | If a single initializer is given for an array, it's repeated for all | ||
97 | remaining elements. This doesn't happen if two or more initializers | ||
98 | are given: all remaining uninitialized elements are filled with zero | ||
99 | bytes.</li> | ||
100 | |||
101 | <li>The fields of a <tt>struct</tt> are initialized in the order of | ||
102 | their declaration. Uninitialized fields are filled with zero | ||
103 | bytes.</li> | ||
104 | |||
105 | <li>Only the first field of a <tt>union</tt> can be initialized with a | ||
106 | flat initializer.</li> | ||
107 | |||
108 | <li>Elements or fields which are aggregates themselves are initialized | ||
109 | with a <em>single</em> initializer, but this may be a compound | ||
110 | initializer 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> |
75 | A C library namespace is a special kind of object which allows | 116 | A C library namespace is a special kind of object which allows |