Commit 985d50f3 authored by Kurt Smith's avatar Kurt Smith Committed by Mark Florisson

consistent naming of all memoryview slice and cython.memoryview references.

parent bf083b70
......@@ -54,10 +54,10 @@ class IntroduceBufferAuxiliaryVars(CythonTransform):
if len(bufvars) > 0:
self.buffers_exists = True
memviewvars = [entry for name, entry
memviewslicevars = [entry for name, entry
in scope.entries.iteritems()
if entry.type.is_memoryview]
if len(memviewvars) > 0:
if entry.type.is_memoryviewslice]
if len(memviewslicevars) > 0:
self.buffers_exists = True
......
......@@ -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_memoryviewslice:
import MemoryView
if not src.type.is_memoryview:
src = CoerceToMemViewNode(src, dst_type, env)
if not src.type.is_memoryviewslice:
src = CoerceToMemViewSliceNode(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_memoryviewslice:
self.generate_acquire_memoryviewslice(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_memoryviewslice:
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_memoryviewslice(self, rhs, code):
import MemoryView
MemoryView.put_assign_to_memview(self.result(), rhs.result(), self.type,
MemoryView.put_assign_to_memviewslice(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_memoryviewslice:
import MemoryView
MemoryView.put_assign_to_memview(select_code, rhs.result(), self.type,
MemoryView.put_assign_to_memviewslice(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_memoryviewslice:
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 CoerceToMemViewSliceNode(CoercionNode):
def __init__(self, arg, dst_type, env):
assert dst_type.is_memoryview
assert not arg.type.is_memoryview
assert dst_type.is_memoryviewslice
assert not arg.type.is_memoryviewslice
CoercionNode.__init__(self, arg)
self.type = dst_type
self.env = env
......
......@@ -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, memviewtype, pos, code):
def put_assign_to_memviewslice(lhs_cname, rhs_cname, memviewslicetype, 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(memviewslicetype.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 MemoryViewSliceTransform(CythonTransform):
memviews_exist = False
def __call__(self, node):
return super(MemoryViewTransform, self).__call__(node)
return super(MemoryViewSliceTransform, 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_memoryviewslice]
if memviewvars:
self.memviews_exist = True
......
......@@ -1185,13 +1185,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
type = scope.parent_type
base_type = type.base_type
py_attrs = []
memview_attrs = []
memviewslice_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_memoryviewslice:
memviewslice_attrs.append(entry)
need_self_cast = type.vtabslot_cname or py_attrs or memviewslice_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 memviewslice_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)
......
......@@ -804,7 +804,7 @@ class CSimpleBaseTypeNode(CBaseTypeNode):
else:
return PyrexTypes.error_type
class MemoryViewTypeNode(CBaseTypeNode):
class MemoryViewSliceTypeNode(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.MemoryViewSliceType(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_memoryviewslice):
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 slices
for entry in lenv.var_entries + lenv.arg_entries:
if entry.type.is_memoryview:
if entry.type.is_memoryviewslice:
MemoryView.put_init_entry(entry.cname, code)
# ----- Check and convert arguments
self.generate_argument_type_tests(code)
......
......@@ -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_memoryviewslice_access(s):
return p_memoryviewslice_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_memoryviewslice_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_memoryviewslice_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.MemoryViewSliceTypeNode(pos,
base_type_node = base_type_node,
axes = indexes)
return result
......
......@@ -114,7 +114,7 @@ class PyrexType(BaseType):
is_returncode = 0
is_error = 0
is_buffer = 0
is_memoryview = 0
is_memoryviewslice = 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 MemoryViewSliceType(PyrexType):
is_memoryview = 1
is_memoryviewslice = 1
def __init__(self, base_dtype, axes, env):
'''
MemoryViewType(base, axes)
MemoryViewSliceType(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,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment