Author: mvidner Date: Tue Jul 15 12:53:00 2008 New Revision: 49094 URL: http://svn.opensuse.org/viewcvs/yast?rev=49094&view=rev Log: Allow string representation of large numbers in SWIG typemaps for "integer &" (bnc#408829). Enhanced the test script. Modified: trunk/perl-bindings/package/yast2-perl-bindings.changes trunk/perl-bindings/pluglib-bindings/swig/stdc/references.i trunk/perl-bindings/pluglib-bindings/tests/Reference/Ref.cc trunk/perl-bindings/pluglib-bindings/tests/Reference/test.pl trunk/perl-bindings/pluglib-bindings/tests/Reference/test.ycp Modified: trunk/perl-bindings/package/yast2-perl-bindings.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/perl-bindings/package/yast2-perl-... ============================================================================== --- trunk/perl-bindings/package/yast2-perl-bindings.changes (original) +++ trunk/perl-bindings/package/yast2-perl-bindings.changes Tue Jul 15 12:53:00 2008 @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Tue Jul 15 12:52:33 CEST 2008 - mvidner@suse.cz + +- Allow string representation of large numbers in SWIG typemaps for + "integer &" (bnc#408829). + +------------------------------------------------------------------- Mon Jul 14 17:34:03 CEST 2008 - mvidner@suse.cz - Respect prefix when installing pluglibs. Modified: trunk/perl-bindings/pluglib-bindings/swig/stdc/references.i URL: http://svn.opensuse.org/viewcvs/yast/trunk/perl-bindings/pluglib-bindings/sw... ============================================================================== --- trunk/perl-bindings/pluglib-bindings/swig/stdc/references.i (original) +++ trunk/perl-bindings/pluglib-bindings/swig/stdc/references.i Tue Jul 15 12:53:00 2008 @@ -40,9 +40,12 @@ %typemap(in) long long *(long long dvalue), long long &(long long dvalue) { SV *sv; - if (!SvROK($input) || !(sv = SvRV($input)) || !SvIOK(sv)) { - SWIG_croak("Type error in argument $argnum of $symname. Expected a REFERENCE to INTEGER.\n"); + if (!SvROK($input) || + !(sv = SvRV($input)) || + !(SvIOK(sv) || SvNOK(sv) || SvPOK(sv)) ) { + SWIG_croak("Type error in argument $argnum of $symname. Expected a REFERENCE to INTEGER_IN_STRING.\n"); } + char * coerce = SvPV_nolen(sv); TO_QUAD(sv, &dvalue, sizeof(dvalue), $1_descriptor); $1 = &dvalue; } @@ -50,9 +53,12 @@ %typemap(in) unsigned long long *(unsigned long long dvalue), unsigned long long &(unsigned long long dvalue) { SV *sv; - if (!SvROK($input) || !(sv = SvRV($input)) || !SvIOK(sv)) { - SWIG_croak("Type error in argument $argnum of $symname. Expected a REFERENCE to INTEGER.\n"); + if (!SvROK($input) || + !(sv = SvRV($input)) || + !(SvIOK(sv) || SvNOK(sv) || SvPOK(sv)) ) { + SWIG_croak("Type error in argument $argnum of $symname. Expected a REFERENCE to INTEGER_IN_STRING.\n"); } + char * coerce = SvPV_nolen(sv); TO_UQUAD(sv, &dvalue, sizeof(dvalue), $1_descriptor); $1 = &dvalue; } Modified: trunk/perl-bindings/pluglib-bindings/tests/Reference/Ref.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/perl-bindings/pluglib-bindings/te... ============================================================================== --- trunk/perl-bindings/pluglib-bindings/tests/Reference/Ref.cc (original) +++ trunk/perl-bindings/pluglib-bindings/tests/Reference/Ref.cc Tue Jul 15 12:53:00 2008 @@ -36,7 +36,7 @@ void PLLong(long long int* x) { - x += 3; + *x += 3; } Modified: trunk/perl-bindings/pluglib-bindings/tests/Reference/test.pl URL: http://svn.opensuse.org/viewcvs/yast/trunk/perl-bindings/pluglib-bindings/te... ============================================================================== --- trunk/perl-bindings/pluglib-bindings/tests/Reference/test.pl (original) +++ trunk/perl-bindings/pluglib-bindings/tests/Reference/test.pl Tue Jul 15 12:53:00 2008 @@ -1,54 +1,68 @@ #!/usr/bin/perl +use Test::More tests => 18; use lib "./modules"; use Ref; -use Data::Dumper; +#use Devel::Peek; $ln = []; Ref::RListInt($ln); -print Dumper($ln); +ok(@$ln == (), "ref to empty list"); $l = [0, 8, 333]; -print Dumper($l); Ref::RListInt($l); -print Dumper($l); +is_deeply($l, [1, 9, 334], "ref to non-empty list"); $s = 8; -print "$s\n"; Ref::RInt($s); -print "$s\n"; +ok($s == 16, "ref to int"); Ref::PInt($s); -print "$s\n"; +ok($s == 18, "ptr to int"); # bnc#408829 -$s = 5000000000; -print "$s\n"; -Ref::RLLong($s); -print "$s\n"; -Ref::PLLong($s); -print "$s\n"; +# start as number +$y = 5000000000; +#Dump($y); +Ref::RLLong($y); +ok($y == 15000000000, "ref to llong"); +Ref::PLLong($y); +ok($y == 15000000003, "ptr to llong"); + +# start as string +$y = "5000000000"; +#Dump($y); +Ref::RLLong($y); +ok($y == 15000000000, "ref to llong"); +Ref::PLLong($y); +ok($y == 15000000003, "ptr to llong"); + +# error cases +$y = "zillion"; +Ref::RLLong($y); +ok($y == 0, " non-numeric string becomes zero"); +$y = []; +eval { Ref::RLLong($y); }; +like($@, qr/Type error in argument 1/, " list produces exception"); $b = 0; -print "$b\n"; Ref::RBool($b); -print "$b\n"; +ok($b, "ref to bool"); Ref::PBool($b); -print "$b\n"; +ok(! $b, "ptr to bool"); $s = "hu"; -print "$s\n"; -8==Ref::RStr($s) || die; -print "$s\n"; -8==Ref::PStr($s) || die; -print "$s\n"; -8==Ref::CRStr($s) || die; -print "$s\n"; -8==Ref::CPStr($s) || die; -print "$s\n"; +Ref::RStr($s); +ok($s eq "hu.A", "ref to string"); +Ref::PStr($s); +ok($s eq "hu.A.B", "ptr to string"); + +$r = Ref::CRStr($s); +ok($r == 8, "ref to const string"); +$r = Ref::CPStr($s); +ok($r == 8, "ptr to const string"); $b = 4; -print "$b\n"; Ref::REnum($b); -print "$b\n"; +ok($b == 0, "ref to enum"); Ref::PEnum($b); -print "$b\n"; +ok($b == 1, "ptr to enum"); Modified: trunk/perl-bindings/pluglib-bindings/tests/Reference/test.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/perl-bindings/pluglib-bindings/te... ============================================================================== --- trunk/perl-bindings/pluglib-bindings/tests/Reference/test.ycp (original) +++ trunk/perl-bindings/pluglib-bindings/tests/Reference/test.ycp Tue Jul 15 12:53:00 2008 @@ -18,12 +18,12 @@ y2warning("i=%1", i); // bnc#408829 -integer l = 5000000000; -y2warning("l=%1", l); -Ref::RLLong(l); -y2warning("l=%1", l); -Ref::PLLong(l); -y2warning("l=%1", l); +integer y = 5000000000; +y2warning("y=%1", y); +Ref::RLLong(y); +y2warning("y=%1", y); +Ref::PLLong(y); +y2warning("y=%1", y); boolean b = false; y2warning("b=%1", b); @@ -33,6 +33,7 @@ y2warning("b=%1", b); string s = "hu"; +Ref::RLLong(s); y2warning("s=%1", s); Ref::RStr(s); y2warning("s=%1", s); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org