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
This commit is contained in:
Kristian Rietveld 2008-06-23 12:06:39 +00:00 committed by Kristian Rietveld
parent 88e007810c
commit 1289b6d165
3 changed files with 20 additions and 1 deletions

View File

@ -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> 2008-06-22 Stefan Kost <ensonic@users.sf.net>
* glib/gurifuncs.c: * glib/gurifuncs.c:

View File

@ -14,7 +14,7 @@ G_BEGIN_DECLS
/*** BEGIN value-header ***/ /*** BEGIN value-header ***/
GType @enum_name@_get_type (void) G_GNUC_CONST; 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 ***/ /*** END value-header ***/
/*** BEGIN file-tail ***/ /*** BEGIN file-tail ***/

View File

@ -15,6 +15,7 @@ my $seenbitshift; # Have we seen bitshift operators?
my $enum_prefix; # Prefix for this enumeration my $enum_prefix; # Prefix for this enumeration
my $enumname; # Name for this enumeration my $enumname; # Name for this enumeration
my $enumshort; # $enumname without prefix my $enumshort; # $enumname without prefix
my $enumname_prefix; # prefix of $enumname
my $enumindex = 0; # Global enum counter my $enumindex = 0; # Global enum counter
my $firstenum = 1; # Is this the first enumeration per file? my $firstenum = 1; # Is this the first enumeration per file?
my @entries; # [ $name, $val ] for each entry my @entries; # [ $name, $val ] for each entry
@ -149,6 +150,7 @@ sub usage {
print " \@enum_name\@ prefix_the_xenum\n"; print " \@enum_name\@ prefix_the_xenum\n";
print " \@ENUMNAME\@ PREFIX_THE_XENUM\n"; print " \@ENUMNAME\@ PREFIX_THE_XENUM\n";
print " \@ENUMSHORT\@ THE_XENUM\n"; print " \@ENUMSHORT\@ THE_XENUM\n";
print " \@ENUMPREFIX\@ PREFIX\n";
print " \@VALUENAME\@ PREFIX_THE_XVALUE\n"; print " \@VALUENAME\@ PREFIX_THE_XVALUE\n";
print " \@valuenick\@ the-xvalue\n"; print " \@valuenick\@ the-xvalue\n";
print " \@type\@ either enum or flags\n"; print " \@type\@ either enum or flags\n";
@ -361,6 +363,9 @@ while (<>) {
$enumsym = lc $option_underscore_name; $enumsym = lc $option_underscore_name;
$enumshort = $enumlong; $enumshort = $enumlong;
$enumshort =~ s/^[A-Z][A-Z0-9]*_//; $enumshort =~ s/^[A-Z][A-Z0-9]*_//;
$enumname_prefix = $enumlong;
$enumname_prefix =~ s/$enumshort$//;
} else { } else {
# enumname is e.g. GMatchType # enumname is e.g. GMatchType
$enspace = $enumname; $enspace = $enumname;
@ -372,6 +377,10 @@ while (<>) {
$enumshort =~ s/([A-Z][A-Z])([A-Z][0-9a-z])/$1_$2/g; $enumshort =~ s/([A-Z][A-Z])([A-Z][0-9a-z])/$1_$2/g;
$enumshort = uc($enumshort); $enumshort = uc($enumshort);
$enumname_prefix = $enumname;
$enumname_prefix =~ s/^([A-Z][a-z]*).*$/$1/;
$enumname_prefix = uc($enumname_prefix);
$enumlong = uc($enspace) . "_" . $enumshort; $enumlong = uc($enspace) . "_" . $enumshort;
$enumsym = lc($enspace) . "_" . lc($enumshort); $enumsym = lc($enspace) . "_" . lc($enumshort);
@ -402,6 +411,7 @@ while (<>) {
$prod =~ s/\@EnumName\@/$enumname/g; $prod =~ s/\@EnumName\@/$enumname/g;
$prod =~ s/\@ENUMSHORT\@/$enumshort/g; $prod =~ s/\@ENUMSHORT\@/$enumshort/g;
$prod =~ s/\@ENUMNAME\@/$enumlong/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; } 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/\@EnumName\@/$enumname/g;
$prod =~ s/\@ENUMSHORT\@/$enumshort/g; $prod =~ s/\@ENUMSHORT\@/$enumshort/g;
$prod =~ s/\@ENUMNAME\@/$enumlong/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; } 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/\@EnumName\@/$enumname/g;
$prod =~ s/\@ENUMSHORT\@/$enumshort/g; $prod =~ s/\@ENUMSHORT\@/$enumshort/g;
$prod =~ s/\@ENUMNAME\@/$enumlong/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; } 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; }