self.type = self.base.type.dtype
self.is_buffer_access = True
self.buffer_type = self.base.entry.type
-
- if getting:
- # we only need a temp because result_code isn't refactored to
- # generation time, but this seems an ok shortcut to take
+
+ if getting and self.type.is_pyobject:
self.is_temp = True
- self.result_ctype = PyrexTypes.c_ptr_type(self.type)
if setting:
if not self.base.entry.type.writable:
error(self.pos, "Writing to readonly buffer")
def calculate_result_code(self):
if self.is_buffer_access:
- return "<not used>"
+ return "(*%s)" % self.buffer_ptr_code
else:
return "(%s[%s])" % (
self.base.result(), self.index.result())
if self.is_buffer_access:
if code.globalstate.directives['nonecheck']:
self.put_nonecheck(code)
- ptrcode = self.buffer_lookup_code(code)
- code.putln("%s = *%s;" % (
- self.result(),
- self.buffer_type.buffer_ptr_type.cast_code(ptrcode)))
- # Must incref the value we pulled out.
- if self.buffer_type.dtype.is_pyobject:
+ self.buffer_ptr_code = self.buffer_lookup_code(code)
+ if self.type.is_pyobject:
+ # is_temp is True, so must pull out value and incref it.
+ code.putln("%s = *%s;" % (self.result(), self.buffer_ptr_code))
code.putln("Py_INCREF((PyObject*)%s);" % self.result())
elif self.type.is_pyobject:
if self.index.type.is_int:
>>> E = ErrorBuffer("E")
"""
+
+import re
+exclude = []#re.compile('object').search]
def testcase(func):
+ for e in exclude:
+ if e(func.__name__):
+ return func
__test__[func.__name__] = setup_string + func.__doc__
return func
@testcase
def complex_struct_inplace(object[LongComplex] buf):
"""
- >>> complex_struct_dtype(LongComplexMockBuffer(None, [(0, -1)]))
+ >>> complex_struct_inplace(LongComplexMockBuffer(None, [(0, -1)]))
1.0 1.0
"""
buf[0].real += 1