handle options with -'s in them

2003-06-29  Manish Singh  <yosh@gimp.org>

        * tools/gimp-mkenums: handle options with -'s in them

        * tools/pdbgen/enumgen.pl: redo a bunch of logic for the below

        * app/core/core-enums.h: use /*< pdb-skip, skip >*/ for skipping
        in both gimp-mkenums and enumgen.pl

        * app/core/core-enums.c: regenerated
This commit is contained in:
Manish Singh 2003-06-29 21:54:09 +00:00 committed by Manish Singh
parent 8dd2e80792
commit 35907ff2f6
5 changed files with 55 additions and 132 deletions

View File

@ -1,3 +1,14 @@
2003-06-29 Manish Singh <yosh@gimp.org>
* tools/gimp-mkenums: handle options with -'s in them
* tools/pdbgen/enumgen.pl: redo a bunch of logic for the below
* app/core/core-enums.h: use /*< pdb-skip, skip >*/ for skipping
in both gimp-mkenums and enumgen.pl
* app/core/core-enums.c: regenerated
2003-06-29 Michael Natterer <mitch@gimp.org>
Getting rid of some legacy filenames:

View File

@ -554,115 +554,5 @@ gimp_undo_type_get_type (void)
}
static const GEnumValue gimp_context_prop_type_enum_values[] =
{
{ GIMP_CONTEXT_FIRST_PROP, "GIMP_CONTEXT_FIRST_PROP", "first-prop" },
{ GIMP_CONTEXT_PROP_IMAGE, "GIMP_CONTEXT_PROP_IMAGE", "prop-image" },
{ GIMP_CONTEXT_PROP_DISPLAY, "GIMP_CONTEXT_PROP_DISPLAY", "prop-display" },
{ GIMP_CONTEXT_PROP_TOOL, "GIMP_CONTEXT_PROP_TOOL", "prop-tool" },
{ GIMP_CONTEXT_PROP_FOREGROUND, "GIMP_CONTEXT_PROP_FOREGROUND", "prop-foreground" },
{ GIMP_CONTEXT_PROP_BACKGROUND, "GIMP_CONTEXT_PROP_BACKGROUND", "prop-background" },
{ GIMP_CONTEXT_PROP_OPACITY, "GIMP_CONTEXT_PROP_OPACITY", "prop-opacity" },
{ GIMP_CONTEXT_PROP_PAINT_MODE, "GIMP_CONTEXT_PROP_PAINT_MODE", "prop-paint-mode" },
{ GIMP_CONTEXT_PROP_BRUSH, "GIMP_CONTEXT_PROP_BRUSH", "prop-brush" },
{ GIMP_CONTEXT_PROP_PATTERN, "GIMP_CONTEXT_PROP_PATTERN", "prop-pattern" },
{ GIMP_CONTEXT_PROP_GRADIENT, "GIMP_CONTEXT_PROP_GRADIENT", "prop-gradient" },
{ GIMP_CONTEXT_PROP_PALETTE, "GIMP_CONTEXT_PROP_PALETTE", "prop-palette" },
{ GIMP_CONTEXT_PROP_FONT, "GIMP_CONTEXT_PROP_FONT", "prop-font" },
{ GIMP_CONTEXT_PROP_BUFFER, "GIMP_CONTEXT_PROP_BUFFER", "prop-buffer" },
{ GIMP_CONTEXT_PROP_IMAGEFILE, "GIMP_CONTEXT_PROP_IMAGEFILE", "prop-imagefile" },
{ GIMP_CONTEXT_PROP_TEMPLATE, "GIMP_CONTEXT_PROP_TEMPLATE", "prop-template" },
{ GIMP_CONTEXT_LAST_PROP, "GIMP_CONTEXT_LAST_PROP", "last-prop" },
{ 0, NULL, NULL }
};
GType
gimp_context_prop_type_get_type (void)
{
static GType enum_type = 0;
if (!enum_type)
enum_type = g_enum_register_static ("GimpContextPropType", gimp_context_prop_type_enum_values);
return enum_type;
}
static const GEnumValue gimp_context_prop_mask_enum_values[] =
{
{ GIMP_CONTEXT_IMAGE_MASK, "GIMP_CONTEXT_IMAGE_MASK", "image-mask" },
{ GIMP_CONTEXT_DISPLAY_MASK, "GIMP_CONTEXT_DISPLAY_MASK", "display-mask" },
{ GIMP_CONTEXT_TOOL_MASK, "GIMP_CONTEXT_TOOL_MASK", "tool-mask" },
{ GIMP_CONTEXT_FOREGROUND_MASK, "GIMP_CONTEXT_FOREGROUND_MASK", "foreground-mask" },
{ GIMP_CONTEXT_BACKGROUND_MASK, "GIMP_CONTEXT_BACKGROUND_MASK", "background-mask" },
{ GIMP_CONTEXT_OPACITY_MASK, "GIMP_CONTEXT_OPACITY_MASK", "opacity-mask" },
{ GIMP_CONTEXT_PAINT_MODE_MASK, "GIMP_CONTEXT_PAINT_MODE_MASK", "paint-mode-mask" },
{ GIMP_CONTEXT_BRUSH_MASK, "GIMP_CONTEXT_BRUSH_MASK", "brush-mask" },
{ GIMP_CONTEXT_PATTERN_MASK, "GIMP_CONTEXT_PATTERN_MASK", "pattern-mask" },
{ GIMP_CONTEXT_GRADIENT_MASK, "GIMP_CONTEXT_GRADIENT_MASK", "gradient-mask" },
{ GIMP_CONTEXT_PALETTE_MASK, "GIMP_CONTEXT_PALETTE_MASK", "palette-mask" },
{ GIMP_CONTEXT_FONT_MASK, "GIMP_CONTEXT_FONT_MASK", "font-mask" },
{ GIMP_CONTEXT_BUFFER_MASK, "GIMP_CONTEXT_BUFFER_MASK", "buffer-mask" },
{ GIMP_CONTEXT_IMAGEFILE_MASK, "GIMP_CONTEXT_IMAGEFILE_MASK", "imagefile-mask" },
{ GIMP_CONTEXT_TEMPLATE_MASK, "GIMP_CONTEXT_TEMPLATE_MASK", "template-mask" },
{ GIMP_CONTEXT_PAINT_PROPS_MASK, "GIMP_CONTEXT_PAINT_PROPS_MASK", "paint-props-mask" },
{ GIMP_CONTEXT_ALL_PROPS_MASK, "GIMP_CONTEXT_ALL_PROPS_MASK", "all-props-mask" },
{ 0, NULL, NULL }
};
GType
gimp_context_prop_mask_get_type (void)
{
static GType enum_type = 0;
if (!enum_type)
enum_type = g_enum_register_static ("GimpContextPropMask", gimp_context_prop_mask_enum_values);
return enum_type;
}
static const GEnumValue gimp_gradient_segment_type_enum_values[] =
{
{ GIMP_GRAD_LINEAR, "GIMP_GRAD_LINEAR", "linear" },
{ GIMP_GRAD_CURVED, "GIMP_GRAD_CURVED", "curved" },
{ GIMP_GRAD_SINE, "GIMP_GRAD_SINE", "sine" },
{ GIMP_GRAD_SPHERE_INCREASING, "GIMP_GRAD_SPHERE_INCREASING", "sphere-increasing" },
{ GIMP_GRAD_SPHERE_DECREASING, "GIMP_GRAD_SPHERE_DECREASING", "sphere-decreasing" },
{ 0, NULL, NULL }
};
GType
gimp_gradient_segment_type_get_type (void)
{
static GType enum_type = 0;
if (!enum_type)
enum_type = g_enum_register_static ("GimpGradientSegmentType", gimp_gradient_segment_type_enum_values);
return enum_type;
}
static const GEnumValue gimp_gradient_segment_color_enum_values[] =
{
{ GIMP_GRAD_RGB, "GIMP_GRAD_RGB", "rgb" },
{ GIMP_GRAD_HSV_CCW, "GIMP_GRAD_HSV_CCW", "hsv-ccw" },
{ GIMP_GRAD_HSV_CW, "GIMP_GRAD_HSV_CW", "hsv-cw" },
{ 0, NULL, NULL }
};
GType
gimp_gradient_segment_color_get_type (void)
{
static GType enum_type = 0;
if (!enum_type)
enum_type = g_enum_register_static ("GimpGradientSegmentColor", gimp_gradient_segment_color_enum_values);
return enum_type;
}
/* Generated data ends here */

