chiark / gitweb /
Fixed previous broken change to DEFBINDING
[clg] / glib / gparam.lisp
index 4579a3299725631388cf710b7edc326faf34440b..d2a4b01db5388cf8806c68dfb91fcd146d28594d 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.10 2004-11-12 15:01:42 espen Exp $
+;; $Id: gparam.lisp,v 1.15 2005-02-03 23:09:04 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))
@@ -55,7 +57,7 @@ (defun gvalue-free (gvalue &optional (unset-p t))
     (deallocate-memory gvalue)))
 
 (defun gvalue-type (gvalue)
-  (type-from-number (system:sap-ref-32 gvalue 0)))
+  (type-from-number (sap-ref-32 gvalue 0)))
 
 (defun gvalue-get (gvalue)
   (funcall (reader-function (gvalue-type gvalue))
@@ -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
@@ -90,8 +96,7 @@ (eval-when (:compile-toplevel :load-toplevel :execute)
   (defclass param-spec-class (ginstance-class)
     ())
 
-  (defmethod validate-superclass 
-      ((class param-spec-class) (super pcl::standard-class))
+  (defmethod validate-superclass  ((class param-spec-class) (super standard-class))
     t ;(subtypep (class-name super) 'param)
 ))
 
@@ -134,12 +139,12 @@ (defclass param (ginstance)
     :allocation :virtual
     :getter "g_param_spec_get_nick"
     :reader param-nickname
-    :type string)
+    :type (copy-of string))
    (documentation
     :allocation :virtual
     :getter "g_param_spec_get_blurb"
     :reader param-documentation
-    :type string))
+    :type (copy-of string)))
   (:metaclass param-spec-class))