From c96e6c03f1055e2fc2b74464462d08db6254d73e Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sat, 16 Sep 2017 23:46:17 +0200 Subject: [PATCH] python/lib/gen_code.py: add support for rdo --- python/lib/gen_code.py | 19 +++++++++++++++---- python/lib/gen_external.py | 4 +++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/python/lib/gen_code.py b/python/lib/gen_code.py index 0498aa20..b29a59fd 100644 --- a/python/lib/gen_code.py +++ b/python/lib/gen_code.py @@ -192,6 +192,11 @@ class MappedObject(object): 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 @@ Py_{shortname}_del (Py_{shortname} * self, PyObject * unused) """.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 @@ static PyMethodDef Py_{shortname}_methods[] = {{""".format(**self.__dict__) 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 @@ PyTypeObject Py_{shortname}Type = {{ 0, 0, 0, - (ternaryfunc)Py_{shortname}_do, + (ternaryfunc)Pyaubio_{shortname}_do, 0, 0, 0, diff --git a/python/lib/gen_external.py b/python/lib/gen_external.py index 8095cb60..1e35bfd0 100644 --- a/python/lib/gen_external.py +++ b/python/lib/gen_external.py @@ -181,7 +181,7 @@ def generate_lib_from_c_declarations(cpp_objects, c_declarations): 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 @@ def generate_lib_from_c_declarations(cpp_objects, c_declarations): 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: -- 2.11.0