barectf.c.j2: packet closing function: do not repeat member names
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 3 Sep 2020 14:25:56 +0000 (10:25 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 3 Sep 2020 14:25:56 +0000 (10:25 -0400)
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
barectf/templates/c/barectf.c.j2

index e27230e278056b16d8eb9be719100faef784827e..1cfc436e01ac1a93a310a8df009bc6f49ec56fa0 100644 (file)
@@ -326,8 +326,9 @@ void _commit_ev(void *vctx)
 
        /* save content size */
        ctx->content_size = ctx->at;
-       {% if 'timestamp_end' in stream_type._pkt_ctx_ft.members %}
-               {% set op = stream_op_pkt_ctx_op(stream_type, 'timestamp_end') %}
+       {% set name = 'timestamp_end' %}
+       {% if name in stream_type._pkt_ctx_ft.members %}
+               {% set op = stream_op_pkt_ctx_op(stream_type, name) %}
 
        /* go back to `timestamp_end` field offset */
        ctx->at = sctx->off_{{ c_common.op_src(op) }};
@@ -338,25 +339,27 @@ void _commit_ev(void *vctx)
 
                {% endfilter %}
        {% endif %}
-       {% if 'content_size' in stream_type._pkt_ctx_ft.members %}
-               {% set op = stream_op_pkt_ctx_op(stream_type, 'content_size') %}
+       {% set name = 'content_size' %}
+       {% if name in stream_type._pkt_ctx_ft.members %}
+               {% set op = stream_op_pkt_ctx_op(stream_type, name) %}
 
        /* go back to `content_size` field offset */
        ctx->at = sctx->off_{{ c_common.op_src(op) }};
 
-               {% set src = 'ctx->content_size' %}
+               {% set src %}ctx->{{ name }}{% endset %}
                {% filter indent_tab(indent_first=True) %}
                        {% include 'c/serialize-write-saved-int-statements.j2' %}
 
                {% endfilter %}
        {% endif %}
-       {% if 'events_discarded' in stream_type._pkt_ctx_ft.members %}
-               {% set op = stream_op_pkt_ctx_op(stream_type, 'events_discarded') %}
+       {% set name = 'events_discarded' %}
+       {% if name in stream_type._pkt_ctx_ft.members %}
+               {% set op = stream_op_pkt_ctx_op(stream_type, name) %}
 
        /* go back to `events_discarded` field offset */
        ctx->at = sctx->off_{{ c_common.op_src(op) }};
 
-               {% set src = 'ctx->events_discarded' %}
+               {% set src %}ctx->{{ name }}{% endset %}
                {% filter indent_tab(indent_first=True) %}
                        {% include 'c/serialize-write-saved-int-statements.j2' %}
 
This page took 0.024227 seconds and 4 git commands to generate.