diff options
Diffstat (limited to 'demo/xclient.py')
-rw-r--r-- | demo/xclient.py | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/demo/xclient.py b/demo/xclient.py index 0d66d8e..b8c7232 100644 --- a/demo/xclient.py +++ b/demo/xclient.py @@ -1,35 +1,14 @@ -import sys +import sys, os + +# If the build script was run immediately before this script, the cffi module +# ends up in the current directory. Make sure we can import it. sys.path.append('.') + try: - import _xclient + from _xclient import ffi, lib except ImportError: - from cffi import FFI - _ffi = FFI() - _ffi.cdef(""" - - typedef ... Display; - typedef struct { ...; } Window; - - typedef struct { int type; ...; } XEvent; - - Display *XOpenDisplay(char *display_name); - Window DefaultRootWindow(Display *display); - int XMapRaised(Display *display, Window w); - Window XCreateSimpleWindow(Display *display, Window parent, int x, int y, - unsigned int width, unsigned int height, - unsigned int border_width, unsigned long border, - unsigned long background); - int XNextEvent(Display *display, XEvent *event_return); - """) - - _ffi.set_source('_xclient', """ - #include <X11/Xlib.h> - """, libraries=['X11']) - _ffi.compile() - import _xclient - -ffi = _xclient.ffi -lib = _xclient.lib + print 'run %s_build first, then make sure the shared object is on sys.path' % os.path.splitext(__file__)[0] + sys.exit(-1) class XError(Exception): pass |