Re: GtkBuildable type resolver
- From: Owen Taylor <otaylor redhat com>
- To: "Brian J. Tarricone" <bjt23 cornell edu>
- Cc: gtk-devel-list gnome org
- Subject: Re: GtkBuildable type resolver
- Date: Tue, 05 Jun 2007 12:33:10 -0400
On Tue, 2007-06-05 at 09:18 -0700, Brian J. Tarricone wrote:
> On Tue, 05 Jun 2007 11:23:36 -0400 Owen Taylor wrote:
>
> >Actually, GtkIMContext fits the standard naming rules we have for
> >mixed-case names:
> >
> >They are something like:
> >
> > NAME := INITIAL_WORD WORD+
> > INITIAL_WORD := [A-Z][a-z0-9]*
> > WORD := [A_Z]{2,} | [A-Z][a-z0-9]+
> >
> >So:
> >
> > GString => g_string
> > GtkCTree => gtk_ctree
> > GtkIMContext => gtk_im_context
> > GdkRGB => gtk_rgb
>
> On a possibly-related note, glib-mkenums doesn't work properly with this
> scheme. It always treats consecutive capitals as separate 'words' in
> the enum names.
>
> My application is called 'Airconfig', and I use the 'ac_' prefix for
> function names. GObject names look like 'ACPreferredNetwork'. But, if
> I call an enum 'ACSecurityType', this happens:
>
> $ cat test.h
> typedef enum
> {
> AC_SECURITY_TYPE_FOO
> } ACSecurityType;
>
> $ glib-mkenums --eprod '@EnumName \n@enum_name \n@ENUMNAME \n' test.h
>
> /* Generated data (by glib-mkenums) */
>
> ACSecurityType
> a_csecurity_type
> A_CSECURITY_TYPE
>
> /* Generated data ends here */
>
> Obviously, what I want here is ac_security_type and AC_SECURITY_TYPE.
> As a workaround, I use a different convention for enums, e.g.,
> 'AcSecurityType', but it would be nice not to have to do this.
>
> Is this a bug (and should I file a bug report), or is this intended (or
> unavoidable) behavior?
You didn't read the rules above closely enough :-) ACSecurityType is
in fact "A CSecurity Type" by our rules. The first word is special:
- It *can* be a single letter long
- It *can't* be an upper-cased abbrevation
This is an inevitable consequence of wanting to handle both GString
and GtkCTree.
You can add pseudo-comments to override the default glib-mkenums
behavior, though you might want to think about switching your
mixed-case names to uniformly use "Ac". Like "Gtk".
- Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]