Changeset 4bc098c
- Timestamp:
- Nov 15, 2009, 3:16:44 PM (15 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
interfaces/python/generator.py
rd6f9b3a r4bc098c 27 27 print "-- INFO: %d objects in total" % len(objects) 28 28 29 for object in objects: 29 generated_objects = [] 30 31 for this_object in objects: 30 32 lint = 0 31 33 32 if object[-2:] == '_t':33 object_name = object[:-2]34 if this_object[-2:] == '_t': 35 object_name = this_object[:-2] 34 36 else: 35 object_name = object36 print "-- WARNING: %s does not end in _t" % object37 object_name = this_object 38 print "-- WARNING: %s does not end in _t" % this_object 37 39 38 40 if object_name[:len('aubio_')] != 'aubio_': 39 print "-- WARNING: %s does not start n aubio_" % object41 print "-- WARNING: %s does not start n aubio_" % this_object 40 42 41 43 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) 43 45 object_methods = [a.strip() for a in object_methods] 44 46 object_methods = filter(lambda x: not x.startswith('typedef'), object_methods) … … 100 102 print method 101 103 102 # generate object104 # generate this_object 103 105 if not os.path.isdir('generated'): os.mkdir('generated') 104 106 from gen_pyobject import * … … 118 120 # print "-- ERROR:", type(e), str(e), "in", short_name 119 121 # continue 122 generated_objects += [this_object] 123 124 125 s = """// generated list of generated objects 126 127 """ 128 129 for each in generated_objects: 130 s += "extern PyTypeObject Py_%sType;\n" % \ 131 each.replace('aubio_','').replace('_t','') 132 133 types_ready = [] 134 for each in generated_objects: 135 types_ready.append(" PyType_Ready (&Py_%sType) < 0" % \ 136 each.replace('aubio_','').replace('_t','') ) 137 138 s += """ 139 int 140 generated_types_ready (void) 141 { 142 return (""" 143 s += ('||\n').join(types_ready) 144 s += """); 145 } 146 """ 147 148 s += """ 149 void 150 add_generated_objects ( PyObject *m ) 151 {""" 152 for 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 157 s += """ 158 }""" 159 160 fd = open('generated/aubio-generated.h', 'w') 161 fd.write(s)
Note: See TracChangeset
for help on using the changeset viewer.