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
611f4187
Commit
611f4187
authored
Oct 29, 2014
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '0.21.x'
parents
e5b3f31e
c62cd655
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
35 deletions
+14
-35
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+0
-30
tests/run/cpp_classes.pyx
tests/run/cpp_classes.pyx
+4
-1
tests/run/shapes.h
tests/run/shapes.h
+10
-4
No files found.
Cython/Compiler/Symtab.py
View file @
611f4187
...
...
@@ -2126,40 +2126,10 @@ class CppClassScope(Scope):
"C++ class member cannot be a Python object"
)
return
entry
def
check_base_default_constructor
(
self
,
pos
):
# Look for default constructors in all base classes.
if
self
.
default_constructor
is
None
:
entry
=
self
.
lookup
(
self
.
name
)
if
not
entry
.
type
.
base_classes
:
self
.
default_constructor
=
True
return
for
base_class
in
entry
.
type
.
base_classes
:
if
base_class
is
PyrexTypes
.
error_type
:
continue
temp_entry
=
base_class
.
scope
.
lookup_here
(
"<init>"
)
found
=
False
if
temp_entry
is
None
:
continue
for
alternative
in
temp_entry
.
all_alternatives
():
type
=
alternative
.
type
if
type
.
is_ptr
:
type
=
type
.
base_type
if
not
type
.
args
:
found
=
True
break
if
not
found
:
self
.
default_constructor
=
temp_entry
.
scope
.
name
error
(
pos
,
"no matching function for call to "
\
"%s::%s()"
%
(
temp_entry
.
scope
.
name
,
temp_entry
.
scope
.
name
))
elif
not
self
.
default_constructor
:
error
(
pos
,
"no matching function for call to %s::%s()"
%
(
self
.
default_constructor
,
self
.
default_constructor
))
def
declare_cfunction
(
self
,
name
,
type
,
pos
,
cname
=
None
,
visibility
=
'extern'
,
api
=
0
,
in_pxd
=
0
,
defining
=
0
,
modifiers
=
(),
utility_code
=
None
,
overridable
=
False
):
if
name
in
(
self
.
name
.
split
(
'::'
)[
-
1
],
'__init__'
)
and
cname
is
None
:
self
.
check_base_default_constructor
(
pos
)
cname
=
self
.
type
.
cname
name
=
'<init>'
type
.
return_type
=
PyrexTypes
.
InvisibleVoidType
()
...
...
tests/run/cpp_classes.pyx
View file @
611f4187
...
...
@@ -7,7 +7,10 @@ cdef extern from "shapes.h" namespace "shapes":
cdef
cppclass
Shape
:
float
area
()
cdef
cppclass
Circle
(
Shape
):
cdef
cppclass
Ellipse
(
Shape
):
Ellipse
(
int
a
,
int
b
)
except
+
cdef
cppclass
Circle
(
Ellipse
):
int
radius
Circle
(
int
r
)
except
+
...
...
tests/run/shapes.h
View file @
611f4187
...
...
@@ -40,11 +40,17 @@ namespace shapes {
Square
(
int
side
)
:
Rectangle
(
side
,
side
)
{
this
->
side
=
side
;
}
int
side
;
};
class
Circle
:
public
Shape
{
class
Ellipse
:
public
Shape
{
public:
Ellipse
(
int
a
,
int
b
)
{
this
->
a
=
a
;
this
->
b
=
b
;
}
float
area
()
const
{
return
3.1415926535897931
f
*
a
*
b
;
}
int
a
,
b
;
};
class
Circle
:
public
Ellipse
{
public:
Circle
(
int
radius
)
{
this
->
radius
=
radius
;
}
float
area
()
const
{
return
3.1415926535897931
f
*
radius
;
}
Circle
(
int
radius
)
:
Ellipse
(
radius
,
radius
)
{
this
->
radius
=
radius
;
}
int
radius
;
};
...
...
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