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: James Henstridge (james@daa.com.au)
Date: Fri Jul 13 2001 - 12:07:44 EDT


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/

_______________________________________________ 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 : Fri Jul 13 2001 - 12:52:32 EDT