see plug-ins/perl/Changes

This commit is contained in:
Marc Lehmann 1999-04-14 19:49:43 +00:00
parent 3a9d0e7da1
commit b809f23b63
12 changed files with 312 additions and 5 deletions

View File

@ -1,6 +1,9 @@
Revision history for Gimp-Perl extension.
- added "oneliners".
- startet implementing Gimp::Module, for embedding perl directly into
the gimp.
- added generic Gimp::Config module.
1.08 Fri Apr 9 03:20:54 CEST 1999
- added guidegrid, git-text, roundrectsel, repdup, centerguide,

View File

@ -29,4 +29,5 @@ WriteMakefile(
'macro' => { libdir => $libdir, exec_prefix => $exec_prefix, prefix => $prefix },
'LDLOADLIBS'=> "$LDFLAGS $LIBS $GIMP_LIBS_NOUI",
'DEFINE' => '',
dynamic_lib => { OTHERLDFLAGS => "$LDFLAGS $LIBS $GIMP_LIBS_NOUI" },
);

View File

@ -0,0 +1,53 @@
=head1 NAME
Gimp::Module - run scripts embedded into the Gimp program.
=head1 SYNOPSIS
not anything you would expect - and not documented, even!
=head1 DESCRIPTION
=head1 FUNCTIONS
=over 4
=cut
package Gimp::Module;
use base qw(DynaLoader);
require DynaLoader;
$VERSION=0.00;
bootstrap Gimp::Module;
#use Gtk;
#init Gtk;
sub _init {
# my $w = new Gtk::Window;
# my $l = new Gtk::Label "Test";
# $w->add($l);
#
# $w->show_all;
# Gtk->main_iteration while Gtk::Gdk->events_pending;
# Gtk::Gdk->flush;
# $w->destroy;
&GIMP_MODULE_OK;
}
sub _deinit {
}
1;
=pod
=back
=head1 AUTHOR
Marc Lehmann <pcg@goof.com>

View File

@ -39,6 +39,11 @@ Gimp/UI.pm
Gimp/Util.pm
Gimp/Feature.pm
Gimp/Pod.pm
Gimp/Module.pm
embed/Makefile.PL
embed/perlmod.c
nolib/Makefile.PL
nolib/Module.xs
examples/PDB
examples/alpha2color.pl
examples/tex-to-float

View File

