From: Philippe Proulx Date: Thu, 3 Sep 2020 14:36:45 +0000 (-0400) Subject: gen.py, templates: use root FT prefixes which match their name X-Git-Url: http://git.efficios.com/?a=commitdiff_plain;h=1c650e47cbda193526bc56ed363cb870ac6cee47;p=deliverable%2Fbarectf.git gen.py, templates: use root FT prefixes which match their name The new prefixes match the new nerminology: `ph`: Packet header `pc`: Packet context `eh`: Event header `ecc`: Event common context `sc`: Specific context `p`: Payload Signed-off-by: Philippe Proulx --- diff --git a/barectf/gen.py b/barectf/gen.py index 2fbc008..ae36036 100644 --- a/barectf/gen.py +++ b/barectf/gen.py @@ -367,22 +367,22 @@ class _StreamOps: # The C variable name prefixes for the six kinds of root field types. class _RootFtPrefixes: - TPH = 'tph' - SPC = 'spc' - SEH = 'seh' - SEC = 'sec' - EC = 'ec' - EP = 'ep' + PH = 'ph' + PC = 'pc' + EH = 'eh' + ECC = 'ecc' + SC = 'sc' + P = 'p' # The human-readable names of the `_RootFtPrefixes` members. _ROOT_FT_PREFIX_NAMES = { - _RootFtPrefixes.TPH: 'packet header', - _RootFtPrefixes.SPC: 'packet context', - _RootFtPrefixes.SEH: 'event header', - _RootFtPrefixes.SEC: 'event common context', - _RootFtPrefixes.EC: 'specific context', - _RootFtPrefixes.EP: 'payload', + _RootFtPrefixes.PH: 'packet header', + _RootFtPrefixes.PC: 'packet context', + _RootFtPrefixes.EH: 'event header', + _RootFtPrefixes.ECC: 'event common context', + _RootFtPrefixes.SC: 'specific context', + _RootFtPrefixes.P: 'payload', } @@ -507,7 +507,7 @@ class _CCodeGenerator: # stream type `stream_type`. def _open_func_params_str(self, stream_type): parts = [] - parts.append(self._proto_params_str(self._trace_type._pkt_header_ft, _RootFtPrefixes.TPH, + parts.append(self._proto_params_str(self._trace_type._pkt_header_ft, _RootFtPrefixes.PH, {'magic', 'stream_id', 'uuid'})) exclude_set = { @@ -517,7 +517,7 @@ class _CCodeGenerator: 'content_size', 'events_discarded', } - parts.append(self._proto_params_str(stream_type._pkt_ctx_ft, _RootFtPrefixes.SPC, + parts.append(self._proto_params_str(stream_type._pkt_ctx_ft, _RootFtPrefixes.PC, exclude_set)) return ''.join(parts) @@ -529,19 +529,19 @@ class _CCodeGenerator: parts = [] if stream_type._ev_header_ft is not None: - parts.append(self._proto_params_str(stream_type._ev_header_ft, _RootFtPrefixes.SEH, + parts.append(self._proto_params_str(stream_type._ev_header_ft, _RootFtPrefixes.EH, {'id', 'timestamp'})) if stream_type.event_common_context_field_type is not None: parts.append(self._proto_params_str(stream_type.event_common_context_field_type, - _RootFtPrefixes.SEC)) + _RootFtPrefixes.ECC)) if ev_type.specific_context_field_type is not None: parts.append(self._proto_params_str(ev_type.specific_context_field_type, - _RootFtPrefixes.EC)) + _RootFtPrefixes.SC)) if ev_type.payload_field_type is not None: - parts.append(self._proto_params_str(ev_type.payload_field_type, _RootFtPrefixes.EP)) + parts.append(self._proto_params_str(ev_type.payload_field_type, _RootFtPrefixes.P)) return ''.join(parts) @@ -549,7 +549,7 @@ class _CCodeGenerator: # parameters for the stream type `stream_type`. def _serialize_ev_common_ctx_func_params_str(self, stream_type): return self._proto_params_str(stream_type.event_common_context_field_type, - _RootFtPrefixes.SEC); + _RootFtPrefixes.ECC); # Generates the bitfield header file contents. def generate_bitfield_header(self): @@ -578,7 +578,7 @@ class _CCodeGenerator: 'uuid': self._serialize_write_uuid_statements_templ, 'stream_id': self._serialize_write_stream_type_id_statements_templ, } - builder.append_root_ft(pkt_header_ft, _RootFtPrefixes.TPH, + builder.append_root_ft(pkt_header_ft, _RootFtPrefixes.PH, spec_serialize_write_templates) pkt_header_ser_ops = copy.copy(builder.ops) @@ -591,7 +591,7 @@ class _CCodeGenerator: 'events_discarded': self._serialize_write_skip_save_statements_templ, 'content_size': self._serialize_write_skip_save_statements_templ, } - builder.append_root_ft(stream_type._pkt_ctx_ft, _RootFtPrefixes.SPC, + builder.append_root_ft(stream_type._pkt_ctx_ft, _RootFtPrefixes.PC, spec_serialize_write_templates) pkt_ctx_ser_ops = copy.copy(builder.ops[first_op_index:]) @@ -604,7 +604,7 @@ class _CCodeGenerator: 'timestamp': self._serialize_write_time_statements_templ, 'id': self._serialize_write_ev_type_id_statements_templ, } - builder.append_root_ft(stream_type._ev_header_ft, _RootFtPrefixes.SEH, + builder.append_root_ft(stream_type._ev_header_ft, _RootFtPrefixes.EH, spec_serialize_write_templates) ev_header_ser_ops = copy.copy(builder.ops) @@ -614,7 +614,7 @@ class _CCodeGenerator: if stream_type.event_common_context_field_type is not None: first_op_index = len(builder.ops) builder.append_root_ft(stream_type.event_common_context_field_type, - _RootFtPrefixes.SEC) + _RootFtPrefixes.ECC) ev_common_ctx_ser_ops = copy.copy(builder.ops[first_op_index:]) # serialization operations specific to each event type @@ -629,7 +629,7 @@ class _CCodeGenerator: if ev_type.specific_context_field_type is not None: first_op_index = len(ev_builder.ops) ev_builder.append_root_ft(ev_type.specific_context_field_type, - _RootFtPrefixes.EC) + _RootFtPrefixes.SC) spec_ctx_ser_ops = copy.copy(ev_builder.ops[first_op_index:]) # payload serialization operations @@ -637,7 +637,7 @@ class _CCodeGenerator: if ev_type.payload_field_type is not None: first_op_index = len(ev_builder.ops) - ev_builder.append_root_ft(ev_type.payload_field_type, _RootFtPrefixes.EP) + ev_builder.append_root_ft(ev_type.payload_field_type, _RootFtPrefixes.P) payload_ser_ops = copy.copy(ev_builder.ops[first_op_index:]) ev_ser_ops[ev_type] = _EventOps(spec_ctx_ser_ops, payload_ser_ops) diff --git a/barectf/templates/c/barectf.c-macros.j2 b/barectf/templates/c/barectf.c-macros.j2 index 5ae2501..b890faa 100644 --- a/barectf/templates/c/barectf.c-macros.j2 +++ b/barectf/templates/c/barectf.c-macros.j2 @@ -53,7 +53,7 @@ const int saved_in_tracing_section = ctx->in_tracing_section; # # Example: # - # , sec_peer_id, sec_addr, ep_msg_id, ep_msg + # , ecc_peer_id, ecc_addr, p_msg_id, p_msg #} {% macro ft_call_params(param_prefix, ft) %} {% if ft %} diff --git a/barectf/templates/c/barectf.c.j2 b/barectf/templates/c/barectf.c.j2 index 1cfc436..5aa7659 100644 --- a/barectf/templates/c/barectf.c.j2 +++ b/barectf/templates/c/barectf.c.j2 @@ -424,7 +424,7 @@ static void _serialize_ev_{{ stream_type.name }}_{{ ev_type.name }}(void *vctx{{ {% if stream_type.event_common_context_field_type %} /* serialize common context */ - {% set params = macros.ft_call_params(root_ft_prefixes.SEC, stream_type.event_common_context_field_type) %} + {% set params = macros.ft_call_params(root_ft_prefixes.ECC, stream_type.event_common_context_field_type) %} _serialize_ev_common_ctx_{{ stream_type.name }}(ctx{{ params }}); {% endif %} {% set this_ev_ops = this_stream_ops.ev_ops[ev_type] %} @@ -525,9 +525,9 @@ static uint32_t _ev_size_{{ stream_type.name }}_{{ ev_type.name }}(void *vctx{{ ctx->in_tracing_section = 1; /* compute event size */ - {% set ev_common_ctx_params = macros.ft_call_params(root_ft_prefixes.SEC, stream_type.event_common_context_field_type) %} - {% set spec_ctx_params = macros.ft_call_params(root_ft_prefixes.EC, ev_type.specific_context_field_type) %} - {% set payload_params = macros.ft_call_params(root_ft_prefixes.EP, ev_type.payload_field_type) %} + {% set ev_common_ctx_params = macros.ft_call_params(root_ft_prefixes.ECC, stream_type.event_common_context_field_type) %} + {% set spec_ctx_params = macros.ft_call_params(root_ft_prefixes.SC, ev_type.specific_context_field_type) %} + {% set payload_params = macros.ft_call_params(root_ft_prefixes.P, ev_type.payload_field_type) %} {% set params %}{{ ev_common_ctx_params }}{{ spec_ctx_params }}{{ payload_params }}{% endset %} ev_size = _ev_size_{{ stream_type.name }}_{{ ev_type.name }}(_TO_VOID_PTR(ctx){{ params }}); diff --git a/barectf/templates/c/barectf.h.j2 b/barectf/templates/c/barectf.h.j2 index 6513e27..6c75a13 100644 --- a/barectf/templates/c/barectf.h.j2 +++ b/barectf/templates/c/barectf.h.j2 @@ -138,11 +138,11 @@ struct {{ prefix }}{{ stream_type.name }}_ctx { /* config-specific members follow */ {% if trace_type._pkt_header_ft %} {% for member_name in trace_type._pkt_header_ft.members %} - uint32_t off_tph_{{ member_name }}; + uint32_t off_ph_{{ member_name }}; {% endfor %} {% endif %} {% for member_name in stream_type._pkt_ctx_ft.members %} - uint32_t off_spc_{{ member_name }}; + uint32_t off_pc_{{ member_name }}; {% endfor %} {% if stream_type.default_clock_type %} {{ cg_opts.clock_type_c_types[stream_type.default_clock_type] }} cur_last_event_ts; diff --git a/barectf/templates/c/common.j2 b/barectf/templates/c/common.j2 index f1d7788..6715a78 100644 --- a/barectf/templates/c/common.j2 +++ b/barectf/templates/c/common.j2 @@ -50,7 +50,7 @@ # # Example: # - # ep_msg_id + # p_msg_id #} {% macro op_src(op) %} {{ op.names | join('_') }}