From 509ac181734d31efc90ec72929c6cd2b94ba0f64 Mon Sep 17 00:00:00 2001 From: Dmitry Kalyanov Date: Thu, 26 Feb 2009 01:38:51 +0300 Subject: [PATCH] Made subtest use g-boxed-refs --- subtest.lisp | 66 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/subtest.lisp b/subtest.lisp index cdcf069..53079f4 100644 --- a/subtest.lisp +++ b/subtest.lisp @@ -80,15 +80,15 @@ (tree-model-get-column-type tree-model-get-column-type-cb gobject::g-type (tree-model gobject:g-object) (index :int)) (tree-model-get-iter tree-model-get-iter-cb :boolean (tree-model gobject:g-object) (iter (gobject:g-boxed-ref tree-iter)) (path (gobject:g-boxed-ref tree-path))) (tree-model-get-path tree-model-get-path-cb (gobject:g-boxed-ref tree-path) (tree-model gobject:g-object) (iter (gobject:g-boxed-ref tree-iter))) - (tree-model-get-value tree-model-get-value-cb :void (tree-model gobject:g-object) (iter (:pointer tree-iter)) (n :int) (value (:pointer gobject::g-value))) - (tree-model-iter-next tree-model-iter-next-cb :boolean (tree-model gobject:g-object) (iter (:pointer tree-iter))) - (tree-model-iter-children tree-model-iter-children-cb :boolean (tree-model gobject:g-object) (iter (:pointer tree-iter)) (parent (:pointer tree-iter))) - (tree-model-iter-has-child tree-model-iter-has-child-cb :boolean (tree-model gobject:g-object) (iter (:pointer tree-iter))) - (tree-model-iter-n-children tree-model-iter-n-children-cb :int (tree-model gobject:g-object) (iter (:pointer tree-iter))) - (tree-model-iter-nth-child tree-model-iter-nth-child-cb :boolean (tree-model gobject:g-object) (iter (:pointer tree-iter)) (parent (:pointer tree-iter)) (n :int)) - (tree-model-iter-parent tree-model-iter-parent-cb :boolean (tree-model gobject:g-object) (iter (:pointer tree-iter)) (child (:pointer tree-iter))) - (tree-model-ref-node tree-model-ref-node-cb :void (tree-model gobject:g-object) (iter (:pointer tree-iter))) - (tree-model-unref-node tree-model-unref-node-cb :void (tree-model gobject:g-object) (iter (:pointer tree-iter)))) + (tree-model-get-value tree-model-get-value-cb :void (tree-model gobject:g-object) (iter (gobject:g-boxed-ref tree-iter)) (n :int) (value (:pointer gobject::g-value))) + (tree-model-iter-next tree-model-iter-next-cb :boolean (tree-model gobject:g-object) (iter (gobject:g-boxed-ref tree-iter))) + (tree-model-iter-children tree-model-iter-children-cb :boolean (tree-model gobject:g-object) (iter (gobject:g-boxed-ref tree-iter)) (parent (gobject:g-boxed-ref tree-iter))) + (tree-model-iter-has-child tree-model-iter-has-child-cb :boolean (tree-model gobject:g-object) (iter (gobject:g-boxed-ref tree-iter))) + (tree-model-iter-n-children tree-model-iter-n-children-cb :int (tree-model gobject:g-object) (iter (gobject:g-boxed-ref tree-iter))) + (tree-model-iter-nth-child tree-model-iter-nth-child-cb :boolean (tree-model gobject:g-object) (iter (gobject:g-boxed-ref tree-iter)) (parent (gobject:g-boxed-ref tree-iter)) (n :int)) + (tree-model-iter-parent tree-model-iter-parent-cb :boolean (tree-model gobject:g-object) (iter (gobject:g-boxed-ref tree-iter)) (child (gobject:g-boxed-ref tree-iter))) + (tree-model-ref-node tree-model-ref-node-cb :void (tree-model gobject:g-object) (iter (gobject:g-boxed-ref tree-iter))) + (tree-model-unref-node tree-model-unref-node-cb :void (tree-model gobject:g-object) (iter (gobject:g-boxed-ref tree-iter)))) (defclass array-list-store (gobject:g-object gtk:tree-model) ((items :initform (make-array 0 :adjustable t :fill-pointer t) :reader store-items) @@ -120,27 +120,27 @@ (aref (store-types tree-model) index)) (defmethod tree-model-get-iter ((model array-list-store) iter path) - (let ((indices (indices path))) - (when (= 1 (length indices)) - (setf (stamp iter) 0 (user-data iter) (first indices)) - (gobject:release iter) - (gobject:release path) - t))) + (gobject:using* (iter path) + (let ((indices (indices path))) + (when (= 1 (length indices)) + (setf (stamp iter) 0 (user-data iter) (first indices)) + t)))) -(defmethod tree-model-ref-node ((model array-list-store) iter)) -(defmethod tree-model-unref-node ((model array-list-store) iter)) +(defmethod tree-model-ref-node ((model array-list-store) iter) (gobject:release iter)) +(defmethod tree-model-unref-node ((model array-list-store) iter) (gobject:release iter)) (defmethod tree-model-iter-next ((model array-list-store) iter) - (cffi:with-foreign-slots ((stamp user-data) iter tree-iter) - (let ((n (cffi:pointer-address user-data))) + (gobject:using* (iter) + (let ((n (user-data iter))) (when (< n (1- (length (store-items model)))) - (setf user-data (cffi:make-pointer (1+ n))) + (setf (user-data iter) (1+ n)) t)))) (defmethod tree-model-iter-nth-child ((model array-list-store) iter parent n) - (cffi:with-foreign-slots ((stamp user-data user-data-2 user-data-3) iter tree-iter) - (setf stamp 0 user-data (cffi:make-pointer n) user-data-2 (cffi:null-pointer) user-data-3 (cffi:null-pointer))) - t) + (gobject:using* (iter parent) + (setf (stamp iter) 0 + (user-data iter) n) + t)) (defmethod tree-model-iter-n-children ((model array-list-store) iter) (if (cffi:null-pointer-p iter) @@ -148,20 +148,22 @@ 0)) (defmethod tree-model-get-path ((model array-list-store) iter) - (anaphora:aprog1 (make-instance 'tree-path) - (setf (indices anaphora:it) (list (user-data iter))) - (gobject:disown-boxed-ref anaphora:it) - (gobject:release iter))) + (gobject:using* (iter) + (anaphora:aprog1 (make-instance 'tree-path) + (setf (indices anaphora:it) (list (user-data iter))) + (gobject:disown-boxed-ref anaphora:it)))) (defmethod tree-model-iter-has-child ((model array-list-store) iter) + (gobject:release iter) nil) (defmethod tree-model-get-value ((model array-list-store) iter n value) - (let ((n-row (cffi:pointer-address (cffi:foreign-slot-value iter 'tree-iter 'user-data)))) - (gobject::set-g-value value - (funcall (aref (store-getters model) n) - (aref (store-items model) n-row)) - (aref (store-types model) n)))) + (gobject:using (iter) + (let ((n-row (user-data iter))) + (gobject::set-g-value value + (funcall (aref (store-getters model) n) + (aref (store-items model) n-row)) + (aref (store-types model) n))))) (cffi:defcfun (%gtk-tree-view-append-column "gtk_tree_view_append_column") :int (tree-view (gobject:g-object gtk:tree-view)) -- 1.7.10.4