@ -171,7 +171,7 @@ WARNING: version 0.3 of Gtk is _required_ for this module to
EOF
}
# wo do no longer do these dirty things
# we do no longer do these dirty things
#for(@shebang) {
# system ($Config{perlpath},"-pi","-e","\$. == 1 and \$_ = '#!$Config{perlpath}\n'",$_);
#}
@ -200,6 +200,7 @@ install ::
fi \
done ; \
$(MAKE) UNINST=1 really-install install-plugins
cd ./embed && $(MAKE) modinstall
'.$install;
}
@ -220,6 +221,9 @@ clean ::
test -f Makefile || mv -f Makefile.old Makefile
\$(RM_RF) inst-temp
all ::
cd ./embed && \$(MAKE)
install-plugins ::
\$(RM_RF) inst-temp
\$(MKPATH) inst-temp
@ -235,6 +239,41 @@ install-plugins ::
";
}
print "writing Gimp/Config.pm...";
open C,">Gimp/Config.pm" or die "Gimp/Config.pm: $!\n";
print C <<'EOF';
package Gimp::Config;
sub TIEHASH {
my $pkg = shift;
my $self;
bless \$self, $pkg;
}
sub FETCH {
$cfg{$_[1]};
}
tie %Gimp::Config, 'Gimp::Config';
%cfg = (
EOF
for $k (keys(%cfg)) {
$v = $cfg{$k};
print C " $k => \"",quotemeta(expand($v)),"\",\n";
}
print C ");\n\n1;\n";
close C;
print "ok\n";
print "configuring in ./embed...\n";
chdir "./embed" or die "unable to cd to 'embed'\n";
system($Config{perlpath},"Makefile.PL");
chdir ".." or die "unable to cd to '..'\n";
WriteMakefile(
'dist' => {
PREOP => 'chmod -R u=rwX,go=rX . ;',
@ -247,7 +286,7 @@ WriteMakefile(
Data::Dumper => 2,
Parse::RecDescent => 1.6,
},
'DIR' => ['Gimp'],
'DIR' => ['Gimp','nolib'],
'NAME' => 'Gimp',
'VERSION_FROM' => 'Gimp.pm',
'PM' => {
@ -260,6 +299,8 @@ WriteMakefile(
'Gimp/PDL.pm' => '$(INST_LIBDIR)/Gimp/PDL.pm',
'Gimp/Util.pm' => '$(INST_LIBDIR)/Gimp/Util.pm',
'Gimp/Feature.pm' => '$(INST_LIBDIR)/Gimp/Feature.pm',
'Gimp/Module.pm' => '$(INST_LIBDIR)/Gimp/Module.pm',
'Gimp/Config.pm' => '$(INST_LIBDIR)/Gimp/Config.pm',
},
'LIBS' => [''],
'INC' => "$CPPFLAGS $CFLAGS $GIMP_INC_NOUI",

View File

@ -10,6 +10,7 @@ make test TEST_VERBOSE=1
bugs
* do NOT modinstall with older gimp versions (!!!!!!!!!)
[DONE] * make parasiterc ascii-only !!!!
* improve examples/example-*.pl
* install in /usr/local (???? why? more options??)

View File

@ -0,0 +1,52 @@
require ExtUtils::MakeMaker;
import ExtUtils::MakeMaker;
use ExtUtils::Embed;
use Config;
do '../config.pl';
$perl = $Config{perlpath};
$_ccopts = ccopts;
$_ldopts = ldopts "-std", $Config{static_exts};
chomp ($_gccflags = qx<glib-config --cflags glib gmodule>);
chomp ($_gldflags = qx<glib-config --libs glib gmodule>);
sub MY::const_loadlibs {
my $self = shift;
if ($IN_GIMP) {
$self->{LD_RUN_PATH} = join (":",
$libdir,
split /:/,$self->{LD_RUN_PATH}
);
}
package MY;
$self->SUPER::const_loadlibs(@_);
}
sub MY::postamble {
<<"EOF";
clean ::
test -f Makefile || mv -f Makefile.old Makefile
modinstall :: \$(INST_DYNAMIC)
mv \$(INST_DYNAMIC) \$(gimpplugindir)/modules/
perlxsi.c:
\$(FULLPERL) -MExtUtils::Embed -e xsinit
EOF
}
WriteMakefile(
NAME => 'libperlinterp',
INSTALLDIRS => 'perl',
INSTALLARCHLIB => '/tmp',
OBJECT => 'perlmod$(OBJ_EXT) perlxsi$(OBJ_EXT)',
INC => "$_ccopts $_gccflags $CPPFLAGS -I.. $CFLAGS $DEFS".($IN_GIMP ? " -DIN_GIMP" : ""),
macro => \%cfg,
DEFINE => '',
dynamic_lib => { OTHERLDFLAGS => "$LDFLAGS $LIBS $_ldopts $_gldflags" },
clean => { FILES => 'perlmod$(OBJ_EXT) perlxsi.c perlxsi$(OBJ_EXT)' }
);

View File

@ -0,0 +1,87 @@
#include <EXTERN.h>
#include <perl.h>
#include <stdio.h>
#include <libgimp/gimpmodule.h>
#include "../ppport.h"
static GimpModuleInfo info = {
NULL,
"Generic Embedded Perl Interpreter",
"Marc Lehmann <pcg@goof.com>",
"v0.00",
"(c) 1999, released under the GPL",
"1999-04-14"
};
static PerlInterpreter *interp;
static int perl_init(void)
{
if (!interp)
{
extern void xs_init();
char *embedding[] = { "", "-e", "0" };
SV *res;
interp = perl_alloc();
if (interp)
{
perl_construct(interp);
perl_parse(interp, xs_init, 3, embedding, NULL);
perl_eval_pv ("require Gimp::Module", TRUE);
res = perl_eval_pv ("Gimp::Module::_init()", TRUE);
if (res && SvIOK (res))
return SvIV (res);
}
return GIMP_MODULE_UNLOAD;
}
return GIMP_MODULE_OK;
}
static void perl_deinit(void)
{
if (interp)
{
perl_run(interp);
perl_eval_pv ("Gimp::Module::_deinit()", TRUE);
PL_perl_destruct_level = 0;
perl_destruct(interp);
perl_free(interp);
interp = 0;
}
}
G_MODULE_EXPORT GimpModuleStatus
module_init (GimpModuleInfo **inforet)
{
GimpModuleStatus s;
*inforet = &info;
s = perl_init ();
if (s != GIMP_MODULE_OK)
perl_deinit ();
return s;
}
G_MODULE_EXPORT void
module_unload (void *shutdown_data,
void (*completed_cb)(void *),
void *completed_data)
{
perl_deinit ();
/* perl is unloadable, *sigh* */
/* completed_cb (completed_data);*/
}

View File

@ -30,7 +30,8 @@
sub expand {
my $cfg = shift;
while($cfg=~/\$\{/) {
my $count = 5;
while($cfg=~/\$\{/ and $count--) {
while(($k,$v)=each %cfg) {
$cfg=~s/\$\{$k\}/$v/g;
}
@ -45,7 +46,7 @@ while (($k,$v)=each(%cfg)) {
$GIMP = $bindir."/gimp" if $IN_GIMP;
$GIMP = expand($GIMP);
$GIMP = expand($GIMP);
$GIMPTOOL = expand($GIMPTOOL);
if (defined $topdir) {
@ -62,5 +63,13 @@ if ($IN_GIMP) {
chomp $GIMP_PREFIX;
}
$DEFS = ' -DGIMP_PREFIX=\"'.$GIMP_PREFIX.'\" -DGIMP_PATH=\"'.$GIMP.'\"';
$cfg{GIMP_PREFIX}=$GIMP_PREFIX;
if (!$IN_GIMP) {
$cfg{gimpplugindir} = `$GIMPTOOL -n --install-admin-bin /bin/sh`;
$cfg{gimpplugindir} =~ s{^.*\s(.*?)(?:/+bin/sh)\r?\n?$}{$1} &&
$cfg{gimpplugindir} =~ s{/plug-ins$}{} or die "\nFATAL: unable to deduce plugindir from gimptool script\n\n";
}
$cfg{_DEFS} = $DEFS = ' -DGIMP_PREFIX=\"'.$GIMP_PREFIX.'\" -DGIMP_PATH=\"'.$GIMP.'\"';

View File

@ -0,0 +1,23 @@
use ExtUtils::MakeMaker;
chomp ($_gccflags = qx<glib-config --cflags glib gmodule>);
chomp ($_gldflags = qx<glib-config --libs glib gmodule>);
$topdir="..";
do '../config.pl';
sub MY::postamble {
<<"EOF";
clean ::
test -f Makefile || mv -f Makefile.old Makefile
EOF
}
WriteMakefile(
'NAME' => 'Gimp::Module',
'VERSION_FROM' => '../Gimp.pm',
'INC' => "$_gccflags $CPPFLAGS -I.. $CFLAGS $DEFS".($IN_GIMP ? " -DIN_GIMP" : ""),
'macro' => \%cfg,
'DEFINE' => '',
dynamic_lib => { OTHERLDFLAGS => "$LDFLAGS $LIBS $_gldflags" },
);

View File

@ -0,0 +1,31 @@
#include "config.h"
/* FIXME */
/* sys/param.h is redefining these! */
#undef MIN
#undef MAX
/* dunno where this comes from */
#undef VOIDUSED
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#define NEED_newCONSTSUB
#include "ppport.h"
#include <libgimp/gimpmodule.h>
MODULE = Gimp::Module PACKAGE = Gimp::Module
VERSIONCHECK: DISABLE
PROTOTYPES: ENABLE
BOOT:
{
HV *stash = gv_stashpvn("Gimp::Module", 12, TRUE);
newCONSTSUB(stash,"GIMP_MODULE_OK",newSViv(GIMP_MODULE_OK));
newCONSTSUB(stash,"GIMP_MODULE_UNLOAD",newSViv(GIMP_MODULE_UNLOAD));
}

View File

@ -166,6 +166,7 @@ __DATA__
# define PL_curstash curstash
# define PL_copline copline
# define PL_Sv Sv
# define PL_perl_destruct_level perl_destruct_level
/* Replace: 0 */
#endif