Skip to content
Snippets Groups Projects
Commit e9dffd017ba5 authored by Kurt Smith's avatar Kurt Smith
Browse files

stubs for MemoryViewSliceType copy() and copy_fortran() functions

parent 545020f67c82
No related branches found
No related tags found
No related merge requests found
...@@ -292,10 +292,43 @@ ...@@ -292,10 +292,43 @@
def attributes_known(self): def attributes_known(self):
if self.scope is None: if self.scope is None:
import Symtab
self.scope = Symtab.StructOrUnionScope(self.specalization_name()) import Symtab, MemoryView
# XXX: we don't necessarily want to have this exposed -- for
# testing purposes currently. self.scope = scope = Symtab.CClassScope(
self.scope.declare_var("data", c_char_ptr_type, None, "data") 'mvs_class_'+self.specialization_suffix(),
self.env.global_scope(),
visibility='private')
scope.parent_type = self
# the C copy method
c_copy_name = '__Pyx_CopyBuffer_C_'+self.specialization_suffix()
scope.declare_cfunction('copy',
CFuncType(cython_memoryview_ptr_type,
[CFuncTypeArg("memviewslice", self, None)]),
pos = None,
defining = 1,
cname = c_copy_name)
# the Fortran copy method
f_copy_name = '__Pyx_CopyBuffer_F_'+self.specialization_suffix()
scope.declare_cfunction('copy_fortran',
CFuncType(cython_memoryview_ptr_type,
[CFuncTypeArg("memviewslice", self, None)]),
pos = None,
defining = 1,
cname = f_copy_name)
# ensure the right util code is used
MemoryView.use_cython_array(self.env)
MemoryView.use_memview_util_code(self.env)
# C copy method implementation.
ccopy_util_code = UtilityCode()
# ccopy_util_code.proto =#XXX
return True return True
...@@ -300,5 +333,11 @@ ...@@ -300,5 +333,11 @@
return True return True
def axes_to_str(self):
return "".join([access[0]+packing[0] for (access, packing) in self.axes])
def specialization_suffix(self):
return self.axes_to_str() + '_' + self.dtype.specalization_name()
def global_init_code(self, entry, code): def global_init_code(self, entry, code):
code.putln("%s.data = NULL;" % entry.cname) code.putln("%s.data = NULL;" % entry.cname)
code.put_init_to_py_none("%s.memview" % entry.cname, cython_memoryview_ptr_type, nanny=False) code.put_init_to_py_none("%s.memview" % entry.cname, cython_memoryview_ptr_type, nanny=False)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment