Re: [gtk-list] Re: define-enum carries duplicate nice names



On Sun, 7 Dec 1997, Kenneth Albanowski wrote:

> However, if we add a bit more information:
> 
>  (define-enum GtkPackType gtk pack
>    (start GTK_PACK_START)
>    (end GTK_PACK_END))
> 
> then it will be easy for a program to use 'start', 'pack_start', or
> 'gtk_pack_start', as needed.
> 

ok, for now gluegen fills this structure on parsing enum values:

struct  _GlueEnumValue
{
  GlueEnum      *enumeration;	/* pointer to "GtkPackType" enumeration */
  gchar         *symbol;	/* "gtk-pack-start", in enum_value_ht */
  gchar         *nice_name;	/* "start" */
  gchar         *nice_name_key;	/* "gtkpacktype-start" in enum_value_ht */
};

GlueGen (Gtk+ Glue code Generator) parses the definition file and fills
corresponding c-structures. all of the important items are added to hash
tables to avoid name-duplication.
for instance the enum_value_ht  holds all enum value symbols (e.g.
"GTK_PACK_START" or "GDK_WINDOW_TOPLEVEL").
since the nice_name needs only to be unique within a certain enum
definition, and the enum type name is known, it's sufficient to hash
them by prefixing with the enum type name.
if you still want a functional prefix field for the nice names on a
per enum basis, i'd like someone to volounteer to go through the
enum definitions and add this item.

i'll mail my gtk+-enums.defs to anyone who'd like to take that (boring ;)
challenge.


> > also numeric characters in the first position of identifiers could
> > cause problems with languages other than scheme, as in:
> > 
> > (define-enum GdkEventType gdk
> >   (nothing GDK_NOTHING)
> >   .
> >   .
> >   (2button-press GDK_2BUTTON_PRESS)
> >   (3button-press GDK_3BUTTON_PRESS)
> >   .
> >   .
> >   (other-event GDK_OTHER_EVENT))
> > 
> > with a few lines extra codes i managed to still scan these identifiers
> > besides ordinary numbers, but again, shouldn't we behave a little bit
> > more resctrictive to honour every possible use (and languages besides
> > scheme)?
> 
> Yes, I agree, all identifiers should start with [A-Za-z] for widest
> compatibility.

i've renamed those to

(define-enum GdkEventType gdk
  (button-press GDK_BUTTON_PRESS)
  (double-button-press GDK_2BUTTON_PRESS)
  (tripple-button-press GDK_3BUTTON_PRESS))

for now.

> 
> Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)
> 

thanx for the input!

---
ciaoTJ



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