Author: chug Date: Wed Oct 27 21:10:46 2010 New Revision: 1028099 URL: http://svn.apache.org/viewvc?rev=1028099&view=rev Log: QPID-2915 Qpid Cpp Messaging .NET Binding does not properly handle Qpid type VAR_VOID
* In C# map sender example, send null list and map values. * In Message ToString() display "" for null list and map values. * Do not dereference null values when determining their type. * Properly marshal native Qpid VAR_VOID data type. Modified: qpid/trunk/qpid/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.cs qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/Message.cpp qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/QpidTypeCheck.h qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/TypeTranslator.cpp Modified: qpid/trunk/qpid/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.cs URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.cs?rev=1028099&r1=1028098&r2=1028099&view=diff ============================================================================== --- qpid/trunk/qpid/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.cs (original) +++ qpid/trunk/qpid/cpp/bindings/qpid/dotnet/examples/csharp.map.sender/csharp.map.sender.cs Wed Oct 27 21:10:46 2010 @@ -79,6 +79,8 @@ namespace Org.Apache.Qpid.Messaging.exam colors.Add("red"); colors.Add("green"); colors.Add("white"); + // list contains null value + colors.Add(null); content["colorsList"] = colors; // add one of each supported amqp data type @@ -118,6 +120,8 @@ namespace Org.Apache.Qpid.Messaging.exam Guid myGuid = new Guid("000102030405060708090a0b0c0d0e0f"); content["myGuid"] = myGuid; + content["myNull"] = null; + // // Construct a message with the map content and send it synchronously // via the sender. Modified: qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/Message.cpp URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/Message.cpp?rev=1028099&r1=1028098&r2=1028099&view=diff ============================================================================== --- qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/Message.cpp (original) +++ qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/Message.cpp Wed Oct 27 21:10:46 2010 @@ -277,6 +277,12 @@ namespace Messaging { ListAsString((System::Collections::ObjectModel::Collection< System::Object^> ^)kvp.Value)); } + else if (nullptr == kvp.Value) + { + sb->AppendFormat( + "{0}=", + kvp.Key); + } else sb->AppendFormat("{0}={1}", kvp.Key, kvp.Value); } @@ -310,6 +316,10 @@ namespace Messaging { sb->Append(ListAsString((System::Collections::ObjectModel::Collection< System::Object^> ^)obj)); } + else if (nullptr == obj) + { + // no display for null objects + } else sb->Append(obj->ToString()); } Modified: qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/QpidTypeCheck.h URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/QpidTypeCheck.h?rev=1028099&r1=1028098&r2=1028099&view=diff ============================================================================== --- qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/QpidTypeCheck.h (original) +++ qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/QpidTypeCheck.h Wed Oct 27 21:10:46 2010 @@ -68,13 +68,19 @@ namespace Messaging { public: static bool ObjectIsMap (System::Object ^ theValue) - { - return (*theValue).GetType() == QpidTypeCheckConstants::mapTypeP; + { + if (nullptr == theValue) + return false; + else + return (*theValue).GetType() == QpidTypeCheckConstants::mapTypeP; } static bool ObjectIsList(System::Object ^ theValue) - { - return (*theValue).GetType() == QpidTypeCheckConstants::listTypeP; + { + if (nullptr == theValue) + return false; + else + return (*theValue).GetType() == QpidTypeCheckConstants::listTypeP; } }; }}}} Modified: qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/TypeTranslator.cpp URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/TypeTranslator.cpp?rev=1028099&r1=1028098&r2=1028099&view=diff ============================================================================== --- qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/TypeTranslator.cpp (original) +++ qpid/trunk/qpid/cpp/bindings/qpid/dotnet/src/TypeTranslator.cpp Wed Oct 27 21:10:46 2010 @@ -91,7 +91,10 @@ namespace Messaging { { // Add a simple native type to map ::qpid::types::Variant entryValue; - ManagedToNativeObject(kvp.Value, entryValue); + if (nullptr != kvp.Value) + { + ManagedToNativeObject(kvp.Value, entryValue); + } std::string entryName = QpidMarshal::ToNative(kvp.Key); qpidMap.insert(std::make_pair<std::string, ::qpid::types::Variant>(entryName, entryValue)); } @@ -144,7 +147,10 @@ namespace Messaging { { // Add a simple native type to list ::qpid::types::Variant entryValue; - ManagedToNativeObject(listObj, entryValue); + if (nullptr != listObj) + { + ManagedToNativeObject(listObj, entryValue); + } qpidList.push_back(entryValue); } } @@ -265,6 +271,10 @@ namespace Messaging { switch (vType) { + case ::qpid::types::VAR_VOID: + dict[elementName] = nullptr; + break; + case ::qpid::types::VAR_BOOL: dict[elementName] = variant.asBool(); break; @@ -358,6 +368,10 @@ namespace Messaging { switch (vType) { + case ::qpid::types::VAR_VOID: + (*managedList).Add(nullptr); + break; + case ::qpid::types::VAR_BOOL: (*managedList).Add(variant.asBool()); break; --------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:commits-subscr...@qpid.apache.org