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
193dc29a
Commit
193dc29a
authored
Jun 23, 2015
by
scoder
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #399 from insertinterestingnamehere/assignment
Enable overloading the assignment operator.
parents
c39b0766
7a1de56a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
1 deletion
+44
-1
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+1
-1
tests/run/cpp_assignment_overload.srctree
tests/run/cpp_assignment_overload.srctree
+43
-0
No files found.
Cython/Compiler/Parsing.py
View file @
193dc29a
...
...
@@ -2547,7 +2547,7 @@ supported_overloaded_operators = cython.declare(set, set([
'+'
,
'-'
,
'*'
,
'/'
,
'%'
,
'++'
,
'--'
,
'~'
,
'|'
,
'&'
,
'^'
,
'<<'
,
'>>'
,
','
,
'=='
,
'!='
,
'>='
,
'>'
,
'<='
,
'<'
,
'[]'
,
'()'
,
'!'
,
'[]'
,
'()'
,
'!'
,
'='
]))
def
p_c_simple_declarator
(
s
,
ctx
,
empty
,
is_type
,
cmethod_flag
,
...
...
tests/run/cpp_assignment_overload.srctree
0 → 100644
View file @
193dc29a
# tag: cpp
"""
PYTHON setup.py build_ext --inplace
PYTHON -c "from assignment_overload import test; test()"
"""
######## setup.py ########
from distutils.core import setup
from Cython.Build import cythonize
setup(ext_modules=cythonize("*.pyx", language='c++'))
######## assign.cpp ########
class wrapped_int {
public:
long long val;
wrapped_int() { val = 0; }
wrapped_int(long long val) { this->val = val; }
wrapped_int &operator=(const wrapped_int &other) {
this->val = other.val;
return *this;
}
};
######## assign.pxd ########
cdef extern from "assign.cpp" nogil:
cppclass wrapped_int:
long long val
wrapped_int()
wrapped_int(long long val)
wrapped_int& operator=(const wrapped_int &other)
######## assignment_overload.pyx ########
from assign cimport wrapped_int
def test():
cdef wrapped_int a=wrapped_int(2), b=wrapped_int(3)
a = b
assert &a != &b
assert a.val == b.val
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