_CCodeGenerator.generate_header(): use Jinja 2 templates
[deliverable/barectf.git] / barectf / templates / c-common.j2
1 {#
2 # Common variables and macros (for C templates).
3 #}
4
5 {% import 'common.j2' as common %}
6
7 {#
8 # Generates the name of a tracing function for the stream type
9 # `stream_type` and the event type `ev_type`.
10 #}
11 {% macro trace_func_name(stream_type, ev_type) -%}
12 {{ common.prefix }}{{ stream_type.name }}_trace_{{ ev_type.name }}
13 {%- endmacro %}
14
15 {#
16 # Generates the name of a single function parameter named `name` for
17 # the field type `ft`.
18 #}
19 {% macro func_param(name, ft) -%}
20 {{ ft | ft_c_type }} {{ name }}
21 {%- endmacro %}
22
23 {#
24 # Generates a list of parameters for the members of a given structure
25 # field type `struct_ft`.
26 #
27 # Each parameter has the prefix `name_prefix` and starts with an
28 # immediate comma followed with a newline and a tab. For example:
29 #
30 # ,
31 # const char * msg,
32 # uint32_t msg_id
33 #
34 # This macro does not generate a parameter line for a member name which
35 # is part of `exclude_list`.
36 #}
37 {% macro func_params(struct_ft, name_prefix, exclude_list) -%}
38 {% for name, member in struct_ft.members.items() if name not in exclude_list -%}
39 ,
40 {{ func_param(name_prefix + name, member.field_type) }}
41 {%- endfor %}
42 {%- endmacro %}
This page took 0.055332 seconds and 4 git commands to generate.