docstrings and g-type-designator
[cl-gtk2.git] / glib / gobject.package.lisp
1 (defpackage :gobject
2   (:use :cl :glib :cffi :tg :bordeaux-threads :iter :closer-mop)
3   (:export #:+g-type-invalid+
4            #:+g-type-void+
5            #:+g-type-interface+
6            #:+g-type-char+
7            #:+g-type-uchar+
8            #:+g-type-boolean+
9            #:+g-type-int+
10            #:+g-type-uint+
11            #:+g-type-long+
12            #:+g-type-ulong+
13            #:+g-type-int64+
14            #:+g-type-uint64+
15            #:+g-type-enum+
16            #:+g-type-flags+
17            #:+g-type-float+
18            #:+g-type-double+
19            #:+g-type-string+
20            #:+g-type-pointer+
21            #:+g-type-boxed+
22            #:+g-type-param+
23            #:+g-type-object+
24            #:g-object
25            #:pointer
26            #:g-type-from-object
27            #:g-type-name
28            #:g-type-from-name
29            #:g-signal-connect
30            #:define-g-object-class
31            #:g-initially-unowned
32            #:define-g-enum
33            #:*lisp-name-package*
34            #:define-g-boxed-class
35            #:define-g-flags
36            #:fixed-array
37            #:g-boxed-inline
38            #:g-boxed-ptr
39            #:define-g-interface
40            #:release
41            #:using
42            #:using*
43            #:define-g-boxed-ref
44            #:g-boxed-ref
45            #:allocate-stable-pointer
46            #:free-stable-pointer
47            #:get-stable-pointer-value
48            #:with-stable-pointer
49            #:release*
50            #:disown-boxed-ref
51            #:g-type-interface
52            #:g-value
53            #:register-object-type-implementation
54            #:ensure-g-type
55            #:define-vtable
56            #:g-type
57            #:set-g-value
58            #:parse-gvalue
59            #:emit-signal
60            #:g-value-unset
61            #:g-value-zero
62            #:g-value-init
63            #:g-class-property-definition
64            #:g-class-property-definition-name
65            #:g-class-property-definition-type
66            #:g-class-property-definition-readable
67            #:g-class-property-definition-writable
68            #:g-class-property-definition-constructor
69            #:g-class-property-definition-constructor-only
70            #:g-class-property-definition-owner-type
71            #:class-properties
72            #:interface-properties
73            #:enum-item
74            #:enum-item-name
75            #:enum-item-value
76            #:enum-item-nick
77            #:get-enum-types
78            #:flags-item
79            #:flags-item-name
80            #:flags-item-value
81            #:flags-item-nick
82            #:get-flags-types
83            #:g-type-class-ref
84            #:g-object-class
85            #:gobject-class
86            #:g-param-spec
87            #:type-instance
88            #:parse-g-param-spec
89            #:g-type-class-unref
90            #:registered-object-type-by-name
91            #:g-type-children
92            #:g-signal-lookup
93            #:g-type-parent
94            #:connect-signal
95            #:boxed-c-structure-name
96            #:g-type-designator
97            #:g-type-fundamental
98            #:g-type-depth
99            #:g-type-next-base
100            #:g-type-is-a
101            #:g-type-interfaces
102            #:g-type-interface-prerequisites)
103   (:documentation
104    "CL-GTK2-GOBJECT is a binding to GObject type system.
105 For information on GObject, see its @a[http://library.gnome.org/devel/gobject/stable/]{documentation}.
106
107 CL-GTK2-GOBJECT is structured as follows:
108 @itemize{
109 @item{Binding to GObject API, providing low-level means to use functionality of GObject. This includes introspection facilities and means to invoke functionality of GObject.}
110 @item{GObject wrapper that bridges Lisp language with GObject API.}
111 }
112
113 @begin[GObject instrospection API]{section}
114 The base of GObject type system is GType. GType is a numerical value that is the unique identifier of a registered type.
115 Each GType has a name that is retrieved with @fun{g-type-name}. Conversely, GType can be retrieved from its name via @fun{g-type-from-name}.
116
117 There are several predefined GType values that correspond to fundamental or base types.
118 @begin{itemize}
119 @item{@variable{+g-type-invalid+}}
120 @item{@variable{+g-type-void+}}
121 @item{@variable{+g-type-interface+}}
122 @item{@variable{+g-type-char+}}
123 @item{@variable{+g-type-uchar+}}
124 @item{@variable{+g-type-boolean+}}
125 @item{@variable{+g-type-int+}}
126 @item{@variable{+g-type-uint+}}
127 @item{@variable{+g-type-long+}}
128 @item{@variable{+g-type-ulong+}}
129 @item{@variable{+g-type-int64+}}
130 @item{@variable{+g-type-uint64+}}
131 @item{@variable{+g-type-enum+}}
132 @item{@variable{+g-type-flags+}}
133 @item{@variable{+g-type-float+}}
134 @item{@variable{+g-type-double+}}
135 @item{@variable{+g-type-string+}}
136 @item{@variable{+g-type-pointer+}}
137 @item{@variable{+g-type-boxed+}}
138 @item{@variable{+g-type-param+}}
139 @item{@variable{+g-type-object+}}
140 @end{itemize}
141
142 GType values form type hierarchies via signle inheritance. Functions @fun{g-type-parent} and @fun{g-type-children} enable to traverse through the type hierarchy.
143
144 For some types, additional information is available. Functions @fun{class-properties} and @fun{interface-properties} return properties of classes and interfaces. Functions @fun{get-enum-items} and @fun{get-flags-items} return members of enum and flags types.
145
146 //TODO: document and refactor signals
147
148 @end{section}
149
150 @begin[GValue]{section}
151 GObject uses GValues as a generic way to pass values. It is used when calling closures, emitting signals, setting and getting properties' values, passing values to object constructors. @class{g-value} foreign structure is used for holding GValue. It used like all foreign structures: either with @code{cffi:foreign-alloc} or with @code{cffi:with-foreign-object}. Before first use, @class{g-value} should be zeroed with @fun{g-value-zero}. Zeroed @class{g-value} may be configured to hold a GValue of a given type with @fun{g-value-init}. @fun{parse-g-value} retrieves the Lisp object corresponding to the value stored in GValue. @fun{set-g-value} sets the GValue from Lisp object.
152 @end{section}"))
153
154 (in-package :gobject)
155
156 (eval-when (:compile-toplevel :load-toplevel :execute)
157   (define-foreign-library gobject
158     (:unix (:or "libgobject-2.0.so.0" "libgobject-2.0.so"))
159     (t "libgobject-2.0")))
160
161 (use-foreign-library gobject)
162
163 (defvar *gobject-debug* nil)
164
165 (defun debugf (&rest args)
166   (when *gobject-debug*
167     (apply 'format t args)))