1 # XXX (F841): local variable 'li' is assigned to but never used
3 from __future__ import print_function
4 from __future__ import unicode_literals
13 def get_td_from_function_signature(line, file, num):
14 left_paren = line.find('(')
17 li = line[left_paren:]
18 right_paren = line.find(')')
19 if right_paren > 0 and right_paren > left_paren and line[right_paren:].find('(') >= 0:
20 fname = line[:right_paren]
21 fname = fname.lstrip(' ').lstrip('*').lstrip(' ').rstrip(' ')
24 print("from {0}:{1}".format(file, num))
25 print("-T {0}".format(fname))
28 def get_td_from_simple_type(line, file, num):
29 line = line.rstrip(' ').rstrip('\t').rstrip(' ').rstrip('\t')
30 right_space = line.rfind(' ')
31 right_tab = line.rfind('\t')
32 sep = right_tab if right_tab > right_space else right_space
35 tname = tname.lstrip('*')
38 print("from {0}:{1}".format(file, num))
39 print("-T {0}".format(tname))
42 def find_typedefs(file):
43 with open(file, 'rb') as f:
49 for i, l in enumerate(data.splitlines(False)):
50 # Don't try to be too smart: only count lines that begin with 'typedef '
51 l = l.rstrip(' ').rstrip('\t')
55 if l[:8] != 'typedef ':
59 if l[8:].lstrip(' ').lstrip('\t')[:6] == 'struct':
62 leftcbrace = l.find('{')
65 td_line.append(l[:leftcbrace])
66 l = l[leftcbrace + 1:]
68 rightcbrace = l.rfind('}')
72 td_line.append(l[rightcbrace + 1:])
75 if len(l) > 0 and l[-1] == ';' and(not td_struct or td_level == 0):
76 td_line = ' '.join(td_line)
77 td_line = td_line[:-1]
79 if td_line[-1] == ')':
80 get_td_from_function_signature(td_line, file, i)
82 get_td_from_simple_type(td_line, file, i)
90 for dirpath, dirs, files in os.walk(d):
92 if re.match(r'(?!lt_).+\.(c|cc|h)$', f):
93 file = os.path.join(dirpath, f)
97 if __name__ == '__main__':
98 if len(sys.argv[1:]) == 0: