#include "ctf-meta-visitors.hpp"
-struct ctx
+namespace ctf {
+
+struct MetaTranslateCtx
{
bt_self_component *self_comp;
bt_trace_class *ir_tc;
enum ctf_scope scope;
};
-static inline bt_field_class *ctf_field_class_to_ir(struct ctx *ctx, struct ctf_field_class *fc);
+} /* namespace ctf */
+
+static inline bt_field_class *ctf_field_class_to_ir(ctf::MetaTranslateCtx *ctx,
+ struct ctf_field_class *fc);
static inline void ctf_field_class_int_set_props(struct ctf_field_class_int *fc,
bt_field_class *ir_fc)
bt_field_class_integer_set_preferred_display_base(ir_fc, fc->disp_base);
}
-static inline bt_field_class *ctf_field_class_int_to_ir(struct ctx *ctx,
+static inline bt_field_class *ctf_field_class_int_to_ir(ctf::MetaTranslateCtx *ctx,
struct ctf_field_class_int *fc)
{
bt_field_class *ir_fc;
return ir_fc;
}
-static inline bt_field_class *ctf_field_class_enum_to_ir(struct ctx *ctx,
+static inline bt_field_class *ctf_field_class_enum_to_ir(ctf::MetaTranslateCtx *ctx,
struct ctf_field_class_enum *fc)
{
int ret;
return ir_fc;
}
-static inline bt_field_class *ctf_field_class_float_to_ir(struct ctx *ctx,
+static inline bt_field_class *ctf_field_class_float_to_ir(ctf::MetaTranslateCtx *ctx,
struct ctf_field_class_float *fc)
{
bt_field_class *ir_fc;
return ir_fc;
}
-static inline bt_field_class *ctf_field_class_string_to_ir(struct ctx *ctx,
- struct ctf_field_class_string *)
+static inline bt_field_class *ctf_field_class_string_to_ir(ctf::MetaTranslateCtx *ctx)
{
bt_field_class *ir_fc = bt_field_class_string_create(ctx->ir_tc);
return ir_fc;
}
-static inline void translate_struct_field_class_members(struct ctx *ctx,
+static inline void translate_struct_field_class_members(ctf::MetaTranslateCtx *ctx,
struct ctf_field_class_struct *fc,
bt_field_class *ir_fc, bool,
struct ctf_field_class_struct *)
}
}
-static inline bt_field_class *ctf_field_class_struct_to_ir(struct ctx *ctx,
+static inline bt_field_class *ctf_field_class_struct_to_ir(ctf::MetaTranslateCtx *ctx,
struct ctf_field_class_struct *fc)
{
bt_field_class *ir_fc = bt_field_class_structure_create(ctx->ir_tc);
return ir_fc;
}
-static inline bt_field_class *borrow_ir_fc_from_field_path(struct ctx *ctx,
+static inline bt_field_class *borrow_ir_fc_from_field_path(ctf::MetaTranslateCtx *ctx,
struct ctf_field_path *field_path)
{
bt_field_class *ir_fc = NULL;
return mapping;
}
-static inline bt_field_class *ctf_field_class_variant_to_ir(struct ctx *ctx,
+static inline bt_field_class *ctf_field_class_variant_to_ir(ctf::MetaTranslateCtx *ctx,
struct ctf_field_class_variant *fc)
{
int ret;
return ir_fc;
}
-static inline bt_field_class *ctf_field_class_array_to_ir(struct ctx *ctx,
+static inline bt_field_class *ctf_field_class_array_to_ir(ctf::MetaTranslateCtx *ctx,
struct ctf_field_class_array *fc)
{
bt_field_class *ir_fc;
return ir_fc;
}
-static inline bt_field_class *ctf_field_class_sequence_to_ir(struct ctx *ctx,
+static inline bt_field_class *ctf_field_class_sequence_to_ir(ctf::MetaTranslateCtx *ctx,
struct ctf_field_class_sequence *fc)
{
bt_field_class *ir_fc;
return ir_fc;
}
-static inline bt_field_class *ctf_field_class_to_ir(struct ctx *ctx, struct ctf_field_class *fc)
+static inline bt_field_class *ctf_field_class_to_ir(ctf::MetaTranslateCtx *ctx,
+ struct ctf_field_class *fc)
{
bt_field_class *ir_fc = NULL;
ir_fc = ctf_field_class_float_to_ir(ctx, ctf_field_class_as_float(fc));
break;
case CTF_FIELD_CLASS_TYPE_STRING:
- ir_fc = ctf_field_class_string_to_ir(ctx, ctf_field_class_as_string(fc));
+ ir_fc = ctf_field_class_string_to_ir(ctx);
break;
case CTF_FIELD_CLASS_TYPE_STRUCT:
ir_fc = ctf_field_class_struct_to_ir(ctx, ctf_field_class_as_struct(fc));
return has_immediate_member_in_ir;
}
-static inline bt_field_class *scope_ctf_field_class_to_ir(struct ctx *ctx)
+static inline bt_field_class *scope_ctf_field_class_to_ir(ctf::MetaTranslateCtx *ctx)
{
bt_field_class *ir_fc = NULL;
struct ctf_field_class *fc = NULL;
return ir_fc;
}
-static inline void ctf_event_class_to_ir(struct ctx *ctx)
+static inline void ctf_event_class_to_ir(ctf::MetaTranslateCtx *ctx)
{
int ret;
bt_event_class *ir_ec = NULL;
return;
}
-static inline void ctf_stream_class_to_ir(struct ctx *ctx)
+static inline void ctf_stream_class_to_ir(ctf::MetaTranslateCtx *ctx)
{
int ret;
bt_field_class *ir_fc;
bt_clock_class_set_origin_is_unix_epoch(ir_cc, cc->is_absolute);
}
-static inline int ctf_trace_class_to_ir(struct ctx *ctx)
+static inline int ctf_trace_class_to_ir(ctf::MetaTranslateCtx *ctx)
{
int ret = 0;
uint64_t i;
{
int ret = 0;
uint64_t i;
- struct ctx ctx = {};
+ ctf::MetaTranslateCtx ctx = {};
ctx.self_comp = self_comp;
ctx.tc = tc;
#include "fs-sink-ctf-meta.hpp"
#include "translate-ctf-ir-to-tsdl.hpp"
-struct ctx
+namespace ctf {
+namespace sink {
+
+struct CtfIrToTsdlCtx
{
unsigned int indent_level;
GString *tsdl;
};
-static inline void append_indent(struct ctx *ctx)
+} /* namespace sink */
+} /* namespace ctf */
+
+static inline void append_indent(ctf::sink::CtfIrToTsdlCtx *ctx)
{
unsigned int i;
}
}
-static void append_uuid(struct ctx *ctx, bt_uuid uuid)
+static void append_uuid(ctf::sink::CtfIrToTsdlCtx *ctx, bt_uuid uuid)
{
g_string_append_printf(ctx->tsdl, "\"" BT_UUID_FMT "\"", BT_UUID_FMT_VALUES(uuid));
}
-static void append_quoted_string_content(struct ctx *ctx, const char *str)
+static void append_quoted_string_content(ctf::sink::CtfIrToTsdlCtx *ctx, const char *str)
{
const char *ch;
}
}
-static void append_quoted_string(struct ctx *ctx, const char *str)
+static void append_quoted_string(ctf::sink::CtfIrToTsdlCtx *ctx, const char *str)
{
g_string_append_c(ctx->tsdl, '"');
append_quoted_string_content(ctx, str);
}
static void append_integer_field_class_from_props(
- struct ctx *ctx, unsigned int size, unsigned int alignment, bool is_signed,
+ ctf::sink::CtfIrToTsdlCtx *ctx, unsigned int size, unsigned int alignment, bool is_signed,
bt_field_class_integer_preferred_display_base disp_base, const char *mapped_clock_class_name,
const char *field_name, bool end)
{
}
}
-static void append_end_block(struct ctx *ctx)
+static void append_end_block(ctf::sink::CtfIrToTsdlCtx *ctx)
{
ctx->indent_level--;
append_indent(ctx);
g_string_append(ctx->tsdl, "}");
}
-static void append_end_block_semi_nl(struct ctx *ctx)
+static void append_end_block_semi_nl(ctf::sink::CtfIrToTsdlCtx *ctx)
{
ctx->indent_level--;
append_indent(ctx);
g_string_append(ctx->tsdl, "};\n");
}
-static void append_end_block_semi_nl_nl(struct ctx *ctx)
+static void append_end_block_semi_nl_nl(ctf::sink::CtfIrToTsdlCtx *ctx)
{
append_end_block_semi_nl(ctx);
g_string_append_c(ctx->tsdl, '\n');
}
-static void append_bool_field_class(struct ctx *ctx,
+static void append_bool_field_class(ctf::sink::CtfIrToTsdlCtx *ctx,
__attribute__((unused)) struct fs_sink_ctf_field_class_bool *fc)
{
/*
NULL, NULL, false);
}
-static void append_bit_array_field_class(struct ctx *ctx,
+static void append_bit_array_field_class(ctf::sink::CtfIrToTsdlCtx *ctx,
struct fs_sink_ctf_field_class_bit_array *fc)
{
/*
NULL, NULL, false);
}
-static void append_integer_field_class(struct ctx *ctx, struct fs_sink_ctf_field_class_int *fc)
+static void append_integer_field_class(ctf::sink::CtfIrToTsdlCtx *ctx,
+ struct fs_sink_ctf_field_class_int *fc)
{
const bt_field_class *ir_fc = fc->base.base.ir_fc;
bt_field_class_type type = bt_field_class_get_type(ir_fc);
}
}
-static void append_float_field_class(struct ctx *ctx, struct fs_sink_ctf_field_class_float *fc)
+static void append_float_field_class(ctf::sink::CtfIrToTsdlCtx *ctx,
+ struct fs_sink_ctf_field_class_float *fc)
{
unsigned int mant_dig, exp_dig;
mant_dig, exp_dig, fc->base.base.alignment);
}
-static void append_string_field_class(struct ctx *ctx)
+static void append_string_field_class(ctf::sink::CtfIrToTsdlCtx *ctx)
{
g_string_append(ctx->tsdl, "string { encoding = UTF8; }");
}
-static void append_field_class(struct ctx *ctx, struct fs_sink_ctf_field_class *fc);
+static void append_field_class(ctf::sink::CtfIrToTsdlCtx *ctx, struct fs_sink_ctf_field_class *fc);
-static void append_member(struct ctx *ctx, const char *name, struct fs_sink_ctf_field_class *fc)
+static void append_member(ctf::sink::CtfIrToTsdlCtx *ctx, const char *name,
+ struct fs_sink_ctf_field_class *fc)
{
GString *lengths = NULL;
const char *lengths_str = "";
}
}
-static void append_struct_field_class_members(struct ctx *ctx,
+static void append_struct_field_class_members(ctf::sink::CtfIrToTsdlCtx *ctx,
struct fs_sink_ctf_field_class_struct *struct_fc)
{
uint64_t i;
}
}
-static void append_struct_field_class(struct ctx *ctx, struct fs_sink_ctf_field_class_struct *fc)
+static void append_struct_field_class(ctf::sink::CtfIrToTsdlCtx *ctx,
+ struct fs_sink_ctf_field_class_struct *fc)
{
g_string_append(ctx->tsdl, "struct {\n");
ctx->indent_level++;
g_string_append_printf(ctx->tsdl, " align(%u)", fc->base.alignment);
}
-static void append_option_field_class(struct ctx *ctx,
+static void append_option_field_class(ctf::sink::CtfIrToTsdlCtx *ctx,
struct fs_sink_ctf_field_class_option *opt_fc)
{
g_string_append_printf(ctx->tsdl, "variant <%s> {\n", opt_fc->tag_ref->str);
append_end_block(ctx);
}
-static void append_variant_field_class(struct ctx *ctx,
+static void append_variant_field_class(ctf::sink::CtfIrToTsdlCtx *ctx,
struct fs_sink_ctf_field_class_variant *var_fc)
{
uint64_t i;
append_end_block(ctx);
}
-static void append_field_class(struct ctx *ctx, struct fs_sink_ctf_field_class *fc)
+static void append_field_class(ctf::sink::CtfIrToTsdlCtx *ctx, struct fs_sink_ctf_field_class *fc)
{
switch (fc->type) {
case FS_SINK_CTF_FIELD_CLASS_TYPE_BOOL:
}
}
-static void append_event_class(struct ctx *ctx, struct fs_sink_ctf_event_class *ec)
+static void append_event_class(ctf::sink::CtfIrToTsdlCtx *ctx, struct fs_sink_ctf_event_class *ec)
{
const char *str;
bt_event_class_log_level log_level;
append_end_block_semi_nl_nl(ctx);
}
-static void append_stream_class(struct ctx *ctx, struct fs_sink_ctf_stream_class *sc)
+static void append_stream_class(ctf::sink::CtfIrToTsdlCtx *ctx, struct fs_sink_ctf_stream_class *sc)
{
uint64_t i;
void translate_trace_ctf_ir_to_tsdl(struct fs_sink_ctf_trace *trace, GString *tsdl)
{
- struct ctx ctx = {
+ ctf::sink::CtfIrToTsdlCtx ctx = {
.indent_level = 0,
.tsdl = tsdl,
};
struct fs_sink_ctf_field_class *parent_fc;
};
-struct ctx
+namespace ctf {
+namespace sink {
+
+struct TraceIrToCtfIrCtx
{
bt_logging_level log_level;
bt_self_component *self_comp;
GArray *cur_path;
};
-static inline struct field_path_elem *cur_path_stack_at(struct ctx *ctx, uint64_t i)
+} /* namespace sink */
+} /* namespace ctf */
+
+static inline struct field_path_elem *cur_path_stack_at(ctf::sink::TraceIrToCtfIrCtx *ctx,
+ uint64_t i)
{
BT_ASSERT(i < ctx->cur_path->len);
return &bt_g_array_index(ctx->cur_path, struct field_path_elem, i);
}
-static inline struct field_path_elem *cur_path_stack_top(struct ctx *ctx)
+static inline struct field_path_elem *cur_path_stack_top(ctf::sink::TraceIrToCtfIrCtx *ctx)
{
BT_ASSERT(ctx->cur_path->len > 0);
return cur_path_stack_at(ctx, ctx->cur_path->len - 1);
return must_protect;
}
-static inline int cur_path_stack_push(struct ctx *ctx, const char *name, bool force_protect_name,
- const bt_field_class *ir_fc,
+static inline int cur_path_stack_push(ctf::sink::TraceIrToCtfIrCtx *ctx, const char *name,
+ bool force_protect_name, const bt_field_class *ir_fc,
struct fs_sink_ctf_field_class *parent_fc)
{
int ret = 0;
return ret;
}
-static inline void cur_path_stack_pop(struct ctx *ctx)
+static inline void cur_path_stack_pop(ctf::sink::TraceIrToCtfIrCtx *ctx)
{
struct field_path_elem *field_path_elem;
*
* Returns a negative value if this resolving operation failed.
*/
-static int create_relative_field_ref(struct ctx *ctx, const bt_field_path *tgt_ir_field_path,
- GString *tgt_field_ref,
+static int create_relative_field_ref(ctf::sink::TraceIrToCtfIrCtx *ctx,
+ const bt_field_path *tgt_ir_field_path, GString *tgt_field_ref,
struct fs_sink_ctf_field_class **user_tgt_fc)
{
int ret = 0;
*
* Returns a negative value if this resolving operation failed.
*/
-static int create_absolute_field_ref(struct ctx *ctx, const bt_field_path *tgt_ir_field_path,
- GString *tgt_field_ref,
+static int create_absolute_field_ref(ctf::sink::TraceIrToCtfIrCtx *ctx,
+ const bt_field_path *tgt_ir_field_path, GString *tgt_field_ref,
struct fs_sink_ctf_field_class **user_tgt_fc)
{
int ret = 0;
* created immediately before (in which case `tgt_field_ref` is
* irrelevant).
*/
-static void resolve_field_class(struct ctx *ctx, const bt_field_path *tgt_ir_field_path,
- GString *tgt_field_ref, bool *create_before,
- struct fs_sink_ctf_field_class **user_tgt_fc)
+static void resolve_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx,
+ const bt_field_path *tgt_ir_field_path, GString *tgt_field_ref,
+ bool *create_before, struct fs_sink_ctf_field_class **user_tgt_fc)
{
int ret;
bt_field_path_scope tgt_scope;
return;
}
-static int translate_field_class(struct ctx *ctx);
+static int translate_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx);
-static inline void append_to_parent_field_class(struct ctx *ctx, struct fs_sink_ctf_field_class *fc)
+static inline void append_to_parent_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx,
+ struct fs_sink_ctf_field_class *fc)
{
struct fs_sink_ctf_field_class *parent_fc = cur_path_stack_top(ctx)->parent_fc;
}
}
-static inline void update_parent_field_class_alignment(struct ctx *ctx, unsigned int alignment)
+static inline void update_parent_field_class_alignment(ctf::sink::TraceIrToCtfIrCtx *ctx,
+ unsigned int alignment)
{
struct fs_sink_ctf_field_class *parent_fc = cur_path_stack_top(ctx)->parent_fc;
}
}
-static inline int translate_structure_field_class_members(
- struct ctx *ctx, struct fs_sink_ctf_field_class_struct *struct_fc, const bt_field_class *ir_fc)
+static inline int
+translate_structure_field_class_members(ctf::sink::TraceIrToCtfIrCtx *ctx,
+ struct fs_sink_ctf_field_class_struct *struct_fc,
+ const bt_field_class *ir_fc)
{
int ret = 0;
uint64_t i;
return ret;
}
-static inline int translate_structure_field_class(struct ctx *ctx)
+static inline int translate_structure_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
{
int ret;
struct fs_sink_ctf_field_class_struct *fc =
return ret;
}
-static inline int translate_option_field_class(struct ctx *ctx)
+static inline int translate_option_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
{
struct fs_sink_ctf_field_class_option *fc =
fs_sink_ctf_field_class_option_create_empty(cur_path_stack_top(ctx)->ir_fc);
return ret;
}
-static inline int translate_variant_field_class(struct ctx *ctx)
+static inline int translate_variant_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
{
int ret = 0;
uint64_t i;
return ret;
}
-static inline int translate_static_array_field_class(struct ctx *ctx)
+static inline int translate_static_array_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
{
struct fs_sink_ctf_field_class_array *fc =
fs_sink_ctf_field_class_array_create_empty(cur_path_stack_top(ctx)->ir_fc);
return ret;
}
-static inline int translate_dynamic_array_field_class(struct ctx *ctx)
+static inline int translate_dynamic_array_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
{
struct fs_sink_ctf_field_class_sequence *fc =
fs_sink_ctf_field_class_sequence_create_empty(cur_path_stack_top(ctx)->ir_fc);
return ret;
}
-static inline int translate_bool_field_class(struct ctx *ctx)
+static inline int translate_bool_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
{
struct fs_sink_ctf_field_class_bool *fc =
fs_sink_ctf_field_class_bool_create(cur_path_stack_top(ctx)->ir_fc);
return 0;
}
-static inline int translate_bit_array_field_class(struct ctx *ctx)
+static inline int translate_bit_array_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
{
struct fs_sink_ctf_field_class_bit_array *fc =
fs_sink_ctf_field_class_bit_array_create(cur_path_stack_top(ctx)->ir_fc);
return 0;
}
-static inline int translate_integer_field_class(struct ctx *ctx)
+static inline int translate_integer_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
{
struct fs_sink_ctf_field_class_int *fc =
fs_sink_ctf_field_class_int_create(cur_path_stack_top(ctx)->ir_fc);
return 0;
}
-static inline int translate_real_field_class(struct ctx *ctx)
+static inline int translate_real_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
{
struct fs_sink_ctf_field_class_float *fc =
fs_sink_ctf_field_class_float_create(cur_path_stack_top(ctx)->ir_fc);
return 0;
}
-static inline int translate_string_field_class(struct ctx *ctx)
+static inline int translate_string_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
{
struct fs_sink_ctf_field_class_string *fc =
fs_sink_ctf_field_class_string_create(cur_path_stack_top(ctx)->ir_fc);
* within its parent are in the context's current path's top element
* (cur_path_stack_top()).
*/
-static int translate_field_class(struct ctx *ctx)
+static int translate_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx)
{
int ret;
bt_field_class_type ir_fc_type = bt_field_class_get_type(cur_path_stack_top(ctx)->ir_fc);
* class and then calls translate_structure_field_class_members() to
* fill it.
*/
-static int translate_scope_field_class(struct ctx *ctx, bt_field_path_scope scope,
+static int translate_scope_field_class(ctf::sink::TraceIrToCtfIrCtx *ctx, bt_field_path_scope scope,
struct fs_sink_ctf_field_class **fc,
const bt_field_class *ir_fc)
{
return ret;
}
-static inline void ctx_init(struct ctx *ctx, struct fs_sink_comp *fs_sink)
+static inline void ctx_init(ctf::sink::TraceIrToCtfIrCtx *ctx, struct fs_sink_comp *fs_sink)
{
- memset(ctx, 0, sizeof(struct ctx));
+ memset(ctx, 0, sizeof(*ctx));
ctx->cur_path = g_array_new(FALSE, TRUE, sizeof(struct field_path_elem));
BT_ASSERT(ctx->cur_path);
ctx->log_level = fs_sink->log_level;
ctx->self_comp = fs_sink->self_comp;
}
-static inline void ctx_fini(struct ctx *ctx)
+static inline void ctx_fini(ctf::sink::TraceIrToCtfIrCtx *ctx)
{
if (ctx->cur_path) {
g_array_free(ctx->cur_path, TRUE);
struct fs_sink_ctf_event_class **out_ec)
{
int ret = 0;
- struct ctx ctx;
+ ctf::sink::TraceIrToCtfIrCtx ctx;
struct fs_sink_ctf_event_class *ec;
BT_ASSERT(sc);
struct fs_sink_ctf_stream_class **out_sc)
{
int ret = 0;
- struct ctx ctx;
+ ctf::sink::TraceIrToCtfIrCtx ctx;
BT_ASSERT(trace);
BT_ASSERT(ir_sc);