]> git.draconx.ca Git - gob-dx.git/blob - doc/gob2.1.in
904691ebb0f61659edb7a9fa25dc2dd5da277a8d
[gob-dx.git] / doc / gob2.1.in
1 .\"
2 .\" gob manual page
3 .\" (C) 1999,2000,2001,2002,2005 George Lebl <jirka@5z.com>
4 .\" 
5 .\" This manual page is covered by the terms of the GNU General
6 .\" Public License.  
7 .\"
8 .TH GOB2 1 "GOB2 @VERSION@" 
9 .SH NAME
10 GOB2 \- The GObject Builder
11 .SH SYNOPSIS
12 .PP
13 .B gob2
14 [ option ] ...
15 file
16
17 .SH DESCRIPTION
18 .PP
19 GObject Builder is a simple preprocessor for easily creating
20 GObject objects.  It does not parse any C code and ignores any C errors.  It
21 is in spirit similar to things like lex or yacc.  In some ways it
22 also resembles java.  But it is really just a simple preprocessor
23 for creating GObjects for use in C or C++ and it is not a programming
24 language.
25
26 .SH OPTIONS
27 .PP
28 .TP
29 .B -? -h --help
30 Display a simple help screen.
31 .TP
32 .B --version
33 Display version information
34 .TP
35 .B -w --exit-on-warn
36 Exit with an error code even when you encounter a warning.
37 .TP
38 .B --no-exit-on-warn
39 Exit with an error only on errors, not on warnings, this is the default.
40 .TP
41 .B --for-cpp
42 Generate C++ code.
43 .TP
44 .B --no-extern-c
45 Never add the extern "C" to the header.
46 .TP
47 .B --no-gnu
48 Never generate any code with GNU C extensions.  However all the GNU C
49 extensions are always wrapped in #ifdef __GNUC__, so code using them compiles
50 correctly even on non-GNU compilers.  This option is for purists only.
51 (using GNU extensions some warnings are eliminated, some ugly hacks and there
52 is better argument type safety, so it\'s good to use them)
53 .TP
54 .B --no-touch
55 Don\'t touch output files unless they really
56 changed (implies --no-touch-headers).  Be careful with automake, see section
57 PREVENTING SPURIOUS BUILDS.
58 .TP
59 .B --no-touch-headers
60 Don\'t touch the generated header file unless it really changed, this avoids
61 spurious rebuilds, but can confuse some make systems (automake in particular),
62 so it is not enabled by default.  Private header is still touched even if
63 unchanged however.
64 .TP
65 .B --always-private-header
66 Always create a \fB<basename>-private.h\fR file, even if it would be empty.
67 .TP
68 .B --ondemand-private-header
69 Create the private header only if it would have something in it, that is,
70 if there are some private data members or protected methods.
71 This is the default.
72 .TP
73 .B --no-private-header
74 Never create a private header file.  If we use any private data members,
75 define the private data structure at the point in the .c source where
76 the class definition begins.
77 .TP
78 .B --m4
79 Preprocess source with m4. Following args will be passed to m4.
80 .TP
81 .B --m4-dir
82 Print directory that will be searched for m4 files.
83 .TP
84 .B -n --no-write
85 Do not write any output files, just check syntax of the input file.
86 .TP
87 .B --no-lines
88 Do not print out the \'#line\' statements into the output.  Useful for debugging
89 the auto-generated generated code.
90 .TP
91 .B --no-self-alias
92 Do not create the Self and SelfClass type aliases and the SELF, IS_SELF
93 and SELF_CLASS macros.
94 .TP
95 .B --no-kill-underscores
96 Do not remove the initial underscore from method names.
97 .TP
98 .B --always-private-struct
99 Always include the private pointer in the public header file.  This is useful
100 for files which are part of a library and you want to reserve the right to add
101 some private data members without breaking binary compatibility.
102 .TP
103 .B -o --output-dir
104 The directory into which output should be placed.
105 .TP
106 .B --file-sep[=c]
107 Replace default \`-\' file name separator.  If no separator character
108 is given then none is used.  Only one character can be used.
109
110 .SH TYPENAMES
111 .PP
112 Because we need to parse out different parts of the typename, sometimes you
113 need to specify the typename with some special syntax.  Types are specified in
114 capitalized form and words are separated by \`:\'.  The first word of the type
115 (which can be empty) is the "namespace".  This fact is for example used for the
116 type checking macro and the type macro.  For "Gtk:New:Button", the macros will
117 be GTK_IS_NEW_BUTTON and GTK_TYPE_NEW_BUTTON.  This colon separated format of
118 typenames is used in the class declaration header and for method argument
119 types.
120
121 .SH OUTPUT FILES
122 .PP
123 The filenames are created from the typename.  The words are
124 separated by \`-\' (this can be changed with
125 \fB--file-sep\fR option) and all in lower case.  For example for an object named
126 "Gtk:New:Button", the files are \fBgtk-new-button.c\fR and
127 \fBgtk-new-button.h\fR.
128 If you are using C++ mode, the output .c file will in fact be a .cc file.
129 If you have any private data members, a private header file will also
130 be created, called \fB<basename>-private.h\fR (for the example above it
131 would be gtk-new-button-private.h).
132 The public header file is created to be human readable and to be used as a
133 reference to the object.  The .c source file is not created as a human
134 readable source and is littered with #line statements, which make the
135 compiler attempt to point you to the right line in your .gob file in
136 case of parsing errors.  The output should not be edited by hand, and
137 you should only edit the .gob file.
138
139 .SH INCLUDING NORMAL C CODE IN THE OUTPUT FILES
140 .PP
141 To include some code directly in the output C file begin with \'%{\'
142 on an empty line and end the code with a \'%}\' on an empty line.  These
143 sections will appear in the output files in the order they are given.
144 There are several other \fIsections\fR to which you can put code.  You can
145 put it in the \'header\' section (which can be abbreviated \'h\') and it will
146 go into the public header file.  You can also put it in the \'privateheader\'
147 section (abbreviated \'ph\') which will make the code go into the private
148 header file.  Sometimes you want some code (other includes) to appear before
149 the extern "C" and the protecting define.  To do this you can put them
150 into the \'headertop\' (or \'ht\') section.  You may wish to include code or
151 comments in all the files, which you can do by putting them into the \'all\'
152 (or \'a\') section.  Similarly, code you wish to appear at the top of all
153 files go in the \'alltop\' (or \'at\') section.  Finally,
154 \'afterdecls\' includes code between the declarations and the method
155 implementations, but note that \'afterdecls\' requires version 2.0.16.
156 For example:
157 .nf
158
159   %alltop{
160         /* this will be on top of all output files */
161   %}
162
163   %headertop{
164         /* this will be on top of the public header */
165   %}
166
167   %privateheader{
168         /* this will go into the private header file */
169   %}
170
171   %h{
172         /* will be included in the header */
173         void somefunc(int i);
174   %}
175
176   %a{
177         /* will be included in all files */
178   %}
179
180   %afterdecls{
181         /* between the declarations and the method implementations */
182         /* Requires gob version 2.0.16 */
183   %}
184
185   %{
186         /* will be included in the C file */
187         void somefunc(int i)
188         {
189               /* some code */
190         }
191   %}
192
193 .fi
194
195 .SH INCLUDE FILES
196 .PP
197 Gob will automatically include the class header file at the top of the .c 
198 source file.  If you wish to include it somewhere else, put the include
199 into some %{ %} section above the class definition, and gob will not include
200 it automatically.  This way you can avoid circular includes and control
201 where in the file do you want to include the header.
202 .PP
203 If you made any data members private, gob will also create a source file
204 that will be called \fB<basename>-private.h\fR.  Same rule as above applies
205 for this just as it does for the regular header file.  If you do explicitly
206 include the regular header file, you should always include this private
207 header file below it.  That is, if you use any private data members.  If you
208 don\'t, the private header file automatically includes the public header file,
209 and thus the public header file will be indirectly included at the very top
210 of the file.
211
212 .SH THE CLASS HEADER
213 .PP
214 There can be only one class per input file.  Defining a class
215 is sort of like in Java, you define the class and write inline code
216 directly into the class definition.  To define a class you need to specify
217 the new object name and the name of the object from which it is derived
218 from, such as this "class <new type> from <parent type> { <class code> }".
219 For example:
220 .nf
221
222   class Gtk:New:Button from Gtk:Button {
223           <class code>
224   }
225
226 .fi
227 .PP
228 To make an abstract class (to pass G_TYPE_FLAG_ABSTRACT) add \'(abstract)\'
229 before the curly braces above.  This works since version 2.0.13.
230
231 .SH DATA MEMBERS
232 .PP
233 There are five types of data members.  Three of them are normal data members,
234 one is class wide (global) in scope and one is a virtual one, usually linked to
235 a normal data member or a class wide data member.  The three normal data
236 members are public, protected and private.  Public and protected are basically
237 just entries in the object structure, while private has it\'s own dynamically
238 allocated private structure.  Protected members are always put after the public
239 one in the structure and are marked protected in the header file.  There is
240 only one identifier allowed per typename unlike in normal C.  Example:
241 .nf
242
243   public int i;
244   private GtkWidget *h;
245   protected long k;
246
247 .fi
248 .PP
249 Public and protected data members are accessed normally as members of
250 the object struct.  Example where \'i\' is as above a public data member:
251 .nf
252
253   object->i = 1;
254
255 .fi
256 .PP
257 The private data members are defined in a structure which is only available
258 inside the .c file, or by including a private header file.  You must access
259 them using the structure _priv.  Example
260 where \'h\' is the private data member (as in the above example):
261 .nf
262
263   object->_priv->h = NULL;
264
265 .fi
266 The _priv structure is defined in the \fB<basename>-private.h\fR.
267 This file is automatically included if you don\'t include it yourself.  You
268 should always explicitly include it in your .gob file if you explicitly also
269 include the main header file.  The reason it is a separate header file is
270 that you can also include it in other places that need to access this objects
271 private data, such as if you have the majority of functionality of an object
272 in a separate .c file.  Or if a derived object needs to access the protected
273 methods.
274 .PP
275 In case you use the \fB--no-private-header\fR option, no
276 private header file is created and you can only access the _priv pointer
277 below the class definition in the .gob file.
278 .PP
279 Also note that this structure is dynamically allocated, and is freed in the
280 finalize handler.  If you override the finalized handler, your code will be
281 run first and only then will the _priv structure be freed.
282 .PP
283 .B "Classwide data members:"
284 .PP
285 Sometimes you want a datamember to be shared by all objects.  You then need
286 the "classwide" scope keyword.  So for example the following adds a global
287 member foo:
288 .nf
289
290   classwide int foo;
291
292 .fi
293 To access the member you can use the SELF_GET_CLASS macro (or
294 YOUR_OBJECT_NAME_GET_CLASS) to get at the class.
295 Thus the following would work:
296 .nf
297
298   SELF_GET_CLASS(object)->foo = 20;
299
300 .fi
301 .PP
302 .B "Automatic Initialization:"
303 .PP
304 You can automatically initialize the public private and protected data members
305 without having to add an init method.  The advantage here is that
306 initialization is kept close to the definition of the data member and thus
307 it\'s easier to check.  To do this, just add a \'=\' followed by a number or
308 a token.  It is also possible to include arbitrary C code for more elaborate
309 initializations by putting it all in curly braces.  Note that the curly braces
310 will not be printed into the output, but since gob does not C parsing it needs
311 them to figure out where the C code ends.  The code will be inserted into the
312 init method, above the user defined body.  So for example the following
313 will initialize an integer to -1 and a string with a newly allocated string
314 of "hello".
315 .nf
316
317   public int foo = -1;
318   private char *bar = {g_strdup("hello")};
319
320 .fi
321 .PP
322 .B "Automatic Destruction:"
323 .PP
324 Most data stored as pointers needs to have a function called when the object
325 is finalized to either free the data.  Gob will let you
326 define a function to be called on the data the object is finalized.  This is
327 achieved by putting \'destroywith\' followed by a function name after the
328 variable definition.  It is only called if the data you defined this on
329 is not NULL, so you cans specify functions which do not handle NULL.  It
330 is very much like the GDestroyNotify function used in GTK+ and glib in many
331 places.  Unlike many other places, gob will not enforce any kind of type
332 safety here so be a little bit more careful.  Any function you give it will
333 be called as a "void function(void *)".  It will in fact be cast into such
334 a form before called.  This is to avoid spurious warnings for gtk calls to
335 subclass methods.  The function needs not be of that form exactly, it just has
336 to take one argument which is the pointer to the data.  You should also not
337 define this on any non-pointer data as the results may be undefined.
338 Example:
339 .nf
340
341   public char *foo = {g_strdup("bar")}
342           destroywith g_free;
343
344 .fi
345 Note that the function name you give must be a real function and not macro.
346 Also note that this is always called in the "finalize" method of GObject.
347 It is always called after any user defined body of the finalize handler.
348 .PP
349 Sometimes you may want to run arbitrary code on destruction.  While this can
350 be perfectly well done in the finalize handler.  Depending on the style you
351 may want to include all destruction/initialization code together with the
352 definition of the data member.  Thus you may want to put arbitrary code which
353 will then be inserted into the "finalize" method of GObject.  This can be
354 done with the "destroy" keyword followed by arbitrary code in curly braces.  
355 Inside this code a macro called VAR will be define which refers to your
356 variable.  So for example destroying a GString can be either done with
357 a helper routine or the following code:
358 .nf
359
360   public GString *string = {g_string_new(NULL)}
361           destroy {
362                   if(VAR) g_string_free(VAR, TRUE);
363           };
364
365 .fi
366 The thing to remember with these is that there are many ways to do this
367 and you\'d better be consistent in your code in how you use the above things.
368 Also defining a helper routine that will do the destruction will be a nicer
369 thing to do if that\'s a possibility.  The "destroy" keyword with code does
370 take up more space in the file and it may become more cluttered.
371 .PP
372 The data is zeroed out after being destroyed.  This is to make debugging easier
373 in case your code might try to access an already finalized object.  In case
374 you have overridden the finalize method, your code will be run first and
375 only then will the destructors be called.  You should not however make any
376 assumptions about the order at which the destructors are called.  If you have
377 interdependencies between destructors for different data members, you will
378 have to do this in your own finalize override function.
379 .PP
380 .B "Automatic Unreffing:"
381 .PP
382 This is very much like the automatic destruction, but is instead run in the
383 dispose method (it is among other places called from the "destroy" method of
384 GtkObject).  All data and other objects that you need to unref should be
385 done here, and not at finalize time.  The semantics are otherwise the same
386 as for the "destroywith" and "destroy" keywords, except that you use
387 "unrefwith" and "unref".
388 .nf
389
390   public G:Object *foo = NULL
391           unrefwith g_object_unref;
392   public G:Object *bar = NULL
393           unref {
394                 g_object_unref (VAR);
395           };
396
397 .fi
398
399 .SH GOBJECT PROPERTIES
400 .PP
401 The fourth type of a data member a property type.  It is a named data member
402 which is one of the features of the GObject system.  It just defines a way to
403 get and set some data, but you have to take care of storing that data
404 somewhere.  So it is normal to also have a normal private (or public)
405 data member where you store the real data.
406 You normally need to define a
407 get and a set handler.  They are fragments of C code that will be used to get
408 the value or set the value of the argument.  Inside them you can use the define
409 VAL to which you assign the data or get the data.  You should treat this VAL
410 as a GValue which stores the data of the correct type.
411 You can also use the
412 identifier "self" as pointer to the object instance.  The type is defined as
413 one of the GObject type enums, but without the G_TYPE_ prefix.  There are
414 also some attributes of a property which you can set.  For example the
415 following is a definition of an integer property \'height\' which will
416 be synchronized with a private integer data member also of the name \'height\'.
417 .nf
418
419   private int height;
420   property INT height
421          (nick = _("Short nickname"),
422           blurb = _("Long description"),
423           minimum = 10,
424           maximum = 200,
425           default_value = 100)
426         set { self->_priv->height = g_value_get_int (VAL); }
427         get { g_value_set_int (VAL, self->_priv->height); };
428
429 .fi
430 .PP
431 The attributes are really optional though you should at least set some
432 of them.
433 All property types have a \'nick\' and a \'blurb\' attribute and you should
434 set those accordingly.  This will make runtime querying the object
435 nicer as things such as gui editors and class browsers can be more
436 verbose about the class itself.  You can use the \'_("string")\' notation
437 instead of just "string", and that will mark the string for translation.
438 .PP
439 Almost all types also have a \'default_value\' attribute which sets the initial
440 value of this property (on object initialization, the set handler will be run
441 automatically with this value).  This value will be overriden if the user 
442 sets a value of this property on the call to g_object_new.
443 .PP
444 All the numeric types (including CHAR) have \'minimum\' and \'maximum\'
445 attributes which can restrict the range.  If you do not specify these
446 the range will be the full range that the data type can handle.
447 .PP
448 Types such as UNICHAR and BOOLEAN only have the \'nick\', \'blurb\' and
449 \'default_value\' attributes.
450 .PP
451 The ENUM type has an \'enum_type\' attribute which is the exact
452 type of the enum.  This is so that the property knows which exact
453 type you can set, rather then just knowing it is an enum.  You should
454 always create an enum type specific for the enum itself (see section
455 on the enum types)
456 .PP
457 Similarly FLAGS type has a \'flags_type\' which again you should set to
458 the specific type of this flags data member.
459 .PP
460 There is a STRING type which has only the extra \'default_value\' attribute.
461 .PP
462 The OBJECT type is one of the types that doesn\'t have a \'default_value\' and it
463 only has an \'object_type\' attribute (in addition to nick and blurb of course)
464 that is the exact object type that this property accepts.  The object_type
465 should be as a type, that is for example \'Gtk:Button\'.
466 .PP
467 There is a BOXED type which is a pointer which has a boxed type defined
468 (such that GObject knows how to copy and destroy this pointer).  Here
469 you will need to specify the \'boxed_type\' attribute with the specific
470 type of the boxed pointer.
471 .PP
472 There is also a POINTER type, which has only the \'nick\' and \'blurb\'
473 attributes.  This is for storing arbitrary pointers.  You should be
474 careful with this one, as GObject knows nothing about the data
475 stored at this pointer.  It is somewhat like a \'void *\' type.
476 .PP
477 There is also the PARAM type for storing parameters with a \'param_type\'
478 attribute.
479 .PP
480 You should notice that this list is pretty much like the list of g_param_spec_*
481 functions from gobject/gparamspecs.h, and the attributes are like the
482 arguments of those functions.  Note however that value array is NOT supported
483 yet.
484 .PP
485 You can also specify extra flags, such as CONSTRUCT or CONSTRUCT_ONLY using the
486 \'flags\' attribute.  You can specify multiple flags by oring them together with
487 \'|\'.  These flags correspond to the GParamFlags enumeration except do not
488 include the G_PARAM_ prefix.  So for example to define an enumeration property,
489 which is a CONSTRUCT_ONLY property, we could do the following:
490 .nf
491
492   private SomeEnumerationType foo;
493   property ENUM foo
494          (nick = _("Short nickname"),
495           blurb = _("Long description"),
496           enum_type = Some:Enumeration:Type
497           default_value = SOME_ENUMERATION_VALUE,
498           flags = CONSTRUCT_ONLY,
499           link);
500
501 .fi
502 .PP
503 The above example also gives an example of automatic linking to a standard data
504 memember.  By including the attribute \'link\' a get and set handlers will be
505 automatically added without having to type them by hand.  This is useful for a
506 vast majority data types that are just linked to some standard data member and
507 do not need to do anything extra on get or set.
508 .PP
509 Another extra feature of properties is the possibility of automatically
510 exporing methods to get and set the property.  That is without having to
511 use g_object_set and g_object_get.  This is achieved by adding an
512 \'export\' attribute to the list of property attributes.
513 .PP
514 If you do not define a set or get handler, the property will automatically
515 be only readable or writable as appropriate.
516 .PP
517 Gob2 also creates macros which can be used for type safe access to
518 properties through g_object_set and g_object_get.
519 The macros are called <type>_PROP_<argument name>(x) and
520 <type>_GET_PROP_<argument name>(x).  They define both the string and the
521 value part of the argument.  So for setting an argument of height, one would
522 use (for object type My:Object):
523 .nf
524
525   g_object_set (G_OBJECT (object),
526                 MY_OBJECT_PROP_HEIGHT (7),
527                 NULL);
528
529 .fi
530 And for getting, you would use:
531 .nf
532
533   int height;
534   g_object_get (G_OBJECT (object),
535                 MY_OBJECT_GET_PROP_HEIGHT (&height),
536                 NULL);
537
538 .fi
539 Note however that the type safety only works completely on GNU C compilers.
540 The code will compile on other compilers but with minimal type safety.
541 For complete type safety it is useful to use the get/set methods that
542 are defined by using the \'export\' attribute.
543 .PP
544 To get bettery type safety on some of the property types, you can specify
545 the \'type\' attribute which will add casts where appropriate in code dealing
546 with this property.  This is especially useful for POINTER and OBJECT types.
547 But even for others.
548 .PP
549 You can also override properties from parent objects (that is override their
550 implementation, not their attributes).  Do this by adding the
551 special \'override\' attribute.  For example if the parent object
552 had a \'height\' property then you could override it by
553 .nf
554
555   private int height;
556   property INT height
557          (override)
558         set { self->_priv->height = g_value_get_int (VAL); }
559         get { g_value_set_int (VAL, self->_priv->height); };
560
561 .fi
562 Overriding is supported since gob 2.0.10.
563
564 .SH METHODS
565 .PP
566 There is a whole array of possible methods.  The three normal,
567 "familiar" method types are private, protected and public.  Public are
568 defined as normal functions with a prototype in the header file.  
569 Protected methods are defined as normal methods (which you can call from other
570 files), but their prototype is placed in the private header file.  Private
571 methods
572 are defined as static functions with prototypes at the top of the .c
573 file.  Then there are signal, virtual and override methods.  More on those
574 later.  You can also
575 define init and class_init methods with a special definition if you want
576 to add code to the constructors or you can just leave them out.
577 You can also not define a body for a method, by just using \';\' instead of a
578 body.  This will define an empty function.  You can\'t do this for non-void
579 regular public, private or protected methods, however it is acceptable for
580 non-void virtual, signal and override methods.
581 .PP
582 .B "Function argument lists:"
583 .PP
584 For all but the init and class_init methods, you use the
585 following syntax for arguments.  The first argument can be just "self",
586 which gob will translate into a pointer to the object instance.  The rest
587 of the arguments are very similar to normal C arguments.  If the
588 typename is an object pointer you should use the syntax defined above
589 with the words separated by \':\'
590 .nf
591 <type> <argument id>
592 or
593 <type> <argument id> (check <list of checks>)
594 .fi
595 .PP
596 The checks are glib type preconditions, and can be the following:
597 "null", which tests pointers for being NULL, "type" which checks GTK+
598 object pointers for being the right type, "<test> <number>" which tests
599 numeric arguments for being a certain value.  The test can be a <,>,<=,>=
600 != or ==.  Example:
601 .nf
602   
603   public int
604   foo (self,
605        int h (check > 0 < 11),
606        Gtk:Widget *w (check null type))
607
608 .fi
609 .PP
610 This will be the prototype of a function which has a self pointer
611 as the first argument, an integer argument which will be checked and has
612 to be more then 0 and less then 11, and a pointer to a GtkWidget object
613 instance and it is checked for being null and the type will also be
614 checked.
615 .PP
616 .B "Function attributes:"
617 .PP
618 For method that aren't virtual, signal or override methods, and aren't
619 init or class_init, GLib function attribute macros G_GNUC_PRINTF,
620 G_GNUC_SCANF, and G_GNUC_FORMAT can optionally be included after the
621 argument list.  Simply include an \'attr\' keyword and the C code to include
622 in the file.  You have to include braces and anything inside the braces
623 will be printed into the header file after the function declaration and
624 before the trailing semicolon.  The braces themselves are not printed.
625 For example:
626 .nf
627
628   public void
629   print (self, const char *format (check null), ...)
630     attr {G_GNUC_PRINTF(2, 3)}
631
632 .fi
633 .PP
634 This will produce a prototype which will generate a warning at compile
635 time if the contents of the format argument (argument number 2) aren't
636 consistent with the types and number of the subsequent variadic
637 arguments (the first of which is argument number 3).  Only one \'attr\'
638 keyword per method is allowed.
639 If you have more than one attribute to include, you should
640 put them all within the braces.
641 Note that function attributes were aded in version 2.0.16.
642 .PP
643 .B "Error return:"
644 .PP
645 Methods which have a return value, there also has to be something
646 returned if there is an error, such as if a precondition is not met.
647 The default is 0, casted to the type of the method.  If you need to
648 return something else then you can specify an \'onerror\' keyword after
649 the prototype and any optional function attribute macros, and after
650 that a number, a token (an identifier) or a bit of C code enclosed in
651 braces {}.  The braces will not be printed into the output, they just
652 delimit the string.  For example:
653 .nf
654
655   public void * get_something (self, int i (check >= 0)) onerror NULL {
656           ...
657   }
658
659 .fi
660 The onerror value is also used in overrides that have a return value, in
661 case there isn\'t a parent method, PARENT_HANDLER will return it.  More about
662 this later.
663 .PP
664 .B "Default return:"
665 .PP
666 Some signal and virtual methods have a return type.  But what happens if
667 there is no default handler and no one connects to a signal.  GOB2 will
668 normally have the wrappers return whatever you specify with onerror or \'0\'
669 if you haven\'t specified anything.  You can also specify a default
670 return value with the keyword \'defreturn\'.  It\'s use is identical to the
671 use of onerror, and you can in fact use both at the same time.  Example
672 .nf
673
674   virtual int get_some_int (self) onerror -1 defreturn 10 ;
675
676 .fi
677 That is an empty virtual method (in C++ terms a pure virtual).  If you never
678 specify any handler for it in the derived children it will just return 10.
679 .PP
680 .B "Constructor methods:"
681 .PP
682 There are two methods that handle the construction of an object, init and
683 class_init.  You define them by just using the init or class_init keyword 
684 with an untyped argument in the argument list.  The argument will be
685 usable in your function as a pointer to your object or class depending if
686 it\'s init or class_init.
687 For example:
688 .nf
689
690   init (self) {
691           /* initialize the object here */
692           self->a = 9;
693           self->b = 9;
694   }
695
696   class_init (class) {
697           /* initialize the class, this is rarely needed */
698           class->blah = NULL;
699   }
700
701 .fi
702 The class_init function is very rarely needed as all standard class
703 initialization is taken care of for you by gob itself.  The init function
704 should on the other hand be used whenever you need to construct or initialize
705 anything in the object to put it into a sane state.
706 .PP
707 .B "Constructor, dispose, finalize methods:"
708 .PP
709 Since 2.0.16, you can also easily add code to the object's constructor,
710 dispose, and finalize methods.  See GObject documentation on how these are
711 run.  The code you add will be run before calling the parents function
712 for dispose and finalize, and after the parent function for constructor.
713 The syntax is just like init and class_init.
714 For example:
715 .nf
716
717   constructor (self) {
718         /* constructor method */
719   }
720
721   dispose (self) {
722         /* dispose method */
723   }
724
725   finalize (self) {
726         /* finalize method */
727   }
728
729 .fi
730 You can also just override those methods as usual, but the above is much easier and nearly as flexible.
731 .PP
732 .B "Virtual methods:"
733 .PP
734 Virtual methods are basically pointers in the class structure,
735 so that one can override the method in derived methods.  That is to implement
736 the method in a derived class, you must then use an override method (more
737 on those later).
738 They can be empty
739 (if you put \';\' instead of the C code).  A wrapper will also be defined
740 which makes calling the methods he same as public methods.  This type of
741 method is just a little bit "slower" then normal functions, but not as
742 slow as signals.  You define them by using "virtual" keyword before the
743 prototype.  If you put the keyword "private" right after the "virtual"
744 keyword, the wrapper will not be a public method, but a private one.
745 You can do the same with "protected" to make a protected wrapper.
746 .PP
747 .B "Signals:"
748 .PP
749 Signals are methods to which the user can bind other handlers
750 and override the default handler.  The default handler is basically the
751 method body.  This is the most versatile and flexible type of a method
752 and also the slowest.  You need to specify a whole bunch of things when
753 you define a signal.  One thing is when the default handler will be run,
754 first or last.  You specify that by "first" or "last" right after the
755 "signal" keyword.  Then you need to define the GObject enum types (again
756 without the G_TYPE_ prefix).  For that you define the return types
757 and the types of arguments after the "self" pointer (not including the
758 "self" pointer).  You put it in the following syntax "<return type> (<list
759 of arguments>)".  If the return type is void, the type should be "NONE",
760 the same should be for the argument list.  The rest of the prototype is
761 the same as for other method types.  The body can also be empty, and
762 also there is a public method wrapper which you can use for calling the
763 signal just like a public method.  Example:
764 .nf
765
766   signal first INT (POINTER, INT)
767   int do_something (self, Gtk:Widget *w (check null type), int length)
768   {
769           ...
770   }
771   
772 .fi
773 or
774 .nf
775
776   signal last NONE (NONE) void foo (self);
777
778 .fi
779 .PP
780 If you don\'t want the wrapper that emits the signal to be public, you can
781 include the keyword "private" after the "signal" keyword.  This will make
782 the wrapper a normal private method.  You can also make a protected wrapper
783 by using "protected" instead of "private".
784 .PP
785 If you don\'t define a "first" or a "last", the default will be taken as
786 "last".
787 .PP
788 You can also add additional flags.  You do this just like with the argument
789 flags, although this is probably very rare.  These are the G_SIGNAL_* flags,
790 and you can add them without the G_SIGNAL_ prefix into a parenthesis, just
791 after the "signal" keyword.  By default all public signals are G_SIGNAL_ACTION.
792 .PP
793 Also gob2 creates a wrapper macros for typesafe signal connection.  That is
794 you will be warned by the compiler if you pass a callback that is not the
795 correct prototype.  This will again only warn you on gcc, but it will
796 compile without warning on another compiler.  So as with all the typesafety
797 hacks in gob, it is better to test your objects under gcc to get any warnings
798 even if you are using a different compiler in the end.
799 .PP
800 The methods that are created for you are:
801 .nf
802
803   <class_name>_connect__<signal_name> (<object>, <callback>, <data>)
804   <class_name>_connect_after__<signal_name> (<object>, <callback>, <data>)
805   <class_name>_connect_data__<signal_name> (<object>, <callback>, <data>,
806                                             <destroy_notify>, <flags>)
807
808 .fi
809 .PP
810 These three functions correspond to the g_signal_connect,
811 g_signal_connect_after and g_signal_connect_data functions that you would
812 normally use, except they are for a specific signal.  Also do note
813 the two underscores between the method name and the signal name.  For
814 example to connect the signal "foo" on the object "Test:Object" you
815 would do:
816 .nf
817
818   test_object_connect__foo (object, callback, data);
819
820 .fi
821 .PP
822 To use BOXED in the signal arguments you need to tell gob which type of boxed
823 argument you want to use.  For this you can just add BOXED_GTK_TYPE_STRING
824 instead of BOXED.  For example BOXED_GTK_TYPE_TREE_ITER for GtkTreeIter.
825 This works since version 2.0.13.
826 .PP
827 .B "Override methods:"
828 .PP
829 If you need to override some method (a signal or a virtual method
830 of some class in the parent tree of the new object), you can define and
831 override method.  After the "override" keyword, you should put the
832 typename of the class you are overriding a method from.  Other then that
833 it is the same as for other methods.  The "self" pointer in this case
834 should be the type of the method you are overriding so that you don\'t
835 get warnings during compilation.  Also to call the method of the parent
836 class, you can use the PARENT_HANDLER macro with your arguments.  Example:
837 .nf
838
839   override (Gtk:Container) void
840   add (Gtk:Container *self (check null type), Gtk:Widget *wid (check null type))
841   {
842           /* some code here */
843           PARENT_HANDLER(self, wid);
844   }
845
846 .fi
847 If the function has a return value, then PARENT_HANDLER is an expression that
848 you can use.  It will return whatever the parent handler returned, or the
849 "onerror" expression if there was no parent handler.
850 .PP
851 .B "Method names:"
852 .PP
853 Inside the code, aliases are set for the methods, so that you don\'t
854 have to type the class name before each call, just type \fBself_\fR instead
855 of the name of the class.  So to call a method called \fBblah\fR, you
856 would use the name \fBself_blah\fR.
857 Example:
858 .nf
859
860   private int
861   foo (self)
862   {
863           return self->len;
864   }
865   
866   private int
867   bar (self, int i)
868   {
869           return self_foo (self) + i;
870   }
871
872 .fi
873
874 .SH MAKING NEW OBJECTS
875 .PP
876 You should define a new method which should be a normal public method.  Inside
877 this method, you can use the GET_NEW macro that is defined for you and that
878 will fetch a new object, so a fairly standard new method would look like:
879 .nf
880
881   public GObject *
882   new (void) {
883           GObject *ret = GET_NEW;
884           return G_OBJECT (ret);
885   }
886
887 .fi
888 .PP
889 You should not a subtle peculiarity of the GObject system here.  If there is
890 any code inside the G_OBJECT macro argument, it will get executed multiple
891 times.  This means that things such as G_OBJECT(GET_NEW) would actually create
892 4 objects, leaking 3 of them.  A good rule (as with anywhere in C) is to be
893 careful with all macros.
894
895 .SH SELF REFERENCES
896 .PP
897 .B "Self alias casts:"
898 .PP
899 There are some standard casts defined for you.  Instead of using the full
900 macros inside the .c file, you can use SELF, IS_SELF and SELF_CLASS.  Using
901 these makes it easier to for example change class names around.
902 .PP
903 .B "Self alias types:"
904 .PP
905 There are also the Self and SelfClass types inside
906 your .c file.  These serve the same function as the above, they make it easier
907 to type and easier to change typenames around which can help a lot during
908 prototyping stage.  However you should note that the Self type should not be
909 used in function prototypes as one of the arguments or as a return value type.
910 This is because this is a simple C typedef which is only available inside your
911 \&.c file and not in the header files.  You can disable both the self casting
912 macros and the self type aliases by passing --no-self-alias to gob.
913
914 .SH DEALING WITH DIFFERENT GOB VERSIONS
915 .PP
916 .B "Defines:"
917 .PP
918 In your generated C file, you can use the defines GOB_VERSION_MAJOR
919 GOB_VERSION_MINOR and GOB_VERSION_PATCHLEVEL if you wish to for example
920 use a feature that is only available in some newer gob version.  Note however
921 that you can only use these defines in the C code portions of your .gob file,
922 and #ifdef\'s cannot span multiple functions.  Check the BUGS section
923 for more on using the C preprocessor and gob.
924 .PP
925 .B "Minimum version requires:"
926 .PP
927 You can also make your .gob file require at least certain version of gob.  You
928 do this by putting \'requires x.y.z\' (where x.y.z is the version number)
929 outside of any C block, comment or class, usually you should make this the
930 first line in the file or close to the top.  If gob finds this and the version
931 of gob used to compile the code is lower then that listed in the require, gob
932 will generate an error and exit.  For example to require that gob2 version
933 2.0.0 or higher be used to compile a file, put this at the top of that file:
934 .nf
935
936   requires 2.0.0
937
938 .fi
939
940 .SH CREATING NEW ENUM, FLAGS and ERROR TYPES
941 .PP
942 You can create new GObject ENUM, FLAGS and GError types for use in your
943 classes easily.  Glib includes some utilities for handling these, however
944 it may be cleaner to use the below specified way in your classes.  It also
945 then doesn\'t require any Makefile setup.  Make sure this is defined in the
946 same section as the class, that is not in any of the \'%?{\' \'%}\' sections.
947 .PP
948 You use the keywords \'enum\' \'flags\' and \'error\' as you would use the
949 \'class\' keyword.  Then you give a prefix for the values in the enumeration.
950 Then you define a list of values just like in C.  For \'enum\' types you can
951 also specify the values assigned to each string.  Then you specify the type in
952 the standard gob style of specifying types.  Here are a few examples
953 of all of these:
954 .nf
955
956   enum LAME_CLIENT {
957         IS_CONNECTED,
958         NONE = 9,
959         LAST
960   } Test:Enum;
961
962   flags BUGA_BUGA {
963         ONE,
964         TWO,
965         MANY,
966   } Some:Flags;
967
968   error TEST_OBJECT_ERROR {
969         BAD_THIS,
970         BAD_THAT
971   } Test:Object:Error;
972
973 .fi
974 .PP
975 This will for example define an enum that is equivalent to the following
976 C code:
977 .nf
978
979   typedef enum {
980         LAME_CLIENT_IS_CONNECTED,
981         LAME_CLIENT_NONE = 9,
982         LAME_CLIENT_LAST
983   } TestEnum;
984
985 .fi
986
987 .SH C++ MODE
988 .PP
989 There is a C++ mode so that gob creates C++ compiler friendly files.  You need
990 to use the --for-cpp argument to gob.  This will make the generated file have
991 a .cc instead of a .c extension, and several things will be adjusted to
992 make it all work for a C++ compiler.  One thing that will be missing is an
993 alias to the new method, as that clashes with C++, so instead you\'ll have to
994 use the full name of the method inside your code.  Also note that gob does
995 not use any C++ features, this option will just make the generated code
996 compile with a C++ compiler.
997
998 .SH OVERRIDING THE GET_TYPE METHOD
999 .PP
1000 The get_type is not really a method, but a function which initializes your
1001 object.  Recently objects appeared which require you to make a custom
1002 get_type function.  So it is possible
1003 to override this function.  To do so, just define a new public method called
1004 get_type, with no arguments.  Example:
1005 .nf
1006
1007   public GType
1008   get_type (void)
1009   {
1010         /* code goes here */
1011         return some_type;
1012   }
1013
1014 .fi
1015
1016 .SH INTERFACES
1017 .PP
1018 Currently gob will only allow you to implement interfaces (that is, define new
1019 classes which implement an interface) and doesn\'t yet have support for making
1020 new interfaces, but this will be coming at some point in the future.
1021 .PP
1022 To define a class that implements an interface add a class flag \'interface\'
1023 with the type name of the interface as an argument.  Then to implement
1024 a specific method of the interface, just add \'interface <typename>\'
1025 before the method definition.  The method can, and probably should be,
1026 private.
1027 .PP
1028 The following example implements a new object, that implements the
1029 Gtk:Tree:Model interface and implements the get_flags method of that
1030 interface.  Do note that except for standard (GTK+ and glib) specific
1031 interfaces which seem
1032 to have a non-standard name for the interface structure, the structure
1033 should end with and Iface, if you are implementing an interface.  That
1034 is for example for the Gtk:Tree:Model, the structure containing the
1035 table of methods should be named GtkTreeModelIface.
1036 .nf
1037   class Some:Object from G:Object
1038           (interface Gtk:Tree:Model)
1039   {
1040           /* function implemented for the Gtk:Tree:Model interface */
1041           interface Gtk:Tree:Model
1042           private GtkTreeModelFlags
1043           get_flags (Gtk:Tree:Model *self (check null type))
1044           {
1045                 /* Here would be the implementation */
1046                 return (GtkTreeModelFlags)0;
1047           }
1048   }
1049
1050 .fi
1051 .PP
1052 If you want to implement multiple interfaces just list more class flag lines
1053 as follows:
1054 .nf
1055
1056   class Some:Object from G:Object
1057           (interface Gtk:Tree:Model)
1058           (interface Gtk:Editable)
1059   {
1060           /* ... */
1061   }
1062
1063 .fi
1064
1065 .SH DIRECT BonoboObject SUPPORT
1066 .PP
1067 If you want to build a BonoboObject class gob2 has direct support for these.
1068 Just create a new object that derives from
1069 Bonobo:Object.
1070 Then use a "BonoboObject" class flag with the interface name as an
1071 argument.  The interface name should be as you would type it in C, that is with
1072 underscores as namespace separators.  Then you add the methods (using exact
1073 same names as in the idl file) and prepend those methods with a BonoboObject
1074 keyword.  For example imagine you have an interface GNOME/Foo/SomeInterface,
1075 with a method fooBar that takes a single string:
1076 .nf
1077
1078   class Foo:Some:Interface from Bonobo:Object
1079     (BonoboObject GNOME_Foo_SomeInterface) {
1080
1081           BonoboObject
1082           private void
1083           fooBar (PortableServer_Servant servant,
1084                   const CORBA_char *string,
1085                   CORBA_Environment *ev)
1086           {
1087                   Self *self = SELF (bonobo_object_from_servant (servant));
1088
1089                   /* your code here */
1090           }
1091
1092           /* rest of class */
1093   }
1094
1095 .fi
1096 Note that the implementation method can be private, in fact that\'s probably
1097 a good idea to do.  It won\'t work to make this a signal, it can however
1098 be a virtual.  Note that the method prototype must match the one from the
1099 interface header file, or you will get a bad assignment warning.  You should
1100 check the header file generated by orbit-idl and see the epv structure
1101 for the correct prototypes if you can\'t figure them out from the idl itself.
1102 Also note that the first argument is not "self", but the servant and you must
1103 use bonobo_object_from_servant function to get the actual object pointer.
1104
1105 .SH DIRECT LIBGLADE SUPPORT
1106 .PP
1107 Gob can simplify writing a libglade class.  Just create a new object that
1108 derives from a GtkContainer widget.  Then use a "GladeXML" class flag
1109 with the glade file name, root widget and optional domain  as arguments
1110 between double quotes.  For example:
1111 .nf
1112
1113 class My:Glade from Gtk:Window (GladeXML "gob-libglade.glade" "root")
1114 {
1115   ....
1116 }
1117
1118 .fi
1119 Note however that then "gob-libglade.glade" would have to be in the current
1120 directory.  You could specify a path, but that may not work for all
1121 installations.  You can replace the glade filename with a token to be used
1122 in the generated .c file and you can then have a macro with the filename,
1123 as follows:
1124 .nf
1125
1126 class My:Glade from Gtk:Window (GladeXML GLADE_FILE "root")
1127 {
1128   ....
1129 }
1130
1131 .fi
1132 And somewhere in your header files you would have
1133 .nf
1134
1135 #define GLADE_FILE "/path/to/file.glade"
1136
1137 .fi
1138
1139 You can declare widgets as data members by adding a 'GladeXML' to
1140 the definition.
1141 .nf
1142
1143 private Gtk:Button * button1 GladeXML;
1144
1145 .fi
1146 This will automatically set the "button1" from the GladeXML file.
1147
1148 All signals created with glade are automatically connected if you defined
1149 those class methods in your class.  For example suppose in glade that
1150 we set the "connect" signal on button1 to go to on_button1_clicked, then
1151 in our gob file we can just write:
1152 .nf
1153
1154 public void
1155 on_button1_clicked(self, GtkButton * button)
1156 {
1157 }
1158
1159 .fi
1160
1161 See the examples directory for a full example.  Note that this feature
1162 requires version at least 2.0.12.
1163
1164
1165 .SH IDENTIFIER CONFLICTS
1166 .PP
1167 Gob will need to define some local variables and functions in the generated
1168 files, so you need to take some precaution not to conflict with these.  The
1169 general rule of thumb is that all of these start with three underscores.  There
1170 is one, "parent_class" which doesn\'t because it\'s intended for use in your
1171 code.  For virtuals or signals, you cannot use the identifier __parent__
1172 which is used for the parent of the object.  You should actually never access
1173 __parent__ either as it not guaranteed that it will stay named this way.
1174 Data members cannot be named __parent__ nor _priv.  For methods, you cannot
1175 use the identifiers "init" or "class_init" unless you mean the constructor
1176 methods.  You shouldn\'t generally use 3 underscores even in override method
1177 argument lists and virtual and signal method names as it might confuse the
1178 PARENT_HANDLER macro.  In fact avoiding all names with three underscores is
1179 the best policy when working with gob.
1180 .PP
1181 There are a couple of defines which you shouldn\'t be redefining in the code
1182 or other headers.  These are SELF, IS_SELF, SELF_CLASS, SELF_TYPE, ARG, VAR,
1183 PARENT_HANDLER, GET_NEW, GOB_VERSION_MAJOR, GOB_VERSION_MINOR and
1184 GOB_VERSION_PATCHLEVEL.
1185 .PP
1186 As for types, there are Self and SelfClass types which are only defined in your
1187 source files.  Their generation (just like the generation of the SELF macros)
1188 can be turned off, see command line options.
1189
1190 .SH USING GTK-DOC STYLE INLINE DOCUMENTATION
1191 .PP
1192 If you want to use gtk-doc style inline documentation for your objects, you
1193 can do one of two things.  First, you could include the inline documentation
1194 comments in your %{ %} section which will then be put verbatim into the
1195 output source file.  This is the way you should use for functions you define
1196 outside of the class.
1197 .PP
1198 For class methods, you should use a gtk+ style comment, however it can be
1199 indented any number of tabs or spaces and you can use the short method name
1200 without the type prefix.  Gob will automatically try to extract these and
1201 translate to full names and put them in the output source file.  An example
1202 would be:
1203 .nf
1204
1205   class Gtk:Button:Example from Gtk:Button {
1206           /**
1207            * new:
1208            *
1209            * Makes a new #GtkButtonExample widget
1210            *
1211            * Returns: a new widget
1212            **/
1213           public
1214           GtkWidget *
1215           new(void)
1216           {
1217                   return (GtkWidget *)GET_NEW;
1218           }
1219   } 
1220
1221 .fi
1222 If the function you are documenting is a signal or a virtual then it will
1223 be documenting the wrapper that starts that virtual function or emits
1224 that signal.
1225
1226 .SH DEALING WITH CIRCULAR HEADERS
1227 .PP
1228 Sometimes you may need to use an object of type MyObjectA in the MyObjectB
1229 class and vice versa.  Obviously you can\'t include headers for both.  So you
1230 need to just declare the typedef in the header of A for B, and the other way
1231 around as well.  The headers generated include a protecting
1232 define before it declares the typedef.  This define is the
1233 __TYPEDEF_<upper case object name>__.  So inside my-object-a.h there will be
1234 this:
1235 .nf
1236
1237   #ifndef __TYPEDEF_MY_OBJECT_A__
1238   #define __TYPEDEF_MY_OBJECT_A__
1239   typedef struct _MyObjectA MyObjectA;
1240   #endif
1241
1242 .fi
1243 Now instead of including my-object-a.h in the header section of
1244 my-object-b.gob, just copy the above code there and you\'re set for using
1245 MyObjectA as a type in the method parameters and public types.
1246 .PP
1247 Another way to get out of this problem is if you can use those types only
1248 in the private members, in which case they won\'t be in the generated public
1249 header.
1250
1251 .SH BUILDING WITH MAKE
1252 .PP
1253 If you are using normal makefiles, what you need to do is to add a generic
1254 rule for .gob files.  So you would include the following in the Makefile
1255 and then just use the .c and .h files as usual (make sure the space
1256 before the \'gob2\' is a tab, not spaces):
1257 .nf
1258
1259   %.c %.h %-private.h: %.gob
1260           gob2 $<
1261
1262 .fi
1263
1264 .SH BUILDING WITH AUTOCONF and AUTOMAKE
1265 .PP
1266 This is a little bit more involved.  Basically the first thing to do is to
1267 check for GOB2 in your configure.in file.  You can use the supplied m4 macro
1268 which will also check the version of gob.  Basically you include this:
1269 .nf
1270
1271   GOB2_CHECK([2.0.0])
1272
1273 .fi
1274 This will replace @GOB2@ in your makefiles with the full path of gob2.  Thus
1275 when adding the generic rule to your Makefile.am file, it should look like:
1276 .nf
1277
1278   %.c %.h %-private.h: %.gob
1279           @GOB2@ $<
1280
1281 .fi
1282 .PP
1283 For Makefile.am you have to set up a couple more things.  First you have to
1284 include the generated .c and .h files into BUILT_SOURCES variable.  You
1285 have to include both the .gob and the .c and .h files in the SOURCES for your
1286 program.
1287
1288 .SH PREVENTING SPURIOUS BUILDS
1289 .PP
1290 When nothing has changed you might not really want to rebuild everything and
1291 gob provides options --no-touch (since 2.0.13) and --no-touch-headers to avoid
1292 this.  When working with build systems such as automake you have to be more
1293 careful as just using those options can cause automake to get confused and you
1294 will need to use something like the following:
1295 .nf
1296
1297   foo_SOURCES = foo.gob foo.gob.stamp foo.c foo.h foo-private.h
1298   BUILT_SOURCES = foo.gob.stamp
1299   MAINTAINERCLEANFILES = foo.gob.stamp
1300
1301   %.gob.stamp: %.gob
1302           @GOB2@ --no-touch $<
1303           @touch $@
1304
1305 .fi 
1306
1307 .SH DEBUGGING
1308 .PP
1309 GOB does several things to make debugging the code easier.  First it adds
1310 preprocessor commands into the output c file that point to the correct places
1311 in your .gob input file.  However sometimes there might be some bigger
1312 confusion and this is just not helpful.  In this case you will probably want
1313 to have gcc point you directly at the generated files.  For this use
1314 the --no-lines command line option.  You should also note that these commands
1315 are not generated for the public header file at all.  If there is an error which
1316 points you to the public header file, make sure you fix this error in the .gob
1317 file, otherwise your changes will not have any effect after gob recompiles the
1318 sources again.
1319 .PP
1320 Sometimes you might want to know which method you are in for some debugging
1321 output.  GOB will define __GOB_FUNCTION__ macro, which is just a string constant
1322 with a pretty name of the method.
1323
1324 .SH M4 SUPPORT
1325 .PP
1326 It is possible to have your .gob file also preprocessed by m4.  This is useful
1327 if you have a lot of files and you\'d like to have some preprocessor put in
1328 some common features.  All you have to do is add --m4 to the command line
1329 of gob2 and gob2 will first run your file through m4.  You can print the
1330 directory that is searched for m4 files by running "gob2 --m4-dir"
1331 .PP
1332 All the arguments after --m4 will be passed to m4 itself, so it has to be the
1333 last gob2 argument on the command line.  This way you can specify arbitrary
1334 options to pass to m4.
1335
1336 .SH BUGS
1337 .PP
1338 The lexer does not actually parse the C code, so I\'m sure that some corner
1339 cases or maybe even some not so corner cases of C syntax might confuse gob
1340 completely.  If you find any, send me the source that makes it go gaga and
1341 I\'ll try to make the lexer try to handle it properly, but no promises.
1342 .PP
1343 Another thing is that gob ignores preprocessor macros.  Since gob counts
1344 braces, the following code won\'t work:
1345 .nf
1346
1347   #ifdef SOME_DEFINE
1348   if(foo) {
1349   #else
1350   if(bar) {
1351   #endif
1352           blah();
1353   }
1354
1355 .fi
1356 To make this work, you\'d have to do this:
1357 .nf
1358
1359   #ifdef SOME_DEFINE
1360   if(foo)
1361   #else
1362   if(bar)
1363   #endif
1364   {
1365           blah();
1366   }
1367
1368 .fi
1369 There is no real good way we can handle this without parsing C code, so we
1370 probably never will.  In the future, I might add #if 0 as a comment but
1371 that\'s about as far as I can really take it and even that is problematic.
1372 Basically, if you use gob, just don\'t use the C preprocessor too extensively.
1373 And if you use it make sure that you do not cross the boundaries of the C
1374 code segments.
1375 .PP
1376 Comments will not get through to the generated files unless inside C code.
1377 This is not the case for gtk-doc style comments which are supported.
1378 .PP
1379 The short name aliases are actually implemented as pointers to functions.  Thus
1380 if you want to get the pointer of a function using the short name alias you
1381 can\'t use the \'&\'.  Thus:
1382 .nf
1383
1384   void (*foo)(Self *);
1385
1386   /* this will NOT work */
1387   foo = &self_short_name;
1388
1389   /* this will work */
1390   foo = self_short_name;
1391
1392   /* Both of these will work */
1393   foo = &my_class_long_name;
1394   foo = my_class_long_name;
1395
1396 .fi
1397
1398 .SH AUTHOR
1399 .PP
1400 George Lebl <jirka@5z.com>
1401 .PP
1402 GOB2 Homepage: http://www.jirka.org/gob.html