Re: [classad-users] swig broken in classad 0.9.8


Date: Thu, 22 Jun 2006 13:45:15 -0500
From: Erik Paulson <epaulson@xxxxxxxxxxx>
Subject: Re: [classad-users] swig broken in classad 0.9.8
On Thu, Jun 15, 2006 at 12:28:31PM -0500, Erik Paulson wrote:
> 
> On Thu, Jun 15, 2006 at 12:12:30PM -0500, Erik Paulson wrote:
> > The SWIG interface doesn't build in the new version of classads:
> > 
> > g++ -fno-implicit-templates -g -DCLASSAD_DISTRIBUTION -I/s/perl-5.8.6/i386_tao1
> > /lib/5.8.6/i686-linux-64int/CORE -c classad_wrap.C
> > classad_wrap.C: In function `int SWIG_Perl_ConvertPtr(SV*, void**, swig_type_in
> > o*, int)':
> > classad_wrap.C:532: warning: cast to pointer from integer of different size
> > In file included from classad.h:32,
> >                  from classad_wrap.C:833:
> > exprTree.h:117:27: macro "Copy" requires 4 arguments, but only 1 given
> > In file included from classad.h:32,
> >                  from classad_wrap.C:833:
> > exprTree.h: At global scope:
> 
> Ugh. The perl headers define:
> 
> #define Move(s,d,n,t)   (MEM_WRAP_CHECK(n,t), (void)memmove((char*)(d),(char*)(s), (n) * sizeof(t)))
> #define Copy(s,d,n,t)   (MEM_WRAP_CHECK(n,t), (void)memcpy((char*)(d),(char*)(s), (n) * sizeof(t)))
> #define Zero(d,n,t) (MEM_WRAP_CHECK(n,t), (void)memzero((char*)(d), (n) * sizeof(t)))
> 
> Classads use Copy() in about 40 different places.
> 

I got this to work two ways:

1. I undefed Copy right away in the ClassAd code, so the definition from
perl isn't seen. Nate thinks he did this as well at one point, but wasn't
what did in the end (but he's not sure what he did in the end either)

2. I renamed all occourances of Copy() in classads to deepcopy(). 

I'd like to propose making number #2 part of the ClassAd library. Nate
thinks that the Perl/SWIG may use the Copy() functionality. (And yes,
it sucks that Perl does this, and the SWIG developers are angry at
Perl for doing it and want Perl to change, see the end of this
section: http://www.swig.org/Doc1.3/Perl5.html#Perl5_nn9 ) but for
now it sucks) 

Also, deepcopy() is more clear about what's going on than
copy().

There's also a minor bug in ClassAd::Simple code that cases
the test suite to fail - in evalaute_expr, it's got:

if (ref($expr))
    {
    ($value) = $this->evaluate_expr_expr($expr->copy);
    } 

but it only works if it's 

if (ref($expr))
    {
    ($value) = $this->evaluate_expr_expr($expr);
    }


I'm not sure why yet, and Nate didn't know off-hand either. I think as the SWIG
interface gets used more we'll trip over more of those sorts of bugs.

-Erik
[← Prev in Thread] Current Thread [Next in Thread→]