[pypy-commit] cffi default: Update the example: the buffer is read-write.

arigo noreply at buildbot.pypy.org
Fri Jun 15 16:44:15 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r368:b153965be6e6
Date: 2012-06-15 16:44 +0200
http://bitbucket.org/cffi/cffi/changeset/b153965be6e6/

Log:	Update the example: the buffer is read-write.

diff --git a/doc/source/index.rst b/doc/source/index.rst
--- a/doc/source/index.rst
+++ b/doc/source/index.rst
@@ -120,9 +120,14 @@
         } pixel_t;
     """)
     image = ffi.new("pixel_t[]", 800*600)
-    image[0].r = 255
-    image[0].g = 192
-    image[0].b = 128
+
+    f = open('data', 'rb')
+    f.readinto(ffi.buffer(image))
+    f.close()
+
+    image[100].r = 255
+    image[100].g = 192
+    image[100].b = 128
 
     f = open('data', 'wb')
     f.write(ffi.buffer(image))


More information about the pypy-commit mailing list