klisp

an open source interpreter for the Kernel Programming Language.
git clone http://git.hanabi.in/repos/klisp.git
Log | Files | Refs | README

commit 0421fd85d63a911b730df305eb2fcc119697fa2b
parent 9cab3f60630432582e12fec00389f9e07cf07fd6
Author: Oto Havle <havleoto@gmail.com>
Date:   Thu, 27 Oct 2011 17:12:51 +0200

Added GTK example.

Diffstat:
Asrc/examples/ffi-gtk.k | 21+++++++++++++++++++++
1 file changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/examples/ffi-gtk.k b/src/examples/ffi-gtk.k @@ -0,0 +1,21 @@ +;; +;; Dynamic FFI example. +;; +;; Inspired by example gtk.lua from Lua Alien FFI library +;; (the original is only 11 lines long, though...) +;; + +($define! gtk (ffi-load-library "libgtk-x11-2.0.so.0")) +($define! i "sint") +($define! p "pointer") +($define! make + ($lambda (rtype name . atypes) + (ffi-make-applicative gtk name + (ffi-make-call-interface "FFI_DEFAULT_ABI" rtype atypes)))) + +($define! gtk-init (make "void" "gtk_init" p p)) +($define! gtk-message-dialog-new (make p "gtk_message_dialog_new" p i i i "string")) +($define! gtk-dialog-run (make i "gtk_dialog_run" p)) + +(gtk-init () ()) +(gtk-dialog-run (gtk-message-dialog-new () 0 0 1 "Klisp Rocks!"))