Changeset 9c9cd54 for interfaces


Ignore:
Timestamp:
Dec 25, 2009, 5:02:17 AM (15 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, pitchshift, sampler, timestretch, yinfft+
Children:
474f297
Parents:
1a6ef2c
Message:

gen_pyobject.py: simplify with proxy functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • interfaces/python/gen_pyobject.py

    r1a6ef2c r9c9cd54  
    123123}
    124124
    125 # aubio to pyaubio
    126 aubio2pyaubio = {
    127     'fvec_t*': 'fvec_t',
    128     'cvec_t*': 'cvec_t',
    129 }
    130 
    131 # array to aubio
     125# python to aubio
    132126aubiovecfrompyobj = {
    133127    'fvec_t*': 'PyAubio_ArrayToCFvec',
     
    135129}
    136130
    137 # aubio to array
     131# aubio to python
    138132aubiovectopyobj = {
    139     'fvec_t*': 'PyAubio_FvecToArray',
    140     'cvec_t*': 'PyAubio_CvecToArray',
    141 }
    142 
    143 aubiovectopyobj_new = {
    144133    'fvec_t*': 'PyAubio_CFvecToArray',
    145134    'cvec_t*': 'PyAubio_CCvecToPyCvec',
     
    270259    inputdefs = "\n  ".join(["PyObject * " + p[-1] + "_obj;" for p in inputparams])
    271260    inputvecs = "\n  ".join(map(lambda p: \
    272                 aubio2pyaubio[p[0]]+" * " + p[-1] + ";", inputparams))
     261                p[0] + p[-1] + ";", inputparams))
    273262    parseinput = ""
    274263    for p in inputparams:
     
    290279        #assert len(outputparams) == 1, \
    291280        #    "too many output parameters"
    292         outputvecs = "\n  ".join([aubio2pyaubio[p[0]]+" * " + p[-1] + ";" for p in outputparams])
     281        outputvecs = "\n  ".join([p[0] + p[-1] + ";" for p in outputparams])
    293282        outputcreate = "\n  ".join(["""\
    294283  %(name)s = new_%(autype)s (%(length)s);""" % \
    295     {'name': p[-1], 'pytype': aubio2pyaubio[p[0]], 'autype': p[0][:-3],
     284    {'name': p[-1], 'pytype': p[0], 'autype': p[0][:-3],
    296285        'length': defaultsizes[name]} \
    297286        for p in outputparams])
     
    299288            returnval = "PyObject *outputs = PyList_New(0);\n"
    300289            for p in outputparams:
    301                 returnval += "  PyList_Append( outputs, (PyObject *)" + aubiovectopyobj_new[p[0]] + " (" + p[-1] + ")" +");\n"
     290                returnval += "  PyList_Append( outputs, (PyObject *)" + aubiovectopyobj[p[0]] + " (" + p[-1] + ")" +");\n"
    302291            returnval += "  return outputs;"
    303292        else:
    304             returnval = "return (PyObject *)" + aubiovectopyobj_new[p[0]] + " (" + p[-1] + ")"
     293            returnval = "return (PyObject *)" + aubiovectopyobj[p[0]] + " (" + p[-1] + ")"
    305294    else:
    306295        # no output
     
    308297        outputcreate = ""
    309298        #returnval = "Py_None";
    310         returnval = "return (PyObject *)" + aubiovectopyobj_new[p[0]] + " (" + p[-1] + ")"
     299        returnval = "return (PyObject *)" + aubiovectopyobj[p[0]] + " (" + p[-1] + ")"
    311300    # end of output strings
    312301
     
    420409            "get method has more than one parameter %s" % params
    421410        getter_args = "self->o"
    422         returnval = "(PyObject *)" + aubiovectopyobj_new[out_type] + " (tmp)"
     411        returnval = "(PyObject *)" + aubiovectopyobj[out_type] + " (tmp)"
    423412        shortname = method_name.split(name+'_')[-1]
    424413        method_defs += """\
Note: See TracChangeset for help on using the changeset viewer.