# Return the module-level scope containing this scope.
return self.outer_scope.builtin_scope()
- def WTK_declare(self, binding, type, shadow = 0, pos = None):
+ def declare(self, binding, type, shadow = 0, pos = None):
# Create new entry, and add to dictionary if
# name is not None. Reports a warning if already
# declared.
binding.c_visibility = 'public'
return binding
- def declare(self, name, cname, type, pos, visibility, shadow = 0):
- binding = self._WTK_setup(name, cname, visibility)
- return self.WTK_declare(binding, type, shadow = shadow, pos = pos)
-
def qualify_name(self, name):
return EncodedString("%s.%s" % (self.qualified_name, name))
else:
binding.cname = self.mangle(
Naming.enum_prefix, binding.name)
- entry = self.WTK_declare(binding, type, pos = pos)
+ entry = self.declare(binding, type, pos = pos)
entry.is_const = 1
entry.value_node = value
return entry
# Add an entry for a type definition.
if not binding.cname:
binding.cname = binding.name
- entry = self.WTK_declare(binding, type, shadow = shadow, pos = pos)
+ entry = self.declare(binding, type, shadow = shadow, pos = pos)
entry.is_type = 1
if defining:
self.type_entries.append(entry)
self.type_entries.append(entry)
if templates is not None:
for T in templates:
- binding = self._WTK_setup(T.name, T.name, 'extern')
- template_entry = entry.type.scope.WTK_declare(
- binding, type=T, pos=None)
+ binding = Binding(
+ name=T.name, cname=T.name,
+ extern=True, c_visibility='public')
+ template_entry = entry.type.scope.declare(binding, type=T)
template_entry.is_type = 1
def declare_inherited_attributes(entry, base_classes):
constructor = type.scope.lookup(u'<init>')
if constructor is not None and PyrexTypes.best_match([], constructor.all_alternatives()) is None:
error(pos, "C++ class must have a default constructor to be stack allocated")
- entry = self.WTK_declare(binding, type, pos = pos)
+ entry = self.declare(binding, type, pos = pos)
entry.is_variable = 1
self.control_flow.set_state(
(), (binding.name, 'initialized'), False)
def add_cfunction(self, binding, pos, type,
modifiers = ()):
# Add a C function entry without giving it a func_cname.
- entry = self.WTK_declare(binding, type, pos = pos)
+ entry = self.declare(binding, type, pos = pos)
entry.is_cfunction = 1
if modifiers:
entry.func_modifiers = modifiers
Scope.__init__(self, Options.pre_import, None, None)
def declare_builtin(self, binding, pos):
- entry = self.WTK_declare(binding, py_object_type, pos = pos)
+ entry = self.declare(binding, py_object_type, pos = pos)
entry.is_variable = True
entry.is_pyglobal = True
return entry
for entry in self.cached_builtins:
if entry.name == binding.name:
return entry
- entry = self.WTK_declare(Binding(), py_object_type, pos = pos)
+ entry = self.declare(Binding(), py_object_type, pos = pos)
if Options.cache_builtins:
entry.is_builtin = 1
entry.is_const = 1
# Add an entry for an argument of a function.
if binding.cname is None:
binding.cname = self.mangle(Naming.var_prefix, binding.name)
- entry = self.WTK_declare(binding, type, pos = pos)
+ entry = self.declare(binding, type, pos = pos)
entry.is_variable = 1
if type.is_pyobject:
entry.init = "0"
# this scope must hold its name exclusively
binding.cname = '%s%s' % (self.genexp_prefix, self.parent_scope.mangle(
Naming.var_prefix, binding.name))
- entry = self.WTK_declare(
- binding, type, pos = pos)
+ entry = self.declare(binding, type, pos = pos)
entry.is_variable = 1
self.var_entries.append(entry)
self.entries[binding.name] = entry
binding.cname = c_safe_identifier(binding.cname)
if type.is_cfunction:
type = PyrexTypes.CPtrType(type)
- entry = self.WTK_declare(binding, type, pos = pos)
+ entry = self.declare(binding, type, pos = pos)
entry.is_variable = 1
self.var_entries.append(entry)
if type.is_pyobject and not allow_pyobject:
binding.cname = c_safe_identifier(binding.cname)
if type.is_cpp_class and not binding.extern:
error(pos, "C++ classes not allowed as members of an extension type, use a pointer or reference instead")
- entry = self.WTK_declare(binding, type, pos = pos)
+ entry = self.declare(binding, type, pos = pos)
entry.is_variable = 1
self.var_entries.append(entry)
if type.is_pyobject:
def declare_property(self, binding, doc, pos = None):
entry = self.lookup_here(binding.name)
if entry is None:
- entry = self.WTK_declare(binding, py_object_type, pos = pos)
+ entry = self.declare(binding, py_object_type, pos = pos)
entry.is_property = 1
entry.doc = doc
# WTK: TODO: adjust PropertyScope attributes
return "%s.%s" % (Naming.obj_base_cname, base_entry.cname)
for base_entry in \
base_scope.inherited_var_entries + base_scope.var_entries:
- entry = self.declare(
- base_entry.name,
- adapt(base_entry.cname),
- base_entry.type, None, 'private')
- entry.is_variable = 1
- self.inherited_var_entries.append(entry)
+ binding = Binding(
+ name = base_entry.name, cname = adapt(base_entry.cname))
+ entry = self.declare(binding, type = base_entry.type)
+ entry.is_variable = 1
+ self.inherited_var_entries.append(entry)
for base_entry in base_scope.cfunc_entries:
binding = Binding()
binding.pull(base_entry)
binding.cname = binding.name
if type.is_cfunction:
type = PyrexTypes.CPtrType(type)
- entry = self.WTK_declare(binding, type, pos = pos)
+ entry = self.declare(binding, type, pos = pos)
entry.is_variable = 1
self.var_entries.append(entry)
if type.is_pyobject and not allow_pyobject:
#print base_entry.name, self.entries
if base_entry.name in self.entries:
base_entry.name
+ binding = Binding(
+ name = base_entry.name,
+ cname = base_entry.cname,
+ extern = True,
+ c_visibility = 'public')
entry = self.declare(
- base_entry.name, base_entry.cname,
- base_entry.type, None, 'extern')
+ binding, type = base_entry.type)
entry.is_variable = 1
self.inherited_var_entries.append(entry)
for base_entry in base_scope.cfunc_entries:
# Add an entry for a method.
signature = get_property_accessor_signature(binding.name)
if signature:
- entry = self.WTK_declare(binding, py_object_type, pos = pos)
+ entry = self.declare(binding, py_object_type, pos = pos)
entry.is_special = 1
entry.signature = signature
return entry