lib: rename option/var. "selector" to "selector field"
[babeltrace.git] / src / lib / trace-ir / field.c
CommitLineData
273b65be 1/*
f2b0325d 2 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
de9dd397 3 * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
273b65be
JG
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
b03487ab 24#define BT_LOG_TAG "LIB/FIELD"
1633ef46 25#include "lib/logging.h"
fc25abce 26
57952005 27#include "lib/assert-pre.h"
71c5da58
MJ
28#include <babeltrace2/trace-ir/field.h>
29#include <babeltrace2/trace-ir/field-const.h>
57952005
MJ
30#include "lib/object.h"
31#include "compat/compiler.h"
32#include "compat/fcntl.h"
33#include "common/align.h"
34#include "common/assert.h"
fc25abce 35#include <inttypes.h>
273b65be 36
57952005
MJ
37#include "field.h"
38#include "field-class.h"
fb25b9e3 39#include "lib/func-status.h"
57952005 40
18acc6f8 41static
7b33a0e0 42void reset_single_field(struct bt_field *field);
18acc6f8
PP
43
44static
7b33a0e0 45void reset_array_field(struct bt_field *field);
18acc6f8
PP
46
47static
7b33a0e0 48void reset_structure_field(struct bt_field *field);
18acc6f8 49
247fa9e3
PP
50static
51void reset_option_field(struct bt_field *field);
52
18acc6f8 53static
7b33a0e0 54void reset_variant_field(struct bt_field *field);
18acc6f8
PP
55
56static
7b33a0e0 57void set_single_field_is_frozen(struct bt_field *field, bool is_frozen);
18acc6f8
PP
58
59static
7b33a0e0 60void set_array_field_is_frozen(struct bt_field *field, bool is_frozen);
18acc6f8
PP
61
62static
7b33a0e0 63void set_structure_field_is_frozen(struct bt_field *field, bool is_frozen);
18acc6f8 64
247fa9e3
PP
65static
66void set_option_field_is_frozen(struct bt_field *field, bool is_frozen);
67
18acc6f8 68static
7b33a0e0 69void set_variant_field_is_frozen(struct bt_field *field, bool is_frozen);
18acc6f8
PP
70
71static
78cf9df6 72bool single_field_is_set(const struct bt_field *field);
18acc6f8
PP
73
74static
78cf9df6 75bool array_field_is_set(const struct bt_field *field);
18acc6f8
PP
76
77static
78cf9df6 78bool structure_field_is_set(const struct bt_field *field);
18acc6f8 79
247fa9e3
PP
80static
81bool option_field_is_set(const struct bt_field *field);
82
18acc6f8 83static
78cf9df6 84bool variant_field_is_set(const struct bt_field *field);
18acc6f8 85
9414b439
PP
86static
87struct bt_field_methods bool_field_methods = {
88 .set_is_frozen = set_single_field_is_frozen,
89 .is_set = single_field_is_set,
90 .reset = reset_single_field,
91};
92
6943da6a
PP
93static
94struct bt_field_methods bit_array_field_methods = {
95 .set_is_frozen = set_single_field_is_frozen,
96 .is_set = single_field_is_set,
97 .reset = reset_single_field,
98};
99
18acc6f8 100static
7b33a0e0
PP
101struct bt_field_methods integer_field_methods = {
102 .set_is_frozen = set_single_field_is_frozen,
103 .is_set = single_field_is_set,
104 .reset = reset_single_field,
8deee039 105};
273b65be 106
7b33a0e0
PP
107static
108struct bt_field_methods real_field_methods = {
109 .set_is_frozen = set_single_field_is_frozen,
110 .is_set = single_field_is_set,
111 .reset = reset_single_field,
12c8a1a3
JG
112};
113
7b33a0e0
PP
114static
115struct bt_field_methods string_field_methods = {
116 .set_is_frozen = set_single_field_is_frozen,
117 .is_set = single_field_is_set,
118 .reset = reset_single_field,
273b65be
JG
119};
120
7b33a0e0
PP
121static
122struct bt_field_methods structure_field_methods = {
123 .set_is_frozen = set_structure_field_is_frozen,
124 .is_set = structure_field_is_set,
125 .reset = reset_structure_field,
87d43dc1
JG
126};
127
7b33a0e0
PP
128static
129struct bt_field_methods array_field_methods = {
130 .set_is_frozen = set_array_field_is_frozen,
131 .is_set = array_field_is_set,
132 .reset = reset_array_field,
918be005
PP
133};
134
247fa9e3
PP
135static
136struct bt_field_methods option_field_methods = {
137 .set_is_frozen = set_option_field_is_frozen,
138 .is_set = option_field_is_set,
139 .reset = reset_option_field,
140};
141
76f869ab 142static
7b33a0e0
PP
143struct bt_field_methods variant_field_methods = {
144 .set_is_frozen = set_variant_field_is_frozen,
145 .is_set = variant_field_is_set,
146 .reset = reset_variant_field,
147};
76f869ab 148
9414b439
PP
149static
150struct bt_field *create_bool_field(struct bt_field_class *);
151
6943da6a
PP
152static
153struct bt_field *create_bit_array_field(struct bt_field_class *);
154
8deee039 155static
939190b3 156struct bt_field *create_integer_field(struct bt_field_class *);
8deee039
PP
157
158static
939190b3 159struct bt_field *create_real_field(struct bt_field_class *);
8deee039
PP
160
161static
939190b3 162struct bt_field *create_string_field(struct bt_field_class *);
8deee039
PP
163
164static
939190b3 165struct bt_field *create_structure_field(struct bt_field_class *);
8deee039 166static
939190b3 167struct bt_field *create_static_array_field(struct bt_field_class *);
8b45963b 168
8deee039 169static
939190b3 170struct bt_field *create_dynamic_array_field(struct bt_field_class *);
8b45963b 171
247fa9e3
PP
172static
173struct bt_field *create_option_field(struct bt_field_class *);
174
8deee039 175static
939190b3 176struct bt_field *create_variant_field(struct bt_field_class *);
8b45963b 177
8deee039 178static
939190b3 179struct bt_field *(* const field_create_funcs[])(struct bt_field_class *) = {
467673c1
PP
180 [BT_FIELD_CLASS_TYPE_BOOL] = create_bool_field,
181 [BT_FIELD_CLASS_TYPE_BIT_ARRAY] = create_bit_array_field,
182 [BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER] = create_integer_field,
183 [BT_FIELD_CLASS_TYPE_SIGNED_INTEGER] = create_integer_field,
184 [BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION] = create_integer_field,
185 [BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION] = create_integer_field,
186 [BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL] = create_real_field,
187 [BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL] = create_real_field,
188 [BT_FIELD_CLASS_TYPE_STRING] = create_string_field,
189 [BT_FIELD_CLASS_TYPE_STRUCTURE] = create_structure_field,
190 [BT_FIELD_CLASS_TYPE_STATIC_ARRAY] = create_static_array_field,
b8ddb4f0
PP
191 [BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD] = create_dynamic_array_field,
192 [BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD] = create_dynamic_array_field,
8bc207af
PP
193 [BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD] = create_option_field,
194 [BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD] = create_option_field,
195 [BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD] = create_option_field,
196 [BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD] = create_option_field,
197 [BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD] = create_variant_field,
198 [BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD] = create_variant_field,
199 [BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD] = create_variant_field,
8deee039 200};
8b45963b 201
9414b439
PP
202static
203void destroy_bool_field(struct bt_field *field);
204
6943da6a
PP
205static
206void destroy_bit_array_field(struct bt_field *field);
207
a6918753 208static
7b33a0e0 209void destroy_integer_field(struct bt_field *field);
a6918753
PP
210
211static
7b33a0e0 212void destroy_real_field(struct bt_field *field);
a6918753
PP
213
214static
7b33a0e0 215void destroy_string_field(struct bt_field *field);
a6918753
PP
216
217static
7b33a0e0 218void destroy_structure_field(struct bt_field *field);
a6918753
PP
219
220static
7b33a0e0 221void destroy_array_field(struct bt_field *field);
a6918753 222
247fa9e3
PP
223static
224void destroy_option_field(struct bt_field *field);
225
a6918753 226static
7b33a0e0 227void destroy_variant_field(struct bt_field *field);
a6918753
PP
228
229static
230void (* const field_destroy_funcs[])(struct bt_field *) = {
467673c1
PP
231 [BT_FIELD_CLASS_TYPE_BOOL] = destroy_bool_field,
232 [BT_FIELD_CLASS_TYPE_BIT_ARRAY] = destroy_bit_array_field,
233 [BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER] = destroy_integer_field,
234 [BT_FIELD_CLASS_TYPE_SIGNED_INTEGER] = destroy_integer_field,
235 [BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION] = destroy_integer_field,
236 [BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION] = destroy_integer_field,
237 [BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL] = destroy_real_field,
238 [BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL] = destroy_real_field,
239 [BT_FIELD_CLASS_TYPE_STRING] = destroy_string_field,
240 [BT_FIELD_CLASS_TYPE_STRUCTURE] = destroy_structure_field,
241 [BT_FIELD_CLASS_TYPE_STATIC_ARRAY] = destroy_array_field,
b8ddb4f0
PP
242 [BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD] = destroy_array_field,
243 [BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD] = destroy_array_field,
8bc207af
PP
244 [BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD] = destroy_option_field,
245 [BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD] = destroy_option_field,
246 [BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD] = destroy_option_field,
247 [BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD] = destroy_option_field,
248 [BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD] = destroy_variant_field,
249 [BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD] = destroy_variant_field,
250 [BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD] = destroy_variant_field,
a6918753
PP
251};
252
844d5df6 253struct bt_field_class *bt_field_borrow_class(struct bt_field *field)
18acc6f8 254{
fa6cfec3 255 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
939190b3 256 return field->class;
18acc6f8
PP
257}
258
78cf9df6
PP
259const struct bt_field_class *bt_field_borrow_class_const(
260 const struct bt_field *field)
9e550e5f 261{
fa6cfec3 262 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
78cf9df6 263 return field->class;
9e550e5f
PP
264}
265
78cf9df6 266enum bt_field_class_type bt_field_get_class_type(const struct bt_field *field)
18acc6f8 267{
fa6cfec3 268 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
af0c18e3 269 return field->class->type;
18acc6f8
PP
270}
271
a6918753 272BT_HIDDEN
939190b3 273struct bt_field *bt_field_create(struct bt_field_class *fc)
273b65be 274{
839d52a5 275 struct bt_field *field = NULL;
7b33a0e0 276
fa6cfec3 277 BT_ASSERT(fc);
af0c18e3 278 field = field_create_funcs[fc->type](fc);
273b65be 279 if (!field) {
a8f90e5d 280 BT_LIB_LOGE_APPEND_CAUSE("Cannot create field object from field class: "
939190b3 281 "%![fc-]+F", fc);
8deee039 282 goto end;
273b65be
JG
283 }
284
8deee039
PP
285end:
286 return field;
273b65be
JG
287}
288
7b33a0e0 289static inline
939190b3 290void init_field(struct bt_field *field, struct bt_field_class *fc,
7b33a0e0 291 struct bt_field_methods *methods)
cd95e351 292{
7b33a0e0 293 BT_ASSERT(field);
939190b3 294 BT_ASSERT(fc);
7b33a0e0
PP
295 bt_object_init_unique(&field->base);
296 field->methods = methods;
4b70020d 297 field->class = fc;
864aa43f 298 bt_object_get_ref_no_null_check(fc);
cd95e351
JG
299}
300
9414b439
PP
301static
302struct bt_field *create_bool_field(struct bt_field_class *fc)
303{
304 struct bt_field_bool *bool_field;
305
306 BT_LIB_LOGD("Creating boolean field object: %![fc-]+F", fc);
307 bool_field = g_new0(struct bt_field_bool, 1);
308 if (!bool_field) {
309 BT_LIB_LOGE_APPEND_CAUSE(
310 "Failed to allocate one boolean field.");
311 goto end;
312 }
313
314 init_field((void *) bool_field, fc, &bool_field_methods);
315 BT_LIB_LOGD("Created boolean field object: %!+f", bool_field);
316
317end:
318 return (void *) bool_field;
319}
320
6943da6a
PP
321static
322struct bt_field *create_bit_array_field(struct bt_field_class *fc)
323{
324 struct bt_field_bit_array *ba_field;
325
326 BT_LIB_LOGD("Creating bit array field object: %![fc-]+F", fc);
327 ba_field = g_new0(struct bt_field_bit_array, 1);
328 if (!ba_field) {
329 BT_LIB_LOGE_APPEND_CAUSE(
330 "Failed to allocate one bit array field.");
331 goto end;
332 }
333
334 init_field((void *) ba_field, fc, &bit_array_field_methods);
335 BT_LIB_LOGD("Created bit array field object: %!+f", ba_field);
336
337end:
338 return (void *) ba_field;
339}
340
7b33a0e0 341static
939190b3 342struct bt_field *create_integer_field(struct bt_field_class *fc)
4ebcc695 343{
7b33a0e0
PP
344 struct bt_field_integer *int_field;
345
939190b3 346 BT_LIB_LOGD("Creating integer field object: %![fc-]+F", fc);
7b33a0e0
PP
347 int_field = g_new0(struct bt_field_integer, 1);
348 if (!int_field) {
a8f90e5d
PP
349 BT_LIB_LOGE_APPEND_CAUSE(
350 "Failed to allocate one integer field.");
7b33a0e0
PP
351 goto end;
352 }
353
939190b3 354 init_field((void *) int_field, fc, &integer_field_methods);
7b33a0e0
PP
355 BT_LIB_LOGD("Created integer field object: %!+f", int_field);
356
357end:
358 return (void *) int_field;
4ebcc695
PP
359}
360
7b33a0e0 361static
939190b3 362struct bt_field *create_real_field(struct bt_field_class *fc)
fea75608 363{
7b33a0e0 364 struct bt_field_real *real_field;
18acc6f8 365
939190b3 366 BT_LIB_LOGD("Creating real field object: %![fc-]+F", fc);
7b33a0e0
PP
367 real_field = g_new0(struct bt_field_real, 1);
368 if (!real_field) {
a8f90e5d 369 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one real field.");
7b33a0e0
PP
370 goto end;
371 }
372
939190b3 373 init_field((void *) real_field, fc, &real_field_methods);
7b33a0e0
PP
374 BT_LIB_LOGD("Created real field object: %!+f", real_field);
375
376end:
377 return (void *) real_field;
fea75608
PP
378}
379
7b33a0e0 380static
939190b3 381struct bt_field *create_string_field(struct bt_field_class *fc)
273b65be 382{
7b33a0e0 383 struct bt_field_string *string_field;
18acc6f8 384
939190b3 385 BT_LIB_LOGD("Creating string field object: %![fc-]+F", fc);
7b33a0e0
PP
386 string_field = g_new0(struct bt_field_string, 1);
387 if (!string_field) {
a8f90e5d
PP
388 BT_LIB_LOGE_APPEND_CAUSE(
389 "Failed to allocate one string field.");
7b33a0e0
PP
390 goto end;
391 }
18acc6f8 392
939190b3 393 init_field((void *) string_field, fc, &string_field_methods);
7b33a0e0
PP
394 string_field->buf = g_array_sized_new(FALSE, FALSE,
395 sizeof(char), 1);
396 if (!string_field->buf) {
a8f90e5d 397 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GArray.");
6a9bd19d
FD
398 bt_field_destroy((void *) string_field);
399 string_field = NULL;
7b33a0e0
PP
400 goto end;
401 }
18acc6f8 402
7b33a0e0
PP
403 g_array_index(string_field->buf, char, 0) = '\0';
404 BT_LIB_LOGD("Created string field object: %!+f", string_field);
18acc6f8 405
7b33a0e0
PP
406end:
407 return (void *) string_field;
408}
18acc6f8 409
7b33a0e0 410static inline
939190b3
PP
411int create_fields_from_named_field_classes(
412 struct bt_field_class_named_field_class_container *fc,
7b33a0e0
PP
413 GPtrArray **fields)
414{
415 int ret = 0;
416 uint64_t i;
18acc6f8 417
7b33a0e0
PP
418 *fields = g_ptr_array_new_with_free_func(
419 (GDestroyNotify) bt_field_destroy);
420 if (!*fields) {
a8f90e5d 421 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GPtrArray.");
7b33a0e0
PP
422 ret = -1;
423 goto end;
18acc6f8
PP
424 }
425
939190b3 426 g_ptr_array_set_size(*fields, fc->named_fcs->len);
7b33a0e0 427
939190b3 428 for (i = 0; i < fc->named_fcs->len; i++) {
7b33a0e0 429 struct bt_field *field;
02b61fe0 430 struct bt_named_field_class *named_fc = fc->named_fcs->pdata[i];
7b33a0e0 431
939190b3 432 field = bt_field_create(named_fc->fc);
7b33a0e0 433 if (!field) {
a8f90e5d
PP
434 BT_LIB_LOGE_APPEND_CAUSE(
435 "Failed to create structure member or variant option field: "
939190b3
PP
436 "name=\"%s\", %![fc-]+F",
437 named_fc->name->str, named_fc->fc);
7b33a0e0
PP
438 ret = -1;
439 goto end;
440 }
441
442 g_ptr_array_index(*fields, i) = field;
443 }
18acc6f8
PP
444
445end:
446 return ret;
273b65be
JG
447}
448
7b33a0e0 449static
939190b3 450struct bt_field *create_structure_field(struct bt_field_class *fc)
cd95e351 451{
7b33a0e0 452 struct bt_field_structure *struct_field;
18acc6f8 453
939190b3 454 BT_LIB_LOGD("Creating structure field object: %![fc-]+F", fc);
7b33a0e0
PP
455 struct_field = g_new0(struct bt_field_structure, 1);
456 if (!struct_field) {
a8f90e5d
PP
457 BT_LIB_LOGE_APPEND_CAUSE(
458 "Failed to allocate one structure field.");
7b33a0e0
PP
459 goto end;
460 }
fc25abce 461
939190b3 462 init_field((void *) struct_field, fc, &structure_field_methods);
7b33a0e0 463
939190b3 464 if (create_fields_from_named_field_classes((void *) fc,
7b33a0e0 465 &struct_field->fields)) {
a8f90e5d
PP
466 BT_LIB_LOGE_APPEND_CAUSE(
467 "Cannot create structure member fields: %![fc-]+F", fc);
6a9bd19d
FD
468 bt_field_destroy((void *) struct_field);
469 struct_field = NULL;
7b33a0e0 470 goto end;
18acc6f8
PP
471 }
472
7b33a0e0 473 BT_LIB_LOGD("Created structure field object: %!+f", struct_field);
18acc6f8 474
7b33a0e0
PP
475end:
476 return (void *) struct_field;
cd95e351
JG
477}
478
247fa9e3
PP
479static
480struct bt_field *create_option_field(struct bt_field_class *fc)
481{
482 struct bt_field_option *opt_field;
483 struct bt_field_class_option *opt_fc = (void *) fc;
484
485 BT_LIB_LOGD("Creating option field object: %![fc-]+F", fc);
486 opt_field = g_new0(struct bt_field_option, 1);
487 if (!opt_field) {
488 BT_LIB_LOGE_APPEND_CAUSE(
489 "Failed to allocate one option field.");
490 goto end;
491 }
492
493 init_field((void *) opt_field, fc, &option_field_methods);
494 opt_field->content_field = bt_field_create(opt_fc->content_fc);
495 if (!opt_field->content_field) {
496 BT_LIB_LOGE_APPEND_CAUSE(
497 "Failed to create option field's content field: "
498 "%![opt-fc-]+F, %![content-fc-]+F",
499 opt_fc, opt_fc->content_fc);
6a9bd19d
FD
500 bt_field_destroy((void *) opt_field);
501 opt_field = NULL;
247fa9e3
PP
502 goto end;
503 }
504
505 BT_LIB_LOGD("Created option field object: %!+f", opt_field);
506
507end:
508 return (void *) opt_field;
509}
510
7b33a0e0 511static
939190b3 512struct bt_field *create_variant_field(struct bt_field_class *fc)
273b65be 513{
7b33a0e0 514 struct bt_field_variant *var_field;
18acc6f8 515
939190b3 516 BT_LIB_LOGD("Creating variant field object: %![fc-]+F", fc);
7b33a0e0
PP
517 var_field = g_new0(struct bt_field_variant, 1);
518 if (!var_field) {
a8f90e5d
PP
519 BT_LIB_LOGE_APPEND_CAUSE(
520 "Failed to allocate one variant field.");
7b33a0e0
PP
521 goto end;
522 }
8b45963b 523
939190b3 524 init_field((void *) var_field, fc, &variant_field_methods);
18acc6f8 525
939190b3 526 if (create_fields_from_named_field_classes((void *) fc,
7b33a0e0 527 &var_field->fields)) {
a8f90e5d 528 BT_LIB_LOGE_APPEND_CAUSE("Cannot create variant member fields: "
939190b3 529 "%![fc-]+F", fc);
6a9bd19d
FD
530 bt_field_destroy((void *) var_field);
531 var_field = NULL;
7b33a0e0
PP
532 goto end;
533 }
273b65be 534
7b33a0e0 535 BT_LIB_LOGD("Created variant field object: %!+f", var_field);
18acc6f8 536
7b33a0e0
PP
537end:
538 return (void *) var_field;
18acc6f8
PP
539}
540
541static inline
7b33a0e0 542int init_array_field_fields(struct bt_field_array *array_field)
18acc6f8
PP
543{
544 int ret = 0;
7b33a0e0 545 uint64_t i;
939190b3 546 struct bt_field_class_array *array_fc;
18acc6f8 547
7b33a0e0 548 BT_ASSERT(array_field);
939190b3 549 array_fc = (void *) array_field->common.class;
7b33a0e0
PP
550 array_field->fields = g_ptr_array_sized_new(array_field->length);
551 if (!array_field->fields) {
a8f90e5d 552 BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GPtrArray.");
18acc6f8
PP
553 ret = -1;
554 goto end;
555 }
556
7b33a0e0
PP
557 g_ptr_array_set_free_func(array_field->fields,
558 (GDestroyNotify) bt_field_destroy);
559 g_ptr_array_set_size(array_field->fields, array_field->length);
560
561 for (i = 0; i < array_field->length; i++) {
562 array_field->fields->pdata[i] = bt_field_create(
939190b3 563 array_fc->element_fc);
7b33a0e0 564 if (!array_field->fields->pdata[i]) {
a8f90e5d
PP
565 BT_LIB_LOGE_APPEND_CAUSE(
566 "Cannot create array field's element field: "
939190b3 567 "index=%" PRIu64 ", %![fc-]+F", i, array_fc);
7b33a0e0
PP
568 ret = -1;
569 goto end;
570 }
571 }
18acc6f8
PP
572
573end:
574 return ret;
3f4a108d
PP
575}
576
7b33a0e0 577static
939190b3 578struct bt_field *create_static_array_field(struct bt_field_class *fc)
f78d67fb 579{
60bbfc7c 580 struct bt_field_class_array_static *array_fc = (void *) fc;
7b33a0e0 581 struct bt_field_array *array_field;
a6918753 582
939190b3 583 BT_LIB_LOGD("Creating static array field object: %![fc-]+F", fc);
7b33a0e0
PP
584 array_field = g_new0(struct bt_field_array, 1);
585 if (!array_field) {
a8f90e5d
PP
586 BT_LIB_LOGE_APPEND_CAUSE(
587 "Failed to allocate one static array field.");
7b33a0e0
PP
588 goto end;
589 }
f78d67fb 590
939190b3
PP
591 init_field((void *) array_field, fc, &array_field_methods);
592 array_field->length = array_fc->length;
18acc6f8 593
7b33a0e0 594 if (init_array_field_fields(array_field)) {
a8f90e5d 595 BT_LIB_LOGE_APPEND_CAUSE("Cannot create static array fields: "
939190b3 596 "%![fc-]+F", fc);
6a9bd19d
FD
597 bt_field_destroy((void *) array_field);
598 array_field = NULL;
7b33a0e0
PP
599 goto end;
600 }
a6918753 601
7b33a0e0 602 BT_LIB_LOGD("Created static array field object: %!+f", array_field);
18acc6f8 603
7b33a0e0
PP
604end:
605 return (void *) array_field;
273b65be
JG
606}
607
7b33a0e0 608static
939190b3 609struct bt_field *create_dynamic_array_field(struct bt_field_class *fc)
cd95e351 610{
7b33a0e0 611 struct bt_field_array *array_field;
a6918753 612
939190b3 613 BT_LIB_LOGD("Creating dynamic array field object: %![fc-]+F", fc);
7b33a0e0
PP
614 array_field = g_new0(struct bt_field_array, 1);
615 if (!array_field) {
a8f90e5d
PP
616 BT_LIB_LOGE_APPEND_CAUSE(
617 "Failed to allocate one dynamic array field.");
7b33a0e0
PP
618 goto end;
619 }
620
939190b3 621 init_field((void *) array_field, fc, &array_field_methods);
7b33a0e0
PP
622
623 if (init_array_field_fields(array_field)) {
a8f90e5d 624 BT_LIB_LOGE_APPEND_CAUSE("Cannot create dynamic array fields: "
939190b3 625 "%![fc-]+F", fc);
6a9bd19d
FD
626 bt_field_destroy((void *) array_field);
627 array_field = NULL;
7b33a0e0 628 goto end;
18acc6f8
PP
629 }
630
7b33a0e0
PP
631 BT_LIB_LOGD("Created dynamic array field object: %!+f", array_field);
632
633end:
634 return (void *) array_field;
a6918753
PP
635}
636
9414b439
PP
637bt_bool bt_field_bool_get_value(const struct bt_field *field)
638{
639 const struct bt_field_bool *bool_field = (const void *) field;
640
641 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
642 BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
643 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_BOOL,
644 "Field");
645 return (bt_bool) bool_field->value;
646}
647
648void bt_field_bool_set_value(struct bt_field *field, bt_bool value)
649{
650 struct bt_field_bool *bool_field = (void *) field;
651
652 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
653 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_BOOL,
654 "Field");
655 BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
656 bool_field->value = (bool) value;
657 bt_field_set_single(field, true);
658}
659
6943da6a
PP
660uint64_t bt_field_bit_array_get_value_as_integer(const struct bt_field *field)
661{
662 const struct bt_field_bit_array *ba_field = (const void *) field;
663
664 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
665 BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
666 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
667 BT_FIELD_CLASS_TYPE_BIT_ARRAY, "Field");
668 return ba_field->value_as_int;
669}
670
671void bt_field_bit_array_set_value_as_integer(struct bt_field *field,
672 uint64_t value)
673{
674 struct bt_field_bit_array *ba_field = (void *) field;
675 struct bt_field_class_bit_array *ba_fc;
676
677 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
678 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
679 BT_FIELD_CLASS_TYPE_BIT_ARRAY, "Field");
680 BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
681 ba_fc = (void *) field->class;
682 ba_field->value_as_int = value;
683
684 if (ba_fc->length < 64) {
685 /* Apply mask */
686 ba_field->value_as_int &= ((UINT64_C(1) << ba_fc->length) - 1);
687 }
688
689 bt_field_set_single(field, true);
690}
691
60bbfc7c 692int64_t bt_field_integer_signed_get_value(const struct bt_field *field)
a6918753 693{
78cf9df6 694 const struct bt_field_integer *int_field = (const void *) field;
a6918753 695
fa6cfec3
PP
696 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
697 BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
698 BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(field, "Field");
7b33a0e0 699 return int_field->value.i;
cd95e351
JG
700}
701
60bbfc7c 702void bt_field_integer_signed_set_value(struct bt_field *field, int64_t value)
cd95e351 703{
7b33a0e0 704 struct bt_field_integer *int_field = (void *) field;
a6918753 705
fa6cfec3
PP
706 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
707 BT_ASSERT_PRE_DEV_FIELD_IS_SIGNED_INT(field, "Field");
708 BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
709 BT_ASSERT_PRE_DEV(bt_util_value_is_in_range_signed(
939190b3 710 ((struct bt_field_class_integer *) field->class)->range, value),
7b33a0e0 711 "Value is out of bounds: value=%" PRId64 ", %![field-]+f, "
939190b3 712 "%![fc-]+F", value, field, field->class);
7b33a0e0
PP
713 int_field->value.i = value;
714 bt_field_set_single(field, true);
cd95e351
JG
715}
716
60bbfc7c 717uint64_t bt_field_integer_unsigned_get_value(const struct bt_field *field)
273b65be 718{
78cf9df6 719 const struct bt_field_integer *int_field = (const void *) field;
7b33a0e0 720
fa6cfec3
PP
721 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
722 BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
723 BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(field, "Field");
7b33a0e0 724 return int_field->value.u;
273b65be
JG
725}
726
60bbfc7c 727void bt_field_integer_unsigned_set_value(struct bt_field *field, uint64_t value)
cd95e351 728{
7b33a0e0 729 struct bt_field_integer *int_field = (void *) field;
a6918753 730
fa6cfec3
PP
731 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
732 BT_ASSERT_PRE_DEV_FIELD_IS_UNSIGNED_INT(field, "Field");
733 BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
734 BT_ASSERT_PRE_DEV(bt_util_value_is_in_range_unsigned(
939190b3 735 ((struct bt_field_class_integer *) field->class)->range, value),
7b33a0e0 736 "Value is out of bounds: value=%" PRIu64 ", %![field-]+f, "
939190b3 737 "%![fc-]+F", value, field, field->class);
7b33a0e0
PP
738 int_field->value.u = value;
739 bt_field_set_single(field, true);
cd95e351
JG
740}
741
76276a81
FD
742float bt_field_real_single_precision_get_value(const struct bt_field *field)
743{
744 const struct bt_field_real *real_field = (const void *) field;
745
746 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
747 BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
748 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
749 BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL, "Field");
750 return (float) real_field->value;
751}
752
753double bt_field_real_double_precision_get_value(const struct bt_field *field)
273b65be 754{
78cf9df6 755 const struct bt_field_real *real_field = (const void *) field;
7b33a0e0 756
fa6cfec3
PP
757 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
758 BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
76276a81
FD
759 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
760 BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL, "Field");
761
7b33a0e0 762 return real_field->value;
8b45963b
PP
763}
764
76276a81
FD
765void bt_field_real_single_precision_set_value(struct bt_field *field,
766 float value)
8b45963b 767{
7b33a0e0 768 struct bt_field_real *real_field = (void *) field;
18acc6f8 769
fa6cfec3 770 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
76276a81
FD
771 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
772 BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL, "Field");
fa6cfec3 773 BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
76276a81
FD
774
775 real_field->value = (double) value;
776 bt_field_set_single(field, true);
777}
778
779void bt_field_real_double_precision_set_value(struct bt_field *field,
780 double value)
781{
782 struct bt_field_real *real_field = (void *) field;
783
784 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
785 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
786 BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL, "Field");
787 BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
788
7b33a0e0
PP
789 real_field->value = value;
790 bt_field_set_single(field, true);
791}
792
fb25b9e3 793enum bt_field_enumeration_get_mapping_labels_status
60bbfc7c 794bt_field_enumeration_unsigned_get_mapping_labels(
78cf9df6 795 const struct bt_field *field,
939190b3 796 bt_field_class_enumeration_mapping_label_array *label_array,
7b33a0e0
PP
797 uint64_t *count)
798{
78cf9df6 799 const struct bt_field_integer *int_field = (const void *) field;
7b33a0e0 800
fa6cfec3
PP
801 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
802 BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Label array (output)");
803 BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Count (output)");
804 BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
805 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
af0c18e3 806 BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, "Field");
937c4e48 807 return (int)
60bbfc7c 808 bt_field_class_enumeration_unsigned_get_mapping_labels_for_value(
937c4e48 809 field->class, int_field->value.u, label_array, count);
273b65be
JG
810}
811
fb25b9e3 812enum bt_field_enumeration_get_mapping_labels_status
60bbfc7c 813bt_field_enumeration_signed_get_mapping_labels(
78cf9df6 814 const struct bt_field *field,
939190b3 815 bt_field_class_enumeration_mapping_label_array *label_array,
7b33a0e0 816 uint64_t *count)
cd95e351 817{
78cf9df6 818 const struct bt_field_integer *int_field = (const void *) field;
18acc6f8 819
fa6cfec3
PP
820 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
821 BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Label array (output)");
822 BT_ASSERT_PRE_DEV_NON_NULL(label_array, "Count (output)");
823 BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
824 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
af0c18e3 825 BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, "Field");
937c4e48 826 return (int)
60bbfc7c 827 bt_field_class_enumeration_signed_get_mapping_labels_for_value(
937c4e48 828 field->class, int_field->value.i, label_array, count);
8b45963b 829}
fc25abce 830
78cf9df6 831const char *bt_field_string_get_value(const struct bt_field *field)
8b45963b 832{
78cf9df6 833 const struct bt_field_string *string_field = (const void *) field;
7b33a0e0 834
fa6cfec3
PP
835 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
836 BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
837 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_STRING,
7b33a0e0
PP
838 "Field");
839 return (const char *) string_field->buf->data;
840}
841
78cf9df6 842uint64_t bt_field_string_get_length(const struct bt_field *field)
7b33a0e0 843{
78cf9df6 844 const struct bt_field_string *string_field = (const void *) field;
18acc6f8 845
fa6cfec3
PP
846 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
847 BT_ASSERT_PRE_DEV_FIELD_IS_SET(field, "Field");
848 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_STRING,
7b33a0e0
PP
849 "Field");
850 return string_field->length;
cd95e351
JG
851}
852
937c4e48
PP
853static inline
854void clear_string_field(struct bt_field *field)
855{
856 struct bt_field_string *string_field = (void *) field;
857
858 BT_ASSERT(field);
859 string_field->length = 0;
860 bt_field_set_single(field, true);
861}
862
fb25b9e3
PP
863enum bt_field_string_set_value_status bt_field_string_set_value(
864 struct bt_field *field, const char *value)
273b65be 865{
fa6cfec3
PP
866 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
867 BT_ASSERT_PRE_DEV_NON_NULL(value, "Value");
868 BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
869 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field, BT_FIELD_CLASS_TYPE_STRING,
7b33a0e0 870 "Field");
937c4e48 871 clear_string_field(field);
fb25b9e3 872 return (int) bt_field_string_append_with_length(field, value,
7b33a0e0 873 (uint64_t) strlen(value));
273b65be
JG
874}
875
fb25b9e3
PP
876enum bt_field_string_append_status bt_field_string_append(
877 struct bt_field *field, const char *value)
cd95e351 878{
78cf9df6 879 return bt_field_string_append_with_length(field,
9e550e5f 880 value, (uint64_t) strlen(value));
cd95e351
JG
881}
882
fb25b9e3
PP
883enum bt_field_string_append_status bt_field_string_append_with_length(
884 struct bt_field *field, const char *value, uint64_t length)
273b65be 885{
18acc6f8
PP
886 struct bt_field_string *string_field = (void *) field;
887 char *data;
7b33a0e0 888 uint64_t new_length;
273b65be 889
fa6cfec3
PP
890 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
891 BT_ASSERT_PRE_DEV_NON_NULL(value, "Value");
892 BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
893 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
af0c18e3 894 BT_FIELD_CLASS_TYPE_STRING, "Field");
a6918753 895
18acc6f8 896 /* Make sure no null bytes are appended */
8e01f2d9 897 BT_ASSERT_PRE_DEV(!memchr(value, '\0', length),
18acc6f8 898 "String value to append contains a null character: "
7b33a0e0 899 "partial-value=\"%.32s\", length=%" PRIu64, value, length);
c6f9c5a3 900
7b33a0e0 901 new_length = length + string_field->length;
18acc6f8 902
85e7137b 903 if (G_UNLIKELY(new_length + 1 > string_field->buf->len)) {
7b33a0e0 904 g_array_set_size(string_field->buf, new_length + 1);
c6f9c5a3
PP
905 }
906
18acc6f8 907 data = string_field->buf->data;
7b33a0e0
PP
908 memcpy(data + string_field->length, value, length);
909 ((char *) string_field->buf->data)[new_length] = '\0';
910 string_field->length = new_length;
911 bt_field_set_single(field, true);
fb25b9e3 912 return BT_FUNC_STATUS_OK;
18acc6f8 913}
8deee039 914
fb25b9e3 915void bt_field_string_clear(struct bt_field *field)
18acc6f8 916{
fa6cfec3
PP
917 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
918 BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
919 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
af0c18e3 920 BT_FIELD_CLASS_TYPE_STRING, "Field");
937c4e48 921 clear_string_field(field);
18acc6f8
PP
922}
923
78cf9df6 924uint64_t bt_field_array_get_length(const struct bt_field *field)
18acc6f8 925{
78cf9df6 926 const struct bt_field_array *array_field = (const void *) field;
c6f9c5a3 927
fa6cfec3
PP
928 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
929 BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(field, "Field");
7b33a0e0 930 return array_field->length;
8deee039 931}
f98c6554 932
60bbfc7c 933enum bt_field_array_dynamic_set_length_status bt_field_array_dynamic_set_length(
fb25b9e3 934 struct bt_field *field, uint64_t length)
8deee039 935{
fb25b9e3 936 int ret = BT_FUNC_STATUS_OK;
7b33a0e0 937 struct bt_field_array *array_field = (void *) field;
f98c6554 938
fa6cfec3 939 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
b8ddb4f0 940 BT_ASSERT_PRE_DEV_FIELD_IS_DYNAMIC_ARRAY(field, "Field");
fa6cfec3 941 BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
273b65be 942
85e7137b 943 if (G_UNLIKELY(length > array_field->fields->len)) {
7b33a0e0 944 /* Make more room */
939190b3 945 struct bt_field_class_array *array_fc;
7b33a0e0
PP
946 uint64_t cur_len = array_field->fields->len;
947 uint64_t i;
18acc6f8 948
7b33a0e0 949 g_ptr_array_set_size(array_field->fields, length);
939190b3 950 array_fc = (void *) field->class;
18acc6f8 951
7b33a0e0
PP
952 for (i = cur_len; i < array_field->fields->len; i++) {
953 struct bt_field *elem_field = bt_field_create(
939190b3 954 array_fc->element_fc);
273b65be 955
7b33a0e0 956 if (!elem_field) {
a8f90e5d
PP
957 BT_LIB_LOGE_APPEND_CAUSE(
958 "Cannot create element field for "
7b33a0e0
PP
959 "dynamic array field: "
960 "index=%" PRIu64 ", "
961 "%![array-field-]+f", i, field);
fb25b9e3 962 ret = BT_FUNC_STATUS_MEMORY_ERROR;
7b33a0e0
PP
963 goto end;
964 }
9be89173 965
7b33a0e0
PP
966 BT_ASSERT(!array_field->fields->pdata[i]);
967 array_field->fields->pdata[i] = elem_field;
9be89173 968 }
9be89173
JG
969 }
970
7b33a0e0 971 array_field->length = length;
8deee039 972
273b65be 973end:
9be89173 974 return ret;
273b65be
JG
975}
976
78cf9df6
PP
977static inline
978struct bt_field *borrow_array_field_element_field_by_index(
7b33a0e0 979 struct bt_field *field, uint64_t index)
a6918753 980{
7b33a0e0 981 struct bt_field_array *array_field = (void *) field;
a6918753 982
fa6cfec3
PP
983 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
984 BT_ASSERT_PRE_DEV_FIELD_IS_ARRAY(field, "Field");
985 BT_ASSERT_PRE_DEV_VALID_INDEX(index, array_field->length);
7b33a0e0 986 return array_field->fields->pdata[index];
a6918753
PP
987}
988
78cf9df6
PP
989struct bt_field *bt_field_array_borrow_element_field_by_index(
990 struct bt_field *field, uint64_t index)
9e550e5f 991{
78cf9df6 992 return borrow_array_field_element_field_by_index(field, index);
9e550e5f
PP
993}
994
78cf9df6
PP
995const struct bt_field *
996bt_field_array_borrow_element_field_by_index_const(
997 const struct bt_field *field, uint64_t index)
998{
999 return borrow_array_field_element_field_by_index((void *) field, index);
1000}
1001
1002static inline
1003struct bt_field *borrow_structure_field_member_field_by_index(
7b33a0e0 1004 struct bt_field *field, uint64_t index)
e42dd763 1005{
7b33a0e0 1006 struct bt_field_structure *struct_field = (void *) field;
e42dd763 1007
fa6cfec3
PP
1008 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
1009 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
af0c18e3 1010 BT_FIELD_CLASS_TYPE_STRUCTURE, "Field");
fa6cfec3 1011 BT_ASSERT_PRE_DEV_VALID_INDEX(index, struct_field->fields->len);
7b33a0e0 1012 return struct_field->fields->pdata[index];
e42dd763
PP
1013}
1014
78cf9df6
PP
1015struct bt_field *bt_field_structure_borrow_member_field_by_index(
1016 struct bt_field *field, uint64_t index)
1017{
1018 return borrow_structure_field_member_field_by_index(field,
1019 index);
1020}
1021
1022const struct bt_field *
1023bt_field_structure_borrow_member_field_by_index_const(
1024 const struct bt_field *field, uint64_t index)
9e550e5f 1025{
78cf9df6 1026 return borrow_structure_field_member_field_by_index(
9e550e5f
PP
1027 (void *) field, index);
1028}
1029
78cf9df6
PP
1030static inline
1031struct bt_field *borrow_structure_field_member_field_by_name(
7b33a0e0 1032 struct bt_field *field, const char *name)
273b65be 1033{
7b33a0e0 1034 struct bt_field *ret_field = NULL;
939190b3 1035 struct bt_field_class_structure *struct_fc;
7b33a0e0
PP
1036 struct bt_field_structure *struct_field = (void *) field;
1037 gpointer orig_key;
1038 gpointer index;
fc25abce 1039
fa6cfec3
PP
1040 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
1041 BT_ASSERT_PRE_DEV_NON_NULL(name, "Field name");
1042 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
af0c18e3 1043 BT_FIELD_CLASS_TYPE_STRUCTURE, "Field");
939190b3 1044 struct_fc = (void *) field->class;
a6918753 1045
939190b3 1046 if (!g_hash_table_lookup_extended(struct_fc->common.name_to_index, name,
7b33a0e0 1047 &orig_key, &index)) {
a6918753 1048 goto end;
fc25abce
PP
1049 }
1050
7b33a0e0
PP
1051 ret_field = struct_field->fields->pdata[GPOINTER_TO_UINT(index)];
1052 BT_ASSERT(ret_field);
a6918753
PP
1053
1054end:
7b33a0e0 1055 return ret_field;
273b65be
JG
1056}
1057
78cf9df6
PP
1058struct bt_field *bt_field_structure_borrow_member_field_by_name(
1059 struct bt_field *field, const char *name)
1060{
1061 return borrow_structure_field_member_field_by_name(field, name);
1062}
1063
1064const struct bt_field *bt_field_structure_borrow_member_field_by_name_const(
1065 const struct bt_field *field, const char *name)
9e550e5f 1066{
78cf9df6 1067 return borrow_structure_field_member_field_by_name(
9e550e5f
PP
1068 (void *) field, name);
1069}
1070
247fa9e3
PP
1071void bt_field_option_set_has_field(struct bt_field *field, bt_bool has_field)
1072{
1073 struct bt_field_option *opt_field = (void *) field;
1074
1075 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
467673c1 1076 BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(field, "Field");
247fa9e3
PP
1077 BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
1078
1079 if (has_field) {
1080 opt_field->selected_field = opt_field->content_field;
1081 } else {
1082 opt_field->selected_field = NULL;
1083 }
1084}
1085
1086struct bt_field *bt_field_option_borrow_field(struct bt_field *field)
1087{
1088 struct bt_field_option *opt_field = (void *) field;
1089
1090 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
467673c1 1091 BT_ASSERT_PRE_DEV_FIELD_IS_OPTION(field, "Field");
247fa9e3
PP
1092 return opt_field->selected_field;
1093}
1094
1095const struct bt_field *bt_field_option_borrow_field_const(
1096 const struct bt_field *field)
1097{
1098 return (const void *) bt_field_option_borrow_field((void *) field);
1099}
1100
78cf9df6
PP
1101static inline
1102struct bt_field *borrow_variant_field_selected_option_field(
7b33a0e0 1103 struct bt_field *field)
273b65be 1104{
7b33a0e0 1105 struct bt_field_variant *var_field = (void *) field;
273b65be 1106
fa6cfec3 1107 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
02b61fe0 1108 BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(field, "Field");
fa6cfec3 1109 BT_ASSERT_PRE_DEV(var_field->selected_field,
7b33a0e0
PP
1110 "Variant field has no selected field: %!+f", field);
1111 return var_field->selected_field;
273b65be
JG
1112}
1113
78cf9df6
PP
1114struct bt_field *bt_field_variant_borrow_selected_option_field(
1115 struct bt_field *field)
1116{
1117 return borrow_variant_field_selected_option_field(field);
1118}
1119
1120const struct bt_field *bt_field_variant_borrow_selected_option_field_const(
1121 const struct bt_field *field)
273b65be 1122{
78cf9df6 1123 return borrow_variant_field_selected_option_field((void *) field);
9e550e5f
PP
1124}
1125
02b61fe0
PP
1126static
1127const struct bt_field_class_variant_option *
1128borrow_variant_field_selected_class_option(const struct bt_field *field)
1129{
1130 const struct bt_field_class_named_field_class_container *container_fc;
1131 const struct bt_field_variant *var_field = (const void *) field;
1132
1133 BT_ASSERT(field);
1134 BT_ASSERT_PRE_DEV(var_field->selected_field,
1135 "Variant field has no selected field: %!+f", field);
1136 container_fc = (const void *) field->class;
1137 return container_fc->named_fcs->pdata[var_field->selected_index];
1138}
1139
1140const struct bt_field_class_variant_option *
1141bt_field_variant_borrow_selected_class_option_const(
1142 const struct bt_field *field)
1143{
1144 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
1145 BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(field, "Field");
1146 return borrow_variant_field_selected_class_option(field);
1147}
1148
8bc207af 1149const struct bt_field_class_variant_with_selector_field_integer_unsigned_option *
0822832b 1150bt_field_variant_with_unsigned_integer_selector_borrow_selected_class_option_const(
02b61fe0
PP
1151 const struct bt_field *field)
1152{
1153 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
1154 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
8bc207af 1155 BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD, "Field");
02b61fe0
PP
1156 return (const void *) borrow_variant_field_selected_class_option(field);
1157}
1158
8bc207af 1159const struct bt_field_class_variant_with_selector_field_integer_signed_option *
0822832b 1160bt_field_variant_with_signed_integer_selector_borrow_selected_class_option_const(
02b61fe0
PP
1161 const struct bt_field *field)
1162{
1163 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
1164 BT_ASSERT_PRE_DEV_FIELD_HAS_CLASS_TYPE(field,
8bc207af 1165 BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD, "Field");
02b61fe0
PP
1166 return (const void *) borrow_variant_field_selected_class_option(field);
1167}
1168
1169enum bt_field_variant_select_option_field_by_index_status
1170bt_field_variant_select_option_field_by_index(
78cf9df6 1171 struct bt_field *field, uint64_t index)
9e550e5f 1172{
7b33a0e0 1173 struct bt_field_variant *var_field = (void *) field;
fc25abce 1174
fa6cfec3 1175 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
02b61fe0 1176 BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(field, "Field");
fa6cfec3
PP
1177 BT_ASSERT_PRE_DEV_FIELD_HOT(field, "Field");
1178 BT_ASSERT_PRE_DEV_VALID_INDEX(index, var_field->fields->len);
7b33a0e0
PP
1179 var_field->selected_field = var_field->fields->pdata[index];
1180 var_field->selected_index = index;
fb25b9e3 1181 return BT_FUNC_STATUS_OK;
273b65be
JG
1182}
1183
7b33a0e0 1184uint64_t bt_field_variant_get_selected_option_field_index(
78cf9df6 1185 const struct bt_field *field)
a6918753 1186{
78cf9df6 1187 const struct bt_field_variant *var_field = (const void *) field;
a6918753 1188
fa6cfec3 1189 BT_ASSERT_PRE_DEV_NON_NULL(field, "Field");
02b61fe0 1190 BT_ASSERT_PRE_DEV_FIELD_IS_VARIANT(field, "Field");
fa6cfec3 1191 BT_ASSERT_PRE_DEV(var_field->selected_field,
7b33a0e0
PP
1192 "Variant field has no selected field: %!+f", field);
1193 return var_field->selected_index;
a6918753
PP
1194}
1195
7b33a0e0
PP
1196static inline
1197void bt_field_finalize(struct bt_field *field)
273b65be 1198{
7b33a0e0 1199 BT_ASSERT(field);
939190b3 1200 BT_LOGD_STR("Putting field's class.");
1248f5ea 1201 BT_OBJECT_PUT_REF_AND_RESET(field->class);
273b65be
JG
1202}
1203
9414b439
PP
1204static
1205void destroy_bool_field(struct bt_field *field)
1206{
1207 BT_ASSERT(field);
1208 BT_LIB_LOGD("Destroying boolean field object: %!+f", field);
1209 bt_field_finalize(field);
1210 g_free(field);
1211}
1212
6943da6a
PP
1213static
1214void destroy_bit_array_field(struct bt_field *field)
1215{
1216 BT_ASSERT(field);
1217 BT_LIB_LOGD("Destroying bit array field object: %!+f", field);
1218 bt_field_finalize(field);
1219 g_free(field);
1220}
1221
273b65be 1222static
7b33a0e0 1223void destroy_integer_field(struct bt_field *field)
273b65be 1224{
7b33a0e0
PP
1225 BT_ASSERT(field);
1226 BT_LIB_LOGD("Destroying integer field object: %!+f", field);
1227 bt_field_finalize(field);
1228 g_free(field);
273b65be
JG
1229}
1230
18acc6f8 1231static
7b33a0e0 1232void destroy_real_field(struct bt_field *field)
273b65be 1233{
7b33a0e0
PP
1234 BT_ASSERT(field);
1235 BT_LIB_LOGD("Destroying real field object: %!+f", field);
1236 bt_field_finalize(field);
1237 g_free(field);
273b65be
JG
1238}
1239
18acc6f8 1240static
7b33a0e0 1241void destroy_structure_field(struct bt_field *field)
273b65be 1242{
7b33a0e0 1243 struct bt_field_structure *struct_field = (void *) field;
273b65be 1244
8b45963b 1245 BT_ASSERT(field);
7b33a0e0
PP
1246 BT_LIB_LOGD("Destroying structure field object: %!+f", field);
1247 bt_field_finalize(field);
8b45963b 1248
7b33a0e0
PP
1249 if (struct_field->fields) {
1250 g_ptr_array_free(struct_field->fields, TRUE);
1248f5ea 1251 struct_field->fields = NULL;
273b65be 1252 }
8b45963b 1253
7b33a0e0 1254 g_free(field);
273b65be
JG
1255}
1256
247fa9e3
PP
1257static
1258void destroy_option_field(struct bt_field *field)
1259{
1260 struct bt_field_option *opt_field = (void *) field;
1261
1262 BT_ASSERT(field);
1263 BT_LIB_LOGD("Destroying option field object: %!+f", field);
1264 bt_field_finalize(field);
1265
1266 if (opt_field->content_field) {
1267 bt_field_destroy(opt_field->content_field);
1268 }
1269
1270 g_free(field);
1271}
1272
18acc6f8 1273static
7b33a0e0 1274void destroy_variant_field(struct bt_field *field)
273b65be 1275{
7b33a0e0 1276 struct bt_field_variant *var_field = (void *) field;
273b65be 1277
8b45963b 1278 BT_ASSERT(field);
7b33a0e0
PP
1279 BT_LIB_LOGD("Destroying variant field object: %!+f", field);
1280 bt_field_finalize(field);
a6918753 1281
7b33a0e0
PP
1282 if (var_field->fields) {
1283 g_ptr_array_free(var_field->fields, TRUE);
1248f5ea 1284 var_field->fields = NULL;
fc25abce 1285 }
8b45963b 1286
7b33a0e0 1287 g_free(field);
273b65be
JG
1288}
1289
18acc6f8 1290static
7b33a0e0 1291void destroy_array_field(struct bt_field *field)
273b65be 1292{
7b33a0e0 1293 struct bt_field_array *array_field = (void *) field;
273b65be 1294
8b45963b 1295 BT_ASSERT(field);
7b33a0e0
PP
1296 BT_LIB_LOGD("Destroying array field object: %!+f", field);
1297 bt_field_finalize(field);
8deee039 1298
7b33a0e0
PP
1299 if (array_field->fields) {
1300 g_ptr_array_free(array_field->fields, TRUE);
1248f5ea 1301 array_field->fields = NULL;
273b65be 1302 }
8b45963b 1303
7b33a0e0 1304 g_free(field);
273b65be
JG
1305}
1306
18acc6f8 1307static
7b33a0e0 1308void destroy_string_field(struct bt_field *field)
273b65be 1309{
7b33a0e0 1310 struct bt_field_string *string_field = (void *) field;
273b65be 1311
8b45963b 1312 BT_ASSERT(field);
7b33a0e0
PP
1313 BT_LIB_LOGD("Destroying string field object: %!+f", field);
1314 bt_field_finalize(field);
8deee039 1315
7b33a0e0
PP
1316 if (string_field->buf) {
1317 g_array_free(string_field->buf, TRUE);
1248f5ea 1318 string_field->buf = NULL;
273b65be 1319 }
7b33a0e0
PP
1320
1321 g_free(field);
273b65be
JG
1322}
1323
7b33a0e0
PP
1324BT_HIDDEN
1325void bt_field_destroy(struct bt_field *field)
12c8a1a3 1326{
8b45963b 1327 BT_ASSERT(field);
af0c18e3 1328 field_destroy_funcs[field->class->type](field);
12c8a1a3
JG
1329}
1330
18acc6f8 1331static
7b33a0e0 1332void reset_single_field(struct bt_field *field)
12c8a1a3 1333{
8b45963b 1334 BT_ASSERT(field);
7b33a0e0 1335 field->is_set = false;
12c8a1a3
JG
1336}
1337
18acc6f8 1338static
7b33a0e0 1339void reset_structure_field(struct bt_field *field)
12c8a1a3 1340{
7b33a0e0
PP
1341 uint64_t i;
1342 struct bt_field_structure *struct_field = (void *) field;
12c8a1a3 1343
8b45963b 1344 BT_ASSERT(field);
7b33a0e0
PP
1345
1346 for (i = 0; i < struct_field->fields->len; i++) {
1347 bt_field_reset(struct_field->fields->pdata[i]);
1348 }
12c8a1a3
JG
1349}
1350
247fa9e3
PP
1351static
1352void reset_option_field(struct bt_field *field)
1353{
1354 struct bt_field_option *opt_field = (void *) field;
1355
1356 BT_ASSERT(opt_field);
1357 bt_field_reset(opt_field->content_field);
1358 opt_field->selected_field = NULL;
1359}
1360
18acc6f8 1361static
7b33a0e0 1362void reset_variant_field(struct bt_field *field)
12c8a1a3 1363{
7b33a0e0
PP
1364 uint64_t i;
1365 struct bt_field_variant *var_field = (void *) field;
12c8a1a3 1366
8b45963b 1367 BT_ASSERT(field);
8b45963b 1368
7b33a0e0
PP
1369 for (i = 0; i < var_field->fields->len; i++) {
1370 bt_field_reset(var_field->fields->pdata[i]);
12c8a1a3 1371 }
12c8a1a3
JG
1372}
1373
18acc6f8 1374static
7b33a0e0 1375void reset_array_field(struct bt_field *field)
12c8a1a3 1376{
a6918753 1377 uint64_t i;
7b33a0e0 1378 struct bt_field_array *array_field = (void *) field;
12c8a1a3 1379
8b45963b 1380 BT_ASSERT(field);
8b45963b 1381
7b33a0e0
PP
1382 for (i = 0; i < array_field->fields->len; i++) {
1383 bt_field_reset(array_field->fields->pdata[i]);
12c8a1a3 1384 }
12c8a1a3
JG
1385}
1386
18acc6f8 1387static
7b33a0e0 1388void set_single_field_is_frozen(struct bt_field *field, bool is_frozen)
918be005 1389{
a6918753 1390 field->frozen = is_frozen;
918be005
PP
1391}
1392
18acc6f8 1393static
7b33a0e0 1394void set_structure_field_is_frozen(struct bt_field *field, bool is_frozen)
918be005 1395{
a6918753 1396 uint64_t i;
7b33a0e0 1397 struct bt_field_structure *struct_field = (void *) field;
918be005 1398
7b33a0e0
PP
1399 BT_LIB_LOGD("Setting structure field's frozen state: "
1400 "%![field-]+f, is-frozen=%d", field, is_frozen);
fc25abce 1401
7b33a0e0
PP
1402 for (i = 0; i < struct_field->fields->len; i++) {
1403 struct bt_field *member_field = struct_field->fields->pdata[i];
918be005 1404
7b33a0e0
PP
1405 BT_LIB_LOGD("Setting structure field's member field's "
1406 "frozen state: %![field-]+f, index=%" PRIu64,
1407 member_field, i);
247fa9e3 1408 _bt_field_set_is_frozen(member_field, is_frozen);
918be005
PP
1409 }
1410
7b33a0e0 1411 set_single_field_is_frozen(field, is_frozen);
918be005
PP
1412}
1413
247fa9e3
PP
1414static
1415void set_option_field_is_frozen(struct bt_field *field, bool is_frozen)
1416{
1417 struct bt_field_option *opt_field = (void *) field;
1418
1419 BT_LIB_LOGD("Setting option field's frozen state: "
1420 "%![field-]+f, is-frozen=%d", field, is_frozen);
1421 _bt_field_set_is_frozen(opt_field->content_field, is_frozen);
1422 set_single_field_is_frozen(field, is_frozen);
1423}
1424
18acc6f8 1425static
7b33a0e0 1426void set_variant_field_is_frozen(struct bt_field *field, bool is_frozen)
918be005 1427{
a6918753 1428 uint64_t i;
7b33a0e0 1429 struct bt_field_variant *var_field = (void *) field;
918be005 1430
7b33a0e0
PP
1431 BT_LIB_LOGD("Setting variant field's frozen state: "
1432 "%![field-]+f, is-frozen=%d", field, is_frozen);
a6918753 1433
7b33a0e0
PP
1434 for (i = 0; i < var_field->fields->len; i++) {
1435 struct bt_field *option_field = var_field->fields->pdata[i];
a6918753 1436
7b33a0e0
PP
1437 BT_LIB_LOGD("Setting variant field's option field's "
1438 "frozen state: %![field-]+f, index=%" PRIu64,
1439 option_field, i);
247fa9e3 1440 _bt_field_set_is_frozen(option_field, is_frozen);
a6918753
PP
1441 }
1442
7b33a0e0 1443 set_single_field_is_frozen(field, is_frozen);
918be005
PP
1444}
1445
18acc6f8 1446static
7b33a0e0 1447void set_array_field_is_frozen(struct bt_field *field, bool is_frozen)
918be005 1448{
7b33a0e0 1449 uint64_t i;
18acc6f8 1450 struct bt_field_array *array_field = (void *) field;
918be005 1451
7b33a0e0
PP
1452 BT_LIB_LOGD("Setting array field's frozen state: "
1453 "%![field-]+f, is-frozen=%d", field, is_frozen);
fc25abce 1454
7b33a0e0
PP
1455 for (i = 0; i < array_field->fields->len; i++) {
1456 struct bt_field *elem_field = array_field->fields->pdata[i];
918be005 1457
7b33a0e0
PP
1458 BT_LIB_LOGD("Setting array field's element field's "
1459 "frozen state: %![field-]+f, index=%" PRIu64,
fc25abce 1460 elem_field, i);
247fa9e3 1461 _bt_field_set_is_frozen(elem_field, is_frozen);
918be005
PP
1462 }
1463
7b33a0e0 1464 set_single_field_is_frozen(field, is_frozen);
918be005
PP
1465}
1466
1467BT_HIDDEN
78cf9df6 1468void _bt_field_set_is_frozen(const struct bt_field *field,
a6918753 1469 bool is_frozen)
918be005 1470{
7b33a0e0
PP
1471 BT_ASSERT(field);
1472 BT_LIB_LOGD("Setting field object's frozen state: %!+f, is-frozen=%d",
a6918753 1473 field, is_frozen);
a6918753 1474 BT_ASSERT(field->methods->set_is_frozen);
78cf9df6 1475 field->methods->set_is_frozen((void *) field, is_frozen);
918be005 1476}
76f869ab 1477
18acc6f8 1478static
78cf9df6 1479bool single_field_is_set(const struct bt_field *field)
76f869ab 1480{
7b33a0e0
PP
1481 BT_ASSERT(field);
1482 return field->is_set;
76f869ab
JG
1483}
1484
18acc6f8 1485static
78cf9df6 1486bool structure_field_is_set(const struct bt_field *field)
76f869ab 1487{
7b33a0e0
PP
1488 bool is_set = true;
1489 uint64_t i;
78cf9df6 1490 const struct bt_field_structure *struct_field = (const void *) field;
76f869ab 1491
8b45963b 1492 BT_ASSERT(field);
8deee039 1493
7b33a0e0
PP
1494 for (i = 0; i < struct_field->fields->len; i++) {
1495 is_set = bt_field_is_set(struct_field->fields->pdata[i]);
53d65c1d 1496 if (!is_set) {
76f869ab
JG
1497 goto end;
1498 }
1499 }
8deee039 1500
76f869ab 1501end:
53d65c1d 1502 return is_set;
76f869ab
JG
1503}
1504
247fa9e3
PP
1505static
1506bool option_field_is_set(const struct bt_field *field)
1507{
1508 const struct bt_field_option *opt_field = (const void *) field;
1509 bool is_set = false;
1510
1511 BT_ASSERT(field);
1512
1513 if (opt_field->selected_field) {
1514 is_set = bt_field_is_set(opt_field->selected_field);
1515 }
1516
1517 return is_set;
1518}
1519
18acc6f8 1520static
78cf9df6 1521bool variant_field_is_set(const struct bt_field *field)
76f869ab 1522{
78cf9df6 1523 const struct bt_field_variant *var_field = (const void *) field;
7b33a0e0 1524 bool is_set = false;
76f869ab 1525
8b45963b 1526 BT_ASSERT(field);
8deee039 1527
7b33a0e0
PP
1528 if (var_field->selected_field) {
1529 is_set = bt_field_is_set(var_field->selected_field);
76f869ab 1530 }
8deee039 1531
53d65c1d 1532 return is_set;
76f869ab
JG
1533}
1534
18acc6f8 1535static
78cf9df6 1536bool array_field_is_set(const struct bt_field *field)
76f869ab 1537{
7b33a0e0
PP
1538 bool is_set = true;
1539 uint64_t i;
78cf9df6 1540 const struct bt_field_array *array_field = (const void *) field;
76f869ab 1541
8b45963b 1542 BT_ASSERT(field);
8deee039 1543
7b33a0e0
PP
1544 for (i = 0; i < array_field->length; i++) {
1545 is_set = bt_field_is_set(array_field->fields->pdata[i]);
53d65c1d 1546 if (!is_set) {
76f869ab
JG
1547 goto end;
1548 }
1549 }
8deee039 1550
76f869ab 1551end:
53d65c1d 1552 return is_set;
76f869ab 1553}
This page took 0.159037 seconds and 4 git commands to generate.