Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
1d5d18ff
Commit
1d5d18ff
authored
Feb 03, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hierarchical special cython module namespaces.
parent
f53e00e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
12 deletions
+36
-12
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+3
-0
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+33
-12
No files found.
Cython/Compiler/ExprNodes.py
View file @
1d5d18ff
...
...
@@ -2921,6 +2921,9 @@ class AttributeNode(ExprNode):
def
as_cython_attribute
(
self
):
if
isinstance
(
self
.
obj
,
NameNode
)
and
self
.
obj
.
is_cython_module
:
return
self
.
attribute
cy
=
self
.
obj
.
as_cython_attribute
()
if
cy
:
return
"%s.%s"
%
(
cy
,
self
.
attribute
)
def
coerce_to
(
self
,
dst_type
,
env
):
# If coercing to a generic pyobject and this is a cpdef function
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
1d5d18ff
...
...
@@ -377,18 +377,32 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
else
:
modname
=
u"cython"
self
.
cython_module_names
.
add
(
modname
)
return
node
elif
node
.
module_name
.
startswith
(
u"cython."
):
if
node
.
as_name
:
modname
=
node
.
as_name
else
:
modname
=
u"cython"
self
.
directive_names
[
modname
]
=
node
.
module_name
[
7
:]
else
:
return
node
def
visit_FromCImportStatNode
(
self
,
node
):
if
node
.
module_name
==
u"cython"
:
if
node
.
module_name
.
startswith
(
u"cython."
):
is_cython_module
=
True
submodule
=
node
.
module_name
[
7
:]
+
u"."
elif
node
.
module_name
==
u"cython"
:
is_cython_module
=
True
submodule
=
u""
if
is_cython_module
:
newimp
=
[]
for
pos
,
name
,
as_name
,
kind
in
node
.
imported_names
:
if
(
name
in
Options
.
directive_types
or
name
in
self
.
special_methods
or
PyrexTypes
.
parse_basic_type
(
name
)):
full_name
=
submodule
+
name
if
(
full_name
in
Options
.
directive_types
or
full_name
in
self
.
special_methods
or
PyrexTypes
.
parse_basic_type
(
full_name
)):
if
as_name
is
None
:
as_name
=
name
self
.
directive_names
[
as_name
]
=
name
as_name
=
full_
name
self
.
directive_names
[
as_name
]
=
full_
name
if
kind
is
not
None
:
self
.
context
.
nonfatal_error
(
PostParseError
(
pos
,
"Compiler directive imports must be plain imports"
))
...
...
@@ -400,13 +414,20 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
return
node
def
visit_FromImportStatNode
(
self
,
node
):
if
node
.
module
.
module_name
.
value
==
u"cython"
:
if
node
.
module
.
module_name
.
value
.
startswith
(
u"cython."
):
is_cython_module
=
True
submodule
=
node
.
module
.
module_name
.
value
[
7
:]
+
u"."
elif
node
.
module
.
module_name
.
value
==
u"cython"
:
is_cython_module
=
True
submodule
=
u""
if
is_cython_module
:
newimp
=
[]
for
name
,
name_node
in
node
.
items
:
if
(
name
in
Options
.
directive_types
or
name
in
self
.
special_methods
or
PyrexTypes
.
parse_basic_type
(
name
)):
self
.
directive_names
[
name_node
.
name
]
=
name
full_name
=
submodule
+
name
if
(
full_name
in
Options
.
directive_types
or
full_name
in
self
.
special_methods
or
PyrexTypes
.
parse_basic_type
(
full_name
)):
self
.
directive_names
[
name_node
.
name
]
=
full_name
else
:
newimp
.
append
((
name
,
name_node
))
if
not
newimp
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment