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
Kirill Smelkov
cython
Commits
52af0421
Commit
52af0421
authored
Aug 20, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support 'from cpython.array cimport array' in addition to existing cimport forms
parent
b7be9d74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
+18
-9
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+18
-9
No files found.
Cython/Compiler/Nodes.py
View file @
52af0421
...
@@ -6358,6 +6358,12 @@ class EnsureGILNode(GILExitNode):
...
@@ -6358,6 +6358,12 @@ class EnsureGILNode(GILExitNode):
def
generate_execution_code
(
self
,
code
):
def
generate_execution_code
(
self
,
code
):
code
.
put_ensure_gil
(
declare_gilstate
=
False
)
code
.
put_ensure_gil
(
declare_gilstate
=
False
)
utility_code_for_cimports
=
{
# utility code (or inlining c) in a pxd (or pyx) file.
# TODO: Consider a generic user-level mechanism for importing
'cpython.array'
:
(
"ArrayAPI"
,
"arrayarray.h"
),
'cpython.array.array'
:
(
"ArrayAPI"
,
"arrayarray.h"
),
}
class
CImportStatNode
(
StatNode
):
class
CImportStatNode
(
StatNode
):
# cimport statement
# cimport statement
...
@@ -6389,10 +6395,9 @@ class CImportStatNode(StatNode):
...
@@ -6389,10 +6395,9 @@ class CImportStatNode(StatNode):
else
:
else
:
name
=
self
.
as_name
or
self
.
module_name
name
=
self
.
as_name
or
self
.
module_name
env
.
declare_module
(
name
,
module_scope
,
self
.
pos
)
env
.
declare_module
(
name
,
module_scope
,
self
.
pos
)
if
self
.
module_name
==
"cpython.array"
:
if
self
.
module_name
in
utility_code_for_cimports
:
# TODO: Consider a generic user-level mechanism for importing
env
.
use_utility_code
(
UtilityCode
.
load_cached
(
# utility code (or inlining c) in a pxd (or pyx) file.
*
utility_code_for_cimports
[
self
.
module_name
]))
env
.
use_utility_code
(
UtilityCode
.
load
(
"ArrayAPI"
,
"arrayarray.h"
))
def
analyse_expressions
(
self
,
env
):
def
analyse_expressions
(
self
,
env
):
pass
pass
...
@@ -6443,12 +6448,16 @@ class FromCImportStatNode(StatNode):
...
@@ -6443,12 +6448,16 @@ class FromCImportStatNode(StatNode):
if
entry
:
if
entry
:
local_name
=
as_name
or
name
local_name
=
as_name
or
name
env
.
add_imported_entry
(
local_name
,
entry
,
pos
)
env
.
add_imported_entry
(
local_name
,
entry
,
pos
)
if
self
.
module_name
==
"cpython"
:
# TODO: Consider a generic user-level mechanism for importing
if
self
.
module_name
.
startswith
(
'cpython'
):
# enough for now
# utility code (or inlining c) in a pxd (or pyx) file.
if
self
.
module_name
in
utility_code_for_cimports
:
env
.
use_utility_code
(
UtilityCode
.
load_cached
(
*
utility_code_for_cimports
[
self
.
module_name
]))
for
_
,
name
,
_
,
_
in
self
.
imported_names
:
for
_
,
name
,
_
,
_
in
self
.
imported_names
:
if
name
==
"array"
:
fqname
=
'%s.%s'
%
(
self
.
module_name
,
name
)
env
.
use_utility_code
(
UtilityCode
.
load
(
"ArrayAPI"
,
"arrayarray.h"
))
if
fqname
in
utility_code_for_cimports
:
env
.
use_utility_code
(
UtilityCode
.
load_cached
(
*
utility_code_for_cimports
[
fqname
]))
def
declaration_matches
(
self
,
entry
,
kind
):
def
declaration_matches
(
self
,
entry
,
kind
):
if
not
entry
.
is_type
:
if
not
entry
.
is_type
:
...
...
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