Normalize WTK_declare_struct_or_union -> declare_struct_or_union.
authorW. Trevor King <wking@drexel.edu>
Sun, 6 Mar 2011 03:04:15 +0000 (22:04 -0500)
committerW. Trevor King <wking@drexel.edu>
Sun, 6 Mar 2011 03:04:15 +0000 (22:04 -0500)
Cython/Compiler/Builtin.py
Cython/Compiler/Nodes.py
Cython/Compiler/Symtab.py

index 34273c40d05771804a1a867e8955d8ecff5f51e6..94561920483431696f334539c0b5652e9ae3cfc2 100644 (file)
@@ -570,8 +570,9 @@ def init_builtin_structs():
         for attribute_name, attribute_type in attribute_types:
             scope.declare_var(attribute_name, attribute_type, None,
                               attribute_name, allow_pyobject=True)
+        binding = Binding(name = name, cname = cname)
         builtin_scope.declare_struct_or_union(
-            name, "struct", scope, 1, None, cname = cname)
+            binding, kind = 'struct', scope = scope, typedef_flag = True)
 
 def init_builtins():
     init_builtin_structs()
index 04f570b3bb17d7a56e5a1eeca1a90fc7749347df..eee0037d8e26265569540238a2edd78bcaec93df 100644 (file)
@@ -567,12 +567,9 @@ class CFuncDeclaratorNode(CDeclaratorNode):
             for arg in func_type_args[len(func_type_args)-self.optional_arg_count:]:
                 scope.declare_var(arg.name, arg.type, arg.pos, allow_pyobject = 1)
             struct_cname = env.mangle(Naming.opt_arg_prefix, self.base.name)
-            self.op_args_struct = env.global_scope().declare_struct_or_union(name = struct_cname,
-                                        kind = 'struct',
-                                        scope = scope,
-                                        typedef_flag = 0,
-                                        pos = self.pos,
-                                        cname = struct_cname)
+            binding = Binding(name = struct_cname, cname = struct_cname)
+            self.op_args_struct = env.global_scope().declare_struct_or_union(
+                binding, kind = 'struct', scope = scope, pos = self.pos)
             self.op_args_struct.defined_in_pxd = 1
             self.op_args_struct.used = 1
 
@@ -1000,7 +997,7 @@ class CStructOrUnionDefNode(StatNode):
             scope = StructOrUnionScope(self.name)
         binding = Binding()
         binding.pull(self)
-        self.entry = env.WTK_declare_struct_or_union(
+        self.entry = env.declare_struct_or_union(
             binding, kind = self.kind, scope = scope,
             typedef_flag = self.typedef_flag, packed = self.packed,
             pos = self.pos)
@@ -3519,7 +3516,10 @@ class SingleAssignmentNode(AssignmentNode):
                         error(self.lhs.pos, "Invalid declaration.")
                     name = self.lhs.name
                     scope = StructOrUnionScope(name)
-                    env.declare_struct_or_union(name, func_name, scope, False, self.rhs.pos)
+                    binding = Binding(name = name)
+                    env.declare_struct_or_union(
+                        binding, kind = func_name, scope = scope,
+                        pos = self.rhs.pos)
                     for member, type, pos in members:
                         scope.declare_var(member, type, pos)
 
@@ -5280,8 +5280,9 @@ class FromCImportStatNode(StatNode):
                         entry.redeclared(pos)
                 else:
                     if kind == 'struct' or kind == 'union':
-                        entry = module_scope.declare_struct_or_union(name,
-                            kind = kind, scope = None, typedef_flag = 0, pos = pos)
+                        binding = Binding(name = name)
+                        entry = module_scope.declare_struct_or_union(
+                            binding, kind = kind, scope = None, pos = pos)
                     elif kind == 'class':
                         entry = module_scope.declare_c_class(name, pos = pos,
                             module_name = self.module_name)
index 19bbeaa091e444bce49485ef40467aed9d973b37..5448bf0009974288b026917708735ebd25860138 100644 (file)
@@ -435,15 +435,8 @@ class Scope(object):
         type.qualified_name = entry.qualified_name
         return entry
 
-    def declare_struct_or_union(self, name, kind, scope,
-            typedef_flag, pos, cname = None, visibility = 'private',
-            packed = False):
-        binding = self._WTK_setup(name, cname, visibility=visibility)
-        return self.WTK_declare_struct_or_union(binding, pos, kind, scope, typedef_flag, packed)
-
-    def WTK_declare_struct_or_union(
-        self, binding,
-        pos, kind, scope, typedef_flag, packed=False):
+    def declare_struct_or_union(self, binding, kind, scope, typedef_flag=False,
+                                packed=False, pos = None):
         # Add an entry for a struct or union definition.
         if not binding.cname:
             if self.in_cinclude or binding.c_visibility == 'public':