Changeset c85da04
- Timestamp:
- Oct 21, 2009, 7:53:59 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:
- 992beaa
- Parents:
- a8aaef3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
interfaces/python/generator.py
ra8aaef3 rc85da04 14 14 i = 1 15 15 while 1: 16 if i >= len(cpp_output): break17 if cpp_output[i-1].endswith(',') or cpp_output[i-1].endswith('{') or cpp_output[i].startswith('}'):18 cpp_output[i] = cpp_output[i-1] + ' ' + cpp_output[i]19 cpp_output.pop(i-1)20 else:21 i += 116 if i >= len(cpp_output): break 17 if cpp_output[i-1].endswith(',') or cpp_output[i-1].endswith('{') or cpp_output[i].startswith('}'): 18 cpp_output[i] = cpp_output[i-1] + ' ' + cpp_output[i] 19 cpp_output.pop(i-1) 20 else: 21 i += 1 22 22 23 23 typedefs = filter(lambda y: y.startswith ('typedef struct _aubio'), cpp_output) … … 28 28 29 29 for object in objects: 30 lint = 031 32 if object[-2:] == '_t':33 object_name = object[:-2]34 else:35 object_name = object36 print "-- WARNING: %s does not end in _t" % object30 lint = 0 31 32 if object[-2:] == '_t': 33 object_name = object[:-2] 34 else: 35 object_name = object 36 print "-- WARNING: %s does not end in _t" % object 37 37 38 if object_name[:len('aubio_')] != 'aubio_':39 print "-- WARNING: %s does not start n aubio_" % object38 if object_name[:len('aubio_')] != 'aubio_': 39 print "-- WARNING: %s does not start n aubio_" % object 40 40 41 print "-- INFO: looking at", object_name42 object_methods = filter(lambda x: object in x, cpp_output)43 object_methods = [a.strip() for a in object_methods]44 object_methods = filter(lambda x: not x.startswith('typedef'), object_methods)45 #for method in object_methods:46 #print method41 print "-- INFO: looking at", object_name 42 object_methods = filter(lambda x: object in x, cpp_output) 43 object_methods = [a.strip() for a in object_methods] 44 object_methods = filter(lambda x: not x.startswith('typedef'), object_methods) 45 #for method in object_methods: 46 # print method 47 47 48 new_methods = filter(lambda x: 'new_'+object_name in x, object_methods)49 if len(new_methods) > 1:50 print "-- WARNING: more than one new method for", object_name51 for method in new_methods:52 print method53 elif len(new_methods) < 1:54 print "-- WARNING: no new method for", object_name55 elif 0:56 for method in new_methods:57 print method48 new_methods = filter(lambda x: 'new_'+object_name in x, object_methods) 49 if len(new_methods) > 1: 50 print "-- WARNING: more than one new method for", object_name 51 for method in new_methods: 52 print method 53 elif len(new_methods) < 1: 54 print "-- WARNING: no new method for", object_name 55 elif 0: 56 for method in new_methods: 57 print method 58 58 59 del_methods = filter(lambda x: 'del_'+object_name in x, object_methods)60 if len(del_methods) > 1:61 print "-- WARNING: more than one del method for", object_name62 for method in del_methods:63 print method64 elif len(del_methods) < 1:65 print "-- WARNING: no del method for", object_name59 del_methods = filter(lambda x: 'del_'+object_name in x, object_methods) 60 if len(del_methods) > 1: 61 print "-- WARNING: more than one del method for", object_name 62 for method in del_methods: 63 print method 64 elif len(del_methods) < 1: 65 print "-- WARNING: no del method for", object_name 66 66 67 do_methods = filter(lambda x: object_name+'_do' in x, object_methods) 68 if len(do_methods) > 1: 69 pass 70 #print "-- WARNING: more than one do method for", object_name 71 #for method in do_methods: 72 # print method 73 elif len(do_methods) < 1: 74 print "-- WARNING: no do method for", object_name 75 elif 0: 67 do_methods = filter(lambda x: object_name+'_do' in x, object_methods) 68 if len(do_methods) > 1: 69 pass 70 #print "-- WARNING: more than one do method for", object_name 71 #for method in do_methods: 72 # print method 73 elif len(do_methods) < 1: 74 print "-- WARNING: no do method for", object_name 75 elif 0: 76 for method in do_methods: 77 print method 78 79 # check do methods return void 76 80 for method in do_methods: 77 print method 81 if (method.split()[0] != 'void'): 82 print "-- ERROR: _do method does not return void:", method 78 83 79 # check do methods return void 80 for method in do_methods: 81 if (method.split()[0] != 'void'): 82 print "-- ERROR: _do method does not return void:", method 84 get_methods = filter(lambda x: object_name+'_get_' in x, object_methods) 83 85 84 get_methods = filter(lambda x: object_name+'_get_' in x, object_methods) 86 set_methods = filter(lambda x: object_name+'_set_' in x, object_methods) 87 for method in set_methods: 88 if (method.split()[0] != 'uint_t'): 89 print "-- ERROR: _set method does not return uint_t:", method 85 90 86 set_methods = filter(lambda x: object_name+'_set_' in x, object_methods) 87 for method in set_methods: 88 if (method.split()[0] != 'uint_t'): 89 print "-- ERROR: _set method does not return uint_t:", method 91 other_methods = filter(lambda x: x not in new_methods, object_methods) 92 other_methods = filter(lambda x: x not in del_methods, other_methods) 93 other_methods = filter(lambda x: x not in do_methods, other_methods) 94 other_methods = filter(lambda x: x not in get_methods, other_methods) 95 other_methods = filter(lambda x: x not in set_methods, other_methods) 90 96 91 other_methods = filter(lambda x: x not in new_methods, object_methods) 92 other_methods = filter(lambda x: x not in del_methods, other_methods) 93 other_methods = filter(lambda x: x not in do_methods, other_methods) 94 other_methods = filter(lambda x: x not in get_methods, other_methods) 95 other_methods = filter(lambda x: x not in set_methods, other_methods) 97 if len(other_methods) > 0: 98 print "-- WARNING: some methods for", object_name, "were unidentified" 99 for method in other_methods: 100 print method 96 101 97 if len(other_methods) > 0: 98 print "-- WARNING: some methods for", object_name, "were unidentified" 99 for method in other_methods: 100 print method 101 102 # generate object 103 if not os.path.isdir('generated'): os.mkdir('generated') 104 from gen_pyobject import * 105 short_name = object_name[len('aubio_'):] 106 if short_name in skip_objects: 107 print "-- INFO: skipping object", short_name 108 continue 109 if 1: #try: 110 s = gen_new_init(new_methods[0], short_name) 111 s += gen_do(do_methods[0], short_name) 112 s += gen_members(new_methods[0], short_name) 113 s += gen_methods(get_methods, set_methods, short_name) 114 s += gen_finish(short_name) 115 fd = open('generated/gen-'+short_name+'.c', 'w') 116 fd.write(s) 117 #except Exception, e: 118 # print "-- ERROR:", type(e), str(e), "in", short_name 119 # continue 102 # generate object 103 if not os.path.isdir('generated'): os.mkdir('generated') 104 from gen_pyobject import * 105 short_name = object_name[len('aubio_'):] 106 if short_name in skip_objects: 107 print "-- INFO: skipping object", short_name 108 continue 109 if 1: #try: 110 s = gen_new_init(new_methods[0], short_name) 111 s += gen_do(do_methods[0], short_name) 112 s += gen_members(new_methods[0], short_name) 113 s += gen_methods(get_methods, set_methods, short_name) 114 s += gen_finish(short_name) 115 fd = open('generated/gen-'+short_name+'.c', 'w') 116 fd.write(s) 117 #except Exception, e: 118 # print "-- ERROR:", type(e), str(e), "in", short_name 119 # continue
Note: See TracChangeset
for help on using the changeset viewer.