diff options
author | Aleksandr <[email protected]> | 2022-02-10 16:47:52 +0300 |
---|---|---|
committer | Daniil Cherednik <[email protected]> | 2022-02-10 16:47:52 +0300 |
commit | ea6c5b7f172becca389cacaff7d5f45f6adccbe6 (patch) | |
tree | d16cef493ac1e092b4a03ab9437ec06ffe3d188f /contrib/tools/cython/Cython/Compiler/UtilityCode.py | |
parent | 37de222addabbef336dcaaea5f7c7645a629fc6d (diff) |
Restoring authorship annotation for Aleksandr <[email protected]>. Commit 1 of 2.
Diffstat (limited to 'contrib/tools/cython/Cython/Compiler/UtilityCode.py')
-rw-r--r-- | contrib/tools/cython/Cython/Compiler/UtilityCode.py | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/contrib/tools/cython/Cython/Compiler/UtilityCode.py b/contrib/tools/cython/Cython/Compiler/UtilityCode.py index 98e9ab5bfbf..4a90470fd17 100644 --- a/contrib/tools/cython/Cython/Compiler/UtilityCode.py +++ b/contrib/tools/cython/Cython/Compiler/UtilityCode.py @@ -11,7 +11,7 @@ class NonManglingModuleScope(Symtab.ModuleScope): def __init__(self, prefix, *args, **kw): self.prefix = prefix self.cython_scope = None - self.cpp = kw.pop('cpp', False) + self.cpp = kw.pop('cpp', False) Symtab.ModuleScope.__init__(self, *args, **kw) def add_imported_entry(self, name, entry, pos): @@ -43,7 +43,7 @@ class CythonUtilityCodeContext(StringParseContext): if self.scope is None: self.scope = NonManglingModuleScope( - self.prefix, module_name, parent_module=None, context=self, cpp=self.cpp) + self.prefix, module_name, parent_module=None, context=self, cpp=self.cpp) return self.scope @@ -76,13 +76,13 @@ class CythonUtilityCode(Code.UtilityCodeBase): # while the generated node trees can be altered in the compilation of a # single file. # Hence, delay any processing until later. - context_types = {} + context_types = {} if context is not None: - from .PyrexTypes import BaseType - for key, value in context.items(): - if isinstance(value, BaseType): - context[key] = key - context_types[key] = value + from .PyrexTypes import BaseType + for key, value in context.items(): + if isinstance(value, BaseType): + context[key] = key + context_types[key] = value impl = Code.sub_tempita(impl, context, file, name) self.impl = impl self.name = name @@ -92,7 +92,7 @@ class CythonUtilityCode(Code.UtilityCodeBase): self.from_scope = from_scope self.outer_module_scope = outer_module_scope self.compiler_directives = compiler_directives - self.context_types = context_types + self.context_types = context_types def __eq__(self, other): if isinstance(other, CythonUtilityCode): @@ -118,8 +118,8 @@ class CythonUtilityCode(Code.UtilityCodeBase): from . import Pipeline, ParseTreeTransforms context = CythonUtilityCodeContext( - self.name, compiler_directives=self.compiler_directives, - cpp=cython_scope.is_cpp() if cython_scope else False) + self.name, compiler_directives=self.compiler_directives, + cpp=cython_scope.is_cpp() if cython_scope else False) context.prefix = self.prefix context.cython_scope = cython_scope #context = StringParseContext(self.name) @@ -170,18 +170,18 @@ class CythonUtilityCode(Code.UtilityCodeBase): pipeline, scope_transform, before=ParseTreeTransforms.AnalyseDeclarationsTransform) - if self.context_types: - # inject types into module scope - def scope_transform(module_node): - for name, type in self.context_types.items(): - entry = module_node.scope.declare_type(name, type, None, visibility='extern') - entry.in_cinclude = True - return module_node - - pipeline = Pipeline.insert_into_pipeline( - pipeline, scope_transform, - before=ParseTreeTransforms.AnalyseDeclarationsTransform) - + if self.context_types: + # inject types into module scope + def scope_transform(module_node): + for name, type in self.context_types.items(): + entry = module_node.scope.declare_type(name, type, None, visibility='extern') + entry.in_cinclude = True + return module_node + + pipeline = Pipeline.insert_into_pipeline( + pipeline, scope_transform, + before=ParseTreeTransforms.AnalyseDeclarationsTransform) + (err, tree) = Pipeline.run_pipeline(pipeline, tree, printtree=False) assert not err, err self.tree = tree @@ -223,7 +223,7 @@ class CythonUtilityCode(Code.UtilityCodeBase): for dep in self.requires: if dep.is_cython_utility: - dep.declare_in_scope(dest_scope, cython_scope=cython_scope) + dep.declare_in_scope(dest_scope, cython_scope=cython_scope) return original_scope |