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
Gwenaël Samain
cython
Commits
9ab6e447
Commit
9ab6e447
authored
Jul 19, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix refnanny + test tags
parent
fed08a41
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
32 deletions
+53
-32
Cython/Compiler/MemoryView.py
Cython/Compiler/MemoryView.py
+13
-8
Cython/Compiler/Pipeline.py
Cython/Compiler/Pipeline.py
+19
-19
Cython/Compiler/UtilityCode.py
Cython/Compiler/UtilityCode.py
+14
-5
tests/run/cymemoryview.pyx
tests/run/cymemoryview.pyx
+2
-0
tests/run/memoryview.pyx
tests/run/memoryview.pyx
+2
-0
tests/run/memoryviewattrs.pyx
tests/run/memoryviewattrs.pyx
+3
-0
No files found.
Cython/Compiler/MemoryView.py
View file @
9ab6e447
...
...
@@ -684,6 +684,7 @@ class MemoryViewSliceTransform(CythonTransform):
copy_template
=
'''
static __Pyx_memviewslice %(copy_name)s(const __Pyx_memviewslice from_mvs) {
__Pyx_RefNannyDeclarations
int i;
__Pyx_memviewslice new_mvs = {0, 0};
struct __pyx_obj_memoryview *from_memview = from_mvs.memview;
...
...
@@ -694,7 +695,7 @@ static __Pyx_memviewslice %(copy_name)s(const __Pyx_memviewslice from_mvs) {
struct __pyx_obj_memoryview *memview_obj = 0;
char mode[] = "%(mode)s";
__Pyx_
SetupRefcount
Context("%(copy_name)s");
__Pyx_
RefNannySetup
Context("%(copy_name)s");
shape_tuple = PyTuple_New((Py_ssize_t)(buf->ndim));
if(unlikely(!shape_tuple)) {
...
...
@@ -746,7 +747,7 @@ no_fail:
__Pyx_GOTREF(temp_int);
__Pyx_XDECREF(temp_int); temp_int = 0;
__Pyx_XDECREF(array_obj); array_obj = 0;
__Pyx_
FinishRefcount
Context();
__Pyx_
RefNannyFinish
Context();
return new_mvs;
}
...
...
@@ -763,7 +764,9 @@ spec_constants_code = UtilityCode(proto="""
)
memviewslice_cname
=
u'__Pyx_memviewslice'
memviewslice_declare_code
=
UtilityCode
(
proto
=
"""
memviewslice_declare_code
=
UtilityCode
(
proto_block
=
'utility_code_proto_before_types'
,
proto
=
"""
/* memoryview slice struct */
...
...
@@ -813,7 +816,8 @@ static int __Pyx_ValidateAndInit_memviewslice(
__Pyx_BufFmt_StackElem stack[],
__Pyx_memviewslice *memviewslice) {
__Pyx_SetupRefcountContext("ValidateAndInit_memviewslice");
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("ValidateAndInit_memviewslice");
Py_buffer *buf = &memview->view;
int stride, i, spec = 0, retval = -1;
...
...
@@ -929,7 +933,7 @@ fail:
retval = -1;
no_fail:
__Pyx_
FinishRefcount
Context();
__Pyx_
RefNannyFinish
Context();
return retval;
}
...
...
@@ -937,8 +941,9 @@ static int __Pyx_init_memviewslice(
struct __pyx_obj_memoryview *memview,
int ndim,
__Pyx_memviewslice *memviewslice) {
__Pyx_SetupRefcountContext("init_memviewslice");
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("init_memviewslice");
int i, retval=-1;
Py_buffer *buf = &memview->view;
...
...
@@ -975,7 +980,7 @@ fail:
memviewslice->data = 0;
retval = -1;
no_fail:
__Pyx_
FinishRefcount
Context();
__Pyx_
RefNannyFinish
Context();
return retval;
}
"""
)
...
...
Cython/Compiler/Pipeline.py
View file @
9ab6e447
...
...
@@ -93,24 +93,24 @@ def inject_utility_code_stage_factory(context):
return
module_node
return
inject_utility_code_stage
#
class UseUtilityCodeDefinitions(CythonTransform):
#
# Temporary hack to use any utility code in nodes' "utility_code_definitions".
#
# This should be moved to the code generation phase of the relevant nodes once
#
# it is safe to generate CythonUtilityCode at code generation time.
#
def __call__(self, node):
#
self.scope = node.scope
#
return super(UseUtilityCodeDefinitions, self).__call__(node)
#
#
def visit_AttributeNode(self, node):
#
if node.entry and node.entry.utility_code_definition:
#
self.scope.use_utility_code(node.entry.utility_code_definition)
#
return node
#
#
def visit_NameNode(self, node):
#
for e in (node.entry, node.type_entry):
#
if e and e.utility_code_definition:
#
self.scope.use_utility_code(e.utility_code_definition)
#
return node
class
UseUtilityCodeDefinitions
(
CythonTransform
):
# Temporary hack to use any utility code in nodes' "utility_code_definitions".
# This should be moved to the code generation phase of the relevant nodes once
# it is safe to generate CythonUtilityCode at code generation time.
def
__call__
(
self
,
node
):
self
.
scope
=
node
.
scope
return
super
(
UseUtilityCodeDefinitions
,
self
).
__call__
(
node
)
def
visit_AttributeNode
(
self
,
node
):
if
node
.
entry
and
node
.
entry
.
utility_code_definition
:
self
.
scope
.
use_utility_code
(
node
.
entry
.
utility_code_definition
)
return
node
def
visit_NameNode
(
self
,
node
):
for
e
in
(
node
.
entry
,
node
.
type_entry
):
if
e
and
e
.
utility_code_definition
:
self
.
scope
.
use_utility_code
(
e
.
utility_code_definition
)
return
node
#
# Pipeline factories
...
...
@@ -191,7 +191,7 @@ def create_pipeline(context, mode, exclude_classes=()):
DropRefcountingTransform
(),
FinalOptimizePhase
(
context
),
GilCheck
(),
#
UseUtilityCodeDefinitions(context),
UseUtilityCodeDefinitions
(
context
),
]
filtered_stages
=
[]
for
s
in
stages
:
...
...
Cython/Compiler/UtilityCode.py
View file @
9ab6e447
...
...
@@ -74,7 +74,7 @@ class CythonUtilityCode(object):
self
.
prefix
=
prefix
self
.
requires
=
requires
or
[]
def
get_tree
(
self
):
def
get_tree
(
self
,
entries_only
=
False
):
from
AnalysedTreeTransforms
import
AutoTestDictTransform
# The AutoTestDictTransform creates the statement "__test__ = {}",
# which when copied into the main ModuleNode overwrites
...
...
@@ -88,6 +88,15 @@ class CythonUtilityCode(object):
tree
=
parse_from_strings
(
self
.
name
,
self
.
pyx
,
context
=
context
)
pipeline
=
Pipeline
.
create_pipeline
(
context
,
'pyx'
,
exclude_classes
=
excludes
)
if
entries_only
:
p
=
[]
for
t
in
pipeline
:
p
.
append
(
t
)
if
isinstance
(
p
,
ParseTreeTransforms
.
AnalyseDeclarationsTransform
):
break
pipeline
=
p
transform
=
ParseTreeTransforms
.
CnameDirectivesTransform
(
context
)
# InterpretCompilerDirectives already does a cdef declarator check
#before = ParseTreeTransforms.DecoratorTransform
...
...
@@ -107,9 +116,9 @@ class CythonUtilityCode(object):
Declare all entries from the utility code in dest_scope. Code will only
be included for used entries.
"""
self
.
tree
=
self
.
get_tree
(
)
tree
=
self
.
get_tree
(
entries_only
=
True
)
entries
=
self
.
tree
.
scope
.
entries
entries
=
tree
.
scope
.
entries
entries
.
pop
(
'__name__'
)
entries
.
pop
(
'__file__'
)
entries
.
pop
(
'__builtins__'
)
...
...
@@ -119,8 +128,8 @@ class CythonUtilityCode(object):
entry
.
utility_code_definition
=
self
entry
.
used
=
used
dest_scope
.
merge_in
(
self
.
tree
.
scope
,
merge_unused
=
True
)
self
.
tree
.
scope
=
dest_scope
dest_scope
.
merge_in
(
tree
.
scope
,
merge_unused
=
True
)
tree
.
scope
=
dest_scope
for
dep
in
self
.
requires
:
if
dep
.
is_cython_utility
:
...
...
tests/run/cymemoryview.pyx
View file @
9ab6e447
# mode: run
u'''
>>> f()
>>> g()
...
...
tests/run/memoryview.pyx
View file @
9ab6e447
# mode: run
u'''
>>> f()
>>> g()
...
...
tests/run/memoryviewattrs.pyx
View file @
9ab6e447
# mode: run
# tag: numpy
__test__
=
{}
def
testcase
(
func
):
...
...
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