Commit dfdfc93f authored by scoder's avatar scoder

Merge pull request #222 from nnemkin/cy_utility_decorators

Hide Cython utility classes (like memoryview) from Python level module scope.
parents 573ab079 530247a1
......@@ -82,6 +82,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
# Ensure that we don't generate import code for these entries!
for entry in scope.c_class_entries:
entry.type.module_name = self.full_module_name
entry.type.scope.directives["internal"] = True
self.scope.merge_in(scope)
......
......@@ -7952,10 +7952,14 @@ class CnameDecoratorNode(StatNode):
def analyse_declarations(self, env):
self.node.analyse_declarations(env)
self.is_function = isinstance(self.node, FuncDefNode)
is_struct_or_enum = isinstance(self.node, (CStructOrUnionDefNode,
node = self.node
if isinstance(node, CompilerDirectivesNode):
node = node.body.stats[0]
self.is_function = isinstance(node, FuncDefNode)
is_struct_or_enum = isinstance(node, (CStructOrUnionDefNode,
CEnumDefNode))
e = self.node.entry
e = node.entry
if self.is_function:
e.cname = self.cname
......@@ -7966,7 +7970,7 @@ class CnameDecoratorNode(StatNode):
elif is_struct_or_enum:
e.cname = e.type.cname = self.cname
else:
scope = self.node.scope
scope = node.scope
e.cname = self.cname
e.type.objstruct_cname = self.cname + '_obj'
......
cdef int data[10]
cdef int[:] myslice = data
def test_memoryview_namespace():
"""
>>> test_memoryview_namespace()
"""
namespace = dir(__import__(__name__))
assert 'array' not in namespace, namespace
assert 'memoryview' not in namespace, namespace
assert '_memoryviewslice' not in namespace, namespace
assert 'Enum' not in namespace, namespace
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