[gtk-cffi-cvs] CVS gtk-cffi/g-lib
CVS User rklochkov
rklochkov at common-lisp.net
Sun Aug 28 10:31:30 UTC 2011
Update of /project/gtk-cffi/cvsroot/gtk-cffi/g-lib
In directory tiger.common-lisp.net:/tmp/cvs-serv22502/g-lib
Modified Files:
array.lisp list.lisp
Log Message:
Refactored GBoxed structs. Now they can be garbage collected
--- /project/gtk-cffi/cvsroot/gtk-cffi/g-lib/array.lisp 2011/08/26 17:16:13 1.1
+++ /project/gtk-cffi/cvsroot/gtk-cffi/g-lib/array.lisp 2011/08/28 10:31:30 1.2
@@ -23,7 +23,17 @@
(make-instance 'cffi-array :type type))
(defmethod translate-to-foreign (value (cffi-array cffi-array))
- value)
+ (if (pointerp value)
+ value
+ (let ((length (length value))
+ (type (element-type cffi-array)))
+ (let ((res (foreign-alloc type :count length)))
+ (dotimes (i length (values res t))
+ (setf (mem-aref res type i) (elt value i)))))))
+
+(defmethod free-translated-object (value (cffi-array cffi-array) param)
+ (when param
+ (foreign-free value)))
(defcfun g-free :void (var :pointer))
--- /project/gtk-cffi/cvsroot/gtk-cffi/g-lib/list.lisp 2011/08/26 17:16:13 1.3
+++ /project/gtk-cffi/cvsroot/gtk-cffi/g-lib/list.lisp 2011/08/28 10:31:30 1.4
@@ -52,7 +52,7 @@
(*list-type* (list-type g-list)))
(g-list-foreach ptr (callback list-collect) (null-pointer))
(g-list-free ptr)
- *list*))
+ (nreverse *list*)))
(defmethod translate-to-foreign (lisp-list (g-list g-list))
(declare (type list lisp-list))
More information about the gtk-cffi-cvs
mailing list