Debian Codegraph @

vendor/onigmo-source/win32/makedef.py

raw
1 #!/usr/bin/env python
2
3 from __future__ import print_function
4 import re
5
6 header_files = (
7 "onigmo.h", "regenc.h",
8 "onigmognu.h", "onigmoposix.h"
9 )
10
11 exclude_symbols = [
12 "OnigEncodingKOI8",
13
14 # USE_UPPER_CASE_TABLE
15 "OnigEncAsciiToUpperCaseTable",
16 "OnigEncISO_8859_1_ToUpperCaseTable",
17 ]
18
19 features = {
20 "USE_VARIABLE_META_CHARS": ("onig_set_meta_char",),
21 "USE_CAPTURE_HISTORY": ("onig_get_capture_tree",)
22 }
23
24 for v in features.values():
25 exclude_symbols += list(v)
26
27 # Check if the features are enabled
28 with open("regint.h", "r") as f:
29 e = set()
30 for line in f:
31 for k, v in features.items():
32 if re.match(r"^#define\s+" + k + r"\b", line):
33 e |= set(v)
34 exclude_symbols = list(set(exclude_symbols) - e)
35
36 symbols = set()
37
38 rx1 = re.compile("(ONIG_EXTERN.*)$")
39 rx2 = re.compile(r"(\w+)( +PV?_\(\(.*\)\)|\[.*\])?;\s*(/\*.*\*/)?$")
40 for filename in header_files:
41 with open(filename, "r") as f:
42 for line in f:
43 m = rx1.match(line)
44 if not m:
45 continue
46 s = m.group(1)
47 if s[-1] != ';':
48 s += ' ' + next(f)
49 m2 = rx2.search(s)
50 if m2 and (not m2.group(1) in exclude_symbols):
51 symbols.add(m2.group(1))
52
53 print('EXPORTS')
54 for s in sorted(symbols):
55 print('\t' + s)