;; 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.18 2006-02-06 11:56:22 espen Exp $
+;; $Id: gparam.lisp,v 1.20 2006-02-15 09:55:50 espen Exp $
(in-package "GLIB")
(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+))
-
-(defun gvalue-weak-get (gvalue)
- (funcall (weak-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))
(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 ()