Changeset 195e22e4


Ignore:
Timestamp:
Nov 17, 2018, 3:03:08 PM (5 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master
Children:
da01353
Parents:
11c899b
Message:

[py] generate code for setters with multiple parameters

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/lib/gen_code.py

    r11c899b r195e22e4  
    463463""".format(**self.__dict__)
    464464        for set_param in self.prototypes['set']:
    465             params = get_params_types_names(set_param)[1]
    466             paramtype = params['type']
     465            params = get_params_types_names(set_param)[1:]
     466            param = self.shortname.split('_set_')[-1]
     467            paramdecls = "".join(["""
     468   {0} {1};""".format(p['type'], p['name']) for p in params])
    467469            method_name = get_name(set_param)
    468470            param = method_name.split('aubio_'+self.shortname+'_set_')[-1]
    469             pyparamtype = pyargparse_chars[paramtype]
     471            refs = ", ".join(["&%s" % p['name'] for p in params])
     472            paramlist = ", ".join(["%s" % p['name'] for p in params])
     473            pyparamtypes = ''.join([pyargparse_chars[p['type']] for p in params])
    470474            out += """
    471475static PyObject *
     
    473477{{
    474478  uint_t err = 0;
    475   {paramtype} {param};
    476 
    477   if (!PyArg_ParseTuple (args, "{pyparamtype}", &{param})) {{
     479  {paramdecls}
     480
     481  if (!PyArg_ParseTuple (args, "{pyparamtypes}", {refs})) {{
    478482    return NULL;
    479483  }}
    480   err = aubio_{shortname}_set_{param} (self->o, {param});
     484  err = aubio_{shortname}_set_{param} (self->o, {paramlist});
    481485
    482486  if (err > 0) {{
     
    493497  Py_RETURN_NONE;
    494498}}
    495 """.format(param = param, paramtype = paramtype, pyparamtype = pyparamtype, **self.__dict__)
     499""".format(param = param, refs = refs, paramdecls = paramdecls,
     500        pyparamtypes = pyparamtypes, paramlist = paramlist, **self.__dict__)
    496501        return out
    497502
Note: See TracChangeset for help on using the changeset viewer.