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

SWIG not generating correct type qualifiers

From: Nik Clayton <nik_at_ngo.org.uk>
Date: 2007-02-28 19:56:41 CET

Has anyone experienced problems with Swig not generating correct type

Here's the first part of the code it generates when expecting an
apr_uint32_t (you'll see this in
subversion/bindings/swig/perl/native/{core.c, svn_client.c, ...} after
running "make swig-pl")

   SWIG_AsVal_unsigned_SS_long SWIG_PERL_DECL_ARGS_2(SV *obj,
                                                     unsigned long *val)
     if (SvUOK(obj)) {
       if (val) *val = SvUV(obj);
       return SWIG_OK;
     } else if (SvIOK(obj)) {
       long v = SvIV(obj); /* conversion */
       if (v >= 0) { /* check */
         if (val) *val = v;
         return SWIG_OK;
       } else {
         return SWIG_OverflowError;

If you try and pass anything that fits in an unsigned 32 bit int, but not a
signed 32 bit int (eg., 0xffffffff), the check at the line marked "/* check
*/" will fail, and SWIG_OverflowError is returned.

The solution is to manually change the line marked "/* conversion */" to

     unsigned long SvIV(obj);

But these files are all automatically generated by Swig, so that's obviously
grossly hacky. I guess this is either a bug in the type conversion specs we
hand off to Swig, or a bug in Swig, but I'm not sure which.

Anyone else run in to anything like this when working on the language
bindings? I've verified that this behaviour exists with Swig 1.3.29 and 1.3.31.


PS: The specific place I'm running in to this is trying to wrap
SVN_DIRENT_ALL, which is 0xffffffff, and is passed to svn_client_list().

To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Wed Feb 28 19:57:33 2007

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