From: Dag Sverre Seljebotn Date: Wed, 18 Jun 2008 01:51:40 +0000 (-0700) Subject: Merge X-Git-Tag: 0.9.8.1~49^2~127 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=ab686ec69db5c20dc6ac5ee90ea61b5d892dfd88;p=cython.git Merge --- ab686ec69db5c20dc6ac5ee90ea61b5d892dfd88 diff --cc Cython/CodeWriter.py index 283d080e,d4161701..3a61a4e3 --- a/Cython/CodeWriter.py +++ b/Cython/CodeWriter.py @@@ -1,5 -1,5 +1,6 @@@ from Cython.Compiler.Visitor import TreeVisitor from Cython.Compiler.Nodes import * ++from Cython.Compiler.Symtab import TempName """ Serializes a Cython code tree to Cython code. This is primarily useful for diff --cc Cython/Compiler/Symtab.py index e80139c1,b1d09251..0adb2954 --- a/Cython/Compiler/Symtab.py +++ b/Cython/Compiler/Symtab.py @@@ -16,8 -16,30 +16,31 @@@ from TypeSlots import import ControlFlow import __builtin__ + class TempName(object): + """ + Use instances of this class in order to provide a name for + anonymous, temporary functions. Each instance is considered + a seperate name, which are guaranteed not to clash with one + another or with names explicitly given as strings. + + The argument to the constructor is simply a describing string + for debugging purposes and does not affect name clashes at all. + + NOTE: Support for these TempNames are introduced on an as-needed + basis and will not "just work" everywhere. Places where they work: + - (none) + """ + def __init__(self, description): + self.description = description + + # Spoon-feed operators for documentation purposes + def __hash__(self): + return id(self) + def __cmp__(self, other): + return cmp(id(self), id(other)) + possible_identifier = re.compile(ur"(?![0-9])\w+$", re.U).match +nice_identifier = re.compile('^[a-zA-Z0-0_]+$').match class Entry: # A symbol table entry in a Scope or ModuleNamespace. diff --cc Cython/Compiler/TreeFragment.py index 90263bda,a1c0b677..c5a574bc --- a/Cython/Compiler/TreeFragment.py +++ b/Cython/Compiler/TreeFragment.py @@@ -53,7 -54,7 +54,7 @@@ def parse_from_strings(name, code, pxds buf = StringIO(code.encode(encoding)) scanner = PyrexScanner(buf, code_source, source_encoding = encoding, -- type_names = scope.type_names, context = context) ++ scope = scope, context = context) tree = Parsing.p_module(scanner, 0, module_name) return tree