Esempio n. 1
0
 def test_returning_unicode(self):
     import _rawffi
     A = _rawffi.Array('u')
     a = A(6, u'xx\x00\x00xx')
     res = _rawffi.wcharp2unicode(a.buffer)
     assert isinstance(res, unicode)
     assert res == u'xx'
     a.free()
Esempio n. 2
0
 def test_returning_unicode(self):
     import _rawffi
     A = _rawffi.Array('u')
     a = A(6, u'xx\x00\x00xx')
     res = _rawffi.wcharp2unicode(a.buffer)
     assert isinstance(res, unicode)
     assert res == u'xx'
     a.free()
Esempio n. 3
0
 def _CData_output(self, resarray, base=None, index=-1):
     # this seems to be a string if we're array of char, surprise!
     from ctypes import c_char, c_wchar
     if self._type_ is c_char:
         return _rawffi.charp2string(resarray.buffer, self._length_)
     if self._type_ is c_wchar:
         return _rawffi.wcharp2unicode(resarray.buffer, self._length_)
     res = self.__new__(self)
     ffiarray = self._ffiarray.fromaddress(resarray.buffer, self._length_)
     res._buffer = ffiarray
     res._base = base
     res._index = index
     return res
Esempio n. 4
0
 def _CData_output(self, resarray, base=None, index=-1):
     # this seems to be a string if we're array of char, surprise!
     from ctypes import c_char, c_wchar
     if self._type_ is c_char:
         return _rawffi.charp2string(resarray.buffer, self._length_)
     if self._type_ is c_wchar:
         return _rawffi.wcharp2unicode(resarray.buffer, self._length_)
     res = self.__new__(self)
     ffiarray = self._ffiarray.fromaddress(resarray.buffer, self._length_)
     res._buffer = ffiarray
     res._base = base
     res._index = index
     return res
Esempio n. 5
0
 def _CData_output(self, resarray, base=None, index=-1):
     from _rawffi.alt import types
     # If a char_p or unichar_p is received, skip the string interpretation
     if base._ffiargtype != types.Pointer(types.char_p) and \
        base._ffiargtype != types.Pointer(types.unichar_p):
         # this seems to be a string if we're array of char, surprise!
         from ctypes import c_char, c_wchar
         if self._type_ is c_char:
             return _rawffi.charp2string(resarray.buffer, self._length_)
         if self._type_ is c_wchar:
             return _rawffi.wcharp2unicode(resarray.buffer, self._length_)
     res = self.__new__(self)
     ffiarray = self._ffiarray.fromaddress(resarray.buffer, self._length_)
     res._buffer = ffiarray
     if base is not None:
         res._base = base
         res._index = index
     return res
Esempio n. 6
0
 def _getvalue(self):
     addr = self._buffer[0]
     if addr == 0:
         return None
     else:
         return _rawffi.wcharp2unicode(addr)
Esempio n. 7
0
 def getvalue(self):
     return _rawffi.wcharp2unicode(self._buffer.buffer,
                                   self._length_)
Esempio n. 8
0
 def _getvalue(self):
     addr = self._buffer[0]
     if addr == 0:
         return None
     else:
         return _rawffi.wcharp2unicode(addr)
Esempio n. 9
0
 def getvalue(self):
     return _rawffi.wcharp2unicode(self._buffer.buffer,
                                   self._length_)