Merge pull request #16061 from alalek:bindings_parser_support_simple_if

pull/16068/head^2
Alexander Alekhin 5 years ago
commit 36c9f7c3df
  1. 4
      modules/core/misc/java/src/cpp/core_manual.hpp
  2. 2
      modules/features2d/misc/java/src/cpp/features2d_manual.hpp
  3. 27
      modules/python/src2/hdr_parser.py

@ -9,7 +9,7 @@ CV_EXPORTS_W void setErrorVerbosity(bool verbose);
}
#if 0
#ifdef OPENCV_BINDINGS_PARSER
namespace cv
{
@ -30,4 +30,4 @@ CV_EXPORTS_W void min(InputArray src1, Scalar src2, OutputArray dst);
CV_EXPORTS_W void max(InputArray src1, Scalar src2, OutputArray dst);
}
#endif //0
#endif

@ -294,7 +294,7 @@ private:
Ptr<DescriptorExtractor> wrapped;
};
#if 0
#ifdef OPENCV_BINDINGS_PARSER
//DO NOT REMOVE! The block is required for sources parser
enum
{

@ -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:

Loading…
Cancel
Save