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
c7476b5c
Commit
c7476b5c
authored
Apr 11, 2011
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial cimport-from-pyx push.
(Somewhat hackish...)
parent
fd88308e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
4 deletions
+41
-4
Cython/Compiler/Main.py
Cython/Compiler/Main.py
+37
-4
Cython/Compiler/Options.py
Cython/Compiler/Options.py
+4
-0
No files found.
Cython/Compiler/Main.py
View file @
c7476b5c
...
@@ -31,6 +31,7 @@ from Cython import Utils
...
@@ -31,6 +31,7 @@ from Cython import Utils
from
Cython.Utils
import
open_new_file
,
replace_suffix
from
Cython.Utils
import
open_new_file
,
replace_suffix
import
CythonScope
import
CythonScope
import
DebugFlags
import
DebugFlags
import
Options
module_name_pattern
=
re
.
compile
(
r"[A-Za-z_][A-Za-z0-9_]*(\
.[A-Z
a-z_][A-Za-z0-9_]*)*$"
)
module_name_pattern
=
re
.
compile
(
r"[A-Za-z_][A-Za-z0-9_]*(\
.[A-Z
a-z_][A-Za-z0-9_]*)*$"
)
...
@@ -73,7 +74,7 @@ class Context(object):
...
@@ -73,7 +74,7 @@ class Context(object):
# future_directives [object]
# future_directives [object]
# language_level int currently 2 or 3 for Python 2/3
# language_level int currently 2 or 3 for Python 2/3
def
__init__
(
self
,
include_directories
,
compiler_directives
,
cpp
=
False
,
language_level
=
2
):
def
__init__
(
self
,
include_directories
,
compiler_directives
,
cpp
=
False
,
language_level
=
2
,
options
=
None
):
import
Builtin
,
CythonScope
import
Builtin
,
CythonScope
self
.
modules
=
{
"__builtin__"
:
Builtin
.
builtin_scope
}
self
.
modules
=
{
"__builtin__"
:
Builtin
.
builtin_scope
}
self
.
modules
[
"cython"
]
=
CythonScope
.
create_cython_scope
(
self
)
self
.
modules
[
"cython"
]
=
CythonScope
.
create_cython_scope
(
self
)
...
@@ -81,6 +82,7 @@ class Context(object):
...
@@ -81,6 +82,7 @@ class Context(object):
self
.
future_directives
=
set
()
self
.
future_directives
=
set
()
self
.
compiler_directives
=
compiler_directives
self
.
compiler_directives
=
compiler_directives
self
.
cpp
=
cpp
self
.
cpp
=
cpp
self
.
options
=
options
self
.
pxds
=
{}
# full name -> node tree
self
.
pxds
=
{}
# full name -> node tree
...
@@ -231,8 +233,37 @@ class Context(object):
...
@@ -231,8 +233,37 @@ class Context(object):
def
create_py_pipeline
(
self
,
options
,
result
):
def
create_py_pipeline
(
self
,
options
,
result
):
return
self
.
create_pyx_pipeline
(
options
,
result
,
py
=
True
)
return
self
.
create_pyx_pipeline
(
options
,
result
,
py
=
True
)
def
create_pyx_as_pxd_pipeline
(
self
,
source
):
from
ParseTreeTransforms
import
(
AlignFunctionDefinitions
,
MarkClosureVisitor
,
WithTransform
,
AnalyseDeclarationsTransform
)
from
Optimize
import
ConstantFolding
,
FlattenInListTransform
from
Nodes
import
StatListNode
pipeline
=
[]
result
=
create_default_resultobj
(
source
,
self
.
options
)
pyx_pipeline
=
self
.
create_pyx_pipeline
(
self
.
options
,
result
)
for
stage
in
pyx_pipeline
:
if
stage
.
__class__
in
[
AlignFunctionDefinitions
,
MarkClosureVisitor
,
ConstantFolding
,
FlattenInListTransform
,
WithTransform
,
]:
pass
# continue
pipeline
.
append
(
stage
)
if
isinstance
(
stage
,
AnalyseDeclarationsTransform
):
break
def
fake_pxd
(
root
):
return
StatListNode
(
root
.
pos
,
stats
=
[]),
root
.
scope
pipeline
.
append
(
fake_pxd
)
return
pipeline
def
process_pxd
(
self
,
source_desc
,
scope
,
module_name
):
def
process_pxd
(
self
,
source_desc
,
scope
,
module_name
):
if
isinstance
(
source_desc
,
FileSourceDescriptor
)
and
source_desc
.
_file_type
==
'pyx'
:
source
=
CompilationSource
(
source_desc
,
module_name
,
os
.
getcwd
())
pipeline
=
self
.
create_pyx_as_pxd_pipeline
(
source
)
result
=
self
.
run_pipeline
(
pipeline
,
source
)
else
:
pipeline
=
self
.
create_pxd_pipeline
(
scope
,
module_name
)
pipeline
=
self
.
create_pxd_pipeline
(
scope
,
module_name
)
result
=
self
.
run_pipeline
(
pipeline
,
source_desc
)
result
=
self
.
run_pipeline
(
pipeline
,
source_desc
)
return
result
return
result
...
@@ -365,6 +396,8 @@ class Context(object):
...
@@ -365,6 +396,8 @@ class Context(object):
warning
(
pos
,
"'%s' is deprecated, use 'libc.%s'"
%
(
name
,
name
),
1
)
warning
(
pos
,
"'%s' is deprecated, use 'libc.%s'"
%
(
name
,
name
),
1
)
elif
name
in
(
'stl'
):
elif
name
in
(
'stl'
):
warning
(
pos
,
"'%s' is deprecated, use 'libcpp.*.*'"
%
name
,
1
)
warning
(
pos
,
"'%s' is deprecated, use 'libcpp.*.*'"
%
name
,
1
)
if
pxd
is
None
and
Options
.
cimport_from_pyx
:
return
self
.
find_pyx_file
(
qualified_name
,
pos
)
return
pxd
return
pxd
def
find_pyx_file
(
self
,
qualified_name
,
pos
):
def
find_pyx_file
(
self
,
qualified_name
,
pos
):
...
@@ -686,7 +719,7 @@ class CompilationOptions(object):
...
@@ -686,7 +719,7 @@ class CompilationOptions(object):
def
create_context
(
self
):
def
create_context
(
self
):
return
Context
(
self
.
include_path
,
self
.
compiler_directives
,
return
Context
(
self
.
include_path
,
self
.
compiler_directives
,
self
.
cplus
,
self
.
language_level
)
self
.
cplus
,
self
.
language_level
,
options
=
self
)
class
CompilationResult
(
object
):
class
CompilationResult
(
object
):
...
...
Cython/Compiler/Options.py
View file @
c7476b5c
...
@@ -63,6 +63,10 @@ disable_function_redefinition = False
...
@@ -63,6 +63,10 @@ disable_function_redefinition = False
# globals in the call stack. Sage relies on this behavior for variable injection.
# globals in the call stack. Sage relies on this behavior for variable injection.
old_style_globals
=
False
old_style_globals
=
False
# Allows cimporting from a pyx file without a pxd file.
cimport_from_pyx
=
True
# Declare compiler directives
# Declare compiler directives
directive_defaults
=
{
directive_defaults
=
{
...
...
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