Files
gimp/tools/pdbgen/enumgen.pl
Manish Singh 96f78088b0 tools/pdbgen/app.pl tools/pdbgen/enumcode-py.pl tools/pdbgen/enumcode.pl
2002-03-17  Manish Singh  <yosh@gimp.org>

        * tools/pdbgen/app.pl
        * tools/pdbgen/enumcode-py.pl
        * tools/pdbgen/enumcode.pl
        * tools/pdbgen/enumgen.pl: removed enum nick support, best to keep
        internal and external names consistent

        * app/core/core-enums.h: remove chops from enums. Change TRANS to
        TRANSPARENT in GimpBlendMode

        * app/core/core-types.h: remove chops and nicks from enums. Change INV
        to INVERSE and SUB to SUBTRACT to make things more clear

        * app/core/gimpchannel.c
        * app/gui/channels-commands.c
        * app/gui/vectors-commands.c
        * app/tools/gimpbezierselecttool.c
        * app/tools/gimpbycolorselecttool.c
        * app/tools/gimprectselecttool.c
        * app/tools/gimpselectiontool.c
        * app/tools/selection_options.c
        * app/tools/tools-types.h
        * app/widgets/gimpchannellistview.c
        * app/widgets/gimpvectorslistview.c: reflect SUB -> SUBTRACT change

        * app/core/gimpdrawable-blend.c: reflect TRANS -> TRANSPARENT change

        * app/core/gimplayer.c
        * app/gui/layers-commands.c: reflect INV -> INVERSE change

        * app/paint/paint-types.h: remove nick from PaintApplicationMode

        * app/tools/gimperasertool.c: fix tooltip

        * app/widgets/gimpenummenu.c: #include "libgimp/gimpintl.h" for
        gettext

        * libgimp/gimpcompat.h: compatibility enums here, since we removed
        the nicks

        * tools/pdbgen/enums.pl
        * libgimp/gimpenums.h
        * plug-ins/script-fu/script-fu-constants.c
        * app/core/core-enums.c
        * app/pdb/channel_cmds.c
        * app/pdb/drawable_cmds.c
        * app/pdb/edit_cmds.c
        * app/pdb/layer_cmds.c
        * app/pdb/misc_tools_cmds.c
        * app/pdb/paint_tools_cmds.c
        * app/pdb/selection_cmds.c
        * app/pdb/selection_tools_cmds.c: regenerated, enum changes

        * plug-ins/common/hot.c: GIMP_TRANS_IMAGE_FILL -> GIMP_TRANSPARENT_FILL

        * plug-ins/common/warp.c: GIMP_BG_IMAGE_FILL -> GIMP_BACKGROUND_FILL

        * plug-ins/script-fu/siod-wrapper.c: compat constant definitions
2002-03-17 22:54:26 +00:00

240 lines
5.6 KiB
Perl
Executable File

