From bad831ce41caa3b22bc12fce2d106963cdf9ecfd Mon Sep 17 00:00:00 2001 From: Manish Singh Date: Sat, 8 Feb 2003 19:47:48 +0000 Subject: [PATCH] use True and False if available. Ditch GIMP_ prefixes since we have real 2003-02-08 Manish Singh * tools/pdbgen/enumcode-py.pl: use True and False if available. Ditch GIMP_ prefixes since we have real namespaces in python. * tools/pdbgen/Makefile.am: generate python enums too * tools/pdbgen/enumcode.pl: cosmetic cleanup --- ChangeLog | 9 +++++++++ tools/pdbgen/.cvsignore | 1 + tools/pdbgen/Makefile.am | 10 +++++++++- tools/pdbgen/enumcode-py.pl | 12 ++++++++++-- tools/pdbgen/enumcode.pl | 3 +-- 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 77f37c1f79..d40c0ec118 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2003-02-08 Manish Singh + + * tools/pdbgen/enumcode-py.pl: use True and False if available. + Ditch GIMP_ prefixes since we have real namespaces in python. + + * tools/pdbgen/Makefile.am: generate python enums too + + * tools/pdbgen/enumcode.pl: cosmetic cleanup + 2003-02-08 Sven Neumann * libgimp/gimpmiscui.c (gimp_fixme_preview_fill): fixed diff --git a/tools/pdbgen/.cvsignore b/tools/pdbgen/.cvsignore index 6cb7642468..e7cf1a2ee1 100644 --- a/tools/pdbgen/.cvsignore +++ b/tools/pdbgen/.cvsignore @@ -4,3 +4,4 @@ stamp-enums stamp-groups stamp-pdbgen stamp-enum-code +stamp-enum-code-py diff --git a/tools/pdbgen/Makefile.am b/tools/pdbgen/Makefile.am index 33e305a581..ab8acf7ba6 100644 --- a/tools/pdbgen/Makefile.am +++ b/tools/pdbgen/Makefile.am @@ -110,4 +110,12 @@ stamp-enum-code: $(srcdir)/enumcode.pl enums.pl util.pl $(PERL) enumcode.pl \ && echo timestamp > $$rootme/stamp-enum-code -all-local: stamp-pdbgen stamp-enum-code +stamp-enum-code-py: $(srcdir)/enumcode-py.pl enums.pl util.pl + rootme=`pwd`; \ + destdir=`cd $(top_srcdir) && pwd`; export destdir; \ + cd $(srcdir) && \ + PDBGEN_BACKUP=$(PDBGEN_BACKUP) \ + $(PERL) enumcode-py.pl \ + && echo timestamp > $$rootme/stamp-enum-code-py + +all-local: stamp-pdbgen stamp-enum-code stamp-enum-code-py diff --git a/tools/pdbgen/enumcode-py.pl b/tools/pdbgen/enumcode-py.pl index 91c4d8acfa..c4967254ac 100755 --- a/tools/pdbgen/enumcode-py.pl +++ b/tools/pdbgen/enumcode-py.pl @@ -67,8 +67,15 @@ print ENUMFILE <<'GPL'; GPL print ENUMFILE <<'CODE'; -TRUE = 1 -FALSE = 0 +# TRUE and FALSE constants ... +import __builtin__ +if not hasattr(__builtin__, 'True'): + __builtin__.True = (1 == 1) + __builtin__.False = (1 != 1) +del __builtin__ + +FALSE = False +TRUE = True CODE foreach (sort keys %enums) { @@ -80,6 +87,7 @@ foreach (sort keys %enums) { my $sym = $symbol; # Maybe Python has nice enough namespace handling that we don't # need to prefix all constants with GIMP_ + $sym =~ s/^GIMP\_//; $body .= "$sym"; if (!$enum->{contig}) { $i = $enum->{mapping}->{$symbol}; diff --git a/tools/pdbgen/enumcode.pl b/tools/pdbgen/enumcode.pl index d7ea61c9c5..e4f2d0ff6c 100755 --- a/tools/pdbgen/enumcode.pl +++ b/tools/pdbgen/enumcode.pl @@ -124,6 +124,7 @@ HEADER foreach (sort keys %enums) { if (! ($enums{$_}->{header} =~ /libgimp/)) { print ENUMFILE "typedef enum\n{\n"; + my $enum = $enums{$_}; my $body = ""; foreach $symbol (@{$enum->{symbols}}) { my $sym = $symbol; @@ -153,5 +154,3 @@ HEADER close ENUMFILE; &write_file($enumfile); - -