gen.py, templates: use root FT prefixes which match their name
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 3 Sep 2020 14:36:45 +0000 (10:36 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 3 Sep 2020 14:36:45 +0000 (10:36 -0400)
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 <eeppeliteloop@gmail.com>
barectf/gen.py
barectf/templates/c/barectf.c-macros.j2
barectf/templates/c/barectf.c.j2
barectf/templates/c/barectf.h.j2
barectf/templates/c/common.j2

index 2fbc00881970bba48aedfd3ff3db0d869d48d595..ae36036207ce70e95ceb58cdea94cb1fd6a6af23 100644 (file)
@@ -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)
index 5ae2501bee132d1cdf1652d1102af8f28ed7c3b0..b890faa1293a63be3e73f49d4279e62c5e0332ed 100644 (file)
@@ -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 %}
index 1cfc436e01ac1a93a310a8df009bc6f49ec56fa0..5aa76597650e910b26ac6be3c9fd1e774118ede7 100644 (file)
@@ -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 }});
 
index 6513e2700d479b28938e9e6c702d6a876e6848c2..6c75a131c3803236f821548da172edc84b0dbf55 100644 (file)
@@ -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;
index f1d7788daab037c55a050a22226cc845fffc79d3..6715a78b6d142f2f78352c3c88ee99b6911e9276 100644 (file)
@@ -50,7 +50,7 @@
  #
  # Example:
  #
- #     ep_msg_id
+ #     p_msg_id
  #}
 {% macro op_src(op) %}
 {{ op.names | join('_') }}
This page took 0.028743 seconds and 4 git commands to generate.