History

gen_external.py : rename cpp_output to c_declarations make pre processing parsing part of get_cpp_objects a distinct function get_c_declarations

Martin Hermant committed 9 years ago

Commit 150ec2d1 parent 56748331 file · +16 −12Browse files

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

Unified · Split

python/lib/gen_external.py+16−12
@@ -75,7 +75,10 @@ def get_preprocessor(): · 74 unmodified lines
7575 cpp_cmd += ['-x', 'c'] # force C language (emcc defaults to c++)
7676 return cpp_cmd
7777
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+ '''
7982 cpp_cmd = get_preprocessor()
8083
8184 macros = [('AUBIO_UNSTABLE', 1)]
@@ -118,14 +121,14 @@ def get_cpp_objects(header=header, usedouble=False): · 36 unmodified lines
118121 else:
119122 i += 1
120123
121− typedefs = filter(lambda y: y.startswith ('typedef struct _aubio'), cpp_output)
124+ return cpp_output
122125
126+def get_cpp_objects_from_c_declarations(c_declarations):
127+ typedefs = filter(lambda y: y.startswith ('typedef struct _aubio'), c_declarations)
123128 cpp_objects = [a.split()[3][:-1] for a in typedefs]
129+ return cpp_objects
124130
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):
129132 lib = {}
130133
131134 for o in cpp_objects:
@@ -144,7 +147,7 @@ def analyze_cpp_output(cpp_objects, cpp_output): · 12 unmodified lines
144147 lib[shortname]['shortname'] = shortname
145148 valid_funcname_part = ['_'+longname,longname+'_']
146149
147− for fn in cpp_output:
150+ for fn in c_declarations:
148151 func_name = fn.split('(')[0].strip().split(' ')[1:]
149152 if func_name:
150153 func_name = func_name[-1]
@@ -169,8 +172,8 @@ def analyze_cpp_output(cpp_objects, cpp_output): · 18 unmodified lines
169172 lib[shortname]['other'].append(fn)
170173 return lib
171174
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:
174177 found = 0
175178 for o in lib:
176179 for family in lib[o]:
@@ -193,10 +196,11 @@ def generate_external(header=header, output_path=output_path, usedouble=False, o · 16 unmodified lines
193196 if not os.path.isdir(output_path): os.mkdir(output_path)
194197 elif not overwrite: return sorted(glob.glob(os.path.join(output_path, '*.c')))
195198
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)
197201
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)
200204
201205 sources_list = []
202206 try:

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