4 (type-of-thing-being-defined name-used-to-refer-to-this-thing
5 (attribute-name attribute-value-depending-on-the-attribute)
6 (attribute-name attribute-value-depending-on-the-attribute)
7 (attribute-name attribute-value-depending-on-the-attribute))
9 Some definitions can have a c-declaration field that gives the C code
10 we parsed to arrive at the definition. The c-declaration is a quoted
11 string because it can contain parentheses and such.
13 Defined types and their attributes:
17 (submodule-of module-name)) ;; submodule is optional
23 modules are later referred to with a list of module names, like
26 Object and boxed type definitions automatically create a submodule.
27 For example, GtkCList creates the module (module CList (submodule-of
28 (Gtk))) which is referred to as module (Gtk CList).
33 (alias some-unique-identifier)
34 (in-module module-name) ;; optional, gchar* is not in a module
35 (gtk-type-id gtk-type-system-id) ;; optional, absent if this is not
37 (is-parametric boolean) ;; optional default to #f
38 (in-c-name name-of-symbol-in-C)
39 (out-c-name name-of-symbol-in-C)
40 (inout-c-name name-of-symbol-in-C))
44 (gtk-type-id GTK_TYPE_STRING)
45 (in-c-name "const gchar*")
46 (out-c-name "gchar**") ;; actually I'm not sure how strings work out/inout
47 (inout-c-name "gchar*"))
51 (gtk-type-id GTK_TYPE_POINTER)
54 (out-c-name "GList**")
55 (inout-c-name "GList**"))
58 ;; This one would be implied by the (object) def for GtkWidget I
59 ;; think - (type) is only required for types that are not implied
60 ;; by other definitions, such as int/boolean/etc.
65 (gtk-type-id GTK_TYPE_WIDGET)
66 (in-c-name "GtkWidget*")
67 (inout-c-name "GtkWidget*")
68 (out-c-name "GtkWidget**"))
70 "Type" bindings are automatically assumed for objects, boxed types,
71 etc. as defined below.
73 The alias field is used to refer to the type later on.
75 Whenever a type alias can be used, it is also possible to use the
76 keyword "native", which implies that the type in question is too
77 C-specific to represent. Then a c-declaration will typically be
80 C types containing [] or () are function pointers or arrays. For
81 arrays that don't specify a size, we just treat them as pointers. For
82 function pointers, we need special (type) syntax/attributes of some
83 kind, but since there basically aren't any of these right now in the
84 libs we care about we can just ignore them. For arrays that specify a
85 size ditto, you would handle them by adding an (array-size) attribute
86 or something or using the "native" keyword and skipping the (type)
91 (in-module module-name-list)
92 (parent object-name optional-module-name-if-different)
93 (abstract boolean-is-abstract-class) ;; omit for default of #f
94 (c-name name-of-the-object-in-C)
95 (field (type-and-name type-alias-of-struct-field name-of-struct-field)
96 (access read-or-write-or-readwrite)))
101 (parent Object) ;; could say (parent Object (Gtk))
104 (field (type-and-name GdkWindow* window) (access read)))
106 An "object" declaration automatically implies the type definition:
109 (alias concat-module-elements-and-object-name)
110 (in-c-name pointer-to-c-name)
111 (out-c-name pointer-to-pointer-to-c-name)
112 (inout-c-name pointer-to-c-name))
115 (type (alias GtkWidget)
116 (in-c-name GtkWidget*)
117 (out-c-name GtkWidget**)
118 (inout-c-name GtkWidget*))
120 It also implies a module that is the name broken into parts:
126 (function function-name
127 (in-module module-name-list) ;; "static methods" go in their
129 (is-constructor-of object-type-alias) ;; optional, marks a constructor
130 (c-name function-name)
131 (return-type return-value-type) ;; defaults to void
132 (caller-owns-return boolean-value) ;; defaults to #f
133 (can-return-null boolean-value) ;; defaults to #t
134 (parameter in-or-out-or-inout
135 (type-and-name parameter-type-alias parameter-name)
136 (type-parameter name-of-contained-type) ;; optional, requires parametric type
137 (c-declaration "c-type-and-name")) ;; c-declaration only required
138 ;; if the type alias is "native"
139 (varargs #t) ;; has varargs at the end
145 (c-name gdk_rgb_init)))
149 (in-module (Gdk Rgb Cmap))
150 (is-constructor-of GdkRgbCmap)
151 (c-name gdk_rgb_cmap_new)
152 (return-type GdkRgbCmap)
153 (caller-owns-return #t) ;; perhaps this could be implied by is-constructor-of
154 (parameter in (type-and-name array-of-guint32 colors))
155 (parameter in (type-and-name gint n_colors)))
158 (function config_set_set_handler
160 (c-name gnome_config_set_set_handler)
161 (parameter in (type-and-name native func)
162 (c-declaration "void (*func)(void*)"))
163 (parameter in (type-and-name gpointer data)))
167 (of-object object-name module-name)
168 ;; retval/arg attributes as for (function), but with first parameter
169 ;; omitted for non-constructors
174 (of-object Label (Gtk))
175 (parameter (type-and-name const-gchar* str)))
178 (object-argument arg-name
179 (of-object object-we-are-an-argument-of optional-objects-module)
180 (type-id argument-type) ;; GTK_TYPE_OBJECT etc.
181 ;; flags all default to #f
182 (readable bool-value)
183 (writeable bool-value)
184 (construct-only bool-value))
187 (object-argument label
188 (of-object Label (Gtk))
189 (type GTK_TYPE_STRING)
195 (run-action bool-value)
196 (run-first bool-value)
197 (run-last bool-value)
198 (of-object object-we-are-a-signal-of optional-objects-module)
199 ;; return value and parameters as for a function, omitting the object
200 ;; and user data parameters
202 ;; what other properties matter for a signal?
207 (of-object CList (Gtk))
209 ;; return type defaults to void
210 (parameter in (type-and-name gint row))
211 (parameter in (type-and-name gint column))
212 (parameter in (type-and-name GdkEvent* event)))
218 (value (nick value-name-noprefixes-hyphen-lowercase) (c-name value-c-name)))
224 (c-name GtkDirectionType)
225 (value (nick tab-forward) (c-name GTK_DIR_TAB_FORWARD))
226 (value (nick tab-backward) (c-name GTK_DIR_TAB_BACKWARD))
227 (value (nick up) (c-name GTK_DIR_UP))
228 (value (nick down) (c-name GTK_DIR_DOWN))
229 (value (nick left) (c-name GTK_DIR_LEFT))
230 (value (nick right) (c-name GTK_DIR_RIGHT)))
233 (in-module (Gtk CTree))
235 (value (nick before) (c-name GTK_CTREE_POS_BEFORE))
236 (value (nick as-child) (c-name GTK_CTREE_POS_AS_CHILD))
237 (value (nick after) (c-name GTK_CTREE_POS_AFTER)))
240 (flags) is just like enum, but some bindings may wrap enums and flags differently.
247 (ref-func func-to-increase-refcount)
248 (copy-func func-to-copy)
249 (release-func func-to-destroy-or-decrement-refcount)
250 (field (type-and-name type-alias-of-struct-field name-of-struct-field) (access access-rule)))
252 It is never OK to use memcpy() to copy a boxed type, or use
253 malloc()/free() to alloc/free one.
260 (ref-func pixmap_ref)
261 (release-func pixmap_unref))
263 An "object" declaration automatically implies the type definition:
266 (alias concat-module-elements-and-boxed-name)
267 (in-c-name pointer-to-c-name)
268 (out-c-name pointer-to-pointer-to-c-name)
269 (inout-c-name pointer-to-c-name))
272 (type (alias GdkPixmap)
273 (in-c-name GdkPixmap*)
274 (out-c-name GdkPixmap**)
275 (inout-c-name GdkPixmap*))
283 (field (type-and-name type-alias-of-struct-field name-of-struct-field) (access access-rule)))
285 Unlike a boxed type, a struct type can be copied with memcpy() and
286 allocated on the stack or with g_malloc().
291 (c-name GdkRectangle)
292 (field (type-and-name gint16 x) (access readwrite))
293 (field (type-and-name gint16 y) (access readwrite))
294 (field (type-and-name guint16 width) (access readwrite))
295 (field (type-and-name guint16 height) (access readwrite)))
297 Implies GdkRectangle type alias:
299 (type (alias GdkRectangle)
300 (in-c-name GdkRectangle*)
301 (out-c-name GdkRectangle*) ;; note - not the same as boxed types
302 (inout-c-name GdkRectangle*))
308 (c-name c-typedef-name)
309 ;; return-type and parameters as for (function)
314 (user-function PrintFunc
316 (parameter in (type-and-name gpointer func_data))
317 (parameter in (type-and-name gchar* str)))
324 (orig-type alias-of-orig-type))