Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
f89e4e7d
Commit
f89e4e7d
authored
Aug 26, 2018
by
Hamdi Sahloul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support parsing C++11 `enum struct` and `enum class`
parent
dfa8467a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
9 deletions
+16
-9
gen_java.py
modules/java/generator/gen_java.py
+4
-0
gen2.py
modules/python/src2/gen2.py
+5
-0
hdr_parser.py
modules/python/src2/hdr_parser.py
+7
-9
No files found.
modules/java/generator/gen_java.py
View file @
f89e4e7d
...
...
@@ -425,6 +425,10 @@ class JavaWrapperGenerator(object):
def
add_enum
(
self
,
decl
):
# [ "enum cname", "", [], [] ]
enumname
=
decl
[
0
]
.
replace
(
"enum "
,
""
)
.
strip
()
self
.
enum_types
.
append
(
enumname
)
const_decls
=
decl
[
3
]
for
decl
in
const_decls
:
self
.
add_const
(
decl
)
def
add_func
(
self
,
decl
):
fi
=
FuncInfo
(
decl
,
namespaces
=
self
.
namespaces
)
...
...
modules/python/src2/gen2.py
View file @
f89e4e7d
...
...
@@ -916,6 +916,11 @@ class PythonWrapperGenerator(object):
def
add_enum
(
self
,
name
,
decl
):
enumname
=
normalize_class_name
(
name
)
self
.
enum_types
.
append
(
enumname
)
const_decls
=
decl
[
3
]
for
decl
in
const_decls
:
name
=
decl
[
0
]
self
.
add_const
(
name
.
replace
(
"const "
,
""
)
.
strip
(),
decl
)
def
add_func
(
self
,
decl
):
namespace
,
classes
,
barename
=
self
.
split_decl_name
(
decl
[
0
])
...
...
modules/python/src2/hdr_parser.py
View file @
f89e4e7d
...
...
@@ -634,8 +634,8 @@ class CppHeaderParser(object):
block_type
,
block_name
=
b
[
self
.
BLOCK_TYPE
],
b
[
self
.
BLOCK_NAME
]
if
block_type
in
[
"file"
,
"enum"
]:
continue
if
block_type
not
in
[
"struct"
,
"class"
,
"namespace"
]:
print
(
"Error at
%
d: there are non-valid entries in the current block stack "
%
(
self
.
lineno
,
self
.
block_stack
))
if
block_type
not
in
[
"struct"
,
"class"
,
"namespace"
,
"enum struct"
,
"enum class"
]:
print
(
"Error at
%
d: there are non-valid entries in the current block stack
%
s
"
%
(
self
.
lineno
,
self
.
block_stack
))
sys
.
exit
(
-
1
)
if
block_name
and
(
block_type
==
"namespace"
or
not
qualified_name
):
n
+=
block_name
+
"."
...
...
@@ -712,7 +712,7 @@ class CppHeaderParser(object):
return
stmt_type
,
classname
,
True
,
decl
if
stmt
.
startswith
(
"enum"
)
or
stmt
.
startswith
(
"namespace"
):
stmt_list
=
stmt
.
split
(
)
stmt_list
=
stmt
.
rsplit
(
" "
,
1
)
if
len
(
stmt_list
)
<
2
:
stmt_list
.
append
(
"<unnamed>"
)
return
stmt_list
[
0
],
stmt_list
[
1
],
True
,
None
...
...
@@ -720,10 +720,10 @@ class CppHeaderParser(object):
if
stmt
.
startswith
(
"extern"
)
and
"
\"
C
\"
"
in
stmt
:
return
"namespace"
,
""
,
True
,
None
if
end_token
==
"}"
and
context
==
"enum"
:
if
end_token
==
"}"
and
context
.
startswith
(
"enum"
)
:
decl
=
self
.
parse_enum
(
stmt
)
name
=
stack_top
[
self
.
BLOCK_NAME
]
return
"enum"
,
name
,
False
,
decl
return
context
,
name
,
False
,
decl
if
end_token
==
";"
and
stmt
.
startswith
(
"typedef"
):
# TODO: handle typedef's more intelligently
...
...
@@ -900,10 +900,8 @@ class CppHeaderParser(object):
docstring
=
docstring
.
strip
()
stmt_type
,
name
,
parse_flag
,
decl
=
self
.
parse_stmt
(
stmt
,
token
,
docstring
=
docstring
)
if
decl
:
if
stmt_type
==
"enum"
:
if
name
!=
"<unnamed>"
:
decls
.
append
([
"enum "
+
self
.
get_dotted_name
(
name
),
""
,
[],
[],
None
,
""
])
decls
.
extend
(
decl
)
if
stmt_type
.
startswith
(
"enum"
):
decls
.
append
([
stmt_type
+
" "
+
self
.
get_dotted_name
(
name
),
""
,
[],
decl
,
None
,
""
])
else
:
decls
.
append
(
decl
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment