diff options
Diffstat (limited to 'cpp')
199 files changed, 6588 insertions, 3271 deletions
diff --git a/cpp/allTests.py b/cpp/allTests.py index c0432217228..d3107df594f 100755 --- a/cpp/allTests.py +++ b/cpp/allTests.py @@ -66,6 +66,8 @@ tests = [ ("Ice/defaultServant", ["core"]), ("Ice/defaultValue", ["core"]), ("Ice/invoke", ["core", "novc6"]), + ("Ice/plugin", ["core"]), + ("Ice/hash", ["once"]), ("IceSSL/configuration", ["once", "novalgrind"]), # valgrind doesn't work well with openssl ("IceBox/configuration", ["core", "noipv6", "novc6", "nomingw"]), ("Freeze/dbmap", ["once", "novc6", "nomingw"]), diff --git a/cpp/config/Make.rules b/cpp/config/Make.rules index 878b330e3ce..67335ca86f6 100644 --- a/cpp/config/Make.rules +++ b/cpp/config/Make.rules @@ -255,12 +255,11 @@ endif SLICE2CPPFLAGS = $(ICECPPFLAGS) ifeq ($(ice_dir), /usr) - CPPFLAGS = LDFLAGS = $(LDPLATFORMFLAGS) $(CXXFLAGS) else ifeq ($(MinGW), yes) includedir_win = $(shell $(top_srcdir)/../cpp/config/cygpath-win.sh $(includedir)) - CPPFLAGS = -I"$(includedir_win)" + CPPFLAGS += -I"$(includedir_win)" ice_dir_win = $(shell $(top_srcdir)/../cpp/config/cygpath-win.sh $(ice_dir)) ifdef ice_src_dist LDFLAGS = $(LDPLATFORMFLAGS) $(CXXFLAGS) -L$(libdir) @@ -268,7 +267,7 @@ else LDFLAGS = $(LDPLATFORMFLAGS) $(CXXFLAGS) -L"$(ice_dir_win)\$(binsubdir)" endif else - CPPFLAGS = -I$(includedir) + CPPFLAGS += -I$(includedir) ifdef ice_src_dist LDFLAGS = $(LDPLATFORMFLAGS) $(CXXFLAGS) -L$(libdir) else diff --git a/cpp/config/Make.rules.Darwin b/cpp/config/Make.rules.Darwin index 8cbfddb6a9c..2f82bb94ed1 100644 --- a/cpp/config/Make.rules.Darwin +++ b/cpp/config/Make.rules.Darwin @@ -16,12 +16,11 @@ ifeq ($(DEVELOPER_PATH),) endif TOOLCHAIN_BIN_DIR = $(DEVELOPER_PATH)/Toolchains/XcodeDefault.xctoolchain/usr/bin -CXX = $(TOOLCHAIN_BIN_DIR)/clang++ +CXX = $(TOOLCHAIN_BIN_DIR)/clang++ #CXX = g++ CXXFLAGS = -Wall -D_REENTRANT - ifeq ($(OPTIMIZE),yes) # # By default we build binaries with both architectures when optimization is enabled. @@ -34,6 +33,12 @@ else CXXFLAGS := $(CXXARCHFLAGS) -g $(CXXFLAGS) endif +ifeq ($(CPP11), yes) +ifeq ($(CXX), $(TOOLCHAIN_BIN_DIR)/clang++) + CPPFLAGS += --std=c++11 + CXXFLAGS += --stdlib=libc++ +endif +endif # # C++ run-time libraries, necessary for linking some shared libraries. diff --git a/cpp/config/Make.rules.FreeBSD b/cpp/config/Make.rules.FreeBSD index 804f4529ddc..eded0d6bd78 100644 --- a/cpp/config/Make.rules.FreeBSD +++ b/cpp/config/Make.rules.FreeBSD @@ -18,7 +18,7 @@ $(warning ===================================================================) # This file is included by Make.rules when uname is FreeBSD # -CXX = c++ +CXX = g++ CXXFLAGS = -Wall -D_REENTRANT -D_THREAD_SAFE diff --git a/cpp/config/Make.rules.Linux b/cpp/config/Make.rules.Linux index f16b2ef558a..9e0128f6712 100644 --- a/cpp/config/Make.rules.Linux +++ b/cpp/config/Make.rules.Linux @@ -24,19 +24,23 @@ endif # Default compiler is c++ (aka g++). # ifeq ($(CXX),) - CXX = c++ + CXX = g++ endif -ifeq ($(CXX),g++) - CXX = c++ +ifeq ($(CXX),c++) + CXX = g++ endif -ifeq ($(CXX),c++) +ifeq ($(CXX),g++) ifneq ($(SUSE_i586),) CXXARCHFLAGS += -march=i586 endif + ifeq ($(CPP11), yes) + CPPFLAGS += -std=c++0x + endif + ifeq ($(MACHINE),sparc64) # # We are an ultra, at least, and so have the atomic instructions diff --git a/cpp/config/Make.rules.msvc b/cpp/config/Make.rules.msvc index 92f94704b7e..faadd595c28 100755 --- a/cpp/config/Make.rules.msvc +++ b/cpp/config/Make.rules.msvc @@ -99,8 +99,10 @@ LD_EXEFLAGS = $(LDFLAGS) !if "$(WINRT)" == "yes" ICE_OS_LIBS = kernel32.lib user32.lib +ICEUTIL_OS_LIBS = $(ICE_OS_LIBS) !else ICE_OS_LIBS = rpcrt4.lib advapi32.lib +ICEUTIL_OS_LIBS = $(ICE_OS_LIBS) DbgHelp.lib BZIP2_LIBS = libbz2$(LIBSUFFIX).lib !if "$(CPP_COMPILER)" == "VC110" diff --git a/cpp/demo/Glacier2/chat/Chat.ice b/cpp/demo/Glacier2/chat/Chat.ice index 235449c4188..46df544a028 100644 --- a/cpp/demo/Glacier2/chat/Chat.ice +++ b/cpp/demo/Glacier2/chat/Chat.ice @@ -16,7 +16,7 @@ module Demo interface ChatCallback { - ["ami"] void message(string data); + void message(string data); }; interface ChatSession extends Glacier2::Session diff --git a/cpp/demo/Glacier2/winrt/chat/App.xaml.cpp b/cpp/demo/Glacier2/winrt/chat/App.xaml.cpp index f551ed4bccb..826dbb0322a 100644 --- a/cpp/demo/Glacier2/winrt/chat/App.xaml.cpp +++ b/cpp/demo/Glacier2/winrt/chat/App.xaml.cpp @@ -1,7 +1,11 @@ -//
-// App.xaml.cpp
-// Implementation of the App class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#include "pch.h"
#include "MainPage.xaml.h"
diff --git a/cpp/demo/Glacier2/winrt/chat/App.xaml.h b/cpp/demo/Glacier2/winrt/chat/App.xaml.h index 779bf1490be..b1b6a271204 100644 --- a/cpp/demo/Glacier2/winrt/chat/App.xaml.h +++ b/cpp/demo/Glacier2/winrt/chat/App.xaml.h @@ -1,7 +1,11 @@ -//
-// App.xaml.h
-// Declaration of the App class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#pragma once
diff --git a/cpp/demo/Glacier2/winrt/chat/ChatView.xaml.cpp b/cpp/demo/Glacier2/winrt/chat/ChatView.xaml.cpp index a9c505c2aae..0b05884d269 100644 --- a/cpp/demo/Glacier2/winrt/chat/ChatView.xaml.cpp +++ b/cpp/demo/Glacier2/winrt/chat/ChatView.xaml.cpp @@ -1,7 +1,11 @@ -//
-// ChatView.xaml.cpp
-// Implementation of the ChatView class
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#include "pch.h"
#include "ChatView.xaml.h"
@@ -21,8 +25,6 @@ using namespace Windows::UI::Xaml::Input; using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
-// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
-
ChatView::ChatView()
{
InitializeComponent();
@@ -43,23 +45,12 @@ ChatView::appendMessage(String^ message) Scroller->ScrollToVerticalOffset(Scroller->ScrollableHeight);
}
-/// <summary>
-/// Invoked when this page is about to be displayed in a Frame.
-/// </summary>
-/// <param name="e">Event data that describes how this page was reached. The Parameter
-/// property is typically used to configure the page.</param>
-void ChatView::OnNavigatedTo(NavigationEventArgs^ e)
-{
- (void) e; // Unused parameter
-}
-
-
void chat::ChatView::inputKeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
{
if(e->Key == Windows::System::VirtualKey::Enter && !input->Text->IsEmpty())
{
string msg = IceUtil::wstringToString(input->Text->Data());
- input->Text = ref new String();
+ input->Text = "";
MainPage::instance()->coordinator()->say(msg);
}
}
diff --git a/cpp/demo/Glacier2/winrt/chat/ChatView.xaml.h b/cpp/demo/Glacier2/winrt/chat/ChatView.xaml.h index 15de1de2aea..6ec11949560 100644 --- a/cpp/demo/Glacier2/winrt/chat/ChatView.xaml.h +++ b/cpp/demo/Glacier2/winrt/chat/ChatView.xaml.h @@ -1,7 +1,11 @@ -//
-// ChatView.xaml.h
-// Declaration of the ChatView class
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#pragma once
@@ -9,25 +13,18 @@ namespace chat
{
- /// <summary>
- /// An empty page that can be used on its own or navigated to within a Frame.
- /// </summary>
- public ref class ChatView sealed
- {
- public:
-
- ChatView();
-
- void setError(Platform::String^ err);
- void appendMessage(Platform::String^ message);
-
- protected:
+public ref class ChatView sealed
+{
+public:
- virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
+ ChatView();
+ void setError(Platform::String^ err);
+ void appendMessage(Platform::String^ message);
- private:
+private:
- void inputKeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
- };
+ void inputKeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
+};
+
}
diff --git a/cpp/demo/Glacier2/winrt/chat/LoginView.xaml.cpp b/cpp/demo/Glacier2/winrt/chat/LoginView.xaml.cpp index 7afa5d9320e..8c7ed5927b5 100644 --- a/cpp/demo/Glacier2/winrt/chat/LoginView.xaml.cpp +++ b/cpp/demo/Glacier2/winrt/chat/LoginView.xaml.cpp @@ -1,7 +1,11 @@ -//
-// LoginView.xaml.cpp
-// Implementation of the LoginView class
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#include "pch.h"
#include "LoginView.xaml.h"
@@ -20,8 +24,6 @@ using namespace Windows::UI::Xaml::Input; using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
-// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
-
LoginView::LoginView()
{
InitializeComponent();
@@ -36,12 +38,7 @@ LoginView::setError(String^ err) error->Text = err;
}
-/// <summary>
-/// Invoked when this page is about to be displayed in a Frame.
-/// </summary>
-/// <param name="e">Event data that describes how this page was reached. The Parameter
-/// property is typically used to configure the page.</param>
-void LoginView::OnNavigatedTo(NavigationEventArgs^ e)
+void LoginView::OnNavigatedTo(NavigationEventArgs^)
{
LoginData loginData = MainPage::instance()->coordinator()->loginData();
if(!loginData.hostname.empty())
@@ -56,7 +53,6 @@ void LoginView::OnNavigatedTo(NavigationEventArgs^ e) {
password->Password = ref new String(IceUtil::stringToWstring(loginData.password).c_str());
}
- (void) e; // Unused parameter
}
void chat::LoginView::signinClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
diff --git a/cpp/demo/Glacier2/winrt/chat/LoginView.xaml.h b/cpp/demo/Glacier2/winrt/chat/LoginView.xaml.h index dc4e60f5118..87317e73b49 100644 --- a/cpp/demo/Glacier2/winrt/chat/LoginView.xaml.h +++ b/cpp/demo/Glacier2/winrt/chat/LoginView.xaml.h @@ -1,7 +1,11 @@ -//
-// LoginView.xaml.h
-// Declaration of the LoginView class
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#pragma once
@@ -9,27 +13,25 @@ namespace chat
{
- ref class MainPage;
-
- /// <summary>
- /// An empty page that can be used on its own or navigated to within a Frame.
- /// </summary>
- public ref class LoginView sealed
- {
- public:
- LoginView();
+public ref class LoginView sealed
+{
+public:
- void setError(Platform::String^ err);
+ LoginView();
+ void setError(Platform::String^);
+ void signinCompleted()
+ {
+ signin->IsEnabled = true;
+ }
- protected:
+protected:
- virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
+ virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^) override;
- private:
+private:
- void signinClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ void signinClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^);
+};
- friend ref class MainPage;
- };
}
diff --git a/cpp/demo/Glacier2/winrt/chat/MainPage.xaml.cpp b/cpp/demo/Glacier2/winrt/chat/MainPage.xaml.cpp index 20c74f86162..3f110ecd409 100644 --- a/cpp/demo/Glacier2/winrt/chat/MainPage.xaml.cpp +++ b/cpp/demo/Glacier2/winrt/chat/MainPage.xaml.cpp @@ -1,7 +1,11 @@ -//
-// MainPage.xaml.cpp
-// Implementation of the MainPage class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#include "pch.h"
#include "MainPage.xaml.h"
@@ -24,44 +28,28 @@ using namespace Windows::UI::Xaml::Interop; using namespace std;
-// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
-
MainPage^ MainPage::_instance = nullptr;
-class DispatcherI : virtual public Ice::Dispatcher
-{
-public:
-
- DispatcherI(CoreDispatcher^ dispatcher) :
- _dispatcher(dispatcher)
- {
- }
-
- virtual void dispatch(const Ice::DispatcherCallPtr& call, const Ice::ConnectionPtr&)
- {
- _dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([=]()
- {
- call->run();
- }, CallbackContext::Any));
- }
-
-private:
-
- CoreDispatcher^ _dispatcher;
-};
-
Coordinator::Coordinator(CoreDispatcher^ dispatcher) :
_dispatcher(dispatcher)
{
}
void
-Coordinator::signIn(LoginData loginData)
+Coordinator::signIn(const LoginData& loginData)
{
_loginData = loginData;
Ice::InitializationData id;
id.properties = Ice::createProperties();
- id.dispatcher = new DispatcherI(_dispatcher);
+ id.dispatcher = Ice::newDispatcher(
+ [=](const Ice::DispatcherCallPtr& call, const Ice::ConnectionPtr&)
+ {
+ this->_dispatcher->RunAsync(
+ CoreDispatcherPriority::Normal, ref new DispatchedHandler([=]()
+ {
+ call->run();
+ }, CallbackContext::Any));
+ });
Glacier2::SessionFactoryHelperPtr factory = new Glacier2::SessionFactoryHelper(id, this);
Ice::Identity identity;
identity.name = "router";
@@ -82,9 +70,12 @@ Coordinator::say(const std::string& msg) {
try
{
- Demo::Callback_ChatSession_sayPtr cb = Demo::newCallback_ChatSession_say(this, &Coordinator::sayCallbackSuccess,
- &Coordinator::sayCallbackError);
- _chat->begin_say(msg, cb);
+ _chat->begin_say(msg, nullptr, [](const Ice::Exception& ex)
+ {
+ ostringstream os;
+ os << "Connect failed:\n" << ex << endl;
+ MainPage::instance()->setError(os.str());
+ });
}
catch(const Ice::CommunicatorDestroyedException& ex)
{
@@ -95,38 +86,11 @@ Coordinator::say(const std::string& msg) }
void
-Coordinator::sayCallbackSuccess()
-{
-}
-
-void
-Coordinator::sayCallbackError(const Ice::Exception& ex)
-{
- ostringstream os;
- os << "Connect failed:\n" << ex << endl;
- MainPage::instance()->setError(os.str());
-}
-
-void
Coordinator::createdCommunicator(const Glacier2::SessionHelperPtr&)
{
}
void
-Coordinator::setCallbackSuccess()
-{
- MainPage::instance()->setConnected(true);
-}
-
-void
-Coordinator::setCallbackError(const Ice::Exception& ex)
-{
- ostringstream os;
- os << "Connect failed:\n" << ex << endl;
- MainPage::instance()->setError(os.str());
-}
-
-void
Coordinator::connected(const Glacier2::SessionHelperPtr& session)
{
if(_session != session)
@@ -136,9 +100,17 @@ Coordinator::connected(const Glacier2::SessionHelperPtr& session) try
{
_chat = Demo::ChatSessionPrx::uncheckedCast(session->session());
- Demo::Callback_ChatSession_setCallbackPtr cb =
- Demo::newCallback_ChatSession_setCallback(this, &Coordinator::setCallbackSuccess, &Coordinator::setCallbackError);
- _chat->begin_setCallback(Demo::ChatCallbackPrx::uncheckedCast(_session->addWithUUID(this)), cb);
+ _chat->begin_setCallback(Demo::ChatCallbackPrx::uncheckedCast(_session->addWithUUID(this)),
+ []()
+ {
+ MainPage::instance()->setConnected(true);
+ },
+ [](const Ice::Exception& ex)
+ {
+ ostringstream os;
+ os << "Connect failed:\n" << ex << endl;
+ MainPage::instance()->setError(os.str());
+ });
}
catch(const Ice::CommunicatorDestroyedException& ex)
{
@@ -167,7 +139,7 @@ Coordinator::message(const string& msg, const Ice::Current&) {
try
{
- MainPage::instance()->_chatView->appendMessage(ref new String(IceUtil::stringToWstring(msg).c_str()));
+ MainPage::instance()->appendMessage(ref new String(IceUtil::stringToWstring(msg).c_str()));
}
catch(const Ice::CommunicatorDestroyedException& ex)
{
@@ -195,6 +167,12 @@ MainPage::MainPage() setConnected(false);
}
+void
+MainPage::appendMessage(String^ message)
+{
+ _chatView->appendMessage(message);
+}
+
MainPage^
MainPage::instance()
{
@@ -217,7 +195,7 @@ MainPage::setConnected(bool connected) }
TypeName page = {pageName, TypeKind::Custom};
main->Navigate(page, this);
- _loginView->signin->IsEnabled = true;
+ _loginView->signinCompleted();
}
void
@@ -227,16 +205,6 @@ MainPage::setError(const std::string& err) _loginView->setError(ref new String(IceUtil::stringToWstring(err).c_str()));
}
-/// <summary>
-/// Invoked when this page is about to be displayed in a Frame.
-/// </summary>
-/// <param name="e">Event data that describes how this page was reached. The Parameter
-/// property is typically used to configure the page.</param>
-void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
-{
- (void) e; // Unused parameter
-}
-
void chat::MainPage::signoutClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
_coordinator->destroy();
diff --git a/cpp/demo/Glacier2/winrt/chat/MainPage.xaml.h b/cpp/demo/Glacier2/winrt/chat/MainPage.xaml.h index 717930ecc99..9b503992663 100644 --- a/cpp/demo/Glacier2/winrt/chat/MainPage.xaml.h +++ b/cpp/demo/Glacier2/winrt/chat/MainPage.xaml.h @@ -1,7 +1,11 @@ -//
-// MainPage.xaml.h
-// Declaration of the MainPage class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#pragma once
@@ -14,89 +18,80 @@ namespace chat
{
- struct LoginData
- {
- std::string hostname;
- std::string username;
- std::string password;
- };
+struct LoginData
+{
+ std::string hostname;
+ std::string username;
+ std::string password;
+};
- class Coordinator : virtual public Glacier2::SessionCallback,
- virtual public Demo::ChatCallback
- {
- public:
+class Coordinator : virtual public Glacier2::SessionCallback,
+ virtual public Demo::ChatCallback
+{
+public:
- Coordinator(Windows::UI::Core::CoreDispatcher^);
+ Coordinator(Windows::UI::Core::CoreDispatcher^);
- void signIn(LoginData);
- LoginData loginData();
+ void signIn(const LoginData&);
+ LoginData loginData();
- //
- // Session callback
- //
- virtual void createdCommunicator(const Glacier2::SessionHelperPtr& session);
- virtual void connected(const Glacier2::SessionHelperPtr&);
- virtual void disconnected(const Glacier2::SessionHelperPtr&);
- virtual void connectFailed(const Glacier2::SessionHelperPtr&, const Ice::Exception&);
+ //
+ // Session callback
+ //
+ virtual void createdCommunicator(const Glacier2::SessionHelperPtr&);
+ virtual void connected(const Glacier2::SessionHelperPtr&);
+ virtual void disconnected(const Glacier2::SessionHelperPtr&);
+ virtual void connectFailed(const Glacier2::SessionHelperPtr&, const Ice::Exception&);
- //
- // Chat callback
- //
- virtual void message(const std::string& data, const Ice::Current&);
-
- void setCallbackSuccess();
- void setCallbackError(const Ice::Exception&);
-
- void say(const std::string&);
- void sayCallbackSuccess();
- void sayCallbackError(const Ice::Exception&);
+ //
+ // Chat callback
+ //
+ virtual void message(const std::string& data, const Ice::Current&);
+
+ //
+ // Chat session.
+ //
+ void say(const std::string&);
+ void destroy();
+
+private:
+
+ Demo::ChatSessionPrx _chat;
+ Glacier2::SessionHelperPtr _session;
+ Windows::UI::Core::CoreDispatcher^ _dispatcher;
+ LoginData _loginData;
+};
+typedef IceUtil::Handle<Coordinator> CoordinatorPtr;
+
+public ref class MainPage sealed
+{
+public:
- void destroy();
+ MainPage();
- private:
+ static MainPage^ instance();
+ void setConnected(bool);
+ void appendMessage(Platform::String^);
- Demo::ChatSessionPrx _chat;
- Glacier2::SessionHelperPtr _session;
- Windows::UI::Core::CoreDispatcher^ _dispatcher;
- LoginData _loginData;
- };
- typedef IceUtil::Handle<Coordinator> CoordinatorPtr;
+private:
+
+ virtual void setError(const std::string&);
- /// <summary>
- /// An empty page that can be used on its own or navigated to within a Frame.
- /// </summary>
- public ref class MainPage sealed
+ CoordinatorPtr coordinator()
{
- public:
-
- MainPage();
-
- static MainPage^ instance();
-
- void setConnected(bool);
-
- protected:
-
- virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
-
- private:
-
- virtual void setError(const std::string&);
+ return _coordinator;
+ }
+ CoordinatorPtr _coordinator;
- CoordinatorPtr coordinator()
- {
- return _coordinator;
- }
- CoordinatorPtr _coordinator;
+ static MainPage^ _instance;
- static MainPage^ _instance;
+ friend ref class LoginView;
+ friend ref class ChatView;
+ friend class Coordinator;
- friend ref class LoginView;
- friend ref class ChatView;
- friend class Coordinator;
+ LoginView^ _loginView;
+ ChatView^ _chatView;
+ void signoutClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+};
- LoginView^ _loginView;
- ChatView^ _chatView;
- void signoutClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
- };
}
diff --git a/cpp/demo/Glacier2/winrt/chat/chat.vcxproj b/cpp/demo/Glacier2/winrt/chat/chat.vcxproj index f10b56c07e7..5a422517ed5 100644 --- a/cpp/demo/Glacier2/winrt/chat/chat.vcxproj +++ b/cpp/demo/Glacier2/winrt/chat/chat.vcxproj @@ -209,10 +209,10 @@ </ClCompile>
</ItemGroup>
<ItemGroup>
- <SDKReference Include="IceWinRT, Version=3.4" />
+ <Text Include="README.txt" />
</ItemGroup>
<ItemGroup>
- <Text Include="README.txt" />
+ <SDKReference Include="IceWinRT, Version=3.4" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/cpp/demo/Ice/MFC/client/Hello.ice b/cpp/demo/Ice/MFC/client/Hello.ice index da4c993409d..bb7f6d95924 100644 --- a/cpp/demo/Ice/MFC/client/Hello.ice +++ b/cpp/demo/Ice/MFC/client/Hello.ice @@ -14,8 +14,8 @@ module Demo interface Hello { - ["ami"] idempotent void sayHello(int delay); - ["ami"] void shutdown(); + idempotent void sayHello(int delay); + void shutdown(); }; }; diff --git a/cpp/demo/Ice/MFC/client/stdafx.h b/cpp/demo/Ice/MFC/client/stdafx.h index 06b52e61d72..c7ab72d2085 100755 --- a/cpp/demo/Ice/MFC/client/stdafx.h +++ b/cpp/demo/Ice/MFC/client/stdafx.h @@ -13,39 +13,20 @@ #pragma once -// -// For VC6 and STLport -// -#if !defined(NDEBUG) && !defined(_STLP_DEBUG) -# define _STLP_DEBUG -#endif - #ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +# define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif -// Change this to the appropriate value to target Windows 98 and -// Windows 2000 or later if not using VC6. #ifndef _WIN32_WINNT -# if defined(_MSC_VER) && _MSC_VER < 1500 -# define _WIN32_WINNT 0x0400 -# endif +# define _WIN32_WINNT 0x0501 #endif #ifndef WINVER -# if defined(_MSC_VER) && _MSC_VER > 1300 && _MSC_VER < 1600 -# define WINVER 0x0400 -# elif defined(_MSC_VER) && _MSC_VER >=1600 - # define WINVER 0x0501 -# endif +# define WINVER 0x0501 #endif -#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. -# if defined(_MSC_VER) && _MSC_VER >=1600 -# define _WIN32_IE 0x0500 // Change this to the appropriate value to target IE 5.0 or later. -# else -# define _WIN32_IE 0x0400 -# endif +#ifndef _WIN32_IE // Allow use of features specific to IE 5.0 or later. +# define _WIN32_IE 0x0500 #endif #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit @@ -53,12 +34,11 @@ // turns off MFC's hiding of some common and often safely ignored warning messages #define _AFX_ALL_WARNINGS -#include <afxwin.h> // MFC core and standard components -#include <afxext.h> // MFC extensions +#include <afxwin.h> // MFC core and standard components +#include <afxext.h> // MFC extensions -#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls #ifndef _AFX_NO_AFXCMN_SUPPORT -#include <afxcmn.h> // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT +# include <afxcmn.h> // MFC support for Windows Common Controls +#endif #include <Ice/Ice.h> diff --git a/cpp/demo/Ice/MFC/server/stdafx.h b/cpp/demo/Ice/MFC/server/stdafx.h index 06b52e61d72..89b2b07356d 100755 --- a/cpp/demo/Ice/MFC/server/stdafx.h +++ b/cpp/demo/Ice/MFC/server/stdafx.h @@ -13,39 +13,20 @@ #pragma once -// -// For VC6 and STLport -// -#if !defined(NDEBUG) && !defined(_STLP_DEBUG) -# define _STLP_DEBUG -#endif - #ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +# define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif -// Change this to the appropriate value to target Windows 98 and -// Windows 2000 or later if not using VC6. #ifndef _WIN32_WINNT -# if defined(_MSC_VER) && _MSC_VER < 1500 -# define _WIN32_WINNT 0x0400 -# endif +# define _WIN32_WINNT 0x0501 #endif #ifndef WINVER -# if defined(_MSC_VER) && _MSC_VER > 1300 && _MSC_VER < 1600 -# define WINVER 0x0400 -# elif defined(_MSC_VER) && _MSC_VER >=1600 - # define WINVER 0x0501 -# endif +# define WINVER 0x0501 #endif -#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. -# if defined(_MSC_VER) && _MSC_VER >=1600 -# define _WIN32_IE 0x0500 // Change this to the appropriate value to target IE 5.0 or later. -# else -# define _WIN32_IE 0x0400 -# endif +#ifndef _WIN32_IE // Allow use of features specific to IE 5.0 or later. +# define _WIN32_IE 0x0500 #endif #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit @@ -53,12 +34,11 @@ // turns off MFC's hiding of some common and often safely ignored warning messages #define _AFX_ALL_WARNINGS -#include <afxwin.h> // MFC core and standard components -#include <afxext.h> // MFC extensions +#include <afxwin.h> // MFC core and standard components +#include <afxext.h> // MFC extensions -#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls #ifndef _AFX_NO_AFXCMN_SUPPORT -#include <afxcmn.h> // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT +# include <afxcmn.h> // MFC support for Windows Common Controls +#endif -#include <Ice/Ice.h> +#include <Ice/Ice.h>
\ No newline at end of file diff --git a/cpp/demo/Ice/async/Hello.ice b/cpp/demo/Ice/async/Hello.ice index 9a1f68b3492..6a32e05fffa 100644 --- a/cpp/demo/Ice/async/Hello.ice +++ b/cpp/demo/Ice/async/Hello.ice @@ -18,7 +18,7 @@ exception RequestCanceledException interface Hello { - ["ami", "amd"] idempotent void sayHello(int delay) + ["amd"] idempotent void sayHello(int delay) throws RequestCanceledException; void shutdown(); diff --git a/cpp/demo/Ice/winrt/bidir/App.xaml.cpp b/cpp/demo/Ice/winrt/bidir/App.xaml.cpp index d2b443c3643..d3b64f4d024 100644 --- a/cpp/demo/Ice/winrt/bidir/App.xaml.cpp +++ b/cpp/demo/Ice/winrt/bidir/App.xaml.cpp @@ -1,7 +1,12 @@ -//
-// App.xaml.cpp
-// Implementation of the App class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
#include "pch.h"
#include "MainPage.xaml.h"
diff --git a/cpp/demo/Ice/winrt/bidir/App.xaml.h b/cpp/demo/Ice/winrt/bidir/App.xaml.h index 7cce50550bb..103a440e38e 100644 --- a/cpp/demo/Ice/winrt/bidir/App.xaml.h +++ b/cpp/demo/Ice/winrt/bidir/App.xaml.h @@ -1,7 +1,11 @@ -//
-// App.xaml.h
-// Declaration of the App class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#pragma once
diff --git a/cpp/demo/Ice/winrt/bidir/MainPage.xaml.cpp b/cpp/demo/Ice/winrt/bidir/MainPage.xaml.cpp index 11f76249417..6f234cdfec5 100644 --- a/cpp/demo/Ice/winrt/bidir/MainPage.xaml.cpp +++ b/cpp/demo/Ice/winrt/bidir/MainPage.xaml.cpp @@ -1,7 +1,11 @@ -//
-// MainPage.xaml.cpp
-// Implementation of the MainPage class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#include "pch.h"
#include "MainPage.xaml.h"
@@ -29,23 +33,11 @@ CallbackReceiverI::callback(Ice::Int num, const Ice::Current& current) _page->callback(num, current);
}
-// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
-
MainPage::MainPage()
{
InitializeComponent();
}
-/// <summary>
-/// Invoked when this page is about to be displayed in a Frame.
-/// </summary>
-/// <param name="e">Event data that describes how this page was reached. The Parameter
-/// property is typically used to configure the page.</param>
-void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
-{
- (void) e; // Unused parameter
-}
-
void bidir::MainPage::startClient_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
try
@@ -58,7 +50,8 @@ void bidir::MainPage::startClient_Click(Platform::Object^ sender, Windows::UI::X _communicator = Ice::initialize(initData);
CallbackSenderPrx server = CallbackSenderPrx::checkedCast(
- _communicator->stringToProxy("sender:tcp -h " + IceUtil::wstringToString(hostname->Text->Data()) + " -p 10000"));
+ _communicator->stringToProxy("sender:tcp -h " + IceUtil::wstringToString(hostname->Text->Data()) +
+ " -p 10000"));
if(!server)
{
@@ -75,7 +68,14 @@ void bidir::MainPage::startClient_Click(Platform::Object^ sender, Windows::UI::X adapter->add(cr, ident);
adapter->activate();
server->ice_getConnection()->setAdapter(adapter);
- server->addClient(ident);
+ server->begin_addClient(ident, nullptr, [=](const Ice::Exception& ex)
+ {
+ ostringstream os;
+ os << ex << endl;
+ print(os.str());
+ startClient->IsEnabled = true;
+ stopClient->IsEnabled = false;
+ });
}
catch(const Ice::Exception& ex)
{
@@ -121,10 +121,13 @@ bidir::MainPage::callback(Ice::Int num, const Ice::Current&) void
bidir::MainPage::print(const std::string& message)
{
- this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([=] ()
- {
- output->Text += ref new String(IceUtil::stringToWstring(message).c_str());
- output->UpdateLayout();
- scroller->ScrollToVerticalOffset(scroller->ScrollableHeight);
- }, CallbackContext::Any));
+ this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal,
+ ref new DispatchedHandler(
+ [=] ()
+ {
+ output->Text += ref new String(IceUtil::stringToWstring(message).c_str());
+ output->UpdateLayout();
+ scroller->ScrollToVerticalOffset(scroller->ScrollableHeight);
+ },
+ CallbackContext::Any));
}
diff --git a/cpp/demo/Ice/winrt/bidir/MainPage.xaml.h b/cpp/demo/Ice/winrt/bidir/MainPage.xaml.h index cec23cb50d5..a68c98d50c8 100644 --- a/cpp/demo/Ice/winrt/bidir/MainPage.xaml.h +++ b/cpp/demo/Ice/winrt/bidir/MainPage.xaml.h @@ -1,7 +1,11 @@ -//
-// MainPage.xaml.h
-// Declaration of the MainPage class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#pragma once
@@ -12,44 +16,38 @@ namespace bidir
{
- ref class MainPage;
+ref class MainPage;
- class CallbackReceiverI : public Demo::CallbackReceiver
- {
- public:
+class CallbackReceiverI : public Demo::CallbackReceiver
+{
+public:
- CallbackReceiverI(MainPage^ page) : _page(page)
- {
- }
+ CallbackReceiverI(MainPage^ page) : _page(page)
+ {
+ }
- virtual void
- callback(Ice::Int, const Ice::Current&);
+ virtual void
+ callback(Ice::Int, const Ice::Current&);
- private:
+private:
- MainPage^ _page;
- };
-
- /// <summary>
- /// An empty page that can be used on its own or navigated to within a Frame.
- /// </summary>
- public ref class MainPage sealed
- {
- public:
- MainPage();
+ MainPage^ _page;
+};
- protected:
+public ref class MainPage sealed
+{
+public:
+ MainPage();
- virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
+private:
- private:
+ friend class CallbackReceiverI;
- friend class CallbackReceiverI;
+ void callback(Ice::Int, const Ice::Current&);
+ void print(const std::string&);
+ void startClient_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ void stopClient_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ Ice::CommunicatorPtr _communicator;
+};
- void callback(Ice::Int, const Ice::Current&);
- void print(const std::string&);
- void startClient_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
- void stopClient_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
- Ice::CommunicatorPtr _communicator;
- };
}
diff --git a/cpp/demo/Ice/winrt/bidir/bidir.vcxproj b/cpp/demo/Ice/winrt/bidir/bidir.vcxproj index 275b3cabf19..855d494f803 100644 --- a/cpp/demo/Ice/winrt/bidir/bidir.vcxproj +++ b/cpp/demo/Ice/winrt/bidir/bidir.vcxproj @@ -189,10 +189,10 @@ </ClCompile>
</ItemGroup>
<ItemGroup>
- <SDKReference Include="IceWinRT, Version=3.4" />
+ <Text Include="README.txt" />
</ItemGroup>
<ItemGroup>
- <Text Include="README.txt" />
+ <SDKReference Include="IceWinRT, Version=3.4" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/cpp/demo/Ice/winrt/hello/App.xaml.cpp b/cpp/demo/Ice/winrt/hello/App.xaml.cpp index e23a2601ed3..dd08ad621d1 100644 --- a/cpp/demo/Ice/winrt/hello/App.xaml.cpp +++ b/cpp/demo/Ice/winrt/hello/App.xaml.cpp @@ -1,7 +1,11 @@ -//
-// App.xaml.cpp
-// Implementation of the App class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#include "pch.h"
#include "MainPage.xaml.h"
diff --git a/cpp/demo/Ice/winrt/hello/MainPage.xaml.cpp b/cpp/demo/Ice/winrt/hello/MainPage.xaml.cpp index 25910c04340..711291d6bb5 100644 --- a/cpp/demo/Ice/winrt/hello/MainPage.xaml.cpp +++ b/cpp/demo/Ice/winrt/hello/MainPage.xaml.cpp @@ -1,7 +1,11 @@ -//
-// MainPage.xaml.cpp
-// Implementation of the MainPage class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#include "pch.h"
#include "MainPage.xaml.h"
@@ -22,105 +26,29 @@ using namespace Windows::UI::Xaml::Input; using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
-class DispatcherI : virtual public Ice::Dispatcher
-{
-public:
-
- DispatcherI(CoreDispatcher^ dispatcher) :
- _dispatcher(dispatcher)
- {
- }
-
- virtual void dispatch(const Ice::DispatcherCallPtr& call, const Ice::ConnectionPtr&)
- {
- _dispatcher->RunAsync(CoreDispatcherPriority::Normal,
- ref new DispatchedHandler([=]()
- {
- call->run();
- }, CallbackContext::Any));
- }
-
-private:
-
- CoreDispatcher^ _dispatcher;
-};
-
-// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
-
MainPage::MainPage()
{
InitializeComponent();
mode->SelectedIndex = 0;
Ice::InitializationData id;
- id.dispatcher = new DispatcherI(this->Dispatcher);
+ id.dispatcher = Ice::newDispatcher(
+ [=](const Ice::DispatcherCallPtr& call, const Ice::ConnectionPtr&)
+ {
+ this->Dispatcher->RunAsync(
+ CoreDispatcherPriority::Normal, ref new DispatchedHandler([=]()
+ {
+ call->run();
+ }, CallbackContext::Any));
+ });
_communicator = Ice::initialize(id);
}
-/// <summary>
-/// Invoked when this page is about to be displayed in a Frame.
-/// </summary>
-/// <param name="e">Event data that describes how this page was reached. The Parameter
-/// property is typically used to configure the page.</param>
-void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
-{
- (void) e; // Unused parameter
-}
-
-HelloCallback::HelloCallback(MainPage^ page) :
- _page(page)
-{
-}
-
-void
-HelloCallback::helloSent(bool sent)
-{
- _page->helloSent(sent);
-}
-
-void
-HelloCallback::helloSuccess()
-{
- _page->helloSuccess();
-}
-
-void
-HelloCallback::helloFailure(const Ice::Exception& ex)
-{
- _page->helloFailure(ex);
-}
-
-void
-hello::MainPage::helloSuccess()
-{
- print("Ready.");
-}
-
-void
-hello::MainPage::helloFailure(const Ice::Exception& ex)
-{
- ostringstream os;
- os << ex;
- print(os.str());
-}
-
-void
-hello::MainPage::helloSent(bool)
-{
- if(mode->SelectedIndex == 0 || mode->SelectedIndex == 1)
- {
- print("Waiting for response.");
- }
- else
- {
- print("Ready.");
- }
-}
-
Demo::HelloPrx
hello::MainPage::proxy()
{
string h = IceUtil::wstringToString(hostname->Text->Data());
- Ice::ObjectPrx prx = _communicator->stringToProxy("hello:tcp -h " + h + " -p 10000:ssl -h " + h + " -p 10001:udp -h " + h + " -p 10000");
+ Ice::ObjectPrx prx = _communicator->stringToProxy("hello:tcp -h " + h + " -p 10000:ssl -h " + h +
+ " -p 10001:udp -h " + h + " -p 10000");
switch(mode->SelectedIndex)
{
case 0:
@@ -196,16 +124,52 @@ hello::MainPage::hello_Click(Platform::Object^ sender, Windows::UI::Xaml::Routed if(!isBatch())
{
print("Sending sayHello request.");
- Demo::Callback_Hello_sayHelloPtr cb =
- Demo::newCallback_Hello_sayHello(new HelloCallback(this),
- &HelloCallback::helloSuccess,
- &HelloCallback::helloFailure,
- &HelloCallback::helloSent);
- prx->begin_sayHello(static_cast<int>(delay->Value * 1000), cb);
+ _response = false;
+ hello->IsEnabled = false;
+ int deliveryMode = mode->SelectedIndex;
+ Ice::AsyncResultPtr result = prx->begin_sayHello(static_cast<int>(delay->Value * 1000),
+ [=]()
+ {
+ hello->IsEnabled = true;
+ this->_response = true;
+ print("Ready.");
+ },
+ [=](const Ice::Exception& ex)
+ {
+ hello->IsEnabled = true;
+ this->_response = true;
+ ostringstream os;
+ os << ex;
+ print(os.str());
+ },
+ [=](bool sentSynchronously)
+ {
+ if(this->_response)
+ {
+ return; // Response was received already.
+ }
+ if(deliveryMode <= 1)
+ {
+ print("Waiting for response.");
+ }
+ else if(!sentSynchronously)
+ {
+ print("Ready.");
+ }
+ });
+
+ if(!result->sentSynchronously())
+ {
+ print("Sending request");
+ }
+ else if(deliveryMode > 1)
+ {
+ print("Ready");
+ }
}
else
{
- print("Queued sayHello request.");
+ print("Queued hello request.");
prx->sayHello((int)(delay->Value * 1000));
flush->IsEnabled = true;
}
@@ -243,10 +207,16 @@ void hello::MainPage::flush_Click(Platform::Object^ sender, Windows::UI::Xaml::R try
{
flush->IsEnabled = false;
- Ice::Callback_Communicator_flushBatchRequestsPtr cb =
- Ice::newCallback_Communicator_flushBatchRequests(new HelloCallback(this), &HelloCallback::helloFailure);
- _communicator->begin_flushBatchRequests(cb);
- print("Flushed batch requests.");
+ _communicator->begin_flushBatchRequests([=](const Ice::Exception& ex)
+ {
+ ostringstream os;
+ os << ex;
+ print(os.str());
+ },
+ [=](bool)
+ {
+ print("Flushed batch requests.");
+ });
}
catch(const Ice::Exception& ex)
{
diff --git a/cpp/demo/Ice/winrt/hello/MainPage.xaml.h b/cpp/demo/Ice/winrt/hello/MainPage.xaml.h index 0ad44475d25..4bf197f8447 100644 --- a/cpp/demo/Ice/winrt/hello/MainPage.xaml.h +++ b/cpp/demo/Ice/winrt/hello/MainPage.xaml.h @@ -1,7 +1,11 @@ -//
-// MainPage.xaml.h
-// Declaration of the MainPage class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#pragma once
@@ -12,56 +16,25 @@ namespace hello
{
- ref class MainPage;
-
- class HelloCallback : virtual public IceUtil::Shared
- {
- public:
-
- HelloCallback(MainPage^);
-
- void helloSent(bool);
-
- void helloSuccess();
- void helloFailure(const Ice::Exception&);
-
- private:
-
- MainPage^ _page;
- };
- typedef IceUtil::Handle<HelloCallback> HelloCallbackPtr;
-
- /// <summary>
- /// An empty page that can be used on its own or navigated to within a Frame.
- /// </summary>
- public ref class MainPage sealed
- {
- public:
-
- MainPage();
-
- protected:
-
- virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
-
+public ref class MainPage sealed
+{
+public:
- private:
+ MainPage();
- friend class HelloCallback;
+private:
- Demo::HelloPrx proxy();
- bool isBatch();
+ Demo::HelloPrx proxy();
+ bool isBatch();
+ void print(const std::string&);
- void helloSuccess();
- void helloFailure(const Ice::Exception& ex);
- void helloSent(bool);
- void print(const std::string&);
+ void hello_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ void shutdown_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ void flush_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
- void hello_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
- void shutdown_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
- void flush_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ Ice::CommunicatorPtr _communicator;
+ bool _response;
+};
- Ice::CommunicatorPtr _communicator;
- };
}
diff --git a/cpp/demo/IcePatch2/MFC/stdafx.h b/cpp/demo/IcePatch2/MFC/stdafx.h index 06b52e61d72..d9ba470f8fc 100755 --- a/cpp/demo/IcePatch2/MFC/stdafx.h +++ b/cpp/demo/IcePatch2/MFC/stdafx.h @@ -13,39 +13,20 @@ #pragma once -// -// For VC6 and STLport -// -#if !defined(NDEBUG) && !defined(_STLP_DEBUG) -# define _STLP_DEBUG -#endif - #ifndef VC_EXTRALEAN -#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers +# define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers #endif -// Change this to the appropriate value to target Windows 98 and -// Windows 2000 or later if not using VC6. #ifndef _WIN32_WINNT -# if defined(_MSC_VER) && _MSC_VER < 1500 -# define _WIN32_WINNT 0x0400 -# endif +# define _WIN32_WINNT 0x0501 #endif #ifndef WINVER -# if defined(_MSC_VER) && _MSC_VER > 1300 && _MSC_VER < 1600 -# define WINVER 0x0400 -# elif defined(_MSC_VER) && _MSC_VER >=1600 - # define WINVER 0x0501 -# endif +# define WINVER 0x0501 #endif -#ifndef _WIN32_IE // Allow use of features specific to IE 4.0 or later. -# if defined(_MSC_VER) && _MSC_VER >=1600 -# define _WIN32_IE 0x0500 // Change this to the appropriate value to target IE 5.0 or later. -# else -# define _WIN32_IE 0x0400 -# endif +#ifndef _WIN32_IE // Allow use of features specific to IE 5.0 or later. +# define _WIN32_IE 0x0500 #endif #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit @@ -53,12 +34,12 @@ // turns off MFC's hiding of some common and often safely ignored warning messages #define _AFX_ALL_WARNINGS -#include <afxwin.h> // MFC core and standard components -#include <afxext.h> // MFC extensions +#include <afxwin.h> // MFC core and standard components +#include <afxext.h> // MFC extensions -#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls +#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls #ifndef _AFX_NO_AFXCMN_SUPPORT -#include <afxcmn.h> // MFC support for Windows Common Controls -#endif // _AFX_NO_AFXCMN_SUPPORT +# include <afxcmn.h> // MFC support for Windows Common Controls +#endif #include <Ice/Ice.h> diff --git a/cpp/include/Freeze/Initialize.h b/cpp/include/Freeze/Initialize.h index 931bd58aeb6..a81407e23a2 100644 --- a/cpp/include/Freeze/Initialize.h +++ b/cpp/include/Freeze/Initialize.h @@ -75,7 +75,7 @@ public: virtual ~TransactionalEvictorDeadlockException() throw(); virtual std::string ice_name() const; - virtual Ice::Exception* ice_clone() const; + virtual TransactionalEvictorDeadlockException* ice_clone() const; virtual void ice_throw() const; TransactionPtr tx; diff --git a/cpp/include/Glacier2/Application.h b/cpp/include/Glacier2/Application.h index 6bf8334af94..edbe14f31c6 100644 --- a/cpp/include/Glacier2/Application.h +++ b/cpp/include/Glacier2/Application.h @@ -27,7 +27,7 @@ class GLACIER2_API RestartSessionException : public IceUtil::Exception public: virtual std::string ice_name() const; - virtual IceUtil::Exception* ice_clone() const; + virtual RestartSessionException* ice_clone() const; virtual void ice_throw() const; }; diff --git a/cpp/include/Ice/CommunicatorAsync.h b/cpp/include/Ice/CommunicatorAsync.h index 26915051f8d..cb7dfeb288c 100644 --- a/cpp/include/Ice/CommunicatorAsync.h +++ b/cpp/include/Ice/CommunicatorAsync.h @@ -42,11 +42,41 @@ public: catch(::Ice::Exception& ex) { ::IceInternal::CallbackNC<T>::__exception(__result, ex); - return; } } }; +#ifdef ICE_CPP11 +class Cpp11FnCallbackNC_Communicator_flushBatchRequests : virtual public ::IceInternal::Cpp11FnCallbackNC +{ +public: + + Cpp11FnCallbackNC_Communicator_flushBatchRequests( + const ::IceInternal::Function<void (const ::Ice::Exception&)>& excb, + const ::IceInternal::Function<void (bool)>& sentcb) : + ::IceInternal::Cpp11FnCallbackNC(excb, sentcb) + { + CallbackBase::checkCallback(true, excb != nullptr); + } + + virtual void + __completed(const ::Ice::AsyncResultPtr& __result) const + { + ::Ice::CommunicatorPtr __com = __result->getCommunicator(); + assert(__com); + try + { + __com->end_flushBatchRequests(__result); + assert(false); + } + catch(::Ice::Exception& ex) + { + ::IceInternal::Cpp11FnCallbackNC::__exception(__result, ex); + } + } +}; +#endif + template<class T> Callback_Communicator_flushBatchRequestsPtr newCallback_Communicator_flushBatchRequests(const IceUtil::Handle<T>& instance, void (T::*excb)(const ::Ice::Exception&), @@ -90,7 +120,6 @@ public: catch(::Ice::Exception& ex) { ::IceInternal::Callback<T, CT>::__exception(__result, ex); - return; } } }; diff --git a/cpp/include/Ice/ConnectionAsync.h b/cpp/include/Ice/ConnectionAsync.h index 5d850e577f4..4a27138aa53 100644 --- a/cpp/include/Ice/ConnectionAsync.h +++ b/cpp/include/Ice/ConnectionAsync.h @@ -42,11 +42,40 @@ public: catch(::Ice::Exception& ex) { ::IceInternal::CallbackNC<T>::__exception(__result, ex); - return; } } }; +#ifdef ICE_CPP11 +class Cpp11FnCallbackNC_Connection_flushBatchRequests : virtual public ::IceInternal::Cpp11FnCallbackNC +{ +public: + + Cpp11FnCallbackNC_Connection_flushBatchRequests(const ::IceInternal::Function<void (const ::Ice::Exception&)>& excb, + const ::IceInternal::Function<void (bool)>& sentcb) : + ::IceInternal::Cpp11FnCallbackNC(excb, sentcb) + { + CallbackBase::checkCallback(true, excb != nullptr); + } + + virtual void + __completed(const ::Ice::AsyncResultPtr& __result) const + { + ::Ice::ConnectionPtr __con = __result->getConnection(); + assert(__con); + try + { + __con->end_flushBatchRequests(__result); + assert(false); + } + catch(::Ice::Exception& ex) + { + ::IceInternal::Cpp11FnCallbackNC::__exception(__result, ex); + } + } +}; +#endif + template<class T> Callback_Connection_flushBatchRequestsPtr newCallback_Connection_flushBatchRequests(const IceUtil::Handle<T>& instance, void (T::*excb)(const ::Ice::Exception&), @@ -90,7 +119,6 @@ public: catch(::Ice::Exception& ex) { ::IceInternal::Callback<T, CT>::__exception(__result, ex); - return; } } }; diff --git a/cpp/include/Ice/Dispatcher.h b/cpp/include/Ice/Dispatcher.h index 323ca7afa68..5ad42625215 100644 --- a/cpp/include/Ice/Dispatcher.h +++ b/cpp/include/Ice/Dispatcher.h @@ -9,9 +9,13 @@ #pragma once +#include <IceUtil/Config.h> #include <IceUtil/Shared.h> #include <IceUtil/Handle.h> #include <Ice/ConnectionF.h> +#ifdef ICE_CPP11 +# include <functional> +#endif namespace Ice { @@ -37,3 +41,36 @@ public: typedef IceUtil::Handle<Dispatcher> DispatcherPtr; } + +#ifdef ICE_CPP11 +namespace IceInternal +{ +class ICE_API Cpp11Dispatcher : public ::Ice::Dispatcher +{ +public: + + Cpp11Dispatcher(const ::std::function<void (const ::Ice::DispatcherCallPtr&, const ::Ice::ConnectionPtr)>& cb) : + _cb(cb) + { + } + + virtual void dispatch(const ::Ice::DispatcherCallPtr& call, const ::Ice::ConnectionPtr& conn); + +private: + + const ::std::function<void (const ::Ice::DispatcherCallPtr&, const ::Ice::ConnectionPtr)> _cb; +}; + +} + +namespace Ice +{ + +inline DispatcherPtr +newDispatcher(const ::std::function<void (const ::Ice::DispatcherCallPtr&, const ::Ice::ConnectionPtr)>& cb) +{ + return new ::IceInternal::Cpp11Dispatcher(cb); +} + +} +#endif diff --git a/cpp/include/Ice/Exception.h b/cpp/include/Ice/Exception.h index f0a57f27e4b..9ed187dae90 100644 --- a/cpp/include/Ice/Exception.h +++ b/cpp/include/Ice/Exception.h @@ -43,7 +43,7 @@ public: LocalException(const char*, int); virtual ~LocalException() throw(); virtual std::string ice_name() const = 0; - virtual Exception* ice_clone() const = 0; + virtual LocalException* ice_clone() const = 0; virtual void ice_throw() const = 0; }; @@ -52,7 +52,7 @@ class ICE_API UserException : public IceUtil::Exception public: virtual std::string ice_name() const = 0; - virtual Exception* ice_clone() const = 0; + virtual UserException* ice_clone() const = 0; virtual void ice_throw() const = 0; virtual void __write(::IceInternal::BasicStream*) const = 0; @@ -71,7 +71,7 @@ public: SystemException(const char*, int); virtual ~SystemException() throw(); virtual std::string ice_name() const = 0; - virtual Exception* ice_clone() const = 0; + virtual SystemException* ice_clone() const = 0; virtual void ice_throw() const = 0; }; diff --git a/cpp/include/Ice/Ice.h b/cpp/include/Ice/Ice.h index 6fc7f119645..9c4b8ad74f4 100644 --- a/cpp/include/Ice/Ice.h +++ b/cpp/include/Ice/Ice.h @@ -28,7 +28,7 @@ #include <Ice/IncomingAsync.h> #include <Ice/Process.h> #ifndef ICE_OS_WINRT -#include <Ice/Application.h> +# include <Ice/Application.h> #endif #include <Ice/Connection.h> #include <Ice/ConnectionAsync.h> @@ -39,7 +39,9 @@ #include <Ice/Router.h> #include <Ice/DispatchInterceptor.h> #include <Ice/Plugin.h> - +#ifndef ICE_OS_WINRT +# include <Ice/Service.h> +#endif #ifndef _WIN32 -#include <Ice/IconvStringConverter.h> +# include <Ice/IconvStringConverter.h> #endif diff --git a/cpp/include/Ice/IncomingAsync.h b/cpp/include/Ice/IncomingAsync.h index 7c29f4ff243..bbb94ac183f 100644 --- a/cpp/include/Ice/IncomingAsync.h +++ b/cpp/include/Ice/IncomingAsync.h @@ -15,7 +15,7 @@ namespace Ice { -class AMDCallback : virtual public IceUtil::Shared +class ICE_API AMDCallback : virtual public IceUtil::Shared { public: diff --git a/cpp/include/Ice/OutgoingAsync.h b/cpp/include/Ice/OutgoingAsync.h index 2b147ef1cb7..6d5205f6bc5 100644 --- a/cpp/include/Ice/OutgoingAsync.h +++ b/cpp/include/Ice/OutgoingAsync.h @@ -24,6 +24,9 @@ #include <Ice/ObserverHelper.h> #include <memory> +#ifdef ICE_CPP11 +# include <functional> // for std::function +#endif namespace IceInternal { @@ -415,6 +418,125 @@ public: Callback sent; }; +#ifdef ICE_CPP11 + +template<typename T> struct callback_type +{ + static const int value = 1; +}; + +template<> struct callback_type<void(const ::Ice::AsyncResultPtr&)> +{ + static const int value = 2; +}; + +template<> struct callback_type<void(const ::Ice::Exception&)> +{ + static const int value = 3; +}; + +template<typename Callable, typename = void> struct callable_type +{ + static const int value = 1; +}; + +template<class Callable> struct callable_type<Callable, typename ::std::enable_if< ::std::is_class<Callable>::value && + !::std::is_bind_expression<Callable>::value>::type> +{ + template<typename T, T> struct TypeCheck; + template<typename T> struct AsyncResultCallback + { + typedef void (T::*ok)(const ::Ice::AsyncResultPtr&) const; + }; + template<typename T> struct ExceptionCallback + { + typedef void (T::*ok)(const ::Ice::Exception&) const; + }; + + typedef char (&other)[1]; + typedef char (&asyncResult)[2]; + typedef char (&exception)[3]; + + template<typename T> static other check(...); + template<typename T> static asyncResult check(TypeCheck<typename AsyncResultCallback<T>::ok, &T::operator()>*); + template<typename T> static exception check(TypeCheck<typename ExceptionCallback<T>::ok, &T::operator()>*); + + enum { value = sizeof(check<Callable>(0)) }; +}; + +template<> struct callable_type<void(*)(const ::Ice::AsyncResultPtr&)> +{ + static const int value = 2; +}; + +template<> struct callable_type<void(*)(const ::Ice::Exception&)> +{ + static const int value = 3; +}; + +template<typename Callable, typename Callback> struct is_callable +{ + static const bool value = callable_type<Callable>::value == callback_type<Callback>::value; +}; + +template<class S> class Function : public std::function<S> +{ + +public: + + template<typename T> Function(T f, typename ::std::enable_if<is_callable<T, S>::value>::type* = 0) : std::function<S>(f) + { + } + + Function() + { + } + + Function(::std::nullptr_t) : ::std::function<S>(nullptr) + { + } +}; + +class Cpp11AsyncCallback : public GenericCallbackBase +{ +public: + + Cpp11AsyncCallback(const ::std::function<void (const ::Ice::AsyncResultPtr&)>& completed, + const ::std::function<void (const ::Ice::AsyncResultPtr&)>& sent) : + _completed(completed), + _sent(sent) + { + checkCallback(true, completed != nullptr); + } + + virtual void __completed(const ::Ice::AsyncResultPtr& result) const + { + _completed(result); + } + + virtual CallbackBasePtr __verify(::Ice::LocalObjectPtr&) + { + return this; // Nothing to do, the cookie is not type-safe. + } + + virtual void __sent(const ::Ice::AsyncResultPtr& result) const + { + if(_sent != nullptr) + { + _sent(result); + } + } + + virtual bool __hasSentCallback() const + { + return _sent != nullptr; + } + + ::std::function< void (const ::Ice::AsyncResultPtr&)> _completed; + ::std::function< void (const ::Ice::AsyncResultPtr&)> _sent; +}; +#endif + } namespace Ice @@ -438,6 +560,16 @@ newCallback(T* instance, return new ::IceInternal::AsyncCallback<T>(instance, cb, sentcb); } +#ifdef ICE_CPP11 +inline CallbackPtr +newCallback(const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = + ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) +{ + return new ::IceInternal::Cpp11AsyncCallback(completed, sent); +} +#endif + // // Operation callbacks are specified in Proxy.h // diff --git a/cpp/include/Ice/Proxy.h b/cpp/include/Ice/Proxy.h index b1ceddfaf27..12ac7496667 100644 --- a/cpp/include/Ice/Proxy.h +++ b/cpp/include/Ice/Proxy.h @@ -150,13 +150,84 @@ typedef IceUtil::Handle<AMI_Object_ice_flushBatchRequests> AMI_Object_ice_flushB } +#ifdef ICE_CPP11 +namespace IceInternal +{ + +class ICE_API Cpp11FnCallbackNC : virtual public CallbackBase +{ +public: + + Cpp11FnCallbackNC(const ::std::function<void (const ::Ice::Exception&)>& excb, + const ::std::function<void (bool)>& sentcb) : + _exception(excb), + _sent(sentcb) + { + } + + virtual CallbackBasePtr __verify(::Ice::LocalObjectPtr& cookie) + { + return this; + } + + virtual void __sent(const ::Ice::AsyncResultPtr& result) const + { + if(_sent != nullptr) + { + _sent(result->sentSynchronously()); + } + } + + virtual bool __hasSentCallback() const + { + return _sent != nullptr; + } + +protected: + + void __exception(const ::Ice::AsyncResultPtr&, const ::Ice::Exception& ex) const + { + if(_exception != nullptr) + { + _exception(ex); + } + } + + ::std::function<void (const ::Ice::Exception&)> _exception; + ::std::function<void (bool)> _sent; +}; + +class ICE_API Cpp11FnOnewayCallbackNC : virtual public ::IceInternal::Cpp11FnCallbackNC +{ +public: + + Cpp11FnOnewayCallbackNC(const ::std::function<void ()>& cb, + const ::std::function<void (const ::Ice::Exception&)>& excb, + const ::std::function<void (bool)>& sentcb) : + Cpp11FnCallbackNC(excb, sentcb), + _cb(cb) + { + CallbackBase::checkCallback(true, cb || excb != nullptr); + } + + virtual void + __completed(const ::Ice::AsyncResultPtr&) const; + +private: + + ::std::function<void ()> _cb; +}; + +} +#endif + namespace IceProxy { namespace Ice { class ICE_API Object : public ::IceUtil::Shared, private ::IceUtil::Mutex { public: - + bool operator==(const Object&) const; bool operator!=(const Object&) const; bool operator<(const Object&) const; @@ -175,6 +246,48 @@ public: { return ice_isA(typeId, &context); } + +#ifdef ICE_CPP11 + ::Ice::AsyncResultPtr + begin_ice_isA(const ::std::string& typeId, + const ::Ice::Context& ctx, + const ::IceInternal::Function<void (bool)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>(), + const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) + { + return __begin_ice_isA(typeId, &ctx, response, exception, sent); + } + + ::Ice::AsyncResultPtr + begin_ice_isA(const ::std::string& typeId, + const ::IceInternal::Function<void (bool)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>(), + const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) + { + return __begin_ice_isA(typeId, 0, response, exception, sent); + } + + ::Ice::AsyncResultPtr + begin_ice_isA(const ::std::string& typeId, + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = + ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) + { + return begin_ice_isA(typeId, 0, ::Ice::newCallback(completed, sent), 0); + } + + ::Ice::AsyncResultPtr + begin_ice_isA(const ::std::string& typeId, + const ::Ice::Context& ctx, + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = + ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) + { + return begin_ice_isA(typeId, &ctx, ::Ice::newCallback(completed, sent), 0); + } +#endif ::Ice::AsyncResultPtr begin_ice_isA(const ::std::string& typeId) { @@ -227,6 +340,44 @@ public: ice_ping(&context); } +#ifdef ICE_CPP11 + ::Ice::AsyncResultPtr + begin_ice_ping(const ::IceInternal::Function<void ()>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>(), + const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) + { + return __begin_ice_ping(0, response, exception, sent); + } + + ::Ice::AsyncResultPtr + begin_ice_ping(const ::Ice::Context& ctx, + const ::IceInternal::Function<void ()>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>(), + const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) + { + return __begin_ice_ping(&ctx, response, exception, sent); + } + + ::Ice::AsyncResultPtr + begin_ice_ping(const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = + ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) + { + return begin_ice_ping(0, ::Ice::newCallback(completed, sent), 0); + } + + ::Ice::AsyncResultPtr + begin_ice_ping(const ::Ice::Context& ctx, + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = + ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) + { + return begin_ice_ping(&ctx, ::Ice::newCallback(completed, sent), 0); + } +#endif + ::Ice::AsyncResultPtr begin_ice_ping() { return begin_ice_ping(0, ::IceInternal::__dummyCallback, 0); @@ -272,6 +423,44 @@ public: { return ice_ids(&context); } + +#ifdef ICE_CPP11 + ::Ice::AsyncResultPtr + begin_ice_ids(const ::IceInternal::Function<void (const ::std::vector< ::std::string>&)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>(), + const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) + { + return __begin_ice_ids(0, response, exception, sent); + } + + ::Ice::AsyncResultPtr + begin_ice_ids(const ::Ice::Context& ctx, + const ::IceInternal::Function<void (const ::std::vector< ::std::string>&)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>(), + const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) + { + return __begin_ice_ids(&ctx, response, exception, sent); + } + + ::Ice::AsyncResultPtr + begin_ice_ids(const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = + ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) + { + return begin_ice_ids(0, ::Ice::newCallback(completed, sent), 0); + } + + ::Ice::AsyncResultPtr + begin_ice_ids(const ::Ice::Context& ctx, + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = + ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) + { + return begin_ice_ids(&ctx, ::Ice::newCallback(completed, sent), 0); + } +#endif ::Ice::AsyncResultPtr begin_ice_ids() { @@ -304,7 +493,7 @@ public: ::Ice::AsyncResultPtr begin_ice_ids(const ::Ice::Context& __ctx, const ::Ice::Callback_Object_ice_idsPtr& __del, - const ::Ice::LocalObjectPtr& __cookie = 0) + const ::Ice::LocalObjectPtr& __cookie = 0) { return begin_ice_ids(&__ctx, __del, __cookie); } @@ -319,6 +508,44 @@ public: { return ice_id(&context); } + +#ifdef ICE_CPP11 + ::Ice::AsyncResultPtr + begin_ice_id(const ::IceInternal::Function<void (const ::std::string&)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>(), + const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) + { + return __begin_ice_id(0, response, exception, sent); + } + + ::Ice::AsyncResultPtr + begin_ice_id(const ::Ice::Context& ctx, + const ::IceInternal::Function<void (const ::std::string&)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>(), + const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) + { + return __begin_ice_id(&ctx, response, exception, sent); + } + + ::Ice::AsyncResultPtr + begin_ice_id(const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = + ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) + { + return begin_ice_id(0, ::Ice::newCallback(completed, sent), 0); + } + + ::Ice::AsyncResultPtr + begin_ice_id(const ::Ice::Context& ctx, + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed, + const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = + ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()) + { + return begin_ice_id(&ctx, ::Ice::newCallback(completed, sent), 0); + } +#endif ::Ice::AsyncResultPtr begin_ice_id() { @@ -338,7 +565,7 @@ public: ::Ice::AsyncResultPtr begin_ice_id(const ::Ice::Context& __ctx, const ::Ice::CallbackPtr& __del, - const ::Ice::LocalObjectPtr& __cookie = 0) + const ::Ice::LocalObjectPtr& __cookie = 0) { return begin_ice_id(&__ctx, __del, __cookie); } @@ -351,7 +578,7 @@ public: ::Ice::AsyncResultPtr begin_ice_id(const ::Ice::Context& __ctx, const ::Ice::Callback_Object_ice_idPtr& __del, - const ::Ice::LocalObjectPtr& __cookie = 0) + const ::Ice::LocalObjectPtr& __cookie = 0) { return begin_ice_id(&__ctx, __del, __cookie); } @@ -381,6 +608,58 @@ public: bool ice_invoke_async(const ::Ice::AMI_Object_ice_invokePtr&, const ::std::string&, ::Ice::OperationMode, const ::std::vector< ::Ice::Byte>&, const ::Ice::Context&); +#ifdef ICE_CPP11 + ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, + ::Ice::OperationMode mode, + const ::std::vector< ::Ice::Byte>& inParams, + const ::IceInternal::Function<void (bool, const ::std::vector< ::Ice::Byte>&)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>(), + const ::IceInternal::Function<void (bool)>& sent = + ::IceInternal::Function<void (bool)>()) + { + return __begin_ice_invoke(operation, mode, inParams, 0, response, exception, sent); + } + + ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, + ::Ice::OperationMode mode, + const ::std::vector< ::Ice::Byte>& inParams, + const ::Ice::Context& ctx, + const ::IceInternal::Function<void (bool, const ::std::vector< ::Ice::Byte>&)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>(), + const ::IceInternal::Function<void (bool)>& sent = + ::IceInternal::Function<void (bool)>()) + { + return __begin_ice_invoke(operation, mode, inParams, &ctx, response, exception, sent); + } + + ::Ice::AsyncResultPtr begin_ice_invoke( + const ::std::string& operation, + ::Ice::OperationMode mode, + const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams, + const ::IceInternal::Function<void (bool, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>(), + const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) + { + return __begin_ice_invoke(operation, mode, inParams, 0, response, exception, sent); + } + + ::Ice::AsyncResultPtr begin_ice_invoke( + const ::std::string& operation, + ::Ice::OperationMode mode, + const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams, + const ::Ice::Context& ctx, + const ::IceInternal::Function<void (bool, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>(), + const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) + { + return __begin_ice_invoke(operation, mode, inParams, &ctx, response, exception, sent); + } +#endif + ::Ice::AsyncResultPtr begin_ice_invoke(const ::std::string& operation, ::Ice::OperationMode mode, const ::std::vector< ::Ice::Byte>& inParams) @@ -578,6 +857,16 @@ public: void ice_flushBatchRequests(); bool ice_flushBatchRequests_async(const ::Ice::AMI_Object_ice_flushBatchRequestsPtr&); + +#ifdef ICE_CPP11 + ::Ice::AsyncResultPtr begin_ice_flushBatchRequests( + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception, + const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) + { + return begin_ice_flushBatchRequestsInternal(new ::IceInternal::Cpp11FnOnewayCallbackNC(nullptr, exception, sent), 0); + } +#endif + ::Ice::AsyncResultPtr begin_ice_flushBatchRequests() { return begin_ice_flushBatchRequestsInternal(::IceInternal::__dummyCallback, 0); @@ -624,28 +913,283 @@ protected: virtual Object* __newInstance() const; private: + +#ifdef ICE_CPP11 + ::Ice::AsyncResultPtr __begin_ice_isA( + const ::std::string& typeId, + const ::Ice::Context* ctx, + const ::IceInternal::Function<void (bool)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>(), + const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) + { + class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC + { + public: + + Cpp11CB(const ::std::function<void (bool)>& responseFunc, + const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc, + const ::std::function<void (bool)>& sentFunc) : + ::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc), + _response(responseFunc) + { + CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr); + } + + virtual void __completed(const ::Ice::AsyncResultPtr& __result) const + { + ::Ice::ObjectPrx __proxy = ::Ice::ObjectPrx::uncheckedCast(__result->getProxy()); + bool __ret; + try + { + __ret = __proxy->end_ice_isA(__result); + } + catch(::Ice::Exception& ex) + { + Cpp11FnCallbackNC::__exception(__result, ex); + return; + } + if(_response != nullptr) + { + _response(__ret); + } + } + + private: + + ::std::function<void (bool)> _response; + }; + return begin_ice_isA(typeId, ctx, new Cpp11CB(response, exception, sent), 0); + } + + ::Ice::AsyncResultPtr __begin_ice_ping( + const ::Ice::Context* ctx, + const ::IceInternal::Function<void ()>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>(), + const ::IceInternal::Function<void (bool)>& sent = + ::IceInternal::Function<void (bool)>()) + { + return begin_ice_ping(ctx, new ::IceInternal::Cpp11FnOnewayCallbackNC(response, exception, sent), 0); + } + + ::Ice::AsyncResultPtr __begin_ice_id( + const ::Ice::Context* ctx, + const ::IceInternal::Function<void (const ::std::string&)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>(), + const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) + { + class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC + { + public: + + Cpp11CB(const ::std::function<void (const ::std::string&)>& responseFunc, + const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc, + const ::std::function<void (bool)>& sentFunc) : + ::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc), + _response(responseFunc) + { + CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr); + } + + virtual void __completed(const ::Ice::AsyncResultPtr& __result) const + { + ::Ice::ObjectPrx __proxy = ::Ice::ObjectPrx::uncheckedCast(__result->getProxy()); + ::std::string __ret; + try + { + __ret = __proxy->end_ice_id(__result); + } + catch(::Ice::Exception& ex) + { + Cpp11FnCallbackNC::__exception(__result, ex); + return; + } + if(_response != nullptr) + { + _response(__ret); + } + } + + private: + + ::std::function<void (const ::std::string&)> _response; + }; + return begin_ice_id(ctx, new Cpp11CB(response, exception, sent), 0); + } + + ::Ice::AsyncResultPtr __begin_ice_ids( + const ::Ice::Context* ctx, + const ::IceInternal::Function<void (const ::std::vector< ::std::string>&)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>(), + const ::IceInternal::Function<void (bool)>& sent = + ::IceInternal::Function<void (bool)>()) + { + class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC + { + public: + + Cpp11CB(const ::std::function<void (const ::std::vector< ::std::string>&)>& responseFunc, + const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc, + const ::std::function<void (bool)>& sentFunc) : + ::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc), + _response(responseFunc) + { + CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr); + } + + virtual void __completed(const ::Ice::AsyncResultPtr& __result) const + { + ::Ice::ObjectPrx __proxy = ::Ice::ObjectPrx::uncheckedCast(__result->getProxy()); + ::std::vector< ::std::string> __ret; + try + { + __ret = __proxy->end_ice_ids(__result); + } + catch(::Ice::Exception& ex) + { + Cpp11FnCallbackNC::__exception(__result, ex); + return; + } + if(_response != nullptr) + { + _response(__ret); + } + } + + private: + + ::std::function<void (const ::std::vector< ::std::string>&)> _response; + }; + return begin_ice_ids(ctx, new Cpp11CB(response, exception, sent), 0); + } +#endif bool ice_isA(const ::std::string&, const ::Ice::Context*); ::Ice::AsyncResultPtr begin_ice_isA(const ::std::string&, const ::Ice::Context*, - const ::IceInternal::CallbackBasePtr&, - const ::Ice::LocalObjectPtr&); + const ::IceInternal::CallbackBasePtr&, + const ::Ice::LocalObjectPtr&); void ice_ping(const ::Ice::Context*); ::Ice::AsyncResultPtr begin_ice_ping(const ::Ice::Context*, const ::IceInternal::CallbackBasePtr&, - const ::Ice::LocalObjectPtr&); + const ::Ice::LocalObjectPtr&); ::std::vector< ::std::string> ice_ids(const ::Ice::Context*); ::Ice::AsyncResultPtr begin_ice_ids(const ::Ice::Context*, const ::IceInternal::CallbackBasePtr&, - const ::Ice::LocalObjectPtr&); + const ::Ice::LocalObjectPtr&); ::std::string ice_id(const ::Ice::Context*); ::Ice::AsyncResultPtr begin_ice_id(const ::Ice::Context*, const ::IceInternal::CallbackBasePtr&, - const ::Ice::LocalObjectPtr&); - + const ::Ice::LocalObjectPtr&); + +#ifdef ICE_CPP11 + ::Ice::AsyncResultPtr __begin_ice_invoke( + const ::std::string& operation, + ::Ice::OperationMode mode, + const ::std::vector< ::Ice::Byte>& inParams, + const ::Ice::Context* ctx, + const ::IceInternal::Function<void (bool, const ::std::vector< ::Ice::Byte>&)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>(), + const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) + { + class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC + { + public: + + Cpp11CB(const ::std::function<void (bool, const ::std::vector< ::Ice::Byte>&)>& responseFunc, + const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc, + const ::std::function<void (bool)>& sentFunc) : + ::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc), + _response(responseFunc) + { + CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr); + } + + virtual void __completed(const ::Ice::AsyncResultPtr& __result) const + { + ::Ice::ObjectPrx __proxy = ::Ice::ObjectPrx::uncheckedCast(__result->getProxy()); + bool __ret; + ::std::vector< ::Ice::Byte> p1; + try + { + __ret = __proxy->end_ice_invoke(p1, __result); + } + catch(::Ice::Exception& ex) + { + Cpp11FnCallbackNC::__exception(__result, ex); + return; + } + if(_response != nullptr) + { + _response(__ret, p1); + } + } + + private: + + ::std::function<void (bool, const ::std::vector< ::Ice::Byte>&)> _response; + }; + return begin_ice_invoke(operation, mode, inParams, ctx, new Cpp11CB(response, exception, sent), 0); + } + + ::Ice::AsyncResultPtr __begin_ice_invoke( + const ::std::string& operation, + ::Ice::OperationMode mode, + const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& inParams, + const ::Ice::Context* ctx, + const ::IceInternal::Function<void (bool, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&)>& response, + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = + ::IceInternal::Function<void (const ::Ice::Exception&)>(), + const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) + { + class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC + { + public: + + Cpp11CB(const ::std::function<void (bool, const ::std::pair<const ::Ice::Byte*, + const ::Ice::Byte*>&)>& responseFunc, + const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc, + const ::std::function<void (bool)>& sentFunc) : + ::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc), + _response(responseFunc) + { + CallbackBase::checkCallback(true, _response || _exception != nullptr); + } + + virtual void __completed(const ::Ice::AsyncResultPtr& __result) const + { + bool __ret; + ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*> p1; + try + { + __ret = __result->getProxy()->___end_ice_invoke(p1, __result); + } + catch(::Ice::Exception& ex) + { + Cpp11FnCallbackNC::__exception(__result, ex); + return; + } + if(_response != nullptr) + { + _response(__ret, p1); + } + } + + private: + + ::std::function<void (bool, const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&)> _response; + }; + return begin_ice_invoke(operation, mode, inParams, ctx, new Cpp11CB(response, exception, sent), 0); + } +#endif + bool ice_invoke(const ::std::string&, ::Ice::OperationMode, const ::std::vector< ::Ice::Byte>&, @@ -1057,19 +1601,19 @@ public: virtual CallbackBasePtr __verify(::Ice::LocalObjectPtr& cookie) { - if(cookie != 0) // Makes sure begin_ was called without a cookie - { - throw IceUtil::IllegalArgumentException(__FILE__, __LINE__, "cookie specified for callback without cookie"); - } + if(cookie != 0) // Makes sure begin_ was called without a cookie + { + throw IceUtil::IllegalArgumentException(__FILE__, __LINE__, "cookie specified for callback without cookie"); + } return this; } virtual void __sent(const ::Ice::AsyncResultPtr& result) const { - if(sent) - { - (callback.get()->*sent)(result->sentSynchronously()); - } + if(sent) + { + (callback.get()->*sent)(result->sentSynchronously()); + } } virtual bool __hasSentCallback() const @@ -1111,19 +1655,19 @@ public: virtual CallbackBasePtr __verify(::Ice::LocalObjectPtr& cookie) { - if(cookie && !CT::dynamicCast(cookie)) - { - throw IceUtil::IllegalArgumentException(__FILE__, __LINE__, "unexpected cookie type"); - } + if(cookie && !CT::dynamicCast(cookie)) + { + throw IceUtil::IllegalArgumentException(__FILE__, __LINE__, "unexpected cookie type"); + } return this; } virtual void __sent(const ::Ice::AsyncResultPtr& result) const { - if(sent) - { - (callback.get()->*sent)(result->sentSynchronously(), CT::dynamicCast(result->getCookie())); - } + if(sent) + { + (callback.get()->*sent)(result->sentSynchronously(), CT::dynamicCast(result->getCookie())); + } } virtual bool __hasSentCallback() const @@ -1165,6 +1709,8 @@ public: } }; + + template<class T, typename CT> class TwowayCallback : public Callback<T, CT> { @@ -2047,7 +2593,8 @@ newCallback_Object_ice_invoke(T* instance, void (T::*excb)(const ::Ice::Exception&), void (T::*sentcb)(bool) = 0) { - return new CallbackNC_Object_ice_invoke<T>(instance, 0, excb, sentcb); + return new CallbackNC_Object_ice_invoke<T>( + instance, static_cast<void (T::*)(bool, const std::vector<Ice::Byte>&)>(0), excb, sentcb); } template<class T, typename CT> Callback_Object_ice_invokePtr @@ -2055,7 +2602,8 @@ newCallback_Object_ice_invoke(T* instance, void (T::*excb)(const ::Ice::Exception&, const CT&), void (T::*sentcb)(bool, const CT&) = 0) { - return new Callback_Object_ice_invoke<T, CT>(instance, 0, excb, sentcb); + return new Callback_Object_ice_invoke<T, CT>( + instance, static_cast<void (T::*)(bool, const std::vector<Ice::Byte>&, const CT&)>(0), excb, sentcb); } template<class T> Callback_Object_ice_flushBatchRequestsPtr diff --git a/cpp/include/Ice/Service.h b/cpp/include/Ice/Service.h index 8b24f58e192..c124d371e1e 100644 --- a/cpp/include/Ice/Service.h +++ b/cpp/include/Ice/Service.h @@ -9,8 +9,13 @@ #pragma once +#include <IceUtil/Config.h> #include <Ice/Ice.h> +#ifdef _WIN32 +# include <winsvc.h> +#endif + namespace Ice { @@ -40,10 +45,6 @@ public: // // Win32: // - // --install NAME [--display DISP] [--executable EXEC] - // --uninstall NAME - // --start NAME [args ...] - // --stop NAME // --service NAME // // Unix: @@ -109,6 +110,12 @@ public: // The return value is an exit status code: EXIT_FAILURE or // EXIT_SUCCESS. // +#ifdef _WIN32 + + int run(int&, wchar_t*[], const InitializationData& = InitializationData()); + +#endif + int run(int&, char*[], const InitializationData& = InitializationData()); #ifdef _WIN32 @@ -119,28 +126,6 @@ public: // void configureService(const std::string&); - // - // Installs a Win32 service. - // - int installService(bool, const std::string&, const std::string&, const std::string&, - const std::vector<std::string>&); - - // - // Uninstalls a Win32 service. - // - int uninstallService(bool, const std::string&); - - // - // Starts a Win32 service. The argument vector is passed to the - // service at startup. - // - int startService(const std::string&, const std::vector<std::string>&); - - // - // Stops a running Win32 service. - // - int stopService(const std::string&); - static void setModuleHandle(HMODULE); #else @@ -246,7 +231,7 @@ private: public: - void serviceMain(int, char*[]); + void serviceMain(int, wchar_t*[]); void control(int); #else diff --git a/cpp/include/Ice/Stream.h b/cpp/include/Ice/Stream.h index 80b7f804b7b..7715a496e72 100644 --- a/cpp/include/Ice/Stream.h +++ b/cpp/include/Ice/Stream.h @@ -66,7 +66,7 @@ public: virtual void usesClasses(bool) = 0; virtual ::std::string ice_name() const = 0; - virtual Exception* ice_clone() const = 0; + virtual UserExceptionReader* ice_clone() const = 0; virtual void ice_throw() const = 0; virtual void __write(IceInternal::BasicStream*) const; @@ -331,7 +331,24 @@ public: virtual void write(const Float*, const Float*) = 0; virtual void write(const Double*, const Double*) = 0; - virtual void writeOptional(Int, OptionalType) = 0; + virtual void writeOptional(Int, OptionalType) = 0; + +// +// COMPILER FIX: clang using libc++ cannot use the StreamHelper to write +// vector<bool>, as vector<bool> get optimized to +// __bit_const_reference that has not size member function. +// +#if defined(__clang__) && defined(_LIBCPP_VERSION) + virtual void write(const ::std::vector<bool>& v) + { + writeSize(static_cast<Int>(v.size())); + for(::std::vector<bool>::const_iterator p = v.begin(); p != v.end(); ++p) + { + bool v = (*p); + write(v); + } + } +#endif template<typename T> inline void write(const T& v) { @@ -405,7 +422,7 @@ public: virtual bool usesClasses() const = 0; virtual ::std::string ice_name() const = 0; - virtual Exception* ice_clone() const = 0; + virtual UserExceptionWriter* ice_clone() const = 0; virtual void ice_throw() const = 0; virtual void __write(IceInternal::BasicStream*) const; diff --git a/cpp/include/Ice/StreamTraits.h b/cpp/include/Ice/StreamTraits.h index db4e60b1b05..7dfa5279c84 100644 --- a/cpp/include/Ice/StreamTraits.h +++ b/cpp/include/Ice/StreamTraits.h @@ -399,6 +399,28 @@ struct StreamHelper<std::pair<T, T>, StreamTraitTypeSequence> } }; +template<> +struct StreamHelper<std::pair< ::std::vector<bool>::const_iterator, + ::std::vector<bool>::const_iterator>, StreamTraitTypeSequence> +{ + template<class S> static inline void + write(S* stream, const std::pair< ::std::vector<bool>::const_iterator, + ::std::vector<bool>::const_iterator>& v) + { + stream->writeSize(static_cast< ::Ice::Int>(IceUtilInternal::distance(v.first, v.second))); + for(::std::vector<bool>::const_iterator p = v.first; p != v.second; ++p) + { + stream->write(static_cast<bool>(*p)); + } + } + + template<class S> static inline void + read(S* stream, std::pair< ::std::vector<bool>::const_iterator, ::std::vector<bool>::const_iterator>&) + { + assert(false); // Only used for marshaling. + } +}; + // Helper for zero-copy array sequence parameters template<typename T> struct StreamHelper<std::pair<IceUtil::ScopedArray<T>, std::pair<const T*, const T*> >, StreamTraitTypeSequence> diff --git a/cpp/include/IceSSL/Plugin.h b/cpp/include/IceSSL/Plugin.h index ff67ba55a43..80772366690 100644 --- a/cpp/include/IceSSL/Plugin.h +++ b/cpp/include/IceSSL/Plugin.h @@ -61,7 +61,7 @@ public: CertificateReadException(const char*, int, const std::string&); virtual ~CertificateReadException() throw(); virtual std::string ice_name() const; - virtual IceUtil::Exception* ice_clone() const; + virtual CertificateReadException* ice_clone() const; virtual void ice_throw() const; std::string reason; @@ -81,7 +81,7 @@ public: CertificateEncodingException(const char*, int, const std::string&); virtual ~CertificateEncodingException() throw(); virtual std::string ice_name() const; - virtual IceUtil::Exception* ice_clone() const; + virtual CertificateEncodingException* ice_clone() const; virtual void ice_throw() const; std::string reason; @@ -101,7 +101,7 @@ public: ParseException(const char*, int, const std::string&); virtual ~ParseException() throw(); virtual std::string ice_name() const; - virtual IceUtil::Exception* ice_clone() const; + virtual ParseException* ice_clone() const; virtual void ice_throw() const; std::string reason; diff --git a/cpp/include/IceUtil/Cond.h b/cpp/include/IceUtil/Cond.h index 5a4121fbaf1..bf94fc04d7f 100644 --- a/cpp/include/IceUtil/Cond.h +++ b/cpp/include/IceUtil/Cond.h @@ -54,12 +54,12 @@ class Mutex; // Condition variable implementation. Conforms to the same semantics // as a POSIX threads condition variable. // -class Cond : private noncopyable +class ICE_UTIL_API Cond : private noncopyable { public: - ICE_UTIL_API Cond(); - ICE_UTIL_API ~Cond(); + Cond(); + ~Cond(); // // signal restarts one of the threads that are waiting on the @@ -67,14 +67,14 @@ public: // nothing happens. If several threads are waiting on cond, // exactly one is restarted, but it is not specified which. // - ICE_UTIL_API void signal(); + void signal(); // // broadcast restarts all the threads that are waiting on the // condition variable cond. Nothing happens if no threads are // waiting on cond. // - ICE_UTIL_API void broadcast(); + void broadcast(); // // MSVC doesn't support out-of-class definitions of member @@ -178,11 +178,11 @@ private: # ifdef ICE_HAS_WIN32_CONDVAR mutable CONDITION_VARIABLE _cond; # else - ICE_UTIL_API void wake(bool); - ICE_UTIL_API void preWait() const; - ICE_UTIL_API void postWait(bool) const; - ICE_UTIL_API bool timedDowait(const Time&) const; - ICE_UTIL_API void dowait() const; + void wake(bool); + void preWait() const; + void postWait(bool) const; + bool timedDowait(const Time&) const; + void dowait() const; Mutex _internal; IceUtilInternal::Semaphore _gate; diff --git a/cpp/include/IceUtil/Config.h b/cpp/include/IceUtil/Config.h index ea9371ca845..06ec81a729f 100644 --- a/cpp/include/IceUtil/Config.h +++ b/cpp/include/IceUtil/Config.h @@ -45,9 +45,19 @@ # define ICE_32 #endif -#if defined(_MSC_VER) && (_MSC_VER >= 1700) // -// Visual Studio 2012 and later +// Check for C++ 11 support +// +#if (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || \ + (defined(__clang__) && (__clang_major__ >= 4) && __cplusplus >= 201103) || \ + (defined(_MSC_VER) && (_MSC_VER >= 1600)) +# define ICE_CPP11 +#endif + + +#if defined(_MSC_VER) && (_MSC_VER >= 1700) // Visual Studio 2012 or later +// +// Check if building for WinRT // # include <winapifamily.h> # if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) @@ -80,14 +90,6 @@ # define ICE_DECLSPEC_IMPORT /**/ #endif -#if defined(_MSC_VER) -# define ICE_DEPRECATED_API __declspec(deprecated) -#elif defined(__GNUC__) -# define ICE_DEPRECATED_API __attribute__((deprecated)) -#else -# define ICE_DEPRECATED_API /**/ -#endif - // // Let's use these extensions with IceUtil: // @@ -98,22 +100,20 @@ #endif -#ifdef _WIN32 +#if defined(_MSC_VER) +# define ICE_DEPRECATED_API __declspec(deprecated) +#elif defined(__GNUC__) +# define ICE_DEPRECATED_API __attribute__((deprecated)) +#else +# define ICE_DEPRECATED_API /**/ +#endif +#ifdef _WIN32 # if !defined(ICE_STATIC_LIBS) && defined(_MSC_VER) && (!defined(_DLL) || !defined(_MT)) # error "Only multi-threaded DLL libraries can be used with Ice!" # endif # include <windows.h> - -# ifdef _MSC_VER -// ... : inherits ... via dominance -# pragma warning( disable : 4250 ) -// class ... needs to have dll-interface to be used by clients of class ... -# pragma warning( disable : 4251 ) -// non dll-interface class ... used as base for dll-interface class ... -# pragma warning( disable : 4275 ) -# endif #endif // @@ -128,6 +128,13 @@ # include <errno.h> #endif +#ifdef _MSC_VER +// +// Move some warnings to level 4 +// +# pragma warning( 4 : 4250 ) // ... : inherits ... via dominance +# pragma warning( 4 : 4251 ) // class ... needs to have dll-interface to be used by clients of class .. +#endif namespace IceUtil { @@ -135,7 +142,7 @@ namespace IceUtil // // By deriving from this class, other classes are made non-copyable. // -class noncopyable +class ICE_UTIL_API noncopyable { protected: diff --git a/cpp/include/IceUtil/CtrlCHandler.h b/cpp/include/IceUtil/CtrlCHandler.h index 6614b601c58..24d2012df33 100644 --- a/cpp/include/IceUtil/CtrlCHandler.h +++ b/cpp/include/IceUtil/CtrlCHandler.h @@ -60,7 +60,7 @@ public: CtrlCHandlerException(const char*, int); virtual std::string ice_name() const; - virtual Exception* ice_clone() const; + virtual CtrlCHandlerException* ice_clone() const; virtual void ice_throw() const; }; diff --git a/cpp/include/IceUtil/Exception.h b/cpp/include/IceUtil/Exception.h index 9f04171efd9..fdeb01372e6 100644 --- a/cpp/include/IceUtil/Exception.h +++ b/cpp/include/IceUtil/Exception.h @@ -51,7 +51,7 @@ public: NullHandleException(const char*, int); virtual ~NullHandleException() throw(); virtual std::string ice_name() const; - virtual Exception* ice_clone() const; + virtual NullHandleException* ice_clone() const; virtual void ice_throw() const; private: @@ -68,7 +68,7 @@ public: virtual ~IllegalArgumentException() throw(); virtual std::string ice_name() const; virtual void ice_print(std::ostream&) const; - virtual Exception* ice_clone() const; + virtual IllegalArgumentException* ice_clone() const; virtual void ice_throw() const; std::string reason() const; @@ -86,7 +86,7 @@ public: SyscallException(const char*, int, int); virtual std::string ice_name() const; virtual void ice_print(std::ostream&) const; - virtual Exception* ice_clone() const; + virtual SyscallException* ice_clone() const; virtual void ice_throw() const; int error() const; @@ -105,7 +105,7 @@ public: virtual ~FileLockException() throw(); virtual std::string ice_name() const; virtual void ice_print(std::ostream&) const; - virtual Exception* ice_clone() const; + virtual FileLockException* ice_clone() const; virtual void ice_throw() const; std::string path() const; @@ -125,7 +125,7 @@ public: OptionalNotSetException(const char*, int); virtual ~OptionalNotSetException() throw(); virtual std::string ice_name() const; - virtual Exception* ice_clone() const; + virtual OptionalNotSetException* ice_clone() const; virtual void ice_throw() const; private: diff --git a/cpp/include/IceUtil/Mutex.h b/cpp/include/IceUtil/Mutex.h index f85cf721f30..76f2fbdc52f 100644 --- a/cpp/include/IceUtil/Mutex.h +++ b/cpp/include/IceUtil/Mutex.h @@ -32,7 +32,7 @@ class Cond; // `IceUtil::noncopyable' inaccessible in `IceInternal::Outgoing' due // to ambiguity // -class Mutex +class ICE_UTIL_API Mutex { public: diff --git a/cpp/include/IceUtil/Options.h b/cpp/include/IceUtil/Options.h index 364df237821..2bc37c5fdff 100644 --- a/cpp/include/IceUtil/Options.h +++ b/cpp/include/IceUtil/Options.h @@ -29,7 +29,7 @@ public: virtual ~APIException() throw(); virtual ::std::string ice_name() const; virtual void ice_print(std::ostream&) const; - virtual ::IceUtil::Exception* ice_clone() const; + virtual APIException* ice_clone() const; virtual void ice_throw() const; ::std::string reason; @@ -49,7 +49,7 @@ public: virtual ~BadOptException() throw(); virtual ::std::string ice_name() const; virtual void ice_print(std::ostream&) const; - virtual ::IceUtil::Exception* ice_clone() const; + virtual BadOptException* ice_clone() const; virtual void ice_throw() const; ::std::string reason; diff --git a/cpp/include/IceUtil/ThreadException.h b/cpp/include/IceUtil/ThreadException.h index d0444c20573..b723ff4d4fe 100644 --- a/cpp/include/IceUtil/ThreadException.h +++ b/cpp/include/IceUtil/ThreadException.h @@ -21,7 +21,7 @@ public: ThreadSyscallException(const char*, int, int); virtual std::string ice_name() const; - virtual Exception* ice_clone() const; + virtual ThreadSyscallException* ice_clone() const; virtual void ice_throw() const; private: @@ -35,7 +35,7 @@ public: ThreadLockedException(const char*, int); virtual std::string ice_name() const; - virtual Exception* ice_clone() const; + virtual ThreadLockedException* ice_clone() const; virtual void ice_throw() const; private: @@ -49,7 +49,7 @@ public: ThreadStartedException(const char*, int); virtual std::string ice_name() const; - virtual Exception* ice_clone() const; + virtual ThreadStartedException* ice_clone() const; virtual void ice_throw() const; private: @@ -63,7 +63,7 @@ public: ThreadNotStartedException(const char*, int); virtual std::string ice_name() const; - virtual Exception* ice_clone() const; + virtual ThreadNotStartedException* ice_clone() const; virtual void ice_throw() const; private: @@ -77,7 +77,7 @@ public: BadThreadControlException(const char*, int); virtual std::string ice_name() const; - virtual Exception* ice_clone() const; + virtual BadThreadControlException* ice_clone() const; virtual void ice_throw() const; private: @@ -92,7 +92,7 @@ public: InvalidTimeoutException(const char*, int, const Time&); virtual std::string ice_name() const; virtual void ice_print(std::ostream&) const; - virtual Exception* ice_clone() const; + virtual InvalidTimeoutException* ice_clone() const; virtual void ice_throw() const; private: diff --git a/cpp/include/IceUtil/Unicode.h b/cpp/include/IceUtil/Unicode.h index 6bd5232c065..4921a5b27ea 100644 --- a/cpp/include/IceUtil/Unicode.h +++ b/cpp/include/IceUtil/Unicode.h @@ -46,7 +46,7 @@ public: UTFConversionException(const char*, int, ConversionError); virtual std::string ice_name() const; virtual void ice_print(std::ostream&) const; - virtual Exception* ice_clone() const; + virtual UTFConversionException* ice_clone() const; virtual void ice_throw() const; ConversionError conversionError() const; diff --git a/cpp/include/IceXML/Parser.h b/cpp/include/IceXML/Parser.h index e32993aa207..28a48daf367 100644 --- a/cpp/include/IceXML/Parser.h +++ b/cpp/include/IceXML/Parser.h @@ -37,7 +37,7 @@ public: virtual std::string ice_name() const; virtual void ice_print(std::ostream&) const; - virtual IceUtil::Exception* ice_clone() const; + virtual ParserException* ice_clone() const; virtual void ice_throw() const; std::string reason() const; diff --git a/cpp/include/Slice/FileTracker.h b/cpp/include/Slice/FileTracker.h index 3fb45799e8c..ba12335da7d 100644 --- a/cpp/include/Slice/FileTracker.h +++ b/cpp/include/Slice/FileTracker.h @@ -23,7 +23,7 @@ public: ~FileException() throw(); virtual std::string ice_name() const; virtual void ice_print(std::ostream&) const; - virtual ::IceUtil::Exception* ice_clone() const; + virtual FileException* ice_clone() const; virtual void ice_throw() const; std::string reason() const; diff --git a/cpp/src/Freeze/TransactionalEvictorContext.cpp b/cpp/src/Freeze/TransactionalEvictorContext.cpp index c65523fa836..b0dacafe261 100644 --- a/cpp/src/Freeze/TransactionalEvictorContext.cpp +++ b/cpp/src/Freeze/TransactionalEvictorContext.cpp @@ -39,7 +39,7 @@ Freeze::TransactionalEvictorDeadlockException::ice_name() const return "Freeze::TransactionalEvictorDeadlockException"; } -Ice::Exception* +Freeze::TransactionalEvictorDeadlockException* Freeze::TransactionalEvictorDeadlockException::ice_clone() const { return new TransactionalEvictorDeadlockException(*this); @@ -197,7 +197,7 @@ Freeze::TransactionalEvictorContext::exception(const std::exception& ex) if(dx != 0 && _owner == IceUtil::ThreadControl()) { - _deadlockException.reset(dynamic_cast<DeadlockException*>(dx->ice_clone())); + _deadlockException.reset(dx->ice_clone()); return false; } @@ -205,7 +205,7 @@ Freeze::TransactionalEvictorContext::exception(const std::exception& ex) dynamic_cast<const TransactionalEvictorDeadlockException*>(&ex); if(edx != 0 && _owner == IceUtil::ThreadControl()) { - _nestedCallDeadlockException.reset(dynamic_cast<TransactionalEvictorDeadlockException*>(edx->ice_clone())); + _nestedCallDeadlockException.reset(edx->ice_clone()); return false; } diff --git a/cpp/src/Freeze/TransactionalEvictorI.cpp b/cpp/src/Freeze/TransactionalEvictorI.cpp index 27cae3e8282..5d984a5cf4f 100644 --- a/cpp/src/Freeze/TransactionalEvictorI.cpp +++ b/cpp/src/Freeze/TransactionalEvictorI.cpp @@ -422,7 +422,12 @@ Freeze::TransactionalEvictorI::dispatch(Request& request) assert(sample != 0); int operationAttributes = sample->ice_operationAttributes(current.operation); - + + if(operationAttributes < 0) + { + throw OperationNotExistException(__FILE__, __LINE__); + } + bool readOnly = (operationAttributes & 0x1) == 0; int txMode = (operationAttributes & 0x6) >> 1; @@ -467,6 +472,7 @@ Freeze::TransactionalEvictorI::dispatch(Request& request) default: { assert(0); + throw OperationNotExistException(__FILE__, __LINE__); } } diff --git a/cpp/src/Glacier2/Blobject.cpp b/cpp/src/Glacier2/Blobject.cpp index ac0571fd6de..c64e3def10e 100755 --- a/cpp/src/Glacier2/Blobject.cpp +++ b/cpp/src/Glacier2/Blobject.cpp @@ -26,122 +26,10 @@ const string clientTraceRequest = "Glacier2.Client.Trace.Request"; const string serverTraceOverride = "Glacier2.Server.Trace.Override"; const string clientTraceOverride = "Glacier2.Client.Trace.Override"; -class AMI_Array_Object_ice_invokeTwowayI : public AMI_Array_Object_ice_invoke -{ -public: - - AMI_Array_Object_ice_invokeTwowayI(const AMD_Object_ice_invokePtr& amdCB, - const InstancePtr& instance, - const ConnectionPtr& connection) : - _amdCB(amdCB), - _instance(instance), - _connection(connection) - { - } - - virtual void - ice_response(bool ok, const pair<const Byte*, const Byte*>& outParams) - { - _amdCB->ice_response(ok, outParams); - } - - virtual void - ice_exception(const Exception& ex) - { - // - // If the connection has been lost, destroy the session. - // - if(_connection) - { - if(dynamic_cast<const Ice::SocketException*>(&ex) || - dynamic_cast<const Ice::TimeoutException*>(&ex) || - dynamic_cast<const Ice::ProtocolException*>(&ex)) - { - try - { - _instance->sessionRouter()->destroySession(_connection); - } - catch(const Exception&) - { - } - } - } - - _amdCB->ice_exception(ex); - } - -private: - - const AMD_Object_ice_invokePtr _amdCB; - const InstancePtr _instance; - const ConnectionPtr _connection; -}; - -class AMI_Array_Object_ice_invokeOnewayI : public AMI_Array_Object_ice_invoke, public Ice::AMISentCallback -{ -public: - - AMI_Array_Object_ice_invokeOnewayI(const AMD_Object_ice_invokePtr& amdCB, - const InstancePtr& instance, - const ConnectionPtr& connection) : - _amdCB(amdCB), - _instance(instance), - _connection(connection) - { - } - - virtual void - ice_response(bool, const pair<const Byte*, const Byte*>&) - { - assert(false); - } - - virtual void - ice_sent() - { -#if (defined(_MSC_VER) && (_MSC_VER >= 1600)) - _amdCB->ice_response(true, pair<const Byte*, const Byte*>(nullptr, nullptr)); -#else - _amdCB->ice_response(true, pair<const Byte*, const Byte*>(0, 0)); -#endif - } - - virtual void - ice_exception(const Exception& ex) - { - // - // If the connection has been lost, destroy the session. - // - if(_connection) - { - if(dynamic_cast<const Ice::SocketException*>(&ex) || - dynamic_cast<const Ice::TimeoutException*>(&ex) || - dynamic_cast<const Ice::ProtocolException*>(&ex)) - { - try - { - _instance->sessionRouter()->destroySession(_connection); - } - catch(const Exception&) - { - } - } - } - - _amdCB->ice_exception(ex); - } - -private: - - const AMD_Object_ice_invokePtr _amdCB; - const InstancePtr _instance; - const ConnectionPtr _connection; -}; - } Glacier2::Blobject::Blobject(const InstancePtr& instance, const ConnectionPtr& reverseConnection, - const Ice::Context& context) : + const Context& context) : _instance(instance), _reverseConnection(reverseConnection), _forwardContext(_reverseConnection ? @@ -180,8 +68,52 @@ Glacier2::Blobject::destroy() } void +Glacier2::Blobject::invokeResponse(bool ok, const pair<const Byte*, const Byte*>& outParams, + const InvokeCookiePtr& cookie) +{ + cookie->cb()->ice_response(ok, outParams); +} + +void +Glacier2::Blobject::invokeSent(bool sent, const InvokeCookiePtr& cookie) +{ + if(sent) + { +#if (defined(_MSC_VER) && (_MSC_VER >= 1600)) + cookie->cb()->ice_response(true, pair<const Byte*, const Byte*>(nullptr, nullptr)); +#else + cookie->cb()->ice_response(true, pair<const Byte*, const Byte*>(0, 0)); +#endif + } +} + +void +Glacier2::Blobject::invokeException(const Exception& ex, const InvokeCookiePtr& cookie) +{ + // + // If the connection has been lost, destroy the session. + // + if(_reverseConnection) + { + if(dynamic_cast<const SocketException*>(&ex) || + dynamic_cast<const TimeoutException*>(&ex) || + dynamic_cast<const ProtocolException*>(&ex)) + { + try + { + _instance->sessionRouter()->destroySession(_reverseConnection); + } + catch(const Exception&) + { + } + } + } + cookie->cb()->ice_exception(ex); +} + +void Glacier2::Blobject::invoke(ObjectPrx& proxy, const AMD_Object_ice_invokePtr& amdCB, - const std::pair<const Ice::Byte*, const Ice::Byte*>& inParams, const Current& current) + const std::pair<const Byte*, const Byte*>& inParams, const Current& current) { // // Set the correct facet on the proxy. @@ -398,50 +330,44 @@ Glacier2::Blobject::invoke(ObjectPrx& proxy, const AMD_Object_ice_invokePtr& amd try { - AMI_Array_Object_ice_invokePtr amiCB; - Ice::AMISentCallback* sentCB = 0; + Callback_Object_ice_invokePtr amiCB; if(proxy->ice_isTwoway()) { - amiCB = new AMI_Array_Object_ice_invokeTwowayI(amdCB, _instance, _reverseConnection); + amiCB = newCallback_Object_ice_invoke(this, &Blobject::invokeResponse, &Blobject::invokeException); } else { - AMI_Array_Object_ice_invokeOnewayI* cb = - new AMI_Array_Object_ice_invokeOnewayI(amdCB, _instance, _reverseConnection); - amiCB = cb; - sentCB = cb; + amiCB = newCallback_Object_ice_invoke(this, &Blobject::invokeException, &Blobject::invokeSent); } - bool sent; if(_forwardContext) { if(_context.size() > 0) { - Ice::Context ctx = current.ctx; + Context ctx = current.ctx; ctx.insert(_context.begin(), _context.end()); - sent = proxy->ice_invoke_async(amiCB, current.operation, current.mode, inParams, ctx); + proxy->begin_ice_invoke(current.operation, current.mode, inParams, ctx, amiCB, + new InvokeCookie(amdCB)); } else { - sent = proxy->ice_invoke_async(amiCB, current.operation, current.mode, inParams, current.ctx); + proxy->begin_ice_invoke(current.operation, current.mode, inParams, current.ctx, amiCB, + new InvokeCookie(amdCB)); } } else { if(_context.size() > 0) { - sent = proxy->ice_invoke_async(amiCB, current.operation, current.mode, inParams, _context); + proxy->begin_ice_invoke(current.operation, current.mode, inParams, _context, amiCB, + new InvokeCookie(amdCB)); } else { - sent = proxy->ice_invoke_async(amiCB, current.operation, current.mode, inParams); + proxy->begin_ice_invoke(current.operation, current.mode, inParams, amiCB, + new InvokeCookie(amdCB)); } } - - if(sent && sentCB) - { - sentCB->ice_sent(); - } } catch(const LocalException& ex) { diff --git a/cpp/src/Glacier2/Blobject.h b/cpp/src/Glacier2/Blobject.h index 05e6c63fe3b..dff1fbe91ca 100644 --- a/cpp/src/Glacier2/Blobject.h +++ b/cpp/src/Glacier2/Blobject.h @@ -25,6 +25,31 @@ public: void destroy(); + class InvokeCookie : public Ice::LocalObject + { + public: + + InvokeCookie(const Ice::AMD_Object_ice_invokePtr& cb) : + _cb(cb) + { + } + + Ice::AMD_Object_ice_invokePtr cb() + { + return _cb; + } + + private: + + Ice::AMD_Object_ice_invokePtr _cb; + }; + typedef IceUtil::Handle<InvokeCookie> InvokeCookiePtr; + + void invokeResponse(bool, const std::pair<const Ice::Byte*, const Ice::Byte*>&, + const InvokeCookiePtr&); + void invokeSent(bool, const InvokeCookiePtr&); + void invokeException(const Ice::Exception&, const InvokeCookiePtr&); + protected: void invoke(Ice::ObjectPrx&, const Ice::AMD_Object_ice_invokePtr&, diff --git a/cpp/src/Glacier2/RouterI.cpp b/cpp/src/Glacier2/RouterI.cpp index 058b1bf7104..b0624578d41 100644 --- a/cpp/src/Glacier2/RouterI.cpp +++ b/cpp/src/Glacier2/RouterI.cpp @@ -65,7 +65,7 @@ Glacier2::RouterI::~RouterI() } void -Glacier2::RouterI::destroy(const AMI_Session_destroyPtr& amiCB) +Glacier2::RouterI::destroy(const Callback_Session_destroyPtr& asyncCB) { if(_session) { @@ -91,11 +91,11 @@ Glacier2::RouterI::destroy(const AMI_Session_destroyPtr& amiCB) if(_context.size() > 0) { - _session->destroy_async(amiCB, _context); + _session->begin_destroy(_context, asyncCB); } else { - _session->destroy_async(amiCB); + _session->begin_destroy(asyncCB); } } diff --git a/cpp/src/Glacier2/RouterI.h b/cpp/src/Glacier2/RouterI.h index 619ef513b48..30ddb91024e 100644 --- a/cpp/src/Glacier2/RouterI.h +++ b/cpp/src/Glacier2/RouterI.h @@ -32,7 +32,7 @@ public: const FilterManagerPtr&, const Ice::Context&); virtual ~RouterI(); - void destroy(const AMI_Session_destroyPtr&); + void destroy(const Callback_Session_destroyPtr&); virtual Ice::ObjectPrx getClientProxy(const Ice::Current& = Ice::Current()) const; virtual Ice::ObjectPrx getServerProxy(const Ice::Current& = Ice::Current()) const; diff --git a/cpp/src/Glacier2/SessionRouterI.cpp b/cpp/src/Glacier2/SessionRouterI.cpp index 0764521248b..6f4546a5463 100644 --- a/cpp/src/Glacier2/SessionRouterI.cpp +++ b/cpp/src/Glacier2/SessionRouterI.cpp @@ -21,6 +21,7 @@ using namespace std; using namespace Ice; +using namespace Glacier2; namespace Glacier2 { @@ -146,48 +147,33 @@ public: _password(password) { } + - class CheckPermissionsCB : public AMI_PermissionsVerifier_checkPermissions + void + checkPermissionsResponse(bool ok, const string& reason) { - public: - - CheckPermissionsCB(const UserPasswordCreateSessionPtr& session, bool hasSessionManager) : - _session(session), - _hasSessionManager(hasSessionManager) + if(ok) { + authorized(_sessionRouter->_sessionManager); } - - virtual void - ice_response(bool ok, const string& reason) + else { - if(ok) - { - _session->authorized(_hasSessionManager); - } - else - { - _session->exception(PermissionDeniedException(reason.empty() ? string("permission denied") : reason)); - } + exception(PermissionDeniedException(reason.empty() ? string("permission denied") : reason)); } + } - virtual void - ice_exception(const Ice::Exception& ex) + void + checkPermissionsException(const Ice::Exception& ex) + { + if(dynamic_cast<const CollocationOptimizationException*>(&ex)) { - if(dynamic_cast<const CollocationOptimizationException*>(&ex)) - { - _session->authorizeCollocated(); - } - else - { - _session->unexpectedAuthorizeException(ex); - } + authorizeCollocated(); } - - private: - - const UserPasswordCreateSessionPtr _session; - const bool _hasSessionManager; - }; + else + { + unexpectedAuthorizeException(ex); + } + } virtual void authorize() @@ -196,8 +182,11 @@ public: Ice::Context ctx = _current.ctx; ctx.insert(_context.begin(), _context.end()); - AMI_PermissionsVerifier_checkPermissionsPtr cb = new CheckPermissionsCB(this, _sessionRouter->_sessionManager); - _sessionRouter->_verifier->checkPermissions_async(cb, _user, _password, ctx); + + _sessionRouter->_verifier->begin_checkPermissions(_user, _password, ctx, + newCallback_PermissionsVerifier_checkPermissions(this, + &UserPasswordCreateSession::checkPermissionsResponse, + &UserPasswordCreateSession::checkPermissionsException)); } virtual void @@ -229,48 +218,16 @@ public: return FilterManager::create(_instance, _user, true); } - class CreateCB : public AMI_SessionManager_create - { - public: - - CreateCB(const CreateSessionPtr& session) : _session(session) - { - } - - virtual void - ice_response(const SessionPrx& session) - { - _session->sessionCreated(session); - } - - virtual void - ice_exception(const Ice::Exception& ex) - { - try - { - ex.ice_throw(); - } - catch(const CannotCreateSessionException& ex) - { - _session->exception(ex); - } - catch(const Ice::Exception& ex) - { - _session->unexpectedCreateSessionException(ex); - } - } - - private: - - const CreateSessionPtr _session; - }; - virtual void createSession() { Ice::Context ctx = _current.ctx; ctx.insert(_context.begin(), _context.end()); - _sessionRouter->_sessionManager->create_async(new CreateCB(this), _user, _control, ctx); + _sessionRouter->_sessionManager->begin_create(_user, _control, ctx, + newCallback_SessionManager_create( + static_cast<CreateSession*>(this), + &CreateSession::sessionCreated, + &CreateSession::createException)); } virtual void @@ -302,49 +259,32 @@ public: _sslInfo(sslInfo) { } - - class AuthorizeCB : public AMI_SSLPermissionsVerifier_authorize + + void + authorizeResponse(bool ok, const string& reason) { - public: - - AuthorizeCB(const SSLCreateSessionPtr& session, bool hasSessionManager) : - _session(session), - _hasSessionManager(hasSessionManager) + if(ok) { + authorized(_sessionRouter->_sslSessionManager); } - - virtual void - ice_response(bool ok, const string& reason) + else { - if(ok) - { - _session->authorized(_hasSessionManager); - } - else - { - _session->exception(PermissionDeniedException(reason.empty() ? string("permission denied") - : reason)); - } + exception(PermissionDeniedException(reason.empty() ? string("permission denied") : reason)); } + } - virtual void - ice_exception(const Ice::Exception& ex) + void + authorizeException(const Ice::Exception& ex) + { + if(dynamic_cast<const CollocationOptimizationException*>(&ex)) { - if(dynamic_cast<const CollocationOptimizationException*>(&ex)) - { - _session->authorizeCollocated(); - } - else - { - _session->unexpectedAuthorizeException(ex); - } + authorizeCollocated(); } - - private: - - const SSLCreateSessionPtr _session; - const bool _hasSessionManager; - }; + else + { + unexpectedAuthorizeException(ex); + } + } virtual void authorize() @@ -353,9 +293,10 @@ public: Ice::Context ctx = _current.ctx; ctx.insert(_context.begin(), _context.end()); - - AMI_SSLPermissionsVerifier_authorizePtr cb = new AuthorizeCB(this, _sessionRouter->_sslSessionManager); - _sessionRouter->_sslVerifier->authorize_async(cb, _sslInfo, ctx); + _sessionRouter->_sslVerifier->begin_authorize(_sslInfo, ctx, + newCallback_SSLPermissionsVerifier_authorize(this, + &SSLCreateSession::authorizeResponse, + &SSLCreateSession::authorizeException)); } virtual void @@ -387,48 +328,16 @@ public: return FilterManager::create(_instance, _user, false); } - class CreateCB : public AMI_SSLSessionManager_create - { - public: - - CreateCB(const CreateSessionPtr& session) : _session(session) - { - } - - virtual void - ice_response(const SessionPrx& session) - { - _session->sessionCreated(session); - } - - virtual void - ice_exception(const Ice::Exception& ex) - { - try - { - ex.ice_throw(); - } - catch(const CannotCreateSessionException& ex) - { - _session->exception(ex); - } - catch(const Ice::Exception& ex) - { - _session->unexpectedCreateSessionException(ex); - } - } - - private: - - const CreateSessionPtr _session; - }; - virtual void createSession() { Ice::Context ctx = _current.ctx; ctx.insert(_context.begin(), _context.end()); - _sessionRouter->_sslSessionManager->create_async(new CreateCB(this), _sslInfo, _control, ctx); + _sessionRouter->_sslSessionManager->begin_create(_sslInfo, _control, ctx, + newCallback_SSLSessionManager_create( + static_cast<CreateSession*>(this), + &CreateSession::sessionCreated, + &CreateSession::createException)); } virtual void @@ -449,44 +358,9 @@ private: const SSLInfo _sslInfo; }; -class DestroyCB : public AMI_Session_destroy -{ -public: - - DestroyCB(int traceLevel, const LoggerPtr& logger) - { - if(traceLevel > 0) - { - _logger = logger; - } - } - - virtual void - ice_response() - { - } - - virtual void - ice_exception(const Ice::Exception& ex) - { - if(_logger) - { - Trace out(_logger, "Glacier2"); - out << "exception while destroying session\n" << ex; - } - } - -private: - - LoggerPtr _logger; -}; - } -using namespace Glacier2; - -Glacier2::CreateSession::CreateSession(const SessionRouterIPtr& sessionRouter, const string& user, - const Ice::Current& current) : +CreateSession::CreateSession(const SessionRouterIPtr& sessionRouter, const string& user, const Ice::Current& current) : _instance(sessionRouter->_instance), _sessionRouter(sessionRouter), _user(user), @@ -523,7 +397,7 @@ Glacier2::CreateSession::CreateSession(const SessionRouterIPtr& sessionRouter, c } void -Glacier2::CreateSession::create() +CreateSession::create() { try { @@ -539,13 +413,13 @@ Glacier2::CreateSession::create() } void -Glacier2::CreateSession::addPendingCallback(const CreateSessionPtr& callback) +CreateSession::addPendingCallback(const CreateSessionPtr& callback) { _pendingCallbacks.push_back(callback); } void -Glacier2::CreateSession::authorized(bool createSession) +CreateSession::authorized(bool createSession) { // // Create the filter manager now as it's required for the session control object. @@ -572,7 +446,7 @@ Glacier2::CreateSession::authorized(bool createSession) } void -Glacier2::CreateSession::unexpectedAuthorizeException(const Ice::Exception& ex) +CreateSession::unexpectedAuthorizeException(const Ice::Exception& ex) { if(_sessionRouter->sessionTraceLevel() >= 1) { @@ -583,7 +457,24 @@ Glacier2::CreateSession::unexpectedAuthorizeException(const Ice::Exception& ex) } void -Glacier2::CreateSession::sessionCreated(const SessionPrx& session) +CreateSession::createException(const Ice::Exception& ex) +{ + try + { + ex.ice_throw(); + } + catch(const CannotCreateSessionException& ex) + { + exception(ex); + } + catch(const Ice::Exception& ex) + { + unexpectedCreateSessionException(ex); + } +} + +void +CreateSession::sessionCreated(const SessionPrx& session) { // // Create the session router object. @@ -633,7 +524,7 @@ Glacier2::CreateSession::sessionCreated(const SessionPrx& session) { if(session) { - session->destroy_async(new DestroyCB(0, 0)); + session->begin_destroy(); } unexpectedCreateSessionException(ex); return; @@ -659,7 +550,7 @@ Glacier2::CreateSession::sessionCreated(const SessionPrx& session) } void -Glacier2::CreateSession::unexpectedCreateSessionException(const Ice::Exception& ex) +CreateSession::unexpectedCreateSessionException(const Ice::Exception& ex) { if(_sessionRouter->sessionTraceLevel() >= 1) { @@ -670,7 +561,7 @@ Glacier2::CreateSession::unexpectedCreateSessionException(const Ice::Exception& } void -Glacier2::CreateSession::exception(const Ice::Exception& ex) +CreateSession::exception(const Ice::Exception& ex) { try { @@ -699,11 +590,11 @@ Glacier2::CreateSession::exception(const Ice::Exception& ex) } } -Glacier2::SessionRouterI::SessionRouterI(const InstancePtr& instance, - const PermissionsVerifierPrx& verifier, - const SessionManagerPrx& sessionManager, - const SSLPermissionsVerifierPrx& sslVerifier, - const SSLSessionManagerPrx& sslSessionManager) : +SessionRouterI::SessionRouterI(const InstancePtr& instance, + const PermissionsVerifierPrx& verifier, + const SessionManagerPrx& sessionManager, + const SSLPermissionsVerifierPrx& sslVerifier, + const SSLSessionManagerPrx& sslSessionManager) : _instance(instance), _sessionTraceLevel(_instance->properties()->getPropertyAsInt("Glacier2.Trace.Session")), _rejectTraceLevel(_instance->properties()->getPropertyAsInt("Glacier2.Client.Trace.Reject")), @@ -716,6 +607,7 @@ Glacier2::SessionRouterI::SessionRouterI(const InstancePtr& instance, _routersByConnectionHint(_routersByConnection.end()), _routersByCategoryHint(_routersByCategory.end()), _sessionPingCallback(newCallback_Object_ice_ping(this, &SessionRouterI::sessionPingException)), + _sessionDestroyCallback(newCallback_Session_destroy(this, &SessionRouterI::sessionDestroyException)), _destroy(false) { @@ -772,7 +664,7 @@ Glacier2::SessionRouterI::SessionRouterI(const InstancePtr& instance, _instance->setSessionRouter(this); } -Glacier2::SessionRouterI::~SessionRouterI() +SessionRouterI::~SessionRouterI() { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); @@ -784,11 +676,11 @@ Glacier2::SessionRouterI::~SessionRouterI() } void -Glacier2::SessionRouterI::destroy() +SessionRouterI::destroy() { map<ConnectionPtr, RouterIPtr> routers; SessionThreadPtr sessionThread; - + Callback_Session_destroyPtr destroyCallback; { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); @@ -805,6 +697,7 @@ Glacier2::SessionRouterI::destroy() sessionThread = _sessionThread; _sessionThread = 0; + swap(destroyCallback, _sessionDestroyCallback); // Break cyclic reference count. _sessionPingCallback = 0; // Break cyclic reference count. } @@ -814,7 +707,7 @@ Glacier2::SessionRouterI::destroy() // for(map<ConnectionPtr, RouterIPtr>::iterator p = routers.begin(); p != routers.end(); ++p) { - p->second->destroy(new DestroyCB(_sessionTraceLevel, _instance->logger())); + p->second->destroy(destroyCallback); } if(sessionThread) @@ -825,19 +718,19 @@ Glacier2::SessionRouterI::destroy() } ObjectPrx -Glacier2::SessionRouterI::getClientProxy(const Current& current) const +SessionRouterI::getClientProxy(const Current& current) const { return getRouter(current.con, current.id)->getClientProxy(current); // Forward to the per-client router. } ObjectPrx -Glacier2::SessionRouterI::getServerProxy(const Current& current) const +SessionRouterI::getServerProxy(const Current& current) const { return getRouter(current.con, current.id)->getServerProxy(current); // Forward to the per-client router. } void -Glacier2::SessionRouterI::addProxy(const ObjectPrx& proxy, const Current& current) +SessionRouterI::addProxy(const ObjectPrx& proxy, const Current& current) { ObjectProxySeq seq; seq.push_back(proxy); @@ -845,7 +738,7 @@ Glacier2::SessionRouterI::addProxy(const ObjectPrx& proxy, const Current& curren } ObjectProxySeq -Glacier2::SessionRouterI::addProxies(const ObjectProxySeq& proxies, const Current& current) +SessionRouterI::addProxies(const ObjectProxySeq& proxies, const Current& current) { // // Forward to the per-client router. @@ -854,7 +747,7 @@ Glacier2::SessionRouterI::addProxies(const ObjectProxySeq& proxies, const Curren } string -Glacier2::SessionRouterI::getCategoryForClient(const Ice::Current& current) const +SessionRouterI::getCategoryForClient(const Ice::Current& current) const { // Forward to the per-client router. if(_instance->serverObjectAdapter()) @@ -868,7 +761,7 @@ Glacier2::SessionRouterI::getCategoryForClient(const Ice::Current& current) cons } void -Glacier2::SessionRouterI::createSession_async(const AMD_Router_createSessionPtr& amdCB, const std::string& userId, +SessionRouterI::createSession_async(const AMD_Router_createSessionPtr& amdCB, const std::string& userId, const std::string& password, const Current& current) { if(!_verifier) @@ -882,7 +775,7 @@ Glacier2::SessionRouterI::createSession_async(const AMD_Router_createSessionPtr& } void -Glacier2::SessionRouterI::createSessionFromSecureConnection_async( +SessionRouterI::createSessionFromSecureConnection_async( const AMD_Router_createSessionFromSecureConnectionPtr& amdCB, const Current& current) { if(!_sslVerifier) @@ -932,13 +825,13 @@ Glacier2::SessionRouterI::createSessionFromSecureConnection_async( } void -Glacier2::SessionRouterI::destroySession(const Current& current) +SessionRouterI::destroySession(const Current& current) { destroySession(current.con); } void -Glacier2::SessionRouterI::refreshSession(const Ice::Current& current) +SessionRouterI::refreshSession(const Ice::Current& current) { RouterIPtr router = getRouter(current.con, current.id, false); if(!router) @@ -951,7 +844,7 @@ Glacier2::SessionRouterI::refreshSession(const Ice::Current& current) // Ping the session to ensure it does not timeout. // assert(_sessionPingCallback); - Glacier2::SessionPrx session = router->getSession(); + SessionPrx session = router->getSession(); if(session) { session->begin_ice_ping(_sessionPingCallback, current.con); @@ -959,7 +852,7 @@ Glacier2::SessionRouterI::refreshSession(const Ice::Current& current) } void -Glacier2::SessionRouterI::destroySession(const ConnectionPtr& connection) +SessionRouterI::destroySession(const ConnectionPtr& connection) { RouterIPtr router; @@ -1010,18 +903,17 @@ Glacier2::SessionRouterI::destroySession(const ConnectionPtr& connection) Trace out(_instance->logger(), "Glacier2"); out << "destroying session\n" << router->toString(); } - - router->destroy(new DestroyCB(_sessionTraceLevel, _instance->logger())); + router->destroy(_sessionDestroyCallback); } Ice::Long -Glacier2::SessionRouterI::getSessionTimeout(const Ice::Current&) const +SessionRouterI::getSessionTimeout(const Ice::Current&) const { return _sessionTimeout.toSeconds(); } RouterIPtr -Glacier2::SessionRouterI::getRouter(const ConnectionPtr& connection, const Ice::Identity& id, bool close) const +SessionRouterI::getRouter(const ConnectionPtr& connection, const Ice::Identity& id, bool close) const { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); @@ -1059,7 +951,7 @@ Glacier2::SessionRouterI::getRouter(const ConnectionPtr& connection, const Ice:: } RouterIPtr -Glacier2::SessionRouterI::getRouter(const string& category) const +SessionRouterI::getRouter(const string& category) const { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); @@ -1089,7 +981,7 @@ Glacier2::SessionRouterI::getRouter(const string& category) const } void -Glacier2::SessionRouterI::expireSessions() +SessionRouterI::expireSessions() { vector<RouterIPtr> routers; @@ -1142,19 +1034,29 @@ Glacier2::SessionRouterI::expireSessions() Trace out(_instance->logger(), "Glacier2"); out << "expiring session\n" << (*p)->toString(); } - - (*p)->destroy(new DestroyCB(_sessionTraceLevel, _instance->logger())); + (*p)->destroy(_sessionDestroyCallback); } } void -Glacier2::SessionRouterI::sessionPingException(const Ice::Exception&, const Ice::ConnectionPtr& con) +SessionRouterI::sessionPingException(const Ice::Exception&, const Ice::ConnectionPtr& con) { destroySession(con); } +void +SessionRouterI::sessionDestroyException(const Ice::Exception& ex) +{ + if(_sessionTraceLevel > 0) + { + Trace out(_instance->logger(), "Glacier2"); + out << "exception while destroying session\n" << ex; + } +} + + bool -Glacier2::SessionRouterI::startCreateSession(const CreateSessionPtr& cb, const ConnectionPtr& connection) +SessionRouterI::startCreateSession(const CreateSessionPtr& cb, const ConnectionPtr& connection) { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); @@ -1211,7 +1113,7 @@ Glacier2::SessionRouterI::startCreateSession(const CreateSessionPtr& cb, const C } void -Glacier2::SessionRouterI::finishCreateSession(const ConnectionPtr& connection, const RouterIPtr& router) +SessionRouterI::finishCreateSession(const ConnectionPtr& connection, const RouterIPtr& router) { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); @@ -1229,7 +1131,7 @@ Glacier2::SessionRouterI::finishCreateSession(const ConnectionPtr& connection, c if(_destroy) { - router->destroy(new DestroyCB(0, 0)); + router->destroy(_sessionDestroyCallback); CannotCreateSessionException exc; exc.reason = "router is shutting down"; @@ -1256,7 +1158,7 @@ Glacier2::SessionRouterI::finishCreateSession(const ConnectionPtr& connection, c } } -Glacier2::SessionRouterI::SessionThread::SessionThread(const SessionRouterIPtr& sessionRouter, +SessionRouterI::SessionThread::SessionThread(const SessionRouterIPtr& sessionRouter, const IceUtil::Time& sessionTimeout) : IceUtil::Thread("Glacier2 session thread"), _sessionRouter(sessionRouter), @@ -1264,13 +1166,13 @@ Glacier2::SessionRouterI::SessionThread::SessionThread(const SessionRouterIPtr& { } -Glacier2::SessionRouterI::SessionThread::~SessionThread() +SessionRouterI::SessionThread::~SessionThread() { assert(!_sessionRouter); } void -Glacier2::SessionRouterI::SessionThread::destroy() +SessionRouterI::SessionThread::destroy() { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); _sessionRouter = 0; @@ -1278,7 +1180,7 @@ Glacier2::SessionRouterI::SessionThread::destroy() } void -Glacier2::SessionRouterI::SessionThread::run() +SessionRouterI::SessionThread::run() { while(true) { diff --git a/cpp/src/Glacier2/SessionRouterI.h b/cpp/src/Glacier2/SessionRouterI.h index a494d1158bf..ecf6ff120fc 100644 --- a/cpp/src/Glacier2/SessionRouterI.h +++ b/cpp/src/Glacier2/SessionRouterI.h @@ -51,6 +51,8 @@ public: void unexpectedCreateSessionException(const Ice::Exception&); void exception(const Ice::Exception&); + + void createException(const Ice::Exception&); virtual void authorize() = 0; virtual void createSession() = 0; @@ -110,6 +112,7 @@ public: private: void sessionPingException(const Ice::Exception&, const ::Ice::ConnectionPtr&); + void sessionDestroyException(const Ice::Exception&); bool startCreateSession(const CreateSessionPtr&, const Ice::ConnectionPtr&); void finishCreateSession(const Ice::ConnectionPtr&, const RouterIPtr&); @@ -153,6 +156,7 @@ private: std::map<Ice::ConnectionPtr, CreateSessionPtr> _pending; Ice::Callback_Object_ice_pingPtr _sessionPingCallback; + Callback_Session_destroyPtr _sessionDestroyCallback; bool _destroy; }; diff --git a/cpp/src/Glacier2Lib/Application.cpp b/cpp/src/Glacier2Lib/Application.cpp index 8b62671a3d9..806071206be 100644 --- a/cpp/src/Glacier2Lib/Application.cpp +++ b/cpp/src/Glacier2Lib/Application.cpp @@ -23,73 +23,44 @@ string Glacier2::Application::_category; namespace { -class SessionPingThread : virtual public IceUtil::Shared +class SessionPingThreadI : virtual public IceUtil::Thread { public: - virtual void done() = 0; -}; -typedef IceUtil::Handle<SessionPingThread> SessionPingThreadPtr; - -class AMI_Router_refreshSessionI : public Glacier2::AMI_Router_refreshSession -{ - -public: - - AMI_Router_refreshSessionI(Glacier2::Application* app, const SessionPingThreadPtr& pinger) : + SessionPingThreadI(Glacier2::Application* app, const Glacier2::RouterPrx& router, IceUtil::Int64 period) : _app(app), - _pinger(pinger) - { - } - - void - ice_response() + _router(router), + _period(period), + _done(false) { + assert(_period); } void - ice_exception(const Ice::Exception& ex) + exception(const Ice::Exception& ex) { // - // Here the session has gone. The thread - // terminates, and we notify the - // application that the session has been + // Here the session has been destroyed. The thread terminates, + // and we notify the application that the session has been // destroyed. // - _pinger->done(); + done(); _app->sessionDestroyed(); } -private: - - Glacier2::Application* _app; - SessionPingThreadPtr _pinger; -}; - -class SessionPingThreadI : virtual public IceUtil::Thread, virtual public SessionPingThread -{ - -public: - - SessionPingThreadI(Glacier2::Application* app, const Glacier2::RouterPrx& router, IceUtil::Int64 period) : - _app(app), - _router(router), - _period(period), - _done(false) - { - assert(_period); - } - void run() { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor); + + Glacier2::Callback_Router_refreshSessionPtr callback = + Glacier2::newCallback_Router_refreshSession(this, &SessionPingThreadI::exception); while(true) { try { - _router->refreshSession_async(new AMI_Router_refreshSessionI(_app, this)); + _router->begin_refreshSession(callback); } catch(const Ice::CommunicatorDestroyedException&) { @@ -140,7 +111,7 @@ Glacier2::RestartSessionException::ice_name() const return "RestartSessionException"; } -Exception* +Glacier2::RestartSessionException* Glacier2::RestartSessionException::ice_clone() const { return new RestartSessionException(*this); diff --git a/cpp/src/Glacier2Lib/SessionHelper.cpp b/cpp/src/Glacier2Lib/SessionHelper.cpp index 046cc984d11..31cfc92fbee 100644 --- a/cpp/src/Glacier2Lib/SessionHelper.cpp +++ b/cpp/src/Glacier2Lib/SessionHelper.cpp @@ -70,7 +70,6 @@ public: private: - const Glacier2::Callback_Router_refreshSessionPtr _cb; const Glacier2::SessionHelperPtr _session; const Glacier2::RouterPrx _router; Ice::Long _period; @@ -130,8 +129,6 @@ typedef IceUtil::Handle<SessionHelperI> SessionHelperIPtr; SessionRefreshThread::SessionRefreshThread(const Glacier2::SessionHelperPtr& session, const Glacier2::RouterPrx& router, Ice::Long period) : - _cb(Glacier2::newCallback_Router_refreshSession(this, &SessionRefreshThread::success, - &SessionRefreshThread::failure)), _session(session), _router(router), _period(period), @@ -142,12 +139,14 @@ SessionRefreshThread::SessionRefreshThread(const Glacier2::SessionHelperPtr& ses void SessionRefreshThread::run() { + Glacier2::Callback_Router_refreshSessionPtr cb = + Glacier2::newCallback_Router_refreshSession(this, &SessionRefreshThread::failure); IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor); while(true) { try { - _router->begin_refreshSession(_cb); + _router->begin_refreshSession(cb); } catch(const Ice::CommunicatorDestroyedException&) { @@ -181,11 +180,6 @@ SessionRefreshThread::done() } void -SessionRefreshThread::success() -{ -} - -void SessionRefreshThread::failure(const Ice::Exception&) { done(); @@ -517,7 +511,7 @@ public: _callback(callback), _session(session) { - _ex.reset(dynamic_cast<Ice::Exception*>(ex.ice_clone())); + _ex.reset(ex.ice_clone()); } virtual void diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp index a54c8bfb9b0..25762041b06 100644 --- a/cpp/src/Ice/CommunicatorI.cpp +++ b/cpp/src/Ice/CommunicatorI.cpp @@ -310,20 +310,20 @@ Ice::CommunicatorI::flushBatchRequests() AsyncResultPtr Ice::CommunicatorI::begin_flushBatchRequests() { - return begin_flushBatchRequestsInternal(::IceInternal::__dummyCallback, 0); + return __begin_flushBatchRequests(::IceInternal::__dummyCallback, 0); } AsyncResultPtr Ice::CommunicatorI::begin_flushBatchRequests(const CallbackPtr& cb, const LocalObjectPtr& cookie) { - return begin_flushBatchRequestsInternal(cb, cookie); + return __begin_flushBatchRequests(cb, cookie); } AsyncResultPtr Ice::CommunicatorI::begin_flushBatchRequests(const Callback_Communicator_flushBatchRequestsPtr& cb, const LocalObjectPtr& cookie) { - return begin_flushBatchRequestsInternal(cb, cookie); + return __begin_flushBatchRequests(cb, cookie); } namespace @@ -334,7 +334,7 @@ const ::std::string __flushBatchRequests_name = "flushBatchRequests"; } AsyncResultPtr -Ice::CommunicatorI::begin_flushBatchRequestsInternal(const IceInternal::CallbackBasePtr& cb, +Ice::CommunicatorI::__begin_flushBatchRequests(const IceInternal::CallbackBasePtr& cb, const LocalObjectPtr& cookie) { OutgoingConnectionFactoryPtr connectionFactory = _instance->outgoingConnectionFactory(); diff --git a/cpp/src/Ice/CommunicatorI.h b/cpp/src/Ice/CommunicatorI.h index dd21e0b941b..d9628478707 100644 --- a/cpp/src/Ice/CommunicatorI.h +++ b/cpp/src/Ice/CommunicatorI.h @@ -14,6 +14,7 @@ #include <Ice/DynamicLibraryF.h> #include <Ice/Initialize.h> #include <Ice/Communicator.h> +#include <Ice/CommunicatorAsync.h> namespace Ice { @@ -60,6 +61,15 @@ public: virtual void flushBatchRequests(); +#ifdef ICE_CPP11 + virtual ::Ice::AsyncResultPtr begin_flushBatchRequests( + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception, + const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) + { + return __begin_flushBatchRequests(new Cpp11FnCallbackNC_Communicator_flushBatchRequests(exception, sent), 0); + } +#endif + virtual AsyncResultPtr begin_flushBatchRequests(); virtual AsyncResultPtr begin_flushBatchRequests(const CallbackPtr&, const LocalObjectPtr& = 0); virtual AsyncResultPtr begin_flushBatchRequests(const Callback_Communicator_flushBatchRequestsPtr&, @@ -86,7 +96,7 @@ private: friend ICE_API CommunicatorPtr initialize(const InitializationData&, Int); friend ICE_API ::IceInternal::InstancePtr IceInternal::getInstance(const ::Ice::CommunicatorPtr&); - AsyncResultPtr begin_flushBatchRequestsInternal(const IceInternal::CallbackBasePtr&, const LocalObjectPtr&); + AsyncResultPtr __begin_flushBatchRequests(const IceInternal::CallbackBasePtr&, const LocalObjectPtr&); const ::IceInternal::InstancePtr _instance; diff --git a/cpp/src/Ice/ConnectRequestHandler.cpp b/cpp/src/Ice/ConnectRequestHandler.cpp index c04164af0d4..3d35eb40c10 100644 --- a/cpp/src/Ice/ConnectRequestHandler.cpp +++ b/cpp/src/Ice/ConnectRequestHandler.cpp @@ -34,7 +34,7 @@ public: const Ice::LocalException& ex) : DispatchWorkItem(instance), _handler(handler), - _exception(dynamic_cast<Ice::LocalException*>(ex.ice_clone())) + _exception(ex.ice_clone()) { } @@ -328,7 +328,7 @@ ConnectRequestHandler::setException(const Ice::LocalException& ex) assert(!_initialized && !_exception.get()); assert(_updateRequestHandler || _requests.empty()); - _exception.reset(dynamic_cast<Ice::LocalException*>(ex.ice_clone())); + _exception.reset(ex.ice_clone()); _proxy = 0; // Break cyclic reference count. _delegate = 0; // Break cyclic reference count. @@ -451,7 +451,7 @@ ConnectRequestHandler::flushRequests() { Lock sync(*this); assert(!_exception.get() && !_requests.empty()); - _exception.reset(dynamic_cast<Ice::LocalException*>(ex.get()->ice_clone())); + _exception.reset(ex.get()->ice_clone()); const InstancePtr instance = _reference->getInstance(); instance->clientThreadPool()->execute(new FlushRequestsWithExceptionWrapper(instance, this, ex)); } @@ -459,7 +459,7 @@ ConnectRequestHandler::flushRequests() { Lock sync(*this); assert(!_exception.get() && !_requests.empty()); - _exception.reset(dynamic_cast<Ice::LocalException*>(ex.ice_clone())); + _exception.reset(ex.ice_clone()); const InstancePtr instance = _reference->getInstance(); instance->clientThreadPool()->execute(new FlushRequestsWithException(instance, this, ex)); } diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp index 3759ca19abe..2869d610748 100755 --- a/cpp/src/Ice/ConnectionFactory.cpp +++ b/cpp/src/Ice/ConnectionFactory.cpp @@ -206,7 +206,7 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointIPtr>& endpt } catch(const Ice::LocalException& ex) { - exception.reset(dynamic_cast<Ice::LocalException*>(ex.ice_clone())); + exception.reset(ex.ice_clone()); handleException(ex, hasMore || p != endpoints.end() - 1); } } @@ -276,7 +276,7 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointIPtr>& endpt observer->failed(ex.ice_name()); observer->detach(); } - exception.reset(dynamic_cast<Ice::LocalException*>(ex.ice_clone())); + exception.reset(ex.ice_clone()); handleConnectionException(*exception.get(), hasMore || q != connectors.end() - 1); connection = 0; break; // No need to continue @@ -288,7 +288,7 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointIPtr>& endpt observer->failed(ex.ice_name()); observer->detach(); } - exception.reset(dynamic_cast<Ice::LocalException*>(ex.ice_clone())); + exception.reset(ex.ice_clone()); handleConnectionException(*exception.get(), hasMore || q != connectors.end() - 1); connection = 0; } diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp index afc70dcf85f..fb38a16bc8a 100644 --- a/cpp/src/Ice/ConnectionI.cpp +++ b/cpp/src/Ice/ConnectionI.cpp @@ -924,7 +924,7 @@ Ice::ConnectionI::flushBatchRequests() AsyncResultPtr Ice::ConnectionI::begin_flushBatchRequests() { - return begin_flushBatchRequestsInternal(__dummyCallback, 0); + return __begin_flushBatchRequests(__dummyCallback, 0); } namespace @@ -937,18 +937,18 @@ const ::std::string __flushBatchRequests_name = "flushBatchRequests"; AsyncResultPtr Ice::ConnectionI::begin_flushBatchRequests(const CallbackPtr& cb, const LocalObjectPtr& cookie) { - return begin_flushBatchRequestsInternal(cb, cookie); + return __begin_flushBatchRequests(cb, cookie); } AsyncResultPtr Ice::ConnectionI::begin_flushBatchRequests(const Callback_Connection_flushBatchRequestsPtr& cb, const LocalObjectPtr& cookie) { - return begin_flushBatchRequestsInternal(cb, cookie); + return __begin_flushBatchRequests(cb, cookie); } AsyncResultPtr -Ice::ConnectionI::begin_flushBatchRequestsInternal(const CallbackBasePtr& cb, const LocalObjectPtr& cookie) +Ice::ConnectionI::__begin_flushBatchRequests(const CallbackBasePtr& cb, const LocalObjectPtr& cookie) { ConnectionBatchOutgoingAsyncPtr result = new ConnectionBatchOutgoingAsync(this, _communicator, _instance, __flushBatchRequests_name, cb, cookie); @@ -2018,7 +2018,7 @@ Ice::ConnectionI::setState(State state, const LocalException& ex) // assert(_state != StateClosed); - _exception.reset(dynamic_cast<LocalException*>(ex.ice_clone())); + _exception.reset(ex.ice_clone()); if(_warn) { diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h index 9fef29ea74e..57fd34d3e5f 100644 --- a/cpp/src/Ice/ConnectionI.h +++ b/cpp/src/Ice/ConnectionI.h @@ -31,6 +31,7 @@ #include <Ice/EventHandler.h> #include <Ice/Dispatcher.h> #include <Ice/ObserverHelper.h> +#include <Ice/ConnectionAsync.h> #include <deque> #include <memory> @@ -129,6 +130,15 @@ public: void abortBatchRequest(); virtual void flushBatchRequests(); // From Connection. + +#ifdef ICE_CPP11 + virtual ::Ice::AsyncResultPtr begin_flushBatchRequests( + const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception, + const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()) + { + return __begin_flushBatchRequests(new Cpp11FnCallbackNC_Connection_flushBatchRequests(exception, sent), 0); + } +#endif virtual AsyncResultPtr begin_flushBatchRequests(); virtual AsyncResultPtr begin_flushBatchRequests(const CallbackPtr&, const LocalObjectPtr& = 0); @@ -294,7 +304,7 @@ private: int connectTimeout(); int closeTimeout(); - AsyncResultPtr begin_flushBatchRequestsInternal(const IceInternal::CallbackBasePtr&, const LocalObjectPtr&); + AsyncResultPtr __begin_flushBatchRequests(const IceInternal::CallbackBasePtr&, const LocalObjectPtr&); Ice::CommunicatorPtr _communicator; const IceInternal::InstancePtr _instance; diff --git a/cpp/src/Ice/Direct.cpp b/cpp/src/Ice/Direct.cpp index 64f61790abe..9c4d906d9ec 100644 --- a/cpp/src/Ice/Direct.cpp +++ b/cpp/src/Ice/Direct.cpp @@ -107,7 +107,7 @@ IceInternal::Direct::throwUserException() void IceInternal::Direct::setUserException(const Ice::UserException& ue) { - _userException.reset(dynamic_cast<Ice::UserException*>(ue.ice_clone())); + _userException.reset(ue.ice_clone()); } void diff --git a/cpp/src/Ice/DynamicLibrary.cpp b/cpp/src/Ice/DynamicLibrary.cpp index 5b690df5f2b..ab724a9847a 100644 --- a/cpp/src/Ice/DynamicLibrary.cpp +++ b/cpp/src/Ice/DynamicLibrary.cpp @@ -50,7 +50,28 @@ IceInternal::DynamicLibrary::~DynamicLibrary() IceInternal::DynamicLibrary::symbol_type IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIceVersion) { + +#ifdef _WIN32 + bool isFilePath = entryPoint.find('\\') != string::npos || entryPoint.find('/') != string::npos; +#else + bool isFilePath = entryPoint.find('/') != string::npos; +#endif + string::size_type colon = entryPoint.rfind(':'); + +#ifdef _WIN32 + const string driveLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; + if(colon == 1 && driveLetters.find(entryPoint[0]) != string::npos && + (entryPoint[2] == '\\' || entryPoint[2] == '/')) + { + // + // The only colon we found is in the drive specification, as in "C:\MyDir". + // This means the function name is missing. + // + colon = string::npos; + } +#endif + string::size_type comma = entryPoint.find(','); if(colon == string::npos || colon == entryPoint.size() - 1 || (comma != string::npos && (comma > colon || comma == colon - 1))) @@ -58,9 +79,22 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc _err = "invalid entry point format `" + entryPoint + "'"; return 0; } + string libSpec = entryPoint.substr(0, colon); string funcName = entryPoint.substr(colon + 1); - string libName, version, debug; + string libPath, libName, version, debug; + + if(isFilePath) + { +#ifdef _WIN32 + string::size_type separator = entryPoint.find_last_of("/\\"); +#else + string::size_type separator = entryPoint.rfind('/'); +#endif + libPath = libSpec.substr(0, separator + 1); + libSpec = libSpec.substr(separator + 1); + } + if(comma == string::npos) { libName = libSpec; @@ -70,7 +104,7 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc int minorVersion = (ICE_INT_VERSION / 100) - majorVersion * 100; ostringstream os; os << majorVersion * 10 + minorVersion; - + int patchVersion = ICE_INT_VERSION % 100; if(patchVersion > 50) { @@ -89,10 +123,10 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc version = libSpec.substr(comma + 1); } - string lib; + string lib = libPath; #ifdef _WIN32 - lib = libName; + lib += libName; # ifdef COMPSUFFIX // @@ -114,13 +148,13 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc lib += ".dll"; #elif defined(__APPLE__) - lib = "lib" + libName; - if(!version.empty()) + lib += "lib" + libName; + if(!version.empty()) { lib += "." + version; } #elif defined(__hpux) - lib = "lib" + libName; + lib += "lib" + libName; if(!version.empty()) { lib += "." + version; @@ -130,14 +164,14 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc lib += ".sl"; } #elif defined(_AIX) - lib = "lib" + libName + ".a(lib" + libName + ".so"; + lib += "lib" + libName + ".a(lib" + libName + ".so"; if(!version.empty()) { lib += "." + version; } lib += ")"; #else - lib = "lib" + libName + ".so"; + lib += "lib" + libName + ".so"; if(!version.empty()) { lib += "." + version; @@ -217,16 +251,16 @@ IceInternal::DynamicLibrary::getSymbol(const string& name) #else symbol_type result = dlsym(_hnd, name.c_str()); #endif - + if(result == 0) { // // Remember the most recent error in _err. // #ifdef _WIN32 - _err = IceUtilInternal::lastErrorToString(); + _err = IceUtilInternal::lastErrorToString(); #else - const char* err = dlerror(); + const char* err = dlerror(); if(err) { _err = err; diff --git a/cpp/src/Ice/EventHandler.h b/cpp/src/Ice/EventHandler.h index 3c7ece52a57..04200f2d29e 100644 --- a/cpp/src/Ice/EventHandler.h +++ b/cpp/src/Ice/EventHandler.h @@ -19,7 +19,7 @@ namespace IceInternal { -class EventHandler : virtual public ::IceUtil::Shared +class ICE_API EventHandler : virtual public ::IceUtil::Shared { public: @@ -54,7 +54,7 @@ public: protected: EventHandler(); - ICE_API virtual ~EventHandler(); + virtual ~EventHandler(); #if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT) SocketOperation _ready; diff --git a/cpp/src/Ice/HashUtil.h b/cpp/src/Ice/HashUtil.h index 7b6c7f6a27b..d23ee90ff0c 100644 --- a/cpp/src/Ice/HashUtil.h +++ b/cpp/src/Ice/HashUtil.h @@ -15,13 +15,13 @@ namespace IceInternal inline void hashAdd(Ice::Int& hashCode, Ice::Int value) { - hashCode = hashCode * 5 + value; + hashCode = ((hashCode << 5) + hashCode) ^ (2654435761u * value); } inline void hashAdd(Ice::Int& hashCode, bool value) { - hashCode = hashCode * 5 + static_cast<Ice::Int>(value); + hashCode = ((hashCode << 5) + hashCode) ^ (value ? 1 : 0); } inline void @@ -29,7 +29,7 @@ hashAdd(Ice::Int& hashCode, const std::string& value) { for(std::string::const_iterator p = value.begin(); p != value.end(); ++p) { - hashCode = 5 * hashCode + *p; + hashCode = ((hashCode << 5) + hashCode) ^ *p; } } @@ -52,5 +52,4 @@ hashAdd(Ice::Int& hashCode, const std::map<K, V>& map) } } - } diff --git a/cpp/src/Ice/Initialize.cpp b/cpp/src/Ice/Initialize.cpp index f8b7f2a3cd4..adbd58424dc 100644 --- a/cpp/src/Ice/Initialize.cpp +++ b/cpp/src/Ice/Initialize.cpp @@ -323,3 +323,11 @@ IceInternal::getInstance(const CommunicatorPtr& communicator) assert(p); return p->_instance; } + +#ifdef ICE_CPP11 +void +IceInternal::Cpp11Dispatcher::dispatch(const ::Ice::DispatcherCallPtr& call, const ::Ice::ConnectionPtr& conn) +{ + _cb(call, conn); +} +#endif diff --git a/cpp/src/Ice/LocatorInfo.cpp b/cpp/src/Ice/LocatorInfo.cpp index 15c78d1fcd7..ac693041b2e 100644 --- a/cpp/src/Ice/LocatorInfo.cpp +++ b/cpp/src/Ice/LocatorInfo.cpp @@ -31,7 +31,7 @@ IceUtil::Shared* IceInternal::upCast(LocatorTable* p) { return p; } namespace { -class ObjectRequest : public LocatorInfo::Request, public Ice::AMI_Locator_findObjectById +class ObjectRequest : public LocatorInfo::Request { public: @@ -40,37 +40,31 @@ public: assert(ref->isWellKnown()); } - virtual void ice_response(const Ice::ObjectPrx& proxy) - { - response(proxy); - } - - virtual void ice_exception(const Ice::Exception& ex) - { - exception(ex); - } - virtual void send(bool async) { try { if(async) { - _locatorInfo->getLocator()->findObjectById_async(this, _ref->getIdentity()); + _locatorInfo->getLocator()->begin_findObjectById( + _ref->getIdentity(), + newCallback_Locator_findObjectById(static_cast<LocatorInfo::Request*>(this), + &LocatorInfo::Request::response, + &LocatorInfo::Request::exception)); } else { - ice_response(_locatorInfo->getLocator()->findObjectById(_ref->getIdentity())); + response(_locatorInfo->getLocator()->findObjectById(_ref->getIdentity())); } } catch(const Ice::Exception& ex) { - ice_exception(ex); + exception(ex); } } }; -class AdapterRequest : public LocatorInfo::Request, public Ice::AMI_Locator_findAdapterById +class AdapterRequest : public LocatorInfo::Request { public: @@ -79,32 +73,26 @@ public: assert(ref->isIndirect() && !ref->isWellKnown()); } - virtual void ice_response(const Ice::ObjectPrx& proxy) - { - response(proxy); - } - - virtual void ice_exception(const Ice::Exception& ex) - { - exception(ex); - } - virtual void send(bool async) { try { if(async) { - _locatorInfo->getLocator()->findAdapterById_async(this, _ref->getAdapterId()); + _locatorInfo->getLocator()->begin_findAdapterById( + _ref->getAdapterId(), + newCallback_Locator_findAdapterById(static_cast<LocatorInfo::Request*>(this), + &LocatorInfo::Request::response, + &LocatorInfo::Request::exception)); } else { - ice_response(_locatorInfo->getLocator()->findAdapterById(_ref->getAdapterId())); + response(_locatorInfo->getLocator()->findAdapterById(_ref->getAdapterId())); } } catch(const Ice::Exception& ex) { - ice_exception(ex); + exception(ex); } } }; diff --git a/cpp/src/Ice/LocatorInfo.h b/cpp/src/Ice/LocatorInfo.h index 4abbfac03ff..09f114663cc 100644 --- a/cpp/src/Ice/LocatorInfo.h +++ b/cpp/src/Ice/LocatorInfo.h @@ -109,14 +109,14 @@ public: void addCallback(const ReferencePtr&, const ReferencePtr&, int, const GetEndpointsCallbackPtr&); std::vector<EndpointIPtr> getEndpoints(const ReferencePtr&, const ReferencePtr&, int, bool&); + + void response(const Ice::ObjectPrx&); + void exception(const Ice::Exception&); protected: Request(const LocatorInfoPtr&, const ReferencePtr&); - void response(const Ice::ObjectPrx&); - void exception(const Ice::Exception&); - virtual void send(bool) = 0; const LocatorInfoPtr _locatorInfo; diff --git a/cpp/src/Ice/Makefile.mak b/cpp/src/Ice/Makefile.mak index 37f401cc50d..e07cc6833bc 100644 --- a/cpp/src/Ice/Makefile.mak +++ b/cpp/src/Ice/Makefile.mak @@ -130,7 +130,6 @@ CPPFLAGS = $(CPPFLAGS) -DCOMPSUFFIX=\"$(COMPSUFFIX)\" SLICE2CPPFLAGS = --ice --include-dir Ice --dll-export ICE_API $(SLICE2CPPFLAGS)
LINKWITH = $(BASELIBS) $(BZIP2_LIBS) $(ICE_OS_LIBS) ws2_32.lib Iphlpapi.lib
-
PDBFLAGS = /pdb:$(DLLNAME:.dll=.pdb)
LD_DLLFLAGS = $(LD_DLLFLAGS) /entry:"ice_DLL_Main"
RES_FILE = Ice.res
diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp index a86f23f2834..9ab03d9827c 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -17,6 +17,14 @@ # include <netinet/in.h> #endif +// +// The following is required for MinGW to bring in +// some definitions. +// +#if defined(__MINGW32__) +# define _WIN32_WINNT 0x0501 +#endif + #include <IceUtil/DisableWarnings.h> #include <Ice/Network.h> #include <IceUtil/StringUtil.h> @@ -1630,7 +1638,7 @@ IceInternal::doBind(SOCKET fd, const Address& addr) size = 0; // Keep the compiler happy. } - if(bind(fd, reinterpret_cast<const struct sockaddr*>(&addr), size) == SOCKET_ERROR) + if(::bind(fd, reinterpret_cast<const struct sockaddr*>(&addr), size) == SOCKET_ERROR) { closeSocketNoThrow(fd); SocketException ex(__FILE__, __LINE__); diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp index 879f486b78b..d5048326e93 100644 --- a/cpp/src/Ice/Object.cpp +++ b/cpp/src/Ice/Object.cpp @@ -86,7 +86,7 @@ Ice::Object::ice_staticId() return __Ice__Object_ids[0]; } -ObjectPtr +Ice::ObjectPtr Ice::Object::ice_clone() const { throw CloneNotImplementedException(__FILE__, __LINE__); diff --git a/cpp/src/Ice/OpaqueEndpointI.cpp b/cpp/src/Ice/OpaqueEndpointI.cpp index 42918b04fa9..6ce56874f74 100644 --- a/cpp/src/Ice/OpaqueEndpointI.cpp +++ b/cpp/src/Ice/OpaqueEndpointI.cpp @@ -433,7 +433,8 @@ IceInternal::OpaqueEndpointI::operator<(const LocalObject& r) const Ice::Int IceInternal::OpaqueEndpointI::hashInit() const { - Ice::Int h = _type; + Ice::Int h = 5381; + hashAdd(h, _type); hashAdd(h, _rawEncoding.major); hashAdd(h, _rawEncoding.minor); hashAdd(h, _rawBytes); diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp index d6d09d1271a..23fc92af5df 100644 --- a/cpp/src/Ice/Outgoing.cpp +++ b/cpp/src/Ice/Outgoing.cpp @@ -28,13 +28,13 @@ using namespace IceInternal; IceInternal::LocalExceptionWrapper::LocalExceptionWrapper(const LocalException& ex, bool r) : _retry(r) { - _ex.reset(dynamic_cast<LocalException*>(ex.ice_clone())); + _ex.reset(ex.ice_clone()); } IceInternal::LocalExceptionWrapper::LocalExceptionWrapper(const LocalExceptionWrapper& ex) : _retry(ex._retry) { - _ex.reset(dynamic_cast<LocalException*>(ex.get()->ice_clone())); + _ex.reset(ex.get()->ice_clone()); } void @@ -527,7 +527,7 @@ IceInternal::Outgoing::finished(const LocalException& ex, bool sent) _remoteObserver.detach(); _state = StateFailed; - _exception.reset(dynamic_cast<LocalException*>(ex.ice_clone())); + _exception.reset(ex.ice_clone()); _sent = sent; _monitor.notify(); } @@ -601,6 +601,6 @@ void IceInternal::BatchOutgoing::finished(const Ice::LocalException& ex, bool) { IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor); - _exception.reset(dynamic_cast<LocalException*>(ex.ice_clone())); + _exception.reset(ex.ice_clone()); _monitor.notify(); } diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp index 3a158848376..6f96ed33a8e 100644 --- a/cpp/src/Ice/OutgoingAsync.cpp +++ b/cpp/src/Ice/OutgoingAsync.cpp @@ -55,7 +55,7 @@ public: AsynchronousException(const IceInternal::InstancePtr& instance, const Ice::AsyncResultPtr& result, const Ice::Exception& ex) : - DispatchWorkItem(instance), _result(result), _exception(dynamic_cast<Ice::LocalException*>(ex.ice_clone())) + DispatchWorkItem(instance), _result(result), _exception(ex.ice_clone()) { } diff --git a/cpp/src/Ice/PluginManagerI.cpp b/cpp/src/Ice/PluginManagerI.cpp index 513a3036ea6..bb2bcd37959 100644 --- a/cpp/src/Ice/PluginManagerI.cpp +++ b/cpp/src/Ice/PluginManagerI.cpp @@ -7,6 +7,7 @@ // // ********************************************************************** +#include <IceUtil/Options.h> #include <Ice/PluginManagerI.h> #include <Ice/DynamicLibrary.h> #include <Ice/Communicator.h> @@ -40,10 +41,10 @@ Ice::PluginManagerI::initializePlugins() vector<PluginPtr> initializedPlugins; try { - for(vector<PluginPtr>::iterator p = _initOrder.begin(); p != _initOrder.end(); ++p) + for(PluginInfoList::iterator p = _plugins.begin(); p != _plugins.end(); ++p) { - (*p)->initialize(); - initializedPlugins.push_back(*p); + p->plugin->initialize(); + initializedPlugins.push_back(p->plugin); } } catch(...) @@ -75,10 +76,9 @@ Ice::PluginManagerI::getPlugins() IceUtil::Mutex::Lock sync(*this); StringSeq names; - map<string, PluginPtr>::iterator r; - for(r = _plugins.begin(); r != _plugins.end(); ++r) + for(PluginInfoList::iterator p = _plugins.begin(); p != _plugins.end(); ++p) { - names.push_back((*r).first); + names.push_back(p->name); } return names; } @@ -93,10 +93,10 @@ Ice::PluginManagerI::getPlugin(const string& name) throw CommunicatorDestroyedException(__FILE__, __LINE__); } - map<string, PluginPtr>::const_iterator r = _plugins.find(name); - if(r != _plugins.end()) + PluginPtr p = findPlugin(name); + if(p) { - return (*r).second; + return p; } NotRegisteredException ex(__FILE__, __LINE__); @@ -115,15 +115,18 @@ Ice::PluginManagerI::addPlugin(const string& name, const PluginPtr& plugin) throw CommunicatorDestroyedException(__FILE__, __LINE__); } - map<string, PluginPtr>::const_iterator r = _plugins.find(name); - if(r != _plugins.end()) + if(findPlugin(name)) { AlreadyRegisteredException ex(__FILE__, __LINE__); ex.kindOfObject = _kindOfObject; ex.id = name; throw ex; } - _plugins[name] = plugin; + + PluginInfo info; + info.name = name; + info.plugin = plugin; + _plugins.push_back(info); } void @@ -135,40 +138,44 @@ Ice::PluginManagerI::destroy() { if(_initialized) { - map<string, PluginPtr>::iterator r; - for(r = _plugins.begin(); r != _plugins.end(); ++r) + + // + // Destroy the plug-ins that have been successfully initialized, in the + // reverse order. + // + for(PluginInfoList::reverse_iterator p = _plugins.rbegin(); p != _plugins.rend(); ++p) { try { - r->second->destroy(); - r->second = 0; + p->plugin->destroy(); } catch(const std::exception& ex) { Warning out(getProcessLogger()); - out << "unexpected exception raised by plug-in `" << r->first << "' destruction:\n" << ex.what(); + out << "unexpected exception raised by plug-in `" << p->name << "' destruction:\n" << ex.what(); } catch(const std::string& str) { Warning out(getProcessLogger()); - out << "unexpected exception raised by plug-in `" << r->first << "' destruction:\n" << str; + out << "unexpected exception raised by plug-in `" << p->name << "' destruction:\n" << str; } catch(const char* msg) { Warning out(getProcessLogger()); - out << "unexpected exception raised by plug-in `" << r->first << "' destruction:\n" << msg; + out << "unexpected exception raised by plug-in `" << p->name << "' destruction:\n" << msg; } catch(...) { Warning out(getProcessLogger()); - out << "unexpected exception raised by plug-in `" << r->first << "' destruction"; + out << "unexpected exception raised by plug-in `" << p->name << "' destruction"; } } } - + _communicator = 0; } + _plugins.clear(); _libraries = 0; } @@ -206,7 +213,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[]) { string name = *p; - if(_plugins.find(name) != _plugins.end()) + if(findPlugin(name)) { PluginInitializationException ex(__FILE__, __LINE__); ex.reason = "plug-in `" + name + "' already loaded"; @@ -239,7 +246,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[]) // // Load any remaining plug-ins that weren't specified in PluginLoadOrder. // - + while(!plugins.empty()) { PropertyDict::iterator p = plugins.begin(); @@ -262,7 +269,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[]) name = name.substr(0, dotPos); loadPlugin(name, p->second, cmdArgs); plugins.erase(p); - + plugins.erase("Ice.Plugin." + name); } else @@ -273,7 +280,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[]) dotPos = string::npos; } } - + if(dotPos == string::npos) { // @@ -299,36 +306,29 @@ Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, St { assert(_communicator); // - // Separate the entry point from the arguments. + // Split the entire property value into arguments. An entry point containing spaces + // must be enclosed in quotes. // - string entryPoint; StringSeq args; - const string delim = " \t\n"; - string::size_type pos = pluginSpec.find_first_of(delim); - if(pos == string::npos) + try { - entryPoint = pluginSpec; + args = IceUtilInternal::Options::split(pluginSpec); } - else + catch(const IceUtilInternal::BadOptException& ex) { - entryPoint = pluginSpec.substr(0, pos); - string::size_type beg = pluginSpec.find_first_not_of(delim, pos); - while(beg != string::npos) - { - string::size_type end = pluginSpec.find_first_of(delim, beg); - if(end == string::npos) - { - args.push_back(pluginSpec.substr(beg)); - beg = end; - } - else - { - args.push_back(pluginSpec.substr(beg, end - beg)); - beg = pluginSpec.find_first_not_of(delim, end); - } - } + PluginInitializationException e(__FILE__, __LINE__); + e.reason = "invalid arguments for plug-in `" + name + "':\n" + ex.reason; + throw e; } + assert(!args.empty()); + + // + // Shift the arguments. + // + const string entryPoint = args[0]; + args.erase(args.begin()); + // // Convert command-line options into properties. First we // convert the options from the plug-in configuration, then @@ -373,15 +373,30 @@ Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, St throw e; } - _plugins[name] = plugin; - _initOrder.push_back(plugin); + PluginInfo info; + info.name = name; + info.plugin = plugin; + _plugins.push_back(info); _libraries->add(library); } +Ice::PluginPtr +Ice::PluginManagerI::findPlugin(const string& name) const +{ + for(PluginInfoList::const_iterator p = _plugins.begin(); p != _plugins.end(); ++p) + { + if(name == p->name) + { + return p->plugin; + } + } + return 0; +} + void -IceInternal::loadPlugin(const Ice::CommunicatorPtr& communicator, - const string& name, +IceInternal::loadPlugin(const Ice::CommunicatorPtr& communicator, + const string& name, const string& pluginSpec, Ice::StringSeq& cmdArgs) { diff --git a/cpp/src/Ice/PluginManagerI.h b/cpp/src/Ice/PluginManagerI.h index ecb73fa3a43..a7b7578ebaa 100644 --- a/cpp/src/Ice/PluginManagerI.h +++ b/cpp/src/Ice/PluginManagerI.h @@ -41,17 +41,25 @@ private: PluginManagerI(const CommunicatorPtr&, const IceInternal::DynamicLibraryListPtr&); friend class IceInternal::Instance; - friend void IceInternal::loadPlugin(const Ice::CommunicatorPtr&, const std::string&, const std::string&, + friend void IceInternal::loadPlugin(const Ice::CommunicatorPtr&, const std::string&, const std::string&, Ice::StringSeq&); void loadPlugins(int&, char*[]); void loadPlugin(const std::string&, const std::string&, StringSeq&); + PluginPtr findPlugin(const std::string&) const; + CommunicatorPtr _communicator; IceInternal::DynamicLibraryListPtr _libraries; - std::map<std::string, PluginPtr> _plugins; - std::vector<PluginPtr> _initOrder; + struct PluginInfo + { + std::string name; + PluginPtr plugin; + }; + typedef std::vector<PluginInfo> PluginInfoList; + + PluginInfoList _plugins; bool _initialized; static const char * const _kindOfObject; }; diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index f2e20d3ee50..69da155dd9d 100644 --- a/cpp/src/Ice/Proxy.cpp +++ b/cpp/src/Ice/Proxy.cpp @@ -70,6 +70,26 @@ IceInternal::checkedCastImpl(const ObjectPrx& b, const string& f, const string& return 0; } +#ifdef ICE_CPP11 +void +IceInternal::Cpp11FnOnewayCallbackNC::__completed(const ::Ice::AsyncResultPtr& result) const +{ + try + { + result->getProxy()->__end(result, result->getOperation()); + } + catch(const ::Ice::Exception& ex) + { + Cpp11FnCallbackNC::__exception(result, ex); + return; + } + if(_cb != nullptr) + { + _cb(); + } +} +#endif + bool IceProxy::Ice::Object::operator==(const Object& r) const { diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp index 3ec8385c214..1d5f4dd1b91 100644 --- a/cpp/src/Ice/Reference.cpp +++ b/cpp/src/Ice/Reference.cpp @@ -483,12 +483,20 @@ IceInternal::Reference::Reference(const Reference& r) : int IceInternal::Reference::hashInit() const { - Int h = static_cast<Int>(_mode); + Int h = 5381; + hashAdd(h, static_cast<Int>(_mode)); + hashAdd(h, _secure); hashAdd(h, _identity.name); hashAdd(h, _identity.category); hashAdd(h, _context->getValue()); hashAdd(h, _facet); - hashAdd(h, _secure); + hashAdd(h, _overrideCompress); + if(_overrideCompress) + { + hashAdd(h, _compress); + } + hashAdd(h, _encoding.major); + hashAdd(h, _encoding.minor); return h; } @@ -1681,7 +1689,7 @@ IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& all } catch(const LocalException& ex) { - exception.reset(dynamic_cast<LocalException*>(ex.ice_clone())); + exception.reset(ex.ice_clone()); } } @@ -1793,7 +1801,7 @@ IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& all { if(!_exception.get()) { - _exception.reset(dynamic_cast<Ice::LocalException*>(ex.ice_clone())); + _exception.reset(ex.ice_clone()); } if(++_i == _endpoints.size()) diff --git a/cpp/src/Ice/RouterInfo.cpp b/cpp/src/Ice/RouterInfo.cpp index a07ff0d6cf9..291e0ec03d9 100644 --- a/cpp/src/Ice/RouterInfo.cpp +++ b/cpp/src/Ice/RouterInfo.cpp @@ -166,6 +166,32 @@ IceInternal::RouterInfo::getClientEndpoints() } void +IceInternal::RouterInfo::getClientProxyResponse(const Ice::ObjectPrx& proxy, const GetClientEndpointsCallbackPtr& callback) +{ + callback->setEndpoints(setClientEndpoints(proxy)); +} + +void +IceInternal::RouterInfo::getClientProxyException(const Ice::Exception& ex, const GetClientEndpointsCallbackPtr& callback) +{ + if(dynamic_cast<const Ice::CollocationOptimizationException*>(&ex)) + { + try + { + callback->setEndpoints(getClientEndpoints()); + } + catch(const Ice::LocalException& e) + { + callback->setException(e); + } + } + else + { + callback->setException(dynamic_cast<const Ice::LocalException&>(ex)); + } +} + +void IceInternal::RouterInfo::getClientEndpoints(const GetClientEndpointsCallbackPtr& callback) { vector<EndpointIPtr> clientEndpoints; @@ -180,48 +206,10 @@ IceInternal::RouterInfo::getClientEndpoints(const GetClientEndpointsCallbackPtr& return; } - class Callback : public AMI_Router_getClientProxy - { - public: - - virtual void - ice_response(const Ice::ObjectPrx& clientProxy) - { - _callback->setEndpoints(_routerInfo->setClientEndpoints(clientProxy)); - } - - virtual void - ice_exception(const Ice::Exception& ex) - { - if(dynamic_cast<const Ice::CollocationOptimizationException*>(&ex)) - { - try - { - _callback->setEndpoints(_routerInfo->getClientEndpoints()); - } - catch(const Ice::LocalException& e) - { - _callback->setException(e); - } - } - else - { - _callback->setException(dynamic_cast<const Ice::LocalException&>(ex)); - } - } - - Callback(const RouterInfoPtr& routerInfo, const GetClientEndpointsCallbackPtr& callback) : - _routerInfo(routerInfo), _callback(callback) - { - } - - private: - - const RouterInfoPtr _routerInfo; - const GetClientEndpointsCallbackPtr _callback; - }; - - _router->getClientProxy_async(new Callback(this, callback)); + _router->begin_getClientProxy(newCallback_Router_getClientProxy(this, + &RouterInfo::getClientProxyResponse, + &RouterInfo::getClientProxyException), + callback); } vector<EndpointIPtr> @@ -259,6 +247,34 @@ IceInternal::RouterInfo::addProxy(const ObjectPrx& proxy) addAndEvictProxies(proxy, _router->addProxies(proxies)); } +void +IceInternal::RouterInfo::addProxyResponse(const Ice::ObjectProxySeq& proxies, const AddProxyCookiePtr& cookie) +{ + addAndEvictProxies(cookie->proxy(), proxies); + cookie->cb()->addedProxy(); +} + +void +IceInternal::RouterInfo::addProxyException(const Ice::Exception& ex, const AddProxyCookiePtr& cookie) +{ + if(dynamic_cast<const Ice::CollocationOptimizationException*>(&ex)) + { + try + { + addProxy(cookie->proxy()); + cookie->cb()->addedProxy(); + } + catch(const Ice::LocalException& e) + { + cookie->cb()->setException(e); + } + } + else + { + cookie->cb()->setException(dynamic_cast<const Ice::LocalException&>(ex)); + } +} + bool IceInternal::RouterInfo::addProxy(const Ice::ObjectPrx& proxy, const AddProxyCallbackPtr& callback) { @@ -274,53 +290,15 @@ IceInternal::RouterInfo::addProxy(const Ice::ObjectPrx& proxy, const AddProxyCal } } - class Callback : public AMI_Router_addProxies - { - public: - - virtual void - ice_response(const Ice::ObjectProxySeq& evictedProxies) - { - _routerInfo->addAndEvictProxies(_proxy, evictedProxies); - _callback->addedProxy(); - } - - virtual void - ice_exception(const Ice::Exception& ex) - { - if(dynamic_cast<const Ice::CollocationOptimizationException*>(&ex)) - { - try - { - _routerInfo->addProxy(_proxy); - _callback->addedProxy(); - } - catch(const Ice::LocalException& e) - { - _callback->setException(e); - } - } - else - { - _callback->setException(dynamic_cast<const Ice::LocalException&>(ex)); - } - } - - Callback(const RouterInfoPtr& routerInfo, const Ice::ObjectPrx& proxy, const AddProxyCallbackPtr& callback) : - _routerInfo(routerInfo), _proxy(proxy), _callback(callback) - { - } - - private: - - const RouterInfoPtr _routerInfo; - const Ice::ObjectPrx _proxy; - const AddProxyCallbackPtr _callback; - }; Ice::ObjectProxySeq proxies; proxies.push_back(proxy); - _router->addProxies_async(new Callback(this, proxy, callback), proxies); + AddProxyCookiePtr cookie = new AddProxyCookie(callback, proxy); + _router->begin_addProxies(proxies, + newCallback_Router_addProxies(this, + &RouterInfo::addProxyResponse, + &RouterInfo::addProxyException), + cookie); return false; } diff --git a/cpp/src/Ice/RouterInfo.h b/cpp/src/Ice/RouterInfo.h index 52801b57651..b1c80ed07fb 100644 --- a/cpp/src/Ice/RouterInfo.h +++ b/cpp/src/Ice/RouterInfo.h @@ -47,7 +47,7 @@ class RouterInfo : public IceUtil::Shared, public IceUtil::Mutex { public: - class GetClientEndpointsCallback : virtual public IceUtil::Shared + class GetClientEndpointsCallback : virtual public Ice::LocalObject { public: @@ -74,9 +74,41 @@ public: bool operator<(const RouterInfo&) const; Ice::RouterPrx getRouter() const; + void getClientProxyResponse(const Ice::ObjectPrx&, const GetClientEndpointsCallbackPtr&); + void getClientProxyException(const Ice::Exception&, const GetClientEndpointsCallbackPtr&); std::vector<EndpointIPtr> getClientEndpoints(); void getClientEndpoints(const GetClientEndpointsCallbackPtr&); std::vector<EndpointIPtr> getServerEndpoints(); + + class AddProxyCookie : public Ice::LocalObject + { + public: + + AddProxyCookie(const AddProxyCallbackPtr cb, const Ice::ObjectPrx& proxy) : + _cb(cb), + _proxy(proxy) + { + } + + AddProxyCallbackPtr cb() const + { + return _cb; + } + + Ice::ObjectPrx proxy() const + { + return _proxy; + } + + private: + + const AddProxyCallbackPtr _cb; + const Ice::ObjectPrx _proxy; + }; + typedef IceUtil::Handle<AddProxyCookie> AddProxyCookiePtr; + + void addProxyResponse(const Ice::ObjectProxySeq&, const AddProxyCookiePtr&); + void addProxyException(const Ice::Exception&, const AddProxyCookiePtr&); void addProxy(const Ice::ObjectPrx&); bool addProxy(const Ice::ObjectPrx&, const AddProxyCallbackPtr&); diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp index 7800b392076..722a729229d 100644 --- a/cpp/src/Ice/Service.cpp +++ b/cpp/src/Ice/Service.cpp @@ -22,6 +22,7 @@ #include <Ice/Communicator.h> #include <Ice/LocalException.h> #include <Ice/Properties.h> +#include <Ice/Instance.h> #ifdef _WIN32 # include <winsock2.h> @@ -57,7 +58,7 @@ ctrlCHandlerCallback(int sig) // Main function for Win32 service. // void WINAPI -Ice_Service_ServiceMain(DWORD argc, LPTSTR* argv) +Ice_Service_ServiceMain(DWORD argc, LPWSTR* argv) { Ice::Service* service = Ice::Service::instance(); assert(service != 0); @@ -202,9 +203,11 @@ class SMEventLoggerI : public Ice::Logger, public SMEventLogger { public: - SMEventLoggerI(const string& source) + SMEventLoggerI(const string& source, const StringConverterPtr& stringConverter) : + _stringConverter(stringConverter) { - _source = RegisterEventSource(0, mangleSource(source).c_str()); + _source = RegisterEventSourceW(0, IceUtil::stringToWstring( + nativeToUTF8(_stringConverter, mangleSource(source))).c_str()); if(_source == 0) { SyscallException ex(__FILE__, __LINE__); @@ -220,12 +223,14 @@ public: } static void - addKeys(const string& source) + addKeys(const string& source, const StringConverterPtr& stringConverter) { HKEY hKey; DWORD d; - LONG err = RegCreateKeyEx(HKEY_LOCAL_MACHINE, createKey(source).c_str(), 0, "REG_SZ", - REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, &d); + LONG err = RegCreateKeyExW(HKEY_LOCAL_MACHINE, + IceUtil::stringToWstring(nativeToUTF8(stringConverter, createKey(source))).c_str(), + 0, L"REG_SZ", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, &d); + if(err != ERROR_SUCCESS) { SyscallException ex(__FILE__, __LINE__); @@ -236,9 +241,9 @@ public: // // Get the filename of this DLL. // - char path[_MAX_PATH]; + wchar_t path[_MAX_PATH]; assert(_module != 0); - if(!GetModuleFileName(_module, path, _MAX_PATH)) + if(!GetModuleFileNameW(_module, path, _MAX_PATH)) { RegCloseKey(hKey); SyscallException ex(__FILE__, __LINE__); @@ -251,8 +256,9 @@ public: // the "EventMessageFile" key should contain the path to this // DLL. // - err = RegSetValueEx(hKey, "EventMessageFile", 0, REG_EXPAND_SZ, - reinterpret_cast<unsigned char*>(path), static_cast<DWORD>(strlen(path) + 1)); + err = RegSetValueExW(hKey, L"EventMessageFile", 0, REG_EXPAND_SZ, reinterpret_cast<unsigned char*>(path), + static_cast<DWORD>((wcslen(path) * sizeof(wchar_t)) + 1)); + if(err == ERROR_SUCCESS) { // @@ -260,8 +266,8 @@ public: // types. // DWORD typesSupported = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE; - err = RegSetValueEx(hKey, "TypesSupported", 0, REG_DWORD, - reinterpret_cast<unsigned char*>(&typesSupported), sizeof(typesSupported)); + err = RegSetValueExW(hKey, L"TypesSupported", 0, REG_DWORD, + reinterpret_cast<unsigned char*>(&typesSupported), sizeof(typesSupported)); } if(err != ERROR_SUCCESS) { @@ -275,9 +281,10 @@ public: } static void - removeKeys(const string& source) + removeKeys(const string& source, const StringConverterPtr& stringConverter) { - LONG err = RegDeleteKey(HKEY_LOCAL_MACHINE, createKey(source).c_str()); + LONG err = RegDeleteKeyW(HKEY_LOCAL_MACHINE, + IceUtil::stringToWstring(nativeToUTF8(stringConverter, createKey(source))).c_str()); if(err != ERROR_SUCCESS) { SyscallException ex(__FILE__, __LINE__); @@ -302,13 +309,14 @@ public: virtual void print(const string& message) { - const char* str[1]; - str[0] = message.c_str(); + wstring msg = IceUtil::stringToWstring(nativeToUTF8(_stringConverter, message)); + const wchar_t* messages[1]; + messages[0] = msg.c_str(); // // We ignore any failures from ReportEvent since there isn't // anything we can do about it. // - ReportEvent(_source, EVENTLOG_INFORMATION_TYPE, 0, EVENT_LOGGER_MSG, 0, 1, 0, str, 0); + ReportEventW(_source, EVENTLOG_INFORMATION_TYPE, 0, EVENT_LOGGER_MSG, 0, 1, 0, messages, 0); } virtual void @@ -335,13 +343,14 @@ public: } s.append(message); - const char* str[1]; - str[0] = s.c_str(); + wstring msg = IceUtil::stringToWstring(nativeToUTF8(_stringConverter, s)); + const wchar_t* messages[1]; + messages[0] = msg.c_str(); // // We ignore any failures from ReportEvent since there isn't // anything we can do about it. // - ReportEvent(_source, EVENTLOG_INFORMATION_TYPE, 0, EVENT_LOGGER_MSG, 0, 1, 0, str, 0); + ReportEventW(_source, EVENTLOG_INFORMATION_TYPE, 0, EVENT_LOGGER_MSG, 0, 1, 0, messages, 0); } virtual void @@ -360,13 +369,14 @@ public: virtual void warning(const string& message) { - const char* str[1]; - str[0] = message.c_str(); + wstring msg = IceUtil::stringToWstring(nativeToUTF8(_stringConverter, message)); + const wchar_t* messages[1]; + messages[0] = msg.c_str(); // // We ignore any failures from ReportEvent since there isn't // anything we can do about it. // - ReportEvent(_source, EVENTLOG_WARNING_TYPE, 0, EVENT_LOGGER_MSG, 0, 1, 0, str, 0); + ReportEventW(_source, EVENTLOG_WARNING_TYPE, 0, EVENT_LOGGER_MSG, 0, 1, 0, messages, 0); } virtual void @@ -385,13 +395,14 @@ public: virtual void error(const string& message) { - const char* str[1]; - str[0] = message.c_str(); + wstring msg = IceUtil::stringToWstring(nativeToUTF8(_stringConverter, message)); + const wchar_t* messages[1]; + messages[0] = msg.c_str(); // // We ignore any failures from ReportEvent since there isn't // anything we can do about it. // - ReportEvent(_source, EVENTLOG_ERROR_TYPE, 0, EVENT_LOGGER_MSG, 0, 1, 0, str, 0); + ReportEventW(_source, EVENTLOG_ERROR_TYPE, 0, EVENT_LOGGER_MSG, 0, 1, 0, messages, 0); } virtual Ice::LoggerPtr @@ -433,7 +444,7 @@ private: return "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\" + mangleSource(name); } - + StringConverterPtr _stringConverter; HANDLE _source; static HMODULE _module; }; @@ -552,7 +563,7 @@ Ice::Service::main(int& argc, char* argv[], const InitializationData& initializa if(LoggerIPtr::dynamicCast(_logger)) { string eventLogSource = initData.properties->getPropertyWithDefault("Ice.EventLog.Source", name); - _logger = new SMEventLoggerIWrapper(new SMEventLoggerI(eventLogSource), ""); + _logger = new SMEventLoggerIWrapper(new SMEventLoggerI(eventLogSource, initData.stringConverter), ""); setProcessLogger(_logger); } @@ -568,160 +579,6 @@ Ice::Service::main(int& argc, char* argv[], const InitializationData& initializa } } - // - // Next check for service control options. - // - string op; - idx = 1; - while(idx < argc) - { - if(strcmp(argv[idx], "--install") == 0 || - strcmp(argv[idx], "--uninstall") == 0 || - strcmp(argv[idx], "--start") == 0 || - strcmp(argv[idx], "--stop") == 0) - { - if(!op.empty()) - { - error("cannot specify `" + op + "' and `" + string(argv[idx]) + "'"); - return EXIT_FAILURE; - } - - if(!name.empty()) - { - error("cannot specify `--service' and `" + string(argv[idx]) + "'"); - return EXIT_FAILURE; - } - - if(idx + 1 >= argc) - { - error("service name argument expected for `" + string(argv[idx]) + "'"); - return EXIT_FAILURE; - } - - op = argv[idx]; - name = argv[idx + 1]; - - warning("the " + op + " option is deprecated"); - - for(int i = idx ; i + 2 < argc ; ++i) - { - argv[i] = argv[i + 2]; - } - argc -= 2; - } - else - { - ++idx; - } - } - - if(!op.empty()) - { - if(op == "--install") - { - // - // Check for --display, --executable. - // - string display, executable; - idx = 1; - while(idx < argc) - { - if(strcmp(argv[idx], "--display") == 0) - { - if(idx + 1 >= argc) - { - error("argument expected for `" + string(argv[idx]) + "'"); - return EXIT_FAILURE; - } - - display = argv[idx + 1]; - - for(int i = idx ; i + 2 < argc ; ++i) - { - argv[i] = argv[i + 2]; - } - argc -= 2; - } - else if(strcmp(argv[idx], "--executable") == 0) - { - if(idx + 1 >= argc) - { - error("argument expected for `" + string(argv[idx]) + "'"); - return EXIT_FAILURE; - } - - executable = argv[idx + 1]; - - for(int i = idx ; i + 2 < argc ; ++i) - { - argv[i] = argv[i + 2]; - } - argc -= 2; - } - else - { - ++idx; - } - } - - vector<string> args; - // - // Prepend the arguments "--service NAME" so that the service - // starts properly. - // - args.push_back("--service"); - args.push_back(name); - for(idx = 1; idx < argc; ++idx) - { - args.push_back(argv[idx]); - } - try - { - // - // Add the registry keys for the event logger if - // initData.logger is empty (which is the case if the - // user wants to use the service default logger). - // - return installService(!initData.logger, name, display, executable, args); - } - catch(const Ice::Exception& ex) - { - ostringstream ostr; - ostr << ex; - error(ostr.str()); - return EXIT_FAILURE; - } - } - else if(op == "--uninstall") - { - try - { - return uninstallService(!initData.logger, name); - } - catch(const Ice::Exception& ex) - { - ostringstream ostr; - ostr << ex; - error(ostr.str()); - return EXIT_FAILURE; - } - } - else if(op == "--start") - { - vector<string> args; - for(idx = 1; idx < argc; ++idx) - { - args.push_back(argv[idx]); - } - return startService(name, args); - } - else - { - assert(op == "--stop"); - return stopService(name); - } - } - if(!name.empty()) { configureService(name); @@ -913,6 +770,16 @@ Ice::Service::checkSystem() const #endif } +#ifdef _WIN32 +int +Ice::Service::run(int& argc, wchar_t* argv[], const InitializationData& initData) +{ + StringSeq args = Ice::argsToStringSeq(argc, argv, initData.stringConverter); + IceUtilInternal::ArgVector av(args); + return run(av.argc, av.argv, initData); +} +#endif + int Ice::Service::run(int& argc, char* argv[], const InitializationData& initData) { @@ -1019,292 +886,6 @@ Ice::Service::configureService(const string& name) _name = name; } -int -Ice::Service::installService(bool useEventLogger, const string& name, const string& display, const string& executable, - const vector<string>& args) -{ - string disp, exec; - - disp = display; - if(disp.empty()) - { - disp = name; - } - - exec = executable; - if(exec.empty()) - { - // - // Use this executable if none is specified. - // - char buf[_MAX_PATH]; - if(GetModuleFileName(0, buf, _MAX_PATH) == 0) - { - error("unable to obtain file name of executable"); - return EXIT_FAILURE; - } - exec = buf; - } - - // - // Compose service command line. The executable and any arguments must - // be enclosed in quotes if they contain whitespace. - // - string command; - if(executable.find(' ') != string::npos) - { - command.push_back('"'); - command.append(exec); - command.push_back('"'); - } - else - { - command = exec; - } - for(vector<string>::const_iterator p = args.begin(); p != args.end(); ++p) - { - command.push_back(' '); - - if(p->find_first_of(" \t\n\r") != string::npos) - { - command.push_back('"'); - command.append(*p); - command.push_back('"'); - } - else - { - command.append(*p); - } - } - - SC_HANDLE hSCM = OpenSCManager(0, 0, SC_MANAGER_ALL_ACCESS); - if(hSCM == 0) - { - syserror("failure in OpenSCManager"); - return EXIT_FAILURE; - } - SC_HANDLE hService = CreateService( - hSCM, - name.c_str(), - disp.c_str(), - SERVICE_ALL_ACCESS, - SERVICE_WIN32_OWN_PROCESS, - SERVICE_AUTO_START, - SERVICE_ERROR_NORMAL, - command.c_str(), - 0, - 0, - 0, - 0, - 0); - - if(hService == 0) - { - syserror("unable to install service `" + name + "'"); - CloseServiceHandle(hSCM); - return EXIT_FAILURE; - } - - CloseServiceHandle(hSCM); - CloseServiceHandle(hService); - - // - // Add the registry keys for the event logger if _logger is - // empty (which is the case if the user wants to use - // the service default logger). - // - if(useEventLogger) - { - SMEventLoggerI::addKeys(name); - } - - return EXIT_SUCCESS; -} - -int -Ice::Service::uninstallService(bool useEventLogger, const string& name) -{ - SC_HANDLE hSCM = OpenSCManager(0, 0, SC_MANAGER_ALL_ACCESS); - if(hSCM == 0) - { - syserror("failure in OpenSCManager"); - return EXIT_FAILURE; - } - - SC_HANDLE hService = OpenService(hSCM, name.c_str(), SERVICE_ALL_ACCESS); - if(hService == 0) - { - syserror("unable to open service `" + name + "'"); - CloseServiceHandle(hSCM); - return EXIT_FAILURE; - } - - BOOL b = DeleteService(hService); - - if(!b) - { - syserror("unable to uninstall service `" + name + "'"); - CloseServiceHandle(hSCM); - CloseServiceHandle(hService); - return EXIT_FAILURE; - } - - CloseServiceHandle(hSCM); - CloseServiceHandle(hService); - - // - // Remove the registry keys for the event logger if necessary. - // - if(useEventLogger) - { - SMEventLoggerI::removeKeys(name); - } - - return EXIT_SUCCESS; -} - -int -Ice::Service::startService(const string& name, const vector<string>& args) -{ - SC_HANDLE hSCM = OpenSCManager(0, 0, SC_MANAGER_ALL_ACCESS); - if(hSCM == 0) - { - syserror("failure in OpenSCManager"); - return EXIT_FAILURE; - } - - SC_HANDLE hService = OpenService(hSCM, name.c_str(), SERVICE_ALL_ACCESS); - if(hService == 0) - { - syserror("unable to open service `" + name + "'"); - CloseServiceHandle(hSCM); - return EXIT_FAILURE; - } - - // - // Create argument vector. Note that StartService() automatically - // adds the service name in argv[0], so the argv that is passed to - // StartService() must *not* include the the service name in - // argv[0]. - // - const int argc = static_cast<int>(args.size()); - LPCSTR* argv = new LPCSTR[argc]; - int i = 0; - for(vector<string>::const_iterator p = args.begin(); p != args.end(); ++p) - { - argv[i++] = _strdup(p->c_str()); - } - - // - // Start service. - // - BOOL b = StartService(hService, argc, argv); - - // - // Clean up argument vector. - // - for(i = 0; i < argc; ++i) - { - free(const_cast<char*>(argv[i])); - } - delete[] argv; - - if(!b) - { - syserror("unable to start service `" + name + "'"); - CloseServiceHandle(hService); - CloseServiceHandle(hSCM); - return EXIT_FAILURE; - } - - trace("Service start pending."); - - // - // Wait until the service is started or an error is detected. - // - SERVICE_STATUS status; - if(!waitForServiceState(hService, SERVICE_START_PENDING, status)) - { - syserror("unable to query status of service `" + name + "'"); - CloseServiceHandle(hService); - CloseServiceHandle(hSCM); - return EXIT_FAILURE; - } - - CloseServiceHandle(hService); - CloseServiceHandle(hSCM); - - if(status.dwCurrentState == SERVICE_RUNNING) - { - trace("Service is running."); - } - else - { - showServiceStatus("Service failed to start.", status); - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} - -int -Ice::Service::stopService(const string& name) -{ - SC_HANDLE hSCM = OpenSCManager(0, 0, SC_MANAGER_ALL_ACCESS); - if(hSCM == 0) - { - syserror("failure in OpenSCManager"); - return EXIT_FAILURE; - } - - SC_HANDLE hService = OpenService(hSCM, name.c_str(), SERVICE_ALL_ACCESS); - if(hService == 0) - { - syserror("unable to open service `" + name + "'"); - CloseServiceHandle(hSCM); - return EXIT_FAILURE; - } - - SERVICE_STATUS status; - BOOL b = ControlService(hService, SERVICE_CONTROL_STOP, &status); - - if(!b) - { - syserror("unable to stop service `" + name + "'"); - CloseServiceHandle(hSCM); - CloseServiceHandle(hService); - return EXIT_FAILURE; - } - - trace("Service stop pending."); - - // - // Wait until the service is stopped or an error is detected. - // - if(!waitForServiceState(hService, SERVICE_STOP_PENDING, status)) - { - syserror("unable to query status of service `" + name + "'"); - CloseServiceHandle(hService); - CloseServiceHandle(hSCM); - return EXIT_FAILURE; - } - - CloseServiceHandle(hService); - CloseServiceHandle(hSCM); - - if(status.dwCurrentState == SERVICE_STOPPED) - { - trace("Service is stopped."); - } - else - { - showServiceStatus("Service failed to stop.", status); - return EXIT_FAILURE; - } - - return EXIT_SUCCESS; -} - void Ice::Service::setModuleHandle(HMODULE module) { @@ -1384,10 +965,10 @@ Ice::Service::syserror(const string& msg) } else { - if(!_name.empty()) - { - cerr << _name << ": "; - } + if(!_name.empty()) + { + cerr << _name << ": "; + } if(!msg.empty()) { cerr << msg << endl; @@ -1408,11 +989,11 @@ Ice::Service::error(const string& msg) } else { - if(!_name.empty()) - { - cerr << _name << ": "; - } - cerr << "error: " << msg << endl; + if(!_name.empty()) + { + cerr << _name << ": "; + } + cerr << "error: " << msg << endl; } } @@ -1425,10 +1006,10 @@ Ice::Service::warning(const string& msg) } else { - if(!_name.empty()) - { - cerr << _name << ": "; - } + if(!_name.empty()) + { + cerr << _name << ": "; + } cerr << "warning: " << msg << endl; } } @@ -1501,16 +1082,16 @@ Ice::Service::runService(int argc, char* argv[], const InitializationData& initD _initData = initData; - SERVICE_TABLE_ENTRY ste[] = + SERVICE_TABLE_ENTRYW ste[] = { - { const_cast<char*>(_name.c_str()), Ice_Service_ServiceMain }, + { const_cast<wchar_t*>(IceUtil::stringToWstring(nativeToUTF8(_initData.stringConverter, _name)).c_str()), Ice_Service_ServiceMain }, { 0, 0 }, }; // // Start the service. // - if(!StartServiceCtrlDispatcher(ste)) + if(!StartServiceCtrlDispatcherW(ste)) { syserror("unable to start service control dispatcher"); return EXIT_FAILURE; @@ -1658,14 +1239,14 @@ Ice::Service::showServiceStatus(const string& msg, SERVICE_STATUS& status) } void -Ice::Service::serviceMain(int argc, char* argv[]) +Ice::Service::serviceMain(int argc, wchar_t* argv[]) { _ctrlCHandler = new IceUtil::CtrlCHandler; // // Register the control handler function. // - _statusHandle = RegisterServiceCtrlHandler(argv[0], Ice_Service_CtrlHandler); + _statusHandle = RegisterServiceCtrlHandlerW(argv[0], Ice_Service_CtrlHandler); if(_statusHandle == (SERVICE_STATUS_HANDLE)0) { syserror("unable to register service control handler"); @@ -1685,7 +1266,7 @@ Ice::Service::serviceMain(int argc, char* argv[]) // Merge the executable's arguments with the service's arguments. // char** args = new char*[_serviceArgs.size() + argc]; - args[0] = argv[0]; + args[0] = const_cast<char*>(UTF8ToNative(_initData.stringConverter, IceUtil::wstringToString(argv[0])).c_str()); int i = 1; for(vector<string>::iterator p = _serviceArgs.begin(); p != _serviceArgs.end(); ++p) { @@ -1693,7 +1274,7 @@ Ice::Service::serviceMain(int argc, char* argv[]) } for(int j = 1; j < argc; ++j) { - args[i++] = argv[j]; + args[i++] = const_cast<char*>(UTF8ToNative(_initData.stringConverter, IceUtil::wstringToString(argv[j])).c_str()); } argc += static_cast<int>(_serviceArgs.size()); @@ -1923,11 +1504,11 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa pid_t pid = fork(); if(pid < 0) { - if(argv[0]) - { - cerr << argv[0] << ": "; - } - cerr << strerror(errno) << endl; + if(argv[0]) + { + cerr << argv[0] << ": "; + } + cerr << strerror(errno) << endl; return EXIT_FAILURE; } @@ -1956,10 +1537,10 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa continue; } - if(argv[0]) - { - cerr << argv[0] << ": "; - } + if(argv[0]) + { + cerr << argv[0] << ": "; + } cerr << strerror(errno) << endl; _exit(EXIT_FAILURE); } @@ -1983,20 +1564,20 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa continue; } - if(argv[0]) - { - cerr << ": "; - } + if(argv[0]) + { + cerr << ": "; + } cerr << "I/O error while reading error message from child:\n" << strerror(errno) << endl; _exit(EXIT_FAILURE); } pos += n; break; } - if(argv[0]) - { - cerr << argv[0] << ": "; - } + if(argv[0]) + { + cerr << argv[0] << ": "; + } cerr << "failure occurred in daemon"; if(strlen(msg) > 0) { diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp index 7eeac08f05b..7b47da856cd 100644 --- a/cpp/src/Ice/TcpEndpointI.cpp +++ b/cpp/src/Ice/TcpEndpointI.cpp @@ -546,10 +546,15 @@ IceInternal::TcpEndpointI::operator<(const LocalObject& r) const Ice::Int IceInternal::TcpEndpointI::hashInit() const { - Ice::Int h = 0; + Ice::Int h = 5381; + hashAdd(h, TCPEndpointType); hashAdd(h, _host); hashAdd(h, _port); hashAdd(h, _timeout); + hashAdd(h, _protocol.major); + hashAdd(h, _protocol.minor); + hashAdd(h, _encoding.major); + hashAdd(h, _encoding.minor); hashAdd(h, _connectionId); hashAdd(h, _compress); return h; diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index 2faf56e1538..d6114a45071 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -7,6 +7,14 @@ // // ********************************************************************** +// +// The following is required for MinGW to bring in +// some definitions. +// +#if defined(__MINGW32__) +# define _WIN32_WINNT 0x0501 +#endif + #include <Ice/ThreadPool.h> #include <IceUtil/DisableWarnings.h> #include <Ice/EventHandler.h> diff --git a/cpp/src/Ice/UdpEndpointI.cpp b/cpp/src/Ice/UdpEndpointI.cpp index 9b4c05bdf9d..c20a430bbe6 100644 --- a/cpp/src/Ice/UdpEndpointI.cpp +++ b/cpp/src/Ice/UdpEndpointI.cpp @@ -631,12 +631,17 @@ IceInternal::UdpEndpointI::operator<(const LocalObject& r) const Ice::Int IceInternal::UdpEndpointI::hashInit() const { - Ice::Int h = 0; + Ice::Int h = 5381; + hashAdd(h, UDPEndpointType); hashAdd(h, _host); hashAdd(h, _port); hashAdd(h, _mcastInterface); hashAdd(h, _mcastTtl); hashAdd(h, _connect); + hashAdd(h, _protocol.major); + hashAdd(h, _protocol.minor); + hashAdd(h, _encoding.major); + hashAdd(h, _encoding.minor); hashAdd(h, _connectionId); hashAdd(h, _compress); return h; diff --git a/cpp/src/Ice/winrt/StreamEndpointI.cpp b/cpp/src/Ice/winrt/StreamEndpointI.cpp index 1f1c030f84e..d048945f0a0 100644 --- a/cpp/src/Ice/winrt/StreamEndpointI.cpp +++ b/cpp/src/Ice/winrt/StreamEndpointI.cpp @@ -587,10 +587,15 @@ IceInternal::StreamEndpointI::operator<(const LocalObject& r) const Ice::Int IceInternal::StreamEndpointI::hashInit() const { - Ice::Int h = 0; + Ice::Int h = 5381; + hashAdd(h, _type); hashAdd(h, _host); hashAdd(h, _port); hashAdd(h, _timeout); + hashAdd(h, _protocol.major); + hashAdd(h, _protocol.minor); + hashAdd(h, _encoding.major); + hashAdd(h, _encoding.minor); hashAdd(h, _connectionId); hashAdd(h, _compress); return h; diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp index 0a2a5908543..f91e9cd8da2 100644 --- a/cpp/src/IceBox/ServiceManagerI.cpp +++ b/cpp/src/IceBox/ServiceManagerI.cpp @@ -22,47 +22,18 @@ using namespace std; typedef IceBox::Service* (*SERVICE_FACTORY)(CommunicatorPtr); -namespace +namespace { -template<class T> -class AMICallbackT : public T -{ -public: - - AMICallbackT(const ServiceManagerIPtr& serviceManager, const ServiceObserverPrx& observer) : - _serviceManager(serviceManager), - _observer(observer) - { - } - - virtual void ice_response() - { - // ok, success - } - - virtual void ice_exception(const Ice::Exception& ex) - { - // - // Drop this observer - // - _serviceManager->removeObserver(_observer, ex); - } - -private: - ServiceManagerIPtr _serviceManager; - ServiceObserverPrx _observer; -}; - class PropertiesAdminI : public PropertiesAdmin { public: - + PropertiesAdminI(const PropertiesPtr& properties) : _properties(properties) { } - + virtual string getProperty(const string& name, const Current&) { return _properties->getProperty(name); @@ -72,10 +43,10 @@ public: { return _properties->getPropertiesForPrefix(prefix); } - + private: - const PropertiesPtr _properties; + const PropertiesPtr _properties; }; struct StartServiceInfo @@ -85,28 +56,28 @@ struct StartServiceInfo name = service; // - // Separate the entry point from the arguments. + // Split the entire property value into arguments. An entry point containing spaces + // must be enclosed in quotes. // - string::size_type pos = value.find_first_of(" \t\n"); - if(pos == string::npos) + try { - entryPoint = value; + args = IceUtilInternal::Options::split(value); } - else + catch(const IceUtilInternal::BadOptException& ex) { - entryPoint = value.substr(0, pos); - try - { - args = IceUtilInternal::Options::split(value.substr(pos + 1)); - } - catch(const IceUtilInternal::BadOptException& ex) - { - FailureException e(__FILE__, __LINE__); - e.reason = "ServiceManager: invalid arguments for service `" + name + "':\n" + ex.reason; - throw e; - } + PluginInitializationException e(__FILE__, __LINE__); + e.reason = "invalid arguments for service `" + name + "':\n" + ex.reason; + throw e; } + assert(!args.empty()); + + // + // Shift the arguments. + // + entryPoint = args[0]; + args.erase(args.begin()); + for(Ice::StringSeq::const_iterator p = serverArgs.begin(); p != serverArgs.end(); ++p) { if(p->find("--" + name + ".") == 0) @@ -121,13 +92,13 @@ struct StartServiceInfo Ice::StringSeq args; }; - } -IceBox::ServiceManagerI::ServiceManagerI(CommunicatorPtr communicator, int& argc, char* argv[]) : +IceBox::ServiceManagerI::ServiceManagerI(CommunicatorPtr communicator, int& argc, char* argv[]) : _communicator(communicator), _pendingStatusChanges(false), - _traceServiceObserver(0) + _traceServiceObserver(0), + _observerCompletedCB(newCallback(this, &ServiceManagerI::observerCompleted)) { _logger = _communicator->getLogger(); _traceServiceObserver = _communicator->getProperties()->getPropertyAsInt("IceBox.Trace.ServiceObserver"); @@ -197,7 +168,7 @@ IceBox::ServiceManagerI::startService(const string& name, const Current&) Warning out(_logger); out << "ServiceManager: unknown exception in start for service " << info.name; } - + { IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); @@ -318,7 +289,7 @@ IceBox::ServiceManagerI::addObserver(const ServiceObserverPrx& observer, const I { Trace out(_logger, "IceBox.ServiceObserver"); out << "Added service observer " << _communicator->proxyToString(observer); - } + } vector<string> activeServices; for(vector<ServiceInfo>::iterator p = _services.begin(); p != _services.end(); ++p) @@ -329,35 +300,15 @@ IceBox::ServiceManagerI::addObserver(const ServiceObserverPrx& observer, const I activeServices.push_back(info.name); } } - + if(activeServices.size() > 0) { - observer->servicesStarted_async(new AMICallbackT<AMI_ServiceObserver_servicesStarted>(this, observer), - activeServices); + observer->begin_servicesStarted(activeServices, _observerCompletedCB); } } } void -IceBox::ServiceManagerI::removeObserver(const ServiceObserverPrx& observer, const Ice::Exception& ex) -{ - IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); - - // - // It's possible to remove several times the same observer, e.g. multiple concurrent - // requests that fail - // - - set<ServiceObserverPrx>::iterator p = _observers.find(observer); - if(p != _observers.end()) - { - ServiceObserverPrx observer = *p; - _observers.erase(p); - observerRemoved(observer, ex); - } -} - -void IceBox::ServiceManagerI::shutdown(const Current&) { _communicator->shutdown(); @@ -393,7 +344,7 @@ IceBox::ServiceManagerI::start() // // IceBox.Service.Foo=entry_point [args] // - // We parse the service properties specified in IceBox.LoadOrder + // We parse the service properties specified in IceBox.LoadOrder // first, then the ones from remaining services. // const string prefix = "IceBox.Service."; @@ -417,7 +368,7 @@ IceBox::ServiceManagerI::start() { servicesInfo.push_back(StartServiceInfo(p->first.substr(prefix.size()), p->second, _argv)); } - + // // Check if some services are using the shared communicator in which // case we create the shared communicator now with a property set which @@ -464,12 +415,12 @@ IceBox::ServiceManagerI::start() { initData.properties->setProperty(r->first, r->second); } - + // - // Parse <service>.* command line options (the Ice command line options + // Parse <service>.* command line options (the Ice command line options // were parsed by the createProperties above) // - q->args = initData.properties->parseCommandLineOptions(q->name, q->args); + q->args = initData.properties->parseCommandLineOptions(q->name, q->args); } _sharedCommunicator = initialize(initData); } @@ -510,7 +461,7 @@ IceBox::ServiceManagerI::start() // // Add a Properties facet for each service - // + // for(vector<ServiceInfo>::iterator r = _services.begin(); r != _services.end(); ++r) { const ServiceInfo& info = *r; @@ -518,7 +469,7 @@ IceBox::ServiceManagerI::start() _communicator->addAdminFacet(new PropertiesAdminI(communicator->getProperties()), "IceBox.Service." + info.name + ".Properties"); } - + _communicator->getAdmin(); } catch(const ObjectAdapterDeactivatedException&) @@ -659,7 +610,7 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint, communicator = _sharedCommunicator; } else - { + { // // Create the service properties. We use the communicator properties as the default // properties if IceBox.InheritProperties is set. @@ -675,25 +626,25 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint, initData.properties = createProperties(info.args, initData.properties); // - // Next, parse the service "<service>.*" command line options (the Ice command + // Next, parse the service "<service>.*" command line options (the Ice command // line options were parsed by the createProperties above) // info.args = initData.properties->parseCommandLineOptions(service, info.args); } - + // // Clone the logger to assign a new prefix. // initData.logger = _logger->cloneWithPrefix(initData.properties->getProperty("Ice.ProgramName")); - + // - // Remaining command line options are passed to the communicator. This is + // Remaining command line options are passed to the communicator. This is // necessary for Ice plug-in properties (e.g.: IceSSL). // info.communicator = initialize(info.args, initData); communicator = info.communicator; } - + // // Start the service. // @@ -704,8 +655,8 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint, // // There is no need to notify the observers since the 'start all' - // (that indirectly calls this function) occurs before the creation of - // the Server Admin object, and before the activation of the main + // (that indirectly calls this function) occurs before the creation of + // the Server Admin object, and before the activation of the main // object adapter (so before any observer can be registered) // } @@ -798,7 +749,7 @@ IceBox::ServiceManagerI::stopAll() vector<string> stoppedServices; // - // First, for each service, we call stop on the service and flush its database environment to + // First, for each service, we call stop on the service and flush its database environment to // the disk. // for(p = _services.rbegin(); p != _services.rend(); ++p) @@ -830,7 +781,7 @@ IceBox::ServiceManagerI::stopAll() for(p = _services.rbegin(); p != _services.rend(); ++p) { ServiceInfo& info = *p; - + try { _communicator->removeAdminFacet("IceBox.Service." + info.name + ".Properties"); @@ -863,9 +814,9 @@ IceBox::ServiceManagerI::stopAll() } // - // Release the service, the service communicator and then the library. The order is important, + // Release the service, the service communicator and then the library. The order is important, // the service must be released before destroying the communicator so that the communicator - // leak detector doesn't report potential leaks, and the communicator must be destroyed before + // leak detector doesn't report potential leaks, and the communicator must be destroyed before // the library is released since the library will destroy its global state. // try @@ -898,7 +849,7 @@ IceBox::ServiceManagerI::stopAll() out << ex; } } - + try { info.library = 0; @@ -933,6 +884,8 @@ IceBox::ServiceManagerI::stopAll() _services.clear(); servicesStopped(stoppedServices, _observers); + + _observerCompletedCB = 0; // Break cyclic reference count. } void @@ -942,9 +895,7 @@ IceBox::ServiceManagerI::servicesStarted(const vector<string>& services, const s { for(set<ServiceObserverPrx>::const_iterator p = observers.begin(); p != observers.end(); ++p) { - ServiceObserverPrx observer = *p; - observer->servicesStarted_async(new AMICallbackT<AMI_ServiceObserver_servicesStarted>(this, observer), - services); + (*p)->begin_servicesStarted(services, _observerCompletedCB); } } } @@ -956,16 +907,14 @@ IceBox::ServiceManagerI::servicesStopped(const vector<string>& services, const s { for(set<ServiceObserverPrx>::const_iterator p = observers.begin(); p != observers.end(); ++p) { - ServiceObserverPrx observer = *p; - observer->servicesStopped_async(new AMICallbackT<AMI_ServiceObserver_servicesStopped>(this, observer), - services); + (*p)->begin_servicesStopped(services, _observerCompletedCB); } } } void IceBox::ServiceManagerI::observerRemoved(const ServiceObserverPrx& observer, const std::exception& ex) -{ +{ if(_traceServiceObserver >= 1) { // @@ -979,8 +928,8 @@ IceBox::ServiceManagerI::observerRemoved(const ServiceObserverPrx& observer, con out << "Removed service observer " << _communicator->proxyToString(observer) << "\nafter catching " << ex.what(); } - } -} + } +} Ice::PropertiesPtr IceBox::ServiceManagerI::createServiceProperties(const string& service) @@ -996,7 +945,7 @@ IceBox::ServiceManagerI::createServiceProperties(const string& service) { properties = createProperties(); } - + string programName = communicatorProperties->getProperty("Ice.ProgramName"); if(programName.empty()) { @@ -1008,3 +957,29 @@ IceBox::ServiceManagerI::createServiceProperties(const string& service) } return properties; } + +void +ServiceManagerI::observerCompleted(const Ice::AsyncResultPtr& result) +{ + try + { + result->throwLocalException(); + } + catch(const Ice::LocalException& ex) + { + ServiceObserverPrx observer = ServiceObserverPrx::uncheckedCast(result->getProxy()); + IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this); + + // + // It's possible to remove several times the same observer, e.g. multiple concurrent + // requests that fail + // + set<ServiceObserverPrx>::iterator p = _observers.find(observer); + if(p != _observers.end()) + { + ServiceObserverPrx observer = *p; + _observers.erase(p); + observerRemoved(observer, ex); + } + } +} diff --git a/cpp/src/IceBox/ServiceManagerI.h b/cpp/src/IceBox/ServiceManagerI.h index a613ae1b3f8..9c381941b49 100644 --- a/cpp/src/IceBox/ServiceManagerI.h +++ b/cpp/src/IceBox/ServiceManagerI.h @@ -39,7 +39,7 @@ public: bool start(); void stop(); - void removeObserver(const ServiceObserverPrx&, const Ice::Exception&); + void observerCompleted(const Ice::AsyncResultPtr&); private: @@ -80,6 +80,7 @@ private: std::set<ServiceObserverPrx> _observers; int _traceServiceObserver; + ::Ice::CallbackPtr _observerCompletedCB; }; typedef IceUtil::Handle<ServiceManagerI> ServiceManagerIPtr; diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp index 628978b6488..10d0f20d66b 100644 --- a/cpp/src/IceGrid/Activator.cpp +++ b/cpp/src/IceGrid/Activator.cpp @@ -786,6 +786,40 @@ Activator::activate(const string& name, #endif } +namespace +{ + +class ShutdownCallback : public IceUtil::Shared +{ +public: + + ShutdownCallback(const ActivatorPtr& activator, const string& name, const TraceLevelsPtr& traceLevels) : + _activator(activator), _name(name), _traceLevels(traceLevels) + { + + } + + virtual void + exception(const Ice::Exception& ex) + { + Ice::Warning out(_traceLevels->logger); + out << "exception occurred while deactivating `" << _name << "' using process proxy:\n" << ex; + + // + // Send a SIGTERM to the process. + // + _activator->sendSignal(_name, SIGTERM); + } + +private: + + const ActivatorPtr _activator; + const string _name; + const TraceLevelsPtr _traceLevels; +}; + +} + void Activator::deactivate(const string& name, const Ice::ProcessPrx& process) { @@ -800,44 +834,6 @@ Activator::deactivate(const string& name, const Ice::ProcessPrx& process) } #endif - class ShutdownCallback : public Ice::AMI_Process_shutdown - { - public: - - ShutdownCallback(const ActivatorPtr& activator, const string& name, const TraceLevelsPtr& traceLevels) : - _activator(activator), _name(name), _traceLevels(traceLevels) - { - - } - - virtual void - ice_response() - { - // - // Nothing to do, server successfully shutdown, the activator will detect it - // once the pipe is closed. - // - } - - virtual void - ice_exception(const Ice::Exception& ex) - { - Ice::Warning out(_traceLevels->logger); - out << "exception occurred while deactivating `" << _name << "' using process proxy:\n" << ex; - - // - // Send a SIGTERM to the process. - // - _activator->sendSignal(_name, SIGTERM); - } - - private: - - const ActivatorPtr _activator; - const string _name; - const TraceLevelsPtr _traceLevels; - }; - // // Try to shut down the server gracefully using the process proxy. // @@ -848,8 +844,8 @@ Activator::deactivate(const string& name, const Ice::ProcessPrx& process) Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat); out << "deactivating `" << name << "' using process proxy"; } - - process->shutdown_async(new ShutdownCallback(this, name, _traceLevels)); + process->begin_shutdown(Ice::newCallback_Process_shutdown(new ShutdownCallback(this, name, _traceLevels), + &ShutdownCallback::exception)); return; } diff --git a/cpp/src/IceGrid/AdminCallbackRouter.cpp b/cpp/src/IceGrid/AdminCallbackRouter.cpp index 2fc00ab89c9..bb68190a233 100644 --- a/cpp/src/IceGrid/AdminCallbackRouter.cpp +++ b/cpp/src/IceGrid/AdminCallbackRouter.cpp @@ -12,35 +12,20 @@ using namespace Ice; using namespace std; -namespace +void +IceGrid::AdminCallbackRouter::invokeResponse(bool ok, const std::pair<const Byte*, const Byte*>& outParams, + const InvokeCookiePtr& cookie) { + cookie->cb()->ice_response(ok, outParams); +} -class InvokeAMICallback : public AMI_Array_Object_ice_invoke +void +IceGrid::AdminCallbackRouter::invokeException(const Ice::Exception&, const InvokeCookiePtr& cookie) { -public: - - InvokeAMICallback(const AMD_Object_ice_invokePtr& cb) : - _cb(cb) - { - } - - virtual void ice_response(bool ok, const std::pair<const Byte*, const Byte*>& outParams) - { - _cb->ice_response(ok, outParams); - } - - virtual void ice_exception(const Ice::Exception&) - { - _cb->ice_exception(ObjectNotExistException(__FILE__, __LINE__)); // Callback object is unreachable. - } - -private: - AMD_Object_ice_invokePtr _cb; -}; - + // Callback object is unreachable. + cookie->cb()->ice_exception(ObjectNotExistException(__FILE__, __LINE__)); } - void IceGrid::AdminCallbackRouter::addMapping(const string& category, const ConnectionPtr& con) { @@ -92,6 +77,11 @@ IceGrid::AdminCallbackRouter::ice_invoke_async(const AMD_Object_ice_invokePtr& c // // Call with AMI // - target->ice_invoke_async(new InvokeAMICallback(cb), current.operation, current.mode, inParams, current.ctx); + target->begin_ice_invoke(current.operation, current.mode, inParams, current.ctx, + newCallback_Object_ice_invoke( + this, + &AdminCallbackRouter::invokeResponse, + &AdminCallbackRouter::invokeException), + new InvokeCookie(cb)); } diff --git a/cpp/src/IceGrid/AdminCallbackRouter.h b/cpp/src/IceGrid/AdminCallbackRouter.h index 0affceba9ef..8ae022f5759 100644 --- a/cpp/src/IceGrid/AdminCallbackRouter.h +++ b/cpp/src/IceGrid/AdminCallbackRouter.h @@ -28,6 +28,30 @@ public: void addMapping(const std::string&, const Ice::ConnectionPtr&); void removeMapping(const std::string&); + class InvokeCookie : public Ice::LocalObject + { + public: + + InvokeCookie(const Ice::AMD_Object_ice_invokePtr& cb) : + _cb(cb) + { + } + + Ice::AMD_Object_ice_invokePtr cb() + { + return _cb; + } + + private: + + Ice::AMD_Object_ice_invokePtr _cb; + }; + typedef IceUtil::Handle<InvokeCookie> InvokeCookiePtr; + + virtual void invokeResponse(bool, const std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&, + const InvokeCookiePtr&); + + virtual void invokeException(const Ice::Exception&, const InvokeCookiePtr&); virtual void ice_invoke_async(const Ice::AMD_Object_ice_invokePtr&, const std::pair<const Ice::Byte*, const Ice::Byte*>&, diff --git a/cpp/src/IceGrid/AdminI.cpp b/cpp/src/IceGrid/AdminI.cpp index 5c832e4f4a5..7453a93902b 100644 --- a/cpp/src/IceGrid/AdminI.cpp +++ b/cpp/src/IceGrid/AdminI.cpp @@ -394,100 +394,115 @@ AdminI::getServerAdmin(const string& id, const Current& current) const return current.adapter->createProxy(adminId); } -void -AdminI::startServer_async(const AMD_Admin_startServerPtr& amdCB, const string& id, const Current&) +namespace { - ServerProxyWrapper proxy(_database, id); - proxy.useActivationTimeout(); - class StartCB : public AMI_Server_start +class StartCB : virtual public IceUtil::Shared +{ +public: + + StartCB(const ServerProxyWrapper& proxy, const AMD_Admin_startServerPtr& amdCB) : _proxy(proxy), _amdCB(amdCB) { - public: + } - StartCB(const ServerProxyWrapper& proxy, const AMD_Admin_startServerPtr& amdCB) : _proxy(proxy), _amdCB(amdCB) - { - } + virtual void + response() + { + _amdCB->ice_response(); + } - virtual void - ice_response() + virtual void + exception(const Ice::Exception& ex) + { + try { - _amdCB->ice_response(); + _proxy.handleException(ex); + assert(false); } - - virtual void - ice_exception(const Ice::Exception& ex) + catch(const Ice::Exception& ex) { - try - { - _proxy.handleException(ex); - assert(false); - } - catch(const Ice::Exception& ex) - { - _amdCB->ice_exception(ex); - } + _amdCB->ice_exception(ex); } + } - private: +private: + + const ServerProxyWrapper _proxy; + const AMD_Admin_startServerPtr _amdCB; +}; + +} + + +void +AdminI::startServer_async(const AMD_Admin_startServerPtr& amdCB, const string& id, const Current&) +{ + ServerProxyWrapper proxy(_database, id); + proxy.useActivationTimeout(); - const ServerProxyWrapper _proxy; - const AMD_Admin_startServerPtr _amdCB; - }; - // // Since the server might take a while to be activated, we use AMI. // - proxy->start_async(new StartCB(proxy, amdCB)); + proxy->begin_start(newCallback_Server_start(new StartCB(proxy, amdCB), + &StartCB::response, + &StartCB::exception)); } -void -AdminI::stopServer_async(const AMD_Admin_stopServerPtr& amdCB, const string& id, const Current&) +namespace { - ServerProxyWrapper proxy(_database, id); - proxy.useDeactivationTimeout(); - class StopCB : public AMI_Server_stop +class StopCB : virtual public IceUtil::Shared +{ +public: + + StopCB(const ServerProxyWrapper& proxy, const AMD_Admin_stopServerPtr& amdCB) : _proxy(proxy), _amdCB(amdCB) + { + } + + virtual void + response() { - public: + _amdCB->ice_response(); + } - StopCB(const ServerProxyWrapper& proxy, const AMD_Admin_stopServerPtr& amdCB) : _proxy(proxy), _amdCB(amdCB) + virtual void + exception(const Ice::Exception& ex) + { + try { + _proxy.handleException(ex); + assert(false); } - - virtual void - ice_response() + catch(const Ice::TimeoutException&) { _amdCB->ice_response(); } - - virtual void - ice_exception(const Ice::Exception& ex) + catch(const Ice::Exception& ex) { - try - { - _proxy.handleException(ex); - assert(false); - } - catch(const Ice::TimeoutException&) - { - _amdCB->ice_response(); - } - catch(const Ice::Exception& ex) - { - _amdCB->ice_exception(ex); - } + _amdCB->ice_exception(ex); } + } - private: +private: - const ServerProxyWrapper _proxy; - const AMD_Admin_stopServerPtr _amdCB; - }; + const ServerProxyWrapper _proxy; + const AMD_Admin_stopServerPtr _amdCB; +}; + +} + +void +AdminI::stopServer_async(const AMD_Admin_stopServerPtr& amdCB, const string& id, const Current&) +{ + ServerProxyWrapper proxy(_database, id); + proxy.useDeactivationTimeout(); // // Since the server might take a while to be deactivated, we use AMI. // - proxy->stop_async(new StopCB(proxy, amdCB)); + proxy->begin_stop(newCallback_Server_stop(new StopCB(proxy, amdCB), + &StopCB::response, + &StopCB::exception)); } void diff --git a/cpp/src/IceGrid/Internal.ice b/cpp/src/IceGrid/Internal.ice index ed90c4c757b..1362ff7bbe7 100644 --- a/cpp/src/IceGrid/Internal.ice +++ b/cpp/src/IceGrid/Internal.ice @@ -149,7 +149,7 @@ interface Adapter * adapter direct proxy it's active. * **/ - ["ami", "amd"] Object* activate(); + ["amd"] Object* activate(); /** * @@ -161,7 +161,7 @@ interface Adapter * endpoints if the adapter is already active. * **/ - ["ami", "nonmutating", "cpp:const"] idempotent Object* getDirectProxy() + ["nonmutating", "cpp:const"] idempotent Object* getDirectProxy() throws AdapterNotActiveException; /** @@ -177,7 +177,7 @@ interface Adapter * active adapter. * **/ - ["ami"] void setDirectProxy(Object* proxy) + void setDirectProxy(Object* proxy) throws AdapterActiveException; }; @@ -224,7 +224,7 @@ interface Server extends FileReader * otherwise. * **/ - ["amd", "ami"] void start() + ["amd"] void start() throws ServerStartException; /** @@ -234,7 +234,7 @@ interface Server extends FileReader * amount of time, it will be killed. * **/ - ["amd", "ami"] void stop() + ["amd"] void stop() throws ServerStopException; /** @@ -292,7 +292,7 @@ interface Server extends FileReader * Set the process proxy. * **/ - ["ami", "amd"] void setProcess(Ice::Process* proc); + ["amd"] void setProcess(Ice::Process* proc); }; interface InternalRegistry; @@ -350,7 +350,7 @@ interface Node extends FileReader, ReplicaObserver * they will be created. * **/ - ["amd", "ami"] idempotent Server* loadServer(InternalServerDescriptor svr, + ["amd"] idempotent Server* loadServer(InternalServerDescriptor svr, string replicaName, out AdapterPrxDict adapters, out int actTimeout, @@ -362,7 +362,7 @@ interface Node extends FileReader, ReplicaObserver * Destroy the given server. * **/ - ["amd", "ami"] idempotent void destroyServer(string name, string uuid, int revision, string replicaName) + ["amd"] idempotent void destroyServer(string name, string uuid, int revision, string replicaName) throws DeploymentException; /** @@ -386,7 +386,7 @@ interface Node extends FileReader, ReplicaObserver * replicaAdded below). * **/ - ["ami"] void registerWithReplica(InternalRegistry* replica); + void registerWithReplica(InternalRegistry* replica); /** * @@ -492,7 +492,7 @@ interface NodeSession * of the server. * **/ - ["amd", "ami", "cpp:const"] void waitForApplicationUpdate(string application, int revision); + ["amd", "cpp:const"] void waitForApplicationUpdate(string application, int revision); /** * @@ -572,7 +572,7 @@ interface ReplicaSession * the locator registry interface. * **/ - ["ami"] idempotent void setAdapterDirectProxy(string adapterId, string replicaGroupId, Object* proxy) + idempotent void setAdapterDirectProxy(string adapterId, string replicaGroupId, Object* proxy) throws AdapterNotExistException, AdapterExistsException; /** diff --git a/cpp/src/IceGrid/LocatorI.cpp b/cpp/src/IceGrid/LocatorI.cpp index 6583980e948..ddcc8601758 100644 --- a/cpp/src/IceGrid/LocatorI.cpp +++ b/cpp/src/IceGrid/LocatorI.cpp @@ -22,22 +22,22 @@ namespace IceGrid // // Callback from asynchronous call to adapter->getDirectProxy() invoked in LocatorI::findAdapterById_async(). // -class AMI_Adapter_getDirectProxyI : public AMI_Adapter_getDirectProxy +class AdapterGetDirectProxyCallback : virtual public IceUtil::Shared { public: - AMI_Adapter_getDirectProxyI(const LocatorIPtr& locator, const LocatorAdapterInfo& adapter) : + AdapterGetDirectProxyCallback(const LocatorIPtr& locator, const LocatorAdapterInfo& adapter) : _locator(locator), _adapter(adapter) { } - virtual void ice_response(const ::Ice::ObjectPrx& obj) + virtual void response(const ::Ice::ObjectPrx& obj) { assert(obj); _locator->getDirectProxyResponse(_adapter, obj); } - virtual void ice_exception(const ::Ice::Exception& e) + virtual void exception(const ::Ice::Exception& e) { _locator->getDirectProxyException(_adapter, e); } @@ -48,21 +48,21 @@ private: const LocatorAdapterInfo _adapter; }; -class AMI_Adapter_activateI : public AMI_Adapter_activate +class AdapterActivateCallback : virtual public IceUtil::Shared { public: - AMI_Adapter_activateI(const LocatorIPtr& locator, const LocatorAdapterInfo& adapter) : + AdapterActivateCallback(const LocatorIPtr& locator, const LocatorAdapterInfo& adapter) : _locator(locator), _adapter(adapter) { } - virtual void ice_response(const ::Ice::ObjectPrx& obj) + virtual void response(const ::Ice::ObjectPrx& obj) { _locator->getDirectProxyResponse(_adapter, obj); } - virtual void ice_exception(const ::Ice::Exception& ex) + virtual void exception(const ::Ice::Exception& ex) { _locator->getDirectProxyException(_adapter, ex); } @@ -936,8 +936,10 @@ LocatorI::getDirectProxy(const LocatorAdapterInfo& adapter, const RequestPtr& re requests.push_back(request); _pendingRequests.insert(make_pair(adapter.id, requests)); } - - adapter.proxy->getDirectProxy_async(new AMI_Adapter_getDirectProxyI(this, adapter)); + adapter.proxy->begin_getDirectProxy(newCallback_Adapter_getDirectProxy( + new AdapterGetDirectProxyCallback(this, adapter), + &AdapterGetDirectProxyCallback::response, + &AdapterGetDirectProxyCallback::exception)); return false; } @@ -1011,9 +1013,11 @@ LocatorI::getDirectProxyException(const LocatorAdapterInfo& adapter, const Ice:: (*q)->activating(adapter.id); } - AMI_Adapter_activatePtr amiCB = new AMI_Adapter_activateI(this, adapter); int timeout = adapter.activationTimeout + adapter.deactivationTimeout; - AdapterPrx::uncheckedCast(adapter.proxy->ice_timeout(timeout * 1000))->activate_async(amiCB); + AdapterPrx::uncheckedCast(adapter.proxy->ice_timeout(timeout * 1000))->begin_activate( + newCallback_Adapter_activate(new AdapterActivateCallback(this, adapter), + &AdapterActivateCallback::response, + &AdapterActivateCallback::exception)); } else { diff --git a/cpp/src/IceGrid/LocatorRegistryI.cpp b/cpp/src/IceGrid/LocatorRegistryI.cpp index 994d84d0141..6620222da4a 100644 --- a/cpp/src/IceGrid/LocatorRegistryI.cpp +++ b/cpp/src/IceGrid/LocatorRegistryI.cpp @@ -20,7 +20,7 @@ namespace IceGrid { template<class AmdCB> -class SetDirectProxyCB : public AMI_Adapter_setDirectProxy +class SetDirectProxyCB : public LocatorRegistryI::AdapterSetDirectProxyCB { public: @@ -32,7 +32,7 @@ public: { } - virtual void ice_response() + virtual void response() { if(_traceLevels->locator > 1) { @@ -43,7 +43,7 @@ public: _cb->ice_response(); } - virtual void ice_exception(const ::Ice::Exception& ex) + virtual void exception(const ::Ice::Exception& ex) { if(_traceLevels->locator > 1) { @@ -88,14 +88,14 @@ newSetDirectProxyCB(const AmdCB& cb, const TraceLevelsPtr& traceLevels, const st return new SetDirectProxyCB<AmdCB>(cb, traceLevels, id, p); } -class AMI_Server_setProcessI : public AMI_Server_setProcess +class ServerSetProcessCB : virtual public IceUtil::Shared { public: - AMI_Server_setProcessI(const Ice::AMD_LocatorRegistry_setServerProcessProxyPtr& cb, - const TraceLevelsPtr& traceLevels, - const string& id, - const Ice::ObjectPrx& proxy) : + ServerSetProcessCB(const Ice::AMD_LocatorRegistry_setServerProcessProxyPtr& cb, + const TraceLevelsPtr& traceLevels, + const string& id, + const Ice::ObjectPrx& proxy) : _cb(cb), _traceLevels(traceLevels), _id(id), _proxy(proxy) { } @@ -145,13 +145,14 @@ private: const string _id; const Ice::ObjectPrx _proxy; }; +typedef IceUtil::Handle<ServerSetProcessCB> ServerSetProcessCBPtr; class SetAdapterDirectProxyCallback : public SynchronizationCallback { public: SetAdapterDirectProxyCallback(const LocatorRegistryIPtr& registry, - const AMI_Adapter_setDirectProxyPtr& amiCB, + const LocatorRegistryI::AdapterSetDirectProxyCBPtr& amiCB, const string& adapterId, const string& replicaGroupId, const Ice::ObjectPrx& proxy) : @@ -168,7 +169,7 @@ public: } catch(const Ice::Exception& ex) { - _amiCB->ice_exception(ex); + _amiCB->exception(ex); } } @@ -181,14 +182,14 @@ public: } catch(const Ice::Exception& ex) { - _amiCB->ice_exception(ex); + _amiCB->exception(ex); } } private: const LocatorRegistryIPtr _registry; - const AMI_Adapter_setDirectProxyPtr _amiCB; + const LocatorRegistryI::AdapterSetDirectProxyCBPtr _amiCB; const string _adapterId; const string _replicaGroupId; const Ice::ObjectPrx _proxy; @@ -322,8 +323,10 @@ LocatorRegistryI::setServerProcessProxy_async(const Ice::AMD_LocatorRegistry_set } } - AMI_Server_setProcessPtr amiCB = new AMI_Server_setProcessI(cb, _database->getTraceLevels(), id, proxy); - server->setProcess_async(amiCB, proxy); + server->begin_setProcess(proxy, IceGrid::newCallback_Server_setProcess( + new ServerSetProcessCB(cb, _database->getTraceLevels(), id, proxy), + &ServerSetProcessCB::ice_response, + &ServerSetProcessCB::ice_exception)); } catch(const ServerNotExistException&) { @@ -342,7 +345,7 @@ LocatorRegistryI::setServerProcessProxy_async(const Ice::AMD_LocatorRegistry_set } void -LocatorRegistryI::setAdapterDirectProxy(const AMI_Adapter_setDirectProxyPtr& amiCB, +LocatorRegistryI::setAdapterDirectProxy(const LocatorRegistryI::AdapterSetDirectProxyCBPtr& amiCB, const string& adapterId, const string& replicaGroupId, const Ice::ObjectPrx& proxy) @@ -352,7 +355,7 @@ LocatorRegistryI::setAdapterDirectProxy(const AMI_Adapter_setDirectProxyPtr& ami // if(adapterId.empty()) { - amiCB->ice_response(); + amiCB->response(); return; } @@ -386,7 +389,9 @@ LocatorRegistryI::setAdapterDirectProxy(const AMI_Adapter_setDirectProxyPtr& ami } } - adapter->setDirectProxy_async(amiCB, proxy); + adapter->begin_setDirectProxy(proxy, IceGrid::newCallback_Adapter_setDirectProxy(amiCB, + &LocatorRegistryI::AdapterSetDirectProxyCB::response, + &LocatorRegistryI::AdapterSetDirectProxyCB::exception)); return; } catch(const AdapterNotExistException&) @@ -413,7 +418,7 @@ LocatorRegistryI::setAdapterDirectProxy(const AMI_Adapter_setDirectProxyPtr& ami try { _database->setAdapterDirectProxy(adapterId, replicaGroupId, proxy); - amiCB->ice_response(); + amiCB->response(); return; } catch(const AdapterExistsException&) @@ -439,7 +444,7 @@ LocatorRegistryI::setAdapterDirectProxy(const AMI_Adapter_setDirectProxyPtr& ami try { session->setAdapterDirectProxy(adapterId, replicaGroupId, proxy); - amiCB->ice_response(); + amiCB->response(); return; } catch(const AdapterExistsException&) diff --git a/cpp/src/IceGrid/LocatorRegistryI.h b/cpp/src/IceGrid/LocatorRegistryI.h index 44bc8e7007d..b20ad40ccbc 100644 --- a/cpp/src/IceGrid/LocatorRegistryI.h +++ b/cpp/src/IceGrid/LocatorRegistryI.h @@ -11,6 +11,7 @@ #include <IceGrid/Internal.h> #include <Ice/Locator.h> +#include <IceUtil/Shared.h> namespace IceGrid { @@ -26,6 +27,15 @@ class ReplicaSessionManager; class LocatorRegistryI : public Ice::LocatorRegistry { public: + + class AdapterSetDirectProxyCB : virtual public IceUtil::Shared + { + public: + + virtual void response() = 0; + virtual void exception(const ::Ice::Exception&) = 0; + }; + typedef IceUtil::Handle<AdapterSetDirectProxyCB> AdapterSetDirectProxyCBPtr; LocatorRegistryI(const DatabasePtr&, bool, bool, ReplicaSessionManager&); @@ -39,7 +49,7 @@ public: virtual void setServerProcessProxy_async(const Ice::AMD_LocatorRegistry_setServerProcessProxyPtr&, const ::std::string&, const ::Ice::ProcessPrx&, const ::Ice::Current&); - void setAdapterDirectProxy(const AMI_Adapter_setDirectProxyPtr&, const std::string&, const std::string&, + void setAdapterDirectProxy(const AdapterSetDirectProxyCBPtr&, const std::string&, const std::string&, const Ice::ObjectPrx&); const TraceLevelsPtr& getTraceLevels() const; diff --git a/cpp/src/IceGrid/NodeCache.cpp b/cpp/src/IceGrid/NodeCache.cpp index c3c14d92789..e03a74e51d9 100644 --- a/cpp/src/IceGrid/NodeCache.cpp +++ b/cpp/src/IceGrid/NodeCache.cpp @@ -178,7 +178,7 @@ struct ToInternalServerDescriptor : std::unary_function<CommunicatorDescriptorPt int _iceVersion; }; -class LoadCB : public AMI_Node_loadServer +class LoadCB : virtual public IceUtil::Shared { public: @@ -191,7 +191,7 @@ public: } void - ice_response(const ServerPrx& server, const AdapterPrxDict& adapters, int at, int dt) + response(const ServerPrx& server, const AdapterPrxDict& adapters, int at, int dt) { if(_traceLevels && _traceLevels->server > 1) { @@ -207,7 +207,7 @@ public: } void - ice_exception(const Ice::Exception& ex) + exception(const Ice::Exception& ex) { try { @@ -248,7 +248,7 @@ private: const int _timeout; }; -class DestroyCB : public AMI_Node_destroyServer +class DestroyCB : virtual public IceUtil::Shared { public: @@ -258,7 +258,7 @@ public: } void - ice_response() + response() { if(_traceLevels && _traceLevels->server > 1) { @@ -269,7 +269,7 @@ public: } void - ice_exception(const Ice::Exception& ex) + exception(const Ice::Exception& ex) { try { @@ -308,31 +308,7 @@ private: const string _node; }; -class RegisterCB : public AMI_Node_registerWithReplica -{ -public: - - RegisterCB(const NodeEntryPtr& node) : _node(node) - { - } - - void - ice_response() - { - _node->finishedRegistration(); - } - - void - ice_exception(const Ice::Exception& ex) - { - _node->finishedRegistration(ex); - } - -private: - const NodeEntryPtr _node; -}; - -}; +} NodeCache::NodeCache(const Ice::CommunicatorPtr& communicator, ReplicaCache& replicaCache, const string& replicaName) : _communicator(communicator), @@ -625,8 +601,11 @@ NodeEntry::loadServer(const ServerEntryPtr& entry, const ServerInfo& server, con } } - AMI_Node_loadServerPtr amiCB = new LoadCB(_cache.getTraceLevels(), entry, _name, sessionTimeout); - node->loadServer_async(amiCB, desc, _cache.getReplicaName()); + node->begin_loadServer(desc, _cache.getReplicaName(), + newCallback_Node_loadServer( + new LoadCB(_cache.getTraceLevels(), entry, _name, sessionTimeout), + &LoadCB::response, + &LoadCB::exception)); } catch(const NodeUnreachableException& ex) { @@ -663,8 +642,10 @@ NodeEntry::destroyServer(const ServerEntryPtr& entry, const ServerInfo& info, in out << "unloading `" << info.descriptor->id << "' on node `" << _name << "'"; } - AMI_Node_destroyServerPtr amiCB = new DestroyCB(_cache.getTraceLevels(), entry, _name); - node->destroyServer_async(amiCB, info.descriptor->id, info.uuid, info.revision, _cache.getReplicaName()); + node->begin_destroyServer(info.descriptor->id, info.uuid, info.revision, _cache.getReplicaName(), + newCallback_Node_destroyServer(new DestroyCB(_cache.getTraceLevels(), entry, _name), + &DestroyCB::response, + &DestroyCB::exception)); } catch(const NodeUnreachableException& ex) { @@ -794,7 +775,10 @@ NodeEntry::checkSession() const // _registering = true; NodeEntry* self = const_cast<NodeEntry*>(this); - _proxy->registerWithReplica_async(new RegisterCB(self), _cache.getReplicaCache().getInternalRegistry()); + _proxy->begin_registerWithReplica(_cache.getReplicaCache().getInternalRegistry(), + newCallback_Node_registerWithReplica(self, + &NodeEntry::finishedRegistration, + &NodeEntry::finishedRegistration)); _proxy = 0; // Registration with the proxy is only attempted once. } diff --git a/cpp/src/IceGrid/NodeI.cpp b/cpp/src/IceGrid/NodeI.cpp index 2a44b98dbdb..1c03de9c4fa 100644 --- a/cpp/src/IceGrid/NodeI.cpp +++ b/cpp/src/IceGrid/NodeI.cpp @@ -188,7 +188,7 @@ private: string _dest; }; -class NodeUp : public NodeI::Update, public AMI_NodeObserver_nodeUp +class NodeUp : public NodeI::Update { public: @@ -202,7 +202,7 @@ public: { try { - _observer->nodeUp_async(this, _info); + _observer->begin_nodeUp(_info, newCallback(static_cast<NodeI::Update*>(this), &NodeI::Update::completed)); } catch(const Ice::LocalException&) { @@ -210,25 +210,13 @@ public: } return true; } - - virtual void - ice_response() - { - finished(true); - } - - virtual void - ice_exception(const Ice::Exception&) - { - finished(false); - } private: NodeDynamicInfo _info; }; -class UpdateServer : public NodeI::Update, public AMI_NodeObserver_updateServer +class UpdateServer : public NodeI::Update { public: @@ -242,7 +230,9 @@ public: { try { - _observer->updateServer_async(this, _node->getName(), _info); + _observer->begin_updateServer(_node->getName(), + _info, + newCallback(static_cast<NodeI::Update*>(this), &NodeI::Update::completed)); } catch(const Ice::LocalException&) { @@ -250,25 +240,13 @@ public: } return true; } - - virtual void - ice_response() - { - finished(true); - } - - virtual void - ice_exception(const Ice::Exception&) - { - finished(false); - } private: ServerDynamicInfo _info; }; -class UpdateAdapter : public NodeI::Update, public AMI_NodeObserver_updateAdapter +class UpdateAdapter : public NodeI::Update { public: @@ -282,7 +260,9 @@ public: { try { - _observer->updateAdapter_async(this, _node->getName(), _info); + _observer->begin_updateAdapter(_node->getName(), + _info, + newCallback(static_cast<NodeI::Update*>(this), &NodeI::Update::completed)); } catch(const Ice::LocalException&) { @@ -290,18 +270,6 @@ public: } return true; } - - virtual void - ice_response() - { - finished(true); - } - - virtual void - ice_exception(const Ice::Exception&) - { - finished(false); - } private: @@ -384,6 +352,20 @@ NodeI::NodeI(const Ice::ObjectAdapterPtr& adapter, } } +void +NodeI::Update::completed(const Ice::AsyncResultPtr& result) +{ + try + { + result->throwLocalException(); + finished(true); + } + catch(const Ice::LocalException&) + { + finished(false); + } +} + NodeI::~NodeI() { } diff --git a/cpp/src/IceGrid/NodeI.h b/cpp/src/IceGrid/NodeI.h index 4d29d853147..508de0f2a48 100644 --- a/cpp/src/IceGrid/NodeI.h +++ b/cpp/src/IceGrid/NodeI.h @@ -40,6 +40,7 @@ typedef IceUtil::Handle<NodeI> NodeIPtr; class NodeI : public Node, public IceUtil::Monitor<IceUtil::Mutex> { public: + class Update : virtual public IceUtil::Shared { public: @@ -50,6 +51,8 @@ public: virtual bool send() = 0; void finished(bool); + + void completed(const Ice::AsyncResultPtr&); protected: diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp index 1eb80d965f3..4db7ef92f78 100755 --- a/cpp/src/IceGrid/ServerI.cpp +++ b/cpp/src/IceGrid/ServerI.cpp @@ -248,31 +248,6 @@ private: const TraceLevelsPtr _traceLevels; }; -class WaitForApplicationUpdateCB : public AMI_NodeSession_waitForApplicationUpdate -{ -public: - - WaitForApplicationUpdateCB(const ServerIPtr& server) : _server(server) - { - } - - virtual void - ice_response() - { - _server->activate(); - } - - virtual void - ice_exception(const Ice::Exception&) - { - _server->activate(); - } - -private: - - const ServerIPtr _server; -}; - struct EnvironmentEval : std::unary_function<string, string> { @@ -697,6 +672,12 @@ ServerI::~ServerI() } void +ServerI::waitForApplicationUpdateCompleted(const Ice::AsyncResultPtr&) +{ + activate(); +} + +void ServerI::start_async(const AMD_Server_startPtr& amdCB, const Ice::Current&) { start(Manual, amdCB); @@ -1406,8 +1387,8 @@ ServerI::activate() NodeSessionPrx session = _node->getMasterNodeSession(); if(session) { - AMI_NodeSession_waitForApplicationUpdatePtr cb = new WaitForApplicationUpdateCB(this); - _node->getMasterNodeSession()->waitForApplicationUpdate_async(cb, desc->uuid, desc->revision); + _node->getMasterNodeSession()->begin_waitForApplicationUpdate( + desc->uuid, desc->revision, ::Ice::newCallback(this, &ServerI::waitForApplicationUpdateCompleted)); return; } } diff --git a/cpp/src/IceGrid/ServerI.h b/cpp/src/IceGrid/ServerI.h index f033a4d8bec..e40cd51c877 100644 --- a/cpp/src/IceGrid/ServerI.h +++ b/cpp/src/IceGrid/ServerI.h @@ -71,6 +71,8 @@ public: ServerI(const NodeIPtr&, const ServerPrx&, const std::string&, const std::string&, int); virtual ~ServerI(); + void waitForApplicationUpdateCompleted(const Ice::AsyncResultPtr&); + virtual void start_async(const AMD_Server_startPtr&, const ::Ice::Current& = Ice::Current()); virtual void stop_async(const AMD_Server_stopPtr&, const ::Ice::Current& = Ice::Current()); virtual void sendSignal(const std::string&, const ::Ice::Current&); diff --git a/cpp/src/IcePatch2Lib/ClientUtil.cpp b/cpp/src/IcePatch2Lib/ClientUtil.cpp index 4196200775b..78aa0776d3e 100755 --- a/cpp/src/IcePatch2Lib/ClientUtil.cpp +++ b/cpp/src/IcePatch2Lib/ClientUtil.cpp @@ -241,66 +241,6 @@ private: const PatcherFeedbackPtr _feedback; }; -class AMIGetFileInfoSeq : public AMI_FileServer_getFileInfoSeq, public IceUtil::Monitor<IceUtil::Mutex> -{ -public: - - AMIGetFileInfoSeq() : - _done(false) - { - } - - FileInfoSeq - getFileInfoSeq() - { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - - while(!_done) - { - wait(); - } - - _done = false; - - if(_exception.get()) - { - auto_ptr<Exception> ex = _exception; - _fileInfoSeq.clear(); - ex->ice_throw(); - } - - FileInfoSeq fileInfoSeq; - fileInfoSeq.swap(_fileInfoSeq); - return fileInfoSeq; - } - - virtual void - ice_response(const FileInfoSeq& fileInfoSeq) - { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - _fileInfoSeq = fileInfoSeq; - _done = true; - notify(); - } - - virtual void - ice_exception(const Exception& ex) - { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - _exception.reset(ex.ice_clone()); - _done = true; - notify(); - } - -private: - - bool _done; - FileInfoSeq _fileInfoSeq; - auto_ptr<Exception> _exception; -}; - -typedef IceUtil::Handle<AMIGetFileInfoSeq> AMIGetFileInfoSeqPtr; - } bool @@ -363,8 +303,8 @@ IcePatch2::Patcher::prepare() throw string("server returned illegal value"); } - AMIGetFileInfoSeqPtr curCB; - AMIGetFileInfoSeqPtr nxtCB; + AsyncResultPtr curCB; + AsyncResultPtr nxtCB; for(int node0 = 0; node0 < 256; ++node0) { @@ -373,9 +313,7 @@ IcePatch2::Patcher::prepare() if(!curCB) { assert(!nxtCB); - curCB = new AMIGetFileInfoSeq; - nxtCB = new AMIGetFileInfoSeq; - _serverCompress->getFileInfoSeq_async(curCB, node0); + curCB = _serverCompress->begin_getFileInfoSeq(node0); } else { @@ -393,10 +331,10 @@ IcePatch2::Patcher::prepare() if(node0Nxt < 256) { - _serverCompress->getFileInfoSeq_async(nxtCB, node0Nxt); + nxtCB = _serverCompress->begin_getFileInfoSeq(node0Nxt); } - FileInfoSeq files = curCB->getFileInfoSeq(); + FileInfoSeq files = _serverCompress->end_getFileInfoSeq(curCB); sort(files.begin(), files.end(), FileInfoLess()); files.erase(unique(files.begin(), files.end(), FileInfoEqual()), files.end()); @@ -733,71 +671,6 @@ IcePatch2::Patcher::updateFiles(const FileInfoSeq& files) return result; } -namespace -{ - -class AMIGetFileCompressed : public AMI_FileServer_getFileCompressed, public IceUtil::Monitor<IceUtil::Mutex> -{ -public: - - AMIGetFileCompressed() : - _done(false) - { - } - - ByteSeq - getFileCompressed() - { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - - while(!_done) - { - wait(); - } - - _done = false; - - if(_exception.get()) - { - auto_ptr<Exception> ex = _exception; - _bytes.clear(); - ex->ice_throw(); - } - - ByteSeq bytes; - bytes.swap(_bytes); - return bytes; - } - - virtual void - ice_response(const pair<const Ice::Byte*, const Ice::Byte*>& bytes) - { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - ByteSeq(bytes.first, bytes.second).swap(_bytes); - _done = true; - notify(); - } - - virtual void - ice_exception(const Exception& ex) - { - IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this); - _exception.reset(ex.ice_clone()); - _done = true; - notify(); - } - -private: - - bool _done; - ByteSeq _bytes; - auto_ptr<Exception> _exception; -}; - -typedef IceUtil::Handle<AMIGetFileCompressed> AMIGetFileCompressedPtr; - -} - bool IcePatch2::Patcher::updateFilesInternal(const FileInfoSeq& files, const DecompressorPtr& decompressor) { @@ -814,8 +687,8 @@ IcePatch2::Patcher::updateFilesInternal(const FileInfoSeq& files, const Decompre } } - AMIGetFileCompressedPtr curCB; - AMIGetFileCompressedPtr nxtCB; + AsyncResultPtr curCB; + AsyncResultPtr nxtCB; for(p = files.begin(); p != files.end(); ++p) { @@ -877,9 +750,7 @@ IcePatch2::Patcher::updateFilesInternal(const FileInfoSeq& files, const Decompre if(!curCB) { assert(!nxtCB); - curCB = new AMIGetFileCompressed; - nxtCB = new AMIGetFileCompressed; - _serverNoCompress->getFileCompressed_async(curCB, p->path, pos, _chunkSize); + curCB = _serverNoCompress->begin_getFileCompressed(p->path, pos, _chunkSize); } else { @@ -889,7 +760,7 @@ IcePatch2::Patcher::updateFilesInternal(const FileInfoSeq& files, const Decompre if(pos + _chunkSize < p->size) { - _serverNoCompress->getFileCompressed_async(nxtCB, p->path, pos + _chunkSize, _chunkSize); + nxtCB = _serverNoCompress->begin_getFileCompressed(p->path, pos + _chunkSize, _chunkSize); } else { @@ -902,7 +773,7 @@ IcePatch2::Patcher::updateFilesInternal(const FileInfoSeq& files, const Decompre if(q != files.end()) { - _serverNoCompress->getFileCompressed_async(nxtCB, q->path, 0, _chunkSize); + nxtCB = _serverNoCompress->begin_getFileCompressed(q->path, 0, _chunkSize); } } @@ -910,7 +781,7 @@ IcePatch2::Patcher::updateFilesInternal(const FileInfoSeq& files, const Decompre try { - bytes = curCB->getFileCompressed(); + bytes = _serverNoCompress->end_getFileCompressed(curCB); } catch(const FileAccessException& ex) { diff --git a/cpp/src/IceSSL/Certificate.cpp b/cpp/src/IceSSL/Certificate.cpp index 5a33fdda464..da9e7e2c4b9 100644 --- a/cpp/src/IceSSL/Certificate.cpp +++ b/cpp/src/IceSSL/Certificate.cpp @@ -40,7 +40,7 @@ CertificateReadException::ice_name() const return _name; } -Exception* +CertificateReadException* CertificateReadException::ice_clone() const { return new CertificateReadException(*this); @@ -70,7 +70,7 @@ CertificateEncodingException::ice_name() const return _name; } -Exception* +CertificateEncodingException* CertificateEncodingException::ice_clone() const { return new CertificateEncodingException(*this); @@ -269,7 +269,7 @@ ParseException::ice_name() const return _name; } -IceUtil::Exception* +ParseException* ParseException::ice_clone() const { return new ParseException(*this); diff --git a/cpp/src/IceSSL/EndpointI.cpp b/cpp/src/IceSSL/EndpointI.cpp index d7a63a226ee..6e5a8bb7463 100644 --- a/cpp/src/IceSSL/EndpointI.cpp +++ b/cpp/src/IceSSL/EndpointI.cpp @@ -543,10 +543,15 @@ IceSSL::EndpointI::operator<(const Ice::LocalObject& r) const Ice::Int IceSSL::EndpointI::hashInit() const { - Int h = 0; + Int h = 5381; + IceInternal::hashAdd(h, EndpointType); IceInternal::hashAdd(h, _host); IceInternal::hashAdd(h, _port); IceInternal::hashAdd(h, _timeout); + IceInternal::hashAdd(h, _protocol.major); + IceInternal::hashAdd(h, _protocol.minor); + IceInternal::hashAdd(h, _encoding.major); + IceInternal::hashAdd(h, _encoding.minor); IceInternal::hashAdd(h, _connectionId); IceInternal::hashAdd(h, _compress); return h; diff --git a/cpp/src/IceStorm/Election.ice b/cpp/src/IceStorm/Election.ice index fc8a8025484..3e9c95f6321 100644 --- a/cpp/src/IceStorm/Election.ice +++ b/cpp/src/IceStorm/Election.ice @@ -68,7 +68,7 @@ interface ReplicaObserver * inconsisency was detected. * **/ - ["ami"] void createTopic(LogUpdate llu, string name) + void createTopic(LogUpdate llu, string name) throws ObserverInconsistencyException; /** @@ -83,7 +83,7 @@ interface ReplicaObserver * inconsisency was detected. * **/ - ["ami"] void destroyTopic(LogUpdate llu, string name) + void destroyTopic(LogUpdate llu, string name) throws ObserverInconsistencyException; /** @@ -100,7 +100,7 @@ interface ReplicaObserver * inconsisency was detected. * **/ - ["ami"] void addSubscriber(LogUpdate llu, string topic, IceStorm::SubscriberRecord record) + void addSubscriber(LogUpdate llu, string topic, IceStorm::SubscriberRecord record) throws ObserverInconsistencyException; /** @@ -117,7 +117,7 @@ interface ReplicaObserver * inconsisency was detected. * **/ - ["ami"] void removeSubscriber(LogUpdate llu, string topic, Ice::IdentitySeq subscribers) + void removeSubscriber(LogUpdate llu, string topic, Ice::IdentitySeq subscribers) throws ObserverInconsistencyException; }; diff --git a/cpp/src/IceStorm/IceStormInternal.ice b/cpp/src/IceStorm/IceStormInternal.ice index e664f76abfb..3f89f9d3a03 100644 --- a/cpp/src/IceStorm/IceStormInternal.ice +++ b/cpp/src/IceStorm/IceStormInternal.ice @@ -59,7 +59,7 @@ interface TopicLink * @param events The events to forward. * **/ - ["ami"] void forward(EventDataSeq events); + void forward(EventDataSeq events); }; /** Thrown if the reap call would block. */ @@ -94,7 +94,7 @@ interface TopicInternal extends Topic * @throws ReapWouldBlock Raised if the reap call would block. * **/ - ["ami"] void reap(Ice::IdentitySeq id) throws ReapWouldBlock; + void reap(Ice::IdentitySeq id) throws ReapWouldBlock; }; /** diff --git a/cpp/src/IceStorm/NodeI.cpp b/cpp/src/IceStorm/NodeI.cpp index 9933b18357a..f586edcaa86 100644 --- a/cpp/src/IceStorm/NodeI.cpp +++ b/cpp/src/IceStorm/NodeI.cpp @@ -107,6 +107,21 @@ GroupNodeInfo::operator==(const GroupNodeInfo& rhs) const return id == rhs.id; } +// +// COMPILER FIX: Clang using libc++ requires to define operator= +// +#if defined(__clang__) && defined(_LIBCPP_VERSION) +GroupNodeInfo& +GroupNodeInfo::operator=(const GroupNodeInfo& other) + +{ + const_cast<int&>(this->id) = other.id; + const_cast<LogUpdate&>(this->llu) = other.llu; + const_cast<Ice::ObjectPrx&>(this->observer) = other.observer; + return *this; +} +#endif + Replica::~Replica() { //cout << "~Replica" << endl; diff --git a/cpp/src/IceStorm/Observers.cpp b/cpp/src/IceStorm/Observers.cpp index a937adf874c..92f74469421 100644 --- a/cpp/src/IceStorm/Observers.cpp +++ b/cpp/src/IceStorm/Observers.cpp @@ -15,82 +15,6 @@ using namespace std; using namespace IceStorm; using namespace IceStormElection; -namespace -{ - -class AMI_ReplicaObserver_createTopicI : public AMI_ReplicaObserver_createTopic, public AMICall -{ -public: - - virtual void ice_response() { response(); } - virtual void ice_exception(const Ice::Exception& e) { exception(e); } -}; -typedef IceUtil::Handle<AMI_ReplicaObserver_createTopicI> AMI_ReplicaObserver_createTopicIPtr; - -class AMI_ReplicaObserver_addSubscriberI : public AMI_ReplicaObserver_addSubscriber, public AMICall -{ -public: - - virtual void ice_response() { response(); } - virtual void ice_exception(const Ice::Exception& e) { exception(e); } -}; -typedef IceUtil::Handle<AMI_ReplicaObserver_addSubscriberI> AMI_ReplicaObserver_addSubscriberIPtr; - -class AMI_ReplicaObserver_removeSubscriberI : public AMI_ReplicaObserver_removeSubscriber, public AMICall -{ -public: - - virtual void ice_response() { response(); } - virtual void ice_exception(const Ice::Exception& e) { exception(e); } -}; -typedef IceUtil::Handle<AMI_ReplicaObserver_removeSubscriberI> AMI_ReplicaObserver_removeSubscriberIPtr; - -class AMI_ReplicaObserver_destroyTopicI : public AMI_ReplicaObserver_destroyTopic, public AMICall -{ -public: - - virtual void ice_response() { response(); } - virtual void ice_exception(const Ice::Exception& e) { exception(e); } -}; -typedef IceUtil::Handle<AMI_ReplicaObserver_destroyTopicI> AMI_ReplicaObserver_destroyTopicIPtr; - -} - -AMICall::AMICall() : - _response(false) -{ -} - -void -AMICall::response() -{ - Lock sync(*this); - _response = true; - notify(); -} -void -AMICall::exception(const IceUtil::Exception& e) -{ - Lock sync(*this); - _response = true; - _ex.reset(e.ice_clone()); - notify(); -} - -void -AMICall::waitResponse() -{ - Lock sync(*this); - while(!_response) - { - wait(); - } - if(_ex.get()) - { - _ex->ice_throw(); - } -} - Observers::Observers(const InstancePtr& instance) : _traceLevels(instance->traceLevels()), _majority(0) @@ -194,9 +118,7 @@ Observers::createTopic(const LogUpdate& llu, const string& name) Lock sync(*this); for(vector<ObserverInfo>::iterator p = _observers.begin(); p != _observers.end(); ++p) { - AMI_ReplicaObserver_createTopicIPtr cb = new AMI_ReplicaObserver_createTopicI; - p->call = cb; - p->observer->createTopic_async(cb, llu, name); + p->result = p->observer->begin_createTopic(llu, name); } wait("createTopic"); } @@ -207,9 +129,7 @@ Observers::destroyTopic(const LogUpdate& llu, const string& id) Lock sync(*this); for(vector<ObserverInfo>::iterator p = _observers.begin(); p != _observers.end(); ++p) { - AMI_ReplicaObserver_destroyTopicIPtr cb = new AMI_ReplicaObserver_destroyTopicI; - p->call = cb; - p->observer->destroyTopic_async(cb, llu, id); + p->result = p->observer->begin_destroyTopic(llu, id); } wait("destroyTopic"); } @@ -221,9 +141,7 @@ Observers::addSubscriber(const LogUpdate& llu, const string& name, const Subscri Lock sync(*this); for(vector<ObserverInfo>::iterator p = _observers.begin(); p != _observers.end(); ++p) { - AMI_ReplicaObserver_addSubscriberIPtr cb = new AMI_ReplicaObserver_addSubscriberI; - p->call = cb; - p->observer->addSubscriber_async(cb, llu, name, rec); + p->result = p->observer->begin_addSubscriber(llu, name, rec); } wait("addSubscriber"); } @@ -234,9 +152,7 @@ Observers::removeSubscriber(const LogUpdate& llu, const string& name, const Ice: Lock sync(*this); for(vector<ObserverInfo>::iterator p = _observers.begin(); p != _observers.end(); ++p) { - AMI_ReplicaObserver_removeSubscriberIPtr cb = new AMI_ReplicaObserver_removeSubscriberI; - p->call = cb; - p->observer->removeSubscriber_async(cb, llu, name, id); + p->result = p->observer->begin_removeSubscriber(llu, name, id); } wait("removeSubscriber"); } @@ -249,7 +165,8 @@ Observers::wait(const string& op) { try { - p->call->waitResponse(); + p->result->waitForCompleted(); + p->result->throwLocalException(); } catch(const Ice::Exception& ex) { @@ -261,11 +178,8 @@ Observers::wait(const string& op) int id = p->id; p = _observers.erase(p); - // COMPILERFIX: Just using following causes double unlock with C++Builder 2007 - //IceUtil::Mutex::Lock sync(_reapedMutex); - _reapedMutex.lock(); + IceUtil::Mutex::Lock sync(_reapedMutex); _reaped.push_back(id); - _reapedMutex.unlock(); continue; } ++p; diff --git a/cpp/src/IceStorm/Observers.h b/cpp/src/IceStorm/Observers.h index d7c51f9020f..1cac54a8b8e 100644 --- a/cpp/src/IceStorm/Observers.h +++ b/cpp/src/IceStorm/Observers.h @@ -25,23 +25,6 @@ typedef IceUtil::Handle<TraceLevels> TraceLevelsPtr; namespace IceStormElection { -class AMICall : virtual public IceUtil::Shared, - virtual public IceUtil::Monitor<IceUtil::Mutex> -{ -public: - - AMICall(); - - void response(); - void exception(const IceUtil::Exception& e); - void waitResponse(); - -private: - bool _response; - std::auto_ptr<IceUtil::Exception> _ex; -}; -typedef IceUtil::Handle<AMICall> AMICallPtr; - class Observers : public IceUtil::Shared, public IceUtil::Mutex { public: @@ -72,7 +55,7 @@ private: id(i), observer(o) {} int id; ReplicaObserverPrx observer; - AMICallPtr call; + ::Ice::AsyncResultPtr result; }; std::vector<ObserverInfo> _observers; IceUtil::Mutex _reapedMutex; diff --git a/cpp/src/IceStorm/Replica.h b/cpp/src/IceStorm/Replica.h index 60600c778d8..7e131904bf1 100644 --- a/cpp/src/IceStorm/Replica.h +++ b/cpp/src/IceStorm/Replica.h @@ -22,6 +22,12 @@ struct GroupNodeInfo GroupNodeInfo(int i, LogUpdate l, const Ice::ObjectPrx& o = Ice::ObjectPrx()); bool operator<(const GroupNodeInfo& rhs) const; bool operator==(const GroupNodeInfo& rhs) const; + // + // COMPILER FIX: Clang using libc++ requires to define operator= + // +#if defined(__clang__) && defined(_LIBCPP_VERSION) + GroupNodeInfo& operator=(const GroupNodeInfo&); +#endif const int id; const LogUpdate llu; const Ice::ObjectPrx observer; diff --git a/cpp/src/IceStorm/Service.cpp b/cpp/src/IceStorm/Service.cpp index 2844453c5a7..9bb02dc0b83 100644 --- a/cpp/src/IceStorm/Service.cpp +++ b/cpp/src/IceStorm/Service.cpp @@ -85,7 +85,7 @@ createIceStorm(CommunicatorPtr communicator) } ServicePtr -Service::create(const CommunicatorPtr& communicator, +IceStormInternal::Service::create(const CommunicatorPtr& communicator, const ObjectAdapterPtr& topicAdapter, const ObjectAdapterPtr& publishAdapter, const string& name, diff --git a/cpp/src/IceStorm/Subscriber.cpp b/cpp/src/IceStorm/Subscriber.cpp index b854ff2a835..74b15583cc1 100755 --- a/cpp/src/IceStorm/Subscriber.cpp +++ b/cpp/src/IceStorm/Subscriber.cpp @@ -93,6 +93,11 @@ public: virtual void flush(); + void exception(const Ice::Exception& ex) + { + error(false, ex); + } + void doFlush(); private: @@ -111,7 +116,11 @@ public: virtual void flush(); - void sent(); + void exception(const Ice::Exception& ex) + { + error(true, ex); + } + void sent(bool); private: @@ -146,84 +155,6 @@ private: const TopicLinkPrx _obj; }; -class OnewayIceInvokeI : public Ice::AMI_Object_ice_invoke, public Ice::AMISentCallback -{ -public: - - OnewayIceInvokeI(const SubscriberOnewayPtr& subscriber) : - _subscriber(subscriber) - { - } - - virtual void - ice_response(bool, const std::vector<Ice::Byte>&) - { - assert(false); - } - - virtual void - ice_sent() - { - _subscriber->sent(); - } - - virtual void - ice_exception(const Ice::Exception& e) - { - _subscriber->error(true, e); - } - -private: - - const SubscriberOnewayPtr _subscriber; -}; - -class IceInvokeI : public Ice::AMI_Object_ice_invoke -{ -public: - - IceInvokeI(const SubscriberPtr& subscriber) : - _subscriber(subscriber) - { - } - - virtual void - ice_response(bool, const std::vector<Ice::Byte>&) - { - _subscriber->response(); - } - - virtual void - ice_exception(const Ice::Exception& e) - { - _subscriber->error(true, e); - } - -private: - - const SubscriberPtr _subscriber; -}; - -class FlushBatchI : public Ice::AMI_Object_ice_flushBatchRequests -{ -public: - - FlushBatchI(const SubscriberPtr& subscriber) : - _subscriber(subscriber) - { - } - - virtual void - ice_exception(const Ice::Exception& e) - { - _subscriber->error(false, e); - } - -private: - - const SubscriberPtr _subscriber; -}; - class FlushTimerTask : public IceUtil::TimerTask { public: @@ -313,7 +244,8 @@ SubscriberBatch::doFlush() return; } - _obj->ice_flushBatchRequests_async(new FlushBatchI(this)); + _obj->begin_ice_flushBatchRequests(Ice::newCallback_Object_ice_flushBatchRequests(this, + &SubscriberBatch::exception)); // This is significantly faster than the async version, but it can // block the calling thread. Bad news! @@ -361,7 +293,11 @@ SubscriberOneway::flush() _events.erase(_events.begin()); try { - if(!_obj->ice_invoke_async(new OnewayIceInvokeI(this), e->op, e->mode, e->data, e->context)) + Ice::AsyncResultPtr result = _obj->begin_ice_invoke( + e->op, e->mode, e->data, e->context, Ice::newCallback_Object_ice_invoke(this, + &SubscriberOneway::exception, + &SubscriberOneway::sent)); + if(!result->sentSynchronously()) { ++_outstanding; } @@ -380,8 +316,13 @@ SubscriberOneway::flush() } void -SubscriberOneway::sent() +SubscriberOneway::sent(bool sentSynchronously) { + if(sentSynchronously) + { + return; + } + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(_lock); // Decrement the _outstanding count. @@ -436,7 +377,8 @@ SubscriberTwoway::flush() try { - _obj->ice_invoke_async(new IceInvokeI(this), e->op, e->mode, e->data, e->context); + _obj->begin_ice_invoke(e->op, e->mode, e->data, e->context, + Ice::newCallback(static_cast<Subscriber*>(this), &Subscriber::completed)); } catch(const Ice::Exception& ex) { @@ -449,34 +391,6 @@ SubscriberTwoway::flush() namespace { -class Topiclink_forwardI : public IceStorm::AMI_TopicLink_forward -{ -public: - - Topiclink_forwardI(const SubscriberPtr& subscriber) : - _subscriber(subscriber) - { - } - - virtual void - ice_response() - { - _subscriber->response(); - } - - virtual void - ice_exception(const Ice::Exception& e) - { - _subscriber->error(true, e); - } - -private: - - const SubscriberPtr _subscriber; -}; - -} - SubscriberLink::SubscriberLink( const InstancePtr& instance, const SubscriberRecord& rec) : @@ -523,7 +437,7 @@ SubscriberLink::flush() try { ++_outstanding; - _obj->forward_async(new Topiclink_forwardI(this), v); + _obj->begin_forward(v, Ice::newCallback(static_cast<Subscriber*>(this), &Subscriber::completed)); } catch(const Ice::Exception& ex) { @@ -532,6 +446,8 @@ SubscriberLink::flush() } } +} + SubscriberPtr Subscriber::create( const InstancePtr& instance, @@ -850,30 +766,40 @@ Subscriber::error(bool dec, const Ice::Exception& e) } void -Subscriber::response() +Subscriber::completed(const Ice::AsyncResultPtr& result) { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(_lock); - - // Decrement the _outstanding count. - --_outstanding; - assert(_outstanding >= 0 && _outstanding < _maxOutstanding); - - // - // A successful response means we're no longer retrying, we're - // back active. - // - _currentRetry = 0; - - if(_events.empty() && _outstanding == 0 && _shutdown) + try { - _lock.notify(); + result->throwLocalException(); + + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(_lock); + + // Decrement the _outstanding count. + --_outstanding; + assert(_outstanding >= 0 && _outstanding < _maxOutstanding); + + // + // A successful response means we're no longer retrying, we're + // back active. + // + _currentRetry = 0; + + if(_events.empty() && _outstanding == 0 && _shutdown) + { + _lock.notify(); + } + else + { + flush(); + } } - else + catch(const Ice::LocalException& ex) { - flush(); + error(true, ex); } } + void Subscriber::shutdown() { diff --git a/cpp/src/IceStorm/Subscriber.h b/cpp/src/IceStorm/Subscriber.h index 75b7e0ea056..52e07c2b137 100644 --- a/cpp/src/IceStorm/Subscriber.h +++ b/cpp/src/IceStorm/Subscriber.h @@ -43,8 +43,8 @@ public: void destroy(); // To be called by the AMI callbacks only. + void completed(const Ice::AsyncResultPtr&); void error(bool, const Ice::Exception&); - void response(); void shutdown(); diff --git a/cpp/src/IceStorm/TopicI.cpp b/cpp/src/IceStorm/TopicI.cpp index 35e0fe455dc..a19ac8b7289 100644 --- a/cpp/src/IceStorm/TopicI.cpp +++ b/cpp/src/IceStorm/TopicI.cpp @@ -1147,20 +1147,16 @@ TopicImpl::proxy() const namespace { -class TopicInternal_reapI : public AMI_TopicInternal_reap +class TopicInternalReapCB : public IceUtil::Shared { public: - TopicInternal_reapI(const InstancePtr& instance, Ice::Long generation) : + TopicInternalReapCB(const InstancePtr& instance, Ice::Long generation) : _instance(instance), _generation(generation) { } - virtual void ice_response() - { - } - - virtual void ice_exception(const Ice::Exception& ex) + virtual void exception(const Ice::Exception& ex) { TraceLevelsPtr traceLevels = _instance->traceLevels(); if(traceLevels->topic > 0) @@ -1236,7 +1232,8 @@ TopicImpl::publish(bool forwarded, const EventDataSeq& events) // call may raise an exception in the caller (that is directly // call ice_exception) which calls recover() on the node which // would result in a deadlock since the node is locked. - masterInternal->reap_async(new TopicInternal_reapI(_instance, generation), reap); + masterInternal->begin_reap(reap, newCallback_TopicInternal_reap(new TopicInternalReapCB(_instance, generation), + &TopicInternalReapCB::exception)); } void diff --git a/cpp/src/IceUtil/CtrlCHandler.cpp b/cpp/src/IceUtil/CtrlCHandler.cpp index 26b9fcf711a..bb6bbb9f2a3 100644 --- a/cpp/src/IceUtil/CtrlCHandler.cpp +++ b/cpp/src/IceUtil/CtrlCHandler.cpp @@ -68,7 +68,7 @@ CtrlCHandlerException::ice_name() const return ctrlCHandlerName; } -Exception* +CtrlCHandlerException* CtrlCHandlerException::ice_clone() const { return new CtrlCHandlerException(*this); diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp index b6c75231f5a..3d4a40a91fc 100644 --- a/cpp/src/IceUtil/Exception.cpp +++ b/cpp/src/IceUtil/Exception.cpp @@ -17,8 +17,20 @@ #if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__) # include <execinfo.h> # include <cxxabi.h> +# define ICE_STACK_TRACES +# define ICE_GCC_STACK_TRACES #endif +#if defined(_WIN32) && !defined(__MINGW32__) && !defined(ICE_OS_WINRT) +# include <IceUtil/Unicode.h> +# define DBGHELP_TRANSLATE_TCHAR +# include <DbgHelp.h> +# include <iomanip> +# define ICE_STACK_TRACES +# define ICE_WIN32_STACK_TRACES +#endif + + using namespace std; namespace IceUtilInternal @@ -34,6 +46,10 @@ namespace IceUtil::Mutex* globalMutex = 0; +#ifdef ICE_WIN32_STACK_TRACES +HANDLE process = 0; +#endif + class Init { public: @@ -47,22 +63,102 @@ public: { delete globalMutex; globalMutex = 0; +#ifdef ICE_WIN32_STACK_TRACES + if(process != 0) + { + SymCleanup(process); + process = 0; + } +#endif } }; Init init; -#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__) +#ifdef ICE_STACK_TRACES string getStackTrace() { + if(!IceUtilInternal::printStackTraces) + { + return ""; + } + string stackTrace; - if(!IceUtilInternal::printStackTraces) +# ifdef ICE_WIN32_STACK_TRACES + // + // Note: the Sym functions are not thread-safe + // + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(globalMutex); + if(process == 0) + { + process = GetCurrentProcess(); + SymSetOptions(SYMOPT_LOAD_LINES | SYMOPT_UNDNAME); + BOOL ok = SymInitialize(process, 0, TRUE); + if(!ok) + { + process = 0; + return "No stack trace: SymInitialize failed with " + IceUtilInternal::errorToString(GetLastError()); + } + } + lock.release(); + + const int stackSize = 61; + void* stack[stackSize]; + + // + // 1: skip the first frame (the call to getStackTrace) + // 1 + stackSize < 63 on XP according to the documentation for CaptureStackBackTrace + // + USHORT frames = CaptureStackBackTrace(1, stackSize, stack, 0); + + if(frames > 0) { - return stackTrace; + char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)]; + SYMBOL_INFO* symbol = reinterpret_cast<SYMBOL_INFO*>(buffer); + symbol->SizeOfStruct = sizeof(SYMBOL_INFO); + symbol->MaxNameLen = MAX_SYM_NAME; + + IMAGEHLP_LINE64 line = {}; + line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); + DWORD displacement = 0; + + lock.acquire(); + for(int i = 0; i < frames; i++) + { + if(!stackTrace.empty()) + { + stackTrace += "\n"; + } + + stringstream s; + s << setw(3) << i << " "; + + DWORD64 address = reinterpret_cast<DWORD64>(stack[i]); + + BOOL ok = SymFromAddr(process, address, 0, symbol); + if(ok) + { + s << IceUtil::wstringToString(symbol->Name); + + ok = SymGetLineFromAddr64(process, address, &displacement, &line); + if(ok) + { + s << " at line " << line.LineNumber << " in " << IceUtil::wstringToString(line.FileName); + } + } + else + { + s << hex << "0x" << address; + } + stackTrace += s.str(); + } + lock.release(); } +# elif defined(ICE_GCC_STACK_TRACES) + const size_t maxDepth = 100; void *stackAddrs[maxDepth]; @@ -174,6 +270,7 @@ getStackTrace() } free(stackStrings); +# endif return stackTrace; } #endif @@ -183,7 +280,7 @@ getStackTrace() IceUtil::Exception::Exception() : _file(0), _line(0) -#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__) +#ifdef ICE_STACK_TRACES , _stackTrace(getStackTrace()) #endif { @@ -192,7 +289,7 @@ IceUtil::Exception::Exception() : IceUtil::Exception::Exception(const char* file, int line) : _file(file), _line(line) -#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__) +#ifdef ICE_STACK_TRACES , _stackTrace(getStackTrace()) #endif { @@ -300,7 +397,7 @@ IceUtil::NullHandleException::ice_name() const return _name; } -IceUtil::Exception* +IceUtil::NullHandleException* IceUtil::NullHandleException::ice_clone() const { return new NullHandleException(*this); @@ -342,7 +439,7 @@ IceUtil::IllegalArgumentException::ice_print(ostream& out) const out << ": " << _reason; } -IceUtil::Exception* +IceUtil::IllegalArgumentException* IceUtil::IllegalArgumentException::ice_clone() const { return new IllegalArgumentException(*this); @@ -384,7 +481,7 @@ IceUtil::SyscallException::ice_print(ostream& os) const } } -IceUtil::Exception* +IceUtil::SyscallException* IceUtil::SyscallException::ice_clone() const { return new SyscallException(*this); @@ -433,7 +530,7 @@ IceUtil::FileLockException::ice_print(ostream& os) const } } -IceUtil::Exception* +IceUtil::FileLockException* IceUtil::FileLockException::ice_clone() const { return new FileLockException(*this); @@ -472,7 +569,7 @@ IceUtil::OptionalNotSetException::ice_name() const return _name; } -IceUtil::Exception* +IceUtil::OptionalNotSetException* IceUtil::OptionalNotSetException::ice_clone() const { return new OptionalNotSetException(*this); diff --git a/cpp/src/IceUtil/FileUtil.cpp b/cpp/src/IceUtil/FileUtil.cpp index 9fe0a5f85d3..b09159619bf 100644 --- a/cpp/src/IceUtil/FileUtil.cpp +++ b/cpp/src/IceUtil/FileUtil.cpp @@ -16,10 +16,9 @@ #ifdef _WIN32 # include <process.h> -#endif - -#ifdef _WIN32 # include <io.h> +#else +# include <unistd.h> #endif using namespace std; diff --git a/cpp/src/IceUtil/Makefile.mak b/cpp/src/IceUtil/Makefile.mak index a4ec13cc6e3..1867424f63c 100644 --- a/cpp/src/IceUtil/Makefile.mak +++ b/cpp/src/IceUtil/Makefile.mak @@ -60,7 +60,7 @@ $(LIBNAME): $(OBJS) $(LIBNAME): $(DLLNAME)
$(DLLNAME): $(OBJS) IceUtil.res
- $(LINK) $(BASE):0x20000000 $(LD_DLLFLAGS) $(PDBFLAGS) $(OBJS) $(PREOUT)$@ $(PRELIBS)$(ICE_OS_LIBS) \
+ $(LINK) $(BASE):0x20000000 $(LD_DLLFLAGS) $(PDBFLAGS) $(OBJS) $(PREOUT)$@ $(PRELIBS) $(ICEUTIL_OS_LIBS) \
$(RES_FILE)
move $(DLLNAME:.dll=.lib) $(LIBNAME)
@if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \
diff --git a/cpp/src/IceUtil/Options.cpp b/cpp/src/IceUtil/Options.cpp index b632d0e90fa..32840de107c 100644 --- a/cpp/src/IceUtil/Options.cpp +++ b/cpp/src/IceUtil/Options.cpp @@ -42,7 +42,7 @@ IceUtilInternal::APIException::ice_print(ostream& out) const } } -IceUtil::Exception* +IceUtilInternal::APIException* IceUtilInternal::APIException::ice_clone() const { return new APIException(*this); @@ -88,7 +88,7 @@ IceUtilInternal::BadOptException::ice_print(ostream& out) const } } -IceUtil::Exception* +IceUtilInternal::BadOptException* IceUtilInternal::BadOptException::ice_clone() const { return new BadOptException(*this); diff --git a/cpp/src/IceUtil/OutputUtil.cpp b/cpp/src/IceUtil/OutputUtil.cpp index 00464533d98..7ab7ca159f0 100644 --- a/cpp/src/IceUtil/OutputUtil.cpp +++ b/cpp/src/IceUtil/OutputUtil.cpp @@ -35,7 +35,11 @@ IceUtilInternal::int64ToString(Int64 val) { char buf[64]; #ifdef _WIN32 +# if defined(_MSC_VER) sprintf_s(buf, sizeof(buf), "%I64d", val); +# else + sprintf(buf, "%I64d", val); +# endif #elif defined(ICE_64) sprintf(buf, "%ld", val); // Avoids a format warning from GCC. #else diff --git a/cpp/src/IceUtil/ThreadException.cpp b/cpp/src/IceUtil/ThreadException.cpp index dcfcfad386e..f034da27408 100644 --- a/cpp/src/IceUtil/ThreadException.cpp +++ b/cpp/src/IceUtil/ThreadException.cpp @@ -24,7 +24,7 @@ IceUtil::ThreadSyscallException::ice_name() const return _name; } -IceUtil::Exception* +IceUtil::ThreadSyscallException* IceUtil::ThreadSyscallException::ice_clone() const { return new ThreadSyscallException(*this); @@ -49,7 +49,7 @@ IceUtil::ThreadLockedException::ice_name() const return _name; } -IceUtil::Exception* +IceUtil::ThreadLockedException* IceUtil::ThreadLockedException::ice_clone() const { return new ThreadLockedException(*this); @@ -74,7 +74,7 @@ IceUtil::ThreadStartedException::ice_name() const return _name; } -IceUtil::Exception* +IceUtil::ThreadStartedException* IceUtil::ThreadStartedException::ice_clone() const { return new ThreadStartedException(*this); @@ -99,7 +99,7 @@ IceUtil::ThreadNotStartedException::ice_name() const return _name; } -IceUtil::Exception* +IceUtil::ThreadNotStartedException* IceUtil::ThreadNotStartedException::ice_clone() const { return new ThreadNotStartedException(*this); @@ -125,7 +125,7 @@ IceUtil::BadThreadControlException::ice_name() const return _name; } -IceUtil::Exception* +IceUtil::BadThreadControlException* IceUtil::BadThreadControlException::ice_clone() const { return new BadThreadControlException(*this); @@ -159,7 +159,7 @@ IceUtil::InvalidTimeoutException::ice_print(ostream& os) const os << ":\ninvalid timeout: " << _timeout << " seconds"; } -IceUtil::Exception* +IceUtil::InvalidTimeoutException* IceUtil::InvalidTimeoutException::ice_clone() const { return new InvalidTimeoutException(*this); diff --git a/cpp/src/IceUtil/Unicode.cpp b/cpp/src/IceUtil/Unicode.cpp index f7a8bd5192a..238ae2042ff 100644 --- a/cpp/src/IceUtil/Unicode.cpp +++ b/cpp/src/IceUtil/Unicode.cpp @@ -165,7 +165,7 @@ IceUtil::UTFConversionException::ice_print(ostream& os) const }; } -IceUtil::Exception* +IceUtil::UTFConversionException* IceUtil::UTFConversionException::ice_clone() const { return new UTFConversionException(*this); diff --git a/cpp/src/IceXML/Parser.cpp b/cpp/src/IceXML/Parser.cpp index d72164c5c5c..d561cf70459 100644 --- a/cpp/src/IceXML/Parser.cpp +++ b/cpp/src/IceXML/Parser.cpp @@ -55,7 +55,7 @@ IceXML::ParserException::ice_print(std::ostream& out) const } } -IceUtil::Exception* +IceXML::ParserException* IceXML::ParserException::ice_clone() const { return new ParserException(*this); diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp index 1cd5e3dcec3..482ee8a11b1 100644 --- a/cpp/src/Slice/CsUtil.cpp +++ b/cpp/src/Slice/CsUtil.cpp @@ -582,24 +582,7 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, EnumPtr en = EnumPtr::dynamicCast(type); if(en) { - string func; - string cast; size_t sz = en->getEnumerators().size(); - if(sz <= 0x7f) - { - func = marshal ? "writeByte" : "readByte"; - cast = marshal ? string("(byte)") : "(" + fixId(en->scoped()) + ")"; - } - else if(sz <= 0x7fff) - { - func = marshal ? "writeShort" : "readShort"; - cast = marshal ? string("(short)") : "(" + fixId(en->scoped()) + ")"; - } - else - { - func = marshal ? "writeInt" : "readInt"; - cast = marshal ? string("(int)") : "(" + fixId(en->scoped()) + ")"; - } if(marshal) { if(streamingAPI) @@ -609,21 +592,11 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out, out << nl << "throw new Ice.MarshalException(\"enumerator out of range\");"; out << eb; } - out << nl << stream << '.' << func << '(' << cast << param; - if(!streamingAPI) - { - out << ", " << sz; - } - out << ");"; + out << nl << stream << ".writeEnum((int)" << param << ", " << sz << ");"; } else { - out << nl << param << " = " << cast << stream << '.' << func << "("; - if(!streamingAPI) - { - out << sz; - } - out << ")" << ';'; + out << nl << param << " = (" << fixId(en->scoped()) << ')' << stream << ".readEnum(" << sz << ");"; if(streamingAPI) { out << nl << "if((int)" << param << " < 0 || (int)" << param << " >= " << sz << ")"; @@ -1246,23 +1219,6 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, if(en) { size_t sz = en->getEnumerators().size(); - string dataType; - string func = marshal ? "write" : "read"; - if(sz <= 0x7f) - { - func += "Byte"; - dataType = "byte"; - } - else if(sz <= 0x7fff) - { - func += "Short"; - dataType = "short"; - } - else - { - func += "Int"; - dataType = "int"; - } if(marshal) { out << nl << "if(" << param << " == null)"; @@ -1282,12 +1238,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, out << nl << typeS << "[] " << param << "_tmp = " << param << ".ToArray();"; out << nl << "for(int ix__ = " << param << "_tmp.Length - 1; ix__ >= 0; --ix__)"; out << sb; - out << nl << stream << '.' << func << "((" << dataType << ")" << param << "_tmp[ix__]"; - if(!streamingAPI) - { - out << ", " << sz; - } - out << ");"; + out << nl << stream << ".writeEnum((int)" << param << "_tmp[ix__], " << sz << ");"; out << eb; } else @@ -1296,12 +1247,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, << "> e__ = " << param << ".GetEnumerator();"; out << nl << "while(e__.MoveNext())"; out << sb; - out << nl << stream << '.' << func << "((" << dataType << ")e__.Current"; - if(!streamingAPI) - { - out << ", " << sz; - } - out << ");"; + out << nl << stream << ".writeEnum((int)e__.Current, " << sz << ");"; out << eb; } } @@ -1309,12 +1255,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, { out << nl << "for(int ix__ = 0; ix__ < " << param << '.' << limitID << "; ++ix__)"; out << sb; - out << nl << stream << '.' << func << "((" << dataType << ")" << param << "[ix__]"; - if(!streamingAPI) - { - out << ", " << sz; - } - out << ");"; + out << nl << stream << ".writeEnum((int)" << param << "[ix__], " << sz << ");"; out << eb; } out << eb; @@ -1350,21 +1291,11 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out, out << sb; if(isArray) { - out << nl << param << "[ix__] = (" << typeS << ')' << stream << "." << func << "("; - if(!streamingAPI) - { - out << sz; - } - out << ");"; + out << nl << param << "[ix__] = (" << typeS << ')' << stream << ".readEnum(" << sz << ");"; } else { - out << nl << param << "." << addMethod << "((" << typeS << ')' << stream << "." << func << "("; - if(!streamingAPI) - { - out << sz; - } - out << "));"; + out << nl << param << "." << addMethod << "((" << typeS << ')' << stream << ".readEnum(" << sz << "));"; } out << eb; out << eb; diff --git a/cpp/src/Slice/FileTracker.cpp b/cpp/src/Slice/FileTracker.cpp index a14638757a2..9000efb43a0 100644 --- a/cpp/src/Slice/FileTracker.cpp +++ b/cpp/src/Slice/FileTracker.cpp @@ -9,12 +9,10 @@ #include <Slice/FileTracker.h> -#ifdef __sun -# include <unistd.h> -#endif - #ifdef _WIN32 # include <direct.h> +#else +# include <unistd.h> #endif using namespace std; @@ -44,7 +42,7 @@ Slice::FileException::ice_print(ostream& out) const out << ": " << _reason; } -IceUtil::Exception* +Slice::FileException* Slice::FileException::ice_clone() const { return new FileException(*this); diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 70adaf19199..f6cb56d797b 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -814,8 +814,8 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) H << nl << "virtual void ice_print(::std::ostream&) const;"; } - H << nl << "virtual ::Ice::Exception* ice_clone() const;"; - C << sp << nl << "::Ice::Exception*" << nl << scoped.substr(2) << "::ice_clone() const"; + H << nl << "virtual " << name << "* ice_clone() const;"; + C << sp << nl << scoped.substr(2) << "*" << nl << scoped.substr(2) << "::ice_clone() const"; C << sb; C << nl << "return new " << name << "(*this);"; C << eb; @@ -1763,6 +1763,38 @@ Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr& p) _useWstring = resetUseWstring(_useWstringHist); } +namespace +{ + +bool +usePrivateEnd(const OperationPtr& p) +{ + TypePtr ret = p->returnType(); + bool retIsOpt = p->returnIsOptional(); + string retSEnd = returnTypeToString(ret, retIsOpt, p->getMetaData(), TypeContextAMIEnd); + string retSPrivateEnd = returnTypeToString(ret, retIsOpt, p->getMetaData(), TypeContextAMIPrivateEnd); + + ParamDeclList outParams; + vector<string> outDeclsEnd; + vector<string> outDeclsPrivateEnd; + + ParamDeclList paramList = p->parameters(); + for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) + { + if((*q)->isOutParam()) + { + outDeclsEnd.push_back(outputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), + TypeContextAMIEnd)); + outDeclsPrivateEnd.push_back(outputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), + TypeContextAMIPrivateEnd)); + } + } + + return retSEnd != retSPrivateEnd || outDeclsEnd != outDeclsPrivateEnd; +} + +} + void Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) { @@ -1771,14 +1803,17 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) string scope = fixKwd(p->scope()); TypePtr ret = p->returnType(); + bool retIsOpt = p->returnIsOptional(); string retS = returnTypeToString(ret, retIsOpt, p->getMetaData(), _useWstring | TypeContextAMIEnd); string retSEndAMI = returnTypeToString(ret, retIsOpt, p->getMetaData(), _useWstring | TypeContextAMIPrivateEnd); + string retInS = retS != "void" ? inputTypeToString(ret, retIsOpt, p->getMetaData(), _useWstring) : ""; ContainerPtr container = p->container(); ClassDefPtr cl = ClassDefPtr::dynamicCast(container); + string clName = cl->name(); string clScope = fixKwd(cl->scope()); - string delName = "Callback_" + cl->name() + "_" + name; + string delName = "Callback_" + clName + "_" + name; string delNameScoped = clScope + delName; vector<string> params; @@ -1789,12 +1824,18 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) vector<string> paramsDeclAMI; vector<string> argsAMI; vector<string> outParamsAMI; + vector<string> outParamNamesAMI; vector<string> outParamsDeclAMI; vector<string> outParamsDeclEndAMI; - + vector<string> outDecls; + ParamDeclList paramList = p->parameters(); ParamDeclList inParams; ParamDeclList outParams; + + + vector<string> outEndArgs; + for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) { string paramName = fixKwd((*q)->name()); @@ -1827,9 +1868,12 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) else { outParamsAMI.push_back(typeString); + outParamNamesAMI.push_back(paramName); outParamsDeclAMI.push_back(typeString + ' ' + paramName); outParamsDeclEndAMI.push_back(typeStringEndAMI + ' ' + paramName); outParams.push_back(*q); + outDecls.push_back(inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring)); + outEndArgs.push_back(getEndArg((*q)->type(), (*q)->getMetaData(), outParamNamesAMI.back())); } } @@ -1873,6 +1917,201 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) } H << fixKwd(name) << spar << args << "&__ctx" << epar << ';'; H << eb; + + H.zeroIndent(); + H << nl << "#ifdef ICE_CPP11"; + H.restoreIndent(); + + string retEndArg = getEndArg(ret, p->getMetaData(), "__ret"); + + H << nl << "::Ice::AsyncResultPtr"; + H << nl << "begin_" << name << spar << paramsDeclAMI + << "const ::IceInternal::Function<void " << spar; + if(!retInS.empty()) + { + H << retInS; + } + H << outDecls << epar << ">& response, " + << "const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = " + "::IceInternal::Function<void (const ::Ice::Exception&)>(), " + << "const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()" << epar; + + H << sb; + if(p->returnsData()) + { + H << nl << "return __begin_" << name << spar << argsAMI << "0, response, exception, sent" << epar << ";"; + } + else + { + H << nl << "return begin_" << name << spar << argsAMI + << "0, new ::IceInternal::Cpp11FnOnewayCallbackNC(response, exception, sent)" << epar << ";"; + + } + H << eb; + + H << nl << "::Ice::AsyncResultPtr"; + H << nl << "begin_" << name << spar << paramsDeclAMI + << "const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed" + << "const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = " + "::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()" << epar; + H << sb; + H << nl << "return begin_" << name << spar << argsAMI << "0, ::Ice::newCallback(completed, sent), 0" << epar << ";"; + H << eb; + + + H << nl << "::Ice::AsyncResultPtr"; + H << nl << "begin_" << name << spar << paramsDeclAMI << "const ::Ice::Context& ctx" + << "const ::IceInternal::Function<void " << spar; + if(!retInS.empty()) + { + H << retInS; + } + H << outDecls << epar << ">& response, " + << "const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = " + "::IceInternal::Function<void (const ::Ice::Exception&)>(), " + << "const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()" << epar; + + H << sb; + if(p->returnsData()) + { + H << nl << "return __begin_" << name << spar << argsAMI << "&ctx, response, exception, sent" << epar << ";"; + } + else + { + H << nl << "return begin_" << name << spar << argsAMI + << "&ctx, new ::IceInternal::Cpp11FnOnewayCallbackNC(response, exception, sent), 0" << epar << ";"; + } + H << eb; + + H << nl << "::Ice::AsyncResultPtr"; + H << nl << "begin_" << name << spar << paramsDeclAMI + << "const ::Ice::Context& ctx" + << "const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed" + << "const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = " + "::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()" << epar; + H << sb; + H << nl << "return begin_" << name << spar << argsAMI << "&ctx, ::Ice::newCallback(completed, sent)" << epar << ";"; + H << eb; + + if(p->returnsData()) + { + H << nl; + H.dec(); + H << nl << "private:"; + H.inc(); + + + H << sp << nl << "::Ice::AsyncResultPtr __begin_" << name << spar << paramsDeclAMI + << "const ::Ice::Context* ctx" << "const ::IceInternal::Function<void " << spar; + + + if(!retInS.empty()) + { + H << retInS; + } + H << outDecls; + + H << epar << ">& response, " + << "const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception, " + << "const ::IceInternal::Function<void (bool)>& sent" << epar; + H << sb; + H << nl << "class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC"; + H << sb; + H.dec(); + H << nl << "public:"; + H.inc(); + H << sp << nl << "Cpp11CB" << spar << "const ::std::function<void " << spar; + if(!retInS.empty()) + { + H << retInS; + } + H << outDecls; + H << epar << ">& responseFunc, " + << "const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc, " + << "const ::std::function<void (bool)>& sentFunc" << epar << " :"; + H.inc(); + H << nl << "::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc),"; + H << nl << "_response(responseFunc)"; + H.dec(); + H << sb; + H << nl << "CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr);"; + H << eb; + + // + // completed. + // + H << sp << nl << "virtual void __completed(const ::Ice::AsyncResultPtr& __result) const"; + H << sb; + H << nl << clScope << clName << "Prx __proxy = " << clScope << clName + << "Prx::uncheckedCast(__result->getProxy());"; + writeAllocateCode(H, outParams, p, _useWstring | TypeContextInParam | TypeContextAMICallPrivateEnd); + H << nl << "try"; + H << sb; + H << nl; + if(!usePrivateEnd(p)) + { + if(ret) + { + H << retEndArg << " = "; + } + H << "__proxy->end_" << p->name() << spar << outEndArgs << "__result" << epar << ';'; + } + else + { + H << "__proxy->___end_" << p->name() << spar << outEndArgs; + if(ret) + { + H << retEndArg; + } + H << "__result" << epar << ';'; + } + writeEndCode(H, outParams, p); + H << eb; + H << nl << "catch(::Ice::Exception& ex)"; + H << sb; + H << nl << "Cpp11FnCallbackNC::__exception(__result, ex);"; + H << nl << "return;"; + H << eb; + H << nl << "if(_response != nullptr)"; + H << sb; + H << nl << "_response" << spar; + if(ret) + { + H << "__ret"; + } + H << outParamNamesAMI; + H << epar << ';'; + H << eb; + H << eb; + + H.dec(); + H << nl << nl << "private:"; + H.inc(); + H << nl; + H << nl << "::std::function<void " << spar; + + if(!retInS.empty()) + { + H << retInS; + } + H << outDecls; + + H << epar << "> _response;"; + + H << eb << ';'; + + H << nl << "return begin_" << name << spar << argsAMI << "ctx" << "new Cpp11CB(response, exception, sent)" + << epar << ';'; + H << eb; + H << nl; + H.dec(); + H << nl << "public:"; + H.inc(); + } + + H.zeroIndent(); + H << nl << "#endif"; + H.restoreIndent(); H << sp << nl << "::Ice::AsyncResultPtr begin_" << name << spar << paramsDeclAMI << epar; H << sb; @@ -1921,7 +2160,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) << "const ::Ice::AsyncResultPtr&" << epar << ';'; if(generatePrivateEnd) { - H << sp << nl << "void ___end_" << name << spar << outParamsDeclEndAMI; + H << sp << nl << _dllExport << " void ___end_" << name << spar << outParamsDeclEndAMI; H << "const ::Ice::AsyncResultPtr&" << epar << ';'; } @@ -1938,7 +2177,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) H.dec(); H << nl << "public:"; H.inc(); - + C << sp << nl << retS << nl << "IceProxy" << scoped << spar << paramsDecl << "const ::Ice::Context* __ctx" << epar; C << sb; C << nl << "::IceInternal::InvocationObserver __observer(this, " << p->flattenedScope() << p->name() @@ -3316,27 +3555,37 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p) if(!p->isLocal()) { - H << nl << "virtual ::Ice::ObjectPtr ice_clone() const;"; - C << sp << nl << (_dllExport.empty() ? "" : "ICE_DECLSPEC_EXPORT ") << "::Ice::Object* " << scope.substr(2) << "upCast(" << scoped << "* p) { return p; }"; - C << sp; - C << nl << "::Ice::ObjectPtr"; - C << nl << scoped.substr(2) << "::ice_clone() const"; - C << sb; - if(!p->isAbstract()) - { - C << nl << fixKwd(p->scope()) << p->name() << "Ptr __p = new " << scoped << "(*this);"; - C << nl << "return __p;"; - } - else - { - C << nl << "throw ::Ice::CloneNotImplementedException(__FILE__, __LINE__);"; - C << nl << "return 0; // to avoid a warning with some compilers"; - } - C << eb; + // + // It would make sense to provide a covariant ice_clone(); unfortunately many compilers + // (including VS2010) generate bad code for covariant types that use virtual inheritance + // + + if(!p->isInterface()) + { + H << nl << "virtual ::Ice::ObjectPtr ice_clone() const;"; + + C << nl << "::Ice::ObjectPtr"; + C << nl << scoped.substr(2) << "::ice_clone() const"; + C << sb; + if(!p->isAbstract()) + { + C << nl << "::Ice::Object* __p = new " << name << "(*this);"; + C << nl << "return __p;"; + } + else + { + // + // We need this ice_clone for abstract classes derived from concrete classes + // + C << nl << "throw ::Ice::CloneNotImplementedException(__FILE__, __LINE__);"; + C << nl << "return 0; // to avoid a warning with some compilers"; + } + C << eb; + } ClassList allBases = p->allBases(); StringList ids; @@ -3967,6 +4216,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) ParamDeclList inParams; ParamDeclList outParams; ParamDeclList paramList = p->parameters(); + vector< string> outDecls; for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) { string paramName = fixKwd((*q)->name()); @@ -4008,6 +4258,10 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) argsAMD += paramName; argsAMD += ", "; } + else + { + outDecls.push_back(inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring)); + } } if(!cl->isLocal()) @@ -4198,6 +4452,18 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) outParamsDeclAMI.push_back(typeString + ' ' + paramName); } } + + H.zeroIndent(); + H << nl << "#ifdef ICE_CPP11"; + H.restoreIndent(); + + H << nl << "virtual ::Ice::AsyncResultPtr begin_" << name << spar << paramsDeclAMI + << "const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception" + << "const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()" << epar << " = 0;"; + + H.zeroIndent(); + H << nl << "#endif"; + H.restoreIndent(); H << sp << nl << "virtual ::Ice::AsyncResultPtr begin_" << name << spar << paramsDeclAMI << epar << " = 0;"; @@ -4726,38 +4992,6 @@ Slice::Gen::AsyncCallbackTemplateVisitor::visitClassDefEnd(const ClassDefPtr& p) _useWstring = resetUseWstring(_useWstringHist); } -namespace -{ - -bool -usePrivateEnd(const OperationPtr& p) -{ - TypePtr ret = p->returnType(); - bool retIsOpt = p->returnIsOptional(); - string retSEnd = returnTypeToString(ret, retIsOpt, p->getMetaData(), TypeContextAMIEnd); - string retSPrivateEnd = returnTypeToString(ret, retIsOpt, p->getMetaData(), TypeContextAMIPrivateEnd); - - ParamDeclList outParams; - vector<string> outDeclsEnd; - vector<string> outDeclsPrivateEnd; - - ParamDeclList paramList = p->parameters(); - for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) - { - if((*q)->isOutParam()) - { - outDeclsEnd.push_back(outputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), - TypeContextAMIEnd)); - outDeclsPrivateEnd.push_back(outputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), - TypeContextAMIPrivateEnd)); - } - } - - return retSEnd != retSPrivateEnd || outDeclsEnd != outDeclsPrivateEnd; -} - -} - void Slice::Gen::AsyncCallbackTemplateVisitor::visitOperation(const OperationPtr& p) { diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index a8b82aaa52d..e9d8a211d2d 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -22,7 +22,7 @@ using namespace Slice; namespace { -IceUtil::Mutex* mutex = 0; +IceUtil::Mutex* globalMutex = 0; bool interrupted = false; class Init @@ -31,13 +31,13 @@ public: Init() { - mutex = new IceUtil::Mutex; + globalMutex = new IceUtil::Mutex; } ~Init() { - delete mutex; - mutex = 0; + delete globalMutex; + globalMutex = 0; } }; @@ -48,7 +48,7 @@ Init init; void interruptedCallback(int signal) { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); interrupted = true; } @@ -295,7 +295,7 @@ compile(int argc, char* argv[]) } { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); if(interrupted) { diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp index f636b758a77..a79ea86851e 100644 --- a/cpp/src/slice2cs/Gen.cpp +++ b/cpp/src/slice2cs/Gen.cpp @@ -62,6 +62,24 @@ sliceModeToIceMode(Operation::Mode opMode) } static string +opFormatTypeToString(const OperationPtr& op) +{ + switch(op->format()) + { + case DefaultFormat: + return "Ice.FormatType.DefaultFormat"; + case CompactFormat: + return "Ice.FormatType.CompactFormat"; + case SlicedFormat: + return "Ice.FormatType.SlicedFormat"; + default: + assert(false); + } + + return "???"; +} + +static string getDeprecateReason(const ContainedPtr& p1, const ContainedPtr& p2, const string& type) { string deprecateMetadata, deprecateReason; @@ -97,6 +115,133 @@ Slice::CsVisitor::~CsVisitor() } void +Slice::CsVisitor::writeMarshalDataMember(const DataMemberPtr& member, const string& name) +{ + writeMarshalUnmarshalCode(_out, member->type(), name, true, false, false); + +#if 0 + if(!member->optional()) + { + writeMarshalUnmarshalCode(out, package, member->type(), OptionalNone, false, 0, fixKwd(member->name()), + true, iter, false, member->getMetaData()); + } + else + { + out << nl << "if(__has_" << member->name() << " && __os.writeOpt(" << member->tag() << ", " + << getOptionalType(member->type()) << "))"; + out << sb; + writeMarshalUnmarshalCode(out, package, member->type(), OptionalMember, false, 0, fixKwd(member->name()), true, + iter, false, member->getMetaData()); + out << eb; + } +#endif +} + +void +Slice::CsVisitor::writeUnmarshalDataMember(const DataMemberPtr& member, const string& name, bool needPatcher, + int& patchIter) +{ + string patchParams = "this"; + if(needPatcher) + { + BuiltinPtr builtin = BuiltinPtr::dynamicCast(member->type()); + if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(member->type())) + { + ostringstream ostr; + ostr << ", " << patchIter++; + patchParams += ostr.str(); + } + } + + writeMarshalUnmarshalCode(_out, member->type(), name, false, false, false, patchParams); +#if 0 + if(!member->optional()) + { + writeMarshalUnmarshalCode(out, package, member->type(), OptionalNone, false, 0, fixKwd(member->name()), false, + iter, false, member->getMetaData(), patchParams); + } + else + { + out << nl << "if(__has_" << member->name() << " = __is.readOpt(" << member->tag() << ", " + << getOptionalType(member->type()) << "))"; + out << sb; + writeMarshalUnmarshalCode(out, package, member->type(), OptionalMember, false, 0, fixKwd(member->name()), false, + iter, false, member->getMetaData(), patchParams); + out << eb; + } +#endif +} + +void +Slice::CsVisitor::writeStreamMarshalDataMember(const DataMemberPtr& member, const string& name) +{ + writeMarshalUnmarshalCode(_out, member->type(), name, true, true, false); +#if 0 + if(!member->optional()) + { + writeStreamMarshalUnmarshalCode(out, package, member->type(), false, 0, fixKwd(member->name()), true, + iter, false, member->getMetaData()); + } + else + { + out << nl << "if(__has_" << member->name() << " && __outS.writeOptional(" << member->tag() << ", " + << getOptionalType(member->type()) << "))"; + out << sb; + writeStreamMarshalUnmarshalCode(out, package, member->type(), true, member->tag(), fixKwd(member->name()), + true, iter, false, member->getMetaData()); + out << eb; + } +#endif +} + +void +Slice::CsVisitor::writeStreamUnmarshalDataMember(const DataMemberPtr& member, const string& name, bool needPatcher, + int& patchIter) +{ + string patchParams = "this"; + if(needPatcher) + { + BuiltinPtr builtin = BuiltinPtr::dynamicCast(member->type()); + if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(member->type())) + { + ostringstream ostr; + ostr << ", " << patchIter++; + patchParams += ostr.str(); + } + } + + writeMarshalUnmarshalCode(_out, member->type(), name, false, true, false, patchParams); +#if 0 + string patchParams; + if(needPatcher) + { + BuiltinPtr builtin = BuiltinPtr::dynamicCast(member->type()); + if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(member->type())) + { + ostringstream ostr; + ostr << "new Patcher(" << patchIter++ << ')'; + patchParams = ostr.str(); + } + } + + if(!member->optional()) + { + writeStreamMarshalUnmarshalCode(out, package, member->type(), false, 0, fixKwd(member->name()), false, + iter, false, member->getMetaData(), patchParams); + } + else + { + out << nl << "if(__has_" << member->name() << " = __inS.readOptional(" << member->tag() << ", " + << getOptionalType(member->type()) << "))"; + out << sb; + writeStreamMarshalUnmarshalCode(out, package, member->type(), true, member->tag(), fixKwd(member->name()), + false, iter, false, member->getMetaData(), patchParams); + out << eb; + } +#endif +} + +void Slice::CsVisitor::writeInheritedOperations(const ClassDefPtr& p) { ClassList bases = p->bases(); @@ -445,7 +590,8 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream) // if(!outParams.empty() || ret) { - _out << nl << "IceInternal.BasicStream os__ = inS__.startWriteParams__();"; + _out << nl << "IceInternal.BasicStream os__ = inS__.startWriteParams__(" + << opFormatTypeToString(op) << ");"; for(q = outParams.begin(); q != outParams.end(); ++q) { writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, true, ""); @@ -478,8 +624,7 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream) string exS = fixId((*t)->scoped()); _out << nl << "catch(" << exS << " ex__)"; _out << sb; - _out << nl << "inS__.startWriteParams__().writeUserException(ex__);"; - _out << nl << "inS__.endWriteParams__(false);"; + _out << nl << "inS__.writeUserException__(ex__, " << opFormatTypeToString(op) << ");"; _out << nl << "return Ice.DispatchStatus.DispatchUserException;"; _out << eb; } @@ -716,6 +861,9 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream) DataMemberList::const_iterator d; DataMemberList members = p->dataMembers(); DataMemberList classMembers = p->classDataMembers(); + const bool basePreserved = p->inheritsMetaData("preserve-slice"); + const bool preserved = basePreserved || p->hasMetaData("preserve-slice"); + ClassList bases = p->bases(); ClassDefPtr base; if(!bases.empty() && !bases.front()->isInterface()) @@ -732,15 +880,35 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream) } _out << nl << "public override void write__(IceInternal.BasicStream os__)"; _out << sb; - _out << nl << "os__.writeTypeId(ice_staticId());"; - _out << nl << "os__.startWriteSlice();"; + if(preserved) + { + _out << nl << "os__.startWriteObject(slicedData__);"; + } + else + { + _out << nl << "os__.startWriteObject(null);"; + } + _out << nl << "writeImpl__(os__);"; + _out << nl << "os__.endWriteObject();"; + _out << eb; + + _out << sp; + if(!p->isInterface()) + { + emitGeneratedCodeAttribute(); + } + _out << nl << "public override void writeImpl__(IceInternal.BasicStream os__)"; + _out << sb; + _out << nl << "os__.startWriteSlice(ice_staticId(), " << (!base ? "true" : "false") << ");"; for(d = members.begin(); d != members.end(); ++d) { - writeMarshalUnmarshalCode(_out, (*d)->type(), fixId(*d, DotNet::ICloneable, true), - true, false, false); + writeMarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true)); } _out << nl << "os__.endWriteSlice();"; - _out << nl << "base.write__(os__);"; + if(base) + { + _out << nl << "base.writeImpl__(os__);"; + } _out << eb; if(allClassMembers.size() != 0) @@ -826,31 +994,39 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream) { emitGeneratedCodeAttribute(); } - _out << nl << "public override void read__(IceInternal.BasicStream is__, bool rid__)"; - _out << sb; - _out << nl << "if(rid__)"; + _out << nl << "public override void read__(IceInternal.BasicStream is__)"; _out << sb; - _out << nl << "/* string myId = */ is__.readTypeId();"; + _out << nl << "is__.startReadObject();"; + _out << nl << "readImpl__(is__);"; + if(preserved) + { + _out << nl << "slicedData__ = is__.endReadObject(true);"; + } + else + { + _out << nl << "is__.endReadObject(false);"; + } _out << eb; + + _out << sp; + if(!p->isInterface()) + { + emitGeneratedCodeAttribute(); + } + _out << nl << "public override void readImpl__(IceInternal.BasicStream is__)"; + _out << sb; _out << nl << "is__.startReadSlice();"; int classMemberCount = static_cast<int>(allClassMembers.size() - classMembers.size()); + const bool needCustomPatcher = classMembers.size() > 1 || allClassMembers.size() > 1; for(d = members.begin(); d != members.end(); ++d) { - ostringstream patchParams; - patchParams << "this"; - BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type()); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*d)->type())) - { - if(classMembers.size() > 1 || allClassMembers.size() > 1) - { - patchParams << ", " << classMemberCount++; - } - } - writeMarshalUnmarshalCode(_out, (*d)->type(), fixId(*d, DotNet::ICloneable, true), - false, false, false, patchParams.str()); + writeUnmarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true), needCustomPatcher, classMemberCount); } _out << nl << "is__.endReadSlice();"; - _out << nl << "base.read__(is__, true);"; + if(base) + { + _out << nl << "base.readImpl__(is__);"; + } _out << eb; // @@ -865,15 +1041,35 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream) } _out << nl << "public override void write__(Ice.OutputStream outS__)"; _out << sb; - _out << nl << "outS__.writeTypeId(ice_staticId());"; - _out << nl << "outS__.startSlice();"; + if(preserved) + { + _out << nl << "outS__.startObject(slicedData__);"; + } + else + { + _out << nl << "outS__.startObject(null);"; + } + _out << nl << "writeImpl__(outS__);"; + _out << nl << "outS__.endObject();"; + _out << eb; + + _out << sp; + if(!p->isInterface()) + { + emitGeneratedCodeAttribute(); + } + _out << nl << "public " << (base ? "override" : "virtual") << " void writeImpl__(Ice.OutputStream outS__)"; + _out << sb; + _out << nl << "outS__.startSlice(ice_staticId(), " << (!base ? "true" : "false") << ");"; for(d = members.begin(); d != members.end(); ++d) { - writeMarshalUnmarshalCode(_out, (*d)->type(), fixId(*d, DotNet::ICloneable, true), - true, true, false); + writeStreamMarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true)); } _out << nl << "outS__.endSlice();"; - _out << nl << "base.write__(outS__);"; + if(base) + { + _out << nl << "base.writeImpl__(outS__);"; + } _out << eb; _out << sp; @@ -881,30 +1077,39 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream) { emitGeneratedCodeAttribute(); } - _out << nl << "public override void read__(Ice.InputStream inS__, bool rid__)"; + _out << nl << "public override void read__(Ice.InputStream inS__)"; _out << sb; - _out << nl << "if(rid__)"; - _out << sb; - _out << nl << "/* string myId = */ inS__.readTypeId();"; + _out << nl << "inS__.startObject();"; + _out << nl << "readImpl__(inS__);"; + if(preserved) + { + _out << nl << "slicedData__ = inS__.endObject(true);"; + } + else + { + _out << nl << "inS__.endObject(false);"; + } _out << eb; + + _out << sp; + if(!p->isInterface()) + { + emitGeneratedCodeAttribute(); + } + _out << nl << "public " << (base ? "override" : "virtual") << " void readImpl__(Ice.InputStream inS__)"; + _out << sb; _out << nl << "inS__.startSlice();"; + classMemberCount = static_cast<int>(allClassMembers.size() - classMembers.size()); for(d = members.begin(); d != members.end(); ++d) { - ostringstream patchParams; - patchParams << "this"; - BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type()); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*d)->type())) - { - if(classMembers.size() > 1 || allClassMembers.size() > 1) - { - patchParams << ", " << classMemberCount++; - } - } - writeMarshalUnmarshalCode(_out, (*d)->type(), fixId(*d, DotNet::ICloneable, true), - false, true, false, patchParams.str()); + writeStreamUnmarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true), needCustomPatcher, + classMemberCount); } _out << nl << "inS__.endSlice();"; - _out << nl << "base.read__(inS__, true);"; + if(base) + { + _out << nl << "base.readImpl__(inS__);"; + } _out << eb; } else @@ -930,7 +1135,7 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream) { emitGeneratedCodeAttribute(); } - _out << nl << "public override void read__(Ice.InputStream inS__, bool rid__)"; + _out << nl << "public override void read__(Ice.InputStream inS__)"; _out << sb; _out << nl << "Ice.MarshalException ex = new Ice.MarshalException();"; _out << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\";"; @@ -938,6 +1143,11 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream) _out << eb; } + if(preserved && !basePreserved) + { + _out << sp << nl << "protected Ice.SlicedData slicedData__;"; + } + _out << sp << nl << "#endregion"; // Marshalling support } @@ -2844,8 +3054,9 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) } else { - _out << nl << "int h__ = 0;"; + _out << nl << "int h__ = 5381;"; } + _out << nl << "IceInternal.HashUtil.hashAdd(ref h__, \"" << p->scoped() << "\");"; writeMemberHashCode(dataMembers, DotNet::Exception); _out << nl << "return h__;"; _out << eb; @@ -2905,21 +3116,38 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) string scoped = p->scoped(); ExceptionPtr base = p->base(); + const bool basePreserved = p->inheritsMetaData("preserve-slice"); + const bool preserved = basePreserved || p->hasMetaData("preserve-slice"); + _out << sp; emitGeneratedCodeAttribute(); _out << nl << "public override void write__(IceInternal.BasicStream os__)"; _out << sb; - _out << nl << "os__.writeString(\"" << scoped << "\");"; - _out << nl << "os__.startWriteSlice();"; + if(preserved) + { + _out << nl << "os__.startWriteException(slicedData__);"; + } + else + { + _out << nl << "os__.startWriteException(null);"; + } + _out << nl << "writeImpl__(os__);"; + _out << nl << "os__.endWriteException();"; + _out << eb; + + _out << sp; + emitGeneratedCodeAttribute(); + _out << nl << "public override void writeImpl__(IceInternal.BasicStream os__)"; + _out << sb; + _out << nl << "os__.startWriteSlice(\"" << scoped << "\", " << (!base ? "true" : "false") << ");"; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name(), DotNet::Exception), - true, false, false); + writeMarshalDataMember(*q, fixId((*q)->name(), DotNet::Exception)); } _out << nl << "os__.endWriteSlice();"; if(base) { - _out << nl << "base.write__(os__);"; + _out << nl << "base.writeImpl__(os__);"; } _out << eb; @@ -3001,34 +3229,36 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public override void read__(IceInternal.BasicStream is__, bool rid__)"; - _out << sb; - _out << nl << "if(rid__)"; + _out << nl << "public override void read__(IceInternal.BasicStream is__)"; _out << sb; - _out << nl << "/* string myId = */ is__.readString();"; + _out << nl << "is__.startReadException();"; + _out << nl << "readImpl__(is__);"; + if(preserved) + { + _out << nl << "slicedData__ = is__.endReadException(true);"; + } + else + { + _out << nl << "is__.endReadException(false);"; + } _out << eb; + + _out << sp; + emitGeneratedCodeAttribute(); + _out << nl << "public override void readImpl__(IceInternal.BasicStream is__)"; + _out << sb; _out << nl << "is__.startReadSlice();"; DataMemberList classMembers = p->classDataMembers(); int classMemberCount = static_cast<int>(allClassMembers.size() - classMembers.size()); + const bool needCustomPatcher = classMembers.size() > 1 || allClassMembers.size() > 1; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - ostringstream patchParams; - patchParams << "this"; - BuiltinPtr builtin = BuiltinPtr::dynamicCast((*q)->type()); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*q)->type())) - { - if(classMembers.size() > 1 || allClassMembers.size() > 1) - { - patchParams << ", " << classMemberCount++; - } - } - writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name(), DotNet::Exception), - false, false, false, patchParams.str()); + writeUnmarshalDataMember(*q, fixId((*q)->name(), DotNet::Exception), needCustomPatcher, classMemberCount); } _out << nl << "is__.endReadSlice();"; if(base) { - _out << nl << "base.read__(is__, true);"; + _out << nl << "base.readImpl__(is__);"; } _out << eb; @@ -3038,49 +3268,65 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) emitGeneratedCodeAttribute(); _out << nl << "public override void write__(Ice.OutputStream outS__)"; _out << sb; - _out << nl << "outS__.writeString(\"" << scoped << "\");"; - _out << nl << "outS__.startSlice();"; + if(preserved) + { + _out << nl << "outS__.startException(slicedData__);"; + } + else + { + _out << nl << "outS__.startException(null);"; + } + _out << nl << "writeImpl__(outS__);"; + _out << nl << "outS__.endException();"; + _out << eb; + + _out << sp; + emitGeneratedCodeAttribute(); + _out << nl << "public " << (base ? "override" : "virtual") << " void writeImpl__(Ice.OutputStream outS__)"; + _out << sb; + _out << nl << "outS__.startSlice(\"" << scoped << "\", " << (!base ? "true" : "false") << ");"; for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name(), DotNet::Exception), - true, true, false); + writeStreamMarshalDataMember(*q, fixId((*q)->name(), DotNet::Exception)); } _out << nl << "outS__.endSlice();"; if(base) { - _out << nl << "base.write__(outS__);"; + _out << nl << "base.writeImpl__(outS__);"; } _out << eb; _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public override void read__(Ice.InputStream inS__, bool rid__)"; - _out << sb; - _out << nl << "if(rid__)"; + _out << nl << "public override void read__(Ice.InputStream inS__)"; _out << sb; - _out << nl << "/* string myId = */ inS__.readString();"; + _out << nl << "inS__.startException();"; + _out << nl << "readImpl__(inS__);"; + if(preserved) + { + _out << nl << "slicedData__ = inS__.endException(true);"; + } + else + { + _out << nl << "inS__.endException(false);"; + } _out << eb; + + _out << sp; + emitGeneratedCodeAttribute(); + _out << nl << "public " << (base ? "override" : "virtual") << " void readImpl__(Ice.InputStream inS__)"; + _out << sb; _out << nl << "inS__.startSlice();"; classMemberCount = static_cast<int>(allClassMembers.size() - classMembers.size()); for(q = dataMembers.begin(); q != dataMembers.end(); ++q) { - ostringstream patchParams; - patchParams << "this"; - BuiltinPtr builtin = BuiltinPtr::dynamicCast((*q)->type()); - if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*q)->type())) - { - if(classMembers.size() > 1 || allClassMembers.size() > 1) - { - patchParams << ", " << classMemberCount++; - } - } - writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name(), DotNet::Exception), - false, true, false, patchParams.str()); + writeStreamUnmarshalDataMember(*q, fixId((*q)->name(), DotNet::Exception), needCustomPatcher, + classMemberCount); } _out << nl << "inS__.endSlice();"; if(base) { - _out << nl << "base.read__(inS__, true);"; + _out << nl << "base.readImpl__(inS__);"; } _out << eb; } @@ -3100,7 +3346,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) _out << sp; emitGeneratedCodeAttribute(); - _out << nl << "public override void read__(Ice.InputStream inS__, bool rid__)"; + _out << nl << "public override void read__(Ice.InputStream inS__)"; _out << sb; _out << nl << "Ice.MarshalException ex = new Ice.MarshalException();"; _out << nl << "ex.reason = \"exception " << scoped.substr(2) << " was not generated with stream support\";"; @@ -3108,14 +3354,9 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p) _out << eb; } - if((!base || (base && !base->usesClasses())) && p->usesClasses()) + if(preserved && !basePreserved) { - _out << sp; - emitGeneratedCodeAttribute(); - _out << nl << "public override bool usesClasses__()"; - _out << sb; - _out << nl << "return true;"; - _out << eb; + _out << sp << nl << "protected Ice.SlicedData slicedData__;"; } _out << sp << nl << "#endregion"; // Marshalling support @@ -3252,7 +3493,8 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) emitGeneratedCodeAttribute(); _out << nl << "public override int GetHashCode()"; _out << sb; - _out << nl << "int h__ = 0;"; + _out << nl << "int h__ = 5381;"; + _out << nl << "IceInternal.HashUtil.hashAdd(ref h__, \"" << p->scoped() << "\");"; writeMemberHashCode(dataMembers, isClass ? DotNet::ICloneable : 0); _out << nl << "return h__;"; _out << eb; @@ -3678,73 +3920,7 @@ Slice::Gen::TypesVisitor::writeMemberHashCode(const DataMemberList& dataMembers, { for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q) { - string memberName = fixId((*q)->name(), baseTypes); - TypePtr memberType = (*q)->type(); - bool isValue = isValueType(memberType); - if(!isValue) - { - _out << nl << "if(" << memberName << " != null)"; - _out << sb; - } - SequencePtr seq = SequencePtr::dynamicCast(memberType); - if(seq) - { - string meta; - bool isSerializable = seq->findMetaData("clr:serializable", meta); - bool isGeneric = seq->findMetaData("clr:generic:", meta); - bool isArray = !isSerializable && !isGeneric && !seq->hasMetaData("clr:collection"); - if(isArray) - { - // - // GetHashCode() for native arrays does not have value semantics. - // - _out << nl << "h__ = 5 * h__ + IceUtilInternal.Arrays.GetHashCode(" << memberName << ");"; - } - else if(isGeneric) - { - // - // GetHashCode() for generic types does not have value semantics. - // - _out << nl << "h__ = 5 * h__ + IceUtilInternal.Collections.SequenceGetHashCode(" << memberName << ");"; - } - else - { - // - // GetHashCode() for CollectionBase has value semantics. - // - _out << nl << "h__ = 5 * h__ + " << memberName << ".GetHashCode();"; - } - } - else - { - DictionaryPtr dict = DictionaryPtr::dynamicCast(memberType); - if(dict) - { - if(dict->hasMetaData("clr:collection")) - { - // - // GetHashCode() for DictionaryBase has value semantics. - // - _out << nl << "h__ = 5 * h__ + " << memberName << ".GetHashCode();"; - } - else - { - // - // GetHashCode() for generic types does not have value semantics. - // - _out << nl << "h__ = 5 * h__ + IceUtilInternal.Collections.DictionaryGetHashCode(" << memberName - << ");"; - } - } - else - { - _out << nl << "h__ = 5 * h__ + " << memberName << ".GetHashCode();"; - } - } - if(!isValue) - { - _out << eb; - } + _out << nl << "IceInternal.HashUtil.hashAdd(ref h__, " << fixId((*q)->name(), baseTypes) << ");"; } } @@ -4598,7 +4774,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p) << sliceModeToIceMode(op->sendMode()) << ", ctx__, explicitContext__);"; if(!inParams.empty()) { - _out << nl << "IceInternal.BasicStream os__ = result__.startWriteParams__();"; + _out << nl << "IceInternal.BasicStream os__ = result__.startWriteParams__(" + << opFormatTypeToString(op) << ");"; for(q = inParams.begin(); q != inParams.end(); ++q) { string typeS = typeToString(q->first); @@ -5478,7 +5655,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p) { _out << nl << "try"; _out << sb; - _out << nl << "IceInternal.BasicStream os__ = og__.startWriteParams();"; + _out << nl << "IceInternal.BasicStream os__ = og__.startWriteParams(" << opFormatTypeToString(op) << ");"; for(q = inParams.begin(); q != inParams.end(); ++q) { writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, false); @@ -6110,7 +6287,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) { _out << nl << "try"; _out << sb; - _out << nl << "IceInternal.BasicStream os__ = startWriteParams__();"; + _out << nl << "IceInternal.BasicStream os__ = startWriteParams__(" << opFormatTypeToString(p) << ");"; for(q = outParams.begin(); q != outParams.end(); ++q) { string typeS = typeToString(q->first); @@ -6156,8 +6333,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p) _out << sb; _out << nl << "if(validateResponse__(false))"; _out << sb; - _out << nl << "startWriteParams__().writeUserException(ex__);"; - _out << nl << "endWriteParams__(false);"; + _out << nl << "writeUserException__(ex__, " << opFormatTypeToString(p) << ");"; _out << nl << "response__();"; _out << eb; _out << eb; diff --git a/cpp/src/slice2cs/Gen.h b/cpp/src/slice2cs/Gen.h index bec13760eaf..2c171a71e25 100644 --- a/cpp/src/slice2cs/Gen.h +++ b/cpp/src/slice2cs/Gen.h @@ -24,6 +24,11 @@ public: protected: + void writeMarshalDataMember(const DataMemberPtr&, const std::string&); + void writeUnmarshalDataMember(const DataMemberPtr&, const std::string&, bool, int&); + void writeStreamMarshalDataMember(const DataMemberPtr&, const std::string&); + void writeStreamUnmarshalDataMember(const DataMemberPtr&, const std::string&, bool, int&); + virtual void writeInheritedOperations(const ClassDefPtr&); virtual void writeDispatchAndMarshalling(const ClassDefPtr&, bool); virtual std::vector<std::string> getParams(const OperationPtr&); diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp index 4ebc975b0f8..8539e303244 100644 --- a/cpp/src/slice2cs/Main.cpp +++ b/cpp/src/slice2cs/Main.cpp @@ -22,7 +22,7 @@ using namespace Slice; namespace { -IceUtil::Mutex* mutex = 0; +IceUtil::Mutex* globalMutex = 0; bool interrupted = false; class Init @@ -31,13 +31,13 @@ public: Init() { - mutex = new IceUtil::Mutex; + globalMutex = new IceUtil::Mutex; } ~Init() { - delete mutex; - mutex = 0; + delete globalMutex; + globalMutex = 0; } }; @@ -48,7 +48,7 @@ Init init; void interruptedCallback(int signal) { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); interrupted = true; } @@ -303,7 +303,7 @@ compile(int argc, char* argv[]) } { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); if(interrupted) { diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp index 9cf0e4477e3..2d2020f10a2 100644 --- a/cpp/src/slice2freeze/Main.cpp +++ b/cpp/src/slice2freeze/Main.cpp @@ -28,7 +28,7 @@ using namespace Slice; namespace { -IceUtil::Mutex* mutex = 0; +IceUtil::Mutex* globalMutex = 0; bool interrupted = false; class Init @@ -37,13 +37,13 @@ public: Init() { - mutex = new IceUtil::Mutex; + globalMutex = new IceUtil::Mutex; } ~Init() { - delete mutex; - mutex = 0; + delete globalMutex; + globalMutex = 0; } }; @@ -56,7 +56,7 @@ string ICE_ENCODING_COMPARE = "Freeze::IceEncodingCompare"; void interruptedCallback(int signal) { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); interrupted = true; } @@ -1999,7 +1999,7 @@ compile(int argc, char* argv[]) } { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); if(interrupted) { @@ -2046,7 +2046,7 @@ compile(int argc, char* argv[]) u->destroy(); { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); if(interrupted) { diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp index 9f85a9f5536..a08642d2650 100755 --- a/cpp/src/slice2freezej/Main.cpp +++ b/cpp/src/slice2freezej/Main.cpp @@ -26,7 +26,7 @@ using namespace IceUtilInternal; namespace { -IceUtil::Mutex* mutex = 0; +IceUtil::Mutex* globalMutex = 0; bool interrupted = false; class Init @@ -35,13 +35,13 @@ public: Init() { - mutex = new IceUtil::Mutex; + globalMutex = new IceUtil::Mutex; } ~Init() { - delete mutex; - mutex = 0; + delete globalMutex; + globalMutex = 0; } }; @@ -52,7 +52,7 @@ Init init; void interruptedCallback(int signal) { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(globalMutex); interrupted = true; } @@ -1841,7 +1841,7 @@ compile(int argc, char* argv[]) } { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); if(interrupted) { @@ -1941,7 +1941,7 @@ compile(int argc, char* argv[]) u->destroy(); { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); if(interrupted) { diff --git a/cpp/src/slice2html/Main.cpp b/cpp/src/slice2html/Main.cpp index 26caf348009..861cbafb0bb 100755 --- a/cpp/src/slice2html/Main.cpp +++ b/cpp/src/slice2html/Main.cpp @@ -24,7 +24,7 @@ using namespace IceUtil; namespace { -IceUtil::Mutex* mutex = 0; +IceUtil::Mutex* globalMutex = 0; bool interrupted = false; class Init @@ -33,13 +33,13 @@ public: Init() { - mutex = new IceUtil::Mutex; + globalMutex = new IceUtil::Mutex; } ~Init() { - delete mutex; - mutex = 0; + delete globalMutex; + globalMutex = 0; } }; @@ -50,7 +50,7 @@ Init init; void interruptedCallback(int signal) { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); interrupted = true; } @@ -254,7 +254,7 @@ compile(int argc, char* argv[]) } { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); if(interrupted) { @@ -296,7 +296,7 @@ compile(int argc, char* argv[]) p->destroy(); { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); if(interrupted) { diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp index 3f0c23c2aca..1a9b678b6aa 100644 --- a/cpp/src/slice2java/Gen.cpp +++ b/cpp/src/slice2java/Gen.cpp @@ -465,110 +465,6 @@ Slice::JavaVisitor::writeDelegateThrowsClause(const string& package, const Excep } void -Slice::JavaVisitor::writeHashCode(Output& out, const TypePtr& type, const string& name, int& iter, - const StringList& metaData) -{ - BuiltinPtr builtin = BuiltinPtr::dynamicCast(type); - if(builtin) - { - switch(builtin->kind()) - { - case Builtin::KindByte: - case Builtin::KindShort: - case Builtin::KindLong: - { - out << nl << "__h = 5 * __h + (int)" << name << ';'; - break; - } - case Builtin::KindBool: - { - out << nl << "__h = 5 * __h + (" << name << " ? 1 : 0);"; - break; - } - case Builtin::KindInt: - { - out << nl << "__h = 5 * __h + " << name << ';'; - break; - } - case Builtin::KindFloat: - { - out << nl << "__h = 5 * __h + java.lang.Float.floatToIntBits(" << name << ");"; - break; - } - case Builtin::KindDouble: - { - out << nl << "__h = 5 * __h + (int)java.lang.Double.doubleToLongBits(" << name << ");"; - break; - } - case Builtin::KindString: - { - out << nl << "if(" << name << " != null)"; - out << sb; - out << nl << "__h = 5 * __h + " << name << ".hashCode();"; - out << eb; - break; - } - case Builtin::KindObject: - case Builtin::KindObjectProxy: - case Builtin::KindLocalObject: - { - out << nl << "if(" << name << " != null)"; - out << sb; - out << nl << "__h = 5 * __h + " << name << ".hashCode();"; - out << eb; - break; - } - } - return; - } - - ProxyPtr prx = ProxyPtr::dynamicCast(type); - ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type); - DictionaryPtr dict = DictionaryPtr::dynamicCast(type); - if(prx || cl || dict) - { - out << nl << "if(" << name << " != null)"; - out << sb; - out << nl << "__h = 5 * __h + " << name << ".hashCode();"; - out << eb; - return; - } - - SequencePtr seq = SequencePtr::dynamicCast(type); - if(seq) - { - bool customType = hasTypeMetaData(seq, metaData); - - out << nl << "if(" << name << " != null)"; - out << sb; - if(customType) - { - out << nl << "__h = 5 * __h + " << name << ".hashCode();"; - } - else - { - out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < " << name << ".length; __i" << iter - << "++)"; - out << sb; - ostringstream elem; - elem << name << "[__i" << iter << ']'; - iter++; - writeHashCode(out, seq->type(), elem.str(), iter); - out << eb; - } - out << eb; - return; - } - - ConstructedPtr constructed = ConstructedPtr::dynamicCast(type); - assert(constructed); - out << nl << "if(" << name << " != null)"; - out << sb; - out << nl << "__h = 5 * __h + " << name << ".hashCode();"; - out << eb; -} - -void Slice::JavaVisitor::writeMarshalDataMember(Output& out, const string& package, const DataMemberPtr& member, int& iter) { if(!member->optional()) @@ -2528,14 +2424,6 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p) if(p->isLocal()) { - out << sp << nl << "/**"; - out << nl << " * @deprecated This method is deprecated, use hashCode instead."; - out << nl << " **/"; - out << nl << "public int" << nl << "ice_hash()"; - out << sb; - out << nl << "return hashCode();"; - out << eb; - out << sp << nl << "public java.lang.Object" << nl << "clone()"; out.inc(); out << nl << "throws java.lang.CloneNotSupportedException"; @@ -3772,13 +3660,13 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p) out << sp << nl << "public int" << nl << "hashCode()"; out << sb; - out << nl << "int __h = 0;"; + out << nl << "int __h = 5381;"; + out << nl << "__h = IceInternal.HashUtil.hashAdd(__h, \"" << p->scoped() << "\");"; iter = 0; for(d = members.begin(); d != members.end(); ++d) { string memberName = fixKwd((*d)->name()); - StringList metaData = (*d)->getMetaData(); - writeHashCode(out, (*d)->type(), memberName, iter, metaData); + out << nl << "__h = IceInternal.HashUtil.hashAdd(__h, " << memberName << ");"; } out << nl << "return __h;"; out << eb; diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp index 6ced6400644..02e92a9bd6b 100644 --- a/cpp/src/slice2java/Main.cpp +++ b/cpp/src/slice2java/Main.cpp @@ -23,7 +23,7 @@ using namespace Slice; namespace { -IceUtil::Mutex* mutex = 0; +IceUtil::Mutex* globalMutex = 0; bool interrupted = false; class Init @@ -32,13 +32,13 @@ public: Init() { - mutex = new IceUtil::Mutex; + globalMutex = new IceUtil::Mutex; } ~Init() { - delete mutex; - mutex = 0; + delete globalMutex; + globalMutex = 0; } }; @@ -49,7 +49,7 @@ Init init; void interruptedCallback(int signal) { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); interrupted = true; } @@ -356,7 +356,7 @@ compile(int argc, char* argv[]) } { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); if(interrupted) { diff --git a/cpp/src/slice2php/Main.cpp b/cpp/src/slice2php/Main.cpp index a30a16eca2d..4a566ffb7c0 100644 --- a/cpp/src/slice2php/Main.cpp +++ b/cpp/src/slice2php/Main.cpp @@ -1491,7 +1491,7 @@ printHeader(IceUtilInternal::Output& out) namespace { -IceUtil::Mutex* mutex = 0; +IceUtil::Mutex* globalMutex = 0; bool interrupted = false; class Init @@ -1500,13 +1500,13 @@ public: Init() { - mutex = new IceUtil::Mutex; + globalMutex = new IceUtil::Mutex; } ~Init() { - delete mutex; - mutex = 0; + delete globalMutex; + globalMutex = 0; } }; @@ -1517,7 +1517,7 @@ Init init; static void interruptedCallback(int signal) { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); interrupted = true; } @@ -1780,7 +1780,7 @@ compile(int argc, char* argv[]) } { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); if(interrupted) { diff --git a/cpp/src/slice2py/Main.cpp b/cpp/src/slice2py/Main.cpp index 08e947d3ecb..dee21f342b1 100644 --- a/cpp/src/slice2py/Main.cpp +++ b/cpp/src/slice2py/Main.cpp @@ -40,7 +40,7 @@ using namespace Slice::Python; namespace { -IceUtil::Mutex* mutex = 0; +IceUtil::Mutex* globalMutex = 0; bool interrupted = false; class Init @@ -49,13 +49,13 @@ public: Init() { - mutex = new IceUtil::Mutex; + globalMutex = new IceUtil::Mutex; } ~Init() { - delete mutex; - mutex = 0; + delete globalMutex; + globalMutex = 0; } }; @@ -66,7 +66,7 @@ Init init; void interruptedCallback(int signal) { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); interrupted = true; } @@ -631,7 +631,7 @@ compile(int argc, char* argv[]) } { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); if(interrupted) { diff --git a/cpp/src/slice2rb/Main.cpp b/cpp/src/slice2rb/Main.cpp index 9afaffeaf73..0f899485d02 100644 --- a/cpp/src/slice2rb/Main.cpp +++ b/cpp/src/slice2rb/Main.cpp @@ -23,11 +23,9 @@ #include <sys/stat.h> #ifdef _WIN32 -#include <direct.h> -#endif - -#ifndef _WIN32 -#include <unistd.h> +# include <direct.h> +#else +# include <unistd.h> #endif #include <string.h> @@ -39,7 +37,7 @@ using namespace Slice::Ruby; namespace { -IceUtil::Mutex* mutex = 0; +IceUtil::Mutex* globalMutex = 0; bool interrupted = false; class Init @@ -48,13 +46,13 @@ public: Init() { - mutex = new IceUtil::Mutex; + globalMutex = new IceUtil::Mutex; } ~Init() { - delete mutex; - mutex = 0; + delete globalMutex; + globalMutex = 0; } }; @@ -65,7 +63,7 @@ Init init; void interruptedCallback(int signal) { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); interrupted = true; } @@ -316,7 +314,7 @@ compile(int argc, char* argv[]) } { - IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex); + IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex); if(interrupted) { diff --git a/cpp/test/Freeze/evictor/Client.cpp b/cpp/test/Freeze/evictor/Client.cpp index f397f368cc3..433636aad25 100644 --- a/cpp/test/Freeze/evictor/Client.cpp +++ b/cpp/test/Freeze/evictor/Client.cpp @@ -608,7 +608,18 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator, bool trans { } - + // + // Call an operation that does not exist on the servant + // + try + { + int balance = Test::AccountPrx::uncheckedCast(servants[0])->getBalance(); + test(false); + } + catch(const Ice::OperationNotExistException&) + { + } + // // Remove all facets // diff --git a/cpp/test/Freeze/evictor/Test.ice b/cpp/test/Freeze/evictor/Test.ice index bd92465393a..b0777202501 100644 --- a/cpp/test/Freeze/evictor/Test.ice +++ b/cpp/test/Freeze/evictor/Test.ice @@ -62,7 +62,7 @@ sequence<Ice::Identity> AccountIdSeq; idempotent void setValue(int value); - ["ami", "amd"] void setValueAsync(int value); + ["amd"] void setValueAsync(int value); ["freeze:read", "cpp:const"] void releaseAsync(); ["freeze:read", "cpp:const"] void addFacet(string name, string data) throws AlreadyRegisteredException; diff --git a/cpp/test/Freeze/evictor/TestI.cpp b/cpp/test/Freeze/evictor/TestI.cpp index 6e5c65589fa..6d7c552079c 100644 --- a/cpp/test/Freeze/evictor/TestI.cpp +++ b/cpp/test/Freeze/evictor/TestI.cpp @@ -88,7 +88,7 @@ public: void exception(const Ice::UserException& e) { Lock sync(*this); - _exception.reset(dynamic_cast<Ice::UserException*>(e.ice_clone())); + _exception.reset(e.ice_clone()); notify(); } diff --git a/cpp/test/Glacier2/override/Callback.ice b/cpp/test/Glacier2/override/Callback.ice index 28feafb3643..fd2e0ea8ce4 100644 --- a/cpp/test/Glacier2/override/Callback.ice +++ b/cpp/test/Glacier2/override/Callback.ice @@ -16,9 +16,9 @@ module Test interface CallbackReceiver { - ["ami"] void callback(int token); + void callback(int token); - ["ami"] void callbackWithPayload(Ice::ByteSeq payload); + void callbackWithPayload(Ice::ByteSeq payload); }; interface Callback diff --git a/cpp/test/Glacier2/router/Callback.ice b/cpp/test/Glacier2/router/Callback.ice index 14305af27ca..576858984ce 100644 --- a/cpp/test/Glacier2/router/Callback.ice +++ b/cpp/test/Glacier2/router/Callback.ice @@ -22,16 +22,16 @@ exception CallbackException interface CallbackReceiver { - ["ami"] void callback(); + void callback(); - ["ami"] void callbackEx() + void callbackEx() throws CallbackException; - ["amd", "ami"] int concurrentCallback(int number); + ["amd"] int concurrentCallback(int number); - ["ami"] void waitCallback(); + void waitCallback(); - ["ami"] void callbackWithPayload(Ice::ByteSeq payload); + void callbackWithPayload(Ice::ByteSeq payload); }; interface Callback @@ -41,7 +41,7 @@ interface Callback ["amd"] void initiateCallbackEx(CallbackReceiver* proxy) throws CallbackException; - ["amd", "ami"] int initiateConcurrentCallback(int number, CallbackReceiver* proxy); + ["amd"] int initiateConcurrentCallback(int number, CallbackReceiver* proxy); ["amd"] void initiateWaitCallback(CallbackReceiver* proxy); diff --git a/cpp/test/Glacier2/sessionControl/SessionI.cpp b/cpp/test/Glacier2/sessionControl/SessionI.cpp index 86d274e100e..51554382c48 100644 --- a/cpp/test/Glacier2/sessionControl/SessionI.cpp +++ b/cpp/test/Glacier2/sessionControl/SessionI.cpp @@ -14,7 +14,7 @@ using namespace std; using namespace Test; -class DestroyCB : public Glacier2::AMI_SessionControl_destroy +class DestroyCB : virtual public IceUtil::Shared { public: @@ -23,13 +23,13 @@ public: } void - ice_response() + response() { _cb->ice_response(); } void - ice_exception(const IceUtil::Exception&) + exception(const IceUtil::Exception&) { test(false); } @@ -39,6 +39,8 @@ private: Test::AMD_Session_destroyFromClientPtr _cb; }; +typedef IceUtil::Handle<DestroyCB> DestroyCBPtr; + Glacier2::SessionPrx SessionManagerI::create(const string& userId, const Glacier2::SessionControlPrx& sessionControl, const Ice::Current& current) @@ -63,7 +65,11 @@ SessionI::SessionI(const Glacier2::SessionControlPrx& sessionControl) : void SessionI::destroyFromClient_async(const Test::AMD_Session_destroyFromClientPtr& cb, const Ice::Current& current) { - _sessionControl->destroy_async(new DestroyCB(cb)); + DestroyCBPtr asyncCB = new DestroyCB(cb); + Glacier2::Callback_SessionControl_destroyPtr amiCB = Glacier2::newCallback_SessionControl_destroy(asyncCB, + &DestroyCB::response, + &DestroyCB::exception); + _sessionControl->begin_destroy(amiCB); } void diff --git a/cpp/test/Ice/Makefile b/cpp/test/Ice/Makefile index c9f3b3390ec..ea2d27fe5fa 100644 --- a/cpp/test/Ice/Makefile +++ b/cpp/test/Ice/Makefile @@ -24,6 +24,7 @@ SUBDIRS = proxy \ adapterDeactivation \ slicing \ gc \ + hash \ checksum \ stream \ dispatcher \ @@ -41,7 +42,8 @@ SUBDIRS = proxy \ defaultValue \ threadPoolPriority \ invoke \ - properties + properties \ + plugin $(EVERYTHING):: @for subdir in $(SUBDIRS); \ diff --git a/cpp/test/Ice/Makefile.mak b/cpp/test/Ice/Makefile.mak index 12a0b8186de..dfd91c1bda1 100644 --- a/cpp/test/Ice/Makefile.mak +++ b/cpp/test/Ice/Makefile.mak @@ -20,6 +20,7 @@ SUBDIRS = proxy \ objects \
location \
adapterDeactivation \
+ hash \
ami \
invoke \
dispatcher \
@@ -28,7 +29,8 @@ SUBDIRS = proxy \ retry \
timeout \
udp \
- stream \
+ plugin \
+ stream
!if "$(WINRT)" != "yes"
SUBDIRS = $(SUBDIRS) \
diff --git a/cpp/test/Ice/ami/AllTests.cpp b/cpp/test/Ice/ami/AllTests.cpp index 8fd66031174..4fdfb66dd44 100644 --- a/cpp/test/Ice/ami/AllTests.cpp +++ b/cpp/test/Ice/ami/AllTests.cpp @@ -945,6 +945,50 @@ allTests(const Ice::CommunicatorPtr& communicator) cbWC->check(); } cout << "ok" << endl; + +#ifdef ICE_CPP11 + cout << "testing C++11 async callback... " << flush; + { + AsyncCallbackPtr cb = new AsyncCallback(); + Ice::Context ctx; + + p->begin_ice_isA(Test::TestIntf::ice_staticId(), [=](const ::Ice::AsyncResultPtr& r){ cb->isA(r); }); + cb->check(); + p->begin_ice_isA(Test::TestIntf::ice_staticId(), ctx, [=](const ::Ice::AsyncResultPtr& r){ cb->isA(r); }); + cb->check(); + + p->begin_ice_ping([=](const ::Ice::AsyncResultPtr& r){ cb->ping(r); }); + cb->check(); + p->begin_ice_ping(ctx, [=](const ::Ice::AsyncResultPtr& r){ cb->ping(r); }); + cb->check(); + + p->begin_ice_id([=](const ::Ice::AsyncResultPtr& r){ cb->id(r); }); + cb->check(); + p->begin_ice_id(ctx, [=](const ::Ice::AsyncResultPtr& r){ cb->id(r); }); + cb->check(); + + p->begin_ice_ids([=](const ::Ice::AsyncResultPtr& r){ cb->ids(r); }); + cb->check(); + p->begin_ice_ids(ctx, [=](const ::Ice::AsyncResultPtr& r){ cb->ids(r); }); + cb->check(); + + p->begin_op([=](const ::Ice::AsyncResultPtr& r){ cb->op(r); }); + cb->check(); + p->begin_op(ctx, [=](const ::Ice::AsyncResultPtr& r){ cb->op(r); }); + cb->check(); + + p->begin_opWithResult([=](const ::Ice::AsyncResultPtr& r){ cb->opWithResult(r); }); + cb->check(); + p->begin_opWithResult(ctx, [=](const ::Ice::AsyncResultPtr& r){ cb->opWithResult(r); }); + cb->check(); + + p->begin_opWithUE([=](const ::Ice::AsyncResultPtr& r){ cb->opWithUE(r); }); + cb->check(); + p->begin_opWithUE(ctx, [=](const ::Ice::AsyncResultPtr& r){ cb->opWithUE(r); }); + cb->check(); + } + cout << "ok" << endl; +#endif cout << "testing response callback... " << flush; { @@ -1031,6 +1075,58 @@ allTests(const Ice::CommunicatorPtr& communicator) } cout << "ok" << endl; +#ifdef ICE_CPP11 + cout << "testing C++11 response callback... " << flush; + { + ResponseCallbackPtr cb = new ResponseCallback(); + Ice::Context ctx; + + p->begin_ice_isA(Test::TestIntf::ice_staticId(), [=](bool is){ cb->isA(is); }); + cb->check(); + + p->begin_ice_isA(Test::TestIntf::ice_staticId(), ctx, [=](bool is){ cb->isA(is); }); + cb->check(); + + p->begin_ice_ping([=](){ cb->ping(); }); + cb->check(); + + p->begin_ice_ping(ctx, [=](){ cb->ping(); }); + cb->check(); + + + p->begin_ice_id([=](const string& id){ cb->id(id); }); + cb->check(); + + p->begin_ice_id(ctx, [=](const string& id){ cb->id(id); }); + cb->check(); + + p->begin_ice_ids([=](const Ice::StringSeq& ids){ cb->ids(ids); }); + cb->check(); + + p->begin_ice_ids(ctx, [=](const Ice::StringSeq& ids){ cb->ids(ids); }); + cb->check(); + + p->begin_op([=](){ cb->op(); }); + cb->check(); + + p->begin_op(ctx, [=](){ cb->op(); }); + cb->check(); + + p->begin_opWithResult([=](int ret){ cb->opWithResult(ret); }); + cb->check(); + + p->begin_opWithResult(ctx, [=](int ret){ cb->opWithResult(ret); }); + cb->check(); + + p->begin_opWithUE([](){ test(false); }, [=](const Ice::Exception& ex){ cb->opWithUE(ex); }); + cb->check(); + + p->begin_opWithUE(ctx, [](){ test(false); }, [=](const Ice::Exception& ex){ cb->opWithUE(ex); }); + cb->check(); + } + cout << "ok" << endl; +#endif + cout << "testing local exceptions... " << flush; { Test::TestIntfPrx indirect = Test::TestIntfPrx::uncheckedCast(p->ice_adapterId("dummy")); @@ -1111,7 +1207,7 @@ allTests(const Ice::CommunicatorPtr& communicator) cbWC->check(); } cout << "ok" << endl; - + cout << "testing local exceptions with response callback... " << flush; { Test::TestIntfPrx i = Test::TestIntfPrx::uncheckedCast(p->ice_adapterId("dummy")); @@ -1151,6 +1247,30 @@ allTests(const Ice::CommunicatorPtr& communicator) cbWC->check(); } cout << "ok" << endl; + +#ifdef ICE_CPP11 + cout << "testing local exceptions with C++11 response callback... " << flush; + { + Test::TestIntfPrx i = Test::TestIntfPrx::uncheckedCast(p->ice_adapterId("dummy")); + ExceptionCallbackPtr cb = new ExceptionCallback(); + + i->begin_ice_isA(Test::TestIntf::ice_staticId(), std::function<void (bool)>([](bool){ test(false); }), [=](const Ice::Exception& ex){ cb->ex(ex); }); + cb->check(); + + i->begin_ice_ping([](){ test(false); }, [=](const Ice::Exception& ex){ cb->ex(ex); }); + cb->check(); + + i->begin_ice_id([](const string&){ test(false); }, [=](const Ice::Exception& ex){ cb->ex(ex); }); + cb->check(); + + i->begin_ice_ids([](const Ice::StringSeq&){ test(false); }, [=](const Ice::Exception& ex){ cb->ex(ex); }); + cb->check(); + + i->begin_op([](){ test(false); }, [=](const Ice::Exception& ex){ cb->ex(ex); }); + cb->check(); + } + cout << "ok" << endl; +#endif cout << "testing exception callback... " << flush; { @@ -1200,6 +1320,32 @@ allTests(const Ice::CommunicatorPtr& communicator) cbWC->check(); } cout << "ok" << endl; + +#ifdef ICE_CPP11 + cout << "testing C++11 exception callback... " << flush; + { + Test::TestIntfPrx i = Test::TestIntfPrx::uncheckedCast(p->ice_adapterId("dummy")); + ExceptionCallbackPtr cb = new ExceptionCallback(); + + i->begin_ice_isA(Test::TestIntf::ice_staticId(), nullptr, [=](const Ice::Exception& ex){cb->ex(ex); }); + cb->check(); + + i->begin_op(nullptr, [=](const Ice::Exception& ex){ cb->ex(ex); }); + cb->check(); + + i->begin_opWithUE(nullptr, [=](const Ice::Exception& ex){ cb->ex(ex); }); + cb->check(); + + // Ensures no exception is called when response is received + p->begin_ice_isA(Test::TestIntf::ice_staticId(), nullptr, [=](const Ice::Exception& ex){ cb->noEx(ex); }); + p->begin_op(nullptr, [=](const Ice::Exception& ex){ cb->noEx(ex); }); + + // If response is a user exception, it should be received. + p->begin_opWithUE(nullptr, [=](const Ice::Exception& ex){ cb->opWithUE(ex); }); + cb->check(); + } + cout << "ok" << endl; +#endif cout << "testing sent callback... " << flush; { @@ -1280,6 +1426,79 @@ allTests(const Ice::CommunicatorPtr& communicator) } } cout << "ok" << endl; + +#ifdef ICE_CPP11 + cout << "testing C++11 sent callback... " << flush; + { + SentCallbackPtr cb = new SentCallback; + + p->begin_ice_isA("", [=](bool v){ cb->isA(v); }, + [=](const Ice::Exception& ex){ cb->ex(ex); }, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + + p->begin_ice_ping([=](){ cb->ping(); }, + [=](const Ice::Exception& ex){ cb->ex(ex); }, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + + p->begin_ice_id([=](const string& id){ cb->id(id); }, + [=](const Ice::Exception& ex){ cb->ex(ex); }, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + + p->begin_ice_ids([=](const Ice::StringSeq& ids){ cb->ids(ids); }, + [=](const Ice::Exception& ex){ cb->ex(ex); }, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + + + p->begin_op([=](){ cb->op(); }, + [=](const Ice::Exception& ex){ cb->ex(ex); }, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + + p->begin_op([=](){ cb->op(); }, + nullptr, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + + p->begin_op(nullptr, + [=](const Ice::Exception& ex){ cb->ex(ex); }, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + + vector<SentCallbackPtr> cbs; + Ice::ByteSeq seq; + seq.resize(1024); // Make sure the request doesn't compress too well. + for(Ice::ByteSeq::iterator q = seq.begin(); q != seq.end(); ++q) + { + *q = static_cast<Ice::Byte>(IceUtilInternal::random(255)); + } + testController->holdAdapter(); + try + { + cb = new SentCallback(); + while(p->begin_opWithPayload(seq, nullptr, [=](const Ice::Exception& ex){ cb->ex(ex); }, + [=](bool sent){ cb->sent(sent); })->sentSynchronously()) + { + cbs.push_back(cb); + cb = new SentCallback(); + } + } + catch(...) + { + testController->resumeAdapter(); + throw; + } + testController->resumeAdapter(); + for(vector<SentCallbackPtr>::const_iterator r = cbs.begin(); r != cbs.end(); r++) + { + (*r)->check(); + } + } + cout << "ok" << endl; +#endif cout << "testing illegal arguments... " << flush; { @@ -1427,6 +1646,32 @@ allTests(const Ice::CommunicatorPtr& communicator) } } cout << "ok" << endl; + +#ifdef ICE_CPP11 + cout << "testing unexpected exceptions from C++11 callback... " << flush; + { + Test::TestIntfPrx q = Test::TestIntfPrx::uncheckedCast(p->ice_adapterId("dummy")); + ThrowType throwEx[] = { LocalException, UserException, StandardException, OtherException }; + + for(int i = 0; i < 4; ++i) + { + ThrowerPtr cb = new Thrower(throwEx[i]); + + p->begin_op([=](){ cb->op(); }, [=](const Ice::Exception& ex){ cb->noEx(ex); }); + cb->check(); + + p->begin_op([=](){ cb->op(); }, [=](const Ice::Exception& ex){ cb->ex(ex); }); + cb->check(); + + p->begin_op([=](){ cb->noOp(); }, [=](const Ice::Exception& ex){ cb->noEx(ex); }, [=](bool sent){ cb->sent(sent); }); + cb->check(); + + q->begin_op(nullptr, [=](const Ice::Exception& ex){ cb->ex(ex); }); + cb->check(); + } + } + cout << "ok" << endl; +#endif cout << "testing batch requests with proxy... " << flush; { @@ -1566,6 +1811,43 @@ allTests(const Ice::CommunicatorPtr& communicator) } cout << "ok" << endl; +#ifdef ICE_CPP11 + cout << "testing C++11 batch requests with proxy... " << flush; + { + + { + test(p->opBatchCount() == 0); + Test::TestIntfPrx b1 = p->ice_batchOneway(); + b1->opBatch(); + b1->opBatch(); + FlushCallbackPtr cb = new FlushCallback(); + Ice::AsyncResultPtr r = b1->begin_ice_flushBatchRequests( + [=](const Ice::Exception& ex){ cb->exception(ex);}, + [=](bool sent){ cb->sent(sent); }); + + cb->check(); + test(r->isSent()); + test(r->isCompleted()); + test(p->waitForBatch(2)); + } + + { + test(p->opBatchCount() == 0); + Test::TestIntfPrx b1 = p->ice_batchOneway(); + b1->opBatch(); + b1->ice_getConnection()->close(false); + FlushExCallbackPtr cb = new FlushExCallback(); + Ice::AsyncResultPtr r = b1->begin_ice_flushBatchRequests( + [=](const Ice::Exception& ex){ cb->exception(ex);}, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + test(!r->isSent()); + test(r->isCompleted()); + test(p->opBatchCount() == 0); + } + } + cout << "ok" << endl; +#endif cout << "testing batch requests with connection... " << flush; { CookiePtr cookie = new Cookie(5); @@ -1702,6 +1984,48 @@ allTests(const Ice::CommunicatorPtr& communicator) } } cout << "ok" << endl; + +#ifdef ICE_CPP11 + cout << "testing C++11 batch requests with connection... " << flush; + { + { + // + // Without cookie. + // + test(p->opBatchCount() == 0); + Test::TestIntfPrx b1 = p->ice_batchOneway(); + b1->opBatch(); + b1->opBatch(); + FlushCallbackPtr cb = new FlushCallback(); + Ice::AsyncResultPtr r = b1->ice_getConnection()->begin_flushBatchRequests( + [=](const Ice::Exception& ex){ cb->exception(ex);}, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + test(r->isSent()); + test(r->isCompleted()); + test(p->waitForBatch(2)); + } + + { + // + // Exception without cookie. + // + test(p->opBatchCount() == 0); + Test::TestIntfPrx b1 = p->ice_batchOneway(); + b1->opBatch(); + b1->ice_getConnection()->close(false); + FlushExCallbackPtr cb = new FlushExCallback(); + Ice::AsyncResultPtr r = b1->ice_getConnection()->begin_flushBatchRequests( + [=](const Ice::Exception& ex){ cb->exception(ex);}, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + test(!r->isSent()); + test(r->isCompleted()); + test(p->opBatchCount() == 0); + } + } + cout << "ok" << endl; +#endif cout << "testing batch requests with communicator... " << flush; { @@ -1973,6 +2297,117 @@ allTests(const Ice::CommunicatorPtr& communicator) } cout << "ok" << endl; +#ifdef ICE_CPP11 + cout << "testing C++11 batch requests with communicator... " << flush; + { + { + // + // Without cookie - 1 connection. + // + test(p->opBatchCount() == 0); + Test::TestIntfPrx b1 = p->ice_batchOneway(); + b1->opBatch(); + b1->opBatch(); + FlushCallbackPtr cb = new FlushCallback(); + Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests( + [=](const Ice::Exception& ex){ cb->exception(ex);}, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + test(r->isSent()); + test(r->isCompleted()); + test(p->waitForBatch(2)); + } + + { + // + // Exception without cookie - 1 connection. + // + test(p->opBatchCount() == 0); + Test::TestIntfPrx b1 = p->ice_batchOneway(); + b1->opBatch(); + b1->ice_getConnection()->close(false); + FlushCallbackPtr cb = new FlushCallback(); + Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests( + [=](const Ice::Exception& ex){ cb->exception(ex);}, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + test(r->isSent()); // Exceptions are ignored! + test(r->isCompleted()); + test(p->opBatchCount() == 0); + } + + { + // + // 2 connections. + // + test(p->opBatchCount() == 0); + Test::TestIntfPrx b1 = p->ice_batchOneway(); + Test::TestIntfPrx b2 = p->ice_connectionId("2")->ice_batchOneway(); + b2->ice_getConnection(); // Ensure connection is established. + b1->opBatch(); + b1->opBatch(); + b2->opBatch(); + b2->opBatch(); + FlushCallbackPtr cb = new FlushCallback(); + Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests( + [=](const Ice::Exception& ex){ cb->exception(ex);}, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + test(r->isSent()); + test(r->isCompleted()); + test(p->waitForBatch(4)); + } + + { + // + // Exception - 2 connections - 1 failure. + // + // All connections should be flushed even if there are failures on some connections. + // Exceptions should not be reported. + // + test(p->opBatchCount() == 0); + Test::TestIntfPrx b1 = p->ice_batchOneway(); + Test::TestIntfPrx b2 = p->ice_connectionId("2")->ice_batchOneway(); + b2->ice_getConnection(); // Ensure connection is established. + b1->opBatch(); + b2->opBatch(); + b1->ice_getConnection()->close(false); + FlushCallbackPtr cb = new FlushCallback(); + Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests( + [=](const Ice::Exception& ex){ cb->exception(ex);}, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + test(r->isSent()); // Exceptions are ignored! + test(r->isCompleted()); + test(p->waitForBatch(1)); + } + + { + // + // Exception - 2 connections - 2 failures. + // + // The sent callback should be invoked even if all connections fail. + // + test(p->opBatchCount() == 0); + Test::TestIntfPrx b1 = p->ice_batchOneway(); + Test::TestIntfPrx b2 = p->ice_connectionId("2")->ice_batchOneway(); + b2->ice_getConnection(); // Ensure connection is established. + b1->opBatch(); + b2->opBatch(); + b1->ice_getConnection()->close(false); + b2->ice_getConnection()->close(false); + FlushCallbackPtr cb = new FlushCallback(); + Ice::AsyncResultPtr r = communicator->begin_flushBatchRequests( + [=](const Ice::Exception& ex){ cb->exception(ex);}, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + test(r->isSent()); // Exceptions are ignored! + test(r->isCompleted()); + test(p->opBatchCount() == 0); + } + } + cout << "ok" << endl; +#endif cout << "testing AsyncResult operations... " << flush; { { diff --git a/cpp/test/Ice/binding/Test.ice b/cpp/test/Ice/binding/Test.ice index 03fbce936bc..160e41d6774 100644 --- a/cpp/test/Ice/binding/Test.ice +++ b/cpp/test/Ice/binding/Test.ice @@ -14,7 +14,7 @@ module Test interface TestIntf { - ["ami"] string getAdapterName(); + string getAdapterName(); }; interface RemoteObjectAdapter diff --git a/cpp/test/Ice/custom/AllTests.cpp b/cpp/test/Ice/custom/AllTests.cpp index a4c3983c919..0f6853e19a5 100755 --- a/cpp/test/Ice/custom/AllTests.cpp +++ b/cpp/test/Ice/custom/AllTests.cpp @@ -13,6 +13,10 @@ #include <Test.h> #include <Wstring.h> +#ifdef _MSC_VER +# pragma warning( 4 : 4503 ) // C4503: ... : decorated name length exceeded, name was truncated +#endif + using namespace std; namespace @@ -1448,6 +1452,23 @@ public: test(false); } } + + void throwExcept1(const Ice::Exception& ex, const wstring& in) + { + try + { + ex.ice_throw(); + } + catch(const Test1::WstringException& e) + { + test(e.reason == in); + called(); + } + catch(...) + { + test(false); + } + } void throwExcept2(const Ice::AsyncResultPtr& result) { @@ -1467,10 +1488,28 @@ public: test(false); } } + + void throwExcept2(const Ice::Exception& ex, const wstring& in) + { + try + { + ex.ice_throw(); + } + catch(const Test2::WstringException& e) + { + test(e.reason == in); + called(); + } + catch(...) + { + test(false); + } + } void - noEx(const Ice::Exception&, const InParamPtr&) + noEx(const Ice::Exception& ex, const InParamPtr&) { + cerr << ex << endl; test(false); } }; @@ -3519,6 +3558,724 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) } cout << "ok" << endl; +#ifdef ICE_CPP11 + cout << "testing alternate sequences with C++11 AMI callbacks... " << flush; + + { + Test::DoubleSeq in(5); + in[0] = 3.14; + in[1] = 1 / 3; + in[2] = 0.375; + in[3] = 4 / 3; + in[4] = -5.725; + Ice::Double inArray[5]; + for(int i = 0; i < 5; ++i) + { + inArray[i] = in[i]; + } + pair<const Ice::Double*, const Ice::Double*> inPair(inArray, inArray + 5); + + CallbackPtr cb = new Callback(); + t->begin_opDoubleArray(inPair, + [=](const pair<const Ice::Double*, const Ice::Double*>& p1, const pair<const Ice::Double*, const Ice::Double*>& p2) + { + cb->opDoubleArray(p1, p2, newInParam(inPair)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(inPair)); + }); + cb->check(); + } + + { + Test::BoolSeq in(5); + in[0] = false; + in[1] = true; + in[2] = true; + in[3] = false; + in[4] = true; + bool inArray[5]; + for(int i = 0; i < 5; ++i) + { + inArray[i] = in[i]; + } + pair<const bool*, const bool*> inPair(inArray, inArray + 5); + + CallbackPtr cb = new Callback(); + t->begin_opBoolArray(inPair, + [=](const pair<const bool*, const bool*>& p1, const pair<const bool*, const bool*>& p2) + { + cb->opBoolArray(p1, p2, newInParam(inPair)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(inPair)); + }); + cb->check(); + } + + { + Ice::Byte in[5]; + in[0] = '1'; + in[1] = '2'; + in[2] = '3'; + in[3] = '4'; + in[4] = '5'; + pair<const Ice::Byte*, const Ice::Byte*> inPair(in, in + 5); + + CallbackPtr cb = new Callback(); + t->begin_opByteArray(inPair, + [=](const pair<const Ice::Byte*, const Ice::Byte*>& p1, + const pair<const Ice::Byte*, const Ice::Byte*>& p2) + { + cb->opByteArray(p1, p2, newInParam(inPair)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(inPair)); + }); + cb->check(); + } + + { + Test::VariableList in; + Test::Variable inArray[5]; + inArray[0].s = "These"; + in.push_back(inArray[0]); + inArray[1].s = "are"; + in.push_back(inArray[1]); + inArray[2].s = "five"; + in.push_back(inArray[2]); + inArray[3].s = "short"; + in.push_back(inArray[3]); + inArray[4].s = "strings."; + in.push_back(inArray[4]); + pair<const Test::Variable*, const Test::Variable*> inPair(inArray, inArray + 5); + + CallbackPtr cb = new Callback(); + t->begin_opVariableArray(inPair, + [=](const pair<const Test::Variable*, const Test::Variable*>& p1, + const pair<const Test::Variable*, const Test::Variable*>& p2) + { + cb->opVariableArray(p1, p2, newInParam(inPair)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(inPair)); + }); + cb->check(); + } + + { + Test::BoolSeq in(5); + in[0] = false; + in[1] = true; + in[2] = true; + in[3] = false; + in[4] = true; + pair<Test::BoolSeq::const_iterator, Test::BoolSeq::const_iterator> inPair(in.begin(), in.end()); + + CallbackPtr cb = new Callback(); + t->begin_opBoolRange(inPair, + [=](const pair<Test::BoolSeq::const_iterator, Test::BoolSeq::const_iterator>& p1, + const pair<Test::BoolSeq::const_iterator, Test::BoolSeq::const_iterator>& p2) + { + cb->opBoolRange(p1, p2, newInParam(inPair)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(inPair)); + }); + cb->check(); + } + + { + Test::ByteList in; + in.push_back('1'); + in.push_back('2'); + in.push_back('3'); + in.push_back('4'); + in.push_back('5'); + pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator> inPair(in.begin(), in.end()); + + CallbackPtr cb = new Callback(); + t->begin_opByteRange(inPair, + [=](const pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>& p1, + const pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>& p2) + { + cb->opByteRange(p1, p2, newInParam(inPair)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(inPair)); + }); + cb->check(); + } + + { + Test::VariableList in; + Test::Variable v; + v.s = "These"; + in.push_back(v); + v.s = "are"; + in.push_back(v); + v.s = "five"; + in.push_back(v); + v.s = "short"; + in.push_back(v); + v.s = "strings."; + in.push_back(v); + pair<Test::VariableList::const_iterator, Test::VariableList::const_iterator> inPair(in.begin(), in.end()); + + CallbackPtr cb = new Callback(); + t->begin_opVariableRange(inPair, + [=](const pair<Test::VariableList::const_iterator, Test::VariableList::const_iterator>& p1, + const pair<Test::VariableList::const_iterator, Test::VariableList::const_iterator>& p2) + { + cb->opVariableRange(p1, p2, newInParam(inPair)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(inPair)); + }); + cb->check(); + } + + { + Test::BoolSeq in(5); + in[0] = false; + in[1] = true; + in[2] = true; + in[3] = false; + in[4] = true; + bool inArray[5]; + for(int i = 0; i < 5; ++i) + { + inArray[i] = in[i]; + } + pair<const bool*, const bool*> inPair(inArray, inArray + 5); + + CallbackPtr cb = new Callback(); + Test::Callback_TestIntf_opBoolRangeTypePtr callback = + Test::newCallback_TestIntf_opBoolRangeType(cb, &Callback::opBoolRangeType, &Callback::noEx); + t->begin_opBoolRangeType(inPair, callback, newInParam(inPair)); + cb->check(); + } + + { + Test::ByteList in; + in.push_back('1'); + in.push_back('2'); + in.push_back('3'); + in.push_back('4'); + in.push_back('5'); + pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator> inPair(in.begin(), in.end()); + + CallbackPtr cb = new Callback(); + t->begin_opByteRangeType(inPair, + [=](const pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>& p1, + const pair<Test::ByteList::const_iterator, Test::ByteList::const_iterator>& p2) + { + cb->opByteRangeType(p1, p2, newInParam(inPair)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(inPair)); + }); + cb->check(); + } + + { + Test::VariableList in; + deque<Test::Variable> inSeq; + Test::Variable v; + v.s = "These"; + in.push_back(v); + inSeq.push_back(v); + v.s = "are"; + in.push_back(v); + inSeq.push_back(v); + v.s = "five"; + in.push_back(v); + inSeq.push_back(v); + v.s = "short"; + in.push_back(v); + inSeq.push_back(v); + v.s = "strings."; + in.push_back(v); + inSeq.push_back(v); + pair<deque<Test::Variable>::const_iterator, deque<Test::Variable>::const_iterator> inPair(inSeq.begin(), + inSeq.end()); + + CallbackPtr cb = new Callback(); + t->begin_opVariableRangeType(inPair, + [=](const pair<deque<Test::Variable>::const_iterator, deque<Test::Variable>::const_iterator>& p1, + const pair<deque<Test::Variable>::const_iterator, deque<Test::Variable>::const_iterator>& p2) + { + cb->opVariableRangeType(p1, p2, newInParam(inPair)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(inPair)); + }); + cb->check(); + } + + { + deque<bool> in(5); + in[0] = false; + in[1] = true; + in[2] = true; + in[3] = false; + in[4] = true; + + CallbackPtr cb = new Callback(); + t->begin_opBoolSeq(in, + [=](const deque<bool>& p1, const deque<bool>& p2) + { + cb->opBoolSeq(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + list<bool> in; + in.push_back(false); + in.push_back(true); + in.push_back(true); + in.push_back(false); + in.push_back(true); + + CallbackPtr cb = new Callback(); + t->begin_opBoolList(in, + [=](const list<bool>& p1, const list<bool>& p2) + { + cb->opBoolList(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + deque< ::Ice::Byte> in(5); + in[0] = '1'; + in[1] = '2'; + in[2] = '3'; + in[3] = '4'; + in[4] = '5'; + + CallbackPtr cb = new Callback(); + t->begin_opByteSeq(in, + [=](const deque< ::Ice::Byte>& p1, const deque< ::Ice::Byte>& p2) + { + cb->opByteSeq(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + list< ::Ice::Byte> in; + in.push_back('1'); + in.push_back('2'); + in.push_back('3'); + in.push_back('4'); + in.push_back('5'); + + CallbackPtr cb = new Callback(); + t->begin_opByteList(in, + [=](const list< ::Ice::Byte>& p1, const list< ::Ice::Byte>& p2) + { + cb->opByteList(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + MyByteSeq in(5); + int i = 0; + for(MyByteSeq::iterator p = in.begin(); p != in.end(); ++p) + { + *p = '1' + i++; + } + + CallbackPtr cb = new Callback(); + t->begin_opMyByteSeq(in, + [=](const MyByteSeq& p1, const MyByteSeq& p2) + { + cb->opMyByteSeq(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + deque<string> in(5); + in[0] = "These"; + in[1] = "are"; + in[2] = "five"; + in[3] = "short"; + in[4] = "strings."; + + CallbackPtr cb = new Callback(); + t->begin_opStringSeq(in, + [=](const deque<string>& p1, const deque<string>& p2) + { + cb->opStringSeq(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + list<string> in; + in.push_back("These"); + in.push_back("are"); + in.push_back("five"); + in.push_back("short"); + in.push_back("strings."); + + CallbackPtr cb = new Callback(); + t->begin_opStringList(in, + [=](const list<string>& p1, const list<string>& p2) + { + cb->opStringList(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + deque<Test::Fixed> in(5); + in[0].s = 1; + in[1].s = 2; + in[2].s = 3; + in[3].s = 4; + in[4].s = 5; + + CallbackPtr cb = new Callback(); + t->begin_opFixedSeq(in, + [=](const deque<Test::Fixed>& p1, const deque<Test::Fixed>& p2) + { + cb->opFixedSeq(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + list<Test::Fixed> in(5); + short num = 1; + for(list<Test::Fixed>::iterator p = in.begin(); p != in.end(); ++p) + { + (*p).s = num++; + } + + CallbackPtr cb = new Callback(); + t->begin_opFixedList(in, + [=](const list<Test::Fixed> p1, const list<Test::Fixed> p2) + { + cb->opFixedList(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + deque<Test::Variable> in(5); + in[0].s = "These"; + in[1].s = "are"; + in[2].s = "five"; + in[3].s = "short"; + in[4].s = "strings."; + + CallbackPtr cb = new Callback(); + t->begin_opVariableSeq(in, + [=](const deque<Test::Variable>& p1, const deque<Test::Variable>& p2) + { + cb->opVariableSeq(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + list<Test::Variable> in; + Test::Variable v; + v.s = "These"; + in.push_back(v); + v.s = "are"; + in.push_back(v); + v.s = "five"; + in.push_back(v); + v.s = "short"; + in.push_back(v); + v.s = "strings."; + in.push_back(v); + + CallbackPtr cb = new Callback(); + t->begin_opVariableList(in, + [=](const list<Test::Variable>& p1, const list<Test::Variable>& p2) + { + cb->opVariableList(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + deque<Test::StringStringDict> in(5); + in[0]["A"] = "a"; + in[1]["B"] = "b"; + in[2]["C"] = "c"; + in[3]["D"] = "d"; + in[4]["E"] = "e"; + + CallbackPtr cb = new Callback(); + t->begin_opStringStringDictSeq(in, + [=](const deque<Test::StringStringDict>& p1, const deque<Test::StringStringDict>& p2) + { + cb->opStringStringDictSeq(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + list<Test::StringStringDict> in; + Test::StringStringDict ssd; + ssd["A"] = "a"; + in.push_back(ssd); + ssd["B"] = "b"; + in.push_back(ssd); + ssd["C"] = "c"; + in.push_back(ssd); + ssd["D"] = "d"; + in.push_back(ssd); + ssd["E"] = "e"; + in.push_back(ssd); + + CallbackPtr cb = new Callback(); + t->begin_opStringStringDictList(in, + [=](const list<Test::StringStringDict>& p1, + const list<Test::StringStringDict>& p2) + { + cb->opStringStringDictList(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + deque<Test::E> in(5); + in[0] = Test::E1; + in[1] = Test::E2; + in[2] = Test::E3; + in[3] = Test::E1; + in[4] = Test::E3; + + CallbackPtr cb = new Callback(); + t->begin_opESeq(in, + [=](const deque<Test::E>& p1, const deque<Test::E>& p2) + { + cb->opESeq(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + list<Test::E> in; + in.push_back(Test::E1); + in.push_back(Test::E2); + in.push_back(Test::E3); + in.push_back(Test::E1); + in.push_back(Test::E3); + + CallbackPtr cb = new Callback(); + t->begin_opEList(in, + [=](const list<Test::E>& p1, const list<Test::E>& p2) + { + cb->opEList(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + deque<Test::CPrx> in(5); + in[0] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C1:default -p 12010 -t 10000")); + in[1] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C2:default -p 12010 -t 10001")); + in[2] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C3:default -p 12010 -t 10002")); + in[3] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C4:default -p 12010 -t 10003")); + in[4] = Test::CPrx::uncheckedCast(communicator->stringToProxy("C5:default -p 12010 -t 10004")); + + CallbackPtr cb = new Callback(); + t->begin_opCPrxSeq(in, + [=](const deque<Test::CPrx>& p1, const deque<Test::CPrx>& p2) + { + cb->opCPrxSeq(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + list<Test::CPrx> in; + in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C1:default -p 12010 -t 10000"))); + in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C2:default -p 12010 -t 10001"))); + in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C3:default -p 12010 -t 10002"))); + in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C4:default -p 12010 -t 10003"))); + in.push_back(Test::CPrx::uncheckedCast(communicator->stringToProxy("C5:default -p 12010 -t 10004"))); + + CallbackPtr cb = new Callback(); + t->begin_opCPrxList(in, + [=](const list<Test::CPrx>& p1, const list<Test::CPrx>& p2) + { + cb->opCPrxList(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + deque<Test::CPtr> in(5); + in[0] = new Test::C(); + in[1] = in[0]; + in[2] = in[0]; + in[3] = in[0]; + in[4] = in[0]; + + CallbackPtr cb = new Callback(); + t->begin_opCSeq(in, + [=](const deque<Test::CPtr>& p1, const deque<Test::CPtr>& p2) + { + cb->opCSeq(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + list<Test::CPtr> in; + in.push_back(new Test::C()); + in.push_back(new Test::C()); + in.push_back(new Test::C()); + in.push_back(new Test::C()); + in.push_back(new Test::C()); + + CallbackPtr cb = new Callback(); + t->begin_opCList(in, + [=](const list<Test::CPtr>& p1, const list<Test::CPtr>& p2) + { + cb->opCList(p1, p2, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + + { + Test::ByteSeq in; + in.push_back('1'); + in.push_back('2'); + in.push_back('3'); + in.push_back('4'); + + CallbackPtr cb = new Callback(); + t->begin_opOutArrayByteSeq(in, + [=](const ::std::pair<const ::Ice::Byte*, const ::Ice::Byte*>& p1) + { + cb->opOutArrayByteSeq(p1, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + + { + Test::ByteSeq in; + in.push_back('1'); + in.push_back('2'); + in.push_back('3'); + in.push_back('4'); + + CallbackPtr cb = new Callback(); + t->begin_opOutRangeByteSeq(in, + [=](const ::std::pair< ::Test::ByteSeq::const_iterator, ::Test::ByteSeq::const_iterator>& p1) + { + cb->opOutRangeByteSeq(p1, newInParam(in)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(in)); + }); + cb->check(); + } + cout << "ok" << endl; +#endif } cout << "testing class mapped structs ... " << flush; @@ -3568,6 +4325,25 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) cb->check(); } cout << "ok" << endl; +#ifdef ICE_CPP11 + cout << "testing class mapped structs with C++11 AMI... " << flush; + { + CallbackPtr cb = new Callback(); + t->begin_opClassStruct(cs, csseq1, + [=](const ::Test::ClassStructPtr& p1, + const ::Test::ClassStructPtr& p2, + const ::Test::ClassStructSeq& p3) + { + cb->opClassStruct(p1, p2, p3, newInParam(make_pair(cs, csseq1))); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(make_pair(cs, csseq1))); + }); + cb->check(); + } + cout << "ok" << endl; +#endif } cout << "testing wstring... " << flush; @@ -3622,6 +4398,21 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) newInParam(wstr)); cb->check(); } +#ifdef ICE_CPP11 + { + CallbackPtr cb = new Callback(); + wsc1->begin_opString(wstr, + [=](const wstring& p1, const wstring& p2) + { + cb->opString(p1, p2, newInParam(wstr)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(wstr)); + }); + cb->check(); + } +#endif } ret = wsc2->opString(wstr, out); @@ -3648,6 +4439,27 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) &Callback::noEx), newInParam(wstr)); cb->check(); } + { + CallbackPtr cb = new Callback(); + wsc2->begin_opString(wstr, Test2::newCallback_WstringClass_opString(cb, &Callback::opString, + &Callback::noEx), newInParam(wstr)); + cb->check(); + } +#ifdef ICE_CPP11 + { + CallbackPtr cb = new Callback(); + wsc2->begin_opString(wstr, + [=](const wstring& p1, const wstring& p2) + { + cb->opString(p1, p2, newInParam(wstr)); + }, + [=](const Ice::Exception& ex) + { + cb->noEx(ex, newInParam(wstr)); + }); + cb->check(); + } +#endif } Test1::WstringStruct wss1; @@ -3697,6 +4509,17 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) wsc1->begin_throwExcept(wstr, Ice::newCallback(cb, &Callback::throwExcept1), newInParam(wstr)); cb->check(); } +#ifdef ICE_CPP11 + { + CallbackPtr cb = new Callback(); + wsc1->begin_throwExcept(wstr, nullptr, + [=](const Ice::Exception& ex) + { + cb->throwExcept1(ex, wstr); + }); + cb->check(); + } +#endif } try @@ -3732,6 +4555,17 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) wsc2->begin_throwExcept(wstr, Ice::newCallback(cb, &Callback::throwExcept2), newInParam(wstr)); cb->check(); } +#ifdef ICE_CPP11 + { + CallbackPtr cb = new Callback(); + wsc2->begin_throwExcept(wstr, nullptr, + [=](const Ice::Exception& ex) + { + cb->throwExcept2(ex, wstr); + }); + cb->check(); + } +#endif } cout << "ok" << endl; diff --git a/cpp/test/Ice/dispatcher/AllTests.cpp b/cpp/test/Ice/dispatcher/AllTests.cpp index 48af9c3754d..9bb283b6a07 100644 --- a/cpp/test/Ice/dispatcher/AllTests.cpp +++ b/cpp/test/Ice/dispatcher/AllTests.cpp @@ -104,7 +104,11 @@ allTests(const Ice::CommunicatorPtr& communicator) Test::TestIntfControllerPrx testController = Test::TestIntfControllerPrx::uncheckedCast(obj); +#ifdef ICE_CPP11 + cout << "testing C++11 dispatcher... " << flush; +#else cout << "testing dispatcher... " << flush; +#endif { p->op(); diff --git a/cpp/test/Ice/dispatcher/Client.cpp b/cpp/test/Ice/dispatcher/Client.cpp index da86ee480af..8060023eeac 100644 --- a/cpp/test/Ice/dispatcher/Client.cpp +++ b/cpp/test/Ice/dispatcher/Client.cpp @@ -29,13 +29,24 @@ main(int argc, char* argv[]) { int status; Ice::CommunicatorPtr communicator; - + try { Ice::InitializationData initData; initData.properties = Ice::createProperties(argc, argv); +#ifdef ICE_CPP11 + Ice::DispatcherPtr dispatcher = new Dispatcher(); + initData.dispatcher = Ice::newDispatcher( + [=](const Ice::DispatcherCallPtr& call, const Ice::ConnectionPtr& conn) + { + dispatcher->dispatch(call, conn); + }); +#else initData.dispatcher = new Dispatcher(); +#endif communicator = Ice::initialize(argc, argv, initData); + + status = run(argc, argv, communicator); } catch(const Ice::Exception& ex) diff --git a/cpp/test/Ice/dispatcher/Server.cpp b/cpp/test/Ice/dispatcher/Server.cpp index e517301982b..53e4ce4a359 100644 --- a/cpp/test/Ice/dispatcher/Server.cpp +++ b/cpp/test/Ice/dispatcher/Server.cpp @@ -50,7 +50,16 @@ main(int argc, char* argv[]) { Ice::InitializationData initData; initData.properties = Ice::createProperties(argc, argv); +#ifdef ICE_CPP11 + Ice::DispatcherPtr dispatcher = new Dispatcher(); + initData.dispatcher = Ice::newDispatcher( + [=](const Ice::DispatcherCallPtr& call, const Ice::ConnectionPtr& conn) + { + dispatcher->dispatch(call, conn); + }); +#else initData.dispatcher = new Dispatcher(); +#endif communicator = Ice::initialize(argc, argv, initData); status = run(argc, argv, communicator); } diff --git a/cpp/test/Ice/dispatcher/Test.ice b/cpp/test/Ice/dispatcher/Test.ice index 75b26b2f8d3..d0e02f8bf57 100644 --- a/cpp/test/Ice/dispatcher/Test.ice +++ b/cpp/test/Ice/dispatcher/Test.ice @@ -15,7 +15,7 @@ module Test { -["ami"] interface TestIntf +interface TestIntf { void op(); void opWithPayload(Ice::ByteSeq seq); diff --git a/cpp/test/Ice/faultTolerance/Test.ice b/cpp/test/Ice/faultTolerance/Test.ice index 2e0615c9798..64607cac781 100644 --- a/cpp/test/Ice/faultTolerance/Test.ice +++ b/cpp/test/Ice/faultTolerance/Test.ice @@ -12,7 +12,7 @@ module Test { -["ami"] interface TestIntf +interface TestIntf { void shutdown(); void abort(); diff --git a/cpp/test/Ice/hash/.depend b/cpp/test/Ice/hash/.depend new file mode 100644 index 00000000000..d48f87cfd5c --- /dev/null +++ b/cpp/test/Ice/hash/.depend @@ -0,0 +1,3 @@ +Client$(OBJEXT): Client.cpp $(includedir)/Ice/Ice.h $(includedir)/IceUtil/Config.h $(includedir)/Ice/Initialize.h $(includedir)/Ice/CommunicatorF.h $(includedir)/Ice/LocalObjectF.h $(includedir)/IceUtil/Shared.h $(includedir)/Ice/Handle.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/Ice/Config.h $(includedir)/Ice/ProxyF.h $(includedir)/Ice/ProxyHandle.h $(includedir)/Ice/ObjectF.h $(includedir)/Ice/Exception.h $(includedir)/Ice/LocalObject.h $(includedir)/IceUtil/ScopedArray.h $(includedir)/Ice/UndefSysMacros.h $(includedir)/Ice/PropertiesF.h $(includedir)/Ice/Proxy.h $(includedir)/IceUtil/Mutex.h $(includedir)/IceUtil/Lock.h $(includedir)/IceUtil/ThreadException.h $(includedir)/IceUtil/Time.h $(includedir)/IceUtil/MutexProtocol.h $(includedir)/Ice/ProxyFactoryF.h $(includedir)/Ice/ConnectionIF.h $(includedir)/Ice/RequestHandlerF.h $(includedir)/Ice/EndpointIF.h $(includedir)/Ice/EndpointF.h $(includedir)/Ice/EndpointTypes.h $(includedir)/Ice/ObjectAdapterF.h $(includedir)/Ice/ReferenceF.h $(includedir)/Ice/OutgoingAsync.h $(includedir)/IceUtil/Monitor.h $(includedir)/IceUtil/Cond.h $(includedir)/IceUtil/Timer.h $(includedir)/IceUtil/Thread.h $(includedir)/Ice/OutgoingAsyncF.h $(includedir)/Ice/InstanceF.h $(includedir)/Ice/Current.h $(includedir)/Ice/ConnectionF.h $(includedir)/Ice/Identity.h $(includedir)/Ice/BasicStream.h $(includedir)/Ice/ObjectFactoryF.h $(includedir)/Ice/Buffer.h $(includedir)/Ice/Protocol.h $(includedir)/Ice/StreamF.h $(includedir)/Ice/Object.h $(includedir)/Ice/GCShared.h $(includedir)/Ice/GCCountMap.h $(includedir)/Ice/IncomingAsyncF.h $(includedir)/Ice/LoggerF.h $(includedir)/Ice/StatsF.h $(includedir)/Ice/Dispatcher.h $(includedir)/Ice/StringConverter.h $(includedir)/Ice/Plugin.h $(includedir)/Ice/BuiltinSequences.h $(includedir)/Ice/Stream.h $(includedir)/IceUtil/Unicode.h $(includedir)/Ice/LocalException.h $(includedir)/Ice/Properties.h $(includedir)/Ice/Outgoing.h $(includedir)/Ice/Incoming.h $(includedir)/Ice/ServantLocatorF.h $(includedir)/Ice/ServantManagerF.h $(includedir)/Ice/Direct.h $(includedir)/Ice/Logger.h $(includedir)/Ice/LoggerUtil.h $(includedir)/Ice/Stats.h $(includedir)/Ice/Communicator.h $(includedir)/Ice/RouterF.h $(includedir)/Ice/LocatorF.h $(includedir)/Ice/PluginF.h $(includedir)/Ice/ImplicitContextF.h $(includedir)/Ice/CommunicatorAsync.h $(includedir)/Ice/ObjectFactory.h $(includedir)/Ice/ObjectAdapter.h $(includedir)/Ice/FacetMap.h $(includedir)/Ice/Endpoint.h $(includedir)/Ice/ServantLocator.h $(includedir)/Ice/IncomingAsync.h $(includedir)/Ice/Process.h $(includedir)/Ice/Application.h $(includedir)/Ice/Connection.h $(includedir)/Ice/ConnectionAsync.h $(includedir)/Ice/Functional.h $(includedir)/IceUtil/Functional.h $(includedir)/Ice/ImplicitContext.h $(includedir)/Ice/Locator.h $(includedir)/Ice/FactoryTableInit.h $(includedir)/Ice/FactoryTable.h $(includedir)/Ice/UserExceptionFactory.h $(includedir)/Ice/ProcessF.h $(includedir)/Ice/Router.h $(includedir)/Ice/DispatchInterceptor.h $(includedir)/Ice/IconvStringConverter.h Test.h ../../include/TestCommon.h $(includedir)/IceUtil/IceUtil.h $(includedir)/IceUtil/AbstractMutex.h $(includedir)/IceUtil/Cache.h $(includedir)/IceUtil/CountDownLatch.h $(includedir)/IceUtil/CtrlCHandler.h $(includedir)/IceUtil/MutexPtrLock.h $(includedir)/IceUtil/RecMutex.h $(includedir)/IceUtil/UUID.h +Test$(OBJEXT): Test.cpp Test.h $(includedir)/Ice/LocalObjectF.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/Ice/Handle.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/Ice/Config.h $(includedir)/Ice/ProxyF.h $(includedir)/Ice/ProxyHandle.h $(includedir)/Ice/ObjectF.h $(includedir)/Ice/Exception.h $(includedir)/Ice/LocalObject.h $(includedir)/Ice/Proxy.h $(includedir)/IceUtil/Mutex.h $(includedir)/IceUtil/Lock.h $(includedir)/IceUtil/ThreadException.h $(includedir)/IceUtil/Time.h $(includedir)/IceUtil/MutexProtocol.h $(includedir)/Ice/ProxyFactoryF.h $(includedir)/Ice/ConnectionIF.h $(includedir)/Ice/RequestHandlerF.h $(includedir)/Ice/EndpointIF.h $(includedir)/Ice/EndpointF.h $(includedir)/IceUtil/ScopedArray.h $(includedir)/Ice/UndefSysMacros.h $(includedir)/Ice/EndpointTypes.h $(includedir)/Ice/ObjectAdapterF.h $(includedir)/Ice/ReferenceF.h $(includedir)/Ice/OutgoingAsync.h $(includedir)/IceUtil/Monitor.h $(includedir)/IceUtil/Cond.h $(includedir)/IceUtil/Timer.h $(includedir)/IceUtil/Thread.h $(includedir)/Ice/OutgoingAsyncF.h $(includedir)/Ice/InstanceF.h $(includedir)/Ice/CommunicatorF.h $(includedir)/Ice/Current.h $(includedir)/Ice/ConnectionF.h $(includedir)/Ice/Identity.h $(includedir)/Ice/BasicStream.h $(includedir)/Ice/ObjectFactoryF.h $(includedir)/Ice/Buffer.h $(includedir)/Ice/Protocol.h $(includedir)/Ice/StreamF.h $(includedir)/Ice/Object.h $(includedir)/Ice/GCShared.h $(includedir)/Ice/GCCountMap.h $(includedir)/Ice/IncomingAsyncF.h $(includedir)/Ice/Outgoing.h $(includedir)/Ice/Incoming.h $(includedir)/Ice/ServantLocatorF.h $(includedir)/Ice/ServantManagerF.h $(includedir)/Ice/Direct.h $(includedir)/Ice/FactoryTableInit.h $(includedir)/Ice/FactoryTable.h $(includedir)/Ice/UserExceptionFactory.h $(includedir)/Ice/LocalException.h $(includedir)/Ice/BuiltinSequences.h $(includedir)/Ice/Stream.h $(includedir)/Ice/ObjectFactory.h $(includedir)/IceUtil/Iterator.h +Test.h Test.cpp: Test.ice $(SLICE2CPP) $(SLICEPARSERLIB) diff --git a/cpp/test/Ice/hash/.depend.mak b/cpp/test/Ice/hash/.depend.mak new file mode 100644 index 00000000000..ebd394b6929 --- /dev/null +++ b/cpp/test/Ice/hash/.depend.mak @@ -0,0 +1,3 @@ +Client$(OBJEXT): Client.cpp "$(includedir)/Ice/Ice.h" "$(includedir)/IceUtil/Config.h" "$(includedir)/Ice/Initialize.h" "$(includedir)/Ice/CommunicatorF.h" "$(includedir)/Ice/LocalObjectF.h" "$(includedir)/IceUtil/Shared.h" "$(includedir)/Ice/Handle.h" "$(includedir)/IceUtil/Handle.h" "$(includedir)/IceUtil/Exception.h" "$(includedir)/Ice/Config.h" "$(includedir)/Ice/ProxyF.h" "$(includedir)/Ice/ProxyHandle.h" "$(includedir)/Ice/ObjectF.h" "$(includedir)/Ice/Exception.h" "$(includedir)/Ice/LocalObject.h" "$(includedir)/IceUtil/ScopedArray.h" "$(includedir)/Ice/UndefSysMacros.h" "$(includedir)/Ice/PropertiesF.h" "$(includedir)/Ice/Proxy.h" "$(includedir)/IceUtil/Mutex.h" "$(includedir)/IceUtil/Lock.h" "$(includedir)/IceUtil/ThreadException.h" "$(includedir)/IceUtil/Time.h" "$(includedir)/IceUtil/MutexProtocol.h" "$(includedir)/Ice/ProxyFactoryF.h" "$(includedir)/Ice/ConnectionIF.h" "$(includedir)/Ice/RequestHandlerF.h" "$(includedir)/Ice/EndpointIF.h" "$(includedir)/Ice/EndpointF.h" "$(includedir)/Ice/EndpointTypes.h" "$(includedir)/Ice/ObjectAdapterF.h" "$(includedir)/Ice/ReferenceF.h" "$(includedir)/Ice/OutgoingAsync.h" "$(includedir)/IceUtil/Monitor.h" "$(includedir)/IceUtil/Cond.h" "$(includedir)/IceUtil/Timer.h" "$(includedir)/IceUtil/Thread.h" "$(includedir)/Ice/OutgoingAsyncF.h" "$(includedir)/Ice/InstanceF.h" "$(includedir)/Ice/Current.h" "$(includedir)/Ice/ConnectionF.h" "$(includedir)/Ice/Identity.h" "$(includedir)/Ice/BasicStream.h" "$(includedir)/Ice/ObjectFactoryF.h" "$(includedir)/Ice/Buffer.h" "$(includedir)/Ice/Protocol.h" "$(includedir)/Ice/StreamF.h" "$(includedir)/Ice/Object.h" "$(includedir)/Ice/GCShared.h" "$(includedir)/Ice/GCCountMap.h" "$(includedir)/Ice/IncomingAsyncF.h" "$(includedir)/Ice/LoggerF.h" "$(includedir)/Ice/StatsF.h" "$(includedir)/Ice/Dispatcher.h" "$(includedir)/Ice/StringConverter.h" "$(includedir)/Ice/Plugin.h" "$(includedir)/Ice/BuiltinSequences.h" "$(includedir)/Ice/Stream.h" "$(includedir)/IceUtil/Unicode.h" "$(includedir)/Ice/LocalException.h" "$(includedir)/Ice/Properties.h" "$(includedir)/Ice/Outgoing.h" "$(includedir)/Ice/Incoming.h" "$(includedir)/Ice/ServantLocatorF.h" "$(includedir)/Ice/ServantManagerF.h" "$(includedir)/Ice/Direct.h" "$(includedir)/Ice/Logger.h" "$(includedir)/Ice/LoggerUtil.h" "$(includedir)/Ice/Stats.h" "$(includedir)/Ice/Communicator.h" "$(includedir)/Ice/RouterF.h" "$(includedir)/Ice/LocatorF.h" "$(includedir)/Ice/PluginF.h" "$(includedir)/Ice/ImplicitContextF.h" "$(includedir)/Ice/CommunicatorAsync.h" "$(includedir)/Ice/ObjectFactory.h" "$(includedir)/Ice/ObjectAdapter.h" "$(includedir)/Ice/FacetMap.h" "$(includedir)/Ice/Endpoint.h" "$(includedir)/Ice/ServantLocator.h" "$(includedir)/Ice/IncomingAsync.h" "$(includedir)/Ice/Process.h" "$(includedir)/Ice/Application.h" "$(includedir)/Ice/Connection.h" "$(includedir)/Ice/ConnectionAsync.h" "$(includedir)/Ice/Functional.h" "$(includedir)/IceUtil/Functional.h" "$(includedir)/Ice/ImplicitContext.h" "$(includedir)/Ice/Locator.h" "$(includedir)/Ice/FactoryTableInit.h" "$(includedir)/Ice/FactoryTable.h" "$(includedir)/Ice/UserExceptionFactory.h" "$(includedir)/Ice/ProcessF.h" "$(includedir)/Ice/Router.h" "$(includedir)/Ice/DispatchInterceptor.h" "$(includedir)/Ice/IconvStringConverter.h" Test.h ../../include/TestCommon.h "$(includedir)/IceUtil/IceUtil.h" "$(includedir)/IceUtil/AbstractMutex.h" "$(includedir)/IceUtil/Cache.h" "$(includedir)/IceUtil/CountDownLatch.h" "$(includedir)/IceUtil/CtrlCHandler.h" "$(includedir)/IceUtil/MutexPtrLock.h" "$(includedir)/IceUtil/RecMutex.h" "$(includedir)/IceUtil/UUID.h" +Test$(OBJEXT): Test.cpp Test.h "$(includedir)/Ice/LocalObjectF.h" "$(includedir)/IceUtil/Shared.h" "$(includedir)/IceUtil/Config.h" "$(includedir)/Ice/Handle.h" "$(includedir)/IceUtil/Handle.h" "$(includedir)/IceUtil/Exception.h" "$(includedir)/Ice/Config.h" "$(includedir)/Ice/ProxyF.h" "$(includedir)/Ice/ProxyHandle.h" "$(includedir)/Ice/ObjectF.h" "$(includedir)/Ice/Exception.h" "$(includedir)/Ice/LocalObject.h" "$(includedir)/Ice/Proxy.h" "$(includedir)/IceUtil/Mutex.h" "$(includedir)/IceUtil/Lock.h" "$(includedir)/IceUtil/ThreadException.h" "$(includedir)/IceUtil/Time.h" "$(includedir)/IceUtil/MutexProtocol.h" "$(includedir)/Ice/ProxyFactoryF.h" "$(includedir)/Ice/ConnectionIF.h" "$(includedir)/Ice/RequestHandlerF.h" "$(includedir)/Ice/EndpointIF.h" "$(includedir)/Ice/EndpointF.h" "$(includedir)/IceUtil/ScopedArray.h" "$(includedir)/Ice/UndefSysMacros.h" "$(includedir)/Ice/EndpointTypes.h" "$(includedir)/Ice/ObjectAdapterF.h" "$(includedir)/Ice/ReferenceF.h" "$(includedir)/Ice/OutgoingAsync.h" "$(includedir)/IceUtil/Monitor.h" "$(includedir)/IceUtil/Cond.h" "$(includedir)/IceUtil/Timer.h" "$(includedir)/IceUtil/Thread.h" "$(includedir)/Ice/OutgoingAsyncF.h" "$(includedir)/Ice/InstanceF.h" "$(includedir)/Ice/CommunicatorF.h" "$(includedir)/Ice/Current.h" "$(includedir)/Ice/ConnectionF.h" "$(includedir)/Ice/Identity.h" "$(includedir)/Ice/BasicStream.h" "$(includedir)/Ice/ObjectFactoryF.h" "$(includedir)/Ice/Buffer.h" "$(includedir)/Ice/Protocol.h" "$(includedir)/Ice/StreamF.h" "$(includedir)/Ice/Object.h" "$(includedir)/Ice/GCShared.h" "$(includedir)/Ice/GCCountMap.h" "$(includedir)/Ice/IncomingAsyncF.h" "$(includedir)/Ice/Outgoing.h" "$(includedir)/Ice/Incoming.h" "$(includedir)/Ice/ServantLocatorF.h" "$(includedir)/Ice/ServantManagerF.h" "$(includedir)/Ice/Direct.h" "$(includedir)/Ice/FactoryTableInit.h" "$(includedir)/Ice/FactoryTable.h" "$(includedir)/Ice/UserExceptionFactory.h" "$(includedir)/Ice/LocalException.h" "$(includedir)/Ice/BuiltinSequences.h" "$(includedir)/Ice/Stream.h" "$(includedir)/Ice/ObjectFactory.h" "$(includedir)/IceUtil/Iterator.h" +Test.h Test.cpp: Test.ice "$(SLICE2CPP)" "$(SLICEPARSERLIB)" diff --git a/cpp/test/Ice/hash/.gitignore b/cpp/test/Ice/hash/.gitignore new file mode 100644 index 00000000000..d780341c0e4 --- /dev/null +++ b/cpp/test/Ice/hash/.gitignore @@ -0,0 +1,6 @@ +// Generated by makegitignore.py + +// IMPORTANT: Do not edit this file -- any edits made here will be lost! +client +Test.h +Test.cpp diff --git a/cpp/test/Ice/hash/Client.cpp b/cpp/test/Ice/hash/Client.cpp new file mode 100644 index 00000000000..833ce35dc9d --- /dev/null +++ b/cpp/test/Ice/hash/Client.cpp @@ -0,0 +1,139 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <IceUtil/Random.h> +#include <Test.h> +#include <TestCommon.h> + +using namespace std; +using namespace Test; + +DEFINE_TEST("client") + +int main(int argc, char** argv) +{ + cout << "testing proxy & endpoint hash algorithm collisions... " << flush; + map<Ice::Int, Ice::ObjectPrx> seenProxy; + map<Ice::Int, Ice::EndpointPtr> seenEndpoint; + unsigned int proxyCollisions = 0; + unsigned int endpointCollisions = 0; + unsigned int i = 0; + unsigned int maxCollisions = 10; + unsigned int maxIterations = 10000; + + Ice::InitializationData id; + id.properties = Ice::createProperties(argc, argv); +#ifndef ICE_OS_WINRT + // + // In Ice for WinRT IceSSL is part of Ice core. + // + id.properties->setProperty("Ice.Plugin.IceSSL", "IceSSL:createIceSSL"); +#endif + Ice::CommunicatorPtr communicator = Ice::initialize(id); + for(i = 0; proxyCollisions < maxCollisions && + endpointCollisions < maxCollisions && + i < maxIterations; ++i) + { + ostringstream os; + os << i << ":tcp -p " << IceUtilInternal::random(65536) << " -t 10" << IceUtilInternal::random(1000000) + << ":udp -p " << IceUtilInternal::random(65536) << " -h " << IceUtilInternal::random(100); + + Ice::ObjectPrx obj = communicator->stringToProxy(os.str()); + Ice::EndpointSeq endpoints = obj->ice_getEndpoints(); + if(!seenProxy.insert(make_pair(obj->ice_getHash(), obj)).second) + { + ++proxyCollisions; + } + test(obj->ice_getHash() == obj->ice_getHash()); + + for(Ice::EndpointSeq::const_iterator j = endpoints.begin(); j != endpoints.end(); ++j) + { + Ice::EndpointPtr endpoint = (*j); + if(!seenEndpoint.insert(make_pair(endpoint->ice_getHash(), endpoint)).second) + { + if(endpoint == seenEndpoint[endpoint->ice_getHash()]) + { + continue; // Same object + } + ++endpointCollisions; + } + test(endpoint->ice_getHash() == endpoint->ice_getHash()); + } + } + test(proxyCollisions < maxCollisions); + test(endpointCollisions < maxCollisions); + + // + // Check the same proxy produce the same hash, even when we recreate the proxy. + // + Ice::ObjectPrx prx1 = communicator->stringToProxy("Glacier2/router:tcp -p 10010"); + Ice::ObjectPrx prx2 = communicator->stringToProxy("Glacier2/router:ssl -p 10011"); + Ice::ObjectPrx prx3 = communicator->stringToProxy("Glacier2/router:udp -p 10012"); + Ice::ObjectPrx prx4 = communicator->stringToProxy("Glacier2/router:tcp -h zeroc.com -p 10010"); + Ice::ObjectPrx prx5 = communicator->stringToProxy("Glacier2/router:ssl -h zeroc.com -p 10011"); + Ice::ObjectPrx prx6 = communicator->stringToProxy("Glacier2/router:udp -h zeroc.com -p 10012"); + Ice::ObjectPrx prx7 = communicator->stringToProxy("Glacier2/router:tcp -p 10010 -t 10000"); + Ice::ObjectPrx prx8 = communicator->stringToProxy("Glacier2/router:ssl -p 10011 -t 10000"); + Ice::ObjectPrx prx9 = communicator->stringToProxy("Glacier2/router:tcp -h zeroc.com -p 10010 -t 10000"); + Ice::ObjectPrx prx10 = communicator->stringToProxy("Glacier2/router:ssl -h zeroc.com -p 10011 -t 10000"); + + map<string, int> proxyMap; + proxyMap["prx1"] = prx1->ice_getHash(); + proxyMap["prx2"] = prx2->ice_getHash(); + proxyMap["prx3"] = prx3->ice_getHash(); + proxyMap["prx4"] = prx4->ice_getHash(); + proxyMap["prx5"] = prx5->ice_getHash(); + proxyMap["prx6"] = prx6->ice_getHash(); + proxyMap["prx7"] = prx7->ice_getHash(); + proxyMap["prx8"] = prx8->ice_getHash(); + proxyMap["prx9"] = prx9->ice_getHash(); + proxyMap["prx10"] = prx10->ice_getHash(); + + test( communicator->stringToProxy("Glacier2/router:tcp -p 10010")->ice_getHash() == proxyMap["prx1"]); + test( communicator->stringToProxy("Glacier2/router:ssl -p 10011")->ice_getHash() == proxyMap["prx2"]); + test( communicator->stringToProxy("Glacier2/router:udp -p 10012")->ice_getHash() == proxyMap["prx3"]); + test( communicator->stringToProxy("Glacier2/router:tcp -h zeroc.com -p 10010")->ice_getHash() == proxyMap["prx4"]); + test( communicator->stringToProxy("Glacier2/router:ssl -h zeroc.com -p 10011")->ice_getHash() == proxyMap["prx5"]); + test( communicator->stringToProxy("Glacier2/router:udp -h zeroc.com -p 10012")->ice_getHash() == proxyMap["prx6"]); + test( communicator->stringToProxy("Glacier2/router:tcp -p 10010 -t 10000")->ice_getHash() == proxyMap["prx7"]); + test( communicator->stringToProxy("Glacier2/router:ssl -p 10011 -t 10000")->ice_getHash() == proxyMap["prx8"]); + test( communicator->stringToProxy("Glacier2/router:tcp -h zeroc.com -p 10010 -t 10000")->ice_getHash() == proxyMap["prx9"]); + test( communicator->stringToProxy("Glacier2/router:ssl -h zeroc.com -p 10011 -t 10000")->ice_getHash() == proxyMap["prx10"]); + + cerr << "ok" << endl; + + cout << "testing objects hash algorithm collisions... " << flush; + unsigned int objectCollisions = 0; + map<Ice::Int, Ice::ObjectPtr> seenObject; + for(i = 0; objectCollisions < maxCollisions && i < maxIterations; ++i) + { + Ice::ObjectPtr obj = new Point; + if(!seenObject.insert(make_pair(obj->ice_getHash(), obj)).second) + { + ++objectCollisions; + } + test(obj->ice_getHash() == obj->ice_getHash()); + } + test(objectCollisions < maxCollisions); + + cerr << "ok" << endl; + if(communicator) + { + try + { + communicator->destroy(); + } + catch(const Ice::LocalException& ex) + { + cerr << ex << endl; + } + } + return EXIT_SUCCESS; +} diff --git a/cpp/test/Ice/hash/Makefile b/cpp/test/Ice/hash/Makefile new file mode 100644 index 00000000000..250beb61bf6 --- /dev/null +++ b/cpp/test/Ice/hash/Makefile @@ -0,0 +1,33 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +top_srcdir = ../../.. + +CLIENT = client + +TARGETS = $(CLIENT) + +COBJS = Client.o + +OBJS = Test.o + +SRCS = $(COBJS:.o=.cpp) \ + $(OBJS:.o=.cpp) + +SLICE_SRCS = Test.ice + +include $(top_srcdir)/config/Make.rules + +CPPFLAGS := -I. -I../../include $(CPPFLAGS) + +$(CLIENT): $(OBJS) $(COBJS) + rm -f $@ + $(CXX) $(LDFLAGS) -o $@ $(COBJS) $(OBJS) $(LIBS) + +include .depend diff --git a/cpp/test/Ice/hash/Makefile.mak b/cpp/test/Ice/hash/Makefile.mak new file mode 100644 index 00000000000..b231eda718d --- /dev/null +++ b/cpp/test/Ice/hash/Makefile.mak @@ -0,0 +1,49 @@ +# **********************************************************************
+#
+# Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+top_srcdir = ..\..\..
+
+!if "$(WINRT)" != "yes"
+NAME_PREFIX =
+EXT = .exe
+!else
+NAME_PREFIX = Ice_hash_
+EXT = .dll
+!endif
+
+CLIENT = $(NAME_PREFIX)client
+
+TARGETS = $(CLIENT)$(EXT)
+
+COBJS = Test.obj \
+ Client.obj
+
+SRCS = $(COBJS:.obj=.cpp)
+
+!include $(top_srcdir)/config/Make.rules.mak
+
+CPPFLAGS = -I. -I../../include $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN
+
+
+!if "$(WINRT)" != "yes"
+LD_TESTFLAGS = $(LD_EXEFLAGS) $(SETARGV)
+!else
+LD_TESTFLAGS = $(LD_DLLFLAGS) /export:dllMain
+!endif
+
+!if "$(GENERATE_PDB)" == "yes"
+CPDBFLAGS = /pdb:$(CLIENT).pdb
+!endif
+
+$(CLIENT)$(EXT): $(COBJS)
+ $(LINK) $(LD_TESTFLAGS) $(CPDBFLAGS) $(SETARGV) $(COBJS) $(PREOUT)$@ $(PRELIBS)$(LIBS)
+ @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \
+ $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest
+
+!include .depend.mak
diff --git a/cpp/test/Ice/hash/Test.ice b/cpp/test/Ice/hash/Test.ice new file mode 100644 index 00000000000..0bc77e005b6 --- /dev/null +++ b/cpp/test/Ice/hash/Test.ice @@ -0,0 +1,20 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#pragma once + +module Test +{ + +class Point +{ +}; + +}; + diff --git a/cpp/test/Ice/hash/run.py b/cpp/test/Ice/hash/run.py new file mode 100755 index 00000000000..efb892821a7 --- /dev/null +++ b/cpp/test/Ice/hash/run.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import os, sys + +path = [ ".", "..", "../..", "../../..", "../../../.." ] +head = os.path.dirname(sys.argv[0]) +if len(head) > 0: + path = [os.path.join(head, p) for p in path] +path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] +if len(path) == 0: + raise "can't find toplevel directory!" +sys.path.append(os.path.join(path[0], "scripts")) +import TestUtil + +TestUtil.simpleTest() diff --git a/cpp/test/Ice/hold/Test.ice b/cpp/test/Ice/hold/Test.ice index 3801bfebb83..1c3b28cc971 100644 --- a/cpp/test/Ice/hold/Test.ice +++ b/cpp/test/Ice/hold/Test.ice @@ -16,8 +16,8 @@ interface Hold { void putOnHold(int seconds); void waitForHold(); - ["ami"] int set(int value, int delay); void setOneway(int value, int expected); + int set(int value, int delay); void shutdown(); }; diff --git a/cpp/test/Ice/info/Makefile.mak b/cpp/test/Ice/info/Makefile.mak index 683d8b5d0b8..bfafa223556 100644 --- a/cpp/test/Ice/info/Makefile.mak +++ b/cpp/test/Ice/info/Makefile.mak @@ -40,7 +40,7 @@ CPPFLAGS = -I. -I../../include $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN !if "$(WINRT)" != "yes"
LD_TESTFLAGS = $(LD_EXEFLAGS) $(SETARGV)
-LIBS = $(LIBS) icessl$(LIBSUFFIX).lib
+LIBS = $(LIBS) icessl$(LIBSUFFIX).lib
!else
LD_TESTFLAGS = $(LD_DLLFLAGS) /export:dllMain
!endif
diff --git a/cpp/test/Ice/invoke/AllTests.cpp b/cpp/test/Ice/invoke/AllTests.cpp index b51ab5469a7..5b8cde9fc4b 100644 --- a/cpp/test/Ice/invoke/AllTests.cpp +++ b/cpp/test/Ice/invoke/AllTests.cpp @@ -155,6 +155,26 @@ public: test(false); } } + + void opStringPairNC(bool ok, const pair<const Ice::Byte*, const Ice::Byte*>& outParams) + { + if(ok) + { + Ice::InputStreamPtr in = Ice::createInputStream(_communicator, outParams); + in->startEncapsulation(); + string s; + in->read(s); + test(s == testString); + in->read(s); + test(s == testString); + in->endEncapsulation(); + called(); + } + else + { + test(false); + } + } void opStringWC(bool ok, const Ice::ByteSeq& outParams, const CookiePtr& cookie) { @@ -201,6 +221,32 @@ public: } } } + + void opExceptionPairNC(bool ok, const pair<const Ice::Byte*, const Ice::Byte*>& outParams) + { + if(ok) + { + test(false); + } + else + { + Ice::InputStreamPtr in = Ice::createInputStream(_communicator, outParams); + in->startEncapsulation(); + try + { + in->throwException(); + } + catch(const Test::MyException&) + { + in->endEncapsulation(); + called(); + } + catch(...) + { + test(false); + } + } + } void opExceptionWC(bool ok, const Ice::ByteSeq& outParams, const CookiePtr& cookie) { @@ -479,6 +525,59 @@ allTests(const Ice::CommunicatorPtr& communicator) } cout << "ok" << endl; +#ifdef ICE_CPP11 + cout << "testing asynchronous ice_invoke with C++11 style callbacks... " << flush; + + { + Ice::ByteSeq inEncaps, outEncaps; + Ice::OutputStreamPtr out = Ice::createOutputStream(communicator); + out->startEncapsulation(); + out->write(testString); + out->endEncapsulation(); + out->finished(inEncaps); + + CallbackPtr cb = new Callback(communicator, false); + Ice::Context ctx; + cl->begin_ice_invoke("opString", Ice::Normal, inEncaps, ctx, + [=](bool ret, const vector< ::Ice::Byte>& args) + { + cb->opStringNC(ret, args); + }); + cb->check(); + + cb = new Callback(communicator, false); + pair<const ::Ice::Byte*, const ::Ice::Byte*> inPair(&inEncaps[0], &inEncaps[0] + inEncaps.size()); + cl->begin_ice_invoke("opString", Ice::Normal, inPair, + [=](bool ret, const pair<const Ice::Byte*, const Ice::Byte*>& args) + { + cb->opStringPairNC(ret, args); + }); + cb->check(); + } + + { + Ice::ByteSeq inEncaps, outEncaps; + CallbackPtr cb = new Callback(communicator, false); + cl->begin_ice_invoke("opException", Ice::Normal, inEncaps, + [=](bool ret, const vector< ::Ice::Byte>& args) + { + cb->opExceptionNC(ret, args); + } + ); + cb->check(); + + pair<const ::Ice::Byte*, const ::Ice::Byte*> inPair(static_cast< ::Ice::Byte*>(0), static_cast< ::Ice::Byte*>(0)); + cb = new Callback(communicator, false); + cl->begin_ice_invoke("opException", Ice::Normal, inPair, + [=](bool ret, const pair<const Ice::Byte*, const Ice::Byte*>& args) + { + cb->opExceptionPairNC(ret, args); + }); + cb->check(); + } + + cout << "ok" << endl; +#endif return cl; } diff --git a/cpp/test/Ice/location/Test.ice b/cpp/test/Ice/location/Test.ice index 259770847d3..bdb5c20f65f 100644 --- a/cpp/test/Ice/location/Test.ice +++ b/cpp/test/Ice/location/Test.ice @@ -38,7 +38,7 @@ interface ServerManager interface Hello { - ["ami"] void sayHello(); + void sayHello(); }; interface TestIntf diff --git a/cpp/test/Ice/objects/AllTests.cpp b/cpp/test/Ice/objects/AllTests.cpp index 9945eee5735..d1eb70a22de 100644 --- a/cpp/test/Ice/objects/AllTests.cpp +++ b/cpp/test/Ice/objects/AllTests.cpp @@ -14,6 +14,14 @@ using namespace std; using namespace Test; +class AbstractBaseI : public AbstractBase +{ +public: + + virtual void op(const Ice::Current&) + {} +}; + void testUOE(const Ice::CommunicatorPtr& communicator) { @@ -81,6 +89,23 @@ allTests(const Ice::CommunicatorPtr& communicator, bool collocated) cout << "ok" << endl; + cout << "testing ice_clone..." << flush; + + BasePtr bp2 = BasePtr::dynamicCast(bp1->ice_clone()); + test(bp1->theS.str == bp2->theS.str); + test(bp1->str == bp2->str); + + AbstractBasePtr abp1 = new AbstractBaseI; + try + { + abp1->ice_clone(); + test(false); + } + catch(const Ice::CloneNotImplementedException&) + { + } + cout << "ok" << endl; + cout << "getting B1... " << flush; BPtr b1 = initial->getB1(); test(b1); diff --git a/cpp/test/Ice/objects/Test.ice b/cpp/test/Ice/objects/Test.ice index 89a12b4e56d..54e7df966f1 100644 --- a/cpp/test/Ice/objects/Test.ice +++ b/cpp/test/Ice/objects/Test.ice @@ -23,6 +23,11 @@ class Base string str; }; +class AbstractBase extends Base +{ + void op(); +}; + class B; class C; diff --git a/cpp/test/Ice/operations/OnewaysNewAMI.cpp b/cpp/test/Ice/operations/OnewaysNewAMI.cpp index 21127c66d3c..e82afcab5f9 100644 --- a/cpp/test/Ice/operations/OnewaysNewAMI.cpp +++ b/cpp/test/Ice/operations/OnewaysNewAMI.cpp @@ -85,7 +85,7 @@ onewaysNewAMI(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& Test::MyClassPrx p = Test::MyClassPrx::uncheckedCast(proxy->ice_oneway()); { - CallbackPtr cb = new Callback; + CallbackPtr cb = new Callback; Ice::Callback_Object_ice_pingPtr callback = Ice::newCallback_Object_ice_ping(cb, &Callback::noException, &Callback::sent); p->begin_ice_ping(callback); @@ -159,4 +159,81 @@ onewaysNewAMI(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& { } } +#ifdef ICE_CPP11 + { + CallbackPtr cb = new Callback; + p->begin_ice_ping(nullptr, + [=](const Ice::Exception& ex){ cb->noException(ex); }, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + } + + { + try + { + p->begin_ice_isA(Test::MyClass::ice_staticId(), [=](bool){ test(false); }); + test(false); + } + catch(const IceUtil::IllegalArgumentException&) + { + } + } + + { + try + { + p->begin_ice_id([=](const string&){ test(false); }); + test(false); + } + catch(const IceUtil::IllegalArgumentException&) + { + } + } + + { + try + { + p->begin_ice_ids([=](const Ice::StringSeq&){ test(false); }); + test(false); + } + catch(const IceUtil::IllegalArgumentException&) + { + } + } + + { + CallbackPtr cb = new Callback; + p->begin_opVoid(nullptr, + [=](const Ice::Exception& ex){ cb->noException(ex); }, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + } + + { + CallbackPtr cb = new Callback; + p->begin_opIdempotent(nullptr, + [=](const Ice::Exception& ex){ cb->noException(ex); }, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + } + + { + CallbackPtr cb = new Callback; + p->begin_opNonmutating(nullptr, + [=](const Ice::Exception& ex){ cb->noException(ex); }, + [=](bool sent){ cb->sent(sent); }); + cb->check(); + } + + { + try + { + p->begin_opByte(Ice::Byte(0xff), Ice::Byte(0x0f), [=](const Ice::Byte&, const Ice::Byte&){ test(false); }); + test(false); + } + catch(const IceUtil::IllegalArgumentException&) + { + } + } +#endif } diff --git a/cpp/test/Ice/operations/TwowaysNewAMI.cpp b/cpp/test/Ice/operations/TwowaysNewAMI.cpp index 0b156c55651..212bc12d6fd 100644 --- a/cpp/test/Ice/operations/TwowaysNewAMI.cpp +++ b/cpp/test/Ice/operations/TwowaysNewAMI.cpp @@ -556,8 +556,6 @@ twowaysNewAMI(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& } { - Ice::Double d = 1278312346.0 / 13.0; - Test::DoubleS ds(5, d); CallbackPtr cb = new Callback; Test::Callback_MyClass_opBytePtr callback = Test::newCallback_MyClass_opByte(cb, &Callback::opByte, @@ -566,16 +564,6 @@ twowaysNewAMI(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& cb->check(); } - - { - CallbackPtr cb = new Callback; - Test::Callback_MyClass_opVoidPtr callback = Test::newCallback_MyClass_opVoid(cb, - &Callback::opVoid, - &Callback::exCB); - p->begin_opVoid(callback); - cb->check(); - } - { CallbackPtr cb = new Callback; Test::Callback_MyClass_opBoolPtr callback = Test::newCallback_MyClass_opBool(cb, @@ -1067,4 +1055,497 @@ twowaysNewAMI(const Ice::CommunicatorPtr& communicator, const Test::MyClassPrx& derived->begin_opDerived(callback); cb->check(); } +#ifdef ICE_CPP11 + { + CallbackPtr cb = new Callback; + p->begin_ice_ping([=](){ cb->ping(); }, [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + CallbackPtr cb = new Callback; + p->begin_ice_isA(Test::MyClass::ice_staticId(), [=](bool isA){ cb->isA(isA); }, [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + CallbackPtr cb = new Callback; + p->begin_ice_id([=](const string& id){ cb->id(id); }, [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + CallbackPtr cb = new Callback; + p->begin_ice_ids([=](const Ice::StringSeq& ids){ cb->ids(ids); }, [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + CallbackPtr cb = new Callback; + p->begin_opVoid([=](){ cb->opVoid(); }, [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + CallbackPtr cb = new Callback; + p->begin_opByte(Ice::Byte(0xff), Ice::Byte(0x0f), + [=](const Ice::Byte& p1, const Ice::Byte& p2){ cb->opByte(p1, p2); }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + CallbackPtr cb = new Callback; + Test::Callback_MyClass_opBoolPtr callback = Test::newCallback_MyClass_opBool(cb, + &Callback::opBool, + &Callback::exCB); + p->begin_opBool(true, false, [=](bool p1, bool p2){ cb->opBool(p1, p2); }, [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + CallbackPtr cb = new Callback; + p->begin_opShortIntLong(10, 11, 12, + [=](Ice::Long p1, Ice::Short p2, Ice::Int p3, Ice::Long p4){ cb->opShortIntLong(p1, p2, p3, p4); }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + CallbackPtr cb = new Callback; + p->begin_opFloatDouble(Ice::Float(3.14), Ice::Double(1.1E10), + [=](Ice::Double p1, Ice::Float p2, Ice::Double p3){ cb->opFloatDouble(p1, p2, p3); }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + CallbackPtr cb = new Callback; + p->begin_opString("hello", "world", + [=](const string& p1, const string& p2){ cb->opString(p1, p2); }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + CallbackPtr cb = new Callback; + p->begin_opMyEnum(Test::enum2, + [=](Test::MyEnum p1, Test::MyEnum p2){ cb->opMyEnum(p1, p2); }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + CallbackPtr cb = new Callback(communicator); + p->begin_opMyClass(p, + [=](const Test::MyClassPrx& p1, const Test::MyClassPrx p2, const Test::MyClassPrx p3) + { + cb->opMyClass(p1, p2, p3); + }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + Test::Structure si1; + si1.p = p; + si1.e = Test::enum3; + si1.s.s = "abc"; + Test::Structure si2; + si2.p = 0; + si2.e = Test::enum2; + si2.s.s = "def"; + + CallbackPtr cb = new Callback(communicator); + p->begin_opStruct(si1, si2, + [=](const Test::Structure& p1, const Test::Structure& p2) + { + cb->opStruct(p1, p2); + }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + Test::ByteS bsi1; + Test::ByteS bsi2; + + bsi1.push_back(Ice::Byte(0x01)); + bsi1.push_back(Ice::Byte(0x11)); + bsi1.push_back(Ice::Byte(0x12)); + bsi1.push_back(Ice::Byte(0x22)); + + bsi2.push_back(Ice::Byte(0xf1)); + bsi2.push_back(Ice::Byte(0xf2)); + bsi2.push_back(Ice::Byte(0xf3)); + bsi2.push_back(Ice::Byte(0xf4)); + + CallbackPtr cb = new Callback; + Test::Callback_MyClass_opByteSPtr callback = Test::newCallback_MyClass_opByteS(cb, + &Callback::opByteS, + &Callback::exCB); + p->begin_opByteS(bsi1, bsi2, + [=](const Test::ByteS& p1, const Test::ByteS& p2) + { + cb->opByteS(p1, p2); + }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + Test::BoolS bsi1; + Test::BoolS bsi2; + + bsi1.push_back(true); + bsi1.push_back(true); + bsi1.push_back(false); + + bsi2.push_back(false); + + CallbackPtr cb = new Callback; + p->begin_opBoolS(bsi1, bsi2, + [=](const Test::BoolS& p1, const Test::BoolS& p2) + { + cb->opBoolS(p1, p2); + }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + Test::ShortS ssi; + Test::IntS isi; + Test::LongS lsi; + + ssi.push_back(1); + ssi.push_back(2); + ssi.push_back(3); + + isi.push_back(5); + isi.push_back(6); + isi.push_back(7); + isi.push_back(8); + + lsi.push_back(10); + lsi.push_back(30); + lsi.push_back(20); + + CallbackPtr cb = new Callback; + p->begin_opShortIntLongS(ssi, isi, lsi, + [=](const Test::LongS& p1, const Test::ShortS& p2, const Test::IntS& p3, const Test::LongS& p4) + { + cb->opShortIntLongS(p1, p2, p3, p4); + }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + Test::FloatS fsi; + Test::DoubleS dsi; + + fsi.push_back(Ice::Float(3.14)); + fsi.push_back(Ice::Float(1.11)); + + dsi.push_back(Ice::Double(1.1E10)); + dsi.push_back(Ice::Double(1.2E10)); + dsi.push_back(Ice::Double(1.3E10)); + + CallbackPtr cb = new Callback; + p->begin_opFloatDoubleS(fsi, dsi, + [=](const Test::DoubleS& p1, const Test::FloatS& p2, const Test::DoubleS& p3) + { + cb->opFloatDoubleS(p1, p2, p3); + }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + Test::StringS ssi1; + Test::StringS ssi2; + + ssi1.push_back("abc"); + ssi1.push_back("de"); + ssi1.push_back("fghi"); + + ssi2.push_back("xyz"); + + CallbackPtr cb = new Callback; + p->begin_opStringS(ssi1, ssi2, + [=](const Test::StringS& p1, const Test::StringS& p2) + { + cb->opStringS(p1, p2); + }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + Test::ByteSS bsi1; + bsi1.resize(2); + Test::ByteSS bsi2; + bsi2.resize(2); + + bsi1[0].push_back(Ice::Byte(0x01)); + bsi1[0].push_back(Ice::Byte(0x11)); + bsi1[0].push_back(Ice::Byte(0x12)); + bsi1[1].push_back(Ice::Byte(0xff)); + + bsi2[0].push_back(Ice::Byte(0x0e)); + bsi2[1].push_back(Ice::Byte(0xf2)); + bsi2[1].push_back(Ice::Byte(0xf1)); + + CallbackPtr cb = new Callback; + p->begin_opByteSS(bsi1, bsi2, + [=](const Test::ByteSS& p1, const Test::ByteSS& p2) + { + cb->opByteSS(p1, p2); + }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + Test::FloatSS fsi; + fsi.resize(3); + Test::DoubleSS dsi; + dsi.resize(1); + + fsi[0].push_back(Ice::Float(3.14)); + fsi[1].push_back(Ice::Float(1.11)); + + dsi[0].push_back(Ice::Double(1.1E10)); + dsi[0].push_back(Ice::Double(1.2E10)); + dsi[0].push_back(Ice::Double(1.3E10)); + + CallbackPtr cb = new Callback; + p->begin_opFloatDoubleSS(fsi, dsi, + [=](const Test::DoubleSS& p1, const Test::FloatSS& p2, const Test::DoubleSS& p3) + { + cb->opFloatDoubleSS(p1, p2, p3); + }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + Test::StringSS ssi1; + ssi1.resize(2); + Test::StringSS ssi2; + ssi2.resize(3); + + ssi1[0].push_back("abc"); + ssi1[1].push_back("de"); + ssi1[1].push_back("fghi"); + + ssi2[2].push_back("xyz"); + + CallbackPtr cb = new Callback; + p->begin_opStringSS(ssi1, ssi2, + [=](const Test::StringSS& p1, const Test::StringSS& p2) + { + cb->opStringSS(p1, p2); + }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + Test::ByteBoolD di1; + di1[10] = true; + di1[100] = false; + Test::ByteBoolD di2; + di2[10] = true; + di2[11] = false; + di2[101] = true; + + CallbackPtr cb = new Callback; + p->begin_opByteBoolD(di1, di2, + [=](const Test::ByteBoolD& p1, const Test::ByteBoolD& p2) + { + cb->opByteBoolD(p1, p2); + }, + [=](const Ice::Exception& ex) + { + cb->exCB(ex); + }); + cb->check(); + } + + { + Test::ShortIntD di1; + di1[110] = -1; + di1[1100] = 123123; + Test::ShortIntD di2; + di2[110] = -1; + di2[111] = -100; + di2[1101] = 0; + + CallbackPtr cb = new Callback; + p->begin_opShortIntD(di1, di2, + [=](const Test::ShortIntD& p1, const Test::ShortIntD& p2) + { + cb->opShortIntD(p1, p2); + }, + [=](const Ice::Exception& ex) + { + cb->exCB(ex); + }); + cb->check(); + } + + { + Test::LongFloatD di1; + di1[999999110] = Ice::Float(-1.1); + di1[999999111] = Ice::Float(123123.2); + Test::LongFloatD di2; + di2[999999110] = Ice::Float(-1.1); + di2[999999120] = Ice::Float(-100.4); + di2[999999130] = Ice::Float(0.5); + + CallbackPtr cb = new Callback; + p->begin_opLongFloatD(di1, di2, + [=](const Test::LongFloatD& p1, const Test::LongFloatD& p2) + { + cb->opLongFloatD(p1, p2); + }, + [=](const Ice::Exception& ex) + { + cb->exCB(ex); + }); + cb->check(); + } + + { + Test::StringStringD di1; + di1["foo"] = "abc -1.1"; + di1["bar"] = "abc 123123.2"; + Test::StringStringD di2; + di2["foo"] = "abc -1.1"; + di2["FOO"] = "abc -100.4"; + di2["BAR"] = "abc 0.5"; + + CallbackPtr cb = new Callback; + p->begin_opStringStringD(di1, di2, + [=](const Test::StringStringD& p1, const Test::StringStringD& p2) + { + cb->opStringStringD(p1, p2); + }, + [=](const Ice::Exception& ex) + { + cb->exCB(ex); + }); + cb->check(); + } + + { + Test::StringMyEnumD di1; + di1["abc"] = Test::enum1; + di1[""] = Test::enum2; + Test::StringMyEnumD di2; + di2["abc"] = Test::enum1; + di2["qwerty"] = Test::enum3; + di2["Hello!!"] = Test::enum2; + + CallbackPtr cb = new Callback; + p->begin_opStringMyEnumD(di1, di2, + [=](const Test::StringMyEnumD& p1, const Test::StringMyEnumD& p2) + { + cb->opStringMyEnumD(p1, p2); + }, + [=](const Ice::Exception& ex) + { + cb->exCB(ex); + }); + cb->check(); + } + + { + Test::MyStruct s11 = { 1, 1 }; + Test::MyStruct s12 = { 1, 2 }; + Test::MyStructMyEnumD di1; + di1[s11] = Test::enum1; + di1[s12] = Test::enum2; + + Test::MyStruct s22 = { 2, 2 }; + Test::MyStruct s23 = { 2, 3 }; + Test::MyStructMyEnumD di2; + di2[s11] = Test::enum1; + di2[s22] = Test::enum3; + di2[s23] = Test::enum2; + + CallbackPtr cb = new Callback; + p->begin_opMyStructMyEnumD(di1, di2, + [=](const Test::MyStructMyEnumD& p1, const Test::MyStructMyEnumD& p2) + { + cb->opMyStructMyEnumD(p1, p2); + }, + [=](const Ice::Exception& ex) + { + cb->exCB(ex); + }); + cb->check(); + } + + { + const int lengths[] = { 0, 1, 2, 126, 127, 128, 129, 253, 254, 255, 256, 257, 1000 }; + + for(unsigned int l = 0; l != sizeof(lengths) / sizeof(*lengths); ++l) + { + Test::IntS s; + for(int i = 0; i < lengths[l]; ++i) + { + s.push_back(i); + } + CallbackPtr cb = new Callback; + p->begin_opIntS(s, + [=](const Test::IntS& p1) + { + cb->opIntS(p1); + }, + [=](const Ice::Exception& ex) + { + cb->exCB(ex); + }); + cb->check(); + } + } + + { + Ice::Double d = 1278312346.0 / 13.0; + Test::DoubleS ds(5, d); + CallbackPtr cb = new Callback; + p->begin_opDoubleMarshaling(d, ds, + [=](){ cb->opDoubleMarshaling(); }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + CallbackPtr cb = new Callback; + Test::Callback_MyClass_opIdempotentPtr callback = + Test::newCallback_MyClass_opIdempotent(cb, &Callback::opIdempotent, &Callback::exCB); + p->begin_opIdempotent([=](){ cb->opIdempotent(); }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + CallbackPtr cb = new Callback; + p->begin_opNonmutating([=](){ cb->opNonmutating(); }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } + + { + Test::MyDerivedClassPrx derived = Test::MyDerivedClassPrx::checkedCast(p); + test(derived); + CallbackPtr cb = new Callback; + derived->begin_opDerived([=](){ cb->opDerived(); }, + [=](const Ice::Exception& ex){ cb->exCB(ex); }); + cb->check(); + } +#endif } diff --git a/cpp/test/Ice/plugin/.depend b/cpp/test/Ice/plugin/.depend new file mode 100644 index 00000000000..1d479e875ec --- /dev/null +++ b/cpp/test/Ice/plugin/.depend @@ -0,0 +1 @@ +Plugin$(OBJEXT): Plugin.cpp $(includedir)/Ice/Ice.h $(includedir)/Ice/Initialize.h $(includedir)/Ice/CommunicatorF.h $(includedir)/Ice/LocalObjectF.h $(includedir)/IceUtil/Shared.h $(includedir)/IceUtil/Config.h $(includedir)/Ice/Handle.h $(includedir)/IceUtil/Handle.h $(includedir)/IceUtil/Exception.h $(includedir)/Ice/Config.h $(includedir)/Ice/ProxyF.h $(includedir)/Ice/ProxyHandle.h $(includedir)/Ice/ObjectF.h $(includedir)/Ice/Exception.h $(includedir)/Ice/LocalObject.h $(includedir)/IceUtil/ScopedArray.h $(includedir)/Ice/UndefSysMacros.h $(includedir)/Ice/PropertiesF.h $(includedir)/Ice/Proxy.h $(includedir)/IceUtil/Mutex.h $(includedir)/IceUtil/Lock.h $(includedir)/IceUtil/ThreadException.h $(includedir)/IceUtil/Time.h $(includedir)/IceUtil/MutexProtocol.h $(includedir)/Ice/ProxyFactoryF.h $(includedir)/Ice/ConnectionIF.h $(includedir)/Ice/RequestHandlerF.h $(includedir)/Ice/EndpointIF.h $(includedir)/Ice/EndpointF.h $(includedir)/Ice/EndpointTypes.h $(includedir)/Ice/ObjectAdapterF.h $(includedir)/Ice/ReferenceF.h $(includedir)/Ice/OutgoingAsync.h $(includedir)/IceUtil/Monitor.h $(includedir)/IceUtil/Cond.h $(includedir)/IceUtil/Timer.h $(includedir)/IceUtil/Thread.h $(includedir)/Ice/OutgoingAsyncF.h $(includedir)/Ice/InstanceF.h $(includedir)/Ice/Current.h $(includedir)/Ice/ConnectionF.h $(includedir)/Ice/Identity.h $(includedir)/Ice/BasicStream.h $(includedir)/Ice/ObjectFactoryF.h $(includedir)/Ice/Buffer.h $(includedir)/Ice/Protocol.h $(includedir)/Ice/StreamF.h $(includedir)/Ice/Object.h $(includedir)/Ice/GCShared.h $(includedir)/Ice/GCCountMap.h $(includedir)/Ice/IncomingAsyncF.h $(includedir)/Ice/LoggerF.h $(includedir)/Ice/StatsF.h $(includedir)/Ice/Dispatcher.h $(includedir)/Ice/StringConverter.h $(includedir)/Ice/Plugin.h $(includedir)/Ice/BuiltinSequences.h $(includedir)/Ice/Stream.h $(includedir)/IceUtil/Unicode.h $(includedir)/Ice/LocalException.h $(includedir)/Ice/Properties.h $(includedir)/Ice/Outgoing.h $(includedir)/Ice/Incoming.h $(includedir)/Ice/ServantLocatorF.h $(includedir)/Ice/ServantManagerF.h $(includedir)/Ice/Direct.h $(includedir)/Ice/Logger.h $(includedir)/Ice/LoggerUtil.h $(includedir)/Ice/Stats.h $(includedir)/Ice/Communicator.h $(includedir)/Ice/RouterF.h $(includedir)/Ice/LocatorF.h $(includedir)/Ice/PluginF.h $(includedir)/Ice/ImplicitContextF.h $(includedir)/Ice/CommunicatorAsync.h $(includedir)/Ice/ObjectFactory.h $(includedir)/Ice/ObjectAdapter.h $(includedir)/Ice/FacetMap.h $(includedir)/Ice/Endpoint.h $(includedir)/Ice/ServantLocator.h $(includedir)/Ice/IncomingAsync.h $(includedir)/Ice/Process.h $(includedir)/Ice/Application.h $(includedir)/Ice/Connection.h $(includedir)/Ice/ConnectionAsync.h $(includedir)/Ice/Functional.h $(includedir)/IceUtil/Functional.h $(includedir)/Ice/ImplicitContext.h $(includedir)/Ice/Locator.h $(includedir)/Ice/FactoryTableInit.h $(includedir)/Ice/FactoryTable.h $(includedir)/Ice/UserExceptionFactory.h $(includedir)/Ice/ProcessF.h $(includedir)/Ice/Router.h $(includedir)/Ice/DispatchInterceptor.h $(includedir)/Ice/IconvStringConverter.h ../../include/TestCommon.h diff --git a/cpp/test/Ice/plugin/.depend.mak b/cpp/test/Ice/plugin/.depend.mak new file mode 100644 index 00000000000..e02b2718caf --- /dev/null +++ b/cpp/test/Ice/plugin/.depend.mak @@ -0,0 +1 @@ +Plugin$(OBJEXT): Plugin.cpp "$(includedir)/Ice/Ice.h" "$(includedir)/Ice/Initialize.h" "$(includedir)/Ice/CommunicatorF.h" "$(includedir)/Ice/LocalObjectF.h" "$(includedir)/IceUtil/Shared.h" "$(includedir)/IceUtil/Config.h" "$(includedir)/Ice/Handle.h" "$(includedir)/IceUtil/Handle.h" "$(includedir)/IceUtil/Exception.h" "$(includedir)/Ice/Config.h" "$(includedir)/Ice/ProxyF.h" "$(includedir)/Ice/ProxyHandle.h" "$(includedir)/Ice/ObjectF.h" "$(includedir)/Ice/Exception.h" "$(includedir)/Ice/LocalObject.h" "$(includedir)/IceUtil/ScopedArray.h" "$(includedir)/Ice/UndefSysMacros.h" "$(includedir)/Ice/PropertiesF.h" "$(includedir)/Ice/Proxy.h" "$(includedir)/IceUtil/Mutex.h" "$(includedir)/IceUtil/Lock.h" "$(includedir)/IceUtil/ThreadException.h" "$(includedir)/IceUtil/Time.h" "$(includedir)/IceUtil/MutexProtocol.h" "$(includedir)/Ice/ProxyFactoryF.h" "$(includedir)/Ice/ConnectionIF.h" "$(includedir)/Ice/RequestHandlerF.h" "$(includedir)/Ice/EndpointIF.h" "$(includedir)/Ice/EndpointF.h" "$(includedir)/Ice/EndpointTypes.h" "$(includedir)/Ice/ObjectAdapterF.h" "$(includedir)/Ice/ReferenceF.h" "$(includedir)/Ice/OutgoingAsync.h" "$(includedir)/IceUtil/Monitor.h" "$(includedir)/IceUtil/Cond.h" "$(includedir)/IceUtil/Timer.h" "$(includedir)/IceUtil/Thread.h" "$(includedir)/Ice/OutgoingAsyncF.h" "$(includedir)/Ice/InstanceF.h" "$(includedir)/Ice/Current.h" "$(includedir)/Ice/ConnectionF.h" "$(includedir)/Ice/Identity.h" "$(includedir)/Ice/BasicStream.h" "$(includedir)/Ice/ObjectFactoryF.h" "$(includedir)/Ice/Buffer.h" "$(includedir)/Ice/Protocol.h" "$(includedir)/Ice/StreamF.h" "$(includedir)/Ice/Object.h" "$(includedir)/Ice/GCShared.h" "$(includedir)/Ice/GCCountMap.h" "$(includedir)/Ice/IncomingAsyncF.h" "$(includedir)/Ice/LoggerF.h" "$(includedir)/Ice/StatsF.h" "$(includedir)/Ice/Dispatcher.h" "$(includedir)/Ice/StringConverter.h" "$(includedir)/Ice/Plugin.h" "$(includedir)/Ice/BuiltinSequences.h" "$(includedir)/Ice/Stream.h" "$(includedir)/IceUtil/Unicode.h" "$(includedir)/Ice/LocalException.h" "$(includedir)/Ice/Properties.h" "$(includedir)/Ice/Outgoing.h" "$(includedir)/Ice/Incoming.h" "$(includedir)/Ice/ServantLocatorF.h" "$(includedir)/Ice/ServantManagerF.h" "$(includedir)/Ice/Direct.h" "$(includedir)/Ice/Logger.h" "$(includedir)/Ice/LoggerUtil.h" "$(includedir)/Ice/Stats.h" "$(includedir)/Ice/Communicator.h" "$(includedir)/Ice/RouterF.h" "$(includedir)/Ice/LocatorF.h" "$(includedir)/Ice/PluginF.h" "$(includedir)/Ice/ImplicitContextF.h" "$(includedir)/Ice/CommunicatorAsync.h" "$(includedir)/Ice/ObjectFactory.h" "$(includedir)/Ice/ObjectAdapter.h" "$(includedir)/Ice/FacetMap.h" "$(includedir)/Ice/Endpoint.h" "$(includedir)/Ice/ServantLocator.h" "$(includedir)/Ice/IncomingAsync.h" "$(includedir)/Ice/Process.h" "$(includedir)/Ice/Application.h" "$(includedir)/Ice/Connection.h" "$(includedir)/Ice/ConnectionAsync.h" "$(includedir)/Ice/Functional.h" "$(includedir)/IceUtil/Functional.h" "$(includedir)/Ice/ImplicitContext.h" "$(includedir)/Ice/Locator.h" "$(includedir)/Ice/FactoryTableInit.h" "$(includedir)/Ice/FactoryTable.h" "$(includedir)/Ice/UserExceptionFactory.h" "$(includedir)/Ice/ProcessF.h" "$(includedir)/Ice/Router.h" "$(includedir)/Ice/DispatchInterceptor.h" "$(includedir)/Ice/IconvStringConverter.h" ../../include/TestCommon.h diff --git a/cpp/test/Ice/plugin/.gitignore b/cpp/test/Ice/plugin/.gitignore new file mode 100644 index 00000000000..a86ad423f93 --- /dev/null +++ b/cpp/test/Ice/plugin/.gitignore @@ -0,0 +1,7 @@ +// Generated by makegitignore.py + +// IMPORTANT: Do not edit this file -- any edits made here will be lost! +client +plugins/libTestPlugin.so.3.4.2 +plugins/libTestPlugin.so.34 +plugins/libTestPlugin.so diff --git a/cpp/test/Ice/plugin/Client.cpp b/cpp/test/Ice/plugin/Client.cpp new file mode 100644 index 00000000000..a54ec9e65c2 --- /dev/null +++ b/cpp/test/Ice/plugin/Client.cpp @@ -0,0 +1,187 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <TestCommon.h> + +using namespace std; + +DEFINE_TEST("client") + +namespace +{ + +class MyPlugin : public Ice::Plugin +{ + +public: + + MyPlugin() : + _initialized(false), + _destroyed(false) + { + } + + bool + isInitialized() const + { + return _initialized; + } + + bool + isDestroyed() const + { + return _destroyed; + } + + void + initialize() + { + _initialized = true; + } + + void + destroy() + { + _destroyed = true; + } + + ~MyPlugin() + { + test(_initialized); + test(_destroyed); + } + +private: + + const Ice::CommunicatorPtr _communicator; + bool _initialized; + bool _destroyed; +}; +typedef IceUtil::Handle<MyPlugin> MyPluginPtr; + +} + +int +main(int argc, char* argv[]) +{ + int status = EXIT_SUCCESS; + Ice::CommunicatorPtr communicator; + + cout << "testing a simple plug-in... " << flush; + try + { + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + initData.properties->setProperty("Ice.Plugin.Test", + "plugins/TestPlugin:createPlugin 'C:\\Program Files\\' --DatabasePath " + "'C:\\Program Files\\Application\\db'" ); + communicator = Ice::initialize(argc, argv, initData); + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + cout << "ok" << endl; + + cout << "testing a simple plug-in that fails to initialize... " << flush; + communicator = 0; + try + { + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + initData.properties->setProperty("Ice.Plugin.Test", "plugins/TestPlugin:createPluginInitializeFail"); + communicator = Ice::initialize(argc, argv, initData); + test(false); + } + catch(const std::exception& ex) + { + test(string(ex.what()) == "PluginInitializeFailExeption"); + } + test(!communicator); + cout << "ok" << endl; + + cout << "testing plug-in load order... " << flush; + try + { + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + initData.properties->setProperty("Ice.Plugin.PluginOne", "plugins/TestPlugin:createPluginOne"); + initData.properties->setProperty("Ice.Plugin.PluginTwo", "plugins/TestPlugin:createPluginTwo"); + initData.properties->setProperty("Ice.Plugin.PluginThree", "plugins/TestPlugin:createPluginThree"); + initData.properties->setProperty("Ice.PluginLoadOrder", "PluginOne, PluginTwo"); // Exclude PluginThree + communicator = Ice::initialize(argc, argv, initData); + communicator->destroy(); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + cout << "ok" << endl; + + cout << "testing plug-in manager... " << flush; + try + { + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + initData.properties->setProperty("Ice.Plugin.PluginOne", "plugins/TestPlugin:createPluginOne"); + initData.properties->setProperty("Ice.Plugin.PluginTwo", "plugins/TestPlugin:createPluginTwo"); + initData.properties->setProperty("Ice.Plugin.PluginThree", "plugins/TestPlugin:createPluginThree"); + initData.properties->setProperty("Ice.PluginLoadOrder", "PluginOne, PluginTwo"); + initData.properties->setProperty("Ice.InitPlugins", "0"); + communicator = Ice::initialize(argc, argv, initData); + + Ice::PluginManagerPtr pm = communicator->getPluginManager(); + test(pm->getPlugin("PluginOne")); + test(pm->getPlugin("PluginTwo")); + test(pm->getPlugin("PluginThree")); + + MyPluginPtr p4 = new MyPlugin; + pm->addPlugin("PluginFour", p4); + test(pm->getPlugin("PluginFour")); + + pm->initializePlugins(); + + test(p4->isInitialized()); + + communicator->destroy(); + + test(p4->isDestroyed()); + } + catch(const Ice::Exception& ex) + { + cerr << ex << endl; + test(false); + } + cout << "ok" << endl; + + cout << "testing destroy when a plug-in fails to initialize... " << flush; + communicator = 0; + try + { + Ice::InitializationData initData; + initData.properties = Ice::createProperties(argc, argv); + initData.properties->setProperty("Ice.Plugin.PluginOneFail", "plugins/TestPlugin:createPluginOneFail"); + initData.properties->setProperty("Ice.Plugin.PluginTwoFail", "plugins/TestPlugin:createPluginTwoFail"); + initData.properties->setProperty("Ice.Plugin.PluginThreeFail", "plugins/TestPlugin:createPluginThreeFail"); + initData.properties->setProperty("Ice.PluginLoadOrder", "PluginOneFail, PluginTwoFail, PluginThreeFail"); + communicator = Ice::initialize(argc, argv, initData); + } + catch(const std::exception& ex) + { + test(string(ex.what()) == "PluginInitializeFailExeption"); + } + test(!communicator); + cout << "ok" << endl; + + return status; +} diff --git a/cpp/test/Ice/plugin/Makefile b/cpp/test/Ice/plugin/Makefile new file mode 100644 index 00000000000..446a4b7c8ac --- /dev/null +++ b/cpp/test/Ice/plugin/Makefile @@ -0,0 +1,51 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +top_srcdir = ../../.. + +PLUGINLIBFILENAME = $(call mklibfilename,TestPlugin,$(VERSION)) +PLUGINSONAME = $(call mksoname,TestPlugin,$(SOVERSION)) +PLUGINLIBNAME = $(call mklibname,TestPlugin) +CLIENT = client +PLUGINDIR = plugins + +TARGETS = $(CLIENT) $(call mklibtargets,$(PLUGINDIR)/$(PLUGINLIBFILENAME),$(PLUGINDIR)/$(PLUGINSONAME),$(PLUGINDIR)/$(PLUGINLIBNAME)) + +COBJS = Client.o \ + +POBJS = Plugin.o + +SRCS = $(COBJS:.o=.cpp) \ + $(SOBJS:.o=.cpp) \ + $(POBJS:.o=.cpp) + +LINKWITH := -lIceUtil -lIce + +include $(top_srcdir)/config/Make.rules + +CPPFLAGS := -I. -I../../include $(CPPFLAGS) + +$(CLIENT): $(COBJS) + rm -f $@ + $(CXX) $(LDFLAGS) -o $@ $(COBJS) $(LIBS) + +$(PLUGINDIR)/$(PLUGINLIBFILENAME): $(POBJS) + rm -f $@ + $(call mkshlib,$@,$(PLUGINSONAME),$(POBJS),$(LINKWITH)) + +$(PLUGINDIR)/$(PLUGINSONAME): $(PLUGINDIR)/$(PLUGINLIBFILENAME) + rm -f $@ + ln -s $(PLUGINLIBFILENAME) $@ + +$(PLUGINDIR)/$(PLUGINLIBNAME): $(PLUGINDIR)/$(PLUGINSONAME) + rm -f $@ + ln -s $(PLUGINSONAME) $@ + + +include .depend diff --git a/cpp/test/Ice/plugin/Makefile.mak b/cpp/test/Ice/plugin/Makefile.mak new file mode 100644 index 00000000000..c1baf6957f2 --- /dev/null +++ b/cpp/test/Ice/plugin/Makefile.mak @@ -0,0 +1,68 @@ +# **********************************************************************
+#
+# Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved.
+#
+# This copy of Ice is licensed to you under the terms described in the
+# ICE_LICENSE file included in this distribution.
+#
+# **********************************************************************
+
+top_srcdir = ..\..\..
+
+!if "$(WINRT)" != "yes"
+NAME_PREFIX =
+EXT = .exe
+!else
+NAME_PREFIX = Ice_plugin_
+EXT = .dll
+!endif
+
+CLIENT = $(NAME_PREFIX)client
+LIBNAME = TestPlugin$(LIBSUFFIX).lib
+DLLNAME = TestPlugin$(SOVERSION)$(LIBSUFFIX).dll
+PLUGINDIR = plugins
+
+TARGETS = $(CLIENT)$(EXT) $(PLUGINDIR)\$(LIBNAME) $(PLUGINDIR)\$(DLLNAME)
+
+COBJS = Client.obj
+
+POBJS = Plugin.obj
+
+SRCS = $(COBJS:.obj=.cpp) \
+ $(POBJS:.obj=.cpp)
+
+!include $(top_srcdir)/config/Make.rules.mak
+
+CPPFLAGS = -I. -I../../include $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN
+
+!if "$(GENERATE_PDB)" == "yes"
+CPDBFLAGS = /pdb:$(CLIENT).pdb
+PPDBFLAGS = /pdb:$(DLLNAME:.dll=.pdb)
+!endif
+
+!if "$(WINRT)" != "yes"
+LD_TESTFLAGS = $(LD_EXEFLAGS) $(SETARGV)
+!else
+LD_TESTFLAGS = $(LD_DLLFLAGS) /export:dllMain
+!endif
+
+LINKWITH = $(LIBS)
+
+$(PLUGINDIR)\$(LIBNAME): $(PLUGINDIR)\$(DLLNAME)
+
+$(PLUGINDIR)\$(DLLNAME): $(POBJS)
+ $(LINK) $(BASE):0x22000000 $(LD_DLLFLAGS) $(PDBFLAGS) $(POBJS) $(PREOUT)$@ $(PRELIBS)$(LINKWITH)
+ move $(PLUGINDIR)\$(DLLNAME:.dll=.lib) $(PLUGINDIR)\$(LIBNAME)
+ @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \
+ $(MT) -nologo -manifest $@.manifest -outputresource:$@;#2 && del /q $@.manifest
+ @if exist $(PLUGINDIR)\$(DLLNAME:.dll=.exp) del /q $(PLUGINDIR)\$(DLLNAME:.dll=.exp)
+
+$(CLIENT)$(EXT): $(COBJS)
+ $(LINK) $(LD_TESTFLAGS) $(CPDBFLAGS) $(SETARGV) $(COBJS) $(PREOUT)$@ $(PRELIBS)$(LIBS)
+ @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \
+ $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest
+
+clean::
+ del /q $(PLUGINDIR)\*.ilk $(PLUGINDIR)\*.pdb
+
+!include .depend.mak
diff --git a/cpp/test/Ice/plugin/Plugin.cpp b/cpp/test/Ice/plugin/Plugin.cpp new file mode 100644 index 00000000000..0fc9cbad24d --- /dev/null +++ b/cpp/test/Ice/plugin/Plugin.cpp @@ -0,0 +1,404 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <Ice/Ice.h> +#include <TestCommon.h> + +using namespace std; + +namespace +{ + +class Plugin : public Ice::Plugin +{ + +public: + + Plugin(const Ice::CommunicatorPtr& communicator, const Ice::StringSeq& args) : + _communicator(communicator), + _args(args), + _initialized(false), + _destroyed(false) + { + } + + void + initialize() + { + _initialized = true; + test(_args.size() == 3); + test(_args[0] == "C:\\Program Files\\"); + test(_args[1] == "--DatabasePath"); + test(_args[2] == "C:\\Program Files\\Application\\db"); + } + + void + destroy() + { + _destroyed = true; + } + + ~Plugin() + { + test(_initialized); + test(_destroyed); + } + +private: + + const Ice::CommunicatorPtr _communicator; + Ice::StringSeq _args; + bool _initialized; + bool _destroyed; +}; + +class PluginInitializeFailExeption : public std::exception +{ + +public: + + PluginInitializeFailExeption() throw() {} + virtual ~PluginInitializeFailExeption() throw() {} + virtual const char* what() const throw() { return "PluginInitializeFailExeption"; } +}; + +class PluginInitializeFail : public Ice::Plugin +{ + +public: + + PluginInitializeFail(const Ice::CommunicatorPtr& communicator) : + _communicator(communicator) + { + } + + void + initialize() + { + throw PluginInitializeFailExeption(); + } + + void + destroy() + { + test(false); + } + +private: + + const Ice::CommunicatorPtr _communicator; +}; + +class BasePlugin; +typedef IceUtil::Handle<BasePlugin> BasePluginPtr; + +class BasePlugin : public Ice::Plugin +{ + +public: + + BasePlugin(const Ice::CommunicatorPtr& communicator) : + _communicator(communicator), + _initialized(false), + _destroyed(false) + { + } + + bool + isInitialized() const + { + return _initialized; + } + + bool + isDestroyed() const + { + return _destroyed; + } + +protected: + + const Ice::CommunicatorPtr _communicator; + bool _initialized; + bool _destroyed; + BasePluginPtr _other; +}; + + +class PluginOne : public BasePlugin +{ + +public: + + PluginOne(const Ice::CommunicatorPtr& communicator) : + BasePlugin(communicator) + { + } + + void + initialize() + { + _other = BasePluginPtr::dynamicCast(_communicator->getPluginManager()->getPlugin("PluginTwo")); + test(!_other->isInitialized()); + _initialized = true; + } + + void + destroy() + { + _destroyed = true; + test(_other->isDestroyed()); + } +}; + +class PluginTwo : public BasePlugin +{ + +public: + + PluginTwo(const Ice::CommunicatorPtr& communicator) : + BasePlugin(communicator) + { + } + + void + initialize() + { + _initialized = true; + _other = BasePluginPtr::dynamicCast(_communicator->getPluginManager()->getPlugin("PluginOne")); + test(_other->isInitialized()); + } + + void + destroy() + { + _destroyed = true; + test(!_other->isDestroyed()); + } +}; + +class PluginThree : public BasePlugin +{ + +public: + + PluginThree(const Ice::CommunicatorPtr& communicator) : + BasePlugin(communicator) + { + } + + void + initialize() + { + _initialized = true; + _other = BasePluginPtr::dynamicCast(_communicator->getPluginManager()->getPlugin("PluginTwo")); + test(_other->isInitialized()); + } + + void + destroy() + { + _destroyed = true; + test(!_other->isDestroyed()); + } +}; + +class BasePluginFail; +typedef IceUtil::Handle<BasePluginFail> BasePluginFailPtr; + +class BasePluginFail : public Ice::Plugin +{ + +public: + + BasePluginFail(const Ice::CommunicatorPtr& communicator) : + _communicator(communicator), + _initialized(false), + _destroyed(false) + { + } + + bool + isInitialized() const + { + return _initialized; + } + + bool + isDestroyed() const + { + return _destroyed; + } + +protected: + + const Ice::CommunicatorPtr _communicator; + bool _initialized; + bool _destroyed; + BasePluginFailPtr _one; + BasePluginFailPtr _two; + BasePluginFailPtr _three; +}; + + +class PluginOneFail : public BasePluginFail +{ + +public: + + PluginOneFail(const Ice::CommunicatorPtr& communicator) : + BasePluginFail(communicator) + { + } + + void + initialize() + { + _two = BasePluginFailPtr::dynamicCast(_communicator->getPluginManager()->getPlugin("PluginTwoFail")); + test(!_two->isInitialized()); + _three = BasePluginFailPtr::dynamicCast(_communicator->getPluginManager()->getPlugin("PluginThreeFail")); + test(!_three->isInitialized()); + _initialized = true; + } + + void + destroy() + { + test(_two->isDestroyed()); + // + // Not destroyed because initialize fails. + // + test(!_three->isDestroyed()); + _destroyed = true; + } + + ~PluginOneFail() + { + test(_initialized); + test(_destroyed); + } +}; + +class PluginTwoFail : public BasePluginFail +{ + +public: + + PluginTwoFail(const Ice::CommunicatorPtr& communicator) : + BasePluginFail(communicator) + { + } + + void + initialize() + { + _initialized = true; + _one = BasePluginFailPtr::dynamicCast(_communicator->getPluginManager()->getPlugin("PluginOneFail")); + test(_one->isInitialized()); + _three = BasePluginFailPtr::dynamicCast(_communicator->getPluginManager()->getPlugin("PluginThreeFail")); + test(!_three->isInitialized()); + } + + void + destroy() + { + _destroyed = true; + test(!_one->isDestroyed()); + } + + ~PluginTwoFail() + { + test(_initialized); + test(_destroyed); + } +}; + +class PluginThreeFail : public BasePluginFail +{ + +public: + + PluginThreeFail(const Ice::CommunicatorPtr& communicator) : + BasePluginFail(communicator) + { + } + + void + initialize() + { + throw PluginInitializeFailExeption(); + } + + void + destroy() + { + test(false); + } + + ~PluginThreeFail() + { + test(!_initialized); + test(!_destroyed); + } +}; + +} + +extern "C" +{ + +ICE_DECLSPEC_EXPORT ::Ice::Plugin* +createPlugin(const Ice::CommunicatorPtr& communicator, const string&, const Ice::StringSeq& args) +{ + return new Plugin(communicator, args); +} + +ICE_DECLSPEC_EXPORT ::Ice::Plugin* +createPluginInitializeFail(const Ice::CommunicatorPtr& communicator, const string&, const Ice::StringSeq&) +{ + return new PluginInitializeFail(communicator); +} + +ICE_DECLSPEC_EXPORT ::Ice::Plugin* +createPluginOne(const Ice::CommunicatorPtr& communicator, const string&, const Ice::StringSeq&) +{ + return new PluginOne(communicator); +} + +ICE_DECLSPEC_EXPORT ::Ice::Plugin* +createPluginTwo(const Ice::CommunicatorPtr& communicator, const string&, const Ice::StringSeq&) +{ + return new PluginTwo(communicator); +} + +ICE_DECLSPEC_EXPORT ::Ice::Plugin* +createPluginThree(const Ice::CommunicatorPtr& communicator, const string&, const Ice::StringSeq&) +{ + return new PluginThree(communicator); +} + +ICE_DECLSPEC_EXPORT ::Ice::Plugin* +createPluginOneFail(const Ice::CommunicatorPtr& communicator, const string&, const Ice::StringSeq&) +{ + return new PluginOneFail(communicator); +} + +ICE_DECLSPEC_EXPORT ::Ice::Plugin* +createPluginTwoFail(const Ice::CommunicatorPtr& communicator, const string&, const Ice::StringSeq&) +{ + return new PluginTwoFail(communicator); +} + +ICE_DECLSPEC_EXPORT ::Ice::Plugin* +createPluginThreeFail(const Ice::CommunicatorPtr& communicator, const string&, const Ice::StringSeq&) +{ + return new PluginThreeFail(communicator); +} + +} diff --git a/cpp/test/Ice/plugin/plugins/.gitignore b/cpp/test/Ice/plugin/plugins/.gitignore new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/cpp/test/Ice/plugin/plugins/.gitignore diff --git a/cpp/test/Ice/plugin/run.py b/cpp/test/Ice/plugin/run.py new file mode 100755 index 00000000000..3c4472ca289 --- /dev/null +++ b/cpp/test/Ice/plugin/run.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2011 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import os, sys + +path = [ ".", "..", "../..", "../../..", "../../../.." ] +head = os.path.dirname(sys.argv[0]) +if len(head) > 0: + path = [os.path.join(head, p) for p in path] +path = [os.path.abspath(p) for p in path if os.path.exists(os.path.join(p, "scripts", "TestUtil.py")) ] +if len(path) == 0: + raise "can't find toplevel directory!" +sys.path.append(os.path.join(path[0])) +from scripts import * + +client = os.path.join(os.getcwd(), "client") +TestUtil.simpleTest(client) + diff --git a/cpp/test/Ice/retry/Test.ice b/cpp/test/Ice/retry/Test.ice index 8e3b4c89b18..04f3073e835 100644 --- a/cpp/test/Ice/retry/Test.ice +++ b/cpp/test/Ice/retry/Test.ice @@ -14,7 +14,7 @@ module Test interface Retry { - ["ami"] void op(bool kill); + void op(bool kill); void shutdown(); }; diff --git a/cpp/test/Ice/slicing/exceptions/Test.ice b/cpp/test/Ice/slicing/exceptions/Test.ice index ddf84d47e82..e558935d440 100644 --- a/cpp/test/Ice/slicing/exceptions/Test.ice +++ b/cpp/test/Ice/slicing/exceptions/Test.ice @@ -59,7 +59,7 @@ interface Relay void unknownPreservedAsKnownPreserved() throws KnownPreserved; }; -["ami", "format:sliced"] +["format:sliced"] interface TestIntf { void baseAsBase() throws Base; diff --git a/cpp/test/Ice/slicing/exceptions/TestAMD.ice b/cpp/test/Ice/slicing/exceptions/TestAMD.ice index 9d5e2422550..259a297fd63 100644 --- a/cpp/test/Ice/slicing/exceptions/TestAMD.ice +++ b/cpp/test/Ice/slicing/exceptions/TestAMD.ice @@ -59,7 +59,7 @@ interface Relay void unknownPreservedAsKnownPreserved() throws KnownPreserved; }; -["ami", "amd", "format:sliced"] +["amd", "format:sliced"] interface TestIntf { void baseAsBase() throws Base; diff --git a/cpp/test/Ice/slicing/objects/Test.ice b/cpp/test/Ice/slicing/objects/Test.ice index 0c221367c86..b2d87343e48 100644 --- a/cpp/test/Ice/slicing/objects/Test.ice +++ b/cpp/test/Ice/slicing/objects/Test.ice @@ -97,7 +97,7 @@ exception PreservedException { }; -["ami", "format:sliced"] +["format:sliced"] interface TestIntf { Object SBaseAsObject(); diff --git a/cpp/test/Ice/slicing/objects/TestAMD.ice b/cpp/test/Ice/slicing/objects/TestAMD.ice index c023f59d638..3df92c08f0b 100644 --- a/cpp/test/Ice/slicing/objects/TestAMD.ice +++ b/cpp/test/Ice/slicing/objects/TestAMD.ice @@ -97,7 +97,7 @@ exception PreservedException { }; -["ami", "amd", "format:sliced"] +["amd", "format:sliced"] interface TestIntf { Object SBaseAsObject(); diff --git a/cpp/test/Ice/timeout/Test.ice b/cpp/test/Ice/timeout/Test.ice index 39f85a34bb5..1a513390d46 100644 --- a/cpp/test/Ice/timeout/Test.ice +++ b/cpp/test/Ice/timeout/Test.ice @@ -17,8 +17,8 @@ sequence<byte> ByteSeq; interface Timeout { void op(); - ["ami"] void sendData(ByteSeq seq); - ["ami"] void sleep(int to); + void sendData(ByteSeq seq); + void sleep(int to); void holdAdapter(int to); diff --git a/cpp/test/IceGrid/activation/AllTests.cpp b/cpp/test/IceGrid/activation/AllTests.cpp index 8b8bc0bc09a..391cb8a2497 100644 --- a/cpp/test/IceGrid/activation/AllTests.cpp +++ b/cpp/test/IceGrid/activation/AllTests.cpp @@ -53,7 +53,7 @@ public: } catch(const Ice::LocalException& ex) { - _exception.reset(dynamic_cast<Ice::LocalException*>(ex.ice_clone())); + _exception.reset(ex.ice_clone()); } catch(...) { diff --git a/cpp/test/IceGrid/allocation/AllTests.cpp b/cpp/test/IceGrid/allocation/AllTests.cpp index 2833debab19..99f7dd1087a 100644 --- a/cpp/test/IceGrid/allocation/AllTests.cpp +++ b/cpp/test/IceGrid/allocation/AllTests.cpp @@ -21,7 +21,7 @@ using namespace std; using namespace Test; using namespace IceGrid; -class Callback : public IceUtil::Monitor<IceUtil::Mutex> +class Callback : public IceUtil::Monitor<IceUtil::Mutex>, virtual public IceUtil::Shared { public: @@ -39,7 +39,7 @@ public: } void - exception() + exception(const Ice::Exception&) { Lock sync(*this); _exception = true; @@ -77,24 +77,8 @@ private: bool _exception; Ice::ObjectPrx _obj; }; +typedef IceUtil::Handle<Callback> CallbackPtr; -class AllocateObjectByIdCallback : public AMI_Session_allocateObjectById, public Callback -{ -public: - - virtual void ice_response(const Ice::ObjectPrx& obj) { response(obj); } - virtual void ice_exception(const Ice::Exception&) { exception(); } -}; -typedef IceUtil::Handle<AllocateObjectByIdCallback> AllocateObjectByIdCallbackPtr; - -class AllocateObjectByTypeCallback : public AMI_Session_allocateObjectByType, public Callback -{ -public: - - virtual void ice_response(const Ice::ObjectPrx& obj) { response(obj); } - virtual void ice_exception(const Ice::Exception&) { exception(); } -}; -typedef IceUtil::Handle<AllocateObjectByTypeCallback> AllocateObjectByTypeCallbackPtr; class StressClient : public IceUtil::Thread, public IceUtil::Monitor<IceUtil::Mutex> { @@ -242,14 +226,22 @@ public: { ostringstream os; os << "stress-" << IceUtilInternal::random(3); - session->allocateObjectById_async(new AllocateObjectByIdCallback(), _communicator->stringToIdentity(os.str())); + CallbackPtr asyncCB = new Callback(); + IceGrid::Callback_Session_allocateObjectByIdPtr cb = IceGrid::newCallback_Session_allocateObjectById(asyncCB, + &Callback::response, + &Callback::exception); + session->begin_allocateObjectById(_communicator->stringToIdentity(os.str()), cb); session->destroy(); } void allocateByTypeAndDestroy(const SessionPrx& session) { - session->allocateObjectByType_async(new AllocateObjectByTypeCallback(), "::StressTest"); + CallbackPtr asyncCB = new Callback(); + IceGrid::Callback_Session_allocateObjectByTypePtr cb = IceGrid::newCallback_Session_allocateObjectByType(asyncCB, + &Callback::response, + &Callback::exception); + session->begin_allocateObjectByType("::StressTest", cb); session->destroy(); } @@ -532,13 +524,18 @@ allTests(const Ice::CommunicatorPtr& communicator) session2->releaseObject(allocatablebis); session2->setAllocationTimeout(allocationTimeout); - AllocateObjectByIdCallbackPtr cb1 = new AllocateObjectByIdCallback(); - session2->allocateObjectById_async(cb1, allocatable); + + CallbackPtr asyncCB1 = new Callback(); + IceGrid::Callback_Session_allocateObjectByIdPtr cb1 = IceGrid::newCallback_Session_allocateObjectById(asyncCB1, + &Callback::response, + &Callback::exception); + + session2->begin_allocateObjectById(allocatable, cb1); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb1->hasResponse(dummy)); + test(!asyncCB1->hasResponse(dummy)); session1->releaseObject(allocatable); - cb1->waitResponse(__FILE__, __LINE__); - test(cb1->hasResponse(dummy)); + asyncCB1->waitResponse(__FILE__, __LINE__); + test(asyncCB1->hasResponse(dummy)); session1->setAllocationTimeout(0); try @@ -558,13 +555,16 @@ allTests(const Ice::CommunicatorPtr& communicator) { } session1->setAllocationTimeout(allocationTimeout); - cb1 = new AllocateObjectByIdCallback(); - session1->allocateObjectById_async(cb1, allocatable); + asyncCB1 = new Callback(); + cb1 = IceGrid::newCallback_Session_allocateObjectById(asyncCB1, + &Callback::response, + &Callback::exception); + session1->begin_allocateObjectById(allocatable, cb1); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb1->hasResponse(dummy)); + test(!asyncCB1->hasResponse(dummy)); session2->releaseObject(allocatable); - cb1->waitResponse(__FILE__, __LINE__); - test(cb1->hasResponse(dummy)); + asyncCB1->waitResponse(__FILE__, __LINE__); + test(asyncCB1->hasResponse(dummy)); session1->releaseObject(allocatable); @@ -677,13 +677,17 @@ allTests(const Ice::CommunicatorPtr& communicator) session2->releaseObject(allocatablebis); session1->setAllocationTimeout(allocationTimeout); - AllocateObjectByTypeCallbackPtr cb3 = new AllocateObjectByTypeCallback(); - session1->allocateObjectByType_async(cb3, "::Test"); + CallbackPtr asyncCB3 = new Callback(); + IceGrid::Callback_Session_allocateObjectByTypePtr cb3 = IceGrid::newCallback_Session_allocateObjectByType(asyncCB3, + &Callback::response, + &Callback::exception); + + session1->begin_allocateObjectByType("::Test", cb3); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb3->hasResponse(dummy)); + test(!asyncCB3->hasResponse(dummy)); session2->releaseObject(obj->ice_getIdentity()); - cb3->waitResponse(__FILE__, __LINE__); - test(cb3->hasResponse(obj)); + asyncCB3->waitResponse(__FILE__, __LINE__); + test(asyncCB3->hasResponse(obj)); session1->releaseObject(obj->ice_getIdentity()); @@ -833,26 +837,32 @@ allTests(const Ice::CommunicatorPtr& communicator) session1->allocateObjectById(allocatable4); session2->setAllocationTimeout(allocationTimeout); - cb1 = new AllocateObjectByIdCallback(); - session2->allocateObjectById_async(cb1, allocatable3); + asyncCB1 = new Callback(); + cb1 = IceGrid::newCallback_Session_allocateObjectById(asyncCB1, + &Callback::response, + &Callback::exception); + session2->begin_allocateObjectById(allocatable3, cb1); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb1->hasResponse(dummy)); + test(!asyncCB1->hasResponse(dummy)); session1->releaseObject(allocatable3); - test(!cb1->hasResponse(dummy)); + test(!asyncCB1->hasResponse(dummy)); session1->releaseObject(allocatable4); - cb1->waitResponse(__FILE__, __LINE__); - test(cb1->hasResponse(dummy)); + asyncCB1->waitResponse(__FILE__, __LINE__); + test(asyncCB1->hasResponse(dummy)); session2->releaseObject(allocatable3); session1->setAllocationTimeout(allocationTimeout); test(session2->allocateObjectByType("::TestServer1")); - cb3 = new AllocateObjectByTypeCallback(); - session1->allocateObjectByType_async(cb3, "::TestServer2"); + asyncCB3 = new Callback(); + cb3 = IceGrid::newCallback_Session_allocateObjectByType(asyncCB3, + &Callback::response, + &Callback::exception); + session1->begin_allocateObjectByType("::TestServer2", cb3); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb3->hasResponse(dummy)); + test(!asyncCB3->hasResponse(dummy)); session2->releaseObject(allocatable3); - cb3->waitResponse(__FILE__, __LINE__); - test(cb3->hasResponse(dummy)); + asyncCB3->waitResponse(__FILE__, __LINE__); + test(asyncCB3->hasResponse(dummy)); session1->releaseObject(allocatable4); session1->setAllocationTimeout(0); @@ -915,105 +925,135 @@ allTests(const Ice::CommunicatorPtr& communicator) session2->setAllocationTimeout(allocationTimeout); session2->allocateObjectById(allocatable); - AllocateObjectByIdCallbackPtr cb11 = new AllocateObjectByIdCallback(); - AllocateObjectByIdCallbackPtr cb12 = new AllocateObjectByIdCallback(); - session1->allocateObjectById_async(cb11, allocatable); - session1->allocateObjectById_async(cb12, allocatable); + CallbackPtr asyncCB11 = new Callback(); + IceGrid::Callback_Session_allocateObjectByIdPtr cb11 = IceGrid::newCallback_Session_allocateObjectById(asyncCB11, + &Callback::response, + &Callback::exception); + CallbackPtr asyncCB12 = new Callback(); + IceGrid::Callback_Session_allocateObjectByIdPtr cb12 = IceGrid::newCallback_Session_allocateObjectById(asyncCB12, + &Callback::response, + &Callback::exception); + session1->begin_allocateObjectById(allocatable, cb11); + session1->begin_allocateObjectById(allocatable, cb12); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb11->hasResponse(dummy)); - test(!cb12->hasResponse(dummy)); + test(!asyncCB11->hasResponse(dummy)); + test(!asyncCB12->hasResponse(dummy)); session2->releaseObject(allocatable); - cb11->waitResponse(__FILE__, __LINE__); - cb12->waitResponse(__FILE__, __LINE__); - test(cb11->hasResponse(dummy) ? cb12->hasException() : cb12->hasResponse(dummy)); - test(cb12->hasResponse(dummy) ? cb11->hasException() : cb11->hasResponse(dummy)); + asyncCB11->waitResponse(__FILE__, __LINE__); + asyncCB12->waitResponse(__FILE__, __LINE__); + test(asyncCB11->hasResponse(dummy) ? asyncCB12->hasException() : asyncCB12->hasResponse(dummy)); + test(asyncCB12->hasResponse(dummy) ? asyncCB11->hasException() : asyncCB11->hasResponse(dummy)); session1->releaseObject(allocatable); session2->allocateObjectById(allocatable); - AllocateObjectByTypeCallbackPtr cb31 = new AllocateObjectByTypeCallback(); - AllocateObjectByTypeCallbackPtr cb32 = new AllocateObjectByTypeCallback(); - session1->allocateObjectByType_async(cb31, "::Test"); - session1->allocateObjectByType_async(cb32, "::Test"); + CallbackPtr asyncCB31 = new Callback(); + IceGrid::Callback_Session_allocateObjectByTypePtr cb31 = IceGrid::newCallback_Session_allocateObjectByType(asyncCB31, + &Callback::response, + &Callback::exception); + CallbackPtr asyncCB32 = new Callback(); + IceGrid::Callback_Session_allocateObjectByTypePtr cb32 = IceGrid::newCallback_Session_allocateObjectByType(asyncCB32, + &Callback::response, + &Callback::exception); + session1->begin_allocateObjectByType("::Test", cb31); + session1->begin_allocateObjectByType("::Test", cb32); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb31->hasResponse(dummy)); - test(!cb32->hasResponse(dummy)); + test(!asyncCB31->hasResponse(dummy)); + test(!asyncCB32->hasResponse(dummy)); session2->releaseObject(allocatable); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); do { IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); } - while(!cb31->hasResponse(dummy) && !cb32->hasResponse(dummy)); - test((cb31->hasResponse(dummy) && dummy && !cb32->hasResponse(dummy)) || - (cb32->hasResponse(dummy) && dummy && !cb31->hasResponse(dummy))); + while(!asyncCB31->hasResponse(dummy) && !asyncCB32->hasResponse(dummy)); + test((asyncCB31->hasResponse(dummy) && dummy && !asyncCB32->hasResponse(dummy)) || + (asyncCB32->hasResponse(dummy) && dummy && !asyncCB31->hasResponse(dummy))); session1->releaseObject(allocatable); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); - AllocateObjectByTypeCallbackPtr cb33 = cb31->hasResponse(dummy) ? cb32 : cb31; - cb33->waitResponse(__FILE__, __LINE__); - test(cb33->hasResponse(dummy) && dummy); + CallbackPtr asyncCB33 = asyncCB31->hasResponse(dummy) ? asyncCB32 : asyncCB31; + asyncCB33->waitResponse(__FILE__, __LINE__); + test(asyncCB33->hasResponse(dummy) && dummy); session1->releaseObject(allocatable); session2->allocateObjectById(allocatable3); - cb11 = new AllocateObjectByIdCallback(); - cb12 = new AllocateObjectByIdCallback(); - session1->allocateObjectById_async(cb11, allocatable3); - session1->allocateObjectById_async(cb12, allocatable3); + asyncCB11 = new Callback(); + cb11 = IceGrid::newCallback_Session_allocateObjectById(asyncCB11, + &Callback::response, + &Callback::exception); + asyncCB12 = new Callback(); + cb12 = IceGrid::newCallback_Session_allocateObjectById(asyncCB12, + &Callback::response, + &Callback::exception); + session1->begin_allocateObjectById(allocatable3, cb11); + session1->begin_allocateObjectById(allocatable3, cb12); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb11->hasResponse(dummy)); - test(!cb12->hasResponse(dummy)); + test(!asyncCB11->hasResponse(dummy)); + test(!asyncCB12->hasResponse(dummy)); session2->releaseObject(allocatable3); - cb11->waitResponse(__FILE__, __LINE__); - cb12->waitResponse(__FILE__, __LINE__); - test(cb11->hasResponse(dummy) ? cb12->hasException() : cb12->hasResponse(dummy)); - test(cb12->hasResponse(dummy) ? cb11->hasException() : cb11->hasResponse(dummy)); + asyncCB11->waitResponse(__FILE__, __LINE__); + asyncCB12->waitResponse(__FILE__, __LINE__); + test(asyncCB11->hasResponse(dummy) ? asyncCB12->hasException() : asyncCB12->hasResponse(dummy)); + test(asyncCB12->hasResponse(dummy) ? asyncCB11->hasException() : asyncCB11->hasResponse(dummy)); session1->releaseObject(allocatable3); session2->allocateObjectById(allocatable3); - cb31 = new AllocateObjectByTypeCallback(); - cb32 = new AllocateObjectByTypeCallback(); - session1->allocateObjectByType_async(cb31, "::TestServer1"); - session1->allocateObjectByType_async(cb32, "::TestServer1"); + asyncCB31 = new Callback(); + cb31 = IceGrid::newCallback_Session_allocateObjectByType(asyncCB31, + &Callback::response, + &Callback::exception); + asyncCB32 = new Callback(); + cb32 = IceGrid::newCallback_Session_allocateObjectByType(asyncCB32, + &Callback::response, + &Callback::exception); + session1->begin_allocateObjectByType("::TestServer1", cb31); + session1->begin_allocateObjectByType("::TestServer1", cb32); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb31->hasResponse(dummy)); - test(!cb32->hasResponse(dummy)); + test(!asyncCB31->hasResponse(dummy)); + test(!asyncCB32->hasResponse(dummy)); session2->releaseObject(allocatable3); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); do { IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); } - while(!cb31->hasResponse(dummy) && !cb32->hasResponse(dummy)); - test((cb31->hasResponse(dummy) && dummy && !cb32->hasResponse(dummy)) || - (cb32->hasResponse(dummy) && dummy && !cb31->hasResponse(dummy))); + while(!asyncCB31->hasResponse(dummy) && !asyncCB32->hasResponse(dummy)); + test((asyncCB31->hasResponse(dummy) && dummy && !asyncCB32->hasResponse(dummy)) || + (asyncCB32->hasResponse(dummy) && dummy && !asyncCB31->hasResponse(dummy))); session1->releaseObject(allocatable3); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); - cb33 = cb31->hasResponse(dummy) ? cb32 : cb31; - cb33->waitResponse(__FILE__, __LINE__); - test(cb33->hasResponse(dummy) && dummy); + asyncCB33 = asyncCB31->hasResponse(dummy) ? asyncCB32 : asyncCB31; + asyncCB33->waitResponse(__FILE__, __LINE__); + test(asyncCB33->hasResponse(dummy) && dummy); session1->releaseObject(allocatable3); session1->allocateObjectById(allocatable3); - cb31 = new AllocateObjectByTypeCallback(); - cb32 = new AllocateObjectByTypeCallback(); - session1->allocateObjectByType_async(cb31, "::TestServer1"); - session1->allocateObjectByType_async(cb32, "::TestServer1"); + asyncCB31 = new Callback(); + cb31 = IceGrid::newCallback_Session_allocateObjectByType(asyncCB31, + &Callback::response, + &Callback::exception); + asyncCB32 = new Callback(); + cb32 = IceGrid::newCallback_Session_allocateObjectByType(asyncCB32, + &Callback::response, + &Callback::exception); + session1->begin_allocateObjectByType("::TestServer1", cb31); + session1->begin_allocateObjectByType("::TestServer1", cb32); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb31->hasResponse(dummy)); - test(!cb32->hasResponse(dummy)); + test(!asyncCB31->hasResponse(dummy)); + test(!asyncCB32->hasResponse(dummy)); session1->releaseObject(allocatable3); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); do { IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200)); } - while(!cb31->hasResponse(dummy) && !cb32->hasResponse(dummy)); - test((cb31->hasResponse(dummy) && dummy && !cb32->hasResponse(dummy)) || - (cb32->hasResponse(dummy) && dummy && !cb31->hasResponse(dummy))); + while(!asyncCB31->hasResponse(dummy) && !asyncCB32->hasResponse(dummy)); + test((asyncCB31->hasResponse(dummy) && dummy && !asyncCB32->hasResponse(dummy)) || + (asyncCB32->hasResponse(dummy) && dummy && !asyncCB31->hasResponse(dummy))); session1->releaseObject(allocatable3); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(300)); - cb33 = cb31->hasResponse(dummy) ? cb32 : cb31; - cb33->waitResponse(__FILE__, __LINE__); - test(cb33->hasResponse(dummy) && dummy); + asyncCB33 = asyncCB31->hasResponse(dummy) ? asyncCB32 : asyncCB31; + asyncCB33->waitResponse(__FILE__, __LINE__); + test(asyncCB33->hasResponse(dummy) && dummy); session1->releaseObject(allocatable3); cout << "ok" << endl; @@ -1024,13 +1064,16 @@ allTests(const Ice::CommunicatorPtr& communicator) test(obj && obj->ice_getIdentity().name == "allocatable"); session1->setAllocationTimeout(allocationTimeout); - cb3 = new AllocateObjectByTypeCallback(); - session1->allocateObjectByType_async(cb3, "::Test"); + asyncCB3 = new Callback(); + cb3 = IceGrid::newCallback_Session_allocateObjectByType(asyncCB3, + &Callback::response, + &Callback::exception); + session1->begin_allocateObjectByType("::Test", cb3); IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); - test(!cb3->hasResponse(dummy)); + test(!asyncCB3->hasResponse(dummy)); session2->destroy(); - cb3->waitResponse(__FILE__, __LINE__); - test(cb3->hasResponse(obj)); + asyncCB3->waitResponse(__FILE__, __LINE__); + test(asyncCB3->hasResponse(obj)); session1->destroy(); session2 = SessionPrx::uncheckedCast(registry->createSession("Client2", "")); diff --git a/cpp/test/IceUtil/unicode/Client.cpp b/cpp/test/IceUtil/unicode/Client.cpp index 0e9881deec5..c2184556ca7 100644 --- a/cpp/test/IceUtil/unicode/Client.cpp +++ b/cpp/test/IceUtil/unicode/Client.cpp @@ -13,6 +13,8 @@ #ifdef _WIN32 # include <io.h> +#else +# include <unistd.h> #endif using namespace IceUtil; @@ -209,9 +211,9 @@ main(int argc, char* argv[]) test(fd > 0); #if defined(_MSC_VER) test(_close(fd) == 0); -#else - test(close(fd) == 0); -#endif +# else + test(::close(fd) == 0); +# endif FILE* f = IceUtilInternal::fopen(filepath, "r"); test(f != 0); diff --git a/cpp/test/WinRT/TestSuite/MainPage.xaml.cpp b/cpp/test/WinRT/TestSuite/MainPage.xaml.cpp index a572f49a96f..becadead55f 100644 --- a/cpp/test/WinRT/TestSuite/MainPage.xaml.cpp +++ b/cpp/test/WinRT/TestSuite/MainPage.xaml.cpp @@ -300,7 +300,9 @@ static const TestCase allTest[] = {"Ice\\retry", "Ice_retry_", "client.dll", "server.dll", 0, 0 }, {"Ice\\stream", "Ice_stream_", "client.dll", 0, 0, 0}, {"Ice\\timeout", "Ice_timeout_", "client.dll", "server.dll", 0, 0 }, - {"Ice\\udp", "Ice_udp_", "client.dll", "server.dll", 0, 0 } + {"Ice\\udp", "Ice_udp_", "client.dll", "server.dll", 0, 0 }, + {"Ice\\hash", "Ice_hash_", "client.dll", 0, 0, 0}, + {"Ice\\plugin", "Ice_plugin_", "client.dll", 0, 0, 0} }; class TestRunner : public IceUtil::Thread diff --git a/cpp/test/WinRT/TestSuite/TestSuite.vcxproj b/cpp/test/WinRT/TestSuite/TestSuite.vcxproj index 3e6321b9bc0..ee8bd766392 100644 --- a/cpp/test/WinRT/TestSuite/TestSuite.vcxproj +++ b/cpp/test/WinRT/TestSuite/TestSuite.vcxproj @@ -227,6 +227,9 @@ <None Include="..\..\Ice\facets\Ice_facets_server.dll">
<DeploymentContent>true</DeploymentContent>
</None>
+ <None Include="..\..\Ice\hash\Ice_hash_client.dll">
+ <DeploymentContent>true</DeploymentContent>
+ </None>
<None Include="..\..\Ice\hold\Ice_hold_client.dll">
<DeploymentContent>true</DeploymentContent>
</None>
diff --git a/cpp/test/WinRT/TestSuite/TestSuite.vcxproj.filters b/cpp/test/WinRT/TestSuite/TestSuite.vcxproj.filters index a265ba6d68e..05791395699 100644 --- a/cpp/test/WinRT/TestSuite/TestSuite.vcxproj.filters +++ b/cpp/test/WinRT/TestSuite/TestSuite.vcxproj.filters @@ -196,6 +196,9 @@ <Filter>Tests</Filter>
</None>
<None Include="key.pfx" />
+ <None Include="..\..\Ice\hash\Ice_hash_client.dll">
+ <Filter>Tests</Filter>
+ </None>
</ItemGroup>
<ItemGroup>
<Page Include="MainPage.xaml" />
diff --git a/cpp/test/include/TestCommon.h b/cpp/test/include/TestCommon.h index c834907c00f..7afb82ce914 100644 --- a/cpp/test/include/TestCommon.h +++ b/cpp/test/include/TestCommon.h @@ -188,7 +188,7 @@ public: return "::TestFailedException"; } - virtual ::Ice::Exception* ice_clone() const + virtual TestFailedException* ice_clone() const { return new TestFailedException(*this); } |