| 175 | }}} |
| 176 | |
| 177 | Creating a hash for more than a few directives can be cumbersome in PIR. The PIR HLL module includes a subroutine called {{{new_cmd}}} that does the dirty work for us. It may eventually be moved to {{{ModParrot;Apache;Module}}} so other modules can use it. |
| 178 | |
| 179 | ''{{{new_cmd}}} from the PIR HLL module'' |
| 180 | |
| 181 | {{{ |
| 182 | .sub new_cmd |
| 183 | .param string name |
| 184 | .param string how |
| 185 | .param string func |
| 186 | .param string override |
| 187 | .param string errmsg |
| 188 | .local pmc ap_const |
| 189 | .local pmc cmd |
| 190 | |
| 191 | ap_const = get_root_global ['ModParrot'; 'Apache'; 'Constants'], 'table' |
| 192 | |
| 193 | cmd = new 'Hash' |
| 194 | $P0 = new 'String' |
| 195 | $P0 = name |
| 196 | cmd['name'] = $P0 |
| 197 | $P0 = new 'Integer' |
| 198 | $P0 = ap_const[how] |
| 199 | cmd['args_how'] = $P0 |
| 200 | $P0 = get_hll_global [ 'ModParrot'; 'HLL'; 'PIR' ], func |
| 201 | cmd['func'] = $P0 |
| 202 | $P0 = new 'Integer' |
| 203 | $P0 = ap_const[override] |
| 204 | cmd['req_override'] = $P0 |
| 205 | $P0 = new 'String' |
| 206 | $P0 = errmsg |
| 207 | cmd['errmsg'] = $P0 |
| 208 | |
| 209 | .return(cmd) |
| 210 | .end |