Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -135,7 +135,37 @@ def get_cpp_objects_from_c_declarations(c_declarations): · 134 unmodified lines | ||
| 135 | 135 | cpp_objects = [a.split()[3][:-1] for a in typedefs] |
| 136 | 136 | return cpp_objects |
| 137 | 137 | |
| 138 | −def analyze_c_declarations(cpp_objects, c_declarations): | |
| 138 | + | |
| 139 | +def get_all_func_names_from_lib(lib, depth=0): | |
| 140 | + ''' return flat string of all function used in lib | |
| 141 | + ''' | |
| 142 | + res = [] | |
| 143 | + indent = " " * depth | |
| 144 | + for k, v in lib.items(): | |
| 145 | + if isinstance(v, dict): | |
| 146 | + res += get_all_func_names_from_lib(v, depth + 1) | |
| 147 | + elif isinstance(v, list): | |
| 148 | + for elem in v: | |
| 149 | + e = elem.split('(') | |
| 150 | + if len(e) < 2: | |
| 151 | + continue # not a function | |
| 152 | + fname_part = e[0].strip().split(' ') | |
| 153 | + fname = fname_part[-1] | |
| 154 | + if fname: | |
| 155 | + res += [fname] | |
| 156 | + else: | |
| 157 | + raise NameError('gen_lib : weird function: ' + str(e)) | |
| 158 | + | |
| 159 | + return res | |
| 160 | + | |
| 161 | + | |
| 162 | +def generate_lib_from_c_declarations(cpp_objects, c_declarations): | |
| 163 | + ''' returns a lib from given cpp_object names | |
| 164 | + | |
| 165 | + a lib is a dict grouping functions by family (onset,pitch...) | |
| 166 | + each eement is itself a dict of functions grouped by puposes as : | |
| 167 | + struct, new, del, do, get, set and other | |
| 168 | + ''' | |
| 139 | 169 | lib = {} |
| 140 | 170 | |
| 141 | 171 | for o in cpp_objects: |
| @@ -205,7 +235,7 @@ def generate_external(header=header, output_path=output_path, usedouble=False, o · 63 unmodified lines | ||
| 205 | 235 | c_declarations = get_c_declarations(header, usedouble=usedouble) |
| 206 | 236 | cpp_objects = get_cpp_objects_from_c_declarations(c_declarations) |
| 207 | 237 | |
| 208 | − lib = analyze_c_declarations(cpp_objects, c_declarations) | |
| 238 | + lib = generate_lib_from_c_declarations(cpp_objects, c_declarations) | |
| 209 | 239 | # print_c_declarations_results(lib, c_declarations) |
| 210 | 240 | |
| 211 | 241 | sources_list = [] |