[pypy-commit] cffi default: Document 61e03368485c and 4d6671385e08. Remove the "new in version 0.9"

arigo pypy.commits at gmail.com
Fri Jun 3 07:59:21 EDT 2016


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r2703:61aa9f30a8cc
Date: 2016-06-03 14:00 +0200
http://bitbucket.org/cffi/cffi/changeset/61aa9f30a8cc/

Log:	Document 61e03368485c and 4d6671385e08. Remove the "new in version
	0.9" as deprecated; keep only "new in version 1.x".

diff --git a/doc/source/cdef.rst b/doc/source/cdef.rst
--- a/doc/source/cdef.rst
+++ b/doc/source/cdef.rst
@@ -183,11 +183,11 @@
   ``c_f = ffi.cast("FILE *", fileobj)`` and then pass around ``c_f``.
 
 * all `common Windows types`_ are defined if you run
-  on Windows (``DWORD``, ``LPARAM``, etc.).  *Changed in version 0.9:* the
-  types ``TBYTE TCHAR LPCTSTR PCTSTR LPTSTR PTSTR PTBYTE PTCHAR`` are no
-  longer automatically defined; see `ffi.set_unicode()`_.
+  on Windows (``DWORD``, ``LPARAM``, etc.).  Exception:
+  ``TBYTE TCHAR LPCTSTR PCTSTR LPTSTR PTSTR PTBYTE PTCHAR`` are
+  not automatically defined; see `ffi.set_unicode()`_.
 
-* *New in version 0.9.3:* the other standard integer types from
+* the other standard integer types from
   stdint.h, like ``intmax_t``, as long as they map to integers of 1,
   2, 4 or 8 bytes.  Larger integers are not supported.
 
@@ -253,7 +253,7 @@
 PTCHAR`` to be (pointers to) ``wchar_t``.  If ``enabled_flag`` is
 False, declare these types to be (pointers to) plain 8-bit characters.
 (These types are not predeclared at all if you don't call
-``set_unicode()``.)  *New in version 0.9.*
+``set_unicode()``.)
 
 The reason behind this method is that a lot of standard functions have
 two versions, like ``MessageBoxA()`` and ``MessageBoxW()``.  The
@@ -724,9 +724,8 @@
 
 * ``source_extension`` has the same meaning as in ``ffi.set_source()``.
 
-*  The optional ``flags`` argument has been added in version 0.9;
-   see ``man dlopen``
-   (ignored on Windows).  It defaults to ``ffi.RTLD_NOW``.  (With
+*  The optional ``flags`` argument (ignored on Windows) defaults to
+   ``ffi.RTLD_NOW``; see ``man dlopen``.  (With
    ``ffi.set_source()``, you would use ``sys.setdlopenflags()``.)
 
 *  The optional ``relative_to`` argument is useful if you need to list
diff --git a/doc/source/ref.rst b/doc/source/ref.rst
--- a/doc/source/ref.rst
+++ b/doc/source/ref.rst
@@ -171,16 +171,24 @@
 buffer interface.  This is the opposite of ``ffi.buffer()``.  It gives
 a reference to the existing data, not a copy; for this
 reason, and for PyPy compatibility, it does not work with the built-in
-types str or unicode or bytearray (or buffers/memoryviews on them).
+types str or unicode (or buffers/memoryviews on them).
 It is meant to be used on objects
-containing large quantities of raw data, like ``array.array`` or numpy
+containing large quantities of raw data, like bytearrays
+or ``array.array`` or numpy
 arrays.  It supports both the old buffer API (in Python 2.x) and the
 new memoryview API.  Note that if you pass a read-only buffer object,
 you still get a regular ``<cdata 'char[]'>``; it is your responsibility
 not to write there if the original buffer doesn't expect you to.
 The original object is kept alive (and, in case
 of memoryview, locked) as long as the cdata object returned by
-``ffi.from_buffer()`` is alive.  *New in version 0.9.*
+``ffi.from_buffer()`` is alive.
+
+A common use case is calling a C function with some ``char *`` that
+points to the internal buffer of a Python object; for this case you
+can directly pass ``ffi.from_buffer(python_buffer)`` as argument to
+the call.
+
+*New in version 1.7:* the python_buffer can be a bytearray object.
 
 
 ffi.memmove()
@@ -255,7 +263,6 @@
 offset within the struct of the given field.  Corresponds to ``offsetof()``
 in C.
 
-*New in version 0.9:*
 You can give several field names in case of nested structures.  You
 can also give numeric values which correspond to array items, in case
 of a pointer or array type.  For example, ``ffi.offsetof("int[5]", 2)``
diff --git a/doc/source/whatsnew.rst b/doc/source/whatsnew.rst
--- a/doc/source/whatsnew.rst
+++ b/doc/source/whatsnew.rst
@@ -16,6 +16,16 @@
   this would only return False for cdata objects of a pointer type when
   the pointer is NULL.
 
+* bytearrays: ``ffi.from_buffer(bytearray-object)`` is now supported.
+  (The reason it was not supported was that it was hard to do in PyPy,
+  but it works since PyPy 5.2.)  You can call C functions with a
+  ``char *`` argument from any buffer object, now including
+  bytearrays, by giving them ``ffi.from_buffer(..)`` as argument.
+  Additionally, you can now do ``p[0:length] = bytearray-object``.
+  The problem with this was that a iterating over bytearrays gives
+  *numbers* instead of *characters*.  (Now it is implemented with just
+  a memcpy, of course, not actually iterating over the characters.)
+
 
 v1.6
 ====


More information about the pypy-commit mailing list