Standardize root field type prefixes
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 23 Sep 2020 14:51:05 +0000 (10:51 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 23 Sep 2020 14:51:05 +0000 (10:51 -0400)
This patch changes `cgen.py` and what depends on it so that:

* `_RootFtPrefixes` attribute names always begin with `P` (packet) or
  `ER` (event record).

* `_RootFtPrefixes` attribute values for event record prefixes do not
  begin with `er`.

  The C source context where this is used indicates that it's an event
  record field, so `er` is redundant.

  This also makes the documentation easier to understand.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
barectf/cgen.py
barectf/templates/c/barectf.c-macros.j2
barectf/templates/c/barectf.c.j2

index d6f6e0bdd9241c5feb03e05e8162b2fbad3b98b8..b4ec1c233599b08b605add8e320176039c21bc59 100644 (file)
@@ -401,20 +401,20 @@ class _DsOps:
 class _RootFtPrefixes:
     PH = 'ph'
     PC = 'pc'
-    ERH = 'erh'
-    ERCC = 'ercc'
-    SC = 'sc'
-    P = 'p'
+    ERH = 'h'
+    ERCC = 'cc'
+    ERSC = 'sc'
+    ERP = 'p'
 
 
 # The human-readable names of the `_RootFtPrefixes` members.
 _ROOT_FT_PREFIX_NAMES = {
     _RootFtPrefixes.PH: 'packet header',
     _RootFtPrefixes.PC: 'packet context',
-    _RootFtPrefixes.ERH: 'event record header',
-    _RootFtPrefixes.ERCC: 'event record common context',
-    _RootFtPrefixes.SC: 'specific context',
-    _RootFtPrefixes.P: 'payload',
+    _RootFtPrefixes.ERH: 'header',
+    _RootFtPrefixes.ERCC: 'common context',
+    _RootFtPrefixes.ERSC: 'specific context',
+    _RootFtPrefixes.ERP: 'payload',
 }
 
 
@@ -671,11 +671,11 @@ class _CodeGen:
 
         if ert.specific_context_field_type is not None:
             parts.append(self._proto_params_str(ert.specific_context_field_type,
-                                                _RootFtPrefixes.SC, const_params,
+                                                _RootFtPrefixes.ERSC, const_params,
                                                 only_dyn=only_dyn))
 
         if ert.payload_field_type is not None:
-            parts.append(self._proto_params_str(ert.payload_field_type, _RootFtPrefixes.P,
+            parts.append(self._proto_params_str(ert.payload_field_type, _RootFtPrefixes.ERP,
                                                 const_params, only_dyn=only_dyn))
 
         return ''.join(parts)
@@ -759,14 +759,14 @@ class _CodeGen:
 
                     if ert.specific_context_field_type is not None:
                         spec_ctx_op = ev_builder.build_for_root_ft(ert.specific_context_field_type,
-                                                                   _RootFtPrefixes.SC)
+                                                                   _RootFtPrefixes.ERSC)
 
                     # payload operation
                     payload_op = None
 
                     if ert.payload_field_type is not None:
                         payload_op = ev_builder.build_for_root_ft(ert.payload_field_type,
-                                                                  _RootFtPrefixes.P)
+                                                                  _RootFtPrefixes.ERP)
 
                     er_ops[ert] = _ErOps(spec_ctx_op, payload_op)
 
index 44e2d0e4429aaa952aaacce2f3088fea0ab55209..ee14024eefcd8945d9bc24bc712872ae4fc28bd4 100644 (file)
@@ -53,7 +53,7 @@ const int saved_in_tracing_section = ctx->in_tracing_section;
  #
  # Example:
  #
- #     , ercc_peer_id, ercc_addr, p_msg_id, p_msg
+ #     , cc_peer_id, sc_addr, p_msg_id, p_msg
  #}
 {% macro ft_call_params(param_prefix, ft, only_dyn=false) %}
 {% if ft %}
index 48af1687f2f9b8b1fdacedbe93199325468fb422..0948d83f52fe5bd7a37853c58bdfb97b5c447763 100644 (file)
@@ -479,8 +479,8 @@ static uint32_t _er_size_{{ dst.name }}_{{ ert.name }}(void * const vctx{{ (dst,
 
        /* Compute event record size */
                {% set er_common_ctx_params = macros.ft_call_params(root_ft_prefixes.ERCC, dst.event_record_common_context_field_type, true) %}
-               {% set spec_ctx_params = macros.ft_call_params(root_ft_prefixes.SC, ert.specific_context_field_type, true) %}
-               {% set payload_params = macros.ft_call_params(root_ft_prefixes.P, ert.payload_field_type, true) %}
+               {% set spec_ctx_params = macros.ft_call_params(root_ft_prefixes.ERSC, ert.specific_context_field_type, true) %}
+               {% set payload_params = macros.ft_call_params(root_ft_prefixes.ERP, ert.payload_field_type, true) %}
                {% set params %}{{ er_common_ctx_params }}{{ spec_ctx_params }}{{ payload_params }}{% endset %}
        er_size = _er_size_{{ dst.name }}_{{ ert.name }}(_TO_VOID_PTR(ctx){{ params }});
 
@@ -493,8 +493,8 @@ static uint32_t _er_size_{{ dst.name }}_{{ ert.name }}(void * const vctx{{ (dst,
 
        /* Serialize event record */
                {% set er_common_ctx_params = macros.ft_call_params(root_ft_prefixes.ERCC, dst.event_record_common_context_field_type) %}
-               {% set spec_ctx_params = macros.ft_call_params(root_ft_prefixes.SC, ert.specific_context_field_type) %}
-               {% set payload_params = macros.ft_call_params(root_ft_prefixes.P, ert.payload_field_type) %}
+               {% set spec_ctx_params = macros.ft_call_params(root_ft_prefixes.ERSC, ert.specific_context_field_type) %}
+               {% set payload_params = macros.ft_call_params(root_ft_prefixes.ERP, ert.payload_field_type) %}
                {% set params %}{{ er_common_ctx_params }}{{ spec_ctx_params }}{{ payload_params }}{% endset %}
        _serialize_er_{{ dst.name }}_{{ ert.name }}(_TO_VOID_PTR(ctx){{ params }});
 
This page took 0.027014 seconds and 4 git commands to generate.