[mapserver-users] Re: perl errorObj

Andy Colson andy at squeakycode.net
Tue May 1 11:46:48 EDT 2012


On 5/1/2012 8:50 AM, Andy Colson wrote:
> I have noticed a problem with the errorObj mapserver/mapscript/swig/perl
> object.
>
> Its treated as an array, the generated code to get the message looks
> like this:
>
> arg1 = (errorObj *)(argp1);
> result = (char *)(char *) ((arg1)->message);
> {
> size_t size = 2048;
>
> while (size && (result[size - 1] == '\0')) --size;
>
> ST(argvi) = SWIG_FromCharPtrAndSize(result, size); argvi++ ;
> }
>
> When I log errors:
> my $errObj = new mapscript::errorObj();
> while ($errObj)
> {
> $s .= "ERROR: $errObj->{code}:$errObj->{message}:$errObj->{routine}<br>";
> $errObj = $errObj->next();
> }
>
> I get the message, but then huge amounts of garbage data as well.
>
>
> In plmodule.i I tried to add a typemap:
>
> %typemap(memberout) char[ANY] {
> $result = newSVpvn($1, strlen($1));
> argvi++;
> }
>
>
> But it doesn't seem to work, the generated code is exactly the same as
> it was before. (I'm new to mapscript and swig, so I'm just guessing)
>
> Any help or hints on how I might fix this?
>
> Thanks,
>
> -Andy


Ok, this works:

%typemap(out) char[ANY] {
	$result = newSVpvn($1, strlen($1));
	argvi++;
}

I was worried about it changing too much code, but after looking at the 
generated mapscript_wrap.c, it looks fine by me.  I also tested it on my 
test box and it reports errors much much better.

I'm going to put this on my live site and run it for a while.

Are there any -dev's on this list?  I'm not subscribed to mapserver-dev, 
I'm hoping I can post this here and a dev can verify its ok and add it 
to plmodule.i.

Pretty please?

-Andy


More information about the mapserver-users mailing list