X-Git-Url: https://git.distorted.org.uk/~mdw/clg/blobdiff_plain/112ac1d33aa8f9b7f3d2f9542d15431f152b1d35..8a2470dd09b8822bfcf11d5fbe965c02343557d5:/glib/gparam.lisp diff --git a/glib/gparam.lisp b/glib/gparam.lisp index d706580..86fe82c 100644 --- a/glib/gparam.lisp +++ b/glib/gparam.lisp @@ -20,7 +20,7 @@ ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -;; $Id: gparam.lisp,v 1.17 2005-04-23 16:48:51 espen Exp $ +;; $Id: gparam.lisp,v 1.20 2006-02-15 09:55:50 espen Exp $ (in-package "GLIB") @@ -64,9 +64,9 @@ (defun gvalue-type (gvalue) (type-from-number (sap-ref-32 gvalue 0))) -(defun gvalue-get (gvalue) +(defun gvalue-get (gvalue &optional weak-p) (funcall (reader-function (gvalue-type gvalue)) - gvalue +gvalue-value-offset+)) + gvalue +gvalue-value-offset+ weak-p)) (defun gvalue-set (gvalue value) (funcall (writer-function (gvalue-type gvalue)) @@ -77,15 +77,12 @@ (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 - ,(unless value-p `(gvalue-get ,gvalue))) - (gvalue-free ,gvalue)))) + `(with-allocated-memory (,gvalue +gvalue-size+) + ,(cond + ((and type value-p) `(gvalue-init ,gvalue ,type ,value)) + (type `(gvalue-init ,gvalue ,type))) + ,@body + ,(unless value-p `(gvalue-get ,gvalue)))) (deftype param-flag-type ()