39 with open(os.path.join(dirname, filename))
as f:
40 contents = f.readlines()
41 look_for_function_name =
False
44 if look_for_function_name:
45 look_for_function_name =
False
46 split_line = line.rstrip().
split(
' ')
50 if not line.startswith(
'FPDF_EXPORT '):
54 split_line = line.rstrip().
split(
' ')
55 callconv_index = split_line.index(
'FPDF_CALLCONV')
56 assert callconv_index >= 2
57 if callconv_index + 1 == len(split_line):
58 look_for_function_name =
True
61 functions.append(
_FindFunction(split_line[callconv_index + 1], filename))
84 chk_regex = re.compile(
'^ CHK\((.*)\);\n$')
85 file_regex = re.compile(
'^ //.*\.h\n$')
86 with open(api_test_path)
as f:
87 contents = f.readlines()
89 functions_in_file = []
91 if (file_regex.match(line)):
92 functions.append(functions_in_file)
93 functions_in_file = []
94 match = chk_regex.match(line)
96 functions_in_file.append(match.groups()[0])
97 functions.append(functions_in_file)
116 script_abspath = os.path.abspath(__file__)
117 src_path = os.path.dirname(os.path.dirname(os.path.dirname(script_abspath)))
120 api_test_relative_path = os.path.join(
'fpdfsdk',
'fpdf_view_c_api_test.c')
121 api_test_path = os.path.join(src_path, api_test_relative_path)
124 unsorted_functions =
set()
125 for functions
in test_functions_per_section:
129 'Found CHKs that are not in alphabetical order within each section in %s'
131 result = result
and check
135 'Found duplicate functions in public headers')
136 result = result
and check
139 function
for functions
in test_functions_per_section
140 for function
in functions
144 'Found duplicate functions in API test')
145 result = result
and check
147 public_functions_set =
set(public_functions)
148 test_functions_set =
set(test_functions)
149 not_tested = public_functions_set.difference(test_functions_set)
151 result = result
and check
152 non_existent = test_functions_set.difference(public_functions_set)
154 result = result
and check
157 print(
'Some checks failed. Make sure %s is in sync with the public API '
158 'headers.' % api_test_relative_path)