|
From: David A. <da...@gm...> - 2008-03-08 23:38:26
|
NOTE: I am not subscribed to the devel list, so please CC: me on all
replies. Thank you!
The last time I checked (which may have been around the 0.67 days)
SOAP::Lite was using regular expressions to decide how to encode a
value. So, for instance, a string that looked like "1.40" would get
interpreted as being a (?) xsd:float and we'd lose the trailing zero
when it makes it to the receiver (assuming the server is soap::lite
and is generating the "1.40" string).
The simplest way to reproduce this is to return a hash ref such as:
{
"this should be a string" => "1.40",
}
After digging into this further I discovered the Sv*OK family of
perlapi macros. These allow you to test the underlying C datatype and
determine the true "type" of a scalar without having to use regular
expressions (and thus, is probably faster too).
Currently, these macros are exported by the Convert::Scalar module:
http://search.cpan.org/~mlehmann/Convert-Scalar-1.04/Scalar.pm
I just finished helping the c::s author update the API so that it is
compatible with perl 5.10's perlapi. If you are using 5.10 (or
debian, which has backported the api changes to 5.8.8) then use c::s
1.04. c::s 1.03 is suitable for pre-5.10.
So.. long story short:
Would the developers of SOAP::Lite be adverse to adding a dependency
on Convert::Scalar so that SOAP::Lite's value type-detection routine
can use Convert::Scalar's nok and pok functions for helping to
determine a scalar's underlying type?
I'm asking because I haven't yet written these patches and would like
to know whether an additional dependency would be accepted upstream or
whether this is a change that I'll have to apply to my local tree and
maintain separately.
As it is, there is no other way to test the type of a perl scalar.
Perl scalars are too magical because of the autoconversion between
double, int, and string. Convert::Scalar lets us cheat and use the
perlapi to ask these questions, which is both more robust and faster
than using regular expressions.
Thoughts?
--
David
p.s. here is the link to the perlapi reference. The "pok" and "nok"
are the Convert::Scalar exported names for SvPOK and SvNOK:
http://search.cpan.org/~rgarcia/perl-5.10.0/pod/perlapi.pod#SV_Manipulation_Functions
(scroll down a little from the link or search for "SvPOK")
Thanks for SOAP::Lite, btw!
|