You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Chia-liang Kao <cl...@clkao.org> on 2003/07/12 10:08:07 UTC
[PATCH] work in progress perl typemaps for swig
Some basic typemaps.
Since in perl there is IO Layers, and there is no interface to
libc FILE * structure, it needs to be kludged.
Index: subversion/bindings/swig/core.i
===================================================================
--- subversion/bindings/swig/core.i (revision 6452)
+++ subversion/bindings/swig/core.i (working copy)
@@ -141,7 +141,9 @@
$2 = ($2_ltype)&temp;
}
%typemap(perl5, in) (char *buffer, apr_size_t *len) ($*2_type temp) {
- /* ### FIXME-perl */
+ temp = SvIV($input);
+ $1 = malloc(temp);
+ $2 = ($2_ltype)&temp;
}
/* ### need to use freearg or somesuch to ensure the string is freed.
@@ -152,7 +154,8 @@
free($1);
}
%typemap(perl5, argout) (char *buffer, apr_size_t *len) {
- /* ### FIXME-perl */
+ $result = newSVpvn($1, $2);
+ free($1);
}
/* -----------------------------------------------------------------------
@@ -169,7 +172,7 @@
$2 = ($2_ltype)&temp;
}
%typemap(perl5, in) (const char *data, apr_size_t *len) ($*2_type temp) {
- /* ### FIXME-perl */
+ $1 = SvPV($input, *$2);
}
%typemap(python, argout, fragment="t_output_helper") (const char *data, apr_size_t *len) {
@@ -177,7 +180,8 @@
}
%typemap(perl5, argout, fragment="t_output_helper") (const char *data, apr_size_t *len) {
- /* ### FIXME-perl */
+ $result = newSViv(*$2);
+
}
/* -----------------------------------------------------------------------
@@ -191,7 +195,30 @@
}
}
%typemap(perl5, in) FILE * {
- /* ### FIXME-perl */
+ dSP ;
+ int count, fd ;
+
+ ENTER ;
+ SAVETMPS;
+
+ PUSHMARK(SP) ;
+ XPUSHs($input);
+ PUTBACK ;
+
+ count = call_pv("fileno", G_SCALAR);
+ SPAGAIN ;
+
+ if (count != 1)
+ croak("Big trouble\n") ;
+
+ if (fd = POPi < 0)
+ croak("not an accessible filehandle");
+
+ $1 = fdopen (fd, "r+");
+
+ PUTBACK ;
+ FREETMPS ;
+ LEAVE ;
}
/* -----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] work in progress perl typemaps for swig
Posted by Paul Lussier <pl...@lanminds.com>.
Filed as issue 1437:
http://subversion.tigris.org/issues/show_bug.cgi?id=1437
--
Seeya,
Paul
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] work in progress perl typemaps for swig
Posted by Chia-liang Kao <cl...@clkao.org>.
On Mon, Jul 14, 2003 at 10:47:27PM -0700, Blair Zajac wrote:
> > now here's some changes to make perl bindings work. you could run
> > the following code now:
> >
> > use SVN::core;
> > use SVN::repos;
>
> Minor nit, most Perl modules have capital letters, so I suggest SVN::Core
> and SVN::Repos.
>
> > SVN::core::apr_initialize;
>
> Shouldn't the SVN::core module call apr_initialize? It can make sure
> that it is only called once per process.
right, but this should be in the BEGIN block of the wrapper class.
so I think maybe capitalized class will be the shadow class in the
future, where as SVN::core and alike generated by swig, will be the
raw class providing direct library call.
Cheers,
CLK
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] work in progress perl typemaps for swig
Posted by Greg Stein <gs...@lyra.org>.
On Mon, Jul 14, 2003 at 10:47:27PM -0700, Blair Zajac wrote:
>...
> > SVN::core::apr_initialize;
>
> Shouldn't the SVN::core module call apr_initialize? It can make sure
> that it is only called once per process.
No, I don't think so. The Perl bindings should probably be treated just like
the libraries they're covering: don't "just do" something. If the app
doesn't want you to, then it is stuck.
If you have some high level wrappers, then sure. Just make sure that people
can always avoid your "help" if/when they need to.
(this is kind of why the Python bindings, at least, are organized into the
libsvn and svn packages)
Cheers,
-g
--
Greg Stein, http://www.lyra.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] work in progress perl typemaps for swig
Posted by Blair Zajac <bl...@orcaware.com>.
Chia-liang Kao wrote:
>
> now here's some changes to make perl bindings work. you could run
> the following code now:
>
> use SVN::core;
> use SVN::repos;
Minor nit, most Perl modules have capital letters, so I suggest SVN::Core
and SVN::Repos.
> SVN::core::apr_initialize;
Shouldn't the SVN::core module call apr_initialize? It can make sure
that it is only called once per process.
Best,
Blair
--
Blair Zajac <bl...@orcaware.com>
Plots of your system's performance - http://www.orcaware.com/orca/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] work in progress perl typemaps for swig
Posted by Josef Wolf <jw...@raven.inka.de>.
On Tue, Jul 15, 2003 at 01:38:21PM +0800, Chia-liang Kao wrote:
> now here's some changes to make perl bindings work. you could run
> the following code now:
Fine :)
> my $pool = SVN::core::svn_pool_create(undef);
> my $repo = SVN::repos->svn_repos_open('/Users/clkao/svn/pairang', $pool);
> my $fs = SVN::repos::svn_repos_fs($repo);
> print SVN::fs::svn_fs_youngest_rev($fs, $pool);
Don't you think the pool handling stuff should be hidden? IMHO too much
details of the original API is shining through. Some additional abstraction
could lead to much more perlish code:
my $repo=SVN::Repos->new("http://foo.bar/path");
my @revs=$repo->revisions();
print $revs[$#revs]->{revnumber}; # youngest revision
print $revs[$#revs]->{log}; # log of the youngest revision
# etc/pp
--
-- Josef Wolf -- jw@raven.inka.de --
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] work in progress perl typemaps for swig
Posted by Chia-liang Kao <cl...@clkao.org>.
the last one was just a quick snap for people interested. here comes
the one with wrapper classes. :)
On Wed, Jul 16, 2003 at 12:35:03AM -0700, Greg Stein wrote:
> How about a log message for this patch? Please see the patch posting
> guidelines in HACKING.
log message:
Some works on the swig perl binding support, including some typemap
code and high level wrapper classes. now you could do:
my $pool = SVN::Core::pool_create(undef);
print SVN::Repos->open ('/Users/clkao/svn/pairang',
$pool)->fs->youngest_rev ($pool);
The Base class strips defined prefix of functions to be imported into
the module's namespace.
* core.i: Finish typemaps.
* svn_type.i: Typemaps for returned param and apr_pool_t.
* apr.i: Comment the perl sections so it's easier to fix things
later on.
* perl/Makefile.PL: perl binding's builder (for now).
* perl/Base.pm: Base class for exporting symbol to wrapper classes.
* perl/Client.pm: New file.
* perl/Core.pm: New file.
* perl/Delta.pm: New file.
* perl/Fs.pm: New file.
* perl/Ra.pm: New file.
* perl/Repos.pm: New file.
* perl/Wc.pm: New file.
Index: core.i
===================================================================
--- core.i (revision 6452)
+++ core.i (working copy)
@@ -141,7 +141,9 @@
$2 = ($2_ltype)&temp;
}
%typemap(perl5, in) (char *buffer, apr_size_t *len) ($*2_type temp) {
- /* ### FIXME-perl */
+ temp = SvIV($input);
+ $1 = malloc(temp);
+ $2 = ($2_ltype)&temp;
}
/* ### need to use freearg or somesuch to ensure the string is freed.
@@ -152,7 +154,8 @@
free($1);
}
%typemap(perl5, argout) (char *buffer, apr_size_t *len) {
- /* ### FIXME-perl */
+ $result = newSVpvn($1, $2);
+ free($1);
}
/* -----------------------------------------------------------------------
@@ -169,7 +172,7 @@
$2 = ($2_ltype)&temp;
}
%typemap(perl5, in) (const char *data, apr_size_t *len) ($*2_type temp) {
- /* ### FIXME-perl */
+ $1 = SvPV($input, *$2);
}
%typemap(python, argout, fragment="t_output_helper") (const char *data, apr_size_t *len) {
@@ -177,7 +180,8 @@
}
%typemap(perl5, argout, fragment="t_output_helper") (const char *data, apr_size_t *len) {
- /* ### FIXME-perl */
+ $result = newSViv(*$2);
+
}
/* -----------------------------------------------------------------------
@@ -191,7 +195,30 @@
}
}
%typemap(perl5, in) FILE * {
- /* ### FIXME-perl */
+ dSP ;
+ int count, fd ;
+
+ ENTER ;
+ SAVETMPS;
+
+ PUSHMARK(SP) ;
+ XPUSHs($input);
+ PUTBACK ;
+
+ count = call_pv("fileno", G_SCALAR);
+ SPAGAIN ;
+
+ if (count != 1)
+ croak("Big trouble\n") ;
+
+ if (fd = POPi < 0)
+ croak("not an accessible filehandle");
+
+ $1 = fdopen (fd, "r+");
+
+ PUTBACK ;
+ FREETMPS ;
+ LEAVE ;
}
/* -----------------------------------------------------------------------
Index: svn_types.i
===================================================================
--- svn_types.i (revision 6452)
+++ svn_types.i (working copy)
@@ -34,12 +34,16 @@
%typemap(java, in) SWIGTYPE **OUTPARAM ($*1_type temp) {
$1 = ($1_ltype)&temp;
}
+%typemap(perl5, in) SWIGTYPE **OUTPARAM ($*1_type temp) {
+ $1 = ($1_ltype)&temp;
+}
%typemap(python, argout, fragment="t_output_helper") SWIGTYPE **OUTPARAM {
$result = t_output_helper($result,
SWIG_NewPointerObj(*$1, $*1_descriptor, 0));
}
%typemap(perl5, argout) SWIGTYPE **OUTPARAM {
- /* ### FIXME-perl */
+ ST(argvi) = sv_newmortal();
+ SWIG_MakePtr(ST(argvi++), (void *)*$1, $*1_descriptor,0);
}
/* -----------------------------------------------------------------------
@@ -192,7 +196,9 @@
_global_pool = $1;
}
%typemap(perl5, arginit) apr_pool_t *pool(apr_pool_t *_global_pool) {
- /* ### FIXME-perl */
+ SWIG_ConvertPtr(ST($argnum-1),
+ (void **)&$1, $1_descriptor, 0);
+ _global_pool = $1;
}
%typemap(java, arginit) apr_pool_t *pool(apr_pool_t *_global_pool) {
Index: perl/Repos.pm
===================================================================
--- perl/Repos.pm (working copy)
+++ perl/Repos.pm (working copy)
@@ -0,0 +1,13 @@
+package SVN::Repos;
+use SVN::Base qw(Repos svn_repos_);
+
+package _p_svn_repos_t;
+
+my @methods = qw/fs/;
+
+for (@methods) {
+ *{$_} = *{"SVN::Repos::$_"};
+}
+
+
+1;
Index: perl/Fs.pm
===================================================================
--- perl/Fs.pm (working copy)
+++ perl/Fs.pm (working copy)
@@ -0,0 +1,13 @@
+package SVN::Fs;
+use SVN::Base qw(Fs svn_fs_);
+
+package _p_svn_fs_t;
+
+my @methods = qw/youngest_rev/;
+
+for (@methods) {
+ *{$_} = *{"SVN::Fs::$_"};
+}
+
+
+1;
Index: perl/Core.pm
===================================================================
--- perl/Core.pm (working copy)
+++ perl/Core.pm (working copy)
@@ -0,0 +1,13 @@
+package SVN::Core;
+use SVN::Base qw(Core svn_);
+
+BEGIN {
+ SVN::_Core::apr_initialize;
+
+}
+
+END {
+ SVN::_Core::apr_terminate;
+}
+
+1;
Index: perl/Wc.pm
===================================================================
--- perl/Wc.pm (working copy)
+++ perl/Wc.pm (working copy)
@@ -0,0 +1,11 @@
+package SVN::Wc;
+use SVN::Base qw(Wc svn_wc_);
+
+package _p_svn_wc_t;
+
+package _p_svn_wc_entry_t;
+# still need to check if the function prototype allows it to be called
+# as method.
+use SVN::Base qw(Wc svn_wc_entry_t_);
+
+1;
Index: perl/Delta.pm
===================================================================
--- perl/Delta.pm (working copy)
+++ perl/Delta.pm (working copy)
@@ -0,0 +1,4 @@
+package SVN::Delta;
+use SVN::Base qw(Delta svn_delta_);
+
+1;
Index: perl/Base.pm
===================================================================
--- perl/Base.pm (working copy)
+++ perl/Base.pm (working copy)
@@ -0,0 +1,23 @@
+package SVN::Base;
+
+sub import {
+ my (undef, $pkg, $prefix) = @_;
+ unless (defined %{"SVN::_${pkg}::"}) {
+ @{"SVN::_${pkg}::ISA"} = qw(DynaLoader);
+ eval qq'
+package SVN::_$pkg;
+require DynaLoader;
+bootstrap SVN::_$pkg;
+1;
+ ' or die $@;
+ };
+
+ for (keys %{"SVN::_${pkg}::"}) {
+ my $name = $_;
+ next unless s/^$prefix//i;
+ *{caller(0)."::$_"} = ${"SVN::_${pkg}::"}{$name};
+ }
+
+}
+
+1;
Index: perl/Makefile.PL
===================================================================
--- perl/Makefile.PL (working copy)
+++ perl/Makefile.PL (working copy)
@@ -0,0 +1,56 @@
+#!/usr/bin/perl
+use ExtUtils::MakeMaker;
+
+my @modules = qw/client delta fs ra repos wc/;
+my @ldmodules = map {"-lsvn_$_-1"} (@modules, qw/subr/);
+
+my $apr_cflags = `apr-config --includes`;
+my $apr_ldflags = `apr-config --libs`;
+
+chomp $apr_cflags;
+chomp $apr_ldflags;
+
+my %config = (
+ ABSTRACT => 'perl binding for subversion',
+ CCFLAGS => join(' ', $apr_cflags, `perl -MExtUtils::Embed -e ccopts`,
+ ' -I.. -I../../../include -g'),
+ OBJECT => q/$(O_FILES)/,
+ dynamic_lib => {
+ OTHERLDFLAGS => join(' ', $apr_ldflags, '-L/usr/local/lib',
+ @ldmodules, `swig -perl -ldflags`),
+ },
+);
+
+sub perlish {
+ local $_ = $_[0];
+ s/^(\w)/\U$1/;
+ $_;
+}
+
+WriteMakefile(%config, NAME => 'SVN::_Core', C => ['core.c'],
+ PM => {map { ("$_.pm" => "\$(INST_LIBDIR)/$_.pm") }
+ map { perlish $_ }
+ ('base', 'core', @modules)},
+ );
+
+for (@modules) {
+ WriteMakefile(%config,
+ MAKEFILE=> "Makefile.$_",
+ NAME => "SVN::_".perlish($_),
+ PM => {"$_.pm" => "\$(INST_LIBDIR)/SVN/$_.pm"},
+ C => ["svn_$_.c"],
+ );
+}
+
+sub MY::postamble {
+ package MY ;
+ return join('', "all :: modules\n\n",
+ "modules :: ",(map { " svn_$_.c"} @modules),"\n",
+ (map {"\tmake -f Makefile.$_\n"} @modules),
+ "\ncore.pm core.c :: ../core.i\n",
+ "\tswig -c -nopm -perl -I.. -I../../../include $apr_cflags -module SVN::_Core -o core.c ../core.i\n",
+ map {"\nsvn_$_.c :: ../svn_$_.i\n".
+ "\tswig -c -shadow -perl -I.. -I../../../include $apr_cflags -module SVN::_".main::perlish($_)." -o svn_$_.c ../svn_$_.i\n"}
+ @modules
+ );
+}
Index: perl/Client.pm
===================================================================
--- perl/Client.pm (working copy)
+++ perl/Client.pm (working copy)
@@ -0,0 +1,4 @@
+package SVN::Client;
+use SVN::Base qw(Client svn_client_);
+
+1;
Index: perl/Ra.pm
===================================================================
--- perl/Ra.pm (working copy)
+++ perl/Ra.pm (working copy)
@@ -0,0 +1,4 @@
+package SVN::Ra;
+use SVN::Base qw(Ra svn_ra_);
+
+1;
Index: apr.i
===================================================================
--- apr.i (revision 6452)
+++ apr.i (working copy)
@@ -44,7 +44,7 @@
"$result = t_output_helper($result,PyInt_FromLong((long) (*$1)));";
%typemap(perl5,argout) apr_off_t * {
- /* ### FIXME-perl */
+ /* ### FIXME-perl apr_off_t out*/
}
/* ----------------------------------------------------------------------- */
@@ -86,7 +86,7 @@
}
%typemap(perl5,argout) apr_time_t * {
- /* ### FIXME-perl */
+ /* ### FIXME-perl apr_time_t out */
}
/* -----------------------------------------------------------------------
create some INOUT typemaps for apr_size_t
@@ -104,6 +104,8 @@
}
%typemap(perl5,in) apr_size_t *INOUT (apr_size_t temp) {
+ temp = (apr_size_t) SvIV($input);
+ $1 = &temp;
/* ### FIXME-perl */
}
/* -----------------------------------------------------------------------
@@ -172,7 +174,7 @@
}
%typemap(perl5,argout) apr_hash_t **PROPHASH {
- /* ### FIXME-perl */
+ /* ### FIXME-perl apr_hash out */
}
/* -----------------------------------------------------------------------
handle apr_file_t *
@@ -182,7 +184,7 @@
$1 = svn_swig_py_make_file($input, _global_pool);
}
%typemap(perl5, in) apr_file_t * {
- /* ### FIXME-perl */
+ /* ### FIXME-perl apr_file_t in*/
}
/* -----------------------------------------------------------------------
@@ -198,6 +200,6 @@
SWIG_NewPointerObj(*$1, $*1_descriptor, 0));";
%typemap(perl5,argout) apr_file_t ** {
- /* ### FIXME-perl */
+ /* ### FIXME-perl apr_file_t out*/
}
/* ----------------------------------------------------------------------- */
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] work in progress perl typemaps for swig
Posted by Greg Stein <gs...@lyra.org>.
On Tue, Jul 15, 2003 at 01:38:21PM +0800, Chia-liang Kao wrote:
>...
> I'll continue to make sure important function calls work, and
> I think we'll need our own shadow class instead of the one
> swig generates.
>...
> Index: core.i
>...
How about a log message for this patch? Please see the patch posting
guidelines in HACKING.
Cheers,
-g
--
Greg Stein, http://www.lyra.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] work in progress perl typemaps for swig
Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
--On Wednesday, July 16, 2003 12:32 AM -0700 Greg Stein <gs...@lyra.org>
wrote:
> No... we should get the sucker integrated into the standard build system.
> I'm torn on whether to include the Makefile.PL even temporarily. As long as
> it is present, nobody will have any impetus to fix the real build system.
Which, AFAIK, it should be doing just that starting with r6441 (use 'make
swig-pl'). install-swig-pl may not work because we weren't sure what it'll
emit and what we need to install just yet. -- justin
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] work in progress perl typemaps for swig
Posted by Greg Stein <gs...@lyra.org>.
On Tue, Jul 15, 2003 at 08:17:18AM -0400, Garrett Rooney wrote:
> Chia-liang Kao wrote:
>
> > note that I think it's better to build the perl bindings
> > with perl's standard way instead of libtool. libtool is
I very much disagree. We tried that with the Python bindings and using
distutil. We got screwed. Arguably, the Perl MakeMake thingy is better, but
I look at your sample Makefile.PL and still see a lot of problems. There are
a log of things that need to be passed into a proper build of SWIG
extensions. All kinds of paths, library names, version numbers, etc.
No... we should get the sucker integrated into the standard build system.
I'm torn on whether to include the Makefile.PL even temporarily. As long as
it is present, nobody will have any impetus to fix the real build system.
I'm guessing that you'll get a long ways just by doing some simple copy and
paste in the top-level Makefile.in for the swig-related symbols. Then adjust
the swig-languages option into build.conf and see what happens :-)
> > good for cross platform shared libraray building. but as
> > for perl (or maybe python too), on different platform there
> > might be different way to build their own shared object.
> > for example on Mac OS X, the libraries should be built as
> > .bundle instead of .dylib. and maybe this is why I can't
> > use python binding on Mac OS X: libtool links them as .so.
>
> That's a bug in libtool. Newer versions fix it. I know 1.5 does, and
> earlier versions might work, although I'm not sure which ones.
Right. And worst case, we can always apply some additional platform-specific
magic until we decide to move up to libtool 1.5 to fix the problems.
Cheers,
-g
--
Greg Stein, http://www.lyra.org/
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] work in progress perl typemaps for swig
Posted by Garrett Rooney <ro...@electricjellyfish.net>.
Chia-liang Kao wrote:
> note that I think it's better to build the perl bindings
> with perl's standard way instead of libtool. libtool is
> good for cross platform shared libraray building. but as
> for perl (or maybe python too), on different platform there
> might be different way to build their own shared object.
> for example on Mac OS X, the libraries should be built as
> .bundle instead of .dylib. and maybe this is why I can't
> use python binding on Mac OS X: libtool links them as .so.
That's a bug in libtool. Newer versions fix it. I know 1.5 does, and
earlier versions might work, although I'm not sure which ones.
-garrett
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Re: [PATCH] work in progress perl typemaps for swig
Posted by Chia-liang Kao <cl...@clkao.org>.
now here's some changes to make perl bindings work. you could run
the following code now:
use SVN::core;
use SVN::repos;
SVN::core::apr_initialize;
my $pool = SVN::core::svn_pool_create(undef);
my $repo = SVN::repos->svn_repos_open('/Users/clkao/svn/pairang', $pool);
my $fs = SVN::repos::svn_repos_fs($repo);
print SVN::fs::svn_fs_youngest_rev($fs, $pool);
to use it, go to bindings/swig/perl, and then
perl Makefile.PL; make all modules; perl -Mblib <your script>
note that I think it's better to build the perl bindings
with perl's standard way instead of libtool. libtool is
good for cross platform shared libraray building. but as
for perl (or maybe python too), on different platform there
might be different way to build their own shared object.
for example on Mac OS X, the libraries should be built as
.bundle instead of .dylib. and maybe this is why I can't
use python binding on Mac OS X: libtool links them as .so.
But it'd be also nice if someone familiar with libtool
could fix them.
I'll continue to make sure important function calls work, and
I think we'll need our own shadow class instead of the one
swig generates.
Cheeres,
CLK
Index: core.i
===================================================================
--- core.i (revision 6452)
+++ core.i (working copy)
@@ -141,7 +141,9 @@
$2 = ($2_ltype)&temp;
}
%typemap(perl5, in) (char *buffer, apr_size_t *len) ($*2_type temp) {
- /* ### FIXME-perl */
+ temp = SvIV($input);
+ $1 = malloc(temp);
+ $2 = ($2_ltype)&temp;
}
/* ### need to use freearg or somesuch to ensure the string is freed.
@@ -152,7 +154,8 @@
free($1);
}
%typemap(perl5, argout) (char *buffer, apr_size_t *len) {
- /* ### FIXME-perl */
+ $result = newSVpvn($1, $2);
+ free($1);
}
/* -----------------------------------------------------------------------
@@ -169,7 +172,7 @@
$2 = ($2_ltype)&temp;
}
%typemap(perl5, in) (const char *data, apr_size_t *len) ($*2_type temp) {
- /* ### FIXME-perl */
+ $1 = SvPV($input, *$2);
}
%typemap(python, argout, fragment="t_output_helper") (const char *data, apr_size_t *len) {
@@ -177,7 +180,8 @@
}
%typemap(perl5, argout, fragment="t_output_helper") (const char *data, apr_size_t *len) {
- /* ### FIXME-perl */
+ $result = newSViv(*$2);
+
}
/* -----------------------------------------------------------------------
@@ -191,7 +195,30 @@
}
}
%typemap(perl5, in) FILE * {
- /* ### FIXME-perl */
+ dSP ;
+ int count, fd ;
+
+ ENTER ;
+ SAVETMPS;
+
+ PUSHMARK(SP) ;
+ XPUSHs($input);
+ PUTBACK ;
+
+ count = call_pv("fileno", G_SCALAR);
+ SPAGAIN ;
+
+ if (count != 1)
+ croak("Big trouble\n") ;
+
+ if (fd = POPi < 0)
+ croak("not an accessible filehandle");
+
+ $1 = fdopen (fd, "r+");
+
+ PUTBACK ;
+ FREETMPS ;
+ LEAVE ;
}
/* -----------------------------------------------------------------------
Index: svn_types.i
===================================================================
--- svn_types.i (revision 6452)
+++ svn_types.i (working copy)
@@ -34,12 +34,16 @@
%typemap(java, in) SWIGTYPE **OUTPARAM ($*1_type temp) {
$1 = ($1_ltype)&temp;
}
+%typemap(perl5, in) SWIGTYPE **OUTPARAM ($*1_type temp) {
+ $1 = ($1_ltype)&temp;
+}
%typemap(python, argout, fragment="t_output_helper") SWIGTYPE **OUTPARAM {
$result = t_output_helper($result,
SWIG_NewPointerObj(*$1, $*1_descriptor, 0));
}
%typemap(perl5, argout) SWIGTYPE **OUTPARAM {
- /* ### FIXME-perl */
+ ST(argvi) = sv_newmortal();
+ SWIG_MakePtr(ST(argvi++), (void *)*$1, $*1_descriptor,0);
}
/* -----------------------------------------------------------------------
@@ -192,7 +196,9 @@
_global_pool = $1;
}
%typemap(perl5, arginit) apr_pool_t *pool(apr_pool_t *_global_pool) {
- /* ### FIXME-perl */
+ SWIG_ConvertPtr(ST($argnum-1),
+ (void **)&$1, $1_descriptor, 0);
+ _global_pool = $1;
}
%typemap(java, arginit) apr_pool_t *pool(apr_pool_t *_global_pool) {
Index: perl/Makefile.PL
===================================================================
--- perl/Makefile.PL (working copy)
+++ perl/Makefile.PL (working copy)
@@ -0,0 +1,48 @@
+#!/usr/bin/perl
+use ExtUtils::MakeMaker;
+
+my @modules = qw/client delta fs ra repos wc/;
+my @ldmodules = map {"-lsvn_$_-1"} (@modules, qw/subr/);
+
+my $apr_cflags = `apr-config --includes`;
+my $apr_ldflags = `apr-config --libs`;
+
+chomp $apr_cflags;
+chomp $apr_ldflags;
+
+my %config = (
+ ABSTRACT => 'perl binding for subversion',
+ CCFLAGS => join(' ', $apr_cflags, `perl -MExtUtils::Embed -e ccopts`,
+ ' -I.. -I../../../include -g'),
+ dynamic_lib => {
+ OTHERLDFLAGS => join(' ', $apr_ldflags, '-L/usr/local/lib',
+ @ldmodules, `swig -perl -ldflags`),
+ },
+);
+
+WriteMakefile(%config, NAME => 'SVN::core', C => ['core.c'],
+ PM => {map { ("$_.pm" => "\$(INST_LIBDIR)/$_.pm") }
+ ('core',@modules)},
+ );
+
+for (@modules) {
+ WriteMakefile(%config,
+ MAKEFILE=> "Makefile.$_",
+ NAME => "SVN::$_",
+ PM => {"$_.pm" => "\$(INST_LIBDIR)/SVN/$_.pm"},
+ C => ["svn_$_.c"],
+ OBJECT => q/$(O_FILES)/,
+ );
+}
+
+sub MY::postamble {
+ package MY ;
+ return join('', "\$(MYEXTLIB): modules\n\n",
+ "modules: \n", (map {"\tmake -f Makefile.$_\n"} @modules),
+
+ "\ncore.pm core.c :: ../core.i\n",
+ "\tswig -c -perl -I.. -I../../../include $apr_cflags -module SVN::core -o core.c ../core.i\n",
+ map {"\n$_.pm svn_$_.c :: ../svn_$_.i\n\tswig -c -shadow -perl -I.. -I../../../include $apr_cflags -module SVN::$_ -o svn_$_.c ../svn_$_.i\n"}
+ @modules
+ );
+}
Index: apr.i
===================================================================
--- apr.i (revision 6452)
+++ apr.i (working copy)
@@ -44,7 +44,7 @@
"$result = t_output_helper($result,PyInt_FromLong((long) (*$1)));";
%typemap(perl5,argout) apr_off_t * {
- /* ### FIXME-perl */
+ /* ### FIXME-perl apr_off_t out*/
}
/* ----------------------------------------------------------------------- */
@@ -86,7 +86,7 @@
}
%typemap(perl5,argout) apr_time_t * {
- /* ### FIXME-perl */
+ /* ### FIXME-perl apr_time_t out */
}
/* -----------------------------------------------------------------------
create some INOUT typemaps for apr_size_t
@@ -104,6 +104,8 @@
}
%typemap(perl5,in) apr_size_t *INOUT (apr_size_t temp) {
+ temp = (apr_size_t) SvIV($input);
+ $1 = &temp;
/* ### FIXME-perl */
}
/* -----------------------------------------------------------------------
@@ -172,7 +174,7 @@
}
%typemap(perl5,argout) apr_hash_t **PROPHASH {
- /* ### FIXME-perl */
+ /* ### FIXME-perl apr_hash out */
}
/* -----------------------------------------------------------------------
handle apr_file_t *
@@ -182,7 +184,7 @@
$1 = svn_swig_py_make_file($input, _global_pool);
}
%typemap(perl5, in) apr_file_t * {
- /* ### FIXME-perl */
+ /* ### FIXME-perl apr_file_t in*/
}
/* -----------------------------------------------------------------------
@@ -198,6 +200,6 @@
SWIG_NewPointerObj(*$1, $*1_descriptor, 0));";
%typemap(perl5,argout) apr_file_t ** {
- /* ### FIXME-perl */
+ /* ### FIXME-perl apr_file_t out*/
}
/* ----------------------------------------------------------------------- */
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org