Commit 381380c9 authored by Mark Florisson's avatar Mark Florisson

Silence some warnings

parent 54cbd0e8
...@@ -1466,7 +1466,8 @@ class CCodeWriter(object): ...@@ -1466,7 +1466,8 @@ class CCodeWriter(object):
if type.is_pyobject: if type.is_pyobject:
self.putln("%s = NULL;" % decl) self.putln("%s = NULL;" % decl)
elif type.is_memoryviewslice: elif type.is_memoryviewslice:
self.putln("%s = { 0 };" % decl) import MemoryView
self.putln("%s = %s;" % (decl, MemoryView.memslice_entry_init))
else: else:
self.putln("%s;" % decl) self.putln("%s;" % decl)
......
...@@ -60,6 +60,8 @@ _spec_to_abbrev = { ...@@ -60,6 +60,8 @@ _spec_to_abbrev = {
'follow' : '_', 'follow' : '_',
} }
memslice_entry_init = "{ 0, 0, { 0 }, { 0 }, { 0 } }"
memview_name = u'memoryview' memview_name = u'memoryview'
memview_typeptr_cname = '__pyx_memoryview_type' memview_typeptr_cname = '__pyx_memoryview_type'
memview_objstruct_cname = '__pyx_memoryview_obj' memview_objstruct_cname = '__pyx_memoryview_obj'
...@@ -529,7 +531,8 @@ class CopyFuncUtilCode(object): ...@@ -529,7 +531,8 @@ class CopyFuncUtilCode(object):
mode = 'fortran' mode = 'fortran'
contig_flag = memview_f_contiguous contig_flag = memview_f_contiguous
context = dict( C = dict(
context,
copy_name=self.copy_func_name, copy_name=self.copy_func_name,
mode=mode, mode=mode,
sizeof_dtype="sizeof(%s)" % self.from_memview.dtype.declaration_code(''), sizeof_dtype="sizeof(%s)" % self.from_memview.dtype.declaration_code(''),
...@@ -539,7 +542,7 @@ class CopyFuncUtilCode(object): ...@@ -539,7 +542,7 @@ class CopyFuncUtilCode(object):
_, copy_code = UtilityCode.load_as_string("MemviewSliceCopyTemplate", _, copy_code = UtilityCode.load_as_string("MemviewSliceCopyTemplate",
from_file="MemoryView_C.c", from_file="MemoryView_C.c",
context=context) context=C)
code.put(copy_code) code.put(copy_code)
...@@ -915,6 +918,7 @@ context = { ...@@ -915,6 +918,7 @@ context = {
'memview_struct_name': memview_objstruct_cname, 'memview_struct_name': memview_objstruct_cname,
'max_dims': Options.buffer_max_dims, 'max_dims': Options.buffer_max_dims,
'memviewslice_name': memviewslice_cname, 'memviewslice_name': memviewslice_cname,
'memslice_init': memslice_entry_init,
} }
memviewslice_declare_code = load_memview_c_utility( memviewslice_declare_code = load_memview_c_utility(
"MemviewSliceStruct", "MemviewSliceStruct",
......
...@@ -383,7 +383,8 @@ class Scope(object): ...@@ -383,7 +383,8 @@ class Scope(object):
entries[name] = entry entries[name] = entry
if type.is_memoryviewslice: if type.is_memoryviewslice:
entry.init = "{ 0, 0 }" import MemoryView
entry.init = MemoryView.memslice_entry_init
entry.scope = self entry.scope = self
entry.visibility = visibility entry.visibility = visibility
......
...@@ -174,6 +174,9 @@ cdef extern from "pythread.h": ...@@ -174,6 +174,9 @@ cdef extern from "pythread.h":
int PyThread_acquire_lock(PyThread_type_lock, int mode) nogil int PyThread_acquire_lock(PyThread_type_lock, int mode) nogil
void PyThread_release_lock(PyThread_type_lock) nogil void PyThread_release_lock(PyThread_type_lock) nogil
cdef extern from "string.h":
void *memset(void *b, int c, size_t len)
cdef extern from *: cdef extern from *:
int __Pyx_GetBuffer(object, Py_buffer *, int) except -1 int __Pyx_GetBuffer(object, Py_buffer *, int) except -1
void __Pyx_ReleaseBuffer(Py_buffer *) void __Pyx_ReleaseBuffer(Py_buffer *)
...@@ -415,9 +418,13 @@ cdef tuple _unellipsify(object index, int ndim): ...@@ -415,9 +418,13 @@ cdef tuple _unellipsify(object index, int ndim):
cdef memoryview memview_slice(memoryview memview, object indices): cdef memoryview memview_slice(memoryview memview, object indices):
cdef int new_ndim = 0, suboffset_dim = -1, dim cdef int new_ndim = 0, suboffset_dim = -1, dim
cdef bint negative_step cdef bint negative_step
cdef {{memviewslice_name}} dst, src cdef {{memviewslice_name}} src, dst
cdef {{memviewslice_name}} *p_src cdef {{memviewslice_name}} *p_src
# dst is copied by value in memoryview_fromslice -- initialize it
# src is never copied
memset(&dst, 0, sizeof(dst))
cdef _memoryviewslice memviewsliceobj cdef _memoryviewslice memviewsliceobj
assert memview.view.ndim > 0 assert memview.view.ndim > 0
......
...@@ -49,7 +49,7 @@ static CYTHON_INLINE char *__pyx_memviewslice_index_full(const char *bufp, Py_ss ...@@ -49,7 +49,7 @@ static CYTHON_INLINE char *__pyx_memviewslice_index_full(const char *bufp, Py_ss
/////////////// ObjectToMemviewSlice /////////////// /////////////// ObjectToMemviewSlice ///////////////
static CYTHON_INLINE {{memviewslice_name}} {{funcname}}(PyObject *obj) { static CYTHON_INLINE {{memviewslice_name}} {{funcname}}(PyObject *obj) {
{{memviewslice_name}} result = {0}; {{memviewslice_name}} result = {{memslice_init}};
struct __pyx_memoryview_obj *memview = \ struct __pyx_memoryview_obj *memview = \
(struct __pyx_memoryview_obj *) __pyx_memoryview_new(obj, {{buf_flag}}); (struct __pyx_memoryview_obj *) __pyx_memoryview_new(obj, {{buf_flag}});
...@@ -336,7 +336,7 @@ static __Pyx_memviewslice {{copy_name}}(const __Pyx_memviewslice from_mvs) { ...@@ -336,7 +336,7 @@ static __Pyx_memviewslice {{copy_name}}(const __Pyx_memviewslice from_mvs) {
__Pyx_RefNannyDeclarations __Pyx_RefNannyDeclarations
int i; int i;
__Pyx_memviewslice new_mvs = {0, 0}; __Pyx_memviewslice new_mvs = {{memslice_init}};
struct __pyx_memoryview_obj *from_memview = from_mvs.memview; struct __pyx_memoryview_obj *from_memview = from_mvs.memview;
Py_buffer *buf = &from_memview->view; Py_buffer *buf = &from_memview->view;
PyObject *shape_tuple = 0; PyObject *shape_tuple = 0;
......
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