lib: move `bt_value` structures to `value-internal.h`
[babeltrace.git] / lib / value.c
1 /*
2 * Copyright (c) 2015-2018 Philippe Proulx <pproulx@efficios.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 #define BT_LOG_TAG "VALUES"
24 #include <babeltrace/lib-logging-internal.h>
25
26 #include <stdlib.h>
27 #include <string.h>
28 #include <string.h>
29 #include <inttypes.h>
30 #include <babeltrace/compiler-internal.h>
31 #include <babeltrace/common-internal.h>
32 #include <babeltrace/value-const.h>
33 #include <babeltrace/value.h>
34 #include <babeltrace/compat/glib-internal.h>
35 #include <babeltrace/types.h>
36 #include <babeltrace/assert-pre-internal.h>
37 #include <babeltrace/value-internal.h>
38 #include <babeltrace/assert-internal.h>
39
40 #define BT_VALUE_FROM_CONCRETE(_concrete) ((struct bt_value *) (_concrete))
41 #define BT_VALUE_TO_BOOL(_base) ((struct bt_value_bool *) (_base))
42 #define BT_VALUE_TO_INTEGER(_base) ((struct bt_value_integer *) (_base))
43 #define BT_VALUE_TO_REAL(_base) ((struct bt_value_real *) (_base))
44 #define BT_VALUE_TO_STRING(_base) ((struct bt_value_string *) (_base))
45 #define BT_VALUE_TO_ARRAY(_base) ((struct bt_value_array *) (_base))
46 #define BT_VALUE_TO_MAP(_base) ((struct bt_value_map *) (_base))
47
48 #define BT_ASSERT_PRE_VALUE_IS_TYPE(_value, _type) \
49 BT_ASSERT_PRE(((struct bt_value *) (_value))->type == (_type), \
50 "Value has the wrong type ID: expected-type=%s, " \
51 "%![value-]+v", bt_common_value_type_string(_type), \
52 (_value))
53
54 #define BT_ASSERT_PRE_VALUE_HOT(_value, _name) \
55 BT_ASSERT_PRE_HOT(((struct bt_value *) (_value)), (_name), \
56 ": %!+v", (_value))
57
58 #define BT_ASSERT_PRE_VALUE_INDEX_IN_BOUNDS(_index, _count) \
59 BT_ASSERT_PRE((_index) < (_count), \
60 "Index is out of bound: " \
61 "index=%" PRIu64 ", count=%u", (_index), (_count));
62
63 static
64 void bt_value_null_instance_release_func(struct bt_object *obj)
65 {
66 BT_LOGW("Releasing the null value singleton: addr=%p", obj);
67 }
68
69 static
70 struct bt_value bt_value_null_instance = {
71 .base = {
72 .is_shared = true,
73 .ref_count = 1,
74 .release_func = bt_value_null_instance_release_func,
75 .spec_release_func = NULL,
76 .parent_is_owner_listener_func = NULL,
77 .parent = NULL,
78 },
79 .type = BT_VALUE_TYPE_NULL,
80 .frozen = BT_TRUE,
81 };
82
83 struct bt_value *const bt_value_null = &bt_value_null_instance;
84
85 static
86 void bt_value_destroy(struct bt_object *obj);
87
88 static
89 void bt_value_string_destroy(struct bt_value *object)
90 {
91 g_string_free(BT_VALUE_TO_STRING(object)->gstr, TRUE);
92 BT_VALUE_TO_STRING(object)->gstr = NULL;
93 }
94
95 static
96 void bt_value_array_destroy(struct bt_value *object)
97 {
98 /*
99 * Pointer array's registered value destructor will take care
100 * of putting each contained object.
101 */
102 g_ptr_array_free(BT_VALUE_TO_ARRAY(object)->garray, TRUE);
103 BT_VALUE_TO_ARRAY(object)->garray = NULL;
104 }
105
106 static
107 void bt_value_map_destroy(struct bt_value *object)
108 {
109 /*
110 * Hash table's registered value destructor will take care of
111 * putting each contained object. Keys are GQuarks and cannot
112 * be destroyed anyway.
113 */
114 g_hash_table_destroy(BT_VALUE_TO_MAP(object)->ght);
115 BT_VALUE_TO_MAP(object)->ght = NULL;
116 }
117
118 static
119 void (* const destroy_funcs[])(struct bt_value *) = {
120 [BT_VALUE_TYPE_NULL] = NULL,
121 [BT_VALUE_TYPE_BOOL] = NULL,
122 [BT_VALUE_TYPE_INTEGER] = NULL,
123 [BT_VALUE_TYPE_REAL] = NULL,
124 [BT_VALUE_TYPE_STRING] = bt_value_string_destroy,
125 [BT_VALUE_TYPE_ARRAY] = bt_value_array_destroy,
126 [BT_VALUE_TYPE_MAP] = bt_value_map_destroy,
127 };
128
129 static
130 struct bt_value *bt_value_null_copy(const struct bt_value *null_obj)
131 {
132 return (void *) bt_value_null;
133 }
134
135 static
136 struct bt_value *bt_value_bool_copy(const struct bt_value *bool_obj)
137 {
138 return bt_value_bool_create_init(
139 BT_VALUE_TO_BOOL(bool_obj)->value);
140 }
141
142 static
143 struct bt_value *bt_value_integer_copy(
144 const struct bt_value *integer_obj)
145 {
146 return bt_value_integer_create_init(
147 BT_VALUE_TO_INTEGER(integer_obj)->value);
148 }
149
150 static
151 struct bt_value *bt_value_real_copy(const struct bt_value *real_obj)
152 {
153 return bt_value_real_create_init(
154 BT_VALUE_TO_REAL(real_obj)->value);
155 }
156
157 static
158 struct bt_value *bt_value_string_copy(const struct bt_value *string_obj)
159 {
160 return bt_value_string_create_init(
161 BT_VALUE_TO_STRING(string_obj)->gstr->str);
162 }
163
164 static
165 struct bt_value *bt_value_array_copy(const struct bt_value *array_obj)
166 {
167 int i;
168 int ret;
169 struct bt_value *copy_obj;
170 struct bt_value_array *typed_array_obj;
171
172 BT_LOGD("Copying array value: addr=%p", array_obj);
173 typed_array_obj = BT_VALUE_TO_ARRAY(array_obj);
174 copy_obj = bt_value_array_create();
175 if (!copy_obj) {
176 BT_LOGE_STR("Cannot create empty array value.");
177 goto end;
178 }
179
180 for (i = 0; i < typed_array_obj->garray->len; ++i) {
181 struct bt_value *element_obj_copy = NULL;
182 const struct bt_value *element_obj =
183 bt_value_array_borrow_element_by_index_const(
184 array_obj, i);
185
186 BT_ASSERT(element_obj);
187 BT_LOGD("Copying array value's element: element-addr=%p, "
188 "index=%d", element_obj, i);
189 ret = bt_value_copy(element_obj, &element_obj_copy);
190 if (ret) {
191 BT_LOGE("Cannot copy array value's element: "
192 "array-addr=%p, index=%d",
193 array_obj, i);
194 BT_OBJECT_PUT_REF_AND_RESET(copy_obj);
195 goto end;
196 }
197
198 BT_ASSERT(element_obj_copy);
199 ret = bt_value_array_append_element(copy_obj,
200 (void *) element_obj_copy);
201 BT_OBJECT_PUT_REF_AND_RESET(element_obj_copy);
202 if (ret) {
203 BT_LOGE("Cannot append to array value: addr=%p",
204 array_obj);
205 BT_OBJECT_PUT_REF_AND_RESET(copy_obj);
206 goto end;
207 }
208 }
209
210 BT_LOGD("Copied array value: original-addr=%p, copy-addr=%p",
211 array_obj, copy_obj);
212
213 end:
214 return copy_obj;
215 }
216
217 static
218 struct bt_value *bt_value_map_copy(const struct bt_value *map_obj)
219 {
220 int ret;
221 GHashTableIter iter;
222 gpointer key, element_obj;
223 struct bt_value *copy_obj;
224 struct bt_value *element_obj_copy = NULL;
225 struct bt_value_map *typed_map_obj;
226
227 BT_LOGD("Copying map value: addr=%p", map_obj);
228 typed_map_obj = BT_VALUE_TO_MAP(map_obj);
229 copy_obj = bt_value_map_create();
230 if (!copy_obj) {
231 goto end;
232 }
233
234 g_hash_table_iter_init(&iter, typed_map_obj->ght);
235
236 while (g_hash_table_iter_next(&iter, &key, &element_obj)) {
237 const char *key_str = g_quark_to_string(GPOINTER_TO_UINT(key));
238
239 BT_ASSERT(key_str);
240 BT_LOGD("Copying map value's element: element-addr=%p, "
241 "key=\"%s\"", element_obj, key_str);
242 ret = bt_value_copy(element_obj, &element_obj_copy);
243 if (ret) {
244 BT_LOGE("Cannot copy map value's element: "
245 "map-addr=%p, key=\"%s\"",
246 map_obj, key_str);
247 BT_OBJECT_PUT_REF_AND_RESET(copy_obj);
248 goto end;
249 }
250
251 BT_ASSERT(element_obj_copy);
252 ret = bt_value_map_insert_entry(copy_obj, key_str,
253 (void *) element_obj_copy);
254 BT_OBJECT_PUT_REF_AND_RESET(element_obj_copy);
255 if (ret) {
256 BT_LOGE("Cannot insert into map value: addr=%p, key=\"%s\"",
257 map_obj, key_str);
258 BT_OBJECT_PUT_REF_AND_RESET(copy_obj);
259 goto end;
260 }
261 }
262
263 BT_LOGD("Copied map value: addr=%p", map_obj);
264
265 end:
266 return copy_obj;
267 }
268
269 static
270 struct bt_value *(* const copy_funcs[])(const struct bt_value *) = {
271 [BT_VALUE_TYPE_NULL] = bt_value_null_copy,
272 [BT_VALUE_TYPE_BOOL] = bt_value_bool_copy,
273 [BT_VALUE_TYPE_INTEGER] = bt_value_integer_copy,
274 [BT_VALUE_TYPE_REAL] = bt_value_real_copy,
275 [BT_VALUE_TYPE_STRING] = bt_value_string_copy,
276 [BT_VALUE_TYPE_ARRAY] = bt_value_array_copy,
277 [BT_VALUE_TYPE_MAP] = bt_value_map_copy,
278 };
279
280 static
281 bt_bool bt_value_null_compare(const struct bt_value *object_a,
282 const struct bt_value *object_b)
283 {
284 /*
285 * Always BT_TRUE since bt_value_compare() already checks if both
286 * object_a and object_b have the same type, and in the case of
287 * null value objects, they're always the same if it is so.
288 */
289 return BT_TRUE;
290 }
291
292 static
293 bt_bool bt_value_bool_compare(const struct bt_value *object_a,
294 const struct bt_value *object_b)
295 {
296 if (BT_VALUE_TO_BOOL(object_a)->value !=
297 BT_VALUE_TO_BOOL(object_b)->value) {
298 BT_LOGV("Boolean value objects are different: "
299 "bool-a-val=%d, bool-b-val=%d",
300 BT_VALUE_TO_BOOL(object_a)->value,
301 BT_VALUE_TO_BOOL(object_b)->value);
302 return BT_FALSE;
303 }
304
305 return BT_TRUE;
306 }
307
308 static
309 bt_bool bt_value_integer_compare(const struct bt_value *object_a,
310 const struct bt_value *object_b)
311 {
312 if (BT_VALUE_TO_INTEGER(object_a)->value !=
313 BT_VALUE_TO_INTEGER(object_b)->value) {
314 BT_LOGV("Integer value objects are different: "
315 "int-a-val=%" PRId64 ", int-b-val=%" PRId64,
316 BT_VALUE_TO_INTEGER(object_a)->value,
317 BT_VALUE_TO_INTEGER(object_b)->value);
318 return BT_FALSE;
319 }
320
321 return BT_TRUE;
322 }
323
324 static
325 bt_bool bt_value_real_compare(const struct bt_value *object_a,
326 const struct bt_value *object_b)
327 {
328 if (BT_VALUE_TO_REAL(object_a)->value !=
329 BT_VALUE_TO_REAL(object_b)->value) {
330 BT_LOGV("Real number value objects are different: "
331 "real-a-val=%f, real-b-val=%f",
332 BT_VALUE_TO_REAL(object_a)->value,
333 BT_VALUE_TO_REAL(object_b)->value);
334 return BT_FALSE;
335 }
336
337 return BT_TRUE;
338 }
339
340 static
341 bt_bool bt_value_string_compare(const struct bt_value *object_a,
342 const struct bt_value *object_b)
343 {
344 if (strcmp(BT_VALUE_TO_STRING(object_a)->gstr->str,
345 BT_VALUE_TO_STRING(object_b)->gstr->str) != 0) {
346 BT_LOGV("String value objects are different: "
347 "string-a-val=\"%s\", string-b-val=\"%s\"",
348 BT_VALUE_TO_STRING(object_a)->gstr->str,
349 BT_VALUE_TO_STRING(object_b)->gstr->str);
350 return BT_FALSE;
351 }
352
353 return BT_TRUE;
354 }
355
356 static
357 bt_bool bt_value_array_compare(const struct bt_value *object_a,
358 const struct bt_value *object_b)
359 {
360 int i;
361 bt_bool ret = BT_TRUE;
362 const struct bt_value_array *array_obj_a =
363 BT_VALUE_TO_ARRAY(object_a);
364
365 if (bt_value_array_get_size(object_a) !=
366 bt_value_array_get_size(object_b)) {
367 BT_LOGV("Array values are different: size mismatch "
368 "value-a-addr=%p, value-b-addr=%p, "
369 "value-a-size=%" PRId64 ", value-b-size=%" PRId64,
370 object_a, object_b,
371 bt_value_array_get_size(object_a),
372 bt_value_array_get_size(object_b));
373 ret = BT_FALSE;
374 goto end;
375 }
376
377 for (i = 0; i < array_obj_a->garray->len; ++i) {
378 const struct bt_value *element_obj_a;
379 const struct bt_value *element_obj_b;
380
381 element_obj_a = bt_value_array_borrow_element_by_index_const(
382 object_a, i);
383 element_obj_b = bt_value_array_borrow_element_by_index_const(
384 object_b, i);
385
386 if (!bt_value_compare(element_obj_a, element_obj_b)) {
387 BT_LOGV("Array values's elements are different: "
388 "value-a-addr=%p, value-b-addr=%p, index=%d",
389 element_obj_a, element_obj_b, i);
390 ret = BT_FALSE;
391 goto end;
392 }
393 }
394
395 end:
396 return ret;
397 }
398
399 static
400 bt_bool bt_value_map_compare(const struct bt_value *object_a,
401 const struct bt_value *object_b)
402 {
403 bt_bool ret = BT_TRUE;
404 GHashTableIter iter;
405 gpointer key, element_obj_a;
406 const struct bt_value_map *map_obj_a = BT_VALUE_TO_MAP(object_a);
407
408 if (bt_value_map_get_size(object_a) !=
409 bt_value_map_get_size(object_b)) {
410 BT_LOGV("Map values are different: size mismatch "
411 "value-a-addr=%p, value-b-addr=%p, "
412 "value-a-size=%" PRId64 ", value-b-size=%" PRId64,
413 object_a, object_b,
414 bt_value_map_get_size(object_a),
415 bt_value_map_get_size(object_b));
416 ret = BT_FALSE;
417 goto end;
418 }
419
420 g_hash_table_iter_init(&iter, map_obj_a->ght);
421
422 while (g_hash_table_iter_next(&iter, &key, &element_obj_a)) {
423 const struct bt_value *element_obj_b;
424 const char *key_str = g_quark_to_string(GPOINTER_TO_UINT(key));
425
426 element_obj_b = bt_value_map_borrow_entry_value_const(object_b,
427 key_str);
428
429 if (!bt_value_compare(element_obj_a, element_obj_b)) {
430 BT_LOGV("Map values's elements are different: "
431 "value-a-addr=%p, value-b-addr=%p, key=\"%s\"",
432 element_obj_a, element_obj_b, key_str);
433 ret = BT_FALSE;
434 goto end;
435 }
436 }
437
438 end:
439 return ret;
440 }
441
442 static
443 bt_bool (* const compare_funcs[])(const struct bt_value *,
444 const struct bt_value *) = {
445 [BT_VALUE_TYPE_NULL] = bt_value_null_compare,
446 [BT_VALUE_TYPE_BOOL] = bt_value_bool_compare,
447 [BT_VALUE_TYPE_INTEGER] = bt_value_integer_compare,
448 [BT_VALUE_TYPE_REAL] = bt_value_real_compare,
449 [BT_VALUE_TYPE_STRING] = bt_value_string_compare,
450 [BT_VALUE_TYPE_ARRAY] = bt_value_array_compare,
451 [BT_VALUE_TYPE_MAP] = bt_value_map_compare,
452 };
453
454 static
455 void bt_value_null_freeze(struct bt_value *object)
456 {
457 }
458
459 static
460 void bt_value_generic_freeze(struct bt_value *object)
461 {
462 object->frozen = BT_TRUE;
463 }
464
465 static
466 void bt_value_array_freeze(struct bt_value *object)
467 {
468 int i;
469 struct bt_value_array *typed_array_obj =
470 BT_VALUE_TO_ARRAY(object);
471
472 for (i = 0; i < typed_array_obj->garray->len; ++i) {
473 bt_value_freeze(g_ptr_array_index(typed_array_obj->garray, i));
474 }
475
476 bt_value_generic_freeze(object);
477 }
478
479 static
480 void bt_value_map_freeze(struct bt_value *object)
481 {
482 GHashTableIter iter;
483 gpointer key, element_obj;
484 const struct bt_value_map *map_obj = BT_VALUE_TO_MAP(object);
485
486 g_hash_table_iter_init(&iter, map_obj->ght);
487
488 while (g_hash_table_iter_next(&iter, &key, &element_obj)) {
489 bt_value_freeze(element_obj);
490 }
491
492 bt_value_generic_freeze(object);
493 }
494
495 static
496 void (* const freeze_funcs[])(struct bt_value *) = {
497 [BT_VALUE_TYPE_NULL] = bt_value_null_freeze,
498 [BT_VALUE_TYPE_BOOL] = bt_value_generic_freeze,
499 [BT_VALUE_TYPE_INTEGER] = bt_value_generic_freeze,
500 [BT_VALUE_TYPE_REAL] = bt_value_generic_freeze,
501 [BT_VALUE_TYPE_STRING] = bt_value_generic_freeze,
502 [BT_VALUE_TYPE_ARRAY] = bt_value_array_freeze,
503 [BT_VALUE_TYPE_MAP] = bt_value_map_freeze,
504 };
505
506 static
507 void bt_value_destroy(struct bt_object *obj)
508 {
509 struct bt_value *value;
510
511 value = container_of(obj, struct bt_value, base);
512 BT_LOGD("Destroying value: addr=%p", value);
513
514 if (bt_value_is_null(value)) {
515 BT_LOGD_STR("Not destroying the null value singleton.");
516 return;
517 }
518
519 if (destroy_funcs[value->type]) {
520 destroy_funcs[value->type](value);
521 }
522
523 g_free(value);
524 }
525
526 BT_HIDDEN
527 enum bt_value_status _bt_value_freeze(const struct bt_value *c_object)
528 {
529 const struct bt_value *object = (void *) c_object;
530 enum bt_value_status ret = BT_VALUE_STATUS_OK;
531
532 BT_ASSERT(object);
533
534 if (object->frozen) {
535 goto end;
536 }
537
538 BT_LOGD("Freezing value: addr=%p", object);
539 freeze_funcs[object->type]((void *) object);
540
541 end:
542 return ret;
543 }
544
545 enum bt_value_type bt_value_get_type(const struct bt_value *object)
546 {
547 BT_ASSERT_PRE_NON_NULL(object, "Value object");
548 return object->type;
549 }
550
551 static
552 struct bt_value bt_value_create_base(enum bt_value_type type)
553 {
554 struct bt_value value;
555
556 value.type = type;
557 value.frozen = BT_FALSE;
558 bt_object_init_shared(&value.base, bt_value_destroy);
559 return value;
560 }
561
562 struct bt_value *bt_value_bool_create_init(bt_bool val)
563 {
564 struct bt_value_bool *bool_obj;
565
566 BT_LOGD("Creating boolean value object: val=%d", val);
567 bool_obj = g_new0(struct bt_value_bool, 1);
568 if (!bool_obj) {
569 BT_LOGE_STR("Failed to allocate one boolean value object.");
570 goto end;
571 }
572
573 bool_obj->base = bt_value_create_base(BT_VALUE_TYPE_BOOL);
574 bool_obj->value = val;
575 BT_LOGD("Created boolean value object: addr=%p", bool_obj);
576
577 end:
578 return (void *) BT_VALUE_FROM_CONCRETE(bool_obj);
579 }
580
581 struct bt_value *bt_value_bool_create(void)
582 {
583 return bt_value_bool_create_init(BT_FALSE);
584 }
585
586 struct bt_value *bt_value_integer_create_init(int64_t val)
587 {
588 struct bt_value_integer *integer_obj;
589
590 BT_LOGD("Creating integer value object: val=%" PRId64, val);
591 integer_obj = g_new0(struct bt_value_integer, 1);
592 if (!integer_obj) {
593 BT_LOGE_STR("Failed to allocate one integer value object.");
594 goto end;
595 }
596
597 integer_obj->base = bt_value_create_base(BT_VALUE_TYPE_INTEGER);
598 integer_obj->value = val;
599 BT_LOGD("Created integer value object: addr=%p",
600 integer_obj);
601
602 end:
603 return (void *) BT_VALUE_FROM_CONCRETE(integer_obj);
604 }
605
606 struct bt_value *bt_value_integer_create(void)
607 {
608 return bt_value_integer_create_init(0);
609 }
610
611 struct bt_value *bt_value_real_create_init(double val)
612 {
613 struct bt_value_real *real_obj;
614
615 BT_LOGD("Creating real number value object: val=%f", val);
616 real_obj = g_new0(struct bt_value_real, 1);
617 if (!real_obj) {
618 BT_LOGE_STR("Failed to allocate one real number value object.");
619 goto end;
620 }
621
622 real_obj->base = bt_value_create_base(BT_VALUE_TYPE_REAL);
623 real_obj->value = val;
624 BT_LOGD("Created real number value object: addr=%p",
625 real_obj);
626
627 end:
628 return (void *) BT_VALUE_FROM_CONCRETE(real_obj);
629 }
630
631 struct bt_value *bt_value_real_create(void)
632 {
633 return bt_value_real_create_init(0.);
634 }
635
636 struct bt_value *bt_value_string_create_init(const char *val)
637 {
638 struct bt_value_string *string_obj = NULL;
639
640 if (!val) {
641 BT_LOGW_STR("Invalid parameter: value is NULL.");
642 goto end;
643 }
644
645 BT_LOGD("Creating string value object: val-len=%zu", strlen(val));
646 string_obj = g_new0(struct bt_value_string, 1);
647 if (!string_obj) {
648 BT_LOGE_STR("Failed to allocate one string object.");
649 goto end;
650 }
651
652 string_obj->base = bt_value_create_base(BT_VALUE_TYPE_STRING);
653 string_obj->gstr = g_string_new(val);
654 if (!string_obj->gstr) {
655 BT_LOGE_STR("Failed to allocate a GString.");
656 g_free(string_obj);
657 string_obj = NULL;
658 goto end;
659 }
660
661 BT_LOGD("Created string value object: addr=%p",
662 string_obj);
663
664 end:
665 return (void *) BT_VALUE_FROM_CONCRETE(string_obj);
666 }
667
668 struct bt_value *bt_value_string_create(void)
669 {
670 return bt_value_string_create_init("");
671 }
672
673 struct bt_value *bt_value_array_create(void)
674 {
675 struct bt_value_array *array_obj;
676
677 BT_LOGD_STR("Creating empty array value object.");
678 array_obj = g_new0(struct bt_value_array, 1);
679 if (!array_obj) {
680 BT_LOGE_STR("Failed to allocate one array object.");
681 goto end;
682 }
683
684 array_obj->base = bt_value_create_base(BT_VALUE_TYPE_ARRAY);
685 array_obj->garray = bt_g_ptr_array_new_full(0,
686 (GDestroyNotify) bt_object_put_ref);
687 if (!array_obj->garray) {
688 BT_LOGE_STR("Failed to allocate a GPtrArray.");
689 g_free(array_obj);
690 array_obj = NULL;
691 goto end;
692 }
693
694 BT_LOGD("Created array value object: addr=%p",
695 array_obj);
696
697 end:
698 return (void *) BT_VALUE_FROM_CONCRETE(array_obj);
699 }
700
701 struct bt_value *bt_value_map_create(void)
702 {
703 struct bt_value_map *map_obj;
704
705 BT_LOGD_STR("Creating empty map value object.");
706 map_obj = g_new0(struct bt_value_map, 1);
707 if (!map_obj) {
708 BT_LOGE_STR("Failed to allocate one map object.");
709 goto end;
710 }
711
712 map_obj->base = bt_value_create_base(BT_VALUE_TYPE_MAP);
713 map_obj->ght = g_hash_table_new_full(g_direct_hash, g_direct_equal,
714 NULL, (GDestroyNotify) bt_object_put_ref);
715 if (!map_obj->ght) {
716 BT_LOGE_STR("Failed to allocate a GHashTable.");
717 g_free(map_obj);
718 map_obj = NULL;
719 goto end;
720 }
721
722 BT_LOGD("Created map value object: addr=%p",
723 map_obj);
724
725 end:
726 return (void *) BT_VALUE_FROM_CONCRETE(map_obj);
727 }
728
729 bt_bool bt_value_bool_get(const struct bt_value *bool_obj)
730 {
731 BT_ASSERT_PRE_NON_NULL(bool_obj, "Value object");
732 BT_ASSERT_PRE_VALUE_IS_TYPE(bool_obj, BT_VALUE_TYPE_BOOL);
733 return BT_VALUE_TO_BOOL(bool_obj)->value;
734 }
735
736 void bt_value_bool_set(struct bt_value *bool_obj, bt_bool val)
737 {
738 BT_ASSERT_PRE_NON_NULL(bool_obj, "Value object");
739 BT_ASSERT_PRE_VALUE_IS_TYPE(bool_obj, BT_VALUE_TYPE_BOOL);
740 BT_ASSERT_PRE_VALUE_HOT(bool_obj, "Value object");
741 BT_VALUE_TO_BOOL(bool_obj)->value = val;
742 BT_LOGV("Set boolean value's raw value: value-addr=%p, value=%d",
743 bool_obj, val);
744 }
745
746 int64_t bt_value_integer_get(const struct bt_value *integer_obj)
747 {
748 BT_ASSERT_PRE_NON_NULL(integer_obj, "Value object");
749 BT_ASSERT_PRE_VALUE_IS_TYPE(integer_obj, BT_VALUE_TYPE_INTEGER);
750 return BT_VALUE_TO_INTEGER(integer_obj)->value;
751 }
752
753 void bt_value_integer_set(struct bt_value *integer_obj,
754 int64_t val)
755 {
756 BT_ASSERT_PRE_NON_NULL(integer_obj, "Value object");
757 BT_ASSERT_PRE_VALUE_IS_TYPE(integer_obj, BT_VALUE_TYPE_INTEGER);
758 BT_ASSERT_PRE_VALUE_HOT(integer_obj, "Value object");
759 BT_VALUE_TO_INTEGER(integer_obj)->value = val;
760 BT_LOGV("Set integer value's raw value: value-addr=%p, value=%" PRId64,
761 integer_obj, val);
762 }
763
764 double bt_value_real_get(const struct bt_value *real_obj)
765 {
766 BT_ASSERT_PRE_NON_NULL(real_obj, "Value object");
767 BT_ASSERT_PRE_VALUE_IS_TYPE(real_obj, BT_VALUE_TYPE_REAL);
768 return BT_VALUE_TO_REAL(real_obj)->value;
769 }
770
771 void bt_value_real_set(struct bt_value *real_obj, double val)
772 {
773 BT_ASSERT_PRE_NON_NULL(real_obj, "Value object");
774 BT_ASSERT_PRE_VALUE_IS_TYPE(real_obj, BT_VALUE_TYPE_REAL);
775 BT_ASSERT_PRE_VALUE_HOT(real_obj, "Value object");
776 BT_VALUE_TO_REAL(real_obj)->value = val;
777 BT_LOGV("Set real number value's raw value: value-addr=%p, value=%f",
778 real_obj, val);
779 }
780
781 const char *bt_value_string_get(const struct bt_value *string_obj)
782 {
783 BT_ASSERT_PRE_NON_NULL(string_obj, "Value object");
784 BT_ASSERT_PRE_VALUE_IS_TYPE(string_obj, BT_VALUE_TYPE_STRING);
785 return BT_VALUE_TO_STRING(string_obj)->gstr->str;
786 }
787
788 enum bt_value_status bt_value_string_set(
789 struct bt_value *string_obj, const char *val)
790 {
791 BT_ASSERT_PRE_NON_NULL(string_obj, "Value object");
792 BT_ASSERT_PRE_VALUE_IS_TYPE(string_obj, BT_VALUE_TYPE_STRING);
793 BT_ASSERT_PRE_VALUE_HOT(string_obj, "Value object");
794 g_string_assign(BT_VALUE_TO_STRING(string_obj)->gstr, val);
795 BT_LOGV("Set string value's raw value: value-addr=%p, raw-value-addr=%p",
796 string_obj, val);
797 return BT_VALUE_STATUS_OK;
798 }
799
800 uint64_t bt_value_array_get_size(const struct bt_value *array_obj)
801 {
802 BT_ASSERT_PRE_NON_NULL(array_obj, "Value object");
803 BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_VALUE_TYPE_ARRAY);
804 return (uint64_t) BT_VALUE_TO_ARRAY(array_obj)->garray->len;
805 }
806
807 struct bt_value *bt_value_array_borrow_element_by_index(
808 struct bt_value *array_obj, uint64_t index)
809 {
810 struct bt_value_array *typed_array_obj =
811 BT_VALUE_TO_ARRAY(array_obj);
812
813 BT_ASSERT_PRE_NON_NULL(array_obj, "Value object");
814 BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_VALUE_TYPE_ARRAY);
815 BT_ASSERT_PRE_VALUE_INDEX_IN_BOUNDS(index,
816 typed_array_obj->garray->len);
817 return g_ptr_array_index(typed_array_obj->garray, index);
818 }
819
820 const struct bt_value *bt_value_array_borrow_element_by_index_const(
821 const struct bt_value *array_obj,
822 uint64_t index)
823 {
824 return bt_value_array_borrow_element_by_index(
825 (void *) array_obj, index);
826 }
827
828 enum bt_value_status bt_value_array_append_element(
829 struct bt_value *array_obj,
830 struct bt_value *element_obj)
831 {
832 struct bt_value_array *typed_array_obj =
833 BT_VALUE_TO_ARRAY(array_obj);
834
835 BT_ASSERT_PRE_NON_NULL(array_obj, "Array value object");
836 BT_ASSERT_PRE_NON_NULL(element_obj, "Element value object");
837 BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_VALUE_TYPE_ARRAY);
838 BT_ASSERT_PRE_VALUE_HOT(array_obj, "Array value object");
839 g_ptr_array_add(typed_array_obj->garray, element_obj);
840 bt_object_get_ref(element_obj);
841 BT_LOGV("Appended element to array value: array-value-addr=%p, "
842 "element-value-addr=%p, new-size=%u",
843 array_obj, element_obj, typed_array_obj->garray->len);
844 return BT_VALUE_STATUS_OK;
845 }
846
847 enum bt_value_status bt_value_array_append_bool_element(
848 struct bt_value *array_obj, bt_bool val)
849 {
850 enum bt_value_status ret;
851 struct bt_value *bool_obj = NULL;
852
853 bool_obj = bt_value_bool_create_init(val);
854 ret = bt_value_array_append_element(array_obj,
855 (void *) bool_obj);
856 bt_object_put_ref(bool_obj);
857 return ret;
858 }
859
860 enum bt_value_status bt_value_array_append_integer_element(
861 struct bt_value *array_obj, int64_t val)
862 {
863 enum bt_value_status ret;
864 struct bt_value *integer_obj = NULL;
865
866 integer_obj = bt_value_integer_create_init(val);
867 ret = bt_value_array_append_element(array_obj,
868 (void *) integer_obj);
869 bt_object_put_ref(integer_obj);
870 return ret;
871 }
872
873 enum bt_value_status bt_value_array_append_real_element(
874 struct bt_value *array_obj, double val)
875 {
876 enum bt_value_status ret;
877 struct bt_value *real_obj = NULL;
878
879 real_obj = bt_value_real_create_init(val);
880 ret = bt_value_array_append_element(array_obj,
881 (void *) real_obj);
882 bt_object_put_ref(real_obj);
883 return ret;
884 }
885
886 enum bt_value_status bt_value_array_append_string_element(
887 struct bt_value *array_obj, const char *val)
888 {
889 enum bt_value_status ret;
890 struct bt_value *string_obj = NULL;
891
892 string_obj = bt_value_string_create_init(val);
893 ret = bt_value_array_append_element(array_obj,
894 (void *) string_obj);
895 bt_object_put_ref(string_obj);
896 return ret;
897 }
898
899 enum bt_value_status bt_value_array_append_empty_array_element(
900 struct bt_value *array_obj)
901 {
902 enum bt_value_status ret;
903 struct bt_value *empty_array_obj = NULL;
904
905 empty_array_obj = bt_value_array_create();
906 ret = bt_value_array_append_element(array_obj,
907 (void *) empty_array_obj);
908 bt_object_put_ref(empty_array_obj);
909 return ret;
910 }
911
912 enum bt_value_status bt_value_array_append_empty_map_element(
913 struct bt_value *array_obj)
914 {
915 enum bt_value_status ret;
916 struct bt_value *map_obj = NULL;
917
918 map_obj = bt_value_map_create();
919 ret = bt_value_array_append_element(array_obj,
920 (void *) map_obj);
921 bt_object_put_ref(map_obj);
922 return ret;
923 }
924
925 enum bt_value_status bt_value_array_set_element_by_index(
926 struct bt_value *array_obj, uint64_t index,
927 struct bt_value *element_obj)
928 {
929 struct bt_value_array *typed_array_obj =
930 BT_VALUE_TO_ARRAY(array_obj);
931
932 BT_ASSERT_PRE_NON_NULL(array_obj, "Array value object");
933 BT_ASSERT_PRE_NON_NULL(element_obj, "Element value object");
934 BT_ASSERT_PRE_VALUE_IS_TYPE(array_obj, BT_VALUE_TYPE_ARRAY);
935 BT_ASSERT_PRE_VALUE_HOT(array_obj, "Array value object");
936 BT_ASSERT_PRE_VALUE_INDEX_IN_BOUNDS(index,
937 typed_array_obj->garray->len);
938 bt_object_put_ref(g_ptr_array_index(typed_array_obj->garray, index));
939 g_ptr_array_index(typed_array_obj->garray, index) = element_obj;
940 bt_object_get_ref(element_obj);
941 BT_LOGV("Set array value's element: array-value-addr=%p, "
942 "index=%" PRIu64 ", element-value-addr=%p",
943 array_obj, index, element_obj);
944 return BT_VALUE_STATUS_OK;
945 }
946
947 uint64_t bt_value_map_get_size(const struct bt_value *map_obj)
948 {
949 BT_ASSERT_PRE_NON_NULL(map_obj, "Value object");
950 BT_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_VALUE_TYPE_MAP);
951 return (uint64_t) g_hash_table_size(BT_VALUE_TO_MAP(map_obj)->ght);
952 }
953
954 struct bt_value *bt_value_map_borrow_entry_value(struct bt_value *map_obj,
955 const char *key)
956 {
957 BT_ASSERT_PRE_NON_NULL(map_obj, "Value object");
958 BT_ASSERT_PRE_NON_NULL(key, "Key");
959 BT_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_VALUE_TYPE_MAP);
960 return g_hash_table_lookup(BT_VALUE_TO_MAP(map_obj)->ght,
961 GUINT_TO_POINTER(g_quark_from_string(key)));
962 }
963
964 const struct bt_value *bt_value_map_borrow_entry_value_const(
965 const struct bt_value *map_obj, const char *key)
966 {
967 return bt_value_map_borrow_entry_value((void *) map_obj, key);
968 }
969
970 bt_bool bt_value_map_has_entry(const struct bt_value *map_obj, const char *key)
971 {
972 BT_ASSERT_PRE_NON_NULL(map_obj, "Value object");
973 BT_ASSERT_PRE_NON_NULL(key, "Key");
974 BT_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_VALUE_TYPE_MAP);
975 return bt_g_hash_table_contains(BT_VALUE_TO_MAP(map_obj)->ght,
976 GUINT_TO_POINTER(g_quark_from_string(key)));
977 }
978
979 enum bt_value_status bt_value_map_insert_entry(
980 struct bt_value *map_obj,
981 const char *key, struct bt_value *element_obj)
982 {
983 BT_ASSERT_PRE_NON_NULL(map_obj, "Map value object");
984 BT_ASSERT_PRE_NON_NULL(key, "Key");
985 BT_ASSERT_PRE_NON_NULL(element_obj, "Element value object");
986 BT_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_VALUE_TYPE_MAP);
987 BT_ASSERT_PRE_VALUE_HOT(map_obj, "Map value object");
988 g_hash_table_insert(BT_VALUE_TO_MAP(map_obj)->ght,
989 GUINT_TO_POINTER(g_quark_from_string(key)), element_obj);
990 bt_object_get_ref(element_obj);
991 BT_LOGV("Inserted value into map value: map-value-addr=%p, "
992 "key=\"%s\", element-value-addr=%p",
993 map_obj, key, element_obj);
994 return BT_VALUE_STATUS_OK;
995 }
996
997 enum bt_value_status bt_value_map_insert_bool_entry(
998 struct bt_value *map_obj, const char *key, bt_bool val)
999 {
1000 enum bt_value_status ret;
1001 struct bt_value *bool_obj = NULL;
1002
1003 bool_obj = bt_value_bool_create_init(val);
1004 ret = bt_value_map_insert_entry(map_obj, key,
1005 (void *) bool_obj);
1006 bt_object_put_ref(bool_obj);
1007 return ret;
1008 }
1009
1010 enum bt_value_status bt_value_map_insert_integer_entry(
1011 struct bt_value *map_obj, const char *key, int64_t val)
1012 {
1013 enum bt_value_status ret;
1014 struct bt_value *integer_obj = NULL;
1015
1016 integer_obj = bt_value_integer_create_init(val);
1017 ret = bt_value_map_insert_entry(map_obj, key,
1018 (void *) integer_obj);
1019 bt_object_put_ref(integer_obj);
1020 return ret;
1021 }
1022
1023 enum bt_value_status bt_value_map_insert_real_entry(
1024 struct bt_value *map_obj, const char *key, double val)
1025 {
1026 enum bt_value_status ret;
1027 struct bt_value *real_obj = NULL;
1028
1029 real_obj = bt_value_real_create_init(val);
1030 ret = bt_value_map_insert_entry(map_obj, key,
1031 (void *) real_obj);
1032 bt_object_put_ref(real_obj);
1033 return ret;
1034 }
1035
1036 enum bt_value_status bt_value_map_insert_string_entry(
1037 struct bt_value *map_obj, const char *key,
1038 const char *val)
1039 {
1040 enum bt_value_status ret;
1041 struct bt_value *string_obj = NULL;
1042
1043 string_obj = bt_value_string_create_init(val);
1044 ret = bt_value_map_insert_entry(map_obj, key,
1045 (void *) string_obj);
1046 bt_object_put_ref(string_obj);
1047 return ret;
1048 }
1049
1050 enum bt_value_status bt_value_map_insert_empty_array_entry(
1051 struct bt_value *map_obj, const char *key)
1052 {
1053 enum bt_value_status ret;
1054 struct bt_value *array_obj = NULL;
1055
1056 array_obj = bt_value_array_create();
1057 ret = bt_value_map_insert_entry(map_obj, key,
1058 (void *) array_obj);
1059 bt_object_put_ref(array_obj);
1060 return ret;
1061 }
1062
1063 enum bt_value_status bt_value_map_insert_empty_map_entry(
1064 struct bt_value *map_obj, const char *key)
1065 {
1066 enum bt_value_status ret;
1067 struct bt_value *empty_map_obj = NULL;
1068
1069 empty_map_obj = bt_value_map_create();
1070 ret = bt_value_map_insert_entry(map_obj, key,
1071 (void *) empty_map_obj);
1072 bt_object_put_ref(empty_map_obj);
1073 return ret;
1074 }
1075
1076 enum bt_value_status bt_value_map_foreach_entry(struct bt_value *map_obj,
1077 bt_value_map_foreach_entry_func func, void *data)
1078 {
1079 enum bt_value_status ret = BT_VALUE_STATUS_OK;
1080 gpointer key, element_obj;
1081 GHashTableIter iter;
1082 struct bt_value_map *typed_map_obj = BT_VALUE_TO_MAP(map_obj);
1083
1084 BT_ASSERT_PRE_NON_NULL(map_obj, "Value object");
1085 BT_ASSERT_PRE_NON_NULL(func, "Callback");
1086 BT_ASSERT_PRE_VALUE_IS_TYPE(map_obj, BT_VALUE_TYPE_MAP);
1087 g_hash_table_iter_init(&iter, typed_map_obj->ght);
1088
1089 while (g_hash_table_iter_next(&iter, &key, &element_obj)) {
1090 const char *key_str = g_quark_to_string(GPOINTER_TO_UINT(key));
1091
1092 if (!func(key_str, element_obj, data)) {
1093 BT_LOGV("User canceled the loop: key=\"%s\", "
1094 "value-addr=%p, data=%p",
1095 key_str, element_obj, data);
1096 ret = BT_VALUE_STATUS_CANCELED;
1097 break;
1098 }
1099 }
1100
1101 return ret;
1102 }
1103
1104 enum bt_value_status bt_value_map_foreach_entry_const(
1105 const struct bt_value *map_obj,
1106 bt_value_map_foreach_entry_const_func func, void *data)
1107 {
1108 return bt_value_map_foreach_entry((void *) map_obj,
1109 (bt_value_map_foreach_entry_func) func, data);
1110 }
1111
1112 struct extend_map_element_data {
1113 struct bt_value *extended_obj;
1114 enum bt_value_status status;
1115 };
1116
1117 static
1118 bt_bool extend_map_element(const char *key,
1119 const struct bt_value *extension_obj_elem, void *data)
1120 {
1121 bt_bool ret = BT_TRUE;
1122 struct extend_map_element_data *extend_data = data;
1123 struct bt_value *extension_obj_elem_copy = NULL;
1124
1125 /* Copy object which is to replace the current one */
1126 extend_data->status = bt_value_copy(extension_obj_elem,
1127 &extension_obj_elem_copy);
1128 if (extend_data->status) {
1129 BT_LOGE("Cannot copy map element: addr=%p",
1130 extension_obj_elem);
1131 goto error;
1132 }
1133
1134 BT_ASSERT(extension_obj_elem_copy);
1135
1136 /* Replace in extended object */
1137 extend_data->status = bt_value_map_insert_entry(
1138 extend_data->extended_obj, key,
1139 (void *) extension_obj_elem_copy);
1140 if (extend_data->status) {
1141 BT_LOGE("Cannot replace value in extended value: key=\"%s\", "
1142 "extended-value-addr=%p, element-value-addr=%p",
1143 key, extend_data->extended_obj,
1144 extension_obj_elem_copy);
1145 goto error;
1146 }
1147
1148 goto end;
1149
1150 error:
1151 BT_ASSERT(extend_data->status != BT_VALUE_STATUS_OK);
1152 ret = BT_FALSE;
1153
1154 end:
1155 BT_OBJECT_PUT_REF_AND_RESET(extension_obj_elem_copy);
1156 return ret;
1157 }
1158
1159 enum bt_value_status bt_value_map_extend(
1160 const struct bt_value *base_map_obj,
1161 const struct bt_value *extension_obj,
1162 struct bt_value **extended_map_obj)
1163 {
1164 struct extend_map_element_data extend_data = {
1165 .extended_obj = NULL,
1166 .status = BT_VALUE_STATUS_OK,
1167 };
1168
1169 BT_ASSERT_PRE_NON_NULL(base_map_obj, "Base value object");
1170 BT_ASSERT_PRE_NON_NULL(extension_obj, "Extension value object");
1171 BT_ASSERT_PRE_NON_NULL(extended_map_obj,
1172 "Extended value object (output)");
1173 BT_ASSERT_PRE_VALUE_IS_TYPE(base_map_obj, BT_VALUE_TYPE_MAP);
1174 BT_ASSERT_PRE_VALUE_IS_TYPE(extension_obj, BT_VALUE_TYPE_MAP);
1175 BT_LOGD("Extending map value: base-value-addr=%p, extension-value-addr=%p",
1176 base_map_obj, extension_obj);
1177 *extended_map_obj = NULL;
1178
1179 /* Create copy of base map object to start with */
1180 extend_data.status = bt_value_copy(base_map_obj, extended_map_obj);
1181 if (extend_data.status) {
1182 BT_LOGE("Cannot copy base value: base-value-addr=%p",
1183 base_map_obj);
1184 goto error;
1185 }
1186
1187 BT_ASSERT(extended_map_obj);
1188
1189 /*
1190 * For each key in the extension map object, replace this key
1191 * in the copied map object.
1192 */
1193 extend_data.extended_obj = *extended_map_obj;
1194
1195 if (bt_value_map_foreach_entry_const(extension_obj, extend_map_element,
1196 &extend_data)) {
1197 BT_LOGE("Cannot iterate on the extension object's elements: "
1198 "extension-value-addr=%p", extension_obj);
1199 goto error;
1200 }
1201
1202 if (extend_data.status) {
1203 BT_LOGE("Failed to successfully iterate on the extension object's elements: "
1204 "extension-value-addr=%p", extension_obj);
1205 goto error;
1206 }
1207
1208 BT_LOGD("Extended map value: extended-value-addr=%p",
1209 *extended_map_obj);
1210 goto end;
1211
1212 error:
1213 BT_OBJECT_PUT_REF_AND_RESET(*extended_map_obj);
1214 *extended_map_obj = NULL;
1215
1216 end:
1217 return extend_data.status;
1218 }
1219
1220 enum bt_value_status bt_value_copy(const struct bt_value *object,
1221 struct bt_value **copy_obj)
1222 {
1223 enum bt_value_status status = BT_VALUE_STATUS_OK;
1224
1225 BT_ASSERT_PRE_NON_NULL(object, "Value object");
1226 BT_ASSERT_PRE_NON_NULL(copy_obj, "Value object copy (output)");
1227 BT_LOGD("Copying value object: addr=%p", object);
1228 *copy_obj = copy_funcs[object->type](object);
1229 if (*copy_obj) {
1230 BT_LOGD("Copied value object: copy-value-addr=%p",
1231 copy_obj);
1232 } else {
1233 status = BT_VALUE_STATUS_NOMEM;
1234 *copy_obj = NULL;
1235 BT_LOGE_STR("Failed to copy value object.");
1236 }
1237
1238 return status;
1239 }
1240
1241 bt_bool bt_value_compare(const struct bt_value *object_a,
1242 const struct bt_value *object_b)
1243 {
1244 bt_bool ret = BT_FALSE;
1245
1246 BT_ASSERT_PRE_NON_NULL(object_a, "Value object A");
1247 BT_ASSERT_PRE_NON_NULL(object_b, "Value object B");
1248
1249 if (object_a->type != object_b->type) {
1250 BT_LOGV("Values are different: type mismatch: "
1251 "value-a-addr=%p, value-b-addr=%p, "
1252 "value-a-type=%s, value-b-type=%s",
1253 object_a, object_b,
1254 bt_common_value_type_string(object_a->type),
1255 bt_common_value_type_string(object_b->type));
1256 goto end;
1257 }
1258
1259 ret = compare_funcs[object_a->type](object_a, object_b);
1260
1261 end:
1262 return ret;
1263 }
1264
1265 void bt_value_get_ref(const struct bt_value *value)
1266 {
1267 bt_object_get_ref(value);
1268 }
1269
1270 void bt_value_put_ref(const struct bt_value *value)
1271 {
1272 bt_object_put_ref(value);
1273 }
This page took 0.055872 seconds and 4 git commands to generate.