History

[py] generate code for setters with multiple parameters

Paul Brossier committed 7 years ago

Commit 195e22e1 parent 11c899b1 file · +12 −7Browse files

Showing the changes to python/lib/gen_code.py (1 of 1 file). Show all

Unified · Split

python/lib/gen_code.py+12−7
@@ -462,22 +462,26 @@ Pyaubio_{shortname}_{method} (Py_{shortname} * self, PyObject * args) · 461 unmodified lines
462462 // {shortname} setters
463463 """.format(**self.__dict__)
464464 for set_param in self.prototypes['set']:
465− params = get_params_types_names(set_param)[1]
466− paramtype = params['type']
465+ params = get_params_types_names(set_param)[1:]
466+ param = self.shortname.split('_set_')[-1]
467+ paramdecls = "".join(["""
468+ {0} {1};""".format(p['type'], p['name']) for p in params])
467469 method_name = get_name(set_param)
468470 param = method_name.split('aubio_'+self.shortname+'_set_')[-1]
469− pyparamtype = pyargparse_chars[paramtype]
471+ refs = ", ".join(["&%s" % p['name'] for p in params])
472+ paramlist = ", ".join(["%s" % p['name'] for p in params])
473+ pyparamtypes = ''.join([pyargparse_chars[p['type']] for p in params])
470474 out += """
471475 static PyObject *
472476 Pyaubio_{shortname}_set_{param} (Py_{shortname} *self, PyObject *args)
473477 {{
474478 uint_t err = 0;
475− {paramtype} {param};
479+ {paramdecls}
476480
477− if (!PyArg_ParseTuple (args, "{pyparamtype}", &{param})) {{
481+ if (!PyArg_ParseTuple (args, "{pyparamtypes}", {refs})) {{
478482 return NULL;
479483 }}
480− err = aubio_{shortname}_set_{param} (self->o, {param});
484+ err = aubio_{shortname}_set_{param} (self->o, {paramlist});
481485
482486 if (err > 0) {{
483487 if (PyErr_Occurred() == NULL) {{
@@ -492,7 +496,8 @@ Pyaubio_{shortname}_set_{param} (Py_{shortname} *self, PyObject *args) · 8 unmodified lines
492496 }}
493497 Py_RETURN_NONE;
494498 }}
495−""".format(param = param, paramtype = paramtype, pyparamtype = pyparamtype, **self.__dict__)
499+""".format(param = param, refs = refs, paramdecls = paramdecls,
500+ pyparamtypes = pyparamtypes, paramlist = paramlist, **self.__dict__)
496501 return out
497502
498503 def gen_get(self):

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t