コード例 #1
0
ファイル: _raw_api.py プロジェクト: CymatiCorp/CyKit
 def c_uint8_ptr(data):
     if isinstance(data, _buffer_type):
         # This only works for cffi >= 1.7
         return ffi.cast(uint8_t_type, ffi.from_buffer(data))
     elif byte_string(data) or isinstance(data, _Array):
         return data
     else:
         raise TypeError("Object type %s cannot be passed to C code" % type(data))
コード例 #2
0
ファイル: _raw_api.py プロジェクト: Cerebrock/BCI
 def c_uint8_ptr(data):
     if isinstance(data, _buffer_type):
         # This only works for cffi >= 1.7
         return ffi.cast(uint8_t_type, ffi.from_buffer(data))
     elif byte_string(data) or isinstance(data, _Array):
         return data
     else:
         raise TypeError("Object type %s cannot be passed to C code" % type(data))
コード例 #3
0
ファイル: _raw_api.py プロジェクト: CymatiCorp/CyKit
 def c_uint8_ptr(data):
     if byte_string(data) or isinstance(data, _Array):
         return data
     elif isinstance(data, _buffer_type):
         obj = _py_object(data)
         buf = _Py_buffer()
         _PyObject_GetBuffer(obj, byref(buf), _PyBUF_SIMPLE)
         buffer_type = c_ubyte * buf.len
         return buffer_type.from_address(buf.buf)
     else:
         raise TypeError("Object type %s cannot be passed to C code" % type(data))
コード例 #4
0
ファイル: _raw_api.py プロジェクト: Cerebrock/BCI
 def c_uint8_ptr(data):
     if byte_string(data) or isinstance(data, _Array):
         return data
     elif isinstance(data, _buffer_type):
         obj = _py_object(data)
         buf = _Py_buffer()
         _PyObject_GetBuffer(obj, byref(buf), _PyBUF_SIMPLE)
         buffer_type = c_ubyte * buf.len
         return buffer_type.from_address(buf.buf)
     else:
         raise TypeError("Object type %s cannot be passed to C code" % type(data))