summaryrefslogtreecommitdiff
path: root/cffi/api.py
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2017-02-04 15:05:47 +0100
committerArmin Rigo <arigo@tunes.org>2017-02-04 15:05:47 +0100
commitb05cea94af19abfd675f4e4a46af338b6c329612 (patch)
tree5d08cf562c25ef6739451ca78ff77068479b4713 /cffi/api.py
parent00c4cf9b031aa19905e6e87325269acf2ae47121 (diff)
downloadcffi-b05cea94af19abfd675f4e4a46af338b6c329612.tar.gz
Make 'ffi.buffer' be the type of minibuffers returned by cffi, and
'ffi.buffer()' now calls the constructor.
Diffstat (limited to 'cffi/api.py')
-rw-r--r--cffi/api.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/cffi/api.py b/cffi/api.py
index 43b78f8..272a6a7 100644
--- a/cffi/api.py
+++ b/cffi/api.py
@@ -93,6 +93,7 @@ class FFI(object):
# ctypes backend: attach these constants to the instance
self.NULL = self.cast(self.BVoidP, 0)
self.CData, self.CType = backend._get_types()
+ self.buffer = backend.buffer
def cdef(self, csource, override=False, packed=False):
"""Parse the given C source. This registers all declared functions,
@@ -316,18 +317,18 @@ class FFI(object):
"""
return self._backend.unpack(cdata, length)
- def buffer(self, cdata, size=-1):
- """Return a read-write buffer object that references the raw C data
- pointed to by the given 'cdata'. The 'cdata' must be a pointer or
- an array. Can be passed to functions expecting a buffer, or directly
- manipulated with:
-
- buf[:] get a copy of it in a regular string, or
- buf[idx] as a single character
- buf[:] = ...
- buf[idx] = ... change the content
- """
- return self._backend.buffer(cdata, size)
+ #def buffer(self, cdata, size=-1):
+ # """Return a read-write buffer object that references the raw C data
+ # pointed to by the given 'cdata'. The 'cdata' must be a pointer or
+ # an array. Can be passed to functions expecting a buffer, or directly
+ # manipulated with:
+ #
+ # buf[:] get a copy of it in a regular string, or
+ # buf[idx] as a single character
+ # buf[:] = ...
+ # buf[idx] = ... change the content
+ # """
+ # note that 'buffer' is a type, set on this instance by __init__
def from_buffer(self, python_buffer):
"""Return a <cdata 'char[]'> that points to the data of the