summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog17
-rw-r--r--lib/soap/mapping/factory.rb14
-rw-r--r--lib/soap/mapping/registry.rb5
-rw-r--r--lib/soap/mapping/rubytypeFactory.rb4
-rw-r--r--lib/xsd/datatypes.rb16
5 files changed, 48 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 0d7d6758bf..67b18ccac4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+Thu Apr 1 19:58:37 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
+
+ * lib/soap/mapping/{factory.rb,registry.rb}: fixed illegal mapped URI
+ object with soap/marshal.
+ added URIFactory class for URI mapping. BasetypeFactory checks
+ instance_variables when original mapping is not allowed (ivar must
+ be empty). Instance of URI have instance_variables but it must be
+ llowed whenever original mapping is allowed or not.
+
+ * lib/xsd/datatypes.rb: check the smallest positive non-zero
+ single-precision float exactly instead of packing with "f".
+ [ruby-talk:88822]
+
+ * lib/soap/mapping/rubytypeFactory.rb: should not dump singleton class.
+ [ruby-dev:22588]
+ c = class << Object.new; class C; self; end; end; SOAPMarshal.dump(c)
+
Wed Mar 31 19:06:23 2004 Tanaka Akira <akr@m17n.org>
* time.c (year_leap_p): new function.
diff --git a/lib/soap/mapping/factory.rb b/lib/soap/mapping/factory.rb
index bf68701229..fe6a6de7ae 100644
--- a/lib/soap/mapping/factory.rb
+++ b/lib/soap/mapping/factory.rb
@@ -220,6 +220,20 @@ class Base64Factory_ < Factory
end
end
+class URIFactory_ < Factory
+ def obj2soap(soap_class, obj, info, map)
+ soap_obj = soap_class.new(obj)
+ mark_marshalled_obj(obj, soap_obj) if soap_obj
+ soap_obj
+ end
+
+ def soap2obj(obj_class, node, info, map)
+ obj = node.data
+ mark_unmarshalled_obj(node, obj)
+ return true, obj
+ end
+end
+
class ArrayFactory_ < Factory
def initialize(allow_original_mapping = false)
super()
diff --git a/lib/soap/mapping/registry.rb b/lib/soap/mapping/registry.rb
index 46a04e368f..8142047724 100644
--- a/lib/soap/mapping/registry.rb
+++ b/lib/soap/mapping/registry.rb
@@ -186,6 +186,7 @@ class Registry
DateTimeFactory = DateTimeFactory_.new
ArrayFactory = ArrayFactory_.new
Base64Factory = Base64Factory_.new
+ URIFactory = URIFactory_.new
TypedArrayFactory = TypedArrayFactory_.new
TypedStructFactory = TypedStructFactory_.new
@@ -213,7 +214,7 @@ class Registry
{:derived_class => true}],
[::Integer, ::SOAP::SOAPShort, BasetypeFactory,
{:derived_class => true}],
- [::URI::Generic, ::SOAP::SOAPAnyURI, BasetypeFactory,
+ [::URI::Generic, ::SOAP::SOAPAnyURI, URIFactory,
{:derived_class => true}],
[::String, ::SOAP::SOAPBase64, Base64Factory],
[::String, ::SOAP::SOAPHexBinary, Base64Factory],
@@ -259,7 +260,7 @@ class Registry
{:derived_class => true}],
[::Integer, ::SOAP::SOAPShort, BasetypeFactory,
{:derived_class => true}],
- [::URI::Generic, ::SOAP::SOAPAnyURI, BasetypeFactory,
+ [::URI::Generic, ::SOAP::SOAPAnyURI, URIFactory,
{:derived_class => true}],
[::String, ::SOAP::SOAPBase64, Base64Factory],
[::String, ::SOAP::SOAPHexBinary, Base64Factory],
diff --git a/lib/soap/mapping/rubytypeFactory.rb b/lib/soap/mapping/rubytypeFactory.rb
index a447715add..f79bc78cc7 100644
--- a/lib/soap/mapping/rubytypeFactory.rb
+++ b/lib/soap/mapping/rubytypeFactory.rb
@@ -167,7 +167,7 @@ class RubytypeFactory < Factory
unless @allow_original_mapping
return nil
end
- if obj.name.empty?
+ if obj.to_s[0] == ?#
raise TypeError.new("Can't dump anonymous class #{ obj }.")
end
param = SOAPStruct.new(TYPE_CLASS)
@@ -178,7 +178,7 @@ class RubytypeFactory < Factory
unless @allow_original_mapping
return nil
end
- if obj.name.empty?
+ if obj.to_s[0] == ?#
raise TypeError.new("Can't dump anonymous module #{ obj }.")
end
param = SOAPStruct.new(TYPE_MODULE)
diff --git a/lib/xsd/datatypes.rb b/lib/xsd/datatypes.rb
index f318e612b1..7223632b04 100644
--- a/lib/xsd/datatypes.rb
+++ b/lib/xsd/datatypes.rb
@@ -268,8 +268,11 @@ end
module FloatConstants
NaN = 0.0/0.0
- POSITIVE_INF = 1.0/0.0
+ POSITIVE_INF = +1.0/0.0
NEGATIVE_INF = -1.0/0.0
+ POSITIVE_ZERO = +1.0/POSITIVE_INF
+ NEGATIVE_ZERO = -1.0/POSITIVE_INF
+ MIN_POSITIVE_SINGLE = 2 ** -149
end
class XSDFloat < XSDAnySimpleType
@@ -320,7 +323,7 @@ private
elsif @data.infinite? == -1
'-INF'
else
- sign = (1 / @data > 0.0) ? '+' : '-'
+ sign = XSDFloat.positive?(@data) ? '+' : '-'
sign + sprintf("%.10g", @data.abs).sub(/[eE]([+-])?0+/) { 'e' + $1 }
end
end
@@ -329,11 +332,16 @@ private
def narrow32bit(f)
if f.nan? || f.infinite?
f
+ elsif f.abs < MIN_POSITIVE_SINGLE
+ XSDFloat.positive?(f) ? POSITIVE_ZERO : NEGATIVE_ZERO
else
- packed = [f].pack("f")
- (/\A\0*\z/ =~ packed)? 0.0 : f
+ f
end
end
+
+ def self.positive?(value)
+ (1 / value) > 0.0
+ end
end
# Ruby's Float is double-precision 64-bit floating point value.