Changeset 4bc098c


Ignore:
Timestamp:
Nov 15, 2009, 3:16:44 PM (14 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:
90077e4
Parents:
d6f9b3a
Message:

generator.py: also spit out aubio-generated.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • interfaces/python/generator.py

    rd6f9b3a r4bc098c  
    2727print "-- INFO: %d objects in total" % len(objects)
    2828
    29 for object in objects:
     29generated_objects = []
     30
     31for this_object in objects:
    3032    lint = 0
    3133 
    32     if object[-2:] == '_t':
    33         object_name = object[:-2]
     34    if this_object[-2:] == '_t':
     35        object_name = this_object[:-2]
    3436    else:
    35         object_name = object
    36         print "-- WARNING: %s does not end in _t" % object
     37        object_name = this_object
     38        print "-- WARNING: %s does not end in _t" % this_object
    3739
    3840    if object_name[:len('aubio_')] != 'aubio_':
    39         print "-- WARNING: %s does not start n aubio_" % object
     41        print "-- WARNING: %s does not start n aubio_" % this_object
    4042
    4143    print "-- INFO: looking at", object_name
    42     object_methods = filter(lambda x: object in x, cpp_output)
     44    object_methods = filter(lambda x: this_object in x, cpp_output)
    4345    object_methods = [a.strip() for a in object_methods]
    4446    object_methods = filter(lambda x: not x.startswith('typedef'), object_methods)
     
    100102            print method
    101103
    102     # generate object
     104    # generate this_object
    103105    if not os.path.isdir('generated'): os.mkdir('generated')
    104106    from gen_pyobject import *
     
    118120    #        print "-- ERROR:", type(e), str(e), "in", short_name
    119121    #        continue
     122    generated_objects += [this_object]
     123
     124
     125s = """// generated list of generated objects
     126
     127"""
     128
     129for each in generated_objects:
     130    s += "extern PyTypeObject Py_%sType;\n" % \
     131            each.replace('aubio_','').replace('_t','')
     132
     133types_ready = []
     134for each in generated_objects:
     135    types_ready.append("  PyType_Ready (&Py_%sType) < 0" % \
     136            each.replace('aubio_','').replace('_t','') )
     137
     138s += """
     139int
     140generated_types_ready (void)
     141{
     142    return ("""
     143s += ('||\n').join(types_ready)
     144s += """);
     145}
     146"""
     147
     148s += """
     149void
     150add_generated_objects ( PyObject *m )
     151{"""
     152for each in generated_objects:
     153    s += """  Py_INCREF (&Py_%(name)sType);
     154  PyModule_AddObject (m, "%(name)s", (PyObject *) & Py_%(name)sType);""" % \
     155          { 'name': ( each.replace('aubio_','').replace('_t','') ) }
     156
     157s += """
     158}"""
     159
     160fd = open('generated/aubio-generated.h', 'w')
     161fd.write(s)
Note: See TracChangeset for help on using the changeset viewer.