#ifndef _CTF_META_H
#define _CTF_META_H
-#include <babeltrace2/babeltrace.h>
-#include "common/common.h"
-#include "common/uuid.h"
-#include "common/assert.h"
#include <glib.h>
-#include <stdbool.h>
#include <stdint.h>
#include <string.h>
+#include <babeltrace2/babeltrace.h>
+
+#include "common/assert.h"
+#include "common/common.h"
+#include "common/uuid.h"
+
enum ctf_field_class_type
{
CTF_FIELD_CLASS_TYPE_INT,
for (i = 0; i < fc->mappings->len; i++) {
struct ctf_field_class_enum_mapping *mapping =
- &g_array_index(fc->mappings, struct ctf_field_class_enum_mapping, i);
+ &bt_g_array_index(fc->mappings, struct ctf_field_class_enum_mapping, i);
_ctf_field_class_enum_mapping_fini(mapping);
}
for (i = 0; i < fc->members->len; i++) {
struct ctf_named_field_class *named_fc =
- &g_array_index(fc->members, struct ctf_named_field_class, i);
+ &bt_g_array_index(fc->members, struct ctf_named_field_class, i);
_ctf_named_field_class_fini(named_fc);
}
for (i = 0; i < fc->options->len; i++) {
struct ctf_named_field_class *named_fc =
- &g_array_index(fc->options, struct ctf_named_field_class, i);
+ &bt_g_array_index(fc->options, struct ctf_named_field_class, i);
_ctf_named_field_class_fini(named_fc);
}
{
BT_ASSERT_DBG(mapping);
BT_ASSERT_DBG(index < mapping->ranges->len);
- return &g_array_index(mapping->ranges, struct ctf_range, index);
+ return &bt_g_array_index(mapping->ranges, struct ctf_range, index);
}
static inline struct ctf_field_class_enum_mapping *
{
BT_ASSERT_DBG(fc);
BT_ASSERT_DBG(index < fc->mappings->len);
- return &g_array_index(fc->mappings, struct ctf_field_class_enum_mapping, index);
+ return &bt_g_array_index(fc->mappings, struct ctf_field_class_enum_mapping, index);
}
static inline struct ctf_field_class_enum_mapping *
{
BT_ASSERT_DBG(fc);
BT_ASSERT_DBG(index < fc->members->len);
- return &g_array_index(fc->members, struct ctf_named_field_class, index);
+ return &bt_g_array_index(fc->members, struct ctf_named_field_class, index);
}
static inline struct ctf_named_field_class *
ctf_field_class_struct_borrow_member_int_field_class_by_name(
struct ctf_field_class_struct *struct_fc, const char *name)
{
- struct ctf_field_class_int *int_fc = NULL;
+ ctf_field_class *member_fc =
+ ctf_field_class_struct_borrow_member_field_class_by_name(struct_fc, name);
- int_fc = ctf_field_class_as_int(
- ctf_field_class_struct_borrow_member_field_class_by_name(struct_fc, name));
- if (!int_fc) {
- goto end;
+ if (!member_fc) {
+ return nullptr;
}
- if (int_fc->base.base.type != CTF_FIELD_CLASS_TYPE_INT &&
- int_fc->base.base.type != CTF_FIELD_CLASS_TYPE_ENUM) {
- int_fc = NULL;
- goto end;
+ if (member_fc->type != CTF_FIELD_CLASS_TYPE_INT &&
+ member_fc->type != CTF_FIELD_CLASS_TYPE_ENUM) {
+ return nullptr;
}
-end:
- return int_fc;
+ return ctf_field_class_as_int(member_fc);
}
static inline void _ctf_named_field_class_unescape_orig_name(struct ctf_named_field_class *named_fc)
BT_ASSERT(orig_name);
g_array_set_size(fc->members, fc->members->len + 1);
- named_fc = &g_array_index(fc->members, struct ctf_named_field_class, fc->members->len - 1);
+ named_fc = &bt_g_array_index(fc->members, struct ctf_named_field_class, fc->members->len - 1);
_ctf_named_field_class_init(named_fc);
g_string_assign(named_fc->orig_name, orig_name);
_ctf_named_field_class_unescape_orig_name(named_fc);
{
BT_ASSERT_DBG(fc);
BT_ASSERT_DBG(index < fc->options->len);
- return &g_array_index(fc->options, struct ctf_named_field_class, index);
+ return &bt_g_array_index(fc->options, struct ctf_named_field_class, index);
}
static inline struct ctf_named_field_class *
{
BT_ASSERT_DBG(fc);
BT_ASSERT_DBG(index < fc->ranges->len);
- return &g_array_index(fc->ranges, struct ctf_field_class_variant_range, index);
+ return &bt_g_array_index(fc->ranges, struct ctf_field_class_variant_range, index);
}
static inline void ctf_field_class_variant_append_option(struct ctf_field_class_variant *fc,
BT_ASSERT(orig_name);
g_array_set_size(fc->options, fc->options->len + 1);
- named_fc = &g_array_index(fc->options, struct ctf_named_field_class, fc->options->len - 1);
+ named_fc = &bt_g_array_index(fc->options, struct ctf_named_field_class, fc->options->len - 1);
_ctf_named_field_class_init(named_fc);
g_string_assign(named_fc->orig_name, orig_name);
_ctf_named_field_class_unescape_orig_name(named_fc);
{
BT_ASSERT_DBG(fp);
BT_ASSERT_DBG(index < fp->path->len);
- return g_array_index(fp->path, int64_t, index);
+ return bt_g_array_index(fp->path, int64_t, index);
}
static inline void ctf_field_path_clear(struct ctf_field_path *fp)
uint64_t range_i;
struct ctf_field_class_enum_mapping *mapping =
- &g_array_index(fc->mappings, struct ctf_field_class_enum_mapping, i);
+ &bt_g_array_index(fc->mappings, struct ctf_field_class_enum_mapping, i);
for (range_i = 0; range_i < mapping->ranges->len; range_i++) {
- struct ctf_range *range = &g_array_index(mapping->ranges, struct ctf_range, range_i);
+ struct ctf_range *range = &bt_g_array_index(mapping->ranges, struct ctf_range, range_i);
ctf_field_class_enum_map_range(copy_fc, mapping->label->str, range->lower.u,
range->upper.u);
}
static inline struct ctf_field_class_string *
-_ctf_field_class_string_copy(struct ctf_field_class_string *fc)
+_ctf_field_class_string_copy(struct ctf_field_class_string *)
{
struct ctf_field_class_string *copy_fc = ctf_field_class_string_create();
for (i = 0; i < fc->members->len; i++) {
struct ctf_named_field_class *named_fc =
- &g_array_index(fc->members, struct ctf_named_field_class, i);
+ &bt_g_array_index(fc->members, struct ctf_named_field_class, i);
ctf_field_class_struct_append_member(copy_fc, named_fc->name->str,
ctf_field_class_copy(named_fc->fc));
for (i = 0; i < fc->options->len; i++) {
struct ctf_named_field_class *named_fc =
- &g_array_index(fc->options, struct ctf_named_field_class, i);
+ &bt_g_array_index(fc->options, struct ctf_named_field_class, i);
ctf_field_class_variant_append_option(copy_fc, named_fc->name->str,
ctf_field_class_copy(named_fc->fc));
for (i = 0; i < fc->ranges->len; i++) {
struct ctf_field_class_variant_range *range =
- &g_array_index(fc->ranges, struct ctf_field_class_variant_range, i);
+ &bt_g_array_index(fc->ranges, struct ctf_field_class_variant_range, i);
g_array_append_val(copy_fc->ranges, *range);
}
for (i = 0; i < tc->env_entries->len; i++) {
struct ctf_trace_class_env_entry *entry =
- &g_array_index(tc->env_entries, struct ctf_trace_class_env_entry, i);
+ &bt_g_array_index(tc->env_entries, struct ctf_trace_class_env_entry, i);
_ctf_trace_class_env_entry_fini(entry);
}
BT_ASSERT(name);
g_array_set_size(tc->env_entries, tc->env_entries->len + 1);
- entry =
- &g_array_index(tc->env_entries, struct ctf_trace_class_env_entry, tc->env_entries->len - 1);
+ entry = &bt_g_array_index(tc->env_entries, struct ctf_trace_class_env_entry,
+ tc->env_entries->len - 1);
entry->type = type;
_ctf_trace_class_env_entry_init(entry);
g_string_assign(entry->name, name);
{
BT_ASSERT_DBG(tc);
BT_ASSERT_DBG(index < tc->env_entries->len);
- return &g_array_index(tc->env_entries, struct ctf_trace_class_env_entry, index);
+ return &bt_g_array_index(tc->env_entries, struct ctf_trace_class_env_entry, index);
}
static inline struct ctf_trace_class_env_entry *