View File

@ -25,7 +25,7 @@
/*< pdb-skip >*/ are exported to libgimp and the PDB. Enums that are
not marked with /*< skip >*/ are registered with the GType system.
If you want the enum to be skipped by both scripts, you have to use
/*< pdb-skip >*/ _before_ /*< skip >*/.
/*< pdb-skip, skip >*/.
All enum values that are marked with /*< skip >*/ are skipped for
both targets.
@ -423,7 +423,7 @@ typedef enum /*< pdb-skip >*/
* non-registered enums; register them if needed
*/
typedef enum /*< pdb-skip >*/ /*< skip >*/
typedef enum /*< pdb-skip, skip >*/
{
GIMP_CONTEXT_FIRST_PROP = 2,
@ -446,7 +446,7 @@ typedef enum /*< pdb-skip >*/ /*< skip >*/
GIMP_CONTEXT_LAST_PROP = GIMP_CONTEXT_PROP_TEMPLATE
} GimpContextPropType;
typedef enum /*< pdb-skip >*/ /*< skip >*/
typedef enum /*< pdb-skip, skip >*/
{
GIMP_CONTEXT_IMAGE_MASK = 1 << 2,
GIMP_CONTEXT_DISPLAY_MASK = 1 << 3,
@ -492,7 +492,7 @@ typedef enum /*< skip >*/
GIMP_CUSTOM_PALETTE
} GimpConvertPaletteType;
typedef enum /*< pdb-skip >*/ /*< skip >*/
typedef enum /*< pdb-skip, skip >*/
{
GIMP_GRAD_LINEAR = 0,
GIMP_GRAD_CURVED,
@ -501,7 +501,7 @@ typedef enum /*< pdb-skip >*/ /*< skip >*/
GIMP_GRAD_SPHERE_DECREASING
} GimpGradientSegmentType;
typedef enum /*< pdb-skip >*/ /*< skip >*/
typedef enum /*< pdb-skip, skip >*/
{
GIMP_GRAD_RGB, /* normal RGB */
GIMP_GRAD_HSV_CCW, /* counterclockwise hue */

View File

@ -26,7 +26,7 @@ sub parse_trigraph {
for $opt (split /\s*,\s*/, $opts) {
$opt =~ s/^\s*//;
$opt =~ s/\s*$//;
my ($key,$val) = $opt =~ /(\w+)(?:=(.+))?/;
my ($key,$val) = $opt =~ /([-\w]+)(?:=(.+))?/;
defined $val or $val = 1;
push @opts, $key, $val;
}

View File

@ -73,7 +73,6 @@ my $footer = <<'FOOTER';
FOOTER
my ($enumname, $contig, $symbols, @mapping, $before);
my ($skip, $pdbskip);
# Most of this enum parsing stuff was swiped from makeenums.pl in GTK+
sub parse_options {
@ -81,7 +80,9 @@ sub parse_options {
my @opts;
for $opt (split /\s*,\s*/, $opts) {
my ($key,$val) = $opt =~ /\s*([\w-]+)(?:=(\S+))?/;
$opt =~ s/^\s*//;
$opt =~ s/\s*$//;
my ($key,$val) = $opt =~ /([-\w]+)(?:=(.+))?/;
defined $val or $val = 1;
push @opts, $key, $val;
}
@ -90,17 +91,17 @@ sub parse_options {
sub parse_entries {
my $file = shift;
my $file_name = shift;
my $looking_for_name = 0;
while (<$file>) {
# Read lines until we have no open comments
while (m@/\*
([^*]|\*(?!/))*$
@x) {
while (m@/\*([^*]|\*(?!/))*$@) {
my $new;
defined ($new = <$file>) || die "Unmatched comment";
defined ($new = <$file>) || die "Unmatched comment in $ARGV";
$_ .= $new;
}
# Now strip comments
# strip comments w/o options
s@/\*(?!<)
([^*]+|\*(?!/))*
\*/@@gx;
@ -109,12 +110,19 @@ sub parse_entries {
next if m@^\s*$@;
if ($looking_for_name) {
if (/^\s*(\w+)/) {
$enumname = $1;
return 1;
}
}
# Handle include files
if (/^\#include\s*<([^>]*)>/ ) {
my $file= "../$1";
open NEWFILE, $file or die "Cannot open include file $file: $!\n";
if (&parse_entries (\*NEWFILE)) {
if (&parse_entries (\*NEWFILE, $NEWFILE)) {
return 1;
} else {
next;
@ -126,6 +134,11 @@ sub parse_entries {
return 1;
}
if (/^\s*\}/) {
$looking_for_name = 1;
next;
}
if (m@^\s*
(\w+)\s* # name
(?:=( # value
@ -164,8 +177,10 @@ sub parse_entries {
$contig = 0 if $contig && ($@ || $test - 1 != $before);
$before = $test;
} elsif (m@^\s*\#@) {
# ignore preprocessor directives
} else {
print STDERR "Can't understand: $_\n";
print STDERR "$0: $file_name:$.: Failed to parse `$_'\n";
}
}
return 0;
@ -177,6 +192,17 @@ while (<>) {
close (ARGV); # reset line numbering
}
# read lines until we have no open comments
while (m@/\*([^*]|\*(?!/))*$@) {
my $new;
defined ($new = <>) || die "Unmatched comment in $ARGV";
$_ .= $new;
}
# strip comments w/o options
s@/\*(?!<)
([^*]+|\*(?!/))*
\*/@@gx;
if (m@^\s*typedef\s+enum\s*
({)?\s*
(?:/\*<
@ -185,11 +211,7 @@ while (<>) {
@x) {
if (defined $2) {
my %options = parse_options($2);
$skip = $options{"skip"};
$pdbskip = $options{"pdb-skip"};
} else {
$skip = undef;
$pdbskip = undef;
next if defined $options{"pdb-skip"};
}
# Didn't have trailing '{' look on next lines
if (!defined $1) {
@ -203,7 +225,7 @@ while (<>) {
$symbols = ""; $contig = 1; $before = -1; @mapping = ();
# Now parse the entries
&parse_entries (\*ARGV);
&parse_entries (\*ARGV, $ARGV);
$symbols =~ s/\s*$//s;
$symbols = wrap("\t\t\t ", "\t\t\t " , $symbols);
@ -217,7 +239,7 @@ while (<>) {
$ARGV =~ s@(?:(?:..|app)/)*@@;
$code .= <<ENTRY if !$pdbskip;
$code .= <<ENTRY;
: $enumname =>
: { contig => $contig,
: header => '$ARGV',