Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 1 | <%! |
| 2 | def indent(str, depth): |
| 3 | return ''.join(4*' '*depth+line for line in str.splitlines(True)) |
| 4 | %>\ |
| 5 | |
Matthew Barth | cd3bfbc | 2018-03-07 16:26:03 -0600 | [diff] [blame] | 6 | <%def name="genParams(par)" buffered="True"> |
| 7 | %if ('type' in par['hparams']) and \ |
| 8 | (par['hparams']['type'] is not None): |
| 9 | handler::${par['handler']}<${par['hparams']['type']}>( |
| 10 | %else: |
| 11 | handler::${par['handler']}( |
| 12 | %endif |
| 13 | %for i, hpk in enumerate(par['hparams']['params']): |
Matthew Barth | 926df66 | 2018-10-09 09:51:12 -0500 | [diff] [blame] | 14 | %if (i+1) != len(par['hparams']['params']): |
| 15 | ${par['hparams'][hpk]}, |
| 16 | %else: |
| 17 | ${par['hparams'][hpk]} |
| 18 | %endif |
Matthew Barth | cd3bfbc | 2018-03-07 16:26:03 -0600 | [diff] [blame] | 19 | %endfor |
| 20 | ) |
| 21 | </%def>\ |
| 22 | |
Matthew Barth | 926df66 | 2018-10-09 09:51:12 -0500 | [diff] [blame] | 23 | <%def name="genSignal(sig)" buffered="True"> |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 24 | %if ('type' in sig['sparams']) and \ |
| 25 | (sig['sparams']['type'] is not None): |
Matthew Barth | 926df66 | 2018-10-09 09:51:12 -0500 | [diff] [blame] | 26 | ${indent(sig['signal'], 3)}<${sig['sparams']['type']}>(\ |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 27 | %else: |
Matthew Barth | 926df66 | 2018-10-09 09:51:12 -0500 | [diff] [blame] | 28 | ${indent(sig['signal'], 3)}(\ |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 29 | %endif |
| 30 | %for spk in sig['sparams']['params']: |
Matthew Barth | 926df66 | 2018-10-09 09:51:12 -0500 | [diff] [blame] | 31 | ${indent(sig['sparams'][spk], 3)}, |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 32 | %endfor |
Matthew Barth | 926df66 | 2018-10-09 09:51:12 -0500 | [diff] [blame] | 33 | ${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 Barth | cd3bfbc | 2018-03-07 16:26:03 -0600 | [diff] [blame] | 48 | ) |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 49 | </%def>\ |
| 50 | |
| 51 | <%def name="genSSE(event)" buffered="True"> |
Matthew Barth | 06fa781 | 2018-11-20 09:54:30 -0600 | [diff] [blame] | 52 | Group |
| 53 | { |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 54 | %for group in event['groups']: |
| 55 | %for member in group['members']: |
Matthew Barth | 06fa781 | 2018-11-20 09:54:30 -0600 | [diff] [blame] | 56 | {"${member['object']}", |
Matthew Barth | 146b739 | 2018-03-08 16:17:58 -0600 | [diff] [blame] | 57 | "${member['interface']}", |
Matthew Barth | 06fa781 | 2018-11-20 09:54:30 -0600 | [diff] [blame] | 58 | "${member['property']}"}, |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 59 | %endfor |
| 60 | %endfor |
| 61 | }, |
Matthew Barth | 06fa781 | 2018-11-20 09:54:30 -0600 | [diff] [blame] | 62 | ActionData{ |
| 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 Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 73 | std::vector<Action>{ |
Matthew Barth | 06fa781 | 2018-11-20 09:54:30 -0600 | [diff] [blame] | 74 | %for a in e['actions']: |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 75 | make_action(action::${a['name']}( |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 76 | %for i, p in enumerate(a['parameters']): |
| 77 | %if (i+1) != len(a['parameters']): |
| 78 | ${p}, |
| 79 | %else: |
Matthew Barth | 06fa781 | 2018-11-20 09:54:30 -0600 | [diff] [blame] | 80 | ${p} |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 81 | %endif |
| 82 | %endfor |
Matthew Barth | 06fa781 | 2018-11-20 09:54:30 -0600 | [diff] [blame] | 83 | )), |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 84 | %endfor |
Matthew Barth | 75d9735 | 2018-11-01 10:34:49 -0500 | [diff] [blame] | 85 | }}, |
Matthew Barth | 06fa781 | 2018-11-20 09:54:30 -0600 | [diff] [blame] | 86 | %endfor |
| 87 | }, |
Matthew Barth | 1b4de26 | 2018-03-06 13:03:16 -0600 | [diff] [blame] | 88 | std::vector<Trigger>{ |
Matthew Barth | d0b90fc | 2018-03-05 09:38:45 -0600 | [diff] [blame] | 89 | %if ('timer' in event['triggers']) and \ |
| 90 | (event['triggers']['timer'] is not None): |
Matthew Barth | 1b4de26 | 2018-03-06 13:03:16 -0600 | [diff] [blame] | 91 | make_trigger(trigger::timer(TimerConf{ |
Matthew Barth | d0b90fc | 2018-03-05 09:38:45 -0600 | [diff] [blame] | 92 | ${event['triggers']['timer']['interval']}, |
| 93 | ${event['triggers']['timer']['type']} |
Matthew Barth | 016bd24 | 2018-03-07 16:06:06 -0600 | [diff] [blame] | 94 | })), |
Matthew Barth | d0b90fc | 2018-03-05 09:38:45 -0600 | [diff] [blame] | 95 | %endif |
Matthew Barth | 016bd24 | 2018-03-07 16:06:06 -0600 | [diff] [blame] | 96 | %if ('signals' in event['triggers']) and \ |
| 97 | (event['triggers']['signals'] is not None): |
| 98 | %for s in event['triggers']['signals']: |
| 99 | make_trigger(trigger::signal( |
Matthew Barth | 18c9103 | 2019-01-29 15:36:00 -0600 | [diff] [blame] | 100 | %if ('match' in s) and \ |
| 101 | (s['match'] is not None): |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 102 | match::${s['match']}( |
Matthew Barth | 926df66 | 2018-10-09 09:51:12 -0500 | [diff] [blame] | 103 | %for i, mp in enumerate(s['mparams']['params']): |
| 104 | %if (i+1) != len(s['mparams']['params']): |
| 105 | ${indent(s['mparams'][mp], 1)}, |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 106 | %else: |
Matthew Barth | 926df66 | 2018-10-09 09:51:12 -0500 | [diff] [blame] | 107 | ${indent(s['mparams'][mp], 1)} |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 108 | %endif |
| 109 | %endfor |
| 110 | ), |
Matthew Barth | 18c9103 | 2019-01-29 15:36:00 -0600 | [diff] [blame] | 111 | %else: |
| 112 | "", |
| 113 | %endif |
Matthew Barth | 926df66 | 2018-10-09 09:51:12 -0500 | [diff] [blame] | 114 | make_handler<SignalHandler>(\ |
| 115 | ${genSignal(sig=s)} |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 116 | ) |
Matthew Barth | 016bd24 | 2018-03-07 16:06:06 -0600 | [diff] [blame] | 117 | )), |
| 118 | %endfor |
| 119 | %endif |
Matthew Barth | cd3bfbc | 2018-03-07 16:26:03 -0600 | [diff] [blame] | 120 | %if ('init' in event['triggers']): |
| 121 | %for i in event['triggers']['init']: |
| 122 | make_trigger(trigger::init( |
Matthew Barth | 926df66 | 2018-10-09 09:51:12 -0500 | [diff] [blame] | 123 | %if ('method' in i): |
| 124 | make_handler<MethodHandler>(\ |
| 125 | ${indent(genMethod(meth=i), 3)}\ |
Matthew Barth | cd3bfbc | 2018-03-07 16:26:03 -0600 | [diff] [blame] | 126 | ) |
| 127 | %endif |
| 128 | )), |
| 129 | %endfor |
| 130 | %endif |
Matthew Barth | 016bd24 | 2018-03-07 16:06:06 -0600 | [diff] [blame] | 131 | }, |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 132 | </%def>\ |