src.ctf.*: add old CTF IR const functions
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Wed, 17 Apr 2024 17:53:23 +0000 (13:53 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 4 Sep 2024 19:05:14 +0000 (15:05 -0400)
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I73f825b4127cff772904579c90806bd367a7fe36
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8012
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12709

src/plugins/ctf/common/src/metadata/tsdl/ctf-meta.hpp

index 541fba6dc981d427b4eed95b3dd7613d0f175415..880e98fedd6a784688a78f38c719303b35c1235a 100644 (file)
@@ -801,6 +801,12 @@ ctf_field_class_enum_mapping_borrow_range_by_index(struct ctf_field_class_enum_m
     BT_ASSERT_DBG(index < mapping->ranges->len);
     return &bt_g_array_index(mapping->ranges, struct ctf_range, index);
 }
+static inline const struct ctf_range *ctf_field_class_enum_mapping_borrow_range_by_index_const(
+    const struct ctf_field_class_enum_mapping *mapping, uint64_t index)
+{
+    return ctf_field_class_enum_mapping_borrow_range_by_index(
+        (struct ctf_field_class_enum_mapping *) mapping, index);
+}
 
 static inline struct ctf_field_class_enum_mapping *
 ctf_field_class_enum_borrow_mapping_by_index(struct ctf_field_class_enum *fc, uint64_t index)
@@ -810,6 +816,13 @@ ctf_field_class_enum_borrow_mapping_by_index(struct ctf_field_class_enum *fc, ui
     return &bt_g_array_index(fc->mappings, struct ctf_field_class_enum_mapping, index);
 }
 
+static inline const struct ctf_field_class_enum_mapping *
+ctf_field_class_enum_borrow_mapping_by_index_const(const struct ctf_field_class_enum *fc,
+                                                   uint64_t index)
+{
+    return ctf_field_class_enum_borrow_mapping_by_index((struct ctf_field_class_enum *) fc, index);
+}
+
 static inline struct ctf_field_class_enum_mapping *
 ctf_field_class_enum_borrow_mapping_by_label(struct ctf_field_class_enum *fc, const char *label)
 {
@@ -883,6 +896,14 @@ ctf_field_class_struct_borrow_member_by_index(struct ctf_field_class_struct *fc,
     return &bt_g_array_index(fc->members, struct ctf_named_field_class, index);
 }
 
+static inline const struct ctf_named_field_class *
+ctf_field_class_struct_borrow_member_by_index_const(const struct ctf_field_class_struct *fc,
+                                                    uint64_t index)
+{
+    return ctf_field_class_struct_borrow_member_by_index((struct ctf_field_class_struct *) fc,
+                                                         index);
+}
+
 static inline struct ctf_named_field_class *
 ctf_field_class_struct_borrow_member_by_name(struct ctf_field_class_struct *fc, const char *name)
 {
@@ -987,6 +1008,14 @@ ctf_field_class_variant_borrow_option_by_index(struct ctf_field_class_variant *f
     return &bt_g_array_index(fc->options, struct ctf_named_field_class, index);
 }
 
+static inline const struct ctf_named_field_class *
+ctf_field_class_variant_borrow_option_by_index_const(const struct ctf_field_class_variant *fc,
+                                                     uint64_t index)
+{
+    return ctf_field_class_variant_borrow_option_by_index((struct ctf_field_class_variant *) fc,
+                                                          index);
+}
+
 static inline struct ctf_named_field_class *
 ctf_field_class_variant_borrow_option_by_name(struct ctf_field_class_variant *fc, const char *name)
 {
@@ -1018,6 +1047,14 @@ ctf_field_class_variant_borrow_range_by_index(struct ctf_field_class_variant *fc
     return &bt_g_array_index(fc->ranges, struct ctf_field_class_variant_range, index);
 }
 
+static inline const struct ctf_field_class_variant_range *
+ctf_field_class_variant_borrow_range_by_index_const(const struct ctf_field_class_variant *fc,
+                                                    uint64_t index)
+{
+    return ctf_field_class_variant_borrow_range_by_index((struct ctf_field_class_variant *) fc,
+                                                         index);
+}
+
 static inline void ctf_field_class_variant_append_option(struct ctf_field_class_variant *fc,
                                                          const char *orig_name,
                                                          struct ctf_field_class *option_fc)
@@ -1107,6 +1144,39 @@ ctf_field_class_compound_borrow_field_class_by_index(struct ctf_field_class *com
     return fc;
 }
 
+static inline const struct ctf_named_field_class *
+ctf_field_class_compound_borrow_named_field_class_by_index(struct ctf_field_class *comp_fc,
+                                                           uint64_t index)
+{
+    struct ctf_named_field_class *named_fc = NULL;
+
+    switch (comp_fc->type) {
+    case CTF_FIELD_CLASS_TYPE_STRUCT:
+    {
+        named_fc = ctf_field_class_struct_borrow_member_by_index(
+            (struct ctf_field_class_struct *) comp_fc, index);
+
+        BT_ASSERT_DBG(named_fc);
+        break;
+    }
+    case CTF_FIELD_CLASS_TYPE_VARIANT:
+    {
+        named_fc = ctf_field_class_variant_borrow_option_by_index(
+            (struct ctf_field_class_variant *) comp_fc, index);
+
+        BT_ASSERT_DBG(named_fc);
+        break;
+    }
+    case CTF_FIELD_CLASS_TYPE_ARRAY:
+    case CTF_FIELD_CLASS_TYPE_SEQUENCE:
+        bt_common_abort();
+    default:
+        break;
+    }
+
+    return named_fc;
+}
+
 static inline uint64_t ctf_field_class_compound_get_field_class_count(struct ctf_field_class *fc)
 {
     uint64_t field_count;
This page took 0.026193 seconds and 4 git commands to generate.