summaryrefslogtreecommitdiff
path: root/cffi/backend_ctypes.py
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2012-10-29 09:17:16 +0100
committerArmin Rigo <arigo@tunes.org>2012-10-29 09:17:16 +0100
commit39f3365732e3f14030b7b2422a6e1376ab9c76f8 (patch)
treebd05d21edadba0933bc8f7fb7c4fb8319d28ac91 /cffi/backend_ctypes.py
parent56c69b1792334254e1ef49e2139be0a6afda296d (diff)
downloadcffi-39f3365732e3f14030b7b2422a6e1376ab9c76f8.tar.gz
Fix the tests and kill support in the ctypes backend.
Diffstat (limited to 'cffi/backend_ctypes.py')
-rw-r--r--cffi/backend_ctypes.py43
1 files changed, 1 insertions, 42 deletions
diff --git a/cffi/backend_ctypes.py b/cffi/backend_ctypes.py
index 7ce9839..1e08e39 100644
--- a/cffi/backend_ctypes.py
+++ b/cffi/backend_ctypes.py
@@ -980,48 +980,7 @@ class CTypesBackend(object):
return b._to_string(maxlen)
def buffer(self, bptr, size=-1):
- if sys.version_info >= (2, 7):
- # buf = bptr._as_ctype_ptr
- # return memoryview(buf.contents)
- if isinstance(bptr, CTypesGenericPtr):
- buf = bptr._as_ctype_ptr
- val = buf.contents
- elif isinstance(bptr, CTypesGenericArray):
- buf = bptr._blob
- val = bptr._blob
- else:
- raise TypeError(bptr)
- class Hack(ctypes.Union):
- _fields_ = [('stupid', type(val))]
- ptr = ctypes.cast(buf, ctypes.POINTER(Hack))
- view = memoryview(ptr.contents)
- try:
- view = view.cast('B')
- except AttributeError:
- raise NotImplementedError("buffer() with ctypes backend "
- "in Python < 3.3")
- if size >= 0:
- view = view[:size]
- return view
-
- # haaaaaaaaaaaack
- if '__pypy__' in sys.builtin_module_names:
- raise NotImplementedError("PyPy: ffi.buffer() with ctypes backend")
- call = ctypes.pythonapi.PyBuffer_FromReadWriteMemory
- call.argtypes = (ctypes.c_void_p, ctypes.c_size_t)
- call.restype = ctypes.py_object
- #
- if isinstance(bptr, CTypesGenericPtr):
- if size < 0:
- size = bptr._bitem_size
- return call(bptr._as_ctype_ptr, size)
- elif isinstance(bptr, CTypesGenericArray):
- if size < 0:
- size = ctypes.sizeof(bptr._blob)
- return call(ctypes.pointer(bptr._blob), size)
- else:
- raise TypeError("pointer or array argument expected, got %r" %
- (type(bptr).__name__,))
+ raise NotImplementedError("buffer() with ctypes backend")
def sizeof(self, cdata_or_BType):
if isinstance(cdata_or_BType, CTypesData):