Exemplo n.º 1
0
 def _wrap_result(self, restype, result):
     """
     Convert from low-level repr of the result to the high-level python
     one.
     """
     # hack for performance: if restype is a "simple" primitive type, don't
     # allocate the buffer because it's going to be thrown away immediately
     if self._is_primitive(restype) and not restype._is_pointer_like():
         return result
     #
     shape = restype._ffishape_
     if is_struct_shape(shape):
         buf = result
     else:
         buf = _rawffi.Array(shape)(1, autofree=True)
         buf[0] = result
     retval = restype._CData_retval(buf)
     return retval
Exemplo n.º 2
0
 def _wrap_result(self, restype, result):
     """
     Convert from low-level repr of the result to the high-level python
     one.
     """
     # hack for performance: if restype is a "simple" primitive type, don't
     # allocate the buffer because it's going to be thrown away immediately
     if self._is_primitive(restype) and not restype._is_pointer_like():
         return result
     #
     shape = restype._ffishape
     if is_struct_shape(shape):
         buf = result
     else:
         buf = _rawffi.Array(shape)(1, autofree=True)
         buf[0] = result
     retval = restype._CData_retval(buf)
     return retval