projects
/
aubio.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
11c899b
)
[py] generate code for setters with multiple parameters
author
Paul Brossier
<piem@piem.org>
Sat, 17 Nov 2018 14:03:08 +0000
(15:03 +0100)
committer
Paul Brossier
<piem@piem.org>
Sat, 17 Nov 2018 14:03:08 +0000
(15:03 +0100)
python/lib/gen_code.py
patch
|
blob
|
history
diff --git
a/python/lib/gen_code.py
b/python/lib/gen_code.py
index
1266336
..
1dc5fe4
100644
(file)
--- a/
python/lib/gen_code.py
+++ b/
python/lib/gen_code.py
@@
-462,22
+462,26
@@
Pyaubio_{shortname}_{method} (Py_{shortname} * self, PyObject * args)
// {shortname} setters
""".format(**self.__dict__)
for set_param in self.prototypes['set']:
// {shortname} setters
""".format(**self.__dict__)
for set_param in self.prototypes['set']:
- params = get_params_types_names(set_param)[1]
- paramtype = params['type']
+ params = get_params_types_names(set_param)[1:]
+ param = self.shortname.split('_set_')[-1]
+ paramdecls = "".join(["""
+ {0} {1};""".format(p['type'], p['name']) for p in params])
method_name = get_name(set_param)
param = method_name.split('aubio_'+self.shortname+'_set_')[-1]
method_name = get_name(set_param)
param = method_name.split('aubio_'+self.shortname+'_set_')[-1]
- pyparamtype = pyargparse_chars[paramtype]
+ refs = ", ".join(["&%s" % p['name'] for p in params])
+ paramlist = ", ".join(["%s" % p['name'] for p in params])
+ pyparamtypes = ''.join([pyargparse_chars[p['type']] for p in params])
out += """
static PyObject *
Pyaubio_{shortname}_set_{param} (Py_{shortname} *self, PyObject *args)
{{
uint_t err = 0;
out += """
static PyObject *
Pyaubio_{shortname}_set_{param} (Py_{shortname} *self, PyObject *args)
{{
uint_t err = 0;
- {param
type} {param};
+ {param
decls}
- if (!PyArg_ParseTuple (args, "{pyparamtype
}", &{param
})) {{
+ if (!PyArg_ParseTuple (args, "{pyparamtype
s}", {refs
})) {{
return NULL;
}}
return NULL;
}}
- err = aubio_{shortname}_set_{param} (self->o, {param});
+ err = aubio_{shortname}_set_{param} (self->o, {param
list
});
if (err > 0) {{
if (PyErr_Occurred() == NULL) {{
if (err > 0) {{
if (PyErr_Occurred() == NULL) {{
@@
-492,7
+496,8
@@
Pyaubio_{shortname}_set_{param} (Py_{shortname} *self, PyObject *args)
}}
Py_RETURN_NONE;
}}
}}
Py_RETURN_NONE;
}}
-""".format(param = param, paramtype = paramtype, pyparamtype = pyparamtype, **self.__dict__)
+""".format(param = param, refs = refs, paramdecls = paramdecls,
+ pyparamtypes = pyparamtypes, paramlist = paramlist, **self.__dict__)
return out
def gen_get(self):
return out
def gen_get(self):