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
Received on Tue Jul 15 07:39:32 2003