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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
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):
def
generate_execution_code
(
self
,
code
):
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
):
# cimport statement
...
...
@@ -6389,10 +6395,9 @@ class CImportStatNode(StatNode):
else
:
name
=
self
.
as_name
or
self
.
module_name
env
.
declare_module
(
name
,
module_scope
,
self
.
pos
)
if
self
.
module_name
==
"cpython.array"
:
# TODO: Consider a generic user-level mechanism for importing
# utility code (or inlining c) in a pxd (or pyx) file.
env
.
use_utility_code
(
UtilityCode
.
load
(
"ArrayAPI"
,
"arrayarray.h"
))
if
self
.
module_name
in
utility_code_for_cimports
:
env
.
use_utility_code
(
UtilityCode
.
load_cached
(
*
utility_code_for_cimports
[
self
.
module_name
]))
def
analyse_expressions
(
self
,
env
):
pass
...
...
@@ -6443,12 +6448,16 @@ class FromCImportStatNode(StatNode):
if
entry
:
local_name
=
as_name
or
name
env
.
add_imported_entry
(
local_name
,
entry
,
pos
)
if
self
.
module_name
==
"cpython"
:
# TODO: Consider a generic user-level mechanism for importing
# utility code (or inlining c) in a pxd (or pyx) file.
if
self
.
module_name
.
startswith
(
'cpython'
):
# enough for now
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
:
if
name
==
"array"
:
env
.
use_utility_code
(
UtilityCode
.
load
(
"ArrayAPI"
,
"arrayarray.h"
))
fqname
=
'%s.%s'
%
(
self
.
module_name
,
name
)
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
):
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