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 = []
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
def signature_cast_string(self):
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
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):
}
def is_promotion(type, other_type):
- 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)
+ 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)
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:
# 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):
"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
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),