[gtk-cffi-cvs] CVS gtk-cffi/utils

CVS User rklochkov rklochkov at common-lisp.net
Fri Aug 26 17:16:14 UTC 2011


Update of /project/gtk-cffi/cvsroot/gtk-cffi/utils
In directory tiger.common-lisp.net:/tmp/cvs-serv16215/utils

Modified Files:
	gtk-cffi-utils.asd package.lisp utils.lisp 
Log Message:
Added GTK3 support. Dropped GTK2 support.
Refactored CFFI layer.



--- /project/gtk-cffi/cvsroot/gtk-cffi/utils/gtk-cffi-utils.asd	2011/08/08 15:02:02	1.1
+++ /project/gtk-cffi/cvsroot/gtk-cffi/utils/gtk-cffi-utils.asd	2011/08/26 17:16:14	1.2
@@ -8,6 +8,7 @@
   :author "Roman Klochkov <kalimehtar at mail.ru>"
   :version "1.0"
   :license "LGPL"
+  :depends-on (alexandria iterate cffi)
   :components
-  ((:file :package)
-   (:file :utils :depends-on (:package))))
\ No newline at end of file
+  ((:file package)
+   (:file utils :depends-on (package))))
\ No newline at end of file
--- /project/gtk-cffi/cvsroot/gtk-cffi/utils/package.lisp	2011/08/08 15:02:02	1.1
+++ /project/gtk-cffi/cvsroot/gtk-cffi/utils/package.lisp	2011/08/26 17:16:14	1.2
@@ -1,6 +1,9 @@
 (in-package #:cl-user)
 
 (defpackage #:gtk-cffi-utils
-  (:use #:common-lisp)
+  (:use #:common-lisp #:alexandria #:iterate)
   (:export
-   #:with-hash))
\ No newline at end of file
+   #:with-hash
+   #:memo
+   #:debug-out
+   #:bitmask))
--- /project/gtk-cffi/cvsroot/gtk-cffi/utils/utils.lisp	2011/08/08 15:02:02	1.1
+++ /project/gtk-cffi/cvsroot/gtk-cffi/utils/utils.lisp	2011/08/26 17:16:14	1.2
@@ -1,8 +1,40 @@
 (in-package :gtk-cffi-utils)
 
+(defmacro debug-out (&body body)
+;  (declare (ignore body))
+  `(format t , at body)
+  )
+
+(defmacro memo (place &nody body)
+  `(or ,place
+       (setf ,place , at body)))
+
+(defun find-key (key seq)
+  (when seq
+    (if (eq key (car seq)) 
+        (list (first seq) (second seq))
+        (find-key key (cddr seq)))))
+
 (defmacro with-hash (hash key &body body)
+  "If found KEY in HASH, return corresponding value,
+else use BODY to calculate the value and save to HASH.
+NIL values not saved"
   (let ((try (gensym)))
     `(or (gethash ,key ,hash)
          (let ((,try (progn , at body)))
            (when ,try
-             (setf (gethash ,key ,hash) ,try))))))
\ No newline at end of file
+             (setf (gethash ,key ,hash) ,try))))))
+
+(defmacro bitmask (&rest flags)
+  "Returns list from lisp values as keywords:
+ Example: (bitmask after swapped)
+ -> nil, when after=nil and swapped=nil
+ -> (:after), when after=t and swapped=nil
+ -> (:swapped), when after=nil and swapped=t
+ -> (:after :swapped), when both are t"
+  `(flatten
+    (list ,@(iter
+             (for flag in flags)
+             (collect `(when ,flag
+                         ,(make-keyword flag)))))))
+





More information about the gtk-cffi-cvs mailing list