ref: c96e6c03f1055e2fc2b74464462d08db6254d73e
parent: 2bf590427e2a1f227be0a6391e025af3fc0ff2c0
author: Paul Brossier <piem@piem.org>
date: Sat Sep 16 19:46:17 EDT 2017
python/lib/gen_code.py: add support for rdo
--- a/python/lib/gen_code.py
+++ b/python/lib/gen_code.py
@@ -192,6 +192,11 @@
out += self.gen_init()
out += self.gen_del()
out += self.gen_do()
+ if len(self.prototypes['rdo']):
+ self.do_proto = self.prototypes['rdo'][0]
+ self.do_inputs = [get_params_types_names(self.do_proto)[1]]
+ self.do_outputs = get_params_types_names(self.do_proto)[2:]
+ out += self.gen_do(method='rdo')
out += self.gen_memberdef()
out += self.gen_set()
out += self.gen_get()
@@ -372,12 +377,12 @@
""".format(del_fn = del_fn)
return out
- def gen_do(self):
+ def gen_do(self, method = 'do'):
out = """
// do {shortname}
static PyObject*
-Py_{shortname}_do (Py_{shortname} * self, PyObject * args)
-{{""".format(**self.__dict__)
+Pyaubio_{shortname}_{method} (Py_{shortname} * self, PyObject * args)
+{{""".format(**self.__dict__, method = method)
input_params = self.do_inputs
output_params = self.do_outputs
#print input_params
@@ -517,6 +522,12 @@
out += """
{{"{shortname}", (PyCFunction) Py{name},
METH_NOARGS, ""}},""".format(name = name, shortname = shortname)
+ for m in self.prototypes['rdo']:
+ name = get_name(m)
+ shortname = name.replace('aubio_%s_' % self.shortname, '')
+ out += """
+ {{"{shortname}", (PyCFunction) Py{name},
+ METH_VARARGS, ""}},""".format(name = name, shortname = shortname)
out += """
{NULL} /* sentinel */
};
@@ -542,7 +553,7 @@
0,
0,
0,
- (ternaryfunc)Py_{shortname}_do,
+ (ternaryfunc)Pyaubio_{shortname}_do,
0,
0,
0,
--- a/python/lib/gen_external.py
+++ b/python/lib/gen_external.py
@@ -181,7 +181,7 @@
if o[:6] == 'aubio_':
shortname = o[6:-2] # without aubio_ prefix and _t suffix
- lib[shortname] = {'struct': [], 'new': [], 'del': [], 'do': [], 'get': [], 'set': [], 'other': []}
+ lib[shortname] = {'struct': [], 'new': [], 'del': [], 'do': [], 'rdo': [], 'get': [], 'set': [], 'other': []}
lib[shortname]['longname'] = o
lib[shortname]['shortname'] = shortname
@@ -195,6 +195,8 @@
lib[shortname]['struct'].append(fn)
elif '_do' in fn:
lib[shortname]['do'].append(fn)
+ elif '_rdo' in fn:
+ lib[shortname]['rdo'].append(fn)
elif 'new_' in fn:
lib[shortname]['new'].append(fn)
elif 'del_' in fn: