chiark / gitweb /
Added pseudo type COPY-OF
[clg] / glib / gparam.lisp
index 1d90291a8dadd46bf3610cf842c4bd325bf78ed1..ec24b969ad4172af1d429c4c89d08877b6df3adc 100644 (file)
@@ -15,7 +15,7 @@
 ;; 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.9 2004-11-06 21:39:58 espen Exp $
+;; $Id: gparam.lisp,v 1.11 2004-11-19 13:02:51 espen Exp $
 
 (in-package "GLIB")
 
@@ -66,6 +66,15 @@ (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))))
+    (unwind-protect
+        (progn
+          ,@body
+          ,(unless value-p `(gvalue-get ,gvalue)))
+      (gvalue-free ,gvalue))))
 
 
 (deftype param-flag-type ()
@@ -125,12 +134,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))