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): ...@@ -54,10 +54,10 @@ class IntroduceBufferAuxiliaryVars(CythonTransform):
if len(bufvars) > 0: if len(bufvars) > 0:
self.buffers_exists = True self.buffers_exists = True
memviewvars = [entry for name, entry memviewslicevars = [entry for name, entry
in scope.entries.iteritems() in scope.entries.iteritems()
if entry.type.is_memoryview] if entry.type.is_memoryviewslice]
if len(memviewvars) > 0: if len(memviewslicevars) > 0:
self.buffers_exists = True self.buffers_exists = True
......
...@@ -584,10 +584,10 @@ class ExprNode(Node): ...@@ -584,10 +584,10 @@ class ExprNode(Node):
if dst_type.is_reference: if dst_type.is_reference:
dst_type = dst_type.ref_base_type dst_type = dst_type.ref_base_type
if dst_type.is_memoryview: if dst_type.is_memoryviewslice:
import MemoryView import MemoryView
if not src.type.is_memoryview: if not src.type.is_memoryviewslice:
src = CoerceToMemViewNode(src, dst_type, env) src = CoerceToMemViewSliceNode(src, dst_type, env)
elif not MemoryView.src_conforms_to_dst(src.type, dst_type): elif not MemoryView.src_conforms_to_dst(src.type, dst_type):
error(self.pos, "Memoryview '%s' not conformable to memoryview '%s'." % error(self.pos, "Memoryview '%s' not conformable to memoryview '%s'." %
(src.type, dst_type)) (src.type, dst_type))
...@@ -1654,8 +1654,8 @@ class NameNode(AtomicExprNode): ...@@ -1654,8 +1654,8 @@ class NameNode(AtomicExprNode):
rhs.generate_disposal_code(code) rhs.generate_disposal_code(code)
rhs.free_temps(code) rhs.free_temps(code)
else: else:
if self.type.is_memoryview: if self.type.is_memoryviewslice:
self.generate_acquire_memoryview(rhs, code) self.generate_acquire_memoryviewslice(rhs, code)
elif self.type.is_buffer: elif self.type.is_buffer:
# Generate code for doing the buffer release/acquisition. # Generate code for doing the buffer release/acquisition.
...@@ -1691,7 +1691,7 @@ class NameNode(AtomicExprNode): ...@@ -1691,7 +1691,7 @@ class NameNode(AtomicExprNode):
code.put_decref(self.result(), self.ctype()) code.put_decref(self.result(), self.ctype())
if is_external_ref: if is_external_ref:
code.put_giveref(rhs.py_result()) 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()))) code.putln('%s = %s;' % (self.result(), rhs.result_as(self.ctype())))
if debug_disposal_code: if debug_disposal_code:
print("NameNode.generate_assignment_code:") print("NameNode.generate_assignment_code:")
...@@ -1699,9 +1699,9 @@ class NameNode(AtomicExprNode): ...@@ -1699,9 +1699,9 @@ class NameNode(AtomicExprNode):
rhs.generate_post_assignment_code(code) rhs.generate_post_assignment_code(code)
rhs.free_temps(code) rhs.free_temps(code)
def generate_acquire_memoryview(self, rhs, code): def generate_acquire_memoryviewslice(self, rhs, code):
import MemoryView 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) pos=self.pos, code=code)
if rhs.is_temp: if rhs.is_temp:
code.put_xdecref_clear("%s.memview" % rhs.result(), py_object_type) code.put_xdecref_clear("%s.memview" % rhs.result(), py_object_type)
...@@ -3944,13 +3944,13 @@ class AttributeNode(ExprNode): ...@@ -3944,13 +3944,13 @@ class AttributeNode(ExprNode):
code.put_giveref(rhs.py_result()) code.put_giveref(rhs.py_result())
code.put_gotref(select_code) code.put_gotref(select_code)
code.put_decref(select_code, self.ctype()) code.put_decref(select_code, self.ctype())
elif self.type.is_memoryview: elif self.type.is_memoryviewslice:
import MemoryView 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) pos=self.pos, code=code)
if rhs.is_temp: if rhs.is_temp:
code.put_xdecref_clear("%s.memview" % rhs.result(), py_object_type) 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( code.putln(
"%s = %s;" % ( "%s = %s;" % (
select_code, select_code,
...@@ -7590,11 +7590,11 @@ class CoercionNode(ExprNode): ...@@ -7590,11 +7590,11 @@ class CoercionNode(ExprNode):
file, line, col = self.pos 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))) 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): def __init__(self, arg, dst_type, env):
assert dst_type.is_memoryview assert dst_type.is_memoryviewslice
assert not arg.type.is_memoryview assert not arg.type.is_memoryviewslice
CoercionNode.__init__(self, arg) CoercionNode.__init__(self, arg)
self.type = dst_type self.type = dst_type
self.env = env self.env = env
......
...@@ -70,7 +70,7 @@ def put_init_entry(mv_cname, code): ...@@ -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_init_to_py_none("%s.memview" % mv_cname, cython_memoryview_type)
code.put_giveref("%s.memview" % mv_cname) 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! # XXX: add error checks!
...@@ -80,7 +80,7 @@ def put_assign_to_memview(lhs_cname, rhs_cname, memviewtype, pos, code): ...@@ -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.put_xdecref("%s.memview" % (lhs_cname), py_object_type)
code.putln("%s.memview = %s.memview;" % (lhs_cname, rhs_cname)) code.putln("%s.memview = %s.memview;" % (lhs_cname, rhs_cname))
code.putln("%s.data = %s.data;" % (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): for i in range(ndim):
code.putln("%s.diminfo[%d] = %s.diminfo[%d];" % (lhs_cname, i, rhs_cname, i)) code.putln("%s.diminfo[%d] = %s.diminfo[%d];" % (lhs_cname, i, rhs_cname, i))
...@@ -328,18 +328,18 @@ def _resolve_AttributeNode(env, node): ...@@ -328,18 +328,18 @@ def _resolve_AttributeNode(env, node):
scope = scope.lookup(modname).as_module scope = scope.lookup(modname).as_module
return scope.lookup(path[-1]) return scope.lookup(path[-1])
class MemoryViewTransform(CythonTransform): class MemoryViewSliceTransform(CythonTransform):
memviews_exist = False memviews_exist = False
def __call__(self, node): def __call__(self, node):
return super(MemoryViewTransform, self).__call__(node) return super(MemoryViewSliceTransform, self).__call__(node)
def inspect_scope(self, node, scope): def inspect_scope(self, node, scope):
memviewvars = [entry for name, entry memviewvars = [entry for name, entry
in scope.entries.iteritems() in scope.entries.iteritems()
if entry.type.is_memoryview] if entry.type.is_memoryviewslice]
if memviewvars: if memviewvars:
self.memviews_exist = True self.memviews_exist = True
......
...@@ -1185,13 +1185,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1185,13 +1185,13 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
type = scope.parent_type type = scope.parent_type
base_type = type.base_type base_type = type.base_type
py_attrs = [] py_attrs = []
memview_attrs = [] memviewslice_attrs = []
for entry in scope.var_entries: for entry in scope.var_entries:
if entry.type.is_pyobject: if entry.type.is_pyobject:
py_attrs.append(entry) py_attrs.append(entry)
elif entry.type.is_memoryview: elif entry.type.is_memoryviewslice:
memview_attrs.append(entry) memviewslice_attrs.append(entry)
need_self_cast = type.vtabslot_cname or py_attrs or memview_attrs need_self_cast = type.vtabslot_cname or py_attrs or memviewslice_attrs
code.putln("") code.putln("")
code.putln( code.putln(
"static PyObject *%s(PyTypeObject *t, PyObject *a, PyObject *k) {" "static PyObject *%s(PyTypeObject *t, PyObject *a, PyObject *k) {"
...@@ -1234,7 +1234,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode): ...@@ -1234,7 +1234,7 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code.putln("p->%s = 0;" % entry.cname) code.putln("p->%s = 0;" % entry.cname)
else: else:
code.put_init_var_to_py_none(entry, "p->%s", nanny=False) 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.putln("p->%s.data = NULL;" % entry.cname)
code.put_init_to_py_none("p->%s.memview" % entry.cname, code.put_init_to_py_none("p->%s.memview" % entry.cname,
PyrexTypes.cython_memoryview_type, nanny=False) PyrexTypes.cython_memoryview_type, nanny=False)
......
...@@ -804,7 +804,7 @@ class CSimpleBaseTypeNode(CBaseTypeNode): ...@@ -804,7 +804,7 @@ class CSimpleBaseTypeNode(CBaseTypeNode):
else: else:
return PyrexTypes.error_type return PyrexTypes.error_type
class MemoryViewTypeNode(CBaseTypeNode): class MemoryViewSliceTypeNode(CBaseTypeNode):
child_attrs = ['base_type_node', 'axes'] child_attrs = ['base_type_node', 'axes']
...@@ -822,7 +822,7 @@ class MemoryViewTypeNode(CBaseTypeNode): ...@@ -822,7 +822,7 @@ class MemoryViewTypeNode(CBaseTypeNode):
self.type = PyrexTypes.ErrorType() self.type = PyrexTypes.ErrorType()
return self.type 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) MemoryView.use_memview_util_code(env)
return self.type return self.type
...@@ -965,7 +965,7 @@ class CVarDefNode(StatNode): ...@@ -965,7 +965,7 @@ class CVarDefNode(StatNode):
else: else:
name_declarator, type = declarator.analyse(base_type, env) name_declarator, type = declarator.analyse(base_type, env)
if not type.is_complete(): 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, error(declarator.pos,
"Variable type '%s' is incomplete" % type) "Variable type '%s' is incomplete" % type)
if self.visibility == 'extern' and type.is_pyobject: if self.visibility == 'extern' and type.is_pyobject:
...@@ -1428,9 +1428,9 @@ class FuncDefNode(StatNode, BlockNode): ...@@ -1428,9 +1428,9 @@ class FuncDefNode(StatNode, BlockNode):
for entry in lenv.var_entries + lenv.arg_entries: for entry in lenv.var_entries + lenv.arg_entries:
if entry.type.is_buffer and entry.buffer_aux.buflocal_nd_var.used: if entry.type.is_buffer and entry.buffer_aux.buflocal_nd_var.used:
Buffer.put_init_vars(entry, code) Buffer.put_init_vars(entry, code)
# ----- Initialise local memoryviews # ----- Initialise local memoryview slices
for entry in lenv.var_entries + lenv.arg_entries: 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) MemoryView.put_init_entry(entry.cname, code)
# ----- Check and convert arguments # ----- Check and convert arguments
self.generate_argument_type_tests(code) self.generate_argument_type_tests(code)
......
...@@ -2002,6 +2002,7 @@ def p_c_simple_base_type(s, self_flag, nonempty, templates = None): ...@@ -2002,6 +2002,7 @@ def p_c_simple_base_type(s, self_flag, nonempty, templates = None):
complex = complex, longness = longness, complex = complex, longness = longness,
is_self_arg = self_flag, templates = templates) is_self_arg = self_flag, templates = templates)
# declarations here.
if s.sy == '[': if s.sy == '[':
if is_memoryviewslice_access(s): if is_memoryviewslice_access(s):
type_node = p_memoryview_access(s, type_node) type_node = p_memoryview_access(s, type_node)
...@@ -2043,24 +2044,25 @@ def p_bracketed_base_type(s, base_type_node, nonempty, empty): ...@@ -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]). # sizeof-like thing. Only anonymous C arrays allowed (int[SIZE]).
return base_type_node return base_type_node
elif not empty and nonempty: elif not empty and nonempty:
# declaration of either memoryview or buffer. # declaration of either memoryview slice or buffer.
if is_memoryview_access(s): if is_memoryviewslice_access(s):
return p_memoryview_access(s, base_type_node) return p_memoryviewslice_access(s, base_type_node)
else: else:
return p_buffer_access(s, base_type_node) return p_buffer_access(s, base_type_node)
elif not empty and not nonempty: elif not empty and not nonempty:
# only anonymous C arrays and memoryview arrays here. We disallow buffer # only anonymous C arrays and memoryview slice arrays here. We
# declarations for now, due to ambiguity with anonymous C arrays. # disallow buffer declarations for now, due to ambiguity with anonymous
if is_memoryview_access(s): # C arrays.
return p_memoryview_access(s, base_type_node) if is_memoryviewslice_access(s):
return p_memoryviewslice_access(s, base_type_node)
else: else:
return base_type_node return base_type_node
def is_memoryview_access(s): def is_memoryviewslice_access(s):
# s.sy == '[' # 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 # 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)] saved = [(s.sy, s.systring)]
s.next() s.next()
retval = False retval = False
...@@ -2077,7 +2079,7 @@ def is_memoryview_access(s): ...@@ -2077,7 +2079,7 @@ def is_memoryview_access(s):
return retval return retval
def p_memoryview_access(s, base_type_node): def p_memoryviewslice_access(s, base_type_node):
# s.sy == '[' # s.sy == '['
pos = s.position() pos = s.position()
s.next() s.next()
...@@ -2088,7 +2090,7 @@ def p_memoryview_access(s, base_type_node): ...@@ -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.error("An axis specification in memoryview declaration does not have a ':'.")
s.expect(']') s.expect(']')
indexes = make_slice_nodes(pos, subscripts) indexes = make_slice_nodes(pos, subscripts)
result = Nodes.MemoryViewTypeNode(pos, result = Nodes.MemoryViewSliceTypeNode(pos,
base_type_node = base_type_node, base_type_node = base_type_node,
axes = indexes) axes = indexes)
return result return result
......
...@@ -114,7 +114,7 @@ class PyrexType(BaseType): ...@@ -114,7 +114,7 @@ class PyrexType(BaseType):
is_returncode = 0 is_returncode = 0
is_error = 0 is_error = 0
is_buffer = 0 is_buffer = 0
is_memoryview = 0 is_memoryviewslice = 0
has_attributes = 0 has_attributes = 0
default_value = "" default_value = ""
...@@ -313,13 +313,13 @@ class CTypedefType(BaseType): ...@@ -313,13 +313,13 @@ class CTypedefType(BaseType):
def __getattr__(self, name): def __getattr__(self, name):
return getattr(self.typedef_base_type, 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): 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, 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 where access is one of 'full', 'direct' or 'ptr' and packing is one of
...@@ -357,7 +357,7 @@ class MemoryViewType(PyrexType): ...@@ -357,7 +357,7 @@ class MemoryViewType(PyrexType):
self.env = env self.env = env
def is_complete(self): 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 return 0
def declaration_code(self, entity_code, 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