[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] work in progress perl typemaps for swig

From: Chia-liang Kao <clkao_at_clkao.org>
Date: 2003-07-12 12:08:07 CEST

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
Received on Sat Jul 12 12:08:58 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.