[gimp-perl] Code/doc tidy-up - no substantive changes. Fixes bug #726082.
- From: Kevin Cozens <kcozens src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp-perl] Code/doc tidy-up - no substantive changes. Fixes bug #726082.
- Date: Wed, 26 Mar 2014 18:39:59 +0000 (UTC)
commit a3cc27fc5b175933f672e7f0f81c7ea7b25e5e3a
Author: Ed J <m8r-35s8eo mailinator com>
Date: Tue Mar 11 03:25:12 2014 +0000
Code/doc tidy-up - no substantive changes. Fixes bug #726082.
Gimp.pm | 167 ++++++++++---
Gimp.xs | 5 -
Gimp/Lib.pm | 4 +-
Gimp/Lib.xs | 696 ++++++++++++++++++++++++++---------------------------
Gimp/Pixel.pod | 5 +-
Net/Net.pm | 2 +-
Net/Net.xs | 23 +-
Perl-Server | 1 -
examples/pixelmap | 2 +-
9 files changed, 480 insertions(+), 425 deletions(-)
---
diff --git a/Gimp.pm b/Gimp.pm
index 2e0ece5..c4a274d 100644
--- a/Gimp.pm
+++ b/Gimp.pm
@@ -296,8 +296,8 @@ sub canonicalize_colour {
return [ loc_col];
} elsif
($_[0] =~ /^#([0-9a-fA-F]{2,2})([0-9a-fA-F]{2,2})([0-9a-fA-F]{2,2})$/) {
- # convert hex specfier of #xxyyzz
- return [ map { eval "0x$_/255.0" } ($1, $2, $3) ];
+ # convert hex specfier of #xxyyzz
+ return [ map { eval "0x$_/255.0" } ($1, $2, $3) ];
} else {
unless (%rgb_db) {
if ($rgb_db_path) {
@@ -330,7 +330,7 @@ $in_query=0 unless defined $in_query; # perl -w is SOOO braindamaged
$in_top=$in_quit=$in_run=$in_net=$in_init=0; # perl -w is braindamaged
($function)=$0=~/([^\/\\]+)$/;
-$verbose=0;
+$verbose=0 unless defined $verbose;
# $verbose=1;
$interface_type = "net";
@@ -684,13 +684,13 @@ package Gimp; # for __DATA__
1;
-=cut
-
=head1 NAME
-Gimp - a Perl extension for writing Gimp Extensions/Plug-ins/Load & Save-Handlers
+Gimp - a Perl extension for writing Gimp Extensions/Plug-ins/Load &
+Save-Handlers
-This is a release of gimp-perl for gimp-2.0. It is not compatible with version 1.2.x or below of The Gimp.
+This is a release of gimp-perl for gimp-2.8. It is not compatible with
+version 2.6 or below of The Gimp.
This is mostly a reference manual. For a quick intro, look at
L<Gimp::Fu>.
@@ -702,7 +702,8 @@ L<Gimp::Fu>.
=head2 IMPORT TAGS
-Place these in your C<use Gimp qw(...)> command to have added features available to your plug-in.
+Place these in your C<use Gimp qw(...)> command to have added features
+available to your plug-in.
=over 2
@@ -718,7 +719,8 @@ Import PARAM_* constants (PDB_INT32, PDB_STRING etc.) only.
=item :consts
-All constants from gimpenums.h (BG_IMAGE_FILL, RUN_NONINTERACTIVE, NORMAL_MODE, PDB_INT32 etc.).
+All constants from gimpenums.h (BG_IMAGE_FILL, RUN_NONINTERACTIVE,
+NORMAL_MODE, PDB_INT32 etc.).
=item spawn_options=I<options>
@@ -735,43 +737,92 @@ The default (unless '' is specified) is C<'main', ':consts', '__'>.
=head1 GETTING STARTED
-L<Gimp::Fu> is recommended for scripts not requiring custom interfaces or speciailized execution. Lots of
examples are in the C<examples/> directory of your gimp-perl source tree, or installed in your plug-ins
directory if you are running from a package.
+L<Gimp::Fu> is recommended for scripts not requiring custom interfaces
+or specialized execution. Lots of examples are in the C<examples/>
+directory of your gimp-perl source tree, or installed in your plug-ins
+directory if you are running from a package.
-Using the C<Xtns-E<gt>DB Browser> is a good way to learn The GIMP's Procedural Database(pdb). For
referencing functions you already know of, the included script gimpdoc is useful.
+Using the C<Xtns-E<gt>DB Browser> is a good way to learn The GIMP's
+Procedural Database(pdb). For referencing functions you already know of,
+the included script gimpdoc is useful.
=head1 DESCRIPTION
-Gimp-Perl is a module for writing plug-ins, extensions, standalone scripts, and file-handlers for The GNU
Image Manipulation Program (The GIMP). It can be used to automate repetitive tasks, acheive a precision hard
to get through manual use of The GIMP, interface to a web server, or other tasks that involve Gimp.
+Gimp-Perl is a module for writing plug-ins, extensions, standalone
+scripts, and file-handlers for The GNU Image Manipulation Program (The
+GIMP). It can be used to automate repetitive tasks, achieve a precision
+hard to get through manual use of The GIMP, interface to a web server,
+or other tasks that involve Gimp.
It is developed on Linux, and should work with similar OSes.
-Some hilights:
+Some highlights:
=over 2
=item *
-Access to The GIMP's Procedural Database (pdb) for manipulation of most objects.
+Access to The GIMP's Procedural Database (pdb) for manipulation of
+most objects.
=item *
-Use either a plain pdb (scheme-like) interface or an object-oriented syntax, i.e.
C<gimp_image_new(600,300,RGB)> is the same as C<new Image(600,300,RGB)>
+Use either a plain pdb (scheme-like) interface or an object-oriented
+syntax, i.e. C<gimp_image_new(600,300,RGB)> is the same as C<new
+Image(600,300,RGB)>
=item *
Networked plug-ins look/behave the same as those running from within gimp.
=item *
-Gimp::Fu will start The GIMP for you, if it cannot connect to an existing GIMP process.
+Gimp::Fu will start The GIMP for you, if it cannot connect to an existing
+GIMP process.
=item *
-You can access the pixel-data functions using piddles (see L<Gimp::PDL>) giving the same level of control as
a C plug-in, with a data language wrapper.
+You can access the pixel-data functions using piddles (see L<PDL>) giving
+the same level of control as a C plug-in, with a data language wrapper.
=item *
Over 50 example scripts to give you a good starting point, or use as is.
=back
+=head1 ARCHITECTURE
+
+There are two modes of operation: the perl is called by GIMP (as a
+plugin/filter), or GIMP is called by perl (which uses the Gimp::Net
+functionality).
+
+=head2 Plugin
+
+The perl script is written as a plug-in using C<Gimp::Fu> as described
+above. The architecture is simply that Gimp, on start-up, runs all
+its plug-ins at startup including all the perl scripts in its plugins
+directory. The perl scripts will register themselves as GIMP "procedures"
+in the PDB. When these procedures are called, typically from the menu
+system, the perl script will be run and supplied with the appropriate
+arguments.
+
+=head2 From outside GIMP
+
+The script will use C<Gimp> as above, and use Gimp functions as it
+wishes. Behind the scenes, GIMP has running a perl plugin (as described
+above) that is constantly running, and waits for connections from
+perl scripts. Your script, when it uses GIMP procedures (and Gimp-Perl
+functions), will actually be communicating with the perl server running
+under GIMP.
+
+The architecture may be visualised like this:
+
+ perlscript <-> Gimp::Net <-> Perl-Server <-> Gimp::Lib <-> GIMP
+
+This has certain consequences; native GIMP objects like images and layers
+obviously persist between Perl method calls, but C<libgimp> entities such
+as C<GimpDrawable>, with the perl interface C<Gimp::PixelRgn>, require
+special handling. Currently they do not work when used over C<Gimp::Net>.
+
=head1 OUTLINE OF A GIMP PLUG-IN
-All plug-ins (with the exception of those using C<Gimp::init>) I<must> contain a call to C<Gimp::main>.
+All plug-ins (with the exception of those using C<Gimp::init>) I<must>
+contain a call to C<Gimp::main>.
The return code should be immediately handed out to exit:
@@ -779,24 +830,32 @@ The return code should be immediately handed out to exit:
Before the call to C<Gimp::main>, I<no> other PDB function must be called.
-In a C<Gimp::Fu>-script, it will actually call C<Gimp::Fu::main> instead of C<Gimp::main>:
+In a C<Gimp::Fu>-script, it will actually call C<Gimp::Fu::main> instead
+of C<Gimp::main>:
exit main; # Gimp::Fu::main is exported by default when using Gimp::Fu
This is similar to Gtk, Tk or similar modules, where you have to call the
main eventloop.
-Although you call C<exit> with the result of C<main>, the main function might not actually return. This
depends on both the version of Gimp and the version of the Gimp-Perl module that is in use. Do not depend on
C<main> to return at all, but still call C<exit> immediately.
+Although you call C<exit> with the result of C<main>, the main function
+might not actually return. This depends on both the version of Gimp and
+the version of the Gimp-Perl module that is in use. Do not depend on
+C<main> to return at all, but still call C<exit> immediately.
=head2 CALLBACKS
-The Gimp module provides routines to be optionally filled in by a plug-in writer. This does not apply if
using C<Gimp::Fu>, as these are done automatically.
+The Gimp module provides routines to be optionally filled in by a
+plug-in writer. This does not apply if using C<Gimp::Fu>, as these are
+done automatically.
=over 2
=item Gimp::on_query
-Do any activities that must be performed at Gimp startup, when the procedure is queried. Should typically
have at least one call to gimp_install_procedure.
+Do any activities that must be performed at Gimp startup, when the
+procedure is queried. Should typically have at least one call to
+gimp_install_procedure.
=item Gimp::on_net
@@ -844,7 +903,11 @@ syntax, so its actually shorter to write and hopefully clearer to read.
=head1 SPECIAL FUNCTIONS
-In this section, you can find descriptions of special functions, functions having different calling
conventions/semantics than might be expected or otherwise interesting functions. All of these functions must
either be imported explicitly or called using a namespace override (C<Gimp::>), not as Methods
(C<Gimp-E<gt>>).
+In this section, you can find descriptions of special functions, functions
+having different calling conventions/semantics than might be expected
+or otherwise interesting functions. All of these functions must either
+be imported explicitly or called using a namespace override (C<Gimp::>),
+not as Methods (C<Gimp-E<gt>>).
=over 4
@@ -926,7 +989,6 @@ between 0 and 1.0.
For example:
-
$color = canonicalize_colour ("#ff00bb");
$color = canonicalize_colour ([255,255,34]);
$color = canonicalize_colour ([255,255,34,255]);
@@ -939,7 +1001,7 @@ Note that bounds checking is excessively lax; this assumes relatively good input
=head1 SPECIAL METHODS
-This chapter descibes methods that behave differently than you might
+This chapter describes methods that behave differently than you might
expect, or methods uniquely implemented in perl (that is, not in the
PDB). All of these must be invoked using the method syntax (C<Gimp-E<gt>>
or C<$object-E<gt>>).
@@ -948,7 +1010,10 @@ or C<$object-E<gt>>).
=item gimp_install_procedure(name, blurb, help, author, copyright, date, menu_path, image_types, type,
[params], [return_vals])
-Mostly same as gimp_install_procedure from the C library. The parameters and return values for the functions
are specified as an array ref containing either integers or array-refs with three elements, [PARAM_TYPE,
\"NAME\", \"DESCRIPTION\"].
+Mostly same as gimp_install_procedure from the C library. The
+parameters and return values for the functions are specified as an
+array ref containing either integers or array-refs with three elements,
+[PARAM_TYPE, \"NAME\", \"DESCRIPTION\"].
=item gimp_progress_init(message,[])
@@ -1002,17 +1067,19 @@ reported as runtime errors (i.e. throwing an exception).
=head1 OBJECT ORIENTED SYNTAX
-In this manual, only the plain syntax (that lesser languages like C use) is
-described. See L<Gimp::OO> for details on using the object oritented syntax. The 'gimpdoc' script will also
return OO varients when functions are described. For example:
+In this manual, only the plain syntax (that lesser languages like C use)
+is described. See L<Gimp::OO> for details on using the object oriented
+syntax. The 'gimpdoc' script will also return OO varients when functions
+are described. For example:
gimpdoc image_new
has a section:
SOME SYNTAX ALTERNATIVES
- image = Gimp->image_new (width,height,type)
- image = new Image (width,height,type)
- image = image_new Display (width,height,type)
+ $image = Gimp->image_new (width,height,type)
+ $image = new Image (width,height,type)
+ $image = image_new Display (width,height,type)
=head1 DEBUGGING AIDS
@@ -1020,6 +1087,13 @@ How to debug your scripts:
=over 4
+=item $Gimp::verbose
+
+If set to true, will make Gimp say what it's doing on STDOUT. It will
+also stop L<Gimp::Net>'s normal behaviour of the server-side closing
+STDIN, STDOUT and STDERR. If you want it to be set during loading Gimp.pm,
+make sure to do so in a C<BEGIN> block.
+
=item Gimp::set_trace (tracemask)
Tracking down bugs in gimp scripts is difficult, due to a lack of
@@ -1074,6 +1148,17 @@ invocation.
write trace to FILEHANDLE instead of STDERR.
+=item GLib debugging
+
+GIMP makes use of GLib. Environment variables including
+C<G_DEBUG>, and setting C<G_SLICE> to
+C<always-malloc>, control some behaviour. See
+L<https://developer.gnome.org/glib/unstable/glib-running.html>
+for details. Additionally, the behaviour of C<malloc> can
+be controlled with other environment variables as shown at
+L<http://man7.org/linux/man-pages/man3/mallopt.3.html>, especially
+setting C<MALLOC_CHECK_> (note trailing underscore) to 3.
+
=back
=head1 SUPPORTED GIMP DATA TYPES
@@ -1088,7 +1173,7 @@ perl, these are represented as:
normal perl scalars. Anything except STRING will be mapped
to a perl-double.
-=item INT32ARRAY, INT16ARRAY, INT8ARRAY, FLOATARRAY, STRINGARRAY
+=item INT32ARRAY, INT16ARRAY, INT8ARRAY, FLOATARRAY, STRINGARRAY, COLORARRAY
array refs containing scalars of the same type, i.e. [1, 2, 3, 4]. Gimp
implicitly swallows or generates a preceeding integer argument because the
@@ -1097,16 +1182,19 @@ of elements.
=item COLOR
-on input, either an array ref with 3 or 4 elements (i.e. [0.1,0.4,0.9] or [233,40,40]), a X11-like string
("#rrggbb") or a colour name ("papayawhip") (see set_rgb_db).
+on input, either an array ref with 3 or 4 elements (i.e. [0.1,0.4,0.9]
+or [233,40,40]), a X11-like string ("#rrggbb") or a colour name
+("papayawhip") (see set_rgb_db).
-=item DISPLAY, IMAGE, LAYER, CHANNEL, DRAWABLE, SELECTION
+=item DISPLAY, IMAGE, LAYER, CHANNEL, DRAWABLE, SELECTION, VECTORS
-these will be mapped to corresponding objects (IMAGE => Gimp::Image). In trace
-output you will see small integers (the image/layer/etc..-ID)
+these will be mapped to corresponding objects (IMAGE => Gimp::Image). In
+trace output you will see small integers (the image/layer/etc..-ID)
=item PARASITE
-represented as an array ref [name, flags, data], where name and data should be perl strings and flags is the
numerical flag value.
+represented as an array ref [name, flags, data], where name and data
+should be perl strings and flags is the numerical flag value.
=item REGION, BOUNDARY, PATH, STATUS
@@ -1120,9 +1208,12 @@ Marc Lehmann <pcg goof com> (pre-2.0)
Seth Burgess <sjburge gimp org> (2.0+)
+Ed J (with oversight and guidance from Kevin Cozens) (2.3+)
+
=head1 SEE ALSO
-perl(1), gimp(1), L<Gimp::OO>, L<Gimp::Data>, L<Gimp::Pixel>, L<Gimp::PDL>, L<Gimp::Util>, L<Gimp::UI>,
L<Gimp::Feature>, L<Gimp::Net>,
+perl(1), gimp(1), L<Gimp::OO>, L<Gimp::Data>, L<Gimp::Pixel>,
+L<Gimp::Util>, L<Gimp::UI>, L<Gimp::Feature>, L<Gimp::Net>,
L<Gimp::Compat>, L<Gimp::Config>, L<Gimp::Lib>, and L<Gimp::Module> .
=cut
diff --git a/Gimp.xs b/Gimp.xs
index 50a3bef..7fe87c0 100644
--- a/Gimp.xs
+++ b/Gimp.xs
@@ -5,11 +5,6 @@
#include <locale.h>
-/* FIXME */
-/* sys/param.h is redefining these! */
-#undef MIN
-#undef MAX
-
/* dunno where this comes from */
#undef VOIDUSED
diff --git a/Gimp/Lib.pm b/Gimp/Lib.pm
index e645555..3e5861a 100644
--- a/Gimp/Lib.pm
+++ b/Gimp/Lib.pm
@@ -20,7 +20,7 @@ sub gimp_init {
}
sub gimp_end {
- Gimp::croak Gimp::_("gimp_end not implemented for in the Lib interface");
+ Gimp::croak Gimp::_("gimp_end not implemented for the Lib interface");
}
sub lock {
@@ -60,7 +60,7 @@ sub _gimp_append_data($$) {
gimp_set_data ($_[0], gimp_get_data ($_[0]) . $_[1]);
}
-# convinience functions
+# convenience functions
sub gimp_drawable_pixel_rgn($$$$$$) {
Gimp::gimp_pixel_rgn_init(@_);
}
diff --git a/Gimp/Lib.xs b/Gimp/Lib.xs
index 93c23eb..851ed6d 100644
--- a/Gimp/Lib.xs
+++ b/Gimp/Lib.xs
@@ -5,11 +5,6 @@
#include <libgimp/gimp.h>
-/* FIXME */
-/* sys/param.h is redefining these! */
-#undef MIN
-#undef MAX
-
#if HAVE_PDL
#define PDL_clean_namespace
#include <pdlcore.h>
@@ -18,9 +13,6 @@
/* various functions allocate static buffers, STILL. */
#define MAX_STRING 4096
-/* dunno where this comes from */
-#undef VOIDUSED
-
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
@@ -64,26 +56,19 @@ static int trace = TRACE_NONE;
typedef GimpPixelRgn GimpPixelRgn_PDL;
-/* hack, undocumented, argh! */
static Core* PDL; /* Structure hold core C functions */
/* get pointer to PDL structure. */
static void need_pdl (void)
{
SV *CoreSV;
-
- if (!PDL)
- {
- /* the perl-server can't be bothered to do this itself! */
- perl_require_pv ("PDL::Core");
-
- /* Get pointer to structure of core shared C routines */
- CoreSV = perl_get_sv("PDL::SHARE", FALSE);
- if (!CoreSV)
- croak("gimp-perl-pixel functions require the PDL::Core module, which was not found");
-
- PDL = (Core*) SvIV(CoreSV);
- }
+ if (!PDL) {
+ require_pv("PDL/Core.pm");
+ CoreSV = get_sv("PDL::SHARE", FALSE);
+ if (CoreSV == NULL)
+ croak("gimp-perl-pixel functions require PDL::Core module - failed");
+ PDL = INT2PTR(Core*,SvIV( CoreSV ));
+ }
}
static pdl *new_pdl (int a, int b, int c)
@@ -141,7 +126,7 @@ static pdl *redim_pdl (pdl *p, int ndim, int newsize)
sv_setiv (*av_fetch (dims, ndim, 0), newsize);
- PDL->affine_new (p, r, 0,
+ PDL->affine_new (p, r, 0,
sv_2mortal (newRV_noinc ((SV*)dims)),
sv_2mortal (newRV_noinc ((SV*)dimincs)));
@@ -150,7 +135,7 @@ static pdl *redim_pdl (pdl *p, int ndim, int newsize)
#endif
-/* set when its safe to call gimp functions. */
+/* set when it's safe to call gimp functions. */
static int gimp_is_initialized = 0;
typedef gint32 IMAGE;
@@ -163,15 +148,64 @@ typedef gint32 ITEM;
typedef gint32 COLOR;
typedef gpointer GimpPixelRgnIterator;
+/* tracing stuff. put at top so immediately available! */
+static SV *trace_var = 0;
+static PerlIO *trace_file = 0; /* FIXME: unportable. */
+
+static void
+trace_init ()
+{
+ if (!trace_file)
+ SvCUR_set (trace_var, 0);
+}
+
+#ifndef __STDC__
+#error You need to compile with an ansi-c compiler!!!
+#error Remove these lines to continue at your own risk!
+#endif
+
+#if __STDC_VERSION__ > 199900
+#define trace_printf(...) \
+ do { \
+ if (trace_file) PerlIO_printf (trace_file, __VA_ARGS__); \
+ else sv_catpvf (trace_var, __VA_ARGS__); \
+ } while(0)
+#elif __GNUC__
+#define trace_printf(frmt,args...) \
+ do { \
+ if (trace_file) PerlIO_printf (trace_file, frmt, ## args); \
+ else sv_catpvf (trace_var, frmt, ## args); \
+ } while(0)
+#elif defined(__STDC__)
+
+/* sigh */
+#include <stdarg.h>
+static void trace_printf (char *frmt, ...)
+{
+ va_list args;
+ char buffer[MAX_STRING]; /* sorry... */
+
+ va_start (args, frmt);
+#ifdef HAVE_VSNPRINTF
+ vsnprintf (buffer, sizeof buffer, frmt, args);
+#else
+ vsprintf (buffer, frmt, args);
+#endif
+ if (trace_file) PerlIO_printf (trace_file, "%s", buffer);
+ else sv_catpv (trace_var, buffer);
+}
+
+#endif
+
/* new SV with len len. There _must_ be a better way, but newSV doesn't work. */
static SV *newSVn (STRLEN len)
{
SV *sv = newSVpv ("", 0);
-
+
(void) SvUPGRADE (sv, SVt_PV);
SvGROW (sv, len);
SvCUR_set (sv, len);
-
+
return sv;
}
@@ -194,31 +228,30 @@ static SV *new_gdrawable (gint32 id)
{
static HV *stash;
SV *sv;
-
+
if (!gdrawable_cache)
gdrawable_cache = g_hash_table_new (g_direct_hash, g_direct_equal);
assert (sizeof (gpointer) >= sizeof (id));
- if ((sv = (SV*)g_hash_table_lookup (gdrawable_cache, GINT_TO_POINTER(id))))
+ if ((sv = (SV*)g_hash_table_lookup (gdrawable_cache, GINT_TO_POINTER(id)))) {
SvREFCNT_inc (sv);
- else
- {
- GimpDrawable *gdr = gimp_drawable_get (id);
+ } else {
+ GimpDrawable *gdr = gimp_drawable_get (id);
- if (!gdr)
- croak (__("unable to convert Gimp::Drawable into Gimp::GimpDrawable (id %d)"), id);
+ if (!gdr)
+ croak (__("unable to convert Gimp::Drawable into Gimp::GimpDrawable (id %d)"), id);
- if (!stash)
- stash = gv_stashpv (PKG_GDRAWABLE, 1);
+ if (!stash)
+ stash = gv_stashpv (PKG_GDRAWABLE, 1);
- sv = newSViv ((IV) gdr);
- sv_magic (sv, 0, '~', 0, 0);
- mg_find (sv, '~')->mg_virtual = &vtbl_gdrawable;
+ sv = newSViv ((IV) gdr);
+ sv_magic (sv, 0, '~', 0, 0);
+ mg_find (sv, '~')->mg_virtual = &vtbl_gdrawable;
+
+ g_hash_table_insert (gdrawable_cache, GINT_TO_POINTER(id), (void *)sv);
+ }
- g_hash_table_insert (gdrawable_cache, GINT_TO_POINTER(id), (void *)sv);
- }
-
return sv_bless (newRV_noinc (sv), stash);
}
@@ -236,12 +269,12 @@ SV *new_tile (GimpTile *tile, SV *gdrawable)
{
static HV *stash;
HV *hv = newHV ();
-
- hv_store (hv, "_gdrawable" ,10, SvREFCNT_inc (gdrawable) , 0);
-
+
+ (void)hv_store (hv, "_gdrawable",10, SvREFCNT_inc (gdrawable), 0);
+
if (!stash)
stash = gv_stashpv (PKG_TILE, 1);
-
+
return sv_bless (newRV_noinc ((SV*)hv), stash);
}
@@ -249,7 +282,7 @@ static GimpTile *old_tile (SV *sv)
{
if (!sv_derived_from (sv, PKG_TILE))
croak (__("argument is not of type %s"), PKG_TILE);
-
+
/* the next line lacks any type of checking. */
return (GimpTile *)SvIV(*(hv_fetch ((HV*)SvRV(sv), "_tile", 5, 0)));
}
@@ -291,9 +324,9 @@ static SV *new_gpixelrgn (SV *gdrawable, int x, int y, int width, int height, in
if (!stash)
stash = gv_stashpv (PKG_PIXELRGN, 1);
-
- gimp_pixel_rgn_init (pr, old_gdrawable (gdrawable),
- x, y, width, height, dirty, shadow);
+
+ GimpDrawable *gd = old_gdrawable(gdrawable);
+ gimp_pixel_rgn_init (pr, gd, x, y, width, height, dirty, shadow);
sv_magic (sv, SvRV(gdrawable), '~', 0, 0);
mg_find (sv, '~')->mg_virtual = &vtbl_gpixelrgn;
@@ -305,7 +338,7 @@ static GimpPixelRgn *old_pixelrgn (SV *sv)
{
if (!sv_derived_from (sv, PKG_PIXELRGN))
croak (__("argument is not of type %s"), PKG_PIXELRGN);
-
+
return (GimpPixelRgn *)SvPV_nolen(SvRV(sv));
}
@@ -317,55 +350,6 @@ static GimpPixelRgn *old_pixelrgn_pdl (SV *sv)
return old_pixelrgn (sv);
}
-/* tracing stuff. */
-static SV *trace_var = 0;
-static PerlIO *trace_file = 0; /* FIXME: unportable. */
-
-static void
-trace_init ()
-{
- if (!trace_file)
- SvCUR_set (trace_var, 0);
-}
-
-#ifndef __STDC__
-#error You need to compile with an ansi-c compiler!!!
-#error Remove these lines to continue at your own risk!
-#endif
-
-#if __STDC_VERSION__ > 199900
-#define trace_printf(...) \
- do { \
- if (trace_file) PerlIO_printf (trace_file, __VA_ARGS__); \
- else sv_catpvf (trace_var, __VA_ARGS__); \
- } while(0)
-#elif __GNUC__
-#define trace_printf(frmt,args...) \
- do { \
- if (trace_file) PerlIO_printf (trace_file, frmt, ## args); \
- else sv_catpvf (trace_var, frmt, ## args); \
- } while(0)
-#elif defined(__STDC__)
-
-/* sigh */
-#include <stdarg.h>
-static void trace_printf (char *frmt, ...)
-{
- va_list args;
- char buffer[MAX_STRING]; /* sorry... */
-
- va_start (args, frmt);
-#ifdef HAVE_VSNPRINTF
- vsnprintf (buffer, sizeof buffer, frmt, args);
-#else
- vsprintf (buffer, frmt, args);
-#endif
- if (trace_file) PerlIO_printf (trace_file, "%s", buffer);
- else sv_catpv (trace_var, buffer);
-}
-
-#endif
-
static int
is_array (GimpPDBArgType typ)
{
@@ -381,11 +365,11 @@ static int
perl_param_count (const GimpParam *arg, int count)
{
const GimpParam *end = arg + count;
-
+
while (arg < end)
if (is_array (arg++->type))
count--;
-
+
return count;
}
@@ -396,11 +380,11 @@ static int
perl_paramdef_count (GimpParamDef *arg, int count)
{
GimpParamDef *end = arg + count;
-
+
while (arg < end)
if (is_array (arg++->type))
count--;
-
+
return count;
}
@@ -431,12 +415,12 @@ dump_params (int nparams, GimpParam *args, GimpParamDef *params)
"STATUS" , "END"
};
int i;
-
+
trace_printf ("(");
-
+
if ((trace & TRACE_DESC) == TRACE_DESC)
trace_printf ("\n\t");
-
+
for (i = 0; i < nparams; i++)
{
if ((trace & TRACE_TYPE) == TRACE_TYPE)
@@ -446,10 +430,10 @@ dump_params (int nparams, GimpParam *args, GimpParamDef *params)
else
trace_printf ("T%d ", params[i].type);
}
-
+
if ((trace & TRACE_NAME) == TRACE_NAME)
trace_printf ("%s=", params[i].name);
-
+
switch (args[i].type)
{
case GIMP_PDB_INT32: trace_printf ("%d", args[i].data.d_int32); break;
@@ -465,7 +449,7 @@ dump_params (int nparams, GimpParam *args, GimpParamDef *params)
case GIMP_PDB_SELECTION: trace_printf ("%d", args[i].data.d_selection); break;
case GIMP_PDB_COLORARRAY:
{
- int j;
+ int j;
trace_printf ("[");
if (args[i].data.d_colorarray || !args[i-1].data.d_int32) {
for (j = 0; j < args[i-1].data.d_int32; j++)
@@ -489,7 +473,7 @@ dump_params (int nparams, GimpParam *args, GimpParamDef *params)
case GIMP_PDB_INT8ARRAY: dump_printarray (args, i, guint8, d_int8array , "%d"); break;
case GIMP_PDB_FLOATARRAY: dump_printarray (args, i, gfloat, d_floatarray, "%f"); break;
case GIMP_PDB_STRINGARRAY: dump_printarray (args, i, char* , d_stringarray, "'%s'"); break;
-
+
case GIMP_PDB_COLOR:
trace_printf ("[%f,%f,%f,%f]",
args[i].data.d_color.r,
@@ -510,32 +494,32 @@ dump_params (int nparams, GimpParam *args, GimpParamDef *params)
trace_printf ("GIMP_PARASITE_PERSISTENT");
found |= GIMP_PARASITE_PERSISTENT;
}
-
+
if (args[i].data.d_parasite.flags & ~found)
{
if (found)
trace_printf ("|");
trace_printf ("%d", args[i].data.d_parasite.flags & ~found);
}
-
+
trace_printf (__(", %d bytes data]"), args[i].data.d_parasite.size);
}
else
trace_printf (__("[undefined]"));
}
break;
-
+
default:
trace_printf ("(?%d?)", args[i].type);
}
-
+
if ((trace & TRACE_DESC) == TRACE_DESC)
trace_printf ("\t\"%s\"\n\t", params[i].description);
else if (i < nparams - 1)
trace_printf (", ");
-
+
}
-
+
trace_printf (")");
}
@@ -544,12 +528,12 @@ convert_array2paramdef (AV *av, GimpParamDef **res)
{
int count = 0;
GimpParamDef *def = 0;
-
+
if (av_len (av) >= 0)
for(;;)
{
int idx;
-
+
for (idx = 0; idx <= av_len (av); idx++)
{
SV *sv = *av_fetch (av, idx, 0);
@@ -561,7 +545,7 @@ convert_array2paramdef (AV *av, GimpParamDef **res)
{
AV *av = (AV *)SvRV(sv);
SV **x;
-
+
if ((x = av_fetch (av, 0, 0))) type = *x;
if ((x = av_fetch (av, 1, 0))) name = *x;
if ((x = av_fetch (av, 2, 0))) help = *x;
@@ -580,7 +564,7 @@ convert_array2paramdef (AV *av, GimpParamDef **res)
def->description = "the size of the following array";
def++;
}
-
+
def->type = SvIV (type);
def->name = name ? SvPV_nolen (name) : 0;
def->description = help ? SvPV_nolen (help) : 0;
@@ -592,15 +576,15 @@ convert_array2paramdef (AV *av, GimpParamDef **res)
else
croak (__("malformed paramdef, expected [PARAM_TYPE,\"NAME\",\"DESCRIPTION\"] or PARAM_TYPE"));
}
-
+
if (def)
break;
-
+
*res = def = g_new (GimpParamDef, count);
}
else
*res = 0;
-
+
return count;
}
@@ -654,26 +638,26 @@ param_stash (GimpPDBArgType type)
PKG_PARASITE,
0
};
-
+
if (bless [type] && !bless_hv [type])
bless_hv [type] = gv_stashpv (bless [type], 1);
-
+
return bless_hv [type];
}
-
+
/* automatically bless SV into PARAM_type. */
/* for what it's worth, we cache the stashes. */
static SV *
autobless (SV *sv, int type)
{
HV *stash = param_stash (type);
-
+
if (stash)
sv = sv_bless (newRV_noinc (sv), stash);
if (stash && !SvOBJECT(SvRV(sv)))
croak ("jupp\n");
-
+
return sv;
}
@@ -681,19 +665,15 @@ autobless (SV *sv, int type)
static gint32
unbless (SV *sv, char *type, char *croak_str)
{
- if (sv_isobject (sv))
- if (type == PKG_ANY || sv_derived_from (sv, type))
- {
- if (SvTYPE (SvRV (sv)) == SVt_PVMG)
- return SvIV (SvRV (sv));
- else
- strcpy (croak_str, __("only blessed scalars accepted here"));
- }
+ if (!sv_isobject (sv)) return SvIV (sv);
+ if (type == PKG_ANY || sv_derived_from (sv, type)) {
+ if (SvTYPE (SvRV (sv)) == SVt_PVMG)
+ return SvIV (SvRV (sv));
else
- sprintf (croak_str, __("argument type %s expected (not %s)"), type, HvNAME(SvSTASH(SvRV(sv))));
- else
- return SvIV (sv);
-
+ strcpy (croak_str, __("only blessed scalars accepted here"));
+ } else
+ sprintf (croak_str, __("argument type %s expected (not %s)"), type, HvNAME(SvSTASH(SvRV(sv))));
+
return -1;
}
@@ -708,7 +688,7 @@ unbless_croak (SV *sv, char *type)
if (croak_str [0])
croak (croak_str);
-
+
return r;
}
@@ -716,19 +696,19 @@ static void
canonicalize_colour (char *err, SV *sv, GimpRGB *c)
{
dSP;
-
+
ENTER;
SAVETMPS;
-
+
PUSHMARK(SP);
XPUSHs (sv);
PUTBACK;
-
+
if (perl_call_pv ("Gimp::canonicalize_colour", G_SCALAR) != 1)
croak (__("FATAL: canonicalize_colour did not return a value!"));
-
+
SPAGAIN;
-
+
sv = POPs;
if (SvROK(sv))
{
@@ -752,7 +732,7 @@ canonicalize_colour (char *err, SV *sv, GimpRGB *c)
}
else
sprintf (err, __("unable to grok colour specification"));
-
+
PUTBACK;
FREETMPS;
LEAVE;
@@ -822,7 +802,7 @@ push_gimp_sv (const GimpParam *arg, int array_as_ref)
{
dSP;
SV *sv = 0;
-
+
switch (arg->type)
{
case GIMP_PDB_INT32: sv = newSViv(arg->data.d_int32 ); break;
@@ -830,19 +810,19 @@ push_gimp_sv (const GimpParam *arg, int array_as_ref)
case GIMP_PDB_INT8: sv = newSVu8(arg->data.d_int8 ); break;
case GIMP_PDB_FLOAT: sv = newSVnv(arg->data.d_float ); break;
case GIMP_PDB_STRING: sv = neuSVpv(arg->data.d_string ); break;
-
+
case GIMP_PDB_DISPLAY:
- case GIMP_PDB_IMAGE:
- case GIMP_PDB_LAYER:
+ case GIMP_PDB_IMAGE:
+ case GIMP_PDB_LAYER:
case GIMP_PDB_CHANNEL:
case GIMP_PDB_DRAWABLE:
case GIMP_PDB_SELECTION:
- case GIMP_PDB_VECTORS:
+ case GIMP_PDB_VECTORS:
case GIMP_PDB_STATUS:
-
+
{
int id;
-
+
switch (arg->type) {
case GIMP_PDB_DISPLAY: id = arg->data.d_display; break;
case GIMP_PDB_IMAGE: id = arg->data.d_image; break;
@@ -894,7 +874,7 @@ push_gimp_sv (const GimpParam *arg, int array_as_ref)
case GIMP_PDB_INT8ARRAY: push_gimp_av (arg, d_int8array , newSVu8, array_as_ref); break;
case GIMP_PDB_FLOATARRAY: push_gimp_av (arg, d_floatarray , newSVnv, array_as_ref);
break;
case GIMP_PDB_STRINGARRAY: push_gimp_av (arg, d_stringarray, neuSVpv, array_as_ref); break;
- case GIMP_PDB_COLORARRAY:
+ case GIMP_PDB_COLORARRAY:
{
int j;
AV *av;
@@ -922,10 +902,10 @@ push_gimp_sv (const GimpParam *arg, int array_as_ref)
default:
croak (__("dunno how to return param type %d"), arg->type);
}
-
+
if (sv)
PUSHs (sv_2mortal (autobless (sv, arg->type)));
-
+
PUTBACK;
}
@@ -962,10 +942,10 @@ static int
convert_sv2gimp (char *croak_str, GimpParam *arg, SV *sv)
{
switch (arg->type)
- {
+ {
/* Note that the sv2gimp_extract_noref includes a break;, so no fall throughs occur */
case GIMP_PDB_INT32: check_int (croak_str, sv);
- arg->data.d_int32 = SvIV(sv);
+ arg->data.d_int32 = SvIV(sv);
arg->data.d_int32 = sv2gimp_extract_noref (SvIV, "INT32");
case GIMP_PDB_INT16: arg->data.d_int16 = sv2gimp_extract_noref (SvIV, "INT16");
case GIMP_PDB_INT8: arg->data.d_int8 = sv2gimp_extract_noref (SvIV, "INT8");
@@ -1020,9 +1000,9 @@ convert_sv2gimp (char *croak_str, GimpParam *arg, SV *sv)
case GIMP_PDB_IMAGE: arg->data.d_image = -1; return 0; break;
default: abort ();
}
-
+
break;
-
+
case GIMP_PDB_COLOR:
canonicalize_colour (croak_str, sv, &arg->data.d_color);
break;
@@ -1051,9 +1031,9 @@ convert_sv2gimp (char *croak_str, GimpParam *arg, SV *sv)
}
else
sprintf (croak_str, __("illegal parasite specification, reference expected"));
-
+
break;
-
+
case GIMP_PDB_INT32ARRAY: av2gimp (arg, sv, d_int32array , gint32 , Sv32); break;
case GIMP_PDB_INT16ARRAY: av2gimp (arg, sv, d_int16array , gint16 , SvIV); break;
case GIMP_PDB_INT8ARRAY: av2gimp (arg, sv, d_int8array , guint8 , SvIV); break;
@@ -1069,7 +1049,7 @@ convert_sv2gimp (char *croak_str, GimpParam *arg, SV *sv)
for (i = 0; i <= av_len (av); i++)
canonicalize_colour (
croak_str,
- *av_fetch (av, i, 0),
+ *av_fetch (av, i, 0),
&arg->data.d_colorarray[i]
);
} else {
@@ -1077,7 +1057,7 @@ convert_sv2gimp (char *croak_str, GimpParam *arg, SV *sv)
arg->data.d_colorarray = 0;
}
break;
-
+
default:
croak (
__("tried to convert '%s' to unknown type %d"),
@@ -1085,7 +1065,7 @@ convert_sv2gimp (char *croak_str, GimpParam *arg, SV *sv)
arg->type
);
}
-
+
return 1;
}
@@ -1094,7 +1074,7 @@ static void
destroy_params (GimpParam *arg, int count)
{
int i;
-
+
for (i = 0; i < count; i++)
switch (arg[i].type)
{
@@ -1103,10 +1083,10 @@ destroy_params (GimpParam *arg, int count)
case GIMP_PDB_INT8ARRAY: g_free (arg[i].data.d_int8array); break;
case GIMP_PDB_FLOATARRAY: g_free (arg[i].data.d_floatarray); break;
case GIMP_PDB_STRINGARRAY: g_free (arg[i].data.d_stringarray); break;
-
+
default: ;
}
-
+
g_free (arg);
}
@@ -1143,12 +1123,12 @@ static void pii_run(const gchar *name,
{
static GimpParam *return_vals;
static int nreturn_vals;
-
+
dSP;
int i, count;
char *err_msg = 0;
-
+
char *proc_blurb;
char *proc_help;
char *proc_author;
@@ -1175,13 +1155,13 @@ static void pii_run(const gchar *name,
g_free (proc_copyright);
g_free (proc_date);
gimp_destroy_paramdefs (params, _nparams);
-
+
PUSHMARK(SP);
EXTEND (SP, 3);
PUSHs (sv_2mortal (newSVpv ("-run", 4)));
PUSHs (sv_2mortal (newSVpv (name, 0)));
-
+
if (nparams)
{
EXTEND (SP, perl_param_count (param, nparams));
@@ -1190,19 +1170,19 @@ static void pii_run(const gchar *name,
{
if (i < nparams-1 && is_array (param[i+1].type))
i++;
-
+
push_gimp_sv (param+i, nparams > 2);
}
-
+
SPAGAIN;
}
else
PUTBACK;
-
+
count = perl_call_pv ("Gimp::callback", G_EVAL
| (nreturn_vals == 0 ? G_VOID : nreturn_vals == 1 ? G_SCALAR : G_ARRAY));
SPAGAIN;
-
+
if (SvTRUE (ERRSV))
{
if (strEQ ("IGNORE THIS MESSAGE\n", SvPV_nolen (ERRSV)))
@@ -1222,7 +1202,7 @@ static void pii_run(const gchar *name,
int i;
char errmsg [MAX_STRING];
errmsg [0] = 0;
-
+
return_vals = (GimpParam *) g_new0 (GimpParam, nreturn_vals+1);
return_vals->type = GIMP_PDB_STATUS;
return_vals->data.d_status = GIMP_PDB_SUCCESS;
@@ -1238,33 +1218,33 @@ static void pii_run(const gchar *name,
--count;
(void) POPs;
}
-
+
if (errmsg [0])
{
err_msg = g_strdup (errmsg);
break;
}
}
-
+
if (count && !err_msg)
err_msg = g_strdup_printf (__("plug-in returned %d more values than expected"), count);
}
-
+
gimp_destroy_paramdefs (return_defs, nreturn_vals);
-
+
PUTBACK;
}
else
err_msg = g_strdup_printf (__("being called as '%s', but '%s' not registered in the pdb"), name, name);
-
+
if (err_msg)
{
gimp_die_msg (err_msg);
g_free (err_msg);
-
+
if (return_vals)
destroy_params (*xreturn_vals, nreturn_vals+1);
-
+
nreturn_vals = 0;
return_vals = g_new (GimpParam, 1);
return_vals->type = GIMP_PDB_STATUS;
@@ -1292,14 +1272,14 @@ set_trace (var)
CODE:
{
SV *sv = ST (0);
-
+
RETVAL = trace;
-
+
if (SvROK (sv) || SvTYPE (sv) == SVt_PVGV)
{
if (trace_var)
SvREFCNT_dec (trace_var), trace_var = 0;
-
+
if (SvTYPE (sv) == SVt_PVGV) /* pray it's a filehandle! */
trace_file = IoOFP (GvIO (sv));
else
@@ -1333,18 +1313,18 @@ gimp_main(...)
PREINIT:
CODE:
SV *sv;
-
+
if ((sv = perl_get_sv ("Gimp::help", FALSE)) && SvTRUE (sv))
RETVAL = 0;
else
{
char *argv [10];
int argc = 0;
-
+
if (items == 0)
{
AV *av = perl_get_av ("ARGV", FALSE);
-
+
argv [argc++] = SvPV_nolen (perl_get_sv ("0", FALSE));
if (av && av_len (av) < 10-1)
{
@@ -1357,7 +1337,7 @@ gimp_main(...)
}
else
croak (__("arguments to main not yet supported!"));
-
+
gimp_is_initialized = 1;
RETVAL = gimp_main (&PLUG_IN_INFO, argc, argv);
gimp_is_initialized = 0;
@@ -1396,12 +1376,12 @@ gimp_micro_version()
OUTPUT:
RETVAL
-# checks wether a gimp procedure exists
+# checks whether a gimp procedure exists
int
_gimp_procedure_available (utf8_str proc_name)
CODE:
{
- char *proc_blurb;
+ char *proc_blurb;
char *proc_help;
char *proc_author;
char *proc_copyright;
@@ -1413,8 +1393,8 @@ _gimp_procedure_available (utf8_str proc_name)
GimpParamDef *return_vals;
if (!gimp_is_initialized)
- croak ("_gimp_procedure_available(%s) called without an active connection", proc_name);
-
+ croak (__("_gimp_procedure_available(%s) called without an active connection"), proc_name);
+
if (gimp_procedural_db_proc_info (proc_name, &proc_blurb, &proc_help, &proc_author,
&proc_copyright, &proc_date, &proc_type, &nparams, &nreturn_vals,
¶ms, &return_vals) == TRUE)
@@ -1430,20 +1410,20 @@ _gimp_procedure_available (utf8_str proc_name)
}
else
RETVAL = FALSE;
-
+
}
OUTPUT:
RETVAL
#if 0
-# checks wether a gimp procedure exists
+# checks whether a gimp procedure exists
void
gimp_procedural_db_proc_info(proc_name)
char * proc_name
PPCODE:
{
- char *proc_blurb;
+ char *proc_blurb;
char *proc_help;
char *proc_author;
char *proc_copyright;
@@ -1453,7 +1433,7 @@ gimp_procedural_db_proc_info(proc_name)
int nreturn_vals;
GimpParamDef *params;
GimpParamDef *return_vals;
-
+
if (!gimp_is_initialized)
croak ("gimp_procedural_db_proc_info called without an active connection");
@@ -1477,159 +1457,154 @@ gimp_procedural_db_proc_info(proc_name)
void
gimp_call_procedure (proc_name, ...)
- utf8_str proc_name
- PPCODE:
- {
- char croak_str[MAX_STRING] = "";
- char *proc_blurb;
- char *proc_help;
- char *proc_author;
- char *proc_copyright;
- char *proc_date;
- GimpPDBProcType proc_type;
- int nparams;
- int nreturn_vals;
- GimpParam *args = 0;
- GimpParam *values = 0;
- int nvalues;
- GimpParamDef *params;
- GimpParamDef *return_vals;
- int i=0, j=0; /* work around bogus warning. */
+ utf8_str proc_name
+PPCODE:
+{
+ char croak_str[MAX_STRING] = "";
+ char *proc_blurb;
+ char *proc_help;
+ char *proc_author;
+ char *proc_copyright;
+ char *proc_date;
+ GimpPDBProcType proc_type;
+ int nparams;
+ int nreturn_vals;
+ GimpParam *args = 0;
+ GimpParam *values = 0;
+ int nvalues;
+ GimpParamDef *params;
+ GimpParamDef *return_vals;
+ int i=0, j=0; /* work around bogus warning. */
+
+ if (!gimp_is_initialized)
+ croak (__("gimp_call_procedure(%s,...) called without an active connection"), proc_name);
+
+ if (trace)
+ trace_init ();
+
+ if (trace & TRACE_CALL)
+ trace_printf ("%s", proc_name);
+
+ if (
+ gimp_procedural_db_proc_info(
+ proc_name, &proc_blurb, &proc_help, &proc_author,
+ &proc_copyright, &proc_date, &proc_type, &nparams, &nreturn_vals,
+ ¶ms, &return_vals
+ ) == TRUE
+ ) {
+ int runmode = nparams
+ && params[0].type == GIMP_PDB_INT32
+ && ( !strcmp (params[0].name, "run_mode") || !strcmp (params[0].name, "run-mode"));
+ g_free (proc_blurb);
+ g_free (proc_help);
+ g_free (proc_author);
+ g_free (proc_copyright);
+ g_free (proc_date);
+
+ if (nparams)
+ args = (GimpParam *) g_new0 (GimpParam, nparams);
+
+ for (i = 0, j = 1; i < nparams && j < items; i++) {
+ args[i].type = params[i].type;
+ if (i == 0 && runmode) {
+ /* If it's a valid value for the run mode, and # of parameters
+ are correct we assume the user explicitly included the run
+ mode parameter */
+ if (
+ nparams==(items-1) &&
+ (SvIV(ST(j))==GIMP_RUN_INTERACTIVE || SvIV(ST(j))==GIMP_RUN_NONINTERACTIVE)
+ ) {
+ args->data.d_int32 = SvIV(ST(j));
+ j++;
+ } else {
+ args->data.d_int32 = GIMP_RUN_NONINTERACTIVE;
+ }
+ } else if (
+ (!SvROK(ST(j)) || i >= nparams-1 || !is_array (params[i+1].type)) &&
+ convert_sv2gimp (croak_str, &args[i], ST(j))
+ ) {
+ j++;
+ }
- if (!gimp_is_initialized)
- croak ("gimp_call_procedure(%s,...) called without an active connection", proc_name);
-
- if (trace)
- trace_init ();
-
- if (trace & TRACE_CALL)
- trace_printf ("%s", proc_name);
-
- if (gimp_procedural_db_proc_info (proc_name, &proc_blurb, &proc_help, &proc_author,
- &proc_copyright, &proc_date, &proc_type, &nparams, &nreturn_vals,
- ¶ms, &return_vals) == TRUE)
- {
- int runmode = nparams
- && params[0].type == GIMP_PDB_INT32
- && ( !strcmp (params[0].name, "run_mode") || !strcmp (params[0].name,
"run-mode"));
- g_free (proc_blurb);
- g_free (proc_help);
- g_free (proc_author);
- g_free (proc_copyright);
- g_free (proc_date);
-
- if (nparams)
- args = (GimpParam *) g_new0 (GimpParam, nparams);
-
- for (i = 0, j = 1; i < nparams && j < items; i++)
- {
- args[i].type = params[i].type;
- if (i == 0 && runmode)
- { /* If its a valid value for the run mode, and # of parameters are correct
- * we assume the user explicitly included the run mode parameter
- */
- if (nparams==(items-1) && SvIV(ST(j))==GIMP_RUN_INTERACTIVE ||
SvIV(ST(j))==GIMP_RUN_NONINTERACTIVE)
- {
- args->data.d_int32 = SvIV(ST(j));
- j++;
- }
- else
- {
- args->data.d_int32 = GIMP_RUN_NONINTERACTIVE;
- }
- }
- else if ((!SvROK(ST(j)) || i >= nparams-1 || !is_array (params[i+1].type))
- && convert_sv2gimp (croak_str, &args[i], ST(j)))
- {
- j++;
- }
-
- if (croak_str [0])
- {
- if (trace & TRACE_CALL)
- {
- dump_params (i, args, params);
- trace_printf (__(" = [argument error]\n"));
- }
-
- goto error;
- }
- }
-
- if (trace & TRACE_CALL)
- {
- dump_params (i, args, params);
- trace_printf (" = ");
- }
-
- if (i < nparams || j < items)
- {
- if (trace & TRACE_CALL)
- trace_printf (__("[unfinished]\n"));
-
- sprintf (croak_str, __("%s arguments for function '%s'"),
- i < nparams ? __("not enough") : __("too many"), proc_name);
-
- if (nparams)
- destroy_params (args, nparams);
- }
- else
- {
- values = gimp_run_procedure2 (proc_name, &nvalues, nparams, args);
-
- if (nparams)
- destroy_params (args, nparams);
-
- if (trace & TRACE_CALL)
- {
- dump_params (nvalues-1, values+1, return_vals);
- trace_printf ("\n");
- }
-
- if (values && values[0].type == GIMP_PDB_STATUS)
- {
- if (values[0].data.d_status == GIMP_PDB_EXECUTION_ERROR)
- sprintf (croak_str, __("%s: procedural database execution failed"), proc_name);
- else if (values[0].data.d_status == GIMP_PDB_CALLING_ERROR)
- sprintf (croak_str, __("%s: procedural database execution failed on invalid
input arguments"), proc_name);
- else if (values[0].data.d_status == GIMP_PDB_SUCCESS)
- {
- EXTEND(SP, perl_paramdef_count (return_vals, nvalues-1));
- PUTBACK;
- for (i = 0; i < nvalues-1; i++)
- {
- if (i < nvalues-2 && is_array (values[i+2].type))
- i++;
-
- push_gimp_sv (values+i+1, nvalues > 2+1);
- }
-
- SPAGAIN;
- }
- else
- sprintf (croak_str, "unsupported status code: %d, fatal error\n",
values[0].data.d_status);
- }
- else
- sprintf (croak_str, "gimp didn't return an execution status, fatal error");
-
- }
-
- error:
-
- if (values)
- gimp_destroy_params (values, nreturn_vals);
-
- gimp_destroy_paramdefs (params, nparams);
- gimp_destroy_paramdefs (return_vals, nreturn_vals);
-
-
- if (croak_str[0])
- croak (croak_str);
- }
- else
- croak (__("gimp procedure '%s' not found"), proc_name);
+ if (croak_str [0]) {
+ if (trace & TRACE_CALL) {
+ dump_params (i, args, params);
+ trace_printf (__(" = [argument error]\n"));
}
+ goto error;
+ }
+ }
+
+ if (trace & TRACE_CALL) {
+ dump_params (i, args, params);
+ trace_printf (" = ");
+ }
+
+ if (i < nparams || j < items) {
+ if (trace & TRACE_CALL)
+ trace_printf (__("[unfinished]\n"));
+
+ sprintf(
+ croak_str,
+ __("%s arguments for function '%s', wanted %d, got %d"),
+ i < nparams ? __("not enough") : __("too many"),
+ proc_name,
+ nparams,
+ i
+ );
+
+ if (nparams)
+ destroy_params (args, nparams);
+ } else {
+ values = gimp_run_procedure2 (proc_name, &nvalues, nparams, args);
+
+ if (nparams)
+ destroy_params (args, nparams);
+
+ if (trace & TRACE_CALL) {
+ dump_params (nvalues-1, values+1, return_vals);
+ trace_printf ("\n");
+ }
+
+ if (values && values[0].type == GIMP_PDB_STATUS) {
+ if (values[0].data.d_status == GIMP_PDB_EXECUTION_ERROR)
+ sprintf (croak_str, __("%s: procedural database execution failed"), proc_name);
+ else if (values[0].data.d_status == GIMP_PDB_CALLING_ERROR)
+ sprintf (croak_str, __("%s: procedural database execution failed on invalid input arguments"),
proc_name);
+ else if (values[0].data.d_status == GIMP_PDB_SUCCESS) {
+ EXTEND(SP, perl_paramdef_count (return_vals, nvalues-1));
+ PUTBACK;
+ for (i = 0; i < nvalues-1; i++) {
+ if (i < nvalues-2 && is_array (values[i+2].type))
+ i++;
+
+ push_gimp_sv (values+i+1, nvalues > 2+1);
+ }
+
+ SPAGAIN;
+ } else
+ sprintf (croak_str, __("unsupported status code: %d, fatal error\n"), values[0].data.d_status);
+ } else
+ sprintf (croak_str, __("gimp didn't return an execution status, fatal error"));
+
+ }
+
+ error:
+
+ if (values)
+ gimp_destroy_params (values, nreturn_vals);
+
+ gimp_destroy_paramdefs (params, nparams);
+ gimp_destroy_paramdefs (return_vals, nreturn_vals);
+
+
+ if (croak_str[0])
+ croak (croak_str);
+ } else
+ croak (__("gimp procedure '%s' not found"), proc_name);
+}
+
void
gimp_install_procedure(name, blurb, help, author, copyright, date, menu_path, image_types, type, params,
return_vals)
utf8_str name
@@ -1651,10 +1626,10 @@ gimp_install_procedure(name, blurb, help, author, copyright, date, menu_path, im
{
GimpParamDef *apd; int nparams;
GimpParamDef *rpd; int nreturn_vals;
-
+
nparams = convert_array2paramdef ((AV *)SvRV(params) , &apd);
nreturn_vals = convert_array2paramdef ((AV *)SvRV(return_vals), &rpd);
-
+
if (ix)
gimp_install_temp_proc(name,blurb,help,author,copyright,date,SvPv(menu_path),SvPv(image_types),
type,nparams,nreturn_vals,apd,rpd,pii_run);
@@ -1665,7 +1640,7 @@ gimp_install_procedure(name, blurb, help, author, copyright, date, menu_path, im
gimp_install_procedure(name,blurb,help,author,copyright,date,SvPv(menu_path),SvPv(image_types),
type,nparams,nreturn_vals,apd,rpd);
}
-
+
g_free (rpd);
g_free (apd);
}
@@ -1689,7 +1664,7 @@ gimp_set_data(id, data)
{
STRLEN dlen;
void *dta;
-
+
dta = SvPV (data, dlen);
gimp_set_data (SvPV_nolen (id), dta, dlen);
@@ -1702,7 +1677,7 @@ gimp_get_data(id)
{
SV *data;
STRLEN dlen;
-
+
dlen = gimp_get_data_size (SvPV_nolen (id));
/* I count on dlen being zero if "id" doesn't exist. */
data = newSVpv ("", 0);
@@ -2201,6 +2176,7 @@ gimp_tile_set_data(tile,data)
GimpTile * tile
SV * data
CODE:
+ data = data; // to suppress "unused var" warning
croak (__("gimp_tile_set_data is not yet implemented\n")); /*(void *)data;*/
gimp_tile_ref_zero (tile);
gimp_tile_unref (tile, 1);
@@ -2224,7 +2200,7 @@ gimp_pixel_rgn_data(...)
gimp_tile_set_data = 12
CODE:
croak (__("This module was built without support for PDL."));
-
+
#endif
BOOT:
@@ -2241,24 +2217,24 @@ gimp_patterns_get_pattern_data(name)
{
GimpParam *return_vals;
int nreturn_vals;
-
+
return_vals = gimp_run_procedure ("gimp_patterns_get_pattern_data",
&nreturn_vals,
GIMP_PDB_STRING, SvPV_nolen (name),
GIMP_PDB_END);
-
+
if (nreturn_vals == 7
&& return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
{
EXTEND (SP, 5);
-
+
PUSHs (sv_2mortal (newSVpv ( return_vals[1].data.d_string, 0)));
PUSHs (sv_2mortal (newSViv ( return_vals[2].data.d_int32)));
PUSHs (sv_2mortal (newSViv ( return_vals[3].data.d_int32)));
PUSHs (sv_2mortal (newSViv ( return_vals[4].data.d_int32)));
PUSHs (sv_2mortal (newSVpvn((char *)return_vals[6].data.d_int8array,
return_vals[5].data.d_int32)));
}
-
+
gimp_destroy_params (return_vals, nreturn_vals);
}
diff --git a/Gimp/Pixel.pod b/Gimp/Pixel.pod
index 337689e..fa3d9b1 100644
--- a/Gimp/Pixel.pod
+++ b/Gimp/Pixel.pod
@@ -52,7 +52,7 @@ get one from any drawable, by calling the C<get> function:
in a sense, <$gdrawable> contains all tiles. Changes you make to them might
not be reflected in the image until you destroy this variable. (Thats the
-reason I used "my" int he above example. Once $gdrawable gets out of scope,
+reason I used "my" in the above example. Once $gdrawable gets out of scope,
the drawable in the gimp automatically gets updated).
To get access to a tile, you have to call C<get_tile> or C<get_tile2>.
@@ -87,8 +87,7 @@ the C<GimpDrawable>:
which method you choose is purely a question of style...
-The following functions return packed pixel data (see L<Gimp::PDL> for an
-easier way to manipulate on image data):
+The following functions return packed pixel data:
$piddle = $region->get_pixel(45,60); # return the pixel at (45|60)
$piddle = $region->get_row(45,60,10); # return ten horizontal pixels
diff --git a/Net/Net.pm b/Net/Net.pm
index 1370499..b163cf9 100644
--- a/Net/Net.pm
+++ b/Net/Net.pm
@@ -153,7 +153,7 @@ sub start_server {
or socketpair $server_fh,$gimp_fh,AF_LOCAL,SOCK_STREAM,PF_UNSPEC
or croak __"unable to create socketpair for gimp communications: $!";
- # do it here so it i done only once
+ # do it here so it is done only once
require Gimp::Config;
$gimp_pid = fork;
if ($gimp_pid > 0) {
diff --git a/Net/Net.xs b/Net/Net.xs
index d0c87f5..0c6fc5b 100644
--- a/Net/Net.xs
+++ b/Net/Net.xs
@@ -60,18 +60,13 @@ static int object_id = 100;
static void destroy_object (SV *sv)
{
- if (object_cache && sv_isobject (sv))
- {
- if (is_dynamic (HvNAME(SvSTASH(SvRV(sv)))))
- {
- int id = SvIV(SvRV(sv));
- hv_delete (object_cache, (char *)&id, sizeof(id), G_DISCARD);
- }
- else
- croak ("Internal error: Gimp::Net #101, please report!");
- }
- else
- croak ("Internal error: Gimp::Net #100, please report!");
+ if (!(object_cache && sv_isobject (sv)))
+ croak (__("Internal error: Gimp::Net #100, please report!"));
+ char *name = HvNAME(SvSTASH(SvRV(sv)));
+ if (!is_dynamic (name))
+ croak (__("Internal error: Gimp::Net #101, please report!"));
+ int id = SvIV(SvRV(sv));
+ (void)hv_delete (object_cache, (char *)&id, sizeof(id), G_DISCARD);
}
/* allocate this much as initial length */
@@ -104,14 +99,14 @@ static void sv2net (int deobjectify, SV *s, SV *sv)
{
char *name = HvNAME (SvSTASH (rv));
- sv_catpvf (s, "b%x:%s", strlen (name), name);
+ sv_catpvf (s, "b%x:%s", (unsigned int)strlen (name), name);
if (deobjectify && is_dynamic (name))
{
object_id++;
SvREFCNT_inc(sv);
- hv_store (object_cache, (char *)&object_id, sizeof(object_id), sv, 0);
+ (void)hv_store (object_cache, (char *)&object_id, sizeof(object_id), sv, 0);
sv_catpvf (s, "i%d:", object_id);
return; /* well... */
diff --git a/Perl-Server b/Perl-Server
index 1fa7f54..d7fbabb 100755
--- a/Perl-Server
+++ b/Perl-Server
@@ -340,4 +340,3 @@ Gimp::on_query {
};
exit Gimp::main;
-
diff --git a/examples/pixelmap b/examples/pixelmap
index 0b4eae2..5914364 100755
--- a/examples/pixelmap
+++ b/examples/pixelmap
@@ -60,7 +60,7 @@ register "pixelmap",
N_"<Image>/Filters/Generic/Pixelmap...",
"*",
[
- [PF_TEXT, "expression" , "The perl expression to use",
"(\$x*\$y*0.01)\n->slice(\"*\$bpp\")"]
+ [PF_TEXT, "expression" , "The perl expression to use",
'($x*$y*0.01)'."\n".'->slice("*$bpp")']
],
\&pixelmap;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]