Commit 084af98b authored by Stefan Behnel's avatar Stefan Behnel

Compile C++ Cython utility code in a C++ context.

parent de4aa5fe
......@@ -24,13 +24,13 @@ from . import UtilNodes
class StringParseContext(Main.Context):
def __init__(self, name, include_directories=None, compiler_directives=None):
def __init__(self, name, include_directories=None, compiler_directives=None, cpp=False):
if include_directories is None:
include_directories = []
if compiler_directives is None:
compiler_directives = {}
Main.Context.__init__(self, include_directories, compiler_directives,
create_testscope=False)
create_testscope=False, cpp=cpp)
self.module_name = name
def find_module(self, module_name, relative_to=None, pos=None, need_pxd=1, absolute_fallback=True):
......
......@@ -8,11 +8,10 @@ from . import Code
class NonManglingModuleScope(Symtab.ModuleScope):
cpp = False
def __init__(self, prefix, *args, **kw):
self.prefix = prefix
self.cython_scope = None
self.cpp = kw.pop('cpp', False)
Symtab.ModuleScope.__init__(self, *args, **kw)
def add_imported_entry(self, name, entry, pos):
......@@ -44,7 +43,7 @@ class CythonUtilityCodeContext(StringParseContext):
if self.scope is None:
self.scope = NonManglingModuleScope(
self.prefix, module_name, parent_module=None, context=self)
self.prefix, module_name, parent_module=None, context=self, cpp=self.cpp)
return self.scope
......@@ -119,7 +118,8 @@ class CythonUtilityCode(Code.UtilityCodeBase):
from . import Pipeline, ParseTreeTransforms
context = CythonUtilityCodeContext(
self.name, compiler_directives=self.compiler_directives)
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)
......@@ -223,7 +223,7 @@ class CythonUtilityCode(Code.UtilityCodeBase):
for dep in self.requires:
if dep.is_cython_utility:
dep.declare_in_scope(dest_scope)
dep.declare_in_scope(dest_scope, cython_scope=cython_scope)
return original_scope
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment