From 6416d9a6f220e79b68869802fee3aafa03e7123d Mon Sep 17 00:00:00 2001 From: "Charles E. Rolke" Date: Thu, 7 Apr 2011 20:40:10 +0000 Subject: QPID-3192 .NET Binding for Messaging classes are missing intrinsic copy constructors. The existing 'T(const T ^)' constructor is useful for C# code but fails for Cpp/clr. This commit adds the 'T(const T %)' intrinsic copy constructor for Cpp/clr. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1089995 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/bindings/qpid/dotnet/src/Address.cpp | 24 +++++++++++++++++++++++- cpp/bindings/qpid/dotnet/src/Address.h | 1 + cpp/bindings/qpid/dotnet/src/Connection.cpp | 24 +++++++++++++++++++++++- cpp/bindings/qpid/dotnet/src/Connection.h | 1 + cpp/bindings/qpid/dotnet/src/Message.cpp | 26 ++++++++++++++++++++++++-- cpp/bindings/qpid/dotnet/src/Message.h | 1 + cpp/bindings/qpid/dotnet/src/Receiver.cpp | 25 ++++++++++++++++++++++++- cpp/bindings/qpid/dotnet/src/Receiver.h | 1 + cpp/bindings/qpid/dotnet/src/Sender.cpp | 25 ++++++++++++++++++++++++- cpp/bindings/qpid/dotnet/src/Sender.h | 1 + cpp/bindings/qpid/dotnet/src/Session.cpp | 26 +++++++++++++++++++++++++- cpp/bindings/qpid/dotnet/src/Session.h | 1 + 12 files changed, 149 insertions(+), 7 deletions(-) (limited to 'cpp/bindings') diff --git a/cpp/bindings/qpid/dotnet/src/Address.cpp b/cpp/bindings/qpid/dotnet/src/Address.cpp index b688d973ed..79a8021d9a 100644 --- a/cpp/bindings/qpid/dotnet/src/Address.cpp +++ b/cpp/bindings/qpid/dotnet/src/Address.cpp @@ -141,7 +141,7 @@ namespace Messaging { } } - // copy constructor + // Copy constructor look-alike (C#) Address::Address(const Address ^ address) { System::Exception ^ newException = nullptr; @@ -163,6 +163,28 @@ namespace Messaging { } } + // Copy constructor implicitly dereferenced (C++) + Address::Address(const Address % address) + { + System::Exception ^ newException = nullptr; + + try + { + addressp = new ::qpid::messaging::Address( + *(const_cast
(address).NativeAddress)); + } + catch (const ::qpid::types::Exception & error) + { + String ^ errmsg = gcnew String(error.what()); + newException = gcnew QpidException(errmsg); + } + + if (newException != nullptr) + { + throw newException; + } + } + // unmanaged clone Address::Address(const ::qpid::messaging::Address & addrp) { diff --git a/cpp/bindings/qpid/dotnet/src/Address.h b/cpp/bindings/qpid/dotnet/src/Address.h index e5a00d8f11..8bbc207d4e 100644 --- a/cpp/bindings/qpid/dotnet/src/Address.h +++ b/cpp/bindings/qpid/dotnet/src/Address.h @@ -64,6 +64,7 @@ namespace Messaging { // copy constructor Address(const Address ^ address); + Address(const Address % address); // unmanaged clone Address(const ::qpid::messaging::Address & addrp); diff --git a/cpp/bindings/qpid/dotnet/src/Connection.cpp b/cpp/bindings/qpid/dotnet/src/Connection.cpp index 69ace7db52..12c0e29f74 100644 --- a/cpp/bindings/qpid/dotnet/src/Connection.cpp +++ b/cpp/bindings/qpid/dotnet/src/Connection.cpp @@ -114,7 +114,7 @@ namespace Messaging { } - // Copy constructor + // Copy constructor look-alike (C#) Connection::Connection(const Connection ^ connection) { System::Exception ^ newException = nullptr; @@ -136,6 +136,28 @@ namespace Messaging { } } + // Copy constructor implicitly dereferenced (C++) + Connection::Connection(const Connection % connection) + { + System::Exception ^ newException = nullptr; + + try + { + connectionp = new ::qpid::messaging::Connection( + *(const_cast(connection).NativeConnection)); + } + catch (const ::qpid::types::Exception & error) + { + String ^ errmsg = gcnew String(error.what()); + newException = gcnew QpidException(errmsg); + } + + if (newException != nullptr) + { + throw newException; + } + } + // Destructor Connection::~Connection() diff --git a/cpp/bindings/qpid/dotnet/src/Connection.h b/cpp/bindings/qpid/dotnet/src/Connection.h index f9b62d4a08..0788f5d225 100644 --- a/cpp/bindings/qpid/dotnet/src/Connection.h +++ b/cpp/bindings/qpid/dotnet/src/Connection.h @@ -56,6 +56,7 @@ namespace Messaging { // copy constructor Connection(const Connection ^ connection); + Connection(const Connection % connection); // unmanaged clone // not defined diff --git a/cpp/bindings/qpid/dotnet/src/Message.cpp b/cpp/bindings/qpid/dotnet/src/Message.cpp index fe7825134d..e5dbf845b3 100644 --- a/cpp/bindings/qpid/dotnet/src/Message.cpp +++ b/cpp/bindings/qpid/dotnet/src/Message.cpp @@ -235,7 +235,7 @@ namespace Messaging { } } - // Copy constructor + // Copy constructor look-alike (C#) Message::Message(const Message ^ message) { System::Exception ^ newException = nullptr; @@ -257,7 +257,29 @@ namespace Messaging { } } - // Property + // Copy constructor implicitly dereferenced (C++) + Message::Message(const Message % message) + { + System::Exception ^ newException = nullptr; + + try + { + messagep = new ::qpid::messaging::Message( + *(const_cast(message).NativeMessage)); + } + catch (const ::qpid::types::Exception & error) + { + String ^ errmsg = gcnew String(error.what()); + newException = gcnew QpidException(errmsg); + } + + if (newException != nullptr) + { + throw newException; + } + } + + // Property void Message::SetProperty(System::String ^ name, System::Object ^ value) { System::Exception ^ newException = nullptr; diff --git a/cpp/bindings/qpid/dotnet/src/Message.h b/cpp/bindings/qpid/dotnet/src/Message.h index b92cc4200b..ac7f285fe5 100644 --- a/cpp/bindings/qpid/dotnet/src/Message.h +++ b/cpp/bindings/qpid/dotnet/src/Message.h @@ -71,6 +71,7 @@ namespace Messaging { // Copy constructor Message(const Message ^ message); + Message(const Message % message); // unmanaged clone Message(const ::qpid::messaging::Message & msgp); diff --git a/cpp/bindings/qpid/dotnet/src/Receiver.cpp b/cpp/bindings/qpid/dotnet/src/Receiver.cpp index 3c0d79b393..8aa77effbd 100644 --- a/cpp/bindings/qpid/dotnet/src/Receiver.cpp +++ b/cpp/bindings/qpid/dotnet/src/Receiver.cpp @@ -89,7 +89,7 @@ namespace Messaging { } - // Copy constructor + // Copy constructor look-alike (C#) Receiver::Receiver(const Receiver ^ receiver) : parentSession(receiver->parentSession) { @@ -112,6 +112,29 @@ namespace Messaging { } } + // Copy constructor implicitly dereferenced (C++) + Receiver::Receiver(const Receiver % receiver) : + parentSession(receiver.parentSession) + { + System::Exception ^ newException = nullptr; + + try + { + receiverp = new ::qpid::messaging::Receiver( + *(const_cast(receiver).NativeReceiver)); + } + catch (const ::qpid::types::Exception & error) + { + String ^ errmsg = gcnew String(error.what()); + newException = gcnew QpidException(errmsg); + } + + if (newException != nullptr) + { + throw newException; + } + } + // // Get(message) diff --git a/cpp/bindings/qpid/dotnet/src/Receiver.h b/cpp/bindings/qpid/dotnet/src/Receiver.h index e9912a61dd..8ddcc9ac01 100644 --- a/cpp/bindings/qpid/dotnet/src/Receiver.h +++ b/cpp/bindings/qpid/dotnet/src/Receiver.h @@ -65,6 +65,7 @@ namespace Messaging { // copy constructor Receiver(const Receiver ^ receiver); + Receiver(const Receiver % receiver); // unmanaged clone // undefined diff --git a/cpp/bindings/qpid/dotnet/src/Sender.cpp b/cpp/bindings/qpid/dotnet/src/Sender.cpp index 584075ef5f..3225f1a6e1 100644 --- a/cpp/bindings/qpid/dotnet/src/Sender.cpp +++ b/cpp/bindings/qpid/dotnet/src/Sender.cpp @@ -84,7 +84,7 @@ namespace Messaging { } - // Copy constructor + // Copy constructor look-alike (C#) Sender::Sender(const Sender ^ sender) : parentSession(sender->parentSession) { @@ -107,6 +107,29 @@ namespace Messaging { } } + // Copy constructor implicitly dereferenced (C++) + Sender::Sender(const Sender % sender) + : parentSession(sender.parentSession) + { + System::Exception ^ newException = nullptr; + + try + { + senderp = new ::qpid::messaging::Sender( + *(const_cast(sender).NativeSender)); + } + catch (const ::qpid::types::Exception & error) + { + String ^ errmsg = gcnew String(error.what()); + newException = gcnew QpidException(errmsg); + } + + if (newException != nullptr) + { + throw newException; + } + } + // // Send(msg) diff --git a/cpp/bindings/qpid/dotnet/src/Sender.h b/cpp/bindings/qpid/dotnet/src/Sender.h index 0e90a9f4a4..4054e87316 100644 --- a/cpp/bindings/qpid/dotnet/src/Sender.h +++ b/cpp/bindings/qpid/dotnet/src/Sender.h @@ -62,6 +62,7 @@ namespace Messaging { // copy constructor Sender(const Sender ^ sender); + Sender(const Sender % sender); ~Sender(); !Sender(); diff --git a/cpp/bindings/qpid/dotnet/src/Session.cpp b/cpp/bindings/qpid/dotnet/src/Session.cpp index 880331c588..4a6199f108 100644 --- a/cpp/bindings/qpid/dotnet/src/Session.cpp +++ b/cpp/bindings/qpid/dotnet/src/Session.cpp @@ -89,7 +89,7 @@ namespace Messaging { } - // Copy constructor + // Copy constructor look-alike (C#) Session::Session(const Session ^ session) : parentConnectionp(session->parentConnectionp) { @@ -113,6 +113,30 @@ namespace Messaging { } } + // Copy constructor implicitly dereferenced (C++) + Session::Session(const Session % session) + : parentConnectionp(session.parentConnectionp) + { + System::Exception ^ newException = nullptr; + + try + { + sessionp = new ::qpid::messaging::Session( + *(const_cast(session).NativeSession)); + + } + catch (const ::qpid::types::Exception & error) + { + String ^ errmsg = gcnew String(error.what()); + newException = gcnew QpidException(errmsg); + } + + if (newException != nullptr) + { + throw newException; + } + } + void Session::Close() { diff --git a/cpp/bindings/qpid/dotnet/src/Session.h b/cpp/bindings/qpid/dotnet/src/Session.h index 7eaad8a0a5..4d4cad75c4 100644 --- a/cpp/bindings/qpid/dotnet/src/Session.h +++ b/cpp/bindings/qpid/dotnet/src/Session.h @@ -69,6 +69,7 @@ namespace Messaging { // copy constructor Session(const Session ^ session); + Session(const Session % session); ~Session(); !Session(); -- cgit v1.2.1