1999-09-25 01:59:43 +00:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
|
|
|
# The GIMP -- an image manipulation program
|
2003-07-03 00:47:26 +00:00
|
|
|
# Copyright (C) 1999-2003 Manish Singh <yosh@gimp.org>
|
1999-09-25 01:59:43 +00:00
|
|
|
|
|
|
|
# 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{destdir} || '.';
|
|
|
|
}
|
|
|
|
|
|
|
|
use lib $srcdir;
|
|
|
|
|
|
|
|
require 'enums.pl';
|
|
|
|
require 'util.pl';
|
|
|
|
|
|
|
|
*enums = \%Gimp::CodeGen::enums::enums;
|
|
|
|
|
|
|
|
*write_file = \&Gimp::CodeGen::util::write_file;
|
|
|
|
*FILE_EXT = \$Gimp::CodeGen::util::FILE_EXT;
|
|
|
|
|
2004-10-25 19:29:00 +00:00
|
|
|
my $enumfile = "$destdir/libgimp/gimpenums.h$FILE_EXT";
|
1999-09-25 01:59:43 +00:00
|
|
|
open ENUMFILE, "> $enumfile" or die "Can't open $enumfile: $!\n";
|
|
|
|
|
|
|
|
print ENUMFILE <<'LGPL';
|
|
|
|
/* LIBGIMP - The GIMP Library
|
2003-07-03 00:47:26 +00:00
|
|
|
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
|
1999-09-25 01:59:43 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
1999-12-26 07:54:39 +00:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1999-09-25 01:59:43 +00:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
1999-12-26 07:54:39 +00:00
|
|
|
* Lesser General Public License for more details.
|
1999-09-25 01:59:43 +00:00
|
|
|
*
|
1999-12-26 07:54:39 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
1999-09-25 01:59:43 +00:00
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* NOTE: This file is autogenerated by enumcode.pl */
|
|
|
|
|
|
|
|
LGPL
|
|
|
|
|
|
|
|
my $guard = "__GIMP_ENUMS_H__";
|
|
|
|
print ENUMFILE <<HEADER;
|
|
|
|
#ifndef $guard
|
|
|
|
#define $guard
|
|
|
|
|
2001-11-22 23:46:13 +00:00
|
|
|
G_BEGIN_DECLS
|
1999-09-25 01:59:43 +00:00
|
|
|
|
|
|
|
HEADER
|
|
|
|
|
|
|
|
foreach (sort keys %enums) {
|
2001-12-01 00:14:14 +00:00
|
|
|
if (! ($enums{$_}->{header} =~ /libgimp/)) {
|
2004-10-25 01:52:12 +00:00
|
|
|
my $gtype = $func = $_;
|
|
|
|
|
|
|
|
for ($gtype) { s/Gimp//; s/([A-Z][^A-Z]+)/\U\1\E_/g; s/_$// }
|
|
|
|
for ($func) { s/Gimp//; s/([A-Z][^A-Z]+)/\L\1\E_/g; s/_$// }
|
|
|
|
|
|
|
|
print ENUMFILE "\n#define GIMP_TYPE_$gtype (gimp_$func\_get_type ())\n\n";
|
|
|
|
print ENUMFILE "GType gimp_$func\_get_type (void) G_GNUC_CONST;\n\n";
|
2001-05-21 13:58:46 +00:00
|
|
|
print ENUMFILE "typedef enum\n{\n";
|
2003-02-08 19:47:48 +00:00
|
|
|
|
2001-05-21 13:58:46 +00:00
|
|
|
my $enum = $enums{$_}; my $body = "";
|
2004-10-25 01:52:12 +00:00
|
|
|
|
2001-05-21 13:58:46 +00:00
|
|
|
foreach $symbol (@{$enum->{symbols}}) {
|
|
|
|
my $sym = $symbol;
|
2004-10-25 01:52:12 +00:00
|
|
|
$body .= " $sym";
|
2001-05-21 13:58:46 +00:00
|
|
|
$body .= " = $enum->{mapping}->{$symbol}" if !$enum->{contig};
|
|
|
|
$body .= ",\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$body =~ s/,\n$//s;
|
|
|
|
$body .= "\n} ";
|
|
|
|
$body .= "$_;\n\n";
|
|
|
|
print ENUMFILE $body
|
1999-09-25 01:59:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print ENUMFILE <<HEADER;
|
2001-11-22 23:46:13 +00:00
|
|
|
|
2004-10-25 19:29:00 +00:00
|
|
|
void _gimp_enums_init (void);
|
|
|
|
|
|
|
|
const gchar ** gimp_enums_get_type_names (gint *n_type_names);
|
|
|
|
|
|
|
|
|
2001-11-22 23:46:13 +00:00
|
|
|
G_END_DECLS
|
1999-10-24 22:08:11 +00:00
|
|
|
|
1999-09-25 01:59:43 +00:00
|
|
|
#endif /* $guard */
|
|
|
|
HEADER
|
|
|
|
|
|
|
|
close ENUMFILE;
|
|
|
|
&write_file($enumfile);
|
2004-10-25 19:29:00 +00:00
|
|
|
|
|
|
|
$enumfile = "$destdir/libgimp/gimpenums.c.tail$FILE_EXT";
|
|
|
|
open ENUMFILE, "> $enumfile" or die "Can't open $enumfile: $!\n";
|
|
|
|
|
|
|
|
print ENUMFILE <<CODE;
|
|
|
|
|
|
|
|
typedef GType (* GimpGetTypeFunc) (void);
|
|
|
|
|
|
|
|
static GimpGetTypeFunc get_type_funcs[] =
|
|
|
|
{
|
|
|
|
CODE
|
|
|
|
|
|
|
|
foreach (sort keys %enums) {
|
|
|
|
if (! ($_ =~ /GimpUnit/)) {
|
|
|
|
my $enum = $enums{$_};
|
|
|
|
my $func = $_;
|
|
|
|
|
|
|
|
for ($func) { s/Gimp//; s/PDB/Pdb/; s/([A-Z][^A-Z]+)/\L\1\E_/g; s/_$// }
|
|
|
|
|
|
|
|
print ENUMFILE " gimp_$func\_get_type,\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print ENUMFILE <<CODE;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const gchar *type_names[] =
|
|
|
|
{
|
|
|
|
CODE
|
|
|
|
|
|
|
|
foreach (sort keys %enums) {
|
|
|
|
if (! ($_ =~ /GimpUnit/)) {
|
|
|
|
my $enum = $enums{$_};
|
|
|
|
my $gtype = $_;
|
|
|
|
|
|
|
|
print ENUMFILE " \"$gtype\",\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print ENUMFILE <<CODE;
|
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
_gimp_enums_init (void)
|
|
|
|
{
|
|
|
|
GimpGetTypeFunc *funcs;
|
|
|
|
gint i;
|
|
|
|
GType type;
|
|
|
|
|
|
|
|
for (i = 0, funcs = get_type_funcs; *funcs; i++, funcs++)
|
|
|
|
{
|
|
|
|
type = (*funcs) ();
|
|
|
|
|
|
|
|
g_type_class_ref (type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const gchar **
|
|
|
|
gimp_enums_get_type_names (gint *n_type_names)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (n_type_names != NULL, NULL);
|
|
|
|
|
|
|
|
*n_type_names = G_N_ELEMENTS (type_names);
|
|
|
|
|
|
|
|
return type_names;
|
|
|
|
}
|
|
|
|
|
|
|
|
CODE
|
|
|
|
|
|
|
|
close ENUMFILE;
|
|
|
|
&write_file($enumfile);
|