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 (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
462// {shortname} setters462// {shortname} setters
463""".format(**self.__dict__)463""".format(**self.__dict__)
464 for set_param in self.prototypes['set']:464 for set_param in self.prototypes['set']:
465 params = get_params_types_names(set_param)[1]465 params = get_params_types_names(set_param)[1:]
466 paramtype = params['type']466 param = self.shortname.split('_set_')[-1]
467 paramdecls = "".join(["""
468 {0} {1};""".format(p['type'], p['name']) for p in params])
467 method_name = get_name(set_param)469 method_name = get_name(set_param)
468 param = method_name.split('aubio_'+self.shortname+'_set_')[-1]470 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])
470 out += """474 out += """
471static PyObject *475static PyObject *
472Pyaubio_{shortname}_set_{param} (Py_{shortname} *self, PyObject *args)476Pyaubio_{shortname}_set_{param} (Py_{shortname} *self, PyObject *args)
473{{477{{
474 uint_t err = 0;478 uint_t err = 0;
475 {paramtype} {param};479 {paramdecls}
476 480
477 if (!PyArg_ParseTuple (args, "{pyparamtype}", &{param})) {{481 if (!PyArg_ParseTuple (args, "{pyparamtypes}", {refs})) {{
478 return NULL;482 return NULL;
479 }}483 }}
480 err = aubio_{shortname}_set_{param} (self->o, {param});484 err = aubio_{shortname}_set_{param} (self->o, {paramlist});
481 485
482 if (err > 0) {{486 if (err > 0) {{
483 if (PyErr_Occurred() == NULL) {{487 if (PyErr_Occurred() == NULL) {{
@@ -492,7 +496,8 @@ Pyaubio_{shortname}_set_{param} (Py_{shortname} *self, PyObject *args) · 8 unmodified lines
492 }}496 }}
493 Py_RETURN_NONE;497 Py_RETURN_NONE;
494}}498}}
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__)
496 return out501 return out
497 502
498 def gen_get(self):503 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