blob: e3addbc95e4a35fcb9d87d2714e71187eb07711c [file] [log] [blame]
Matthew Barth702c4a52018-02-28 16:23:11 -06001<%!
2def indent(str, depth):
3 return ''.join(4*' '*depth+line for line in str.splitlines(True))
4%>\
5
Matthew Barthcd3bfbc2018-03-07 16:26:03 -06006<%def name="genParams(par)" buffered="True">
7%if ('type' in par['hparams']) and \
8 (par['hparams']['type'] is not None):
9handler::${par['handler']}<${par['hparams']['type']}>(
10%else:
11handler::${par['handler']}(
12%endif
13%for i, hpk in enumerate(par['hparams']['params']):
Matthew Barth926df662018-10-09 09:51:12 -050014%if (i+1) != len(par['hparams']['params']):
15${par['hparams'][hpk]},
16%else:
17${par['hparams'][hpk]}
18%endif
Matthew Barthcd3bfbc2018-03-07 16:26:03 -060019%endfor
20)
21</%def>\
22
Matthew Barth926df662018-10-09 09:51:12 -050023<%def name="genSignal(sig)" buffered="True">
Matthew Barth702c4a52018-02-28 16:23:11 -060024%if ('type' in sig['sparams']) and \
25 (sig['sparams']['type'] is not None):
Matthew Barth926df662018-10-09 09:51:12 -050026${indent(sig['signal'], 3)}<${sig['sparams']['type']}>(\
Matthew Barth702c4a52018-02-28 16:23:11 -060027%else:
Matthew Barth926df662018-10-09 09:51:12 -050028${indent(sig['signal'], 3)}(\
Matthew Barth702c4a52018-02-28 16:23:11 -060029%endif
30%for spk in sig['sparams']['params']:
Matthew Barth926df662018-10-09 09:51:12 -050031${indent(sig['sparams'][spk], 3)},
Matthew Barth702c4a52018-02-28 16:23:11 -060032%endfor
Matthew Barth926df662018-10-09 09:51:12 -050033${genParams(par=sig)}
34)
35</%def>\
36
37<%def name="genMethod(meth)" buffered="True">
38%if ('type' in meth['mparams']) and \
39 (meth['mparams']['type'] is not None):
40${meth['method']}<${meth['mparams']['type']}>(
41%else:
42${meth['method']}(
43%endif
44%for spk in meth['mparams']['params']:
45${meth['mparams'][spk]},
46%endfor
47${genParams(par=meth)}\
Matthew Barthcd3bfbc2018-03-07 16:26:03 -060048)
Matthew Barth702c4a52018-02-28 16:23:11 -060049</%def>\
50
51<%def name="genSSE(event)" buffered="True">
Matthew Barth06fa7812018-11-20 09:54:30 -060052Group
53{
Matthew Barth702c4a52018-02-28 16:23:11 -060054%for group in event['groups']:
55%for member in group['members']:
Matthew Barth06fa7812018-11-20 09:54:30 -060056 {"${member['object']}",
Matthew Barth146b7392018-03-08 16:17:58 -060057 "${member['interface']}",
Matthew Barth06fa7812018-11-20 09:54:30 -060058 "${member['property']}"},
Matthew Barth702c4a52018-02-28 16:23:11 -060059%endfor
60%endfor
61},
Matthew Barth06fa7812018-11-20 09:54:30 -060062ActionData{
63%for e in event['action']:
64{Group{
65%for g in e['groups']:
66%for m in g['members']:
67 {"${m['object']}",
68 "${m['interface']}",
69 "${m['property']}"},
70%endfor
71%endfor
72},
Matthew Barth702c4a52018-02-28 16:23:11 -060073std::vector<Action>{
Matthew Barth06fa7812018-11-20 09:54:30 -060074%for a in e['actions']:
Matthew Barth8a697b62018-12-14 13:23:47 -060075%if len(a['parameters']) != 0:
Matthew Barth702c4a52018-02-28 16:23:11 -060076make_action(action::${a['name']}(
Matthew Barth8a697b62018-12-14 13:23:47 -060077%else:
78make_action(action::${a['name']}
79%endif
Matthew Barth702c4a52018-02-28 16:23:11 -060080%for i, p in enumerate(a['parameters']):
81%if (i+1) != len(a['parameters']):
82 ${p},
83%else:
Matthew Barth06fa7812018-11-20 09:54:30 -060084 ${p}
Matthew Barth702c4a52018-02-28 16:23:11 -060085%endif
86%endfor
Matthew Barth8a697b62018-12-14 13:23:47 -060087%if len(a['parameters']) != 0:
Matthew Barth06fa7812018-11-20 09:54:30 -060088)),
Matthew Barth8a697b62018-12-14 13:23:47 -060089%else:
90),
91%endif
Matthew Barth702c4a52018-02-28 16:23:11 -060092%endfor
Matthew Barth75d97352018-11-01 10:34:49 -050093}},
Matthew Barth06fa7812018-11-20 09:54:30 -060094%endfor
95},
Matthew Barth1b4de262018-03-06 13:03:16 -060096std::vector<Trigger>{
Matthew Barthd0b90fc2018-03-05 09:38:45 -060097 %if ('timer' in event['triggers']) and \
98 (event['triggers']['timer'] is not None):
Matthew Barth1b4de262018-03-06 13:03:16 -060099 make_trigger(trigger::timer(TimerConf{
Matthew Barthd0b90fc2018-03-05 09:38:45 -0600100 ${event['triggers']['timer']['interval']},
101 ${event['triggers']['timer']['type']}
Matthew Barth016bd242018-03-07 16:06:06 -0600102 })),
Matthew Barthd0b90fc2018-03-05 09:38:45 -0600103 %endif
Matthew Barth016bd242018-03-07 16:06:06 -0600104 %if ('signals' in event['triggers']) and \
105 (event['triggers']['signals'] is not None):
106 %for s in event['triggers']['signals']:
107 make_trigger(trigger::signal(
Matthew Barth18c91032019-01-29 15:36:00 -0600108 %if ('match' in s) and \
109 (s['match'] is not None):
Matthew Barth702c4a52018-02-28 16:23:11 -0600110 match::${s['match']}(
Matthew Barth926df662018-10-09 09:51:12 -0500111 %for i, mp in enumerate(s['mparams']['params']):
112 %if (i+1) != len(s['mparams']['params']):
113 ${indent(s['mparams'][mp], 1)},
Matthew Barth702c4a52018-02-28 16:23:11 -0600114 %else:
Matthew Barth926df662018-10-09 09:51:12 -0500115 ${indent(s['mparams'][mp], 1)}
Matthew Barth702c4a52018-02-28 16:23:11 -0600116 %endif
117 %endfor
118 ),
Matthew Barth18c91032019-01-29 15:36:00 -0600119 %else:
120 "",
121 %endif
Matthew Barth926df662018-10-09 09:51:12 -0500122 make_handler<SignalHandler>(\
123 ${genSignal(sig=s)}
Matthew Barth702c4a52018-02-28 16:23:11 -0600124 )
Matthew Barth016bd242018-03-07 16:06:06 -0600125 )),
126 %endfor
127 %endif
Matthew Barthcd3bfbc2018-03-07 16:26:03 -0600128 %if ('init' in event['triggers']):
129 %for i in event['triggers']['init']:
130 make_trigger(trigger::init(
Matthew Barth926df662018-10-09 09:51:12 -0500131 %if ('method' in i):
132 make_handler<MethodHandler>(\
133 ${indent(genMethod(meth=i), 3)}\
Matthew Barthcd3bfbc2018-03-07 16:26:03 -0600134 )
135 %endif
136 )),
137 %endfor
138 %endif
Matthew Barth016bd242018-03-07 16:06:06 -0600139},
Matthew Barth702c4a52018-02-28 16:23:11 -0600140</%def>\