[gimp] pdb, libgimp: allow to use external GType-registered enums in the PDB
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] pdb, libgimp: allow to use external GType-registered enums in the PDB
- Date: Sat, 17 Mar 2018 19:32:14 +0000 (UTC)
commit 390ef44481bf065ac86fbfa1856479fff652db70
Author: Michael Natterer <mitch gimp org>
Date: Sat Mar 17 20:19:58 2018 +0100
pdb, libgimp: allow to use external GType-registered enums in the PDB
The enums have to be menually registered in pdb/enums-external.pl.
Currently supports enums from GEGL only.
Add enum GeglDistanceMetric as first external enum.
libgimp/Makefile.am | 2 +-
libgimp/gimpenums.c.tail | 2 ++
pdb/Makefile.am | 3 ++-
pdb/enumcode.pl | 14 +++++++++++---
pdb/enumgen.pl | 10 +++++++++-
pdb/enums-external.pl | 10 ++++++++++
pdb/enums.pl | 10 ++++++++++
7 files changed, 45 insertions(+), 6 deletions(-)
---
diff --git a/libgimp/Makefile.am b/libgimp/Makefile.am
index 2e71ba9..141f857 100644
--- a/libgimp/Makefile.am
+++ b/libgimp/Makefile.am
@@ -445,7 +445,7 @@ CLEANFILES = $(gen_sources)
gimpenums.c: $(srcdir)/gimpenums.h $(srcdir)/gimpenums.c.tail $(GIMP_MKENUMS) Makefile.am
$(AM_V_GEN) $(GIMP_MKENUMS) \
- --fhead "#include \"config.h\"\n#include <gio/gio.h>\n#undef
GIMP_DISABLE_DEPRECATED\n#include \"libgimpbase/gimpbase.h\"\n#include
\"libgimpbase/gimpbase-private.h\"\n#include \"libgimpconfig/gimpconfigenums.h\"\n#include \"gimpenums.h\"" \
+ --fhead "#include \"config.h\"\n#include <gio/gio.h>\n#include <gegl.h>\n#undef
GIMP_DISABLE_DEPRECATED\n#include \"libgimpbase/gimpbase.h\"\n#include
\"libgimpbase/gimpbase-private.h\"\n#include \"libgimpconfig/gimpconfigenums.h\"\n#include \"gimpenums.h\"" \
--fprod "\n/* enumerations from \"@filename@\" */" \
--vhead "GType\n@enum_name@_get_type (void)\n{\n static const G@Type@Value values[] =\n {" \
--vprod " { @VALUENAME@, \"@VALUENAME@\", \"@valuenick@\" }," \
diff --git a/libgimp/gimpenums.c.tail b/libgimp/gimpenums.c.tail
index ac40359..e1d1c96 100644
--- a/libgimp/gimpenums.c.tail
+++ b/libgimp/gimpenums.c.tail
@@ -3,6 +3,7 @@ typedef GType (* GimpGetTypeFunc) (void);
static const GimpGetTypeFunc get_type_funcs[] =
{
+ gegl_distance_metric_get_type,
gimp_add_mask_type_get_type,
gimp_blend_mode_get_type,
gimp_brush_application_mode_get_type,
@@ -69,6 +70,7 @@ static const GimpGetTypeFunc get_type_funcs[] =
static const gchar * const type_names[] =
{
+ "GeglDistanceMetric",
"GimpAddMaskType",
"GimpBlendMode",
"GimpBrushApplicationMode",
diff --git a/pdb/Makefile.am b/pdb/Makefile.am
index eab66dc..31275da 100644
--- a/pdb/Makefile.am
+++ b/pdb/Makefile.am
@@ -66,6 +66,7 @@ EXTRA_DIST = \
enumcode.pl \
enumgen.pl \
enums.pl \
+ enums-external.pl \
groups.pl \
lib.pl \
pdb.pl \
@@ -112,7 +113,7 @@ DISTCLEANFILES = $(stamp_files)
$(srcdir)/enums.pl: stamp-enums
@:
-stamp-enums: $(srcdir)/enumgen.pl $(enum_headers) Makefile.am
+stamp-enums: $(srcdir)/enumgen.pl $(enum_headers) enums-external.pl Makefile.am
rootme=`pwd`; \
destdir=`cd $(top_srcdir) && pwd`; export destdir; \
builddir=`cd $(top_builddir) && pwd`; export builddir; \
diff --git a/pdb/enumcode.pl b/pdb/enumcode.pl
index dc9fff6..96faf5a 100755
--- a/pdb/enumcode.pl
+++ b/pdb/enumcode.pl
@@ -68,7 +68,8 @@ G_BEGIN_DECLS
HEADER
foreach (sort keys %enums) {
- if (! ($enums{$_}->{header} =~ /libgimp/)) {
+ if (! ($enums{$_}->{header} =~ /libgimp/) &&
+ ! $enums{$_}->{external}) {
my $gtype = $func = $_;
for ($gtype) { s/Gimp//; s/([A-Z][^A-Z]+)/\U$1\E_/g; s/_$// }
@@ -125,11 +126,18 @@ foreach (sort keys %enums) {
if (! ($_ =~ /GimpUnit/)) {
my $enum = $enums{$_};
my $func = $_;
+ my $gegl_enum = ($func =~ /Gegl/);
- for ($func) { s/Gimp//; s/PDB/Pdb/; s/([A-Z][^A-Z]+)/\L$1\E_/g; s/_$// }
+ for ($func) { s/Gimp//; s/Gegl//; s/PDB/Pdb/;
+ s/([A-Z][^A-Z]+)/\L$1\E_/g; s/_$// }
print ENUMFILE ",\n" unless $first;
- print ENUMFILE " gimp_$func\_get_type";
+
+ if ($gegl_enum) {
+ print ENUMFILE " gegl_$func\_get_type";
+ } else {
+ print ENUMFILE " gimp_$func\_get_type";
+ }
$first = 0;
}
diff --git a/pdb/enumgen.pl b/pdb/enumgen.pl
index 6b6af04..6fe02e4 100755
--- a/pdb/enumgen.pl
+++ b/pdb/enumgen.pl
@@ -57,6 +57,14 @@ my $header = <<'HEADER';
:%enums = (
HEADER
+my $external;
+open my $EXTERNAL, "enums-external.pl";
+{
+ local $/;
+ $external = <$EXTERNAL>;
+}
+close $EXTERNAL;
+
my $footer = <<'FOOTER';
:);
:
@@ -255,6 +263,6 @@ foreach ($header, $code, $footer) { s/^://mg }
$outfile = "$builddir/pdb/enums.pl$FILE_EXT";
open OUTFILE, "> $outfile";
-print OUTFILE $header, $code, $footer;
+print OUTFILE $header, $external, $code, $footer;
close OUTFILE;
&write_file($outfile, "$destdir/pdb");
diff --git a/pdb/enums-external.pl b/pdb/enums-external.pl
new file mode 100644
index 0000000..de7ef87
--- /dev/null
+++ b/pdb/enums-external.pl
@@ -0,0 +1,10 @@
+ GeglDistanceMetric =>
+ { contig => 1,
+ external => 1,
+ symbols => [ qw(GEGL_DISTANCE_METRIC_EUCLIDEAN
+ GEGL_DISTANCE_METRIC_MANHATTAN
+ GEGL_DISTANCE_METRIC_CHEBYSHEV) ],
+ mapping => { GEGL_DISTANCE_METRIC_EUCLIDEAN => '0',
+ GEGL_DISTANCE_METRIC_MANHATTAN => '1',
+ GEGL_DISTANCE_METRIC_CHEBYSHEV => '2' }
+ },
diff --git a/pdb/enums.pl b/pdb/enums.pl
index 85075b9..3926580 100644
--- a/pdb/enums.pl
+++ b/pdb/enums.pl
@@ -19,6 +19,16 @@
package Gimp::CodeGen::enums;
%enums = (
+ GeglDistanceMetric =>
+ { contig => 1,
+ external => 1,
+ symbols => [ qw(GEGL_DISTANCE_METRIC_EUCLIDEAN
+ GEGL_DISTANCE_METRIC_MANHATTAN
+ GEGL_DISTANCE_METRIC_CHEBYSHEV) ],
+ mapping => { GEGL_DISTANCE_METRIC_EUCLIDEAN => '0',
+ GEGL_DISTANCE_METRIC_MANHATTAN => '1',
+ GEGL_DISTANCE_METRIC_CHEBYSHEV => '2' }
+ },
GimpAddMaskType =>
{ contig => 1,
header => 'libgimpbase/gimpbaseenums.h',
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]