History

gen_external : add function get_all_func_names_from_lib analyze_c_declarations -> generate_lib_from_c_declarations

Martin Hermant committed 9 years ago

Commit 6cbf34b1 parent b1f93c41 file · +32 −2Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/lib/gen_external.py+32−2
@@ -135,7 +135,37 @@ def get_cpp_objects_from_c_declarations(c_declarations): · 134 unmodified lines
135135 cpp_objects = [a.split()[3][:-1] for a in typedefs]
136136 return cpp_objects
137137
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+ '''
139169 lib = {}
140170
141171 for o in cpp_objects:
@@ -205,7 +235,7 @@ def generate_external(header=header, output_path=output_path, usedouble=False, o · 63 unmodified lines
205235 c_declarations = get_c_declarations(header, usedouble=usedouble)
206236 cpp_objects = get_cpp_objects_from_c_declarations(c_declarations)
207237
208− lib = analyze_c_declarations(cpp_objects, c_declarations)
238+ lib = generate_lib_from_c_declarations(cpp_objects, c_declarations)
209239 # print_c_declarations_results(lib, c_declarations)
210240
211241 sources_list = []

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t