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
164ae885
Commit
164ae885
authored
Jul 07, 2009
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make sure constructor/destructors are being called
parent
67164f05
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
tests/run/cpp_classes.pyx
tests/run/cpp_classes.pyx
+4
-0
tests/run/shapes.h
tests/run/shapes.h
+5
-1
No files found.
tests/run/cpp_classes.pyx
View file @
164ae885
__doc__
=
u"""
__doc__
=
u"""
>>> test_new_del()
>>> test_new_del()
(2, 2)
>>> test_rect_area(3, 4)
>>> test_rect_area(3, 4)
12.0
12.0
>>> test_square_area(15)
>>> test_square_area(15)
...
@@ -23,11 +24,14 @@ cdef extern from "shapes.h" namespace shapes:
...
@@ -23,11 +24,14 @@ cdef extern from "shapes.h" namespace shapes:
cdef
cppclass
Square
(
Rectangle
):
cdef
cppclass
Square
(
Rectangle
):
int
side
int
side
# __init__(int) # need function overloading
# __init__(int) # need function overloading
int
constructor_count
,
destructor_count
def
test_new_del
():
def
test_new_del
():
cdef
Rectangle
*
rect
=
new
Rectangle
(
10
,
20
)
cdef
Rectangle
*
rect
=
new
Rectangle
(
10
,
20
)
cdef
Circle
*
circ
=
new
Circle
(
15
)
cdef
Circle
*
circ
=
new
Circle
(
15
)
del
rect
,
circ
del
rect
,
circ
return
constructor_count
,
destructor_count
def
test_rect_area
(
w
,
h
):
def
test_rect_area
(
w
,
h
):
cdef
Rectangle
*
rect
=
new
Rectangle
(
w
,
h
)
cdef
Rectangle
*
rect
=
new
Rectangle
(
w
,
h
)
...
...
tests/run/shapes.h
View file @
164ae885
...
@@ -3,11 +3,15 @@
...
@@ -3,11 +3,15 @@
namespace
shapes
{
namespace
shapes
{
int
constructor_count
=
0
;
int
destructor_count
=
0
;
class
Shape
class
Shape
{
{
public:
public:
virtual
float
area
()
=
0
;
virtual
float
area
()
=
0
;
virtual
~
Shape
()
{
}
Shape
()
{
constructor_count
++
;
}
virtual
~
Shape
()
{
destructor_count
++
;
}
};
};
class
Rectangle
:
public
Shape
class
Rectangle
:
public
Shape
...
...
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