Commit 49eacae2 authored by Tim Janik's avatar Tim Janik Committed by Tim Janik

applied patch from David Necas which introduces an underscore_name option

Tue Oct 10 12:06:08 2006  Tim Janik  <timj@gtk.org>

        * glib-mkenums.in:
        * glib-mkenums.1: applied patch from David Necas which introduces
        an underscore_name option and fixes #358734.
parent 4766e33d
Tue Oct 10 12:06:08 2006 Tim Janik <timj@gtk.org>
* glib-mkenums.in:
* glib-mkenums.1: applied patch from David Necas which introduces
an underscore_name option and fixes #358734.
Mon Oct 2 15:50:16 2006 Tim Janik <timj@gtk.org>
* gvalue.c (g_value_peek_pointer): reverted a change to have an
......
......@@ -126,8 +126,9 @@ start out with the trigraph sequence "/*<" and end with the trigraph sequence ">
Per enum definition, the options "skip" and "flags" can be specified, to indicate
this enum definition to be skipped, or for it to be treated as a flags definition, or
to specify the common prefix to be stripped from all values to generate value nicknames,
respectively. The "lowercase_name" option can be used to specify the word separation used
in the *_get_type() function. For instance, /*< lowercase_name=gnome_vfs_uri_hide_options >*/.
respectively. The "underscore_name" option can be used to specify the underscorized name
variant used in the *_get_type() function and *_TYPE_* macro. For instance,
/*< underscore_name=gnome_vfs_uri_hide_options >*/.
.PP
Per value definition, the options "skip" and "nick" are supported. The former causes the
value to be skipped, and the latter can be used to specify the otherwise auto-generated
......
......@@ -3,8 +3,14 @@
# glib-mkenums.pl
# Information about the current enumeration
my $flags; # Is enumeration a bitmask?
my $option_lowercase_name; # A lower case name to use as part of the *_get_type() function, instead of the one that we guess.
# For instance, when an enum uses abnormal capitalization and we can not guess where to put the underscores.
my $option_underscore_name; # Overriden underscore variant of the enum name
# for example to fix the cases we don't get the
# mixed-case -> underscorized transform right.
my $option_lowercase_name; # DEPRECATED. A lower case name to use as part
# of the *_get_type() function, instead of the
# one that we guess. For instance, when an enum
# uses abnormal capitalization and we can not
# guess where to put the underscores.
my $seenbitshift; # Have we seen bitshift operators?
my $enum_prefix; # Prefix for this enumeration
my $enumname; # Name for this enumeration
......@@ -184,8 +190,7 @@ sub read_template_file {
elsif (($in eq $2) && ($1 eq 'END') && (exists($tmpl{$2}))) {
$in = 'junk';
next;
}
else {
} else {
die "Malformed template file $file\n";
}
}
......@@ -274,11 +279,21 @@ while (<>) {
next if defined $options{skip};
$enum_prefix = $options{prefix};
$flags = $options{flags};
$option_lowercase_name = $options{lowercase_name};
$option_lowercase_name = $options{lowercase_name};
$option_underscore_name = $options{underscore_name};
} else {
$enum_prefix = undef;
$flags = undef;
$option_lowercase_name = undef;
$option_lowercase_name = undef;
$option_underscore_name = undef;
}
if (defined $option_lowercase_name) {
if (defined $option_underscore_name) {
print STDERR "$0: $ARGV:$.: lowercase_name overriden with underscore_name\n";
$option_lowercase_name = undef;
} else {
print STDERR "$0: $ARGV:$.: lowercase_name is deprecated, use underscore_name\n";
}
}
# Didn't have trailing '{' look on next lines
if (!defined $1 && !defined $4) {
......@@ -340,24 +355,29 @@ while (<>) {
# Spit out the output
# enumname is e.g. GMatchType
$enspace = $enumname;
$enspace =~ s/^([A-Z][a-z]*).*$/$1/;
$enumshort = $enumname;
$enumshort =~ s/^[A-Z][a-z]*//;
$enumshort =~ s/([^A-Z])([A-Z])/$1_$2/g;
$enumshort =~ s/([A-Z][A-Z])([A-Z][0-9a-z])/$1_$2/g;
$enumshort = uc($enumshort);
$enumlong = uc($enspace) . "_" . $enumshort;
$enumsym = lc($enspace) . "_" . lc($enumshort);
#The options might override the lower case name if it could not be generated correctly:
if (defined($option_lowercase_name)) {
$enumsym = $option_lowercase_name;
}
if (defined $option_underscore_name) {
$enumlong = uc $option_underscore_name;
$enumsym = lc $option_underscore_name;
$enumshort = $enumlong;
$enumshort =~ s/^[A-Z][A-Z0-9]*_//;
} else {
# enumname is e.g. GMatchType
$enspace = $enumname;
$enspace =~ s/^([A-Z][a-z]*).*$/$1/;
$enumshort = $enumname;
$enumshort =~ s/^[A-Z][a-z]*//;
$enumshort =~ s/([^A-Z])([A-Z])/$1_$2/g;
$enumshort =~ s/([A-Z][A-Z])([A-Z][0-9a-z])/$1_$2/g;
$enumshort = uc($enumshort);
$enumlong = uc($enspace) . "_" . $enumshort;
$enumsym = lc($enspace) . "_" . lc($enumshort);
if (defined($option_lowercase_name)) {
$enumsym = $option_lowercase_name;
}
}
if ($firstenum) {
$firstenum = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment