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
Xavier Thompson
cython
Commits
985d50f3
Commit
985d50f3
authored
Aug 05, 2009
by
Kurt Smith
Committed by
Mark Florisson
Sep 30, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
consistent naming of all memoryview slice and cython.memoryview references.
parent
bf083b70
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
49 deletions
+51
-49
Cython/Compiler/Buffer.py
Cython/Compiler/Buffer.py
+3
-3
Cython/Compiler/ExprNodes.py
Cython/Compiler/ExprNodes.py
+14
-14
Cython/Compiler/MemoryView.py
Cython/Compiler/MemoryView.py
+5
-5
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+5
-5
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+5
-5
Cython/Compiler/Parsing.py
Cython/Compiler/Parsing.py
+14
-12
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+5
-5
No files found.
Cython/Compiler/Buffer.py
View file @
985d50f3
...
...
@@ -54,10 +54,10 @@ class IntroduceBufferAuxiliaryVars(CythonTransform):
if
len
(
bufvars
)
>
0
:
self
.
buffers_exists
=
True
memviewvars
=
[
entry
for
name
,
entry
memview
slice
vars
=
[
entry
for
name
,
entry
in
scope
.
entries
.
iteritems
()
if
entry
.
type
.
is_memoryview
]
if
len
(
memviewvars
)
>
0
:
if
entry
.
type
.
is_memoryview
slice
]
if
len
(
memview
slice
vars
)
>
0
:
self
.
buffers_exists
=
True
...
...
Cython/Compiler/ExprNodes.py
View file @
985d50f3
...
...
@@ -584,10 +584,10 @@ class ExprNode(Node):
if
dst_type
.
is_reference
:
dst_type
=
dst_type
.
ref_base_type
if
dst_type
.
is_memoryview
:
if
dst_type
.
is_memoryview
slice
:
import
MemoryView
if
not
src
.
type
.
is_memoryview
:
src
=
CoerceToMemViewNode
(
src
,
dst_type
,
env
)
if
not
src
.
type
.
is_memoryview
slice
:
src
=
CoerceToMemView
Slice
Node
(
src
,
dst_type
,
env
)
elif
not
MemoryView
.
src_conforms_to_dst
(
src
.
type
,
dst_type
):
error
(
self
.
pos
,
"Memoryview '%s' not conformable to memoryview '%s'."
%
(
src
.
type
,
dst_type
))
...
...
@@ -1654,8 +1654,8 @@ class NameNode(AtomicExprNode):
rhs
.
generate_disposal_code
(
code
)
rhs
.
free_temps
(
code
)
else
:
if
self
.
type
.
is_memoryview
:
self
.
generate_acquire_memoryview
(
rhs
,
code
)
if
self
.
type
.
is_memoryview
slice
:
self
.
generate_acquire_memoryview
slice
(
rhs
,
code
)
elif
self
.
type
.
is_buffer
:
# Generate code for doing the buffer release/acquisition.
...
...
@@ -1691,7 +1691,7 @@ class NameNode(AtomicExprNode):
code
.
put_decref
(
self
.
result
(),
self
.
ctype
())
if
is_external_ref
:
code
.
put_giveref
(
rhs
.
py_result
())
if
not
self
.
type
.
is_memoryview
:
if
not
self
.
type
.
is_memoryview
slice
:
code
.
putln
(
'%s = %s;'
%
(
self
.
result
(),
rhs
.
result_as
(
self
.
ctype
())))
if
debug_disposal_code
:
print
(
"NameNode.generate_assignment_code:"
)
...
...
@@ -1699,9 +1699,9 @@ class NameNode(AtomicExprNode):
rhs
.
generate_post_assignment_code
(
code
)
rhs
.
free_temps
(
code
)
def
generate_acquire_memoryview
(
self
,
rhs
,
code
):
def
generate_acquire_memoryview
slice
(
self
,
rhs
,
code
):
import
MemoryView
MemoryView
.
put_assign_to_memview
(
self
.
result
(),
rhs
.
result
(),
self
.
type
,
MemoryView
.
put_assign_to_memview
slice
(
self
.
result
(),
rhs
.
result
(),
self
.
type
,
pos
=
self
.
pos
,
code
=
code
)
if
rhs
.
is_temp
:
code
.
put_xdecref_clear
(
"%s.memview"
%
rhs
.
result
(),
py_object_type
)
...
...
@@ -3944,13 +3944,13 @@ class AttributeNode(ExprNode):
code
.
put_giveref
(
rhs
.
py_result
())
code
.
put_gotref
(
select_code
)
code
.
put_decref
(
select_code
,
self
.
ctype
())
elif
self
.
type
.
is_memoryview
:
elif
self
.
type
.
is_memoryview
slice
:
import
MemoryView
MemoryView
.
put_assign_to_memview
(
select_code
,
rhs
.
result
(),
self
.
type
,
MemoryView
.
put_assign_to_memview
slice
(
select_code
,
rhs
.
result
(),
self
.
type
,
pos
=
self
.
pos
,
code
=
code
)
if
rhs
.
is_temp
:
code
.
put_xdecref_clear
(
"%s.memview"
%
rhs
.
result
(),
py_object_type
)
if
not
self
.
type
.
is_memoryview
:
if
not
self
.
type
.
is_memoryview
slice
:
code
.
putln
(
"%s = %s;"
%
(
select_code
,
...
...
@@ -7590,11 +7590,11 @@ class CoercionNode(ExprNode):
file
,
line
,
col
=
self
.
pos
code
.
annotate
((
file
,
line
,
col
-
1
),
AnnotationItem
(
style
=
'coerce'
,
tag
=
'coerce'
,
text
=
'[%s] to [%s]'
%
(
self
.
arg
.
type
,
self
.
type
)))
class
CoerceToMemViewNode
(
CoercionNode
):
class
CoerceToMemView
Slice
Node
(
CoercionNode
):
def
__init__
(
self
,
arg
,
dst_type
,
env
):
assert
dst_type
.
is_memoryview
assert
not
arg
.
type
.
is_memoryview
assert
dst_type
.
is_memoryview
slice
assert
not
arg
.
type
.
is_memoryview
slice
CoercionNode
.
__init__
(
self
,
arg
)
self
.
type
=
dst_type
self
.
env
=
env
...
...
Cython/Compiler/MemoryView.py
View file @
985d50f3
...
...
@@ -70,7 +70,7 @@ def put_init_entry(mv_cname, code):
code
.
put_init_to_py_none
(
"%s.memview"
%
mv_cname
,
cython_memoryview_type
)
code
.
put_giveref
(
"%s.memview"
%
mv_cname
)
def
put_assign_to_memview
(
lhs_cname
,
rhs_cname
,
memview
type
,
pos
,
code
):
def
put_assign_to_memview
slice
(
lhs_cname
,
rhs_cname
,
memviewslice
type
,
pos
,
code
):
# XXX: add error checks!
...
...
@@ -80,7 +80,7 @@ def put_assign_to_memview(lhs_cname, rhs_cname, memviewtype, pos, code):
code
.
put_xdecref
(
"%s.memview"
%
(
lhs_cname
),
py_object_type
)
code
.
putln
(
"%s.memview = %s.memview;"
%
(
lhs_cname
,
rhs_cname
))
code
.
putln
(
"%s.data = %s.data;"
%
(
lhs_cname
,
rhs_cname
))
ndim
=
len
(
memviewtype
.
axes
)
ndim
=
len
(
memview
slice
type
.
axes
)
for
i
in
range
(
ndim
):
code
.
putln
(
"%s.diminfo[%d] = %s.diminfo[%d];"
%
(
lhs_cname
,
i
,
rhs_cname
,
i
))
...
...
@@ -328,18 +328,18 @@ def _resolve_AttributeNode(env, node):
scope
=
scope
.
lookup
(
modname
).
as_module
return
scope
.
lookup
(
path
[
-
1
])
class
MemoryViewTransform
(
CythonTransform
):
class
MemoryView
Slice
Transform
(
CythonTransform
):
memviews_exist
=
False
def
__call__
(
self
,
node
):
return
super
(
MemoryViewTransform
,
self
).
__call__
(
node
)
return
super
(
MemoryView
Slice
Transform
,
self
).
__call__
(
node
)
def
inspect_scope
(
self
,
node
,
scope
):
memviewvars
=
[
entry
for
name
,
entry
in
scope
.
entries
.
iteritems
()
if
entry
.
type
.
is_memoryview
]
if
entry
.
type
.
is_memoryview
slice
]
if
memviewvars
:
self
.
memviews_exist
=
True
...
...
Cython/Compiler/ModuleNode.py
View file @
985d50f3
...
...
@@ -1185,13 +1185,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
type
=
scope
.
parent_type
base_type
=
type
.
base_type
py_attrs
=
[]
memview_attrs
=
[]
memview
slice
_attrs
=
[]
for
entry
in
scope
.
var_entries
:
if
entry
.
type
.
is_pyobject
:
py_attrs
.
append
(
entry
)
elif
entry
.
type
.
is_memoryview
:
memview_attrs
.
append
(
entry
)
need_self_cast
=
type
.
vtabslot_cname
or
py_attrs
or
memview_attrs
elif
entry
.
type
.
is_memoryview
slice
:
memview
slice
_attrs
.
append
(
entry
)
need_self_cast
=
type
.
vtabslot_cname
or
py_attrs
or
memview
slice
_attrs
code
.
putln
(
""
)
code
.
putln
(
"static PyObject *%s(PyTypeObject *t, PyObject *a, PyObject *k) {"
...
...
@@ -1234,7 +1234,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"p->%s = 0;"
%
entry
.
cname
)
else
:
code
.
put_init_var_to_py_none
(
entry
,
"p->%s"
,
nanny
=
False
)
for
entry
in
memview_attrs
:
for
entry
in
memview
slice
_attrs
:
code
.
putln
(
"p->%s.data = NULL;"
%
entry
.
cname
)
code
.
put_init_to_py_none
(
"p->%s.memview"
%
entry
.
cname
,
PyrexTypes
.
cython_memoryview_type
,
nanny
=
False
)
...
...
Cython/Compiler/Nodes.py
View file @
985d50f3
...
...
@@ -804,7 +804,7 @@ class CSimpleBaseTypeNode(CBaseTypeNode):
else
:
return
PyrexTypes
.
error_type
class
MemoryViewTypeNode
(
CBaseTypeNode
):
class
MemoryView
Slice
TypeNode
(
CBaseTypeNode
):
child_attrs
=
[
'base_type_node'
,
'axes'
]
...
...
@@ -822,7 +822,7 @@ class MemoryViewTypeNode(CBaseTypeNode):
self
.
type
=
PyrexTypes
.
ErrorType
()
return
self
.
type
self
.
type
=
PyrexTypes
.
MemoryViewType
(
base_type
,
axes_specs
,
env
)
self
.
type
=
PyrexTypes
.
MemoryView
Slice
Type
(
base_type
,
axes_specs
,
env
)
MemoryView
.
use_memview_util_code
(
env
)
return
self
.
type
...
...
@@ -965,7 +965,7 @@ class CVarDefNode(StatNode):
else
:
name_declarator
,
type
=
declarator
.
analyse
(
base_type
,
env
)
if
not
type
.
is_complete
():
if
not
(
self
.
visibility
==
'extern'
and
type
.
is_array
or
type
.
is_memoryview
):
if
not
(
self
.
visibility
==
'extern'
and
type
.
is_array
or
type
.
is_memoryview
slice
):
error
(
declarator
.
pos
,
"Variable type '%s' is incomplete"
%
type
)
if
self
.
visibility
==
'extern'
and
type
.
is_pyobject
:
...
...
@@ -1428,9 +1428,9 @@ class FuncDefNode(StatNode, BlockNode):
for
entry
in
lenv
.
var_entries
+
lenv
.
arg_entries
:
if
entry
.
type
.
is_buffer
and
entry
.
buffer_aux
.
buflocal_nd_var
.
used
:
Buffer
.
put_init_vars
(
entry
,
code
)
# ----- Initialise local memoryviews
# ----- Initialise local memoryview
slice
s
for
entry
in
lenv
.
var_entries
+
lenv
.
arg_entries
:
if
entry
.
type
.
is_memoryview
:
if
entry
.
type
.
is_memoryview
slice
:
MemoryView
.
put_init_entry
(
entry
.
cname
,
code
)
# ----- Check and convert arguments
self
.
generate_argument_type_tests
(
code
)
...
...
Cython/Compiler/Parsing.py
View file @
985d50f3
...
...
@@ -2002,6 +2002,7 @@ def p_c_simple_base_type(s, self_flag, nonempty, templates = None):
complex
=
complex
,
longness
=
longness
,
is_self_arg
=
self_flag
,
templates
=
templates
)
# declarations here.
if
s
.
sy
==
'['
:
if
is_memoryviewslice_access
(
s
):
type_node
=
p_memoryview_access
(
s
,
type_node
)
...
...
@@ -2043,24 +2044,25 @@ def p_bracketed_base_type(s, base_type_node, nonempty, empty):
# sizeof-like thing. Only anonymous C arrays allowed (int[SIZE]).
return
base_type_node
elif
not
empty
and
nonempty
:
# declaration of either memoryview or buffer.
if
is_memoryview_access
(
s
):
return
p_memoryview_access
(
s
,
base_type_node
)
# declaration of either memoryview
slice
or buffer.
if
is_memoryview
slice
_access
(
s
):
return
p_memoryview
slice
_access
(
s
,
base_type_node
)
else
:
return
p_buffer_access
(
s
,
base_type_node
)
elif
not
empty
and
not
nonempty
:
# only anonymous C arrays and memoryview arrays here. We disallow buffer
# declarations for now, due to ambiguity with anonymous C arrays.
if
is_memoryview_access
(
s
):
return
p_memoryview_access
(
s
,
base_type_node
)
# only anonymous C arrays and memoryview slice arrays here. We
# disallow buffer declarations for now, due to ambiguity with anonymous
# C arrays.
if
is_memoryviewslice_access
(
s
):
return
p_memoryviewslice_access
(
s
,
base_type_node
)
else
:
return
base_type_node
def
is_memoryview_access
(
s
):
def
is_memoryview
slice
_access
(
s
):
# s.sy == '['
# a memoryview declaration is distinguishable from a buffer access
# a memoryview
slice
declaration is distinguishable from a buffer access
# declaration by the first entry in the bracketed list. The buffer will
# not have an unnested colon in the first entry; the memoryview will.
# not have an unnested colon in the first entry; the memoryview
slice
will.
saved
=
[(
s
.
sy
,
s
.
systring
)]
s
.
next
()
retval
=
False
...
...
@@ -2077,7 +2079,7 @@ def is_memoryview_access(s):
return
retval
def
p_memoryview_access
(
s
,
base_type_node
):
def
p_memoryview
slice
_access
(
s
,
base_type_node
):
# s.sy == '['
pos
=
s
.
position
()
s
.
next
()
...
...
@@ -2088,7 +2090,7 @@ def p_memoryview_access(s, base_type_node):
s
.
error
(
"An axis specification in memoryview declaration does not have a ':'."
)
s
.
expect
(
']'
)
indexes
=
make_slice_nodes
(
pos
,
subscripts
)
result
=
Nodes
.
MemoryViewTypeNode
(
pos
,
result
=
Nodes
.
MemoryView
Slice
TypeNode
(
pos
,
base_type_node
=
base_type_node
,
axes
=
indexes
)
return
result
...
...
Cython/Compiler/PyrexTypes.py
View file @
985d50f3
...
...
@@ -114,7 +114,7 @@ class PyrexType(BaseType):
is_returncode
=
0
is_error
=
0
is_buffer
=
0
is_memoryview
=
0
is_memoryview
slice
=
0
has_attributes
=
0
default_value
=
""
...
...
@@ -313,13 +313,13 @@ class CTypedefType(BaseType):
def
__getattr__
(
self
,
name
):
return
getattr
(
self
.
typedef_base_type
,
name
)
class
MemoryViewType
(
PyrexType
):
class
MemoryView
Slice
Type
(
PyrexType
):
is_memoryview
=
1
is_memoryview
slice
=
1
def
__init__
(
self
,
base_dtype
,
axes
,
env
):
'''
MemoryViewType(base, axes)
MemoryView
Slice
Type(base, axes)
Base is the C base type; axes is a list of (access, packing) strings,
where access is one of 'full', 'direct' or 'ptr' and packing is one of
...
...
@@ -357,7 +357,7 @@ class MemoryViewType(PyrexType):
self
.
env
=
env
def
is_complete
(
self
):
# incomplete since the underlying struct doesn't have a
memoryview
.
# incomplete since the underlying struct doesn't have a
cython.memoryview object
.
return
0
def
declaration_code
(
self
,
entity_code
,
...
...
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