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 | 8a697b6 | 2018-12-14 13:23:47 -0600 | [diff] [blame] | 75 | %if len(a['parameters']) != 0: |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 76 | make_action(action::${a['name']}( |
Matthew Barth | 8a697b6 | 2018-12-14 13:23:47 -0600 | [diff] [blame] | 77 | %else: |
| 78 | make_action(action::${a['name']} |
| 79 | %endif |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 80 | %for i, p in enumerate(a['parameters']): |
| 81 | %if (i+1) != len(a['parameters']): |
| 82 | ${p}, |
| 83 | %else: |
Matthew Barth | 06fa781 | 2018-11-20 09:54:30 -0600 | [diff] [blame] | 84 | ${p} |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 85 | %endif |
| 86 | %endfor |
Matthew Barth | 8a697b6 | 2018-12-14 13:23:47 -0600 | [diff] [blame] | 87 | %if len(a['parameters']) != 0: |
Matthew Barth | 06fa781 | 2018-11-20 09:54:30 -0600 | [diff] [blame] | 88 | )), |
Matthew Barth | 8a697b6 | 2018-12-14 13:23:47 -0600 | [diff] [blame] | 89 | %else: |
| 90 | ), |
| 91 | %endif |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 92 | %endfor |
Matthew Barth | 75d9735 | 2018-11-01 10:34:49 -0500 | [diff] [blame] | 93 | }}, |
Matthew Barth | 06fa781 | 2018-11-20 09:54:30 -0600 | [diff] [blame] | 94 | %endfor |
| 95 | }, |
Matthew Barth | 1b4de26 | 2018-03-06 13:03:16 -0600 | [diff] [blame] | 96 | std::vector<Trigger>{ |
Matthew Barth | d0b90fc | 2018-03-05 09:38:45 -0600 | [diff] [blame] | 97 | %if ('timer' in event['triggers']) and \ |
| 98 | (event['triggers']['timer'] is not None): |
Matthew Barth | 1b4de26 | 2018-03-06 13:03:16 -0600 | [diff] [blame] | 99 | make_trigger(trigger::timer(TimerConf{ |
Matthew Barth | d0b90fc | 2018-03-05 09:38:45 -0600 | [diff] [blame] | 100 | ${event['triggers']['timer']['interval']}, |
| 101 | ${event['triggers']['timer']['type']} |
Matthew Barth | 016bd24 | 2018-03-07 16:06:06 -0600 | [diff] [blame] | 102 | })), |
Matthew Barth | d0b90fc | 2018-03-05 09:38:45 -0600 | [diff] [blame] | 103 | %endif |
Matthew Barth | 016bd24 | 2018-03-07 16:06:06 -0600 | [diff] [blame] | 104 | %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 Barth | 18c9103 | 2019-01-29 15:36:00 -0600 | [diff] [blame] | 108 | %if ('match' in s) and \ |
| 109 | (s['match'] is not None): |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 110 | match::${s['match']}( |
Matthew Barth | 926df66 | 2018-10-09 09:51:12 -0500 | [diff] [blame] | 111 | %for i, mp in enumerate(s['mparams']['params']): |
| 112 | %if (i+1) != len(s['mparams']['params']): |
| 113 | ${indent(s['mparams'][mp], 1)}, |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 114 | %else: |
Matthew Barth | 926df66 | 2018-10-09 09:51:12 -0500 | [diff] [blame] | 115 | ${indent(s['mparams'][mp], 1)} |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 116 | %endif |
| 117 | %endfor |
| 118 | ), |
Matthew Barth | 18c9103 | 2019-01-29 15:36:00 -0600 | [diff] [blame] | 119 | %else: |
| 120 | "", |
| 121 | %endif |
Matthew Barth | 926df66 | 2018-10-09 09:51:12 -0500 | [diff] [blame] | 122 | make_handler<SignalHandler>(\ |
| 123 | ${genSignal(sig=s)} |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 124 | ) |
Matthew Barth | 016bd24 | 2018-03-07 16:06:06 -0600 | [diff] [blame] | 125 | )), |
| 126 | %endfor |
| 127 | %endif |
Matthew Barth | cd3bfbc | 2018-03-07 16:26:03 -0600 | [diff] [blame] | 128 | %if ('init' in event['triggers']): |
| 129 | %for i in event['triggers']['init']: |
| 130 | make_trigger(trigger::init( |
Matthew Barth | 926df66 | 2018-10-09 09:51:12 -0500 | [diff] [blame] | 131 | %if ('method' in i): |
| 132 | make_handler<MethodHandler>(\ |
| 133 | ${indent(genMethod(meth=i), 3)}\ |
Matthew Barth | cd3bfbc | 2018-03-07 16:26:03 -0600 | [diff] [blame] | 134 | ) |
| 135 | %endif |
| 136 | )), |
| 137 | %endfor |
| 138 | %endif |
Matthew Barth | 016bd24 | 2018-03-07 16:06:06 -0600 | [diff] [blame] | 139 | }, |
Matthew Barth | 702c4a5 | 2018-02-28 16:23:11 -0600 | [diff] [blame] | 140 | </%def>\ |