156 /**
157 * Returns the memory address of the C {@code va_list} associated with this instance.
158 *
159 * @return the memory address of the C {@code va_list} associated with this instance.
160 */
161 MemoryAddress address();
162
163 /**
164 * Constructs a new {@code VaList} instance out of a memory address pointing to an existing C {@code va_list}.
165 *
166 * @param address a memory address pointing to an existing C {@code va_list}.
167 * @return a new {@code VaList} instance backed by the C {@code va_list} at {@code address}.
168 */
169 static VaList ofAddress(MemoryAddress address) {
170 return SharedUtils.newVaListOfAddress(address);
171 }
172
173 /**
174 * Constructs a new {@code VaList} using a builder (see {@link Builder}).
175 *
176 * @param actions a consumer for a builder (see {@link Builder}) which can be used to specify the contents
177 * of the underlying C {@code va_list}.
178 * @return a new {@code VaList} instance backed by a fresh C {@code va_list}.
179 */
180 static VaList make(Consumer<VaList.Builder> actions) {
181 return SharedUtils.newVaList(actions);
182 }
183
184 /**
185 * A builder interface used to construct a C {@code va_list}.
186 */
187 interface Builder {
188
189 /**
190 * Adds a native value represented as an {@code int} to the C {@code va_list} being constructed.
191 *
192 * @param layout the native layout of the value.
193 * @param value the value, represented as an {@code int}.
194 * @return this builder.
195 */
196 Builder vargFromInt(MemoryLayout layout, int value);
197
198 /**
199 * Adds a native value represented as a {@code long} to the C {@code va_list} being constructed.
200 *
201 * @param layout the native layout of the value.
202 * @param value the value, represented as a {@code long}.
203 * @return this builder.
|
156 /**
157 * Returns the memory address of the C {@code va_list} associated with this instance.
158 *
159 * @return the memory address of the C {@code va_list} associated with this instance.
160 */
161 MemoryAddress address();
162
163 /**
164 * Constructs a new {@code VaList} instance out of a memory address pointing to an existing C {@code va_list}.
165 *
166 * @param address a memory address pointing to an existing C {@code va_list}.
167 * @return a new {@code VaList} instance backed by the C {@code va_list} at {@code address}.
168 */
169 static VaList ofAddress(MemoryAddress address) {
170 return SharedUtils.newVaListOfAddress(address);
171 }
172
173 /**
174 * Constructs a new {@code VaList} using a builder (see {@link Builder}).
175 *
176 * Note that when there are no arguments added to the created va list,
177 * this method will return the same as {@linkplain #empty()}.
178 *
179 * @param actions a consumer for a builder (see {@link Builder}) which can be used to specify the contents
180 * of the underlying C {@code va_list}.
181 * @return a new {@code VaList} instance backed by a fresh C {@code va_list}.
182 */
183 static VaList make(Consumer<VaList.Builder> actions) {
184 return SharedUtils.newVaList(actions);
185 }
186
187 /**
188 * Returns an empty C {@code va_list} constant.
189 *
190 * The returned {@code VaList} can not be closed.
191 *
192 * @return a {@code VaList} modelling an empty C {@code va_list}.
193 */
194 static VaList empty() {
195 return SharedUtils.emptyVaList();
196 }
197
198 /**
199 * A builder interface used to construct a C {@code va_list}.
200 */
201 interface Builder {
202
203 /**
204 * Adds a native value represented as an {@code int} to the C {@code va_list} being constructed.
205 *
206 * @param layout the native layout of the value.
207 * @param value the value, represented as an {@code int}.
208 * @return this builder.
209 */
210 Builder vargFromInt(MemoryLayout layout, int value);
211
212 /**
213 * Adds a native value represented as a {@code long} to the C {@code va_list} being constructed.
214 *
215 * @param layout the native layout of the value.
216 * @param value the value, represented as a {@code long}.
217 * @return this builder.
|