2 # The MIT License (MIT)
4 # Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com>
6 # Permission is hereby granted, free of charge, to any person obtaining
7 # a copy of this software and associated documentation files (the
8 # "Software"), to deal in the Software without restriction, including
9 # without limitation the rights to use, copy, modify, merge, publish,
10 # distribute, sublicense, and/or sell copies of the Software, and to
11 # permit persons to whom the Software is furnished to do so, subject to
12 # the following conditions:
14 # The above copyright notice and this permission notice shall be
15 # included in all copies or substantial portions of the Software.
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 {% import 'common.j2' as common %}
28 {% set prefix = common.prefix %}
29 {% set ucprefix = common.ucprefix %}
30 {% set cg_opts = cfg.options.code_generation_options %}
33 # Generates the preamble of the packet opening/closing functions for
34 # the stream type `stream_type`.
36 {% macro open_close_func_preamble(stream_type) %}
37 struct {{ prefix }}ctx *ctx = &sctx->parent;
38 {% if stream_type.default_clock_type %}
39 const {{ cg_opts.clock_type_c_types[stream_type.default_clock_type] }} ts = ctx->use_cur_last_event_ts ?
40 sctx->cur_last_event_ts :
41 ctx->cbs.{{ stream_type.default_clock_type.name }}_clock_get_value(ctx->data);
43 const int saved_in_tracing_section = ctx->in_tracing_section;
47 # Generates a list of function call parameters for the members of
48 # the structure field type `ft`.
50 # Each parameter has the prefix `param_prefix`.
52 # The list always starts with a comma (if there's at least one member).
56 # , sec_peer_id, sec_addr, ep_msg_id, ep_msg
58 {% macro ft_call_params(param_prefix, ft) %}
60 {% for member_name in ft.members %}
61 , {{ param_prefix }}_{{ member_name }}