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
1b78e1ae
Commit
1b78e1ae
authored
Dec 15, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Work on C++ operators
parent
16bf4f76
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
2 deletions
+12
-2
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+6
-1
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+4
-0
tests/compile/cpp_operators.pyx
tests/compile/cpp_operators.pyx
+2
-1
No files found.
Cython/Compiler/ExprNodes.py
View file @
1b78e1ae
...
...
@@ -4281,10 +4281,15 @@ class NumBinopNode(BinopNode):
type2
=
type2
.
base_type
entry
=
env
.
lookup
(
type1
.
name
)
function
=
entry
.
type
.
scope
.
lookup
(
"operator%s"
%
self
.
operator
)
if
function
is
not
None
:
operands
=
[
self
.
operand2
]
else
:
function
=
env
.
lookup
(
"operator%s"
%
self
.
operator
)
operands
=
[
self
.
operand1
,
self
.
operand2
]
if
not
function
:
self
.
type_error
()
return
entry
=
PyrexTypes
.
best_match
(
[
self
.
operand1
,
self
.
operand2
]
,
function
.
all_alternatives
(),
self
.
pos
)
entry
=
PyrexTypes
.
best_match
(
operands
,
function
.
all_alternatives
(),
self
.
pos
)
if
entry
is
None
:
self
.
type
=
PyrexTypes
.
error_type
self
.
result_code
=
"<error>"
...
...
Cython/Compiler/Parsing.py
View file @
1b78e1ae
...
...
@@ -2008,6 +2008,10 @@ def p_c_simple_declarator(s, ctx, empty, is_type, cmethod_flag,
cname
=
None
if
cname
is
None
and
ctx
.
namespace
is
not
None
:
cname
=
ctx
.
namespace
+
"::"
+
name
if
name
==
'operator'
and
ctx
.
visibility
==
'extern'
:
# TODO: This needs to be more strict...
name
+=
s
.
sy
s
.
next
()
result
=
Nodes
.
CNameDeclaratorNode
(
pos
,
name
=
name
,
cname
=
cname
,
default
=
rhs
)
result
.
calling_convention
=
calling_convention
...
...
tests/compile/cpp_operators.pyx
View file @
1b78e1ae
cdef
extern
from
"operators.h"
:
cdef
cppclass
Operators
:
__init__
(
int
)
Operators
(
int
)
Operators
operator
+
(
Operators
)
Operators
__add__
(
Operators
,
Operators
)
Operators
__sub__
(
Operators
,
Operators
)
Operators
__mul__
(
Operators
,
Operators
)
...
...
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