Showing the changes to python/lib/gen_code.py (1 of 9 files). Show all
Unified · Split
| @@ -202,7 +202,9 @@ typedef struct{{ · 201 unmodified lines | ||
| 202 | 202 | {output_results}; |
| 203 | 203 | }} Py_{shortname}; |
| 204 | 204 | """ |
| 205 | − return out.format(do_inputs_list = "; ".join(get_input_params(self.do_proto)), **self.__dict__) | |
| 205 | + # fmat_t* / fvec_t* / cvec_t* inputs -> full fvec_t /.. struct in Py_{shortname} | |
| 206 | + do_inputs_list = "; ".join(get_input_params(self.do_proto)).replace('fvec_t *','fvec_t').replace('fmat_t *', 'fmat_t').replace('cvec_t *', 'cvec_t') | |
| 207 | + return out.format(do_inputs_list = do_inputs_list, **self.__dict__) | |
| 206 | 208 | |
| 207 | 209 | def gen_doc(self): |
| 208 | 210 | out = """ |
| @@ -310,9 +312,6 @@ Py_{shortname}_init (Py_{shortname} * self, PyObject * args, PyObject * kwds) · 101 unmodified lines | ||
| 310 | 312 | out += """ |
| 311 | 313 | // TODO get internal params after actual object creation? |
| 312 | 314 | """ |
| 313 | − for input_param in self.do_inputs: | |
| 314 | − out += """ | |
| 315 | − self->{0} = ({1})malloc(sizeof({2}));""".format(input_param['name'], input_param['type'], input_param['type'][:-1]) | |
| 316 | 315 | out += """ |
| 317 | 316 | // create outputs{output_create} |
| 318 | 317 | """.format(output_create = output_create) |
| @@ -342,8 +341,9 @@ static void · 23 unmodified lines | ||
| 342 | 341 | Py_{shortname}_del (Py_{shortname} * self, PyObject * unused) |
| 343 | 342 | {{""".format(**self.__dict__) |
| 344 | 343 | for input_param in self.do_inputs: |
| 345 | − out += """ | |
| 346 | − free(self->{0[name]});""".format(input_param) | |
| 344 | + if input_param['type'] == 'fmat_t *': | |
| 345 | + out += """ | |
| 346 | + free(self->{0[name]}.data);""".format(input_param) | |
| 347 | 347 | for o in self.outputs: |
| 348 | 348 | name = o['name'] |
| 349 | 349 | del_out = delfromtype_fn[o['type']] |
| @@ -379,11 +379,11 @@ Py_{shortname}_do (Py_{shortname} * self, PyObject * args) · 29 unmodified lines | ||
| 379 | 379 | }}""".format(refs = refs, pyparamtypes = pyparamtypes, **self.__dict__) |
| 380 | 380 | for p in input_params: |
| 381 | 381 | out += """ |
| 382 | − if (!{pytoaubio}(py_{0[name]}, self->{0[name]})) {{ | |
| 382 | + if (!{pytoaubio}(py_{0[name]}, &(self->{0[name]}))) {{ | |
| 383 | 383 | return NULL; |
| 384 | 384 | }}""".format(input_param, pytoaubio = pytoaubio_fn[input_param['type']]) |
| 385 | 385 | do_fn = get_name(self.do_proto) |
| 386 | − inputs = ", ".join(['self->'+p['name'] for p in input_params]) | |
| 386 | + inputs = ", ".join(['&(self->'+p['name']+')' for p in input_params]) | |
| 387 | 387 | outputs = ", ".join(["self->%s" % p['name'] for p in self.do_outputs]) |
| 388 | 388 | out += """ |
| 389 | 389 | |