From: Jérémie Galarneau Date: Mon, 11 May 2015 21:24:24 +0000 (-0400) Subject: ir: add bt_ctf_field_path internal API X-Git-Tag: v2.0.0-pre1~1248 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=6b64f18523958d5dfbbbb00b17f6028b1eeb24ce ir: add bt_ctf_field_path internal API Signed-off-by: Jérémie Galarneau --- diff --git a/formats/ctf/ir/event-types.c b/formats/ctf/ir/event-types.c index 9b78c0db..9a8ce896 100644 --- a/formats/ctf/ir/event-types.c +++ b/formats/ctf/ir/event-types.c @@ -1955,6 +1955,56 @@ end: return copy; } +BT_HIDDEN +struct bt_ctf_field_path *bt_ctf_field_path_create(void) +{ + struct bt_ctf_field_path *field_path = NULL; + + field_path = g_new0(struct bt_ctf_field_path, 1); + if (!field_path) { + goto end; + } + + field_path->root = CTF_NODE_UNKNOWN; + field_path->path_indexes = g_array_new(TRUE, FALSE, sizeof(int)); + if (!field_path->path_indexes) { + bt_ctf_field_path_destroy(field_path); + field_path = NULL; + } +end: + return field_path; +} + + +BT_HIDDEN +struct bt_ctf_field_path *bt_ctf_field_path_copy( + struct bt_ctf_field_path *path) +{ + struct bt_ctf_field_path *new_path = bt_ctf_field_path_create(); + + if (!new_path) { + goto end; + } + + new_path->root = path->root; + g_array_insert_vals(new_path->path_indexes, 0, + path->path_indexes->data, path->path_indexes->len); +end: + return new_path; +} + +BT_HIDDEN +void bt_ctf_field_path_destroy(struct bt_ctf_field_path *path) +{ + if (!path) { + return; + } + + if (path->path_indexes) { + g_array_free(path->path_indexes, TRUE); + } + g_free(path); +} BT_HIDDEN int bt_ctf_field_type_structure_get_field_name_index( diff --git a/include/babeltrace/ctf-ir/event-types-internal.h b/include/babeltrace/ctf-ir/event-types-internal.h index 8ae102b0..b420a579 100644 --- a/include/babeltrace/ctf-ir/event-types-internal.h +++ b/include/babeltrace/ctf-ir/event-types-internal.h @@ -41,6 +41,26 @@ typedef void (*type_freeze_func)(struct bt_ctf_field_type *); typedef int (*type_serialize_func)(struct bt_ctf_field_type *, struct metadata_context *); +enum bt_ctf_node { + CTF_NODE_UNKNOWN = -1, + CTF_NODE_ENV = 0, + CTF_NODE_TRACE_PACKET_HEADER = 1, + CTF_NODE_STREAM_PACKET_CONTEXT = 2, + CTF_NODE_STREAM_EVENT_HEADER = 3, + CTF_NODE_STREAM_EVENT_CONTEXT = 4, + CTF_NODE_EVENT_CONTEXT = 5, + CTF_NODE_EVENT_FIELDS = 6, +}; + +struct bt_ctf_field_path { + enum bt_ctf_node root; + /* + * Array of integers (int) indicating the index in either + * structures or variants that make-up the path to a field. + */ + GArray *path_indexes; +}; + struct bt_ctf_field_type { struct bt_ctf_ref ref_count; struct bt_declaration *declaration; @@ -165,6 +185,15 @@ BT_HIDDEN struct bt_ctf_field_type *bt_ctf_field_type_copy( struct bt_ctf_field_type *type); +BT_HIDDEN +struct bt_ctf_field_path *bt_ctf_field_path_create(void); + +BT_HIDDEN +struct bt_ctf_field_path *bt_ctf_field_path_copy( + struct bt_ctf_field_path *path); + +BT_HIDDEN +void bt_ctf_field_path_destroy(struct bt_ctf_field_path *path); BT_HIDDEN int bt_ctf_field_type_structure_get_field_name_index(