From 660e839bb8ffd74308b56f100e05f7f141aa00ac Mon Sep 17 00:00:00 2001 From: nahi Date: Sat, 8 Nov 2003 09:52:42 +0000 Subject: * test/wsdl/raa/*: add new testcase for WSDL loading, parsing and reading. * test/soap/marshal/*: backport from soap4r/1.5.1. all differences are for ruby/1.6. * lib/soap/*: backport from soap4r/1.5.1. all differences are for ruby/1.6. * lib/wsdl/data.rb, lib/wsdl/xmlSchema/data.rb: move definition of ArrayTypeAttrName from ::WSDL::XMLSchema::* to ::WSDL::*. [ruby-talk:84813] * lib/wsdl/soap/definitions.rb: element name typo in custom exception struct definition which is needed for wsdlDriver; camelCase -> underscore_name. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@4925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/soap/mapping/factory.rb | 23 +++++++++++++++++++++-- lib/soap/mapping/registry.rb | 19 +++++++++++++++---- lib/soap/soap.rb | 2 +- 3 files changed, 37 insertions(+), 7 deletions(-) (limited to 'lib/soap') diff --git a/lib/soap/mapping/factory.rb b/lib/soap/mapping/factory.rb index 92ed194a4..631c16113 100644 --- a/lib/soap/mapping/factory.rb +++ b/lib/soap/mapping/factory.rb @@ -44,10 +44,29 @@ class Factory klass.allocate end else + MARSHAL_TAG = { + String => ['"', 1], + Regexp => ['/', 2], + Array => ['[', 1], + Hash => ['{', 1] + } def create_empty_object(klass) + if klass <= Struct + name = klass.name + return ::Marshal.load(sprintf("\004\006S:%c%s\000", name.length + 5, name)) + end + if MARSHAL_TAG.has_key?(klass) + tag, terminate = MARSHAL_TAG[klass] + return ::Marshal.load(sprintf("\004\006%s%s", tag, "\000" * terminate)) + end + MARSHAL_TAG.each do |k, v| + if klass < k + name = klass.name + tag, terminate = v + return ::Marshal.load(sprintf("\004\006C:%c%s%s%s", name.length + 5, name, tag, "\000" * terminate)) + end + end name = klass.name - # Below line is from TANAKA, Akira's amarshal.rb. - # See http://cvs.m17n.org/cgi-bin/viewcvs/amarshal/?cvsroot=ruby ::Marshal.load(sprintf("\004\006o:%c%s\000", name.length + 5, name)) end end diff --git a/lib/soap/mapping/registry.rb b/lib/soap/mapping/registry.rb index bdf14d4fc..e98c98a6d 100644 --- a/lib/soap/mapping/registry.rb +++ b/lib/soap/mapping/registry.rb @@ -426,10 +426,21 @@ private Mapping.set_instance_vars(obj, vars) end - def addextend2obj(obj, attr) - return unless attr - attr.split(/ /).reverse_each do |mstr| - obj.extend(Mapping.class_from_name(mstr)) + if RUBY_VERSION >= '1.8.0' + def addextend2obj(obj, attr) + return unless attr + attr.split(/ /).reverse_each do |mstr| + obj.extend(Mapping.class_from_name(mstr)) + end + end + else + # (class < false; self; end).ancestors includes "TrueClass" under 1.6... + def addextend2obj(obj, attr) + return unless attr + attr.split(/ /).reverse_each do |mstr| + m = Mapping.class_from_name(mstr) + obj.extend(m) if m.class == Module + end end end diff --git a/lib/soap/soap.rb b/lib/soap/soap.rb index 313af3a05..2543ec361 100644 --- a/lib/soap/soap.rb +++ b/lib/soap/soap.rb @@ -24,7 +24,7 @@ require 'xsd/charset' module SOAP -Version = '1.5.0' +Version = '1.5.1' EnvelopeNamespace = 'http://schemas.xmlsoap.org/soap/envelope/' EncodingNamespace = 'http://schemas.xmlsoap.org/soap/encoding/' -- cgit