shithub: aubio

Download patch

ref: 21067f97ee2395a9ecdfb7326c6132babc3026f2
parent: da01353b1a810e4b4858e8a485d75c26a525d488
author: Paul Brossier <piem@piem.org>
date: Sat Nov 17 10:15:28 EST 2018

[py] generate code for setters with no parameters

--- a/python/lib/gen_code.py
+++ b/python/lib/gen_code.py
@@ -470,6 +470,8 @@
             param = method_name.split('aubio_'+self.shortname+'_set_')[-1]
             refs = ", ".join(["&%s" % p['name'] for p in params])
             paramlist = ", ".join(["%s" % p['name'] for p in params])
+            if len(params):
+                paramlist = "," + paramlist
             pyparamtypes = ''.join([pyargparse_chars[p['type']] for p in params])
             out += """
 static PyObject *
@@ -477,11 +479,18 @@
 {{
   uint_t err = 0;
   {paramdecls}
+""".format(param = param, paramdecls = paramdecls, **self.__dict__)
 
+            if len(refs) and len(pyparamtypes):
+                out += """
+
   if (!PyArg_ParseTuple (args, "{pyparamtypes}", {refs})) {{
     return NULL;
   }}
-  err = aubio_{shortname}_set_{param} (self->o, {paramlist});
+""".format(pyparamtypes = pyparamtypes, refs = refs)
+
+            out += """
+  err = aubio_{shortname}_set_{param} (self->o {paramlist});
 
   if (err > 0) {{
     if (PyErr_Occurred() == NULL) {{