Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added translate-to-foreign method for GSList

  • Loading branch information...
commit f97b6274683cfe0373105ac0e44edd9cae362804 1 parent 52dd586
@andy128k andy128k authored
Showing with 18 additions and 1 deletion.
  1. +18 −1 glib/glib.glist.lisp
View
19 glib/glib.glist.lisp
@@ -51,6 +51,8 @@
(data :pointer)
(next :pointer))
+(defcfun g-slist-alloc (:pointer g-slist))
+
(defcfun g-slist-free :void (list (:pointer g-slist)))
(defun g-slist-next (list)
@@ -64,4 +66,19 @@
(until (null-pointer-p c))
(collect (convert-from-foreign (foreign-slot-value c 'g-slist 'data) (gslist-type-type type))))
(when (gslist-type-free-from-foreign type)
- (g-slist-free pointer))))
+ (g-slist-free pointer))))
+
+(defmethod translate-to-foreign (list (type gslist-type))
+ (let ((result (null-pointer)) last)
+ (iter (for item in list)
+ (for n = (g-slist-alloc))
+ (for ptr = (convert-to-foreign item (gslist-type-type type)))
+ (setf (foreign-slot-value n 'g-slist 'data) ptr)
+ (setf (foreign-slot-value n 'g-slist 'next) (null-pointer))
+ (when last
+ (setf (foreign-slot-value last 'g-slist 'next) n))
+ (setf last n)
+ (when (first-iteration-p)
+ (setf result n)))
+ result))
+
Please sign in to comment.
Something went wrong with that request. Please try again.