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
4a57c2c3
Commit
4a57c2c3
authored
Jul 03, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
declare C++ default constructor 'except +', fix constructor declarations in test
parent
66204a91
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
5 deletions
+17
-5
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+1
-1
tests/run/cpp_classes.pyx
tests/run/cpp_classes.pyx
+15
-4
tests/run/shapes.h
tests/run/shapes.h
+1
-0
No files found.
Cython/Compiler/ExprNodes.py
View file @
4a57c2c3
...
...
@@ -1329,7 +1329,7 @@ class NewExprNode(AtomicExprNode):
self
.
cpp_check
(
env
)
constructor
=
type
.
scope
.
lookup
(
u'<init>'
)
if
constructor
is
None
:
return_type
=
PyrexTypes
.
CFuncType
(
type
,
[])
return_type
=
PyrexTypes
.
CFuncType
(
type
,
[]
,
exception_check
=
'+'
)
return_type
=
PyrexTypes
.
CPtrType
(
return_type
)
type
.
scope
.
declare_cfunction
(
u'<init>'
,
return_type
,
self
.
pos
)
constructor
=
type
.
scope
.
lookup
(
u'<init>'
)
...
...
tests/run/cpp_classes.pyx
View file @
4a57c2c3
...
...
@@ -7,19 +7,19 @@ cdef extern from "shapes.h" namespace "shapes":
cdef
cppclass
Circle
(
Shape
):
int
radius
Circle
(
int
)
Circle
(
int
)
except
+
cdef
cppclass
Rectangle
(
Shape
):
int
width
int
height
Rectangle
()
Rectangle
(
int
,
int
)
Rectangle
()
except
+
Rectangle
(
int
,
int
)
except
+
int
method
(
int
)
int
method
(
bint
)
cdef
cppclass
Square
(
Rectangle
):
int
side
Square
(
int
)
Square
(
int
)
except
+
cdef
cppclass
Empty
(
Shape
):
pass
...
...
@@ -39,6 +39,17 @@ def test_new_del():
del
rect
,
circ
print
constructor_count
-
c
,
destructor_count
-
d
def
test_default_constructor
():
"""
>>> test_default_constructor()
0.0
"""
shape
=
new
Empty
()
try
:
return
shape
.
area
()
finally
:
del
shape
def
test_rect_area
(
w
,
h
):
"""
>>> test_rect_area(3, 4)
...
...
tests/run/shapes.h
View file @
4a57c2c3
...
...
@@ -49,6 +49,7 @@ namespace shapes {
};
class
Empty
:
public
Shape
{
public:
float
area
()
{
return
0
;
}
};
...
...
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