From 1d5c04bb8c0e786a717e36467e17f34bcc4f1d95 Mon Sep 17 00:00:00 2001 From: Jose Date: Fri, 10 Aug 2012 23:53:37 +0200 Subject: C++11 ami lambda support --- cpp/src/Ice/CommunicatorI.h | 10 ++ cpp/src/Ice/ConnectionI.h | 10 ++ cpp/src/Ice/Initialize.cpp | 8 ++ cpp/src/Ice/Network.cpp | 2 +- cpp/src/Ice/Proxy.cpp | 20 +++ cpp/src/IceStorm/NodeI.cpp | 15 +++ cpp/src/IceStorm/Replica.h | 6 + cpp/src/IceUtil/FileUtil.cpp | 5 +- cpp/src/Slice/FileTracker.cpp | 6 +- cpp/src/slice2cpp/Gen.cpp | 296 ++++++++++++++++++++++++++++++++++++----- cpp/src/slice2cpp/Main.cpp | 12 +- cpp/src/slice2cs/Main.cpp | 12 +- cpp/src/slice2freeze/Main.cpp | 14 +- cpp/src/slice2freezej/Main.cpp | 14 +- cpp/src/slice2html/Main.cpp | 14 +- cpp/src/slice2java/Main.cpp | 12 +- cpp/src/slice2php/Main.cpp | 12 +- cpp/src/slice2py/Main.cpp | 12 +- cpp/src/slice2rb/Main.cpp | 20 ++- 19 files changed, 394 insertions(+), 106 deletions(-) (limited to 'cpp/src') diff --git a/cpp/src/Ice/CommunicatorI.h b/cpp/src/Ice/CommunicatorI.h index dc5580180b2..782cbf13b96 100644 --- a/cpp/src/Ice/CommunicatorI.h +++ b/cpp/src/Ice/CommunicatorI.h @@ -14,6 +14,7 @@ #include #include #include +#include namespace Ice { @@ -59,6 +60,15 @@ public: virtual void flushBatchRequests(); +#ifdef ICE_CPP11 + virtual ::Ice::AsyncResultPtr begin_flushBatchRequests( + const ::IceInternal::Function& exception, + const ::IceInternal::Function& sent = ::IceInternal::Function()) + { + return begin_flushBatchRequestsInternal(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&, diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h index 1f448693a38..946a24f0c79 100644 --- a/cpp/src/Ice/ConnectionI.h +++ b/cpp/src/Ice/ConnectionI.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -103,6 +104,15 @@ public: void abortBatchRequest(); virtual void flushBatchRequests(); // From Connection. + +#ifdef ICE_CPP11 + virtual ::Ice::AsyncResultPtr begin_flushBatchRequests( + const ::IceInternal::Function& exception, + const ::IceInternal::Function& sent = ::IceInternal::Function()) + { + return begin_flushBatchRequestsInternal(new Cpp11FnCallbackNC_Connection_flushBatchRequests(exception, sent), 0); + } +#endif virtual AsyncResultPtr begin_flushBatchRequests(); virtual AsyncResultPtr begin_flushBatchRequests(const CallbackPtr&, const LocalObjectPtr& = 0); 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/Network.cpp b/cpp/src/Ice/Network.cpp index 3a2f6d402e3..d3ed3c505ca 100644 --- a/cpp/src/Ice/Network.cpp +++ b/cpp/src/Ice/Network.cpp @@ -1631,7 +1631,7 @@ IceInternal::doBind(SOCKET fd, const Address& addr) size = 0; // Keep the compiler happy. } - if(bind(fd, reinterpret_cast(&addr), size) == SOCKET_ERROR) + if(::bind(fd, reinterpret_cast(&addr), size) == SOCKET_ERROR) { closeSocketNoThrow(fd); SocketException ex(__FILE__, __LINE__); diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp index ecf1bfbde1d..a9768790b1b 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/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(this->id) = other.id; + const_cast(this->llu) = other.llu; + const_cast(this->observer) = other.observer; + return *this; +} +#endif + Replica::~Replica() { //cout << "~Replica" << endl; 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/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 -#endif - -#ifdef _WIN32 # include +#else +# include #endif using namespace std; diff --git a/cpp/src/Slice/FileTracker.cpp b/cpp/src/Slice/FileTracker.cpp index a14638757a2..7dcd7e96e42 100644 --- a/cpp/src/Slice/FileTracker.cpp +++ b/cpp/src/Slice/FileTracker.cpp @@ -9,12 +9,10 @@ #include -#ifdef __sun -# include -#endif - #ifdef _WIN32 # include +#else +# include #endif using namespace std; diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index db170626d26..1d713299433 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -1774,6 +1774,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 outDeclsEnd; + vector 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) { @@ -1782,14 +1814,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 params; @@ -1800,12 +1835,18 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p) vector paramsDeclAMI; vector argsAMI; vector outParamsAMI; + vector outParamNamesAMI; vector outParamsDeclAMI; vector outParamsDeclEndAMI; - + vector outDecls; + ParamDeclList paramList = p->parameters(); ParamDeclList inParams; ParamDeclList outParams; + + + vector outEndArgs; + for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q) { string paramName = fixKwd((*q)->name()); @@ -1838,9 +1879,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())); } } @@ -1884,6 +1928,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& response, " + << "const ::IceInternal::Function& exception = " + "::IceInternal::Function(), " + << "const ::IceInternal::Function& sent = ::IceInternal::Function()" << 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& completed" + << "const ::IceInternal::Function& sent = " + "::IceInternal::Function()" << 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& response, " + << "const ::IceInternal::Function& exception = " + "::IceInternal::Function(), " + << "const ::IceInternal::Function& sent = ::IceInternal::Function()" << 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& completed" + << "const ::IceInternal::Function& sent = " + "::IceInternal::Function()" << 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& response, " + << "const ::IceInternal::Function& exception, " + << "const ::IceInternal::Function& 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& responseFunc, " + << "const ::std::function& exceptionFunc, " + << "const ::std::function& 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 _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; @@ -1932,7 +2171,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 << ';'; } @@ -1949,7 +2188,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 << "int __cnt = 0;"; @@ -3971,6 +4210,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()); @@ -4012,6 +4252,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()) @@ -4202,6 +4446,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& exception" + << "const ::IceInternal::Function& sent = ::IceInternal::Function()" << epar << " = 0;"; + + H.zeroIndent(); + H << nl << "#endif"; + H.restoreIndent(); H << sp << nl << "virtual ::Ice::AsyncResultPtr begin_" << name << spar << paramsDeclAMI << epar << " = 0;"; @@ -4730,38 +4986,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 outDeclsEnd; - vector 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 sync(mutex); + IceUtilInternal::MutexPtrLock sync(globalMutex); interrupted = true; } @@ -295,7 +295,7 @@ compile(int argc, char* argv[]) } { - IceUtilInternal::MutexPtrLock sync(mutex); + IceUtilInternal::MutexPtrLock sync(globalMutex); if(interrupted) { 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 sync(mutex); + IceUtilInternal::MutexPtrLock sync(globalMutex); interrupted = true; } @@ -303,7 +303,7 @@ compile(int argc, char* argv[]) } { - IceUtilInternal::MutexPtrLock sync(mutex); + IceUtilInternal::MutexPtrLock 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 sync(mutex); + IceUtilInternal::MutexPtrLock sync(globalMutex); interrupted = true; } @@ -1999,7 +1999,7 @@ compile(int argc, char* argv[]) } { - IceUtilInternal::MutexPtrLock sync(mutex); + IceUtilInternal::MutexPtrLock sync(globalMutex); if(interrupted) { @@ -2046,7 +2046,7 @@ compile(int argc, char* argv[]) u->destroy(); { - IceUtilInternal::MutexPtrLock sync(mutex); + IceUtilInternal::MutexPtrLock 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 lock(mutex); + IceUtilInternal::MutexPtrLock lock(globalMutex); interrupted = true; } @@ -1841,7 +1841,7 @@ compile(int argc, char* argv[]) } { - IceUtilInternal::MutexPtrLock sync(mutex); + IceUtilInternal::MutexPtrLock sync(globalMutex); if(interrupted) { @@ -1941,7 +1941,7 @@ compile(int argc, char* argv[]) u->destroy(); { - IceUtilInternal::MutexPtrLock sync(mutex); + IceUtilInternal::MutexPtrLock 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 sync(mutex); + IceUtilInternal::MutexPtrLock sync(globalMutex); interrupted = true; } @@ -254,7 +254,7 @@ compile(int argc, char* argv[]) } { - IceUtilInternal::MutexPtrLock sync(mutex); + IceUtilInternal::MutexPtrLock sync(globalMutex); if(interrupted) { @@ -296,7 +296,7 @@ compile(int argc, char* argv[]) p->destroy(); { - IceUtilInternal::MutexPtrLock sync(mutex); + IceUtilInternal::MutexPtrLock sync(globalMutex); if(interrupted) { 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 sync(mutex); + IceUtilInternal::MutexPtrLock sync(globalMutex); interrupted = true; } @@ -356,7 +356,7 @@ compile(int argc, char* argv[]) } { - IceUtilInternal::MutexPtrLock sync(mutex); + IceUtilInternal::MutexPtrLock 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 sync(mutex); + IceUtilInternal::MutexPtrLock sync(globalMutex); interrupted = true; } @@ -1780,7 +1780,7 @@ compile(int argc, char* argv[]) } { - IceUtilInternal::MutexPtrLock sync(mutex); + IceUtilInternal::MutexPtrLock 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 sync(mutex); + IceUtilInternal::MutexPtrLock sync(globalMutex); interrupted = true; } @@ -631,7 +631,7 @@ compile(int argc, char* argv[]) } { - IceUtilInternal::MutexPtrLock sync(mutex); + IceUtilInternal::MutexPtrLock 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 #ifdef _WIN32 -#include -#endif - -#ifndef _WIN32 -#include +# include +#else +# include #endif #include @@ -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 sync(mutex); + IceUtilInternal::MutexPtrLock sync(globalMutex); interrupted = true; } @@ -316,7 +314,7 @@ compile(int argc, char* argv[]) } { - IceUtilInternal::MutexPtrLock sync(mutex); + IceUtilInternal::MutexPtrLock sync(globalMutex); if(interrupted) { -- cgit v1.2.3