Correct the DEFPACKAGE for GOBJECT to work with recent closer-mop (0.60)
[cl-gtk2.git] / glib / glib.glist.lisp
blob22ea6bcff430308afa772a5d7429f8227d30e08c
1 (in-package :glib)
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
11 :type type
12 :free-from-foreign free-from-foreign
13 :free-to-foreign free-to-foreign))
15 (defcstruct g-list
16 (data :pointer)
17 (next :pointer)
18 (prev :pointer))
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)
26 (null-pointer)
27 (foreign-slot-value list 'g-list 'next)))
29 (defmethod translate-from-foreign (pointer (type glist-type))
30 (prog1
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
46 :type type
47 :free-from-foreign free-from-foreign
48 :free-to-foreign free-to-foreign))
50 (defcstruct g-slist
51 (data :pointer)
52 (next :pointer))
54 (defcfun g-slist-free :void (list (:pointer g-slist)))
56 (defun g-slist-next (list)
57 (if (null-pointer-p list)
58 (null-pointer)
59 (foreign-slot-value list 'g-slist 'next)))
61 (defmethod translate-from-foreign (pointer (type gslist-type))
62 (prog1
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))))