Commits

Armin Rigo  committed dd5af0e

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

  • Participants
  • Parent commits 26a7f61

Comments (0)

Files changed (6)

File demo/_curses.py

     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"

File demo/btrfs-snap.py

 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)

File demo/cffi-cocoa.py

 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(

File demo/readdir.py

         # 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()

File demo/readdir2.py

         # 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()

File demo/xclient.py

 ffi.cdef("""
 
 typedef ... Display;
-typedef ... Window;
+typedef struct { ...; } Window;
 
 typedef struct { int type; ...; } XEvent;
 
     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__':