Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -75,7 +75,10 @@ def get_preprocessor(): · 74 unmodified lines | ||
| 75 | 75 | cpp_cmd += ['-x', 'c'] # force C language (emcc defaults to c++) |
| 76 | 76 | return cpp_cmd |
| 77 | 77 | |
| 78 | −def get_cpp_objects(header=header, usedouble=False): | |
| 78 | + | |
| 79 | +def get_c_declarations(header=header, usedouble=False): | |
| 80 | + ''' return a dense and preprocessed string of all c declarations implied by aubio.h | |
| 81 | + ''' | |
| 79 | 82 | cpp_cmd = get_preprocessor() |
| 80 | 83 | |
| 81 | 84 | macros = [('AUBIO_UNSTABLE', 1)] |
| @@ -118,14 +121,14 @@ def get_cpp_objects(header=header, usedouble=False): · 36 unmodified lines | ||
| 118 | 121 | else: |
| 119 | 122 | i += 1 |
| 120 | 123 | |
| 121 | − typedefs = filter(lambda y: y.startswith ('typedef struct _aubio'), cpp_output) | |
| 124 | + return cpp_output | |
| 122 | 125 | |
| 126 | +def get_cpp_objects_from_c_declarations(c_declarations): | |
| 127 | + typedefs = filter(lambda y: y.startswith ('typedef struct _aubio'), c_declarations) | |
| 123 | 128 | cpp_objects = [a.split()[3][:-1] for a in typedefs] |
| 129 | + return cpp_objects | |
| 124 | 130 | |
| 125 | − return cpp_output, cpp_objects | |
| 126 | − | |
| 127 | − | |
| 128 | −def analyze_cpp_output(cpp_objects, cpp_output): | |
| 131 | +def analyze_c_declarations(cpp_objects, c_declarations): | |
| 129 | 132 | lib = {} |
| 130 | 133 | |
| 131 | 134 | for o in cpp_objects: |
| @@ -144,7 +147,7 @@ def analyze_cpp_output(cpp_objects, cpp_output): · 12 unmodified lines | ||
| 144 | 147 | lib[shortname]['shortname'] = shortname |
| 145 | 148 | valid_funcname_part = ['_'+longname,longname+'_'] |
| 146 | 149 | |
| 147 | − for fn in cpp_output: | |
| 150 | + for fn in c_declarations: | |
| 148 | 151 | func_name = fn.split('(')[0].strip().split(' ')[1:] |
| 149 | 152 | if func_name: |
| 150 | 153 | func_name = func_name[-1] |
| @@ -169,8 +172,8 @@ def analyze_cpp_output(cpp_objects, cpp_output): · 18 unmodified lines | ||
| 169 | 172 | lib[shortname]['other'].append(fn) |
| 170 | 173 | return lib |
| 171 | 174 | |
| 172 | −def print_cpp_output_results(lib, cpp_output): | |
| 173 | − for fn in cpp_output: | |
| 175 | +def print_c_declarations_results(lib, c_declarations): | |
| 176 | + for fn in c_declarations: | |
| 174 | 177 | found = 0 |
| 175 | 178 | for o in lib: |
| 176 | 179 | for family in lib[o]: |
| @@ -193,10 +196,11 @@ def generate_external(header=header, output_path=output_path, usedouble=False, o · 16 unmodified lines | ||
| 193 | 196 | if not os.path.isdir(output_path): os.mkdir(output_path) |
| 194 | 197 | elif not overwrite: return sorted(glob.glob(os.path.join(output_path, '*.c'))) |
| 195 | 198 | |
| 196 | − cpp_output, cpp_objects = get_cpp_objects(header, usedouble=usedouble) | |
| 199 | + c_declarations = get_c_declarations(header, usedouble=usedouble) | |
| 200 | + cpp_objects = get_cpp_objects_from_c_declarations(c_declarations) | |
| 197 | 201 | |
| 198 | − lib = analyze_cpp_output(cpp_objects, cpp_output) | |
| 199 | − # print_cpp_output_results(lib, cpp_output) | |
| 202 | + lib = analyze_c_declarations(cpp_objects, c_declarations) | |
| 203 | + # print_c_declarations_results(lib, c_declarations) | |
| 200 | 204 | |
| 201 | 205 | sources_list = [] |
| 202 | 206 | try: |