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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
d4a39839
Commit
d4a39839
authored
Mar 11, 2019
by
gsamain
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cypclass operator overloading
parent
ae6315f6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
3 deletions
+40
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+14
-2
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+4
-1
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+22
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
d4a39839
...
...
@@ -11383,6 +11383,8 @@ class NumBinopNode(BinopNode):
result1
,
result2
=
self
.
operand1
.
pythran_result
(),
self
.
operand2
.
pythran_result
()
else
:
result1
,
result2
=
self
.
operand1
.
result
(),
self
.
operand2
.
result
()
if
self
.
operand1
.
type
.
is_cyp_class
:
result1
=
'*'
+
result1
return
"(%s %s %s)"
%
(
result1
,
self
.
operator
,
result2
)
else
:
func
=
self
.
type
.
binary_op
(
self
.
operator
)
...
...
@@ -11701,6 +11703,8 @@ class DivNode(NumBinopNode):
op1
=
self
.
type
.
cast_code
(
op1
)
if
self
.
type
!=
self
.
operand2
.
type
:
op2
=
self
.
type
.
cast_code
(
op2
)
if
self
.
operand1
.
type
.
is_cyp_class
:
op1
=
"*(%s)"
%
op1
return
"(%s / %s)"
%
(
op1
,
op2
)
else
:
return
"__Pyx_div_%s(%s, %s)"
%
(
...
...
@@ -11788,8 +11792,11 @@ class ModNode(DivNode):
self
.
operand1
.
result
(),
self
.
operand2
.
result
())
else
:
op1
=
self
.
operand1
.
result
()
if
self
.
operand1
.
type
.
is_cyp_class
:
op1
=
'*'
+
op1
return
"(%s %% %s)"
%
(
self
.
operand1
.
result
()
,
op1
,
self
.
operand2
.
result
())
else
:
return
"__Pyx_mod_%s(%s, %s)"
%
(
...
...
@@ -11856,9 +11863,12 @@ class PowNode(NumBinopNode):
return
operand
.
result
()
else
:
return
self
.
type
.
cast_code
(
operand
.
result
())
op1
=
typecast
(
self
.
operand1
)
if
self
.
operand1
.
type
.
is_cyp_class
:
op1
=
'*'
+
op1
return
"%s(%s, %s)"
%
(
self
.
pow_func
,
typecast
(
self
.
operand1
)
,
op1
,
typecast
(
self
.
operand2
))
def
py_operation_function
(
self
,
code
):
...
...
@@ -12805,6 +12815,8 @@ class PrimaryCmpNode(ExprNode, CmpNode):
result1
,
result2
=
operand1
.
pythran_result
(),
operand2
.
pythran_result
()
else
:
result1
,
result2
=
operand1
.
result
(),
operand2
.
result
()
if
operand1
.
type
.
is_cyp_class
:
result1
=
'*'
+
result1
if
self
.
is_memslice_nonecheck
:
if
operand1
.
type
.
is_memoryviewslice
:
result1
=
"((PyObject *) %s.memview)"
%
result1
...
...
Cython/Compiler/Nodes.py
View file @
d4a39839
...
...
@@ -5908,7 +5908,10 @@ class InPlaceAssignmentNode(AssignmentNode):
else
:
# C++
# TODO: make sure overload is declared
code
.
putln
(
"%s %s= %s;"
%
(
lhs
.
result
(),
c_op
,
rhs
.
result
()))
l_op
=
lhs
.
result
()
if
lhs
.
type
.
is_cyp_class
:
l_op
=
'*'
+
l_op
code
.
putln
(
"%s %s= %s;"
%
(
l_op
,
c_op
,
rhs
.
result
()))
lhs
.
generate_subexpr_disposal_code
(
code
)
lhs
.
free_subexpr_temps
(
code
)
rhs
.
generate_disposal_code
(
code
)
...
...
Cython/Compiler/Symtab.py
View file @
d4a39839
...
...
@@ -2424,6 +2424,28 @@ class CppClassScope(Scope):
default_constructor
=
None
type
=
None
operator_table
=
{
'__add__'
:
'+'
,
'__iadd__'
:
'+='
,
'__sub__'
:
'-'
,
'__isub__'
:
'-='
,
'__mul__'
:
'*'
,
'__imul__'
:
'*='
,
'__div__'
:
'/'
,
'__idiv__'
:
'/='
,
'__mod__'
:
'%'
,
'__imod__'
:
'%='
,
'__lshift__'
:
'<<'
,
'__ilshift__'
:
'<<='
,
'__rshift__'
:
'>>'
,
'__irshift__'
:
'>>='
,
'__and__'
:
'&'
,
'__iand__'
:
'&='
,
'__or__'
:
'|'
,
'__ior__'
:
'|='
,
'__xor__'
:
'^'
,
'__ixor__'
:
'^='
,
'__neg__'
:
'-'
,
'__pos__'
:
'+'
,
'__invert__'
:
'~'
,
'__eq__'
:
'=='
,
'__ne__'
:
'!='
,
'__lt__'
:
'<'
,
'__gt__'
:
'>'
,
'__le__'
:
'<='
,
'__ge__'
:
'>='
}
def
__init__
(
self
,
name
,
outer_scope
,
templates
=
None
):
Scope
.
__init__
(
self
,
name
,
outer_scope
,
None
)
self
.
directives
=
outer_scope
.
directives
...
...
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