Bug in gtkgamma.h



Hi

I noticed a bug in gtkgamma.h (downloaded from CVS yesterday):

#define GTK_GAMMA_CURVE(obj) \
   GTK_CHECK_CAST (obj, gtk_gamma_curve_get_type (), GtkGammaCurve)
#define GTK_GAMMA_CURVE_CLASS(klass) \
   GTK_CHECK_CLASS_CAST (klass, gtk_gamma_curve_get_type, GtkGammaCurveClass)
#define GTK_IS_GAMMA_CURVE(obj) \
   GTK_CHECK_TYPE (obj, gtk_gamma_curve_get_type ())

Definition GTK_GAMMA_CURVE_CLASS has `gtk_gamma_curve_get_type' instead
of `gtk_gamma_curve_get_type()'.
Btw: all other headers uses GTK_TYPE_.* here, reducing possibility
for such bugs.


---- End of the mail is not about that bug but something else. ----

Also, in this and some other headers, GTK_CHECK_CAST() is not covered by
parentheses as most of the definitions are -- not that those would be 
needed, but it is just inconsistent.

May I continue w/ one other inconsistencies I've notided

Header files: 
gtkcolorsel.h gtkcombo.h gtkdrawingarea.h gtkgamma.h gtkhandlebox.h
gtkhbbox.h gtkhpaned.h gtkhruler.h gtkplug.h gtkpreview.h gtkruler.h
gtksocket.h gtkstatusbar.h gtktoolbar.h gtkvbbox.h gtkvpaned.h gtkvruler.h

Doesn't declare gtk_.*_get_type() function to return type GtkType
but just `guint'. Not so consistent...


... All this consistency talk has a reason: I am developing an application
that is used to browse information of GTK+ objects. For this I've developed
a perl script (attached at the end of this file) which given a gtk+ source
directory can figure out the whole GTK+ class tree, all the object and
class structures, public functions by parsing throught the header files in
that directory. W/ that info it also parses the object argument adding
calls from corresponding *.c source files and outputs not just the argument
name, but variable type and arg options.

It now works well with GTK+ 1.2.4 sources but will probably break with
other versions since there are quite a few 'heuristics' used to get
the right information out.

Therefore I would like to see some `metainfo' embedded into gtk+ header
files as a special comments. This info could the be used -- in addition
to case above -- to assure better correctness of the interface. See the
example proposal below:

Every GTK+ header files that introduce a GtkObject (and it's child classes) 
derived class would have:


/* This file introcudes Gtk+ class GtkWidget : public GtkObject */


If this kind of line would be there it would be easy to check that the
object structure really has the parent structure at the beginning (and
same goes for the class stricture). In fact my perl script alreay contains
most of the code to do just that. 

W/ the info above it would be easy to find the object and class structures
However, it would be nice to have the structures introduced as

/* GTK+ Object structure */ and
/* GTK+ Class structure */

This would remove some complexity of the interface parsing code -- 
and inform the checker that the one who created the object is
really interested to write consistent, checkable interface.

The last thing is to add comments:

/* Public functions */ and
/* End public functions */

around object interface functions -- this way just the right set of
the API functions can be extracted for interface documentation. My code
below does not do execptionally good guessing what should be included
here and what not.


Now about the perl prg. It first goes through all *.h files in gtk+ source
directory, reads Object, Class and public functions to associative arrays
(each entry have multiline string in it). It checks what is the parent
class and stores this inheritance info also.

W/ this information it gathers going through the files it first prints
the GTK+ Class tree it has figured out (everything inherited from GtkObject
and so on). 
Then it starts from the leaf nodes of the tree and starts writing the
following info while going up on the tree:
object structure
class structure
"public functions"
"object arguments"
This way a simple scanner can go through the file once and print all the
info about a particular object and it parents up to the GtkObject
information.

An example invocation is like:

$ perl gengclsbdata.perl gtk+-1.2.4/gtk

which will output file gclsdata to current directory.

I hope the ones who test the prg (anw everyone else) will understand
the usability of the things I've written above (if such things does
not yet exists). I guarantee the code I just sent does not install
any viruses/do any other nastiness, and that it exits in finite time.

Tomi

GTK+ object information grabber



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]