def _getvalue(self): addr = self._buffer[0] if addr == 0: return None else: size = SysStringLen(addr) return _rawffi.wcharp2rawunicode(addr, size)
def test_wcharp2rawunicode(self): import _rawffi A = _rawffi.Array('i') arg = A(1) arg[0] = 0x1234 u = _rawffi.wcharp2rawunicode(arg.itemaddress(0)) assert u == u'\u1234' u = _rawffi.wcharp2rawunicode(arg.itemaddress(0), 1) assert u == u'\u1234' arg[0] = -1 raises(ValueError, _rawffi.wcharp2rawunicode, arg.itemaddress(0)) raises(ValueError, _rawffi.wcharp2rawunicode, arg.itemaddress(0), 1) arg[0] = 0x110000 raises(ValueError, _rawffi.wcharp2rawunicode, arg.itemaddress(0)) raises(ValueError, _rawffi.wcharp2rawunicode, arg.itemaddress(0), 1) arg.free()
def _wstring_at_addr(addr, lgt): import ctypes cobj = ctypes.c_void_p.from_param(addr) arg = cobj._get_buffer_value() return _rawffi.wcharp2rawunicode(arg, lgt)