mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-20 08:17:40 +00:00
dec20d8214
2004-01-06 Michael Natterer <mitch@gimp.org> Enabled skipping enum values for either the PDB or GType registration (don't always skip both targets): * tools/gimp-mkenums: skip enum values only if there is a literal "skip" (don't match "pdb-skip"). * tools/pdbgen/enumgen.pl: skip only "pdb-skip" values, not "skip" ones. * app/base/base-enums.h * app/core/core-enums.h * app/paint/paint-enums.h * libgimpbase/gimpbaseenums.h: use the right "pdb-skip"/"skip" combination to skip enum values. Changed comments accordingly. Cleaned up the fill functions: * app/core/core-enums.[ch]: added GIMP_PATTERN_FILL enum value to the GimpFillType enum. Don't export GIMP_NO_FILL to the PDB because it's completely useless to export a NOP. * app/core/gimp-edit.c (gimp_edit_fill, gimp_edit_fill_internal): handle pattern fill requests. * app/core/gimpdrawable.[ch] (gimp_drawable_fill): added GimpPattern parameter and fill with it if it's non-NULL. (gimp_drawable_fill_by_type): handle pattern fill and pass the current pattern to gimp_drawable_fill(). * app/text/gimptextlayer.c: changed accordingly. * app/gui/edit-commands.c * app/gui/image-menu.c: use gimp_edit_fill() instead of gimp_drawable_bucket_fill() for FG, BG and pattern filling. * libgimp/gimpcompat.h * plug-ins/script-fu/siod-wrapper.c: removed NO_IMAGE_FILL compat enum value. It should have never been exported to the PDB. * app/pdb/drawable_cmds.c * app/pdb/edit_cmds.c * libgimp/gimpenums.h * plug-ins/pygimp/gimpenums.py * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: regenerated.
262 lines
6.1 KiB
Perl
Executable file
262 lines
6.1 KiB
Perl
Executable file
#!/usr/bin/perl -w
|
|
|
|
# The GIMP -- an image manipulation program
|
|
# Copyright (C) 1999-2003 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-2003 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);
|
|
|
|
# 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) {
|
|
$opt =~ s/^\s*//;
|
|
$opt =~ s/\s*$//;
|
|
my ($key,$val) = $opt =~ /([-\w]+)(?:=(.+))?/;
|
|
defined $val or $val = 1;
|
|
push @opts, $key, $val;
|
|
}
|
|
@opts;
|
|
}
|
|
|
|
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@/\*([^*]|\*(?!/))*$@) {
|
|
my $new;
|
|
defined ($new = <$file>) || die "Unmatched comment in $ARGV";
|
|
$_ .= $new;
|
|
}
|
|
# strip comments w/o options
|
|
s@/\*(?!<)
|
|
([^*]+|\*(?!/))*
|
|
\*/@@gx;
|
|
|
|
s@\n@ @;
|
|
|
|
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, $NEWFILE)) {
|
|
return 1;
|
|
} else {
|
|
next;
|
|
}
|
|
}
|
|
|
|
if (/^\s*\}\s*(\w+)/) {
|
|
$enumname = $1;
|
|
return 1;
|
|
}
|
|
|
|
if (/^\s*\}/) {
|
|
$looking_for_name = 1;
|
|
next;
|
|
}
|
|
|
|
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{"pdb-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;
|
|
} elsif (m@^\s*\#@) {
|
|
# ignore preprocessor directives
|
|
} else {
|
|
print STDERR "$0: $file_name:$.: Failed to parse `$_'\n";
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
my $code = "";
|
|
while (<>) {
|
|
if (eof) {
|
|
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*
|
|
(?:/\*<
|
|
(([^*]|\*(?!/))*)
|
|
>\s*\*/)?
|
|
@x) {
|
|
if (defined $2) {
|
|
my %options = parse_options($2);
|
|
next if defined $options{"pdb-skip"};
|
|
}
|
|
# 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, $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;
|
|
: $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);
|