Example #1
0
 def do_unpack_fastpath(fmtiter):
     size = rffi.sizeof(TYPE)
     strbuf, pos = fmtiter.get_buffer_as_string_maybe()
     if strbuf is None or pos % size != 0 or not USE_FASTPATH:
         raise CannotUnpack
     fmtiter.skip(size)
     return str_storage_getitem(TYPE, strbuf, pos)
Example #2
0
 def do_unpack_fastpath(fmtiter):
     size = rffi.sizeof(TYPE)
     strbuf, pos = fmtiter.get_buffer_as_string_maybe()
     if strbuf is None or pos % size != 0 or not USE_FASTPATH:
         raise CannotUnpack
     fmtiter.skip(size)
     return str_storage_getitem(TYPE, strbuf, pos)
Example #3
0
 def unpack_ieee(fmtiter):
     size = rffi.sizeof(TYPE)
     if fmtiter.bigendian != native_is_bigendian or not native_is_ieee754:
         # fallback to the very slow unpacking code in ieee.py
         data = fmtiter.read(size)
         fmtiter.appendobj(ieee.unpack_float(data, fmtiter.bigendian))
         return
     ## XXX check if the following code is still needed
     ## if not str_storage_supported(TYPE):
     ##     # this happens e.g. on win32 and ARM32: we cannot read the string
     ##     # content as an array of doubles because it's not properly
     ##     # aligned. But we can read a longlong and convert to float
     ##     assert TYPE == rffi.DOUBLE
     ##     assert rffi.sizeof(TYPE) == 8
     ##     return unpack_longlong2float(fmtiter)
     try:
         # fast path
         val = unpack_fastpath(TYPE)(fmtiter)
     except CannotUnpack:
         # slow path, take the slice
         input = fmtiter.read(size)
         val = str_storage_getitem(TYPE, input, 0)
     fmtiter.appendobj(float(val))
Example #4
0
 def unpack_ieee(fmtiter):
     size = rffi.sizeof(TYPE)
     if fmtiter.bigendian != native_is_bigendian or not native_is_ieee754:
         # fallback to the very slow unpacking code in ieee.py
         data = fmtiter.read(size)
         fmtiter.appendobj(ieee.unpack_float(data, fmtiter.bigendian))
         return
     ## XXX check if the following code is still needed
     ## if not str_storage_supported(TYPE):
     ##     # this happens e.g. on win32 and ARM32: we cannot read the string
     ##     # content as an array of doubles because it's not properly
     ##     # aligned. But we can read a longlong and convert to float
     ##     assert TYPE == rffi.DOUBLE
     ##     assert rffi.sizeof(TYPE) == 8
     ##     return unpack_longlong2float(fmtiter)
     try:
         # fast path
         val = unpack_fastpath(TYPE)(fmtiter)
     except CannotUnpack:
         # slow path, take the slice
         input = fmtiter.read(size)
         val = str_storage_getitem(TYPE, input, 0)
     fmtiter.appendobj(float(val))
Example #5
0
 def llf(buf, offset):
     x = str_storage_getitem(TYPE, buf, offset)
     return lltype.cast_primitive(TARGET_TYPE, x)
Example #6
0
 def fn(offset):
     return str_storage_getitem(TYPE, buf, offset)
Example #7
0
 def str_storage_getitem(self, TYPE, buf, offset):
     return str_storage_getitem(TYPE, buf, offset)
Example #8
0
 def f(val):
     if byteorder == 'little':
         x = chr(val) + '\x00' * (size - 1)
     else:
         x = '\x00' * (size - 1) + chr(val)
     return str_storage_getitem(lltype.Signed, x, 0)
Example #9
0
 def f(val):
     if byteorder == 'little':
         x = chr(val) + '\x00'*(size-1)
     else:
         x = '\x00'*(size-1) + chr(val)
     return str_storage_getitem(lltype.Signed, x, 0)
Example #10
0
 def f():
     return str_storage_getitem(TYPE, buf, offset)
Example #11
0
 def llf(buf, offset):
     x = str_storage_getitem(TYPE, buf, offset)
     return lltype.cast_primitive(TARGET_TYPE, x)
Example #12
0
 def str_storage_getitem(self, TYPE, buf, offset):
     return str_storage_getitem(TYPE, buf, offset)