sink.ctf.fs: write boolean field classes and fields
[babeltrace.git] / src / plugins / ctf / fs-sink / translate-ctf-ir-to-tsdl.c
index f867edbf683a78ac1dce84056b4b9eb47a603d30..b21917ac3584c2b850dcf57f4a86eca45c5ba5b1 100644 (file)
@@ -181,6 +181,20 @@ void append_end_block_semi_nl_nl(struct ctx *ctx)
        g_string_append_c(ctx->tsdl, '\n');
 }
 
+static
+void append_bool_field_class(struct ctx *ctx,
+               __attribute__((unused)) struct fs_sink_ctf_field_class_bool *fc)
+{
+       /*
+        * CTF 1.8 has no boolean field class type, so this component
+        * translates it to an 8-bit unsigned integer field class.
+        */
+       append_integer_field_class_from_props(ctx, fc->base.size,
+               fc->base.base.alignment, false,
+               BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL,
+               NULL, NULL, false);
+}
+
 static
 void append_integer_field_class(struct ctx *ctx,
                struct fs_sink_ctf_field_class_int *fc)
@@ -210,8 +224,8 @@ void append_integer_field_class(struct ctx *ctx,
                for (i = 0; i < bt_field_class_enumeration_get_mapping_count(ir_fc); i++) {
                        const char *label;
                        const bt_field_class_enumeration_mapping *mapping;
-                       const bt_field_class_unsigned_enumeration_mapping *u_mapping;
-                       const bt_field_class_signed_enumeration_mapping *s_mapping;
+                       const bt_field_class_enumeration_unsigned_mapping *u_mapping;
+                       const bt_field_class_enumeration_signed_mapping *s_mapping;
                        const bt_integer_range_set *ranges;
                        const bt_integer_range_set_unsigned *u_ranges;
                        const bt_integer_range_set_signed *s_ranges;
@@ -219,20 +233,20 @@ void append_integer_field_class(struct ctx *ctx,
                        uint64_t range_i;
 
                        if (is_signed) {
-                               s_mapping = bt_field_class_signed_enumeration_borrow_mapping_by_index_const(
+                               s_mapping = bt_field_class_enumeration_signed_borrow_mapping_by_index_const(
                                        ir_fc, i);
-                               mapping = bt_field_class_signed_enumeration_mapping_as_mapping_const(
+                               mapping = bt_field_class_enumeration_signed_mapping_as_mapping_const(
                                        s_mapping);
-                               s_ranges = bt_field_class_signed_enumeration_mapping_borrow_ranges_const(
+                               s_ranges = bt_field_class_enumeration_signed_mapping_borrow_ranges_const(
                                        s_mapping);
                                ranges = bt_integer_range_set_signed_as_range_set_const(
                                        s_ranges);
                        } else {
-                               u_mapping = bt_field_class_unsigned_enumeration_borrow_mapping_by_index_const(
+                               u_mapping = bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const(
                                        ir_fc, i);
-                               mapping = bt_field_class_unsigned_enumeration_mapping_as_mapping_const(
+                               mapping = bt_field_class_enumeration_unsigned_mapping_as_mapping_const(
                                        u_mapping);
-                               u_ranges = bt_field_class_unsigned_enumeration_mapping_borrow_ranges_const(
+                               u_ranges = bt_field_class_enumeration_unsigned_mapping_borrow_ranges_const(
                                        u_mapping);
                                ranges = bt_integer_range_set_unsigned_as_range_set_const(
                                        u_ranges);
@@ -424,6 +438,10 @@ void append_struct_field_class_members(struct ctx *ctx,
                                g_string_append_printf(ctx->tsdl, " %s;\n",
                                        var_fc->tag_ref->str);
                        }
+               } else if (fc->type == FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL) {
+                       append_indent(ctx);
+                       g_string_append(ctx->tsdl,
+                               "/* The integer field class below was a trace IR boolean field class. */\n");
                }
 
                append_indent(ctx);
@@ -469,6 +487,9 @@ static
 void append_field_class(struct ctx *ctx, struct fs_sink_ctf_field_class *fc)
 {
        switch (fc->type) {
+       case FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL:
+               append_bool_field_class(ctx, (void *) fc);
+               break;
        case FS_SINK_CTF_FIELD_CLASS_TYPE_INT:
                append_integer_field_class(ctx, (void *) fc);
                break;
@@ -862,7 +883,7 @@ void translate_trace_ctf_ir_to_tsdl(struct fs_sink_ctf_trace *trace,
                        switch (bt_value_get_type(val)) {
                        case BT_VALUE_TYPE_SIGNED_INTEGER:
                                g_string_append_printf(tsdl, "%" PRId64,
-                                       bt_value_signed_integer_get(val));
+                                       bt_value_integer_signed_get(val));
                                break;
                        case BT_VALUE_TYPE_STRING:
                                append_quoted_string(&ctx, bt_value_string_get(val));
This page took 0.026319 seconds and 4 git commands to generate.