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 | {output_results}; | 202 | {output_results}; |
| 203 | }} Py_{shortname}; | 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 | def gen_doc(self): | 209 | def gen_doc(self): |
| 208 | out = """ | 210 | out = """ |
| @@ -310,9 +312,6 @@ Py_{shortname}_init (Py_{shortname} * self, PyObject * args, PyObject * kwds) · 101 unmodified lines | |||
| 310 | out += """ | 312 | out += """ |
| 311 | // TODO get internal params after actual object creation? | 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 | out += """ | 315 | out += """ |
| 317 | // create outputs{output_create} | 316 | // create outputs{output_create} |
| 318 | """.format(output_create = output_create) | 317 | """.format(output_create = output_create) |
| @@ -342,8 +341,9 @@ static void · 23 unmodified lines | |||
| 342 | Py_{shortname}_del (Py_{shortname} * self, PyObject * unused) | 341 | Py_{shortname}_del (Py_{shortname} * self, PyObject * unused) |
| 343 | {{""".format(**self.__dict__) | 342 | {{""".format(**self.__dict__) |
| 344 | for input_param in self.do_inputs: | 343 | for input_param in self.do_inputs: |
| 345 | out += """ | 344 | if input_param['type'] == 'fmat_t *': |
| 346 | free(self->{0[name]});""".format(input_param) | 345 | out += """ |
| 346 | free(self->{0[name]}.data);""".format(input_param) | ||
| 347 | for o in self.outputs: | 347 | for o in self.outputs: |
| 348 | name = o['name'] | 348 | name = o['name'] |
| 349 | del_out = delfromtype_fn[o['type']] | 349 | del_out = delfromtype_fn[o['type']] |
| @@ -379,11 +379,11 @@ Py_{shortname}_do (Py_{shortname} * self, PyObject * args) · 29 unmodified lines | |||
| 379 | }}""".format(refs = refs, pyparamtypes = pyparamtypes, **self.__dict__) | 379 | }}""".format(refs = refs, pyparamtypes = pyparamtypes, **self.__dict__) |
| 380 | for p in input_params: | 380 | for p in input_params: |
| 381 | out += """ | 381 | out += """ |
| 382 | if (!{pytoaubio}(py_{0[name]}, self->{0[name]})) {{ | 382 | if (!{pytoaubio}(py_{0[name]}, &(self->{0[name]}))) {{ |
| 383 | return NULL; | 383 | return NULL; |
| 384 | }}""".format(input_param, pytoaubio = pytoaubio_fn[input_param['type']]) | 384 | }}""".format(input_param, pytoaubio = pytoaubio_fn[input_param['type']]) |
| 385 | do_fn = get_name(self.do_proto) | 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 | outputs = ", ".join(["self->%s" % p['name'] for p in self.do_outputs]) | 387 | outputs = ", ".join(["self->%s" % p['name'] for p in self.do_outputs]) |
| 388 | out += """ | 388 | out += """ |
| 389 | 389 | ||