summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Rietveld <kris@imendio.com>2008-06-23 12:06:39 +0000
committerKristian Rietveld <kristian@src.gnome.org>2008-06-23 12:06:39 +0000
commit1289b6d16577d079811fe508288bc6e3e7ddfc2d (patch)
treee03c56dcc2dbac985b465a246fff4e85035193c1
parent88e007810c17f6d3c72661680acd3624faea1208 (diff)
introduce an ENUMPREFIX substitution.
2008-06-23 Kristian Rietveld <kris@imendio.com> * gobject/glib-mkenums.in: introduce an ENUMPREFIX substitution. * gio/gioenumtypes.h.template: use @ENUMPREFIX@ instead of hard coding "G" as prefix. svn path=/trunk/; revision=7096
-rw-r--r--ChangeLog7
-rw-r--r--gio/gioenumtypes.h.template2
-rwxr-xr-xgobject/glib-mkenums.in12
3 files changed, 20 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 4bb3dd951..8cf319ba6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-06-23 Kristian Rietveld <kris@imendio.com>
+
+ * gobject/glib-mkenums.in: introduce an ENUMPREFIX substitution.
+
+ * gio/gioenumtypes.h.template: use @ENUMPREFIX@ instead of
+ hard coding "G" as prefix.
+
2008-06-22 Stefan Kost <ensonic@users.sf.net>
* glib/gurifuncs.c:
diff --git a/gio/gioenumtypes.h.template b/gio/gioenumtypes.h.template
index 746005663..174bd6284 100644
--- a/gio/gioenumtypes.h.template
+++ b/gio/gioenumtypes.h.template
@@ -14,7 +14,7 @@ G_BEGIN_DECLS
/*** BEGIN value-header ***/
GType @enum_name@_get_type (void) G_GNUC_CONST;
-#define G_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
+#define @ENUMPREFIX@_TYPE_@ENUMSHORT@ (@enum_name@_get_type ())
/*** END value-header ***/
/*** BEGIN file-tail ***/
diff --git a/gobject/glib-mkenums.in b/gobject/glib-mkenums.in
index e7e00eaf9..3c2912ed5 100755
--- a/gobject/glib-mkenums.in
+++ b/gobject/glib-mkenums.in
@@ -15,6 +15,7 @@ my $seenbitshift; # Have we seen bitshift operators?
my $enum_prefix; # Prefix for this enumeration
my $enumname; # Name for this enumeration
my $enumshort; # $enumname without prefix
+my $enumname_prefix; # prefix of $enumname
my $enumindex = 0; # Global enum counter
my $firstenum = 1; # Is this the first enumeration per file?
my @entries; # [ $name, $val ] for each entry
@@ -149,6 +150,7 @@ sub usage {
print " \@enum_name\@ prefix_the_xenum\n";
print " \@ENUMNAME\@ PREFIX_THE_XENUM\n";
print " \@ENUMSHORT\@ THE_XENUM\n";
+ print " \@ENUMPREFIX\@ PREFIX\n";
print " \@VALUENAME\@ PREFIX_THE_XVALUE\n";
print " \@valuenick\@ the-xvalue\n";
print " \@type\@ either enum or flags\n";
@@ -361,6 +363,9 @@ while (<>) {
$enumsym = lc $option_underscore_name;
$enumshort = $enumlong;
$enumshort =~ s/^[A-Z][A-Z0-9]*_//;
+
+ $enumname_prefix = $enumlong;
+ $enumname_prefix =~ s/$enumshort$//;
} else {
# enumname is e.g. GMatchType
$enspace = $enumname;
@@ -372,6 +377,10 @@ while (<>) {
$enumshort =~ s/([A-Z][A-Z])([A-Z][0-9a-z])/$1_$2/g;
$enumshort = uc($enumshort);
+ $enumname_prefix = $enumname;
+ $enumname_prefix =~ s/^([A-Z][a-z]*).*$/$1/;
+ $enumname_prefix = uc($enumname_prefix);
+
$enumlong = uc($enspace) . "_" . $enumshort;
$enumsym = lc($enspace) . "_" . lc($enumshort);
@@ -402,6 +411,7 @@ while (<>) {
$prod =~ s/\@EnumName\@/$enumname/g;
$prod =~ s/\@ENUMSHORT\@/$enumshort/g;
$prod =~ s/\@ENUMNAME\@/$enumlong/g;
+ $prod =~ s/\@ENUMPREFIX\@/$enumname_prefix/g;
if ($flags) { $prod =~ s/\@type\@/flags/g; } else { $prod =~ s/\@type\@/enum/g; }
if ($flags) { $prod =~ s/\@Type\@/Flags/g; } else { $prod =~ s/\@Type\@/Enum/g; }
if ($flags) { $prod =~ s/\@TYPE\@/FLAGS/g; } else { $prod =~ s/\@TYPE\@/ENUM/g; }
@@ -419,6 +429,7 @@ while (<>) {
$prod =~ s/\@EnumName\@/$enumname/g;
$prod =~ s/\@ENUMSHORT\@/$enumshort/g;
$prod =~ s/\@ENUMNAME\@/$enumlong/g;
+ $prod =~ s/\@ENUMPREFIX\@/$enumname_prefix/g;
if ($flags) { $prod =~ s/\@type\@/flags/g; } else { $prod =~ s/\@type\@/enum/g; }
if ($flags) { $prod =~ s/\@Type\@/Flags/g; } else { $prod =~ s/\@Type\@/Enum/g; }
if ($flags) { $prod =~ s/\@TYPE\@/FLAGS/g; } else { $prod =~ s/\@TYPE\@/ENUM/g; }
@@ -456,6 +467,7 @@ while (<>) {
$prod =~ s/\@EnumName\@/$enumname/g;
$prod =~ s/\@ENUMSHORT\@/$enumshort/g;
$prod =~ s/\@ENUMNAME\@/$enumlong/g;
+ $prod =~ s/\@ENUMPREFIX\@/$enumname_prefix/g;
if ($flags) { $prod =~ s/\@type\@/flags/g; } else { $prod =~ s/\@type\@/enum/g; }
if ($flags) { $prod =~ s/\@Type\@/Flags/g; } else { $prod =~ s/\@Type\@/Enum/g; }
if ($flags) { $prod =~ s/\@TYPE\@/FLAGS/g; } else { $prod =~ s/\@TYPE\@/ENUM/g; }