Changeset 21e8408 for python/lib
- Timestamp:
- Apr 29, 2016, 11:48:39 PM (9 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- e84f7b9
- Parents:
- b055b4e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/lib/gen_code.py
rb055b4e r21e8408 49 49 50 50 newfromtype_fn = { 51 'fvec_t*': 'new_ fvec',52 'fmat_t*': 'new_ fmat',53 'cvec_t*': 'new_ cvec',51 'fvec_t*': 'new_py_fvec', 52 'fmat_t*': 'new_py_fmat', 53 'cvec_t*': 'new_py_cvec', 54 54 } 55 55 56 56 delfromtype_fn = { 57 'fvec_t*': ' del_fvec',58 'fmat_t*': ' del_fmat',59 'cvec_t*': ' del_cvec',57 'fvec_t*': 'Py_DECREF', 58 'fmat_t*': 'Py_DECREF', 59 'cvec_t*': 'Py_DECREF', 60 60 } 61 61 … … 169 169 self.do_inputs = [get_params_types_names(self.do_proto)[1]] 170 170 self.do_outputs = get_params_types_names(self.do_proto)[2:] 171 s elf.outputs_flat = get_output_params(self.do_proto)172 self. output_results = "; ".join(self.outputs_flat)171 struct_output_str = ["PyObject *{0[name]}; {1} c_{0[name]}".format(i, i['type'][:-1]) for i in self.do_outputs] 172 self.struct_outputs = ";\n ".join(struct_output_str) 173 173 174 174 #print ("input_params: ", map(split_type, get_input_params(self.do_proto))) … … 202 202 {do_inputs_list}; 203 203 // output results 204 { output_results};204 {struct_outputs}; 205 205 }} Py_{shortname}; 206 206 """ … … 380 380 return NULL; 381 381 }}""".format(refs = refs, pyparamtypes = pyparamtypes, **self.__dict__) 382 for p in input_params: 383 out += """ 382 for input_param in input_params: 383 out += """ 384 384 385 if (!{pytoaubio}(py_{0[name]}, &(self->{0[name]}))) {{ 385 386 return NULL; 386 387 }}""".format(input_param, pytoaubio = pytoaubio_fn[input_param['type']]) 388 out += """ 389 390 // TODO: check input sizes""" 391 for output_param in output_params: 392 out += """ 393 394 Py_INCREF(self->{0[name]}); 395 if (!{pytoaubio}(self->{0[name]}, &(self->c_{0[name]}))) {{ 396 return NULL; 397 }}""".format(output_param, pytoaubio = pytoaubio_fn[output_param['type']]) 387 398 do_fn = get_name(self.do_proto) 388 399 inputs = ", ".join(['&(self->'+p['name']+')' for p in input_params]) 400 c_outputs = ", ".join(["&(self->c_%s)" % p['name'] for p in self.do_outputs]) 389 401 outputs = ", ".join(["self->%s" % p['name'] for p in self.do_outputs]) 390 402 out += """ 391 403 392 {do_fn}(self->o, {inputs}, { outputs});393 394 return (PyObject *) {aubiotonumpy} ({outputs});404 {do_fn}(self->o, {inputs}, {c_outputs}); 405 406 return {outputs}; 395 407 }} 396 408 """.format( 397 409 do_fn = do_fn, 398 aubiotonumpy = pyfromaubio_fn[output['type']], 399 inputs = inputs, outputs = outputs, 410 inputs = inputs, outputs = outputs, c_outputs = c_outputs, 400 411 ) 401 412 return out
Note: See TracChangeset
for help on using the changeset viewer.