3 (define-foreign-type glist-type
()
4 ((type :reader glist-type-type
:initarg
:type
:initform
:pointer
)
5 (free-from-foreign :reader glist-type-free-from-foreign
:initarg
:free-from-foreign
:initform t
)
6 (free-to-foreign :reader glist-type-free-to-foreign
:initarg
:free-to-foreign
:initform t
))
7 (:actual-type
:pointer
))
9 (define-parse-method glist
(type &key
(free-from-foreign t
) (free-to-foreign t
))
10 (make-instance 'glist-type
12 :free-from-foreign free-from-foreign
13 :free-to-foreign free-to-foreign
))
20 (defcfun g-list-first
(:pointer g-list
) (list (:pointer g-list
)))
22 (defcfun g-list-free
:void
(list (:pointer g-list
)))
24 (defun g-list-next (list)
25 (if (null-pointer-p list
)
27 (foreign-slot-value list
'g-list
'next
)))
29 (defmethod translate-from-foreign (pointer (type glist-type
))
31 (iter (for c initially pointer then
(g-list-next c
))
32 (until (null-pointer-p c
))
33 (collect (convert-from-foreign (foreign-slot-value c
'g-list
'data
) (glist-type-type type
))))
34 (when (glist-type-free-from-foreign type
)
35 (g-list-free pointer
))))
38 (define-foreign-type gslist-type
()
39 ((type :reader gslist-type-type
:initarg
:type
:initform
:pointer
)
40 (free-from-foreign :reader gslist-type-free-from-foreign
:initarg
:free-from-foreign
:initform t
)
41 (free-to-foreign :reader gslist-type-free-to-foreign
:initarg
:free-to-foreign
:initform t
))
42 (:actual-type
:pointer
))
44 (define-parse-method gslist
(type &key
(free-from-foreign t
) (free-to-foreign t
))
45 (make-instance 'gslist-type
47 :free-from-foreign free-from-foreign
48 :free-to-foreign free-to-foreign
))
54 (defcfun g-slist-free
:void
(list (:pointer g-slist
)))
56 (defun g-slist-next (list)
57 (if (null-pointer-p list
)
59 (foreign-slot-value list
'g-slist
'next
)))
61 (defmethod translate-from-foreign (pointer (type gslist-type
))
63 (iter (for c initially pointer then
(g-slist-next c
))
64 (until (null-pointer-p c
))
65 (collect (convert-from-foreign (foreign-slot-value c
'g-slist
'data
) (gslist-type-type type
))))
66 (when (gslist-type-free-from-foreign type
)
67 (g-slist-free pointer
))))