chiark / gitweb /
Mapped NIL type to "void"
[clg] / glib / gparam.lisp
index ec24b969ad4172af1d429c4c89d08877b6df3adc..5b2f4faf3a1c81df86bd719ca77aa27bf49dd66c 100644 (file)
 ;; License along with this library; if not, write to the Free Software
 ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-;; $Id: gparam.lisp,v 1.11 2004-11-19 13:02:51 espen Exp $
+;; $Id: gparam.lisp,v 1.14 2005-01-12 13:31:57 espen Exp $
 
 (in-package "GLIB")
 
 (deftype gvalue () 'pointer)
 
+(register-type 'gvalue "GValue")
+
 (eval-when (:compile-toplevel :load-toplevel :execute)
   (defbinding (size-of-gvalue "size_of_gvalue") () unsigned-int))
 
@@ -41,11 +43,11 @@ (defun gvalue-init (gvalue type &optional (value nil value-p))
   (when value-p
     (funcall (writer-function type) value gvalue +gvalue-value-offset+)))
 
-(defun gvalue-new (type &optional (value nil value-p))
+(defun gvalue-new (&optional type (value nil value-p))
   (let ((gvalue (allocate-memory +gvalue-size+)))
-    (if value-p
-       (gvalue-init gvalue type value)
-      (gvalue-init gvalue type))
+    (cond
+     (value-p (gvalue-init gvalue type value))
+     (type (gvalue-init gvalue type)))
     gvalue))
 
 (defun gvalue-free (gvalue &optional (unset-p t))
@@ -66,10 +68,14 @@ (defun gvalue-set (gvalue value)
    value gvalue +gvalue-value-offset+)
   value)
 
-(defmacro with-gvalue ((gvalue type &optional (value nil value-p)) &body body)
-  `(let ((,gvalue ,(if value-p
-                      `(gvalue-new ',type ,value)
-                    `(gvalue-new ',type ,value))))
+(defbinding (gvalue-p "g_type_check_value") () boolean
+  (location pointer))
+
+(defmacro with-gvalue ((gvalue &optional type (value nil value-p)) &body body)
+  `(let ((,gvalue ,(cond
+                   ((and type value-p) `(gvalue-new ,type ,value))
+                   (type `(gvalue-new ,type))
+                   (`(gvalue-new)))))
     (unwind-protect
         (progn
           ,@body