lib: remove CTF concepts of packet and event headers
[babeltrace.git] / plugins / ctf / common / metadata / ctf-meta-update-in-ir.c
index ca93a8d9a0ed78798d75cfd6a37dc0082ac56618..ed5d23bfd25b060b0311dae7e81df95ac2ed0d0a 100644 (file)
 
 #include "ctf-meta-visitors.h"
 
+static
+void force_update_field_class_in_ir(struct ctf_field_class *fc, bool in_ir)
+{
+       uint64_t i;
+
+       if (!fc) {
+               goto end;
+       }
+
+       fc->in_ir = in_ir;
+
+       switch (fc->type) {
+       case CTF_FIELD_CLASS_TYPE_STRUCT:
+       {
+               struct ctf_field_class_struct *struct_fc = (void *) fc;
+
+               for (i = 0; i < struct_fc->members->len; i++) {
+                       struct ctf_named_field_class *named_fc =
+                               ctf_field_class_struct_borrow_member_by_index(
+                                       struct_fc, i);
+
+                       force_update_field_class_in_ir(named_fc->fc, in_ir);
+               }
+
+               break;
+       }
+       case CTF_FIELD_CLASS_TYPE_VARIANT:
+       {
+               struct ctf_named_field_class *named_fc;
+               struct ctf_field_class_variant *var_fc = (void *) fc;
+
+               for (i = 0; i < var_fc->options->len; i++) {
+                       named_fc =
+                               ctf_field_class_variant_borrow_option_by_index(
+                                       var_fc, i);
+
+                       force_update_field_class_in_ir(named_fc->fc, in_ir);
+               }
+
+               break;
+       }
+       case CTF_FIELD_CLASS_TYPE_ARRAY:
+       case CTF_FIELD_CLASS_TYPE_SEQUENCE:
+       {
+               struct ctf_field_class_array_base *array_fc = (void *) fc;
+
+               force_update_field_class_in_ir(array_fc->elem_fc, in_ir);
+               break;
+       }
+       default:
+               break;
+       }
+
+end:
+       return;
+}
+
 static
 void update_field_class_in_ir(struct ctf_field_class *fc,
                GHashTable *ft_dependents)
@@ -36,9 +93,9 @@ void update_field_class_in_ir(struct ctf_field_class *fc,
                goto end;
        }
 
-       switch (fc->id) {
-       case CTF_FIELD_CLASS_ID_INT:
-       case CTF_FIELD_CLASS_ID_ENUM:
+       switch (fc->type) {
+       case CTF_FIELD_CLASS_TYPE_INT:
+       case CTF_FIELD_CLASS_TYPE_ENUM:
        {
                struct ctf_field_class_int *int_fc = (void *) fc;
 
@@ -55,7 +112,7 @@ void update_field_class_in_ir(struct ctf_field_class *fc,
 
                break;
        }
-       case CTF_FIELD_CLASS_ID_STRUCT:
+       case CTF_FIELD_CLASS_TYPE_STRUCT:
        {
                struct ctf_field_class_struct *struct_fc = (void *) fc;
 
@@ -75,7 +132,7 @@ void update_field_class_in_ir(struct ctf_field_class *fc,
 
                break;
        }
-       case CTF_FIELD_CLASS_ID_VARIANT:
+       case CTF_FIELD_CLASS_TYPE_VARIANT:
        {
                struct ctf_named_field_class *named_fc;
                struct ctf_field_class_variant *var_fc = (void *) fc;
@@ -125,15 +182,15 @@ void update_field_class_in_ir(struct ctf_field_class *fc,
 
                break;
        }
-       case CTF_FIELD_CLASS_ID_ARRAY:
-       case CTF_FIELD_CLASS_ID_SEQUENCE:
+       case CTF_FIELD_CLASS_TYPE_ARRAY:
+       case CTF_FIELD_CLASS_TYPE_SEQUENCE:
        {
                struct ctf_field_class_array_base *array_fc = (void *) fc;
 
                update_field_class_in_ir(array_fc->elem_fc, ft_dependents);
                fc->in_ir = array_fc->elem_fc->in_ir;
 
-               if (fc->id == CTF_FIELD_CLASS_ID_ARRAY) {
+               if (fc->type == CTF_FIELD_CLASS_TYPE_ARRAY) {
                        struct ctf_field_class_array *arr_fc = (void *) fc;
 
                        assert(arr_fc->meaning == CTF_FIELD_CLASS_MEANING_NONE ||
@@ -147,7 +204,7 @@ void update_field_class_in_ir(struct ctf_field_class *fc,
                                fc->in_ir = false;
                                array_fc->elem_fc->in_ir = false;
                        }
-               } else if (fc->id == CTF_FIELD_CLASS_ID_SEQUENCE) {
+               } else if (fc->type == CTF_FIELD_CLASS_TYPE_SEQUENCE) {
                        if (fc->in_ir) {
                                struct ctf_field_class_sequence *seq_fc = (void *) fc;
 
@@ -208,16 +265,16 @@ int ctf_trace_class_update_in_ir(struct ctf_trace_class *ctf_tc)
                if (!sc->is_translated) {
                        update_field_class_in_ir(sc->event_common_context_fc,
                                ft_dependents);
-                       update_field_class_in_ir(sc->event_header_fc,
-                               ft_dependents);
+                       force_update_field_class_in_ir(sc->event_header_fc,
+                               false);
                        update_field_class_in_ir(sc->packet_context_fc,
                                ft_dependents);
                }
        }
 
        if (!ctf_tc->is_translated) {
-               update_field_class_in_ir(ctf_tc->packet_header_fc,
-                       ft_dependents);
+               force_update_field_class_in_ir(ctf_tc->packet_header_fc,
+                       false);
        }
 
        g_hash_table_destroy(ft_dependents);
This page took 0.0402090000000001 seconds and 4 git commands to generate.