def analyse_declarations(self, env):
binding = Binding()
binding.pull(self)
- self.entry = env.WTK_declare_enum(
+ self.entry = env.declare_enum(
binding, typedef_flag = self.typedef_flag, pos = self.pos)
if self.items is not None:
if self.in_pxd and not env.in_cinclude:
elif not arg.type.is_complete() and not arg.type.is_array:
error(arg.pos,
"Argument type '%s' is incomplete" % arg.type)
- return env.declare_arg(arg.name, arg.type, arg.pos)
+ binding = Binding(name = arg.name)
+ return env.declare_arg(binding, type = arg.type, pos = arg.pos)
def generate_arg_type_test(self, arg, code):
# Generate type test for one argument.
if self.shadow:
home_scope.lookup(self.class_name).as_variable = self.entry
if home_scope is not env and self.extern:
- env.add_imported_entry(self.class_name, self.entry, self.pos)
+ env.add_imported_entry(self.entry, self.class_name, pos = self.pos)
self.scope = scope = self.entry.type.scope
if scope is not None:
scope.directives = env.directives
child_attrs = ["body"]
def analyse_declarations(self, env):
- entry = env.declare_property(self.name, self.doc, self.pos)
+ binding = Binding(name = self.name)
+ entry = env.declare_property(binding, self.doc, pos = self.pos)
if entry:
entry.scope.directives = env.directives
self.body.analyse_declarations(entry.scope)
module_scope = top_module_scope
for name in names[1:]:
submodule_scope = module_scope.find_submodule(name)
- module_scope.declare_module(name, submodule_scope, self.pos)
+ module_scope.declare_module(
+ submodule_scope, name, pos = self.pos)
module_scope = submodule_scope
if self.as_name:
- env.declare_module(self.as_name, module_scope, self.pos)
+ env.declare_module(module_scope, self.as_name, pos = self.pos)
else:
- env.declare_module(top_name, top_module_scope, self.pos)
+ env.declare_module(top_module_scope, top_name, pos = self.pos)
else:
name = self.as_name or self.module_name
- env.declare_module(name, module_scope, self.pos)
+ env.declare_module(module_scope, name, pos = self.pos)
def analyse_expressions(self, env):
pass
for pos, name, as_name, kind in self.imported_names:
if name == "*":
for local_name, entry in module_scope.entries.items():
- env.add_imported_entry(local_name, entry, pos)
+ env.add_imported_entry(entry, local_name, pos = pos)
else:
entry = module_scope.lookup(name)
if entry:
else:
submodule_scope = env.context.find_module(name, relative_to = module_scope, pos = self.pos)
if submodule_scope.parent_module is module_scope:
- env.declare_module(as_name or name, submodule_scope, self.pos)
+ env.declare_module(
+ submodule_scope, as_name or name, pos = self.pos)
else:
error(pos, "Name '%s' not declared in module '%s'"
% (name, self.module_name))
if entry:
local_name = as_name or name
- env.add_imported_entry(local_name, entry, pos)
+ env.add_imported_entry(entry, local_name, pos = pos)
def declaration_matches(self, entry, kind):
if not entry.is_type:
error(pos, "%s '%s' previously declared as '%s'" % (
type_name, entry.name, vis_diff))
- def declare_enum(self, name, pos, cname, typedef_flag,
- visibility = 'private'):
- binding = self._WTK_setup(name, cname, visibility=visibility)
- return self.WTK_declare_enum(binding, pos, typedef_flag)
-
- def WTK_declare_enum(self, binding, pos,
- typedef_flag):
+ def declare_enum(self, binding, typedef_flag, pos = None):
if binding.name:
if not binding.cname:
if self.in_cinclude or binding.c_visibility == 'public':
def WTK_declare_builtin(self, binding, pos):
return self.outer_scope.WTK_declare_builtin(binding, pos)
- def _declare_pyfunction(self, name, pos, visibility='extern', entry=None):
- binding = self._WTK_setup(name, name, visibility)
- return self.WTK__declare_pyfunction(binding, entry, pos = pos)
-
- def WTK__declare_pyfunction(self, binding,
- entry = None, pos = None):
+ def _declare_pyfunction(self, binding, entry = None, pos = None):
if entry and not entry.type.is_cfunction:
error(pos, "'%s' already declared" % binding.name)
error(entry.pos, "Previous declaration is here")
# Add an entry for a Python function.
entry = self.lookup_here(binding.name)
if not allow_redefine or Options.disable_function_redefinition:
- return self.WTK__declare_pyfunction(
- binding, entry = entry, pos = pos)
+ binding.extern = 1
+ binding.c_visibility = binding.visibility = 'public'
+ return self._declare_pyfunction(binding, entry = entry, pos = pos)
if entry:
if entry.type.is_unspecified:
entry.type = py_object_type
elif entry.type is not py_object_type:
- return self.WTK__declare_pyfunction(
- binding, entry = entry,
- pos = pos)
+ binding.extern = 1
+ binding.c_visibility = binding.visibility = 'public'
+ return self._declare_pyfunction(
+ binding, entry = entry, pos = pos)
else: # declare entry stub
self.WTK_declare_var(
binding, py_object_type, pos = pos)
for m in scope.cimported_modules:
self.add_imported_module(m)
- def add_imported_entry(self, name, entry, pos):
- return self.WTK_add_imported_entry(entry, pos, as_name=name)
-
- def WTK_add_imported_entry(self, entry, pos, as_name=None):
+ def add_imported_entry(self, entry, as_name = None, pos = None):
if not as_name:
as_name = entry.name
if entry not in self.entries:
else:
warning(pos, "'%s' redeclared " % entry.name, 0)
- def declare_module(self, name, scope, pos):
- return self.WTK_declare_module(scope, pos, as_name=name)
-
- def WTK_declare_module(self, scope, pos, as_name=None):
+ def declare_module(self, scope, as_name = None, pos = None):
# Declare a cimported module. This is represented as a
# Python module-level variable entry with a module
# scope attached to it. Reports an error and returns
def mangle(self, prefix, name):
return prefix + name
- def declare_arg(self, name, type, pos):
- binding = self._WTK_setup(name, None, 'private')
- binding.cname = self.mangle(Naming.var_prefix, binding.name)
- return self.WTK_declare_arg(
- binding, type, pos = pos)
-
- def WTK_declare_arg(self, binding, type, pos = None):
+ def declare_arg(self, binding, type, pos = None):
# 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.is_variable = 1
if type.is_pyobject:
entry.as_variable = var_entry
return entry
- def declare_property(self, name, doc, pos):
- binding = self._WTK_setup(name, name, 'private')
- return self.WTK_declare_property(binding, doc, pos = pos)
-
- def WTK_declare_property(
- self, binding, doc, pos = None):
+ 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)