Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r732:dd5af0ee45d7
Date: 2012-07-28 13:03 +0200
http://bitbucket.org/cffi/cffi/changeset/dd5af0ee45d7/

Log:    Bah. Fix the demos for the updated way of 'ffi.new()'.

diff --git a/demo/_curses.py b/demo/_curses.py
--- a/demo/_curses.py
+++ b/demo/_curses.py
@@ -210,7 +210,7 @@
     if fd < 0:
         import sys
         fd = sys.stdout.fileno()
-    err = ffi.new("int")
+    err = ffi.new("int *")
     if lib.setupterm(term, fd, err) == ERR:
         if err[0] == 0:
             s = "setupterm: could not find terminal"
diff --git a/demo/btrfs-snap.py b/demo/btrfs-snap.py
--- a/demo/btrfs-snap.py
+++ b/demo/btrfs-snap.py
@@ -36,7 +36,7 @@
 target = os.open(opts.target, os.O_DIRECTORY)
 
 
-args = ffi.new('struct btrfs_ioctl_vol_args_v2')
+args = ffi.new('struct btrfs_ioctl_vol_args_v2 *')
 args.name = opts.newname
 args.fd = source
 args_buffer = ffi.buffer(args)
diff --git a/demo/cffi-cocoa.py b/demo/cffi-cocoa.py
--- a/demo/cffi-cocoa.py
+++ b/demo/cffi-cocoa.py
@@ -60,8 +60,8 @@
 NSTitledWindowMask = ffi.cast('NSUInteger', 1)
 NSBackingStoreBuffered = ffi.cast('NSBackingStoreType', 2)
 
-NSMakePoint = lambda x, y: ffi.new('NSPoint', (x, y))[0]
-NSMakeRect = lambda x, y, w, h: ffi.new('NSRect', ((x, y), (w, h)))[0]
+NSMakePoint = lambda x, y: ffi.new('NSPoint *', (x, y))[0]
+NSMakeRect = lambda x, y, w, h: ffi.new('NSRect *', ((x, y), (w, h)))[0]
 
 get, send, sel = objc.objc_getClass, objc.objc_msgSend, objc.sel_registerName
 at = lambda s: send(
diff --git a/demo/readdir.py b/demo/readdir.py
--- a/demo/readdir.py
+++ b/demo/readdir.py
@@ -40,8 +40,8 @@
         # error in openat()
         return
     dir = ffi.C.fdopendir(dirfd)
-    dirent = ffi.new("struct dirent")
-    result = ffi.new("struct dirent *")
+    dirent = ffi.new("struct dirent *")
+    result = ffi.new("struct dirent **")
     while True:
         if ffi.C.readdir_r(dir, dirent, result):
             # error in readdir_r()
diff --git a/demo/readdir2.py b/demo/readdir2.py
--- a/demo/readdir2.py
+++ b/demo/readdir2.py
@@ -47,8 +47,8 @@
         # error in openat()
         return
     dir = ffi.C.fdopendir(dirfd)
-    dirent = ffi.new("struct dirent")
-    result = ffi.new("struct dirent *")
+    dirent = ffi.new("struct dirent *")
+    result = ffi.new("struct dirent **")
     while True:
         if ffi.C.readdir_r(dir, dirent, result):
             # error in readdir_r()
diff --git a/demo/xclient.py b/demo/xclient.py
--- a/demo/xclient.py
+++ b/demo/xclient.py
@@ -4,7 +4,7 @@
 ffi.cdef("""
 
 typedef ... Display;
-typedef ... Window;
+typedef struct { ...; } Window;
 
 typedef struct { int type; ...; } XEvent;
 
@@ -33,7 +33,7 @@
     w = XCreateSimpleWindow(display, DefaultRootWindow(display),
                             10, 10, 500, 350, 0, 0, 0)
     XMapRaised(display, w)
-    event = ffi.new("XEvent")
+    event = ffi.new("XEvent *")
     XNextEvent(display, event)
 
 if __name__ == '__main__':
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to