Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
1479a021
Commit
1479a021
authored
Jul 22, 2010
by
Lisandro Dalcin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix C++ namespace for enum items
parent
333b8c79
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
6 deletions
+43
-6
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+8
-6
tests/compile/cpp_enums.h
tests/compile/cpp_enums.h
+11
-0
tests/compile/cpp_enums.pyx
tests/compile/cpp_enums.pyx
+24
-0
No files found.
Cython/Compiler/Parsing.py
View file @
1479a021
...
...
@@ -2216,34 +2216,36 @@ def p_c_enum_definition(s, pos, ctx):
s
.
expect
(
':'
)
items
=
[]
if
s
.
sy
!=
'NEWLINE'
:
p_c_enum_line
(
s
,
items
)
p_c_enum_line
(
s
,
ctx
,
items
)
else
:
s
.
next
()
# 'NEWLINE'
s
.
expect_indent
()
while
s
.
sy
not
in
(
'DEDENT'
,
'EOF'
):
p_c_enum_line
(
s
,
items
)
p_c_enum_line
(
s
,
ctx
,
items
)
s
.
expect_dedent
()
return
Nodes
.
CEnumDefNode
(
pos
,
name
=
name
,
cname
=
cname
,
items
=
items
,
typedef_flag
=
ctx
.
typedef_flag
,
visibility
=
ctx
.
visibility
,
in_pxd
=
ctx
.
level
==
'module_pxd'
)
def
p_c_enum_line
(
s
,
items
):
def
p_c_enum_line
(
s
,
ctx
,
items
):
if
s
.
sy
!=
'pass'
:
p_c_enum_item
(
s
,
items
)
p_c_enum_item
(
s
,
ctx
,
items
)
while
s
.
sy
==
','
:
s
.
next
()
if
s
.
sy
in
(
'NEWLINE'
,
'EOF'
):
break
p_c_enum_item
(
s
,
items
)
p_c_enum_item
(
s
,
ctx
,
items
)
else
:
s
.
next
()
s
.
expect_newline
(
"Syntax error in enum item list"
)
def
p_c_enum_item
(
s
,
items
):
def
p_c_enum_item
(
s
,
ctx
,
items
):
pos
=
s
.
position
()
name
=
p_ident
(
s
)
cname
=
p_opt_cname
(
s
)
if
cname
is
None
and
ctx
.
namespace
is
not
None
:
cname
=
ctx
.
namespace
+
"::"
+
name
value
=
None
if
s
.
sy
==
'='
:
s
.
next
()
...
...
tests/compile/cpp_enums.h
0 → 100644
View file @
1479a021
enum
Enum1
{
Item1
,
Item2
};
namespace
Namespace1
{
enum
Enum2
{
Item3
,
Item4
};
}
tests/compile/cpp_enums.pyx
0 → 100644
View file @
1479a021
cdef
extern
from
"cpp_enums.h"
:
cdef
enum
Enum1
:
Item1
Item2
a
=
Item1
b
=
Item2
cdef
Enum1
x
,
y
x
=
Item1
y
=
Item2
cdef
extern
from
"cpp_enums.h"
namespace
"Namespace1"
:
cdef
enum
Enum2
:
Item3
Item4
c
=
Item3
d
=
Item4
cdef
Enum2
z
,
w
z
=
Item3
w
=
Item4
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