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
a29411ee
Commit
a29411ee
authored
6 years ago
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'release'
parents
aaaef0bf
51c75def
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
176 additions
and
45 deletions
+176
-45
CHANGES.rst
CHANGES.rst
+6
-0
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-1
tests/run/cpp_operators.pyx
tests/run/cpp_operators.pyx
+117
-44
tests/run/cpp_operators_helper.h
tests/run/cpp_operators_helper.h
+52
-0
No files found.
CHANGES.rst
View file @
a29411ee
...
@@ -59,6 +59,12 @@ Bugs fixed
...
@@ -59,6 +59,12 @@ Bugs fixed
*
Some
C
compiler
warnings
about
unused
memoryview
code
were
fixed
.
*
Some
C
compiler
warnings
about
unused
memoryview
code
were
fixed
.
Patch
by
Ho
Cheuk
Ting
.
(
Github
issue
#
2588
)
Patch
by
Ho
Cheuk
Ting
.
(
Github
issue
#
2588
)
*
A
C
compiler
warning
about
implicit
signed
/
unsigned
conversion
was
fixed
.
(
Github
issue
#
2729
)
*
Assignments
to
C
++
references
returned
by
``
operator
[]``
could
fail
to
compile
.
(
Github
issue
#
2671
)
*
The
power
operator
and
the
support
for
NumPy
math
functions
were
fixed
*
The
power
operator
and
the
support
for
NumPy
math
functions
were
fixed
in
Pythran
expressions
.
in
Pythran
expressions
.
Patch
by
Serge
Guelton
.
(
Github
issues
#
2702
,
#
2709
)
Patch
by
Serge
Guelton
.
(
Github
issues
#
2702
,
#
2709
)
...
...
This diff is collapsed.
Click to expand it.
Cython/Compiler/ExprNodes.py
View file @
a29411ee
...
@@ -4102,7 +4102,7 @@ class IndexNode(_IndexingBaseNode):
...
@@ -4102,7 +4102,7 @@ class IndexNode(_IndexingBaseNode):
# both exception handlers are the same.
# both exception handlers are the same.
translate_cpp_exception
(
code
,
self
.
pos
,
translate_cpp_exception
(
code
,
self
.
pos
,
"%s = %s;"
%
(
self
.
result
(),
rhs
.
result
()),
"%s = %s;"
%
(
self
.
result
(),
rhs
.
result
()),
self
.
result
()
if
self
.
lhs
.
is_pyobject
else
None
,
self
.
result
()
if
self
.
type
.
is_pyobject
else
None
,
self
.
exception_value
,
self
.
in_nogil_context
)
self
.
exception_value
,
self
.
in_nogil_context
)
else
:
else
:
code
.
putln
(
code
.
putln
(
...
...
This diff is collapsed.
Click to expand it.
tests/run/cpp_operators.pyx
View file @
a29411ee
...
@@ -9,48 +9,56 @@ from cython.operator cimport typeid, dereference as deref
...
@@ -9,48 +9,56 @@ from cython.operator cimport typeid, dereference as deref
from
libc.string
cimport
const_char
from
libc.string
cimport
const_char
from
libcpp
cimport
bool
from
libcpp
cimport
bool
cdef
out
(
s
,
result_type
=
None
):
cdef
out
(
s
,
result_type
=
None
):
print
'%s [%s]'
%
(
s
.
decode
(
'ascii'
),
result_type
)
print
'%s [%s]'
%
(
s
.
decode
(
'ascii'
),
result_type
)
cdef
iout
(
int
s
,
result_type
=
None
):
print
'%s [%s]'
%
(
s
,
result_type
)
cdef
extern
from
"cpp_operators_helper.h"
nogil
:
cdef
extern
from
"cpp_operators_helper.h"
nogil
:
cdef
cppclass
TestOps
:
cdef
cppclass
TestOps
:
const_char
*
operator
+
()
const_char
*
operator
+
()
except
+
const_char
*
operator
-
()
const_char
*
operator
-
()
except
+
const_char
*
operator
*
()
const_char
*
operator
*
()
except
+
const_char
*
operator
~
()
const_char
*
operator
~
()
except
+
const_char
*
operator
!
()
const_char
*
operator
!
()
except
+
# FIXME: using 'except +' here leads to wrong calls ???
const_char
*
operator
++
()
const_char
*
operator
++
()
const_char
*
operator
--
()
const_char
*
operator
--
()
const_char
*
operator
++
(
int
)
const_char
*
operator
++
(
int
)
const_char
*
operator
--
(
int
)
const_char
*
operator
--
(
int
)
const_char
*
operator
+
(
int
)
const_char
*
operator
+
(
int
)
except
+
const_char
*
operator
+
(
int
,
const
TestOps
&
)
const_char
*
operator
+
(
int
,
const
TestOps
&
)
except
+
const_char
*
operator
-
(
int
)
const_char
*
operator
-
(
int
)
except
+
const_char
*
operator
-
(
int
,
const
TestOps
&
)
const_char
*
operator
-
(
int
,
const
TestOps
&
)
except
+
const_char
*
operator
*
(
int
)
const_char
*
operator
*
(
int
)
except
+
# deliberately omitted operator* to test case where only defined outside class
# deliberately omitted operator* to test case where only defined outside class
const_char
*
operator
/
(
int
)
const_char
*
operator
/
(
int
)
except
+
const_char
*
operator
/
(
int
,
const
TestOps
&
)
const_char
*
operator
/
(
int
,
const
TestOps
&
)
except
+
const_char
*
operator
%
(
int
)
const_char
*
operator
%
(
int
)
except
+
const_char
*
operator
%
(
int
,
const
TestOps
&
)
const_char
*
operator
%
(
int
,
const
TestOps
&
)
except
+
const_char
*
operator
|
(
int
)
const_char
*
operator
|
(
int
)
except
+
const_char
*
operator
|
(
int
,
const
TestOps
&
)
const_char
*
operator
|
(
int
,
const
TestOps
&
)
except
+
const_char
*
operator
&
(
int
)
const_char
*
operator
&
(
int
)
except
+
const_char
*
operator
&
(
int
,
const
TestOps
&
)
const_char
*
operator
&
(
int
,
const
TestOps
&
)
except
+
const_char
*
operator
^
(
int
)
const_char
*
operator
^
(
int
)
except
+
const_char
*
operator
^
(
int
,
const
TestOps
&
)
const_char
*
operator
^
(
int
,
const
TestOps
&
)
except
+
const_char
*
operator
,(
int
)
const_char
*
operator
,(
int
)
except
+
const_char
*
operator
,(
int
,
const
TestOps
&
)
const_char
*
operator
,(
int
,
const
TestOps
&
)
except
+
const_char
*
operator
<<
(
int
)
const_char
*
operator
<<
(
int
)
except
+
const_char
*
operator
<<
(
int
,
const
TestOps
&
)
const_char
*
operator
<<
(
int
,
const
TestOps
&
)
except
+
const_char
*
operator
>>
(
int
)
const_char
*
operator
>>
(
int
)
except
+
const_char
*
operator
>>
(
int
,
const
TestOps
&
)
const_char
*
operator
>>
(
int
,
const
TestOps
&
)
except
+
# FIXME: using 'except +' here leads to invalid C++ code ???
const_char
*
operator
==
(
int
)
const_char
*
operator
==
(
int
)
const_char
*
operator
!=
(
int
)
const_char
*
operator
!=
(
int
)
const_char
*
operator
>=
(
int
)
const_char
*
operator
>=
(
int
)
...
@@ -58,25 +66,73 @@ cdef extern from "cpp_operators_helper.h" nogil:
...
@@ -58,25 +66,73 @@ cdef extern from "cpp_operators_helper.h" nogil:
const_char
*
operator
>
(
int
)
const_char
*
operator
>
(
int
)
const_char
*
operator
<
(
int
)
const_char
*
operator
<
(
int
)
const_char
*
operator
[](
int
)
const_char
*
operator
[](
int
)
except
+
const_char
*
operator
()(
int
)
const_char
*
operator
()(
int
)
except
+
# Defining the operator outside the class does work
# Defining the operator outside the class does work
# but doesn't help when importing from pxd files
# but doesn't help when importing from pxd files
# (they don't get imported)
# (they don't get imported)
const_char
*
operator
+
(
float
,
const
TestOps
&
)
const_char
*
operator
+
(
float
,
const
TestOps
&
)
except
+
# deliberately omitted operator- to test case where only defined in class
# deliberately omitted operator- to test case where only defined in class
const_char
*
operator
*
(
float
,
const
TestOps
&
)
const_char
*
operator
*
(
float
,
const
TestOps
&
)
except
+
const_char
*
operator
/
(
float
,
const
TestOps
&
)
const_char
*
operator
/
(
float
,
const
TestOps
&
)
except
+
const_char
*
operator
%
(
float
,
const
TestOps
&
)
const_char
*
operator
%
(
float
,
const
TestOps
&
)
except
+
const_char
*
operator
|
(
float
,
const
TestOps
&
)
const_char
*
operator
|
(
float
,
const
TestOps
&
)
except
+
const_char
*
operator
&
(
float
,
const
TestOps
&
)
const_char
*
operator
&
(
float
,
const
TestOps
&
)
except
+
const_char
*
operator
^
(
float
,
const
TestOps
&
)
const_char
*
operator
^
(
float
,
const
TestOps
&
)
except
+
const_char
*
operator
,(
float
,
const
TestOps
&
)
const_char
*
operator
,(
float
,
const
TestOps
&
)
except
+
const_char
*
operator
<<
(
float
,
const
TestOps
&
)
const_char
*
operator
<<
(
float
,
const
TestOps
&
)
except
+
const_char
*
operator
>>
(
float
,
const
TestOps
&
)
const_char
*
operator
>>
(
float
,
const
TestOps
&
)
except
+
cdef
cppclass
RefTestOps
:
int
&
operator
+
()
except
+
int
&
operator
-
()
except
+
int
&
operator
*
()
except
+
int
&
operator
~
()
except
+
int
&
operator
!
()
except
+
int
&
operator
++
()
except
+
int
&
operator
--
()
except
+
int
&
operator
++
(
int
)
except
+
int
&
operator
--
(
int
)
except
+
int
&
operator
+
(
int
)
except
+
int
&
operator
+
(
int
,
const
TestOps
&
)
except
+
int
&
operator
-
(
int
)
except
+
int
&
operator
-
(
int
,
const
TestOps
&
)
except
+
int
&
operator
*
(
int
)
except
+
# deliberately omitted operator* to test case where only defined outside class
int
&
operator
/
(
int
)
except
+
int
&
operator
/
(
int
,
const
TestOps
&
)
except
+
int
&
operator
%
(
int
)
except
+
int
&
operator
%
(
int
,
const
TestOps
&
)
except
+
int
&
operator
|
(
int
)
except
+
int
&
operator
|
(
int
,
const
TestOps
&
)
except
+
int
&
operator
&
(
int
)
except
+
int
&
operator
&
(
int
,
const
TestOps
&
)
except
+
int
&
operator
^
(
int
)
except
+
int
&
operator
^
(
int
,
const
TestOps
&
)
except
+
int
&
operator
,(
int
)
except
+
int
&
operator
,(
int
,
const
TestOps
&
)
except
+
int
&
operator
<<
(
int
)
except
+
int
&
operator
<<
(
int
,
const
TestOps
&
)
except
+
int
&
operator
>>
(
int
)
except
+
int
&
operator
>>
(
int
,
const
TestOps
&
)
except
+
int
&
operator
==
(
int
)
except
+
int
&
operator
!=
(
int
)
except
+
int
&
operator
>=
(
int
)
except
+
int
&
operator
<=
(
int
)
except
+
int
&
operator
>
(
int
)
except
+
int
&
operator
<
(
int
)
except
+
int
&
operator
[](
int
)
except
+
int
&
operator
()(
int
)
except
+
cdef
cppclass
TruthClass
:
cdef
cppclass
TruthClass
:
TruthClass
()
TruthClass
()
...
@@ -84,9 +140,11 @@ cdef extern from "cpp_operators_helper.h" nogil:
...
@@ -84,9 +140,11 @@ cdef extern from "cpp_operators_helper.h" nogil:
bool
operator
bool
()
bool
operator
bool
()
bool
value
bool
value
cdef
cppclass
TruthSubClass
(
TruthClass
):
cdef
cppclass
TruthSubClass
(
TruthClass
):
pass
pass
def
test_unops
():
def
test_unops
():
"""
"""
>>> test_unops()
>>> test_unops()
...
@@ -233,6 +291,7 @@ def test_cmp():
...
@@ -233,6 +291,7 @@ def test_cmp():
out
(
t
[
0
]
<
1
,
typeof
(
t
[
0
]
<
1
))
out
(
t
[
0
]
<
1
,
typeof
(
t
[
0
]
<
1
))
del
t
del
t
def
test_index_call
():
def
test_index_call
():
"""
"""
>>> test_index_call()
>>> test_index_call()
...
@@ -244,6 +303,20 @@ def test_index_call():
...
@@ -244,6 +303,20 @@ def test_index_call():
out
(
t
[
0
](
100
),
typeof
(
t
[
0
](
100
)))
out
(
t
[
0
](
100
),
typeof
(
t
[
0
](
100
)))
del
t
del
t
def
test_index_assignment
():
"""
>>> test_index_assignment()
0 [int &]
123 [int [&]]
"""
cdef
RefTestOps
*
t
=
new
RefTestOps
()
iout
(
t
[
0
][
100
],
typeof
(
t
[
0
][
100
]))
t
[
0
][
99
]
=
123
iout
(
t
[
0
](
100
),
typeof
(
t
[
0
](
100
)))
del
t
def
test_bool_op
():
def
test_bool_op
():
"""
"""
>>> test_bool_op()
>>> test_bool_op()
...
...
This diff is collapsed.
Click to expand it.
tests/run/cpp_operators_helper.h
View file @
a29411ee
...
@@ -76,6 +76,58 @@ NONMEMBER_BIN_OP2(&)
...
@@ -76,6 +76,58 @@ NONMEMBER_BIN_OP2(&)
NONMEMBER_BIN_OP2
(
^
)
NONMEMBER_BIN_OP2
(
^
)
NONMEMBER_BIN_OP2
(
COMMA
)
NONMEMBER_BIN_OP2
(
COMMA
)
/* RefTestOps */
#define REF_UN_OP(op) int& operator op () { return value; }
#define REF_POST_UN_OP(op) int& operator op (int x) { x++; return value; }
#define REF_BIN_OP(op) int& operator op (int x) { x++; return value; }
class
RefTestOps
{
int
value
=
0
;
public:
REF_UN_OP
(
-
);
REF_UN_OP
(
+
);
REF_UN_OP
(
*
);
REF_UN_OP
(
~
);
REF_UN_OP
(
!
);
REF_UN_OP
(
&
);
REF_UN_OP
(
++
);
REF_UN_OP
(
--
);
REF_POST_UN_OP
(
++
);
REF_POST_UN_OP
(
--
);
REF_BIN_OP
(
+
);
REF_BIN_OP
(
-
);
REF_BIN_OP
(
*
);
REF_BIN_OP
(
/
);
REF_BIN_OP
(
%
);
REF_BIN_OP
(
<<
);
REF_BIN_OP
(
>>
);
REF_BIN_OP
(
|
);
REF_BIN_OP
(
&
);
REF_BIN_OP
(
^
);
REF_BIN_OP
(
COMMA
);
REF_BIN_OP
(
==
);
REF_BIN_OP
(
!=
);
REF_BIN_OP
(
<=
);
REF_BIN_OP
(
<
);
REF_BIN_OP
(
>=
);
REF_BIN_OP
(
>
);
REF_BIN_OP
([]);
REF_BIN_OP
(());
};
/* TruthClass */
class
TruthClass
{
class
TruthClass
{
public:
public:
TruthClass
()
:
value
(
false
)
{}
TruthClass
()
:
value
(
false
)
{}
...
...
This diff is collapsed.
Click to expand it.
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