1999-09-25 09:59:43 +08:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
2006-12-10 05:33:38 +08:00
|
|
|
# GIMP - The GNU Image Manipulation Program
|
2003-07-03 08:47:26 +08:00
|
|
|
# Copyright (C) 1999-2003 Manish Singh <yosh@gimp.org>
|
1999-09-25 09:59:43 +08:00
|
|
|
|
2009-01-18 06:28:01 +08:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
1999-09-25 09:59:43 +08:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
# the Free Software Foundation; either version 3 of the License, or
|
1999-09-25 09:59:43 +08:00
|
|
|
# (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
|
2018-07-12 05:27:07 +08:00
|
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
1999-09-25 09:59:43 +08:00
|
|
|
|
|
|
|
BEGIN {
|
2011-11-07 00:33:20 +08:00
|
|
|
$srcdir = $ENV{srcdir} || '.';
|
|
|
|
$destdir = $ENV{destdir} || '.';
|
|
|
|
$builddir = $ENV{builddir} || '.';
|
1999-09-25 09:59:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2011-11-07 00:33:20 +08:00
|
|
|
my $enumfile = "$builddir/libgimp/gimpenums.h$FILE_EXT";
|
1999-09-25 09:59:43 +08:00
|
|
|
open ENUMFILE, "> $enumfile" or die "Can't open $enumfile: $!\n";
|
|
|
|
|
|
|
|
print ENUMFILE <<'LGPL';
|
|
|
|
/* LIBGIMP - The GIMP Library
|
2003-07-03 08:47:26 +08:00
|
|
|
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
|
1999-09-25 09:59:43 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
1999-12-26 15:54:39 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1999-09-25 09:59:43 +08:00
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-18 06:28:01 +08:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
1999-09-25 09:59:43 +08:00
|
|
|
*
|
|
|
|
* 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 15:54:39 +08:00
|
|
|
* Lesser General Public License for more details.
|
1999-09-25 09:59:43 +08:00
|
|
|
*
|
1999-12-26 15:54:39 +08:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-01-18 06:28:01 +08:00
|
|
|
* License along with this library. If not, see
|
2018-07-12 05:27:07 +08:00
|
|
|
* <https://www.gnu.org/licenses/>.
|
1999-09-25 09:59:43 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* NOTE: This file is autogenerated by enumcode.pl */
|
|
|
|
|
|
|
|
LGPL
|
|
|
|
|
|
|
|
my $guard = "__GIMP_ENUMS_H__";
|
|
|
|
print ENUMFILE <<HEADER;
|
|
|
|
#ifndef $guard
|
|
|
|
#define $guard
|
|
|
|
|
2001-11-23 07:46:13 +08:00
|
|
|
G_BEGIN_DECLS
|
1999-09-25 09:59:43 +08:00
|
|
|
|
|
|
|
HEADER
|
|
|
|
|
|
|
|
foreach (sort keys %enums) {
|
2018-03-18 03:19:58 +08:00
|
|
|
if (! ($enums{$_}->{header} =~ /libgimp/) &&
|
|
|
|
! $enums{$_}->{external}) {
|
2004-10-25 09:52:12 +08:00
|
|
|
my $gtype = $func = $_;
|
|
|
|
|
2004-10-26 08:59:41 +08:00
|
|
|
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/_$// }
|
2004-10-25 09:52:12 +08:00
|
|
|
|
|
|
|
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";
|
2019-07-24 07:55:06 +08:00
|
|
|
|
|
|
|
print ENUMFILE "/**\n";
|
|
|
|
print ENUMFILE " * $_:\n";
|
|
|
|
|
|
|
|
my $enum = $enums{$_};
|
|
|
|
|
|
|
|
foreach $symbol (@{$enum->{symbols}}) {
|
|
|
|
print ENUMFILE " * @" . $symbol . ": " . $symbol . "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
print ENUMFILE " *\n";
|
|
|
|
print ENUMFILE " * Extracted from app/" . $enums{$_}->{header} . "\n";
|
|
|
|
print ENUMFILE " **/\n";
|
|
|
|
|
2001-05-21 21:58:46 +08:00
|
|
|
print ENUMFILE "typedef enum\n{\n";
|
2003-02-09 03:47:48 +08:00
|
|
|
|
2019-07-24 07:55:06 +08:00
|
|
|
my $body = "";
|
2004-10-25 09:52:12 +08:00
|
|
|
|
2001-05-21 21:58:46 +08:00
|
|
|
foreach $symbol (@{$enum->{symbols}}) {
|
|
|
|
my $sym = $symbol;
|
2004-10-25 09:52:12 +08:00
|
|
|
$body .= " $sym";
|
2001-05-21 21:58:46 +08: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 09:59:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print ENUMFILE <<HEADER;
|
2001-11-23 07:46:13 +08:00
|
|
|
|
2005-06-04 07:25:44 +08:00
|
|
|
void gimp_enums_init (void);
|
2004-10-26 03:29:00 +08:00
|
|
|
|
|
|
|
const gchar ** gimp_enums_get_type_names (gint *n_type_names);
|
|
|
|
|
|
|
|
|
2001-11-23 07:46:13 +08:00
|
|
|
G_END_DECLS
|
1999-10-25 06:08:11 +08:00
|
|
|
|
1999-09-25 09:59:43 +08:00
|
|
|
#endif /* $guard */
|
|
|
|
HEADER
|
|
|
|
|
|
|
|
close ENUMFILE;
|
2011-11-07 00:33:20 +08:00
|
|
|
&write_file($enumfile, "$destdir/libgimp");
|
2004-10-26 03:29:00 +08:00
|
|
|
|
2011-11-07 00:33:20 +08:00
|
|
|
$enumfile = "$builddir/libgimp/gimpenums.c.tail$FILE_EXT";
|
2004-10-26 03:29:00 +08:00
|
|
|
open ENUMFILE, "> $enumfile" or die "Can't open $enumfile: $!\n";
|
|
|
|
|
|
|
|
print ENUMFILE <<CODE;
|
|
|
|
|
|
|
|
typedef GType (* GimpGetTypeFunc) (void);
|
|
|
|
|
2005-04-30 02:29:24 +08:00
|
|
|
static const GimpGetTypeFunc get_type_funcs[] =
|
2004-10-26 03:29:00 +08:00
|
|
|
{
|
|
|
|
CODE
|
|
|
|
|
2004-10-28 03:32:04 +08:00
|
|
|
my $first = 1;
|
2004-10-26 03:29:00 +08:00
|
|
|
foreach (sort keys %enums) {
|
|
|
|
if (! ($_ =~ /GimpUnit/)) {
|
|
|
|
my $enum = $enums{$_};
|
|
|
|
my $func = $_;
|
2018-03-18 03:19:58 +08:00
|
|
|
my $gegl_enum = ($func =~ /Gegl/);
|
2004-10-26 03:29:00 +08:00
|
|
|
|
2018-03-18 03:19:58 +08:00
|
|
|
for ($func) { s/Gimp//; s/Gegl//; s/PDB/Pdb/;
|
|
|
|
s/([A-Z][^A-Z]+)/\L$1\E_/g; s/_$// }
|
2004-10-26 03:29:00 +08:00
|
|
|
|
2004-10-28 03:32:04 +08:00
|
|
|
print ENUMFILE ",\n" unless $first;
|
2018-03-18 03:19:58 +08:00
|
|
|
|
|
|
|
if ($gegl_enum) {
|
|
|
|
print ENUMFILE " gegl_$func\_get_type";
|
|
|
|
} else {
|
|
|
|
print ENUMFILE " gimp_$func\_get_type";
|
|
|
|
}
|
2004-10-28 03:32:04 +08:00
|
|
|
|
|
|
|
$first = 0;
|
2004-10-26 03:29:00 +08:00
|
|
|
}
|
|
|
|
}
|
2004-10-28 03:32:04 +08:00
|
|
|
print ENUMFILE "\n" unless $first;
|
2004-10-26 03:29:00 +08:00
|
|
|
|
|
|
|
print ENUMFILE <<CODE;
|
|
|
|
};
|
|
|
|
|
2006-04-06 21:20:39 +08:00
|
|
|
static const gchar * const type_names[] =
|
2004-10-26 03:29:00 +08:00
|
|
|
{
|
|
|
|
CODE
|
|
|
|
|
2004-10-28 06:46:40 +08:00
|
|
|
$first = 1;
|
2004-10-26 03:29:00 +08:00
|
|
|
foreach (sort keys %enums) {
|
|
|
|
if (! ($_ =~ /GimpUnit/)) {
|
|
|
|
my $enum = $enums{$_};
|
|
|
|
my $gtype = $_;
|
|
|
|
|
2004-10-28 03:32:04 +08:00
|
|
|
print ENUMFILE ",\n" unless $first;
|
|
|
|
print ENUMFILE " \"$gtype\"";
|
|
|
|
|
|
|
|
$first = 0;
|
2004-10-26 03:29:00 +08:00
|
|
|
}
|
|
|
|
}
|
2004-10-28 03:32:04 +08:00
|
|
|
print ENUMFILE "\n" unless $first;
|
2004-10-26 03:29:00 +08:00
|
|
|
|
|
|
|
print ENUMFILE <<CODE;
|
|
|
|
};
|
|
|
|
|
2005-06-04 07:25:44 +08:00
|
|
|
static gboolean enums_initialized = FALSE;
|
|
|
|
|
2018-04-28 20:00:23 +08:00
|
|
|
#if 0
|
|
|
|
/* keep around as documentation how to do compat enums */
|
2017-02-27 03:10:54 +08:00
|
|
|
GType gimp_convert_dither_type_compat_get_type (void);
|
2018-04-28 20:00:23 +08:00
|
|
|
#endif
|
2017-01-25 06:25:02 +08:00
|
|
|
|
2005-06-04 07:25:44 +08:00
|
|
|
/**
|
2010-07-15 01:02:58 +08:00
|
|
|
* gimp_enums_init:
|
2005-06-04 07:25:44 +08:00
|
|
|
*
|
|
|
|
* This function makes sure all the enum types are registered
|
2010-07-15 01:02:58 +08:00
|
|
|
* with the #GType system. This is intended for use by language
|
|
|
|
* bindings that need the symbols early, before gimp_main is run.
|
|
|
|
* It's not necessary for plug-ins to call this directly, because
|
|
|
|
* the normal plug-in initialization code will handle it implicitly.
|
2005-06-04 07:25:44 +08:00
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.4
|
2005-06-04 07:25:44 +08:00
|
|
|
**/
|
2004-10-26 03:29:00 +08:00
|
|
|
void
|
2005-06-04 07:25:44 +08:00
|
|
|
gimp_enums_init (void)
|
2004-10-26 03:29:00 +08:00
|
|
|
{
|
2005-04-30 02:29:24 +08:00
|
|
|
const GimpGetTypeFunc *funcs = get_type_funcs;
|
2018-04-28 20:00:23 +08:00
|
|
|
#if 0
|
2017-01-09 06:00:19 +08:00
|
|
|
GQuark quark;
|
2018-04-28 20:00:23 +08:00
|
|
|
#endif
|
2005-04-30 02:29:24 +08:00
|
|
|
gint i;
|
2004-10-26 03:29:00 +08:00
|
|
|
|
2005-06-04 07:25:44 +08:00
|
|
|
if (enums_initialized)
|
|
|
|
return;
|
|
|
|
|
2005-04-30 02:29:24 +08:00
|
|
|
for (i = 0; i < G_N_ELEMENTS (get_type_funcs); i++, funcs++)
|
2004-10-26 03:29:00 +08:00
|
|
|
{
|
2004-10-28 02:40:45 +08:00
|
|
|
GType type = (*funcs) ();
|
2004-10-26 03:29:00 +08:00
|
|
|
|
|
|
|
g_type_class_ref (type);
|
|
|
|
}
|
2005-06-04 07:25:44 +08:00
|
|
|
|
2018-04-28 20:00:23 +08:00
|
|
|
#if 0
|
|
|
|
/* keep around as documentation how to do compat enums */
|
|
|
|
|
2017-01-09 06:00:19 +08:00
|
|
|
/* keep compat enum code in sync with app/app.c (app_libs_init) */
|
|
|
|
quark = g_quark_from_static_string ("gimp-compat-enum");
|
|
|
|
|
2017-02-27 03:10:54 +08:00
|
|
|
g_type_set_qdata (GIMP_TYPE_CONVERT_DITHER_TYPE, quark,
|
|
|
|
(gpointer) gimp_convert_dither_type_compat_get_type ());
|
2018-04-28 20:00:23 +08:00
|
|
|
#endif
|
2017-01-09 06:00:19 +08:00
|
|
|
|
2017-10-30 01:37:18 +08:00
|
|
|
gimp_base_compat_enums_init ();
|
2017-06-30 20:52:44 +08:00
|
|
|
|
2005-06-04 07:25:44 +08:00
|
|
|
enums_initialized = TRUE;
|
2004-10-26 03:29:00 +08:00
|
|
|
}
|
|
|
|
|
2004-10-27 02:58:50 +08:00
|
|
|
/**
|
|
|
|
* gimp_enums_get_type_names:
|
2019-08-10 00:47:55 +08:00
|
|
|
* \@n_type_names: (out): return location for the number of names
|
2004-10-27 02:58:50 +08:00
|
|
|
*
|
|
|
|
* This function gives access to the list of enums registered by libgimp.
|
|
|
|
* The returned array is static and must not be modified.
|
|
|
|
*
|
2023-05-22 07:19:17 +08:00
|
|
|
* Returns: (array length=n_type_names) (transfer none): an array with type names
|
2004-10-27 02:58:50 +08:00
|
|
|
*
|
2015-06-01 03:18:09 +08:00
|
|
|
* Since: 2.2
|
2004-10-27 02:58:50 +08:00
|
|
|
**/
|
2004-10-26 03:29:00 +08:00
|
|
|
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);
|
|
|
|
|
2006-05-27 23:19:15 +08:00
|
|
|
return (const gchar **) type_names;
|
2004-10-26 03:29:00 +08:00
|
|
|
}
|
|
|
|
CODE
|
|
|
|
|
|
|
|
close ENUMFILE;
|
2011-11-07 00:33:20 +08:00
|
|
|
&write_file($enumfile, "$destdir/libgimp");
|