Commit | Line | Data |
---|---|---|
fdbf8740 PP |
1 | {# |
2 | # The MIT License (MIT) | |
3 | # | |
4 | # Copyright (c) 2020 Philippe Proulx <pproulx@efficios.com> | |
5 | # | |
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: | |
13 | # | |
14 | # The above copyright notice and this permission notice shall be | |
15 | # included in all copies or substantial portions of the Software. | |
16 | # | |
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. | |
24 | #} | |
25 | ||
d6483c83 PP |
26 | {% import 'common.j2' as common %} |
27 | ||
28 | {% set prefix = common.prefix %} | |
29 | {% set ucprefix = common.ucprefix %} | |
30 | {% set cg_opts = cfg.options.code_generation_options %} | |
31 | ||
32 | {# | |
33 | # Generates the preamble of the packet opening/closing functions for | |
34 | # the stream type `stream_type`. | |
35 | #} | |
36 | {% macro open_close_func_preamble(stream_type) %} | |
e18cf9d6 | 37 | struct {{ prefix }}ctx * const ctx = &sctx->parent; |
d6483c83 PP |
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); | |
42 | {% endif %} | |
43 | const int saved_in_tracing_section = ctx->in_tracing_section; | |
44 | {%- endmacro %} | |
45 | ||
46 | {# | |
47 | # Generates a list of function call parameters for the members of | |
48 | # the structure field type `ft`. | |
49 | # | |
50 | # Each parameter has the prefix `param_prefix`. | |
51 | # | |
52 | # The list always starts with a comma (if there's at least one member). | |
53 | # | |
54 | # Example: | |
55 | # | |
1c650e47 | 56 | # , ecc_peer_id, ecc_addr, p_msg_id, p_msg |
d6483c83 PP |
57 | #} |
58 | {% macro ft_call_params(param_prefix, ft) %} | |
59 | {% if ft %} | |
60 | {% for member_name in ft.members %} | |
61 | , {{ param_prefix }}_{{ member_name }} | |
62 | {%- endfor %} | |
63 | {% endif %} | |
64 | {% endmacro %} |