GQuark mapping_name;
};
+static
+void bt_ctf_field_type_destroy(struct bt_ctf_ref *);
static
void bt_ctf_field_type_integer_destroy(struct bt_ctf_ref *);
static
return ret;
}
+static
+void bt_ctf_field_type_destroy(struct bt_ctf_ref *ref)
+{
+ struct bt_ctf_field_type *type;
+ enum ctf_type_id type_id;
+
+ if (!ref) {
+ return;
+ }
+
+ type = container_of(ref, struct bt_ctf_field_type, ref_count);
+ type_id = type->declaration->id;
+ if (type_id <= CTF_TYPE_UNKNOWN ||
+ type_id >= NR_CTF_TYPES) {
+ return;
+ }
+
+ if (type->alias_name) {
+ g_string_free(type->alias_name, TRUE);
+ }
+ type_destroy_funcs[type_id](ref);
+}
+
BT_HIDDEN
int bt_ctf_field_type_validate(struct bt_ctf_field_type *type)
{
return type->declaration->id;
}
+const char *bt_ctf_field_type_get_alias_name(
+ struct bt_ctf_field_type *type)
+{
+ const char *name = NULL;
+
+ if (!type || !type->alias_name) {
+ goto end;
+ }
+
+ name = type->alias_name->str;
+end:
+ return name;
+}
+
void bt_ctf_field_type_get(struct bt_ctf_field_type *type)
{
if (!type) {
void bt_ctf_field_type_put(struct bt_ctf_field_type *type)
{
- enum ctf_type_id type_id;
-
if (!type) {
return;
}
- type_id = type->declaration->id;
- assert(type_id > CTF_TYPE_UNKNOWN && type_id < NR_CTF_TYPES);
- bt_ctf_ref_put(&type->ref_count, type_destroy_funcs[type_id]);
+ bt_ctf_ref_put(&type->ref_count, bt_ctf_field_type_destroy);
}
BT_HIDDEN
extern enum ctf_type_id bt_ctf_field_type_get_type_id(
struct bt_ctf_field_type *type);
+/*
+ * bt_ctf_field_type_get_alias_nameL get a field type's alias name
+ *
+ * A type's alias name is set if it was resolved from a typedef or
+ * typealias. Note that types that are resolved from a ypealias or
+ * typedef are distinct from the underlying type and can't be compared
+ * pointer-wise.
+ *
+ * @param type Field type.
+ *
+ * Returns a field type's alias name, NULL on error.
+ */
+extern const char *bt_ctf_field_type_get_alias_name(
+ struct bt_ctf_field_type *type);
+
/*
* bt_ctf_field_type_get and bt_ctf_field_type_put: increment and decrement
* the field type's reference count.