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
97882d65
Commit
97882d65
authored
Feb 12, 2010
by
daniloaf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing bug on contructors for inherited classes.
parent
191e7985
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
Cython/Compiler/Symtab.py
Cython/Compiler/Symtab.py
+37
-0
No files found.
Cython/Compiler/Symtab.py
View file @
97882d65
...
...
@@ -1509,6 +1509,8 @@ class CppClassScope(Scope):
# Namespace of a C++ class.
inherited_var_entries
=
[]
default_constructor
=
None
def
__init__
(
self
,
name
,
outer_scope
):
Scope
.
__init__
(
self
,
name
,
outer_scope
,
None
)
self
.
directives
=
outer_scope
.
directives
...
...
@@ -1528,10 +1530,39 @@ 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
len
(
entry
.
type
.
base_classes
)
==
0
:
self
.
default_constructor
=
True
return
for
base_class
in
entry
.
type
.
base_classes
:
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
len
(
type
.
args
)
==
0
:
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
:
print
5
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'
,
defining
=
0
,
api
=
0
,
in_pxd
=
0
,
modifiers
=
()):
if
name
==
self
.
name
.
split
(
'::'
)[
-
1
]
and
cname
is
None
:
self
.
check_base_default_constructor
(
pos
)
name
=
'<init>'
prev_entry
=
self
.
lookup_here
(
name
)
entry
=
self
.
declare_var
(
name
,
type
,
pos
,
cname
,
visibility
)
...
...
@@ -1544,6 +1575,12 @@ class CppClassScope(Scope):
# to work with this type.
for
base_entry
in
\
base_scope
.
inherited_var_entries
+
base_scope
.
var_entries
:
#contructor is not inherited
if
base_entry
.
name
==
"<init>"
:
continue
#print base_entry.name, self.entries
if
base_entry
.
name
in
self
.
entries
:
base_entry
.
name
entry
=
self
.
declare
(
base_entry
.
name
,
base_entry
.
cname
,
base_entry
.
type
,
None
,
'extern'
)
entry
.
is_variable
=
1
...
...
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