Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -75,7 +75,10 @@ def get_preprocessor(): · 74 unmodified lines | |||
| 75 | cpp_cmd += ['-x', 'c'] # force C language (emcc defaults to c++) | 75 | cpp_cmd += ['-x', 'c'] # force C language (emcc defaults to c++) |
| 76 | return cpp_cmd | 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 | cpp_cmd = get_preprocessor() | 82 | cpp_cmd = get_preprocessor() |
| 80 | 83 | ||
| 81 | macros = [('AUBIO_UNSTABLE', 1)] | 84 | macros = [('AUBIO_UNSTABLE', 1)] |
| @@ -118,14 +121,14 @@ def get_cpp_objects(header=header, usedouble=False): · 36 unmodified lines | |||
| 118 | else: | 121 | else: |
| 119 | i += 1 | 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 | cpp_objects = [a.split()[3][:-1] for a in typedefs] | 128 | cpp_objects = [a.split()[3][:-1] for a in typedefs] |
| 129 | return cpp_objects | ||
| 124 | 130 | ||
| 125 | return cpp_output, cpp_objects | 131 | def analyze_c_declarations(cpp_objects, c_declarations): |
| 126 | |||
| 127 | |||
| 128 | def analyze_cpp_output(cpp_objects, cpp_output): | ||
| 129 | lib = {} | 132 | lib = {} |
| 130 | 133 | ||
| 131 | for o in cpp_objects: | 134 | for o in cpp_objects: |
| @@ -144,7 +147,7 @@ def analyze_cpp_output(cpp_objects, cpp_output): · 12 unmodified lines | |||
| 144 | lib[shortname]['shortname'] = shortname | 147 | lib[shortname]['shortname'] = shortname |
| 145 | valid_funcname_part = ['_'+longname,longname+'_'] | 148 | valid_funcname_part = ['_'+longname,longname+'_'] |
| 146 | 149 | ||
| 147 | for fn in cpp_output: | 150 | for fn in c_declarations: |
| 148 | func_name = fn.split('(')[0].strip().split(' ')[1:] | 151 | func_name = fn.split('(')[0].strip().split(' ')[1:] |
| 149 | if func_name: | 152 | if func_name: |
| 150 | func_name = func_name[-1] | 153 | func_name = func_name[-1] |
| @@ -169,8 +172,8 @@ def analyze_cpp_output(cpp_objects, cpp_output): · 18 unmodified lines | |||
| 169 | lib[shortname]['other'].append(fn) | 172 | lib[shortname]['other'].append(fn) |
| 170 | return lib | 173 | return lib |
| 171 | 174 | ||
| 172 | def print_cpp_output_results(lib, cpp_output): | 175 | def print_c_declarations_results(lib, c_declarations): |
| 173 | for fn in cpp_output: | 176 | for fn in c_declarations: |
| 174 | found = 0 | 177 | found = 0 |
| 175 | for o in lib: | 178 | for o in lib: |
| 176 | for family in lib[o]: | 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 | if not os.path.isdir(output_path): os.mkdir(output_path) | 196 | if not os.path.isdir(output_path): os.mkdir(output_path) |
| 194 | elif not overwrite: return sorted(glob.glob(os.path.join(output_path, '*.c'))) | 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) | 202 | lib = analyze_c_declarations(cpp_objects, c_declarations) |
| 199 | # print_cpp_output_results(lib, cpp_output) | 203 | # print_c_declarations_results(lib, c_declarations) |
| 200 | 204 | ||
| 201 | sources_list = [] | 205 | sources_list = [] |
| 202 | try: | 206 | try: |