logo       

RE: SWIG: std::string returned as reference - solution: msg#00133

programming.swig

Subject: RE: SWIG: std::string returned as reference - solution


I just noticed this, but why are you incrementing argvi++ in an "in"
typemap? That's related to output, not input.

Part of it I copied from other implementation.

// Perl5 string
// C++ STL string
%typemap(in) std::string {
if (!SvPOK($input))
croak("Argument $argnum is not a string");
STRLEN len;
char *ptr = SvPV($input, len);
$1 = std::string(ptr, len);
argvi++;
}

It works even if I have increment argvi (BTW, I removed it ).


-----Original Message-----
From: David Beazley [mailto:beazley@xxxxxxxxxxxxxxx]
Sent: Wednesday, November 19, 2003 1:48 PM
To: Nair, Sanjay S
Cc: David Beazley; swig@xxxxxxxxxxxxxxx
Subject: RE: [Swig] SWIG: std::string returned as reference - solution

Nair, Sanjay S writes:
> > This is different than most OUTPUT typemaps which do not modify
their
> > arguments. Use std::string &REFERENCE if you're going to do that
(to
> > be consistent with other typemaps that behave in the same way).
>
> What happens if you have multiple out params?
>
>

Well, that's an entirely different problem.
> >
> > %typemap(in) std::string*, std::string& ($basetype string_temp) {
> > if (!SvPOK($input)) {
> > croak("Argument $argnum is not a string");
> > }
> > $1 = &string_temp;
> > argvi++;
> > }
> >

I just noticed this, but why are you incrementing argvi++ in an "in"
typemap? That's related to output, not input.

-- Dave
_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise