25 _RE_API =
r'(?:GPRAPI|GRPCAPI|CENSUSAPI)([^;]*);'
29 for filename
in filenames:
30 with open(filename,
'r')
as f:
32 for m
in re.finditer(_RE_API, text):
33 api_declaration = re.sub(
'[ \r\n\t]+',
' ', m.group(1))
34 type_and_name, args_and_close = api_declaration.split(
'(', 1)
35 args = args_and_close[:args_and_close.rfind(
')')].strip()
36 last_space = type_and_name.rfind(
' ')
37 last_star = type_and_name.rfind(
'*')
38 type_end =
max(last_space, last_star)
39 return_type = type_and_name[0:type_end + 1].strip()
40 name = type_and_name[type_end + 1:].strip()
42 'return_type': return_type,
50 for root, dirnames, filenames
in os.walk(directory):
51 for filename
in fnmatch.filter(filenames,
'*.h'):
52 yield os.path.join(root, filename)
59 for lib
in dictionary[
'libs']:
60 if lib[
'name']
in [
'grpc',
'gpr']:
61 headers.extend(lib[
'public_headers'])
64 dictionary[
'c_apis'] = apis
67 if __name__ ==
'__main__':