forked from google/cyanobyte
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneric.jinja2
47 lines (44 loc) · 1.36 KB
/
generic.jinja2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
{% macro doRecursion(functions, compute, rw) %}
{% for step in compute.logic %}
{% for key in step.keys() %}
{% if step[key] is string and step[key][:12] == '#/functions/' %}
{{ recursiveReadWrite(functions, step[key][12:], rw) }}
{% endif %}
{% if step[key] is string and step[key][:12] == '#/registers/' and rw == 'r' %}
True
{% endif %}
{% if key == '$cmdWrite' and rw == 'w' %}
True
{% endif %}
{% if key == 'send' and rw == 'w' %}
True
{% endif %}
{% endfor %}
{% endfor %}
{% endmacro %}
{% macro recursiveReadWrite(functions, name, rw) %}
{% set split = name.split('/') %}
{% set fname = split[0] %}
{% set cname = split[1] %}
{% set compute = functions[fname].computed[cname] %}
{{ doRecursion(functions, compute, rw) }}
{% endmacro %}
{% macro functionParams(cpp, functions, compute, isCallback) %}
{% set doread = doRecursion(functions, compute, 'r') %}
{% set dowrite = doRecursion(functions, compute, 'w') %}
{% if 'return' in compute and isCallback == false %}
{% set int_t = cpp.returnType(compute) %}
{{int_t}}* val,
{% endif %}
{% if 'input' in compute %}
{{cpp.params(compute)}}{% if 'True' in dowrite %},
{% endif %}
{% endif %}
{% if 'True' in doread %}
int (*read)(uint8_t, uint8_t, int*, uint8_t){% if 'True' in dowrite %},
{% endif %}
{%- endif %}
{% if 'True' in dowrite %}
int (*write)(uint8_t, uint8_t, int*, uint8_t)
{%- endif %}
{%- endmacro %}