diff options
author | Kurt Smith <kwsmith1@wisc.edu> | 2009-08-09 18:38:20 -0500 |
---|---|---|
committer | Kurt Smith <kwsmith1@wisc.edu> | 2009-08-09 18:38:20 -0500 |
commit | d0d83a34d24831b96801883c36472f4a654a2cf1 (patch) | |
tree | 970ad56e0b1bbd633b97caf6b685512e5085919d | |
parent | 0707601e7fe8848047f5d4057522060ec1b2b02d (diff) | |
download | cython-d0d83a34d24831b96801883c36472f4a654a2cf1.tar.gz |
stubs for MemoryViewSliceType copy() and copy_fortran() functions
-rw-r--r-- | Cython/Compiler/PyrexTypes.py | 49 |
1 files changed, 44 insertions, 5 deletions
diff --git a/Cython/Compiler/PyrexTypes.py b/Cython/Compiler/PyrexTypes.py index a71500a10..d97dd497d 100644 --- a/Cython/Compiler/PyrexTypes.py +++ b/Cython/Compiler/PyrexTypes.py @@ -292,13 +292,52 @@ class MemoryViewSliceType(PyrexType): def attributes_known(self): if self.scope is None: - import Symtab - self.scope = Symtab.StructOrUnionScope(self.specalization_name()) - # XXX: we don't necessarily want to have this exposed -- for - # testing purposes currently. - self.scope.declare_var("data", c_char_ptr_type, None, "data") + + import Symtab, MemoryView + + self.scope = scope = Symtab.CClassScope( + '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 + 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): code.putln("%s.data = NULL;" % entry.cname) code.put_init_to_py_none("%s.memview" % entry.cname, cython_memoryview_ptr_type, nanny=False) |