From: W. Trevor King Date: Wed, 2 Mar 2011 02:21:00 +0000 (-0500) Subject: Go back to cname instead of c_name to reduce churn. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1d31f048c9faf5c16f5d6a267fbff56253d7786a;p=cython.git Go back to cname instead of c_name to reduce churn. --- diff --git a/Cython/Compiler/Binding.py b/Cython/Compiler/Binding.py index 7cef600d..12e078b1 100644 --- a/Cython/Compiler/Binding.py +++ b/Cython/Compiler/Binding.py @@ -64,9 +64,9 @@ class CSource(_BindingAttributes): class CBinding(_BindingAttributes): """Configure the presence and behaviour of an object's C bindings. - * c_name (string): Generated symbol name (or source name, is the + * cname (string): Generated symbol name (or source name, is the symbol is external. - * c_namespace (string): C++ namespace (`None` for C objects) + * cnamespace (string): C++ namespace (`None` for C objects) * api (boolean): Add to generated header file * visibility ('private'|'public'): @@ -75,7 +75,7 @@ class CBinding(_BindingAttributes): * const (boolean): Symbol data is readonly. """ - c_name = None + cname = None namespace = None api = 0 c_visibility = 'private' diff --git a/Cython/Compiler/Buffer.py b/Cython/Compiler/Buffer.py index 42f977ff..c59c6fcf 100644 --- a/Cython/Compiler/Buffer.py +++ b/Cython/Compiler/Buffer.py @@ -221,7 +221,7 @@ def used_buffer_aux_vars(entry): def put_unpack_buffer_aux_into_scope(buffer_aux, mode, code): # Generate code to copy the needed struct info into local # variables. - bufstruct = buffer_aux.buffer_info_var.c_name + bufstruct = buffer_aux.buffer_info_var.cname varspec = [("strides", buffer_aux.stridevars), ("shape", buffer_aux.shapevars)] @@ -230,14 +230,14 @@ def put_unpack_buffer_aux_into_scope(buffer_aux, mode, code): for field, vars in varspec: code.putln(" ".join(["%s = %s.%s[%d];" % - (s.c_name, bufstruct, field, idx) + (s.cname, bufstruct, field, idx) for idx, s in enumerate(vars)])) def put_acquire_arg_buffer(entry, code, pos): code.globalstate.use_utility_code(acquire_utility_code) buffer_aux = entry.buffer_aux getbuffer = get_getbuffer_call( - code, entry.c_name, buffer_aux, entry.type) + code, entry.cname, buffer_aux, entry.type) # Acquire any new buffer code.putln("{") @@ -251,13 +251,13 @@ def put_acquire_arg_buffer(entry, code, pos): def put_release_buffer_code(code, entry): code.globalstate.use_utility_code(acquire_utility_code) code.putln("__Pyx_SafeReleaseBuffer(&%s);" % - entry.buffer_aux.buffer_info_var.c_name) + entry.buffer_aux.buffer_info_var.cname) def get_getbuffer_call(code, obj_cname, buffer_aux, buffer_type): ndim = buffer_type.ndim cast = int(buffer_type.cast) flags = get_flags(buffer_aux, buffer_type) - bufstruct = buffer_aux.buffer_info_var.c_name + bufstruct = buffer_aux.buffer_info_var.cname dtype_typeinfo = get_type_information_cname(code, buffer_type.dtype) @@ -282,7 +282,7 @@ def put_assign_to_buffer(lhs_cname, rhs_cname, buffer_aux, buffer_type, """ code.globalstate.use_utility_code(acquire_utility_code) - bufstruct = buffer_aux.buffer_info_var.c_name + bufstruct = buffer_aux.buffer_info_var.cname flags = get_flags(buffer_aux, buffer_type) code.putln("{") # Set up necesarry stack for getbuffer @@ -349,7 +349,7 @@ def put_buffer_lookup_code(entry, index_signeds, index_cnames, directives, pos, """ bufaux = entry.buffer_aux - bufstruct = bufaux.buffer_info_var.c_name + bufstruct = bufaux.buffer_info_var.cname negative_indices = directives['wraparound'] and entry.type.negative_indices if directives['boundscheck']: @@ -365,7 +365,7 @@ def put_buffer_lookup_code(entry, index_signeds, index_cnames, directives, pos, # not unsigned, deal with negative index code.putln("if (%s < 0) {" % cname) if negative_indices: - code.putln("%s += %s;" % (cname, shape.c_name)) + code.putln("%s += %s;" % (cname, shape.cname)) code.putln("if (%s) %s = %d;" % ( code.unlikely("%s < 0" % cname), tmp_cname, dim)) else: @@ -378,7 +378,7 @@ def put_buffer_lookup_code(entry, index_signeds, index_cnames, directives, pos, cast = "(size_t)" code.putln("if (%s) %s = %d;" % ( code.unlikely("%s >= %s%s" % ( - cname, cast, shape.c_name)), + cname, cast, shape.cname)), tmp_cname, dim)) code.globalstate.use_utility_code(raise_indexerror_code) code.putln("if (%s) {" % code.unlikely("%s != -1" % tmp_cname)) @@ -392,7 +392,7 @@ def put_buffer_lookup_code(entry, index_signeds, index_cnames, directives, pos, bufaux.shapevars): if signed != 0: code.putln("if (%s < 0) %s += %s;" % ( - cname, cname, shape.c_name)) + cname, cname, shape.cname)) # Create buffer lookup and return it # This is done via utility macros/inline functions, which vary @@ -403,8 +403,8 @@ def put_buffer_lookup_code(entry, index_signeds, index_cnames, directives, pos, if mode == 'full': for i, s, o in zip(index_cnames, bufaux.stridevars, bufaux.suboffsetvars): params.append(i) - params.append(s.c_name) - params.append(o.c_name) + params.append(s.cname) + params.append(o.cname) funcname = "__Pyx_BufPtrFull%dd" % nd funcgen = buf_lookup_full_code else: @@ -421,7 +421,7 @@ def put_buffer_lookup_code(entry, index_signeds, index_cnames, directives, pos, assert False for i, s in zip(index_cnames, bufaux.stridevars): params.append(i) - params.append(s.c_name) + params.append(s.cname) # Make sure the utility code is available if funcname not in code.globalstate.utility_codes: @@ -636,7 +636,7 @@ def get_type_information_cname(code, dtype, maxdepth=None): for f, typeinfo in zip(fields, types): typecode.putln(' {&%s, "%s", offsetof(%s, %s)},' % (typeinfo, f.name, - dtype.declaration_code(""), f.c_name), + dtype.declaration_code(""), f.cname), safe=True) typecode.putln(' {NULL, NULL, 0}', safe=True) typecode.putln("};", safe=True) diff --git a/Cython/Compiler/Code.py b/Cython/Compiler/Code.py index 209331c6..60f27365 100644 --- a/Cython/Compiler/Code.py +++ b/Cython/Compiler/Code.py @@ -557,7 +557,7 @@ class GlobalState(object): w.exit_cfunc_scope() def put_pyobject_decl(self, entry): - self['global_var'].putln("static PyObject *%s;" % entry.c_name) + self['global_var'].putln("static PyObject *%s;" % entry.cname) # constant handling at code generation time @@ -646,7 +646,7 @@ class GlobalState(object): def add_cached_builtin_decl(self, entry): if Options.cache_builtins: - if self.should_declare(entry.c_name, entry): + if self.should_declare(entry.cname, entry): self.put_pyobject_decl(entry) w = self.parts['cached_builtins'] if entry.name == 'xrange': @@ -654,12 +654,12 @@ class GlobalState(object): w.putln('#if PY_MAJOR_VERSION >= 3') self.put_cached_builtin_init( entry.pos, StringEncoding.EncodedString('range'), - entry.c_name) + entry.cname) w.putln('#else') self.put_cached_builtin_init( entry.pos, StringEncoding.EncodedString(entry.name), - entry.c_name) + entry.cname) if entry.name == 'xrange': w.putln('#endif') @@ -1116,7 +1116,7 @@ class CCodeWriter(object): #print "...private and not definition, skipping" ### return if entry.c_visibility == 'private' and not entry.used: - #print "not used and private, skipping", entry.c_name ### + #print "not used and private, skipping", entry.cname ### return storage_class = "" if entry.extern: @@ -1132,7 +1132,7 @@ class CCodeWriter(object): if (entry.extern or entry.c_visibility != 'public'): dll_linkage = None - self.put(entry.type.declaration_code(entry.c_name, + self.put(entry.type.declaration_code(entry.cname, dll_linkage = dll_linkage)) if entry.init is not None: self.put_safe(" = %s" % entry.type.literal_code(entry.init)) @@ -1162,9 +1162,9 @@ class CCodeWriter(object): type = entry.type if (not entry.is_self_arg and not entry.type.is_complete() or entry.type.is_extension_type): - return "(PyObject *)" + entry.c_name + return "(PyObject *)" + entry.cname else: - return entry.c_name + return entry.cname def as_pyobject(self, cname, type): from PyrexTypes import py_object_type, typecast @@ -1247,7 +1247,7 @@ class CCodeWriter(object): def put_var_decref_clear(self, entry): if entry.type.is_pyobject: self.putln("__Pyx_DECREF(%s); %s = 0;" % ( - self.entry_as_pyobject(entry), entry.c_name)) + self.entry_as_pyobject(entry), entry.cname)) def put_var_xdecref(self, entry): if entry.type.is_pyobject: @@ -1256,7 +1256,7 @@ class CCodeWriter(object): def put_var_xdecref_clear(self, entry): if entry.type.is_pyobject: self.putln("__Pyx_XDECREF(%s); %s = 0;" % ( - self.entry_as_pyobject(entry), entry.c_name)) + self.entry_as_pyobject(entry), entry.cname)) def put_var_decrefs(self, entries, used_only = 0): for entry in entries: @@ -1283,7 +1283,7 @@ class CCodeWriter(object): self.putln("%s = %s; Py_INCREF(Py_None);" % (cname, py_none)) def put_init_var_to_py_none(self, entry, template = "%s", nanny=True): - code = template % entry.c_name + code = template % entry.cname #if entry.type.is_extension_type: # code = "((PyObject*)%s)" % code self.put_init_to_py_none(code, entry.type, nanny) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index 372d7d45..fe1a4004 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -1322,7 +1322,7 @@ class NameNode(AtomicExprNode): def get_constant_c_result_code(self): if not self.entry or self.entry.type.is_pyobject: return None - return self.entry.c_name + return self.entry.cname def coerce_to(self, dst_type, env): # If coercing to a generic pyobject and this is a builtin @@ -1512,7 +1512,7 @@ class NameNode(AtomicExprNode): entry = self.entry if not entry: return "" # There was an error earlier - return entry.c_name + return entry.cname def generate_result_code(self, code): assert hasattr(self, 'entry') @@ -1566,7 +1566,7 @@ class NameNode(AtomicExprNode): elif not Options.init_local_none and assigned is None: code.putln( 'if (%s == 0) { PyErr_SetString(PyExc_UnboundLocalError, "%s"); %s }' % - (entry.c_name, entry.name, + (entry.cname, entry.name, code.error_goto(self.pos))) entry.scope.control_flow.set_state( self.pos, (entry.name, 'initialized'), True) @@ -1674,7 +1674,7 @@ class NameNode(AtomicExprNode): code.putln('%s = %s;' % (rhstmp, rhs.result_as(self.ctype()))) buffer_aux = self.entry.buffer_aux - bufstruct = buffer_aux.buffer_info_var.c_name + bufstruct = buffer_aux.buffer_info_var.cname import Buffer Buffer.put_assign_to_buffer(self.result(), rhstmp, buffer_aux, self.entry.type, is_initialized=not self.lhs_of_first_assignment, @@ -3179,11 +3179,11 @@ class SimpleCallNode(CallNode): raise_py_exception = "__Pyx_CppExn2PyErr()" elif func_type.exception_value.type.is_pyobject: raise_py_exception = ' try { throw; } catch(const std::exception& exn) { PyErr_SetString(%s, exn.what()); } catch(...) { PyErr_SetNone(%s); }' % ( - func_type.exception_value.entry.c_name, - func_type.exception_value.entry.c_name) + func_type.exception_value.entry.cname, + func_type.exception_value.entry.cname) else: raise_py_exception = '%s(); if (!PyErr_Occurred()) PyErr_SetString(PyExc_RuntimeError , "Error converting c++ exception.")' % ( - func_type.exception_value.entry.c_name) + func_type.exception_value.entry.cname) if self.nogil: raise_py_exception = 'Py_BLOCK_THREADS; %s; Py_UNBLOCK_THREADS' % raise_py_exception code.putln( @@ -3505,7 +3505,7 @@ class AttributeNode(ExprNode): # Create a temporary entry describing the C method # as an ordinary function. ubcm_entry = Symtab.Entry(entry.name, - "%s->%s" % (type.vtabptr_cname, entry.c_name), + "%s->%s" % (type.vtabptr_cname, entry.cname), entry.type) ubcm_entry.is_cfunction = 1 ubcm_entry.func_cname = entry.func_cname @@ -3612,7 +3612,7 @@ class AttributeNode(ExprNode): # because they do not have struct entries if entry.is_variable or entry.is_cmethod: self.type = entry.type - self.member = entry.c_name + self.member = entry.cname return else: # If it's not a variable or C method, it must be a Python @@ -4241,7 +4241,7 @@ class ListNode(SequenceNode): for arg, member in zip(self.args, self.type.scope.var_entries): code.putln("%s.%s = %s;" % ( self.result(), - member.c_name, + member.cname, arg.result())) else: raise InternalError("List type never specified") diff --git a/Cython/Compiler/ModuleNode.py b/Cython/Compiler/ModuleNode.py index 1f015156..04c9435e 100644 --- a/Cython/Compiler/ModuleNode.py +++ b/Cython/Compiler/ModuleNode.py @@ -151,10 +151,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): h_code.putln("%s %s;" % ( Naming.extern_c_macro, entry.type.declaration_code( - entry.c_name, dll_linkage = "DL_IMPORT"))) + entry.cname, dll_linkage = "DL_IMPORT"))) if i_code: i_code.putln("cdef extern %s" % - entry.type.declaration_code(entry.c_name, pyrex = 1)) + entry.type.declaration_code(entry.cname, pyrex = 1)) def api_name(self, env): return env.qualified_name.replace(".", "__") @@ -192,7 +192,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): for entry in api_funcs: type = CPtrType(entry.type) h_code.putln("static %s;" % type.declaration_code( - entry.c_name)) + entry.cname)) h_code.putln("") h_code.put_h_guard(Naming.api_func_guard + "import_module") h_code.put(import_module_utility_code.impl) @@ -214,7 +214,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): h_code.putln( 'if (__Pyx_ImportFunction(module, "%s", (void (**)(void))&%s, "%s") < 0) goto bad;' % ( entry.name, - entry.c_name, + entry.cname, sig)) h_code.putln("Py_DECREF(module); module = 0;") for entry in public_extension_types: @@ -248,7 +248,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): if var_entries: for entry in var_entries: i_code.putln("cdef %s" % entry.type.declaration_code( - entry.c_name, pyrex = 1)) + entry.cname, pyrex = 1)) else: i_code.putln("pass") i_code.dedent() @@ -794,7 +794,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): writer = code writer.putln("") writer.putln("typedef %s;" % base_type.declaration_code( - entry.c_name)) + entry.cname)) def sue_header_footer(self, type, kind, name): if type.typedef_flag: @@ -833,7 +833,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): for attr in var_entries: code.putln( "%s;" % - attr.type.declaration_code(attr.c_name)) + attr.type.declaration_code(attr.cname)) code.putln(footer) if packed: code.putln("#if defined(__SUNPRO_C)") @@ -845,7 +845,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): def generate_enum_definition(self, entry, code): code.mark_pos(entry.pos) type = entry.type - name = entry.c_name or entry.name or "" + name = entry.cname or entry.name or "" header, footer = \ self.sue_header_footer(type, "enum", name) code.putln("") @@ -864,10 +864,10 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): for value_entry in enum_values: if value_entry.value_node is None: - value_code = value_entry.c_name + value_code = value_entry.cname else: value_code = ("%s = %s" % ( - value_entry.c_name, + value_entry.cname, value_entry.value_node.result())) if value_entry is not last_entry: value_code += "," @@ -949,7 +949,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): for attr in type.scope.var_entries: code.putln( "%s;" % - attr.type.declaration_code(attr.c_name)) + attr.type.declaration_code(attr.cname)) code.putln(footer) if type.objtypedef_cname is not None: # Only for exposing public typedef name. @@ -976,7 +976,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): type = entry.type if not definition and entry.defined_in_pxd: type = CPtrType(type) - header = type.declaration_code(entry.c_name, + header = type.declaration_code(entry.cname, dll_linkage = dll_linkage) if entry.c_visibility == 'private': storage_class = "static " @@ -1098,7 +1098,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): for entry in py_attrs: if scope.is_internal or entry.name == "__weakref__": # internal classes do not need None inits - code.putln("p->%s = 0;" % entry.c_name) + code.putln("p->%s = 0;" % entry.cname) else: code.put_init_var_to_py_none(entry, "p->%s", nanny=False) entry = scope.lookup_here("__new__") @@ -1140,7 +1140,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln("if (p->__weakref__) PyObject_ClearWeakRefs(o);") for entry in py_attrs: code.put_xdecref( - "p->%s" % entry.c_name, entry.type, nanny=False) + "p->%s" % entry.cname, entry.type, nanny=False) if base_type: tp_dealloc = TypeSlots.get_base_slot_function(scope, tp_slot) if tp_dealloc is None: @@ -1207,7 +1207,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): base_type.typeptr_cname) code.putln("}") for entry in py_attrs: - var_code = "p->%s" % entry.c_name + var_code = "p->%s" % entry.cname code.putln( "if (%s) {" % var_code) @@ -1249,7 +1249,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln("%s->tp_clear(o);" % base_type.typeptr_cname) code.putln("}") for entry in py_attrs: - name = "p->%s" % entry.c_name + name = "p->%s" % entry.cname code.putln("tmp = ((PyObject*)%s);" % name) code.put_init_to_py_none(name, entry.type, nanny=False) code.putln("Py_XDECREF(tmp);") @@ -1709,18 +1709,18 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.error_goto(entry.pos))) code.putln("Py_INCREF(o);") code.put_decref( - entry.c_name, entry.type, nanny=False) + entry.cname, entry.type, nanny=False) code.putln("%s = %s;" % ( - entry.c_name, + entry.cname, PyrexTypes.typecast(entry.type, py_object_type, "o"))) elif entry.type.from_py_function: rhs = "%s(o)" % entry.type.from_py_function if entry.type.is_enum: rhs = PyrexTypes.typecast(entry.type, PyrexTypes.c_long_type, rhs) code.putln("%s = %s; if (%s) %s;" % ( - entry.c_name, + entry.cname, rhs, - entry.type.error_condition(entry.c_name), + entry.type.error_condition(entry.cname), code.error_goto(entry.pos))) else: code.putln('PyErr_Format(PyExc_TypeError, "Cannot convert Python object %s to %s");' % (name, entry.type)) @@ -1876,7 +1876,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): if entry.type.is_pyobject and entry.used: code.putln("Py_DECREF(%s); %s = 0;" % ( code.entry_as_pyobject(entry), - entry.c_name)) + entry.cname)) code.putln("__Pyx_CleanupGlobals();") if Options.generate_cleanup_code >= 3: code.putln("/*--- Type import cleanup code ---*/") @@ -1885,7 +1885,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): if Options.cache_builtins: code.putln("/*--- Builtin cleanup code ---*/") for entry in env.cached_builtins: - code.put_decref_clear(entry.c_name, + code.put_decref_clear(entry.cname, PyrexTypes.py_object_type, nanny=False) code.putln("/*--- Intern cleanup code ---*/") @@ -1893,7 +1893,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): PyrexTypes.py_object_type, nanny=False) # for entry in env.pynum_entries: -# code.put_decref_clear(entry.c_name, +# code.put_decref_clear(entry.cname, # PyrexTypes.py_object_type, # nanny=False) # for entry in env.all_pystring_entries: @@ -1904,7 +1904,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): # for entry in env.default_entries: # if entry.type.is_pyobject and entry.used: # code.putln("Py_DECREF(%s); %s = 0;" % ( -# code.entry_as_pyobject(entry), entry.c_name)) +# code.entry_as_pyobject(entry), entry.cname)) code.putln("Py_INCREF(Py_None); return Py_None;") def generate_main_method(self, env, code): @@ -2007,7 +2007,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): signature = entry.type.signature_string() code.putln('if (__Pyx_ExportFunction("%s", (void (*)(void))%s, "%s") < 0) %s' % ( entry.name, - entry.c_name, + entry.cname, signature, code.error_goto(self.pos))) @@ -2040,7 +2040,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): 'if (__Pyx_ImportFunction(%s, "%s", (void (**)(void))&%s, "%s") < 0) %s' % ( temp, entry.name, - entry.c_name, + entry.cname, entry.type.signature_string(), code.error_goto(self.pos))) code.putln("Py_DECREF(%s); %s = 0;" % (temp, temp)) @@ -2186,7 +2186,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): tp_weaklistoffset, tp_weaklistoffset, objstruct, - weakref_entry.c_name)) + weakref_entry.cname)) else: error(weakref_entry.pos, "__weakref__ slot must be of type 'object'") @@ -2215,7 +2215,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): code.putln( "%s.%s = %s%s;" % ( type.vtable_cname, - meth_entry.c_name, + meth_entry.cname, cast, meth_entry.func_cname)) diff --git a/Cython/Compiler/Nodes.py b/Cython/Compiler/Nodes.py index bad84378..1b044fa4 100644 --- a/Cython/Compiler/Nodes.py +++ b/Cython/Compiler/Nodes.py @@ -1016,7 +1016,7 @@ class CStructOrUnionDefNode(StatNode): cname = self.cname, visibility='ignore') struct_entry.type.typedef_flag = False # FIXME: this might be considered a hack ;-) - struct_entry.c_name = struct_entry.type.cname = ( + struct_entry.cname = struct_entry.type.cname = ( '_' + self.entry.type.typedef_cname) def analyse_expressions(self, env): @@ -1094,7 +1094,7 @@ class CEnumDefNode(StatNode): for item in self.entry.enum_values: code.putln("%s = PyInt_FromLong(%s); %s" % ( temp, - item.c_name, + item.cname, code.error_goto_if_null(temp, item.pos))) code.put_gotref(temp) code.putln('if (__Pyx_SetAttrString(%s, "%s", %s) < 0) %s' % ( @@ -1198,7 +1198,7 @@ class FuncDefNode(StatNode, BlockNode): if self.needs_closure: lenv = ClosureScope(name=self.entry.name, outer_scope = genv, - scope_name=self.entry.c_name) + scope_name=self.entry.cname) else: lenv = LocalScope(name=self.entry.name, outer_scope=genv, @@ -1368,7 +1368,7 @@ class FuncDefNode(StatNode, BlockNode): for entry in lenv.var_entries + lenv.arg_entries: if entry.type.is_buffer and entry.buffer_aux.buffer_info_var.used: code.putln("%s.buf = NULL;" % - entry.buffer_aux.buffer_info_var.c_name) + entry.buffer_aux.buffer_info_var.cname) # ----- Check and convert arguments self.generate_argument_type_tests(code) # ----- Acquire buffer arguments @@ -1409,7 +1409,7 @@ class FuncDefNode(StatNode, BlockNode): code.putln("__Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);") for entry in lenv.buffer_entries: Buffer.put_release_buffer_code(code, entry) - #code.putln("%s = 0;" % entry.c_name) + #code.putln("%s = 0;" % entry.cname) code.putln("__Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}") err_val = self.error_value() @@ -1464,7 +1464,7 @@ class FuncDefNode(StatNode, BlockNode): if entry.used and not entry.in_closure: code.put_var_decref(entry) elif entry.in_closure and self.needs_closure: - code.put_giveref(entry.c_name) + code.put_giveref(entry.cname) # Decref any increfed args for entry in lenv.arg_entries: if entry.type.is_pyobject: @@ -1534,7 +1534,7 @@ class FuncDefNode(StatNode, BlockNode): if arg.type.typeobj_is_available(): code.globalstate.use_utility_code(arg_type_test_utility_code) typeptr_cname = arg.type.typeptr_cname - arg_code = "((PyObject *)%s)" % arg.entry.c_name + arg_code = "((PyObject *)%s)" % arg.entry.cname code.putln( 'if (unlikely(!__Pyx_ArgTypeTest(%s, %s, %d, "%s", %s))) %s' % ( arg_code, @@ -1550,7 +1550,7 @@ class FuncDefNode(StatNode, BlockNode): def generate_arg_none_check(self, arg, code): # Generate None check for one argument. code.putln('if (unlikely(((PyObject *)%s) == Py_None)) {' % - arg.entry.c_name) + arg.entry.cname) code.putln('''PyErr_Format(PyExc_TypeError, "Argument '%s' must not be None"); %s''' % ( arg.name, code.error_goto(arg.pos))) @@ -1584,7 +1584,7 @@ class FuncDefNode(StatNode, BlockNode): # Special code for the __getbuffer__ function # def getbuffer_init(self, code): - info = self.local_scope.arg_entries[1].c_name + info = self.local_scope.arg_entries[1].cname # Python 3.0 betas have a bug in memoryview which makes it call # getbuffer with a NULL parameter. For now we work around this; # the following line should be removed when this bug is fixed. @@ -1593,13 +1593,13 @@ class FuncDefNode(StatNode, BlockNode): code.put_giveref("%s->obj" % info) # Do not refnanny object within structs def getbuffer_error_cleanup(self, code): - info = self.local_scope.arg_entries[1].c_name + info = self.local_scope.arg_entries[1].cname code.put_gotref("%s->obj" % info) code.putln("__Pyx_DECREF(%s->obj); %s->obj = NULL;" % (info, info)) def getbuffer_normal_cleanup(self, code): - info = self.local_scope.arg_entries[1].c_name + info = self.local_scope.arg_entries[1].cname code.putln("if (%s->obj == Py_None) {" % info) code.put_gotref("Py_None") code.putln("__Pyx_DECREF(Py_None); %s->obj = NULL;" % info) @@ -2432,19 +2432,19 @@ class DefNode(FuncDefNode): if arg.is_generic: item = PyrexTypes.typecast(arg.type, PyrexTypes.py_object_type, item) entry = arg.entry - code.putln("%s = %s;" % (entry.c_name, item)) + code.putln("%s = %s;" % (entry.cname, item)) if entry.in_closure: code.put_var_incref(entry) else: func = arg.type.from_py_function if func: code.putln("%s = %s(%s); %s" % ( - arg.entry.c_name, + arg.entry.cname, func, item, code.error_goto_if( arg.type.error_condition( - arg.entry.c_name), + arg.entry.cname), arg.pos))) else: error(arg.pos, "Cannot convert Python object argument to type '%s'" % arg.type) @@ -2482,34 +2482,34 @@ class DefNode(FuncDefNode): if self.starstar_arg: code.putln("%s = (%s) ? PyDict_Copy(%s) : PyDict_New();" % ( - self.starstar_arg.entry.c_name, + self.starstar_arg.entry.cname, Naming.kwds_cname, Naming.kwds_cname)) code.putln("if (unlikely(!%s)) return %s;" % ( - self.starstar_arg.entry.c_name, + self.starstar_arg.entry.cname, self.error_value())) self.starstar_arg.entry.xdecref_cleanup = 0 - code.put_gotref(self.starstar_arg.entry.c_name) + code.put_gotref(self.starstar_arg.entry.cname) if self.self_in_stararg: # need to create a new tuple with 'self' inserted as first item code.put("%s = PyTuple_New(PyTuple_GET_SIZE(%s)+1); if (unlikely(!%s)) " % ( - self.star_arg.entry.c_name, + self.star_arg.entry.cname, Naming.args_cname, - self.star_arg.entry.c_name)) + self.star_arg.entry.cname)) if self.starstar_arg: code.putln("{") code.put_decref_clear( - self.starstar_arg.entry.c_name, py_object_type) + self.starstar_arg.entry.cname, py_object_type) code.putln("return %s;" % self.error_value()) code.putln("}") else: code.putln("return %s;" % self.error_value()) - code.put_gotref(self.star_arg.entry.c_name) + code.put_gotref(self.star_arg.entry.cname) code.put_incref(Naming.self_cname, py_object_type) code.put_giveref(Naming.self_cname) code.putln("PyTuple_SET_ITEM(%s, 0, %s);" % ( - self.star_arg.entry.c_name, Naming.self_cname)) + self.star_arg.entry.cname, Naming.self_cname)) temp = code.funcstate.allocate_temp(PyrexTypes.c_py_ssize_t_type, manage_ref=False) code.putln("for (%s=0; %s < PyTuple_GET_SIZE(%s); %s++) {" % ( temp, temp, Naming.args_cname, temp)) @@ -2518,14 +2518,14 @@ class DefNode(FuncDefNode): code.put_incref("item", py_object_type) code.put_giveref("item") code.putln("PyTuple_SET_ITEM(%s, %s+1, item);" % ( - self.star_arg.entry.c_name, temp)) + self.star_arg.entry.cname, temp)) code.putln("}") code.funcstate.release_temp(temp) self.star_arg.entry.xdecref_cleanup = 0 elif self.star_arg: code.put_incref(Naming.args_cname, py_object_type) code.putln("%s = %s;" % ( - self.star_arg.entry.c_name, + self.star_arg.entry.cname, Naming.args_cname)) self.star_arg.entry.xdecref_cleanup = 0 @@ -2642,41 +2642,41 @@ class DefNode(FuncDefNode): if arg.is_generic and arg.default: code.putln( "%s = %s;" % ( - arg.entry.c_name, + arg.entry.cname, arg.calculate_default_value_code(code))) def generate_stararg_init_code(self, max_positional_args, code): if self.starstar_arg: self.starstar_arg.entry.xdecref_cleanup = 0 code.putln('%s = PyDict_New(); if (unlikely(!%s)) return %s;' % ( - self.starstar_arg.entry.c_name, - self.starstar_arg.entry.c_name, + self.starstar_arg.entry.cname, + self.starstar_arg.entry.cname, self.error_value())) - code.put_gotref(self.starstar_arg.entry.c_name) + code.put_gotref(self.starstar_arg.entry.cname) if self.star_arg: self.star_arg.entry.xdecref_cleanup = 0 code.putln('if (PyTuple_GET_SIZE(%s) > %d) {' % ( Naming.args_cname, max_positional_args)) code.put('%s = PyTuple_GetSlice(%s, %d, PyTuple_GET_SIZE(%s)); ' % ( - self.star_arg.entry.c_name, Naming.args_cname, + self.star_arg.entry.cname, Naming.args_cname, max_positional_args, Naming.args_cname)) - code.put_gotref(self.star_arg.entry.c_name) + code.put_gotref(self.star_arg.entry.cname) if self.starstar_arg: code.putln("") code.putln("if (unlikely(!%s)) {" % - self.star_arg.entry.c_name) + self.star_arg.entry.cname) code.put_decref_clear( - self.starstar_arg.entry.c_name, py_object_type) + self.starstar_arg.entry.cname, py_object_type) code.putln('return %s;' % self.error_value()) code.putln('}') else: code.putln("if (unlikely(!%s)) return %s;" % ( - self.star_arg.entry.c_name, + self.star_arg.entry.cname, self.error_value())) code.putln('} else {') code.put("%s = %s; " % ( - self.star_arg.entry.c_name, Naming.empty_tuple)) + self.star_arg.entry.cname, Naming.empty_tuple)) code.put_incref(Naming.empty_tuple, py_object_type) code.putln('}') @@ -2818,7 +2818,7 @@ class DefNode(FuncDefNode): Naming.kwds_cname, Naming.pykwdlist_cname, (self.starstar_arg and - self.starstar_arg.entry.c_name or + self.starstar_arg.entry.cname or '0'), pos_arg_count, self.name)) @@ -2834,7 +2834,7 @@ class DefNode(FuncDefNode): code.putln('} else {') code.putln( "%s = %s;" % ( - arg.entry.c_name, + arg.entry.cname, arg.calculate_default_value_code(code))) code.putln('}') @@ -2847,7 +2847,7 @@ class DefNode(FuncDefNode): self.generate_arg_conversion(arg, code) elif arg.entry.in_closure: code.putln('%s = %s;' % ( - arg.entry.c_name, arg.hdr_cname)) + arg.entry.cname, arg.hdr_cname)) if arg.type.is_pyobject: code.put_var_incref(arg.entry) @@ -2867,7 +2867,7 @@ class DefNode(FuncDefNode): else: if new_type.assignable_from(old_type): code.putln( - "%s = %s;" % (arg.entry.c_name, arg.hdr_cname)) + "%s = %s;" % (arg.entry.cname, arg.hdr_cname)) else: error(arg.pos, "Cannot convert 1 argument from '%s' to '%s'" % @@ -2878,7 +2878,7 @@ class DefNode(FuncDefNode): func = new_type.from_py_function # copied from CoerceFromPyTypeNode if func: - lhs = arg.entry.c_name + lhs = arg.entry.cname rhs = "%s(%s)" % (func, arg.hdr_cname) if new_type.is_enum: rhs = PyrexTypes.typecast(new_type, PyrexTypes.c_long_type, rhs) @@ -2886,7 +2886,7 @@ class DefNode(FuncDefNode): lhs, rhs, code.error_goto_if( - new_type.error_condition(arg.entry.c_name), + new_type.error_condition(arg.entry.cname), arg.pos))) else: error(arg.pos, @@ -2898,10 +2898,10 @@ class DefNode(FuncDefNode): func = old_type.to_py_function if func: code.putln("%s = %s(%s); %s" % ( - arg.entry.c_name, + arg.entry.cname, func, arg.hdr_cname, - code.error_goto_if_null(arg.entry.c_name, arg.pos))) + code.error_goto_if_null(arg.entry.cname, arg.pos))) code.put_var_gotref(arg.entry) else: error(arg.pos, @@ -2965,7 +2965,7 @@ class OverrideCheckNode(StatNode): if self.py_func.is_module_scope: self_arg = "((PyObject *)%s)" % Naming.module_cname else: - self_arg = "((PyObject *)%s)" % self.args[0].c_name + self_arg = "((PyObject *)%s)" % self.args[0].cname code.putln("/* Check if called by wrapper */") code.putln("if (unlikely(%s)) ;" % Naming.skip_dispatch_cname) code.putln("/* Check if overriden in Python */") @@ -3116,7 +3116,7 @@ class PyClassDefNode(ClassDefNode): self.target.analyse_target_declaration(env) cenv = self.create_scope(env) cenv.directives = env.directives - cenv.class_obj_cname = self.target.entry.c_name + cenv.class_obj_cname = self.target.entry.cname self.body.analyse_declarations(cenv) def analyse_expressions(self, env): diff --git a/Cython/Compiler/ParseTreeTransforms.py b/Cython/Compiler/ParseTreeTransforms.py index eed7a521..a1a66c03 100644 --- a/Cython/Compiler/ParseTreeTransforms.py +++ b/Cython/Compiler/ParseTreeTransforms.py @@ -1394,7 +1394,7 @@ class CreateClosureClasses(CythonTransform): as_name = '%s_%s' % ( target_module_scope.next_id(Naming.closure_class_prefix), - node.entry.c_name) + node.entry.cname) entry = target_module_scope.declare_c_class(name = as_name, pos = node.pos, defining = True, implementing = True) @@ -1414,7 +1414,7 @@ class CreateClosureClasses(CythonTransform): for name, entry in in_closure: class_scope.declare_var(pos=entry.pos, name=entry.name, - cname=entry.c_name, + cname=entry.cname, type=entry.type, is_cdef=True) node.needs_closure = True @@ -1760,17 +1760,17 @@ class DebugTransform(CythonTransform): # We're dealing with a closure where a variable from an outer # scope is accessed, get it from the scope object. cname = '%s->%s' % (Naming.cur_scope_cname, - entry.outer_entry.c_name) + entry.outer_entry.cname) qname = '%s.%s.%s' % (entry.scope.outer_scope.qualified_name, entry.scope.name, entry.name) elif entry.in_closure: cname = '%s->%s' % (Naming.cur_scope_cname, - entry.c_name) + entry.cname) qname = entry.qualified_name else: - cname = entry.c_name + cname = entry.cname qname = entry.qualified_name if not entry.pos: diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index 24aca54a..2dd8f65b 100755 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -1908,7 +1908,7 @@ class CFuncType(CType): def opt_arg_cname(self, arg_name): return self.op_arg_struct.base_type.scope.lookup( - arg_name).c_name + arg_name).cname class CFuncTypeArg(object): @@ -1964,7 +1964,7 @@ class StructUtilityCode(object): nameconst_cname = code.get_py_string_const( member.name, identifier=True) code.putln("member = %s(s.%s); if (member == NULL) goto bad;" % ( - member.type.to_py_function, member.c_name)) + member.type.to_py_function, member.cname)) code.putln("if (PyDict_SetItem(res, %s, member) < 0) goto bad;" % nameconst_cname) code.putln("Py_DECREF(member);") code.putln("return res;") diff --git a/Cython/Compiler/Symtab.py b/Cython/Compiler/Symtab.py index b86e60d4..6059f3d1 100644 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@ -174,7 +174,7 @@ class Entry(Binding): def __init__(self, name, cname, type, pos = None, init = None): self.name = name - self.c_name = cname + self.cname = cname self.type = type self.pos = pos self.init = init @@ -197,7 +197,7 @@ class WTK_Entry(Entry): # Binding attributes def __init__(self, binding, type, pos = None, init = None): Entry.__init__( - self, name=binding.name, cname=binding.c_name, + self, name=binding.name, cname=binding.cname, type=type, pos = pos, init=init) binding.push(self) @@ -342,9 +342,9 @@ class Scope(object): if type.is_buffer and not isinstance(self, LocalScope): error(pos, ERR_BUF_LOCALONLY) if (not self.in_cinclude and - binding.c_name and re.match("^_[_A-Z]+$", binding.c_name)): + binding.cname and re.match("^_[_A-Z]+$", binding.cname)): # See http://www.gnu.org/software/libc/manual/html_node/Reserved-Names.html#Reserved-Names - warning(pos, "'%s' is a reserved name in C." % binding.c_name, -1) + warning(pos, "'%s' is a reserved name in C." % binding.cname, -1) entries = self.entries if binding.name and binding.name in entries: if binding.extern: @@ -365,7 +365,7 @@ class Scope(object): return entry def _WTK_setup(self, name, cname, visibility): - binding = Binding(name=name, c_name=cname) + binding = Binding(name=name, cname=cname) if visibility == 'extern': binding.extern = 1 binding.c_visibility = 'public' @@ -391,11 +391,11 @@ class Scope(object): def WTK_declare_const(self, binding, type, value, pos): # Add an entry for a named constant. - if not binding.c_name: + if not binding.cname: if self.in_cinclude or binding.c_visibility == 'public': - binding.c_name = binding.name + binding.cname = binding.name else: - binding.c_name = self.mangle( + binding.cname = self.mangle( Naming.enum_prefix, binding.name) entry = self.WTK_declare(binding, type, pos) entry.is_const = 1 @@ -410,8 +410,8 @@ class Scope(object): def WTK_declare_type(self, binding, type, defining = 1, pos = None): # Add an entry for a type definition. - if not binding.c_name: - binding.c_name = binding.name + if not binding.cname: + binding.cname = binding.name entry = self.WTK_declare(binding, type, pos) entry.is_type = 1 if defining: @@ -426,15 +426,15 @@ class Scope(object): def WTK_declare_typedef(self, binding, base_type, pos): - if not binding.c_name: + if not binding.cname: if self.in_cinclude or binding.c_visibility == 'public': - binding.c_name = binding.name + binding.cname = binding.name else: - binding.c_name = self.mangle( + binding.cname = self.mangle( Naming.type_prefix, binding.name) try: type = PyrexTypes.create_typedef_type( - binding.name, base_type, binding.c_name, + binding.name, base_type, binding.cname, binding.extern) except ValueError, e: error(pos, e.args[0]) @@ -454,16 +454,16 @@ class Scope(object): self, binding, pos, kind, scope, typedef_flag, packed=False): # Add an entry for a struct or union definition. - if not binding.c_name: + if not binding.cname: if self.in_cinclude or binding.c_visibility == 'public': - binding.c_name = binding.name + binding.cname = binding.name else: - binding.c_name = self.mangle( + binding.cname = self.mangle( Naming.type_prefix, binding.name) entry = self.lookup_here(binding.name) if not entry: type = PyrexTypes.CStructOrUnionType( - binding.name, kind, scope, typedef_flag, binding.c_name, + binding.name, kind, scope, typedef_flag, binding.cname, packed) entry = self.WTK_declare_type( binding, type, @@ -501,12 +501,12 @@ class Scope(object): pos, scope, base_classes = (), templates = None): if not binding.extern: error(pos, "C++ classes may only be extern") - if binding.c_name is None: - binding.c_name = binding.name + if binding.cname is None: + binding.cname = binding.name entry = self.lookup_here(binding.name) if not entry: type = PyrexTypes.CppClassType( - binding.name, scope, binding.c_name, base_classes, + binding.name, scope, binding.cname, base_classes, templates = templates) entry = self.WTK_declare_type( binding, type, @@ -586,14 +586,14 @@ class Scope(object): def WTK_declare_enum(self, binding, pos, typedef_flag): if binding.name: - if not binding.c_name: + if not binding.cname: if self.in_cinclude or binding.c_visibility == 'public': - binding.c_name = binding.name + binding.cname = binding.name else: - binding.c_name = self.mangle( + binding.cname = self.mangle( Naming.type_prefix, binding.name) type = PyrexTypes.CEnumType( - binding.name, binding.c_name, typedef_flag) + binding.name, binding.cname, typedef_flag) else: type = PyrexTypes.c_anon_enum_type entry = self.WTK_declare_type(binding, type, pos = pos) @@ -610,11 +610,11 @@ class Scope(object): def WTK_declare_var(self, binding, type, is_cdef = 0, pos = None): # Add an entry for a variable. - if not binding.c_name: + if not binding.cname: if binding.c_visibility != 'private': - binding.c_name = binding.name + binding.cname = binding.name else: - binding.c_name = self.mangle( + binding.cname = self.mangle( Naming.var_prefix, binding.name) if type.is_cpp_class and not binding.extern: constructor = type.scope.lookup(u'') @@ -668,7 +668,7 @@ class Scope(object): else: # declare entry stub self.WTK_declare_var( binding, py_object_type, pos = pos) - entry = self.WTK_declare_var(Binding(name=None, c_name=binding.name), + entry = self.WTK_declare_var(Binding(name=None, cname=binding.name), py_object_type, pos = pos) entry.name = EncodedString(binding.name) entry.qualified_name = self.qualify_name(binding.name) @@ -684,8 +684,8 @@ class Scope(object): pos = None): # Add an entry for an anonymous Python function. entry = self.WTK_declare_var(binding, py_object_type, pos = pos) - entry.name = EncodedString(binding.c_name) - entry.func_cname = binding.c_name + entry.name = EncodedString(binding.cname) + entry.func_cname = binding.cname entry.signature = pyfunction_signature entry.is_anonymous = True return entry @@ -710,11 +710,11 @@ class Scope(object): in_pxd = 0, modifiers = (), utility_code = None): # Add an entry for a C function. - if not binding.c_name: + if not binding.cname: if binding.api or binding.c_visibility != 'private': - binding.c_name = binding.name + binding.cname = binding.name else: - binding.c_name = self.mangle( + binding.cname = self.mangle( Naming.func_prefix, binding.name) entry = self.lookup_here(binding.name) if entry: @@ -728,12 +728,12 @@ class Scope(object): can_override = False if self.is_cpp(): can_override = True - elif binding.c_name: + elif binding.cname: # if all alternatives have different cnames, # it's safe to allow signature overrides for alt_entry in entry.all_alternatives(): - if (not alt_entry.c_name or - binding.c_name == alt_entry.c_name): + if (not alt_entry.cname or + binding.cname == alt_entry.cname): break # cname not unique! else: can_override = True @@ -749,7 +749,7 @@ class Scope(object): error(pos, "Function signature does not match previous declaration") else: entry = self.WTK_add_cfunction(binding, pos, type, modifiers) - entry.func_cname = binding.c_name + entry.func_cname = binding.cname if in_pxd and not binding.extern: entry.defined_in_pxd = 1 if not defining and not in_pxd and not binding.extern: @@ -936,7 +936,7 @@ class BuiltinScope(Scope): else: python_equiv = EncodedString(python_equiv) var_entry = WTK_Entry( - Binding(name=python_equiv, c_name=python_equiv), py_object_type) + Binding(name=python_equiv, cname=python_equiv), py_object_type) var_entry.is_variable = 1 var_entry.is_builtin = 1 var_entry.utility_code = utility_code @@ -949,7 +949,7 @@ class BuiltinScope(Scope): def WTK_declare_builtin_type(self, binding, objstruct_cname = None, utility_code = None): binding.name = EncodedString(binding.name) - type = PyrexTypes.BuiltinObjectType(binding.name, binding.c_name, objstruct_cname) + type = PyrexTypes.BuiltinObjectType(binding.name, binding.cname, objstruct_cname) # WTK: TODO: visibility checking. CClassCcope visibility splitting scope = CClassScope(binding.name, outer_scope=None, visibility='extern') scope.directives = {} @@ -961,7 +961,7 @@ class BuiltinScope(Scope): entry.utility_code = utility_code var_entry = WTK_Entry( - binding.deepcopy(c_name="((PyObject*)%s)" % entry.type.typeptr_cname), + binding.deepcopy(cname="((PyObject*)%s)" % entry.type.typeptr_cname), type = self.lookup('type').type, # make sure "type" is the first type declared... pos = entry.pos) var_entry.is_variable = 1 @@ -1105,7 +1105,7 @@ class ModuleScope(Scope): entry.is_builtin = 1 entry.is_const = 1 entry.name = binding.name - entry.c_name = Naming.builtin_prefix + binding.name + entry.cname = Naming.builtin_prefix + binding.name self.cached_builtins.append(entry) self.undeclared_cached_builtins.append(entry) else: @@ -1294,9 +1294,9 @@ class ModuleScope(Scope): if objstruct_cname: type.objstruct_cname = objstruct_cname elif binding.extern or binding.c_visibility != 'public': - binding.c_name = self.mangle( + binding.cname = self.mangle( Naming.objstruct_prefix, binding.name) - type.objstruct_cname = binding.c_name + type.objstruct_cname = binding.cname else: error(entry.pos, "Object name required for 'public' or 'extern' C class") @@ -1504,7 +1504,7 @@ class LocalScope(Scope): def declare_arg(self, name, type, pos): binding = self._WTK_setup(name, None, 'private') - binding.c_name = self.mangle(Naming.var_prefix, binding.name) + binding.cname = self.mangle(Naming.var_prefix, binding.name) return self.WTK_declare_arg( binding, type, pos = pos) @@ -1562,7 +1562,7 @@ class LocalScope(Scope): entry.in_closure = True # Would it be better to declare_var here? inner_entry = Entry( - entry.name, entry.c_name, + entry.name, entry.cname, entry.type, entry.pos) inner_entry.scope = self inner_entry.is_variable = True @@ -1575,18 +1575,18 @@ class LocalScope(Scope): def mangle_closure_cnames(self, outer_scope_cname): for entry in self.entries.values(): if entry.from_closure: - cname = entry.outer_entry.c_name + cname = entry.outer_entry.cname if self.is_passthrough: - entry.c_name = cname + entry.cname = cname else: if cname.startswith(Naming.cur_scope_cname): cname = cname[len(Naming.cur_scope_cname)+2:] - entry.c_name = "%s->%s" % ( + entry.cname = "%s->%s" % ( outer_scope_cname, cname) elif entry.in_closure: - entry.original_cname = entry.c_name - entry.c_name = "%s->%s" % ( - Naming.cur_scope_cname, entry.c_name) + entry.original_cname = entry.cname + entry.cname = "%s->%s" % ( + Naming.cur_scope_cname, entry.cname) class GeneratorExpressionScope(Scope): """Scope for generator expressions and comprehensions. As opposed @@ -1617,7 +1617,7 @@ class GeneratorExpressionScope(Scope): type = outer_entry.type # may still be 'unspecified_type' ! # the parent scope needs to generate code for the variable, but # this scope must hold its name exclusively - binding.c_name = '%s%s' % (self.genexp_prefix, self.parent_scope.mangle( + binding.cname = '%s%s' % (self.genexp_prefix, self.parent_scope.mangle( Naming.var_prefix, binding.name)) entry = self.WTK_declare( binding, type, pos = pos) @@ -1668,10 +1668,10 @@ class StructOrUnionScope(Scope): def WTK_declare_var(self, binding, type, is_cdef = 0, allow_pyobject = 0, pos = None): # Add an entry for an attribute. - if not binding.c_name: - binding.c_name = binding.name + if not binding.cname: + binding.cname = binding.name if binding.c_visibility == 'private': - binding.c_name = c_safe_identifier(binding.c_name) + binding.cname = c_safe_identifier(binding.cname) if type.is_cfunction: type = PyrexTypes.CPtrType(type) entry = self.WTK_declare(binding, type, pos) @@ -1816,10 +1816,10 @@ class CClassScope(ClassScope): error(pos, "The name '%s' is reserved for a special method." % binding.name) - if not binding.c_name: - binding.c_name = binding.name + if not binding.cname: + binding.cname = binding.name if binding.c_visibility == 'private': - binding.c_name = c_safe_identifier(binding.c_name) + 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) @@ -1935,8 +1935,8 @@ class CClassScope(ClassScope): error(pos, "C method '%s' not previously declared in definition part of" " extension type" % binding.name) - if not binding.c_name: - binding.c_name = binding.name + if not binding.cname: + binding.cname = binding.name entry = self.WTK_add_cfunction(binding, pos, type, modifiers) if defining: entry.func_cname = self.mangle(Naming.func_prefix, binding.name) @@ -1966,13 +1966,13 @@ class CClassScope(ClassScope): # overridden methods of builtin types still have their Python # equivalent that must be accessible to support bound methods binding.name = EncodedString(binding.name) - #entry = self.declare_cfunction(binding.name, type, None, binding.c_name, visibility='extern', + #entry = self.declare_cfunction(binding.name, type, None, binding.cname, visibility='extern', # utility_code = utility_code) entry = self.WTK_declare_cfunction( binding, pos=None, type=type, utility_code = utility_code) # WTK: need all declare_cfunction-s wrapped var_entry = WTK_Entry( - Binding(name=binding.name, c_name=binding.name), py_object_type) + Binding(name=binding.name, cname=binding.name), py_object_type) var_entry.is_variable = 1 var_entry.is_builtin = 1 var_entry.utility_code = utility_code @@ -2002,12 +2002,12 @@ class CClassScope(ClassScope): # inherited type, with cnames modified appropriately # to work with this type. def adapt(cname): - return "%s.%s" % (Naming.obj_base_cname, base_entry.c_name) + 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.c_name), + adapt(base_entry.cname), base_entry.type, None, 'private') entry.is_variable = 1 self.inherited_var_entries.append(entry) @@ -2019,7 +2019,7 @@ class CClassScope(ClassScope): visibility = base_entry.c_visibility entry = self.add_cfunction( base_entry.name, base_entry.type, - base_entry.pos, adapt(base_entry.c_name), + base_entry.pos, adapt(base_entry.cname), visibility, base_entry.func_modifiers) entry.is_inherited = 1 @@ -2045,8 +2045,8 @@ class CppClassScope(Scope): def WTK_declare_var(self, binding, type, is_cdef = 0, allow_pyobject = 0, pos = None): # Add an entry for an attribute. - if not binding.c_name: - binding.c_name = binding.name + if not binding.cname: + binding.cname = binding.name if type.is_cfunction: type = PyrexTypes.CPtrType(type) entry = self.WTK_declare(binding, type, pos) @@ -2096,7 +2096,7 @@ class CppClassScope(Scope): def WTK_declare_cfunction( self, binding, pos, type, defining = 0, in_pxd = 0, modifiers = (), utility_code = None): - if binding.name == self.name.split('::')[-1] and binding.c_name is None: + if binding.name == self.name.split('::')[-1] and binding.cname is None: self.check_base_default_constructor(pos) binding.name = '' type.return_type = self.lookup(self.name).type @@ -2120,7 +2120,7 @@ class CppClassScope(Scope): if base_entry.name in self.entries: base_entry.name entry = self.declare( - base_entry.name, base_entry.c_name, + base_entry.name, base_entry.cname, base_entry.type, None, 'extern') entry.is_variable = 1 self.inherited_var_entries.append(entry) @@ -2132,7 +2132,7 @@ class CppClassScope(Scope): visibility = base_entry.c_visibility entry = self.declare_cfunction( base_entry.name, base_entry.type, - base_entry.pos, base_entry.c_name, + base_entry.pos, base_entry.cname, visibility, base_entry.func_modifiers, utility_code = base_entry.utility_code) entry.is_inherited = 1