diff options
author | Marc Laukien <marc@zeroc.com> | 2001-10-14 22:07:51 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2001-10-14 22:07:51 +0000 |
commit | e3391e10721a7bbe8c867d1c798fcf6d24a67308 (patch) | |
tree | dbab6b044338c6e7a920eb72e8c9d3b4cbd07f56 /cpp/src | |
parent | fixes (diff) | |
download | ice-e3391e10721a7bbe8c867d1c798fcf6d24a67308.tar.bz2 ice-e3391e10721a7bbe8c867d1c798fcf6d24a67308.tar.xz ice-e3391e10721a7bbe8c867d1c798fcf6d24a67308.zip |
win and other fixes
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/Collector.cpp | 32 | ||||
-rw-r--r-- | cpp/src/Ice/Collector.h | 13 | ||||
-rw-r--r-- | cpp/src/Ice/Emitter.cpp | 14 | ||||
-rw-r--r-- | cpp/src/Ice/Emitter.h | 9 | ||||
-rw-r--r-- | cpp/src/Ice/EventHandler.h | 9 | ||||
-rw-r--r-- | cpp/src/Ice/Incoming.cpp | 14 | ||||
-rw-r--r-- | cpp/src/Ice/Outgoing.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Ice/ThreadPool.cpp | 6 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 36 | ||||
-rw-r--r-- | cpp/src/slice2freeze/slice2freeze.dsp | 8 |
10 files changed, 75 insertions, 72 deletions
diff --git a/cpp/src/Ice/Collector.cpp b/cpp/src/Ice/Collector.cpp index 9313d044540..38420dde166 100644 --- a/cpp/src/Ice/Collector.cpp +++ b/cpp/src/Ice/Collector.cpp @@ -187,12 +187,12 @@ IceInternal::Collector::message(BasicStream& stream) } } } - catch(const ConnectionLostException&) + catch (const ConnectionLostException&) { setState(StateClosed); // Connection drop from client is ok return; } - catch(const Exception& ex) + catch (const LocalException& ex) { warning(ex); setState(StateClosed); @@ -213,11 +213,15 @@ IceInternal::Collector::message(BasicStream& stream) stream.swap(*in.is()); } } - catch(const Exception& ex) + catch (const Exception& ex) { JTCSyncT<JTCRecursiveMutex> sync(*this); warning(ex); } + catch (...) + { + assert(false); // Should not happen + } } while (batch && stream.i < stream.b.end()); } @@ -253,12 +257,12 @@ IceInternal::Collector::message(BasicStream& stream) closeConnection(); } } - catch(const ConnectionLostException&) + catch (const ConnectionLostException&) { setState(StateClosed); // Connection drop from client is ok return; } - catch(const Exception& ex) + catch (const LocalException& ex) { warning(ex); setState(StateClosed); @@ -315,7 +319,7 @@ IceInternal::Collector::tryDestroy() { setState(StateClosing); } - catch(...) + catch (...) { unlock(); throw; @@ -399,12 +403,12 @@ IceInternal::Collector::setState(State state) { closeConnection(); } - catch(const ConnectionLostException&) + catch (const ConnectionLostException&) { state = StateClosed; setState(state); // Connection drop from client is ok } - catch(const Exception& ex) + catch (const LocalException& ex) { warning(ex); state = StateClosed; @@ -458,7 +462,7 @@ IceInternal::Collector::closeConnection() } void -IceInternal::Collector::warning(const LocalException& ex) const +IceInternal::Collector::warning(const Exception& ex) const { if (_warnAboutExceptions) { @@ -555,11 +559,11 @@ IceInternal::CollectorFactory::message(BasicStream&) collector->activate(); _collectors.push_back(collector); } - catch(const TimeoutException&) + catch (const TimeoutException&) { // Ignore timeouts } - catch(const Exception& ex) + catch (const LocalException& ex) { warning(ex); destroy(); @@ -628,7 +632,7 @@ IceInternal::CollectorFactory::CollectorFactory(const InstancePtr& instance, _threadPool = _instance->threadPool(); } } - catch(...) + catch (...) { setState(StateClosed); throw; @@ -725,7 +729,7 @@ IceInternal::CollectorFactory::clearBacklog() CollectorPtr collector = new Collector(_instance, _adapter, transceiver, _endpoint); collector->destroy(); } - catch(const Exception&) + catch (const Exception&) { break; } @@ -733,7 +737,7 @@ IceInternal::CollectorFactory::clearBacklog() } void -IceInternal::CollectorFactory::warning(const LocalException& ex) const +IceInternal::CollectorFactory::warning(const Exception& ex) const { if (_warnAboutExceptions) { diff --git a/cpp/src/Ice/Collector.h b/cpp/src/Ice/Collector.h index 891afdccae8..38b8cede96e 100644 --- a/cpp/src/Ice/Collector.h +++ b/cpp/src/Ice/Collector.h @@ -23,17 +23,10 @@ #include <Ice/EventHandler.h> #include <list> -namespace IceUtil -{ - -class Exception; - -} - namespace Ice { -typedef IceUtil::Exception LocalException; +class LocalException; class ObjectAdapterI; } @@ -81,7 +74,7 @@ private: void setState(State); void closeConnection(); - void warning(const ::Ice::LocalException&) const; + void warning(const ::Ice::Exception&) const; ::Ice::ObjectAdapterPtr _adapter; TransceiverPtr _transceiver; @@ -132,7 +125,7 @@ private: void setState(State); void clearBacklog(); - void warning(const ::Ice::LocalException&) const; + void warning(const ::Ice::Exception&) const; ::Ice::ObjectAdapterPtr _adapter; AcceptorPtr _acceptor; diff --git a/cpp/src/Ice/Emitter.cpp b/cpp/src/Ice/Emitter.cpp index a157323bc4a..34babb67a98 100644 --- a/cpp/src/Ice/Emitter.cpp +++ b/cpp/src/Ice/Emitter.cpp @@ -96,7 +96,7 @@ IceInternal::Emitter::sendRequest(Outgoing* out, bool oneway) traceRequest("sending request", *os, _logger, _traceLevels); _transceiver->write(*os, _endpoint->timeout()); } - catch(const Exception& ex) + catch(const LocalException& ex) { setState(StateClosed, ex); ex._throw(); @@ -203,7 +203,7 @@ IceInternal::Emitter::flushBatchRequest() _batchStream.swap(dummy); assert(_batchStream.b.empty()); } - catch(const Exception& ex) + catch(const LocalException& ex) { setState(StateClosed, ex); ex._throw(); @@ -307,7 +307,7 @@ IceInternal::Emitter::message(BasicStream& stream) } } } - catch(const Exception& ex) + catch(const LocalException& ex) { setState(StateClosed, ex); return; @@ -405,7 +405,7 @@ IceInternal::Emitter::setState(State state, const LocalException& ex) if (!_exception.get()) { - _exception = auto_ptr<LocalException>(ex._clone()); + _exception = auto_ptr<LocalException>(dynamic_cast<LocalException*>(ex._clone())); } for (std::map< ::Ice::Int, Outgoing*>::iterator p = _requests.begin(); p != _requests.end(); ++p) @@ -487,15 +487,15 @@ IceInternal::EmitterFactory::create(const vector<EndpointPtr>& endpoints) } catch (const SocketException& ex) { - exception = auto_ptr<LocalException>(ex._clone()); + exception = auto_ptr<LocalException>(dynamic_cast<LocalException*>(ex._clone())); } catch (const DNSException& ex) { - exception = auto_ptr<LocalException>(ex._clone()); + exception = auto_ptr<LocalException>(dynamic_cast<LocalException*>(ex._clone())); } catch (const TimeoutException& ex) { - exception = auto_ptr<LocalException>(ex._clone()); + exception = auto_ptr<LocalException>(dynamic_cast<LocalException*>(ex._clone())); } ++q; diff --git a/cpp/src/Ice/Emitter.h b/cpp/src/Ice/Emitter.h index d12c5330fc5..9330e7010bb 100644 --- a/cpp/src/Ice/Emitter.h +++ b/cpp/src/Ice/Emitter.h @@ -21,17 +21,10 @@ #include <Ice/LoggerF.h> #include <Ice/EventHandler.h> -namespace IceUtil -{ - -class Exception; - -} - namespace Ice { -typedef IceUtil::Exception LocalException; +class LocalException; } diff --git a/cpp/src/Ice/EventHandler.h b/cpp/src/Ice/EventHandler.h index 3b788daaee7..14190238004 100644 --- a/cpp/src/Ice/EventHandler.h +++ b/cpp/src/Ice/EventHandler.h @@ -17,17 +17,10 @@ #include <Ice/ThreadPoolF.h> #include <Ice/BasicStream.h> -namespace IceUtil -{ - -class Exception; - -} - namespace Ice { -typedef IceUtil::Exception LocalException; +class LocalException; } diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp index c08382c2ed8..30e04169f23 100644 --- a/cpp/src/Ice/Incoming.cpp +++ b/cpp/src/Ice/Incoming.cpp @@ -86,7 +86,7 @@ IceInternal::Incoming::invoke(BasicStream& is) locator->finished(_adapter, identity, servant, operation, cookie); } } - catch(const LocationForward& p) + catch (const LocationForward& ex) { if (locator && servant) { @@ -94,10 +94,10 @@ IceInternal::Incoming::invoke(BasicStream& is) } _os.b.resize(statusPos); _os.write(static_cast<Byte>(DispatchLocationForward)); - _os.write(p._prx); + _os.write(ex._prx); return; } - catch(const LocalException&) + catch (const LocalException& ex) { if (locator && servant) { @@ -105,9 +105,9 @@ IceInternal::Incoming::invoke(BasicStream& is) } _os.b.resize(statusPos); _os.write(static_cast<Byte>(DispatchUnknownLocalException)); - throw; + ex._throw(); } - catch(const UserException&) + catch (const UserException& ex) { if (locator && servant) { @@ -115,9 +115,9 @@ IceInternal::Incoming::invoke(BasicStream& is) } _os.b.resize(statusPos); _os.write(static_cast<Byte>(DispatchUnknownUserException)); - throw; + ex._throw(); } - catch(...) + catch (...) { if (locator && servant) { diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp index 2974197d876..f48b4b0c4d8 100644 --- a/cpp/src/Ice/Outgoing.cpp +++ b/cpp/src/Ice/Outgoing.cpp @@ -20,12 +20,12 @@ using namespace IceInternal; IceInternal::NonRepeatable::NonRepeatable(const NonRepeatable& ex) { - _ex = auto_ptr<LocalException>(ex.get()->_clone()); + _ex = auto_ptr<LocalException>(dynamic_cast<LocalException*>(ex.get()->_clone())); } IceInternal::NonRepeatable::NonRepeatable(const ::Ice::LocalException& ex) { - _ex = auto_ptr<LocalException>(ex._clone()); + _ex = auto_ptr<LocalException>(dynamic_cast<LocalException*>(ex._clone())); } const ::Ice::LocalException* @@ -265,7 +265,7 @@ IceInternal::Outgoing::finished(const LocalException& ex) if (_state == StateInProgress) { _state = StateLocalException; - _exception = auto_ptr<LocalException>(ex._clone()); + _exception = auto_ptr<LocalException>(dynamic_cast<LocalException*>(ex._clone())); notify(); } } diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp index dbc24fa904c..533a7e8e61b 100644 --- a/cpp/src/Ice/ThreadPool.cpp +++ b/cpp/src/Ice/ThreadPool.cpp @@ -462,7 +462,7 @@ IceInternal::ThreadPool::run() goto repeatSelect; } } - catch (const LocalException& ex) + catch (const LocalException&) { // Ignore exeptions. } @@ -564,7 +564,7 @@ IceInternal::ThreadPool::EventHandlerThread::run() { _pool->run(); } - catch (const LocalException& ex) + catch (const Exception& ex) { ostringstream s; s << "exception in thread pool:\n" << ex; @@ -573,7 +573,7 @@ IceInternal::ThreadPool::EventHandlerThread::run() catch (const JTCException& ex) { ostringstream s; - s << "exception in thread pool:\n" << ex; + s << "JThreads/C++ exception in thread pool:\n" << ex; _pool->_instance->logger()->error(s.str()); } catch (...) diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index e61c0f838d9..8e3ab81235b 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -200,7 +200,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) string scoped = p->scoped(); ExceptionPtr base = p->base(); - H << sp << nl << "struct " << name << " : "; + H << sp << nl << "class " << name << " : "; H.useCurrentPosAsIndent(); if (!base) { @@ -220,6 +220,10 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p) H.restoreIndent(); H << sb; + H.dec(); + H << nl << "public: "; + H.inc(); + if (p->isLocal()) { H << nl << _dllExport << name << "(const char*, int);"; @@ -1139,8 +1143,6 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p) C << sb; if (!throws.empty()) { - // TODO: pretty hacky, should be statically initialized, once - // per operation. ExceptionList::const_iterator r; C << nl << "static const char* __throws[] ="; C << sb; @@ -1341,6 +1343,8 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) C << sb; C << nl << "throw ::Ice::OperationNotExistException(__FILE__, __LINE__);"; C << eb; + C << nl << "try"; + C << sb; C << nl; if (ret) { @@ -1348,6 +1352,30 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p) } C << "__servant->" << name << args << ';'; C << eb; + ExceptionList throws = p->throws(); + throws.sort(); + throws.unique(); + ExceptionList::const_iterator r; + for (r = throws.begin(); r != throws.end(); ++r) + { + C << nl << "catch (const " << (*r)->scoped() << "&)"; + C << sb; + C << nl << "throw;"; + C << eb; + } + C << nl << "catch (const ::Ice::LocalException&)"; + C << sb; + C << nl << "throw ::Ice::UnknownLocalException(__FILE__, __LINE__);"; + C << eb; + C << nl << "catch (const ::Ice::UserException&)"; + C << sb; + C << nl << "throw ::Ice::UnknownUserException(__FILE__, __LINE__);"; + C << eb; + C << nl << "catch (...)"; + C << sb; + C << nl << "throw ::Ice::UnknownException(__FILE__, __LINE__);"; + C << eb; + C << eb; } Slice::Gen::ObjectDeclVisitor::ObjectDeclVisitor(Output& h, Output& c, const string& dllExport) : @@ -1864,7 +1892,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p) ExceptionList::const_iterator r; for (r = throws.begin(); r != throws.end(); ++r) { - C << nl << "catch(const " << (*r)->scoped() << "& __ex)"; + C << nl << "catch (const " << (*r)->scoped() << "& __ex)"; C << sb; C << nl << "__os->write(__ex);"; C << nl << "return ::IceInternal::DispatchUserException;"; diff --git a/cpp/src/slice2freeze/slice2freeze.dsp b/cpp/src/slice2freeze/slice2freeze.dsp index 121436a9f2e..4f19630e7dc 100644 --- a/cpp/src/slice2freeze/slice2freeze.dsp +++ b/cpp/src/slice2freeze/slice2freeze.dsp @@ -89,20 +89,12 @@ LINK32=link.exe # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
-SOURCE=.\GenUtil.cpp
-# End Source File
-# Begin Source File
-
SOURCE=.\Main.cpp
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\GenUtil.h
-# End Source File
# End Group
# Begin Group "Resource Files"
|