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
Kirill Smelkov
cython
Commits
fbed3e79
Commit
fbed3e79
authored
Jun 22, 2015
by
Ian Henriksen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test for calling stack allocated c++ object.
parent
d0e3a743
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
tests/run/cpp_call_stack_allocated.srctree
tests/run/cpp_call_stack_allocated.srctree
+42
-0
No files found.
tests/run/cpp_call_stack_allocated.srctree
0 → 100644
View file @
fbed3e79
# tag: cpp
"""
PYTHON setup.py build_ext --inplace
PYTHON -c "from call_stack_allocated import test; test()"
"""
######## setup.py ########
from distutils.core import setup
from Cython.Build import cythonize
setup(ext_modules=cythonize('*.pyx', language='c++'))
######## call.cpp ########
class wint {
public:
long long val;
wint() { val = 0; }
wint(long long val) { this->val = val; }
long long &operator()() { return this->val; }
};
######## call.pxd ########
cdef extern from "call.cpp" nogil:
cppclass wint:
long long val
wint()
wint(long long val)
long long& operator()()
######## call_stack_allocated.pyx ########
from call cimport wint
def test():
cdef wint a = wint(4)
cdef long long b = 3
b = a()
assert b == 4
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