History

python/lib/gen_code.py: add support for rdo

Paul Brossier committed 9 years ago

Commit c96e6c01 parent 2bf59042 files · +18 −5Browse files

Showing the changes to python (2 of 2 files). Show all

Unified · Split

2 files
  1. python/lib/gen_code.py +15 −4
  2. python/lib/gen_external.py +3 −1
python/lib/gen_code.py+15−4
@@ -192,6 +192,11 @@ class MappedObject(object): · 191 unmodified lines
192 out += self.gen_init()192 out += self.gen_init()
193 out += self.gen_del()193 out += self.gen_del()
194 out += self.gen_do()194 out += self.gen_do()
195 if len(self.prototypes['rdo']):
196 self.do_proto = self.prototypes['rdo'][0]
197 self.do_inputs = [get_params_types_names(self.do_proto)[1]]
198 self.do_outputs = get_params_types_names(self.do_proto)[2:]
199 out += self.gen_do(method='rdo')
195 out += self.gen_memberdef()200 out += self.gen_memberdef()
196 out += self.gen_set()201 out += self.gen_set()
197 out += self.gen_get()202 out += self.gen_get()
@@ -372,12 +377,12 @@ Py_{shortname}_del (Py_{shortname} * self, PyObject * unused) · 174 unmodified lines
372""".format(del_fn = del_fn)377""".format(del_fn = del_fn)
373 return out378 return out
374 379
375 def gen_do(self):380 def gen_do(self, method = 'do'):
376 out = """381 out = """
377// do {shortname}382// do {shortname}
378static PyObject*383static PyObject*
379Py_{shortname}_do (Py_{shortname} * self, PyObject * args)384Pyaubio_{shortname}_{method} (Py_{shortname} * self, PyObject * args)
380{{""".format(**self.__dict__)385{{""".format(**self.__dict__, method = method)
381 input_params = self.do_inputs386 input_params = self.do_inputs
382 output_params = self.do_outputs387 output_params = self.do_outputs
383 #print input_params388 #print input_params
@@ -517,6 +522,12 @@ static PyMethodDef Py_{shortname}_methods[] = {{""".format(**self.__dict__) · 133 unmodified lines
517 out += """522 out += """
518 {{"{shortname}", (PyCFunction) Py{name},523 {{"{shortname}", (PyCFunction) Py{name},
519 METH_NOARGS, ""}},""".format(name = name, shortname = shortname)524 METH_NOARGS, ""}},""".format(name = name, shortname = shortname)
525 for m in self.prototypes['rdo']:
526 name = get_name(m)
527 shortname = name.replace('aubio_%s_' % self.shortname, '')
528 out += """
529 {{"{shortname}", (PyCFunction) Py{name},
530 METH_VARARGS, ""}},""".format(name = name, shortname = shortname)
520 out += """531 out += """
521 {NULL} /* sentinel */532 {NULL} /* sentinel */
522};533};
@@ -542,7 +553,7 @@ PyTypeObject Py_{shortname}Type = {{ · 19 unmodified lines
542 0,553 0,
543 0,554 0,
544 0,555 0,
545 (ternaryfunc)Py_{shortname}_do,556 (ternaryfunc)Pyaubio_{shortname}_do,
546 0,557 0,
547 0,558 0,
548 0,559 0,
python/lib/gen_external.py+3−1
@@ -181,7 +181,7 @@ def generate_lib_from_c_declarations(cpp_objects, c_declarations): · 180 unmodified lines
181 if o[:6] == 'aubio_':181 if o[:6] == 'aubio_':
182 shortname = o[6:-2] # without aubio_ prefix and _t suffix182 shortname = o[6:-2] # without aubio_ prefix and _t suffix
183 183
184 lib[shortname] = {'struct': [], 'new': [], 'del': [], 'do': [], 'get': [], 'set': [], 'other': []}184 lib[shortname] = {'struct': [], 'new': [], 'del': [], 'do': [], 'rdo': [], 'get': [], 'set': [], 'other': []}
185 lib[shortname]['longname'] = o185 lib[shortname]['longname'] = o
186 lib[shortname]['shortname'] = shortname186 lib[shortname]['shortname'] = shortname
187 187
@@ -195,6 +195,8 @@ def generate_lib_from_c_declarations(cpp_objects, c_declarations): · 7 unmodified lines
195 lib[shortname]['struct'].append(fn)195 lib[shortname]['struct'].append(fn)
196 elif '_do' in fn:196 elif '_do' in fn:
197 lib[shortname]['do'].append(fn)197 lib[shortname]['do'].append(fn)
198 elif '_rdo' in fn:
199 lib[shortname]['rdo'].append(fn)
198 elif 'new_' in fn:200 elif 'new_' in fn:
199 lib[shortname]['new'].append(fn)201 lib[shortname]['new'].append(fn)
200 elif 'del_' in fn:202 elif 'del_' in fn:

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