#!/usr/bin/perl -w
# The GIMP -- an image manipulation program
# Copyright (C) 1999-2000 Manish Singh <yosh@gimp.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUTFILE ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
BEGIN {
$srcdir = $ENV{srcdir} || '.';
$destdir = $ENV{srcdir} || '.';
}
use lib $srcdir;
use Text::Wrap qw(wrap $columns);
$columns = 77;
#BEGIN { require 'util.pl' }
require 'util.pl';
*write_file = \&Gimp::CodeGen::util::write_file;
*FILE_EXT = \$Gimp::CodeGen::util::FILE_EXT;
my $header = <<'HEADER';
:# The GIMP -- an image manipulation program
:# Copyright (C) 1999-2000 Manish Singh <yosh@gimp.org>
:
:# This program is free software; you can redistribute it and/or modify
:# it under the terms of the GNU General Public License as published by
:# the Free Software Foundation; either version 2 of the License, or
:# (at your option) any later version.
:
:# This program is distributed in the hope that it will be useful,
:# but WITHOUTFILE ANY WARRANTY; without even the implied warranty of
:# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
:# GNU General Public License for more details.
:
:# You should have received a copy of the GNU General Public License
:# along with this program; if not, write to the Free Software
:# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
:
:# autogenerated by enumgen.pl
:
:package Gimp::CodeGen::enums;
:
:%enums = (
HEADER
my $footer = <<'FOOTER';
:);
:
:foreach $e (values %enums) {
: $e->{info} = "";
: foreach (@{$e->{symbols}}) {
: $e->{info} .= "$_ ($e->{mapping}->{$_}), "
: }
: $e->{info} =~ s/, $//;
:}
:
:1;
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 {
my $opts = shift;
my @opts;
for $opt (split /\s*,\s*/, $opts) {
my ($key,$val) = $opt =~ /\s*([\w-]+)(?:=(\S+))?/;
defined $val or $val = 1;
push @opts, $key, $val;
}
@opts;
}
sub parse_entries {
my $file = shift;
while (<$file>) {
# Read lines until we have no open comments
while (m@/\*
([^*]|\*(?!/))*$
@x) {
my $new;
defined ($new = <$file>) || die "Unmatched comment";
$_ .= $new;
}
# Now strip comments
s@/\*(?!<)
([^*]+|\*(?!/))*
\*/@@gx;
s@\n@ @;
next if m@^\s*$@;
# Handle include files
if (/^\#include\s*<([^>]*)>/ ) {
my $file= "../$1";
open NEWFILE, $file or die "Cannot open include file $file: $!\n";
if (&parse_entries (\*NEWFILE)) {
return 1;
} else {
next;
}
}
if (/^\s*\}\s*(\w+)/) {
$enumname = $1;
return 1;
}
if (m@^\s*
(\w+)\s* # name
(?:=( # value
(?:[^,/]|/(?!\*))*
))?,?\s*
(?:/\*< # options
(([^*]|\*(?!/))*)
>\s*\*/)?,?
\s*$
@x) {
my ($name, $value, $options) = ($1, $2, $3);
if (defined $options) {
my %options = parse_options($options);
next if defined $options{skip};
}
$symbols .= $name . ' ';
# Figure out a default value (not really foolproof)
$value = $before + 1 if !defined $value;
$value =~ s/\s*$//s;
$value =~ s/^\s*//s;
push @mapping, $name, $value;
my $test = $before + 1;
# Warnings in our eval should be fatal so they set $@
local $SIG{__WARN__} = sub { die $_[0] };
# Try to get a numeric value
eval "\$test = $value * 1;";
# Assume noncontiguous if it's not a number
$contig = 0 if $contig && ($@ || $test - 1 != $before);
$before = $test;
} else {
print STDERR "Can't understand: $_\n";
}
}
return 0;
}
my $code = "";
while (<>) {
if (eof) {
close (ARGV); # reset line numbering
}
if (m@^\s*typedef\s+enum\s*
({)?\s*
(?:/\*<
(([^*]|\*(?!/))*)
>\s*\*/)?
@x) {
if (defined $2) {
my %options = parse_options($2);
$skip = $options{"skip"};
$pdbskip = $options{"pdb-skip"};
} else {
$skip = undef;
$pdbskip = undef;
}
# Didn't have trailing '{' look on next lines
if (!defined $1) {
while (<>) {
if (s/^\s*\{//) {
last;
}
}
}
$symbols = ""; $contig = 1; $before = -1; @mapping = ();
# Now parse the entries
&parse_entries (\*ARGV);
$symbols =~ s/\s*$//s;
$symbols = wrap("\t\t\t ", "\t\t\t " , $symbols);
$symbols =~ s/^\s*//s;
my $mapping = ""; $pos = 1;
foreach (@mapping) {
$mapping .= $pos++ % 2 ? "$_ => " : "'$_',\n\t\t ";
}
$mapping =~ s/,\n\s*$//s;
$ARGV =~ s@(?:(?:..|app)/)*@@;
$code .= <<ENTRY if !$pdbskip;
: $enumname =>
: { contig => $contig,
: header => '$ARGV',
: symbols => [ qw($symbols) ],
: mapping => { $mapping }
: },
ENTRY
}
}
$code =~ s/,\n$/\n/s;
foreach ($header, $code, $footer) { s/^://mg }
$outfile = "$destdir/enums.pl$FILE_EXT";
open OUTFILE, "> $outfile";
print OUTFILE $header, $code, $footer;
close OUTFILE;
&write_file($outfile);