|
|
|
@ -793,6 +793,7 @@ class CppHeaderParser(object): |
|
|
|
|
COMMENT = 1 # inside a multi-line comment |
|
|
|
|
DIRECTIVE = 2 # inside a multi-line preprocessor directive |
|
|
|
|
DOCSTRING = 3 # inside a multi-line docstring |
|
|
|
|
DIRECTIVE_IF_0 = 4 # inside a '#if 0' directive |
|
|
|
|
|
|
|
|
|
state = SCAN |
|
|
|
|
|
|
|
|
@ -802,6 +803,8 @@ class CppHeaderParser(object): |
|
|
|
|
self.lineno = 0 |
|
|
|
|
self.wrap_mode = wmode |
|
|
|
|
|
|
|
|
|
depth_if_0 = 0 |
|
|
|
|
|
|
|
|
|
for l0 in linelist: |
|
|
|
|
self.lineno += 1 |
|
|
|
|
#print(state, self.lineno, l0) |
|
|
|
@ -813,8 +816,28 @@ class CppHeaderParser(object): |
|
|
|
|
# fall through to the if state == DIRECTIVE check |
|
|
|
|
|
|
|
|
|
if state == DIRECTIVE: |
|
|
|
|
if not l.endswith("\\"): |
|
|
|
|
state = SCAN |
|
|
|
|
if l.endswith("\\"): |
|
|
|
|
continue |
|
|
|
|
state = SCAN |
|
|
|
|
l = re.sub(r'//(.+)?', '', l).strip() # drop // comment |
|
|
|
|
if l == '#if 0' or l == '#if defined(__OPENCV_BUILD)' or l == '#ifdef __OPENCV_BUILD': |
|
|
|
|
state = DIRECTIVE_IF_0 |
|
|
|
|
depth_if_0 = 1 |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
if state == DIRECTIVE_IF_0: |
|
|
|
|
if l.startswith('#'): |
|
|
|
|
l = l[1:].strip() |
|
|
|
|
if l.startswith("if"): |
|
|
|
|
depth_if_0 += 1 |
|
|
|
|
continue |
|
|
|
|
if l.startswith("endif"): |
|
|
|
|
depth_if_0 -= 1 |
|
|
|
|
if depth_if_0 == 0: |
|
|
|
|
state = SCAN |
|
|
|
|
else: |
|
|
|
|
# print('---- {:30s}:{:5d}: {}'.format(hname[-30:], self.lineno, l)) |
|
|
|
|
pass |
|
|
|
|
continue |
|
|
|
|
|
|
|
|
|
if state == COMMENT: |
|
|
|
|