Re: [Glade-devel] [PATCH]: We don't need no educat...sorry... GetType Markup! (deja vu Pink Floyd)

Date view Thread view Subject view Author view

From: Archit Baweja (bighead@crosswinds.net)
Date: Sun Jul 15 2001 - 11:03:39 EDT


On 14 Jul 2001 00:07:44 +0800, James Henstridge wrote:
> On 13 Jul 2001, Archit Baweja wrote:
>
> > Hey
> >
> > Talked to chema about this on irc.
> > BTW, the changes can handle following names such situations
> >
> > GtkWindow -> gtk_window_get_type
> > GtkHBox -> gtk_hbox_get_type
> > GtkFooBAR -> gtk_foo_bar_get_type
> >
> > Please commit.
>
> This doesn't quite match the rules used to build the
> lower_case_with_underscores names used by GTK+ in the case of runs of more
> than 2 upper case letters. Eg. it would convert GtkFOOBar to
> gtk_foobar_get_type, while gtk+ would use gtk_foo_bar_get_type.
>
> You really should use multiple passes that emulate the regular expressions
> used by gtk's support scripts. Something like:
> /* s/([^A-Z])([A-Z])/\1_\2/g */
> i = 0;
> while (str[i]) {
> if (!isupper(str[i]) && isupper(str[i+1]))
> insert(str, ++i, '_');
> i++;
> }
> /* s/([A-Z][A-Z])([A-Z][0-9a-z])/\1_\2/g */
> i = 0;
> while (str[i]) {
> if (isupper(str[i]) && isupper(str[i+1]) && isupper(str[i+2]) &&
> (islower(str[i+3]) || isdigit(str[i+3])) {
> insert(str, i+2, '_');
> i += 2;
> }
> i++;
> }
> /* cover the GObject -> g_object case */
> if (isupper(str[0]) && isupper(str[1]))
> insert(str, 1, '_');
>
> (note that this is pseudo code so needs some work, and probably has some
> buffer overrun problems).
>
> James.
>
> --
> Email: james@daa.com.au
> WWW: http://www.daa.com.au/~james/
>

Here's a new patch. This is does a one pass thing (something GNU
promotes). Handles GtkFOOBar too. And uses GetTypeFunction for backup.

See and commit.

Archit Baweja

-- 
"Mother do you think they'll try to break my balls ...."
        -- Pink Floyd (Mother, The Wall)


_______________________________________________ Glade-devel maillist - Glade-devel@ximian.com http://lists.ximian.com/mailman/listinfo/glade-devel


Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Sun Jul 15 2001 - 12:53:22 EDT