|
From: John K. <jko...@on...> - 2005-12-07 20:05:31
|
There seems to be a bug in the CVS version when creating perl bindings.
Version 1.3.27 was able to implicitly convert strings to integers (eg
"1" -> 1), but 1.3.28 dies with a TypeError. I think the problem is in
SWIG_AsVal_unsigned_SS_long, since neither SvUOK or SvIOK is true. Is
there another macro that should be used as a "can this sv be coerced
into being a uv?" I didn't look at the 1.3.27 version of this function,
but I don't really know anything about perl internals either, so I
figured I'd ask the list.
John
=== test.i ===
%include "typemaps.i"
%module test
%{
typedef unsigned char t_u8;
typedef t_u8 t_bool;
static t_bool priv_bool = 0;
int GetBool(t_bool *b) {
*b=priv_bool;
printf("C: Returning %d\n",*b);
return 0;
};
int SetBool(t_bool b) {
printf("C: Setting %d\n",b);
priv_bool = b;
return 0;
};
%}
%apply unsigned char *OUTPUT { unsigned char * }
typedef unsigned char t_u8;
typedef t_u8 t_bool;
int GetBool(t_bool *b);
int SetBool(t_bool b);
=== test_pl.pl ===
#!/usr/bin/perl
use test;
$r = test::SetBool(1);
print "Set Result: $r\n";
$r = test::GetBool();
print "Get Result: $r\n";
$r = test::SetBool("0");
print "Set Result: $r\n";
$r = test::GetBool();
print "Get Result: $r\n";
=== example output ===
C: Setting 1
Set Result: 0
C: Returning 1
Get Result: 1
TypeError in argument 1 of type 't_bool'
swig/perl error at ./test_pl.pl line 8.
|