The functions used to create enumeration, array, and
sequence types are different from the other creation
functions in that they register another type at creation
time. Other compound types are empty when created. When a
type is initialized, its byte order setting function is
called, which is recursive for compound types and for the
enumeration type. This overrides the previously set byte
order of the underlying type passed to those creation functions.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
-void bt_ctf_field_type_init(struct bt_ctf_field_type *type)
+void bt_ctf_field_type_init(struct bt_ctf_field_type *type, int init_bo)
{
enum ctf_type_id type_id = type->declaration->id;
{
enum ctf_type_id type_id = type->declaration->id;
assert(type && (type_id > CTF_TYPE_UNKNOWN) &&
(type_id < NR_CTF_TYPES));
assert(type && (type_id > CTF_TYPE_UNKNOWN) &&
(type_id < NR_CTF_TYPES));
bt_ctf_ref_init(&type->ref_count);
type->freeze = type_freeze_funcs[type_id];
type->serialize = type_serialize_funcs[type_id];
bt_ctf_ref_init(&type->ref_count);
type->freeze = type_freeze_funcs[type_id];
type->serialize = type_serialize_funcs[type_id];
- ret = bt_ctf_field_type_set_byte_order(type, BT_CTF_BYTE_ORDER_NATIVE);
- assert(!ret);
+
+ if (init_bo) {
+ int ret = bt_ctf_field_type_set_byte_order(type,
+ BT_CTF_BYTE_ORDER_NATIVE);
+ assert(!ret);
+ }
+
type->declaration->alignment = 1;
}
type->declaration->alignment = 1;
}
integer->declaration.len = size;
integer->declaration.base = BT_CTF_INTEGER_BASE_DECIMAL;
integer->declaration.encoding = CTF_STRING_NONE;
integer->declaration.len = size;
integer->declaration.base = BT_CTF_INTEGER_BASE_DECIMAL;
integer->declaration.encoding = CTF_STRING_NONE;
- bt_ctf_field_type_init(&integer->parent);
+ bt_ctf_field_type_init(&integer->parent, TRUE);
return &integer->parent;
}
return &integer->parent;
}
enumeration->container = integer_container_type;
enumeration->entries = g_ptr_array_new_with_free_func(
(GDestroyNotify)destroy_enumeration_mapping);
enumeration->container = integer_container_type;
enumeration->entries = g_ptr_array_new_with_free_func(
(GDestroyNotify)destroy_enumeration_mapping);
- bt_ctf_field_type_init(&enumeration->parent);
+ bt_ctf_field_type_init(&enumeration->parent, FALSE);
return &enumeration->parent;
error:
g_free(enumeration);
return &enumeration->parent;
error:
g_free(enumeration);
floating_point->mantissa.p.alignment = 1;
floating_point->exp.p.alignment = 1;
floating_point->mantissa.p.alignment = 1;
floating_point->exp.p.alignment = 1;
- bt_ctf_field_type_init(&floating_point->parent);
+ bt_ctf_field_type_init(&floating_point->parent, TRUE);
end:
return floating_point ? &floating_point->parent : NULL;
}
end:
return floating_point ? &floating_point->parent : NULL;
}
structure->fields = g_ptr_array_new_with_free_func(
(GDestroyNotify)destroy_structure_field);
structure->field_name_to_index = g_hash_table_new(NULL, NULL);
structure->fields = g_ptr_array_new_with_free_func(
(GDestroyNotify)destroy_structure_field);
structure->field_name_to_index = g_hash_table_new(NULL, NULL);
- bt_ctf_field_type_init(&structure->parent);
+ bt_ctf_field_type_init(&structure->parent, TRUE);
return &structure->parent;
error:
return NULL;
return &structure->parent;
error:
return NULL;
struct bt_ctf_field_type_enumeration, parent);
}
struct bt_ctf_field_type_enumeration, parent);
}
- bt_ctf_field_type_init(&variant->parent);
+ bt_ctf_field_type_init(&variant->parent, TRUE);
/* A variant's alignment is undefined */
variant->parent.declaration->alignment = 0;
return &variant->parent;
/* A variant's alignment is undefined */
variant->parent.declaration->alignment = 0;
return &variant->parent;
bt_ctf_field_type_get(element_type);
array->element_type = element_type;
array->length = length;
bt_ctf_field_type_get(element_type);
array->element_type = element_type;
array->length = length;
- bt_ctf_field_type_init(&array->parent);
+ bt_ctf_field_type_init(&array->parent, FALSE);
return &array->parent;
error:
return NULL;
return &array->parent;
error:
return NULL;
bt_ctf_field_type_get(element_type);
sequence->element_type = element_type;
sequence->length_field_name = g_string_new(length_field_name);
bt_ctf_field_type_get(element_type);
sequence->element_type = element_type;
sequence->length_field_name = g_string_new(length_field_name);
- bt_ctf_field_type_init(&sequence->parent);
+ bt_ctf_field_type_init(&sequence->parent, FALSE);
return &sequence->parent;
error:
return NULL;
return &sequence->parent;
error:
return NULL;
string->parent.declaration = &string->declaration.p;
string->parent.declaration->id = CTF_TYPE_STRING;
string->parent.declaration = &string->declaration.p;
string->parent.declaration->id = CTF_TYPE_STRING;
- bt_ctf_field_type_init(&string->parent);
+ bt_ctf_field_type_init(&string->parent, TRUE);
string->declaration.encoding = CTF_STRING_UTF8;
string->parent.declaration->alignment = CHAR_BIT;
return &string->parent;
string->declaration.encoding = CTF_STRING_UTF8;
string->parent.declaration->alignment = CHAR_BIT;
return &string->parent;