Commit 2fe3ae06 authored by Robert Bradshaw's avatar Robert Bradshaw

Working stl vector.

parent fee03687
......@@ -944,7 +944,7 @@ class CppClassNode(CStructOrUnionDefNode):
def analyse_declarations(self, env):
scope = None
if len(self.attributes) != 0:
scope = CppClassScope(self.name)
scope = CppClassScope(self.name, env)
else:
self.attributes = None
base_class_types = []
......@@ -968,7 +968,7 @@ class CppClassNode(CStructOrUnionDefNode):
if self.in_pxd and not env.in_cinclude:
self.entry.defined_in_pxd = 1
for attr in self.attributes:
attr.analyse_declarations(env, scope)
attr.analyse_declarations(scope)
class CEnumDefNode(StatNode):
# name string or None
......
......@@ -2602,8 +2602,6 @@ def p_cpp_class_definition(s, pos, ctx):
s.next()
s.expect(']')
base_classes = []
objstruct_name = None
typeobj_name = None
if s.sy == '(':
base_class = True
while (base_class):
......@@ -2626,7 +2624,7 @@ def p_cpp_class_definition(s, pos, ctx):
s.expect('NEWLINE')
s.expect_indent()
attributes = []
body_ctx = Ctx()
body_ctx = Ctx(visibility = ctx.visibility)
body_ctx.templates = templates
while s.sy != 'DEDENT':
if s.sy != 'pass':
......
......@@ -1243,6 +1243,22 @@ class CFuncType(CType):
s = self.declaration_code("(*)", with_calling_convention=False)
return '(%s)' % s
def specialize(self, values):
if self.templates is None:
new_templates = None
else:
new_templates = [v.specialize(values) for v in self.templates]
return CFuncType(self.return_type.specialize(values),
[arg.specialize(values) for arg in self.args],
has_varargs = 0,
exception_value = self.exception_value,
exception_check = self.exception_check,
calling_convention = self.calling_convention,
nogil = self.nogil,
with_gil = self.with_gil,
is_overridable = self.is_overridable,
optional_arg_count = self.optional_arg_count,
templates = new_templates)
class CFuncTypeArg(object):
# name string
......@@ -1267,6 +1283,9 @@ class CFuncTypeArg(object):
def declaration_code(self, for_display = 0):
return self.type.declaration_code(self.cname, for_display)
def specialize(self, values):
return CFuncTypeArg(self.name, self.type.specialize(values), self.pos, self.cname)
class CStructOrUnionType(CType):
# name string
......@@ -1736,9 +1755,12 @@ modifiers_and_name_to_type = {
}
def is_promotion(type, other_type):
if type.is_numeric and other_type.is_numeric:
return (type.is_int and type.is_int and type.signed == other_type.signed) \
or (type.is_float and other_type.is_float) \
or (type.is_enum and other_type.is_int)
else:
return False
def best_match(args, functions, pos):
actual_nargs = len(args)
......
......@@ -1137,7 +1137,11 @@ class ModuleScope(Scope):
entry.type.scope = scope
self.type_entries.append(entry)
if not scope and not entry.type.scope:
entry.type.scope = CppClassScope(name)
entry.type.scope = CppClassScope(name, self)
if templates is not None:
for T in templates:
template_entry = entry.type.scope.declare(T.name, T.name, T, None, 'extern')
template_entry.is_type = 1
def declare_inherited_attributes(entry, base_classes):
for base_class in base_classes:
......@@ -1604,8 +1608,9 @@ class CppClassScope(Scope):
# Namespace of a C++ class.
inherited_var_entries = []
def __init__(self, name="?"):
Scope.__init__(self, name, None, None)
def __init__(self, name, outer_scope):
Scope.__init__(self, name, outer_scope, None)
self.directives = outer_scope.directives
def declare_var(self, name, type, pos,
cname = None, visibility = 'extern', is_cdef = 0, allow_pyobject = 0):
......@@ -1622,11 +1627,6 @@ class CppClassScope(Scope):
"C++ class member cannot be a Python object")
return entry
def declare_cfunction(self, name, type, pos,
cname = None, visibility = 'extern', defining = 0,
api = 0, in_pxd = 0, modifiers = ()):
entry = self.declare_var(name, type, pos, cname, visibility)
def declare_inherited_cpp_attributes(self, base_scope):
# Declare entries for all the C++ attributes of an
# inherited type, with cnames modified appropriately
......@@ -1644,7 +1644,7 @@ class CppClassScope(Scope):
entry.is_inherited = 1
def specialize(self, values):
scope = CppClassScope()
scope = CppClassScope(self.name, self.outer_scope)
for entry in self.entries.values():
scope.declare_var(entry.name,
entry.type.specialize(values),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment