lib, bt2: rename "signed/unsigned sel." -> "integer signed/unsigned sel."
[babeltrace.git] / src / plugins / lttng-utils / debug-info / trace-ir-metadata-field-class-copy.c
index dc757d03934be630b2242029d1acb2d07973c6de..1face29d15ccc809dc90586000560637ac6d3fc1 100644 (file)
@@ -74,7 +74,10 @@ const bt_field_class *walk_field_path(struct trace_ir_metadata_maps *md_maps,
                                member);
                        break;
                }
-               case BT_FIELD_CLASS_TYPE_OPTION:
+               case BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR:
+               case BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR:
+               case BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR:
+               case BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR:
                {
                        BT_ASSERT(bt_field_path_item_get_type(fp_item) ==
                                BT_FIELD_PATH_ITEM_TYPE_CURRENT_OPTION_CONTENT);
@@ -83,8 +86,8 @@ const bt_field_class *walk_field_path(struct trace_ir_metadata_maps *md_maps,
                        break;
                }
                case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR:
-               case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR:
-               case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR:
+               case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR:
+               case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR:
                {
                        const bt_field_class_variant_option *option;
 
@@ -476,36 +479,36 @@ int field_class_variant_copy(
                        goto error;
                }
 
-               if (fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR) {
-                       const bt_field_class_variant_with_selector_unsigned_option *spec_opt =
-                               bt_field_class_variant_with_selector_unsigned_borrow_option_by_index_const(
+               if (fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR) {
+                       const bt_field_class_variant_with_selector_integer_unsigned_option *spec_opt =
+                               bt_field_class_variant_with_selector_integer_unsigned_borrow_option_by_index_const(
                                        in_field_class, i);
                        const bt_integer_range_set_unsigned *ranges =
-                               bt_field_class_variant_with_selector_unsigned_option_borrow_ranges_const(
+                               bt_field_class_variant_with_selector_integer_unsigned_option_borrow_ranges_const(
                                        spec_opt);
 
-                       if (bt_field_class_variant_with_selector_unsigned_append_option(
+                       if (bt_field_class_variant_with_selector_integer_unsigned_append_option(
                                        out_field_class, option_name,
                                        out_option_field_class, ranges) !=
                                        BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_APPEND_OPTION_STATUS_OK) {
-                               BT_COMP_LOGE_STR("Cannot append option to variant field class with unsigned selector'");
+                               BT_COMP_LOGE_STR("Cannot append option to variant field class with unsigned integer selector'");
                                BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class);
                                ret = -1;
                                goto error;
                        }
-               } else if (fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR) {
-                       const bt_field_class_variant_with_selector_signed_option *spec_opt =
-                               bt_field_class_variant_with_selector_signed_borrow_option_by_index_const(
+               } else if (fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR) {
+                       const bt_field_class_variant_with_selector_integer_signed_option *spec_opt =
+                               bt_field_class_variant_with_selector_integer_signed_borrow_option_by_index_const(
                                        in_field_class, i);
                        const bt_integer_range_set_signed *ranges =
-                               bt_field_class_variant_with_selector_signed_option_borrow_ranges_const(
+                               bt_field_class_variant_with_selector_integer_signed_option_borrow_ranges_const(
                                        spec_opt);
 
-                       if (bt_field_class_variant_with_selector_signed_append_option(
+                       if (bt_field_class_variant_with_selector_integer_signed_append_option(
                                        out_field_class, option_name,
                                        out_option_field_class, ranges) !=
                                        BT_FIELD_CLASS_VARIANT_WITH_SELECTOR_APPEND_OPTION_STATUS_OK) {
-                               BT_COMP_LOGE_STR("Cannot append option to variant field class with signed selector'");
+                               BT_COMP_LOGE_STR("Cannot append option to variant field class with signed integer selector'");
                                BT_FIELD_CLASS_PUT_REF_AND_RESET(out_tag_field_class);
                                ret = -1;
                                goto error;
@@ -593,10 +596,14 @@ int field_class_option_copy(
                        "in-fc-addr=%p, out-fc-addr=%p",
                        in_field_class, out_field_class);
 
-       /*
-        * There is no content to copy. Keep this function call anyway for
-        * logging purposes.
-        */
+       if (bt_field_class_get_type(out_field_class) ==
+                       BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR) {
+               bt_field_class_option_with_selector_bool_set_selector_is_reversed(
+                       out_field_class,
+                       bt_field_class_option_with_selector_bool_selector_is_reversed(
+                               in_field_class));
+       }
+
        BT_COMP_LOGD("Copied option field class: in-fc-addr=%p, "
                        "out-fc-addr=%p", in_field_class, out_field_class);
 
@@ -753,14 +760,14 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps *
                                out_elem_fc, out_length_fc);
                break;
        }
-       case BT_FIELD_CLASS_TYPE_OPTION:
+       case BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR:
+       case BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR:
+       case BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR:
+       case BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR:
        {
                const bt_field_class *in_content_fc =
                        bt_field_class_option_borrow_field_class_const(
                                        in_field_class);
-               const bt_field_path *in_selector_fp =
-                       bt_field_class_option_borrow_selector_field_path_const(
-                               in_field_class);
                bt_field_class *out_selector_fc = NULL;
                bt_field_class *out_content_fc;
                int ret;
@@ -780,30 +787,66 @@ bt_field_class *create_field_class_copy_internal(struct trace_ir_metadata_maps *
                        goto error;
                }
 
-               if (in_selector_fp) {
-                       const bt_field_class *in_selector_fc =
-                               resolve_field_path_to_field_class(
-                                       in_selector_fp, md_maps);
+               if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR) {
+                       out_field_class =
+                               bt_field_class_option_without_selector_create(
+                                       md_maps->output_trace_class,
+                                       out_content_fc);
+               } else {
+                       const bt_field_path *in_selector_fp =
+                               bt_field_class_option_with_selector_borrow_selector_field_path_const(
+                                       in_field_class);
+                       const bt_field_class *in_selector_fc;
 
+                       BT_ASSERT(in_selector_fp);
+                       in_selector_fc = resolve_field_path_to_field_class(
+                               in_selector_fp, md_maps);
                        BT_ASSERT(in_selector_fc);
                        out_selector_fc = g_hash_table_lookup(
                                md_maps->field_class_map, in_selector_fc);
                        BT_ASSERT(out_selector_fc);
+
+                       if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR) {
+                               out_field_class =
+                                       bt_field_class_option_with_selector_bool_create(
+                                               md_maps->output_trace_class,
+                                               out_content_fc, out_selector_fc);
+                       } else if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR) {
+                               const bt_integer_range_set_unsigned *ranges =
+                                       bt_field_class_option_with_selector_integer_unsigned_borrow_selector_ranges_const(
+                                               in_field_class);
+
+                               BT_ASSERT(ranges);
+                               out_field_class =
+                                       bt_field_class_option_with_selector_integer_unsigned_create(
+                                               md_maps->output_trace_class,
+                                               out_content_fc, out_selector_fc,
+                                               ranges);
+                       } else if (fc_type == BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR) {
+                               const bt_integer_range_set_signed *ranges =
+                                       bt_field_class_option_with_selector_integer_signed_borrow_selector_ranges_const(
+                                               in_field_class);
+
+                               BT_ASSERT(ranges);
+                               out_field_class =
+                                       bt_field_class_option_with_selector_integer_signed_create(
+                                               md_maps->output_trace_class,
+                                               out_content_fc, out_selector_fc,
+                                               ranges);
+                       }
                }
 
-               out_field_class = bt_field_class_option_create(
-                               md_maps->output_trace_class,
-                               out_content_fc, out_selector_fc);
+               BT_ASSERT(out_field_class);
                break;
        }
        case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR:
-       case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR:
-       case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR:
+       case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR:
+       case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR:
        {
                bt_field_class *out_sel_fc = NULL;
 
-               if (fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR ||
-                               fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR) {
+               if (fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR ||
+                               fc_type == BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR) {
                        const bt_field_class *in_sel_fc;
                        const bt_field_path *sel_fp =
                                bt_field_class_variant_with_selector_borrow_selector_field_path_const(
@@ -910,13 +953,16 @@ int copy_field_class_content_internal(
                ret = field_class_dynamic_array_copy(md_maps,
                                in_field_class, out_field_class);
                break;
-       case BT_FIELD_CLASS_TYPE_OPTION:
+       case BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR:
+       case BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR:
+       case BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR:
+       case BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR:
                ret = field_class_option_copy(md_maps,
                                in_field_class, out_field_class);
                break;
        case BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR:
-       case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_SELECTOR:
-       case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_SELECTOR:
+       case BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR:
+       case BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR:
                ret = field_class_variant_copy(md_maps,
                                in_field_class, out_field_class);
                break;
This page took 0.026002 seconds and 4 git commands to generate.