summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Freeze/ConnectionI.cpp36
-rw-r--r--cpp/src/Freeze/ConnectionI.h6
-rw-r--r--cpp/src/Freeze/EvictorI.cpp2280
-rw-r--r--cpp/src/Freeze/EvictorI.h16
-rw-r--r--cpp/src/Freeze/EvictorIteratorI.cpp274
-rw-r--r--cpp/src/Freeze/IndexI.cpp402
-rw-r--r--cpp/src/Freeze/MapI.cpp1552
-rw-r--r--cpp/src/Freeze/MapI.h30
-rw-r--r--cpp/src/Freeze/ObjectStore.cpp362
-rw-r--r--cpp/src/Freeze/ObjectStore.h2
-rw-r--r--cpp/src/Freeze/SharedDb.cpp402
-rw-r--r--cpp/src/Freeze/SharedDb.h34
-rw-r--r--cpp/src/Freeze/SharedDbEnv.cpp374
-rw-r--r--cpp/src/Freeze/TransactionHolder.cpp50
-rw-r--r--cpp/src/Freeze/TransactionI.cpp160
-rw-r--r--cpp/src/Freeze/TransactionI.h2
-rw-r--r--cpp/src/Freeze/Util.cpp72
-rw-r--r--cpp/src/Freeze/Util.h4
-rw-r--r--cpp/src/FreezeScript/Data.cpp44
-rw-r--r--cpp/src/FreezeScript/DumpDB.cpp268
-rw-r--r--cpp/src/FreezeScript/DumpDescriptors.cpp24
-rw-r--r--cpp/src/FreezeScript/DumpDescriptors.h2
-rw-r--r--cpp/src/FreezeScript/Functions.cpp4
-rw-r--r--cpp/src/FreezeScript/Functions.h2
-rw-r--r--cpp/src/FreezeScript/TransformAnalyzer.cpp20
-rw-r--r--cpp/src/FreezeScript/TransformAnalyzer.h4
-rw-r--r--cpp/src/FreezeScript/Transformer.cpp82
-rw-r--r--cpp/src/FreezeScript/Transformer.h6
-rw-r--r--cpp/src/FreezeScript/Util.cpp42
-rw-r--r--cpp/src/FreezeScript/transformdb.cpp738
-rw-r--r--cpp/src/Glacier2/Blobject.cpp510
-rw-r--r--cpp/src/Glacier2/Blobject.h2
-rw-r--r--cpp/src/Glacier2/ClientBlobject.cpp138
-rw-r--r--cpp/src/Glacier2/ClientBlobject.h2
-rwxr-xr-xcpp/src/Glacier2/CryptPermissionsVerifierI.cpp4
-rwxr-xr-xcpp/src/Glacier2/FilterI.h76
-rwxr-xr-xcpp/src/Glacier2/FilterManager.cpp350
-rwxr-xr-xcpp/src/Glacier2/FilterManager.h12
-rw-r--r--cpp/src/Glacier2/Glacier2Router.cpp342
-rw-r--r--cpp/src/Glacier2/ProxyVerifier.cpp1010
-rw-r--r--cpp/src/Glacier2/RequestQueue.cpp402
-rw-r--r--cpp/src/Glacier2/RequestQueue.h2
-rw-r--r--cpp/src/Glacier2/RouterI.cpp104
-rw-r--r--cpp/src/Glacier2/RouterI.h2
-rw-r--r--cpp/src/Glacier2/RoutingTable.cpp126
-rw-r--r--cpp/src/Glacier2/RoutingTable.h4
-rw-r--r--cpp/src/Glacier2/ServerBlobject.cpp4
-rw-r--r--cpp/src/Glacier2/ServerBlobject.h2
-rw-r--r--cpp/src/Glacier2/SessionRouterI.cpp1028
-rw-r--r--cpp/src/Glacier2/SessionRouterI.h18
-rw-r--r--cpp/src/Ice/Application.cpp624
-rw-r--r--cpp/src/Ice/BasicStream.cpp1148
-rw-r--r--cpp/src/Ice/Buffer.cpp20
-rw-r--r--cpp/src/Ice/CommunicatorI.cpp146
-rw-r--r--cpp/src/Ice/ConnectionFactory.cpp1436
-rw-r--r--cpp/src/Ice/ConnectionFactory.h18
-rw-r--r--cpp/src/Ice/ConnectionI.cpp3414
-rw-r--r--cpp/src/Ice/ConnectionI.h36
-rw-r--r--cpp/src/Ice/ConnectionMonitor.cpp104
-rwxr-xr-xcpp/src/Ice/DLLMain.cpp2
-rw-r--r--cpp/src/Ice/DefaultsAndOverrides.cpp22
-rw-r--r--cpp/src/Ice/Direct.cpp110
-rw-r--r--cpp/src/Ice/DynamicLibrary.cpp32
-rw-r--r--cpp/src/Ice/EndpointFactoryManager.cpp4
-rwxr-xr-xcpp/src/Ice/EventLoggerI.cpp2
-rw-r--r--cpp/src/Ice/Exception.cpp78
-rw-r--r--cpp/src/Ice/FactoryTableDef.cpp106
-rwxr-xr-xcpp/src/Ice/GC.cpp302
-rw-r--r--cpp/src/Ice/IdentityUtil.cpp4
-rw-r--r--cpp/src/Ice/ImplicitContextI.cpp308
-rw-r--r--cpp/src/Ice/Incoming.cpp610
-rw-r--r--cpp/src/Ice/IncomingAsync.cpp120
-rw-r--r--cpp/src/Ice/Initialize.cpp74
-rw-r--r--cpp/src/Ice/Instance.cpp684
-rw-r--r--cpp/src/Ice/Instance.h8
-rw-r--r--cpp/src/Ice/LocatorInfo.cpp436
-rw-r--r--cpp/src/Ice/LoggerI.cpp6
-rw-r--r--cpp/src/Ice/LoggerUtil.cpp8
-rw-r--r--cpp/src/Ice/Network.cpp1164
-rw-r--r--cpp/src/Ice/Object.cpp110
-rw-r--r--cpp/src/Ice/ObjectAdapterFactory.cpp146
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp994
-rw-r--r--cpp/src/Ice/ObjectAdapterI.h6
-rw-r--r--cpp/src/Ice/ObjectFactoryManager.cpp102
-rw-r--r--cpp/src/Ice/Outgoing.cpp714
-rw-r--r--cpp/src/Ice/OutgoingAsync.cpp596
-rw-r--r--cpp/src/Ice/PluginManagerI.cpp198
-rw-r--r--cpp/src/Ice/PropertiesI.cpp142
-rw-r--r--cpp/src/Ice/Protocol.cpp2
-rw-r--r--cpp/src/Ice/Proxy.cpp974
-rw-r--r--cpp/src/Ice/ProxyFactory.cpp190
-rw-r--r--cpp/src/Ice/Reference.cpp904
-rw-r--r--cpp/src/Ice/Reference.h30
-rw-r--r--cpp/src/Ice/ReferenceFactory.cpp656
-rw-r--r--cpp/src/Ice/ReferenceFactory.h10
-rw-r--r--cpp/src/Ice/RouterInfo.cpp164
-rw-r--r--cpp/src/Ice/ServantManager.cpp198
-rwxr-xr-xcpp/src/Ice/Service.cpp366
-rw-r--r--cpp/src/Ice/SharedContext.h4
-rw-r--r--cpp/src/Ice/SliceChecksums.cpp8
-rwxr-xr-xcpp/src/Ice/StringConverter.cpp66
-rw-r--r--cpp/src/Ice/TcpAcceptor.cpp40
-rw-r--r--cpp/src/Ice/TcpConnector.cpp8
-rw-r--r--cpp/src/Ice/TcpEndpointI.cpp352
-rw-r--r--cpp/src/Ice/TcpTransceiver.cpp452
-rw-r--r--cpp/src/Ice/ThreadPool.cpp1192
-rw-r--r--cpp/src/Ice/ThreadPool.h8
-rw-r--r--cpp/src/Ice/TraceUtil.cpp514
-rw-r--r--cpp/src/Ice/UdpEndpointI.cpp602
-rw-r--r--cpp/src/Ice/UdpTransceiver.cpp460
-rw-r--r--cpp/src/Ice/UnknownEndpointI.cpp16
-rw-r--r--cpp/src/IceBox/Admin.cpp130
-rw-r--r--cpp/src/IceBox/Service.cpp6
-rw-r--r--cpp/src/IceBox/ServiceManagerI.cpp620
-rw-r--r--cpp/src/IceBox/ServiceManagerI.h8
-rw-r--r--cpp/src/IceGrid/Activator.cpp1182
-rw-r--r--cpp/src/IceGrid/Activator.h12
-rw-r--r--cpp/src/IceGrid/AdapterCache.cpp274
-rw-r--r--cpp/src/IceGrid/AdapterCache.h2
-rw-r--r--cpp/src/IceGrid/AdminI.cpp362
-rw-r--r--cpp/src/IceGrid/AdminI.h4
-rw-r--r--cpp/src/IceGrid/AdminSessionI.cpp266
-rw-r--r--cpp/src/IceGrid/AdminSessionI.h8
-rw-r--r--cpp/src/IceGrid/Allocatable.cpp476
-rw-r--r--cpp/src/IceGrid/Allocatable.h8
-rw-r--r--cpp/src/IceGrid/AllocatableObjectCache.cpp224
-rw-r--r--cpp/src/IceGrid/AllocatableObjectCache.h24
-rw-r--r--cpp/src/IceGrid/Cache.h114
-rw-r--r--cpp/src/IceGrid/Client.cpp644
-rw-r--r--cpp/src/IceGrid/Database.cpp1358
-rw-r--r--cpp/src/IceGrid/Database.h4
-rw-r--r--cpp/src/IceGrid/DescriptorBuilder.cpp216
-rw-r--r--cpp/src/IceGrid/DescriptorBuilder.h4
-rw-r--r--cpp/src/IceGrid/DescriptorHelper.cpp2678
-rw-r--r--cpp/src/IceGrid/DescriptorHelper.h18
-rw-r--r--cpp/src/IceGrid/DescriptorParser.cpp1220
-rw-r--r--cpp/src/IceGrid/DescriptorParser.h8
-rw-r--r--cpp/src/IceGrid/FileCache.cpp170
-rwxr-xr-xcpp/src/IceGrid/FileParserI.cpp6
-rw-r--r--cpp/src/IceGrid/FileUserAccountMapperI.cpp82
-rw-r--r--cpp/src/IceGrid/IceGridNode.cpp518
-rw-r--r--cpp/src/IceGrid/IceGridRegistry.cpp74
-rw-r--r--cpp/src/IceGrid/Internal.ice40
-rw-r--r--cpp/src/IceGrid/InternalRegistryI.cpp62
-rw-r--r--cpp/src/IceGrid/InternalRegistryI.h6
-rw-r--r--cpp/src/IceGrid/LocatorI.cpp414
-rw-r--r--cpp/src/IceGrid/LocatorI.h42
-rw-r--r--cpp/src/IceGrid/LocatorRegistryI.cpp370
-rw-r--r--cpp/src/IceGrid/LocatorRegistryI.h10
-rw-r--r--cpp/src/IceGrid/NodeCache.cpp824
-rw-r--r--cpp/src/IceGrid/NodeI.cpp1066
-rw-r--r--cpp/src/IceGrid/NodeI.h20
-rw-r--r--cpp/src/IceGrid/NodeSessionI.cpp208
-rw-r--r--cpp/src/IceGrid/NodeSessionI.h4
-rw-r--r--cpp/src/IceGrid/NodeSessionManager.cpp458
-rw-r--r--cpp/src/IceGrid/NodeSessionManager.h50
-rw-r--r--cpp/src/IceGrid/ObjectCache.cpp36
-rw-r--r--cpp/src/IceGrid/ObjectCache.h14
-rw-r--r--cpp/src/IceGrid/Parser.cpp1744
-rw-r--r--cpp/src/IceGrid/PlatformInfo.cpp158
-rw-r--r--cpp/src/IceGrid/QueryI.cpp40
-rw-r--r--cpp/src/IceGrid/QueryI.h2
-rw-r--r--cpp/src/IceGrid/ReapThread.cpp146
-rw-r--r--cpp/src/IceGrid/ReapThread.h48
-rw-r--r--cpp/src/IceGrid/RegistryI.cpp942
-rw-r--r--cpp/src/IceGrid/RegistryI.h8
-rw-r--r--cpp/src/IceGrid/ReplicaCache.cpp194
-rw-r--r--cpp/src/IceGrid/ReplicaSessionI.cpp134
-rw-r--r--cpp/src/IceGrid/ReplicaSessionI.h4
-rw-r--r--cpp/src/IceGrid/ReplicaSessionManager.cpp698
-rw-r--r--cpp/src/IceGrid/ReplicaSessionManager.h40
-rw-r--r--cpp/src/IceGrid/ServerAdapterI.cpp140
-rw-r--r--cpp/src/IceGrid/ServerCache.cpp1000
-rw-r--r--cpp/src/IceGrid/ServerI.cpp2484
-rw-r--r--cpp/src/IceGrid/ServerI.h32
-rw-r--r--cpp/src/IceGrid/SessionI.cpp168
-rw-r--r--cpp/src/IceGrid/SessionI.h6
-rw-r--r--cpp/src/IceGrid/SessionManager.h352
-rw-r--r--cpp/src/IceGrid/SessionServantLocatorI.cpp4
-rw-r--r--cpp/src/IceGrid/SessionServantLocatorI.h6
-rw-r--r--cpp/src/IceGrid/Topics.cpp530
-rw-r--r--cpp/src/IceGrid/Util.cpp72
-rw-r--r--cpp/src/IceGrid/Util.h26
-rw-r--r--cpp/src/IceGrid/WaitQueue.cpp160
-rw-r--r--cpp/src/IceGrid/WellKnownObjectsManager.cpp6
-rw-r--r--cpp/src/IcePatch2/Calc.cpp308
-rw-r--r--cpp/src/IcePatch2/Client.cpp264
-rwxr-xr-xcpp/src/IcePatch2/ClientUtil.cpp1144
-rw-r--r--cpp/src/IcePatch2/FileServerI.cpp58
-rw-r--r--cpp/src/IcePatch2/FileServerI.h2
-rw-r--r--cpp/src/IcePatch2/OS.cpp4
-rw-r--r--cpp/src/IcePatch2/Server.cpp116
-rw-r--r--cpp/src/IcePatch2/Util.cpp1518
-rw-r--r--cpp/src/IceSSL/AcceptorI.cpp58
-rwxr-xr-xcpp/src/IceSSL/Certificate.cpp236
-rw-r--r--cpp/src/IceSSL/ConnectorI.cpp206
-rw-r--r--cpp/src/IceSSL/EndpointI.cpp328
-rw-r--r--cpp/src/IceSSL/Instance.cpp1156
-rw-r--r--cpp/src/IceSSL/PluginI.cpp186
-rw-r--r--cpp/src/IceSSL/RFC2253.cpp444
-rw-r--r--cpp/src/IceSSL/TrustManager.cpp174
-rw-r--r--cpp/src/IceSSL/Util.cpp288
-rw-r--r--cpp/src/IceStorm/Admin.cpp310
-rw-r--r--cpp/src/IceStorm/BatchFlusher.cpp110
-rw-r--r--cpp/src/IceStorm/Instance.cpp20
-rw-r--r--cpp/src/IceStorm/Parser.cpp550
-rw-r--r--cpp/src/IceStorm/Parser.h4
-rw-r--r--cpp/src/IceStorm/Service.cpp60
-rw-r--r--cpp/src/IceStorm/Subscriber.cpp504
-rw-r--r--cpp/src/IceStorm/Subscriber.h14
-rw-r--r--cpp/src/IceStorm/SubscriberPool.cpp422
-rw-r--r--cpp/src/IceStorm/TopicI.cpp484
-rw-r--r--cpp/src/IceStorm/TopicI.h2
-rw-r--r--cpp/src/IceStorm/TopicManagerI.cpp52
-rw-r--r--cpp/src/IceStorm/TopicManagerI.h6
-rw-r--r--cpp/src/IceUtil/Cond.cpp96
-rwxr-xr-xcpp/src/IceUtil/ConvertUTF.cpp478
-rwxr-xr-xcpp/src/IceUtil/ConvertUTF.h34
-rw-r--r--cpp/src/IceUtil/CountDownLatch.cpp70
-rw-r--r--cpp/src/IceUtil/CtrlCHandler.cpp120
-rw-r--r--cpp/src/IceUtil/Exception.cpp4
-rw-r--r--cpp/src/IceUtil/InputUtil.cpp130
-rw-r--r--cpp/src/IceUtil/MD5I.cpp128
-rw-r--r--cpp/src/IceUtil/MD5I.h16
-rwxr-xr-xcpp/src/IceUtil/Options.cpp1210
-rw-r--r--cpp/src/IceUtil/OutputUtil.cpp146
-rw-r--r--cpp/src/IceUtil/RWRecMutex.cpp318
-rw-r--r--cpp/src/IceUtil/Random.cpp126
-rw-r--r--cpp/src/IceUtil/RecMutex.cpp116
-rw-r--r--cpp/src/IceUtil/StaticMutex.cpp40
-rw-r--r--cpp/src/IceUtil/StringUtil.cpp358
-rw-r--r--cpp/src/IceUtil/Thread.cpp132
-rw-r--r--cpp/src/IceUtil/ThreadException.cpp46
-rw-r--r--cpp/src/IceUtil/Time.cpp2
-rw-r--r--cpp/src/IceUtil/UUID.cpp26
-rw-r--r--cpp/src/IceUtil/Unicode.cpp116
-rw-r--r--cpp/src/Slice/CPlusPlusUtil.cpp1428
-rwxr-xr-xcpp/src/Slice/CsUtil.cpp1260
-rwxr-xr-xcpp/src/Slice/DotNetNames.cpp130
-rw-r--r--cpp/src/Slice/JavaUtil.cpp1844
-rw-r--r--cpp/src/Slice/Parser.cpp3934
-rw-r--r--cpp/src/Slice/Preprocessor.cpp226
-rw-r--r--cpp/src/Slice/PythonUtil.cpp468
-rw-r--r--cpp/src/Slice/RubyUtil.cpp1778
-rwxr-xr-xcpp/src/Slice/VbUtil.cpp1298
-rw-r--r--cpp/src/ca/ImportKey.java184
-rw-r--r--cpp/src/icecpp/cccp.c6174
-rw-r--r--cpp/src/icecpp/gansidecl.h12
-rw-r--r--cpp/src/icecpp/pcp.h14
-rw-r--r--cpp/src/icecpp/prefix.c30
-rw-r--r--cpp/src/slice2cpp/Gen.cpp4608
-rw-r--r--cpp/src/slice2cpp/Gen.h348
-rw-r--r--cpp/src/slice2cpp/Main.cpp152
-rw-r--r--cpp/src/slice2cppe/Gen.cpp2388
-rw-r--r--cpp/src/slice2cppe/Gen.h204
-rw-r--r--cpp/src/slice2cppe/Main.cpp150
-rwxr-xr-xcpp/src/slice2cs/Gen.cpp4664
-rw-r--r--cpp/src/slice2cs/Gen.h144
-rw-r--r--cpp/src/slice2cs/Main.cpp170
-rw-r--r--cpp/src/slice2docbook/Gen.cpp1678
-rw-r--r--cpp/src/slice2docbook/Main.cpp120
-rw-r--r--cpp/src/slice2freeze/Main.cpp2142
-rw-r--r--cpp/src/slice2freezej/Main.cpp1436
-rw-r--r--cpp/src/slice2html/Gen.cpp2186
-rw-r--r--cpp/src/slice2html/Gen.h4
-rw-r--r--cpp/src/slice2html/Main.cpp164
-rw-r--r--cpp/src/slice2java/Gen.cpp3508
-rw-r--r--cpp/src/slice2java/Gen.h12
-rw-r--r--cpp/src/slice2java/Main.cpp204
-rw-r--r--cpp/src/slice2javae/Gen.cpp1432
-rw-r--r--cpp/src/slice2javae/Gen.h2
-rw-r--r--cpp/src/slice2javae/Main.cpp162
-rw-r--r--cpp/src/slice2py/Main.cpp182
-rw-r--r--cpp/src/slice2rb/Main.cpp152
-rwxr-xr-xcpp/src/slice2vb/Gen.cpp5302
-rw-r--r--cpp/src/slice2vb/Gen.h140
-rw-r--r--cpp/src/slice2vb/Main.cpp170
277 files changed, 59757 insertions, 59757 deletions
diff --git a/cpp/src/Freeze/ConnectionI.cpp b/cpp/src/Freeze/ConnectionI.cpp
index 8b823a613ad..3f93a4eebaa 100644
--- a/cpp/src/Freeze/ConnectionI.cpp
+++ b/cpp/src/Freeze/ConnectionI.cpp
@@ -21,7 +21,7 @@ Freeze::ConnectionI::beginTransaction()
{
if(_transaction != 0)
{
- throw TransactionAlreadyInProgressException(__FILE__, __LINE__);
+ throw TransactionAlreadyInProgressException(__FILE__, __LINE__);
}
closeAllIterators();
_transaction = new TransactionI(this);
@@ -39,21 +39,21 @@ Freeze::ConnectionI::close()
{
if(_transaction != 0)
{
- try
- {
- _transaction->rollback();
- }
- catch(const DatabaseException&)
- {
- //
- // Ignored
- //
- }
+ try
+ {
+ _transaction->rollback();
+ }
+ catch(const DatabaseException&)
+ {
+ //
+ // Ignored
+ //
+ }
}
while(!_mapList.empty())
{
- (*_mapList.begin())->close();
+ (*_mapList.begin())->close();
}
_dbEnv = 0;
@@ -79,7 +79,7 @@ Freeze::ConnectionI::~ConnectionI()
}
Freeze::ConnectionI::ConnectionI(const CommunicatorPtr& communicator,
- const string& envName, DbEnv* dbEnv) :
+ const string& envName, DbEnv* dbEnv) :
_communicator(communicator),
_dbEnv(SharedDbEnv::get(communicator, envName, dbEnv)),
_envName(envName),
@@ -93,9 +93,9 @@ void
Freeze::ConnectionI::closeAllIterators()
{
for(list<MapHelperI*>::iterator p = _mapList.begin(); p != _mapList.end();
- ++p)
+ ++p)
{
- (*p)->closeAllIterators();
+ (*p)->closeAllIterators();
}
}
@@ -113,7 +113,7 @@ Freeze::ConnectionI::unregisterMap(MapHelperI* m)
Freeze::ConnectionPtr
Freeze::createConnection(const CommunicatorPtr& communicator,
- const string& envName)
+ const string& envName)
{
return new ConnectionI(communicator, envName, 0);
@@ -121,8 +121,8 @@ Freeze::createConnection(const CommunicatorPtr& communicator,
Freeze::ConnectionPtr
Freeze::createConnection(const CommunicatorPtr& communicator,
- const string& envName,
- DbEnv& dbEnv)
+ const string& envName,
+ DbEnv& dbEnv)
{
return new ConnectionI(communicator, envName, &dbEnv);
}
diff --git a/cpp/src/Freeze/ConnectionI.h b/cpp/src/Freeze/ConnectionI.h
index 7ee5a59390e..987077b1adf 100644
--- a/cpp/src/Freeze/ConnectionI.h
+++ b/cpp/src/Freeze/ConnectionI.h
@@ -43,7 +43,7 @@ public:
virtual ~ConnectionI();
ConnectionI(const Ice::CommunicatorPtr& communicator,
- const std::string& envName, DbEnv*);
+ const std::string& envName, DbEnv*);
void
closeAllIterators();
@@ -101,11 +101,11 @@ ConnectionI::dbTxn() const
{
if(_transaction == 0)
{
- return 0;
+ return 0;
}
else
{
- return _transaction->dbTxn();
+ return _transaction->dbTxn();
}
}
diff --git a/cpp/src/Freeze/EvictorI.cpp b/cpp/src/Freeze/EvictorI.cpp
index 75e1722c004..a3bffc1a2bc 100644
--- a/cpp/src/Freeze/EvictorI.cpp
+++ b/cpp/src/Freeze/EvictorI.cpp
@@ -36,23 +36,23 @@ string Freeze::EvictorI::indexPrefix = "$index:";
Freeze::EvictorPtr
Freeze::createEvictor(const ObjectAdapterPtr& adapter,
- const string& envName,
- const string& filename,
- const ServantInitializerPtr& initializer,
- const vector<IndexPtr>& indices,
- bool createDb)
+ const string& envName,
+ const string& filename,
+ const ServantInitializerPtr& initializer,
+ const vector<IndexPtr>& indices,
+ bool createDb)
{
return new EvictorI(adapter, envName, 0, filename, initializer, indices, createDb);
}
Freeze::EvictorPtr
Freeze::createEvictor(const ObjectAdapterPtr& adapter,
- const string& envName,
- DbEnv& dbEnv,
- const string& filename,
- const ServantInitializerPtr& initializer,
- const vector<IndexPtr>& indices,
- bool createDb)
+ const string& envName,
+ DbEnv& dbEnv,
+ const string& filename,
+ const ServantInitializerPtr& initializer,
+ const vector<IndexPtr>& indices,
+ bool createDb)
{
return new EvictorI(adapter, envName, &dbEnv, filename, initializer, indices, createDb);
}
@@ -78,11 +78,11 @@ handleFatalError(const Freeze::EvictorPtr& evictor, const Ice::CommunicatorPtr&
IceUtil::StaticMutex::Lock lock(fatalErrorCallbackMutex);
if(fatalErrorCallback != 0)
{
- fatalErrorCallback(evictor, communicator);
+ fatalErrorCallback(evictor, communicator);
}
else
{
- ::abort();
+ ::abort();
}
}
@@ -112,7 +112,7 @@ Freeze::DeactivateController::Guard::Guard(DeactivateController& controller) :
Lock sync(controller);
if(controller._deactivated || _controller._deactivating)
{
- throw EvictorDeactivatedException(__FILE__, __LINE__);
+ throw EvictorDeactivatedException(__FILE__, __LINE__);
}
controller._guardCount++;
}
@@ -123,11 +123,11 @@ Freeze::DeactivateController::Guard::~Guard()
_controller._guardCount--;
if(_controller._deactivating && _controller._guardCount == 0)
{
- //
- // Notify all the threads -- although we only want to
- // reach the thread doing the deactivation.
- //
- _controller.notifyAll();
+ //
+ // Notify all the threads -- although we only want to
+ // reach the thread doing the deactivation.
+ //
+ _controller.notifyAll();
}
}
@@ -153,40 +153,40 @@ Freeze::DeactivateController::deactivate()
if(_deactivated)
{
- return false;
+ return false;
}
if(_deactivating)
{
- //
- // Wait for deactivated
- //
- while(!_deactivated)
- {
- wait();
- }
- return false;
+ //
+ // Wait for deactivated
+ //
+ while(!_deactivated)
+ {
+ wait();
+ }
+ return false;
}
else
{
- _deactivating = true;
- while(_guardCount > 0)
- {
- if(_evictor->trace() >= 1)
- {
- Trace out(_evictor->communicator()->getLogger(), "Freeze.Evictor");
- out << "*** Waiting for " << _guardCount << " threads to complete before starting deactivation.";
- }
-
- wait();
- }
-
- if(_evictor->trace() >= 1)
- {
- Trace out(_evictor->communicator()->getLogger(), "Freeze.Evictor");
- out << "Starting deactivation.";
- }
- return true;
+ _deactivating = true;
+ while(_guardCount > 0)
+ {
+ if(_evictor->trace() >= 1)
+ {
+ Trace out(_evictor->communicator()->getLogger(), "Freeze.Evictor");
+ out << "*** Waiting for " << _guardCount << " threads to complete before starting deactivation.";
+ }
+
+ wait();
+ }
+
+ if(_evictor->trace() >= 1)
+ {
+ Trace out(_evictor->communicator()->getLogger(), "Freeze.Evictor");
+ out << "Starting deactivation.";
+ }
+ return true;
}
}
@@ -195,8 +195,8 @@ Freeze::DeactivateController::deactivationComplete()
{
if(_evictor->trace() >= 1)
{
- Trace out(_evictor->communicator()->getLogger(), "Freeze.Evictor");
- out << "Deactivation complete.";
+ Trace out(_evictor->communicator()->getLogger(), "Freeze.Evictor");
+ out << "Deactivation complete.";
}
Lock sync(*this);
@@ -225,20 +225,20 @@ Freeze::WatchDogThread::run()
while(!_done)
{
- if(_active)
- {
- if(timedWait(_timeout) == false && _active && !_done)
- {
- Error out(_evictor.communicator()->getLogger());
- out << "Fatal error: streaming watch dog thread timed out.";
- out.flush();
- handleFatalError(&_evictor, _evictor.communicator());
- }
- }
- else
- {
- wait();
- }
+ if(_active)
+ {
+ if(timedWait(_timeout) == false && _active && !_done)
+ {
+ Error out(_evictor.communicator()->getLogger());
+ out << "Fatal error: streaming watch dog thread timed out.";
+ out.flush();
+ handleFatalError(&_evictor, _evictor.communicator());
+ }
+ }
+ else
+ {
+ wait();
+ }
}
}
@@ -270,12 +270,12 @@ Freeze::WatchDogThread::terminate()
//
Freeze::EvictorI::EvictorI(const ObjectAdapterPtr& adapter,
- const string& envName,
- DbEnv* dbEnv,
- const string& filename,
- const ServantInitializerPtr& initializer,
- const vector<IndexPtr>& indices,
- bool createDb) :
+ const string& envName,
+ DbEnv* dbEnv,
+ const string& filename,
+ const ServantInitializerPtr& initializer,
+ const vector<IndexPtr>& indices,
+ bool createDb) :
_evictorSize(10),
_currentEvictorSize(0),
@@ -304,10 +304,10 @@ Freeze::EvictorI::EvictorI(const ObjectAdapterPtr& adapter,
//
_saveSizeTrigger = _communicator->getProperties()->
- getPropertyAsIntWithDefault(propertyPrefix + ".SaveSizeTrigger", 10);
+ getPropertyAsIntWithDefault(propertyPrefix + ".SaveSizeTrigger", 10);
Int savePeriod = _communicator->getProperties()->
- getPropertyAsIntWithDefault(propertyPrefix + ".SavePeriod", 60 * 1000);
+ getPropertyAsIntWithDefault(propertyPrefix + ".SavePeriod", 60 * 1000);
_savePeriod = IceUtil::Time::milliSeconds(savePeriod);
@@ -315,17 +315,17 @@ Freeze::EvictorI::EvictorI(const ObjectAdapterPtr& adapter,
// By default, we save at most 10 * SaveSizeTrigger objects per transaction
//
_maxTxSize = _communicator->getProperties()->
- getPropertyAsIntWithDefault(propertyPrefix + ".MaxTxSize", 10 * _saveSizeTrigger);
+ getPropertyAsIntWithDefault(propertyPrefix + ".MaxTxSize", 10 * _saveSizeTrigger);
if(_maxTxSize <= 0)
{
- _maxTxSize = 100;
- }
+ _maxTxSize = 100;
+ }
bool populateEmptyIndices =
- (_communicator->getProperties()->
- getPropertyAsIntWithDefault(propertyPrefix + ".PopulateEmptyIndices", 0) != 0);
-
+ (_communicator->getProperties()->
+ getPropertyAsIntWithDefault(propertyPrefix + ".PopulateEmptyIndices", 0) != 0);
+
//
// Instantiate all Dbs in 2 steps:
// (1) iterate over the indices and create ObjectStore with indices
@@ -342,57 +342,57 @@ Freeze::EvictorI::EvictorI(const ObjectAdapterPtr& adapter,
for(vector<IndexPtr>::const_iterator i = indices.begin(); i != indices.end(); ++i)
{
- string facet = (*i)->facet();
+ string facet = (*i)->facet();
- StoreMap::iterator q = _storeMap.find(facet);
- if(q == _storeMap.end())
- {
- //
- // New db
- //
+ StoreMap::iterator q = _storeMap.find(facet);
+ if(q == _storeMap.end())
+ {
+ //
+ // New db
+ //
- vector<IndexPtr> storeIndices;
+ vector<IndexPtr> storeIndices;
- for(vector<IndexPtr>::const_iterator r = i; r != indices.end(); ++r)
- {
- if((*r)->facet() == facet)
- {
- storeIndices.push_back(*r);
- }
- }
- ObjectStore* store = new ObjectStore(facet, _createDb, this, storeIndices, populateEmptyIndices);
- _storeMap.insert(StoreMap::value_type(facet, store));
- }
+ for(vector<IndexPtr>::const_iterator r = i; r != indices.end(); ++r)
+ {
+ if((*r)->facet() == facet)
+ {
+ storeIndices.push_back(*r);
+ }
+ }
+ ObjectStore* store = new ObjectStore(facet, _createDb, this, storeIndices, populateEmptyIndices);
+ _storeMap.insert(StoreMap::value_type(facet, store));
+ }
}
for(vector<string>::iterator p = dbs.begin(); p != dbs.end(); ++p)
{
- string facet = *p;
- if(facet == defaultDb)
- {
- facet = "";
- }
-
- pair<StoreMap::iterator, bool> ir =
- _storeMap.insert(StoreMap::value_type(facet, 0));
-
- if(ir.second)
- {
- ir.first->second = new ObjectStore(facet, _createDb, this);
- }
+ string facet = *p;
+ if(facet == defaultDb)
+ {
+ facet = "";
+ }
+
+ pair<StoreMap::iterator, bool> ir =
+ _storeMap.insert(StoreMap::value_type(facet, 0));
+
+ if(ir.second)
+ {
+ ir.first->second = new ObjectStore(facet, _createDb, this);
+ }
}
//
// By default, no stream timeout
//
long streamTimeout = _communicator->getProperties()->
- getPropertyAsIntWithDefault(propertyPrefix+ ".StreamTimeout", 0) * 1000;
+ getPropertyAsIntWithDefault(propertyPrefix+ ".StreamTimeout", 0) * 1000;
if(streamTimeout > 0)
{
- _watchDogThread = new WatchDogThread(streamTimeout, *this);
- _watchDogThread->start();
+ _watchDogThread = new WatchDogThread(streamTimeout, *this);
+ _watchDogThread->start();
}
//
@@ -405,13 +405,13 @@ Freeze::EvictorI::~EvictorI()
{
if(!_deactivateController.deactivated())
{
- Warning out(_communicator->getLogger());
- out << "evictor has not been deactivated";
+ Warning out(_communicator->getLogger());
+ out << "evictor has not been deactivated";
- //
- // Need to deactivate to save objects and join saving thread
- //
- deactivate("");
+ //
+ // Need to deactivate to save objects and join saving thread
+ //
+ deactivate("");
}
//
@@ -419,7 +419,7 @@ Freeze::EvictorI::~EvictorI()
//
for(StoreMap::iterator p = _storeMap.begin(); p != _storeMap.end(); ++p)
{
- delete (*p).second;
+ delete (*p).second;
}
}
@@ -435,7 +435,7 @@ Freeze::EvictorI::setSize(Int evictorSize)
//
if(evictorSize < 0)
{
- return;
+ return;
}
//
@@ -473,35 +473,35 @@ Freeze::EvictorI::addFacet(const ObjectPtr& servant, const Identity& ident, cons
for(;;)
{
- {
- Lock sync(*this);
-
- StoreMap::iterator p = _storeMap.find(facet);
- if(p == _storeMap.end())
- {
- if(store != 0)
- {
- _storeMap.insert(StoreMap::value_type(facet, store));
- }
- }
- else
- {
- delete store;
- store = (*p).second;
- assert(store != 0);
- }
- }
-
- if(store == 0)
- {
- assert(facet != "");
- store = new ObjectStore(facet, _createDb, this);
- // loop
- }
- else
- {
- break; // for(;;)
- }
+ {
+ Lock sync(*this);
+
+ StoreMap::iterator p = _storeMap.find(facet);
+ if(p == _storeMap.end())
+ {
+ if(store != 0)
+ {
+ _storeMap.insert(StoreMap::value_type(facet, store));
+ }
+ }
+ else
+ {
+ delete store;
+ store = (*p).second;
+ assert(store != 0);
+ }
+ }
+
+ if(store == 0)
+ {
+ assert(facet != "");
+ store = new ObjectStore(facet, _createDb, this);
+ // loop
+ }
+ else
+ {
+ break; // for(;;)
+ }
}
assert(store != 0);
@@ -509,103 +509,103 @@ Freeze::EvictorI::addFacet(const ObjectPtr& servant, const Identity& ident, cons
for(;;)
{
- //
- // Create a new entry
- //
-
- EvictorElementPtr element = new EvictorElement(*store);
- element->status = EvictorElement::dead;
- EvictorElementPtr oldElt = store->putIfAbsent(ident, element);
+ //
+ // Create a new entry
+ //
+
+ EvictorElementPtr element = new EvictorElement(*store);
+ element->status = EvictorElement::dead;
+ EvictorElementPtr oldElt = store->putIfAbsent(ident, element);
- if(oldElt != 0)
- {
- element = oldElt;
- }
-
- {
- Lock sync(*this);
-
- if(element->stale)
- {
- //
- // Try again
- //
- continue;
- }
- fixEvictPosition(element);
-
- IceUtil::Mutex::Lock lock(element->mutex);
-
- switch(element->status)
- {
- case EvictorElement::clean:
- case EvictorElement::created:
- case EvictorElement::modified:
- {
- alreadyThere = true;
- break;
- }
- case EvictorElement::destroyed:
- {
- element->status = EvictorElement::modified;
- element->rec.servant = servant;
-
- //
- // No need to push it on the modified queue, as a destroyed object
- // is either already on the queue or about to be saved. When saved,
- // it becomes dead.
- //
- break;
- }
- case EvictorElement::dead:
- {
- element->status = EvictorElement::created;
- ObjectRecord& rec = element->rec;
-
- rec.servant = servant;
- rec.stats.creationTime = IceUtil::Time::now().toMilliSeconds();
- rec.stats.lastSaveTime = 0;
- rec.stats.avgSaveTime = 0;
-
- addToModifiedQueue(element);
- break;
- }
- default:
- {
- assert(0);
- break;
- }
- }
- }
- break; // for(;;)
+ if(oldElt != 0)
+ {
+ element = oldElt;
+ }
+
+ {
+ Lock sync(*this);
+
+ if(element->stale)
+ {
+ //
+ // Try again
+ //
+ continue;
+ }
+ fixEvictPosition(element);
+
+ IceUtil::Mutex::Lock lock(element->mutex);
+
+ switch(element->status)
+ {
+ case EvictorElement::clean:
+ case EvictorElement::created:
+ case EvictorElement::modified:
+ {
+ alreadyThere = true;
+ break;
+ }
+ case EvictorElement::destroyed:
+ {
+ element->status = EvictorElement::modified;
+ element->rec.servant = servant;
+
+ //
+ // No need to push it on the modified queue, as a destroyed object
+ // is either already on the queue or about to be saved. When saved,
+ // it becomes dead.
+ //
+ break;
+ }
+ case EvictorElement::dead:
+ {
+ element->status = EvictorElement::created;
+ ObjectRecord& rec = element->rec;
+
+ rec.servant = servant;
+ rec.stats.creationTime = IceUtil::Time::now().toMilliSeconds();
+ rec.stats.lastSaveTime = 0;
+ rec.stats.avgSaveTime = 0;
+
+ addToModifiedQueue(element);
+ break;
+ }
+ default:
+ {
+ assert(0);
+ break;
+ }
+ }
+ }
+ break; // for(;;)
}
if(alreadyThere)
{
- AlreadyRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "servant";
- ex.id = _communicator->identityToString(ident);
- if(!facet.empty())
- {
- ex.id += " -f " + IceUtil::escapeString(facet, "");
- }
- throw ex;
+ AlreadyRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "servant";
+ ex.id = _communicator->identityToString(ident);
+ if(!facet.empty())
+ {
+ ex.id += " -f " + IceUtil::escapeString(facet, "");
+ }
+ throw ex;
}
if(_trace >= 1)
{
- Trace out(_communicator->getLogger(), "Freeze.Evictor");
- out << "added object \"" << _communicator->identityToString(ident) << "\"";
- if(!facet.empty())
- {
- out << " with facet \"" << facet << "\"";
- }
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "added object \"" << _communicator->identityToString(ident) << "\"";
+ if(!facet.empty())
+ {
+ out << " with facet \"" << facet << "\"";
+ }
}
ObjectPrx obj = _adapter->createProxy(ident);
if(!facet.empty())
{
- obj = obj->ice_facet(facet);
+ obj = obj->ice_facet(facet);
}
return obj;
}
@@ -627,108 +627,108 @@ Freeze::EvictorI::removeFacet(const Identity& ident, const string& facet)
if(store != 0)
{
- for(;;)
- {
- //
- // Retrieve object
- //
-
- EvictorElementPtr element = store->pin(ident);
- if(element != 0)
- {
- Lock sync(*this);
- if(element->stale)
- {
- //
- // Try again
- //
- continue;
- }
-
- fixEvictPosition(element);
- {
- IceUtil::Mutex::Lock lock(element->mutex);
-
- switch(element->status)
- {
- case EvictorElement::clean:
- {
- servant = element->rec.servant;
- element->status = EvictorElement::destroyed;
- element->rec.servant = 0;
- addToModifiedQueue(element);
- break;
- }
- case EvictorElement::created:
- {
- servant = element->rec.servant;
- element->status = EvictorElement::dead;
- element->rec.servant = 0;
- break;
- }
- case EvictorElement::modified:
- {
- servant = element->rec.servant;
- element->status = EvictorElement::destroyed;
- element->rec.servant = 0;
- //
- // Not necessary to push it on the modified queue, as a modified
- // element is either on the queue already or about to be saved
- // (at which point it becomes clean)
- //
- break;
- }
- case EvictorElement::destroyed:
- case EvictorElement::dead:
- {
- break;
- }
- default:
- {
- assert(0);
- break;
- }
- }
- }
- if(element->keepCount > 0)
- {
- assert(servant != 0);
-
- element->keepCount = 0;
- //
- // Add to front of evictor queue
- //
- // Note that save evicts dead objects
- //
- _evictorList.push_front(element);
- _currentEvictorSize++;
- element->evictPosition = _evictorList.begin();
- }
- }
- break; // for(;;)
- }
+ for(;;)
+ {
+ //
+ // Retrieve object
+ //
+
+ EvictorElementPtr element = store->pin(ident);
+ if(element != 0)
+ {
+ Lock sync(*this);
+ if(element->stale)
+ {
+ //
+ // Try again
+ //
+ continue;
+ }
+
+ fixEvictPosition(element);
+ {
+ IceUtil::Mutex::Lock lock(element->mutex);
+
+ switch(element->status)
+ {
+ case EvictorElement::clean:
+ {
+ servant = element->rec.servant;
+ element->status = EvictorElement::destroyed;
+ element->rec.servant = 0;
+ addToModifiedQueue(element);
+ break;
+ }
+ case EvictorElement::created:
+ {
+ servant = element->rec.servant;
+ element->status = EvictorElement::dead;
+ element->rec.servant = 0;
+ break;
+ }
+ case EvictorElement::modified:
+ {
+ servant = element->rec.servant;
+ element->status = EvictorElement::destroyed;
+ element->rec.servant = 0;
+ //
+ // Not necessary to push it on the modified queue, as a modified
+ // element is either on the queue already or about to be saved
+ // (at which point it becomes clean)
+ //
+ break;
+ }
+ case EvictorElement::destroyed:
+ case EvictorElement::dead:
+ {
+ break;
+ }
+ default:
+ {
+ assert(0);
+ break;
+ }
+ }
+ }
+ if(element->keepCount > 0)
+ {
+ assert(servant != 0);
+
+ element->keepCount = 0;
+ //
+ // Add to front of evictor queue
+ //
+ // Note that save evicts dead objects
+ //
+ _evictorList.push_front(element);
+ _currentEvictorSize++;
+ element->evictPosition = _evictorList.begin();
+ }
+ }
+ break; // for(;;)
+ }
}
if(servant == 0)
{
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "servant";
- ex.id = _communicator->identityToString(ident);
- if(!facet.empty())
- {
- ex.id += " -f " + IceUtil::escapeString(facet, "");
- }
- throw ex;
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "servant";
+ ex.id = _communicator->identityToString(ident);
+ if(!facet.empty())
+ {
+ ex.id += " -f " + IceUtil::escapeString(facet, "");
+ }
+ throw ex;
}
if(_trace >= 1)
{
- Trace out(_communicator->getLogger(), "Freeze.Evictor");
- out << "removed object \"" << _communicator->identityToString(ident) << "\"";
- if(!facet.empty())
- {
- out << " with facet \"" << facet << "\"";
- }
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "removed object \"" << _communicator->identityToString(ident) << "\"";
+ if(!facet.empty())
+ {
+ out << " with facet \"" << facet << "\"";
+ }
}
return servant;
}
@@ -750,77 +750,77 @@ Freeze::EvictorI::keepFacet(const Identity& ident, const string& facet)
ObjectStore* store = findStore(facet);
if(store == 0)
{
- notThere = true;
+ notThere = true;
}
else
{
- for(;;)
- {
- EvictorElementPtr element = store->pin(ident);
- if(element == 0)
- {
- notThere = true;
- break;
- }
-
- Lock sync(*this);
-
- if(element->stale)
- {
- //
- // try again
- //
- continue;
- }
-
-
- {
- IceUtil::Mutex::Lock lockElement(element->mutex);
- if(element->status == EvictorElement::destroyed || element->status == EvictorElement::dead)
- {
- notThere = true;
- break;
- }
- }
-
- //
- // Found!
- //
-
- if(element->keepCount == 0)
- {
- if(element->usageCount < 0)
- {
- //
- // New object
- //
- element->usageCount = 0;
- }
- else
- {
- _evictorList.erase(element->evictPosition);
- _currentEvictorSize--;
- }
- element->keepCount = 1;
- }
- else
- {
- element->keepCount++;
- }
- break;
- }
+ for(;;)
+ {
+ EvictorElementPtr element = store->pin(ident);
+ if(element == 0)
+ {
+ notThere = true;
+ break;
+ }
+
+ Lock sync(*this);
+
+ if(element->stale)
+ {
+ //
+ // try again
+ //
+ continue;
+ }
+
+
+ {
+ IceUtil::Mutex::Lock lockElement(element->mutex);
+ if(element->status == EvictorElement::destroyed || element->status == EvictorElement::dead)
+ {
+ notThere = true;
+ break;
+ }
+ }
+
+ //
+ // Found!
+ //
+
+ if(element->keepCount == 0)
+ {
+ if(element->usageCount < 0)
+ {
+ //
+ // New object
+ //
+ element->usageCount = 0;
+ }
+ else
+ {
+ _evictorList.erase(element->evictPosition);
+ _currentEvictorSize--;
+ }
+ element->keepCount = 1;
+ }
+ else
+ {
+ element->keepCount++;
+ }
+ break;
+ }
}
if(notThere)
{
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "servant";
- ex.id = _communicator->identityToString(ident);
- if(!facet.empty())
- {
- ex.id += " -f " + IceUtil::escapeString(facet, "");
- }
- throw ex;
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "servant";
+ ex.id = _communicator->identityToString(ident);
+ if(!facet.empty())
+ {
+ ex.id += " -f " + IceUtil::escapeString(facet, "");
+ }
+ throw ex;
}
}
@@ -837,38 +837,38 @@ Freeze::EvictorI::releaseFacet(const Identity& ident, const string& facet)
DeactivateController::Guard deactivateGuard(_deactivateController);
{
- Lock sync(*this);
-
- StoreMap::iterator p = _storeMap.find(facet);
- if(p != _storeMap.end())
- {
- ObjectStore* store = (*p).second;
-
- EvictorElementPtr element = store->getIfPinned(ident);
- if(element != 0)
- {
- assert(!element->stale);
- if(element->keepCount > 0)
- {
- if(--element->keepCount == 0)
- {
- //
- // Add to front of evictor queue
- //
- // Note that the element cannot be destroyed or dead since
- // its keepCount was > 0.
- //
- _evictorList.push_front(element);
- _currentEvictorSize++;
- element->evictPosition = _evictorList.begin();
- }
- //
- // Success
- //
- return;
- }
- }
- }
+ Lock sync(*this);
+
+ StoreMap::iterator p = _storeMap.find(facet);
+ if(p != _storeMap.end())
+ {
+ ObjectStore* store = (*p).second;
+
+ EvictorElementPtr element = store->getIfPinned(ident);
+ if(element != 0)
+ {
+ assert(!element->stale);
+ if(element->keepCount > 0)
+ {
+ if(--element->keepCount == 0)
+ {
+ //
+ // Add to front of evictor queue
+ //
+ // Note that the element cannot be destroyed or dead since
+ // its keepCount was > 0.
+ //
+ _evictorList.push_front(element);
+ _currentEvictorSize++;
+ element->evictPosition = _evictorList.begin();
+ }
+ //
+ // Success
+ //
+ return;
+ }
+ }
+ }
}
NotRegisteredException ex(__FILE__, __LINE__);
@@ -876,7 +876,7 @@ Freeze::EvictorI::releaseFacet(const Identity& ident, const string& facet)
ex.id = _communicator->identityToString(ident);
if(!facet.empty())
{
- ex.id += " -f " + IceUtil::escapeString(facet, "");
+ ex.id += " -f " + IceUtil::escapeString(facet, "");
}
throw ex;
}
@@ -888,14 +888,14 @@ Freeze::EvictorI::getIterator(const string& facet, Int batchSize)
ObjectStore* store = 0;
{
- Lock sync(*this);
-
- StoreMap::iterator p = _storeMap.find(facet);
- if(p != _storeMap.end())
- {
- store = (*p).second;
- saveNowNoSync();
- }
+ Lock sync(*this);
+
+ StoreMap::iterator p = _storeMap.find(facet);
+ if(p != _storeMap.end())
+ {
+ store = (*p).second;
+ saveNowNoSync();
+ }
}
return new EvictorIteratorI(store, batchSize);
}
@@ -924,25 +924,25 @@ Freeze::EvictorI::hasFacetImpl(const Identity& ident, const string& facet)
ObjectStore* store = 0;
{
- Lock sync(*this);
+ Lock sync(*this);
- StoreMap::iterator p = _storeMap.find(facet);
- if(p == _storeMap.end())
- {
- return false;
- }
-
- store = (*p).second;
-
- EvictorElementPtr element = store->getIfPinned(ident);
- if(element != 0)
- {
- assert(!element->stale);
-
- IceUtil::Mutex::Lock lock(element->mutex);
- return element->status != EvictorElement::dead &&
- element->status != EvictorElement::destroyed;
- }
+ StoreMap::iterator p = _storeMap.find(facet);
+ if(p == _storeMap.end())
+ {
+ return false;
+ }
+
+ store = (*p).second;
+
+ EvictorElementPtr element = store->getIfPinned(ident);
+ if(element != 0)
+ {
+ assert(!element->stale);
+
+ IceUtil::Mutex::Lock lock(element->mutex);
+ return element->status != EvictorElement::dead &&
+ element->status != EvictorElement::destroyed;
+ }
}
return store->dbHasObject(ident);
}
@@ -960,45 +960,45 @@ Freeze::EvictorI::hasAnotherFacet(const Identity& ident, const string& facet)
//
StoreMap storeMapCopy;
{
- Lock sync(*this);
- storeMapCopy = _storeMap;
- }
-
+ Lock sync(*this);
+ storeMapCopy = _storeMap;
+ }
+
for(StoreMap::iterator p = storeMapCopy.begin(); p != storeMapCopy.end(); ++p)
{
- //
- // Do not check again the given facet
- //
- if((*p).first != facet)
- {
- ObjectStore* store = (*p).second;
-
- bool inCache = false;
- {
- Lock sync(*this);
-
- EvictorElementPtr element = store->getIfPinned(ident);
- if(element != 0)
- {
- inCache = true;
- assert(!element->stale);
-
- IceUtil::Mutex::Lock lock(element->mutex);
- if(element->status != EvictorElement::dead &&
- element->status != EvictorElement::destroyed)
- {
- return true;
- }
- }
- }
- if(!inCache)
- {
- if(store->dbHasObject(ident))
- {
- return true;
- }
- }
- }
+ //
+ // Do not check again the given facet
+ //
+ if((*p).first != facet)
+ {
+ ObjectStore* store = (*p).second;
+
+ bool inCache = false;
+ {
+ Lock sync(*this);
+
+ EvictorElementPtr element = store->getIfPinned(ident);
+ if(element != 0)
+ {
+ inCache = true;
+ assert(!element->stale);
+
+ IceUtil::Mutex::Lock lock(element->mutex);
+ if(element->status != EvictorElement::dead &&
+ element->status != EvictorElement::destroyed)
+ {
+ return true;
+ }
+ }
+ }
+ if(!inCache)
+ {
+ if(store->dbHasObject(ident))
+ {
+ return true;
+ }
+ }
+ }
}
return false;
}
@@ -1018,48 +1018,48 @@ Freeze::EvictorI::locate(const Current& current, LocalObjectPtr& cookie)
//
if(current.operation == "ice_ping")
{
- if(hasFacetImpl(current.id, current.facet))
- {
- if(_trace >= 3)
- {
- Trace out(_communicator->getLogger(), "Freeze.Evictor");
- out << "ice_ping found \"" << _communicator->identityToString(current.id)
- << "\" with facet \"" << current.facet + "\"";
- }
-
- cookie = 0;
- return _pingObject;
- }
- else if(hasAnotherFacet(current.id, current.facet))
- {
- if(_trace >= 3)
- {
- Trace out(_communicator->getLogger(), "Freeze.Evictor");
- out << "ice_ping raises FacetNotExistException for \"" << _communicator->identityToString(current.id)
- << "\" with facet \"" << current.facet + "\"";
- }
- throw FacetNotExistException(__FILE__, __LINE__);
- }
- else
- {
- if(_trace >= 3)
- {
- Trace out(_communicator->getLogger(), "Freeze.Evictor");
- out << "ice_ping will raise ObjectNotExistException for \""
- << _communicator->identityToString(current.id) << "\" with facet \"" << current.facet + "\"";
- }
- return 0;
- }
+ if(hasFacetImpl(current.id, current.facet))
+ {
+ if(_trace >= 3)
+ {
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "ice_ping found \"" << _communicator->identityToString(current.id)
+ << "\" with facet \"" << current.facet + "\"";
+ }
+
+ cookie = 0;
+ return _pingObject;
+ }
+ else if(hasAnotherFacet(current.id, current.facet))
+ {
+ if(_trace >= 3)
+ {
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "ice_ping raises FacetNotExistException for \"" << _communicator->identityToString(current.id)
+ << "\" with facet \"" << current.facet + "\"";
+ }
+ throw FacetNotExistException(__FILE__, __LINE__);
+ }
+ else
+ {
+ if(_trace >= 3)
+ {
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "ice_ping will raise ObjectNotExistException for \""
+ << _communicator->identityToString(current.id) << "\" with facet \"" << current.facet + "\"";
+ }
+ return 0;
+ }
}
ObjectPtr result = locateImpl(current, cookie);
if(result == 0)
{
- if(hasAnotherFacet(current.id, current.facet))
- {
- throw FacetNotExistException(__FILE__, __LINE__);
- }
+ if(hasAnotherFacet(current.id, current.facet))
+ {
+ throw FacetNotExistException(__FILE__, __LINE__);
+ }
}
return result;
}
@@ -1074,65 +1074,65 @@ Freeze::EvictorI::locateImpl(const Current& current, LocalObjectPtr& cookie)
if(store == 0)
{
if(_trace >= 2)
- {
- Trace out(_communicator->getLogger(), "Freeze.Evictor");
- out << "locate could not find a database for facet \"" << current.facet << "\"";
- }
- return 0;
+ {
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "locate could not find a database for facet \"" << current.facet << "\"";
+ }
+ return 0;
}
for(;;)
{
- EvictorElementPtr element = store->pin(current.id);
- if(element == 0)
- {
+ EvictorElementPtr element = store->pin(current.id);
+ if(element == 0)
+ {
if(_trace >= 2)
- {
- Trace out(_communicator->getLogger(), "Freeze.Evictor");
- out << "locate could not find \"" << _communicator->identityToString(current.id) << "\" in database \""
- << current.facet << "\"";
- }
- return 0;
- }
-
- Lock sync(*this);
-
- if(element->stale)
- {
- //
- // try again
- //
- continue;
- }
-
-
- IceUtil::Mutex::Lock lockElement(element->mutex);
- if(element->status == EvictorElement::destroyed || element->status == EvictorElement::dead)
- {
+ {
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "locate could not find \"" << _communicator->identityToString(current.id) << "\" in database \""
+ << current.facet << "\"";
+ }
+ return 0;
+ }
+
+ Lock sync(*this);
+
+ if(element->stale)
+ {
+ //
+ // try again
+ //
+ continue;
+ }
+
+
+ IceUtil::Mutex::Lock lockElement(element->mutex);
+ if(element->status == EvictorElement::destroyed || element->status == EvictorElement::dead)
+ {
if(_trace >= 2)
- {
- Trace out(_communicator->getLogger(), "Freeze.Evictor");
- out << "locate found \"" << _communicator->identityToString(current.id)
- << "\" in the cache for database \"" << current.facet << "\" but it was dead or destroyed";
- }
- return 0;
- }
-
- //
- // It's a good one!
- //
+ {
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "locate found \"" << _communicator->identityToString(current.id)
+ << "\" in the cache for database \"" << current.facet << "\" but it was dead or destroyed";
+ }
+ return 0;
+ }
+
+ //
+ // It's a good one!
+ //
if(_trace >= 2)
- {
- Trace out(_communicator->getLogger(), "Freeze.Evictor");
- out << "locate found \"" << _communicator->identityToString(current.id) << "\" in database \""
- << current.facet << "\"";
- }
-
- fixEvictPosition(element);
- element->usageCount++;
- cookie = element;
- assert(element->rec.servant != 0);
- return element->rec.servant;
+ {
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "locate found \"" << _communicator->identityToString(current.id) << "\" in database \""
+ << current.facet << "\"";
+ }
+
+ fixEvictPosition(element);
+ element->usageCount++;
+ cookie = element;
+ assert(element->rec.servant != 0);
+ return element->rec.servant;
}
}
@@ -1148,51 +1148,51 @@ Freeze::EvictorI::finished(const Current& current, const ObjectPtr& servant, con
if(cookie != 0)
{
- EvictorElementPtr element = EvictorElementPtr::dynamicCast(cookie);
- assert(element);
+ EvictorElementPtr element = EvictorElementPtr::dynamicCast(cookie);
+ assert(element);
- bool enqueue = false;
-
- if((_useNonmutating && current.mode != Nonmutating) ||
- (servant->ice_operationAttributes(current.operation) & 0x1) != 0)
- {
- IceUtil::Mutex::Lock lock(element->mutex);
-
- if(element->status == EvictorElement::clean)
- {
- //
- // Assume this operation updated the object
- //
- element->status = EvictorElement::modified;
- enqueue = true;
- }
- }
-
- Lock sync(*this);
-
- //
- // Only elements with a usageCount == 0 can become stale and we own
- // one count!
- //
- assert(!element->stale);
- assert(element->usageCount >= 1);
-
- //
- // Decrease the usage count of the evictor queue element.
- //
- element->usageCount--;
-
- if(enqueue)
- {
- addToModifiedQueue(element);
- }
- else if(element->usageCount == 0 && element->keepCount == 0)
- {
- //
- // Evict as many elements as necessary.
- //
- evict();
- }
+ bool enqueue = false;
+
+ if((_useNonmutating && current.mode != Nonmutating) ||
+ (servant->ice_operationAttributes(current.operation) & 0x1) != 0)
+ {
+ IceUtil::Mutex::Lock lock(element->mutex);
+
+ if(element->status == EvictorElement::clean)
+ {
+ //
+ // Assume this operation updated the object
+ //
+ element->status = EvictorElement::modified;
+ enqueue = true;
+ }
+ }
+
+ Lock sync(*this);
+
+ //
+ // Only elements with a usageCount == 0 can become stale and we own
+ // one count!
+ //
+ assert(!element->stale);
+ assert(element->usageCount >= 1);
+
+ //
+ // Decrease the usage count of the evictor queue element.
+ //
+ element->usageCount--;
+
+ if(enqueue)
+ {
+ addToModifiedQueue(element);
+ }
+ else if(element->usageCount == 0 && element->keepCount == 0)
+ {
+ //
+ // Evict as many elements as necessary.
+ //
+ evict();
+ }
}
}
@@ -1201,44 +1201,44 @@ Freeze::EvictorI::deactivate(const string&)
{
if(_deactivateController.deactivate())
{
- try
- {
- Lock sync(*this);
-
- saveNowNoSync();
-
- //
- // Set the evictor size to zero, meaning that we will evict
- // everything possible.
- //
- _evictorSize = 0;
- evict();
-
- _savingThreadDone = true;
- notifyAll();
- sync.release();
- getThreadControl().join();
-
- if(_watchDogThread != 0)
- {
- _watchDogThread->terminate();
- _watchDogThread->getThreadControl().join();
- }
-
- for(StoreMap::iterator p = _storeMap.begin(); p != _storeMap.end(); ++p)
- {
- (*p).second->close();
- }
-
- _dbEnv = 0;
- _initializer = 0;
- }
- catch(...)
- {
- _deactivateController.deactivationComplete();
- throw;
- }
- _deactivateController.deactivationComplete();
+ try
+ {
+ Lock sync(*this);
+
+ saveNowNoSync();
+
+ //
+ // Set the evictor size to zero, meaning that we will evict
+ // everything possible.
+ //
+ _evictorSize = 0;
+ evict();
+
+ _savingThreadDone = true;
+ notifyAll();
+ sync.release();
+ getThreadControl().join();
+
+ if(_watchDogThread != 0)
+ {
+ _watchDogThread->terminate();
+ _watchDogThread->getThreadControl().join();
+ }
+
+ for(StoreMap::iterator p = _storeMap.begin(); p != _storeMap.end(); ++p)
+ {
+ (*p).second->close();
+ }
+
+ _dbEnv = 0;
+ _initializer = 0;
+ }
+ catch(...)
+ {
+ _deactivateController.deactivationComplete();
+ throw;
+ }
+ _deactivateController.deactivationComplete();
}
}
@@ -1248,7 +1248,7 @@ Freeze::EvictorI::initialize(const Identity& ident, const string& facet, const O
{
if(_initializer != 0)
{
- _initializer->initialize(_adapter, ident, facet, servant);
+ _initializer->initialize(_adapter, ident, facet, servant);
}
}
@@ -1258,387 +1258,387 @@ Freeze::EvictorI::run()
{
try
{
- for(;;)
- {
- deque<EvictorElementPtr> allObjects;
- deque<EvictorElementPtr> deadObjects;
-
- size_t saveNowThreadsSize = 0;
-
- {
- Lock sync(*this);
-
- while(!_savingThreadDone &&
- (_saveNowThreads.size() == 0) &&
- (_saveSizeTrigger < 0 || static_cast<Int>(_modifiedQueue.size()) < _saveSizeTrigger))
- {
- if(_savePeriod == IceUtil::Time::milliSeconds(0))
- {
- wait();
- }
- else if(timedWait(_savePeriod) == false)
- {
- //
- // Timeout, so let's save
- //
- break; // while
- }
- }
-
- saveNowThreadsSize = _saveNowThreads.size();
-
- if(_savingThreadDone)
- {
- assert(_modifiedQueue.size() == 0);
- assert(saveNowThreadsSize == 0);
- break; // for(;;)
- }
-
- //
- // Check first if there is something to do!
- //
- if(_modifiedQueue.size() == 0)
- {
- if(saveNowThreadsSize > 0)
- {
- _saveNowThreads.clear();
- notifyAll();
- }
- continue; // for(;;)
- }
-
- _modifiedQueue.swap(allObjects);
- }
-
- const size_t size = allObjects.size();
-
- deque<StreamedObject> streamedObjectQueue;
-
- Long streamStart = IceUtil::Time::now().toMilliSeconds();
-
- //
- // Stream each element
- //
- for(size_t i = 0; i < size; i++)
- {
- EvictorElementPtr& element = allObjects[i];
-
- bool tryAgain;
- do
- {
- tryAgain = false;
- ObjectPtr servant = 0;
-
- //
- // These elements can't be stale as only elements with
- // usageCount == 0 can become stale, and the modifiedQueue
- // (us now) owns one count.
- //
-
- IceUtil::Mutex::Lock lockElement(element->mutex);
- Byte status = element->status;
-
- switch(status)
- {
- case EvictorElement::created:
- case EvictorElement::modified:
- {
- servant = element->rec.servant;
- break;
- }
- case EvictorElement::destroyed:
- {
- size_t index = streamedObjectQueue.size();
- streamedObjectQueue.resize(index + 1);
- StreamedObject& obj = streamedObjectQueue[index];
- stream(element, streamStart, obj);
-
- element->status = EvictorElement::dead;
- deadObjects.push_back(element);
-
- break;
- }
- case EvictorElement::dead:
- {
- deadObjects.push_back(element);
- break;
- }
- default:
- {
- //
- // Nothing to do (could be a duplicate)
- //
- break;
- }
- }
- if(servant == 0)
- {
- lockElement.release();
- }
- else
- {
- IceUtil::AbstractMutex* mutex = dynamic_cast<IceUtil::AbstractMutex*>(servant.get());
- if(mutex != 0)
- {
- //
- // Lock servant and then element so that user can safely lock
- // servant and call various Evictor operations
- //
-
- IceUtil::AbstractMutex::TryLock lockServant(*mutex);
- if(!lockServant.acquired())
- {
- lockElement.release();
-
- if(_watchDogThread != 0)
- {
- _watchDogThread->activate();
- }
- lockServant.acquire();
- if(_watchDogThread != 0)
- {
- _watchDogThread->deactivate();
- }
-
- lockElement.acquire();
- status = element->status;
- }
+ for(;;)
+ {
+ deque<EvictorElementPtr> allObjects;
+ deque<EvictorElementPtr> deadObjects;
+
+ size_t saveNowThreadsSize = 0;
+
+ {
+ Lock sync(*this);
+
+ while(!_savingThreadDone &&
+ (_saveNowThreads.size() == 0) &&
+ (_saveSizeTrigger < 0 || static_cast<Int>(_modifiedQueue.size()) < _saveSizeTrigger))
+ {
+ if(_savePeriod == IceUtil::Time::milliSeconds(0))
+ {
+ wait();
+ }
+ else if(timedWait(_savePeriod) == false)
+ {
+ //
+ // Timeout, so let's save
+ //
+ break; // while
+ }
+ }
+
+ saveNowThreadsSize = _saveNowThreads.size();
+
+ if(_savingThreadDone)
+ {
+ assert(_modifiedQueue.size() == 0);
+ assert(saveNowThreadsSize == 0);
+ break; // for(;;)
+ }
+
+ //
+ // Check first if there is something to do!
+ //
+ if(_modifiedQueue.size() == 0)
+ {
+ if(saveNowThreadsSize > 0)
+ {
+ _saveNowThreads.clear();
+ notifyAll();
+ }
+ continue; // for(;;)
+ }
+
+ _modifiedQueue.swap(allObjects);
+ }
+
+ const size_t size = allObjects.size();
+
+ deque<StreamedObject> streamedObjectQueue;
+
+ Long streamStart = IceUtil::Time::now().toMilliSeconds();
+
+ //
+ // Stream each element
+ //
+ for(size_t i = 0; i < size; i++)
+ {
+ EvictorElementPtr& element = allObjects[i];
+
+ bool tryAgain;
+ do
+ {
+ tryAgain = false;
+ ObjectPtr servant = 0;
+
+ //
+ // These elements can't be stale as only elements with
+ // usageCount == 0 can become stale, and the modifiedQueue
+ // (us now) owns one count.
+ //
+
+ IceUtil::Mutex::Lock lockElement(element->mutex);
+ Byte status = element->status;
+
+ switch(status)
+ {
+ case EvictorElement::created:
+ case EvictorElement::modified:
+ {
+ servant = element->rec.servant;
+ break;
+ }
+ case EvictorElement::destroyed:
+ {
+ size_t index = streamedObjectQueue.size();
+ streamedObjectQueue.resize(index + 1);
+ StreamedObject& obj = streamedObjectQueue[index];
+ stream(element, streamStart, obj);
+
+ element->status = EvictorElement::dead;
+ deadObjects.push_back(element);
+
+ break;
+ }
+ case EvictorElement::dead:
+ {
+ deadObjects.push_back(element);
+ break;
+ }
+ default:
+ {
+ //
+ // Nothing to do (could be a duplicate)
+ //
+ break;
+ }
+ }
+ if(servant == 0)
+ {
+ lockElement.release();
+ }
+ else
+ {
+ IceUtil::AbstractMutex* mutex = dynamic_cast<IceUtil::AbstractMutex*>(servant.get());
+ if(mutex != 0)
+ {
+ //
+ // Lock servant and then element so that user can safely lock
+ // servant and call various Evictor operations
+ //
+
+ IceUtil::AbstractMutex::TryLock lockServant(*mutex);
+ if(!lockServant.acquired())
+ {
+ lockElement.release();
+
+ if(_watchDogThread != 0)
+ {
+ _watchDogThread->activate();
+ }
+ lockServant.acquire();
+ if(_watchDogThread != 0)
+ {
+ _watchDogThread->deactivate();
+ }
+
+ lockElement.acquire();
+ status = element->status;
+ }
- switch(status)
- {
- case EvictorElement::created:
- case EvictorElement::modified:
- {
- if(servant == element->rec.servant)
- {
- size_t index = streamedObjectQueue.size();
- streamedObjectQueue.resize(index + 1);
- StreamedObject& obj = streamedObjectQueue[index];
- stream(element, streamStart, obj);
-
- element->status = EvictorElement::clean;
- }
- else
- {
- tryAgain = true;
- }
- break;
- }
- case EvictorElement::destroyed:
- {
- lockServant.release();
-
- size_t index = streamedObjectQueue.size();
- streamedObjectQueue.resize(index + 1);
- StreamedObject& obj = streamedObjectQueue[index];
- stream(element, streamStart, obj);
-
- element->status = EvictorElement::dead;
- deadObjects.push_back(element);
- break;
- }
- case EvictorElement::dead:
- {
- deadObjects.push_back(element);
- break;
- }
- default:
- {
- //
- // Nothing to do (could be a duplicate)
- //
- break;
- }
- }
- }
- else
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = string(typeid(*element->rec.servant).name())
- + " does not implement IceUtil::AbstractMutex";
- throw ex;
- }
- }
- } while(tryAgain);
- }
-
- if(_trace >= 1)
- {
- Long now = IceUtil::Time::now().toMilliSeconds();
- Trace out(_communicator->getLogger(), "Freeze.Evictor");
- out << "streamed " << streamedObjectQueue.size() << " objects in "
- << static_cast<Int>(now - streamStart) << " ms";
- }
-
- //
- // Now let's save all these streamed objects to disk using a transaction
- //
-
- //
- // Each time we get a deadlock, we reduce the number of objects to save
- // per transaction
- //
- size_t txSize = streamedObjectQueue.size();
- if(txSize > static_cast<size_t>(_maxTxSize))
- {
- txSize = static_cast<size_t>(_maxTxSize);
- }
- bool tryAgain;
-
- do
- {
- tryAgain = false;
-
- while(streamedObjectQueue.size() > 0)
- {
- if(txSize > streamedObjectQueue.size())
- {
- txSize = streamedObjectQueue.size();
- }
-
- Long saveStart = IceUtil::Time::now().toMilliSeconds();
- try
- {
- DbTxn* tx = 0;
- _dbEnv->getEnv()->txn_begin(0, &tx, 0);
-
- long txnId = 0;
- if(_txTrace >= 1)
- {
- txnId = (tx->id() & 0x7FFFFFFF) + 0x80000000L;
- Trace out(_communicator->getLogger(), "Freeze.Evictor");
- out << "started transaction " << hex << txnId << dec << " in saving thread";
- }
-
- try
- {
- for(size_t i = 0; i < txSize; i++)
- {
- StreamedObject& obj = streamedObjectQueue[i];
- obj.store->save(obj.key, obj.value, obj.status, tx);
- }
- }
- catch(...)
- {
- tx->abort();
- if(_txTrace >= 1)
- {
- Trace out(_communicator->getLogger(), "Freeze.Evictor");
- out << "rolled back transaction " << hex << txnId << dec;
- }
- throw;
- }
- tx->commit(0);
-
- if(_txTrace >= 1)
- {
- Trace out(_communicator->getLogger(), "Freeze.Evictor");
- out << "committed transaction " << hex << txnId << dec;
- }
-
- streamedObjectQueue.erase
- (streamedObjectQueue.begin(),
- streamedObjectQueue.begin() + txSize);
-
- if(_trace >= 1)
- {
- Long now = IceUtil::Time::now().toMilliSeconds();
- Trace out(_communicator->getLogger(), "Freeze.Evictor");
- out << "saved " << txSize << " objects in "
- << static_cast<Int>(now - saveStart) << " ms";
- }
- }
- catch(const DbDeadlockException&)
- {
- if(_deadlockWarning)
- {
- Warning out(_communicator->getLogger());
- out << "Deadlock in Freeze::EvictorI::run while writing into Db \"" + _filename
- + "\"; retrying ...";
- }
-
- tryAgain = true;
- txSize = (txSize + 1)/2;
- }
- catch(const DbException& dx)
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
- }
- }
- while(tryAgain);
-
- {
- Lock sync(*this);
-
- //
- // Release usage count
- //
- for(deque<EvictorElementPtr>::iterator p = allObjects.begin();
- p != allObjects.end(); p++)
- {
- EvictorElementPtr& element = *p;
- element->usageCount--;
- }
- allObjects.clear();
-
- for(deque<EvictorElementPtr>::iterator q = deadObjects.begin();
- q != deadObjects.end(); q++)
- {
- EvictorElementPtr& element = *q;
- if(!element->stale)
- {
- //
- // Can be stale when there are duplicate elements on the
- // deadObjecst queue
- //
-
- if(!element->stale && element->usageCount == 0 && element->keepCount == 0)
- {
- //
- // Get rid of unused dead elements
- //
- IceUtil::Mutex::Lock lockElement(element->mutex);
- if(element->status == EvictorElement::dead)
- {
- evict(element);
- }
- }
- }
- }
- deadObjects.clear();
- evict();
-
- if(saveNowThreadsSize > 0)
- {
- _saveNowThreads.erase(_saveNowThreads.begin(), _saveNowThreads.begin() + saveNowThreadsSize);
- notifyAll();
- }
- }
- }
+ switch(status)
+ {
+ case EvictorElement::created:
+ case EvictorElement::modified:
+ {
+ if(servant == element->rec.servant)
+ {
+ size_t index = streamedObjectQueue.size();
+ streamedObjectQueue.resize(index + 1);
+ StreamedObject& obj = streamedObjectQueue[index];
+ stream(element, streamStart, obj);
+
+ element->status = EvictorElement::clean;
+ }
+ else
+ {
+ tryAgain = true;
+ }
+ break;
+ }
+ case EvictorElement::destroyed:
+ {
+ lockServant.release();
+
+ size_t index = streamedObjectQueue.size();
+ streamedObjectQueue.resize(index + 1);
+ StreamedObject& obj = streamedObjectQueue[index];
+ stream(element, streamStart, obj);
+
+ element->status = EvictorElement::dead;
+ deadObjects.push_back(element);
+ break;
+ }
+ case EvictorElement::dead:
+ {
+ deadObjects.push_back(element);
+ break;
+ }
+ default:
+ {
+ //
+ // Nothing to do (could be a duplicate)
+ //
+ break;
+ }
+ }
+ }
+ else
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = string(typeid(*element->rec.servant).name())
+ + " does not implement IceUtil::AbstractMutex";
+ throw ex;
+ }
+ }
+ } while(tryAgain);
+ }
+
+ if(_trace >= 1)
+ {
+ Long now = IceUtil::Time::now().toMilliSeconds();
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "streamed " << streamedObjectQueue.size() << " objects in "
+ << static_cast<Int>(now - streamStart) << " ms";
+ }
+
+ //
+ // Now let's save all these streamed objects to disk using a transaction
+ //
+
+ //
+ // Each time we get a deadlock, we reduce the number of objects to save
+ // per transaction
+ //
+ size_t txSize = streamedObjectQueue.size();
+ if(txSize > static_cast<size_t>(_maxTxSize))
+ {
+ txSize = static_cast<size_t>(_maxTxSize);
+ }
+ bool tryAgain;
+
+ do
+ {
+ tryAgain = false;
+
+ while(streamedObjectQueue.size() > 0)
+ {
+ if(txSize > streamedObjectQueue.size())
+ {
+ txSize = streamedObjectQueue.size();
+ }
+
+ Long saveStart = IceUtil::Time::now().toMilliSeconds();
+ try
+ {
+ DbTxn* tx = 0;
+ _dbEnv->getEnv()->txn_begin(0, &tx, 0);
+
+ long txnId = 0;
+ if(_txTrace >= 1)
+ {
+ txnId = (tx->id() & 0x7FFFFFFF) + 0x80000000L;
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "started transaction " << hex << txnId << dec << " in saving thread";
+ }
+
+ try
+ {
+ for(size_t i = 0; i < txSize; i++)
+ {
+ StreamedObject& obj = streamedObjectQueue[i];
+ obj.store->save(obj.key, obj.value, obj.status, tx);
+ }
+ }
+ catch(...)
+ {
+ tx->abort();
+ if(_txTrace >= 1)
+ {
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "rolled back transaction " << hex << txnId << dec;
+ }
+ throw;
+ }
+ tx->commit(0);
+
+ if(_txTrace >= 1)
+ {
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "committed transaction " << hex << txnId << dec;
+ }
+
+ streamedObjectQueue.erase
+ (streamedObjectQueue.begin(),
+ streamedObjectQueue.begin() + txSize);
+
+ if(_trace >= 1)
+ {
+ Long now = IceUtil::Time::now().toMilliSeconds();
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "saved " << txSize << " objects in "
+ << static_cast<Int>(now - saveStart) << " ms";
+ }
+ }
+ catch(const DbDeadlockException&)
+ {
+ if(_deadlockWarning)
+ {
+ Warning out(_communicator->getLogger());
+ out << "Deadlock in Freeze::EvictorI::run while writing into Db \"" + _filename
+ + "\"; retrying ...";
+ }
+
+ tryAgain = true;
+ txSize = (txSize + 1)/2;
+ }
+ catch(const DbException& dx)
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+ }
+ }
+ while(tryAgain);
+
+ {
+ Lock sync(*this);
+
+ //
+ // Release usage count
+ //
+ for(deque<EvictorElementPtr>::iterator p = allObjects.begin();
+ p != allObjects.end(); p++)
+ {
+ EvictorElementPtr& element = *p;
+ element->usageCount--;
+ }
+ allObjects.clear();
+
+ for(deque<EvictorElementPtr>::iterator q = deadObjects.begin();
+ q != deadObjects.end(); q++)
+ {
+ EvictorElementPtr& element = *q;
+ if(!element->stale)
+ {
+ //
+ // Can be stale when there are duplicate elements on the
+ // deadObjecst queue
+ //
+
+ if(!element->stale && element->usageCount == 0 && element->keepCount == 0)
+ {
+ //
+ // Get rid of unused dead elements
+ //
+ IceUtil::Mutex::Lock lockElement(element->mutex);
+ if(element->status == EvictorElement::dead)
+ {
+ evict(element);
+ }
+ }
+ }
+ }
+ deadObjects.clear();
+ evict();
+
+ if(saveNowThreadsSize > 0)
+ {
+ _saveNowThreads.erase(_saveNowThreads.begin(), _saveNowThreads.begin() + saveNowThreadsSize);
+ notifyAll();
+ }
+ }
+ }
}
catch(const IceUtil::Exception& ex)
{
- Error out(_communicator->getLogger());
- out << "Saving thread killed by exception: " << ex;
- out.flush();
- handleFatalError(this, _communicator);
+ Error out(_communicator->getLogger());
+ out << "Saving thread killed by exception: " << ex;
+ out.flush();
+ handleFatalError(this, _communicator);
}
catch(const std::exception& ex)
{
- Error out(_communicator->getLogger());
- out << "Saving thread killed by std::exception: " << ex.what();
- out.flush();
- handleFatalError(this, _communicator);
+ Error out(_communicator->getLogger());
+ out << "Saving thread killed by std::exception: " << ex.what();
+ out.flush();
+ handleFatalError(this, _communicator);
}
catch(...)
{
- Error out(_communicator->getLogger());
- out << "Saving thread killed by unknown exception";
- out.flush();
- handleFatalError(this, _communicator);
+ Error out(_communicator->getLogger());
+ out << "Saving thread killed by unknown exception";
+ out.flush();
+ handleFatalError(this, _communicator);
}
}
@@ -1665,7 +1665,7 @@ Freeze::EvictorI::saveNowNoSync()
notifyAll();
do
{
- wait();
+ wait();
}
while(find(_saveNowThreads.begin(), _saveNowThreads.end(), myself) != _saveNowThreads.end());
}
@@ -1683,50 +1683,50 @@ Freeze::EvictorI::evict()
while(_currentEvictorSize > _evictorSize)
{
- //
- // Get the last unused element from the evictor queue.
- //
- while(p != _evictorList.rend())
- {
- if((*p)->usageCount == 0)
- {
- break; // Fine, servant is not in use (and not in the modifiedQueue)
- }
- ++p;
- }
- if(p == _evictorList.rend())
- {
- //
- // All servants are active, can't evict any further.
- //
- break;
- }
-
- EvictorElementPtr& element = *p;
- assert(!element->stale);
- assert(element->keepCount == 0);
-
- if(_trace >= 2 || (_trace >= 1 && _evictorList.size() % 50 == 0))
- {
- string facet = element->store.facet();
-
- Trace out(_communicator->getLogger(), "Freeze.Evictor");
- out << "evicting \"" << _communicator->identityToString(element->cachePosition->first) << "\" ";
- if(facet != "")
- {
- out << "-f \"" << facet << "\" ";
- }
- out << "from the queue\n"
- << "number of elements in the queue: " << _currentEvictorSize;
- }
-
- //
- // Remove last unused element from the evictor queue.
- //
- element->stale = true;
- element->store.unpin(element->cachePosition);
- p = list<EvictorElementPtr>::reverse_iterator(_evictorList.erase(element->evictPosition));
- _currentEvictorSize--;
+ //
+ // Get the last unused element from the evictor queue.
+ //
+ while(p != _evictorList.rend())
+ {
+ if((*p)->usageCount == 0)
+ {
+ break; // Fine, servant is not in use (and not in the modifiedQueue)
+ }
+ ++p;
+ }
+ if(p == _evictorList.rend())
+ {
+ //
+ // All servants are active, can't evict any further.
+ //
+ break;
+ }
+
+ EvictorElementPtr& element = *p;
+ assert(!element->stale);
+ assert(element->keepCount == 0);
+
+ if(_trace >= 2 || (_trace >= 1 && _evictorList.size() % 50 == 0))
+ {
+ string facet = element->store.facet();
+
+ Trace out(_communicator->getLogger(), "Freeze.Evictor");
+ out << "evicting \"" << _communicator->identityToString(element->cachePosition->first) << "\" ";
+ if(facet != "")
+ {
+ out << "-f \"" << facet << "\" ";
+ }
+ out << "from the queue\n"
+ << "number of elements in the queue: " << _currentEvictorSize;
+ }
+
+ //
+ // Remove last unused element from the evictor queue.
+ //
+ element->stale = true;
+ element->store.unpin(element->cachePosition);
+ p = list<EvictorElementPtr>::reverse_iterator(_evictorList.erase(element->evictPosition));
+ _currentEvictorSize--;
}
}
@@ -1737,20 +1737,20 @@ Freeze::EvictorI::fixEvictPosition(const EvictorElementPtr& element)
if(element->keepCount == 0)
{
- if(element->usageCount < 0)
- {
- //
- // New object
- //
- element->usageCount = 0;
- _currentEvictorSize++;
- }
- else
- {
- _evictorList.erase(element->evictPosition);
- }
- _evictorList.push_front(element);
- element->evictPosition = _evictorList.begin();
+ if(element->usageCount < 0)
+ {
+ //
+ // New object
+ //
+ element->usageCount = 0;
+ _currentEvictorSize++;
+ }
+ else
+ {
+ _evictorList.erase(element->evictPosition);
+ }
+ _evictorList.push_front(element);
+ element->evictPosition = _evictorList.begin();
}
}
@@ -1775,7 +1775,7 @@ Freeze::EvictorI::addToModifiedQueue(const EvictorElementPtr& element)
if(_saveSizeTrigger >= 0 && static_cast<Int>(_modifiedQueue.size()) >= _saveSizeTrigger)
{
- notifyAll();
+ notifyAll();
}
}
@@ -1793,22 +1793,22 @@ Freeze::EvictorI::stream(const EvictorElementPtr& element, Long streamStart, Str
if(element->status != EvictorElement::destroyed)
{
- //
- // Update stats first
- //
- Statistics& stats = element->rec.stats;
- Long diff = streamStart - (stats.creationTime + stats.lastSaveTime);
- if(stats.lastSaveTime == 0)
- {
- stats.lastSaveTime = diff;
- stats.avgSaveTime = diff;
- }
- else
- {
- stats.lastSaveTime = streamStart - stats.creationTime;
- stats.avgSaveTime = static_cast<Long>(stats.avgSaveTime * 0.95 + diff * 0.05);
- }
- ObjectStore::marshal(element->rec, obj.value, _communicator);
+ //
+ // Update stats first
+ //
+ Statistics& stats = element->rec.stats;
+ Long diff = streamStart - (stats.creationTime + stats.lastSaveTime);
+ if(stats.lastSaveTime == 0)
+ {
+ stats.lastSaveTime = diff;
+ stats.avgSaveTime = diff;
+ }
+ else
+ {
+ stats.lastSaveTime = streamStart - stats.creationTime;
+ stats.avgSaveTime = static_cast<Long>(stats.avgSaveTime * 0.95 + diff * 0.05);
+ }
+ ObjectStore::marshal(element->rec, obj.value, _communicator);
}
}
@@ -1820,11 +1820,11 @@ Freeze::EvictorI::findStore(const string& facet) const
StoreMap::const_iterator p = _storeMap.find(facet);
if(p == _storeMap.end())
{
- return 0;
+ return 0;
}
else
{
- return (*p).second;
+ return (*p).second;
}
}
@@ -1836,45 +1836,45 @@ Freeze::EvictorI::allDbs() const
try
{
- Db db(_dbEnv->getEnv(), 0);
- db.open(0, _filename.c_str(), 0, DB_UNKNOWN, DB_RDONLY, 0);
-
- Dbc* dbc = 0;
- db.cursor(0, &dbc, 0);
-
- Dbt dbKey;
- dbKey.set_flags(DB_DBT_MALLOC);
-
- Dbt dbValue;
- dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
-
- bool more = true;
- while(more)
- {
- more = (dbc->get(&dbKey, &dbValue, DB_NEXT) == 0);
- if(more)
- {
- string dbName(static_cast<char*>(dbKey.get_data()), dbKey.get_size());
-
- if(dbName.find(indexPrefix) != 0)
- {
- result.push_back(dbName);
- }
- free(dbKey.get_data());
- }
- }
-
- dbc->close();
- db.close(0);
+ Db db(_dbEnv->getEnv(), 0);
+ db.open(0, _filename.c_str(), 0, DB_UNKNOWN, DB_RDONLY, 0);
+
+ Dbc* dbc = 0;
+ db.cursor(0, &dbc, 0);
+
+ Dbt dbKey;
+ dbKey.set_flags(DB_DBT_MALLOC);
+
+ Dbt dbValue;
+ dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
+
+ bool more = true;
+ while(more)
+ {
+ more = (dbc->get(&dbKey, &dbValue, DB_NEXT) == 0);
+ if(more)
+ {
+ string dbName(static_cast<char*>(dbKey.get_data()), dbKey.get_size());
+
+ if(dbName.find(indexPrefix) != 0)
+ {
+ result.push_back(dbName);
+ }
+ free(dbKey.get_data());
+ }
+ }
+
+ dbc->close();
+ db.close(0);
}
catch(const DbException& dx)
{
- if(dx.get_errno() != ENOENT)
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
+ if(dx.get_errno() != ENOENT)
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
}
return result;
diff --git a/cpp/src/Freeze/EvictorI.h b/cpp/src/Freeze/EvictorI.h
index 6c85a3092df..187294cb8c6 100644
--- a/cpp/src/Freeze/EvictorI.h
+++ b/cpp/src/Freeze/EvictorI.h
@@ -43,11 +43,11 @@ public:
class Guard
{
public:
- Guard(DeactivateController&);
- ~Guard();
+ Guard(DeactivateController&);
+ ~Guard();
private:
- DeactivateController& _controller;
+ DeactivateController& _controller;
};
DeactivateController(EvictorI*);
@@ -112,7 +112,7 @@ class EvictorI : public Evictor, public IceUtil::Monitor<IceUtil::Mutex>, publi
public:
EvictorI(const Ice::ObjectAdapterPtr&, const std::string&, DbEnv*, const std::string&,
- const ServantInitializerPtr&, const std::vector<IndexPtr>&, bool);
+ const ServantInitializerPtr&, const std::vector<IndexPtr>&, bool);
virtual ~EvictorI();
@@ -165,10 +165,10 @@ public:
struct StreamedObject
{
- Key key;
- Value value;
- Ice::Byte status;
- ObjectStore* store;
+ Key key;
+ Value value;
+ Ice::Byte status;
+ ObjectStore* store;
};
diff --git a/cpp/src/Freeze/EvictorIteratorI.cpp b/cpp/src/Freeze/EvictorIteratorI.cpp
index d2a1ecef2f5..68feab953aa 100644
--- a/cpp/src/Freeze/EvictorIteratorI.cpp
+++ b/cpp/src/Freeze/EvictorIteratorI.cpp
@@ -33,12 +33,12 @@ Freeze::EvictorIteratorI::hasNext()
{
if(_batchIterator != _batch.end())
{
- return true;
+ return true;
}
else
{
- _batchIterator = nextBatch();
- return (_batchIterator != _batch.end());
+ _batchIterator = nextBatch();
+ return (_batchIterator != _batch.end());
}
}
@@ -47,11 +47,11 @@ Freeze::EvictorIteratorI::next()
{
if(hasNext())
{
- return *_batchIterator++;
+ return *_batchIterator++;
}
else
{
- throw Freeze::NoSuchElementException(__FILE__, __LINE__);
+ throw Freeze::NoSuchElementException(__FILE__, __LINE__);
}
}
@@ -60,13 +60,13 @@ vector<Identity>::const_iterator
Freeze::EvictorIteratorI::nextBatch()
{
DeactivateController::Guard
- deactivateGuard(_store->evictor()->deactivateController());
+ deactivateGuard(_store->evictor()->deactivateController());
_batch.clear();
if(!_more)
{
- return _batch.end();
+ return _batch.end();
}
vector<EvictorElementPtr> evictorElements;
@@ -78,145 +78,145 @@ Freeze::EvictorIteratorI::nextBatch()
try
{
- for(;;)
- {
- _batch.clear();
- evictorElements.clear();
-
- Dbt dbKey;
- initializeOutDbt(_key, dbKey);
-
- Dbt dbValue;
- dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
-
- Dbc* dbc = 0;
- try
- {
- //
- // Move to the first record
- //
- u_int32_t flags = DB_NEXT;
-
- if(_initialized)
- {
- //
- // _key represents the next element not yet returned
- // if it has been deleted, we want the one after
- //
- flags = DB_SET_RANGE;
-
- //
- // Will be used as input as well
- //
- dbKey.set_size(static_cast<u_int32_t>(firstKey.size()));
- }
-
- _store->db()->cursor(0, &dbc, 0);
-
- bool done = false;
- do
- {
- for(;;)
- {
- try
- {
- //
- // It is critical to set key size to key capacity before the
- // get, as a resize that increases the size inserts 0
- //
- _key.resize(_key.capacity());
-
- _more = (dbc->get(&dbKey, &dbValue, flags) == 0);
- if(_more)
- {
- _key.resize(dbKey.get_size());
- _initialized = true;
-
- flags = DB_NEXT;
-
- Ice::Identity ident;
- ObjectStore::unmarshal(ident, _key, communicator);
- if(_batch.size() < _batchSize)
- {
- _batch.push_back(ident);
- }
- else
- {
- //
- // Keep the last element in _key
- //
- done = true;
- }
- }
- break;
- }
- catch(const DbDeadlockException&)
- {
- throw;
- }
- catch(const DbException& dx)
- {
- handleDbException(dx, _key, dbKey, __FILE__, __LINE__);
- }
- }
- }
- while(!done && _more);
-
- Dbc* toClose = dbc;
- dbc = 0;
- toClose->close();
- break; // for (;;)
- }
- catch(const DbDeadlockException&)
- {
- if(dbc != 0)
- {
- try
- {
- dbc->close();
- }
- catch(const DbDeadlockException&)
- {
- //
- // Ignored
- //
- }
- }
- _key = firstKey;
- //
- // Retry
- //
- }
- catch(...)
- {
- if(dbc != 0)
- {
- try
- {
- dbc->close();
- }
- catch(const DbDeadlockException&)
- {
- //
- // Ignored
- //
- }
- }
- throw;
- }
- }
+ for(;;)
+ {
+ _batch.clear();
+ evictorElements.clear();
+
+ Dbt dbKey;
+ initializeOutDbt(_key, dbKey);
+
+ Dbt dbValue;
+ dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
+
+ Dbc* dbc = 0;
+ try
+ {
+ //
+ // Move to the first record
+ //
+ u_int32_t flags = DB_NEXT;
+
+ if(_initialized)
+ {
+ //
+ // _key represents the next element not yet returned
+ // if it has been deleted, we want the one after
+ //
+ flags = DB_SET_RANGE;
+
+ //
+ // Will be used as input as well
+ //
+ dbKey.set_size(static_cast<u_int32_t>(firstKey.size()));
+ }
+
+ _store->db()->cursor(0, &dbc, 0);
+
+ bool done = false;
+ do
+ {
+ for(;;)
+ {
+ try
+ {
+ //
+ // It is critical to set key size to key capacity before the
+ // get, as a resize that increases the size inserts 0
+ //
+ _key.resize(_key.capacity());
+
+ _more = (dbc->get(&dbKey, &dbValue, flags) == 0);
+ if(_more)
+ {
+ _key.resize(dbKey.get_size());
+ _initialized = true;
+
+ flags = DB_NEXT;
+
+ Ice::Identity ident;
+ ObjectStore::unmarshal(ident, _key, communicator);
+ if(_batch.size() < _batchSize)
+ {
+ _batch.push_back(ident);
+ }
+ else
+ {
+ //
+ // Keep the last element in _key
+ //
+ done = true;
+ }
+ }
+ break;
+ }
+ catch(const DbDeadlockException&)
+ {
+ throw;
+ }
+ catch(const DbException& dx)
+ {
+ handleDbException(dx, _key, dbKey, __FILE__, __LINE__);
+ }
+ }
+ }
+ while(!done && _more);
+
+ Dbc* toClose = dbc;
+ dbc = 0;
+ toClose->close();
+ break; // for (;;)
+ }
+ catch(const DbDeadlockException&)
+ {
+ if(dbc != 0)
+ {
+ try
+ {
+ dbc->close();
+ }
+ catch(const DbDeadlockException&)
+ {
+ //
+ // Ignored
+ //
+ }
+ }
+ _key = firstKey;
+ //
+ // Retry
+ //
+ }
+ catch(...)
+ {
+ if(dbc != 0)
+ {
+ try
+ {
+ dbc->close();
+ }
+ catch(const DbDeadlockException&)
+ {
+ //
+ // Ignored
+ //
+ }
+ }
+ throw;
+ }
+ }
}
catch(const DbException& dx)
{
- handleDbException(dx, __FILE__, __LINE__);
+ handleDbException(dx, __FILE__, __LINE__);
}
if(_batch.size() == 0)
{
- return _batch.end();
+ return _batch.end();
}
else
{
- return _batch.begin();
+ return _batch.begin();
}
}
diff --git a/cpp/src/Freeze/IndexI.cpp b/cpp/src/Freeze/IndexI.cpp
index 5058fb23ece..ca9c21e095a 100644
--- a/cpp/src/Freeze/IndexI.cpp
+++ b/cpp/src/Freeze/IndexI.cpp
@@ -37,7 +37,7 @@ vector<Identity>
Freeze::IndexI::untypedFindFirst(const Key& bytes, Int firstN) const
{
DeactivateController::Guard
- deactivateGuard(_store->evictor()->deactivateController());
+ deactivateGuard(_store->evictor()->deactivateController());
Dbt dbKey;
initializeInDbt(bytes, dbKey);
@@ -63,111 +63,111 @@ Freeze::IndexI::untypedFindFirst(const Key& bytes, Int firstN) const
try
{
- for(;;)
- {
- Dbc* dbc = 0;
- identities.clear();
-
- try
- {
- //
- // Move to the first record
- //
- _db->cursor(0, &dbc, 0);
- u_int32_t flags = DB_SET;
-
- bool found;
-
- do
- {
- for(;;)
- {
- try
- {
- //
- // It is critical to set key size to key capacity before the
- // get, as a resize that increases the size inserts 0
- //
- pkey.resize(pkey.capacity());
-
- found = (dbc->pget(&dbKey, &pdbKey, &dbValue, flags) == 0);
- if(found)
- {
- pkey.resize(pdbKey.get_size());
-
- Ice::Identity ident;
- ObjectStore::unmarshal(ident, pkey, communicator);
- identities.push_back(ident);
- flags = DB_NEXT_DUP;
- }
- break; // for(;;)
- }
- catch(const DbDeadlockException&)
- {
- throw;
- }
- catch(const DbException& dx)
- {
- handleDbException(dx, pkey, pdbKey, __FILE__, __LINE__);
- }
- }
- }
- while((firstN <= 0 || identities.size() < static_cast<size_t>(firstN)) && found);
-
- Dbc* toClose = dbc;
- dbc = 0;
- toClose->close();
- break; // for (;;)
- }
- catch(const DbDeadlockException&)
- {
- if(dbc != 0)
- {
- try
- {
- dbc->close();
- }
- catch(const DbDeadlockException&)
- {
- //
- // Ignored
- //
- }
- }
-
- if(_store->evictor()->deadlockWarning())
- {
- Warning out(_store->communicator()->getLogger());
- out << "Deadlock in Freeze::IndexI::untypedFindFirst while searching \""
- << _store->evictor()->filename() + "/" + _dbName << "\"; retrying ...";
- }
-
- //
- // Retry
- //
- }
- catch(...)
- {
- if(dbc != 0)
- {
- try
- {
- dbc->close();
- }
- catch(const DbDeadlockException&)
- {
- //
- // Ignored
- //
- }
- }
- throw;
- }
- }
+ for(;;)
+ {
+ Dbc* dbc = 0;
+ identities.clear();
+
+ try
+ {
+ //
+ // Move to the first record
+ //
+ _db->cursor(0, &dbc, 0);
+ u_int32_t flags = DB_SET;
+
+ bool found;
+
+ do
+ {
+ for(;;)
+ {
+ try
+ {
+ //
+ // It is critical to set key size to key capacity before the
+ // get, as a resize that increases the size inserts 0
+ //
+ pkey.resize(pkey.capacity());
+
+ found = (dbc->pget(&dbKey, &pdbKey, &dbValue, flags) == 0);
+ if(found)
+ {
+ pkey.resize(pdbKey.get_size());
+
+ Ice::Identity ident;
+ ObjectStore::unmarshal(ident, pkey, communicator);
+ identities.push_back(ident);
+ flags = DB_NEXT_DUP;
+ }
+ break; // for(;;)
+ }
+ catch(const DbDeadlockException&)
+ {
+ throw;
+ }
+ catch(const DbException& dx)
+ {
+ handleDbException(dx, pkey, pdbKey, __FILE__, __LINE__);
+ }
+ }
+ }
+ while((firstN <= 0 || identities.size() < static_cast<size_t>(firstN)) && found);
+
+ Dbc* toClose = dbc;
+ dbc = 0;
+ toClose->close();
+ break; // for (;;)
+ }
+ catch(const DbDeadlockException&)
+ {
+ if(dbc != 0)
+ {
+ try
+ {
+ dbc->close();
+ }
+ catch(const DbDeadlockException&)
+ {
+ //
+ // Ignored
+ //
+ }
+ }
+
+ if(_store->evictor()->deadlockWarning())
+ {
+ Warning out(_store->communicator()->getLogger());
+ out << "Deadlock in Freeze::IndexI::untypedFindFirst while searching \""
+ << _store->evictor()->filename() + "/" + _dbName << "\"; retrying ...";
+ }
+
+ //
+ // Retry
+ //
+ }
+ catch(...)
+ {
+ if(dbc != 0)
+ {
+ try
+ {
+ dbc->close();
+ }
+ catch(const DbDeadlockException&)
+ {
+ //
+ // Ignored
+ //
+ }
+ }
+ throw;
+ }
+ }
}
catch(const DbException& dx)
{
- handleDbException(dx, __FILE__, __LINE__);
+ handleDbException(dx, __FILE__, __LINE__);
}
return identities;
@@ -183,7 +183,7 @@ Int
Freeze::IndexI::untypedCount(const Key& bytes) const
{
DeactivateController::Guard
- deactivateGuard(_store->evictor()->deactivateController());
+ deactivateGuard(_store->evictor()->deactivateController());
Dbt dbKey;
initializeInDbt(bytes, dbKey);
@@ -203,81 +203,81 @@ Freeze::IndexI::untypedCount(const Key& bytes) const
try
{
- for(;;)
- {
- Dbc* dbc = 0;
-
- try
- {
- //
- // Move to the first record
- //
- _db->cursor(0, &dbc, 0);
- bool found = (dbc->get(&dbKey, &dbValue, DB_SET) == 0);
-
- if(found)
- {
- db_recno_t count = 0;
- dbc->count(&count, 0);
- result = static_cast<Int>(count);
- }
-
- Dbc* toClose = dbc;
- dbc = 0;
- toClose->close();
- break; // for (;;)
- }
- catch(const DbDeadlockException&)
- {
- if(dbc != 0)
- {
- try
- {
- dbc->close();
- }
- catch(const DbDeadlockException&)
- {
- //
- // Ignored
- //
- }
- }
-
- if(_store->evictor()->deadlockWarning())
- {
- Warning out(_store->communicator()->getLogger());
- out << "Deadlock in Freeze::IndexI::untypedCount while searching \""
- << _store->evictor()->filename() + "/" + _dbName << "\"; retrying ...";
- }
-
- //
- // Retry
- //
- }
- catch(...)
- {
- if(dbc != 0)
- {
- try
- {
- dbc->close();
- }
- catch(const DbDeadlockException&)
- {
- //
- // Ignored
- //
- }
- }
- throw;
- }
- }
+ for(;;)
+ {
+ Dbc* dbc = 0;
+
+ try
+ {
+ //
+ // Move to the first record
+ //
+ _db->cursor(0, &dbc, 0);
+ bool found = (dbc->get(&dbKey, &dbValue, DB_SET) == 0);
+
+ if(found)
+ {
+ db_recno_t count = 0;
+ dbc->count(&count, 0);
+ result = static_cast<Int>(count);
+ }
+
+ Dbc* toClose = dbc;
+ dbc = 0;
+ toClose->close();
+ break; // for (;;)
+ }
+ catch(const DbDeadlockException&)
+ {
+ if(dbc != 0)
+ {
+ try
+ {
+ dbc->close();
+ }
+ catch(const DbDeadlockException&)
+ {
+ //
+ // Ignored
+ //
+ }
+ }
+
+ if(_store->evictor()->deadlockWarning())
+ {
+ Warning out(_store->communicator()->getLogger());
+ out << "Deadlock in Freeze::IndexI::untypedCount while searching \""
+ << _store->evictor()->filename() + "/" + _dbName << "\"; retrying ...";
+ }
+
+ //
+ // Retry
+ //
+ }
+ catch(...)
+ {
+ if(dbc != 0)
+ {
+ try
+ {
+ dbc->close();
+ }
+ catch(const DbDeadlockException&)
+ {
+ //
+ // Ignored
+ //
+ }
+ }
+ throw;
+ }
+ }
}
catch(const DbException& dx)
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
return result;
@@ -285,7 +285,7 @@ Freeze::IndexI::untypedCount(const Key& bytes) const
void
Freeze::IndexI::associate(ObjectStore* store, DbTxn* txn,
- bool createDb, bool populateIndex)
+ bool createDb, bool populateIndex)
{
assert(txn != 0);
_store = store;
@@ -298,7 +298,7 @@ Freeze::IndexI::associate(ObjectStore* store, DbTxn* txn,
u_int32_t flags = 0;
if(createDb)
{
- flags = DB_CREATE;
+ flags = DB_CREATE;
}
_dbName = EvictorI::indexPrefix + store->dbName() + "." + _index.name();
@@ -308,14 +308,14 @@ Freeze::IndexI::associate(ObjectStore* store, DbTxn* txn,
flags = 0;
if(populateIndex)
{
- flags = DB_CREATE;
+ flags = DB_CREATE;
}
store->db()->associate(txn, _db.get(), callback, flags);
}
int
Freeze::IndexI::secondaryKeyCreate(Db* secondary, const Dbt* dbKey,
- const Dbt* dbValue, Dbt* result)
+ const Dbt* dbValue, Dbt* result)
{
Ice::CommunicatorPtr communicator = _store->communicator();
@@ -327,19 +327,19 @@ Freeze::IndexI::secondaryKeyCreate(Db* secondary, const Dbt* dbKey,
Key bytes;
if(_index.marshalKey(rec.servant, bytes))
{
- result->set_flags(DB_DBT_APPMALLOC);
- void* data = malloc(bytes.size());
- memcpy(data, &bytes[0], bytes.size());
- result->set_data(data);
- result->set_size(static_cast<u_int32_t>(bytes.size()));
- return 0;
+ result->set_flags(DB_DBT_APPMALLOC);
+ void* data = malloc(bytes.size());
+ memcpy(data, &bytes[0], bytes.size());
+ result->set_data(data);
+ result->set_size(static_cast<u_int32_t>(bytes.size()));
+ return 0;
}
else
{
- //
- // Don't want to index this one
- //
- return DB_DONOTINDEX;
+ //
+ // Don't want to index this one
+ //
+ return DB_DONOTINDEX;
}
}
@@ -348,16 +348,16 @@ Freeze::IndexI::close()
{
if(_db.get() != 0)
{
- try
- {
- _db->close(0);
- }
- catch(const DbException& dx)
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
- _db.reset(0);
+ try
+ {
+ _db->close(0);
+ }
+ catch(const DbException& dx)
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+ _db.reset(0);
}
}
diff --git a/cpp/src/Freeze/MapI.cpp b/cpp/src/Freeze/MapI.cpp
index a3e756725d2..37c894dad0c 100644
--- a/cpp/src/Freeze/MapI.cpp
+++ b/cpp/src/Freeze/MapI.cpp
@@ -86,12 +86,12 @@ Freeze::KeyCompareBase::compareEnabled() const
Freeze::MapHelper*
Freeze::MapHelper::create(const Freeze::ConnectionPtr& connection,
- const string& dbName,
- const string& key,
- const string& value,
- const Freeze::KeyCompareBasePtr& keyCompare,
- const std::vector<MapIndexBasePtr>& indices,
- bool createDb)
+ const string& dbName,
+ const string& key,
+ const string& value,
+ const Freeze::KeyCompareBasePtr& keyCompare,
+ const std::vector<MapIndexBasePtr>& indices,
+ bool createDb)
{
Freeze::ConnectionIPtr connectionI = Freeze::ConnectionIPtr::dynamicCast(connection.get());
return new MapHelperI(connectionI, dbName, key, value, keyCompare, indices, createDb);
@@ -112,14 +112,14 @@ Freeze::IteratorHelper::create(const MapHelper& m, bool readOnly)
const MapHelperI& actualMap = dynamic_cast<const MapHelperI&>(m);
auto_ptr<IteratorHelperI> r(new IteratorHelperI(actualMap, readOnly,
- 0, false));
+ 0, false));
if(r->next())
{
- return r.release();
+ return r.release();
}
else
{
- return 0;
+ return 0;
}
}
@@ -134,8 +134,8 @@ Freeze::IteratorHelper::~IteratorHelper()
//
Freeze::IteratorHelperI::IteratorHelperI(const MapHelperI& m, bool readOnly,
- const MapIndexBasePtr& index,
- bool onlyDups) :
+ const MapIndexBasePtr& index,
+ bool onlyDups) :
_map(m),
_dbc(0),
_indexed(index != 0),
@@ -144,41 +144,41 @@ Freeze::IteratorHelperI::IteratorHelperI(const MapHelperI& m, bool readOnly,
{
if(_map._trace >= 2)
{
- Trace out(_map._connection->communicator()->getLogger(), "Freeze.Map");
- out << "opening iterator on Db \"" << _map._dbName << "\"";
- if(index != 0)
- {
- out << " with index \"" << index->name() << "\"";
- }
+ Trace out(_map._connection->communicator()->getLogger(), "Freeze.Map");
+ out << "opening iterator on Db \"" << _map._dbName << "\"";
+ if(index != 0)
+ {
+ out << " with index \"" << index->name() << "\"";
+ }
}
DbTxn* txn = _map._connection->dbTxn();
if(txn == 0 && !readOnly)
{
- //
- // Need to start a transaction
- //
- _tx = new Tx(_map);
- txn = _tx->getTxn();
+ //
+ // Need to start a transaction
+ //
+ _tx = new Tx(_map);
+ txn = _tx->getTxn();
}
try
{
- if(index != 0)
- {
- index->_impl->db()->cursor(txn, &_dbc, 0);
- }
- else
- {
- _map._db->cursor(txn, &_dbc, 0);
- }
+ if(index != 0)
+ {
+ index->_impl->db()->cursor(txn, &_dbc, 0);
+ }
+ else
+ {
+ _map._db->cursor(txn, &_dbc, 0);
+ }
}
catch(const ::DbException& dx)
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
_map._iteratorList.push_back(this);
@@ -194,19 +194,19 @@ Freeze::IteratorHelperI::IteratorHelperI(const IteratorHelperI& it) :
{
if(_map._trace >= 2)
{
- Trace out(_map._connection->communicator()->getLogger(), "Freeze.Map");
- out << "duplicating iterator on Db \"" << _map._dbName << "\"";
+ Trace out(_map._connection->communicator()->getLogger(), "Freeze.Map");
+ out << "duplicating iterator on Db \"" << _map._dbName << "\"";
}
try
{
- it._dbc->dup(&_dbc, DB_POSITION);
+ it._dbc->dup(&_dbc, DB_POSITION);
}
catch(const ::DbException& dx)
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
_tx = it._tx;
@@ -241,31 +241,31 @@ Freeze::IteratorHelperI::find(const Key& key) const
{
try
{
- if(_dbc->get(&dbKey, &dbValue, DB_SET) == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
+ if(_dbc->get(&dbKey, &dbValue, DB_SET) == 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
catch(const ::DbDeadlockException& dx)
{
- if(_tx != 0)
- {
- _tx->dead();
- }
-
- DeadlockException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ if(_tx != 0)
+ {
+ _tx->dead();
+ }
+
+ DeadlockException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
catch(const ::DbException& dx)
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
}
}
@@ -289,42 +289,42 @@ Freeze::IteratorHelperI::lowerBound(const Key& key) const
for(;;)
{
- try
- {
- int err = _dbc->get(&dbKey, &dbValue, DB_SET_RANGE);
- if(err == 0)
- {
- _key.resize(dbKey.get_size());
- return true;
- }
- else if(err == DB_NOTFOUND)
- {
- return false;
- }
- else
- {
- //
- // Bug in Freeze
- //
- assert(0);
- throw DatabaseException(__FILE__, __LINE__);
- }
- }
- catch(const ::DbDeadlockException& dx)
- {
- if(_tx != 0)
- {
- _tx->dead();
- }
-
- DeadlockException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
- catch(const ::DbException& dx)
- {
- handleDbException(dx, _key, dbKey, __FILE__, __LINE__);
- }
+ try
+ {
+ int err = _dbc->get(&dbKey, &dbValue, DB_SET_RANGE);
+ if(err == 0)
+ {
+ _key.resize(dbKey.get_size());
+ return true;
+ }
+ else if(err == DB_NOTFOUND)
+ {
+ return false;
+ }
+ else
+ {
+ //
+ // Bug in Freeze
+ //
+ assert(0);
+ throw DatabaseException(__FILE__, __LINE__);
+ }
+ }
+ catch(const ::DbDeadlockException& dx)
+ {
+ if(_tx != 0)
+ {
+ _tx->dead();
+ }
+
+ DeadlockException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+ catch(const ::DbException& dx)
+ {
+ handleDbException(dx, _key, dbKey, __FILE__, __LINE__);
+ }
}
}
@@ -333,18 +333,18 @@ Freeze::IteratorHelperI::upperBound(const Key& key) const
{
if(lowerBound(key))
{
- if(_key == key)
- {
- return next(true);
- }
- else
- {
- return true;
- }
+ if(_key == key)
+ {
+ return next(true);
+ }
+ else
+ {
+ return true;
+ }
}
else
{
- return false;
+ return false;
}
}
@@ -364,7 +364,7 @@ Freeze::IteratorHelperI::get(const Key*& key, const Value*& value) const
size_t keySize = _key.capacity();
if(keySize < 1024)
{
- keySize = 1024;
+ keySize = 1024;
}
_key.resize(keySize);
@@ -374,7 +374,7 @@ Freeze::IteratorHelperI::get(const Key*& key, const Value*& value) const
size_t valueSize = _value.capacity();
if(valueSize < 1024)
{
- valueSize = 1024;
+ valueSize = 1024;
}
_value.resize(valueSize);
Dbt dbValue;
@@ -382,60 +382,60 @@ Freeze::IteratorHelperI::get(const Key*& key, const Value*& value) const
for(;;)
{
- try
- {
- int err;
-
- if(_indexed)
- {
- //
- // Not interested in getting the index's key
- //
- Dbt iKey;
- iKey.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
-
- err = _dbc->pget(&iKey, &dbKey, &dbValue, DB_CURRENT);
- }
- else
- {
- err = _dbc->get(&dbKey, &dbValue, DB_CURRENT);
- }
-
- if(err == 0)
- {
- _key.resize(dbKey.get_size());
- _value.resize(dbValue.get_size());
- break; // for(;;)
- }
- else if(err == DB_KEYEMPTY)
- {
- throw InvalidPositionException(__FILE__, __LINE__);
- }
- else
- {
- //
- // Bug in Freeze
- //
- assert(0);
- throw DatabaseException(__FILE__, __LINE__);
- }
- }
- catch(const ::DbDeadlockException& dx)
- {
- if(_tx != 0)
- {
- _tx->dead();
- }
-
- DeadlockException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
- catch(const ::DbException& dx)
- {
- handleDbException(dx, _key, dbKey, _value, dbValue,
- __FILE__, __LINE__);
- }
+ try
+ {
+ int err;
+
+ if(_indexed)
+ {
+ //
+ // Not interested in getting the index's key
+ //
+ Dbt iKey;
+ iKey.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
+
+ err = _dbc->pget(&iKey, &dbKey, &dbValue, DB_CURRENT);
+ }
+ else
+ {
+ err = _dbc->get(&dbKey, &dbValue, DB_CURRENT);
+ }
+
+ if(err == 0)
+ {
+ _key.resize(dbKey.get_size());
+ _value.resize(dbValue.get_size());
+ break; // for(;;)
+ }
+ else if(err == DB_KEYEMPTY)
+ {
+ throw InvalidPositionException(__FILE__, __LINE__);
+ }
+ else
+ {
+ //
+ // Bug in Freeze
+ //
+ assert(0);
+ throw DatabaseException(__FILE__, __LINE__);
+ }
+ }
+ catch(const ::DbDeadlockException& dx)
+ {
+ if(_tx != 0)
+ {
+ _tx->dead();
+ }
+
+ DeadlockException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+ catch(const ::DbException& dx)
+ {
+ handleDbException(dx, _key, dbKey, _value, dbValue,
+ __FILE__, __LINE__);
+ }
}
}
@@ -445,7 +445,7 @@ Freeze::IteratorHelperI::get() const
size_t keySize = _key.capacity();
if(keySize < 1024)
{
- keySize = 1024;
+ keySize = 1024;
}
_key.resize(keySize);
@@ -460,57 +460,57 @@ Freeze::IteratorHelperI::get() const
for(;;)
{
- try
- {
- int err;
- if(_indexed)
- {
- //
- // Not interested in getting the index's key
- //
- Dbt iKey;
- iKey.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
-
- err = _dbc->pget(&iKey, &dbKey, &dbValue, DB_CURRENT);
- }
- else
- {
- err = _dbc->get(&dbKey, &dbValue, DB_CURRENT);
- }
-
- if(err == 0)
- {
- _key.resize(dbKey.get_size());
- return &_key;
- }
- else if(err == DB_KEYEMPTY)
- {
- throw InvalidPositionException(__FILE__, __LINE__);
- }
- else
- {
- //
- // Bug in Freeze
- //
- assert(0);
- throw DatabaseException(__FILE__, __LINE__);
- }
- }
- catch(const ::DbDeadlockException& dx)
- {
- if(_tx != 0)
- {
- _tx->dead();
- }
-
- DeadlockException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
- catch(const ::DbException& dx)
- {
- handleDbException(dx, _key, dbKey, __FILE__, __LINE__);
- }
+ try
+ {
+ int err;
+ if(_indexed)
+ {
+ //
+ // Not interested in getting the index's key
+ //
+ Dbt iKey;
+ iKey.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
+
+ err = _dbc->pget(&iKey, &dbKey, &dbValue, DB_CURRENT);
+ }
+ else
+ {
+ err = _dbc->get(&dbKey, &dbValue, DB_CURRENT);
+ }
+
+ if(err == 0)
+ {
+ _key.resize(dbKey.get_size());
+ return &_key;
+ }
+ else if(err == DB_KEYEMPTY)
+ {
+ throw InvalidPositionException(__FILE__, __LINE__);
+ }
+ else
+ {
+ //
+ // Bug in Freeze
+ //
+ assert(0);
+ throw DatabaseException(__FILE__, __LINE__);
+ }
+ }
+ catch(const ::DbDeadlockException& dx)
+ {
+ if(_tx != 0)
+ {
+ _tx->dead();
+ }
+
+ DeadlockException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+ catch(const ::DbException& dx)
+ {
+ handleDbException(dx, _key, dbKey, __FILE__, __LINE__);
+ }
}
}
@@ -519,9 +519,9 @@ Freeze::IteratorHelperI::set(const Value& value)
{
if(_indexed)
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = "Cannot set an iterator retrieved through an index";
- throw ex;
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = "Cannot set an iterator retrieved through an index";
+ throw ex;
}
//
@@ -535,31 +535,31 @@ Freeze::IteratorHelperI::set(const Value& value)
if(_tx != 0)
{
- _map.closeAllIteratorsExcept(_tx);
+ _map.closeAllIteratorsExcept(_tx);
}
try
{
- int err;
- err = _dbc->put(&dbKey, &dbValue, DB_CURRENT);
- assert(err == 0);
+ int err;
+ err = _dbc->put(&dbKey, &dbValue, DB_CURRENT);
+ assert(err == 0);
}
catch(const ::DbDeadlockException& dx)
{
- if(_tx != 0)
- {
- _tx->dead();
- }
+ if(_tx != 0)
+ {
+ _tx->dead();
+ }
- DeadlockException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ DeadlockException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
catch(const ::DbException& dx)
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
}
@@ -568,34 +568,34 @@ Freeze::IteratorHelperI::erase()
{
if(_tx != 0)
{
- _map.closeAllIteratorsExcept(_tx);
+ _map.closeAllIteratorsExcept(_tx);
}
try
{
- int err = _dbc->del(0);
- if(err == DB_KEYEMPTY)
- {
- throw InvalidPositionException(__FILE__, __LINE__);
- }
- assert(err == 0);
+ int err = _dbc->del(0);
+ if(err == DB_KEYEMPTY)
+ {
+ throw InvalidPositionException(__FILE__, __LINE__);
+ }
+ assert(err == 0);
}
catch(const ::DbDeadlockException& dx)
{
- if(_tx != 0)
- {
- _tx->dead();
- }
+ if(_tx != 0)
+ {
+ _tx->dead();
+ }
- DeadlockException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ DeadlockException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
catch(const ::DbException& dx)
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
}
@@ -619,40 +619,40 @@ Freeze::IteratorHelperI::next(bool skipDups) const
int flags = DB_NEXT;
if(skipDups)
{
- flags = DB_NEXT_NODUP;
+ flags = DB_NEXT_NODUP;
}
else if(_indexed && _onlyDups)
{
- flags = DB_NEXT_DUP;
+ flags = DB_NEXT_DUP;
}
try
{
- if(_dbc->get(&dbKey, &dbValue, flags) == 0)
- {
- return true;
- }
- else
- {
- return false;
- }
+ if(_dbc->get(&dbKey, &dbValue, flags) == 0)
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
}
catch(const ::DbDeadlockException& dx)
{
- if(_tx != 0)
- {
- _tx->dead();
- }
+ if(_tx != 0)
+ {
+ _tx->dead();
+ }
- DeadlockException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ DeadlockException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
catch(const ::DbException& dx)
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
}
@@ -661,35 +661,35 @@ Freeze::IteratorHelperI::close()
{
if(_dbc != 0)
{
- if(_map._trace >= 2)
- {
- Trace out(_map._connection->communicator()->getLogger(), "Freeze.Map");
- out << "closing iterator on Db \"" << _map._dbName << "\"";
- }
-
- try
- {
- _dbc->close();
- }
- catch(const ::DbDeadlockException& dx)
- {
- bool raiseException = (_tx == 0);
- cleanup();
- if(raiseException)
- {
- DeadlockException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
- }
- catch(const ::DbException& dx)
- {
- cleanup();
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
- cleanup();
+ if(_map._trace >= 2)
+ {
+ Trace out(_map._connection->communicator()->getLogger(), "Freeze.Map");
+ out << "closing iterator on Db \"" << _map._dbName << "\"";
+ }
+
+ try
+ {
+ _dbc->close();
+ }
+ catch(const ::DbDeadlockException& dx)
+ {
+ bool raiseException = (_tx == 0);
+ cleanup();
+ if(raiseException)
+ {
+ DeadlockException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+ }
+ catch(const ::DbException& dx)
+ {
+ cleanup();
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+ cleanup();
}
}
@@ -713,68 +713,68 @@ Freeze::IteratorHelperI::Tx::Tx(const MapHelperI& m) :
{
if(_map._trace >= 2)
{
- Trace out(_map._connection->communicator()->getLogger(), "Freeze.Map");
- out << "starting transaction for Db \"" << _map._dbName << "\"";
+ Trace out(_map._connection->communicator()->getLogger(), "Freeze.Map");
+ out << "starting transaction for Db \"" << _map._dbName << "\"";
}
try
{
- _map._connection->dbEnv()->getEnv()->txn_begin(0, &_txn, 0);
+ _map._connection->dbEnv()->getEnv()->txn_begin(0, &_txn, 0);
}
catch(const ::DbException& dx)
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
}
-
+
Freeze::IteratorHelperI::Tx::~Tx()
{
if(_dead)
{
- if(_map._trace >= 2)
- {
- Trace out(_map._connection->communicator()->getLogger(), "");
- out << "aborting transaction for Db \"" << _map._dbName << "\"";
- }
-
- try
- {
- _txn->abort();
- }
- catch(...)
- {
- //
- // Ignore exceptions to avoid crash during stack unwinding
- //
- }
+ if(_map._trace >= 2)
+ {
+ Trace out(_map._connection->communicator()->getLogger(), "");
+ out << "aborting transaction for Db \"" << _map._dbName << "\"";
+ }
+
+ try
+ {
+ _txn->abort();
+ }
+ catch(...)
+ {
+ //
+ // Ignore exceptions to avoid crash during stack unwinding
+ //
+ }
}
else
{
- if(_map._trace >= 2)
- {
- Trace out(_map._connection->communicator()->getLogger(), "Freeze.Map");
- out << "committing transaction for Db \"" << _map._dbName.c_str() << "\"";
- }
-
- try
- {
- _txn->commit(0);
- }
- catch(const ::DbDeadlockException& dx)
- {
- DeadlockException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
- catch(const ::DbException& dx)
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
+ if(_map._trace >= 2)
+ {
+ Trace out(_map._connection->communicator()->getLogger(), "Freeze.Map");
+ out << "committing transaction for Db \"" << _map._dbName.c_str() << "\"";
+ }
+
+ try
+ {
+ _txn->commit(0);
+ }
+ catch(const ::DbDeadlockException& dx)
+ {
+ DeadlockException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+ catch(const ::DbException& dx)
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
}
}
@@ -792,31 +792,31 @@ Freeze::IteratorHelperI::Tx::dead()
Freeze::MapHelperI::MapHelperI(const ConnectionIPtr& connection,
- const string& dbName,
- const string& key,
- const string& value,
- const KeyCompareBasePtr& keyCompare,
- const vector<MapIndexBasePtr>& indices,
- bool createDb) :
+ const string& dbName,
+ const string& key,
+ const string& value,
+ const KeyCompareBasePtr& keyCompare,
+ const vector<MapIndexBasePtr>& indices,
+ bool createDb) :
_connection(connection),
_db(SharedDb::get(connection, dbName, key, value, keyCompare, indices, createDb)),
_dbName(dbName),
_trace(connection->trace())
{
for(vector<MapIndexBasePtr>::const_iterator p = indices.begin();
- p != indices.end(); ++p)
+ p != indices.end(); ++p)
{
- const MapIndexBasePtr& indexBase = *p;
- assert(indexBase->_impl != 0);
- assert(indexBase->_communicator == _connection->communicator());
- assert(indexBase->_map == 0);
-
+ const MapIndexBasePtr& indexBase = *p;
+ assert(indexBase->_impl != 0);
+ assert(indexBase->_communicator == _connection->communicator());
+ assert(indexBase->_map == 0);
+
#ifndef NDEBUG
- bool inserted =
+ bool inserted =
#endif
- _indices.insert(IndexMap::value_type(indexBase->name(), indexBase)).second;
- assert(inserted);
- indexBase->_map = this;
+ _indices.insert(IndexMap::value_type(indexBase->name(), indexBase)).second;
+ assert(inserted);
+ indexBase->_map = this;
}
_connection->registerMap(this);
@@ -832,38 +832,38 @@ Freeze::MapHelperI::find(const Key& k, bool readOnly) const
{
for(;;)
{
- try
- {
- auto_ptr<IteratorHelperI> r(new IteratorHelperI(*this, readOnly, 0, false));
- if(r->find(k))
- {
- return r.release();
- }
- else
- {
- return 0;
- }
- }
- catch(const DeadlockException&)
- {
- if(_connection->dbTxn() != 0)
- {
- throw;
- }
- else
- {
- if(_connection->deadlockWarning())
- {
- Warning out(_connection->communicator()->getLogger());
- out << "Deadlock in Freeze::MapHelperI::find on Map \""
- << _dbName << "\"; retrying ...";
- }
-
- //
- // Ignored, try again
- //
- }
- }
+ try
+ {
+ auto_ptr<IteratorHelperI> r(new IteratorHelperI(*this, readOnly, 0, false));
+ if(r->find(k))
+ {
+ return r.release();
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ catch(const DeadlockException&)
+ {
+ if(_connection->dbTxn() != 0)
+ {
+ throw;
+ }
+ else
+ {
+ if(_connection->deadlockWarning())
+ {
+ Warning out(_connection->communicator()->getLogger());
+ out << "Deadlock in Freeze::MapHelperI::find on Map \""
+ << _dbName << "\"; retrying ...";
+ }
+
+ //
+ // Ignored, try again
+ //
+ }
+ }
}
}
@@ -872,38 +872,38 @@ Freeze::MapHelperI::lowerBound(const Key& k, bool readOnly) const
{
for(;;)
{
- try
- {
- auto_ptr<IteratorHelperI> r(new IteratorHelperI(*this, readOnly, 0, false));
- if(r->lowerBound(k))
- {
- return r.release();
- }
- else
- {
- return 0;
- }
- }
- catch(const DeadlockException&)
- {
- if(_connection->dbTxn() != 0)
- {
- throw;
- }
- else
- {
- if(_connection->deadlockWarning())
- {
- Warning out(_connection->communicator()->getLogger());
- out << "Deadlock in Freeze::MapHelperI::lowerBound on Map \""
- << _dbName << "\"; retrying ...";
- }
-
- //
- // Ignored, try again
- //
- }
- }
+ try
+ {
+ auto_ptr<IteratorHelperI> r(new IteratorHelperI(*this, readOnly, 0, false));
+ if(r->lowerBound(k))
+ {
+ return r.release();
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ catch(const DeadlockException&)
+ {
+ if(_connection->dbTxn() != 0)
+ {
+ throw;
+ }
+ else
+ {
+ if(_connection->deadlockWarning())
+ {
+ Warning out(_connection->communicator()->getLogger());
+ out << "Deadlock in Freeze::MapHelperI::lowerBound on Map \""
+ << _dbName << "\"; retrying ...";
+ }
+
+ //
+ // Ignored, try again
+ //
+ }
+ }
}
}
@@ -912,38 +912,38 @@ Freeze::MapHelperI::upperBound(const Key& k, bool readOnly) const
{
for(;;)
{
- try
- {
- auto_ptr<IteratorHelperI> r(new IteratorHelperI(*this, readOnly, 0, false));
- if(r->upperBound(k))
- {
- return r.release();
- }
- else
- {
- return 0;
- }
- }
- catch(const DeadlockException&)
- {
- if(_connection->dbTxn() != 0)
- {
- throw;
- }
- else
- {
- if(_connection->deadlockWarning())
- {
- Warning out(_connection->communicator()->getLogger());
- out << "Deadlock in Freeze::MapHelperI::upperBound on Map \""
- << _dbName << "\"; retrying ...";
- }
-
- //
- // Ignored, try again
- //
- }
- }
+ try
+ {
+ auto_ptr<IteratorHelperI> r(new IteratorHelperI(*this, readOnly, 0, false));
+ if(r->upperBound(k))
+ {
+ return r.release();
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ catch(const DeadlockException&)
+ {
+ if(_connection->dbTxn() != 0)
+ {
+ throw;
+ }
+ else
+ {
+ if(_connection->deadlockWarning())
+ {
+ Warning out(_connection->communicator()->getLogger());
+ out << "Deadlock in Freeze::MapHelperI::upperBound on Map \""
+ << _dbName << "\"; retrying ...";
+ }
+
+ //
+ // Ignored, try again
+ //
+ }
+ }
}
}
@@ -958,56 +958,56 @@ Freeze::MapHelperI::put(const Key& key, const Value& value)
DbTxn* txn = _connection->dbTxn();
if(txn == 0)
{
- closeAllIterators();
+ closeAllIterators();
}
for(;;)
{
- try
- {
- int err = _db->put(txn, &dbKey, &dbValue,
- txn != 0 ? 0 : DB_AUTO_COMMIT);
-
- if(err == 0)
- {
- break;
- }
- else
- {
- //
- // Bug in Freeze
- //
- throw DatabaseException(__FILE__, __LINE__);
- }
- }
- catch(const ::DbDeadlockException& dx)
- {
- if(txn != 0)
- {
- DeadlockException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
- else
- {
- if(_connection->deadlockWarning())
- {
- Warning out(_connection->communicator()->getLogger());
- out << "Deadlock in Freeze::MapHelperI::put on Map \""
- << _dbName << "\"; retrying ...";
- }
-
- //
- // Ignored, try again
- //
- }
- }
- catch(const ::DbException& dx)
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
+ try
+ {
+ int err = _db->put(txn, &dbKey, &dbValue,
+ txn != 0 ? 0 : DB_AUTO_COMMIT);
+
+ if(err == 0)
+ {
+ break;
+ }
+ else
+ {
+ //
+ // Bug in Freeze
+ //
+ throw DatabaseException(__FILE__, __LINE__);
+ }
+ }
+ catch(const ::DbDeadlockException& dx)
+ {
+ if(txn != 0)
+ {
+ DeadlockException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+ else
+ {
+ if(_connection->deadlockWarning())
+ {
+ Warning out(_connection->communicator()->getLogger());
+ out << "Deadlock in Freeze::MapHelperI::put on Map \""
+ << _dbName << "\"; retrying ...";
+ }
+
+ //
+ // Ignored, try again
+ //
+ }
+ }
+ catch(const ::DbException& dx)
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
}
}
@@ -1020,57 +1020,57 @@ Freeze::MapHelperI::erase(const Key& key)
DbTxn* txn = _connection->dbTxn();
if(txn == 0)
{
- closeAllIterators();
+ closeAllIterators();
}
for(;;)
{
- try
- {
- int err = _db->del(txn, &dbKey, txn != 0 ? 0 : DB_AUTO_COMMIT);
-
- if(err == 0)
- {
- return true;
- }
- else if(err == DB_NOTFOUND)
- {
- return false;
- }
- else
- {
- assert(0);
- throw DatabaseException(__FILE__, __LINE__);
- }
- }
- catch(const ::DbDeadlockException& dx)
- {
- if(txn != 0)
- {
- DeadlockException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
- else
- {
- if(_connection->deadlockWarning())
- {
- Warning out(_connection->communicator()->getLogger());
- out << "Deadlock in Freeze::MapHelperI::erase on Map \""
- << _dbName << "\"; retrying ...";
- }
-
- //
- // Ignored, try again
- //
- }
- }
- catch(const ::DbException& dx)
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
+ try
+ {
+ int err = _db->del(txn, &dbKey, txn != 0 ? 0 : DB_AUTO_COMMIT);
+
+ if(err == 0)
+ {
+ return true;
+ }
+ else if(err == DB_NOTFOUND)
+ {
+ return false;
+ }
+ else
+ {
+ assert(0);
+ throw DatabaseException(__FILE__, __LINE__);
+ }
+ }
+ catch(const ::DbDeadlockException& dx)
+ {
+ if(txn != 0)
+ {
+ DeadlockException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+ else
+ {
+ if(_connection->deadlockWarning())
+ {
+ Warning out(_connection->communicator()->getLogger());
+ out << "Deadlock in Freeze::MapHelperI::erase on Map \""
+ << _dbName << "\"; retrying ...";
+ }
+
+ //
+ // Ignored, try again
+ //
+ }
+ }
+ catch(const ::DbException& dx)
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
}
}
@@ -1088,52 +1088,52 @@ Freeze::MapHelperI::count(const Key& key) const
for(;;)
{
- try
- {
- int err = _db->get(_connection->dbTxn(), &dbKey, &dbValue, 0);
-
- if(err == 0)
- {
- return 1;
- }
- else if(err == DB_NOTFOUND)
- {
- return 0;
- }
- else
- {
- assert(0);
- throw DatabaseException(__FILE__, __LINE__);
- }
- }
- catch(const ::DbDeadlockException& dx)
- {
- if(_connection->dbTxn() != 0)
- {
- DeadlockException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
- else
- {
- if(_connection->deadlockWarning())
- {
- Warning out(_connection->communicator()->getLogger());
- out << "Deadlock in Freeze::MapHelperI::count on Map \""
- << _dbName << "\"; retrying ...";
- }
-
- //
- // Ignored, try again
- //
- }
- }
- catch(const ::DbException& dx)
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
+ try
+ {
+ int err = _db->get(_connection->dbTxn(), &dbKey, &dbValue, 0);
+
+ if(err == 0)
+ {
+ return 1;
+ }
+ else if(err == DB_NOTFOUND)
+ {
+ return 0;
+ }
+ else
+ {
+ assert(0);
+ throw DatabaseException(__FILE__, __LINE__);
+ }
+ }
+ catch(const ::DbDeadlockException& dx)
+ {
+ if(_connection->dbTxn() != 0)
+ {
+ DeadlockException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+ else
+ {
+ if(_connection->deadlockWarning())
+ {
+ Warning out(_connection->communicator()->getLogger());
+ out << "Deadlock in Freeze::MapHelperI::count on Map \""
+ << _dbName << "\"; retrying ...";
+ }
+
+ //
+ // Ignored, try again
+ //
+ }
+ }
+ catch(const ::DbException& dx)
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
}
}
@@ -1143,47 +1143,47 @@ Freeze::MapHelperI::clear()
DbTxn* txn = _connection->dbTxn();
if(txn == 0)
{
- closeAllIterators();
+ closeAllIterators();
}
for(;;)
{
- try
- {
- u_int32_t count;
- int err;
- err = _db->truncate(txn, &count, txn != 0 ? 0 : DB_AUTO_COMMIT);
- assert(err == 0);
- break;
- }
- catch(const ::DbDeadlockException& dx)
- {
- if(txn != 0)
- {
- DeadlockException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
- else
- {
- if(_connection->deadlockWarning())
- {
- Warning out(_connection->communicator()->getLogger());
- out << "Deadlock in Freeze::MapHelperI::clear on Map \""
- << _dbName << "\"; retrying ...";
- }
-
- //
- // Ignored, try again
- //
- }
- }
- catch(const ::DbException& dx)
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
+ try
+ {
+ u_int32_t count;
+ int err;
+ err = _db->truncate(txn, &count, txn != 0 ? 0 : DB_AUTO_COMMIT);
+ assert(err == 0);
+ break;
+ }
+ catch(const ::DbDeadlockException& dx)
+ {
+ if(txn != 0)
+ {
+ DeadlockException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+ else
+ {
+ if(_connection->deadlockWarning())
+ {
+ Warning out(_connection->communicator()->getLogger());
+ out << "Deadlock in Freeze::MapHelperI::clear on Map \""
+ << _dbName << "\"; retrying ...";
+ }
+
+ //
+ // Ignored, try again
+ //
+ }
+ }
+ catch(const ::DbException& dx)
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
}
}
@@ -1192,71 +1192,71 @@ Freeze::MapHelperI::destroy()
{
if(_dbName == catalogName())
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = "You cannot destroy the " + catalogName() + " database";
- throw ex;
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = "You cannot destroy the " + catalogName() + " database";
+ throw ex;
}
TransactionPtr tx = _connection->currentTransaction();
bool ownTx = (tx == 0);
if(ownTx)
- {
- tx = _connection->beginTransaction();
+ {
+ tx = _connection->beginTransaction();
}
DbTxn* txn = _connection->dbTxn();
try
{
- close();
+ close();
- Catalog catalog(_connection, catalogName());
- catalog.erase(_dbName);
- _connection->dbEnv()->getEnv()->dbremove(txn, _dbName.c_str(), 0, 0);
+ Catalog catalog(_connection, catalogName());
+ catalog.erase(_dbName);
+ _connection->dbEnv()->getEnv()->dbremove(txn, _dbName.c_str(), 0, 0);
- if(ownTx)
- {
- tx->commit();
- }
+ if(ownTx)
+ {
+ tx->commit();
+ }
}
catch(const ::DbException& dx)
{
- if(ownTx)
- {
- tx = _connection->currentTransaction();
- if(tx != 0)
- {
- try
- {
- tx->rollback();
- }
- catch(...)
- {
- }
- }
- }
-
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ if(ownTx)
+ {
+ tx = _connection->currentTransaction();
+ if(tx != 0)
+ {
+ try
+ {
+ tx->rollback();
+ }
+ catch(...)
+ {
+ }
+ }
+ }
+
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
catch(...)
{
- if(ownTx)
- {
- tx = _connection->currentTransaction();
- if(tx != 0)
- {
- try
- {
- tx->rollback();
- }
- catch(...)
- {
- }
- }
- }
- throw;
+ if(ownTx)
+ {
+ tx = _connection->currentTransaction();
+ if(tx != 0)
+ {
+ try
+ {
+ tx->rollback();
+ }
+ catch(...)
+ {
+ }
+ }
+ }
+ throw;
}
}
@@ -1282,9 +1282,9 @@ Freeze::MapHelperI::size() const
}
catch(const ::DbException& dx)
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
size_t num = s->bt_ndata;
@@ -1298,7 +1298,7 @@ Freeze::MapHelperI::closeAllIterators()
{
while(!_iteratorList.empty())
{
- (*_iteratorList.begin())->close();
+ (*_iteratorList.begin())->close();
}
}
@@ -1308,9 +1308,9 @@ Freeze::MapHelperI::index(const string& name) const
IndexMap::const_iterator p = _indices.find(name);
if(p == _indices.end())
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = "Cannot find index \"" + name + "\"";
- throw ex;
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = "Cannot find index \"" + name + "\"";
+ throw ex;
}
return p->second;
}
@@ -1320,16 +1320,16 @@ Freeze::MapHelperI::close()
{
if(_db != 0)
{
- _connection->unregisterMap(this);
+ _connection->unregisterMap(this);
}
_db = 0;
for(IndexMap::iterator p = _indices.begin(); p != _indices.end(); ++p)
{
- MapIndexBasePtr& indexBase = p->second;
+ MapIndexBasePtr& indexBase = p->second;
- indexBase->_impl = 0;
- indexBase->_map = 0;
+ indexBase->_impl = 0;
+ indexBase->_map = 0;
}
_indices.clear();
}
@@ -1343,15 +1343,15 @@ Freeze::MapHelperI::closeAllIteratorsExcept(const IteratorHelperI::TxPtr& tx) co
while(q != _iteratorList.end())
{
- if((*q)->tx().get() == tx.get())
- {
- ++q;
- }
- else
- {
- (*q)->close();
- q = _iteratorList.begin();
- }
+ if((*q)->tx().get() == tx.get())
+ {
+ ++q;
+ }
+ else
+ {
+ (*q)->close();
+ q = _iteratorList.begin();
+ }
}
}
@@ -1385,7 +1385,7 @@ callback(Db* secondary, const Dbt* key, const Dbt* value, Dbt* result)
Freeze::MapIndexI::MapIndexI(const ConnectionIPtr& connection, SharedDb& db,
- DbTxn* txn, bool createDb, const MapIndexBasePtr& index) :
+ DbTxn* txn, bool createDb, const MapIndexBasePtr& index) :
_index(index)
{
assert(txn != 0);
@@ -1397,7 +1397,7 @@ Freeze::MapIndexI::MapIndexI(const ConnectionIPtr& connection, SharedDb& db,
u_int32_t flags = 0;
if(createDb)
{
- flags = DB_CREATE;
+ flags = DB_CREATE;
}
_dbName = db.dbName() + "." + _index->name();
@@ -1406,7 +1406,7 @@ Freeze::MapIndexI::MapIndexI(const ConnectionIPtr& connection, SharedDb& db,
if(index->compareEnabled())
{
- _db->set_bt_compare(&customIndexCompare);
+ _db->set_bt_compare(&customIndexCompare);
}
_db->open(txn, _dbName.c_str(), 0, DB_BTREE, flags, FREEZE_DB_MODE);
@@ -1429,17 +1429,17 @@ Freeze::MapIndexI::~MapIndexI()
IteratorHelper*
Freeze::MapIndexI::untypedFind(const Key& k, bool ro, const MapHelperI& m,
- bool onlyDups) const
+ bool onlyDups) const
{
auto_ptr<IteratorHelperI> r(new IteratorHelperI(m, ro, _index, onlyDups));
if(r->find(k))
{
- return r.release();
+ return r.release();
}
else
{
- return 0;
+ return 0;
}
}
@@ -1450,11 +1450,11 @@ Freeze::MapIndexI::untypedLowerBound(const Key& k, bool ro, const MapHelperI& m)
if(r->lowerBound(k))
{
- return r.release();
+ return r.release();
}
else
{
- return 0;
+ return 0;
}
}
@@ -1465,11 +1465,11 @@ Freeze::MapIndexI::untypedUpperBound(const Key& k, bool ro, const MapHelperI& m)
if(r->upperBound(k))
{
- return r.release();
+ return r.release();
}
else
{
- return 0;
+ return 0;
}
}
@@ -1493,81 +1493,81 @@ Freeze::MapIndexI::untypedCount(const Key& k, const ConnectionIPtr& connection)
try
{
- for(;;)
- {
- Dbc* dbc = 0;
-
- try
- {
- //
- // Move to the first record
- //
- _db->cursor(0, &dbc, 0);
- bool found = (dbc->get(&dbKey, &dbValue, DB_SET) == 0);
-
- if(found)
- {
- db_recno_t count = 0;
- dbc->count(&count, 0);
- result = static_cast<int>(count);
- }
-
- Dbc* toClose = dbc;
- dbc = 0;
- toClose->close();
- break; // for (;;)
- }
- catch(const DbDeadlockException&)
- {
- if(dbc != 0)
- {
- try
- {
- dbc->close();
- }
- catch(const DbDeadlockException&)
- {
- //
- // Ignored
- //
- }
- }
-
- if(connection->deadlockWarning())
- {
- Warning out(connection->communicator()->getLogger());
- out << "Deadlock in Freeze::MapIndexI::untypedCount while searching \""
- << _dbName << "\"; retrying ...";
- }
-
- //
- // Retry
- //
- }
- catch(...)
- {
- if(dbc != 0)
- {
- try
- {
- dbc->close();
- }
- catch(const DbDeadlockException&)
- {
- //
- // Ignored
- //
- }
- }
- throw;
- }
- }
+ for(;;)
+ {
+ Dbc* dbc = 0;
+
+ try
+ {
+ //
+ // Move to the first record
+ //
+ _db->cursor(0, &dbc, 0);
+ bool found = (dbc->get(&dbKey, &dbValue, DB_SET) == 0);
+
+ if(found)
+ {
+ db_recno_t count = 0;
+ dbc->count(&count, 0);
+ result = static_cast<int>(count);
+ }
+
+ Dbc* toClose = dbc;
+ dbc = 0;
+ toClose->close();
+ break; // for (;;)
+ }
+ catch(const DbDeadlockException&)
+ {
+ if(dbc != 0)
+ {
+ try
+ {
+ dbc->close();
+ }
+ catch(const DbDeadlockException&)
+ {
+ //
+ // Ignored
+ //
+ }
+ }
+
+ if(connection->deadlockWarning())
+ {
+ Warning out(connection->communicator()->getLogger());
+ out << "Deadlock in Freeze::MapIndexI::untypedCount while searching \""
+ << _dbName << "\"; retrying ...";
+ }
+
+ //
+ // Retry
+ //
+ }
+ catch(...)
+ {
+ if(dbc != 0)
+ {
+ try
+ {
+ dbc->close();
+ }
+ catch(const DbDeadlockException&)
+ {
+ //
+ // Ignored
+ //
+ }
+ }
+ throw;
+ }
+ }
}
catch(const DbException& dx)
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
return result;
@@ -1575,7 +1575,7 @@ Freeze::MapIndexI::untypedCount(const Key& k, const ConnectionIPtr& connection)
int
Freeze::MapIndexI::secondaryKeyCreate(Db* secondary, const Dbt* dbKey,
- const Dbt* dbValue, Dbt* result)
+ const Dbt* dbValue, Dbt* result)
{
Byte* first = static_cast<Byte*>(dbValue->get_data());
Value value(first, first + dbValue->get_size());
diff --git a/cpp/src/Freeze/MapI.h b/cpp/src/Freeze/MapI.h
index fa2e3524b3e..3623beae33d 100644
--- a/cpp/src/Freeze/MapI.h
+++ b/cpp/src/Freeze/MapI.h
@@ -24,7 +24,7 @@ class IteratorHelperI : public IteratorHelper
public:
IteratorHelperI(const MapHelperI& m, bool readOnly,
- const MapIndexBasePtr& index, bool onlyDups);
+ const MapIndexBasePtr& index, bool onlyDups);
IteratorHelperI(const IteratorHelperI&);
virtual
@@ -66,20 +66,20 @@ public:
{
public:
- Tx(const MapHelperI&);
- ~Tx();
+ Tx(const MapHelperI&);
+ ~Tx();
- void dead();
+ void dead();
- DbTxn* getTxn()
- {
- return _txn;
- }
+ DbTxn* getTxn()
+ {
+ return _txn;
+ }
private:
- const MapHelperI& _map;
- DbTxn* _txn;
- bool _dead;
+ const MapHelperI& _map;
+ DbTxn* _txn;
+ bool _dead;
};
typedef IceUtil::Handle<Tx> TxPtr;
@@ -108,9 +108,9 @@ class MapHelperI : public MapHelper
public:
MapHelperI(const ConnectionIPtr&, const std::string&,
- const std::string&, const std::string&,
- const KeyCompareBasePtr&,
- const std::vector<MapIndexBasePtr>&, bool);
+ const std::string&, const std::string&,
+ const KeyCompareBasePtr&,
+ const std::vector<MapIndexBasePtr>&, bool);
virtual ~MapHelperI();
@@ -152,7 +152,7 @@ public:
const ConnectionIPtr& connection() const
{
- return _connection;
+ return _connection;
}
diff --git a/cpp/src/Freeze/ObjectStore.cpp b/cpp/src/Freeze/ObjectStore.cpp
index 6f120752afb..24ab9ba484f 100644
--- a/cpp/src/Freeze/ObjectStore.cpp
+++ b/cpp/src/Freeze/ObjectStore.cpp
@@ -20,9 +20,9 @@ using namespace Freeze;
Freeze::ObjectStore::ObjectStore(const string& facet,
- bool createDb, EvictorI* evictor,
- const vector<IndexPtr>& indices,
- bool populateEmptyIndices) :
+ bool createDb, EvictorI* evictor,
+ const vector<IndexPtr>& indices,
+ bool populateEmptyIndices) :
_facet(facet),
_evictor(evictor),
_indices(indices),
@@ -30,11 +30,11 @@ Freeze::ObjectStore::ObjectStore(const string& facet,
{
if(facet == "")
{
- _dbName = EvictorI::defaultDb;
+ _dbName = EvictorI::defaultDb;
}
else
{
- _dbName = facet;
+ _dbName = facet;
}
ConnectionPtr catalogConnection = createConnection(_communicator, evictor->dbEnv()->getEnvName());
@@ -43,85 +43,85 @@ Freeze::ObjectStore::ObjectStore(const string& facet,
Catalog::iterator p = catalog.find(evictor->filename());
if(p != catalog.end())
{
- if(p->second.evictor == false)
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = evictor->filename() + " is an evictor database";
- throw ex;
- }
+ if(p->second.evictor == false)
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = evictor->filename() + " is an evictor database";
+ throw ex;
+ }
}
DbEnv* dbEnv = evictor->dbEnv()->getEnv();
try
{
- _db.reset(new Db(dbEnv, 0));
-
- TransactionPtr tx = catalogConnection->beginTransaction();
- DbTxn* txn = getTxn(tx);
-
- u_int32_t flags = DB_THREAD;
- if(createDb)
- {
- flags |= DB_CREATE;
- }
- _db->open(txn, evictor->filename().c_str(), _dbName.c_str(), DB_BTREE, flags, FREEZE_DB_MODE);
-
- for(size_t i = 0; i < _indices.size(); ++i)
- {
- _indices[i]->_impl->associate(this, txn, createDb, populateEmptyIndices);
- }
-
- if(p == catalog.end())
- {
- CatalogData catalogData;
- catalogData.evictor = true;
- catalog.put(Catalog::value_type(evictor->filename(), catalogData));
- }
-
- tx->commit();
+ _db.reset(new Db(dbEnv, 0));
+
+ TransactionPtr tx = catalogConnection->beginTransaction();
+ DbTxn* txn = getTxn(tx);
+
+ u_int32_t flags = DB_THREAD;
+ if(createDb)
+ {
+ flags |= DB_CREATE;
+ }
+ _db->open(txn, evictor->filename().c_str(), _dbName.c_str(), DB_BTREE, flags, FREEZE_DB_MODE);
+
+ for(size_t i = 0; i < _indices.size(); ++i)
+ {
+ _indices[i]->_impl->associate(this, txn, createDb, populateEmptyIndices);
+ }
+
+ if(p == catalog.end())
+ {
+ CatalogData catalogData;
+ catalogData.evictor = true;
+ catalog.put(Catalog::value_type(evictor->filename(), catalogData));
+ }
+
+ tx->commit();
}
catch(const DbException& dx)
{
- TransactionPtr tx = catalogConnection->currentTransaction();
- if(tx != 0)
- {
- try
- {
- tx->rollback();
- }
- catch(...)
- {
- }
- }
-
- if(dx.get_errno() == ENOENT)
- {
- NotFoundException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
- else
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
+ TransactionPtr tx = catalogConnection->currentTransaction();
+ if(tx != 0)
+ {
+ try
+ {
+ tx->rollback();
+ }
+ catch(...)
+ {
+ }
+ }
+
+ if(dx.get_errno() == ENOENT)
+ {
+ NotFoundException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+ else
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
}
catch(...)
{
- TransactionPtr tx = catalogConnection->currentTransaction();
- if(tx != 0)
- {
- try
- {
- tx->rollback();
- }
- catch(...)
- {
- }
- }
- throw;
+ TransactionPtr tx = catalogConnection->currentTransaction();
+ if(tx != 0)
+ {
+ try
+ {
+ tx->rollback();
+ }
+ catch(...)
+ {
+ }
+ }
+ throw;
}
}
@@ -129,7 +129,7 @@ Freeze::ObjectStore::~ObjectStore()
{
if(_db.get() != 0)
{
- close();
+ close();
}
}
@@ -138,19 +138,19 @@ Freeze::ObjectStore::close()
{
try
{
- _db->close(0);
-
- for(size_t i = 0; i < _indices.size(); ++i)
- {
- _indices[i]->_impl->close();
- }
- _indices.clear();
+ _db->close(0);
+
+ for(size_t i = 0; i < _indices.size(); ++i)
+ {
+ _indices[i]->_impl->close();
+ }
+ _indices.clear();
}
catch(const DbException& dx)
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
_db.reset();
}
@@ -171,43 +171,43 @@ Freeze::ObjectStore::dbHasObject(const Identity& ident) const
for(;;)
{
- try
- {
- int err = _db->get(0, &dbKey, &dbValue, 0);
-
- if(err == 0)
- {
- return true;
- }
- else if(err == DB_NOTFOUND)
- {
- return false;
- }
- else
- {
- assert(0);
- throw DatabaseException(__FILE__, __LINE__);
- }
- }
- catch(const DbDeadlockException&)
- {
- if(_evictor->deadlockWarning())
- {
- Warning out(_communicator->getLogger());
- out << "Deadlock in Freeze::ObjectStore::dbHasObject while searching \""
- << _evictor->filename() + "/" + _dbName << "\"; retrying ...";
- }
-
- //
- // Ignored, try again
- //
- }
- catch(const DbException& dx)
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
+ try
+ {
+ int err = _db->get(0, &dbKey, &dbValue, 0);
+
+ if(err == 0)
+ {
+ return true;
+ }
+ else if(err == DB_NOTFOUND)
+ {
+ return false;
+ }
+ else
+ {
+ assert(0);
+ throw DatabaseException(__FILE__, __LINE__);
+ }
+ }
+ catch(const DbDeadlockException&)
+ {
+ if(_evictor->deadlockWarning())
+ {
+ Warning out(_communicator->getLogger());
+ out << "Deadlock in Freeze::ObjectStore::dbHasObject while searching \""
+ << _evictor->filename() + "/" + _dbName << "\"; retrying ...";
+ }
+
+ //
+ // Ignored, try again
+ //
+ }
+ catch(const DbException& dx)
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
}
}
@@ -217,37 +217,37 @@ Freeze::ObjectStore::save(Key& key, Value& value, Byte status, DbTxn* tx)
{
switch(status)
{
- case EvictorElement::created:
- case EvictorElement::modified:
- {
- Dbt dbKey;
- Dbt dbValue;
- initializeInDbt(key, dbKey);
- initializeInDbt(value, dbValue);
- u_int32_t flags = (status == EvictorElement::created) ? DB_NOOVERWRITE : 0;
- int err = _db->put(tx, &dbKey, &dbValue, flags);
- if(err != 0)
- {
- throw DatabaseException(__FILE__, __LINE__);
- }
- break;
- }
-
- case EvictorElement::destroyed:
- {
- Dbt dbKey;
- initializeInDbt(key, dbKey);
- int err = _db->del(tx, &dbKey, 0);
- if(err != 0)
- {
- throw DatabaseException(__FILE__, __LINE__);
- }
- break;
- }
- default:
- {
- assert(0);
- }
+ case EvictorElement::created:
+ case EvictorElement::modified:
+ {
+ Dbt dbKey;
+ Dbt dbValue;
+ initializeInDbt(key, dbKey);
+ initializeInDbt(value, dbValue);
+ u_int32_t flags = (status == EvictorElement::created) ? DB_NOOVERWRITE : 0;
+ int err = _db->put(tx, &dbKey, &dbValue, flags);
+ if(err != 0)
+ {
+ throw DatabaseException(__FILE__, __LINE__);
+ }
+ break;
+ }
+
+ case EvictorElement::destroyed:
+ {
+ Dbt dbKey;
+ initializeInDbt(key, dbKey);
+ int err = _db->del(tx, &dbKey, 0);
+ if(err != 0)
+ {
+ throw DatabaseException(__FILE__, __LINE__);
+ }
+ break;
+ }
+ default:
+ {
+ assert(0);
+ }
}
}
@@ -322,36 +322,36 @@ Freeze::ObjectStore::load(const Identity& ident)
for(;;)
{
- try
- {
- int rs = _db->get(0, &dbKey, &dbValue, 0);
- if(rs == DB_NOTFOUND)
- {
- return 0;
- }
- else if(rs != 0)
- {
- assert(0);
- throw DatabaseException(__FILE__, __LINE__);
- }
- break; // for(;;)
- }
- catch(const DbDeadlockException&)
- {
- if(_evictor->deadlockWarning())
- {
- Warning out(_communicator->getLogger());
- out << "Deadlock in Freeze::ObjectStore::load while searching \""
- << _evictor->filename() + "/" + _dbName << "\"; retrying ...";
- }
- //
- // Ignored, try again
- //
- }
- catch(const DbException& dx)
- {
- handleDbException(dx, value, dbValue, __FILE__, __LINE__);
- }
+ try
+ {
+ int rs = _db->get(0, &dbKey, &dbValue, 0);
+ if(rs == DB_NOTFOUND)
+ {
+ return 0;
+ }
+ else if(rs != 0)
+ {
+ assert(0);
+ throw DatabaseException(__FILE__, __LINE__);
+ }
+ break; // for(;;)
+ }
+ catch(const DbDeadlockException&)
+ {
+ if(_evictor->deadlockWarning())
+ {
+ Warning out(_communicator->getLogger());
+ out << "Deadlock in Freeze::ObjectStore::load while searching \""
+ << _evictor->filename() + "/" + _dbName << "\"; retrying ...";
+ }
+ //
+ // Ignored, try again
+ //
+ }
+ catch(const DbException& dx)
+ {
+ handleDbException(dx, value, dbValue, __FILE__, __LINE__);
+ }
}
EvictorElementPtr result = new EvictorElement(*this);
diff --git a/cpp/src/Freeze/ObjectStore.h b/cpp/src/Freeze/ObjectStore.h
index 274a82331f7..94db579a64d 100644
--- a/cpp/src/Freeze/ObjectStore.h
+++ b/cpp/src/Freeze/ObjectStore.h
@@ -36,7 +36,7 @@ class ObjectStore : public Cache
public:
ObjectStore(const std::string&, bool, EvictorI*,
- const std::vector<IndexPtr>& = std::vector<IndexPtr>(), bool = false);
+ const std::vector<IndexPtr>& = std::vector<IndexPtr>(), bool = false);
virtual ~ObjectStore();
diff --git a/cpp/src/Freeze/SharedDb.cpp b/cpp/src/Freeze/SharedDb.cpp
index 86205fa91b4..0c208c26eb1 100644
--- a/cpp/src/Freeze/SharedDb.cpp
+++ b/cpp/src/Freeze/SharedDb.cpp
@@ -31,15 +31,15 @@ checkTypes(const SharedDb& sharedDb, const string& key, const string& value)
{
if(key != sharedDb.key())
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = sharedDb.dbName() + "'s key type is " + sharedDb.key() + ", not " + key;
- throw ex;
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = sharedDb.dbName() + "'s key type is " + sharedDb.key() + ", not " + key;
+ throw ex;
}
if(value != sharedDb.value())
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = sharedDb.dbName() + "'s value type is " + sharedDb.value() + ", not " + value;
- throw ex;
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = sharedDb.dbName() + "'s value type is " + sharedDb.value() + ", not " + value;
+ throw ex;
}
}
}
@@ -68,29 +68,29 @@ Freeze::catalogName()
SharedDbPtr
Freeze::SharedDb::get(const ConnectionIPtr& connection,
- const string& dbName,
- const string& key,
- const string& value,
- const KeyCompareBasePtr& keyCompare,
- const vector<MapIndexBasePtr>& indices,
- bool createDb)
+ const string& dbName,
+ const string& key,
+ const string& value,
+ const KeyCompareBasePtr& keyCompare,
+ const vector<MapIndexBasePtr>& indices,
+ bool createDb)
{
if(dbName == _catalogName)
{
- //
- // We don't want to lock the _mapMutex to retrieve the catalog
- //
-
- SharedDbPtr result = connection->dbEnv()->getCatalog();
- checkTypes(*result, key, value);
- return result;
+ //
+ // We don't want to lock the _mapMutex to retrieve the catalog
+ //
+
+ SharedDbPtr result = connection->dbEnv()->getCatalog();
+ checkTypes(*result, key, value);
+ return result;
}
StaticMutex::Lock lock(_mapMutex);
if(sharedDbMap == 0)
{
- sharedDbMap = new SharedDbMap;
+ sharedDbMap = new SharedDbMap;
}
MapKey mapKey;
@@ -99,20 +99,20 @@ Freeze::SharedDb::get(const ConnectionIPtr& connection,
mapKey.dbName = dbName;
{
- SharedDbMap::iterator p = sharedDbMap->find(mapKey);
- if(p != sharedDbMap->end())
- {
- checkTypes(*(p->second), key, value);
- p->second->connectIndices(indices);
- return p->second;
- }
+ SharedDbMap::iterator p = sharedDbMap->find(mapKey);
+ if(p != sharedDbMap->end())
+ {
+ checkTypes(*(p->second), key, value);
+ p->second->connectIndices(indices);
+ return p->second;
+ }
}
//
// MapKey not found, let's create and open a new Db
//
auto_ptr<SharedDb> result(new SharedDb(mapKey, key, value, connection,
- keyCompare, indices, createDb));
+ keyCompare, indices, createDb));
//
// Insert it into the map
@@ -131,7 +131,7 @@ Freeze::SharedDb::openCatalog(SharedDbEnv& dbEnv)
if(sharedDbMap == 0)
{
- sharedDbMap = new SharedDbMap;
+ sharedDbMap = new SharedDbMap;
}
MapKey mapKey;
@@ -145,17 +145,17 @@ Freeze::SharedDb::openCatalog(SharedDbEnv& dbEnv)
// Insert it into the map
//
pair<SharedDbMap::iterator, bool> insertResult
- = sharedDbMap->insert(SharedDbMap::value_type(mapKey, result.get()));
+ = sharedDbMap->insert(SharedDbMap::value_type(mapKey, result.get()));
if(!insertResult.second)
{
- //
- // That's very wrong: the catalog is associated with another env
- //
- assert(0);
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = "Catalog already opened";
- throw ex;
+ //
+ // That's very wrong: the catalog is associated with another env
+ //
+ assert(0);
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = "Catalog already opened";
+ throw ex;
}
return result.release();
@@ -166,8 +166,8 @@ Freeze::SharedDb::~SharedDb()
{
if(_trace >= 1)
{
- Trace out(_mapKey.communicator->getLogger(), "Freeze.Map");
- out << "closing Db \"" << _mapKey.dbName << "\"";
+ Trace out(_mapKey.communicator->getLogger(), "Freeze.Map");
+ out << "closing Db \"" << _mapKey.dbName << "\"";
}
cleanup(false);
@@ -177,8 +177,8 @@ void Freeze::SharedDb::__incRef()
{
if(_trace >= 2)
{
- Trace out(_mapKey.communicator->getLogger(), "Freeze.Map");
- out << "incremeting reference count for Db \"" << _mapKey.dbName << "\"";
+ Trace out(_mapKey.communicator->getLogger(), "Freeze.Map");
+ out << "incremeting reference count for Db \"" << _mapKey.dbName << "\"";
}
IceUtil::StaticMutex::Lock lock(_refCountMutex);
@@ -189,57 +189,57 @@ void Freeze::SharedDb::__decRef()
{
if(_trace >= 2)
{
- Trace out(_mapKey.communicator->getLogger(), "Freeze.Map");
- out << "removing reference count for Db \"" << _mapKey.dbName << "\"";
+ Trace out(_mapKey.communicator->getLogger(), "Freeze.Map");
+ out << "removing reference count for Db \"" << _mapKey.dbName << "\"";
}
IceUtil::StaticMutex::Lock lock(_refCountMutex);
if(--_refCount == 0)
{
IceUtil::StaticMutex::TryLock mapLock(_mapMutex);
- if(!mapLock.acquired())
- {
- //
- // Reacquire mutex in proper order and check again
- //
- lock.release();
- mapLock.acquire();
- lock.acquire();
- if(_refCount > 0)
- {
- return;
- }
- }
-
- //
- // Remove from map
- //
- size_t one;
- one = sharedDbMap->erase(_mapKey);
- assert(one == 1);
-
- if(sharedDbMap->size() == 0)
- {
- delete sharedDbMap;
- sharedDbMap = 0;
- }
-
- //
- // Keep lock to prevent somebody else to re-open this Db
- // before it's closed.
- //
- delete this;
+ if(!mapLock.acquired())
+ {
+ //
+ // Reacquire mutex in proper order and check again
+ //
+ lock.release();
+ mapLock.acquire();
+ lock.acquire();
+ if(_refCount > 0)
+ {
+ return;
+ }
+ }
+
+ //
+ // Remove from map
+ //
+ size_t one;
+ one = sharedDbMap->erase(_mapKey);
+ assert(one == 1);
+
+ if(sharedDbMap->size() == 0)
+ {
+ delete sharedDbMap;
+ sharedDbMap = 0;
+ }
+
+ //
+ // Keep lock to prevent somebody else to re-open this Db
+ // before it's closed.
+ //
+ delete this;
}
}
Freeze::SharedDb::SharedDb(const MapKey& mapKey,
- const string& key,
- const string& value,
- const ConnectionIPtr& connection,
- const KeyCompareBasePtr& keyCompare,
- const vector<MapIndexBasePtr>& indices,
- bool createDb) :
+ const string& key,
+ const string& value,
+ const ConnectionIPtr& connection,
+ const KeyCompareBasePtr& keyCompare,
+ const vector<MapIndexBasePtr>& indices,
+ bool createDb) :
Db(connection->dbEnv()->getEnv(), 0),
_mapKey(mapKey),
_refCount(0),
@@ -248,128 +248,128 @@ Freeze::SharedDb::SharedDb(const MapKey& mapKey,
{
if(_trace >= 1)
{
- Trace out(_mapKey.communicator->getLogger(), "Freeze.Map");
- out << "opening Db \"" << _mapKey.dbName << "\"";
+ Trace out(_mapKey.communicator->getLogger(), "Freeze.Map");
+ out << "opening Db \"" << _mapKey.dbName << "\"";
}
ConnectionPtr catalogConnection =
- createConnection(_mapKey.communicator, connection->dbEnv()->getEnvName());
+ createConnection(_mapKey.communicator, connection->dbEnv()->getEnvName());
Catalog catalog(catalogConnection, _catalogName);
Catalog::iterator ci = catalog.find(_mapKey.dbName);
if(ci != catalog.end())
{
- if(ci->second.evictor)
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = _mapKey.dbName + " is an evictor database";
- throw ex;
- }
-
- _key = ci->second.key;
- _value = ci->second.value;
- checkTypes(*this, key, value);
+ if(ci->second.evictor)
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = _mapKey.dbName + " is an evictor database";
+ throw ex;
+ }
+
+ _key = ci->second.key;
+ _value = ci->second.value;
+ checkTypes(*this, key, value);
}
else
{
- _key = key;
- _value = value;
+ _key = key;
+ _value = value;
}
set_app_private(this);
if(_keyCompare->compareEnabled())
{
- set_bt_compare(&customCompare);
+ set_bt_compare(&customCompare);
}
try
{
- TransactionPtr tx = catalogConnection->beginTransaction();
- DbTxn* txn = getTxn(tx);
-
- u_int32_t flags = DB_THREAD;
- if(createDb)
- {
- flags |= DB_CREATE;
- }
- open(txn, _mapKey.dbName.c_str(), 0, DB_BTREE, flags, FREEZE_DB_MODE);
-
- for(vector<MapIndexBasePtr>::const_iterator p = indices.begin();
- p != indices.end(); ++p)
- {
- const MapIndexBasePtr& indexBase = *p;
- assert(indexBase->_impl == 0);
- assert(indexBase->_communicator == 0);
- indexBase->_communicator = connection->communicator();
-
- auto_ptr<MapIndexI> indexI(new MapIndexI(connection, *this, txn, createDb, indexBase));
-
+ TransactionPtr tx = catalogConnection->beginTransaction();
+ DbTxn* txn = getTxn(tx);
+
+ u_int32_t flags = DB_THREAD;
+ if(createDb)
+ {
+ flags |= DB_CREATE;
+ }
+ open(txn, _mapKey.dbName.c_str(), 0, DB_BTREE, flags, FREEZE_DB_MODE);
+
+ for(vector<MapIndexBasePtr>::const_iterator p = indices.begin();
+ p != indices.end(); ++p)
+ {
+ const MapIndexBasePtr& indexBase = *p;
+ assert(indexBase->_impl == 0);
+ assert(indexBase->_communicator == 0);
+ indexBase->_communicator = connection->communicator();
+
+ auto_ptr<MapIndexI> indexI(new MapIndexI(connection, *this, txn, createDb, indexBase));
+
#ifndef NDEBUG
- bool inserted =
+ bool inserted =
#endif
- _indices.insert(IndexMap::value_type(indexBase->name(), indexI.get())).second;
- assert(inserted);
-
- indexBase->_impl = indexI.release();
- }
-
- if(ci == catalog.end())
- {
- CatalogData catalogData;
- catalogData.evictor = false;
- catalogData.key = key;
- catalogData.value = value;
- catalog.put(Catalog::value_type(_mapKey.dbName, catalogData));
- }
-
- tx->commit();
+ _indices.insert(IndexMap::value_type(indexBase->name(), indexI.get())).second;
+ assert(inserted);
+
+ indexBase->_impl = indexI.release();
+ }
+
+ if(ci == catalog.end())
+ {
+ CatalogData catalogData;
+ catalogData.evictor = false;
+ catalogData.key = key;
+ catalogData.value = value;
+ catalog.put(Catalog::value_type(_mapKey.dbName, catalogData));
+ }
+
+ tx->commit();
}
catch(const ::DbException& dx)
{
- TransactionPtr tx = catalogConnection->currentTransaction();
- if(tx != 0)
- {
- try
- {
- tx->rollback();
- }
- catch(...)
- {
- }
- }
-
- cleanup(true);
-
- if(dx.get_errno() == ENOENT)
- {
- NotFoundException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
- else
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
+ TransactionPtr tx = catalogConnection->currentTransaction();
+ if(tx != 0)
+ {
+ try
+ {
+ tx->rollback();
+ }
+ catch(...)
+ {
+ }
+ }
+
+ cleanup(true);
+
+ if(dx.get_errno() == ENOENT)
+ {
+ NotFoundException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+ else
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
}
catch(...)
{
- TransactionPtr tx = catalogConnection->currentTransaction();
- if(tx != 0)
- {
- try
- {
- tx->rollback();
- }
- catch(...)
- {
- }
- }
-
- cleanup(true);
- throw;
+ TransactionPtr tx = catalogConnection->currentTransaction();
+ if(tx != 0)
+ {
+ try
+ {
+ tx->rollback();
+ }
+ catch(...)
+ {
+ }
+ }
+
+ cleanup(true);
+ throw;
}
}
@@ -385,20 +385,20 @@ Freeze::SharedDb::SharedDb(const MapKey& mapKey, DbEnv* env) :
if(_trace >= 1)
{
- Trace out(_mapKey.communicator->getLogger(), "Freeze.Db");
- out << "opening Db \"" << _mapKey.dbName << "\"";
+ Trace out(_mapKey.communicator->getLogger(), "Freeze.Db");
+ out << "opening Db \"" << _mapKey.dbName << "\"";
}
try
{
- u_int32_t flags = DB_THREAD | DB_CREATE | DB_AUTO_COMMIT;
- open(0, _mapKey.dbName.c_str(), 0, DB_BTREE, flags, FREEZE_DB_MODE);
+ u_int32_t flags = DB_THREAD | DB_CREATE | DB_AUTO_COMMIT;
+ open(0, _mapKey.dbName.c_str(), 0, DB_BTREE, flags, FREEZE_DB_MODE);
}
catch(const ::DbException& dx)
{
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
}
@@ -406,15 +406,15 @@ void
Freeze::SharedDb::connectIndices(const vector<MapIndexBasePtr>& indices) const
{
for(vector<MapIndexBasePtr>::const_iterator p = indices.begin();
- p != indices.end(); ++p)
+ p != indices.end(); ++p)
{
- const MapIndexBasePtr& indexBase = *p;
- assert(indexBase->_impl == 0);
+ const MapIndexBasePtr& indexBase = *p;
+ assert(indexBase->_impl == 0);
- IndexMap::const_iterator q = _indices.find(indexBase->name());
- assert(q != _indices.end());
- indexBase->_impl = q->second;
- indexBase->_communicator = _mapKey.communicator;
+ IndexMap::const_iterator q = _indices.find(indexBase->name());
+ assert(q != _indices.end());
+ indexBase->_impl = q->second;
+ indexBase->_communicator = _mapKey.communicator;
}
}
@@ -423,21 +423,21 @@ Freeze::SharedDb::cleanup(bool noThrow)
{
try
{
- for(IndexMap::iterator p = _indices.begin(); p != _indices.end(); ++p)
- {
- delete p->second;
- }
- _indices.clear();
-
- close(0);
+ for(IndexMap::iterator p = _indices.begin(); p != _indices.end(); ++p)
+ {
+ delete p->second;
+ }
+ _indices.clear();
+
+ close(0);
}
catch(const ::DbException& dx)
{
- if(!noThrow)
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
+ if(!noThrow)
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
}
}
diff --git a/cpp/src/Freeze/SharedDb.h b/cpp/src/Freeze/SharedDb.h
index a6ce6672c44..3576f51fa23 100644
--- a/cpp/src/Freeze/SharedDb.h
+++ b/cpp/src/Freeze/SharedDb.h
@@ -30,7 +30,7 @@ class MapIndexI
public:
MapIndexI(const ConnectionIPtr&, SharedDb&,
- DbTxn*, bool, const MapIndexBasePtr&);
+ DbTxn*, bool, const MapIndexBasePtr&);
~MapIndexI();
@@ -45,17 +45,17 @@ public:
const std::string name() const
{
- return _index->name();
+ return _index->name();
}
Db* db() const
{
- return _db.get();
+ return _db.get();
}
const MapIndexBasePtr& getKeyCompare() const
{
- return _index;
+ return _index;
}
private:
@@ -73,9 +73,9 @@ public:
using Db::get;
static SharedDbPtr get(const ConnectionIPtr&, const std::string&,
- const std::string&, const std::string&,
- const KeyCompareBasePtr&,
- const std::vector<MapIndexBasePtr>&, bool);
+ const std::string&, const std::string&,
+ const KeyCompareBasePtr&,
+ const std::vector<MapIndexBasePtr>&, bool);
static SharedDbPtr openCatalog(SharedDbEnv&);
@@ -101,7 +101,7 @@ public:
virtual int
get(DbTxn *txnid, Dbt *key, Dbt *data, u_int32_t flags)
{
- return ::Db::get(txnid, key, data, flags);
+ return ::Db::get(txnid, key, data, flags);
}
#endif
@@ -111,19 +111,19 @@ private:
struct MapKey
{
- std::string envName;
- Ice::CommunicatorPtr communicator;
- std::string dbName;
+ std::string envName;
+ Ice::CommunicatorPtr communicator;
+ std::string dbName;
- inline bool
- operator<(const MapKey& rhs) const;
+ inline bool
+ operator<(const MapKey& rhs) const;
};
typedef std::map<MapKey, Freeze::SharedDb*> SharedDbMap;
SharedDb(const MapKey&, const std::string&, const std::string&,
- const ConnectionIPtr&, const KeyCompareBasePtr&,
- const std::vector<MapIndexBasePtr>&, bool);
+ const ConnectionIPtr&, const KeyCompareBasePtr&,
+ const std::vector<MapIndexBasePtr>&, bool);
SharedDb(const MapKey&, DbEnv*);
@@ -170,8 +170,8 @@ inline bool
SharedDb::MapKey::operator<(const MapKey& rhs) const
{
return (communicator < rhs.communicator) ||
- ((communicator == rhs.communicator) && (dbName < rhs.dbName)) ||
- ((communicator == rhs.communicator) && (dbName == rhs.dbName) && (envName < rhs.envName));
+ ((communicator == rhs.communicator) && (dbName < rhs.dbName)) ||
+ ((communicator == rhs.communicator) && (dbName == rhs.dbName) && (envName < rhs.envName));
}
}
diff --git a/cpp/src/Freeze/SharedDbEnv.cpp b/cpp/src/Freeze/SharedDbEnv.cpp
index ea1dc64a054..3c03af446d2 100644
--- a/cpp/src/Freeze/SharedDbEnv.cpp
+++ b/cpp/src/Freeze/SharedDbEnv.cpp
@@ -59,7 +59,7 @@ inline bool
operator<(const MapKey& lhs, const MapKey& rhs)
{
return (lhs.communicator < rhs.communicator) ||
- ((lhs.communicator == rhs.communicator) && (lhs.envName < rhs.envName));
+ ((lhs.communicator == rhs.communicator) && (lhs.envName < rhs.envName));
}
#if DB_VERSION_MAJOR != 4
@@ -92,13 +92,13 @@ SharedDbEnvMap* sharedDbEnvMap;
Freeze::SharedDbEnvPtr
Freeze::SharedDbEnv::get(const CommunicatorPtr& communicator,
- const string& envName, DbEnv* env)
+ const string& envName, DbEnv* env)
{
StaticMutex::Lock lock(_mapMutex);
if(sharedDbEnvMap == 0)
{
- sharedDbEnvMap = new SharedDbEnvMap;
+ sharedDbEnvMap = new SharedDbEnvMap;
}
MapKey key;
@@ -106,11 +106,11 @@ Freeze::SharedDbEnv::get(const CommunicatorPtr& communicator,
key.communicator = communicator;
{
- SharedDbEnvMap::iterator p = sharedDbEnvMap->find(key);
- if(p != sharedDbEnvMap->end())
- {
- return p->second;
- }
+ SharedDbEnvMap::iterator p = sharedDbEnvMap->find(key);
+ if(p != sharedDbEnvMap->end())
+ {
+ return p->second;
+ }
}
//
@@ -132,8 +132,8 @@ Freeze::SharedDbEnv::~SharedDbEnv()
{
if(_trace >= 1)
{
- Trace out(_communicator->getLogger(), "Freeze.DbEnv");
- out << "closing database environment \"" << _envName << "\"";
+ Trace out(_communicator->getLogger(), "Freeze.DbEnv");
+ out << "closing database environment \"" << _envName << "\"";
}
//
@@ -146,22 +146,22 @@ Freeze::SharedDbEnv::~SharedDbEnv()
//
if(_thread != 0)
{
- _thread->terminate();
- _thread = 0;
+ _thread->terminate();
+ _thread = 0;
}
if(_envHolder.get() != 0)
{
- try
- {
- _envHolder->close(0);
- }
- catch(const ::DbException& dx)
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
+ try
+ {
+ _envHolder->close(0);
+ }
+ catch(const ::DbException& dx)
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
}
}
@@ -177,47 +177,47 @@ void Freeze::SharedDbEnv::__decRef()
if(--_refCount == 0)
{
IceUtil::StaticMutex::TryLock mapLock(_mapMutex);
- if(!mapLock.acquired())
- {
- //
- // Reacquire mutex in proper order and check again
- //
- lock.release();
- mapLock.acquire();
- lock.acquire();
- if(_refCount > 0)
- {
- return;
- }
- }
-
- //
- // Remove from map
- //
+ if(!mapLock.acquired())
+ {
+ //
+ // Reacquire mutex in proper order and check again
+ //
+ lock.release();
+ mapLock.acquire();
+ lock.acquire();
+ if(_refCount > 0)
+ {
+ return;
+ }
+ }
+
+ //
+ // Remove from map
+ //
MapKey key;
key.envName = _envName;
key.communicator = _communicator;
- size_t one;
- one = sharedDbEnvMap->erase(key);
- assert(one == 1);
-
- if(sharedDbEnvMap->size() == 0)
- {
- delete sharedDbEnvMap;
- sharedDbEnvMap = 0;
- }
-
- //
- // Keep lock to prevent somebody else to re-open this DbEnv
- // before it's closed.
- //
- delete this;
+ size_t one;
+ one = sharedDbEnvMap->erase(key);
+ assert(one == 1);
+
+ if(sharedDbEnvMap->size() == 0)
+ {
+ delete sharedDbEnvMap;
+ sharedDbEnvMap = 0;
+ }
+
+ //
+ // Keep lock to prevent somebody else to re-open this DbEnv
+ // before it's closed.
+ //
+ delete this;
}
}
Freeze::SharedDbEnv::SharedDbEnv(const std::string& envName,
- const Ice::CommunicatorPtr& communicator, DbEnv* env) :
+ const Ice::CommunicatorPtr& communicator, DbEnv* env) :
_env(env),
_envName(envName),
_communicator(communicator),
@@ -229,113 +229,113 @@ Freeze::SharedDbEnv::SharedDbEnv(const std::string& envName,
if(_env == 0)
{
- _envHolder.reset(new DbEnv(0));
- _env = _envHolder.get();
+ _envHolder.reset(new DbEnv(0));
+ _env = _envHolder.get();
- if(_trace >= 1)
- {
- Trace out(_communicator->getLogger(), "Freeze.DbEnv");
- out << "opening database environment \"" << envName << "\"";
- }
+ if(_trace >= 1)
+ {
+ Trace out(_communicator->getLogger(), "Freeze.DbEnv");
+ out << "opening database environment \"" << envName << "\"";
+ }
- string propertyPrefix = string("Freeze.DbEnv.") + envName;
-
- try
- {
- _env->set_errpfx(reinterpret_cast<char*>(this));
+ string propertyPrefix = string("Freeze.DbEnv.") + envName;
+
+ try
+ {
+ _env->set_errpfx(reinterpret_cast<char*>(this));
- _env->set_errcall(dbErrCallback);
+ _env->set_errcall(dbErrCallback);
#ifdef _WIN32
- //
- // Berkeley DB may use a different C++ runtime
- //
- _env->set_alloc(::malloc, ::realloc, ::free);
+ //
+ // Berkeley DB may use a different C++ runtime
+ //
+ _env->set_alloc(::malloc, ::realloc, ::free);
#endif
-
- //
- // Deadlock detection
- //
- _env->set_lk_detect(DB_LOCK_YOUNGEST);
-
- u_int32_t flags = DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN;
-
- if(properties->getPropertyAsInt(propertyPrefix + ".DbRecoverFatal") != 0)
- {
- flags |= DB_RECOVER_FATAL | DB_CREATE;
- }
- else
- {
- flags |= DB_RECOVER | DB_CREATE;
- }
-
- if(properties->getPropertyAsIntWithDefault(propertyPrefix + ".DbPrivate", 1) != 0)
- {
- flags |= DB_PRIVATE;
- }
-
- /*
-
- //
- // Does not seem to work reliably in 4.1.25
- //
-
- time_t timeStamp = properties->getPropertyAsIntWithDefault(propertyPrefix + ".TxTimestamp", 0);
-
- if(timeStamp != 0)
- {
- try
- {
- set_tx_timestamp(&timeStamp);
- }
- catch(const ::DbException& dx)
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
- }
- */
-
- //
- // Maybe we can deprecate this property since it can be set in the DB_CONFIG file
- //
- bool autoDelete = (properties->getPropertyAsIntWithDefault(
- propertyPrefix + ".OldLogsAutoDelete", 1) != 0);
-
- if(autoDelete)
- {
- _env->set_flags(DB_LOG_AUTOREMOVE, 1);
- }
-
- //
- // Threading
- //
- flags |= DB_THREAD;
-
- string dbHome = properties->getPropertyWithDefault(
- propertyPrefix + ".DbHome", envName);
-
- _env->open(dbHome.c_str(), flags, FREEZE_DB_MODE);
- }
- catch(const ::DbException& dx)
- {
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
- }
-
- //
- // Default checkpoint period is every 120 seconds
- //
- Int checkpointPeriod = properties->getPropertyAsIntWithDefault(
- propertyPrefix + ".CheckpointPeriod", 120);
- Int kbyte = properties->getPropertyAsIntWithDefault(propertyPrefix + ".PeriodicCheckpointMinSize", 0);
-
- if(checkpointPeriod > 0)
- {
- _thread = new CheckpointThread(*this, Time::seconds(checkpointPeriod), kbyte, _trace);
- }
+
+ //
+ // Deadlock detection
+ //
+ _env->set_lk_detect(DB_LOCK_YOUNGEST);
+
+ u_int32_t flags = DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN;
+
+ if(properties->getPropertyAsInt(propertyPrefix + ".DbRecoverFatal") != 0)
+ {
+ flags |= DB_RECOVER_FATAL | DB_CREATE;
+ }
+ else
+ {
+ flags |= DB_RECOVER | DB_CREATE;
+ }
+
+ if(properties->getPropertyAsIntWithDefault(propertyPrefix + ".DbPrivate", 1) != 0)
+ {
+ flags |= DB_PRIVATE;
+ }
+
+ /*
+
+ //
+ // Does not seem to work reliably in 4.1.25
+ //
+
+ time_t timeStamp = properties->getPropertyAsIntWithDefault(propertyPrefix + ".TxTimestamp", 0);
+
+ if(timeStamp != 0)
+ {
+ try
+ {
+ set_tx_timestamp(&timeStamp);
+ }
+ catch(const ::DbException& dx)
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+ }
+ */
+
+ //
+ // Maybe we can deprecate this property since it can be set in the DB_CONFIG file
+ //
+ bool autoDelete = (properties->getPropertyAsIntWithDefault(
+ propertyPrefix + ".OldLogsAutoDelete", 1) != 0);
+
+ if(autoDelete)
+ {
+ _env->set_flags(DB_LOG_AUTOREMOVE, 1);
+ }
+
+ //
+ // Threading
+ //
+ flags |= DB_THREAD;
+
+ string dbHome = properties->getPropertyWithDefault(
+ propertyPrefix + ".DbHome", envName);
+
+ _env->open(dbHome.c_str(), flags, FREEZE_DB_MODE);
+ }
+ catch(const ::DbException& dx)
+ {
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
+ }
+
+ //
+ // Default checkpoint period is every 120 seconds
+ //
+ Int checkpointPeriod = properties->getPropertyAsIntWithDefault(
+ propertyPrefix + ".CheckpointPeriod", 120);
+ Int kbyte = properties->getPropertyAsIntWithDefault(propertyPrefix + ".PeriodicCheckpointMinSize", 0);
+
+ if(checkpointPeriod > 0)
+ {
+ _thread = new CheckpointThread(*this, Time::seconds(checkpointPeriod), kbyte, _trace);
+ }
}
//
@@ -361,9 +361,9 @@ void
Freeze::CheckpointThread::terminate()
{
{
- Lock sync(*this);
- _done = true;
- notify();
+ Lock sync(*this);
+ _done = true;
+ notify();
}
getThreadControl().join();
@@ -375,33 +375,33 @@ Freeze::CheckpointThread::run()
{
for(;;)
{
- {
- Lock sync(*this);
- while(!_done && timedWait(_checkpointPeriod))
- {
- //
- // Loop
- //
- }
- if(_done)
- {
- return;
- }
- }
-
- try
- {
- if(_trace >= 2)
- {
- Trace out(_dbEnv.getCommunicator()->getLogger(), "Freeze.DbEnv");
- out << "checkpointing environment \"" << _dbEnv.getEnvName() << "\"";
- }
- _dbEnv.getEnv()->txn_checkpoint(_kbyte, 0, 0);
- }
- catch(const DbException& dx)
- {
- Warning out(_dbEnv.getCommunicator()->getLogger());
- out << "checkpoint on DbEnv \"" << _dbEnv.getEnvName() << "\" raised DbException: " << dx.what();
- }
+ {
+ Lock sync(*this);
+ while(!_done && timedWait(_checkpointPeriod))
+ {
+ //
+ // Loop
+ //
+ }
+ if(_done)
+ {
+ return;
+ }
+ }
+
+ try
+ {
+ if(_trace >= 2)
+ {
+ Trace out(_dbEnv.getCommunicator()->getLogger(), "Freeze.DbEnv");
+ out << "checkpointing environment \"" << _dbEnv.getEnvName() << "\"";
+ }
+ _dbEnv.getEnv()->txn_checkpoint(_kbyte, 0, 0);
+ }
+ catch(const DbException& dx)
+ {
+ Warning out(_dbEnv.getCommunicator()->getLogger());
+ out << "checkpoint on DbEnv \"" << _dbEnv.getEnvName() << "\" raised DbException: " << dx.what();
+ }
}
}
diff --git a/cpp/src/Freeze/TransactionHolder.cpp b/cpp/src/Freeze/TransactionHolder.cpp
index e10c402d10e..04d87729abb 100644
--- a/cpp/src/Freeze/TransactionHolder.cpp
+++ b/cpp/src/Freeze/TransactionHolder.cpp
@@ -16,7 +16,7 @@ Freeze::TransactionHolder::TransactionHolder(const ConnectionPtr& connection)
{
if(connection->currentTransaction() == 0)
{
- _transaction = connection->beginTransaction();
+ _transaction = connection->beginTransaction();
}
}
@@ -24,13 +24,13 @@ Freeze::TransactionHolder::~TransactionHolder()
{
try
{
- rollback();
+ rollback();
}
catch(...)
{
- //
- // Ignored to avoid crash during stack unwinding
- //
+ //
+ // Ignored to avoid crash during stack unwinding
+ //
}
}
@@ -39,16 +39,16 @@ Freeze::TransactionHolder::commit()
{
if(_transaction != 0)
{
- try
- {
- _transaction->commit();
- _transaction = 0;
- }
- catch(...)
- {
- _transaction = 0;
- throw;
- }
+ try
+ {
+ _transaction->commit();
+ _transaction = 0;
+ }
+ catch(...)
+ {
+ _transaction = 0;
+ throw;
+ }
}
}
@@ -57,15 +57,15 @@ Freeze::TransactionHolder::rollback()
{
if(_transaction != 0)
{
- try
- {
- _transaction->rollback();
- _transaction = 0;
- }
- catch(...)
- {
- _transaction = 0;
- throw;
- }
+ try
+ {
+ _transaction->rollback();
+ _transaction = 0;
+ }
+ catch(...)
+ {
+ _transaction = 0;
+ throw;
+ }
}
}
diff --git a/cpp/src/Freeze/TransactionI.cpp b/cpp/src/Freeze/TransactionI.cpp
index ae8c4c7e2e4..c9920c7bfc0 100644
--- a/cpp/src/Freeze/TransactionI.cpp
+++ b/cpp/src/Freeze/TransactionI.cpp
@@ -30,46 +30,46 @@ Freeze::TransactionI::commit()
long txnId = 0;
try
{
- _connection->closeAllIterators();
+ _connection->closeAllIterators();
- if(_txTrace >= 1)
- {
- txnId = (_txn->id() & 0x7FFFFFFF) + 0x80000000L;
- }
+ if(_txTrace >= 1)
+ {
+ txnId = (_txn->id() & 0x7FFFFFFF) + 0x80000000L;
+ }
- _txn->commit(0);
+ _txn->commit(0);
- if(_txTrace >= 1)
- {
- Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
- out << "committed transaction " << hex << txnId << dec;
- }
+ if(_txTrace >= 1)
+ {
+ Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
+ out << "committed transaction " << hex << txnId << dec;
+ }
}
catch(const ::DbDeadlockException& dx)
{
- if(_txTrace >= 1)
- {
- Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
- out << "failed to commit transaction " << hex << txnId << dec << ": " << dx.what();
- }
-
- cleanup();
- DeadlockException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ if(_txTrace >= 1)
+ {
+ Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
+ out << "failed to commit transaction " << hex << txnId << dec << ": " << dx.what();
+ }
+
+ cleanup();
+ DeadlockException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
catch(const ::DbException& dx)
{
- if(_txTrace >= 1)
- {
- Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
- out << "failed to commit transaction " << hex << txnId << dec << ": " << dx.what();
- }
-
- cleanup();
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ if(_txTrace >= 1)
+ {
+ Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
+ out << "failed to commit transaction " << hex << txnId << dec << ": " << dx.what();
+ }
+
+ cleanup();
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
cleanup();
}
@@ -82,46 +82,46 @@ Freeze::TransactionI::rollback()
long txnId = 0;
try
{
- _connection->closeAllIterators();
+ _connection->closeAllIterators();
- if(_txTrace >= 1)
- {
- txnId = (_txn->id() & 0x7FFFFFFF) + 0x80000000L;
- }
+ if(_txTrace >= 1)
+ {
+ txnId = (_txn->id() & 0x7FFFFFFF) + 0x80000000L;
+ }
- _txn->abort();
+ _txn->abort();
- if(_txTrace >= 1)
- {
- Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
- out << "rolled back transaction " << hex << txnId << dec;
- }
+ if(_txTrace >= 1)
+ {
+ Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
+ out << "rolled back transaction " << hex << txnId << dec;
+ }
}
catch(const ::DbDeadlockException& dx)
{
- if(_txTrace >= 1)
- {
- Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
- out << "failed to rollback transaction " << hex << txnId << dec << ": " << dx.what();
- }
-
- cleanup();
- DeadlockException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ if(_txTrace >= 1)
+ {
+ Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
+ out << "failed to rollback transaction " << hex << txnId << dec << ": " << dx.what();
+ }
+
+ cleanup();
+ DeadlockException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
catch(const ::DbException& dx)
{
- if(_txTrace >= 1)
- {
- Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
- out << "failed to rollback transaction " << hex << txnId << dec << ": " << dx.what();
- }
-
- cleanup();
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ if(_txTrace >= 1)
+ {
+ Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
+ out << "failed to rollback transaction " << hex << txnId << dec << ": " << dx.what();
+ }
+
+ cleanup();
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
cleanup();
}
@@ -133,26 +133,26 @@ Freeze::TransactionI::TransactionI(ConnectionI* connection) :
{
try
{
- _connection->dbEnv()->getEnv()->txn_begin(0, &_txn, 0);
-
- if(_txTrace >= 1)
- {
- long txnId = (_txn->id() & 0x7FFFFFFF) + 0x80000000L;
- Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
- out << "started transaction " << hex << txnId << dec;
- }
+ _connection->dbEnv()->getEnv()->txn_begin(0, &_txn, 0);
+
+ if(_txTrace >= 1)
+ {
+ long txnId = (_txn->id() & 0x7FFFFFFF) + 0x80000000L;
+ Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
+ out << "started transaction " << hex << txnId << dec;
+ }
}
catch(const ::DbException& dx)
{
- if(_txTrace >= 1)
- {
- Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
- out << "failed to start transaction: " << dx.what();
- }
-
- DatabaseException ex(__FILE__, __LINE__);
- ex.message = dx.what();
- throw ex;
+ if(_txTrace >= 1)
+ {
+ Trace out(_connection->communicator()->getLogger(), "Freeze.Map");
+ out << "failed to start transaction: " << dx.what();
+ }
+
+ DatabaseException ex(__FILE__, __LINE__);
+ ex.message = dx.what();
+ throw ex;
}
}
@@ -160,7 +160,7 @@ Freeze::TransactionI::~TransactionI()
{
if(_txn != 0)
{
- rollback();
+ rollback();
}
}
diff --git a/cpp/src/Freeze/TransactionI.h b/cpp/src/Freeze/TransactionI.h
index 275f8b429f4..72cfc852d16 100644
--- a/cpp/src/Freeze/TransactionI.h
+++ b/cpp/src/Freeze/TransactionI.h
@@ -36,7 +36,7 @@ public:
DbTxn*
dbTxn() const
{
- return _txn;
+ return _txn;
}
private:
diff --git a/cpp/src/Freeze/Util.cpp b/cpp/src/Freeze/Util.cpp
index c29f3845f9e..20782bfeca4 100644
--- a/cpp/src/Freeze/Util.cpp
+++ b/cpp/src/Freeze/Util.cpp
@@ -16,75 +16,75 @@ using namespace std;
void
Freeze::handleDbException(const DbException& dx,
- const char* file, int line)
+ const char* file, int line)
{
throw DatabaseException(file, line, dx.what());
}
void
Freeze::handleDbException(const DbException& dx,
- Key& key, Dbt& dbKey,
- const char* file, int line)
+ Key& key, Dbt& dbKey,
+ const char* file, int line)
{
bool bufferSmallException =
#if (DB_VERSION_MAJOR == 4) && (DB_VERSION_MINOR == 2)
- (dx.get_errno() == ENOMEM);
+ (dx.get_errno() == ENOMEM);
#else
(dx.get_errno() == DB_BUFFER_SMALL || dx.get_errno() == ENOMEM);
-#endif
-
+#endif
+
if(bufferSmallException && (dbKey.get_size() > dbKey.get_ulen()))
{
- //
- // Keep the old key size in case it's used as input
- //
- size_t oldKeySize = key.size();
+ //
+ // Keep the old key size in case it's used as input
+ //
+ size_t oldKeySize = key.size();
- key.resize(dbKey.get_size());
- initializeOutDbt(key, dbKey);
- dbKey.set_size(static_cast<u_int32_t>(oldKeySize));
+ key.resize(dbKey.get_size());
+ initializeOutDbt(key, dbKey);
+ dbKey.set_size(static_cast<u_int32_t>(oldKeySize));
}
else
{
- handleDbException(dx, file, line);
+ handleDbException(dx, file, line);
}
}
void
Freeze::handleDbException(const DbException& dx,
- Key& key, Dbt& dbKey,
- Value& value, Dbt& dbValue,
- const char* file, int line)
+ Key& key, Dbt& dbKey,
+ Value& value, Dbt& dbValue,
+ const char* file, int line)
{
bool bufferSmallException =
#if (DB_VERSION_MAJOR == 4) && (DB_VERSION_MINOR == 2)
- (dx.get_errno() == ENOMEM);
+ (dx.get_errno() == ENOMEM);
#else
(dx.get_errno() == DB_BUFFER_SMALL || dx.get_errno() == ENOMEM);
-#endif
+#endif
- bool resized = false;
+ bool resized = false;
if(bufferSmallException)
{
- if(dbKey.get_size() > dbKey.get_ulen())
- {
- size_t oldKeySize = key.size();
- key.resize(dbKey.get_size());
- initializeOutDbt(key, dbKey);
- dbKey.set_size(static_cast<u_int32_t>(oldKeySize));
- resized = true;
- }
-
- if(dbValue.get_size() > dbValue.get_ulen())
- {
- value.resize(dbValue.get_size());
- initializeOutDbt(value, dbValue);
- resized = true;
- }
+ if(dbKey.get_size() > dbKey.get_ulen())
+ {
+ size_t oldKeySize = key.size();
+ key.resize(dbKey.get_size());
+ initializeOutDbt(key, dbKey);
+ dbKey.set_size(static_cast<u_int32_t>(oldKeySize));
+ resized = true;
+ }
+
+ if(dbValue.get_size() > dbValue.get_ulen())
+ {
+ value.resize(dbValue.get_size());
+ initializeOutDbt(value, dbValue);
+ resized = true;
+ }
}
if(!resized)
{
- handleDbException(dx, file, line);
+ handleDbException(dx, file, line);
}
}
diff --git a/cpp/src/Freeze/Util.h b/cpp/src/Freeze/Util.h
index b41815f2c94..52582471517 100644
--- a/cpp/src/Freeze/Util.h
+++ b/cpp/src/Freeze/Util.h
@@ -61,11 +61,11 @@ handleDbException(const DbException&, const char*, int);
void
handleDbException(const DbException&, Key&, Dbt&,
- const char*, int);
+ const char*, int);
void
handleDbException(const DbException&, Key&, Dbt&, Value&, Dbt&,
- const char*, int);
+ const char*, int);
}
diff --git a/cpp/src/FreezeScript/Data.cpp b/cpp/src/FreezeScript/Data.cpp
index 3c4050f03ee..cc51a8a2d0e 100644
--- a/cpp/src/FreezeScript/Data.cpp
+++ b/cpp/src/FreezeScript/Data.cpp
@@ -2494,28 +2494,28 @@ FreezeScript::ObjectFactory::create(const string& id)
if(_factory)
{
- if(id == Ice::Object::ice_staticId())
- {
- result = new ObjectReader(_factory, _unit->builtin(Slice::Builtin::KindObject));
- }
- else
- {
- Slice::TypeList l = _unit->lookupTypeNoBuiltin(id);
- if(!l.empty())
- {
- Slice::ClassDeclPtr decl = Slice::ClassDeclPtr::dynamicCast(l.front());
- if(!decl)
- {
- _factory->getErrorReporter()->error("Slice definition for `" + id + "' is not a class");
- }
- Slice::ClassDefPtr def = decl->definition();
- if(!def)
- {
- _factory->getErrorReporter()->error("no class definition for `" + id + "'");
- }
- result = new ObjectReader(_factory, decl);
- }
- }
+ if(id == Ice::Object::ice_staticId())
+ {
+ result = new ObjectReader(_factory, _unit->builtin(Slice::Builtin::KindObject));
+ }
+ else
+ {
+ Slice::TypeList l = _unit->lookupTypeNoBuiltin(id);
+ if(!l.empty())
+ {
+ Slice::ClassDeclPtr decl = Slice::ClassDeclPtr::dynamicCast(l.front());
+ if(!decl)
+ {
+ _factory->getErrorReporter()->error("Slice definition for `" + id + "' is not a class");
+ }
+ Slice::ClassDefPtr def = decl->definition();
+ if(!def)
+ {
+ _factory->getErrorReporter()->error("no class definition for `" + id + "'");
+ }
+ result = new ObjectReader(_factory, decl);
+ }
+ }
}
return result;
diff --git a/cpp/src/FreezeScript/DumpDB.cpp b/cpp/src/FreezeScript/DumpDB.cpp
index de79afd89a3..dc08bfcbda9 100644
--- a/cpp/src/FreezeScript/DumpDB.cpp
+++ b/cpp/src/FreezeScript/DumpDB.cpp
@@ -54,7 +54,7 @@ class DescriptorHandler : public IceXML::Handler
public:
DescriptorHandler(const DataFactoryPtr&, const Slice::UnitPtr&, const ErrorReporterPtr&,
- const FreezeScript::ObjectFactoryPtr&);
+ const FreezeScript::ObjectFactoryPtr&);
virtual void startElement(const std::string&, const IceXML::Attributes&, int, int);
virtual void endElement(const std::string&, int, int);
@@ -108,13 +108,13 @@ printCatalogData(const string& dbName, const Freeze::CatalogData& data)
cout << dbName << ": ";
if(data.evictor)
{
- cout << "Evictor database" << endl;
+ cout << "Evictor database" << endl;
}
else
{
- cout << "Map database" << endl;
- cout << " key type = " << data.key << endl;
- cout << " value type = " << data.value << endl;
+ cout << "Map database" << endl;
+ cout << " key type = " << data.key << endl;
+ cout << " value type = " << data.value << endl;
}
}
@@ -159,98 +159,98 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
}
catch(const IceUtil::BadOptException& e)
{
- cerr << argv[0] << ": " << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": " << e.reason << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(opts.isSet("h"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(argv[0]);
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
if(opts.isSet("c"))
{
- if(args.empty())
- {
- cerr << argv[0] << ": no database environment specified." << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- else if(args.size() > 2)
- {
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- try
- {
- FreezeScript::CatalogDataMap catalog = FreezeScript::readCatalog(communicator, args[0]);
- if(args.size() == 1)
- {
- if(catalog.empty())
- {
- cout << "Catalog is empty." << endl;
- }
- else
- {
- cout << "Catalog contents:" << endl;
- for(FreezeScript::CatalogDataMap::const_iterator p = catalog.begin(); p != catalog.end(); ++p)
- {
- cout << endl;
- printCatalogData(p->first, p->second);
- }
- }
- }
- else
- {
- FreezeScript::CatalogDataMap::const_iterator p = catalog.find(args[1]);
- if(p == catalog.end())
- {
- cerr << argv[0] << ": database `" << args[1] << "' not found in environment `" << args[0] << "'."
- << endl;
- return EXIT_FAILURE;
- }
- else
- {
- printCatalogData(p->first, p->second);
- }
- }
- return EXIT_SUCCESS;
- }
- catch(const FreezeScript::FailureException& ex)
- {
- cerr << argv[0] << ": " << ex.reason() << endl;
- return EXIT_FAILURE;
- }
+ if(args.empty())
+ {
+ cerr << argv[0] << ": no database environment specified." << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ else if(args.size() > 2)
+ {
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ try
+ {
+ FreezeScript::CatalogDataMap catalog = FreezeScript::readCatalog(communicator, args[0]);
+ if(args.size() == 1)
+ {
+ if(catalog.empty())
+ {
+ cout << "Catalog is empty." << endl;
+ }
+ else
+ {
+ cout << "Catalog contents:" << endl;
+ for(FreezeScript::CatalogDataMap::const_iterator p = catalog.begin(); p != catalog.end(); ++p)
+ {
+ cout << endl;
+ printCatalogData(p->first, p->second);
+ }
+ }
+ }
+ else
+ {
+ FreezeScript::CatalogDataMap::const_iterator p = catalog.find(args[1]);
+ if(p == catalog.end())
+ {
+ cerr << argv[0] << ": database `" << args[1] << "' not found in environment `" << args[0] << "'."
+ << endl;
+ return EXIT_FAILURE;
+ }
+ else
+ {
+ printCatalogData(p->first, p->second);
+ }
+ }
+ return EXIT_SUCCESS;
+ }
+ catch(const FreezeScript::FailureException& ex)
+ {
+ cerr << argv[0] << ": " << ex.reason() << endl;
+ return EXIT_FAILURE;
+ }
}
if(opts.isSet("D"))
{
- vector<string> optargs = opts.argVec("D");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- cppArgs += " -D" + *i;
- }
+ vector<string> optargs = opts.argVec("D");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ cppArgs += " -D" + *i;
+ }
}
if(opts.isSet("U"))
{
- vector<string> optargs = opts.argVec("U");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- cppArgs += " -U" + *i;
- }
+ vector<string> optargs = opts.argVec("U");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ cppArgs += " -U" + *i;
+ }
}
if(opts.isSet("I"))
{
- vector<string> optargs = opts.argVec("I");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- cppArgs += " -I" + *i;
- }
+ vector<string> optargs = opts.argVec("I");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ cppArgs += " -I" + *i;
+ }
}
debug = opts.isSet("debug");
@@ -258,32 +258,32 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
if(opts.isSet("o"))
{
- outputFile = opts.optArg("o");
+ outputFile = opts.optArg("o");
}
if(opts.isSet("f"))
{
- inputFile = opts.optArg("f");
+ inputFile = opts.optArg("f");
}
if(opts.isSet("load"))
{
vector<string> optArgs = opts.argVec("load");
- for(vector<string>::const_iterator i = optArgs.begin(); i != optArgs.end(); ++i)
- {
- slice.push_back(*i);
- }
+ for(vector<string>::const_iterator i = optArgs.begin(); i != optArgs.end(); ++i)
+ {
+ slice.push_back(*i);
+ }
}
evictor = opts.isSet("e");
if(opts.isSet("key"))
{
- keyTypeName = opts.optArg("key");
+ keyTypeName = opts.optArg("key");
}
if(opts.isSet("value"))
{
- valueTypeName = opts.optArg("value");
+ valueTypeName = opts.optArg("value");
}
if(opts.isSet("select"))
{
- selectExpr = opts.optArg("select");
+ selectExpr = opts.optArg("select");
}
caseSensitive = opts.isSet("case-sensitive");
@@ -328,55 +328,55 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
string descriptors;
if(inputFile.empty())
{
- const string evictorKeyTypeName = "::Ice::Identity";
- const string evictorValueTypeName = "::Freeze::ObjectRecord";
-
- if((!keyTypeName.empty() && valueTypeName.empty()) || (keyTypeName.empty() && !valueTypeName.empty()))
- {
- cerr << argv[0] << ": a key type and a value type must be specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- else if(!evictor && keyTypeName.empty() && valueTypeName.empty())
- {
- try
- {
- FreezeScript::CatalogDataMap catalog = FreezeScript::readCatalog(communicator, dbEnvName);
- FreezeScript::CatalogDataMap::iterator p = catalog.find(dbName);
- if(p == catalog.end())
- {
- cerr << argv[0] << ": database `" << dbName << "' not found in catalog." << endl;
- cerr << "Current catalog databases:" << endl;
- for(p = catalog.begin(); p != catalog.end(); ++p)
- {
- cerr << " " << p->first << endl;
- }
- return EXIT_FAILURE;
- }
- else
- {
- if(p->second.evictor)
- {
- evictor = true;
- }
- else
- {
- keyTypeName = p->second.key;
- valueTypeName = p->second.value;
- }
- }
- }
- catch(const FreezeScript::FailureException& ex)
- {
- cerr << argv[0] << ": " << ex.reason() << endl;
- return EXIT_FAILURE;
- }
- }
+ const string evictorKeyTypeName = "::Ice::Identity";
+ const string evictorValueTypeName = "::Freeze::ObjectRecord";
+
+ if((!keyTypeName.empty() && valueTypeName.empty()) || (keyTypeName.empty() && !valueTypeName.empty()))
+ {
+ cerr << argv[0] << ": a key type and a value type must be specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ else if(!evictor && keyTypeName.empty() && valueTypeName.empty())
+ {
+ try
+ {
+ FreezeScript::CatalogDataMap catalog = FreezeScript::readCatalog(communicator, dbEnvName);
+ FreezeScript::CatalogDataMap::iterator p = catalog.find(dbName);
+ if(p == catalog.end())
+ {
+ cerr << argv[0] << ": database `" << dbName << "' not found in catalog." << endl;
+ cerr << "Current catalog databases:" << endl;
+ for(p = catalog.begin(); p != catalog.end(); ++p)
+ {
+ cerr << " " << p->first << endl;
+ }
+ return EXIT_FAILURE;
+ }
+ else
+ {
+ if(p->second.evictor)
+ {
+ evictor = true;
+ }
+ else
+ {
+ keyTypeName = p->second.key;
+ valueTypeName = p->second.value;
+ }
+ }
+ }
+ catch(const FreezeScript::FailureException& ex)
+ {
+ cerr << argv[0] << ": " << ex.reason() << endl;
+ return EXIT_FAILURE;
+ }
+ }
if(evictor)
{
- keyTypeName = evictorKeyTypeName;
- valueTypeName = evictorValueTypeName;
+ keyTypeName = evictorKeyTypeName;
+ valueTypeName = evictorValueTypeName;
}
Slice::TypePtr keyType, valueType;
@@ -744,7 +744,7 @@ FreezeScript::SliceVisitor::visitEnum(const Slice::EnumPtr& v)
//
FreezeScript::DescriptorHandler::DescriptorHandler(const DataFactoryPtr& factory, const Slice::UnitPtr& unit,
const ErrorReporterPtr& errorReporter,
- const FreezeScript::ObjectFactoryPtr& objectFactory) :
+ const FreezeScript::ObjectFactoryPtr& objectFactory) :
_factory(factory), _unit(unit), _errorReporter(errorReporter), _objectFactory(objectFactory)
{
}
diff --git a/cpp/src/FreezeScript/DumpDescriptors.cpp b/cpp/src/FreezeScript/DumpDescriptors.cpp
index fb947a16e47..8b2a15300cc 100644
--- a/cpp/src/FreezeScript/DumpDescriptors.cpp
+++ b/cpp/src/FreezeScript/DumpDescriptors.cpp
@@ -1239,7 +1239,7 @@ FreezeScript::RecordDescriptor::RecordDescriptor(const DescriptorPtr& parent, in
const ErrorReporterPtr& errorReporter,
const IceXML::Attributes& attributes,
const Slice::UnitPtr& unit,
- const FreezeScript::ObjectFactoryPtr& objectFactory) :
+ const FreezeScript::ObjectFactoryPtr& objectFactory) :
Descriptor(parent, line, factory, errorReporter),
ExecutableContainerDescriptor(parent, line, factory, errorReporter, attributes, "record"),
_unit(unit),
@@ -1322,7 +1322,7 @@ FreezeScript::RecordDescriptor::execute(const SymbolTablePtr& sym, ExecuteInfo*
{
dbc->close();
}
- _objectFactory->deactivate();
+ _objectFactory->deactivate();
throw;
}
@@ -1870,16 +1870,16 @@ FreezeScript::DumpVisitor::visitObject(const ObjectRefPtr& data)
ObjectDataPtr value = data->getValue();
if(value)
{
- set<const ObjectData*>::iterator p = _objectHistory.find(value.get());
- if(p == _objectHistory.end())
- {
- _objectHistory.insert(value.get());
- DataMemberMap& members = value->getMembers();
- for(DataMemberMap::iterator q = members.begin(); q != members.end(); ++q)
- {
- q->second->visit(*this);
- }
- }
+ set<const ObjectData*>::iterator p = _objectHistory.find(value.get());
+ if(p == _objectHistory.end())
+ {
+ _objectHistory.insert(value.get());
+ DataMemberMap& members = value->getMembers();
+ for(DataMemberMap::iterator q = members.begin(); q != members.end(); ++q)
+ {
+ q->second->visit(*this);
+ }
+ }
}
}
}
diff --git a/cpp/src/FreezeScript/DumpDescriptors.h b/cpp/src/FreezeScript/DumpDescriptors.h
index 4f8daf65b9c..f915c08ba1f 100644
--- a/cpp/src/FreezeScript/DumpDescriptors.h
+++ b/cpp/src/FreezeScript/DumpDescriptors.h
@@ -247,7 +247,7 @@ public:
RecordDescriptor(const DescriptorPtr&, int, const DataFactoryPtr&, const ErrorReporterPtr&,
const IceXML::Attributes&, const Slice::UnitPtr&,
- const FreezeScript::ObjectFactoryPtr&);
+ const FreezeScript::ObjectFactoryPtr&);
virtual void execute(const SymbolTablePtr&, ExecuteInfo*);
diff --git a/cpp/src/FreezeScript/Functions.cpp b/cpp/src/FreezeScript/Functions.cpp
index b96f237b3d0..4f38c91f935 100644
--- a/cpp/src/FreezeScript/Functions.cpp
+++ b/cpp/src/FreezeScript/Functions.cpp
@@ -15,8 +15,8 @@ using namespace std;
bool
FreezeScript::invokeGlobalFunction(const Ice::CommunicatorPtr& communicator, const string& name, const DataList& args,
- DataPtr& result, const DataFactoryPtr& factory,
- const ErrorReporterPtr& errorReporter)
+ DataPtr& result, const DataFactoryPtr& factory,
+ const ErrorReporterPtr& errorReporter)
{
//
// Global function.
diff --git a/cpp/src/FreezeScript/Functions.h b/cpp/src/FreezeScript/Functions.h
index b0a4b5eb441..0b5fff2b21b 100644
--- a/cpp/src/FreezeScript/Functions.h
+++ b/cpp/src/FreezeScript/Functions.h
@@ -16,7 +16,7 @@ namespace FreezeScript
{
bool invokeGlobalFunction(const Ice::CommunicatorPtr&, const std::string&, const DataList&, DataPtr&,
- const DataFactoryPtr&, const ErrorReporterPtr&);
+ const DataFactoryPtr&, const ErrorReporterPtr&);
bool invokeMemberFunction(const std::string&, const DataPtr&, const DataList&, DataPtr&, const DataFactoryPtr&,
const ErrorReporterPtr&);
diff --git a/cpp/src/FreezeScript/TransformAnalyzer.cpp b/cpp/src/FreezeScript/TransformAnalyzer.cpp
index fc9f6be8b66..4095b87007c 100644
--- a/cpp/src/FreezeScript/TransformAnalyzer.cpp
+++ b/cpp/src/FreezeScript/TransformAnalyzer.cpp
@@ -90,46 +90,46 @@ FreezeScript::AnalyzeTransformVisitor::AnalyzeTransformVisitor(XMLOutput& out, c
void
FreezeScript::AnalyzeTransformVisitor::addDatabase(const string& name, const TypePtr& oldKey, const TypePtr& newKey,
- const TypePtr& oldValue, const TypePtr& newValue)
+ const TypePtr& oldValue, const TypePtr& newValue)
{
_out << "\n";
_out << se("database");
if(!name.empty())
{
- _out << attr("name", name);
+ _out << attr("name", name);
}
string oldKeyName = oldKey ? typeToString(oldKey) : string("UNKNOWN");
string newKeyName = newKey ? typeToString(newKey) : string("UNKNOWN");
if(oldKeyName == newKeyName)
{
- _out << attr("key", oldKeyName);
+ _out << attr("key", oldKeyName);
}
else
{
- _out << attr("key", oldKeyName + "," + newKeyName);
+ _out << attr("key", oldKeyName + "," + newKeyName);
}
string oldValueName = oldValue ? typeToString(oldValue) : string("UNKNOWN");
string newValueName = newValue ? typeToString(newValue) : string("UNKNOWN");
if(oldValueName == newValueName)
{
- _out << attr("value", oldValueName);
+ _out << attr("value", oldValueName);
}
else
{
- _out << attr("value", oldValueName + "," + newValueName);
+ _out << attr("value", oldValueName + "," + newValueName);
}
_out << se("record");
if(oldKey && newKey)
{
- compareTypes("database key", oldKey, newKey);
+ compareTypes("database key", oldKey, newKey);
}
if(oldValue && newValue)
{
- compareTypes("database value", oldValue, newValue);
+ compareTypes("database value", oldValue, newValue);
}
_out << ee;
@@ -1130,7 +1130,7 @@ FreezeScript::AnalyzeInitVisitor::typeChange(const TypePtr& t, const string& sco
FreezeScript::TransformAnalyzer::TransformAnalyzer(const UnitPtr& oldUnit, const UnitPtr& newUnit,
bool ignoreTypeChanges, ostream& os, vector<string>& missingTypes,
- vector<string>& errors) :
+ vector<string>& errors) :
_old(oldUnit), _new(newUnit), _out(os),
_visitor(new AnalyzeTransformVisitor(_out, newUnit, ignoreTypeChanges, missingTypes, errors))
{
@@ -1144,7 +1144,7 @@ FreezeScript::TransformAnalyzer::~TransformAnalyzer()
void
FreezeScript::TransformAnalyzer::addDatabase(const string& name, const TypePtr& oldKey, const TypePtr& newKey,
- const TypePtr& oldValue, const TypePtr& newValue)
+ const TypePtr& oldValue, const TypePtr& newValue)
{
_visitor->addDatabase(name, oldKey, newKey, oldValue, newValue);
}
diff --git a/cpp/src/FreezeScript/TransformAnalyzer.h b/cpp/src/FreezeScript/TransformAnalyzer.h
index 9af9c06126a..73539de5d67 100644
--- a/cpp/src/FreezeScript/TransformAnalyzer.h
+++ b/cpp/src/FreezeScript/TransformAnalyzer.h
@@ -24,11 +24,11 @@ class TransformAnalyzer
public:
TransformAnalyzer(const Slice::UnitPtr&, const Slice::UnitPtr&, bool, std::ostream&, std::vector<std::string>&,
- std::vector<std::string>&);
+ std::vector<std::string>&);
~TransformAnalyzer();
void addDatabase(const std::string&, const Slice::TypePtr&, const Slice::TypePtr&, const Slice::TypePtr&,
- const Slice::TypePtr&);
+ const Slice::TypePtr&);
void finish();
private:
diff --git a/cpp/src/FreezeScript/Transformer.cpp b/cpp/src/FreezeScript/Transformer.cpp
index 5b6926c75cd..148d3867f68 100644
--- a/cpp/src/FreezeScript/Transformer.cpp
+++ b/cpp/src/FreezeScript/Transformer.cpp
@@ -1911,7 +1911,7 @@ FreezeScript::RecordDescriptor::execute(const SymbolTablePtr& sym)
Ice::ByteSeq outKeyBytes, outValueBytes;
transformRecord(inKeyBytes, inValueBytes, outKeyBytes, outValueBytes);
Dbt dbNewKey(&outKeyBytes[0], static_cast<unsigned>(outKeyBytes.size())),
- dbNewValue(&outValueBytes[0], static_cast<unsigned>(outValueBytes.size()));
+ dbNewValue(&outValueBytes[0], static_cast<unsigned>(outValueBytes.size()));
if(_info->newDb->put(_info->newDbTxn, &dbNewKey, &dbNewValue, DB_NOOVERWRITE) == DB_KEYEXIST)
{
_info->errorReporter->error("duplicate key encountered");
@@ -1941,7 +1941,7 @@ FreezeScript::RecordDescriptor::execute(const SymbolTablePtr& sym)
{
dbc->close();
}
- _info->objectFactory->deactivate();
+ _info->objectFactory->deactivate();
throw;
}
@@ -2051,7 +2051,7 @@ FreezeScript::DatabaseDescriptor::DatabaseDescriptor(const DescriptorPtr& parent
p = attributes.find("name");
if(p != attributes.end())
{
- _name = p->second;
+ _name = p->second;
}
p = attributes.find("key");
@@ -2077,13 +2077,13 @@ FreezeScript::DatabaseDescriptor::DatabaseDescriptor(const DescriptorPtr& parent
}
if(pos == string::npos)
{
- _oldKeyName = keyTypes;
- _newKeyName = keyTypes;
+ _oldKeyName = keyTypes;
+ _newKeyName = keyTypes;
}
else
{
- _oldKeyName = keyTypes.substr(0, pos);
- _newKeyName = keyTypes.substr(pos + 1);
+ _oldKeyName = keyTypes.substr(0, pos);
+ _newKeyName = keyTypes.substr(pos + 1);
}
pos = valueTypes.find(',');
@@ -2093,13 +2093,13 @@ FreezeScript::DatabaseDescriptor::DatabaseDescriptor(const DescriptorPtr& parent
}
if(pos == string::npos)
{
- _oldValueName = valueTypes;
- _newValueName = valueTypes;
+ _oldValueName = valueTypes;
+ _newValueName = valueTypes;
}
else
{
- _oldValueName = valueTypes.substr(0, pos);
- _newValueName = valueTypes.substr(pos + 1);
+ _oldValueName = valueTypes.substr(0, pos);
+ _newValueName = valueTypes.substr(pos + 1);
}
}
@@ -2136,12 +2136,12 @@ FreezeScript::DatabaseDescriptor::execute(const SymbolTablePtr& st)
if(_info->connection != 0)
{
- Freeze::Catalog catalog(_info->connection, Freeze::catalogName());
- Freeze::CatalogData catalogData;
- catalogData.evictor = false;
- catalogData.key = _info->newKeyType->typeId();
- catalogData.value = _info->newValueType->typeId();
- catalog.put(Freeze::Catalog::value_type(_info->newDbName, catalogData));
+ Freeze::Catalog catalog(_info->connection, Freeze::catalogName());
+ Freeze::CatalogData catalogData;
+ catalogData.evictor = false;
+ catalogData.key = _info->newKeyType->typeId();
+ catalogData.value = _info->newValueType->typeId();
+ catalog.put(Freeze::Catalog::value_type(_info->newDbName, catalogData));
}
//
@@ -2182,24 +2182,24 @@ FreezeScript::TransformDBDescriptor::addChild(const DescriptorPtr& child)
if(db)
{
- string name = db->name();
- map<string, DatabaseDescriptorPtr>::iterator p = _databases.find(name);
- if(p != _databases.end())
- {
- if(name.empty())
- {
- _info->errorReporter->error("duplicate <database> element");
- }
- else
- {
- _info->errorReporter->error(string("duplicate <database> element for ") + name);
- }
- }
- else
- {
- _databases[name] = db;
- _children.push_back(db);
- }
+ string name = db->name();
+ map<string, DatabaseDescriptorPtr>::iterator p = _databases.find(name);
+ if(p != _databases.end())
+ {
+ if(name.empty())
+ {
+ _info->errorReporter->error("duplicate <database> element");
+ }
+ else
+ {
+ _info->errorReporter->error(string("duplicate <database> element for ") + name);
+ }
+ }
+ else
+ {
+ _databases[name] = db;
+ _children.push_back(db);
+ }
}
else if(transform)
{
@@ -2243,7 +2243,7 @@ FreezeScript::TransformDBDescriptor::validate()
if(_databases.empty())
{
- _info->errorReporter->error("no <database> element defined");
+ _info->errorReporter->error("no <database> element defined");
}
for(vector<DescriptorPtr>::iterator p = _children.begin(); p != _children.end(); ++p)
@@ -2258,12 +2258,12 @@ FreezeScript::TransformDBDescriptor::execute(const SymbolTablePtr& sym)
map<string, DatabaseDescriptorPtr>::iterator p = _databases.find(_info->newDbName);
if(p == _databases.end())
{
- p = _databases.find("");
+ p = _databases.find("");
}
if(p == _databases.end())
{
- _info->errorReporter->error("no <database> element found for `" + _info->newDbName + "'");
+ _info->errorReporter->error("no <database> element found for `" + _info->newDbName + "'");
}
p->second->execute(sym);
@@ -3000,11 +3000,11 @@ FreezeScript::assignOrTransform(const DataPtr& dest, const DataPtr& src, bool co
void
FreezeScript::transformDatabase(const Ice::CommunicatorPtr& communicator,
- const FreezeScript::ObjectFactoryPtr& objectFactory,
+ const FreezeScript::ObjectFactoryPtr& objectFactory,
const Slice::UnitPtr& oldUnit, const Slice::UnitPtr& newUnit,
Db* oldDb, Db* newDb, DbTxn* newDbTxn, const Freeze::ConnectionPtr& connection,
- const string& newDbName, const string& facetName, bool purgeObjects, ostream& errors,
- bool suppress, istream& is)
+ const string& newDbName, const string& facetName, bool purgeObjects, ostream& errors,
+ bool suppress, istream& is)
{
TransformInfoIPtr info = new TransformInfoI;
diff --git a/cpp/src/FreezeScript/Transformer.h b/cpp/src/FreezeScript/Transformer.h
index 3afc6b507f8..5f856507d78 100644
--- a/cpp/src/FreezeScript/Transformer.h
+++ b/cpp/src/FreezeScript/Transformer.h
@@ -23,10 +23,10 @@ namespace FreezeScript
void
transformDatabase(const Ice::CommunicatorPtr&,
- const FreezeScript::ObjectFactoryPtr& objectFactory,
- const Slice::UnitPtr&, const Slice::UnitPtr&,
+ const FreezeScript::ObjectFactoryPtr& objectFactory,
+ const Slice::UnitPtr&, const Slice::UnitPtr&,
Db*, Db*, DbTxn*, const Freeze::ConnectionPtr&, const std::string&, const std::string&, bool,
- std::ostream&, bool, std::istream&);
+ std::ostream&, bool, std::istream&);
} // End of namespace FreezeScript
diff --git a/cpp/src/FreezeScript/Util.cpp b/cpp/src/FreezeScript/Util.cpp
index 49585d72520..b8f5c17cfc8 100644
--- a/cpp/src/FreezeScript/Util.cpp
+++ b/cpp/src/FreezeScript/Util.cpp
@@ -218,36 +218,36 @@ FreezeScript::readCatalog(const Ice::CommunicatorPtr& communicator, const string
try
{
#ifdef _WIN32
- //
- // Berkeley DB may use a different C++ runtime.
- //
- dbEnv.set_alloc(::malloc, ::realloc, ::free);
+ //
+ // Berkeley DB may use a different C++ runtime.
+ //
+ dbEnv.set_alloc(::malloc, ::realloc, ::free);
#endif
- //
- // Open the database environment.
- //
- {
- u_int32_t flags = DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_CREATE | DB_THREAD | DB_RECOVER;
- dbEnv.open(dbEnvName.c_str(), flags, mode);
- }
+ //
+ // Open the database environment.
+ //
+ {
+ u_int32_t flags = DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_CREATE | DB_THREAD | DB_RECOVER;
+ dbEnv.open(dbEnvName.c_str(), flags, mode);
+ }
- Freeze::ConnectionPtr connection = Freeze::createConnection(communicator, dbEnvName, dbEnv);
- Freeze::Catalog catalog(connection, Freeze::catalogName());
- for(Freeze::Catalog::const_iterator p = catalog.begin(); p != catalog.end(); ++p)
- {
- result.insert(make_pair(p->first, p->second));
- }
+ Freeze::ConnectionPtr connection = Freeze::createConnection(communicator, dbEnvName, dbEnv);
+ Freeze::Catalog catalog(connection, Freeze::catalogName());
+ for(Freeze::Catalog::const_iterator p = catalog.begin(); p != catalog.end(); ++p)
+ {
+ result.insert(make_pair(p->first, p->second));
+ }
}
catch(const DbException& ex)
{
- dbEnv.close(0);
- throw FailureException(__FILE__, __LINE__, string("database error: ") + ex.what());
+ dbEnv.close(0);
+ throw FailureException(__FILE__, __LINE__, string("database error: ") + ex.what());
}
catch(...)
{
- dbEnv.close(0);
- throw FailureException(__FILE__, __LINE__, "unknown exception");
+ dbEnv.close(0);
+ throw FailureException(__FILE__, __LINE__, "unknown exception");
}
dbEnv.close(0);
diff --git a/cpp/src/FreezeScript/transformdb.cpp b/cpp/src/FreezeScript/transformdb.cpp
index 8f17b6e8d37..b3a5a6adec4 100644
--- a/cpp/src/FreezeScript/transformdb.cpp
+++ b/cpp/src/FreezeScript/transformdb.cpp
@@ -96,21 +96,21 @@ findType(const Slice::UnitPtr& u, const string& type)
string t;
if(type == "::Ice::Object")
{
- t = "Object";
+ t = "Object";
}
else if(type == "::Ice::Object*")
{
- t = "Object*";
+ t = "Object*";
}
else
{
- t = type;
+ t = type;
}
l = u->lookupType(t, false);
if(l.empty())
{
- return 0;
+ return 0;
}
return l.front();
@@ -118,97 +118,97 @@ findType(const Slice::UnitPtr& u, const string& type)
static void
transformDb(bool evictor, const Ice::CommunicatorPtr& communicator,
- const FreezeScript::ObjectFactoryPtr& objectFactory,
- DbEnv& dbEnv, DbEnv& dbEnvNew, const string& dbName,
- const Freeze::ConnectionPtr& connectionNew, vector<Db*>& dbs,
- const Slice::UnitPtr& oldUnit, const Slice::UnitPtr& newUnit,
- DbTxn* txnNew, bool purgeObjects, bool suppress, string descriptors)
+ const FreezeScript::ObjectFactoryPtr& objectFactory,
+ DbEnv& dbEnv, DbEnv& dbEnvNew, const string& dbName,
+ const Freeze::ConnectionPtr& connectionNew, vector<Db*>& dbs,
+ const Slice::UnitPtr& oldUnit, const Slice::UnitPtr& newUnit,
+ DbTxn* txnNew, bool purgeObjects, bool suppress, string descriptors)
{
if(evictor)
{
- //
- // The evictor database file contains multiple databases. We must first
- // determine the names of those databases, ignoring any whose names
- // begin with "$index:". Each database represents a separate facet, with
- // the facet name used as the database name. The database named "$default"
- // represents the main object.
- //
- vector<string> dbNames;
- {
- Db db(&dbEnv, 0);
- db.open(0, dbName.c_str(), 0, DB_UNKNOWN, DB_RDONLY, 0);
- Dbt dbKey, dbValue;
- dbKey.set_flags(DB_DBT_MALLOC);
- dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
-
- Dbc* dbc = 0;
- db.cursor(0, &dbc, 0);
-
- while(dbc->get(&dbKey, &dbValue, DB_NEXT) == 0)
- {
- string s(static_cast<char*>(dbKey.get_data()), dbKey.get_size());
- if(s.find("$index:") != 0)
- {
- dbNames.push_back(s);
- }
- free(dbKey.get_data());
- }
-
- dbc->close();
- db.close(0);
- }
-
- //
- // Transform each database. We must delay closing the new databases
- // until after the transaction is committed or aborted.
- //
- for(vector<string>::iterator p = dbNames.begin(); p != dbNames.end(); ++p)
- {
- string name = p->c_str();
-
- Db db(&dbEnv, 0);
- db.open(0, dbName.c_str(), name.c_str(), DB_BTREE, DB_RDONLY, FREEZE_SCRIPT_DB_MODE);
-
- Db* dbNew = new Db(&dbEnvNew, 0);
- dbs.push_back(dbNew);
- dbNew->open(txnNew, dbName.c_str(), name.c_str(), DB_BTREE, DB_CREATE | DB_EXCL, FREEZE_SCRIPT_DB_MODE);
-
- //
- // Execute the transformation descriptors.
- //
- istringstream istr(descriptors);
- string facet = (name == "$default" ? string("") : name);
- FreezeScript::transformDatabase(communicator, objectFactory, oldUnit, newUnit, &db, dbNew, txnNew, 0,
- dbName, facet, purgeObjects, cerr, suppress, istr);
-
- db.close(0);
- }
-
- Freeze::Catalog catalogNew(connectionNew, Freeze::catalogName());
- Freeze::CatalogData catalogData;
- catalogData.evictor = true;
- catalogNew.put(Freeze::Catalog::value_type(dbName, catalogData));
+ //
+ // The evictor database file contains multiple databases. We must first
+ // determine the names of those databases, ignoring any whose names
+ // begin with "$index:". Each database represents a separate facet, with
+ // the facet name used as the database name. The database named "$default"
+ // represents the main object.
+ //
+ vector<string> dbNames;
+ {
+ Db db(&dbEnv, 0);
+ db.open(0, dbName.c_str(), 0, DB_UNKNOWN, DB_RDONLY, 0);
+ Dbt dbKey, dbValue;
+ dbKey.set_flags(DB_DBT_MALLOC);
+ dbValue.set_flags(DB_DBT_USERMEM | DB_DBT_PARTIAL);
+
+ Dbc* dbc = 0;
+ db.cursor(0, &dbc, 0);
+
+ while(dbc->get(&dbKey, &dbValue, DB_NEXT) == 0)
+ {
+ string s(static_cast<char*>(dbKey.get_data()), dbKey.get_size());
+ if(s.find("$index:") != 0)
+ {
+ dbNames.push_back(s);
+ }
+ free(dbKey.get_data());
+ }
+
+ dbc->close();
+ db.close(0);
+ }
+
+ //
+ // Transform each database. We must delay closing the new databases
+ // until after the transaction is committed or aborted.
+ //
+ for(vector<string>::iterator p = dbNames.begin(); p != dbNames.end(); ++p)
+ {
+ string name = p->c_str();
+
+ Db db(&dbEnv, 0);
+ db.open(0, dbName.c_str(), name.c_str(), DB_BTREE, DB_RDONLY, FREEZE_SCRIPT_DB_MODE);
+
+ Db* dbNew = new Db(&dbEnvNew, 0);
+ dbs.push_back(dbNew);
+ dbNew->open(txnNew, dbName.c_str(), name.c_str(), DB_BTREE, DB_CREATE | DB_EXCL, FREEZE_SCRIPT_DB_MODE);
+
+ //
+ // Execute the transformation descriptors.
+ //
+ istringstream istr(descriptors);
+ string facet = (name == "$default" ? string("") : name);
+ FreezeScript::transformDatabase(communicator, objectFactory, oldUnit, newUnit, &db, dbNew, txnNew, 0,
+ dbName, facet, purgeObjects, cerr, suppress, istr);
+
+ db.close(0);
+ }
+
+ Freeze::Catalog catalogNew(connectionNew, Freeze::catalogName());
+ Freeze::CatalogData catalogData;
+ catalogData.evictor = true;
+ catalogNew.put(Freeze::Catalog::value_type(dbName, catalogData));
}
else
{
- //
- // Transform a map database.
- //
- Db db(&dbEnv, 0);
- db.open(0, dbName.c_str(), 0, DB_BTREE, DB_RDONLY, FREEZE_SCRIPT_DB_MODE);
-
- Db* dbNew = new Db(&dbEnvNew, 0);
- dbs.push_back(dbNew);
- dbNew->open(txnNew, dbName.c_str(), 0, DB_BTREE, DB_CREATE | DB_EXCL, FREEZE_SCRIPT_DB_MODE);
-
- //
- // Execute the transformation descriptors.
- //
- istringstream istr(descriptors);
- FreezeScript::transformDatabase(communicator, objectFactory, oldUnit, newUnit, &db, dbNew, txnNew,
- connectionNew, dbName, "", purgeObjects, cerr, suppress, istr);
-
- db.close(0);
+ //
+ // Transform a map database.
+ //
+ Db db(&dbEnv, 0);
+ db.open(0, dbName.c_str(), 0, DB_BTREE, DB_RDONLY, FREEZE_SCRIPT_DB_MODE);
+
+ Db* dbNew = new Db(&dbEnvNew, 0);
+ dbs.push_back(dbNew);
+ dbNew->open(txnNew, dbName.c_str(), 0, DB_BTREE, DB_CREATE | DB_EXCL, FREEZE_SCRIPT_DB_MODE);
+
+ //
+ // Execute the transformation descriptors.
+ //
+ istringstream istr(descriptors);
+ FreezeScript::transformDatabase(communicator, objectFactory, oldUnit, newUnit, &db, dbNew, txnNew,
+ connectionNew, dbName, "", purgeObjects, cerr, suppress, istr);
+
+ db.close(0);
}
}
@@ -263,44 +263,44 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
}
catch(const IceUtil::BadOptException& e)
{
- cerr << argv[0] << ": " << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": " << e.reason << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(argv[0]);
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
if(opts.isSet("D"))
{
- vector<string> optargs = opts.argVec("D");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- oldCppArgs += " -D" + *i;
- newCppArgs += " -D" + *i;
- }
+ vector<string> optargs = opts.argVec("D");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ oldCppArgs += " -D" + *i;
+ newCppArgs += " -D" + *i;
+ }
}
if(opts.isSet("U"))
{
- vector<string> optargs = opts.argVec("U");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- oldCppArgs += " -U" + *i;
- newCppArgs += " -U" + *i;
- }
+ vector<string> optargs = opts.argVec("U");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ oldCppArgs += " -U" + *i;
+ newCppArgs += " -U" + *i;
+ }
}
debug = opts.isSet("debug");
if(opts.isSet("o"))
{
- outputFile = opts.optArg("o");
+ outputFile = opts.optArg("o");
}
ignoreTypeChanges = opts.isSet("i");
purgeObjects = opts.isSet("p");
@@ -308,102 +308,102 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
suppress = opts.isSet("w");
if(opts.isSet("f"))
{
- inputFile = opts.optArg("f");
+ inputFile = opts.optArg("f");
}
if(opts.isSet("include-old"))
{
- vector<string> optargs = opts.argVec("include-old");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- oldCppArgs += " -I" + *i;
- }
+ vector<string> optargs = opts.argVec("include-old");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ oldCppArgs += " -I" + *i;
+ }
}
if(opts.isSet("include-new"))
{
- vector<string> optargs = opts.argVec("include-new");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- newCppArgs += " -I" + *i;
- }
+ vector<string> optargs = opts.argVec("include-new");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ newCppArgs += " -I" + *i;
+ }
}
if(opts.isSet("old"))
{
- vector<string> optargs = opts.argVec("old");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- oldSlice.push_back(*i);
- }
+ vector<string> optargs = opts.argVec("old");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ oldSlice.push_back(*i);
+ }
}
if(opts.isSet("new"))
{
- vector<string> optargs = opts.argVec("new");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- newSlice.push_back(*i);
- }
+ vector<string> optargs = opts.argVec("new");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ newSlice.push_back(*i);
+ }
}
evictor = opts.isSet("e");
if(opts.isSet("key"))
{
- keyTypeNames = opts.optArg("key");
+ keyTypeNames = opts.optArg("key");
}
if(opts.isSet("value"))
{
- valueTypeNames = opts.optArg("value");
+ valueTypeNames = opts.optArg("value");
}
caseSensitive = opts.isSet("case-sensitive");
if(outputFile.empty())
{
- if(args.size() == 2)
- {
- allDb = true;
- }
- else if(args.size() != 3)
- {
- usage(argv[0]);
- return EXIT_FAILURE;
- }
+ if(args.size() == 2)
+ {
+ allDb = true;
+ }
+ else if(args.size() != 3)
+ {
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
}
else
{
- if(args.size() == 1)
- {
- allDb = true;
- }
- else if(args.size() != 0)
- {
- usage(argv[0]);
- return EXIT_FAILURE;
- }
+ if(args.size() == 1)
+ {
+ allDb = true;
+ }
+ else if(args.size() != 0)
+ {
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
}
if(allDb && (!keyTypeNames.empty() || !valueTypeNames.empty()))
{
- usage(argv[0]);
- return EXIT_FAILURE;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(inputFile.empty() && !allDb && !evictor && (keyTypeNames.empty() || valueTypeNames.empty()))
{
- usage(argv[0]);
- return EXIT_FAILURE;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(args.size() > 0)
{
- dbEnvName = args[0];
+ dbEnvName = args[0];
}
if(args.size() > 1)
{
- if(allDb)
- {
- dbEnvNameNew = args[1];
- }
- else
- {
- dbName = args[1];
- }
+ if(allDb)
+ {
+ dbEnvNameNew = args[1];
+ }
+ else
+ {
+ dbName = args[1];
+ }
}
if(args.size() > 2)
{
@@ -436,20 +436,20 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
FreezeScript::CatalogDataMap catalog;
if(allDb)
{
- try
- {
- catalog = FreezeScript::readCatalog(communicator, dbEnvName);
- }
- catch(const FreezeScript::FailureException& ex)
- {
- cerr << argv[0] << ": " << ex.reason() << endl;
- return EXIT_FAILURE;
- }
- if(catalog.empty())
- {
- cerr << argv[0] << ": no databases in environment `" << dbEnvName << "'" << endl;
- return EXIT_FAILURE;
- }
+ try
+ {
+ catalog = FreezeScript::readCatalog(communicator, dbEnvName);
+ }
+ catch(const FreezeScript::FailureException& ex)
+ {
+ cerr << argv[0] << ": " << ex.reason() << endl;
+ return EXIT_FAILURE;
+ }
+ if(catalog.empty())
+ {
+ cerr << argv[0] << ": no databases in environment `" << dbEnvName << "'" << endl;
+ return EXIT_FAILURE;
+ }
}
//
@@ -463,166 +463,166 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
vector<string> missingTypes;
vector<string> analyzeErrors;
- FreezeScript::TransformAnalyzer analyzer(oldUnit, newUnit, ignoreTypeChanges, out, missingTypes, analyzeErrors);
-
- const string evictorKeyName = "::Ice::Identity";
- const string evictorValueName = "::Freeze::ObjectRecord";
-
- if(allDb)
- {
- //
- // Add a <database> element for each database in the catalog.
- //
- for(FreezeScript::CatalogDataMap::iterator p = catalog.begin(); p != catalog.end(); ++p)
- {
- string keyName, valueName;
-
- if(p->second.evictor)
- {
- keyName = evictorKeyName;
- valueName = evictorValueName;
- }
- else
- {
- keyName = p->second.key;
- valueName = p->second.value;
- }
-
- //
- // Look up the key and value types in the old and new Slice definitions.
- //
- Slice::TypePtr oldKeyType = findType(oldUnit, keyName);
- if(!oldKeyType)
- {
- cerr << argv[0] << ": type `" << keyName << "' from database `" << p->first
- << "' not found in old Slice definitions" << endl;
- }
- Slice::TypePtr newKeyType = findType(newUnit, keyName);
- if(!newKeyType)
- {
- cerr << argv[0] << ": type `" << keyName << "' from database `" << p->first
- << "' not found in new Slice definitions" << endl;
- }
- Slice::TypePtr oldValueType = findType(oldUnit, valueName);
- if(!oldValueType)
- {
- cerr << argv[0] << ": type `" << valueName << "' from database `" << p->first
- << "' not found in old Slice definitions" << endl;
- }
- Slice::TypePtr newValueType = findType(newUnit, valueName);
- if(!newValueType)
- {
- cerr << argv[0] << ": type `" << valueName << "' from database `" << p->first
- << "' not found in new Slice definitions" << endl;
- }
-
- //
- // If we are generating an output file, we do not consider a missing type to be
- // an error. Since the type information comes from the catalog of the old
- // environment, it's possible that the key or value types are not present in
- // the new Slice definitions. Rather than abort at this point, we simply emit
- // a partially-defined <database> element that must be edited by the user.
- //
- // If we are not generating an output file, we have to stop now.
- //
- if(outputFile.empty() && (!oldKeyType || !newKeyType || !oldValueType || !newValueType))
- {
- return EXIT_FAILURE;
- }
-
- analyzer.addDatabase(p->first, oldKeyType, newKeyType, oldValueType, newValueType);
- }
- }
- else
- {
- string oldKeyName, newKeyName, oldValueName, newValueName;
-
- if(evictor)
- {
- oldKeyName = newKeyName = evictorKeyName;
- oldValueName = newValueName = evictorValueName;
- }
- else
- {
- string::size_type pos;
-
- if(keyTypeNames.empty() || valueTypeNames.empty())
- {
- usage(argv[0]);
- return EXIT_FAILURE;
- }
-
- pos = keyTypeNames.find(',');
- if(pos == 0 || pos == keyTypeNames.size())
- {
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- if(pos == string::npos)
- {
- oldKeyName = keyTypeNames;
- newKeyName = keyTypeNames;
- }
- else
- {
- oldKeyName = keyTypeNames.substr(0, pos);
- newKeyName = keyTypeNames.substr(pos + 1);
- }
-
- pos = valueTypeNames.find(',');
- if(pos == 0 || pos == valueTypeNames.size())
- {
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- if(pos == string::npos)
- {
- oldValueName = valueTypeNames;
- newValueName = valueTypeNames;
- }
- else
- {
- oldValueName = valueTypeNames.substr(0, pos);
- newValueName = valueTypeNames.substr(pos + 1);
- }
- }
-
- //
- // Look up the key and value types in the old and new Slice definitions.
- //
- Slice::TypePtr oldKeyType = findType(oldUnit, oldKeyName);
- if(!oldKeyType)
- {
- cerr << argv[0] << ": type `" << oldKeyName << "' not found in old Slice definitions" << endl;
- }
- Slice::TypePtr newKeyType = findType(newUnit, newKeyName);
- if(!newKeyType)
- {
- cerr << argv[0] << ": type `" << newKeyName << "' not found in new Slice definitions" << endl;
- }
- Slice::TypePtr oldValueType = findType(oldUnit, oldValueName);
- if(!oldValueType)
- {
- cerr << argv[0] << ": type `" << oldValueName << "' not found in old Slice definitions" << endl;
- }
- Slice::TypePtr newValueType = findType(newUnit, newValueName);
- if(!newValueType)
- {
- cerr << argv[0] << ": type `" << newValueName << "' not found in new Slice definitions" << endl;
- }
-
- //
- // Stop now if any of the types could not be found.
- //
- if(!oldKeyType || !newKeyType || !oldValueType || !newValueType)
- {
- return EXIT_FAILURE;
- }
-
- analyzer.addDatabase("", oldKeyType, newKeyType, oldValueType, newValueType);
- }
-
- analyzer.finish();
+ FreezeScript::TransformAnalyzer analyzer(oldUnit, newUnit, ignoreTypeChanges, out, missingTypes, analyzeErrors);
+
+ const string evictorKeyName = "::Ice::Identity";
+ const string evictorValueName = "::Freeze::ObjectRecord";
+
+ if(allDb)
+ {
+ //
+ // Add a <database> element for each database in the catalog.
+ //
+ for(FreezeScript::CatalogDataMap::iterator p = catalog.begin(); p != catalog.end(); ++p)
+ {
+ string keyName, valueName;
+
+ if(p->second.evictor)
+ {
+ keyName = evictorKeyName;
+ valueName = evictorValueName;
+ }
+ else
+ {
+ keyName = p->second.key;
+ valueName = p->second.value;
+ }
+
+ //
+ // Look up the key and value types in the old and new Slice definitions.
+ //
+ Slice::TypePtr oldKeyType = findType(oldUnit, keyName);
+ if(!oldKeyType)
+ {
+ cerr << argv[0] << ": type `" << keyName << "' from database `" << p->first
+ << "' not found in old Slice definitions" << endl;
+ }
+ Slice::TypePtr newKeyType = findType(newUnit, keyName);
+ if(!newKeyType)
+ {
+ cerr << argv[0] << ": type `" << keyName << "' from database `" << p->first
+ << "' not found in new Slice definitions" << endl;
+ }
+ Slice::TypePtr oldValueType = findType(oldUnit, valueName);
+ if(!oldValueType)
+ {
+ cerr << argv[0] << ": type `" << valueName << "' from database `" << p->first
+ << "' not found in old Slice definitions" << endl;
+ }
+ Slice::TypePtr newValueType = findType(newUnit, valueName);
+ if(!newValueType)
+ {
+ cerr << argv[0] << ": type `" << valueName << "' from database `" << p->first
+ << "' not found in new Slice definitions" << endl;
+ }
+
+ //
+ // If we are generating an output file, we do not consider a missing type to be
+ // an error. Since the type information comes from the catalog of the old
+ // environment, it's possible that the key or value types are not present in
+ // the new Slice definitions. Rather than abort at this point, we simply emit
+ // a partially-defined <database> element that must be edited by the user.
+ //
+ // If we are not generating an output file, we have to stop now.
+ //
+ if(outputFile.empty() && (!oldKeyType || !newKeyType || !oldValueType || !newValueType))
+ {
+ return EXIT_FAILURE;
+ }
+
+ analyzer.addDatabase(p->first, oldKeyType, newKeyType, oldValueType, newValueType);
+ }
+ }
+ else
+ {
+ string oldKeyName, newKeyName, oldValueName, newValueName;
+
+ if(evictor)
+ {
+ oldKeyName = newKeyName = evictorKeyName;
+ oldValueName = newValueName = evictorValueName;
+ }
+ else
+ {
+ string::size_type pos;
+
+ if(keyTypeNames.empty() || valueTypeNames.empty())
+ {
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ pos = keyTypeNames.find(',');
+ if(pos == 0 || pos == keyTypeNames.size())
+ {
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ if(pos == string::npos)
+ {
+ oldKeyName = keyTypeNames;
+ newKeyName = keyTypeNames;
+ }
+ else
+ {
+ oldKeyName = keyTypeNames.substr(0, pos);
+ newKeyName = keyTypeNames.substr(pos + 1);
+ }
+
+ pos = valueTypeNames.find(',');
+ if(pos == 0 || pos == valueTypeNames.size())
+ {
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ if(pos == string::npos)
+ {
+ oldValueName = valueTypeNames;
+ newValueName = valueTypeNames;
+ }
+ else
+ {
+ oldValueName = valueTypeNames.substr(0, pos);
+ newValueName = valueTypeNames.substr(pos + 1);
+ }
+ }
+
+ //
+ // Look up the key and value types in the old and new Slice definitions.
+ //
+ Slice::TypePtr oldKeyType = findType(oldUnit, oldKeyName);
+ if(!oldKeyType)
+ {
+ cerr << argv[0] << ": type `" << oldKeyName << "' not found in old Slice definitions" << endl;
+ }
+ Slice::TypePtr newKeyType = findType(newUnit, newKeyName);
+ if(!newKeyType)
+ {
+ cerr << argv[0] << ": type `" << newKeyName << "' not found in new Slice definitions" << endl;
+ }
+ Slice::TypePtr oldValueType = findType(oldUnit, oldValueName);
+ if(!oldValueType)
+ {
+ cerr << argv[0] << ": type `" << oldValueName << "' not found in old Slice definitions" << endl;
+ }
+ Slice::TypePtr newValueType = findType(newUnit, newValueName);
+ if(!newValueType)
+ {
+ cerr << argv[0] << ": type `" << newValueName << "' not found in new Slice definitions" << endl;
+ }
+
+ //
+ // Stop now if any of the types could not be found.
+ //
+ if(!oldKeyType || !newKeyType || !oldValueType || !newValueType)
+ {
+ return EXIT_FAILURE;
+ }
+
+ analyzer.addDatabase("", oldKeyType, newKeyType, oldValueType, newValueType);
+ }
+
+ analyzer.finish();
if(!analyzeErrors.empty())
{
@@ -717,7 +717,7 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
// Open the old database environment. Use DB_RECOVER_FATAL if -c is specified.
// No transaction is created for the old environment.
//
- // DB_THREAD is for compatibility with Freeze (the catalog)
+ // DB_THREAD is for compatibility with Freeze (the catalog)
{
u_int32_t flags = DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_CREATE | DB_THREAD;
if(catastrophicRecover)
@@ -734,42 +734,42 @@ run(int argc, char** argv, const Ice::CommunicatorPtr& communicator)
//
// Open the new database environment and start a transaction.
//
- //
- // DB_THREAD is for compatibility with Freeze (the catalog)
- //
+ //
+ // DB_THREAD is for compatibility with Freeze (the catalog)
+ //
{
u_int32_t flags = DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_RECOVER | DB_CREATE
- | DB_THREAD;
+ | DB_THREAD;
dbEnvNew.open(dbEnvNameNew.c_str(), flags, FREEZE_SCRIPT_DB_MODE);
}
- //
- // TODO: handle properly DbHome config (currently it will break if it's set for the new env)
- //
-
- //
- // Open the catalog of the new environment, and start a transaction.
- //
- Freeze::ConnectionPtr connectionNew = Freeze::createConnection(communicator, dbEnvNameNew, dbEnvNew);
- txNew = connectionNew->beginTransaction();
- DbTxn* txnNew = Freeze::getTxn(txNew);
-
- if(allDb)
- {
- //
- // Transform all databases in the old catalog.
- //
- for(FreezeScript::CatalogDataMap::iterator p = catalog.begin(); p != catalog.end(); ++p)
- {
- transformDb(p->second.evictor, communicator, objectFactory, dbEnv, dbEnvNew, p->first, connectionNew,
- dbs, oldUnit, newUnit, txnNew, purgeObjects, suppress, descriptors);
- }
- }
- else
- {
- transformDb(evictor, communicator, objectFactory, dbEnv, dbEnvNew, dbName, connectionNew, dbs,
- oldUnit, newUnit, txnNew, purgeObjects, suppress, descriptors);
- }
+ //
+ // TODO: handle properly DbHome config (currently it will break if it's set for the new env)
+ //
+
+ //
+ // Open the catalog of the new environment, and start a transaction.
+ //
+ Freeze::ConnectionPtr connectionNew = Freeze::createConnection(communicator, dbEnvNameNew, dbEnvNew);
+ txNew = connectionNew->beginTransaction();
+ DbTxn* txnNew = Freeze::getTxn(txNew);
+
+ if(allDb)
+ {
+ //
+ // Transform all databases in the old catalog.
+ //
+ for(FreezeScript::CatalogDataMap::iterator p = catalog.begin(); p != catalog.end(); ++p)
+ {
+ transformDb(p->second.evictor, communicator, objectFactory, dbEnv, dbEnvNew, p->first, connectionNew,
+ dbs, oldUnit, newUnit, txnNew, purgeObjects, suppress, descriptors);
+ }
+ }
+ else
+ {
+ transformDb(evictor, communicator, objectFactory, dbEnv, dbEnvNew, dbName, connectionNew, dbs,
+ oldUnit, newUnit, txnNew, purgeObjects, suppress, descriptors);
+ }
}
catch(const DbException& ex)
{
diff --git a/cpp/src/Glacier2/Blobject.cpp b/cpp/src/Glacier2/Blobject.cpp
index fb4f49d8772..bc5995fb547 100644
--- a/cpp/src/Glacier2/Blobject.cpp
+++ b/cpp/src/Glacier2/Blobject.cpp
@@ -32,57 +32,57 @@ Glacier2::Blobject::Blobject(const CommunicatorPtr& communicator, bool reverse,
_logger(_communicator->getLogger()),
_reverse(reverse),
_forwardContext(_reverse ?
- _properties->getPropertyAsInt(serverForwardContext) > 0 :
- _properties->getPropertyAsInt(clientForwardContext) > 0),
+ _properties->getPropertyAsInt(serverForwardContext) > 0 :
+ _properties->getPropertyAsInt(clientForwardContext) > 0),
_buffered(_reverse ?
- _properties->getPropertyAsIntWithDefault(serverBuffered, 1) > 0 :
- _properties->getPropertyAsIntWithDefault(clientBuffered, 1) > 0),
+ _properties->getPropertyAsIntWithDefault(serverBuffered, 1) > 0 :
+ _properties->getPropertyAsIntWithDefault(clientBuffered, 1) > 0),
_alwaysBatch(_reverse ?
- _properties->getPropertyAsInt(serverAlwaysBatch) > 0 :
- _properties->getPropertyAsInt(clientAlwaysBatch) > 0),
+ _properties->getPropertyAsInt(serverAlwaysBatch) > 0 :
+ _properties->getPropertyAsInt(clientAlwaysBatch) > 0),
_requestTraceLevel(_reverse ?
- _properties->getPropertyAsInt(serverTraceRequest) :
- _properties->getPropertyAsInt(clientTraceRequest)),
+ _properties->getPropertyAsInt(serverTraceRequest) :
+ _properties->getPropertyAsInt(clientTraceRequest)),
_overrideTraceLevel(reverse ?
- _properties->getPropertyAsInt(serverTraceOverride) :
- _properties->getPropertyAsInt(clientTraceOverride)),
+ _properties->getPropertyAsInt(serverTraceOverride) :
+ _properties->getPropertyAsInt(clientTraceOverride)),
_sslContext(sslContext)
{
if(_buffered)
{
- try
- {
- IceUtil::Time sleepTime = _reverse ?
- IceUtil::Time::milliSeconds(_properties->getPropertyAsInt(serverSleepTime)) :
- IceUtil::Time::milliSeconds(_properties->getPropertyAsInt(clientSleepTime));
+ try
+ {
+ IceUtil::Time sleepTime = _reverse ?
+ IceUtil::Time::milliSeconds(_properties->getPropertyAsInt(serverSleepTime)) :
+ IceUtil::Time::milliSeconds(_properties->getPropertyAsInt(clientSleepTime));
- const_cast<RequestQueuePtr&>(_requestQueue) = new RequestQueue(sleepTime);
-
- Int threadStackSize = _properties->getPropertyAsInt("Ice.ThreadPerConnection.StackSize");
-
- _requestQueue->start(static_cast<size_t>(threadStackSize));
+ const_cast<RequestQueuePtr&>(_requestQueue) = new RequestQueue(sleepTime);
+
+ Int threadStackSize = _properties->getPropertyAsInt("Ice.ThreadPerConnection.StackSize");
+
+ _requestQueue->start(static_cast<size_t>(threadStackSize));
- //
- // See the comment in Glacier2::RequestQueue::destroy()
- // for why we detach the thread.
- //
- _requestQueue->getThreadControl().detach();
- }
- catch(const IceUtil::Exception& ex)
- {
- {
- Error out(_logger);
- out << "cannot create thread for request queue:\n" << ex;
- }
+ //
+ // See the comment in Glacier2::RequestQueue::destroy()
+ // for why we detach the thread.
+ //
+ _requestQueue->getThreadControl().detach();
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ {
+ Error out(_logger);
+ out << "cannot create thread for request queue:\n" << ex;
+ }
- if(_requestQueue)
- {
- _requestQueue->destroy();
- }
-
- throw;
- }
+ if(_requestQueue)
+ {
+ _requestQueue->destroy();
+ }
+
+ throw;
+ }
}
}
@@ -98,14 +98,14 @@ Glacier2::Blobject::destroy()
void
Glacier2::Blobject::invoke(ObjectPrx& proxy, const AMD_Array_Object_ice_invokePtr& amdCB,
- const std::pair<const Ice::Byte*, const Ice::Byte*>& inParams, const Current& current)
+ const std::pair<const Ice::Byte*, const Ice::Byte*>& inParams, const Current& current)
{
//
// Set the correct facet on the proxy.
//
if(!current.facet.empty())
{
- proxy = proxy->ice_facet(current.facet);
+ proxy = proxy->ice_facet(current.facet);
}
//
@@ -115,13 +115,13 @@ Glacier2::Blobject::invoke(ObjectPrx& proxy, const AMD_Array_Object_ice_invokePt
if(current.requestId == 0)
{
if(_alwaysBatch && _buffered)
- {
- proxy = proxy->ice_batchOneway();
- }
- else
- {
+ {
+ proxy = proxy->ice_batchOneway();
+ }
+ else
+ {
proxy = proxy->ice_oneway();
- }
+ }
}
else if(current.requestId > 0)
{
@@ -134,229 +134,229 @@ Glacier2::Blobject::invoke(ObjectPrx& proxy, const AMD_Array_Object_ice_invokePt
Context::const_iterator p = current.ctx.find("_fwd");
if(p != current.ctx.end())
{
- for(unsigned int i = 0; i < p->second.length(); ++i)
- {
- char option = p->second[i];
- switch(option)
- {
- case 't':
- {
- proxy = proxy->ice_twoway();
- break;
- }
-
- case 'o':
- {
- if(_alwaysBatch && _buffered)
- {
- proxy = proxy->ice_batchOneway();
- }
- else
- {
- proxy = proxy->ice_oneway();
- }
- break;
- }
-
- case 'd':
- {
- if(_alwaysBatch && _buffered)
- {
- proxy = proxy->ice_batchDatagram();
- }
- else
- {
- proxy = proxy->ice_datagram();
- }
- break;
- }
-
- case 'O':
- {
- if(_buffered)
- {
- proxy = proxy->ice_batchOneway();
- }
- else
- {
- proxy = proxy->ice_oneway();
- }
- break;
- }
-
- case 'D':
- {
- if(_buffered)
- {
- proxy = proxy->ice_batchDatagram();
- }
- else
- {
- proxy = proxy->ice_datagram();
- }
- break;
- }
-
- case 's':
- {
- proxy = proxy->ice_secure(true);
- break;
- }
-
- case 'z':
- {
- proxy = proxy->ice_compress(true);
- break;
- }
-
- default:
- {
- Warning out(_logger);
- out << "unknown forward option `" << option << "'";
- break;
- }
- }
- }
+ for(unsigned int i = 0; i < p->second.length(); ++i)
+ {
+ char option = p->second[i];
+ switch(option)
+ {
+ case 't':
+ {
+ proxy = proxy->ice_twoway();
+ break;
+ }
+
+ case 'o':
+ {
+ if(_alwaysBatch && _buffered)
+ {
+ proxy = proxy->ice_batchOneway();
+ }
+ else
+ {
+ proxy = proxy->ice_oneway();
+ }
+ break;
+ }
+
+ case 'd':
+ {
+ if(_alwaysBatch && _buffered)
+ {
+ proxy = proxy->ice_batchDatagram();
+ }
+ else
+ {
+ proxy = proxy->ice_datagram();
+ }
+ break;
+ }
+
+ case 'O':
+ {
+ if(_buffered)
+ {
+ proxy = proxy->ice_batchOneway();
+ }
+ else
+ {
+ proxy = proxy->ice_oneway();
+ }
+ break;
+ }
+
+ case 'D':
+ {
+ if(_buffered)
+ {
+ proxy = proxy->ice_batchDatagram();
+ }
+ else
+ {
+ proxy = proxy->ice_datagram();
+ }
+ break;
+ }
+
+ case 's':
+ {
+ proxy = proxy->ice_secure(true);
+ break;
+ }
+
+ case 'z':
+ {
+ proxy = proxy->ice_compress(true);
+ break;
+ }
+
+ default:
+ {
+ Warning out(_logger);
+ out << "unknown forward option `" << option << "'";
+ break;
+ }
+ }
+ }
}
if(_requestTraceLevel >= 1)
{
- Trace out(_logger, "Glacier2");
- if(_reverse)
- {
- out << "reverse ";
- }
- out << "routing";
- if(_buffered)
- {
- out << " (buffered)";
- }
- else
- {
- out << " (not buffered)";
- }
- if(_reverse)
- {
- out << "\nidentity = " << _communicator->identityToString(proxy->ice_getIdentity());
- }
- else
- {
- out << "\nproxy = " << _communicator->proxyToString(proxy);
- }
- out << "\noperation = " << current.operation;
- out << "\ncontext = ";
- Context::const_iterator q = current.ctx.begin();
- while(q != current.ctx.end())
- {
- out << q->first << '/' << q->second;
- if(++q != current.ctx.end())
- {
- out << ", ";
- }
- }
+ Trace out(_logger, "Glacier2");
+ if(_reverse)
+ {
+ out << "reverse ";
+ }
+ out << "routing";
+ if(_buffered)
+ {
+ out << " (buffered)";
+ }
+ else
+ {
+ out << " (not buffered)";
+ }
+ if(_reverse)
+ {
+ out << "\nidentity = " << _communicator->identityToString(proxy->ice_getIdentity());
+ }
+ else
+ {
+ out << "\nproxy = " << _communicator->proxyToString(proxy);
+ }
+ out << "\noperation = " << current.operation;
+ out << "\ncontext = ";
+ Context::const_iterator q = current.ctx.begin();
+ while(q != current.ctx.end())
+ {
+ out << q->first << '/' << q->second;
+ if(++q != current.ctx.end())
+ {
+ out << ", ";
+ }
+ }
}
if(_buffered)
{
- //
- // If we are in buffered mode, we create a new request and add
- // it to the request queue. If the request is twoway, we use
- // AMI.
- //
+ //
+ // If we are in buffered mode, we create a new request and add
+ // it to the request queue. If the request is twoway, we use
+ // AMI.
+ //
- bool override;
- try
- {
- override =
- _requestQueue->addRequest(new Request(proxy, inParams, current, _forwardContext, _sslContext, amdCB));
- }
- catch(const ObjectNotExistException& ex)
- {
- amdCB->ice_exception(ex);
- return;
- }
+ bool override;
+ try
+ {
+ override =
+ _requestQueue->addRequest(new Request(proxy, inParams, current, _forwardContext, _sslContext, amdCB));
+ }
+ catch(const ObjectNotExistException& ex)
+ {
+ amdCB->ice_exception(ex);
+ return;
+ }
- if(override && _overrideTraceLevel >= 1)
- {
- Trace out(_logger, "Glacier2");
- if(_reverse)
- {
- out << "reverse ";
- }
- out << "routing override";
- if(_reverse)
- {
- out << "\nidentity = " << _communicator->identityToString(proxy->ice_getIdentity());
- }
- else
- {
- out << "\nproxy = " << _communicator->proxyToString(proxy);
- }
- out << "\noperation = " << current.operation;
- out << "\ncontext = ";
- Context::const_iterator q = current.ctx.begin();
- while(q != current.ctx.end())
- {
- out << q->first << '/' << q->second;
- if(++q != current.ctx.end())
- {
- out << ", ";
- }
- }
- }
+ if(override && _overrideTraceLevel >= 1)
+ {
+ Trace out(_logger, "Glacier2");
+ if(_reverse)
+ {
+ out << "reverse ";
+ }
+ out << "routing override";
+ if(_reverse)
+ {
+ out << "\nidentity = " << _communicator->identityToString(proxy->ice_getIdentity());
+ }
+ else
+ {
+ out << "\nproxy = " << _communicator->proxyToString(proxy);
+ }
+ out << "\noperation = " << current.operation;
+ out << "\ncontext = ";
+ Context::const_iterator q = current.ctx.begin();
+ while(q != current.ctx.end())
+ {
+ out << q->first << '/' << q->second;
+ if(++q != current.ctx.end())
+ {
+ out << ", ";
+ }
+ }
+ }
}
else
{
- //
- // If we are in not in buffered mode, we send the request
- // directly.
- //
+ //
+ // If we are in not in buffered mode, we send the request
+ // directly.
+ //
- bool ok;
- ByteSeq outParams;
+ bool ok;
+ ByteSeq outParams;
- try
- {
- if(_forwardContext)
- {
- if(_sslContext.size() > 0)
- {
- Ice::Context ctx = current.ctx;
- ctx.insert(_sslContext.begin(), _sslContext.end());
- ok = proxy->ice_invoke(current.operation, current.mode, inParams, outParams, ctx);
- }
- else
- {
- ok = proxy->ice_invoke(current.operation, current.mode, inParams, outParams, current.ctx);
- }
- }
- else
- {
- if(_sslContext.size() > 0)
- {
- ok = proxy->ice_invoke(current.operation, current.mode, inParams, outParams, _sslContext);
- }
- else
- {
- ok = proxy->ice_invoke(current.operation, current.mode, inParams, outParams);
- }
- }
+ try
+ {
+ if(_forwardContext)
+ {
+ if(_sslContext.size() > 0)
+ {
+ Ice::Context ctx = current.ctx;
+ ctx.insert(_sslContext.begin(), _sslContext.end());
+ ok = proxy->ice_invoke(current.operation, current.mode, inParams, outParams, ctx);
+ }
+ else
+ {
+ ok = proxy->ice_invoke(current.operation, current.mode, inParams, outParams, current.ctx);
+ }
+ }
+ else
+ {
+ if(_sslContext.size() > 0)
+ {
+ ok = proxy->ice_invoke(current.operation, current.mode, inParams, outParams, _sslContext);
+ }
+ else
+ {
+ ok = proxy->ice_invoke(current.operation, current.mode, inParams, outParams);
+ }
+ }
- pair<const Byte*, const Byte*> outPair;
- if(outParams.size() == 0)
- {
- outPair.first = outPair.second = 0;
- }
- else
- {
- outPair.first = &outParams[0];
- outPair.second = outPair.first + outParams.size();
- }
- amdCB->ice_response(ok, outPair);
- }
- catch(const LocalException& ex)
- {
- amdCB->ice_exception(ex);
- }
+ pair<const Byte*, const Byte*> outPair;
+ if(outParams.size() == 0)
+ {
+ outPair.first = outPair.second = 0;
+ }
+ else
+ {
+ outPair.first = &outParams[0];
+ outPair.second = outPair.first + outParams.size();
+ }
+ amdCB->ice_response(ok, outPair);
+ }
+ catch(const LocalException& ex)
+ {
+ amdCB->ice_exception(ex);
+ }
}
}
diff --git a/cpp/src/Glacier2/Blobject.h b/cpp/src/Glacier2/Blobject.h
index c9ffd39469d..afda9383a7e 100644
--- a/cpp/src/Glacier2/Blobject.h
+++ b/cpp/src/Glacier2/Blobject.h
@@ -28,7 +28,7 @@ public:
protected:
void invoke(Ice::ObjectPrx&, const Ice::AMD_Array_Object_ice_invokePtr&,
- const std::pair<const Ice::Byte*, const Ice::Byte*>&, const Ice::Current&);
+ const std::pair<const Ice::Byte*, const Ice::Byte*>&, const Ice::Current&);
const Ice::CommunicatorPtr _communicator;
const Ice::PropertiesPtr _properties;
diff --git a/cpp/src/Glacier2/ClientBlobject.cpp b/cpp/src/Glacier2/ClientBlobject.cpp
index fde2b1669d0..a1e32dca027 100644
--- a/cpp/src/Glacier2/ClientBlobject.cpp
+++ b/cpp/src/Glacier2/ClientBlobject.cpp
@@ -17,9 +17,9 @@ using namespace Ice;
using namespace Glacier2;
Glacier2::ClientBlobject::ClientBlobject(const CommunicatorPtr& communicator,
- const FilterManagerPtr& filters,
- const Ice::Context& sslContext):
-
+ const FilterManagerPtr& filters,
+ const Ice::Context& sslContext):
+
Glacier2::Blobject(communicator, false, sslContext),
_routingTable(new RoutingTable(communicator)),
_filters(filters),
@@ -33,8 +33,8 @@ Glacier2::ClientBlobject::~ClientBlobject()
void
Glacier2::ClientBlobject::ice_invoke_async(const Ice::AMD_Array_Object_ice_invokePtr& amdCB,
- const std::pair<const Byte*, const Byte*>& inParams,
- const Current& current)
+ const std::pair<const Byte*, const Byte*>& inParams,
+ const Current& current)
{
bool matched = false;
bool hasFilters = false;
@@ -42,89 +42,89 @@ Glacier2::ClientBlobject::ice_invoke_async(const Ice::AMD_Array_Object_ice_invok
if(!_filters->categories()->empty())
{
- hasFilters = true;
- if(_filters->categories()->match(current.id.category))
- {
- matched = true;
- }
- else if(_rejectTraceLevel >= 1)
- {
- if(rejectedFilters.size() != 0)
- {
- rejectedFilters += ", ";
-
- }
- rejectedFilters += "category filter";
- }
+ hasFilters = true;
+ if(_filters->categories()->match(current.id.category))
+ {
+ matched = true;
+ }
+ else if(_rejectTraceLevel >= 1)
+ {
+ if(rejectedFilters.size() != 0)
+ {
+ rejectedFilters += ", ";
+
+ }
+ rejectedFilters += "category filter";
+ }
}
if(!_filters->identities()->empty())
{
- hasFilters = true;
- if(_filters->identities()->match(current.id))
- {
- matched = true;
- }
- else if(_rejectTraceLevel >= 1)
- {
- if(rejectedFilters.size() != 0)
- {
- rejectedFilters += ", ";
-
- }
- rejectedFilters += "identity filter";
- }
+ hasFilters = true;
+ if(_filters->identities()->match(current.id))
+ {
+ matched = true;
+ }
+ else if(_rejectTraceLevel >= 1)
+ {
+ if(rejectedFilters.size() != 0)
+ {
+ rejectedFilters += ", ";
+
+ }
+ rejectedFilters += "identity filter";
+ }
}
ObjectPrx proxy = _routingTable->get(current.id);
if(!proxy)
{
- ObjectNotExistException ex(__FILE__, __LINE__);
-
- //
- // We use a special operation name indicate to the client that
- // the proxy for the Ice object has not been found in our
- // routing table. This can happen if the proxy was evicted
- // from the routing table.
- //
- ex.id = current.id;
- ex.facet = current.facet;
- ex.operation = "ice_add_proxy";
- throw ex;
+ ObjectNotExistException ex(__FILE__, __LINE__);
+
+ //
+ // We use a special operation name indicate to the client that
+ // the proxy for the Ice object has not been found in our
+ // routing table. This can happen if the proxy was evicted
+ // from the routing table.
+ //
+ ex.id = current.id;
+ ex.facet = current.facet;
+ ex.operation = "ice_add_proxy";
+ throw ex;
}
string adapterId = proxy->ice_getAdapterId();
if(!adapterId.empty() && !_filters->adapterIds()->empty())
{
- hasFilters = true;
- if(_filters->adapterIds()->match(adapterId))
- {
- matched = true;
- }
- else if(_rejectTraceLevel >= 1)
- {
- if(rejectedFilters.size() != 0)
- {
- rejectedFilters += ", ";
-
- }
- rejectedFilters += "adapter id filter";
- }
+ hasFilters = true;
+ if(_filters->adapterIds()->match(adapterId))
+ {
+ matched = true;
+ }
+ else if(_rejectTraceLevel >= 1)
+ {
+ if(rejectedFilters.size() != 0)
+ {
+ rejectedFilters += ", ";
+
+ }
+ rejectedFilters += "adapter id filter";
+ }
}
if(hasFilters && !matched)
{
- if(_rejectTraceLevel >= 1)
- {
- Trace out(_logger, "Glacier2");
- out << "rejecting request: " << rejectedFilters << "\n";
- out << "identity: " << _communicator->identityToString(current.id);
- }
-
- ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = current.id;
- throw ex;
+ if(_rejectTraceLevel >= 1)
+ {
+ Trace out(_logger, "Glacier2");
+ out << "rejecting request: " << rejectedFilters << "\n";
+ out << "identity: " << _communicator->identityToString(current.id);
+ }
+
+ ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = current.id;
+ throw ex;
}
invoke(proxy, amdCB, inParams, current);
}
diff --git a/cpp/src/Glacier2/ClientBlobject.h b/cpp/src/Glacier2/ClientBlobject.h
index 835a2da22e0..5385a0f2c0b 100644
--- a/cpp/src/Glacier2/ClientBlobject.h
+++ b/cpp/src/Glacier2/ClientBlobject.h
@@ -35,7 +35,7 @@ public:
virtual ~ClientBlobject();
virtual void ice_invoke_async(const Ice::AMD_Array_Object_ice_invokePtr&,
- const std::pair<const Ice::Byte*, const Ice::Byte*>&, const Ice::Current&);
+ const std::pair<const Ice::Byte*, const Ice::Byte*>&, const Ice::Current&);
Ice::ObjectProxySeq add(const Ice::ObjectProxySeq&, const Ice::Current&); // Returns evicted proxies.
diff --git a/cpp/src/Glacier2/CryptPermissionsVerifierI.cpp b/cpp/src/Glacier2/CryptPermissionsVerifierI.cpp
index 7d6736df860..66a77599e0d 100755
--- a/cpp/src/Glacier2/CryptPermissionsVerifierI.cpp
+++ b/cpp/src/Glacier2/CryptPermissionsVerifierI.cpp
@@ -29,12 +29,12 @@ Glacier2::CryptPermissionsVerifierI::checkPermissions(
if(p == _passwords.end())
{
- return false;
+ return false;
}
if(p->second.size() != 13) // Crypt passwords are 13 characters long.
{
- return false;
+ return false;
}
char buff[14];
diff --git a/cpp/src/Glacier2/FilterI.h b/cpp/src/Glacier2/FilterI.h
index b7e6ab996b1..a213f3c08a2 100755
--- a/cpp/src/Glacier2/FilterI.h
+++ b/cpp/src/Glacier2/FilterI.h
@@ -47,24 +47,24 @@ public:
bool
match(const T& candidate) const
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
- //
- // Empty vectors mean no filtering, so all matches will succeed.
- //
- if(_items.size() == 0)
- {
- return true;
- }
-
- return binary_search(_items.begin(), _items.end(), candidate);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
+ //
+ // Empty vectors mean no filtering, so all matches will succeed.
+ //
+ if(_items.size() == 0)
+ {
+ return true;
+ }
+
+ return binary_search(_items.begin(), _items.end(), candidate);
}
bool
empty() const
{
- return _items.size() == 0;
+ return _items.size() == 0;
}
-
+
private:
std::vector<T> _items;
@@ -128,36 +128,36 @@ FilterT<T, P>::remove(const std::vector<T>& deletions, const Ice::Current&)
while(r != toRemove.end())
{
- iterator i = mark;
- while(i != _items.end() && r != toRemove.end())
- {
- if(*r == *i)
- {
- //
- // We want this list to be in LIFO order because we are
- // going to erase things from the tail forward.
- //
- deleteList.push_front(i);
- ++i;
- ++r;
- mark = i;
- }
- else
- {
- ++i;
- }
- }
-
- if(r == toRemove.end())
- {
- break;
- }
- ++r;
+ iterator i = mark;
+ while(i != _items.end() && r != toRemove.end())
+ {
+ if(*r == *i)
+ {
+ //
+ // We want this list to be in LIFO order because we are
+ // going to erase things from the tail forward.
+ //
+ deleteList.push_front(i);
+ ++i;
+ ++r;
+ mark = i;
+ }
+ else
+ {
+ ++i;
+ }
+ }
+
+ if(r == toRemove.end())
+ {
+ break;
+ }
+ ++r;
}
for(literator i = deleteList.begin(); i != deleteList.end(); ++i)
{
- _items.erase(*i);
+ _items.erase(*i);
}
}
diff --git a/cpp/src/Glacier2/FilterManager.cpp b/cpp/src/Glacier2/FilterManager.cpp
index 13c2a44e674..99bc204ed9e 100755
--- a/cpp/src/Glacier2/FilterManager.cpp
+++ b/cpp/src/Glacier2/FilterManager.cpp
@@ -32,61 +32,61 @@ stringToSeq(const string& str, vector<string>& seq)
string::size_type end = 0;
while(current != string::npos)
{
- switch(str[current])
- {
- case '"':
- case '\'':
- {
- char quote = str[current];
- end = current+1;
- while(true)
- {
- end = str.find(quote, end);
+ switch(str[current])
+ {
+ case '"':
+ case '\'':
+ {
+ char quote = str[current];
+ end = current+1;
+ while(true)
+ {
+ end = str.find(quote, end);
- if(end == string::npos)
- {
- //
- // TODO: should this be an unmatched quote error?
- //
- seq.push_back(str.substr(current));
- break;
- }
+ if(end == string::npos)
+ {
+ //
+ // TODO: should this be an unmatched quote error?
+ //
+ seq.push_back(str.substr(current));
+ break;
+ }
- bool markString = true;
- for(string::size_type r = end -1 ; r > current && str[r] == '\\' ; --r)
- {
- markString = !markString;
- }
- //
- // We don't want the quote so we skip that.
- //
- if(markString)
- {
- ++current;
- seq.push_back(str.substr(current, end-current));
- break;
- }
- else
- {
- ++end;
- }
- }
- if(end != string::npos)
- {
- ++end;
- }
- break;
- }
+ bool markString = true;
+ for(string::size_type r = end -1 ; r > current && str[r] == '\\' ; --r)
+ {
+ markString = !markString;
+ }
+ //
+ // We don't want the quote so we skip that.
+ //
+ if(markString)
+ {
+ ++current;
+ seq.push_back(str.substr(current, end-current));
+ break;
+ }
+ else
+ {
+ ++end;
+ }
+ }
+ if(end != string::npos)
+ {
+ ++end;
+ }
+ break;
+ }
- default:
- {
- end = str.find_first_of(ws, current);
- string::size_type len = (end == string::npos) ? string::npos : end - current;
- seq.push_back(str.substr(current, len));
- break;
- }
- }
- current = str.find_first_not_of(ws, end);
+ default:
+ {
+ end = str.find_first_of(ws, current);
+ string::size_type len = (end == string::npos) ? string::npos : end - current;
+ seq.push_back(str.substr(current, len));
+ break;
+ }
+ }
+ current = str.find_first_not_of(ws, end);
}
}
@@ -102,61 +102,61 @@ stringToSeq(const CommunicatorPtr& comm, const string& str, vector<Identity>& se
string::size_type end = 0;
while(current != string::npos)
{
- switch(str[current])
- {
- case '"':
- case '\'':
- {
- char quote = str[current];
- end = current+1;
- while(true)
- {
- end = str.find(quote, end);
+ switch(str[current])
+ {
+ case '"':
+ case '\'':
+ {
+ char quote = str[current];
+ end = current+1;
+ while(true)
+ {
+ end = str.find(quote, end);
- if(end == string::npos)
- {
- //
- // TODO: should this be an unmatched quote error?
- //
- seq.push_back(comm->stringToIdentity(str.substr(current)));
- break;
- }
+ if(end == string::npos)
+ {
+ //
+ // TODO: should this be an unmatched quote error?
+ //
+ seq.push_back(comm->stringToIdentity(str.substr(current)));
+ break;
+ }
- bool markString = true;
- for(string::size_type r = end -1 ; r > current && str[r] == '\\' ; --r)
- {
- markString = !markString;
- }
- //
- // We don't want the quote so we skip that.
- //
- if(markString)
- {
- ++current;
- seq.push_back(comm->stringToIdentity(str.substr(current, end-current)));
- break;
- }
- else
- {
- ++end;
- }
- }
- if(end != string::npos)
- {
- ++end;
- }
- break;
- }
+ bool markString = true;
+ for(string::size_type r = end -1 ; r > current && str[r] == '\\' ; --r)
+ {
+ markString = !markString;
+ }
+ //
+ // We don't want the quote so we skip that.
+ //
+ if(markString)
+ {
+ ++current;
+ seq.push_back(comm->stringToIdentity(str.substr(current, end-current)));
+ break;
+ }
+ else
+ {
+ ++end;
+ }
+ }
+ if(end != string::npos)
+ {
+ ++end;
+ }
+ break;
+ }
- default:
- {
- end = str.find_first_of(ws, current);
- string::size_type len = (end == string::npos) ? string::npos : end - current;
- seq.push_back(comm->stringToIdentity(str.substr(current, len)));
- break;
- }
- }
- current = str.find_first_not_of(ws, end);
+ default:
+ {
+ end = str.find_first_of(ws, current);
+ string::size_type len = (end == string::npos) ? string::npos : end - current;
+ seq.push_back(comm->stringToIdentity(str.substr(current, len)));
+ break;
+ }
+ }
+ current = str.find_first_not_of(ws, end);
}
}
@@ -170,42 +170,42 @@ Glacier2::FilterManager::destroy()
{
if(_adapter)
{
- try
- {
- if(_categoriesPrx)
- {
- _adapter->remove(_categoriesPrx->ice_getIdentity());
- }
- }
- catch(const Exception&)
- {
- }
- try
- {
- if(_adapterIdsPrx)
- {
- _adapter->remove(_adapterIdsPrx->ice_getIdentity());
- }
- }
- catch(const Exception&)
- {
- }
- try
- {
- if(_identitiesPrx)
- {
- _adapter->remove(_identitiesPrx->ice_getIdentity());
- }
- }
- catch(const Exception&)
- {
- }
+ try
+ {
+ if(_categoriesPrx)
+ {
+ _adapter->remove(_categoriesPrx->ice_getIdentity());
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+ try
+ {
+ if(_adapterIdsPrx)
+ {
+ _adapter->remove(_adapterIdsPrx->ice_getIdentity());
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+ try
+ {
+ if(_identitiesPrx)
+ {
+ _adapter->remove(_identitiesPrx->ice_getIdentity());
+ }
+ }
+ catch(const Exception&)
+ {
+ }
}
}
Glacier2::FilterManager::FilterManager(const ObjectAdapterPtr& adapter, const Glacier2::StringSetIPtr& categories,
- const Glacier2::StringSetIPtr& adapters,
- const Glacier2::IdentitySetIPtr& identities) :
+ const Glacier2::StringSetIPtr& adapters,
+ const Glacier2::IdentitySetIPtr& identities) :
_categories(categories),
_adapters(adapters),
_identities(identities),
@@ -213,23 +213,23 @@ Glacier2::FilterManager::FilterManager(const ObjectAdapterPtr& adapter, const Gl
{
try
{
- if(_adapter)
- {
- _categoriesPrx = Glacier2::StringSetPrx::uncheckedCast(_adapter->addWithUUID(_categories));
- _adapterIdsPrx = Glacier2::StringSetPrx::uncheckedCast(_adapter->addWithUUID(_adapters));
- _identitiesPrx = Glacier2::IdentitySetPrx::uncheckedCast(_adapter->addWithUUID(_identities));
- }
+ if(_adapter)
+ {
+ _categoriesPrx = Glacier2::StringSetPrx::uncheckedCast(_adapter->addWithUUID(_categories));
+ _adapterIdsPrx = Glacier2::StringSetPrx::uncheckedCast(_adapter->addWithUUID(_adapters));
+ _identitiesPrx = Glacier2::IdentitySetPrx::uncheckedCast(_adapter->addWithUUID(_identities));
+ }
}
catch(...)
{
- destroy();
- throw;
+ destroy();
+ throw;
}
}
Glacier2::FilterManager*
Glacier2::FilterManager::create(const CommunicatorPtr& communicator, const ObjectAdapterPtr& adapter, const string& userId,
- const bool allowAddUser)
+ const bool allowAddUser)
{
PropertiesPtr props = communicator->getProperties();
//
@@ -239,12 +239,12 @@ Glacier2::FilterManager::create(const CommunicatorPtr& communicator, const Objec
string allow = props->getProperty("Glacier2.Filter.Category.Accept");
if(allow.empty())
{
- allow = props->getProperty("Glacier2.AllowCategories");
- if(!allow.empty())
- {
+ allow = props->getProperty("Glacier2.AllowCategories");
+ if(!allow.empty())
+ {
communicator->getLogger()->warning(
- "Glacier2.AllowCategories has been deprecated, use Glacier2.Filter.Category.Accept instead.");
- }
+ "Glacier2.AllowCategories has been deprecated, use Glacier2.Filter.Category.Accept instead.");
+ }
}
vector<string> allowSeq;
@@ -256,33 +256,33 @@ Glacier2::FilterManager::create(const CommunicatorPtr& communicator, const Objec
// DEPRECATED PROPERTY: Glacier2.AddUserToAllowCategories is to be deprecated
// and superseded by Glacier2.Filter.Category.AcceptUser.
//
- int addUserMode;
- if(!props->getProperty("Glacier2.Filter.Category.AcceptUser").empty())
- {
- addUserMode = props->getPropertyAsInt("Glacier2.Filter.Category.AcceptUser");
- }
- else
- {
- if(!props->getProperty("Glacier2.AddUserToAllowCategories").empty())
- {
+ int addUserMode;
+ if(!props->getProperty("Glacier2.Filter.Category.AcceptUser").empty())
+ {
+ addUserMode = props->getPropertyAsInt("Glacier2.Filter.Category.AcceptUser");
+ }
+ else
+ {
+ if(!props->getProperty("Glacier2.AddUserToAllowCategories").empty())
+ {
communicator->getLogger()->warning(
- "Glacier2.AddUserToAllowCategories has been deprecated, \
- use Glacier2.Filter.Category.AcceptUser instead.");
- }
- addUserMode = props->getPropertyAsInt("Glacier2.AddUserToAllowCategories");
- }
+ "Glacier2.AddUserToAllowCategories has been deprecated, \
+ use Glacier2.Filter.Category.AcceptUser instead.");
+ }
+ addUserMode = props->getPropertyAsInt("Glacier2.AddUserToAllowCategories");
+ }
- if(addUserMode > 0 && !userId.empty())
- {
- if(addUserMode == 1)
- {
- allowSeq.push_back(userId); // Add user id to allowed categories.
- }
- else if(addUserMode == 2)
- {
- allowSeq.push_back('_' + userId); // Add user id with prepended underscore to allowed categories.
- }
- }
+ if(addUserMode > 0 && !userId.empty())
+ {
+ if(addUserMode == 1)
+ {
+ allowSeq.push_back(userId); // Add user id to allowed categories.
+ }
+ else if(addUserMode == 2)
+ {
+ allowSeq.push_back('_' + userId); // Add user id with prepended underscore to allowed categories.
+ }
+ }
}
Glacier2::StringSetIPtr categoryFilter = new Glacier2::StringSetI(allowSeq);
diff --git a/cpp/src/Glacier2/FilterManager.h b/cpp/src/Glacier2/FilterManager.h
index dabd62e8a5f..71881846e81 100755
--- a/cpp/src/Glacier2/FilterManager.h
+++ b/cpp/src/Glacier2/FilterManager.h
@@ -33,37 +33,37 @@ public:
StringSetIPtr
categories() const
{
- return _categories;
+ return _categories;
}
StringSetIPtr
adapterIds() const
{
- return _adapters;
+ return _adapters;
}
IdentitySetIPtr
identities() const
{
- return _identities;
+ return _identities;
}
StringSetPrx
categoriesPrx() const
{
- return _categoriesPrx;
+ return _categoriesPrx;
}
StringSetPrx
adapterIdsPrx() const
{
- return _adapterIdsPrx;
+ return _adapterIdsPrx;
}
IdentitySetPrx
identitiesPrx() const
{
- return _identitiesPrx;
+ return _identitiesPrx;
}
static FilterManager*
diff --git a/cpp/src/Glacier2/Glacier2Router.cpp b/cpp/src/Glacier2/Glacier2Router.cpp
index 9426ae244cd..27fe0be4a3e 100644
--- a/cpp/src/Glacier2/Glacier2Router.cpp
+++ b/cpp/src/Glacier2/Glacier2Router.cpp
@@ -29,14 +29,14 @@ class AdminI : public Admin
public:
AdminI(const CommunicatorPtr& communicator) :
- _communicator(communicator)
+ _communicator(communicator)
{
}
virtual void
shutdown(const Current&)
{
- _communicator->shutdown();
+ _communicator->shutdown();
}
private:
@@ -100,30 +100,30 @@ Glacier2::RouterService::start(int argc, char* argv[])
vector<string> args;
try
{
- args = opts.parse(argc, (const char**)argv);
+ args = opts.parse(argc, (const char**)argv);
}
catch(const IceUtil::BadOptException& e)
{
error(e.reason);
- usage(argv[0]);
- return false;
+ usage(argv[0]);
+ return false;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return false;
+ usage(argv[0]);
+ return false;
}
if(opts.isSet("version"))
{
- print(ICE_STRING_VERSION);
- return false;
+ print(ICE_STRING_VERSION);
+ return false;
}
if(!args.empty())
{
- usage(argv[0]);
- return false;
+ usage(argv[0]);
+ return false;
}
PropertiesPtr properties = communicator()->getProperties();
@@ -137,8 +137,8 @@ Glacier2::RouterService::start(int argc, char* argv[])
if(properties->getProperty(clientEndpointsProperty).empty() &&
properties->getProperty("Glacier2.Client.Endpoints").empty())
{
- error("property `" + clientEndpointsProperty + "' is not set");
- return false;
+ error("property `" + clientEndpointsProperty + "' is not set");
+ return false;
}
ObjectAdapterPtr clientAdapter = communicator()->createObjectAdapter("Glacier2.Client");
@@ -153,7 +153,7 @@ Glacier2::RouterService::start(int argc, char* argv[])
if(!properties->getProperty(serverEndpointsProperty).empty() ||
!properties->getProperty("Glacier2.Server.Endpoints").empty())
{
- serverAdapter = communicator()->createObjectAdapter("Glacier2.Server");
+ serverAdapter = communicator()->createObjectAdapter("Glacier2.Server");
}
//
@@ -167,7 +167,7 @@ Glacier2::RouterService::start(int argc, char* argv[])
if(!properties->getProperty(adminEndpointsProperty).empty() ||
!properties->getProperty("Glacier2.Admin.Endpoints").empty())
{
- adminAdapter = communicator()->createObjectAdapter("Glacier2.Admin");
+ adminAdapter = communicator()->createObjectAdapter("Glacier2.Admin");
}
string instanceName = properties->getPropertyWithDefault("Glacier2.InstanceName", "Glacier2");
@@ -193,67 +193,67 @@ Glacier2::RouterService::start(int argc, char* argv[])
nullPermVerifId.name = "NullPermissionsVerifier";
ObjectPrx obj = communicator()->propertyToProxy(verifierProperty);
- if(obj->ice_getIdentity() == nullPermVerifId)
- {
- verifier = PermissionsVerifierPrx::uncheckedCast(
- verifierAdapter->add(new NullPermissionsVerifierI(), nullPermVerifId)->ice_collocationOptimized(true));
- }
- else
- {
- try
- {
- verifier = PermissionsVerifierPrx::checkedCast(obj);
- }
- catch(const Ice::Exception& ex)
- {
- ostringstream ostr;
- ostr << ex;
- error("unable to contact permissions verifier `" + verifierPropertyValue + "'\n" + ostr.str());
- return false;
- }
- if(!verifier)
- {
- error("permissions verifier `" + verifierPropertyValue + "' is invalid");
- return false;
- }
- }
+ if(obj->ice_getIdentity() == nullPermVerifId)
+ {
+ verifier = PermissionsVerifierPrx::uncheckedCast(
+ verifierAdapter->add(new NullPermissionsVerifierI(), nullPermVerifId)->ice_collocationOptimized(true));
+ }
+ else
+ {
+ try
+ {
+ verifier = PermissionsVerifierPrx::checkedCast(obj);
+ }
+ catch(const Ice::Exception& ex)
+ {
+ ostringstream ostr;
+ ostr << ex;
+ error("unable to contact permissions verifier `" + verifierPropertyValue + "'\n" + ostr.str());
+ return false;
+ }
+ if(!verifier)
+ {
+ error("permissions verifier `" + verifierPropertyValue + "' is invalid");
+ return false;
+ }
+ }
}
else if(!passwordsProperty.empty())
{
- ifstream passwordFile(passwordsProperty.c_str());
- if(!passwordFile)
- {
+ ifstream passwordFile(passwordsProperty.c_str());
+ if(!passwordFile)
+ {
string err = strerror(errno);
- error("cannot open `" + passwordsProperty + "' for reading: " + err);
- return false;
- }
-
- map<string, string> passwords;
-
- while(true)
- {
- string userId;
- passwordFile >> userId;
- if(!passwordFile)
- {
- break;
- }
-
- string password;
- passwordFile >> password;
- if(!passwordFile)
- {
- break;
- }
-
- assert(!userId.empty());
- assert(!password.empty());
- passwords.insert(make_pair(userId, password));
- }
-
- PermissionsVerifierPtr verifierImpl = new CryptPermissionsVerifierI(passwords);
-
- verifier = PermissionsVerifierPrx::uncheckedCast(verifierAdapter->addWithUUID(verifierImpl));
+ error("cannot open `" + passwordsProperty + "' for reading: " + err);
+ return false;
+ }
+
+ map<string, string> passwords;
+
+ while(true)
+ {
+ string userId;
+ passwordFile >> userId;
+ if(!passwordFile)
+ {
+ break;
+ }
+
+ string password;
+ passwordFile >> password;
+ if(!passwordFile)
+ {
+ break;
+ }
+
+ assert(!userId.empty());
+ assert(!password.empty());
+ passwords.insert(make_pair(userId, password));
+ }
+
+ PermissionsVerifierPtr verifierImpl = new CryptPermissionsVerifierI(passwords);
+
+ verifier = PermissionsVerifierPrx::uncheckedCast(verifierAdapter->addWithUUID(verifierImpl));
}
//
@@ -265,24 +265,24 @@ Glacier2::RouterService::start(int argc, char* argv[])
if(!sessionManagerPropertyValue.empty())
{
try
- {
- sessionManager = SessionManagerPrx::checkedCast(communicator()->propertyToProxy(sessionManagerProperty));
- }
- catch(const Ice::Exception& ex)
- {
- ostringstream ostr;
- ostr << ex;
- error("unable to contact session manager `" + sessionManagerPropertyValue + "'\n" + ostr.str());
- return false;
- }
- if(!sessionManager)
- {
- error("session manager `" + sessionManagerPropertyValue + "' is invalid");
- return false;
- }
- sessionManager =
- SessionManagerPrx::uncheckedCast(sessionManager->ice_connectionCached(false)->ice_locatorCacheTimeout(
- properties->getPropertyAsIntWithDefault("Glacier2.SessionManager.LocatorCacheTimeout", 600)));
+ {
+ sessionManager = SessionManagerPrx::checkedCast(communicator()->propertyToProxy(sessionManagerProperty));
+ }
+ catch(const Ice::Exception& ex)
+ {
+ ostringstream ostr;
+ ostr << ex;
+ error("unable to contact session manager `" + sessionManagerPropertyValue + "'\n" + ostr.str());
+ return false;
+ }
+ if(!sessionManager)
+ {
+ error("session manager `" + sessionManagerPropertyValue + "' is invalid");
+ return false;
+ }
+ sessionManager =
+ SessionManagerPrx::uncheckedCast(sessionManager->ice_connectionCached(false)->ice_locatorCacheTimeout(
+ properties->getPropertyAsIntWithDefault("Glacier2.SessionManager.LocatorCacheTimeout", 600)));
}
//
@@ -297,33 +297,33 @@ Glacier2::RouterService::start(int argc, char* argv[])
nullSSLPermVerifId.category = instanceName;
nullSSLPermVerifId.name = "NullSSLPermissionsVerifier";
- ObjectPrx obj = communicator()->propertyToProxy(sslVerifierProperty);
- if(obj->ice_getIdentity() == nullSSLPermVerifId)
- {
+ ObjectPrx obj = communicator()->propertyToProxy(sslVerifierProperty);
+ if(obj->ice_getIdentity() == nullSSLPermVerifId)
+ {
sslVerifier = SSLPermissionsVerifierPrx::uncheckedCast(
verifierAdapter->add(new NullSSLPermissionsVerifierI(), nullSSLPermVerifId)->
- ice_collocationOptimized(true));
- }
- else
- {
+ ice_collocationOptimized(true));
+ }
+ else
+ {
try
- {
- sslVerifier = SSLPermissionsVerifierPrx::checkedCast(obj);
- }
- catch(const Ice::Exception& ex)
- {
- ostringstream ostr;
- ostr << ex;
- error("unable to contact ssl permissions verifier `" + sslVerifierPropertyValue + "'\n" + ostr.str());
- return false;
- }
- if(!sslVerifier)
- {
- error("ssl permissions verifier `" + sslVerifierPropertyValue + "' is invalid");
- return false;
- }
- }
+ {
+ sslVerifier = SSLPermissionsVerifierPrx::checkedCast(obj);
+ }
+ catch(const Ice::Exception& ex)
+ {
+ ostringstream ostr;
+ ostr << ex;
+ error("unable to contact ssl permissions verifier `" + sslVerifierPropertyValue + "'\n" + ostr.str());
+ return false;
+ }
+ if(!sslVerifier)
+ {
+ error("ssl permissions verifier `" + sslVerifierPropertyValue + "' is invalid");
+ return false;
+ }
+ }
}
//
@@ -335,31 +335,31 @@ Glacier2::RouterService::start(int argc, char* argv[])
if(!sslSessionManagerPropertyValue.empty())
{
try
- {
- sslSessionManager =
- SSLSessionManagerPrx::checkedCast(communicator()->propertyToProxy(sslSessionManagerProperty));
- }
- catch(const Ice::Exception& ex)
- {
- ostringstream ostr;
- ostr << ex;
- error("unable to ssl session manager `" + sslSessionManagerPropertyValue + "'\n" + ostr.str());
- return false;
- }
- if(!sslSessionManager)
- {
- error("ssl session manager `" + sslSessionManagerPropertyValue + "' is invalid");
- return false;
- }
- sslSessionManager =
- SSLSessionManagerPrx::uncheckedCast(sslSessionManager->ice_connectionCached(false)->ice_locatorCacheTimeout(
- properties->getPropertyAsIntWithDefault("Glacier2.SSLSessionManager.LocatorCacheTimeout", 600)));
+ {
+ sslSessionManager =
+ SSLSessionManagerPrx::checkedCast(communicator()->propertyToProxy(sslSessionManagerProperty));
+ }
+ catch(const Ice::Exception& ex)
+ {
+ ostringstream ostr;
+ ostr << ex;
+ error("unable to ssl session manager `" + sslSessionManagerPropertyValue + "'\n" + ostr.str());
+ return false;
+ }
+ if(!sslSessionManager)
+ {
+ error("ssl session manager `" + sslSessionManagerPropertyValue + "' is invalid");
+ return false;
+ }
+ sslSessionManager =
+ SSLSessionManagerPrx::uncheckedCast(sslSessionManager->ice_connectionCached(false)->ice_locatorCacheTimeout(
+ properties->getPropertyAsIntWithDefault("Glacier2.SSLSessionManager.LocatorCacheTimeout", 600)));
}
if(!verifier && !sslVerifier)
{
- error("Glacier2 requires a permissions verifier or password file");
- return false;
+ error("Glacier2 requires a permissions verifier or password file");
+ return false;
}
//
@@ -368,17 +368,17 @@ Glacier2::RouterService::start(int argc, char* argv[])
// done here.
//
_sessionRouter = new SessionRouterI(clientAdapter, serverAdapter, verifier, sessionManager, sslVerifier,
- sslSessionManager);
+ sslSessionManager);
//
// If we have an admin adapter, we add an admin object.
//
if(adminAdapter)
{
- Identity adminId;
- adminId.category = instanceName;
- adminId.name = "admin";
- adminAdapter->add(new AdminI(communicator()), adminId);
+ Identity adminId;
+ adminId.category = instanceName;
+ adminId.name = "admin";
+ adminAdapter->add(new AdminI(communicator()), adminId);
}
//
@@ -389,20 +389,20 @@ Glacier2::RouterService::start(int argc, char* argv[])
clientAdapter->activate();
if(serverAdapter)
{
- serverAdapter->activate();
+ serverAdapter->activate();
}
if(adminAdapter)
{
- adminAdapter->activate();
+ adminAdapter->activate();
}
}
catch(const Ice::Exception& ex)
{
- ostringstream ostr;
- ostr << ex;
- error("caught exception activating object adapters\n" + ostr.str());
+ ostringstream ostr;
+ ostr << ex;
+ error("caught exception activating object adapters\n" + ostr.str());
- stop();
+ stop();
return false;
}
@@ -414,15 +414,15 @@ Glacier2::RouterService::stop()
{
if(_sessionRouter)
{
- _sessionRouter->destroy();
- _sessionRouter = 0;
+ _sessionRouter->destroy();
+ _sessionRouter = 0;
}
return true;
}
CommunicatorPtr
Glacier2::RouterService::initializeCommunicator(int& argc, char* argv[],
- const InitializationData& initializationData)
+ const InitializationData& initializationData)
{
InitializationData initData = initializationData;
initData.properties = createProperties(argc, argv, initializationData.properties);
@@ -452,7 +452,7 @@ Glacier2::RouterService::initializeCommunicator(int& argc, char* argv[],
//
if(initData.properties->getProperty("Ice.MonitorConnections").empty())
{
- initData.properties->setProperty("Ice.MonitorConnections", "60");
+ initData.properties->setProperty("Ice.MonitorConnections", "60");
}
//
@@ -470,30 +470,30 @@ void
Glacier2::RouterService::usage(const string& appName)
{
string options =
- "Options:\n"
- "-h, --help Show this message.\n"
- "-v, --version Display the Ice version.";
+ "Options:\n"
+ "-h, --help Show this message.\n"
+ "-v, --version Display the Ice version.";
#ifdef _WIN32
if(checkSystem())
{
options.append(
- "\n"
- "\n"
- "--service NAME Run as the Windows service NAME.\n"
- "\n"
- "--install NAME [--display DISP] [--executable EXEC] [args]\n"
- " Install as Windows service NAME. If DISP is\n"
- " provided, use it as the display name,\n"
- " otherwise NAME is used. If EXEC is provided,\n"
- " use it as the service executable, otherwise\n"
- " this executable is used. Any additional\n"
- " arguments are passed unchanged to the\n"
- " service at startup.\n"
- "--uninstall NAME Uninstall Windows service NAME.\n"
- "--start NAME [args] Start Windows service NAME. Any additional\n"
- " arguments are passed unchanged to the\n"
- " service.\n"
- "--stop NAME Stop Windows service NAME."
+ "\n"
+ "\n"
+ "--service NAME Run as the Windows service NAME.\n"
+ "\n"
+ "--install NAME [--display DISP] [--executable EXEC] [args]\n"
+ " Install as Windows service NAME. If DISP is\n"
+ " provided, use it as the display name,\n"
+ " otherwise NAME is used. If EXEC is provided,\n"
+ " use it as the service executable, otherwise\n"
+ " this executable is used. Any additional\n"
+ " arguments are passed unchanged to the\n"
+ " service at startup.\n"
+ "--uninstall NAME Uninstall Windows service NAME.\n"
+ "--start NAME [args] Start Windows service NAME. Any additional\n"
+ " arguments are passed unchanged to the\n"
+ " service.\n"
+ "--stop NAME Stop Windows service NAME."
);
}
#else
@@ -502,8 +502,8 @@ Glacier2::RouterService::usage(const string& appName)
"\n"
"--daemon Run as a daemon.\n"
"--noclose Do not close open file descriptors.\n"
- "--nochdir Do not change the current working directory.\n"
- "--pidfile <file> Write process ID to <file>."
+ "--nochdir Do not change the current working directory.\n"
+ "--pidfile <file> Write process ID to <file>."
);
#endif
print("Usage: " + appName + " [options]\n" + options);
diff --git a/cpp/src/Glacier2/ProxyVerifier.cpp b/cpp/src/Glacier2/ProxyVerifier.cpp
index b0666c696c4..a71c194eed2 100644
--- a/cpp/src/Glacier2/ProxyVerifier.cpp
+++ b/cpp/src/Glacier2/ProxyVerifier.cpp
@@ -43,67 +43,67 @@ parseGroup(const string& parameter, vector<int>& validPorts, vector<Range>& rang
istringstream istr(parameter);
while(!istr.eof())
{
- ws(istr);
- int value;
- if(!(istr >> value))
- {
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "expected number";
- throw ex;
- }
- ws(istr);
- if(!istr.eof())
- {
- char c;
- if(istr >> c)
- {
- if(c == ',')
- {
- validPorts.push_back(value);
- }
- else if(c == '-')
- {
- Range r;
- r.start = value;
- ws(istr);
- if(istr.eof())
- {
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "Unterminated range";
- throw ex;
- }
- if(!(istr >> value))
- {
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "expected number";
- throw ex;
- }
- r.end = value;
- ws(istr);
- if(!istr.eof())
- {
- istr >> c;
- if(c != ',')
- {
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "expected comma separator";
- throw ex;
- }
- }
- ranges.push_back(r);
- }
- else if(!istr.eof())
- {
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "unexpected trailing character";
- throw ex;
- }
- }
- }
- else
- {
- validPorts.push_back(value);
- }
+ ws(istr);
+ int value;
+ if(!(istr >> value))
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "expected number";
+ throw ex;
+ }
+ ws(istr);
+ if(!istr.eof())
+ {
+ char c;
+ if(istr >> c)
+ {
+ if(c == ',')
+ {
+ validPorts.push_back(value);
+ }
+ else if(c == '-')
+ {
+ Range r;
+ r.start = value;
+ ws(istr);
+ if(istr.eof())
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "Unterminated range";
+ throw ex;
+ }
+ if(!(istr >> value))
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "expected number";
+ throw ex;
+ }
+ r.end = value;
+ ws(istr);
+ if(!istr.eof())
+ {
+ istr >> c;
+ if(c != ',')
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "expected comma separator";
+ throw ex;
+ }
+ }
+ ranges.push_back(r);
+ }
+ else if(!istr.eof())
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "unexpected trailing character";
+ throw ex;
+ }
+ }
+ }
+ else
+ {
+ validPorts.push_back(value);
+ }
}
}
@@ -131,13 +131,13 @@ public:
bool
match(const string&, string::size_type&)
{
- return true;
+ return true;
}
const char*
toString() const
{
- return "(ANY)";
+ return "(ANY)";
}
};
@@ -150,27 +150,27 @@ class StartsWithString : public AddressMatcher
{
public:
StartsWithString(const string& criteria):
- _criteria(criteria),
- _description("starts with " + criteria)
+ _criteria(criteria),
+ _description("starts with " + criteria)
{
}
bool
match(const string& space, string::size_type& pos)
{
- assert(pos == 0);
- bool result = strncmp(space.c_str(), _criteria.c_str(), _criteria.size()) == 0;
- if(result)
- {
- pos += _criteria.size();
- }
- return result;
+ assert(pos == 0);
+ bool result = strncmp(space.c_str(), _criteria.c_str(), _criteria.size()) == 0;
+ if(result)
+ {
+ pos += _criteria.size();
+ }
+ return result;
}
const char*
toString() const
{
- return _description.c_str();
+ return _description.c_str();
}
private:
@@ -186,35 +186,35 @@ class EndsWithString : public AddressMatcher
{
public:
EndsWithString(const string& criteria):
- _criteria(criteria),
- _description("ends with " + criteria)
+ _criteria(criteria),
+ _description("ends with " + criteria)
{
}
bool
match(const string& space, string::size_type& pos)
{
- if(space.size() - pos < _criteria.size())
- {
- return false;
- }
+ if(space.size() - pos < _criteria.size())
+ {
+ return false;
+ }
- string::size_type spaceEnd = space.size();
- for(string::size_type i = _criteria.size(); i > 0; --i)
- {
- if(space[spaceEnd - 1] != _criteria[i-1])
- {
- return false;
- }
- --spaceEnd;
- }
- return true;
+ string::size_type spaceEnd = space.size();
+ for(string::size_type i = _criteria.size(); i > 0; --i)
+ {
+ if(space[spaceEnd - 1] != _criteria[i-1])
+ {
+ return false;
+ }
+ --spaceEnd;
+ }
+ return true;
}
virtual const char*
toString() const
{
- return _description.c_str();
+ return _description.c_str();
}
private:
@@ -226,26 +226,26 @@ class MatchesString : public AddressMatcher
{
public:
MatchesString(const string& criteria):
- _criteria(criteria),
- _description("matches " + criteria)
+ _criteria(criteria),
+ _description("matches " + criteria)
{
}
bool
match(const string& space, string::size_type& pos)
{
- if(strncmp(space.c_str(), _criteria.c_str(), _criteria.size()) == 0)
- {
- pos += _criteria.size();
- return true;
- }
- return false;
+ if(strncmp(space.c_str(), _criteria.c_str(), _criteria.size()) == 0)
+ {
+ pos += _criteria.size();
+ return true;
+ }
+ return false;
}
virtual const char*
toString() const
{
- return _description.c_str();
+ return _description.c_str();
}
private:
@@ -261,27 +261,27 @@ class ContainsString : public AddressMatcher
{
public:
ContainsString(const string& criteria):
- _criteria(criteria),
- _description("contains " + criteria)
+ _criteria(criteria),
+ _description("contains " + criteria)
{
}
bool
match(const string& space, string::size_type& pos)
{
- string::size_type offset = space.find(_criteria, pos);
- if(offset == string::npos)
- {
- return false;
- }
- pos = offset + _criteria.size() +1;
- return true;
+ string::size_type offset = space.find(_criteria, pos);
+ if(offset == string::npos)
+ {
+ return false;
+ }
+ pos = offset + _criteria.size() +1;
+ return true;
}
virtual const char*
toString() const
{
- return _description.c_str();
+ return _description.c_str();
}
private:
@@ -298,90 +298,90 @@ class MatchesNumber : public AddressMatcher
{
public:
MatchesNumber(const vector<int>& values, const vector<Range>& ranges,
- const char* descriptionPrefix = "matches "):
- _values(values),
- _ranges(ranges)
- {
- ostringstream ostr;
- ostr << descriptionPrefix;
- {
- bool start = true;
- for(vector<int>::const_iterator i = values.begin(); i != values.end(); ++i)
- {
- if(start)
- {
- if(values.size() > 1)
- {
- ostr << "one of ";
- }
- start = false;
- }
- else
- {
- ostr << ", ";
- }
-
- ostr << *i;
- }
- }
- if(values.size() > 0 && ranges.size() > 0)
- {
- ostr << " or ";
- }
- {
- bool start = true;
- for(vector<Range>::const_iterator i = ranges.begin(); i != ranges.end(); ++i)
- {
- if(start)
- {
- start = false;
- }
- else
- {
- ostr << ", or";
- }
- ostr << i->start << " up to " << i->end;
- }
- }
- ostr << ends;
- _description = ostr.str();
+ const char* descriptionPrefix = "matches "):
+ _values(values),
+ _ranges(ranges)
+ {
+ ostringstream ostr;
+ ostr << descriptionPrefix;
+ {
+ bool start = true;
+ for(vector<int>::const_iterator i = values.begin(); i != values.end(); ++i)
+ {
+ if(start)
+ {
+ if(values.size() > 1)
+ {
+ ostr << "one of ";
+ }
+ start = false;
+ }
+ else
+ {
+ ostr << ", ";
+ }
+
+ ostr << *i;
+ }
+ }
+ if(values.size() > 0 && ranges.size() > 0)
+ {
+ ostr << " or ";
+ }
+ {
+ bool start = true;
+ for(vector<Range>::const_iterator i = ranges.begin(); i != ranges.end(); ++i)
+ {
+ if(start)
+ {
+ start = false;
+ }
+ else
+ {
+ ostr << ", or";
+ }
+ ostr << i->start << " up to " << i->end;
+ }
+ }
+ ostr << ends;
+ _description = ostr.str();
}
bool
match(const string & space, string::size_type& pos)
{
- istringstream istr(space.substr(pos));
- int val;
- if(!(istr >> val))
- {
- return false;
- }
- pos += istr.tellg();
- {
- for(vector<int>::const_iterator i = _values.begin(); i != _values.end(); ++i)
- {
- if(val == *i)
- {
- return true;
- }
- }
- }
- {
- for(vector<Range>::const_iterator i = _ranges.begin(); i != _ranges.end(); ++i)
- {
- if((val >= i->start) && (val <= i->end))
- {
- return true;
- }
- }
- }
- return false;
+ istringstream istr(space.substr(pos));
+ int val;
+ if(!(istr >> val))
+ {
+ return false;
+ }
+ pos += istr.tellg();
+ {
+ for(vector<int>::const_iterator i = _values.begin(); i != _values.end(); ++i)
+ {
+ if(val == *i)
+ {
+ return true;
+ }
+ }
+ }
+ {
+ for(vector<Range>::const_iterator i = _ranges.begin(); i != _ranges.end(); ++i)
+ {
+ if((val >= i->start) && (val <= i->end))
+ {
+ return true;
+ }
+ }
+ }
+ return false;
}
virtual const char*
toString() const
{
- return _description.c_str();
+ return _description.c_str();
}
private:
@@ -397,27 +397,27 @@ class ContainsNumberMatch : public MatchesNumber
{
public:
ContainsNumberMatch(const vector<int>& values, const vector<Range>& ranges):
- MatchesNumber(values, ranges, "contains ")
+ MatchesNumber(values, ranges, "contains ")
{
}
bool
match(const string& space, string::size_type& pos)
{
- while(true)
- {
- pos = space.find_first_of("0123456789", pos);
- if(pos == string::npos)
- {
- return false;
- }
-
- if(MatchesNumber::match(space, pos))
- {
- return true;
- }
- }
- return false;
+ while(true)
+ {
+ pos = space.find_first_of("0123456789", pos);
+ if(pos == string::npos)
+ {
+ return false;
+ }
+
+ if(MatchesNumber::match(space, pos))
+ {
+ return true;
+ }
+ }
+ return false;
}
};
@@ -425,20 +425,20 @@ class EndsWithNumber : public MatchesNumber
{
public:
EndsWithNumber(const vector<int>& values, const vector<Range>& ranges):
- MatchesNumber(values, ranges, "ends with ")
+ MatchesNumber(values, ranges, "ends with ")
{
}
bool
match(const string& space, string::size_type& pos)
{
- pos = space.find_last_not_of("0123456789", pos);
- if(pos == space.size()-1)
- {
- return false;
- }
+ pos = space.find_last_not_of("0123456789", pos);
+ if(pos == space.size()-1)
+ {
+ return false;
+ }
- return MatchesNumber::match(space, pos);
+ return MatchesNumber::match(space, pos);
}
};
@@ -469,13 +469,13 @@ public:
AddressMatcher*
create(const string& criteria)
{
- return new StartsWithString(criteria);
+ return new StartsWithString(criteria);
}
AddressMatcher*
create(const vector<int>& ports, const vector<Range>& ranges)
{
- return new MatchesNumber(ports, ranges);
+ return new MatchesNumber(ports, ranges);
}
};
@@ -485,13 +485,13 @@ public:
AddressMatcher*
create(const string& criteria)
{
- return new ContainsString(criteria);
+ return new ContainsString(criteria);
}
AddressMatcher*
create(const vector<int>& ports, const vector<Range>& ranges)
{
- return new ContainsNumberMatch(ports, ranges);
+ return new ContainsNumberMatch(ports, ranges);
}
};
@@ -501,13 +501,13 @@ public:
AddressMatcher*
create(const string& criteria)
{
- return new MatchesString(criteria);
+ return new MatchesString(criteria);
}
AddressMatcher*
create(const vector<int>& ports, const vector<Range>& ranges)
{
- return new MatchesNumber(ports, ranges);
+ return new MatchesNumber(ports, ranges);
}
};
@@ -517,13 +517,13 @@ public:
AddressMatcher*
create(const string& criteria)
{
- return new EndsWithString(criteria);
+ return new EndsWithString(criteria);
}
AddressMatcher*
create(const vector<int>& ports, const vector<Range>& ranges)
{
- return new EndsWithNumber(ports, ranges);
+ return new EndsWithNumber(ports, ranges);
}
};
@@ -534,84 +534,84 @@ class AddressRule : public Glacier2::ProxyRule
{
public:
AddressRule(const CommunicatorPtr& communicator, const vector<AddressMatcher*>& address, MatchesNumber* port,
- const int traceLevel) :
- _communicator(communicator),
- _addressRules(address),
- _portMatcher(port),
- _traceLevel(traceLevel)
+ const int traceLevel) :
+ _communicator(communicator),
+ _addressRules(address),
+ _portMatcher(port),
+ _traceLevel(traceLevel)
{
}
~AddressRule()
{
- for(vector<AddressMatcher*>::const_iterator i = _addressRules.begin(); i != _addressRules.end(); ++i)
- {
- delete *i;
- }
- delete _portMatcher;
+ for(vector<AddressMatcher*>::const_iterator i = _addressRules.begin(); i != _addressRules.end(); ++i)
+ {
+ delete *i;
+ }
+ delete _portMatcher;
}
virtual bool
check(const ObjectPrx& prx) const
{
- EndpointSeq endpoints = prx->ice_getEndpoints();
- if(endpoints.size() == 0)
- {
- return false;
- }
-
- for(EndpointSeq::const_iterator i = endpoints.begin(); i != endpoints.end(); ++i)
- {
- string info = (*i)->toString();
- string host;
- if(!extractPart("-h ", info, host))
- {
- return false;
- }
- string port;
- if(!extractPart("-p ", info, port))
- {
- return false;
- }
- string::size_type pos = 0;
- if(!_portMatcher || _portMatcher->match(port, pos))
- {
- pos = 0;
- for(vector<AddressMatcher*>::const_iterator i = _addressRules.begin(); i != _addressRules.end(); ++i)
- {
- if(!(*i)->match(host, pos))
- {
- if(_traceLevel >= 3)
- {
- Trace out(_communicator->getLogger(), "Glacier2");
- out << (*i)->toString() << " failed to match " << host << " at pos=" << pos << "\n";
- }
- return false;
- }
- if(_traceLevel >= 3)
- {
- Trace out(_communicator->getLogger(), "Glacier2");
- out << (*i)->toString() << " matched " << host << " at pos=" << pos << "\n";
- }
- }
- }
- }
- return true;
+ EndpointSeq endpoints = prx->ice_getEndpoints();
+ if(endpoints.size() == 0)
+ {
+ return false;
+ }
+
+ for(EndpointSeq::const_iterator i = endpoints.begin(); i != endpoints.end(); ++i)
+ {
+ string info = (*i)->toString();
+ string host;
+ if(!extractPart("-h ", info, host))
+ {
+ return false;
+ }
+ string port;
+ if(!extractPart("-p ", info, port))
+ {
+ return false;
+ }
+ string::size_type pos = 0;
+ if(!_portMatcher || _portMatcher->match(port, pos))
+ {
+ pos = 0;
+ for(vector<AddressMatcher*>::const_iterator i = _addressRules.begin(); i != _addressRules.end(); ++i)
+ {
+ if(!(*i)->match(host, pos))
+ {
+ if(_traceLevel >= 3)
+ {
+ Trace out(_communicator->getLogger(), "Glacier2");
+ out << (*i)->toString() << " failed to match " << host << " at pos=" << pos << "\n";
+ }
+ return false;
+ }
+ if(_traceLevel >= 3)
+ {
+ Trace out(_communicator->getLogger(), "Glacier2");
+ out << (*i)->toString() << " matched " << host << " at pos=" << pos << "\n";
+ }
+ }
+ }
+ }
+ return true;
}
void
dump() const
{
- cerr << "address(";
- for(vector<AddressMatcher*>::const_iterator i = _addressRules.begin(); i != _addressRules.end(); ++i)
- {
- cerr << (*i)->toString() << " ";
- }
- if(_portMatcher != 0)
- {
- cerr << "):port(" << _portMatcher->toString() << " ";
- }
- cerr << ")" << endl;
+ cerr << "address(";
+ for(vector<AddressMatcher*>::const_iterator i = _addressRules.begin(); i != _addressRules.end(); ++i)
+ {
+ cerr << (*i)->toString() << " ";
+ }
+ if(_portMatcher != 0)
+ {
+ cerr << "):port(" << _portMatcher->toString() << " ";
+ }
+ cerr << ")" << endl;
}
private:
@@ -619,22 +619,22 @@ private:
bool
extractPart(const char* opt, const string& source, string& result) const
{
- string::size_type start = source.find(opt);
- if(start == string::npos)
- {
- return false;
- }
- start += strlen(opt);
- string::size_type end = source.find(' ', start);
- if(end != string::npos)
- {
- result = source.substr(start, end - start);
- }
- else
- {
- result = source.substr(start);
- }
- return true;
+ string::size_type start = source.find(opt);
+ if(start == string::npos)
+ {
+ return false;
+ }
+ start += strlen(opt);
+ string::size_type end = source.find(' ', start);
+ if(end != string::npos)
+ {
+ result = source.substr(start, end - start);
+ }
+ else
+ {
+ result = source.substr(start);
+ }
+ return true;
}
CommunicatorPtr _communicator;
@@ -645,7 +645,7 @@ private:
static void
parseProperty(const Ice::CommunicatorPtr& communicator, const string& property, vector<ProxyRule*>& rules,
- const int traceLevel)
+ const int traceLevel)
{
StartFactory startsWithFactory;
WildCardFactory wildCardFactory;
@@ -654,165 +654,165 @@ parseProperty(const Ice::CommunicatorPtr& communicator, const string& property,
vector<ProxyRule*> allRules;
try
{
- istringstream propertyInput(property);
-
- while(!propertyInput.eof() && propertyInput.good())
- {
- MatchesNumber* portMatch = 0;
- vector<AddressMatcher*> currentRuleSet;
-
- string parameter;
- ws(propertyInput);
- propertyInput >> parameter;
-
- string portInfo;
- string::size_type portPortion = parameter.find(':');
-
- string addr;
- if(portPortion != string::npos)
- {
- addr = parameter.substr(0, portPortion);
- string port = parameter.substr(portPortion + 1);
- string::size_type openBracket = port.find('[');
- if(openBracket != string::npos)
- {
- ++openBracket;
- string::size_type closeBracket = port.find(']', openBracket);
- if(closeBracket == string::npos)
- {
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "unclosed group";
- throw ex;
- }
- port = port.substr(openBracket, closeBracket-openBracket);
- }
- vector<int> ports;
- vector<Range> ranges;
- parseGroup(port, ports, ranges);
- portMatch = new MatchesNumber(ports, ranges);
- }
- else
- {
- addr = parameter;
- }
-
- //
- // The addr portion can contain alphanumerics, * and
- // ranges.
- //
- string::size_type current = 0;
-
- if(current == addr.size())
- {
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "expected address information before ':'";
- throw ex;
- }
-
- //
- // TODO: assuming that there is no leading or trailing whitespace. This
- // should probably be confirmed.
- //
- assert(!isspace(parameter[current]));
- assert(!isspace(addr[addr.size() -1]));
-
- if(current != 0)
- {
- addr = addr.substr(current);
- }
-
- string::size_type mark = 0;
- bool inGroup = false;
- AddressMatcherFactory* currentFactory = &startsWithFactory;
-
- if(addr == "*")
- {
- //
- // Special case. Match everything.
- //
- currentRuleSet.push_back(new MatchesAny);
- }
- else
- {
- for(current = 0; current < addr.size(); ++current)
- {
- if(addr[current] == '*')
- {
- if(inGroup)
- {
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "wildcards not permitted in groups";
- throw ex;
- }
- //
- // current == mark when the wildcard is at the head of a
- // string or directly after a group.
- //
- if(current != mark)
- {
- currentRuleSet.push_back(currentFactory->create(addr.substr(mark, current-mark)));
- }
- currentFactory = &wildCardFactory;
- mark = current + 1;
- }
- else if(addr[current] == '[')
- {
- // ??? what does it mean if current == mark?
- if(current != mark)
- {
- currentRuleSet.push_back(currentFactory->create(addr.substr(mark, current-mark)));
- currentFactory = &followingFactory;
- }
- inGroup = true;
- mark = current + 1;
- }
- else if(addr[current] == ']')
- {
- if(!inGroup)
- {
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "group close without group start";
- throw ex;
- }
- inGroup = false;
- if(mark == current)
- {
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "empty group";
- throw ex;
- }
- string group = addr.substr(mark, current - mark);
- vector<int> numbers;
- vector<Range> ranges;
- parseGroup(group, numbers, ranges);
- currentRuleSet.push_back(currentFactory->create(numbers, ranges));
- currentFactory = &followingFactory;
- mark = current + 1;
- }
- }
- currentFactory = &endsWithFactory;
-
- if(inGroup)
- {
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "unclosed group";
- throw ex;
- }
- if(mark != current)
- {
- currentRuleSet.push_back(currentFactory->create(addr.substr(mark, current - mark)));
- }
- }
- allRules.push_back(new AddressRule(communicator, currentRuleSet, portMatch, traceLevel));
- }
+ istringstream propertyInput(property);
+
+ while(!propertyInput.eof() && propertyInput.good())
+ {
+ MatchesNumber* portMatch = 0;
+ vector<AddressMatcher*> currentRuleSet;
+
+ string parameter;
+ ws(propertyInput);
+ propertyInput >> parameter;
+
+ string portInfo;
+ string::size_type portPortion = parameter.find(':');
+
+ string addr;
+ if(portPortion != string::npos)
+ {
+ addr = parameter.substr(0, portPortion);
+ string port = parameter.substr(portPortion + 1);
+ string::size_type openBracket = port.find('[');
+ if(openBracket != string::npos)
+ {
+ ++openBracket;
+ string::size_type closeBracket = port.find(']', openBracket);
+ if(closeBracket == string::npos)
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "unclosed group";
+ throw ex;
+ }
+ port = port.substr(openBracket, closeBracket-openBracket);
+ }
+ vector<int> ports;
+ vector<Range> ranges;
+ parseGroup(port, ports, ranges);
+ portMatch = new MatchesNumber(ports, ranges);
+ }
+ else
+ {
+ addr = parameter;
+ }
+
+ //
+ // The addr portion can contain alphanumerics, * and
+ // ranges.
+ //
+ string::size_type current = 0;
+
+ if(current == addr.size())
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "expected address information before ':'";
+ throw ex;
+ }
+
+ //
+ // TODO: assuming that there is no leading or trailing whitespace. This
+ // should probably be confirmed.
+ //
+ assert(!isspace(parameter[current]));
+ assert(!isspace(addr[addr.size() -1]));
+
+ if(current != 0)
+ {
+ addr = addr.substr(current);
+ }
+
+ string::size_type mark = 0;
+ bool inGroup = false;
+ AddressMatcherFactory* currentFactory = &startsWithFactory;
+
+ if(addr == "*")
+ {
+ //
+ // Special case. Match everything.
+ //
+ currentRuleSet.push_back(new MatchesAny);
+ }
+ else
+ {
+ for(current = 0; current < addr.size(); ++current)
+ {
+ if(addr[current] == '*')
+ {
+ if(inGroup)
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "wildcards not permitted in groups";
+ throw ex;
+ }
+ //
+ // current == mark when the wildcard is at the head of a
+ // string or directly after a group.
+ //
+ if(current != mark)
+ {
+ currentRuleSet.push_back(currentFactory->create(addr.substr(mark, current-mark)));
+ }
+ currentFactory = &wildCardFactory;
+ mark = current + 1;
+ }
+ else if(addr[current] == '[')
+ {
+ // ??? what does it mean if current == mark?
+ if(current != mark)
+ {
+ currentRuleSet.push_back(currentFactory->create(addr.substr(mark, current-mark)));
+ currentFactory = &followingFactory;
+ }
+ inGroup = true;
+ mark = current + 1;
+ }
+ else if(addr[current] == ']')
+ {
+ if(!inGroup)
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "group close without group start";
+ throw ex;
+ }
+ inGroup = false;
+ if(mark == current)
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "empty group";
+ throw ex;
+ }
+ string group = addr.substr(mark, current - mark);
+ vector<int> numbers;
+ vector<Range> ranges;
+ parseGroup(group, numbers, ranges);
+ currentRuleSet.push_back(currentFactory->create(numbers, ranges));
+ currentFactory = &followingFactory;
+ mark = current + 1;
+ }
+ }
+ currentFactory = &endsWithFactory;
+
+ if(inGroup)
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "unclosed group";
+ throw ex;
+ }
+ if(mark != current)
+ {
+ currentRuleSet.push_back(currentFactory->create(addr.substr(mark, current - mark)));
+ }
+ }
+ allRules.push_back(new AddressRule(communicator, currentRuleSet, portMatch, traceLevel));
+ }
}
catch(...)
{
- for(vector<ProxyRule*>::const_iterator i = allRules.begin(); i != allRules.end(); ++i)
- {
- delete *i;
- }
- throw;
+ for(vector<ProxyRule*>::const_iterator i = allRules.begin(); i != allRules.end(); ++i)
+ {
+ delete *i;
+ }
+ throw;
}
rules = allRules;
}
@@ -825,10 +825,10 @@ match(const vector<ProxyRule*>& rules, const ObjectPrx& proxy)
{
for(vector<ProxyRule*>::const_iterator i = rules.begin(); i != rules.end(); ++i)
{
- if((*i)->check(proxy))
- {
- return true;
- }
+ if((*i)->check(proxy))
+ {
+ return true;
+ }
}
return false;
}
@@ -841,36 +841,36 @@ class ProxyLengthRule : public ProxyRule
{
public:
ProxyLengthRule(const CommunicatorPtr communicator, const string& count, int traceLevel) :
- _communicator(communicator),
- _traceLevel(traceLevel)
- {
- istringstream s(count);
- if(!(s >> _count) || !s.eof())
- {
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "Error parsing ProxySizeMax property";
- throw ex;
- }
- if(_count <= 0)
- {
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "ProxySizeMax must be greater than 1";
- throw ex;
- }
+ _communicator(communicator),
+ _traceLevel(traceLevel)
+ {
+ istringstream s(count);
+ if(!(s >> _count) || !s.eof())
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "Error parsing ProxySizeMax property";
+ throw ex;
+ }
+ if(_count <= 0)
+ {
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "ProxySizeMax must be greater than 1";
+ throw ex;
+ }
}
bool
check(const ObjectPrx& p) const
{
- string s = p->ice_toString();
- bool result = (s.size() > _count);
- if(_traceLevel >= 1)
- {
- Trace out(_communicator->getLogger(), "Glacier2");
- out << _communicator->proxyToString(p) << (result ? " exceeds " : " meets ")
- << "proxy size restriction\n";
- }
- return result;
+ string s = p->ice_toString();
+ bool result = (s.size() > _count);
+ if(_traceLevel >= 1)
+ {
+ Trace out(_communicator->getLogger(), "Glacier2");
+ out << _communicator->proxyToString(p) << (result ? " exceeds " : " meets ")
+ << "proxy size restriction\n";
+ }
+ return result;
}
private:
@@ -892,19 +892,19 @@ Glacier2::ProxyVerifier::ProxyVerifier(const CommunicatorPtr& communicator, cons
string s = communicator->getProperties()->getProperty("Glacier2.Filter.Address.Accept");
if(s != "")
{
- Glacier2::parseProperty(communicator, s, _acceptRules, _traceLevel);
+ Glacier2::parseProperty(communicator, s, _acceptRules, _traceLevel);
}
s = communicator->getProperties()->getProperty("Glacier2.Filter.Address.Reject");
if(s != "")
{
- Glacier2::parseProperty(communicator, s, _rejectRules, _traceLevel);
+ Glacier2::parseProperty(communicator, s, _rejectRules, _traceLevel);
}
s = communicator->getProperties()->getProperty("Glacier2.Filter.ProxySizeMax");
if(s != "")
{
- _rejectRules.push_back(new ProxyLengthRule(communicator, s, _traceLevel));
+ _rejectRules.push_back(new ProxyLengthRule(communicator, s, _traceLevel));
}
}
@@ -912,11 +912,11 @@ Glacier2::ProxyVerifier::~ProxyVerifier()
{
for(vector<ProxyRule*>::const_iterator i = _acceptRules.begin(); i != _acceptRules.end(); ++i)
{
- delete (*i);
+ delete (*i);
}
for(vector<ProxyRule*>::const_iterator j = _rejectRules.begin(); j != _rejectRules.end(); ++j)
{
- delete (*j);
+ delete (*j);
}
}
@@ -928,31 +928,31 @@ Glacier2::ProxyVerifier::verify(const ObjectPrx& proxy)
//
if(_acceptRules.size() == 0 && _rejectRules.size() == 0)
{
- return true;
+ return true;
}
bool result = false;
if(_rejectRules.size() == 0)
{
- //
- // If there are no reject rules, we assume "reject all".
- //
- result = match(_acceptRules, proxy);
+ //
+ // If there are no reject rules, we assume "reject all".
+ //
+ result = match(_acceptRules, proxy);
}
else if(_acceptRules.size() == 0)
{
- //
- // If no accept rules are defined we assume accept all.
- //
- result = !match(_rejectRules, proxy);
+ //
+ // If no accept rules are defined we assume accept all.
+ //
+ result = !match(_rejectRules, proxy);
}
else
{
- if(match(_acceptRules, proxy))
- {
- result = !match(_rejectRules, proxy);
- }
+ if(match(_acceptRules, proxy))
+ {
+ result = !match(_rejectRules, proxy);
+ }
}
//
@@ -960,15 +960,15 @@ Glacier2::ProxyVerifier::verify(const ObjectPrx& proxy)
//
if(_traceLevel > 0)
{
- Trace out(_communicator->getLogger(), "Glacier2");
- if(result)
- {
- out << "accepted proxy " << _communicator->proxyToString(proxy) << '\n';
- }
- else
- {
- out << "rejected proxy " << _communicator->proxyToString(proxy) << '\n';
- }
+ Trace out(_communicator->getLogger(), "Glacier2");
+ if(result)
+ {
+ out << "accepted proxy " << _communicator->proxyToString(proxy) << '\n';
+ }
+ else
+ {
+ out << "rejected proxy " << _communicator->proxyToString(proxy) << '\n';
+ }
}
return result;
}
diff --git a/cpp/src/Glacier2/RequestQueue.cpp b/cpp/src/Glacier2/RequestQueue.cpp
index 55f700a0d65..099b73f3640 100644
--- a/cpp/src/Glacier2/RequestQueue.cpp
+++ b/cpp/src/Glacier2/RequestQueue.cpp
@@ -30,22 +30,22 @@ class AMI_Array_Object_ice_invokeI : public AMI_Array_Object_ice_invoke
public:
AMI_Array_Object_ice_invokeI(const RequestQueuePtr& requestQueue, const AMD_Array_Object_ice_invokePtr& amdCB) :
- _requestQueue(requestQueue),
- _amdCB(amdCB)
+ _requestQueue(requestQueue),
+ _amdCB(amdCB)
{
- assert(_amdCB);
+ assert(_amdCB);
}
virtual void
ice_response(bool ok, const pair<const Byte*, const Byte*>& outParams)
{
- _requestQueue->addResponse(new Response(_amdCB, ok, outParams));
+ _requestQueue->addResponse(new Response(_amdCB, ok, outParams));
}
virtual void
ice_exception(const Exception& ex)
{
- _requestQueue->addResponse(new Response(_amdCB, ex));
+ _requestQueue->addResponse(new Response(_amdCB, ex));
}
private:
@@ -57,8 +57,8 @@ private:
}
Glacier2::Request::Request(const ObjectPrx& proxy, const std::pair<const Byte*, const Byte*>& inParams,
- const Current& current, bool forwardContext, const Ice::Context& sslContext,
- const AMD_Array_Object_ice_invokePtr& amdCB) :
+ const Current& current, bool forwardContext, const Ice::Context& sslContext,
+ const AMD_Array_Object_ice_invokePtr& amdCB) :
_proxy(proxy),
_inParams(inParams.first, inParams.second),
_current(current),
@@ -72,15 +72,15 @@ Glacier2::Request::Request(const ObjectPrx& proxy, const std::pair<const Byte*,
//
if(!_proxy->ice_isTwoway())
{
- bool ok = true;
- pair<const Byte*, const Byte*> outParams(0, 0);
- _amdCB->ice_response(ok, outParams);
+ bool ok = true;
+ pair<const Byte*, const Byte*> outParams(0, 0);
+ _amdCB->ice_response(ok, outParams);
}
Context::const_iterator p = current.ctx.find("_ovrd");
if(p != current.ctx.end())
{
- const_cast<string&>(_override) = p->second;
+ const_cast<string&>(_override) = p->second;
}
}
@@ -96,71 +96,71 @@ Glacier2::Request::invoke(const RequestQueuePtr& requestQueue)
else
{
inPair.first = &_inParams[0];
- inPair.second = inPair.first + _inParams.size();
+ inPair.second = inPair.first + _inParams.size();
}
if(_proxy->ice_isTwoway())
{
- AMI_Array_Object_ice_invokePtr cb = new AMI_Array_Object_ice_invokeI(requestQueue, _amdCB);
- if(_forwardContext)
- {
- if(_sslContext.size() > 0)
- {
- Ice::Context ctx = _current.ctx;
- ctx.insert(_sslContext.begin(), _sslContext.end());
- _proxy->ice_invoke_async(cb, _current.operation, _current.mode, inPair, ctx);
- }
- else
- {
- _proxy->ice_invoke_async(cb, _current.operation, _current.mode, inPair, _current.ctx);
- }
- }
- else
- {
- if(_sslContext.size() > 0)
- {
- _proxy->ice_invoke_async(cb, _current.operation, _current.mode, inPair, _sslContext);
- }
- else
- {
- _proxy->ice_invoke_async(cb, _current.operation, _current.mode, inPair);
- }
- }
- return true; // A twoway method is being dispatched.
+ AMI_Array_Object_ice_invokePtr cb = new AMI_Array_Object_ice_invokeI(requestQueue, _amdCB);
+ if(_forwardContext)
+ {
+ if(_sslContext.size() > 0)
+ {
+ Ice::Context ctx = _current.ctx;
+ ctx.insert(_sslContext.begin(), _sslContext.end());
+ _proxy->ice_invoke_async(cb, _current.operation, _current.mode, inPair, ctx);
+ }
+ else
+ {
+ _proxy->ice_invoke_async(cb, _current.operation, _current.mode, inPair, _current.ctx);
+ }
+ }
+ else
+ {
+ if(_sslContext.size() > 0)
+ {
+ _proxy->ice_invoke_async(cb, _current.operation, _current.mode, inPair, _sslContext);
+ }
+ else
+ {
+ _proxy->ice_invoke_async(cb, _current.operation, _current.mode, inPair);
+ }
+ }
+ return true; // A twoway method is being dispatched.
}
else
{
- try
- {
- ByteSeq outParams;
- if(_forwardContext)
- {
- if(_sslContext.size() > 0)
- {
- Ice::Context ctx = _current.ctx;
- ctx.insert(_sslContext.begin(), _sslContext.end());
- _proxy->ice_invoke(_current.operation, _current.mode, inPair, outParams, ctx);
- }
- else
- {
- _proxy->ice_invoke(_current.operation, _current.mode, inPair, outParams, _current.ctx);
- }
- }
- else
- {
- if(_sslContext.size() > 0)
- {
- _proxy->ice_invoke(_current.operation, _current.mode, inPair, outParams, _sslContext);
- }
- else
- {
- _proxy->ice_invoke(_current.operation, _current.mode, inPair, outParams);
- }
- }
- }
- catch(const LocalException&)
- {
- }
- return false;
+ try
+ {
+ ByteSeq outParams;
+ if(_forwardContext)
+ {
+ if(_sslContext.size() > 0)
+ {
+ Ice::Context ctx = _current.ctx;
+ ctx.insert(_sslContext.begin(), _sslContext.end());
+ _proxy->ice_invoke(_current.operation, _current.mode, inPair, outParams, ctx);
+ }
+ else
+ {
+ _proxy->ice_invoke(_current.operation, _current.mode, inPair, outParams, _current.ctx);
+ }
+ }
+ else
+ {
+ if(_sslContext.size() > 0)
+ {
+ _proxy->ice_invoke(_current.operation, _current.mode, inPair, outParams, _sslContext);
+ }
+ else
+ {
+ _proxy->ice_invoke(_current.operation, _current.mode, inPair, outParams);
+ }
+ }
+ }
+ catch(const LocalException&)
+ {
+ }
+ return false;
}
}
@@ -172,7 +172,7 @@ Glacier2::Request::override(const RequestPtr& other) const
//
if(_override.empty() || other->_override.empty())
{
- return false;
+ return false;
}
//
@@ -181,7 +181,7 @@ Glacier2::Request::override(const RequestPtr& other) const
//
if(_proxy->ice_isTwoway() || other->_proxy->ice_isTwoway())
{
- return false;
+ return false;
}
//
@@ -189,7 +189,7 @@ Glacier2::Request::override(const RequestPtr& other) const
//
if(_proxy != other->_proxy)
{
- return false;
+ return false;
}
return _override == other->_override;
@@ -208,7 +208,7 @@ Glacier2::Request::getConnection() const
}
Glacier2::Response::Response(const AMD_Array_Object_ice_invokePtr& amdCB, bool ok,
- const pair<const Byte*, const Byte*>& outParams) :
+ const pair<const Byte*, const Byte*>& outParams) :
_amdCB(amdCB),
_ok(ok),
_outParams(outParams.first, outParams.second)
@@ -227,21 +227,21 @@ Glacier2::Response::invoke()
{
if(_exception.get())
{
- _amdCB->ice_exception(*_exception.get());
+ _amdCB->ice_exception(*_exception.get());
}
else
{
pair<const Byte*, const Byte*> outPair;
- if(_outParams.size() == 0)
- {
- outPair.first = outPair.second = 0;
- }
- else
- {
- outPair.first = &_outParams[0];
- outPair.second = outPair.first + _outParams.size();
- }
- _amdCB->ice_response(_ok, outPair);
+ if(_outParams.size() == 0)
+ {
+ outPair.first = outPair.second = 0;
+ }
+ else
+ {
+ outPair.first = &_outParams[0];
+ outPair.second = outPair.first + _outParams.size();
+ }
+ _amdCB->ice_response(_ok, outPair);
}
}
@@ -265,12 +265,12 @@ void
Glacier2::RequestQueue::destroy()
{
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
-
- assert(!_destroy);
- _destroy = true;
- _sleep = false;
- notify();
+ IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
+
+ assert(!_destroy);
+ _destroy = true;
+ _sleep = false;
+ notify();
}
//
@@ -295,14 +295,14 @@ Glacier2::RequestQueue::addRequest(const RequestPtr& request)
for(vector<RequestPtr>::iterator p = _requests.begin(); p != _requests.end(); ++p)
{
- //
+ //
// If the new request overrides an old one, then abort the old
// request and replace it with the new request.
- //
+ //
if(request->override(*p))
{
*p = request;
- return true;
+ return true;
}
}
@@ -312,11 +312,11 @@ Glacier2::RequestQueue::addRequest(const RequestPtr& request)
_requests.push_back(request);
if(!_sleep)
{
- //
- // No need to notify if the request queue thread is sleeping,
- // once it wakes up it will check if there's requests to send.
- //
- notify();
+ //
+ // No need to notify if the request queue thread is sleeping,
+ // once it wakes up it will check if there's requests to send.
+ //
+ notify();
}
return false;
}
@@ -336,73 +336,73 @@ Glacier2::RequestQueue::run()
ptrdiff_t dispatchCount = 0; // The dispatch count keeps track of the number of outstanding twoway requests.
while(true)
{
- vector<RequestPtr> requests;
- vector<ResponsePtr> responses;
+ vector<RequestPtr> requests;
+ vector<ResponsePtr> responses;
{
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
- //
- // Wait indefinitely if there's no requests/responses to
- // send. If the queue is being destroyed we still need to
- // wait until all the responses for twoway requests are
- // received.
- //
+ //
+ // Wait indefinitely if there's no requests/responses to
+ // send. If the queue is being destroyed we still need to
+ // wait until all the responses for twoway requests are
+ // received.
+ //
while((!_destroy || dispatchCount != 0) && _responses.empty() && (_requests.empty() || _sleep))
{
- if(_sleep)
- {
- IceUtil::Time now = IceUtil::Time::now();
- if(!timedWait(_sleepDuration))
- {
- _sleepDuration = IceUtil::Time();
- }
- else
- {
- _sleepDuration -= IceUtil::Time::now() - now;
- }
- if(_sleepDuration <= IceUtil::Time())
- {
- _sleep = false;
- }
- }
- else
- {
- wait();
- }
+ if(_sleep)
+ {
+ IceUtil::Time now = IceUtil::Time::now();
+ if(!timedWait(_sleepDuration))
+ {
+ _sleepDuration = IceUtil::Time();
+ }
+ else
+ {
+ _sleepDuration -= IceUtil::Time::now() - now;
+ }
+ if(_sleepDuration <= IceUtil::Time())
+ {
+ _sleep = false;
+ }
+ }
+ else
+ {
+ wait();
+ }
}
- //
- // If the queue is being destroyed and there's no requests
- // or responses to send, we're done.
- //
+ //
+ // If the queue is being destroyed and there's no requests
+ // or responses to send, we're done.
+ //
if(_destroy && _requests.empty() && _responses.empty())
{
- assert(dispatchCount == 0); // We would have blocked in the wait() above otherwise.
+ assert(dispatchCount == 0); // We would have blocked in the wait() above otherwise.
return;
}
- //
- // If there's requests to sent and we're not sleeping,
- // send the requests. If a sleep time is configured, we
- // set the sleep duration and set the sleep flag to make
- // sure we'll sleep again once we're done sending requests
- // and responses.
- //
- if(!_requests.empty() && !_sleep)
- {
- requests.swap(_requests);
- if(_sleepTime > IceUtil::Time())
- {
- _sleep = true;
- _sleepDuration = _sleepTime;
- }
- }
- if(!_responses.empty())
- {
- responses.swap(_responses);
- }
- }
+ //
+ // If there's requests to sent and we're not sleeping,
+ // send the requests. If a sleep time is configured, we
+ // set the sleep duration and set the sleep flag to make
+ // sure we'll sleep again once we're done sending requests
+ // and responses.
+ //
+ if(!_requests.empty() && !_sleep)
+ {
+ requests.swap(_requests);
+ if(_sleepTime > IceUtil::Time())
+ {
+ _sleep = true;
+ _sleepDuration = _sleepTime;
+ }
+ }
+ if(!_responses.empty())
+ {
+ responses.swap(_responses);
+ }
+ }
//
// Send requests, flush batch requests, and sleep outside the
@@ -410,53 +410,53 @@ Glacier2::RequestQueue::run()
// while this is being done.
//
- set<ConnectionPtr> flushSet;
-
- for(vector<RequestPtr>::const_iterator p = requests.begin(); p != requests.end(); ++p)
- {
- if((*p)->isBatch())
- {
- try
- {
- flushSet.insert((*p)->getConnection());
- }
- catch(const LocalException&)
- {
- // Ignore.
- }
- }
-
- //
- // Invoke returns true if the request expects a response.
- // If that's the case we increment the dispatch count to
- // ensure that the thread won't be destroyed before the
- // response is received.
- //
- if((*p)->invoke(self)) // Exceptions are caught within invoke().
- {
- ++dispatchCount;
- }
- }
-
- for(set<ConnectionPtr>::const_iterator q = flushSet.begin(); q != flushSet.end(); ++q)
- {
- try
- {
- (*q)->flushBatchRequests();
- }
- catch(const LocalException&)
- {
- // Ignore.
- }
- }
-
- //
- // Send the responses and decrement the dispatch count.
- //
- for(vector<ResponsePtr>::const_iterator r = responses.begin(); r != responses.end(); ++r)
- {
- (*r)->invoke();
- }
- dispatchCount -= responses.size();
+ set<ConnectionPtr> flushSet;
+
+ for(vector<RequestPtr>::const_iterator p = requests.begin(); p != requests.end(); ++p)
+ {
+ if((*p)->isBatch())
+ {
+ try
+ {
+ flushSet.insert((*p)->getConnection());
+ }
+ catch(const LocalException&)
+ {
+ // Ignore.
+ }
+ }
+
+ //
+ // Invoke returns true if the request expects a response.
+ // If that's the case we increment the dispatch count to
+ // ensure that the thread won't be destroyed before the
+ // response is received.
+ //
+ if((*p)->invoke(self)) // Exceptions are caught within invoke().
+ {
+ ++dispatchCount;
+ }
+ }
+
+ for(set<ConnectionPtr>::const_iterator q = flushSet.begin(); q != flushSet.end(); ++q)
+ {
+ try
+ {
+ (*q)->flushBatchRequests();
+ }
+ catch(const LocalException&)
+ {
+ // Ignore.
+ }
+ }
+
+ //
+ // Send the responses and decrement the dispatch count.
+ //
+ for(vector<ResponsePtr>::const_iterator r = responses.begin(); r != responses.end(); ++r)
+ {
+ (*r)->invoke();
+ }
+ dispatchCount -= responses.size();
}
}
diff --git a/cpp/src/Glacier2/RequestQueue.h b/cpp/src/Glacier2/RequestQueue.h
index 7a9e4db280d..2599b24f7aa 100644
--- a/cpp/src/Glacier2/RequestQueue.h
+++ b/cpp/src/Glacier2/RequestQueue.h
@@ -28,7 +28,7 @@ class Request : public IceUtil::Shared
public:
Request(const Ice::ObjectPrx&, const std::pair<const Ice::Byte*, const Ice::Byte*>&, const Ice::Current&, bool,
- const Ice::Context&, const Ice::AMD_Array_Object_ice_invokePtr&);
+ const Ice::Context&, const Ice::AMD_Array_Object_ice_invokePtr&);
bool invoke(const RequestQueuePtr&);
bool override(const RequestPtr&) const;
diff --git a/cpp/src/Glacier2/RouterI.cpp b/cpp/src/Glacier2/RouterI.cpp
index c3f34f4c4d6..ff917e8b445 100644
--- a/cpp/src/Glacier2/RouterI.cpp
+++ b/cpp/src/Glacier2/RouterI.cpp
@@ -19,9 +19,9 @@ using namespace Ice;
using namespace Glacier2;
Glacier2::RouterI::RouterI(const ObjectAdapterPtr& clientAdapter, const ObjectAdapterPtr& serverAdapter,
- const ConnectionPtr& connection, const string& userId, const SessionPrx& session,
- const Identity& controlId, const FilterManagerPtr& filters,
- const Ice::Context& sslContext) :
+ const ConnectionPtr& connection, const string& userId, const SessionPrx& session,
+ const Identity& controlId, const FilterManagerPtr& filters,
+ const Ice::Context& sslContext) :
_communicator(clientAdapter->getCommunicator()),
_clientBlobject(new ClientBlobject(_communicator, filters, sslContext)),
_serverAdapter(serverAdapter),
@@ -39,26 +39,26 @@ Glacier2::RouterI::RouterI(const ObjectAdapterPtr& clientAdapter, const ObjectAd
if(_communicator->getProperties()->getPropertyAsInt("Glacier2.ReturnClientProxy") > 0)
{
const_cast<Ice::ObjectPrx&>(_clientProxy) =
- clientAdapter->createProxy(_communicator->stringToIdentity("dummy"));
+ clientAdapter->createProxy(_communicator->stringToIdentity("dummy"));
}
if(serverAdapter)
{
- ObjectPrx& serverProxy = const_cast<ObjectPrx&>(_serverProxy);
- Identity ident;
- ident.name = "dummy";
- ident.category.resize(20);
- char buf[20];
- IceUtil::generateRandom(buf, static_cast<int>(sizeof(buf)));
- for(unsigned int i = 0; i < sizeof(buf); ++i)
- {
- const unsigned char c = static_cast<unsigned char>(buf[i]); // A value between 0-255
- ident.category[i] = 33 + c % (127-33); // We use ASCII 33-126 (from ! to ~, w/o space).
- }
- serverProxy = serverAdapter->createProxy(ident);
-
- ServerBlobjectPtr& serverBlobject = const_cast<ServerBlobjectPtr&>(_serverBlobject);
- serverBlobject = new ServerBlobject(_communicator, _connection);
+ ObjectPrx& serverProxy = const_cast<ObjectPrx&>(_serverProxy);
+ Identity ident;
+ ident.name = "dummy";
+ ident.category.resize(20);
+ char buf[20];
+ IceUtil::generateRandom(buf, static_cast<int>(sizeof(buf)));
+ for(unsigned int i = 0; i < sizeof(buf); ++i)
+ {
+ const unsigned char c = static_cast<unsigned char>(buf[i]); // A value between 0-255
+ ident.category[i] = 33 + c % (127-33); // We use ASCII 33-126 (from ! to ~, w/o space).
+ }
+ serverProxy = serverAdapter->createProxy(ident);
+
+ ServerBlobjectPtr& serverBlobject = const_cast<ServerBlobjectPtr&>(_serverBlobject);
+ serverBlobject = new ServerBlobject(_communicator, _connection);
}
}
@@ -75,43 +75,43 @@ Glacier2::RouterI::destroy()
if(_serverBlobject)
{
- _serverBlobject->destroy();
+ _serverBlobject->destroy();
}
if(_session)
{
if(_serverAdapter)
- {
- try
- {
- //
- // Remove the session control object.
- //
- _serverAdapter->remove(_controlId);
- }
- catch(const NotRegisteredException&)
- {
- }
- catch(const ObjectAdapterDeactivatedException&)
- {
- //
- // Expected if the router has been shutdown.
- //
- }
- }
-
- //
- // This can raise an exception, therefore it must be the last
- // statement in this destroy() function.
- //
- if(_sslContext.size() > 0)
- {
- _session->destroy(_sslContext);
- }
- else
- {
- _session->destroy();
- }
+ {
+ try
+ {
+ //
+ // Remove the session control object.
+ //
+ _serverAdapter->remove(_controlId);
+ }
+ catch(const NotRegisteredException&)
+ {
+ }
+ catch(const ObjectAdapterDeactivatedException&)
+ {
+ //
+ // Expected if the router has been shutdown.
+ //
+ }
+ }
+
+ //
+ // This can raise an exception, therefore it must be the last
+ // statement in this destroy() function.
+ //
+ if(_sslContext.size() > 0)
+ {
+ _session->destroy(_sslContext);
+ }
+ else
+ {
+ _session->destroy();
+ }
}
}
@@ -231,7 +231,7 @@ Glacier2::RouterI::toString() const
out << "id = " << _userId << '\n';
if(_serverProxy)
{
- out << "category = " << _serverProxy->ice_getIdentity().category << '\n';
+ out << "category = " << _serverProxy->ice_getIdentity().category << '\n';
}
out << _connection->toString();
diff --git a/cpp/src/Glacier2/RouterI.h b/cpp/src/Glacier2/RouterI.h
index c046413c7c3..64bccd5d50c 100644
--- a/cpp/src/Glacier2/RouterI.h
+++ b/cpp/src/Glacier2/RouterI.h
@@ -31,7 +31,7 @@ public:
RouterI(const Ice::ObjectAdapterPtr&, const Ice::ObjectAdapterPtr&, const Ice::ConnectionPtr&, const std::string&,
const SessionPrx&, const Ice::Identity&, const FilterManagerPtr&, const Ice::Context& sslContext);
-
+
virtual ~RouterI();
void destroy();
diff --git a/cpp/src/Glacier2/RoutingTable.cpp b/cpp/src/Glacier2/RoutingTable.cpp
index 6a366130837..b5f73e7ed10 100644
--- a/cpp/src/Glacier2/RoutingTable.cpp
+++ b/cpp/src/Glacier2/RoutingTable.cpp
@@ -35,69 +35,69 @@ Glacier2::RoutingTable::add(const ObjectProxySeq& unfiltered, const Ice::Current
ObjectProxySeq::const_iterator prx;
for(prx = unfiltered.begin(); prx != unfiltered.end(); ++prx)
{
- if(!*prx) // We ignore null proxies.
- {
- continue;
- }
+ if(!*prx) // We ignore null proxies.
+ {
+ continue;
+ }
- if(!_verifier.verify(*prx))
- {
- current.con->close(true);
- throw ObjectNotExistException(__FILE__, __LINE__);
- }
- ObjectPrx proxy = (*prx)->ice_twoway()->ice_secure(false)->ice_facet(""); // We add proxies in default form.
- proxies.push_back(proxy);
+ if(!_verifier.verify(*prx))
+ {
+ current.con->close(true);
+ throw ObjectNotExistException(__FILE__, __LINE__);
+ }
+ ObjectPrx proxy = (*prx)->ice_twoway()->ice_secure(false)->ice_facet(""); // We add proxies in default form.
+ proxies.push_back(proxy);
}
ObjectProxySeq evictedProxies;
for(prx = proxies.begin(); prx != proxies.end(); ++prx)
{
- ObjectPrx proxy = *prx;
- EvictorMap::iterator p = _map.find(proxy->ice_getIdentity());
-
- if(p == _map.end())
- {
- if(_traceLevel == 1 || _traceLevel >= 3)
- {
- Trace out(_communicator->getLogger(), "Glacier2");
- out << "adding proxy to routing table:\n" << _communicator->proxyToString(proxy);
- }
-
- EvictorEntryPtr entry = new EvictorEntry;
- p = _map.insert(_map.begin(), pair<const Identity, EvictorEntryPtr>(proxy->ice_getIdentity(), entry));
- EvictorQueue::iterator q = _queue.insert(_queue.end(), p);
- entry->proxy = proxy;
- entry->pos = q;
- }
- else
- {
- if(_traceLevel == 1 || _traceLevel >= 3)
- {
- Trace out(_communicator->getLogger(), "Glacier2");
- out << "proxy already in routing table:\n" << _communicator->proxyToString(proxy);
- }
-
- EvictorEntryPtr entry = p->second;
- _queue.erase(entry->pos);
- EvictorQueue::iterator q = _queue.insert(_queue.end(), p);
- entry->pos = q;
- }
-
- while(static_cast<int>(_map.size()) > _maxSize)
- {
- p = _queue.front();
-
- if(_traceLevel >= 2)
- {
- Trace out(_communicator->getLogger(), "Glacier2");
- out << "evicting proxy from routing table:\n" << _communicator->proxyToString(p->second->proxy);
- }
-
- evictedProxies.push_back(p->second->proxy);
+ ObjectPrx proxy = *prx;
+ EvictorMap::iterator p = _map.find(proxy->ice_getIdentity());
+
+ if(p == _map.end())
+ {
+ if(_traceLevel == 1 || _traceLevel >= 3)
+ {
+ Trace out(_communicator->getLogger(), "Glacier2");
+ out << "adding proxy to routing table:\n" << _communicator->proxyToString(proxy);
+ }
+
+ EvictorEntryPtr entry = new EvictorEntry;
+ p = _map.insert(_map.begin(), pair<const Identity, EvictorEntryPtr>(proxy->ice_getIdentity(), entry));
+ EvictorQueue::iterator q = _queue.insert(_queue.end(), p);
+ entry->proxy = proxy;
+ entry->pos = q;
+ }
+ else
+ {
+ if(_traceLevel == 1 || _traceLevel >= 3)
+ {
+ Trace out(_communicator->getLogger(), "Glacier2");
+ out << "proxy already in routing table:\n" << _communicator->proxyToString(proxy);
+ }
+
+ EvictorEntryPtr entry = p->second;
+ _queue.erase(entry->pos);
+ EvictorQueue::iterator q = _queue.insert(_queue.end(), p);
+ entry->pos = q;
+ }
+
+ while(static_cast<int>(_map.size()) > _maxSize)
+ {
+ p = _queue.front();
+
+ if(_traceLevel >= 2)
+ {
+ Trace out(_communicator->getLogger(), "Glacier2");
+ out << "evicting proxy from routing table:\n" << _communicator->proxyToString(p->second->proxy);
+ }
+
+ evictedProxies.push_back(p->second->proxy);
- _map.erase(p);
- _queue.pop_front();
- }
+ _map.erase(p);
+ _queue.pop_front();
+ }
}
return evictedProxies;
@@ -108,7 +108,7 @@ Glacier2::RoutingTable::get(const Identity& ident)
{
if(ident.name.empty())
{
- return 0;
+ return 0;
}
IceUtil::Mutex::Lock sync(*this);
@@ -117,15 +117,15 @@ Glacier2::RoutingTable::get(const Identity& ident)
if(p == _map.end())
{
- return 0;
+ return 0;
}
else
{
- EvictorEntryPtr entry = p->second;
- _queue.erase(entry->pos);
- EvictorQueue::iterator q = _queue.insert(_queue.end(), p);
- entry->pos = q;
+ EvictorEntryPtr entry = p->second;
+ _queue.erase(entry->pos);
+ EvictorQueue::iterator q = _queue.insert(_queue.end(), p);
+ entry->pos = q;
- return entry->proxy;
+ return entry->proxy;
}
}
diff --git a/cpp/src/Glacier2/RoutingTable.h b/cpp/src/Glacier2/RoutingTable.h
index 59c82eb9ff1..140ac29fd42 100644
--- a/cpp/src/Glacier2/RoutingTable.h
+++ b/cpp/src/Glacier2/RoutingTable.h
@@ -45,8 +45,8 @@ private:
friend struct EvictorEntry;
struct EvictorEntry : public IceUtil::Shared
{
- Ice::ObjectPrx proxy;
- EvictorQueue::iterator pos;
+ Ice::ObjectPrx proxy;
+ EvictorQueue::iterator pos;
};
EvictorMap _map;
diff --git a/cpp/src/Glacier2/ServerBlobject.cpp b/cpp/src/Glacier2/ServerBlobject.cpp
index 2942f2df17e..aafc1c8429f 100644
--- a/cpp/src/Glacier2/ServerBlobject.cpp
+++ b/cpp/src/Glacier2/ServerBlobject.cpp
@@ -25,8 +25,8 @@ Glacier2::ServerBlobject::~ServerBlobject()
void
Glacier2::ServerBlobject::ice_invoke_async(const Ice::AMD_Array_Object_ice_invokePtr& amdCB,
- const std::pair<const Byte*, const Byte*>& inParams,
- const Current& current)
+ const std::pair<const Byte*, const Byte*>& inParams,
+ const Current& current)
{
ObjectPrx proxy = _connection->createProxy(current.id);
assert(proxy);
diff --git a/cpp/src/Glacier2/ServerBlobject.h b/cpp/src/Glacier2/ServerBlobject.h
index 965341a9f1f..200a951cc59 100644
--- a/cpp/src/Glacier2/ServerBlobject.h
+++ b/cpp/src/Glacier2/ServerBlobject.h
@@ -26,7 +26,7 @@ public:
virtual ~ServerBlobject();
virtual void ice_invoke_async(const Ice::AMD_Array_Object_ice_invokePtr&,
- const std::pair<const Ice::Byte*, const Ice::Byte*>&, const Ice::Current&);
+ const std::pair<const Ice::Byte*, const Ice::Byte*>&, const Ice::Current&);
private:
diff --git a/cpp/src/Glacier2/SessionRouterI.cpp b/cpp/src/Glacier2/SessionRouterI.cpp
index 2052f7cfd45..a095748b52d 100644
--- a/cpp/src/Glacier2/SessionRouterI.cpp
+++ b/cpp/src/Glacier2/SessionRouterI.cpp
@@ -29,43 +29,43 @@ class SessionControlI : public SessionControl
public:
SessionControlI(const SessionRouterIPtr& sessionRouter, const ConnectionPtr& connection,
- const FilterManagerPtr& filterManager, IceUtil::Time timeout) :
+ const FilterManagerPtr& filterManager, IceUtil::Time timeout) :
_sessionRouter(sessionRouter),
- _connection(connection),
- _filters(filterManager),
- _timeout(static_cast<int>(timeout.toSeconds()))
+ _connection(connection),
+ _filters(filterManager),
+ _timeout(static_cast<int>(timeout.toSeconds()))
{
}
virtual StringSetPrx
categories(const Current&)
{
- return _filters->categoriesPrx();
+ return _filters->categoriesPrx();
}
virtual StringSetPrx
adapterIds(const Current&)
{
- return _filters->adapterIdsPrx();
+ return _filters->adapterIdsPrx();
}
virtual IdentitySetPrx
identities(const Current&)
{
- return _filters->identitiesPrx();
+ return _filters->identitiesPrx();
}
virtual int
getSessionTimeout(const Current&)
{
- return _timeout;
+ return _timeout;
}
virtual void
destroy(const Current&)
{
_sessionRouter->destroySession(_connection);
- _filters->destroy();
+ _filters->destroy();
}
private:
@@ -81,14 +81,14 @@ class ClientLocator : public ServantLocator
public:
ClientLocator(const SessionRouterIPtr& sessionRouter) :
- _sessionRouter(sessionRouter)
+ _sessionRouter(sessionRouter)
{
}
virtual ObjectPtr
locate(const Current& current, LocalObjectPtr&)
{
- return _sessionRouter->getRouter(current.con, current.id)->getClientBlobject();
+ return _sessionRouter->getRouter(current.con, current.id)->getClientBlobject();
}
virtual void
@@ -111,14 +111,14 @@ class ServerLocator : public ServantLocator
public:
ServerLocator(const SessionRouterIPtr& sessionRouter) :
- _sessionRouter(sessionRouter)
+ _sessionRouter(sessionRouter)
{
}
virtual ObjectPtr
locate(const Current& current, LocalObjectPtr&)
{
- return _sessionRouter->getRouter(current.id.category)->getServerBlobject();
+ return _sessionRouter->getRouter(current.id.category)->getServerBlobject();
}
virtual void
@@ -141,19 +141,19 @@ class UserPasswordAuthorizer : public Authorizer
public:
UserPasswordAuthorizer(const PermissionsVerifierPrx& verifier, const string& user, const string& password) :
- _verifier(verifier), _user(user), _password(password)
+ _verifier(verifier), _user(user), _password(password)
{
}
virtual bool
authorize(string& reason, const Ice::Context& ctx)
{
- if(_verifier)
- {
- return _verifier->checkPermissions(_user, _password, reason, ctx);
- }
- reason = "No PermissionsVerifier is available";
- return false;
+ if(_verifier)
+ {
+ return _verifier->checkPermissions(_user, _password, reason, ctx);
+ }
+ reason = "No PermissionsVerifier is available";
+ return false;
}
private:
@@ -168,20 +168,20 @@ class SSLPasswordAuthorizer : public Authorizer
public:
SSLPasswordAuthorizer(const SSLPermissionsVerifierPrx& verifier, const SSLInfo& info) :
- _verifier(verifier), _info(info)
+ _verifier(verifier), _info(info)
{
}
virtual bool
authorize(string& reason, const Ice::Context& ctx)
{
- if(_verifier)
- {
- return _verifier->authorize(_info, reason, ctx);
- }
+ if(_verifier)
+ {
+ return _verifier->authorize(_info, reason, ctx);
+ }
- reason = "No SSLPermissionsVerifier is available";
- return false;
+ reason = "No SSLPermissionsVerifier is available";
+ return false;
}
private:
@@ -195,14 +195,14 @@ class UserSessionFactory : public SessionFactory
public:
UserSessionFactory(const SessionManagerPrx& manager, const string& user) :
- _manager(manager), _user(user)
+ _manager(manager), _user(user)
{
}
virtual SessionPrx
create(const SessionControlPrx& control, const Ice::Context& ctx)
{
- return _manager->create(_user, control, ctx);
+ return _manager->create(_user, control, ctx);
}
private:
@@ -216,14 +216,14 @@ class SSLSessionFactory : public SessionFactory
public:
SSLSessionFactory(const SSLSessionManagerPrx& manager, const SSLInfo& info) :
- _manager(manager), _info(info)
+ _manager(manager), _info(info)
{
}
virtual SessionPrx
create(const SessionControlPrx& control, const Ice::Context& ctx)
{
- return _manager->create(_info, control, ctx);
+ return _manager->create(_info, control, ctx);
}
private:
@@ -237,11 +237,11 @@ private:
using namespace Glacier2;
Glacier2::SessionRouterI::SessionRouterI(const ObjectAdapterPtr& clientAdapter,
- const ObjectAdapterPtr& serverAdapter,
- const PermissionsVerifierPrx& verifier,
- const SessionManagerPrx& sessionManager,
- const SSLPermissionsVerifierPrx& sslVerifier,
- const SSLSessionManagerPrx& sslSessionManager) :
+ const ObjectAdapterPtr& serverAdapter,
+ const PermissionsVerifierPrx& verifier,
+ const SessionManagerPrx& sessionManager,
+ const SSLPermissionsVerifierPrx& sslVerifier,
+ const SSLSessionManagerPrx& sslSessionManager) :
_properties(clientAdapter->getCommunicator()->getProperties()),
_logger(clientAdapter->getCommunicator()->getLogger()),
_sessionTraceLevel(_properties->getPropertyAsInt("Glacier2.Trace.Session")),
@@ -280,12 +280,12 @@ Glacier2::SessionRouterI::SessionRouterI(const ObjectAdapterPtr& clientAdapter,
//
if(_serverAdapter)
{
- _serverAdapter->addServantLocator(new ServerLocator(this), "");
+ _serverAdapter->addServantLocator(new ServerLocator(this), "");
}
if(_sessionThread)
{
- _sessionThread->start();
+ _sessionThread->start();
}
}
@@ -307,20 +307,20 @@ Glacier2::SessionRouterI::destroy()
SessionThreadPtr sessionThread;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
-
- assert(!_destroy);
- _destroy = true;
- notify();
-
- _routersByConnection.swap(routers);
- _routersByConnectionHint = _routersByConnection.end();
-
- _routersByCategory.clear();
- _routersByCategoryHint = _routersByCategory.end();
-
- sessionThread = _sessionThread;
- _sessionThread = 0;
+ IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
+
+ assert(!_destroy);
+ _destroy = true;
+ notify();
+
+ _routersByConnection.swap(routers);
+ _routersByConnectionHint = _routersByConnection.end();
+
+ _routersByCategory.clear();
+ _routersByCategoryHint = _routersByCategory.end();
+
+ sessionThread = _sessionThread;
+ _sessionThread = 0;
}
//
@@ -329,26 +329,26 @@ Glacier2::SessionRouterI::destroy()
//
for(map<ConnectionPtr, RouterIPtr>::iterator p = routers.begin(); p != routers.end(); ++p)
{
- RouterIPtr router = p->second;
-
- try
- {
- router->destroy();
- }
- catch(const Exception& ex)
- {
- if(_sessionTraceLevel >= 1)
- {
- Trace out(_logger, "Glacier2");
- out << "exception while destroying session\n" << ex;
- }
- }
+ RouterIPtr router = p->second;
+
+ try
+ {
+ router->destroy();
+ }
+ catch(const Exception& ex)
+ {
+ if(_sessionTraceLevel >= 1)
+ {
+ Trace out(_logger, "Glacier2");
+ out << "exception while destroying session\n" << ex;
+ }
+ }
}
if(sessionThread)
{
- sessionThread->destroy();
- sessionThread->getThreadControl().join();
+ sessionThread->destroy();
+ sessionThread->getThreadControl().join();
}
}
@@ -394,10 +394,10 @@ Glacier2::SessionRouterI::createSession(const std::string& userId, const std::st
SessionFactoryPtr factory;
if(_sessionManager)
{
- factory = new UserSessionFactory(_sessionManager, userId);
+ factory = new UserSessionFactory(_sessionManager, userId);
}
return createSessionInternal(userId, true, new UserPasswordAuthorizer(_verifier, userId, password), factory,
- Ice::Context(), current);
+ Ice::Context(), current);
}
SessionPrx
@@ -405,9 +405,9 @@ Glacier2::SessionRouterI::createSessionFromSecureConnection(const Current& curre
{
if(!_sslVerifier)
{
- PermissionDeniedException exc;
- exc.reason = "no configured ssl permissions verifier";
- throw exc;
+ PermissionDeniedException exc;
+ exc.reason = "no configured ssl permissions verifier";
+ throw exc;
}
string userDN;
@@ -419,62 +419,62 @@ Glacier2::SessionRouterI::createSessionFromSecureConnection(const Current& curre
//
try
{
- IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(current.con);
- sslinfo.remotePort = ntohs(info.remoteAddr.sin_port);
- sslinfo.remoteHost = IceInternal::inetAddrToString(info.remoteAddr.sin_addr);
- sslinfo.localPort = ntohs(info.localAddr.sin_port);
- sslinfo.localHost = IceInternal::inetAddrToString(info.localAddr.sin_addr);
-
- sslinfo.cipher = info.cipher;
-
- if(info.certs.size() > 0)
- {
- sslinfo.certs.resize(info.certs.size());
- for(unsigned int i = 0; i < info.certs.size(); ++i)
- {
- sslinfo.certs[i] = info.certs[i]->encode();
- }
- userDN = info.certs[0]->getSubjectDN();
- }
-
- if(_properties->getPropertyAsInt("Glacier2.AddSSLContext") > 0)
- {
- sslCtx["SSL.Active"] = "1";
- sslCtx["SSL.Cipher"] = sslinfo.cipher;
- ostringstream os;
- os << sslinfo.remotePort;
- sslCtx["SSL.Remote.Port"] = os.str();
- sslCtx["SSL.Remote.Host"] = sslinfo.remoteHost;
- os.str("");
- os << ntohs(info.localAddr.sin_port);
- sslCtx["SSL.Local.Port"] = os.str();
- sslCtx["SSL.Local.Host"] = sslinfo.localHost;
- if(info.certs.size() > 0)
- {
- sslCtx["SSL.PeerCert"] = info.certs[0]->encode();
- }
- }
+ IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(current.con);
+ sslinfo.remotePort = ntohs(info.remoteAddr.sin_port);
+ sslinfo.remoteHost = IceInternal::inetAddrToString(info.remoteAddr.sin_addr);
+ sslinfo.localPort = ntohs(info.localAddr.sin_port);
+ sslinfo.localHost = IceInternal::inetAddrToString(info.localAddr.sin_addr);
+
+ sslinfo.cipher = info.cipher;
+
+ if(info.certs.size() > 0)
+ {
+ sslinfo.certs.resize(info.certs.size());
+ for(unsigned int i = 0; i < info.certs.size(); ++i)
+ {
+ sslinfo.certs[i] = info.certs[i]->encode();
+ }
+ userDN = info.certs[0]->getSubjectDN();
+ }
+
+ if(_properties->getPropertyAsInt("Glacier2.AddSSLContext") > 0)
+ {
+ sslCtx["SSL.Active"] = "1";
+ sslCtx["SSL.Cipher"] = sslinfo.cipher;
+ ostringstream os;
+ os << sslinfo.remotePort;
+ sslCtx["SSL.Remote.Port"] = os.str();
+ sslCtx["SSL.Remote.Host"] = sslinfo.remoteHost;
+ os.str("");
+ os << ntohs(info.localAddr.sin_port);
+ sslCtx["SSL.Local.Port"] = os.str();
+ sslCtx["SSL.Local.Host"] = sslinfo.localHost;
+ if(info.certs.size() > 0)
+ {
+ sslCtx["SSL.PeerCert"] = info.certs[0]->encode();
+ }
+ }
}
catch(const IceSSL::ConnectionInvalidException&)
{
- PermissionDeniedException exc;
- exc.reason = "not ssl connection";
- throw exc;
+ PermissionDeniedException exc;
+ exc.reason = "not ssl connection";
+ throw exc;
}
catch(const IceSSL::CertificateEncodingException&)
{
- PermissionDeniedException exc;
- exc.reason = "certificate encoding exception";
- throw exc;
+ PermissionDeniedException exc;
+ exc.reason = "certificate encoding exception";
+ throw exc;
}
SessionFactoryPtr factory;
if(_sslSessionManager)
{
- factory = new SSLSessionFactory(_sslSessionManager, sslinfo);
+ factory = new SSLSessionFactory(_sslSessionManager, sslinfo);
}
return createSessionInternal(userDN, false, new SSLPasswordAuthorizer(_sslVerifier, sslinfo), factory, sslCtx,
- current);
+ current);
}
void
@@ -489,43 +489,43 @@ Glacier2::SessionRouterI::destroySession(const ConnectionPtr& connection)
RouterIPtr router;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
-
- if(_destroy)
- {
- connection->close(true);
- throw ObjectNotExistException(__FILE__, __LINE__);
- }
-
- map<ConnectionPtr, RouterIPtr>::iterator p;
-
- if(_routersByConnectionHint != _routersByConnection.end() && _routersByConnectionHint->first == connection)
- {
- p = _routersByConnectionHint;
- }
- else
- {
- p = _routersByConnection.find(connection);
- }
-
- if(p == _routersByConnection.end())
- {
- SessionNotExistException exc;
- throw exc;
- }
-
- router = p->second;
-
- _routersByConnection.erase(p++);
- _routersByConnectionHint = p;
-
- if(_serverAdapter)
- {
- string category = router->getServerProxy(Current())->ice_getIdentity().category;
- assert(!category.empty());
- _routersByCategory.erase(category);
- _routersByCategoryHint = _routersByCategory.end();
- }
+ IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
+
+ if(_destroy)
+ {
+ connection->close(true);
+ throw ObjectNotExistException(__FILE__, __LINE__);
+ }
+
+ map<ConnectionPtr, RouterIPtr>::iterator p;
+
+ if(_routersByConnectionHint != _routersByConnection.end() && _routersByConnectionHint->first == connection)
+ {
+ p = _routersByConnectionHint;
+ }
+ else
+ {
+ p = _routersByConnection.find(connection);
+ }
+
+ if(p == _routersByConnection.end())
+ {
+ SessionNotExistException exc;
+ throw exc;
+ }
+
+ router = p->second;
+
+ _routersByConnection.erase(p++);
+ _routersByConnectionHint = p;
+
+ if(_serverAdapter)
+ {
+ string category = router->getServerProxy(Current())->ice_getIdentity().category;
+ assert(!category.empty());
+ _routersByCategory.erase(category);
+ _routersByCategoryHint = _routersByCategory.end();
+ }
}
//
@@ -534,22 +534,22 @@ Glacier2::SessionRouterI::destroySession(const ConnectionPtr& connection)
//
try
{
- if(_sessionTraceLevel >= 1)
- {
- Trace out(_logger, "Glacier2");
- out << "destroying session\n";
- out << router->toString();
- }
-
- router->destroy();
+ if(_sessionTraceLevel >= 1)
+ {
+ Trace out(_logger, "Glacier2");
+ out << "destroying session\n";
+ out << router->toString();
+ }
+
+ router->destroy();
}
catch(const Exception& ex)
{
- if(_sessionTraceLevel >= 1)
- {
- Trace out(_logger, "Glacier2");
- out << "exception while destroying session\n" << ex;
- }
+ if(_sessionTraceLevel >= 1)
+ {
+ Trace out(_logger, "Glacier2");
+ out << "exception while destroying session\n" << ex;
+ }
}
}
@@ -566,34 +566,34 @@ Glacier2::SessionRouterI::getRouter(const ConnectionPtr& connection, const Ice::
if(_destroy)
{
- connection->close(true);
- throw ObjectNotExistException(__FILE__, __LINE__);
+ connection->close(true);
+ throw ObjectNotExistException(__FILE__, __LINE__);
}
map<ConnectionPtr, RouterIPtr>& routers = const_cast<map<ConnectionPtr, RouterIPtr>&>(_routersByConnection);
if(_routersByConnectionHint != routers.end() && _routersByConnectionHint->first == connection)
{
- return _routersByConnectionHint->second;
+ return _routersByConnectionHint->second;
}
map<ConnectionPtr, RouterIPtr>::iterator p = routers.find(connection);
if(p != routers.end())
{
- _routersByConnectionHint = p;
- return p->second;
+ _routersByConnectionHint = p;
+ return p->second;
}
else
{
- if(_rejectTraceLevel >= 1)
- {
- Trace out(_logger, "Glacier2");
- out << "rejecting request. no session is associated with the connection.\n";
- out << "identity: " << _clientAdapter->getCommunicator()->identityToString(id);
- }
- connection->close(true);
- throw ObjectNotExistException(__FILE__, __LINE__);
+ if(_rejectTraceLevel >= 1)
+ {
+ Trace out(_logger, "Glacier2");
+ out << "rejecting request. no session is associated with the connection.\n";
+ out << "identity: " << _clientAdapter->getCommunicator()->identityToString(id);
+ }
+ connection->close(true);
+ throw ObjectNotExistException(__FILE__, __LINE__);
}
}
@@ -604,26 +604,26 @@ Glacier2::SessionRouterI::getRouter(const string& category) const
if(_destroy)
{
- throw ObjectNotExistException(__FILE__, __LINE__);
+ throw ObjectNotExistException(__FILE__, __LINE__);
}
map<string, RouterIPtr>& routers = const_cast<map<string, RouterIPtr>&>(_routersByCategory);
if(_routersByCategoryHint != routers.end() && _routersByCategoryHint->first == category)
{
- return _routersByCategoryHint->second;
+ return _routersByCategoryHint->second;
}
map<string, RouterIPtr>::iterator p = routers.find(category);
if(p != routers.end())
{
- _routersByCategoryHint = p;
- return p->second;
+ _routersByCategoryHint = p;
+ return p->second;
}
else
{
- throw ObjectNotExistException(__FILE__, __LINE__);
+ throw ObjectNotExistException(__FILE__, __LINE__);
}
}
@@ -633,41 +633,41 @@ Glacier2::SessionRouterI::expireSessions()
vector<RouterIPtr> routers;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
-
- if(_destroy)
- {
- return;
- }
-
- assert(_sessionTimeout > IceUtil::Time());
- IceUtil::Time minTimestamp = IceUtil::Time::now() - _sessionTimeout;
-
- map<ConnectionPtr, RouterIPtr>::iterator p = _routersByConnection.begin();
-
- while(p != _routersByConnection.end())
- {
- if(p->second->getTimestamp() < minTimestamp)
- {
- RouterIPtr router = p->second;
- routers.push_back(router);
-
- _routersByConnection.erase(p++);
- _routersByConnectionHint = p;
-
- if(_serverAdapter)
- {
- string category = router->getServerProxy(Current())->ice_getIdentity().category;
- assert(!category.empty());
- _routersByCategory.erase(category);
- _routersByCategoryHint = _routersByCategory.end();
- }
- }
- else
- {
- ++p;
- }
- }
+ IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
+
+ if(_destroy)
+ {
+ return;
+ }
+
+ assert(_sessionTimeout > IceUtil::Time());
+ IceUtil::Time minTimestamp = IceUtil::Time::now() - _sessionTimeout;
+
+ map<ConnectionPtr, RouterIPtr>::iterator p = _routersByConnection.begin();
+
+ while(p != _routersByConnection.end())
+ {
+ if(p->second->getTimestamp() < minTimestamp)
+ {
+ RouterIPtr router = p->second;
+ routers.push_back(router);
+
+ _routersByConnection.erase(p++);
+ _routersByConnectionHint = p;
+
+ if(_serverAdapter)
+ {
+ string category = router->getServerProxy(Current())->ice_getIdentity().category;
+ assert(!category.empty());
+ _routersByCategory.erase(category);
+ _routersByCategoryHint = _routersByCategory.end();
+ }
+ }
+ else
+ {
+ ++p;
+ }
+ }
}
//
@@ -676,169 +676,169 @@ Glacier2::SessionRouterI::expireSessions()
//
for(vector<RouterIPtr>::iterator p = routers.begin(); p != routers.end(); ++p)
{
- RouterIPtr router = *p;
-
- try
- {
- if(_sessionTraceLevel >= 1)
- {
- Trace out(_logger, "Glacier2");
- out << "expiring session\n";
- out << router->toString();
- }
-
- router->destroy();
- }
- catch(const Exception& ex)
- {
- if(_sessionTraceLevel >= 1)
- {
- Trace out(_logger, "Glacier2");
- out << "exception while expiring session\n" << ex;
- }
- }
+ RouterIPtr router = *p;
+
+ try
+ {
+ if(_sessionTraceLevel >= 1)
+ {
+ Trace out(_logger, "Glacier2");
+ out << "expiring session\n";
+ out << router->toString();
+ }
+
+ router->destroy();
+ }
+ catch(const Exception& ex)
+ {
+ if(_sessionTraceLevel >= 1)
+ {
+ Trace out(_logger, "Glacier2");
+ out << "exception while expiring session\n" << ex;
+ }
+ }
}
}
SessionPrx
Glacier2::SessionRouterI::createSessionInternal(const string& userId, bool allowAddUserMode,
- const AuthorizerPtr& authorizer, const SessionFactoryPtr& factory,
- const Ice::Context& sslContext, const Current& current)
+ const AuthorizerPtr& authorizer, const SessionFactoryPtr& factory,
+ const Ice::Context& sslContext, const Current& current)
{
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
-
- if(_destroy)
- {
- current.con->close(true);
- throw ObjectNotExistException(__FILE__, __LINE__);
- }
-
- //
- // Check whether a session already exists for the connection.
- //
- {
- map<ConnectionPtr, RouterIPtr>::iterator p;
- if(_routersByConnectionHint != _routersByConnection.end() &&
- _routersByConnectionHint->first == current.con)
- {
- p = _routersByConnectionHint;
- }
- else
- {
- p = _routersByConnection.find(current.con);
- }
-
- if(p != _routersByConnection.end())
- {
- CannotCreateSessionException exc;
- exc.reason = "session exists";
- throw exc;
- }
- }
-
- //
- // If some other thread is currently trying to create a
- // session, we wait until this thread is finished.
- //
- bool searchAgain = false;
- while(_pending.find(current.con) != _pending.end())
- {
- wait();
-
- if(_destroy)
- {
- current.con->close(true);
- throw ObjectNotExistException(__FILE__, __LINE__);
- }
-
- searchAgain = true;
- }
-
- //
- // Check for existing sessions again if we waited above, as
- // new sessions have been added in the meantime.
- //
- if(searchAgain)
- {
- map<ConnectionPtr, RouterIPtr>::iterator p;
- if(_routersByConnectionHint != _routersByConnection.end() &&
- _routersByConnectionHint->first == current.con)
- {
- p = _routersByConnectionHint;
- }
- else
- {
- p = _routersByConnection.find(current.con);
- }
-
- if(p != _routersByConnection.end())
- {
- CannotCreateSessionException exc;
- exc.reason = "session exists";
- throw exc;
- }
- }
-
- //
- // No session exists yet, so we will try to create one. To
- // avoid that other threads try to create sessions for the
- // same connection, we add our endpoints to _pending.
- //
- _pending.insert(current.con);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
+
+ if(_destroy)
+ {
+ current.con->close(true);
+ throw ObjectNotExistException(__FILE__, __LINE__);
+ }
+
+ //
+ // Check whether a session already exists for the connection.
+ //
+ {
+ map<ConnectionPtr, RouterIPtr>::iterator p;
+ if(_routersByConnectionHint != _routersByConnection.end() &&
+ _routersByConnectionHint->first == current.con)
+ {
+ p = _routersByConnectionHint;
+ }
+ else
+ {
+ p = _routersByConnection.find(current.con);
+ }
+
+ if(p != _routersByConnection.end())
+ {
+ CannotCreateSessionException exc;
+ exc.reason = "session exists";
+ throw exc;
+ }
+ }
+
+ //
+ // If some other thread is currently trying to create a
+ // session, we wait until this thread is finished.
+ //
+ bool searchAgain = false;
+ while(_pending.find(current.con) != _pending.end())
+ {
+ wait();
+
+ if(_destroy)
+ {
+ current.con->close(true);
+ throw ObjectNotExistException(__FILE__, __LINE__);
+ }
+
+ searchAgain = true;
+ }
+
+ //
+ // Check for existing sessions again if we waited above, as
+ // new sessions have been added in the meantime.
+ //
+ if(searchAgain)
+ {
+ map<ConnectionPtr, RouterIPtr>::iterator p;
+ if(_routersByConnectionHint != _routersByConnection.end() &&
+ _routersByConnectionHint->first == current.con)
+ {
+ p = _routersByConnectionHint;
+ }
+ else
+ {
+ p = _routersByConnection.find(current.con);
+ }
+
+ if(p != _routersByConnection.end())
+ {
+ CannotCreateSessionException exc;
+ exc.reason = "session exists";
+ throw exc;
+ }
+ }
+
+ //
+ // No session exists yet, so we will try to create one. To
+ // avoid that other threads try to create sessions for the
+ // same connection, we add our endpoints to _pending.
+ //
+ _pending.insert(current.con);
}
try
{
- //
- // Authorize.
- //
- string reason;
- bool ok;
-
- try
- {
- ok = authorizer->authorize(reason, current.ctx);
- }
- catch(const Exception& ex)
- {
- if(_sessionTraceLevel >= 1)
- {
- Trace out(_logger, "Glacier2");
- out << "exception while verifying password:\n" << ex;
- }
-
- PermissionDeniedException exc;
- exc.reason = "internal server error";
- throw exc;
- }
-
- if(!ok)
- {
- PermissionDeniedException exc;
- if(reason.empty())
- {
- exc.reason = "permission denied";
- }
- else
- {
- exc.reason = reason;
- }
- throw exc;
- }
+ //
+ // Authorize.
+ //
+ string reason;
+ bool ok;
+
+ try
+ {
+ ok = authorizer->authorize(reason, current.ctx);
+ }
+ catch(const Exception& ex)
+ {
+ if(_sessionTraceLevel >= 1)
+ {
+ Trace out(_logger, "Glacier2");
+ out << "exception while verifying password:\n" << ex;
+ }
+
+ PermissionDeniedException exc;
+ exc.reason = "internal server error";
+ throw exc;
+ }
+
+ if(!ok)
+ {
+ PermissionDeniedException exc;
+ if(reason.empty())
+ {
+ exc.reason = "permission denied";
+ }
+ else
+ {
+ exc.reason = reason;
+ }
+ throw exc;
+ }
}
catch(const Exception& ex)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
- //
- // Signal other threads that we are done with trying to
- // establish a session for our connection;
- //
- _pending.erase(current.con);
- notify();
+ //
+ // Signal other threads that we are done with trying to
+ // establish a session for our connection;
+ //
+ _pending.erase(current.con);
+ notify();
- ex.ice_throw();
+ ex.ice_throw();
}
@@ -848,151 +848,151 @@ Glacier2::SessionRouterI::createSessionInternal(const string& userId, bool allow
try
{
- //
- // The client blobject requires direct access to the full filter
- // servant, but proliferating the implementation of the servant
- // throughout the router code is undesirable. To avoid lots of
- // physical interdependencies, we create the filters and
- // clientblobject together and pass the clientblobject to the
- // router. We create the clientblobject here since it is
- // responsible for creating the filters and we want them to be
- // accessible during session creation.
- //
- FilterManagerPtr filterManager = FilterManager::create(_clientAdapter->getCommunicator(), _serverAdapter,
- userId, allowAddUserMode);
+ //
+ // The client blobject requires direct access to the full filter
+ // servant, but proliferating the implementation of the servant
+ // throughout the router code is undesirable. To avoid lots of
+ // physical interdependencies, we create the filters and
+ // clientblobject together and pass the clientblobject to the
+ // router. We create the clientblobject here since it is
+ // responsible for creating the filters and we want them to be
+ // accessible during session creation.
+ //
+ FilterManagerPtr filterManager = FilterManager::create(_clientAdapter->getCommunicator(), _serverAdapter,
+ userId, allowAddUserMode);
//
- // If we have a session manager configured, we create a
- // client-visible session object.
- //
- if(factory)
- {
- SessionControlPrx control;
- if(_serverAdapter)
- {
- control = SessionControlPrx::uncheckedCast(
- _serverAdapter->addWithUUID(
- new SessionControlI(this, current.con, filterManager, _sessionTimeout)));
- controlId = control->ice_getIdentity();
- }
- session = factory->create(control, current.ctx);
- }
+ // If we have a session manager configured, we create a
+ // client-visible session object.
+ //
+ if(factory)
+ {
+ SessionControlPrx control;
+ if(_serverAdapter)
+ {
+ control = SessionControlPrx::uncheckedCast(
+ _serverAdapter->addWithUUID(
+ new SessionControlI(this, current.con, filterManager, _sessionTimeout)));
+ controlId = control->ice_getIdentity();
+ }
+ session = factory->create(control, current.ctx);
+ }
- //
- // Add a new per-client router.
- //
- router = new RouterI(_clientAdapter, _serverAdapter, current.con, userId,
- session, controlId, filterManager, sslContext);
+ //
+ // Add a new per-client router.
+ //
+ router = new RouterI(_clientAdapter, _serverAdapter, current.con, userId,
+ session, controlId, filterManager, sslContext);
}
catch(const Exception& ex)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
-
- //
- // Signal other threads that we are done with trying to
- // establish a session for our connection;
- //
- _pending.erase(current.con);
- notify();
-
- assert(!router);
-
- if(session)
- {
- if(_serverAdapter)
- {
- try
- {
- _serverAdapter->remove(controlId);
- }
- catch(const Exception&)
- {
- // Ignore all exceptions here.
- }
- }
- try
- {
- session->destroy();
- }
- catch(const Exception&)
- {
- // Ignore all exceptions here.
- }
- }
-
- try
- {
- ex.ice_throw();
- }
- catch(const Glacier2::CannotCreateSessionException&)
- {
- throw;
- }
- catch(const Exception&)
- {
- if(_sessionTraceLevel >= 1)
- {
- Trace out(_logger, "Glacier2");
- out << "exception while creating session with session manager:\n" << ex;
- }
-
- CannotCreateSessionException exc;
- exc.reason = "internal server error";
- throw exc;
- }
+ IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
+
+ //
+ // Signal other threads that we are done with trying to
+ // establish a session for our connection;
+ //
+ _pending.erase(current.con);
+ notify();
+
+ assert(!router);
+
+ if(session)
+ {
+ if(_serverAdapter)
+ {
+ try
+ {
+ _serverAdapter->remove(controlId);
+ }
+ catch(const Exception&)
+ {
+ // Ignore all exceptions here.
+ }
+ }
+ try
+ {
+ session->destroy();
+ }
+ catch(const Exception&)
+ {
+ // Ignore all exceptions here.
+ }
+ }
+
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(const Glacier2::CannotCreateSessionException&)
+ {
+ throw;
+ }
+ catch(const Exception&)
+ {
+ if(_sessionTraceLevel >= 1)
+ {
+ Trace out(_logger, "Glacier2");
+ out << "exception while creating session with session manager:\n" << ex;
+ }
+
+ CannotCreateSessionException exc;
+ exc.reason = "internal server error";
+ throw exc;
+ }
}
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
-
- //
- // Signal other threads that we are done with trying to
- // establish a session for our connection;
- //
- _pending.erase(current.con);
- notify();
-
- if(_destroy)
- {
- try
- {
- router->destroy();
- }
- catch(const Exception&)
- {
- // Ignore all exceptions here.
- }
-
- current.con->close(true);
- throw ObjectNotExistException(__FILE__, __LINE__);
- }
-
- _routersByConnectionHint = _routersByConnection.insert(
- _routersByConnectionHint, pair<const ConnectionPtr, RouterIPtr>(current.con, router));
-
- if(_serverAdapter)
- {
- string category = router->getServerProxy(current)->ice_getIdentity().category;
- assert(!category.empty());
- pair<map<string, RouterIPtr>::iterator, bool> rc =
- _routersByCategory.insert(pair<const string, RouterIPtr>(category, router));
- assert(rc.second);
- _routersByCategoryHint = rc.first;
- }
-
- if(_sessionTraceLevel >= 1)
- {
- Trace out(_logger, "Glacier2");
- out << "created session\n";
- out << router->toString();
- }
+ IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
+
+ //
+ // Signal other threads that we are done with trying to
+ // establish a session for our connection;
+ //
+ _pending.erase(current.con);
+ notify();
+
+ if(_destroy)
+ {
+ try
+ {
+ router->destroy();
+ }
+ catch(const Exception&)
+ {
+ // Ignore all exceptions here.
+ }
+
+ current.con->close(true);
+ throw ObjectNotExistException(__FILE__, __LINE__);
+ }
+
+ _routersByConnectionHint = _routersByConnection.insert(
+ _routersByConnectionHint, pair<const ConnectionPtr, RouterIPtr>(current.con, router));
+
+ if(_serverAdapter)
+ {
+ string category = router->getServerProxy(current)->ice_getIdentity().category;
+ assert(!category.empty());
+ pair<map<string, RouterIPtr>::iterator, bool> rc =
+ _routersByCategory.insert(pair<const string, RouterIPtr>(category, router));
+ assert(rc.second);
+ _routersByCategoryHint = rc.first;
+ }
+
+ if(_sessionTraceLevel >= 1)
+ {
+ Trace out(_logger, "Glacier2");
+ out << "created session\n";
+ out << router->toString();
+ }
}
-
+
return session;
}
Glacier2::SessionRouterI::SessionThread::SessionThread(const SessionRouterIPtr& sessionRouter,
- const IceUtil::Time& sessionTimeout) :
+ const IceUtil::Time& sessionTimeout) :
_sessionRouter(sessionRouter),
_sessionTimeout(sessionTimeout)
{
@@ -1016,27 +1016,27 @@ Glacier2::SessionRouterI::SessionThread::run()
{
while(true)
{
- SessionRouterIPtr sessionRouter;
+ SessionRouterIPtr sessionRouter;
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
- if(!_sessionRouter)
- {
- return;
- }
-
- assert(_sessionTimeout > IceUtil::Time());
- timedWait(_sessionTimeout / 4);
+ if(!_sessionRouter)
+ {
+ return;
+ }
+
+ assert(_sessionTimeout > IceUtil::Time());
+ timedWait(_sessionTimeout / 4);
- if(!_sessionRouter)
- {
- return;
- }
+ if(!_sessionRouter)
+ {
+ return;
+ }
- sessionRouter = _sessionRouter;
- }
+ sessionRouter = _sessionRouter;
+ }
- sessionRouter->expireSessions();
+ sessionRouter->expireSessions();
}
}
diff --git a/cpp/src/Glacier2/SessionRouterI.h b/cpp/src/Glacier2/SessionRouterI.h
index 7fc7a5c2f60..9be3f25e2b0 100644
--- a/cpp/src/Glacier2/SessionRouterI.h
+++ b/cpp/src/Glacier2/SessionRouterI.h
@@ -48,8 +48,8 @@ class SessionRouterI : public Router, public IceUtil::Monitor<IceUtil::Mutex>
public:
SessionRouterI(const Ice::ObjectAdapterPtr&, const Ice::ObjectAdapterPtr&,
- const PermissionsVerifierPrx&, const SessionManagerPrx&,
- const SSLPermissionsVerifierPrx&, const SSLSessionManagerPrx&);
+ const PermissionsVerifierPrx&, const SessionManagerPrx&,
+ const SSLPermissionsVerifierPrx&, const SSLSessionManagerPrx&);
virtual ~SessionRouterI();
void destroy();
@@ -73,7 +73,7 @@ public:
private:
SessionPrx createSessionInternal(const std::string&, bool, const AuthorizerPtr&, const SessionFactoryPtr&,
- const Ice::Context&, const Ice::Current&);
+ const Ice::Context&, const Ice::Current&);
const Ice::PropertiesPtr _properties;
const Ice::LoggerPtr _logger;
@@ -91,16 +91,16 @@ private:
{
public:
- SessionThread(const SessionRouterIPtr&, const IceUtil::Time&);
- virtual ~SessionThread();
- void destroy();
+ SessionThread(const SessionRouterIPtr&, const IceUtil::Time&);
+ virtual ~SessionThread();
+ void destroy();
- virtual void run();
+ virtual void run();
private:
- SessionRouterIPtr _sessionRouter;
- const IceUtil::Time _sessionTimeout;
+ SessionRouterIPtr _sessionRouter;
+ const IceUtil::Time _sessionTimeout;
};
typedef IceUtil::Handle<SessionThread> SessionThreadPtr;
SessionThreadPtr _sessionThread;
diff --git a/cpp/src/Ice/Application.cpp b/cpp/src/Ice/Application.cpp
index ae9a1ea7c4e..adcd5ddfb69 100644
--- a/cpp/src/Ice/Application.cpp
+++ b/cpp/src/Ice/Application.cpp
@@ -68,26 +68,26 @@ holdInterruptCallback(int signal)
{
CtrlCHandlerCallback callback = 0;
{
- StaticMutex::Lock lock(_mutex);
- while(!_released)
- {
- _condVar->wait(lock);
- }
-
- if(_destroyed)
- {
- //
- // Being destroyed by main thread
- //
- return;
- }
- assert(_ctrlCHandler != 0);
- callback = _ctrlCHandler->getCallback();
+ StaticMutex::Lock lock(_mutex);
+ while(!_released)
+ {
+ _condVar->wait(lock);
+ }
+
+ if(_destroyed)
+ {
+ //
+ // Being destroyed by main thread
+ //
+ return;
+ }
+ assert(_ctrlCHandler != 0);
+ callback = _ctrlCHandler->getCallback();
}
if(callback != 0)
{
- callback(signal);
+ callback(signal);
}
}
@@ -95,60 +95,60 @@ static void
destroyOnInterruptCallback(int signal)
{
{
- StaticMutex::Lock lock(_mutex);
- if(_destroyed)
- {
- //
- // Being destroyed by main thread
- //
- return;
- }
- if(_nohup && signal == SIGHUP)
- {
- return;
- }
-
- assert(!_callbackInProgress);
- _callbackInProgress = true;
- _interrupted = true;
- _destroyed = true;
- }
-
+ StaticMutex::Lock lock(_mutex);
+ if(_destroyed)
+ {
+ //
+ // Being destroyed by main thread
+ //
+ return;
+ }
+ if(_nohup && signal == SIGHUP)
+ {
+ return;
+ }
+
+ assert(!_callbackInProgress);
+ _callbackInProgress = true;
+ _interrupted = true;
+ _destroyed = true;
+ }
+
assert(_communicator != 0);
try
{
- _communicator->destroy();
+ _communicator->destroy();
}
catch(const IceUtil::Exception& ex)
{
- cerr << _appName << " (while destroying in response to signal " << signal
- << "): " << ex << endl;
+ cerr << _appName << " (while destroying in response to signal " << signal
+ << "): " << ex << endl;
}
catch(const std::exception& ex)
{
- cerr << _appName << " (while destroying in response to signal " << signal
- << "): std::exception: " << ex.what() << endl;
+ cerr << _appName << " (while destroying in response to signal " << signal
+ << "): std::exception: " << ex.what() << endl;
}
catch(const std::string& msg)
{
- cerr << _appName << " (while destroying in response to signal " << signal
- << "): " << msg << endl;
+ cerr << _appName << " (while destroying in response to signal " << signal
+ << "): " << msg << endl;
}
catch(const char * msg)
{
- cerr << _appName << " (while destroying in response to signal " << signal
- << "): " << msg << endl;
+ cerr << _appName << " (while destroying in response to signal " << signal
+ << "): " << msg << endl;
}
catch(...)
{
- cerr << _appName << " (while destroying in response to signal " << signal
- << "): unknown exception" << endl;
+ cerr << _appName << " (while destroying in response to signal " << signal
+ << "): unknown exception" << endl;
}
{
- StaticMutex::Lock lock(_mutex);
- _callbackInProgress = false;
+ StaticMutex::Lock lock(_mutex);
+ _callbackInProgress = false;
}
_condVar->signal();
}
@@ -158,57 +158,57 @@ static void
shutdownOnInterruptCallback(int signal)
{
{
- StaticMutex::Lock lock(_mutex);
- if(_destroyed)
- {
- //
- // Being destroyed by main thread
- //
- return;
- }
- if(_nohup && signal == SIGHUP)
- {
- return;
- }
- assert(!_callbackInProgress);
- _callbackInProgress = true;
- _interrupted = true;
+ StaticMutex::Lock lock(_mutex);
+ if(_destroyed)
+ {
+ //
+ // Being destroyed by main thread
+ //
+ return;
+ }
+ if(_nohup && signal == SIGHUP)
+ {
+ return;
+ }
+ assert(!_callbackInProgress);
+ _callbackInProgress = true;
+ _interrupted = true;
}
assert(_communicator != 0);
try
{
- _communicator->shutdown();
+ _communicator->shutdown();
}
catch(const IceUtil::Exception& ex)
{
- cerr << _appName << " (while shutting down in response to signal " << signal
- << "): " << ex << endl;
+ cerr << _appName << " (while shutting down in response to signal " << signal
+ << "): " << ex << endl;
}
catch(const std::exception& ex)
{
- cerr << _appName << " (while shutting down in response to signal " << signal
- << "): std::exception: " << ex.what() << endl;
+ cerr << _appName << " (while shutting down in response to signal " << signal
+ << "): std::exception: " << ex.what() << endl;
}
catch(const std::string& msg)
{
- cerr << _appName << " (while shutting down in response to signal " << signal
- << "): " << msg << endl;
+ cerr << _appName << " (while shutting down in response to signal " << signal
+ << "): " << msg << endl;
}
catch(const char * msg)
{
- cerr << _appName << " (while shutting down in response to signal " << signal
- << "): " << msg << endl;
+ cerr << _appName << " (while shutting down in response to signal " << signal
+ << "): " << msg << endl;
}
catch(...)
{
- cerr << _appName << " (while shutting down in response to signal " << signal
- << "): unknown exception" << endl;
+ cerr << _appName << " (while shutting down in response to signal " << signal
+ << "): unknown exception" << endl;
}
{
- StaticMutex::Lock lock(_mutex);
- _callbackInProgress = false;
+ StaticMutex::Lock lock(_mutex);
+ _callbackInProgress = false;
}
_condVar->signal();
}
@@ -217,55 +217,55 @@ static void
callbackOnInterruptCallback(int signal)
{
{
- StaticMutex::Lock lock(_mutex);
- if(_destroyed)
- {
- //
- // Being destroyed by main thread
- //
- return;
- }
- // For SIGHUP the user callback is always called. It can
- // decide what to do.
- assert(!_callbackInProgress);
- _callbackInProgress = true;
- _interrupted = true;
+ StaticMutex::Lock lock(_mutex);
+ if(_destroyed)
+ {
+ //
+ // Being destroyed by main thread
+ //
+ return;
+ }
+ // For SIGHUP the user callback is always called. It can
+ // decide what to do.
+ assert(!_callbackInProgress);
+ _callbackInProgress = true;
+ _interrupted = true;
}
assert(_application != 0);
try
{
- _application->interruptCallback(signal);
+ _application->interruptCallback(signal);
}
catch(const IceUtil::Exception& ex)
{
- cerr << _appName << " (while interrupting in response to signal " << signal
- << "): " << ex << endl;
+ cerr << _appName << " (while interrupting in response to signal " << signal
+ << "): " << ex << endl;
}
catch(const std::exception& ex)
{
- cerr << _appName << " (while interrupting in response to signal " << signal
- << "): std::exception: " << ex.what() << endl;
+ cerr << _appName << " (while interrupting in response to signal " << signal
+ << "): std::exception: " << ex.what() << endl;
}
catch(const std::string& msg)
{
- cerr << _appName << " (while interrupting in response to signal " << signal
- << "): " << msg << endl;
+ cerr << _appName << " (while interrupting in response to signal " << signal
+ << "): " << msg << endl;
}
catch(const char * msg)
{
- cerr << _appName << " (while interrupting in response to signal " << signal
- << "): " << msg << endl;
+ cerr << _appName << " (while interrupting in response to signal " << signal
+ << "): " << msg << endl;
}
catch(...)
{
- cerr << _appName << " (while interrupting in response to signal " << signal
- << "): unknown exception" << endl;
+ cerr << _appName << " (while interrupting in response to signal " << signal
+ << "): unknown exception" << endl;
}
{
- StaticMutex::Lock lock(_mutex);
- _callbackInProgress = false;
+ StaticMutex::Lock lock(_mutex);
+ _callbackInProgress = false;
}
_condVar->signal();
}
@@ -295,26 +295,26 @@ Ice::Application::main(int argc, char* argv[], const char* configFile)
InitializationData initData;
if(configFile)
{
- try
- {
- initData.properties = createProperties();
- initData.properties->load(configFile);
- }
- catch(const IceUtil::Exception& ex)
- {
- cerr << argv[0] << ": " << ex << endl;
- return EXIT_FAILURE;
- }
- catch(const std::exception& ex)
- {
- cerr << argv[0] << ": std::exception: " << ex.what() << endl;
- return EXIT_FAILURE;
- }
- catch(...)
- {
- cerr << argv[0] << ": unknown exception" << endl;
- return EXIT_FAILURE;
- }
+ try
+ {
+ initData.properties = createProperties();
+ initData.properties->load(configFile);
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ cerr << argv[0] << ": " << ex << endl;
+ return EXIT_FAILURE;
+ }
+ catch(const std::exception& ex)
+ {
+ cerr << argv[0] << ": std::exception: " << ex.what() << endl;
+ return EXIT_FAILURE;
+ }
+ catch(...)
+ {
+ cerr << argv[0] << ": unknown exception" << endl;
+ return EXIT_FAILURE;
+ }
}
return main(argc, argv, initData);
}
@@ -326,26 +326,26 @@ Ice::Application::main(int argc, char* argv[], const char* configFile, const Ice
InitializationData initData;
if(configFile)
{
- try
- {
- initData.properties = createProperties();
- initData.properties->load(configFile);
- }
- catch(const IceUtil::Exception& ex)
- {
- cerr << argv[0] << ": " << ex << endl;
- return EXIT_FAILURE;
- }
- catch(const std::exception& ex)
- {
- cerr << argv[0] << ": std::exception: " << ex.what() << endl;
- return EXIT_FAILURE;
- }
- catch(...)
- {
- cerr << argv[0] << ": unknown exception" << endl;
- return EXIT_FAILURE;
- }
+ try
+ {
+ initData.properties = createProperties();
+ initData.properties->load(configFile);
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ cerr << argv[0] << ": " << ex << endl;
+ return EXIT_FAILURE;
+ }
+ catch(const std::exception& ex)
+ {
+ cerr << argv[0] << ": std::exception: " << ex.what() << endl;
+ return EXIT_FAILURE;
+ }
+ catch(...)
+ {
+ cerr << argv[0] << ": unknown exception" << endl;
+ return EXIT_FAILURE;
+ }
}
initData.logger = logger;
return main(argc, argv, initData);
@@ -356,133 +356,133 @@ Ice::Application::main(int argc, char* argv[], const InitializationData& initDat
{
if(_communicator != 0)
{
- cerr << argv[0] << ": only one instance of the Application class can be used" << endl;
- return EXIT_FAILURE;
+ cerr << argv[0] << ": only one instance of the Application class can be used" << endl;
+ return EXIT_FAILURE;
}
int status;
try
{
- //
- // The ctrlCHandler must be created before starting any thread, in particular
- // before initializing the communicator.
- //
- CtrlCHandler ctrCHandler;
- _ctrlCHandler = &ctrCHandler;
-
- try
- {
- if(_condVar.get() == 0)
- {
- _condVar.reset(new Cond);
- }
-
- _interrupted = false;
- _appName = argv[0];
-
- _application = this;
- _communicator = initialize(argc, argv, initData);
- _destroyed = false;
-
- //
- // Used by destroyOnInterruptCallback and shutdownOnInterruptCallback.
- //
- _nohup = (_communicator->getProperties()->getPropertyAsInt("Ice.Nohup") > 0);
-
- //
- // The default is to destroy when a signal is received.
- //
- destroyOnInterrupt();
- status = run(argc, argv);
- }
- catch(const IceUtil::Exception& ex)
- {
- cerr << _appName << ": " << ex << endl;
- status = EXIT_FAILURE;
- }
- catch(const std::exception& ex)
- {
- cerr << _appName << ": std::exception: " << ex.what() << endl;
- status = EXIT_FAILURE;
- }
- catch(const std::string& msg)
- {
- cerr << _appName << ": " << msg << endl;
- status = EXIT_FAILURE;
- }
- catch(const char* msg)
- {
- cerr << _appName << ": " << msg << endl;
- status = EXIT_FAILURE;
- }
- catch(...)
- {
- cerr << _appName << ": unknown exception" << endl;
- status = EXIT_FAILURE;
- }
-
- //
- // Don't want any new interrupt and at this point (post-run),
- // it would not make sense to release a held signal to run
- // shutdown or destroy.
- //
- ignoreInterrupt();
-
- {
- StaticMutex::Lock lock(_mutex);
- while(_callbackInProgress)
- {
- _condVar->wait(lock);
- }
- if(_destroyed)
- {
- _communicator = 0;
- }
- else
- {
- _destroyed = true;
- //
- // And _communicator != 0, meaning will be destroyed
- // next, _destroyed = true also ensures that any
- // remaining callback won't do anything
- //
- }
- _application = 0;
- }
-
- if(_communicator != 0)
- {
- try
- {
- _communicator->destroy();
- }
- catch(const IceUtil::Exception& ex)
- {
- cerr << _appName << ": " << ex << endl;
- status = EXIT_FAILURE;
- }
- catch(const std::exception& ex)
- {
- cerr << _appName << ": std::exception: " << ex.what() << endl;
- status = EXIT_FAILURE;
- }
- catch(...)
- {
- cerr << _appName << ": unknown exception" << endl;
- status = EXIT_FAILURE;
- }
- _communicator = 0;
- }
-
- //
- // Set _ctrlCHandler to 0 only once communicator->destroy() has completed.
- //
- _ctrlCHandler = 0;
+ //
+ // The ctrlCHandler must be created before starting any thread, in particular
+ // before initializing the communicator.
+ //
+ CtrlCHandler ctrCHandler;
+ _ctrlCHandler = &ctrCHandler;
+
+ try
+ {
+ if(_condVar.get() == 0)
+ {
+ _condVar.reset(new Cond);
+ }
+
+ _interrupted = false;
+ _appName = argv[0];
+
+ _application = this;
+ _communicator = initialize(argc, argv, initData);
+ _destroyed = false;
+
+ //
+ // Used by destroyOnInterruptCallback and shutdownOnInterruptCallback.
+ //
+ _nohup = (_communicator->getProperties()->getPropertyAsInt("Ice.Nohup") > 0);
+
+ //
+ // The default is to destroy when a signal is received.
+ //
+ destroyOnInterrupt();
+ status = run(argc, argv);
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ cerr << _appName << ": " << ex << endl;
+ status = EXIT_FAILURE;
+ }
+ catch(const std::exception& ex)
+ {
+ cerr << _appName << ": std::exception: " << ex.what() << endl;
+ status = EXIT_FAILURE;
+ }
+ catch(const std::string& msg)
+ {
+ cerr << _appName << ": " << msg << endl;
+ status = EXIT_FAILURE;
+ }
+ catch(const char* msg)
+ {
+ cerr << _appName << ": " << msg << endl;
+ status = EXIT_FAILURE;
+ }
+ catch(...)
+ {
+ cerr << _appName << ": unknown exception" << endl;
+ status = EXIT_FAILURE;
+ }
+
+ //
+ // Don't want any new interrupt and at this point (post-run),
+ // it would not make sense to release a held signal to run
+ // shutdown or destroy.
+ //
+ ignoreInterrupt();
+
+ {
+ StaticMutex::Lock lock(_mutex);
+ while(_callbackInProgress)
+ {
+ _condVar->wait(lock);
+ }
+ if(_destroyed)
+ {
+ _communicator = 0;
+ }
+ else
+ {
+ _destroyed = true;
+ //
+ // And _communicator != 0, meaning will be destroyed
+ // next, _destroyed = true also ensures that any
+ // remaining callback won't do anything
+ //
+ }
+ _application = 0;
+ }
+
+ if(_communicator != 0)
+ {
+ try
+ {
+ _communicator->destroy();
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ cerr << _appName << ": " << ex << endl;
+ status = EXIT_FAILURE;
+ }
+ catch(const std::exception& ex)
+ {
+ cerr << _appName << ": std::exception: " << ex.what() << endl;
+ status = EXIT_FAILURE;
+ }
+ catch(...)
+ {
+ cerr << _appName << ": unknown exception" << endl;
+ status = EXIT_FAILURE;
+ }
+ _communicator = 0;
+ }
+
+ //
+ // Set _ctrlCHandler to 0 only once communicator->destroy() has completed.
+ //
+ _ctrlCHandler = 0;
}
catch(const CtrlCHandlerException&)
{
- cerr << argv[0] << ": only one instance of the Application class can be used" << endl;
- status = EXIT_FAILURE;
+ cerr << argv[0] << ": only one instance of the Application class can be used" << endl;
+ status = EXIT_FAILURE;
}
return status;
@@ -513,13 +513,13 @@ Ice::Application::destroyOnInterrupt()
//
if(_ctrlCHandler != 0)
{
- StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
- if(_ctrlCHandler->getCallback() == holdInterruptCallback)
- {
- _released = true;
- _condVar->signal();
- }
- _ctrlCHandler->setCallback(destroyOnInterruptCallback);
+ StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
+ if(_ctrlCHandler->getCallback() == holdInterruptCallback)
+ {
+ _released = true;
+ _condVar->signal();
+ }
+ _ctrlCHandler->setCallback(destroyOnInterruptCallback);
}
}
@@ -528,13 +528,13 @@ Ice::Application::shutdownOnInterrupt()
{
if(_ctrlCHandler != 0)
{
- StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
- if(_ctrlCHandler->getCallback() == holdInterruptCallback)
- {
- _released = true;
- _condVar->signal();
- }
- _ctrlCHandler->setCallback(shutdownOnInterruptCallback);
+ StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
+ if(_ctrlCHandler->getCallback() == holdInterruptCallback)
+ {
+ _released = true;
+ _condVar->signal();
+ }
+ _ctrlCHandler->setCallback(shutdownOnInterruptCallback);
}
}
@@ -543,13 +543,13 @@ Ice::Application::ignoreInterrupt()
{
if(_ctrlCHandler != 0)
{
- StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
- if(_ctrlCHandler->getCallback() == holdInterruptCallback)
- {
- _released = true;
- _condVar->signal();
- }
- _ctrlCHandler->setCallback(0);
+ StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
+ if(_ctrlCHandler->getCallback() == holdInterruptCallback)
+ {
+ _released = true;
+ _condVar->signal();
+ }
+ _ctrlCHandler->setCallback(0);
}
}
@@ -558,13 +558,13 @@ Ice::Application::callbackOnInterrupt()
{
if(_ctrlCHandler != 0)
{
- StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
- if(_ctrlCHandler->getCallback() == holdInterruptCallback)
- {
- _released = true;
- _condVar->signal();
- }
- _ctrlCHandler->setCallback(callbackOnInterruptCallback);
+ StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
+ if(_ctrlCHandler->getCallback() == holdInterruptCallback)
+ {
+ _released = true;
+ _condVar->signal();
+ }
+ _ctrlCHandler->setCallback(callbackOnInterruptCallback);
}
}
@@ -573,14 +573,14 @@ Ice::Application::holdInterrupt()
{
if(_ctrlCHandler != 0)
{
- StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
- if(_ctrlCHandler->getCallback() != holdInterruptCallback)
- {
- _previousCallback = _ctrlCHandler->getCallback();
- _released = false;
- _ctrlCHandler->setCallback(holdInterruptCallback);
- }
- // else, we were already holding signals
+ StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
+ if(_ctrlCHandler->getCallback() != holdInterruptCallback)
+ {
+ _previousCallback = _ctrlCHandler->getCallback();
+ _released = false;
+ _ctrlCHandler->setCallback(holdInterruptCallback);
+ }
+ // else, we were already holding signals
}
}
@@ -589,21 +589,21 @@ Ice::Application::releaseInterrupt()
{
if(_ctrlCHandler != 0)
{
- StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
- if(_ctrlCHandler->getCallback() == holdInterruptCallback)
- {
- //
- // Note that it's very possible no signal is held;
- // in this case the callback is just replaced and
- // setting _released to true and signalling _condVar
- // do no harm.
- //
-
- _released = true;
- _ctrlCHandler->setCallback(_previousCallback);
- _condVar->signal();
- }
- // Else nothing to release.
+ StaticMutex::Lock lock(_mutex); // we serialize all the interrupt-setting
+ if(_ctrlCHandler->getCallback() == holdInterruptCallback)
+ {
+ //
+ // Note that it's very possible no signal is held;
+ // in this case the callback is just replaced and
+ // setting _released to true and signalling _condVar
+ // do no harm.
+ //
+
+ _released = true;
+ _ctrlCHandler->setCallback(_previousCallback);
+ _condVar->signal();
+ }
+ // Else nothing to release.
}
}
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp
index 67ea3e484a0..2e38c4c12df 100644
--- a/cpp/src/Ice/BasicStream.cpp
+++ b/cpp/src/Ice/BasicStream.cpp
@@ -51,23 +51,23 @@ IceInternal::BasicStream::clear()
{
while(_currentReadEncaps && _currentReadEncaps != &_preAllocatedReadEncaps)
{
- ReadEncaps* oldEncaps = _currentReadEncaps;
- _currentReadEncaps = _currentReadEncaps->previous;
- delete oldEncaps;
+ ReadEncaps* oldEncaps = _currentReadEncaps;
+ _currentReadEncaps = _currentReadEncaps->previous;
+ delete oldEncaps;
}
while(_currentWriteEncaps && _currentWriteEncaps != &_preAllocatedWriteEncaps)
{
- WriteEncaps* oldEncaps = _currentWriteEncaps;
- _currentWriteEncaps = _currentWriteEncaps->previous;
- delete oldEncaps;
+ WriteEncaps* oldEncaps = _currentWriteEncaps;
+ _currentWriteEncaps = _currentWriteEncaps->previous;
+ delete oldEncaps;
}
while(_seqDataStack)
{
- SeqData* oldSeqData = _seqDataStack;
- _seqDataStack = _seqDataStack->previous;
- delete oldSeqData;
+ SeqData* oldSeqData = _seqDataStack;
+ _seqDataStack = _seqDataStack->previous;
+ delete oldSeqData;
}
delete _objectList;
@@ -91,34 +91,34 @@ IceInternal::BasicStream::swap(BasicStream& other)
if(_currentReadEncaps || other._currentReadEncaps)
{
- _preAllocatedReadEncaps.swap(other._preAllocatedReadEncaps);
+ _preAllocatedReadEncaps.swap(other._preAllocatedReadEncaps);
- if(!_currentReadEncaps)
- {
- _currentReadEncaps = &_preAllocatedReadEncaps;
- other._currentReadEncaps = 0;
- }
- else if(!other._currentReadEncaps)
- {
- other._currentReadEncaps = &other._preAllocatedReadEncaps;
- _currentReadEncaps = 0;
- }
+ if(!_currentReadEncaps)
+ {
+ _currentReadEncaps = &_preAllocatedReadEncaps;
+ other._currentReadEncaps = 0;
+ }
+ else if(!other._currentReadEncaps)
+ {
+ other._currentReadEncaps = &other._preAllocatedReadEncaps;
+ _currentReadEncaps = 0;
+ }
}
if(_currentWriteEncaps || other._currentWriteEncaps)
{
- _preAllocatedWriteEncaps.swap(other._preAllocatedWriteEncaps);
+ _preAllocatedWriteEncaps.swap(other._preAllocatedWriteEncaps);
- if(!_currentWriteEncaps)
- {
- _currentWriteEncaps = &_preAllocatedWriteEncaps;
- other._currentWriteEncaps = 0;
- }
- else if(!other._currentWriteEncaps)
- {
- other._currentWriteEncaps = &other._preAllocatedWriteEncaps;
- _currentWriteEncaps = 0;
- }
+ if(!_currentWriteEncaps)
+ {
+ _currentWriteEncaps = &_preAllocatedWriteEncaps;
+ other._currentWriteEncaps = 0;
+ }
+ else if(!other._currentWriteEncaps)
+ {
+ other._currentWriteEncaps = &other._preAllocatedWriteEncaps;
+ _currentWriteEncaps = 0;
+ }
}
std::swap(_seqDataStack, other._seqDataStack);
@@ -179,7 +179,7 @@ IceInternal::BasicStream::startSeq(int numElements, int minSize)
{
if(numElements == 0) // Optimization to avoid pushing a useless stack frame.
{
- return;
+ return;
}
//
@@ -192,17 +192,17 @@ IceInternal::BasicStream::startSeq(int numElements, int minSize)
int bytesLeft = static_cast<int>(b.end() - i);
if(_seqDataStack->previous == 0) // Outermost sequence
{
- //
- // The sequence must fit within the message.
- //
- if(numElements * minSize > bytesLeft)
- {
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
- }
+ //
+ // The sequence must fit within the message.
+ //
+ if(numElements * minSize > bytesLeft)
+ {
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ }
}
else // Nested sequence
{
- checkSeq(bytesLeft);
+ checkSeq(bytesLeft);
}
}
@@ -212,17 +212,17 @@ IceInternal::BasicStream::checkFixedSeq(int numElements, int elemSize)
int bytesLeft = static_cast<int>(b.end() - i);
if(_seqDataStack == 0) // Outermost sequence
{
- //
- // The sequence must fit within the message.
- //
- if(numElements * elemSize > bytesLeft)
- {
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
- }
+ //
+ // The sequence must fit within the message.
+ //
+ if(numElements * elemSize > bytesLeft)
+ {
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ }
}
else // Nested sequence
{
- checkSeq(bytesLeft - numElements * elemSize);
+ checkSeq(bytesLeft - numElements * elemSize);
}
}
@@ -231,7 +231,7 @@ IceInternal::BasicStream::endSeq(int sz)
{
if(sz == 0) // Pop only if something was pushed previously.
{
- return;
+ return;
}
//
@@ -300,11 +300,11 @@ IceInternal::BasicStream::skipEncaps()
read(sz);
if(sz < 0)
{
- throw NegativeSizeException(__FILE__, __LINE__);
+ throw NegativeSizeException(__FILE__, __LINE__);
}
if(i - sizeof(Int) + sz > b.end())
{
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
i += sz - sizeof(Int);
}
@@ -343,7 +343,7 @@ IceInternal::BasicStream::startReadSlice()
read(sz);
if(sz < 0)
{
- throw NegativeSizeException(__FILE__, __LINE__);
+ throw NegativeSizeException(__FILE__, __LINE__);
}
_readSlice = i - b.begin();
}
@@ -360,12 +360,12 @@ IceInternal::BasicStream::skipSlice()
read(sz);
if(sz < 0)
{
- throw NegativeSizeException(__FILE__, __LINE__);
+ throw NegativeSizeException(__FILE__, __LINE__);
}
i += sz - sizeof(Int);
if(i > b.end())
{
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
}
@@ -375,14 +375,14 @@ IceInternal::BasicStream::writeTypeId(const string& id)
TypeIdWriteMap::const_iterator k = _currentWriteEncaps->typeIdMap->find(id);
if(k != _currentWriteEncaps->typeIdMap->end())
{
- write(true);
- writeSize(k->second);
+ write(true);
+ writeSize(k->second);
}
else
{
- _currentWriteEncaps->typeIdMap->insert(make_pair(id, ++_currentWriteEncaps->typeIdIndex));
- write(false);
- write(id, false);
+ _currentWriteEncaps->typeIdMap->insert(make_pair(id, ++_currentWriteEncaps->typeIdIndex));
+ write(false);
+ write(id, false);
}
}
@@ -393,19 +393,19 @@ IceInternal::BasicStream::readTypeId(string& id)
read(isIndex);
if(isIndex)
{
- Ice::Int index;
- readSize(index);
- TypeIdReadMap::const_iterator k = _currentReadEncaps->typeIdMap->find(index);
- if(k == _currentReadEncaps->typeIdMap->end())
- {
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
- }
- id = k->second;
+ Ice::Int index;
+ readSize(index);
+ TypeIdReadMap::const_iterator k = _currentReadEncaps->typeIdMap->find(index);
+ if(k == _currentReadEncaps->typeIdMap->end())
+ {
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ }
+ id = k->second;
}
else
{
- read(id, false);
- _currentReadEncaps->typeIdMap->insert(make_pair(++_currentReadEncaps->typeIdIndex, id));
+ read(id, false);
+ _currentReadEncaps->typeIdMap->insert(make_pair(++_currentReadEncaps->typeIdIndex, id));
}
}
@@ -414,9 +414,9 @@ IceInternal::BasicStream::writeBlob(const vector<Byte>& v)
{
if(!v.empty())
{
- Container::size_type pos = b.size();
- resize(pos + v.size());
- memcpy(&b[pos], &v[0], v.size());
+ Container::size_type pos = b.size();
+ resize(pos + v.size());
+ memcpy(&b[pos], &v[0], v.size());
}
}
@@ -425,16 +425,16 @@ IceInternal::BasicStream::readBlob(vector<Byte>& v, Int sz)
{
if(sz > 0)
{
- if(b.end() - i < sz)
- {
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
- }
- vector<Byte>(i, i + sz).swap(v);
- i += sz;
+ if(b.end() - i < sz)
+ {
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ }
+ vector<Byte>(i, i + sz).swap(v);
+ i += sz;
}
else
{
- v.clear();
+ v.clear();
}
}
@@ -445,9 +445,9 @@ IceInternal::BasicStream::write(const Byte* begin, const Byte* end)
writeSize(sz);
if(sz > 0)
{
- Container::size_type pos = b.size();
- resize(pos + sz);
- memcpy(&b[pos], begin, sz);
+ Container::size_type pos = b.size();
+ resize(pos + sz);
+ memcpy(&b[pos], begin, sz);
}
}
@@ -476,9 +476,9 @@ IceInternal::BasicStream::write(const vector<bool>& v)
writeSize(sz);
if(sz > 0)
{
- Container::size_type pos = b.size();
- resize(pos + sz);
- copy(v.begin(), v.end(), b.begin() + pos);
+ Container::size_type pos = b.size();
+ resize(pos + sz);
+ copy(v.begin(), v.end(), b.begin() + pos);
}
}
@@ -517,7 +517,7 @@ IceInternal::BasicStream::write(const bool* begin, const bool* end)
{
Container::size_type pos = b.size();
resize(pos + sz);
- BasicStreamWriteBoolHelper<sizeof(bool)>::write(begin, pos, b, sz);
+ BasicStreamWriteBoolHelper<sizeof(bool)>::write(begin, pos, b, sz);
}
}
@@ -550,11 +550,11 @@ struct BasicStreamReadBoolHelper
bool* array = new bool[sz];
for(int idx = 0; idx < sz; ++idx)
{
- array[idx] = static_cast<bool>(*(i + idx));
+ array[idx] = static_cast<bool>(*(i + idx));
}
v.first = array;
v.second = array + sz;
- return array;
+ return array;
}
};
@@ -565,7 +565,7 @@ struct BasicStreamReadBoolHelper<1>
{
v.first = reinterpret_cast<bool*>(i);
v.second = reinterpret_cast<bool*>(i) + sz;
- return 0;
+ return 0;
}
};
@@ -580,7 +580,7 @@ IceInternal::BasicStream::read(pair<const bool*, const bool*>& v)
if(sz > 0)
{
checkFixedSeq(sz, 1);
- result = BasicStreamReadBoolHelper<sizeof(bool)>::read(v, sz, i);
+ result = BasicStreamReadBoolHelper<sizeof(bool)>::read(v, sz, i);
i += sz;
}
else
@@ -614,19 +614,19 @@ IceInternal::BasicStream::write(const Short* begin, const Short* end)
writeSize(sz);
if(sz > 0)
{
- Container::size_type pos = b.size();
- resize(pos + sz * sizeof(Short));
+ Container::size_type pos = b.size();
+ resize(pos + sz * sizeof(Short));
#ifdef ICE_BIG_ENDIAN
- const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Short) - 1;
- Byte* dest = &(*(b.begin() + pos));
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest++ = *src--;
- *dest++ = *src--;
- src += 2 * sizeof(Short);
- }
+ const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Short) - 1;
+ Byte* dest = &(*(b.begin() + pos));
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest++ = *src--;
+ *dest++ = *src--;
+ src += 2 * sizeof(Short);
+ }
#else
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Short));
+ memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Short));
#endif
}
}
@@ -636,7 +636,7 @@ IceInternal::BasicStream::read(Short& v)
{
if(b.end() - i < static_cast<int>(sizeof(Short)))
{
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
const Byte* src = &(*i);
i += sizeof(Short);
@@ -658,26 +658,26 @@ IceInternal::BasicStream::read(vector<Short>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Short)));
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Short));
- v.resize(sz);
+ checkFixedSeq(sz, static_cast<int>(sizeof(Short)));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Short));
+ v.resize(sz);
#ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Short) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Short);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Short) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Short);
+ }
#else
- copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
#endif
}
else
{
- v.clear();
+ v.clear();
}
}
@@ -689,35 +689,35 @@ IceInternal::BasicStream::read(pair<const Short*, const Short*>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Short)));
+ checkFixedSeq(sz, static_cast<int>(sizeof(Short)));
#if defined(__i386) || defined(_M_IX86)
v.first = reinterpret_cast<Short*>(i);
- i += sz * static_cast<int>(sizeof(Short));
+ i += sz * static_cast<int>(sizeof(Short));
v.second = reinterpret_cast<Short*>(i);
#else
result = new Short[sz];
v.first = result;
v.second = result + sz;
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Short));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Short));
# ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Short) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Short);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Short) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Short);
+ }
# else
- copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
# endif
#endif
}
else
{
- v.first = v.second = 0;
+ v.first = v.second = 0;
}
return result;
}
@@ -729,21 +729,21 @@ IceInternal::BasicStream::write(const Int* begin, const Int* end)
writeSize(sz);
if(sz > 0)
{
- Container::size_type pos = b.size();
- resize(pos + sz * sizeof(Int));
+ Container::size_type pos = b.size();
+ resize(pos + sz * sizeof(Int));
#ifdef ICE_BIG_ENDIAN
- const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Int) - 1;
- Byte* dest = &(*(b.begin() + pos));
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- src += 2 * sizeof(Int);
- }
+ const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Int) - 1;
+ Byte* dest = &(*(b.begin() + pos));
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ src += 2 * sizeof(Int);
+ }
#else
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Int));
+ memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Int));
#endif
}
}
@@ -755,28 +755,28 @@ IceInternal::BasicStream::read(vector<Int>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Int)));
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Int));
- v.resize(sz);
+ checkFixedSeq(sz, static_cast<int>(sizeof(Int)));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Int));
+ v.resize(sz);
#ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Int) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Int);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Int) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Int);
+ }
#else
- copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
#endif
}
else
{
- v.clear();
+ v.clear();
}
}
@@ -788,37 +788,37 @@ IceInternal::BasicStream::read(pair<const Int*, const Int*>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Int)));
+ checkFixedSeq(sz, static_cast<int>(sizeof(Int)));
#if defined(__i386) || defined(_M_IX86)
v.first = reinterpret_cast<Int*>(i);
- i += sz * static_cast<int>(sizeof(Int));
+ i += sz * static_cast<int>(sizeof(Int));
v.second = reinterpret_cast<Int*>(i);
#else
result = new Int[sz];
v.first = result;
v.second = result + sz;
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Int));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Int));
# ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Int) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Int);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Int) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Int);
+ }
# else
- copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
# endif
#endif
}
else
{
- v.first = v.second = 0;
+ v.first = v.second = 0;
}
return result;
}
@@ -859,25 +859,25 @@ IceInternal::BasicStream::write(const Long* begin, const Long* end)
writeSize(sz);
if(sz > 0)
{
- Container::size_type pos = b.size();
- resize(pos + sz * sizeof(Long));
+ Container::size_type pos = b.size();
+ resize(pos + sz * sizeof(Long));
#ifdef ICE_BIG_ENDIAN
- const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Long) - 1;
- Byte* dest = &(*(b.begin() + pos));
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- src += 2 * sizeof(Long);
- }
+ const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Long) - 1;
+ Byte* dest = &(*(b.begin() + pos));
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ src += 2 * sizeof(Long);
+ }
#else
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Long));
+ memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Long));
#endif
}
}
@@ -887,7 +887,7 @@ IceInternal::BasicStream::read(Long& v)
{
if(b.end() - i < static_cast<int>(sizeof(Long)))
{
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
const Byte* src = &(*i);
i += sizeof(Long);
@@ -921,32 +921,32 @@ IceInternal::BasicStream::read(vector<Long>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Long)));
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Long));
- v.resize(sz);
+ checkFixedSeq(sz, static_cast<int>(sizeof(Long)));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Long));
+ v.resize(sz);
#ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Long) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Long);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Long) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Long);
+ }
#else
- copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
#endif
}
else
{
- v.clear();
+ v.clear();
}
}
@@ -958,41 +958,41 @@ IceInternal::BasicStream::read(pair<const Long*, const Long*>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Long)));
+ checkFixedSeq(sz, static_cast<int>(sizeof(Long)));
#if defined(__i386) || defined(_M_IX86)
v.first = reinterpret_cast<Long*>(i);
- i += sz * static_cast<int>(sizeof(Long));
+ i += sz * static_cast<int>(sizeof(Long));
v.second = reinterpret_cast<Long*>(i);
#else
result = new Long[sz];
v.first = result;
v.second = result + sz;
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Long));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Long));
# ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Long) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Long);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Long) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Long);
+ }
# else
- copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
# endif
#endif
}
else
{
- v.first = v.second = 0;
+ v.first = v.second = 0;
}
return result;
}
@@ -1025,21 +1025,21 @@ IceInternal::BasicStream::write(const Float* begin, const Float* end)
writeSize(sz);
if(sz > 0)
{
- Container::size_type pos = b.size();
- resize(pos + sz * sizeof(Float));
+ Container::size_type pos = b.size();
+ resize(pos + sz * sizeof(Float));
#ifdef ICE_BIG_ENDIAN
- const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Float) - 1;
- Byte* dest = &(*(b.begin() + pos));
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- src += 2 * sizeof(Float);
- }
+ const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Float) - 1;
+ Byte* dest = &(*(b.begin() + pos));
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ src += 2 * sizeof(Float);
+ }
#else
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Float));
+ memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Float));
#endif
}
}
@@ -1049,7 +1049,7 @@ IceInternal::BasicStream::read(Float& v)
{
if(b.end() - i < static_cast<int>(sizeof(Float)))
{
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
const Byte* src = &(*i);
i += sizeof(Float);
@@ -1075,28 +1075,28 @@ IceInternal::BasicStream::read(vector<Float>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Float)));
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Float));
- v.resize(sz);
+ checkFixedSeq(sz, static_cast<int>(sizeof(Float)));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Float));
+ v.resize(sz);
#ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Float) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Float);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Float) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Float);
+ }
#else
- copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
#endif
}
else
{
- v.clear();
+ v.clear();
}
}
@@ -1108,37 +1108,37 @@ IceInternal::BasicStream::read(pair<const Float*, const Float*>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Float)));
+ checkFixedSeq(sz, static_cast<int>(sizeof(Float)));
#if defined(__i386) || defined(_M_IX86)
v.first = reinterpret_cast<Float*>(i);
- i += sz * static_cast<int>(sizeof(Float));
+ i += sz * static_cast<int>(sizeof(Float));
v.second = reinterpret_cast<Float*>(i);
#else
result = new Float[sz];
v.first = result;
v.second = result + sz;
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Float));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Float));
# ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Float) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Float);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Float) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Float);
+ }
# else
- copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
# endif
#endif
}
else
{
- v.first = v.second = 0;
+ v.first = v.second = 0;
}
return result;
}
@@ -1179,25 +1179,25 @@ IceInternal::BasicStream::write(const Double* begin, const Double* end)
writeSize(sz);
if(sz > 0)
{
- Container::size_type pos = b.size();
- resize(pos + sz * sizeof(Double));
+ Container::size_type pos = b.size();
+ resize(pos + sz * sizeof(Double));
#ifdef ICE_BIG_ENDIAN
- const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Double) - 1;
- Byte* dest = &(*(b.begin() + pos));
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- *dest++ = *src--;
- src += 2 * sizeof(Double);
- }
+ const Byte* src = reinterpret_cast<const Byte*>(begin) + sizeof(Double) - 1;
+ Byte* dest = &(*(b.begin() + pos));
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ *dest++ = *src--;
+ src += 2 * sizeof(Double);
+ }
#else
- memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Double));
+ memcpy(&b[pos], reinterpret_cast<const Byte*>(begin), sz * sizeof(Double));
#endif
}
}
@@ -1207,7 +1207,7 @@ IceInternal::BasicStream::read(Double& v)
{
if(b.end() - i < static_cast<int>(sizeof(Double)))
{
- throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
+ throw UnmarshalOutOfBoundsException(__FILE__, __LINE__);
}
const Byte* src = &(*i);
i += sizeof(Double);
@@ -1241,32 +1241,32 @@ IceInternal::BasicStream::read(vector<Double>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Double)));
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Double));
- v.resize(sz);
+ checkFixedSeq(sz, static_cast<int>(sizeof(Double)));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Double));
+ v.resize(sz);
#ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Double) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Double);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&v[0]) + sizeof(Double) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Double);
+ }
#else
- copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&v[0]));
#endif
}
else
{
- v.clear();
+ v.clear();
}
}
@@ -1278,41 +1278,41 @@ IceInternal::BasicStream::read(pair<const Double*, const Double*>& v)
readSize(sz);
if(sz > 0)
{
- checkFixedSeq(sz, static_cast<int>(sizeof(Double)));
+ checkFixedSeq(sz, static_cast<int>(sizeof(Double)));
#if defined(__i386) || defined(_M_IX86)
v.first = reinterpret_cast<Double*>(i);
- i += sz * static_cast<int>(sizeof(Double));
+ i += sz * static_cast<int>(sizeof(Double));
v.second = reinterpret_cast<Double*>(i);
#else
result = new Double[sz];
v.first = result;
v.second = result + sz;
- Container::iterator begin = i;
- i += sz * static_cast<int>(sizeof(Double));
+ Container::iterator begin = i;
+ i += sz * static_cast<int>(sizeof(Double));
# ifdef ICE_BIG_ENDIAN
- const Byte* src = &(*begin);
- Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Double) - 1;
- for(int j = 0 ; j < sz ; ++j)
- {
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- *dest-- = *src++;
- dest += 2 * sizeof(Double);
- }
+ const Byte* src = &(*begin);
+ Byte* dest = reinterpret_cast<Byte*>(&result[0]) + sizeof(Double) - 1;
+ for(int j = 0 ; j < sz ; ++j)
+ {
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ *dest-- = *src++;
+ dest += 2 * sizeof(Double);
+ }
# else
- copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
+ copy(begin, i, reinterpret_cast<Byte*>(&result[0]));
# endif
#endif
}
else
{
- v.first = v.second = 0;
+ v.first = v.second = 0;
}
return result;
}
@@ -1339,22 +1339,22 @@ IceInternal::BasicStream::writeConverted(const string& v)
// Impossible to tell, so we guess. If we don't guess correctly,
// we'll have to fix the mistake afterwards
//
-
+
Int guessedSize = static_cast<Int>(v.size());
writeSize(guessedSize); // writeSize() only writes the size; it does not reserve any buffer space.
-
+
size_t firstIndex = b.size();
StreamUTF8BufferI buffer(*this);
-
+
Byte* lastByte = _stringConverter->toUTF8(v.data(), v.data() + v.size(), buffer);
if(lastByte != b.end())
{
b.resize(lastByte - b.begin());
}
size_t lastIndex = b.size();
-
+
Int actualSize = static_cast<Int>(lastIndex - firstIndex);
-
+
//
// Check against the guess
//
@@ -1362,29 +1362,29 @@ IceInternal::BasicStream::writeConverted(const string& v)
{
if(guessedSize <= 254 && actualSize > 254)
{
- //
- // Move the UTF-8 sequence 4 bytes further
- // Use memmove instead of memcpy since the source and destination typically overlap.
- //
- resize(b.size() + 4);
- memmove(b.begin() + firstIndex + 4, b.begin() + firstIndex, actualSize);
+ //
+ // Move the UTF-8 sequence 4 bytes further
+ // Use memmove instead of memcpy since the source and destination typically overlap.
+ //
+ resize(b.size() + 4);
+ memmove(b.begin() + firstIndex + 4, b.begin() + firstIndex, actualSize);
}
else if(guessedSize > 254 && actualSize <= 254)
{
- //
- // Move the UTF-8 sequence 4 bytes back
- //
- memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, actualSize);
- resize(b.size() - 4);
+ //
+ // Move the UTF-8 sequence 4 bytes back
+ //
+ memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, actualSize);
+ resize(b.size() - 4);
}
if(guessedSize <= 254)
{
- rewriteSize(actualSize, b.begin() + firstIndex - 1);
+ rewriteSize(actualSize, b.begin() + firstIndex - 1);
}
else
{
- rewriteSize(actualSize, b.begin() + firstIndex - 1 - 4);
+ rewriteSize(actualSize, b.begin() + firstIndex - 1 - 4);
}
}
}
@@ -1396,10 +1396,10 @@ IceInternal::BasicStream::write(const string* begin, const string* end, bool con
writeSize(sz);
if(sz > 0)
{
- for(int i = 0; i < sz; ++i)
- {
- write(begin[i], convert);
- }
+ for(int i = 0; i < sz; ++i)
+ {
+ write(begin[i], convert);
+ }
}
}
@@ -1410,15 +1410,15 @@ IceInternal::BasicStream::read(vector<string>& v, bool convert)
readSize(sz);
if(sz > 0)
{
- startSeq(sz, 1);
- v.resize(sz);
- for(int j = 0; j < sz; ++j)
- {
- read(v[j], convert);
- checkSeq();
- endElement();
- }
- endSeq(sz);
+ startSeq(sz, 1);
+ v.resize(sz);
+ for(int j = 0; j < sz; ++j)
+ {
+ read(v[j], convert);
+ checkSeq();
+ endElement();
+ }
+ endSeq(sz);
}
else
{
@@ -1432,7 +1432,7 @@ IceInternal::BasicStream::write(const wstring& v)
if(v.empty())
{
writeSize(0);
- return;
+ return;
}
//
@@ -1440,22 +1440,22 @@ IceInternal::BasicStream::write(const wstring& v)
// Impossible to tell, so we guess. If we don't guess correctly,
// we'll have to fix the mistake afterwards
//
-
+
Int guessedSize = static_cast<Int>(v.size());
writeSize(guessedSize); // writeSize() only writes the size; it does not reserve any buffer space.
-
+
size_t firstIndex = b.size();
StreamUTF8BufferI buffer(*this);
-
+
Byte* lastByte = _wstringConverter->toUTF8(v.data(), v.data() + v.size(), buffer);
if(lastByte != b.end())
{
b.resize(lastByte - b.begin());
}
size_t lastIndex = b.size();
-
+
Int actualSize = static_cast<Int>(lastIndex - firstIndex);
-
+
//
// Check against the guess
//
@@ -1463,29 +1463,29 @@ IceInternal::BasicStream::write(const wstring& v)
{
if(guessedSize <= 254 && actualSize > 254)
{
- //
- // Move the UTF-8 sequence 4 bytes further
- // Use memmove instead of memcpy since the source and destination typically overlap.
- //
- resize(b.size() + 4);
- memmove(b.begin() + firstIndex + 4, b.begin() + firstIndex, actualSize);
+ //
+ // Move the UTF-8 sequence 4 bytes further
+ // Use memmove instead of memcpy since the source and destination typically overlap.
+ //
+ resize(b.size() + 4);
+ memmove(b.begin() + firstIndex + 4, b.begin() + firstIndex, actualSize);
}
else if(guessedSize > 254 && actualSize <= 254)
{
- //
- // Move the UTF-8 sequence 4 bytes back
- //
- memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, actualSize);
- resize(b.size() - 4);
+ //
+ // Move the UTF-8 sequence 4 bytes back
+ //
+ memmove(b.begin() + firstIndex - 4, b.begin() + firstIndex, actualSize);
+ resize(b.size() - 4);
}
if(guessedSize <= 254)
{
- rewriteSize(actualSize, b.begin() + firstIndex - 1);
+ rewriteSize(actualSize, b.begin() + firstIndex - 1);
}
else
{
- rewriteSize(actualSize, b.begin() + firstIndex - 1 - 4);
+ rewriteSize(actualSize, b.begin() + firstIndex - 1 - 4);
}
}
}
@@ -1497,10 +1497,10 @@ IceInternal::BasicStream::write(const wstring* begin, const wstring* end)
writeSize(sz);
if(sz > 0)
{
- for(int i = 0; i < sz; ++i)
- {
- write(begin[i]);
- }
+ for(int i = 0; i < sz; ++i)
+ {
+ write(begin[i]);
+ }
}
}
@@ -1511,15 +1511,15 @@ IceInternal::BasicStream::read(vector<wstring>& v)
readSize(sz);
if(sz > 0)
{
- startSeq(sz, 1);
- v.resize(sz);
- for(int j = 0; j < sz; ++j)
- {
- read(v[j]);
- checkSeq();
- endElement();
- }
- endSeq(sz);
+ startSeq(sz, 1);
+ v.resize(sz);
+ for(int j = 0; j < sz; ++j)
+ {
+ read(v[j]);
+ checkSeq();
+ endElement();
+ }
+ endSeq(sz);
}
else
{
@@ -1544,50 +1544,50 @@ IceInternal::BasicStream::write(const ObjectPtr& v)
{
if(!_currentWriteEncaps) // Lazy initialization.
{
- _currentWriteEncaps = &_preAllocatedWriteEncaps;
- _currentWriteEncaps->start = b.size();
+ _currentWriteEncaps = &_preAllocatedWriteEncaps;
+ _currentWriteEncaps->start = b.size();
}
if(!_currentWriteEncaps->toBeMarshaledMap) // Lazy initialization.
{
- _currentWriteEncaps->toBeMarshaledMap = new PtrToIndexMap;
- _currentWriteEncaps->marshaledMap = new PtrToIndexMap;
- _currentWriteEncaps->typeIdMap = new TypeIdWriteMap;
+ _currentWriteEncaps->toBeMarshaledMap = new PtrToIndexMap;
+ _currentWriteEncaps->marshaledMap = new PtrToIndexMap;
+ _currentWriteEncaps->typeIdMap = new TypeIdWriteMap;
}
if(v)
{
- //
- // Look for this instance in the to-be-marshaled map.
- //
- PtrToIndexMap::iterator p = _currentWriteEncaps->toBeMarshaledMap->find(v);
- if(p == _currentWriteEncaps->toBeMarshaledMap->end())
- {
- //
- // Didn't find it, try the marshaled map next.
- //
- PtrToIndexMap::iterator q = _currentWriteEncaps->marshaledMap->find(v);
- if(q == _currentWriteEncaps->marshaledMap->end())
- {
- //
- // We haven't seen this instance previously, create a
- // new index, and insert it into the to-be-marshaled
- // map.
- //
- q = _currentWriteEncaps->toBeMarshaledMap->insert(
- _currentWriteEncaps->toBeMarshaledMap->end(),
- pair<const ObjectPtr, Int>(v, ++_currentWriteEncaps->writeIndex));
- }
- p = q;
- }
- //
- // Write the index for the instance.
- //
- write(-(p->second));
+ //
+ // Look for this instance in the to-be-marshaled map.
+ //
+ PtrToIndexMap::iterator p = _currentWriteEncaps->toBeMarshaledMap->find(v);
+ if(p == _currentWriteEncaps->toBeMarshaledMap->end())
+ {
+ //
+ // Didn't find it, try the marshaled map next.
+ //
+ PtrToIndexMap::iterator q = _currentWriteEncaps->marshaledMap->find(v);
+ if(q == _currentWriteEncaps->marshaledMap->end())
+ {
+ //
+ // We haven't seen this instance previously, create a
+ // new index, and insert it into the to-be-marshaled
+ // map.
+ //
+ q = _currentWriteEncaps->toBeMarshaledMap->insert(
+ _currentWriteEncaps->toBeMarshaledMap->end(),
+ pair<const ObjectPtr, Int>(v, ++_currentWriteEncaps->writeIndex));
+ }
+ p = q;
+ }
+ //
+ // Write the index for the instance.
+ //
+ write(-(p->second));
}
else
{
- write(0); // Write null pointer.
+ write(0); // Write null pointer.
}
}
@@ -1596,14 +1596,14 @@ IceInternal::BasicStream::read(PatchFunc patchFunc, void* patchAddr)
{
if(!_currentReadEncaps) // Lazy initialization.
{
- _currentReadEncaps = &_preAllocatedReadEncaps;
+ _currentReadEncaps = &_preAllocatedReadEncaps;
}
if(!_currentReadEncaps->patchMap) // Lazy initialization.
{
- _currentReadEncaps->patchMap = new PatchMap;
- _currentReadEncaps->unmarshaledMap = new IndexToPtrMap;
- _currentReadEncaps->typeIdMap = new TypeIdReadMap;
+ _currentReadEncaps->patchMap = new PatchMap;
+ _currentReadEncaps->unmarshaledMap = new IndexToPtrMap;
+ _currentReadEncaps->typeIdMap = new TypeIdReadMap;
}
ObjectPtr v;
@@ -1613,30 +1613,30 @@ IceInternal::BasicStream::read(PatchFunc patchFunc, void* patchAddr)
if(index == 0)
{
- patchFunc(patchAddr, v); // Null Ptr.
- return;
+ patchFunc(patchAddr, v); // Null Ptr.
+ return;
}
if(index < 0 && patchAddr)
{
- PatchMap::iterator p = _currentReadEncaps->patchMap->find(-index);
- if(p == _currentReadEncaps->patchMap->end())
- {
- //
- // We have no outstanding instances to be patched for this
- // index, so make a new entry in the patch map.
- //
- p = _currentReadEncaps->patchMap->insert(make_pair(-index, PatchList())).first;
- }
- //
- // Append a patch entry for this instance.
- //
- PatchEntry e;
- e.patchFunc = patchFunc;
- e.patchAddr = patchAddr;
- p->second.push_back(e);
- patchPointers(-index, _currentReadEncaps->unmarshaledMap->end(), p);
- return;
+ PatchMap::iterator p = _currentReadEncaps->patchMap->find(-index);
+ if(p == _currentReadEncaps->patchMap->end())
+ {
+ //
+ // We have no outstanding instances to be patched for this
+ // index, so make a new entry in the patch map.
+ //
+ p = _currentReadEncaps->patchMap->insert(make_pair(-index, PatchList())).first;
+ }
+ //
+ // Append a patch entry for this instance.
+ //
+ PatchEntry e;
+ e.patchFunc = patchFunc;
+ e.patchAddr = patchAddr;
+ p->second.push_back(e);
+ patchPointers(-index, _currentReadEncaps->unmarshaledMap->end(), p);
+ return;
}
assert(index > 0);
@@ -1645,16 +1645,16 @@ IceInternal::BasicStream::read(PatchFunc patchFunc, void* patchAddr)
string id = mostDerivedId;
while(true)
{
- //
- // If we slice all the way down to Ice::Object, we throw
- // because Ice::Object is abstract.
- //
+ //
+ // If we slice all the way down to Ice::Object, we throw
+ // because Ice::Object is abstract.
+ //
if(id == Ice::Object::ice_staticId())
- {
- throw NoObjectFactoryException(__FILE__, __LINE__,
- "class sliced to ::Ice::Object, which is abstract",
- mostDerivedId);
- }
+ {
+ throw NoObjectFactoryException(__FILE__, __LINE__,
+ "class sliced to ::Ice::Object, which is abstract",
+ mostDerivedId);
+ }
//
// Try to find a factory registered for the specific type.
@@ -1709,7 +1709,7 @@ IceInternal::BasicStream::read(PatchFunc patchFunc, void* patchAddr)
traceSlicing("class", id, _slicingCat, _instance->initializationData().logger);
}
skipSlice(); // Slice off this derived part -- we don't understand it.
- readTypeId(id); // Read next id for next iteration.
+ readTypeId(id); // Read next id for next iteration.
continue;
}
else
@@ -1720,8 +1720,8 @@ IceInternal::BasicStream::read(PatchFunc patchFunc, void* patchAddr)
}
}
- IndexToPtrMap::const_iterator unmarshaledPos =
- _currentReadEncaps->unmarshaledMap->insert(make_pair(index, v)).first;
+ IndexToPtrMap::const_iterator unmarshaledPos =
+ _currentReadEncaps->unmarshaledMap->insert(make_pair(index, v)).first;
//
// Record each object instance so that readPendingObjects can
@@ -1734,9 +1734,9 @@ IceInternal::BasicStream::read(PatchFunc patchFunc, void* patchAddr)
}
_objectList->push_back(v);
- v->__read(this, false);
- patchPointers(index, unmarshaledPos, _currentReadEncaps->patchMap->end());
- return;
+ v->__read(this, false);
+ patchPointers(index, unmarshaledPos, _currentReadEncaps->patchMap->end());
+ return;
}
//
@@ -1754,7 +1754,7 @@ IceInternal::BasicStream::write(const UserException& v)
v.__write(this);
if(v.__usesClasses())
{
- writePendingObjects();
+ writePendingObjects();
}
}
@@ -1768,49 +1768,49 @@ IceInternal::BasicStream::throwException()
read(id, false);
for(;;)
{
- //
- // Look for a factory for this ID.
- //
- UserExceptionFactoryPtr factory = factoryTable->getExceptionFactory(id);
- if(factory)
- {
- //
- // Got factory -- get the factory to instantiate the
- // exception, initialize the exception members, and throw
- // the exception.
- //
- try
- {
- factory->createAndThrow();
- }
- catch(UserException& ex)
- {
- ex.__read(this, false);
- if(usesClasses)
- {
- readPendingObjects();
- }
- ex.ice_throw();
- }
- }
- else
- {
- //
- // Performance sensitive, so we use lazy initialization
- // for tracing.
- //
- if(_traceSlicing == -1)
- {
- _traceSlicing = _instance->traceLevels()->slicing;
- _slicingCat = _instance->traceLevels()->slicingCat;
- }
- if(_traceSlicing > 0)
- {
- traceSlicing("exception", id, _slicingCat, _instance->initializationData().logger);
- }
- skipSlice(); // Slice off what we don't understand.
- read(id, false); // Read type id for next slice.
- }
+ //
+ // Look for a factory for this ID.
+ //
+ UserExceptionFactoryPtr factory = factoryTable->getExceptionFactory(id);
+ if(factory)
+ {
+ //
+ // Got factory -- get the factory to instantiate the
+ // exception, initialize the exception members, and throw
+ // the exception.
+ //
+ try
+ {
+ factory->createAndThrow();
+ }
+ catch(UserException& ex)
+ {
+ ex.__read(this, false);
+ if(usesClasses)
+ {
+ readPendingObjects();
+ }
+ ex.ice_throw();
+ }
+ }
+ else
+ {
+ //
+ // Performance sensitive, so we use lazy initialization
+ // for tracing.
+ //
+ if(_traceSlicing == -1)
+ {
+ _traceSlicing = _instance->traceLevels()->slicing;
+ _slicingCat = _instance->traceLevels()->slicingCat;
+ }
+ if(_traceSlicing > 0)
+ {
+ traceSlicing("exception", id, _slicingCat, _instance->initializationData().logger);
+ }
+ skipSlice(); // Slice off what we don't understand.
+ read(id, false); // Read type id for next slice.
+ }
}
//
@@ -1827,35 +1827,35 @@ IceInternal::BasicStream::writePendingObjects()
{
if(_currentWriteEncaps && _currentWriteEncaps->toBeMarshaledMap)
{
- while(_currentWriteEncaps->toBeMarshaledMap->size())
- {
- PtrToIndexMap savedMap = *_currentWriteEncaps->toBeMarshaledMap;
- writeSize(static_cast<Int>(savedMap.size()));
- for(PtrToIndexMap::iterator p = savedMap.begin(); p != savedMap.end(); ++p)
- {
- //
- // Add an instance from the old to-be-marshaled map to
- // the marshaled map and then ask the instance to
- // marshal itself. Any new class instances that are
- // triggered by the classes marshaled are added to
- // toBeMarshaledMap.
- //
- _currentWriteEncaps->marshaledMap->insert(*p);
- writeInstance(p->first, p->second);
- }
-
- //
- // We have marshaled all the instances for this pass,
- // substract what we have marshaled from the
- // toBeMarshaledMap.
- //
- PtrToIndexMap newMap;
- set_difference(_currentWriteEncaps->toBeMarshaledMap->begin(),
- _currentWriteEncaps->toBeMarshaledMap->end(),
- savedMap.begin(), savedMap.end(),
- insert_iterator<PtrToIndexMap>(newMap, newMap.begin()));
- *_currentWriteEncaps->toBeMarshaledMap = newMap;
- }
+ while(_currentWriteEncaps->toBeMarshaledMap->size())
+ {
+ PtrToIndexMap savedMap = *_currentWriteEncaps->toBeMarshaledMap;
+ writeSize(static_cast<Int>(savedMap.size()));
+ for(PtrToIndexMap::iterator p = savedMap.begin(); p != savedMap.end(); ++p)
+ {
+ //
+ // Add an instance from the old to-be-marshaled map to
+ // the marshaled map and then ask the instance to
+ // marshal itself. Any new class instances that are
+ // triggered by the classes marshaled are added to
+ // toBeMarshaledMap.
+ //
+ _currentWriteEncaps->marshaledMap->insert(*p);
+ writeInstance(p->first, p->second);
+ }
+
+ //
+ // We have marshaled all the instances for this pass,
+ // substract what we have marshaled from the
+ // toBeMarshaledMap.
+ //
+ PtrToIndexMap newMap;
+ set_difference(_currentWriteEncaps->toBeMarshaledMap->begin(),
+ _currentWriteEncaps->toBeMarshaledMap->end(),
+ savedMap.begin(), savedMap.end(),
+ insert_iterator<PtrToIndexMap>(newMap, newMap.begin()));
+ *_currentWriteEncaps->toBeMarshaledMap = newMap;
+ }
}
writeSize(0); // Zero marker indicates end of sequence of sequences of instances.
}
@@ -1866,11 +1866,11 @@ IceInternal::BasicStream::readPendingObjects()
Int num;
do
{
- readSize(num);
- for(Int k = num; k > 0; --k)
- {
- read(0, 0);
- }
+ readSize(num);
+ for(Int k = num; k > 0; --k)
+ {
+ read(0, 0);
+ }
}
while(num);
@@ -1970,7 +1970,7 @@ IceInternal::BasicStream::writeInstance(const ObjectPtr& v, Int index)
void
IceInternal::BasicStream::patchPointers(Int index, IndexToPtrMap::const_iterator unmarshaledPos,
- PatchMap::iterator patchPos)
+ PatchMap::iterator patchPos)
{
//
// Called whenever we have unmarshaled a new instance. The index
@@ -1981,34 +1981,34 @@ IceInternal::BasicStream::patchPointers(Int index, IndexToPtrMap::const_iterator
// with the new address.
//
assert( (unmarshaledPos != _currentReadEncaps->unmarshaledMap->end()
- && patchPos == _currentReadEncaps->patchMap->end())
- || (unmarshaledPos == _currentReadEncaps->unmarshaledMap->end()
- && patchPos != _currentReadEncaps->patchMap->end())
- );
+ && patchPos == _currentReadEncaps->patchMap->end())
+ || (unmarshaledPos == _currentReadEncaps->unmarshaledMap->end()
+ && patchPos != _currentReadEncaps->patchMap->end())
+ );
if(unmarshaledPos != _currentReadEncaps->unmarshaledMap->end())
{
- //
- // We have just unmarshaled an instance -- check if something
- // needs patching for that instance.
- //
- patchPos = _currentReadEncaps->patchMap->find(index);
- if(patchPos == _currentReadEncaps->patchMap->end())
- {
- return; // We don't have anything to patch for the instance just unmarshaled.
- }
+ //
+ // We have just unmarshaled an instance -- check if something
+ // needs patching for that instance.
+ //
+ patchPos = _currentReadEncaps->patchMap->find(index);
+ if(patchPos == _currentReadEncaps->patchMap->end())
+ {
+ return; // We don't have anything to patch for the instance just unmarshaled.
+ }
}
else
{
- //
- // We have just unmarshaled an index -- check if we have
- // unmarshaled the instance for that index yet.
- //
- unmarshaledPos = _currentReadEncaps->unmarshaledMap->find(index);
- if(unmarshaledPos == _currentReadEncaps->unmarshaledMap->end())
- {
- return; // We haven't unmarshaled the instance yet.
- }
+ //
+ // We have just unmarshaled an index -- check if we have
+ // unmarshaled the instance for that index yet.
+ //
+ unmarshaledPos = _currentReadEncaps->unmarshaledMap->find(index);
+ if(unmarshaledPos == _currentReadEncaps->unmarshaledMap->end())
+ {
+ return; // We haven't unmarshaled the instance yet.
+ }
}
assert(patchPos->second.size() > 0);
@@ -2020,7 +2020,7 @@ IceInternal::BasicStream::patchPointers(Int index, IndexToPtrMap::const_iterator
//
for(PatchList::iterator k = patchPos->second.begin(); k != patchPos->second.end(); ++k)
{
- (*k->patchFunc)(k->patchAddr, v);
+ (*k->patchFunc)(k->patchAddr, v);
}
//
diff --git a/cpp/src/Ice/Buffer.cpp b/cpp/src/Ice/Buffer.cpp
index b0b4ffecdd7..ba09f6f3cfb 100644
--- a/cpp/src/Ice/Buffer.cpp
+++ b/cpp/src/Ice/Buffer.cpp
@@ -58,31 +58,31 @@ IceInternal::Buffer::Container::reserve(size_type n)
{
if(n > _capacity)
{
- _capacity = std::max<size_type>(n, std::min(2 * _capacity, _maxCapacity));
- _capacity = std::max<size_type>(static_cast<size_type>(240), _capacity);
+ _capacity = std::max<size_type>(n, std::min(2 * _capacity, _maxCapacity));
+ _capacity = std::max<size_type>(static_cast<size_type>(240), _capacity);
}
else if(n < _capacity)
{
- _capacity = n;
+ _capacity = n;
}
else
{
- return;
+ return;
}
if(_buf)
{
- _buf = reinterpret_cast<pointer>(::realloc(_buf, _capacity));
+ _buf = reinterpret_cast<pointer>(::realloc(_buf, _capacity));
}
else
{
- _buf = reinterpret_cast<pointer>(::malloc(_capacity));
+ _buf = reinterpret_cast<pointer>(::malloc(_capacity));
}
-
+
if(!_buf)
{
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
}
diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp
index ec72da06d01..c7ca49ea899 100644
--- a/cpp/src/Ice/CommunicatorI.cpp
+++ b/cpp/src/Ice/CommunicatorI.cpp
@@ -35,7 +35,7 @@ IceUtil::Handle<IceInternal::GC> theCollector = 0;
struct GarbageCollectorStats
{
GarbageCollectorStats() :
- runs(0), examined(0), collected(0)
+ runs(0), examined(0), collected(0)
{
}
int runs;
@@ -56,15 +56,15 @@ printGCStats(const IceInternal::GCStats& stats)
{
if(gcTraceLevel)
{
- if(gcTraceLevel > 1)
- {
- Trace out(getProcessLogger(), gcTraceCat);
- out << stats.collected << "/" << stats.examined << ", " << stats.time * 1000 << "ms";
- }
- ++gcStats.runs;
- gcStats.examined += stats.examined;
- gcStats.collected += stats.collected;
- gcStats.time += stats.time;
+ if(gcTraceLevel > 1)
+ {
+ Trace out(getProcessLogger(), gcTraceCat);
+ out << stats.collected << "/" << stats.examined << ", " << stats.time * 1000 << "ms";
+ }
+ ++gcStats.runs;
+ gcStats.examined += stats.examined;
+ gcStats.collected += stats.collected;
+ gcStats.time += stats.time;
}
}
@@ -73,37 +73,37 @@ Ice::CommunicatorI::destroy()
{
if(_instance->destroy())
{
- IceUtil::StaticMutex::Lock sync(gcMutex);
-
- //
- // Wait for the collector thread to stop if this is the last communicator
- // to be destroyed.
- //
- bool last = (--communicatorCount == 0);
- if(last && gcInterval > 0 && theCollector)
- {
- theCollector->stop();
- }
-
- if(theCollector)
+ IceUtil::StaticMutex::Lock sync(gcMutex);
+
+ //
+ // Wait for the collector thread to stop if this is the last communicator
+ // to be destroyed.
+ //
+ bool last = (--communicatorCount == 0);
+ if(last && gcInterval > 0 && theCollector)
+ {
+ theCollector->stop();
+ }
+
+ if(theCollector)
{
- theCollector->collectGarbage(); // Collect whenever a communicator is destroyed.
- }
-
- if(last)
- {
- if(gcTraceLevel)
- {
- Trace out(getProcessLogger(), gcTraceCat);
- out << "totals: " << gcStats.collected << "/" << gcStats.examined << ", "
- << gcStats.time * 1000 << "ms" << ", " << gcStats.runs << " run";
- if(gcStats.runs != 1)
- {
- out << "s";
- }
- }
- theCollector = 0; // Force destruction of the collector.
- }
+ theCollector->collectGarbage(); // Collect whenever a communicator is destroyed.
+ }
+
+ if(last)
+ {
+ if(gcTraceLevel)
+ {
+ Trace out(getProcessLogger(), gcTraceCat);
+ out << "totals: " << gcStats.collected << "/" << gcStats.examined << ", "
+ << gcStats.time * 1000 << "ms" << ", " << gcStats.runs << " run";
+ if(gcStats.runs != 1)
+ {
+ out << "s";
+ }
+ }
+ theCollector = 0; // Force destruction of the collector.
+ }
}
}
@@ -263,47 +263,47 @@ Ice::CommunicatorI::CommunicatorI(const InitializationData& initData)
__setNoDelete(true);
try
{
- const_cast<InstancePtr&>(_instance) = new Instance(this, initData);
+ const_cast<InstancePtr&>(_instance) = new Instance(this, initData);
//
// Keep a reference to the dynamic library list to ensure
// the libraries are not unloaded until this Communicator's
// destructor is invoked.
//
- const_cast<DynamicLibraryListPtr&>(_dynamicLibraryList) = _instance->dynamicLibraryList();
+ const_cast<DynamicLibraryListPtr&>(_dynamicLibraryList) = _instance->dynamicLibraryList();
}
catch(...)
{
- __setNoDelete(false);
- throw;
+ __setNoDelete(false);
+ throw;
}
__setNoDelete(false);
{
- //
- // If this is the first communicator that is created, use that communicator's
- // property settings to determine whether to start the garbage collector.
- // We remember that communicator's trace and logger settings so the garbage
- // collector can continue to log messages even if the first communicator that
- // is created isn't the last communicator to be destroyed.
- //
- IceUtil::StaticMutex::Lock sync(gcMutex);
- static bool gcOnce = true;
- if(gcOnce)
- {
- gcTraceLevel = _instance->traceLevels()->gc;
- gcTraceCat = _instance->traceLevels()->gcCat;
- gcInterval = _instance->initializationData().properties->getPropertyAsInt("Ice.GC.Interval");
- gcOnce = false;
- }
- if(++communicatorCount == 1)
- {
- theCollector = new IceInternal::GC(gcInterval, printGCStats);
- if(gcInterval > 0)
- {
- theCollector->start();
- }
- }
+ //
+ // If this is the first communicator that is created, use that communicator's
+ // property settings to determine whether to start the garbage collector.
+ // We remember that communicator's trace and logger settings so the garbage
+ // collector can continue to log messages even if the first communicator that
+ // is created isn't the last communicator to be destroyed.
+ //
+ IceUtil::StaticMutex::Lock sync(gcMutex);
+ static bool gcOnce = true;
+ if(gcOnce)
+ {
+ gcTraceLevel = _instance->traceLevels()->gc;
+ gcTraceCat = _instance->traceLevels()->gcCat;
+ gcInterval = _instance->initializationData().properties->getPropertyAsInt("Ice.GC.Interval");
+ gcOnce = false;
+ }
+ if(++communicatorCount == 1)
+ {
+ theCollector = new IceInternal::GC(gcInterval, printGCStats);
+ if(gcInterval > 0)
+ {
+ theCollector->start();
+ }
+ }
}
}
@@ -311,8 +311,8 @@ Ice::CommunicatorI::~CommunicatorI()
{
if(!_instance->destroyed())
{
- Warning out(_instance->initializationData().logger);
- out << "Ice::Communicator::destroy() has not been called";
+ Warning out(_instance->initializationData().logger);
+ out << "Ice::Communicator::destroy() has not been called";
}
}
@@ -321,11 +321,11 @@ Ice::CommunicatorI::finishSetup(int& argc, char* argv[])
{
try
{
- _instance->finishSetup(argc, argv);
+ _instance->finishSetup(argc, argv);
}
catch(...)
{
- _instance->destroy();
- throw;
+ _instance->destroy();
+ throw;
}
}
diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp
index 5b33b528d5a..3008dfaa485 100644
--- a/cpp/src/Ice/ConnectionFactory.cpp
+++ b/cpp/src/Ice/ConnectionFactory.cpp
@@ -45,18 +45,18 @@ IceInternal::OutgoingConnectionFactory::destroy()
if(_destroyed)
{
- return;
+ return;
}
#ifdef _STLP_BEGIN_NAMESPACE
// voidbind2nd is an STLport extension for broken compilers in IceUtil/Functional.h
for_each(_connections.begin(), _connections.end(),
- voidbind2nd(Ice::secondVoidMemFun1<EndpointIPtr, ConnectionI, ConnectionI::DestructionReason>
- (&ConnectionI::destroy), ConnectionI::CommunicatorDestroyed));
+ voidbind2nd(Ice::secondVoidMemFun1<EndpointIPtr, ConnectionI, ConnectionI::DestructionReason>
+ (&ConnectionI::destroy), ConnectionI::CommunicatorDestroyed));
#else
for_each(_connections.begin(), _connections.end(),
- bind2nd(Ice::secondVoidMemFun1<const EndpointIPtr, ConnectionI, ConnectionI::DestructionReason>
- (&ConnectionI::destroy), ConnectionI::CommunicatorDestroyed));
+ bind2nd(Ice::secondVoidMemFun1<const EndpointIPtr, ConnectionI, ConnectionI::DestructionReason>
+ (&ConnectionI::destroy), ConnectionI::CommunicatorDestroyed));
#endif
_destroyed = true;
@@ -69,27 +69,27 @@ IceInternal::OutgoingConnectionFactory::waitUntilFinished()
multimap<EndpointIPtr, ConnectionIPtr> connections;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- //
- // First we wait until the factory is destroyed. We also wait
- // until there are no pending connections anymore. Only then
- // we can be sure the _connections contains all connections.
- //
- while(!_destroyed || !_pending.empty())
- {
- wait();
- }
-
- //
- // We want to wait until all connections are finished outside the
- // thread synchronization.
- //
- connections.swap(_connections);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ //
+ // First we wait until the factory is destroyed. We also wait
+ // until there are no pending connections anymore. Only then
+ // we can be sure the _connections contains all connections.
+ //
+ while(!_destroyed || !_pending.empty())
+ {
+ wait();
+ }
+
+ //
+ // We want to wait until all connections are finished outside the
+ // thread synchronization.
+ //
+ connections.swap(_connections);
}
for_each(connections.begin(), connections.end(),
- Ice::secondVoidMemFun<const EndpointIPtr, ConnectionI>(&ConnectionI::waitUntilFinished));
+ Ice::secondVoidMemFun<const EndpointIPtr, ConnectionI>(&ConnectionI::waitUntilFinished));
}
ConnectionIPtr
@@ -100,131 +100,131 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointIPtr>& endpt
vector<EndpointIPtr> endpoints = endpts;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
-
- //
- // Reap connections for which destruction has completed.
- //
- std::multimap<EndpointIPtr, ConnectionIPtr>::iterator p = _connections.begin();
- while(p != _connections.end())
- {
- if(p->second->isFinished())
- {
- _connections.erase(p++);
- }
- else
- {
- ++p;
- }
- }
-
- //
- // Modify endpoints with overrides.
- //
- vector<EndpointIPtr>::iterator q;
- for(q = endpoints.begin(); q != endpoints.end(); ++q)
- {
- if(_instance->defaultsAndOverrides()->overrideTimeout)
- {
- *q = (*q)->timeout(_instance->defaultsAndOverrides()->overrideTimeoutValue);
- }
-
- //
- // The Connection object does not take the compression flag of
- // endpoints into account, but instead gets the information
- // about whether messages should be compressed or not from
- // other sources. In order to allow connection sharing for
- // endpoints that differ in the value of the compression flag
- // only, we always set the compression flag to false here in
- // this connection factory.
- //
- *q = (*q)->compress(false);
- }
-
- //
- // Search for existing connections.
- //
- vector<EndpointIPtr>::const_iterator r;
- for(q = endpoints.begin(), r = endpts.begin(); q != endpoints.end(); ++q, ++r)
- {
- pair<multimap<EndpointIPtr, ConnectionIPtr>::iterator,
- multimap<EndpointIPtr, ConnectionIPtr>::iterator> pr = _connections.equal_range(*q);
-
- while(pr.first != pr.second)
- {
- //
- // Don't return connections for which destruction has
- // been initiated. The connection must also match the
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ if(_destroyed)
+ {
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ }
+
+ //
+ // Reap connections for which destruction has completed.
+ //
+ std::multimap<EndpointIPtr, ConnectionIPtr>::iterator p = _connections.begin();
+ while(p != _connections.end())
+ {
+ if(p->second->isFinished())
+ {
+ _connections.erase(p++);
+ }
+ else
+ {
+ ++p;
+ }
+ }
+
+ //
+ // Modify endpoints with overrides.
+ //
+ vector<EndpointIPtr>::iterator q;
+ for(q = endpoints.begin(); q != endpoints.end(); ++q)
+ {
+ if(_instance->defaultsAndOverrides()->overrideTimeout)
+ {
+ *q = (*q)->timeout(_instance->defaultsAndOverrides()->overrideTimeoutValue);
+ }
+
+ //
+ // The Connection object does not take the compression flag of
+ // endpoints into account, but instead gets the information
+ // about whether messages should be compressed or not from
+ // other sources. In order to allow connection sharing for
+ // endpoints that differ in the value of the compression flag
+ // only, we always set the compression flag to false here in
+ // this connection factory.
+ //
+ *q = (*q)->compress(false);
+ }
+
+ //
+ // Search for existing connections.
+ //
+ vector<EndpointIPtr>::const_iterator r;
+ for(q = endpoints.begin(), r = endpts.begin(); q != endpoints.end(); ++q, ++r)
+ {
+ pair<multimap<EndpointIPtr, ConnectionIPtr>::iterator,
+ multimap<EndpointIPtr, ConnectionIPtr>::iterator> pr = _connections.equal_range(*q);
+
+ while(pr.first != pr.second)
+ {
+ //
+ // Don't return connections for which destruction has
+ // been initiated. The connection must also match the
// requested thread-per-connection setting.
- //
- if(!pr.first->second->isDestroyed() &&
+ //
+ if(!pr.first->second->isDestroyed() &&
pr.first->second->threadPerConnection() == threadPerConnection)
- {
- if(_instance->defaultsAndOverrides()->overrideCompress)
- {
- compress = _instance->defaultsAndOverrides()->overrideCompressValue;
- }
- else
- {
- compress = (*r)->compress();
- }
-
- return pr.first->second;
- }
-
- ++pr.first;
- }
- }
-
- //
- // If some other thread is currently trying to establish a
- // connection to any of our endpoints, we wait until this
- // thread is finished.
- //
- bool searchAgain = false;
- while(!_destroyed)
- {
- for(q = endpoints.begin(); q != endpoints.end(); ++q)
- {
- if(_pending.find(*q) != _pending.end())
- {
- break;
- }
- }
-
- if(q == endpoints.end())
- {
- break;
- }
-
- searchAgain = true;
-
- wait();
- }
-
- if(_destroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
-
- //
- // Search for existing connections again if we waited above,
- // as new connections might have been added in the meantime.
- //
- if(searchAgain)
- {
- for(q = endpoints.begin(), r = endpts.begin(); q != endpoints.end(); ++q, ++r)
- {
- pair<multimap<EndpointIPtr, ConnectionIPtr>::iterator,
- multimap<EndpointIPtr, ConnectionIPtr>::iterator> pr = _connections.equal_range(*q);
-
- while(pr.first != pr.second)
- {
+ {
+ if(_instance->defaultsAndOverrides()->overrideCompress)
+ {
+ compress = _instance->defaultsAndOverrides()->overrideCompressValue;
+ }
+ else
+ {
+ compress = (*r)->compress();
+ }
+
+ return pr.first->second;
+ }
+
+ ++pr.first;
+ }
+ }
+
+ //
+ // If some other thread is currently trying to establish a
+ // connection to any of our endpoints, we wait until this
+ // thread is finished.
+ //
+ bool searchAgain = false;
+ while(!_destroyed)
+ {
+ for(q = endpoints.begin(); q != endpoints.end(); ++q)
+ {
+ if(_pending.find(*q) != _pending.end())
+ {
+ break;
+ }
+ }
+
+ if(q == endpoints.end())
+ {
+ break;
+ }
+
+ searchAgain = true;
+
+ wait();
+ }
+
+ if(_destroyed)
+ {
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ }
+
+ //
+ // Search for existing connections again if we waited above,
+ // as new connections might have been added in the meantime.
+ //
+ if(searchAgain)
+ {
+ for(q = endpoints.begin(), r = endpts.begin(); q != endpoints.end(); ++q, ++r)
+ {
+ pair<multimap<EndpointIPtr, ConnectionIPtr>::iterator,
+ multimap<EndpointIPtr, ConnectionIPtr>::iterator> pr = _connections.equal_range(*q);
+
+ while(pr.first != pr.second)
+ {
//
// Don't return connections for which destruction has
// been initiated. The connection must also match the
@@ -232,31 +232,31 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointIPtr>& endpt
//
if(!pr.first->second->isDestroyed() &&
pr.first->second->threadPerConnection() == threadPerConnection)
- {
- if(_instance->defaultsAndOverrides()->overrideCompress)
- {
- compress = _instance->defaultsAndOverrides()->overrideCompressValue;
- }
- else
- {
- compress = (*r)->compress();
- }
-
- return pr.first->second;
- }
-
- ++pr.first;
- }
- }
- }
-
- //
- // No connection to any of our endpoints exists yet, so we
- // will try to create one. To avoid that other threads try to
- // create connections to the same endpoints, we add our
- // endpoints to _pending.
- //
- _pending.insert(endpoints.begin(), endpoints.end());
+ {
+ if(_instance->defaultsAndOverrides()->overrideCompress)
+ {
+ compress = _instance->defaultsAndOverrides()->overrideCompressValue;
+ }
+ else
+ {
+ compress = (*r)->compress();
+ }
+
+ return pr.first->second;
+ }
+
+ ++pr.first;
+ }
+ }
+ }
+
+ //
+ // No connection to any of our endpoints exists yet, so we
+ // will try to create one. To avoid that other threads try to
+ // create connections to the same endpoints, we add our
+ // endpoints to _pending.
+ //
+ _pending.insert(endpoints.begin(), endpoints.end());
}
ConnectionIPtr connection;
@@ -266,112 +266,112 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointIPtr>& endpt
vector<EndpointIPtr>::const_iterator r;
for(q = endpoints.begin(), r = endpts.begin(); q != endpoints.end(); ++q, ++r)
{
- EndpointIPtr endpoint = *q;
-
- try
- {
- TransceiverPtr transceiver = endpoint->clientTransceiver();
- if(!transceiver)
- {
- ConnectorPtr connector = endpoint->connector();
- assert(connector);
-
- Int timeout;
- if(_instance->defaultsAndOverrides()->overrideConnectTimeout)
- {
- timeout = _instance->defaultsAndOverrides()->overrideConnectTimeoutValue;
- }
- // It is not necessary to check for overrideTimeout,
- // the endpoint has already been modified with this
- // override, if set.
- else
- {
- timeout = endpoint->timeout();
- }
-
- transceiver = connector->connect(timeout);
- assert(transceiver);
- }
- connection = new ConnectionI(_instance, transceiver, endpoint, 0, threadPerConnection,
+ EndpointIPtr endpoint = *q;
+
+ try
+ {
+ TransceiverPtr transceiver = endpoint->clientTransceiver();
+ if(!transceiver)
+ {
+ ConnectorPtr connector = endpoint->connector();
+ assert(connector);
+
+ Int timeout;
+ if(_instance->defaultsAndOverrides()->overrideConnectTimeout)
+ {
+ timeout = _instance->defaultsAndOverrides()->overrideConnectTimeoutValue;
+ }
+ // It is not necessary to check for overrideTimeout,
+ // the endpoint has already been modified with this
+ // override, if set.
+ else
+ {
+ timeout = endpoint->timeout();
+ }
+
+ transceiver = connector->connect(timeout);
+ assert(transceiver);
+ }
+ connection = new ConnectionI(_instance, transceiver, endpoint, 0, threadPerConnection,
_instance->threadPerConnectionStackSize());
- connection->validate();
-
- if(_instance->defaultsAndOverrides()->overrideCompress)
- {
- compress = _instance->defaultsAndOverrides()->overrideCompressValue;
- }
- else
- {
- compress = (*r)->compress();
- }
- break;
- }
- catch(const LocalException& ex)
- {
- exception.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
-
- //
- // If a connection object was constructed, then validate()
- // must have raised the exception.
- //
- if(connection)
- {
- connection->waitUntilFinished(); // We must call waitUntilFinished() for cleanup.
- connection = 0;
- }
- }
-
- TraceLevelsPtr traceLevels = _instance->traceLevels();
- if(traceLevels->retry >= 2)
- {
- Trace out(_instance->initializationData().logger, traceLevels->retryCat);
-
- out << "connection to endpoint failed";
- if(moreEndpts || q + 1 != endpoints.end())
- {
- out << ", trying next endpoint\n";
- }
- else
- {
- out << " and no more endpoints to try\n";
- }
- out << *exception.get();
- }
+ connection->validate();
+
+ if(_instance->defaultsAndOverrides()->overrideCompress)
+ {
+ compress = _instance->defaultsAndOverrides()->overrideCompressValue;
+ }
+ else
+ {
+ compress = (*r)->compress();
+ }
+ break;
+ }
+ catch(const LocalException& ex)
+ {
+ exception.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
+
+ //
+ // If a connection object was constructed, then validate()
+ // must have raised the exception.
+ //
+ if(connection)
+ {
+ connection->waitUntilFinished(); // We must call waitUntilFinished() for cleanup.
+ connection = 0;
+ }
+ }
+
+ TraceLevelsPtr traceLevels = _instance->traceLevels();
+ if(traceLevels->retry >= 2)
+ {
+ Trace out(_instance->initializationData().logger, traceLevels->retryCat);
+
+ out << "connection to endpoint failed";
+ if(moreEndpts || q + 1 != endpoints.end())
+ {
+ out << ", trying next endpoint\n";
+ }
+ else
+ {
+ out << " and no more endpoints to try\n";
+ }
+ out << *exception.get();
+ }
}
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- //
- // Signal other threads that we are done with trying to
- // establish connections to our endpoints.
- //
- for(q = endpoints.begin(); q != endpoints.end(); ++q)
- {
- _pending.erase(*q);
- }
- notifyAll();
-
- if(!connection)
- {
- assert(exception.get());
- exception->ice_throw();
- }
- else
- {
- _connections.insert(_connections.end(),
- pair<const EndpointIPtr, ConnectionIPtr>(connection->endpoint(), connection));
-
- if(_destroyed)
- {
- connection->destroy(ConnectionI::CommunicatorDestroyed);
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
- else
- {
- connection->activate();
- }
- }
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ //
+ // Signal other threads that we are done with trying to
+ // establish connections to our endpoints.
+ //
+ for(q = endpoints.begin(); q != endpoints.end(); ++q)
+ {
+ _pending.erase(*q);
+ }
+ notifyAll();
+
+ if(!connection)
+ {
+ assert(exception.get());
+ exception->ice_throw();
+ }
+ else
+ {
+ _connections.insert(_connections.end(),
+ pair<const EndpointIPtr, ConnectionIPtr>(connection->endpoint(), connection));
+
+ if(_destroyed)
+ {
+ connection->destroy(ConnectionI::CommunicatorDestroyed);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ }
+ else
+ {
+ connection->activate();
+ }
+ }
}
assert(connection);
@@ -385,7 +385,7 @@ IceInternal::OutgoingConnectionFactory::setRouterInfo(const RouterInfoPtr& route
if(_destroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
assert(routerInfo);
@@ -401,44 +401,44 @@ IceInternal::OutgoingConnectionFactory::setRouterInfo(const RouterInfoPtr& route
vector<EndpointIPtr>::const_iterator p;
for(p = endpoints.begin(); p != endpoints.end(); ++p)
{
- EndpointIPtr endpoint = *p;
-
- //
- // Modify endpoints with overrides.
- //
- if(_instance->defaultsAndOverrides()->overrideTimeout)
- {
- endpoint = endpoint->timeout(_instance->defaultsAndOverrides()->overrideTimeoutValue);
- }
-
- //
- // The Connection object does not take the compression flag of
- // endpoints into account, but instead gets the information
- // about whether messages should be compressed or not from
- // other sources. In order to allow connection sharing for
- // endpoints that differ in the value of the compression flag
- // only, we always set the compression flag to false here in
- // this connection factory.
- //
- endpoint = endpoint->compress(false);
-
- pair<multimap<EndpointIPtr, ConnectionIPtr>::iterator,
- multimap<EndpointIPtr, ConnectionIPtr>::iterator> pr = _connections.equal_range(endpoint);
-
- while(pr.first != pr.second)
- {
- try
- {
- pr.first->second->setAdapter(adapter);
- }
- catch(const Ice::LocalException&)
- {
- //
- // Ignore, the connection is being closed or closed.
- //
- }
- ++pr.first;
- }
+ EndpointIPtr endpoint = *p;
+
+ //
+ // Modify endpoints with overrides.
+ //
+ if(_instance->defaultsAndOverrides()->overrideTimeout)
+ {
+ endpoint = endpoint->timeout(_instance->defaultsAndOverrides()->overrideTimeoutValue);
+ }
+
+ //
+ // The Connection object does not take the compression flag of
+ // endpoints into account, but instead gets the information
+ // about whether messages should be compressed or not from
+ // other sources. In order to allow connection sharing for
+ // endpoints that differ in the value of the compression flag
+ // only, we always set the compression flag to false here in
+ // this connection factory.
+ //
+ endpoint = endpoint->compress(false);
+
+ pair<multimap<EndpointIPtr, ConnectionIPtr>::iterator,
+ multimap<EndpointIPtr, ConnectionIPtr>::iterator> pr = _connections.equal_range(endpoint);
+
+ while(pr.first != pr.second)
+ {
+ try
+ {
+ pr.first->second->setAdapter(adapter);
+ }
+ catch(const Ice::LocalException&)
+ {
+ //
+ // Ignore, the connection is being closed or closed.
+ //
+ }
+ ++pr.first;
+ }
}
}
@@ -449,24 +449,24 @@ IceInternal::OutgoingConnectionFactory::removeAdapter(const ObjectAdapterPtr& ad
if(_destroyed)
{
- return;
+ return;
}
for(multimap<EndpointIPtr, ConnectionIPtr>::const_iterator p = _connections.begin(); p != _connections.end(); ++p)
{
- if(p->second->getAdapter() == adapter)
- {
- try
- {
- p->second->setAdapter(0);
- }
- catch(const Ice::LocalException&)
- {
- //
- // Ignore, the connection is being closed or closed.
- //
- }
- }
+ if(p->second->getAdapter() == adapter)
+ {
+ try
+ {
+ p->second->setAdapter(0);
+ }
+ catch(const Ice::LocalException&)
+ {
+ //
+ // Ignore, the connection is being closed or closed.
+ //
+ }
+ }
}
}
@@ -476,26 +476,26 @@ IceInternal::OutgoingConnectionFactory::flushBatchRequests()
list<ConnectionIPtr> c;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- for(std::multimap<EndpointIPtr, ConnectionIPtr>::const_iterator p = _connections.begin();
- p != _connections.end();
- ++p)
- {
- c.push_back(p->second);
- }
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ for(std::multimap<EndpointIPtr, ConnectionIPtr>::const_iterator p = _connections.begin();
+ p != _connections.end();
+ ++p)
+ {
+ c.push_back(p->second);
+ }
}
for(list<ConnectionIPtr>::const_iterator p = c.begin(); p != c.end(); ++p)
{
- try
- {
- (*p)->flushBatchRequests();
- }
- catch(const LocalException&)
- {
- // Ignore.
- }
+ try
+ {
+ (*p)->flushBatchRequests();
+ }
+ catch(const LocalException&)
+ {
+ // Ignore.
+ }
}
}
@@ -538,22 +538,22 @@ IceInternal::IncomingConnectionFactory::waitUntilHolding() const
list<ConnectionIPtr> connections;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- //
- // First we wait until the connection factory itself is in holding
- // state.
- //
- while(_state < StateHolding)
- {
- wait();
- }
-
- //
- // We want to wait until all connections are in holding state
- // outside the thread synchronization.
- //
- connections = _connections;
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ //
+ // First we wait until the connection factory itself is in holding
+ // state.
+ //
+ while(_state < StateHolding)
+ {
+ wait();
+ }
+
+ //
+ // We want to wait until all connections are in holding state
+ // outside the thread synchronization.
+ //
+ connections = _connections;
}
//
@@ -569,35 +569,35 @@ IceInternal::IncomingConnectionFactory::waitUntilFinished()
list<ConnectionIPtr> connections;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- //
- // First we wait until the factory is destroyed. If we are using
- // an acceptor, we also wait for it to be closed.
- //
- while(_state != StateClosed || _acceptor)
- {
- wait();
- }
-
- threadPerIncomingConnectionFactory = _threadPerIncomingConnectionFactory;
- _threadPerIncomingConnectionFactory = 0;
-
- //
- // Clear the OA. See bug 1673 for the details of why this is necessary.
- //
- _adapter = 0;
-
- //
- // We want to wait until all connections are finished outside the
- // thread synchronization.
- //
- connections.swap(_connections);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ //
+ // First we wait until the factory is destroyed. If we are using
+ // an acceptor, we also wait for it to be closed.
+ //
+ while(_state != StateClosed || _acceptor)
+ {
+ wait();
+ }
+
+ threadPerIncomingConnectionFactory = _threadPerIncomingConnectionFactory;
+ _threadPerIncomingConnectionFactory = 0;
+
+ //
+ // Clear the OA. See bug 1673 for the details of why this is necessary.
+ //
+ _adapter = 0;
+
+ //
+ // We want to wait until all connections are finished outside the
+ // thread synchronization.
+ //
+ connections.swap(_connections);
}
if(threadPerIncomingConnectionFactory)
{
- threadPerIncomingConnectionFactory->getThreadControl().join();
+ threadPerIncomingConnectionFactory->getThreadControl().join();
}
for_each(connections.begin(), connections.end(), Ice::voidMemFun(&ConnectionI::waitUntilFinished));
@@ -615,7 +615,7 @@ IceInternal::IncomingConnectionFactory::equivalent(const EndpointIPtr& endp) con
{
if(_transceiver)
{
- return endp->equivalent(_transceiver);
+ return endp->equivalent(_transceiver);
}
assert(_acceptor);
@@ -633,7 +633,7 @@ IceInternal::IncomingConnectionFactory::connections() const
// Only copy connections which have not been destroyed.
//
remove_copy_if(_connections.begin(), _connections.end(), back_inserter(result),
- Ice::constMemFun(&ConnectionI::isDestroyed));
+ Ice::constMemFun(&ConnectionI::isDestroyed));
return result;
}
@@ -645,14 +645,14 @@ IceInternal::IncomingConnectionFactory::flushBatchRequests()
for(list<ConnectionIPtr>::const_iterator p = c.begin(); p != c.end(); ++p)
{
- try
- {
- (*p)->flushBatchRequests();
- }
- catch(const LocalException&)
- {
- // Ignore.
- }
+ try
+ {
+ (*p)->flushBatchRequests();
+ }
+ catch(const LocalException&)
+ {
+ // Ignore.
+ }
}
}
@@ -682,13 +682,13 @@ class PromoteFollower
public:
PromoteFollower(const ThreadPoolPtr& threadPool) :
- _threadPool(threadPool)
+ _threadPool(threadPool)
{
}
~PromoteFollower()
{
- _threadPool->promoteFollower();
+ _threadPool->promoteFollower();
}
private:
@@ -704,73 +704,73 @@ IceInternal::IncomingConnectionFactory::message(BasicStream&, const ThreadPoolPt
ConnectionIPtr connection;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- //
- // This makes sure that we promote a follower before we leave
- // the scope of the mutex above, but after we call accept()
- // (if we call it).
- //
- // If _threadPool is null, then this class doesn't do
- // anything.
- //
- PromoteFollower promote(threadPool);
-
- if(_state != StateActive)
- {
- IceUtil::ThreadControl::yield();
- return;
- }
-
- //
- // Reap connections for which destruction has completed.
- //
- _connections.erase(remove_if(_connections.begin(), _connections.end(),
- Ice::constMemFun(&ConnectionI::isFinished)),
- _connections.end());
-
- //
- // Now accept a new connection.
- //
- TransceiverPtr transceiver;
- try
- {
- transceiver = _acceptor->accept(0);
- }
- catch(const SocketException&)
- {
- // Ignore socket exceptions.
- return;
- }
- catch(const TimeoutException&)
- {
- // Ignore timeouts.
- return;
- }
- catch(const LocalException& ex)
- {
- // Warn about other Ice local exceptions.
- if(_warn)
- {
- Warning out(_instance->initializationData().logger);
- out << "connection exception:\n" << ex << '\n' << _acceptor->toString();
- }
- return;
- }
-
- assert(transceiver);
-
- try
- {
- connection = new ConnectionI(_instance, transceiver, _endpoint, _adapter, _threadPerConnection,
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ //
+ // This makes sure that we promote a follower before we leave
+ // the scope of the mutex above, but after we call accept()
+ // (if we call it).
+ //
+ // If _threadPool is null, then this class doesn't do
+ // anything.
+ //
+ PromoteFollower promote(threadPool);
+
+ if(_state != StateActive)
+ {
+ IceUtil::ThreadControl::yield();
+ return;
+ }
+
+ //
+ // Reap connections for which destruction has completed.
+ //
+ _connections.erase(remove_if(_connections.begin(), _connections.end(),
+ Ice::constMemFun(&ConnectionI::isFinished)),
+ _connections.end());
+
+ //
+ // Now accept a new connection.
+ //
+ TransceiverPtr transceiver;
+ try
+ {
+ transceiver = _acceptor->accept(0);
+ }
+ catch(const SocketException&)
+ {
+ // Ignore socket exceptions.
+ return;
+ }
+ catch(const TimeoutException&)
+ {
+ // Ignore timeouts.
+ return;
+ }
+ catch(const LocalException& ex)
+ {
+ // Warn about other Ice local exceptions.
+ if(_warn)
+ {
+ Warning out(_instance->initializationData().logger);
+ out << "connection exception:\n" << ex << '\n' << _acceptor->toString();
+ }
+ return;
+ }
+
+ assert(transceiver);
+
+ try
+ {
+ connection = new ConnectionI(_instance, transceiver, _endpoint, _adapter, _threadPerConnection,
_threadPerConnectionStackSize);
- }
- catch(const LocalException&)
- {
- return;
- }
+ }
+ catch(const LocalException&)
+ {
+ return;
+ }
- _connections.push_back(connection);
+ _connections.push_back(connection);
}
assert(connection);
@@ -781,14 +781,14 @@ IceInternal::IncomingConnectionFactory::message(BasicStream&, const ThreadPoolPt
//
try
{
- connection->validate();
+ connection->validate();
}
catch(const LocalException&)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- connection->waitUntilFinished(); // We must call waitUntilFinished() for cleanup.
- _connections.remove(connection);
- return;
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ connection->waitUntilFinished(); // We must call waitUntilFinished() for cleanup.
+ _connections.remove(connection);
+ return;
}
connection->activate();
@@ -808,10 +808,10 @@ IceInternal::IncomingConnectionFactory::finished(const ThreadPoolPtr& threadPool
if(_finishedCount == 0 && _state == StateClosed)
{
- dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->decFdsInUse();
- _acceptor->close();
- _acceptor = 0;
- notifyAll();
+ dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->decFdsInUse();
+ _acceptor->close();
+ _acceptor = 0;
+ notifyAll();
}
}
@@ -828,7 +828,7 @@ IceInternal::IncomingConnectionFactory::toString() const
if(_transceiver)
{
- return _transceiver->toString();
+ return _transceiver->toString();
}
assert(_acceptor);
@@ -836,9 +836,9 @@ IceInternal::IncomingConnectionFactory::toString() const
}
IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(const InstancePtr& instance,
- const EndpointIPtr& endpoint,
- const ObjectAdapterPtr& adapter,
- const string& adapterName) :
+ const EndpointIPtr& endpoint,
+ const ObjectAdapterPtr& adapter,
+ const string& adapterName) :
EventHandler(instance),
_endpoint(endpoint),
_adapter(adapter),
@@ -849,14 +849,14 @@ IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(const Instance
{
if(_instance->defaultsAndOverrides()->overrideTimeout)
{
- const_cast<EndpointIPtr&>(_endpoint) =
- _endpoint->timeout(_instance->defaultsAndOverrides()->overrideTimeoutValue);
+ const_cast<EndpointIPtr&>(_endpoint) =
+ _endpoint->timeout(_instance->defaultsAndOverrides()->overrideTimeoutValue);
}
if(_instance->defaultsAndOverrides()->overrideCompress)
{
- const_cast<EndpointIPtr&>(_endpoint) =
- _endpoint->compress(_instance->defaultsAndOverrides()->overrideCompressValue);
+ const_cast<EndpointIPtr&>(_endpoint) =
+ _endpoint->compress(_instance->defaultsAndOverrides()->overrideCompressValue);
}
ObjectAdapterI* adapterImpl = dynamic_cast<ObjectAdapterI*>(_adapter.get());
@@ -866,75 +866,75 @@ IceInternal::IncomingConnectionFactory::IncomingConnectionFactory(const Instance
const_cast<TransceiverPtr&>(_transceiver) = _endpoint->serverTransceiver(const_cast<EndpointIPtr&>(_endpoint));
if(_transceiver)
{
- ConnectionIPtr connection;
+ ConnectionIPtr connection;
- try
- {
- connection = new ConnectionI(_instance, _transceiver, _endpoint, _adapter, _threadPerConnection,
+ try
+ {
+ connection = new ConnectionI(_instance, _transceiver, _endpoint, _adapter, _threadPerConnection,
_threadPerConnectionStackSize);
- connection->validate();
- }
- catch(const LocalException&)
- {
- //
- // If a connection object was constructed, then validate()
- // must have raised the exception.
- //
- if(connection)
- {
- connection->waitUntilFinished(); // We must call waitUntilFinished() for cleanup.
- }
-
- return;
- }
-
- _connections.push_back(connection);
+ connection->validate();
+ }
+ catch(const LocalException&)
+ {
+ //
+ // If a connection object was constructed, then validate()
+ // must have raised the exception.
+ //
+ if(connection)
+ {
+ connection->waitUntilFinished(); // We must call waitUntilFinished() for cleanup.
+ }
+
+ return;
+ }
+
+ _connections.push_back(connection);
}
else
{
- _acceptor = _endpoint->acceptor(const_cast<EndpointIPtr&>(_endpoint), adapterName);
- assert(_acceptor);
- _acceptor->listen();
-
- __setNoDelete(true);
- try
- {
- if(_threadPerConnection)
- {
- //
- // If we are in thread per connection mode, we also use
- // one thread per incoming connection factory, that
- // accepts new connections on this endpoint.
- //
- _threadPerIncomingConnectionFactory = new ThreadPerIncomingConnectionFactory(this);
- _threadPerIncomingConnectionFactory->start(_threadPerConnectionStackSize);
- }
- else
- {
- adapterImpl->getThreadPool()->incFdsInUse();
- }
- }
- catch(const IceUtil::Exception& ex)
- {
- if(_threadPerConnection)
- {
- Error out(_instance->initializationData().logger);
- out << "cannot create thread for incoming connection factory:\n" << ex;
- }
-
- try
- {
- _acceptor->close();
- }
- catch(const LocalException&)
- {
- // Here we ignore any exceptions in close().
- }
-
- __setNoDelete(false);
- ex.ice_throw();
- }
- __setNoDelete(false);
+ _acceptor = _endpoint->acceptor(const_cast<EndpointIPtr&>(_endpoint), adapterName);
+ assert(_acceptor);
+ _acceptor->listen();
+
+ __setNoDelete(true);
+ try
+ {
+ if(_threadPerConnection)
+ {
+ //
+ // If we are in thread per connection mode, we also use
+ // one thread per incoming connection factory, that
+ // accepts new connections on this endpoint.
+ //
+ _threadPerIncomingConnectionFactory = new ThreadPerIncomingConnectionFactory(this);
+ _threadPerIncomingConnectionFactory->start(_threadPerConnectionStackSize);
+ }
+ else
+ {
+ adapterImpl->getThreadPool()->incFdsInUse();
+ }
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ if(_threadPerConnection)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "cannot create thread for incoming connection factory:\n" << ex;
+ }
+
+ try
+ {
+ _acceptor->close();
+ }
+ catch(const LocalException&)
+ {
+ // Here we ignore any exceptions in close().
+ }
+
+ __setNoDelete(false);
+ ex.ice_throw();
+ }
+ __setNoDelete(false);
}
}
@@ -951,74 +951,74 @@ IceInternal::IncomingConnectionFactory::setState(State state)
{
if(_state == state) // Don't switch twice.
{
- return;
+ return;
}
switch(state)
{
- case StateActive:
- {
- if(_state != StateHolding) // Can only switch from holding to active.
- {
- return;
- }
- if(!_threadPerConnection && _acceptor)
- {
- registerWithPool();
- }
- for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::activate));
- break;
- }
-
- case StateHolding:
- {
- if(_state != StateActive) // Can only switch from active to holding.
- {
- return;
- }
- if(!_threadPerConnection && _acceptor)
- {
- unregisterWithPool();
- }
- for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::hold));
- break;
- }
-
- case StateClosed:
- {
- if(_acceptor)
- {
- if(_threadPerConnection)
- {
- //
- // If we are in thread per connection mode, we connect
- // to our own acceptor, which unblocks our thread per
- // incoming connection factory stuck in accept().
- //
- _acceptor->connectToSelf();
- }
- else
- {
- //
- // Otherwise we first must make sure that we are
- // registered, then we unregister, and let finished()
- // do the close.
- //
- registerWithPool();
- unregisterWithPool();
- }
- }
+ case StateActive:
+ {
+ if(_state != StateHolding) // Can only switch from holding to active.
+ {
+ return;
+ }
+ if(!_threadPerConnection && _acceptor)
+ {
+ registerWithPool();
+ }
+ for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::activate));
+ break;
+ }
+
+ case StateHolding:
+ {
+ if(_state != StateActive) // Can only switch from active to holding.
+ {
+ return;
+ }
+ if(!_threadPerConnection && _acceptor)
+ {
+ unregisterWithPool();
+ }
+ for_each(_connections.begin(), _connections.end(), Ice::voidMemFun(&ConnectionI::hold));
+ break;
+ }
+
+ case StateClosed:
+ {
+ if(_acceptor)
+ {
+ if(_threadPerConnection)
+ {
+ //
+ // If we are in thread per connection mode, we connect
+ // to our own acceptor, which unblocks our thread per
+ // incoming connection factory stuck in accept().
+ //
+ _acceptor->connectToSelf();
+ }
+ else
+ {
+ //
+ // Otherwise we first must make sure that we are
+ // registered, then we unregister, and let finished()
+ // do the close.
+ //
+ registerWithPool();
+ unregisterWithPool();
+ }
+ }
#ifdef _STLP_BEGIN_NAMESPACE
- // voidbind2nd is an STLport extension for broken compilers in IceUtil/Functional.h
- for_each(_connections.begin(), _connections.end(),
- voidbind2nd(Ice::voidMemFun1(&ConnectionI::destroy), ConnectionI::ObjectAdapterDeactivated));
+ // voidbind2nd is an STLport extension for broken compilers in IceUtil/Functional.h
+ for_each(_connections.begin(), _connections.end(),
+ voidbind2nd(Ice::voidMemFun1(&ConnectionI::destroy), ConnectionI::ObjectAdapterDeactivated));
#else
- for_each(_connections.begin(), _connections.end(),
- bind2nd(Ice::voidMemFun1(&ConnectionI::destroy), ConnectionI::ObjectAdapterDeactivated));
+ for_each(_connections.begin(), _connections.end(),
+ bind2nd(Ice::voidMemFun1(&ConnectionI::destroy), ConnectionI::ObjectAdapterDeactivated));
#endif
- break;
- }
+ break;
+ }
}
_state = state;
@@ -1033,8 +1033,8 @@ IceInternal::IncomingConnectionFactory::registerWithPool()
if(!_registeredWithPool)
{
- dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->_register(_acceptor->fd(), this);
- _registeredWithPool = true;
+ dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->_register(_acceptor->fd(), this);
+ _registeredWithPool = true;
}
}
@@ -1046,9 +1046,9 @@ IceInternal::IncomingConnectionFactory::unregisterWithPool()
if(_registeredWithPool)
{
- dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->unregister(_acceptor->fd());
- _registeredWithPool = false;
- ++_finishedCount; // For each unregistration, finished() is called once.
+ dynamic_cast<ObjectAdapterI*>(_adapter.get())->getThreadPool()->unregister(_acceptor->fd());
+ _registeredWithPool = false;
+ ++_finishedCount; // For each unregistration, finished() is called once.
}
}
@@ -1059,111 +1059,111 @@ IceInternal::IncomingConnectionFactory::run()
while(true)
{
- //
- // We must accept new connections outside the thread
- // synchronization, because we use blocking accept.
- //
- TransceiverPtr transceiver;
- try
- {
- transceiver = _acceptor->accept(-1);
- }
- catch(const SocketException&)
- {
- // Ignore socket exceptions.
- }
- catch(const TimeoutException&)
- {
- // Ignore timeouts.
- }
- catch(const LocalException& ex)
- {
- // Warn about other Ice local exceptions.
- if(_warn)
- {
- Warning out(_instance->initializationData().logger);
- out << "connection exception:\n" << ex << '\n' << _acceptor->toString();
- }
- }
-
- ConnectionIPtr connection;
-
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- while(_state == StateHolding)
- {
- wait();
- }
-
- if(_state == StateClosed)
- {
- if(transceiver)
- {
- try
- {
- transceiver->close();
- }
- catch(const LocalException&)
- {
- // Here we ignore any exceptions in close().
- }
- }
-
- try
- {
- _acceptor->close();
- }
- catch(const LocalException& ex)
- {
- _acceptor = 0;
- notifyAll();
- ex.ice_throw();
- }
-
- _acceptor = 0;
- notifyAll();
- return;
- }
-
- assert(_state == StateActive);
-
- //
- // Reap connections for which destruction has completed.
- //
- _connections.erase(remove_if(_connections.begin(), _connections.end(),
- Ice::constMemFun(&ConnectionI::isFinished)),
- _connections.end());
-
- //
- // Create a connection object for the connection.
- //
- if(transceiver)
- {
- try
- {
- connection = new ConnectionI(_instance, transceiver, _endpoint, _adapter, _threadPerConnection,
+ //
+ // We must accept new connections outside the thread
+ // synchronization, because we use blocking accept.
+ //
+ TransceiverPtr transceiver;
+ try
+ {
+ transceiver = _acceptor->accept(-1);
+ }
+ catch(const SocketException&)
+ {
+ // Ignore socket exceptions.
+ }
+ catch(const TimeoutException&)
+ {
+ // Ignore timeouts.
+ }
+ catch(const LocalException& ex)
+ {
+ // Warn about other Ice local exceptions.
+ if(_warn)
+ {
+ Warning out(_instance->initializationData().logger);
+ out << "connection exception:\n" << ex << '\n' << _acceptor->toString();
+ }
+ }
+
+ ConnectionIPtr connection;
+
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ while(_state == StateHolding)
+ {
+ wait();
+ }
+
+ if(_state == StateClosed)
+ {
+ if(transceiver)
+ {
+ try
+ {
+ transceiver->close();
+ }
+ catch(const LocalException&)
+ {
+ // Here we ignore any exceptions in close().
+ }
+ }
+
+ try
+ {
+ _acceptor->close();
+ }
+ catch(const LocalException& ex)
+ {
+ _acceptor = 0;
+ notifyAll();
+ ex.ice_throw();
+ }
+
+ _acceptor = 0;
+ notifyAll();
+ return;
+ }
+
+ assert(_state == StateActive);
+
+ //
+ // Reap connections for which destruction has completed.
+ //
+ _connections.erase(remove_if(_connections.begin(), _connections.end(),
+ Ice::constMemFun(&ConnectionI::isFinished)),
+ _connections.end());
+
+ //
+ // Create a connection object for the connection.
+ //
+ if(transceiver)
+ {
+ try
+ {
+ connection = new ConnectionI(_instance, transceiver, _endpoint, _adapter, _threadPerConnection,
_threadPerConnectionStackSize);
- }
- catch(const LocalException&)
- {
- return;
- }
-
- _connections.push_back(connection);
- }
- }
-
- //
- // In thread per connection mode, the connection's thread will
- // take care of connection validation and activation (for
- // non-datagram connections). We don't want to block this
- // thread waiting until validation is complete, because in
- // contrast to thread pool mode, it is the only thread that
- // can accept connections with this factory's
- // acceptor. Therefore we don't call validate() and activate()
- // from the connection factory in thread per connection mode.
- //
+ }
+ catch(const LocalException&)
+ {
+ return;
+ }
+
+ _connections.push_back(connection);
+ }
+ }
+
+ //
+ // In thread per connection mode, the connection's thread will
+ // take care of connection validation and activation (for
+ // non-datagram connections). We don't want to block this
+ // thread waiting until validation is complete, because in
+ // contrast to thread pool mode, it is the only thread that
+ // can accept connections with this factory's
+ // acceptor. Therefore we don't call validate() and activate()
+ // from the connection factory in thread per connection mode.
+ //
}
}
@@ -1178,22 +1178,22 @@ IceInternal::IncomingConnectionFactory::ThreadPerIncomingConnectionFactory::run(
{
try
{
- _factory->run();
+ _factory->run();
}
catch(const Exception& ex)
- {
- Error out(_factory->_instance->initializationData().logger);
- out << "exception in thread per incoming connection factory:\n" << _factory->toString() << ex;
+ {
+ Error out(_factory->_instance->initializationData().logger);
+ out << "exception in thread per incoming connection factory:\n" << _factory->toString() << ex;
}
catch(const std::exception& ex)
{
- Error out(_factory->_instance->initializationData().logger);
- out << "std::exception in thread per incoming connection factory:\n" << _factory->toString() << ex.what();
+ Error out(_factory->_instance->initializationData().logger);
+ out << "std::exception in thread per incoming connection factory:\n" << _factory->toString() << ex.what();
}
catch(...)
{
- Error out(_factory->_instance->initializationData().logger);
- out << "unknown exception in thread per incoming connection factory:\n" << _factory->toString();
+ Error out(_factory->_instance->initializationData().logger);
+ out << "unknown exception in thread per incoming connection factory:\n" << _factory->toString();
}
_factory = 0; // Resolve cyclic dependency.
diff --git a/cpp/src/Ice/ConnectionFactory.h b/cpp/src/Ice/ConnectionFactory.h
index d7e58df05f5..7758e675b8d 100644
--- a/cpp/src/Ice/ConnectionFactory.h
+++ b/cpp/src/Ice/ConnectionFactory.h
@@ -91,15 +91,15 @@ public:
private:
IncomingConnectionFactory(const InstancePtr&, const EndpointIPtr&, const Ice::ObjectAdapterPtr&,
- const std::string&);
+ const std::string&);
virtual ~IncomingConnectionFactory();
friend class Ice::ObjectAdapterI;
enum State
{
- StateActive,
- StateHolding,
- StateClosed
+ StateActive,
+ StateHolding,
+ StateClosed
};
void setState(State);
@@ -111,13 +111,13 @@ private:
class ThreadPerIncomingConnectionFactory : public IceUtil::Thread
{
public:
-
- ThreadPerIncomingConnectionFactory(const IncomingConnectionFactoryPtr&);
- virtual void run();
+
+ ThreadPerIncomingConnectionFactory(const IncomingConnectionFactoryPtr&);
+ virtual void run();
private:
-
- IncomingConnectionFactoryPtr _factory;
+
+ IncomingConnectionFactoryPtr _factory;
};
friend class ThreadPerIncomingConnectionFactory;
IceUtil::ThreadPtr _threadPerIncomingConnectionFactory;
diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp
index d832f87a886..22b4c28cf23 100644
--- a/cpp/src/Ice/ConnectionI.cpp
+++ b/cpp/src/Ice/ConnectionI.cpp
@@ -41,189 +41,189 @@ Ice::ConnectionI::validate()
if(!_endpoint->datagram()) // Datagram connections are always implicitly validated.
{
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- if(_thread && _thread->getThreadControl() != IceUtil::ThreadControl())
- {
- //
- // In thread per connection mode, this connection's thread
- // will take care of connection validation. Therefore all we
- // have to do here is to wait until this thread has completed
- // validation.
- //
- while(_state == StateNotValidated)
- {
- wait();
- }
-
- if(_state >= StateClosing)
- {
- assert(_exception.get());
- _exception->ice_throw();
- }
-
- return;
- }
-
- //
- // The connection might already be closed (e.g.: the communicator
- // was destroyed or object adapter deactivated.)
- //
- assert(_state == StateNotValidated || _state == StateClosed);
- if(_state == StateClosed)
- {
- assert(_exception.get());
- _exception->ice_throw();
- }
-
- if(_adapter)
- {
- active = true; // The server side has the active role for connection validation.
- }
- else
- {
- active = false; // The client side has the passive role for connection validation.
- }
- }
-
- try
- {
- Int timeout;
- if(_instance->defaultsAndOverrides()->overrideConnectTimeout)
- {
- timeout = _instance->defaultsAndOverrides()->overrideConnectTimeoutValue;
- }
- else
- {
- timeout = _endpoint->timeout();
- }
-
- if(active)
- {
- IceUtil::Mutex::Lock sendSync(_sendMutex);
-
- if(!_transceiver) // Has the transceiver already been closed?
- {
- assert(_exception.get());
- _exception->ice_throw(); // The exception is immutable at this point.
- }
-
- BasicStream os(_instance.get());
- os.write(magic[0]);
- os.write(magic[1]);
- os.write(magic[2]);
- os.write(magic[3]);
- os.write(protocolMajor);
- os.write(protocolMinor);
- os.write(encodingMajor);
- os.write(encodingMinor);
- os.write(validateConnectionMsg);
- os.write(static_cast<Byte>(0)); // Compression status (always zero for validate connection).
- os.write(headerSize); // Message size.
- os.i = os.b.begin();
- traceHeader("sending validate connection", os, _logger, _traceLevels);
- try
- {
- _transceiver->initialize(timeout);
- _transceiver->write(os, timeout);
- }
- catch(const TimeoutException&)
- {
- throw ConnectTimeoutException(__FILE__, __LINE__);
- }
- }
- else
- {
- BasicStream is(_instance.get());
- is.b.resize(headerSize);
- is.i = is.b.begin();
- try
- {
- _transceiver->initialize(timeout);
- _transceiver->read(is, timeout);
- }
- catch(const TimeoutException&)
- {
- throw ConnectTimeoutException(__FILE__, __LINE__);
- }
- assert(is.i == is.b.end());
- is.i = is.b.begin();
- Byte m[4];
- is.read(m[0]);
- is.read(m[1]);
- is.read(m[2]);
- is.read(m[3]);
- if(m[0] != magic[0] || m[1] != magic[1] || m[2] != magic[2] || m[3] != magic[3])
- {
- BadMagicException ex(__FILE__, __LINE__);
- ex.badMagic = Ice::ByteSeq(&m[0], &m[0] + sizeof(magic));
- throw ex;
- }
- Byte pMajor;
- Byte pMinor;
- is.read(pMajor);
- is.read(pMinor);
- if(pMajor != protocolMajor)
- {
- UnsupportedProtocolException ex(__FILE__, __LINE__);
- ex.badMajor = static_cast<unsigned char>(pMajor);
- ex.badMinor = static_cast<unsigned char>(pMinor);
- ex.major = static_cast<unsigned char>(protocolMajor);
- ex.minor = static_cast<unsigned char>(protocolMinor);
- throw ex;
- }
- Byte eMajor;
- Byte eMinor;
- is.read(eMajor);
- is.read(eMinor);
- if(eMajor != encodingMajor)
- {
- UnsupportedEncodingException ex(__FILE__, __LINE__);
- ex.badMajor = static_cast<unsigned char>(eMajor);
- ex.badMinor = static_cast<unsigned char>(eMinor);
- ex.major = static_cast<unsigned char>(encodingMajor);
- ex.minor = static_cast<unsigned char>(encodingMinor);
- throw ex;
- }
- Byte messageType;
- is.read(messageType);
- if(messageType != validateConnectionMsg)
- {
- throw ConnectionNotValidatedException(__FILE__, __LINE__);
- }
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ if(_thread && _thread->getThreadControl() != IceUtil::ThreadControl())
+ {
+ //
+ // In thread per connection mode, this connection's thread
+ // will take care of connection validation. Therefore all we
+ // have to do here is to wait until this thread has completed
+ // validation.
+ //
+ while(_state == StateNotValidated)
+ {
+ wait();
+ }
+
+ if(_state >= StateClosing)
+ {
+ assert(_exception.get());
+ _exception->ice_throw();
+ }
+
+ return;
+ }
+
+ //
+ // The connection might already be closed (e.g.: the communicator
+ // was destroyed or object adapter deactivated.)
+ //
+ assert(_state == StateNotValidated || _state == StateClosed);
+ if(_state == StateClosed)
+ {
+ assert(_exception.get());
+ _exception->ice_throw();
+ }
+
+ if(_adapter)
+ {
+ active = true; // The server side has the active role for connection validation.
+ }
+ else
+ {
+ active = false; // The client side has the passive role for connection validation.
+ }
+ }
+
+ try
+ {
+ Int timeout;
+ if(_instance->defaultsAndOverrides()->overrideConnectTimeout)
+ {
+ timeout = _instance->defaultsAndOverrides()->overrideConnectTimeoutValue;
+ }
+ else
+ {
+ timeout = _endpoint->timeout();
+ }
+
+ if(active)
+ {
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
+
+ if(!_transceiver) // Has the transceiver already been closed?
+ {
+ assert(_exception.get());
+ _exception->ice_throw(); // The exception is immutable at this point.
+ }
+
+ BasicStream os(_instance.get());
+ os.write(magic[0]);
+ os.write(magic[1]);
+ os.write(magic[2]);
+ os.write(magic[3]);
+ os.write(protocolMajor);
+ os.write(protocolMinor);
+ os.write(encodingMajor);
+ os.write(encodingMinor);
+ os.write(validateConnectionMsg);
+ os.write(static_cast<Byte>(0)); // Compression status (always zero for validate connection).
+ os.write(headerSize); // Message size.
+ os.i = os.b.begin();
+ traceHeader("sending validate connection", os, _logger, _traceLevels);
+ try
+ {
+ _transceiver->initialize(timeout);
+ _transceiver->write(os, timeout);
+ }
+ catch(const TimeoutException&)
+ {
+ throw ConnectTimeoutException(__FILE__, __LINE__);
+ }
+ }
+ else
+ {
+ BasicStream is(_instance.get());
+ is.b.resize(headerSize);
+ is.i = is.b.begin();
+ try
+ {
+ _transceiver->initialize(timeout);
+ _transceiver->read(is, timeout);
+ }
+ catch(const TimeoutException&)
+ {
+ throw ConnectTimeoutException(__FILE__, __LINE__);
+ }
+ assert(is.i == is.b.end());
+ is.i = is.b.begin();
+ Byte m[4];
+ is.read(m[0]);
+ is.read(m[1]);
+ is.read(m[2]);
+ is.read(m[3]);
+ if(m[0] != magic[0] || m[1] != magic[1] || m[2] != magic[2] || m[3] != magic[3])
+ {
+ BadMagicException ex(__FILE__, __LINE__);
+ ex.badMagic = Ice::ByteSeq(&m[0], &m[0] + sizeof(magic));
+ throw ex;
+ }
+ Byte pMajor;
+ Byte pMinor;
+ is.read(pMajor);
+ is.read(pMinor);
+ if(pMajor != protocolMajor)
+ {
+ UnsupportedProtocolException ex(__FILE__, __LINE__);
+ ex.badMajor = static_cast<unsigned char>(pMajor);
+ ex.badMinor = static_cast<unsigned char>(pMinor);
+ ex.major = static_cast<unsigned char>(protocolMajor);
+ ex.minor = static_cast<unsigned char>(protocolMinor);
+ throw ex;
+ }
+ Byte eMajor;
+ Byte eMinor;
+ is.read(eMajor);
+ is.read(eMinor);
+ if(eMajor != encodingMajor)
+ {
+ UnsupportedEncodingException ex(__FILE__, __LINE__);
+ ex.badMajor = static_cast<unsigned char>(eMajor);
+ ex.badMinor = static_cast<unsigned char>(eMinor);
+ ex.major = static_cast<unsigned char>(encodingMajor);
+ ex.minor = static_cast<unsigned char>(encodingMinor);
+ throw ex;
+ }
+ Byte messageType;
+ is.read(messageType);
+ if(messageType != validateConnectionMsg)
+ {
+ throw ConnectionNotValidatedException(__FILE__, __LINE__);
+ }
Byte compress;
is.read(compress); // Ignore compression status for validate connection.
- Int size;
- is.read(size);
- if(size != headerSize)
- {
- throw IllegalMessageSizeException(__FILE__, __LINE__);
- }
- traceHeader("received validate connection", is, _logger, _traceLevels);
- }
- }
- catch(const LocalException& ex)
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- setState(StateClosed, ex);
- assert(_exception.get());
- _exception->ice_throw();
- }
- }
-
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- if(_acmTimeout > 0)
- {
- _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
- }
-
- //
- // We start out in holding state.
- //
- setState(StateHolding);
+ Int size;
+ is.read(size);
+ if(size != headerSize)
+ {
+ throw IllegalMessageSizeException(__FILE__, __LINE__);
+ }
+ traceHeader("received validate connection", is, _logger, _traceLevels);
+ }
+ }
+ catch(const LocalException& ex)
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ setState(StateClosed, ex);
+ assert(_exception.get());
+ _exception->ice_throw();
+ }
+ }
+
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ if(_acmTimeout > 0)
+ {
+ _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
+ }
+
+ //
+ // We start out in holding state.
+ //
+ setState(StateHolding);
}
}
@@ -234,7 +234,7 @@ Ice::ConnectionI::activate()
while(_state == StateNotValidated)
{
- wait();
+ wait();
}
setState(StateActive);
@@ -247,7 +247,7 @@ Ice::ConnectionI::hold()
while(_state == StateNotValidated)
{
- wait();
+ wait();
}
setState(StateHolding);
@@ -260,17 +260,17 @@ Ice::ConnectionI::destroy(DestructionReason reason)
switch(reason)
{
- case ObjectAdapterDeactivated:
- {
- setState(StateClosing, ObjectAdapterDeactivatedException(__FILE__, __LINE__));
- break;
- }
+ case ObjectAdapterDeactivated:
+ {
+ setState(StateClosing, ObjectAdapterDeactivatedException(__FILE__, __LINE__));
+ break;
+ }
- case CommunicatorDestroyed:
- {
- setState(StateClosing, CommunicatorDestroyedException(__FILE__, __LINE__));
- break;
- }
+ case CommunicatorDestroyed:
+ {
+ setState(StateClosing, CommunicatorDestroyedException(__FILE__, __LINE__));
+ break;
+ }
}
}
@@ -281,23 +281,23 @@ Ice::ConnectionI::close(bool force)
if(force)
{
- setState(StateClosed, ForcedCloseConnectionException(__FILE__, __LINE__));
+ setState(StateClosed, ForcedCloseConnectionException(__FILE__, __LINE__));
}
else
{
- //
- // If we do a graceful shutdown, then we wait until all
- // outstanding requests have been completed. Otherwise, the
- // CloseConnectionException will cause all outstanding
- // requests to be retried, regardless of whether the server
- // has processed them or not.
- //
- while(!_requests.empty() || !_asyncRequests.empty())
- {
- wait();
- }
-
- setState(StateClosing, CloseConnectionException(__FILE__, __LINE__));
+ //
+ // If we do a graceful shutdown, then we wait until all
+ // outstanding requests have been completed. Otherwise, the
+ // CloseConnectionException will cause all outstanding
+ // requests to be retried, regardless of whether the server
+ // has processed them or not.
+ //
+ while(!_requests.empty() || !_asyncRequests.empty())
+ {
+ wait();
+ }
+
+ setState(StateClosing, CloseConnectionException(__FILE__, __LINE__));
}
}
@@ -320,37 +320,37 @@ Ice::ConnectionI::isFinished() const
IceUtil::ThreadPtr threadPerConnection;
{
- //
- // We can use trylock here, because as long as there are still
- // threads operating in this connection object, connection
- // destruction is considered as not yet finished.
- //
- IceUtil::Monitor<IceUtil::Mutex>::TryLock sync(*this);
-
- if(!sync.acquired())
- {
- return false;
- }
+ //
+ // We can use trylock here, because as long as there are still
+ // threads operating in this connection object, connection
+ // destruction is considered as not yet finished.
+ //
+ IceUtil::Monitor<IceUtil::Mutex>::TryLock sync(*this);
+
+ if(!sync.acquired())
+ {
+ return false;
+ }
- if(_transceiver || _dispatchCount != 0)
- {
- return false;
- }
+ if(_transceiver || _dispatchCount != 0)
+ {
+ return false;
+ }
- if(_thread && _thread->isAlive())
- {
- return false;
- }
+ if(_thread && _thread->isAlive())
+ {
+ return false;
+ }
- assert(_state == StateClosed);
+ assert(_state == StateClosed);
- threadPerConnection = _thread;
- _thread = 0;
+ threadPerConnection = _thread;
+ _thread = 0;
}
if(threadPerConnection)
{
- threadPerConnection->getThreadControl().join();
+ threadPerConnection->getThreadControl().join();
}
return true;
@@ -363,8 +363,8 @@ Ice::ConnectionI::throwException() const
if(_exception.get())
{
- assert(_state >= StateClosing);
- _exception->ice_throw();
+ assert(_state >= StateClosing);
+ _exception->ice_throw();
}
}
@@ -375,7 +375,7 @@ Ice::ConnectionI::waitUntilHolding() const
while(_state < StateHolding || _dispatchCount > 0)
{
- wait();
+ wait();
}
}
@@ -385,76 +385,76 @@ Ice::ConnectionI::waitUntilFinished()
IceUtil::ThreadPtr threadPerConnection;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- //
- // We wait indefinitely until connection closing has been
- // initiated. We also wait indefinitely until all outstanding
- // requests are completed. Otherwise we couldn't guarantee
- // that there are no outstanding calls when deactivate() is
- // called on the servant locators.
- //
- while(_state < StateClosing || _dispatchCount > 0)
- {
- wait();
- }
-
- //
- // Now we must wait until close() has been called on the
- // transceiver.
- //
- while(_transceiver)
- {
- if(_state != StateClosed && _endpoint->timeout() >= 0)
- {
- IceUtil::Time timeout = IceUtil::Time::milliSeconds(_endpoint->timeout());
- IceUtil::Time waitTime = _stateTime + timeout - IceUtil::Time::now();
-
- if(waitTime > IceUtil::Time())
- {
- //
- // We must wait a bit longer until we close this
- // connection.
- //
- if(!timedWait(waitTime))
- {
- setState(StateClosed, CloseTimeoutException(__FILE__, __LINE__));
- }
- }
- else
- {
- //
- // We already waited long enough, so let's close this
- // connection!
- //
- setState(StateClosed, CloseTimeoutException(__FILE__, __LINE__));
- }
-
- //
- // No return here, we must still wait until close() is
- // called on the _transceiver.
- //
- }
- else
- {
- wait();
- }
- }
-
- assert(_state == StateClosed);
-
- threadPerConnection = _thread;
- _thread = 0;
-
- //
- // Clear the OA. See bug 1673 for the details of why this is necessary.
- //
- _adapter = 0;
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ //
+ // We wait indefinitely until connection closing has been
+ // initiated. We also wait indefinitely until all outstanding
+ // requests are completed. Otherwise we couldn't guarantee
+ // that there are no outstanding calls when deactivate() is
+ // called on the servant locators.
+ //
+ while(_state < StateClosing || _dispatchCount > 0)
+ {
+ wait();
+ }
+
+ //
+ // Now we must wait until close() has been called on the
+ // transceiver.
+ //
+ while(_transceiver)
+ {
+ if(_state != StateClosed && _endpoint->timeout() >= 0)
+ {
+ IceUtil::Time timeout = IceUtil::Time::milliSeconds(_endpoint->timeout());
+ IceUtil::Time waitTime = _stateTime + timeout - IceUtil::Time::now();
+
+ if(waitTime > IceUtil::Time())
+ {
+ //
+ // We must wait a bit longer until we close this
+ // connection.
+ //
+ if(!timedWait(waitTime))
+ {
+ setState(StateClosed, CloseTimeoutException(__FILE__, __LINE__));
+ }
+ }
+ else
+ {
+ //
+ // We already waited long enough, so let's close this
+ // connection!
+ //
+ setState(StateClosed, CloseTimeoutException(__FILE__, __LINE__));
+ }
+
+ //
+ // No return here, we must still wait until close() is
+ // called on the _transceiver.
+ //
+ }
+ else
+ {
+ wait();
+ }
+ }
+
+ assert(_state == StateClosed);
+
+ threadPerConnection = _thread;
+ _thread = 0;
+
+ //
+ // Clear the OA. See bug 1673 for the details of why this is necessary.
+ //
+ _adapter = 0;
}
if(threadPerConnection)
{
- threadPerConnection->getThreadControl().join();
+ threadPerConnection->getThreadControl().join();
}
}
@@ -465,12 +465,12 @@ Ice::ConnectionI::monitor()
if(!sync.acquired())
{
- return;
+ return;
}
if(_state != StateActive)
{
- return;
+ return;
}
//
@@ -478,11 +478,11 @@ Ice::ConnectionI::monitor()
//
for(map<Int, AsyncRequest>::iterator p = _asyncRequests.begin(); p != _asyncRequests.end(); ++p)
{
- if(p->second.t > IceUtil::Time() && p->second.t <= IceUtil::Time::now())
- {
- setState(StateClosed, TimeoutException(__FILE__, __LINE__));
- return;
- }
+ if(p->second.t > IceUtil::Time() && p->second.t <= IceUtil::Time::now())
+ {
+ setState(StateClosed, TimeoutException(__FILE__, __LINE__));
+ return;
+ }
}
//
@@ -493,11 +493,11 @@ Ice::ConnectionI::monitor()
!_batchStreamInUse && _batchStream.b.empty() &&
_dispatchCount == 0)
{
- if(IceUtil::Time::now() >= _acmAbsoluteTimeout)
- {
- setState(StateClosing, ConnectionTimeoutException(__FILE__, __LINE__));
- return;
- }
+ if(IceUtil::Time::now() >= _acmAbsoluteTimeout)
+ {
+ setState(StateClosing, ConnectionTimeoutException(__FILE__, __LINE__));
+ return;
+ }
}
}
@@ -507,162 +507,162 @@ Ice::ConnectionI::sendRequest(BasicStream* os, Outgoing* out, bool compress)
Int requestId;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- assert(!(out && _endpoint->datagram())); // Twoway requests cannot be datagrams.
-
- if(_exception.get())
- {
- //
- // If the connection is closed before we even have a chance
- // to send our request, we always try to send the request
- // again.
- //
- throw LocalExceptionWrapper(*_exception.get(), true);
- }
-
- assert(_state > StateNotValidated);
- assert(_state < StateClosing);
-
- //
- // Only add to the request map if this is a twoway call.
- //
- if(out)
- {
- //
- // Create a new unique request ID.
- //
- requestId = _nextRequestId++;
- if(requestId <= 0)
- {
- _nextRequestId = 1;
- requestId = _nextRequestId++;
- }
-
- //
- // Fill in the request ID.
- //
- const Byte* p = reinterpret_cast<const Byte*>(&requestId);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ assert(!(out && _endpoint->datagram())); // Twoway requests cannot be datagrams.
+
+ if(_exception.get())
+ {
+ //
+ // If the connection is closed before we even have a chance
+ // to send our request, we always try to send the request
+ // again.
+ //
+ throw LocalExceptionWrapper(*_exception.get(), true);
+ }
+
+ assert(_state > StateNotValidated);
+ assert(_state < StateClosing);
+
+ //
+ // Only add to the request map if this is a twoway call.
+ //
+ if(out)
+ {
+ //
+ // Create a new unique request ID.
+ //
+ requestId = _nextRequestId++;
+ if(requestId <= 0)
+ {
+ _nextRequestId = 1;
+ requestId = _nextRequestId++;
+ }
+
+ //
+ // Fill in the request ID.
+ //
+ const Byte* p = reinterpret_cast<const Byte*>(&requestId);
#ifdef ICE_BIG_ENDIAN
- reverse_copy(p, p + sizeof(Int), os->b.begin() + headerSize);
+ reverse_copy(p, p + sizeof(Int), os->b.begin() + headerSize);
#else
- copy(p, p + sizeof(Int), os->b.begin() + headerSize);
+ copy(p, p + sizeof(Int), os->b.begin() + headerSize);
#endif
- //
- // Add to the requests map.
- //
- _requestsHint = _requests.insert(_requests.end(), pair<const Int, Outgoing*>(requestId, out));
- }
-
- if(_acmTimeout > 0)
- {
- _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
- }
+ //
+ // Add to the requests map.
+ //
+ _requestsHint = _requests.insert(_requests.end(), pair<const Int, Outgoing*>(requestId, out));
+ }
+
+ if(_acmTimeout > 0)
+ {
+ _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
+ }
}
try
{
- IceUtil::Mutex::Lock sendSync(_sendMutex);
-
- if(!_transceiver) // Has the transceiver already been closed?
- {
- assert(_exception.get());
- _exception->ice_throw(); // The exception is immutable at this point.
- }
-
- if(compress && os->b.size() >= 100) // Only compress messages larger than 100 bytes.
- {
- //
- // Message compressed. Request compressed response, if any.
- //
- os->b[9] = 2;
-
- //
- // Do compression.
- //
- BasicStream cstream(_instance.get());
- doCompress(*os, cstream);
-
- //
- // Send the request.
- //
- os->i = os->b.begin();
- traceRequest("sending request", *os, _logger, _traceLevels);
- cstream.i = cstream.b.begin();
- _transceiver->write(cstream, _endpoint->timeout());
- }
- else
- {
- if(compress)
- {
- //
- // Message not compressed. Request compressed response, if any.
- //
- os->b[9] = 1;
- }
-
- //
- // No compression, just fill in the message size.
- //
- Int sz = static_cast<Int>(os->b.size());
- const Byte* p = reinterpret_cast<const Byte*>(&sz);
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
+
+ if(!_transceiver) // Has the transceiver already been closed?
+ {
+ assert(_exception.get());
+ _exception->ice_throw(); // The exception is immutable at this point.
+ }
+
+ if(compress && os->b.size() >= 100) // Only compress messages larger than 100 bytes.
+ {
+ //
+ // Message compressed. Request compressed response, if any.
+ //
+ os->b[9] = 2;
+
+ //
+ // Do compression.
+ //
+ BasicStream cstream(_instance.get());
+ doCompress(*os, cstream);
+
+ //
+ // Send the request.
+ //
+ os->i = os->b.begin();
+ traceRequest("sending request", *os, _logger, _traceLevels);
+ cstream.i = cstream.b.begin();
+ _transceiver->write(cstream, _endpoint->timeout());
+ }
+ else
+ {
+ if(compress)
+ {
+ //
+ // Message not compressed. Request compressed response, if any.
+ //
+ os->b[9] = 1;
+ }
+
+ //
+ // No compression, just fill in the message size.
+ //
+ Int sz = static_cast<Int>(os->b.size());
+ const Byte* p = reinterpret_cast<const Byte*>(&sz);
#ifdef ICE_BIG_ENDIAN
- reverse_copy(p, p + sizeof(Int), os->b.begin() + 10);
+ reverse_copy(p, p + sizeof(Int), os->b.begin() + 10);
#else
- copy(p, p + sizeof(Int), os->b.begin() + 10);
+ copy(p, p + sizeof(Int), os->b.begin() + 10);
#endif
-
- //
- // Send the request.
- //
- os->i = os->b.begin();
- traceRequest("sending request", *os, _logger, _traceLevels);
- _transceiver->write(*os, _endpoint->timeout());
- }
+
+ //
+ // Send the request.
+ //
+ os->i = os->b.begin();
+ traceRequest("sending request", *os, _logger, _traceLevels);
+ _transceiver->write(*os, _endpoint->timeout());
+ }
}
catch(const LocalException& ex)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- setState(StateClosed, ex);
- assert(_exception.get());
-
- if(out)
- {
- //
- // If the request has already been removed from the
- // request map, we are out of luck. It would mean that
- // finished() has been called already, and therefore the
- // exception has been set using the Outgoing::finished()
- // callback. In this case, we cannot throw the exception
- // here, because we must not both raise an exception and
- // have Outgoing::finished() called with an
- // exception. This means that in some rare cases, a
- // request will not be retried even though it could. But I
- // honestly don't know how I could avoid this, without a
- // very elaborate and complex design, which would be bad
- // for performance.
- //
- map<Int, Outgoing*>::iterator p = _requests.find(requestId);
- if(p != _requests.end())
- {
- if(p == _requestsHint)
- {
- _requests.erase(p++);
- _requestsHint = p;
- }
- else
- {
- _requests.erase(p);
- }
-
- _exception->ice_throw();
- }
- }
- else
- {
- _exception->ice_throw();
- }
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ setState(StateClosed, ex);
+ assert(_exception.get());
+
+ if(out)
+ {
+ //
+ // If the request has already been removed from the
+ // request map, we are out of luck. It would mean that
+ // finished() has been called already, and therefore the
+ // exception has been set using the Outgoing::finished()
+ // callback. In this case, we cannot throw the exception
+ // here, because we must not both raise an exception and
+ // have Outgoing::finished() called with an
+ // exception. This means that in some rare cases, a
+ // request will not be retried even though it could. But I
+ // honestly don't know how I could avoid this, without a
+ // very elaborate and complex design, which would be bad
+ // for performance.
+ //
+ map<Int, Outgoing*>::iterator p = _requests.find(requestId);
+ if(p != _requests.end())
+ {
+ if(p == _requestsHint)
+ {
+ _requests.erase(p++);
+ _requestsHint = p;
+ }
+ else
+ {
+ _requests.erase(p);
+ }
+
+ _exception->ice_throw();
+ }
+ }
+ else
+ {
+ _exception->ice_throw();
+ }
}
}
@@ -672,156 +672,156 @@ Ice::ConnectionI::sendAsyncRequest(BasicStream* os, const OutgoingAsyncPtr& out,
Int requestId;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- assert(!_endpoint->datagram()); // Twoway requests cannot be datagrams, and async implies twoway.
-
- if(_exception.get())
- {
- //
- // If the exception is closed before we even have a chance
- // to send our request, we always try to send the request
- // again.
- //
- throw LocalExceptionWrapper(*_exception.get(), true);
- }
-
- assert(_state > StateNotValidated);
- assert(_state < StateClosing);
-
- //
- // Create a new unique request ID.
- //
- requestId = _nextRequestId++;
- if(requestId <= 0)
- {
- _nextRequestId = 1;
- requestId = _nextRequestId++;
- }
-
- //
- // Fill in the request ID.
- //
- const Byte* p = reinterpret_cast<const Byte*>(&requestId);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ assert(!_endpoint->datagram()); // Twoway requests cannot be datagrams, and async implies twoway.
+
+ if(_exception.get())
+ {
+ //
+ // If the exception is closed before we even have a chance
+ // to send our request, we always try to send the request
+ // again.
+ //
+ throw LocalExceptionWrapper(*_exception.get(), true);
+ }
+
+ assert(_state > StateNotValidated);
+ assert(_state < StateClosing);
+
+ //
+ // Create a new unique request ID.
+ //
+ requestId = _nextRequestId++;
+ if(requestId <= 0)
+ {
+ _nextRequestId = 1;
+ requestId = _nextRequestId++;
+ }
+
+ //
+ // Fill in the request ID.
+ //
+ const Byte* p = reinterpret_cast<const Byte*>(&requestId);
#ifdef ICE_BIG_ENDIAN
- reverse_copy(p, p + sizeof(Int), os->b.begin() + headerSize);
+ reverse_copy(p, p + sizeof(Int), os->b.begin() + headerSize);
#else
- copy(p, p + sizeof(Int), os->b.begin() + headerSize);
+ copy(p, p + sizeof(Int), os->b.begin() + headerSize);
#endif
-
- //
- // Add to the async requests map.
- //
- struct AsyncRequest asyncRequest;
- asyncRequest.p = out;
- if(_endpoint->timeout() > 0)
- {
- asyncRequest.t = IceUtil::Time::now() + IceUtil::Time::milliSeconds(_endpoint->timeout());
- }
- _asyncRequestsHint = _asyncRequests.insert(_asyncRequests.end(),
- pair<const Int, AsyncRequest>(requestId, asyncRequest));
-
- if(_acmTimeout > 0)
- {
- _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
- }
+
+ //
+ // Add to the async requests map.
+ //
+ struct AsyncRequest asyncRequest;
+ asyncRequest.p = out;
+ if(_endpoint->timeout() > 0)
+ {
+ asyncRequest.t = IceUtil::Time::now() + IceUtil::Time::milliSeconds(_endpoint->timeout());
+ }
+ _asyncRequestsHint = _asyncRequests.insert(_asyncRequests.end(),
+ pair<const Int, AsyncRequest>(requestId, asyncRequest));
+
+ if(_acmTimeout > 0)
+ {
+ _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
+ }
}
try
{
- IceUtil::Mutex::Lock sendSync(_sendMutex);
-
- if(!_transceiver) // Has the transceiver already been closed?
- {
- assert(_exception.get());
- _exception->ice_throw(); // The exception is immutable at this point.
- }
-
- if(compress && os->b.size() >= 100) // Only compress messages larger than 100 bytes.
- {
- //
- // Message compressed. Request compressed response, if any.
- //
- os->b[9] = 2;
-
- //
- // Do compression.
- //
- BasicStream cstream(_instance.get());
- doCompress(*os, cstream);
-
- //
- // Send the request.
- //
- os->i = os->b.begin();
- traceRequest("sending asynchronous request", *os, _logger, _traceLevels);
- cstream.i = cstream.b.begin();
- _transceiver->write(cstream, _endpoint->timeout());
- }
- else
- {
- if(compress)
- {
- //
- // Message not compressed. Request compressed response, if any.
- //
- os->b[9] = 1;
- }
-
- //
- // No compression, just fill in the message size.
- //
- Int sz = static_cast<Int>(os->b.size());
- const Byte* p = reinterpret_cast<const Byte*>(&sz);
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
+
+ if(!_transceiver) // Has the transceiver already been closed?
+ {
+ assert(_exception.get());
+ _exception->ice_throw(); // The exception is immutable at this point.
+ }
+
+ if(compress && os->b.size() >= 100) // Only compress messages larger than 100 bytes.
+ {
+ //
+ // Message compressed. Request compressed response, if any.
+ //
+ os->b[9] = 2;
+
+ //
+ // Do compression.
+ //
+ BasicStream cstream(_instance.get());
+ doCompress(*os, cstream);
+
+ //
+ // Send the request.
+ //
+ os->i = os->b.begin();
+ traceRequest("sending asynchronous request", *os, _logger, _traceLevels);
+ cstream.i = cstream.b.begin();
+ _transceiver->write(cstream, _endpoint->timeout());
+ }
+ else
+ {
+ if(compress)
+ {
+ //
+ // Message not compressed. Request compressed response, if any.
+ //
+ os->b[9] = 1;
+ }
+
+ //
+ // No compression, just fill in the message size.
+ //
+ Int sz = static_cast<Int>(os->b.size());
+ const Byte* p = reinterpret_cast<const Byte*>(&sz);
#ifdef ICE_BIG_ENDIAN
- reverse_copy(p, p + sizeof(Int), os->b.begin() + 10);
+ reverse_copy(p, p + sizeof(Int), os->b.begin() + 10);
#else
- copy(p, p + sizeof(Int), os->b.begin() + 10);
+ copy(p, p + sizeof(Int), os->b.begin() + 10);
#endif
- //
- // Send the request.
- //
- os->i = os->b.begin();
- traceRequest("sending asynchronous request", *os, _logger, _traceLevels);
- _transceiver->write(*os, _endpoint->timeout());
- }
+ //
+ // Send the request.
+ //
+ os->i = os->b.begin();
+ traceRequest("sending asynchronous request", *os, _logger, _traceLevels);
+ _transceiver->write(*os, _endpoint->timeout());
+ }
}
catch(const LocalException& ex)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- setState(StateClosed, ex);
- assert(_exception.get());
-
- //
- // If the request has already been removed from the async
- // request map, we are out of luck. It would mean that
- // finished() has been called already, and therefore the
- // exception has been set using the
- // OutgoingAsync::__finished() callback. In this case, we
- // cannot throw the exception here, because we must not both
- // raise an exception and have OutgoingAsync::__finished()
- // called with an exception. This means that in some rare
- // cases, a request will not be retried even though it
- // could. But I honestly don't know how I could avoid this,
- // without a very elaborate and complex design, which would be
- // bad for performance.
- //
- map<Int, AsyncRequest>::iterator p = _asyncRequests.find(requestId);
- if(p != _asyncRequests.end())
- {
- if(p == _asyncRequestsHint)
- {
- _asyncRequests.erase(p++);
- _asyncRequestsHint = p;
- }
- else
- {
- _asyncRequests.erase(p);
- }
-
- _exception->ice_throw();
- }
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ setState(StateClosed, ex);
+ assert(_exception.get());
+
+ //
+ // If the request has already been removed from the async
+ // request map, we are out of luck. It would mean that
+ // finished() has been called already, and therefore the
+ // exception has been set using the
+ // OutgoingAsync::__finished() callback. In this case, we
+ // cannot throw the exception here, because we must not both
+ // raise an exception and have OutgoingAsync::__finished()
+ // called with an exception. This means that in some rare
+ // cases, a request will not be retried even though it
+ // could. But I honestly don't know how I could avoid this,
+ // without a very elaborate and complex design, which would be
+ // bad for performance.
+ //
+ map<Int, AsyncRequest>::iterator p = _asyncRequests.find(requestId);
+ if(p != _asyncRequests.end())
+ {
+ if(p == _asyncRequestsHint)
+ {
+ _asyncRequests.erase(p++);
+ _asyncRequestsHint = p;
+ }
+ else
+ {
+ _asyncRequests.erase(p);
+ }
+
+ _exception->ice_throw();
+ }
}
}
@@ -835,12 +835,12 @@ Ice::ConnectionI::prepareBatchRequest(BasicStream* os)
//
while(_batchStreamInUse && !_exception.get())
{
- wait();
+ wait();
}
if(_exception.get())
{
- _exception->ice_throw();
+ _exception->ice_throw();
}
assert(_state > StateNotValidated);
@@ -848,15 +848,15 @@ Ice::ConnectionI::prepareBatchRequest(BasicStream* os)
if(_batchStream.b.empty())
{
- try
- {
- _batchStream.writeBlob(requestBatchHdr, sizeof(requestBatchHdr));
- }
- catch(const LocalException& ex)
- {
- setState(StateClosed, ex);
- ex.ice_throw();
- }
+ try
+ {
+ _batchStream.writeBlob(requestBatchHdr, sizeof(requestBatchHdr));
+ }
+ catch(const LocalException& ex)
+ {
+ setState(StateClosed, ex);
+ ex.ice_throw();
+ }
}
_batchStreamInUse = true;
@@ -884,41 +884,41 @@ Ice::ConnectionI::finishBatchRequest(BasicStream* os, bool compress)
_batchStream.swap(*os);
if(_batchAutoFlush)
- {
- IceUtil::Mutex::Lock sendSync(_sendMutex);
- if(!_transceiver)
- {
- assert(_exception.get());
- _exception->ice_throw(); // The exception is immutable at this point.
- }
-
- //
- // Throw memory limit exception if the first message added causes us to
- // go over limit. Otherwise put aside the marshalled message that caused
- // limit to be exceeded and rollback stream to the marker.
- //
- try
- {
- _transceiver->checkSendSize(_batchStream, _instance->messageSizeMax());
- }
- catch(const Ice::Exception&)
- {
- if(_batchRequestNum == 0)
- {
- resetBatch(true);
- throw;
- }
- vector<Ice::Byte>(_batchStream.b.begin() + _batchMarker, _batchStream.b.end()).swap(lastRequest);
- _batchStream.b.resize(_batchMarker);
- autoflush = true;
- }
- }
-
- if(!autoflush)
- {
- //
- // Increment the number of requests in the batch.
- //
+ {
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
+ if(!_transceiver)
+ {
+ assert(_exception.get());
+ _exception->ice_throw(); // The exception is immutable at this point.
+ }
+
+ //
+ // Throw memory limit exception if the first message added causes us to
+ // go over limit. Otherwise put aside the marshalled message that caused
+ // limit to be exceeded and rollback stream to the marker.
+ //
+ try
+ {
+ _transceiver->checkSendSize(_batchStream, _instance->messageSizeMax());
+ }
+ catch(const Ice::Exception&)
+ {
+ if(_batchRequestNum == 0)
+ {
+ resetBatch(true);
+ throw;
+ }
+ vector<Ice::Byte>(_batchStream.b.begin() + _batchMarker, _batchStream.b.end()).swap(lastRequest);
+ _batchStream.b.resize(_batchMarker);
+ autoflush = true;
+ }
+ }
+
+ if(!autoflush)
+ {
+ //
+ // Increment the number of requests in the batch.
+ //
++_batchRequestNum;
//
@@ -927,7 +927,7 @@ Ice::ConnectionI::finishBatchRequest(BasicStream* os, bool compress)
//
if(compress)
{
- _batchRequestCompress = true;
+ _batchRequestCompress = true;
}
//
@@ -942,41 +942,41 @@ Ice::ConnectionI::finishBatchRequest(BasicStream* os, bool compress)
if(autoflush)
{
//
- // We have to keep _batchStreamInUse set until after we insert the
- // saved marshalled data into a new stream.
- //
+ // We have to keep _batchStreamInUse set until after we insert the
+ // saved marshalled data into a new stream.
+ //
flushBatchRequestsInternal(true);
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- //
- // Throw memory limit exception if the message that caused us to go over
- // limit causes us to exceed the limit by itself.
- //
+ //
+ // Throw memory limit exception if the message that caused us to go over
+ // limit causes us to exceed the limit by itself.
+ //
if(sizeof(requestBatchHdr) + lastRequest.size() > _instance->messageSizeMax())
- {
- resetBatch(true);
- throw MemoryLimitException(__FILE__, __LINE__);
- }
-
- //
- // Start a new batch with the last message that caused us to
- // go over the limit.
- //
- try
- {
- _batchStream.writeBlob(requestBatchHdr, sizeof(requestBatchHdr));
- _batchStream.writeBlob(&lastRequest[0], lastRequest.size());
- }
- catch(const LocalException& ex)
- {
- setState(StateClosed, ex);
- ex.ice_throw();
- }
+ {
+ resetBatch(true);
+ throw MemoryLimitException(__FILE__, __LINE__);
+ }
+
+ //
+ // Start a new batch with the last message that caused us to
+ // go over the limit.
+ //
+ try
+ {
+ _batchStream.writeBlob(requestBatchHdr, sizeof(requestBatchHdr));
+ _batchStream.writeBlob(&lastRequest[0], lastRequest.size());
+ }
+ catch(const LocalException& ex)
+ {
+ setState(StateClosed, ex);
+ ex.ice_throw();
+ }
if(compress)
{
- _batchRequestCompress = true;
+ _batchRequestCompress = true;
}
//
@@ -984,7 +984,7 @@ Ice::ConnectionI::finishBatchRequest(BasicStream* os, bool compress)
//
++_batchRequestNum;
_batchStreamInUse = false;
- notifyAll();
+ notifyAll();
}
}
@@ -1011,133 +1011,133 @@ void
Ice::ConnectionI::flushBatchRequestsInternal(bool ignoreInUse)
{
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- if(!ignoreInUse)
- {
- while(_batchStreamInUse && !_exception.get())
- {
- wait();
- }
- }
-
- if(_exception.get())
- {
- _exception->ice_throw();
- }
-
- if(_batchStream.b.empty())
- {
- return; // Nothing to do.
- }
-
- assert(_state > StateNotValidated);
- assert(_state < StateClosing);
-
- _batchStream.i = _batchStream.b.begin();
-
- if(_acmTimeout > 0)
- {
- _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
- }
-
- //
- // Prevent that new batch requests are added while we are
- // flushing.
- //
- _batchStreamInUse = true;
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ if(!ignoreInUse)
+ {
+ while(_batchStreamInUse && !_exception.get())
+ {
+ wait();
+ }
+ }
+
+ if(_exception.get())
+ {
+ _exception->ice_throw();
+ }
+
+ if(_batchStream.b.empty())
+ {
+ return; // Nothing to do.
+ }
+
+ assert(_state > StateNotValidated);
+ assert(_state < StateClosing);
+
+ _batchStream.i = _batchStream.b.begin();
+
+ if(_acmTimeout > 0)
+ {
+ _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
+ }
+
+ //
+ // Prevent that new batch requests are added while we are
+ // flushing.
+ //
+ _batchStreamInUse = true;
}
try
{
- IceUtil::Mutex::Lock sendSync(_sendMutex);
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
- if(!_transceiver) // Has the transceiver already been closed?
- {
- assert(_exception.get());
- _exception->ice_throw(); // The exception is immutable at this point.
- }
+ if(!_transceiver) // Has the transceiver already been closed?
+ {
+ assert(_exception.get());
+ _exception->ice_throw(); // The exception is immutable at this point.
+ }
- //
- // Fill in the number of requests in the batch.
- //
- const Byte* p = reinterpret_cast<const Byte*>(&_batchRequestNum);
+ //
+ // Fill in the number of requests in the batch.
+ //
+ const Byte* p = reinterpret_cast<const Byte*>(&_batchRequestNum);
#ifdef ICE_BIG_ENDIAN
- reverse_copy(p, p + sizeof(Int), _batchStream.b.begin() + headerSize);
+ reverse_copy(p, p + sizeof(Int), _batchStream.b.begin() + headerSize);
#else
- copy(p, p + sizeof(Int), _batchStream.b.begin() + headerSize);
+ copy(p, p + sizeof(Int), _batchStream.b.begin() + headerSize);
#endif
-
- if(_batchRequestCompress && _batchStream.b.size() >= 100) // Only compress messages larger than 100 bytes.
- {
- //
- // Message compressed. Request compressed response, if any.
- //
- _batchStream.b[9] = 2;
-
- //
- // Do compression.
- //
- BasicStream cstream(_instance.get());
- doCompress(_batchStream, cstream);
-
- //
- // Send the batch request.
- //
- _batchStream.i = _batchStream.b.begin();
- traceBatchRequest("sending batch request", _batchStream, _logger, _traceLevels);
- cstream.i = cstream.b.begin();
- _transceiver->write(cstream, _endpoint->timeout());
- }
- else
- {
- if(_batchRequestCompress)
- {
- //
- // Message not compressed. Request compressed response, if any.
- //
- _batchStream.b[9] = 1;
- }
-
- //
- // No compression, just fill in the message size.
- //
- Int sz = static_cast<Int>(_batchStream.b.size());
- const Byte* q = reinterpret_cast<const Byte*>(&sz);
+
+ if(_batchRequestCompress && _batchStream.b.size() >= 100) // Only compress messages larger than 100 bytes.
+ {
+ //
+ // Message compressed. Request compressed response, if any.
+ //
+ _batchStream.b[9] = 2;
+
+ //
+ // Do compression.
+ //
+ BasicStream cstream(_instance.get());
+ doCompress(_batchStream, cstream);
+
+ //
+ // Send the batch request.
+ //
+ _batchStream.i = _batchStream.b.begin();
+ traceBatchRequest("sending batch request", _batchStream, _logger, _traceLevels);
+ cstream.i = cstream.b.begin();
+ _transceiver->write(cstream, _endpoint->timeout());
+ }
+ else
+ {
+ if(_batchRequestCompress)
+ {
+ //
+ // Message not compressed. Request compressed response, if any.
+ //
+ _batchStream.b[9] = 1;
+ }
+
+ //
+ // No compression, just fill in the message size.
+ //
+ Int sz = static_cast<Int>(_batchStream.b.size());
+ const Byte* q = reinterpret_cast<const Byte*>(&sz);
#ifdef ICE_BIG_ENDIAN
- reverse_copy(q, q + sizeof(Int), _batchStream.b.begin() + 10);
+ reverse_copy(q, q + sizeof(Int), _batchStream.b.begin() + 10);
#else
- copy(q, q + sizeof(Int), _batchStream.b.begin() + 10);
+ copy(q, q + sizeof(Int), _batchStream.b.begin() + 10);
#endif
-
- //
- // Send the batch request.
- //
- _batchStream.i = _batchStream.b.begin();
- traceBatchRequest("sending batch request", _batchStream, _logger, _traceLevels);
- _transceiver->write(_batchStream, _endpoint->timeout());
- }
+
+ //
+ // Send the batch request.
+ //
+ _batchStream.i = _batchStream.b.begin();
+ traceBatchRequest("sending batch request", _batchStream, _logger, _traceLevels);
+ _transceiver->write(_batchStream, _endpoint->timeout());
+ }
}
catch(const LocalException& ex)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- setState(StateClosed, ex);
- assert(_exception.get());
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ setState(StateClosed, ex);
+ assert(_exception.get());
- //
- // Since batch requests are all oneways (or datagrams), we
- // must report the exception to the caller.
- //
- _exception->ice_throw();
+ //
+ // Since batch requests are all oneways (or datagrams), we
+ // must report the exception to the caller.
+ //
+ _exception->ice_throw();
}
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- //
- // Reset the batch stream, and notify that flushing is over.
- //
- resetBatch(!ignoreInUse);
+ //
+ // Reset the batch stream, and notify that flushing is over.
+ //
+ resetBatch(!ignoreInUse);
}
}
@@ -1167,100 +1167,100 @@ Ice::ConnectionI::sendResponse(BasicStream* os, Byte compressFlag)
{
try
{
- IceUtil::Mutex::Lock sendSync(_sendMutex);
-
- if(!_transceiver) // Has the transceiver already been closed?
- {
- assert(_exception.get());
- _exception->ice_throw(); // The exception is immutable at this point.
- }
-
- //
- // Only compress if compression was requested by the client,
- // and if the message is larger than 100 bytes.
- //
- if(compressFlag > 0 && os->b.size() >= 100)
- {
- //
- // Message compressed. Request compressed response, if any.
- //
- os->b[9] = 2;
-
- //
- // Do compression.
- //
- BasicStream cstream(_instance.get());
- doCompress(*os, cstream);
-
- //
- // Send the reply.
- //
- os->i = os->b.begin();
- traceReply("sending reply", *os, _logger, _traceLevels);
- cstream.i = cstream.b.begin();
- _transceiver->write(cstream, _endpoint->timeout());
- }
- else
- {
- if(compressFlag > 0)
- {
- //
- // Message not compressed. Request compressed response, if any.
- //
- os->b[9] = 1;
- }
-
- //
- // No compression, just fill in the message size.
- //
- Int sz = static_cast<Int>(os->b.size());
- const Byte* p = reinterpret_cast<const Byte*>(&sz);
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
+
+ if(!_transceiver) // Has the transceiver already been closed?
+ {
+ assert(_exception.get());
+ _exception->ice_throw(); // The exception is immutable at this point.
+ }
+
+ //
+ // Only compress if compression was requested by the client,
+ // and if the message is larger than 100 bytes.
+ //
+ if(compressFlag > 0 && os->b.size() >= 100)
+ {
+ //
+ // Message compressed. Request compressed response, if any.
+ //
+ os->b[9] = 2;
+
+ //
+ // Do compression.
+ //
+ BasicStream cstream(_instance.get());
+ doCompress(*os, cstream);
+
+ //
+ // Send the reply.
+ //
+ os->i = os->b.begin();
+ traceReply("sending reply", *os, _logger, _traceLevels);
+ cstream.i = cstream.b.begin();
+ _transceiver->write(cstream, _endpoint->timeout());
+ }
+ else
+ {
+ if(compressFlag > 0)
+ {
+ //
+ // Message not compressed. Request compressed response, if any.
+ //
+ os->b[9] = 1;
+ }
+
+ //
+ // No compression, just fill in the message size.
+ //
+ Int sz = static_cast<Int>(os->b.size());
+ const Byte* p = reinterpret_cast<const Byte*>(&sz);
#ifdef ICE_BIG_ENDIAN
- reverse_copy(p, p + sizeof(Int), os->b.begin() + 10);
+ reverse_copy(p, p + sizeof(Int), os->b.begin() + 10);
#else
- copy(p, p + sizeof(Int), os->b.begin() + 10);
+ copy(p, p + sizeof(Int), os->b.begin() + 10);
#endif
-
- //
- // Send the reply.
- //
- os->i = os->b.begin();
- traceReply("sending reply", *os, _logger, _traceLevels);
- _transceiver->write(*os, _endpoint->timeout());
- }
+
+ //
+ // Send the reply.
+ //
+ os->i = os->b.begin();
+ traceReply("sending reply", *os, _logger, _traceLevels);
+ _transceiver->write(*os, _endpoint->timeout());
+ }
}
catch(const LocalException& ex)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- setState(StateClosed, ex);
- }
-
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- assert(_state > StateNotValidated);
-
- try
- {
- if(--_dispatchCount == 0)
- {
- notifyAll();
- }
-
- if(_state == StateClosing && _dispatchCount == 0)
- {
- initiateShutdown();
- }
-
- if(_acmTimeout > 0)
- {
- _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
- }
- }
- catch(const LocalException& ex)
- {
- setState(StateClosed, ex);
- }
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ setState(StateClosed, ex);
+ }
+
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ assert(_state > StateNotValidated);
+
+ try
+ {
+ if(--_dispatchCount == 0)
+ {
+ notifyAll();
+ }
+
+ if(_state == StateClosing && _dispatchCount == 0)
+ {
+ initiateShutdown();
+ }
+
+ if(_acmTimeout > 0)
+ {
+ _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
+ }
+ }
+ catch(const LocalException& ex)
+ {
+ setState(StateClosed, ex);
+ }
}
}
@@ -1273,19 +1273,19 @@ Ice::ConnectionI::sendNoResponse()
try
{
- if(--_dispatchCount == 0)
- {
- notifyAll();
- }
+ if(--_dispatchCount == 0)
+ {
+ notifyAll();
+ }
- if(_state == StateClosing && _dispatchCount == 0)
- {
- initiateShutdown();
- }
+ if(_state == StateClosing && _dispatchCount == 0)
+ {
+ initiateShutdown();
+ }
}
catch(const LocalException& ex)
{
- setState(StateClosed, ex);
+ setState(StateClosed, ex);
}
}
@@ -1308,7 +1308,7 @@ Ice::ConnectionI::setAdapter(const ObjectAdapterPtr& adapter)
if(_exception.get())
{
- _exception->ice_throw();
+ _exception->ice_throw();
}
assert(_state < StateClosing);
@@ -1317,15 +1317,15 @@ Ice::ConnectionI::setAdapter(const ObjectAdapterPtr& adapter)
if(_adapter)
{
- _servantManager = dynamic_cast<ObjectAdapterI*>(_adapter.get())->getServantManager();
- if(!_servantManager)
- {
- _adapter = 0;
- }
+ _servantManager = dynamic_cast<ObjectAdapterI*>(_adapter.get())->getServantManager();
+ if(!_servantManager)
+ {
+ _adapter = 0;
+ }
}
else
{
- _servantManager = 0;
+ _servantManager = 0;
}
//
@@ -1351,7 +1351,7 @@ Ice::ConnectionI::createProxy(const Identity& ident) const
vector<ConnectionIPtr> connections;
connections.push_back(const_cast<ConnectionI*>(this));
ReferencePtr ref = _instance->referenceFactory()->create(ident, _instance->getDefaultContext(),
- "", Reference::ModeTwoway, connections);
+ "", Reference::ModeTwoway, connections);
return _instance->proxyFactory()->referenceToProxy(ref);
}
@@ -1396,28 +1396,28 @@ Ice::ConnectionI::message(BasicStream& stream, const ThreadPoolPtr& threadPool)
OutgoingAsyncPtr outAsync;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- //
- // We must promote within the synchronization, otherwise there
- // could be various race conditions with close connection
- // messages and other messages.
- //
- threadPool->promoteFollower();
+ //
+ // We must promote within the synchronization, otherwise there
+ // could be various race conditions with close connection
+ // messages and other messages.
+ //
+ threadPool->promoteFollower();
- if(_state != StateClosed)
- {
- parseMessage(stream, invokeNum, requestId, compress, servantManager, adapter, outAsync);
- }
+ if(_state != StateClosed)
+ {
+ parseMessage(stream, invokeNum, requestId, compress, servantManager, adapter, outAsync);
+ }
- //
- // parseMessage() can close the connection, so we must check
- // for closed state again.
- //
- if(_state == StateClosed)
- {
- return;
- }
+ //
+ // parseMessage() can close the connection, so we must check
+ // for closed state again.
+ //
+ if(_state == StateClosed)
+ {
+ return;
+ }
}
//
@@ -1426,7 +1426,7 @@ Ice::ConnectionI::message(BasicStream& stream, const ThreadPoolPtr& threadPool)
//
if(outAsync)
{
- outAsync->__finished(stream);
+ outAsync->__finished(stream);
}
//
@@ -1450,57 +1450,57 @@ Ice::ConnectionI::finished(const ThreadPoolPtr& threadPool)
map<Int, AsyncRequest> asyncRequests;
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- --_finishedCount;
- assert(threadPool.get() == _threadPool.get());
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ --_finishedCount;
+ assert(threadPool.get() == _threadPool.get());
- if(_finishedCount == 0 && _state == StateClosed)
- {
- _threadPool->decFdsInUse();
+ if(_finishedCount == 0 && _state == StateClosed)
+ {
+ _threadPool->decFdsInUse();
- //
- // We must make sure that nobody is sending when we close
- // the transceiver.
- //
- IceUtil::Mutex::Lock sendSync(_sendMutex);
+ //
+ // We must make sure that nobody is sending when we close
+ // the transceiver.
+ //
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
- try
- {
- _transceiver->close();
- }
- catch(const LocalException& ex)
- {
- localEx.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
- }
+ try
+ {
+ _transceiver->close();
+ }
+ catch(const LocalException& ex)
+ {
+ localEx.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
+ }
- _transceiver = 0;
- notifyAll();
- }
+ _transceiver = 0;
+ notifyAll();
+ }
- if(_state == StateClosed || _state == StateClosing)
- {
- requests.swap(_requests);
- _requestsHint = _requests.end();
+ if(_state == StateClosed || _state == StateClosing)
+ {
+ requests.swap(_requests);
+ _requestsHint = _requests.end();
- asyncRequests.swap(_asyncRequests);
- _asyncRequestsHint = _asyncRequests.end();
- }
+ asyncRequests.swap(_asyncRequests);
+ _asyncRequestsHint = _asyncRequests.end();
+ }
}
for(map<Int, Outgoing*>::iterator p = requests.begin(); p != requests.end(); ++p)
{
- p->second->finished(*_exception.get()); // The exception is immutable at this point.
+ p->second->finished(*_exception.get()); // The exception is immutable at this point.
}
for(map<Int, AsyncRequest>::iterator q = asyncRequests.begin(); q != asyncRequests.end(); ++q)
{
- q->second.p->__finished(*_exception.get()); // The exception is immutable at this point.
+ q->second.p->__finished(*_exception.get()); // The exception is immutable at this point.
}
if(localEx.get())
{
- localEx->ice_throw();
+ localEx->ice_throw();
}
}
@@ -1524,13 +1524,13 @@ Ice::ConnectionI::invokeException(const LocalException& ex, int invokeNum)
if(invokeNum > 0)
{
- assert(_dispatchCount > 0);
- _dispatchCount -= invokeNum;
- assert(_dispatchCount >= 0);
- if(_dispatchCount == 0)
- {
- notifyAll();
- }
+ assert(_dispatchCount > 0);
+ _dispatchCount -= invokeNum;
+ assert(_dispatchCount >= 0);
+ if(_dispatchCount == 0)
+ {
+ notifyAll();
+ }
}
}
@@ -1565,9 +1565,9 @@ Ice::ConnectionI::getTransceiver() const
}
Ice::ConnectionI::ConnectionI(const InstancePtr& instance,
- const TransceiverPtr& transceiver,
- const EndpointIPtr& endpoint,
- const ObjectAdapterPtr& adapter,
+ const TransceiverPtr& transceiver,
+ const EndpointIPtr& endpoint,
+ const ObjectAdapterPtr& adapter,
bool threadPerConnection,
size_t threadPerConnectionStackSize) :
EventHandler(instance),
@@ -1601,92 +1601,92 @@ Ice::ConnectionI::ConnectionI(const InstancePtr& instance,
Int& acmTimeout = const_cast<Int&>(_acmTimeout);
if(_endpoint->datagram())
{
- acmTimeout = 0;
+ acmTimeout = 0;
}
else
{
- if(_adapter)
- {
- acmTimeout = _instance->serverACM();
- }
- else
- {
- acmTimeout = _instance->clientACM();
- }
+ if(_adapter)
+ {
+ acmTimeout = _instance->serverACM();
+ }
+ else
+ {
+ acmTimeout = _instance->clientACM();
+ }
}
int& compressionLevel = const_cast<int&>(_compressionLevel);
compressionLevel = _instance->initializationData().properties->getPropertyAsIntWithDefault(
- "Ice.Compression.Level", 1);
+ "Ice.Compression.Level", 1);
if(compressionLevel < 1)
{
- compressionLevel = 1;
+ compressionLevel = 1;
}
else if(compressionLevel > 9)
{
- compressionLevel = 9;
+ compressionLevel = 9;
}
ObjectAdapterI* adapterImpl = _adapter ? dynamic_cast<ObjectAdapterI*>(_adapter.get()) : 0;
if(adapterImpl)
{
- _servantManager = adapterImpl->getServantManager();
+ _servantManager = adapterImpl->getServantManager();
}
__setNoDelete(true);
try
{
- if(!threadPerConnection)
- {
- //
- // Only set _threadPool if we really need it, i.e., if we are
- // not in thread per connection mode. Thread pools have lazy
- // initialization in Instance, and we don't want them to be
- // created if they are not needed.
- //
- if(adapterImpl)
- {
- const_cast<ThreadPoolPtr&>(_threadPool) = adapterImpl->getThreadPool();
- }
- else
- {
- const_cast<ThreadPoolPtr&>(_threadPool) = _instance->clientThreadPool();
- }
- _threadPool->incFdsInUse();
- }
- else
- {
- //
- // If we are in thread per connection mode, create the
- // thread for this connection.
- //
- _thread = new ThreadPerConnection(this);
- _thread->start(threadPerConnectionStackSize);
- }
+ if(!threadPerConnection)
+ {
+ //
+ // Only set _threadPool if we really need it, i.e., if we are
+ // not in thread per connection mode. Thread pools have lazy
+ // initialization in Instance, and we don't want them to be
+ // created if they are not needed.
+ //
+ if(adapterImpl)
+ {
+ const_cast<ThreadPoolPtr&>(_threadPool) = adapterImpl->getThreadPool();
+ }
+ else
+ {
+ const_cast<ThreadPoolPtr&>(_threadPool) = _instance->clientThreadPool();
+ }
+ _threadPool->incFdsInUse();
+ }
+ else
+ {
+ //
+ // If we are in thread per connection mode, create the
+ // thread for this connection.
+ //
+ _thread = new ThreadPerConnection(this);
+ _thread->start(threadPerConnectionStackSize);
+ }
}
catch(const IceUtil::Exception& ex)
{
- {
- Error out(_logger);
- if(threadPerConnection)
- {
- out << "cannot create thread for connection:\n" << ex;
- }
- // Otherwise with thread pool the thread pool itself
- // prints a warning if the threads cannot be created.
- }
-
- try
- {
- _transceiver->close();
- }
- catch(const LocalException&)
- {
- // Here we ignore any exceptions in close().
- }
-
- __setNoDelete(false);
- ex.ice_throw();
+ {
+ Error out(_logger);
+ if(threadPerConnection)
+ {
+ out << "cannot create thread for connection:\n" << ex;
+ }
+ // Otherwise with thread pool the thread pool itself
+ // prints a warning if the threads cannot be created.
+ }
+
+ try
+ {
+ _transceiver->close();
+ }
+ catch(const LocalException&)
+ {
+ // Here we ignore any exceptions in close().
+ }
+
+ __setNoDelete(false);
+ ex.ice_throw();
}
__setNoDelete(false);
}
@@ -1710,40 +1710,40 @@ Ice::ConnectionI::setState(State state, const LocalException& ex)
if(_state == state) // Don't switch twice.
{
- return;
+ return;
}
if(!_exception.get())
{
- //
- // If we are in closed state, an exception must be set.
- //
- assert(_state != StateClosed);
-
- _exception.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
-
- if(_warn)
- {
- //
- // We don't warn if we are not validated.
- //
- if(_state > StateNotValidated)
- {
- //
- // Don't warn about certain expected exceptions.
- //
- if(!(dynamic_cast<const CloseConnectionException*>(_exception.get()) ||
- dynamic_cast<const ForcedCloseConnectionException*>(_exception.get()) ||
- dynamic_cast<const ConnectionTimeoutException*>(_exception.get()) ||
- dynamic_cast<const CommunicatorDestroyedException*>(_exception.get()) ||
- dynamic_cast<const ObjectAdapterDeactivatedException*>(_exception.get()) ||
- (dynamic_cast<const ConnectionLostException*>(_exception.get()) && _state == StateClosing)))
- {
- Warning out(_logger);
- out << "connection exception:\n" << *_exception.get() << '\n' << _desc;
- }
- }
- }
+ //
+ // If we are in closed state, an exception must be set.
+ //
+ assert(_state != StateClosed);
+
+ _exception.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
+
+ if(_warn)
+ {
+ //
+ // We don't warn if we are not validated.
+ //
+ if(_state > StateNotValidated)
+ {
+ //
+ // Don't warn about certain expected exceptions.
+ //
+ if(!(dynamic_cast<const CloseConnectionException*>(_exception.get()) ||
+ dynamic_cast<const ForcedCloseConnectionException*>(_exception.get()) ||
+ dynamic_cast<const ConnectionTimeoutException*>(_exception.get()) ||
+ dynamic_cast<const CommunicatorDestroyedException*>(_exception.get()) ||
+ dynamic_cast<const ObjectAdapterDeactivatedException*>(_exception.get()) ||
+ (dynamic_cast<const ConnectionLostException*>(_exception.get()) && _state == StateClosing)))
+ {
+ Warning out(_logger);
+ out << "connection exception:\n" << *_exception.get() << '\n' << _desc;
+ }
+ }
+ }
}
//
@@ -1763,7 +1763,7 @@ Ice::ConnectionI::setState(State state)
//
if(_endpoint->datagram() && state == StateClosing)
{
- state = StateClosed;
+ state = StateClosed;
}
//
@@ -1771,133 +1771,133 @@ Ice::ConnectionI::setState(State state)
//
if(_state == StateNotValidated && state == StateClosing)
{
- state = StateClosed;
+ state = StateClosed;
}
if(_state == state) // Don't switch twice.
{
- return;
+ return;
}
switch(state)
{
- case StateNotValidated:
- {
- assert(false);
- break;
- }
+ case StateNotValidated:
+ {
+ assert(false);
+ break;
+ }
- case StateActive:
- {
- //
+ case StateActive:
+ {
+ //
// Can only switch from holding or not validated to
// active.
- //
- if(_state != StateHolding && _state != StateNotValidated)
- {
- return;
- }
- if(!_threadPerConnection)
- {
- registerWithPool();
- }
- break;
- }
-
- case StateHolding:
- {
- //
- // Can only switch from active or not validated to
- // holding.
- //
- if(_state != StateActive && _state != StateNotValidated)
- {
- return;
- }
- if(!_threadPerConnection)
- {
- unregisterWithPool();
- }
- break;
- }
-
- case StateClosing:
- {
- //
- // Can't change back from closed.
- //
- if(_state == StateClosed)
- {
- return;
- }
- if(!_threadPerConnection)
- {
- registerWithPool(); // We need to continue to read in closing state.
- }
- break;
- }
-
- case StateClosed:
- {
- if(_threadPerConnection)
- {
- //
- // If we are in thread per connection mode, we
- // shutdown both for reading and writing. This will
- // unblock and read call with an exception. The thread
- // per connection then closes the transceiver.
- //
- _transceiver->shutdownReadWrite();
- }
- else if(_state == StateNotValidated)
- {
- //
- // If we change from not validated we can close right
- // away.
- //
- assert(!_registeredWithPool);
-
- _threadPool->decFdsInUse();
-
- //
- // We must make sure that nobody is sending when we
- // close the transceiver.
- //
- IceUtil::Mutex::Lock sendSync(_sendMutex);
-
- try
- {
- _transceiver->close();
- }
- catch(const LocalException&)
- {
- // Here we ignore any exceptions in close().
- }
-
- _transceiver = 0;
- //notifyAll(); // We notify already below.
- }
- else
- {
- //
- // Otherwise we first must make sure that we are
- // registered, then we unregister, and let finished()
- // do the close.
- //
- registerWithPool();
- unregisterWithPool();
-
- //
- // We must prevent any further writes when _state == StateClosed.
- // However, functions such as sendResponse cannot acquire the main
- // mutex in order to check _state. Therefore we shut down the write
- // end of the transceiver, which causes subsequent write attempts
- // to fail with an exception.
- //
- _transceiver->shutdownWrite();
- }
- break;
- }
+ //
+ if(_state != StateHolding && _state != StateNotValidated)
+ {
+ return;
+ }
+ if(!_threadPerConnection)
+ {
+ registerWithPool();
+ }
+ break;
+ }
+
+ case StateHolding:
+ {
+ //
+ // Can only switch from active or not validated to
+ // holding.
+ //
+ if(_state != StateActive && _state != StateNotValidated)
+ {
+ return;
+ }
+ if(!_threadPerConnection)
+ {
+ unregisterWithPool();
+ }
+ break;
+ }
+
+ case StateClosing:
+ {
+ //
+ // Can't change back from closed.
+ //
+ if(_state == StateClosed)
+ {
+ return;
+ }
+ if(!_threadPerConnection)
+ {
+ registerWithPool(); // We need to continue to read in closing state.
+ }
+ break;
+ }
+
+ case StateClosed:
+ {
+ if(_threadPerConnection)
+ {
+ //
+ // If we are in thread per connection mode, we
+ // shutdown both for reading and writing. This will
+ // unblock and read call with an exception. The thread
+ // per connection then closes the transceiver.
+ //
+ _transceiver->shutdownReadWrite();
+ }
+ else if(_state == StateNotValidated)
+ {
+ //
+ // If we change from not validated we can close right
+ // away.
+ //
+ assert(!_registeredWithPool);
+
+ _threadPool->decFdsInUse();
+
+ //
+ // We must make sure that nobody is sending when we
+ // close the transceiver.
+ //
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
+
+ try
+ {
+ _transceiver->close();
+ }
+ catch(const LocalException&)
+ {
+ // Here we ignore any exceptions in close().
+ }
+
+ _transceiver = 0;
+ //notifyAll(); // We notify already below.
+ }
+ else
+ {
+ //
+ // Otherwise we first must make sure that we are
+ // registered, then we unregister, and let finished()
+ // do the close.
+ //
+ registerWithPool();
+ unregisterWithPool();
+
+ //
+ // We must prevent any further writes when _state == StateClosed.
+ // However, functions such as sendResponse cannot acquire the main
+ // mutex in order to check _state. Therefore we shut down the write
+ // end of the transceiver, which causes subsequent write attempts
+ // to fail with an exception.
+ //
+ _transceiver->shutdownWrite();
+ }
+ break;
+ }
}
//
@@ -1909,14 +1909,14 @@ Ice::ConnectionI::setState(State state)
ConnectionMonitorPtr connectionMonitor = _instance->connectionMonitor();
if(connectionMonitor)
{
- if(state == StateActive)
- {
- connectionMonitor->add(this);
- }
- else if(_state == StateActive)
- {
- connectionMonitor->remove(this);
- }
+ if(state == StateActive)
+ {
+ connectionMonitor->add(this);
+ }
+ else if(_state == StateActive)
+ {
+ connectionMonitor->remove(this);
+ }
}
_state = state;
@@ -1926,14 +1926,14 @@ Ice::ConnectionI::setState(State state)
if(_state == StateClosing && _dispatchCount == 0)
{
- try
- {
- initiateShutdown();
- }
- catch(const LocalException& ex)
- {
- setState(StateClosed, ex);
- }
+ try
+ {
+ initiateShutdown();
+ }
+ catch(const LocalException& ex)
+ {
+ setState(StateClosed, ex);
+ }
}
}
@@ -1945,39 +1945,39 @@ Ice::ConnectionI::initiateShutdown() const
if(!_endpoint->datagram())
{
- IceUtil::Mutex::Lock sendSync(_sendMutex);
-
- //
- // Before we shut down, we send a close connection message.
- //
- BasicStream os(_instance.get());
- os.write(magic[0]);
- os.write(magic[1]);
- os.write(magic[2]);
- os.write(magic[3]);
- os.write(protocolMajor);
- os.write(protocolMinor);
- os.write(encodingMajor);
- os.write(encodingMinor);
- os.write(closeConnectionMsg);
- os.write((Byte)1); // Compression status: compression supported but not used.
- os.write(headerSize); // Message size.
-
- //
- // Send the message.
- //
- os.i = os.b.begin();
- traceHeader("sending close connection", os, _logger, _traceLevels);
- _transceiver->write(os, _endpoint->timeout());
- //
- // The CloseConnection message should be sufficient. Closing the write
- // end of the socket is probably an artifact of how things were done
- // in IIOP. In fact, shutting down the write end of the socket causes
- // problems on Windows by preventing the peer from using the socket.
- // For example, the peer is no longer able to continue writing a large
- // message after the socket is shutdown.
- //
- //_transceiver->shutdownWrite();
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
+
+ //
+ // Before we shut down, we send a close connection message.
+ //
+ BasicStream os(_instance.get());
+ os.write(magic[0]);
+ os.write(magic[1]);
+ os.write(magic[2]);
+ os.write(magic[3]);
+ os.write(protocolMajor);
+ os.write(protocolMinor);
+ os.write(encodingMajor);
+ os.write(encodingMinor);
+ os.write(closeConnectionMsg);
+ os.write((Byte)1); // Compression status: compression supported but not used.
+ os.write(headerSize); // Message size.
+
+ //
+ // Send the message.
+ //
+ os.i = os.b.begin();
+ traceHeader("sending close connection", os, _logger, _traceLevels);
+ _transceiver->write(os, _endpoint->timeout());
+ //
+ // The CloseConnection message should be sufficient. Closing the write
+ // end of the socket is probably an artifact of how things were done
+ // in IIOP. In fact, shutting down the write end of the socket causes
+ // problems on Windows by preventing the peer from using the socket.
+ // For example, the peer is no longer able to continue writing a large
+ // message after the socket is shutdown.
+ //
+ //_transceiver->shutdownWrite();
}
}
@@ -1988,8 +1988,8 @@ Ice::ConnectionI::registerWithPool()
if(!_registeredWithPool)
{
- _threadPool->_register(_transceiver->fd(), this);
- _registeredWithPool = true;
+ _threadPool->_register(_transceiver->fd(), this);
+ _registeredWithPool = true;
}
}
@@ -2000,9 +2000,9 @@ Ice::ConnectionI::unregisterWithPool()
if(_registeredWithPool)
{
- _threadPool->unregister(_transceiver->fd());
- _registeredWithPool = false;
- ++_finishedCount; // For each unregistration, finished() is called once.
+ _threadPool->unregister(_transceiver->fd());
+ _registeredWithPool = false;
+ ++_finishedCount; // For each unregistration, finished() is called once.
}
}
@@ -2011,59 +2011,59 @@ getBZ2Error(int bzError)
{
if(bzError == BZ_RUN_OK)
{
- return ": BZ_RUN_OK";
+ return ": BZ_RUN_OK";
}
else if(bzError == BZ_FLUSH_OK)
{
- return ": BZ_FLUSH_OK";
+ return ": BZ_FLUSH_OK";
}
else if(bzError == BZ_FINISH_OK)
{
- return ": BZ_FINISH_OK";
+ return ": BZ_FINISH_OK";
}
else if(bzError == BZ_STREAM_END)
{
- return ": BZ_STREAM_END";
+ return ": BZ_STREAM_END";
}
else if(bzError == BZ_CONFIG_ERROR)
{
- return ": BZ_CONFIG_ERROR";
+ return ": BZ_CONFIG_ERROR";
}
else if(bzError == BZ_SEQUENCE_ERROR)
{
- return ": BZ_SEQUENCE_ERROR";
+ return ": BZ_SEQUENCE_ERROR";
}
else if(bzError == BZ_PARAM_ERROR)
{
- return ": BZ_PARAM_ERROR";
+ return ": BZ_PARAM_ERROR";
}
else if(bzError == BZ_MEM_ERROR)
{
- return ": BZ_MEM_ERROR";
+ return ": BZ_MEM_ERROR";
}
else if(bzError == BZ_DATA_ERROR)
{
- return ": BZ_DATA_ERROR";
+ return ": BZ_DATA_ERROR";
}
else if(bzError == BZ_DATA_ERROR_MAGIC)
{
- return ": BZ_DATA_ERROR_MAGIC";
+ return ": BZ_DATA_ERROR_MAGIC";
}
else if(bzError == BZ_IO_ERROR)
{
- return ": BZ_IO_ERROR";
+ return ": BZ_IO_ERROR";
}
else if(bzError == BZ_UNEXPECTED_EOF)
{
- return ": BZ_UNEXPECTED_EOF";
+ return ": BZ_UNEXPECTED_EOF";
}
else if(bzError == BZ_OUTBUFF_FULL)
{
- return ": BZ_OUTBUFF_FULL";
+ return ": BZ_OUTBUFF_FULL";
}
else
{
- return "";
+ return "";
}
}
@@ -2079,15 +2079,15 @@ Ice::ConnectionI::doCompress(BasicStream& uncompressed, BasicStream& compressed)
unsigned int compressedLen = static_cast<unsigned int>(uncompressedLen * 1.01 + 600);
compressed.b.resize(headerSize + sizeof(Int) + compressedLen);
int bzError = BZ2_bzBuffToBuffCompress(reinterpret_cast<char*>(&compressed.b[0]) + headerSize + sizeof(Int),
- &compressedLen,
- reinterpret_cast<char*>(&uncompressed.b[0]) + headerSize,
- uncompressedLen,
- _compressionLevel, 0, 0);
+ &compressedLen,
+ reinterpret_cast<char*>(&uncompressed.b[0]) + headerSize,
+ uncompressedLen,
+ _compressionLevel, 0, 0);
if(bzError != BZ_OK)
{
- CompressionException ex(__FILE__, __LINE__);
- ex.reason = "BZ2_bzBuffToBuffCompress failed" + getBZ2Error(bzError);
- throw ex;
+ CompressionException ex(__FILE__, __LINE__);
+ ex.reason = "BZ2_bzBuffToBuffCompress failed" + getBZ2Error(bzError);
+ throw ex;
}
compressed.b.resize(headerSize + sizeof(Int) + compressedLen);
@@ -2130,22 +2130,22 @@ Ice::ConnectionI::doUncompress(BasicStream& compressed, BasicStream& uncompresse
compressed.read(uncompressedSize);
if(uncompressedSize <= headerSize)
{
- throw IllegalMessageSizeException(__FILE__, __LINE__);
+ throw IllegalMessageSizeException(__FILE__, __LINE__);
}
uncompressed.resize(uncompressedSize);
unsigned int uncompressedLen = uncompressedSize - headerSize;
unsigned int compressedLen = static_cast<unsigned int>(compressed.b.size() - headerSize - sizeof(Int));
int bzError = BZ2_bzBuffToBuffDecompress(reinterpret_cast<char*>(&uncompressed.b[0]) + headerSize,
- &uncompressedLen,
- reinterpret_cast<char*>(&compressed.b[0]) + headerSize + sizeof(Int),
- compressedLen,
- 0, 0);
+ &uncompressedLen,
+ reinterpret_cast<char*>(&compressed.b[0]) + headerSize + sizeof(Int),
+ compressedLen,
+ 0, 0);
if(bzError != BZ_OK)
{
- CompressionException ex(__FILE__, __LINE__);
- ex.reason = "BZ2_bzBuffToBuffCompress failed" + getBZ2Error(bzError);
- throw ex;
+ CompressionException ex(__FILE__, __LINE__);
+ ex.reason = "BZ2_bzBuffToBuffCompress failed" + getBZ2Error(bzError);
+ throw ex;
}
copy(compressed.b.begin(), compressed.b.begin() + headerSize, uncompressed.b.begin());
@@ -2153,222 +2153,222 @@ Ice::ConnectionI::doUncompress(BasicStream& compressed, BasicStream& uncompresse
void
Ice::ConnectionI::parseMessage(BasicStream& stream, Int& invokeNum, Int& requestId, Byte& compress,
- ServantManagerPtr& servantManager, ObjectAdapterPtr& adapter,
- OutgoingAsyncPtr& outAsync)
+ ServantManagerPtr& servantManager, ObjectAdapterPtr& adapter,
+ OutgoingAsyncPtr& outAsync)
{
assert(_state > StateNotValidated && _state < StateClosed);
if(_acmTimeout > 0)
{
- _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
+ _acmAbsoluteTimeout = IceUtil::Time::now() + IceUtil::Time::seconds(_acmTimeout);
}
try
{
- //
- // We don't need to check magic and version here. This has
- // already been done by the ThreadPool or the
- // ThreadPerConnection, which provides us with the stream.
- //
- assert(stream.i == stream.b.end());
- stream.i = stream.b.begin() + 8;
- Byte messageType;
- stream.read(messageType);
- stream.read(compress);
- if(compress == 2)
- {
- BasicStream ustream(_instance.get());
- doUncompress(stream, ustream);
- stream.b.swap(ustream.b);
- }
- stream.i = stream.b.begin() + headerSize;
+ //
+ // We don't need to check magic and version here. This has
+ // already been done by the ThreadPool or the
+ // ThreadPerConnection, which provides us with the stream.
+ //
+ assert(stream.i == stream.b.end());
+ stream.i = stream.b.begin() + 8;
+ Byte messageType;
+ stream.read(messageType);
+ stream.read(compress);
+ if(compress == 2)
+ {
+ BasicStream ustream(_instance.get());
+ doUncompress(stream, ustream);
+ stream.b.swap(ustream.b);
+ }
+ stream.i = stream.b.begin() + headerSize;
- switch(messageType)
- {
- case closeConnectionMsg:
- {
- traceHeader("received close connection", stream, _logger, _traceLevels);
- if(_endpoint->datagram())
- {
- if(_warn)
- {
- Warning out(_logger);
- out << "ignoring close connection message for datagram connection:\n" << _desc;
- }
- }
- else
- {
- setState(StateClosed, CloseConnectionException(__FILE__, __LINE__));
- }
- break;
- }
-
- case requestMsg:
- {
- if(_state == StateClosing)
- {
- traceRequest("received request during closing\n"
- "(ignored by server, client will retry)",
- stream, _logger, _traceLevels);
- }
- else
- {
- traceRequest("received request", stream, _logger, _traceLevels);
- stream.read(requestId);
- invokeNum = 1;
- servantManager = _servantManager;
- adapter = _adapter;
- ++_dispatchCount;
- }
- break;
- }
-
- case requestBatchMsg:
- {
- if(_state == StateClosing)
- {
- traceBatchRequest("received batch request during closing\n"
- "(ignored by server, client will retry)",
- stream, _logger, _traceLevels);
- }
- else
- {
- traceBatchRequest("received batch request", stream, _logger, _traceLevels);
- stream.read(invokeNum);
- if(invokeNum < 0)
- {
- invokeNum = 0;
- throw NegativeSizeException(__FILE__, __LINE__);
- }
- servantManager = _servantManager;
- adapter = _adapter;
- _dispatchCount += invokeNum;
- }
- break;
- }
-
- case replyMsg:
- {
- traceReply("received reply", stream, _logger, _traceLevels);
-
- stream.read(requestId);
-
- map<Int, Outgoing*>::iterator p = _requests.end();
- map<Int, AsyncRequest>::iterator q = _asyncRequests.end();
-
- if(_requestsHint != _requests.end())
- {
- if(_requestsHint->first == requestId)
- {
- p = _requestsHint;
- }
- }
-
- if(p == _requests.end())
- {
- if(_asyncRequestsHint != _asyncRequests.end())
- {
- if(_asyncRequestsHint->first == requestId)
- {
- q = _asyncRequestsHint;
- }
- }
- }
-
- if(p == _requests.end() && q == _asyncRequests.end())
- {
- p = _requests.find(requestId);
- }
-
- if(p == _requests.end() && q == _asyncRequests.end())
- {
- q = _asyncRequests.find(requestId);
- }
-
- if(p == _requests.end() && q == _asyncRequests.end())
- {
- throw UnknownRequestIdException(__FILE__, __LINE__);
- }
-
- if(p != _requests.end())
- {
- p->second->finished(stream);
-
- if(p == _requestsHint)
- {
- _requests.erase(p++);
- _requestsHint = p;
- }
- else
- {
- _requests.erase(p);
- }
- }
- else
- {
- assert(q != _asyncRequests.end());
-
- outAsync = q->second.p;
-
- if(q == _asyncRequestsHint)
- {
- _asyncRequests.erase(q++);
- _asyncRequestsHint = q;
- }
- else
- {
- _asyncRequests.erase(q);
- }
- }
-
- break;
- }
-
- case validateConnectionMsg:
- {
- traceHeader("received validate connection", stream, _logger, _traceLevels);
- if(_warn)
- {
- Warning out(_logger);
- out << "ignoring unexpected validate connection message:\n" << _desc;
- }
- break;
- }
-
- default:
- {
- traceHeader("received unknown message\n"
- "(invalid, closing connection)",
- stream, _logger, _traceLevels);
- throw UnknownMessageException(__FILE__, __LINE__);
- break;
- }
- }
+ switch(messageType)
+ {
+ case closeConnectionMsg:
+ {
+ traceHeader("received close connection", stream, _logger, _traceLevels);
+ if(_endpoint->datagram())
+ {
+ if(_warn)
+ {
+ Warning out(_logger);
+ out << "ignoring close connection message for datagram connection:\n" << _desc;
+ }
+ }
+ else
+ {
+ setState(StateClosed, CloseConnectionException(__FILE__, __LINE__));
+ }
+ break;
+ }
+
+ case requestMsg:
+ {
+ if(_state == StateClosing)
+ {
+ traceRequest("received request during closing\n"
+ "(ignored by server, client will retry)",
+ stream, _logger, _traceLevels);
+ }
+ else
+ {
+ traceRequest("received request", stream, _logger, _traceLevels);
+ stream.read(requestId);
+ invokeNum = 1;
+ servantManager = _servantManager;
+ adapter = _adapter;
+ ++_dispatchCount;
+ }
+ break;
+ }
+
+ case requestBatchMsg:
+ {
+ if(_state == StateClosing)
+ {
+ traceBatchRequest("received batch request during closing\n"
+ "(ignored by server, client will retry)",
+ stream, _logger, _traceLevels);
+ }
+ else
+ {
+ traceBatchRequest("received batch request", stream, _logger, _traceLevels);
+ stream.read(invokeNum);
+ if(invokeNum < 0)
+ {
+ invokeNum = 0;
+ throw NegativeSizeException(__FILE__, __LINE__);
+ }
+ servantManager = _servantManager;
+ adapter = _adapter;
+ _dispatchCount += invokeNum;
+ }
+ break;
+ }
+
+ case replyMsg:
+ {
+ traceReply("received reply", stream, _logger, _traceLevels);
+
+ stream.read(requestId);
+
+ map<Int, Outgoing*>::iterator p = _requests.end();
+ map<Int, AsyncRequest>::iterator q = _asyncRequests.end();
+
+ if(_requestsHint != _requests.end())
+ {
+ if(_requestsHint->first == requestId)
+ {
+ p = _requestsHint;
+ }
+ }
+
+ if(p == _requests.end())
+ {
+ if(_asyncRequestsHint != _asyncRequests.end())
+ {
+ if(_asyncRequestsHint->first == requestId)
+ {
+ q = _asyncRequestsHint;
+ }
+ }
+ }
+
+ if(p == _requests.end() && q == _asyncRequests.end())
+ {
+ p = _requests.find(requestId);
+ }
+
+ if(p == _requests.end() && q == _asyncRequests.end())
+ {
+ q = _asyncRequests.find(requestId);
+ }
+
+ if(p == _requests.end() && q == _asyncRequests.end())
+ {
+ throw UnknownRequestIdException(__FILE__, __LINE__);
+ }
+
+ if(p != _requests.end())
+ {
+ p->second->finished(stream);
+
+ if(p == _requestsHint)
+ {
+ _requests.erase(p++);
+ _requestsHint = p;
+ }
+ else
+ {
+ _requests.erase(p);
+ }
+ }
+ else
+ {
+ assert(q != _asyncRequests.end());
+
+ outAsync = q->second.p;
+
+ if(q == _asyncRequestsHint)
+ {
+ _asyncRequests.erase(q++);
+ _asyncRequestsHint = q;
+ }
+ else
+ {
+ _asyncRequests.erase(q);
+ }
+ }
+
+ break;
+ }
+
+ case validateConnectionMsg:
+ {
+ traceHeader("received validate connection", stream, _logger, _traceLevels);
+ if(_warn)
+ {
+ Warning out(_logger);
+ out << "ignoring unexpected validate connection message:\n" << _desc;
+ }
+ break;
+ }
+
+ default:
+ {
+ traceHeader("received unknown message\n"
+ "(invalid, closing connection)",
+ stream, _logger, _traceLevels);
+ throw UnknownMessageException(__FILE__, __LINE__);
+ break;
+ }
+ }
}
catch(const SocketException& ex)
{
- exception(ex);
+ exception(ex);
}
catch(const LocalException& ex)
{
- if(_endpoint->datagram())
- {
- if(_warn)
- {
- Warning out(_logger);
- out << "datagram connection exception:\n" << ex << '\n' << _desc;
- }
- }
- else
- {
- setState(StateClosed, ex);
- }
+ if(_endpoint->datagram())
+ {
+ if(_warn)
+ {
+ Warning out(_logger);
+ out << "datagram connection exception:\n" << ex << '\n' << _desc;
+ }
+ }
+ else
+ {
+ setState(StateClosed, ex);
+ }
}
}
void
Ice::ConnectionI::invokeAll(BasicStream& stream, Int invokeNum, Int requestId, Byte compress,
- const ServantManagerPtr& servantManager, const ObjectAdapterPtr& adapter)
+ const ServantManagerPtr& servantManager, const ObjectAdapterPtr& adapter)
{
//
// Note: In contrast to other private or protected methods, this
@@ -2377,45 +2377,45 @@ Ice::ConnectionI::invokeAll(BasicStream& stream, Int invokeNum, Int requestId, B
try
{
- while(invokeNum > 0)
- {
- //
- // Prepare the invocation.
- //
- bool response = !_endpoint->datagram() && requestId != 0;
- Incoming in(_instance.get(), this, adapter, response, compress, requestId);
- BasicStream* is = in.is();
- stream.swap(*is);
- BasicStream* os = in.os();
-
- //
- // Prepare the response if necessary.
- //
- if(response)
- {
- assert(invokeNum == 1); // No further invocations if a response is expected.
- os->writeBlob(replyHdr, sizeof(replyHdr));
-
- //
- // Add the request ID.
- //
- os->write(requestId);
- }
-
- in.invoke(servantManager);
-
- //
- // If there are more invocations, we need the stream back.
- //
- if(--invokeNum > 0)
- {
- stream.swap(*is);
- }
- }
+ while(invokeNum > 0)
+ {
+ //
+ // Prepare the invocation.
+ //
+ bool response = !_endpoint->datagram() && requestId != 0;
+ Incoming in(_instance.get(), this, adapter, response, compress, requestId);
+ BasicStream* is = in.is();
+ stream.swap(*is);
+ BasicStream* os = in.os();
+
+ //
+ // Prepare the response if necessary.
+ //
+ if(response)
+ {
+ assert(invokeNum == 1); // No further invocations if a response is expected.
+ os->writeBlob(replyHdr, sizeof(replyHdr));
+
+ //
+ // Add the request ID.
+ //
+ os->write(requestId);
+ }
+
+ in.invoke(servantManager);
+
+ //
+ // If there are more invocations, we need the stream back.
+ //
+ if(--invokeNum > 0)
+ {
+ stream.swap(*is);
+ }
+ }
}
catch(const LocalException& ex)
{
- invokeException(ex, invokeNum); // Fatal invocation exception
+ invokeException(ex, invokeNum); // Fatal invocation exception
}
}
@@ -2430,40 +2430,40 @@ Ice::ConnectionI::run()
//
if(!_endpoint->datagram())
{
- try
- {
- validate();
- }
- catch(const LocalException&)
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- assert(_state == StateClosed);
-
- //
- // We must make sure that nobody is sending when we close
- // the transceiver.
- //
- IceUtil::Mutex::Lock sendSync(_sendMutex);
-
- if(_transceiver)
- {
- try
- {
- _transceiver->close();
- }
- catch(const LocalException&)
- {
- // Here we ignore any exceptions in close().
- }
-
- _transceiver = 0;
- }
- notifyAll();
- return;
- }
-
- activate();
+ try
+ {
+ validate();
+ }
+ catch(const LocalException&)
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ assert(_state == StateClosed);
+
+ //
+ // We must make sure that nobody is sending when we close
+ // the transceiver.
+ //
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
+
+ if(_transceiver)
+ {
+ try
+ {
+ _transceiver->close();
+ }
+ catch(const LocalException&)
+ {
+ // Here we ignore any exceptions in close().
+ }
+
+ _transceiver = 0;
+ }
+ notifyAll();
+ return;
+ }
+
+ activate();
}
const bool warnUdp = _instance->initializationData().properties->getPropertyAsInt("Ice.Warn.Datagrams") > 0;
@@ -2472,213 +2472,213 @@ Ice::ConnectionI::run()
while(!closed)
{
- //
- // We must accept new connections outside the thread
- // synchronization, because we use blocking accept.
- //
-
- BasicStream stream(_instance.get());
-
- try
- {
- stream.b.resize(headerSize);
- stream.i = stream.b.begin();
- _transceiver->read(stream, -1);
-
- ptrdiff_t pos = stream.i - stream.b.begin();
- if(pos < headerSize)
- {
- //
- // This situation is possible for small UDP packets.
- //
- throw IllegalMessageSizeException(__FILE__, __LINE__);
- }
- stream.i = stream.b.begin();
- const Byte* header;
- stream.readBlob(header, headerSize);
- if(header[0] != magic[0] || header[1] != magic[1] || header[2] != magic[2] || header[3] != magic[3])
- {
- BadMagicException ex(__FILE__, __LINE__);
- ex.badMagic = Ice::ByteSeq(&header[0], &header[0] + sizeof(magic));
- throw ex;
- }
- if(header[4] != protocolMajor)
- {
- UnsupportedProtocolException ex(__FILE__, __LINE__);
- ex.badMajor = static_cast<unsigned char>(header[4]);
- ex.badMinor = static_cast<unsigned char>(header[5]);
- ex.major = static_cast<unsigned char>(protocolMajor);
- ex.minor = static_cast<unsigned char>(protocolMinor);
- throw ex;
- }
- if(header[6] != encodingMajor)
- {
- UnsupportedEncodingException ex(__FILE__, __LINE__);
- ex.badMajor = static_cast<unsigned char>(header[6]);
- ex.badMinor = static_cast<unsigned char>(header[7]);
- ex.major = static_cast<unsigned char>(encodingMajor);
- ex.minor = static_cast<unsigned char>(encodingMinor);
- throw ex;
- }
-
- Int size;
- stream.i -= sizeof(Int);
- stream.read(size);
- if(size < headerSize)
- {
- throw IllegalMessageSizeException(__FILE__, __LINE__);
- }
- if(size > static_cast<Int>(_instance->messageSizeMax()))
- {
- throw MemoryLimitException(__FILE__, __LINE__);
- }
- if(size > static_cast<Int>(stream.b.size()))
- {
- stream.b.resize(size);
- }
- stream.i = stream.b.begin() + pos;
-
- if(stream.i != stream.b.end())
- {
- if(_endpoint->datagram())
- {
- if(warnUdp)
- {
- Warning out(_logger);
- out << "DatagramLimitException: maximum size of " << pos << " exceeded";
- }
- throw DatagramLimitException(__FILE__, __LINE__);
- }
- else
- {
- _transceiver->read(stream, -1);
- assert(stream.i == stream.b.end());
- }
- }
- }
- catch(const DatagramLimitException&) // Expected.
- {
- continue;
- }
- catch(const SocketException& ex)
- {
- exception(ex);
- }
- catch(const LocalException& ex)
- {
- if(_endpoint->datagram())
- {
- if(_warn)
- {
- Warning out(_logger);
- out << "datagram connection exception:\n" << ex << '\n' << _desc;
- }
- continue;
- }
- else
- {
- exception(ex);
- }
- }
-
- Byte compress = 0;
- Int requestId = 0;
- Int invokeNum = 0;
- ServantManagerPtr servantManager;
- ObjectAdapterPtr adapter;
- OutgoingAsyncPtr outAsync;
-
- auto_ptr<LocalException> localEx;
-
- map<Int, Outgoing*> requests;
- map<Int, AsyncRequest> asyncRequests;
-
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- while(_state == StateHolding)
- {
- wait();
- }
-
- if(_state != StateClosed)
- {
- parseMessage(stream, invokeNum, requestId, compress, servantManager, adapter, outAsync);
- }
-
- //
+ //
+ // We must accept new connections outside the thread
+ // synchronization, because we use blocking accept.
+ //
+
+ BasicStream stream(_instance.get());
+
+ try
+ {
+ stream.b.resize(headerSize);
+ stream.i = stream.b.begin();
+ _transceiver->read(stream, -1);
+
+ ptrdiff_t pos = stream.i - stream.b.begin();
+ if(pos < headerSize)
+ {
+ //
+ // This situation is possible for small UDP packets.
+ //
+ throw IllegalMessageSizeException(__FILE__, __LINE__);
+ }
+ stream.i = stream.b.begin();
+ const Byte* header;
+ stream.readBlob(header, headerSize);
+ if(header[0] != magic[0] || header[1] != magic[1] || header[2] != magic[2] || header[3] != magic[3])
+ {
+ BadMagicException ex(__FILE__, __LINE__);
+ ex.badMagic = Ice::ByteSeq(&header[0], &header[0] + sizeof(magic));
+ throw ex;
+ }
+ if(header[4] != protocolMajor)
+ {
+ UnsupportedProtocolException ex(__FILE__, __LINE__);
+ ex.badMajor = static_cast<unsigned char>(header[4]);
+ ex.badMinor = static_cast<unsigned char>(header[5]);
+ ex.major = static_cast<unsigned char>(protocolMajor);
+ ex.minor = static_cast<unsigned char>(protocolMinor);
+ throw ex;
+ }
+ if(header[6] != encodingMajor)
+ {
+ UnsupportedEncodingException ex(__FILE__, __LINE__);
+ ex.badMajor = static_cast<unsigned char>(header[6]);
+ ex.badMinor = static_cast<unsigned char>(header[7]);
+ ex.major = static_cast<unsigned char>(encodingMajor);
+ ex.minor = static_cast<unsigned char>(encodingMinor);
+ throw ex;
+ }
+
+ Int size;
+ stream.i -= sizeof(Int);
+ stream.read(size);
+ if(size < headerSize)
+ {
+ throw IllegalMessageSizeException(__FILE__, __LINE__);
+ }
+ if(size > static_cast<Int>(_instance->messageSizeMax()))
+ {
+ throw MemoryLimitException(__FILE__, __LINE__);
+ }
+ if(size > static_cast<Int>(stream.b.size()))
+ {
+ stream.b.resize(size);
+ }
+ stream.i = stream.b.begin() + pos;
+
+ if(stream.i != stream.b.end())
+ {
+ if(_endpoint->datagram())
+ {
+ if(warnUdp)
+ {
+ Warning out(_logger);
+ out << "DatagramLimitException: maximum size of " << pos << " exceeded";
+ }
+ throw DatagramLimitException(__FILE__, __LINE__);
+ }
+ else
+ {
+ _transceiver->read(stream, -1);
+ assert(stream.i == stream.b.end());
+ }
+ }
+ }
+ catch(const DatagramLimitException&) // Expected.
+ {
+ continue;
+ }
+ catch(const SocketException& ex)
+ {
+ exception(ex);
+ }
+ catch(const LocalException& ex)
+ {
+ if(_endpoint->datagram())
+ {
+ if(_warn)
+ {
+ Warning out(_logger);
+ out << "datagram connection exception:\n" << ex << '\n' << _desc;
+ }
+ continue;
+ }
+ else
+ {
+ exception(ex);
+ }
+ }
+
+ Byte compress = 0;
+ Int requestId = 0;
+ Int invokeNum = 0;
+ ServantManagerPtr servantManager;
+ ObjectAdapterPtr adapter;
+ OutgoingAsyncPtr outAsync;
+
+ auto_ptr<LocalException> localEx;
+
+ map<Int, Outgoing*> requests;
+ map<Int, AsyncRequest> asyncRequests;
+
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ while(_state == StateHolding)
+ {
+ wait();
+ }
+
+ if(_state != StateClosed)
+ {
+ parseMessage(stream, invokeNum, requestId, compress, servantManager, adapter, outAsync);
+ }
+
+ //
// parseMessage() can close the connection, so we must
// check for closed state again.
- //
- if(_state == StateClosed)
- {
- //
- // We must make sure that nobody is sending when we close
- // the transceiver.
- //
- IceUtil::Mutex::Lock sendSync(_sendMutex);
-
- try
- {
- _transceiver->close();
- }
- catch(const LocalException& ex)
- {
- localEx.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
- }
-
- _transceiver = 0;
- notifyAll();
-
- //
- // We cannot simply return here. We have to make sure
- // that all requests (regular and async) are notified
- // about the closed connection below.
- //
- closed = true;
- }
-
- if(_state == StateClosed || _state == StateClosing)
- {
- requests.swap(_requests);
- _requestsHint = _requests.end();
-
- asyncRequests.swap(_asyncRequests);
- _asyncRequestsHint = _asyncRequests.end();
- }
- }
-
- //
- // Asynchronous replies must be handled outside the thread
- // synchronization, so that nested calls are possible.
- //
- if(outAsync)
- {
- outAsync->__finished(stream);
- }
-
- //
- // Method invocation (or multiple invocations for batch messages)
- // must be done outside the thread synchronization, so that nested
- // calls are possible.
- //
- invokeAll(stream, invokeNum, requestId, compress, servantManager, adapter);
-
- for(map<Int, Outgoing*>::iterator p = requests.begin(); p != requests.end(); ++p)
- {
- p->second->finished(*_exception.get()); // The exception is immutable at this point.
- }
-
- for(map<Int, AsyncRequest>::iterator q = asyncRequests.begin(); q != asyncRequests.end(); ++q)
- {
- q->second.p->__finished(*_exception.get()); // The exception is immutable at this point.
- }
-
- if(localEx.get())
- {
- assert(closed);
- localEx->ice_throw();
- }
+ //
+ if(_state == StateClosed)
+ {
+ //
+ // We must make sure that nobody is sending when we close
+ // the transceiver.
+ //
+ IceUtil::Mutex::Lock sendSync(_sendMutex);
+
+ try
+ {
+ _transceiver->close();
+ }
+ catch(const LocalException& ex)
+ {
+ localEx.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
+ }
+
+ _transceiver = 0;
+ notifyAll();
+
+ //
+ // We cannot simply return here. We have to make sure
+ // that all requests (regular and async) are notified
+ // about the closed connection below.
+ //
+ closed = true;
+ }
+
+ if(_state == StateClosed || _state == StateClosing)
+ {
+ requests.swap(_requests);
+ _requestsHint = _requests.end();
+
+ asyncRequests.swap(_asyncRequests);
+ _asyncRequestsHint = _asyncRequests.end();
+ }
+ }
+
+ //
+ // Asynchronous replies must be handled outside the thread
+ // synchronization, so that nested calls are possible.
+ //
+ if(outAsync)
+ {
+ outAsync->__finished(stream);
+ }
+
+ //
+ // Method invocation (or multiple invocations for batch messages)
+ // must be done outside the thread synchronization, so that nested
+ // calls are possible.
+ //
+ invokeAll(stream, invokeNum, requestId, compress, servantManager, adapter);
+
+ for(map<Int, Outgoing*>::iterator p = requests.begin(); p != requests.end(); ++p)
+ {
+ p->second->finished(*_exception.get()); // The exception is immutable at this point.
+ }
+
+ for(map<Int, AsyncRequest>::iterator q = asyncRequests.begin(); q != asyncRequests.end(); ++q)
+ {
+ q->second.p->__finished(*_exception.get()); // The exception is immutable at this point.
+ }
+
+ if(localEx.get())
+ {
+ assert(closed);
+ localEx->ice_throw();
+ }
}
}
@@ -2700,19 +2700,19 @@ Ice::ConnectionI::ThreadPerConnection::run()
_connection->run();
}
catch(const Exception& ex)
- {
- Error out(_connection->_logger);
- out << "exception in thread per connection:\n" << _connection->toString() << ex;
+ {
+ Error out(_connection->_logger);
+ out << "exception in thread per connection:\n" << _connection->toString() << ex;
}
catch(const std::exception& ex)
{
- Error out(_connection->_logger);
- out << "std::exception in thread per connection:\n" << _connection->toString() << ex.what();
+ Error out(_connection->_logger);
+ out << "std::exception in thread per connection:\n" << _connection->toString() << ex.what();
}
catch(...)
{
- Error out(_connection->_logger);
- out << "unknown exception in thread per connection:\n" << _connection->toString();
+ Error out(_connection->_logger);
+ out << "unknown exception in thread per connection:\n" << _connection->toString();
}
if(_connection->_instance->initializationData().threadHook)
diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h
index 626f1c776be..f07841c5632 100644
--- a/cpp/src/Ice/ConnectionI.h
+++ b/cpp/src/Ice/ConnectionI.h
@@ -40,15 +40,15 @@ namespace Ice
class LocalException;
class ICE_API ConnectionI : public Connection, public IceInternal::EventHandler,
- public IceUtil::Monitor<IceUtil::Mutex>
+ public IceUtil::Monitor<IceUtil::Mutex>
{
public:
void validate();
enum DestructionReason
{
- ObjectAdapterDeactivated,
- CommunicatorDestroyed
+ ObjectAdapterDeactivated,
+ CommunicatorDestroyed
};
void activate();
void hold();
@@ -103,18 +103,18 @@ public:
private:
ConnectionI(const IceInternal::InstancePtr&, const IceInternal::TransceiverPtr&,
- const IceInternal::EndpointIPtr&, const ObjectAdapterPtr&, bool, size_t);
+ const IceInternal::EndpointIPtr&, const ObjectAdapterPtr&, bool, size_t);
virtual ~ConnectionI();
friend class IceInternal::IncomingConnectionFactory;
friend class IceInternal::OutgoingConnectionFactory;
enum State
{
- StateNotValidated,
- StateActive,
- StateHolding,
- StateClosing,
- StateClosed
+ StateNotValidated,
+ StateActive,
+ StateHolding,
+ StateClosing,
+ StateClosed
};
void resetBatch(bool);
@@ -132,22 +132,22 @@ private:
void doUncompress(IceInternal::BasicStream&, IceInternal::BasicStream&);
void parseMessage(IceInternal::BasicStream&, Int&, Int&, Byte&,
- IceInternal::ServantManagerPtr&, ObjectAdapterPtr&, IceInternal::OutgoingAsyncPtr&);
+ IceInternal::ServantManagerPtr&, ObjectAdapterPtr&, IceInternal::OutgoingAsyncPtr&);
void invokeAll(IceInternal::BasicStream&, Int, Int, Byte,
- const IceInternal::ServantManagerPtr&, const ObjectAdapterPtr&);
+ const IceInternal::ServantManagerPtr&, const ObjectAdapterPtr&);
void run(); // For thread per connection.
class ThreadPerConnection : public IceUtil::Thread
{
public:
-
- ThreadPerConnection(const ConnectionIPtr&);
- virtual void run();
+
+ ThreadPerConnection(const ConnectionIPtr&);
+ virtual void run();
private:
-
- ConnectionIPtr _connection;
+
+ ConnectionIPtr _connection;
};
friend class ThreadPerConnection;
// Defined as mutable because "isFinished() const" sets this to 0.
@@ -183,8 +183,8 @@ private:
struct AsyncRequest
{
- IceInternal::OutgoingAsyncPtr p;
- IceUtil::Time t;
+ IceInternal::OutgoingAsyncPtr p;
+ IceUtil::Time t;
};
std::map<Int, AsyncRequest> _asyncRequests;
std::map<Int, AsyncRequest>::iterator _asyncRequestsHint;
diff --git a/cpp/src/Ice/ConnectionMonitor.cpp b/cpp/src/Ice/ConnectionMonitor.cpp
index d67962fb9e9..3c9eee7845a 100644
--- a/cpp/src/Ice/ConnectionMonitor.cpp
+++ b/cpp/src/Ice/ConnectionMonitor.cpp
@@ -24,13 +24,13 @@ void
IceInternal::ConnectionMonitor::destroy()
{
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- assert(_instance);
- _instance = 0;
- _connections.clear();
-
- notify();
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ assert(_instance);
+ _instance = 0;
+ _connections.clear();
+
+ notify();
}
getThreadControl().join();
@@ -71,53 +71,53 @@ IceInternal::ConnectionMonitor::run()
{
while(true)
{
- set<ConnectionIPtr> connections;
-
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- if(_instance && !timedWait(_interval))
- {
- connections = _connections;
- }
+ set<ConnectionIPtr> connections;
+
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ if(_instance && !timedWait(_interval))
+ {
+ connections = _connections;
+ }
- if(!_instance)
- {
- return;
- }
- }
-
- //
- // Monitor connections outside the thread synchronization, so
- // that connections can be added or removed during monitoring.
- //
- for(set<ConnectionIPtr>::const_iterator p = connections.begin(); p != connections.end(); ++p)
- {
- try
- {
- (*p)->monitor();
- }
- catch(const Exception& ex)
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- if(!_instance)
- {
- return;
- }
+ if(!_instance)
+ {
+ return;
+ }
+ }
+
+ //
+ // Monitor connections outside the thread synchronization, so
+ // that connections can be added or removed during monitoring.
+ //
+ for(set<ConnectionIPtr>::const_iterator p = connections.begin(); p != connections.end(); ++p)
+ {
+ try
+ {
+ (*p)->monitor();
+ }
+ catch(const Exception& ex)
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ if(!_instance)
+ {
+ return;
+ }
- Error out(_instance->initializationData().logger);
- out << "exception in connection monitor:\n" << ex;
- }
- catch(...)
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- if(!_instance)
- {
- return;
- }
+ Error out(_instance->initializationData().logger);
+ out << "exception in connection monitor:\n" << ex;
+ }
+ catch(...)
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ if(!_instance)
+ {
+ return;
+ }
- Error out(_instance->initializationData().logger);
- out << "unknown exception in connection monitor";
- }
- }
+ Error out(_instance->initializationData().logger);
+ out << "unknown exception in connection monitor";
+ }
+ }
}
}
diff --git a/cpp/src/Ice/DLLMain.cpp b/cpp/src/Ice/DLLMain.cpp
index 55f94abae45..dab9d417bb4 100755
--- a/cpp/src/Ice/DLLMain.cpp
+++ b/cpp/src/Ice/DLLMain.cpp
@@ -34,7 +34,7 @@ ice_DLL_Main(HINSTANCE hDLL, DWORD reason, LPVOID reserved)
}
else if(reason == DLL_THREAD_DETACH)
{
- Ice::ImplicitContextI::cleanupThread();
+ Ice::ImplicitContextI::cleanupThread();
}
return TRUE;
diff --git a/cpp/src/Ice/DefaultsAndOverrides.cpp b/cpp/src/Ice/DefaultsAndOverrides.cpp
index 04f5508d903..64bcd99b63b 100644
--- a/cpp/src/Ice/DefaultsAndOverrides.cpp
+++ b/cpp/src/Ice/DefaultsAndOverrides.cpp
@@ -38,33 +38,33 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro
value = properties->getProperty("Ice.Override.Timeout");
if(!value.empty())
{
- const_cast<bool&>(overrideTimeout) = true;
- const_cast<Int&>(overrideTimeoutValue) = properties->getPropertyAsInt("Ice.Override.Timeout");
+ const_cast<bool&>(overrideTimeout) = true;
+ const_cast<Int&>(overrideTimeoutValue) = properties->getPropertyAsInt("Ice.Override.Timeout");
}
value = properties->getProperty("Ice.Override.ConnectTimeout");
if(!value.empty())
{
- const_cast<bool&>(overrideConnectTimeout) = true;
- const_cast<Int&>(overrideConnectTimeoutValue) = properties->getPropertyAsInt("Ice.Override.ConnectTimeout");
+ const_cast<bool&>(overrideConnectTimeout) = true;
+ const_cast<Int&>(overrideConnectTimeoutValue) = properties->getPropertyAsInt("Ice.Override.ConnectTimeout");
}
value = properties->getProperty("Ice.Override.Compress");
if(!value.empty())
{
- const_cast<bool&>(overrideCompress) = true;
- const_cast<bool&>(overrideCompressValue) = properties->getPropertyAsInt("Ice.Override.Compress");
+ const_cast<bool&>(overrideCompress) = true;
+ const_cast<bool&>(overrideCompressValue) = properties->getPropertyAsInt("Ice.Override.Compress");
}
value = properties->getProperty("Ice.Override.Secure");
if(!value.empty())
{
- const_cast<bool&>(overrideSecure) = true;
- const_cast<bool&>(overrideSecureValue) = properties->getPropertyAsInt("Ice.Override.Secure");
+ const_cast<bool&>(overrideSecure) = true;
+ const_cast<bool&>(overrideSecureValue) = properties->getPropertyAsInt("Ice.Override.Secure");
}
const_cast<bool&>(defaultCollocationOptimization) =
- properties->getPropertyAsIntWithDefault("Ice.Default.CollocationOptimization", 1) > 0;
+ properties->getPropertyAsIntWithDefault("Ice.Default.CollocationOptimization", 1) > 0;
value = properties->getPropertyWithDefault("Ice.Default.EndpointSelection", "Random");
if(value == "Random")
@@ -83,8 +83,8 @@ IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& pro
}
const_cast<int&>(defaultLocatorCacheTimeout) =
- properties->getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);
+ properties->getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);
const_cast<bool&>(defaultPreferSecure) =
- properties->getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0;
+ properties->getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0;
}
diff --git a/cpp/src/Ice/Direct.cpp b/cpp/src/Ice/Direct.cpp
index d27825ab907..b25c85fb9e1 100644
--- a/cpp/src/Ice/Direct.cpp
+++ b/cpp/src/Ice/Direct.cpp
@@ -39,55 +39,55 @@ IceInternal::Direct::Direct(const Current& current) :
try
{
- _servant = servantManager->findServant(_current.id, _current.facet);
- if(!_servant)
- {
- _locator = servantManager->findServantLocator(_current.id.category);
- if(!_locator && !_current.id.category.empty())
- {
- _locator = servantManager->findServantLocator("");
- }
- if(_locator)
- {
- _servant = _locator->locate(_current, _cookie);
- }
- }
- if(!_servant)
- {
- if(servantManager && servantManager->hasServant(_current.id))
- {
- FacetNotExistException ex(__FILE__, __LINE__);
- ex.id = _current.id;
- ex.facet = _current.facet;
- ex.operation = _current.operation;
- throw ex;
- }
- else
- {
- ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = _current.id;
- ex.facet = _current.facet;
- ex.operation = _current.operation;
- throw ex;
- }
- }
+ _servant = servantManager->findServant(_current.id, _current.facet);
+ if(!_servant)
+ {
+ _locator = servantManager->findServantLocator(_current.id.category);
+ if(!_locator && !_current.id.category.empty())
+ {
+ _locator = servantManager->findServantLocator("");
+ }
+ if(_locator)
+ {
+ _servant = _locator->locate(_current, _cookie);
+ }
+ }
+ if(!_servant)
+ {
+ if(servantManager && servantManager->hasServant(_current.id))
+ {
+ FacetNotExistException ex(__FILE__, __LINE__);
+ ex.id = _current.id;
+ ex.facet = _current.facet;
+ ex.operation = _current.operation;
+ throw ex;
+ }
+ else
+ {
+ ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = _current.id;
+ ex.facet = _current.facet;
+ ex.operation = _current.operation;
+ throw ex;
+ }
+ }
}
catch(...)
{
- if(_locator && _servant)
- {
- try
- {
- _locator->finished(_current, _servant, _cookie);
- }
- catch(...)
- {
- adapter->decDirectCount();
- throw;
- }
- }
- adapter->decDirectCount();
- throw;
+ if(_locator && _servant)
+ {
+ try
+ {
+ _locator->finished(_current, _servant, _cookie);
+ }
+ catch(...)
+ {
+ adapter->decDirectCount();
+ throw;
+ }
+ }
+ adapter->decDirectCount();
+ throw;
}
}
@@ -104,15 +104,15 @@ IceInternal::Direct::destroy()
if(_locator && _servant)
{
- try
- {
- _locator->finished(_current, _servant, _cookie);
- }
- catch(...)
- {
- adapter->decDirectCount();
- throw;
- }
+ try
+ {
+ _locator->finished(_current, _servant, _cookie);
+ }
+ catch(...)
+ {
+ adapter->decDirectCount();
+ throw;
+ }
}
adapter->decDirectCount();
diff --git a/cpp/src/Ice/DynamicLibrary.cpp b/cpp/src/Ice/DynamicLibrary.cpp
index d1b25c1a46c..769b0368b19 100644
--- a/cpp/src/Ice/DynamicLibrary.cpp
+++ b/cpp/src/Ice/DynamicLibrary.cpp
@@ -66,21 +66,21 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc
libName = libSpec;
if(useIceVersion)
{
- int majorVersion = (ICE_INT_VERSION / 10000);
- int minorVersion = (ICE_INT_VERSION / 100) - majorVersion * 100;
- ostringstream os;
- os << majorVersion * 10 + minorVersion;
+ int majorVersion = (ICE_INT_VERSION / 10000);
+ int minorVersion = (ICE_INT_VERSION / 100) - majorVersion * 100;
+ ostringstream os;
+ os << majorVersion * 10 + minorVersion;
- int patchVersion = ICE_INT_VERSION % 100;
- if(patchVersion > 50)
- {
- os << 'b';
- if(patchVersion >= 52)
- {
- os << (patchVersion - 50);
- }
- }
- version = os.str();
+ int patchVersion = ICE_INT_VERSION % 100;
+ if(patchVersion > 50)
+ {
+ os << 'b';
+ if(patchVersion >= 52)
+ {
+ os << (patchVersion - 50);
+ }
+ }
+ version = os.str();
}
}
else
@@ -101,7 +101,7 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc
lib = "lib" + libName;
if(!version.empty())
{
- lib += "." + version;
+ lib += "." + version;
}
lib += ".dylib";
#elif defined(__hpux)
@@ -112,7 +112,7 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc
}
else
{
- lib += ".sl";
+ lib += ".sl";
}
#elif defined(_AIX)
lib = "lib" + libName + ".a(lib" + libName + ".so";
diff --git a/cpp/src/Ice/EndpointFactoryManager.cpp b/cpp/src/Ice/EndpointFactoryManager.cpp
index bb8a784e9ab..25db4169e20 100644
--- a/cpp/src/Ice/EndpointFactoryManager.cpp
+++ b/cpp/src/Ice/EndpointFactoryManager.cpp
@@ -75,8 +75,8 @@ IceInternal::EndpointFactoryManager::create(const string& str) const
if(beg == string::npos)
{
EndpointParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
+ ex.str = str;
+ throw ex;
}
string::size_type end = str.find_first_of(delim, beg);
diff --git a/cpp/src/Ice/EventLoggerI.cpp b/cpp/src/Ice/EventLoggerI.cpp
index a61325f1463..c626e62c83f 100755
--- a/cpp/src/Ice/EventLoggerI.cpp
+++ b/cpp/src/Ice/EventLoggerI.cpp
@@ -70,7 +70,7 @@ Ice::EventLoggerI::EventLoggerI(const string& appName) :
// "EventMessageFile" key should contain the path to this DLL.
//
err = RegSetValueEx(hKey, "EventMessageFile", 0, REG_EXPAND_SZ,
- (unsigned char*)path, static_cast<DWORD>(strlen(path) + 1));
+ (unsigned char*)path, static_cast<DWORD>(strlen(path) + 1));
if(err != ERROR_SUCCESS)
{
RegCloseKey(hKey);
diff --git a/cpp/src/Ice/Exception.cpp b/cpp/src/Ice/Exception.cpp
index d43712b6658..3141a604d3e 100644
--- a/cpp/src/Ice/Exception.cpp
+++ b/cpp/src/Ice/Exception.cpp
@@ -56,7 +56,7 @@ Ice::InitializationException::ice_print(ostream& out) const
out << ":\ninitialization exception";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -67,7 +67,7 @@ Ice::UnknownException::ice_print(ostream& out) const
out << ":\nunknown exception";
if(!unknown.empty())
{
- out << ":\n" << unknown;
+ out << ":\n" << unknown;
}
}
@@ -78,7 +78,7 @@ Ice::UnknownLocalException::ice_print(ostream& out) const
out << ":\nunknown local exception";
if(!unknown.empty())
{
- out << ":\n" << unknown;
+ out << ":\n" << unknown;
}
}
@@ -89,7 +89,7 @@ Ice::UnknownUserException::ice_print(ostream& out) const
out << ":\nunknown user exception";
if(!unknown.empty())
{
- out << ":\n" << unknown;
+ out << ":\n" << unknown;
}
}
@@ -238,11 +238,11 @@ Ice::SocketException::ice_print(ostream& out) const
out << ":\nsocket exception: ";
if(error == 0)
{
- out << "unknown error";
+ out << "unknown error";
}
else
{
- out << errorToString(error);
+ out << errorToString(error);
}
}
@@ -253,7 +253,7 @@ Ice::FileException::ice_print(ostream& out) const
out << ":\nfile exception: " << errorToString(error);
if(!path.empty())
{
- out << "\npath: " << path;
+ out << "\npath: " << path;
}
}
@@ -278,11 +278,11 @@ Ice::ConnectionLostException::ice_print(ostream& out) const
out << ":\nconnection lost: ";
if(error == 0)
{
- out << "recv() returned zero";
+ out << "recv() returned zero";
}
else
{
- out << errorToString(error);
+ out << errorToString(error);
}
}
@@ -328,7 +328,7 @@ Ice::ProtocolException::ice_print(ostream& out) const
out << ":\nprotocol exception";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -338,23 +338,23 @@ Ice::BadMagicException::ice_print(ostream& out) const
Exception::ice_print(out);
out << ":\nunknown magic number: ";
- ios_base::fmtflags originalFlags = out.flags(); // Save stream state
+ ios_base::fmtflags originalFlags = out.flags(); // Save stream state
ostream::char_type originalFill = out.fill();
- out.flags(ios_base::hex); // Change to hex
- out.fill('0'); // Fill with leading zeros
+ out.flags(ios_base::hex); // Change to hex
+ out.fill('0'); // Fill with leading zeros
out << "0x" << setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(badMagic[0])) << ", ";
out << "0x" << setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(badMagic[1])) << ", ";
out << "0x" << setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(badMagic[2])) << ", ";
out << "0x" << setw(2) << static_cast<unsigned int>(static_cast<unsigned char>(badMagic[3]));
- out.fill(originalFill); // Restore stream state
+ out.fill(originalFill); // Restore stream state
out.flags(originalFlags);
if(!reason.empty())
{
- out << "\n" << reason;
+ out << "\n" << reason;
}
}
@@ -374,7 +374,7 @@ Ice::UnsupportedEncodingException::ice_print(ostream& out) const
out << "\n(can only support encodings compatible with version " << major << "." << major << ")";
if(!reason.empty())
{
- out << "\n" << reason;
+ out << "\n" << reason;
}
}
@@ -385,7 +385,7 @@ Ice::UnknownMessageException::ice_print(ostream& out) const
out << ":\nprotocol error: unknown message type";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -396,7 +396,7 @@ Ice::ConnectionNotValidatedException::ice_print(ostream& out) const
out << ":\nprotocol error: received message over unvalidated connection";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -407,7 +407,7 @@ Ice::UnknownRequestIdException::ice_print(ostream& out) const
out << ":\nprotocol error: unknown request id";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -418,7 +418,7 @@ Ice::UnknownReplyStatusException::ice_print(ostream& out) const
out << ":\nprotocol error: unknown reply status";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -429,7 +429,7 @@ Ice::CloseConnectionException::ice_print(ostream& out) const
out << ":\nprotocol error: connection closed";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -440,7 +440,7 @@ Ice::ForcedCloseConnectionException::ice_print(ostream& out) const
out << ":\nprotocol error: connection forcefully closed";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -451,7 +451,7 @@ Ice::IllegalMessageSizeException::ice_print(ostream& out) const
out << ":\nprotocol error: illegal message size";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -462,7 +462,7 @@ Ice::CompressionException::ice_print(ostream& out) const
out << ":\nprotocol error: failed to compress or uncompress data";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -473,7 +473,7 @@ Ice::DatagramLimitException::ice_print(ostream& out) const
out << ":\nprotocol error: maximum datagram payload size exceeded";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -484,7 +484,7 @@ Ice::MarshalException::ice_print(ostream& out) const
out << ":\nprotocol error: error during marshaling or unmarshaling";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -495,7 +495,7 @@ Ice::ProxyUnmarshalException::ice_print(ostream& out) const
out << ":\nprotocol error: inconsistent proxy data during unmarshaling";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -506,7 +506,7 @@ Ice::UnmarshalOutOfBoundsException::ice_print(ostream& out) const
out << ":\nprotocol error: out of bounds during unmarshaling";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -517,7 +517,7 @@ Ice::IllegalIndirectionException::ice_print(ostream& out) const
out << ":\nprotocol error: encountered illegal protocol indirection";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -528,21 +528,21 @@ Ice::NoObjectFactoryException::ice_print(ostream& out) const
out << ":\nprotocol error: no suitable object factory found for `" << type << "'";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
-}
+}
void
Ice::UnexpectedObjectException::ice_print(ostream& out) const
{
Exception::ice_print(out);
out << ":\nunexpected class instance of type `" << type <<
- "'; expected instance of type `" << expectedType << "'";
+ "'; expected instance of type `" << expectedType << "'";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
-}
+}
void
Ice::MemoryLimitException::ice_print(ostream& out) const
@@ -551,7 +551,7 @@ Ice::MemoryLimitException::ice_print(ostream& out) const
out << ":\nprotocol error: memory limit exceeded";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -562,7 +562,7 @@ Ice::StringConversionException::ice_print(ostream& out) const
out << ":\nprotocol error: string conversion failed";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -573,7 +573,7 @@ Ice::EncapsulationException::ice_print(ostream& out) const
out << ":\nprotocol error: illegal encapsulation";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -584,7 +584,7 @@ Ice::NegativeSizeException::ice_print(ostream& out) const
out << ":\nprotocol error: negative size for sequence, dictionary, etc.";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
@@ -656,7 +656,7 @@ Ice::SecurityException::ice_print(ostream& out) const
out << ":\nsecurity exception";
if(!reason.empty())
{
- out << ":\n" << reason;
+ out << ":\n" << reason;
}
}
diff --git a/cpp/src/Ice/FactoryTableDef.cpp b/cpp/src/Ice/FactoryTableDef.cpp
index e31a7fd0a7e..9241c8da8d6 100644
--- a/cpp/src/Ice/FactoryTableDef.cpp
+++ b/cpp/src/Ice/FactoryTableDef.cpp
@@ -17,11 +17,11 @@
namespace IceInternal
{
-FactoryTableWrapper factoryTableWrapper; // Single global instance of the wrapper object that
- // initializes factoryTable.
+FactoryTableWrapper factoryTableWrapper; // Single global instance of the wrapper object that
+ // initializes factoryTable.
-ICE_API FactoryTableDef* factoryTable; // Single global instance of the factory table for
- // non-local exceptions and non-abstract classes
+ICE_API FactoryTableDef* factoryTable; // Single global instance of the factory table for
+ // non-local exceptions and non-abstract classes
}
//
@@ -35,11 +35,11 @@ IceInternal::FactoryTableDef::addExceptionFactory(const std::string& t, const Ic
EFTable::iterator i = _eft.find(t);
if(i == _eft.end())
{
- _eft[t] = EFPair(f, 1);
+ _eft[t] = EFPair(f, 1);
}
else
{
- i->second.second++;
+ i->second.second++;
}
}
@@ -54,23 +54,23 @@ IceInternal::FactoryTableDef::getExceptionFactory(const std::string& t) const
#ifdef __APPLE__
if(i == _eft.end())
{
- lock.release();
-
- //
- // Try to find the symbol, if found this should trigger the
- // object static constructors to be called.
- //
- std::string symbol = "__F";
- for(std::string::const_iterator p = t.begin(); p != t.end(); ++p)
- {
- symbol += ((*p) == ':') ? '_' : *p;
- }
- symbol += "__initializer";
- dlsym(RTLD_DEFAULT, symbol.c_str());
-
- lock.acquire();
-
- i = _eft.find(t);
+ lock.release();
+
+ //
+ // Try to find the symbol, if found this should trigger the
+ // object static constructors to be called.
+ //
+ std::string symbol = "__F";
+ for(std::string::const_iterator p = t.begin(); p != t.end(); ++p)
+ {
+ symbol += ((*p) == ':') ? '_' : *p;
+ }
+ symbol += "__initializer";
+ dlsym(RTLD_DEFAULT, symbol.c_str());
+
+ lock.acquire();
+
+ i = _eft.find(t);
}
#endif
return i != _eft.end() ? i->second.first : IceInternal::UserExceptionFactoryPtr();
@@ -89,10 +89,10 @@ IceInternal::FactoryTableDef::removeExceptionFactory(const std::string& t)
EFTable::iterator i = _eft.find(t);
if(i != _eft.end())
{
- if(--i->second.second == 0)
- {
- _eft.erase(i);
- }
+ if(--i->second.second == 0)
+ {
+ _eft.erase(i);
+ }
}
}
@@ -106,11 +106,11 @@ IceInternal::FactoryTableDef::addObjectFactory(const std::string& t, const Ice::
OFTable::iterator i = _oft.find(t);
if(i == _oft.end())
{
- _oft[t] = OFPair(f, 1);
+ _oft[t] = OFPair(f, 1);
}
else
{
- i->second.second++;
+ i->second.second++;
}
}
@@ -125,23 +125,23 @@ IceInternal::FactoryTableDef::getObjectFactory(const std::string& t) const
#ifdef __APPLE__
if(i == _oft.end())
{
- lock.release();
-
- //
- // Try to find the symbol, if found this should trigger the
- // object static constructors to be called.
- //
- std::string symbol = "__F";
- for(std::string::const_iterator p = t.begin(); p != t.end(); ++p)
- {
- symbol += ((*p) == ':') ? '_' : *p;
- }
- symbol += "__initializer";
- dlsym(RTLD_DEFAULT, symbol.c_str());
-
- lock.acquire();
-
- i = _oft.find(t);
+ lock.release();
+
+ //
+ // Try to find the symbol, if found this should trigger the
+ // object static constructors to be called.
+ //
+ std::string symbol = "__F";
+ for(std::string::const_iterator p = t.begin(); p != t.end(); ++p)
+ {
+ symbol += ((*p) == ':') ? '_' : *p;
+ }
+ symbol += "__initializer";
+ dlsym(RTLD_DEFAULT, symbol.c_str());
+
+ lock.acquire();
+
+ i = _oft.find(t);
}
#endif
return i != _oft.end() ? i->second.first : Ice::ObjectFactoryPtr();
@@ -160,10 +160,10 @@ IceInternal::FactoryTableDef::removeObjectFactory(const std::string& t)
OFTable::iterator i = _oft.find(t);
if(i != _oft.end())
{
- if(--i->second.second == 0)
- {
- _oft.erase(i);
- }
+ if(--i->second.second == 0)
+ {
+ _oft.erase(i);
+ }
}
}
@@ -193,7 +193,7 @@ IceInternal::FactoryTableWrapper::initialize()
IceUtil::StaticMutex::Lock lock(_m);
if(_initCount == 0)
{
- factoryTable = new FactoryTableDef;
+ factoryTable = new FactoryTableDef;
}
++_initCount;
}
@@ -207,9 +207,9 @@ IceInternal::FactoryTableWrapper::finalize()
IceUtil::StaticMutex::Lock lock(_m);
if(--_initCount == 0)
{
- delete factoryTable;
+ delete factoryTable;
}
}
IceUtil::StaticMutex IceInternal::FactoryTableWrapper::_m = ICE_STATIC_MUTEX_INITIALIZER;
-int IceInternal::FactoryTableWrapper::_initCount = 0; // Initialization count
+int IceInternal::FactoryTableWrapper::_initCount = 0; // Initialization count
diff --git a/cpp/src/Ice/GC.cpp b/cpp/src/Ice/GC.cpp
index 432a34a7469..605997439a5 100755
--- a/cpp/src/Ice/GC.cpp
+++ b/cpp/src/Ice/GC.cpp
@@ -35,14 +35,14 @@ recursivelyReachable(GCShared* p, GCObjectSet& o)
{
if(o.find(p) == o.end())
{
- assert(p);
- o.insert(p);
- GCCountMap tmp;
- p->__gcReachable(tmp);
- for(GCCountMap::const_iterator i = tmp.begin(); i != tmp.end(); ++i)
- {
- recursivelyReachable(i->first, o);
- }
+ assert(p);
+ o.insert(p);
+ GCCountMap tmp;
+ p->__gcReachable(tmp);
+ for(GCCountMap::const_iterator i = tmp.begin(); i != tmp.end(); ++i)
+ {
+ recursivelyReachable(i->first, o);
+ }
}
}
@@ -82,13 +82,13 @@ IceInternal::GCShared::__decRef()
assert(_ref > 0);
if(--_ref == 0)
{
- doDelete = !_noDelete;
- _noDelete = true;
+ doDelete = !_noDelete;
+ _noDelete = true;
}
lock.release();
if(doDelete)
{
- delete this;
+ delete this;
}
}
@@ -114,10 +114,10 @@ IceInternal::GCShared::__gcIncRef()
if(_ref == 0)
{
#ifdef NDEBUG // To avoid annoying warnings about variables that are not used...
- gcObjects.insert(this);
+ gcObjects.insert(this);
#else
- std::pair<GCObjectSet::iterator, bool> rc = gcObjects.insert(this);
- assert(rc.second);
+ std::pair<GCObjectSet::iterator, bool> rc = gcObjects.insert(this);
+ assert(rc.second);
#endif
}
++_ref;
@@ -131,19 +131,19 @@ IceInternal::GCShared::__gcDecRef()
assert(_ref > 0);
if(--_ref == 0)
{
- doDelete = !_noDelete;
- _noDelete = true;
+ doDelete = !_noDelete;
+ _noDelete = true;
#ifdef NDEBUG // To avoid annoying warnings about variables that are not used...
- gcObjects.erase(this);
+ gcObjects.erase(this);
#else
- GCObjectSet::size_type num = gcObjects.erase(this);
- assert(num == 1);
+ GCObjectSet::size_type num = gcObjects.erase(this);
+ assert(num == 1);
#endif
}
lock.release();
if(doDelete)
{
- delete this;
+ delete this;
}
}
@@ -158,7 +158,7 @@ IceInternal::GC::GC(int interval, StatsCallback cb)
StaticMutex::Lock sync(numCollectorsMutex);
if(numCollectors++ > 0)
{
- abort(); // Enforce singleton.
+ abort(); // Enforce singleton.
}
_state = NotStarted;
@@ -179,33 +179,33 @@ IceInternal::GC::run()
assert(_interval > 0);
{
- Monitor<Mutex>::Lock sync(*this);
+ Monitor<Mutex>::Lock sync(*this);
- _state = Started;
- notify();
+ _state = Started;
+ notify();
}
Time waitTime = Time::seconds(_interval);
while(true)
{
- bool collect = false;
- {
- Monitor<Mutex>::Lock sync(*this);
-
- if(_state == Stopping)
- {
- _state = Stopped;
- return;
- }
- if(!timedWait(waitTime))
- {
- collect = true;
- }
- }
- if(collect)
- {
- collectGarbage();
- }
+ bool collect = false;
+ {
+ Monitor<Mutex>::Lock sync(*this);
+
+ if(_state == Stopping)
+ {
+ _state = Stopped;
+ return;
+ }
+ if(!timedWait(waitTime))
+ {
+ collect = true;
+ }
+ }
+ if(collect)
+ {
+ collectGarbage();
+ }
}
}
@@ -213,32 +213,32 @@ void
IceInternal::GC::stop()
{
{
- Monitor<Mutex>::Lock sync(*this);
-
- if(_state >= Stopping)
- {
- return; // Don't attempt to stop the thread twice.
- }
-
- //
- // Wait until the thread is actually started. (If we don't do this, we
- // can get a problem if a call to stop() immediately follows a call to start():
- // the call to stop() may happen before pthread_create() has scheduled the thread's run()
- // function, and then the notify() that is used to tell the thread to stop can be lost.
- //
- while(_state < Started)
- {
- wait();
- }
+ Monitor<Mutex>::Lock sync(*this);
+
+ if(_state >= Stopping)
+ {
+ return; // Don't attempt to stop the thread twice.
+ }
+
+ //
+ // Wait until the thread is actually started. (If we don't do this, we
+ // can get a problem if a call to stop() immediately follows a call to start():
+ // the call to stop() may happen before pthread_create() has scheduled the thread's run()
+ // function, and then the notify() that is used to tell the thread to stop can be lost.
+ //
+ while(_state < Started)
+ {
+ wait();
+ }
}
//
// Tell the thread to stop.
//
{
- Monitor<Mutex>::Lock sync(*this);
- _state = Stopping;
- notify();
+ Monitor<Mutex>::Lock sync(*this);
+ _state = Stopping;
+ notify();
}
getThreadControl().join();
@@ -252,13 +252,13 @@ IceInternal::GC::collectGarbage()
// Do nothing if the collector is running already.
//
{
- Monitor<Mutex>::Lock sync(*this);
+ Monitor<Mutex>::Lock sync(*this);
- if(_collecting)
- {
- return;
- }
- _collecting = true;
+ if(_collecting)
+ {
+ return;
+ }
+ _collecting = true;
}
RecMutex::Lock sync(gcRecMutex); // Prevent any further class reference count activity.
@@ -268,108 +268,108 @@ IceInternal::GC::collectGarbage()
if(_statsCallback)
{
- t = Time::now();
- stats.examined = static_cast<int>(gcObjects.size());
+ t = Time::now();
+ stats.examined = static_cast<int>(gcObjects.size());
}
GCCountMap counts;
{
- //
- // gcObjects contains the set of class instances that have at least one member of class type,
- // that is, gcObjects contains all those instances that can point at other instances.
- //
- // Create a map that, for each object in gcObjects, contains an <object, refcount> pair.
- // In addition, for each object in gcObjects, add the objects that are immediately (not
- // recursively) reachable from that object to a reachable map that counts how many times
- // the object is pointed at.
- //
- GCCountMap reachable;
- {
- for(GCObjectSet::const_iterator i = gcObjects.begin(); i != gcObjects.end(); ++i)
- {
- counts.insert(GCCountMap::value_type(*i, (*i)->__getRefUnsafe()));
- (*i)->__gcReachable(reachable);
- }
- }
-
- //
- // Decrement the reference count for each object in the counts map by the count in the reachable
- // map. This drops the reference count of each object in the counts map by the number of times that
- // the object is pointed at by other objects in the counts map.
//
- {
- for(GCCountMap::const_iterator i = reachable.begin(); i != reachable.end(); ++i)
- {
- GCCountMap::iterator pos = counts.find(i->first);
- assert(pos != counts.end());
- pos->second -= i->second;
- }
- }
+ // gcObjects contains the set of class instances that have at least one member of class type,
+ // that is, gcObjects contains all those instances that can point at other instances.
+ //
+ // Create a map that, for each object in gcObjects, contains an <object, refcount> pair.
+ // In addition, for each object in gcObjects, add the objects that are immediately (not
+ // recursively) reachable from that object to a reachable map that counts how many times
+ // the object is pointed at.
+ //
+ GCCountMap reachable;
+ {
+ for(GCObjectSet::const_iterator i = gcObjects.begin(); i != gcObjects.end(); ++i)
+ {
+ counts.insert(GCCountMap::value_type(*i, (*i)->__getRefUnsafe()));
+ (*i)->__gcReachable(reachable);
+ }
+ }
+
+ //
+ // Decrement the reference count for each object in the counts map by the count in the reachable
+ // map. This drops the reference count of each object in the counts map by the number of times that
+ // the object is pointed at by other objects in the counts map.
+ //
+ {
+ for(GCCountMap::const_iterator i = reachable.begin(); i != reachable.end(); ++i)
+ {
+ GCCountMap::iterator pos = counts.find(i->first);
+ assert(pos != counts.end());
+ pos->second -= i->second;
+ }
+ }
}
{
- //
- // Any instances in the counts map with a ref count > 0 are referenced from outside the objects in
- // gcObjects (and are therefore reachable from the program, for example, via Ptr variable on the stack).
- // The set of live objects therefore are all the objects with a reference count > 0, as well as all
- // objects that are (recursively) reachable from these objects.
- //
- GCObjectSet liveObjects;
- {
- for(GCCountMap::const_iterator i = counts.begin(); i != counts.end(); ++i)
- {
- if(i->second > 0)
- {
- recursivelyReachable(i->first, liveObjects);
- }
- }
- }
-
- //
- // Remove all live objects from the counts map.
- //
- {
- for(GCObjectSet::const_iterator i = liveObjects.begin(); i != liveObjects.end(); ++i)
- {
+ //
+ // Any instances in the counts map with a ref count > 0 are referenced from outside the objects in
+ // gcObjects (and are therefore reachable from the program, for example, via Ptr variable on the stack).
+ // The set of live objects therefore are all the objects with a reference count > 0, as well as all
+ // objects that are (recursively) reachable from these objects.
+ //
+ GCObjectSet liveObjects;
+ {
+ for(GCCountMap::const_iterator i = counts.begin(); i != counts.end(); ++i)
+ {
+ if(i->second > 0)
+ {
+ recursivelyReachable(i->first, liveObjects);
+ }
+ }
+ }
+
+ //
+ // Remove all live objects from the counts map.
+ //
+ {
+ for(GCObjectSet::const_iterator i = liveObjects.begin(); i != liveObjects.end(); ++i)
+ {
#ifndef NDEBUG
- size_t erased =
+ size_t erased =
#endif
- counts.erase(*i);
- assert(erased != 0);
- }
- }
+ counts.erase(*i);
+ assert(erased != 0);
+ }
+ }
}
//
// What is left in the counts map can be garbage collected.
//
{
- GCCountMap::const_iterator i;
- for(i = counts.begin(); i != counts.end(); ++i)
- {
- //
- // For classes with members that point at potentially-cyclic instances, __gcClear()
- // decrements the reference count of the pointed-at instances as many times as they are
- // pointed at and clears the corresponding Ptr members in the pointing class.
- // For classes that cannot be part of a cycle (because they do not contain class members)
- // and are therefore true leaves, __gcClear() assigns 0 to the corresponding class member,
- // which either decrements the ref count or, if it reaches zero, deletes the instance as usual.
- //
- i->first->__gcClear();
- }
- for(i = counts.begin(); i != counts.end(); ++i)
- {
- gcObjects.erase(i->first); // Remove this object from candidate set.
- delete i->first; // Delete this object.
- }
+ GCCountMap::const_iterator i;
+ for(i = counts.begin(); i != counts.end(); ++i)
+ {
+ //
+ // For classes with members that point at potentially-cyclic instances, __gcClear()
+ // decrements the reference count of the pointed-at instances as many times as they are
+ // pointed at and clears the corresponding Ptr members in the pointing class.
+ // For classes that cannot be part of a cycle (because they do not contain class members)
+ // and are therefore true leaves, __gcClear() assigns 0 to the corresponding class member,
+ // which either decrements the ref count or, if it reaches zero, deletes the instance as usual.
+ //
+ i->first->__gcClear();
+ }
+ for(i = counts.begin(); i != counts.end(); ++i)
+ {
+ gcObjects.erase(i->first); // Remove this object from candidate set.
+ delete i->first; // Delete this object.
+ }
}
if(_statsCallback)
{
- stats.time = Time::now() - t;
- stats.collected = static_cast<int>(counts.size());
- _statsCallback(stats);
+ stats.time = Time::now() - t;
+ stats.collected = static_cast<int>(counts.size());
+ _statsCallback(stats);
}
//
@@ -381,8 +381,8 @@ IceInternal::GC::collectGarbage()
counts.clear();
{
- Monitor<Mutex>::Lock sync(*this);
+ Monitor<Mutex>::Lock sync(*this);
- _collecting = false;
+ _collecting = false;
}
}
diff --git a/cpp/src/Ice/IdentityUtil.cpp b/cpp/src/Ice/IdentityUtil.cpp
index 8b078b0e96c..4758804b4fb 100644
--- a/cpp/src/Ice/IdentityUtil.cpp
+++ b/cpp/src/Ice/IdentityUtil.cpp
@@ -81,10 +81,10 @@ Ice::identityToString(const Identity& ident)
{
if(ident.category.empty())
{
- return IceUtil::escapeString(ident.name, "/");
+ return IceUtil::escapeString(ident.name, "/");
}
else
{
- return IceUtil::escapeString(ident.category, "/") + '/' + IceUtil::escapeString(ident.name, "/");
+ return IceUtil::escapeString(ident.category, "/") + '/' + IceUtil::escapeString(ident.name, "/");
}
}
diff --git a/cpp/src/Ice/ImplicitContextI.cpp b/cpp/src/Ice/ImplicitContextI.cpp
index ab78a011dab..7dd27c0fada 100644
--- a/cpp/src/Ice/ImplicitContextI.cpp
+++ b/cpp/src/Ice/ImplicitContextI.cpp
@@ -80,14 +80,14 @@ public:
struct Slot
{
- Slot() :
- context(0),
- owner(-1) // just to avoid UMR; a random value would work as well
- {
- }
-
- Context* context;
- long owner;
+ Slot() :
+ context(0),
+ owner(-1) // just to avoid UMR; a random value would work as well
+ {
+ }
+
+ Context* context;
+ long owner;
};
@@ -129,25 +129,25 @@ ImplicitContextI::create(const std::string& kind)
{
if(kind == "None" || kind == "")
{
- return 0;
+ return 0;
}
else if(kind == "Shared")
{
- return new SharedImplicitContext;
+ return new SharedImplicitContext;
}
else if(kind == "SharedWithoutLocking")
{
- return new SharedImplicitContextWithoutLocking;
+ return new SharedImplicitContextWithoutLocking;
}
else if(kind == "PerThread")
{
- return new PerThreadImplicitContext;
+ return new PerThreadImplicitContext;
}
else
{
- throw Ice::InitializationException(
- __FILE__, __LINE__,
- "'" + kind + "' is not a valid value for Ice.ImplicitContext");
+ throw Ice::InitializationException(
+ __FILE__, __LINE__,
+ "'" + kind + "' is not a valid value for Ice.ImplicitContext");
return 0; // Keep the compiler happy.
}
}
@@ -158,8 +158,8 @@ ImplicitContextI::cleanupThread()
{
if(PerThreadImplicitContext::_nextId > 0)
{
- PerThreadImplicitContext::threadDestructor(
- TlsGetValue(PerThreadImplicitContext::_key));
+ PerThreadImplicitContext::threadDestructor(
+ TlsGetValue(PerThreadImplicitContext::_key));
}
}
#endif
@@ -186,7 +186,7 @@ SharedImplicitContextWithoutLocking::get(const string& k) const
Context::const_iterator p = _context.find(k);
if(p == _context.end())
{
- throw NotSetException(__FILE__, __LINE__, k);
+ throw NotSetException(__FILE__, __LINE__, k);
}
return p->second;
}
@@ -197,7 +197,7 @@ SharedImplicitContextWithoutLocking::getWithDefault(const string& k, const strin
Context::const_iterator p = _context.find(k);
if(p == _context.end())
{
- return d;
+ return d;
}
return p->second;
}
@@ -213,7 +213,7 @@ SharedImplicitContextWithoutLocking::remove(const string& k)
{
if(_context.erase(k) == 0)
{
- throw NotSetException(__FILE__, __LINE__, k);
+ throw NotSetException(__FILE__, __LINE__, k);
}
}
@@ -222,17 +222,17 @@ SharedImplicitContextWithoutLocking::write(const Context& proxyCtx, ::IceInterna
{
if(proxyCtx.size() == 0)
{
- __write(s, _context, __U__Context());
+ __write(s, _context, __U__Context());
}
else if(_context.size() == 0)
{
- __write(s, proxyCtx, __U__Context());
+ __write(s, proxyCtx, __U__Context());
}
else
{
- Context combined = proxyCtx;
- combined.insert(_context.begin(), _context.end());
- __write(s, combined, __U__Context());
+ Context combined = proxyCtx;
+ combined.insert(_context.begin(), _context.end());
+ __write(s, combined, __U__Context());
}
}
@@ -241,16 +241,16 @@ SharedImplicitContextWithoutLocking::combine(const Context& proxyCtx, Context& c
{
if(proxyCtx.size() == 0)
{
- ctx = _context;
+ ctx = _context;
}
else if(_context.size() == 0)
{
- ctx = proxyCtx;
+ ctx = proxyCtx;
}
else
{
- ctx = proxyCtx;
- ctx.insert(_context.begin(), _context.end());
+ ctx = proxyCtx;
+ ctx.insert(_context.begin(), _context.end());
}
}
@@ -307,19 +307,19 @@ SharedImplicitContext::write(const Context& proxyCtx, ::IceInternal::BasicStream
IceUtil::Mutex::Lock lock(_mutex);
if(proxyCtx.size() == 0)
{
- __write(s, _context, __U__Context());
+ __write(s, _context, __U__Context());
}
else if(_context.size() == 0)
{
- lock.release();
- __write(s, proxyCtx, __U__Context());
+ lock.release();
+ __write(s, proxyCtx, __U__Context());
}
else
{
- Context combined = proxyCtx;
- combined.insert(_context.begin(), _context.end());
- lock.release();
- __write(s, combined, __U__Context());
+ Context combined = proxyCtx;
+ combined.insert(_context.begin(), _context.end());
+ lock.release();
+ __write(s, combined, __U__Context());
}
}
@@ -350,22 +350,22 @@ PerThreadImplicitContext::PerThreadImplicitContext()
_id = _nextId++;
if(_id == 0)
{
- //
- // Initialize; note that we never dealloc this key (it would be
- // complex, and since it's a static variable, it's not really a leak)
- //
+ //
+ // Initialize; note that we never dealloc this key (it would be
+ // complex, and since it's a static variable, it's not really a leak)
+ //
#ifdef _WIN32
- _key = TlsAlloc();
- if(_key == TLS_OUT_OF_INDEXES)
- {
- throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, GetLastError());
- }
+ _key = TlsAlloc();
+ if(_key == TLS_OUT_OF_INDEXES)
+ {
+ throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ }
#else
- int err = pthread_key_create(&_key, &threadDestructor);
- if(err != 0)
- {
- throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, err);
- }
+ int err = pthread_key_create(&_key, &threadDestructor);
+ if(err != 0)
+ {
+ throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, err);
+ }
#endif
}
@@ -374,17 +374,17 @@ PerThreadImplicitContext::PerThreadImplicitContext()
//
if(_indexInUse == 0)
{
- _indexInUse = new IndexInUse(1);
+ _indexInUse = new IndexInUse(1);
}
size_t i = 0;
while(i < _indexInUse->size() && (*_indexInUse)[i])
{
- i++;
+ i++;
}
if(i == _indexInUse->size())
{
- _indexInUse->resize(i + 1);
+ _indexInUse->resize(i + 1);
}
(*_indexInUse)[i] = true;
_index = i;
@@ -397,8 +397,8 @@ PerThreadImplicitContext::~PerThreadImplicitContext()
if(find(_indexInUse->begin(), _indexInUse->end(), true) == _indexInUse->end())
{
- delete _indexInUse;
- _indexInUse = 0;
+ delete _indexInUse;
+ _indexInUse = 0;
}
}
@@ -408,17 +408,17 @@ PerThreadImplicitContext::threadDestructor(void* v)
SlotVector* sv = static_cast<SlotVector*>(v);
if(sv != 0)
{
- //
- // Cleanup each slot
- //
- for(SlotVector::iterator p = sv->begin(); p != sv->end(); ++p)
- {
- delete p->context;
- }
- //
- // Then the vector
- //
- delete sv;
+ //
+ // Cleanup each slot
+ //
+ for(SlotVector::iterator p = sv->begin(); p != sv->end(); ++p)
+ {
+ delete p->context;
+ }
+ //
+ // Then the vector
+ //
+ delete sv;
}
}
@@ -432,65 +432,65 @@ PerThreadImplicitContext::getThreadContext(bool allocate) const
#endif
if(sv == 0)
{
- if(!allocate)
- {
- return 0;
- }
+ if(!allocate)
+ {
+ return 0;
+ }
- sv = new SlotVector(_index + 1);
+ sv = new SlotVector(_index + 1);
#ifdef _WIN32
- if(TlsSetValue(_key, sv) == 0)
- {
- throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, GetLastError());
- }
+ if(TlsSetValue(_key, sv) == 0)
+ {
+ throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ }
#else
- if(int err = pthread_setspecific(_key, sv))
- {
- throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, err);
- }
+ if(int err = pthread_setspecific(_key, sv))
+ {
+ throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, err);
+ }
#endif
}
else
{
- if(sv->size() <= _index)
- {
- if(!allocate)
- {
- return 0;
- }
- else
- {
- sv->resize(_index + 1);
- }
- }
+ if(sv->size() <= _index)
+ {
+ if(!allocate)
+ {
+ return 0;
+ }
+ else
+ {
+ sv->resize(_index + 1);
+ }
+ }
}
Slot& slot = (*sv)[_index];
if(slot.context != 0)
{
- if(slot.owner != _id)
- {
- //
- // Reuse the slot from another (dead) communicator
- //
- slot.context->clear();
- slot.owner = _id;
- }
- //
- // else keep this slot.context
- //
+ if(slot.owner != _id)
+ {
+ //
+ // Reuse the slot from another (dead) communicator
+ //
+ slot.context->clear();
+ slot.owner = _id;
+ }
+ //
+ // else keep this slot.context
+ //
}
else
{
- if(allocate)
- {
- slot.context = new Context;
- slot.owner = _id;
- }
- //
- // else keep null slot.context
- //
+ if(allocate)
+ {
+ slot.context = new Context;
+ slot.owner = _id;
+ }
+ //
+ // else keep null slot.context
+ //
}
return slot.context;
}
@@ -505,33 +505,33 @@ PerThreadImplicitContext::clearThreadContext() const
#endif
if(sv != 0 && _index < sv->size())
{
- delete (*sv)[_index].context;
- (*sv)[_index].context = 0;
-
- int i = sv->size() - 1;
- while(i >= 0 && (*sv)[i].context == 0)
- {
- i--;
- }
- if(i < 0)
- {
- delete sv;
+ delete (*sv)[_index].context;
+ (*sv)[_index].context = 0;
+
+ int i = sv->size() - 1;
+ while(i >= 0 && (*sv)[i].context == 0)
+ {
+ i--;
+ }
+ if(i < 0)
+ {
+ delete sv;
#ifdef _WIN32
- if(TlsSetValue(_key, 0) == 0)
- {
- IceUtil::ThreadSyscallException(__FILE__, __LINE__, GetLastError());
- }
+ if(TlsSetValue(_key, 0) == 0)
+ {
+ IceUtil::ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ }
#else
- if(int err = pthread_setspecific(_key, 0))
- {
- throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, err);
- }
+ if(int err = pthread_setspecific(_key, 0))
+ {
+ throw IceUtil::ThreadSyscallException(__FILE__, __LINE__, err);
+ }
#endif
- }
- else
- {
- sv->resize(i + 1);
- }
+ }
+ else
+ {
+ sv->resize(i + 1);
+ }
}
}
@@ -542,11 +542,11 @@ PerThreadImplicitContext::getContext() const
Context* ctx = getThreadContext(false);
if(ctx == 0)
{
- return Context();
+ return Context();
}
else
{
- return *ctx;
+ return *ctx;
}
}
@@ -555,13 +555,13 @@ PerThreadImplicitContext::setContext(const Context& newContext)
{
if(newContext.size() == 0)
{
- clearThreadContext();
+ clearThreadContext();
}
else
{
- Context* ctx = getThreadContext(true);
- assert(ctx != 0);
- *ctx = newContext;
+ Context* ctx = getThreadContext(true);
+ assert(ctx != 0);
+ *ctx = newContext;
}
}
@@ -571,12 +571,12 @@ PerThreadImplicitContext::get(const string& k) const
Context* ctx = getThreadContext(false);
if(ctx == 0)
{
- throw NotSetException(__FILE__, __LINE__, k);
+ throw NotSetException(__FILE__, __LINE__, k);
}
Context::const_iterator p = ctx->find(k);
if(p == ctx->end())
{
- throw NotSetException(__FILE__, __LINE__, k);
+ throw NotSetException(__FILE__, __LINE__, k);
}
return p->second;
}
@@ -587,12 +587,12 @@ PerThreadImplicitContext::getWithDefault(const string& k, const string& d) const
Context* ctx = getThreadContext(false);
if(ctx == 0)
{
- return d;
+ return d;
}
Context::const_iterator p = ctx->find(k);
if(p == ctx->end())
{
- return d;
+ return d;
}
return p->second;
}
@@ -610,12 +610,12 @@ PerThreadImplicitContext::remove(const string& k)
Context* ctx = getThreadContext(false);
if(ctx == 0 || ctx->erase(k) == 0)
{
- throw NotSetException(__FILE__, __LINE__, k);
+ throw NotSetException(__FILE__, __LINE__, k);
}
if(ctx->size() == 0)
{
- clearThreadContext();
+ clearThreadContext();
}
}
@@ -626,17 +626,17 @@ PerThreadImplicitContext::write(const Context& proxyCtx, ::IceInternal::BasicStr
if(threadCtx == 0 || threadCtx->size() == 0)
{
- __write(s, proxyCtx, __U__Context());
+ __write(s, proxyCtx, __U__Context());
}
else if(proxyCtx.size() == 0)
{
- __write(s, *threadCtx, __U__Context());
+ __write(s, *threadCtx, __U__Context());
}
else
{
- Context combined = proxyCtx;
- combined.insert(threadCtx->begin(), threadCtx->end());
- __write(s, combined, __U__Context());
+ Context combined = proxyCtx;
+ combined.insert(threadCtx->begin(), threadCtx->end());
+ __write(s, combined, __U__Context());
}
}
@@ -647,15 +647,15 @@ PerThreadImplicitContext::combine(const Context& proxyCtx, Context& ctx) const
if(threadCtx == 0 || threadCtx->size() == 0)
{
- ctx = proxyCtx;
+ ctx = proxyCtx;
}
else if(proxyCtx.size() == 0)
{
- ctx = *threadCtx;
+ ctx = *threadCtx;
}
else
{
- ctx = proxyCtx;
- ctx.insert(threadCtx->begin(), threadCtx->end());
+ ctx = proxyCtx;
+ ctx.insert(threadCtx->begin(), threadCtx->end());
}
}
diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp
index bd41e14fef1..22dbebf73e7 100644
--- a/cpp/src/Ice/Incoming.cpp
+++ b/cpp/src/Ice/Incoming.cpp
@@ -25,8 +25,8 @@ using namespace Ice;
using namespace IceInternal;
IceInternal::IncomingBase::IncomingBase(Instance* instance, ConnectionI* connection,
- const ObjectAdapterPtr& adapter,
- bool response, Byte compress, Int requestId) :
+ const ObjectAdapterPtr& adapter,
+ bool response, Byte compress, Int requestId) :
_response(response),
_compress(compress),
_os(instance),
@@ -74,199 +74,199 @@ IceInternal::IncomingBase::__handleException(const Ice::Exception& ex)
{
try
{
- ex.ice_throw();
+ ex.ice_throw();
}
catch(RequestFailedException& ex)
{
- if(ex.id.name.empty())
- {
- ex.id = _current.id;
- }
-
- if(ex.facet.empty() && !_current.facet.empty())
- {
- ex.facet = _current.facet;
- }
-
- if(ex.operation.empty() && !_current.operation.empty())
- {
- ex.operation = _current.operation;
- }
-
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Dispatch status position.
- if(dynamic_cast<ObjectNotExistException*>(&ex))
- {
- _os.write(static_cast<Byte>(DispatchObjectNotExist));
- }
- else if(dynamic_cast<FacetNotExistException*>(&ex))
- {
- _os.write(static_cast<Byte>(DispatchFacetNotExist));
- }
- else if(dynamic_cast<OperationNotExistException*>(&ex))
- {
- _os.write(static_cast<Byte>(DispatchOperationNotExist));
- }
- else
- {
- assert(false);
- }
-
- ex.id.__write(&_os);
-
- //
- // For compatibility with the old FacetPath.
- //
- if(ex.facet.empty())
- {
- _os.write(static_cast<string*>(0), static_cast<string*>(0));
- }
- else
- {
- _os.write(&ex.facet, &ex.facet + 1);
- }
-
- _os.write(ex.operation, false);
-
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
+ if(ex.id.name.empty())
+ {
+ ex.id = _current.id;
+ }
+
+ if(ex.facet.empty() && !_current.facet.empty())
+ {
+ ex.facet = _current.facet;
+ }
+
+ if(ex.operation.empty() && !_current.operation.empty())
+ {
+ ex.operation = _current.operation;
+ }
+
+ if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 1)
+ {
+ __warning(ex);
+ }
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ if(dynamic_cast<ObjectNotExistException*>(&ex))
+ {
+ _os.write(static_cast<Byte>(DispatchObjectNotExist));
+ }
+ else if(dynamic_cast<FacetNotExistException*>(&ex))
+ {
+ _os.write(static_cast<Byte>(DispatchFacetNotExist));
+ }
+ else if(dynamic_cast<OperationNotExistException*>(&ex))
+ {
+ _os.write(static_cast<Byte>(DispatchOperationNotExist));
+ }
+ else
+ {
+ assert(false);
+ }
+
+ ex.id.__write(&_os);
+
+ //
+ // For compatibility with the old FacetPath.
+ //
+ if(ex.facet.empty())
+ {
+ _os.write(static_cast<string*>(0), static_cast<string*>(0));
+ }
+ else
+ {
+ _os.write(&ex.facet, &ex.facet + 1);
+ }
+
+ _os.write(ex.operation, false);
+
+ _connection->sendResponse(&_os, _compress);
+ }
+ else
+ {
+ _connection->sendNoResponse();
+ }
}
catch(const UnknownLocalException& ex)
{
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(DispatchUnknownLocalException));
- _os.write(ex.unknown, false);
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
+ if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
+ {
+ __warning(ex);
+ }
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(DispatchUnknownLocalException));
+ _os.write(ex.unknown, false);
+ _connection->sendResponse(&_os, _compress);
+ }
+ else
+ {
+ _connection->sendNoResponse();
+ }
}
catch(const UnknownUserException& ex)
{
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(DispatchUnknownUserException));
- _os.write(ex.unknown, false);
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
+ if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
+ {
+ __warning(ex);
+ }
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(DispatchUnknownUserException));
+ _os.write(ex.unknown, false);
+ _connection->sendResponse(&_os, _compress);
+ }
+ else
+ {
+ _connection->sendNoResponse();
+ }
}
catch(const UnknownException& ex)
{
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(DispatchUnknownException));
- _os.write(ex.unknown, false);
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
+ if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
+ {
+ __warning(ex);
+ }
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(DispatchUnknownException));
+ _os.write(ex.unknown, false);
+ _connection->sendResponse(&_os, _compress);
+ }
+ else
+ {
+ _connection->sendNoResponse();
+ }
}
catch(const LocalException& ex)
{
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(DispatchUnknownLocalException));
- ostringstream str;
- str << ex;
- _os.write(str.str(), false);
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
+ if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
+ {
+ __warning(ex);
+ }
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(DispatchUnknownLocalException));
+ ostringstream str;
+ str << ex;
+ _os.write(str.str(), false);
+ _connection->sendResponse(&_os, _compress);
+ }
+ else
+ {
+ _connection->sendNoResponse();
+ }
}
catch(const UserException& ex)
{
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(DispatchUnknownUserException));
- ostringstream str;
- str << ex;
- _os.write(str.str(), false);
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
+ if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
+ {
+ __warning(ex);
+ }
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(DispatchUnknownUserException));
+ ostringstream str;
+ str << ex;
+ _os.write(str.str(), false);
+ _connection->sendResponse(&_os, _compress);
+ }
+ else
+ {
+ _connection->sendNoResponse();
+ }
}
catch(const Exception& ex)
{
- if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
- {
- __warning(ex);
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(DispatchUnknownException));
- ostringstream str;
- str << ex;
- _os.write(str.str(), false);
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
+ if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
+ {
+ __warning(ex);
+ }
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(DispatchUnknownException));
+ ostringstream str;
+ str << ex;
+ _os.write(str.str(), false);
+ _connection->sendResponse(&_os, _compress);
+ }
+ else
+ {
+ _connection->sendNoResponse();
+ }
}
}
@@ -275,22 +275,22 @@ IceInternal::IncomingBase::__handleException(const std::exception& ex)
{
if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
- __warning(string("std::exception: ") + ex.what());
+ __warning(string("std::exception: ") + ex.what());
}
if(_response)
{
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(DispatchUnknownException));
- ostringstream str;
- str << "std::exception: " << ex.what();
- _os.write(str.str(), false);
- _connection->sendResponse(&_os, _compress);
+ _os.endWriteEncaps();
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(DispatchUnknownException));
+ ostringstream str;
+ str << "std::exception: " << ex.what();
+ _os.write(str.str(), false);
+ _connection->sendResponse(&_os, _compress);
}
else
{
- _connection->sendNoResponse();
+ _connection->sendNoResponse();
}
}
@@ -299,27 +299,27 @@ IceInternal::IncomingBase::__handleException()
{
if(_os.instance()->initializationData().properties->getPropertyAsIntWithDefault("Ice.Warn.Dispatch", 1) > 0)
{
- __warning("unknown c++ exception");
+ __warning("unknown c++ exception");
}
if(_response)
{
- _os.endWriteEncaps();
- _os.b.resize(headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(DispatchUnknownException));
- string reason = "unknown c++ exception";
- _os.write(reason, false);
- _connection->sendResponse(&_os, _compress);
+ _os.endWriteEncaps();
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(DispatchUnknownException));
+ string reason = "unknown c++ exception";
+ _os.write(reason, false);
+ _connection->sendResponse(&_os, _compress);
}
else
{
- _connection->sendNoResponse();
+ _connection->sendNoResponse();
}
}
IceInternal::Incoming::Incoming(Instance* instance, ConnectionI* connection,
- const ObjectAdapterPtr& adapter,
- bool response, Byte compress, Int requestId) :
+ const ObjectAdapterPtr& adapter,
+ bool response, Byte compress, Int requestId) :
IncomingBase(instance, connection, adapter, response, compress, requestId),
_is(instance)
{
@@ -338,16 +338,16 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
//
string facet;
{
- vector<string> facetPath;
- _is.read(facetPath);
- if(!facetPath.empty())
- {
- if(facetPath.size() > 1)
- {
- throw MarshalException(__FILE__, __LINE__);
- }
- facet.swap(facetPath[0]);
- }
+ vector<string> facetPath;
+ _is.read(facetPath);
+ if(!facetPath.empty())
+ {
+ if(facetPath.size() > 1)
+ {
+ throw MarshalException(__FILE__, __LINE__);
+ }
+ facet.swap(facetPath[0]);
+ }
}
_current.facet.swap(facet);
@@ -361,19 +361,19 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
_is.readSize(sz);
while(sz--)
{
- pair<const string, string> pr;
- _is.read(const_cast<string&>(pr.first));
- _is.read(pr.second);
- _current.ctx.insert(_current.ctx.end(), pr);
+ pair<const string, string> pr;
+ _is.read(const_cast<string&>(pr.first));
+ _is.read(pr.second);
+ _current.ctx.insert(_current.ctx.end(), pr);
}
_is.startReadEncaps();
if(_response)
{
- assert(_os.b.size() == headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(0));
- _os.startWriteEncaps();
+ assert(_os.b.size() == headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(0));
+ _os.startWriteEncaps();
}
// Initialize status to some value, to keep the compiler happy.
@@ -387,72 +387,72 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
try
{
- try
- {
- if(servantManager)
- {
- _servant = servantManager->findServant(_current.id, _current.facet);
- if(!_servant)
- {
- _locator = servantManager->findServantLocator(_current.id.category);
- if(!_locator && !_current.id.category.empty())
- {
- _locator = servantManager->findServantLocator("");
- }
- if(_locator)
- {
- _servant = _locator->locate(_current, _cookie);
- }
- }
- }
- if(!_servant)
- {
- if(servantManager && servantManager->hasServant(_current.id))
- {
- status = DispatchFacetNotExist;
- }
- else
- {
- status = DispatchObjectNotExist;
- }
- }
- else
- {
- status = _servant->__dispatch(*this, _current);
- }
- }
- catch(...)
- {
- if(_locator && _servant && status != DispatchAsync)
- {
- _locator->finished(_current, _servant, _cookie);
- }
-
- throw;
- }
-
- if(_locator && _servant && status != DispatchAsync)
- {
- _locator->finished(_current, _servant, _cookie);
- }
+ try
+ {
+ if(servantManager)
+ {
+ _servant = servantManager->findServant(_current.id, _current.facet);
+ if(!_servant)
+ {
+ _locator = servantManager->findServantLocator(_current.id.category);
+ if(!_locator && !_current.id.category.empty())
+ {
+ _locator = servantManager->findServantLocator("");
+ }
+ if(_locator)
+ {
+ _servant = _locator->locate(_current, _cookie);
+ }
+ }
+ }
+ if(!_servant)
+ {
+ if(servantManager && servantManager->hasServant(_current.id))
+ {
+ status = DispatchFacetNotExist;
+ }
+ else
+ {
+ status = DispatchObjectNotExist;
+ }
+ }
+ else
+ {
+ status = _servant->__dispatch(*this, _current);
+ }
+ }
+ catch(...)
+ {
+ if(_locator && _servant && status != DispatchAsync)
+ {
+ _locator->finished(_current, _servant, _cookie);
+ }
+
+ throw;
+ }
+
+ if(_locator && _servant && status != DispatchAsync)
+ {
+ _locator->finished(_current, _servant, _cookie);
+ }
}
catch(const Exception& ex)
{
- _is.endReadEncaps();
- __handleException(ex);
- return;
+ _is.endReadEncaps();
+ __handleException(ex);
+ return;
}
catch(const std::exception& ex)
{
- _is.endReadEncaps();
- __handleException(ex);
- return;
+ _is.endReadEncaps();
+ __handleException(ex);
+ return;
}
catch(...)
{
- _is.endReadEncaps();
- __handleException();
- return;
+ _is.endReadEncaps();
+ __handleException();
+ return;
}
//
@@ -469,50 +469,50 @@ IceInternal::Incoming::invoke(const ServantManagerPtr& servantManager)
//
if(status == DispatchAsync)
{
- //
- // If this was an asynchronous dispatch, we're done here.
- //
- return;
+ //
+ // If this was an asynchronous dispatch, we're done here.
+ //
+ return;
}
if(_response)
{
- _os.endWriteEncaps();
-
- if(status != DispatchOK && status != DispatchUserException)
- {
- assert(status == DispatchObjectNotExist ||
- status == DispatchFacetNotExist ||
- status == DispatchOperationNotExist);
-
- _os.b.resize(headerSize + 4); // Dispatch status position.
- _os.write(static_cast<Byte>(status));
-
- _current.id.__write(&_os);
-
- //
- // For compatibility with the old FacetPath.
- //
- if(_current.facet.empty())
- {
- _os.write(static_cast<string*>(0), static_cast<string*>(0));
- }
- else
- {
- _os.write(&_current.facet, &_current.facet + 1);
- }
-
- _os.write(_current.operation, false);
- }
- else
- {
- *(_os.b.begin() + headerSize + 4) = static_cast<Byte>(status); // Dispatch status position.
- }
-
- _connection->sendResponse(&_os, _compress);
+ _os.endWriteEncaps();
+
+ if(status != DispatchOK && status != DispatchUserException)
+ {
+ assert(status == DispatchObjectNotExist ||
+ status == DispatchFacetNotExist ||
+ status == DispatchOperationNotExist);
+
+ _os.b.resize(headerSize + 4); // Dispatch status position.
+ _os.write(static_cast<Byte>(status));
+
+ _current.id.__write(&_os);
+
+ //
+ // For compatibility with the old FacetPath.
+ //
+ if(_current.facet.empty())
+ {
+ _os.write(static_cast<string*>(0), static_cast<string*>(0));
+ }
+ else
+ {
+ _os.write(&_current.facet, &_current.facet + 1);
+ }
+
+ _os.write(_current.operation, false);
+ }
+ else
+ {
+ *(_os.b.begin() + headerSize + 4) = static_cast<Byte>(status); // Dispatch status position.
+ }
+
+ _connection->sendResponse(&_os, _compress);
}
else
{
- _connection->sendNoResponse();
+ _connection->sendNoResponse();
}
}
diff --git a/cpp/src/Ice/IncomingAsync.cpp b/cpp/src/Ice/IncomingAsync.cpp
index 00127ea64e9..b7c60f8592d 100644
--- a/cpp/src/Ice/IncomingAsync.cpp
+++ b/cpp/src/Ice/IncomingAsync.cpp
@@ -41,34 +41,34 @@ IceInternal::IncomingAsync::__response(bool ok)
{
try
{
- if(!__servantLocatorFinished())
- {
- return;
- }
-
- if(_response)
- {
- _os.endWriteEncaps();
-
- if(ok)
- {
- *(_os.b.begin() + headerSize + 4) = static_cast<Byte>(DispatchOK);
- }
- else
- {
- *(_os.b.begin() + headerSize + 4) = static_cast<Byte>(DispatchUserException);
- }
-
- _connection->sendResponse(&_os, _compress);
- }
- else
- {
- _connection->sendNoResponse();
- }
+ if(!__servantLocatorFinished())
+ {
+ return;
+ }
+
+ if(_response)
+ {
+ _os.endWriteEncaps();
+
+ if(ok)
+ {
+ *(_os.b.begin() + headerSize + 4) = static_cast<Byte>(DispatchOK);
+ }
+ else
+ {
+ *(_os.b.begin() + headerSize + 4) = static_cast<Byte>(DispatchUserException);
+ }
+
+ _connection->sendResponse(&_os, _compress);
+ }
+ else
+ {
+ _connection->sendNoResponse();
+ }
}
catch(const LocalException& ex)
{
- _connection->invokeException(ex, 1); // Fatal invocation exception
+ _connection->invokeException(ex, 1); // Fatal invocation exception
}
}
@@ -77,16 +77,16 @@ IceInternal::IncomingAsync::__exception(const Exception& exc)
{
try
{
- if(!__servantLocatorFinished())
- {
- return;
- }
+ if(!__servantLocatorFinished())
+ {
+ return;
+ }
- __handleException(exc);
+ __handleException(exc);
}
catch(const LocalException& ex)
{
- _connection->invokeException(ex, 1); // Fatal invocation exception
+ _connection->invokeException(ex, 1); // Fatal invocation exception
}
}
@@ -95,16 +95,16 @@ IceInternal::IncomingAsync::__exception(const std::exception& exc)
{
try
{
- if(!__servantLocatorFinished())
- {
- return;
- }
+ if(!__servantLocatorFinished())
+ {
+ return;
+ }
- __handleException(exc);
+ __handleException(exc);
}
catch(const LocalException& ex)
{
- _connection->invokeException(ex, 1); // Fatal invocation exception
+ _connection->invokeException(ex, 1); // Fatal invocation exception
}
}
@@ -113,16 +113,16 @@ IceInternal::IncomingAsync::__exception()
{
try
{
- if(!__servantLocatorFinished())
- {
- return;
- }
+ if(!__servantLocatorFinished())
+ {
+ return;
+ }
- __handleException();
+ __handleException();
}
catch(const LocalException& ex)
{
- _connection->invokeException(ex, 1); // Fatal invocation exception
+ _connection->invokeException(ex, 1); // Fatal invocation exception
}
}
@@ -131,26 +131,26 @@ IceInternal::IncomingAsync::__servantLocatorFinished()
{
try
{
- if(_locator && _servant)
- {
- _locator->finished(_current, _servant, _cookie);
- }
- return true;
+ if(_locator && _servant)
+ {
+ _locator->finished(_current, _servant, _cookie);
+ }
+ return true;
}
catch(const Exception& ex)
{
- __handleException(ex);
- return false;
+ __handleException(ex);
+ return false;
}
catch(const std::exception& ex)
{
- __handleException(ex);
- return false;
+ __handleException(ex);
+ return false;
}
catch(...)
{
- __handleException();
- return false;
+ __handleException();
+ return false;
}
}
@@ -164,12 +164,12 @@ IceAsync::Ice::AMD_Object_ice_invoke::ice_response(bool ok, const vector<Byte>&
{
try
{
- __os()->writeBlob(outParams);
+ __os()->writeBlob(outParams);
}
catch(const LocalException& ex)
{
- __exception(ex);
- return;
+ __exception(ex);
+ return;
}
__response(ok);
}
@@ -202,12 +202,12 @@ IceAsync::Ice::AMD_Array_Object_ice_invoke::ice_response(bool ok, const pair<con
{
try
{
- __os()->writeBlob(outParams.first, static_cast<Int>(outParams.second - outParams.first));
+ __os()->writeBlob(outParams.first, static_cast<Int>(outParams.second - outParams.first));
}
catch(const LocalException& ex)
{
- __exception(ex);
- return;
+ __exception(ex);
+ return;
}
__response(ok);
}
diff --git a/cpp/src/Ice/Initialize.cpp b/cpp/src/Ice/Initialize.cpp
index cb7252ddf94..70ce1296280 100644
--- a/cpp/src/Ice/Initialize.cpp
+++ b/cpp/src/Ice/Initialize.cpp
@@ -32,7 +32,7 @@ Ice::collectGarbage()
{
if(theCollector)
{
- theCollector->collectGarbage();
+ theCollector->collectGarbage();
}
}
@@ -80,7 +80,7 @@ Ice::stringSeqToArgs(const StringSeq& args, int& argc, char* argv[])
//
if(argv && argcOrig != argc)
{
- argv[argc] = 0;
+ argv[argc] = 0;
}
}
@@ -115,7 +115,7 @@ inline void checkIceVersion(Int version)
//
if(ICE_INT_VERSION != version)
{
- throw VersionMismatchException(__FILE__, __LINE__);
+ throw VersionMismatchException(__FILE__, __LINE__);
}
# else
@@ -124,7 +124,7 @@ inline void checkIceVersion(Int version)
//
if(ICE_INT_VERSION / 100 != version / 100)
{
- throw VersionMismatchException(__FILE__, __LINE__);
+ throw VersionMismatchException(__FILE__, __LINE__);
}
//
@@ -132,7 +132,7 @@ inline void checkIceVersion(Int version)
//
if(version % 100 > 50)
{
- throw VersionMismatchException(__FILE__, __LINE__);
+ throw VersionMismatchException(__FILE__, __LINE__);
}
//
@@ -141,7 +141,7 @@ inline void checkIceVersion(Int version)
//
if(version % 100 > ICE_INT_VERSION % 100)
{
- throw VersionMismatchException(__FILE__, __LINE__);
+ throw VersionMismatchException(__FILE__, __LINE__);
}
# endif
@@ -172,42 +172,42 @@ Ice::initialize(StringSeq& args, const InitializationData& initializationData, I
CommunicatorPtr communicator;
try
{
- //
- // Make a dummy argc/argv.
- // (We can't use argsToStringSeq() because that requires an already initialized argv.)
- //
- int argc = args.size();
- origArgc = argc;
- argv = new char*[args.size() + 1];
- int i;
- for(i = 0; i != argc; ++i)
- {
- argv[i] = new char[args[i].size() + 1];
+ //
+ // Make a dummy argc/argv.
+ // (We can't use argsToStringSeq() because that requires an already initialized argv.)
+ //
+ int argc = args.size();
+ origArgc = argc;
+ argv = new char*[args.size() + 1];
+ int i;
+ for(i = 0; i != argc; ++i)
+ {
+ argv[i] = new char[args[i].size() + 1];
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
- strcpy_s(argv[i], args[i].size() + 1, args[i].c_str());
+ strcpy_s(argv[i], args[i].size() + 1, args[i].c_str());
#else
- strcpy(argv[i], args[i].c_str());
+ strcpy(argv[i], args[i].c_str());
#endif
- }
- argv[argc] = 0;
-
- communicator = initialize(argc, argv, initializationData, version);
-
- args = argsToStringSeq(argc, argv);
-
- for(i = 0; i < origArgc; ++i)
- {
- delete[] argv[i];
- }
- delete[] argv;
+ }
+ argv[argc] = 0;
+
+ communicator = initialize(argc, argv, initializationData, version);
+
+ args = argsToStringSeq(argc, argv);
+
+ for(i = 0; i < origArgc; ++i)
+ {
+ delete[] argv[i];
+ }
+ delete[] argv;
}
catch(...)
{
- for(int i = 0; i < origArgc; ++i)
- {
- delete[] argv[i];
- }
- delete[] argv;
+ for(int i = 0; i < origArgc; ++i)
+ {
+ delete[] argv[i];
+ }
+ delete[] argv;
throw;
}
return communicator;
@@ -249,7 +249,7 @@ Ice::initializeWithLogger(int& argc, char* argv[], const LoggerPtr& logger, Int
CommunicatorPtr
Ice::initializeWithPropertiesAndLogger(int& argc, char* argv[], const PropertiesPtr& properties,
- const LoggerPtr& logger, Int version)
+ const LoggerPtr& logger, Int version)
{
InitializationData initData;
initData.properties = properties;
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index 5548d792c9b..ecb2f466bd2 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -98,7 +98,7 @@ IceInternal::Instance::routerManager() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _routerManager;
@@ -111,7 +111,7 @@ IceInternal::Instance::locatorManager() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _locatorManager;
@@ -124,7 +124,7 @@ IceInternal::Instance::referenceFactory() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _referenceFactory;
@@ -137,7 +137,7 @@ IceInternal::Instance::proxyFactory() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _proxyFactory;
@@ -150,7 +150,7 @@ IceInternal::Instance::outgoingConnectionFactory() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _outgoingConnectionFactory;
@@ -163,7 +163,7 @@ IceInternal::Instance::connectionMonitor() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _connectionMonitor;
@@ -176,7 +176,7 @@ IceInternal::Instance::servantFactoryManager() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _servantFactoryManager;
@@ -189,7 +189,7 @@ IceInternal::Instance::objectAdapterFactory() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _objectAdapterFactory;
@@ -202,12 +202,12 @@ IceInternal::Instance::clientThreadPool()
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
if(!_clientThreadPool) // Lazy initialization.
{
- _clientThreadPool = new ThreadPool(this, "Ice.ThreadPool.Client", 0);
+ _clientThreadPool = new ThreadPool(this, "Ice.ThreadPool.Client", 0);
}
return _clientThreadPool;
@@ -220,13 +220,13 @@ IceInternal::Instance::serverThreadPool()
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
if(!_serverThreadPool) // Lazy initialization.
{
- int timeout = _initData.properties->getPropertyAsInt("Ice.ServerIdleTime");
- _serverThreadPool = new ThreadPool(this, "Ice.ThreadPool.Server", timeout);
+ int timeout = _initData.properties->getPropertyAsInt("Ice.ServerIdleTime");
+ _serverThreadPool = new ThreadPool(this, "Ice.ThreadPool.Server", timeout);
}
return _serverThreadPool;
@@ -253,7 +253,7 @@ IceInternal::Instance::endpointFactoryManager() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _endpointFactoryManager;
@@ -266,7 +266,7 @@ IceInternal::Instance::dynamicLibraryList() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _dynamicLibraryList;
@@ -279,7 +279,7 @@ IceInternal::Instance::pluginManager() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _pluginManager;
@@ -306,15 +306,15 @@ IceInternal::Instance::flushBatchRequests()
ObjectAdapterFactoryPtr adapterFactory;
{
- IceUtil::RecMutex::Lock sync(*this);
+ IceUtil::RecMutex::Lock sync(*this);
- if(_state == StateDestroyed)
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
+ if(_state == StateDestroyed)
+ {
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ }
- connectionFactory = _outgoingConnectionFactory;
- adapterFactory = _objectAdapterFactory;
+ connectionFactory = _outgoingConnectionFactory;
+ adapterFactory = _objectAdapterFactory;
}
connectionFactory->flushBatchRequests();
@@ -328,7 +328,7 @@ IceInternal::Instance::setDefaultContext(const Context& ctx)
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
_defaultContext = new SharedContext(ctx);
@@ -341,7 +341,7 @@ IceInternal::Instance::getDefaultContext() const
if(_state == StateDestroyed)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
return _defaultContext;
@@ -409,15 +409,15 @@ IceInternal::Instance::stringToIdentity(const string& s) const
if(_initData.stringConverter)
{
string tmpString;
- _initData.stringConverter->fromUTF8(reinterpret_cast<const Byte*>(ident.name.data()),
- reinterpret_cast<const Byte*>(ident.name.data() + ident.name.size()),
- tmpString);
- ident.name = tmpString;
+ _initData.stringConverter->fromUTF8(reinterpret_cast<const Byte*>(ident.name.data()),
+ reinterpret_cast<const Byte*>(ident.name.data() + ident.name.size()),
+ tmpString);
+ ident.name = tmpString;
- _initData.stringConverter->fromUTF8(reinterpret_cast<const Byte*>(ident.category.data()),
- reinterpret_cast<const Byte*>(ident.category.data() + ident.category.size()),
- tmpString);
- ident.category = tmpString;
+ _initData.stringConverter->fromUTF8(reinterpret_cast<const Byte*>(ident.category.data()),
+ reinterpret_cast<const Byte*>(ident.category.data() + ident.category.size()),
+ tmpString);
+ ident.category = tmpString;
}
return ident;
@@ -432,12 +432,12 @@ IceInternal::Instance::identityToString(const Identity& ident) const
{
UTF8BufferI buffer;
Byte* last = _initData.stringConverter->toUTF8(ident.name.data(), ident.name.data() + ident.name.size(),
- buffer);
+ buffer);
name = string(reinterpret_cast<const char*>(buffer.getBuffer()), last - buffer.getBuffer());
- buffer.reset();
+ buffer.reset();
last = _initData.stringConverter->toUTF8(ident.category.data(), ident.category.data() + ident.category.size(),
- buffer);
+ buffer);
category = string(reinterpret_cast<const char*>(buffer.getBuffer()), last - buffer.getBuffer());
}
@@ -464,189 +464,189 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi
{
try
{
- __setNoDelete(true);
-
- IceUtil::StaticMutex::Lock sync(staticMutex);
- instanceCount++;
-
- if(!_initData.properties)
- {
- _initData.properties = createProperties();
- }
-
- if(!oneOffDone)
- {
- //
- // StdOut and StdErr redirection
- //
- string stdOutFilename = _initData.properties->getProperty("Ice.StdOut");
- string stdErrFilename = _initData.properties->getProperty("Ice.StdErr");
-
- if(stdOutFilename != "")
- {
- FILE* file = freopen(stdOutFilename.c_str(), "a", stdout);
- if(file == 0)
- {
- FileException ex(__FILE__, __LINE__);
- ex.path = stdOutFilename;
- ex.error = getSystemErrno();
- throw ex;
- }
- }
-
- if(stdErrFilename != "")
- {
- FILE* file = freopen(stdErrFilename.c_str(), "a", stderr);
- if(file == 0)
- {
- FileException ex(__FILE__, __LINE__);
- ex.path = stdErrFilename;
- ex.error = getSystemErrno();
- throw ex;
- }
- }
-
- if(_initData.properties->getPropertyAsInt("Ice.NullHandleAbort") > 0)
- {
- IceUtil::nullHandleAbort = true;
- }
-
+ __setNoDelete(true);
+
+ IceUtil::StaticMutex::Lock sync(staticMutex);
+ instanceCount++;
+
+ if(!_initData.properties)
+ {
+ _initData.properties = createProperties();
+ }
+
+ if(!oneOffDone)
+ {
+ //
+ // StdOut and StdErr redirection
+ //
+ string stdOutFilename = _initData.properties->getProperty("Ice.StdOut");
+ string stdErrFilename = _initData.properties->getProperty("Ice.StdErr");
+
+ if(stdOutFilename != "")
+ {
+ FILE* file = freopen(stdOutFilename.c_str(), "a", stdout);
+ if(file == 0)
+ {
+ FileException ex(__FILE__, __LINE__);
+ ex.path = stdOutFilename;
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+ }
+
+ if(stdErrFilename != "")
+ {
+ FILE* file = freopen(stdErrFilename.c_str(), "a", stderr);
+ if(file == 0)
+ {
+ FileException ex(__FILE__, __LINE__);
+ ex.path = stdErrFilename;
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+ }
+
+ if(_initData.properties->getPropertyAsInt("Ice.NullHandleAbort") > 0)
+ {
+ IceUtil::nullHandleAbort = true;
+ }
+
#ifndef _WIN32
- string newUser = _initData.properties->getProperty("Ice.ChangeUser");
- if(!newUser.empty())
- {
- struct passwd* pw = getpwnam(newUser.c_str());
- if(!pw)
- {
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
- }
-
- if(setgid(pw->pw_gid) == -1)
- {
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
- }
-
- if(setuid(pw->pw_uid) == -1)
- {
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
- }
- }
+ string newUser = _initData.properties->getProperty("Ice.ChangeUser");
+ if(!newUser.empty())
+ {
+ struct passwd* pw = getpwnam(newUser.c_str());
+ if(!pw)
+ {
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+
+ if(setgid(pw->pw_gid) == -1)
+ {
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+
+ if(setuid(pw->pw_uid) == -1)
+ {
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+ }
#endif
- oneOffDone = true;
- }
-
- if(instanceCount == 1)
- {
-
+ oneOffDone = true;
+ }
+
+ if(instanceCount == 1)
+ {
+
#ifdef _WIN32
- WORD version = MAKEWORD(1, 1);
- WSADATA data;
- if(WSAStartup(version, &data) != 0)
- {
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
+ WORD version = MAKEWORD(1, 1);
+ WSADATA data;
+ if(WSAStartup(version, &data) != 0)
+ {
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
#endif
-
+
#ifndef _WIN32
- struct sigaction action;
- action.sa_handler = SIG_IGN;
- sigemptyset(&action.sa_mask);
- action.sa_flags = 0;
- sigaction(SIGPIPE, &action, 0);
-
- if(_initData.properties->getPropertyAsInt("Ice.UseSyslog") > 0)
- {
- identForOpenlog = _initData.properties->getProperty("Ice.ProgramName");
- if(identForOpenlog.empty())
- {
- identForOpenlog = "<Unknown Ice Program>";
- }
- openlog(identForOpenlog.c_str(), LOG_PID, LOG_USER);
- }
+ struct sigaction action;
+ action.sa_handler = SIG_IGN;
+ sigemptyset(&action.sa_mask);
+ action.sa_flags = 0;
+ sigaction(SIGPIPE, &action, 0);
+
+ if(_initData.properties->getPropertyAsInt("Ice.UseSyslog") > 0)
+ {
+ identForOpenlog = _initData.properties->getProperty("Ice.ProgramName");
+ if(identForOpenlog.empty())
+ {
+ identForOpenlog = "<Unknown Ice Program>";
+ }
+ openlog(identForOpenlog.c_str(), LOG_PID, LOG_USER);
+ }
#endif
- }
-
- sync.release();
-
+ }
+
+ sync.release();
+
- if(!_initData.logger)
- {
+ if(!_initData.logger)
+ {
#ifdef _WIN32
- if(_initData.properties->getPropertyAsInt("Ice.UseEventLog") > 0)
- {
- _initData.logger = new EventLoggerI(_initData.properties->getProperty("Ice.ProgramName"));
- }
+ if(_initData.properties->getPropertyAsInt("Ice.UseEventLog") > 0)
+ {
+ _initData.logger = new EventLoggerI(_initData.properties->getProperty("Ice.ProgramName"));
+ }
#else
- if(_initData.properties->getPropertyAsInt("Ice.UseSyslog") > 0)
- {
- _initData.logger = new SysLoggerI;
- }
+ if(_initData.properties->getPropertyAsInt("Ice.UseSyslog") > 0)
+ {
+ _initData.logger = new SysLoggerI;
+ }
#endif
- else
- {
- _initData.logger = getProcessLogger();
- }
- }
-
- const_cast<TraceLevelsPtr&>(_traceLevels) = new TraceLevels(_initData.properties);
-
- const_cast<DefaultsAndOverridesPtr&>(_defaultsAndOverrides) = new DefaultsAndOverrides(_initData.properties);
-
- {
- static const int defaultMessageSizeMax = 1024;
- Int num = _initData.properties->getPropertyAsIntWithDefault("Ice.MessageSizeMax", defaultMessageSizeMax);
- if(num < 1)
- {
- const_cast<size_t&>(_messageSizeMax) = defaultMessageSizeMax * 1024; // Ignore stupid values.
- }
- else if(static_cast<size_t>(num) > (size_t)(0x7fffffff / 1024))
- {
- const_cast<size_t&>(_messageSizeMax) = static_cast<size_t>(0x7fffffff);
- }
- else
- {
- // Property is in kilobytes, _messageSizeMax in bytes.
- const_cast<size_t&>(_messageSizeMax) = static_cast<size_t>(num) * 1024;
- }
- }
-
- //
- // Client ACM enabled by default. Server ACM disabled by default.
- //
- const_cast<Int&>(_clientACM) = _initData.properties->getPropertyAsIntWithDefault("Ice.ACM.Client", 60);
- const_cast<Int&>(_serverACM) = _initData.properties->getPropertyAsInt("Ice.ACM.Server");
-
- const_cast<bool&>(_threadPerConnection) = _initData.properties->getPropertyAsInt("Ice.ThreadPerConnection") > 0;
-
- {
- Int stackSize = _initData.properties->getPropertyAsInt("Ice.ThreadPerConnection.StackSize");
- if(stackSize < 0)
- {
- stackSize = 0;
- }
- const_cast<size_t&>(_threadPerConnectionStackSize) = static_cast<size_t>(stackSize);
- }
-
- const_cast<ImplicitContextIPtr&>(_implicitContext) =
- ImplicitContextI::create(_initData.properties->getProperty("Ice.ImplicitContext"));
-
- _routerManager = new RouterManager;
-
- _locatorManager = new LocatorManager;
-
- _referenceFactory = new ReferenceFactory(this, communicator);
-
- _proxyFactory = new ProxyFactory(this);
-
- _endpointFactoryManager = new EndpointFactoryManager(this);
+ else
+ {
+ _initData.logger = getProcessLogger();
+ }
+ }
+
+ const_cast<TraceLevelsPtr&>(_traceLevels) = new TraceLevels(_initData.properties);
+
+ const_cast<DefaultsAndOverridesPtr&>(_defaultsAndOverrides) = new DefaultsAndOverrides(_initData.properties);
+
+ {
+ static const int defaultMessageSizeMax = 1024;
+ Int num = _initData.properties->getPropertyAsIntWithDefault("Ice.MessageSizeMax", defaultMessageSizeMax);
+ if(num < 1)
+ {
+ const_cast<size_t&>(_messageSizeMax) = defaultMessageSizeMax * 1024; // Ignore stupid values.
+ }
+ else if(static_cast<size_t>(num) > (size_t)(0x7fffffff / 1024))
+ {
+ const_cast<size_t&>(_messageSizeMax) = static_cast<size_t>(0x7fffffff);
+ }
+ else
+ {
+ // Property is in kilobytes, _messageSizeMax in bytes.
+ const_cast<size_t&>(_messageSizeMax) = static_cast<size_t>(num) * 1024;
+ }
+ }
+
+ //
+ // Client ACM enabled by default. Server ACM disabled by default.
+ //
+ const_cast<Int&>(_clientACM) = _initData.properties->getPropertyAsIntWithDefault("Ice.ACM.Client", 60);
+ const_cast<Int&>(_serverACM) = _initData.properties->getPropertyAsInt("Ice.ACM.Server");
+
+ const_cast<bool&>(_threadPerConnection) = _initData.properties->getPropertyAsInt("Ice.ThreadPerConnection") > 0;
+
+ {
+ Int stackSize = _initData.properties->getPropertyAsInt("Ice.ThreadPerConnection.StackSize");
+ if(stackSize < 0)
+ {
+ stackSize = 0;
+ }
+ const_cast<size_t&>(_threadPerConnectionStackSize) = static_cast<size_t>(stackSize);
+ }
+
+ const_cast<ImplicitContextIPtr&>(_implicitContext) =
+ ImplicitContextI::create(_initData.properties->getProperty("Ice.ImplicitContext"));
+
+ _routerManager = new RouterManager;
+
+ _locatorManager = new LocatorManager;
+
+ _referenceFactory = new ReferenceFactory(this, communicator);
+
+ _proxyFactory = new ProxyFactory(this);
+
+ _endpointFactoryManager = new EndpointFactoryManager(this);
EndpointFactoryPtr tcpEndpointFactory = new TcpEndpointFactory(this);
_endpointFactoryManager->add(tcpEndpointFactory);
EndpointFactoryPtr udpEndpointFactory = new UdpEndpointFactory(this);
@@ -656,28 +656,28 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi
_pluginManager = new PluginManagerI(communicator, _dynamicLibraryList);
- _outgoingConnectionFactory = new OutgoingConnectionFactory(this);
+ _outgoingConnectionFactory = new OutgoingConnectionFactory(this);
- _servantFactoryManager = new ObjectFactoryManager();
+ _servantFactoryManager = new ObjectFactoryManager();
- _objectAdapterFactory = new ObjectAdapterFactory(this, communicator);
+ _objectAdapterFactory = new ObjectAdapterFactory(this, communicator);
- if(_initData.wstringConverter == 0)
- {
- _initData.wstringConverter = new UnicodeWstringConverter();
- }
+ if(_initData.wstringConverter == 0)
+ {
+ _initData.wstringConverter = new UnicodeWstringConverter();
+ }
- __setNoDelete(false);
+ __setNoDelete(false);
}
catch(...)
{
- {
- IceUtil::StaticMutex::Lock sync(staticMutex);
- --instanceCount;
- }
- destroy();
- __setNoDelete(false);
- throw;
+ {
+ IceUtil::StaticMutex::Lock sync(staticMutex);
+ --instanceCount;
+ }
+ destroy();
+ __setNoDelete(false);
+ throw;
}
}
@@ -703,21 +703,21 @@ IceInternal::Instance::~Instance()
if(--instanceCount == 0)
{
#ifdef _WIN32
- WSACleanup();
+ WSACleanup();
#endif
-
+
#ifndef _WIN32
- struct sigaction action;
- action.sa_handler = SIG_DFL;
- sigemptyset(&action.sa_mask);
- action.sa_flags = 0;
- sigaction(SIGPIPE, &action, 0);
-
- if(!identForOpenlog.empty())
- {
- closelog();
- identForOpenlog.clear();
- }
+ struct sigaction action;
+ action.sa_handler = SIG_DFL;
+ sigemptyset(&action.sa_mask);
+ action.sa_flags = 0;
+ sigaction(SIGPIPE, &action, 0);
+
+ if(!identForOpenlog.empty())
+ {
+ closelog();
+ identForOpenlog.clear();
+ }
#endif
}
}
@@ -755,24 +755,24 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[])
bool printProcessId = false;
if(!printProcessIdDone && _initData.properties->getPropertyAsInt("Ice.PrintProcessId") > 0)
{
- //
- // Safe double-check locking (no dependent variable!)
- //
- IceUtil::StaticMutex::Lock sync(staticMutex);
- printProcessId = !printProcessIdDone;
-
- //
- // We anticipate: we want to print it once, and we don't care when.
- //
- printProcessIdDone = true;
+ //
+ // Safe double-check locking (no dependent variable!)
+ //
+ IceUtil::StaticMutex::Lock sync(staticMutex);
+ printProcessId = !printProcessIdDone;
+
+ //
+ // We anticipate: we want to print it once, and we don't care when.
+ //
+ printProcessIdDone = true;
}
if(printProcessId)
{
#ifdef _MSC_VER
- cout << _getpid() << endl;
+ cout << _getpid() << endl;
#else
- cout << getpid() << endl;
+ cout << getpid() << endl;
#endif
}
@@ -782,20 +782,20 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[])
Int interval = 0;
if(_clientACM > 0 && _serverACM > 0)
{
- interval = min(_clientACM, _serverACM);
+ interval = min(_clientACM, _serverACM);
}
else if(_clientACM > 0)
{
- interval = _clientACM;
+ interval = _clientACM;
}
else if(_serverACM > 0)
{
- interval = _serverACM;
+ interval = _serverACM;
}
interval = _initData.properties->getPropertyAsIntWithDefault("Ice.MonitorConnections", interval);
if(interval > 0)
{
- _connectionMonitor = new ConnectionMonitor(this, interval);
+ _connectionMonitor = new ConnectionMonitor(this, interval);
}
//
@@ -808,29 +808,29 @@ bool
IceInternal::Instance::destroy()
{
{
- IceUtil::RecMutex::Lock sync(*this);
-
- //
- // If the _state is not StateActive then the instance is
- // either being destroyed, or has already been destroyed.
- //
- if(_state != StateActive)
- {
- return false;
- }
+ IceUtil::RecMutex::Lock sync(*this);
+
+ //
+ // If the _state is not StateActive then the instance is
+ // either being destroyed, or has already been destroyed.
+ //
+ if(_state != StateActive)
+ {
+ return false;
+ }
- //
- // We cannot set state to StateDestroyed otherwise instance
- // methods called during the destroy process (such as
- // outgoingConnectionFactory() from
- // ObjectAdapterI::deactivate() will cause an exception.
- //
- _state = StateDestroyInProgress;
+ //
+ // We cannot set state to StateDestroyed otherwise instance
+ // methods called during the destroy process (such as
+ // outgoingConnectionFactory() from
+ // ObjectAdapterI::deactivate() will cause an exception.
+ //
+ _state = StateDestroyInProgress;
}
if(_objectAdapterFactory)
{
- _objectAdapterFactory->shutdown();
+ _objectAdapterFactory->shutdown();
}
if(_outgoingConnectionFactory)
@@ -852,74 +852,74 @@ IceInternal::Instance::destroy()
ThreadPoolPtr clientThreadPool;
{
- IceUtil::RecMutex::Lock sync(*this);
-
- _objectAdapterFactory = 0;
- _outgoingConnectionFactory = 0;
-
- if(_connectionMonitor)
- {
- _connectionMonitor->destroy();
- _connectionMonitor = 0;
- }
-
- if(_serverThreadPool)
- {
- _serverThreadPool->destroy();
- std::swap(_serverThreadPool, serverThreadPool);
- }
-
- if(_clientThreadPool)
- {
- _clientThreadPool->destroy();
- std::swap(_clientThreadPool, clientThreadPool);
- }
-
- if(_servantFactoryManager)
- {
- _servantFactoryManager->destroy();
- _servantFactoryManager = 0;
- }
-
- if(_referenceFactory)
- {
- _referenceFactory->destroy();
- _referenceFactory = 0;
- }
-
- // No destroy function defined.
- // _proxyFactory->destroy();
- _proxyFactory = 0;
-
- if(_routerManager)
- {
- _routerManager->destroy();
- _routerManager = 0;
- }
-
- if(_locatorManager)
- {
- _locatorManager->destroy();
- _locatorManager = 0;
- }
-
- if(_endpointFactoryManager)
- {
- _endpointFactoryManager->destroy();
- _endpointFactoryManager = 0;
- }
-
- if(_pluginManager)
- {
- _pluginManager->destroy();
- _pluginManager = 0;
- }
-
- // No destroy function defined.
- // _dynamicLibraryList->destroy();
- _dynamicLibraryList = 0;
-
- _state = StateDestroyed;
+ IceUtil::RecMutex::Lock sync(*this);
+
+ _objectAdapterFactory = 0;
+ _outgoingConnectionFactory = 0;
+
+ if(_connectionMonitor)
+ {
+ _connectionMonitor->destroy();
+ _connectionMonitor = 0;
+ }
+
+ if(_serverThreadPool)
+ {
+ _serverThreadPool->destroy();
+ std::swap(_serverThreadPool, serverThreadPool);
+ }
+
+ if(_clientThreadPool)
+ {
+ _clientThreadPool->destroy();
+ std::swap(_clientThreadPool, clientThreadPool);
+ }
+
+ if(_servantFactoryManager)
+ {
+ _servantFactoryManager->destroy();
+ _servantFactoryManager = 0;
+ }
+
+ if(_referenceFactory)
+ {
+ _referenceFactory->destroy();
+ _referenceFactory = 0;
+ }
+
+ // No destroy function defined.
+ // _proxyFactory->destroy();
+ _proxyFactory = 0;
+
+ if(_routerManager)
+ {
+ _routerManager->destroy();
+ _routerManager = 0;
+ }
+
+ if(_locatorManager)
+ {
+ _locatorManager->destroy();
+ _locatorManager = 0;
+ }
+
+ if(_endpointFactoryManager)
+ {
+ _endpointFactoryManager->destroy();
+ _endpointFactoryManager = 0;
+ }
+
+ if(_pluginManager)
+ {
+ _pluginManager->destroy();
+ _pluginManager = 0;
+ }
+
+ // No destroy function defined.
+ // _dynamicLibraryList->destroy();
+ _dynamicLibraryList = 0;
+
+ _state = StateDestroyed;
}
//
@@ -927,11 +927,11 @@ IceInternal::Instance::destroy()
//
if(clientThreadPool)
{
- clientThreadPool->joinWithAllThreads();
+ clientThreadPool->joinWithAllThreads();
}
if(serverThreadPool)
{
- serverThreadPool->joinWithAllThreads();
+ serverThreadPool->joinWithAllThreads();
}
return true;
}
@@ -956,7 +956,7 @@ IceInternal::UTF8BufferI::getMoreBytes(size_t howMany, Byte* firstUnused)
}
else
{
- assert(firstUnused != 0);
+ assert(firstUnused != 0);
_offset = firstUnused - _buffer;
_buffer = (Byte*)realloc(_buffer, _offset + howMany);
}
diff --git a/cpp/src/Ice/Instance.h b/cpp/src/Ice/Instance.h
index 3a4245ff2b7..27f875fc181 100644
--- a/cpp/src/Ice/Instance.h
+++ b/cpp/src/Ice/Instance.h
@@ -81,7 +81,7 @@ public:
const Ice::ImplicitContextIPtr& getImplicitContext() const
{
- return _implicitContext;
+ return _implicitContext;
}
private:
@@ -94,9 +94,9 @@ private:
enum State
{
- StateActive,
- StateDestroyInProgress,
- StateDestroyed
+ StateActive,
+ StateDestroyInProgress,
+ StateDestroyed
};
State _state;
Ice::InitializationData _initData;
diff --git a/cpp/src/Ice/LocatorInfo.cpp b/cpp/src/Ice/LocatorInfo.cpp
index 146126f95ab..15e27d67d03 100644
--- a/cpp/src/Ice/LocatorInfo.cpp
+++ b/cpp/src/Ice/LocatorInfo.cpp
@@ -54,7 +54,7 @@ IceInternal::LocatorManager::get(const LocatorPrx& loc)
{
if(!loc)
{
- return 0;
+ return 0;
}
LocatorPrx locator = LocatorPrx::uncheckedCast(loc->ice_locator(0)); // The locator can't be located.
@@ -69,39 +69,39 @@ IceInternal::LocatorManager::get(const LocatorPrx& loc)
if(_tableHint != _table.end())
{
- if(_tableHint->first == locator)
- {
- p = _tableHint;
- }
+ if(_tableHint->first == locator)
+ {
+ p = _tableHint;
+ }
}
if(p == _table.end())
{
- p = _table.find(locator);
+ p = _table.find(locator);
}
if(p == _table.end())
{
- //
- // Rely on locator identity for the adapter table. We want to
- // have only one table per locator (not one per locator
- // proxy).
- //
- map<Identity, LocatorTablePtr>::iterator t = _locatorTables.find(locator->ice_getIdentity());
- if(t == _locatorTables.end())
- {
- t = _locatorTables.insert(_locatorTables.begin(),
- pair<const Identity, LocatorTablePtr>(locator->ice_getIdentity(),
- new LocatorTable()));
- }
-
- _tableHint = _table.insert(_tableHint,
- pair<const LocatorPrx, LocatorInfoPtr>(locator,
- new LocatorInfo(locator, t->second)));
+ //
+ // Rely on locator identity for the adapter table. We want to
+ // have only one table per locator (not one per locator
+ // proxy).
+ //
+ map<Identity, LocatorTablePtr>::iterator t = _locatorTables.find(locator->ice_getIdentity());
+ if(t == _locatorTables.end())
+ {
+ t = _locatorTables.insert(_locatorTables.begin(),
+ pair<const Identity, LocatorTablePtr>(locator->ice_getIdentity(),
+ new LocatorTable()));
+ }
+
+ _tableHint = _table.insert(_tableHint,
+ pair<const LocatorPrx, LocatorInfoPtr>(locator,
+ new LocatorInfo(locator, t->second)));
}
else
{
- _tableHint = p;
+ _tableHint = p;
}
return _tableHint->second;
@@ -125,7 +125,7 @@ IceInternal::LocatorTable::getAdapterEndpoints(const string& adapter, int ttl, v
{
if(ttl == 0) // No locator cache.
{
- return false;
+ return false;
}
IceUtil::Mutex::Lock sync(*this);
@@ -134,8 +134,8 @@ IceInternal::LocatorTable::getAdapterEndpoints(const string& adapter, int ttl, v
if(p != _adapterEndpointsMap.end() && checkTTL(p->second.first, ttl))
{
- endpoints = p->second.second;
- return true;
+ endpoints = p->second.second;
+ return true;
}
return false;
}
@@ -149,11 +149,11 @@ IceInternal::LocatorTable::addAdapterEndpoints(const string& adapter, const vect
if(p != _adapterEndpointsMap.end())
{
- p->second = make_pair(IceUtil::Time::now(), endpoints);
+ p->second = make_pair(IceUtil::Time::now(), endpoints);
}
else
{
- _adapterEndpointsMap.insert(make_pair(adapter, make_pair(IceUtil::Time::now(), endpoints)));
+ _adapterEndpointsMap.insert(make_pair(adapter, make_pair(IceUtil::Time::now(), endpoints)));
}
}
@@ -165,7 +165,7 @@ IceInternal::LocatorTable::removeAdapterEndpoints(const string& adapter)
map<string, pair<IceUtil::Time, vector<EndpointIPtr> > >::iterator p = _adapterEndpointsMap.find(adapter);
if(p == _adapterEndpointsMap.end())
{
- return vector<EndpointIPtr>();
+ return vector<EndpointIPtr>();
}
vector<EndpointIPtr> endpoints = p->second.second;
@@ -180,7 +180,7 @@ IceInternal::LocatorTable::getProxy(const Identity& id, int ttl, ObjectPrx& prox
{
if(ttl == 0) // No locator cache
{
- return false;
+ return false;
}
IceUtil::Mutex::Lock sync(*this);
@@ -189,8 +189,8 @@ IceInternal::LocatorTable::getProxy(const Identity& id, int ttl, ObjectPrx& prox
if(p != _objectMap.end() && checkTTL(p->second.first, ttl))
{
- proxy = p->second.second;
- return true;
+ proxy = p->second.second;
+ return true;
}
return false;
}
@@ -204,11 +204,11 @@ IceInternal::LocatorTable::addProxy(const Identity& id, const ObjectPrx& proxy)
if(p != _objectMap.end())
{
- p->second = make_pair(IceUtil::Time::now(), proxy);
+ p->second = make_pair(IceUtil::Time::now(), proxy);
}
else
{
- _objectMap.insert(make_pair(id, make_pair(IceUtil::Time::now(), proxy)));
+ _objectMap.insert(make_pair(id, make_pair(IceUtil::Time::now(), proxy)));
}
}
@@ -220,7 +220,7 @@ IceInternal::LocatorTable::removeProxy(const Identity& id)
map<Identity, pair<IceUtil::Time, ObjectPrx> >::iterator p = _objectMap.find(id);
if(p == _objectMap.end())
{
- return 0;
+ return 0;
}
ObjectPrx proxy = p->second.second;
@@ -234,11 +234,11 @@ IceInternal::LocatorTable::checkTTL(const IceUtil::Time& time, int ttl) const
assert(ttl != 0);
if (ttl < 0) // TTL = infinite
{
- return true;
+ return true;
}
else
{
- return IceUtil::Time::now() - time <= IceUtil::Time::seconds(ttl);
+ return IceUtil::Time::now() - time <= IceUtil::Time::seconds(ttl);
}
}
@@ -293,12 +293,12 @@ IceInternal::LocatorInfo::getLocatorRegistry()
if(!_locatorRegistry) // Lazy initialization.
{
- _locatorRegistry = _locator->getRegistry();
+ _locatorRegistry = _locator->getRegistry();
- //
- // The locator registry can't be located.
- //
- _locatorRegistry = LocatorRegistryPrx::uncheckedCast(_locatorRegistry->ice_locator(0));
+ //
+ // The locator registry can't be located.
+ //
+ _locatorRegistry = LocatorRegistryPrx::uncheckedCast(_locatorRegistry->ice_locator(0));
}
return _locatorRegistry;
@@ -312,156 +312,156 @@ IceInternal::LocatorInfo::getEndpoints(const IndirectReferencePtr& ref, int ttl,
cached = true;
try
{
- if(!ref->getAdapterId().empty())
- {
- if(!_table->getAdapterEndpoints(ref->getAdapterId(), ttl, endpoints))
- {
- cached = false;
-
- if(ref->getInstance()->traceLevels()->location >= 1)
- {
- Trace out(ref->getInstance()->initializationData().logger,
- ref->getInstance()->traceLevels()->locationCat);
- out << "searching for adapter by id" << "\n";
- out << "adapter = " << ref->getAdapterId();
- }
-
- object = _locator->findAdapterById(ref->getAdapterId());
- if(object)
- {
- endpoints = object->__reference()->getEndpoints();
- _table->addAdapterEndpoints(ref->getAdapterId(), endpoints);
- }
- }
- }
- else
- {
- bool objectCached = true;
- if(!_table->getProxy(ref->getIdentity(), ttl, object))
- {
- if(ref->getInstance()->traceLevels()->location >= 1)
- {
- Trace out(ref->getInstance()->initializationData().logger,
- ref->getInstance()->traceLevels()->locationCat);
- out << "searching for object by id" << "\n";
- out << "object = " << ref->getInstance()->identityToString(ref->getIdentity());
- }
-
- objectCached = false;
- object = _locator->findObjectById(ref->getIdentity());
- }
-
- bool endpointsCached = true;
- if(object)
- {
- DirectReferencePtr odr = DirectReferencePtr::dynamicCast(object->__reference());
- if(odr)
- {
- endpointsCached = false;
- endpoints = odr->getEndpoints();
- }
- else
- {
- IndirectReferencePtr oir = IndirectReferencePtr::dynamicCast(object->__reference());
- assert(oir);
- if(!oir->getAdapterId().empty())
- {
- endpoints = getEndpoints(oir, ttl, endpointsCached);
- }
- }
- }
-
- if(!objectCached && !endpoints.empty())
- {
- _table->addProxy(ref->getIdentity(), object);
- }
-
- cached = objectCached || endpointsCached;
- }
+ if(!ref->getAdapterId().empty())
+ {
+ if(!_table->getAdapterEndpoints(ref->getAdapterId(), ttl, endpoints))
+ {
+ cached = false;
+
+ if(ref->getInstance()->traceLevels()->location >= 1)
+ {
+ Trace out(ref->getInstance()->initializationData().logger,
+ ref->getInstance()->traceLevels()->locationCat);
+ out << "searching for adapter by id" << "\n";
+ out << "adapter = " << ref->getAdapterId();
+ }
+
+ object = _locator->findAdapterById(ref->getAdapterId());
+ if(object)
+ {
+ endpoints = object->__reference()->getEndpoints();
+ _table->addAdapterEndpoints(ref->getAdapterId(), endpoints);
+ }
+ }
+ }
+ else
+ {
+ bool objectCached = true;
+ if(!_table->getProxy(ref->getIdentity(), ttl, object))
+ {
+ if(ref->getInstance()->traceLevels()->location >= 1)
+ {
+ Trace out(ref->getInstance()->initializationData().logger,
+ ref->getInstance()->traceLevels()->locationCat);
+ out << "searching for object by id" << "\n";
+ out << "object = " << ref->getInstance()->identityToString(ref->getIdentity());
+ }
+
+ objectCached = false;
+ object = _locator->findObjectById(ref->getIdentity());
+ }
+
+ bool endpointsCached = true;
+ if(object)
+ {
+ DirectReferencePtr odr = DirectReferencePtr::dynamicCast(object->__reference());
+ if(odr)
+ {
+ endpointsCached = false;
+ endpoints = odr->getEndpoints();
+ }
+ else
+ {
+ IndirectReferencePtr oir = IndirectReferencePtr::dynamicCast(object->__reference());
+ assert(oir);
+ if(!oir->getAdapterId().empty())
+ {
+ endpoints = getEndpoints(oir, ttl, endpointsCached);
+ }
+ }
+ }
+
+ if(!objectCached && !endpoints.empty())
+ {
+ _table->addProxy(ref->getIdentity(), object);
+ }
+
+ cached = objectCached || endpointsCached;
+ }
}
catch(const AdapterNotFoundException&)
{
- if(ref->getInstance()->traceLevels()->location >= 1)
- {
- Trace out(ref->getInstance()->initializationData().logger,
- ref->getInstance()->traceLevels()->locationCat);
- out << "adapter not found" << "\n";
- out << "adapter = " << ref->getAdapterId();
+ if(ref->getInstance()->traceLevels()->location >= 1)
+ {
+ Trace out(ref->getInstance()->initializationData().logger,
+ ref->getInstance()->traceLevels()->locationCat);
+ out << "adapter not found" << "\n";
+ out << "adapter = " << ref->getAdapterId();
}
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "object adapter";
- ex.id = ref->getAdapterId();
- throw ex;
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "object adapter";
+ ex.id = ref->getAdapterId();
+ throw ex;
}
catch(const ObjectNotFoundException&)
{
- if(ref->getInstance()->traceLevels()->location >= 1)
- {
- Trace out(ref->getInstance()->initializationData().logger,
- ref->getInstance()->traceLevels()->locationCat);
- out << "object not found" << "\n";
- out << "object = " << ref->getInstance()->identityToString(ref->getIdentity());
+ if(ref->getInstance()->traceLevels()->location >= 1)
+ {
+ Trace out(ref->getInstance()->initializationData().logger,
+ ref->getInstance()->traceLevels()->locationCat);
+ out << "object not found" << "\n";
+ out << "object = " << ref->getInstance()->identityToString(ref->getIdentity());
}
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "object";
- ex.id = ref->getInstance()->identityToString(ref->getIdentity());
- throw ex;
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "object";
+ ex.id = ref->getInstance()->identityToString(ref->getIdentity());
+ throw ex;
}
catch(const NotRegisteredException&)
{
- throw;
+ throw;
}
catch(const LocalException& ex)
{
- if(ref->getInstance()->traceLevels()->location >= 1)
- {
- Trace out(ref->getInstance()->initializationData().logger,
- ref->getInstance()->traceLevels()->locationCat);
- out << "couldn't contact the locator to retrieve adapter endpoints\n";
- if(ref->getAdapterId().empty())
- {
- out << "object = " << ref->getInstance()->identityToString(ref->getIdentity()) << "\n";
- }
- else
- {
- out << "adapter = " << ref->getAdapterId() << "\n";
- }
- out << "reason = " << ex;
- }
- throw;
+ if(ref->getInstance()->traceLevels()->location >= 1)
+ {
+ Trace out(ref->getInstance()->initializationData().logger,
+ ref->getInstance()->traceLevels()->locationCat);
+ out << "couldn't contact the locator to retrieve adapter endpoints\n";
+ if(ref->getAdapterId().empty())
+ {
+ out << "object = " << ref->getInstance()->identityToString(ref->getIdentity()) << "\n";
+ }
+ else
+ {
+ out << "adapter = " << ref->getAdapterId() << "\n";
+ }
+ out << "reason = " << ex;
+ }
+ throw;
}
if(ref->getInstance()->traceLevels()->location >= 1)
{
if(!endpoints.empty())
- {
- if(cached)
- {
- trace("found endpoints in locator table", ref, endpoints);
- }
- else
- {
- trace("retrieved endpoints from locator, adding to locator table", ref, endpoints);
- }
- }
- else
- {
- Trace out(ref->getInstance()->initializationData().logger, ref->getInstance()->traceLevels()->locationCat);
- out << "no endpoints configured for ";
- if(ref->getAdapterId().empty())
- {
- out << "object\n";
- out << "object = " << ref->getInstance()->identityToString(ref->getIdentity());
- }
- else
- {
- out << "adapter\n";
- out << "adapter = " << ref->getAdapterId();
- }
- }
+ {
+ if(cached)
+ {
+ trace("found endpoints in locator table", ref, endpoints);
+ }
+ else
+ {
+ trace("retrieved endpoints from locator, adding to locator table", ref, endpoints);
+ }
+ }
+ else
+ {
+ Trace out(ref->getInstance()->initializationData().logger, ref->getInstance()->traceLevels()->locationCat);
+ out << "no endpoints configured for ";
+ if(ref->getAdapterId().empty())
+ {
+ out << "object\n";
+ out << "object = " << ref->getInstance()->identityToString(ref->getIdentity());
+ }
+ else
+ {
+ out << "adapter\n";
+ out << "adapter = " << ref->getAdapterId();
+ }
+ }
}
return endpoints;
@@ -472,25 +472,25 @@ IceInternal::LocatorInfo::clearObjectCache(const IndirectReferencePtr& ref)
{
if(ref->getAdapterId().empty())
{
- ObjectPrx object = _table->removeProxy(ref->getIdentity());
- if(object)
- {
- IndirectReferencePtr oir = IndirectReferencePtr::dynamicCast(object->__reference());
- if(oir)
- {
- if(!oir->getAdapterId().empty())
- {
- clearCache(oir);
- }
- }
- else
- {
- if(ref->getInstance()->traceLevels()->location >= 2)
- {
- trace("removed endpoints from locator table", ref, object->__reference()->getEndpoints());
- }
- }
- }
+ ObjectPrx object = _table->removeProxy(ref->getIdentity());
+ if(object)
+ {
+ IndirectReferencePtr oir = IndirectReferencePtr::dynamicCast(object->__reference());
+ if(oir)
+ {
+ if(!oir->getAdapterId().empty())
+ {
+ clearCache(oir);
+ }
+ }
+ else
+ {
+ if(ref->getInstance()->traceLevels()->location >= 2)
+ {
+ trace("removed endpoints from locator table", ref, object->__reference()->getEndpoints());
+ }
+ }
+ }
}
}
@@ -499,56 +499,56 @@ IceInternal::LocatorInfo::clearCache(const IndirectReferencePtr& ref)
{
if(!ref->getAdapterId().empty())
{
- vector<EndpointIPtr> endpoints = _table->removeAdapterEndpoints(ref->getAdapterId());
+ vector<EndpointIPtr> endpoints = _table->removeAdapterEndpoints(ref->getAdapterId());
- if(!endpoints.empty() && ref->getInstance()->traceLevels()->location >= 2)
- {
- trace("removed endpoints from locator table", ref, endpoints);
- }
+ if(!endpoints.empty() && ref->getInstance()->traceLevels()->location >= 2)
+ {
+ trace("removed endpoints from locator table", ref, endpoints);
+ }
}
else
{
- ObjectPrx object = _table->removeProxy(ref->getIdentity());
- if(object)
- {
- IndirectReferencePtr oir = IndirectReferencePtr::dynamicCast(object->__reference());
- if(oir)
- {
- if(!oir->getAdapterId().empty())
- {
- clearCache(oir);
- }
- }
- else
- {
- if(ref->getInstance()->traceLevels()->location >= 2)
- {
- trace("removed endpoints from locator table", ref, object->__reference()->getEndpoints());
- }
- }
- }
+ ObjectPrx object = _table->removeProxy(ref->getIdentity());
+ if(object)
+ {
+ IndirectReferencePtr oir = IndirectReferencePtr::dynamicCast(object->__reference());
+ if(oir)
+ {
+ if(!oir->getAdapterId().empty())
+ {
+ clearCache(oir);
+ }
+ }
+ else
+ {
+ if(ref->getInstance()->traceLevels()->location >= 2)
+ {
+ trace("removed endpoints from locator table", ref, object->__reference()->getEndpoints());
+ }
+ }
+ }
}
}
void
IceInternal::LocatorInfo::trace(const string& msg,
- const IndirectReferencePtr& ref,
- const vector<EndpointIPtr>& endpoints)
+ const IndirectReferencePtr& ref,
+ const vector<EndpointIPtr>& endpoints)
{
Trace out(ref->getInstance()->initializationData().logger, ref->getInstance()->traceLevels()->locationCat);
out << msg << '\n';
if(!ref->getAdapterId().empty())
{
- out << "adapter = " << ref->getAdapterId() << '\n';
+ out << "adapter = " << ref->getAdapterId() << '\n';
}
else
{
- out << "object = " << ref->getInstance()->identityToString(ref->getIdentity()) << '\n';
+ out << "object = " << ref->getInstance()->identityToString(ref->getIdentity()) << '\n';
}
const char* sep = endpoints.size() > 1 ? ":" : "";
ostringstream o;
transform(endpoints.begin(), endpoints.end(), ostream_iterator<string>(o, sep),
- Ice::constMemFun(&Endpoint::toString));
+ Ice::constMemFun(&Endpoint::toString));
out << "endpoints = " << o.str();
}
diff --git a/cpp/src/Ice/LoggerI.cpp b/cpp/src/Ice/LoggerI.cpp
index d347e221d91..8e4aef6f8fa 100644
--- a/cpp/src/Ice/LoggerI.cpp
+++ b/cpp/src/Ice/LoggerI.cpp
@@ -21,7 +21,7 @@ Ice::LoggerI::LoggerI(const string& prefix)
{
if(!prefix.empty())
{
- _prefix = prefix + ": ";
+ _prefix = prefix + ": ";
}
}
@@ -46,8 +46,8 @@ Ice::LoggerI::trace(const string& category, const string& message)
string::size_type idx = 0;
while((idx = s.find("\n", idx)) != string::npos)
{
- s.insert(idx + 1, " ");
- ++idx;
+ s.insert(idx + 1, " ");
+ ++idx;
}
IceUtil::StaticMutex::Lock sync(outputMutex);
diff --git a/cpp/src/Ice/LoggerUtil.cpp b/cpp/src/Ice/LoggerUtil.cpp
index ca888e23688..6d6f907ee61 100644
--- a/cpp/src/Ice/LoggerUtil.cpp
+++ b/cpp/src/Ice/LoggerUtil.cpp
@@ -30,7 +30,7 @@ Ice::Print::flush()
string s = _str.str();
if(!s.empty())
{
- _logger->print(s);
+ _logger->print(s);
}
_str.str("");
}
@@ -64,7 +64,7 @@ Ice::Warning::flush()
string s = _str.str();
if(!s.empty())
{
- _logger->warning(s);
+ _logger->warning(s);
}
_str.str("");
}
@@ -98,7 +98,7 @@ Ice::Error::flush()
string s = _str.str();
if(!s.empty())
{
- _logger->error(s);
+ _logger->error(s);
}
_str.str("");
}
@@ -133,7 +133,7 @@ Ice::Trace::flush()
string s = _str.str();
if(!s.empty())
{
- _logger->trace(_category, s);
+ _logger->trace(_category, s);
}
_str.str("");
}
diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp
index 9cc42da481c..737f2f3f148 100644
--- a/cpp/src/Ice/Network.cpp
+++ b/cpp/src/Ice/Network.cpp
@@ -73,7 +73,7 @@ IceInternal::acceptInterrupted()
{
if(interrupted())
{
- return true;
+ return true;
}
#ifdef _WIN32
@@ -168,7 +168,7 @@ IceInternal::connectionLost()
errno == ENOTCONN ||
errno == ESHUTDOWN ||
errno == ECONNABORTED ||
- errno == EPIPE;
+ errno == EPIPE;
#endif
}
@@ -200,24 +200,24 @@ IceInternal::createSocket(bool udp)
if(udp)
{
- fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
}
else
{
- fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ fd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
}
if(fd == INVALID_SOCKET)
{
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
if(!udp)
{
- setTcpNoDelay(fd);
- setKeepAlive(fd);
+ setTcpNoDelay(fd);
+ setKeepAlive(fd);
}
return fd;
@@ -230,18 +230,18 @@ IceInternal::closeSocket(SOCKET fd)
int error = WSAGetLastError();
if(closesocket(fd) == SOCKET_ERROR)
{
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
WSASetLastError(error);
#else
int error = errno;
if(close(fd) == SOCKET_ERROR)
{
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
errno = error;
#endif
@@ -266,29 +266,29 @@ IceInternal::shutdownSocketWrite(SOCKET fd)
{
if(shutdown(fd, SHUT_WR) == SOCKET_ERROR)
{
- //
- // Ignore errors indicating that we are shutdown already.
- //
+ //
+ // Ignore errors indicating that we are shutdown already.
+ //
#if defined(_WIN32)
- int error = WSAGetLastError();
- if(error == WSAENOTCONN)
- {
- return;
- }
+ int error = WSAGetLastError();
+ if(error == WSAENOTCONN)
+ {
+ return;
+ }
#elif defined(__APPLE__)
- if(errno == ENOTCONN || errno == EINVAL)
- {
- return;
- }
+ if(errno == ENOTCONN || errno == EINVAL)
+ {
+ return;
+ }
#else
- if(errno == ENOTCONN)
- {
- return;
- }
+ if(errno == ENOTCONN)
+ {
+ return;
+ }
#endif
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
}
@@ -297,30 +297,30 @@ IceInternal::shutdownSocketReadWrite(SOCKET fd)
{
if(shutdown(fd, SHUT_RDWR) == SOCKET_ERROR)
{
- //
- // Ignore errors indicating that we are shutdown already.
- //
+ //
+ // Ignore errors indicating that we are shutdown already.
+ //
#if defined(_WIN32)
- int error = WSAGetLastError();
- if(error == WSAENOTCONN)
- {
- return;
- }
+ int error = WSAGetLastError();
+ if(error == WSAENOTCONN)
+ {
+ return;
+ }
#elif defined(__APPLE__)
- if(errno == ENOTCONN || errno == EINVAL)
- {
- return;
- }
+ if(errno == ENOTCONN || errno == EINVAL)
+ {
+ return;
+ }
#else
- if(errno == ENOTCONN)
- {
- return;
- }
+ if(errno == ENOTCONN)
+ {
+ return;
+ }
#endif
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
}
@@ -330,47 +330,47 @@ IceInternal::setBlock(SOCKET fd, bool block)
if(block)
{
#ifdef _WIN32
- unsigned long arg = 0;
- if(ioctlsocket(fd, FIONBIO, &arg) == SOCKET_ERROR)
- {
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = WSAGetLastError();
- throw ex;
- }
+ unsigned long arg = 0;
+ if(ioctlsocket(fd, FIONBIO, &arg) == SOCKET_ERROR)
+ {
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = WSAGetLastError();
+ throw ex;
+ }
#else
- int flags = fcntl(fd, F_GETFL);
- flags &= ~O_NONBLOCK;
- if(fcntl(fd, F_SETFL, flags) == SOCKET_ERROR)
- {
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = errno;
- throw ex;
- }
+ int flags = fcntl(fd, F_GETFL);
+ flags &= ~O_NONBLOCK;
+ if(fcntl(fd, F_SETFL, flags) == SOCKET_ERROR)
+ {
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = errno;
+ throw ex;
+ }
#endif
}
else
{
#ifdef _WIN32
- unsigned long arg = 1;
- if(ioctlsocket(fd, FIONBIO, &arg) == SOCKET_ERROR)
- {
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = WSAGetLastError();
- throw ex;
- }
+ unsigned long arg = 1;
+ if(ioctlsocket(fd, FIONBIO, &arg) == SOCKET_ERROR)
+ {
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = WSAGetLastError();
+ throw ex;
+ }
#else
- int flags = fcntl(fd, F_GETFL);
- flags |= O_NONBLOCK;
- if(fcntl(fd, F_SETFL, flags) == SOCKET_ERROR)
- {
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = errno;
- throw ex;
- }
+ int flags = fcntl(fd, F_GETFL);
+ flags |= O_NONBLOCK;
+ if(fcntl(fd, F_SETFL, flags) == SOCKET_ERROR)
+ {
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = errno;
+ throw ex;
+ }
#endif
}
}
@@ -381,10 +381,10 @@ IceInternal::setTcpNoDelay(SOCKET fd)
int flag = 1;
if(setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char*)&flag, int(sizeof(int))) == SOCKET_ERROR)
{
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
}
@@ -394,10 +394,10 @@ IceInternal::setKeepAlive(SOCKET fd)
int flag = 1;
if(setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char*)&flag, int(sizeof(int))) == SOCKET_ERROR)
{
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
}
@@ -406,10 +406,10 @@ IceInternal::setSendBufferSize(SOCKET fd, int sz)
{
if(setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*)&sz, int(sizeof(int))) == SOCKET_ERROR)
{
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
}
@@ -420,10 +420,10 @@ IceInternal::getSendBufferSize(SOCKET fd)
socklen_t len = sizeof(sz);
if(getsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*)&sz, &len) == SOCKET_ERROR || len != sizeof(sz))
{
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
return sz;
}
@@ -433,10 +433,10 @@ IceInternal::setRecvBufferSize(SOCKET fd, int sz)
{
if(setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*)&sz, int(sizeof(int))) == SOCKET_ERROR)
{
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
}
@@ -447,10 +447,10 @@ IceInternal::getRecvBufferSize(SOCKET fd)
socklen_t len = sizeof(sz);
if(getsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*)&sz, &len) == SOCKET_ERROR || len != sizeof(sz))
{
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
return sz;
}
@@ -462,19 +462,19 @@ IceInternal::doBind(SOCKET fd, struct sockaddr_in& addr)
int flag = 1;
if(setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&flag, int(sizeof(int))) == SOCKET_ERROR)
{
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
#endif
if(bind(fd, reinterpret_cast<struct sockaddr*>(&addr), int(sizeof(addr))) == SOCKET_ERROR)
{
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
socklen_t len = static_cast<socklen_t>(sizeof(addr));
@@ -492,15 +492,15 @@ IceInternal::doListen(SOCKET fd, int backlog)
repeatListen:
if(::listen(fd, backlog) == SOCKET_ERROR)
{
- if(interrupted())
- {
- goto repeatListen;
- }
-
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ if(interrupted())
+ {
+ goto repeatListen;
+ }
+
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
}
@@ -522,173 +522,173 @@ IceInternal::doConnect(SOCKET fd, struct sockaddr_in& addr, int timeout)
WSAEVENT event = WSACreateEvent();
if(event == 0)
{
- closeSocketNoThrow(fd);
+ closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = WSAGetLastError();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = WSAGetLastError();
+ throw ex;
}
if(WSAEventSelect(fd, event, FD_CONNECT) == SOCKET_ERROR)
{
- int error = WSAGetLastError();
+ int error = WSAGetLastError();
- WSACloseEvent(event);
- closeSocketNoThrow(fd);
+ WSACloseEvent(event);
+ closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = error;
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = error;
+ throw ex;
}
#endif
repeatConnect:
if(::connect(fd, reinterpret_cast<struct sockaddr*>(&addr), int(sizeof(addr))) == SOCKET_ERROR)
{
- if(interrupted())
- {
- goto repeatConnect;
- }
-
- if(connectInProgress())
- {
- int val;
+ if(interrupted())
+ {
+ goto repeatConnect;
+ }
+
+ if(connectInProgress())
+ {
+ int val;
#ifdef _WIN32
- WSAEVENT events[1];
- events[0] = event;
- long tout = (timeout >= 0) ? timeout : WSA_INFINITE;
- DWORD rc = WSAWaitForMultipleEvents(1, events, FALSE, tout, FALSE);
- if(rc == WSA_WAIT_FAILED)
- {
- int error = WSAGetLastError();
-
- WSACloseEvent(event);
- closeSocketNoThrow(fd);
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = error;
- throw ex;
- }
-
- if(rc == WSA_WAIT_TIMEOUT)
- {
- WSACloseEvent(event);
- closeSocketNoThrow(fd);
-
- assert(timeout >= 0);
- throw ConnectTimeoutException(__FILE__, __LINE__);
- }
- assert(rc == WSA_WAIT_EVENT_0);
-
- WSANETWORKEVENTS nevents;
- if(WSAEnumNetworkEvents(fd, event, &nevents) == SOCKET_ERROR)
- {
- int error = WSAGetLastError();
- WSACloseEvent(event);
- closeSocketNoThrow(fd);
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = error;
- throw ex;
- }
-
- //
- // Now we close the event, because we're finished and
- // this code be repeated.
- //
- WSACloseEvent(event);
-
- assert(nevents.lNetworkEvents & FD_CONNECT);
- val = nevents.iErrorCode[FD_CONNECT_BIT];
+ WSAEVENT events[1];
+ events[0] = event;
+ long tout = (timeout >= 0) ? timeout : WSA_INFINITE;
+ DWORD rc = WSAWaitForMultipleEvents(1, events, FALSE, tout, FALSE);
+ if(rc == WSA_WAIT_FAILED)
+ {
+ int error = WSAGetLastError();
+
+ WSACloseEvent(event);
+ closeSocketNoThrow(fd);
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = error;
+ throw ex;
+ }
+
+ if(rc == WSA_WAIT_TIMEOUT)
+ {
+ WSACloseEvent(event);
+ closeSocketNoThrow(fd);
+
+ assert(timeout >= 0);
+ throw ConnectTimeoutException(__FILE__, __LINE__);
+ }
+ assert(rc == WSA_WAIT_EVENT_0);
+
+ WSANETWORKEVENTS nevents;
+ if(WSAEnumNetworkEvents(fd, event, &nevents) == SOCKET_ERROR)
+ {
+ int error = WSAGetLastError();
+ WSACloseEvent(event);
+ closeSocketNoThrow(fd);
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = error;
+ throw ex;
+ }
+
+ //
+ // Now we close the event, because we're finished and
+ // this code be repeated.
+ //
+ WSACloseEvent(event);
+
+ assert(nevents.lNetworkEvents & FD_CONNECT);
+ val = nevents.iErrorCode[FD_CONNECT_BIT];
#else
- repeatPoll:
- struct pollfd pollFd[1];
- pollFd[0].fd = fd;
- pollFd[0].events = POLLOUT;
- int ret = ::poll(pollFd, 1, timeout);
- if(ret == 0)
- {
- closeSocketNoThrow(fd);
- throw ConnectTimeoutException(__FILE__, __LINE__);
- }
- else if(ret == SOCKET_ERROR)
- {
- if(interrupted())
- {
- goto repeatPoll;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
-
- //
- // Strange windows bug: The following call to Sleep() is
- // necessary, otherwise no error is reported through
- // getsockopt.
- //
- //Sleep(0);
- socklen_t len = static_cast<socklen_t>(sizeof(int));
- if(getsockopt(fd, SOL_SOCKET, SO_ERROR, reinterpret_cast<char*>(&val), &len) == SOCKET_ERROR)
- {
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
+ repeatPoll:
+ struct pollfd pollFd[1];
+ pollFd[0].fd = fd;
+ pollFd[0].events = POLLOUT;
+ int ret = ::poll(pollFd, 1, timeout);
+ if(ret == 0)
+ {
+ closeSocketNoThrow(fd);
+ throw ConnectTimeoutException(__FILE__, __LINE__);
+ }
+ else if(ret == SOCKET_ERROR)
+ {
+ if(interrupted())
+ {
+ goto repeatPoll;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+
+ //
+ // Strange windows bug: The following call to Sleep() is
+ // necessary, otherwise no error is reported through
+ // getsockopt.
+ //
+ //Sleep(0);
+ socklen_t len = static_cast<socklen_t>(sizeof(int));
+ if(getsockopt(fd, SOL_SOCKET, SO_ERROR, reinterpret_cast<char*>(&val), &len) == SOCKET_ERROR)
+ {
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
#endif
-
- if(val > 0)
- {
- closeSocketNoThrow(fd);
+
+ if(val > 0)
+ {
+ closeSocketNoThrow(fd);
#ifdef _WIN32
- WSASetLastError(val);
+ WSASetLastError(val);
#else
- errno = val;
+ errno = val;
#endif
- if(connectionRefused())
- {
- ConnectionRefusedException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- else if(connectFailed())
- {
- ConnectFailedException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- else
- {
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- }
-
- return;
- }
+ if(connectionRefused())
+ {
+ ConnectionRefusedException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ else if(connectFailed())
+ {
+ ConnectFailedException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ else
+ {
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ }
+
+ return;
+ }
- closeSocketNoThrow(fd);
- if(connectionRefused())
- {
- ConnectionRefusedException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- else if(connectFailed())
- {
- ConnectFailedException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- else
- {
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
+ closeSocketNoThrow(fd);
+ if(connectionRefused())
+ {
+ ConnectionRefusedException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ else if(connectFailed())
+ {
+ ConnectFailedException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ else
+ {
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
}
}
@@ -704,60 +704,60 @@ IceInternal::doAccept(SOCKET fd, int timeout)
repeatAccept:
if((ret = ::accept(fd, 0, 0)) == INVALID_SOCKET)
{
- if(acceptInterrupted())
- {
- goto repeatAccept;
- }
-
- if(wouldBlock())
- {
- repeatSelect:
- int rs;
+ if(acceptInterrupted())
+ {
+ goto repeatAccept;
+ }
+
+ if(wouldBlock())
+ {
+ repeatSelect:
+ int rs;
#ifdef _WIN32
- fd_set fdSet;
- FD_ZERO(&fdSet);
- FD_SET(fd, &fdSet);
- if(timeout >= 0)
- {
- struct timeval tv;
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000;
- rs = ::select(static_cast<int>(fd + 1), &fdSet, 0, 0, &tv);
- }
- else
- {
- rs = ::select(static_cast<int>(fd + 1), &fdSet, 0, 0, 0);
- }
+ fd_set fdSet;
+ FD_ZERO(&fdSet);
+ FD_SET(fd, &fdSet);
+ if(timeout >= 0)
+ {
+ struct timeval tv;
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000;
+ rs = ::select(static_cast<int>(fd + 1), &fdSet, 0, 0, &tv);
+ }
+ else
+ {
+ rs = ::select(static_cast<int>(fd + 1), &fdSet, 0, 0, 0);
+ }
#else
- struct pollfd pollFd[1];
- pollFd[0].fd = fd;
- pollFd[0].events = POLLIN;
- rs = ::poll(pollFd, 1, timeout);
+ struct pollfd pollFd[1];
+ pollFd[0].fd = fd;
+ pollFd[0].events = POLLIN;
+ rs = ::poll(pollFd, 1, timeout);
#endif
-
- if(rs == SOCKET_ERROR)
- {
- if(interrupted())
- {
- goto repeatSelect;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
-
- if(rs == 0)
- {
- throw TimeoutException(__FILE__, __LINE__);
- }
-
- goto repeatAccept;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+
+ if(rs == SOCKET_ERROR)
+ {
+ if(interrupted())
+ {
+ goto repeatSelect;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+
+ if(rs == 0)
+ {
+ throw TimeoutException(__FILE__, __LINE__);
+ }
+
+ goto repeatAccept;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
setTcpNoDelay(ret);
@@ -786,59 +786,59 @@ IceInternal::getAddress(const string& host, int port, struct sockaddr_in& addr)
{
#ifdef _WIN32
- //
- // Windows XP has getaddrinfo(), but we don't want to require XP to run Ice.
- //
-
- //
- // gethostbyname() is thread safe on Windows, with a separate hostent per thread
- //
- struct hostent* entry;
- int retry = 5;
- do
- {
- entry = gethostbyname(host.c_str());
- }
- while(entry == 0 && WSAGetLastError() == WSATRY_AGAIN && --retry >= 0);
-
- if(entry == 0)
- {
- DNSException ex(__FILE__, __LINE__);
-
- ex.error = WSAGetLastError();
- ex.host = host;
- throw ex;
- }
- memcpy(&addr.sin_addr, entry->h_addr, entry->h_length);
+ //
+ // Windows XP has getaddrinfo(), but we don't want to require XP to run Ice.
+ //
+
+ //
+ // gethostbyname() is thread safe on Windows, with a separate hostent per thread
+ //
+ struct hostent* entry;
+ int retry = 5;
+ do
+ {
+ entry = gethostbyname(host.c_str());
+ }
+ while(entry == 0 && WSAGetLastError() == WSATRY_AGAIN && --retry >= 0);
+
+ if(entry == 0)
+ {
+ DNSException ex(__FILE__, __LINE__);
+
+ ex.error = WSAGetLastError();
+ ex.host = host;
+ throw ex;
+ }
+ memcpy(&addr.sin_addr, entry->h_addr, entry->h_length);
#else
- struct addrinfo* info = 0;
- int retry = 5;
-
- struct addrinfo hints = { 0 };
- hints.ai_family = PF_INET;
-
- int rs = 0;
- do
- {
- rs = getaddrinfo(host.c_str(), 0, &hints, &info);
- }
- while(info == 0 && rs == EAI_AGAIN && --retry >= 0);
-
- if(rs != 0)
- {
- DNSException ex(__FILE__, __LINE__);
- ex.error = rs;
- ex.host = host;
- throw ex;
- }
-
- assert(info->ai_family == PF_INET);
- struct sockaddr_in* sin = reinterpret_cast<sockaddr_in*>(info->ai_addr);
-
- addr.sin_addr.s_addr = sin->sin_addr.s_addr;
- freeaddrinfo(info);
+ struct addrinfo* info = 0;
+ int retry = 5;
+
+ struct addrinfo hints = { 0 };
+ hints.ai_family = PF_INET;
+
+ int rs = 0;
+ do
+ {
+ rs = getaddrinfo(host.c_str(), 0, &hints, &info);
+ }
+ while(info == 0 && rs == EAI_AGAIN && --retry >= 0);
+
+ if(rs != 0)
+ {
+ DNSException ex(__FILE__, __LINE__);
+ ex.error = rs;
+ ex.host = host;
+ throw ex;
+ }
+
+ assert(info->ai_family == PF_INET);
+ struct sockaddr_in* sin = reinterpret_cast<sockaddr_in*>(info->ai_addr);
+
+ addr.sin_addr.s_addr = sin->sin_addr.s_addr;
+ freeaddrinfo(info);
#endif
}
@@ -871,12 +871,12 @@ IceInternal::createPipe(SOCKET fds[2])
try
{
- fds[0] = createSocket(false);
+ fds[0] = createSocket(false);
}
catch(...)
{
- ::closesocket(fd);
- throw;
+ ::closesocket(fd);
+ throw;
}
try
@@ -886,19 +886,19 @@ IceInternal::createPipe(SOCKET fds[2])
}
catch(...)
{
- ::closesocket(fd);
- throw;
+ ::closesocket(fd);
+ throw;
}
try
{
- fds[1] = doAccept(fd, -1);
+ fds[1] = doAccept(fd, -1);
}
catch(...)
{
- ::closesocket(fds[0]);
- ::closesocket(fd);
- throw;
+ ::closesocket(fds[0]);
+ ::closesocket(fd);
+ throw;
}
::closesocket(fd);
@@ -909,18 +909,18 @@ IceInternal::createPipe(SOCKET fds[2])
}
catch(...)
{
- ::closesocket(fds[0]);
- ::closesocket(fd);
- throw;
+ ::closesocket(fds[0]);
+ ::closesocket(fd);
+ throw;
}
#else
if(::pipe(fds) != 0)
{
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
try
@@ -929,8 +929,8 @@ IceInternal::createPipe(SOCKET fds[2])
}
catch(...)
{
- closeSocketNoThrow(fds[1]);
- throw;
+ closeSocketNoThrow(fds[1]);
+ throw;
}
try
@@ -939,8 +939,8 @@ IceInternal::createPipe(SOCKET fds[2])
}
catch(...)
{
- closeSocketNoThrow(fds[0]);
- throw;
+ closeSocketNoThrow(fds[0]);
+ throw;
}
#endif
@@ -953,196 +953,196 @@ IceInternal::errorToString(int error)
{
if(error < WSABASEERR)
{
- LPVOID lpMsgBuf = 0;
- DWORD ok = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- error,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPTSTR)&lpMsgBuf,
- 0,
- NULL);
- if(ok)
- {
- LPCTSTR msg = (LPCTSTR)lpMsgBuf;
- assert(msg && strlen((const char*)msg) > 0);
- string result = (const char*)msg;
- if(result[result.length() - 1] == '\n')
- {
- result = result.substr(0, result.length() - 2);
- }
- LocalFree(lpMsgBuf);
- return result;
- }
- else
- {
- ostringstream os;
- os << "unknown error: " << error;
- return os.str();
- }
+ LPVOID lpMsgBuf = 0;
+ DWORD ok = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ error,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR)&lpMsgBuf,
+ 0,
+ NULL);
+ if(ok)
+ {
+ LPCTSTR msg = (LPCTSTR)lpMsgBuf;
+ assert(msg && strlen((const char*)msg) > 0);
+ string result = (const char*)msg;
+ if(result[result.length() - 1] == '\n')
+ {
+ result = result.substr(0, result.length() - 2);
+ }
+ LocalFree(lpMsgBuf);
+ return result;
+ }
+ else
+ {
+ ostringstream os;
+ os << "unknown error: " << error;
+ return os.str();
+ }
}
switch(error)
{
case WSAEINTR:
- return "WSAEINTR";
-
+ return "WSAEINTR";
+
case WSAEBADF:
- return "WSAEBADF";
-
+ return "WSAEBADF";
+
case WSAEACCES:
- return "WSAEACCES";
-
+ return "WSAEACCES";
+
case WSAEFAULT:
- return "WSAEFAULT";
-
+ return "WSAEFAULT";
+
case WSAEINVAL:
- return "WSAEINVAL";
-
+ return "WSAEINVAL";
+
case WSAEMFILE:
- return "WSAEMFILE";
-
+ return "WSAEMFILE";
+
case WSAEWOULDBLOCK:
- return "WSAEWOULDBLOCK";
-
+ return "WSAEWOULDBLOCK";
+
case WSAEINPROGRESS:
- return "WSAEINPROGRESS";
-
+ return "WSAEINPROGRESS";
+
case WSAEALREADY:
- return "WSAEALREADY";
-
+ return "WSAEALREADY";
+
case WSAENOTSOCK:
- return "WSAENOTSOCK";
-
+ return "WSAENOTSOCK";
+
case WSAEDESTADDRREQ:
- return "WSAEDESTADDRREQ";
-
+ return "WSAEDESTADDRREQ";
+
case WSAEMSGSIZE:
- return "WSAEMSGSIZE";
-
+ return "WSAEMSGSIZE";
+
case WSAEPROTOTYPE:
- return "WSAEPROTOTYPE";
-
+ return "WSAEPROTOTYPE";
+
case WSAENOPROTOOPT:
- return "WSAENOPROTOOPT";
-
+ return "WSAENOPROTOOPT";
+
case WSAEPROTONOSUPPORT:
- return "WSAEPROTONOSUPPORT";
-
+ return "WSAEPROTONOSUPPORT";
+
case WSAESOCKTNOSUPPORT:
- return "WSAESOCKTNOSUPPORT";
-
+ return "WSAESOCKTNOSUPPORT";
+
case WSAEOPNOTSUPP:
- return "WSAEOPNOTSUPP";
-
+ return "WSAEOPNOTSUPP";
+
case WSAEPFNOSUPPORT:
- return "WSAEPFNOSUPPORT";
-
+ return "WSAEPFNOSUPPORT";
+
case WSAEAFNOSUPPORT:
- return "WSAEAFNOSUPPORT";
-
+ return "WSAEAFNOSUPPORT";
+
case WSAEADDRINUSE:
- return "WSAEADDRINUSE";
-
+ return "WSAEADDRINUSE";
+
case WSAEADDRNOTAVAIL:
- return "WSAEADDRNOTAVAIL";
-
+ return "WSAEADDRNOTAVAIL";
+
case WSAENETDOWN:
- return "WSAENETDOWN";
-
+ return "WSAENETDOWN";
+
case WSAENETUNREACH:
- return "WSAENETUNREACH";
-
+ return "WSAENETUNREACH";
+
case WSAENETRESET:
- return "WSAENETRESET";
-
+ return "WSAENETRESET";
+
case WSAECONNABORTED:
- return "WSAECONNABORTED";
-
+ return "WSAECONNABORTED";
+
case WSAECONNRESET:
- return "WSAECONNRESET";
-
+ return "WSAECONNRESET";
+
case WSAENOBUFS:
- return "WSAENOBUFS";
-
+ return "WSAENOBUFS";
+
case WSAEISCONN:
- return "WSAEISCONN";
-
+ return "WSAEISCONN";
+
case WSAENOTCONN:
- return "WSAENOTCONN";
-
+ return "WSAENOTCONN";
+
case WSAESHUTDOWN:
- return "WSAESHUTDOWN";
-
+ return "WSAESHUTDOWN";
+
case WSAETOOMANYREFS:
- return "WSAETOOMANYREFS";
-
+ return "WSAETOOMANYREFS";
+
case WSAETIMEDOUT:
- return "WSAETIMEDOUT";
-
+ return "WSAETIMEDOUT";
+
case WSAECONNREFUSED:
- return "WSAECONNREFUSED";
-
+ return "WSAECONNREFUSED";
+
case WSAELOOP:
- return "WSAELOOP";
-
+ return "WSAELOOP";
+
case WSAENAMETOOLONG:
- return "WSAENAMETOOLONG";
-
+ return "WSAENAMETOOLONG";
+
case WSAEHOSTDOWN:
- return "WSAEHOSTDOWN";
-
+ return "WSAEHOSTDOWN";
+
case WSAEHOSTUNREACH:
- return "WSAEHOSTUNREACH";
-
+ return "WSAEHOSTUNREACH";
+
case WSAENOTEMPTY:
- return "WSAENOTEMPTY";
-
+ return "WSAENOTEMPTY";
+
case WSAEPROCLIM:
- return "WSAEPROCLIM";
-
+ return "WSAEPROCLIM";
+
case WSAEUSERS:
- return "WSAEUSERS";
-
+ return "WSAEUSERS";
+
case WSAEDQUOT:
- return "WSAEDQUOT";
-
+ return "WSAEDQUOT";
+
case WSAESTALE:
- return "WSAESTALE";
-
+ return "WSAESTALE";
+
case WSAEREMOTE:
- return "WSAEREMOTE";
-
+ return "WSAEREMOTE";
+
case WSAEDISCON:
- return "WSAEDISCON";
-
+ return "WSAEDISCON";
+
case WSASYSNOTREADY:
- return "WSASYSNOTREADY";
-
+ return "WSASYSNOTREADY";
+
case WSAVERNOTSUPPORTED:
- return "WSAVERNOTSUPPORTED";
-
+ return "WSAVERNOTSUPPORTED";
+
case WSANOTINITIALISED:
- return "WSANOTINITIALISED";
-
+ return "WSANOTINITIALISED";
+
case WSAHOST_NOT_FOUND:
- return "WSAHOST_NOT_FOUND";
-
+ return "WSAHOST_NOT_FOUND";
+
case WSATRY_AGAIN:
- return "WSATRY_AGAIN";
-
+ return "WSATRY_AGAIN";
+
case WSANO_RECOVERY:
- return "WSANO_RECOVERY";
-
+ return "WSANO_RECOVERY";
+
case WSANO_DATA:
- return "WSANO_DATA";
+ return "WSANO_DATA";
default:
{
- ostringstream os;
- os << "unknown socket error: " << error;
- return os.str();
+ ostringstream os;
+ os << "unknown socket error: " << error;
+ return os.str();
}
}
}
@@ -1184,7 +1184,7 @@ IceInternal::fdToString(SOCKET fd)
{
if(fd == INVALID_SOCKET)
{
- return "<closed>";
+ return "<closed>";
}
struct sockaddr_in localAddr;
@@ -1197,11 +1197,11 @@ IceInternal::fdToString(SOCKET fd)
s << "local address = " << addrToString(localAddr);
if(peerConnected)
{
- s << "\nremote address = " << addrToString(remoteAddr);
+ s << "\nremote address = " << addrToString(remoteAddr);
}
else
{
- s << "\nremote address = <not connected>";
+ s << "\nremote address = <not connected>";
}
return s.str();
}
@@ -1212,10 +1212,10 @@ IceInternal::fdToLocalAddress(SOCKET fd, struct sockaddr_in& addr)
socklen_t len = static_cast<socklen_t>(sizeof(struct sockaddr_in));
if(getsockname(fd, reinterpret_cast<struct sockaddr*>(&addr), &len) == SOCKET_ERROR)
{
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
}
@@ -1225,17 +1225,17 @@ IceInternal::fdToRemoteAddress(SOCKET fd, struct sockaddr_in& addr)
socklen_t len = static_cast<socklen_t>(sizeof(struct sockaddr_in));
if(getpeername(fd, reinterpret_cast<struct sockaddr*>(&addr), &len) == SOCKET_ERROR)
{
- if(notConnected())
- {
- return false;
- }
- else
- {
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
+ if(notConnected())
+ {
+ return false;
+ }
+ else
+ {
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
}
return true;
@@ -1275,10 +1275,10 @@ IceInternal::getLocalHosts()
if(curr->ifa_addr && curr->ifa_addr->sa_family == AF_INET)
{
struct sockaddr_in* addr = reinterpret_cast<struct sockaddr_in*>(curr->ifa_addr);
- if(addr->sin_addr.s_addr != 0)
- {
- result.push_back(inetAddrToString((*addr).sin_addr));
- }
+ if(addr->sin_addr.s_addr != 0)
+ {
+ result.push_back(inetAddrToString((*addr).sin_addr));
+ }
}
curr = curr->ifa_next;
@@ -1312,17 +1312,17 @@ IceInternal::getLocalHosts()
int rs = ioctl(fd, cmd, &ifc);
if(rs == SOCKET_ERROR)
{
- free(ifc.ifc_buf);
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ free(ifc.ifc_buf);
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
else if(ifc.ifc_len == old_ifc_len)
{
//
- // Returned same length twice in a row, finished.
- //
+ // Returned same length twice in a row, finished.
+ //
break;
}
else
@@ -1341,10 +1341,10 @@ IceInternal::getLocalHosts()
if(ifr[i].ifr_addr.sa_family == AF_INET)
{
struct sockaddr_in* addr = reinterpret_cast<struct sockaddr_in*>(&ifr[i].ifr_addr);
- if(addr->sin_addr.s_addr != 0)
- {
- result.push_back(inetAddrToString((*addr).sin_addr));
- }
+ if(addr->sin_addr.s_addr != 0)
+ {
+ result.push_back(inetAddrToString((*addr).sin_addr));
+ }
}
}
@@ -1368,8 +1368,8 @@ IceInternal::getLocalAddresses()
buffer.resize(1024);
unsigned long len = 0;
DWORD rs = WSAIoctl(fd, SIO_ADDRESS_LIST_QUERY, 0, 0,
- &buffer[0], static_cast<DWORD>(buffer.size()),
- &len, 0, 0);
+ &buffer[0], static_cast<DWORD>(buffer.size()),
+ &len, 0, 0);
if(rs == SOCKET_ERROR)
{
//
@@ -1380,8 +1380,8 @@ IceInternal::getLocalAddresses()
{
buffer.resize(len);
rs = WSAIoctl(fd, SIO_ADDRESS_LIST_QUERY, 0, 0,
- &buffer[0], static_cast<DWORD>(buffer.size()),
- &len, 0, 0);
+ &buffer[0], static_cast<DWORD>(buffer.size()),
+ &len, 0, 0);
}
if(rs == SOCKET_ERROR)
@@ -1433,17 +1433,17 @@ IceInternal::isLocalAddress(const struct sockaddr_in& addr)
vector<struct sockaddr_in> localAddrs = getLocalAddresses();
for(vector<struct sockaddr_in>::const_iterator p = localAddrs.begin(); p != localAddrs.end(); ++p)
{
- if(compareAddress(addr0, *p))
- {
- return true;
- }
+ if(compareAddress(addr0, *p))
+ {
+ return true;
+ }
}
}
catch(const Ice::LocalException&)
{
- //
- // TODO: Warning?
- //
+ //
+ // TODO: Warning?
+ //
}
return false;
}
@@ -1455,17 +1455,17 @@ IceInternal::isPeerLocal(SOCKET fd)
struct sockaddr_in remoteAddr;
if(getpeername(fd, reinterpret_cast<struct sockaddr*>(&remoteAddr), &remoteLen) == SOCKET_ERROR)
{
- if(notConnected())
- {
- return false;
- }
- else
- {
- closeSocketNoThrow(fd);
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
+ if(notConnected())
+ {
+ return false;
+ }
+ else
+ {
+ closeSocketNoThrow(fd);
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
}
return isLocalAddress(remoteAddr);
}
diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp
index dd6a5d86cd9..34e00c0cae8 100644
--- a/cpp/src/Ice/Object.cpp
+++ b/cpp/src/Ice/Object.cpp
@@ -152,31 +152,31 @@ DispatchStatus
Ice::Object::__dispatch(Incoming& in, const Current& current)
{
pair<string*, string*> r =
- equal_range(__all, __all + sizeof(__all) / sizeof(string), current.operation);
+ equal_range(__all, __all + sizeof(__all) / sizeof(string), current.operation);
if(r.first == r.second)
{
- return DispatchOperationNotExist;
- }
+ return DispatchOperationNotExist;
+ }
switch(r.first - __all)
{
case 0:
{
- return ___ice_id(in, current);
+ return ___ice_id(in, current);
}
case 1:
{
- return ___ice_ids(in, current);
+ return ___ice_ids(in, current);
}
case 2:
- {
- return ___ice_isA(in, current);
- }
- case 3:
- {
- return ___ice_ping(in, current);
- }
+ {
+ return ___ice_isA(in, current);
+ }
+ case 3:
+ {
+ return ___ice_ping(in, current);
+ }
}
assert(false);
@@ -197,8 +197,8 @@ Ice::Object::__read(BasicStream* __is, bool __rid)
{
if(__rid)
{
- string myId;
- __is->readTypeId(myId);
+ string myId;
+ __is->readTypeId(myId);
}
__is->startReadSlice();
@@ -208,7 +208,7 @@ Ice::Object::__read(BasicStream* __is, bool __rid)
__is->readSize(sz);
if(sz != 0)
{
- throw Ice::MarshalException(__FILE__, __LINE__);
+ throw Ice::MarshalException(__FILE__, __LINE__);
}
__is->endReadSlice();
@@ -228,7 +228,7 @@ Ice::Object::__read(const InputStreamPtr& __inS, bool __rid)
{
if(__rid)
{
- __inS->readTypeId();
+ __inS->readTypeId();
}
__inS->startSlice();
@@ -237,7 +237,7 @@ Ice::Object::__read(const InputStreamPtr& __inS, bool __rid)
Int sz = __inS->readSize();
if(sz != 0)
{
- throw Ice::MarshalException(__FILE__, __LINE__);
+ throw Ice::MarshalException(__FILE__, __LINE__);
}
__inS->endSlice();
@@ -256,13 +256,13 @@ operationModeToString(OperationMode mode)
switch(mode)
{
case Normal:
- return "::Ice::Normal";
+ return "::Ice::Normal";
case Nonmutating:
- return "::Ice::Nonmutating";
+ return "::Ice::Nonmutating";
case Idempotent:
- return "::Ice::Idempotent";
+ return "::Ice::Idempotent";
}
ostringstream os;
@@ -275,29 +275,29 @@ Ice::Object::__checkMode(OperationMode expected, OperationMode received)
{
if(expected != received)
{
- if(expected == Idempotent && received == Nonmutating)
- {
- //
- // Fine: typically an old client still using the deprecated nonmutating keyword
- //
-
- //
- // Note that expected == Nonmutating and received == Idempotent is not ok:
- // the server may still use the deprecated nonmutating keyword to detect updates
- // and the client should not break this (deprecated) feature.
- //
- }
- else
- {
- Ice::MarshalException ex(__FILE__, __LINE__);
- std::ostringstream __reason;
- __reason << "unexpected operation mode. expected = "
- << operationModeToString(expected)
- << " received = "
- << operationModeToString(received);
- ex.reason = __reason.str();
- throw ex;
- }
+ if(expected == Idempotent && received == Nonmutating)
+ {
+ //
+ // Fine: typically an old client still using the deprecated nonmutating keyword
+ //
+
+ //
+ // Note that expected == Nonmutating and received == Idempotent is not ok:
+ // the server may still use the deprecated nonmutating keyword to detect updates
+ // and the client should not break this (deprecated) feature.
+ //
+ }
+ else
+ {
+ Ice::MarshalException ex(__FILE__, __LINE__);
+ std::ostringstream __reason;
+ __reason << "unexpected operation mode. expected = "
+ << operationModeToString(expected)
+ << " received = "
+ << operationModeToString(received);
+ ex.reason = __reason.str();
+ throw ex;
+ }
}
}
@@ -312,11 +312,11 @@ Ice::Blobject::__dispatch(Incoming& in, const Current& current)
in.os()->writeBlob(outParams);
if(ok)
{
- return DispatchOK;
+ return DispatchOK;
}
else
{
- return DispatchUserException;
+ return DispatchUserException;
}
}
@@ -332,11 +332,11 @@ Ice::BlobjectArray::__dispatch(Incoming& in, const Current& current)
in.os()->writeBlob(outParams);
if(ok)
{
- return DispatchOK;
+ return DispatchOK;
}
else
{
- return DispatchUserException;
+ return DispatchUserException;
}
}
@@ -349,19 +349,19 @@ Ice::BlobjectAsync::__dispatch(Incoming& in, const Current& current)
AMD_Object_ice_invokePtr cb = new ::IceAsync::Ice::AMD_Object_ice_invoke(in);
try
{
- ice_invoke_async(cb, inParams, current);
+ ice_invoke_async(cb, inParams, current);
}
catch(const Exception& ex)
{
- cb->ice_exception(ex);
+ cb->ice_exception(ex);
}
catch(const ::std::exception& ex)
{
- cb->ice_exception(ex);
+ cb->ice_exception(ex);
}
catch(...)
{
- cb->ice_exception();
+ cb->ice_exception();
}
return DispatchAsync;
}
@@ -376,19 +376,19 @@ Ice::BlobjectArrayAsync::__dispatch(Incoming& in, const Current& current)
AMD_Array_Object_ice_invokePtr cb = new ::IceAsync::Ice::AMD_Array_Object_ice_invoke(in);
try
{
- ice_invoke_async(cb, inParams, current);
+ ice_invoke_async(cb, inParams, current);
}
catch(const Exception& ex)
{
- cb->ice_exception(ex);
+ cb->ice_exception(ex);
}
catch(const ::std::exception& ex)
{
- cb->ice_exception(ex);
+ cb->ice_exception(ex);
}
catch(...)
{
- cb->ice_exception();
+ cb->ice_exception();
}
return DispatchAsync;
}
diff --git a/cpp/src/Ice/ObjectAdapterFactory.cpp b/cpp/src/Ice/ObjectAdapterFactory.cpp
index 8f93caf12a8..334be027f82 100644
--- a/cpp/src/Ice/ObjectAdapterFactory.cpp
+++ b/cpp/src/Ice/ObjectAdapterFactory.cpp
@@ -26,23 +26,23 @@ IceInternal::ObjectAdapterFactory::shutdown()
map<string, ObjectAdapterIPtr> adapters;
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
-
- //
- // Ignore shutdown requests if the object adapter factory has
- // already been shut down.
- //
- if(!_instance)
- {
- return;
- }
-
- adapters = _adapters;
-
- _instance = 0;
- _communicator = 0;
-
- notifyAll();
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+
+ //
+ // Ignore shutdown requests if the object adapter factory has
+ // already been shut down.
+ //
+ if(!_instance)
+ {
+ return;
+ }
+
+ adapters = _adapters;
+
+ _instance = 0;
+ _communicator = 0;
+
+ notifyAll();
}
//
@@ -50,48 +50,48 @@ IceInternal::ObjectAdapterFactory::shutdown()
// deadlocks.
//
for_each(adapters.begin(), adapters.end(),
- IceUtil::secondVoidMemFun<const string, ObjectAdapterI>(&ObjectAdapter::deactivate));
+ IceUtil::secondVoidMemFun<const string, ObjectAdapterI>(&ObjectAdapter::deactivate));
}
void
IceInternal::ObjectAdapterFactory::waitForShutdown()
{
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
-
- //
- // First we wait for the shutdown of the factory itself.
- //
- while(_instance)
- {
- wait();
- }
-
- //
- // If some other thread is currently shutting down, we wait
- // until this thread is finished.
- //
- while(_waitForShutdown)
- {
- wait();
- }
- _waitForShutdown = true;
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+
+ //
+ // First we wait for the shutdown of the factory itself.
+ //
+ while(_instance)
+ {
+ wait();
+ }
+
+ //
+ // If some other thread is currently shutting down, we wait
+ // until this thread is finished.
+ //
+ while(_waitForShutdown)
+ {
+ wait();
+ }
+ _waitForShutdown = true;
}
//
// Now we wait for deactivation of each object adapter.
//
for_each(_adapters.begin(), _adapters.end(),
- IceUtil::secondVoidMemFun<const string, ObjectAdapterI>(&ObjectAdapter::waitForDeactivate));
+ IceUtil::secondVoidMemFun<const string, ObjectAdapterI>(&ObjectAdapter::waitForDeactivate));
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
- //
- // Signal that waiting is complete.
- //
- _waitForShutdown = false;
- notifyAll();
+ //
+ // Signal that waiting is complete.
+ //
+ _waitForShutdown = false;
+ notifyAll();
}
}
@@ -114,41 +114,41 @@ IceInternal::ObjectAdapterFactory::destroy()
map<string, ObjectAdapterIPtr> adapters;
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
- adapters = _adapters;
- _adapters.clear();
+ adapters = _adapters;
+ _adapters.clear();
}
//
// Now we destroy each object adapter.
//
for_each(adapters.begin(), adapters.end(),
- IceUtil::secondVoidMemFun<const string, ObjectAdapterI>(&ObjectAdapter::destroy));
+ IceUtil::secondVoidMemFun<const string, ObjectAdapterI>(&ObjectAdapter::destroy));
}
ObjectAdapterPtr
IceInternal::ObjectAdapterFactory::createObjectAdapter(const string& name, const string& endpoints,
- const RouterPrx& router)
+ const RouterPrx& router)
{
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
if(!_instance)
{
- throw ObjectAdapterDeactivatedException(__FILE__, __LINE__);
+ throw ObjectAdapterDeactivatedException(__FILE__, __LINE__);
}
map<string, ObjectAdapterIPtr>::iterator p = _adapters.find(name);
if(p != _adapters.end())
{
- throw AlreadyRegisteredException(__FILE__, __LINE__, "object adapter", name);
+ throw AlreadyRegisteredException(__FILE__, __LINE__, "object adapter", name);
}
if(name.empty() && (!endpoints.empty() || router != 0))
{
InitializationException ex(__FILE__, __LINE__);
- ex.reason = "Cannot configure endpoints or router with nameless object adapter";
- throw ex;
+ ex.reason = "Cannot configure endpoints or router with nameless object adapter";
+ throw ex;
}
ObjectAdapterIPtr adapter;
@@ -156,7 +156,7 @@ IceInternal::ObjectAdapterFactory::createObjectAdapter(const string& name, const
{
string uuid = IceUtil::generateUUID();
adapter = new ObjectAdapterI(_instance, _communicator, this, uuid, "", 0, true);
- _adapters.insert(make_pair(uuid, adapter));
+ _adapters.insert(make_pair(uuid, adapter));
}
else
{
@@ -173,22 +173,22 @@ IceInternal::ObjectAdapterFactory::findObjectAdapter(const ObjectPrx& proxy)
if(!_instance)
{
- return 0;
+ return 0;
}
for(map<string, ObjectAdapterIPtr>::iterator p = _adapters.begin(); p != _adapters.end(); ++p)
{
- try
- {
- if(p->second->isLocal(proxy))
- {
- return p->second;
- }
- }
- catch(const ObjectAdapterDeactivatedException&)
- {
- // Ignore.
- }
+ try
+ {
+ if(p->second->isLocal(proxy))
+ {
+ return p->second;
+ }
+ }
+ catch(const ObjectAdapterDeactivatedException&)
+ {
+ // Ignore.
+ }
}
return 0;
@@ -213,7 +213,7 @@ struct FlushAdapter
{
void operator() (ObjectAdapterIPtr p)
{
- p->flushBatchRequests();
+ p->flushBatchRequests();
}
};
@@ -224,18 +224,18 @@ IceInternal::ObjectAdapterFactory::flushBatchRequests() const
{
list<ObjectAdapterIPtr> a;
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
- for(map<string, ObjectAdapterIPtr>::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
- {
- a.push_back(p->second);
- }
+ for(map<string, ObjectAdapterIPtr>::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
+ {
+ a.push_back(p->second);
+ }
}
for_each(a.begin(), a.end(), FlushAdapter());
}
IceInternal::ObjectAdapterFactory::ObjectAdapterFactory(const InstancePtr& instance,
- const CommunicatorPtr& communicator) :
+ const CommunicatorPtr& communicator) :
_instance(instance),
_communicator(communicator),
_waitForShutdown(false)
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index 483ad0542a3..b05a9697500 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -74,84 +74,84 @@ Ice::ObjectAdapterI::activate()
bool printAdapterReady = false;
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
-
- checkForDeactivation();
-
- //
- // If the one off initializations of the adapter are already
- // done, we just need to activate the incoming connection
- // factories and we're done.
- //
- if(_activateOneOffDone)
- {
- for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
- Ice::voidMemFun(&IncomingConnectionFactory::activate));
- return;
- }
-
- //
- // One off initializations of the adapter: update the locator
- // registry and print the "adapter ready" message. We set the
- // _waitForActivate flag to prevent deactivation from other
- // threads while these one off initializations are done.
- //
- _waitForActivate = true;
-
- locatorInfo = _locatorInfo;
- if(!_noConfig)
- {
- PropertiesPtr properties = _instance->initializationData().properties;
- printAdapterReady = properties->getPropertyAsInt("Ice.PrintAdapterReady") > 0;
- //
- // DEPREACTED PROPERTY: Remove extra code in future release
- //
- registerProcess = properties->getPropertyAsIntWithDefault(_propertyPrefix + _name + ".RegisterProcess",
- properties->getPropertyAsInt(_name + ".RegisterProcess")) > 0;
- }
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+
+ checkForDeactivation();
+
+ //
+ // If the one off initializations of the adapter are already
+ // done, we just need to activate the incoming connection
+ // factories and we're done.
+ //
+ if(_activateOneOffDone)
+ {
+ for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
+ Ice::voidMemFun(&IncomingConnectionFactory::activate));
+ return;
+ }
+
+ //
+ // One off initializations of the adapter: update the locator
+ // registry and print the "adapter ready" message. We set the
+ // _waitForActivate flag to prevent deactivation from other
+ // threads while these one off initializations are done.
+ //
+ _waitForActivate = true;
+
+ locatorInfo = _locatorInfo;
+ if(!_noConfig)
+ {
+ PropertiesPtr properties = _instance->initializationData().properties;
+ printAdapterReady = properties->getPropertyAsInt("Ice.PrintAdapterReady") > 0;
+ //
+ // DEPREACTED PROPERTY: Remove extra code in future release
+ //
+ registerProcess = properties->getPropertyAsIntWithDefault(_propertyPrefix + _name + ".RegisterProcess",
+ properties->getPropertyAsInt(_name + ".RegisterProcess")) > 0;
+ }
}
try
{
- Ice::Identity dummy;
- dummy.name = "dummy";
- updateLocatorRegistry(locatorInfo, createDirectProxy(dummy), registerProcess);
+ Ice::Identity dummy;
+ dummy.name = "dummy";
+ updateLocatorRegistry(locatorInfo, createDirectProxy(dummy), registerProcess);
}
catch(const Ice::LocalException&)
{
- //
- // If we couldn't update the locator registry, we let the
- // exception go through and don't activate the adapter to
- // allow to user code to retry activating the adapter
- // later.
- //
- {
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
- _waitForActivate = false;
- notifyAll();
- }
- throw;
+ //
+ // If we couldn't update the locator registry, we let the
+ // exception go through and don't activate the adapter to
+ // allow to user code to retry activating the adapter
+ // later.
+ //
+ {
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ _waitForActivate = false;
+ notifyAll();
+ }
+ throw;
}
if(printAdapterReady)
{
- cout << _name << " ready" << endl;
+ cout << _name << " ready" << endl;
}
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
- assert(!_deactivated); // Not possible if _waitForActivate = true;
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ assert(!_deactivated); // Not possible if _waitForActivate = true;
- //
- // Signal threads waiting for the activation.
- //
- _waitForActivate = false;
- notifyAll();
+ //
+ // Signal threads waiting for the activation.
+ //
+ _waitForActivate = false;
+ notifyAll();
- _activateOneOffDone = true;
+ _activateOneOffDone = true;
- for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
- Ice::voidMemFun(&IncomingConnectionFactory::activate));
+ for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
+ Ice::voidMemFun(&IncomingConnectionFactory::activate));
}
}
@@ -161,9 +161,9 @@ Ice::ObjectAdapterI::hold()
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
checkForDeactivation();
-
+
for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
- Ice::voidMemFun(&IncomingConnectionFactory::hold));
+ Ice::voidMemFun(&IncomingConnectionFactory::hold));
}
void
@@ -174,7 +174,7 @@ Ice::ObjectAdapterI::waitForHold()
checkForDeactivation();
for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
- Ice::constVoidMemFun(&IncomingConnectionFactory::waitUntilHolding));
+ Ice::constVoidMemFun(&IncomingConnectionFactory::waitUntilHolding));
}
void
@@ -184,58 +184,58 @@ Ice::ObjectAdapterI::deactivate()
OutgoingConnectionFactoryPtr outgoingConnectionFactory;
LocatorInfoPtr locatorInfo;
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
-
- //
- // Ignore deactivation requests if the object adapter has already
- // been deactivated.
- //
- if(_deactivated)
- {
- return;
- }
-
- //
- // Wait for activation to complete. This is necessary to not
- // get out of order locator updates.
- //
- while(_waitForActivate)
- {
- wait();
- }
-
- if(_routerInfo)
- {
- //
- // Remove entry from the router manager.
- //
- _instance->routerManager()->erase(_routerInfo->getRouter());
-
- //
- // Clear this object adapter with the router.
- //
- _routerInfo->setAdapter(0);
- }
-
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+
+ //
+ // Ignore deactivation requests if the object adapter has already
+ // been deactivated.
+ //
+ if(_deactivated)
+ {
+ return;
+ }
+
+ //
+ // Wait for activation to complete. This is necessary to not
+ // get out of order locator updates.
+ //
+ while(_waitForActivate)
+ {
+ wait();
+ }
+
+ if(_routerInfo)
+ {
+ //
+ // Remove entry from the router manager.
+ //
+ _instance->routerManager()->erase(_routerInfo->getRouter());
+
+ //
+ // Clear this object adapter with the router.
+ //
+ _routerInfo->setAdapter(0);
+ }
+
incomingConnectionFactories = _incomingConnectionFactories;
- outgoingConnectionFactory = _instance->outgoingConnectionFactory();
- locatorInfo = _locatorInfo;
+ outgoingConnectionFactory = _instance->outgoingConnectionFactory();
+ locatorInfo = _locatorInfo;
- _deactivated = true;
+ _deactivated = true;
- notifyAll();
+ notifyAll();
}
try
{
- updateLocatorRegistry(locatorInfo, 0, false);
+ updateLocatorRegistry(locatorInfo, 0, false);
}
catch(const Ice::LocalException&)
{
- //
- // We can't throw exceptions in deactivate so we ignore
- // failures to update the locator registry.
- //
+ //
+ // We can't throw exceptions in deactivate so we ignore
+ // failures to update the locator registry.
+ //
}
//
@@ -244,7 +244,7 @@ Ice::ObjectAdapterI::deactivate()
// message.
//
for_each(incomingConnectionFactories.begin(), incomingConnectionFactories.end(),
- Ice::voidMemFun(&IncomingConnectionFactory::destroy));
+ Ice::voidMemFun(&IncomingConnectionFactory::destroy));
//
// Must be called outside the thread synchronization, because
@@ -260,23 +260,23 @@ Ice::ObjectAdapterI::waitForDeactivate()
vector<IceInternal::IncomingConnectionFactoryPtr> incomingConnectionFactories;
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
-
- if(_destroyed)
- {
- return;
- }
-
- //
- // Wait for deactivation of the adapter itself, and for
- // the return of all direct method calls using this adapter.
- //
- while(!_deactivated || _directCount > 0)
- {
- wait();
- }
-
- incomingConnectionFactories = _incomingConnectionFactories;
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+
+ if(_destroyed)
+ {
+ return;
+ }
+
+ //
+ // Wait for deactivation of the adapter itself, and for
+ // the return of all direct method calls using this adapter.
+ //
+ while(!_deactivated || _directCount > 0)
+ {
+ wait();
+ }
+
+ incomingConnectionFactories = _incomingConnectionFactories;
}
//
@@ -284,7 +284,7 @@ Ice::ObjectAdapterI::waitForDeactivate()
// finished.
//
for_each(incomingConnectionFactories.begin(), incomingConnectionFactories.end(),
- Ice::voidMemFun(&IncomingConnectionFactory::waitUntilFinished));
+ Ice::voidMemFun(&IncomingConnectionFactory::waitUntilFinished));
}
bool
@@ -299,26 +299,26 @@ void
Ice::ObjectAdapterI::destroy()
{
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
-
- //
- // Another thread is in the process of destroying the object
- // adapter. Wait for it to finish.
- //
- while(_destroying)
- {
- wait();
- }
-
- //
- // Object adpater is already destroyed.
- //
- if(_destroyed)
- {
- return;
- }
-
- _destroying = true;
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+
+ //
+ // Another thread is in the process of destroying the object
+ // adapter. Wait for it to finish.
+ //
+ while(_destroying)
+ {
+ wait();
+ }
+
+ //
+ // Object adpater is already destroyed.
+ //
+ if(_destroyed)
+ {
+ return;
+ }
+
+ _destroying = true;
}
//
@@ -338,41 +338,41 @@ Ice::ObjectAdapterI::destroy()
//
if(_threadPool)
{
- _threadPool->destroy();
- _threadPool->joinWithAllThreads();
+ _threadPool->destroy();
+ _threadPool->joinWithAllThreads();
}
ObjectAdapterFactoryPtr objectAdapterFactory;
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
-
- //
- // Signal that destroy is complete.
- //
- _destroying = false;
- _destroyed = true;
- notifyAll();
-
- //
- // We're done, now we can throw away all incoming connection
- // factories.
- //
- _incomingConnectionFactories.clear();
-
- //
- // Remove object references (some of them cyclic).
- //
- _instance = 0;
- _threadPool = 0;
- _communicator = 0;
- _routerEndpoints.clear();
- _routerInfo = 0;
- _publishedEndpoints.clear();
- _locatorInfo = 0;
-
- objectAdapterFactory = _objectAdapterFactory;
- _objectAdapterFactory = 0;
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+
+ //
+ // Signal that destroy is complete.
+ //
+ _destroying = false;
+ _destroyed = true;
+ notifyAll();
+
+ //
+ // We're done, now we can throw away all incoming connection
+ // factories.
+ //
+ _incomingConnectionFactories.clear();
+
+ //
+ // Remove object references (some of them cyclic).
+ //
+ _instance = 0;
+ _threadPool = 0;
+ _communicator = 0;
+ _routerEndpoints.clear();
+ _routerInfo = 0;
+ _publishedEndpoints.clear();
+ _locatorInfo = 0;
+
+ objectAdapterFactory = _objectAdapterFactory;
+ _objectAdapterFactory = 0;
}
if(objectAdapterFactory)
@@ -549,8 +549,8 @@ Ice::ObjectAdapterI::createReverseProxy(const Identity& ident) const
vector<IncomingConnectionFactoryPtr>::const_iterator p;
for(p = _incomingConnectionFactories.begin(); p != _incomingConnectionFactories.end(); ++p)
{
- list<ConnectionIPtr> cons = (*p)->connections();
- copy(cons.begin(), cons.end(), back_inserter(connections));
+ list<ConnectionIPtr> cons = (*p)->connections();
+ copy(cons.begin(), cons.end(), back_inserter(connections));
}
//
@@ -558,7 +558,7 @@ Ice::ObjectAdapterI::createReverseProxy(const Identity& ident) const
// reference.
//
ReferencePtr ref = _instance->referenceFactory()->create(ident, _instance->getDefaultContext(),
- "", Reference::ModeTwoway, connections);
+ "", Reference::ModeTwoway, connections);
return _instance->proxyFactory()->referenceToProxy(ref);
}
@@ -582,32 +582,32 @@ Ice::ObjectAdapterI::isLocal(const ObjectPrx& proxy) const
IndirectReferencePtr ir = IndirectReferencePtr::dynamicCast(ref);
if(ir)
{
- if(!ir->getAdapterId().empty())
- {
- //
- // Proxy is local if the reference adapter id matches this
- // adapter id.
- //
- return ir->getAdapterId() == _id;
- }
-
- //
- // Get Locator endpoint information for indirect references.
- //
- LocatorInfoPtr info = ir->getLocatorInfo();
- if(info)
- {
- bool isCached;
- endpoints = info->getEndpoints(ir, ir->getLocatorCacheTimeout(), isCached);
- }
- else
- {
- return false;
- }
+ if(!ir->getAdapterId().empty())
+ {
+ //
+ // Proxy is local if the reference adapter id matches this
+ // adapter id.
+ //
+ return ir->getAdapterId() == _id;
+ }
+
+ //
+ // Get Locator endpoint information for indirect references.
+ //
+ LocatorInfoPtr info = ir->getLocatorInfo();
+ if(info)
+ {
+ bool isCached;
+ endpoints = info->getEndpoints(ir, ir->getLocatorCacheTimeout(), isCached);
+ }
+ else
+ {
+ return false;
+ }
}
else
{
- endpoints = ref->getEndpoints();
+ endpoints = ref->getEndpoints();
}
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
@@ -620,14 +620,14 @@ Ice::ObjectAdapterI::isLocal(const ObjectPrx& proxy) const
//
for(p = endpoints.begin(); p != endpoints.end(); ++p)
{
- vector<IncomingConnectionFactoryPtr>::const_iterator q;
- for(q = _incomingConnectionFactories.begin(); q != _incomingConnectionFactories.end(); ++q)
- {
- if((*q)->equivalent(*p))
- {
- return true;
- }
- }
+ vector<IncomingConnectionFactoryPtr>::const_iterator q;
+ for(q = _incomingConnectionFactories.begin(); q != _incomingConnectionFactories.end(); ++q)
+ {
+ if((*q)->equivalent(*p))
+ {
+ return true;
+ }
+ }
}
//
@@ -639,10 +639,10 @@ Ice::ObjectAdapterI::isLocal(const ObjectPrx& proxy) const
{
for(p = endpoints.begin(); p != endpoints.end(); ++p)
{
- if(binary_search(_routerEndpoints.begin(), _routerEndpoints.end(), *p)) // _routerEndpoints is sorted.
- {
- return true;
- }
+ if(binary_search(_routerEndpoints.begin(), _routerEndpoints.end(), *p)) // _routerEndpoints is sorted.
+ {
+ return true;
+ }
}
}
@@ -654,8 +654,8 @@ Ice::ObjectAdapterI::flushBatchRequests()
{
vector<IncomingConnectionFactoryPtr> f;
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
- f = _incomingConnectionFactories;
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ f = _incomingConnectionFactories;
}
for_each(f.begin(), f.end(), Ice::voidMemFun(&IncomingConnectionFactory::flushBatchRequests));
}
@@ -683,7 +683,7 @@ Ice::ObjectAdapterI::decDirectCount()
assert(_directCount > 0);
if(--_directCount == 0)
{
- notifyAll();
+ notifyAll();
}
}
@@ -700,11 +700,11 @@ Ice::ObjectAdapterI::getThreadPool() const
if(_threadPool)
{
- return _threadPool;
+ return _threadPool;
}
else
{
- return _instance->serverThreadPool();
+ return _instance->serverThreadPool();
}
}
@@ -736,8 +736,8 @@ Ice::ObjectAdapterI::getThreadPerConnectionStackSize() const
}
Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const CommunicatorPtr& communicator,
- const ObjectAdapterFactoryPtr& objectAdapterFactory, const string& name,
- const string& endpointInfo, const RouterPrx& router, bool noConfig) :
+ const ObjectAdapterFactoryPtr& objectAdapterFactory, const string& name,
+ const string& endpointInfo, const RouterPrx& router, bool noConfig) :
_deactivated(false),
_instance(instance),
_communicator(communicator),
@@ -769,28 +769,28 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const Communica
{
StringSeq props = filterProperties(_propertyPrefix + _name + ".");
if(oldProps.size() == 0 && props.size() == 0)
- {
+ {
InitializationException ex(__FILE__, __LINE__);
- ex.reason = "object adapter \"" + _name + "\" requires configuration.";
- throw ex;
+ ex.reason = "object adapter \"" + _name + "\" requires configuration.";
+ throw ex;
}
}
if(oldProps.size() != 0)
{
- Warning out(_instance->initializationData().logger);
- out << "The following properties have been deprecated, please prepend \"Ice.OA.\":";
- for(unsigned int i = 0; i < oldProps.size(); ++i)
- {
- out << "\n " << oldProps[i];
- }
+ Warning out(_instance->initializationData().logger);
+ out << "The following properties have been deprecated, please prepend \"Ice.OA.\":";
+ for(unsigned int i = 0; i < oldProps.size(); ++i)
+ {
+ out << "\n " << oldProps[i];
+ }
}
const_cast<string&>(_id) = properties->getPropertyWithDefault(_propertyPrefix + _name + ".AdapterId",
- properties->getProperty(_name + ".AdapterId"));
+ properties->getProperty(_name + ".AdapterId"));
const_cast<string&>(_replicaGroupId) =
- properties->getPropertyWithDefault(_propertyPrefix + _name + ".ReplicaGroupId",
- properties->getProperty(_name + ".ReplicaGroupId"));
+ properties->getPropertyWithDefault(_propertyPrefix + _name + ".ReplicaGroupId",
+ properties->getProperty(_name + ".ReplicaGroupId"));
__setNoDelete(true);
try
@@ -811,7 +811,7 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const Communica
if(_threadPerConnection && (threadPoolSize > 0 || threadPoolSizeMax > 0))
{
InitializationException ex(__FILE__, __LINE__);
- ex.reason = "object adapter \"" + _name + "\" cannot be configured for both\n"
+ ex.reason = "object adapter \"" + _name + "\" cannot be configured for both\n"
"thread pool and thread per connection";
throw ex;
}
@@ -832,138 +832,138 @@ Ice::ObjectAdapterI::ObjectAdapterI(const InstancePtr& instance, const Communica
// Create the per-adapter thread pool, if necessary. This is done before the creation of the incoming
// connection factory as the thread pool is needed during creation for the call to incFdsInUse.
//
- if(threadPoolSize > 0 || threadPoolSizeMax > 0)
- {
- if(!properties->getProperty(_propertyPrefix + _name + ".ThreadPool.Size").empty() ||
- !properties->getProperty(_propertyPrefix + _name + ".ThreadPool.SizeMax").empty())
- {
+ if(threadPoolSize > 0 || threadPoolSizeMax > 0)
+ {
+ if(!properties->getProperty(_propertyPrefix + _name + ".ThreadPool.Size").empty() ||
+ !properties->getProperty(_propertyPrefix + _name + ".ThreadPool.SizeMax").empty())
+ {
_threadPool = new ThreadPool(_instance, _propertyPrefix + _name + ".ThreadPool", 0);
- }
- else
- {
+ }
+ else
+ {
_threadPool = new ThreadPool(_instance, _name + ".ThreadPool", 0);
- }
- }
-
- if(!router)
- {
- const_cast<RouterPrx&>(router) = RouterPrx::uncheckedCast(
- _instance->proxyFactory()->propertyToProxy(_propertyPrefix + _name + ".Router"));
- if(!router)
- {
- const_cast<RouterPrx&>(router) = RouterPrx::uncheckedCast(
- _instance->proxyFactory()->propertyToProxy(_name + ".Router"));
- }
- }
- if(router)
- {
+ }
+ }
+
+ if(!router)
+ {
+ const_cast<RouterPrx&>(router) = RouterPrx::uncheckedCast(
+ _instance->proxyFactory()->propertyToProxy(_propertyPrefix + _name + ".Router"));
+ if(!router)
+ {
+ const_cast<RouterPrx&>(router) = RouterPrx::uncheckedCast(
+ _instance->proxyFactory()->propertyToProxy(_name + ".Router"));
+ }
+ }
+ if(router)
+ {
_routerInfo = _instance->routerManager()->get(router);
if(_routerInfo)
{
- //
- // Make sure this router is not already registered with another adapter.
- //
- if(_routerInfo->getAdapter())
- {
- throw AlreadyRegisteredException(__FILE__, __LINE__, "object adapter with router",
- _instance->identityToString(router->ice_getIdentity()));
- }
-
- //
- // Add the router's server proxy endpoints to this object
- // adapter.
- //
- vector<EndpointIPtr> endpoints = _routerInfo->getServerEndpoints();
- copy(endpoints.begin(), endpoints.end(), back_inserter(_routerEndpoints));
- sort(_routerEndpoints.begin(), _routerEndpoints.end()); // Must be sorted.
- _routerEndpoints.erase(unique(_routerEndpoints.begin(), _routerEndpoints.end()),
- _routerEndpoints.end());
-
- //
- // Associate this object adapter with the router. This way,
- // new outgoing connections to the router's client proxy will
- // use this object adapter for callbacks.
- //
- _routerInfo->setAdapter(this);
-
- //
- // Also modify all existing outgoing connections to the
- // router's client proxy to use this object adapter for
- // callbacks.
- //
- _instance->outgoingConnectionFactory()->setRouterInfo(_routerInfo);
+ //
+ // Make sure this router is not already registered with another adapter.
+ //
+ if(_routerInfo->getAdapter())
+ {
+ throw AlreadyRegisteredException(__FILE__, __LINE__, "object adapter with router",
+ _instance->identityToString(router->ice_getIdentity()));
+ }
+
+ //
+ // Add the router's server proxy endpoints to this object
+ // adapter.
+ //
+ vector<EndpointIPtr> endpoints = _routerInfo->getServerEndpoints();
+ copy(endpoints.begin(), endpoints.end(), back_inserter(_routerEndpoints));
+ sort(_routerEndpoints.begin(), _routerEndpoints.end()); // Must be sorted.
+ _routerEndpoints.erase(unique(_routerEndpoints.begin(), _routerEndpoints.end()),
+ _routerEndpoints.end());
+
+ //
+ // Associate this object adapter with the router. This way,
+ // new outgoing connections to the router's client proxy will
+ // use this object adapter for callbacks.
+ //
+ _routerInfo->setAdapter(this);
+
+ //
+ // Also modify all existing outgoing connections to the
+ // router's client proxy to use this object adapter for
+ // callbacks.
+ //
+ _instance->outgoingConnectionFactory()->setRouterInfo(_routerInfo);
+ }
+ }
+ else
+ {
+ //
+ // Parse the endpoints, but don't store them in the adapter.
+ // The connection factory might change it, for example, to
+ // fill in the real port number.
+ //
+ vector<EndpointIPtr> endpoints;
+ if(endpointInfo.empty())
+ {
+ endpoints = parseEndpoints(properties->getPropertyWithDefault(_propertyPrefix + _name + ".Endpoints",
+ properties->getProperty(_name + ".Endpoints")));
}
- }
- else
- {
- //
- // Parse the endpoints, but don't store them in the adapter.
- // The connection factory might change it, for example, to
- // fill in the real port number.
- //
- vector<EndpointIPtr> endpoints;
- if(endpointInfo.empty())
- {
- endpoints = parseEndpoints(properties->getPropertyWithDefault(_propertyPrefix + _name + ".Endpoints",
- properties->getProperty(_name + ".Endpoints")));
- }
- else
- {
- endpoints = parseEndpoints(endpointInfo);
- }
- for(vector<EndpointIPtr>::iterator p = endpoints.begin(); p != endpoints.end(); ++p)
- {
- _incomingConnectionFactories.push_back(new IncomingConnectionFactory(instance, *p, this, _name));
- }
- if(endpoints.empty())
- {
- TraceLevelsPtr tl = _instance->traceLevels();
- if(tl->network >= 2)
- {
- Trace out(_instance->initializationData().logger, tl->networkCat);
- out << "created adapter `" << name << "' without endpoints";
- }
- }
-
- //
- // Parse published endpoints. If set, these are used in proxies
- // instead of the connection factory endpoints.
- //
- string endpts = properties->getPropertyWithDefault(_propertyPrefix + _name + ".PublishedEndpoints",
- properties->getProperty(_name + ".PublishedEndpoints"));
- _publishedEndpoints = parseEndpoints(endpts);
- if(_publishedEndpoints.empty())
- {
- transform(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
- back_inserter(_publishedEndpoints), Ice::constMemFun(&IncomingConnectionFactory::endpoint));
- }
-
- //
- // Filter out any endpoints that are not meant to be published.
- //
- _publishedEndpoints.erase(remove_if(_publishedEndpoints.begin(), _publishedEndpoints.end(),
- not1(Ice::constMemFun(&EndpointI::publish))), _publishedEndpoints.end());
- }
-
- string locatorProperty = _propertyPrefix + _name + ".Locator";
- if(!properties->getProperty(locatorProperty).empty())
- {
- setLocator(LocatorPrx::uncheckedCast(_instance->proxyFactory()->propertyToProxy(locatorProperty)));
- }
- else if(!properties->getProperty(_name + ".Locator").empty())
- {
- setLocator(LocatorPrx::uncheckedCast(_instance->proxyFactory()->propertyToProxy(_name + ".Locator")));
- }
- else
- {
- setLocator(_instance->referenceFactory()->getDefaultLocator());
- }
+ else
+ {
+ endpoints = parseEndpoints(endpointInfo);
+ }
+ for(vector<EndpointIPtr>::iterator p = endpoints.begin(); p != endpoints.end(); ++p)
+ {
+ _incomingConnectionFactories.push_back(new IncomingConnectionFactory(instance, *p, this, _name));
+ }
+ if(endpoints.empty())
+ {
+ TraceLevelsPtr tl = _instance->traceLevels();
+ if(tl->network >= 2)
+ {
+ Trace out(_instance->initializationData().logger, tl->networkCat);
+ out << "created adapter `" << name << "' without endpoints";
+ }
+ }
+
+ //
+ // Parse published endpoints. If set, these are used in proxies
+ // instead of the connection factory endpoints.
+ //
+ string endpts = properties->getPropertyWithDefault(_propertyPrefix + _name + ".PublishedEndpoints",
+ properties->getProperty(_name + ".PublishedEndpoints"));
+ _publishedEndpoints = parseEndpoints(endpts);
+ if(_publishedEndpoints.empty())
+ {
+ transform(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
+ back_inserter(_publishedEndpoints), Ice::constMemFun(&IncomingConnectionFactory::endpoint));
+ }
+
+ //
+ // Filter out any endpoints that are not meant to be published.
+ //
+ _publishedEndpoints.erase(remove_if(_publishedEndpoints.begin(), _publishedEndpoints.end(),
+ not1(Ice::constMemFun(&EndpointI::publish))), _publishedEndpoints.end());
+ }
+
+ string locatorProperty = _propertyPrefix + _name + ".Locator";
+ if(!properties->getProperty(locatorProperty).empty())
+ {
+ setLocator(LocatorPrx::uncheckedCast(_instance->proxyFactory()->propertyToProxy(locatorProperty)));
+ }
+ else if(!properties->getProperty(_name + ".Locator").empty())
+ {
+ setLocator(LocatorPrx::uncheckedCast(_instance->proxyFactory()->propertyToProxy(_name + ".Locator")));
+ }
+ else
+ {
+ setLocator(_instance->referenceFactory()->getDefaultLocator());
+ }
}
catch(...)
{
- destroy();
- __setNoDelete(false);
- throw;
+ destroy();
+ __setNoDelete(false);
+ throw;
}
__setNoDelete(false);
}
@@ -972,22 +972,22 @@ Ice::ObjectAdapterI::~ObjectAdapterI()
{
if(!_deactivated)
{
- Warning out(_instance->initializationData().logger);
- out << "object adapter `" << getName() << "' has not been deactivated";
+ Warning out(_instance->initializationData().logger);
+ out << "object adapter `" << getName() << "' has not been deactivated";
}
else if(!_destroyed)
{
- Warning out(_instance->initializationData().logger);
- out << "object adapter `" << getName() << "' has not been destroyed";
+ Warning out(_instance->initializationData().logger);
+ out << "object adapter `" << getName() << "' has not been destroyed";
}
else
{
- //assert(!_servantManager); // We don't clear this reference, it needs to be immutable.
- assert(!_threadPool);
- assert(!_communicator);
- assert(_incomingConnectionFactories.empty());
- assert(_directCount == 0);
- assert(!_waitForActivate);
+ //assert(!_servantManager); // We don't clear this reference, it needs to be immutable.
+ assert(!_threadPool);
+ assert(!_communicator);
+ assert(_incomingConnectionFactories.empty());
+ assert(_directCount == 0);
+ assert(!_waitForActivate);
}
}
@@ -996,15 +996,15 @@ Ice::ObjectAdapterI::newProxy(const Identity& ident, const string& facet) const
{
if(_id.empty())
{
- return newDirectProxy(ident, facet);
+ return newDirectProxy(ident, facet);
}
else if(_replicaGroupId.empty())
{
- return newIndirectProxy(ident, facet, _id);
+ return newIndirectProxy(ident, facet, _id);
}
else
{
- return newIndirectProxy(ident, facet, _replicaGroupId);
+ return newIndirectProxy(ident, facet, _replicaGroupId);
}
}
@@ -1024,9 +1024,9 @@ Ice::ObjectAdapterI::newDirectProxy(const Identity& ident, const string& facet)
// Create a reference and return a proxy for this reference.
//
ReferencePtr ref = _instance->referenceFactory()->create(
- ident, _instance->getDefaultContext(), facet, Reference::ModeTwoway, false,
- _instance->defaultsAndOverrides()->defaultPreferSecure, endpoints, 0,
- _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
+ ident, _instance->getDefaultContext(), facet, Reference::ModeTwoway, false,
+ _instance->defaultsAndOverrides()->defaultPreferSecure, endpoints, 0,
+ _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
_instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection());
return _instance->proxyFactory()->referenceToProxy(ref);
@@ -1039,11 +1039,11 @@ Ice::ObjectAdapterI::newIndirectProxy(const Identity& ident, const string& facet
// Create an indirect reference with the given adapter id.
//
ReferencePtr ref = _instance->referenceFactory()->create(
- ident, _instance->getDefaultContext(), facet, Reference::ModeTwoway, false,
- _instance->defaultsAndOverrides()->defaultPreferSecure, id, 0,
- _locatorInfo, _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
+ ident, _instance->getDefaultContext(), facet, Reference::ModeTwoway, false,
+ _instance->defaultsAndOverrides()->defaultPreferSecure, id, 0,
+ _locatorInfo, _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
_instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection(),
- _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout);
+ _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout);
//
// Return a proxy for the reference.
@@ -1056,9 +1056,9 @@ Ice::ObjectAdapterI::checkForDeactivation() const
{
if(_deactivated)
{
- ObjectAdapterDeactivatedException ex(__FILE__, __LINE__);
- ex.name = getName();
- throw ex;
+ ObjectAdapterDeactivatedException ex(__FILE__, __LINE__);
+ ex.name = getName();
+ throw ex;
}
}
@@ -1085,38 +1085,38 @@ Ice::ObjectAdapterI::parseEndpoints(const string& str) const
vector<EndpointIPtr> endpoints;
while(end < endpts.length())
{
- const string delim = " \t\n\r";
-
- beg = endpts.find_first_not_of(delim, end);
- if(beg == string::npos)
- {
- break;
- }
-
- end = endpts.find(':', beg);
- if(end == string::npos)
- {
- end = endpts.length();
- }
-
- if(end == beg)
- {
- ++end;
- continue;
- }
-
- string s = endpts.substr(beg, end - beg);
- EndpointIPtr endp = _instance->endpointFactoryManager()->create(s);
- if(endp == 0)
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = s;
- throw ex;
- }
- vector<EndpointIPtr> endps = endp->expand(true);
- endpoints.insert(endpoints.end(), endps.begin(), endps.end());
-
- ++end;
+ const string delim = " \t\n\r";
+
+ beg = endpts.find_first_not_of(delim, end);
+ if(beg == string::npos)
+ {
+ break;
+ }
+
+ end = endpts.find(':', beg);
+ if(end == string::npos)
+ {
+ end = endpts.length();
+ }
+
+ if(end == beg)
+ {
+ ++end;
+ continue;
+ }
+
+ string s = endpts.substr(beg, end - beg);
+ EndpointIPtr endp = _instance->endpointFactoryManager()->create(s);
+ if(endp == 0)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = s;
+ throw ex;
+ }
+ vector<EndpointIPtr> endps = endp->expand(true);
+ endpoints.insert(endpoints.end(), endps.begin(), endps.end());
+
+ ++end;
}
return endpoints;
@@ -1124,12 +1124,12 @@ Ice::ObjectAdapterI::parseEndpoints(const string& str) const
void
ObjectAdapterI::updateLocatorRegistry(const IceInternal::LocatorInfoPtr& locatorInfo,
- const Ice::ObjectPrx& proxy,
- bool registerProcess)
+ const Ice::ObjectPrx& proxy,
+ bool registerProcess)
{
if(!registerProcess && _id.empty())
{
- return; // Nothing to update.
+ return; // Nothing to update.
}
//
@@ -1147,76 +1147,76 @@ ObjectAdapterI::updateLocatorRegistry(const IceInternal::LocatorInfoPtr& locator
string serverId;
if(registerProcess)
{
- assert(_instance);
- serverId = _instance->initializationData().properties->getProperty("Ice.ServerId");
-
- if(!locatorRegistry)
- {
- Warning out(_instance->initializationData().logger);
- out << "object adapter `" << getName() << "' cannot register the process without a locator registry";
- }
- else if(serverId.empty())
- {
- Warning out(_instance->initializationData().logger);
- out << "object adapter `" << getName() << "' cannot register the process without a value for Ice.ServerId";
- }
+ assert(_instance);
+ serverId = _instance->initializationData().properties->getProperty("Ice.ServerId");
+
+ if(!locatorRegistry)
+ {
+ Warning out(_instance->initializationData().logger);
+ out << "object adapter `" << getName() << "' cannot register the process without a locator registry";
+ }
+ else if(serverId.empty())
+ {
+ Warning out(_instance->initializationData().logger);
+ out << "object adapter `" << getName() << "' cannot register the process without a value for Ice.ServerId";
+ }
}
if(!locatorRegistry)
{
- return;
+ return;
}
if(!_id.empty())
{
- try
- {
- if(_replicaGroupId.empty())
- {
- locatorRegistry->setAdapterDirectProxy(_id, proxy);
- }
- else
- {
- locatorRegistry->setReplicatedAdapterDirectProxy(_id, _replicaGroupId, proxy);
- }
- }
- catch(const AdapterNotFoundException&)
- {
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "object adapter";
- ex.id = _id;
- throw ex;
- }
- catch(const InvalidReplicaGroupIdException&)
- {
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "replica group";
- ex.id = _replicaGroupId;
- throw ex;
- }
- catch(const AdapterAlreadyActiveException&)
- {
- ObjectAdapterIdInUseException ex(__FILE__, __LINE__);
- ex.id = _id;
- throw ex;
- }
- }
+ try
+ {
+ if(_replicaGroupId.empty())
+ {
+ locatorRegistry->setAdapterDirectProxy(_id, proxy);
+ }
+ else
+ {
+ locatorRegistry->setReplicatedAdapterDirectProxy(_id, _replicaGroupId, proxy);
+ }
+ }
+ catch(const AdapterNotFoundException&)
+ {
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "object adapter";
+ ex.id = _id;
+ throw ex;
+ }
+ catch(const InvalidReplicaGroupIdException&)
+ {
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "replica group";
+ ex.id = _replicaGroupId;
+ throw ex;
+ }
+ catch(const AdapterAlreadyActiveException&)
+ {
+ ObjectAdapterIdInUseException ex(__FILE__, __LINE__);
+ ex.id = _id;
+ throw ex;
+ }
+ }
if(registerProcess && !serverId.empty())
{
- try
- {
- ProcessPtr servant = new ProcessI(_communicator);
- Ice::ObjectPrx process = createDirectProxy(addWithUUID(servant)->ice_getIdentity());
- locatorRegistry->setServerProcessProxy(serverId, ProcessPrx::uncheckedCast(process));
- }
- catch(const ServerNotFoundException&)
- {
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "server";
- ex.id = serverId;
- throw ex;
- }
+ try
+ {
+ ProcessPtr servant = new ProcessI(_communicator);
+ Ice::ObjectPrx process = createDirectProxy(addWithUUID(servant)->ice_getIdentity());
+ locatorRegistry->setServerProcessProxy(serverId, ProcessPrx::uncheckedCast(process));
+ }
+ catch(const ServerNotFoundException&)
+ {
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "server";
+ ex.id = serverId;
+ throw ex;
+ }
}
}
@@ -1225,17 +1225,17 @@ Ice::ObjectAdapterI::filterProperties(const string& prefix)
{
static const string suffixes[] =
{
- "AdapterId",
- "Endpoints",
- "Locator",
- "PublishedEndpoints",
- "RegisterProcess",
- "ReplicaGroupId",
- "Router",
- "ThreadPool.Size",
- "ThreadPool.SizeMax",
- "ThreadPool.SizeWarn",
- "ThreadPool.StackSize"
+ "AdapterId",
+ "Endpoints",
+ "Locator",
+ "PublishedEndpoints",
+ "RegisterProcess",
+ "ReplicaGroupId",
+ "Router",
+ "ThreadPool.Size",
+ "ThreadPool.SizeMax",
+ "ThreadPool.SizeWarn",
+ "ThreadPool.StackSize"
};
StringSeq propertySet;
@@ -1243,9 +1243,9 @@ Ice::ObjectAdapterI::filterProperties(const string& prefix)
for(unsigned int i = 0; i < sizeof(suffixes)/sizeof(*suffixes); ++i)
{
if(props.find(prefix + suffixes[i]) != props.end())
- {
- propertySet.push_back(prefix + suffixes[i]);
- }
+ {
+ propertySet.push_back(prefix + suffixes[i]);
+ }
}
return propertySet;
@@ -1267,15 +1267,15 @@ Ice::ObjectAdapterI::ProcessI::writeMessage(const string& message, Int fd, const
{
switch(fd)
{
- case 1:
- {
- cout << message << endl;
- break;
- }
- case 2:
- {
- cerr << message << endl;
- break;
- }
+ case 1:
+ {
+ cout << message << endl;
+ break;
+ }
+ case 2:
+ {
+ cerr << message << endl;
+ break;
+ }
}
}
diff --git a/cpp/src/Ice/ObjectAdapterI.h b/cpp/src/Ice/ObjectAdapterI.h
index e9b6fe0cb6f..b61b7e3e1a7 100644
--- a/cpp/src/Ice/ObjectAdapterI.h
+++ b/cpp/src/Ice/ObjectAdapterI.h
@@ -89,8 +89,8 @@ public:
private:
ObjectAdapterI(const IceInternal::InstancePtr&, const CommunicatorPtr&,
- const IceInternal::ObjectAdapterFactoryPtr&, const std::string&, const std::string&,
- const RouterPrx&, bool);
+ const IceInternal::ObjectAdapterFactoryPtr&, const std::string&, const std::string&,
+ const RouterPrx&, bool);
virtual ~ObjectAdapterI();
friend class IceInternal::ObjectAdapterFactory;
@@ -135,7 +135,7 @@ private:
ProcessI(const CommunicatorPtr&);
virtual void shutdown(const Current&);
- virtual void writeMessage(const std::string&, Int, const Current&);
+ virtual void writeMessage(const std::string&, Int, const Current&);
private:
diff --git a/cpp/src/Ice/ObjectFactoryManager.cpp b/cpp/src/Ice/ObjectFactoryManager.cpp
index c52894f4234..5ed3f2a7d38 100644
--- a/cpp/src/Ice/ObjectFactoryManager.cpp
+++ b/cpp/src/Ice/ObjectFactoryManager.cpp
@@ -28,10 +28,10 @@ IceInternal::ObjectFactoryManager::add(const ObjectFactoryPtr& factory, const st
if((_factoryMapHint != _factoryMap.end() && _factoryMapHint->first == id)
|| _factoryMap.find(id) != _factoryMap.end())
{
- AlreadyRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "object factory";
- ex.id = id;
- throw ex;
+ AlreadyRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "object factory";
+ ex.id = id;
+ throw ex;
}
_factoryMapHint = _factoryMap.insert(_factoryMapHint, pair<const string, ObjectFactoryPtr>(id, factory));
@@ -42,41 +42,41 @@ IceInternal::ObjectFactoryManager::remove(const string& id)
{
ObjectFactoryPtr factory = 0;
{
- IceUtil::Mutex::Lock sync(*this);
-
- FactoryMap::iterator p = _factoryMap.end();
- if(_factoryMapHint != _factoryMap.end())
- {
- if(_factoryMapHint->first == id)
- {
- p = _factoryMapHint;
- }
- }
-
- if(p == _factoryMap.end())
- {
- p = _factoryMap.find(id);
- if(p == _factoryMap.end())
- {
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "object factory";
- ex.id = id;
- throw ex;
- }
- }
- assert(p != _factoryMap.end());
-
- factory = p->second;
-
- if(p == _factoryMapHint)
- {
- _factoryMap.erase(p++);
- _factoryMapHint = p;
- }
- else
- {
- _factoryMap.erase(p);
- }
+ IceUtil::Mutex::Lock sync(*this);
+
+ FactoryMap::iterator p = _factoryMap.end();
+ if(_factoryMapHint != _factoryMap.end())
+ {
+ if(_factoryMapHint->first == id)
+ {
+ p = _factoryMapHint;
+ }
+ }
+
+ if(p == _factoryMap.end())
+ {
+ p = _factoryMap.find(id);
+ if(p == _factoryMap.end())
+ {
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "object factory";
+ ex.id = id;
+ throw ex;
+ }
+ }
+ assert(p != _factoryMap.end());
+
+ factory = p->second;
+
+ if(p == _factoryMapHint)
+ {
+ _factoryMap.erase(p++);
+ _factoryMapHint = p;
+ }
+ else
+ {
+ _factoryMap.erase(p);
+ }
}
//
@@ -96,25 +96,25 @@ IceInternal::ObjectFactoryManager::find(const string& id) const
FactoryMap::iterator p = factoryMap.end();
if(_factoryMapHint != factoryMap.end())
{
- if(_factoryMapHint->first == id)
- {
- p = _factoryMapHint;
- }
+ if(_factoryMapHint->first == id)
+ {
+ p = _factoryMapHint;
+ }
}
if(p == factoryMap.end())
{
- p = factoryMap.find(id);
+ p = factoryMap.find(id);
}
if(p != factoryMap.end())
{
- _factoryMapHint = p;
- return p->second;
+ _factoryMapHint = p;
+ return p->second;
}
else
{
- return 0;
+ return 0;
}
}
@@ -128,14 +128,14 @@ IceInternal::ObjectFactoryManager::destroy()
{
FactoryMap oldMap;
{
- IceUtil::Mutex::Lock sync(*this);
- oldMap.swap(_factoryMap);
- _factoryMapHint = _factoryMap.end();
+ IceUtil::Mutex::Lock sync(*this);
+ oldMap.swap(_factoryMap);
+ _factoryMapHint = _factoryMap.end();
}
//
// Destroy all outside lock
//
for_each(oldMap.begin(), oldMap.end(),
- Ice::secondVoidMemFun<const string, ObjectFactory>(&ObjectFactory::destroy));
+ Ice::secondVoidMemFun<const string, ObjectFactory>(&ObjectFactory::destroy));
}
diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp
index c16f5618c05..33a6fc3931a 100644
--- a/cpp/src/Ice/Outgoing.cpp
+++ b/cpp/src/Ice/Outgoing.cpp
@@ -46,7 +46,7 @@ IceInternal::LocalExceptionWrapper::retry() const
}
IceInternal::Outgoing::Outgoing(ConnectionI* connection, Reference* ref, const string& operation,
- OperationMode mode, const Context* context, bool compress) :
+ OperationMode mode, const Context* context, bool compress) :
_connection(connection),
_reference(ref),
_state(StateUnsent),
@@ -56,80 +56,80 @@ IceInternal::Outgoing::Outgoing(ConnectionI* connection, Reference* ref, const s
{
switch(_reference->getMode())
{
- case Reference::ModeTwoway:
- case Reference::ModeOneway:
- case Reference::ModeDatagram:
- {
- _os.writeBlob(requestHdr, sizeof(requestHdr));
- break;
- }
-
- case Reference::ModeBatchOneway:
- case Reference::ModeBatchDatagram:
- {
- _connection->prepareBatchRequest(&_os);
- break;
- }
+ case Reference::ModeTwoway:
+ case Reference::ModeOneway:
+ case Reference::ModeDatagram:
+ {
+ _os.writeBlob(requestHdr, sizeof(requestHdr));
+ break;
+ }
+
+ case Reference::ModeBatchOneway:
+ case Reference::ModeBatchDatagram:
+ {
+ _connection->prepareBatchRequest(&_os);
+ break;
+ }
}
try
{
- _reference->getIdentity().__write(&_os);
-
- //
- // For compatibility with the old FacetPath.
- //
- if(_reference->getFacet().empty())
- {
- _os.write(static_cast<string*>(0), static_cast<string*>(0));
- }
- else
- {
- string facet = _reference->getFacet();
- _os.write(&facet, &facet + 1);
- }
-
- _os.write(operation, false);
-
- _os.write(static_cast<Byte>(mode));
-
- if(context != 0)
- {
- //
- // Explicit context
- //
- __write(&_os, *context, __U__Context());
- }
- else
- {
- //
- // Implicit context
- //
- const ImplicitContextIPtr& implicitContext =
- _reference->getInstance()->getImplicitContext();
-
- const Context& prxContext = _reference->getContext()->getValue();
-
- if(implicitContext == 0)
- {
- __write(&_os, prxContext, __U__Context());
- }
- else
- {
- implicitContext->write(prxContext, &_os);
- }
- }
-
- //
- // Input and output parameters are always sent in an
- // encapsulation, which makes it possible to forward requests as
- // blobs.
- //
- _os.startWriteEncaps();
+ _reference->getIdentity().__write(&_os);
+
+ //
+ // For compatibility with the old FacetPath.
+ //
+ if(_reference->getFacet().empty())
+ {
+ _os.write(static_cast<string*>(0), static_cast<string*>(0));
+ }
+ else
+ {
+ string facet = _reference->getFacet();
+ _os.write(&facet, &facet + 1);
+ }
+
+ _os.write(operation, false);
+
+ _os.write(static_cast<Byte>(mode));
+
+ if(context != 0)
+ {
+ //
+ // Explicit context
+ //
+ __write(&_os, *context, __U__Context());
+ }
+ else
+ {
+ //
+ // Implicit context
+ //
+ const ImplicitContextIPtr& implicitContext =
+ _reference->getInstance()->getImplicitContext();
+
+ const Context& prxContext = _reference->getContext()->getValue();
+
+ if(implicitContext == 0)
+ {
+ __write(&_os, prxContext, __U__Context());
+ }
+ else
+ {
+ implicitContext->write(prxContext, &_os);
+ }
+ }
+
+ //
+ // Input and output parameters are always sent in an
+ // encapsulation, which makes it possible to forward requests as
+ // blobs.
+ //
+ _os.startWriteEncaps();
}
catch(const LocalException& ex)
{
- abort(ex);
+ abort(ex);
}
}
@@ -142,145 +142,145 @@ IceInternal::Outgoing::invoke()
switch(_reference->getMode())
{
- case Reference::ModeTwoway:
- {
- //
- // We let all exceptions raised by sending directly
- // propagate to the caller, because they can be retried
- // without violating "at-most-once". In case of such
- // exceptions, the connection object does not call back on
- // this object, so we don't need to lock the mutex, keep
- // track of state, or save exceptions.
- //
- _connection->sendRequest(&_os, this, _compress);
-
- //
- // Wait until the request has completed, or until the
- // request times out.
- //
-
- bool timedOut = false;
-
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
-
- //
+ case Reference::ModeTwoway:
+ {
+ //
+ // We let all exceptions raised by sending directly
+ // propagate to the caller, because they can be retried
+ // without violating "at-most-once". In case of such
+ // exceptions, the connection object does not call back on
+ // this object, so we don't need to lock the mutex, keep
+ // track of state, or save exceptions.
+ //
+ _connection->sendRequest(&_os, this, _compress);
+
+ //
+ // Wait until the request has completed, or until the
+ // request times out.
+ //
+
+ bool timedOut = false;
+
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
+
+ //
// It's possible that the request has already
// completed, due to a regular response, or because of
// an exception. So we only change the state to "in
// progress" if it is still "unsent".
- //
- if(_state == StateUnsent)
- {
- _state = StateInProgress;
- }
-
- Int timeout = _connection->timeout();
- while(_state == StateInProgress && !timedOut)
- {
- if(timeout >= 0)
- {
- _monitor.timedWait(IceUtil::Time::milliSeconds(timeout));
-
- if(_state == StateInProgress)
- {
- timedOut = true;
- }
- }
- else
- {
- _monitor.wait();
- }
- }
- }
-
- if(timedOut)
- {
- //
- // Must be called outside the synchronization of this
- // object.
- //
- _connection->exception(TimeoutException(__FILE__, __LINE__));
-
- //
- // We must wait until the exception set above has
- // propagated to this Outgoing object.
- //
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
-
- while(_state == StateInProgress)
- {
- _monitor.wait();
- }
- }
- }
-
- if(_exception.get())
- {
- //
- // A CloseConnectionException indicates graceful
- // server shutdown, and is therefore always repeatable
- // without violating "at-most-once". That's because by
- // sending a close connection message, the server
- // guarantees that all outstanding requests can safely
- // be repeated.
- //
- // An ObjectNotExistException can always be retried as
- // well without violating "at-most-once".
- //
- if(dynamic_cast<CloseConnectionException*>(_exception.get()) ||
- dynamic_cast<ObjectNotExistException*>(_exception.get()))
- {
- _exception->ice_throw();
- }
-
- //
- // Throw the exception wrapped in a
- // LocalExceptionWrapper, to indicate that the request
- // cannot be resent without potentially violating the
- // "at-most-once" principle.
- //
- throw LocalExceptionWrapper(*_exception.get(), false);
- }
-
- if(_state == StateUserException)
- {
- return false;
- }
-
- assert(_state == StateOK);
- break;
- }
-
- case Reference::ModeOneway:
- case Reference::ModeDatagram:
- {
- //
- // For oneway and datagram requests, the connection object
- // never calls back on this object. Therefore we don't
- // need to lock the mutex or save exceptions. We simply
- // let all exceptions from sending propagate to the
- // caller, because such exceptions can be retried without
- // violating "at-most-once".
- //
- _state = StateInProgress;
- _connection->sendRequest(&_os, 0, _compress);
- break;
- }
-
- case Reference::ModeBatchOneway:
- case Reference::ModeBatchDatagram:
- {
- //
- // For batch oneways and datagrams, the same rules as for
- // regular oneways and datagrams (see comment above)
- // apply.
- //
- _state = StateInProgress;
- _connection->finishBatchRequest(&_os, _compress);
- break;
- }
+ //
+ if(_state == StateUnsent)
+ {
+ _state = StateInProgress;
+ }
+
+ Int timeout = _connection->timeout();
+ while(_state == StateInProgress && !timedOut)
+ {
+ if(timeout >= 0)
+ {
+ _monitor.timedWait(IceUtil::Time::milliSeconds(timeout));
+
+ if(_state == StateInProgress)
+ {
+ timedOut = true;
+ }
+ }
+ else
+ {
+ _monitor.wait();
+ }
+ }
+ }
+
+ if(timedOut)
+ {
+ //
+ // Must be called outside the synchronization of this
+ // object.
+ //
+ _connection->exception(TimeoutException(__FILE__, __LINE__));
+
+ //
+ // We must wait until the exception set above has
+ // propagated to this Outgoing object.
+ //
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
+
+ while(_state == StateInProgress)
+ {
+ _monitor.wait();
+ }
+ }
+ }
+
+ if(_exception.get())
+ {
+ //
+ // A CloseConnectionException indicates graceful
+ // server shutdown, and is therefore always repeatable
+ // without violating "at-most-once". That's because by
+ // sending a close connection message, the server
+ // guarantees that all outstanding requests can safely
+ // be repeated.
+ //
+ // An ObjectNotExistException can always be retried as
+ // well without violating "at-most-once".
+ //
+ if(dynamic_cast<CloseConnectionException*>(_exception.get()) ||
+ dynamic_cast<ObjectNotExistException*>(_exception.get()))
+ {
+ _exception->ice_throw();
+ }
+
+ //
+ // Throw the exception wrapped in a
+ // LocalExceptionWrapper, to indicate that the request
+ // cannot be resent without potentially violating the
+ // "at-most-once" principle.
+ //
+ throw LocalExceptionWrapper(*_exception.get(), false);
+ }
+
+ if(_state == StateUserException)
+ {
+ return false;
+ }
+
+ assert(_state == StateOK);
+ break;
+ }
+
+ case Reference::ModeOneway:
+ case Reference::ModeDatagram:
+ {
+ //
+ // For oneway and datagram requests, the connection object
+ // never calls back on this object. Therefore we don't
+ // need to lock the mutex or save exceptions. We simply
+ // let all exceptions from sending propagate to the
+ // caller, because such exceptions can be retried without
+ // violating "at-most-once".
+ //
+ _state = StateInProgress;
+ _connection->sendRequest(&_os, 0, _compress);
+ break;
+ }
+
+ case Reference::ModeBatchOneway:
+ case Reference::ModeBatchDatagram:
+ {
+ //
+ // For batch oneways and datagrams, the same rules as for
+ // regular oneways and datagrams (see comment above)
+ // apply.
+ //
+ _state = StateInProgress;
+ _connection->finishBatchRequest(&_os, _compress);
+ break;
+ }
}
return true;
@@ -298,14 +298,14 @@ IceInternal::Outgoing::abort(const LocalException& ex)
//
if(_reference->getMode() == Reference::ModeBatchOneway || _reference->getMode() == Reference::ModeBatchDatagram)
{
- _connection->abortBatchRequest();
-
- //
- // If we abort a batch requests, we cannot retry, because not
- // only the batch request that caused the problem will be
- // aborted, but all other requests in the batch as well.
- //
- throw LocalExceptionWrapper(ex, false);
+ _connection->abortBatchRequest();
+
+ //
+ // If we abort a batch requests, we cannot retry, because not
+ // only the batch request that caused the problem will be
+ // aborted, but all other requests in the batch as well.
+ //
+ throw LocalExceptionWrapper(ex, false);
}
ex.ice_throw();
@@ -326,152 +326,152 @@ IceInternal::Outgoing::finished(BasicStream& is)
switch(static_cast<DispatchStatus>(status))
{
- case DispatchOK:
- {
- //
- // Input and output parameters are always sent in an
- // encapsulation, which makes it possible to forward
- // oneway requests as blobs.
- //
- _is.startReadEncaps();
- _state = StateOK; // The state must be set last, in case there is an exception.
- break;
- }
-
- case DispatchUserException:
- {
- //
- // Input and output parameters are always sent in an
- // encapsulation, which makes it possible to forward
- // oneway requests as blobs.
- //
- _is.startReadEncaps();
- _state = StateUserException; // The state must be set last, in case there is an exception.
- break;
- }
-
- case DispatchObjectNotExist:
- case DispatchFacetNotExist:
- case DispatchOperationNotExist:
- {
- //
- // Don't read the exception members directly into the
- // exception. Otherwise if reading fails and raises an
- // exception, you will have a memory leak.
- //
- Identity ident;
- ident.__read(&_is);
-
- //
- // For compatibility with the old FacetPath.
- //
- vector<string> facetPath;
- _is.read(facetPath);
- string facet;
- if(!facetPath.empty())
- {
- if(facetPath.size() > 1)
- {
- throw MarshalException(__FILE__, __LINE__);
- }
- facet.swap(facetPath[0]);
- }
-
- string operation;
- _is.read(operation, false);
-
- RequestFailedException* ex;
- switch(static_cast<DispatchStatus>(status))
- {
- case DispatchObjectNotExist:
- {
- ex = new ObjectNotExistException(__FILE__, __LINE__);
- break;
- }
-
- case DispatchFacetNotExist:
- {
- ex = new FacetNotExistException(__FILE__, __LINE__);
- break;
- }
-
- case DispatchOperationNotExist:
- {
- ex = new OperationNotExistException(__FILE__, __LINE__);
- break;
- }
-
- default:
- {
- ex = 0; // To keep the compiler from complaining.
- assert(false);
- break;
- }
- }
-
- ex->id = ident;
- ex->facet = facet;
- ex->operation = operation;
- _exception.reset(ex);
-
- _state = StateLocalException; // The state must be set last, in case there is an exception.
- break;
- }
-
- case DispatchUnknownException:
- case DispatchUnknownLocalException:
- case DispatchUnknownUserException:
- {
- //
- // Don't read the exception members directly into the
- // exception. Otherwise if reading fails and raises an
- // exception, you will have a memory leak.
- //
- string unknown;
- _is.read(unknown, false);
-
- UnknownException* ex;
- switch(static_cast<DispatchStatus>(status))
- {
- case DispatchUnknownException:
- {
- ex = new UnknownException(__FILE__, __LINE__);
- break;
- }
-
- case DispatchUnknownLocalException:
- {
- ex = new UnknownLocalException(__FILE__, __LINE__);
- break;
- }
-
- case DispatchUnknownUserException:
- {
- ex = new UnknownUserException(__FILE__, __LINE__);
- break;
- }
-
- default:
- {
- ex = 0; // To keep the compiler from complaining.
- assert(false);
- break;
- }
- }
-
- ex->unknown = unknown;
- _exception.reset(ex);
-
- _state = StateLocalException; // The state must be set last, in case there is an exception.
- break;
- }
-
- default:
- {
- _exception.reset(new UnknownReplyStatusException(__FILE__, __LINE__));
- _state = StateLocalException;
- break;
- }
+ case DispatchOK:
+ {
+ //
+ // Input and output parameters are always sent in an
+ // encapsulation, which makes it possible to forward
+ // oneway requests as blobs.
+ //
+ _is.startReadEncaps();
+ _state = StateOK; // The state must be set last, in case there is an exception.
+ break;
+ }
+
+ case DispatchUserException:
+ {
+ //
+ // Input and output parameters are always sent in an
+ // encapsulation, which makes it possible to forward
+ // oneway requests as blobs.
+ //
+ _is.startReadEncaps();
+ _state = StateUserException; // The state must be set last, in case there is an exception.
+ break;
+ }
+
+ case DispatchObjectNotExist:
+ case DispatchFacetNotExist:
+ case DispatchOperationNotExist:
+ {
+ //
+ // Don't read the exception members directly into the
+ // exception. Otherwise if reading fails and raises an
+ // exception, you will have a memory leak.
+ //
+ Identity ident;
+ ident.__read(&_is);
+
+ //
+ // For compatibility with the old FacetPath.
+ //
+ vector<string> facetPath;
+ _is.read(facetPath);
+ string facet;
+ if(!facetPath.empty())
+ {
+ if(facetPath.size() > 1)
+ {
+ throw MarshalException(__FILE__, __LINE__);
+ }
+ facet.swap(facetPath[0]);
+ }
+
+ string operation;
+ _is.read(operation, false);
+
+ RequestFailedException* ex;
+ switch(static_cast<DispatchStatus>(status))
+ {
+ case DispatchObjectNotExist:
+ {
+ ex = new ObjectNotExistException(__FILE__, __LINE__);
+ break;
+ }
+
+ case DispatchFacetNotExist:
+ {
+ ex = new FacetNotExistException(__FILE__, __LINE__);
+ break;
+ }
+
+ case DispatchOperationNotExist:
+ {
+ ex = new OperationNotExistException(__FILE__, __LINE__);
+ break;
+ }
+
+ default:
+ {
+ ex = 0; // To keep the compiler from complaining.
+ assert(false);
+ break;
+ }
+ }
+
+ ex->id = ident;
+ ex->facet = facet;
+ ex->operation = operation;
+ _exception.reset(ex);
+
+ _state = StateLocalException; // The state must be set last, in case there is an exception.
+ break;
+ }
+
+ case DispatchUnknownException:
+ case DispatchUnknownLocalException:
+ case DispatchUnknownUserException:
+ {
+ //
+ // Don't read the exception members directly into the
+ // exception. Otherwise if reading fails and raises an
+ // exception, you will have a memory leak.
+ //
+ string unknown;
+ _is.read(unknown, false);
+
+ UnknownException* ex;
+ switch(static_cast<DispatchStatus>(status))
+ {
+ case DispatchUnknownException:
+ {
+ ex = new UnknownException(__FILE__, __LINE__);
+ break;
+ }
+
+ case DispatchUnknownLocalException:
+ {
+ ex = new UnknownLocalException(__FILE__, __LINE__);
+ break;
+ }
+
+ case DispatchUnknownUserException:
+ {
+ ex = new UnknownUserException(__FILE__, __LINE__);
+ break;
+ }
+
+ default:
+ {
+ ex = 0; // To keep the compiler from complaining.
+ assert(false);
+ break;
+ }
+ }
+
+ ex->unknown = unknown;
+ _exception.reset(ex);
+
+ _state = StateLocalException; // The state must be set last, in case there is an exception.
+ break;
+ }
+
+ default:
+ {
+ _exception.reset(new UnknownReplyStatusException(__FILE__, __LINE__));
+ _state = StateLocalException;
+ break;
+ }
}
_monitor.notify();
diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp
index e03c3b58d57..ad53705d9e9 100644
--- a/cpp/src/Ice/OutgoingAsync.cpp
+++ b/cpp/src/Ice/OutgoingAsync.cpp
@@ -56,148 +56,148 @@ IceInternal::OutgoingAsync::__finished(BasicStream& is)
try
{
- __is->swap(is);
-
- Byte b;
- __is->read(b);
- status = static_cast<DispatchStatus>(b);
-
- switch(status)
- {
- case DispatchOK:
- case DispatchUserException:
- {
- __is->startReadEncaps();
- break;
- }
-
- case DispatchObjectNotExist:
- case DispatchFacetNotExist:
- case DispatchOperationNotExist:
- {
- Identity ident;
- ident.__read(__is);
-
- //
- // For compatibility with the old FacetPath.
- //
- vector<string> facetPath;
- __is->read(facetPath);
- string facet;
- if(!facetPath.empty())
- {
- if(facetPath.size() > 1)
- {
- throw MarshalException(__FILE__, __LINE__);
- }
- facet.swap(facetPath[0]);
- }
-
- string operation;
- __is->read(operation, false);
-
- auto_ptr<RequestFailedException> ex;
- switch(static_cast<DispatchStatus>(status))
- {
- case DispatchObjectNotExist:
- {
- ex.reset(new ObjectNotExistException(__FILE__, __LINE__));
- break;
- }
-
- case DispatchFacetNotExist:
- {
- ex.reset(new FacetNotExistException(__FILE__, __LINE__));
- break;
- }
-
- case DispatchOperationNotExist:
- {
- ex.reset(new OperationNotExistException(__FILE__, __LINE__));
- break;
- }
-
- default:
- {
- assert(false);
- break;
- }
- }
-
- ex->id = ident;
- ex->facet = facet;
- ex->operation = operation;
- ex->ice_throw();
- }
-
- case DispatchUnknownException:
- case DispatchUnknownLocalException:
- case DispatchUnknownUserException:
- {
- string unknown;
- __is->read(unknown, false);
-
- auto_ptr<UnknownException> ex;
- switch(static_cast<DispatchStatus>(status))
- {
- case DispatchUnknownException:
- {
- ex.reset(new UnknownException(__FILE__, __LINE__));
- break;
- }
-
- case DispatchUnknownLocalException:
- {
- ex.reset(new UnknownLocalException(__FILE__, __LINE__));
- break;
- }
-
- case DispatchUnknownUserException:
- {
- ex.reset(new UnknownUserException(__FILE__, __LINE__));
- break;
- }
-
- default:
- {
- assert(false);
- break;
- }
- }
-
- ex->unknown = unknown;
- ex->ice_throw();
- }
-
- default:
- {
- throw UnknownReplyStatusException(__FILE__, __LINE__);
- }
- }
+ __is->swap(is);
+
+ Byte b;
+ __is->read(b);
+ status = static_cast<DispatchStatus>(b);
+
+ switch(status)
+ {
+ case DispatchOK:
+ case DispatchUserException:
+ {
+ __is->startReadEncaps();
+ break;
+ }
+
+ case DispatchObjectNotExist:
+ case DispatchFacetNotExist:
+ case DispatchOperationNotExist:
+ {
+ Identity ident;
+ ident.__read(__is);
+
+ //
+ // For compatibility with the old FacetPath.
+ //
+ vector<string> facetPath;
+ __is->read(facetPath);
+ string facet;
+ if(!facetPath.empty())
+ {
+ if(facetPath.size() > 1)
+ {
+ throw MarshalException(__FILE__, __LINE__);
+ }
+ facet.swap(facetPath[0]);
+ }
+
+ string operation;
+ __is->read(operation, false);
+
+ auto_ptr<RequestFailedException> ex;
+ switch(static_cast<DispatchStatus>(status))
+ {
+ case DispatchObjectNotExist:
+ {
+ ex.reset(new ObjectNotExistException(__FILE__, __LINE__));
+ break;
+ }
+
+ case DispatchFacetNotExist:
+ {
+ ex.reset(new FacetNotExistException(__FILE__, __LINE__));
+ break;
+ }
+
+ case DispatchOperationNotExist:
+ {
+ ex.reset(new OperationNotExistException(__FILE__, __LINE__));
+ break;
+ }
+
+ default:
+ {
+ assert(false);
+ break;
+ }
+ }
+
+ ex->id = ident;
+ ex->facet = facet;
+ ex->operation = operation;
+ ex->ice_throw();
+ }
+
+ case DispatchUnknownException:
+ case DispatchUnknownLocalException:
+ case DispatchUnknownUserException:
+ {
+ string unknown;
+ __is->read(unknown, false);
+
+ auto_ptr<UnknownException> ex;
+ switch(static_cast<DispatchStatus>(status))
+ {
+ case DispatchUnknownException:
+ {
+ ex.reset(new UnknownException(__FILE__, __LINE__));
+ break;
+ }
+
+ case DispatchUnknownLocalException:
+ {
+ ex.reset(new UnknownLocalException(__FILE__, __LINE__));
+ break;
+ }
+
+ case DispatchUnknownUserException:
+ {
+ ex.reset(new UnknownUserException(__FILE__, __LINE__));
+ break;
+ }
+
+ default:
+ {
+ assert(false);
+ break;
+ }
+ }
+
+ ex->unknown = unknown;
+ ex->ice_throw();
+ }
+
+ default:
+ {
+ throw UnknownReplyStatusException(__FILE__, __LINE__);
+ }
+ }
}
catch(const LocalException& ex)
{
- __finished(ex);
- return;
+ __finished(ex);
+ return;
}
assert(status == DispatchOK || status == DispatchUserException);
try
{
- __response(status == DispatchOK);
+ __response(status == DispatchOK);
}
catch(const Exception& ex)
{
- warning(ex);
+ warning(ex);
}
catch(const std::exception& ex)
{
- warning(ex);
+ warning(ex);
}
catch(...)
{
- warning();
+ warning();
}
cleanup();
@@ -210,48 +210,48 @@ IceInternal::OutgoingAsync::__finished(const LocalException& exc)
if(__os) // Don't retry if cleanup() was already called.
{
- //
- // A CloseConnectionException indicates graceful server
- // shutdown, and is therefore always repeatable without
- // violating "at-most-once". That's because by sending a close
- // connection message, the server guarantees that all
- // outstanding requests can safely be repeated. Otherwise, we
- // can also retry if the operation mode is Nonmutating or
- // Idempotent.
- //
- // An ObjectNotExistException can always be retried as
- // well without violating "at-most-once".
- //
- if(_mode == Nonmutating || _mode == Idempotent || dynamic_cast<const CloseConnectionException*>(&exc) ||
- dynamic_cast<const ObjectNotExistException*>(&exc))
- {
- try
- {
- _proxy->__handleException(_delegate, exc, _cnt);
- __send();
- return;
- }
- catch(const LocalException&)
- {
- }
- }
+ //
+ // A CloseConnectionException indicates graceful server
+ // shutdown, and is therefore always repeatable without
+ // violating "at-most-once". That's because by sending a close
+ // connection message, the server guarantees that all
+ // outstanding requests can safely be repeated. Otherwise, we
+ // can also retry if the operation mode is Nonmutating or
+ // Idempotent.
+ //
+ // An ObjectNotExistException can always be retried as
+ // well without violating "at-most-once".
+ //
+ if(_mode == Nonmutating || _mode == Idempotent || dynamic_cast<const CloseConnectionException*>(&exc) ||
+ dynamic_cast<const ObjectNotExistException*>(&exc))
+ {
+ try
+ {
+ _proxy->__handleException(_delegate, exc, _cnt);
+ __send();
+ return;
+ }
+ catch(const LocalException&)
+ {
+ }
+ }
}
try
{
- ice_exception(exc);
+ ice_exception(exc);
}
catch(const Exception& ex)
{
- warning(ex);
+ warning(ex);
}
catch(const std::exception& ex)
{
- warning(ex);
+ warning(ex);
}
catch(...)
{
- warning();
+ warning();
}
cleanup();
@@ -259,90 +259,90 @@ IceInternal::OutgoingAsync::__finished(const LocalException& exc)
void
IceInternal::OutgoingAsync::__prepare(const ObjectPrx& prx, const string& operation, OperationMode mode,
- const Context* context)
+ const Context* context)
{
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(_monitor);
try
{
- //
- // We must first wait for other requests to finish.
- //
- while(__os)
- {
- _monitor.wait();
- }
-
- //
- // Can't call async via a oneway proxy.
- //
- prx->__checkTwowayOnly(operation);
-
- _proxy = prx;
+ //
+ // We must first wait for other requests to finish.
+ //
+ while(__os)
+ {
+ _monitor.wait();
+ }
+
+ //
+ // Can't call async via a oneway proxy.
+ //
+ prx->__checkTwowayOnly(operation);
+
+ _proxy = prx;
_delegate = 0;
- _cnt = 0;
- _mode = mode;
-
- ReferencePtr ref = _proxy->__reference();
- assert(!__is);
- __is = new BasicStream(ref->getInstance().get());
- assert(!__os);
- __os = new BasicStream(ref->getInstance().get());
-
- __os->writeBlob(requestHdr, sizeof(requestHdr));
-
- ref->getIdentity().__write(__os);
-
- //
- // For compatibility with the old FacetPath.
- //
- if(ref->getFacet().empty())
- {
- __os->write(static_cast<string*>(0), static_cast<string*>(0));
- }
- else
- {
- string facet = ref->getFacet();
- __os->write(&facet, &facet + 1);
- }
-
- __os->write(operation, false);
-
- __os->write(static_cast<Byte>(_mode));
-
- if(context != 0)
- {
- //
- // Explicit context
- //
- __write(__os, *context, __U__Context());
- }
- else
- {
- //
- // Implicit context
- //
- const ImplicitContextIPtr& implicitContext =
- ref->getInstance()->getImplicitContext();
-
- const Context& prxContext = ref->getContext()->getValue();
-
- if(implicitContext == 0)
- {
- __write(__os, prxContext, __U__Context());
- }
- else
- {
- implicitContext->write(prxContext, __os);
- }
- }
-
- __os->startWriteEncaps();
+ _cnt = 0;
+ _mode = mode;
+
+ ReferencePtr ref = _proxy->__reference();
+ assert(!__is);
+ __is = new BasicStream(ref->getInstance().get());
+ assert(!__os);
+ __os = new BasicStream(ref->getInstance().get());
+
+ __os->writeBlob(requestHdr, sizeof(requestHdr));
+
+ ref->getIdentity().__write(__os);
+
+ //
+ // For compatibility with the old FacetPath.
+ //
+ if(ref->getFacet().empty())
+ {
+ __os->write(static_cast<string*>(0), static_cast<string*>(0));
+ }
+ else
+ {
+ string facet = ref->getFacet();
+ __os->write(&facet, &facet + 1);
+ }
+
+ __os->write(operation, false);
+
+ __os->write(static_cast<Byte>(_mode));
+
+ if(context != 0)
+ {
+ //
+ // Explicit context
+ //
+ __write(__os, *context, __U__Context());
+ }
+ else
+ {
+ //
+ // Implicit context
+ //
+ const ImplicitContextIPtr& implicitContext =
+ ref->getInstance()->getImplicitContext();
+
+ const Context& prxContext = ref->getContext()->getValue();
+
+ if(implicitContext == 0)
+ {
+ __write(__os, prxContext, __U__Context());
+ }
+ else
+ {
+ implicitContext->write(prxContext, __os);
+ }
+ }
+
+ __os->startWriteEncaps();
}
catch(const LocalException& ex)
{
- cleanup();
- ex.ice_throw();
+ cleanup();
+ ex.ice_throw();
}
}
@@ -353,37 +353,37 @@ IceInternal::OutgoingAsync::__send()
try
{
- while(true)
- {
- bool compress;
- _delegate = _proxy->__getDelegate();
- Ice::ConnectionIPtr connection = _delegate->__getConnection(compress);
- try
- {
- connection->sendAsyncRequest(__os, this, compress);
-
- //
- // Don't do anything after sendAsyncRequest() returned
- // without an exception. I such case, there will be
- // callbacks, i.e., calls to the __finished()
- // functions. Since there is no mutex protection, we
- // cannot modify state here and in such callbacks.
- //
- return;
- }
- catch(const LocalExceptionWrapper& ex)
- {
- _proxy->__handleExceptionWrapper(_delegate, ex);
- }
- catch(const LocalException& ex)
- {
- _proxy->__handleException(_delegate, ex, _cnt);
- }
- }
+ while(true)
+ {
+ bool compress;
+ _delegate = _proxy->__getDelegate();
+ Ice::ConnectionIPtr connection = _delegate->__getConnection(compress);
+ try
+ {
+ connection->sendAsyncRequest(__os, this, compress);
+
+ //
+ // Don't do anything after sendAsyncRequest() returned
+ // without an exception. I such case, there will be
+ // callbacks, i.e., calls to the __finished()
+ // functions. Since there is no mutex protection, we
+ // cannot modify state here and in such callbacks.
+ //
+ return;
+ }
+ catch(const LocalExceptionWrapper& ex)
+ {
+ _proxy->__handleExceptionWrapper(_delegate, ex);
+ }
+ catch(const LocalException& ex)
+ {
+ _proxy->__handleException(_delegate, ex, _cnt);
+ }
+ }
}
catch(const LocalException& ex)
{
- __finished(ex);
+ __finished(ex);
}
}
@@ -392,13 +392,13 @@ IceInternal::OutgoingAsync::warning(const Exception& ex) const
{
if(__os) // Don't print anything if cleanup() was already called.
{
- ReferencePtr ref = _proxy->__reference();
- if(ref->getInstance()->initializationData().properties->
- getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0)
- {
- Warning out(ref->getInstance()->initializationData().logger);
- out << "Ice::Exception raised by AMI callback:\n" << ex;
- }
+ ReferencePtr ref = _proxy->__reference();
+ if(ref->getInstance()->initializationData().properties->
+ getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0)
+ {
+ Warning out(ref->getInstance()->initializationData().logger);
+ out << "Ice::Exception raised by AMI callback:\n" << ex;
+ }
}
}
@@ -407,13 +407,13 @@ IceInternal::OutgoingAsync::warning(const std::exception& ex) const
{
if(__os) // Don't print anything if cleanup() was already called.
{
- ReferencePtr ref = _proxy->__reference();
- if(ref->getInstance()->initializationData().properties->
- getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0)
- {
- Warning out(ref->getInstance()->initializationData().logger);
- out << "std::exception raised by AMI callback:\n" << ex.what();
- }
+ ReferencePtr ref = _proxy->__reference();
+ if(ref->getInstance()->initializationData().properties->
+ getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0)
+ {
+ Warning out(ref->getInstance()->initializationData().logger);
+ out << "std::exception raised by AMI callback:\n" << ex.what();
+ }
}
}
@@ -422,13 +422,13 @@ IceInternal::OutgoingAsync::warning() const
{
if(__os) // Don't print anything if cleanup() was already called.
{
- ReferencePtr ref = _proxy->__reference();
- if(ref->getInstance()->initializationData().properties->
- getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0)
- {
- Warning out(ref->getInstance()->initializationData().logger);
- out << "unknown exception raised by AMI callback";
- }
+ ReferencePtr ref = _proxy->__reference();
+ if(ref->getInstance()->initializationData().properties->
+ getPropertyAsIntWithDefault("Ice.Warn.AMICallback", 1) > 0)
+ {
+ Warning out(ref->getInstance()->initializationData().logger);
+ out << "unknown exception raised by AMI callback";
+ }
}
}
@@ -445,18 +445,18 @@ IceInternal::OutgoingAsync::cleanup()
void
Ice::AMI_Object_ice_invoke::__invoke(const ObjectPrx& prx, const string& operation, OperationMode mode,
- const vector<Byte>& inParams, const Context* context)
+ const vector<Byte>& inParams, const Context* context)
{
try
{
- __prepare(prx, operation, mode, context);
- __os->writeBlob(inParams);
- __os->endWriteEncaps();
+ __prepare(prx, operation, mode, context);
+ __os->writeBlob(inParams);
+ __os->endWriteEncaps();
}
catch(const LocalException& ex)
{
- __finished(ex);
- return;
+ __finished(ex);
+ return;
}
__send();
}
@@ -467,31 +467,31 @@ Ice::AMI_Object_ice_invoke::__response(bool ok) // ok == true means no user exce
vector<Byte> outParams;
try
{
- Int sz = __is->getReadEncapsSize();
- __is->readBlob(outParams, sz);
+ Int sz = __is->getReadEncapsSize();
+ __is->readBlob(outParams, sz);
}
catch(const LocalException& ex)
{
- __finished(ex);
- return;
+ __finished(ex);
+ return;
}
ice_response(ok, outParams);
}
void
Ice::AMI_Array_Object_ice_invoke::__invoke(const ObjectPrx& prx, const string& operation, OperationMode mode,
- const pair<const Byte*, const Byte*>& inParams, const Context* context)
+ const pair<const Byte*, const Byte*>& inParams, const Context* context)
{
try
{
- __prepare(prx, operation, mode, context);
- __os->writeBlob(inParams.first, static_cast<Int>(inParams.second - inParams.first));
- __os->endWriteEncaps();
+ __prepare(prx, operation, mode, context);
+ __os->writeBlob(inParams.first, static_cast<Int>(inParams.second - inParams.first));
+ __os->endWriteEncaps();
}
catch(const LocalException& ex)
{
- __finished(ex);
- return;
+ __finished(ex);
+ return;
}
__send();
}
@@ -502,14 +502,14 @@ Ice::AMI_Array_Object_ice_invoke::__response(bool ok) // ok == true means no use
pair<const Byte*, const Byte*> outParams;
try
{
- Int sz = __is->getReadEncapsSize();
- __is->readBlob(outParams.first, sz);
- outParams.second = outParams.first + sz;
+ Int sz = __is->getReadEncapsSize();
+ __is->readBlob(outParams.first, sz);
+ outParams.second = outParams.first + sz;
}
catch(const LocalException& ex)
{
- __finished(ex);
- return;
+ __finished(ex);
+ return;
}
ice_response(ok, outParams);
}
diff --git a/cpp/src/Ice/PluginManagerI.cpp b/cpp/src/Ice/PluginManagerI.cpp
index b199954e938..123c74c0be8 100644
--- a/cpp/src/Ice/PluginManagerI.cpp
+++ b/cpp/src/Ice/PluginManagerI.cpp
@@ -29,9 +29,9 @@ Ice::PluginManagerI::initializePlugins()
{
if(_initialized)
{
- InitializationException ex(__FILE__, __LINE__);
- ex.reason = "plugins already initialized";
- throw ex;
+ InitializationException ex(__FILE__, __LINE__);
+ ex.reason = "plugins already initialized";
+ throw ex;
}
//
@@ -40,30 +40,30 @@ Ice::PluginManagerI::initializePlugins()
vector<PluginPtr> initializedPlugins;
try
{
- for(vector<PluginPtr>::iterator p = _initOrder.begin(); p != _initOrder.end(); ++p)
- {
- (*p)->initialize();
- initializedPlugins.push_back(*p);
- }
+ for(vector<PluginPtr>::iterator p = _initOrder.begin(); p != _initOrder.end(); ++p)
+ {
+ (*p)->initialize();
+ initializedPlugins.push_back(*p);
+ }
}
catch(...)
{
- //
- // Destroy the plugins that have been successfully initialized, in the
- // reverse order.
- //
- for(vector<PluginPtr>::reverse_iterator p = initializedPlugins.rbegin(); p != initializedPlugins.rend(); ++p)
- {
- try
- {
- (*p)->destroy();
- }
- catch(...)
- {
- // Ignore.
- }
- }
- throw;
+ //
+ // Destroy the plugins that have been successfully initialized, in the
+ // reverse order.
+ //
+ for(vector<PluginPtr>::reverse_iterator p = initializedPlugins.rbegin(); p != initializedPlugins.rend(); ++p)
+ {
+ try
+ {
+ (*p)->destroy();
+ }
+ catch(...)
+ {
+ // Ignore.
+ }
+ }
+ throw;
}
_initialized = true;
@@ -76,7 +76,7 @@ Ice::PluginManagerI::getPlugin(const string& name)
if(!_communicator)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
map<string, PluginPtr>::const_iterator r = _plugins.find(name);
@@ -98,16 +98,16 @@ Ice::PluginManagerI::addPlugin(const string& name, const PluginPtr& plugin)
if(!_communicator)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
map<string, PluginPtr>::const_iterator r = _plugins.find(name);
if(r != _plugins.end())
{
AlreadyRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = _kindOfObject;
- ex.id = name;
- throw ex;
+ ex.kindOfObject = _kindOfObject;
+ ex.id = name;
+ throw ex;
}
_plugins[name] = plugin;
}
@@ -119,15 +119,15 @@ Ice::PluginManagerI::destroy()
if(_communicator)
{
- map<string, PluginPtr>::iterator r;
- for(r = _plugins.begin(); r != _plugins.end(); ++r)
- {
- r->second->destroy();
- r->second = 0;
- }
-
- _logger = 0;
- _communicator = 0;
+ map<string, PluginPtr>::iterator r;
+ for(r = _plugins.begin(); r != _plugins.end(); ++r)
+ {
+ r->second->destroy();
+ r->second = 0;
+ }
+
+ _logger = 0;
+ _communicator = 0;
}
_libraries = 0;
@@ -166,44 +166,44 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
string::size_type beg = 0;
if(!loadOrder.empty())
{
- const string delim = ", \t\n";
- beg = loadOrder.find_first_not_of(delim, beg);
- while(beg != string::npos)
- {
- string name;
- string::size_type end = loadOrder.find_first_of(delim, beg);
- if(end == string::npos)
- {
- name = loadOrder.substr(beg);
- beg = end;
- }
- else
- {
- name = loadOrder.substr(beg, end - beg);
- beg = loadOrder.find_first_not_of(delim, end);
- }
-
- map<string, PluginPtr>::iterator p = _plugins.find(name);
- if(p != _plugins.end())
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "plugin `" + name + "' already loaded";
- throw ex;
- }
-
- PropertyDict::iterator q = plugins.find("Ice.Plugin." + name);
- if(q != plugins.end())
- {
- loadPlugin(name, q->second, cmdArgs, false);
- plugins.erase(q);
- }
- else
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "plugin `" + name + "' not defined";
- throw ex;
- }
- }
+ const string delim = ", \t\n";
+ beg = loadOrder.find_first_not_of(delim, beg);
+ while(beg != string::npos)
+ {
+ string name;
+ string::size_type end = loadOrder.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ name = loadOrder.substr(beg);
+ beg = end;
+ }
+ else
+ {
+ name = loadOrder.substr(beg, end - beg);
+ beg = loadOrder.find_first_not_of(delim, end);
+ }
+
+ map<string, PluginPtr>::iterator p = _plugins.find(name);
+ if(p != _plugins.end())
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "plugin `" + name + "' already loaded";
+ throw ex;
+ }
+
+ PropertyDict::iterator q = plugins.find("Ice.Plugin." + name);
+ if(q != plugins.end())
+ {
+ loadPlugin(name, q->second, cmdArgs, false);
+ plugins.erase(q);
+ }
+ else
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "plugin `" + name + "' not defined";
+ throw ex;
+ }
+ }
}
//
@@ -213,7 +213,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
for(p = plugins.begin(); p != plugins.end(); ++p)
{
string name = p->first.substr(prefix.size());
- loadPlugin(name, p->second, cmdArgs, false);
+ loadPlugin(name, p->second, cmdArgs, false);
}
string loggerStr = properties->getProperty("Ice.LoggerPlugin");
@@ -231,7 +231,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
//
if(properties->getPropertyAsIntWithDefault("Ice.InitPlugins", 1) > 0)
{
- initializePlugins();
+ initializePlugins();
}
}
@@ -249,26 +249,26 @@ Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, St
string::size_type pos = pluginSpec.find_first_of(delim);
if(pos == string::npos)
{
- entryPoint = pluginSpec;
+ entryPoint = pluginSpec;
}
else
{
- 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);
- }
- }
+ 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);
+ }
+ }
}
//
@@ -307,15 +307,15 @@ Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, St
if(isLogger)
{
LOGGER_FACTORY factory = (LOGGER_FACTORY)sym;
- _logger = factory(_communicator, args);
- if(!_logger)
- {
+ _logger = factory(_communicator, args);
+ if(!_logger)
+ {
PluginInitializationException e(__FILE__, __LINE__);
ostringstream out;
out << "failure in entry point `" << entryPoint << "'";
e.reason = out.str();
throw e;
- }
+ }
}
else
{
diff --git a/cpp/src/Ice/PropertiesI.cpp b/cpp/src/Ice/PropertiesI.cpp
index 84b0f29bce3..86ddccf7cae 100644
--- a/cpp/src/Ice/PropertiesI.cpp
+++ b/cpp/src/Ice/PropertiesI.cpp
@@ -28,11 +28,11 @@ Ice::PropertiesI::getProperty(const string& key)
map<string, string>::const_iterator p = _properties.find(key);
if(p != _properties.end())
{
- return p->second;
+ return p->second;
}
else
{
- return string();
+ return string();
}
}
@@ -44,11 +44,11 @@ Ice::PropertiesI::getPropertyWithDefault(const string& key, const string& value)
map<string, string>::const_iterator p = _properties.find(key);
if(p != _properties.end())
{
- return p->second;
+ return p->second;
}
else
{
- return value;
+ return value;
}
}
@@ -66,11 +66,11 @@ Ice::PropertiesI::getPropertyAsIntWithDefault(const string& key, Int value)
map<string, string>::const_iterator p = _properties.find(key);
if(p != _properties.end())
{
- istringstream v(p->second);
- if(!(v >> value) || !v.eof())
- {
- return 0;
- }
+ istringstream v(p->second);
+ if(!(v >> value) || !v.eof())
+ {
+ return 0;
+ }
}
return value;
@@ -99,7 +99,7 @@ Ice::PropertiesI::setProperty(const string& key, const string& value)
{
if(key.empty())
{
- return;
+ return;
}
//
@@ -109,28 +109,28 @@ Ice::PropertiesI::setProperty(const string& key, const string& value)
string::size_type dotPos = key.find('.');
if(dotPos != string::npos)
{
- string prefix = key.substr(0, dotPos);
- for(const char* const** i = IceInternal::PropertyNames::validProps; *i != 0; ++i)
- {
- string pattern(*i[0]);
- dotPos = pattern.find('.');
- assert(dotPos != string::npos);
- string propPrefix = pattern.substr(0, dotPos);
- if(propPrefix != prefix)
- {
- continue;
- }
-
- bool found = false;
- for(const char* const* j = *i; *j != 0 && !found; ++j)
- {
- found = IceUtil::match(key, *j);
- }
- if(!found)
- {
- logger->warning("unknown property: " + key);
- }
- }
+ string prefix = key.substr(0, dotPos);
+ for(const char* const** i = IceInternal::PropertyNames::validProps; *i != 0; ++i)
+ {
+ string pattern(*i[0]);
+ dotPos = pattern.find('.');
+ assert(dotPos != string::npos);
+ string propPrefix = pattern.substr(0, dotPos);
+ if(propPrefix != prefix)
+ {
+ continue;
+ }
+
+ bool found = false;
+ for(const char* const* j = *i; *j != 0 && !found; ++j)
+ {
+ found = IceUtil::match(key, *j);
+ }
+ if(!found)
+ {
+ logger->warning("unknown property: " + key);
+ }
+ }
}
IceUtil::Mutex::Lock sync(*this);
@@ -140,11 +140,11 @@ Ice::PropertiesI::setProperty(const string& key, const string& value)
//
if(!value.empty())
{
- _properties[key] = value;
+ _properties[key] = value;
}
else
{
- _properties.erase(key);
+ _properties.erase(key);
}
}
@@ -158,7 +158,7 @@ Ice::PropertiesI::getCommandLineOptions()
map<string, string>::const_iterator p;
for(p = _properties.begin(); p != _properties.end(); ++p)
{
- result.push_back("--" + p->first + "=" + p->second);
+ result.push_back("--" + p->first + "=" + p->second);
}
return result;
}
@@ -169,7 +169,7 @@ Ice::PropertiesI::parseCommandLineOptions(const string& prefix, const StringSeq&
string pfx = prefix;
if(!pfx.empty() && pfx[pfx.size() - 1] != '.')
{
- pfx += '.';
+ pfx += '.';
}
pfx = "--" + pfx;
@@ -215,7 +215,7 @@ Ice::PropertiesI::load(const std::string& file)
if(!in)
{
FileException ex(__FILE__, __LINE__);
- ex.path = file;
+ ex.path = file;
ex.error = getSystemErrno();
throw ex;
}
@@ -223,7 +223,7 @@ Ice::PropertiesI::load(const std::string& file)
char line[1024];
while(in.getline(line, 1024))
{
- parseLine(line, _converter);
+ parseLine(line, _converter);
}
}
@@ -250,24 +250,24 @@ Ice::PropertiesI::PropertiesI(StringSeq& args, const PropertiesPtr& defaults, co
{
if(defaults != 0)
{
- _properties = defaults->getPropertiesForPrefix("");
+ _properties = defaults->getPropertiesForPrefix("");
}
StringSeq::iterator q = args.begin();
if(_properties.find("Ice.ProgramName") == _properties.end())
{
- if(q != args.end())
- {
- //
- // Use the first argument as the value for Ice.ProgramName. Replace
- // any backslashes in this value with forward slashes, in case this
- // value is used by the event logger.
- //
- string name = *q;
- replace(name.begin(), name.end(), '\\', '/');
- setProperty("Ice.ProgramName", name);
- }
+ if(q != args.end())
+ {
+ //
+ // Use the first argument as the value for Ice.ProgramName. Replace
+ // any backslashes in this value with forward slashes, in case this
+ // value is used by the event logger.
+ //
+ string name = *q;
+ replace(name.begin(), name.end(), '\\', '/');
+ setProperty("Ice.ProgramName", name);
+ }
}
StringSeq tmp;
@@ -283,27 +283,27 @@ Ice::PropertiesI::PropertiesI(StringSeq& args, const PropertiesPtr& defaults, co
s += "=1";
}
parseLine(s.substr(2), 0);
- loadConfigFiles = true;
+ loadConfigFiles = true;
}
else
{
- tmp.push_back(s);
+ tmp.push_back(s);
}
- ++q;
+ ++q;
}
args = tmp;
if(!loadConfigFiles)
{
- //
- // If Ice.Config is not set, load from ICE_CONFIG (if set)
- //
- loadConfigFiles = (_properties.find("Ice.Config") == _properties.end());
+ //
+ // If Ice.Config is not set, load from ICE_CONFIG (if set)
+ //
+ loadConfigFiles = (_properties.find("Ice.Config") == _properties.end());
}
if(loadConfigFiles)
{
- loadConfig();
+ loadConfig();
}
args = parseIceCommandLineOptions(args);
@@ -319,25 +319,25 @@ Ice::PropertiesI::parseLine(const string& line, const StringConverterPtr& conver
string::size_type idx = s.find('#');
if(idx != string::npos)
{
- s.erase(idx);
+ s.erase(idx);
}
idx = s.find_last_not_of(delim);
if(idx != string::npos && idx + 1 < s.length())
{
- s.erase(idx + 1);
+ s.erase(idx + 1);
}
string::size_type beg = s.find_first_not_of(delim);
if(beg == string::npos)
{
- return;
+ return;
}
string::size_type end = s.find_first_of(delim + "=", beg);
if(end == string::npos)
{
- return;
+ return;
}
string key = s.substr(beg, end - beg);
@@ -345,7 +345,7 @@ Ice::PropertiesI::parseLine(const string& line, const StringConverterPtr& conver
end = s.find('=', end);
if(end == string::npos)
{
- return;
+ return;
}
++end;
@@ -353,20 +353,20 @@ Ice::PropertiesI::parseLine(const string& line, const StringConverterPtr& conver
beg = s.find_first_not_of(delim, end);
if(beg != string::npos)
{
- end = s.length();
- value = s.substr(beg, end - beg);
+ end = s.length();
+ value = s.substr(beg, end - beg);
}
if(converter)
{
string tmp;
- converter->fromUTF8(reinterpret_cast<const Byte*>(key.data()),
- reinterpret_cast<const Byte*>(key.data() + key.size()), tmp);
- key.swap(tmp);
+ converter->fromUTF8(reinterpret_cast<const Byte*>(key.data()),
+ reinterpret_cast<const Byte*>(key.data() + key.size()), tmp);
+ key.swap(tmp);
- converter->fromUTF8(reinterpret_cast<const Byte*>(value.data()),
- reinterpret_cast<const Byte*>(value.data() + value.size()), tmp);
- value.swap(tmp);
+ converter->fromUTF8(reinterpret_cast<const Byte*>(value.data()),
+ reinterpret_cast<const Byte*>(value.data() + value.size()), tmp);
+ value.swap(tmp);
}
setProperty(key, value);
diff --git a/cpp/src/Ice/Protocol.cpp b/cpp/src/Ice/Protocol.cpp
index 793748dbae2..fbe3f832934 100644
--- a/cpp/src/Ice/Protocol.cpp
+++ b/cpp/src/Ice/Protocol.cpp
@@ -12,7 +12,7 @@
namespace IceInternal
{
-const Ice::Byte magic[] = { 0x49, 0x63, 0x65, 0x50 }; // 'I', 'c', 'e', 'P'
+const Ice::Byte magic[] = { 0x49, 0x63, 0x65, 0x50 }; // 'I', 'c', 'e', 'P'
#ifdef __BCPLUSPLUS__
const Ice::Byte requestHdr[headerSize + sizeof(Ice::Int)] =
diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp
index eb20297fb6a..2ad7d17e5da 100644
--- a/cpp/src/Ice/Proxy.cpp
+++ b/cpp/src/Ice/Proxy.cpp
@@ -56,23 +56,23 @@ IceInternal::checkedCastImpl(const ObjectPrx& b, const string& f, const string&
if(b)
{
- ObjectPrx bb = b->ice_facet(f);
- try
- {
- if(context == 0 ? bb->ice_isA(typeId) : bb->ice_isA(typeId, *context))
- {
- return bb;
- }
+ ObjectPrx bb = b->ice_facet(f);
+ try
+ {
+ if(context == 0 ? bb->ice_isA(typeId) : bb->ice_isA(typeId, *context))
+ {
+ return bb;
+ }
#ifndef NDEBUG
- else
- {
- assert(typeId != "::Ice::Object");
- }
+ else
+ {
+ assert(typeId != "::Ice::Object");
+ }
#endif
- }
- catch(const FacetNotExistException&)
- {
- }
+ }
+ catch(const FacetNotExistException&)
+ {
+ }
}
return 0;
}
@@ -132,21 +132,21 @@ IceProxy::Ice::Object::ice_isA(const string& typeId, const Context* context)
int __cnt = 0;
while(true)
{
- Handle< ::IceDelegate::Ice::Object> __del;
- try
- {
- __checkTwowayOnly("ice_isA");
- __del = __getDelegate();
- return __del->ice_isA(typeId, context);
- }
- catch(const LocalExceptionWrapper& __ex)
- {
- __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
- }
- catch(const LocalException& __ex)
- {
- __handleException(__del, __ex, __cnt);
- }
+ Handle< ::IceDelegate::Ice::Object> __del;
+ try
+ {
+ __checkTwowayOnly("ice_isA");
+ __del = __getDelegate();
+ return __del->ice_isA(typeId, context);
+ }
+ catch(const LocalExceptionWrapper& __ex)
+ {
+ __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
+ }
+ catch(const LocalException& __ex)
+ {
+ __handleException(__del, __ex, __cnt);
+ }
}
}
@@ -156,21 +156,21 @@ IceProxy::Ice::Object::ice_ping(const Context* context)
int __cnt = 0;
while(true)
{
- Handle< ::IceDelegate::Ice::Object> __del;
- try
- {
- __del = __getDelegate();
- __del->ice_ping(context);
- return;
- }
- catch(const LocalExceptionWrapper& __ex)
- {
- __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
- }
- catch(const LocalException& __ex)
- {
- __handleException(__del, __ex, __cnt);
- }
+ Handle< ::IceDelegate::Ice::Object> __del;
+ try
+ {
+ __del = __getDelegate();
+ __del->ice_ping(context);
+ return;
+ }
+ catch(const LocalExceptionWrapper& __ex)
+ {
+ __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
+ }
+ catch(const LocalException& __ex)
+ {
+ __handleException(__del, __ex, __cnt);
+ }
}
}
@@ -180,21 +180,21 @@ IceProxy::Ice::Object::ice_ids(const Context* context)
int __cnt = 0;
while(true)
{
- Handle< ::IceDelegate::Ice::Object> __del;
- try
- {
- __checkTwowayOnly("ice_ids");
- __del = __getDelegate();
- return __del->ice_ids(context);
- }
- catch(const LocalExceptionWrapper& __ex)
- {
- __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
- }
- catch(const LocalException& __ex)
- {
- __handleException(__del, __ex, __cnt);
- }
+ Handle< ::IceDelegate::Ice::Object> __del;
+ try
+ {
+ __checkTwowayOnly("ice_ids");
+ __del = __getDelegate();
+ return __del->ice_ids(context);
+ }
+ catch(const LocalExceptionWrapper& __ex)
+ {
+ __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
+ }
+ catch(const LocalException& __ex)
+ {
+ __handleException(__del, __ex, __cnt);
+ }
}
}
@@ -204,31 +204,31 @@ IceProxy::Ice::Object::ice_id(const Context* context)
int __cnt = 0;
while(true)
{
- Handle< ::IceDelegate::Ice::Object> __del;
- try
- {
- __checkTwowayOnly("ice_id");
- __del = __getDelegate();
- return __del->ice_id(context);
- }
- catch(const LocalExceptionWrapper& __ex)
- {
- __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
- }
- catch(const LocalException& __ex)
- {
- __handleException(__del, __ex, __cnt);
- }
+ Handle< ::IceDelegate::Ice::Object> __del;
+ try
+ {
+ __checkTwowayOnly("ice_id");
+ __del = __getDelegate();
+ return __del->ice_id(context);
+ }
+ catch(const LocalExceptionWrapper& __ex)
+ {
+ __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
+ }
+ catch(const LocalException& __ex)
+ {
+ __handleException(__del, __ex, __cnt);
+ }
}
}
bool
IceProxy::Ice::Object::ice_invoke(const string& operation,
- OperationMode mode,
- const vector<Byte>& inParams,
- vector<Byte>& outParams,
- const Context* context)
+ OperationMode mode,
+ const vector<Byte>& inParams,
+ vector<Byte>& outParams,
+ const Context* context)
{
pair<const Byte*, const Byte*> inPair;
if(inParams.size() == 0)
@@ -238,7 +238,7 @@ IceProxy::Ice::Object::ice_invoke(const string& operation,
else
{
inPair.first = &inParams[0];
- inPair.second = inPair.first + inParams.size();
+ inPair.second = inPair.first + inParams.size();
}
return ice_invoke(operation, mode, inPair, outParams, context);
}
@@ -246,73 +246,73 @@ IceProxy::Ice::Object::ice_invoke(const string& operation,
bool
IceProxy::Ice::Object::ice_invoke(const string& operation,
- OperationMode mode,
- const pair<const Byte*, const Byte*>& inParams,
- vector<Byte>& outParams,
- const Context* context)
+ OperationMode mode,
+ const pair<const Byte*, const Byte*>& inParams,
+ vector<Byte>& outParams,
+ const Context* context)
{
int __cnt = 0;
while(true)
{
- Handle< ::IceDelegate::Ice::Object> __del;
- try
- {
- __del = __getDelegate();
- return __del->ice_invoke(operation, mode, inParams, outParams, context);
- }
- catch(const LocalExceptionWrapper& __ex)
- {
- bool canRetry = mode == Nonmutating || mode == Idempotent;
- if(canRetry)
- {
- __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
- }
- else
- {
- __handleExceptionWrapper(__del, __ex);
- }
- }
- catch(const LocalException& __ex)
- {
- __handleException(__del, __ex, __cnt);
- }
+ Handle< ::IceDelegate::Ice::Object> __del;
+ try
+ {
+ __del = __getDelegate();
+ return __del->ice_invoke(operation, mode, inParams, outParams, context);
+ }
+ catch(const LocalExceptionWrapper& __ex)
+ {
+ bool canRetry = mode == Nonmutating || mode == Idempotent;
+ if(canRetry)
+ {
+ __handleExceptionWrapperRelaxed(__del, __ex, __cnt);
+ }
+ else
+ {
+ __handleExceptionWrapper(__del, __ex);
+ }
+ }
+ catch(const LocalException& __ex)
+ {
+ __handleException(__del, __ex, __cnt);
+ }
}
}
void
IceProxy::Ice::Object::ice_invoke_async(const AMI_Object_ice_invokePtr& cb,
- const string& operation,
- OperationMode mode,
- const vector<Byte>& inParams)
+ const string& operation,
+ OperationMode mode,
+ const vector<Byte>& inParams)
{
cb->__invoke(this, operation, mode, inParams, 0);
}
void
IceProxy::Ice::Object::ice_invoke_async(const AMI_Object_ice_invokePtr& cb,
- const string& operation,
- OperationMode mode,
- const vector<Byte>& inParams,
- const Context& context)
+ const string& operation,
+ OperationMode mode,
+ const vector<Byte>& inParams,
+ const Context& context)
{
cb->__invoke(this, operation, mode, inParams, &context);
}
void
IceProxy::Ice::Object::ice_invoke_async(const AMI_Array_Object_ice_invokePtr& cb,
- const string& operation,
- OperationMode mode,
- const pair<const Byte*, const Byte*>& inParams)
+ const string& operation,
+ OperationMode mode,
+ const pair<const Byte*, const Byte*>& inParams)
{
cb->__invoke(this, operation, mode, inParams, 0);
}
void
IceProxy::Ice::Object::ice_invoke_async(const AMI_Array_Object_ice_invokePtr& cb,
- const string& operation,
- OperationMode mode,
- const pair<const Byte*, const Byte*>& inParams,
- const Context& context)
+ const string& operation,
+ OperationMode mode,
+ const pair<const Byte*, const Byte*>& inParams,
+ const Context& context)
{
cb->__invoke(this, operation, mode, inParams, &context);
}
@@ -332,13 +332,13 @@ IceProxy::Ice::Object::ice_identity(const Identity& newIdentity) const
}
if(newIdentity == _reference->getIdentity())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeIdentity(newIdentity));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeIdentity(newIdentity));
+ return proxy;
}
}
@@ -387,13 +387,13 @@ IceProxy::Ice::Object::ice_facet(const string& newFacet) const
{
if(newFacet == _reference->getFacet())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeFacet(newFacet));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeFacet(newFacet));
+ return proxy;
}
}
@@ -414,13 +414,13 @@ IceProxy::Ice::Object::ice_adapterId(const string& newAdapterId) const
{
if(newAdapterId == _reference->getAdapterId())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeAdapterId(newAdapterId));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeAdapterId(newAdapterId));
+ return proxy;
}
}
@@ -437,7 +437,7 @@ IceProxy::Ice::Object::ice_getEndpoints() const
EndpointSeq retSeq;
for(vector<EndpointIPtr>::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
{
- retSeq.push_back(EndpointPtr::dynamicCast(*p));
+ retSeq.push_back(EndpointPtr::dynamicCast(*p));
}
return retSeq;
}
@@ -448,18 +448,18 @@ IceProxy::Ice::Object::ice_endpoints(const EndpointSeq& newEndpoints) const
vector<EndpointIPtr> endpoints;
for(EndpointSeq::const_iterator p = newEndpoints.begin(); p != newEndpoints.end(); ++p)
{
- endpoints.push_back(EndpointIPtr::dynamicCast(*p));
+ endpoints.push_back(EndpointIPtr::dynamicCast(*p));
}
if(endpoints == _reference->getEndpoints())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeEndpoints(endpoints));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeEndpoints(endpoints));
+ return proxy;
}
}
@@ -480,13 +480,13 @@ IceProxy::Ice::Object::ice_locatorCacheTimeout(Int newTimeout) const
{
if(newTimeout == _reference->getLocatorCacheTimeout())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeLocatorCacheTimeout(newTimeout));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeLocatorCacheTimeout(newTimeout));
+ return proxy;
}
}
@@ -501,13 +501,13 @@ IceProxy::Ice::Object::ice_connectionCached(bool newCache) const
{
if(newCache == _reference->getCacheConnection())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeCacheConnection(newCache));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeCacheConnection(newCache));
+ return proxy;
}
}
@@ -522,13 +522,13 @@ IceProxy::Ice::Object::ice_endpointSelection(EndpointSelectionType newType) cons
{
if(newType == _reference->getEndpointSelection())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeEndpointSelection(newType));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeEndpointSelection(newType));
+ return proxy;
}
}
@@ -543,13 +543,13 @@ IceProxy::Ice::Object::ice_secure(bool b) const
{
if(b == _reference->getSecure())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeSecure(b));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeSecure(b));
+ return proxy;
}
}
@@ -564,13 +564,13 @@ IceProxy::Ice::Object::ice_preferSecure(bool b) const
{
if(b == _reference->getPreferSecure())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changePreferSecure(b));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changePreferSecure(b));
+ return proxy;
}
}
@@ -587,13 +587,13 @@ IceProxy::Ice::Object::ice_router(const RouterPrx& router) const
ReferencePtr ref = _reference->changeRouter(router);
if(ref == _reference)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(ref);
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(ref);
+ return proxy;
}
}
@@ -610,13 +610,13 @@ IceProxy::Ice::Object::ice_locator(const LocatorPrx& locator) const
ReferencePtr ref = _reference->changeLocator(locator);
if(ref == _reference)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(ref);
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(ref);
+ return proxy;
}
}
@@ -637,13 +637,13 @@ IceProxy::Ice::Object::ice_collocationOptimized(bool b) const
{
if(b == _reference->getCollocationOptimization())
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeCollocationOptimization(b));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeCollocationOptimization(b));
+ return proxy;
}
}
@@ -652,13 +652,13 @@ IceProxy::Ice::Object::ice_twoway() const
{
if(_reference->getMode() == Reference::ModeTwoway)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeMode(Reference::ModeTwoway));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeMode(Reference::ModeTwoway));
+ return proxy;
}
}
@@ -673,13 +673,13 @@ IceProxy::Ice::Object::ice_oneway() const
{
if(_reference->getMode() == Reference::ModeOneway)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeMode(Reference::ModeOneway));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeMode(Reference::ModeOneway));
+ return proxy;
}
}
@@ -694,13 +694,13 @@ IceProxy::Ice::Object::ice_batchOneway() const
{
if(_reference->getMode() == Reference::ModeBatchOneway)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeMode(Reference::ModeBatchOneway));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeMode(Reference::ModeBatchOneway));
+ return proxy;
}
}
@@ -715,13 +715,13 @@ IceProxy::Ice::Object::ice_datagram() const
{
if(_reference->getMode() == Reference::ModeDatagram)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeMode(Reference::ModeDatagram));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeMode(Reference::ModeDatagram));
+ return proxy;
}
}
@@ -736,13 +736,13 @@ IceProxy::Ice::Object::ice_batchDatagram() const
{
if(_reference->getMode() == Reference::ModeBatchDatagram)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(_reference->changeMode(Reference::ModeBatchDatagram));
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(_reference->changeMode(Reference::ModeBatchDatagram));
+ return proxy;
}
}
@@ -758,13 +758,13 @@ IceProxy::Ice::Object::ice_compress(bool b) const
ReferencePtr ref = _reference->changeCompress(b);
if(ref == _reference)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(ref);
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(ref);
+ return proxy;
}
}
@@ -774,13 +774,13 @@ IceProxy::Ice::Object::ice_timeout(int t) const
ReferencePtr ref = _reference->changeTimeout(t);
if(ref == _reference)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(ref);
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(ref);
+ return proxy;
}
}
@@ -790,13 +790,13 @@ IceProxy::Ice::Object::ice_connectionId(const string& id) const
ReferencePtr ref = _reference->changeConnectionId(id);
if(ref == _reference)
{
- return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
+ return ObjectPrx(const_cast< ::IceProxy::Ice::Object*>(this));
}
else
{
- ObjectPrx proxy(new ::IceProxy::Ice::Object());
- proxy->setup(ref);
- return proxy;
+ ObjectPrx proxy(new ::IceProxy::Ice::Object());
+ proxy->setup(ref);
+ return proxy;
}
}
@@ -834,17 +834,17 @@ IceProxy::Ice::Object::ice_getConnection()
int __cnt = 0;
while(true)
{
- Handle< ::IceDelegate::Ice::Object> __del;
- try
- {
- __del = __getDelegate();
- bool compress;
- return __del->__getConnection(compress);
- }
- catch(const LocalException& __ex)
- {
- __handleException(__del, __ex, __cnt);
- }
+ Handle< ::IceDelegate::Ice::Object> __del;
+ try
+ {
+ __del = __getDelegate();
+ bool compress;
+ return __del->__getConnection(compress);
+ }
+ catch(const LocalException& __ex)
+ {
+ __handleException(__del, __ex, __cnt);
+ }
}
}
@@ -853,20 +853,20 @@ IceProxy::Ice::Object::ice_getCachedConnection() const
{
Handle< ::IceDelegate::Ice::Object> __del;
{
- IceUtil::Mutex::Lock sync(*this);
- __del = _delegate;
+ IceUtil::Mutex::Lock sync(*this);
+ __del = _delegate;
}
if(__del)
{
- try
- {
- bool compress;
- return __del->__getConnection(compress);
- }
- catch(const CollocationOptimizationException&)
- {
- }
+ try
+ {
+ bool compress;
+ return __del->__getConnection(compress);
+ }
+ catch(const CollocationOptimizationException&)
+ {
+ }
}
return 0;
}
@@ -885,11 +885,11 @@ IceProxy::Ice::Object::__copyFrom(const ObjectPrx& from)
Handle< ::IceDelegateM::Ice::Object> delegateM;
{
- IceUtil::Mutex::Lock sync(*from.get());
+ IceUtil::Mutex::Lock sync(*from.get());
- ref = from->_reference;
- delegateD = dynamic_cast< ::IceDelegateD::Ice::Object*>(from->_delegate.get());
- delegateM = dynamic_cast< ::IceDelegateM::Ice::Object*>(from->_delegate.get());
+ ref = from->_reference;
+ delegateD = dynamic_cast< ::IceDelegateD::Ice::Object*>(from->_delegate.get());
+ delegateM = dynamic_cast< ::IceDelegateM::Ice::Object*>(from->_delegate.get());
}
//
@@ -904,31 +904,31 @@ IceProxy::Ice::Object::__copyFrom(const ObjectPrx& from)
if(_reference->getCacheConnection())
{
- //
- // The _delegate attribute is only used if "cache connection"
- // is enabled. If it's not enabled, we don't keep track of the
- // delegate -- a new delegate is created for each invocations.
- //
+ //
+ // The _delegate attribute is only used if "cache connection"
+ // is enabled. If it's not enabled, we don't keep track of the
+ // delegate -- a new delegate is created for each invocations.
+ //
- if(delegateD)
- {
- Handle< ::IceDelegateD::Ice::Object> delegate = __createDelegateD();
- delegate->__copyFrom(delegateD);
- _delegate = delegate;
- }
- else if(delegateM)
- {
- Handle< ::IceDelegateM::Ice::Object> delegate = __createDelegateM();
- delegate->__copyFrom(delegateM);
- _delegate = delegate;
- }
+ if(delegateD)
+ {
+ Handle< ::IceDelegateD::Ice::Object> delegate = __createDelegateD();
+ delegate->__copyFrom(delegateD);
+ _delegate = delegate;
+ }
+ else if(delegateM)
+ {
+ Handle< ::IceDelegateM::Ice::Object> delegate = __createDelegateM();
+ delegate->__copyFrom(delegateM);
+ _delegate = delegate;
+ }
}
}
void
IceProxy::Ice::Object::__handleException(const ::IceInternal::Handle< ::IceDelegate::Ice::Object>& delegate,
- const LocalException& ex,
- int& cnt)
+ const LocalException& ex,
+ int& cnt)
{
//
// Only _delegate needs to be mutex protected here.
@@ -936,7 +936,7 @@ IceProxy::Ice::Object::__handleException(const ::IceInternal::Handle< ::IceDeleg
IceUtil::Mutex::Lock sync(*this);
if(delegate.get() == _delegate.get())
{
- _delegate = 0;
+ _delegate = 0;
}
ProxyFactoryPtr proxyFactory;
@@ -946,9 +946,9 @@ IceProxy::Ice::Object::__handleException(const ::IceInternal::Handle< ::IceDeleg
}
catch(const CommunicatorDestroyedException&)
{
- //
- // The communicator is already destroyed, so we cannot retry.
- //
+ //
+ // The communicator is already destroyed, so we cannot retry.
+ //
ex.ice_throw();
}
@@ -958,37 +958,37 @@ IceProxy::Ice::Object::__handleException(const ::IceInternal::Handle< ::IceDeleg
void
IceProxy::Ice::Object::__handleExceptionWrapper(const ::IceInternal::Handle< ::IceDelegate::Ice::Object>& delegate,
- const LocalExceptionWrapper& ex)
+ const LocalExceptionWrapper& ex)
{
{
- IceUtil::Mutex::Lock sync(*this);
- if(delegate.get() == _delegate.get())
- {
- _delegate = 0;
- }
+ IceUtil::Mutex::Lock sync(*this);
+ if(delegate.get() == _delegate.get())
+ {
+ _delegate = 0;
+ }
}
if(!ex.retry())
{
- ex.get()->ice_throw();
+ ex.get()->ice_throw();
}
}
void
IceProxy::Ice::Object::__handleExceptionWrapperRelaxed(const ::IceInternal::Handle< ::IceDelegate::Ice::Object>& del,
- const LocalExceptionWrapper& ex, int& cnt)
+ const LocalExceptionWrapper& ex, int& cnt)
{
if(!ex.retry())
{
- __handleException(del, *ex.get(), cnt);
+ __handleException(del, *ex.get(), cnt);
}
else
{
- IceUtil::Mutex::Lock sync(*this);
- if(del.get() == _delegate.get())
- {
- _delegate = 0;
- }
+ IceUtil::Mutex::Lock sync(*this);
+ if(del.get() == _delegate.get())
+ {
+ _delegate = 0;
+ }
}
}
@@ -1009,8 +1009,8 @@ IceProxy::Ice::Object::__checkTwowayOnly(const char* name) const
if(!ice_isTwoway())
{
TwowayOnlyException ex(__FILE__, __LINE__);
- ex.operation = name;
- throw ex;
+ ex.operation = name;
+ throw ex;
}
}
@@ -1025,8 +1025,8 @@ IceProxy::Ice::Object::__checkTwowayOnly(const string& name) const
if(!ice_isTwoway())
{
TwowayOnlyException ex(__FILE__, __LINE__);
- ex.operation = name;
- throw ex;
+ ex.operation = name;
+ throw ex;
}
}
@@ -1043,47 +1043,47 @@ IceProxy::Ice::Object::__getDelegate()
if(_delegate)
{
- return _delegate;
+ return _delegate;
}
Handle< ::IceDelegate::Ice::Object> delegate;
if(_reference->getCollocationOptimization())
{
- ObjectAdapterPtr adapter = _reference->getInstance()->objectAdapterFactory()->findObjectAdapter(this);
- if(adapter)
- {
- Handle< ::IceDelegateD::Ice::Object> d = __createDelegateD();
- d->setup(_reference, adapter);
- delegate = d;
- }
+ ObjectAdapterPtr adapter = _reference->getInstance()->objectAdapterFactory()->findObjectAdapter(this);
+ if(adapter)
+ {
+ Handle< ::IceDelegateD::Ice::Object> d = __createDelegateD();
+ d->setup(_reference, adapter);
+ delegate = d;
+ }
}
if(!delegate)
{
- Handle< ::IceDelegateM::Ice::Object> d = __createDelegateM();
- d->setup(_reference);
- delegate = d;
-
- //
- // If this proxy is for a non-local object, and we are
- // using a router, then add this proxy to the router info
- // object.
- //
- RouterInfoPtr ri = _reference->getRouterInfo();
- if(ri)
- {
- ri->addProxy(this);
- }
+ Handle< ::IceDelegateM::Ice::Object> d = __createDelegateM();
+ d->setup(_reference);
+ delegate = d;
+
+ //
+ // If this proxy is for a non-local object, and we are
+ // using a router, then add this proxy to the router info
+ // object.
+ //
+ RouterInfoPtr ri = _reference->getRouterInfo();
+ if(ri)
+ {
+ ri->addProxy(this);
+ }
}
if(_reference->getCacheConnection())
{
- //
- // The _delegate attribute is only used if "cache connection"
- // is enabled. If it's not enabled, we don't keep track of the
- // delegate -- a new delegate is created for each invocations.
- //
- _delegate = delegate;
+ //
+ // The _delegate attribute is only used if "cache connection"
+ // is enabled. If it's not enabled, we don't keep track of the
+ // delegate -- a new delegate is created for each invocations.
+ //
+ _delegate = delegate;
}
return delegate;
@@ -1126,34 +1126,34 @@ IceDelegateM::Ice::Object::ice_isA(const string& __id, const Context* context)
Outgoing __og(__connection.get(), __reference.get(), __operation, ::Ice::Nonmutating, context, __compress);
try
{
- BasicStream* __os = __og.os();
- __os->write(__id, false);
+ BasicStream* __os = __og.os();
+ __os->write(__id, false);
}
catch(const ::Ice::LocalException& __ex)
{
- __og.abort(__ex);
+ __og.abort(__ex);
}
bool __ret;
bool __ok = __og.invoke();
try
{
- BasicStream* __is = __og.is();
- if(!__ok)
- {
- try
- {
- __is->throwException();
- }
- catch(const ::Ice::UserException& __ex)
- {
- throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
- }
- }
+ BasicStream* __is = __og.is();
+ if(!__ok)
+ {
+ try
+ {
+ __is->throwException();
+ }
+ catch(const ::Ice::UserException& __ex)
+ {
+ throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
+ }
+ }
__is->read(__ret);
}
catch(const ::Ice::LocalException& __ex)
{
- throw ::IceInternal::LocalExceptionWrapper(__ex, false);
+ throw ::IceInternal::LocalExceptionWrapper(__ex, false);
}
return __ret;
}
@@ -1166,22 +1166,22 @@ IceDelegateM::Ice::Object::ice_ping(const Context* context)
bool __ok = __og.invoke();
try
{
- BasicStream* __is = __og.is();
- if(!__ok)
- {
- try
- {
- __is->throwException();
- }
- catch(const ::Ice::UserException& __ex)
- {
- throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
- }
- }
+ BasicStream* __is = __og.is();
+ if(!__ok)
+ {
+ try
+ {
+ __is->throwException();
+ }
+ catch(const ::Ice::UserException& __ex)
+ {
+ throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
+ }
+ }
}
catch(const ::Ice::LocalException& __ex)
{
- throw ::IceInternal::LocalExceptionWrapper(__ex, false);
+ throw ::IceInternal::LocalExceptionWrapper(__ex, false);
}
}
@@ -1194,23 +1194,23 @@ IceDelegateM::Ice::Object::ice_ids(const Context* context)
bool __ok = __og.invoke();
try
{
- BasicStream* __is = __og.is();
- if(!__ok)
- {
- try
- {
- __is->throwException();
- }
- catch(const ::Ice::UserException& __ex)
- {
- throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
- }
- }
- __is->read(__ret, false);
+ BasicStream* __is = __og.is();
+ if(!__ok)
+ {
+ try
+ {
+ __is->throwException();
+ }
+ catch(const ::Ice::UserException& __ex)
+ {
+ throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
+ }
+ }
+ __is->read(__ret, false);
}
catch(const ::Ice::LocalException& __ex)
{
- throw ::IceInternal::LocalExceptionWrapper(__ex, false);
+ throw ::IceInternal::LocalExceptionWrapper(__ex, false);
}
return __ret;
}
@@ -1224,23 +1224,23 @@ IceDelegateM::Ice::Object::ice_id(const Context* context)
bool __ok = __og.invoke();
try
{
- BasicStream* __is = __og.is();
- if(!__ok)
- {
- try
- {
- __is->throwException();
- }
- catch(const ::Ice::UserException& __ex)
- {
- throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
- }
- }
- __is->read(__ret, false);
+ BasicStream* __is = __og.is();
+ if(!__ok)
+ {
+ try
+ {
+ __is->throwException();
+ }
+ catch(const ::Ice::UserException& __ex)
+ {
+ throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());
+ }
+ }
+ __is->read(__ret, false);
}
catch(const ::Ice::LocalException& __ex)
{
- throw ::IceInternal::LocalExceptionWrapper(__ex, false);
+ throw ::IceInternal::LocalExceptionWrapper(__ex, false);
}
return __ret;
}
@@ -1248,19 +1248,19 @@ IceDelegateM::Ice::Object::ice_id(const Context* context)
bool
IceDelegateM::Ice::Object::ice_invoke(const string& operation,
OperationMode mode,
- const pair<const Byte*, const Byte*>& inParams,
- vector<Byte>& outParams,
- const Context* context)
+ const pair<const Byte*, const Byte*>& inParams,
+ vector<Byte>& outParams,
+ const Context* context)
{
Outgoing __og(__connection.get(), __reference.get(), operation, mode, context, __compress);
try
{
- BasicStream* __os = __og.os();
- __os->writeBlob(inParams.first, static_cast<Int>(inParams.second - inParams.first));
+ BasicStream* __os = __og.os();
+ __os->writeBlob(inParams.first, static_cast<Int>(inParams.second - inParams.first));
}
catch(const ::Ice::LocalException& __ex)
{
- __og.abort(__ex);
+ __og.abort(__ex);
}
bool ok = __og.invoke();
if(__reference->getMode() == Reference::ModeTwoway)
@@ -1329,19 +1329,19 @@ IceDelegateD::Ice::Object::ice_isA(const string& __id, const Context* context)
__initCurrent(__current, "ice_isA", ::Ice::Nonmutating, context);
while(true)
{
- Direct __direct(__current);
- bool __ret;
- try
- {
- __ret = __direct.servant()->ice_isA(__id, __current);
- }
- catch(...)
- {
- __direct.destroy();
- throw;
- }
- __direct.destroy();
- return __ret;
+ Direct __direct(__current);
+ bool __ret;
+ try
+ {
+ __ret = __direct.servant()->ice_isA(__id, __current);
+ }
+ catch(...)
+ {
+ __direct.destroy();
+ throw;
+ }
+ __direct.destroy();
+ return __ret;
}
return false; // To keep the Visual C++ compiler happy.
}
@@ -1353,18 +1353,18 @@ IceDelegateD::Ice::Object::ice_ping(const ::Ice::Context* context)
__initCurrent(__current, "ice_ping", ::Ice::Nonmutating, context);
while(true)
{
- Direct __direct(__current);
- try
- {
- __direct.servant()->ice_ping(__current);
- }
- catch(...)
- {
- __direct.destroy();
- throw;
- }
- __direct.destroy();
- return;
+ Direct __direct(__current);
+ try
+ {
+ __direct.servant()->ice_ping(__current);
+ }
+ catch(...)
+ {
+ __direct.destroy();
+ throw;
+ }
+ __direct.destroy();
+ return;
}
}
@@ -1375,19 +1375,19 @@ IceDelegateD::Ice::Object::ice_ids(const ::Ice::Context* context)
__initCurrent(__current, "ice_ids", ::Ice::Nonmutating, context);
while(true)
{
- Direct __direct(__current);
- vector<string> __ret;
- try
- {
- __ret = __direct.servant()->ice_ids(__current);
- }
- catch(...)
- {
- __direct.destroy();
- throw;
- }
- __direct.destroy();
- return __ret;
+ Direct __direct(__current);
+ vector<string> __ret;
+ try
+ {
+ __ret = __direct.servant()->ice_ids(__current);
+ }
+ catch(...)
+ {
+ __direct.destroy();
+ throw;
+ }
+ __direct.destroy();
+ return __ret;
}
return vector<string>(); // To keep the Visual C++ compiler happy.
}
@@ -1399,29 +1399,29 @@ IceDelegateD::Ice::Object::ice_id(const ::Ice::Context* context)
__initCurrent(__current, "ice_id", ::Ice::Nonmutating, context);
while(true)
{
- Direct __direct(__current);
- string __ret;
- try
- {
- __ret = __direct.servant()->ice_id(__current);
- }
- catch(...)
- {
- __direct.destroy();
- throw;
- }
- __direct.destroy();
- return __ret;
+ Direct __direct(__current);
+ string __ret;
+ try
+ {
+ __ret = __direct.servant()->ice_id(__current);
+ }
+ catch(...)
+ {
+ __direct.destroy();
+ throw;
+ }
+ __direct.destroy();
+ return __ret;
}
return string(); // To keep the Visual C++ compiler happy.
}
bool
IceDelegateD::Ice::Object::ice_invoke(const string&,
- OperationMode,
- const pair<const Byte*, const Byte*>& inParams,
- vector<Byte>&,
- const Context*)
+ OperationMode,
+ const pair<const Byte*, const Byte*>& inParams,
+ vector<Byte>&,
+ const Context*)
{
throw CollocationOptimizationException(__FILE__, __LINE__);
return false;
@@ -1456,7 +1456,7 @@ IceDelegateD::Ice::Object::__copyFrom(const ::IceInternal::Handle< ::IceDelegate
void
IceDelegateD::Ice::Object::__initCurrent(Current& current, const string& op, OperationMode mode,
- const Context* context)
+ const Context* context)
{
current.adapter = __adapter;
current.id = __reference->getIdentity();
@@ -1465,29 +1465,29 @@ IceDelegateD::Ice::Object::__initCurrent(Current& current, const string& op, Ope
current.mode = mode;
if(context != 0)
{
- //
- // Explicit context
- //
- current.ctx = *context;
+ //
+ // Explicit context
+ //
+ current.ctx = *context;
}
else
{
- //
- // Implicit context
- //
- const ImplicitContextIPtr& implicitContext =
- __reference->getInstance()->getImplicitContext();
+ //
+ // Implicit context
+ //
+ const ImplicitContextIPtr& implicitContext =
+ __reference->getInstance()->getImplicitContext();
- const Context& prxContext = __reference->getContext()->getValue();
+ const Context& prxContext = __reference->getContext()->getValue();
- if(implicitContext == 0)
- {
- current.ctx = prxContext;
- }
- else
- {
- implicitContext->combine(prxContext, current.ctx);
- }
+ if(implicitContext == 0)
+ {
+ current.ctx = prxContext;
+ }
+ else
+ {
+ implicitContext->combine(prxContext, current.ctx);
+ }
}
current.requestId = -1;
}
@@ -1512,19 +1512,19 @@ Ice::proxyIdentityLess(const ObjectPrx& lhs, const ObjectPrx& rhs)
{
if(!lhs && !rhs)
{
- return false;
+ return false;
}
else if(!lhs && rhs)
{
- return true;
+ return true;
}
else if(lhs && !rhs)
{
- return false;
+ return false;
}
else
{
- return lhs->ice_getIdentity() < rhs->ice_getIdentity();
+ return lhs->ice_getIdentity() < rhs->ice_getIdentity();
}
}
@@ -1533,19 +1533,19 @@ Ice::proxyIdentityEqual(const ObjectPrx& lhs, const ObjectPrx& rhs)
{
if(!lhs && !rhs)
{
- return true;
+ return true;
}
else if(!lhs && rhs)
{
- return false;
+ return false;
}
else if(lhs && !rhs)
{
- return false;
+ return false;
}
else
{
- return lhs->ice_getIdentity() == rhs->ice_getIdentity();
+ return lhs->ice_getIdentity() == rhs->ice_getIdentity();
}
}
@@ -1554,43 +1554,43 @@ Ice::proxyIdentityAndFacetLess(const ObjectPrx& lhs, const ObjectPrx& rhs)
{
if(!lhs && !rhs)
{
- return false;
+ return false;
}
else if(!lhs && rhs)
{
- return true;
+ return true;
}
else if(lhs && !rhs)
{
- return false;
+ return false;
}
else
{
- Identity lhsIdentity = lhs->ice_getIdentity();
- Identity rhsIdentity = rhs->ice_getIdentity();
-
- if(lhsIdentity < rhsIdentity)
- {
- return true;
- }
- else if(rhsIdentity < lhsIdentity)
- {
- return false;
- }
-
- string lhsFacet = lhs->ice_getFacet();
- string rhsFacet = rhs->ice_getFacet();
-
- if(lhsFacet < rhsFacet)
- {
- return true;
- }
- else if(rhsFacet < lhsFacet)
- {
- return false;
- }
-
- return false;
+ Identity lhsIdentity = lhs->ice_getIdentity();
+ Identity rhsIdentity = rhs->ice_getIdentity();
+
+ if(lhsIdentity < rhsIdentity)
+ {
+ return true;
+ }
+ else if(rhsIdentity < lhsIdentity)
+ {
+ return false;
+ }
+
+ string lhsFacet = lhs->ice_getFacet();
+ string rhsFacet = rhs->ice_getFacet();
+
+ if(lhsFacet < rhsFacet)
+ {
+ return true;
+ }
+ else if(rhsFacet < lhsFacet)
+ {
+ return false;
+ }
+
+ return false;
}
}
@@ -1599,33 +1599,33 @@ Ice::proxyIdentityAndFacetEqual(const ObjectPrx& lhs, const ObjectPrx& rhs)
{
if(!lhs && !rhs)
{
- return true;
+ return true;
}
else if(!lhs && rhs)
{
- return false;
+ return false;
}
else if(lhs && !rhs)
{
- return false;
+ return false;
}
else
{
- Identity lhsIdentity = lhs->ice_getIdentity();
- Identity rhsIdentity = rhs->ice_getIdentity();
-
- if(lhsIdentity == rhsIdentity)
- {
- string lhsFacet = lhs->ice_getFacet();
- string rhsFacet = rhs->ice_getFacet();
-
- if(lhsFacet == rhsFacet)
- {
- return true;
- }
- }
-
- return false;
+ Identity lhsIdentity = lhs->ice_getIdentity();
+ Identity rhsIdentity = rhs->ice_getIdentity();
+
+ if(lhsIdentity == rhsIdentity)
+ {
+ string lhsFacet = lhs->ice_getFacet();
+ string rhsFacet = rhs->ice_getFacet();
+
+ if(lhsFacet == rhsFacet)
+ {
+ return true;
+ }
+ }
+
+ return false;
}
}
diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp
index 3de3450d22f..338cd0a62fb 100644
--- a/cpp/src/Ice/ProxyFactory.cpp
+++ b/cpp/src/Ice/ProxyFactory.cpp
@@ -39,11 +39,11 @@ IceInternal::ProxyFactory::proxyToString(const ObjectPrx& proxy) const
{
if(proxy)
{
- return proxy->__reference()->toString();
+ return proxy->__reference()->toString();
}
else
{
- return "";
+ return "";
}
}
@@ -69,13 +69,13 @@ IceInternal::ProxyFactory::proxyToStream(const ObjectPrx& proxy, BasicStream* s)
{
if(proxy)
{
- proxy->__reference()->getIdentity().__write(s);
- proxy->__reference()->streamWrite(s);
+ proxy->__reference()->getIdentity().__write(s);
+ proxy->__reference()->streamWrite(s);
}
else
{
- Identity ident;
- ident.__write(s);
+ Identity ident;
+ ident.__write(s);
}
}
@@ -104,48 +104,48 @@ IceInternal::ProxyFactory::checkRetryAfterException(const LocalException& ex, co
if(one)
{
- LocatorInfoPtr li = ref->getLocatorInfo();
- if(li)
- {
- //
- // We retry ObjectNotExistException if the reference is
- // indirect.
- //
- li->clearObjectCache(IndirectReferencePtr::dynamicCast(ref));
- }
- else if(ref->getRouterInfo() && one->operation == "ice_add_proxy")
- {
- //
- // If we have a router, an ObjectNotExistException with an
- // operation name "ice_add_proxy" indicates to the client
- // that the router isn't aware of the proxy (for example,
- // because it was evicted by the router). In this case, we
- // must *always* retry, so that the missing proxy is added
- // to the router.
- //
- if(traceLevels->retry >= 1)
- {
- Trace out(logger, traceLevels->retryCat);
- out << "retrying operation call to add proxy to router\n" << ex;
- }
- return; // We must always retry, so we don't look at the retry count.
- }
- else
- {
- //
- // For all other cases, we don't retry
- // ObjectNotExistException.
- //
- ex.ice_throw();
- }
+ LocatorInfoPtr li = ref->getLocatorInfo();
+ if(li)
+ {
+ //
+ // We retry ObjectNotExistException if the reference is
+ // indirect.
+ //
+ li->clearObjectCache(IndirectReferencePtr::dynamicCast(ref));
+ }
+ else if(ref->getRouterInfo() && one->operation == "ice_add_proxy")
+ {
+ //
+ // If we have a router, an ObjectNotExistException with an
+ // operation name "ice_add_proxy" indicates to the client
+ // that the router isn't aware of the proxy (for example,
+ // because it was evicted by the router). In this case, we
+ // must *always* retry, so that the missing proxy is added
+ // to the router.
+ //
+ if(traceLevels->retry >= 1)
+ {
+ Trace out(logger, traceLevels->retryCat);
+ out << "retrying operation call to add proxy to router\n" << ex;
+ }
+ return; // We must always retry, so we don't look at the retry count.
+ }
+ else
+ {
+ //
+ // For all other cases, we don't retry
+ // ObjectNotExistException.
+ //
+ ex.ice_throw();
+ }
}
else if(dynamic_cast<const RequestFailedException*>(&ex))
{
- //
+ //
// We don't retry other *NotExistException, which are all
// derived from RequestFailedException.
- //
- ex.ice_throw();
+ //
+ ex.ice_throw();
}
//
@@ -172,7 +172,7 @@ IceInternal::ProxyFactory::checkRetryAfterException(const LocalException& ex, co
//
if(dynamic_cast<const MarshalException*>(&ex))
{
- ex.ice_throw();
+ ex.ice_throw();
}
++cnt;
@@ -180,33 +180,33 @@ IceInternal::ProxyFactory::checkRetryAfterException(const LocalException& ex, co
if(cnt > static_cast<int>(_retryIntervals.size()))
{
- if(traceLevels->retry >= 1)
- {
- Trace out(logger, traceLevels->retryCat);
- out << "cannot retry operation call because retry limit has been exceeded\n" << ex;
- }
- ex.ice_throw();
+ if(traceLevels->retry >= 1)
+ {
+ Trace out(logger, traceLevels->retryCat);
+ out << "cannot retry operation call because retry limit has been exceeded\n" << ex;
+ }
+ ex.ice_throw();
}
int interval = _retryIntervals[cnt - 1];
if(traceLevels->retry >= 1)
{
- Trace out(logger, traceLevels->retryCat);
- out << "retrying operation call";
- if(interval > 0)
- {
- out << " in " << interval << "ms";
- }
- out << " because of exception\n" << ex;
+ Trace out(logger, traceLevels->retryCat);
+ out << "retrying operation call";
+ if(interval > 0)
+ {
+ out << " in " << interval << "ms";
+ }
+ out << " because of exception\n" << ex;
}
if(interval > 0)
{
- //
- // Sleep before retrying.
- //
- IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(interval));
+ //
+ // Sleep before retrying.
+ //
+ IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(interval));
}
}
@@ -220,46 +220,46 @@ IceInternal::ProxyFactory::ProxyFactory(const InstancePtr& instance) :
while(true)
{
- const string delim = " \t";
+ const string delim = " \t";
- beg = str.find_first_not_of(delim, end);
- if(beg == string::npos)
- {
- if(_retryIntervals.empty())
- {
- _retryIntervals.push_back(0);
- }
- break;
- }
+ beg = str.find_first_not_of(delim, end);
+ if(beg == string::npos)
+ {
+ if(_retryIntervals.empty())
+ {
+ _retryIntervals.push_back(0);
+ }
+ break;
+ }
- end = str.find_first_of(delim, beg);
- if(end == string::npos)
- {
- end = str.length();
- }
-
- if(beg == end)
- {
- break;
- }
+ end = str.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ end = str.length();
+ }
+
+ if(beg == end)
+ {
+ break;
+ }
- istringstream value(str.substr(beg, end - beg));
+ istringstream value(str.substr(beg, end - beg));
- int v;
- if(!(value >> v) || !value.eof())
- {
- v = 0;
- }
+ int v;
+ if(!(value >> v) || !value.eof())
+ {
+ v = 0;
+ }
- //
- // If -1 is the first value, no retry and wait intervals.
- //
- if(v == -1 && _retryIntervals.empty())
- {
- break;
- }
+ //
+ // If -1 is the first value, no retry and wait intervals.
+ //
+ if(v == -1 && _retryIntervals.empty())
+ {
+ break;
+ }
- _retryIntervals.push_back(v > 0 ? v : 0);
+ _retryIntervals.push_back(v > 0 ? v : 0);
}
}
diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp
index 99308ff37af..2dfe49d0e55 100644
--- a/cpp/src/Ice/Reference.cpp
+++ b/cpp/src/Ice/Reference.cpp
@@ -41,7 +41,7 @@ struct RandomNumberGenerator : public std::unary_function<ptrdiff_t, ptrdiff_t>
{
ptrdiff_t operator()(ptrdiff_t d)
{
- return IceUtil::random(static_cast<int>(d));
+ return IceUtil::random(static_cast<int>(d));
}
};
@@ -74,7 +74,7 @@ IceInternal::Reference::changeMode(Mode newMode) const
{
if(newMode == _mode)
{
- return ReferencePtr(const_cast<Reference*>(this));
+ return ReferencePtr(const_cast<Reference*>(this));
}
ReferencePtr r = _instance->referenceFactory()->copy(this);
r->_mode = newMode;
@@ -86,7 +86,7 @@ IceInternal::Reference::changeIdentity(const Identity& newIdentity) const
{
if(newIdentity == _identity)
{
- return ReferencePtr(const_cast<Reference*>(this));
+ return ReferencePtr(const_cast<Reference*>(this));
}
ReferencePtr r = _instance->referenceFactory()->copy(this);
r->_identity = newIdentity;
@@ -98,7 +98,7 @@ IceInternal::Reference::changeFacet(const string& newFacet) const
{
if(newFacet == _facet)
{
- return ReferencePtr(const_cast<Reference*>(this));
+ return ReferencePtr(const_cast<Reference*>(this));
}
ReferencePtr r = _instance->referenceFactory()->copy(this);
r->_facet = newFacet;
@@ -132,19 +132,19 @@ Reference::hash() const
for(q = _context->getValue().begin(); q != _context->getValue().end(); ++q)
{
- for(p = q->first.begin(); p != q->first.end(); ++p)
- {
- h = 5 * h + *p;
- }
- for(p = q->second.begin(); p != q->second.end(); ++p)
- {
- h = 5 * h + *p;
- }
+ for(p = q->first.begin(); p != q->first.end(); ++p)
+ {
+ h = 5 * h + *p;
+ }
+ for(p = q->second.begin(); p != q->second.end(); ++p)
+ {
+ h = 5 * h + *p;
+ }
}
for(p = _facet.begin(); p != _facet.end(); ++p)
{
- h = 5 * h + *p;
+ h = 5 * h + *p;
}
h = 5 * h + static_cast<Int>(getSecure());
@@ -168,11 +168,11 @@ IceInternal::Reference::streamWrite(BasicStream* s) const
//
if(_facet.empty())
{
- s->write(static_cast<string*>(0), static_cast<string*>(0));
+ s->write(static_cast<string*>(0), static_cast<string*>(0));
}
else
{
- s->write(&_facet, &_facet + 1);
+ s->write(&_facet, &_facet + 1);
}
s->write(static_cast<Byte>(_mode));
@@ -213,66 +213,66 @@ IceInternal::Reference::toString() const
{
s << " -f ";
- //
- // If the encoded facet string contains characters which
- // the reference parser uses as separators, then we enclose
- // the facet string in quotes.
- //
- string fs = _facet;
+ //
+ // If the encoded facet string contains characters which
+ // the reference parser uses as separators, then we enclose
+ // the facet string in quotes.
+ //
+ string fs = _facet;
if(_instance->initializationData().stringConverter)
{
UTF8BufferI buffer;
Byte* last =
- _instance->initializationData().stringConverter->toUTF8(fs.data(), fs.data() + fs.size(), buffer);
- fs = string(reinterpret_cast<const char*>(buffer.getBuffer()), last - buffer.getBuffer());
+ _instance->initializationData().stringConverter->toUTF8(fs.data(), fs.data() + fs.size(), buffer);
+ fs = string(reinterpret_cast<const char*>(buffer.getBuffer()), last - buffer.getBuffer());
+ }
+ fs = IceUtil::escapeString(fs, "");
+ if(fs.find_first_of(" :@") != string::npos)
+ {
+ s << '"' << fs << '"';
+ }
+ else
+ {
+ s << fs;
}
- fs = IceUtil::escapeString(fs, "");
- if(fs.find_first_of(" :@") != string::npos)
- {
- s << '"' << fs << '"';
- }
- else
- {
- s << fs;
- }
}
switch(_mode)
{
- case ModeTwoway:
- {
- s << " -t";
- break;
- }
-
- case ModeOneway:
- {
- s << " -o";
- break;
- }
-
- case ModeBatchOneway:
- {
- s << " -O";
- break;
- }
-
- case ModeDatagram:
- {
- s << " -d";
- break;
- }
-
- case ModeBatchDatagram:
- {
- s << " -D";
- break;
- }
+ case ModeTwoway:
+ {
+ s << " -t";
+ break;
+ }
+
+ case ModeOneway:
+ {
+ s << " -o";
+ break;
+ }
+
+ case ModeBatchOneway:
+ {
+ s << " -O";
+ break;
+ }
+
+ case ModeDatagram:
+ {
+ s << " -d";
+ break;
+ }
+
+ case ModeBatchDatagram:
+ {
+ s << " -D";
+ break;
+ }
}
if(getSecure())
{
- s << " -s";
+ s << " -s";
}
return s.str();
@@ -289,27 +289,27 @@ IceInternal::Reference::operator==(const Reference& r) const
if(getType() != r.getType())
{
- return false;
+ return false;
}
if(_mode != r._mode)
{
- return false;
+ return false;
}
if(_identity != r._identity)
{
- return false;
+ return false;
}
if(_context->getValue() != r._context->getValue())
{
- return false;
+ return false;
}
if(_facet != r._facet)
{
- return false;
+ return false;
}
return true;
@@ -330,47 +330,47 @@ IceInternal::Reference::operator<(const Reference& r) const
if(_mode < r._mode)
{
- return true;
+ return true;
}
else if(r._mode < _mode)
{
- return false;
+ return false;
}
if(_identity < r._identity)
{
- return true;
+ return true;
}
else if(r._identity < _identity)
{
- return false;
+ return false;
}
if(_context->getValue() < r._context->getValue())
{
- return true;
+ return true;
}
else if(r._context->getValue() < _context->getValue())
{
- return false;
+ return false;
}
if(_facet < r._facet)
{
- return true;
+ return true;
}
else if(r._facet < _facet)
{
- return false;
+ return false;
}
if(getType() < r.getType())
{
- return true;
+ return true;
}
else if(r.getType() < getType())
{
- return false;
+ return false;
}
return false;
@@ -383,7 +383,7 @@ public:
bool
operator()(ConnectionIPtr p) const
{
- return p->endpoint()->datagram();
+ return p->endpoint()->datagram();
}
};
@@ -394,12 +394,12 @@ public:
bool
operator()(ConnectionIPtr p) const
{
- return p->endpoint()->secure();
+ return p->endpoint()->secure();
}
};
IceInternal::Reference::Reference(const InstancePtr& inst, const CommunicatorPtr& com, const Identity& ident,
- const SharedContextPtr& ctx, const string& fs, Mode md) :
+ const SharedContextPtr& ctx, const string& fs, Mode md) :
_hashInitialized(false),
_instance(inst),
_communicator(com),
@@ -425,8 +425,8 @@ void IceInternal::incRef(IceInternal::FixedReference* p) { p->__incRef(); }
void IceInternal::decRef(IceInternal::FixedReference* p) { p->__decRef(); }
IceInternal::FixedReference::FixedReference(const InstancePtr& inst, const CommunicatorPtr& com, const Identity& ident,
- const SharedContextPtr& ctx, const string& fs, Mode md,
- const vector<ConnectionIPtr>& fixedConns) :
+ const SharedContextPtr& ctx, const string& fs, Mode md,
+ const vector<ConnectionIPtr>& fixedConns) :
Reference(inst, com, ident, ctx, fs, md),
_fixedConnections(fixedConns)
{
@@ -620,9 +620,9 @@ IceInternal::FixedReference::getConnection(bool& compress) const
vector<ConnectionIPtr> filteredConns = filterConnections(_fixedConnections);
if(filteredConns.empty())
{
- NoEndpointException ex(__FILE__, __LINE__);
- ex.proxy = ""; // No stringified representation for fixed proxies
- throw ex;
+ NoEndpointException ex(__FILE__, __LINE__);
+ ex.proxy = ""; // No stringified representation for fixed proxies
+ throw ex;
}
ConnectionIPtr connection = filteredConns[0];
@@ -669,7 +669,7 @@ IceInternal::FixedReference::operator<(const Reference& r) const
{
const FixedReference* rhs = dynamic_cast<const FixedReference*>(&r);
assert(rhs);
- return _fixedConnections < rhs->_fixedConnections;
+ return _fixedConnections < rhs->_fixedConnections;
}
return false;
}
@@ -693,28 +693,28 @@ IceInternal::FixedReference::filterConnections(const vector<ConnectionIPtr>& all
switch(getMode())
{
- case Reference::ModeTwoway:
- case Reference::ModeOneway:
- case Reference::ModeBatchOneway:
- {
- //
- // Filter out datagram connections.
- //
+ case Reference::ModeTwoway:
+ case Reference::ModeOneway:
+ case Reference::ModeBatchOneway:
+ {
+ //
+ // Filter out datagram connections.
+ //
connections.erase(remove_if(connections.begin(), connections.end(), ConnectionIsDatagram()),
- connections.end());
- break;
- }
-
- case Reference::ModeDatagram:
- case Reference::ModeBatchDatagram:
- {
- //
- // Filter out non-datagram connections.
- //
+ connections.end());
+ break;
+ }
+
+ case Reference::ModeDatagram:
+ case Reference::ModeBatchDatagram:
+ {
+ //
+ // Filter out non-datagram connections.
+ //
connections.erase(remove_if(connections.begin(), connections.end(), not1(ConnectionIsDatagram())),
- connections.end());
- break;
- }
+ connections.end());
+ break;
+ }
}
//
@@ -733,17 +733,17 @@ IceInternal::FixedReference::filterConnections(const vector<ConnectionIPtr>& all
DefaultsAndOverridesPtr overrides = getInstance()->defaultsAndOverrides();
if(overrides->overrideSecure ? overrides->overrideSecureValue : getSecure())
{
- connections.erase(remove_if(connections.begin(), connections.end(), not1(ConnectionIsSecure())),
- connections.end());
+ connections.erase(remove_if(connections.begin(), connections.end(), not1(ConnectionIsSecure())),
+ connections.end());
}
else
{
- //
- // We must use stable_partition() instead of just simply
- // partition(), because otherwise some STL implementations
- // order our now randomized connections.
- //
- stable_partition(connections.begin(), connections.end(), not1(ConnectionIsSecure()));
+ //
+ // We must use stable_partition() instead of just simply
+ // partition(), because otherwise some STL implementations
+ // order our now randomized connections.
+ //
+ stable_partition(connections.begin(), connections.end(), not1(ConnectionIsSecure()));
}
return connections;
@@ -758,10 +758,10 @@ IceInternal::RoutableReference::getRoutedEndpoints() const
if(_routerInfo)
{
//
- // If we route, we send everything to the router's client
- // proxy endpoints.
- //
- return _routerInfo->getClientEndpoints();
+ // If we route, we send everything to the router's client
+ // proxy endpoints.
+ //
+ return _routerInfo->getClientEndpoints();
}
return vector<EndpointIPtr>();
}
@@ -807,7 +807,7 @@ IceInternal::RoutableReference::changeSecure(bool newSecure) const
{
if(newSecure == _secure)
{
- return RoutableReferencePtr(const_cast<RoutableReference*>(this));
+ return RoutableReferencePtr(const_cast<RoutableReference*>(this));
}
RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_secure = newSecure;
@@ -819,7 +819,7 @@ IceInternal::RoutableReference::changePreferSecure(bool newPreferSecure) const
{
if(newPreferSecure == _preferSecure)
{
- return RoutableReferencePtr(const_cast<RoutableReference*>(this));
+ return RoutableReferencePtr(const_cast<RoutableReference*>(this));
}
RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_preferSecure = newPreferSecure;
@@ -832,7 +832,7 @@ IceInternal::RoutableReference::changeRouter(const RouterPrx& newRouter) const
RouterInfoPtr newRouterInfo = getInstance()->routerManager()->get(newRouter);
if(newRouterInfo == _routerInfo)
{
- return RoutableReferencePtr(const_cast<RoutableReference*>(this));
+ return RoutableReferencePtr(const_cast<RoutableReference*>(this));
}
RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_routerInfo = newRouterInfo;
@@ -844,7 +844,7 @@ IceInternal::RoutableReference::changeCollocationOptimization(bool newCollocatio
{
if(newCollocationOptimization == _collocationOptimization)
{
- return RoutableReferencePtr(const_cast<RoutableReference*>(this));
+ return RoutableReferencePtr(const_cast<RoutableReference*>(this));
}
RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_collocationOptimization = newCollocationOptimization;
@@ -856,7 +856,7 @@ IceInternal::RoutableReference::changeCompress(bool newCompress) const
{
if(_overrideCompress && newCompress == _compress)
{
- return RoutableReferencePtr(const_cast<RoutableReference*>(this));
+ return RoutableReferencePtr(const_cast<RoutableReference*>(this));
}
RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_compress = newCompress;
@@ -869,7 +869,7 @@ IceInternal::RoutableReference::changeTimeout(int newTimeout) const
{
if(_overrideTimeout && newTimeout == _timeout)
{
- return RoutableReferencePtr(const_cast<RoutableReference*>(this));
+ return RoutableReferencePtr(const_cast<RoutableReference*>(this));
}
RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_timeout = newTimeout;
@@ -882,7 +882,7 @@ IceInternal::RoutableReference::changeConnectionId(const string& id) const
{
if(id == _connectionId)
{
- return RoutableReferencePtr(const_cast<RoutableReference*>(this));
+ return RoutableReferencePtr(const_cast<RoutableReference*>(this));
}
RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_connectionId = id;
@@ -894,7 +894,7 @@ IceInternal::RoutableReference::changeCacheConnection(bool newCache) const
{
if(newCache == _cacheConnection)
{
- return RoutableReferencePtr(const_cast<RoutableReference*>(this));
+ return RoutableReferencePtr(const_cast<RoutableReference*>(this));
}
RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_cacheConnection = newCache;
@@ -906,7 +906,7 @@ IceInternal::RoutableReference::changeEndpointSelection(EndpointSelectionType ne
{
if(newType == _endpointSelection)
{
- return RoutableReferencePtr(const_cast<RoutableReference*>(this));
+ return RoutableReferencePtr(const_cast<RoutableReference*>(this));
}
RoutableReferencePtr r = RoutableReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_endpointSelection = newType;
@@ -945,35 +945,35 @@ IceInternal::RoutableReference::operator==(const Reference& r) const
}
if(_secure != rhs->_secure)
{
- return false;
+ return false;
}
if(_preferSecure != rhs->_preferSecure)
{
- return false;
+ return false;
}
if(_collocationOptimization != rhs->_collocationOptimization)
{
- return false;
+ return false;
}
if(_cacheConnection != rhs->_cacheConnection)
{
- return false;
+ return false;
}
if(_endpointSelection != rhs->_endpointSelection)
{
- return false;
+ return false;
}
if(_connectionId != rhs->_connectionId)
{
- return false;
+ return false;
}
if(_overrideCompress != rhs->_overrideCompress || _overrideCompress && _compress != rhs->_compress)
{
- return false;
+ return false;
}
if(_overrideTimeout != rhs->_overrideTimeout || _overrideTimeout && _timeout != rhs->_timeout)
{
- return false;
+ return false;
}
if(_threadPerConnection != rhs->_threadPerConnection)
{
@@ -1002,93 +1002,93 @@ IceInternal::RoutableReference::operator<(const Reference& r) const
if(Reference::operator==(r))
{
const RoutableReference* rhs = dynamic_cast<const RoutableReference*>(&r);
- assert(rhs);
- if(!_secure && rhs->_secure)
- {
- return true;
- }
- else if(rhs->_secure < _secure)
- {
- return false;
- }
- else if(!_preferSecure && rhs->_preferSecure)
- {
- return true;
- }
- else if(rhs->_preferSecure < _preferSecure)
- {
- return false;
- }
- if(!_collocationOptimization && rhs->_collocationOptimization)
- {
- return true;
- }
- else if(rhs->_collocationOptimization < _collocationOptimization)
- {
- return false;
- }
- if(!_cacheConnection && rhs->_cacheConnection)
- {
- return true;
- }
- else if(rhs->_cacheConnection < _cacheConnection)
- {
- return false;
- }
- if(_endpointSelection < rhs->_endpointSelection)
- {
- return true;
- }
- else if(rhs->_endpointSelection < _endpointSelection)
- {
- return false;
- }
- if(_connectionId < rhs->_connectionId)
- {
- return true;
- }
- else if(rhs->_connectionId < _connectionId)
- {
- return false;
- }
- if(!_overrideCompress && rhs->_overrideCompress)
- {
- return true;
- }
- else if(rhs->_overrideCompress < _overrideCompress)
- {
- return false;
- }
- else if(_overrideCompress)
- {
- if(!_compress && rhs->_compress)
- {
- return true;
- }
- else if(rhs->_compress < _compress)
- {
- return false;
- }
- }
- if(!_overrideTimeout && rhs->_overrideTimeout)
- {
- return true;
- }
- else if(rhs->_overrideTimeout < _overrideTimeout)
- {
- return false;
- }
- else if(_overrideTimeout)
- {
- if(_timeout < rhs->_timeout)
- {
- return true;
- }
- else if(rhs->_timeout < _timeout)
- {
- return false;
- }
- }
+ assert(rhs);
+ if(!_secure && rhs->_secure)
+ {
+ return true;
+ }
+ else if(rhs->_secure < _secure)
+ {
+ return false;
+ }
+ else if(!_preferSecure && rhs->_preferSecure)
+ {
+ return true;
+ }
+ else if(rhs->_preferSecure < _preferSecure)
+ {
+ return false;
+ }
+ if(!_collocationOptimization && rhs->_collocationOptimization)
+ {
+ return true;
+ }
+ else if(rhs->_collocationOptimization < _collocationOptimization)
+ {
+ return false;
+ }
+ if(!_cacheConnection && rhs->_cacheConnection)
+ {
+ return true;
+ }
+ else if(rhs->_cacheConnection < _cacheConnection)
+ {
+ return false;
+ }
+ if(_endpointSelection < rhs->_endpointSelection)
+ {
+ return true;
+ }
+ else if(rhs->_endpointSelection < _endpointSelection)
+ {
+ return false;
+ }
+ if(_connectionId < rhs->_connectionId)
+ {
+ return true;
+ }
+ else if(rhs->_connectionId < _connectionId)
+ {
+ return false;
+ }
+ if(!_overrideCompress && rhs->_overrideCompress)
+ {
+ return true;
+ }
+ else if(rhs->_overrideCompress < _overrideCompress)
+ {
+ return false;
+ }
+ else if(_overrideCompress)
+ {
+ if(!_compress && rhs->_compress)
+ {
+ return true;
+ }
+ else if(rhs->_compress < _compress)
+ {
+ return false;
+ }
+ }
+ if(!_overrideTimeout && rhs->_overrideTimeout)
+ {
+ return true;
+ }
+ else if(rhs->_overrideTimeout < _overrideTimeout)
+ {
+ return false;
+ }
+ else if(_overrideTimeout)
+ {
+ if(_timeout < rhs->_timeout)
+ {
+ return true;
+ }
+ else if(rhs->_timeout < _timeout)
+ {
+ return false;
+ }
+ }
if(!_threadPerConnection && rhs->_threadPerConnection)
{
return true;
@@ -1097,15 +1097,15 @@ IceInternal::RoutableReference::operator<(const Reference& r) const
{
return false;
}
- return _routerInfo < rhs->_routerInfo;
+ return _routerInfo < rhs->_routerInfo;
}
return false;
}
IceInternal::RoutableReference::RoutableReference(const InstancePtr& inst, const CommunicatorPtr& com,
- const Identity& ident, const SharedContextPtr& ctx, const string& fs,
- Mode md, bool sec, bool prefSec, const RouterInfoPtr& rtrInfo,
- bool collocationOpt, bool cacheConnection,
+ const Identity& ident, const SharedContextPtr& ctx, const string& fs,
+ Mode md, bool sec, bool prefSec, const RouterInfoPtr& rtrInfo,
+ bool collocationOpt, bool cacheConnection,
EndpointSelectionType endpointSelection, bool threadPerConnection) :
Reference(inst, com, ident, ctx, fs, md),
_secure(sec),
@@ -1148,36 +1148,36 @@ IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& all
// Filter out unknown endpoints.
//
endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), Ice::constMemFun(&EndpointI::unknown)),
- endpoints.end());
+ endpoints.end());
//
// Filter out endpoints according to the mode of the reference.
//
switch(getMode())
{
- case Reference::ModeTwoway:
- case Reference::ModeOneway:
- case Reference::ModeBatchOneway:
- {
- //
- // Filter out datagram endpoints.
- //
+ case Reference::ModeTwoway:
+ case Reference::ModeOneway:
+ case Reference::ModeBatchOneway:
+ {
+ //
+ // Filter out datagram endpoints.
+ //
endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), Ice::constMemFun(&EndpointI::datagram)),
endpoints.end());
- break;
- }
-
- case Reference::ModeDatagram:
- case Reference::ModeBatchDatagram:
- {
- //
- // Filter out non-datagram endpoints.
- //
+ break;
+ }
+
+ case Reference::ModeDatagram:
+ case Reference::ModeBatchDatagram:
+ {
+ //
+ // Filter out non-datagram endpoints.
+ //
endpoints.erase(remove_if(endpoints.begin(), endpoints.end(),
- not1(Ice::constMemFun(&EndpointI::datagram))),
+ not1(Ice::constMemFun(&EndpointI::datagram))),
endpoints.end());
- break;
- }
+ break;
+ }
}
//
@@ -1185,22 +1185,22 @@ IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& all
//
switch(getEndpointSelection())
{
- case Random:
- {
- RandomNumberGenerator rng;
- random_shuffle(endpoints.begin(), endpoints.end(), rng);
- break;
- }
- case Ordered:
- {
- // Nothing to do.
- break;
- }
- default:
- {
- assert(false);
- break;
- }
+ case Random:
+ {
+ RandomNumberGenerator rng;
+ random_shuffle(endpoints.begin(), endpoints.end(), rng);
+ break;
+ }
+ case Ordered:
+ {
+ // Nothing to do.
+ break;
+ }
+ default:
+ {
+ assert(false);
+ break;
+ }
}
//
@@ -1212,33 +1212,33 @@ IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& all
DefaultsAndOverridesPtr overrides = getInstance()->defaultsAndOverrides();
if(overrides->overrideSecure ? overrides->overrideSecureValue : getSecure())
{
- endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), not1(Ice::constMemFun(&EndpointI::secure))),
- endpoints.end());
+ endpoints.erase(remove_if(endpoints.begin(), endpoints.end(), not1(Ice::constMemFun(&EndpointI::secure))),
+ endpoints.end());
}
else if(getPreferSecure())
{
- //
- // We must use stable_partition() instead of just simply
- // partition(), because otherwise some STL implementations
- // order our now randomized endpoints.
- //
- stable_partition(endpoints.begin(), endpoints.end(), Ice::constMemFun(&EndpointI::secure));
+ //
+ // We must use stable_partition() instead of just simply
+ // partition(), because otherwise some STL implementations
+ // order our now randomized endpoints.
+ //
+ stable_partition(endpoints.begin(), endpoints.end(), Ice::constMemFun(&EndpointI::secure));
}
else
{
- //
- // We must use stable_partition() instead of just simply
- // partition(), because otherwise some STL implementations
- // order our now randomized endpoints.
- //
- stable_partition(endpoints.begin(), endpoints.end(), not1(Ice::constMemFun(&EndpointI::secure)));
+ //
+ // We must use stable_partition() instead of just simply
+ // partition(), because otherwise some STL implementations
+ // order our now randomized endpoints.
+ //
+ stable_partition(endpoints.begin(), endpoints.end(), not1(Ice::constMemFun(&EndpointI::secure)));
}
if(endpoints.empty())
{
NoEndpointException ex(__FILE__, __LINE__);
- ex.proxy = toString();
- throw ex;
+ ex.proxy = toString();
+ throw ex;
}
//
@@ -1247,42 +1247,42 @@ IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& all
OutgoingConnectionFactoryPtr factory = getInstance()->outgoingConnectionFactory();
if(getCacheConnection() || endpoints.size() == 1)
{
- //
- // Get an existing connection or create one if there's no
- // existing connection to one of the given endpoints.
- //
- return factory->create(endpoints, false, _threadPerConnection, comp);
+ //
+ // Get an existing connection or create one if there's no
+ // existing connection to one of the given endpoints.
+ //
+ return factory->create(endpoints, false, _threadPerConnection, comp);
}
else
{
- //
- // Go through the list of endpoints and try to create the
- // connection until it succeeds. This is different from just
- // calling create() with the given endpoints since this might
- // create a new connection even if there's an existing
- // connection for one of the endpoints.
- //
-
- auto_ptr<LocalException> exception;
- vector<EndpointIPtr> endpoint;
- endpoint.push_back(0);
-
- for(vector<EndpointIPtr>::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
- {
- try
- {
- endpoint.back() = *p;
- return factory->create(endpoint, p + 1 == endpoints.end(), _threadPerConnection, comp);
- }
- catch(const LocalException& ex)
- {
- exception.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
- }
- }
-
- assert(exception.get());
- exception->ice_throw();
- return 0; // Keeps the compiler happy.
+ //
+ // Go through the list of endpoints and try to create the
+ // connection until it succeeds. This is different from just
+ // calling create() with the given endpoints since this might
+ // create a new connection even if there's an existing
+ // connection for one of the endpoints.
+ //
+
+ auto_ptr<LocalException> exception;
+ vector<EndpointIPtr> endpoint;
+ endpoint.push_back(0);
+
+ for(vector<EndpointIPtr>::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
+ {
+ try
+ {
+ endpoint.back() = *p;
+ return factory->create(endpoint, p + 1 == endpoints.end(), _threadPerConnection, comp);
+ }
+ catch(const LocalException& ex)
+ {
+ exception.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
+ }
+ }
+
+ assert(exception.get());
+ exception->ice_throw();
+ return 0; // Keeps the compiler happy.
}
}
@@ -1291,15 +1291,15 @@ IceInternal::RoutableReference::applyOverrides(vector<EndpointIPtr>& endpoints)
{
for(vector<EndpointIPtr>::iterator p = endpoints.begin(); p != endpoints.end(); ++p)
{
- *p = (*p)->connectionId(_connectionId);
- if(_overrideCompress)
- {
- *p = (*p)->compress(_compress);
- }
- if(_overrideTimeout)
- {
- *p = (*p)->timeout(_timeout);
- }
+ *p = (*p)->connectionId(_connectionId);
+ if(_overrideCompress)
+ {
+ *p = (*p)->compress(_compress);
+ }
+ if(_overrideTimeout)
+ {
+ *p = (*p)->timeout(_timeout);
+ }
}
}
@@ -1307,9 +1307,9 @@ void IceInternal::incRef(IceInternal::DirectReference* p) { p->__incRef(); }
void IceInternal::decRef(IceInternal::DirectReference* p) { p->__decRef(); }
IceInternal::DirectReference::DirectReference(const InstancePtr& inst, const CommunicatorPtr& com,
- const Identity& ident, const SharedContextPtr& ctx, const string& fs,
- Mode md, bool sec, bool prefSec, const vector<EndpointIPtr>& endpts,
- const RouterInfoPtr& rtrInfo, bool collocationOpt, bool cacheConnection,
+ const Identity& ident, const SharedContextPtr& ctx, const string& fs,
+ Mode md, bool sec, bool prefSec, const vector<EndpointIPtr>& endpts,
+ const RouterInfoPtr& rtrInfo, bool collocationOpt, bool cacheConnection,
EndpointSelectionType endpointSelection, bool threadPerConnection) :
RoutableReference(inst, com, ident, ctx, fs, md, sec, prefSec, rtrInfo, collocationOpt, cacheConnection,
endpointSelection, threadPerConnection),
@@ -1353,12 +1353,12 @@ IceInternal::DirectReference::changeCompress(bool newCompress) const
DirectReferencePtr r = DirectReferencePtr::dynamicCast(RoutableReference::changeCompress(newCompress));
if(r.get() != this) // Also override the compress flag on the endpoints if it was updated.
{
- vector<EndpointIPtr> newEndpoints;
- for(vector<EndpointIPtr>::const_iterator p = _endpoints.begin(); p != _endpoints.end(); ++p)
- {
- newEndpoints.push_back((*p)->compress(newCompress));
- }
- r->_endpoints = newEndpoints;
+ vector<EndpointIPtr> newEndpoints;
+ for(vector<EndpointIPtr>::const_iterator p = _endpoints.begin(); p != _endpoints.end(); ++p)
+ {
+ newEndpoints.push_back((*p)->compress(newCompress));
+ }
+ r->_endpoints = newEndpoints;
}
return r;
}
@@ -1369,12 +1369,12 @@ IceInternal::DirectReference::changeTimeout(int newTimeout) const
DirectReferencePtr r = DirectReferencePtr::dynamicCast(RoutableReference::changeTimeout(newTimeout));
if(r.get() != this) // Also override the timeout on the endpoints if it was updated.
{
- vector<EndpointIPtr> newEndpoints;
- for(vector<EndpointIPtr>::const_iterator p = _endpoints.begin(); p != _endpoints.end(); ++p)
- {
- newEndpoints.push_back((*p)->timeout(newTimeout));
- }
- r->_endpoints = newEndpoints;
+ vector<EndpointIPtr> newEndpoints;
+ for(vector<EndpointIPtr>::const_iterator p = _endpoints.begin(); p != _endpoints.end(); ++p)
+ {
+ newEndpoints.push_back((*p)->timeout(newTimeout));
+ }
+ r->_endpoints = newEndpoints;
}
return r;
}
@@ -1385,12 +1385,12 @@ IceInternal::DirectReference::changeConnectionId(const string& newConnectionId)
DirectReferencePtr r = DirectReferencePtr::dynamicCast(RoutableReference::changeConnectionId(newConnectionId));
if(r.get() != this) // Also override the connection id on the endpoints if it was updated.
{
- vector<EndpointIPtr> newEndpoints;
- for(vector<EndpointIPtr>::const_iterator p = _endpoints.begin(); p != _endpoints.end(); ++p)
- {
- newEndpoints.push_back((*p)->connectionId(newConnectionId));
- }
- r->_endpoints = newEndpoints;
+ vector<EndpointIPtr> newEndpoints;
+ for(vector<EndpointIPtr>::const_iterator p = _endpoints.begin(); p != _endpoints.end(); ++p)
+ {
+ newEndpoints.push_back((*p)->connectionId(newConnectionId));
+ }
+ r->_endpoints = newEndpoints;
}
return r;
}
@@ -1406,17 +1406,17 @@ IceInternal::DirectReference::changeAdapterId(const string& newAdapterId) const
{
if(!newAdapterId.empty())
{
- LocatorInfoPtr locatorInfo =
- getInstance()->locatorManager()->get(getInstance()->referenceFactory()->getDefaultLocator());
- return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(),
- getSecure(), getPreferSecure(), newAdapterId, getRouterInfo(),
- locatorInfo, getCollocationOptimization(),
+ LocatorInfoPtr locatorInfo =
+ getInstance()->locatorManager()->get(getInstance()->referenceFactory()->getDefaultLocator());
+ return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(),
+ getSecure(), getPreferSecure(), newAdapterId, getRouterInfo(),
+ locatorInfo, getCollocationOptimization(),
getCacheConnection(), getEndpointSelection(),
getThreadPerConnection(), getLocatorCacheTimeout());
}
else
{
- return DirectReferencePtr(const_cast<DirectReference*>(this));
+ return DirectReferencePtr(const_cast<DirectReference*>(this));
}
}
@@ -1425,7 +1425,7 @@ IceInternal::DirectReference::changeEndpoints(const vector<EndpointIPtr>& newEnd
{
if(newEndpoints == _endpoints)
{
- return DirectReferencePtr(const_cast<DirectReference*>(this));
+ return DirectReferencePtr(const_cast<DirectReference*>(this));
}
DirectReferencePtr r = DirectReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_endpoints = newEndpoints;
@@ -1442,14 +1442,14 @@ IceInternal::DirectReference::streamWrite(BasicStream* s) const
s->writeSize(sz);
if(sz)
{
- for(vector<EndpointIPtr>::const_iterator p = _endpoints.begin(); p != _endpoints.end(); ++p)
- {
- (*p)->streamWrite(s);
- }
+ for(vector<EndpointIPtr>::const_iterator p = _endpoints.begin(); p != _endpoints.end(); ++p)
+ {
+ (*p)->streamWrite(s);
+ }
}
else
{
- s->write(string("")); // Adapter id.
+ s->write(string("")); // Adapter id.
}
}
@@ -1468,12 +1468,12 @@ IceInternal::DirectReference::toString() const
vector<EndpointIPtr>::const_iterator p;
for(p = _endpoints.begin(); p != _endpoints.end(); ++p)
{
- string endp = (*p)->toString();
- if(!endp.empty())
- {
- result.append(":");
- result.append(endp);
- }
+ string endp = (*p)->toString();
+ if(!endp.empty())
+ {
+ result.append(":");
+ result.append(endp);
+ }
}
return result;
}
@@ -1486,7 +1486,7 @@ IceInternal::DirectReference::getConnection(bool& comp) const
if(endpts.empty())
{
- endpts = _endpoints; // Endpoint overrides are already applied on these endpoints.
+ endpts = _endpoints; // Endpoint overrides are already applied on these endpoints.
}
ConnectionIPtr connection = createConnection(endpts, comp);
@@ -1540,8 +1540,8 @@ IceInternal::DirectReference::operator<(const Reference& r) const
if(RoutableReference::operator==(r))
{
const DirectReference* rhs = dynamic_cast<const DirectReference*>(&r);
- assert(rhs);
- return _endpoints < rhs->_endpoints;
+ assert(rhs);
+ return _endpoints < rhs->_endpoints;
}
return false;
}
@@ -1562,10 +1562,10 @@ void IceInternal::incRef(IceInternal::IndirectReference* p) { p->__incRef(); }
void IceInternal::decRef(IceInternal::IndirectReference* p) { p->__decRef(); }
IceInternal::IndirectReference::IndirectReference(const InstancePtr& inst, const CommunicatorPtr& com,
- const Identity& ident, const SharedContextPtr& ctx, const string& fs,
- Mode md, bool sec, bool prefSec, const string& adptid,
- const RouterInfoPtr& rtrInfo, const LocatorInfoPtr& locInfo,
- bool collocationOpt, bool cacheConnection,
+ const Identity& ident, const SharedContextPtr& ctx, const string& fs,
+ Mode md, bool sec, bool prefSec, const string& adptid,
+ const RouterInfoPtr& rtrInfo, const LocatorInfoPtr& locInfo,
+ bool collocationOpt, bool cacheConnection,
EndpointSelectionType endpointSelection, bool threadPerConnection,
int locatorCacheTimeout) :
RoutableReference(inst, com, ident, ctx, fs, md, sec, prefSec, rtrInfo, collocationOpt, cacheConnection,
@@ -1606,7 +1606,7 @@ IceInternal::IndirectReference::changeLocator(const LocatorPrx& newLocator) cons
LocatorInfoPtr newLocatorInfo = getInstance()->locatorManager()->get(newLocator);
if(newLocatorInfo == _locatorInfo)
{
- return IndirectReferencePtr(const_cast<IndirectReference*>(this));
+ return IndirectReferencePtr(const_cast<IndirectReference*>(this));
}
IndirectReferencePtr r = IndirectReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_locatorInfo = newLocatorInfo;
@@ -1618,7 +1618,7 @@ IceInternal::IndirectReference::changeAdapterId(const string& newAdapterId) cons
{
if(newAdapterId == _adapterId)
{
- return IndirectReferencePtr(const_cast<IndirectReference*>(this));
+ return IndirectReferencePtr(const_cast<IndirectReference*>(this));
}
IndirectReferencePtr r = IndirectReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_adapterId = newAdapterId;
@@ -1630,14 +1630,14 @@ IceInternal::IndirectReference::changeEndpoints(const vector<EndpointIPtr>& newE
{
if(!newEndpoints.empty())
{
- return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(),
- getSecure(), getPreferSecure(), newEndpoints, getRouterInfo(),
- getCollocationOptimization(), getCacheConnection(),
+ return getInstance()->referenceFactory()->create(getIdentity(), getContext(), getFacet(), getMode(),
+ getSecure(), getPreferSecure(), newEndpoints, getRouterInfo(),
+ getCollocationOptimization(), getCacheConnection(),
getEndpointSelection(), getThreadPerConnection());
}
else
{
- return IndirectReferencePtr(const_cast<IndirectReference*>(this));
+ return IndirectReferencePtr(const_cast<IndirectReference*>(this));
}
}
@@ -1646,7 +1646,7 @@ IceInternal::IndirectReference::changeLocatorCacheTimeout(int timeout) const
{
if(timeout == _locatorCacheTimeout)
{
- return IndirectReferencePtr(const_cast<IndirectReference*>(this));
+ return IndirectReferencePtr(const_cast<IndirectReference*>(this));
}
IndirectReferencePtr r = IndirectReferencePtr::dynamicCast(getInstance()->referenceFactory()->copy(this));
r->_locatorCacheTimeout = timeout;
@@ -1690,18 +1690,18 @@ IceInternal::IndirectReference::toString() const
{
UTF8BufferI buffer;
Byte* last = getInstance()->initializationData().stringConverter->toUTF8(a.data(), a.data() + a.size(), buffer);
- a = string(reinterpret_cast<const char*>(buffer.getBuffer()), last - buffer.getBuffer());
+ a = string(reinterpret_cast<const char*>(buffer.getBuffer()), last - buffer.getBuffer());
}
a = IceUtil::escapeString(a, "");
if(a.find_first_of(" ") != string::npos)
{
- result.append("\"");
- result.append(a);
- result.append("\"");
+ result.append("\"");
+ result.append(a);
+ result.append("\"");
}
else
{
- result.append(_adapterId);
+ result.append(_adapterId);
}
return result;
}
@@ -1713,59 +1713,59 @@ IceInternal::IndirectReference::getConnection(bool& comp) const
while(true)
{
- vector<EndpointIPtr> endpts = RoutableReference::getRoutedEndpoints();
- bool cached = false;
- if(endpts.empty() && _locatorInfo)
- {
- const IndirectReferencePtr self = const_cast<IndirectReference*>(this);
- endpts = _locatorInfo->getEndpoints(self, _locatorCacheTimeout, cached);
- }
-
- applyOverrides(endpts);
-
- try
- {
- connection = createConnection(endpts, comp);
- assert(connection);
- }
- catch(const NoEndpointException& ex)
- {
- throw ex; // No need to retry if there's no endpoints.
- }
- catch(const LocalException& ex)
- {
- if(!getRouterInfo())
- {
- assert(_locatorInfo);
-
- // COMPILERFIX: Braces needed to prevent BCB from causing Reference refCount from
- // being decremented twice when loop continues.
- {
- const IndirectReferencePtr self = const_cast<IndirectReference*>(this);
- _locatorInfo->clearCache(self);
- }
-
- if(cached)
- {
- // COMPILERFIX: Braces needed to prevent BCB from causing TraceLevels refCount from
- // being decremented twice when loop continues.
- {
- TraceLevelsPtr traceLevels = getInstance()->traceLevels();
- if(traceLevels->retry >= 2)
- {
- Trace out(getInstance()->initializationData().logger, traceLevels->retryCat);
- out << "connection to cached endpoints failed\n"
- << "removing endpoints from cache and trying one more time\n" << ex;
- }
- }
- continue;
- }
- }
-
- throw;
- }
-
- break;
+ vector<EndpointIPtr> endpts = RoutableReference::getRoutedEndpoints();
+ bool cached = false;
+ if(endpts.empty() && _locatorInfo)
+ {
+ const IndirectReferencePtr self = const_cast<IndirectReference*>(this);
+ endpts = _locatorInfo->getEndpoints(self, _locatorCacheTimeout, cached);
+ }
+
+ applyOverrides(endpts);
+
+ try
+ {
+ connection = createConnection(endpts, comp);
+ assert(connection);
+ }
+ catch(const NoEndpointException& ex)
+ {
+ throw ex; // No need to retry if there's no endpoints.
+ }
+ catch(const LocalException& ex)
+ {
+ if(!getRouterInfo())
+ {
+ assert(_locatorInfo);
+
+ // COMPILERFIX: Braces needed to prevent BCB from causing Reference refCount from
+ // being decremented twice when loop continues.
+ {
+ const IndirectReferencePtr self = const_cast<IndirectReference*>(this);
+ _locatorInfo->clearCache(self);
+ }
+
+ if(cached)
+ {
+ // COMPILERFIX: Braces needed to prevent BCB from causing TraceLevels refCount from
+ // being decremented twice when loop continues.
+ {
+ TraceLevelsPtr traceLevels = getInstance()->traceLevels();
+ if(traceLevels->retry >= 2)
+ {
+ Trace out(getInstance()->initializationData().logger, traceLevels->retryCat);
+ out << "connection to cached endpoints failed\n"
+ << "removing endpoints from cache and trying one more time\n" << ex;
+ }
+ }
+ continue;
+ }
+ }
+
+ throw;
+ }
+
+ break;
}
//
@@ -1815,7 +1815,7 @@ IceInternal::IndirectReference::operator==(const Reference& r) const
}
return _adapterId == rhs->_adapterId && _locatorInfo == rhs->_locatorInfo &&
- _locatorCacheTimeout == rhs->_locatorCacheTimeout;
+ _locatorCacheTimeout == rhs->_locatorCacheTimeout;
}
bool
@@ -1838,26 +1838,26 @@ IceInternal::IndirectReference::operator<(const Reference& r) const
if(RoutableReference::operator==(r))
{
const IndirectReference* rhs = dynamic_cast<const IndirectReference*>(&r);
- assert(rhs);
- if(_adapterId < rhs->_adapterId)
- {
- return true;
- }
- else if(rhs->_adapterId < _adapterId)
- {
- return false;
- }
-
- if(_locatorInfo < rhs->_locatorInfo)
- {
- return true;
- }
- else if(rhs->_locatorInfo < _locatorInfo)
- {
- return false;
- }
-
- return _locatorCacheTimeout < rhs->_locatorCacheTimeout;
+ assert(rhs);
+ if(_adapterId < rhs->_adapterId)
+ {
+ return true;
+ }
+ else if(rhs->_adapterId < _adapterId)
+ {
+ return false;
+ }
+
+ if(_locatorInfo < rhs->_locatorInfo)
+ {
+ return true;
+ }
+ else if(rhs->_locatorInfo < _locatorInfo)
+ {
+ return false;
+ }
+
+ return _locatorCacheTimeout < rhs->_locatorCacheTimeout;
}
return false;
}
diff --git a/cpp/src/Ice/Reference.h b/cpp/src/Ice/Reference.h
index bd88dcc6826..4b9a07c259e 100644
--- a/cpp/src/Ice/Reference.h
+++ b/cpp/src/Ice/Reference.h
@@ -35,19 +35,19 @@ public:
enum Type
{
- TypeDirect,
- TypeIndirect,
- TypeFixed
+ TypeDirect,
+ TypeIndirect,
+ TypeFixed
};
enum Mode
{
- ModeTwoway,
- ModeOneway,
- ModeBatchOneway,
- ModeDatagram,
- ModeBatchDatagram,
- ModeLast = ModeBatchDatagram
+ ModeTwoway,
+ ModeOneway,
+ ModeBatchOneway,
+ ModeDatagram,
+ ModeBatchDatagram,
+ ModeLast = ModeBatchDatagram
};
Mode getMode() const { return _mode; }
@@ -125,7 +125,7 @@ public:
protected:
Reference(const InstancePtr&, const Ice::CommunicatorPtr&, const Ice::Identity&, const SharedContextPtr&,
- const std::string&, Mode);
+ const std::string&, Mode);
Reference(const Reference&);
IceUtil::RecMutex _hashMutex; // For lazy initialization of hash value.
@@ -148,7 +148,7 @@ class FixedReference : public Reference
public:
FixedReference(const InstancePtr&, const Ice::CommunicatorPtr&, const Ice::Identity&, const SharedContextPtr&,
- const std::string&, Mode, const std::vector<Ice::ConnectionIPtr>&);
+ const std::string&, Mode, const std::vector<Ice::ConnectionIPtr>&);
const std::vector<Ice::ConnectionIPtr>& getFixedConnections() const;
@@ -238,7 +238,7 @@ public:
protected:
RoutableReference(const InstancePtr&, const Ice::CommunicatorPtr&, const Ice::Identity&, const SharedContextPtr&,
- const std::string&, Mode, bool, bool, const RouterInfoPtr&, bool, bool,
+ const std::string&, Mode, bool, bool, const RouterInfoPtr&, bool, bool,
Ice::EndpointSelectionType, bool);
RoutableReference(const RoutableReference&);
@@ -267,7 +267,7 @@ class DirectReference : public RoutableReference
public:
DirectReference(const InstancePtr&, const Ice::CommunicatorPtr&, const Ice::Identity&, const SharedContextPtr&,
- const std::string&, Mode, bool, bool, const std::vector<EndpointIPtr>&, const RouterInfoPtr&, bool,
+ const std::string&, Mode, bool, bool, const std::vector<EndpointIPtr>&, const RouterInfoPtr&, bool,
bool, Ice::EndpointSelectionType, bool);
virtual Type getType() const;
@@ -307,8 +307,8 @@ class IndirectReference : public RoutableReference
public:
IndirectReference(const InstancePtr&, const Ice::CommunicatorPtr&, const Ice::Identity&, const SharedContextPtr&,
- const std::string&, Mode, bool, bool, const std::string&, const RouterInfoPtr&,
- const LocatorInfoPtr&, bool, bool, Ice::EndpointSelectionType, bool, int);
+ const std::string&, Mode, bool, bool, const std::string&, const RouterInfoPtr&,
+ const LocatorInfoPtr&, bool, bool, Ice::EndpointSelectionType, bool, int);
virtual LocatorInfoPtr getLocatorInfo() const { return _locatorInfo; }
diff --git a/cpp/src/Ice/ReferenceFactory.cpp b/cpp/src/Ice/ReferenceFactory.cpp
index 9e2105beaa7..13348367d9a 100644
--- a/cpp/src/Ice/ReferenceFactory.cpp
+++ b/cpp/src/Ice/ReferenceFactory.cpp
@@ -38,7 +38,7 @@ IceInternal::ReferenceFactory::copy(const Reference* r) const
if(!_instance)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
const Ice::Identity& ident = r->getIdentity();
@@ -52,14 +52,14 @@ IceInternal::ReferenceFactory::copy(const Reference* r) const
ReferencePtr
IceInternal::ReferenceFactory::create(const Identity& ident,
- const SharedContextPtr& context,
- const string& facet,
- Reference::Mode mode,
- bool secure,
- bool preferSecure,
- const vector<EndpointIPtr>& endpoints,
- const RouterInfoPtr& routerInfo,
- bool collocationOptimization,
+ const SharedContextPtr& context,
+ const string& facet,
+ Reference::Mode mode,
+ bool secure,
+ bool preferSecure,
+ const vector<EndpointIPtr>& endpoints,
+ const RouterInfoPtr& routerInfo,
+ bool collocationOptimization,
bool cacheConnection,
EndpointSelectionType endpointSelection,
bool threadPerConnection)
@@ -68,7 +68,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
if(!_instance)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
if(ident.name.empty() && ident.category.empty())
@@ -80,31 +80,31 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
// Create new reference
//
return new DirectReference(_instance, _communicator, ident, context, facet, mode, secure, preferSecure,
- endpoints, routerInfo, collocationOptimization, cacheConnection, endpointSelection,
+ endpoints, routerInfo, collocationOptimization, cacheConnection, endpointSelection,
threadPerConnection);
}
ReferencePtr
IceInternal::ReferenceFactory::create(const Identity& ident,
- const SharedContextPtr& context,
- const string& facet,
- Reference::Mode mode,
- bool secure,
- bool preferSecure,
- const string& adapterId,
- const RouterInfoPtr& routerInfo,
- const LocatorInfoPtr& locatorInfo,
- bool collocationOptimization,
+ const SharedContextPtr& context,
+ const string& facet,
+ Reference::Mode mode,
+ bool secure,
+ bool preferSecure,
+ const string& adapterId,
+ const RouterInfoPtr& routerInfo,
+ const LocatorInfoPtr& locatorInfo,
+ bool collocationOptimization,
bool cacheConnection,
EndpointSelectionType endpointSelection,
bool threadPerConnection,
- int locatorCacheTimeout)
+ int locatorCacheTimeout)
{
IceUtil::Mutex::Lock sync(*this);
if(!_instance)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
if(ident.name.empty() && ident.category.empty())
@@ -116,22 +116,22 @@ IceInternal::ReferenceFactory::create(const Identity& ident,
// Create new reference
//
return new IndirectReference(_instance, _communicator, ident, context, facet, mode, secure, preferSecure,
- adapterId, routerInfo, locatorInfo, collocationOptimization, cacheConnection,
+ adapterId, routerInfo, locatorInfo, collocationOptimization, cacheConnection,
endpointSelection, threadPerConnection, locatorCacheTimeout);
}
ReferencePtr
IceInternal::ReferenceFactory::create(const Identity& ident,
- const SharedContextPtr& context,
- const string& facet,
- Reference::Mode mode,
- const vector<Ice::ConnectionIPtr>& fixedConnections)
+ const SharedContextPtr& context,
+ const string& facet,
+ Reference::Mode mode,
+ const vector<Ice::ConnectionIPtr>& fixedConnections)
{
IceUtil::Mutex::Lock sync(*this);
if(!_instance)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
if(ident.name.empty() && ident.category.empty())
@@ -162,9 +162,9 @@ IceInternal::ReferenceFactory::create(const string& str)
beg = s.find_first_not_of(delim, end);
if(beg == string::npos)
{
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
}
//
@@ -175,9 +175,9 @@ IceInternal::ReferenceFactory::create(const string& str)
end = IceUtil::checkQuote(s, beg);
if(end == string::npos)
{
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
}
else if(end == 0)
{
@@ -197,9 +197,9 @@ IceInternal::ReferenceFactory::create(const string& str)
if(beg == end)
{
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
}
//
@@ -243,54 +243,54 @@ IceInternal::ReferenceFactory::create(const string& str)
while(true)
{
- beg = s.find_first_not_of(delim, end);
- if(beg == string::npos)
- {
- break;
- }
+ beg = s.find_first_not_of(delim, end);
+ if(beg == string::npos)
+ {
+ break;
+ }
if(s[beg] == ':' || s[beg] == '@')
{
break;
}
- end = s.find_first_of(delim + ":@", beg);
- if(end == string::npos)
- {
- end = s.length();
- }
-
- if(beg == end)
- {
- break;
- }
-
- string option = s.substr(beg, end - beg);
- if(option.length() != 2 || option[0] != '-')
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
+ end = s.find_first_of(delim + ":@", beg);
+ if(end == string::npos)
+ {
+ end = s.length();
+ }
+
+ if(beg == end)
+ {
+ break;
+ }
+
+ string option = s.substr(beg, end - beg);
+ if(option.length() != 2 || option[0] != '-')
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
//
// Check for the presence of an option argument. The
// argument may be enclosed in single or double
// quotation marks.
//
- string argument;
- string::size_type argumentBeg = s.find_first_not_of(delim, end);
- if(argumentBeg != string::npos)
- {
+ string argument;
+ string::size_type argumentBeg = s.find_first_not_of(delim, end);
+ if(argumentBeg != string::npos)
+ {
if(s[argumentBeg] != '@' && s[argumentBeg] != ':' && s[argumentBeg] != '-')
{
beg = argumentBeg;
end = IceUtil::checkQuote(s, beg);
if(end == string::npos)
{
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
}
else if(end == 0)
{
@@ -307,122 +307,122 @@ IceInternal::ReferenceFactory::create(const string& str)
argument = s.substr(beg, end - beg);
end++; // Skip trailing quote
}
- }
- }
-
- //
- // If any new options are added here,
- // IceInternal::Reference::toString() and its derived classes must be updated as well.
- //
- switch(option[1])
- {
- case 'f':
- {
- if(argument.empty())
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
-
- if(!IceUtil::unescapeString(argument, 0, argument.size(), facet))
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
-
- if(_instance->initializationData().stringConverter)
- {
- string tmpFacet;
- _instance->initializationData().stringConverter->fromUTF8(
- reinterpret_cast<const Byte*>(facet.data()),
- reinterpret_cast<const Byte*>(facet.data() + facet.size()), tmpFacet);
- facet = tmpFacet;
- }
-
- break;
- }
-
- case 't':
- {
- if(!argument.empty())
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
- mode = Reference::ModeTwoway;
- break;
- }
-
- case 'o':
- {
- if(!argument.empty())
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
- mode = Reference::ModeOneway;
- break;
- }
-
- case 'O':
- {
- if(!argument.empty())
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
- mode = Reference::ModeBatchOneway;
- break;
- }
-
- case 'd':
- {
- if(!argument.empty())
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
- mode = Reference::ModeDatagram;
- break;
- }
-
- case 'D':
- {
- if(!argument.empty())
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
- mode = Reference::ModeBatchDatagram;
- break;
- }
-
- case 's':
- {
- if(!argument.empty())
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
- secure = true;
- break;
- }
-
- default:
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
- }
+ }
+ }
+
+ //
+ // If any new options are added here,
+ // IceInternal::Reference::toString() and its derived classes must be updated as well.
+ //
+ switch(option[1])
+ {
+ case 'f':
+ {
+ if(argument.empty())
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+
+ if(!IceUtil::unescapeString(argument, 0, argument.size(), facet))
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+
+ if(_instance->initializationData().stringConverter)
+ {
+ string tmpFacet;
+ _instance->initializationData().stringConverter->fromUTF8(
+ reinterpret_cast<const Byte*>(facet.data()),
+ reinterpret_cast<const Byte*>(facet.data() + facet.size()), tmpFacet);
+ facet = tmpFacet;
+ }
+
+ break;
+ }
+
+ case 't':
+ {
+ if(!argument.empty())
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+ mode = Reference::ModeTwoway;
+ break;
+ }
+
+ case 'o':
+ {
+ if(!argument.empty())
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+ mode = Reference::ModeOneway;
+ break;
+ }
+
+ case 'O':
+ {
+ if(!argument.empty())
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+ mode = Reference::ModeBatchOneway;
+ break;
+ }
+
+ case 'd':
+ {
+ if(!argument.empty())
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+ mode = Reference::ModeDatagram;
+ break;
+ }
+
+ case 'D':
+ {
+ if(!argument.empty())
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+ mode = Reference::ModeBatchDatagram;
+ break;
+ }
+
+ case 's':
+ {
+ if(!argument.empty())
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+ secure = true;
+ break;
+ }
+
+ default:
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+ }
}
RouterInfoPtr routerInfo = _instance->routerManager()->get(getDefaultRouter());
@@ -430,9 +430,9 @@ IceInternal::ReferenceFactory::create(const string& str)
if(beg == string::npos)
{
- return create(ident, _instance->getDefaultContext(), facet, mode, secure,
- _instance->defaultsAndOverrides()->defaultPreferSecure, "", routerInfo,
- locatorInfo, _instance->defaultsAndOverrides()->defaultCollocationOptimization,
+ return create(ident, _instance->getDefaultContext(), facet, mode, secure,
+ _instance->defaultsAndOverrides()->defaultPreferSecure, "", routerInfo,
+ locatorInfo, _instance->defaultsAndOverrides()->defaultCollocationOptimization,
true, _instance->defaultsAndOverrides()->defaultEndpointSelection,
_instance->threadPerConnection(), _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout);
}
@@ -441,118 +441,118 @@ IceInternal::ReferenceFactory::create(const string& str)
switch(s[beg])
{
- case ':':
- {
- vector<string> unknownEndpoints;
- end = beg;
-
- while(end < s.length() && s[end] == ':')
- {
- beg = end + 1;
-
- end = s.find(':', beg);
- if(end == string::npos)
- {
- end = s.length();
- }
-
- string es = s.substr(beg, end - beg);
- EndpointIPtr endp = _instance->endpointFactoryManager()->create(es);
- if(endp != 0)
- {
- vector<EndpointIPtr> endps = endp->expand(false);
- endpoints.insert(endpoints.end(), endps.begin(), endps.end());
- }
- else
- {
- unknownEndpoints.push_back(es);
- }
- }
- if(endpoints.size() == 0)
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = unknownEndpoints.front();
- throw ex;
- }
- else if(unknownEndpoints.size() != 0 &&
- _instance->initializationData().properties->
- getPropertyAsIntWithDefault("Ice.Warn.Endpoints", 1) > 0)
- {
- Warning out(_instance->initializationData().logger);
- out << "Proxy contains unknown endpoints:";
- for(unsigned int idx = 0; idx < unknownEndpoints.size(); ++idx)
- {
- out << " `" << unknownEndpoints[idx] << "'";
- }
- }
-
- return create(ident, _instance->getDefaultContext(), facet, mode, secure,
- _instance->defaultsAndOverrides()->defaultPreferSecure, endpoints, routerInfo,
- _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
+ case ':':
+ {
+ vector<string> unknownEndpoints;
+ end = beg;
+
+ while(end < s.length() && s[end] == ':')
+ {
+ beg = end + 1;
+
+ end = s.find(':', beg);
+ if(end == string::npos)
+ {
+ end = s.length();
+ }
+
+ string es = s.substr(beg, end - beg);
+ EndpointIPtr endp = _instance->endpointFactoryManager()->create(es);
+ if(endp != 0)
+ {
+ vector<EndpointIPtr> endps = endp->expand(false);
+ endpoints.insert(endpoints.end(), endps.begin(), endps.end());
+ }
+ else
+ {
+ unknownEndpoints.push_back(es);
+ }
+ }
+ if(endpoints.size() == 0)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = unknownEndpoints.front();
+ throw ex;
+ }
+ else if(unknownEndpoints.size() != 0 &&
+ _instance->initializationData().properties->
+ getPropertyAsIntWithDefault("Ice.Warn.Endpoints", 1) > 0)
+ {
+ Warning out(_instance->initializationData().logger);
+ out << "Proxy contains unknown endpoints:";
+ for(unsigned int idx = 0; idx < unknownEndpoints.size(); ++idx)
+ {
+ out << " `" << unknownEndpoints[idx] << "'";
+ }
+ }
+
+ return create(ident, _instance->getDefaultContext(), facet, mode, secure,
+ _instance->defaultsAndOverrides()->defaultPreferSecure, endpoints, routerInfo,
+ _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
_instance->defaultsAndOverrides()->defaultEndpointSelection,
_instance->threadPerConnection());
- break;
- }
- case '@':
- {
- beg = s.find_first_not_of(delim, beg + 1);
- if(beg == string::npos)
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
-
- end = IceUtil::checkQuote(s, beg);
- if(end == string::npos)
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
- else if(end == 0)
- {
- end = s.find_first_of(delim, beg);
- if(end == string::npos)
- {
- end = s.size();
- }
- }
- else
- {
- beg++; // Skip leading quote
- }
-
-
- if(!IceUtil::unescapeString(s, beg, end, adapter) || adapter.size() == 0)
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
+ break;
+ }
+ case '@':
+ {
+ beg = s.find_first_not_of(delim, beg + 1);
+ if(beg == string::npos)
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+
+ end = IceUtil::checkQuote(s, beg);
+ if(end == string::npos)
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
+ else if(end == 0)
+ {
+ end = s.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ end = s.size();
+ }
+ }
+ else
+ {
+ beg++; // Skip leading quote
+ }
+
+
+ if(!IceUtil::unescapeString(s, beg, end, adapter) || adapter.size() == 0)
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
if(_instance->initializationData().stringConverter)
{
- string tmpAdapter;
+ string tmpAdapter;
_instance->initializationData().stringConverter->fromUTF8(
- reinterpret_cast<const Byte*>(adapter.data()),
- reinterpret_cast<const Byte*>(adapter.data() + adapter.size()), tmpAdapter);
- adapter = tmpAdapter;
+ reinterpret_cast<const Byte*>(adapter.data()),
+ reinterpret_cast<const Byte*>(adapter.data() + adapter.size()), tmpAdapter);
+ adapter = tmpAdapter;
}
-
- return create(ident, _instance->getDefaultContext(), facet, mode, secure,
- _instance->defaultsAndOverrides()->defaultPreferSecure, adapter, routerInfo, locatorInfo,
- _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
+
+ return create(ident, _instance->getDefaultContext(), facet, mode, secure,
+ _instance->defaultsAndOverrides()->defaultPreferSecure, adapter, routerInfo, locatorInfo,
+ _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
_instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection(),
- _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout);
- break;
- }
- default:
- {
- ProxyParseException ex(__FILE__, __LINE__);
- ex.str = str;
- throw ex;
- }
+ _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout);
+ break;
+ }
+ default:
+ {
+ ProxyParseException ex(__FILE__, __LINE__);
+ ex.str = str;
+ throw ex;
+ }
}
return 0; // Unreachable, prevents compiler warning.
@@ -573,7 +573,7 @@ IceInternal::ReferenceFactory::createFromProperties(const string& propertyPrefix
if(!properties->getProperty(property).empty())
{
ref = ref->changeLocator(
- LocatorPrx::uncheckedCast(_communicator->propertyToProxy(property)));
+ LocatorPrx::uncheckedCast(_communicator->propertyToProxy(property)));
}
property = propertyPrefix + ".LocatorCacheTimeout";
@@ -586,7 +586,7 @@ IceInternal::ReferenceFactory::createFromProperties(const string& propertyPrefix
if(!properties->getProperty(property).empty())
{
ref = ref->changeRouter(
- RouterPrx::uncheckedCast(_communicator->propertyToProxy(property)));
+ RouterPrx::uncheckedCast(_communicator->propertyToProxy(property)));
}
property = propertyPrefix + ".PreferSecure";
@@ -606,19 +606,19 @@ IceInternal::ReferenceFactory::createFromProperties(const string& propertyPrefix
{
string type = properties->getProperty(property);
if(type == "Random")
- {
- ref = ref->changeEndpointSelection(Random);
- }
- else if(type == "Ordered")
- {
- ref = ref->changeEndpointSelection(Ordered);
- }
- else
- {
- EndpointSelectionTypeParseException ex(__FILE__, __LINE__);
- ex.str = type;
- throw ex;
- }
+ {
+ ref = ref->changeEndpointSelection(Random);
+ }
+ else if(type == "Ordered")
+ {
+ ref = ref->changeEndpointSelection(Ordered);
+ }
+ else
+ {
+ EndpointSelectionTypeParseException ex(__FILE__, __LINE__);
+ ex.str = type;
+ throw ex;
+ }
}
property = propertyPrefix + ".CollocationOptimization";
@@ -646,7 +646,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s)
if(ident.name.empty() && ident.category.empty())
{
- return 0;
+ return 0;
}
//
@@ -657,10 +657,10 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s)
string facet;
if(!facetPath.empty())
{
- if(facetPath.size() > 1)
- {
- throw ProxyUnmarshalException(__FILE__, __LINE__);
- }
+ if(facetPath.size() > 1)
+ {
+ throw ProxyUnmarshalException(__FILE__, __LINE__);
+ }
facet.swap(facetPath[0]);
}
@@ -669,7 +669,7 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s)
Reference::Mode mode = static_cast<Reference::Mode>(modeAsByte);
if(mode < 0 || mode > Reference::ModeLast)
{
- throw ProxyUnmarshalException(__FILE__, __LINE__);
+ throw ProxyUnmarshalException(__FILE__, __LINE__);
}
bool secure;
@@ -686,25 +686,25 @@ IceInternal::ReferenceFactory::create(const Identity& ident, BasicStream* s)
if(sz > 0)
{
- endpoints.reserve(sz);
- while(sz--)
- {
- EndpointIPtr endpoint = _instance->endpointFactoryManager()->read(s);
- endpoints.push_back(endpoint);
- }
- return create(ident, _instance->getDefaultContext(), facet, mode, secure,
- _instance->defaultsAndOverrides()->defaultPreferSecure, endpoints, routerInfo,
- _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
- _instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection());
+ endpoints.reserve(sz);
+ while(sz--)
+ {
+ EndpointIPtr endpoint = _instance->endpointFactoryManager()->read(s);
+ endpoints.push_back(endpoint);
+ }
+ return create(ident, _instance->getDefaultContext(), facet, mode, secure,
+ _instance->defaultsAndOverrides()->defaultPreferSecure, endpoints, routerInfo,
+ _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
+ _instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection());
}
else
{
- s->read(adapterId);
- return create(ident, _instance->getDefaultContext(), facet, mode, secure,
- _instance->defaultsAndOverrides()->defaultPreferSecure, adapterId, routerInfo, locatorInfo,
- _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
- _instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection(),
- _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout);
+ s->read(adapterId);
+ return create(ident, _instance->getDefaultContext(), facet, mode, secure,
+ _instance->defaultsAndOverrides()->defaultPreferSecure, adapterId, routerInfo, locatorInfo,
+ _instance->defaultsAndOverrides()->defaultCollocationOptimization, true,
+ _instance->defaultsAndOverrides()->defaultEndpointSelection, _instance->threadPerConnection(),
+ _instance->defaultsAndOverrides()->defaultLocatorCacheTimeout);
}
}
@@ -749,7 +749,7 @@ IceInternal::ReferenceFactory::destroy()
if(!_instance)
{
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
_instance = 0;
diff --git a/cpp/src/Ice/ReferenceFactory.h b/cpp/src/Ice/ReferenceFactory.h
index cea63de6757..e687c956255 100644
--- a/cpp/src/Ice/ReferenceFactory.h
+++ b/cpp/src/Ice/ReferenceFactory.h
@@ -32,19 +32,19 @@ public:
// Create a direct reference.
//
ReferencePtr create(const ::Ice::Identity&, const SharedContextPtr&, const ::std::string&,
- Reference::Mode, bool, bool, const ::std::vector<EndpointIPtr>&,
- const RouterInfoPtr&, bool, bool, Ice::EndpointSelectionType, bool);
+ Reference::Mode, bool, bool, const ::std::vector<EndpointIPtr>&,
+ const RouterInfoPtr&, bool, bool, Ice::EndpointSelectionType, bool);
//
// Create an indirect reference.
//
ReferencePtr create(const ::Ice::Identity&, const SharedContextPtr&, const ::std::string&,
- Reference::Mode, bool, bool, const ::std::string&,
- const RouterInfoPtr&, const LocatorInfoPtr&, bool, bool, Ice::EndpointSelectionType, bool, int);
+ Reference::Mode, bool, bool, const ::std::string&,
+ const RouterInfoPtr&, const LocatorInfoPtr&, bool, bool, Ice::EndpointSelectionType, bool, int);
//
// Create a fixed reference.
//
ReferencePtr create(const ::Ice::Identity&, const SharedContextPtr&, const ::std::string&,
- Reference::Mode, const ::std::vector< ::Ice::ConnectionIPtr>&);
+ Reference::Mode, const ::std::vector< ::Ice::ConnectionIPtr>&);
//
// Create a reference from a string.
diff --git a/cpp/src/Ice/RouterInfo.cpp b/cpp/src/Ice/RouterInfo.cpp
index d5294304d2c..8eb60be1bdd 100644
--- a/cpp/src/Ice/RouterInfo.cpp
+++ b/cpp/src/Ice/RouterInfo.cpp
@@ -45,7 +45,7 @@ IceInternal::RouterManager::get(const RouterPrx& rtr)
{
if(!rtr)
{
- return 0;
+ return 0;
}
RouterPrx router = RouterPrx::uncheckedCast(rtr->ice_router(0)); // The router cannot be routed.
@@ -56,24 +56,24 @@ IceInternal::RouterManager::get(const RouterPrx& rtr)
if(_tableHint != _table.end())
{
- if(_tableHint->first == router)
- {
- p = _tableHint;
- }
+ if(_tableHint->first == router)
+ {
+ p = _tableHint;
+ }
}
if(p == _table.end())
{
- p = _table.find(router);
+ p = _table.find(router);
}
if(p == _table.end())
{
- _tableHint = _table.insert(_tableHint, pair<const RouterPrx, RouterInfoPtr>(router, new RouterInfo(router)));
+ _tableHint = _table.insert(_tableHint, pair<const RouterPrx, RouterInfoPtr>(router, new RouterInfo(router)));
}
else
{
- _tableHint = p;
+ _tableHint = p;
}
return _tableHint->second;
@@ -85,26 +85,26 @@ IceInternal::RouterManager::erase(const RouterPrx& rtr)
RouterInfoPtr info;
if(rtr)
{
- RouterPrx router = RouterPrx::uncheckedCast(rtr->ice_router(0)); // The router cannot be routed.
- IceUtil::Mutex::Lock sync(*this);
-
- map<RouterPrx, RouterInfoPtr>::iterator p = _table.end();
- if(_tableHint != _table.end() && _tableHint->first == router)
- {
- p = _tableHint;
- _tableHint = _table.end();
- }
-
- if(p == _table.end())
- {
- p = _table.find(router);
- }
-
- if(p != _table.end())
- {
- info = p->second;
- _table.erase(p);
- }
+ RouterPrx router = RouterPrx::uncheckedCast(rtr->ice_router(0)); // The router cannot be routed.
+ IceUtil::Mutex::Lock sync(*this);
+
+ map<RouterPrx, RouterInfoPtr>::iterator p = _table.end();
+ if(_tableHint != _table.end() && _tableHint->first == router)
+ {
+ p = _tableHint;
+ _tableHint = _table.end();
+ }
+
+ if(p == _table.end())
+ {
+ p = _table.find(router);
+ }
+
+ if(p != _table.end())
+ {
+ info = p->second;
+ _table.erase(p);
+ }
}
return info;
@@ -161,34 +161,34 @@ IceInternal::RouterInfo::getClientEndpoints()
if(_clientEndpoints.size() == 0) // Lazy initialization.
{
- ObjectPrx clientProxy = _router->getClientProxy();
- if(!clientProxy)
- {
- //
- // If getClientProxy() return nil, use router endpoints.
- //
- _clientEndpoints = _router->__reference()->getEndpoints();
- }
- else
- {
- clientProxy = clientProxy->ice_router(0); // The client proxy cannot be routed.
-
- //
- // In order to avoid creating a new connection to the router,
- // we must use the same timeout as the already existing
- // connection.
- //
- try
- {
- clientProxy = clientProxy->ice_timeout(_router->ice_getConnection()->timeout());
- }
- catch(const Ice::CollocationOptimizationException&)
- {
- // Ignore - collocated router
- }
-
- _clientEndpoints = clientProxy->__reference()->getEndpoints();
- }
+ ObjectPrx clientProxy = _router->getClientProxy();
+ if(!clientProxy)
+ {
+ //
+ // If getClientProxy() return nil, use router endpoints.
+ //
+ _clientEndpoints = _router->__reference()->getEndpoints();
+ }
+ else
+ {
+ clientProxy = clientProxy->ice_router(0); // The client proxy cannot be routed.
+
+ //
+ // In order to avoid creating a new connection to the router,
+ // we must use the same timeout as the already existing
+ // connection.
+ //
+ try
+ {
+ clientProxy = clientProxy->ice_timeout(_router->ice_getConnection()->timeout());
+ }
+ catch(const Ice::CollocationOptimizationException&)
+ {
+ // Ignore - collocated router
+ }
+
+ _clientEndpoints = clientProxy->__reference()->getEndpoints();
+ }
}
return _clientEndpoints;
@@ -201,15 +201,15 @@ IceInternal::RouterInfo::getServerEndpoints()
if(_serverEndpoints.size() == 0) // Lazy initialization.
{
- ObjectPrx serverProxy = _router->getServerProxy();
- if(!serverProxy)
- {
- throw NoEndpointException(__FILE__, __LINE__);
- }
+ ObjectPrx serverProxy = _router->getServerProxy();
+ if(!serverProxy)
+ {
+ throw NoEndpointException(__FILE__, __LINE__);
+ }
- serverProxy = serverProxy->ice_router(0); // The server proxy cannot be routed.
+ serverProxy = serverProxy->ice_router(0); // The server proxy cannot be routed.
- _serverEndpoints = serverProxy->__reference()->getEndpoints();
+ _serverEndpoints = serverProxy->__reference()->getEndpoints();
}
return _serverEndpoints;
@@ -226,25 +226,25 @@ IceInternal::RouterInfo::addProxy(const ObjectPrx& proxy)
if(p == _identities.end())
{
- //
- // Only add the proxy to the router if it's not already in our local map.
- //
- ObjectProxySeq proxies;
- proxies.push_back(proxy);
- ObjectProxySeq evictedProxies = _router->addProxies(proxies);
-
- //
- // If we successfully added the proxy to the router, we add it to our local map.
- //
- _identities.insert(_identities.begin(), proxy->ice_getIdentity());
-
- //
- // We also must remove whatever proxies the router evicted.
- //
- for(ObjectProxySeq::iterator q = evictedProxies.begin(); q != evictedProxies.end(); ++q)
- {
- _identities.erase((*q)->ice_getIdentity());
- }
+ //
+ // Only add the proxy to the router if it's not already in our local map.
+ //
+ ObjectProxySeq proxies;
+ proxies.push_back(proxy);
+ ObjectProxySeq evictedProxies = _router->addProxies(proxies);
+
+ //
+ // If we successfully added the proxy to the router, we add it to our local map.
+ //
+ _identities.insert(_identities.begin(), proxy->ice_getIdentity());
+
+ //
+ // We also must remove whatever proxies the router evicted.
+ //
+ for(ObjectProxySeq::iterator q = evictedProxies.begin(); q != evictedProxies.end(); ++q)
+ {
+ _identities.erase((*q)->ice_getIdentity());
+ }
}
}
diff --git a/cpp/src/Ice/ServantManager.cpp b/cpp/src/Ice/ServantManager.cpp
index 4f2ad489d1e..0a9a6d010ce 100644
--- a/cpp/src/Ice/ServantManager.cpp
+++ b/cpp/src/Ice/ServantManager.cpp
@@ -35,26 +35,26 @@ IceInternal::ServantManager::addServant(const ObjectPtr& object, const Identity&
if(p == _servantMapMap.end() || p->first != ident)
{
- p = _servantMapMap.find(ident);
+ p = _servantMapMap.find(ident);
}
if(p == _servantMapMap.end())
{
- p = _servantMapMap.insert(_servantMapMapHint, pair<const Identity, FacetMap>(ident, FacetMap()));
+ p = _servantMapMap.insert(_servantMapMapHint, pair<const Identity, FacetMap>(ident, FacetMap()));
}
else
{
- if(p->second.find(facet) != p->second.end())
- {
- AlreadyRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "servant";
- ex.id = _instance->identityToString(ident);
- if(!facet.empty())
- {
- ex.id += " -f " + IceUtil::escapeString(facet, "");
- }
- throw ex;
- }
+ if(p->second.find(facet) != p->second.end())
+ {
+ AlreadyRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "servant";
+ ex.id = _instance->identityToString(ident);
+ if(!facet.empty())
+ {
+ ex.id += " -f " + IceUtil::escapeString(facet, "");
+ }
+ throw ex;
+ }
}
_servantMapMapHint = p;
@@ -81,19 +81,19 @@ IceInternal::ServantManager::removeServant(const Identity& ident, const string&
if(p == _servantMapMap.end() || p->first != ident)
{
- p = _servantMapMap.find(ident);
+ p = _servantMapMap.find(ident);
}
if(p == _servantMapMap.end() || (q = p->second.find(facet)) == p->second.end())
{
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "servant";
- ex.id = _instance->identityToString(ident);
- if(!facet.empty())
- {
- ex.id += " -f " + IceUtil::escapeString(facet, "");
- }
- throw ex;
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "servant";
+ ex.id = _instance->identityToString(ident);
+ if(!facet.empty())
+ {
+ ex.id += " -f " + IceUtil::escapeString(facet, "");
+ }
+ throw ex;
}
servant = q->second;
@@ -101,15 +101,15 @@ IceInternal::ServantManager::removeServant(const Identity& ident, const string&
if(p->second.empty())
{
- if(p == _servantMapMapHint)
- {
- _servantMapMap.erase(p++);
- _servantMapMapHint = p;
- }
- else
- {
- _servantMapMap.erase(p);
- }
+ if(p == _servantMapMapHint)
+ {
+ _servantMapMap.erase(p++);
+ _servantMapMapHint = p;
+ }
+ else
+ {
+ _servantMapMap.erase(p);
+ }
}
return servant;
}
@@ -125,27 +125,27 @@ IceInternal::ServantManager::removeAllFacets(const Identity& ident)
if(p == _servantMapMap.end() || p->first != ident)
{
- p = _servantMapMap.find(ident);
+ p = _servantMapMap.find(ident);
}
if(p == _servantMapMap.end())
{
- NotRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "servant";
- ex.id = _instance->identityToString(ident);
- throw ex;
+ NotRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "servant";
+ ex.id = _instance->identityToString(ident);
+ throw ex;
}
FacetMap result = p->second;
if(p == _servantMapMapHint)
{
- _servantMapMap.erase(p++);
- _servantMapMapHint = p;
+ _servantMapMap.erase(p++);
+ _servantMapMapHint = p;
}
else
{
- _servantMapMap.erase(p);
+ _servantMapMap.erase(p);
}
return result;
@@ -171,17 +171,17 @@ IceInternal::ServantManager::findServant(const Identity& ident, const string& fa
if(p == servantMapMap.end() || p->first != ident)
{
- p = servantMapMap.find(ident);
+ p = servantMapMap.find(ident);
}
if(p == servantMapMap.end() || (q = p->second.find(facet)) == p->second.end())
{
- return 0;
+ return 0;
}
else
{
- _servantMapMapHint = p;
- return q->second;
+ _servantMapMapHint = p;
+ return q->second;
}
}
@@ -198,17 +198,17 @@ IceInternal::ServantManager::findAllFacets(const Identity& ident) const
if(p == servantMapMap.end() || p->first != ident)
{
- p = servantMapMap.find(ident);
+ p = servantMapMap.find(ident);
}
if(p == servantMapMap.end())
{
- return FacetMap();
+ return FacetMap();
}
else
{
- _servantMapMapHint = p;
- return p->second;
+ _servantMapMapHint = p;
+ return p->second;
}
}
@@ -230,18 +230,18 @@ IceInternal::ServantManager::hasServant(const Identity& ident) const
if(p == servantMapMap.end() || p->first != ident)
{
- p = servantMapMap.find(ident);
+ p = servantMapMap.find(ident);
}
if(p == servantMapMap.end())
{
- return false;
+ return false;
}
else
{
- _servantMapMapHint = p;
- assert(!p->second.empty());
- return true;
+ _servantMapMapHint = p;
+ assert(!p->second.empty());
+ return true;
}
}
@@ -255,10 +255,10 @@ IceInternal::ServantManager::addServantLocator(const ServantLocatorPtr& locator,
if((_locatorMapHint != _locatorMap.end() && _locatorMapHint->first == category)
|| _locatorMap.find(category) != _locatorMap.end())
{
- AlreadyRegisteredException ex(__FILE__, __LINE__);
- ex.kindOfObject = "servant locator";
- ex.id = IceUtil::escapeString(category, "");
- throw ex;
+ AlreadyRegisteredException ex(__FILE__, __LINE__);
+ ex.kindOfObject = "servant locator";
+ ex.id = IceUtil::escapeString(category, "");
+ throw ex;
}
_locatorMapHint = _locatorMap.insert(_locatorMapHint, pair<const string, ServantLocatorPtr>(category, locator));
@@ -278,30 +278,30 @@ IceInternal::ServantManager::findServantLocator(const string& category) const
//assert(_instance); // Must not be called after destruction.
map<string, ServantLocatorPtr>& locatorMap =
- const_cast<map<string, ServantLocatorPtr>&>(_locatorMap);
+ const_cast<map<string, ServantLocatorPtr>&>(_locatorMap);
map<string, ServantLocatorPtr>::iterator p = locatorMap.end();
if(_locatorMapHint != locatorMap.end())
{
- if(_locatorMapHint->first == category)
- {
- p = _locatorMapHint;
- }
+ if(_locatorMapHint->first == category)
+ {
+ p = _locatorMapHint;
+ }
}
if(p == locatorMap.end())
{
- p = locatorMap.find(category);
+ p = locatorMap.find(category);
}
if(p != locatorMap.end())
{
- _locatorMapHint = p;
- return p->second;
+ _locatorMapHint = p;
+ return p->second;
}
else
{
- return 0;
+ return 0;
}
}
@@ -330,40 +330,40 @@ IceInternal::ServantManager::destroy()
map<string, ServantLocatorPtr> locatorMap;
{
- IceUtil::Mutex::Lock sync(*this);
-
- assert(_instance); // Must not be called after destruction.
-
- servantMapMap.swap(_servantMapMap);
- _servantMapMapHint = _servantMapMap.end();
-
- for(map<string, ServantLocatorPtr>::const_iterator p = _locatorMap.begin(); p != _locatorMap.end(); ++p)
- {
- try
- {
- p->second->deactivate(p->first);
- }
- catch(const Exception& ex)
- {
- Error out(_instance->initializationData().logger);
- out << "exception during locator deactivation:\n"
- << "object adapter: `" << _adapterName << "'\n"
- << "locator category: `" << p->first << "'\n"
- << ex;
- }
- catch(...)
- {
- Error out(_instance->initializationData().logger);
- out << "unknown exception during locator deactivation:\n"
- << "object adapter: `" << _adapterName << "'\n"
- << "locator category: `" << p->first << "'";
- }
- }
-
- locatorMap.swap(_locatorMap);
- _locatorMapHint = _locatorMap.end();
-
- _instance = 0;
+ IceUtil::Mutex::Lock sync(*this);
+
+ assert(_instance); // Must not be called after destruction.
+
+ servantMapMap.swap(_servantMapMap);
+ _servantMapMapHint = _servantMapMap.end();
+
+ for(map<string, ServantLocatorPtr>::const_iterator p = _locatorMap.begin(); p != _locatorMap.end(); ++p)
+ {
+ try
+ {
+ p->second->deactivate(p->first);
+ }
+ catch(const Exception& ex)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "exception during locator deactivation:\n"
+ << "object adapter: `" << _adapterName << "'\n"
+ << "locator category: `" << p->first << "'\n"
+ << ex;
+ }
+ catch(...)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "unknown exception during locator deactivation:\n"
+ << "object adapter: `" << _adapterName << "'\n"
+ << "locator category: `" << p->first << "'";
+ }
+ }
+
+ locatorMap.swap(_locatorMap);
+ _locatorMapHint = _locatorMap.end();
+
+ _instance = 0;
}
//
diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp
index 21f6a579eb5..d4232d2aefe 100755
--- a/cpp/src/Ice/Service.cpp
+++ b/cpp/src/Ice/Service.cpp
@@ -107,19 +107,19 @@ private:
{
public:
- StatusThread(ServiceStatusManager* manager) :
- _manager(manager)
- {
- }
+ StatusThread(ServiceStatusManager* manager) :
+ _manager(manager)
+ {
+ }
- virtual void run()
- {
- _manager->run();
- }
+ virtual void run()
+ {
+ _manager->run();
+ }
private:
- ServiceStatusManager* _manager;
+ ServiceStatusManager* _manager;
};
friend class StatusThread;
@@ -159,26 +159,26 @@ Ice::Service::shutdown()
{
if(_communicator)
{
- try
- {
- _communicator->shutdown();
- }
- catch(const CommunicatorDestroyedException&)
- {
- //
- // Expected if the service communicator is being destroyed.
- //
- }
- catch(const Ice::Exception& ex)
- {
- ostringstream ostr;
- ostr << "exception during shutdown:\n" << ex;
- warning(ostr.str());
- }
- catch(...)
- {
- warning("unknown exception during shutdown");
- }
+ try
+ {
+ _communicator->shutdown();
+ }
+ catch(const CommunicatorDestroyedException&)
+ {
+ //
+ // Expected if the service communicator is being destroyed.
+ //
+ }
+ catch(const Ice::Exception& ex)
+ {
+ ostringstream ostr;
+ ostr << "exception during shutdown:\n" << ex;
+ warning(ostr.str());
+ }
+ catch(...)
+ {
+ warning("unknown exception during shutdown");
+ }
}
return true;
}
@@ -204,48 +204,48 @@ Ice::Service::main(int& argc, char* argv[], const InitializationData& initData)
{
if(strcmp(argv[idx], "--service") == 0)
{
- //
- // When running as a service, we need a logger to use for reporting any
- // failures that occur prior to initializing a communicator. After we have
- // a communicator, we can use the configured logger instead. If a logger
- // is defined in InitializationData, we'll use that. Otherwise, we create
- // a temporary event logger.
- //
- // We postpone the initialization of the communicator until serviceMain so
- // that we can incorporate the executable's arguments and the service's
- // arguments into one vector.
- //
- _logger = initData.logger;
- if(!_logger)
- {
- try
- {
- //
- // Use the executable name as the source for the temporary logger.
- //
- string loggerName = _name;
- transform(loggerName.begin(), loggerName.end(), loggerName.begin(), ::tolower);
- string::size_type pos = loggerName.find_last_of("\\/");
- if(pos != string::npos)
- {
- loggerName.erase(0, pos + 1); // Remove leading path.
- }
- pos = loggerName.rfind(".exe");
- if(pos != string::npos)
- {
- loggerName.erase(pos, loggerName.size() - pos); // Remove .exe extension.
- }
-
- _logger = new EventLoggerI(loggerName);
- }
- catch(const IceUtil::Exception& ex)
- {
- ostringstream ostr;
- ostr << ex;
- error("unable to create EventLogger:\n" + ostr.str());
- return EXIT_FAILURE;
- }
- }
+ //
+ // When running as a service, we need a logger to use for reporting any
+ // failures that occur prior to initializing a communicator. After we have
+ // a communicator, we can use the configured logger instead. If a logger
+ // is defined in InitializationData, we'll use that. Otherwise, we create
+ // a temporary event logger.
+ //
+ // We postpone the initialization of the communicator until serviceMain so
+ // that we can incorporate the executable's arguments and the service's
+ // arguments into one vector.
+ //
+ _logger = initData.logger;
+ if(!_logger)
+ {
+ try
+ {
+ //
+ // Use the executable name as the source for the temporary logger.
+ //
+ string loggerName = _name;
+ transform(loggerName.begin(), loggerName.end(), loggerName.begin(), ::tolower);
+ string::size_type pos = loggerName.find_last_of("\\/");
+ if(pos != string::npos)
+ {
+ loggerName.erase(0, pos + 1); // Remove leading path.
+ }
+ pos = loggerName.rfind(".exe");
+ if(pos != string::npos)
+ {
+ loggerName.erase(pos, loggerName.size() - pos); // Remove .exe extension.
+ }
+
+ _logger = new EventLoggerI(loggerName);
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ ostringstream ostr;
+ ostr << ex;
+ error("unable to create EventLogger:\n" + ostr.str());
+ return EXIT_FAILURE;
+ }
+ }
if(idx + 1 >= argc)
{
@@ -439,17 +439,17 @@ Ice::Service::main(int& argc, char* argv[], const InitializationData& initData)
changeDirectory = false;
}
- else if(strcmp(argv[idx], "--pidfile") == 0)
+ else if(strcmp(argv[idx], "--pidfile") == 0)
{
- if(idx + 1 < argc)
- {
- pidFile = argv[idx + 1];
- }
- else
- {
- cerr << argv[0] << ": --pidfile must be followed by an argument" << endl;
- return EXIT_FAILURE;
- }
+ if(idx + 1 < argc)
+ {
+ pidFile = argv[idx + 1];
+ }
+ else
+ {
+ cerr << argv[0] << ": --pidfile must be followed by an argument" << endl;
+ return EXIT_FAILURE;
+ }
for(int i = idx; i + 2 < argc; ++i)
{
@@ -835,8 +835,8 @@ Ice::Service::startService(const string& name, const vector<string>& args)
}
else
{
- showServiceStatus("Service failed to start.", status);
- return EXIT_FAILURE;
+ showServiceStatus("Service failed to start.", status);
+ return EXIT_FAILURE;
}
return EXIT_SUCCESS;
@@ -893,8 +893,8 @@ Ice::Service::stopService(const string& name)
}
else
{
- showServiceStatus("Service failed to stop.", status);
- return EXIT_FAILURE;
+ showServiceStatus("Service failed to stop.", status);
+ return EXIT_FAILURE;
}
return EXIT_SUCCESS;
@@ -1137,11 +1137,11 @@ Ice::Service::terminateService(DWORD exitCode)
status.dwControlsAccepted = 0;
if(exitCode != 0)
{
- status.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR;
+ status.dwWin32ExitCode = ERROR_SERVICE_SPECIFIC_ERROR;
}
else
{
- status.dwWin32ExitCode = 0;
+ status.dwWin32ExitCode = 0;
}
status.dwServiceSpecificExitCode = exitCode;
status.dwCheckPoint = 0;
@@ -1155,7 +1155,7 @@ Ice::Service::waitForServiceState(SC_HANDLE hService, DWORD pendingState, SERVIC
{
if(!QueryServiceStatus(hService, &status))
{
- return false;
+ return false;
}
//
@@ -1226,38 +1226,38 @@ Ice::Service::showServiceStatus(const string& msg, SERVICE_STATUS& status)
switch(status.dwCurrentState)
{
case SERVICE_STOPPED:
- state = "STOPPED";
- break;
+ state = "STOPPED";
+ break;
case SERVICE_START_PENDING:
- state = "START PENDING";
- break;
+ state = "START PENDING";
+ break;
case SERVICE_STOP_PENDING:
- state = "STOP PENDING";
- break;
+ state = "STOP PENDING";
+ break;
case SERVICE_RUNNING:
- state = "RUNNING";
- break;
+ state = "RUNNING";
+ break;
case SERVICE_CONTINUE_PENDING:
- state = "CONTINUE PENDING";
- break;
+ state = "CONTINUE PENDING";
+ break;
case SERVICE_PAUSE_PENDING:
- state = "PAUSE PENDING";
- break;
+ state = "PAUSE PENDING";
+ break;
case SERVICE_PAUSED:
- state = "PAUSED";
- break;
+ state = "PAUSED";
+ break;
default:
- state = "UNKNOWN";
- break;
+ state = "UNKNOWN";
+ break;
}
ostringstream ostr;
ostr << msg << endl
- << " Current state: " << state << endl
- << " Exit code: " << status.dwWin32ExitCode << endl
- << " Service specific exit code: " << status.dwServiceSpecificExitCode << endl
- << " Check point: " << status.dwCheckPoint << endl
- << " Wait hint: " << status.dwWaitHint;
+ << " Current state: " << state << endl
+ << " Exit code: " << status.dwWin32ExitCode << endl
+ << " Service specific exit code: " << status.dwServiceSpecificExitCode << endl
+ << " Check point: " << status.dwCheckPoint << endl
+ << " Wait hint: " << status.dwWaitHint;
trace(ostr.str());
}
@@ -1314,14 +1314,14 @@ Ice::Service::serviceMain(int argc, char* argv[])
ostringstream ostr;
ostr << "exception occurred while initializing a communicator:\n" << ex;
error(ostr.str());
- terminateService(EXIT_FAILURE);
+ terminateService(EXIT_FAILURE);
return;
}
catch(...)
{
delete[] args;
error("unknown exception occurred while initializing a communicator");
- terminateService(EXIT_FAILURE);
+ terminateService(EXIT_FAILURE);
return;
}
@@ -1345,8 +1345,8 @@ Ice::Service::serviceMain(int argc, char* argv[])
//
// Change the current status from START_PENDING to RUNNING.
//
- serviceStatusManager->stopUpdate();
- serviceStatusManager->changeStatus(SERVICE_RUNNING, SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN);
+ serviceStatusManager->stopUpdate();
+ serviceStatusManager->changeStatus(SERVICE_RUNNING, SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN);
//
// Wait for the service to be shut down.
@@ -1396,21 +1396,21 @@ Ice::Service::control(int ctrl)
case SERVICE_CONTROL_SHUTDOWN:
case SERVICE_CONTROL_STOP:
{
- serviceStatusManager->startUpdate(SERVICE_STOP_PENDING);
- shutdown();
- break;
+ serviceStatusManager->startUpdate(SERVICE_STOP_PENDING);
+ shutdown();
+ break;
}
default:
{
- if(ctrl != SERVICE_CONTROL_INTERROGATE)
- {
- ostringstream ostr;
- ostr << "unrecognized service control code " << ctrl;
- error(ostr.str());
- }
+ if(ctrl != SERVICE_CONTROL_INTERROGATE)
+ {
+ ostringstream ostr;
+ ostr << "unrecognized service control code " << ctrl;
+ error(ostr.str());
+ }
- serviceStatusManager->reportStatus();
- break;
+ serviceStatusManager->reportStatus();
+ break;
}
}
}
@@ -1449,20 +1449,20 @@ Ice::ServiceStatusManager::stopUpdate()
IceUtil::ThreadPtr thread;
{
- Lock sync(*this);
+ Lock sync(*this);
- if(_thread)
- {
- _stopped = true;
- notify();
- thread = _thread;
- _thread = 0;
- }
+ if(_thread)
+ {
+ _stopped = true;
+ notify();
+ thread = _thread;
+ _thread = 0;
+ }
}
if(thread)
{
- thread->getThreadControl().join();
+ thread->getThreadControl().join();
}
}
@@ -1581,11 +1581,11 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
break;
}
cerr << argv[0] << ": failure occurred in daemon";
- if(strlen(msg) > 0)
- {
- cerr << ':' << endl << msg;
- }
- cerr << endl;
+ if(strlen(msg) > 0)
+ {
+ cerr << ':' << endl << msg;
+ }
+ cerr << endl;
_exit(EXIT_FAILURE);
}
@@ -1644,7 +1644,7 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
}
}
- vector<int> fdsToClose;
+ vector<int> fdsToClose;
if(_closeFiles)
{
//
@@ -1665,13 +1665,13 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
{
if(fcntl(i, F_GETFL) != -1)
{
- //
- // Don't close the write end of the pipe.
- //
- if(i != fds[1])
- {
- fdsToClose.push_back(i);
- }
+ //
+ // Don't close the write end of the pipe.
+ //
+ if(i != fds[1])
+ {
+ fdsToClose.push_back(i);
+ }
}
}
}
@@ -1694,21 +1694,21 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
{
//
// Close unnecessary file descriptors.
- //
- PropertiesPtr properties = _communicator->getProperties();
- string stdOut = properties->getProperty("Ice.StdOut");
- string stdErr = properties->getProperty("Ice.StdErr");
+ //
+ PropertiesPtr properties = _communicator->getProperties();
+ string stdOut = properties->getProperty("Ice.StdOut");
+ string stdErr = properties->getProperty("Ice.StdErr");
- vector<int>::const_iterator p;
- for(p = fdsToClose.begin(); p != fdsToClose.end(); ++p)
+ vector<int>::const_iterator p;
+ for(p = fdsToClose.begin(); p != fdsToClose.end(); ++p)
{
- //
- // NOTE: Do not close stdout if Ice.StdOut is defined. Likewise for Ice.StdErr.
- //
- if((*p == 1 && !stdOut.empty()) || (*p == 2 && !stdErr.empty()))
- {
- continue;
- }
+ //
+ // NOTE: Do not close stdout if Ice.StdOut is defined. Likewise for Ice.StdErr.
+ //
+ if((*p == 1 && !stdOut.empty()) || (*p == 2 && !stdErr.empty()))
+ {
+ continue;
+ }
close(*p);
}
@@ -1718,31 +1718,31 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
int fd;
fd = open("/dev/null", O_RDWR);
assert(fd == 0);
- if(stdOut.empty())
- {
- fd = dup2(0, 1);
- assert(fd == 1);
- }
- if(stdErr.empty())
- {
- fd = dup2(1, 2);
- assert(fd == 2);
- }
+ if(stdOut.empty())
+ {
+ fd = dup2(0, 1);
+ assert(fd == 1);
+ }
+ if(stdErr.empty())
+ {
+ fd = dup2(1, 2);
+ assert(fd == 2);
+ }
+ }
+
+ //
+ // Write PID
+ //
+ if(_pidFile.size() > 0)
+ {
+ ofstream of(_pidFile.c_str());
+ of << getpid() << endl;
+
+ if(!of)
+ {
+ warning("Could not write PID file " + _pidFile);
+ }
}
-
- //
- // Write PID
- //
- if(_pidFile.size() > 0)
- {
- ofstream of(_pidFile.c_str());
- of << getpid() << endl;
-
- if(!of)
- {
- warning("Could not write PID file " + _pidFile);
- }
- }
//
// Use the configured logger.
diff --git a/cpp/src/Ice/SharedContext.h b/cpp/src/Ice/SharedContext.h
index c44858ffb34..1d551f9d406 100644
--- a/cpp/src/Ice/SharedContext.h
+++ b/cpp/src/Ice/SharedContext.h
@@ -32,13 +32,13 @@ public:
}
SharedContext(const Ice::Context& val) :
- _val(val)
+ _val(val)
{
}
inline const Ice::Context& getValue()
{
- return _val;
+ return _val;
}
private:
diff --git a/cpp/src/Ice/SliceChecksums.cpp b/cpp/src/Ice/SliceChecksums.cpp
index eb44bfa5946..98390369e18 100644
--- a/cpp/src/Ice/SliceChecksums.cpp
+++ b/cpp/src/Ice/SliceChecksums.cpp
@@ -22,8 +22,8 @@ public:
~SliceChecksumDictDestroyer()
{
- delete _sliceChecksums;
- _sliceChecksums = 0;
+ delete _sliceChecksums;
+ _sliceChecksums = 0;
}
};
static SliceChecksumDictDestroyer destroyer;
@@ -34,7 +34,7 @@ Ice::sliceChecksums()
IceUtil::StaticMutex::Lock lock(_mutex);
if(_sliceChecksums == 0)
{
- _sliceChecksums = new SliceChecksumDict();
+ _sliceChecksums = new SliceChecksumDict();
}
return *_sliceChecksums;
}
@@ -44,7 +44,7 @@ IceInternal::SliceChecksumInit::SliceChecksumInit(const char* checksums[])
IceUtil::StaticMutex::Lock lock(_mutex);
if(_sliceChecksums == 0)
{
- _sliceChecksums = new SliceChecksumDict();
+ _sliceChecksums = new SliceChecksumDict();
}
for(int i = 0; checksums[i] != 0; i += 2)
diff --git a/cpp/src/Ice/StringConverter.cpp b/cpp/src/Ice/StringConverter.cpp
index 566bfac4abb..985111f9aa9 100755
--- a/cpp/src/Ice/StringConverter.cpp
+++ b/cpp/src/Ice/StringConverter.cpp
@@ -19,8 +19,8 @@ namespace Ice
Byte*
UnicodeWstringConverter::toUTF8(const wchar_t* sourceStart,
- const wchar_t* sourceEnd,
- UTF8Buffer& buffer) const
+ const wchar_t* sourceEnd,
+ UTF8Buffer& buffer) const
{
//
// The "chunk size" is the maximum of the number of characters in the
@@ -34,27 +34,27 @@ UnicodeWstringConverter::toUTF8(const wchar_t* sourceStart,
ConversionResult result;
while((result =
- convertUTFWstringToUTF8(sourceStart, sourceEnd,
- targetStart, targetEnd, lenientConversion))
- == targetExhausted)
+ convertUTFWstringToUTF8(sourceStart, sourceEnd,
+ targetStart, targetEnd, lenientConversion))
+ == targetExhausted)
{
- targetStart = buffer.getMoreBytes(chunkSize, targetStart);
- targetEnd = targetStart + chunkSize;
+ targetStart = buffer.getMoreBytes(chunkSize, targetStart);
+ targetEnd = targetStart + chunkSize;
}
-
+
switch(result)
{
- case conversionOK:
- break;
- case sourceExhausted:
- throw StringConversionException(__FILE__, __LINE__, "wide string source exhausted");
- case sourceIllegal:
- throw StringConversionException(__FILE__, __LINE__, "wide string source illegal");
- default:
- {
- assert(0);
- throw StringConversionException(__FILE__, __LINE__);
- }
+ case conversionOK:
+ break;
+ case sourceExhausted:
+ throw StringConversionException(__FILE__, __LINE__, "wide string source exhausted");
+ case sourceIllegal:
+ throw StringConversionException(__FILE__, __LINE__, "wide string source illegal");
+ default:
+ {
+ assert(0);
+ throw StringConversionException(__FILE__, __LINE__);
+ }
}
return targetStart;
}
@@ -62,24 +62,24 @@ UnicodeWstringConverter::toUTF8(const wchar_t* sourceStart,
void
UnicodeWstringConverter::fromUTF8(const Byte* sourceStart, const Byte* sourceEnd,
- wstring& target) const
+ wstring& target) const
{
ConversionResult result =
- convertUTF8ToUTFWstring(sourceStart, sourceEnd, target, lenientConversion);
+ convertUTF8ToUTFWstring(sourceStart, sourceEnd, target, lenientConversion);
switch(result)
- {
- case conversionOK:
- break;
- case sourceExhausted:
- throw StringConversionException(__FILE__, __LINE__, "UTF-8 string source exhausted");
- case sourceIllegal:
- throw StringConversionException(__FILE__, __LINE__, "UTF-8 string source illegal");
- default:
- {
- assert(0);
- throw StringConversionException(__FILE__, __LINE__);
- }
+ {
+ case conversionOK:
+ break;
+ case sourceExhausted:
+ throw StringConversionException(__FILE__, __LINE__, "UTF-8 string source exhausted");
+ case sourceIllegal:
+ throw StringConversionException(__FILE__, __LINE__, "UTF-8 string source illegal");
+ default:
+ {
+ assert(0);
+ throw StringConversionException(__FILE__, __LINE__);
+ }
}
}
}
diff --git a/cpp/src/Ice/TcpAcceptor.cpp b/cpp/src/Ice/TcpAcceptor.cpp
index 3a933042bbd..193aefe8175 100644
--- a/cpp/src/Ice/TcpAcceptor.cpp
+++ b/cpp/src/Ice/TcpAcceptor.cpp
@@ -30,8 +30,8 @@ IceInternal::TcpAcceptor::close()
{
if(_traceLevels->network >= 1)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "stopping to accept tcp connections at " << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "stopping to accept tcp connections at " << toString();
}
SOCKET fd = _fd;
@@ -44,18 +44,18 @@ IceInternal::TcpAcceptor::listen()
{
try
{
- doListen(_fd, _backlog);
+ doListen(_fd, _backlog);
}
catch(...)
{
- _fd = INVALID_SOCKET;
- throw;
+ _fd = INVALID_SOCKET;
+ throw;
}
if(_traceLevels->network >= 1)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "accepting tcp connections at " << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "accepting tcp connections at " << toString();
}
}
@@ -67,8 +67,8 @@ IceInternal::TcpAcceptor::accept(int timeout)
if(_traceLevels->network >= 1)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "accepted tcp connection\n" << fdToString(fd);
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "accepted tcp connection\n" << fdToString(fd);
}
return new TcpTransceiver(_instance, fd);
@@ -116,20 +116,20 @@ IceInternal::TcpAcceptor::TcpAcceptor(const InstancePtr& instance, const string&
try
{
- _fd = createSocket(false);
- setBlock(_fd, false);
- getAddress(host, port, _addr);
- if(_traceLevels->network >= 2)
- {
- Trace out(_logger, _traceLevels->networkCat);
- out << "attempting to bind to tcp socket " << toString();
- }
- doBind(_fd, _addr);
+ _fd = createSocket(false);
+ setBlock(_fd, false);
+ getAddress(host, port, _addr);
+ if(_traceLevels->network >= 2)
+ {
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "attempting to bind to tcp socket " << toString();
+ }
+ doBind(_fd, _addr);
}
catch(...)
{
- _fd = INVALID_SOCKET;
- throw;
+ _fd = INVALID_SOCKET;
+ throw;
}
}
diff --git a/cpp/src/Ice/TcpConnector.cpp b/cpp/src/Ice/TcpConnector.cpp
index 22ca94ab15d..935aaa9a84a 100644
--- a/cpp/src/Ice/TcpConnector.cpp
+++ b/cpp/src/Ice/TcpConnector.cpp
@@ -24,8 +24,8 @@ IceInternal::TcpConnector::connect(int timeout)
{
if(_traceLevels->network >= 2)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "trying to establish tcp connection to " << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "trying to establish tcp connection to " << toString();
}
SOCKET fd = createSocket(false);
@@ -34,8 +34,8 @@ IceInternal::TcpConnector::connect(int timeout)
if(_traceLevels->network >= 1)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "tcp connection established\n" << fdToString(fd);
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "tcp connection established\n" << fdToString(fd);
}
return new TcpTransceiver(_instance, fd);
diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp
index 817008a0141..6cf54872826 100644
--- a/cpp/src/Ice/TcpEndpointI.cpp
+++ b/cpp/src/Ice/TcpEndpointI.cpp
@@ -22,7 +22,7 @@ using namespace Ice;
using namespace IceInternal;
IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const string& ho, Int po, Int ti,
- const string& conId, bool co, bool pub) :
+ const string& conId, bool co, bool pub) :
_instance(instance),
_host(ho),
_port(po),
@@ -47,96 +47,96 @@ IceInternal::TcpEndpointI::TcpEndpointI(const InstancePtr& instance, const strin
while(true)
{
- beg = str.find_first_not_of(delim, end);
- if(beg == string::npos)
- {
- break;
- }
-
- end = str.find_first_of(delim, beg);
- if(end == string::npos)
- {
- end = str.length();
- }
-
- string option = str.substr(beg, end - beg);
- if(option.length() != 2 || option[0] != '-')
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
- throw ex;
- }
-
- string argument;
- string::size_type argumentBeg = str.find_first_not_of(delim, end);
- if(argumentBeg != string::npos && str[argumentBeg] != '-')
- {
- beg = argumentBeg;
- end = str.find_first_of(delim, beg);
- if(end == string::npos)
- {
- end = str.length();
- }
- argument = str.substr(beg, end - beg);
- }
-
- switch(option[1])
- {
- case 'h':
- {
- if(argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
- throw ex;
- }
- const_cast<string&>(_host) = argument;
- break;
- }
-
- case 'p':
- {
- istringstream p(argument);
- if(!(p >> const_cast<Int&>(_port)) || !p.eof() || _port < 0 || _port > 65535)
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
- throw ex;
- }
- break;
- }
-
- case 't':
- {
- istringstream t(argument);
- if(!(t >> const_cast<Int&>(_timeout)) || !t.eof())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
- throw ex;
- }
- break;
- }
-
- case 'z':
- {
- if(!argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
- throw ex;
- }
- const_cast<bool&>(_compress) = true;
- break;
- }
-
- default:
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "tcp " + str;
- throw ex;
- }
- }
+ beg = str.find_first_not_of(delim, end);
+ if(beg == string::npos)
+ {
+ break;
+ }
+
+ end = str.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ end = str.length();
+ }
+
+ string option = str.substr(beg, end - beg);
+ if(option.length() != 2 || option[0] != '-')
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "tcp " + str;
+ throw ex;
+ }
+
+ string argument;
+ string::size_type argumentBeg = str.find_first_not_of(delim, end);
+ if(argumentBeg != string::npos && str[argumentBeg] != '-')
+ {
+ beg = argumentBeg;
+ end = str.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ end = str.length();
+ }
+ argument = str.substr(beg, end - beg);
+ }
+
+ switch(option[1])
+ {
+ case 'h':
+ {
+ if(argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "tcp " + str;
+ throw ex;
+ }
+ const_cast<string&>(_host) = argument;
+ break;
+ }
+
+ case 'p':
+ {
+ istringstream p(argument);
+ if(!(p >> const_cast<Int&>(_port)) || !p.eof() || _port < 0 || _port > 65535)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "tcp " + str;
+ throw ex;
+ }
+ break;
+ }
+
+ case 't':
+ {
+ istringstream t(argument);
+ if(!(t >> const_cast<Int&>(_timeout)) || !t.eof())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "tcp " + str;
+ throw ex;
+ }
+ break;
+ }
+
+ case 'z':
+ {
+ if(!argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "tcp " + str;
+ throw ex;
+ }
+ const_cast<bool&>(_compress) = true;
+ break;
+ }
+
+ default:
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "tcp " + str;
+ throw ex;
+ }
+ }
}
}
@@ -181,11 +181,11 @@ IceInternal::TcpEndpointI::toString() const
s << "tcp -h " << _host << " -p " << _port;
if(_timeout != -1)
{
- s << " -t " << _timeout;
+ s << " -t " << _timeout;
}
if(_compress)
{
- s << " -z";
+ s << " -z";
}
return s.str();
}
@@ -207,11 +207,11 @@ IceInternal::TcpEndpointI::timeout(Int timeout) const
{
if(timeout == _timeout)
{
- return const_cast<TcpEndpointI*>(this);
+ return const_cast<TcpEndpointI*>(this);
}
else
{
- return new TcpEndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _publish);
+ return new TcpEndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _publish);
}
}
@@ -220,11 +220,11 @@ IceInternal::TcpEndpointI::connectionId(const string& connectionId) const
{
if(connectionId == _connectionId)
{
- return const_cast<TcpEndpointI*>(this);
+ return const_cast<TcpEndpointI*>(this);
}
else
{
- return new TcpEndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _publish);
+ return new TcpEndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _publish);
}
}
@@ -239,11 +239,11 @@ IceInternal::TcpEndpointI::compress(bool compress) const
{
if(compress == _compress)
{
- return const_cast<TcpEndpointI*>(this);
+ return const_cast<TcpEndpointI*>(this);
}
else
{
- return new TcpEndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _publish);
+ return new TcpEndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _publish);
}
}
@@ -297,18 +297,18 @@ IceInternal::TcpEndpointI::expand(bool server) const
{
if(_host.empty())
{
- const_cast<string&>(_host) = _instance->defaultsAndOverrides()->defaultHost;
- if(_host.empty())
- {
- if(server)
- {
- const_cast<string&>(_host) = "0.0.0.0";
- }
- else
- {
- const_cast<string&>(_host) = "127.0.0.1";
- }
- }
+ const_cast<string&>(_host) = _instance->defaultsAndOverrides()->defaultHost;
+ if(_host.empty())
+ {
+ if(server)
+ {
+ const_cast<string&>(_host) = "0.0.0.0";
+ }
+ else
+ {
+ const_cast<string&>(_host) = "127.0.0.1";
+ }
+ }
}
else if(_host == "*")
{
@@ -319,11 +319,11 @@ IceInternal::TcpEndpointI::expand(bool server) const
if(_host == "0.0.0.0")
{
vector<string> hosts = getLocalHosts();
- for(unsigned int i = 0; i < hosts.size(); ++i)
- {
- endps.push_back(new TcpEndpointI(_instance, hosts[i], _port, _timeout, _connectionId, _compress,
- hosts.size() == 1 || hosts[i] != "127.0.0.1"));
- }
+ for(unsigned int i = 0; i < hosts.size(); ++i)
+ {
+ endps.push_back(new TcpEndpointI(_instance, hosts[i], _port, _timeout, _connectionId, _compress,
+ hosts.size() == 1 || hosts[i] != "127.0.0.1"));
+ }
}
else
{
@@ -350,7 +350,7 @@ IceInternal::TcpEndpointI::equivalent(const AcceptorPtr& acceptor) const
const TcpAcceptor* tcpAcceptor = dynamic_cast<const TcpAcceptor*>(acceptor.get());
if(!tcpAcceptor)
{
- return false;
+ return false;
}
return tcpAcceptor->equivalent(_host, _port);
}
@@ -361,52 +361,52 @@ IceInternal::TcpEndpointI::operator==(const EndpointI& r) const
const TcpEndpointI* p = dynamic_cast<const TcpEndpointI*>(&r);
if(!p)
{
- return false;
+ return false;
}
if(this == p)
{
- return true;
+ return true;
}
if(_port != p->_port)
{
- return false;
+ return false;
}
if(_timeout != p->_timeout)
{
- return false;
+ return false;
}
if(_connectionId != p->_connectionId)
{
- return false;
+ return false;
}
if(_compress != p->_compress)
{
- return false;
+ return false;
}
if(_host != p->_host)
{
- //
- // We do the most time-consuming part of the comparison last.
- //
- struct sockaddr_in laddr;
- struct sockaddr_in raddr;
- try
- {
- getAddress(_host, _port, laddr);
- getAddress(p->_host, p->_port, raddr);
- }
- catch(const DNSException&)
- {
- return false;
- }
+ //
+ // We do the most time-consuming part of the comparison last.
+ //
+ struct sockaddr_in laddr;
+ struct sockaddr_in raddr;
+ try
+ {
+ getAddress(_host, _port, laddr);
+ getAddress(p->_host, p->_port, raddr);
+ }
+ catch(const DNSException&)
+ {
+ return false;
+ }
- return compareAddress(laddr, raddr);
+ return compareAddress(laddr, raddr);
}
return true;
@@ -429,76 +429,76 @@ IceInternal::TcpEndpointI::operator<(const EndpointI& r) const
if(this == p)
{
- return false;
+ return false;
}
if(_port < p->_port)
{
- return true;
+ return true;
}
else if(p->_port < _port)
{
- return false;
+ return false;
}
if(_timeout < p->_timeout)
{
- return true;
+ return true;
}
else if(p->_timeout < _timeout)
{
- return false;
+ return false;
}
if(_connectionId < p->_connectionId)
{
- return true;
+ return true;
}
else if(p->_connectionId < _connectionId)
{
- return false;
+ return false;
}
if(!_compress && p->_compress)
{
- return true;
+ return true;
}
else if(p->_compress < _compress)
{
- return false;
+ return false;
}
if(_host != p->_host)
{
- //
- // We do the most time-consuming part of the comparison last.
- //
- struct sockaddr_in laddr;
- try
- {
- getAddress(_host, _port, laddr);
- }
- catch(const DNSException&)
- {
- }
-
- struct sockaddr_in raddr;
- try
- {
- getAddress(p->_host, p->_port, raddr);
- }
- catch(const DNSException&)
- {
- }
-
- if(laddr.sin_addr.s_addr < raddr.sin_addr.s_addr)
- {
- return true;
- }
- else if(raddr.sin_addr.s_addr < laddr.sin_addr.s_addr)
- {
- return false;
- }
+ //
+ // We do the most time-consuming part of the comparison last.
+ //
+ struct sockaddr_in laddr;
+ try
+ {
+ getAddress(_host, _port, laddr);
+ }
+ catch(const DNSException&)
+ {
+ }
+
+ struct sockaddr_in raddr;
+ try
+ {
+ getAddress(p->_host, p->_port, raddr);
+ }
+ catch(const DNSException&)
+ {
+ }
+
+ if(laddr.sin_addr.s_addr < raddr.sin_addr.s_addr)
+ {
+ return true;
+ }
+ else if(raddr.sin_addr.s_addr < laddr.sin_addr.s_addr)
+ {
+ return false;
+ }
}
return false;
diff --git a/cpp/src/Ice/TcpTransceiver.cpp b/cpp/src/Ice/TcpTransceiver.cpp
index 4eb5f54fa02..541843223b7 100644
--- a/cpp/src/Ice/TcpTransceiver.cpp
+++ b/cpp/src/Ice/TcpTransceiver.cpp
@@ -32,20 +32,20 @@ IceInternal::TcpTransceiver::close()
{
if(_traceLevels->network >= 1)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "closing tcp connection\n" << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "closing tcp connection\n" << toString();
}
assert(_fd != INVALID_SOCKET);
try
{
- closeSocket(_fd);
- _fd = INVALID_SOCKET;
+ closeSocket(_fd);
+ _fd = INVALID_SOCKET;
}
catch(const SocketException&)
{
- _fd = INVALID_SOCKET;
- throw;
+ _fd = INVALID_SOCKET;
+ throw;
}
}
@@ -54,8 +54,8 @@ IceInternal::TcpTransceiver::shutdownWrite()
{
if(_traceLevels->network >= 2)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "shutting down tcp connection for writing\n" << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "shutting down tcp connection for writing\n" << toString();
}
assert(_fd != INVALID_SOCKET);
@@ -67,8 +67,8 @@ IceInternal::TcpTransceiver::shutdownReadWrite()
{
if(_traceLevels->network >= 2)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "shutting down tcp connection for reading and writing\n" << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "shutting down tcp connection for reading and writing\n" << toString();
}
assert(_fd != INVALID_SOCKET);
@@ -87,112 +87,112 @@ IceInternal::TcpTransceiver::write(Buffer& buf, int timeout)
//
if(_isPeerLocal && packetSize > 64 * 1024)
{
- packetSize = 64 * 1024;
+ packetSize = 64 * 1024;
}
#endif
while(buf.i != buf.b.end())
{
- assert(_fd != INVALID_SOCKET);
- ssize_t ret = ::send(_fd, reinterpret_cast<const char*>(&*buf.i), packetSize, 0);
-
- if(ret == 0)
- {
- ConnectionLostException ex(__FILE__, __LINE__);
- ex.error = 0;
- throw ex;
- }
-
- if(ret == SOCKET_ERROR)
- {
- if(interrupted())
- {
- continue;
- }
-
- if(noBuffers() && packetSize > 1024)
- {
- packetSize /= 2;
- continue;
- }
-
- if(wouldBlock())
- {
- repeatSelect:
-
- int rs;
- assert(_fd != INVALID_SOCKET);
+ assert(_fd != INVALID_SOCKET);
+ ssize_t ret = ::send(_fd, reinterpret_cast<const char*>(&*buf.i), packetSize, 0);
+
+ if(ret == 0)
+ {
+ ConnectionLostException ex(__FILE__, __LINE__);
+ ex.error = 0;
+ throw ex;
+ }
+
+ if(ret == SOCKET_ERROR)
+ {
+ if(interrupted())
+ {
+ continue;
+ }
+
+ if(noBuffers() && packetSize > 1024)
+ {
+ packetSize /= 2;
+ continue;
+ }
+
+ if(wouldBlock())
+ {
+ repeatSelect:
+
+ int rs;
+ assert(_fd != INVALID_SOCKET);
#ifdef _WIN32
- FD_SET(_fd, &_wFdSet);
-
- if(timeout >= 0)
- {
- struct timeval tv;
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000;
- rs = ::select(static_cast<int>(_fd + 1), 0, &_wFdSet, 0, &tv);
- }
- else
- {
- rs = ::select(static_cast<int>(_fd + 1), 0, &_wFdSet, 0, 0);
- }
+ FD_SET(_fd, &_wFdSet);
+
+ if(timeout >= 0)
+ {
+ struct timeval tv;
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000;
+ rs = ::select(static_cast<int>(_fd + 1), 0, &_wFdSet, 0, &tv);
+ }
+ else
+ {
+ rs = ::select(static_cast<int>(_fd + 1), 0, &_wFdSet, 0, 0);
+ }
#else
- struct pollfd pollFd[1];
- pollFd[0].fd = _fd;
- pollFd[0].events = POLLOUT;
- rs = ::poll(pollFd, 1, timeout);
-#endif
- if(rs == SOCKET_ERROR)
- {
- if(interrupted())
- {
- goto repeatSelect;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
-
- if(rs == 0)
- {
- throw TimeoutException(__FILE__, __LINE__);
- }
-
- continue;
- }
-
- if(connectionLost())
- {
- ConnectionLostException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- else
- {
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- }
-
- if(_traceLevels->network >= 3)
- {
- Trace out(_logger, _traceLevels->networkCat);
- out << "sent " << ret << " of " << packetSize << " bytes via tcp\n" << toString();
- }
-
- if(_stats)
- {
- _stats->bytesSent(type(), static_cast<Int>(ret));
- }
-
- buf.i += ret;
-
- if(packetSize > buf.b.end() - buf.i)
- {
- packetSize = static_cast<int>(buf.b.end() - buf.i);
- }
+ struct pollfd pollFd[1];
+ pollFd[0].fd = _fd;
+ pollFd[0].events = POLLOUT;
+ rs = ::poll(pollFd, 1, timeout);
+#endif
+ if(rs == SOCKET_ERROR)
+ {
+ if(interrupted())
+ {
+ goto repeatSelect;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+
+ if(rs == 0)
+ {
+ throw TimeoutException(__FILE__, __LINE__);
+ }
+
+ continue;
+ }
+
+ if(connectionLost())
+ {
+ ConnectionLostException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ else
+ {
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ }
+
+ if(_traceLevels->network >= 3)
+ {
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "sent " << ret << " of " << packetSize << " bytes via tcp\n" << toString();
+ }
+
+ if(_stats)
+ {
+ _stats->bytesSent(type(), static_cast<Int>(ret));
+ }
+
+ buf.i += ret;
+
+ if(packetSize > buf.b.end() - buf.i)
+ {
+ packetSize = static_cast<int>(buf.b.end() - buf.i);
+ }
}
}
@@ -204,125 +204,125 @@ IceInternal::TcpTransceiver::read(Buffer& buf, int timeout)
while(buf.i != buf.b.end())
{
- assert(_fd != INVALID_SOCKET);
- ssize_t ret = ::recv(_fd, reinterpret_cast<char*>(&*buf.i), packetSize, 0);
-
- if(ret == 0)
- {
- //
- // If the connection is lost when reading data, we shut
- // down the write end of the socket. This helps to unblock
- // threads that are stuck in send() or select() while
- // sending data. Note: I don't really understand why
- // send() or select() sometimes don't detect a connection
- // loss. Therefore this helper to make them detect it.
- //
- //assert(_fd != INVALID_SOCKET);
- //shutdownSocketReadWrite(_fd);
-
- ConnectionLostException ex(__FILE__, __LINE__);
- ex.error = 0;
- throw ex;
- }
-
- if(ret == SOCKET_ERROR)
- {
- if(interrupted())
- {
- continue;
- }
-
- if(noBuffers() && packetSize > 1024)
- {
- packetSize /= 2;
- continue;
- }
-
- if(wouldBlock())
- {
- repeatSelect:
-
- int rs;
- assert(_fd != INVALID_SOCKET);
+ assert(_fd != INVALID_SOCKET);
+ ssize_t ret = ::recv(_fd, reinterpret_cast<char*>(&*buf.i), packetSize, 0);
+
+ if(ret == 0)
+ {
+ //
+ // If the connection is lost when reading data, we shut
+ // down the write end of the socket. This helps to unblock
+ // threads that are stuck in send() or select() while
+ // sending data. Note: I don't really understand why
+ // send() or select() sometimes don't detect a connection
+ // loss. Therefore this helper to make them detect it.
+ //
+ //assert(_fd != INVALID_SOCKET);
+ //shutdownSocketReadWrite(_fd);
+
+ ConnectionLostException ex(__FILE__, __LINE__);
+ ex.error = 0;
+ throw ex;
+ }
+
+ if(ret == SOCKET_ERROR)
+ {
+ if(interrupted())
+ {
+ continue;
+ }
+
+ if(noBuffers() && packetSize > 1024)
+ {
+ packetSize /= 2;
+ continue;
+ }
+
+ if(wouldBlock())
+ {
+ repeatSelect:
+
+ int rs;
+ assert(_fd != INVALID_SOCKET);
#ifdef _WIN32
- FD_SET(_fd, &_rFdSet);
-
- if(timeout >= 0)
- {
- struct timeval tv;
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000;
- rs = ::select(static_cast<int>(_fd + 1), &_rFdSet, 0, 0, &tv);
- }
- else
- {
- rs = ::select(static_cast<int>(_fd + 1), &_rFdSet, 0, 0, 0);
- }
+ FD_SET(_fd, &_rFdSet);
+
+ if(timeout >= 0)
+ {
+ struct timeval tv;
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000;
+ rs = ::select(static_cast<int>(_fd + 1), &_rFdSet, 0, 0, &tv);
+ }
+ else
+ {
+ rs = ::select(static_cast<int>(_fd + 1), &_rFdSet, 0, 0, 0);
+ }
#else
- struct pollfd pollFd[1];
- pollFd[0].fd = _fd;
- pollFd[0].events = POLLIN;
- rs = ::poll(pollFd, 1, timeout);
+ struct pollfd pollFd[1];
+ pollFd[0].fd = _fd;
+ pollFd[0].events = POLLIN;
+ rs = ::poll(pollFd, 1, timeout);
#endif
- if(rs == SOCKET_ERROR)
- {
- if(interrupted())
- {
- goto repeatSelect;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
-
- if(rs == 0)
- {
- throw TimeoutException(__FILE__, __LINE__);
- }
-
- continue;
- }
-
- if(connectionLost())
- {
- //
- // See the commment above about shutting down the
- // socket if the connection is lost while reading
- // data.
- //
- //assert(_fd != INVALID_SOCKET);
- //shutdownSocketReadWrite(_fd);
-
- ConnectionLostException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- else
- {
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
- }
-
- if(_traceLevels->network >= 3)
- {
- Trace out(_logger, _traceLevels->networkCat);
- out << "received " << ret << " of " << packetSize << " bytes via tcp\n" << toString();
- }
-
- if(_stats)
- {
- _stats->bytesReceived(type(), static_cast<Int>(ret));
- }
-
- buf.i += ret;
-
- if(packetSize > buf.b.end() - buf.i)
- {
- packetSize = static_cast<int>(buf.b.end() - buf.i);
- }
+ if(rs == SOCKET_ERROR)
+ {
+ if(interrupted())
+ {
+ goto repeatSelect;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+
+ if(rs == 0)
+ {
+ throw TimeoutException(__FILE__, __LINE__);
+ }
+
+ continue;
+ }
+
+ if(connectionLost())
+ {
+ //
+ // See the commment above about shutting down the
+ // socket if the connection is lost while reading
+ // data.
+ //
+ //assert(_fd != INVALID_SOCKET);
+ //shutdownSocketReadWrite(_fd);
+
+ ConnectionLostException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ else
+ {
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+ }
+
+ if(_traceLevels->network >= 3)
+ {
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "received " << ret << " of " << packetSize << " bytes via tcp\n" << toString();
+ }
+
+ if(_stats)
+ {
+ _stats->bytesReceived(type(), static_cast<Int>(ret));
+ }
+
+ buf.i += ret;
+
+ if(packetSize > buf.b.end() - buf.i)
+ {
+ packetSize = static_cast<int>(buf.b.end() - buf.i);
+ }
}
}
@@ -348,7 +348,7 @@ IceInternal::TcpTransceiver::checkSendSize(const Buffer& buf, size_t messageSize
{
if(buf.b.size() > messageSizeMax)
{
- throw MemoryLimitException(__FILE__, __LINE__);
+ throw MemoryLimitException(__FILE__, __LINE__);
}
}
diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp
index 87b315b9cba..6e122f575f0 100644
--- a/cpp/src/Ice/ThreadPool.cpp
+++ b/cpp/src/Ice/ThreadPool.cpp
@@ -61,9 +61,9 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p
_epollFd = epoll_create(1);
if(_epollFd < 0)
{
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
_events.resize(1);
epoll_event event;
@@ -71,9 +71,9 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p
event.data.fd = _fdIntrRead;
if(epoll_ctl(_epollFd, EPOLL_CTL_ADD, _fdIntrRead, &event) != 0)
{
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
#else
_pollFdSet.resize(1);
@@ -90,8 +90,8 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p
if(size < 1)
{
Warning out(_instance->initializationData().logger);
- out << _prefix << ".Size < 1; Size adjusted to 1";
- size = 1;
+ out << _prefix << ".Size < 1; Size adjusted to 1";
+ size = 1;
}
int sizeMax =
@@ -99,17 +99,17 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p
if(sizeMax < size)
{
Warning out(_instance->initializationData().logger);
- out << _prefix << ".SizeMax < " << _prefix << ".Size; SizeMax adjusted to Size (" << size << ")";
- sizeMax = size;
- }
+ out << _prefix << ".SizeMax < " << _prefix << ".Size; SizeMax adjusted to Size (" << size << ")";
+ sizeMax = size;
+ }
int sizeWarn = _instance->initializationData().properties->
- getPropertyAsIntWithDefault(_prefix + ".SizeWarn", sizeMax * 80 / 100);
+ getPropertyAsIntWithDefault(_prefix + ".SizeWarn", sizeMax * 80 / 100);
if(sizeWarn > sizeMax)
{
- Warning out(_instance->initializationData().logger);
- out << _prefix << ".SizeWarn > " << _prefix << ".SizeMax; adjusted SizeWarn to SizeMax (" << sizeMax << ")";
- sizeWarn = sizeMax;
+ Warning out(_instance->initializationData().logger);
+ out << _prefix << ".SizeWarn > " << _prefix << ".SizeMax; adjusted SizeWarn to SizeMax (" << sizeMax << ")";
+ sizeWarn = sizeMax;
}
const_cast<int&>(_size) = size;
@@ -120,38 +120,38 @@ IceInternal::ThreadPool::ThreadPool(const InstancePtr& instance, const string& p
if(stackSize < 0)
{
Warning out(_instance->initializationData().logger);
- out << _prefix << ".StackSize < 0; Size adjusted to OS default";
- stackSize = 0;
+ out << _prefix << ".StackSize < 0; Size adjusted to OS default";
+ stackSize = 0;
}
const_cast<size_t&>(_stackSize) = static_cast<size_t>(stackSize);
__setNoDelete(true);
try
{
- for(int i = 0 ; i < _size ; ++i)
- {
- IceUtil::ThreadPtr thread = new EventHandlerThread(this);
- thread->start(_stackSize);
- _threads.push_back(thread);
- ++_running;
- }
+ for(int i = 0 ; i < _size ; ++i)
+ {
+ IceUtil::ThreadPtr thread = new EventHandlerThread(this);
+ thread->start(_stackSize);
+ _threads.push_back(thread);
+ ++_running;
+ }
}
catch(const IceUtil::Exception& ex)
{
- {
- Error out(_instance->initializationData().logger);
- out << "cannot create thread for `" << _prefix << "':\n" << ex;
- }
+ {
+ Error out(_instance->initializationData().logger);
+ out << "cannot create thread for `" << _prefix << "':\n" << ex;
+ }
- destroy();
- joinWithAllThreads();
- __setNoDelete(false);
- throw;
+ destroy();
+ joinWithAllThreads();
+ __setNoDelete(false);
+ throw;
}
catch(...)
{
- __setNoDelete(false);
- throw;
+ __setNoDelete(false);
+ throw;
}
__setNoDelete(false);
}
@@ -162,33 +162,33 @@ IceInternal::ThreadPool::~ThreadPool()
try
{
- closeSocket(_fdIntrWrite);
+ closeSocket(_fdIntrWrite);
}
catch(const LocalException& ex)
{
- Error out(_instance->initializationData().logger);
- out << "exception in `" << _prefix << "' while calling closeSocket():\n" << ex;
+ Error out(_instance->initializationData().logger);
+ out << "exception in `" << _prefix << "' while calling closeSocket():\n" << ex;
}
try
{
- closeSocket(_fdIntrRead);
+ closeSocket(_fdIntrRead);
}
catch(const LocalException& ex)
{
- Error out(_instance->initializationData().logger);
- out << "exception in `" << _prefix << "' while calling closeSocket():\n" << ex;
+ Error out(_instance->initializationData().logger);
+ out << "exception in `" << _prefix << "' while calling closeSocket():\n" << ex;
}
#ifdef __linux
try
{
- closeSocket(_epollFd);
+ closeSocket(_epollFd);
}
catch(const LocalException& ex)
{
- Error out(_instance->initializationData().logger);
- out << "exception in `" << _prefix << "' while calling closeSocket():\n" << ex;
+ Error out(_instance->initializationData().logger);
+ out << "exception in `" << _prefix << "' while calling closeSocket():\n" << ex;
}
#endif
}
@@ -214,15 +214,15 @@ IceInternal::ThreadPool::incFdsInUse()
assert(!_destroyed);
if(_fdsInUse + 1 > FD_SETSIZE)
{
- Warning warn(_instance->initializationData().logger);
- warn << "maximum number of connections exceeded";
+ Warning warn(_instance->initializationData().logger);
+ warn << "maximum number of connections exceeded";
- //
- // No appropriate errno.
- //
- SocketException ex(__FILE__, __LINE__);
- ex.error = 0;
- throw ex;
+ //
+ // No appropriate errno.
+ //
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = 0;
+ throw ex;
}
++_fdsInUse;
#endif
@@ -238,8 +238,8 @@ IceInternal::ThreadPool::decFdsInUse()
assert(!_destroyed);
if(_fdsInUse <= 1)
{
- Trace trace(_instance->initializationData().logger, "ThreadPool");
- trace << _prefix << ": about to assert";
+ Trace trace(_instance->initializationData().logger, "ThreadPool");
+ trace << _prefix << ": about to assert";
}
assert(_fdsInUse > 1); // _fdIntrRead is always in use.
--_fdsInUse;
@@ -269,41 +269,41 @@ IceInternal::ThreadPool::promoteFollower()
{
if(_sizeMax > 1)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- assert(!_promote);
- _promote = true;
- notify();
+ assert(!_promote);
+ _promote = true;
+ notify();
- if(!_destroyed)
- {
- assert(_inUse >= 0);
- ++_inUse;
-
- if(_inUse == _sizeWarn)
- {
- Warning out(_instance->initializationData().logger);
- out << "thread pool `" << _prefix << "' is running low on threads\n"
- << "Size=" << _size << ", " << "SizeMax=" << _sizeMax << ", " << "SizeWarn=" << _sizeWarn;
- }
-
- assert(_inUse <= _running);
- if(_inUse < _sizeMax && _inUse == _running)
- {
- try
- {
- IceUtil::ThreadPtr thread = new EventHandlerThread(this);
- thread->start(_stackSize);
- _threads.push_back(thread);
- ++_running;
- }
- catch(const IceUtil::Exception& ex)
- {
- Error out(_instance->initializationData().logger);
- out << "cannot create thread for `" << _prefix << "':\n" << ex;
- }
- }
- }
+ if(!_destroyed)
+ {
+ assert(_inUse >= 0);
+ ++_inUse;
+
+ if(_inUse == _sizeWarn)
+ {
+ Warning out(_instance->initializationData().logger);
+ out << "thread pool `" << _prefix << "' is running low on threads\n"
+ << "Size=" << _size << ", " << "SizeMax=" << _sizeMax << ", " << "SizeWarn=" << _sizeWarn;
+ }
+
+ assert(_inUse <= _running);
+ if(_inUse < _sizeMax && _inUse == _running)
+ {
+ try
+ {
+ IceUtil::ThreadPtr thread = new EventHandlerThread(this);
+ thread->start(_stackSize);
+ _threads.push_back(thread);
+ ++_running;
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "cannot create thread for `" << _prefix << "':\n" << ex;
+ }
+ }
+ }
}
}
@@ -319,7 +319,7 @@ IceInternal::ThreadPool::joinWithAllThreads()
assert(_destroyed);
for(vector<IceUtil::ThreadPtr>::iterator p = _threads.begin(); p != _threads.end(); ++p)
{
- (*p)->getThreadControl().join();
+ (*p)->getThreadControl().join();
}
}
@@ -339,26 +339,26 @@ repeat:
#ifdef _WIN32
if(::recv(_fdIntrRead, &c, 1, 0) == SOCKET_ERROR)
{
- if(interrupted())
- {
- goto repeat;
- }
+ if(interrupted())
+ {
+ goto repeat;
+ }
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
#else
if(::read(_fdIntrRead, &c, 1) == -1)
{
- if(interrupted())
- {
- goto repeat;
- }
+ if(interrupted())
+ {
+ goto repeat;
+ }
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
#endif
}
@@ -373,26 +373,26 @@ repeat:
#ifdef _WIN32
if(::send(_fdIntrWrite, &c, 1, 0) == SOCKET_ERROR)
{
- if(interrupted())
- {
- goto repeat;
- }
+ if(interrupted())
+ {
+ goto repeat;
+ }
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
#else
if(::write(_fdIntrWrite, &c, 1) == -1)
{
- if(interrupted())
- {
- goto repeat;
- }
+ if(interrupted())
+ {
+ goto repeat;
+ }
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
#endif
}
@@ -404,467 +404,467 @@ IceInternal::ThreadPool::run()
if(_sizeMax > 1)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- while(!_promote)
- {
- wait();
- }
+ while(!_promote)
+ {
+ wait();
+ }
- _promote = false;
+ _promote = false;
}
while(true)
{
- int ret;
+ int ret;
#if defined(_WIN32)
- fd_set fdSet;
- memcpy(&fdSet, &_fdSet, sizeof(fd_set));
- if(_timeout > 0)
- {
- struct timeval tv;
- tv.tv_sec = _timeout;
- tv.tv_usec = 0;
- ret = ::select(static_cast<int>(_maxFd + 1), &fdSet, 0, 0, &tv);
- }
- else
- {
- ret = ::select(static_cast<int>(_maxFd + 1), &fdSet, 0, 0, 0);
- }
+ fd_set fdSet;
+ memcpy(&fdSet, &_fdSet, sizeof(fd_set));
+ if(_timeout > 0)
+ {
+ struct timeval tv;
+ tv.tv_sec = _timeout;
+ tv.tv_usec = 0;
+ ret = ::select(static_cast<int>(_maxFd + 1), &fdSet, 0, 0, &tv);
+ }
+ else
+ {
+ ret = ::select(static_cast<int>(_maxFd + 1), &fdSet, 0, 0, 0);
+ }
#elif defined(__linux)
- ret = epoll_wait(_epollFd, &_events[0], _events.size(), _timeout > 0 ? _timeout * 1000 : -1);
+ ret = epoll_wait(_epollFd, &_events[0], _events.size(), _timeout > 0 ? _timeout * 1000 : -1);
#else
- ret = poll(&_pollFdSet[0], _pollFdSet.size(), _timeout > 0 ? _timeout * 1000 : -1);
+ ret = poll(&_pollFdSet[0], _pollFdSet.size(), _timeout > 0 ? _timeout * 1000 : -1);
#endif
- if(ret == SOCKET_ERROR)
- {
- if(interrupted())
- {
- continue;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- //throw ex;
- Error out(_instance->initializationData().logger);
- out << "exception in `" << _prefix << "':\n" << ex;
- continue;
- }
-
- EventHandlerPtr handler;
- bool finished = false;
- bool shutdown = false;
+ if(ret == SOCKET_ERROR)
+ {
+ if(interrupted())
+ {
+ continue;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ //throw ex;
+ Error out(_instance->initializationData().logger);
+ out << "exception in `" << _prefix << "':\n" << ex;
+ continue;
+ }
+
+ EventHandlerPtr handler;
+ bool finished = false;
+ bool shutdown = false;
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- if(ret == 0) // We initiate a shutdown if there is a thread pool timeout.
- {
- assert(_timeout > 0);
- _timeout = 0;
- shutdown = true;
- }
- else
- {
- bool interrupted = false;
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ if(ret == 0) // We initiate a shutdown if there is a thread pool timeout.
+ {
+ assert(_timeout > 0);
+ _timeout = 0;
+ shutdown = true;
+ }
+ else
+ {
+ bool interrupted = false;
#if defined(_WIN32)
- interrupted = FD_ISSET(_fdIntrRead, &fdSet);
+ interrupted = FD_ISSET(_fdIntrRead, &fdSet);
#elif defined(__linux)
for(int i = 0; i < ret; ++i)
- {
- if(_events[i].data.fd == _fdIntrRead)
- {
- interrupted = true;
- break;
- }
- }
+ {
+ if(_events[i].data.fd == _fdIntrRead)
+ {
+ interrupted = true;
+ break;
+ }
+ }
#else
- assert(_pollFdSet[0].fd == _fdIntrRead);
+ assert(_pollFdSet[0].fd == _fdIntrRead);
interrupted = _pollFdSet[0].revents != 0;
#endif
- if(interrupted)
- {
- //
- // There are two possiblities for an interrupt:
- //
- // 1. The thread pool has been destroyed.
- //
- // 2. An event handler was registered or unregistered.
- //
+ if(interrupted)
+ {
+ //
+ // There are two possiblities for an interrupt:
+ //
+ // 1. The thread pool has been destroyed.
+ //
+ // 2. An event handler was registered or unregistered.
+ //
- //
- // Thread pool destroyed?
- //
- if(_destroyed)
- {
- //
- // Don't clear the interrupt if destroyed, so that
- // the other threads exit as well.
- //
- return true;
- }
-
- clearInterrupt();
-
- //
- // An event handler must have been registered or
- // unregistered.
- //
- assert(!_changes.empty());
- pair<SOCKET, EventHandlerPtr> change = _changes.front();
- _changes.pop_front();
-
- if(change.second) // Addition if handler is set.
- {
- _handlerMap.insert(change);
+ //
+ // Thread pool destroyed?
+ //
+ if(_destroyed)
+ {
+ //
+ // Don't clear the interrupt if destroyed, so that
+ // the other threads exit as well.
+ //
+ return true;
+ }
+
+ clearInterrupt();
+
+ //
+ // An event handler must have been registered or
+ // unregistered.
+ //
+ assert(!_changes.empty());
+ pair<SOCKET, EventHandlerPtr> change = _changes.front();
+ _changes.pop_front();
+
+ if(change.second) // Addition if handler is set.
+ {
+ _handlerMap.insert(change);
#if defined(_WIN32)
- FD_SET(change.first, &_fdSet);
+ FD_SET(change.first, &_fdSet);
#elif defined(__linux)
- epoll_event event;
- event.events = EPOLLIN;
- event.data.fd = change.first;
- if(epoll_ctl(_epollFd, EPOLL_CTL_ADD, change.first, &event) != 0)
- {
- Error out(_instance->initializationData().logger);
- out << "error while adding filedescriptor to epoll set:\n";
- out << errorToString(getSocketErrno());
- continue;
- }
- _events.resize(_handlerMap.size() + 1);
+ epoll_event event;
+ event.events = EPOLLIN;
+ event.data.fd = change.first;
+ if(epoll_ctl(_epollFd, EPOLL_CTL_ADD, change.first, &event) != 0)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "error while adding filedescriptor to epoll set:\n";
+ out << errorToString(getSocketErrno());
+ continue;
+ }
+ _events.resize(_handlerMap.size() + 1);
#else
- struct pollfd pollFd;
- pollFd.fd = change.first;
- pollFd.events = POLLIN;
- _pollFdSet.push_back(pollFd);
+ struct pollfd pollFd;
+ pollFd.fd = change.first;
+ pollFd.events = POLLIN;
+ _pollFdSet.push_back(pollFd);
#endif
- _maxFd = max(_maxFd, change.first);
- _minFd = min(_minFd, change.first);
- continue;
- }
- else // Removal if handler is not set.
- {
- map<SOCKET, EventHandlerPtr>::iterator p = _handlerMap.find(change.first);
- assert(p != _handlerMap.end());
- handler = p->second;
- finished = true;
- _handlerMap.erase(p);
+ _maxFd = max(_maxFd, change.first);
+ _minFd = min(_minFd, change.first);
+ continue;
+ }
+ else // Removal if handler is not set.
+ {
+ map<SOCKET, EventHandlerPtr>::iterator p = _handlerMap.find(change.first);
+ assert(p != _handlerMap.end());
+ handler = p->second;
+ finished = true;
+ _handlerMap.erase(p);
#if defined(_WIN32)
- FD_CLR(change.first, &_fdSet);
+ FD_CLR(change.first, &_fdSet);
#elif defined(__linux)
- epoll_event event;
- event.events = 0;
- if(epoll_ctl(_epollFd, EPOLL_CTL_DEL, change.first, &event) != 0)
- {
- Error out(_instance->initializationData().logger);
- out << "error while adding filedescriptor to epoll set:\n";
- out << errorToString(getSocketErrno());
- continue;
- }
- _events.resize(_handlerMap.size() + 1);
+ epoll_event event;
+ event.events = 0;
+ if(epoll_ctl(_epollFd, EPOLL_CTL_DEL, change.first, &event) != 0)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "error while adding filedescriptor to epoll set:\n";
+ out << errorToString(getSocketErrno());
+ continue;
+ }
+ _events.resize(_handlerMap.size() + 1);
#else
- for(vector<struct pollfd>::iterator p = _pollFdSet.begin(); p != _pollFdSet.end(); ++p)
- {
- if(p->fd == change.first)
- {
- _pollFdSet.erase(p);
- break;
- }
- }
+ for(vector<struct pollfd>::iterator p = _pollFdSet.begin(); p != _pollFdSet.end(); ++p)
+ {
+ if(p->fd == change.first)
+ {
+ _pollFdSet.erase(p);
+ break;
+ }
+ }
#endif
- _maxFd = _fdIntrRead;
- _minFd = _fdIntrRead;
- if(!_handlerMap.empty())
- {
- _maxFd = max(_maxFd, (--_handlerMap.end())->first);
- _minFd = min(_minFd, _handlerMap.begin()->first);
- }
- // Don't continue; we have to call
- // finished() on the event handler below, outside
- // the thread synchronization.
- }
- }
- else
- {
- //
- // Round robin for the filedescriptors.
- //
- SOCKET largerFd = _maxFd + 1;
- SOCKET smallestFd = _maxFd + 1;
+ _maxFd = _fdIntrRead;
+ _minFd = _fdIntrRead;
+ if(!_handlerMap.empty())
+ {
+ _maxFd = max(_maxFd, (--_handlerMap.end())->first);
+ _minFd = min(_minFd, _handlerMap.begin()->first);
+ }
+ // Don't continue; we have to call
+ // finished() on the event handler below, outside
+ // the thread synchronization.
+ }
+ }
+ else
+ {
+ //
+ // Round robin for the filedescriptors.
+ //
+ SOCKET largerFd = _maxFd + 1;
+ SOCKET smallestFd = _maxFd + 1;
#if defined(_WIN32)
- if(fdSet.fd_count == 0)
- {
- Error out(_instance->initializationData().logger);
- out << "select() in `" << _prefix << "' returned " << ret
- << " but no filedescriptor is readable";
- continue;
- }
- for(u_short i = 0; i < fdSet.fd_count; ++i)
- {
- SOCKET fd = fdSet.fd_array[i];
+ if(fdSet.fd_count == 0)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "select() in `" << _prefix << "' returned " << ret
+ << " but no filedescriptor is readable";
+ continue;
+ }
+ for(u_short i = 0; i < fdSet.fd_count; ++i)
+ {
+ SOCKET fd = fdSet.fd_array[i];
#elif defined(__linux)
- for(int i = 0; i < ret; ++i)
- {
- SOCKET fd = _events[i].data.fd;
+ for(int i = 0; i < ret; ++i)
+ {
+ SOCKET fd = _events[i].data.fd;
#else
for(vector<struct pollfd>::const_iterator p = _pollFdSet.begin(); p != _pollFdSet.end(); ++p)
- {
- if(p->revents == 0)
- {
- continue;
- }
- SOCKET fd = p->fd;
+ {
+ if(p->revents == 0)
+ {
+ continue;
+ }
+ SOCKET fd = p->fd;
#endif
- assert(fd != INVALID_SOCKET);
- if(fd > _lastFd || _lastFd == INVALID_SOCKET)
- {
- largerFd = min(largerFd, fd);
- }
-
- smallestFd = min(smallestFd, fd);
- }
-
- if(largerFd <= _maxFd)
- {
- assert(largerFd >= _minFd);
- _lastFd = largerFd;
- }
- else
- {
- assert(smallestFd >= _minFd && smallestFd <= _maxFd);
- _lastFd = smallestFd;
- }
- assert(_lastFd != _fdIntrRead);
- map<SOCKET, EventHandlerPtr>::iterator p = _handlerMap.find(_lastFd);
- if(p == _handlerMap.end())
- {
- Error out(_instance->initializationData().logger);
- out << "filedescriptor " << _lastFd << " not registered with `" << _prefix << "'";
- continue;
- }
-
- handler = p->second;
- }
- }
- }
-
- //
- // Now we are outside the thread synchronization.
- //
+ assert(fd != INVALID_SOCKET);
+ if(fd > _lastFd || _lastFd == INVALID_SOCKET)
+ {
+ largerFd = min(largerFd, fd);
+ }
+
+ smallestFd = min(smallestFd, fd);
+ }
+
+ if(largerFd <= _maxFd)
+ {
+ assert(largerFd >= _minFd);
+ _lastFd = largerFd;
+ }
+ else
+ {
+ assert(smallestFd >= _minFd && smallestFd <= _maxFd);
+ _lastFd = smallestFd;
+ }
+ assert(_lastFd != _fdIntrRead);
+ map<SOCKET, EventHandlerPtr>::iterator p = _handlerMap.find(_lastFd);
+ if(p == _handlerMap.end())
+ {
+ Error out(_instance->initializationData().logger);
+ out << "filedescriptor " << _lastFd << " not registered with `" << _prefix << "'";
+ continue;
+ }
+
+ handler = p->second;
+ }
+ }
+ }
+
+ //
+ // Now we are outside the thread synchronization.
+ //
- if(shutdown)
- {
- //
- // Initiate server shutdown.
- //
- ObjectAdapterFactoryPtr factory;
- try
- {
- factory = _instance->objectAdapterFactory();
- }
- catch(const Ice::CommunicatorDestroyedException&)
- {
- continue;
- }
+ if(shutdown)
+ {
+ //
+ // Initiate server shutdown.
+ //
+ ObjectAdapterFactoryPtr factory;
+ try
+ {
+ factory = _instance->objectAdapterFactory();
+ }
+ catch(const Ice::CommunicatorDestroyedException&)
+ {
+ continue;
+ }
- promoteFollower();
- factory->shutdown();
+ promoteFollower();
+ factory->shutdown();
- //
- // No "continue", because we want shutdown to be done in
- // its own thread from this pool. Therefore we called
- // promoteFollower().
- //
- }
- else
- {
- assert(handler);
-
- if(finished)
- {
- //
- // Notify a handler about it's removal from the thread
- // pool.
- //
- try
- {
- //
- // "self" is faster than "this", as the reference
- // count is not modified.
- //
- handler->finished(self);
- }
- catch(const LocalException& ex)
- {
- Error out(_instance->initializationData().logger);
- out << "exception in `" << _prefix << "' while calling finished():\n"
- << ex << '\n' << handler->toString();
- }
+ //
+ // No "continue", because we want shutdown to be done in
+ // its own thread from this pool. Therefore we called
+ // promoteFollower().
+ //
+ }
+ else
+ {
+ assert(handler);
+
+ if(finished)
+ {
+ //
+ // Notify a handler about it's removal from the thread
+ // pool.
+ //
+ try
+ {
+ //
+ // "self" is faster than "this", as the reference
+ // count is not modified.
+ //
+ handler->finished(self);
+ }
+ catch(const LocalException& ex)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "exception in `" << _prefix << "' while calling finished():\n"
+ << ex << '\n' << handler->toString();
+ }
- //
- // No "continue", because we want finished() to be
- // called in its own thread from this pool. Note that
- // this means that finished() must call
- // promoteFollower().
- //
- }
- else
- {
- //
- // If the handler is "readable", try to read a
- // message.
- //
- BasicStream stream(_instance.get());
- if(handler->readable())
- {
- try
- {
- read(handler);
- }
- catch(const TimeoutException&) // Expected.
- {
- continue;
- }
- catch(const DatagramLimitException&) // Expected.
- {
- continue;
- }
- catch(const SocketException& ex)
- {
- handler->exception(ex);
- continue;
- }
- catch(const LocalException& ex)
- {
- if(handler->datagram())
- {
- if(_instance->initializationData().properties->
- getPropertyAsInt("Ice.Warn.Connections") > 0)
- {
- Warning out(_instance->initializationData().logger);
- out << "datagram connection exception:\n" << ex << '\n' << handler->toString();
- }
- }
- else
- {
- handler->exception(ex);
- }
- continue;
- }
-
- stream.swap(handler->_stream);
- assert(stream.i == stream.b.end());
- }
-
- //
- // Provide a new mesage to the handler.
- //
- try
- {
- //
- // "self" is faster than "this", as the reference
- // count is not modified.
- //
- handler->message(stream, self);
- }
- catch(const LocalException& ex)
- {
- Error out(_instance->initializationData().logger);
- out << "exception in `" << _prefix << "' while calling message():\n"
- << ex << '\n' << handler->toString();
- }
-
- //
- // No "continue", because we want message() to be
- // called in its own thread from this pool. Note that
- // this means that message() must call
- // promoteFollower().
- //
- }
- }
+ //
+ // No "continue", because we want finished() to be
+ // called in its own thread from this pool. Note that
+ // this means that finished() must call
+ // promoteFollower().
+ //
+ }
+ else
+ {
+ //
+ // If the handler is "readable", try to read a
+ // message.
+ //
+ BasicStream stream(_instance.get());
+ if(handler->readable())
+ {
+ try
+ {
+ read(handler);
+ }
+ catch(const TimeoutException&) // Expected.
+ {
+ continue;
+ }
+ catch(const DatagramLimitException&) // Expected.
+ {
+ continue;
+ }
+ catch(const SocketException& ex)
+ {
+ handler->exception(ex);
+ continue;
+ }
+ catch(const LocalException& ex)
+ {
+ if(handler->datagram())
+ {
+ if(_instance->initializationData().properties->
+ getPropertyAsInt("Ice.Warn.Connections") > 0)
+ {
+ Warning out(_instance->initializationData().logger);
+ out << "datagram connection exception:\n" << ex << '\n' << handler->toString();
+ }
+ }
+ else
+ {
+ handler->exception(ex);
+ }
+ continue;
+ }
+
+ stream.swap(handler->_stream);
+ assert(stream.i == stream.b.end());
+ }
+
+ //
+ // Provide a new mesage to the handler.
+ //
+ try
+ {
+ //
+ // "self" is faster than "this", as the reference
+ // count is not modified.
+ //
+ handler->message(stream, self);
+ }
+ catch(const LocalException& ex)
+ {
+ Error out(_instance->initializationData().logger);
+ out << "exception in `" << _prefix << "' while calling message():\n"
+ << ex << '\n' << handler->toString();
+ }
+
+ //
+ // No "continue", because we want message() to be
+ // called in its own thread from this pool. Note that
+ // this means that message() must call
+ // promoteFollower().
+ //
+ }
+ }
- if(_sizeMax > 1)
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- if(!_destroyed)
- {
- //
- // First we reap threads that have been destroyed before.
- //
- int sz = static_cast<int>(_threads.size());
- assert(_running <= sz);
- if(_running < sz)
- {
- vector<IceUtil::ThreadPtr>::iterator start =
- partition(_threads.begin(), _threads.end(), IceUtil::constMemFun(&IceUtil::Thread::isAlive));
+ if(_sizeMax > 1)
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ if(!_destroyed)
+ {
+ //
+ // First we reap threads that have been destroyed before.
+ //
+ int sz = static_cast<int>(_threads.size());
+ assert(_running <= sz);
+ if(_running < sz)
+ {
+ vector<IceUtil::ThreadPtr>::iterator start =
+ partition(_threads.begin(), _threads.end(), IceUtil::constMemFun(&IceUtil::Thread::isAlive));
- for(vector<IceUtil::ThreadPtr>::iterator p = start; p != _threads.end(); ++p)
- {
- (*p)->getThreadControl().join();
- }
+ for(vector<IceUtil::ThreadPtr>::iterator p = start; p != _threads.end(); ++p)
+ {
+ (*p)->getThreadControl().join();
+ }
- _threads.erase(start, _threads.end());
- }
-
- //
- // Now we check if this thread can be destroyed, based
- // on a load factor.
- //
+ _threads.erase(start, _threads.end());
+ }
+
+ //
+ // Now we check if this thread can be destroyed, based
+ // on a load factor.
+ //
- //
- // The load factor jumps immediately to the number of
- // threads that are currently in use, but decays
- // exponentially if the number of threads in use is
- // smaller than the load factor. This reflects that we
- // create threads immediately when they are needed,
- // but want the number of threads to slowly decline to
- // the configured minimum.
- //
- double inUse = static_cast<double>(_inUse);
- if(_load < inUse)
- {
- _load = inUse;
- }
- else
- {
- const double loadFactor = 0.05; // TODO: Configurable?
- const double oneMinusLoadFactor = 1 - loadFactor;
- _load = _load * oneMinusLoadFactor + inUse * loadFactor;
- }
-
- if(_running > _size)
- {
- int load = static_cast<int>(_load + 0.5);
+ //
+ // The load factor jumps immediately to the number of
+ // threads that are currently in use, but decays
+ // exponentially if the number of threads in use is
+ // smaller than the load factor. This reflects that we
+ // create threads immediately when they are needed,
+ // but want the number of threads to slowly decline to
+ // the configured minimum.
+ //
+ double inUse = static_cast<double>(_inUse);
+ if(_load < inUse)
+ {
+ _load = inUse;
+ }
+ else
+ {
+ const double loadFactor = 0.05; // TODO: Configurable?
+ const double oneMinusLoadFactor = 1 - loadFactor;
+ _load = _load * oneMinusLoadFactor + inUse * loadFactor;
+ }
+
+ if(_running > _size)
+ {
+ int load = static_cast<int>(_load + 0.5);
- //
- // We add one to the load factor because on
- // additional thread is needed for select().
- //
- if(load + 1 < _running)
- {
- assert(_inUse > 0);
- --_inUse;
-
- assert(_running > 0);
- --_running;
-
- return false;
- }
- }
-
- assert(_inUse > 0);
- --_inUse;
- }
+ //
+ // We add one to the load factor because on
+ // additional thread is needed for select().
+ //
+ if(load + 1 < _running)
+ {
+ assert(_inUse > 0);
+ --_inUse;
+
+ assert(_running > 0);
+ --_running;
+
+ return false;
+ }
+ }
+
+ assert(_inUse > 0);
+ --_inUse;
+ }
- while(!_promote)
- {
- wait();
- }
-
- _promote = false;
- }
+ while(!_promote)
+ {
+ wait();
+ }
+
+ _promote = false;
+ }
}
}
@@ -875,32 +875,32 @@ IceInternal::ThreadPool::read(const EventHandlerPtr& handler)
if(stream.b.size() == 0)
{
- stream.b.resize(headerSize);
- stream.i = stream.b.begin();
+ stream.b.resize(headerSize);
+ stream.i = stream.b.begin();
}
if(stream.i != stream.b.end())
{
- handler->read(stream);
- assert(stream.i == stream.b.end());
+ handler->read(stream);
+ assert(stream.i == stream.b.end());
}
ptrdiff_t pos = stream.i - stream.b.begin();
if(pos < headerSize)
{
- //
- // This situation is possible for small UDP packets.
- //
- throw IllegalMessageSizeException(__FILE__, __LINE__);
+ //
+ // This situation is possible for small UDP packets.
+ //
+ throw IllegalMessageSizeException(__FILE__, __LINE__);
}
stream.i = stream.b.begin();
const Byte* m;
stream.readBlob(m, static_cast<Int>(sizeof(magic)));
if(m[0] != magic[0] || m[1] != magic[1] || m[2] != magic[2] || m[3] != magic[3])
{
- BadMagicException ex(__FILE__, __LINE__);
- ex.badMagic = Ice::ByteSeq(&m[0], &m[0] + sizeof(magic));
- throw ex;
+ BadMagicException ex(__FILE__, __LINE__);
+ ex.badMagic = Ice::ByteSeq(&m[0], &m[0] + sizeof(magic));
+ throw ex;
}
Byte pMajor;
Byte pMinor;
@@ -909,12 +909,12 @@ IceInternal::ThreadPool::read(const EventHandlerPtr& handler)
if(pMajor != protocolMajor
|| static_cast<unsigned char>(pMinor) > static_cast<unsigned char>(protocolMinor))
{
- UnsupportedProtocolException ex(__FILE__, __LINE__);
- ex.badMajor = static_cast<unsigned char>(pMajor);
- ex.badMinor = static_cast<unsigned char>(pMinor);
- ex.major = static_cast<unsigned char>(protocolMajor);
- ex.minor = static_cast<unsigned char>(protocolMinor);
- throw ex;
+ UnsupportedProtocolException ex(__FILE__, __LINE__);
+ ex.badMajor = static_cast<unsigned char>(pMajor);
+ ex.badMinor = static_cast<unsigned char>(pMinor);
+ ex.major = static_cast<unsigned char>(protocolMajor);
+ ex.minor = static_cast<unsigned char>(protocolMinor);
+ throw ex;
}
Byte eMajor;
Byte eMinor;
@@ -923,12 +923,12 @@ IceInternal::ThreadPool::read(const EventHandlerPtr& handler)
if(eMajor != encodingMajor
|| static_cast<unsigned char>(eMinor) > static_cast<unsigned char>(encodingMinor))
{
- UnsupportedEncodingException ex(__FILE__, __LINE__);
- ex.badMajor = static_cast<unsigned char>(eMajor);
- ex.badMinor = static_cast<unsigned char>(eMinor);
- ex.major = static_cast<unsigned char>(encodingMajor);
- ex.minor = static_cast<unsigned char>(encodingMinor);
- throw ex;
+ UnsupportedEncodingException ex(__FILE__, __LINE__);
+ ex.badMajor = static_cast<unsigned char>(eMajor);
+ ex.badMinor = static_cast<unsigned char>(eMinor);
+ ex.major = static_cast<unsigned char>(encodingMajor);
+ ex.minor = static_cast<unsigned char>(encodingMinor);
+ throw ex;
}
Byte messageType;
stream.read(messageType);
@@ -938,36 +938,36 @@ IceInternal::ThreadPool::read(const EventHandlerPtr& handler)
stream.read(size);
if(size < headerSize)
{
- throw IllegalMessageSizeException(__FILE__, __LINE__);
+ throw IllegalMessageSizeException(__FILE__, __LINE__);
}
if(size > static_cast<Int>(_instance->messageSizeMax()))
{
- throw MemoryLimitException(__FILE__, __LINE__);
+ throw MemoryLimitException(__FILE__, __LINE__);
}
if(size > static_cast<Int>(stream.b.size()))
{
- stream.b.resize(size);
+ stream.b.resize(size);
}
stream.i = stream.b.begin() + pos;
if(stream.i != stream.b.end())
{
- if(handler->datagram())
- {
- if(_warnUdp)
- {
- Warning out(_instance->initializationData().logger);
- out << "DatagramLimitException: maximum size of " << pos << " exceeded";
- stream.resize(0);
- stream.i = stream.b.begin();
- }
- throw DatagramLimitException(__FILE__, __LINE__);
- }
- else
- {
- handler->read(stream);
- assert(stream.i == stream.b.end());
- }
+ if(handler->datagram())
+ {
+ if(_warnUdp)
+ {
+ Warning out(_instance->initializationData().logger);
+ out << "DatagramLimitException: maximum size of " << pos << " exceeded";
+ stream.resize(0);
+ stream.i = stream.b.begin();
+ }
+ throw DatagramLimitException(__FILE__, __LINE__);
+ }
+ else
+ {
+ handler->read(stream);
+ assert(stream.i == stream.b.end());
+ }
}
}
@@ -988,39 +988,39 @@ IceInternal::ThreadPool::EventHandlerThread::run()
try
{
- promote = _pool->run();
+ promote = _pool->run();
}
catch(const Exception& ex)
- {
- Error out(_pool->_instance->initializationData().logger);
- out << "exception in `" << _pool->_prefix << "':\n" << ex;
- promote = true;
+ {
+ Error out(_pool->_instance->initializationData().logger);
+ out << "exception in `" << _pool->_prefix << "':\n" << ex;
+ promote = true;
}
catch(const std::exception& ex)
{
- Error out(_pool->_instance->initializationData().logger);
- out << "std::exception in `" << _pool->_prefix << "':\n" << ex.what();
- promote = true;
+ Error out(_pool->_instance->initializationData().logger);
+ out << "std::exception in `" << _pool->_prefix << "':\n" << ex.what();
+ promote = true;
}
catch(...)
{
- Error out(_pool->_instance->initializationData().logger);
- out << "unknown exception in `" << _pool->_prefix << "'";
- promote = true;
+ Error out(_pool->_instance->initializationData().logger);
+ out << "unknown exception in `" << _pool->_prefix << "'";
+ promote = true;
}
if(promote && _pool->_sizeMax > 1)
{
- //
- // Promote a follower, but w/o modifying _inUse or creating
- // new threads.
- //
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*_pool.get());
- assert(!_pool->_promote);
- _pool->_promote = true;
- _pool->notify();
- }
+ //
+ // Promote a follower, but w/o modifying _inUse or creating
+ // new threads.
+ //
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*_pool.get());
+ assert(!_pool->_promote);
+ _pool->_promote = true;
+ _pool->notify();
+ }
}
if(_pool->_instance->initializationData().threadHook)
diff --git a/cpp/src/Ice/ThreadPool.h b/cpp/src/Ice/ThreadPool.h
index a0ecc923a46..6cda824ee5e 100644
--- a/cpp/src/Ice/ThreadPool.h
+++ b/cpp/src/Ice/ThreadPool.h
@@ -94,13 +94,13 @@ private:
class EventHandlerThread : public IceUtil::Thread
{
public:
-
- EventHandlerThread(const ThreadPoolPtr&);
- virtual void run();
+
+ EventHandlerThread(const ThreadPoolPtr&);
+ virtual void run();
private:
- ThreadPoolPtr _pool;
+ ThreadPoolPtr _pool;
};
friend class EventHandlerThread;
diff --git a/cpp/src/Ice/TraceUtil.cpp b/cpp/src/Ice/TraceUtil.cpp
index 6dfc11c029c..cc89bf153ee 100644
--- a/cpp/src/Ice/TraceUtil.cpp
+++ b/cpp/src/Ice/TraceUtil.cpp
@@ -53,29 +53,29 @@ printRequestHeader(ostream& s, BasicStream& stream)
s << "\nmode = " << static_cast<int>(mode) << ' ';
switch(mode)
{
- case Normal:
- {
- s << "(normal)";
- break;
- }
-
- case Nonmutating:
- {
- s << "(nonmutating)";
- break;
- }
-
- case Idempotent:
- {
- s << "(idempotent)";
- break;
- }
-
- default:
- {
- s << "(unknown)";
- break;
- }
+ case Normal:
+ {
+ s << "(normal)";
+ break;
+ }
+
+ case Nonmutating:
+ {
+ s << "(nonmutating)";
+ break;
+ }
+
+ case Idempotent:
+ {
+ s << "(idempotent)";
+ break;
+ }
+
+ default:
+ {
+ s << "(unknown)";
+ break;
+ }
}
Int sz;
@@ -83,14 +83,14 @@ printRequestHeader(ostream& s, BasicStream& stream)
s << "\ncontext = ";
while(sz--)
{
- pair<string, string> pair;
- stream.read(pair.first);
- stream.read(pair.second);
- s << pair.first << '/' << pair.second;
- if(sz)
- {
- s << ", ";
- }
+ pair<string, string> pair;
+ stream.read(pair.first);
+ stream.read(pair.second);
+ s << pair.first << '/' << pair.second;
+ if(sz)
+ {
+ s << ", ";
+ }
}
}
@@ -98,7 +98,7 @@ static void
printHeader(ostream& s, BasicStream& stream)
{
Byte magicNumber;
- stream.read(magicNumber); // Don't bother printing the magic number
+ stream.read(magicNumber); // Don't bother printing the magic number
stream.read(magicNumber);
stream.read(magicNumber);
stream.read(magicNumber);
@@ -123,41 +123,41 @@ printHeader(ostream& s, BasicStream& stream)
switch(type)
{
- case requestMsg:
- {
- s << "(request)";
- break;
- }
-
- case requestBatchMsg:
- {
- s << "(batch request)";
- break;
- }
-
- case replyMsg:
- {
- s << "(reply)";
- break;
- }
-
- case closeConnectionMsg:
- {
- s << "(close connection)";
- break;
- }
-
- case validateConnectionMsg:
- {
- s << "(validate connection)";
- break;
- }
-
- default:
- {
- s << "(unknown)";
- break;
- }
+ case requestMsg:
+ {
+ s << "(request)";
+ break;
+ }
+
+ case requestBatchMsg:
+ {
+ s << "(batch request)";
+ break;
+ }
+
+ case replyMsg:
+ {
+ s << "(reply)";
+ break;
+ }
+
+ case closeConnectionMsg:
+ {
+ s << "(close connection)";
+ break;
+ }
+
+ case validateConnectionMsg:
+ {
+ s << "(validate connection)";
+ break;
+ }
+
+ default:
+ {
+ s << "(unknown)";
+ break;
+ }
}
Byte compress;
@@ -166,29 +166,29 @@ printHeader(ostream& s, BasicStream& stream)
switch(compress)
{
- case 0:
- {
- s << "(not compressed; do not compress response, if any)";
- break;
- }
-
- case 1:
- {
- s << "(not compressed; compress response, if any)";
- break;
- }
-
- case 2:
- {
- s << "(compressed; compress response, if any)";
- break;
- }
-
- default:
- {
- s << "(unknown)";
- break;
- }
+ case 0:
+ {
+ s << "(not compressed; do not compress response, if any)";
+ break;
+ }
+
+ case 1:
+ {
+ s << "(not compressed; compress response, if any)";
+ break;
+ }
+
+ case 2:
+ {
+ s << "(compressed; compress response, if any)";
+ break;
+ }
+
+ default:
+ {
+ s << "(unknown)";
+ break;
+ }
}
Int size;
@@ -198,198 +198,198 @@ printHeader(ostream& s, BasicStream& stream)
void
IceInternal::traceHeader(const char* heading, const BasicStream& str, const LoggerPtr& logger,
- const TraceLevelsPtr& tl)
+ const TraceLevelsPtr& tl)
{
if(tl->protocol >= 1)
{
- BasicStream& stream = const_cast<BasicStream&>(str);
- BasicStream::Container::iterator p = stream.i;
- stream.i = stream.b.begin();
+ BasicStream& stream = const_cast<BasicStream&>(str);
+ BasicStream::Container::iterator p = stream.i;
+ stream.i = stream.b.begin();
- ostringstream s;
- s << heading;
- printHeader(s, stream);
+ ostringstream s;
+ s << heading;
+ printHeader(s, stream);
- logger->trace(tl->protocolCat, s.str());
- stream.i = p;
+ logger->trace(tl->protocolCat, s.str());
+ stream.i = p;
}
}
void
IceInternal::traceRequest(const char* heading, const BasicStream& str, const LoggerPtr& logger,
- const TraceLevelsPtr& tl)
+ const TraceLevelsPtr& tl)
{
if(tl->protocol >= 1)
{
- BasicStream& stream = const_cast<BasicStream&>(str);
- BasicStream::Container::iterator p = stream.i;
- stream.i = stream.b.begin();
-
- ostringstream s;
- s << heading;
- printHeader(s, stream);
-
- Int requestId;
- stream.read(requestId);
- s << "\nrequest id = " << requestId;
- if(requestId == 0)
- {
- s << " (oneway)";
- }
-
- printRequestHeader(s, stream);
-
- logger->trace(tl->protocolCat, s.str());
- stream.i = p;
+ BasicStream& stream = const_cast<BasicStream&>(str);
+ BasicStream::Container::iterator p = stream.i;
+ stream.i = stream.b.begin();
+
+ ostringstream s;
+ s << heading;
+ printHeader(s, stream);
+
+ Int requestId;
+ stream.read(requestId);
+ s << "\nrequest id = " << requestId;
+ if(requestId == 0)
+ {
+ s << " (oneway)";
+ }
+
+ printRequestHeader(s, stream);
+
+ logger->trace(tl->protocolCat, s.str());
+ stream.i = p;
}
}
void
IceInternal::traceBatchRequest(const char* heading, const BasicStream& str, const LoggerPtr& logger,
- const TraceLevelsPtr& tl)
+ const TraceLevelsPtr& tl)
{
if(tl->protocol >= 1)
{
- BasicStream& stream = const_cast<BasicStream&>(str);
- BasicStream::Container::iterator p = stream.i;
- stream.i = stream.b.begin();
-
- ostringstream s;
- s << heading;
- printHeader(s, stream);
-
- int batchRequestNum;
- stream.read(batchRequestNum);
- s << "\nnumber of requests = " << batchRequestNum;
-
- for(int i = 0; i < batchRequestNum; ++i)
- {
- s << "\nrequest #" << i << ':';
- printRequestHeader(s, stream);
- stream.skipEncaps();
- }
-
- logger->trace(tl->protocolCat, s.str());
- stream.i = p;
+ BasicStream& stream = const_cast<BasicStream&>(str);
+ BasicStream::Container::iterator p = stream.i;
+ stream.i = stream.b.begin();
+
+ ostringstream s;
+ s << heading;
+ printHeader(s, stream);
+
+ int batchRequestNum;
+ stream.read(batchRequestNum);
+ s << "\nnumber of requests = " << batchRequestNum;
+
+ for(int i = 0; i < batchRequestNum; ++i)
+ {
+ s << "\nrequest #" << i << ':';
+ printRequestHeader(s, stream);
+ stream.skipEncaps();
+ }
+
+ logger->trace(tl->protocolCat, s.str());
+ stream.i = p;
}
}
void
IceInternal::traceReply(const char* heading, const BasicStream& str, const LoggerPtr& logger,
- const TraceLevelsPtr& tl)
+ const TraceLevelsPtr& tl)
{
if(tl->protocol >= 1)
{
- BasicStream& stream = const_cast<BasicStream&>(str);
- BasicStream::Container::iterator p = stream.i;
- stream.i = stream.b.begin();
-
- ostringstream s;
- s << heading;
- printHeader(s, stream);
-
- Int requestId;
- stream.read(requestId);
- s << "\nrequest id = " << requestId;
-
- Byte status;
- stream.read(status);
- s << "\nreply status = " << static_cast<int>(status) << ' ';
- switch(static_cast<DispatchStatus>(status))
- {
- case DispatchOK:
- {
- s << "(ok)";
- break;
- }
-
- case DispatchUserException:
- {
- s << "(user exception)";
- break;
- }
-
- case DispatchObjectNotExist:
- case DispatchFacetNotExist:
- case DispatchOperationNotExist:
- {
- switch(static_cast<DispatchStatus>(status))
- {
- case DispatchObjectNotExist:
- {
- s << "(object not exist)";
- break;
- }
-
- case DispatchFacetNotExist:
- {
- s << "(facet not exist)";
- break;
- }
-
- case DispatchOperationNotExist:
- {
- s << "(operation not exist)";
- break;
- }
-
- default:
- {
- assert(false);
- break;
- }
- }
-
- printIdentityFacetOperation(s, stream);
- break;
- }
-
- case DispatchUnknownException:
- case DispatchUnknownLocalException:
- case DispatchUnknownUserException:
- {
- switch(static_cast<DispatchStatus>(status))
- {
- case DispatchUnknownException:
- {
- s << "(unknown exception)";
- break;
- }
-
- case DispatchUnknownLocalException:
- {
- s << "(unknown local exception)";
- break;
- }
-
- case DispatchUnknownUserException:
- {
- s << "(unknown user exception)";
- break;
- }
-
- default:
- {
- assert(false);
- break;
- }
- }
-
- string unknown;
- stream.read(unknown, false);
- s << "\nunknown = " << unknown;
- break;
- }
-
- default:
- {
- s << "(unknown)";
- break;
- }
- }
-
- logger->trace(tl->protocolCat, s.str());
- stream.i = p;
+ BasicStream& stream = const_cast<BasicStream&>(str);
+ BasicStream::Container::iterator p = stream.i;
+ stream.i = stream.b.begin();
+
+ ostringstream s;
+ s << heading;
+ printHeader(s, stream);
+
+ Int requestId;
+ stream.read(requestId);
+ s << "\nrequest id = " << requestId;
+
+ Byte status;
+ stream.read(status);
+ s << "\nreply status = " << static_cast<int>(status) << ' ';
+ switch(static_cast<DispatchStatus>(status))
+ {
+ case DispatchOK:
+ {
+ s << "(ok)";
+ break;
+ }
+
+ case DispatchUserException:
+ {
+ s << "(user exception)";
+ break;
+ }
+
+ case DispatchObjectNotExist:
+ case DispatchFacetNotExist:
+ case DispatchOperationNotExist:
+ {
+ switch(static_cast<DispatchStatus>(status))
+ {
+ case DispatchObjectNotExist:
+ {
+ s << "(object not exist)";
+ break;
+ }
+
+ case DispatchFacetNotExist:
+ {
+ s << "(facet not exist)";
+ break;
+ }
+
+ case DispatchOperationNotExist:
+ {
+ s << "(operation not exist)";
+ break;
+ }
+
+ default:
+ {
+ assert(false);
+ break;
+ }
+ }
+
+ printIdentityFacetOperation(s, stream);
+ break;
+ }
+
+ case DispatchUnknownException:
+ case DispatchUnknownLocalException:
+ case DispatchUnknownUserException:
+ {
+ switch(static_cast<DispatchStatus>(status))
+ {
+ case DispatchUnknownException:
+ {
+ s << "(unknown exception)";
+ break;
+ }
+
+ case DispatchUnknownLocalException:
+ {
+ s << "(unknown local exception)";
+ break;
+ }
+
+ case DispatchUnknownUserException:
+ {
+ s << "(unknown user exception)";
+ break;
+ }
+
+ default:
+ {
+ assert(false);
+ break;
+ }
+ }
+
+ string unknown;
+ stream.read(unknown, false);
+ s << "\nunknown = " << unknown;
+ break;
+ }
+
+ default:
+ {
+ s << "(unknown)";
+ break;
+ }
+ }
+
+ logger->trace(tl->protocolCat, s.str());
+ stream.i = p;
}
}
@@ -402,9 +402,9 @@ IceInternal::traceSlicing(const char* kind, const string& typeId, const char* sl
static set<string> slicingIds;
if(slicingIds.insert(typeId).second)
{
- string s("unknown ");
- s += kind;
- s += " type `" + typeId + "'";
- logger->trace(slicingCat, s);
+ string s("unknown ");
+ s += kind;
+ s += " type `" + typeId + "'";
+ logger->trace(slicingCat, s);
}
}
diff --git a/cpp/src/Ice/UdpEndpointI.cpp b/cpp/src/Ice/UdpEndpointI.cpp
index d3ca4a84719..6681e8becbf 100644
--- a/cpp/src/Ice/UdpEndpointI.cpp
+++ b/cpp/src/Ice/UdpEndpointI.cpp
@@ -21,7 +21,7 @@ using namespace Ice;
using namespace IceInternal;
IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const string& ho, Int po, bool conn,
- const string& conId, bool co, bool pub) :
+ const string& conId, bool co, bool pub) :
_instance(instance),
_host(ho),
_port(po),
@@ -54,209 +54,209 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin
while(true)
{
- beg = str.find_first_not_of(delim, end);
- if(beg == string::npos)
- {
- break;
- }
-
- end = str.find_first_of(delim, beg);
- if(end == string::npos)
- {
- end = str.length();
- }
-
- string option = str.substr(beg, end - beg);
- if(option.length() != 2 || option[0] != '-')
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
-
- string argument;
- string::size_type argumentBeg = str.find_first_not_of(delim, end);
- if(argumentBeg != string::npos && str[argumentBeg] != '-')
- {
- beg = argumentBeg;
- end = str.find_first_of(delim + ":", beg);
- if(end == string::npos)
- {
- end = str.length();
- }
- argument = str.substr(beg, end - beg);
- }
-
- switch(option[1])
- {
- case 'v':
- {
- if(argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
-
- string::size_type pos = argument.find('.');
- if(pos == string::npos)
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
- string majorStr = argument.substr(0, pos);
- string minorStr = argument.substr(pos + 1, string::npos);
-
- istringstream majStr(majorStr);
- Int majVersion;
- if(!(majStr >> majVersion) || !majStr.eof())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
-
- istringstream minStr(minorStr);
- Int minVersion;
- if(!(minStr >> minVersion) || !minStr.eof())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
-
- if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
-
- if(majVersion != protocolMajor)
- {
- UnsupportedProtocolException ex(__FILE__, __LINE__);
- ex.badMajor = majVersion;
- ex.badMinor = minVersion;
- ex.major = static_cast<unsigned char>(protocolMajor);
- ex.minor = static_cast<unsigned char>(protocolMinor);
- throw ex;
- }
-
- const_cast<Byte&>(_protocolMajor) = majVersion;
- const_cast<Byte&>(_protocolMinor) = minVersion;
-
- break;
- }
-
- case 'e':
- {
- if(argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
- string::size_type pos = argument.find('.');
- string majorStr = argument.substr(0, pos);
- string minorStr = argument.substr(pos + 1, string::npos);
-
- istringstream majStr(majorStr);
- Int majVersion;
- if(!(majStr >> majVersion) || !majStr.eof())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
-
- istringstream minStr(minorStr);
- Int minVersion;
- if(!(minStr >> minVersion) || !minStr.eof())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
-
- if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
-
- if(majVersion != static_cast<unsigned char>(encodingMajor))
- {
- UnsupportedEncodingException ex(__FILE__, __LINE__);
- ex.badMajor = majVersion;
- ex.badMinor = minVersion;
- ex.major = static_cast<unsigned char>(encodingMajor);
- ex.minor = static_cast<unsigned char>(encodingMinor);
- throw ex;
- }
-
- const_cast<Byte&>(_encodingMajor) = majVersion;
- const_cast<Byte&>(_encodingMinor) = minVersion;
-
- break;
- }
-
- case 'h':
- {
- if(argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
- const_cast<string&>(_host) = argument;
- break;
- }
-
- case 'p':
- {
- istringstream p(argument);
- if(!(p >> const_cast<Int&>(_port)) || !p.eof() || _port < 0 || _port > 65535)
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
- break;
- }
-
- case 'c':
- {
- if(!argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
- const_cast<bool&>(_connect) = true;
- break;
- }
-
- case 'z':
- {
- if(!argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
- const_cast<bool&>(_compress) = true;
- break;
- }
-
- default:
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "udp " + str;
- throw ex;
- }
- }
+ beg = str.find_first_not_of(delim, end);
+ if(beg == string::npos)
+ {
+ break;
+ }
+
+ end = str.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ end = str.length();
+ }
+
+ string option = str.substr(beg, end - beg);
+ if(option.length() != 2 || option[0] != '-')
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+
+ string argument;
+ string::size_type argumentBeg = str.find_first_not_of(delim, end);
+ if(argumentBeg != string::npos && str[argumentBeg] != '-')
+ {
+ beg = argumentBeg;
+ end = str.find_first_of(delim + ":", beg);
+ if(end == string::npos)
+ {
+ end = str.length();
+ }
+ argument = str.substr(beg, end - beg);
+ }
+
+ switch(option[1])
+ {
+ case 'v':
+ {
+ if(argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+
+ string::size_type pos = argument.find('.');
+ if(pos == string::npos)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+ string majorStr = argument.substr(0, pos);
+ string minorStr = argument.substr(pos + 1, string::npos);
+
+ istringstream majStr(majorStr);
+ Int majVersion;
+ if(!(majStr >> majVersion) || !majStr.eof())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+
+ istringstream minStr(minorStr);
+ Int minVersion;
+ if(!(minStr >> minVersion) || !minStr.eof())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+
+ if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+
+ if(majVersion != protocolMajor)
+ {
+ UnsupportedProtocolException ex(__FILE__, __LINE__);
+ ex.badMajor = majVersion;
+ ex.badMinor = minVersion;
+ ex.major = static_cast<unsigned char>(protocolMajor);
+ ex.minor = static_cast<unsigned char>(protocolMinor);
+ throw ex;
+ }
+
+ const_cast<Byte&>(_protocolMajor) = majVersion;
+ const_cast<Byte&>(_protocolMinor) = minVersion;
+
+ break;
+ }
+
+ case 'e':
+ {
+ if(argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+ string::size_type pos = argument.find('.');
+ string majorStr = argument.substr(0, pos);
+ string minorStr = argument.substr(pos + 1, string::npos);
+
+ istringstream majStr(majorStr);
+ Int majVersion;
+ if(!(majStr >> majVersion) || !majStr.eof())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+
+ istringstream minStr(minorStr);
+ Int minVersion;
+ if(!(minStr >> minVersion) || !minStr.eof())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+
+ if(majVersion < 1 || majVersion > 255 || minVersion < 0 || minVersion > 255)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+
+ if(majVersion != static_cast<unsigned char>(encodingMajor))
+ {
+ UnsupportedEncodingException ex(__FILE__, __LINE__);
+ ex.badMajor = majVersion;
+ ex.badMinor = minVersion;
+ ex.major = static_cast<unsigned char>(encodingMajor);
+ ex.minor = static_cast<unsigned char>(encodingMinor);
+ throw ex;
+ }
+
+ const_cast<Byte&>(_encodingMajor) = majVersion;
+ const_cast<Byte&>(_encodingMinor) = minVersion;
+
+ break;
+ }
+
+ case 'h':
+ {
+ if(argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+ const_cast<string&>(_host) = argument;
+ break;
+ }
+
+ case 'p':
+ {
+ istringstream p(argument);
+ if(!(p >> const_cast<Int&>(_port)) || !p.eof() || _port < 0 || _port > 65535)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+ break;
+ }
+
+ case 'c':
+ {
+ if(!argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+ const_cast<bool&>(_connect) = true;
+ break;
+ }
+
+ case 'z':
+ {
+ if(!argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+ const_cast<bool&>(_compress) = true;
+ break;
+ }
+
+ default:
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "udp " + str;
+ throw ex;
+ }
+ }
}
}
@@ -280,21 +280,21 @@ IceInternal::UdpEndpointI::UdpEndpointI(BasicStream* s) :
s->read(const_cast<Byte&>(_encodingMinor));
if(_protocolMajor != protocolMajor)
{
- UnsupportedProtocolException ex(__FILE__, __LINE__);
- ex.badMajor = _protocolMajor;
- ex.badMinor = _protocolMinor;
- ex.major = static_cast<unsigned char>(protocolMajor);
- ex.minor = static_cast<unsigned char>(protocolMinor);
- throw ex;
+ UnsupportedProtocolException ex(__FILE__, __LINE__);
+ ex.badMajor = _protocolMajor;
+ ex.badMinor = _protocolMinor;
+ ex.major = static_cast<unsigned char>(protocolMajor);
+ ex.minor = static_cast<unsigned char>(protocolMinor);
+ throw ex;
}
if(_encodingMajor != encodingMajor)
{
- UnsupportedEncodingException ex(__FILE__, __LINE__);
- ex.badMajor = _encodingMajor;
- ex.badMinor = _encodingMinor;
- ex.major = static_cast<unsigned char>(encodingMajor);
- ex.minor = static_cast<unsigned char>(encodingMinor);
- throw ex;
+ UnsupportedEncodingException ex(__FILE__, __LINE__);
+ ex.badMajor = _encodingMajor;
+ ex.badMinor = _encodingMinor;
+ ex.major = static_cast<unsigned char>(encodingMajor);
+ ex.minor = static_cast<unsigned char>(encodingMinor);
+ throw ex;
}
// Not transmitted.
//s->read(const_cast<bool&>(_connect));
@@ -335,28 +335,28 @@ IceInternal::UdpEndpointI::toString() const
if(_protocolMajor != Byte(1) || _protocolMinor != Byte(0))
{
- s << " -v "
- << static_cast<unsigned>(static_cast<unsigned char>(_protocolMajor)) << "."
- << static_cast<unsigned>(static_cast<unsigned char>(_protocolMinor));
+ s << " -v "
+ << static_cast<unsigned>(static_cast<unsigned char>(_protocolMajor)) << "."
+ << static_cast<unsigned>(static_cast<unsigned char>(_protocolMinor));
}
if(_encodingMajor != Byte(1) || _encodingMinor != Byte(0))
{
- s << " -e "
- << static_cast<unsigned>(static_cast<unsigned char>(_encodingMajor)) << "."
- << static_cast<unsigned>(static_cast<unsigned char>(_encodingMinor));
+ s << " -e "
+ << static_cast<unsigned>(static_cast<unsigned char>(_encodingMajor)) << "."
+ << static_cast<unsigned>(static_cast<unsigned char>(_encodingMinor));
}
s << " -h " << _host << " -p " << _port;
if(_connect)
{
- s << " -c";
+ s << " -c";
}
if(_compress)
{
- s << " -z";
+ s << " -z";
}
return s.str();
@@ -385,11 +385,11 @@ IceInternal::UdpEndpointI::connectionId(const string& connectionId) const
{
if(connectionId == _connectionId)
{
- return const_cast<UdpEndpointI*>(this);
+ return const_cast<UdpEndpointI*>(this);
}
else
{
- return new UdpEndpointI(_instance, _host, _port, _connect, connectionId, _compress, _publish);
+ return new UdpEndpointI(_instance, _host, _port, _connect, connectionId, _compress, _publish);
}
}
@@ -404,11 +404,11 @@ IceInternal::UdpEndpointI::compress(bool compress) const
{
if(compress == _compress)
{
- return const_cast<UdpEndpointI*>(this);
+ return const_cast<UdpEndpointI*>(this);
}
else
{
- return new UdpEndpointI(_instance, _host, _port, _connect, _connectionId, compress, _publish);
+ return new UdpEndpointI(_instance, _host, _port, _connect, _connectionId, compress, _publish);
}
}
@@ -487,7 +487,7 @@ IceInternal::UdpEndpointI::expand(bool server) const
for(unsigned int i = 0; i < hosts.size(); ++i)
{
endps.push_back(new UdpEndpointI(_instance, hosts[i], _port, _connect, _connectionId, _compress,
- hosts.size() == 1 || hosts[i] != "127.0.0.1"));
+ hosts.size() == 1 || hosts[i] != "127.0.0.1"));
}
}
else
@@ -509,7 +509,7 @@ IceInternal::UdpEndpointI::equivalent(const TransceiverPtr& transceiver) const
const UdpTransceiver* udpTransceiver = dynamic_cast<const UdpTransceiver*>(transceiver.get());
if(!udpTransceiver)
{
- return false;
+ return false;
}
return udpTransceiver->equivalent(_host, _port);
}
@@ -526,72 +526,72 @@ IceInternal::UdpEndpointI::operator==(const EndpointI& r) const
const UdpEndpointI* p = dynamic_cast<const UdpEndpointI*>(&r);
if(!p)
{
- return false;
+ return false;
}
if(this == p)
{
- return true;
+ return true;
}
if(_port != p->_port)
{
- return false;
+ return false;
}
if(_compress != p->_compress)
{
- return false;
+ return false;
}
if(_connectionId != p->_connectionId)
{
- return false;
+ return false;
}
if(_connect != p->_connect)
{
- return false;
+ return false;
}
if(_protocolMajor != p->_protocolMajor)
{
- return false;
+ return false;
}
if(_protocolMinor != p->_protocolMinor)
{
- return false;
+ return false;
}
if(_encodingMajor != p->_encodingMajor)
{
- return false;
+ return false;
}
if(_encodingMinor != p->_encodingMinor)
{
- return false;
+ return false;
}
if(_host != p->_host)
{
- //
- // We do the most time-consuming part of the comparison last.
- //
- struct sockaddr_in laddr;
- struct sockaddr_in raddr;
- try
- {
- getAddress(_host, _port, laddr);
- getAddress(p->_host, p->_port, raddr);
- }
- catch(const DNSException&)
- {
- return false;
- }
+ //
+ // We do the most time-consuming part of the comparison last.
+ //
+ struct sockaddr_in laddr;
+ struct sockaddr_in raddr;
+ try
+ {
+ getAddress(_host, _port, laddr);
+ getAddress(p->_host, p->_port, raddr);
+ }
+ catch(const DNSException&)
+ {
+ return false;
+ }
- return compareAddress(laddr, raddr);
+ return compareAddress(laddr, raddr);
}
return true;
@@ -614,112 +614,112 @@ IceInternal::UdpEndpointI::operator<(const EndpointI& r) const
if(this == p)
{
- return false;
+ return false;
}
if(_port < p->_port)
{
- return true;
+ return true;
}
else if(p->_port < _port)
{
- return false;
+ return false;
}
if(_connectionId < p->_connectionId)
{
- return true;
+ return true;
}
else if(p->_connectionId < _connectionId)
{
- return false;
+ return false;
}
if(!_compress && p->_compress)
{
- return true;
+ return true;
}
else if(p->_compress < _compress)
{
- return false;
+ return false;
}
if(!_connect && p->_connect)
{
- return true;
+ return true;
}
else if(!p->_connect && _connect)
{
- return false;
+ return false;
}
if(_protocolMajor < p->_protocolMajor)
{
- return true;
+ return true;
}
else if(p->_protocolMajor < _protocolMajor)
{
- return false;
+ return false;
}
if(_protocolMinor < p->_protocolMinor)
{
- return true;
+ return true;
}
else if(p->_protocolMinor < _protocolMinor)
{
- return false;
+ return false;
}
if(_encodingMajor < p->_encodingMajor)
{
- return true;
+ return true;
}
else if(p->_encodingMajor < _encodingMajor)
{
- return false;
+ return false;
}
if(_encodingMinor < p->_encodingMinor)
{
- return true;
+ return true;
}
else if(p->_encodingMinor < _encodingMinor)
{
- return false;
+ return false;
}
if(_host != p->_host)
{
- //
- // We do the most time-consuming part of the comparison last.
- //
- struct sockaddr_in laddr;
- try
- {
- getAddress(_host, _port, laddr);
- }
- catch(const DNSException&)
- {
- }
-
- struct sockaddr_in raddr;
- try
- {
- getAddress(p->_host, p->_port, raddr);
- }
- catch(const DNSException&)
- {
- }
-
- if(laddr.sin_addr.s_addr < raddr.sin_addr.s_addr)
- {
- return true;
- }
- else if(raddr.sin_addr.s_addr < laddr.sin_addr.s_addr)
- {
- return false;
- }
+ //
+ // We do the most time-consuming part of the comparison last.
+ //
+ struct sockaddr_in laddr;
+ try
+ {
+ getAddress(_host, _port, laddr);
+ }
+ catch(const DNSException&)
+ {
+ }
+
+ struct sockaddr_in raddr;
+ try
+ {
+ getAddress(p->_host, p->_port, raddr);
+ }
+ catch(const DNSException&)
+ {
+ }
+
+ if(laddr.sin_addr.s_addr < raddr.sin_addr.s_addr)
+ {
+ return true;
+ }
+ else if(raddr.sin_addr.s_addr < laddr.sin_addr.s_addr)
+ {
+ return false;
+ }
}
return false;
diff --git a/cpp/src/Ice/UdpTransceiver.cpp b/cpp/src/Ice/UdpTransceiver.cpp
index f7e26883e38..4853d98aaa9 100644
--- a/cpp/src/Ice/UdpTransceiver.cpp
+++ b/cpp/src/Ice/UdpTransceiver.cpp
@@ -33,8 +33,8 @@ IceInternal::UdpTransceiver::close()
{
if(_traceLevels->network >= 1)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "closing udp connection\n" << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "closing udp connection\n" << toString();
}
assert(_fd != INVALID_SOCKET);
@@ -52,8 +52,8 @@ IceInternal::UdpTransceiver::shutdownReadWrite()
{
if(_traceLevels->network >= 2)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "shutting down udp connection for reading and writing\n" << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "shutting down udp connection for reading and writing\n" << toString();
}
//
@@ -84,10 +84,10 @@ IceInternal::UdpTransceiver::shutdownReadWrite()
//
if(!_connect)
{
- struct sockaddr_in unspec;
- memset(&unspec, 0, sizeof(unspec));
- unspec.sin_family = AF_UNSPEC;
- ::connect(_fd, reinterpret_cast<struct sockaddr*>(&unspec), int(sizeof(unspec)));
+ struct sockaddr_in unspec;
+ memset(&unspec, 0, sizeof(unspec));
+ unspec.sin_family = AF_UNSPEC;
+ ::connect(_fd, reinterpret_cast<struct sockaddr*>(&unspec), int(sizeof(unspec)));
}
//
@@ -117,10 +117,10 @@ IceInternal::UdpTransceiver::write(Buffer& buf, int)
const int packetSize = min(_maxPacketSize, _sndSize - _udpOverhead);
if(packetSize < static_cast<int>(buf.b.size()))
{
- //
- // We don't log a warning here because the client gets an exception anyway.
- //
- throw DatagramLimitException(__FILE__, __LINE__);
+ //
+ // We don't log a warning here because the client gets an exception anyway.
+ //
+ throw DatagramLimitException(__FILE__, __LINE__);
}
repeat:
@@ -128,62 +128,62 @@ repeat:
assert(_fd != INVALID_SOCKET);
#ifdef _WIN32
ssize_t ret = ::send(_fd, reinterpret_cast<const char*>(&buf.b[0]),
- static_cast<int>(buf.b.size()), 0);
+ static_cast<int>(buf.b.size()), 0);
#else
ssize_t ret = ::send(_fd, reinterpret_cast<const char*>(&buf.b[0]),
- buf.b.size(), 0);
+ buf.b.size(), 0);
#endif
if(ret == SOCKET_ERROR)
{
- if(interrupted())
- {
- goto repeat;
- }
+ if(interrupted())
+ {
+ goto repeat;
+ }
- if(wouldBlock())
- {
- repeatSelect:
+ if(wouldBlock())
+ {
+ repeatSelect:
- assert(_fd != INVALID_SOCKET);
+ assert(_fd != INVALID_SOCKET);
#ifdef _WIN32
- FD_SET(_fd, &_wFdSet);
- int rs = ::select(static_cast<int>(_fd + 1), 0, &_wFdSet, 0, 0);
+ FD_SET(_fd, &_wFdSet);
+ int rs = ::select(static_cast<int>(_fd + 1), 0, &_wFdSet, 0, 0);
#else
- struct pollfd fdSet[1];
- fdSet[0].fd = _fd;
- fdSet[0].events = POLLOUT;
- int rs = ::poll(fdSet, 1, -1);
+ struct pollfd fdSet[1];
+ fdSet[0].fd = _fd;
+ fdSet[0].events = POLLOUT;
+ int rs = ::poll(fdSet, 1, -1);
#endif
- if(rs == SOCKET_ERROR)
- {
- if(interrupted())
- {
- goto repeatSelect;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
-
- goto repeat;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ if(rs == SOCKET_ERROR)
+ {
+ if(interrupted())
+ {
+ goto repeatSelect;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+
+ goto repeat;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
if(_traceLevels->network >= 3)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "sent " << ret << " bytes via udp\n" << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "sent " << ret << " bytes via udp\n" << toString();
}
if(_stats)
{
- _stats->bytesSent(type(), static_cast<Int>(ret));
+ _stats->bytesSent(type(), static_cast<Int>(ret));
}
assert(ret == static_cast<ssize_t>(buf.b.size()));
@@ -203,16 +203,16 @@ IceInternal::UdpTransceiver::read(Buffer& buf, int)
const int packetSize = min(_maxPacketSize, _rcvSize - _udpOverhead);
if(packetSize < static_cast<int>(buf.b.size()))
{
- //
- // We log a warning here because this is the server side -- without the
- // the warning, there would only be silence.
- //
- if(_warn)
- {
- Warning out(_logger);
- out << "DatagramLimitException: maximum size of " << packetSize << " exceeded";
- }
- throw DatagramLimitException(__FILE__, __LINE__);
+ //
+ // We log a warning here because this is the server side -- without the
+ // the warning, there would only be silence.
+ //
+ if(_warn)
+ {
+ Warning out(_logger);
+ out << "DatagramLimitException: maximum size of " << packetSize << " exceeded";
+ }
+ throw DatagramLimitException(__FILE__, __LINE__);
}
buf.b.resize(packetSize);
buf.i = buf.b.begin();
@@ -223,107 +223,107 @@ repeat:
// Check the shutdown flag.
//
{
- IceUtil::Mutex::Lock sync(_shutdownReadWriteMutex);
- if(_shutdownReadWrite)
- {
- throw ConnectionLostException(__FILE__, __LINE__);
- }
+ IceUtil::Mutex::Lock sync(_shutdownReadWriteMutex);
+ if(_shutdownReadWrite)
+ {
+ throw ConnectionLostException(__FILE__, __LINE__);
+ }
}
ssize_t ret;
if(_connect)
{
- //
- // If we must connect, then we connect to the first peer that
- // sends us a packet.
- //
- struct sockaddr_in peerAddr;
- memset(&peerAddr, 0, sizeof(struct sockaddr_in));
- socklen_t len = static_cast<socklen_t>(sizeof(peerAddr));
- assert(_fd != INVALID_SOCKET);
- ret = recvfrom(_fd, reinterpret_cast<char*>(&buf.b[0]), packetSize,
- 0, reinterpret_cast<struct sockaddr*>(&peerAddr), &len);
- if(ret != SOCKET_ERROR)
- {
- doConnect(_fd, peerAddr, -1);
- _connect = false; // We are connected now.
-
- if(_traceLevels->network >= 1)
- {
- Trace out(_logger, _traceLevels->networkCat);
- out << "connected udp socket\n" << toString();
- }
- }
+ //
+ // If we must connect, then we connect to the first peer that
+ // sends us a packet.
+ //
+ struct sockaddr_in peerAddr;
+ memset(&peerAddr, 0, sizeof(struct sockaddr_in));
+ socklen_t len = static_cast<socklen_t>(sizeof(peerAddr));
+ assert(_fd != INVALID_SOCKET);
+ ret = recvfrom(_fd, reinterpret_cast<char*>(&buf.b[0]), packetSize,
+ 0, reinterpret_cast<struct sockaddr*>(&peerAddr), &len);
+ if(ret != SOCKET_ERROR)
+ {
+ doConnect(_fd, peerAddr, -1);
+ _connect = false; // We are connected now.
+
+ if(_traceLevels->network >= 1)
+ {
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "connected udp socket\n" << toString();
+ }
+ }
}
else
{
- assert(_fd != INVALID_SOCKET);
- ret = ::recv(_fd, reinterpret_cast<char*>(&buf.b[0]), packetSize, 0);
+ assert(_fd != INVALID_SOCKET);
+ ret = ::recv(_fd, reinterpret_cast<char*>(&buf.b[0]), packetSize, 0);
}
if(ret == SOCKET_ERROR)
{
- if(interrupted())
- {
- goto repeat;
- }
-
- if(wouldBlock())
- {
- repeatSelect:
-
- assert(_fd != INVALID_SOCKET);
+ if(interrupted())
+ {
+ goto repeat;
+ }
+
+ if(wouldBlock())
+ {
+ repeatSelect:
+
+ assert(_fd != INVALID_SOCKET);
#ifdef _WIN32
- FD_SET(_fd, &_rFdSet);
- int rs = ::select(static_cast<int>(_fd + 1), &_rFdSet, 0, 0, 0);
+ FD_SET(_fd, &_rFdSet);
+ int rs = ::select(static_cast<int>(_fd + 1), &_rFdSet, 0, 0, 0);
#else
- struct pollfd fdSet[1];
- fdSet[0].fd = _fd;
- fdSet[0].events = POLLIN;
- int rs = ::poll(fdSet, 1, -1);
+ struct pollfd fdSet[1];
+ fdSet[0].fd = _fd;
+ fdSet[0].events = POLLIN;
+ int rs = ::poll(fdSet, 1, -1);
#endif
- if(rs == SOCKET_ERROR)
- {
- if(interrupted())
- {
- goto repeatSelect;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
- }
-
- goto repeat;
- }
-
- if(recvTruncated())
- {
- DatagramLimitException ex(__FILE__, __LINE__);
- if(_warn)
- {
- Warning out(_logger);
- out << "DatagramLimitException: maximum size of " << packetSize << " exceeded";
- }
- throw ex;
-
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = getSocketErrno();
- throw ex;
+ if(rs == SOCKET_ERROR)
+ {
+ if(interrupted())
+ {
+ goto repeatSelect;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
+ }
+
+ goto repeat;
+ }
+
+ if(recvTruncated())
+ {
+ DatagramLimitException ex(__FILE__, __LINE__);
+ if(_warn)
+ {
+ Warning out(_logger);
+ out << "DatagramLimitException: maximum size of " << packetSize << " exceeded";
+ }
+ throw ex;
+
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = getSocketErrno();
+ throw ex;
}
if(_traceLevels->network >= 3)
{
- Trace out(_logger, _traceLevels->networkCat);
- out << "received " << ret << " bytes via udp\n" << toString();
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "received " << ret << " bytes via udp\n" << toString();
}
if(_stats)
{
- _stats->bytesReceived(type(), static_cast<Int>(ret));
+ _stats->bytesReceived(type(), static_cast<Int>(ret));
}
buf.b.resize(ret);
@@ -352,12 +352,12 @@ IceInternal::UdpTransceiver::checkSendSize(const Buffer& buf, size_t messageSize
{
if(buf.b.size() > messageSizeMax)
{
- throw MemoryLimitException(__FILE__, __LINE__);
+ throw MemoryLimitException(__FILE__, __LINE__);
}
const int packetSize = min(_maxPacketSize, _sndSize - _udpOverhead);
if(packetSize < static_cast<int>(buf.b.size()))
{
- throw DatagramLimitException(__FILE__, __LINE__);
+ throw DatagramLimitException(__FILE__, __LINE__);
}
}
@@ -386,23 +386,23 @@ IceInternal::UdpTransceiver::UdpTransceiver(const InstancePtr& instance, const s
{
try
{
- _fd = createSocket(true);
- setBufSize(instance);
- setBlock(_fd, false);
- getAddress(host, port, _addr);
- doConnect(_fd, _addr, -1);
- _connect = false; // We're connected now
-
- if(_traceLevels->network >= 1)
- {
- Trace out(_logger, _traceLevels->networkCat);
- out << "starting to send udp packets\n" << toString();
- }
+ _fd = createSocket(true);
+ setBufSize(instance);
+ setBlock(_fd, false);
+ getAddress(host, port, _addr);
+ doConnect(_fd, _addr, -1);
+ _connect = false; // We're connected now
+
+ if(_traceLevels->network >= 1)
+ {
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "starting to send udp packets\n" << toString();
+ }
}
catch(...)
{
- _fd = INVALID_SOCKET;
- throw;
+ _fd = INVALID_SOCKET;
+ throw;
}
#ifdef _WIN32
@@ -422,27 +422,27 @@ IceInternal::UdpTransceiver::UdpTransceiver(const InstancePtr& instance, const s
{
try
{
- _fd = createSocket(true);
- setBufSize(instance);
- setBlock(_fd, false);
- getAddress(host, port, _addr);
- if(_traceLevels->network >= 2)
- {
- Trace out(_logger, _traceLevels->networkCat);
- out << "attempting to bind to udp socket " << addrToString(_addr);
- }
- doBind(_fd, _addr);
-
- if(_traceLevels->network >= 1)
- {
- Trace out(_logger, _traceLevels->networkCat);
- out << "starting to receive udp packets\n" << toString();
- }
+ _fd = createSocket(true);
+ setBufSize(instance);
+ setBlock(_fd, false);
+ getAddress(host, port, _addr);
+ if(_traceLevels->network >= 2)
+ {
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "attempting to bind to udp socket " << addrToString(_addr);
+ }
+ doBind(_fd, _addr);
+
+ if(_traceLevels->network >= 1)
+ {
+ Trace out(_logger, _traceLevels->networkCat);
+ out << "starting to receive udp packets\n" << toString();
+ }
}
catch(...)
{
- _fd = INVALID_SOCKET;
- throw;
+ _fd = INVALID_SOCKET;
+ throw;
}
#ifdef _WIN32
@@ -467,66 +467,66 @@ IceInternal::UdpTransceiver::setBufSize(const InstancePtr& instance)
for(int i = 0; i < 2; ++i)
{
- string direction;
- string prop;
- int* addr;
- int dfltSize;
- if(i == 0)
- {
- direction = "receive";
- prop = "Ice.UDP.RcvSize";
- addr = &_rcvSize;
- dfltSize = getRecvBufferSize(_fd);
- _rcvSize = dfltSize;
- }
- else
- {
- direction = "send";
- prop = "Ice.UDP.SndSize";
- addr = &_sndSize;
- dfltSize = getSendBufferSize(_fd);
- _sndSize = dfltSize;
- }
-
- //
- // Get property for buffer size and check for sanity.
- //
- Int sizeRequested = instance->initializationData().properties->getPropertyAsIntWithDefault(prop, dfltSize);
- if(sizeRequested < _udpOverhead)
- {
- Warning out(_logger);
- out << "Invalid " << prop << " value of " << sizeRequested << " adjusted to " << dfltSize;
- sizeRequested = dfltSize;
- }
-
- if(sizeRequested != dfltSize)
- {
- //
- // Try to set the buffer size. The kernel will silently adjust
- // the size to an acceptable value. Then read the size back to
- // get the size that was actually set.
- //
- if(i == 0)
- {
- setRecvBufferSize(_fd, sizeRequested);
- *addr = getRecvBufferSize(_fd);
- }
- else
- {
- setSendBufferSize(_fd, sizeRequested);
- *addr = getSendBufferSize(_fd);
- }
-
- //
- // Warn if the size that was set is less than the requested size.
- //
- if(*addr < sizeRequested)
- {
- Warning out(_logger);
- out << "UDP " << direction << " buffer size: requested size of "
- << sizeRequested << " adjusted to " << *addr;
- }
- }
+ string direction;
+ string prop;
+ int* addr;
+ int dfltSize;
+ if(i == 0)
+ {
+ direction = "receive";
+ prop = "Ice.UDP.RcvSize";
+ addr = &_rcvSize;
+ dfltSize = getRecvBufferSize(_fd);
+ _rcvSize = dfltSize;
+ }
+ else
+ {
+ direction = "send";
+ prop = "Ice.UDP.SndSize";
+ addr = &_sndSize;
+ dfltSize = getSendBufferSize(_fd);
+ _sndSize = dfltSize;
+ }
+
+ //
+ // Get property for buffer size and check for sanity.
+ //
+ Int sizeRequested = instance->initializationData().properties->getPropertyAsIntWithDefault(prop, dfltSize);
+ if(sizeRequested < _udpOverhead)
+ {
+ Warning out(_logger);
+ out << "Invalid " << prop << " value of " << sizeRequested << " adjusted to " << dfltSize;
+ sizeRequested = dfltSize;
+ }
+
+ if(sizeRequested != dfltSize)
+ {
+ //
+ // Try to set the buffer size. The kernel will silently adjust
+ // the size to an acceptable value. Then read the size back to
+ // get the size that was actually set.
+ //
+ if(i == 0)
+ {
+ setRecvBufferSize(_fd, sizeRequested);
+ *addr = getRecvBufferSize(_fd);
+ }
+ else
+ {
+ setSendBufferSize(_fd, sizeRequested);
+ *addr = getSendBufferSize(_fd);
+ }
+
+ //
+ // Warn if the size that was set is less than the requested size.
+ //
+ if(*addr < sizeRequested)
+ {
+ Warning out(_logger);
+ out << "UDP " << direction << " buffer size: requested size of "
+ << sizeRequested << " adjusted to " << *addr;
+ }
+ }
}
}
diff --git a/cpp/src/Ice/UnknownEndpointI.cpp b/cpp/src/Ice/UnknownEndpointI.cpp
index 80a3b5c5b1d..12a46a347dc 100644
--- a/cpp/src/Ice/UnknownEndpointI.cpp
+++ b/cpp/src/Ice/UnknownEndpointI.cpp
@@ -153,12 +153,12 @@ IceInternal::UnknownEndpointI::operator==(const EndpointI& r) const
const UnknownEndpointI* p = dynamic_cast<const UnknownEndpointI*>(&r);
if(!p)
{
- return false;
+ return false;
}
if(this == p)
{
- return true;
+ return true;
}
if(_type != p->_type)
@@ -168,7 +168,7 @@ IceInternal::UnknownEndpointI::operator==(const EndpointI& r) const
if(_rawBytes != p->_rawBytes)
{
- return false;
+ return false;
}
return true;
@@ -191,25 +191,25 @@ IceInternal::UnknownEndpointI::operator<(const EndpointI& r) const
if(this == p)
{
- return false;
+ return false;
}
if(_type < p->_type)
{
- return true;
+ return true;
}
else if(p->_type < _type)
{
- return false;
+ return false;
}
if(_rawBytes < p->_rawBytes)
{
- return true;
+ return true;
}
else if(p->_rawBytes < _rawBytes)
{
- return false;
+ return false;
}
return false;
diff --git a/cpp/src/IceBox/Admin.cpp b/cpp/src/IceBox/Admin.cpp
index 777f6bc0054..74234008973 100644
--- a/cpp/src/IceBox/Admin.cpp
+++ b/cpp/src/IceBox/Admin.cpp
@@ -58,24 +58,24 @@ Client::run(int argc, char* argv[])
vector<string> commands;
try
{
- commands = opts.parse(argc, (const char**)argv);
+ commands = opts.parse(argc, (const char**)argv);
}
catch(const IceUtil::BadOptException& e)
{
cerr << e.reason << endl;
- usage();
- return EXIT_FAILURE;
+ usage();
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage();
- return EXIT_SUCCESS;
+ usage();
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
if(commands.empty())
@@ -93,34 +93,34 @@ Client::run(int argc, char* argv[])
if(properties->getProperty("Ice.Default.Locator").empty())
{
//
- // DEPRECATED PROPERTY: Remove extra code in future release.
- //
- string managerEndpoints =
- properties->getPropertyWithDefault("Ice.OA.IceBox.ServiceManager.Endpoints",
- properties->getProperty("IceBox.ServiceManager.Endpoints"));
- if(managerEndpoints.empty())
- {
- cerr << appName() << ": property `Ice.OA.IceBox.ServiceManager.Endpoints' is not set" << endl;
- return EXIT_FAILURE;
- }
-
- managerProxy = "\"" + communicator()->identityToString(managerIdentity) + "\" :" + managerEndpoints;
+ // DEPRECATED PROPERTY: Remove extra code in future release.
+ //
+ string managerEndpoints =
+ properties->getPropertyWithDefault("Ice.OA.IceBox.ServiceManager.Endpoints",
+ properties->getProperty("IceBox.ServiceManager.Endpoints"));
+ if(managerEndpoints.empty())
+ {
+ cerr << appName() << ": property `Ice.OA.IceBox.ServiceManager.Endpoints' is not set" << endl;
+ return EXIT_FAILURE;
+ }
+
+ managerProxy = "\"" + communicator()->identityToString(managerIdentity) + "\" :" + managerEndpoints;
}
else
{
//
- // DEPRECATED PROPERTY: Remove extra code in future release.
- //
- string managerAdapterId =
- properties->getPropertyWithDefault("Ice.OA.IceBox.ServiceManager.AdapterId",
- properties->getProperty("IceBox.ServiceManager.AdapterId"));
- if(managerAdapterId.empty())
- {
- cerr << appName() << ": property `Ice.OA.IceBox.ServiceManager.AdapterId' is not set" << endl;
- return EXIT_FAILURE;
- }
-
- managerProxy = "\"" + communicator()->identityToString(managerIdentity) + "\" @" + managerAdapterId;
+ // DEPRECATED PROPERTY: Remove extra code in future release.
+ //
+ string managerAdapterId =
+ properties->getPropertyWithDefault("Ice.OA.IceBox.ServiceManager.AdapterId",
+ properties->getProperty("IceBox.ServiceManager.AdapterId"));
+ if(managerAdapterId.empty())
+ {
+ cerr << appName() << ": property `Ice.OA.IceBox.ServiceManager.AdapterId' is not set" << endl;
+ return EXIT_FAILURE;
+ }
+
+ managerProxy = "\"" + communicator()->identityToString(managerIdentity) + "\" @" + managerAdapterId;
}
ObjectPrx base = communicator()->stringToProxy(managerProxy);
@@ -154,48 +154,48 @@ Client::run(int argc, char* argv[])
{
manager->shutdown();
}
- else if((*r) == "start")
- {
- if(++r == commands.end())
- {
+ else if((*r) == "start")
+ {
+ if(++r == commands.end())
+ {
cerr << appName() << ": no service name specified." << endl;
return EXIT_FAILURE;
- }
-
- try
- {
- manager->startService(*r);
- }
- catch(const IceBox::NoSuchServiceException&)
- {
+ }
+
+ try
+ {
+ manager->startService(*r);
+ }
+ catch(const IceBox::NoSuchServiceException&)
+ {
cerr << appName() << ": unknown service `" << *r << "'" << endl;
- }
- catch(const IceBox::AlreadyStartedException&)
- {
+ }
+ catch(const IceBox::AlreadyStartedException&)
+ {
cerr << appName() << ": service already started." << endl;
- }
- }
- else if((*r) == "stop")
- {
- if(++r == commands.end())
- {
+ }
+ }
+ else if((*r) == "stop")
+ {
+ if(++r == commands.end())
+ {
cerr << appName() << ": no service name specified." << endl;
return EXIT_FAILURE;
- }
-
- try
- {
- manager->stopService(*r);
- }
- catch(const IceBox::NoSuchServiceException&)
- {
+ }
+
+ try
+ {
+ manager->stopService(*r);
+ }
+ catch(const IceBox::NoSuchServiceException&)
+ {
cerr << appName() << ": unknown service `" << *r << "'" << endl;
- }
- catch(const IceBox::AlreadyStoppedException&)
- {
+ }
+ catch(const IceBox::AlreadyStoppedException&)
+ {
cerr << appName() << ": service already stopped." << endl;
- }
- }
+ }
+ }
else
{
cerr << appName() << ": unknown command `" << *r << "'" << endl;
diff --git a/cpp/src/IceBox/Service.cpp b/cpp/src/IceBox/Service.cpp
index 881c263fe25..295d0c45817 100644
--- a/cpp/src/IceBox/Service.cpp
+++ b/cpp/src/IceBox/Service.cpp
@@ -88,7 +88,7 @@ IceBox::IceBoxService::stop()
if(_serviceManager)
{
_serviceManager->stop();
- _serviceManager = 0;
+ _serviceManager = 0;
}
return true;
}
@@ -129,8 +129,8 @@ IceBox::IceBoxService::usage(const string& appName)
"\n"
"--daemon Run as a daemon.\n"
"--noclose Do not close open file descriptors.\n"
- "--nochdir Do not change the current working directory.\n"
- "--pidfile <file> Write process ID to <file>."
+ "--nochdir Do not change the current working directory.\n"
+ "--pidfile <file> Write process ID to <file>."
);
#endif
print("Usage: " + appName + " [options]\n" + options);
diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp
index c3097d5b99e..047be74601b 100644
--- a/cpp/src/IceBox/ServiceManagerI.cpp
+++ b/cpp/src/IceBox/ServiceManagerI.cpp
@@ -53,33 +53,33 @@ IceBox::ServiceManagerI::startService(const string& name, const Current&)
vector<ServiceInfo>::iterator p;
for(p = _services.begin(); p != _services.end(); ++p)
{
- ServiceInfo& info = *p;
- if(info.name == name)
- {
- if(info.active)
- {
- throw AlreadyStartedException();
- }
-
- try
- {
- info.service->start(name, info.communicator == 0 ? _communicator : info.communicator, info.args);
- info.active = true;
- }
- catch(const Ice::Exception& ex)
- {
+ ServiceInfo& info = *p;
+ if(info.name == name)
+ {
+ if(info.active)
+ {
+ throw AlreadyStartedException();
+ }
+
+ try
+ {
+ info.service->start(name, info.communicator == 0 ? _communicator : info.communicator, info.args);
+ info.active = true;
+ }
+ catch(const Ice::Exception& ex)
+ {
Warning out(_logger);
- out << "ServiceManager: exception in start for service " << info.name << ":\n";
- out << ex;
- }
- catch(...)
- {
+ out << "ServiceManager: exception in start for service " << info.name << ":\n";
+ out << ex;
+ }
+ catch(...)
+ {
Warning out(_logger);
- out << "ServiceManager: unknown exception in start for service " << info.name;
- }
+ out << "ServiceManager: unknown exception in start for service " << info.name;
+ }
- return;
- }
+ return;
+ }
}
throw NoSuchServiceException();
@@ -97,33 +97,33 @@ IceBox::ServiceManagerI::stopService(const string& name, const Current&)
vector<ServiceInfo>::iterator p;
for(p = _services.begin(); p != _services.end(); ++p)
{
- ServiceInfo& info = *p;
- if(info.name == name)
- {
- if(!info.active)
- {
- throw AlreadyStoppedException();
- }
-
- try
- {
- info.service->stop();
- info.active = false;
- }
- catch(const Ice::Exception& ex)
- {
+ ServiceInfo& info = *p;
+ if(info.name == name)
+ {
+ if(!info.active)
+ {
+ throw AlreadyStoppedException();
+ }
+
+ try
+ {
+ info.service->stop();
+ info.active = false;
+ }
+ catch(const Ice::Exception& ex)
+ {
Warning out(_logger);
- out << "ServiceManager: exception in stop for service " << info.name << ":\n";
- out << ex;
- }
- catch(...)
- {
+ out << "ServiceManager: exception in stop for service " << info.name << ":\n";
+ out << ex;
+ }
+ catch(...)
+ {
Warning out(_logger);
- out << "ServiceManager: unknown exception in stop for service " << info.name;
- }
+ out << "ServiceManager: unknown exception in stop for service " << info.name;
+ }
- return;
- }
+ return;
+ }
}
throw NoSuchServiceException();
@@ -149,10 +149,10 @@ IceBox::ServiceManagerI::start()
//
ObjectAdapterPtr adapter = _communicator->createObjectAdapter("IceBox.ServiceManager");
- PropertiesPtr properties = _communicator->getProperties();
+ PropertiesPtr properties = _communicator->getProperties();
Identity identity;
- identity.category = properties->getPropertyWithDefault("IceBox.InstanceName", "IceBox");
- identity.name = "ServiceManager";
+ identity.category = properties->getPropertyWithDefault("IceBox.InstanceName", "IceBox");
+ identity.name = "ServiceManager";
adapter->add(obj, identity);
//
@@ -191,7 +191,7 @@ IceBox::ServiceManagerI::start()
//
const string prefix = "IceBox.Service.";
PropertyDict services = properties->getPropertiesForPrefix(prefix);
- PropertyDict::iterator p;
+ PropertyDict::iterator p;
for(StringSeq::const_iterator q = loadOrder.begin(); q != loadOrder.end(); ++q)
{
p = services.find(prefix + *q);
@@ -204,8 +204,8 @@ IceBox::ServiceManagerI::start()
load(*q, p->second);
services.erase(p);
}
- for(p = services.begin(); p != services.end(); ++p)
- {
+ for(p = services.begin(); p != services.end(); ++p)
+ {
string name = p->first.substr(prefix.size());
load(name, p->second);
}
@@ -228,16 +228,16 @@ IceBox::ServiceManagerI::start()
cout << bundleName << " ready" << endl;
}
- try
- {
- adapter->activate();
- }
- catch(const ObjectAdapterDeactivatedException&)
- {
- //
- // Expected if the communicator has been shutdown.
- //
- }
+ try
+ {
+ adapter->activate();
+ }
+ catch(const ObjectAdapterDeactivatedException&)
+ {
+ //
+ // Expected if the communicator has been shutdown.
+ //
+ }
}
catch(const FailureException& ex)
{
@@ -279,16 +279,16 @@ IceBox::ServiceManagerI::load(const string& name, const string& value)
else
{
entryPoint = value.substr(0, pos);
- try
- {
- args = IceUtil::Options::split(value.substr(pos + 1));
- }
- catch(const IceUtil::BadOptException& ex)
- {
- FailureException e(__FILE__, __LINE__);
- e.reason = "ServiceManager: invalid arguments for service `" + name + "':\n" + ex.reason;
- throw e;
- }
+ try
+ {
+ args = IceUtil::Options::split(value.substr(pos + 1));
+ }
+ catch(const IceUtil::BadOptException& ex)
+ {
+ FailureException e(__FILE__, __LINE__);
+ e.reason = "ServiceManager: invalid arguments for service `" + name + "':\n" + ex.reason;
+ throw e;
+ }
}
start(name, entryPoint, args);
}
@@ -363,148 +363,148 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint,
//
try
{
- //
- // If Ice.UseSharedCommunicator.<name> is not defined, create
- // a communicator for the service. The communicator inherits
- // from the shared communicator properties. If it's defined
- // add the service properties to the shared commnunicator
- // property set.
- //
- PropertiesPtr properties = _communicator->getProperties();
-
-
- if(properties->getPropertyAsInt("IceBox.UseSharedCommunicator." + service) > 0)
- {
- PropertiesPtr serviceProperties = createProperties(info.args, properties);
-
- //
- // Erase properties in 'properties'
- //
- PropertyDict allProps = properties->getPropertiesForPrefix("");
- for(PropertyDict::iterator p = allProps.begin(); p != allProps.end(); ++p)
- {
- if(serviceProperties->getProperty(p->first) == "")
- {
- properties->setProperty(p->first, "");
- }
- }
-
- //
- // Put all serviceProperties into 'properties'
- //
- properties->parseCommandLineOptions("", serviceProperties->getCommandLineOptions());
-
- //
- // Parse <service>.* command line options
- // (the Ice command line options were parse by the createProperties above)
- //
- info.args = properties->parseCommandLineOptions(service, info.args);
- }
- else
- {
- string name = properties->getProperty("Ice.ProgramName");
- PropertiesPtr serviceProperties;
- if(properties->getPropertyAsInt("IceBox.InheritContainerProperties") > 0)
- {
- serviceProperties = createProperties(info.args, properties);
- }
- else
- {
- serviceProperties = createProperties(info.args);
- }
-
- if(name == serviceProperties->getProperty("Ice.ProgramName"))
- {
- //
- // If the service did not set its own program-name, and
- // the icebox program-name != service, append the service name to the
- // program name.
- //
- if(name != service)
- {
- name = name.empty() ? service : name + "-" + service;
- }
- serviceProperties->setProperty("Ice.ProgramName", name);
- }
-
- //
- // Parse <service>.* command line options
- // (the Ice command line options were parsed by the createProperties above)
- //
- info.args = serviceProperties->parseCommandLineOptions(service, info.args);
-
- //
- // Remaining command line options are passed to the
- // communicator with argc/argv. This is necessary for Ice
- // plugin properties (e.g.: IceSSL).
- //
- int argc = static_cast<int>(info.args.size());
- char** argv = new char*[argc + 1];
- int i = 0;
- for(Ice::StringSeq::const_iterator p = info.args.begin(); p != info.args.end(); ++p, ++i)
- {
- argv[i] = strdup(p->c_str());
- }
- argv[argc] = 0;
-
- InitializationData initData;
- initData.properties = serviceProperties;
- info.communicator = initialize(argc, argv, initData);
-
- for(i = 0; i < argc + 1; ++i)
- {
- free(argv[i]);
- }
- delete[] argv;
- }
-
- CommunicatorPtr communicator = info.communicator ? info.communicator : _communicator;
-
- //
- // Start the service.
- //
- try
- {
- info.service->start(service, communicator, info.args);
- info.active = true;
- }
- catch(...)
- {
- if(info.communicator)
- {
- try
- {
- info.communicator->shutdown();
- info.communicator->waitForShutdown();
- }
- catch(const Ice::CommunicatorDestroyedException&)
- {
- //
- // Ignore, the service might have already destroyed
- // the communicator for its own reasons.
- //
- }
- catch(const Ice::Exception& ex)
- {
- Warning out(_logger);
- out << "ServiceManager: exception in shutting down communicator for service " << service << ":\n";
- out << ex;
- }
-
- try
- {
- info.communicator->destroy();
- info.communicator = 0;
- }
- catch(const Exception& ex)
- {
- Warning out(_logger);
- out << "ServiceManager: exception in shutting down communicator for service " << service << ":\n";
- out << ex;
- }
- }
- throw;
- }
+ //
+ // If Ice.UseSharedCommunicator.<name> is not defined, create
+ // a communicator for the service. The communicator inherits
+ // from the shared communicator properties. If it's defined
+ // add the service properties to the shared commnunicator
+ // property set.
+ //
+ PropertiesPtr properties = _communicator->getProperties();
+
+
+ if(properties->getPropertyAsInt("IceBox.UseSharedCommunicator." + service) > 0)
+ {
+ PropertiesPtr serviceProperties = createProperties(info.args, properties);
+
+ //
+ // Erase properties in 'properties'
+ //
+ PropertyDict allProps = properties->getPropertiesForPrefix("");
+ for(PropertyDict::iterator p = allProps.begin(); p != allProps.end(); ++p)
+ {
+ if(serviceProperties->getProperty(p->first) == "")
+ {
+ properties->setProperty(p->first, "");
+ }
+ }
+
+ //
+ // Put all serviceProperties into 'properties'
+ //
+ properties->parseCommandLineOptions("", serviceProperties->getCommandLineOptions());
+
+ //
+ // Parse <service>.* command line options
+ // (the Ice command line options were parse by the createProperties above)
+ //
+ info.args = properties->parseCommandLineOptions(service, info.args);
+ }
+ else
+ {
+ string name = properties->getProperty("Ice.ProgramName");
+ PropertiesPtr serviceProperties;
+ if(properties->getPropertyAsInt("IceBox.InheritContainerProperties") > 0)
+ {
+ serviceProperties = createProperties(info.args, properties);
+ }
+ else
+ {
+ serviceProperties = createProperties(info.args);
+ }
+
+ if(name == serviceProperties->getProperty("Ice.ProgramName"))
+ {
+ //
+ // If the service did not set its own program-name, and
+ // the icebox program-name != service, append the service name to the
+ // program name.
+ //
+ if(name != service)
+ {
+ name = name.empty() ? service : name + "-" + service;
+ }
+ serviceProperties->setProperty("Ice.ProgramName", name);
+ }
+
+ //
+ // Parse <service>.* command line options
+ // (the Ice command line options were parsed by the createProperties above)
+ //
+ info.args = serviceProperties->parseCommandLineOptions(service, info.args);
+
+ //
+ // Remaining command line options are passed to the
+ // communicator with argc/argv. This is necessary for Ice
+ // plugin properties (e.g.: IceSSL).
+ //
+ int argc = static_cast<int>(info.args.size());
+ char** argv = new char*[argc + 1];
+ int i = 0;
+ for(Ice::StringSeq::const_iterator p = info.args.begin(); p != info.args.end(); ++p, ++i)
+ {
+ argv[i] = strdup(p->c_str());
+ }
+ argv[argc] = 0;
+
+ InitializationData initData;
+ initData.properties = serviceProperties;
+ info.communicator = initialize(argc, argv, initData);
+
+ for(i = 0; i < argc + 1; ++i)
+ {
+ free(argv[i]);
+ }
+ delete[] argv;
+ }
+
+ CommunicatorPtr communicator = info.communicator ? info.communicator : _communicator;
+
+ //
+ // Start the service.
+ //
+ try
+ {
+ info.service->start(service, communicator, info.args);
+ info.active = true;
+ }
+ catch(...)
+ {
+ if(info.communicator)
+ {
+ try
+ {
+ info.communicator->shutdown();
+ info.communicator->waitForShutdown();
+ }
+ catch(const Ice::CommunicatorDestroyedException&)
+ {
+ //
+ // Ignore, the service might have already destroyed
+ // the communicator for its own reasons.
+ //
+ }
+ catch(const Ice::Exception& ex)
+ {
+ Warning out(_logger);
+ out << "ServiceManager: exception in shutting down communicator for service " << service << ":\n";
+ out << ex;
+ }
+
+ try
+ {
+ info.communicator->destroy();
+ info.communicator = 0;
+ }
+ catch(const Exception& ex)
+ {
+ Warning out(_logger);
+ out << "ServiceManager: exception in shutting down communicator for service " << service << ":\n";
+ out << ex;
+ }
+ }
+ throw;
+ }
info.library = library;
_services.push_back(info);
@@ -515,12 +515,12 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint,
}
catch(const Exception& ex)
{
- ostringstream s;
- s << "ServiceManager: exception while starting service " << service << ":\n";
- s << ex;
+ ostringstream s;
+ s << "ServiceManager: exception while starting service " << service << ":\n";
+ s << ex;
- FailureException e(__FILE__, __LINE__);
- e.reason = s.str();
+ FailureException e(__FILE__, __LINE__);
+ e.reason = s.str();
throw e;
}
}
@@ -541,103 +541,103 @@ IceBox::ServiceManagerI::stopAll()
//
for(p = _services.rbegin(); p != _services.rend(); ++p)
{
- ServiceInfo& info = *p;
- try
- {
- info.service->stop();
- info.active = false;
- }
- catch(const Ice::Exception& ex)
- {
+ ServiceInfo& info = *p;
+ try
+ {
+ info.service->stop();
+ info.active = false;
+ }
+ catch(const Ice::Exception& ex)
+ {
Warning out(_logger);
- out << "ServiceManager: exception in stop for service " << info.name << ":\n";
- out << ex;
- }
- catch(...)
- {
+ out << "ServiceManager: exception in stop for service " << info.name << ":\n";
+ out << ex;
+ }
+ catch(...)
+ {
Warning out(_logger);
- out << "ServiceManager: unknown exception in stop for service " << info.name;
- }
+ out << "ServiceManager: unknown exception in stop for service " << info.name;
+ }
}
for(p = _services.rbegin(); p != _services.rend(); ++p)
{
- ServiceInfo& info = *p;
-
- if(info.communicator)
- {
- try
- {
- info.communicator->shutdown();
- info.communicator->waitForShutdown();
- }
- catch(const Ice::CommunicatorDestroyedException&)
- {
- //
- // Ignore, the service might have already destroyed
- // the communicator for its own reasons.
- //
- }
- catch(const Ice::Exception& ex)
- {
- Warning out(_logger);
- out << "ServiceManager: exception in stop for service " << info.name << ":\n";
- out << ex;
- }
- }
-
- //
- // 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
- // the library is released since the library will destroy its global state.
- //
- try
- {
- info.service = 0;
- }
- catch(const Exception& ex)
- {
- Warning out(_logger);
- out << "ServiceManager: exception in stop for service " << info.name << ":\n";
- out << ex;
- }
- catch(...)
- {
+ ServiceInfo& info = *p;
+
+ if(info.communicator)
+ {
+ try
+ {
+ info.communicator->shutdown();
+ info.communicator->waitForShutdown();
+ }
+ catch(const Ice::CommunicatorDestroyedException&)
+ {
+ //
+ // Ignore, the service might have already destroyed
+ // the communicator for its own reasons.
+ //
+ }
+ catch(const Ice::Exception& ex)
+ {
+ Warning out(_logger);
+ out << "ServiceManager: exception in stop for service " << info.name << ":\n";
+ out << ex;
+ }
+ }
+
+ //
+ // 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
+ // the library is released since the library will destroy its global state.
+ //
+ try
+ {
+ info.service = 0;
+ }
+ catch(const Exception& ex)
+ {
Warning out(_logger);
- out << "ServiceManager: unknown exception in stop for service " << info.name;
- }
-
- if(info.communicator)
- {
- try
- {
- info.communicator->destroy();
- info.communicator = 0;
- }
- catch(const Exception& ex)
- {
- Warning out(_logger);
- out << "ServiceManager: exception in stop for service " << info.name << ":\n";
- out << ex;
- }
- }
-
- try
- {
- info.library = 0;
- }
- catch(const Exception& ex)
- {
- Warning out(_logger);
- out << "ServiceManager: exception in stop for service " << info.name << ":\n";
- out << ex;
- }
- catch(...)
- {
+ out << "ServiceManager: exception in stop for service " << info.name << ":\n";
+ out << ex;
+ }
+ catch(...)
+ {
Warning out(_logger);
- out << "ServiceManager: unknown exception in stop for service " << info.name;
- }
+ out << "ServiceManager: unknown exception in stop for service " << info.name;
+ }
+
+ if(info.communicator)
+ {
+ try
+ {
+ info.communicator->destroy();
+ info.communicator = 0;
+ }
+ catch(const Exception& ex)
+ {
+ Warning out(_logger);
+ out << "ServiceManager: exception in stop for service " << info.name << ":\n";
+ out << ex;
+ }
+ }
+
+ try
+ {
+ info.library = 0;
+ }
+ catch(const Exception& ex)
+ {
+ Warning out(_logger);
+ out << "ServiceManager: exception in stop for service " << info.name << ":\n";
+ out << ex;
+ }
+ catch(...)
+ {
+ Warning out(_logger);
+ out << "ServiceManager: unknown exception in stop for service " << info.name;
+ }
}
_services.clear();
diff --git a/cpp/src/IceBox/ServiceManagerI.h b/cpp/src/IceBox/ServiceManagerI.h
index 95a12ad6096..5484aa7b3fa 100644
--- a/cpp/src/IceBox/ServiceManagerI.h
+++ b/cpp/src/IceBox/ServiceManagerI.h
@@ -39,10 +39,10 @@ public:
::std::string name;
ServicePtr service;
::IceInternal::DynamicLibraryPtr library;
- ::Ice::CommunicatorPtr communicator;
- ::std::string envName;
- bool active;
- Ice::StringSeq args;
+ ::Ice::CommunicatorPtr communicator;
+ ::std::string envName;
+ bool active;
+ Ice::StringSeq args;
};
bool start();
diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp
index c9535ba7814..8d6c04aa3ca 100644
--- a/cpp/src/IceGrid/Activator.cpp
+++ b/cpp/src/IceGrid/Activator.cpp
@@ -41,14 +41,14 @@ class TerminationListenerThread : public IceUtil::Thread
public:
TerminationListenerThread(Activator& activator) :
- _activator(activator)
+ _activator(activator)
{
}
virtual
void run()
{
- _activator.runTerminationListener();
+ _activator.runTerminationListener();
}
private:
@@ -81,8 +81,8 @@ reportChildError(int err, int fd, const char* cannot, const char* name)
strcat(msg, "'");
if(err)
{
- strcat(msg, ": ");
- strcat(msg, strerror(err));
+ strcat(msg, ": ");
+ strcat(msg, strerror(err));
}
write(fd, msg, strlen(msg));
close(fd);
@@ -102,68 +102,68 @@ signalToString(int signal)
{
switch(signal)
{
- case SIGHUP:
- {
- return ICE_STRING(SIGHUP);
- }
- case SIGINT:
- {
- return ICE_STRING(SIGINT);
- }
- case SIGQUIT:
- {
- return ICE_STRING(SIGQUIT);
- }
- case SIGILL:
- {
- return ICE_STRING(SIGILL);
- }
- case SIGTRAP:
- {
- return ICE_STRING(SIGTRAP);
- }
- case SIGABRT:
- {
- return ICE_STRING(SIGABRT);
- }
- case SIGBUS:
- {
- return ICE_STRING(SIGBUS);
- }
- case SIGFPE:
- {
- return ICE_STRING(SIGFPE);
- }
- case SIGKILL:
- {
- return ICE_STRING(SIGKILL);
- }
- case SIGUSR1:
- {
- return ICE_STRING(SIGUSR1);
- }
- case SIGSEGV:
- {
- return ICE_STRING(SIGSEGV);
- }
- case SIGPIPE:
- {
- return ICE_STRING(SIGPIPE);
- }
- case SIGALRM:
- {
- return ICE_STRING(SIGALRM);
- }
- case SIGTERM:
- {
- return ICE_STRING(SIGTERM);
- }
- default:
- {
- ostringstream os;
- os << "signal " << signal;
- return os.str();
- }
+ case SIGHUP:
+ {
+ return ICE_STRING(SIGHUP);
+ }
+ case SIGINT:
+ {
+ return ICE_STRING(SIGINT);
+ }
+ case SIGQUIT:
+ {
+ return ICE_STRING(SIGQUIT);
+ }
+ case SIGILL:
+ {
+ return ICE_STRING(SIGILL);
+ }
+ case SIGTRAP:
+ {
+ return ICE_STRING(SIGTRAP);
+ }
+ case SIGABRT:
+ {
+ return ICE_STRING(SIGABRT);
+ }
+ case SIGBUS:
+ {
+ return ICE_STRING(SIGBUS);
+ }
+ case SIGFPE:
+ {
+ return ICE_STRING(SIGFPE);
+ }
+ case SIGKILL:
+ {
+ return ICE_STRING(SIGKILL);
+ }
+ case SIGUSR1:
+ {
+ return ICE_STRING(SIGUSR1);
+ }
+ case SIGSEGV:
+ {
+ return ICE_STRING(SIGSEGV);
+ }
+ case SIGPIPE:
+ {
+ return ICE_STRING(SIGPIPE);
+ }
+ case SIGALRM:
+ {
+ return ICE_STRING(SIGALRM);
+ }
+ case SIGTERM:
+ {
+ return ICE_STRING(SIGTERM);
+ }
+ default:
+ {
+ ostringstream os;
+ os << "signal " << signal;
+ return os.str();
+ }
}
#endif
}
@@ -177,77 +177,77 @@ stringToSignal(const string& str)
if(str == ICE_STRING(SIGHUP))
{
- return SIGHUP;
+ return SIGHUP;
}
else if(str == ICE_STRING(SIGINT))
{
- return SIGINT;
+ return SIGINT;
}
else if(str == ICE_STRING(SIGQUIT))
{
- return SIGQUIT;
+ return SIGQUIT;
}
else if(str == ICE_STRING(SIGILL))
{
- return SIGILL;
+ return SIGILL;
}
else if(str == ICE_STRING(SIGTRAP))
{
- return SIGTRAP;
+ return SIGTRAP;
}
else if(str == ICE_STRING(SIGABRT))
{
- return SIGABRT;
+ return SIGABRT;
}
else if(str == ICE_STRING(SIGBUS))
{
- return SIGBUS;
+ return SIGBUS;
}
else if(str == ICE_STRING(SIGFPE))
{
- return SIGFPE;
+ return SIGFPE;
}
else if(str == ICE_STRING(SIGKILL))
{
- return SIGKILL;
+ return SIGKILL;
}
else if(str == ICE_STRING(SIGUSR1))
{
- return SIGUSR1;
+ return SIGUSR1;
}
else if(str == ICE_STRING(SIGSEGV))
{
- return SIGSEGV;
+ return SIGSEGV;
}
else if(str == ICE_STRING(SIGUSR2))
{
- return SIGUSR2;
+ return SIGUSR2;
}
else if(str == ICE_STRING(SIGPIPE))
{
- return SIGPIPE;
+ return SIGPIPE;
}
else if(str == ICE_STRING(SIGALRM))
{
- return SIGALRM;
+ return SIGALRM;
}
else if(str == ICE_STRING(SIGTERM))
{
- return SIGTERM;
+ return SIGTERM;
}
else
{
- if(str != "")
- {
- char* end;
- long int signal = strtol(str.c_str(), &end, 10);
- if(*end == '\0' && signal > 0 && signal < 64)
- {
- return static_cast<int>(signal);
- }
- }
- throw BadSignalException("unknown signal `" + str + "'");
- return SIGTERM; // Keep the compiler happy.
+ if(str != "")
+ {
+ char* end;
+ long int signal = strtol(str.c_str(), &end, 10);
+ if(*end == '\0' && signal > 0 && signal < 64)
+ {
+ return static_cast<int>(signal);
+ }
+ }
+ throw BadSignalException("unknown signal `" + str + "'");
+ return SIGTERM; // Keep the compiler happy.
}
}
#endif
@@ -268,17 +268,17 @@ Activator::Activator(const TraceLevelsPtr& traceLevels) :
if(_hIntr == NULL)
{
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
#else
int fds[2];
if(pipe(fds) != 0)
{
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
_fdIntrRead = fds[0];
_fdIntrWrite = fds[1];
@@ -307,56 +307,56 @@ Activator::~Activator()
int
Activator::activate(const string& name,
- const string& exePath,
- const string& pwdPath,
+ const string& exePath,
+ const string& pwdPath,
#ifndef _WIN32
- uid_t uid,
- gid_t gid,
+ uid_t uid,
+ gid_t gid,
#endif
- const Ice::StringSeq& options,
- const Ice::StringSeq& envs,
- const ServerIPtr& server)
+ const Ice::StringSeq& options,
+ const Ice::StringSeq& envs,
+ const ServerIPtr& server)
{
IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
if(_deactivating)
{
- throw string("The node is being shutdown.");
+ throw string("The node is being shutdown.");
}
string path = exePath;
if(path.empty())
{
- throw string("The server executable path is empty.");
+ throw string("The server executable path is empty.");
}
string pwd = IcePatch2::simplify(pwdPath);
#ifdef _WIN32
if(!IcePatch2::isAbsolute(path))
{
- if(path.find('/') == string::npos)
- {
- //
- // Get the absolute pathname of the executable.
- //
- char absbuf[_MAX_PATH];
- char* filePart;
- string ext = path.size() <= 4 || path[path.size() - 4] != '.' ? ".exe" : "";
- if(SearchPath(NULL, path.c_str(), ext.c_str(), _MAX_PATH, absbuf, &filePart) == 0)
- {
- if(_traceLevels->activator > 0)
- {
- Trace out(_traceLevels->logger, _traceLevels->activatorCat);
- out << "cannot convert `" << path << "' into an absolute path";
- }
- throw string("The server executable path `" + path + "' can't be converted into an absolute path.");
- }
- path = absbuf;
- }
- else if(!pwd.empty())
- {
- path = pwd + "/" + path;
- }
+ if(path.find('/') == string::npos)
+ {
+ //
+ // Get the absolute pathname of the executable.
+ //
+ char absbuf[_MAX_PATH];
+ char* filePart;
+ string ext = path.size() <= 4 || path[path.size() - 4] != '.' ? ".exe" : "";
+ if(SearchPath(NULL, path.c_str(), ext.c_str(), _MAX_PATH, absbuf, &filePart) == 0)
+ {
+ if(_traceLevels->activator > 0)
+ {
+ Trace out(_traceLevels->logger, _traceLevels->activatorCat);
+ out << "cannot convert `" << path << "' into an absolute path";
+ }
+ throw string("The server executable path `" + path + "' can't be converted into an absolute path.");
+ }
+ path = absbuf;
+ }
+ else if(!pwd.empty())
+ {
+ path = pwd + "/" + path;
+ }
}
//
@@ -364,17 +364,17 @@ Activator::activate(const string& name,
//
if(!pwd.empty())
{
- char absbuf[_MAX_PATH];
- if(_fullpath(absbuf, pwd.c_str(), _MAX_PATH) == NULL)
- {
- if(_traceLevels->activator > 0)
- {
- Trace out(_traceLevels->logger, _traceLevels->activatorCat);
- out << "cannot convert `" << pwd << "' into an absolute path";
- }
- throw string("The server working directory path `" + pwd + "' can't be converted into an absolute path.");
- }
- pwd = absbuf;
+ char absbuf[_MAX_PATH];
+ if(_fullpath(absbuf, pwd.c_str(), _MAX_PATH) == NULL)
+ {
+ if(_traceLevels->activator > 0)
+ {
+ Trace out(_traceLevels->logger, _traceLevels->activatorCat);
+ out << "cannot convert `" << pwd << "' into an absolute path";
+ }
+ throw string("The server working directory path `" + pwd + "' can't be converted into an absolute path.");
+ }
+ pwd = absbuf;
}
#endif
@@ -387,41 +387,41 @@ Activator::activate(const string& name,
if(_traceLevels->activator > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
- out << "activating server `" << name << "'";
- if(_traceLevels->activator > 1)
- {
- out << "\n";
- out << "path = " << path << "\n";
- if(pwd.empty())
- {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
+ out << "activating server `" << name << "'";
+ if(_traceLevels->activator > 1)
+ {
+ out << "\n";
+ out << "path = " << path << "\n";
+ if(pwd.empty())
+ {
#ifdef _WIN32
- char cwd[_MAX_PATH];
- if(_getcwd(cwd, _MAX_PATH) != NULL)
+ char cwd[_MAX_PATH];
+ if(_getcwd(cwd, _MAX_PATH) != NULL)
#else
- char cwd[PATH_MAX];
- if(getcwd(cwd, PATH_MAX) != NULL)
+ char cwd[PATH_MAX];
+ if(getcwd(cwd, PATH_MAX) != NULL)
#endif
- {
- out << "pwd = " << string(cwd) << "\n";
- }
- }
- else
- {
- out << "pwd = " << pwd << "\n";
- }
+ {
+ out << "pwd = " << string(cwd) << "\n";
+ }
+ }
+ else
+ {
+ out << "pwd = " << pwd << "\n";
+ }
#ifndef _WIN32
- out << "uid/gid = " << uid << "/" << gid << "\n";
+ out << "uid/gid = " << uid << "/" << gid << "\n";
#endif
- if(!envs.empty())
- {
- out << "envs = " << toString(envs, ", ") << "\n";
- }
- if(!args.empty())
- {
- out << "args = " << toString(args);
- }
- }
+ if(!envs.empty())
+ {
+ out << "envs = " << toString(envs, ", ") << "\n";
+ }
+ if(!args.empty())
+ {
+ out << "args = " << toString(args);
+ }
+ }
}
//
@@ -500,8 +500,8 @@ Activator::activate(const string& name,
string::size_type pos = s.find('=');
if(pos != string::npos)
{
- string key = s.substr(0, pos);
- std::transform(key.begin(), key.end(), key.begin(), toupper);
+ string key = s.substr(0, pos);
+ std::transform(key.begin(), key.end(), key.begin(), toupper);
envMap.insert(map<string, string>::value_type(key, s.substr(pos + 1)));
}
var += s.size();
@@ -514,9 +514,9 @@ Activator::activate(const string& name,
string::size_type pos = s.find('=');
if(pos != string::npos)
{
- string key = s.substr(0, pos);
- std::transform(key.begin(), key.end(), key.begin(), toupper);
- envMap.erase(key);
+ string key = s.substr(0, pos);
+ std::transform(key.begin(), key.end(), key.begin(), toupper);
+ envMap.erase(key);
envMap.insert(map<string, string>::value_type(key, s.substr(pos + 1)));
}
}
@@ -591,9 +591,9 @@ Activator::activate(const string& name,
int fds[2];
if(pipe(fds) != 0)
{
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
//
@@ -604,8 +604,8 @@ Activator::activate(const string& name,
int i = 0;
for(StringSeq::const_iterator p = args.begin(); p != args.end(); ++p, ++i)
{
- assert(i < argc);
- argv[i] = strdup(p->c_str());
+ assert(i < argc);
+ argv[i] = strdup(p->c_str());
}
assert(i == argc);
argv[argc] = 0;
@@ -615,7 +615,7 @@ Activator::activate(const string& name,
i = 0;
for(StringSeq::const_iterator q = envs.begin(); q != envs.end(); ++q)
{
- envArray[i++] = strdup(q->c_str());
+ envArray[i++] = strdup(q->c_str());
}
//
@@ -626,118 +626,118 @@ Activator::activate(const string& name,
pid_t pid = fork();
if(pid == -1)
{
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
if(pid == 0) // Child process.
{
- //
- // Until exec, we can only use async-signal safe functions
- //
-
- //
- // Change the uid/gid under which the process will run.
- //
- if(setgid(gid) == -1)
- {
- ostringstream os;
- os << gid;
- reportChildError(getSystemErrno(), fds[1], "cannot set process group id", os.str().c_str());
- }
-
- if(setuid(uid) == -1)
- {
- ostringstream os;
- os << uid;
- reportChildError(getSystemErrno(), fds[1], "cannot set process user id", os.str().c_str());
- }
-
- //
- // Assign a new process group for this process.
- //
- setpgid(0, 0);
-
- //
- // Close all file descriptors, except for standard input,
- // standard output, standard error, and the write side
- // of the newly created pipe.
- //
- int maxFd = static_cast<int>(sysconf(_SC_OPEN_MAX));
- for(int fd = 3; fd < maxFd; ++fd)
- {
- if(fd != fds[1])
- {
- close(fd);
- }
- }
-
- for(i = 0; i < envCount; i++)
- {
- if(putenv(envArray[i]) != 0)
- {
- reportChildError(errno, fds[1], "cannot set environment variable", envArray[i]);
- }
- }
- //
- // Each env is leaked on purpose ... see man putenv().
- //
- delete[] envArray;
-
- //
- // Change working directory.
- //
- if(strlen(pwdCStr) != 0)
- {
- if(chdir(pwdCStr) == -1)
- {
- reportChildError(errno, fds[1], "cannot change working directory to", pwdCStr);
- }
- }
-
- if(execvp(argv[0], argv) == -1)
- {
- reportChildError(errno, fds[1], "cannot execute", argv[0]);
- }
+ //
+ // Until exec, we can only use async-signal safe functions
+ //
+
+ //
+ // Change the uid/gid under which the process will run.
+ //
+ if(setgid(gid) == -1)
+ {
+ ostringstream os;
+ os << gid;
+ reportChildError(getSystemErrno(), fds[1], "cannot set process group id", os.str().c_str());
+ }
+
+ if(setuid(uid) == -1)
+ {
+ ostringstream os;
+ os << uid;
+ reportChildError(getSystemErrno(), fds[1], "cannot set process user id", os.str().c_str());
+ }
+
+ //
+ // Assign a new process group for this process.
+ //
+ setpgid(0, 0);
+
+ //
+ // Close all file descriptors, except for standard input,
+ // standard output, standard error, and the write side
+ // of the newly created pipe.
+ //
+ int maxFd = static_cast<int>(sysconf(_SC_OPEN_MAX));
+ for(int fd = 3; fd < maxFd; ++fd)
+ {
+ if(fd != fds[1])
+ {
+ close(fd);
+ }
+ }
+
+ for(i = 0; i < envCount; i++)
+ {
+ if(putenv(envArray[i]) != 0)
+ {
+ reportChildError(errno, fds[1], "cannot set environment variable", envArray[i]);
+ }
+ }
+ //
+ // Each env is leaked on purpose ... see man putenv().
+ //
+ delete[] envArray;
+
+ //
+ // Change working directory.
+ //
+ if(strlen(pwdCStr) != 0)
+ {
+ if(chdir(pwdCStr) == -1)
+ {
+ reportChildError(errno, fds[1], "cannot change working directory to", pwdCStr);
+ }
+ }
+
+ if(execvp(argv[0], argv) == -1)
+ {
+ reportChildError(errno, fds[1], "cannot execute", argv[0]);
+ }
}
else // Parent process.
{
- close(fds[1]);
-
- for(i = 0; argv[i]; i++)
- {
- free(argv[i]);
- }
- free(argv);
-
- for(i = 0; i < envCount; ++i)
- {
- free(envArray[i]);
- }
- delete[] envArray;
-
- Process process;
- process.pid = pid;
- process.pipeFd = fds[0];
- process.server = server;
- _processes.insert(make_pair(name, process));
-
- int flags = fcntl(process.pipeFd, F_GETFL);
- flags |= O_NONBLOCK;
- fcntl(process.pipeFd, F_SETFL, flags);
-
- setInterrupt();
+ close(fds[1]);
+
+ for(i = 0; argv[i]; i++)
+ {
+ free(argv[i]);
+ }
+ free(argv);
+
+ for(i = 0; i < envCount; ++i)
+ {
+ free(envArray[i]);
+ }
+ delete[] envArray;
+
+ Process process;
+ process.pid = pid;
+ process.pipeFd = fds[0];
+ process.server = server;
+ _processes.insert(make_pair(name, process));
+
+ int flags = fcntl(process.pipeFd, F_GETFL);
+ flags |= O_NONBLOCK;
+ fcntl(process.pipeFd, F_SETFL, flags);
+
+ setInterrupt();
//
// Don't print the following trace, this might interfere with the
// output of the started process if it fails with an error message.
//
-// if(_traceLevels->activator > 0)
-// {
-// Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
-// out << "activated server `" << name << "' (pid = " << pid << ")";
-// }
+// if(_traceLevels->activator > 0)
+// {
+// Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
+// out << "activated server `" << name << "' (pid = " << pid << ")";
+// }
}
return pid;
@@ -751,10 +751,10 @@ Activator::deactivate(const string& name, const Ice::ProcessPrx& process)
Ice::Int pid = getServerPid(name);
if(pid == 0)
{
- //
- // Server is already deactivated.
- //
- return;
+ //
+ // Server is already deactivated.
+ //
+ return;
}
#endif
@@ -763,21 +763,21 @@ Activator::deactivate(const string& name, const Ice::ProcessPrx& process)
//
if(process)
{
- if(_traceLevels->activator > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
- out << "deactivating `" << name << "' using process proxy";
- }
- try
- {
- process->shutdown();
- return;
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Warning out(_traceLevels->logger);
- out << "exception occurred while deactivating `" << name << "' using process proxy:\n" << ex;
- }
+ if(_traceLevels->activator > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
+ out << "deactivating `" << name << "' using process proxy";
+ }
+ try
+ {
+ process->shutdown();
+ return;
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_traceLevels->logger);
+ out << "exception occurred while deactivating `" << name << "' using process proxy:\n" << ex;
+ }
}
if(_traceLevels->activator > 1)
@@ -820,10 +820,10 @@ Activator::kill(const string& name)
Ice::Int pid = getServerPid(name);
if(pid == 0)
{
- //
- // Server is already deactivated.
- //
- return;
+ //
+ // Server is already deactivated.
+ //
+ return;
}
HANDLE hnd = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
@@ -840,8 +840,8 @@ Activator::kill(const string& name)
if(_traceLevels->activator > 1)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
- out << "terminating server `" << name << "' (pid = " << pid << ")";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
+ out << "terminating server `" << name << "' (pid = " << pid << ")";
}
#else
@@ -869,24 +869,24 @@ Activator::sendSignal(const string& name, int signal)
Ice::Int pid = getServerPid(name);
if(pid == 0)
{
- //
- // Server is already deactivated.
- //
- return;
+ //
+ // Server is already deactivated.
+ //
+ return;
}
int ret = ::kill(static_cast<pid_t>(pid), signal);
if(ret != 0 && getSystemErrno() != ESRCH)
{
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
if(_traceLevels->activator > 1)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
- out << "sent " << signalToString(signal) << " to server `" << name << "' (pid = " << pid << ")";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
+ out << "sent " << signalToString(signal) << " to server `" << name << "' (pid = " << pid << ")";
}
#endif
}
@@ -899,7 +899,7 @@ Activator::getServerPid(const string& name)
map<string, Process>::const_iterator p = _processes.find(name);
if(p == _processes.end())
{
- return 0;
+ return 0;
}
return static_cast<Ice::Int>(p->second.pid);
@@ -921,7 +921,7 @@ Activator::waitForShutdown()
IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
while(!_deactivating)
{
- wait();
+ wait();
}
}
@@ -945,9 +945,9 @@ Activator::destroy()
{
map<string, Process> processes;
{
- IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
- assert(_deactivating);
- processes = _processes;
+ IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
+ assert(_deactivating);
+ processes = _processes;
}
//
@@ -955,30 +955,30 @@ Activator::destroy()
//
for(map<string, Process>::iterator p = processes.begin(); p != processes.end(); ++p)
{
- //
- // Stop the server. The listener thread should detect the
- // process deactivation and remove it from the activator's
- // list of active processes.
- //
- try
- {
- p->second.server->stop_async(0);
- }
- catch(const ServerStopException&)
- {
- // Server already stopped or destroyed.
- }
- catch(const ObjectNotExistException&)
- {
- //
- // Expected if the server was in the process of being destroyed.
- //
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Warning out(_traceLevels->logger);
- out << "unexpected exception raised by server `" << p->first << "' stop:\n" << ex;
- }
+ //
+ // Stop the server. The listener thread should detect the
+ // process deactivation and remove it from the activator's
+ // list of active processes.
+ //
+ try
+ {
+ p->second.server->stop_async(0);
+ }
+ catch(const ServerStopException&)
+ {
+ // Server already stopped or destroyed.
+ }
+ catch(const ObjectNotExistException&)
+ {
+ //
+ // Expected if the server was in the process of being destroyed.
+ //
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_traceLevels->logger);
+ out << "unexpected exception raised by server `" << p->first << "' stop:\n" << ex;
+ }
}
//
@@ -996,21 +996,21 @@ Activator::runTerminationListener()
{
while(true)
{
- try
- {
- terminationListener();
- break;
- }
- catch(const Exception& ex)
- {
- Error out(_traceLevels->logger);
- out << "exception in process termination listener:\n" << ex;
- }
- catch(...)
- {
- Error out(_traceLevels->logger);
- out << "unknown exception in process termination listener";
- }
+ try
+ {
+ terminationListener();
+ break;
+ }
+ catch(const Exception& ex)
+ {
+ Error out(_traceLevels->logger);
+ out << "exception in process termination listener:\n" << ex;
+ }
+ catch(...)
+ {
+ Error out(_traceLevels->logger);
+ out << "unknown exception in process termination listener";
+ }
}
}
@@ -1051,60 +1051,60 @@ Activator::terminationListener()
assert(pos < handles.size());
HANDLE hnd = handles[pos];
- vector<Process> terminated;
- bool deactivated = false;
- {
- IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
-
- if(hnd == _hIntr)
- {
- clearInterrupt();
- }
- else
- {
- for(map<string, Process>::iterator p = _processes.begin(); p != _processes.end(); ++p)
- {
- if(p->second.hnd == hnd)
- {
- terminated.push_back(p->second);
- _processes.erase(p);
- break;
- }
- }
+ vector<Process> terminated;
+ bool deactivated = false;
+ {
+ IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
+
+ if(hnd == _hIntr)
+ {
+ clearInterrupt();
+ }
+ else
+ {
+ for(map<string, Process>::iterator p = _processes.begin(); p != _processes.end(); ++p)
+ {
+ if(p->second.hnd == hnd)
+ {
+ terminated.push_back(p->second);
+ _processes.erase(p);
+ break;
+ }
+ }
+ }
+
+ deactivated = _deactivating && _processes.empty();
+ }
+
+ for(vector<Process>::const_iterator p = terminated.begin(); p != terminated.end(); ++p)
+ {
+ DWORD status;
+ GetExitCodeProcess(p->hnd, &status);
+ CloseHandle(p->hnd);
+ assert(status != STILL_ACTIVE);
+
+ if(_traceLevels->activator > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
+ out << "detected termination of server `" << p->server->getId() << "'";
+ if(status != 0)
+ {
+ out << "\nexit code = " << status;
+ }
+ }
+
+ try
+ {
+ p->server->terminated("", status);
}
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_traceLevels->logger);
+ out << "unexpected exception raised by server `" << p->server->getId() << "' termination:\n" << ex;
+ }
+ }
- deactivated = _deactivating && _processes.empty();
- }
-
- for(vector<Process>::const_iterator p = terminated.begin(); p != terminated.end(); ++p)
- {
- DWORD status;
- GetExitCodeProcess(p->hnd, &status);
- CloseHandle(p->hnd);
- assert(status != STILL_ACTIVE);
-
- if(_traceLevels->activator > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
- out << "detected termination of server `" << p->server->getId() << "'";
- if(status != 0)
- {
- out << "\nexit code = " << status;
- }
- }
-
- try
- {
- p->server->terminated("", status);
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Warning out(_traceLevels->logger);
- out << "unexpected exception raised by server `" << p->server->getId() << "' termination:\n" << ex;
- }
- }
-
- if(deactivated)
+ if(deactivated)
{
return;
}
@@ -1112,197 +1112,197 @@ Activator::terminationListener()
#else
while(true)
{
- fd_set fdSet;
- int maxFd = _fdIntrRead;
- FD_ZERO(&fdSet);
- FD_SET(_fdIntrRead, &fdSet);
-
- {
- IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
-
- for(map<string, Process>::iterator p = _processes.begin(); p != _processes.end(); ++p)
- {
- int fd = p->second.pipeFd;
- FD_SET(fd, &fdSet);
- if(maxFd < fd)
- {
- maxFd = fd;
- }
- }
- }
-
+ fd_set fdSet;
+ int maxFd = _fdIntrRead;
+ FD_ZERO(&fdSet);
+ FD_SET(_fdIntrRead, &fdSet);
+
+ {
+ IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
+
+ for(map<string, Process>::iterator p = _processes.begin(); p != _processes.end(); ++p)
+ {
+ int fd = p->second.pipeFd;
+ FD_SET(fd, &fdSet);
+ if(maxFd < fd)
+ {
+ maxFd = fd;
+ }
+ }
+ }
+
repeatSelect:
- int ret = ::select(maxFd + 1, &fdSet, 0, 0, 0);
- assert(ret != 0);
-
- if(ret == -1)
- {
+ int ret = ::select(maxFd + 1, &fdSet, 0, 0, 0);
+ assert(ret != 0);
+
+ if(ret == -1)
+ {
#ifdef EPROTO
- if(errno == EINTR || errno == EPROTO)
- {
- goto repeatSelect;
- }
+ if(errno == EINTR || errno == EPROTO)
+ {
+ goto repeatSelect;
+ }
#else
- if(errno == EINTR)
- {
- goto repeatSelect;
- }
+ if(errno == EINTR)
+ {
+ goto repeatSelect;
+ }
#endif
-
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
- }
-
- vector<Process> terminated;
- bool deactivated = false;
- {
- IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
-
- if(FD_ISSET(_fdIntrRead, &fdSet))
- {
- clearInterrupt();
-
- if(_deactivating && _processes.empty())
+
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+
+ vector<Process> terminated;
+ bool deactivated = false;
+ {
+ IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
+
+ if(FD_ISSET(_fdIntrRead, &fdSet))
+ {
+ clearInterrupt();
+
+ if(_deactivating && _processes.empty())
{
return;
}
- }
-
- map<string, Process>::iterator p = _processes.begin();
- while(p != _processes.end())
- {
- int fd = p->second.pipeFd;
- if(!FD_ISSET(fd, &fdSet))
- {
- ++p;
- continue;
- }
-
- char s[16];
- ssize_t rs;
- string message;
-
- //
- // Read the message over the pipe.
- //
- while((rs = read(fd, &s, 16)) > 0)
- {
- message.append(s, rs);
- }
-
- //
- // Keep the received message.
- //
- if(!message.empty())
- {
- p->second.msg += message;
- }
-
- if(rs == -1)
- {
- if(errno != EAGAIN || message.empty())
- {
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
- }
-
- ++p;
- }
- else if(rs == 0)
- {
- //
- // If the pipe was closed, the process has terminated.
- //
-
- terminated.push_back(p->second);
+ }
+
+ map<string, Process>::iterator p = _processes.begin();
+ while(p != _processes.end())
+ {
+ int fd = p->second.pipeFd;
+ if(!FD_ISSET(fd, &fdSet))
+ {
+ ++p;
+ continue;
+ }
+
+ char s[16];
+ ssize_t rs;
+ string message;
+
+ //
+ // Read the message over the pipe.
+ //
+ while((rs = read(fd, &s, 16)) > 0)
+ {
+ message.append(s, rs);
+ }
+
+ //
+ // Keep the received message.
+ //
+ if(!message.empty())
+ {
+ p->second.msg += message;
+ }
+
+ if(rs == -1)
+ {
+ if(errno != EAGAIN || message.empty())
+ {
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+
+ ++p;
+ }
+ else if(rs == 0)
+ {
+ //
+ // If the pipe was closed, the process has terminated.
+ //
+
+ terminated.push_back(p->second);
- close(p->second.pipeFd);
- _processes.erase(p++);
- }
- }
-
- //
- // We are deactivating and there's no more active processes.
- //
- deactivated = _deactivating && _processes.empty();
- }
-
- for(vector<Process>::const_iterator p = terminated.begin(); p != terminated.end(); ++p)
- {
- int status;
+ close(p->second.pipeFd);
+ _processes.erase(p++);
+ }
+ }
+
+ //
+ // We are deactivating and there's no more active processes.
+ //
+ deactivated = _deactivating && _processes.empty();
+ }
+
+ for(vector<Process>::const_iterator p = terminated.begin(); p != terminated.end(); ++p)
+ {
+ int status;
#if defined(__linux)
- int nRetry = 0;
- while(true) // The while loop is necessary for the linux workaround.
- {
- pid_t pid = waitpid(p->pid, &status, 0);
- if(pid < 0)
- {
- //
- // Some Linux distribution have a bogus waitpid() (e.g.: CentOS 4.x). It doesn't
- // block and reports an incorrect ECHILD error on the first call. We sleep a
- // little and retry to work around this issue (it appears from testing that a
- // single retry is enough but to make sure we retry up to 10 times before to throw.)
- //
- if(errno == ECHILD && nRetry < 10)
- {
- // Wait 1ms, 11ms, 21ms, etc.
- IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(nRetry * 10 + 1));
- ++nRetry;
- continue;
- }
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
- }
- assert(pid == p->pid);
- break;
- }
+ int nRetry = 0;
+ while(true) // The while loop is necessary for the linux workaround.
+ {
+ pid_t pid = waitpid(p->pid, &status, 0);
+ if(pid < 0)
+ {
+ //
+ // Some Linux distribution have a bogus waitpid() (e.g.: CentOS 4.x). It doesn't
+ // block and reports an incorrect ECHILD error on the first call. We sleep a
+ // little and retry to work around this issue (it appears from testing that a
+ // single retry is enough but to make sure we retry up to 10 times before to throw.)
+ //
+ if(errno == ECHILD && nRetry < 10)
+ {
+ // Wait 1ms, 11ms, 21ms, etc.
+ IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(nRetry * 10 + 1));
+ ++nRetry;
+ continue;
+ }
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+ assert(pid == p->pid);
+ break;
+ }
#else
- pid_t pid = waitpid(p->pid, &status, 0);
- if(pid < 0)
- {
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
- }
- assert(pid == p->pid);
+ pid_t pid = waitpid(p->pid, &status, 0);
+ if(pid < 0)
+ {
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+ assert(pid == p->pid);
#endif
- if(_traceLevels->activator > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
- out << "detected termination of server `" << p->server->getId() << "'";
- if(!p->msg.empty())
- {
- out << "\nreason = " << p->msg;
- }
- if(WIFEXITED(status) && status != 0)
- {
- out << "\nexit code = " << WEXITSTATUS(status);
- }
- else if(WIFSIGNALED(status))
- {
- out << "\nsignal = " << signalToString(WTERMSIG(status));
- }
- }
-
- try
- {
- p->server->terminated(p->msg, status);
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Warning out(_traceLevels->logger);
- out << "unexpected exception raised by server `" << p->server->getId() << "' termination:\n" << ex;
- }
- }
-
- if(deactivated)
- {
- return;
- }
+ if(_traceLevels->activator > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
+ out << "detected termination of server `" << p->server->getId() << "'";
+ if(!p->msg.empty())
+ {
+ out << "\nreason = " << p->msg;
+ }
+ if(WIFEXITED(status) && status != 0)
+ {
+ out << "\nexit code = " << WEXITSTATUS(status);
+ }
+ else if(WIFSIGNALED(status))
+ {
+ out << "\nsignal = " << signalToString(WTERMSIG(status));
+ }
+ }
+
+ try
+ {
+ p->server->terminated(p->msg, status);
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_traceLevels->logger);
+ out << "unexpected exception raised by server `" << p->server->getId() << "' termination:\n" << ex;
+ }
+ }
+
+ if(deactivated)
+ {
+ return;
+ }
}
#endif
}
diff --git a/cpp/src/IceGrid/Activator.h b/cpp/src/IceGrid/Activator.h
index 40c7a9b3878..24a2b60f800 100644
--- a/cpp/src/IceGrid/Activator.h
+++ b/cpp/src/IceGrid/Activator.h
@@ -37,9 +37,9 @@ public:
virtual int activate(const std::string&, const std::string&, const std::string&,
#ifndef _WIN32
- uid_t, gid_t,
+ uid_t, gid_t,
#endif
- const Ice::StringSeq&, const Ice::StringSeq&, const ServerIPtr&);
+ const Ice::StringSeq&, const Ice::StringSeq&, const ServerIPtr&);
virtual void deactivate(const std::string&, const Ice::ProcessPrx&);
virtual void kill(const std::string&);
virtual void sendSignal(const std::string&, const std::string&);
@@ -67,11 +67,11 @@ private:
DWORD pid;
HANDLE hnd;
#else
- pid_t pid;
- int pipeFd;
- std::string msg;
+ pid_t pid;
+ int pipeFd;
+ std::string msg;
#endif
- ServerIPtr server;
+ ServerIPtr server;
};
TraceLevelsPtr _traceLevels;
diff --git a/cpp/src/IceGrid/AdapterCache.cpp b/cpp/src/IceGrid/AdapterCache.cpp
index 5ebd4ba6c8d..64d235bacea 100644
--- a/cpp/src/IceGrid/AdapterCache.cpp
+++ b/cpp/src/IceGrid/AdapterCache.cpp
@@ -28,7 +28,7 @@ struct ReplicaLoadComp : binary_function<ServerAdapterEntryPtr&, ServerAdapterEn
{
bool operator()(const pair<float, ServerAdapterEntryPtr>& lhs, const pair<float, ServerAdapterEntryPtr>& rhs)
{
- return lhs.first < rhs.first;
+ return lhs.first < rhs.first;
}
};
@@ -36,12 +36,12 @@ struct ReplicaPriorityComp : binary_function<ServerAdapterEntryPtr&, ServerAdapt
{
bool operator()(const ServerAdapterEntryPtr& lhs, const ServerAdapterEntryPtr& rhs)
{
- return lhs->getPriority() < rhs->getPriority();
+ return lhs->getPriority() < rhs->getPriority();
}
};
struct TransformToReplicaLoad :
- public unary_function<const ServerAdapterEntryPtr&, pair<float, ServerAdapterEntryPtr> >
+ public unary_function<const ServerAdapterEntryPtr&, pair<float, ServerAdapterEntryPtr> >
{
public:
@@ -50,7 +50,7 @@ public:
pair<float, ServerAdapterEntryPtr>
operator()(const ServerAdapterEntryPtr& value)
{
- return make_pair(value->getLeastLoadedNodeLoad(_loadSample), value);
+ return make_pair(value->getLeastLoadedNodeLoad(_loadSample), value);
}
LoadSample _loadSample;
@@ -61,7 +61,7 @@ struct TransformToReplica : public unary_function<const pair<string, ServerAdapt
ServerAdapterEntryPtr
operator()(const pair<float, ServerAdapterEntryPtr>& value)
{
- return value.second;
+ return value.second;
}
};
@@ -82,9 +82,9 @@ AdapterCache::addServerAdapter(const AdapterDescriptor& desc, const ServerEntryP
if(!desc.replicaGroupId.empty())
{
- ReplicaGroupEntryPtr repEntry = ReplicaGroupEntryPtr::dynamicCast(getImpl(desc.replicaGroupId));
- assert(repEntry);
- repEntry->addReplica(desc.id, entry);
+ ReplicaGroupEntryPtr repEntry = ReplicaGroupEntryPtr::dynamicCast(getImpl(desc.replicaGroupId));
+ assert(repEntry);
+ repEntry->addReplica(desc.id, entry);
}
return entry;
@@ -107,7 +107,7 @@ AdapterCache::get(const string& id) const
AdapterEntryPtr entry = getImpl(id);
if(!entry)
{
- throw AdapterNotExistException(id);
+ throw AdapterNotExistException(id);
}
return entry;
}
@@ -124,9 +124,9 @@ AdapterCache::removeServerAdapter(const string& id)
string replicaGroupId = entry->getReplicaGroupId();
if(!replicaGroupId.empty())
{
- ReplicaGroupEntryPtr repEntry = ReplicaGroupEntryPtr::dynamicCast(getImpl(replicaGroupId));
- assert(repEntry);
- repEntry->removeReplica(id);
+ ReplicaGroupEntryPtr repEntry = ReplicaGroupEntryPtr::dynamicCast(getImpl(replicaGroupId));
+ assert(repEntry);
+ repEntry->removeReplica(id);
}
}
@@ -142,8 +142,8 @@ AdapterCache::addImpl(const string& id, const AdapterEntryPtr& entry)
{
if(_traceLevels && _traceLevels->adapter > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
- out << "added adapter `" << id << "'";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
+ out << "added adapter `" << id << "'";
}
return Cache<string, AdapterEntry>::addImpl(id, entry);
}
@@ -153,8 +153,8 @@ AdapterCache::removeImpl(const string& id)
{
if(_traceLevels && _traceLevels->adapter > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
- out << "removed adapter `" << id << "'";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
+ out << "removed adapter `" << id << "'";
}
Cache<string, AdapterEntry>::removeImpl(id);
}
@@ -185,11 +185,11 @@ AdapterEntry::getApplication() const
}
ServerAdapterEntry::ServerAdapterEntry(AdapterCache& cache,
- const string& id,
- const string& application,
- const string& replicaGroupId,
- int priority,
- const ServerEntryPtr& server) :
+ const string& id,
+ const string& application,
+ const string& replicaGroupId,
+ int priority,
+ const ServerEntryPtr& server) :
AdapterEntry(cache, id, application),
_replicaGroupId(replicaGroupId),
_priority(priority),
@@ -213,23 +213,23 @@ ServerAdapterEntry::getLeastLoadedNodeLoad(LoadSample loadSample) const
{
try
{
- return _server->getLoad(loadSample);
+ return _server->getLoad(loadSample);
}
catch(const ServerNotExistException&)
{
- // This might happen if the application is updated concurrently.
+ // This might happen if the application is updated concurrently.
}
catch(const NodeNotExistException&)
{
- // This might happen if the application is updated concurrently.
+ // This might happen if the application is updated concurrently.
}
catch(const NodeUnreachableException&)
{
}
catch(const Ice::Exception& ex)
{
- Ice::Error error(_cache.getTraceLevels()->logger);
- error << "unexpected exception while getting node load:\n" << ex;
+ Ice::Error error(_cache.getTraceLevels()->logger);
+ error << "unexpected exception while getting node load:\n" << ex;
}
return 999.9f;
}
@@ -242,7 +242,7 @@ ServerAdapterEntry::getAdapterInfo() const
info.replicaGroupId = _replicaGroupId;
try
{
- info.proxy = _server->getAdapter(_id, true)->getDirectProxy();
+ info.proxy = _server->getAdapter(_id, true)->getDirectProxy();
}
catch(const Ice::Exception&)
{
@@ -257,15 +257,15 @@ ServerAdapterEntry::getProxy(const string& replicaGroupId, bool upToDate) const
{
if(replicaGroupId.empty())
{
- return _server->getAdapter(_id, upToDate);
+ return _server->getAdapter(_id, upToDate);
}
else
{
- if(_replicaGroupId != replicaGroupId) // Validate the replica group.
- {
- throw Ice::InvalidReplicaGroupIdException();
- }
- return _server->getAdapter(_id, upToDate);
+ if(_replicaGroupId != replicaGroupId) // Validate the replica group.
+ {
+ throw Ice::InvalidReplicaGroupIdException();
+ }
+ return _server->getAdapter(_id, upToDate);
}
}
@@ -276,9 +276,9 @@ ServerAdapterEntry::getPriority() const
}
ReplicaGroupEntry::ReplicaGroupEntry(AdapterCache& cache,
- const string& id,
- const string& application,
- const LoadBalancingPolicyPtr& policy) :
+ const string& id,
+ const string& application,
+ const LoadBalancingPolicyPtr& policy) :
AdapterEntry(cache, id, application),
_lastReplica(0)
{
@@ -298,13 +298,13 @@ ReplicaGroupEntry::removeReplica(const string& replicaId)
Lock sync(*this);
for(vector<ServerAdapterEntryPtr>::iterator p = _replicas.begin(); p != _replicas.end(); ++p)
{
- if(replicaId == (*p)->getId())
- {
- _replicas.erase(p);
- // Make sure _lastReplica is still within the bounds.
- _lastReplica = _replicas.empty() ? 0 : _lastReplica % static_cast<int>(_replicas.size());
- break;
- }
+ if(replicaId == (*p)->getId())
+ {
+ _replicas.erase(p);
+ // Make sure _lastReplica is still within the bounds.
+ _lastReplica = _replicas.empty() ? 0 : _lastReplica % static_cast<int>(_replicas.size());
+ break;
+ }
}
}
@@ -323,22 +323,22 @@ ReplicaGroupEntry::update(const LoadBalancingPolicyPtr& policy)
AdaptiveLoadBalancingPolicyPtr alb = AdaptiveLoadBalancingPolicyPtr::dynamicCast(_loadBalancing);
if(alb)
{
- if(alb->loadSample == "1")
- {
- _loadSample = LoadSample1;
- }
- else if(alb->loadSample == "5")
- {
- _loadSample = LoadSample5;
- }
- else if(alb->loadSample == "15")
- {
- _loadSample = LoadSample15;
- }
- else
- {
- _loadSample = LoadSample1;
- }
+ if(alb->loadSample == "1")
+ {
+ _loadSample = LoadSample1;
+ }
+ else if(alb->loadSample == "5")
+ {
+ _loadSample = LoadSample5;
+ }
+ else if(alb->loadSample == "15")
+ {
+ _loadSample = LoadSample15;
+ }
+ else
+ {
+ _loadSample = LoadSample1;
+ }
}
}
@@ -349,59 +349,59 @@ ReplicaGroupEntry::getLocatorAdapterInfo(LocatorAdapterInfoSeq& adapters, int& n
bool adaptive = false;
LoadSample loadSample = LoadSample1;
{
- Lock sync(*this);
- replicaGroup = true;
- nReplicas = _loadBalancingNReplicas > 0 ? _loadBalancingNReplicas : static_cast<int>(_replicas.size());
-
- if(_replicas.empty())
- {
- return;
- }
-
- replicas.reserve(_replicas.size());
- if(RoundRobinLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
- {
- for(unsigned int i = 0; i < _replicas.size(); ++i)
- {
- replicas.push_back(_replicas[(_lastReplica + i) % _replicas.size()]);
- }
- _lastReplica = (_lastReplica + 1) % static_cast<int>(_replicas.size());
- }
- else if(AdaptiveLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
- {
- replicas = _replicas;
- RandomNumberGenerator rng;
- random_shuffle(replicas.begin(), replicas.end(), rng);
- loadSample = _loadSample;
- adaptive = true;
- }
- else if(OrderedLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
- {
- replicas = _replicas;
- sort(replicas.begin(), replicas.end(), ReplicaPriorityComp());
- }
- else if(RandomLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
- {
- replicas = _replicas;
- RandomNumberGenerator rng;
- random_shuffle(replicas.begin(), replicas.end(), rng);
- }
+ Lock sync(*this);
+ replicaGroup = true;
+ nReplicas = _loadBalancingNReplicas > 0 ? _loadBalancingNReplicas : static_cast<int>(_replicas.size());
+
+ if(_replicas.empty())
+ {
+ return;
+ }
+
+ replicas.reserve(_replicas.size());
+ if(RoundRobinLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
+ {
+ for(unsigned int i = 0; i < _replicas.size(); ++i)
+ {
+ replicas.push_back(_replicas[(_lastReplica + i) % _replicas.size()]);
+ }
+ _lastReplica = (_lastReplica + 1) % static_cast<int>(_replicas.size());
+ }
+ else if(AdaptiveLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
+ {
+ replicas = _replicas;
+ RandomNumberGenerator rng;
+ random_shuffle(replicas.begin(), replicas.end(), rng);
+ loadSample = _loadSample;
+ adaptive = true;
+ }
+ else if(OrderedLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
+ {
+ replicas = _replicas;
+ sort(replicas.begin(), replicas.end(), ReplicaPriorityComp());
+ }
+ else if(RandomLoadBalancingPolicyPtr::dynamicCast(_loadBalancing))
+ {
+ replicas = _replicas;
+ RandomNumberGenerator rng;
+ random_shuffle(replicas.begin(), replicas.end(), rng);
+ }
}
if(adaptive)
{
- //
- // This must be done outside the synchronization block since
- // the trasnform() might call and lock each server adapter
- // entry. We also can't sort directly as the load of each
- // server adapter is not stable so we first take a snapshot of
- // each adapter and sort the snapshot.
- //
- vector<pair<float, ServerAdapterEntryPtr> > rl;
- transform(replicas.begin(), replicas.end(), back_inserter(rl), TransformToReplicaLoad(loadSample));
- sort(rl.begin(), rl.end(), ReplicaLoadComp());
- replicas.clear();
- transform(rl.begin(), rl.end(), back_inserter(replicas), TransformToReplica());
+ //
+ // This must be done outside the synchronization block since
+ // the trasnform() might call and lock each server adapter
+ // entry. We also can't sort directly as the load of each
+ // server adapter is not stable so we first take a snapshot of
+ // each adapter and sort the snapshot.
+ //
+ vector<pair<float, ServerAdapterEntryPtr> > rl;
+ transform(replicas.begin(), replicas.end(), back_inserter(rl), TransformToReplicaLoad(loadSample));
+ sort(rl.begin(), rl.end(), ReplicaLoadComp());
+ replicas.clear();
+ transform(rl.begin(), rl.end(), back_inserter(replicas), TransformToReplica());
}
//
@@ -411,21 +411,21 @@ ReplicaGroupEntry::getLocatorAdapterInfo(LocatorAdapterInfoSeq& adapters, int& n
//
for(vector<ServerAdapterEntryPtr>::const_iterator p = replicas.begin(); p != replicas.end(); ++p)
{
- try
- {
- int dummy;
- bool dummy2;
- (*p)->getLocatorAdapterInfo(adapters, dummy, dummy2);
- }
- catch(const AdapterNotExistException&)
- {
- }
- catch(const NodeUnreachableException&)
- {
- }
- catch(const DeploymentException&)
- {
- }
+ try
+ {
+ int dummy;
+ bool dummy2;
+ (*p)->getLocatorAdapterInfo(adapters, dummy, dummy2);
+ }
+ catch(const AdapterNotExistException&)
+ {
+ }
+ catch(const NodeUnreachableException&)
+ {
+ }
+ catch(const DeploymentException&)
+ {
+ }
}
}
@@ -434,25 +434,25 @@ ReplicaGroupEntry::getLeastLoadedNodeLoad(LoadSample loadSample) const
{
vector<ServerAdapterEntryPtr> replicas;
{
- Lock sync(*this);
- replicas = _replicas;
+ Lock sync(*this);
+ replicas = _replicas;
}
if(replicas.empty())
{
- return 999.9f;
+ return 999.9f;
}
else if(replicas.size() == 1)
{
- return replicas.back()->getLeastLoadedNodeLoad(loadSample);
+ return replicas.back()->getLeastLoadedNodeLoad(loadSample);
}
else
{
- RandomNumberGenerator rng;
- random_shuffle(replicas.begin(), replicas.end(), rng);
- vector<pair<float, ServerAdapterEntryPtr> > rl;
- transform(replicas.begin(), replicas.end(), back_inserter(rl), TransformToReplicaLoad(loadSample));
- return min_element(rl.begin(), rl.end(), ReplicaLoadComp())->first;
+ RandomNumberGenerator rng;
+ random_shuffle(replicas.begin(), replicas.end(), rng);
+ vector<pair<float, ServerAdapterEntryPtr> > rl;
+ transform(replicas.begin(), replicas.end(), back_inserter(rl), TransformToReplicaLoad(loadSample));
+ return min_element(rl.begin(), rl.end(), ReplicaLoadComp())->first;
}
}
@@ -461,16 +461,16 @@ ReplicaGroupEntry::getAdapterInfo() const
{
vector<ServerAdapterEntryPtr> replicas;
{
- Lock sync(*this);
- replicas = _replicas;
+ Lock sync(*this);
+ replicas = _replicas;
}
AdapterInfoSeq infos;
for(vector<ServerAdapterEntryPtr>::const_iterator p = replicas.begin(); p != replicas.end(); ++p)
{
- AdapterInfoSeq infs = (*p)->getAdapterInfo();
- assert(infs.size() == 1);
- infos.push_back(infs[0]);
+ AdapterInfoSeq infs = (*p)->getAdapterInfo();
+ assert(infs.size() == 1);
+ infos.push_back(infs[0]);
}
return infos;
}
diff --git a/cpp/src/IceGrid/AdapterCache.h b/cpp/src/IceGrid/AdapterCache.h
index 14debc9838d..8e45f5b186e 100644
--- a/cpp/src/IceGrid/AdapterCache.h
+++ b/cpp/src/IceGrid/AdapterCache.h
@@ -65,7 +65,7 @@ class ServerAdapterEntry : public AdapterEntry
public:
ServerAdapterEntry(AdapterCache&, const std::string&, const std::string&, const std::string&, int,
- const ServerEntryPtr&);
+ const ServerEntryPtr&);
virtual void getLocatorAdapterInfo(LocatorAdapterInfoSeq&, int&, bool&);
virtual float getLeastLoadedNodeLoad(LoadSample) const;
diff --git a/cpp/src/IceGrid/AdminI.cpp b/cpp/src/IceGrid/AdminI.cpp
index 70a95368cd4..cf2d752f6b9 100644
--- a/cpp/src/IceGrid/AdminI.cpp
+++ b/cpp/src/IceGrid/AdminI.cpp
@@ -36,48 +36,48 @@ public:
ServerProxyWrapper(const DatabasePtr& database, const string& id) : _id(id)
{
- _proxy = database->getServer(_id)->getProxy(_activationTimeout, _deactivationTimeout, _node);
+ _proxy = database->getServer(_id)->getProxy(_activationTimeout, _deactivationTimeout, _node);
}
void
useActivationTimeout()
{
- _proxy = ServerPrx::uncheckedCast(_proxy->ice_timeout(_activationTimeout * 1000));
+ _proxy = ServerPrx::uncheckedCast(_proxy->ice_timeout(_activationTimeout * 1000));
}
void
useDeactivationTimeout()
{
- _proxy = ServerPrx::uncheckedCast(_proxy->ice_timeout(_deactivationTimeout * 1000));
+ _proxy = ServerPrx::uncheckedCast(_proxy->ice_timeout(_deactivationTimeout * 1000));
}
IceProxy::IceGrid::Server*
operator->() const
{
- return _proxy.get();
+ return _proxy.get();
}
void
handleException(const Ice::Exception& ex)
{
- try
- {
- ex.ice_throw();
- }
- catch(const Ice::UserException&)
- {
- throw;
- }
- catch(const Ice::ObjectNotExistException&)
- {
- throw ServerNotExistException(_id);
- }
- catch(const Ice::LocalException& e)
- {
- ostringstream os;
- os << e;
- throw NodeUnreachableException(_node, os.str());
- }
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(const Ice::UserException&)
+ {
+ throw;
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ throw ServerNotExistException(_id);
+ }
+ catch(const Ice::LocalException& e)
+ {
+ ostringstream os;
+ os << e;
+ throw NodeUnreachableException(_node, os.str());
+ }
}
private:
@@ -95,13 +95,13 @@ class AMDPatcherFeedbackAggregator : public PatcherFeedbackAggregator
public:
AMDPatcherFeedbackAggregator(const AmdCB& cb,
- Ice::Identity id,
- const TraceLevelsPtr& traceLevels,
- const string& type,
- const string& name,
- int nodeCount) :
- PatcherFeedbackAggregator(id, traceLevels, type, name, nodeCount),
- _cb(cb)
+ Ice::Identity id,
+ const TraceLevelsPtr& traceLevels,
+ const string& type,
+ const string& name,
+ int nodeCount) :
+ PatcherFeedbackAggregator(id, traceLevels, type, name, nodeCount),
+ _cb(cb)
{
}
@@ -110,13 +110,13 @@ private:
void
response()
{
- _cb->ice_response();
+ _cb->ice_response();
}
void
exception(const Ice::Exception& ex)
{
- _cb->ice_exception(ex);
+ _cb->ice_exception(ex);
}
const AmdCB _cb;
@@ -125,11 +125,11 @@ private:
template<typename AmdCB> PatcherFeedbackAggregatorPtr
static newPatcherFeedback(const AmdCB& cb,
- Ice::Identity id,
- const TraceLevelsPtr& traceLevels,
- const string& type,
- const string& name,
- int nodeCount)
+ Ice::Identity id,
+ const TraceLevelsPtr& traceLevels,
+ const string& type,
+ const string& name,
+ int nodeCount)
{
return new AMDPatcherFeedbackAggregator<AmdCB>(cb, id, traceLevels, type, name, nodeCount);
}
@@ -200,9 +200,9 @@ AdminI::instantiateServer(const string& app, const string& node, const ServerIns
void
AdminI::patchApplication_async(const AMD_Admin_patchApplicationPtr& amdCB,
- const string& name,
- bool shutdown,
- const Current& current)
+ const string& name,
+ bool shutdown,
+ const Current& current)
{
ApplicationHelper helper(current.adapter->getCommunicator(), _database->getApplicationInfo(name).descriptor);
DistributionDescriptor appDistrib;
@@ -211,8 +211,8 @@ AdminI::patchApplication_async(const AMD_Admin_patchApplicationPtr& amdCB,
if(nodes.empty())
{
- amdCB->ice_response();
- return;
+ amdCB->ice_response();
+ return;
}
Ice::Identity id;
@@ -220,39 +220,39 @@ AdminI::patchApplication_async(const AMD_Admin_patchApplicationPtr& amdCB,
id.name = IceUtil::generateUUID();
PatcherFeedbackAggregatorPtr feedback =
- newPatcherFeedback(amdCB, id, _traceLevels, "application", name, static_cast<int>(nodes.size()));
+ newPatcherFeedback(amdCB, id, _traceLevels, "application", name, static_cast<int>(nodes.size()));
for(vector<string>::const_iterator p = nodes.begin(); p != nodes.end(); ++p)
{
- try
- {
- if(_traceLevels->patch > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << "started patching of application `" << name << "' on node `" << *p << "'";
- }
-
- NodeEntryPtr node = _database->getNode(*p);
- Resolver resolve(node->getInfo(), _database->getCommunicator());
- DistributionDescriptor desc = resolve(appDistrib);
- InternalDistributionDescriptorPtr intAppDistrib = new InternalDistributionDescriptor(desc.icepatch,
- desc.directories);
- node->getSession()->patch(feedback, name, "", intAppDistrib, shutdown);
- }
- catch(const NodeNotExistException&)
- {
- feedback->failed(*p, "node doesn't exist");
- }
- catch(const NodeUnreachableException& e)
- {
- feedback->failed(*p, "node is unreachable: " + e.reason);
- }
- catch(const Ice::Exception& e)
- {
- ostringstream os;
- os << e;
- feedback->failed(*p, "node is unreachable:\n" + os.str());
- }
+ try
+ {
+ if(_traceLevels->patch > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << "started patching of application `" << name << "' on node `" << *p << "'";
+ }
+
+ NodeEntryPtr node = _database->getNode(*p);
+ Resolver resolve(node->getInfo(), _database->getCommunicator());
+ DistributionDescriptor desc = resolve(appDistrib);
+ InternalDistributionDescriptorPtr intAppDistrib = new InternalDistributionDescriptor(desc.icepatch,
+ desc.directories);
+ node->getSession()->patch(feedback, name, "", intAppDistrib, shutdown);
+ }
+ catch(const NodeNotExistException&)
+ {
+ feedback->failed(*p, "node doesn't exist");
+ }
+ catch(const NodeUnreachableException& e)
+ {
+ feedback->failed(*p, "node is unreachable: " + e.reason);
+ }
+ catch(const Ice::Exception& e)
+ {
+ ostringstream os;
+ os << e;
+ feedback->failed(*p, "node is unreachable:\n" + os.str());
+ }
}
}
@@ -269,49 +269,49 @@ AdminI::getDefaultApplicationDescriptor(const Current& current) const
string path = properties->getProperty("IceGrid.Registry.DefaultTemplates");
if(path.empty())
{
- throw DeploymentException("no default templates configured, you need to set "
- "IceGrid.Registry.DefaultTemplates in the IceGrid registry configuration.");
+ throw DeploymentException("no default templates configured, you need to set "
+ "IceGrid.Registry.DefaultTemplates in the IceGrid registry configuration.");
}
ApplicationDescriptor desc;
try
{
- desc = DescriptorParser::parseDescriptor(path, current.adapter->getCommunicator());
+ desc = DescriptorParser::parseDescriptor(path, current.adapter->getCommunicator());
}
catch(const IceXML::ParserException& ex)
{
- throw DeploymentException("can't parse default templates:\n" + ex.reason());
+ throw DeploymentException("can't parse default templates:\n" + ex.reason());
}
desc.name = "";
if(!desc.nodes.empty())
{
- Ice::Warning warn(_traceLevels->logger);
- warn << "default application descriptor:\nnode definitions are not allowed.";
- desc.nodes.clear();
+ Ice::Warning warn(_traceLevels->logger);
+ warn << "default application descriptor:\nnode definitions are not allowed.";
+ desc.nodes.clear();
}
if(!desc.distrib.icepatch.empty() || !desc.distrib.directories.empty())
{
- Ice::Warning warn(_traceLevels->logger);
- warn << "default application descriptor:\ndistribution is not allowed.";
- desc.distrib = DistributionDescriptor();
+ Ice::Warning warn(_traceLevels->logger);
+ warn << "default application descriptor:\ndistribution is not allowed.";
+ desc.distrib = DistributionDescriptor();
}
if(!desc.replicaGroups.empty())
{
- Ice::Warning warn(_traceLevels->logger);
- warn << "default application descriptor:\nreplica group definitions are not allowed.";
- desc.replicaGroups.clear();
+ Ice::Warning warn(_traceLevels->logger);
+ warn << "default application descriptor:\nreplica group definitions are not allowed.";
+ desc.replicaGroups.clear();
}
if(!desc.description.empty())
{
- Ice::Warning warn(_traceLevels->logger);
- warn << "default application descriptor:\ndescription is not allowed.";
- desc.description = "";
+ Ice::Warning warn(_traceLevels->logger);
+ warn << "default application descriptor:\ndescription is not allowed.";
+ desc.description = "";
}
if(!desc.variables.empty())
{
- Ice::Warning warn(_traceLevels->logger);
- warn << "default application descriptor:\nvariable definitions are not allowed.";
- desc.variables.clear();
+ Ice::Warning warn(_traceLevels->logger);
+ warn << "default application descriptor:\nvariable definitions are not allowed.";
+ desc.variables.clear();
}
return desc;
}
@@ -334,12 +334,12 @@ AdminI::getServerState(const string& id, const Current&) const
ServerProxyWrapper proxy(_database, id);
try
{
- return proxy->getState();
+ return proxy->getState();
}
catch(const Ice::Exception& ex)
{
- proxy.handleException(ex);
- return Inactive;
+ proxy.handleException(ex);
+ return Inactive;
}
}
@@ -349,12 +349,12 @@ AdminI::getServerPid(const string& id, const Current&) const
ServerProxyWrapper proxy(_database, id);
try
{
- return proxy->getPid();
+ return proxy->getPid();
}
catch(const Ice::Exception& ex)
{
- proxy.handleException(ex);
- return 0;
+ proxy.handleException(ex);
+ return 0;
}
}
@@ -365,11 +365,11 @@ AdminI::startServer(const string& id, const Current&)
proxy.useActivationTimeout();
try
{
- proxy->start();
+ proxy->start();
}
catch(const Ice::Exception& ex)
{
- proxy.handleException(ex);
+ proxy.handleException(ex);
}
}
@@ -380,20 +380,20 @@ AdminI::stopServer(const string& id, const Current&)
proxy.useDeactivationTimeout();
try
{
- proxy->stop();
+ proxy->stop();
}
catch(const Ice::TimeoutException&)
{
}
catch(const Ice::Exception& ex)
{
- proxy.handleException(ex);
+ proxy.handleException(ex);
}
}
void
AdminI::patchServer_async(const AMD_Admin_patchServerPtr& amdCB, const string& id, bool shutdown,
- const Current& current)
+ const Current& current)
{
ServerInfo info = _database->getServer(id)->getInfo();
ApplicationInfo appInfo = _database->getApplicationInfo(info.application);
@@ -404,8 +404,8 @@ AdminI::patchServer_async(const AMD_Admin_patchServerPtr& amdCB, const string& i
if(appDistrib.icepatch.empty() && nodes.empty())
{
- amdCB->ice_response();
- return;
+ amdCB->ice_response();
+ return;
}
assert(nodes.size() == 1);
@@ -415,37 +415,37 @@ AdminI::patchServer_async(const AMD_Admin_patchServerPtr& amdCB, const string& i
identity.name = IceUtil::generateUUID();
PatcherFeedbackAggregatorPtr feedback =
- newPatcherFeedback(amdCB, identity, _traceLevels, "server", id, static_cast<int>(nodes.size()));
+ newPatcherFeedback(amdCB, identity, _traceLevels, "server", id, static_cast<int>(nodes.size()));
vector<string>::const_iterator p = nodes.begin();
try
{
- if(_traceLevels->patch > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << "started patching of server `" << id << "' on node `" << *p << "'";
- }
+ if(_traceLevels->patch > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << "started patching of server `" << id << "' on node `" << *p << "'";
+ }
- NodeEntryPtr node = _database->getNode(*p);
- Resolver resolve(node->getInfo(), _database->getCommunicator());
- DistributionDescriptor desc = resolve(appDistrib);
- InternalDistributionDescriptorPtr intAppDistrib = new InternalDistributionDescriptor(desc.icepatch,
- desc.directories);
- node->getSession()->patch(feedback, info.application, id, intAppDistrib, shutdown);
+ NodeEntryPtr node = _database->getNode(*p);
+ Resolver resolve(node->getInfo(), _database->getCommunicator());
+ DistributionDescriptor desc = resolve(appDistrib);
+ InternalDistributionDescriptorPtr intAppDistrib = new InternalDistributionDescriptor(desc.icepatch,
+ desc.directories);
+ node->getSession()->patch(feedback, info.application, id, intAppDistrib, shutdown);
}
catch(const NodeNotExistException&)
{
- feedback->failed(*p, "node doesn't exist");
+ feedback->failed(*p, "node doesn't exist");
}
catch(const NodeUnreachableException& e)
{
- feedback->failed(*p, "node is unreachable: " + e.reason);
+ feedback->failed(*p, "node is unreachable: " + e.reason);
}
catch(const Ice::Exception& e)
{
- ostringstream os;
- os << e;
- feedback->failed(*p, "node is unreachable:\n" + os.str());
+ ostringstream os;
+ os << e;
+ feedback->failed(*p, "node is unreachable:\n" + os.str());
}
}
@@ -455,11 +455,11 @@ AdminI::sendSignal(const string& id, const string& signal, const Current&)
ServerProxyWrapper proxy(_database, id);
try
{
- proxy->sendSignal(signal);
+ proxy->sendSignal(signal);
}
catch(const Ice::Exception& ex)
{
- proxy.handleException(ex);
+ proxy.handleException(ex);
}
}
@@ -469,11 +469,11 @@ AdminI::writeMessage(const string& id, const string& message, Int fd, const Curr
ServerProxyWrapper proxy(_database, id);
try
{
- proxy->writeMessage(message, fd);
+ proxy->writeMessage(message, fd);
}
catch(const Ice::Exception& ex)
{
- proxy.handleException(ex);
+ proxy.handleException(ex);
}
}
@@ -489,11 +489,11 @@ AdminI::enableServer(const string& id, bool enable, const Ice::Current&)
ServerProxyWrapper proxy(_database, id);
try
{
- proxy->setEnabled(enable);
+ proxy->setEnabled(enable);
}
catch(const Ice::Exception& ex)
{
- proxy.handleException(ex);
+ proxy.handleException(ex);
}
}
@@ -503,12 +503,12 @@ AdminI::isServerEnabled(const ::std::string& id, const Ice::Current&) const
ServerProxyWrapper proxy(_database, id);
try
{
- return proxy->isEnabled();
+ return proxy->isEnabled();
}
catch(const Ice::Exception& ex)
{
- proxy.handleException(ex);
- return true; // Keeps the compiler happy.
+ proxy.handleException(ex);
+ return true; // Keeps the compiler happy.
}
}
@@ -537,15 +537,15 @@ AdminI::addObject(const Ice::ObjectPrx& proxy, const ::Ice::Current& current)
checkIsMaster();
try
{
- addObjectWithType(proxy, proxy->ice_id(), current);
+ addObjectWithType(proxy, proxy->ice_id(), current);
}
catch(const Ice::LocalException& e)
{
- ostringstream os;
+ ostringstream os;
- os << "failed to invoke ice_id() on proxy `" + current.adapter->getCommunicator()->proxyToString(proxy);
- os << "':\n" << e;
- throw DeploymentException(os.str());
+ os << "failed to invoke ice_id() on proxy `" + current.adapter->getCommunicator()->proxyToString(proxy);
+ os << "':\n" << e;
+ throw DeploymentException(os.str());
}
}
@@ -556,9 +556,9 @@ AdminI::updateObject(const Ice::ObjectPrx& proxy, const ::Ice::Current& current)
const Ice::Identity id = proxy->ice_getIdentity();
if(id.category == _database->getInstanceName())
{
- DeploymentException ex;
- ex.reason ="updating object `" + _database->getCommunicator()->identityToString(id) + "' is not allowed";
- throw ex;
+ DeploymentException ex;
+ ex.reason ="updating object `" + _database->getCommunicator()->identityToString(id) + "' is not allowed";
+ throw ex;
}
_database->updateObject(proxy);
}
@@ -570,9 +570,9 @@ AdminI::addObjectWithType(const Ice::ObjectPrx& proxy, const string& type, const
const Ice::Identity id = proxy->ice_getIdentity();
if(id.category == _database->getInstanceName())
{
- DeploymentException ex;
- ex.reason = "adding object `" + _database->getCommunicator()->identityToString(id) + "' is not allowed";
- throw ex;
+ DeploymentException ex;
+ ex.reason = "adding object `" + _database->getCommunicator()->identityToString(id) + "' is not allowed";
+ throw ex;
}
ObjectInfo info;
@@ -587,9 +587,9 @@ AdminI::removeObject(const Ice::Identity& id, const Ice::Current& current)
checkIsMaster();
if(id.category == _database->getInstanceName())
{
- DeploymentException ex;
- ex.reason = "removing object `" + _database->getCommunicator()->identityToString(id) + "' is not allowed";
- throw ex;
+ DeploymentException ex;
+ ex.reason = "removing object `" + _database->getCommunicator()->identityToString(id) + "' is not allowed";
+ throw ex;
}
_database->removeObject(id);
}
@@ -623,20 +623,20 @@ AdminI::pingNode(const string& name, const Current&) const
{
try
{
- _database->getNode(name)->getProxy()->ice_ping();
- return true;
+ _database->getNode(name)->getProxy()->ice_ping();
+ return true;
}
catch(const NodeUnreachableException&)
{
- return false;
+ return false;
}
catch(const Ice::ObjectNotExistException&)
{
- throw NodeNotExistException();
+ throw NodeNotExistException();
}
catch(const Ice::LocalException&)
{
- return false;
+ return false;
}
}
@@ -645,17 +645,17 @@ AdminI::getNodeLoad(const string& name, const Current&) const
{
try
{
- return _database->getNode(name)->getProxy()->getLoad();
+ return _database->getNode(name)->getProxy()->getLoad();
}
catch(const Ice::ObjectNotExistException&)
{
- throw NodeNotExistException();
+ throw NodeNotExistException();
}
catch(const Ice::LocalException& ex)
{
- ostringstream os;
- os << ex;
- throw NodeUnreachableException(name, os.str());
+ ostringstream os;
+ os << ex;
+ throw NodeUnreachableException(name, os.str());
}
return LoadInfo(); // Keep the compiler happy.
}
@@ -665,17 +665,17 @@ AdminI::shutdownNode(const string& name, const Current&)
{
try
{
- _database->getNode(name)->getProxy()->shutdown();
+ _database->getNode(name)->getProxy()->shutdown();
}
catch(const Ice::ObjectNotExistException&)
{
- throw NodeNotExistException(name);
+ throw NodeNotExistException(name);
}
catch(const Ice::LocalException& ex)
{
- ostringstream os;
- os << ex;
- throw NodeUnreachableException(name, os.str());
+ ostringstream os;
+ os << ex;
+ throw NodeUnreachableException(name, os.str());
}
}
@@ -684,18 +684,18 @@ AdminI::getNodeHostname(const string& name, const Current&) const
{
try
{
- return _database->getNode(name)->getInfo()->hostname;
+ return _database->getNode(name)->getInfo()->hostname;
}
catch(const Ice::ObjectNotExistException&)
{
- throw NodeNotExistException(name);
+ throw NodeNotExistException(name);
}
catch(const Ice::LocalException& ex)
{
- ostringstream os;
- os << ex;
- throw NodeUnreachableException(name, os.str());
- return ""; // Keep the compiler happy.
+ ostringstream os;
+ os << ex;
+ throw NodeUnreachableException(name, os.str());
+ return ""; // Keep the compiler happy.
}
}
@@ -711,11 +711,11 @@ AdminI::getRegistryInfo(const string& name, const Ice::Current&) const
{
if(name == _registry->getName())
{
- return _registry->getInfo();
+ return _registry->getInfo();
}
else
{
- return toRegistryInfo(_database->getReplica(name)->getInfo());
+ return toRegistryInfo(_database->getReplica(name)->getInfo());
}
}
@@ -724,21 +724,21 @@ AdminI::pingRegistry(const string& name, const Current&) const
{
if(name == _registry->getName())
{
- return true;
+ return true;
}
try
{
- _database->getReplica(name)->getProxy()->ice_ping();
- return true;
+ _database->getReplica(name)->getProxy()->ice_ping();
+ return true;
}
catch(const Ice::ObjectNotExistException&)
{
- throw RegistryNotExistException();
+ throw RegistryNotExistException();
}
catch(const Ice::LocalException&)
{
- return false;
+ return false;
}
return false;
}
@@ -748,23 +748,23 @@ AdminI::shutdownRegistry(const string& name, const Current&)
{
if(name == _registry->getName())
{
- _registry->shutdown();
- return;
+ _registry->shutdown();
+ return;
}
try
{
- _database->getReplica(name)->getProxy()->shutdown();
+ _database->getReplica(name)->getProxy()->shutdown();
}
catch(const Ice::ObjectNotExistException&)
{
- throw RegistryNotExistException(name);
+ throw RegistryNotExistException(name);
}
catch(const Ice::LocalException& ex)
{
- ostringstream os;
- os << ex;
- throw RegistryUnreachableException(name, os.str());
+ ostringstream os;
+ os << ex;
+ throw RegistryUnreachableException(name, os.str());
}
}
@@ -793,9 +793,9 @@ AdminI::checkIsMaster() const
{
if(!_database->isMaster())
{
- DeploymentException ex;
- ex.reason = "this operation is only allowed on the master registry.";
- throw ex;
+ DeploymentException ex;
+ ex.reason = "this operation is only allowed on the master registry.";
+ throw ex;
}
}
diff --git a/cpp/src/IceGrid/AdminI.h b/cpp/src/IceGrid/AdminI.h
index bce347df242..a5c63735ad9 100644
--- a/cpp/src/IceGrid/AdminI.h
+++ b/cpp/src/IceGrid/AdminI.h
@@ -39,9 +39,9 @@ public:
virtual void updateApplication(const ApplicationUpdateDescriptor&, const Ice::Current&);
virtual void removeApplication(const std::string&, const Ice::Current&);
virtual void instantiateServer(const std::string&, const std::string&, const ServerInstanceDescriptor&,
- const Ice::Current&);
+ const Ice::Current&);
virtual void patchApplication_async(const AMD_Admin_patchApplicationPtr&, const std::string&, bool,
- const Ice::Current&);
+ const Ice::Current&);
virtual ApplicationInfo getApplicationInfo(const ::std::string&, const Ice::Current&) const;
virtual ApplicationDescriptor getDefaultApplicationDescriptor(const Ice::Current&) const;
virtual Ice::StringSeq getAllApplicationNames(const Ice::Current&) const;
diff --git a/cpp/src/IceGrid/AdminSessionI.cpp b/cpp/src/IceGrid/AdminSessionI.cpp
index 44a634abd5d..8422018e210 100644
--- a/cpp/src/IceGrid/AdminSessionI.cpp
+++ b/cpp/src/IceGrid/AdminSessionI.cpp
@@ -20,10 +20,10 @@ using namespace std;
using namespace IceGrid;
FileIteratorI::FileIteratorI(const AdminSessionIPtr& session,
- const FileReaderPrx& reader,
- const string& filename,
- Ice::Long offset,
- int messageSizeMax) :
+ const FileReaderPrx& reader,
+ const string& filename,
+ Ice::Long offset,
+ int messageSizeMax) :
_session(session),
_reader(reader),
_filename(filename),
@@ -37,13 +37,13 @@ FileIteratorI::read(int size, Ice::StringSeq& lines, const Ice::Current& current
{
try
{
- return _reader->read(_filename, _offset, size > _messageSizeMax ? _messageSizeMax : size, _offset, lines);
+ return _reader->read(_filename, _offset, size > _messageSizeMax ? _messageSizeMax : size, _offset, lines);
}
catch(const Ice::LocalException& ex)
{
- ostringstream os;
- os << ex;
- throw FileNotAvailableException(os.str());
+ ostringstream os;
+ os << ex;
+ throw FileNotAvailableException(os.str());
}
return false; // Keep the compiler happy.
}
@@ -67,8 +67,8 @@ AdminSessionI::~AdminSessionI()
Ice::ObjectPrx
AdminSessionI::registerWithServantLocator(const SessionServantLocatorIPtr& servantLoc,
- const Ice::ConnectionPtr& con,
- const RegistryIPtr& registry)
+ const Ice::ConnectionPtr& con,
+ const RegistryIPtr& registry)
{
Ice::ObjectPrx proxy = BaseSessionI::registerWithServantLocator(servantLoc, con);
_admin = AdminPrx::uncheckedCast(servantLoc->add(new AdminI(_database, registry, this), con));
@@ -94,18 +94,18 @@ AdminSessionI::getAdmin(const Ice::Current& current) const
void
AdminSessionI::setObservers(const RegistryObserverPrx& registryObserver,
- const NodeObserverPrx& nodeObserver,
- const ApplicationObserverPrx& appObserver,
- const AdapterObserverPrx& adapterObserver,
- const ObjectObserverPrx& objectObserver,
- const Ice::Current& current)
+ const NodeObserverPrx& nodeObserver,
+ const ApplicationObserverPrx& appObserver,
+ const AdapterObserverPrx& adapterObserver,
+ const ObjectObserverPrx& objectObserver,
+ const Ice::Current& current)
{
Lock sync(*this);
if(_destroyed)
{
- Ice::ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = current.id;
- throw ex;
+ Ice::ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = current.id;
+ throw ex;
}
if(registryObserver)
@@ -114,7 +114,7 @@ AdminSessionI::setObservers(const RegistryObserverPrx& registryObserver,
}
else
{
- setupObserverSubscription(RegistryObserverTopicName, Ice::ObjectPrx());
+ setupObserverSubscription(RegistryObserverTopicName, Ice::ObjectPrx());
}
if(nodeObserver)
@@ -156,18 +156,18 @@ AdminSessionI::setObservers(const RegistryObserverPrx& registryObserver,
void
AdminSessionI::setObserversByIdentity(const Ice::Identity& registryObserver,
- const Ice::Identity& nodeObserver,
- const Ice::Identity& appObserver,
- const Ice::Identity& adapterObserver,
- const Ice::Identity& objectObserver,
- const Ice::Current& current)
+ const Ice::Identity& nodeObserver,
+ const Ice::Identity& appObserver,
+ const Ice::Identity& adapterObserver,
+ const Ice::Identity& objectObserver,
+ const Ice::Current& current)
{
Lock sync(*this);
if(_destroyed)
{
- Ice::ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = current.id;
- throw ex;
+ Ice::ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = current.id;
+ throw ex;
}
setupObserverSubscription(RegistryObserverTopicName, toProxy(registryObserver, current.con));
@@ -184,9 +184,9 @@ AdminSessionI::startUpdate(const Ice::Current& current)
Lock sync(*this);
if(_destroyed)
{
- Ice::ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = current.id;
- throw ex;
+ Ice::ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = current.id;
+ throw ex;
}
int serial = _database->lock(this, _id);
@@ -199,9 +199,9 @@ AdminSessionI::finishUpdate(const Ice::Current& current)
Lock sync(*this);
if(_destroyed)
{
- Ice::ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = current.id;
- throw ex;
+ Ice::ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = current.id;
+ throw ex;
}
_database->unlock(this);
@@ -249,11 +249,11 @@ AdminSessionI::openRegistryStdOut(const string& name, int nLines, const Ice::Cur
FileReaderPrx reader;
if(name == _replicaName)
{
- reader = _database->getReplicaCache().getInternalRegistry();
+ reader = _database->getReplicaCache().getInternalRegistry();
}
else
{
- reader = _database->getReplica(name)->getProxy();
+ reader = _database->getReplica(name)->getProxy();
}
return addFileIterator(reader, "stdout", nLines, current);
}
@@ -264,11 +264,11 @@ AdminSessionI::openRegistryStdErr(const string& name, int nLines, const Ice::Cur
FileReaderPrx reader;
if(name == _replicaName)
{
- reader = _database->getReplicaCache().getInternalRegistry();
+ reader = _database->getReplicaCache().getInternalRegistry();
}
else
{
- reader = _database->getReplica(name)->getProxy();
+ reader = _database->getReplica(name)->getProxy();
}
return addFileIterator(reader, "stderr", nLines, current);
}
@@ -284,14 +284,14 @@ AdminSessionI::setupObserverSubscription(TopicName name, const Ice::ObjectPrx& o
{
if(_observers[name] && _observers[name] != observer)
{
- _database->getObserverTopic(name)->unsubscribe(_observers[name]);
- _observers[name] = 0;
+ _database->getObserverTopic(name)->unsubscribe(_observers[name]);
+ _observers[name] = 0;
}
if(observer)
{
- _observers[name] = observer;
- _database->getObserverTopic(name)->subscribe(_observers[name]);
+ _observers[name] = observer;
+ _database->getObserverTopic(name)->subscribe(_observers[name]);
}
}
@@ -303,16 +303,16 @@ AdminSessionI::toProxy(const Ice::Identity& id, const Ice::ConnectionPtr& connec
FileIteratorPrx
AdminSessionI::addFileIterator(const FileReaderPrx& reader,
- const string& filename,
- int nLines,
- const Ice::Current& current)
+ const string& filename,
+ int nLines,
+ const Ice::Current& current)
{
Lock sync(*this);
if(_destroyed)
{
- Ice::ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = current.id;
- throw ex;
+ Ice::ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = current.id;
+ throw ex;
}
//
@@ -338,12 +338,12 @@ AdminSessionI::addFileIterator(const FileReaderPrx& reader,
Ice::ObjectPtr servant = new FileIteratorI(this, reader, filename, offset, messageSizeMax);
if(_servantLocator)
{
- obj = _servantLocator->add(servant, current.con);
+ obj = _servantLocator->add(servant, current.con);
}
else
{
- assert(_adapter);
- obj = _adapter->addWithUUID(servant);
+ assert(_adapter);
+ obj = _adapter->addWithUUID(servant);
}
_iterators.insert(obj->ice_getIdentity());
return FileIteratorPrx::uncheckedCast(obj);
@@ -355,18 +355,18 @@ AdminSessionI::removeFileIterator(const Ice::Identity& id, const Ice::Current& c
Lock sync(*this);
if(_servantLocator)
{
- _servantLocator->remove(id);
+ _servantLocator->remove(id);
}
else
{
- try
- {
- assert(_adapter);
- _adapter->remove(id);
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- }
+ try
+ {
+ assert(_adapter);
+ _adapter->remove(id);
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ }
}
_iterators.erase(id);
}
@@ -378,7 +378,7 @@ AdminSessionI::destroyImpl(bool shutdown)
try
{
- _database->unlock(this);
+ _database->unlock(this);
}
catch(AccessDeniedException&)
{
@@ -390,58 +390,58 @@ AdminSessionI::destroyImpl(bool shutdown)
//
if(!shutdown)
{
- if(_servantLocator)
- {
- _servantLocator->remove(_admin->ice_getIdentity());
- }
- else if(_adapter)
- {
- try
- {
- _adapter->remove(_admin->ice_getIdentity());
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- }
- }
-
- //
- // Unregister the iterators from the session servant locator or
- // object adapter.
- //
- for(set<Ice::Identity>::const_iterator p = _iterators.begin(); p != _iterators.end(); ++p)
- {
- if(_servantLocator)
- {
- _servantLocator->remove(*p);
- }
- else if(_adapter)
- {
- try
- {
- _adapter->remove(*p);
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- }
- }
- }
-
- //
- // Unsubscribe from the topics.
- //
- setupObserverSubscription(RegistryObserverTopicName, 0);
- setupObserverSubscription(NodeObserverTopicName, 0);
- setupObserverSubscription(ApplicationObserverTopicName, 0);
- setupObserverSubscription(AdapterObserverTopicName, 0);
- setupObserverSubscription(ObjectObserverTopicName, 0);
+ if(_servantLocator)
+ {
+ _servantLocator->remove(_admin->ice_getIdentity());
+ }
+ else if(_adapter)
+ {
+ try
+ {
+ _adapter->remove(_admin->ice_getIdentity());
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ }
+ }
+
+ //
+ // Unregister the iterators from the session servant locator or
+ // object adapter.
+ //
+ for(set<Ice::Identity>::const_iterator p = _iterators.begin(); p != _iterators.end(); ++p)
+ {
+ if(_servantLocator)
+ {
+ _servantLocator->remove(*p);
+ }
+ else if(_adapter)
+ {
+ try
+ {
+ _adapter->remove(*p);
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ }
+ }
+ }
+
+ //
+ // Unsubscribe from the topics.
+ //
+ setupObserverSubscription(RegistryObserverTopicName, 0);
+ setupObserverSubscription(NodeObserverTopicName, 0);
+ setupObserverSubscription(ApplicationObserverTopicName, 0);
+ setupObserverSubscription(AdapterObserverTopicName, 0);
+ setupObserverSubscription(ObjectObserverTopicName, 0);
}
}
AdminSessionFactory::AdminSessionFactory(const Ice::ObjectAdapterPtr& adapter,
- const DatabasePtr& database,
- const ReapThreadPtr& reaper,
- const RegistryIPtr& registry) :
+ const DatabasePtr& database,
+ const ReapThreadPtr& reaper,
+ const RegistryIPtr& registry) :
_adapter(adapter),
_database(database),
_timeout(registry->getSessionTimeout()),
@@ -470,21 +470,21 @@ AdminSessionFactory::createGlacier2Session(const string& sessionId, const Glacie
int timeout = 0;
if(ctl)
{
- try
- {
- ctl->identities()->add(ids);
- }
- catch(const Ice::LocalException&)
- {
- session->destroy(Ice::Current());
- return 0;
- }
- timeout = ctl->getSessionTimeout();
+ try
+ {
+ ctl->identities()->add(ids);
+ }
+ catch(const Ice::LocalException&)
+ {
+ session->destroy(Ice::Current());
+ return 0;
+ }
+ timeout = ctl->getSessionTimeout();
}
if(timeout > 0)
{
- _reaper->add(new SessionReapable<AdminSessionI>(_database->getTraceLevels()->logger, session), timeout);
+ _reaper->add(new SessionReapable<AdminSessionI>(_database->getTraceLevels()->logger, session), timeout);
}
return Glacier2::SessionPrx::uncheckedCast(proxy);
@@ -518,24 +518,24 @@ AdminSSLSessionManagerI::AdminSSLSessionManagerI(const AdminSessionFactoryPtr& f
Glacier2::SessionPrx
AdminSSLSessionManagerI::create(const Glacier2::SSLInfo& info,
- const Glacier2::SessionControlPrx& ctl,
- const Ice::Current& current)
+ const Glacier2::SessionControlPrx& ctl,
+ const Ice::Current& current)
{
string userDN;
if(!info.certs.empty()) // TODO: Require userDN?
{
- try
- {
- IceSSL::CertificatePtr cert = IceSSL::Certificate::decode(info.certs[0]);
- userDN = cert->getSubjectDN();
- }
- catch(const Ice::Exception& ex)
- {
- // This shouldn't happen, the SSLInfo is supposed to be encoded by Glacier2.
- Ice::Error out(_factory->getTraceLevels()->logger);
- out << "SSL session manager couldn't decode SSL certificates:\n" << ex;
- return 0;
- }
+ try
+ {
+ IceSSL::CertificatePtr cert = IceSSL::Certificate::decode(info.certs[0]);
+ userDN = cert->getSubjectDN();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ // This shouldn't happen, the SSLInfo is supposed to be encoded by Glacier2.
+ Ice::Error out(_factory->getTraceLevels()->logger);
+ out << "SSL session manager couldn't decode SSL certificates:\n" << ex;
+ return 0;
+ }
}
return _factory->createGlacier2Session(userDN, ctl);
diff --git a/cpp/src/IceGrid/AdminSessionI.h b/cpp/src/IceGrid/AdminSessionI.h
index 0f0ec222c72..7fc506b7cc9 100644
--- a/cpp/src/IceGrid/AdminSessionI.h
+++ b/cpp/src/IceGrid/AdminSessionI.h
@@ -32,7 +32,7 @@ public:
virtual ~AdminSessionI();
virtual Ice::ObjectPrx registerWithServantLocator(const SessionServantLocatorIPtr&, const Ice::ConnectionPtr&,
- const RegistryIPtr&);
+ const RegistryIPtr&);
virtual Ice::ObjectPrx registerWithObjectAdapter(const Ice::ObjectAdapterPtr&, const RegistryIPtr&);
virtual void keepAlive(const Ice::Current& current) { BaseSessionI::keepAlive(current); }
@@ -40,10 +40,10 @@ public:
virtual AdminPrx getAdmin(const Ice::Current& = Ice::Current()) const;
virtual void setObservers(const RegistryObserverPrx&, const NodeObserverPrx&, const ApplicationObserverPrx&,
- const AdapterObserverPrx&, const ObjectObserverPrx&, const Ice::Current&);
+ const AdapterObserverPrx&, const ObjectObserverPrx&, const Ice::Current&);
virtual void setObserversByIdentity(const Ice::Identity&, const Ice::Identity&, const Ice::Identity&,
- const Ice::Identity&, const Ice::Identity&, const Ice::Current&);
+ const Ice::Identity&, const Ice::Identity&, const Ice::Current&);
virtual int startUpdate(const Ice::Current&);
virtual void finishUpdate(const Ice::Current&);
@@ -121,7 +121,7 @@ public:
AdminSSLSessionManagerI(const AdminSessionFactoryPtr&);
virtual Glacier2::SessionPrx create(const Glacier2::SSLInfo&, const Glacier2::SessionControlPrx&,
- const Ice::Current&);
+ const Ice::Current&);
private:
diff --git a/cpp/src/IceGrid/Allocatable.cpp b/cpp/src/IceGrid/Allocatable.cpp
index 428bed9d086..5d05acda6b8 100644
--- a/cpp/src/IceGrid/Allocatable.cpp
+++ b/cpp/src/IceGrid/Allocatable.cpp
@@ -25,20 +25,20 @@ AllocationRequest::pending()
if(_timeout == 0)
{
- _state = Canceled;
- canceled(AllocationTimeoutException());
- return false;
+ _state = Canceled;
+ canceled(AllocationTimeoutException());
+ return false;
}
else if(!_session->addAllocationRequest(this))
{
- _state = Canceled;
- canceled(AllocationException("session destroyed"));
- return false;
+ _state = Canceled;
+ canceled(AllocationException("session destroyed"));
+ return false;
}
if(_timeout > 0)
{
- _session->getWaitQueue()->add(this, IceUtil::Time::milliSeconds(_timeout));
+ _session->getWaitQueue()->add(this, IceUtil::Time::milliSeconds(_timeout));
}
_state = Pending;
return true;
@@ -51,19 +51,19 @@ AllocationRequest::allocate(const AllocatablePtr& allocatable, const SessionIPtr
switch(_state)
{
case Initial:
- break;
+ break;
case Canceled:
- return false;
+ return false;
case Pending:
- if(_timeout > 0)
- {
- _session->getWaitQueue()->remove(this);
- }
- _session->removeAllocationRequest(this);
- break;
+ if(_timeout > 0)
+ {
+ _session->getWaitQueue()->remove(this);
+ }
+ _session->removeAllocationRequest(this);
+ break;
case Allocated:
- assert(false);
- break;
+ assert(false);
+ break;
}
//
@@ -71,14 +71,14 @@ AllocationRequest::allocate(const AllocatablePtr& allocatable, const SessionIPtr
//
if(_session == session)
{
- _state = Canceled;
- canceled(AllocationException("already allocated by the session"));
- return false;
+ _state = Canceled;
+ canceled(AllocationException("already allocated by the session"));
+ return false;
}
else
{
- _state = Allocated;
- return true;
+ _state = Allocated;
+ return true;
}
}
@@ -89,17 +89,17 @@ AllocationRequest::cancel(const AllocationException& ex)
switch(_state)
{
case Initial:
- break;
+ break;
case Canceled:
case Allocated:
- return;
+ return;
case Pending:
- if(_timeout > 0)
- {
- _session->getWaitQueue()->remove(this);
- }
- _session->removeAllocationRequest(this);
- break;
+ if(_timeout > 0)
+ {
+ _session->getWaitQueue()->remove(this);
+ }
+ _session->removeAllocationRequest(this);
+ break;
}
_state = Canceled;
@@ -113,13 +113,13 @@ AllocationRequest::expired(bool destroyed)
switch(_state)
{
case Initial:
- assert(false);
+ assert(false);
case Canceled:
case Allocated:
- return;
+ return;
case Pending:
- _session->removeAllocationRequest(this);
- break;
+ _session->removeAllocationRequest(this);
+ break;
}
_state = Canceled;
@@ -175,7 +175,7 @@ Allocatable::checkAllocatable()
{
if(!isAllocatable())
{
- throw AllocationException("not allocatable");
+ throw AllocationException("not allocatable");
}
}
@@ -184,11 +184,11 @@ Allocatable::allocate(const AllocationRequestPtr& request, bool fromRelease)
{
try
{
- return allocate(request, false, fromRelease);
+ return allocate(request, false, fromRelease);
}
catch(const SessionDestroyedException&)
{
- return false; // The session was destroyed
+ return false; // The session was destroyed
}
}
@@ -197,11 +197,11 @@ Allocatable::tryAllocate(const AllocationRequestPtr& request, bool fromRelease)
{
try
{
- return allocate(request, true, fromRelease);
+ return allocate(request, true, fromRelease);
}
catch(const AllocationException&)
{
- return false; // Not allocatable
+ return false; // Not allocatable
}
}
@@ -211,117 +211,117 @@ Allocatable::release(const SessionIPtr& session, bool fromRelease)
bool isReleased = false;
bool hasRequests = false;
{
- Lock sync(*this);
- if(!fromRelease)
- {
- while(_releasing)
- {
- wait();
- }
- assert(!_releasing);
- }
-
- if(!_session || _session != session)
- {
- throw AllocationException("can't release object which is not allocated");
- }
-
- if(--_count == 0)
- {
- _session = 0;
-
- released(session);
-
- isReleased = true;
-
- if(!fromRelease && !_requests.empty())
- {
- assert(!_parent);
- _releasing = true; // Prevent new allocations.
- hasRequests = true;
- }
- }
+ Lock sync(*this);
+ if(!fromRelease)
+ {
+ while(_releasing)
+ {
+ wait();
+ }
+ assert(!_releasing);
+ }
+
+ if(!_session || _session != session)
+ {
+ throw AllocationException("can't release object which is not allocated");
+ }
+
+ if(--_count == 0)
+ {
+ _session = 0;
+
+ released(session);
+
+ isReleased = true;
+
+ if(!fromRelease && !_requests.empty())
+ {
+ assert(!_parent);
+ _releasing = true; // Prevent new allocations.
+ hasRequests = true;
+ }
+ }
}
if(isReleased)
{
- releasedNoSync(session);
+ releasedNoSync(session);
}
if(_parent)
{
- _parent->release(session, fromRelease);
+ _parent->release(session, fromRelease);
}
else if(!fromRelease)
{
- if(hasRequests)
- {
- while(true)
- {
- AllocationRequestPtr request;
- AllocatablePtr allocatable;
- {
- Lock sync(*this);
- allocatable = dequeueAllocationAttempt(request);
- if(!allocatable)
- {
- assert(_count == 0 && _requests.empty());
- _releasing = false;
- notifyAll();
- return;
- }
- }
-
- //
- // Try to allocate the allocatable with the request or if
- // there's no request, just notify the allocatable that it can
- // be allocated again.
- //
- if(request && allocatable->allocate(request, true) || !request && allocatable->canTryAllocate())
- {
- while(true)
- {
- {
- Lock sync(*this);
- assert(_count);
-
- allocatable = 0;
- request = 0;
-
- //
- // Check if there's other requests from the session
- // waiting to allocate this allocatable.
- //
- list<pair<AllocatablePtr, AllocationRequestPtr> >::iterator p = _requests.begin();
- while(p != _requests.end())
- {
- if(p->second && p->second->getSession() == _session)
- {
- allocatable = p->first;
- request = p->second;
- _requests.erase(p);
- break;
- }
- ++p;
- }
- if(!allocatable)
- {
- _releasing = false;
- notifyAll();
- return; // We're done, the allocatable was released (but is allocated again)!
- }
- }
-
- assert(allocatable && request);
- allocatable->allocate(request, true);
- }
- }
- }
- }
- else if(isReleased)
- {
- canTryAllocate(); // Notify that this allocatable can be allocated.
- }
+ if(hasRequests)
+ {
+ while(true)
+ {
+ AllocationRequestPtr request;
+ AllocatablePtr allocatable;
+ {
+ Lock sync(*this);
+ allocatable = dequeueAllocationAttempt(request);
+ if(!allocatable)
+ {
+ assert(_count == 0 && _requests.empty());
+ _releasing = false;
+ notifyAll();
+ return;
+ }
+ }
+
+ //
+ // Try to allocate the allocatable with the request or if
+ // there's no request, just notify the allocatable that it can
+ // be allocated again.
+ //
+ if(request && allocatable->allocate(request, true) || !request && allocatable->canTryAllocate())
+ {
+ while(true)
+ {
+ {
+ Lock sync(*this);
+ assert(_count);
+
+ allocatable = 0;
+ request = 0;
+
+ //
+ // Check if there's other requests from the session
+ // waiting to allocate this allocatable.
+ //
+ list<pair<AllocatablePtr, AllocationRequestPtr> >::iterator p = _requests.begin();
+ while(p != _requests.end())
+ {
+ if(p->second && p->second->getSession() == _session)
+ {
+ allocatable = p->first;
+ request = p->second;
+ _requests.erase(p);
+ break;
+ }
+ ++p;
+ }
+ if(!allocatable)
+ {
+ _releasing = false;
+ notifyAll();
+ return; // We're done, the allocatable was released (but is allocated again)!
+ }
+ }
+
+ assert(allocatable && request);
+ allocatable->allocate(request, true);
+ }
+ }
+ }
+ }
+ else if(isReleased)
+ {
+ canTryAllocate(); // Notify that this allocatable can be allocated.
+ }
}
}
@@ -340,20 +340,20 @@ Allocatable::operator<(const Allocatable& r) const
void
Allocatable::queueAllocationAttempt(const AllocatablePtr& allocatable,
- const AllocationRequestPtr& request,
- bool tryAllocate)
+ const AllocationRequestPtr& request,
+ bool tryAllocate)
{
assert(!_parent);
if(!tryAllocate)
{
- if(request->pending())
- {
- _requests.push_back(make_pair(allocatable, request));
- }
+ if(request->pending())
+ {
+ _requests.push_back(make_pair(allocatable, request));
+ }
}
else
{
- _requests.push_back(make_pair(allocatable, AllocationRequestPtr()));
+ _requests.push_back(make_pair(allocatable, AllocationRequestPtr()));
}
}
@@ -362,8 +362,8 @@ Allocatable::queueAllocationAttemptFromChild(const AllocatablePtr& allocatable)
{
if(_parent)
{
- _parent->queueAllocationAttemptFromChild(allocatable);
- return;
+ _parent->queueAllocationAttemptFromChild(allocatable);
+ return;
}
Lock sync(*this);
@@ -375,14 +375,14 @@ Allocatable::dequeueAllocationAttempt(AllocationRequestPtr& request)
{
if(_requests.empty())
{
- return 0;
+ return 0;
}
pair<AllocatablePtr, AllocationRequestPtr> alloc = _requests.front();
_requests.pop_front();
if(alloc.second)
{
- request = alloc.second;
+ request = alloc.second;
}
return alloc.first;
}
@@ -392,130 +392,130 @@ Allocatable::allocate(const AllocationRequestPtr& request, bool tryAllocate, boo
{
if(_parent && !_parent->allocateFromChild(request, this, tryAllocate, fromRelease))
{
- return false;
+ return false;
}
bool queueWithParent = false;
int allocationCount = 0;
try
{
- Lock sync(*this);
- checkAllocatable();
-
- if(!_session && (fromRelease || !_releasing))
- {
- if(request->allocate(this, _session))
- {
- try
- {
- allocated(request->getSession()); // This might throw SessionDestroyedException
- }
- catch(const SessionDestroyedException&)
- {
- request->canceled(AllocationException("session destroyed"));
- throw;
- }
- assert(_count == 0);
- _session = request->getSession();
- request->allocated(this, request->getSession());
- ++_count;
- allocationCount = _count;
- }
- }
- else if(_session == request->getSession())
- {
- if(!tryAllocate)
- {
- if(request->allocate(this, _session))
- {
- assert(_count > 0);
- ++_count;
- request->allocated(this, _session);
- allocationCount = _count;
- }
- }
- else
- {
- queueWithParent = true;
- }
- }
- else
- {
- queueAllocationAttempt(this, request, tryAllocate);
- }
+ Lock sync(*this);
+ checkAllocatable();
+
+ if(!_session && (fromRelease || !_releasing))
+ {
+ if(request->allocate(this, _session))
+ {
+ try
+ {
+ allocated(request->getSession()); // This might throw SessionDestroyedException
+ }
+ catch(const SessionDestroyedException&)
+ {
+ request->canceled(AllocationException("session destroyed"));
+ throw;
+ }
+ assert(_count == 0);
+ _session = request->getSession();
+ request->allocated(this, request->getSession());
+ ++_count;
+ allocationCount = _count;
+ }
+ }
+ else if(_session == request->getSession())
+ {
+ if(!tryAllocate)
+ {
+ if(request->allocate(this, _session))
+ {
+ assert(_count > 0);
+ ++_count;
+ request->allocated(this, _session);
+ allocationCount = _count;
+ }
+ }
+ else
+ {
+ queueWithParent = true;
+ }
+ }
+ else
+ {
+ queueAllocationAttempt(this, request, tryAllocate);
+ }
}
catch(const SessionDestroyedException& ex)
{
- if(_parent)
- {
- _parent->release(request->getSession(), fromRelease);
- }
- throw ex;
+ if(_parent)
+ {
+ _parent->release(request->getSession(), fromRelease);
+ }
+ throw ex;
}
catch(const AllocationException& ex)
{
- if(_parent)
- {
- _parent->release(request->getSession(), fromRelease);
- }
- throw ex;
+ if(_parent)
+ {
+ _parent->release(request->getSession(), fromRelease);
+ }
+ throw ex;
}
if(allocationCount == 1)
{
- allocatedNoSync(request->getSession());
+ allocatedNoSync(request->getSession());
}
else if(allocationCount == 0 && _parent)
{
- if(queueWithParent)
- {
- _parent->queueAllocationAttemptFromChild(this);
- }
- _parent->release(request->getSession(), fromRelease);
+ if(queueWithParent)
+ {
+ _parent->queueAllocationAttemptFromChild(this);
+ }
+ _parent->release(request->getSession(), fromRelease);
}
return allocationCount > 0;
}
bool
Allocatable::allocateFromChild(const AllocationRequestPtr& request,
- const AllocatablePtr& child,
- bool tryAllocate,
- bool fromRelease)
+ const AllocatablePtr& child,
+ bool tryAllocate,
+ bool fromRelease)
{
if(_parent && !_parent->allocateFromChild(request, child, tryAllocate, fromRelease))
{
- return false;
+ return false;
}
int allocationCount = 0;
{
- Lock sync(*this);
- if((!_session || _session == request->getSession()) && (fromRelease || !_releasing))
- {
- if(!_session)
- {
- try
- {
- allocated(request->getSession());
- }
- catch(const SessionDestroyedException&)
- {
- // Ignore
- }
- }
- _session = request->getSession();
- ++_count;
- allocationCount = _count;
- }
- else
- {
- queueAllocationAttempt(child, request, tryAllocate);
- }
+ Lock sync(*this);
+ if((!_session || _session == request->getSession()) && (fromRelease || !_releasing))
+ {
+ if(!_session)
+ {
+ try
+ {
+ allocated(request->getSession());
+ }
+ catch(const SessionDestroyedException&)
+ {
+ // Ignore
+ }
+ }
+ _session = request->getSession();
+ ++_count;
+ allocationCount = _count;
+ }
+ else
+ {
+ queueAllocationAttempt(child, request, tryAllocate);
+ }
}
if(allocationCount == 1)
{
- allocatedNoSync(request->getSession());
+ allocatedNoSync(request->getSession());
}
return allocationCount > 0;
}
diff --git a/cpp/src/IceGrid/Allocatable.h b/cpp/src/IceGrid/Allocatable.h
index 325cfeb6bd7..11543ffc426 100644
--- a/cpp/src/IceGrid/Allocatable.h
+++ b/cpp/src/IceGrid/Allocatable.h
@@ -58,10 +58,10 @@ private:
enum State
{
- Initial,
- Pending,
- Canceled,
- Allocated
+ Initial,
+ Pending,
+ Canceled,
+ Allocated
};
const SessionIPtr _session;
diff --git a/cpp/src/IceGrid/AllocatableObjectCache.cpp b/cpp/src/IceGrid/AllocatableObjectCache.cpp
index 97484f85949..7df3a45afc3 100644
--- a/cpp/src/IceGrid/AllocatableObjectCache.cpp
+++ b/cpp/src/IceGrid/AllocatableObjectCache.cpp
@@ -26,7 +26,7 @@ struct AllocatableObjectEntryCI : binary_function<AllocatableObjectEntryPtr&, Al
bool
operator()(const AllocatableObjectEntryPtr& lhs, const AllocatableObjectEntryPtr& rhs)
{
- return ::Ice::proxyIdentityLess(lhs->getProxy(), rhs->getProxy());
+ return ::Ice::proxyIdentityLess(lhs->getProxy(), rhs->getProxy());
}
};
@@ -45,7 +45,7 @@ AllocatableObjectCache::TypeEntry::add(const AllocatableObjectEntryPtr& obj)
_objects.insert(lower_bound(_objects.begin(), _objects.end(), obj, AllocatableObjectEntryCI()), obj);
if(!_requests.empty())
{
- canTryAllocate(obj, false);
+ canTryAllocate(obj, false);
}
}
@@ -62,10 +62,10 @@ AllocatableObjectCache::TypeEntry::remove(const AllocatableObjectEntryPtr& obj)
if(!_requests.empty() && _objects.empty())
{
- for(list<ObjectAllocationRequestPtr>::const_iterator p = _requests.begin(); p != _requests.end(); ++p)
- {
- (*p)->cancel(AllocationException("no allocatable objects with type `" + obj->getType() + "' registered"));
- }
+ for(list<ObjectAllocationRequestPtr>::const_iterator p = _requests.begin(); p != _requests.end(); ++p)
+ {
+ (*p)->cancel(AllocationException("no allocatable objects with type `" + obj->getType() + "' registered"));
+ }
}
return _objects.empty();
}
@@ -78,7 +78,7 @@ AllocatableObjectCache::TypeEntry::addAllocationRequest(const ObjectAllocationRe
//
if(request->pending())
{
- _requests.push_back(request);
+ _requests.push_back(request);
}
}
@@ -91,31 +91,31 @@ AllocatableObjectCache::TypeEntry::canTryAllocate(const AllocatableObjectEntryPt
list<ObjectAllocationRequestPtr>::iterator p = _requests.begin();
while(p != _requests.end())
{
- AllocationRequestPtr request = *p;
- try
- {
- if(request->isCanceled()) // If the request has been canceled, we just remove it.
- {
- p = _requests.erase(p);
- }
- else if(entry->tryAllocate(request, fromRelease))
- {
- p = _requests.erase(p);
- return true; // The request successfully allocated the entry!
- }
- else if(entry->getSession()) // If entry is allocated, we're done
- {
- return false;
- }
- else
- {
- ++p;
- }
- }
- catch(const SessionDestroyedException&)
- {
- p = _requests.erase(p);
- }
+ AllocationRequestPtr request = *p;
+ try
+ {
+ if(request->isCanceled()) // If the request has been canceled, we just remove it.
+ {
+ p = _requests.erase(p);
+ }
+ else if(entry->tryAllocate(request, fromRelease))
+ {
+ p = _requests.erase(p);
+ return true; // The request successfully allocated the entry!
+ }
+ else if(entry->getSession()) // If entry is allocated, we're done
+ {
+ return false;
+ }
+ else
+ {
+ ++p;
+ }
+ }
+ catch(const SessionDestroyedException&)
+ {
+ p = _requests.erase(p);
+ }
}
return false;
}
@@ -139,14 +139,14 @@ AllocatableObjectCache::add(const ObjectInfo& info, const AllocatablePtr& parent
map<string, TypeEntry>::iterator p = _types.find(entry->getType());
if(p == _types.end())
{
- p = _types.insert(p, map<string, TypeEntry>::value_type(entry->getType(), TypeEntry()));
+ p = _types.insert(p, map<string, TypeEntry>::value_type(entry->getType(), TypeEntry()));
}
p->second.add(entry);
if(_traceLevels && _traceLevels->object > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
- out << "added allocatable object `" << _communicator->identityToString(id) << "'";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
+ out << "added allocatable object `" << _communicator->identityToString(id) << "'";
}
}
@@ -157,7 +157,7 @@ AllocatableObjectCache::get(const Ice::Identity& id) const
AllocatableObjectEntryPtr entry = getImpl(id);
if(!entry)
{
- throw ObjectNotRegisteredException(id);
+ throw ObjectNotRegisteredException(id);
}
return entry;
}
@@ -167,23 +167,23 @@ AllocatableObjectCache::remove(const Ice::Identity& id)
{
AllocatableObjectEntryPtr entry;
{
- Lock sync(*this);
- entry = getImpl(id);
- assert(entry);
- removeImpl(id);
-
- map<string, TypeEntry>::iterator p = _types.find(entry->getType());
- assert(p != _types.end());
- if(p->second.remove(entry))
- {
- _types.erase(p);
- }
-
- if(_traceLevels && _traceLevels->object > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
- out << "removed allocatable object `" << _communicator->identityToString(id) << "'";
- }
+ Lock sync(*this);
+ entry = getImpl(id);
+ assert(entry);
+ removeImpl(id);
+
+ map<string, TypeEntry>::iterator p = _types.find(entry->getType());
+ assert(p != _types.end());
+ if(p->second.remove(entry))
+ {
+ _types.erase(p);
+ }
+
+ if(_traceLevels && _traceLevels->object > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
+ out << "removed allocatable object `" << _communicator->identityToString(id) << "'";
+ }
}
//
@@ -202,7 +202,7 @@ AllocatableObjectCache::allocateByType(const string& type, const ObjectAllocatio
map<string, TypeEntry>::iterator p = _types.find(type);
if(p == _types.end())
{
- throw AllocationException("no allocatable objects with type `" + type + "' registered");
+ throw AllocationException("no allocatable objects with type `" + type + "' registered");
}
vector<AllocatableObjectEntryPtr> objects = p->second.getObjects();
@@ -210,17 +210,17 @@ AllocatableObjectCache::allocateByType(const string& type, const ObjectAllocatio
random_shuffle(objects.begin(), objects.end(), rng); // TODO: OPTIMIZE
try
{
- for(vector<AllocatableObjectEntryPtr>::const_iterator q = objects.begin(); q != objects.end(); ++q)
- {
- if((*q)->tryAllocate(request))
- {
- return;
- }
- }
+ for(vector<AllocatableObjectEntryPtr>::const_iterator q = objects.begin(); q != objects.end(); ++q)
+ {
+ if((*q)->tryAllocate(request))
+ {
+ return;
+ }
+ }
}
catch(const SessionDestroyedException&)
{
- return; // The request has been answered already, no need to throw here.
+ return; // The request has been answered already, no need to throw here.
}
p->second.addAllocationRequest(request);
@@ -236,14 +236,14 @@ AllocatableObjectCache::canTryAllocate(const AllocatableObjectEntryPtr& entry)
map<string, TypeEntry>::iterator p = _types.find(entry->getType());
if(p == _types.end())
{
- return false;
+ return false;
}
return p->second.canTryAllocate(entry, true);
}
AllocatableObjectEntry::AllocatableObjectEntry(AllocatableObjectCache& cache,
- const ObjectInfo& info,
- const AllocatablePtr& parent) :
+ const ObjectInfo& info,
+ const AllocatablePtr& parent) :
Allocatable(true, parent),
_cache(cache),
_info(info),
@@ -281,29 +281,29 @@ AllocatableObjectEntry::allocated(const SessionIPtr& session)
TraceLevelsPtr traceLevels = _cache.getTraceLevels();
if(traceLevels && traceLevels->object > 1)
{
- Ice::Trace out(traceLevels->logger, traceLevels->objectCat);
- out << "object `" << _info.proxy->ice_toString() << "' allocated by `" << session->getId() << "' (" << _count
- << ")";
+ Ice::Trace out(traceLevels->logger, traceLevels->objectCat);
+ out << "object `" << _info.proxy->ice_toString() << "' allocated by `" << session->getId() << "' (" << _count
+ << ")";
}
Glacier2::SessionControlPrx ctl = session->getSessionControl();
if(ctl)
{
- try
- {
- Ice::IdentitySeq seq(1);
- seq.push_back(_info.proxy->ice_getIdentity());
- ctl->identities()->add(seq);
- }
- catch(const Ice::LocalException& ex)
- {
- if(traceLevels && traceLevels->object > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->objectCat);
- out << "couldn't add Glacier2 filter for object `" << _info.proxy->ice_toString();
- out << "' allocated by `" << session->getId() << "':\n" << ex;
- }
- }
+ try
+ {
+ Ice::IdentitySeq seq(1);
+ seq.push_back(_info.proxy->ice_getIdentity());
+ ctl->identities()->add(seq);
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ if(traceLevels && traceLevels->object > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->objectCat);
+ out << "couldn't add Glacier2 filter for object `" << _info.proxy->ice_toString();
+ out << "' allocated by `" << session->getId() << "':\n" << ex;
+ }
+ }
}
}
@@ -320,28 +320,28 @@ AllocatableObjectEntry::released(const SessionIPtr& session)
Glacier2::SessionControlPrx ctl = session->getSessionControl();
if(ctl)
{
- try
- {
- Ice::IdentitySeq seq(1);
- seq.push_back(_info.proxy->ice_getIdentity());
- ctl->identities()->remove(seq);
- }
- catch(const Ice::LocalException& ex)
- {
- if(traceLevels && traceLevels->object > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->objectCat);
- out << "couldn't remove Glacier2 filter for object `" << _info.proxy->ice_toString();
- out << "' allocated by `" << session->getId() << "':\n" << ex;
- }
- }
+ try
+ {
+ Ice::IdentitySeq seq(1);
+ seq.push_back(_info.proxy->ice_getIdentity());
+ ctl->identities()->remove(seq);
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ if(traceLevels && traceLevels->object > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->objectCat);
+ out << "couldn't remove Glacier2 filter for object `" << _info.proxy->ice_toString();
+ out << "' allocated by `" << session->getId() << "':\n" << ex;
+ }
+ }
}
if(traceLevels && traceLevels->object > 1)
{
- Ice::Trace out(traceLevels->logger, traceLevels->objectCat);
- out << "object `" << _info.proxy->ice_toString() << "' released by `" << session->getId() << "' (" << _count
- << ")";
+ Ice::Trace out(traceLevels->logger, traceLevels->objectCat);
+ out << "object `" << _info.proxy->ice_toString() << "' released by `" << session->getId() << "' (" << _count
+ << ")";
}
}
@@ -350,19 +350,19 @@ AllocatableObjectEntry::destroy()
{
SessionIPtr session;
{
- Lock sync(*this);
- _destroyed = true;
- session = _session;
+ Lock sync(*this);
+ _destroyed = true;
+ session = _session;
}
if(session)
{
- try
- {
- release(session);
- }
- catch(const AllocationException&)
- {
- }
+ try
+ {
+ release(session);
+ }
+ catch(const AllocationException&)
+ {
+ }
}
}
@@ -371,7 +371,7 @@ AllocatableObjectEntry::checkAllocatable()
{
if(_destroyed)
{
- throw ObjectNotRegisteredException(_info.proxy->ice_getIdentity());
+ throw ObjectNotRegisteredException(_info.proxy->ice_getIdentity());
}
Allocatable::checkAllocatable();
diff --git a/cpp/src/IceGrid/AllocatableObjectCache.h b/cpp/src/IceGrid/AllocatableObjectCache.h
index a46279e04e1..8c794a1f91f 100644
--- a/cpp/src/IceGrid/AllocatableObjectCache.h
+++ b/cpp/src/IceGrid/AllocatableObjectCache.h
@@ -59,12 +59,12 @@ private:
virtual void allocated(const AllocatablePtr& allocatable, const SessionIPtr& session)
{
- response(AllocatableObjectEntryPtr::dynamicCast(allocatable)->getProxy());
+ response(AllocatableObjectEntryPtr::dynamicCast(allocatable)->getProxy());
}
virtual void canceled(const AllocationException& ex)
{
- exception(ex);
+ exception(ex);
}
};
typedef IceUtil::Handle<ObjectAllocationRequest> ObjectAllocationRequestPtr;
@@ -92,20 +92,20 @@ private:
{
public:
- TypeEntry();
+ TypeEntry();
- void add(const AllocatableObjectEntryPtr&);
- bool remove(const AllocatableObjectEntryPtr&);
-
- void addAllocationRequest(const ObjectAllocationRequestPtr&);
- bool canTryAllocate(const AllocatableObjectEntryPtr&, bool);
+ void add(const AllocatableObjectEntryPtr&);
+ bool remove(const AllocatableObjectEntryPtr&);
+
+ void addAllocationRequest(const ObjectAllocationRequestPtr&);
+ bool canTryAllocate(const AllocatableObjectEntryPtr&, bool);
- const std::vector<AllocatableObjectEntryPtr>& getObjects() const { return _objects; }
+ const std::vector<AllocatableObjectEntryPtr>& getObjects() const { return _objects; }
private:
-
- std::vector<AllocatableObjectEntryPtr> _objects;
- std::list<ObjectAllocationRequestPtr> _requests;
+
+ std::vector<AllocatableObjectEntryPtr> _objects;
+ std::list<ObjectAllocationRequestPtr> _requests;
};
const Ice::CommunicatorPtr _communicator;
diff --git a/cpp/src/IceGrid/Cache.h b/cpp/src/IceGrid/Cache.h
index 284ba6953d0..295aa4a55b4 100644
--- a/cpp/src/IceGrid/Cache.h
+++ b/cpp/src/IceGrid/Cache.h
@@ -38,21 +38,21 @@ public:
bool
has(const Key& key) const
{
- Lock sync(*this);
- return getImpl(key);
+ Lock sync(*this);
+ return getImpl(key);
}
void
remove(const Key& key)
{
- Lock sync(*this);
- removeImpl(key);
+ Lock sync(*this);
+ removeImpl(key);
}
void
setTraceLevels(const TraceLevelsPtr& traceLevels)
{
- _traceLevels = traceLevels;
+ _traceLevels = traceLevels;
}
const TraceLevelsPtr& getTraceLevels() const { return _traceLevels; }
@@ -62,66 +62,66 @@ protected:
virtual ValuePtr
getImpl(const Key& key) const
{
- typename ValueMap::iterator p = const_cast<ValueMap&>(_entries).end();
- if(_entriesHint != p)
- {
- if(_entriesHint->first == key)
- {
- p = _entriesHint;
- }
- }
-
- if(p == const_cast<ValueMap&>(_entries).end())
- {
- p = const_cast<ValueMap&>(_entries).find(key);
- }
-
- if(p != const_cast<ValueMap&>(_entries).end())
- {
- const_cast<typename ValueMap::iterator&>(_entriesHint) = p;
- return p->second;
- }
- else
- {
- return 0;
- }
+ typename ValueMap::iterator p = const_cast<ValueMap&>(_entries).end();
+ if(_entriesHint != p)
+ {
+ if(_entriesHint->first == key)
+ {
+ p = _entriesHint;
+ }
+ }
+
+ if(p == const_cast<ValueMap&>(_entries).end())
+ {
+ p = const_cast<ValueMap&>(_entries).find(key);
+ }
+
+ if(p != const_cast<ValueMap&>(_entries).end())
+ {
+ const_cast<typename ValueMap::iterator&>(_entriesHint) = p;
+ return p->second;
+ }
+ else
+ {
+ return 0;
+ }
}
virtual ValuePtr
addImpl(const Key& key, const ValuePtr& entry)
{
- typename ValueMap::value_type v(key, entry);
- _entriesHint = _entries.insert(_entriesHint, v);
- return entry;
+ typename ValueMap::value_type v(key, entry);
+ _entriesHint = _entries.insert(_entriesHint, v);
+ return entry;
}
virtual void
removeImpl(const Key& key)
{
- typename ValueMap::iterator p = _entries.end();
- if(_entriesHint != _entries.end())
- {
- if(_entriesHint->first == key)
- {
- p = _entriesHint;
- }
- }
-
- if(p == _entries.end())
- {
- p = _entries.find(key);
- }
-
- assert(p != _entries.end());
- if(p->second->canRemove())
- {
- _entries.erase(p);
- _entriesHint = _entries.end();
- }
- else
- {
- _entriesHint = p;
- }
+ typename ValueMap::iterator p = _entries.end();
+ if(_entriesHint != _entries.end())
+ {
+ if(_entriesHint->first == key)
+ {
+ p = _entriesHint;
+ }
+ }
+
+ if(p == _entries.end())
+ {
+ p = _entries.find(key);
+ }
+
+ assert(p != _entries.end());
+ if(p->second->canRemove())
+ {
+ _entries.erase(p);
+ _entriesHint = _entries.end();
+ }
+ else
+ {
+ _entriesHint = p;
+ }
}
TraceLevelsPtr _traceLevels;
@@ -139,8 +139,8 @@ public:
virtual std::vector<std::string>
getAll(const std::string& expr)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- return getMatchingKeys<std::map<std::string,TPtr> >(Cache<std::string, T>::_entries, expr);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ return getMatchingKeys<std::map<std::string,TPtr> >(Cache<std::string, T>::_entries, expr);
}
};
diff --git a/cpp/src/IceGrid/Client.cpp b/cpp/src/IceGrid/Client.cpp
index 965fc931a3b..08f1b384dd1 100644
--- a/cpp/src/IceGrid/Client.cpp
+++ b/cpp/src/IceGrid/Client.cpp
@@ -33,7 +33,7 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I
public:
SessionKeepAliveThread(const AdminSessionPrx& session, long timeout) :
- _session(session),
+ _session(session),
_timeout(IceUtil::Time::seconds(timeout)),
_destroy(false)
{
@@ -48,15 +48,15 @@ public:
timedWait(_timeout);
if(_destroy)
{
- break;
- }
+ break;
+ }
try
{
_session->keepAlive();
}
catch(const Ice::Exception&)
{
- break;
+ break;
}
}
}
@@ -103,7 +103,7 @@ static void interruptCallback(int signal)
IceUtil::StaticMutex::Lock lock(_staticMutex);
if(_globalClient)
{
- _globalClient->interrupted();
+ _globalClient->interrupted();
}
}
@@ -118,23 +118,23 @@ void
Client::usage()
{
cerr << "Usage: " << appName() << " [options] [file...]\n";
- cerr <<
- "Options:\n"
- "-h, --help Show this message.\n"
- "-v, --version Display the Ice version.\n"
- "-DNAME Define NAME as 1.\n"
- "-DNAME=DEF Define NAME as DEF.\n"
- "-UNAME Remove any definition for NAME.\n"
- "-IDIR Put DIR in the include file search path.\n"
- "-e COMMANDS Execute COMMANDS.\n"
- "-d, --debug Print debug messages.\n"
+ cerr <<
+ "Options:\n"
+ "-h, --help Show this message.\n"
+ "-v, --version Display the Ice version.\n"
+ "-DNAME Define NAME as 1.\n"
+ "-DNAME=DEF Define NAME as DEF.\n"
+ "-UNAME Remove any definition for NAME.\n"
+ "-IDIR Put DIR in the include file search path.\n"
+ "-e COMMANDS Execute COMMANDS.\n"
+ "-d, --debug Print debug messages.\n"
"-s, --server Start icegridadmin as a server (to parse XML files).\n"
"-u, --username Login with the given username.\n"
"-p, --password Login with the given password.\n"
"-s, --ssl Authenticate through SSL.\n"
"-r, --routed Login through a Glacier2 router.\n"
"-R, --replica NAME Connect to the replica NAME.\n"
- ;
+ ;
}
int
@@ -144,74 +144,74 @@ Client::main(int argc, char* argv[])
try
{
- _appName = argv[0];
- _communicator = Ice::initialize(argc, argv);
-
- {
- IceUtil::StaticMutex::Lock sync(_staticMutex);
- _globalClient = this;
- }
- _ctrlCHandler.setCallback(interruptCallback);
-
- try
- {
- run(argc, argv);
- }
- catch(const Ice::CommunicatorDestroyedException&)
- {
- // Expected if the client is interrupted during the initialization.
- }
+ _appName = argv[0];
+ _communicator = Ice::initialize(argc, argv);
+
+ {
+ IceUtil::StaticMutex::Lock sync(_staticMutex);
+ _globalClient = this;
+ }
+ _ctrlCHandler.setCallback(interruptCallback);
+
+ try
+ {
+ run(argc, argv);
+ }
+ catch(const Ice::CommunicatorDestroyedException&)
+ {
+ // Expected if the client is interrupted during the initialization.
+ }
}
catch(const IceUtil::Exception& ex)
{
- cerr << _appName << ": " << ex << endl;
- status = EXIT_FAILURE;
+ cerr << _appName << ": " << ex << endl;
+ status = EXIT_FAILURE;
}
catch(const std::exception& ex)
{
- cerr << _appName << ": std::exception: " << ex.what() << endl;
- status = EXIT_FAILURE;
+ cerr << _appName << ": std::exception: " << ex.what() << endl;
+ status = EXIT_FAILURE;
}
catch(const std::string& msg)
{
- cerr << _appName << ": " << msg << endl;
- status = EXIT_FAILURE;
+ cerr << _appName << ": " << msg << endl;
+ status = EXIT_FAILURE;
}
catch(const char* msg)
{
- cerr << _appName << ": " << msg << endl;
- status = EXIT_FAILURE;
+ cerr << _appName << ": " << msg << endl;
+ status = EXIT_FAILURE;
}
catch(...)
{
- cerr << _appName << ": unknown exception" << endl;
- status = EXIT_FAILURE;
+ cerr << _appName << ": unknown exception" << endl;
+ status = EXIT_FAILURE;
}
if(_communicator)
{
- try
- {
- _communicator->destroy();
- }
- catch(const Ice::CommunicatorDestroyedException&)
- {
- }
- catch(const Ice::Exception& ex)
- {
- cerr << ex << endl;
- status = EXIT_FAILURE;
- }
+ try
+ {
+ _communicator->destroy();
+ }
+ catch(const Ice::CommunicatorDestroyedException&)
+ {
+ }
+ catch(const Ice::Exception& ex)
+ {
+ cerr << ex << endl;
+ status = EXIT_FAILURE;
+ }
}
_ctrlCHandler.setCallback(0);
{
- IceUtil::StaticMutex::Lock sync(_staticMutex);
- _globalClient = 0;
+ IceUtil::StaticMutex::Lock sync(_staticMutex);
+ _globalClient = 0;
}
return status;
-
+
}
void
@@ -220,21 +220,21 @@ Client::interrupted()
Lock sync(*this);
if(_parser) // If there's an interactive parser, notify the parser.
{
- _parser->interrupt();
+ _parser->interrupt();
}
else
{
- //
- // Otherwise, destroy the communicator.
- //
- assert(_communicator);
- try
- {
- _communicator->destroy();
- }
- catch(const Ice::Exception&)
- {
- }
+ //
+ // Otherwise, destroy the communicator.
+ //
+ assert(_communicator);
+ try
+ {
+ _communicator->destroy();
+ }
+ catch(const Ice::Exception&)
+ {
+ }
}
}
@@ -263,103 +263,103 @@ Client::run(int argc, char* argv[])
vector<string> args;
try
{
- args = opts.parse(argc, (const char**)argv);
+ args = opts.parse(argc, (const char**)argv);
}
catch(const IceUtil::BadOptException& e)
{
cerr << e.reason << endl;
- usage();
- return EXIT_FAILURE;
+ usage();
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage();
- return EXIT_SUCCESS;
+ usage();
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
if(opts.isSet("server"))
{
- ObjectAdapterPtr adapter = communicator()->createObjectAdapterWithEndpoints("FileParser", "tcp -h localhost");
- adapter->activate();
- ObjectPrx proxy = adapter->add(new FileParserI, communicator()->stringToIdentity("FileParser"));
- cout << proxy << endl;
+ ObjectAdapterPtr adapter = communicator()->createObjectAdapterWithEndpoints("FileParser", "tcp -h localhost");
+ adapter->activate();
+ ObjectPrx proxy = adapter->add(new FileParserI, communicator()->stringToIdentity("FileParser"));
+ cout << proxy << endl;
- communicator()->waitForShutdown();
- return EXIT_SUCCESS;
+ communicator()->waitForShutdown();
+ return EXIT_SUCCESS;
}
if(opts.isSet("D"))
{
- vector<string> optargs = opts.argVec("D");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- cpp += " -D" + *i;
- }
+ vector<string> optargs = opts.argVec("D");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ cpp += " -D" + *i;
+ }
}
if(opts.isSet("U"))
{
- vector<string> optargs = opts.argVec("U");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- cpp += " -U" + *i;
- }
+ vector<string> optargs = opts.argVec("U");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ cpp += " -U" + *i;
+ }
}
if(opts.isSet("I"))
{
- vector<string> optargs = opts.argVec("I");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- cpp += " -I" + *i;
- }
+ vector<string> optargs = opts.argVec("I");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ cpp += " -I" + *i;
+ }
}
if(opts.isSet("e"))
{
- vector<string> optargs = opts.argVec("e");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- commands += *i + ";";
- }
+ vector<string> optargs = opts.argVec("e");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ commands += *i + ";";
+ }
}
debug = opts.isSet("debug");
if(!args.empty() && !commands.empty())
{
- cerr << appName() << ": `-e' option cannot be used if input files are given" << endl;
- usage();
- return EXIT_FAILURE;
+ cerr << appName() << ": `-e' option cannot be used if input files are given" << endl;
+ usage();
+ return EXIT_FAILURE;
}
string instanceName;
if(communicator()->getDefaultLocator())
{
- instanceName = communicator()->getDefaultLocator()->ice_getIdentity().category;
+ instanceName = communicator()->getDefaultLocator()->ice_getIdentity().category;
}
else
{
- instanceName = communicator()->getProperties()->getPropertyWithDefault("IceGrid.InstanceName", "IceGrid");
+ instanceName = communicator()->getProperties()->getPropertyWithDefault("IceGrid.InstanceName", "IceGrid");
}
bool ssl = communicator()->getProperties()->getPropertyAsInt("IceGridAdmin.AuthenticateUsingSSL");
if(opts.isSet("ssl"))
{
- ssl = true;
+ ssl = true;
}
string id = communicator()->getProperties()->getProperty("IceGridAdmin.Username");
if(!opts.optArg("username").empty())
{
- id = opts.optArg("username");
+ id = opts.optArg("username");
}
string password = communicator()->getProperties()->getProperty("IceGridAdmin.Password");
if(!opts.optArg("password").empty())
{
- password = opts.optArg("password");
+ password = opts.optArg("password");
}
//
@@ -370,12 +370,12 @@ Client::run(int argc, char* argv[])
bool routed = properties->getPropertyAsIntWithDefault("IceGridAdmin.Routed", communicator()->getDefaultRouter());
if(opts.isSet("routed"))
{
- routed = true;
+ routed = true;
}
string replica = properties->getProperty("IceGridAdmin.Replica");
if(!opts.optArg("replica").empty())
{
- replica = opts.optArg("replica");
+ replica = opts.optArg("replica");
}
AdminSessionPrx session;
@@ -383,227 +383,227 @@ Client::run(int argc, char* argv[])
int status = EXIT_SUCCESS;
try
{
- int timeout;
- if(routed)
- {
- Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(communicator()->getDefaultRouter());
- if(!router)
- {
- cerr << argv[0] << ": configured router is not a Glacier2 router" << endl;
- return EXIT_FAILURE;
- }
-
- // Use SSL if available.
- try
- {
- router = Glacier2::RouterPrx::checkedCast(router->ice_secure(true));
- }
- catch(const Ice::NoEndpointException&)
- {
- }
-
- if(ssl)
- {
- session = AdminSessionPrx::uncheckedCast(router->createSessionFromSecureConnection());
- if(!session)
- {
- cerr << argv[0]
- << ": Glacier2 returned a null session, please set the Glacier2.SSLSessionManager property"
- << endl;
- return EXIT_FAILURE;
- }
- }
- else
- {
- while(id.empty())
- {
- cout << "user id: " << flush;
- getline(cin, id);
- id = trim(id);
- }
-
- if(password.empty())
- {
- cout << "password: " << flush;
- getline(cin, password);
- password = trim(password);
- }
-
- session = AdminSessionPrx::uncheckedCast(router->createSession(id, password));
- if(!session)
- {
- cerr << argv[0]
- << ": Glacier2 returned a null session, please set the Glacier2.SessionManager property"
- << endl;
- return EXIT_FAILURE;
- }
- }
- timeout = static_cast<int>(router->getSessionTimeout());
- }
- else
- {
- Identity registryId;
- registryId.category = instanceName;
- registryId.name = "Registry";
- if(!replica.empty() && replica != "Master")
- {
- registryId.name += "-" + replica;
- }
-
- RegistryPrx registry;
- try
- {
- registry = RegistryPrx::checkedCast(
- communicator()->stringToProxy("\"" + communicator()->identityToString(registryId) + "\""));
- if(!registry)
- {
- cerr << argv[0] << ": could not contact registry" << endl;
- return EXIT_FAILURE;
- }
- }
- catch(const Ice::NotRegisteredException&)
- {
- cerr << argv[0] << ": no active registry replica named `" << replica << "'" << endl;
- return EXIT_FAILURE;
- }
-
- // Use SSL if available.
- try
- {
- registry = RegistryPrx::checkedCast(registry->ice_secure(true));
- }
- catch(const Ice::NoEndpointException&)
- {
- }
-
- if(ssl)
- {
- session = registry->createAdminSessionFromSecureConnection();
- }
- else
- {
- while(id.empty())
- {
- cout << "user id: " << flush;
- getline(cin, id);
- id = trim(id);
- }
-
- if(password.empty())
- {
- cout << "password: " << flush;
- getline(cin, password);
- password = trim(password);
- }
-
- session = registry->createAdminSession(id, password);
- }
- assert(session);
- timeout = registry->getSessionTimeout();
- }
-
- keepAlive = new SessionKeepAliveThread(session, timeout / 2);
- keepAlive->start();
-
- AdminPrx admin = session->getAdmin();
-
- Ice::SliceChecksumDict serverChecksums = admin->getSliceChecksums();
- Ice::SliceChecksumDict localChecksums = Ice::sliceChecksums();
-
- //
- // The following slice types are only used by the admin CLI.
- //
- localChecksums.erase("::IceGrid::FileParser");
- localChecksums.erase("::IceGrid::ParseException");
-
- for(Ice::SliceChecksumDict::const_iterator q = localChecksums.begin(); q != localChecksums.end(); ++q)
- {
- Ice::SliceChecksumDict::const_iterator r = serverChecksums.find(q->first);
- if(r == serverChecksums.end())
- {
- cerr << appName() << ": server is using unknown Slice type `" << q->first << "'" << endl;
- }
- else if(q->second != r->second)
- {
- cerr << appName() << ": server is using a different Slice definition of `" << q->first << "'" << endl;
- }
- }
-
- {
- Lock sync(*this);
- _parser = Parser::createParser(communicator(), session, admin, args.empty() && commands.empty());
- }
-
- if(!args.empty()) // Files given
- {
- // Process files given on the command line
- for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i)
- {
- ifstream test(i->c_str());
- if(!test)
- {
- cerr << appName() << ": can't open `" << *i << "' for reading: " << strerror(errno) << endl;
- return EXIT_FAILURE;
- }
- test.close();
-
- string cmd = cpp + " " + *i;
+ int timeout;
+ if(routed)
+ {
+ Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(communicator()->getDefaultRouter());
+ if(!router)
+ {
+ cerr << argv[0] << ": configured router is not a Glacier2 router" << endl;
+ return EXIT_FAILURE;
+ }
+
+ // Use SSL if available.
+ try
+ {
+ router = Glacier2::RouterPrx::checkedCast(router->ice_secure(true));
+ }
+ catch(const Ice::NoEndpointException&)
+ {
+ }
+
+ if(ssl)
+ {
+ session = AdminSessionPrx::uncheckedCast(router->createSessionFromSecureConnection());
+ if(!session)
+ {
+ cerr << argv[0]
+ << ": Glacier2 returned a null session, please set the Glacier2.SSLSessionManager property"
+ << endl;
+ return EXIT_FAILURE;
+ }
+ }
+ else
+ {
+ while(id.empty())
+ {
+ cout << "user id: " << flush;
+ getline(cin, id);
+ id = trim(id);
+ }
+
+ if(password.empty())
+ {
+ cout << "password: " << flush;
+ getline(cin, password);
+ password = trim(password);
+ }
+
+ session = AdminSessionPrx::uncheckedCast(router->createSession(id, password));
+ if(!session)
+ {
+ cerr << argv[0]
+ << ": Glacier2 returned a null session, please set the Glacier2.SessionManager property"
+ << endl;
+ return EXIT_FAILURE;
+ }
+ }
+ timeout = static_cast<int>(router->getSessionTimeout());
+ }
+ else
+ {
+ Identity registryId;
+ registryId.category = instanceName;
+ registryId.name = "Registry";
+ if(!replica.empty() && replica != "Master")
+ {
+ registryId.name += "-" + replica;
+ }
+
+ RegistryPrx registry;
+ try
+ {
+ registry = RegistryPrx::checkedCast(
+ communicator()->stringToProxy("\"" + communicator()->identityToString(registryId) + "\""));
+ if(!registry)
+ {
+ cerr << argv[0] << ": could not contact registry" << endl;
+ return EXIT_FAILURE;
+ }
+ }
+ catch(const Ice::NotRegisteredException&)
+ {
+ cerr << argv[0] << ": no active registry replica named `" << replica << "'" << endl;
+ return EXIT_FAILURE;
+ }
+
+ // Use SSL if available.
+ try
+ {
+ registry = RegistryPrx::checkedCast(registry->ice_secure(true));
+ }
+ catch(const Ice::NoEndpointException&)
+ {
+ }
+
+ if(ssl)
+ {
+ session = registry->createAdminSessionFromSecureConnection();
+ }
+ else
+ {
+ while(id.empty())
+ {
+ cout << "user id: " << flush;
+ getline(cin, id);
+ id = trim(id);
+ }
+
+ if(password.empty())
+ {
+ cout << "password: " << flush;
+ getline(cin, password);
+ password = trim(password);
+ }
+
+ session = registry->createAdminSession(id, password);
+ }
+ assert(session);
+ timeout = registry->getSessionTimeout();
+ }
+
+ keepAlive = new SessionKeepAliveThread(session, timeout / 2);
+ keepAlive->start();
+
+ AdminPrx admin = session->getAdmin();
+
+ Ice::SliceChecksumDict serverChecksums = admin->getSliceChecksums();
+ Ice::SliceChecksumDict localChecksums = Ice::sliceChecksums();
+
+ //
+ // The following slice types are only used by the admin CLI.
+ //
+ localChecksums.erase("::IceGrid::FileParser");
+ localChecksums.erase("::IceGrid::ParseException");
+
+ for(Ice::SliceChecksumDict::const_iterator q = localChecksums.begin(); q != localChecksums.end(); ++q)
+ {
+ Ice::SliceChecksumDict::const_iterator r = serverChecksums.find(q->first);
+ if(r == serverChecksums.end())
+ {
+ cerr << appName() << ": server is using unknown Slice type `" << q->first << "'" << endl;
+ }
+ else if(q->second != r->second)
+ {
+ cerr << appName() << ": server is using a different Slice definition of `" << q->first << "'" << endl;
+ }
+ }
+
+ {
+ Lock sync(*this);
+ _parser = Parser::createParser(communicator(), session, admin, args.empty() && commands.empty());
+ }
+
+ if(!args.empty()) // Files given
+ {
+ // Process files given on the command line
+ for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i)
+ {
+ ifstream test(i->c_str());
+ if(!test)
+ {
+ cerr << appName() << ": can't open `" << *i << "' for reading: " << strerror(errno) << endl;
+ return EXIT_FAILURE;
+ }
+ test.close();
+
+ string cmd = cpp + " " + *i;
#ifdef _WIN32
- FILE* cppHandle = _popen(cmd.c_str(), "r");
+ FILE* cppHandle = _popen(cmd.c_str(), "r");
#else
- FILE* cppHandle = popen(cmd.c_str(), "r");
+ FILE* cppHandle = popen(cmd.c_str(), "r");
#endif
- if(cppHandle == NULL)
- {
- cerr << appName() << ": can't run C++ preprocessor: " << strerror(errno) << endl;
- return EXIT_FAILURE;
- }
-
- int parseStatus = _parser->parse(cppHandle, debug);
-
+ if(cppHandle == NULL)
+ {
+ cerr << appName() << ": can't run C++ preprocessor: " << strerror(errno) << endl;
+ return EXIT_FAILURE;
+ }
+
+ int parseStatus = _parser->parse(cppHandle, debug);
+
#ifdef _WIN32
- _pclose(cppHandle);
+ _pclose(cppHandle);
#else
- pclose(cppHandle);
+ pclose(cppHandle);
#endif
- if(parseStatus == EXIT_FAILURE)
- {
- status = EXIT_FAILURE;
- }
- }
- }
- else if(!commands.empty()) // Commands were given
- {
- int parseStatus = _parser->parse(commands, debug);
- if(parseStatus == EXIT_FAILURE)
- {
- status = EXIT_FAILURE;
- }
- }
- else // No commands, let's use standard input
- {
- _parser->showBanner();
-
- int parseStatus = _parser->parse(stdin, debug);
- if(parseStatus == EXIT_FAILURE)
- {
- status = EXIT_FAILURE;
- }
- }
+ if(parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
+ }
+ }
+ else if(!commands.empty()) // Commands were given
+ {
+ int parseStatus = _parser->parse(commands, debug);
+ if(parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
+ }
+ else // No commands, let's use standard input
+ {
+ _parser->showBanner();
+
+ int parseStatus = _parser->parse(stdin, debug);
+ if(parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
+ }
}
catch(const IceGrid::PermissionDeniedException& ex)
{
- cout << "permission denied:\n" << ex.reason << endl;
- return EXIT_FAILURE;
+ cout << "permission denied:\n" << ex.reason << endl;
+ return EXIT_FAILURE;
}
catch(...)
{
- if(keepAlive)
- {
- keepAlive->destroy();
- keepAlive->getThreadControl().join();
- }
+ if(keepAlive)
+ {
+ keepAlive->destroy();
+ keepAlive->getThreadControl().join();
+ }
if(session)
{
@@ -615,7 +615,7 @@ Client::run(int argc, char* argv[])
{
}
}
- throw;
+ throw;
}
keepAlive->destroy();
diff --git a/cpp/src/IceGrid/Database.cpp b/cpp/src/IceGrid/Database.cpp
index aa4803f9269..15dafc7bf4d 100644
--- a/cpp/src/IceGrid/Database.cpp
+++ b/cpp/src/IceGrid/Database.cpp
@@ -38,17 +38,17 @@ struct ObjectLoadCI : binary_function<pair<Ice::ObjectPrx, float>&, pair<Ice::Ob
{
bool operator()(const pair<Ice::ObjectPrx, float>& lhs, const pair<Ice::ObjectPrx, float>& rhs)
{
- return lhs.second < rhs.second;
+ return lhs.second < rhs.second;
}
};
}
Database::Database(const Ice::ObjectAdapterPtr& registryAdapter,
- const IceStorm::TopicManagerPrx& topicManager,
- const string& instanceName,
- const TraceLevelsPtr& traceLevels,
- const RegistryInfo& info) :
+ const IceStorm::TopicManagerPrx& topicManager,
+ const string& instanceName,
+ const TraceLevelsPtr& traceLevels,
+ const RegistryInfo& info) :
_communicator(registryAdapter->getCommunicator()),
_internalAdapter(registryAdapter),
_topicManager(topicManager),
@@ -72,31 +72,31 @@ Database::Database(const Ice::ObjectAdapterPtr& registryAdapter,
ServerEntrySeq entries;
for(StringApplicationInfoDict::iterator p = _applications.begin(); p != _applications.end(); ++p)
{
- try
- {
- //
- // Create an application helper for the application
- // without instantiating. The application might be invalid
- // if we need to upgrade it.
- //
- ApplicationInfo info = p->second;
-
- ApplicationHelper helper(_communicator, p->second.descriptor, false, false);
- if(helper.upgrade(info.descriptor))
- {
- ++info.revision;
- info.updateUser = "IceGrid Registry (database upgrade)";
- info.updateTime = IceUtil::Time::now().toMilliSeconds();
- p.set(info);
- }
-
- load(ApplicationHelper(_communicator, info.descriptor), entries, info.uuid, info.revision);
- }
- catch(const DeploymentException& ex)
- {
- Ice::Error err(_traceLevels->logger);
- err << "invalid application `" << p->first << "':\n" << ex.reason;
- }
+ try
+ {
+ //
+ // Create an application helper for the application
+ // without instantiating. The application might be invalid
+ // if we need to upgrade it.
+ //
+ ApplicationInfo info = p->second;
+
+ ApplicationHelper helper(_communicator, p->second.descriptor, false, false);
+ if(helper.upgrade(info.descriptor))
+ {
+ ++info.revision;
+ info.updateUser = "IceGrid Registry (database upgrade)";
+ info.updateTime = IceUtil::Time::now().toMilliSeconds();
+ p.set(info);
+ }
+
+ load(ApplicationHelper(_communicator, info.descriptor), entries, info.uuid, info.revision);
+ }
+ catch(const DeploymentException& ex)
+ {
+ Ice::Error err(_traceLevels->logger);
+ err << "invalid application `" << p->first << "':\n" << ex.reason;
+ }
}
_serverCache.setTraceLevels(_traceLevels);
@@ -141,17 +141,17 @@ Database::getObserverTopic(TopicName name) const
switch(name)
{
case RegistryObserverTopicName:
- return _registryObserverTopic;
+ return _registryObserverTopic;
case NodeObserverTopicName:
- return _nodeObserverTopic;
+ return _nodeObserverTopic;
case ApplicationObserverTopicName:
- return _applicationObserverTopic;
+ return _applicationObserverTopic;
case AdapterObserverTopicName:
- return _adapterObserverTopic;
+ return _adapterObserverTopic;
case ObjectObserverTopicName:
- return _objectObserverTopic;
+ return _objectObserverTopic;
default:
- break;
+ break;
}
return 0;
}
@@ -161,7 +161,7 @@ Database::checkSessionLock(AdminSessionI* session)
{
if(_lock != 0 && session != _lock)
{
- throw AccessDeniedException(_lockUserId); // Lock held by another session.
+ throw AccessDeniedException(_lockUserId); // Lock held by another session.
}
}
@@ -172,7 +172,7 @@ Database::lock(AdminSessionI* session, const string& userId)
if(_lock != 0 && session != _lock)
{
- throw AccessDeniedException(_lockUserId); // Lock held by another session.
+ throw AccessDeniedException(_lockUserId); // Lock held by another session.
}
assert(_lock == 0 || _lock == session);
@@ -188,7 +188,7 @@ Database::unlock(AdminSessionI* session)
Lock sync(*this);
if(_lock != session)
{
- throw AccessDeniedException();
+ throw AccessDeniedException();
}
_lock = 0;
@@ -200,54 +200,54 @@ Database::syncApplications(const ApplicationInfoSeq& applications)
{
int serial;
{
- Lock sync(*this);
+ Lock sync(*this);
- Freeze::TransactionHolder txHolder(_connection);
- ServerEntrySeq entries;
- set<string> names;
- for(ApplicationInfoSeq::const_iterator p = applications.begin(); p != applications.end(); ++p)
- {
- try
- {
- StringApplicationInfoDict::const_iterator s = _applications.find(p->descriptor.name);
- if(s != _applications.end())
- {
- ApplicationHelper previous(_communicator, s->second.descriptor);
- ApplicationHelper helper(_communicator, p->descriptor);
- reload(previous, helper, entries, p->uuid, p->revision);
- }
- else
- {
- load(ApplicationHelper(_communicator, p->descriptor), entries, p->uuid, p->revision);
- }
- }
- catch(const DeploymentException& ex)
- {
- Ice::Warning warn(_traceLevels->logger);
- warn << "invalid application `" << p->descriptor.name << "':\n" << ex.reason;
- }
- _applications.put(StringApplicationInfoDict::value_type(p->descriptor.name, *p));
- names.insert(p->descriptor.name);
- }
-
- StringApplicationInfoDict::iterator s = _applications.begin();
- while(s != _applications.end())
- {
- if(names.find(s->first) == names.end())
- {
- unload(ApplicationHelper(_communicator, s->second.descriptor), entries);
- _applications.erase(s++);
- }
- else
- {
- ++s;
- }
- }
- ++_applicationSerial;
+ Freeze::TransactionHolder txHolder(_connection);
+ ServerEntrySeq entries;
+ set<string> names;
+ for(ApplicationInfoSeq::const_iterator p = applications.begin(); p != applications.end(); ++p)
+ {
+ try
+ {
+ StringApplicationInfoDict::const_iterator s = _applications.find(p->descriptor.name);
+ if(s != _applications.end())
+ {
+ ApplicationHelper previous(_communicator, s->second.descriptor);
+ ApplicationHelper helper(_communicator, p->descriptor);
+ reload(previous, helper, entries, p->uuid, p->revision);
+ }
+ else
+ {
+ load(ApplicationHelper(_communicator, p->descriptor), entries, p->uuid, p->revision);
+ }
+ }
+ catch(const DeploymentException& ex)
+ {
+ Ice::Warning warn(_traceLevels->logger);
+ warn << "invalid application `" << p->descriptor.name << "':\n" << ex.reason;
+ }
+ _applications.put(StringApplicationInfoDict::value_type(p->descriptor.name, *p));
+ names.insert(p->descriptor.name);
+ }
+
+ StringApplicationInfoDict::iterator s = _applications.begin();
+ while(s != _applications.end())
+ {
+ if(names.find(s->first) == names.end())
+ {
+ unload(ApplicationHelper(_communicator, s->second.descriptor), entries);
+ _applications.erase(s++);
+ }
+ else
+ {
+ ++s;
+ }
+ }
+ ++_applicationSerial;
- serial = _applicationObserverTopic->applicationInit(_applicationSerial, applications);
+ serial = _applicationObserverTopic->applicationInit(_applicationSerial, applications);
- txHolder.commit();
+ txHolder.commit();
}
_applicationObserverTopic->waitForSyncedSubscribers(serial);
}
@@ -257,15 +257,15 @@ Database::syncAdapters(const AdapterInfoSeq& adapters)
{
int serial;
{
- Lock sync(*this);
- Freeze::TransactionHolder txHolder(_connection);
- _adapters.clear();
- for(AdapterInfoSeq::const_iterator r = adapters.begin(); r != adapters.end(); ++r)
- {
- _adapters.put(StringAdapterInfoDict::value_type(r->id, *r));
- }
- serial = _adapterObserverTopic->adapterInit(adapters);
- txHolder.commit();
+ Lock sync(*this);
+ Freeze::TransactionHolder txHolder(_connection);
+ _adapters.clear();
+ for(AdapterInfoSeq::const_iterator r = adapters.begin(); r != adapters.end(); ++r)
+ {
+ _adapters.put(StringAdapterInfoDict::value_type(r->id, *r));
+ }
+ serial = _adapterObserverTopic->adapterInit(adapters);
+ txHolder.commit();
}
_adapterObserverTopic->waitForSyncedSubscribers(serial);
}
@@ -275,15 +275,15 @@ Database::syncObjects(const ObjectInfoSeq& objects)
{
int serial;
{
- Lock sync(*this);
- Freeze::TransactionHolder txHolder(_connection);
- _objects.clear();
- for(ObjectInfoSeq::const_iterator q = objects.begin(); q != objects.end(); ++q)
- {
- _objects.put(IdentityObjectInfoDict::value_type(q->proxy->ice_getIdentity(), *q));
- }
- serial = _objectObserverTopic->objectInit(objects);
- txHolder.commit();
+ Lock sync(*this);
+ Freeze::TransactionHolder txHolder(_connection);
+ _objects.clear();
+ for(ObjectInfoSeq::const_iterator q = objects.begin(); q != objects.end(); ++q)
+ {
+ _objects.put(IdentityObjectInfoDict::value_type(q->proxy->ice_getIdentity(), *q));
+ }
+ serial = _objectObserverTopic->objectInit(objects);
+ txHolder.commit();
}
_objectObserverTopic->waitForSyncedSubscribers(serial);
}
@@ -293,62 +293,62 @@ Database::addApplication(const ApplicationInfo& info, AdminSessionI* session)
{
ServerEntrySeq entries;
{
- Lock sync(*this);
- checkSessionLock(session);
+ Lock sync(*this);
+ checkSessionLock(session);
- while(_updating.find(info.descriptor.name) != _updating.end())
- {
- wait();
- }
+ while(_updating.find(info.descriptor.name) != _updating.end())
+ {
+ wait();
+ }
- if(_applications.find(info.descriptor.name) != _applications.end())
- {
- throw DeploymentException("application `" + info.descriptor.name + "' already exists");
- }
+ if(_applications.find(info.descriptor.name) != _applications.end())
+ {
+ throw DeploymentException("application `" + info.descriptor.name + "' already exists");
+ }
- ApplicationHelper helper(_communicator, info.descriptor, true);
- checkForAddition(helper);
- load(helper, entries, info.uuid, info.revision);
- startUpdating(info.descriptor.name);
+ ApplicationHelper helper(_communicator, info.descriptor, true);
+ checkForAddition(helper);
+ load(helper, entries, info.uuid, info.revision);
+ startUpdating(info.descriptor.name);
}
if(_master)
{
- try
- {
- for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::syncAndWait));
- }
- catch(const DeploymentException& ex)
- {
- try
- {
- Lock sync(*this);
- entries.clear();
- unload(ApplicationHelper(_communicator, info.descriptor), entries);
- }
- catch(const DeploymentException& ex)
- {
- Ice::Error err(_traceLevels->logger);
- err << "failed to rollback previous application `" << info.descriptor.name << "':\n" << ex.reason;
- }
- finishUpdating(info.descriptor.name);
- throw ex;
- }
+ try
+ {
+ for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::syncAndWait));
+ }
+ catch(const DeploymentException& ex)
+ {
+ try
+ {
+ Lock sync(*this);
+ entries.clear();
+ unload(ApplicationHelper(_communicator, info.descriptor), entries);
+ }
+ catch(const DeploymentException& ex)
+ {
+ Ice::Error err(_traceLevels->logger);
+ err << "failed to rollback previous application `" << info.descriptor.name << "':\n" << ex.reason;
+ }
+ finishUpdating(info.descriptor.name);
+ throw ex;
+ }
}
int serial;
{
- Lock sync(*this);
- ++_applicationSerial;
- _applications.put(StringApplicationInfoDict::value_type(info.descriptor.name, info));
+ Lock sync(*this);
+ ++_applicationSerial;
+ _applications.put(StringApplicationInfoDict::value_type(info.descriptor.name, info));
- serial = _applicationObserverTopic->applicationAdded(_applicationSerial, info);
+ serial = _applicationObserverTopic->applicationAdded(_applicationSerial, info);
- if(_traceLevels->application > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->applicationCat);
- out << "added application `" << info.descriptor.name << "'";
- }
+ if(_traceLevels->application > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->applicationCat);
+ out << "added application `" << info.descriptor.name << "'";
+ }
}
_applicationObserverTopic->waitForSyncedSubscribers(serial);
@@ -364,35 +364,35 @@ Database::updateApplication(const ApplicationUpdateInfo& updt, AdminSessionI* se
ApplicationDescriptor newDesc;
ApplicationUpdateInfo update = updt;
{
- Lock sync(*this);
- checkSessionLock(session);
+ Lock sync(*this);
+ checkSessionLock(session);
- while(_updating.find(update.descriptor.name) != _updating.end())
- {
- wait();
- }
+ while(_updating.find(update.descriptor.name) != _updating.end())
+ {
+ wait();
+ }
- StringApplicationInfoDict::const_iterator p = _applications.find(update.descriptor.name);
- if(p == _applications.end())
- {
- throw ApplicationNotExistException(update.descriptor.name);
- }
- oldApp = p->second;
+ StringApplicationInfoDict::const_iterator p = _applications.find(update.descriptor.name);
+ if(p == _applications.end())
+ {
+ throw ApplicationNotExistException(update.descriptor.name);
+ }
+ oldApp = p->second;
- if(update.revision < 0)
- {
- update.revision = oldApp.revision + 1;
- }
+ if(update.revision < 0)
+ {
+ update.revision = oldApp.revision + 1;
+ }
- ApplicationHelper previous(_communicator, oldApp.descriptor);
- ApplicationHelper helper(_communicator, previous.update(update.descriptor), true);
+ ApplicationHelper previous(_communicator, oldApp.descriptor);
+ ApplicationHelper helper(_communicator, previous.update(update.descriptor), true);
- checkForUpdate(previous, helper);
- reload(previous, helper, entries, oldApp.uuid, oldApp.revision + 1);
+ checkForUpdate(previous, helper);
+ reload(previous, helper, entries, oldApp.uuid, oldApp.revision + 1);
- newDesc = helper.getDefinition();
+ newDesc = helper.getDefinition();
- startUpdating(update.descriptor.name);
+ startUpdating(update.descriptor.name);
}
finishApplicationUpdate(entries, update, oldApp, newDesc, session);
@@ -405,33 +405,33 @@ Database::syncApplicationDescriptor(const ApplicationDescriptor& newDesc, AdminS
ApplicationUpdateInfo update;
ApplicationInfo oldApp;
{
- Lock sync(*this);
- checkSessionLock(session);
+ Lock sync(*this);
+ checkSessionLock(session);
- while(_updating.find(update.descriptor.name) != _updating.end())
- {
- wait();
- }
+ while(_updating.find(update.descriptor.name) != _updating.end())
+ {
+ wait();
+ }
- StringApplicationInfoDict::const_iterator p = _applications.find(newDesc.name);
- if(p == _applications.end())
- {
- throw ApplicationNotExistException(newDesc.name);
- }
- oldApp = p->second;
+ StringApplicationInfoDict::const_iterator p = _applications.find(newDesc.name);
+ if(p == _applications.end())
+ {
+ throw ApplicationNotExistException(newDesc.name);
+ }
+ oldApp = p->second;
- ApplicationHelper previous(_communicator, oldApp.descriptor);
- ApplicationHelper helper(_communicator, newDesc, true);
+ ApplicationHelper previous(_communicator, oldApp.descriptor);
+ ApplicationHelper helper(_communicator, newDesc, true);
- update.updateTime = IceUtil::Time::now().toMilliSeconds();
- update.updateUser = _lockUserId;
- update.revision = oldApp.revision + 1;
- update.descriptor = helper.diff(previous);
-
- checkForUpdate(previous, helper);
- reload(previous, helper, entries, oldApp.uuid, oldApp.revision + 1);
+ update.updateTime = IceUtil::Time::now().toMilliSeconds();
+ update.updateUser = _lockUserId;
+ update.revision = oldApp.revision + 1;
+ update.descriptor = helper.diff(previous);
+
+ checkForUpdate(previous, helper);
+ reload(previous, helper, entries, oldApp.uuid, oldApp.revision + 1);
- startUpdating(update.descriptor.name);
+ startUpdating(update.descriptor.name);
}
finishApplicationUpdate(entries, update, oldApp, newDesc, session);
@@ -439,44 +439,44 @@ Database::syncApplicationDescriptor(const ApplicationDescriptor& newDesc, AdminS
void
Database::instantiateServer(const string& application,
- const string& node,
- const ServerInstanceDescriptor& instance,
- AdminSessionI* session)
+ const string& node,
+ const ServerInstanceDescriptor& instance,
+ AdminSessionI* session)
{
ServerEntrySeq entries;
ApplicationUpdateInfo update;
ApplicationInfo oldApp;
ApplicationDescriptor newDesc;
{
- Lock sync(*this);
- checkSessionLock(session);
+ Lock sync(*this);
+ checkSessionLock(session);
- while(_updating.find(application) != _updating.end())
- {
- wait();
- }
+ while(_updating.find(application) != _updating.end())
+ {
+ wait();
+ }
- StringApplicationInfoDict::const_iterator p = _applications.find(application);
- if(p == _applications.end())
- {
- throw ApplicationNotExistException(application);
- }
- oldApp = p->second;
+ StringApplicationInfoDict::const_iterator p = _applications.find(application);
+ if(p == _applications.end())
+ {
+ throw ApplicationNotExistException(application);
+ }
+ oldApp = p->second;
- ApplicationHelper previous(_communicator, oldApp.descriptor);
- ApplicationHelper helper(_communicator, previous.instantiateServer(node, instance), true);
+ ApplicationHelper previous(_communicator, oldApp.descriptor);
+ ApplicationHelper helper(_communicator, previous.instantiateServer(node, instance), true);
- update.updateTime = IceUtil::Time::now().toMilliSeconds();
- update.updateUser = _lockUserId;
- update.revision = oldApp.revision + 1;
- update.descriptor = helper.diff(previous);
+ update.updateTime = IceUtil::Time::now().toMilliSeconds();
+ update.updateUser = _lockUserId;
+ update.revision = oldApp.revision + 1;
+ update.descriptor = helper.diff(previous);
- checkForUpdate(previous, helper);
- reload(previous, helper, entries, oldApp.uuid, oldApp.revision + 1);
+ checkForUpdate(previous, helper);
+ reload(previous, helper, entries, oldApp.uuid, oldApp.revision + 1);
- newDesc = helper.getDefinition();
+ newDesc = helper.getDefinition();
- startUpdating(update.descriptor.name);
+ startUpdating(update.descriptor.name);
}
finishApplicationUpdate(entries, update, oldApp, newDesc, session);
@@ -488,55 +488,55 @@ Database::removeApplication(const string& name, AdminSessionI* session)
ServerEntrySeq entries;
int serial;
{
- Lock sync(*this);
- checkSessionLock(session);
-
- while(_updating.find(name) != _updating.end())
- {
- wait();
- }
-
- StringApplicationInfoDict::iterator p = _applications.find(name);
- if(p == _applications.end())
- {
- throw ApplicationNotExistException(name);
- }
-
- try
- {
- ApplicationHelper helper(_communicator, p->second.descriptor);
- unload(helper, entries);
- }
- catch(const DeploymentException&)
- {
- //
- // For some reasons the application became invalid. If
- // it's invalid, it's most likely not loaded either. So we
- // ignore the error and erase the descriptor.
- //
- }
-
- startUpdating(name);
+ Lock sync(*this);
+ checkSessionLock(session);
+
+ while(_updating.find(name) != _updating.end())
+ {
+ wait();
+ }
+
+ StringApplicationInfoDict::iterator p = _applications.find(name);
+ if(p == _applications.end())
+ {
+ throw ApplicationNotExistException(name);
+ }
+
+ try
+ {
+ ApplicationHelper helper(_communicator, p->second.descriptor);
+ unload(helper, entries);
+ }
+ catch(const DeploymentException&)
+ {
+ //
+ // For some reasons the application became invalid. If
+ // it's invalid, it's most likely not loaded either. So we
+ // ignore the error and erase the descriptor.
+ //
+ }
+
+ startUpdating(name);
}
if(_master)
{
- for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::sync));
- for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::waitNoThrow));
+ for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::sync));
+ for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::waitNoThrow));
}
{
- Lock sync(*this);
- _applications.erase(name);
- ++_applicationSerial;
+ Lock sync(*this);
+ _applications.erase(name);
+ ++_applicationSerial;
- serial = _applicationObserverTopic->applicationRemoved(_applicationSerial, name);
+ serial = _applicationObserverTopic->applicationRemoved(_applicationSerial, name);
- if(_traceLevels->application > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->applicationCat);
- out << "removed application `" << name << "'";
- }
+ if(_traceLevels->application > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->applicationCat);
+ out << "removed application `" << name << "'";
+ }
}
_applicationObserverTopic->waitForSyncedSubscribers(serial);
@@ -553,7 +553,7 @@ Database::getApplicationInfo(const std::string& name)
StringApplicationInfoDict::const_iterator p = descriptors.find(name);
if(p == descriptors.end())
{
- throw ApplicationNotExistException(name);
+ throw ApplicationNotExistException(name);
}
return p->second;
@@ -569,18 +569,18 @@ Database::getAllApplications(const string& expression)
void
Database::waitForApplicationUpdate(const AMD_NodeSession_waitForApplicationUpdatePtr& cb,
- const string& application,
- int revision)
+ const string& application,
+ int revision)
{
Lock sync(*this);
map<string, vector<AMD_NodeSession_waitForApplicationUpdatePtr> >::iterator p = _updating.find(application);
if(p != _updating.end())
{
- p->second.push_back(cb);
+ p->second.push_back(cb);
}
else
{
- cb->ice_response();
+ cb->ice_response();
}
}
@@ -637,67 +637,67 @@ Database::setAdapterDirectProxy(const string& adapterId, const string& replicaGr
{
int serial;
{
- Lock sync(*this);
- if(_adapterCache.has(adapterId))
- {
- throw AdapterExistsException(adapterId);
- }
-
- StringAdapterInfoDict::iterator p = _adapters.find(adapterId);
- AdapterInfo info;
- bool updated = false;
- if(proxy)
- {
- if(p != _adapters.end())
- {
- info = p->second;
- info.proxy = proxy;
- info.replicaGroupId = replicaGroupId;
- p.set(info);
- updated = true;
- }
- else
- {
- info.id = adapterId;
- info.proxy = proxy;
- info.replicaGroupId = replicaGroupId;
- _adapters.put(StringAdapterInfoDict::value_type(adapterId, info));
- }
- }
- else
- {
- if(p == _adapters.end())
- {
- return;
- }
- _adapters.erase(p);
- }
-
- if(_traceLevels->adapter > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
- out << (proxy ? (updated ? "updated" : "added") : "removed") << " adapter `" << adapterId << "'";
- if(!replicaGroupId.empty())
- {
- out << " with replica group `" << replicaGroupId << "'";
- }
- }
+ Lock sync(*this);
+ if(_adapterCache.has(adapterId))
+ {
+ throw AdapterExistsException(adapterId);
+ }
+
+ StringAdapterInfoDict::iterator p = _adapters.find(adapterId);
+ AdapterInfo info;
+ bool updated = false;
+ if(proxy)
+ {
+ if(p != _adapters.end())
+ {
+ info = p->second;
+ info.proxy = proxy;
+ info.replicaGroupId = replicaGroupId;
+ p.set(info);
+ updated = true;
+ }
+ else
+ {
+ info.id = adapterId;
+ info.proxy = proxy;
+ info.replicaGroupId = replicaGroupId;
+ _adapters.put(StringAdapterInfoDict::value_type(adapterId, info));
+ }
+ }
+ else
+ {
+ if(p == _adapters.end())
+ {
+ return;
+ }
+ _adapters.erase(p);
+ }
+
+ if(_traceLevels->adapter > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
+ out << (proxy ? (updated ? "updated" : "added") : "removed") << " adapter `" << adapterId << "'";
+ if(!replicaGroupId.empty())
+ {
+ out << " with replica group `" << replicaGroupId << "'";
+ }
+ }
- if(proxy)
- {
- if(updated)
- {
- serial = _adapterObserverTopic->adapterUpdated(info);
- }
- else
- {
- serial = _adapterObserverTopic->adapterAdded(info);
- }
- }
- else
- {
- serial = _adapterObserverTopic->adapterRemoved(adapterId);
- }
+ if(proxy)
+ {
+ if(updated)
+ {
+ serial = _adapterObserverTopic->adapterUpdated(info);
+ }
+ else
+ {
+ serial = _adapterObserverTopic->adapterAdded(info);
+ }
+ }
+ else
+ {
+ serial = _adapterObserverTopic->adapterRemoved(adapterId);
+ }
}
_adapterObserverTopic->waitForSyncedSubscribers(serial);
}
@@ -710,18 +710,18 @@ Database::getAdapterDirectProxy(const string& id)
StringAdapterInfoDict::const_iterator p = adapters.find(id);
if(p != adapters.end())
{
- return p->second.proxy;
+ return p->second.proxy;
}
Ice::EndpointSeq endpoints;
for(p = adapters.findByReplicaGroupId(id, true); p != adapters.end(); ++p)
{
- Ice::EndpointSeq edpts = p->second.proxy->ice_getEndpoints();
- endpoints.insert(endpoints.end(), edpts.begin(), edpts.end());
+ Ice::EndpointSeq edpts = p->second.proxy->ice_getEndpoints();
+ endpoints.insert(endpoints.end(), edpts.begin(), edpts.end());
}
if(!endpoints.empty())
{
- return _communicator->stringToProxy("dummy:default")->ice_endpoints(endpoints);
+ return _communicator->stringToProxy("dummy:default")->ice_endpoints(endpoints);
}
throw AdapterNotExistException(id);
@@ -732,61 +732,61 @@ Database::removeAdapter(const string& adapterId)
{
int serial;
{
- Lock sync(*this);
- if(_adapterCache.has(adapterId))
- {
- AdapterEntryPtr adpt = _adapterCache.get(adapterId);
- DeploymentException ex;
- ex.reason = "removing adapter `" + adapterId + "' is not allowed:\n";
- ex.reason += "the adapter was added with the application descriptor `" + adpt->getApplication() + "'";
- throw ex;
- }
-
- Freeze::TransactionHolder txHolder(_connection); // Required because of the iterator
-
- StringAdapterInfoDict::iterator p = _adapters.find(adapterId);
- AdapterInfoSeq infos;
- if(p != _adapters.end())
- {
- _adapters.erase(p);
- }
- else
- {
- p = _adapters.findByReplicaGroupId(adapterId, true);
- if(p == _adapters.end())
- {
- throw AdapterNotExistException(adapterId);
- }
-
- while(p != _adapters.end())
- {
- AdapterInfo info = p->second;
- info.replicaGroupId = "";
- infos.push_back(info);
- _adapters.put(StringAdapterInfoDict::value_type(p->first, info));
- ++p;
- }
- }
-
- if(_traceLevels->adapter > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
- out << "removed " << (infos.empty() ? "adapter" : "replica group") << " `" << adapterId << "'";
- }
-
- if(infos.empty())
- {
- serial = _adapterObserverTopic->adapterRemoved(adapterId);
- }
- else
- {
- for(AdapterInfoSeq::const_iterator p = infos.begin(); p != infos.end(); ++p)
- {
- serial = _adapterObserverTopic->adapterUpdated(*p);
- }
- }
-
- txHolder.commit();
+ Lock sync(*this);
+ if(_adapterCache.has(adapterId))
+ {
+ AdapterEntryPtr adpt = _adapterCache.get(adapterId);
+ DeploymentException ex;
+ ex.reason = "removing adapter `" + adapterId + "' is not allowed:\n";
+ ex.reason += "the adapter was added with the application descriptor `" + adpt->getApplication() + "'";
+ throw ex;
+ }
+
+ Freeze::TransactionHolder txHolder(_connection); // Required because of the iterator
+
+ StringAdapterInfoDict::iterator p = _adapters.find(adapterId);
+ AdapterInfoSeq infos;
+ if(p != _adapters.end())
+ {
+ _adapters.erase(p);
+ }
+ else
+ {
+ p = _adapters.findByReplicaGroupId(adapterId, true);
+ if(p == _adapters.end())
+ {
+ throw AdapterNotExistException(adapterId);
+ }
+
+ while(p != _adapters.end())
+ {
+ AdapterInfo info = p->second;
+ info.replicaGroupId = "";
+ infos.push_back(info);
+ _adapters.put(StringAdapterInfoDict::value_type(p->first, info));
+ ++p;
+ }
+ }
+
+ if(_traceLevels->adapter > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->adapterCat);
+ out << "removed " << (infos.empty() ? "adapter" : "replica group") << " `" << adapterId << "'";
+ }
+
+ if(infos.empty())
+ {
+ serial = _adapterObserverTopic->adapterRemoved(adapterId);
+ }
+ else
+ {
+ for(AdapterInfoSeq::const_iterator p = infos.begin(); p != infos.end(); ++p)
+ {
+ serial = _adapterObserverTopic->adapterUpdated(*p);
+ }
+ }
+
+ txHolder.commit();
}
_adapterObserverTopic->waitForSyncedSubscribers(serial);
}
@@ -807,7 +807,7 @@ Database::getAdapterInfo(const string& id)
//
try
{
- return _adapterCache.get(id)->getAdapterInfo();
+ return _adapterCache.get(id)->getAdapterInfo();
}
catch(AdapterNotExistException&)
{
@@ -822,9 +822,9 @@ Database::getAdapterInfo(const string& id)
StringAdapterInfoDict::const_iterator p = adapters.find(id);
if(p != adapters.end())
{
- AdapterInfoSeq infos;
- infos.push_back(p->second);
- return infos;
+ AdapterInfoSeq infos;
+ infos.push_back(p->second);
+ return infos;
}
//
@@ -834,13 +834,13 @@ Database::getAdapterInfo(const string& id)
p = adapters.findByReplicaGroupId(id, true);
if(p != adapters.end())
{
- AdapterInfoSeq infos;
- while(p != adapters.end())
- {
- infos.push_back(p->second);
- ++p;
- }
- return infos;
+ AdapterInfoSeq infos;
+ while(p != adapters.end())
+ {
+ infos.push_back(p->second);
+ ++p;
+ }
+ return infos;
}
throw AdapterNotExistException(id);
@@ -857,15 +857,15 @@ Database::getAllAdapters(const string& expression)
set<string> groups;
for(StringAdapterInfoDict::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
{
- if(expression.empty() || IceUtil::match(p->first, expression, true))
- {
- result.push_back(p->first);
- }
- string replicaGroupId = p->second.replicaGroupId;
- if(!replicaGroupId.empty() && (expression.empty() || IceUtil::match(replicaGroupId, expression, true)))
- {
- groups.insert(replicaGroupId);
- }
+ if(expression.empty() || IceUtil::match(p->first, expression, true))
+ {
+ result.push_back(p->first);
+ }
+ string replicaGroupId = p->second.replicaGroupId;
+ if(!replicaGroupId.empty() && (expression.empty() || IceUtil::match(replicaGroupId, expression, true)))
+ {
+ groups.insert(replicaGroupId);
+ }
}
//
// COMPILERFIX: We're not using result.insert() here, this doesn't compile on Sun.
@@ -873,7 +873,7 @@ Database::getAllAdapters(const string& expression)
//result.insert(result.end(), groups.begin(), groups.end())
for(set<string>::const_iterator q = groups.begin(); q != groups.end(); ++q)
{
- result.push_back(*q);
+ result.push_back(*q);
}
return result;
}
@@ -883,27 +883,27 @@ Database::addObject(const ObjectInfo& info)
{
int serial;
{
- Lock sync(*this);
- const Ice::Identity id = info.proxy->ice_getIdentity();
-
- if(_objectCache.has(id))
- {
- throw ObjectExistsException(id);
- }
-
- if(_objects.find(id) != _objects.end())
- {
- throw ObjectExistsException(id);
- }
- _objects.put(IdentityObjectInfoDict::value_type(id, info));
-
- serial = _objectObserverTopic->objectAdded(info);
-
- if(_traceLevels->object > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
- out << "added object `" << _communicator->identityToString(id) << "'";
- }
+ Lock sync(*this);
+ const Ice::Identity id = info.proxy->ice_getIdentity();
+
+ if(_objectCache.has(id))
+ {
+ throw ObjectExistsException(id);
+ }
+
+ if(_objects.find(id) != _objects.end())
+ {
+ throw ObjectExistsException(id);
+ }
+ _objects.put(IdentityObjectInfoDict::value_type(id, info));
+
+ serial = _objectObserverTopic->objectAdded(info);
+
+ if(_traceLevels->object > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
+ out << "added object `" << _communicator->identityToString(id) << "'";
+ }
}
_objectObserverTopic->waitForSyncedSubscribers(serial);
}
@@ -913,31 +913,31 @@ Database::addOrUpdateObject(const ObjectInfo& info)
{
int serial;
{
- Lock sync(*this);
- const Ice::Identity id = info.proxy->ice_getIdentity();
-
- if(_objectCache.has(id))
- {
- throw ObjectExistsException(id);
- }
-
- bool update = _objects.find(id) != _objects.end();
- _objects.put(IdentityObjectInfoDict::value_type(id, info));
-
- if(update)
- {
- serial = _objectObserverTopic->objectUpdated(info);
- }
- else
- {
- serial = _objectObserverTopic->objectAdded(info);
- }
-
- if(_traceLevels->object > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
- out << (!update ? "added" : "updated") << " object `" << _communicator->identityToString(id) << "'";
- }
+ Lock sync(*this);
+ const Ice::Identity id = info.proxy->ice_getIdentity();
+
+ if(_objectCache.has(id))
+ {
+ throw ObjectExistsException(id);
+ }
+
+ bool update = _objects.find(id) != _objects.end();
+ _objects.put(IdentityObjectInfoDict::value_type(id, info));
+
+ if(update)
+ {
+ serial = _objectObserverTopic->objectUpdated(info);
+ }
+ else
+ {
+ serial = _objectObserverTopic->objectAdded(info);
+ }
+
+ if(_traceLevels->object > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
+ out << (!update ? "added" : "updated") << " object `" << _communicator->identityToString(id) << "'";
+ }
}
_objectObserverTopic->waitForSyncedSubscribers(serial);
}
@@ -947,33 +947,33 @@ Database::removeObject(const Ice::Identity& id)
{
int serial;
{
- Lock sync(*this);
- if(_objectCache.has(id))
- {
- DeploymentException ex;
- ex.reason = "removing object `" + _communicator->identityToString(id) + "' is not allowed:\n";
- ex.reason += "the object was added with the application descriptor `";
- ex.reason += _objectCache.get(id)->getApplication();
- ex.reason += "'";
- throw ex;
- }
-
- IdentityObjectInfoDict::iterator p = _objects.find(id);
- if(p == _objects.end())
- {
- ObjectNotRegisteredException ex;
- ex.id = id;
- throw ex;
- }
- _objects.erase(p);
-
- serial = _objectObserverTopic->objectRemoved(id);
-
- if(_traceLevels->object > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
- out << "removed object `" << _communicator->identityToString(id) << "'";
- }
+ Lock sync(*this);
+ if(_objectCache.has(id))
+ {
+ DeploymentException ex;
+ ex.reason = "removing object `" + _communicator->identityToString(id) + "' is not allowed:\n";
+ ex.reason += "the object was added with the application descriptor `";
+ ex.reason += _objectCache.get(id)->getApplication();
+ ex.reason += "'";
+ throw ex;
+ }
+
+ IdentityObjectInfoDict::iterator p = _objects.find(id);
+ if(p == _objects.end())
+ {
+ ObjectNotRegisteredException ex;
+ ex.id = id;
+ throw ex;
+ }
+ _objects.erase(p);
+
+ serial = _objectObserverTopic->objectRemoved(id);
+
+ if(_traceLevels->object > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
+ out << "removed object `" << _communicator->identityToString(id) << "'";
+ }
}
_objectObserverTopic->waitForSyncedSubscribers(serial);
}
@@ -983,39 +983,39 @@ Database::updateObject(const Ice::ObjectPrx& proxy)
{
int serial;
{
- Lock sync(*this);
-
- const Ice::Identity id = proxy->ice_getIdentity();
- if(_objectCache.has(id))
- {
- DeploymentException ex;
- ex.reason = "updating object `" + _communicator->identityToString(id) + "' is not allowed:\n";
- ex.reason += "the object was added with the application descriptor `";
- ex.reason += _objectCache.get(id)->getApplication();
- ex.reason += "'";
- throw ex;
- }
+ Lock sync(*this);
+
+ const Ice::Identity id = proxy->ice_getIdentity();
+ if(_objectCache.has(id))
+ {
+ DeploymentException ex;
+ ex.reason = "updating object `" + _communicator->identityToString(id) + "' is not allowed:\n";
+ ex.reason += "the object was added with the application descriptor `";
+ ex.reason += _objectCache.get(id)->getApplication();
+ ex.reason += "'";
+ throw ex;
+ }
- IdentityObjectInfoDict::iterator p = _objects.find(id);
- if(p == _objects.end())
- {
- ObjectNotRegisteredException ex;
- ex.id = id;
- throw ex;
- }
-
- ObjectInfo info;
- info = p->second;
- info.proxy = proxy;
- p.set(info);
+ IdentityObjectInfoDict::iterator p = _objects.find(id);
+ if(p == _objects.end())
+ {
+ ObjectNotRegisteredException ex;
+ ex.id = id;
+ throw ex;
+ }
+
+ ObjectInfo info;
+ info = p->second;
+ info.proxy = proxy;
+ p.set(info);
- serial = _objectObserverTopic->objectUpdated(info);
-
- if(_traceLevels->object > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
- out << "updated object `" << _communicator->identityToString(id) << "'";
- }
+ serial = _objectObserverTopic->objectUpdated(info);
+
+ if(_traceLevels->object > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
+ out << "updated object `" << _communicator->identityToString(id) << "'";
+ }
}
_objectObserverTopic->waitForSyncedSubscribers(serial);
}
@@ -1027,7 +1027,7 @@ Database::addOrUpdateObjectsInDatabase(const ObjectInfoSeq& objects)
Freeze::TransactionHolder txHolder(_connection);
for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
{
- _objects.put(IdentityObjectInfoDict::value_type(p->proxy->ice_getIdentity(), *p));
+ _objects.put(IdentityObjectInfoDict::value_type(p->proxy->ice_getIdentity(), *p));
}
int serial = _objectObserverTopic->objectsAddedOrUpdated(objects);
txHolder.commit();
@@ -1041,7 +1041,7 @@ Database::removeObjectsInDatabase(const ObjectInfoSeq& objects)
Freeze::TransactionHolder txHolder(_connection);
for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
{
- _objects.erase(p->proxy->ice_getIdentity());
+ _objects.erase(p->proxy->ice_getIdentity());
}
_objectObserverTopic->objectsRemoved(objects);
txHolder.commit();
@@ -1052,10 +1052,10 @@ Database::getObjectProxy(const Ice::Identity& id)
{
try
{
- //
- // Only return proxies for non allocatable objects.
- //
- return _objectCache.get(id)->getProxy();
+ //
+ // Only return proxies for non allocatable objects.
+ //
+ return _objectCache.get(id)->getProxy();
}
catch(ObjectNotRegisteredException&)
{
@@ -1066,9 +1066,9 @@ Database::getObjectProxy(const Ice::Identity& id)
IdentityObjectInfoDict::const_iterator p = objects.find(id);
if(p == objects.end())
{
- ObjectNotRegisteredException ex;
- ex.id = id;
- throw ex;
+ ObjectNotRegisteredException ex;
+ ex.id = id;
+ throw ex;
}
return p->second.proxy;
}
@@ -1079,7 +1079,7 @@ Database::getObjectByType(const string& type)
Ice::ObjectProxySeq objs = getObjectsByType(type);
if(objs.empty())
{
- return 0;
+ return 0;
}
return objs[IceUtil::random(static_cast<int>(objs.size()))];
}
@@ -1090,7 +1090,7 @@ Database::getObjectByTypeOnLeastLoadedNode(const string& type, LoadSample sample
Ice::ObjectProxySeq objs = getObjectsByType(type);
if(objs.empty())
{
- return 0;
+ return 0;
}
RandomNumberGenerator rng;
@@ -1099,18 +1099,18 @@ Database::getObjectByTypeOnLeastLoadedNode(const string& type, LoadSample sample
objectsWithLoad.reserve(objs.size());
for(Ice::ObjectProxySeq::const_iterator p = objs.begin(); p != objs.end(); ++p)
{
- float load = 1.0f;
- if(!(*p)->ice_getAdapterId().empty())
- {
- try
- {
- load = _adapterCache.get((*p)->ice_getAdapterId())->getLeastLoadedNodeLoad(sample);
- }
- catch(const AdapterNotExistException&)
- {
- }
- }
- objectsWithLoad.push_back(make_pair(*p, load));
+ float load = 1.0f;
+ if(!(*p)->ice_getAdapterId().empty())
+ {
+ try
+ {
+ load = _adapterCache.get((*p)->ice_getAdapterId())->getLeastLoadedNodeLoad(sample);
+ }
+ catch(const AdapterNotExistException&)
+ {
+ }
+ }
+ objectsWithLoad.push_back(make_pair(*p, load));
}
return min_element(objectsWithLoad.begin(), objectsWithLoad.end(), ObjectLoadCI())->first;
}
@@ -1124,7 +1124,7 @@ Database::getObjectsByType(const string& type)
IdentityObjectInfoDict objects(connection, _objectDbName);
for(IdentityObjectInfoDict::const_iterator p = objects.findByType(type); p != objects.end(); ++p)
{
- proxies.push_back(p->second.proxy);
+ proxies.push_back(p->second.proxy);
}
return proxies;
}
@@ -1134,8 +1134,8 @@ Database::getObjectInfo(const Ice::Identity& id)
{
try
{
- ObjectEntryPtr object = _objectCache.get(id);
- return object->getObjectInfo();
+ ObjectEntryPtr object = _objectCache.get(id);
+ return object->getObjectInfo();
}
catch(ObjectNotRegisteredException&)
{
@@ -1146,7 +1146,7 @@ Database::getObjectInfo(const Ice::Identity& id)
IdentityObjectInfoDict::const_iterator p = objects.find(id);
if(p == objects.end())
{
- throw ObjectNotRegisteredException(id);
+ throw ObjectNotRegisteredException(id);
}
return p->second;
}
@@ -1159,10 +1159,10 @@ Database::getAllObjectInfos(const string& expression)
IdentityObjectInfoDict objects(connection, _objectDbName);
for(IdentityObjectInfoDict::const_iterator p = objects.begin(); p != objects.end(); ++p)
{
- if(expression.empty() || IceUtil::match(_communicator->identityToString(p->first), expression, true))
- {
- infos.push_back(p->second);
- }
+ if(expression.empty() || IceUtil::match(_communicator->identityToString(p->first), expression, true))
+ {
+ infos.push_back(p->second);
+ }
}
return infos;
}
@@ -1175,7 +1175,7 @@ Database::getObjectInfosByType(const string& type)
IdentityObjectInfoDict objects(connection, _objectDbName);
for(IdentityObjectInfoDict::const_iterator p = objects.findByType(type); p != objects.end(); ++p)
{
- infos.push_back(p->second);
+ infos.push_back(p->second);
}
return infos;
}
@@ -1183,11 +1183,11 @@ Database::getObjectInfosByType(const string& type)
void
Database::addInternalObject(const ObjectInfo& info, bool replace)
{
- Lock sync(*this);
+ Lock sync(*this);
const Ice::Identity id = info.proxy->ice_getIdentity();
if(!replace && _internalObjects.find(id) != _internalObjects.end())
{
- throw ObjectExistsException(id);
+ throw ObjectExistsException(id);
}
_internalObjects.put(IdentityObjectInfoDict::value_type(id, info));
}
@@ -1199,9 +1199,9 @@ Database::removeInternalObject(const Ice::Identity& id)
IdentityObjectInfoDict::iterator p = _internalObjects.find(id);
if(p == _internalObjects.end())
{
- ObjectNotRegisteredException ex;
- ex.id = id;
- throw ex;
+ ObjectNotRegisteredException ex;
+ ex.id = id;
+ throw ex;
}
_internalObjects.erase(p);
}
@@ -1214,7 +1214,7 @@ Database::getInternalObjectsByType(const string& type)
Ice::ObjectProxySeq proxies;
for(IdentityObjectInfoDict::const_iterator p = internalObjects.findByType(type); p != internalObjects.end(); ++p)
{
- proxies.push_back(p->second.proxy);
+ proxies.push_back(p->second.proxy);
}
return proxies;
}
@@ -1261,9 +1261,9 @@ Database::checkServerForAddition(const string& id)
{
if(_serverCache.has(id))
{
- DeploymentException ex;
- ex.reason = "server `" + id + "' is already registered";
- throw ex;
+ DeploymentException ex;
+ ex.reason = "server `" + id + "' is already registered";
+ throw ex;
}
}
@@ -1274,9 +1274,9 @@ Database::checkAdapterForAddition(const string& id)
_adapters.find(id) != _adapters.end() ||
_adapters.findByReplicaGroupId(id) != _adapters.end())
{
- DeploymentException ex;
- ex.reason = "adapter `" + id + "' is already registered";
- throw ex;
+ DeploymentException ex;
+ ex.reason = "adapter `" + id + "' is already registered";
+ throw ex;
}
}
@@ -1287,9 +1287,9 @@ Database::checkObjectForAddition(const Ice::Identity& objectId)
_allocatableObjectCache.has(objectId) ||
_objects.find(objectId) != _objects.end())
{
- DeploymentException ex;
- ex.reason = "object `" + _communicator->identityToString(objectId) + "' is already registered";
- throw ex;
+ DeploymentException ex;
+ ex.reason = "object `" + _communicator->identityToString(objectId) + "' is already registered";
+ throw ex;
}
}
@@ -1300,27 +1300,27 @@ Database::load(const ApplicationHelper& app, ServerEntrySeq& entries, const stri
const string application = app.getInstance().name;
for(NodeDescriptorDict::const_iterator n = nodes.begin(); n != nodes.end(); ++n)
{
- _nodeCache.get(n->first, true)->addDescriptor(application, n->second);
+ _nodeCache.get(n->first, true)->addDescriptor(application, n->second);
}
const ReplicaGroupDescriptorSeq& adpts = app.getInstance().replicaGroups;
for(ReplicaGroupDescriptorSeq::const_iterator r = adpts.begin(); r != adpts.end(); ++r)
{
- assert(!r->id.empty());
- _adapterCache.addReplicaGroup(*r, application);
- for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
- {
- ObjectInfo info;
- info.type = o->type;
- info.proxy = _communicator->stringToProxy("\"" + _communicator->identityToString(o->id) + "\" @ " + r->id);
- _objectCache.add(info, application);
- }
+ assert(!r->id.empty());
+ _adapterCache.addReplicaGroup(*r, application);
+ for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
+ {
+ ObjectInfo info;
+ info.type = o->type;
+ info.proxy = _communicator->stringToProxy("\"" + _communicator->identityToString(o->id) + "\" @ " + r->id);
+ _objectCache.add(info, application);
+ }
}
map<string, ServerInfo> servers = app.getServerInfos(uuid, revision);
for(map<string, ServerInfo>::const_iterator p = servers.begin(); p != servers.end(); ++p)
{
- entries.push_back(_serverCache.add(p->second));
+ entries.push_back(_serverCache.add(p->second));
}
}
@@ -1330,33 +1330,33 @@ Database::unload(const ApplicationHelper& app, ServerEntrySeq& entries)
map<string, ServerInfo> servers = app.getServerInfos("", 0);
for(map<string, ServerInfo>::const_iterator p = servers.begin(); p != servers.end(); ++p)
{
- entries.push_back(_serverCache.remove(p->first));
+ entries.push_back(_serverCache.remove(p->first));
}
const ReplicaGroupDescriptorSeq& adpts = app.getInstance().replicaGroups;
for(ReplicaGroupDescriptorSeq::const_iterator r = adpts.begin(); r != adpts.end(); ++r)
{
- for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
- {
- _objectCache.remove(o->id);
- }
- _adapterCache.removeReplicaGroup(r->id);
+ for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
+ {
+ _objectCache.remove(o->id);
+ }
+ _adapterCache.removeReplicaGroup(r->id);
}
const NodeDescriptorDict& nodes = app.getInstance().nodes;
const string application = app.getInstance().name;
for(NodeDescriptorDict::const_iterator n = nodes.begin(); n != nodes.end(); ++n)
{
- _nodeCache.get(n->first)->removeDescriptor(application);
+ _nodeCache.get(n->first)->removeDescriptor(application);
}
}
void
Database::reload(const ApplicationHelper& oldApp,
- const ApplicationHelper& newApp,
- ServerEntrySeq& entries,
- const string& uuid,
- int revision)
+ const ApplicationHelper& newApp,
+ ServerEntrySeq& entries,
+ const string& uuid,
+ int revision)
{
const string application = oldApp.getInstance().name;
@@ -1369,24 +1369,24 @@ Database::reload(const ApplicationHelper& oldApp,
map<string, ServerInfo>::const_iterator p;
for(p = newServers.begin(); p != newServers.end(); ++p)
{
- map<string, ServerInfo>::const_iterator q = oldServers.find(p->first);
- if(q == oldServers.end())
- {
- load.push_back(p->second);
- }
- else
- {
- _serverCache.remove(p->first, false); // Don't destroy the server if it was updated.
- load.push_back(p->second);
- }
+ map<string, ServerInfo>::const_iterator q = oldServers.find(p->first);
+ if(q == oldServers.end())
+ {
+ load.push_back(p->second);
+ }
+ else
+ {
+ _serverCache.remove(p->first, false); // Don't destroy the server if it was updated.
+ load.push_back(p->second);
+ }
}
for(p = oldServers.begin(); p != oldServers.end(); ++p)
{
- map<string, ServerInfo>::const_iterator q = newServers.find(p->first);
- if(q == newServers.end())
- {
- entries.push_back(_serverCache.remove(p->first));
- }
+ map<string, ServerInfo>::const_iterator q = newServers.find(p->first);
+ if(q == newServers.end())
+ {
+ entries.push_back(_serverCache.remove(p->first));
+ }
}
//
@@ -1397,22 +1397,22 @@ Database::reload(const ApplicationHelper& oldApp,
ReplicaGroupDescriptorSeq::const_iterator r;
for(r = oldAdpts.begin(); r != oldAdpts.end(); ++r)
{
- ReplicaGroupDescriptorSeq::const_iterator t;
- for(t = newAdpts.begin(); t != newAdpts.end(); ++t)
- {
- if(t->id == r->id)
- {
- break;
- }
- }
- for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
- {
- _objectCache.remove(o->id);
- }
- if(t == newAdpts.end())
- {
- _adapterCache.removeReplicaGroup(r->id);
- }
+ ReplicaGroupDescriptorSeq::const_iterator t;
+ for(t = newAdpts.begin(); t != newAdpts.end(); ++t)
+ {
+ if(t->id == r->id)
+ {
+ break;
+ }
+ }
+ for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
+ {
+ _objectCache.remove(o->id);
+ }
+ if(t == newAdpts.end())
+ {
+ _adapterCache.removeReplicaGroup(r->id);
+ }
}
//
@@ -1422,7 +1422,7 @@ Database::reload(const ApplicationHelper& oldApp,
NodeDescriptorDict::const_iterator n;
for(n = oldNodes.begin(); n != oldNodes.end(); ++n)
{
- _nodeCache.get(n->first)->removeDescriptor(application);
+ _nodeCache.get(n->first)->removeDescriptor(application);
}
//
@@ -1431,7 +1431,7 @@ Database::reload(const ApplicationHelper& oldApp,
const NodeDescriptorDict& newNodes = newApp.getInstance().nodes;
for(n = newNodes.begin(); n != newNodes.end(); ++n)
{
- _nodeCache.get(n->first, true)->addDescriptor(application, n->second);
+ _nodeCache.get(n->first, true)->addDescriptor(application, n->second);
}
//
@@ -1439,24 +1439,24 @@ Database::reload(const ApplicationHelper& oldApp,
//
for(r = newAdpts.begin(); r != newAdpts.end(); ++r)
{
- try
- {
- ReplicaGroupEntryPtr entry = ReplicaGroupEntryPtr::dynamicCast(_adapterCache.get(r->id));
- assert(entry);
- entry->update(r->loadBalancing);
- }
- catch(const AdapterNotExistException&)
- {
- _adapterCache.addReplicaGroup(*r, application);
- }
-
- for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
- {
- ObjectInfo info;
- info.type = o->type;
- info.proxy = _communicator->stringToProxy(_communicator->identityToString(o->id) + "@" + r->id);
- _objectCache.add(info, application);
- }
+ try
+ {
+ ReplicaGroupEntryPtr entry = ReplicaGroupEntryPtr::dynamicCast(_adapterCache.get(r->id));
+ assert(entry);
+ entry->update(r->loadBalancing);
+ }
+ catch(const AdapterNotExistException&)
+ {
+ _adapterCache.addReplicaGroup(*r, application);
+ }
+
+ for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
+ {
+ ObjectInfo info;
+ info.type = o->type;
+ info.proxy = _communicator->stringToProxy(_communicator->identityToString(o->id) + "@" + r->id);
+ _objectCache.add(info, application);
+ }
}
//
@@ -1464,51 +1464,51 @@ Database::reload(const ApplicationHelper& oldApp,
//
for(vector<ServerInfo>::const_iterator q = load.begin(); q != load.end(); ++q)
{
- entries.push_back(_serverCache.add(*q));
+ entries.push_back(_serverCache.add(*q));
}
}
void
Database::finishApplicationUpdate(ServerEntrySeq& entries,
- const ApplicationUpdateInfo& update,
- const ApplicationInfo& oldApp,
- const ApplicationDescriptor& newDesc,
- AdminSessionI* session)
+ const ApplicationUpdateInfo& update,
+ const ApplicationInfo& oldApp,
+ const ApplicationDescriptor& newDesc,
+ AdminSessionI* session)
{
if(_master)
{
- //
- // Load the servers on the nodes. If a server couldn't be
- // deployed we unload the application and throw.
- //
- try
- {
- for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::syncAndWait));
- }
- catch(const DeploymentException& ex)
- {
- ApplicationUpdateInfo newUpdate;
- {
- Lock sync(*this);
- entries.clear();
- ApplicationHelper previous(_communicator, newDesc);
- ApplicationHelper helper(_communicator, oldApp.descriptor);
- reload(previous, helper, entries, oldApp.uuid, oldApp.revision);
- }
-
- try
- {
- for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::syncAndWait));
- }
- catch(const DeploymentException& ex)
- {
- Ice::Error err(_traceLevels->logger);
- err << "failed to rollback previous application `" << oldApp.descriptor.name << "':\n" << ex.reason;
- }
-
- finishUpdating(newDesc.name);
- throw ex;
- }
+ //
+ // Load the servers on the nodes. If a server couldn't be
+ // deployed we unload the application and throw.
+ //
+ try
+ {
+ for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::syncAndWait));
+ }
+ catch(const DeploymentException& ex)
+ {
+ ApplicationUpdateInfo newUpdate;
+ {
+ Lock sync(*this);
+ entries.clear();
+ ApplicationHelper previous(_communicator, newDesc);
+ ApplicationHelper helper(_communicator, oldApp.descriptor);
+ reload(previous, helper, entries, oldApp.uuid, oldApp.revision);
+ }
+
+ try
+ {
+ for_each(entries.begin(), entries.end(), IceUtil::voidMemFun(&ServerEntry::syncAndWait));
+ }
+ catch(const DeploymentException& ex)
+ {
+ Ice::Error err(_traceLevels->logger);
+ err << "failed to rollback previous application `" << oldApp.descriptor.name << "':\n" << ex.reason;
+ }
+
+ finishUpdating(newDesc.name);
+ throw ex;
+ }
}
//
@@ -1516,24 +1516,24 @@ Database::finishApplicationUpdate(ServerEntrySeq& entries,
//
int serial;
{
- Lock sync(*this);
-
- ApplicationInfo info = oldApp;
- info.updateTime = update.updateTime;
- info.updateUser = update.updateUser;
- info.revision = update.revision;
- info.descriptor = newDesc;
-
- _applications.put(StringApplicationInfoDict::value_type(update.descriptor.name, info));
- ++_applicationSerial;
+ Lock sync(*this);
+
+ ApplicationInfo info = oldApp;
+ info.updateTime = update.updateTime;
+ info.updateUser = update.updateUser;
+ info.revision = update.revision;
+ info.descriptor = newDesc;
+
+ _applications.put(StringApplicationInfoDict::value_type(update.descriptor.name, info));
+ ++_applicationSerial;
- if(_traceLevels->application > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->applicationCat);
- out << "updated application `" << update.descriptor.name << "'";
- }
-
- serial = _applicationObserverTopic->applicationUpdated(_applicationSerial, update);
+ if(_traceLevels->application > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->applicationCat);
+ out << "updated application `" << update.descriptor.name << "'";
+ }
+
+ serial = _applicationObserverTopic->applicationUpdated(_applicationSerial, update);
}
_applicationObserverTopic->waitForSyncedSubscribers(serial);
@@ -1556,9 +1556,9 @@ Database::finishUpdating(const string& name)
map<string, vector<AMD_NodeSession_waitForApplicationUpdatePtr> >::iterator p = _updating.find(name);
assert(p != _updating.end());
for(vector<AMD_NodeSession_waitForApplicationUpdatePtr>::const_iterator q = p->second.begin();
- q != p->second.end(); ++q)
+ q != p->second.end(); ++q)
{
- (*q)->ice_response();
+ (*q)->ice_response();
}
_updating.erase(p);
diff --git a/cpp/src/IceGrid/Database.h b/cpp/src/IceGrid/Database.h
index 339d52722e8..a02bbe02eb2 100644
--- a/cpp/src/IceGrid/Database.h
+++ b/cpp/src/IceGrid/Database.h
@@ -51,7 +51,7 @@ class Database : public IceUtil::Shared, public IceUtil::Monitor<IceUtil::Mutex>
public:
Database(const Ice::ObjectAdapterPtr&, const IceStorm::TopicManagerPrx&, const std::string&, const TraceLevelsPtr&,
- const RegistryInfo&);
+ const RegistryInfo&);
virtual ~Database();
std::string getInstanceName() const;
@@ -133,7 +133,7 @@ private:
void unload(const ApplicationHelper&, ServerEntrySeq&);
void reload(const ApplicationHelper&, const ApplicationHelper&, ServerEntrySeq&, const std::string&, int);
void finishApplicationUpdate(ServerEntrySeq&, const ApplicationUpdateInfo&, const ApplicationInfo&,
- const ApplicationDescriptor&, AdminSessionI*);
+ const ApplicationDescriptor&, AdminSessionI*);
void checkSessionLock(AdminSessionI*);
diff --git a/cpp/src/IceGrid/DescriptorBuilder.cpp b/cpp/src/IceGrid/DescriptorBuilder.cpp
index a5405ad18c9..eeb0c11c723 100644
--- a/cpp/src/IceGrid/DescriptorBuilder.cpp
+++ b/cpp/src/IceGrid/DescriptorBuilder.cpp
@@ -16,9 +16,9 @@ using namespace std;
using namespace IceGrid;
XmlAttributesHelper::XmlAttributesHelper(const IceXML::Attributes& attrs,
- const Ice::LoggerPtr& logger,
- const string& filename,
- int line) :
+ const Ice::LoggerPtr& logger,
+ const string& filename,
+ int line) :
_attributes(attrs),
_logger(logger),
_filename(filename),
@@ -32,17 +32,17 @@ XmlAttributesHelper::checkUnknownAttributes()
vector<string> notUsed;
for(map<string, string>::const_iterator p = _attributes.begin(); p != _attributes.end(); ++p)
{
- if(_used.find(p->first) == _used.end())
- {
- notUsed.push_back(p->first);
- }
+ if(_used.find(p->first) == _used.end())
+ {
+ notUsed.push_back(p->first);
+ }
}
if(!notUsed.empty())
{
- ostringstream os;
- os << "unknown attributes in <" << _filename << "> descriptor, line " << _line << ":\n" << toString(notUsed);
- throw os.str();
+ ostringstream os;
+ os << "unknown attributes in <" << _filename << "> descriptor, line " << _line << ":\n" << toString(notUsed);
+ throw os.str();
}
}
@@ -60,12 +60,12 @@ XmlAttributesHelper::operator()(const string& name) const
IceXML::Attributes::const_iterator p = _attributes.find(name);
if(p == _attributes.end())
{
- throw "missing attribute '" + name + "'";
+ throw "missing attribute '" + name + "'";
}
string v = p->second;
if(v.empty())
{
- throw "attribute '" + name + "' is empty";
+ throw "attribute '" + name + "' is empty";
}
return v;
}
@@ -77,11 +77,11 @@ XmlAttributesHelper::operator()(const string& name, const string& def) const
IceXML::Attributes::const_iterator p = _attributes.find(name);
if(p == _attributes.end())
{
- return def;
+ return def;
}
else
{
- return p->second;
+ return p->second;
}
}
@@ -90,7 +90,7 @@ XmlAttributesHelper::asMap() const
{
for(map<string, string>::const_iterator p = _attributes.begin(); p != _attributes.end(); ++p)
{
- _used.insert(p->first);
+ _used.insert(p->first);
}
return _attributes;
}
@@ -102,21 +102,21 @@ XmlAttributesHelper::asBool(const string& name) const
IceXML::Attributes::const_iterator p = _attributes.find(name);
if(p == _attributes.end())
{
- throw "missing attribute '" + name + "'";
- return true; // Keep the compiler happy.
+ throw "missing attribute '" + name + "'";
+ return true; // Keep the compiler happy.
}
else if(p->second == "true")
{
- return true;
+ return true;
}
else if(p->second == "false")
{
- return false;
+ return false;
}
else
{
- throw "invalid attribute `" + name + "': value is not 'false' or 'true'";
- return true; // Keep the compiler happy.
+ throw "invalid attribute `" + name + "': value is not 'false' or 'true'";
+ return true; // Keep the compiler happy.
}
}
@@ -127,20 +127,20 @@ XmlAttributesHelper::asBool(const string& name, bool def) const
IceXML::Attributes::const_iterator p = _attributes.find(name);
if(p == _attributes.end())
{
- return def;
+ return def;
}
else if(p->second == "true")
{
- return true;
+ return true;
}
else if(p->second == "false")
{
- return false;
+ return false;
}
else
{
- throw "invalid attribute `" + name + "': value is not 'false' or 'true'";
- return true; // Keep the compiler happy.
+ throw "invalid attribute `" + name + "': value is not 'false' or 'true'";
+ return true; // Keep the compiler happy.
}
}
@@ -206,11 +206,11 @@ PropertySetDescriptorBuilder::addPropertySet(const XmlAttributesHelper& attrs)
{
if(attrs.contains("id") || !attrs.contains("refid"))
{
- throw "only <properties refid=\"\"> can be a child of a <properties> element";
+ throw "only <properties refid=\"\"> can be a child of a <properties> element";
}
if(!_descriptor.properties.empty())
{
- throw "<properties refid=\"\"> can't be defined after a <property> element";
+ throw "<properties refid=\"\"> can't be defined after a <property> element";
}
_descriptor.references.push_back(attrs("refid"));
_inPropertySetRef = true;
@@ -221,15 +221,15 @@ PropertySetDescriptorBuilder::finish()
{
if(_inPropertySetRef)
{
- _inPropertySetRef = false;
- return false;
+ _inPropertySetRef = false;
+ return false;
}
return true;
}
ApplicationDescriptorBuilder::ApplicationDescriptorBuilder(const Ice::CommunicatorPtr& communicator,
- const XmlAttributesHelper& attrs,
- const map<string, string>& overrides) :
+ const XmlAttributesHelper& attrs,
+ const map<string, string>& overrides) :
_communicator(communicator),
_overrides(overrides)
{
@@ -238,9 +238,9 @@ ApplicationDescriptorBuilder::ApplicationDescriptorBuilder(const Ice::Communicat
}
ApplicationDescriptorBuilder::ApplicationDescriptorBuilder(const Ice::CommunicatorPtr& communicator,
- const ApplicationDescriptor& app,
- const XmlAttributesHelper& attrs,
- const map<string, string>& overrides) :
+ const ApplicationDescriptor& app,
+ const XmlAttributesHelper& attrs,
+ const map<string, string>& overrides) :
_communicator(communicator),
_descriptor(app),
_overrides(overrides)
@@ -274,8 +274,8 @@ ApplicationDescriptorBuilder::finishReplicaGroup()
{
if(!_descriptor.replicaGroups.back().loadBalancing)
{
- _descriptor.replicaGroups.back().loadBalancing = new RandomLoadBalancingPolicy();
- _descriptor.replicaGroups.back().loadBalancing->nReplicas = "0";
+ _descriptor.replicaGroups.back().loadBalancing = new RandomLoadBalancingPolicy();
+ _descriptor.replicaGroups.back().loadBalancing->nReplicas = "0";
}
}
@@ -286,25 +286,25 @@ ApplicationDescriptorBuilder::setLoadBalancing(const XmlAttributesHelper& attrs)
string type = attrs("type");
if(type == "random")
{
- policy = new RandomLoadBalancingPolicy();
+ policy = new RandomLoadBalancingPolicy();
}
else if(type == "ordered")
{
- policy = new OrderedLoadBalancingPolicy();
+ policy = new OrderedLoadBalancingPolicy();
}
else if(type == "round-robin")
{
- policy = new RoundRobinLoadBalancingPolicy();
+ policy = new RoundRobinLoadBalancingPolicy();
}
else if(type == "adaptive")
{
- AdaptiveLoadBalancingPolicyPtr alb = new AdaptiveLoadBalancingPolicy();
- alb->loadSample = attrs("load-sample", "1");
- policy = alb;
+ AdaptiveLoadBalancingPolicyPtr alb = new AdaptiveLoadBalancingPolicy();
+ alb->loadSample = attrs("load-sample", "1");
+ policy = alb;
}
else
{
- throw "invalid load balancing policy `" + type + "'";
+ throw "invalid load balancing policy `" + type + "'";
}
policy->nReplicas = attrs("n-replicas", "1");
_descriptor.replicaGroups.back().loadBalancing = policy;
@@ -324,7 +324,7 @@ ApplicationDescriptorBuilder::addObject(const XmlAttributesHelper& attrs)
object.id = _communicator->stringToIdentity(attrs("identity"));
if(attrs.contains("property"))
{
- throw "property attribute is not allowed in object descriptors from a replica group";
+ throw "property attribute is not allowed in object descriptors from a replica group";
}
_descriptor.replicaGroups.back().objects.push_back(object);
}
@@ -334,11 +334,11 @@ ApplicationDescriptorBuilder::addVariable(const XmlAttributesHelper& attrs)
{
if(!isOverride(attrs("name")))
{
- _descriptor.variables[attrs("name")] = attrs("value", "");
+ _descriptor.variables[attrs("name")] = attrs("value", "");
}
else
{
- attrs.contains("value"); // NOTE: prevents warning about "value" not being used.
+ attrs.contains("value"); // NOTE: prevents warning about "value" not being used.
}
}
@@ -381,11 +381,11 @@ ApplicationDescriptorBuilder::addServerTemplate(const string& id, const Template
{
if(!templ.descriptor)
{
- throw "invalid server template `" + id + "': server definition is missing";
+ throw "invalid server template `" + id + "': server definition is missing";
}
if(!_descriptor.serverTemplates.insert(make_pair(id, templ)).second)
{
- throw "duplicate server template `" + id + "'";
+ throw "duplicate server template `" + id + "'";
}
}
@@ -394,11 +394,11 @@ ApplicationDescriptorBuilder::addServiceTemplate(const string& id, const Templat
{
if(!templ.descriptor)
{
- throw "invalid service template `" + id + "': service definition is missing";
+ throw "invalid service template `" + id + "': service definition is missing";
}
if(!_descriptor.serviceTemplates.insert(make_pair(id, templ)).second)
{
- throw "duplicate service template `" + id + "'";
+ throw "duplicate service template `" + id + "'";
}
}
@@ -407,7 +407,7 @@ ApplicationDescriptorBuilder::addPropertySet(const string& id, const PropertySet
{
if(!_descriptor.propertySets.insert(make_pair(id, desc)).second)
{
- throw "duplicate property set `" + id + "'";
+ throw "duplicate property set `" + id + "'";
}
}
@@ -442,7 +442,7 @@ ServerInstanceDescriptorBuilder::createPropertySet(const XmlAttributesHelper& at
string service;
if(attrs.contains("service"))
{
- service = attrs("service"); // Can't be empty.
+ service = attrs("service"); // Can't be empty.
}
PropertySetDescriptorBuilder* builder = new PropertySetDescriptorBuilder();
@@ -462,8 +462,8 @@ ServerInstanceDescriptorBuilder::addPropertySet(const string& service, const Pro
}
NodeDescriptorBuilder::NodeDescriptorBuilder(ApplicationDescriptorBuilder& app,
- const NodeDescriptor& desc,
- const XmlAttributesHelper& attrs) :
+ const NodeDescriptor& desc,
+ const XmlAttributesHelper& attrs) :
_application(app),
_descriptor(desc)
{
@@ -504,11 +504,11 @@ NodeDescriptorBuilder::addVariable(const XmlAttributesHelper& attrs)
{
if(!_application.isOverride(attrs("name")))
{
- _descriptor.variables[attrs("name")] = attrs("value", "");
+ _descriptor.variables[attrs("name")] = attrs("value", "");
}
else
{
- attrs.contains("value"); // NOTE: prevents warning about "value" not being used.
+ attrs.contains("value"); // NOTE: prevents warning about "value" not being used.
}
}
@@ -529,7 +529,7 @@ NodeDescriptorBuilder::addPropertySet(const string& id, const PropertySetDescrip
{
if(!_descriptor.propertySets.insert(make_pair(id, desc)).second)
{
- throw "duplicate property set `" + id + "'";
+ throw "duplicate property set `" + id + "'";
}
}
@@ -540,8 +540,8 @@ NodeDescriptorBuilder::setDescription(const string& description)
}
TemplateDescriptorBuilder::TemplateDescriptorBuilder(ApplicationDescriptorBuilder& application,
- const XmlAttributesHelper& attrs,
- bool serviceTemplate) :
+ const XmlAttributesHelper& attrs,
+ bool serviceTemplate) :
_application(application),
_serviceTemplate(serviceTemplate),
_id(attrs("id"))
@@ -554,13 +554,13 @@ TemplateDescriptorBuilder::addParameter(const XmlAttributesHelper& attrs)
if(find(_descriptor.parameters.begin(), _descriptor.parameters.end(), attrs("name")) !=
_descriptor.parameters.end())
{
- throw "duplicate parameter `" + attrs("name") + "'";
+ throw "duplicate parameter `" + attrs("name") + "'";
}
_descriptor.parameters.push_back(attrs("name"));
if(attrs.contains("default"))
{
- _descriptor.parameterDefaults.insert(make_pair(attrs("name"), attrs("default", "")));
+ _descriptor.parameterDefaults.insert(make_pair(attrs("name"), attrs("default", "")));
}
}
@@ -575,7 +575,7 @@ TemplateDescriptorBuilder::createServer(const XmlAttributesHelper& attrs)
{
if(_serviceTemplate)
{
- throw "<server> element can't be a child of <service-template>";
+ throw "<server> element can't be a child of <service-template>";
}
return new ServerDescriptorBuilder(_application.getCommunicator(), attrs);
}
@@ -585,7 +585,7 @@ TemplateDescriptorBuilder::createIceBox(const XmlAttributesHelper& attrs)
{
if(_serviceTemplate)
{
- throw "<icebox> element can't be a child of <service-template>";
+ throw "<icebox> element can't be a child of <service-template>";
}
return new IceBoxDescriptorBuilder(_application.getCommunicator(), attrs);
}
@@ -595,7 +595,7 @@ TemplateDescriptorBuilder::createService(const XmlAttributesHelper& attrs)
{
if(!_serviceTemplate)
{
- throw "<service> element can't be a child of <server-template>";
+ throw "<service> element can't be a child of <server-template>";
}
return new ServiceDescriptorBuilder(_application.getCommunicator(), attrs);
}
@@ -621,7 +621,7 @@ CommunicatorDescriptorBuilder::finish()
// before references to property sets.
//
_descriptor->propertySet.properties.insert(_descriptor->propertySet.properties.begin(),
- _hiddenProperties.begin(), _hiddenProperties.end());
+ _hiddenProperties.begin(), _hiddenProperties.end());
}
void
@@ -660,23 +660,23 @@ CommunicatorDescriptorBuilder::addAdapter(const XmlAttributesHelper& attrs)
desc.name = attrs("name");
if(attrs.contains("id"))
{
- desc.id = attrs("id");
+ desc.id = attrs("id");
}
else
{
- string fqn = "${server}";
- if(ServiceDescriptorPtr::dynamicCast(_descriptor))
- {
- fqn += ".${service}";
- }
- desc.id = fqn + "." + desc.name;
+ string fqn = "${server}";
+ if(ServiceDescriptorPtr::dynamicCast(_descriptor))
+ {
+ fqn += ".${service}";
+ }
+ desc.id = fqn + "." + desc.name;
}
desc.replicaGroupId = attrs("replica-group", "");
desc.priority = attrs("priority", "");
desc.registerProcess = attrs.asBool("register-process", false);
if(desc.id == "")
{
- throw "empty `id' for adapter `" + desc.name + "'";
+ throw "empty `id' for adapter `" + desc.name + "'";
}
desc.serverLifetime = attrs.asBool("server-lifetime", true);
_descriptor->adapters.push_back(desc);
@@ -698,7 +698,7 @@ CommunicatorDescriptorBuilder::addObject(const XmlAttributesHelper& attrs)
object.id = _communicator->stringToIdentity(attrs("identity"));
if(attrs.contains("property"))
{
- addProperty(_hiddenProperties, attrs("property"), attrs("identity"));
+ addProperty(_hiddenProperties, attrs("property"), attrs("identity"));
}
_descriptor->adapters.back().objects.push_back(object);
}
@@ -711,7 +711,7 @@ CommunicatorDescriptorBuilder::addAllocatable(const XmlAttributesHelper& attrs)
object.id = _communicator->stringToIdentity(attrs("identity"));
if(attrs.contains("property"))
{
- addProperty(_hiddenProperties, attrs("property"), attrs("identity"));
+ addProperty(_hiddenProperties, attrs("property"), attrs("identity"));
}
_descriptor->adapters.back().allocatables.push_back(object);
}
@@ -726,28 +726,28 @@ CommunicatorDescriptorBuilder::addDbEnv(const XmlAttributesHelper& attrs)
DbEnvDescriptorSeq::iterator p;
for(p = _descriptor->dbEnvs.begin(); p != _descriptor->dbEnvs.end(); ++p)
{
- //
- // We are re-opening the dbenv element to define more properties.
- //
- if(p->name == desc.name)
- {
- break;
- }
+ //
+ // We are re-opening the dbenv element to define more properties.
+ //
+ if(p->name == desc.name)
+ {
+ break;
+ }
}
if(p != _descriptor->dbEnvs.end())
{
- //
- // Remove the previously defined dbenv, we'll add it back again when
- // the dbenv element end tag is reached.
- //
- desc = *p;
- _descriptor->dbEnvs.erase(p);
- }
+ //
+ // Remove the previously defined dbenv, we'll add it back again when
+ // the dbenv element end tag is reached.
+ //
+ desc = *p;
+ _descriptor->dbEnvs.erase(p);
+ }
if(desc.dbHome.empty())
{
- desc.dbHome = attrs("home", "");
+ desc.dbHome = attrs("home", "");
}
_descriptor->dbEnvs.push_back(desc);
@@ -758,9 +758,9 @@ CommunicatorDescriptorBuilder::addDbEnvProperty(const XmlAttributesHelper& attrs
{
if(!_descriptor->dbEnvs.back().dbHome.empty())
{
- throw "can't add property to the database environment:\n"
- "properties are only allowed if the database\n"
- "environment home directory is managed by the node";
+ throw "can't add property to the database environment:\n"
+ "properties are only allowed if the database\n"
+ "environment home directory is managed by the node";
}
PropertyDescriptor prop;
@@ -780,7 +780,7 @@ CommunicatorDescriptorBuilder::addLog(const XmlAttributesHelper& attrs)
{
if(attrs.contains("property"))
{
- addProperty(_hiddenProperties, attrs("property"), attrs("path"));
+ addProperty(_hiddenProperties, attrs("property"), attrs("path"));
}
_descriptor->logs.push_back(attrs("path"));
}
@@ -819,7 +819,7 @@ ServiceInstanceDescriptorBuilder::addPropertySet(const PropertySetDescriptor& de
}
ServerDescriptorBuilder::ServerDescriptorBuilder(const Ice::CommunicatorPtr& communicator,
- const XmlAttributesHelper& attrs) :
+ const XmlAttributesHelper& attrs) :
CommunicatorDescriptorBuilder(communicator)
{
init(new ServerDescriptor(), attrs);
@@ -898,7 +898,7 @@ ServerDescriptorBuilder::addDistributionDirectory(const string& directory)
}
IceBoxDescriptorBuilder::IceBoxDescriptorBuilder(const Ice::CommunicatorPtr& communicator,
- const XmlAttributesHelper& attrs) :
+ const XmlAttributesHelper& attrs) :
ServerDescriptorBuilder(communicator)
{
init(new IceBoxDescriptor(), attrs);
@@ -916,18 +916,18 @@ IceBoxDescriptorBuilder::finish()
{
if(getProperty(_descriptor->propertySet.properties, "IceBox.InstanceName").empty())
{
- _hiddenProperties.push_back(createProperty("IceBox.InstanceName", "${server}"));
+ _hiddenProperties.push_back(createProperty("IceBox.InstanceName", "${server}"));
}
if(_descriptor->adapters.empty())
{
- if(getProperty(_descriptor->propertySet.properties, "Ice.OA.IceBox.ServiceManager.Endpoints").empty())
- {
- _hiddenProperties.push_back(createProperty("Ice.OA.IceBox.ServiceManager.Endpoints", "tcp -h 127.0.0.1"));
- }
- if(getProperty(_descriptor->propertySet.properties, "Ice.OA.IceBox.ServiceManager.RegisterProcess").empty())
- {
- _hiddenProperties.push_back(createProperty("Ice.OA.IceBox.ServiceManager.RegisterProcess", "1"));
- }
+ if(getProperty(_descriptor->propertySet.properties, "Ice.OA.IceBox.ServiceManager.Endpoints").empty())
+ {
+ _hiddenProperties.push_back(createProperty("Ice.OA.IceBox.ServiceManager.Endpoints", "tcp -h 127.0.0.1"));
+ }
+ if(getProperty(_descriptor->propertySet.properties, "Ice.OA.IceBox.ServiceManager.RegisterProcess").empty())
+ {
+ _hiddenProperties.push_back(createProperty("Ice.OA.IceBox.ServiceManager.RegisterProcess", "1"));
+ }
}
ServerDescriptorBuilder::finish();
@@ -950,7 +950,7 @@ IceBoxDescriptorBuilder::addAdapter(const XmlAttributesHelper& attrs)
{
if(attrs("name") != "IceBox.ServiceManager")
{
- throw "<adapter> element can't be a child of an <icebox> element";
+ throw "<adapter> element can't be a child of an <icebox> element";
}
ServerDescriptorBuilder::addAdapter(attrs);
@@ -978,7 +978,7 @@ IceBoxDescriptorBuilder::addService(const ServiceDescriptorPtr& desc)
}
ServiceDescriptorBuilder::ServiceDescriptorBuilder(const Ice::CommunicatorPtr& communicator,
- const XmlAttributesHelper& attrs) :
+ const XmlAttributesHelper& attrs) :
CommunicatorDescriptorBuilder(communicator)
{
init(new ServiceDescriptor(), attrs);
diff --git a/cpp/src/IceGrid/DescriptorBuilder.h b/cpp/src/IceGrid/DescriptorBuilder.h
index 04f0ca60d4e..532df9e61df 100644
--- a/cpp/src/IceGrid/DescriptorBuilder.h
+++ b/cpp/src/IceGrid/DescriptorBuilder.h
@@ -89,9 +89,9 @@ class ApplicationDescriptorBuilder : public DescriptorBuilder
public:
ApplicationDescriptorBuilder(const Ice::CommunicatorPtr&, const XmlAttributesHelper&,
- const std::map<std::string, std::string>&);
+ const std::map<std::string, std::string>&);
ApplicationDescriptorBuilder(const Ice::CommunicatorPtr&, const ApplicationDescriptor&, const XmlAttributesHelper&,
- const std::map<std::string, std::string>&);
+ const std::map<std::string, std::string>&);
const ApplicationDescriptor& getDescriptor() const;
diff --git a/cpp/src/IceGrid/DescriptorHelper.cpp b/cpp/src/IceGrid/DescriptorHelper.cpp
index 1e540b5938f..f1cf78d4367 100644
--- a/cpp/src/IceGrid/DescriptorHelper.cpp
+++ b/cpp/src/IceGrid/DescriptorHelper.cpp
@@ -25,7 +25,7 @@ struct GetReplicaGroupId : unary_function<ReplicaGroupDescriptor&, const string&
const string&
operator()(const ReplicaGroupDescriptor& desc)
{
- return desc.id;
+ return desc.id;
}
};
@@ -34,42 +34,42 @@ struct TemplateDescriptorEqual : std::binary_function<TemplateDescriptor&, Templ
bool
operator()(const TemplateDescriptor& lhs, const TemplateDescriptor& rhs)
{
- if(lhs.parameters != rhs.parameters)
- {
- return false;
- }
-
- if(lhs.parameterDefaults != rhs.parameterDefaults)
- {
- return false;
- }
-
- {
- IceBoxDescriptorPtr slhs = IceBoxDescriptorPtr::dynamicCast(lhs.descriptor);
- IceBoxDescriptorPtr srhs = IceBoxDescriptorPtr::dynamicCast(rhs.descriptor);
- if(slhs && srhs)
- {
- return IceBoxHelper(slhs) == IceBoxHelper(srhs);
- }
- }
- {
- ServerDescriptorPtr slhs = ServerDescriptorPtr::dynamicCast(lhs.descriptor);
- ServerDescriptorPtr srhs = ServerDescriptorPtr::dynamicCast(rhs.descriptor);
- if(slhs && srhs)
- {
- return ServerHelper(slhs) == ServerHelper(srhs);
- }
- }
- {
- ServiceDescriptorPtr slhs = ServiceDescriptorPtr::dynamicCast(lhs.descriptor);
- ServiceDescriptorPtr srhs = ServiceDescriptorPtr::dynamicCast(rhs.descriptor);
- if(slhs && srhs)
- {
- return ServiceHelper(slhs) == ServiceHelper(srhs);
- }
- }
-
- return false;
+ if(lhs.parameters != rhs.parameters)
+ {
+ return false;
+ }
+
+ if(lhs.parameterDefaults != rhs.parameterDefaults)
+ {
+ return false;
+ }
+
+ {
+ IceBoxDescriptorPtr slhs = IceBoxDescriptorPtr::dynamicCast(lhs.descriptor);
+ IceBoxDescriptorPtr srhs = IceBoxDescriptorPtr::dynamicCast(rhs.descriptor);
+ if(slhs && srhs)
+ {
+ return IceBoxHelper(slhs) == IceBoxHelper(srhs);
+ }
+ }
+ {
+ ServerDescriptorPtr slhs = ServerDescriptorPtr::dynamicCast(lhs.descriptor);
+ ServerDescriptorPtr srhs = ServerDescriptorPtr::dynamicCast(rhs.descriptor);
+ if(slhs && srhs)
+ {
+ return ServerHelper(slhs) == ServerHelper(srhs);
+ }
+ }
+ {
+ ServiceDescriptorPtr slhs = ServiceDescriptorPtr::dynamicCast(lhs.descriptor);
+ ServiceDescriptorPtr srhs = ServiceDescriptorPtr::dynamicCast(rhs.descriptor);
+ if(slhs && srhs)
+ {
+ return ServiceHelper(slhs) == ServiceHelper(srhs);
+ }
+ }
+
+ return false;
}
};
@@ -78,38 +78,38 @@ struct ReplicaGroupEq : std::binary_function<ReplicaGroupDescriptor&, ReplicaGro
bool
operator()(const ReplicaGroupDescriptor& lhs, const ReplicaGroupDescriptor& rhs)
{
- if(lhs.id != rhs.id)
- {
- return false;
- }
- if(set<ObjectDescriptor>(lhs.objects.begin(), lhs.objects.end()) !=
- set<ObjectDescriptor>(rhs.objects.begin(), rhs.objects.end()))
- {
- return false;
- }
- if(lhs.loadBalancing && rhs.loadBalancing)
- {
- if(lhs.loadBalancing->ice_id() != rhs.loadBalancing->ice_id())
- {
- return false;
- }
- if(lhs.loadBalancing->nReplicas != rhs.loadBalancing->nReplicas)
- {
- return false;
- }
- AdaptiveLoadBalancingPolicyPtr alhs = AdaptiveLoadBalancingPolicyPtr::dynamicCast(lhs.loadBalancing);
- AdaptiveLoadBalancingPolicyPtr arhs = AdaptiveLoadBalancingPolicyPtr::dynamicCast(rhs.loadBalancing);
- if(alhs && arhs && alhs->loadSample != arhs->loadSample)
- {
- return false;
- }
- }
- else if(lhs.loadBalancing || rhs.loadBalancing)
- {
- return false;
- }
-
- return true;
+ if(lhs.id != rhs.id)
+ {
+ return false;
+ }
+ if(set<ObjectDescriptor>(lhs.objects.begin(), lhs.objects.end()) !=
+ set<ObjectDescriptor>(rhs.objects.begin(), rhs.objects.end()))
+ {
+ return false;
+ }
+ if(lhs.loadBalancing && rhs.loadBalancing)
+ {
+ if(lhs.loadBalancing->ice_id() != rhs.loadBalancing->ice_id())
+ {
+ return false;
+ }
+ if(lhs.loadBalancing->nReplicas != rhs.loadBalancing->nReplicas)
+ {
+ return false;
+ }
+ AdaptiveLoadBalancingPolicyPtr alhs = AdaptiveLoadBalancingPolicyPtr::dynamicCast(lhs.loadBalancing);
+ AdaptiveLoadBalancingPolicyPtr arhs = AdaptiveLoadBalancingPolicyPtr::dynamicCast(rhs.loadBalancing);
+ if(alhs && arhs && alhs->loadSample != arhs->loadSample)
+ {
+ return false;
+ }
+ }
+ else if(lhs.loadBalancing || rhs.loadBalancing)
+ {
+ return false;
+ }
+
+ return true;
}
};
@@ -133,18 +133,18 @@ getSeqUpdatedEltsWithEq(const Seq& lseq, const Seq& rseq, GetKeyFunc func, EqFun
Seq result;
for(typename Seq::const_iterator p = rseq.begin(); p != rseq.end(); ++p)
{
- typename Seq::const_iterator q = lseq.begin();
- for(; q != lseq.end(); ++q)
- {
- if(func(*p) == func(*q))
- {
- break;
- }
- }
- if(q == lseq.end() || !eq(*p, *q))
- {
- result.push_back(*p);
- }
+ typename Seq::const_iterator q = lseq.begin();
+ for(; q != lseq.end(); ++q)
+ {
+ if(func(*p) == func(*q))
+ {
+ break;
+ }
+ }
+ if(q == lseq.end() || !eq(*p, *q))
+ {
+ result.push_back(*p);
+ }
}
return result;
}
@@ -155,18 +155,18 @@ getSeqRemovedElts(const Seq& lseq, const Seq& rseq, GetKeyFunc func)
Ice::StringSeq removed;
for(typename Seq::const_iterator p = lseq.begin(); p != lseq.end(); ++p)
{
- typename Seq::const_iterator q;
- for(q = rseq.begin(); q != rseq.end(); ++q)
- {
- if(func(*p) == func(*q))
- {
- break;
- }
- }
- if(q == rseq.end())
- {
- removed.push_back(func(*p));
- }
+ typename Seq::const_iterator q;
+ for(q = rseq.begin(); q != rseq.end(); ++q)
+ {
+ if(func(*p) == func(*q))
+ {
+ break;
+ }
+ }
+ if(q == rseq.end())
+ {
+ removed.push_back(func(*p));
+ }
}
return removed;
}
@@ -178,21 +178,21 @@ updateSeqElts(const Seq& seq, const Seq& update, const Ice::StringSeq& remove, G
set<string> removed(remove.begin(), remove.end());
for(typename Seq::const_iterator p = seq.begin(); p != seq.end(); ++p)
{
- if(removed.find(func(*p)) == removed.end())
- {
- typename Seq::const_iterator q = update.begin();
- for(; q != update.end(); ++q)
- {
- if(func(*p) == func(*q))
- {
- break;
- }
- }
- if(q == update.end())
- {
- result.push_back(*p);
- }
- }
+ if(removed.find(func(*p)) == removed.end())
+ {
+ typename Seq::const_iterator q = update.begin();
+ for(; q != update.end(); ++q)
+ {
+ if(func(*p) == func(*q))
+ {
+ break;
+ }
+ }
+ if(q == update.end())
+ {
+ result.push_back(*p);
+ }
+ }
}
return result;
}
@@ -213,11 +213,11 @@ getDictUpdatedEltsWithEq(const Dict& ldict, const Dict& rdict, EqFunc eq)
Dict result;
for(typename Dict::const_iterator p = rdict.begin(); p != rdict.end(); ++p)
{
- typename Dict::const_iterator q = ldict.find(p->first);
- if(q == ldict.end() || !eq(p->second, q->second))
- {
- result.insert(*p);
- }
+ typename Dict::const_iterator q = ldict.find(p->first);
+ if(q == ldict.end() || !eq(p->second, q->second))
+ {
+ result.insert(*p);
+ }
}
return result;
}
@@ -228,10 +228,10 @@ getDictRemovedElts(const Dict& ldict, const Dict& rdict)
Ice::StringSeq removed;
for(typename Dict::const_iterator p = ldict.begin(); p != ldict.end(); ++p)
{
- if(rdict.find(p->first) == rdict.end())
- {
- removed.push_back(p->first);
- }
+ if(rdict.find(p->first) == rdict.end())
+ {
+ removed.push_back(p->first);
+ }
}
return removed;
}
@@ -242,11 +242,11 @@ updateDictElts(const Dict& dict, const Dict& update, const Ice::StringSeq& remov
Dict result = dict;
for(Ice::StringSeq::const_iterator p = remove.begin(); p != remove.end(); ++p)
{
- result.erase(*p);
+ result.erase(*p);
}
for(typename Dict::const_iterator q = update.begin(); q != update.end(); ++q)
{
- result[q->first] = q->second;
+ result[q->first] = q->second;
}
return result;
}
@@ -281,63 +281,63 @@ Resolver::Resolver(const ApplicationDescriptor& app, const Ice::CommunicatorPtr&
for(StringStringDict::const_iterator v = _variables.begin(); v != _variables.end(); ++v)
{
- if(v->first == "")
- {
- exception("empty variable name");
- }
+ if(v->first == "")
+ {
+ exception("empty variable name");
+ }
}
TemplateDescriptorDict::const_iterator t;
for(t = _application->serverTemplates.begin(); t != _application->serverTemplates.end(); ++t)
{
- if(t->first == "")
- {
- exception("empty server template id");
- }
- if(!t->second.descriptor)
- {
- exception("invalid server template `" + t->first + "': server definition is empty");
- }
-
- Ice::StringSeq params = t->second.parameters;
- sort(params.begin(), params.end());
- Ice::StringSeq wdups = params;
- Ice::StringSeq dups;
- set_difference(wdups.begin(), wdups.end(), params.begin(), unique(params.begin(), params.end()),
- back_inserter(dups));
- if(!dups.empty())
- {
- dups.erase(unique(dups.begin(), dups.end()), dups.end());
- exception("invalid server template `" + t->first + "': duplicate parameters " + toString(dups));
- }
+ if(t->first == "")
+ {
+ exception("empty server template id");
+ }
+ if(!t->second.descriptor)
+ {
+ exception("invalid server template `" + t->first + "': server definition is empty");
+ }
+
+ Ice::StringSeq params = t->second.parameters;
+ sort(params.begin(), params.end());
+ Ice::StringSeq wdups = params;
+ Ice::StringSeq dups;
+ set_difference(wdups.begin(), wdups.end(), params.begin(), unique(params.begin(), params.end()),
+ back_inserter(dups));
+ if(!dups.empty())
+ {
+ dups.erase(unique(dups.begin(), dups.end()), dups.end());
+ exception("invalid server template `" + t->first + "': duplicate parameters " + toString(dups));
+ }
}
for(t = _application->serviceTemplates.begin(); t != _application->serviceTemplates.end(); ++t)
{
- if(t->first == "")
- {
- exception("empty service template id");
- }
- if(!t->second.descriptor)
- {
- exception("invalid service template `" + t->first + "': service definition is empty");
- }
- Ice::StringSeq params = t->second.parameters;
- sort(params.begin(), params.end());
- Ice::StringSeq wdups = params;
- Ice::StringSeq dups;
- set_difference(wdups.begin(), wdups.end(), params.begin(), unique(params.begin(), params.end()),
- back_inserter(dups));
- if(!dups.empty())
- {
- dups.erase(unique(dups.begin(), dups.end()), dups.end());
- exception("invalid server template `" + t->first + "': duplicate parameters " + toString(dups));
- }
+ if(t->first == "")
+ {
+ exception("empty service template id");
+ }
+ if(!t->second.descriptor)
+ {
+ exception("invalid service template `" + t->first + "': service definition is empty");
+ }
+ Ice::StringSeq params = t->second.parameters;
+ sort(params.begin(), params.end());
+ Ice::StringSeq wdups = params;
+ Ice::StringSeq dups;
+ set_difference(wdups.begin(), wdups.end(), params.begin(), unique(params.begin(), params.end()),
+ back_inserter(dups));
+ if(!dups.empty())
+ {
+ dups.erase(unique(dups.begin(), dups.end()), dups.end());
+ exception("invalid server template `" + t->first + "': duplicate parameters " + toString(dups));
+ }
}
}
Resolver::Resolver(const Resolver& resolve,
- const map<string, string>& values,
- bool params) :
+ const map<string, string>& values,
+ bool params) :
_application(resolve._application),
_communicator(resolve._communicator),
_escape(resolve._escape),
@@ -351,20 +351,20 @@ Resolver::Resolver(const Resolver& resolve,
{
if(params)
{
- checkReserved("parameter", values);
+ checkReserved("parameter", values);
}
else
{
- _variables.insert(resolve._variables.begin(), resolve._variables.end());
- checkReserved("variable", values);
+ _variables.insert(resolve._variables.begin(), resolve._variables.end());
+ checkReserved("variable", values);
}
for(StringStringDict::const_iterator v = _variables.begin(); v != _variables.end(); ++v)
{
- if(v->first == "")
- {
- exception("empty variable name");
- }
+ if(v->first == "")
+ {
+ exception("empty variable name");
+ }
}
}
@@ -390,40 +390,40 @@ Resolver::operator()(const string& value, const string& name, bool allowEmpty) c
{
try
{
- string val;
- try
- {
- val = substitute(value, true, true);
- }
- catch(const string& reason)
- {
- throw "invalid variable `" + value + "': " + reason;
- }
- catch(const char* reason)
- {
- throw "invalid variable `" + value + "': " + reason;
- }
-
- if(!allowEmpty)
- {
- if(value.empty())
- {
- throw "empty string";
- }
- else if(val.empty())
- {
- throw "the value of `" + value + "' is an empty string";
- }
- }
- return val;
+ string val;
+ try
+ {
+ val = substitute(value, true, true);
+ }
+ catch(const string& reason)
+ {
+ throw "invalid variable `" + value + "': " + reason;
+ }
+ catch(const char* reason)
+ {
+ throw "invalid variable `" + value + "': " + reason;
+ }
+
+ if(!allowEmpty)
+ {
+ if(value.empty())
+ {
+ throw "empty string";
+ }
+ else if(val.empty())
+ {
+ throw "the value of `" + value + "' is an empty string";
+ }
+ }
+ return val;
}
catch(const string& reason)
{
- exception("invalid value for attribute `" + name + "':\n" + reason);
+ exception("invalid value for attribute `" + name + "':\n" + reason);
}
catch(const char* reason)
{
- exception("invalid value for attribute `" + name + "':\n" + reason);
+ exception("invalid value for attribute `" + name + "':\n" + reason);
}
return ""; // To prevent compiler warning.
}
@@ -434,7 +434,7 @@ Resolver::operator()(const Ice::StringSeq& values, const string& name) const
Ice::StringSeq result;
for(Ice::StringSeq::const_iterator p = values.begin(); p != values.end(); ++p)
{
- result.push_back(operator()(*p, name));
+ result.push_back(operator()(*p, name));
}
return result;
}
@@ -454,10 +454,10 @@ Resolver::operator()(const PropertyDescriptorSeq& properties, const string& name
PropertyDescriptorSeq result;
for(PropertyDescriptorSeq::const_iterator q = properties.begin(); q != properties.end(); ++q)
{
- PropertyDescriptor prop;
- prop.name = operator()(q->name, name + " name");
- prop.value = operator()(q->value, name + " value");
- result.push_back(prop);
+ PropertyDescriptor prop;
+ prop.name = operator()(q->name, name + " name");
+ prop.value = operator()(q->value, name + " value");
+ result.push_back(prop);
}
return result;
}
@@ -469,10 +469,10 @@ Resolver::operator()(const PropertySetDescriptorDict& propertySets) const
PropertySetDescriptorDict::const_iterator ps;
for(ps = propertySets.begin(); ps != propertySets.end(); ++ps)
{
- PropertySetDescriptor desc;
- desc.references = operator()(ps->second.references, "property set `" + ps->first + "' reference");
- desc.properties = operator()(ps->second.properties, "property set `" + ps->first + "' property");
- result.insert(make_pair(ps->first, desc));
+ PropertySetDescriptor desc;
+ desc.references = operator()(ps->second.references, "property set `" + ps->first + "' reference");
+ desc.properties = operator()(ps->second.properties, "property set `" + ps->first + "' property");
+ result.insert(make_pair(ps->first, desc));
}
return result;
}
@@ -483,10 +483,10 @@ Resolver::operator()(const ObjectDescriptorSeq& objects, const string& type) con
ObjectDescriptorSeq result;
for(ObjectDescriptorSeq::const_iterator q = objects.begin(); q != objects.end(); ++q)
{
- ObjectDescriptor obj;
- obj.type = operator()(q->type, type + " object type");
- obj.id = operator()(q->id, type + " object identity");
- result.push_back(obj);
+ ObjectDescriptor obj;
+ obj.type = operator()(q->type, type + " object type");
+ obj.id = operator()(q->id, type + " object identity");
+ result.push_back(obj);
}
return result;
}
@@ -499,7 +499,7 @@ Resolver::operator()(const Ice::Identity& value, const string& name) const
Ice::Identity id = _communicator->stringToIdentity(str);
if(id.name.empty())
{
- exception("invalid object identity `" + _communicator->identityToString(value) + "': name empty");
+ exception("invalid object identity `" + _communicator->identityToString(value) + "': name empty");
}
return id;
}
@@ -520,20 +520,20 @@ Resolver::asInt(const string& value, const string& name) const
string v = operator()(value, name);
if(!v.empty())
{
- string::size_type beg = v.find_first_not_of(' ');
- string::size_type end = v.find_last_not_of(' ');
- v = v.substr(beg == string::npos ? 0 : beg, end == string::npos ? v.length() - 1 : end - beg + 1);
+ string::size_type beg = v.find_first_not_of(' ');
+ string::size_type end = v.find_last_not_of(' ');
+ v = v.substr(beg == string::npos ? 0 : beg, end == string::npos ? v.length() - 1 : end - beg + 1);
- int val;
- istringstream is(v);
- if(!(is >> val) || !is.eof())
- {
- exception("invalid value `" + value + "' for `" + name + "':\nnot an integer");
- }
+ int val;
+ istringstream is(v);
+ if(!(is >> val) || !is.eof())
+ {
+ exception("invalid value `" + value + "' for `" + name + "':\nnot an integer");
+ }
- ostringstream os;
- os << val;
- v = os.str();
+ ostringstream os;
+ os << val;
+ v = os.str();
}
return v;
}
@@ -544,16 +544,16 @@ Resolver::asFloat(const string& value, const string& name) const
string v = operator()(value, name);
if(!v.empty())
{
- string::size_type beg = v.find_first_not_of(' ');
- string::size_type end = v.find_last_not_of(' ');
- v = v.substr(beg == string::npos ? 0 : beg, end == string::npos ? v.length() - 1 : end - beg + 1);
+ string::size_type beg = v.find_first_not_of(' ');
+ string::size_type end = v.find_last_not_of(' ');
+ v = v.substr(beg == string::npos ? 0 : beg, end == string::npos ? v.length() - 1 : end - beg + 1);
- float val;
- istringstream is(v);
- if(!(is >> val) || !is.eof())
- {
- exception("invalid value `" + value + "' for `" + name + "':\nnot a float");
- }
+ float val;
+ istringstream is(v);
+ if(!(is >> val) || !is.eof())
+ {
+ exception("invalid value `" + value + "' for `" + name + "':\nnot a float");
+ }
}
return v;
}
@@ -563,38 +563,38 @@ Resolver::asId(const string& value, const string& name, bool allowEmpty) const
{
try
{
- if(!allowEmpty && value.empty())
- {
- throw "empty string";
- }
-
- string val;
- try
- {
- val = substitute(value, true, false);
- }
- catch(const string& reason)
- {
- throw "invalid variable `" + value + "':\n" + reason;
- }
- catch(const char* reason)
- {
- throw "invalid variable `" + value + "':\n" + reason;
- }
-
- if(!allowEmpty && val.empty())
- {
- throw "the value of `" + value + "' is an empty string";
- }
- return val;
+ if(!allowEmpty && value.empty())
+ {
+ throw "empty string";
+ }
+
+ string val;
+ try
+ {
+ val = substitute(value, true, false);
+ }
+ catch(const string& reason)
+ {
+ throw "invalid variable `" + value + "':\n" + reason;
+ }
+ catch(const char* reason)
+ {
+ throw "invalid variable `" + value + "':\n" + reason;
+ }
+
+ if(!allowEmpty && val.empty())
+ {
+ throw "the value of `" + value + "' is an empty string";
+ }
+ return val;
}
catch(const string& reason)
{
- exception("invalid value for attribute `" + name + "':\n" + reason);
+ exception("invalid value for attribute `" + name + "':\n" + reason);
}
catch(const char* reason)
{
- exception("invalid value for attribute `" + name + "':\n" + reason);
+ exception("invalid value for attribute `" + name + "':\n" + reason);
}
return ""; // To prevent compiler warning.
}
@@ -611,15 +611,15 @@ Resolver::setContext(const string& context)
{
try
{
- _context = substitute(context, true, true);
+ _context = substitute(context, true, true);
}
catch(const string& reason)
{
- exception(reason);
+ exception(reason);
}
catch(const char* reason)
{
- exception(reason);
+ exception(reason);
}
}
@@ -631,10 +631,10 @@ Resolver::addPropertySets(const PropertySetDescriptorDict& propertySets)
PropertySetDescriptorDict::const_iterator p;
for(p = propertySets.begin(); p != propertySets.end(); ++p)
{
- if(!_propertySets.insert(*p).second)
- {
- exception("property set with id `" + p->first + "' is already defined at this scope");
- }
+ if(!_propertySets.insert(*p).second)
+ {
+ exception("property set with id `" + p->first + "' is already defined at this scope");
+ }
}
_propertySets.insert(oldPropertySets.begin(), oldPropertySets.end());
@@ -643,7 +643,7 @@ Resolver::addPropertySets(const PropertySetDescriptorDict& propertySets)
//
for(p = propertySets.begin(); p != propertySets.end(); ++p)
{
- getProperties(p->second.references);
+ getProperties(p->second.references);
}
}
@@ -653,7 +653,7 @@ Resolver::getPropertySet(const string& id) const
PropertySetDescriptorDict::const_iterator p = _propertySets.find(id);
if(p == _propertySets.end())
{
- exception("invalid reference to property set, property set `" + id + "' doesn't exist");
+ exception("invalid reference to property set, property set `" + id + "' doesn't exist");
}
return p->second;
}
@@ -684,7 +684,7 @@ Resolver::getServerTemplate(const string& tmpl) const
TemplateDescriptorDict::const_iterator p = _application->serverTemplates.find(tmpl);
if(p == _application->serverTemplates.end())
{
- throw DeploymentException("unknown server template `" + tmpl + "'");
+ throw DeploymentException("unknown server template `" + tmpl + "'");
}
return p->second;
}
@@ -696,7 +696,7 @@ Resolver::getServiceTemplate(const string& tmpl) const
TemplateDescriptorDict::const_iterator p = _application->serviceTemplates.find(tmpl);
if(p == _application->serviceTemplates.end())
{
- throw DeploymentException("unknown service template `" + tmpl + "'");
+ throw DeploymentException("unknown service template `" + tmpl + "'");
}
return p->second;
}
@@ -706,22 +706,22 @@ Resolver::hasReplicaGroup(const string& id) const
{
if(!_application)
{
- //
- // If we don't know the application descrpitor we assume that
- // the replica group exists (this is possible if the resolver
- // wasn't built from an application helper, that's the case if
- // it's built from NodeCache just to resolve ${node.*} and
- // ${session.*} variables.
- //
- return true;
+ //
+ // If we don't know the application descrpitor we assume that
+ // the replica group exists (this is possible if the resolver
+ // wasn't built from an application helper, that's the case if
+ // it's built from NodeCache just to resolve ${node.*} and
+ // ${session.*} variables.
+ //
+ return true;
}
ReplicaGroupDescriptorSeq::const_iterator p;
for(p = _application->replicaGroups.begin(); p != _application->replicaGroups.end(); ++p)
{
- if(p->id == id)
- {
- return true;
- }
+ if(p->id == id)
+ {
+ return true;
+ }
}
return false;
}
@@ -735,66 +735,66 @@ Resolver::substitute(const string& v, bool useParams, bool useIgnored) const
while((beg = value.find("${", beg)) != string::npos)
{
- if(beg > 0 && value[beg - 1] == '$')
- {
- string::size_type escape = beg - 1;
- while(escape > 0 && value[escape - 1] == '$')
- {
- --escape;
- }
-
- if((beg - escape) % 2)
- {
- if(_escape)
- {
- value.replace(escape, beg - escape, (beg - escape) / 2, '$');
- }
- ++beg;
- continue;
- }
- else
- {
- value.replace(escape, beg - escape, (beg - escape) / 2, '$');
- beg -= (beg - escape) / 2;
- }
- }
-
- end = value.find("}", beg);
- if(end == string::npos)
- {
- throw "malformed variable name `" + value + "'";
- }
-
- //
- // Get the name of the variable and get its value if the
- // variable is not currently ignored (in which case we do
- // nothing, the variable will be substituted later). If the
- // name refered to a parameter we don't do any recursive
- // substitution: the parameter value is computed at the point
- // of definition.
- //
- string name = value.substr(beg + 2, end - beg - 2);
- if(_ignore.find(name) != _ignore.end())
- {
- if(useIgnored)
- {
- ++beg;
- continue;
- }
- else
- {
- throw "use of the `" + name + "' variable is now allowed here";
- }
- }
-
- bool param;
- string val = getVariable(name, useParams, param);
- if(!param)
- {
- val = substitute(val, false, useIgnored); // Recursive resolution
- }
- value.replace(beg, end - beg + 1, val);
- beg += val.length();
+ if(beg > 0 && value[beg - 1] == '$')
+ {
+ string::size_type escape = beg - 1;
+ while(escape > 0 && value[escape - 1] == '$')
+ {
+ --escape;
+ }
+
+ if((beg - escape) % 2)
+ {
+ if(_escape)
+ {
+ value.replace(escape, beg - escape, (beg - escape) / 2, '$');
+ }
+ ++beg;
+ continue;
+ }
+ else
+ {
+ value.replace(escape, beg - escape, (beg - escape) / 2, '$');
+ beg -= (beg - escape) / 2;
+ }
+ }
+
+ end = value.find("}", beg);
+ if(end == string::npos)
+ {
+ throw "malformed variable name `" + value + "'";
+ }
+
+ //
+ // Get the name of the variable and get its value if the
+ // variable is not currently ignored (in which case we do
+ // nothing, the variable will be substituted later). If the
+ // name refered to a parameter we don't do any recursive
+ // substitution: the parameter value is computed at the point
+ // of definition.
+ //
+ string name = value.substr(beg + 2, end - beg - 2);
+ if(_ignore.find(name) != _ignore.end())
+ {
+ if(useIgnored)
+ {
+ ++beg;
+ continue;
+ }
+ else
+ {
+ throw "use of the `" + name + "' variable is now allowed here";
+ }
+ }
+
+ bool param;
+ string val = getVariable(name, useParams, param);
+ if(!param)
+ {
+ val = substitute(val, false, useIgnored); // Recursive resolution
+ }
+ value.replace(beg, end - beg + 1, val);
+ beg += val.length();
}
return value;
}
@@ -810,25 +810,25 @@ Resolver::getVariable(const string& name, bool checkParams, bool& param) const
map<string, string>::const_iterator p = _reserved.find(name);
if(p != _reserved.end())
{
- if(p->second.empty())
- {
- throw "undefined variable `" + name + "'";
- }
- return p->second;
+ if(p->second.empty())
+ {
+ throw "undefined variable `" + name + "'";
+ }
+ return p->second;
}
if(checkParams)
{
- p = _parameters.find(name);
- if(p != _parameters.end())
- {
- param = true;
- return p->second;
- }
+ p = _parameters.find(name);
+ if(p != _parameters.end())
+ {
+ param = true;
+ return p->second;
+ }
}
p = _variables.find(name);
if(p != _variables.end())
{
- return p->second;
+ return p->second;
}
throw "undefined variable `" + name + "'";
@@ -841,21 +841,21 @@ Resolver::getProperties(const Ice::StringSeq& references, set<string>& resolved)
PropertyDescriptorSeq properties;
for(Ice::StringSeq::const_iterator p = references.begin(); p != references.end(); ++p)
{
- if(resolved.find(*p) != resolved.end())
- {
- exception("detected circular dependency with property reference `" + *p + "'");
- }
-
- PropertySetDescriptor desc = getPropertySet(*p);
- if(!desc.references.empty())
- {
- resolved.insert(*p);
- PropertyDescriptorSeq p = getProperties(desc.references, resolved);
- properties.insert(properties.end(), p.begin(), p.end());
- }
-
- PropertyDescriptorSeq pds = operator()(desc.properties);
- properties.insert(properties.end(), pds.begin(), pds.end());
+ if(resolved.find(*p) != resolved.end())
+ {
+ exception("detected circular dependency with property reference `" + *p + "'");
+ }
+
+ PropertySetDescriptor desc = getPropertySet(*p);
+ if(!desc.references.empty())
+ {
+ resolved.insert(*p);
+ PropertyDescriptorSeq p = getProperties(desc.references, resolved);
+ properties.insert(properties.end(), p.begin(), p.end());
+ }
+
+ PropertyDescriptorSeq pds = operator()(desc.properties);
+ properties.insert(properties.end(), pds.begin(), pds.end());
}
return properties;
}
@@ -890,10 +890,10 @@ Resolver::checkReserved(const string& type, const map<string, string>& values) c
{
for(map<string, string>::const_iterator p = values.begin(); p != values.end(); ++p)
{
- if(_reserved.find(p->first) != _reserved.end())
- {
- exception("invalid " + type + " `" + p->first + "': reserved variable name");
- }
+ if(_reserved.find(p->first) != _reserved.end())
+ {
+ exception("invalid " + type + " `" + p->first + "': reserved variable name");
+ }
}
}
@@ -907,34 +907,34 @@ CommunicatorHelper::operator==(const CommunicatorHelper& helper) const
{
if(_desc->ice_id() != helper._desc->ice_id())
{
- return false;
+ return false;
}
if(_desc->description != helper._desc->description)
{
- return false;
+ return false;
}
if(set<AdapterDescriptor>(_desc->adapters.begin(), _desc->adapters.end()) !=
set<AdapterDescriptor>(helper._desc->adapters.begin(), helper._desc->adapters.end()))
{
- return false;
+ return false;
}
if(_desc->propertySet != helper._desc->propertySet)
{
- return false;
+ return false;
}
if(set<DbEnvDescriptor>(_desc->dbEnvs.begin(), _desc->dbEnvs.end()) !=
set<DbEnvDescriptor>(helper._desc->dbEnvs.begin(), helper._desc->dbEnvs.end()))
{
- return false;
+ return false;
}
if(_desc->logs != helper._desc->logs)
{
- return false;
+ return false;
}
return true;
@@ -950,23 +950,23 @@ void
CommunicatorHelper::getIds(multiset<string>& adapterIds, multiset<Ice::Identity>& objectIds) const
{
for(AdapterDescriptorSeq::const_iterator p = _desc->adapters.begin(); p != _desc->adapters.end(); ++p)
- {
- if(!p->id.empty())
- {
- adapterIds.insert(p->id);
- }
-
- set<Ice::Identity> ids;
- ObjectDescriptorSeq::const_iterator q;
- for(q = p->objects.begin(); q != p->objects.end(); ++q)
- {
- ids.insert(q->id);
- }
- for(q = p->allocatables.begin(); q != p->allocatables.end(); ++q)
- {
- ids.insert(q->id);
- }
- objectIds.insert(ids.begin(), ids.end());
+ {
+ if(!p->id.empty())
+ {
+ adapterIds.insert(p->id);
+ }
+
+ set<Ice::Identity> ids;
+ ObjectDescriptorSeq::const_iterator q;
+ for(q = p->objects.begin(); q != p->objects.end(); ++q)
+ {
+ ids.insert(q->id);
+ }
+ for(q = p->allocatables.begin(); q != p->allocatables.end(); ++q)
+ {
+ ids.insert(q->id);
+ }
+ objectIds.insert(ids.begin(), ids.end());
}
}
@@ -978,44 +978,44 @@ CommunicatorHelper::instantiateImpl(const CommunicatorDescriptorPtr& instance, c
for(AdapterDescriptorSeq::const_iterator p = _desc->adapters.begin(); p != _desc->adapters.end(); ++p)
{
- AdapterDescriptor adapter;
- adapter.name = resolve(p->name, "object adapter name", false);
- adapter.description = resolve(p->description, "object adapter description");
- adapter.id = resolve.asId(p->id, "object adapter id");
- adapter.registerProcess = p->registerProcess;
- adapter.serverLifetime = p->serverLifetime;
- adapter.replicaGroupId = resolve.asId(p->replicaGroupId, "object adapter replica group id", true);
- if(!adapter.replicaGroupId.empty() && !resolve.hasReplicaGroup(adapter.replicaGroupId))
- {
- resolve.exception("unknown replica group `" + adapter.replicaGroupId + "'");
- }
- adapter.priority = resolve.asInt(p->priority, "object adapter priority");
- adapter.objects = resolve(p->objects, "well-known");
- adapter.allocatables = resolve(p->allocatables, "allocatable");
- instance->adapters.push_back(adapter);
-
- //
- // Make sure the endpoints are defined.
- //
- if(IceGrid::getProperty(instance->propertySet.properties, "Ice.OA." + adapter.name + ".Endpoints").empty())
- {
- resolve.exception("invalid endpoints for adapter `" + adapter.name + "': empty string");
- }
+ AdapterDescriptor adapter;
+ adapter.name = resolve(p->name, "object adapter name", false);
+ adapter.description = resolve(p->description, "object adapter description");
+ adapter.id = resolve.asId(p->id, "object adapter id");
+ adapter.registerProcess = p->registerProcess;
+ adapter.serverLifetime = p->serverLifetime;
+ adapter.replicaGroupId = resolve.asId(p->replicaGroupId, "object adapter replica group id", true);
+ if(!adapter.replicaGroupId.empty() && !resolve.hasReplicaGroup(adapter.replicaGroupId))
+ {
+ resolve.exception("unknown replica group `" + adapter.replicaGroupId + "'");
+ }
+ adapter.priority = resolve.asInt(p->priority, "object adapter priority");
+ adapter.objects = resolve(p->objects, "well-known");
+ adapter.allocatables = resolve(p->allocatables, "allocatable");
+ instance->adapters.push_back(adapter);
+
+ //
+ // Make sure the endpoints are defined.
+ //
+ if(IceGrid::getProperty(instance->propertySet.properties, "Ice.OA." + adapter.name + ".Endpoints").empty())
+ {
+ resolve.exception("invalid endpoints for adapter `" + adapter.name + "': empty string");
+ }
}
for(DbEnvDescriptorSeq::const_iterator s = _desc->dbEnvs.begin(); s != _desc->dbEnvs.end(); ++s)
{
- DbEnvDescriptor dbEnv;
- dbEnv.name = resolve(s->name, "database environment name", false);
- dbEnv.description = resolve(s->description, "database environment description");
- dbEnv.dbHome = resolve(s->dbHome, "database environment home directory");
- dbEnv.properties = resolve(s->properties, "database environment property");
- instance->dbEnvs.push_back(dbEnv);
+ DbEnvDescriptor dbEnv;
+ dbEnv.name = resolve(s->name, "database environment name", false);
+ dbEnv.description = resolve(s->description, "database environment description");
+ dbEnv.dbHome = resolve(s->dbHome, "database environment home directory");
+ dbEnv.properties = resolve(s->properties, "database environment property");
+ instance->dbEnvs.push_back(dbEnv);
}
for(Ice::StringSeq::const_iterator l = _desc->logs.begin(); l != _desc->logs.end(); ++l)
{
- instance->logs.push_back(resolve(*l, "log path", false));
+ instance->logs.push_back(resolve(*l, "log path", false));
}
}
@@ -1039,17 +1039,17 @@ CommunicatorHelper::upgrade(CommunicatorDescriptorPtr& desc) const
bool upgraded = false;
for(AdapterDescriptorSeq::const_iterator p = _desc->adapters.begin(); p != _desc->adapters.end(); ++p)
{
- const string oaPrefix = p->name + ".";
- for(PropertyDescriptorSeq::iterator q = properties.begin(); q != properties.end(); ++q)
- {
- if(q->name.find(oaPrefix) == 0 &&
- q->name.size() > oaPrefix.size() &&
- oaProperties.find(q->name.substr(oaPrefix.size())) != oaProperties.end())
- {
- q->name = "Ice.OA." + q->name;
- upgraded = true;
- }
- }
+ const string oaPrefix = p->name + ".";
+ for(PropertyDescriptorSeq::iterator q = properties.begin(); q != properties.end(); ++q)
+ {
+ if(q->name.find(oaPrefix) == 0 &&
+ q->name.size() > oaPrefix.size() &&
+ oaProperties.find(q->name.substr(oaPrefix.size())) != oaProperties.end())
+ {
+ q->name = "Ice.OA." + q->name;
+ upgraded = true;
+ }
+ }
}
return upgraded;
}
@@ -1059,48 +1059,48 @@ CommunicatorHelper::print(const Ice::CommunicatorPtr& communicator, Output& out)
{
if(!_desc->description.empty())
{
- out << nl << "description";
- out << sb;
- out << nl << _desc->description;
- out << eb;
+ out << nl << "description";
+ out << sb;
+ out << nl << _desc->description;
+ out << eb;
}
set<string> hiddenProperties;
{
- for(DbEnvDescriptorSeq::const_iterator p = _desc->dbEnvs.begin(); p != _desc->dbEnvs.end(); ++p)
- {
- printDbEnv(out, *p);
- }
+ for(DbEnvDescriptorSeq::const_iterator p = _desc->dbEnvs.begin(); p != _desc->dbEnvs.end(); ++p)
+ {
+ printDbEnv(out, *p);
+ }
}
{
- for(AdapterDescriptorSeq::const_iterator p = _desc->adapters.begin(); p != _desc->adapters.end(); ++p)
- {
- hiddenProperties.insert("Ice.OA." + p->name + ".Endpoints");
- printObjectAdapter(communicator, out, *p);
- }
+ for(AdapterDescriptorSeq::const_iterator p = _desc->adapters.begin(); p != _desc->adapters.end(); ++p)
+ {
+ hiddenProperties.insert("Ice.OA." + p->name + ".Endpoints");
+ printObjectAdapter(communicator, out, *p);
+ }
}
{
- for(Ice::StringSeq::const_iterator p = _desc->logs.begin(); p != _desc->logs.end(); ++p)
- {
- out << nl << "log `" << *p << "'";
- }
+ for(Ice::StringSeq::const_iterator p = _desc->logs.begin(); p != _desc->logs.end(); ++p)
+ {
+ out << nl << "log `" << *p << "'";
+ }
}
if(!_desc->propertySet.properties.empty() || !_desc->propertySet.references.empty())
{
- out << nl << "properties";
- out << sb;
- if(!_desc->propertySet.references.empty())
- {
- out << nl << "references = " << toString(_desc->propertySet.references);
- }
- PropertyDescriptorSeq::const_iterator q;
- for(q = _desc->propertySet.properties.begin(); q != _desc->propertySet.properties.end(); ++q)
- {
- if(hiddenProperties.find(q->name) == hiddenProperties.end())
- {
- out << nl << q->name << " = `" << q->value << "'";
- }
- }
- out << eb;
+ out << nl << "properties";
+ out << sb;
+ if(!_desc->propertySet.references.empty())
+ {
+ out << nl << "references = " << toString(_desc->propertySet.references);
+ }
+ PropertyDescriptorSeq::const_iterator q;
+ for(q = _desc->propertySet.properties.begin(); q != _desc->propertySet.properties.end(); ++q)
+ {
+ if(hiddenProperties.find(q->name) == hiddenProperties.end())
+ {
+ out << nl << q->name << " = `" << q->value << "'";
+ }
+ }
+ out << eb;
}
}
@@ -1110,82 +1110,82 @@ CommunicatorHelper::printDbEnv(Output& out, const DbEnvDescriptor& dbEnv) const
out << nl << "database environment `" << dbEnv.name << "'";
if(!dbEnv.dbHome.empty() || !dbEnv.properties.empty() || !dbEnv.description.empty())
{
- out << sb;
- if(!dbEnv.dbHome.empty())
- {
- out << nl << "home = `" << dbEnv.dbHome << "'";
- }
- if(!dbEnv.description.empty())
- {
- out << nl << "description = `" << dbEnv.description << "'";
- }
- if(!dbEnv.properties.empty())
- {
- out << nl << "properties";
- out << sb;
- for(PropertyDescriptorSeq::const_iterator p = dbEnv.properties.begin(); p != dbEnv.properties.end(); ++p)
- {
- out << nl << p->name << " = `" << p->value << "'";
- }
- out << eb;
- }
- out << eb;
+ out << sb;
+ if(!dbEnv.dbHome.empty())
+ {
+ out << nl << "home = `" << dbEnv.dbHome << "'";
+ }
+ if(!dbEnv.description.empty())
+ {
+ out << nl << "description = `" << dbEnv.description << "'";
+ }
+ if(!dbEnv.properties.empty())
+ {
+ out << nl << "properties";
+ out << sb;
+ for(PropertyDescriptorSeq::const_iterator p = dbEnv.properties.begin(); p != dbEnv.properties.end(); ++p)
+ {
+ out << nl << p->name << " = `" << p->value << "'";
+ }
+ out << eb;
+ }
+ out << eb;
}
}
void
CommunicatorHelper::printObjectAdapter(const Ice::CommunicatorPtr& communicator,
- Output& out,
- const AdapterDescriptor& adapter) const
+ Output& out,
+ const AdapterDescriptor& adapter) const
{
out << nl << "adapter `" << adapter.name << "'";
out << sb;
if(!adapter.id.empty())
{
- out << nl << "id = `" << adapter.id << "'";
+ out << nl << "id = `" << adapter.id << "'";
}
if(!adapter.replicaGroupId.empty())
{
- out << nl << "replica group id = `" << adapter.replicaGroupId << "'";
+ out << nl << "replica group id = `" << adapter.replicaGroupId << "'";
}
if(!adapter.priority.empty())
{
- out << nl << "priority = `" << adapter.priority << "'";
+ out << nl << "priority = `" << adapter.priority << "'";
}
string endpoints = getProperty("Ice.OA." + adapter.name + ".Endpoints");
if(!endpoints.empty())
{
- out << nl << "endpoints = `" << endpoints << "'";
+ out << nl << "endpoints = `" << endpoints << "'";
}
out << nl << "register process = `" << (adapter.registerProcess ? "true" : "false") << "'";
out << nl << "server lifetime = `" << (adapter.serverLifetime ? "true" : "false") << "'";
ObjectDescriptorSeq::const_iterator p;
for(p = adapter.objects.begin(); p != adapter.objects.end(); ++p)
{
- out << nl << "well-known object";
- out << sb;
- out << nl << "identity = `" << communicator->identityToString(p->id) << "' ";
- if(!p->type.empty())
- {
- out << nl << "type = `" << p->type << "'";
- }
- out << eb;
+ out << nl << "well-known object";
+ out << sb;
+ out << nl << "identity = `" << communicator->identityToString(p->id) << "' ";
+ if(!p->type.empty())
+ {
+ out << nl << "type = `" << p->type << "'";
+ }
+ out << eb;
}
for(p = adapter.allocatables.begin(); p != adapter.allocatables.end(); ++p)
{
- out << nl << "allocatable";
- out << sb;
- out << nl << "identity = `" << communicator->identityToString(p->id) << "' ";
- if(!p->type.empty())
- {
- out << nl << "type = `" << p->type << "'";
- }
- out << eb;
+ out << nl << "allocatable";
+ out << sb;
+ out << nl << "identity = `" << communicator->identityToString(p->id) << "' ";
+ if(!p->type.empty())
+ {
+ out << nl << "type = `" << p->type << "'";
+ }
+ out << eb;
}
if(!adapter.description.empty())
{
- out << nl << "description = `" << adapter.description << "'";
+ out << nl << "description = `" << adapter.description << "'";
}
out << eb;
}
@@ -1207,17 +1207,17 @@ ServiceHelper::operator==(const ServiceHelper& helper) const
{
if(!CommunicatorHelper::operator==(helper))
{
- return false;
+ return false;
}
if(_desc->name != helper._desc->name)
{
- return false;
+ return false;
}
if(_desc->entry != helper._desc->entry)
{
- return false;
+ return false;
}
return true;
@@ -1237,7 +1237,7 @@ ServiceHelper::getDescriptor() const
ServiceDescriptorPtr
ServiceHelper::instantiate(const Resolver& resolver, const PropertyDescriptorSeq& props,
- const PropertySetDescriptorDict& serviceProps) const
+ const PropertySetDescriptorDict& serviceProps) const
{
ServiceDescriptorPtr service = new ServiceDescriptor();
instantiateImpl(service, resolver, props, serviceProps);
@@ -1246,9 +1246,9 @@ ServiceHelper::instantiate(const Resolver& resolver, const PropertyDescriptorSeq
void
ServiceHelper::instantiateImpl(const ServiceDescriptorPtr& instance,
- const Resolver& resolve,
- const PropertyDescriptorSeq& props,
- const PropertySetDescriptorDict& serviceProps) const
+ const Resolver& resolve,
+ const PropertyDescriptorSeq& props,
+ const PropertySetDescriptorDict& serviceProps) const
{
CommunicatorHelper::instantiateImpl(instance, resolve);
instance->name = resolve(_desc->name, "name", false);
@@ -1257,9 +1257,9 @@ ServiceHelper::instantiateImpl(const ServiceDescriptorPtr& instance,
PropertySetDescriptorDict::const_iterator p = serviceProps.find(instance->name);
if(p != serviceProps.end())
{
- instance->propertySet.properties.insert(instance->propertySet.properties.end(),
- p->second.properties.begin(),
- p->second.properties.end());
+ instance->propertySet.properties.insert(instance->propertySet.properties.end(),
+ p->second.properties.begin(),
+ p->second.properties.end());
}
}
@@ -1284,69 +1284,69 @@ ServerHelper::operator==(const ServerHelper& helper) const
{
if(!CommunicatorHelper::operator==(helper))
{
- return false;
+ return false;
}
if(_desc->id != helper._desc->id)
{
- return false;
+ return false;
}
if(_desc->exe != helper._desc->exe)
{
- return false;
+ return false;
}
if(_desc->pwd != helper._desc->pwd)
{
- return false;
+ return false;
}
if(set<string>(_desc->options.begin(), _desc->options.end()) !=
set<string>(helper._desc->options.begin(), helper._desc->options.end()))
{
- return false;
+ return false;
}
if(set<string>(_desc->envs.begin(), _desc->envs.end()) !=
set<string>(helper._desc->envs.begin(), helper._desc->envs.end()))
{
- return false;
+ return false;
}
if(_desc->activation != helper._desc->activation)
{
- return false;
+ return false;
}
if(_desc->activationTimeout != helper._desc->activationTimeout)
{
- return false;
+ return false;
}
if(_desc->deactivationTimeout != helper._desc->deactivationTimeout)
{
- return false;
+ return false;
}
if(_desc->distrib != helper._desc->distrib)
{
- return false;
+ return false;
}
if(_desc->allocatable != helper._desc->allocatable)
{
- return false;
+ return false;
}
if(_desc->user != helper._desc->user)
{
- return false;
+ return false;
}
if(_desc->iceVersion != helper._desc->iceVersion)
{
- return false;
+ return false;
}
return true;
@@ -1366,12 +1366,12 @@ ServerHelper::getDescriptor() const
ServerDescriptorPtr
ServerHelper::instantiate(const Resolver& resolver,
- const PropertyDescriptorSeq& props,
- const PropertySetDescriptorDict& serviceProps) const
+ const PropertyDescriptorSeq& props,
+ const PropertySetDescriptorDict& serviceProps) const
{
if(!serviceProps.empty())
{
- resolver.exception("service property sets are only allowed in IceBox server instances");
+ resolver.exception("service property sets are only allowed in IceBox server instances");
}
ServerDescriptorPtr server = new ServerDescriptor();
@@ -1399,70 +1399,70 @@ ServerHelper::printImpl(const Ice::CommunicatorPtr& communicator, Output& out, c
{
if(!info.application.empty())
{
- out << nl << "application = `" << info.application << "'";
- out << nl << "application uuid = `" << info.uuid << "'";
- out << nl << "application revision = `" << info.revision << "'";
+ out << nl << "application = `" << info.application << "'";
+ out << nl << "application uuid = `" << info.uuid << "'";
+ out << nl << "application revision = `" << info.revision << "'";
}
if(!info.node.empty())
{
- out << nl << "node = `" << info.node << "'";
+ out << nl << "node = `" << info.node << "'";
}
if(!info.sessionId.empty())
{
- out << nl << "session id = `" << info.sessionId << "'";
+ out << nl << "session id = `" << info.sessionId << "'";
}
out << nl << "exe = `" << _desc->exe << "'";
if(!_desc->pwd.empty())
{
- out << nl << "pwd = `" << _desc->pwd << "'";
+ out << nl << "pwd = `" << _desc->pwd << "'";
}
out << nl << "activation = `" << _desc->activation << "'";
if(!_desc->activationTimeout.empty() && _desc->activationTimeout != "0")
{
- out << nl << "activationTimeout = `" << _desc->activationTimeout << "'";
+ out << nl << "activationTimeout = `" << _desc->activationTimeout << "'";
}
if(!_desc->deactivationTimeout.empty() && _desc->deactivationTimeout != "0")
{
- out << nl << "deactivationTimeout = `" << _desc->deactivationTimeout << "'";
+ out << nl << "deactivationTimeout = `" << _desc->deactivationTimeout << "'";
}
if(!_desc->user.empty())
{
- out << nl << "user = `" << _desc->user << "'";
+ out << nl << "user = `" << _desc->user << "'";
}
if(!_desc->iceVersion.empty())
{
- out << nl << "ice version = `" << _desc->iceVersion << "'";
+ out << nl << "ice version = `" << _desc->iceVersion << "'";
}
if(!_desc->applicationDistrib)
{
- out << nl << "application distribution = `false'";
+ out << nl << "application distribution = `false'";
}
if(!_desc->options.empty())
{
- out << nl << "options = `" << toString(_desc->options) << "'";
+ out << nl << "options = `" << toString(_desc->options) << "'";
}
if(!_desc->envs.empty())
{
- out << nl << "envs = `" << toString(_desc->envs) << "'";
+ out << nl << "envs = `" << toString(_desc->envs) << "'";
}
if(!_desc->distrib.icepatch.empty())
{
- out << nl << "distribution";
- out << sb;
- out << nl << "proxy = `" << _desc->distrib.icepatch << "'";
- if(!_desc->distrib.directories.empty())
- {
- out << nl << "directories = `" << toString(_desc->distrib.directories) << "'";
- }
- out << eb;
+ out << nl << "distribution";
+ out << sb;
+ out << nl << "proxy = `" << _desc->distrib.icepatch << "'";
+ if(!_desc->distrib.directories.empty())
+ {
+ out << nl << "directories = `" << toString(_desc->distrib.directories) << "'";
+ }
+ out << eb;
}
CommunicatorHelper::print(communicator, out);
}
void
ServerHelper::instantiateImpl(const ServerDescriptorPtr& instance,
- const Resolver& resolve,
- const PropertyDescriptorSeq& props) const
+ const Resolver& resolve,
+ const PropertyDescriptorSeq& props) const
{
CommunicatorHelper::instantiateImpl(instance, resolve);
@@ -1476,22 +1476,22 @@ ServerHelper::instantiateImpl(const ServerDescriptorPtr& instance,
instance->iceVersion = resolve(_desc->iceVersion, "ice version");
if(!instance->iceVersion.empty())
{
- int version = getMMVersion(instance->iceVersion);
- if(version < 0)
- {
- resolve.exception("invalid ice version: " + instance->iceVersion);
- }
- else if(version > ICE_INT_VERSION)
- {
- //resolve.exception("invalid ice version: " + instance->iceVersion + " is superior to the IceGrid \n"
- //"registry version (" + ICE_STRING_VERSION + ")");
- if(resolve.warningEnabled())
- {
- Ice::Warning out(resolve.getCommunicator()->getLogger());
- out << "invalid ice version: " << instance->iceVersion << " is superior to the IceGrid ";
- out << "registry version (" << ICE_STRING_VERSION << ")";
- }
- }
+ int version = getMMVersion(instance->iceVersion);
+ if(version < 0)
+ {
+ resolve.exception("invalid ice version: " + instance->iceVersion);
+ }
+ else if(version > ICE_INT_VERSION)
+ {
+ //resolve.exception("invalid ice version: " + instance->iceVersion + " is superior to the IceGrid \n"
+ //"registry version (" + ICE_STRING_VERSION + ")");
+ if(resolve.warningEnabled())
+ {
+ Ice::Warning out(resolve.getCommunicator()->getLogger());
+ out << "invalid ice version: " << instance->iceVersion << " is superior to the IceGrid ";
+ out << "registry version (" << ICE_STRING_VERSION << ")";
+ }
+ }
}
if(!instance->activation.empty() &&
instance->activation != "manual" &&
@@ -1499,7 +1499,7 @@ ServerHelper::instantiateImpl(const ServerDescriptorPtr& instance,
instance->activation != "always" &&
instance->activation != "session")
{
- resolve.exception("unknown activation `" + instance->activation + "'");
+ resolve.exception("unknown activation `" + instance->activation + "'");
}
instance->activationTimeout = resolve.asInt(_desc->activationTimeout, "activation timeout");
instance->deactivationTimeout = resolve.asInt(_desc->deactivationTimeout, "deactivation timeout");
@@ -1515,7 +1515,7 @@ IceBoxHelper::IceBoxHelper(const IceBoxDescriptorPtr& descriptor) :
{
for(ServiceInstanceDescriptorSeq::const_iterator p = _desc->services.begin(); p != _desc->services.end(); ++p)
{
- _services.push_back(ServiceInstanceHelper(*p));
+ _services.push_back(ServiceInstanceHelper(*p));
}
}
@@ -1524,12 +1524,12 @@ IceBoxHelper::operator==(const IceBoxHelper& helper) const
{
if(!ServerHelper::operator==(helper))
{
- return false;
+ return false;
}
-
+
if(_services != helper._services)
{
- return false;
+ return false;
}
return true;
@@ -1543,8 +1543,8 @@ IceBoxHelper::operator!=(const IceBoxHelper& helper) const
ServerDescriptorPtr
IceBoxHelper::instantiate(const Resolver& resolver,
- const PropertyDescriptorSeq& props,
- const PropertySetDescriptorDict& serviceProps) const
+ const PropertyDescriptorSeq& props,
+ const PropertySetDescriptorDict& serviceProps) const
{
IceBoxDescriptorPtr iceBox = new IceBoxDescriptor();
instantiateImpl(iceBox, resolver, props, serviceProps);
@@ -1557,7 +1557,7 @@ IceBoxHelper::getIds(multiset<string>& adapterIds, multiset<Ice::Identity>& obje
CommunicatorHelper::getIds(adapterIds, objectIds);
for(vector<ServiceInstanceHelper>::const_iterator p = _services.begin(); p != _services.end(); ++p)
{
- p->getIds(adapterIds, objectIds);
+ p->getIds(adapterIds, objectIds);
}
}
@@ -1568,16 +1568,16 @@ IceBoxHelper::upgrade(CommunicatorDescriptorPtr& communicator) const
IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(communicator);
for(ServiceInstanceDescriptorSeq::iterator p = iceBox->services.begin(); p != iceBox->services.end(); ++p)
{
- if(p->descriptor)
- {
- CommunicatorDescriptorPtr com;
- if(ServiceHelper(p->descriptor).upgrade(com))
- {
- upgraded = true;
- p->descriptor = ServiceDescriptorPtr::dynamicCast(com);
- assert(p->descriptor);
- }
- }
+ if(p->descriptor)
+ {
+ CommunicatorDescriptorPtr com;
+ if(ServiceHelper(p->descriptor).upgrade(com))
+ {
+ upgraded = true;
+ p->descriptor = ServiceDescriptorPtr::dynamicCast(com);
+ assert(p->descriptor);
+ }
+ }
}
return upgraded;
}
@@ -1599,42 +1599,42 @@ IceBoxHelper::print(const Ice::CommunicatorPtr& communicator, Output& out, const
printImpl(communicator, out, info);
for(vector<ServiceInstanceHelper>::const_iterator p = _services.begin(); p != _services.end(); ++p)
{
- out << nl;
- p->print(communicator, out);
+ out << nl;
+ p->print(communicator, out);
}
out << eb;
}
void
IceBoxHelper::instantiateImpl(const IceBoxDescriptorPtr& instance,
- const Resolver& resolver,
- const PropertyDescriptorSeq& props,
- const PropertySetDescriptorDict& serviceProps) const
+ const Resolver& resolver,
+ const PropertyDescriptorSeq& props,
+ const PropertySetDescriptorDict& serviceProps) const
{
ServerHelper::instantiateImpl(instance, resolver, props);
set<string> serviceNames;
for(vector<ServiceInstanceHelper>::const_iterator p = _services.begin(); p != _services.end(); ++p)
{
- ServiceInstanceDescriptor desc = p->instantiate(resolver, serviceProps);
- assert(desc.descriptor);
- serviceNames.insert(desc.descriptor->name);
- instance->services.push_back(desc);
+ ServiceInstanceDescriptor desc = p->instantiate(resolver, serviceProps);
+ assert(desc.descriptor);
+ serviceNames.insert(desc.descriptor->name);
+ instance->services.push_back(desc);
}
for(PropertySetDescriptorDict::const_iterator q = serviceProps.begin(); q != serviceProps.end(); ++q)
{
- if(serviceNames.find(q->first) == serviceNames.end())
- {
- resolver.exception("invalid service property set: service `" + q->first + "' doesn't exist");
- }
+ if(serviceNames.find(q->first) == serviceNames.end())
+ {
+ resolver.exception("invalid service property set: service `" + q->first + "' doesn't exist");
+ }
}
}
map<string, string>
InstanceHelper::instantiateParams(const Resolver& resolve,
- const string& tmpl,
- const map<string, string>& parameters,
- const vector<string>& requiredParameters,
- const map<string, string>& defaults) const
+ const string& tmpl,
+ const map<string, string>& parameters,
+ const vector<string>& requiredParameters,
+ const map<string, string>& defaults) const
{
map<string, string> params;
@@ -1642,42 +1642,42 @@ InstanceHelper::instantiateParams(const Resolver& resolve,
set<string> unknown;
for(map<string, string>::const_iterator p = parameters.begin(); p != parameters.end(); ++p)
{
- if(required.find(p->first) == required.end())
- {
- unknown.insert(p->first);
- }
- params.insert(make_pair(p->first, resolve(p->second, "parameter `" + p->first + "'")));
+ if(required.find(p->first) == required.end())
+ {
+ unknown.insert(p->first);
+ }
+ params.insert(make_pair(p->first, resolve(p->second, "parameter `" + p->first + "'")));
}
if(!unknown.empty())
{
- ostringstream os;
- os << "unknown parameters when instantiating `" + tmpl + "' template: ";
- copy(unknown.begin(), unknown.end(), ostream_iterator<string>(os, " "));
- resolve.exception(os.str());
+ ostringstream os;
+ os << "unknown parameters when instantiating `" + tmpl + "' template: ";
+ copy(unknown.begin(), unknown.end(), ostream_iterator<string>(os, " "));
+ resolve.exception(os.str());
}
set<string> missingParams;
for(set<string>::const_iterator q = required.begin(); q != required.end(); ++q)
{
- if(params.find(*q) == params.end())
- {
- map<string, string>::const_iterator r = defaults.find(*q);
- if(r == defaults.end())
- {
- missingParams.insert(*q);
- }
- else
- {
- params.insert(make_pair(r->first, resolve(r->second, "default parameter `" + r->first + "'")));
- }
- }
+ if(params.find(*q) == params.end())
+ {
+ map<string, string>::const_iterator r = defaults.find(*q);
+ if(r == defaults.end())
+ {
+ missingParams.insert(*q);
+ }
+ else
+ {
+ params.insert(make_pair(r->first, resolve(r->second, "default parameter `" + r->first + "'")));
+ }
+ }
}
if(!missingParams.empty())
{
- ostringstream os;
- os << "undefined parameters when instantiating `" + tmpl + "' template: ";
- copy(missingParams.begin(), missingParams.end(), ostream_iterator<string>(os, " "));
- resolve.exception(os.str());
+ ostringstream os;
+ os << "undefined parameters when instantiating `" + tmpl + "' template: ";
+ copy(missingParams.begin(), missingParams.end(), ostream_iterator<string>(os, " "));
+ resolve.exception(os.str());
}
return params;
@@ -1693,12 +1693,12 @@ ServiceInstanceHelper::ServiceInstanceHelper(const ServiceInstanceDescriptor& de
//
if(_def._cpp_template.empty() && !_def.descriptor)
{
- throw DeploymentException("invalid service instance: no template defined");
+ throw DeploymentException("invalid service instance: no template defined");
}
if(_def.descriptor)
{
- _service = ServiceHelper(_def.descriptor);
+ _service = ServiceHelper(_def.descriptor);
}
}
@@ -1707,13 +1707,13 @@ ServiceInstanceHelper::operator==(const ServiceInstanceHelper& helper) const
{
if(_def._cpp_template.empty())
{
- return _service == helper._service;
+ return _service == helper._service;
}
else
{
- return _def._cpp_template == helper._def._cpp_template &&
- _def.parameterValues == helper._def.parameterValues &&
- _def.propertySet == helper._def.propertySet;
+ return _def._cpp_template == helper._def._cpp_template &&
+ _def.parameterValues == helper._def.parameterValues &&
+ _def.propertySet == helper._def.propertySet;
}
}
@@ -1730,14 +1730,14 @@ ServiceInstanceHelper::instantiate(const Resolver& resolve, const PropertySetDes
std::map<std::string, std::string> parameterValues;
if(!def.getDescriptor())
{
- assert(!_def._cpp_template.empty());
- TemplateDescriptor tmpl = resolve.getServiceTemplate(_def._cpp_template);
- def = ServiceHelper(ServiceDescriptorPtr::dynamicCast(tmpl.descriptor));
- parameterValues = instantiateParams(resolve,
- _def._cpp_template,
- _def.parameterValues,
- tmpl.parameters,
- tmpl.parameterDefaults);
+ assert(!_def._cpp_template.empty());
+ TemplateDescriptor tmpl = resolve.getServiceTemplate(_def._cpp_template);
+ def = ServiceHelper(ServiceDescriptorPtr::dynamicCast(tmpl.descriptor));
+ parameterValues = instantiateParams(resolve,
+ _def._cpp_template,
+ _def.parameterValues,
+ tmpl.parameters,
+ tmpl.parameterDefaults);
}
//
@@ -1776,36 +1776,36 @@ ServiceInstanceHelper::print(const Ice::CommunicatorPtr& communicator, Output& o
{
if(_service.getDescriptor())
{
- _service.print(communicator, out);
+ _service.print(communicator, out);
}
else
{
- assert(!_def._cpp_template.empty());
- out << "service instance";
- out << sb;
- out << nl << "template = `" << _def._cpp_template << "'";
- out << nl << "parameters";
- out << sb;
- for(StringStringDict::const_iterator p = _def.parameterValues.begin(); p != _def.parameterValues.end(); ++p)
- {
- out << nl << p->first << " = `" << p->second << "'";
- }
- out << eb;
- out << eb;
+ assert(!_def._cpp_template.empty());
+ out << "service instance";
+ out << sb;
+ out << nl << "template = `" << _def._cpp_template << "'";
+ out << nl << "parameters";
+ out << sb;
+ for(StringStringDict::const_iterator p = _def.parameterValues.begin(); p != _def.parameterValues.end(); ++p)
+ {
+ out << nl << p->first << " = `" << p->second << "'";
+ }
+ out << eb;
+ out << eb;
}
}
ServerInstanceHelper::ServerInstanceHelper(const ServerInstanceDescriptor& desc,
- const Resolver& resolve,
- bool instantiate) :
+ const Resolver& resolve,
+ bool instantiate) :
_def(desc)
{
init(0, resolve, instantiate);
}
ServerInstanceHelper::ServerInstanceHelper(const ServerDescriptorPtr& definition,
- const Resolver& resolve,
- bool instantiate) :
+ const Resolver& resolve,
+ bool instantiate) :
_def(ServerInstanceDescriptor())
{
init(definition, resolve, instantiate);
@@ -1821,21 +1821,21 @@ ServerInstanceHelper::init(const ServerDescriptorPtr& definition, const Resolver
std::map<std::string, std::string> parameterValues;
if(!def)
{
- if(_def._cpp_template.empty())
- {
- resolve.exception("invalid server instance: template is not defined");
- }
-
- //
- // Get the server definition and the template property sets.
- //
- TemplateDescriptor tmpl = resolve.getServerTemplate(_def._cpp_template);
- def = ServerDescriptorPtr::dynamicCast(tmpl.descriptor);
- parameterValues = instantiateParams(resolve,
- _def._cpp_template,
- _def.parameterValues,
- tmpl.parameters,
- tmpl.parameterDefaults);
+ if(_def._cpp_template.empty())
+ {
+ resolve.exception("invalid server instance: template is not defined");
+ }
+
+ //
+ // Get the server definition and the template property sets.
+ //
+ TemplateDescriptor tmpl = resolve.getServerTemplate(_def._cpp_template);
+ def = ServerDescriptorPtr::dynamicCast(tmpl.descriptor);
+ parameterValues = instantiateParams(resolve,
+ _def._cpp_template,
+ _def.parameterValues,
+ tmpl.parameters,
+ tmpl.parameterDefaults);
}
assert(def);
@@ -1854,7 +1854,7 @@ ServerInstanceHelper::init(const ServerDescriptorPtr& definition, const Resolver
if(!instantiate)
{
- return; // We're done.
+ return; // We're done.
}
//
@@ -1863,30 +1863,30 @@ ServerInstanceHelper::init(const ServerDescriptorPtr& definition, const Resolver
//
if(svrResolve(def->activation, "server activation", true) == "session")
{
- svrResolve.addIgnored("session.id");
+ svrResolve.addIgnored("session.id");
}
-
+
//
// Instantiate the server instance definition (we use the server
// resolver above, so using parameters in properties is possible).
//
if(!_def._cpp_template.empty())
{
- _instance._cpp_template = _def._cpp_template;
- _instance.parameterValues = parameterValues;
- _instance.propertySet = svrResolve(_def.propertySet);
- for(PropertySetDescriptorDict::const_iterator p = _def.servicePropertySets.begin();
- p != _def.servicePropertySets.end(); ++p)
- {
- _instance.servicePropertySets.insert(make_pair(svrResolve(p->first), svrResolve(p->second)));
- }
+ _instance._cpp_template = _def._cpp_template;
+ _instance.parameterValues = parameterValues;
+ _instance.propertySet = svrResolve(_def.propertySet);
+ for(PropertySetDescriptorDict::const_iterator p = _def.servicePropertySets.begin();
+ p != _def.servicePropertySets.end(); ++p)
+ {
+ _instance.servicePropertySets.insert(make_pair(svrResolve(p->first), svrResolve(p->second)));
+ }
}
//
// Instantiate the server definition.
//
ServerDescriptorPtr inst = _serverDefinition->instantiate(svrResolve, _instance.propertySet.properties,
- _instance.servicePropertySets);
+ _instance.servicePropertySets);
_serverInstance = createHelper(inst);
}
@@ -1895,14 +1895,14 @@ ServerInstanceHelper::operator==(const ServerInstanceHelper& helper) const
{
if(_def._cpp_template.empty())
{
- return *_serverDefinition == *helper._serverDefinition;
+ return *_serverDefinition == *helper._serverDefinition;
}
else
{
- return _def._cpp_template == helper._def._cpp_template &&
- _def.parameterValues == helper._def.parameterValues &&
- _def.propertySet == helper._def.propertySet &&
- _def.servicePropertySets == helper._def.servicePropertySets;
+ return _def._cpp_template == helper._def._cpp_template &&
+ _def.parameterValues == helper._def.parameterValues &&
+ _def.propertySet == helper._def.propertySet &&
+ _def.servicePropertySets == helper._def.servicePropertySets;
}
}
@@ -1954,16 +1954,16 @@ ServerInstanceHelper::getIds(multiset<string>& adapterIds, multiset<Ice::Identit
}
NodeHelper::NodeHelper(const string& name,
- const NodeDescriptor& descriptor,
- const Resolver& appResolve,
- bool instantiate) :
+ const NodeDescriptor& descriptor,
+ const Resolver& appResolve,
+ bool instantiate) :
_name(name),
_def(descriptor),
_instantiated(instantiate)
{
if(_name.empty())
{
- appResolve.exception("invalid node: empty name");
+ appResolve.exception("invalid node: empty name");
}
Resolver resolve(appResolve, _def.variables, false);
@@ -1972,48 +1972,48 @@ NodeHelper::NodeHelper(const string& name,
if(instantiate)
{
- //
- // Instantiate the node definition.
- //
- _instance.variables = _def.variables;
- _instance.loadFactor = resolve.asFloat(_def.loadFactor, "load factor");
- _instance.description = resolve(_def.description, "description");
- _instance.propertySets = resolve(_def.propertySets);
+ //
+ // Instantiate the node definition.
+ //
+ _instance.variables = _def.variables;
+ _instance.loadFactor = resolve.asFloat(_def.loadFactor, "load factor");
+ _instance.description = resolve(_def.description, "description");
+ _instance.propertySets = resolve(_def.propertySets);
- //
- // Set the named property sets on the resolver. We use the
- // instantiated named property sets here -- named property sets
- // must be fully definied at the node level.
- //
- resolve.addPropertySets(_instance.propertySets);
+ //
+ // Set the named property sets on the resolver. We use the
+ // instantiated named property sets here -- named property sets
+ // must be fully definied at the node level.
+ //
+ resolve.addPropertySets(_instance.propertySets);
}
ServerInstanceDescriptorSeq::const_iterator p;
for(p = _def.serverInstances.begin(); p != _def.serverInstances.end(); ++p)
{
- ServerInstanceHelper helper(*p, resolve, instantiate);
- if(!_serverInstances.insert(make_pair(helper.getId(), helper)).second)
- {
- resolve.exception("duplicate server `" + helper.getId() + "' in node `" + _name + "'");
- }
- if(instantiate)
- {
- _instance.serverInstances.push_back(helper.getInstance());
- }
+ ServerInstanceHelper helper(*p, resolve, instantiate);
+ if(!_serverInstances.insert(make_pair(helper.getId(), helper)).second)
+ {
+ resolve.exception("duplicate server `" + helper.getId() + "' in node `" + _name + "'");
+ }
+ if(instantiate)
+ {
+ _instance.serverInstances.push_back(helper.getInstance());
+ }
}
ServerDescriptorSeq::const_iterator q;
for(q = _def.servers.begin(); q != _def.servers.end(); ++q)
{
- ServerInstanceHelper helper(*q, resolve, instantiate);
- if(!_servers.insert(make_pair(helper.getId(), helper)).second)
- {
- resolve.exception("duplicate server `" + helper.getId() + "' in node `" + _name + "'");
- }
- if(instantiate)
- {
- _instance.servers.push_back(helper.getServerInstance());
- }
+ ServerInstanceHelper helper(*q, resolve, instantiate);
+ if(!_servers.insert(make_pair(helper.getId(), helper)).second)
+ {
+ resolve.exception("duplicate server `" + helper.getId() + "' in node `" + _name + "'");
+ }
+ if(instantiate)
+ {
+ _instance.servers.push_back(helper.getServerInstance());
+ }
}
}
@@ -2022,32 +2022,32 @@ NodeHelper::operator==(const NodeHelper& helper) const
{
if(_def.variables != helper._def.variables)
{
- return false;
+ return false;
}
if(_serverInstances != helper._serverInstances)
{
- return false;
+ return false;
}
if(_servers != helper._servers)
{
- return false;
+ return false;
}
if(_def.loadFactor != helper._def.loadFactor)
{
- return false;
+ return false;
}
if(_def.description != helper._def.description)
{
- return false;
+ return false;
}
if(_def.propertySets != helper._def.propertySets)
{
- return false;
+ return false;
}
return true;
@@ -2069,12 +2069,12 @@ NodeHelper::diff(const NodeHelper& helper) const
update.name = _name;
if(_def.loadFactor != helper._def.loadFactor)
{
- update.loadFactor = new BoxedString(_def.loadFactor);
+ update.loadFactor = new BoxedString(_def.loadFactor);
}
if(_def.description != helper._def.description)
{
- update.description = new BoxedString(_def.description);
+ update.description = new BoxedString(_def.description);
}
update.variables = getDictUpdatedElts(helper._def.variables, _def.variables);
@@ -2086,14 +2086,14 @@ NodeHelper::diff(const NodeHelper& helper) const
ServerInstanceHelperDict updated = getDictUpdatedElts(helper._serverInstances, _serverInstances);
for(ServerInstanceHelperDict::const_iterator p = updated.begin(); p != updated.end(); ++p)
{
- update.serverInstances.push_back(p->second.getDefinition());
+ update.serverInstances.push_back(p->second.getDefinition());
}
update.removeServers = getDictRemovedElts(helper._serverInstances, _serverInstances);
updated = getDictUpdatedElts(helper._servers, _servers);
for(ServerInstanceHelperDict::const_iterator q = updated.begin(); q != updated.end(); ++q)
{
- update.servers.push_back(q->second.getServerDefinition());
+ update.servers.push_back(q->second.getServerDefinition());
}
Ice::StringSeq removed = getDictRemovedElts(helper._servers, _servers);
update.removeServers.insert(update.removeServers.end(), removed.begin(), removed.end());
@@ -2137,63 +2137,63 @@ NodeHelper::update(const NodeUpdateDescriptor& update, const Resolver& appResolv
ServerInstanceDescriptorSeq::const_iterator q;
for(q = update.serverInstances.begin(); q != update.serverInstances.end(); ++q)
{
- ServerInstanceHelper helper(*q, resolve, false);
- if(!added.insert(helper.getId()).second)
- {
- resolve.exception("duplicate server `" + helper.getId() + "' in node `" + _name + "'");
- }
- def.serverInstances.push_back(helper.getDefinition());
+ ServerInstanceHelper helper(*q, resolve, false);
+ if(!added.insert(helper.getId()).second)
+ {
+ resolve.exception("duplicate server `" + helper.getId() + "' in node `" + _name + "'");
+ }
+ def.serverInstances.push_back(helper.getDefinition());
}
for(r = _serverInstances.begin(); r != _serverInstances.end(); ++r)
{
- if(removed.find(r->first) != removed.end() || added.find(r->first) != added.end())
- {
- continue;
- }
-
- //
- // Re-instantiate the server. Make sure the server ID didn't
- // change, if the ID of a server changes the update descriptor
- // has to remove the server and add an update entry for it.
- //
- ServerInstanceHelper helper(r->second.getDefinition(), resolve, false);
- if(helper.getId() != r->first)
- {
- resolve.exception("invalid update in node `" + _name + "':\n" + "server instance id `" + r->first +
- "' changed to `" + helper.getId() + "'");
- }
- def.serverInstances.push_back(helper.getDefinition());
+ if(removed.find(r->first) != removed.end() || added.find(r->first) != added.end())
+ {
+ continue;
+ }
+
+ //
+ // Re-instantiate the server. Make sure the server ID didn't
+ // change, if the ID of a server changes the update descriptor
+ // has to remove the server and add an update entry for it.
+ //
+ ServerInstanceHelper helper(r->second.getDefinition(), resolve, false);
+ if(helper.getId() != r->first)
+ {
+ resolve.exception("invalid update in node `" + _name + "':\n" + "server instance id `" + r->first +
+ "' changed to `" + helper.getId() + "'");
+ }
+ def.serverInstances.push_back(helper.getDefinition());
}
added.clear();
for(ServerDescriptorSeq::const_iterator s = update.servers.begin(); s != update.servers.end(); ++s)
{
- ServerInstanceHelper helper(*s, resolve, false);
- if(!added.insert(helper.getId()).second)
- {
- resolve.exception("duplicate server `" + helper.getId() + "' in node `" + _name + "'");
- }
- def.servers.push_back(helper.getServerDefinition());
+ ServerInstanceHelper helper(*s, resolve, false);
+ if(!added.insert(helper.getId()).second)
+ {
+ resolve.exception("duplicate server `" + helper.getId() + "' in node `" + _name + "'");
+ }
+ def.servers.push_back(helper.getServerDefinition());
}
for(r = _servers.begin(); r != _servers.end(); ++r)
{
- if(removed.find(r->first) != removed.end() || added.find(r->first) != added.end())
- {
- continue;
- }
-
- //
- // Re-instantiate the server. Make sure the server ID didn't
- // change, if the ID of a server changes the update descriptor
- // has to remove the server and add an update entry for it.
- //
- ServerInstanceHelper helper(r->second.getServerDefinition(), resolve, false);
- if(helper.getId() != r->first)
- {
- resolve.exception("invalid update in node `" + _name + "':\nserver instance id `" + r->first +
- "' changed to `" + helper.getId() + "'");
- }
- def.servers.push_back(helper.getServerDefinition());
+ if(removed.find(r->first) != removed.end() || added.find(r->first) != added.end())
+ {
+ continue;
+ }
+
+ //
+ // Re-instantiate the server. Make sure the server ID didn't
+ // change, if the ID of a server changes the update descriptor
+ // has to remove the server and add an update entry for it.
+ //
+ ServerInstanceHelper helper(r->second.getServerDefinition(), resolve, false);
+ if(helper.getId() != r->first)
+ {
+ resolve.exception("invalid update in node `" + _name + "':\nserver instance id `" + r->first +
+ "' changed to `" + helper.getId() + "'");
+ }
+ def.servers.push_back(helper.getServerDefinition());
}
return def;
}
@@ -2206,12 +2206,12 @@ NodeHelper::upgrade(NodeDescriptor& desc) const
bool upgraded = false;
for(ServerDescriptorSeq::iterator j = desc.servers.begin(); j != desc.servers.end(); ++j)
{
- CommunicatorDescriptorPtr com;
- if(createHelper(*j)->upgrade(com))
- {
- *j = ServerDescriptorPtr::dynamicCast(com);
- upgraded = true;
- }
+ CommunicatorDescriptorPtr com;
+ if(createHelper(*j)->upgrade(com))
+ {
+ *j = ServerDescriptorPtr::dynamicCast(com);
+ upgraded = true;
+ }
}
return upgraded;
@@ -2224,13 +2224,13 @@ NodeHelper::getIds(multiset<string>& serverIds, multiset<string>& adapterIds, mu
ServerInstanceHelperDict::const_iterator p;
for(p = _serverInstances.begin(); p != _serverInstances.end(); ++p)
{
- serverIds.insert(p->first);
- p->second.getIds(adapterIds, objectIds);
+ serverIds.insert(p->first);
+ p->second.getIds(adapterIds, objectIds);
}
for(p = _servers.begin(); p != _servers.end(); ++p)
{
- serverIds.insert(p->first);
- p->second.getIds(adapterIds, objectIds);
+ serverIds.insert(p->first);
+ p->second.getIds(adapterIds, objectIds);
}
}
@@ -2255,23 +2255,23 @@ NodeHelper::getServerInfos(const string& app, const string& uuid, int revision,
ServerInstanceHelperDict::const_iterator p;
for(p = _serverInstances.begin(); p != _serverInstances.end(); ++p)
{
- ServerInfo info;
- info.node = _name;
- info.application = app;
- info.uuid = uuid;
- info.revision = revision;
- info.descriptor = p->second.getServerInstance();
- servers.insert(make_pair(p->second.getId(), info));
+ ServerInfo info;
+ info.node = _name;
+ info.application = app;
+ info.uuid = uuid;
+ info.revision = revision;
+ info.descriptor = p->second.getServerInstance();
+ servers.insert(make_pair(p->second.getId(), info));
}
for(p = _servers.begin(); p != _servers.end(); ++p)
{
- ServerInfo info;
- info.node = _name;
- info.application = app;
- info.uuid = uuid;
- info.revision = revision;
- info.descriptor = p->second.getServerInstance();
- servers.insert(make_pair(p->second.getId(), info));
+ ServerInfo info;
+ info.node = _name;
+ info.application = app;
+ info.uuid = uuid;
+ info.revision = revision;
+ info.descriptor = p->second.getServerInstance();
+ servers.insert(make_pair(p->second.getId(), info));
}
}
@@ -2285,38 +2285,38 @@ NodeHelper::hasDistributions(const string& server) const
//
if(server.empty())
{
- ServerInstanceHelperDict::const_iterator p;
- for(p = _serverInstances.begin(); p != _serverInstances.end(); ++p)
- {
- if(!p->second.getServerInstance()->distrib.icepatch.empty())
- {
- return true;
- }
- }
- for(p = _servers.begin(); p != _servers.end(); ++p)
- {
- if(!p->second.getServerInstance()->distrib.icepatch.empty())
- {
- return true;
- }
- }
+ ServerInstanceHelperDict::const_iterator p;
+ for(p = _serverInstances.begin(); p != _serverInstances.end(); ++p)
+ {
+ if(!p->second.getServerInstance()->distrib.icepatch.empty())
+ {
+ return true;
+ }
+ }
+ for(p = _servers.begin(); p != _servers.end(); ++p)
+ {
+ if(!p->second.getServerInstance()->distrib.icepatch.empty())
+ {
+ return true;
+ }
+ }
}
else
{
- ServerInstanceHelperDict::const_iterator p = _serverInstances.find(server);
- if(p == _serverInstances.end())
- {
- p = _servers.find(server);
- if(p == _servers.end())
- {
- return false;
- }
- }
+ ServerInstanceHelperDict::const_iterator p = _serverInstances.find(server);
+ if(p == _serverInstances.end())
+ {
+ p = _servers.find(server);
+ if(p == _servers.end())
+ {
+ return false;
+ }
+ }
- if(!p->second.getServerInstance()->distrib.icepatch.empty())
- {
- return true;
- }
+ if(!p->second.getServerInstance()->distrib.icepatch.empty())
+ {
+ return true;
+ }
}
return false;
@@ -2343,45 +2343,45 @@ NodeHelper::print(Output& out) const
out << sb;
if(!_instance.loadFactor.empty())
{
- out << nl << "load factor = `" << _instance.loadFactor << "'";
+ out << nl << "load factor = `" << _instance.loadFactor << "'";
}
if(!_instance.description.empty())
{
- out << nl << "description = `" << _instance.description << "'";
+ out << nl << "description = `" << _instance.description << "'";
}
if(!_instance.variables.empty())
{
- out << nl << "variables";
- out << sb;
- for(StringStringDict::const_iterator q = _instance.variables.begin(); q != _instance.variables.end(); ++q)
- {
- out << nl << q->first << " = `" << q->second << "'";
- }
- out << eb;
+ out << nl << "variables";
+ out << sb;
+ for(StringStringDict::const_iterator q = _instance.variables.begin(); q != _instance.variables.end(); ++q)
+ {
+ out << nl << q->first << " = `" << q->second << "'";
+ }
+ out << eb;
}
if(!_instance.propertySets.empty())
{
- PropertySetDescriptorDict::const_iterator q;
- for(q = _instance.propertySets.begin(); q != _instance.propertySets.end(); ++q)
- {
- out << nl << "properties `" << q->first << "'";
- out << sb;
- if(!q->second.references.empty())
- {
- out << nl << "references = " << toString(q->second.references);
- }
- PropertyDescriptorSeq::const_iterator r;
- for(r = q->second.properties.begin(); r != q->second.properties.end(); ++r)
- {
- out << nl << r->name << " = `" << r->value << "'";
- }
- out << eb;
- }
+ PropertySetDescriptorDict::const_iterator q;
+ for(q = _instance.propertySets.begin(); q != _instance.propertySets.end(); ++q)
+ {
+ out << nl << "properties `" << q->first << "'";
+ out << sb;
+ if(!q->second.references.empty())
+ {
+ out << nl << "references = " << toString(q->second.references);
+ }
+ PropertyDescriptorSeq::const_iterator r;
+ for(r = q->second.properties.begin(); r != q->second.properties.end(); ++r)
+ {
+ out << nl << r->name << " = `" << r->value << "'";
+ }
+ out << eb;
+ }
}
if(_serverInstances.empty() && _servers.empty())
{
- return;
+ return;
}
out << nl << "servers";
@@ -2389,11 +2389,11 @@ NodeHelper::print(Output& out) const
ServerInstanceHelperDict::const_iterator p;
for(p = _serverInstances.begin(); p != _serverInstances.end(); ++p)
{
- out << nl << p->first;
+ out << nl << p->first;
}
for(p = _servers.begin(); p != _servers.end(); ++p)
{
- out << nl << p->first;
+ out << nl << p->first;
}
out << eb;
out << eb;
@@ -2428,7 +2428,7 @@ NodeHelper::printDiff(Output& out, const NodeHelper& helper) const
_def.loadFactor == helper._def.loadFactor &&
_def.description == helper._def.description)
{
- return;
+ return;
}
//
@@ -2440,116 +2440,116 @@ NodeHelper::printDiff(Output& out, const NodeHelper& helper) const
if(_def.loadFactor != helper._def.loadFactor)
{
- out << nl << "load factor udpated";
+ out << nl << "load factor udpated";
}
if(_def.description != helper._def.description)
{
- out << nl << "description udpated";
+ out << nl << "description udpated";
}
if(!updatedPs.empty() || !removedPs.empty())
{
- out << nl << "property sets udpated";
+ out << nl << "property sets udpated";
}
if(!variables.empty() || !removeVariables.empty())
{
- out << nl << "variables udpated";
+ out << nl << "variables udpated";
}
if(!updated.empty() || !removed.empty())
{
- out << nl << "servers";
- out << sb;
- ServerInstanceHelperDict::const_iterator p;
- for(p = updated.begin(); p != updated.end(); ++p)
- {
- if(helper._serverInstances.find(p->first) == helper._serverInstances.end() &&
- helper._servers.find(p->first) == helper._servers.end())
- {
- out << nl << "server `" << p->first << "' added";
- }
- }
- for(p = updated.begin(); p != updated.end(); ++p)
- {
- if(helper._serverInstances.find(p->first) != helper._serverInstances.end() ||
- helper._servers.find(p->first) != helper._servers.end())
- {
- out << nl << "server `" << p->first << "' updated";
- }
- }
- for(Ice::StringSeq::const_iterator q = removed.begin(); q != removed.end(); ++q)
- {
- out << nl << "server `" << *q << "' removed";
- }
- out << eb;
+ out << nl << "servers";
+ out << sb;
+ ServerInstanceHelperDict::const_iterator p;
+ for(p = updated.begin(); p != updated.end(); ++p)
+ {
+ if(helper._serverInstances.find(p->first) == helper._serverInstances.end() &&
+ helper._servers.find(p->first) == helper._servers.end())
+ {
+ out << nl << "server `" << p->first << "' added";
+ }
+ }
+ for(p = updated.begin(); p != updated.end(); ++p)
+ {
+ if(helper._serverInstances.find(p->first) != helper._serverInstances.end() ||
+ helper._servers.find(p->first) != helper._servers.end())
+ {
+ out << nl << "server `" << p->first << "' updated";
+ }
+ }
+ for(Ice::StringSeq::const_iterator q = removed.begin(); q != removed.end(); ++q)
+ {
+ out << nl << "server `" << *q << "' removed";
+ }
+ out << eb;
}
out << eb;
}
ApplicationHelper::ApplicationHelper(const Ice::CommunicatorPtr& communicator,
- const ApplicationDescriptor& desc,
- bool enableWarning,
- bool instantiate) :
+ const ApplicationDescriptor& desc,
+ bool enableWarning,
+ bool instantiate) :
_communicator(communicator),
_def(desc)
{
if(_def.name.empty())
{
- throw DeploymentException("invalid application: empty name");
+ throw DeploymentException("invalid application: empty name");
}
Resolver resolve(_def, communicator, enableWarning);
if(instantiate)
{
- //
- // Instantiate the application definition.
- //
- _instance.name = _def.name;
- _instance.variables = _def.variables;
- _instance.serverTemplates = _def.serverTemplates;
- _instance.serviceTemplates = _def.serviceTemplates;
- _instance.description = resolve(_def.description, "description");
- _instance.distrib = resolve(_def.distrib);
- _instance.propertySets = resolve(_def.propertySets);
-
- for(ReplicaGroupDescriptorSeq::iterator r = _def.replicaGroups.begin(); r != _def.replicaGroups.end(); ++r)
- {
- ReplicaGroupDescriptor desc;
- desc.id = resolve.asId(r->id, "replica group id", false);
- desc.description = resolve(r->description, "replica group description");
- desc.objects = resolve(r->objects, "replica group well-known");
- if(!r->loadBalancing)
- {
- resolve.exception("replica group load balancing is not set");
- }
- desc.loadBalancing = LoadBalancingPolicyPtr::dynamicCast(r->loadBalancing->ice_clone());
- desc.loadBalancing->nReplicas =
- resolve.asInt(r->loadBalancing->nReplicas, "replica group number of replicas");
- if(desc.loadBalancing->nReplicas.empty())
- {
- resolve.exception("invalid replica group load balancing number of replicas value: empty value");
- }
- else if(desc.loadBalancing->nReplicas[0] == '-')
- {
- resolve.exception("invalid replica group load balancing number of replicas value: inferior to 0");
- }
- AdaptiveLoadBalancingPolicyPtr al = AdaptiveLoadBalancingPolicyPtr::dynamicCast(desc.loadBalancing);
- if(al)
- {
- al->loadSample = resolve(al->loadSample, "replica group load sample");
- if(al->loadSample != "" && al->loadSample != "1" && al->loadSample != "5" && al->loadSample != "15")
- {
- resolve.exception("invalid load sample value (allowed values are 1, 5 or 15)");
- }
- }
- _instance.replicaGroups.push_back(desc);
- }
-
- //
- // Set the named property sets on the resolver. We use the
- // instantiated named property sets here -- named property sets
- // must be fully definied at the application level.
- //
- resolve.addPropertySets(_instance.propertySets);
+ //
+ // Instantiate the application definition.
+ //
+ _instance.name = _def.name;
+ _instance.variables = _def.variables;
+ _instance.serverTemplates = _def.serverTemplates;
+ _instance.serviceTemplates = _def.serviceTemplates;
+ _instance.description = resolve(_def.description, "description");
+ _instance.distrib = resolve(_def.distrib);
+ _instance.propertySets = resolve(_def.propertySets);
+
+ for(ReplicaGroupDescriptorSeq::iterator r = _def.replicaGroups.begin(); r != _def.replicaGroups.end(); ++r)
+ {
+ ReplicaGroupDescriptor desc;
+ desc.id = resolve.asId(r->id, "replica group id", false);
+ desc.description = resolve(r->description, "replica group description");
+ desc.objects = resolve(r->objects, "replica group well-known");
+ if(!r->loadBalancing)
+ {
+ resolve.exception("replica group load balancing is not set");
+ }
+ desc.loadBalancing = LoadBalancingPolicyPtr::dynamicCast(r->loadBalancing->ice_clone());
+ desc.loadBalancing->nReplicas =
+ resolve.asInt(r->loadBalancing->nReplicas, "replica group number of replicas");
+ if(desc.loadBalancing->nReplicas.empty())
+ {
+ resolve.exception("invalid replica group load balancing number of replicas value: empty value");
+ }
+ else if(desc.loadBalancing->nReplicas[0] == '-')
+ {
+ resolve.exception("invalid replica group load balancing number of replicas value: inferior to 0");
+ }
+ AdaptiveLoadBalancingPolicyPtr al = AdaptiveLoadBalancingPolicyPtr::dynamicCast(desc.loadBalancing);
+ if(al)
+ {
+ al->loadSample = resolve(al->loadSample, "replica group load sample");
+ if(al->loadSample != "" && al->loadSample != "1" && al->loadSample != "5" && al->loadSample != "15")
+ {
+ resolve.exception("invalid load sample value (allowed values are 1, 5 or 15)");
+ }
+ }
+ _instance.replicaGroups.push_back(desc);
+ }
+
+ //
+ // Set the named property sets on the resolver. We use the
+ // instantiated named property sets here -- named property sets
+ // must be fully definied at the application level.
+ //
+ resolve.addPropertySets(_instance.propertySets);
}
//
@@ -2558,11 +2558,11 @@ ApplicationHelper::ApplicationHelper(const Ice::CommunicatorPtr& communicator,
NodeHelperDict::const_iterator n;
for(NodeDescriptorDict::const_iterator p = _def.nodes.begin(); p != _def.nodes.end(); ++p)
{
- n = _nodes.insert(make_pair(p->first, NodeHelper(p->first, p->second, resolve, instantiate))).first;
- if(instantiate)
- {
- _instance.nodes.insert(make_pair(n->first, n->second.getInstance()));
- }
+ n = _nodes.insert(make_pair(p->first, NodeHelper(p->first, p->second, resolve, instantiate))).first;
+ if(instantiate)
+ {
+ _instance.nodes.insert(make_pair(n->first, n->second.getInstance()));
+ }
}
//
@@ -2571,52 +2571,52 @@ ApplicationHelper::ApplicationHelper(const Ice::CommunicatorPtr& communicator,
//
if(instantiate)
{
- multiset<string> serverIds;
- multiset<string> adapterIds;
- multiset<Ice::Identity> objectIds;
- for(n = _nodes.begin(); n != _nodes.end(); ++n)
- {
- n->second.getIds(serverIds, adapterIds, objectIds);
- }
-
- for(ReplicaGroupDescriptorSeq::iterator r = _def.replicaGroups.begin(); r != _def.replicaGroups.end(); ++r)
- {
- if(r->id.empty())
- {
- throw DeploymentException("replica group id is empty");
- }
- if(adapterIds.find(r->id) != adapterIds.end())
- {
- throw DeploymentException("duplicate replica group `" + r->id + "'");
- }
- adapterIds.insert(r->id);
- for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
- {
- objectIds.insert(o->id);
- }
- }
-
- for(multiset<string>::const_iterator s = serverIds.begin(); s != serverIds.end(); ++s)
- {
- if(serverIds.count(*s) > 1)
- {
- resolve.exception("duplicate server `" + *s + "'");
- }
- }
- for(multiset<string>::const_iterator a = adapterIds.begin(); a != adapterIds.end(); ++a)
- {
- if(adapterIds.count(*a) > 1)
- {
- resolve.exception("duplicate adapter `" + *a + "'");
- }
- }
- for(multiset<Ice::Identity>::const_iterator o = objectIds.begin(); o != objectIds.end(); ++o)
- {
- if(objectIds.count(*o) > 1)
- {
- resolve.exception("duplicate object `" + _communicator->identityToString(*o) + "'");
- }
- }
+ multiset<string> serverIds;
+ multiset<string> adapterIds;
+ multiset<Ice::Identity> objectIds;
+ for(n = _nodes.begin(); n != _nodes.end(); ++n)
+ {
+ n->second.getIds(serverIds, adapterIds, objectIds);
+ }
+
+ for(ReplicaGroupDescriptorSeq::iterator r = _def.replicaGroups.begin(); r != _def.replicaGroups.end(); ++r)
+ {
+ if(r->id.empty())
+ {
+ throw DeploymentException("replica group id is empty");
+ }
+ if(adapterIds.find(r->id) != adapterIds.end())
+ {
+ throw DeploymentException("duplicate replica group `" + r->id + "'");
+ }
+ adapterIds.insert(r->id);
+ for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
+ {
+ objectIds.insert(o->id);
+ }
+ }
+
+ for(multiset<string>::const_iterator s = serverIds.begin(); s != serverIds.end(); ++s)
+ {
+ if(serverIds.count(*s) > 1)
+ {
+ resolve.exception("duplicate server `" + *s + "'");
+ }
+ }
+ for(multiset<string>::const_iterator a = adapterIds.begin(); a != adapterIds.end(); ++a)
+ {
+ if(adapterIds.count(*a) > 1)
+ {
+ resolve.exception("duplicate adapter `" + *a + "'");
+ }
+ }
+ for(multiset<Ice::Identity>::const_iterator o = objectIds.begin(); o != objectIds.end(); ++o)
+ {
+ if(objectIds.count(*o) > 1)
+ {
+ resolve.exception("duplicate object `" + _communicator->identityToString(*o) + "'");
+ }
+ }
}
}
@@ -2629,7 +2629,7 @@ ApplicationHelper::diff(const ApplicationHelper& helper) const
updt.name = _def.name;
if(_def.description != helper._def.description)
{
- updt.description = new BoxedString(_def.description);
+ updt.description = new BoxedString(_def.description);
}
updt.variables = getDictUpdatedElts(helper._def.variables, _def.variables);
@@ -2640,7 +2640,7 @@ ApplicationHelper::diff(const ApplicationHelper& helper) const
if(_def.distrib != helper._def.distrib)
{
- updt.distrib = new BoxedDistributionDescriptor(_def.distrib);
+ updt.distrib = new BoxedDistributionDescriptor(_def.distrib);
}
GetReplicaGroupId rk;
@@ -2657,23 +2657,23 @@ ApplicationHelper::diff(const ApplicationHelper& helper) const
NodeHelperDict updated = getDictUpdatedElts(helper._nodes, _nodes);
for(NodeHelperDict::const_iterator p = updated.begin(); p != updated.end(); ++p)
{
- NodeHelperDict::const_iterator q = helper._nodes.find(p->first);
- if(q == helper._nodes.end())
- {
- NodeUpdateDescriptor nodeUpdate;
- const NodeDescriptor& node = p->second.getDefinition();
- nodeUpdate.name = p->first;
- nodeUpdate.variables = node.variables;
- nodeUpdate.servers = node.servers;
- nodeUpdate.serverInstances = node.serverInstances;
- nodeUpdate.loadFactor = new BoxedString(node.loadFactor);
- nodeUpdate.description = new BoxedString(node.description);
- updt.nodes.push_back(nodeUpdate);
- }
- else
- {
- updt.nodes.push_back(p->second.diff(q->second));
- }
+ NodeHelperDict::const_iterator q = helper._nodes.find(p->first);
+ if(q == helper._nodes.end())
+ {
+ NodeUpdateDescriptor nodeUpdate;
+ const NodeDescriptor& node = p->second.getDefinition();
+ nodeUpdate.name = p->first;
+ nodeUpdate.variables = node.variables;
+ nodeUpdate.servers = node.servers;
+ nodeUpdate.serverInstances = node.serverInstances;
+ nodeUpdate.loadFactor = new BoxedString(node.loadFactor);
+ nodeUpdate.description = new BoxedString(node.description);
+ updt.nodes.push_back(nodeUpdate);
+ }
+ else
+ {
+ updt.nodes.push_back(p->second.diff(q->second));
+ }
}
updt.removeNodes = getDictRemovedElts(helper._nodes, _nodes);
@@ -2698,50 +2698,50 @@ ApplicationHelper::update(const ApplicationUpdateDescriptor& updt) const
Resolver resolve(def, _communicator, false); // A resolver based on the *updated* application descriptor.
for(NodeUpdateDescriptorSeq::const_iterator p = updt.nodes.begin(); p != updt.nodes.end(); ++p)
{
- NodeHelperDict::const_iterator q = _nodes.find(p->name);
- if(q != _nodes.end()) // Updated node
- {
- //
- // COMPILERBUG: AIX xlC (Visual Age 6, 64bit builds)
- // requires the `desc' temporary here. We can't do the
- // update call in the make_pair call directly (this
- // results in a SEGFAULT at runtime).
- //
- NodeDescriptor desc = q->second.update(*p, resolve);
- def.nodes.insert(make_pair(p->name, desc));
- }
- else // New node
- {
- NodeDescriptor desc;
- desc.variables = p->variables;
- if(!p->removeVariables.empty())
- {
- resolve.exception("can't remove variables for node `" + p->name + "': node doesn't exist");
- }
- desc.propertySets = p->propertySets;
- if(!p->removePropertySets.empty())
- {
- resolve.exception("can't remove property sets for node `" + p->name + "': node doesn't exist");
- }
- desc.servers = p->servers;
- desc.serverInstances = p->serverInstances;
- if(!p->removeServers.empty())
- {
- resolve.exception("can't remove servers for node `" + p->name + "': node doesn't exist");
- }
- desc.loadFactor = p->loadFactor ? p->loadFactor->value : string("");
- desc.description = p->description ? p->description->value : string("");
- def.nodes.insert(make_pair(p->name, desc));
- }
+ NodeHelperDict::const_iterator q = _nodes.find(p->name);
+ if(q != _nodes.end()) // Updated node
+ {
+ //
+ // COMPILERBUG: AIX xlC (Visual Age 6, 64bit builds)
+ // requires the `desc' temporary here. We can't do the
+ // update call in the make_pair call directly (this
+ // results in a SEGFAULT at runtime).
+ //
+ NodeDescriptor desc = q->second.update(*p, resolve);
+ def.nodes.insert(make_pair(p->name, desc));
+ }
+ else // New node
+ {
+ NodeDescriptor desc;
+ desc.variables = p->variables;
+ if(!p->removeVariables.empty())
+ {
+ resolve.exception("can't remove variables for node `" + p->name + "': node doesn't exist");
+ }
+ desc.propertySets = p->propertySets;
+ if(!p->removePropertySets.empty())
+ {
+ resolve.exception("can't remove property sets for node `" + p->name + "': node doesn't exist");
+ }
+ desc.servers = p->servers;
+ desc.serverInstances = p->serverInstances;
+ if(!p->removeServers.empty())
+ {
+ resolve.exception("can't remove servers for node `" + p->name + "': node doesn't exist");
+ }
+ desc.loadFactor = p->loadFactor ? p->loadFactor->value : string("");
+ desc.description = p->description ? p->description->value : string("");
+ def.nodes.insert(make_pair(p->name, desc));
+ }
}
set<string> removedNodes(updt.removeNodes.begin(), updt.removeNodes.end());
for(NodeHelperDict::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n)
{
- if(removedNodes.find(n->first) != removedNodes.end() || def.nodes.find(n->first) != def.nodes.end())
- {
- continue; // Node was removed or updated.
- }
- def.nodes.insert(make_pair(n->first, n->second.getDefinition()));
+ if(removedNodes.find(n->first) != removedNodes.end() || def.nodes.find(n->first) != def.nodes.end())
+ {
+ continue; // Node was removed or updated.
+ }
+ def.nodes.insert(make_pair(n->first, n->second.getDefinition()));
}
return def;
@@ -2754,24 +2754,24 @@ ApplicationHelper::upgrade(ApplicationDescriptor& desc) const
bool upgraded = false;
for(NodeHelperDict::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n)
{
- NodeDescriptor nodeDesc;
- if(n->second.upgrade(nodeDesc))
- {
- desc.nodes[n->first] = nodeDesc;
- upgraded = true;
- }
+ NodeDescriptor nodeDesc;
+ if(n->second.upgrade(nodeDesc))
+ {
+ desc.nodes[n->first] = nodeDesc;
+ upgraded = true;
+ }
}
TemplateDescriptorDict::iterator t;
for(t = desc.serverTemplates.begin(); t != desc.serverTemplates.end(); ++t)
{
- ServerDescriptorPtr desc = ServerDescriptorPtr::dynamicCast(t->second.descriptor);
- upgraded |= createHelper(desc)->upgrade(t->second.descriptor);
+ ServerDescriptorPtr desc = ServerDescriptorPtr::dynamicCast(t->second.descriptor);
+ upgraded |= createHelper(desc)->upgrade(t->second.descriptor);
}
for(t = desc.serviceTemplates.begin(); t != desc.serviceTemplates.end(); ++t)
{
- ServiceDescriptorPtr desc = ServiceDescriptorPtr::dynamicCast(t->second.descriptor);
- upgraded |= ServiceHelper(desc).upgrade(t->second.descriptor);
+ ServiceDescriptorPtr desc = ServiceDescriptorPtr::dynamicCast(t->second.descriptor);
+ upgraded |= ServiceHelper(desc).upgrade(t->second.descriptor);
}
return upgraded;
@@ -2790,13 +2790,13 @@ ApplicationHelper::instantiateServer(const string& node, const ServerInstanceDes
NodeDescriptorDict::iterator q = def.nodes.find(node);
if(q == def.nodes.end())
{
- NodeDescriptor desc;
- desc.serverInstances.push_back(instance);
- def.nodes.insert(make_pair(node, desc));
+ NodeDescriptor desc;
+ desc.serverInstances.push_back(instance);
+ def.nodes.insert(make_pair(node, desc));
}
else
{
- q->second.serverInstances.push_back(instance);
+ q->second.serverInstances.push_back(instance);
}
return def;
}
@@ -2810,16 +2810,16 @@ ApplicationHelper::getIds(set<string>& serverIds, set<string>& adapterIds, set<I
for(NodeHelperDict::const_iterator p = _nodes.begin(); p != _nodes.end(); ++p)
{
- p->second.getIds(sIds, aIds, oIds);
+ p->second.getIds(sIds, aIds, oIds);
}
ReplicaGroupDescriptorSeq::const_iterator r;
for(r = _def.replicaGroups.begin(); r != _def.replicaGroups.end(); ++r)
{
- aIds.insert(r->id);
- for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
- {
- oIds.insert(o->id);
- }
+ aIds.insert(r->id);
+ for(ObjectDescriptorSeq::const_iterator o = r->objects.begin(); o != r->objects.end(); ++o)
+ {
+ oIds.insert(o->id);
+ }
}
copy(sIds.begin(), sIds.end(), inserter(serverIds, serverIds.begin()));
@@ -2848,34 +2848,34 @@ ApplicationHelper::getServerInfos(const string& uuid, int revision) const
map<string, ServerInfo> servers;
for(NodeHelperDict::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n)
{
- n->second.getServerInfos(_def.name, uuid, revision, servers);
+ n->second.getServerInfos(_def.name, uuid, revision, servers);
}
return servers;
}
void
ApplicationHelper::getDistributions(DistributionDescriptor& distribution,
- vector<string>& nodes,
- const string& server) const
+ vector<string>& nodes,
+ const string& server) const
{
assert(!_instance.name.empty());
distribution = _instance.distrib;
for(NodeHelperDict::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n)
{
- if(n->second.hasDistributions(server))
- {
- nodes.push_back(n->first);
- if(!server.empty())
- {
- break;
- }
- }
- else if(!_instance.distrib.icepatch.empty() &&
- (server.empty() && n->second.hasServers() || n->second.hasServer(server)))
- {
- nodes.push_back(n->first);
- }
+ if(n->second.hasDistributions(server))
+ {
+ nodes.push_back(n->first);
+ if(!server.empty())
+ {
+ break;
+ }
+ }
+ else if(!_instance.distrib.icepatch.empty() &&
+ (server.empty() && n->second.hasServers() || n->second.hasServer(server)))
+ {
+ nodes.push_back(n->first);
+ }
}
}
@@ -2895,109 +2895,109 @@ ApplicationHelper::print(Output& out, const ApplicationInfo& info) const
if(!_instance.description.empty())
{
- out << nl << "description = `" << _instance.description << "'";
+ out << nl << "description = `" << _instance.description << "'";
}
if(!_instance.variables.empty())
{
- out << nl << "variables";
- out << sb;
- for(StringStringDict::const_iterator p = _instance.variables.begin(); p != _instance.variables.end();
- ++p)
- {
- out << nl << p->first << " = `" << p->second << "'";
- }
- out << eb;
+ out << nl << "variables";
+ out << sb;
+ for(StringStringDict::const_iterator p = _instance.variables.begin(); p != _instance.variables.end();
+ ++p)
+ {
+ out << nl << p->first << " = `" << p->second << "'";
+ }
+ out << eb;
}
if(!_instance.propertySets.empty())
{
- PropertySetDescriptorDict::const_iterator q;
- for(q = _instance.propertySets.begin(); q != _instance.propertySets.end(); ++q)
- {
- out << nl << "properties `" << q->first << "'";
- out << sb;
- if(!q->second.references.empty())
- {
- out << nl << "references = " << toString(q->second.references);
- }
- PropertyDescriptorSeq::const_iterator r;
- for(r = q->second.properties.begin(); r != q->second.properties.end(); ++r)
- {
- out << nl << r->name << " = `" << r->value << "'";
- }
- out << eb;
- }
+ PropertySetDescriptorDict::const_iterator q;
+ for(q = _instance.propertySets.begin(); q != _instance.propertySets.end(); ++q)
+ {
+ out << nl << "properties `" << q->first << "'";
+ out << sb;
+ if(!q->second.references.empty())
+ {
+ out << nl << "references = " << toString(q->second.references);
+ }
+ PropertyDescriptorSeq::const_iterator r;
+ for(r = q->second.properties.begin(); r != q->second.properties.end(); ++r)
+ {
+ out << nl << r->name << " = `" << r->value << "'";
+ }
+ out << eb;
+ }
}
if(!_instance.distrib.icepatch.empty())
{
- out << nl << "distribution";
- out << sb;
- out << nl << "proxy = `" << _instance.distrib.icepatch << "'";
- if(!_instance.distrib.directories.empty())
- {
- out << nl << "directories = `" << toString(_instance.distrib.directories) << "'";
- }
- out << eb;
+ out << nl << "distribution";
+ out << sb;
+ out << nl << "proxy = `" << _instance.distrib.icepatch << "'";
+ if(!_instance.distrib.directories.empty())
+ {
+ out << nl << "directories = `" << toString(_instance.distrib.directories) << "'";
+ }
+ out << eb;
}
if(!_instance.replicaGroups.empty())
{
- out << nl << "replica groups";
- out << sb;
- ReplicaGroupDescriptorSeq::const_iterator p;
- for(p = _instance.replicaGroups.begin(); p != _instance.replicaGroups.end(); ++p)
- {
- out << nl << "id = `" << p->id << "' load balancing = `";
- if(!p->loadBalancing)
- {
- out << "default (return all endpoints)";
- }
- else if(RandomLoadBalancingPolicyPtr::dynamicCast(p->loadBalancing))
- {
- out << "random";
- }
- else if(RoundRobinLoadBalancingPolicyPtr::dynamicCast(p->loadBalancing))
- {
- out << "round-robin";
- }
- else if(AdaptiveLoadBalancingPolicyPtr::dynamicCast(p->loadBalancing))
- {
- out << "adaptive" ;
- }
- else
- {
- out << "<unknown load balancing policy>";
- }
- out << "'";
- }
- out << eb;
+ out << nl << "replica groups";
+ out << sb;
+ ReplicaGroupDescriptorSeq::const_iterator p;
+ for(p = _instance.replicaGroups.begin(); p != _instance.replicaGroups.end(); ++p)
+ {
+ out << nl << "id = `" << p->id << "' load balancing = `";
+ if(!p->loadBalancing)
+ {
+ out << "default (return all endpoints)";
+ }
+ else if(RandomLoadBalancingPolicyPtr::dynamicCast(p->loadBalancing))
+ {
+ out << "random";
+ }
+ else if(RoundRobinLoadBalancingPolicyPtr::dynamicCast(p->loadBalancing))
+ {
+ out << "round-robin";
+ }
+ else if(AdaptiveLoadBalancingPolicyPtr::dynamicCast(p->loadBalancing))
+ {
+ out << "adaptive" ;
+ }
+ else
+ {
+ out << "<unknown load balancing policy>";
+ }
+ out << "'";
+ }
+ out << eb;
}
if(!_instance.serverTemplates.empty())
{
- out << nl << "server templates";
- out << sb;
- TemplateDescriptorDict::const_iterator p;
- for(p = _instance.serverTemplates.begin(); p != _instance.serverTemplates.end(); ++p)
- {
- out << nl << p->first;
- }
- out << eb;
+ out << nl << "server templates";
+ out << sb;
+ TemplateDescriptorDict::const_iterator p;
+ for(p = _instance.serverTemplates.begin(); p != _instance.serverTemplates.end(); ++p)
+ {
+ out << nl << p->first;
+ }
+ out << eb;
}
if(!_instance.serviceTemplates.empty())
{
- out << nl << "service templates";
- out << sb;
- TemplateDescriptorDict::const_iterator p;
- for(p = _instance.serviceTemplates.begin(); p != _instance.serviceTemplates.end(); ++p)
- {
- out << nl << p->first;
- }
- out << eb;
+ out << nl << "service templates";
+ out << sb;
+ TemplateDescriptorDict::const_iterator p;
+ for(p = _instance.serviceTemplates.begin(); p != _instance.serviceTemplates.end(); ++p)
+ {
+ out << nl << p->first;
+ }
+ out << eb;
}
if(!_nodes.empty())
{
- for(NodeHelperDict::const_iterator p = _nodes.begin(); p != _nodes.end(); ++p)
- {
- p->second.print(out);
- }
+ for(NodeHelperDict::const_iterator p = _nodes.begin(); p != _nodes.end(); ++p)
+ {
+ p->second.print(out);
+ }
}
out << eb;
}
@@ -3011,157 +3011,157 @@ ApplicationHelper::printDiff(Output& out, const ApplicationHelper& helper) const
out << sb;
{
- map<string, string> variables = getDictUpdatedElts(helper._def.variables, _def.variables);
- Ice::StringSeq removeVariables = getDictRemovedElts(helper._def.variables, _def.variables);
- if(!variables.empty() || !removeVariables.empty())
- {
- out << nl << "variables udpated";
- }
- }
- {
- if(_def.distrib != helper._def.distrib)
- {
- out << nl << "distribution updated";
- }
- }
- {
- PropertySetDescriptorDict updt = getDictUpdatedElts(helper._def.propertySets, _def.propertySets);
- Ice::StringSeq removed = getDictRemovedElts(helper._def.propertySets, _def.propertySets);
- if(!updt.empty() || !removed.empty())
- {
- out << nl << "property sets udpated";
- }
- }
- {
- GetReplicaGroupId rk;
- ReplicaGroupEq req;
- ReplicaGroupDescriptorSeq updated =
- getSeqUpdatedEltsWithEq(helper._def.replicaGroups, _def.replicaGroups, rk, req);
- Ice::StringSeq removed = getSeqRemovedElts(helper._def.replicaGroups, _def.replicaGroups, rk);
- if(!updated.empty() || !removed.empty())
- {
- out << nl << "replica groups";
- out << sb;
- ReplicaGroupDescriptorSeq::iterator p = updated.begin();
- while(p != updated.end())
- {
- ReplicaGroupDescriptorSeq::const_iterator r;
- for(r = helper._def.replicaGroups.begin(); r != helper._def.replicaGroups.end();
- ++r)
- {
- if(p->id == r->id)
- {
- out << nl << "replica group `" << r->id << "' updated";
- p = updated.erase(p);
- break;
- }
- }
- if(r == helper._def.replicaGroups.end())
- {
- ++p;
- }
- }
- for(p = updated.begin(); p != updated.end(); ++p)
- {
- out << nl << "replica group `" << p->id << "' added";
- }
- for(Ice::StringSeq::const_iterator q = removed.begin(); q != removed.end(); ++q)
- {
- out << nl << "replica group `" << *q << "' removed";
- }
- out << eb;
- }
- }
-
- {
- TemplateDescriptorEqual eq;
- TemplateDescriptorDict updated;
- updated = getDictUpdatedEltsWithEq(helper._def.serverTemplates, _def.serverTemplates, eq);
- Ice::StringSeq removed = getDictRemovedElts(helper._def.serverTemplates, _def.serverTemplates);
- if(!updated.empty() || !removed.empty())
- {
- out << nl << "server templates";
- out << sb;
- for(TemplateDescriptorDict::const_iterator p = updated.begin(); p != updated.end(); ++p)
- {
- if(helper._def.serverTemplates.find(p->first) == helper._def.serverTemplates.end())
- {
- out << nl << "server template `" << p->first << "' added";
- }
- }
- for(TemplateDescriptorDict::const_iterator q = updated.begin(); q != updated.end(); ++q)
- {
- if(helper._def.serverTemplates.find(q->first) != helper._def.serverTemplates.end())
- {
- out << nl << "server template `" << q->first << "' updated";
- }
- }
- for(Ice::StringSeq::const_iterator r = removed.begin(); r != removed.end(); ++r)
- {
- out << nl << "server template `" << *r << "' removed";
- }
- out << eb;
- }
- }
- {
- TemplateDescriptorEqual eq;
- TemplateDescriptorDict updated;
- updated = getDictUpdatedEltsWithEq(helper._def.serviceTemplates, _def.serviceTemplates, eq);
- Ice::StringSeq removed = getDictRemovedElts(helper._def.serviceTemplates, _def.serviceTemplates);
- if(!updated.empty() || !removed.empty())
- {
- out << nl << "service templates";
- out << sb;
- for(TemplateDescriptorDict::const_iterator p = updated.begin(); p != updated.end(); ++p)
- {
- if(helper._def.serviceTemplates.find(p->first) == helper._def.serviceTemplates.end())
- {
- out << nl << "service template `" << p->first << "' added";
- }
- }
- for(TemplateDescriptorDict::const_iterator q = updated.begin(); q != updated.end(); ++q)
- {
- if(helper._def.serviceTemplates.find(q->first) != helper._def.serviceTemplates.end())
- {
- out << nl << "service template `" << q->first << "' updated";
- }
- }
- for(Ice::StringSeq::const_iterator r = removed.begin(); r != removed.end(); ++r)
- {
- out << nl << "service template `" << *r << "' removed";
- }
- out << eb;
- }
- }
- {
- NodeHelperDict updated = getDictUpdatedElts(helper._nodes, _nodes);
- Ice::StringSeq removed = getDictRemovedElts(helper._nodes, _nodes);
- if(!updated.empty() || !removed.empty())
- {
- out << nl << "nodes";
- out << sb;
- for(NodeHelperDict::const_iterator p = updated.begin(); p != updated.end(); ++p)
- {
- NodeHelperDict::const_iterator q = helper._nodes.find(p->first);
- if(q == helper._nodes.end())
- {
- p->second.print(out);
- }
- }
- for(NodeHelperDict::const_iterator r = updated.begin(); r != updated.end(); ++r)
- {
- NodeHelperDict::const_iterator q = helper._nodes.find(r->first);
- if(q != helper._nodes.end())
- {
- r->second.printDiff(out, q->second);
- }
- }
- for(Ice::StringSeq::const_iterator s = removed.begin(); s != removed.end(); ++s)
- {
- out << nl << "node `" << *s << "' removed";
- }
- out << eb;
- }
+ map<string, string> variables = getDictUpdatedElts(helper._def.variables, _def.variables);
+ Ice::StringSeq removeVariables = getDictRemovedElts(helper._def.variables, _def.variables);
+ if(!variables.empty() || !removeVariables.empty())
+ {
+ out << nl << "variables udpated";
+ }
+ }
+ {
+ if(_def.distrib != helper._def.distrib)
+ {
+ out << nl << "distribution updated";
+ }
+ }
+ {
+ PropertySetDescriptorDict updt = getDictUpdatedElts(helper._def.propertySets, _def.propertySets);
+ Ice::StringSeq removed = getDictRemovedElts(helper._def.propertySets, _def.propertySets);
+ if(!updt.empty() || !removed.empty())
+ {
+ out << nl << "property sets udpated";
+ }
+ }
+ {
+ GetReplicaGroupId rk;
+ ReplicaGroupEq req;
+ ReplicaGroupDescriptorSeq updated =
+ getSeqUpdatedEltsWithEq(helper._def.replicaGroups, _def.replicaGroups, rk, req);
+ Ice::StringSeq removed = getSeqRemovedElts(helper._def.replicaGroups, _def.replicaGroups, rk);
+ if(!updated.empty() || !removed.empty())
+ {
+ out << nl << "replica groups";
+ out << sb;
+ ReplicaGroupDescriptorSeq::iterator p = updated.begin();
+ while(p != updated.end())
+ {
+ ReplicaGroupDescriptorSeq::const_iterator r;
+ for(r = helper._def.replicaGroups.begin(); r != helper._def.replicaGroups.end();
+ ++r)
+ {
+ if(p->id == r->id)
+ {
+ out << nl << "replica group `" << r->id << "' updated";
+ p = updated.erase(p);
+ break;
+ }
+ }
+ if(r == helper._def.replicaGroups.end())
+ {
+ ++p;
+ }
+ }
+ for(p = updated.begin(); p != updated.end(); ++p)
+ {
+ out << nl << "replica group `" << p->id << "' added";
+ }
+ for(Ice::StringSeq::const_iterator q = removed.begin(); q != removed.end(); ++q)
+ {
+ out << nl << "replica group `" << *q << "' removed";
+ }
+ out << eb;
+ }
+ }
+
+ {
+ TemplateDescriptorEqual eq;
+ TemplateDescriptorDict updated;
+ updated = getDictUpdatedEltsWithEq(helper._def.serverTemplates, _def.serverTemplates, eq);
+ Ice::StringSeq removed = getDictRemovedElts(helper._def.serverTemplates, _def.serverTemplates);
+ if(!updated.empty() || !removed.empty())
+ {
+ out << nl << "server templates";
+ out << sb;
+ for(TemplateDescriptorDict::const_iterator p = updated.begin(); p != updated.end(); ++p)
+ {
+ if(helper._def.serverTemplates.find(p->first) == helper._def.serverTemplates.end())
+ {
+ out << nl << "server template `" << p->first << "' added";
+ }
+ }
+ for(TemplateDescriptorDict::const_iterator q = updated.begin(); q != updated.end(); ++q)
+ {
+ if(helper._def.serverTemplates.find(q->first) != helper._def.serverTemplates.end())
+ {
+ out << nl << "server template `" << q->first << "' updated";
+ }
+ }
+ for(Ice::StringSeq::const_iterator r = removed.begin(); r != removed.end(); ++r)
+ {
+ out << nl << "server template `" << *r << "' removed";
+ }
+ out << eb;
+ }
+ }
+ {
+ TemplateDescriptorEqual eq;
+ TemplateDescriptorDict updated;
+ updated = getDictUpdatedEltsWithEq(helper._def.serviceTemplates, _def.serviceTemplates, eq);
+ Ice::StringSeq removed = getDictRemovedElts(helper._def.serviceTemplates, _def.serviceTemplates);
+ if(!updated.empty() || !removed.empty())
+ {
+ out << nl << "service templates";
+ out << sb;
+ for(TemplateDescriptorDict::const_iterator p = updated.begin(); p != updated.end(); ++p)
+ {
+ if(helper._def.serviceTemplates.find(p->first) == helper._def.serviceTemplates.end())
+ {
+ out << nl << "service template `" << p->first << "' added";
+ }
+ }
+ for(TemplateDescriptorDict::const_iterator q = updated.begin(); q != updated.end(); ++q)
+ {
+ if(helper._def.serviceTemplates.find(q->first) != helper._def.serviceTemplates.end())
+ {
+ out << nl << "service template `" << q->first << "' updated";
+ }
+ }
+ for(Ice::StringSeq::const_iterator r = removed.begin(); r != removed.end(); ++r)
+ {
+ out << nl << "service template `" << *r << "' removed";
+ }
+ out << eb;
+ }
+ }
+ {
+ NodeHelperDict updated = getDictUpdatedElts(helper._nodes, _nodes);
+ Ice::StringSeq removed = getDictRemovedElts(helper._nodes, _nodes);
+ if(!updated.empty() || !removed.empty())
+ {
+ out << nl << "nodes";
+ out << sb;
+ for(NodeHelperDict::const_iterator p = updated.begin(); p != updated.end(); ++p)
+ {
+ NodeHelperDict::const_iterator q = helper._nodes.find(p->first);
+ if(q == helper._nodes.end())
+ {
+ p->second.print(out);
+ }
+ }
+ for(NodeHelperDict::const_iterator r = updated.begin(); r != updated.end(); ++r)
+ {
+ NodeHelperDict::const_iterator q = helper._nodes.find(r->first);
+ if(q != helper._nodes.end())
+ {
+ r->second.printDiff(out, q->second);
+ }
+ }
+ for(Ice::StringSeq::const_iterator s = removed.begin(); s != removed.end(); ++s)
+ {
+ out << nl << "node `" << *s << "' removed";
+ }
+ out << eb;
+ }
}
out << eb;
}
@@ -3173,15 +3173,15 @@ IceGrid::descriptorEqual(const ServerDescriptorPtr& lhs, const ServerDescriptorP
IceBoxDescriptorPtr rhsIceBox = IceBoxDescriptorPtr::dynamicCast(rhs);
if(lhsIceBox && rhsIceBox)
{
- return IceBoxHelper(lhsIceBox) == IceBoxHelper(rhsIceBox);
+ return IceBoxHelper(lhsIceBox) == IceBoxHelper(rhsIceBox);
}
else if(!lhsIceBox && !rhsIceBox)
{
- return ServerHelper(lhs) == ServerHelper(rhs);
+ return ServerHelper(lhs) == ServerHelper(rhs);
}
else
{
- return false;
+ return false;
}
}
@@ -3191,10 +3191,10 @@ IceGrid::createHelper(const ServerDescriptorPtr& desc)
IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(desc);
if(iceBox)
{
- return new IceBoxHelper(iceBox);
+ return new IceBoxHelper(iceBox);
}
else
{
- return new ServerHelper(desc);
+ return new ServerHelper(desc);
}
}
diff --git a/cpp/src/IceGrid/DescriptorHelper.h b/cpp/src/IceGrid/DescriptorHelper.h
index 6ca60f0a170..2564d68d18d 100644
--- a/cpp/src/IceGrid/DescriptorHelper.h
+++ b/cpp/src/IceGrid/DescriptorHelper.h
@@ -120,14 +120,14 @@ public:
ServiceDescriptorPtr getDescriptor() const;
ServiceDescriptorPtr instantiate(const Resolver&, const PropertyDescriptorSeq&,
- const PropertySetDescriptorDict&) const;
+ const PropertySetDescriptorDict&) const;
void print(const Ice::CommunicatorPtr&, IceUtil::Output&) const;
protected:
void instantiateImpl(const ServiceDescriptorPtr&, const Resolver&, const PropertyDescriptorSeq&,
- const PropertySetDescriptorDict&) const;
+ const PropertySetDescriptorDict&) const;
private:
@@ -146,7 +146,7 @@ public:
ServerDescriptorPtr getDescriptor() const;
virtual ServerDescriptorPtr instantiate(const Resolver&, const PropertyDescriptorSeq&,
- const PropertySetDescriptorDict&) const;
+ const PropertySetDescriptorDict&) const;
void print(const Ice::CommunicatorPtr&, IceUtil::Output&) const;
void print(const Ice::CommunicatorPtr&, IceUtil::Output&, const ServerInfo&) const;
@@ -167,10 +167,10 @@ class InstanceHelper
protected:
std::map<std::string, std::string> instantiateParams(const Resolver&,
- const std::string&,
- const std::map<std::string, std::string>&,
- const std::vector<std::string>&,
- const std::map<std::string, std::string>&) const;
+ const std::string&,
+ const std::map<std::string, std::string>&,
+ const std::vector<std::string>&,
+ const std::map<std::string, std::string>&) const;
};
@@ -206,7 +206,7 @@ public:
bool operator!=(const IceBoxHelper&) const;
virtual ServerDescriptorPtr instantiate(const Resolver&, const PropertyDescriptorSeq&,
- const PropertySetDescriptorDict&) const;
+ const PropertySetDescriptorDict&) const;
virtual void getIds(std::multiset<std::string>&, std::multiset<Ice::Identity>&) const;
@@ -218,7 +218,7 @@ public:
protected:
void instantiateImpl(const IceBoxDescriptorPtr&, const Resolver&, const PropertyDescriptorSeq&,
- const PropertySetDescriptorDict&) const;
+ const PropertySetDescriptorDict&) const;
private:
diff --git a/cpp/src/IceGrid/DescriptorParser.cpp b/cpp/src/IceGrid/DescriptorParser.cpp
index 4fd68f57a7f..fac00758c70 100644
--- a/cpp/src/IceGrid/DescriptorParser.cpp
+++ b/cpp/src/IceGrid/DescriptorParser.cpp
@@ -114,366 +114,366 @@ DescriptorHandler::startElement(const string& name, const IceXML::Attributes& at
try
{
- if(name == "icegrid")
- {
- if(!_isTopLevel)
- {
- error("element <icegrid> is a top level element");
- }
- _isTopLevel = false;
- }
- else if(_isTopLevel)
- {
- error("only the <icegrid> element is allowed at the top-level");
- }
- else if(name == "target")
- {
- if(!_isCurrentTargetDeployable)
- {
- ++_targetCounter;
- }
- else
- {
- _isCurrentTargetDeployable = isTargetDeployable(attributes("name"));
- _targetCounter = 1;
- return;
- }
- }
- else if(!isCurrentTargetDeployable())
- {
- //
- // We don't bother to parse the elements if the elements are enclosed in a target element
- // which won't be deployed.
- //
- attributes.asMap();
- return;
- }
- else if(name == "include")
- {
- string targets = attributes("targets", "");
- string file = attributes("file");
- if(file[0] != '/')
- {
- string::size_type end = _filename.find_last_of('/');
- if(end != string::npos)
- {
- file = _filename.substr(0, end) + "/" + file;
- }
- }
-
- string oldFileName = _filename;
- vector<string> oldTargets = _targets;
- _isTopLevel = true;
- _filename = file;
- _targets = getTargets(targets);
-
- IceXML::Parser::parse(file, *this);
-
- _filename = oldFileName;
- _targets = oldTargets;
- }
- else if(name == "application")
- {
- if(_currentApplication.get())
- {
- error("only one <application> element is allowed");
- }
-
- bool importTemplates = attributes.asBool("import-default-templates", false);
-
- //
- // TODO: is ignoring importTemplates the desired behavior when _admin == 0?
- //
- if(importTemplates && _admin != 0)
- {
- try
- {
- ApplicationDescriptor application = _admin->getDefaultApplicationDescriptor();
- _currentApplication.reset(new ApplicationDescriptorBuilder(_communicator, application,
- attributes, _overrides));
- }
- catch(const DeploymentException& ex)
- {
- throw ex.reason;
- }
- }
- else
- {
- _currentApplication.reset(new ApplicationDescriptorBuilder(_communicator, attributes, _overrides));
- }
- }
- else if(name == "node")
- {
- if(!_currentApplication.get())
- {
- error("the <node> element can only be a child of an <application> element");
- }
- _currentNode.reset(_currentApplication->createNode(attributes));
- }
- else if(name == "server-instance")
- {
- if(!_currentNode.get() || _currentServer.get())
- {
- error("the <server-instance> element can only be a child of a <node> element");
- }
- _currentServerInstance.reset(_currentNode->createServerInstance(attributes));
- }
- else if(name == "server")
- {
- if(!_currentNode.get() && !_currentTemplate.get() || _currentServer.get())
- {
- error("the <server> element can only be a child of a <node> or <server-template> element");
- }
- if(_currentNode.get())
- {
- _currentServer.reset(_currentNode->createServer(attributes));
- }
- else
- {
- _currentServer.reset(_currentTemplate->createServer(attributes));
- }
- _currentCommunicator = _currentServer.get();
- }
- else if(name == "icebox")
- {
- if(!_currentNode.get() && !_currentTemplate.get() || _currentServer.get())
- {
- error("the <icebox> element can only be a child of a <node> or <server-template> element");
- }
- if(_currentNode.get())
- {
- _currentServer.reset(_currentNode->createIceBox(attributes));
- }
- else
- {
- _currentServer.reset(_currentTemplate->createIceBox(attributes));
- }
- _currentCommunicator = _currentServer.get();
- }
- else if(name == "server-template")
- {
- if(!_currentApplication.get() || _currentTemplate.get() || _currentNode.get())
- {
- error("the <server-template> element can only be a child of an <application> element");
- }
- _currentTemplate.reset(_currentApplication->createServerTemplate(attributes));
- }
- else if(name == "service-instance")
- {
- if(!_currentServer.get())
- {
- error("the <service-instance> element can only be a child of an <icebox> element");
- }
- _currentServiceInstance.reset(_currentServer->createServiceInstance(attributes));
- }
- else if(name == "service")
- {
- if(!_currentServer.get() && !_currentTemplate.get() || _currentService.get())
- {
- error("the <service> element can only be a child of an <icebox> or <service-template> element");
- }
-
- if(_currentServer.get())
- {
- _currentService.reset(_currentServer->createService(attributes));
- }
- else
- {
- _currentService.reset(_currentTemplate->createService(attributes));
- }
- _currentCommunicator = _currentService.get();
- }
- else if(name == "service-template")
- {
- if(!_currentApplication.get() || _currentNode.get() || _currentTemplate.get())
- {
- error("the <service-template> element can only be a child of an <application> element");
- }
-
- _currentTemplate.reset(_currentApplication->createServiceTemplate(attributes));
- }
- else if(name == "replica-group")
- {
- if(!_currentApplication.get())
- {
- error("the <replica-group> element can only be a child of an <application> element");
- }
- _currentApplication->addReplicaGroup(attributes);
- _inReplicaGroup = true;
- }
- else if(name == "load-balancing")
- {
- if(!_inReplicaGroup)
- {
- error("the <load-balancing> element can only be a child of a <replica-group> element");
- }
- _currentApplication->setLoadBalancing(attributes);
- }
- else if(name == "variable")
- {
- if(_currentNode.get())
- {
- _currentNode->addVariable(attributes);
- }
- else if(_currentApplication.get())
- {
- _currentApplication->addVariable(attributes);
- }
- else
- {
- error("the <variable> element can only be a child of an <application> or <node> element");
- }
- }
- else if(name == "parameter")
- {
- if(!_currentTemplate.get())
- {
- error("the <parameter> element can only be a child of a <template> element");
- }
- _currentTemplate->addParameter(attributes);
- }
- else if(name == "properties")
- {
- if(_currentPropertySet.get())
- {
- _currentPropertySet->addPropertySet(attributes);
- }
- else if(_currentServiceInstance.get())
- {
- _currentPropertySet.reset(_currentServiceInstance->createPropertySet());
- }
- else if(_currentServerInstance.get())
- {
- _currentPropertySet.reset(_currentServerInstance->createPropertySet(attributes));
- }
- else if(_currentCommunicator)
- {
- _currentPropertySet.reset(_currentCommunicator->createPropertySet());
- }
- else if(_currentNode.get())
- {
- _currentPropertySet.reset(_currentNode->createPropertySet(attributes));
- }
- else if(_currentApplication.get() && !_currentTemplate.get())
- {
- _currentPropertySet.reset(_currentApplication->createPropertySet(attributes));
- }
- else
- {
- error("the <properties> element is not allowed here");
- }
- }
- else if(name == "property")
- {
- if(_currentPropertySet.get())
- {
- _currentPropertySet->addProperty(attributes);
- }
- else if(_currentCommunicator)
- {
- _currentCommunicator->addProperty(attributes);
- }
- else
- {
- error("the <property> element can only be a child of a <properties>, <icebox>, <server> or <service> "
- "element");
- }
- }
- else if(name == "adapter")
- {
- if(!_currentCommunicator)
- {
- error("the <adapter> element can only be a child of a <server> or <service> element");
- }
- _currentCommunicator->addAdapter(attributes);
- _inAdapter = true;
- }
- else if(name == "object")
- {
- if(!_inAdapter && !_inReplicaGroup)
- {
- error("the <object> element can only be a child of an <adapter> or <replica-group> element");
- }
- if(_inReplicaGroup)
- {
- _currentApplication->addObject(attributes);
- }
- else
- {
- _currentCommunicator->addObject(attributes);
- }
- }
- else if(name == "allocatable")
- {
- if(!_inAdapter)
- {
- error("the <allocatable> element can only be a child of an <adapter> element");
- }
- _currentCommunicator->addAllocatable(attributes);
- }
- else if(name == "distrib")
- {
- if(!_currentApplication.get() ||
- (_currentNode.get() || _currentTemplate.get()) && !_currentServer.get() ||
- _currentServer.get() != _currentCommunicator)
- {
- error("the <distrib> element can only be a child of an <application>, <server> or <icebox> element");
- }
- if(!_currentServer.get())
- {
- _currentApplication->addDistribution(attributes);
- }
- else
- {
- _currentServer->addDistribution(attributes);
- }
- _inDistrib = true;
- }
- else if(name == "dbenv")
- {
- if(!_currentCommunicator)
- {
- error("the <dbenv> element can only be a child of a <server> or <service> element");
- }
- _currentCommunicator->addDbEnv(attributes);
- _inDbEnv = true;
- }
- else if(name == "log")
- {
- if(!_currentCommunicator)
- {
- error("the <log> element can only be a child of a <server> or <service> element");
- }
- _currentCommunicator->addLog(attributes);
- }
- else if(name == "dbproperty")
- {
- if(!_inDbEnv)
- {
- error("the <dbproperty> element can only be a child of a <dbenv> element");
- }
- _currentCommunicator->addDbEnvProperty(attributes);
- }
- else if(name == "description" || name == "option" || name == "env" || name == "directory")
- {
- //
- // Nothing to do.
- //
- }
- else
- {
- error("unknown element `" + name + "'");
- }
-
- attributes.checkUnknownAttributes();
+ if(name == "icegrid")
+ {
+ if(!_isTopLevel)
+ {
+ error("element <icegrid> is a top level element");
+ }
+ _isTopLevel = false;
+ }
+ else if(_isTopLevel)
+ {
+ error("only the <icegrid> element is allowed at the top-level");
+ }
+ else if(name == "target")
+ {
+ if(!_isCurrentTargetDeployable)
+ {
+ ++_targetCounter;
+ }
+ else
+ {
+ _isCurrentTargetDeployable = isTargetDeployable(attributes("name"));
+ _targetCounter = 1;
+ return;
+ }
+ }
+ else if(!isCurrentTargetDeployable())
+ {
+ //
+ // We don't bother to parse the elements if the elements are enclosed in a target element
+ // which won't be deployed.
+ //
+ attributes.asMap();
+ return;
+ }
+ else if(name == "include")
+ {
+ string targets = attributes("targets", "");
+ string file = attributes("file");
+ if(file[0] != '/')
+ {
+ string::size_type end = _filename.find_last_of('/');
+ if(end != string::npos)
+ {
+ file = _filename.substr(0, end) + "/" + file;
+ }
+ }
+
+ string oldFileName = _filename;
+ vector<string> oldTargets = _targets;
+ _isTopLevel = true;
+ _filename = file;
+ _targets = getTargets(targets);
+
+ IceXML::Parser::parse(file, *this);
+
+ _filename = oldFileName;
+ _targets = oldTargets;
+ }
+ else if(name == "application")
+ {
+ if(_currentApplication.get())
+ {
+ error("only one <application> element is allowed");
+ }
+
+ bool importTemplates = attributes.asBool("import-default-templates", false);
+
+ //
+ // TODO: is ignoring importTemplates the desired behavior when _admin == 0?
+ //
+ if(importTemplates && _admin != 0)
+ {
+ try
+ {
+ ApplicationDescriptor application = _admin->getDefaultApplicationDescriptor();
+ _currentApplication.reset(new ApplicationDescriptorBuilder(_communicator, application,
+ attributes, _overrides));
+ }
+ catch(const DeploymentException& ex)
+ {
+ throw ex.reason;
+ }
+ }
+ else
+ {
+ _currentApplication.reset(new ApplicationDescriptorBuilder(_communicator, attributes, _overrides));
+ }
+ }
+ else if(name == "node")
+ {
+ if(!_currentApplication.get())
+ {
+ error("the <node> element can only be a child of an <application> element");
+ }
+ _currentNode.reset(_currentApplication->createNode(attributes));
+ }
+ else if(name == "server-instance")
+ {
+ if(!_currentNode.get() || _currentServer.get())
+ {
+ error("the <server-instance> element can only be a child of a <node> element");
+ }
+ _currentServerInstance.reset(_currentNode->createServerInstance(attributes));
+ }
+ else if(name == "server")
+ {
+ if(!_currentNode.get() && !_currentTemplate.get() || _currentServer.get())
+ {
+ error("the <server> element can only be a child of a <node> or <server-template> element");
+ }
+ if(_currentNode.get())
+ {
+ _currentServer.reset(_currentNode->createServer(attributes));
+ }
+ else
+ {
+ _currentServer.reset(_currentTemplate->createServer(attributes));
+ }
+ _currentCommunicator = _currentServer.get();
+ }
+ else if(name == "icebox")
+ {
+ if(!_currentNode.get() && !_currentTemplate.get() || _currentServer.get())
+ {
+ error("the <icebox> element can only be a child of a <node> or <server-template> element");
+ }
+ if(_currentNode.get())
+ {
+ _currentServer.reset(_currentNode->createIceBox(attributes));
+ }
+ else
+ {
+ _currentServer.reset(_currentTemplate->createIceBox(attributes));
+ }
+ _currentCommunicator = _currentServer.get();
+ }
+ else if(name == "server-template")
+ {
+ if(!_currentApplication.get() || _currentTemplate.get() || _currentNode.get())
+ {
+ error("the <server-template> element can only be a child of an <application> element");
+ }
+ _currentTemplate.reset(_currentApplication->createServerTemplate(attributes));
+ }
+ else if(name == "service-instance")
+ {
+ if(!_currentServer.get())
+ {
+ error("the <service-instance> element can only be a child of an <icebox> element");
+ }
+ _currentServiceInstance.reset(_currentServer->createServiceInstance(attributes));
+ }
+ else if(name == "service")
+ {
+ if(!_currentServer.get() && !_currentTemplate.get() || _currentService.get())
+ {
+ error("the <service> element can only be a child of an <icebox> or <service-template> element");
+ }
+
+ if(_currentServer.get())
+ {
+ _currentService.reset(_currentServer->createService(attributes));
+ }
+ else
+ {
+ _currentService.reset(_currentTemplate->createService(attributes));
+ }
+ _currentCommunicator = _currentService.get();
+ }
+ else if(name == "service-template")
+ {
+ if(!_currentApplication.get() || _currentNode.get() || _currentTemplate.get())
+ {
+ error("the <service-template> element can only be a child of an <application> element");
+ }
+
+ _currentTemplate.reset(_currentApplication->createServiceTemplate(attributes));
+ }
+ else if(name == "replica-group")
+ {
+ if(!_currentApplication.get())
+ {
+ error("the <replica-group> element can only be a child of an <application> element");
+ }
+ _currentApplication->addReplicaGroup(attributes);
+ _inReplicaGroup = true;
+ }
+ else if(name == "load-balancing")
+ {
+ if(!_inReplicaGroup)
+ {
+ error("the <load-balancing> element can only be a child of a <replica-group> element");
+ }
+ _currentApplication->setLoadBalancing(attributes);
+ }
+ else if(name == "variable")
+ {
+ if(_currentNode.get())
+ {
+ _currentNode->addVariable(attributes);
+ }
+ else if(_currentApplication.get())
+ {
+ _currentApplication->addVariable(attributes);
+ }
+ else
+ {
+ error("the <variable> element can only be a child of an <application> or <node> element");
+ }
+ }
+ else if(name == "parameter")
+ {
+ if(!_currentTemplate.get())
+ {
+ error("the <parameter> element can only be a child of a <template> element");
+ }
+ _currentTemplate->addParameter(attributes);
+ }
+ else if(name == "properties")
+ {
+ if(_currentPropertySet.get())
+ {
+ _currentPropertySet->addPropertySet(attributes);
+ }
+ else if(_currentServiceInstance.get())
+ {
+ _currentPropertySet.reset(_currentServiceInstance->createPropertySet());
+ }
+ else if(_currentServerInstance.get())
+ {
+ _currentPropertySet.reset(_currentServerInstance->createPropertySet(attributes));
+ }
+ else if(_currentCommunicator)
+ {
+ _currentPropertySet.reset(_currentCommunicator->createPropertySet());
+ }
+ else if(_currentNode.get())
+ {
+ _currentPropertySet.reset(_currentNode->createPropertySet(attributes));
+ }
+ else if(_currentApplication.get() && !_currentTemplate.get())
+ {
+ _currentPropertySet.reset(_currentApplication->createPropertySet(attributes));
+ }
+ else
+ {
+ error("the <properties> element is not allowed here");
+ }
+ }
+ else if(name == "property")
+ {
+ if(_currentPropertySet.get())
+ {
+ _currentPropertySet->addProperty(attributes);
+ }
+ else if(_currentCommunicator)
+ {
+ _currentCommunicator->addProperty(attributes);
+ }
+ else
+ {
+ error("the <property> element can only be a child of a <properties>, <icebox>, <server> or <service> "
+ "element");
+ }
+ }
+ else if(name == "adapter")
+ {
+ if(!_currentCommunicator)
+ {
+ error("the <adapter> element can only be a child of a <server> or <service> element");
+ }
+ _currentCommunicator->addAdapter(attributes);
+ _inAdapter = true;
+ }
+ else if(name == "object")
+ {
+ if(!_inAdapter && !_inReplicaGroup)
+ {
+ error("the <object> element can only be a child of an <adapter> or <replica-group> element");
+ }
+ if(_inReplicaGroup)
+ {
+ _currentApplication->addObject(attributes);
+ }
+ else
+ {
+ _currentCommunicator->addObject(attributes);
+ }
+ }
+ else if(name == "allocatable")
+ {
+ if(!_inAdapter)
+ {
+ error("the <allocatable> element can only be a child of an <adapter> element");
+ }
+ _currentCommunicator->addAllocatable(attributes);
+ }
+ else if(name == "distrib")
+ {
+ if(!_currentApplication.get() ||
+ (_currentNode.get() || _currentTemplate.get()) && !_currentServer.get() ||
+ _currentServer.get() != _currentCommunicator)
+ {
+ error("the <distrib> element can only be a child of an <application>, <server> or <icebox> element");
+ }
+ if(!_currentServer.get())
+ {
+ _currentApplication->addDistribution(attributes);
+ }
+ else
+ {
+ _currentServer->addDistribution(attributes);
+ }
+ _inDistrib = true;
+ }
+ else if(name == "dbenv")
+ {
+ if(!_currentCommunicator)
+ {
+ error("the <dbenv> element can only be a child of a <server> or <service> element");
+ }
+ _currentCommunicator->addDbEnv(attributes);
+ _inDbEnv = true;
+ }
+ else if(name == "log")
+ {
+ if(!_currentCommunicator)
+ {
+ error("the <log> element can only be a child of a <server> or <service> element");
+ }
+ _currentCommunicator->addLog(attributes);
+ }
+ else if(name == "dbproperty")
+ {
+ if(!_inDbEnv)
+ {
+ error("the <dbproperty> element can only be a child of a <dbenv> element");
+ }
+ _currentCommunicator->addDbEnvProperty(attributes);
+ }
+ else if(name == "description" || name == "option" || name == "env" || name == "directory")
+ {
+ //
+ // Nothing to do.
+ //
+ }
+ else
+ {
+ error("unknown element `" + name + "'");
+ }
+
+ attributes.checkUnknownAttributes();
}
catch(const string& reason)
{
- error(reason);
+ error(reason);
}
catch(const char* reason)
{
- error(reason);
+ error(reason);
}
//
@@ -483,7 +483,7 @@ DescriptorHandler::startElement(const string& name, const IceXML::Attributes& at
string value = elementValue();
if(!value.empty() && value.find_first_not_of(" \t\r\n") != string::npos)
{
- error("invalid element value for element `" + _previousElementName + "'");
+ error("invalid element value for element `" + _previousElementName + "'");
}
_previousElementName = name;
}
@@ -496,206 +496,206 @@ DescriptorHandler::endElement(const string& name, int line, int column)
try
{
- if(name == "target")
- {
- if(!_isCurrentTargetDeployable && --_targetCounter == 0)
- {
- _isCurrentTargetDeployable = true;
- _targetCounter = 0;
- }
- return;
- }
- else if(!isCurrentTargetDeployable())
- {
- //
- // We don't bother to parse the elements if the elements are enclosed in a target element
- // which won't be deployed.
- //
- return;
- }
- else if(name == "node")
- {
- _currentApplication->addNode(_currentNode->getName(), _currentNode->getDescriptor());
- _currentNode.reset(0);
- }
- else if(name == "server" || name == "icebox")
- {
- assert(_currentServer.get());
- if(_currentTemplate.get())
- {
- _currentTemplate->setDescriptor(_currentServer->getDescriptor());
- }
- else
- {
- assert(_currentNode.get());
- _currentNode->addServer(_currentServer->getDescriptor());
- }
- _currentServer->finish();
- _currentServer.reset(0);
- _currentCommunicator = 0;
- }
- else if(name == "server-template")
- {
- assert(_currentApplication.get());
- _currentApplication->addServerTemplate(_currentTemplate->getId(), _currentTemplate->getDescriptor());
- _currentTemplate.reset(0);
- }
- else if(name == "service")
- {
- assert(_currentService.get());
- if(_currentServer.get())
- {
- _currentServer->addService(_currentService->getDescriptor());
- }
- else
- {
- _currentTemplate->setDescriptor(_currentService->getDescriptor());
- }
- _currentService->finish();
- _currentService.reset(0);
- _currentCommunicator = _currentServer.get();
- }
- else if(name == "service-template")
- {
- assert(_currentTemplate.get());
- _currentApplication->addServiceTemplate(_currentTemplate->getId(), _currentTemplate->getDescriptor());
- _currentTemplate.reset(0);
- }
- else if(name == "server-instance")
- {
- assert(_currentNode.get() && _currentServerInstance.get());
- _currentNode->addServerInstance(_currentServerInstance->getDescriptor());
- _currentServerInstance.reset(0);
- }
- else if(name == "service-instance")
- {
- assert(_currentServer.get() && _currentServiceInstance.get());
- _currentServer->addServiceInstance(_currentServiceInstance->getDescriptor());
- _currentServiceInstance.reset(0);
- }
- else if(name == "properties")
- {
- assert(_currentPropertySet.get());
- if(_currentPropertySet->finish())
- {
- if(_currentServiceInstance.get())
- {
- _currentServiceInstance->addPropertySet(_currentPropertySet->getDescriptor());
- }
- else if(_currentServerInstance.get())
- {
- _currentServerInstance->addPropertySet(_currentPropertySet->getService(),
- _currentPropertySet->getDescriptor());
- }
- else if(_currentCommunicator)
- {
- _currentCommunicator->addPropertySet(_currentPropertySet->getDescriptor());
- }
- else if(_currentNode.get())
- {
- _currentNode->addPropertySet(_currentPropertySet->getId(),
- _currentPropertySet->getDescriptor());
- }
- else if(_currentApplication.get())
- {
- _currentApplication->addPropertySet(_currentPropertySet->getId(),
- _currentPropertySet->getDescriptor());
- }
- else
- {
- assert(false);
- }
- _currentPropertySet.reset(0);
- }
- }
- else if(name == "description")
- {
- if(_inAdapter)
- {
- _currentCommunicator->setAdapterDescription(elementValue());
- }
- else if(_inReplicaGroup)
- {
- _currentApplication->setReplicaGroupDescription(elementValue());
- }
- else if(_inDbEnv)
- {
- assert(_currentCommunicator);
- _currentCommunicator->setDbEnvDescription(elementValue());
- }
- else if(_currentCommunicator)
- {
- _currentCommunicator->setDescription(elementValue());
- }
- else if(_currentNode.get())
- {
- _currentNode->setDescription(elementValue());
- }
- else if(_currentApplication.get())
- {
- _currentApplication->setDescription(elementValue());
- }
- else
- {
- error("element <description> is not allowed here");
- }
- }
- else if(name == "option")
- {
- if(!_currentServer.get())
- {
- error("element <option> can only be the child of a <server> element");
- }
- _currentServer->addOption(elementValue());
- }
- else if(name == "env")
- {
- if(!_currentServer.get())
- {
- error("element <env> can only be the child of a <server> element");
- }
- _currentServer->addEnv(elementValue());
- }
- else if(name == "directory")
- {
- if(!_inDistrib)
- {
- error("the <directory> element can only be a child of a <distrib> element");
- }
- if(!_currentServer.get())
- {
- _currentApplication->addDistributionDirectory(elementValue());
- }
- else
- {
- _currentServer->addDistributionDirectory(elementValue());
- }
- }
- else if(name == "adapter")
- {
- _inAdapter = false;
- }
- else if(name == "replica-group")
- {
- _currentApplication->finishReplicaGroup();
- _inReplicaGroup = false;
- }
- else if(name == "dbenv")
- {
- _inDbEnv = false;
- }
- else if(name == "distrib")
- {
- _inDistrib = false;
- }
+ if(name == "target")
+ {
+ if(!_isCurrentTargetDeployable && --_targetCounter == 0)
+ {
+ _isCurrentTargetDeployable = true;
+ _targetCounter = 0;
+ }
+ return;
+ }
+ else if(!isCurrentTargetDeployable())
+ {
+ //
+ // We don't bother to parse the elements if the elements are enclosed in a target element
+ // which won't be deployed.
+ //
+ return;
+ }
+ else if(name == "node")
+ {
+ _currentApplication->addNode(_currentNode->getName(), _currentNode->getDescriptor());
+ _currentNode.reset(0);
+ }
+ else if(name == "server" || name == "icebox")
+ {
+ assert(_currentServer.get());
+ if(_currentTemplate.get())
+ {
+ _currentTemplate->setDescriptor(_currentServer->getDescriptor());
+ }
+ else
+ {
+ assert(_currentNode.get());
+ _currentNode->addServer(_currentServer->getDescriptor());
+ }
+ _currentServer->finish();
+ _currentServer.reset(0);
+ _currentCommunicator = 0;
+ }
+ else if(name == "server-template")
+ {
+ assert(_currentApplication.get());
+ _currentApplication->addServerTemplate(_currentTemplate->getId(), _currentTemplate->getDescriptor());
+ _currentTemplate.reset(0);
+ }
+ else if(name == "service")
+ {
+ assert(_currentService.get());
+ if(_currentServer.get())
+ {
+ _currentServer->addService(_currentService->getDescriptor());
+ }
+ else
+ {
+ _currentTemplate->setDescriptor(_currentService->getDescriptor());
+ }
+ _currentService->finish();
+ _currentService.reset(0);
+ _currentCommunicator = _currentServer.get();
+ }
+ else if(name == "service-template")
+ {
+ assert(_currentTemplate.get());
+ _currentApplication->addServiceTemplate(_currentTemplate->getId(), _currentTemplate->getDescriptor());
+ _currentTemplate.reset(0);
+ }
+ else if(name == "server-instance")
+ {
+ assert(_currentNode.get() && _currentServerInstance.get());
+ _currentNode->addServerInstance(_currentServerInstance->getDescriptor());
+ _currentServerInstance.reset(0);
+ }
+ else if(name == "service-instance")
+ {
+ assert(_currentServer.get() && _currentServiceInstance.get());
+ _currentServer->addServiceInstance(_currentServiceInstance->getDescriptor());
+ _currentServiceInstance.reset(0);
+ }
+ else if(name == "properties")
+ {
+ assert(_currentPropertySet.get());
+ if(_currentPropertySet->finish())
+ {
+ if(_currentServiceInstance.get())
+ {
+ _currentServiceInstance->addPropertySet(_currentPropertySet->getDescriptor());
+ }
+ else if(_currentServerInstance.get())
+ {
+ _currentServerInstance->addPropertySet(_currentPropertySet->getService(),
+ _currentPropertySet->getDescriptor());
+ }
+ else if(_currentCommunicator)
+ {
+ _currentCommunicator->addPropertySet(_currentPropertySet->getDescriptor());
+ }
+ else if(_currentNode.get())
+ {
+ _currentNode->addPropertySet(_currentPropertySet->getId(),
+ _currentPropertySet->getDescriptor());
+ }
+ else if(_currentApplication.get())
+ {
+ _currentApplication->addPropertySet(_currentPropertySet->getId(),
+ _currentPropertySet->getDescriptor());
+ }
+ else
+ {
+ assert(false);
+ }
+ _currentPropertySet.reset(0);
+ }
+ }
+ else if(name == "description")
+ {
+ if(_inAdapter)
+ {
+ _currentCommunicator->setAdapterDescription(elementValue());
+ }
+ else if(_inReplicaGroup)
+ {
+ _currentApplication->setReplicaGroupDescription(elementValue());
+ }
+ else if(_inDbEnv)
+ {
+ assert(_currentCommunicator);
+ _currentCommunicator->setDbEnvDescription(elementValue());
+ }
+ else if(_currentCommunicator)
+ {
+ _currentCommunicator->setDescription(elementValue());
+ }
+ else if(_currentNode.get())
+ {
+ _currentNode->setDescription(elementValue());
+ }
+ else if(_currentApplication.get())
+ {
+ _currentApplication->setDescription(elementValue());
+ }
+ else
+ {
+ error("element <description> is not allowed here");
+ }
+ }
+ else if(name == "option")
+ {
+ if(!_currentServer.get())
+ {
+ error("element <option> can only be the child of a <server> element");
+ }
+ _currentServer->addOption(elementValue());
+ }
+ else if(name == "env")
+ {
+ if(!_currentServer.get())
+ {
+ error("element <env> can only be the child of a <server> element");
+ }
+ _currentServer->addEnv(elementValue());
+ }
+ else if(name == "directory")
+ {
+ if(!_inDistrib)
+ {
+ error("the <directory> element can only be a child of a <distrib> element");
+ }
+ if(!_currentServer.get())
+ {
+ _currentApplication->addDistributionDirectory(elementValue());
+ }
+ else
+ {
+ _currentServer->addDistributionDirectory(elementValue());
+ }
+ }
+ else if(name == "adapter")
+ {
+ _inAdapter = false;
+ }
+ else if(name == "replica-group")
+ {
+ _currentApplication->finishReplicaGroup();
+ _inReplicaGroup = false;
+ }
+ else if(name == "dbenv")
+ {
+ _inDbEnv = false;
+ }
+ else if(name == "distrib")
+ {
+ _inDistrib = false;
+ }
}
catch(const string& reason)
{
- error(reason);
+ error(reason);
}
catch(const char* reason)
{
- error(reason);
+ error(reason);
}
//
@@ -705,7 +705,7 @@ DescriptorHandler::endElement(const string& name, int line, int column)
string value = elementValue();
if(!value.empty() && value.find_first_not_of(" \t\r\n") != string::npos)
{
- error("invalid element value for element `" + name + "'");
+ error("invalid element value for element `" + name + "'");
}
}
@@ -714,7 +714,7 @@ DescriptorHandler::characters(const string& chars, int, int)
{
if(isCurrentTargetDeployable())
{
- _data += chars;
+ _data += chars;
}
}
@@ -731,7 +731,7 @@ DescriptorHandler::getApplicationDescriptor() const
{
if(!_currentApplication.get())
{
- error("no application descriptor defined in this file");
+ error("no application descriptor defined in this file");
}
return _currentApplication->getDescriptor();
}
@@ -749,22 +749,22 @@ DescriptorHandler::getTargets(const string& targets) const
if(!targets.empty())
{
- const string delim = " \t\n\r";
-
- string::size_type beg = 0;
- string::size_type end = 0;
- do
- {
- end = targets.find_first_of(delim, end);
- if(end == string::npos)
- {
- end = targets.size();
- }
-
- result.push_back(targets.substr(beg, end - beg));
- beg = ++end;
- }
- while(end < targets.size());
+ const string delim = " \t\n\r";
+
+ string::size_type beg = 0;
+ string::size_type end = 0;
+ do
+ {
+ end = targets.find_first_of(delim, end);
+ if(end == string::npos)
+ {
+ end = targets.size();
+ }
+
+ result.push_back(targets.substr(beg, end - beg));
+ beg = ++end;
+ }
+ while(end < targets.size());
}
copy(_targets.begin(), _targets.end(), back_inserter(result));
@@ -803,19 +803,19 @@ DescriptorHandler::isTargetDeployable(const string& target) const
string fqn;
if(!application.empty())
{
- fqn += (fqn.empty() ? "" : ".") + application;
+ fqn += (fqn.empty() ? "" : ".") + application;
}
if(!node.empty())
{
- fqn += (fqn.empty() ? "" : ".") + node;
+ fqn += (fqn.empty() ? "" : ".") + node;
}
if(!server.empty())
{
- fqn += (fqn.empty() ? "" : ".") + server;
+ fqn += (fqn.empty() ? "" : ".") + server;
}
if(!service.empty())
{
- fqn += (fqn.empty() ? "" : ".") + service;
+ fqn += (fqn.empty() ? "" : ".") + service;
}
//
@@ -823,40 +823,40 @@ DescriptorHandler::isTargetDeployable(const string& target) const
//
for(vector<string>::const_iterator p = _targets.begin(); p != _targets.end(); ++p)
{
- if((*p) == target)
- {
- //
- // A supplied target without any communicator prefix is matching the target.
- //
- return true;
- }
- else
- {
- string communicatorTarget;
- string::size_type end = 0;
- while(end != string::npos)
- {
- //
- // Add the first communicator name from the communicator fully qualified name to the
- // target and see if matches.
- //
- end = fqn.find('.', end);
- if(end == string::npos)
- {
- communicatorTarget = fqn + "." + target;
- }
- else
- {
- communicatorTarget = fqn.substr(0, end) + "." + target;
- ++end;
- }
-
- if((*p) == communicatorTarget)
- {
- return true;
- }
- }
- }
+ if((*p) == target)
+ {
+ //
+ // A supplied target without any communicator prefix is matching the target.
+ //
+ return true;
+ }
+ else
+ {
+ string communicatorTarget;
+ string::size_type end = 0;
+ while(end != string::npos)
+ {
+ //
+ // Add the first communicator name from the communicator fully qualified name to the
+ // target and see if matches.
+ //
+ end = fqn.find('.', end);
+ if(end == string::npos)
+ {
+ communicatorTarget = fqn + "." + target;
+ }
+ else
+ {
+ communicatorTarget = fqn.substr(0, end) + "." + target;
+ ++end;
+ }
+
+ if((*p) == communicatorTarget)
+ {
+ return true;
+ }
+ }
+ }
}
return false;
@@ -864,10 +864,10 @@ DescriptorHandler::isTargetDeployable(const string& target) const
ApplicationDescriptor
DescriptorParser::parseDescriptor(const string& descriptor,
- const Ice::StringSeq& targets,
- const map<string, string>& variables,
- const Ice::CommunicatorPtr& communicator,
- const IceGrid::AdminPrx& admin)
+ const Ice::StringSeq& targets,
+ const map<string, string>& variables,
+ const Ice::CommunicatorPtr& communicator,
+ const IceGrid::AdminPrx& admin)
{
string filename = IcePatch2::simplify(descriptor);
DescriptorHandler handler(filename, communicator);
diff --git a/cpp/src/IceGrid/DescriptorParser.h b/cpp/src/IceGrid/DescriptorParser.h
index c1187f29949..f5a801225e1 100644
--- a/cpp/src/IceGrid/DescriptorParser.h
+++ b/cpp/src/IceGrid/DescriptorParser.h
@@ -18,10 +18,10 @@ class DescriptorParser
public:
static ApplicationDescriptor parseDescriptor(const std::string&,
- const Ice::StringSeq&,
- const std::map<std::string, std::string>&,
- const Ice::CommunicatorPtr&,
- const IceGrid::AdminPrx&);
+ const Ice::StringSeq&,
+ const std::map<std::string, std::string>&,
+ const Ice::CommunicatorPtr&,
+ const IceGrid::AdminPrx&);
static ApplicationDescriptor parseDescriptor(const std::string&, const Ice::CommunicatorPtr&);
diff --git a/cpp/src/IceGrid/FileCache.cpp b/cpp/src/IceGrid/FileCache.cpp
index b09b5dcbf9f..fa06add4ca7 100644
--- a/cpp/src/IceGrid/FileCache.cpp
+++ b/cpp/src/IceGrid/FileCache.cpp
@@ -30,7 +30,7 @@ FileCache::getOffsetFromEnd(const string& file, int originalCount)
ifstream is(file.c_str());
if(is.fail())
{
- throw FileNotAvailableException("failed to open file `" + file + "'");
+ throw FileNotAvailableException("failed to open file `" + file + "'");
}
if(originalCount < 0)
@@ -54,64 +54,64 @@ FileCache::getOffsetFromEnd(const string& file, int originalCount)
{
lines.clear();
- //
- // Move the current position of the stream to the new block to
- // read.
- //
- is.clear();
- if(lastBlockOffset - blockSize > streamoff(0))
- {
- is.seekg(lastBlockOffset - blockSize);
- getline(is, line); // Ignore the first line as it's most likely not complete.
- }
- else
- {
- is.seekg(0, ios::beg); // We've reach the begining of the file.
- }
-
- //
- // Read the block and count the number of lines in the block
- // If we found the "first last N lines", we start throwing out
- // the lines read at the begining of the file.
- //
- int count = originalCount - totalCount; // Number of lines left to find.
- while(is.good() && is.tellg() <= streamoff(lastBlockOffset))
- {
+ //
+ // Move the current position of the stream to the new block to
+ // read.
+ //
+ is.clear();
+ if(lastBlockOffset - blockSize > streamoff(0))
+ {
+ is.seekg(lastBlockOffset - blockSize);
+ getline(is, line); // Ignore the first line as it's most likely not complete.
+ }
+ else
+ {
+ is.seekg(0, ios::beg); // We've reach the begining of the file.
+ }
+
+ //
+ // Read the block and count the number of lines in the block
+ // If we found the "first last N lines", we start throwing out
+ // the lines read at the begining of the file.
+ //
+ int count = originalCount - totalCount; // Number of lines left to find.
+ while(is.good() && is.tellg() <= streamoff(lastBlockOffset))
+ {
streampos beg = is.tellg();
- getline(is, line);
- if(is.eof() && line.empty()) // Don't count the last line if it's empty.
- {
- continue;
- }
-
- lines.push_back(make_pair(beg, line));
- ++totalCount;
- if(lines.size() == static_cast<unsigned int>(count + 1))
- {
- --totalCount;
- lines.pop_front();
- }
- }
-
- if(lastBlockOffset - blockSize < streamoff(0))
- {
- break; // We're done if the block started at the begining of the file.
- }
- else if(totalCount < originalCount)
- {
- //
- // Otherwise, it we still didn't find the required number of lines,
- // read another block of text before this block.
- //
- lastBlockOffset -= blockSize; // Position of the block we just read.
- blockSize *= 2; // Read a bigger block.
- }
+ getline(is, line);
+ if(is.eof() && line.empty()) // Don't count the last line if it's empty.
+ {
+ continue;
+ }
+
+ lines.push_back(make_pair(beg, line));
+ ++totalCount;
+ if(lines.size() == static_cast<unsigned int>(count + 1))
+ {
+ --totalCount;
+ lines.pop_front();
+ }
+ }
+
+ if(lastBlockOffset - blockSize < streamoff(0))
+ {
+ break; // We're done if the block started at the begining of the file.
+ }
+ else if(totalCount < originalCount)
+ {
+ //
+ // Otherwise, it we still didn't find the required number of lines,
+ // read another block of text before this block.
+ //
+ lastBlockOffset -= blockSize; // Position of the block we just read.
+ blockSize *= 2; // Read a bigger block.
+ }
}
while(totalCount < originalCount && !is.bad());
if(is.bad())
{
- throw FileNotAvailableException("unrecoverable error occured while reading file `" + file + "'");
+ throw FileNotAvailableException("unrecoverable error occured while reading file `" + file + "'");
}
if(lines.empty())
@@ -131,18 +131,18 @@ FileCache::read(const string& file, Ice::Long offset, int size, Ice::Long& newOf
if(size > _messageSizeMax)
{
- size = _messageSizeMax;
+ size = _messageSizeMax;
}
if(size <= 5)
{
- throw FileNotAvailableException("maximum bytes per read request is too low");
+ throw FileNotAvailableException("maximum bytes per read request is too low");
}
ifstream is(file.c_str());
if(is.fail())
{
- throw FileNotAvailableException("failed to open file `" + file + "'");
+ throw FileNotAvailableException("failed to open file `" + file + "'");
}
//
@@ -153,9 +153,9 @@ FileCache::read(const string& file, Ice::Long offset, int size, Ice::Long& newOf
is.seekg(0, ios::end);
if(offset >= is.tellg())
{
- newOffset = is.tellg();
- lines = Ice::StringSeq();
- return true;
+ newOffset = is.tellg();
+ lines = Ice::StringSeq();
+ return true;
}
//
@@ -173,44 +173,44 @@ FileCache::read(const string& file, Ice::Long offset, int size, Ice::Long& newOf
for(int i = 0; is.good(); ++i)
{
- getline(is, line);
+ getline(is, line);
- int lineSize = static_cast<int>(line.size()) + 5; // 5 bytes for the encoding of the string size (worst case)
- if(lineSize + totalSize > size)
- {
- if(totalSize + 5 < size)
- {
+ int lineSize = static_cast<int>(line.size()) + 5; // 5 bytes for the encoding of the string size (worst case)
+ if(lineSize + totalSize > size)
+ {
+ if(totalSize + 5 < size)
+ {
// There's some room left for a part of the string, return a partial string
line = line.substr(0, size - totalSize - 5);
- lines.push_back(line);
- newOffset += line.size();
- }
- else
- {
- lines.push_back("");
- }
+ lines.push_back(line);
+ newOffset += line.size();
+ }
+ else
+ {
+ lines.push_back("");
+ }
return false; // We didn't reach the end of file, we've just reached the size limit!
- }
+ }
- totalSize += lineSize;
- lines.push_back(line);
+ totalSize += lineSize;
+ lines.push_back(line);
#if defined(_MSC_VER) && (_MSC_VER < 1300)
- if(is.eof())
- {
- newOffset += line.size();
- }
- else
+ if(is.eof())
+ {
+ newOffset += line.size();
+ }
+ else
#else
- if(!is.fail())
+ if(!is.fail())
#endif
- {
- newOffset = is.tellg();
- }
+ {
+ newOffset = is.tellg();
+ }
}
if(is.bad())
{
- throw FileNotAvailableException("unrecoverable error occured while reading file `" + file + "'");
+ throw FileNotAvailableException("unrecoverable error occured while reading file `" + file + "'");
}
return is.eof();
diff --git a/cpp/src/IceGrid/FileParserI.cpp b/cpp/src/IceGrid/FileParserI.cpp
index f2e33fbb69b..9e71dd0b55d 100755
--- a/cpp/src/IceGrid/FileParserI.cpp
+++ b/cpp/src/IceGrid/FileParserI.cpp
@@ -20,12 +20,12 @@ FileParserI::parse(const string& file, const AdminPrx& admin, const Ice::Current
{
try
{
- return DescriptorParser::parseDescriptor(file, Ice::StringSeq(), map<string, string>(),
- current.adapter->getCommunicator(), admin);
+ return DescriptorParser::parseDescriptor(file, Ice::StringSeq(), map<string, string>(),
+ current.adapter->getCommunicator(), admin);
}
catch(const IceXML::ParserException& e)
{
- throw ParseException(e.reason());
+ throw ParseException(e.reason());
return ApplicationDescriptor();
}
}
diff --git a/cpp/src/IceGrid/FileUserAccountMapperI.cpp b/cpp/src/IceGrid/FileUserAccountMapperI.cpp
index b57b57af61a..0ab37bed844 100644
--- a/cpp/src/IceGrid/FileUserAccountMapperI.cpp
+++ b/cpp/src/IceGrid/FileUserAccountMapperI.cpp
@@ -20,55 +20,55 @@ FileUserAccountMapperI::FileUserAccountMapperI(const string& filename)
ifstream file(filename.c_str());
if(!file)
{
- throw "cannot open `" + filename + "' for reading: " + strerror(errno);
+ throw "cannot open `" + filename + "' for reading: " + strerror(errno);
}
-
+
const string delim = " \t\r\n";
while(true)
{
- string line;
- getline(file, line);
- if(!file)
- {
- break;
- }
+ string line;
+ getline(file, line);
+ if(!file)
+ {
+ break;
+ }
- string::size_type idx = line.find('#');
- if(idx != string::npos)
- {
- line.erase(idx);
- }
-
- idx = line.find_last_not_of(delim);
- if(idx != string::npos && idx + 1 < line.length())
- {
- line.erase(idx + 1);
- }
+ string::size_type idx = line.find('#');
+ if(idx != string::npos)
+ {
+ line.erase(idx);
+ }
+
+ idx = line.find_last_not_of(delim);
+ if(idx != string::npos && idx + 1 < line.length())
+ {
+ line.erase(idx + 1);
+ }
- string::size_type beg = line.find_first_not_of(delim);
- if(beg == string::npos)
- {
- continue;
- }
+ string::size_type beg = line.find_first_not_of(delim);
+ if(beg == string::npos)
+ {
+ continue;
+ }
- string::size_type end = line.find_first_of(delim, beg);
- if(end == string::npos || end <= beg)
- {
- continue;
- }
- string account = line.substr(beg, end - beg);
+ string::size_type end = line.find_first_of(delim, beg);
+ if(end == string::npos || end <= beg)
+ {
+ continue;
+ }
+ string account = line.substr(beg, end - beg);
- beg = line.find_first_not_of(delim, end);
- if(beg == string::npos)
- {
- continue;
- }
- string user = line.substr(beg);
-
- assert(!user.empty());
- assert(!account.empty());
+ beg = line.find_first_not_of(delim, end);
+ if(beg == string::npos)
+ {
+ continue;
+ }
+ string user = line.substr(beg);
+
+ assert(!user.empty());
+ assert(!account.empty());
- _accounts[user] = account;
+ _accounts[user] = account;
}
}
@@ -78,7 +78,7 @@ FileUserAccountMapperI::getUserAccount(const string& user, const Ice::Current&)
map<string, string>::const_iterator p = _accounts.find(user);
if(p == _accounts.end())
{
- throw UserAccountNotFoundException();
+ throw UserAccountNotFoundException();
}
return p->second;
}
diff --git a/cpp/src/IceGrid/IceGridNode.cpp b/cpp/src/IceGrid/IceGridNode.cpp
index 012e35f8333..3f38c508056 100644
--- a/cpp/src/IceGrid/IceGridNode.cpp
+++ b/cpp/src/IceGrid/IceGridNode.cpp
@@ -132,16 +132,16 @@ ProcessI::writeMessage(const string& message, Int fd, const Current&)
{
switch(fd)
{
- case 1:
- {
- cout << message << endl;
- break;
- }
- case 2:
- {
- cerr << message << endl;
- break;
- }
+ case 1:
+ {
+ cout << message << endl;
+ break;
+ }
+ case 2:
+ {
+ cerr << message << endl;
+ break;
+ }
}
}
@@ -196,12 +196,12 @@ NodeService::start(int argc, char* argv[])
targets.push_back(argv[i]);
}
}
- else
- {
- error("invalid option: `" + string(argv[i]) + "'");
- usage(argv[0]);
- return false;
- }
+ else
+ {
+ error("invalid option: `" + string(argv[i]) + "'");
+ usage(argv[0]);
+ return false;
+ }
}
PropertiesPtr properties = communicator()->getProperties();
@@ -222,59 +222,59 @@ NodeService::start(int argc, char* argv[])
//
if(!nowarn && properties->getPropertyAsIntWithDefault("Ice.ThreadPool.Server.Size", 0) > 0)
{
- Warning out(communicator()->getLogger());
- out << "setting `Ice.ThreadPool.Server.Size' is not useful,\n";
- out << "you should set individual adapter thread pools instead.";
+ Warning out(communicator()->getLogger());
+ out << "setting `Ice.ThreadPool.Server.Size' is not useful,\n";
+ out << "you should set individual adapter thread pools instead.";
}
//
// DEPRECATED PROPERTY: Remove extra code in future release
//
int size = properties->getPropertyAsIntWithDefault("Ice.OA.IceGrid.Node.ThreadPool.Size",
- properties->getPropertyAsIntWithDefault("IceGrid.Node.ThreadPool.Size", 0));
+ properties->getPropertyAsIntWithDefault("IceGrid.Node.ThreadPool.Size", 0));
if(size <= 0)
{
- properties->setProperty("Ice.OA.IceGrid.Node.ThreadPool.Size", "1");
- size = 1;
+ properties->setProperty("Ice.OA.IceGrid.Node.ThreadPool.Size", "1");
+ size = 1;
}
//
// DEPRECATED PROPERTY: Remove extra code in future release
//
int sizeMax = properties->getPropertyAsIntWithDefault("Ice.OA.IceGrid.Node.ThreadPool.SizeMax",
- properties->getPropertyAsIntWithDefault("IceGrid.Node.ThreadPool.SizeMax", 0));
+ properties->getPropertyAsIntWithDefault("IceGrid.Node.ThreadPool.SizeMax", 0));
if(sizeMax <= 0)
{
- if(size >= sizeMax)
- {
- sizeMax = size * 10;
- }
-
- ostringstream os;
- os << sizeMax;
- properties->setProperty("Ice.OA.IceGrid.Node.ThreadPool.SizeMax", os.str());
+ if(size >= sizeMax)
+ {
+ sizeMax = size * 10;
+ }
+
+ ostringstream os;
+ os << sizeMax;
+ properties->setProperty("Ice.OA.IceGrid.Node.ThreadPool.SizeMax", os.str());
}
size = properties->getPropertyAsIntWithDefault("Ice.ThreadPool.Client.Size", 0);
if(size <= 0)
{
- properties->setProperty("Ice.ThreadPool.Client.Size", "1");
- size = 1;
+ properties->setProperty("Ice.ThreadPool.Client.Size", "1");
+ size = 1;
}
sizeMax = properties->getPropertyAsIntWithDefault("Ice.ThreadPool.Client.SizeMax", 0);
if(sizeMax <= 0)
{
- if(size >= sizeMax)
- {
- sizeMax = size * 10;
- }
- if(sizeMax < 100)
- {
- sizeMax = 100;
- }
- ostringstream os;
- os << sizeMax;
- properties->setProperty("Ice.ThreadPool.Client.SizeMax", os.str());
+ if(size >= sizeMax)
+ {
+ sizeMax = size * 10;
+ }
+ if(sizeMax < 100)
+ {
+ sizeMax = 100;
+ }
+ ostringstream os;
+ os << sizeMax;
+ properties->setProperty("Ice.ThreadPool.Client.SizeMax", os.str());
}
//
@@ -294,27 +294,27 @@ NodeService::start(int argc, char* argv[])
return false;
}
- //
- // Set the default locator property to point to the collocated
- // locator (this property is passed by the activator to each
- // activated server). The default locator is also needed by
- // the node session manager.
//
- if(properties->getProperty("Ice.Default.Locator").empty())
- {
- Identity locatorId;
- locatorId.category = properties->getPropertyWithDefault("IceGrid.InstanceName", "IceGrid");
- locatorId.name = "Locator";
- //
- // DEPRECATED PROPERTY: Remove extra code in future release
- //
- string endpoints =
- properties->getPropertyWithDefault("Ice.OA.IceGrid.Registry.Client.Endpoints",
- properties->getProperty("IceGrid.Registry.Client.Endpoints"));
- string locatorPrx = "\"" + communicator()->identityToString(locatorId) + "\" :" + endpoints;
- communicator()->setDefaultLocator(LocatorPrx::uncheckedCast(communicator()->stringToProxy(locatorPrx)));
- properties->setProperty("Ice.Default.Locator", locatorPrx);
- }
+ // Set the default locator property to point to the collocated
+ // locator (this property is passed by the activator to each
+ // activated server). The default locator is also needed by
+ // the node session manager.
+ //
+ if(properties->getProperty("Ice.Default.Locator").empty())
+ {
+ Identity locatorId;
+ locatorId.category = properties->getPropertyWithDefault("IceGrid.InstanceName", "IceGrid");
+ locatorId.name = "Locator";
+ //
+ // DEPRECATED PROPERTY: Remove extra code in future release
+ //
+ string endpoints =
+ properties->getPropertyWithDefault("Ice.OA.IceGrid.Registry.Client.Endpoints",
+ properties->getProperty("IceGrid.Registry.Client.Endpoints"));
+ string locatorPrx = "\"" + communicator()->identityToString(locatorId) + "\" :" + endpoints;
+ communicator()->setDefaultLocator(LocatorPrx::uncheckedCast(communicator()->stringToProxy(locatorPrx)));
+ properties->setProperty("Ice.Default.Locator", locatorPrx);
+ }
}
else if(properties->getProperty("Ice.Default.Locator").empty())
{
@@ -338,25 +338,25 @@ NodeService::start(int argc, char* argv[])
struct _stat filestat;
if(::_stat(dataPath.c_str(), &filestat) != 0 || !S_ISDIR(filestat.st_mode))
{
- ostringstream os;
- FileException ex(__FILE__, __LINE__);
- ex.path = dataPath;
- ex.error = getSystemErrno();
- os << ex;
+ ostringstream os;
+ FileException ex(__FILE__, __LINE__);
+ ex.path = dataPath;
+ ex.error = getSystemErrno();
+ os << ex;
error("property `IceGrid.Node.Data' is set to an invalid path:\n" + os.str());
- return false;
+ return false;
}
#else
struct stat filestat;
if(::stat(dataPath.c_str(), &filestat) != 0 || !S_ISDIR(filestat.st_mode))
{
- ostringstream os;
- FileException ex(__FILE__, __LINE__);
- ex.path = dataPath;
- ex.error = getSystemErrno();
- os << ex;
+ ostringstream os;
+ FileException ex(__FILE__, __LINE__);
+ ex.path = dataPath;
+ ex.error = getSystemErrno();
+ os << ex;
error("property `IceGrid.Node.Data' is set to an invalid path:\n" + os.str());
- return false;
+ return false;
}
#endif
@@ -368,9 +368,9 @@ NodeService::start(int argc, char* argv[])
dataPath += "/";
}
- IcePatch2::createDirectory(dataPath + "servers");
- IcePatch2::createDirectory(dataPath + "tmp");
- IcePatch2::createDirectory(dataPath + "distrib");
+ IcePatch2::createDirectory(dataPath + "servers");
+ IcePatch2::createDirectory(dataPath + "tmp");
+ IcePatch2::createDirectory(dataPath + "distrib");
}
//
@@ -388,8 +388,8 @@ NodeService::start(int argc, char* argv[])
string name = properties->getProperty("IceGrid.Node.Name");
if(name.empty())
{
- error("property `IceGrid.Node.Name' is not set");
- return false;
+ error("property `IceGrid.Node.Name' is not set");
+ return false;
}
//
@@ -416,35 +416,35 @@ NodeService::start(int argc, char* argv[])
UserAccountMapperPrx mapper;
if(!mapperProperty.empty())
{
- try
- {
- mapper = UserAccountMapperPrx::uncheckedCast(communicator()->stringToProxy(mapperProperty));
- }
- catch(const Ice::LocalException& ex)
- {
- ostringstream os;
- os << "user account mapper `" << mapperProperty << "' is invalid:\n" << ex;
- error(os.str());
- return false;
- }
+ try
+ {
+ mapper = UserAccountMapperPrx::uncheckedCast(communicator()->stringToProxy(mapperProperty));
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ ostringstream os;
+ os << "user account mapper `" << mapperProperty << "' is invalid:\n" << ex;
+ error(os.str());
+ return false;
+ }
}
else
{
- string userAccountFileProperty = properties->getProperty("IceGrid.Node.UserAccounts");
- if(!userAccountFileProperty.empty())
- {
- try
- {
- Ice::ObjectPrx object = _adapter->addWithUUID(new FileUserAccountMapperI(userAccountFileProperty));
- object = object->ice_collocationOptimized(true);
- mapper = UserAccountMapperPrx::uncheckedCast(object);
- }
- catch(const std::string& msg)
- {
- error(msg);
- return false;
- }
- }
+ string userAccountFileProperty = properties->getProperty("IceGrid.Node.UserAccounts");
+ if(!userAccountFileProperty.empty())
+ {
+ try
+ {
+ Ice::ObjectPrx object = _adapter->addWithUUID(new FileUserAccountMapperI(userAccountFileProperty));
+ object = object->ice_collocationOptimized(true);
+ mapper = UserAccountMapperPrx::uncheckedCast(object);
+ }
+ catch(const std::string& msg)
+ {
+ error(msg);
+ return false;
+ }
+ }
}
//
@@ -479,18 +479,18 @@ NodeService::start(int argc, char* argv[])
//
if(!properties->getProperty("Ice.ServerId").empty() && communicator()->getDefaultLocator())
{
- try
- {
- ProcessPrx proxy = ProcessPrx::uncheckedCast(_adapter->addWithUUID(new ProcessI(_activator)));
- LocatorRegistryPrx locatorRegistry = communicator()->getDefaultLocator()->getRegistry();
- locatorRegistry->setServerProcessProxy(properties->getProperty("Ice.ServerId"), proxy);
- }
- catch(const ServerNotFoundException&)
- {
- }
- catch(const LocalException&)
- {
- }
+ try
+ {
+ ProcessPrx proxy = ProcessPrx::uncheckedCast(_adapter->addWithUUID(new ProcessI(_activator)));
+ LocatorRegistryPrx locatorRegistry = communicator()->getDefaultLocator()->getRegistry();
+ locatorRegistry->setServerProcessProxy(properties->getProperty("Ice.ServerId"), proxy);
+ }
+ catch(const ServerNotFoundException&)
+ {
+ }
+ catch(const LocalException&)
+ {
+ }
}
//
@@ -512,16 +512,16 @@ NodeService::start(int argc, char* argv[])
string bundleName = properties->getProperty("IceGrid.Node.PrintServersReady");
if(!bundleName.empty() || !desc.empty())
{
- enableInterrupt();
- if(!_sessions.waitForCreate())
- {
- //
- // Create was interrupted, return true as if the service was
- // correctly initiliazed to make sure it's properly stopped.
- //
- return true;
- }
- disableInterrupt();
+ enableInterrupt();
+ if(!_sessions.waitForCreate())
+ {
+ //
+ // Create was interrupted, return true as if the service was
+ // correctly initiliazed to make sure it's properly stopped.
+ //
+ return true;
+ }
+ disableInterrupt();
}
//
@@ -529,100 +529,100 @@ NodeService::start(int argc, char* argv[])
//
if(!desc.empty())
{
- try
- {
- Ice::Identity registryId;
- registryId.category = instanceName;
- registryId.name = "Registry";
-
- RegistryPrx registry = RegistryPrx::checkedCast(
- communicator()->stringToProxy("\"" + communicator()->identityToString(registryId) + "\""));
- if(!registry)
- {
- throw "invalid registry";
- }
-
- //
- // Use SSL if available.
- //
- try
- {
- registry = RegistryPrx::checkedCast(registry->ice_secure(true));
- }
- catch(const Ice::NoEndpointException&)
- {
- }
-
- IceGrid::AdminSessionPrx session;
- if(communicator()->getProperties()->getPropertyAsInt("IceGridAdmin.AuthenticateUsingSSL"))
- {
- session = registry->createAdminSessionFromSecureConnection();
- }
- else
- {
- string id = communicator()->getProperties()->getProperty("IceGridAdmin.Username");
- string password = communicator()->getProperties()->getProperty("IceGridAdmin.Password");
- while(id.empty())
- {
- cout << "user id: " << flush;
- getline(cin, id);
- id = trim(id);
- }
-
- if(password.empty())
- {
- cout << "password: " << flush;
- getline(cin, password);
- password = trim(password);
- }
-
- session = registry->createAdminSession(id, password);
- }
- assert(session);
-
- AdminPrx admin = session->getAdmin();
- map<string, string> vars;
- ApplicationDescriptor app = DescriptorParser::parseDescriptor(desc, targets, vars, communicator(), admin);
-
- try
- {
- admin->syncApplication(app);
- }
- catch(const ApplicationNotExistException&)
- {
- admin->addApplication(app);
- }
- }
- catch(const DeploymentException& ex)
- {
- ostringstream ostr;
- ostr << "failed to deploy application `" << desc << "':\n" << ex << ": " << ex.reason;
- warning(ostr.str());
- }
- catch(const AccessDeniedException& ex)
- {
- ostringstream ostr;
- ostr << "failed to deploy application `" << desc << "':\n"
- << "registry database is locked by `" << ex.lockUserId << "'";
- warning(ostr.str());
- }
- catch(const LocalException& ex)
- {
- ostringstream ostr;
- ostr << "failed to deploy application `" << desc << "':\n" << ex;
- warning(ostr.str());
- }
- catch(const string& reason)
- {
- ostringstream ostr;
- ostr << "failed to deploy application `" << desc << "':\n" << reason;
- warning(ostr.str());
- }
+ try
+ {
+ Ice::Identity registryId;
+ registryId.category = instanceName;
+ registryId.name = "Registry";
+
+ RegistryPrx registry = RegistryPrx::checkedCast(
+ communicator()->stringToProxy("\"" + communicator()->identityToString(registryId) + "\""));
+ if(!registry)
+ {
+ throw "invalid registry";
+ }
+
+ //
+ // Use SSL if available.
+ //
+ try
+ {
+ registry = RegistryPrx::checkedCast(registry->ice_secure(true));
+ }
+ catch(const Ice::NoEndpointException&)
+ {
+ }
+
+ IceGrid::AdminSessionPrx session;
+ if(communicator()->getProperties()->getPropertyAsInt("IceGridAdmin.AuthenticateUsingSSL"))
+ {
+ session = registry->createAdminSessionFromSecureConnection();
+ }
+ else
+ {
+ string id = communicator()->getProperties()->getProperty("IceGridAdmin.Username");
+ string password = communicator()->getProperties()->getProperty("IceGridAdmin.Password");
+ while(id.empty())
+ {
+ cout << "user id: " << flush;
+ getline(cin, id);
+ id = trim(id);
+ }
+
+ if(password.empty())
+ {
+ cout << "password: " << flush;
+ getline(cin, password);
+ password = trim(password);
+ }
+
+ session = registry->createAdminSession(id, password);
+ }
+ assert(session);
+
+ AdminPrx admin = session->getAdmin();
+ map<string, string> vars;
+ ApplicationDescriptor app = DescriptorParser::parseDescriptor(desc, targets, vars, communicator(), admin);
+
+ try
+ {
+ admin->syncApplication(app);
+ }
+ catch(const ApplicationNotExistException&)
+ {
+ admin->addApplication(app);
+ }
+ }
+ catch(const DeploymentException& ex)
+ {
+ ostringstream ostr;
+ ostr << "failed to deploy application `" << desc << "':\n" << ex << ": " << ex.reason;
+ warning(ostr.str());
+ }
+ catch(const AccessDeniedException& ex)
+ {
+ ostringstream ostr;
+ ostr << "failed to deploy application `" << desc << "':\n"
+ << "registry database is locked by `" << ex.lockUserId << "'";
+ warning(ostr.str());
+ }
+ catch(const LocalException& ex)
+ {
+ ostringstream ostr;
+ ostr << "failed to deploy application `" << desc << "':\n" << ex;
+ warning(ostr.str());
+ }
+ catch(const string& reason)
+ {
+ ostringstream ostr;
+ ostr << "failed to deploy application `" << desc << "':\n" << reason;
+ warning(ostr.str());
+ }
}
if(!bundleName.empty())
{
- print(bundleName + " ready");
+ print(bundleName + " ready");
}
return true;
@@ -649,7 +649,7 @@ NodeService::stop()
}
catch(...)
{
- assert(false);
+ assert(false);
}
//
@@ -659,11 +659,11 @@ NodeService::stop()
try
{
_waitQueue->destroy();
- _waitQueue = 0;
+ _waitQueue = 0;
}
catch(...)
{
- assert(false);
+ assert(false);
}
_activator = 0;
@@ -673,14 +673,14 @@ NodeService::stop()
//
try
{
- _adapter->deactivate();
- _adapter = 0;
+ _adapter->deactivate();
+ _adapter = 0;
}
catch(const Ice::LocalException& ex)
{
- ostringstream ostr;
- ostr << "unexpected exception while shutting down node:\n" << ex;
- warning(ostr.str());
+ ostringstream ostr;
+ ostr << "unexpected exception while shutting down node:\n" << ex;
+ warning(ostr.str());
}
//
@@ -704,9 +704,9 @@ NodeService::stop()
}
catch(const Ice::LocalException& ex)
{
- ostringstream ostr;
- ostr << "unexpected exception while shutting down node:\n" << ex;
- warning(ostr.str());
+ ostringstream ostr;
+ ostr << "unexpected exception while shutting down node:\n" << ex;
+ warning(ostr.str());
}
//
@@ -714,8 +714,8 @@ NodeService::stop()
//
if(_registry)
{
- _registry->stop();
- _registry = 0;
+ _registry->stop();
+ _registry = 0;
}
return true;
@@ -723,7 +723,7 @@ NodeService::stop()
CommunicatorPtr
NodeService::initializeCommunicator(int& argc, char* argv[],
- const InitializationData& initializationData)
+ const InitializationData& initializationData)
{
InitializationData initData = initializationData;
initData.properties = createProperties(argc, argv, initData.properties);
@@ -742,35 +742,35 @@ void
NodeService::usage(const string& appName)
{
string options =
- "Options:\n"
- "-h, --help Show this message.\n"
- "-v, --version Display the Ice version.\n"
- "--nowarn Don't print any security warnings.\n"
- "\n"
- "--deploy DESCRIPTOR [TARGET1 [TARGET2 ...]]\n"
- " Add or update descriptor in file DESCRIPTOR, with\n"
- " optional targets.\n";
+ "Options:\n"
+ "-h, --help Show this message.\n"
+ "-v, --version Display the Ice version.\n"
+ "--nowarn Don't print any security warnings.\n"
+ "\n"
+ "--deploy DESCRIPTOR [TARGET1 [TARGET2 ...]]\n"
+ " Add or update descriptor in file DESCRIPTOR, with\n"
+ " optional targets.\n";
#ifdef _WIN32
if(checkSystem())
{
options.append(
- "\n"
- "\n"
- "--service NAME Run as the Windows service NAME.\n"
- "\n"
- "--install NAME [--display DISP] [--executable EXEC] [args]\n"
- " Install as Windows service NAME. If DISP is\n"
- " provided, use it as the display name,\n"
- " otherwise NAME is used. If EXEC is provided,\n"
- " use it as the service executable, otherwise\n"
- " this executable is used. Any additional\n"
- " arguments are passed unchanged to the\n"
- " service at startup.\n"
- "--uninstall NAME Uninstall Windows service NAME.\n"
- "--start NAME [args] Start Windows service NAME. Any additional\n"
- " arguments are passed unchanged to the\n"
- " service.\n"
- "--stop NAME Stop Windows service NAME."
+ "\n"
+ "\n"
+ "--service NAME Run as the Windows service NAME.\n"
+ "\n"
+ "--install NAME [--display DISP] [--executable EXEC] [args]\n"
+ " Install as Windows service NAME. If DISP is\n"
+ " provided, use it as the display name,\n"
+ " otherwise NAME is used. If EXEC is provided,\n"
+ " use it as the service executable, otherwise\n"
+ " this executable is used. Any additional\n"
+ " arguments are passed unchanged to the\n"
+ " service at startup.\n"
+ "--uninstall NAME Uninstall Windows service NAME.\n"
+ "--start NAME [args] Start Windows service NAME. Any additional\n"
+ " arguments are passed unchanged to the\n"
+ " service.\n"
+ "--stop NAME Stop Windows service NAME."
);
}
#else
@@ -780,7 +780,7 @@ NodeService::usage(const string& appName)
"--daemon Run as a daemon.\n"
"--noclose Do not close open file descriptors.\n"
"--nochdir Do not change the current working directory.\n"
- "--pidfile <file> Write process ID to <file>."
+ "--pidfile <file> Write process ID to <file>."
);
#endif
print("Usage: " + appName + " [options]\n" + options);
diff --git a/cpp/src/IceGrid/IceGridRegistry.cpp b/cpp/src/IceGrid/IceGridRegistry.cpp
index 825dc50bd4a..413a0264fd7 100644
--- a/cpp/src/IceGrid/IceGridRegistry.cpp
+++ b/cpp/src/IceGrid/IceGridRegistry.cpp
@@ -76,31 +76,31 @@ RegistryService::start(int argc, char* argv[])
vector<string> args;
try
{
- args = opts.parse(argc, (const char**)argv);
+ args = opts.parse(argc, (const char**)argv);
}
catch(const IceUtil::BadOptException& e)
{
error(e.reason);
- usage(argv[0]);
- return false;
+ usage(argv[0]);
+ return false;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return false;
+ usage(argv[0]);
+ return false;
}
if(opts.isSet("version"))
{
- print(ICE_STRING_VERSION);
- return false;
+ print(ICE_STRING_VERSION);
+ return false;
}
nowarn = opts.isSet("nowarn");
if(!args.empty())
{
- usage(argv[0]);
- return false;
+ usage(argv[0]);
+ return false;
}
Ice::PropertiesPtr properties = communicator()->getProperties();
@@ -110,9 +110,9 @@ RegistryService::start(int argc, char* argv[])
//
if(!nowarn && properties->getPropertyAsIntWithDefault("Ice.ThreadPool.Server.Size", 0) > 0)
{
- Warning out(communicator()->getLogger());
- out << "setting `Ice.ThreadPool.Server.Size' is not useful,\n";
- out << "you should set individual adapter thread pools instead.";
+ Warning out(communicator()->getLogger());
+ out << "setting `Ice.ThreadPool.Server.Size' is not useful,\n";
+ out << "you should set individual adapter thread pools instead.";
}
TraceLevelsPtr traceLevels = new TraceLevels(communicator(), "IceGrid.Registry");
@@ -120,7 +120,7 @@ RegistryService::start(int argc, char* argv[])
_registry = new RegistryI(communicator(), traceLevels);
if(!_registry->start(nowarn))
{
- return false;
+ return false;
}
return true;
@@ -147,7 +147,7 @@ RegistryService::stop()
CommunicatorPtr
RegistryService::initializeCommunicator(int& argc, char* argv[],
- const InitializationData& initializationData)
+ const InitializationData& initializationData)
{
InitializationData initData = initializationData;
initData.properties = createProperties(argc, argv, initData.properties);
@@ -166,31 +166,31 @@ void
RegistryService::usage(const string& appName)
{
string options =
- "Options:\n"
- "-h, --help Show this message.\n"
- "-v, --version Display the Ice version.\n"
- "--nowarn Don't print any security warnings.";
+ "Options:\n"
+ "-h, --help Show this message.\n"
+ "-v, --version Display the Ice version.\n"
+ "--nowarn Don't print any security warnings.";
#ifdef _WIN32
if(checkSystem())
{
options.append(
- "\n"
- "\n"
- "--service NAME Run as the Windows service NAME.\n"
- "\n"
- "--install NAME [--display DISP] [--executable EXEC] [args]\n"
- " Install as Windows service NAME. If DISP is\n"
- " provided, use it as the display name,\n"
- " otherwise NAME is used. If EXEC is provided,\n"
- " use it as the service executable, otherwise\n"
- " this executable is used. Any additional\n"
- " arguments are passed unchanged to the\n"
- " service at startup.\n"
- "--uninstall NAME Uninstall Windows service NAME.\n"
- "--start NAME [args] Start Windows service NAME. Any additional\n"
- " arguments are passed unchanged to the\n"
- " service.\n"
- "--stop NAME Stop Windows service NAME."
+ "\n"
+ "\n"
+ "--service NAME Run as the Windows service NAME.\n"
+ "\n"
+ "--install NAME [--display DISP] [--executable EXEC] [args]\n"
+ " Install as Windows service NAME. If DISP is\n"
+ " provided, use it as the display name,\n"
+ " otherwise NAME is used. If EXEC is provided,\n"
+ " use it as the service executable, otherwise\n"
+ " this executable is used. Any additional\n"
+ " arguments are passed unchanged to the\n"
+ " service at startup.\n"
+ "--uninstall NAME Uninstall Windows service NAME.\n"
+ "--start NAME [args] Start Windows service NAME. Any additional\n"
+ " arguments are passed unchanged to the\n"
+ " service.\n"
+ "--stop NAME Stop Windows service NAME."
);
}
#else
@@ -199,8 +199,8 @@ RegistryService::usage(const string& appName)
"\n"
"--daemon Run as a daemon.\n"
"--noclose Do not close open file descriptors.\n"
- "--nochdir Do not change the current working directory.\n"
- "--pidfile <file> Write process ID to <file>."
+ "--nochdir Do not change the current working directory.\n"
+ "--pidfile <file> Write process ID to <file>."
);
#endif
print("Usage: " + appName + " [options]\n" + options);
diff --git a/cpp/src/IceGrid/Internal.ice b/cpp/src/IceGrid/Internal.ice
index da569db2803..ed516ff5822 100644
--- a/cpp/src/IceGrid/Internal.ice
+++ b/cpp/src/IceGrid/Internal.ice
@@ -159,7 +159,7 @@ interface Adapter
*
**/
["ami", "nonmutating", "cpp:const"] idempotent Object* getDirectProxy()
- throws AdapterNotActiveException;
+ throws AdapterNotActiveException;
/**
*
@@ -175,7 +175,7 @@ interface Adapter
*
**/
["ami"] void setDirectProxy(Object* proxy)
- throws AdapterActiveException;
+ throws AdapterActiveException;
};
/**
@@ -200,7 +200,7 @@ interface FileReader
*
**/
["cpp:const"] idempotent long getOffsetFromEnd(string filename, int lines)
- throws FileNotAvailableException;
+ throws FileNotAvailableException;
/**
*
@@ -208,7 +208,7 @@ interface FileReader
*
**/
["cpp:const"] idempotent bool read(string filename, long pos, int size, out long newPos, out Ice::StringSeq lines)
- throws FileNotAvailableException;
+ throws FileNotAvailableException;
};
interface Server extends FileReader
@@ -222,7 +222,7 @@ interface Server extends FileReader
*
**/
["amd"] void start()
- throws ServerStartException;
+ throws ServerStartException;
/**
*
@@ -232,7 +232,7 @@ interface Server extends FileReader
*
**/
["amd"] void stop()
- throws ServerStopException;
+ throws ServerStopException;
/**
*
@@ -254,7 +254,7 @@ interface Server extends FileReader
*
**/
void sendSignal(string signal)
- throws BadSignalException;
+ throws BadSignalException;
/**
*
@@ -348,11 +348,11 @@ interface Node extends FileReader, ReplicaObserver
*
**/
["amd", "ami"] idempotent Server* loadServer(InternalServerDescriptor svr,
- string replicaName,
- out AdapterPrxDict adapters,
- out int actTimeout,
- out int deactTimeout)
- throws DeploymentException;
+ string replicaName,
+ out AdapterPrxDict adapters,
+ out int actTimeout,
+ out int deactTimeout)
+ throws DeploymentException;
/**
*
@@ -360,7 +360,7 @@ interface Node extends FileReader, ReplicaObserver
*
**/
["amd", "ami"] idempotent void destroyServer(string name, string uuid, int revision, string replicaName)
- throws DeploymentException;
+ throws DeploymentException;
/**
*
@@ -371,10 +371,10 @@ interface Node extends FileReader, ReplicaObserver
*
**/
["amd"] idempotent void patch(PatcherFeedback* feedback,
- string application,
- string server,
- InternalDistributionDescriptor appDistrib,
- bool shutdown);
+ string application,
+ string server,
+ InternalDistributionDescriptor appDistrib,
+ bool shutdown);
/**
*
@@ -562,7 +562,7 @@ interface ReplicaSession
*
**/
["ami"] idempotent void setAdapterDirectProxy(string adapterId, string replicaGroupId, Object* proxy)
- throws AdapterNotExistException, AdapterExistsException;
+ throws AdapterNotExistException, AdapterExistsException;
/**
*
@@ -690,7 +690,7 @@ interface InternalRegistry extends FileReader
*
**/
NodeSession* registerNode(InternalNodeInfo info, Node* prx, LoadInfo loadInf)
- throws NodeActiveException;
+ throws NodeActiveException;
/**
*
@@ -709,7 +709,7 @@ interface InternalRegistry extends FileReader
*
**/
ReplicaSession* registerReplica(InternalReplicaInfo info, InternalRegistry* prx)
- throws ReplicaActiveException;
+ throws ReplicaActiveException;
/**
*
diff --git a/cpp/src/IceGrid/InternalRegistryI.cpp b/cpp/src/IceGrid/InternalRegistryI.cpp
index 997d2b1769a..ae54ddda0cf 100644
--- a/cpp/src/IceGrid/InternalRegistryI.cpp
+++ b/cpp/src/IceGrid/InternalRegistryI.cpp
@@ -24,10 +24,10 @@ using namespace std;
using namespace IceGrid;
InternalRegistryI::InternalRegistryI(const RegistryIPtr& registry,
- const DatabasePtr& database,
- const ReapThreadPtr& reaper,
- const WellKnownObjectsManagerPtr& wellKnownObjects,
- ReplicaSessionManager& session) :
+ const DatabasePtr& database,
+ const ReapThreadPtr& reaper,
+ const WellKnownObjectsManagerPtr& wellKnownObjects,
+ ReplicaSessionManager& session) :
_registry(registry),
_database(database),
_reaper(reaper),
@@ -46,38 +46,38 @@ InternalRegistryI::~InternalRegistryI()
NodeSessionPrx
InternalRegistryI::registerNode(const InternalNodeInfoPtr& info,
- const NodePrx& node,
- const LoadInfo& load,
- const Ice::Current& current)
+ const NodePrx& node,
+ const LoadInfo& load,
+ const Ice::Current& current)
{
const Ice::LoggerPtr logger = _database->getTraceLevels()->logger;
try
{
- NodeSessionIPtr session = new NodeSessionI(_database, node, info, _nodeSessionTimeout, load);
- _reaper->add(new SessionReapable<NodeSessionI>(logger, session), _nodeSessionTimeout);
- return session->getProxy();
+ NodeSessionIPtr session = new NodeSessionI(_database, node, info, _nodeSessionTimeout, load);
+ _reaper->add(new SessionReapable<NodeSessionI>(logger, session), _nodeSessionTimeout);
+ return session->getProxy();
}
catch(const Ice::ObjectAdapterDeactivatedException&)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
}
}
ReplicaSessionPrx
InternalRegistryI::registerReplica(const InternalReplicaInfoPtr& info,
- const InternalRegistryPrx& prx,
- const Ice::Current& current)
+ const InternalRegistryPrx& prx,
+ const Ice::Current& current)
{
const Ice::LoggerPtr logger = _database->getTraceLevels()->logger;
try
{
- ReplicaSessionIPtr s = new ReplicaSessionI(_database, _wellKnownObjects, info, prx, _replicaSessionTimeout);
- _reaper->add(new SessionReapable<ReplicaSessionI>(logger, s), _replicaSessionTimeout);
- return s->getProxy();
+ ReplicaSessionIPtr s = new ReplicaSessionI(_database, _wellKnownObjects, info, prx, _replicaSessionTimeout);
+ _reaper->add(new SessionReapable<ReplicaSessionI>(logger, s), _replicaSessionTimeout);
+ return s->getProxy();
}
catch(const Ice::ObjectAdapterDeactivatedException&)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__, current.id, current.facet, current.operation);
}
}
@@ -94,7 +94,7 @@ InternalRegistryI::getNodes(const Ice::Current&) const
Ice::ObjectProxySeq proxies = _database->getInternalObjectsByType(Node::ice_staticId());
for(Ice::ObjectProxySeq::const_iterator p = proxies.begin(); p != proxies.end(); ++p)
{
- nodes.push_back(NodePrx::uncheckedCast(*p));
+ nodes.push_back(NodePrx::uncheckedCast(*p));
}
return nodes;
}
@@ -106,7 +106,7 @@ InternalRegistryI::getReplicas(const Ice::Current&) const
Ice::ObjectProxySeq proxies = _database->getObjectsByType(InternalRegistry::ice_staticId());
for(Ice::ObjectProxySeq::const_iterator p = proxies.begin(); p != proxies.end(); ++p)
{
- replicas.push_back(InternalRegistryPrx::uncheckedCast(*p));
+ replicas.push_back(InternalRegistryPrx::uncheckedCast(*p));
}
return replicas;
}
@@ -125,7 +125,7 @@ InternalRegistryI::getOffsetFromEnd(const string& filename, int count, const Ice
bool
InternalRegistryI::read(const string& filename, Ice::Long pos, int size, Ice::Long& newPos, Ice::StringSeq& lines,
- const Ice::Current&) const
+ const Ice::Current&) const
{
return _fileCache->read(getFilePath(filename), pos, size, newPos, lines);
}
@@ -136,23 +136,23 @@ InternalRegistryI::getFilePath(const string& filename) const
string file;
if(filename == "stderr")
{
- file = _database->getCommunicator()->getProperties()->getProperty("Ice.StdErr");
- if(file.empty())
- {
- throw FileNotAvailableException("Ice.StdErr configuration property is not set");
- }
+ file = _database->getCommunicator()->getProperties()->getProperty("Ice.StdErr");
+ if(file.empty())
+ {
+ throw FileNotAvailableException("Ice.StdErr configuration property is not set");
+ }
}
else if(filename == "stdout")
{
- file = _database->getCommunicator()->getProperties()->getProperty("Ice.StdOut");
- if(file.empty())
- {
- throw FileNotAvailableException("Ice.StdOut configuration property is not set");
- }
+ file = _database->getCommunicator()->getProperties()->getProperty("Ice.StdOut");
+ if(file.empty())
+ {
+ throw FileNotAvailableException("Ice.StdOut configuration property is not set");
+ }
}
else
{
- throw FileNotAvailableException("unknown file");
+ throw FileNotAvailableException("unknown file");
}
return file;
}
diff --git a/cpp/src/IceGrid/InternalRegistryI.h b/cpp/src/IceGrid/InternalRegistryI.h
index d528e8ce088..e13e292b8e9 100644
--- a/cpp/src/IceGrid/InternalRegistryI.h
+++ b/cpp/src/IceGrid/InternalRegistryI.h
@@ -38,13 +38,13 @@ class InternalRegistryI : public InternalRegistry
public:
InternalRegistryI(const RegistryIPtr&, const DatabasePtr&, const ReapThreadPtr&,
- const WellKnownObjectsManagerPtr&, ReplicaSessionManager&);
+ const WellKnownObjectsManagerPtr&, ReplicaSessionManager&);
virtual ~InternalRegistryI();
virtual NodeSessionPrx registerNode(const InternalNodeInfoPtr&, const NodePrx&, const LoadInfo&,
- const Ice::Current&);
+ const Ice::Current&);
virtual ReplicaSessionPrx registerReplica(const InternalReplicaInfoPtr&, const InternalRegistryPrx&,
- const Ice::Current&);
+ const Ice::Current&);
virtual void registerWithReplica(const InternalRegistryPrx&, const Ice::Current&);
diff --git a/cpp/src/IceGrid/LocatorI.cpp b/cpp/src/IceGrid/LocatorI.cpp
index 58cd8503f7a..9158def55ff 100644
--- a/cpp/src/IceGrid/LocatorI.cpp
+++ b/cpp/src/IceGrid/LocatorI.cpp
@@ -27,19 +27,19 @@ class AMI_Adapter_getDirectProxyI : public AMI_Adapter_getDirectProxy
public:
AMI_Adapter_getDirectProxyI(const LocatorIPtr& locator, const string& id, const LocatorAdapterInfo& adapter) :
- _locator(locator), _id(id), _adapter(adapter)
+ _locator(locator), _id(id), _adapter(adapter)
{
}
virtual void ice_response(const ::Ice::ObjectPrx& obj)
{
- assert(obj);
- _locator->getDirectProxyCallback(_adapter.proxy->ice_getIdentity(), obj);
+ assert(obj);
+ _locator->getDirectProxyCallback(_adapter.proxy->ice_getIdentity(), obj);
}
virtual void ice_exception(const ::Ice::Exception& ex)
{
- _locator->getDirectProxyException(_adapter, _id, ex);
+ _locator->getDirectProxyException(_adapter, _id, ex);
}
private:
@@ -54,18 +54,18 @@ class AMI_Adapter_activateI : public AMI_Adapter_activate
public:
AMI_Adapter_activateI(const LocatorIPtr& locator, const string& id, const LocatorAdapterInfo& adapter) :
- _locator(locator), _id(id), _adapter(adapter)
+ _locator(locator), _id(id), _adapter(adapter)
{
}
virtual void ice_response(const ::Ice::ObjectPrx& obj)
{
- _locator->getDirectProxyCallback(_adapter.proxy->ice_getIdentity(), obj);
+ _locator->getDirectProxyCallback(_adapter.proxy->ice_getIdentity(), obj);
}
virtual void ice_exception(const ::Ice::Exception& ex)
{
- _locator->getDirectProxyException(_adapter, _id, ex);
+ _locator->getDirectProxyException(_adapter, _id, ex);
}
private:
@@ -84,66 +84,66 @@ class AMD_Locator_findAdapterByIdI : public Ice::AMD_Locator_findAdapterById
public:
AMD_Locator_findAdapterByIdI(const Ice::AMD_Locator_findObjectByIdPtr& cb, const Ice::ObjectPrx& obj) :
- _cb(cb),
- _obj(obj)
+ _cb(cb),
+ _obj(obj)
{
}
virtual void ice_response(const ::Ice::ObjectPrx& obj)
{
- //
- // If the adapter dummy direct proxy is not null, return a
- // proxy containing the identity we were looking for and the
- // endpoints of the adapter.
- //
- // If null, return the proxy registered with the object
- // registry.
- //
- if(obj)
- {
- _cb->ice_response(obj->ice_identity(_obj->ice_getIdentity()));
- }
- else
- {
- _cb->ice_response(_obj);
- }
+ //
+ // If the adapter dummy direct proxy is not null, return a
+ // proxy containing the identity we were looking for and the
+ // endpoints of the adapter.
+ //
+ // If null, return the proxy registered with the object
+ // registry.
+ //
+ if(obj)
+ {
+ _cb->ice_response(obj->ice_identity(_obj->ice_getIdentity()));
+ }
+ else
+ {
+ _cb->ice_response(_obj);
+ }
}
virtual void ice_exception(const ::Ice::Exception& ex)
{
- try
- {
- ex.ice_throw();
- }
- catch(Ice::AdapterNotFoundException&)
- {
- //
- // We couldn't find the adapter, we ignore and return the
- // original proxy containing the adapter id.
- //
- _cb->ice_response(_obj);
- return;
- }
- catch(const Ice::Exception& ex)
- {
- //
- // Rethrow unexpected exception.
- //
- _cb->ice_exception(ex);
- return;
- }
-
- assert(false);
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(Ice::AdapterNotFoundException&)
+ {
+ //
+ // We couldn't find the adapter, we ignore and return the
+ // original proxy containing the adapter id.
+ //
+ _cb->ice_response(_obj);
+ return;
+ }
+ catch(const Ice::Exception& ex)
+ {
+ //
+ // Rethrow unexpected exception.
+ //
+ _cb->ice_exception(ex);
+ return;
+ }
+
+ assert(false);
}
virtual void ice_exception(const std::exception& ex)
{
- _cb->ice_exception(ex);
+ _cb->ice_exception(ex);
}
virtual void ice_exception()
{
- _cb->ice_exception();
+ _cb->ice_exception();
}
private:
@@ -155,12 +155,12 @@ private:
}
LocatorI::Request::Request(const Ice::AMD_Locator_findAdapterByIdPtr& amdCB,
- const LocatorIPtr& locator,
- const string& id,
- bool replicaGroup,
- const LocatorAdapterInfoSeq& adapters,
- int count,
- const TraceLevelsPtr& traceLevels) :
+ const LocatorIPtr& locator,
+ const string& id,
+ bool replicaGroup,
+ const LocatorAdapterInfoSeq& adapters,
+ int count,
+ const TraceLevelsPtr& traceLevels) :
_amdCB(amdCB),
_locator(locator),
_id(id),
@@ -182,8 +182,8 @@ LocatorI::Request::execute()
//
if(_adapters.empty())
{
- sendResponse();
- return;
+ sendResponse();
+ return;
}
//
@@ -191,24 +191,24 @@ LocatorI::Request::execute()
//
LocatorAdapterInfoSeq adapters;
{
- Lock sync(*this);
- assert(_count > 0 && _lastAdapter != _adapters.end());
- for(unsigned int i = 0; i < _count; ++i)
- {
- if(_lastAdapter == _adapters.end())
- {
- _count = i;
- break;
- }
- assert(_lastAdapter->proxy);
- adapters.push_back(*_lastAdapter);
- ++_lastAdapter;
- }
+ Lock sync(*this);
+ assert(_count > 0 && _lastAdapter != _adapters.end());
+ for(unsigned int i = 0; i < _count; ++i)
+ {
+ if(_lastAdapter == _adapters.end())
+ {
+ _count = i;
+ break;
+ }
+ assert(_lastAdapter->proxy);
+ adapters.push_back(*_lastAdapter);
+ ++_lastAdapter;
+ }
}
assert(!adapters.empty());
for(LocatorAdapterInfoSeq::const_iterator p = adapters.begin(); p != adapters.end(); ++p)
{
- requestAdapter(*p);
+ requestAdapter(*p);
}
}
@@ -217,32 +217,32 @@ LocatorI::Request::exception(const Ice::Exception& ex)
{
LocatorAdapterInfo adapter;
{
- Lock sync(*this);
-
- if(!_exception.get())
- {
- _exception.reset(ex.ice_clone());
- }
-
- if(_lastAdapter == _adapters.end())
- {
- --_count; // Expect one less adapter proxy if there's no more adapters to query.
-
- //
- // If we received all the required proxies, it's time to send the
- // answer back to the client.
- //
- if(_count == _proxies.size())
- {
- sendResponse();
- }
- return;
- }
- else
- {
- adapter = *_lastAdapter;
- ++_lastAdapter;
- }
+ Lock sync(*this);
+
+ if(!_exception.get())
+ {
+ _exception.reset(ex.ice_clone());
+ }
+
+ if(_lastAdapter == _adapters.end())
+ {
+ --_count; // Expect one less adapter proxy if there's no more adapters to query.
+
+ //
+ // If we received all the required proxies, it's time to send the
+ // answer back to the client.
+ //
+ if(_count == _proxies.size())
+ {
+ sendResponse();
+ }
+ return;
+ }
+ else
+ {
+ adapter = *_lastAdapter;
+ ++_lastAdapter;
+ }
}
requestAdapter(adapter);
}
@@ -261,7 +261,7 @@ LocatorI::Request::response(const Ice::ObjectPrx& proxy)
//
if(_proxies.size() == _count)
{
- sendResponse();
+ sendResponse();
}
}
@@ -271,8 +271,8 @@ LocatorI::Request::requestAdapter(const LocatorAdapterInfo& adapter)
assert(adapter.proxy);
if(_locator->getDirectProxyRequest(this, adapter))
{
- AMI_Adapter_getDirectProxyPtr amiCB = new AMI_Adapter_getDirectProxyI(_locator, _id, adapter);
- adapter.proxy->getDirectProxy_async(amiCB);
+ AMI_Adapter_getDirectProxyPtr amiCB = new AMI_Adapter_getDirectProxyI(_locator, _id, adapter);
+ adapter.proxy->getDirectProxy_async(amiCB);
}
}
@@ -281,45 +281,45 @@ LocatorI::Request::sendResponse()
{
if(_proxies.size() == 1)
{
- _amdCB->ice_response(_proxies.back());
+ _amdCB->ice_response(_proxies.back());
}
else if(_proxies.empty())
{
- //
- // If there's no proxies, it's either because we couldn't
- // contact the adapters or because the replica group has
- // no members.
- //
- assert(_exception.get() || _replicaGroup && _adapters.empty());
-
- if(_traceLevels->locator > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
- out << "couldn't resolve " << (_replicaGroup ? "replica group `" : "adapter `") << _id << "' endpoints:\n";
- out << (_exception.get() ? toString(*_exception) : string("replica group is empty"));
- }
- _amdCB->ice_response(0);
+ //
+ // If there's no proxies, it's either because we couldn't
+ // contact the adapters or because the replica group has
+ // no members.
+ //
+ assert(_exception.get() || _replicaGroup && _adapters.empty());
+
+ if(_traceLevels->locator > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
+ out << "couldn't resolve " << (_replicaGroup ? "replica group `" : "adapter `") << _id << "' endpoints:\n";
+ out << (_exception.get() ? toString(*_exception) : string("replica group is empty"));
+ }
+ _amdCB->ice_response(0);
}
else if(_proxies.size() > 1)
{
- Ice::EndpointSeq endpoints;
- endpoints.reserve(_proxies.size());
- for(vector<Ice::ObjectPrx>::const_iterator p = _proxies.begin(); p != _proxies.end(); ++p)
- {
- Ice::EndpointSeq edpts = (*p)->ice_getEndpoints();
- endpoints.insert(endpoints.end(), edpts.begin(), edpts.end());
- }
+ Ice::EndpointSeq endpoints;
+ endpoints.reserve(_proxies.size());
+ for(vector<Ice::ObjectPrx>::const_iterator p = _proxies.begin(); p != _proxies.end(); ++p)
+ {
+ Ice::EndpointSeq edpts = (*p)->ice_getEndpoints();
+ endpoints.insert(endpoints.end(), edpts.begin(), edpts.end());
+ }
- Ice::ObjectPrx proxy = _locator->getCommunicator()->stringToProxy("dummy:default");
- _amdCB->ice_response(proxy->ice_endpoints(endpoints));
+ Ice::ObjectPrx proxy = _locator->getCommunicator()->stringToProxy("dummy:default");
+ _amdCB->ice_response(proxy->ice_endpoints(endpoints));
}
}
LocatorI::LocatorI(const Ice::CommunicatorPtr& communicator,
- const DatabasePtr& database,
- const Ice::LocatorRegistryPrx& locatorRegistry,
- const RegistryPrx& registry,
- const QueryPrx& query) :
+ const DatabasePtr& database,
+ const Ice::LocatorRegistryPrx& locatorRegistry,
+ const RegistryPrx& registry,
+ const QueryPrx& query) :
_communicator(communicator),
_database(database),
_locatorRegistry(locatorRegistry),
@@ -334,17 +334,17 @@ LocatorI::LocatorI(const Ice::CommunicatorPtr& communicator,
//
void
LocatorI::findObjectById_async(const Ice::AMD_Locator_findObjectByIdPtr& cb,
- const Ice::Identity& id,
- const Ice::Current& current) const
+ const Ice::Identity& id,
+ const Ice::Current& current) const
{
Ice::ObjectPrx proxy;
try
{
- proxy = _database->getObjectProxy(id);
+ proxy = _database->getObjectProxy(id);
}
catch(const ObjectNotRegisteredException&)
{
- throw Ice::ObjectNotFoundException();
+ throw Ice::ObjectNotFoundException();
}
assert(proxy);
@@ -358,12 +358,12 @@ LocatorI::findObjectById_async(const Ice::AMD_Locator_findObjectByIdPtr& cb,
const string adapterId = proxy->ice_getAdapterId();
if(!adapterId.empty())
{
- Ice::AMD_Locator_findAdapterByIdPtr amiCB = new AMD_Locator_findAdapterByIdI(cb, proxy);
- findAdapterById_async(amiCB, adapterId, current);
+ Ice::AMD_Locator_findAdapterByIdPtr amiCB = new AMD_Locator_findAdapterByIdI(cb, proxy);
+ findAdapterById_async(amiCB, adapterId, current);
}
else
{
- cb->ice_response(proxy);
+ cb->ice_response(proxy);
}
}
@@ -373,54 +373,54 @@ LocatorI::findObjectById_async(const Ice::AMD_Locator_findObjectByIdPtr& cb,
//
void
LocatorI::findAdapterById_async(const Ice::AMD_Locator_findAdapterByIdPtr& cb,
- const string& id,
- const Ice::Current&) const
+ const string& id,
+ const Ice::Current&) const
{
bool replicaGroup = false;
try
{
- //
- // NOTE: getProxies() might throw if the adapter is a server
- // adapter and the node is unreachable (it doesn't throw for
- // replica groups).
- //
- int count;
- LocatorAdapterInfoSeq adapters;
- _database->getAdapter(id)->getLocatorAdapterInfo(adapters, count, replicaGroup);
+ //
+ // NOTE: getProxies() might throw if the adapter is a server
+ // adapter and the node is unreachable (it doesn't throw for
+ // replica groups).
+ //
+ int count;
+ LocatorAdapterInfoSeq adapters;
+ _database->getAdapter(id)->getLocatorAdapterInfo(adapters, count, replicaGroup);
- LocatorIPtr self = const_cast<LocatorI*>(this);
- RequestPtr request = new Request(cb, self, id, replicaGroup, adapters, count, _database->getTraceLevels());
- request->execute();
+ LocatorIPtr self = const_cast<LocatorI*>(this);
+ RequestPtr request = new Request(cb, self, id, replicaGroup, adapters, count, _database->getTraceLevels());
+ request->execute();
}
catch(const AdapterNotExistException&)
{
- try
- {
- cb->ice_response(_database->getAdapterDirectProxy(id));
- }
- catch(const AdapterNotExistException&)
- {
- cb->ice_exception(Ice::AdapterNotFoundException());
- }
- return;
+ try
+ {
+ cb->ice_response(_database->getAdapterDirectProxy(id));
+ }
+ catch(const AdapterNotExistException&)
+ {
+ cb->ice_exception(Ice::AdapterNotFoundException());
+ }
+ return;
}
catch(const Ice::Exception& ex)
{
- const TraceLevelsPtr traceLevels = _database->getTraceLevels();
- if(traceLevels->locator > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
- if(replicaGroup)
- {
- out << "couldn't resolve replica group `" << id << "' endpoints:\n" << toString(ex);
- }
- else
- {
- out << "couldn't resolve adapter `" << id << "' endpoints:\n" << toString(ex);
- }
- }
- cb->ice_response(0);
- return;
+ const TraceLevelsPtr traceLevels = _database->getTraceLevels();
+ if(traceLevels->locator > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
+ if(replicaGroup)
+ {
+ out << "couldn't resolve replica group `" << id << "' endpoints:\n" << toString(ex);
+ }
+ else
+ {
+ out << "couldn't resolve adapter `" << id << "' endpoints:\n" << toString(ex);
+ }
+ }
+ cb->ice_response(0);
+ return;
}
}
@@ -463,24 +463,24 @@ LocatorI::getDirectProxyException(const LocatorAdapterInfo& adpt, const string&
{
try
{
- ex.ice_throw();
+ ex.ice_throw();
}
catch(const AdapterNotActiveException& ex)
{
- if(ex.activatable)
- {
- //
- // Activate the adapter if it can be activated on demand.
- //
- // NOTE: we use a timeout large enough to ensure that the
- // activate() call won't timeout if the server hangs in
- // deactivation and/or activation.
- //
- AMI_Adapter_activatePtr amiCB = new AMI_Adapter_activateI(this, id, adpt);
- int timeout = adpt.activationTimeout + adpt.deactivationTimeout;
- AdapterPrx::uncheckedCast(adpt.proxy->ice_timeout(timeout * 1000))->activate_async(amiCB);
- return;
- }
+ if(ex.activatable)
+ {
+ //
+ // Activate the adapter if it can be activated on demand.
+ //
+ // NOTE: we use a timeout large enough to ensure that the
+ // activate() call won't timeout if the server hangs in
+ // deactivation and/or activation.
+ //
+ AMI_Adapter_activatePtr amiCB = new AMI_Adapter_activateI(this, id, adpt);
+ int timeout = adpt.activationTimeout + adpt.deactivationTimeout;
+ AdapterPrx::uncheckedCast(adpt.proxy->ice_timeout(timeout * 1000))->activate_async(amiCB);
+ return;
+ }
}
catch(const Ice::Exception&)
{
@@ -488,16 +488,16 @@ LocatorI::getDirectProxyException(const LocatorAdapterInfo& adpt, const string&
PendingRequests requests;
{
- Lock sync(*this);
- PendingRequestsMap::iterator p = _pendingRequests.find(adpt.proxy->ice_getIdentity());
- assert(p != _pendingRequests.end());
- requests.swap(p->second);
- _pendingRequests.erase(p);
+ Lock sync(*this);
+ PendingRequestsMap::iterator p = _pendingRequests.find(adpt.proxy->ice_getIdentity());
+ assert(p != _pendingRequests.end());
+ requests.swap(p->second);
+ _pendingRequests.erase(p);
}
for(PendingRequests::iterator q = requests.begin(); q != requests.end(); ++q)
{
- (*q)->exception(ex);
+ (*q)->exception(ex);
}
}
@@ -506,26 +506,26 @@ LocatorI::getDirectProxyCallback(const Ice::Identity& adapterId, const Ice::Obje
{
PendingRequests requests;
{
- Lock sync(*this);
- PendingRequestsMap::iterator p = _pendingRequests.find(adapterId);
- assert(p != _pendingRequests.end());
- requests.swap(p->second);
- _pendingRequests.erase(p);
+ Lock sync(*this);
+ PendingRequestsMap::iterator p = _pendingRequests.find(adapterId);
+ assert(p != _pendingRequests.end());
+ requests.swap(p->second);
+ _pendingRequests.erase(p);
}
if(proxy)
{
- for(PendingRequests::const_iterator q = requests.begin(); q != requests.end(); ++q)
- {
- (*q)->response(proxy);
- }
+ for(PendingRequests::const_iterator q = requests.begin(); q != requests.end(); ++q)
+ {
+ (*q)->response(proxy);
+ }
}
else
{
- for(PendingRequests::const_iterator q = requests.begin(); q != requests.end(); ++q)
- {
- (*q)->exception(AdapterNotActiveException());
- }
+ for(PendingRequests::const_iterator q = requests.begin(); q != requests.end(); ++q)
+ {
+ (*q)->exception(AdapterNotActiveException());
+ }
}
}
diff --git a/cpp/src/IceGrid/LocatorI.h b/cpp/src/IceGrid/LocatorI.h
index 96cd6a96d37..e36741631f9 100644
--- a/cpp/src/IceGrid/LocatorI.h
+++ b/cpp/src/IceGrid/LocatorI.h
@@ -34,41 +34,41 @@ class LocatorI : public Locator, public IceUtil::Mutex
{
public:
- Request(const Ice::AMD_Locator_findAdapterByIdPtr&, const LocatorIPtr&, const std::string&, bool,
- const LocatorAdapterInfoSeq&, int, const TraceLevelsPtr&);
+ Request(const Ice::AMD_Locator_findAdapterByIdPtr&, const LocatorIPtr&, const std::string&, bool,
+ const LocatorAdapterInfoSeq&, int, const TraceLevelsPtr&);
- void execute();
- void response(const Ice::ObjectPrx&);
- void exception(const Ice::Exception&);
+ void execute();
+ void response(const Ice::ObjectPrx&);
+ void exception(const Ice::Exception&);
private:
- void requestAdapter(const LocatorAdapterInfo&);
- void sendResponse();
-
- const Ice::AMD_Locator_findAdapterByIdPtr _amdCB;
- const LocatorIPtr _locator;
- const std::string _id;
- const bool _replicaGroup;
- LocatorAdapterInfoSeq _adapters;
- const TraceLevelsPtr _traceLevels;
- unsigned int _count;
- LocatorAdapterInfoSeq::const_iterator _lastAdapter;
- std::vector<Ice::ObjectPrx> _proxies;
- std::auto_ptr<Ice::Exception> _exception;
+ void requestAdapter(const LocatorAdapterInfo&);
+ void sendResponse();
+
+ const Ice::AMD_Locator_findAdapterByIdPtr _amdCB;
+ const LocatorIPtr _locator;
+ const std::string _id;
+ const bool _replicaGroup;
+ LocatorAdapterInfoSeq _adapters;
+ const TraceLevelsPtr _traceLevels;
+ unsigned int _count;
+ LocatorAdapterInfoSeq::const_iterator _lastAdapter;
+ std::vector<Ice::ObjectPrx> _proxies;
+ std::auto_ptr<Ice::Exception> _exception;
};
typedef IceUtil::Handle<Request> RequestPtr;
public:
LocatorI(const Ice::CommunicatorPtr&, const DatabasePtr&, const Ice::LocatorRegistryPrx&, const RegistryPrx&,
- const QueryPrx&);
+ const QueryPrx&);
virtual void findObjectById_async(const Ice::AMD_Locator_findObjectByIdPtr&, const Ice::Identity&,
- const Ice::Current&) const;
+ const Ice::Current&) const;
virtual void findAdapterById_async(const Ice::AMD_Locator_findAdapterByIdPtr&, const ::std::string&,
- const Ice::Current&) const;
+ const Ice::Current&) const;
virtual Ice::LocatorRegistryPrx getRegistry(const Ice::Current&) const;
virtual RegistryPrx getLocalRegistry(const Ice::Current&) const;
diff --git a/cpp/src/IceGrid/LocatorRegistryI.cpp b/cpp/src/IceGrid/LocatorRegistryI.cpp
index c4958152f20..01b01795192 100644
--- a/cpp/src/IceGrid/LocatorRegistryI.cpp
+++ b/cpp/src/IceGrid/LocatorRegistryI.cpp
@@ -25,53 +25,53 @@ class SetDirectProxyCB : public AMI_Adapter_setDirectProxy
public:
SetDirectProxyCB(const AmdCB& cb,
- const TraceLevelsPtr& traceLevels,
- const string& id,
- const Ice::ObjectPrx& proxy) :
- _cb(cb), _traceLevels(traceLevels), _id(id), _proxy(proxy)
+ const TraceLevelsPtr& traceLevels,
+ const string& id,
+ const Ice::ObjectPrx& proxy) :
+ _cb(cb), _traceLevels(traceLevels), _id(id), _proxy(proxy)
{
}
virtual void ice_response()
{
- if(_traceLevels->locator > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
- out << "registered adapter `" << _id << "' endpoints: `";
- out << (_proxy ? _proxy->ice_toString() : string("")) << "'";
- }
- _cb->ice_response();
+ if(_traceLevels->locator > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
+ out << "registered adapter `" << _id << "' endpoints: `";
+ out << (_proxy ? _proxy->ice_toString() : string("")) << "'";
+ }
+ _cb->ice_response();
}
virtual void ice_exception(const ::Ice::Exception& ex)
{
- if(_traceLevels->locator > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
- out << "failed to register adapter `" << _id << "' endpoints:\n" << ex;
- }
-
- try
- {
- ex.ice_throw();
- }
- catch(const AdapterActiveException&)
- {
- _cb->ice_exception(Ice::AdapterAlreadyActiveException());
- return;
- }
- catch(const Ice::ObjectNotExistException&)
- {
- _cb->ice_exception(Ice::AdapterNotFoundException()); // Expected if the adapter was destroyed.
- return;
- }
- catch(const Ice::LocalException&)
- {
- _cb->ice_exception(Ice::AdapterNotFoundException());
- return;
- }
+ if(_traceLevels->locator > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
+ out << "failed to register adapter `" << _id << "' endpoints:\n" << ex;
+ }
+
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(const AdapterActiveException&)
+ {
+ _cb->ice_exception(Ice::AdapterAlreadyActiveException());
+ return;
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ _cb->ice_exception(Ice::AdapterNotFoundException()); // Expected if the adapter was destroyed.
+ return;
+ }
+ catch(const Ice::LocalException&)
+ {
+ _cb->ice_exception(Ice::AdapterNotFoundException());
+ return;
+ }
- assert(false);
+ assert(false);
}
private:
@@ -93,49 +93,49 @@ class AMI_Server_setProcessI : public AMI_Server_setProcess
public:
AMI_Server_setProcessI(const Ice::AMD_LocatorRegistry_setServerProcessProxyPtr& cb,
- const TraceLevelsPtr& traceLevels,
- const string& id,
- const Ice::ObjectPrx& proxy) :
- _cb(cb), _traceLevels(traceLevels), _id(id), _proxy(proxy)
+ const TraceLevelsPtr& traceLevels,
+ const string& id,
+ const Ice::ObjectPrx& proxy) :
+ _cb(cb), _traceLevels(traceLevels), _id(id), _proxy(proxy)
{
}
virtual void ice_response()
{
- if(_traceLevels->locator > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
- out << "registered server `" << _id << "' process proxy: `";
- out << (_proxy ? _proxy->ice_toString() : string("")) << "'";
- }
- _cb->ice_response();
+ if(_traceLevels->locator > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
+ out << "registered server `" << _id << "' process proxy: `";
+ out << (_proxy ? _proxy->ice_toString() : string("")) << "'";
+ }
+ _cb->ice_response();
}
virtual void ice_exception(const ::Ice::Exception& ex)
{
- if(_traceLevels->locator > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
- out << "failed to register server process proxy `" << _id << "':\n" << ex;
- }
+ if(_traceLevels->locator > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->locatorCat);
+ out << "failed to register server process proxy `" << _id << "':\n" << ex;
+ }
- try
- {
- ex.ice_throw();
- }
- catch(const Ice::ObjectNotExistException&)
- {
- // Expected if the server was destroyed.
- _cb->ice_exception(Ice::ServerNotFoundException());
- return;
- }
- catch(const Ice::LocalException&)
- {
- _cb->ice_exception(Ice::ServerNotFoundException());
- return;
- }
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ // Expected if the server was destroyed.
+ _cb->ice_exception(Ice::ServerNotFoundException());
+ return;
+ }
+ catch(const Ice::LocalException&)
+ {
+ _cb->ice_exception(Ice::ServerNotFoundException());
+ return;
+ }
- assert(false);
+ assert(false);
}
private:
@@ -149,9 +149,9 @@ private:
};
LocatorRegistryI::LocatorRegistryI(const DatabasePtr& database,
- bool dynamicRegistration,
- bool master,
- ReplicaSessionManager& session) :
+ bool dynamicRegistration,
+ bool master,
+ ReplicaSessionManager& session) :
_database(database),
_dynamicRegistration(dynamicRegistration),
_master(master),
@@ -161,14 +161,14 @@ LocatorRegistryI::LocatorRegistryI(const DatabasePtr& database,
void
LocatorRegistryI::setAdapterDirectProxy_async(const Ice::AMD_LocatorRegistry_setAdapterDirectProxyPtr& cb,
- const string& adapterId,
- const Ice::ObjectPrx& proxy,
- const Ice::Current&)
+ const string& adapterId,
+ const Ice::ObjectPrx& proxy,
+ const Ice::Current&)
{
setAdapterDirectProxy(newSetDirectProxyCB(cb, _database->getTraceLevels(), adapterId, proxy),
- adapterId,
- "",
- proxy);
+ adapterId,
+ "",
+ proxy);
}
void
@@ -180,140 +180,140 @@ LocatorRegistryI::setReplicatedAdapterDirectProxy_async(
const Ice::Current&)
{
setAdapterDirectProxy(newSetDirectProxyCB(cb, _database->getTraceLevels(), adapterId, proxy),
- adapterId,
- replicaGroupId,
- proxy);
+ adapterId,
+ replicaGroupId,
+ proxy);
}
void
LocatorRegistryI::setServerProcessProxy_async(const Ice::AMD_LocatorRegistry_setServerProcessProxyPtr& cb,
- const string& id,
- const Ice::ProcessPrx& proxy,
- const Ice::Current&)
+ const string& id,
+ const Ice::ProcessPrx& proxy,
+ const Ice::Current&)
{
try
{
//
// Get the server from the registry and set its process proxy.
//
- // NOTE: We pass false to the getServer call to indicate that
- // we don't necessarily want an up-to-date adapter proxy. This
- // is needed for the session activation mode for cases where
- // the server is released during the server startup.
- //
- AMI_Server_setProcessPtr amiCB = new AMI_Server_setProcessI(cb, _database->getTraceLevels(), id, proxy);
+ // NOTE: We pass false to the getServer call to indicate that
+ // we don't necessarily want an up-to-date adapter proxy. This
+ // is needed for the session activation mode for cases where
+ // the server is released during the server startup.
+ //
+ AMI_Server_setProcessPtr amiCB = new AMI_Server_setProcessI(cb, _database->getTraceLevels(), id, proxy);
_database->getServer(id)->getProxy(false)->setProcess_async(amiCB, proxy);
}
catch(const ServerNotExistException&)
{
- cb->ice_exception(Ice::ServerNotFoundException());
+ cb->ice_exception(Ice::ServerNotFoundException());
}
catch(const Ice::Exception& ex)
{
- const TraceLevelsPtr traceLevels = _database->getTraceLevels();
- if(traceLevels->locator > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
- out << "couldn't register server `" << id << "' process proxy:\n" << toString(ex);
- }
- cb->ice_exception(Ice::ServerNotFoundException());
+ const TraceLevelsPtr traceLevels = _database->getTraceLevels();
+ if(traceLevels->locator > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
+ out << "couldn't register server `" << id << "' process proxy:\n" << toString(ex);
+ }
+ cb->ice_exception(Ice::ServerNotFoundException());
}
}
void
LocatorRegistryI::setAdapterDirectProxy(const AMI_Adapter_setDirectProxyPtr& amiCB,
- const string& adapterId,
- const string& replicaGroupId,
- const Ice::ObjectPrx& proxy)
+ const string& adapterId,
+ const string& replicaGroupId,
+ const Ice::ObjectPrx& proxy)
{
int nRetry = 5;
do
{
- try
- {
- //
- // Get the adapter from the registry and set its direct proxy.
- //
- ServerAdapterEntryPtr adapter = ServerAdapterEntryPtr::dynamicCast(_database->getAdapter(adapterId));
- if(!adapter)
- {
- throw Ice::AdapterNotFoundException();
- }
- adapter->getProxy(replicaGroupId, false)->setDirectProxy_async(amiCB, proxy);
- return;
- }
- catch(const AdapterNotExistException&)
- {
- if(!_dynamicRegistration)
- {
- throw Ice::AdapterNotFoundException();
- }
- }
- catch(const Ice::Exception& ex)
- {
- const TraceLevelsPtr traceLevels = _database->getTraceLevels();
- if(traceLevels->locator > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
- out << "couldn't register adapter `" << adapterId << "' endpoints:\n" << toString(ex);
- }
- throw Ice::AdapterNotFoundException();
- }
-
- assert(_dynamicRegistration);
- if(_master)
- {
- try
- {
- _database->setAdapterDirectProxy(adapterId, replicaGroupId, proxy);
- amiCB->ice_response();
- return;
- }
- catch(const AdapterExistsException&)
- {
- // Continue
- }
- }
- else
- {
- ReplicaSessionPrx session = _session.getSession();
- if(!session)
- {
- const TraceLevelsPtr traceLevels = _database->getTraceLevels();
- if(traceLevels->locator > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
- out << "couldn't register adapter `" << adapterId << "' endpoints with master:\n";
- out << "no session established with the master";
- }
- throw Ice::AdapterNotFoundException();
- }
+ try
+ {
+ //
+ // Get the adapter from the registry and set its direct proxy.
+ //
+ ServerAdapterEntryPtr adapter = ServerAdapterEntryPtr::dynamicCast(_database->getAdapter(adapterId));
+ if(!adapter)
+ {
+ throw Ice::AdapterNotFoundException();
+ }
+ adapter->getProxy(replicaGroupId, false)->setDirectProxy_async(amiCB, proxy);
+ return;
+ }
+ catch(const AdapterNotExistException&)
+ {
+ if(!_dynamicRegistration)
+ {
+ throw Ice::AdapterNotFoundException();
+ }
+ }
+ catch(const Ice::Exception& ex)
+ {
+ const TraceLevelsPtr traceLevels = _database->getTraceLevels();
+ if(traceLevels->locator > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
+ out << "couldn't register adapter `" << adapterId << "' endpoints:\n" << toString(ex);
+ }
+ throw Ice::AdapterNotFoundException();
+ }
+
+ assert(_dynamicRegistration);
+ if(_master)
+ {
+ try
+ {
+ _database->setAdapterDirectProxy(adapterId, replicaGroupId, proxy);
+ amiCB->ice_response();
+ return;
+ }
+ catch(const AdapterExistsException&)
+ {
+ // Continue
+ }
+ }
+ else
+ {
+ ReplicaSessionPrx session = _session.getSession();
+ if(!session)
+ {
+ const TraceLevelsPtr traceLevels = _database->getTraceLevels();
+ if(traceLevels->locator > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
+ out << "couldn't register adapter `" << adapterId << "' endpoints with master:\n";
+ out << "no session established with the master";
+ }
+ throw Ice::AdapterNotFoundException();
+ }
- try
- {
- session->setAdapterDirectProxy(adapterId, replicaGroupId, proxy);
- amiCB->ice_response();
- return;
- }
- catch(const AdapterExistsException&)
- {
- // Continue
- }
- catch(const AdapterNotExistException&)
- {
- throw Ice::AdapterNotFoundException(); // Dynamic registration not allowed on the master.
- }
- catch(const Ice::LocalException& ex)
- {
- const TraceLevelsPtr traceLevels = _database->getTraceLevels();
- if(traceLevels->locator > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
- out << "couldn't register adapter `" << adapterId << "' endpoints with master:\n" << toString(ex);
- }
- throw Ice::AdapterNotFoundException();
- }
- }
+ try
+ {
+ session->setAdapterDirectProxy(adapterId, replicaGroupId, proxy);
+ amiCB->ice_response();
+ return;
+ }
+ catch(const AdapterExistsException&)
+ {
+ // Continue
+ }
+ catch(const AdapterNotExistException&)
+ {
+ throw Ice::AdapterNotFoundException(); // Dynamic registration not allowed on the master.
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ const TraceLevelsPtr traceLevels = _database->getTraceLevels();
+ if(traceLevels->locator > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->locatorCat);
+ out << "couldn't register adapter `" << adapterId << "' endpoints with master:\n" << toString(ex);
+ }
+ throw Ice::AdapterNotFoundException();
+ }
+ }
}
while(nRetry-- > 0);
throw Ice::AdapterNotFoundException();
diff --git a/cpp/src/IceGrid/LocatorRegistryI.h b/cpp/src/IceGrid/LocatorRegistryI.h
index 51ed4319109..58139160106 100644
--- a/cpp/src/IceGrid/LocatorRegistryI.h
+++ b/cpp/src/IceGrid/LocatorRegistryI.h
@@ -28,19 +28,19 @@ public:
LocatorRegistryI(const DatabasePtr&, bool, bool, ReplicaSessionManager&);
virtual void setAdapterDirectProxy_async(const Ice::AMD_LocatorRegistry_setAdapterDirectProxyPtr&,
- const std::string&, const Ice::ObjectPrx&, const Ice::Current&);
+ const std::string&, const Ice::ObjectPrx&, const Ice::Current&);
virtual void setReplicatedAdapterDirectProxy_async(
- const Ice::AMD_LocatorRegistry_setReplicatedAdapterDirectProxyPtr&, const std::string&, const std::string&,
- const Ice::ObjectPrx&, const Ice::Current&);
+ const Ice::AMD_LocatorRegistry_setReplicatedAdapterDirectProxyPtr&, const std::string&, const std::string&,
+ const Ice::ObjectPrx&, const Ice::Current&);
virtual void setServerProcessProxy_async(const Ice::AMD_LocatorRegistry_setServerProcessProxyPtr&,
- const ::std::string&, const ::Ice::ProcessPrx&, const ::Ice::Current&);
+ const ::std::string&, const ::Ice::ProcessPrx&, const ::Ice::Current&);
private:
void setAdapterDirectProxy(const AMI_Adapter_setDirectProxyPtr&, const std::string&, const std::string&,
- const Ice::ObjectPrx&);
+ const Ice::ObjectPrx&);
const DatabasePtr _database;
const bool _dynamicRegistration;
diff --git a/cpp/src/IceGrid/NodeCache.cpp b/cpp/src/IceGrid/NodeCache.cpp
index 63e23ea919c..a431b527712 100644
--- a/cpp/src/IceGrid/NodeCache.cpp
+++ b/cpp/src/IceGrid/NodeCache.cpp
@@ -29,107 +29,107 @@ namespace IceGrid
struct ToInternalServerDescriptor : std::unary_function<CommunicatorDescriptorPtr&, void>
{
ToInternalServerDescriptor(const InternalServerDescriptorPtr& descriptor, const InternalNodeInfoPtr& node) :
- _desc(descriptor),
- _node(node)
+ _desc(descriptor),
+ _node(node)
{
}
void
operator()(const CommunicatorDescriptorPtr& desc)
{
- //
- // Figure out the configuration file name for the communicator
- // (if it's a service, it's "config_<service name>", if it's
- // the server, it's just "config").
- //
- string filename = "config";
- ServiceDescriptorPtr svc = ServiceDescriptorPtr::dynamicCast(desc);
- if(svc)
- {
- filename += "_" + svc->name;
- }
- PropertyDescriptorSeq& props = _desc->properties[filename];
-
- PropertyDescriptorSeq communicatorProps = desc->propertySet.properties;
-
- //
- // Add the adapters and their configuration.
- //
- for(AdapterDescriptorSeq::const_iterator q = desc->adapters.begin(); q != desc->adapters.end(); ++q)
- {
- _desc->adapters.push_back(new InternalAdapterDescriptor(q->id, q->serverLifetime));
-
- props.push_back(createProperty("# Object adapter " + q->name));
- PropertyDescriptor prop = removeProperty(communicatorProps, "Ice.OA." + q->name + ".Endpoints");
- prop.name = "Ice.OA." + q->name + ".Endpoints";
- props.push_back(prop);
- props.push_back(createProperty("Ice.OA." + q->name + ".AdapterId", q->id));
- if(!q->replicaGroupId.empty())
- {
- props.push_back(createProperty("Ice.OA." + q->name + ".ReplicaGroupId", q->replicaGroupId));
- }
- if(q->registerProcess)
- {
- props.push_back(createProperty("Ice.OA." + q->name + ".RegisterProcess", "1"));
- _desc->processRegistered = true;
- }
- }
-
- _desc->logs.insert(_desc->logs.end(), desc->logs.begin(), desc->logs.end());
-
- const string dbsPath = _node->dataDir + "/servers/" + _desc->id + "/dbs/";
- for(DbEnvDescriptorSeq::const_iterator p = desc->dbEnvs.begin(); p != desc->dbEnvs.end(); ++p)
- {
- props.push_back(createProperty("# Database environment " + p->name));
- if(p->dbHome.empty())
- {
- _desc->dbEnvs.push_back(new InternalDbEnvDescriptor(p->name, p->properties));
- props.push_back(createProperty("Freeze.DbEnv." + p->name + ".DbHome", dbsPath + p->name));
- }
- else
- {
- props.push_back(createProperty("Freeze.DbEnv." + p->name + ".DbHome", p->dbHome));
- }
- }
-
- //
- // Copy the communicator descriptor properties.
- //
- if(!communicatorProps.empty())
- {
- if(svc)
- {
- props.push_back(createProperty("# Service descriptor properties"));
- }
- else
- {
- props.push_back(createProperty("# Server descriptor properties"));
- }
- copy(communicatorProps.begin(), communicatorProps.end(), back_inserter(props));
- }
+ //
+ // Figure out the configuration file name for the communicator
+ // (if it's a service, it's "config_<service name>", if it's
+ // the server, it's just "config").
+ //
+ string filename = "config";
+ ServiceDescriptorPtr svc = ServiceDescriptorPtr::dynamicCast(desc);
+ if(svc)
+ {
+ filename += "_" + svc->name;
+ }
+ PropertyDescriptorSeq& props = _desc->properties[filename];
+
+ PropertyDescriptorSeq communicatorProps = desc->propertySet.properties;
+
+ //
+ // Add the adapters and their configuration.
+ //
+ for(AdapterDescriptorSeq::const_iterator q = desc->adapters.begin(); q != desc->adapters.end(); ++q)
+ {
+ _desc->adapters.push_back(new InternalAdapterDescriptor(q->id, q->serverLifetime));
+
+ props.push_back(createProperty("# Object adapter " + q->name));
+ PropertyDescriptor prop = removeProperty(communicatorProps, "Ice.OA." + q->name + ".Endpoints");
+ prop.name = "Ice.OA." + q->name + ".Endpoints";
+ props.push_back(prop);
+ props.push_back(createProperty("Ice.OA." + q->name + ".AdapterId", q->id));
+ if(!q->replicaGroupId.empty())
+ {
+ props.push_back(createProperty("Ice.OA." + q->name + ".ReplicaGroupId", q->replicaGroupId));
+ }
+ if(q->registerProcess)
+ {
+ props.push_back(createProperty("Ice.OA." + q->name + ".RegisterProcess", "1"));
+ _desc->processRegistered = true;
+ }
+ }
+
+ _desc->logs.insert(_desc->logs.end(), desc->logs.begin(), desc->logs.end());
+
+ const string dbsPath = _node->dataDir + "/servers/" + _desc->id + "/dbs/";
+ for(DbEnvDescriptorSeq::const_iterator p = desc->dbEnvs.begin(); p != desc->dbEnvs.end(); ++p)
+ {
+ props.push_back(createProperty("# Database environment " + p->name));
+ if(p->dbHome.empty())
+ {
+ _desc->dbEnvs.push_back(new InternalDbEnvDescriptor(p->name, p->properties));
+ props.push_back(createProperty("Freeze.DbEnv." + p->name + ".DbHome", dbsPath + p->name));
+ }
+ else
+ {
+ props.push_back(createProperty("Freeze.DbEnv." + p->name + ".DbHome", p->dbHome));
+ }
+ }
+
+ //
+ // Copy the communicator descriptor properties.
+ //
+ if(!communicatorProps.empty())
+ {
+ if(svc)
+ {
+ props.push_back(createProperty("# Service descriptor properties"));
+ }
+ else
+ {
+ props.push_back(createProperty("# Server descriptor properties"));
+ }
+ copy(communicatorProps.begin(), communicatorProps.end(), back_inserter(props));
+ }
}
PropertyDescriptor
removeProperty(PropertyDescriptorSeq& properties, const string& name)
{
- string value;
- PropertyDescriptorSeq::iterator p = properties.begin();
- while(p != properties.end())
- {
- if(p->name == name)
- {
- value = p->value;
- p = properties.erase(p);
- }
- else
- {
- ++p;
- }
- }
- PropertyDescriptor desc;
- desc.name = name;
- desc.value = value;
- return desc;
+ string value;
+ PropertyDescriptorSeq::iterator p = properties.begin();
+ while(p != properties.end())
+ {
+ if(p->name == name)
+ {
+ value = p->value;
+ p = properties.erase(p);
+ }
+ else
+ {
+ ++p;
+ }
+ }
+ PropertyDescriptor desc;
+ desc.name = name;
+ desc.value = value;
+ return desc;
}
InternalServerDescriptorPtr _desc;
@@ -141,60 +141,60 @@ class LoadCB : public AMI_Node_loadServer
public:
LoadCB(const TraceLevelsPtr& traceLevels,
- const ServerEntryPtr& server,
- const string& node,
- int timeout) :
- _traceLevels(traceLevels), _server(server), _id(server->getId()), _node(node), _timeout(timeout)
+ const ServerEntryPtr& server,
+ const string& node,
+ int timeout) :
+ _traceLevels(traceLevels), _server(server), _id(server->getId()), _node(node), _timeout(timeout)
{
}
void
ice_response(const ServerPrx& server, const AdapterPrxDict& adapters, int at, int dt)
{
- if(_traceLevels && _traceLevels->server > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "loaded `" << _id << "' on node `" << _node << "'";
- }
+ if(_traceLevels && _traceLevels->server > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "loaded `" << _id << "' on node `" << _node << "'";
+ }
- //
- // Add the node session timeout on the proxies to ensure the
- // timeout is large enough.
- //
- _server->loadCallback(server, adapters, at + _timeout, dt + _timeout);
+ //
+ // Add the node session timeout on the proxies to ensure the
+ // timeout is large enough.
+ //
+ _server->loadCallback(server, adapters, at + _timeout, dt + _timeout);
}
void
ice_exception(const Ice::Exception& ex)
{
- try
- {
- ex.ice_throw();
- }
- catch(const DeploymentException& ex)
- {
- if(_traceLevels && _traceLevels->server > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "couldn't load `" << _id << "' on node `" << _node << "':\n" << ex.reason;
- }
-
- ostringstream os;
- os << "couldn't load `" << _id << "' on node `" << _node << "':\n" << ex.reason;
- _server->exception(DeploymentException(os.str()));
- }
- catch(const Ice::Exception& ex)
- {
- if(_traceLevels && _traceLevels->server > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "couldn't load `" << _id << "' on node `" << _node << "':\n" << ex;
- }
-
- ostringstream os;
- os << ex;
- _server->exception(NodeUnreachableException(_node, os.str()));
- }
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(const DeploymentException& ex)
+ {
+ if(_traceLevels && _traceLevels->server > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "couldn't load `" << _id << "' on node `" << _node << "':\n" << ex.reason;
+ }
+
+ ostringstream os;
+ os << "couldn't load `" << _id << "' on node `" << _node << "':\n" << ex.reason;
+ _server->exception(DeploymentException(os.str()));
+ }
+ catch(const Ice::Exception& ex)
+ {
+ if(_traceLevels && _traceLevels->server > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "couldn't load `" << _id << "' on node `" << _node << "':\n" << ex;
+ }
+
+ ostringstream os;
+ os << ex;
+ _server->exception(NodeUnreachableException(_node, os.str()));
+ }
}
private:
@@ -211,51 +211,51 @@ class DestroyCB : public AMI_Node_destroyServer
public:
DestroyCB(const TraceLevelsPtr& traceLevels, const ServerEntryPtr& server, const string& node) :
- _traceLevels(traceLevels), _server(server), _id(server->getId()), _node(node)
+ _traceLevels(traceLevels), _server(server), _id(server->getId()), _node(node)
{
}
void
ice_response()
{
- if(_traceLevels && _traceLevels->server > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "unloaded `" << _id << "' on node `" << _node << "'";
- }
- _server->destroyCallback();
+ if(_traceLevels && _traceLevels->server > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "unloaded `" << _id << "' on node `" << _node << "'";
+ }
+ _server->destroyCallback();
}
void
ice_exception(const Ice::Exception& ex)
{
- try
- {
- ex.ice_throw();
- }
- catch(const DeploymentException& ex)
- {
- if(_traceLevels && _traceLevels->server > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "couldn't unload `" << _id << "' on node `" << _node << "':\n" << ex.reason;
- }
-
- ostringstream os;
- os << "couldn't unload `" << _id << "' on node `" << _node << "':\n" << ex.reason;
- _server->exception(DeploymentException(os.str()));
- }
- catch(const Ice::Exception& ex)
- {
- if(_traceLevels && _traceLevels->server > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "couldn't unload `" << _id << "' on node `" << _node << "':\n" << ex;
- }
- ostringstream os;
- os << ex;
- _server->exception(NodeUnreachableException(_node, os.str()));
- }
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(const DeploymentException& ex)
+ {
+ if(_traceLevels && _traceLevels->server > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "couldn't unload `" << _id << "' on node `" << _node << "':\n" << ex.reason;
+ }
+
+ ostringstream os;
+ os << "couldn't unload `" << _id << "' on node `" << _node << "':\n" << ex.reason;
+ _server->exception(DeploymentException(os.str()));
+ }
+ catch(const Ice::Exception& ex)
+ {
+ if(_traceLevels && _traceLevels->server > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "couldn't unload `" << _id << "' on node `" << _node << "':\n" << ex;
+ }
+ ostringstream os;
+ os << ex;
+ _server->exception(NodeUnreachableException(_node, os.str()));
+ }
}
private:
@@ -277,13 +277,13 @@ public:
void
ice_response()
{
- _node->finishedRegistration();
+ _node->finishedRegistration();
}
void
ice_exception(const Ice::Exception& ex)
{
- _node->finishedRegistration(ex);
+ _node->finishedRegistration(ex);
}
private:
@@ -306,15 +306,15 @@ NodeCache::get(const string& name, bool create) const
NodeEntryPtr entry = getImpl(name);
if(!entry && create)
{
- NodeCache& self = const_cast<NodeCache&>(*this);
- entry = new NodeEntry(self, name);
- self.addImpl(name, entry);
+ NodeCache& self = const_cast<NodeCache&>(*this);
+ entry = new NodeEntry(self, name);
+ self.addImpl(name, entry);
}
if(!entry)
{
- NodeNotExistException ex;
- ex.name = name;
- throw ex;
+ NodeNotExistException ex;
+ ex.name = name;
+ throw ex;
}
return entry;
}
@@ -366,50 +366,50 @@ NodeEntry::setSession(const NodeSessionIPtr& session)
if(session)
{
- while(_session)
- {
- if(_session->isDestroyed())
- {
- // If the current session has just been destroyed, wait for the setSession(0) call.
- assert(session != _session);
- wait();
- }
- else
- {
- NodeSessionIPtr session = _session;
- sync.release();
- try
- {
- session->getNode()->ice_ping();
- throw NodeActiveException();
- }
- catch(const Ice::LocalException&)
- {
- try
- {
- session->destroy();
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
- }
- sync.acquire();
- }
- }
-
- //
- // Clear the saved proxy, the node has established a session
- // so we won't need anymore to try to register it with this
- // registry.
- //
- _proxy = 0;
+ while(_session)
+ {
+ if(_session->isDestroyed())
+ {
+ // If the current session has just been destroyed, wait for the setSession(0) call.
+ assert(session != _session);
+ wait();
+ }
+ else
+ {
+ NodeSessionIPtr session = _session;
+ sync.release();
+ try
+ {
+ session->getNode()->ice_ping();
+ throw NodeActiveException();
+ }
+ catch(const Ice::LocalException&)
+ {
+ try
+ {
+ session->destroy();
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
+ }
+ sync.acquire();
+ }
+ }
+
+ //
+ // Clear the saved proxy, the node has established a session
+ // so we won't need anymore to try to register it with this
+ // registry.
+ //
+ _proxy = 0;
}
else
{
- if(!_session)
- {
- return;
- }
+ if(!_session)
+ {
+ return;
+ }
}
_session = session;
@@ -417,25 +417,25 @@ NodeEntry::setSession(const NodeSessionIPtr& session)
if(_registering)
{
- _registering = false;
- notifyAll();
+ _registering = false;
+ notifyAll();
}
if(session)
{
- if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
- {
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
- out << "node `" << _name << "' up";
- }
+ if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
+ {
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
+ out << "node `" << _name << "' up";
+ }
}
else
{
- if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
- {
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
- out << "node `" << _name << "' down";
- }
+ if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
+ {
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
+ out << "node `" << _name << "' down";
+ }
}
}
@@ -462,7 +462,7 @@ NodeEntry::getServers() const
ServerEntrySeq entries;
for(map<string, ServerEntryPtr>::const_iterator p = _servers.begin(); p != _servers.end(); ++p)
{
- entries.push_back(p->second);
+ entries.push_back(p->second);
}
return entries;
}
@@ -476,7 +476,7 @@ NodeEntry::getLoadInfoAndLoadFactor(const string& application, float& loadFactor
map<string, NodeDescriptor>::const_iterator p = _descriptors.find(application);
if(p == _descriptors.end())
{
- throw NodeNotExistException(); // The node doesn't exist in the given application.
+ throw NodeNotExistException(); // The node doesn't exist in the given application.
}
//
@@ -486,30 +486,30 @@ NodeEntry::getLoadInfoAndLoadFactor(const string& application, float& loadFactor
loadFactor = -1.0f;
if(!p->second.loadFactor.empty())
{
- istringstream is(p->second.loadFactor);
- is >> loadFactor;
+ istringstream is(p->second.loadFactor);
+ is >> loadFactor;
}
if(loadFactor < 0.0f)
{
- if(_session->getInfo()->os != "Windows")
- {
- //
- // On Unix platforms, we divide the load averages by the
- // number of processors. A load of 2 on a dual processor
- // machine is the same as a load of 1 on a single process
- // machine.
- //
- loadFactor = 1.0f / _session->getInfo()->nProcessors;
- }
- else
- {
- //
- // On Windows, load1, load5 and load15 are the average of
- // the CPU utilization (all CPUs). We don't need to divide
- // by the number of CPU.
- //
- loadFactor = 1.0f;
- }
+ if(_session->getInfo()->os != "Windows")
+ {
+ //
+ // On Unix platforms, we divide the load averages by the
+ // number of processors. A load of 2 on a dual processor
+ // machine is the same as a load of 1 on a single process
+ // machine.
+ //
+ loadFactor = 1.0f / _session->getInfo()->nProcessors;
+ }
+ else
+ {
+ //
+ // On Windows, load1, load5 and load15 are the average of
+ // the CPU utilization (all CPUs). We don't need to divide
+ // by the number of CPU.
+ //
+ loadFactor = 1.0f;
+ }
}
return _session->getLoadInfo();
@@ -535,60 +535,60 @@ NodeEntry::loadServer(const ServerEntryPtr& entry, const ServerInfo& server, con
{
try
{
- NodePrx node;
- int sessionTimeout;
- InternalServerDescriptorPtr desc;
- {
- Lock sync(*this);
- checkSession();
- node = _session->getNode();
- sessionTimeout = _session->getTimeout();
-
- //
- // Check if we should use a specific timeout (the load
- // call can deactivate the server and it can take some
- // time to deactivate, up to "deactivation-timeout"
- // seconds).
- //
- if(timeout > 0)
- {
- node = NodePrx::uncheckedCast(node->ice_timeout(timeout * 1000));
- }
-
- ServerInfo info = server;
- try
- {
- info.descriptor = getServerDescriptor(server, session);
- }
- catch(const DeploymentException&)
- {
- //
- // We ignore the deployment error for now (which can
- // only be caused in theory by session variables not
- // being defined because the server isn't
- // allocated...)
- //
- }
- desc = getInternalServerDescriptor(info);
- }
- assert(desc);
-
- if(_cache.getTraceLevels() && _cache.getTraceLevels()->server > 2)
- {
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->serverCat);
- out << "loading `" << desc->id << "' on node `" << _name << "'";
- if(session)
- {
- out << " for session `" << session->getId() << "'";
- }
- }
-
- AMI_Node_loadServerPtr amiCB = new LoadCB(_cache.getTraceLevels(), entry, _name, sessionTimeout);
- node->loadServer_async(amiCB, desc, _cache.getReplicaName());
+ NodePrx node;
+ int sessionTimeout;
+ InternalServerDescriptorPtr desc;
+ {
+ Lock sync(*this);
+ checkSession();
+ node = _session->getNode();
+ sessionTimeout = _session->getTimeout();
+
+ //
+ // Check if we should use a specific timeout (the load
+ // call can deactivate the server and it can take some
+ // time to deactivate, up to "deactivation-timeout"
+ // seconds).
+ //
+ if(timeout > 0)
+ {
+ node = NodePrx::uncheckedCast(node->ice_timeout(timeout * 1000));
+ }
+
+ ServerInfo info = server;
+ try
+ {
+ info.descriptor = getServerDescriptor(server, session);
+ }
+ catch(const DeploymentException&)
+ {
+ //
+ // We ignore the deployment error for now (which can
+ // only be caused in theory by session variables not
+ // being defined because the server isn't
+ // allocated...)
+ //
+ }
+ desc = getInternalServerDescriptor(info);
+ }
+ assert(desc);
+
+ if(_cache.getTraceLevels() && _cache.getTraceLevels()->server > 2)
+ {
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->serverCat);
+ out << "loading `" << desc->id << "' on node `" << _name << "'";
+ if(session)
+ {
+ out << " for session `" << session->getId() << "'";
+ }
+ }
+
+ AMI_Node_loadServerPtr amiCB = new LoadCB(_cache.getTraceLevels(), entry, _name, sessionTimeout);
+ node->loadServer_async(amiCB, desc, _cache.getReplicaName());
}
catch(const NodeUnreachableException& ex)
{
- entry->exception(ex);
+ entry->exception(ex);
}
}
@@ -597,36 +597,36 @@ NodeEntry::destroyServer(const ServerEntryPtr& entry, const ServerInfo& info, in
{
try
{
- NodePrx node;
- {
- Lock sync(*this);
- checkSession();
- node = _session->getNode();
-
- //
- // Check if we should use a specific timeout (the load
- // call can deactivate the server and it can take some
- // time to deactivate, up to "deactivation-timeout"
- // seconds).
- //
- if(timeout > 0)
- {
- node = NodePrx::uncheckedCast(node->ice_timeout(timeout * 1000));
- }
- }
-
- if(_cache.getTraceLevels() && _cache.getTraceLevels()->server > 2)
- {
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->serverCat);
- 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());
+ NodePrx node;
+ {
+ Lock sync(*this);
+ checkSession();
+ node = _session->getNode();
+
+ //
+ // Check if we should use a specific timeout (the load
+ // call can deactivate the server and it can take some
+ // time to deactivate, up to "deactivation-timeout"
+ // seconds).
+ //
+ if(timeout > 0)
+ {
+ node = NodePrx::uncheckedCast(node->ice_timeout(timeout * 1000));
+ }
+ }
+
+ if(_cache.getTraceLevels() && _cache.getTraceLevels()->server > 2)
+ {
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->serverCat);
+ 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());
}
catch(const NodeUnreachableException& ex)
{
- entry->exception(ex);
+ entry->exception(ex);
}
}
@@ -654,18 +654,18 @@ NodeEntry::getServerDescriptor(const ServerInfo& server, const SessionIPtr& sess
if(session)
{
- resolve.setReserved("session.id", session->getId());
+ resolve.setReserved("session.id", session->getId());
}
IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(server.descriptor);
if(iceBox)
{
- return IceBoxHelper(iceBox).instantiate(resolve, PropertyDescriptorSeq(), PropertySetDescriptorDict());
+ return IceBoxHelper(iceBox).instantiate(resolve, PropertyDescriptorSeq(), PropertySetDescriptorDict());
}
else
{
- return ServerHelper(server.descriptor).instantiate(resolve, PropertyDescriptorSeq(),
- PropertySetDescriptorDict());
+ return ServerHelper(server.descriptor).instantiate(resolve, PropertyDescriptorSeq(),
+ PropertySetDescriptorDict());
}
}
@@ -691,28 +691,28 @@ NodeEntry::__decRef()
bool doRemove = false;
bool doDelete = false;
{
- Lock sync(*this); // We use a recursive mutex so it's fine to
- // create Ptr with the mutex locked.
- assert(_ref > 0);
- --_ref;
-
- if(_ref == 1)
- {
- doRemove = canRemove();
- }
- else if(_ref == 0)
- {
- doDelete = true;
- }
+ Lock sync(*this); // We use a recursive mutex so it's fine to
+ // create Ptr with the mutex locked.
+ assert(_ref > 0);
+ --_ref;
+
+ if(_ref == 1)
+ {
+ doRemove = canRemove();
+ }
+ else if(_ref == 0)
+ {
+ doDelete = true;
+ }
}
if(doRemove)
{
- _cache.remove(_name);
+ _cache.remove(_name);
}
else if(doDelete)
{
- delete this;
+ delete this;
}
}
@@ -721,45 +721,45 @@ NodeEntry::checkSession() const
{
if(_session && !_session->isDestroyed())
{
- return;
+ return;
}
else if(!_proxy && !_registering)
{
- throw NodeUnreachableException(_name, "the node is not active");
+ throw NodeUnreachableException(_name, "the node is not active");
}
else if(_proxy)
{
- //
- // If the node proxy is set, we attempt to get the node to
- // register with this registry.
- //
- assert(!_registering);
-
- if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
- {
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
- out << "creating node `" << _name << "' session";
- }
-
- //
- // NOTE: setting _registering to true must be done before the
- // call otherwise if the callback is call immediately we'll
- // hang in the while loop.
- //
- _registering = true;
- NodeEntry* self = const_cast<NodeEntry*>(this);
- _proxy->registerWithReplica_async(new RegisterCB(self), _cache.getReplicaCache().getInternalRegistry());
- _proxy = 0; // Registration with the proxy is only attempted once.
+ //
+ // If the node proxy is set, we attempt to get the node to
+ // register with this registry.
+ //
+ assert(!_registering);
+
+ if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
+ {
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
+ out << "creating node `" << _name << "' session";
+ }
+
+ //
+ // NOTE: setting _registering to true must be done before the
+ // call otherwise if the callback is call immediately we'll
+ // hang in the while loop.
+ //
+ _registering = true;
+ NodeEntry* self = const_cast<NodeEntry*>(this);
+ _proxy->registerWithReplica_async(new RegisterCB(self), _cache.getReplicaCache().getInternalRegistry());
+ _proxy = 0; // Registration with the proxy is only attempted once.
}
while(_registering)
{
- wait();
+ wait();
}
if(!_session)
{
- throw NodeUnreachableException(_name, "the node is not active");
+ throw NodeUnreachableException(_name, "the node is not active");
}
}
@@ -776,7 +776,7 @@ NodeEntry::setProxy(const NodePrx& node)
//
if(!_session)
{
- _proxy = node;
+ _proxy = node;
}
}
@@ -786,21 +786,21 @@ NodeEntry::finishedRegistration()
Lock sync(*this);
if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
{
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
- if(_session)
- {
- out << "node `" << _name << "' session created";
- }
- else
- {
- out << "node `" << _name << "' session creation failed";
- }
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
+ if(_session)
+ {
+ out << "node `" << _name << "' session created";
+ }
+ else
+ {
+ out << "node `" << _name << "' session creation failed";
+ }
}
if(_registering)
{
- _registering = false;
- notifyAll();
+ _registering = false;
+ notifyAll();
}
}
@@ -810,14 +810,14 @@ NodeEntry::finishedRegistration(const Ice::Exception& ex)
Lock sync(*this);
if(_cache.getTraceLevels() && _cache.getTraceLevels()->node > 0)
{
- Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
- out << "node `" << _name << "' session creation failed:\n" << ex;
+ Ice::Trace out(_cache.getTraceLevels()->logger, _cache.getTraceLevels()->nodeCat);
+ out << "node `" << _name << "' session creation failed:\n" << ex;
}
if(_registering)
{
- _registering = false;
- notifyAll();
+ _registering = false;
+ notifyAll();
}
}
@@ -840,17 +840,17 @@ NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const
server->deactivationTimeout = info.descriptor->deactivationTimeout;
if(!info.descriptor->iceVersion.empty())
{
- server->iceVersion = info.descriptor->iceVersion;
+ server->iceVersion = info.descriptor->iceVersion;
}
else
{
- server->iceVersion = string(ICE_STRING_VERSION);
+ server->iceVersion = string(ICE_STRING_VERSION);
}
server->applicationDistrib = info.descriptor->applicationDistrib;
if(!info.descriptor->distrib.icepatch.empty())
{
- server->distrib = new InternalDistributionDescriptor(info.descriptor->distrib.icepatch,
- info.descriptor->distrib.directories);
+ server->distrib = new InternalDistributionDescriptor(info.descriptor->distrib.icepatch,
+ info.descriptor->distrib.directories);
}
server->options = info.descriptor->options;
server->envs = info.descriptor->envs;
@@ -875,15 +875,15 @@ NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const
IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(info.descriptor);
if(iceBox)
{
- for(ServiceInstanceDescriptorSeq::const_iterator p = iceBox->services.begin(); p != iceBox->services.end();++p)
- {
- ServiceDescriptorPtr s = p->descriptor;
- const string path = _session->getInfo()->dataDir + "/servers/" + server->id + "/config/config_" + s->name;
- props.push_back(
- createProperty("IceBox.Service." + s->name, s->entry + " --Ice.Config=\"" + path + "\""));
- servicesStr += s->name + " ";
- }
- props.push_back(createProperty("IceBox.LoadOrder", servicesStr));
+ for(ServiceInstanceDescriptorSeq::const_iterator p = iceBox->services.begin(); p != iceBox->services.end();++p)
+ {
+ ServiceDescriptorPtr s = p->descriptor;
+ const string path = _session->getInfo()->dataDir + "/servers/" + server->id + "/config/config_" + s->name;
+ props.push_back(
+ createProperty("IceBox.Service." + s->name, s->entry + " --Ice.Config=\"" + path + "\""));
+ servicesStr += s->name + " ";
+ }
+ props.push_back(createProperty("IceBox.LoadOrder", servicesStr));
}
//
@@ -899,17 +899,17 @@ NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const
//
if(getMMVersion(server->iceVersion) < 30200)
{
- const string oaPrefix = "Ice.OA.";
- for(PropertyDescriptorSeqDict::iterator p = server->properties.begin(); p != server->properties.end(); ++p)
- {
- for(PropertyDescriptorSeq::iterator q = p->second.begin(); q != p->second.end(); ++q)
- {
- if(q->name.find(oaPrefix) == 0)
- {
- q->name = q->name.substr(oaPrefix.size());
- }
- }
- }
+ const string oaPrefix = "Ice.OA.";
+ for(PropertyDescriptorSeqDict::iterator p = server->properties.begin(); p != server->properties.end(); ++p)
+ {
+ for(PropertyDescriptorSeq::iterator q = p->second.begin(); q != p->second.end(); ++q)
+ {
+ if(q->name.find(oaPrefix) == 0)
+ {
+ q->name = q->name.substr(oaPrefix.size());
+ }
+ }
+ }
}
return server;
diff --git a/cpp/src/IceGrid/NodeI.cpp b/cpp/src/IceGrid/NodeI.cpp
index a1131fcae4c..4c3ca5c8c45 100644
--- a/cpp/src/IceGrid/NodeI.cpp
+++ b/cpp/src/IceGrid/NodeI.cpp
@@ -31,151 +31,151 @@ class LogPatcherFeedback : public IcePatch2::PatcherFeedback
public:
LogPatcherFeedback(const TraceLevelsPtr& traceLevels, const string& dest) :
- _traceLevels(traceLevels),
- _startedPatch(false),
- _lastProgress(0),
- _dest(dest)
+ _traceLevels(traceLevels),
+ _startedPatch(false),
+ _lastProgress(0),
+ _dest(dest)
{
}
void
setPatchingPath(const string& path)
{
- _path = path;
- _startedPatch = false;
- _lastProgress = 0;
+ _path = path;
+ _startedPatch = false;
+ _lastProgress = 0;
}
virtual bool
noFileSummary(const string& reason)
{
- if(_traceLevels->patch > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << _dest << ": can't load summary file (will perform a thorough patch):\n" << reason;
- }
- return true;
+ if(_traceLevels->patch > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << _dest << ": can't load summary file (will perform a thorough patch):\n" << reason;
+ }
+ return true;
}
virtual bool
checksumStart()
{
- if(_traceLevels->patch > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << _dest << ": started checksum calculation";
- }
- return true;
+ if(_traceLevels->patch > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << _dest << ": started checksum calculation";
+ }
+ return true;
}
virtual bool
checksumProgress(const string& path)
{
- if(_traceLevels->patch > 2)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << _dest << ": calculating checksum for " << getBasename(path);
- }
- return true;
+ if(_traceLevels->patch > 2)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << _dest << ": calculating checksum for " << getBasename(path);
+ }
+ return true;
}
virtual bool
checksumEnd()
{
- if(_traceLevels->patch > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << _dest << ": finished checksum calculation";
- }
- return true;
+ if(_traceLevels->patch > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << _dest << ": finished checksum calculation";
+ }
+ return true;
}
virtual bool
fileListStart()
{
- if(_traceLevels->patch > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << _dest << ": getting list of file to patch";
- }
- return true;
+ if(_traceLevels->patch > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << _dest << ": getting list of file to patch";
+ }
+ return true;
}
virtual bool
fileListProgress(Ice::Int percent)
{
- return true;
+ return true;
}
virtual bool
fileListEnd()
{
- if(_traceLevels->patch > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << _dest << ": getting list of file to patch completed";
- }
- return true;
+ if(_traceLevels->patch > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << _dest << ": getting list of file to patch completed";
+ }
+ return true;
}
virtual bool
patchStart(const string& path, Ice::Long size, Ice::Long totalProgress, Ice::Long totalSize)
{
- if(_traceLevels->patch > 1 && totalSize > (1024 * 1024))
- {
- int progress = static_cast<int>(static_cast<double>(totalProgress) / totalSize * 100.0);
- progress /= 5;
- progress *= 5;
- if(progress != _lastProgress)
- {
- _lastProgress = progress;
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << _dest << ": downloaded " << progress << "% (" << totalProgress << '/' << totalSize << ')';
- if(!_path.empty())
- {
- out << " of " << _path;
- }
- }
- }
- else if(_traceLevels->patch > 0)
- {
- if(!_startedPatch)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- int roundedSize = static_cast<int>(static_cast<double>(totalSize) / 1024);
- if(roundedSize == 0 && totalSize > 0)
- {
- roundedSize = 1;
- }
- out << _dest << ": downloading " << (_path.empty() ? string("") : (_path + " ")) << roundedSize
- << "KB ";
- _startedPatch = true;
- }
- }
-
- return true;
+ if(_traceLevels->patch > 1 && totalSize > (1024 * 1024))
+ {
+ int progress = static_cast<int>(static_cast<double>(totalProgress) / totalSize * 100.0);
+ progress /= 5;
+ progress *= 5;
+ if(progress != _lastProgress)
+ {
+ _lastProgress = progress;
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << _dest << ": downloaded " << progress << "% (" << totalProgress << '/' << totalSize << ')';
+ if(!_path.empty())
+ {
+ out << " of " << _path;
+ }
+ }
+ }
+ else if(_traceLevels->patch > 0)
+ {
+ if(!_startedPatch)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ int roundedSize = static_cast<int>(static_cast<double>(totalSize) / 1024);
+ if(roundedSize == 0 && totalSize > 0)
+ {
+ roundedSize = 1;
+ }
+ out << _dest << ": downloading " << (_path.empty() ? string("") : (_path + " ")) << roundedSize
+ << "KB ";
+ _startedPatch = true;
+ }
+ }
+
+ return true;
}
virtual bool
patchProgress(Ice::Long progress, Ice::Long size, Ice::Long totalProgress, Ice::Long totalSize)
{
- return true;
+ return true;
}
virtual bool
patchEnd()
- {
- return true;
+ {
+ return true;
}
void
finishPatch()
{
- if(_traceLevels->patch > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << _dest << ": downloading completed";
- }
+ if(_traceLevels->patch > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << _dest << ": downloading completed";
+ }
}
private:
@@ -190,13 +190,13 @@ private:
}
NodeI::NodeI(const Ice::ObjectAdapterPtr& adapter,
- NodeSessionManager& sessions,
- const ActivatorPtr& activator,
- const WaitQueuePtr& waitQueue,
- const TraceLevelsPtr& traceLevels,
- const NodePrx& proxy,
- const string& name,
- const UserAccountMapperPrx& mapper) :
+ NodeSessionManager& sessions,
+ const ActivatorPtr& activator,
+ const WaitQueuePtr& waitQueue,
+ const TraceLevelsPtr& traceLevels,
+ const NodePrx& proxy,
+ const string& name,
+ const UserAccountMapperPrx& mapper) :
_communicator(adapter->getCommunicator()),
_adapter(adapter),
_sessions(sessions),
@@ -229,32 +229,32 @@ NodeI::NodeI(const Ice::ObjectAdapterPtr& adapter,
Ice::StringSeq propsAsArgs;
if(!props.empty())
{
- string::size_type end = 0;
- while(end != string::npos)
- {
- const string delim = " \t\r\n";
-
- string::size_type beg = props.find_first_not_of(delim, end);
- if(beg == string::npos)
- {
- break;
- }
-
- end = props.find_first_of(delim, beg);
- string arg;
- if(end == string::npos)
- {
- arg = props.substr(beg);
- }
- else
- {
- arg = props.substr(beg, end - beg);
- }
-
- if(arg.find("--") == 0)
- {
- arg = arg.substr(2);
- }
+ string::size_type end = 0;
+ while(end != string::npos)
+ {
+ const string delim = " \t\r\n";
+
+ string::size_type beg = props.find_first_not_of(delim, end);
+ if(beg == string::npos)
+ {
+ break;
+ }
+
+ end = props.find_first_of(delim, beg);
+ string arg;
+ if(end == string::npos)
+ {
+ arg = props.substr(beg);
+ }
+ else
+ {
+ arg = props.substr(beg, end - beg);
+ }
+
+ if(arg.find("--") == 0)
+ {
+ arg = arg.substr(2);
+ }
//
// Extract the key/value
@@ -283,7 +283,7 @@ NodeI::NodeI(const Ice::ObjectAdapterPtr& adapter,
}
_propertiesOverride.push_back(createProperty(key, value));
- }
+ }
}
}
@@ -293,274 +293,274 @@ NodeI::~NodeI()
void
NodeI::loadServer_async(const AMD_Node_loadServerPtr& amdCB,
- const InternalServerDescriptorPtr& descriptor,
- const string& replicaName,
- const Ice::Current& current)
+ const InternalServerDescriptorPtr& descriptor,
+ const string& replicaName,
+ const Ice::Current& current)
{
ServerCommandPtr command;
{
- Lock sync(*this);
- ++_serial;
-
- Ice::Identity id = createServerIdentity(descriptor->id);
-
- //
- // Check if we already have a servant for this server. If that's
- // the case, the server is already loaded and we just need to
- // update it.
- //
- while(true)
- {
- bool added = false;
- ServerIPtr server = ServerIPtr::dynamicCast(_adapter->find(id));
- if(!server)
- {
- ServerPrx proxy = ServerPrx::uncheckedCast(_adapter->createProxy(id));
- server = new ServerI(this, proxy, _serversDir, descriptor->id, _waitTime);
- _adapter->add(server, id);
- added = true;
- }
-
- try
- {
- command = server->load(amdCB, descriptor, replicaName);
- }
- catch(const Ice::ObjectNotExistException&)
- {
- assert(!added);
- continue;
- }
- catch(const Ice::Exception&)
- {
- if(added)
- {
- _adapter->remove(id);
- }
- throw;
- }
- break;
- }
+ Lock sync(*this);
+ ++_serial;
+
+ Ice::Identity id = createServerIdentity(descriptor->id);
+
+ //
+ // Check if we already have a servant for this server. If that's
+ // the case, the server is already loaded and we just need to
+ // update it.
+ //
+ while(true)
+ {
+ bool added = false;
+ ServerIPtr server = ServerIPtr::dynamicCast(_adapter->find(id));
+ if(!server)
+ {
+ ServerPrx proxy = ServerPrx::uncheckedCast(_adapter->createProxy(id));
+ server = new ServerI(this, proxy, _serversDir, descriptor->id, _waitTime);
+ _adapter->add(server, id);
+ added = true;
+ }
+
+ try
+ {
+ command = server->load(amdCB, descriptor, replicaName);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ assert(!added);
+ continue;
+ }
+ catch(const Ice::Exception&)
+ {
+ if(added)
+ {
+ _adapter->remove(id);
+ }
+ throw;
+ }
+ break;
+ }
}
if(command)
{
- command->execute();
+ command->execute();
}
}
void
NodeI::destroyServer_async(const AMD_Node_destroyServerPtr& amdCB,
- const string& serverId,
- const string& uuid,
- int revision,
- const string& replicaName,
- const Ice::Current& current)
+ const string& serverId,
+ const string& uuid,
+ int revision,
+ const string& replicaName,
+ const Ice::Current& current)
{
ServerCommandPtr command;
{
- Lock sync(*this);
- ++_serial;
-
- ServerIPtr server = ServerIPtr::dynamicCast(_adapter->find(createServerIdentity(serverId)));
- if(!server)
- {
- server = new ServerI(this, 0, _serversDir, serverId, _waitTime);
- }
-
- //
- // Destroy the server object if it's loaded.
- //
- try
- {
- command = server->destroy(amdCB, uuid, revision, replicaName);
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
+ Lock sync(*this);
+ ++_serial;
+
+ ServerIPtr server = ServerIPtr::dynamicCast(_adapter->find(createServerIdentity(serverId)));
+ if(!server)
+ {
+ server = new ServerI(this, 0, _serversDir, serverId, _waitTime);
+ }
+
+ //
+ // Destroy the server object if it's loaded.
+ //
+ try
+ {
+ command = server->destroy(amdCB, uuid, revision, replicaName);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
}
if(command)
{
- command->execute();
+ command->execute();
}
}
void
NodeI::patch_async(const AMD_Node_patchPtr& amdCB,
- const PatcherFeedbackPrx& feedback,
- const string& application,
- const string& server,
- const InternalDistributionDescriptorPtr& appDistrib,
- bool shutdown,
- const Ice::Current&)
+ const PatcherFeedbackPrx& feedback,
+ const string& application,
+ const string& server,
+ const InternalDistributionDescriptorPtr& appDistrib,
+ bool shutdown,
+ const Ice::Current&)
{
amdCB->ice_response();
{
- Lock sync(*this);
- while(_patchInProgress.find(application) != _patchInProgress.end())
- {
- wait();
- }
- _patchInProgress.insert(application);
+ Lock sync(*this);
+ while(_patchInProgress.find(application) != _patchInProgress.end())
+ {
+ wait();
+ }
+ _patchInProgress.insert(application);
}
set<ServerIPtr> servers;
if(!appDistrib->icepatch.empty())
{
- //
- // Get all the application servers (even the ones which
- // don't have a distribution since they depend on the
- // application distribution).
- //
- servers = getApplicationServers(application);
+ //
+ // Get all the application servers (even the ones which
+ // don't have a distribution since they depend on the
+ // application distribution).
+ //
+ servers = getApplicationServers(application);
}
else if(server.empty())
{
- //
- // Get all the application servers which have a distribution.
- //
- servers = getApplicationServers(application);
- set<ServerIPtr>::iterator s = servers.begin();
- while(s != servers.end())
- {
- if((*s)->getDistribution())
- {
- ++s;
- }
- else
- {
- servers.erase(s++);
- }
- }
+ //
+ // Get all the application servers which have a distribution.
+ //
+ servers = getApplicationServers(application);
+ set<ServerIPtr>::iterator s = servers.begin();
+ while(s != servers.end())
+ {
+ if((*s)->getDistribution())
+ {
+ ++s;
+ }
+ else
+ {
+ servers.erase(s++);
+ }
+ }
}
else
{
- //
- // Get the given server.
- //
- Ice::Identity id = createServerIdentity(server);
- ServerIPtr svr = ServerIPtr::dynamicCast(_adapter->find(id));
- if(svr)
- {
- servers.insert(svr);
- }
+ //
+ // Get the given server.
+ //
+ Ice::Identity id = createServerIdentity(server);
+ ServerIPtr svr = ServerIPtr::dynamicCast(_adapter->find(id));
+ if(svr)
+ {
+ servers.insert(svr);
+ }
}
string failure;
try
{
- set<ServerIPtr>::iterator s = servers.begin();
- vector<string> running;
- while(s != servers.end())
- {
- try
- {
- if(!(*s)->startPatch(shutdown))
- {
- running.push_back((*s)->getId());
- servers.erase(s++);
- }
- else
- {
- ++s;
- }
- }
- catch(const Ice::ObjectNotExistException&)
- {
- servers.erase(s++);
- }
- }
-
- if((servers.empty() || !appDistrib->icepatch.empty()) && !running.empty())
- {
- if(running.size() == 1)
- {
- throw "server `" + toString(running) + "' is active";
- }
- else
- {
- throw "servers `" + toString(running, ", ") + "' are active";
- }
- }
-
- for(s = servers.begin(); s != servers.end(); ++s)
- {
- (*s)->waitForPatch();
- }
-
- //
- // Patch the application.
- //
- FileServerPrx icepatch;
- if(!appDistrib->icepatch.empty())
- {
- icepatch = FileServerPrx::checkedCast(_communicator->stringToProxy(appDistrib->icepatch));
- if(!icepatch)
- {
- throw "proxy `" + appDistrib->icepatch + "' is not a file server.";
- }
- patch(icepatch, "distrib/" + application, appDistrib->directories);
- }
-
- //
- // Patch the server(s).
- //
- for(s = servers.begin(); s != servers.end(); ++s)
- {
- InternalDistributionDescriptorPtr dist = (*s)->getDistribution();
- if(!dist || (!server.empty() && (*s)->getId() != server))
- {
- continue;
- }
-
- icepatch = FileServerPrx::checkedCast(_communicator->stringToProxy(dist->icepatch));
- if(!icepatch)
- {
- throw "proxy `" + dist->icepatch + "' is not a file server.";
- }
- patch(icepatch, "servers/" + (*s)->getId() + "/distrib", dist->directories);
-
- if(!server.empty())
- {
- break;
- }
- }
+ set<ServerIPtr>::iterator s = servers.begin();
+ vector<string> running;
+ while(s != servers.end())
+ {
+ try
+ {
+ if(!(*s)->startPatch(shutdown))
+ {
+ running.push_back((*s)->getId());
+ servers.erase(s++);
+ }
+ else
+ {
+ ++s;
+ }
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ servers.erase(s++);
+ }
+ }
+
+ if((servers.empty() || !appDistrib->icepatch.empty()) && !running.empty())
+ {
+ if(running.size() == 1)
+ {
+ throw "server `" + toString(running) + "' is active";
+ }
+ else
+ {
+ throw "servers `" + toString(running, ", ") + "' are active";
+ }
+ }
+
+ for(s = servers.begin(); s != servers.end(); ++s)
+ {
+ (*s)->waitForPatch();
+ }
+
+ //
+ // Patch the application.
+ //
+ FileServerPrx icepatch;
+ if(!appDistrib->icepatch.empty())
+ {
+ icepatch = FileServerPrx::checkedCast(_communicator->stringToProxy(appDistrib->icepatch));
+ if(!icepatch)
+ {
+ throw "proxy `" + appDistrib->icepatch + "' is not a file server.";
+ }
+ patch(icepatch, "distrib/" + application, appDistrib->directories);
+ }
+
+ //
+ // Patch the server(s).
+ //
+ for(s = servers.begin(); s != servers.end(); ++s)
+ {
+ InternalDistributionDescriptorPtr dist = (*s)->getDistribution();
+ if(!dist || (!server.empty() && (*s)->getId() != server))
+ {
+ continue;
+ }
+
+ icepatch = FileServerPrx::checkedCast(_communicator->stringToProxy(dist->icepatch));
+ if(!icepatch)
+ {
+ throw "proxy `" + dist->icepatch + "' is not a file server.";
+ }
+ patch(icepatch, "servers/" + (*s)->getId() + "/distrib", dist->directories);
+
+ if(!server.empty())
+ {
+ break;
+ }
+ }
}
catch(const Ice::LocalException& e)
{
- ostringstream os;
- os << e;
- failure = os.str();
+ ostringstream os;
+ os << e;
+ failure = os.str();
}
catch(const string& e)
{
- failure = e;
+ failure = e;
}
catch(const char* e)
{
- failure = e;
+ failure = e;
}
for(set<ServerIPtr>::const_iterator s = servers.begin(); s != servers.end(); ++s)
{
- (*s)->finishPatch();
+ (*s)->finishPatch();
}
{
- Lock sync(*this);
- _patchInProgress.erase(application);
- notifyAll();
+ Lock sync(*this);
+ _patchInProgress.erase(application);
+ notifyAll();
}
try
{
- if(failure.empty())
- {
- feedback->finished();
- }
- else
- {
- feedback->failed(failure);
- }
+ if(failure.empty())
+ {
+ feedback->finished();
+ }
+ else
+ {
+ feedback->failed(failure);
+ }
}
catch(const Ice::LocalException&)
{
@@ -623,7 +623,7 @@ NodeI::getOffsetFromEnd(const string& filename, int count, const Ice::Current&)
bool
NodeI::read(const string& filename, Ice::Long pos, int size, Ice::Long& newPos, Ice::StringSeq& lines,
- const Ice::Current&) const
+ const Ice::Current&) const
{
return _fileCache->read(getFilePath(filename), pos, size, newPos, lines);
}
@@ -731,26 +731,26 @@ NodeI::checkConsistency(const NodeSessionPrx& session)
vector<ServerCommandPtr> commands;
while(true)
{
- {
- Lock sync(*this);
- if(serial == _serial)
- {
- _serial = 1; // We can reset the serial number.
- commands = checkConsistencyNoSync(servers);
- break;
- }
- serial = _serial;
- }
- assert(session);
- try
- {
- servers = session->getServers();
- }
- catch(const Ice::LocalException&)
- {
- return; // The connection with the session was lost.
- }
- sort(servers.begin(), servers.end());
+ {
+ Lock sync(*this);
+ if(serial == _serial)
+ {
+ _serial = 1; // We can reset the serial number.
+ commands = checkConsistencyNoSync(servers);
+ break;
+ }
+ serial = _serial;
+ }
+ assert(session);
+ try
+ {
+ servers = session->getServers();
+ }
+ catch(const Ice::LocalException&)
+ {
+ return; // The connection with the session was lost.
+ }
+ sort(servers.begin(), servers.end());
}
for_each(commands.begin(), commands.end(), IceUtil::voidMemFun(&ServerCommand::execute));
@@ -766,31 +766,31 @@ NodeI::addObserver(const NodeSessionPrx& session, const NodeObserverPrx& observe
ServerDynamicInfoSeq serverInfos;
AdapterDynamicInfoSeq adapterInfos;
for(map<string, ServerDynamicInfo>::const_iterator p = _serversDynamicInfo.begin();
- p != _serversDynamicInfo.end(); ++p)
+ p != _serversDynamicInfo.end(); ++p)
{
- assert(p->second.state != Destroyed && (p->second.state != Inactive || !p->second.enabled));
- serverInfos.push_back(p->second);
+ assert(p->second.state != Destroyed && (p->second.state != Inactive || !p->second.enabled));
+ serverInfos.push_back(p->second);
}
for(map<string, AdapterDynamicInfo>::const_iterator q = _adaptersDynamicInfo.begin();
- q != _adaptersDynamicInfo.end(); ++q)
+ q != _adaptersDynamicInfo.end(); ++q)
{
- assert(q->second.proxy);
- adapterInfos.push_back(q->second);
+ assert(q->second.proxy);
+ adapterInfos.push_back(q->second);
}
try
{
- NodeDynamicInfo info;
- info.info = _platform.getNodeInfo();
- info.servers = serverInfos;
- info.adapters = adapterInfos;
- observer->nodeUp(info);
+ NodeDynamicInfo info;
+ info.info = _platform.getNodeInfo();
+ info.servers = serverInfos;
+ info.adapters = adapterInfos;
+ observer->nodeUp(info);
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_traceLevels->logger);
- out << "unexpected observer exception:\n" << ex;
+ Ice::Warning out(_traceLevels->logger);
+ out << "unexpected observer exception:\n" << ex;
}
}
@@ -808,11 +808,11 @@ NodeI::observerUpdateServer(const ServerDynamicInfo& info)
if(info.state == Destroyed || info.state == Inactive && info.enabled)
{
- _serversDynamicInfo.erase(info.id);
+ _serversDynamicInfo.erase(info.id);
}
else
{
- _serversDynamicInfo[info.id] = info;
+ _serversDynamicInfo[info.id] = info;
}
//
@@ -824,18 +824,18 @@ NodeI::observerUpdateServer(const ServerDynamicInfo& info)
set<NodeObserverPrx> sent;
for(map<NodeSessionPrx, NodeObserverPrx>::const_iterator p = _observers.begin(); p != _observers.end(); ++p)
{
- if(sent.find(p->second) == sent.end())
- {
- try
- {
- p->second->updateServer(_name, info);
- sent.insert(p->second);
- }
- catch(const Ice::LocalException&)
- {
- // IGNORE
- }
- }
+ if(sent.find(p->second) == sent.end())
+ {
+ try
+ {
+ p->second->updateServer(_name, info);
+ sent.insert(p->second);
+ }
+ catch(const Ice::LocalException&)
+ {
+ // IGNORE
+ }
+ }
}
}
@@ -846,11 +846,11 @@ NodeI::observerUpdateAdapter(const AdapterDynamicInfo& info)
if(info.proxy)
{
- _adaptersDynamicInfo[info.id] = info;
+ _adaptersDynamicInfo[info.id] = info;
}
else
{
- _adaptersDynamicInfo.erase(info.id);
+ _adaptersDynamicInfo.erase(info.id);
}
//
@@ -862,17 +862,17 @@ NodeI::observerUpdateAdapter(const AdapterDynamicInfo& info)
set<NodeObserverPrx> sent;
for(map<NodeSessionPrx, NodeObserverPrx>::const_iterator p = _observers.begin(); p != _observers.end(); ++p)
{
- if(sent.find(p->second) == sent.end())
- {
- try
- {
- p->second->updateAdapter(_name, info);
- }
- catch(const Ice::LocalException&)
- {
- // IGNORE
- }
- }
+ if(sent.find(p->second) == sent.end())
+ {
+ try
+ {
+ p->second->updateAdapter(_name, info);
+ }
+ catch(const Ice::LocalException&)
+ {
+ // IGNORE
+ }
+ }
}
}
@@ -883,13 +883,13 @@ NodeI::addServer(const ServerIPtr& server, const string& application, bool depen
if(dependsOnApplicationDistrib)
{
- map<string, set<ServerIPtr> >::iterator p = _serversByApplication.find(application);
- if(p == _serversByApplication.end())
- {
- map<string, set<ServerIPtr> >::value_type v(application, set<ServerIPtr>());
- p = _serversByApplication.insert(p, v);
- }
- p->second.insert(server);
+ map<string, set<ServerIPtr> >::iterator p = _serversByApplication.find(application);
+ if(p == _serversByApplication.end())
+ {
+ map<string, set<ServerIPtr> >::value_type v(application, set<ServerIPtr>());
+ p = _serversByApplication.insert(p, v);
+ }
+ p->second.insert(server);
}
}
@@ -900,15 +900,15 @@ NodeI::removeServer(const ServerIPtr& server, const std::string& application, bo
if(dependsOnApplicationDistrib)
{
- map<string, set<ServerIPtr> >::iterator p = _serversByApplication.find(application);
- if(p != _serversByApplication.end())
- {
- p->second.erase(server);
- if(p->second.empty())
- {
- _serversByApplication.erase(p);
- }
- }
+ map<string, set<ServerIPtr> >::iterator p = _serversByApplication.find(application);
+ if(p != _serversByApplication.end())
+ {
+ p->second.erase(server);
+ if(p->second.empty())
+ {
+ _serversByApplication.erase(p);
+ }
+ }
}
}
@@ -924,78 +924,78 @@ NodeI::checkConsistencyNoSync(const Ice::StringSeq& servers)
Ice::StringSeq contents;
try
{
- contents = readDirectory(_serversDir);
+ contents = readDirectory(_serversDir);
}
catch(const string& msg)
{
- Ice::Error out(_traceLevels->logger);
- out << "couldn't read directory `" << _serversDir << "':" << msg;
- return commands;
+ Ice::Error out(_traceLevels->logger);
+ out << "couldn't read directory `" << _serversDir << "':" << msg;
+ return commands;
}
vector<string> remove;
set_difference(contents.begin(), contents.end(), servers.begin(), servers.end(), back_inserter(remove));
-
+
//
// Remove the extra servers if possible.
//
{
- vector<string>::iterator p = remove.begin();
- while(p != remove.end())
- {
- ServerIPtr server = ServerIPtr::dynamicCast(_adapter->find(createServerIdentity(*p)));
- if(server)
- {
- //
- // If the server is loaded, we invoke on it to destroy it.
- //
- try
- {
- ServerCommandPtr command = server->destroy(0, "", 0, "Master");
- if(command)
- {
- commands.push_back(command);
- }
- p = remove.erase(p);
- continue;
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Error out(_traceLevels->logger);
- out << "server `" << *p << "' destroy failed:" << ex;
- }
- catch(const string&)
- {
- assert(false);
- }
- }
-
- try
- {
- if(canRemoveServerDirectory(*p))
- {
- //
- // If the server directory can be removed and we
- // either remove it or back it up before to remove it.
- //
- removeRecursive(_serversDir + "/" + *p);
- p = remove.erase(p);
- continue;
- }
- }
- catch(const string& msg)
- {
- Ice::Warning out(_traceLevels->logger);
- out << "removing server directory `" << _serversDir << "/" << *p << "' failed:" << msg;
- }
-
- ++p;
- }
+ vector<string>::iterator p = remove.begin();
+ while(p != remove.end())
+ {
+ ServerIPtr server = ServerIPtr::dynamicCast(_adapter->find(createServerIdentity(*p)));
+ if(server)
+ {
+ //
+ // If the server is loaded, we invoke on it to destroy it.
+ //
+ try
+ {
+ ServerCommandPtr command = server->destroy(0, "", 0, "Master");
+ if(command)
+ {
+ commands.push_back(command);
+ }
+ p = remove.erase(p);
+ continue;
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Error out(_traceLevels->logger);
+ out << "server `" << *p << "' destroy failed:" << ex;
+ }
+ catch(const string&)
+ {
+ assert(false);
+ }
+ }
+
+ try
+ {
+ if(canRemoveServerDirectory(*p))
+ {
+ //
+ // If the server directory can be removed and we
+ // either remove it or back it up before to remove it.
+ //
+ removeRecursive(_serversDir + "/" + *p);
+ p = remove.erase(p);
+ continue;
+ }
+ }
+ catch(const string& msg)
+ {
+ Ice::Warning out(_traceLevels->logger);
+ out << "removing server directory `" << _serversDir << "/" << *p << "' failed:" << msg;
+ }
+
+ ++p;
+ }
}
-
+
if(remove.empty())
{
- return commands;
+ return commands;
}
//
@@ -1005,54 +1005,54 @@ NodeI::checkConsistencyNoSync(const Ice::StringSeq& servers)
//
try
{
- contents.clear();
- contents = readDirectory(_tmpDir);
+ contents.clear();
+ contents = readDirectory(_tmpDir);
}
catch(const string& msg)
{
- Ice::Error out(_traceLevels->logger);
- out << "couldn't read directory `" << _tmpDir << "':" << msg;
- return commands;
+ Ice::Error out(_traceLevels->logger);
+ out << "couldn't read directory `" << _tmpDir << "':" << msg;
+ return commands;
}
if(contents.size() < 10)
{
- ostringstream os;
- os << "servers-" << contents.size();
- contents.push_back(os.str());
- sort(contents.begin(), contents.end(), greater<string>());
+ ostringstream os;
+ os << "servers-" << contents.size();
+ contents.push_back(os.str());
+ sort(contents.begin(), contents.end(), greater<string>());
}
else if(contents.size() == 10)
{
- sort(contents.begin(), contents.end(), greater<string>());
- try
- {
- removeRecursive(_tmpDir + "/" + *contents.begin());
- }
- catch(const string& msg)
- {
- Ice::Warning out(_traceLevels->logger);
- out << msg;
- }
+ sort(contents.begin(), contents.end(), greater<string>());
+ try
+ {
+ removeRecursive(_tmpDir + "/" + *contents.begin());
+ }
+ catch(const string& msg)
+ {
+ Ice::Warning out(_traceLevels->logger);
+ out << msg;
+ }
}
try
{
- Ice::StringSeq::const_iterator p;
- for(p = contents.begin(); p != (contents.end() - 1); ++p)
- {
- rename(_tmpDir + "/" + *(p + 1), _tmpDir + "/" + *p);
- }
- createDirectoryRecursive(_tmpDir + "/servers-0");
- for(p = remove.begin(); p != remove.end(); ++p)
- {
- rename(_serversDir + "/" + *p, _tmpDir + "/servers-0/" + *p);
- }
+ Ice::StringSeq::const_iterator p;
+ for(p = contents.begin(); p != (contents.end() - 1); ++p)
+ {
+ rename(_tmpDir + "/" + *(p + 1), _tmpDir + "/" + *p);
+ }
+ createDirectoryRecursive(_tmpDir + "/servers-0");
+ for(p = remove.begin(); p != remove.end(); ++p)
+ {
+ rename(_serversDir + "/" + *p, _tmpDir + "/servers-0/" + *p);
+ }
}
catch(const string& msg)
{
- Ice::Warning out(_traceLevels->logger);
- out << "rotation failed: " << msg;
+ Ice::Warning out(_traceLevels->logger);
+ out << "rotation failed: " << msg;
}
return commands;
@@ -1076,7 +1076,7 @@ NodeI::canRemoveServerDirectory(const string& name)
remove(contents.begin(), contents.end(), "distrib");
if(!contents.empty())
{
- return false;
+ return false;
}
contents = readDirectory(_serversDir + "/" + name + "/config");
@@ -1084,21 +1084,21 @@ NodeI::canRemoveServerDirectory(const string& name)
Ice::StringSeq::const_iterator p;
for(p = contents.begin() ; p != contents.end(); ++p)
{
- if(p->find("config") != 0)
- {
- return false;
- }
+ if(p->find("config") != 0)
+ {
+ return false;
+ }
}
contents = readDirectory(_serversDir + "/" + name + "/dbs");
for(p = contents.begin() ; p != contents.end(); ++p)
{
- Ice::StringSeq files = readDirectory(_serversDir + "/" + name + "/dbs/" + *p);
- remove(files.begin(), files.end(), "DB_CONFIG");
- if(!files.empty())
- {
- return false;
- }
+ Ice::StringSeq files = readDirectory(_serversDir + "/" + name + "/dbs/" + *p);
+ remove(files.begin(), files.end(), "DB_CONFIG");
+ if(!files.empty())
+ {
+ return false;
+ }
}
return true;
@@ -1113,28 +1113,28 @@ NodeI::patch(const FileServerPrx& icepatch, const string& dest, const vector<str
bool aborted = !patcher->prepare();
if(!aborted)
{
- if(directories.empty())
- {
- aborted = !patcher->patch("");
- dynamic_cast<LogPatcherFeedback*>(feedback.get())->finishPatch();
- }
- else
- {
- for(vector<string>::const_iterator p = directories.begin(); p != directories.end(); ++p)
- {
- dynamic_cast<LogPatcherFeedback*>(feedback.get())->setPatchingPath(*p);
- if(!patcher->patch(*p))
- {
- aborted = true;
- break;
- }
- dynamic_cast<LogPatcherFeedback*>(feedback.get())->finishPatch();
- }
- }
+ if(directories.empty())
+ {
+ aborted = !patcher->patch("");
+ dynamic_cast<LogPatcherFeedback*>(feedback.get())->finishPatch();
+ }
+ else
+ {
+ for(vector<string>::const_iterator p = directories.begin(); p != directories.end(); ++p)
+ {
+ dynamic_cast<LogPatcherFeedback*>(feedback.get())->setPatchingPath(*p);
+ if(!patcher->patch(*p))
+ {
+ aborted = true;
+ break;
+ }
+ dynamic_cast<LogPatcherFeedback*>(feedback.get())->finishPatch();
+ }
+ }
}
if(!aborted)
{
- patcher->finish();
+ patcher->finish();
}
//
@@ -1150,7 +1150,7 @@ NodeI::getApplicationServers(const string& application) const
map<string, set<ServerIPtr> >::const_iterator p = _serversByApplication.find(application);
if(p != _serversByApplication.end())
{
- servers = p->second;
+ servers = p->second;
}
return servers;
}
@@ -1170,23 +1170,23 @@ NodeI::getFilePath(const string& filename) const
string file;
if(filename == "stderr")
{
- file = _communicator->getProperties()->getProperty("Ice.StdErr");
- if(file.empty())
- {
- throw FileNotAvailableException("Ice.StdErr configuration property is not set");
- }
+ file = _communicator->getProperties()->getProperty("Ice.StdErr");
+ if(file.empty())
+ {
+ throw FileNotAvailableException("Ice.StdErr configuration property is not set");
+ }
}
else if(filename == "stdout")
{
- file = _communicator->getProperties()->getProperty("Ice.StdOut");
- if(file.empty())
- {
- throw FileNotAvailableException("Ice.StdOut configuration property is not set");
- }
+ file = _communicator->getProperties()->getProperty("Ice.StdOut");
+ if(file.empty())
+ {
+ throw FileNotAvailableException("Ice.StdOut configuration property is not set");
+ }
}
else
{
- throw FileNotAvailableException("unknown file");
+ throw FileNotAvailableException("unknown file");
}
return file;
}
diff --git a/cpp/src/IceGrid/NodeI.h b/cpp/src/IceGrid/NodeI.h
index 7572a0b648c..0f472f0bdbe 100644
--- a/cpp/src/IceGrid/NodeI.h
+++ b/cpp/src/IceGrid/NodeI.h
@@ -41,23 +41,23 @@ class NodeI : public Node, public IceUtil::Monitor<IceUtil::Mutex>
public:
NodeI(const Ice::ObjectAdapterPtr&, NodeSessionManager&, const ActivatorPtr&, const WaitQueuePtr&,
- const TraceLevelsPtr&, const NodePrx&, const std::string&, const UserAccountMapperPrx&);
+ const TraceLevelsPtr&, const NodePrx&, const std::string&, const UserAccountMapperPrx&);
virtual ~NodeI();
virtual void loadServer_async(const AMD_Node_loadServerPtr&,
- const InternalServerDescriptorPtr&,
- const std::string&,
- const Ice::Current&);
+ const InternalServerDescriptorPtr&,
+ const std::string&,
+ const Ice::Current&);
virtual void destroyServer_async(const AMD_Node_destroyServerPtr&,
- const std::string&,
- const std::string&,
- int,
- const std::string&,
- const Ice::Current&);
+ const std::string&,
+ const std::string&,
+ int,
+ const std::string&,
+ const Ice::Current&);
virtual void patch_async(const AMD_Node_patchPtr&, const PatcherFeedbackPrx&, const std::string&,
- const std::string&, const InternalDistributionDescriptorPtr&, bool, const Ice::Current&);
+ const std::string&, const InternalDistributionDescriptorPtr&, bool, const Ice::Current&);
virtual void registerWithReplica(const InternalRegistryPrx&, const Ice::Current&);
diff --git a/cpp/src/IceGrid/NodeSessionI.cpp b/cpp/src/IceGrid/NodeSessionI.cpp
index afc5619c2d5..6d12869379e 100644
--- a/cpp/src/IceGrid/NodeSessionI.cpp
+++ b/cpp/src/IceGrid/NodeSessionI.cpp
@@ -24,26 +24,26 @@ class PatcherFeedbackI : public PatcherFeedback
public:
PatcherFeedbackI(const string& node,
- const NodeSessionIPtr& session,
- const Ice::Identity id,
- const PatcherFeedbackAggregatorPtr& aggregator) :
- _node(node),
- _session(session),
- _id(id),
- _aggregator(aggregator)
+ const NodeSessionIPtr& session,
+ const Ice::Identity id,
+ const PatcherFeedbackAggregatorPtr& aggregator) :
+ _node(node),
+ _session(session),
+ _id(id),
+ _aggregator(aggregator)
{
}
void finished(const Ice::Current&)
{
- _aggregator->finished(_node);
- _session->removeFeedback(this, _id);
+ _aggregator->finished(_node);
+ _session->removeFeedback(this, _id);
}
virtual void failed(const string& reason, const Ice::Current& = Ice::Current())
{
- _aggregator->failed(_node, reason);
- _session->removeFeedback(this, _id);
+ _aggregator->failed(_node, reason);
+ _session->removeFeedback(this, _id);
}
private:
@@ -57,10 +57,10 @@ private:
};
PatcherFeedbackAggregator::PatcherFeedbackAggregator(Ice::Identity id,
- const TraceLevelsPtr& traceLevels,
- const string& type,
- const string& name,
- int nodeCount) :
+ const TraceLevelsPtr& traceLevels,
+ const string& type,
+ const string& name,
+ int nodeCount) :
_id(id),
_traceLevels(traceLevels),
_type(type),
@@ -79,13 +79,13 @@ PatcherFeedbackAggregator::finished(const string& node)
Lock sync(*this);
if(_successes.find(node) != _successes.end() || _failures.find(node) != _failures.end())
{
- return;
+ return;
}
if(_traceLevels->patch > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << "finished patching of " << _type << " `" << _name << "' on node `" << node << "'";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << "finished patching of " << _type << " `" << _name << "' on node `" << node << "'";
}
_successes.insert(node);
@@ -98,13 +98,13 @@ PatcherFeedbackAggregator::failed(const string& node, const string& failure)
Lock sync(*this);
if(_successes.find(node) != _successes.end() || _failures.find(node) != _failures.end())
{
- return;
+ return;
}
if(_traceLevels->patch > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
- out << "patching of " << _type << " `" << _name << "' on node `" << node <<"' failed:\n" << failure;
+ Ice::Trace out(_traceLevels->logger, _traceLevels->patchCat);
+ out << "patching of " << _type << " `" << _name << "' on node `" << node <<"' failed:\n" << failure;
}
_failures.insert(node);
@@ -117,25 +117,25 @@ PatcherFeedbackAggregator::checkIfDone()
{
if(static_cast<int>(_successes.size() + _failures.size()) == _count)
{
- if(!_failures.empty())
- {
- sort(_reasons.begin(), _reasons.end());
- PatchException ex;
- ex.reasons = _reasons;
- exception(ex);
- }
- else
- {
- response();
- }
+ if(!_failures.empty())
+ {
+ sort(_reasons.begin(), _reasons.end());
+ PatchException ex;
+ ex.reasons = _reasons;
+ exception(ex);
+ }
+ else
+ {
+ response();
+ }
}
}
NodeSessionI::NodeSessionI(const DatabasePtr& database,
- const NodePrx& node,
- const InternalNodeInfoPtr& info,
- int timeout,
- const LoadInfo& load) :
+ const NodePrx& node,
+ const InternalNodeInfoPtr& info,
+ int timeout,
+ const LoadInfo& load) :
_database(database),
_traceLevels(database->getTraceLevels()),
_node(node),
@@ -148,34 +148,34 @@ NodeSessionI::NodeSessionI(const DatabasePtr& database,
__setNoDelete(true);
try
{
- _database->getNode(info->name, true)->setSession(this);
+ _database->getNode(info->name, true)->setSession(this);
- ObjectInfo objInfo;
- objInfo.type = Node::ice_staticId();
- objInfo.proxy = _node;
- _database->addInternalObject(objInfo, true); // Add or update previous node proxy.
+ ObjectInfo objInfo;
+ objInfo.type = Node::ice_staticId();
+ objInfo.proxy = _node;
+ _database->addInternalObject(objInfo, true); // Add or update previous node proxy.
- _proxy = NodeSessionPrx::uncheckedCast(_database->getInternalAdapter()->addWithUUID(this));
+ _proxy = NodeSessionPrx::uncheckedCast(_database->getInternalAdapter()->addWithUUID(this));
}
catch(const NodeActiveException&)
{
- __setNoDelete(false);
- throw;
+ __setNoDelete(false);
+ throw;
}
catch(...)
{
- try
- {
- _database->removeInternalObject(_node->ice_getIdentity());
- }
- catch(const ObjectNotRegisteredException&)
- {
- }
-
- _database->getNode(info->name)->setSession(0);
-
- __setNoDelete(false);
- throw;
+ try
+ {
+ _database->removeInternalObject(_node->ice_getIdentity());
+ }
+ catch(const ObjectNotRegisteredException&)
+ {
+ }
+
+ _database->getNode(info->name)->setSession(0);
+
+ __setNoDelete(false);
+ throw;
}
__setNoDelete(false);
}
@@ -186,7 +186,7 @@ NodeSessionI::keepAlive(const LoadInfo& load, const Ice::Current& current)
Lock sync(*this);
if(_destroy)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
}
_timestamp = IceUtil::Time::now();
@@ -194,9 +194,9 @@ NodeSessionI::keepAlive(const LoadInfo& load, const Ice::Current& current)
if(_traceLevels->node > 2)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->nodeCat);
- out << "node `" << _info->name << "' keep alive ";
- out << "(load = " << _load.avg1 << ", " << _load.avg5 << ", " << _load.avg15 << ")";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->nodeCat);
+ out << "node `" << _info->name << "' keep alive ";
+ out << "(load = " << _load.avg1 << ", " << _load.avg5 << ", " << _load.avg15 << ")";
}
}
@@ -206,12 +206,12 @@ NodeSessionI::setReplicaObserver(const ReplicaObserverPrx& observer, const Ice::
Lock sync(*this);
if(_destroy)
{
- return;
+ return;
}
else if(_replicaObserver) // This might happen on activation of the node.
{
- assert(_replicaObserver == observer);
- return;
+ assert(_replicaObserver == observer);
+ return;
}
_replicaObserver = observer;
@@ -255,16 +255,16 @@ NodeSessionI::getServers(const Ice::Current& current) const
Ice::StringSeq names;
for(ServerEntrySeq::const_iterator p = servers.begin(); p != servers.end(); ++p)
{
- names.push_back((*p)->getId());
+ names.push_back((*p)->getId());
}
return names;
}
void
NodeSessionI::waitForApplicationUpdate_async(const AMD_NodeSession_waitForApplicationUpdatePtr& cb,
- const std::string& application,
- int revision,
- const Ice::Current&) const
+ const std::string& application,
+ int revision,
+ const Ice::Current&) const
{
_database->waitForApplicationUpdate(cb, application, revision);
}
@@ -281,7 +281,7 @@ NodeSessionI::timestamp() const
Lock sync(*this);
if(_destroy)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
}
return _timestamp;
}
@@ -294,10 +294,10 @@ NodeSessionI::shutdown()
void
NodeSessionI::patch(const PatcherFeedbackAggregatorPtr& aggregator,
- const string& application,
- const string& server,
- const InternalDistributionDescriptorPtr& dist,
- bool shutdown)
+ const string& application,
+ const string& server,
+ const InternalDistributionDescriptorPtr& dist,
+ bool shutdown)
{
Ice::Identity id;
id.category = _database->getInstanceName();
@@ -306,21 +306,21 @@ NodeSessionI::patch(const PatcherFeedbackAggregatorPtr& aggregator,
PatcherFeedbackPtr obj = new PatcherFeedbackI(_info->name, this, id, aggregator);
try
{
- PatcherFeedbackPrx feedback = PatcherFeedbackPrx::uncheckedCast(_database->getInternalAdapter()->add(obj, id));
- _node->patch(feedback, application, server, dist, shutdown);
-
- Lock sync(*this);
- if(_destroy)
- {
- throw NodeUnreachableException(_info->name, "node is down");
- }
- _feedbacks.insert(obj);
+ PatcherFeedbackPrx feedback = PatcherFeedbackPrx::uncheckedCast(_database->getInternalAdapter()->add(obj, id));
+ _node->patch(feedback, application, server, dist, shutdown);
+
+ Lock sync(*this);
+ if(_destroy)
+ {
+ throw NodeUnreachableException(_info->name, "node is down");
+ }
+ _feedbacks.insert(obj);
}
catch(const Ice::LocalException& ex)
{
- ostringstream os;
- os << "node unreachable:\n" << ex;
- obj->failed(os.str());
+ ostringstream os;
+ os << "node unreachable:\n" << ex;
+ obj->failed(os.str());
}
}
@@ -360,12 +360,12 @@ void
NodeSessionI::destroyImpl(bool shutdown)
{
{
- Lock sync(*this);
- if(_destroy)
- {
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
- }
- _destroy = true;
+ Lock sync(*this);
+ if(_destroy)
+ {
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ }
+ _destroy = true;
}
ServerEntrySeq servers = _database->getNode(_info->name)->getServers();
@@ -377,7 +377,7 @@ NodeSessionI::destroyImpl(bool shutdown)
//
if(!shutdown)
{
- _database->removeInternalObject(_node->ice_getIdentity());
+ _database->removeInternalObject(_node->ice_getIdentity());
}
//
@@ -390,8 +390,8 @@ NodeSessionI::destroyImpl(bool shutdown)
//
if(_replicaObserver)
{
- _database->getReplicaCache().unsubscribe(_replicaObserver);
- _replicaObserver = 0;
+ _database->getReplicaCache().unsubscribe(_replicaObserver);
+ _replicaObserver = 0;
}
//
@@ -409,18 +409,18 @@ NodeSessionI::destroyImpl(bool shutdown)
_feedbacks.swap(feedbacks);
for(set<PatcherFeedbackPtr>::const_iterator p = feedbacks.begin(); p != feedbacks.end(); ++p)
{
- (*p)->failed("node is down");
+ (*p)->failed("node is down");
}
if(!shutdown)
{
- try
- {
- _database->getInternalAdapter()->remove(_proxy->ice_getIdentity());
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- }
+ try
+ {
+ _database->getInternalAdapter()->remove(_proxy->ice_getIdentity());
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ }
}
}
@@ -429,14 +429,14 @@ NodeSessionI::removeFeedback(const PatcherFeedbackPtr& feedback, const Ice::Iden
{
try
{
- _database->getInternalAdapter()->remove(id);
+ _database->getInternalAdapter()->remove(id);
}
catch(const Ice::LocalException&)
{
}
{
- Lock sync(*this);
- _feedbacks.erase(feedback);
+ Lock sync(*this);
+ _feedbacks.erase(feedback);
}
}
diff --git a/cpp/src/IceGrid/NodeSessionI.h b/cpp/src/IceGrid/NodeSessionI.h
index a9653203ad1..50bf000e513 100644
--- a/cpp/src/IceGrid/NodeSessionI.h
+++ b/cpp/src/IceGrid/NodeSessionI.h
@@ -65,13 +65,13 @@ public:
virtual void loadServers_async(const AMD_NodeSession_loadServersPtr&, const Ice::Current&) const;
virtual Ice::StringSeq getServers(const Ice::Current&) const;
virtual void waitForApplicationUpdate_async(const AMD_NodeSession_waitForApplicationUpdatePtr&,
- const std::string&, int, const Ice::Current&) const;
+ const std::string&, int, const Ice::Current&) const;
virtual void destroy(const Ice::Current& = Ice::Current());
virtual IceUtil::Time timestamp() const;
virtual void shutdown();
void patch(const PatcherFeedbackAggregatorPtr&, const std::string&, const std::string&,
- const InternalDistributionDescriptorPtr&, bool);
+ const InternalDistributionDescriptorPtr&, bool);
const NodePrx& getNode() const;
const InternalNodeInfoPtr& getInfo() const;
diff --git a/cpp/src/IceGrid/NodeSessionManager.cpp b/cpp/src/IceGrid/NodeSessionManager.cpp
index ff522a1a58e..f723134a0a5 100644
--- a/cpp/src/IceGrid/NodeSessionManager.cpp
+++ b/cpp/src/IceGrid/NodeSessionManager.cpp
@@ -17,8 +17,8 @@ using namespace std;
using namespace IceGrid;
NodeSessionKeepAliveThread::NodeSessionKeepAliveThread(const InternalRegistryPrx& registry,
- const NodeIPtr& node,
- const vector<QueryPrx>& queryObjects) :
+ const NodeIPtr& node,
+ const vector<QueryPrx>& queryObjects) :
SessionKeepAliveThread<NodeSessionPrx>(registry),
_node(node),
_queryObjects(queryObjects)
@@ -29,7 +29,7 @@ NodeSessionKeepAliveThread::NodeSessionKeepAliveThread(const InternalRegistryPrx
string::size_type pos = name.find(prefix);
if(pos != string::npos)
{
- name = name.substr(prefix.size());
+ name = name.substr(prefix.size());
}
const_cast<string&>(_name) = name;
}
@@ -42,90 +42,90 @@ NodeSessionKeepAliveThread::createSession(InternalRegistryPrx& registry, IceUtil
TraceLevelsPtr traceLevels = _node->getTraceLevels();
try
{
- if(traceLevels && traceLevels->replica > 1)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->replicaCat);
- out << "trying to establish session with replica `" << _name << "'";
- }
-
- set<InternalRegistryPrx> used;
- if(!registry->ice_getEndpoints().empty())
- {
- try
- {
- session = createSessionImpl(registry, timeout);
- }
- catch(const Ice::LocalException& ex)
- {
- exception.reset(ex.ice_clone());
- used.insert(registry);
- registry = InternalRegistryPrx::uncheckedCast(registry->ice_endpoints(Ice::EndpointSeq()));
- }
- }
-
- if(!session)
- {
- for(vector<QueryPrx>::const_iterator p = _queryObjects.begin(); p != _queryObjects.end(); ++p)
- {
- InternalRegistryPrx newRegistry;
- try
- {
- Ice::ObjectPrx obj = (*p)->findObjectById(registry->ice_getIdentity());
- newRegistry = InternalRegistryPrx::uncheckedCast(obj);
- if(newRegistry && used.find(newRegistry) == used.end())
- {
- session = createSessionImpl(newRegistry, timeout);
- registry = newRegistry;
- break;
- }
- }
- catch(const Ice::LocalException& ex)
- {
- exception.reset(ex.ice_clone());
- if(newRegistry)
- {
- used.insert(newRegistry);
- }
- }
- }
- }
+ if(traceLevels && traceLevels->replica > 1)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->replicaCat);
+ out << "trying to establish session with replica `" << _name << "'";
+ }
+
+ set<InternalRegistryPrx> used;
+ if(!registry->ice_getEndpoints().empty())
+ {
+ try
+ {
+ session = createSessionImpl(registry, timeout);
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ exception.reset(ex.ice_clone());
+ used.insert(registry);
+ registry = InternalRegistryPrx::uncheckedCast(registry->ice_endpoints(Ice::EndpointSeq()));
+ }
+ }
+
+ if(!session)
+ {
+ for(vector<QueryPrx>::const_iterator p = _queryObjects.begin(); p != _queryObjects.end(); ++p)
+ {
+ InternalRegistryPrx newRegistry;
+ try
+ {
+ Ice::ObjectPrx obj = (*p)->findObjectById(registry->ice_getIdentity());
+ newRegistry = InternalRegistryPrx::uncheckedCast(obj);
+ if(newRegistry && used.find(newRegistry) == used.end())
+ {
+ session = createSessionImpl(newRegistry, timeout);
+ registry = newRegistry;
+ break;
+ }
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ exception.reset(ex.ice_clone());
+ if(newRegistry)
+ {
+ used.insert(newRegistry);
+ }
+ }
+ }
+ }
}
catch(const NodeActiveException& ex)
{
- if(traceLevels)
- {
- traceLevels->logger->error("a node with the same name is already active with the replica `" + _name + "'");
- }
- exception.reset(ex.ice_clone());
+ if(traceLevels)
+ {
+ traceLevels->logger->error("a node with the same name is already active with the replica `" + _name + "'");
+ }
+ exception.reset(ex.ice_clone());
}
catch(const Ice::Exception& ex)
{
- exception.reset(ex.ice_clone());
+ exception.reset(ex.ice_clone());
}
if(session)
{
- if(traceLevels && traceLevels->replica > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->replicaCat);
- out << "established session with replica `" << _name << "'";
- }
+ if(traceLevels && traceLevels->replica > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->replicaCat);
+ out << "established session with replica `" << _name << "'";
+ }
}
else
{
- if(traceLevels && traceLevels->replica > 1)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->replicaCat);
- out << "failed to establish session with replica `" << _name << "':\n";
- if(exception.get())
- {
- out << *exception.get();
- }
- else
- {
- out << "failed to get replica proxy";
- }
- }
+ if(traceLevels && traceLevels->replica > 1)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->replicaCat);
+ out << "failed to establish session with replica `" << _name << "':\n";
+ if(exception.get())
+ {
+ out << *exception.get();
+ }
+ else
+ {
+ out << "failed to get replica proxy";
+ }
+ }
}
return session;
@@ -138,7 +138,7 @@ NodeSessionKeepAliveThread::createSessionImpl(const InternalRegistryPrx& registr
int t = session->getTimeout();
if(t > 0)
{
- timeout = IceUtil::Time::seconds(t / 2);
+ timeout = IceUtil::Time::seconds(t / 2);
}
_node->addObserver(session, session->getObserver());
return session;
@@ -151,21 +151,21 @@ NodeSessionKeepAliveThread::destroySession(const NodeSessionPrx& session)
try
{
- session->destroy();
+ session->destroy();
- if(_node->getTraceLevels() && _node->getTraceLevels()->replica > 0)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->replicaCat);
- out << "destroyed replica `" << _name << "' session";
- }
+ if(_node->getTraceLevels() && _node->getTraceLevels()->replica > 0)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->replicaCat);
+ out << "destroyed replica `" << _name << "' session";
+ }
}
catch(const Ice::LocalException& ex)
{
- if(_node->getTraceLevels() && _node->getTraceLevels()->replica > 1)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->replicaCat);
- out << "couldn't destroy replica `" << _name << "' session:\n" << ex;
- }
+ if(_node->getTraceLevels() && _node->getTraceLevels()->replica > 1)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->replicaCat);
+ out << "couldn't destroy replica `" << _name << "' session:\n" << ex;
+ }
}
}
@@ -174,24 +174,24 @@ NodeSessionKeepAliveThread::keepAlive(const NodeSessionPrx& session)
{
if(_node->getTraceLevels() && _node->getTraceLevels()->replica > 2)
{
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->replicaCat);
- out << "sending keep alive message to replica `" << _name << "'";
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->replicaCat);
+ out << "sending keep alive message to replica `" << _name << "'";
}
try
{
- session->keepAlive(_node->getPlatformInfo().getLoadInfo());
- return true;
+ session->keepAlive(_node->getPlatformInfo().getLoadInfo());
+ return true;
}
catch(const Ice::LocalException& ex)
{
- _node->removeObserver(session);
- if(_node->getTraceLevels() && _node->getTraceLevels()->replica > 0)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->replicaCat);
- out << "lost session with replica `" << _name << "':\n" << ex;
- }
- return false;
+ _node->removeObserver(session);
+ if(_node->getTraceLevels() && _node->getTraceLevels()->replica > 0)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->replicaCat);
+ out << "lost session with replica `" << _name << "':\n" << ex;
+ }
+ return false;
}
}
@@ -225,9 +225,9 @@ NodeSessionManager::create(const NodeIPtr& node)
QueryPrx query = QueryPrx::uncheckedCast(communicator->stringToProxy(communicator->identityToString(id)));
for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
{
- Ice::EndpointSeq singleEndpoint;
- singleEndpoint.push_back(*p);
- _queryObjects.push_back(QueryPrx::uncheckedCast(query->ice_endpoints(singleEndpoint)));
+ Ice::EndpointSeq singleEndpoint;
+ singleEndpoint.push_back(*p);
+ _queryObjects.push_back(QueryPrx::uncheckedCast(query->ice_endpoints(singleEndpoint)));
}
id.name = "InternalRegistry-Master";
@@ -252,17 +252,17 @@ NodeSessionManager::create(const InternalRegistryPrx& replica)
NodeSessionKeepAliveThreadPtr thread;
if(replica->ice_getIdentity() == _master->ice_getIdentity())
{
- thread = _thread;
- thread->setRegistry(replica);
+ thread = _thread;
+ thread->setRegistry(replica);
}
else
{
- thread = addReplicaSession(replica);
+ thread = addReplicaSession(replica);
}
if(thread)
{
- thread->tryCreateSession();
+ thread->tryCreateSession();
}
}
@@ -270,8 +270,8 @@ void
NodeSessionManager::activate()
{
{
- Lock sync(*this);
- _activated = true;
+ Lock sync(*this);
+ _activated = true;
}
//
@@ -282,19 +282,19 @@ NodeSessionManager::activate()
NodeSessionPrx session = _thread->getSession();
if(!session)
{
- _thread->tryCreateSession(true);
- session = _thread->getSession();
+ _thread->tryCreateSession(true);
+ session = _thread->getSession();
}
if(session)
{
- try
- {
- session->setReplicaObserver(_node->getProxy());
- syncServers(session);
- }
- catch(const Ice::LocalException&)
- {
- }
+ try
+ {
+ session->setReplicaObserver(_node->getProxy());
+ syncServers(session);
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
}
}
@@ -317,23 +317,23 @@ NodeSessionManager::destroy()
{
NodeSessionMap sessions;
{
- Lock sync(*this);
- _destroyed = true;
- _sessions.swap(sessions);
- notifyAll();
+ Lock sync(*this);
+ _destroyed = true;
+ _sessions.swap(sessions);
+ notifyAll();
}
_thread->terminate();
NodeSessionMap::const_iterator p;
for(p = sessions.begin(); p != sessions.end(); ++p)
{
- p->second->terminate();
+ p->second->terminate();
}
_thread->getThreadControl().join();
for(p = sessions.begin(); p != sessions.end(); ++p)
{
- p->second->getThreadControl().join();
+ p->second->getThreadControl().join();
}
}
@@ -343,7 +343,7 @@ NodeSessionManager::replicaInit(const InternalRegistryPrxSeq& replicas)
Lock sync(*this);
if(_destroyed)
{
- return;
+ return;
}
//
@@ -352,8 +352,8 @@ NodeSessionManager::replicaInit(const InternalRegistryPrxSeq& replicas)
_replicas.clear();
for(InternalRegistryPrxSeq::const_iterator p = replicas.begin(); p != replicas.end(); ++p)
{
- _replicas.insert((*p)->ice_getIdentity());
- addReplicaSession(*p)->tryCreateSession(false);
+ _replicas.insert((*p)->ice_getIdentity());
+ addReplicaSession(*p)->tryCreateSession(false);
}
}
@@ -363,7 +363,7 @@ NodeSessionManager::replicaAdded(const InternalRegistryPrx& replica)
Lock sync(*this);
if(_destroyed)
{
- return;
+ return;
}
_replicas.insert(replica->ice_getIdentity());
addReplicaSession(replica)->tryCreateSession(false);
@@ -373,12 +373,12 @@ void
NodeSessionManager::replicaRemoved(const InternalRegistryPrx& replica)
{
{
- Lock sync(*this);
- if(_destroyed)
- {
- return;
- }
- _replicas.erase(replica->ice_getIdentity());
+ Lock sync(*this);
+ if(_destroyed)
+ {
+ return;
+ }
+ _replicas.erase(replica->ice_getIdentity());
}
//
@@ -396,14 +396,14 @@ NodeSessionManager::addReplicaSession(const InternalRegistryPrx& replica)
NodeSessionKeepAliveThreadPtr thread;
if(p != _sessions.end())
{
- thread = p->second;
- thread->setRegistry(replica);
+ thread = p->second;
+ thread->setRegistry(replica);
}
else
{
- thread = new NodeSessionKeepAliveThread(replica, _node, _queryObjects);
- _sessions.insert(make_pair(replica->ice_getIdentity(), thread));
- thread->start();
+ thread = new NodeSessionKeepAliveThread(replica, _node, _queryObjects);
+ _sessions.insert(make_pair(replica->ice_getIdentity(), thread));
+ thread->start();
}
return thread;
}
@@ -413,31 +413,31 @@ NodeSessionManager::reapReplicas()
{
vector<NodeSessionKeepAliveThreadPtr> reap;
{
- Lock sync(*this);
- if(_destroyed)
- {
- return;
- }
-
- NodeSessionMap::iterator q = _sessions.begin();
- while(q != _sessions.end())
- {
- if(_replicas.find(q->first) == _replicas.end() && q->second->terminateIfDisconnected())
- {
- _node->removeObserver(q->second->getSession());
- reap.push_back(q->second);
- _sessions.erase(q++);
- }
- else
- {
- ++q;
- }
- }
+ Lock sync(*this);
+ if(_destroyed)
+ {
+ return;
+ }
+
+ NodeSessionMap::iterator q = _sessions.begin();
+ while(q != _sessions.end())
+ {
+ if(_replicas.find(q->first) == _replicas.end() && q->second->terminateIfDisconnected())
+ {
+ _node->removeObserver(q->second->getSession());
+ reap.push_back(q->second);
+ _sessions.erase(q++);
+ }
+ else
+ {
+ ++q;
+ }
+ }
}
for(vector<NodeSessionKeepAliveThreadPtr>::const_iterator p = reap.begin(); p != reap.end(); ++p)
{
- (*p)->getThreadControl().join();
+ (*p)->getThreadControl().join();
}
}
@@ -465,8 +465,8 @@ NodeSessionManager::createdSession(const NodeSessionPrx& session)
{
bool activated;
{
- Lock sync(*this);
- activated = _activated;
+ Lock sync(*this);
+ activated = _activated;
}
//
@@ -479,15 +479,15 @@ NodeSessionManager::createdSession(const NodeSessionPrx& session)
//
if(session && activated)
{
- try
- {
- session->setReplicaObserver(_node->getProxy());
- syncServers(session);
- }
- catch(const Ice::LocalException&)
- {
- }
- return;
+ try
+ {
+ session->setReplicaObserver(_node->getProxy());
+ syncServers(session);
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
+ return;
}
//
@@ -501,73 +501,73 @@ NodeSessionManager::createdSession(const NodeSessionPrx& session)
InternalRegistryPrxSeq replicas;
if(session)
{
- assert(!activated); // The node adapter isn't activated yet so
- // we're not subscribed yet to the replica
+ assert(!activated); // The node adapter isn't activated yet so
+ // we're not subscribed yet to the replica
// observer topic.
- try
- {
- replicas = _thread->getRegistry()->getReplicas();
- }
- catch(const Ice::LocalException&)
- {
- }
+ try
+ {
+ replicas = _thread->getRegistry()->getReplicas();
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
}
else
{
- map<Ice::Identity, Ice::ObjectPrx> proxies;
- for(vector<QueryPrx>::const_iterator p = _queryObjects.begin(); p != _queryObjects.end(); ++p)
- {
- try
- {
- Ice::ObjectProxySeq prxs = (*p)->findAllObjectsByType(InternalRegistry::ice_staticId());
- for(Ice::ObjectProxySeq::const_iterator q = prxs.begin(); q != prxs.end(); ++q)
- {
- //
- // NOTE: We might override a good proxy here! We could improve this to make
- // sure that we don't override the proxy for replica N if that proxy was
- // obtained from replica N.
- //
- proxies[(*q)->ice_getIdentity()] = *q;
- }
- }
- catch(const Ice::LocalException&)
- {
- // IGNORE
- }
- }
-
- for(map<Ice::Identity, Ice::ObjectPrx>::const_iterator q = proxies.begin(); q != proxies.end(); ++q)
- {
- replicas.push_back(InternalRegistryPrx::uncheckedCast(q->second));
- }
+ map<Ice::Identity, Ice::ObjectPrx> proxies;
+ for(vector<QueryPrx>::const_iterator p = _queryObjects.begin(); p != _queryObjects.end(); ++p)
+ {
+ try
+ {
+ Ice::ObjectProxySeq prxs = (*p)->findAllObjectsByType(InternalRegistry::ice_staticId());
+ for(Ice::ObjectProxySeq::const_iterator q = prxs.begin(); q != prxs.end(); ++q)
+ {
+ //
+ // NOTE: We might override a good proxy here! We could improve this to make
+ // sure that we don't override the proxy for replica N if that proxy was
+ // obtained from replica N.
+ //
+ proxies[(*q)->ice_getIdentity()] = *q;
+ }
+ }
+ catch(const Ice::LocalException&)
+ {
+ // IGNORE
+ }
+ }
+
+ for(map<Ice::Identity, Ice::ObjectPrx>::const_iterator q = proxies.begin(); q != proxies.end(); ++q)
+ {
+ replicas.push_back(InternalRegistryPrx::uncheckedCast(q->second));
+ }
}
vector<NodeSessionKeepAliveThreadPtr> sessions;
{
- Lock sync(*this);
- if(_destroyed)
- {
- return;
- }
-
- //
- // If the node adapter was activated since we last check, we don't need
- // to initialize the replicas here, it will be done by replicaInit().
- //
- if(!session || !_activated)
- {
- _replicas.clear();
- for(InternalRegistryPrxSeq::const_iterator p = replicas.begin(); p != replicas.end(); ++p)
- {
- if((*p)->ice_getIdentity() != _master->ice_getIdentity())
- {
- _replicas.insert((*p)->ice_getIdentity());
- NodeSessionKeepAliveThreadPtr session = addReplicaSession(*p);
- session->tryCreateSession(false);
- sessions.push_back(session);
- }
- }
- }
+ Lock sync(*this);
+ if(_destroyed)
+ {
+ return;
+ }
+
+ //
+ // If the node adapter was activated since we last check, we don't need
+ // to initialize the replicas here, it will be done by replicaInit().
+ //
+ if(!session || !_activated)
+ {
+ _replicas.clear();
+ for(InternalRegistryPrxSeq::const_iterator p = replicas.begin(); p != replicas.end(); ++p)
+ {
+ if((*p)->ice_getIdentity() != _master->ice_getIdentity())
+ {
+ _replicas.insert((*p)->ice_getIdentity());
+ NodeSessionKeepAliveThreadPtr session = addReplicaSession(*p);
+ session->tryCreateSession(false);
+ sessions.push_back(session);
+ }
+ }
+ }
}
//
@@ -577,7 +577,7 @@ NodeSessionManager::createdSession(const NodeSessionPrx& session)
//
for(vector<NodeSessionKeepAliveThreadPtr>::const_iterator p = sessions.begin(); p != sessions.end(); ++p)
{
- (*p)->tryCreateSession(true);
+ (*p)->tryCreateSession(true);
}
}
diff --git a/cpp/src/IceGrid/NodeSessionManager.h b/cpp/src/IceGrid/NodeSessionManager.h
index 7c67e4d0dc0..11f12386aa9 100644
--- a/cpp/src/IceGrid/NodeSessionManager.h
+++ b/cpp/src/IceGrid/NodeSessionManager.h
@@ -78,39 +78,39 @@ private:
{
public:
- Thread(NodeSessionManager& manager) :
- NodeSessionKeepAliveThread(manager._master, manager._node, manager._queryObjects),
- _manager(manager)
+ Thread(NodeSessionManager& manager) :
+ NodeSessionKeepAliveThread(manager._master, manager._node, manager._queryObjects),
+ _manager(manager)
{
- }
+ }
- virtual NodeSessionPrx
- createSession(InternalRegistryPrx& master, IceUtil::Time& timeout)
+ virtual NodeSessionPrx
+ createSession(InternalRegistryPrx& master, IceUtil::Time& timeout)
{
- NodeSessionPrx session = NodeSessionKeepAliveThread::createSession(master, timeout);
- _manager.createdSession(session);
- _manager.reapReplicas();
- return session;
- }
-
- virtual void
- destroySession(const NodeSessionPrx& session)
+ NodeSessionPrx session = NodeSessionKeepAliveThread::createSession(master, timeout);
+ _manager.createdSession(session);
+ _manager.reapReplicas();
+ return session;
+ }
+
+ virtual void
+ destroySession(const NodeSessionPrx& session)
{
- NodeSessionKeepAliveThread::destroySession(session);
- _manager.reapReplicas();
- }
+ NodeSessionKeepAliveThread::destroySession(session);
+ _manager.reapReplicas();
+ }
- virtual bool
- keepAlive(const NodeSessionPrx& session)
+ virtual bool
+ keepAlive(const NodeSessionPrx& session)
{
- bool alive = NodeSessionKeepAliveThread::keepAlive(session);
- _manager.reapReplicas();
- return alive;
- }
+ bool alive = NodeSessionKeepAliveThread::keepAlive(session);
+ _manager.reapReplicas();
+ return alive;
+ }
private:
-
- NodeSessionManager& _manager;
+
+ NodeSessionManager& _manager;
};
typedef IceUtil::Handle<Thread> ThreadPtr;
friend class Thread;
diff --git a/cpp/src/IceGrid/ObjectCache.cpp b/cpp/src/IceGrid/ObjectCache.cpp
index baa608ee12f..65dfe17cf23 100644
--- a/cpp/src/IceGrid/ObjectCache.cpp
+++ b/cpp/src/IceGrid/ObjectCache.cpp
@@ -30,7 +30,7 @@ struct ObjectEntryCI : binary_function<ObjectEntryPtr&, ObjectEntryPtr&, bool>
bool
operator()(const ObjectEntryPtr& lhs, const ObjectEntryPtr& rhs)
{
- return ::Ice::proxyIdentityLess(lhs->getProxy(), rhs->getProxy());
+ return ::Ice::proxyIdentityLess(lhs->getProxy(), rhs->getProxy());
}
};
@@ -38,7 +38,7 @@ struct ObjectLoadCI : binary_function<pair<Ice::ObjectPrx, float>&, pair<Ice::Ob
{
bool operator()(const pair<Ice::ObjectPrx, float>& lhs, const pair<Ice::ObjectPrx, float>& rhs)
{
- return lhs.second < rhs.second;
+ return lhs.second < rhs.second;
}
};
@@ -87,14 +87,14 @@ ObjectCache::add(const ObjectInfo& info, const string& application)
map<string, TypeEntry>::iterator p = _types.find(entry->getType());
if(p == _types.end())
{
- p = _types.insert(p, map<string, TypeEntry>::value_type(entry->getType(), TypeEntry()));
+ p = _types.insert(p, map<string, TypeEntry>::value_type(entry->getType(), TypeEntry()));
}
p->second.add(entry);
if(_traceLevels && _traceLevels->object > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
- out << "added object `" << _communicator->identityToString(id) << "'";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
+ out << "added object `" << _communicator->identityToString(id) << "'";
}
}
@@ -105,7 +105,7 @@ ObjectCache::get(const Ice::Identity& id) const
ObjectEntryPtr entry = getImpl(id);
if(!entry)
{
- throw ObjectNotRegisteredException(id);
+ throw ObjectNotRegisteredException(id);
}
return entry;
}
@@ -121,14 +121,14 @@ ObjectCache::remove(const Ice::Identity& id)
map<string, TypeEntry>::iterator p = _types.find(entry->getType());
assert(p != _types.end());
if(p->second.remove(entry))
- {
- _types.erase(p);
+ {
+ _types.erase(p);
}
if(_traceLevels && _traceLevels->object > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
- out << "removed object `" << _communicator->identityToString(id) << "'";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->objectCat);
+ out << "removed object `" << _communicator->identityToString(id) << "'";
}
return entry;
@@ -142,12 +142,12 @@ ObjectCache::getObjectsByType(const string& type)
map<string, TypeEntry>::const_iterator p = _types.find(type);
if(p == _types.end())
{
- return proxies;
+ return proxies;
}
const vector<ObjectEntryPtr>& objects = p->second.getObjects();
for(vector<ObjectEntryPtr>::const_iterator q = objects.begin(); q != objects.end(); ++q)
{
- proxies.push_back((*q)->getProxy());
+ proxies.push_back((*q)->getProxy());
}
return proxies;
}
@@ -159,10 +159,10 @@ ObjectCache::getAll(const string& expression)
ObjectInfoSeq infos;
for(map<Ice::Identity, ObjectEntryPtr>::const_iterator p = _entries.begin(); p != _entries.end(); ++p)
{
- if(expression.empty() || IceUtil::match(_communicator->identityToString(p->first), expression, true))
- {
- infos.push_back(p->second->getObjectInfo());
- }
+ if(expression.empty() || IceUtil::match(_communicator->identityToString(p->first), expression, true))
+ {
+ infos.push_back(p->second->getObjectInfo());
+ }
}
return infos;
}
@@ -175,13 +175,13 @@ ObjectCache::getAllByType(const string& type)
map<string, TypeEntry>::const_iterator p = _types.find(type);
if(p == _types.end())
{
- return infos;
+ return infos;
}
const vector<ObjectEntryPtr>& objects = p->second.getObjects();
for(vector<ObjectEntryPtr>::const_iterator q = objects.begin(); q != objects.end(); ++q)
{
- infos.push_back((*q)->getObjectInfo());
+ infos.push_back((*q)->getObjectInfo());
}
return infos;
}
diff --git a/cpp/src/IceGrid/ObjectCache.h b/cpp/src/IceGrid/ObjectCache.h
index fc814a1c87e..7293d1c53fd 100644
--- a/cpp/src/IceGrid/ObjectCache.h
+++ b/cpp/src/IceGrid/ObjectCache.h
@@ -62,16 +62,16 @@ private:
{
public:
- TypeEntry();
+ TypeEntry();
- void add(const ObjectEntryPtr&);
- bool remove(const ObjectEntryPtr&);
-
- const std::vector<ObjectEntryPtr>& getObjects() const { return _objects; }
+ void add(const ObjectEntryPtr&);
+ bool remove(const ObjectEntryPtr&);
+
+ const std::vector<ObjectEntryPtr>& getObjects() const { return _objects; }
private:
-
- std::vector<ObjectEntryPtr> _objects;
+
+ std::vector<ObjectEntryPtr> _objects;
};
const Ice::CommunicatorPtr _communicator;
diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp
index d2c90f05048..bfc95391d91 100644
--- a/cpp/src/IceGrid/Parser.cpp
+++ b/cpp/src/IceGrid/Parser.cpp
@@ -210,7 +210,7 @@ Parser* parser;
ParserPtr
Parser::createParser(const CommunicatorPtr& communicator, const AdminSessionPrx& session, const AdminPrx& admin,
- bool interactive)
+ bool interactive)
{
return new Parser(communicator, session, admin, interactive);
}
@@ -220,15 +220,15 @@ Parser::usage(const string& category, const string& command)
{
if(_helpCommands.find(category) == _helpCommands.end())
{
- invalidCommand("unknown category `" + category + "'");
+ invalidCommand("unknown category `" + category + "'");
}
else if(_helpCommands[category].find(command) == _helpCommands[category].end())
{
- invalidCommand("unknown command `" + category + " " + command + "'");
+ invalidCommand("unknown command `" + category + " " + command + "'");
}
else
{
- cout << _helpCommands[category][command];
+ cout << _helpCommands[category][command];
}
}
@@ -237,15 +237,15 @@ Parser::usage(const string& category, const list<string>& args)
{
if(args.empty())
{
- usage(category);
+ usage(category);
}
else if(args.size() > 1)
{
- invalidCommand("`help' requires at most 1 argument");
+ invalidCommand("`help' requires at most 1 argument");
}
else
{
- usage(category, *args.begin());
+ usage(category, *args.begin());
}
}
@@ -255,11 +255,11 @@ Parser::usage()
cout <<
"help Print this message.\n"
"exit, quit Exit this program.\n"
- "CATEGORY help Print the help section of the given CATEGORY.\n"
- "COMMAND help Print the help of the given COMMAND.\n"
- "\n"
- "List of help categories:\n"
- "\n"
+ "CATEGORY help Print the help section of the given CATEGORY.\n"
+ "COMMAND help Print the help of the given COMMAND.\n"
+ "\n"
+ "List of help categories:\n"
+ "\n"
" application: commands to manage applications\n"
" node: commands to manage nodes\n"
" registry: commands to manage registries\n"
@@ -268,7 +268,7 @@ Parser::usage()
" object: commands to manage objects\n"
" server template: commands to manage server templates\n"
" service template: commands to manage service templates\n"
- "\n";
+ "\n";
}
void
@@ -298,11 +298,11 @@ Parser::checkInterrupted()
{
if(!_interactive)
{
- Lock sync(*this);
- if(_interrupted)
- {
- throw "interrupted with Ctrl-C";
- }
+ Lock sync(*this);
+ if(_interrupted)
+ {
+ throw "interrupted with Ctrl-C";
+ }
}
}
@@ -317,69 +317,69 @@ Parser::addApplication(const list<string>& origArgs)
vector<string> args;
try
{
- for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
- {
- args.push_back(*p);
- }
- args = opts.parse(args);
+ for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
+ {
+ args.push_back(*p);
+ }
+ args = opts.parse(args);
}
catch(const IceUtil::BadOptException& e)
{
- error(e.reason);
- return;
+ error(e.reason);
+ return;
}
if(args.size() < 1)
{
- invalidCommand("application add", "requires at least one argument");
- return;
+ invalidCommand("application add", "requires at least one argument");
+ return;
}
try
{
- StringSeq targets;
- map<string, string> vars;
-
- vector<string>::const_iterator p = args.begin();
- string desc = *p++;
-
- for(; p != args.end(); ++p)
- {
- string::size_type pos = p->find('=');
- if(pos != string::npos)
- {
- vars[p->substr(0, pos)] = p->substr(pos + 1);
- }
- else
- {
- targets.push_back(*p);
- }
- }
-
- //
- // Add the application.
- //
- ApplicationDescriptor app = DescriptorParser::parseDescriptor(desc, targets, vars, _communicator, _admin);
- _admin->addApplication(app);
-
- if(!opts.isSet("no-patch"))
- {
- //
- // Patch the application.
- //
- try
- {
- _admin->patchApplication(app.name, true);
- }
- catch(const PatchException& ex)
- {
- patchFailed(ex.reasons);
- }
- }
+ StringSeq targets;
+ map<string, string> vars;
+
+ vector<string>::const_iterator p = args.begin();
+ string desc = *p++;
+
+ for(; p != args.end(); ++p)
+ {
+ string::size_type pos = p->find('=');
+ if(pos != string::npos)
+ {
+ vars[p->substr(0, pos)] = p->substr(pos + 1);
+ }
+ else
+ {
+ targets.push_back(*p);
+ }
+ }
+
+ //
+ // Add the application.
+ //
+ ApplicationDescriptor app = DescriptorParser::parseDescriptor(desc, targets, vars, _communicator, _admin);
+ _admin->addApplication(app);
+
+ if(!opts.isSet("no-patch"))
+ {
+ //
+ // Patch the application.
+ //
+ try
+ {
+ _admin->patchApplication(app.name, true);
+ }
+ catch(const PatchException& ex)
+ {
+ patchFailed(ex.reasons);
+ }
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -388,21 +388,21 @@ Parser::removeApplication(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("application remove", "requires exactly one argument");
- return;
+ invalidCommand("application remove", "requires exactly one argument");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
+ list<string>::const_iterator p = args.begin();
- string name = *p++;
+ string name = *p++;
- _admin->removeApplication(name);
+ _admin->removeApplication(name);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -411,25 +411,25 @@ Parser::describeApplication(const list<string>& args)
{
if(args.size() < 1)
{
- invalidCommand("application describe", "requires at least one argument");
- return;
+ invalidCommand("application describe", "requires at least one argument");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
+ list<string>::const_iterator p = args.begin();
- string name = *p++;
+ string name = *p++;
- Output out(cout);
- ApplicationInfo info = _admin->getApplicationInfo(name);
- ApplicationHelper helper(_communicator, info.descriptor);
- helper.print(out, info);
- out << nl;
+ Output out(cout);
+ ApplicationInfo info = _admin->getApplicationInfo(name);
+ ApplicationHelper helper(_communicator, info.descriptor);
+ helper.print(out, info);
+ out << nl;
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -438,44 +438,44 @@ Parser::diffApplication(const list<string>& args)
{
if(args.size() < 1)
{
- invalidCommand("application diff" , "requires at least one argument");
- return;
+ invalidCommand("application diff" , "requires at least one argument");
+ return;
}
try
{
- StringSeq targets;
- map<string, string> vars;
-
- list<string>::const_iterator p = args.begin();
- string desc = *p++;
-
- for(; p != args.end(); ++p)
- {
- string::size_type pos = p->find('=');
- if(pos != string::npos)
- {
- vars[p->substr(0, pos)] = p->substr(pos + 1);
- }
- else
- {
- targets.push_back(*p);
- }
- }
-
- ApplicationDescriptor newApp = DescriptorParser::parseDescriptor(desc, targets, vars, _communicator, _admin);
- ApplicationInfo origApp = _admin->getApplicationInfo(newApp.name);
-
- ApplicationHelper newAppHelper(_communicator, newApp);
- ApplicationHelper oldAppHelper(_communicator, origApp.descriptor);
-
- Output out(cout);
- newAppHelper.printDiff(out, oldAppHelper);
- out << nl;
+ StringSeq targets;
+ map<string, string> vars;
+
+ list<string>::const_iterator p = args.begin();
+ string desc = *p++;
+
+ for(; p != args.end(); ++p)
+ {
+ string::size_type pos = p->find('=');
+ if(pos != string::npos)
+ {
+ vars[p->substr(0, pos)] = p->substr(pos + 1);
+ }
+ else
+ {
+ targets.push_back(*p);
+ }
+ }
+
+ ApplicationDescriptor newApp = DescriptorParser::parseDescriptor(desc, targets, vars, _communicator, _admin);
+ ApplicationInfo origApp = _admin->getApplicationInfo(newApp.name);
+
+ ApplicationHelper newAppHelper(_communicator, newApp);
+ ApplicationHelper oldAppHelper(_communicator, origApp.descriptor);
+
+ Output out(cout);
+ newAppHelper.printDiff(out, oldAppHelper);
+ out << nl;
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -484,36 +484,36 @@ Parser::updateApplication(const list<string>& args)
{
if(args.size() < 1)
{
- invalidCommand("application diff", "requires at least one argument");
- return;
+ invalidCommand("application diff", "requires at least one argument");
+ return;
}
try
{
- StringSeq targets;
- map<string, string> vars;
+ StringSeq targets;
+ map<string, string> vars;
- list<string>::const_iterator p = args.begin();
- string desc = *p++;
+ list<string>::const_iterator p = args.begin();
+ string desc = *p++;
- for(; p != args.end(); ++p)
- {
- string::size_type pos = p->find('=');
- if(pos != string::npos)
- {
- vars[p->substr(0, pos)] = p->substr(pos + 1);
- }
- else
- {
- targets.push_back(*p);
- }
- }
+ for(; p != args.end(); ++p)
+ {
+ string::size_type pos = p->find('=');
+ if(pos != string::npos)
+ {
+ vars[p->substr(0, pos)] = p->substr(pos + 1);
+ }
+ else
+ {
+ targets.push_back(*p);
+ }
+ }
- _admin->syncApplication(DescriptorParser::parseDescriptor(desc, targets, vars, _communicator, _admin));
+ _admin->syncApplication(DescriptorParser::parseDescriptor(desc, targets, vars, _communicator, _admin));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -528,33 +528,33 @@ Parser::patchApplication(const list<string>& origArgs)
vector<string> args;
try
{
- for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
- {
- args.push_back(*p);
- }
- args = opts.parse(args);
+ for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
+ {
+ args.push_back(*p);
+ }
+ args = opts.parse(args);
}
catch(const IceUtil::BadOptException& e)
{
- error(e.reason);
- return;
+ error(e.reason);
+ return;
}
if(args.size() != 1)
{
- invalidCommand("application patch", "requires exactly one argument");
- return;
+ invalidCommand("application patch", "requires exactly one argument");
+ return;
}
try
{
- vector<string>::const_iterator p = args.begin();
- string name = *p++;
- _admin->patchApplication(name, opts.isSet("force"));
+ vector<string>::const_iterator p = args.begin();
+ string name = *p++;
+ _admin->patchApplication(name, opts.isSet("force"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -563,12 +563,12 @@ Parser::listAllApplications()
{
try
{
- Ice::StringSeq names = _admin->getAllApplicationNames();
- copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
+ Ice::StringSeq names = _admin->getAllApplicationNames();
+ copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -577,50 +577,50 @@ Parser::describeServerTemplate(const list<string>& args)
{
if(args.size() != 2)
{
- invalidCommand("server template describe", "requires exactly two arguments");
- return;
+ invalidCommand("server template describe", "requires exactly two arguments");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
-
- string name = *p++;
- string templ = *p++;
-
- ApplicationInfo application = _admin->getApplicationInfo(name);
-
- Output out(cout);
- TemplateDescriptorDict::const_iterator q = application.descriptor.serverTemplates.find(templ);
- if(q != application.descriptor.serverTemplates.end())
- {
- out << "server template `" << templ << "'";
- out << sb;
-
- out << nl << "parameters = `" << toString(q->second.parameters) << "'";
- out << nl;
-
- ServerDescriptorPtr server = ServerDescriptorPtr::dynamicCast(q->second.descriptor);
- IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(server);
- if(iceBox)
- {
- IceBoxHelper(iceBox).print(_communicator, out);
- }
- else
- {
- ServerHelper(server).print(_communicator, out);
- }
- out << eb;
- out << nl;
- }
- else
- {
- error("no server template with id `" + templ + "'");
- }
+ list<string>::const_iterator p = args.begin();
+
+ string name = *p++;
+ string templ = *p++;
+
+ ApplicationInfo application = _admin->getApplicationInfo(name);
+
+ Output out(cout);
+ TemplateDescriptorDict::const_iterator q = application.descriptor.serverTemplates.find(templ);
+ if(q != application.descriptor.serverTemplates.end())
+ {
+ out << "server template `" << templ << "'";
+ out << sb;
+
+ out << nl << "parameters = `" << toString(q->second.parameters) << "'";
+ out << nl;
+
+ ServerDescriptorPtr server = ServerDescriptorPtr::dynamicCast(q->second.descriptor);
+ IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(server);
+ if(iceBox)
+ {
+ IceBoxHelper(iceBox).print(_communicator, out);
+ }
+ else
+ {
+ ServerHelper(server).print(_communicator, out);
+ }
+ out << eb;
+ out << nl;
+ }
+ else
+ {
+ error("no server template with id `" + templ + "'");
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -629,35 +629,35 @@ Parser::instantiateServerTemplate(const list<string>& args)
{
if(args.size() < 3)
{
- invalidCommand("server template instantiate", "requires at least three arguments");
- return;
+ invalidCommand("server template instantiate", "requires at least three arguments");
+ return;
}
try
{
- map<string, string> vars;
-
- list<string>::const_iterator p = args.begin();
- string application = *p++;
- string node = *p++;
- string templ = *p++;
- for(; p != args.end(); ++p)
- {
- string::size_type pos = p->find('=');
- if(pos != string::npos)
- {
- vars[p->substr(0, pos)] = p->substr(pos + 1);
- }
- }
-
- ServerInstanceDescriptor desc;
- desc._cpp_template = templ;
- desc.parameterValues = vars;
- _admin->instantiateServer(application, node, desc);
+ map<string, string> vars;
+
+ list<string>::const_iterator p = args.begin();
+ string application = *p++;
+ string node = *p++;
+ string templ = *p++;
+ for(; p != args.end(); ++p)
+ {
+ string::size_type pos = p->find('=');
+ if(pos != string::npos)
+ {
+ vars[p->substr(0, pos)] = p->substr(pos + 1);
+ }
+ }
+
+ ServerInstanceDescriptor desc;
+ desc._cpp_template = templ;
+ desc.parameterValues = vars;
+ _admin->instantiateServer(application, node, desc);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -666,42 +666,42 @@ Parser::describeServiceTemplate(const list<string>& args)
{
if(args.size() != 2)
{
- invalidCommand("service template describe", "requires exactly two arguments");
- return;
+ invalidCommand("service template describe", "requires exactly two arguments");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
-
- string name = *p++;
- string templ = *p++;
-
- ApplicationInfo application = _admin->getApplicationInfo(name);
-
- Output out(cout);
- TemplateDescriptorDict::const_iterator q = application.descriptor.serviceTemplates.find(templ);
- if(q != application.descriptor.serviceTemplates.end())
- {
- out << "service template `" << templ << "'";
- out << sb;
-
- out << nl << "parameters = `" << toString(q->second.parameters) << "'";
- out << nl;
-
- ServiceDescriptorPtr desc = ServiceDescriptorPtr::dynamicCast(q->second.descriptor);
- ServiceHelper(desc).print(_communicator, out);
- out << eb;
- out << nl;
- }
- else
- {
- invalidCommand("no service template with id `" + templ + "'");
- }
+ list<string>::const_iterator p = args.begin();
+
+ string name = *p++;
+ string templ = *p++;
+
+ ApplicationInfo application = _admin->getApplicationInfo(name);
+
+ Output out(cout);
+ TemplateDescriptorDict::const_iterator q = application.descriptor.serviceTemplates.find(templ);
+ if(q != application.descriptor.serviceTemplates.end())
+ {
+ out << "service template `" << templ << "'";
+ out << sb;
+
+ out << nl << "parameters = `" << toString(q->second.parameters) << "'";
+ out << nl;
+
+ ServiceDescriptorPtr desc = ServiceDescriptorPtr::dynamicCast(q->second.descriptor);
+ ServiceHelper(desc).print(_communicator, out);
+ out << eb;
+ out << nl;
+ }
+ else
+ {
+ invalidCommand("no service template with id `" + templ + "'");
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -710,28 +710,28 @@ Parser::describeNode(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("node describe", "requires exactly one argument");
- return;
+ invalidCommand("node describe", "requires exactly one argument");
+ return;
}
try
{
- NodeInfo info = _admin->getNodeInfo(args.front());
- Output out(cout);
- out << "node `" << args.front() << "'";
- out << sb;
- out << nl << "operating system = `" << info.os << "'";
- out << nl << "host name = `" << info.hostname << "'";
- out << nl << "release = `" << info.release << "'";
- out << nl << "version = `" << info.version << "'";
- out << nl << "machine type = `" << info.machine << "'";
- out << nl << "number of processors = `" << info.nProcessors << "'";
- out << eb;
- out << nl;
+ NodeInfo info = _admin->getNodeInfo(args.front());
+ Output out(cout);
+ out << "node `" << args.front() << "'";
+ out << sb;
+ out << nl << "operating system = `" << info.os << "'";
+ out << nl << "host name = `" << info.hostname << "'";
+ out << nl << "release = `" << info.release << "'";
+ out << nl << "version = `" << info.version << "'";
+ out << nl << "machine type = `" << info.machine << "'";
+ out << nl << "number of processors = `" << info.nProcessors << "'";
+ out << eb;
+ out << nl;
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -740,24 +740,24 @@ Parser::pingNode(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("node ping", "requires exactly one argument");
- return;
+ invalidCommand("node ping", "requires exactly one argument");
+ return;
}
try
{
- if(_admin->pingNode(args.front()))
- {
- cout << "node is up" << endl;
- }
- else
- {
- cout << "node is down" << endl;
- }
+ if(_admin->pingNode(args.front()))
+ {
+ cout << "node is up" << endl;
+ }
+ else
+ {
+ cout << "node is down" << endl;
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -766,18 +766,18 @@ Parser::printLoadNode(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("node load", "requires exactly one argument");
- return;
+ invalidCommand("node load", "requires exactly one argument");
+ return;
}
try
{
- LoadInfo load = _admin->getNodeLoad(args.front());
- cout << "load average (1/5/15): " << load.avg1 << " / " << load.avg5 << " / " << load.avg15 << endl;
+ LoadInfo load = _admin->getNodeLoad(args.front());
+ cout << "load average (1/5/15): " << load.avg1 << " / " << load.avg5 << " / " << load.avg15 << endl;
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -786,17 +786,17 @@ Parser::shutdownNode(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("node shutdown", "requires exactly one argument");
- return;
+ invalidCommand("node shutdown", "requires exactly one argument");
+ return;
}
try
{
- _admin->shutdownNode(args.front());
+ _admin->shutdownNode(args.front());
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -805,12 +805,12 @@ Parser::listAllNodes()
{
try
{
- Ice::StringSeq names = _admin->getAllNodeNames();
- copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
+ Ice::StringSeq names = _admin->getAllNodeNames();
+ copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -819,23 +819,23 @@ Parser::describeRegistry(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("registry describe", "requires exactly one argument");
- return;
+ invalidCommand("registry describe", "requires exactly one argument");
+ return;
}
try
{
- RegistryInfo info = _admin->getRegistryInfo(args.front());
- Output out(cout);
- out << "registry `" << args.front() << "'";
- out << sb;
- out << nl << "host name = `" << info.hostname << "'";
- out << eb;
- out << nl;
+ RegistryInfo info = _admin->getRegistryInfo(args.front());
+ Output out(cout);
+ out << "registry `" << args.front() << "'";
+ out << sb;
+ out << nl << "host name = `" << info.hostname << "'";
+ out << eb;
+ out << nl;
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -844,24 +844,24 @@ Parser::pingRegistry(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("registry ping", "requires exactly one argument");
- return;
+ invalidCommand("registry ping", "requires exactly one argument");
+ return;
}
try
{
- if(_admin->pingRegistry(args.front()))
- {
- cout << "registry is up" << endl;
- }
- else
- {
- cout << "registry is down" << endl;
- }
+ if(_admin->pingRegistry(args.front()))
+ {
+ cout << "registry is up" << endl;
+ }
+ else
+ {
+ cout << "registry is down" << endl;
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -870,24 +870,24 @@ Parser::shutdownRegistry(const list<string>& args)
{
if(args.size() > 1)
{
- invalidCommand("registry shutdown", "requires at most one argument");
- return;
+ invalidCommand("registry shutdown", "requires at most one argument");
+ return;
}
try
{
- if(args.empty())
- {
- _admin->shutdown();
- }
- else
- {
- _admin->shutdownRegistry(args.front());
- }
+ if(args.empty())
+ {
+ _admin->shutdown();
+ }
+ else
+ {
+ _admin->shutdownRegistry(args.front());
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -896,12 +896,12 @@ Parser::listAllRegistries()
{
try
{
- Ice::StringSeq names = _admin->getAllRegistryNames();
- copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
+ Ice::StringSeq names = _admin->getAllRegistryNames();
+ copy(names.begin(), names.end(), ostream_iterator<string>(cout,"\n"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -910,24 +910,24 @@ Parser::removeServer(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("server remove", "requires exactly one argument");
- return;
+ invalidCommand("server remove", "requires exactly one argument");
+ return;
}
try
{
- ServerInfo info = _admin->getServerInfo(args.front());
- NodeUpdateDescriptor nodeUpdate;
- nodeUpdate.name = info.node;
- nodeUpdate.removeServers.push_back(args.front());
- ApplicationUpdateDescriptor update;
- update.name = info.application;
- update.nodes.push_back(nodeUpdate);
- _admin->updateApplication(update);
+ ServerInfo info = _admin->getServerInfo(args.front());
+ NodeUpdateDescriptor nodeUpdate;
+ nodeUpdate.name = info.node;
+ nodeUpdate.removeServers.push_back(args.front());
+ ApplicationUpdateDescriptor update;
+ update.name = info.application;
+ update.nodes.push_back(nodeUpdate);
+ _admin->updateApplication(update);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -936,21 +936,21 @@ Parser::startServer(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("server start", "requires exactly one argument");
- return;
+ invalidCommand("server start", "requires exactly one argument");
+ return;
}
try
{
- _admin->startServer(args.front());
+ _admin->startServer(args.front());
}
catch(const ServerStartException& ex)
{
- error("the server didn't start successfully:\n" + ex.reason);
+ error("the server didn't start successfully:\n" + ex.reason);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -959,21 +959,21 @@ Parser::stopServer(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("server stop", "requires exactly one argument");
- return;
+ invalidCommand("server stop", "requires exactly one argument");
+ return;
}
try
{
- _admin->stopServer(args.front());
+ _admin->stopServer(args.front());
}
catch(const ServerStopException& ex)
{
- error("the server didn't stop successfully:\n" + ex.reason);
+ error("the server didn't stop successfully:\n" + ex.reason);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -988,31 +988,31 @@ Parser::patchServer(const list<string>& origArgs)
vector<string> args;
try
{
- for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
- {
- args.push_back(*p);
- }
- args = opts.parse(args);
+ for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
+ {
+ args.push_back(*p);
+ }
+ args = opts.parse(args);
}
catch(const IceUtil::BadOptException& e)
{
- error(e.reason);
- return;
+ error(e.reason);
+ return;
}
if(args.size() != 1)
{
- invalidCommand("server patch", "requires exactly one argument");
- return;
+ invalidCommand("server patch", "requires exactly one argument");
+ return;
}
try
{
- _admin->patchServer(args.front(), opts.isSet("force"));
+ _admin->patchServer(args.front(), opts.isSet("force"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1021,19 +1021,19 @@ Parser::signalServer(const list<string>& args)
{
if(args.size() != 2)
{
- invalidCommand("server signal", "requires exactly two arguments");
- return;
+ invalidCommand("server signal", "requires exactly two arguments");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
- string server = *p++;
- _admin->sendSignal(server, *p);
+ list<string>::const_iterator p = args.begin();
+ string server = *p++;
+ _admin->sendSignal(server, *p);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1043,19 +1043,19 @@ Parser::writeMessage(const list<string>& args, int fd)
{
if(args.size() != 2)
{
- invalidCommand("server stdout or server stderr", "requires exactly two arguments");
- return;
+ invalidCommand("server stdout or server stderr", "requires exactly two arguments");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
- string server = *p++;
- _admin->writeMessage(server, *p, fd);
+ list<string>::const_iterator p = args.begin();
+ string server = *p++;
+ _admin->writeMessage(server, *p, fd);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1064,28 +1064,28 @@ Parser::describeServer(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("server describe", "requires exactly one argument");
- return;
+ invalidCommand("server describe", "requires exactly one argument");
+ return;
}
try
{
- ServerInfo info = _admin->getServerInfo(args.front());
- Output out(cout);
- IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(info.descriptor);
- if(iceBox)
- {
- IceBoxHelper(iceBox).print(_communicator, out, info);
- }
- else
- {
- ServerHelper(info.descriptor).print(_communicator, out, info);
- }
- out << nl;
+ ServerInfo info = _admin->getServerInfo(args.front());
+ Output out(cout);
+ IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(info.descriptor);
+ if(iceBox)
+ {
+ IceBoxHelper(iceBox).print(_communicator, out, info);
+ }
+ else
+ {
+ ServerHelper(info.descriptor).print(_communicator, out, info);
+ }
+ out << nl;
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1094,60 +1094,60 @@ Parser::stateServer(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("server state", "requires exactly one argument");
- return;
+ invalidCommand("server state", "requires exactly one argument");
+ return;
}
try
{
- ServerState state = _admin->getServerState(args.front());
- string enabled = _admin->isServerEnabled(args.front()) ? "enabled" : "disabled";
- switch(state)
- {
- case Inactive:
- {
- cout << "inactive (" << enabled << ")" << endl;
- break;
- }
- case Activating:
- {
- cout << "activating (" << enabled << ")" << endl;
- break;
- }
- case Active:
- {
- int pid = _admin->getServerPid(args.front());
- cout << "active (pid = " << pid << ", " << enabled << ")" << endl;
- break;
- }
- case ActivationTimedOut:
- {
- int pid = _admin->getServerPid(args.front());
- cout << "activation timed out (pid = " << pid << ", " << enabled << ")" << endl;
- break;
- }
- case Deactivating:
- {
- cout << "deactivating (" << enabled << ")" << endl;
- break;
- }
- case Destroying:
- {
- cout << "destroying (" << enabled << ")" << endl;
- break;
- }
- case Destroyed:
- {
- cout << "destroyed (" << enabled << ")" << endl;
- break;
- }
- default:
- assert(false);
- }
+ ServerState state = _admin->getServerState(args.front());
+ string enabled = _admin->isServerEnabled(args.front()) ? "enabled" : "disabled";
+ switch(state)
+ {
+ case Inactive:
+ {
+ cout << "inactive (" << enabled << ")" << endl;
+ break;
+ }
+ case Activating:
+ {
+ cout << "activating (" << enabled << ")" << endl;
+ break;
+ }
+ case Active:
+ {
+ int pid = _admin->getServerPid(args.front());
+ cout << "active (pid = " << pid << ", " << enabled << ")" << endl;
+ break;
+ }
+ case ActivationTimedOut:
+ {
+ int pid = _admin->getServerPid(args.front());
+ cout << "activation timed out (pid = " << pid << ", " << enabled << ")" << endl;
+ break;
+ }
+ case Deactivating:
+ {
+ cout << "deactivating (" << enabled << ")" << endl;
+ break;
+ }
+ case Destroying:
+ {
+ cout << "destroying (" << enabled << ")" << endl;
+ break;
+ }
+ case Destroyed:
+ {
+ cout << "destroyed (" << enabled << ")" << endl;
+ break;
+ }
+ default:
+ assert(false);
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1156,25 +1156,25 @@ Parser::pidServer(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("server pid", "requires exactly one argument");
- return;
+ invalidCommand("server pid", "requires exactly one argument");
+ return;
}
try
{
- int pid = _admin->getServerPid(args.front());
- if(pid > 0)
- {
- cout << pid << endl;
- }
- else
- {
- error("server is not running");
- }
+ int pid = _admin->getServerPid(args.front());
+ if(pid > 0)
+ {
+ cout << pid << endl;
+ }
+ else
+ {
+ error("server is not running");
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1183,24 +1183,24 @@ Parser::enableServer(const list<string>& args, bool enable)
{
if(args.size() != 1)
{
- if(enable)
- {
- invalidCommand("server enable", "requires exactly one argument");
- }
- else
- {
- invalidCommand("server disable", "requires exactly one argument");
- }
- return;
+ if(enable)
+ {
+ invalidCommand("server enable", "requires exactly one argument");
+ }
+ else
+ {
+ invalidCommand("server disable", "requires exactly one argument");
+ }
+ return;
}
try
{
- _admin->enableServer(args.front(), enable);
+ _admin->enableServer(args.front(), enable);
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1209,12 +1209,12 @@ Parser::listAllServers()
{
try
{
- Ice::StringSeq ids = _admin->getAllServerIds();
- copy(ids.begin(), ids.end(), ostream_iterator<string>(cout,"\n"));
+ Ice::StringSeq ids = _admin->getAllServerIds();
+ copy(ids.begin(), ids.end(), ostream_iterator<string>(cout,"\n"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1223,32 +1223,32 @@ Parser::endpointsAdapter(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("adapter endpoints", "requires exactly one argument");
- return;
+ invalidCommand("adapter endpoints", "requires exactly one argument");
+ return;
}
try
{
- string adapterId = args.front();
- AdapterInfoSeq adpts = _admin->getAdapterInfo(adapterId);
- if(adpts.size() == 1 && adpts.begin()->id == adapterId)
- {
- string endpoints = _communicator->proxyToString(adpts.begin()->proxy);
- cout << (endpoints.empty() ? string("<inactive>") : endpoints) << endl;
- }
- else
- {
- for(AdapterInfoSeq::const_iterator p = adpts.begin(); p != adpts.end(); ++p)
- {
- cout << (p->id.empty() ? string("<empty>") : p->id) << ": ";
- string endpoints = _communicator->proxyToString(p->proxy);
- cout << (endpoints.empty() ? string("<inactive>") : endpoints) << endl;
- }
- }
+ string adapterId = args.front();
+ AdapterInfoSeq adpts = _admin->getAdapterInfo(adapterId);
+ if(adpts.size() == 1 && adpts.begin()->id == adapterId)
+ {
+ string endpoints = _communicator->proxyToString(adpts.begin()->proxy);
+ cout << (endpoints.empty() ? string("<inactive>") : endpoints) << endl;
+ }
+ else
+ {
+ for(AdapterInfoSeq::const_iterator p = adpts.begin(); p != adpts.end(); ++p)
+ {
+ cout << (p->id.empty() ? string("<empty>") : p->id) << ": ";
+ string endpoints = _communicator->proxyToString(p->proxy);
+ cout << (endpoints.empty() ? string("<inactive>") : endpoints) << endl;
+ }
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1257,17 +1257,17 @@ Parser::removeAdapter(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("adapter remove", "requires exactly one argument");
- return;
+ invalidCommand("adapter remove", "requires exactly one argument");
+ return;
}
try
{
- _admin->removeAdapter(*args.begin());
+ _admin->removeAdapter(*args.begin());
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1276,12 +1276,12 @@ Parser::listAllAdapters()
{
try
{
- Ice::StringSeq ids = _admin->getAllAdapterIds();
- copy(ids.begin(), ids.end(), ostream_iterator<string>(cout,"\n"));
+ Ice::StringSeq ids = _admin->getAllAdapterIds();
+ copy(ids.begin(), ids.end(), ostream_iterator<string>(cout,"\n"));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1290,29 +1290,29 @@ Parser::addObject(const list<string>& args)
{
if(args.size() < 1)
{
- invalidCommand("object add", "requires at least one argument");
- return;
+ invalidCommand("object add", "requires at least one argument");
+ return;
}
try
{
- list<string>::const_iterator p = args.begin();
+ list<string>::const_iterator p = args.begin();
- string proxy = *p++;
+ string proxy = *p++;
- if(p != args.end())
- {
- string type = *p++;
- _admin->addObjectWithType(_communicator->stringToProxy(proxy), type);
- }
- else
- {
- _admin->addObject(_communicator->stringToProxy(proxy));
- }
+ if(p != args.end())
+ {
+ string type = *p++;
+ _admin->addObjectWithType(_communicator->stringToProxy(proxy), type);
+ }
+ else
+ {
+ _admin->addObject(_communicator->stringToProxy(proxy));
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1321,17 +1321,17 @@ Parser::removeObject(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("object remove", "requires exactly one argument");
- return;
+ invalidCommand("object remove", "requires exactly one argument");
+ return;
}
try
{
- _admin->removeObject(_communicator->stringToIdentity((*(args.begin()))));
+ _admin->removeObject(_communicator->stringToIdentity((*(args.begin()))));
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1340,21 +1340,21 @@ Parser::findObject(const list<string>& args)
{
if(args.size() != 1)
{
- invalidCommand("object find", "requires exactly one argument");
- return;
+ invalidCommand("object find", "requires exactly one argument");
+ return;
}
try
{
- ObjectInfoSeq objects = _admin->getObjectInfosByType(*(args.begin()));
- for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
- {
- cout << _communicator->proxyToString(p->proxy) << endl;
- }
+ ObjectInfoSeq objects = _admin->getObjectInfosByType(*(args.begin()));
+ for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
+ {
+ cout << _communicator->proxyToString(p->proxy) << endl;
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1363,36 +1363,36 @@ Parser::describeObject(const list<string>& args)
{
try
{
- ObjectInfoSeq objects;
- if(args.size() == 1)
- {
- string arg = *(args.begin());
- if(arg.find('*') == string::npos)
- {
- ObjectInfo info = _admin->getObjectInfo(_communicator->stringToIdentity(arg));
- cout << "proxy = `" << _communicator->proxyToString(info.proxy) << "'" << endl;
- cout << "type = `" << info.type << "'" << endl;
- return;
- }
- else
- {
- objects = _admin->getAllObjectInfos(arg);
- }
- }
- else
- {
- objects = _admin->getAllObjectInfos("");
- }
-
- for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
- {
- cout << "proxy = `" << _communicator->proxyToString(p->proxy) << "' type = `" << p->type << "'" << endl;
- }
-
+ ObjectInfoSeq objects;
+ if(args.size() == 1)
+ {
+ string arg = *(args.begin());
+ if(arg.find('*') == string::npos)
+ {
+ ObjectInfo info = _admin->getObjectInfo(_communicator->stringToIdentity(arg));
+ cout << "proxy = `" << _communicator->proxyToString(info.proxy) << "'" << endl;
+ cout << "type = `" << info.type << "'" << endl;
+ return;
+ }
+ else
+ {
+ objects = _admin->getAllObjectInfos(arg);
+ }
+ }
+ else
+ {
+ objects = _admin->getAllObjectInfos("");
+ }
+
+ for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
+ {
+ cout << "proxy = `" << _communicator->proxyToString(p->proxy) << "' type = `" << p->type << "'" << endl;
+ }
+
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1401,24 +1401,24 @@ Parser::listObject(const list<string>& args)
{
try
{
- ObjectInfoSeq objects;
- if(args.size() == 1)
- {
- objects = _admin->getAllObjectInfos(*(args.begin()));
- }
- else
- {
- objects = _admin->getAllObjectInfos("");
- }
-
- for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
- {
- cout << _communicator->identityToString(p->proxy->ice_getIdentity()) << endl;
- }
+ ObjectInfoSeq objects;
+ if(args.size() == 1)
+ {
+ objects = _admin->getAllObjectInfos(*(args.begin()));
+ }
+ else
+ {
+ objects = _admin->getAllObjectInfos("");
+ }
+
+ for(ObjectInfoSeq::const_iterator p = objects.begin(); p != objects.end(); ++p)
+ {
+ cout << _communicator->identityToString(p->proxy->ice_getIdentity()) << endl;
+ }
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1436,184 +1436,184 @@ Parser::showFile(const string& reader, const list<string>& origArgs)
vector<string> args;
try
{
- for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
- {
- args.push_back(*p);
- }
- args = opts.parse(args);
+ for(list<string>::const_iterator p = copyArgs.begin(); p != copyArgs.end(); ++p)
+ {
+ args.push_back(*p);
+ }
+ args = opts.parse(args);
}
catch(const IceUtil::BadOptException& e)
{
- error(e.reason);
- return;
+ error(e.reason);
+ return;
}
if(args.size() != 2)
{
- invalidCommand(reader + " show", "requires two arguments");
- return;
+ invalidCommand(reader + " show", "requires two arguments");
+ return;
}
try
{
- vector<string>::const_iterator p = args.begin();
- string id = *p++;
- string filename = *p++;
-
- cout << reader << " `" << id << "' " << filename << ": " << flush;
- Ice::StringSeq lines;
-
- bool head = opts.isSet("head");
- bool tail = opts.isSet("tail");
- if(head && tail)
- {
- invalidCommand("can't specify both -h | --head and -t | --tail options");
- return;
- }
- int lineCount = 20;
- int maxBytes = _communicator->getProperties()->getPropertyAsIntWithDefault("Ice.MessageSizeMax", 1024) * 1024;
- if(head || tail)
- {
- if(head)
- {
- istringstream is(opts.optArg("head"));
- is >> lineCount;
- }
- else
- {
- istringstream is(opts.optArg("tail"));
- is >> lineCount;
- }
- if(lineCount <= 0)
- {
- invalidCommand("invalid argument for -h | --head or -t | --tail option");
- return;
- }
- }
-
- FileIteratorPrx it;
- if(reader == "node")
- {
- if(filename == "stderr")
- {
- it = _session->openNodeStdErr(id, tail ? lineCount : -1);
- }
- else if(filename == "stdout")
- {
- it = _session->openNodeStdOut(id, tail ? lineCount : -1);
- }
- else
- {
- invalidCommand("invalid node log filename `" + filename + "'");
- return;
- }
- }
- else if(reader == "registry")
- {
- if(filename == "stderr")
- {
- it = _session->openRegistryStdErr(id, tail ? lineCount : -1);
- }
- else if(filename == "stdout")
- {
- it = _session->openRegistryStdOut(id, tail ? lineCount : -1);
- }
- else
- {
- invalidCommand("invalid registry log filename `" + filename + "'");
- return;
- }
- }
- else if(reader == "server")
- {
- if(filename == "stderr")
- {
- it = _session->openServerStdErr(id, tail ? lineCount : -1);
- }
- else if(filename == "stdout")
- {
- it = _session->openServerStdOut(id, tail ? lineCount : -1);
- }
- else
- {
- it = _session->openServerLog(id, filename, tail ? lineCount : -1);
- }
- }
-
- bool follow = opts.isSet("follow");
- resetInterrupt();
- if(head)
- {
- if(follow)
- {
- invalidCommand("can't use -f | --follow option with -h | --head option");
- return;
- }
-
- int i = 0;
- bool eof = false;
- while(!interrupted() && !eof && i < lineCount)
- {
- eof = it->read(maxBytes, lines);
- for(Ice::StringSeq::const_iterator p = lines.begin(); i < lineCount && p != lines.end(); ++p, ++i)
- {
- cout << endl << *p << flush;
- }
- }
- }
- else
- {
- bool eof = false;
- while(!interrupted() && !eof)
- {
- eof = it->read(maxBytes, lines);
- for(Ice::StringSeq::const_iterator p = lines.begin(); p != lines.end(); ++p)
- {
- cout << endl << *p << flush;
- }
- }
- }
-
- if(follow)
- {
- while(!interrupted())
- {
- bool eof = it->read(maxBytes, lines);
- for(Ice::StringSeq::const_iterator p = lines.begin(); p != lines.end(); ++p)
- {
- cout << *p;
- if((p + 1) != lines.end())
- {
- cout << endl;
- }
- else
- {
- cout << flush;
- }
- }
-
- if(eof)
- {
- Lock sync(*this);
- if(_interrupted)
- {
- break;
- }
- timedWait(IceUtil::Time::seconds(5));
- }
- }
- }
-
- if(lines.empty() || !lines.back().empty())
- {
- cout << endl;
- }
-
- it->destroy();
+ vector<string>::const_iterator p = args.begin();
+ string id = *p++;
+ string filename = *p++;
+
+ cout << reader << " `" << id << "' " << filename << ": " << flush;
+ Ice::StringSeq lines;
+
+ bool head = opts.isSet("head");
+ bool tail = opts.isSet("tail");
+ if(head && tail)
+ {
+ invalidCommand("can't specify both -h | --head and -t | --tail options");
+ return;
+ }
+ int lineCount = 20;
+ int maxBytes = _communicator->getProperties()->getPropertyAsIntWithDefault("Ice.MessageSizeMax", 1024) * 1024;
+ if(head || tail)
+ {
+ if(head)
+ {
+ istringstream is(opts.optArg("head"));
+ is >> lineCount;
+ }
+ else
+ {
+ istringstream is(opts.optArg("tail"));
+ is >> lineCount;
+ }
+ if(lineCount <= 0)
+ {
+ invalidCommand("invalid argument for -h | --head or -t | --tail option");
+ return;
+ }
+ }
+
+ FileIteratorPrx it;
+ if(reader == "node")
+ {
+ if(filename == "stderr")
+ {
+ it = _session->openNodeStdErr(id, tail ? lineCount : -1);
+ }
+ else if(filename == "stdout")
+ {
+ it = _session->openNodeStdOut(id, tail ? lineCount : -1);
+ }
+ else
+ {
+ invalidCommand("invalid node log filename `" + filename + "'");
+ return;
+ }
+ }
+ else if(reader == "registry")
+ {
+ if(filename == "stderr")
+ {
+ it = _session->openRegistryStdErr(id, tail ? lineCount : -1);
+ }
+ else if(filename == "stdout")
+ {
+ it = _session->openRegistryStdOut(id, tail ? lineCount : -1);
+ }
+ else
+ {
+ invalidCommand("invalid registry log filename `" + filename + "'");
+ return;
+ }
+ }
+ else if(reader == "server")
+ {
+ if(filename == "stderr")
+ {
+ it = _session->openServerStdErr(id, tail ? lineCount : -1);
+ }
+ else if(filename == "stdout")
+ {
+ it = _session->openServerStdOut(id, tail ? lineCount : -1);
+ }
+ else
+ {
+ it = _session->openServerLog(id, filename, tail ? lineCount : -1);
+ }
+ }
+
+ bool follow = opts.isSet("follow");
+ resetInterrupt();
+ if(head)
+ {
+ if(follow)
+ {
+ invalidCommand("can't use -f | --follow option with -h | --head option");
+ return;
+ }
+
+ int i = 0;
+ bool eof = false;
+ while(!interrupted() && !eof && i < lineCount)
+ {
+ eof = it->read(maxBytes, lines);
+ for(Ice::StringSeq::const_iterator p = lines.begin(); i < lineCount && p != lines.end(); ++p, ++i)
+ {
+ cout << endl << *p << flush;
+ }
+ }
+ }
+ else
+ {
+ bool eof = false;
+ while(!interrupted() && !eof)
+ {
+ eof = it->read(maxBytes, lines);
+ for(Ice::StringSeq::const_iterator p = lines.begin(); p != lines.end(); ++p)
+ {
+ cout << endl << *p << flush;
+ }
+ }
+ }
+
+ if(follow)
+ {
+ while(!interrupted())
+ {
+ bool eof = it->read(maxBytes, lines);
+ for(Ice::StringSeq::const_iterator p = lines.begin(); p != lines.end(); ++p)
+ {
+ cout << *p;
+ if((p + 1) != lines.end())
+ {
+ cout << endl;
+ }
+ else
+ {
+ cout << flush;
+ }
+ }
+
+ if(eof)
+ {
+ Lock sync(*this);
+ if(_interrupted)
+ {
+ break;
+ }
+ timedWait(IceUtil::Time::seconds(5));
+ }
+ }
+ }
+
+ if(lines.empty() || !lines.back().empty())
+ {
+ cout << endl;
+ }
+
+ it->destroy();
}
catch(const Ice::Exception& ex)
{
- exception(ex);
+ exception(ex);
}
}
@@ -1640,104 +1640,104 @@ Parser::getInput(char* buf, int& result, int maxSize)
{
if(!_commands.empty())
{
- if(_commands == ";")
- {
- result = 0;
- }
- else
- {
+ if(_commands == ";")
+ {
+ result = 0;
+ }
+ else
+ {
#if defined(_MSC_VER) && !defined(_STLP_MSVC)
- // COMPILERBUG: Stupid Visual C++ defines min and max as macros
- result = _MIN(maxSize, static_cast<int>(_commands.length()));
+ // COMPILERBUG: Stupid Visual C++ defines min and max as macros
+ result = _MIN(maxSize, static_cast<int>(_commands.length()));
#else
- result = min(maxSize, static_cast<int>(_commands.length()));
+ result = min(maxSize, static_cast<int>(_commands.length()));
#endif
- strncpy(buf, _commands.c_str(), result);
- _commands.erase(0, result);
- if(_commands.empty())
- {
- _commands = ";";
- }
- }
+ strncpy(buf, _commands.c_str(), result);
+ _commands.erase(0, result);
+ if(_commands.empty())
+ {
+ _commands = ";";
+ }
+ }
}
else if(isatty(fileno(yyin)))
{
#ifdef HAVE_READLINE
const char* prompt = parser->getPrompt();
- char* line = readline(const_cast<char*>(prompt));
- if(!line)
- {
- result = 0;
- }
- else
- {
- if(*line)
- {
- add_history(line);
- }
-
- result = strlen(line) + 1;
- if(result > maxSize)
- {
- free(line);
- error("input line too long");
- result = 0;
- }
- else
- {
- strcpy(buf, line);
- strcat(buf, "\n");
- free(line);
- }
- }
+ char* line = readline(const_cast<char*>(prompt));
+ if(!line)
+ {
+ result = 0;
+ }
+ else
+ {
+ if(*line)
+ {
+ add_history(line);
+ }
+
+ result = strlen(line) + 1;
+ if(result > maxSize)
+ {
+ free(line);
+ error("input line too long");
+ result = 0;
+ }
+ else
+ {
+ strcpy(buf, line);
+ strcat(buf, "\n");
+ free(line);
+ }
+ }
#else
- cout << parser->getPrompt() << flush;
-
- string line;
- while(true)
- {
- char c = static_cast<char>(getc(yyin));
- if(c == EOF)
- {
- if(line.size())
- {
- line += '\n';
- }
- break;
- }
- line += c;
-
- if(c == '\n')
- {
- break;
- }
- }
-
- result = (int) line.length();
- if(result > maxSize)
- {
- error("input line too long");
- buf[0] = EOF;
- result = 1;
- }
- else
- {
- strcpy(buf, line.c_str());
- }
+ cout << parser->getPrompt() << flush;
+
+ string line;
+ while(true)
+ {
+ char c = static_cast<char>(getc(yyin));
+ if(c == EOF)
+ {
+ if(line.size())
+ {
+ line += '\n';
+ }
+ break;
+ }
+ line += c;
+
+ if(c == '\n')
+ {
+ break;
+ }
+ }
+
+ result = (int) line.length();
+ if(result > maxSize)
+ {
+ error("input line too long");
+ buf[0] = EOF;
+ result = 1;
+ }
+ else
+ {
+ strcpy(buf, line.c_str());
+ }
#endif
}
else
{
- if(((result = (int) fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin))
- {
- error("input in flex scanner failed");
- buf[0] = EOF;
- result = 1;
- }
+ if(((result = (int) fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin))
+ {
+ error("input in flex scanner failed");
+ buf[0] = EOF;
+ result = 1;
+ }
}
}
@@ -1760,12 +1760,12 @@ Parser::getPrompt()
if(_continue)
{
- _continue = false;
- return "(cont) ";
+ _continue = false;
+ return "(cont) ";
}
else
{
- return ">>> ";
+ return ">>> ";
}
}
@@ -1778,13 +1778,13 @@ Parser::scanPosition(const char* s)
idx = line.find("line");
if(idx != string::npos)
{
- line.erase(0, idx + 4);
+ line.erase(0, idx + 4);
}
idx = line.find_first_not_of(" \t\r#");
if(idx != string::npos)
{
- line.erase(0, idx);
+ line.erase(0, idx);
}
_currentLine = atoi(line.c_str()) - 1;
@@ -1792,24 +1792,24 @@ Parser::scanPosition(const char* s)
idx = line.find_first_of(" \t\r");
if(idx != string::npos)
{
- line.erase(0, idx);
+ line.erase(0, idx);
}
idx = line.find_first_not_of(" \t\r\"");
if(idx != string::npos)
{
- line.erase(0, idx);
+ line.erase(0, idx);
- idx = line.find_first_of(" \t\r\"");
- if(idx != string::npos)
- {
- _currentFile = line.substr(0, idx);
- line.erase(0, idx + 1);
- }
- else
- {
- _currentFile = line;
- }
+ idx = line.find_first_of(" \t\r\"");
+ if(idx != string::npos)
+ {
+ _currentFile = line.substr(0, idx);
+ line.erase(0, idx + 1);
+ }
+ else
+ {
+ _currentFile = line;
+ }
}
}
@@ -1840,31 +1840,31 @@ Parser::patchFailed(const Ice::StringSeq& reasons)
out << "the patch failed on some nodes:\n";
for(Ice::StringSeq::const_iterator p = reasons.begin(); p != reasons.end(); ++p)
{
- string reason = *p;
- string::size_type beg = 0;
- string::size_type end = reason.find_first_of("\n");
- if(end == string::npos)
- {
- end = reason.size();
- }
- out << "- " << reason.substr(beg, end - beg);
- out.inc();
- while(end < reason.size())
- {
- beg = end + 1;
- end = reason.find_first_of("\n", beg);
- if(end == string::npos)
- {
- end = reason.size();
- }
- out.newline();
- out << reason.substr(beg, end - beg);
- }
- out.dec();
- if(p + 1 != reasons.end())
- {
- out.newline();
- }
+ string reason = *p;
+ string::size_type beg = 0;
+ string::size_type end = reason.find_first_of("\n");
+ if(end == string::npos)
+ {
+ end = reason.size();
+ }
+ out << "- " << reason.substr(beg, end - beg);
+ out.inc();
+ while(end < reason.size())
+ {
+ beg = end + 1;
+ end = reason.find_first_of("\n", beg);
+ if(end == string::npos)
+ {
+ end = reason.size();
+ }
+ out.newline();
+ out << reason.substr(beg, end - beg);
+ }
+ out.dec();
+ if(p + 1 != reasons.end())
+ {
+ out.newline();
+ }
}
warning(os.str());
}
@@ -1874,11 +1874,11 @@ Parser::error(const char* s)
{
if(_commands.empty() && !isatty(fileno(yyin)))
{
- cerr << _currentFile << ':' << _currentLine << ": " << s << endl;
+ cerr << _currentFile << ':' << _currentLine << ": " << s << endl;
}
else
{
- cerr << "error: " << s << endl;
+ cerr << "error: " << s << endl;
}
_errors++;
}
@@ -1894,11 +1894,11 @@ Parser::warning(const char* s)
{
if(_commands.empty() && !isatty(fileno(yyin)))
{
- cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl;
+ cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl;
}
else
{
- cerr << "warning: " << s << endl;
+ cerr << "warning: " << s << endl;
}
}
@@ -1929,7 +1929,7 @@ Parser::parse(FILE* file, bool debug)
int status = yyparse();
if(_errors)
{
- status = EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
parser = 0;
@@ -1957,7 +1957,7 @@ Parser::parse(const std::string& commands, bool debug)
int status = yyparse();
if(_errors)
{
- status = EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
parser = 0;
@@ -1965,9 +1965,9 @@ Parser::parse(const std::string& commands, bool debug)
}
Parser::Parser(const CommunicatorPtr& communicator,
- const AdminSessionPrx& session,
- const AdminPrx& admin,
- bool interactive) :
+ const AdminSessionPrx& session,
+ const AdminPrx& admin,
+ bool interactive) :
_communicator(communicator),
_session(session),
_admin(admin),
@@ -1976,11 +1976,11 @@ Parser::Parser(const CommunicatorPtr& communicator,
{
for(int i = 0; _commandsHelp[i][0]; i++)
{
- const string category = _commandsHelp[i][0];
- const string cmd = _commandsHelp[i][1];
- const string help = _commandsHelp[i][2];
- _helpCommands[category][""] += help;
- _helpCommands[category][cmd] += help;
+ const string category = _commandsHelp[i][0];
+ const string cmd = _commandsHelp[i][1];
+ const string help = _commandsHelp[i][2];
+ _helpCommands[category][""] += help;
+ _helpCommands[category][cmd] += help;
}
}
@@ -1989,81 +1989,81 @@ Parser::exception(const Ice::Exception& ex)
{
try
{
- ex.ice_throw();
+ ex.ice_throw();
}
catch(const ApplicationNotExistException& ex)
{
- error("couldn't find application `" + ex.name + "'");
+ error("couldn't find application `" + ex.name + "'");
}
catch(const NodeNotExistException& ex)
{
- error("couldn't find node `" + ex.name + "'");
+ error("couldn't find node `" + ex.name + "'");
}
catch(const ServerNotExistException& ex)
{
- error("couldn't find server `" + ex.id + "'");
+ error("couldn't find server `" + ex.id + "'");
}
catch(const AdapterNotExistException& ex)
{
- error("couldn't find adapter `" + ex.id + "'");
+ error("couldn't find adapter `" + ex.id + "'");
}
catch(const ObjectExistsException& ex)
{
- error("object `" + _communicator->identityToString(ex.id) + "' already exists");
+ error("object `" + _communicator->identityToString(ex.id) + "' already exists");
}
catch(const DeploymentException& ex)
{
- ostringstream s;
- s << ex << ":\n" << ex.reason;
- error(s.str());
+ ostringstream s;
+ s << ex << ":\n" << ex.reason;
+ error(s.str());
}
catch(const PatchException& ex)
{
- if(ex.reasons.size() == 1)
- {
- ostringstream s;
- s << ex << ":\n" << ex.reasons[0];
- error(s.str());
- }
- else
- {
- patchFailed(ex.reasons);
- }
+ if(ex.reasons.size() == 1)
+ {
+ ostringstream s;
+ s << ex << ":\n" << ex.reasons[0];
+ error(s.str());
+ }
+ else
+ {
+ patchFailed(ex.reasons);
+ }
}
catch(const BadSignalException& ex)
{
- ostringstream s;
- s << ex.reason;
- error(s.str());
+ ostringstream s;
+ s << ex.reason;
+ error(s.str());
}
catch(const NodeUnreachableException& ex)
{
- error("node `" + ex.name + "' couldn't be reached:\n" + ex.reason);
+ error("node `" + ex.name + "' couldn't be reached:\n" + ex.reason);
}
catch(const AccessDeniedException& ex)
{
- error("couldn't update the registry, the session from `" + ex.lockUserId + "' is updating the registry");
+ error("couldn't update the registry, the session from `" + ex.lockUserId + "' is updating the registry");
}
catch(const FileNotAvailableException& ex)
{
- error("couldn't access file:\n" + ex.reason);
+ error("couldn't access file:\n" + ex.reason);
}
catch(const IceXML::ParserException& ex)
{
- ostringstream s;
- s << ex;
- error(s.str());
+ ostringstream s;
+ s << ex;
+ error(s.str());
}
catch(const Ice::LocalException& ex)
{
- ostringstream s;
- s << "couldn't reach the IceGrid registry:\n" << ex;
- error(s.str());
+ ostringstream s;
+ s << "couldn't reach the IceGrid registry:\n" << ex;
+ error(s.str());
}
catch(const Ice::Exception& ex)
{
- ostringstream s;
- s << ex;
- error(s.str());
+ ostringstream s;
+ s << ex;
+ error(s.str());
}
}
diff --git a/cpp/src/IceGrid/PlatformInfo.cpp b/cpp/src/IceGrid/PlatformInfo.cpp
index e9245b89527..ff7ccf65a3c 100644
--- a/cpp/src/IceGrid/PlatformInfo.cpp
+++ b/cpp/src/IceGrid/PlatformInfo.cpp
@@ -50,7 +50,7 @@ getLocalizedPerfName(const map<string, string>& perfNames, const string& name)
map<string, string>::const_iterator p = perfNames.find(name);
if(p == perfNames.end())
{
- return "";
+ return "";
}
istringstream is(p->second);
is >> idx;
@@ -60,8 +60,8 @@ getLocalizedPerfName(const map<string, string>& perfNames, const string& name)
localized.resize(size);
while(PdhLookupPerfNameByIndex(0, idx, &localized[0], &size) == PDH_MORE_DATA)
{
- size += 256;
- localized.resize(size);
+ size += 256;
+ localized.resize(size);
}
return string(&localized[0]);
}
@@ -94,8 +94,8 @@ toNodeInfo(const InternalNodeInfoPtr& node)
}
PlatformInfo::PlatformInfo(const string& prefix,
- const Ice::CommunicatorPtr& communicator,
- const TraceLevelsPtr& traceLevels) :
+ const Ice::CommunicatorPtr& communicator,
+ const TraceLevelsPtr& traceLevels) :
_traceLevels(traceLevels)
{
//
@@ -125,18 +125,18 @@ PlatformInfo::PlatformInfo(const string& prefix,
nl.n_value = 0;
if(knlist(&nl, 1, sizeof(nl)) == 0)
{
- _kmem = open("/dev/kmem", O_RDONLY);
+ _kmem = open("/dev/kmem", O_RDONLY);
- //
- // Give up root permissions to minimize security risks, it's
- // only needed to access /dev/kmem.
- //
+ //
+ // Give up root permissions to minimize security risks, it's
+ // only needed to access /dev/kmem.
+ //
setuid(getuid());
setgid(getgid());
}
else
{
- _kmem = -1;
+ _kmem = -1;
}
#endif
@@ -152,9 +152,9 @@ PlatformInfo::PlatformInfo(const string& prefix,
size_t sz = sizeof(_nProcessors);
if(sysctl(ncpu, 2, &_nProcessors, &sz, 0, 0) == -1)
{
- Ice::SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
+ Ice::SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
}
#elif defined(__hpux)
struct pst_dynamic dynInfo;
@@ -179,7 +179,7 @@ PlatformInfo::PlatformInfo(const string& prefix,
unsigned long size = sizeof(hostname);
if(GetComputerName(hostname, &size))
{
- _hostname = hostname;
+ _hostname = hostname;
}
OSVERSIONINFO osInfo;
osInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
@@ -196,17 +196,17 @@ PlatformInfo::PlatformInfo(const string& prefix,
#else
case PROCESSOR_ARCHITECTURE_AMD64:
#endif
- _machine = "x64";
- break;
+ _machine = "x64";
+ break;
case PROCESSOR_ARCHITECTURE_IA64:
- _machine = "IA64";
- break;
+ _machine = "IA64";
+ break;
case PROCESSOR_ARCHITECTURE_INTEL:
- _machine = "x86";
- break;
+ _machine = "x86";
+ break;
default:
- _machine = "unknown";
- break;
+ _machine = "unknown";
+ break;
};
#else
struct utsname utsinfo;
@@ -226,15 +226,15 @@ PlatformInfo::PlatformInfo(const string& prefix,
string oldEndpointsPrefix;
if(prefix == "IceGrid.Registry")
{
- _name = properties->getPropertyWithDefault("IceGrid.Registry.ReplicaName", "Master");
- endpointsPrefix = "Ice.OA." + prefix + ".Client";
- oldEndpointsPrefix = prefix + ".Client";
+ _name = properties->getPropertyWithDefault("IceGrid.Registry.ReplicaName", "Master");
+ endpointsPrefix = "Ice.OA." + prefix + ".Client";
+ oldEndpointsPrefix = prefix + ".Client";
}
else
{
- _name = properties->getProperty(prefix + ".Name");
- endpointsPrefix = "Ice.OA." + prefix;
- oldEndpointsPrefix = prefix;
+ _name = properties->getProperty(prefix + ".Name");
+ endpointsPrefix = "Ice.OA." + prefix;
+ oldEndpointsPrefix = prefix;
}
Ice::PropertyDict props = properties->getPropertiesForPrefix(endpointsPrefix);
@@ -254,7 +254,7 @@ PlatformInfo::PlatformInfo(const string& prefix,
else
{
_endpoints = properties->getPropertyWithDefault(
- endpointsPrefix + ".Endpoints", properties->getProperty(oldEndpointsPrefix + ".Endpoints"));
+ endpointsPrefix + ".Endpoints", properties->getProperty(oldEndpointsPrefix + ".Endpoints"));
}
}
@@ -262,7 +262,7 @@ PlatformInfo::PlatformInfo(const string& prefix,
char cwd[_MAX_PATH];
if(_getcwd(cwd, _MAX_PATH) == NULL)
#else
- char cwd[PATH_MAX];
+ char cwd[PATH_MAX];
if(getcwd(cwd, PATH_MAX) == NULL)
#endif
{
@@ -273,11 +273,11 @@ PlatformInfo::PlatformInfo(const string& prefix,
_dataDir = properties->getProperty(prefix + ".Data");
if(!IcePatch2::isAbsolute(_dataDir))
{
- _dataDir = _cwd + '/' + _dataDir;
+ _dataDir = _cwd + '/' + _dataDir;
}
if(_dataDir[_dataDir.length() - 1] == '/')
{
- _dataDir = _dataDir.substr(0, _dataDir.length() - 1);
+ _dataDir = _dataDir.substr(0, _dataDir.length() - 1);
}
}
@@ -286,12 +286,12 @@ PlatformInfo::~PlatformInfo()
#ifdef _WIN32
if(_query != NULL)
{
- PdhCloseQuery(_query);
+ PdhCloseQuery(_query);
}
#elif defined(_AIX)
if(_kmem > 0)
{
- close(_kmem);
+ close(_kmem);
}
#endif
}
@@ -344,14 +344,14 @@ PlatformInfo::getLoadInfo()
int usage = 100;
if(_query == NULL)
{
- initQuery();
+ initQuery();
}
if(_query != NULL && _counter != NULL && PdhCollectQueryData(_query) == ERROR_SUCCESS)
{
- DWORD type;
- PDH_FMT_COUNTERVALUE value;
- PdhGetFormattedCounterValue(_counter, PDH_FMT_LONG, &type, &value);
- usage = static_cast<int>(value.longValue);
+ DWORD type;
+ PDH_FMT_COUNTERVALUE value;
+ PdhGetFormattedCounterValue(_counter, PDH_FMT_LONG, &type, &value);
+ usage = static_cast<int>(value.longValue);
}
_last1Total += usage - _usages1.back();
@@ -377,34 +377,34 @@ PlatformInfo::getLoadInfo()
double loadAvg[3];
if(getloadavg(loadAvg, 3) != -1)
{
- info.avg1 = static_cast<float>(loadAvg[0]);
- info.avg5 = static_cast<float>(loadAvg[1]);
- info.avg15 = static_cast<float>(loadAvg[2]);
+ info.avg1 = static_cast<float>(loadAvg[0]);
+ info.avg5 = static_cast<float>(loadAvg[1]);
+ info.avg15 = static_cast<float>(loadAvg[2]);
}
#elif defined(__hpux)
struct pst_dynamic dynInfo;
if(pstat_getdynamic(&dynInfo, sizeof(dynInfo), 1, 0) >= 0)
{
- info.avg1 = dynInfo.psd_avg_1_min;
- info.avg5 = dynInfo.psd_avg_5_min;
- info.avg15 = dynInfo.psd_avg_15_min;
+ info.avg1 = dynInfo.psd_avg_1_min;
+ info.avg5 = dynInfo.psd_avg_5_min;
+ info.avg15 = dynInfo.psd_avg_15_min;
}
#elif defined(_AIX)
if(_kmem > 1)
{
- long long avenrun[3];
- struct nlist nl;
- nl.n_name = "avenrun";
- nl.n_value = 0;
- if(knlist(&nl, 1, sizeof(nl)) == 0)
- {
- if(pread(_kmem, avenrun, sizeof(avenrun), nl.n_value) >= sizeof(avenrun))
- {
- info.avg1 = avenrun[0] / 65536.0f;
- info.avg5 = avenrun[1] / 65536.0f;
- info.avg15 = avenrun[2] / 65536.0f;
- }
- }
+ long long avenrun[3];
+ struct nlist nl;
+ nl.n_name = "avenrun";
+ nl.n_value = 0;
+ if(knlist(&nl, 1, sizeof(nl)) == 0)
+ {
+ if(pread(_kmem, avenrun, sizeof(avenrun), nl.n_value) >= sizeof(avenrun))
+ {
+ info.avg1 = avenrun[0] / 65536.0f;
+ info.avg5 = avenrun[1] / 65536.0f;
+ info.avg15 = avenrun[2] / 65536.0f;
+ }
+ }
}
#endif
return info;
@@ -438,11 +438,11 @@ PlatformInfo::initQuery()
PDH_STATUS err = PdhOpenQuery(0, 0, &_query);
if(err != ERROR_SUCCESS)
{
- Ice::SyscallException ex(__FILE__, __LINE__);
- ex.error = err;
- Ice::Warning out(_traceLevels->logger);
- out << "can't open performance data query:\n" << ex;
- return;
+ Ice::SyscallException ex(__FILE__, __LINE__);
+ ex.error = err;
+ Ice::Warning out(_traceLevels->logger);
+ out << "can't open performance data query:\n" << ex;
+ return;
}
//
@@ -453,8 +453,8 @@ PlatformInfo::initQuery()
buffer.resize(size);
while(RegQueryValueEx(HKEY_PERFORMANCE_DATA, "Counter 09", 0, 0, &buffer[0], &size) == ERROR_MORE_DATA)
{
- size += 8192;
- buffer.resize(size);
+ size += 8192;
+ buffer.resize(size);
}
map<string, string> perfNames;
@@ -462,15 +462,15 @@ PlatformInfo::initQuery()
unsigned int i = 0;
while(i < buffer.size() && buf[i])
{
- string index(&buf[i]);
- i += static_cast<int>(index.size()) + 1;
- if(i >= buffer.size())
- {
- break;
- }
- string name(&buf[i]);
- i += static_cast<int>(name.size()) + 1;
- perfNames.insert(make_pair(name, index));
+ string index(&buf[i]);
+ i += static_cast<int>(index.size()) + 1;
+ if(i >= buffer.size())
+ {
+ break;
+ }
+ string name(&buf[i]);
+ i += static_cast<int>(name.size()) + 1;
+ perfNames.insert(make_pair(name, index));
}
//
@@ -486,10 +486,10 @@ PlatformInfo::initQuery()
err = PdhAddCounter(_query, name.c_str(), 0, &_counter);
if(err != ERROR_SUCCESS)
{
- Ice::SyscallException ex(__FILE__, __LINE__);
- ex.error = err;
- Ice::Warning out(_traceLevels->logger);
- out << "can't add performance counter `" << name << "':\n" << ex;
+ Ice::SyscallException ex(__FILE__, __LINE__);
+ ex.error = err;
+ Ice::Warning out(_traceLevels->logger);
+ out << "can't add performance counter `" << name << "':\n" << ex;
}
}
#endif
diff --git a/cpp/src/IceGrid/QueryI.cpp b/cpp/src/IceGrid/QueryI.cpp
index 187b6c1339f..3d5cddf03ea 100644
--- a/cpp/src/IceGrid/QueryI.cpp
+++ b/cpp/src/IceGrid/QueryI.cpp
@@ -30,11 +30,11 @@ QueryI::findObjectById(const Ice::Identity& id, const Ice::Current&) const
{
try
{
- return _database->getObjectProxy(id);
+ return _database->getObjectProxy(id);
}
catch(const ObjectNotRegisteredException&)
{
- return 0;
+ return 0;
}
}
@@ -62,28 +62,28 @@ QueryI::findAllReplicas(const Ice::ObjectPrx& proxy, const Ice::Current&) const
{
try
{
- if(!proxy)
- {
- return Ice::ObjectProxySeq();
- }
+ if(!proxy)
+ {
+ return Ice::ObjectProxySeq();
+ }
- AdapterInfoSeq infos = _database->getAdapterInfo(proxy->ice_getAdapterId());
- assert(!infos.empty());
- if(infos[0].replicaGroupId != proxy->ice_getAdapterId()) // The adapter id doesn't refer to a replica group.
- {
- return Ice::ObjectProxySeq();
- }
+ AdapterInfoSeq infos = _database->getAdapterInfo(proxy->ice_getAdapterId());
+ assert(!infos.empty());
+ if(infos[0].replicaGroupId != proxy->ice_getAdapterId()) // The adapter id doesn't refer to a replica group.
+ {
+ return Ice::ObjectProxySeq();
+ }
- Ice::ObjectProxySeq proxies;
- for(AdapterInfoSeq::const_iterator p = infos.begin(); p != infos.end(); ++p)
- {
- assert(!p->id.empty());
- proxies.push_back(proxy->ice_adapterId(p->id));
- }
- return proxies;
+ Ice::ObjectProxySeq proxies;
+ for(AdapterInfoSeq::const_iterator p = infos.begin(); p != infos.end(); ++p)
+ {
+ assert(!p->id.empty());
+ proxies.push_back(proxy->ice_adapterId(p->id));
+ }
+ return proxies;
}
catch(const AdapterNotExistException&)
{
- return Ice::ObjectProxySeq();
+ return Ice::ObjectProxySeq();
}
}
diff --git a/cpp/src/IceGrid/QueryI.h b/cpp/src/IceGrid/QueryI.h
index 58fb86c182b..37a6ea87df3 100644
--- a/cpp/src/IceGrid/QueryI.h
+++ b/cpp/src/IceGrid/QueryI.h
@@ -31,7 +31,7 @@ public:
virtual Ice::ObjectPrx findObjectByType(const ::std::string&, const ::Ice::Current&) const;
virtual Ice::ObjectPrx findObjectByTypeOnLeastLoadedNode(const ::std::string&, LoadSample,
- const ::Ice::Current&) const;
+ const ::Ice::Current&) const;
virtual Ice::ObjectProxySeq findAllObjectsByType(const ::std::string&, const ::Ice::Current&) const;
diff --git a/cpp/src/IceGrid/ReapThread.cpp b/cpp/src/IceGrid/ReapThread.cpp
index e781683bd41..06869232b6e 100644
--- a/cpp/src/IceGrid/ReapThread.cpp
+++ b/cpp/src/IceGrid/ReapThread.cpp
@@ -24,61 +24,61 @@ ReapThread::run()
vector<ReapableItem> reap;
while(true)
{
- {
- Lock sync(*this);
- if(_terminated)
- {
- break;
- }
-
- calcWakeInterval();
-
- //
- // If the wake interval is zero then we wait forever.
- //
- if(_wakeInterval == IceUtil::Time())
- {
- assert(_sessions.empty());
- wait();
- }
- else
- {
- assert(!_sessions.empty());
- timedWait(_wakeInterval);
- }
-
- if(_terminated)
- {
- break;
- }
-
- list<ReapableItem>::iterator p = _sessions.begin();
- while(p != _sessions.end())
- {
- try
- {
- if((IceUtil::Time::now() - p->item->timestamp()) > p->timeout)
- {
- reap.push_back(*p);
- p = _sessions.erase(p);
- }
- else
- {
- ++p;
- }
- }
- catch(const Ice::ObjectNotExistException&)
- {
- p = _sessions.erase(p);
- }
- }
- }
-
- for(vector<ReapableItem>::const_iterator p = reap.begin(); p != reap.end(); ++p)
- {
- p->item->destroy(false);
- }
- reap.clear();
+ {
+ Lock sync(*this);
+ if(_terminated)
+ {
+ break;
+ }
+
+ calcWakeInterval();
+
+ //
+ // If the wake interval is zero then we wait forever.
+ //
+ if(_wakeInterval == IceUtil::Time())
+ {
+ assert(_sessions.empty());
+ wait();
+ }
+ else
+ {
+ assert(!_sessions.empty());
+ timedWait(_wakeInterval);
+ }
+
+ if(_terminated)
+ {
+ break;
+ }
+
+ list<ReapableItem>::iterator p = _sessions.begin();
+ while(p != _sessions.end())
+ {
+ try
+ {
+ if((IceUtil::Time::now() - p->item->timestamp()) > p->timeout)
+ {
+ reap.push_back(*p);
+ p = _sessions.erase(p);
+ }
+ else
+ {
+ ++p;
+ }
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ p = _sessions.erase(p);
+ }
+ }
+ }
+
+ for(vector<ReapableItem>::const_iterator p = reap.begin(); p != reap.end(); ++p)
+ {
+ p->item->destroy(false);
+ }
+ reap.clear();
}
}
@@ -87,20 +87,20 @@ ReapThread::terminate()
{
list<ReapableItem> reap;
{
- Lock sync(*this);
- if(_terminated)
- {
- assert(_sessions.empty());
- return;
- }
- _terminated = true;
- notify();
- reap.swap(_sessions);
+ Lock sync(*this);
+ if(_terminated)
+ {
+ assert(_sessions.empty());
+ return;
+ }
+ _terminated = true;
+ notify();
+ reap.swap(_sessions);
}
for(list<ReapableItem>::iterator p = reap.begin(); p != reap.end(); ++p)
{
- p->item->destroy(true);
+ p->item->destroy(true);
}
}
@@ -110,7 +110,7 @@ ReapThread::add(const ReapablePtr& reapable, int timeout)
Lock sync(*this);
if(_terminated)
{
- return;
+ return;
}
//
@@ -118,7 +118,7 @@ ReapThread::add(const ReapablePtr& reapable, int timeout)
//
if(timeout < 10)
{
- timeout = 10;
+ timeout = 10;
}
ReapableItem item;
@@ -132,7 +132,7 @@ ReapThread::add(const ReapablePtr& reapable, int timeout)
//
if(calcWakeInterval())
{
- notify();
+ notify();
}
//
@@ -154,11 +154,11 @@ ReapThread::calcWakeInterval()
bool first = true;
for(list<ReapableItem>::const_iterator p = _sessions.begin(); p != _sessions.end(); ++p)
{
- if(first || p->timeout < minimum)
- {
- minimum = p->timeout;
- first = false;
- }
+ if(first || p->timeout < minimum)
+ {
+ minimum = p->timeout;
+ first = false;
+ }
}
_wakeInterval = minimum;
diff --git a/cpp/src/IceGrid/ReapThread.h b/cpp/src/IceGrid/ReapThread.h
index 317624fcba5..88729d500ac 100644
--- a/cpp/src/IceGrid/ReapThread.h
+++ b/cpp/src/IceGrid/ReapThread.h
@@ -43,42 +43,42 @@ class SessionReapable : public Reapable
public:
SessionReapable(const Ice::LoggerPtr& logger, const TPtr& session) :
- _logger(logger), _session(session)
+ _logger(logger), _session(session)
{
}
virtual ~SessionReapable()
{
}
-
+
virtual IceUtil::Time
timestamp() const
{
- return _session->timestamp();
+ return _session->timestamp();
}
virtual void
destroy(bool shutdown)
{
- try
- {
- if(shutdown)
- {
- _session->shutdown();
- }
- else
- {
- _session->destroy(Ice::Current());
- }
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Warning out(_logger);
- out << "unexpected exception while reaping session:\n" << ex;
- }
+ try
+ {
+ if(shutdown)
+ {
+ _session->shutdown();
+ }
+ else
+ {
+ _session->destroy(Ice::Current());
+ }
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_logger);
+ out << "unexpected exception while reaping session:\n" << ex;
+ }
}
private:
@@ -105,8 +105,8 @@ private:
bool _terminated;
struct ReapableItem
{
- ReapablePtr item;
- IceUtil::Time timeout;
+ ReapablePtr item;
+ IceUtil::Time timeout;
};
std::list<ReapableItem> _sessions;
};
diff --git a/cpp/src/IceGrid/RegistryI.cpp b/cpp/src/IceGrid/RegistryI.cpp
index e059519cbc0..8f9d0fc1287 100644
--- a/cpp/src/IceGrid/RegistryI.cpp
+++ b/cpp/src/IceGrid/RegistryI.cpp
@@ -65,7 +65,7 @@ public:
bool checkPermissions(const string& userId, const string& password, string&, const Current&) const
{
- return true;
+ return true;
}
};
@@ -76,7 +76,7 @@ public:
virtual bool
authorize(const Glacier2::SSLInfo&, std::string&, const Ice::Current&) const
{
- return true;
+ return true;
}
};
@@ -90,25 +90,25 @@ public:
bool checkPermissions(const string& userId, const string& password, string&, const Current&) const
{
- map<string, string>::const_iterator p = _passwords.find(userId);
- if(p == _passwords.end())
- {
- return false;
- }
-
- if(p->second.size() != 13) // Crypt passwords are 13 characters long.
- {
- return false;
- }
-
- char buff[14];
- string salt = p->second.substr(0, 2);
+ map<string, string>::const_iterator p = _passwords.find(userId);
+ if(p == _passwords.end())
+ {
+ return false;
+ }
+
+ if(p->second.size() != 13) // Crypt passwords are 13 characters long.
+ {
+ return false;
+ }
+
+ char buff[14];
+ string salt = p->second.substr(0, 2);
#if OPENSSL_VERSION_NUMBER >= 0x0090700fL
- DES_fcrypt(password.c_str(), salt.c_str(), buff);
+ DES_fcrypt(password.c_str(), salt.c_str(), buff);
#else
- des_fcrypt(password.c_str(), salt.c_str(), buff);
+ des_fcrypt(password.c_str(), salt.c_str(), buff);
#endif
- return p->second == buff;
+ return p->second == buff;
}
private:
@@ -141,21 +141,21 @@ RegistryI::start(bool nowarn)
string dbPath = properties->getProperty("IceGrid.Registry.Data");
if(dbPath.empty())
{
- Error out(_communicator->getLogger());
- out << "property `IceGrid.Registry.Data' is not set";
- return false;
+ Error out(_communicator->getLogger());
+ out << "property `IceGrid.Registry.Data' is not set";
+ return false;
}
else
{
- struct stat filestat;
- if(stat(dbPath.c_str(), &filestat) != 0 || !S_ISDIR(filestat.st_mode))
- {
- Error out(_communicator->getLogger());
- SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- out << "property `IceGrid.Registry.Data' is set to an invalid path:\n" << ex;
- return false;
- }
+ struct stat filestat;
+ if(stat(dbPath.c_str(), &filestat) != 0 || !S_ISDIR(filestat.st_mode))
+ {
+ Error out(_communicator->getLogger());
+ SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ out << "property `IceGrid.Registry.Data' is set to an invalid path:\n" << ex;
+ return false;
+ }
}
//
@@ -166,9 +166,9 @@ RegistryI::start(bool nowarn)
if(properties->getProperty("Ice.OA.IceGrid.Registry.Client.Endpoints").empty() &&
properties->getProperty("IceGrid.Registry.Client.Endpoints").empty())
{
- Error out(_communicator->getLogger());
- out << "property `Ice.OA.IceGrid.Registry.Client.Endpoints' is not set";
- return false;
+ Error out(_communicator->getLogger());
+ out << "property `Ice.OA.IceGrid.Registry.Client.Endpoints' is not set";
+ return false;
}
//
@@ -177,9 +177,9 @@ RegistryI::start(bool nowarn)
if(properties->getProperty("Ice.OA.IceGrid.Registry.Server.Endpoints").empty() &&
properties->getProperty("IceGrid.Registry.Server.Endpoints").empty())
{
- Error out(_communicator->getLogger());
- out << "property `Ice.OA.IceGrid.Registry.Server.Endpoints' is not set";
- return false;
+ Error out(_communicator->getLogger());
+ out << "property `Ice.OA.IceGrid.Registry.Server.Endpoints' is not set";
+ return false;
}
//
@@ -188,9 +188,9 @@ RegistryI::start(bool nowarn)
if(properties->getProperty("Ice.OA.IceGrid.Registry.Internal.Endpoints").empty() &&
properties->getProperty("IceGrid.Registry.Internal.Endpoints").empty())
{
- Error out(_communicator->getLogger());
- out << "property `Ice.OA.IceGrid.Registry.Internal.Endpoints' is not set";
- return false;
+ Error out(_communicator->getLogger());
+ out << "property `Ice.OA.IceGrid.Registry.Internal.Endpoints' is not set";
+ return false;
}
//
@@ -199,11 +199,11 @@ RegistryI::start(bool nowarn)
if(!properties->getProperty("Ice.OA.IceGrid.Registry.SessionManager.Endpoints").empty() ||
!properties->getProperty("IceGrid.Registry.SessionManager.Endpoints").empty())
{
- if(!nowarn)
- {
- Warning out(_communicator->getLogger());
- out << "session manager endpoints `Ice.OA.IceGrid.Registry.SessionManager.Endpoints' enabled";
- }
+ if(!nowarn)
+ {
+ Warning out(_communicator->getLogger());
+ out << "session manager endpoints `Ice.OA.IceGrid.Registry.SessionManager.Endpoints' enabled";
+ }
}
properties->setProperty("Ice.PrintProcessId", "0");
@@ -228,28 +228,28 @@ RegistryI::start(bool nowarn)
//
if(_master)
{
- _instanceName = properties->getProperty("IceGrid.InstanceName");
- if(_instanceName.empty())
- {
- if(_communicator->getDefaultLocator())
- {
- _instanceName = _communicator->getDefaultLocator()->ice_getIdentity().category;
- }
- else
- {
- _instanceName = "IceGrid";
- }
- }
+ _instanceName = properties->getProperty("IceGrid.InstanceName");
+ if(_instanceName.empty())
+ {
+ if(_communicator->getDefaultLocator())
+ {
+ _instanceName = _communicator->getDefaultLocator()->ice_getIdentity().category;
+ }
+ else
+ {
+ _instanceName = "IceGrid";
+ }
+ }
}
else
{
- if(properties->getProperty("Ice.Default.Locator").empty())
- {
- Error out(_communicator->getLogger());
- out << "property `Ice.Default.Locator' is not set";
- return false;
- }
- _instanceName = _communicator->getDefaultLocator()->ice_getIdentity().category;
+ if(properties->getProperty("Ice.Default.Locator").empty())
+ {
+ Error out(_communicator->getLogger());
+ out << "property `Ice.Default.Locator' is not set";
+ return false;
+ }
+ _instanceName = _communicator->getDefaultLocator()->ice_getIdentity().category;
}
//
@@ -261,18 +261,18 @@ RegistryI::start(bool nowarn)
try
{
//
- // DEPRECATED PROPERTY: Remove extra code in future release
- //
+ // DEPRECATED PROPERTY: Remove extra code in future release
+ //
string endpoints =
- properties->getPropertyWithDefault("Ice.OA.IceGrid.Registry.Client.Endpoints",
- properties->getProperty("IceGrid.Registry.Client.Endpoints"));
- string strPrx = _instanceName + "/Locator:" + endpoints;
- _communicator->stringToProxy(strPrx)->ice_timeout(5000)->ice_ping();
+ properties->getPropertyWithDefault("Ice.OA.IceGrid.Registry.Client.Endpoints",
+ properties->getProperty("IceGrid.Registry.Client.Endpoints"));
+ string strPrx = _instanceName + "/Locator:" + endpoints;
+ _communicator->stringToProxy(strPrx)->ice_timeout(5000)->ice_ping();
- Error out(_communicator->getLogger());
- out << "an IceGrid registry is already running and listening on\n";
- out << "the client endpoints `" << endpoints << "'";
- return false;
+ Error out(_communicator->getLogger());
+ out << "an IceGrid registry is already running and listening on\n";
+ out << "the client endpoints `" << endpoints << "'";
+ return false;
}
catch(const Ice::LocalException&)
{
@@ -300,11 +300,11 @@ RegistryI::start(bool nowarn)
registryTopicManagerId.category = _instanceName;
registryTopicManagerId.name = "RegistryTopicManager";
_iceStorm = IceStorm::Service::create(_communicator,
- registryAdapter,
- registryAdapter,
- "IceGrid.Registry",
- registryTopicManagerId,
- "Registry");
+ registryAdapter,
+ registryAdapter,
+ "IceGrid.Registry",
+ registryTopicManagerId,
+ "Registry");
const IceStorm::TopicManagerPrx topicManager = _iceStorm->getTopicManager();
//
@@ -324,14 +324,14 @@ RegistryI::start(bool nowarn)
proxies = _database->getInternalObjectsByType(Node::ice_staticId());
for(p = proxies.begin(); p != proxies.end(); ++p)
{
- nodes.push_back(NodePrx::uncheckedCast(*p));
+ nodes.push_back(NodePrx::uncheckedCast(*p));
}
InternalRegistryPrxSeq replicas;
proxies = _database->getObjectsByType(InternalRegistry::ice_staticId());
for(p = proxies.begin(); p != proxies.end(); ++p)
{
- replicas.push_back(InternalRegistryPrx::uncheckedCast(*p));
+ replicas.push_back(InternalRegistryPrx::uncheckedCast(*p));
}
//
@@ -343,14 +343,14 @@ RegistryI::start(bool nowarn)
InternalRegistryPrx internalRegistry = setupInternalRegistry(registryAdapter);
if(_master)
{
- nodes = registerReplicas(internalRegistry, replicas, nodes);
- registerNodes(internalRegistry, nodes);
+ nodes = registerReplicas(internalRegistry, replicas, nodes);
+ registerNodes(internalRegistry, nodes);
}
else
{
- InternalReplicaInfoPtr info = _platform.getInternalReplicaInfo();
- _session.create(_replicaName, info, _database, _wellKnownObjects, internalRegistry);
- registerNodes(internalRegistry, _session.getNodes(nodes));
+ InternalReplicaInfoPtr info = _platform.getInternalReplicaInfo();
+ _session.create(_replicaName, info, _database, _wellKnownObjects, internalRegistry);
+ registerNodes(internalRegistry, _session.getNodes(nodes));
}
ObjectAdapterPtr serverAdapter = _communicator->createObjectAdapter("IceGrid.Registry.Server");
@@ -362,7 +362,7 @@ RegistryI::start(bool nowarn)
if(!properties->getProperty("Ice.OA.IceGrid.Registry.SessionManager.Endpoints").empty() ||
!properties->getProperty("IceGrid.Registry.SessionManager.Endpoints").empty())
{
- sessionManagerAdapter = _communicator->createObjectAdapter("IceGrid.Registry.SessionManager");
+ sessionManagerAdapter = _communicator->createObjectAdapter("IceGrid.Registry.SessionManager");
}
Ice::Identity dummy;
@@ -371,14 +371,14 @@ RegistryI::start(bool nowarn)
_wellKnownObjects->addEndpoint("Server", serverAdapter->createDirectProxy(dummy));
if(sessionManagerAdapter)
{
- _wellKnownObjects->addEndpoint("SessionManager", sessionManagerAdapter->createDirectProxy(dummy));
+ _wellKnownObjects->addEndpoint("SessionManager", sessionManagerAdapter->createDirectProxy(dummy));
}
_wellKnownObjects->addEndpoint("Internal", registryAdapter->createDirectProxy(dummy));
setupNullPermissionsVerifier(registryAdapter);
if(!setupUserAccountMapper(registryAdapter))
{
- return false;
+ return false;
}
QueryPrx query = setupQuery(_clientAdapter);
@@ -401,11 +401,11 @@ RegistryI::start(bool nowarn)
_wellKnownObjects->finish();
if(_master)
{
- _wellKnownObjects->registerAll();
+ _wellKnownObjects->registerAll();
}
else
{
- _session.registerAllWellKnownObjects();
+ _session.registerAllWellKnownObjects();
}
//
@@ -415,7 +415,7 @@ RegistryI::start(bool nowarn)
_clientAdapter->activate();
if(sessionManagerAdapter)
{
- sessionManagerAdapter->activate();
+ sessionManagerAdapter->activate();
}
return true;
@@ -434,10 +434,10 @@ RegistryI::setupLocatorRegistry(const Ice::ObjectAdapterPtr& serverAdapter)
IceGrid::LocatorPrx
RegistryI::setupLocator(const Ice::ObjectAdapterPtr& clientAdapter,
- const Ice::ObjectAdapterPtr& registryAdapter,
- const Ice::LocatorRegistryPrx& locatorRegistry,
- const RegistryPrx& registry,
- const QueryPrx& query)
+ const Ice::ObjectAdapterPtr& registryAdapter,
+ const Ice::LocatorRegistryPrx& locatorRegistry,
+ const RegistryPrx& registry,
+ const QueryPrx& query)
{
LocatorPtr locator = new LocatorI(_communicator, _database, locatorRegistry, registry, query);
Identity locatorId;
@@ -469,7 +469,7 @@ RegistryI::setupRegistry(const Ice::ObjectAdapterPtr& clientAdapter)
registryId.name = "Registry";
if(!_master)
{
- registryId.name += "-" + _replicaName;
+ registryId.name += "-" + _replicaName;
}
RegistryPrx proxy = RegistryPrx::uncheckedCast(clientAdapter->add(this, registryId));
_wellKnownObjects->add(proxy, Registry::ice_staticId());
@@ -499,13 +499,13 @@ RegistryI::setupNullPermissionsVerifier(const Ice::ObjectAdapterPtr& registryAda
nullPermVerifId.category = _instanceName;
nullPermVerifId.name = "NullPermissionsVerifier";
_nullPermissionsVerifier = Glacier2::PermissionsVerifierPrx::uncheckedCast(
- registryAdapter->add(new NullPermissionsVerifierI(), nullPermVerifId)->ice_collocationOptimized(true));
+ registryAdapter->add(new NullPermissionsVerifierI(), nullPermVerifId)->ice_collocationOptimized(true));
Identity nullSSLPermVerifId;
nullSSLPermVerifId.category = _instanceName;
nullSSLPermVerifId.name = "NullSSLPermissionsVerifier";
_nullSSLPermissionsVerifier = Glacier2::SSLPermissionsVerifierPrx::uncheckedCast(
- registryAdapter->add(new NullSSLPermissionsVerifierI(), nullSSLPermVerifId)->ice_collocationOptimized(true));
+ registryAdapter->add(new NullSSLPermissionsVerifierI(), nullSSLPermVerifId)->ice_collocationOptimized(true));
}
bool
@@ -519,33 +519,33 @@ RegistryI::setupUserAccountMapper(const Ice::ObjectAdapterPtr& registryAdapter)
string userAccountFileProperty = properties->getProperty("IceGrid.Registry.UserAccounts");
if(!userAccountFileProperty.empty())
{
- try
- {
- Identity mapperId;
- mapperId.category = _instanceName;
- mapperId.name = "RegistryUserAccountMapper";
- if(!_master)
- {
- mapperId.name += "-" + _replicaName;
- }
- registryAdapter->add(new FileUserAccountMapperI(userAccountFileProperty), mapperId);
- _wellKnownObjects->add(registryAdapter->createProxy(mapperId), UserAccountMapper::ice_staticId());
- }
- catch(const std::string& msg)
- {
- Error out(_communicator->getLogger());
- out << msg;
- return false;
- }
+ try
+ {
+ Identity mapperId;
+ mapperId.category = _instanceName;
+ mapperId.name = "RegistryUserAccountMapper";
+ if(!_master)
+ {
+ mapperId.name += "-" + _replicaName;
+ }
+ registryAdapter->add(new FileUserAccountMapperI(userAccountFileProperty), mapperId);
+ _wellKnownObjects->add(registryAdapter->createProxy(mapperId), UserAccountMapper::ice_staticId());
+ }
+ catch(const std::string& msg)
+ {
+ Error out(_communicator->getLogger());
+ out << msg;
+ return false;
+ }
}
return true;
}
void
RegistryI::setupClientSessionFactory(const Ice::ObjectAdapterPtr& registryAdapter,
- const Ice::ObjectAdapterPtr& sessionManagerAdapter,
- const IceGrid::LocatorPrx& locator,
- bool nowarn)
+ const Ice::ObjectAdapterPtr& sessionManagerAdapter,
+ const IceGrid::LocatorPrx& locator,
+ bool nowarn)
{
_waitQueue = new WaitQueue(); // Used for for session allocation timeout.
_waitQueue->start();
@@ -555,80 +555,80 @@ RegistryI::setupClientSessionFactory(const Ice::ObjectAdapterPtr& registryAdapte
if(sessionManagerAdapter && _master) // Slaves don't support client session manager objects.
{
- Identity clientSessionMgrId;
- clientSessionMgrId.category = _instanceName;
- clientSessionMgrId.name = "SessionManager";
- Identity sslClientSessionMgrId;
- sslClientSessionMgrId.category = _instanceName;
- sslClientSessionMgrId.name = "SSLSessionManager";
+ Identity clientSessionMgrId;
+ clientSessionMgrId.category = _instanceName;
+ clientSessionMgrId.name = "SessionManager";
+ Identity sslClientSessionMgrId;
+ sslClientSessionMgrId.category = _instanceName;
+ sslClientSessionMgrId.name = "SSLSessionManager";
- sessionManagerAdapter->add(new ClientSessionManagerI(_clientSessionFactory), clientSessionMgrId);
- sessionManagerAdapter->add(new ClientSSLSessionManagerI(_clientSessionFactory), sslClientSessionMgrId);
+ sessionManagerAdapter->add(new ClientSessionManagerI(_clientSessionFactory), clientSessionMgrId);
+ sessionManagerAdapter->add(new ClientSSLSessionManagerI(_clientSessionFactory), sslClientSessionMgrId);
- _wellKnownObjects->add(sessionManagerAdapter->createProxy(clientSessionMgrId),
- Glacier2::SessionManager::ice_staticId());
-
- _wellKnownObjects->add(sessionManagerAdapter->createProxy(sslClientSessionMgrId),
- Glacier2::SSLSessionManager::ice_staticId());
+ _wellKnownObjects->add(sessionManagerAdapter->createProxy(clientSessionMgrId),
+ Glacier2::SessionManager::ice_staticId());
+
+ _wellKnownObjects->add(sessionManagerAdapter->createProxy(sslClientSessionMgrId),
+ Glacier2::SSLSessionManager::ice_staticId());
}
Ice::PropertiesPtr properties = _communicator->getProperties();
_clientVerifier = getPermissionsVerifier(registryAdapter,
- locator,
- "IceGrid.Registry.PermissionsVerifier",
- properties->getProperty("IceGrid.Registry.CryptPasswords"),
- nowarn);
+ locator,
+ "IceGrid.Registry.PermissionsVerifier",
+ properties->getProperty("IceGrid.Registry.CryptPasswords"),
+ nowarn);
_sslClientVerifier = getSSLPermissionsVerifier(locator,
- "IceGrid.Registry.SSLPermissionsVerifier",
- nowarn);
+ "IceGrid.Registry.SSLPermissionsVerifier",
+ nowarn);
}
void
RegistryI::setupAdminSessionFactory(const Ice::ObjectAdapterPtr& registryAdapter,
- const Ice::ObjectAdapterPtr& sessionManagerAdapter,
- const IceGrid::LocatorPrx& locator,
- bool nowarn)
+ const Ice::ObjectAdapterPtr& sessionManagerAdapter,
+ const IceGrid::LocatorPrx& locator,
+ bool nowarn)
{
assert(_reaper);
_adminSessionFactory = new AdminSessionFactory(sessionManagerAdapter, _database, _reaper, this);
if(sessionManagerAdapter)
{
- Identity adminSessionMgrId;
- adminSessionMgrId.category = _instanceName;
- adminSessionMgrId.name = "AdminSessionManager";
- Identity sslAdmSessionMgrId;
- sslAdmSessionMgrId.category = _instanceName;
- sslAdmSessionMgrId.name = "AdminSSLSessionManager";
- if(!_master)
- {
- adminSessionMgrId.name += "-" + _replicaName;
- sslAdmSessionMgrId.name += "-" + _replicaName;
- }
-
- sessionManagerAdapter->add(new AdminSessionManagerI(_adminSessionFactory), adminSessionMgrId);
- sessionManagerAdapter->add(new AdminSSLSessionManagerI(_adminSessionFactory), sslAdmSessionMgrId);
-
- _wellKnownObjects->add(sessionManagerAdapter->createProxy(adminSessionMgrId),
- Glacier2::SessionManager::ice_staticId());
- _wellKnownObjects->add(sessionManagerAdapter->createProxy(sslAdmSessionMgrId),
- Glacier2::SSLSessionManager::ice_staticId());
+ Identity adminSessionMgrId;
+ adminSessionMgrId.category = _instanceName;
+ adminSessionMgrId.name = "AdminSessionManager";
+ Identity sslAdmSessionMgrId;
+ sslAdmSessionMgrId.category = _instanceName;
+ sslAdmSessionMgrId.name = "AdminSSLSessionManager";
+ if(!_master)
+ {
+ adminSessionMgrId.name += "-" + _replicaName;
+ sslAdmSessionMgrId.name += "-" + _replicaName;
+ }
+
+ sessionManagerAdapter->add(new AdminSessionManagerI(_adminSessionFactory), adminSessionMgrId);
+ sessionManagerAdapter->add(new AdminSSLSessionManagerI(_adminSessionFactory), sslAdmSessionMgrId);
+
+ _wellKnownObjects->add(sessionManagerAdapter->createProxy(adminSessionMgrId),
+ Glacier2::SessionManager::ice_staticId());
+ _wellKnownObjects->add(sessionManagerAdapter->createProxy(sslAdmSessionMgrId),
+ Glacier2::SSLSessionManager::ice_staticId());
}
Ice::PropertiesPtr properties = _communicator->getProperties();
_adminVerifier = getPermissionsVerifier(registryAdapter,
- locator,
- "IceGrid.Registry.AdminPermissionsVerifier",
- properties->getProperty("IceGrid.Registry.AdminCryptPasswords"),
- nowarn);
+ locator,
+ "IceGrid.Registry.AdminPermissionsVerifier",
+ properties->getProperty("IceGrid.Registry.AdminCryptPasswords"),
+ nowarn);
_sslAdminVerifier =
- getSSLPermissionsVerifier(locator,
- "IceGrid.Registry.AdminSSLPermissionsVerifier",
- nowarn);
+ getSSLPermissionsVerifier(locator,
+ "IceGrid.Registry.AdminSSLPermissionsVerifier",
+ nowarn);
}
void
@@ -650,27 +650,27 @@ RegistryI::stop()
}
catch(const Ice::LocalException& ex)
{
- Warning out(_communicator->getLogger());
- out << "unexpected exception while shutting down registry communicator:\n" << ex;
+ Warning out(_communicator->getLogger());
+ out << "unexpected exception while shutting down registry communicator:\n" << ex;
}
if(_reaper)
{
- _reaper->terminate();
- _reaper->getThreadControl().join();
- _reaper = 0;
+ _reaper->terminate();
+ _reaper->getThreadControl().join();
+ _reaper = 0;
}
if(_waitQueue)
{
- _waitQueue->destroy();
- _waitQueue = 0;
+ _waitQueue->destroy();
+ _waitQueue = 0;
}
if(_iceStorm)
{
- _iceStorm->stop();
- _iceStorm = 0;
+ _iceStorm->stop();
+ _iceStorm = 0;
}
_wellKnownObjects = 0;
@@ -684,20 +684,20 @@ RegistryI::createSession(const string& user, const string& password, const Curre
{
if(!_master)
{
- PermissionDeniedException ex;
- ex.reason = "client session creation is only allowed with the master registry.";
- throw ex;
+ PermissionDeniedException ex;
+ ex.reason = "client session creation is only allowed with the master registry.";
+ throw ex;
}
assert(_reaper && _clientSessionFactory);
if(!_clientVerifier)
{
- PermissionDeniedException ex;
- ex.reason = "no permissions verifier configured, use the property\n";
- ex.reason += "`IceGrid.Registry.PermissionsVerifier' to configure\n";
- ex.reason += "a permissions verifier.";
- throw ex;
+ PermissionDeniedException ex;
+ ex.reason = "no permissions verifier configured, use the property\n";
+ ex.reason += "`IceGrid.Registry.PermissionsVerifier' to configure\n";
+ ex.reason += "a permissions verifier.";
+ throw ex;
}
if(user.empty())
@@ -709,32 +709,32 @@ RegistryI::createSession(const string& user, const string& password, const Curre
try
{
- string reason;
- if(!_clientVerifier->checkPermissions(user, password, reason, current.ctx))
- {
- PermissionDeniedException exc;
- exc.reason = reason;
- throw exc;
- }
+ string reason;
+ if(!_clientVerifier->checkPermissions(user, password, reason, current.ctx))
+ {
+ PermissionDeniedException exc;
+ exc.reason = reason;
+ throw exc;
+ }
}
catch(const LocalException& ex)
{
- if(_traceLevels && _traceLevels->session > 0)
- {
- Trace out(_traceLevels->logger, _traceLevels->sessionCat);
- out << "exception while verifying password with client permission verifier:\n" << ex;
- }
+ if(_traceLevels && _traceLevels->session > 0)
+ {
+ Trace out(_traceLevels->logger, _traceLevels->sessionCat);
+ out << "exception while verifying password with client permission verifier:\n" << ex;
+ }
- PermissionDeniedException exc;
- exc.reason = "internal server error";
- throw exc;
+ PermissionDeniedException exc;
+ exc.reason = "internal server error";
+ throw exc;
}
SessionIPtr session = _clientSessionFactory->createSessionServant(user, 0);
Ice::ObjectPrx proxy = session->registerWithServantLocator(_sessionServantLocator, current.con);
if(_sessionTimeout > 0)
{
- _reaper->add(new SessionReapable<SessionI>(_traceLevels->logger, session), _sessionTimeout);
+ _reaper->add(new SessionReapable<SessionI>(_traceLevels->logger, session), _sessionTimeout);
}
return SessionPrx::uncheckedCast(proxy);
}
@@ -746,11 +746,11 @@ RegistryI::createAdminSession(const string& user, const string& password, const
if(!_adminVerifier)
{
- PermissionDeniedException ex;
- ex.reason = "no admin permissions verifier configured, use the property\n";
- ex.reason += "`IceGrid.Registry.AdminPermissionsVerifier' to configure\n";
- ex.reason += "a permissions verifier.";
- throw ex;
+ PermissionDeniedException ex;
+ ex.reason = "no admin permissions verifier configured, use the property\n";
+ ex.reason += "`IceGrid.Registry.AdminPermissionsVerifier' to configure\n";
+ ex.reason += "a permissions verifier.";
+ throw ex;
}
if(user.empty())
@@ -762,32 +762,32 @@ RegistryI::createAdminSession(const string& user, const string& password, const
try
{
- string reason;
- if(!_adminVerifier->checkPermissions(user, password, reason, current.ctx))
- {
- PermissionDeniedException exc;
- exc.reason = reason;
- throw exc;
- }
+ string reason;
+ if(!_adminVerifier->checkPermissions(user, password, reason, current.ctx))
+ {
+ PermissionDeniedException exc;
+ exc.reason = reason;
+ throw exc;
+ }
}
catch(const LocalException& ex)
{
- if(_traceLevels && _traceLevels->session > 0)
- {
- Trace out(_traceLevels->logger, _traceLevels->sessionCat);
- out << "exception while verifying password with admin permission verifier:\n" << ex;
- }
+ if(_traceLevels && _traceLevels->session > 0)
+ {
+ Trace out(_traceLevels->logger, _traceLevels->sessionCat);
+ out << "exception while verifying password with admin permission verifier:\n" << ex;
+ }
- PermissionDeniedException exc;
- exc.reason = "internal server error";
- throw exc;
+ PermissionDeniedException exc;
+ exc.reason = "internal server error";
+ throw exc;
}
AdminSessionIPtr session = _adminSessionFactory->createSessionServant(user);
Ice::ObjectPrx proxy = session->registerWithServantLocator(_sessionServantLocator, current.con, this);
if(_sessionTimeout > 0)
{
- _reaper->add(new SessionReapable<AdminSessionI>(_traceLevels->logger, session), _sessionTimeout);
+ _reaper->add(new SessionReapable<AdminSessionI>(_traceLevels->logger, session), _sessionTimeout);
}
return AdminSessionPrx::uncheckedCast(proxy);
}
@@ -797,20 +797,20 @@ RegistryI::createSessionFromSecureConnection(const Current& current)
{
if(!_master)
{
- PermissionDeniedException ex;
- ex.reason = "client session creation is only allowed with the master registry.";
- throw ex;
+ PermissionDeniedException ex;
+ ex.reason = "client session creation is only allowed with the master registry.";
+ throw ex;
}
assert(_reaper && _clientSessionFactory);
if(!_sslClientVerifier)
{
- PermissionDeniedException ex;
- ex.reason = "no ssl permissions verifier configured, use the property\n";
- ex.reason += "`IceGrid.Registry.SSLPermissionsVerifier' to configure\n";
- ex.reason += "a permissions verifier.";
- throw ex;
+ PermissionDeniedException ex;
+ ex.reason = "no ssl permissions verifier configured, use the property\n";
+ ex.reason += "`IceGrid.Registry.SSLPermissionsVerifier' to configure\n";
+ ex.reason += "a permissions verifier.";
+ throw ex;
}
string userDN;
@@ -824,32 +824,32 @@ RegistryI::createSessionFromSecureConnection(const Current& current)
try
{
- string reason;
- if(!_sslClientVerifier->authorize(info, reason, current.ctx))
- {
- PermissionDeniedException exc;
- exc.reason = reason;
- throw exc;
- }
+ string reason;
+ if(!_sslClientVerifier->authorize(info, reason, current.ctx))
+ {
+ PermissionDeniedException exc;
+ exc.reason = reason;
+ throw exc;
+ }
}
catch(const LocalException& ex)
{
- if(_traceLevels && _traceLevels->session > 0)
- {
- Trace out(_traceLevels->logger, _traceLevels->sessionCat);
- out << "exception while verifying password with SSL client permission verifier:\n" << ex;
- }
+ if(_traceLevels && _traceLevels->session > 0)
+ {
+ Trace out(_traceLevels->logger, _traceLevels->sessionCat);
+ out << "exception while verifying password with SSL client permission verifier:\n" << ex;
+ }
- PermissionDeniedException exc;
- exc.reason = "internal server error";
- throw exc;
+ PermissionDeniedException exc;
+ exc.reason = "internal server error";
+ throw exc;
}
SessionIPtr session = _clientSessionFactory->createSessionServant(userDN, 0);
Ice::ObjectPrx proxy = session->registerWithServantLocator(_sessionServantLocator, current.con);
if(_sessionTimeout > 0)
{
- _reaper->add(new SessionReapable<SessionI>(_traceLevels->logger, session), _sessionTimeout);
+ _reaper->add(new SessionReapable<SessionI>(_traceLevels->logger, session), _sessionTimeout);
}
return SessionPrx::uncheckedCast(proxy);
}
@@ -861,36 +861,36 @@ RegistryI::createAdminSessionFromSecureConnection(const Current& current)
if(!_sslAdminVerifier)
{
- PermissionDeniedException ex;
- ex.reason = "no ssl admin permissions verifier configured, use the property\n";
- ex.reason += "`IceGrid.Registry.AdminSSLPermissionsVerifier' to configure\n";
- ex.reason += "a permissions verifier.";
- throw ex;
+ PermissionDeniedException ex;
+ ex.reason = "no ssl admin permissions verifier configured, use the property\n";
+ ex.reason += "`IceGrid.Registry.AdminSSLPermissionsVerifier' to configure\n";
+ ex.reason += "a permissions verifier.";
+ throw ex;
}
string userDN;
Glacier2::SSLInfo info = getSSLInfo(current.con, userDN);
try
{
- string reason;
- if(!_sslAdminVerifier->authorize(info, reason, current.ctx))
- {
- PermissionDeniedException exc;
- exc.reason = reason;
- throw exc;
- }
+ string reason;
+ if(!_sslAdminVerifier->authorize(info, reason, current.ctx))
+ {
+ PermissionDeniedException exc;
+ exc.reason = reason;
+ throw exc;
+ }
}
catch(const LocalException& ex)
{
- if(_traceLevels && _traceLevels->session > 0)
- {
- Trace out(_traceLevels->logger, _traceLevels->sessionCat);
- out << "exception while verifying password with SSL admin permission verifier:\n" << ex;
- }
+ if(_traceLevels && _traceLevels->session > 0)
+ {
+ Trace out(_traceLevels->logger, _traceLevels->sessionCat);
+ out << "exception while verifying password with SSL admin permission verifier:\n" << ex;
+ }
- PermissionDeniedException exc;
- exc.reason = "internal server error";
- throw exc;
+ PermissionDeniedException exc;
+ exc.reason = "internal server error";
+ throw exc;
}
//
@@ -900,7 +900,7 @@ RegistryI::createAdminSessionFromSecureConnection(const Current& current)
Ice::ObjectPrx proxy = session->registerWithServantLocator(_sessionServantLocator, current.con, this);
if(_sessionTimeout > 0)
{
- _reaper->add(new SessionReapable<AdminSessionI>(_traceLevels->logger, session), _sessionTimeout);
+ _reaper->add(new SessionReapable<AdminSessionI>(_traceLevels->logger, session), _sessionTimeout);
}
return AdminSessionPrx::uncheckedCast(proxy);
}
@@ -942,34 +942,34 @@ RegistryI::setupThreadPool(const PropertiesPtr& properties, const string& name,
{
if(properties->getPropertyAsIntWithDefault(name + ".Size", 0) < size)
{
- ostringstream os;
- os << size;
- properties->setProperty(name + ".Size", os.str());
+ ostringstream os;
+ os << size;
+ properties->setProperty(name + ".Size", os.str());
}
else
{
- size = properties->getPropertyAsInt(name + ".Size");
+ size = properties->getPropertyAsInt(name + ".Size");
}
if(sizeMax > 0 && properties->getPropertyAsIntWithDefault(name + ".SizeMax", 0) < sizeMax)
{
- if(size >= sizeMax)
- {
- sizeMax = size * 10;
- }
-
- ostringstream os;
- os << sizeMax;
- properties->setProperty(name + ".SizeMax", os.str());
+ if(size >= sizeMax)
+ {
+ sizeMax = size * 10;
+ }
+
+ ostringstream os;
+ os << sizeMax;
+ properties->setProperty(name + ".SizeMax", os.str());
}
}
Glacier2::PermissionsVerifierPrx
RegistryI::getPermissionsVerifier(const ObjectAdapterPtr& adapter,
- const IceGrid::LocatorPrx& locator,
- const string& verifierProperty,
- const string& passwordsProperty,
- bool nowarn)
+ const IceGrid::LocatorPrx& locator,
+ const string& verifierProperty,
+ const string& passwordsProperty,
+ bool nowarn)
{
//
// Get the permissions verifier, or create a default one if no
@@ -980,61 +980,61 @@ RegistryI::getPermissionsVerifier(const ObjectAdapterPtr& adapter,
string verifierPropertyValue = _communicator->getProperties()->getProperty(verifierProperty);
if(!verifierPropertyValue.empty())
{
- try
- {
- verifier = _communicator->propertyToProxy(verifierProperty);
- assert(_nullPermissionsVerifier);
- if(verifier->ice_getIdentity() == _nullPermissionsVerifier->ice_getIdentity())
- {
- verifier = _nullPermissionsVerifier;
- }
- }
- catch(const LocalException& ex)
- {
- Error out(_communicator->getLogger());
- out << "permissions verifier `" + verifierPropertyValue + "' is invalid:\n" << ex;
- return 0;
- }
+ try
+ {
+ verifier = _communicator->propertyToProxy(verifierProperty);
+ assert(_nullPermissionsVerifier);
+ if(verifier->ice_getIdentity() == _nullPermissionsVerifier->ice_getIdentity())
+ {
+ verifier = _nullPermissionsVerifier;
+ }
+ }
+ catch(const LocalException& ex)
+ {
+ Error out(_communicator->getLogger());
+ out << "permissions verifier `" + verifierPropertyValue + "' is invalid:\n" << ex;
+ return 0;
+ }
}
else if(!passwordsProperty.empty())
{
- ifstream passwordFile(passwordsProperty.c_str());
- if(!passwordFile)
- {
- Error out(_communicator->getLogger());
+ ifstream passwordFile(passwordsProperty.c_str());
+ if(!passwordFile)
+ {
+ Error out(_communicator->getLogger());
string err = strerror(errno);
- out << "cannot open `" + passwordsProperty + "' for reading: " + err;
- return 0;
- }
-
- map<string, string> passwords;
-
- while(true)
- {
- string userId;
- passwordFile >> userId;
- if(!passwordFile)
- {
- break;
- }
-
- string password;
- passwordFile >> password;
- if(!passwordFile)
- {
- break;
- }
-
- assert(!userId.empty());
- assert(!password.empty());
- passwords.insert(make_pair(userId, password));
- }
-
- verifier = adapter->addWithUUID(new CryptPermissionsVerifierI(passwords));
+ out << "cannot open `" + passwordsProperty + "' for reading: " + err;
+ return 0;
+ }
+
+ map<string, string> passwords;
+
+ while(true)
+ {
+ string userId;
+ passwordFile >> userId;
+ if(!passwordFile)
+ {
+ break;
+ }
+
+ string password;
+ passwordFile >> password;
+ if(!passwordFile)
+ {
+ break;
+ }
+
+ assert(!userId.empty());
+ assert(!password.empty());
+ passwords.insert(make_pair(userId, password));
+ }
+
+ verifier = adapter->addWithUUID(new CryptPermissionsVerifierI(passwords));
}
else
{
- return 0;
+ return 0;
}
assert(verifier);
@@ -1042,28 +1042,28 @@ RegistryI::getPermissionsVerifier(const ObjectAdapterPtr& adapter,
Glacier2::PermissionsVerifierPrx verifierPrx;
try
{
- //
- // Set the permission verifier proxy locator to the internal
- // locator. We can't use the "public" locator, this could lead
- // to deadlocks if there's not enough threads in the client
- // thread pool anymore.
- //
- verifierPrx = Glacier2::PermissionsVerifierPrx::checkedCast(verifier->ice_locator(locator));
- if(!verifierPrx)
- {
- Error out(_communicator->getLogger());
- out << "permissions verifier `" + verifierProperty + "' is invalid";
- return 0;
- }
+ //
+ // Set the permission verifier proxy locator to the internal
+ // locator. We can't use the "public" locator, this could lead
+ // to deadlocks if there's not enough threads in the client
+ // thread pool anymore.
+ //
+ verifierPrx = Glacier2::PermissionsVerifierPrx::checkedCast(verifier->ice_locator(locator));
+ if(!verifierPrx)
+ {
+ Error out(_communicator->getLogger());
+ out << "permissions verifier `" + verifierProperty + "' is invalid";
+ return 0;
+ }
}
catch(const LocalException& ex)
{
- if(!nowarn)
- {
- Warning out(_communicator->getLogger());
- out << "couldn't contact permissions verifier `" + verifierProperty + "':\n" << ex;
- }
- verifierPrx = Glacier2::PermissionsVerifierPrx::uncheckedCast(verifier->ice_locator(locator));
+ if(!nowarn)
+ {
+ Warning out(_communicator->getLogger());
+ out << "couldn't contact permissions verifier `" + verifierProperty + "':\n" << ex;
+ }
+ verifierPrx = Glacier2::PermissionsVerifierPrx::uncheckedCast(verifier->ice_locator(locator));
}
return verifierPrx;
}
@@ -1081,18 +1081,18 @@ RegistryI::getSSLPermissionsVerifier(const IceGrid::LocatorPrx& locator, const s
{
try
{
- verifier = _communicator->propertyToProxy(verifierProperty);
- assert(_nullSSLPermissionsVerifier);
- if(verifier->ice_getIdentity() == _nullSSLPermissionsVerifier->ice_getIdentity())
- {
- verifier = _nullSSLPermissionsVerifier;
- }
+ verifier = _communicator->propertyToProxy(verifierProperty);
+ assert(_nullSSLPermissionsVerifier);
+ if(verifier->ice_getIdentity() == _nullSSLPermissionsVerifier->ice_getIdentity())
+ {
+ verifier = _nullSSLPermissionsVerifier;
+ }
}
catch(const LocalException& ex)
{
- Error out(_communicator->getLogger());
- out << "permissions verifier `" + verifierPropertyValue + "' is invalid:\n" << ex;
- return 0;
+ Error out(_communicator->getLogger());
+ out << "permissions verifier `" + verifierPropertyValue + "' is invalid:\n" << ex;
+ return 0;
}
}
else
@@ -1103,28 +1103,28 @@ RegistryI::getSSLPermissionsVerifier(const IceGrid::LocatorPrx& locator, const s
Glacier2::SSLPermissionsVerifierPrx verifierPrx;
try
{
- //
- // Set the permission verifier proxy locator to the internal
- // locator. We can't use the "public" locator, this could lead
- // to deadlocks if there's not enough threads in the client
- // thread pool anymore.
- //
- verifierPrx = Glacier2::SSLPermissionsVerifierPrx::checkedCast(verifier->ice_locator(locator));
- if(!verifierPrx)
- {
- Error out(_communicator->getLogger());
- out << "permissions verifier `" + verifierProperty + "' is invalid";
- return 0;
- }
+ //
+ // Set the permission verifier proxy locator to the internal
+ // locator. We can't use the "public" locator, this could lead
+ // to deadlocks if there's not enough threads in the client
+ // thread pool anymore.
+ //
+ verifierPrx = Glacier2::SSLPermissionsVerifierPrx::checkedCast(verifier->ice_locator(locator));
+ if(!verifierPrx)
+ {
+ Error out(_communicator->getLogger());
+ out << "permissions verifier `" + verifierProperty + "' is invalid";
+ return 0;
+ }
}
catch(const LocalException& ex)
{
- if(!nowarn)
- {
- Warning out(_communicator->getLogger());
- out << "couldn't contact permissions verifier `" + verifierProperty + "':\n" << ex;
- }
- verifierPrx = Glacier2::SSLPermissionsVerifierPrx::uncheckedCast(verifier->ice_locator(locator));
+ if(!nowarn)
+ {
+ Warning out(_communicator->getLogger());
+ out << "couldn't contact permissions verifier `" + verifierProperty + "':\n" << ex;
+ }
+ verifierPrx = Glacier2::SSLPermissionsVerifierPrx::uncheckedCast(verifier->ice_locator(locator));
}
return verifierPrx;
}
@@ -1135,35 +1135,35 @@ RegistryI::getSSLInfo(const ConnectionPtr& connection, string& userDN)
Glacier2::SSLInfo sslinfo;
try
{
- IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(connection);
- sslinfo.remotePort = ntohs(info.remoteAddr.sin_port);
- sslinfo.remoteHost = IceInternal::inetAddrToString(info.remoteAddr.sin_addr);
- sslinfo.localPort = ntohs(info.localAddr.sin_port);
- sslinfo.localHost = IceInternal::inetAddrToString(info.localAddr.sin_addr);
+ IceSSL::ConnectionInfo info = IceSSL::getConnectionInfo(connection);
+ sslinfo.remotePort = ntohs(info.remoteAddr.sin_port);
+ sslinfo.remoteHost = IceInternal::inetAddrToString(info.remoteAddr.sin_addr);
+ sslinfo.localPort = ntohs(info.localAddr.sin_port);
+ sslinfo.localHost = IceInternal::inetAddrToString(info.localAddr.sin_addr);
- sslinfo.cipher = info.cipher;
+ sslinfo.cipher = info.cipher;
- if(!info.certs.empty())
- {
- sslinfo.certs.resize(info.certs.size());
- for(unsigned int i = 0; i < info.certs.size(); ++i)
- {
- sslinfo.certs[i] = info.certs[i]->encode();
- }
- userDN = info.certs[0]->getSubjectDN();
- }
+ if(!info.certs.empty())
+ {
+ sslinfo.certs.resize(info.certs.size());
+ for(unsigned int i = 0; i < info.certs.size(); ++i)
+ {
+ sslinfo.certs[i] = info.certs[i]->encode();
+ }
+ userDN = info.certs[0]->getSubjectDN();
+ }
}
catch(const IceSSL::ConnectionInvalidException&)
{
- PermissionDeniedException exc;
- exc.reason = "not ssl connection";
- throw exc;
+ PermissionDeniedException exc;
+ exc.reason = "not ssl connection";
+ throw exc;
}
catch(const IceSSL::CertificateEncodingException&)
{
- PermissionDeniedException exc;
- exc.reason = "certificate encoding exception";
- throw exc;
+ PermissionDeniedException exc;
+ exc.reason = "certificate encoding exception";
+ throw exc;
}
return sslinfo;
@@ -1171,71 +1171,71 @@ RegistryI::getSSLInfo(const ConnectionPtr& connection, string& userDN)
NodePrxSeq
RegistryI::registerReplicas(const InternalRegistryPrx& internalRegistry,
- const InternalRegistryPrxSeq& replicas,
- const NodePrxSeq& dbNodes)
+ const InternalRegistryPrxSeq& replicas,
+ const NodePrxSeq& dbNodes)
{
set<NodePrx> nodes;
nodes.insert(dbNodes.begin(), dbNodes.end());
for(InternalRegistryPrxSeq::const_iterator r = replicas.begin(); r != replicas.end(); ++r)
{
- if((*r)->ice_getIdentity() != internalRegistry->ice_getIdentity())
- {
- string replicaName;
- if(_traceLevels && _traceLevels->replica > 1)
- {
- replicaName = (*r)->ice_getIdentity().name;
- const string prefix("InternalRegistry-");
- string::size_type pos = replicaName.find(prefix);
- if(pos != string::npos)
- {
- replicaName = replicaName.substr(prefix.size());
- }
-
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "creating replica `" << replicaName << "' session";
- }
-
- try
- {
- (*r)->registerWithReplica(internalRegistry);
- NodePrxSeq nds = (*r)->getNodes();
- nodes.insert(nds.begin(), nds.end());
-
- if(_traceLevels && _traceLevels->replica > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "replica `" << replicaName << "' session created";
- }
- }
- catch(const Ice::LocalException& ex)
- {
- //
- // Clear the proxy from the database if we can't
- // contact the replica.
- //
- try
- {
- _database->removeObject((*r)->ice_getIdentity());
- }
- catch(const ObjectNotRegisteredException&)
- {
- }
-
- if(_traceLevels && _traceLevels->replica > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "replica `" << replicaName << "' session creation failed:\n" << ex;
- }
- }
- }
+ if((*r)->ice_getIdentity() != internalRegistry->ice_getIdentity())
+ {
+ string replicaName;
+ if(_traceLevels && _traceLevels->replica > 1)
+ {
+ replicaName = (*r)->ice_getIdentity().name;
+ const string prefix("InternalRegistry-");
+ string::size_type pos = replicaName.find(prefix);
+ if(pos != string::npos)
+ {
+ replicaName = replicaName.substr(prefix.size());
+ }
+
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "creating replica `" << replicaName << "' session";
+ }
+
+ try
+ {
+ (*r)->registerWithReplica(internalRegistry);
+ NodePrxSeq nds = (*r)->getNodes();
+ nodes.insert(nds.begin(), nds.end());
+
+ if(_traceLevels && _traceLevels->replica > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "replica `" << replicaName << "' session created";
+ }
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ //
+ // Clear the proxy from the database if we can't
+ // contact the replica.
+ //
+ try
+ {
+ _database->removeObject((*r)->ice_getIdentity());
+ }
+ catch(const ObjectNotRegisteredException&)
+ {
+ }
+
+ if(_traceLevels && _traceLevels->replica > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "replica `" << replicaName << "' session creation failed:\n" << ex;
+ }
+ }
+ }
}
#ifdef _RWSTD_NO_MEMBER_TEMPLATES
NodePrxSeq result;
for(set<NodePrx>::iterator p = nodes.begin(); p != nodes.end(); ++p)
{
- result.push_back(*p);
+ result.push_back(*p);
}
return result;
#else
@@ -1250,25 +1250,25 @@ RegistryI::registerNodes(const InternalRegistryPrx& internalRegistry, const Node
for(NodePrxSeq::const_iterator p = nodes.begin(); p != nodes.end(); ++p)
{
- assert((*p)->ice_getIdentity().name.find(prefix) != string::npos);
- try
- {
- _database->getNode((*p)->ice_getIdentity().name.substr(prefix.size()))->setProxy(*p);
- }
- catch(const NodeNotExistException&)
- {
- //
- // Ignore, if nothing's deployed on the node we won't need
- // to contact it for locator requests so we don't need to
- // keep its proxy.
- //
- try
- {
- _database->removeInternalObject((*p)->ice_getIdentity());
- }
- catch(const ObjectNotRegisteredException&)
- {
- }
- }
+ assert((*p)->ice_getIdentity().name.find(prefix) != string::npos);
+ try
+ {
+ _database->getNode((*p)->ice_getIdentity().name.substr(prefix.size()))->setProxy(*p);
+ }
+ catch(const NodeNotExistException&)
+ {
+ //
+ // Ignore, if nothing's deployed on the node we won't need
+ // to contact it for locator requests so we don't need to
+ // keep its proxy.
+ //
+ try
+ {
+ _database->removeInternalObject((*p)->ice_getIdentity());
+ }
+ catch(const ObjectNotRegisteredException&)
+ {
+ }
+ }
}
}
diff --git a/cpp/src/IceGrid/RegistryI.h b/cpp/src/IceGrid/RegistryI.h
index 63958bc08ee..152944dc19c 100644
--- a/cpp/src/IceGrid/RegistryI.h
+++ b/cpp/src/IceGrid/RegistryI.h
@@ -74,20 +74,20 @@ private:
Ice::LocatorRegistryPrx setupLocatorRegistry(const Ice::ObjectAdapterPtr&);
LocatorPrx setupLocator(const Ice::ObjectAdapterPtr&, const Ice::ObjectAdapterPtr&, const Ice::LocatorRegistryPrx&,
- const RegistryPrx&, const QueryPrx&);
+ const RegistryPrx&, const QueryPrx&);
QueryPrx setupQuery(const Ice::ObjectAdapterPtr&);
RegistryPrx setupRegistry(const Ice::ObjectAdapterPtr&);
InternalRegistryPrx setupInternalRegistry(const Ice::ObjectAdapterPtr&);
void setupNullPermissionsVerifier(const Ice::ObjectAdapterPtr&);
bool setupUserAccountMapper(const Ice::ObjectAdapterPtr&);
void setupClientSessionFactory(const Ice::ObjectAdapterPtr&, const Ice::ObjectAdapterPtr&, const LocatorPrx&,
- bool);
+ bool);
void setupAdminSessionFactory(const Ice::ObjectAdapterPtr&, const Ice::ObjectAdapterPtr&, const LocatorPrx&,
- bool);
+ bool);
void setupThreadPool(const Ice::PropertiesPtr&, const std::string&, int, int = 0);
Glacier2::PermissionsVerifierPrx getPermissionsVerifier(const Ice::ObjectAdapterPtr&, const LocatorPrx&,
- const std::string&, const std::string&, bool);
+ const std::string&, const std::string&, bool);
Glacier2::SSLPermissionsVerifierPrx getSSLPermissionsVerifier(const LocatorPrx&, const std::string&, bool);
Glacier2::SSLInfo getSSLInfo(const Ice::ConnectionPtr&, std::string&);
diff --git a/cpp/src/IceGrid/ReplicaCache.cpp b/cpp/src/IceGrid/ReplicaCache.cpp
index fa5102a322c..a766f46c69e 100644
--- a/cpp/src/IceGrid/ReplicaCache.cpp
+++ b/cpp/src/IceGrid/ReplicaCache.cpp
@@ -23,11 +23,11 @@ ReplicaCache::ReplicaCache(const Ice::CommunicatorPtr& communicator, const IceSt
IceStorm::TopicPrx t;
try
{
- t = topicManager->create("ReplicaObserverTopic");
+ t = topicManager->create("ReplicaObserverTopic");
}
catch(const IceStorm::TopicExists&)
{
- t = topicManager->retrieve("ReplicaObserverTopic");
+ t = topicManager->retrieve("ReplicaObserverTopic");
}
const_cast<IceStorm::TopicPrx&>(_topic) = IceStorm::TopicPrx::uncheckedCast(t->ice_collocationOptimized(true));
@@ -42,59 +42,59 @@ ReplicaCache::add(const string& name, const ReplicaSessionIPtr& session)
ReplicaEntryPtr entry;
while(entry = getImpl(name))
{
- ReplicaSessionIPtr session = entry->getSession();
- if(session->isDestroyed())
- {
- wait(); // Wait for the session to be removed.
- }
- else
- {
- //
- // Check if the replica is still reachable, if not, we
- // destroy its session.
- //
- sync.release();
- try
- {
- session->getInternalRegistry()->ice_ping();
- throw ReplicaActiveException();
- }
- catch(const Ice::LocalException&)
- {
- try
- {
- session->destroy();
- }
- catch(const Ice::LocalException&)
- {
- }
- }
- sync.acquire();
- }
+ ReplicaSessionIPtr session = entry->getSession();
+ if(session->isDestroyed())
+ {
+ wait(); // Wait for the session to be removed.
+ }
+ else
+ {
+ //
+ // Check if the replica is still reachable, if not, we
+ // destroy its session.
+ //
+ sync.release();
+ try
+ {
+ session->getInternalRegistry()->ice_ping();
+ throw ReplicaActiveException();
+ }
+ catch(const Ice::LocalException&)
+ {
+ try
+ {
+ session->destroy();
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
+ }
+ sync.acquire();
+ }
}
if(_traceLevels && _traceLevels->replica > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "replica `" << name << "' up";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "replica `" << name << "' up";
}
try
{
- _observers->replicaAdded(session->getInternalRegistry());
+ _observers->replicaAdded(session->getInternalRegistry());
}
catch(const Ice::ConnectionRefusedException&)
{
- // Expected if the replica is being shutdown.
+ // Expected if the replica is being shutdown.
}
catch(const Ice::LocalException& ex)
{
- TraceLevelsPtr traceLevels = getTraceLevels();
- if(traceLevels)
- {
- Ice::Warning out(traceLevels->logger);
- out << "unexpected exception while publishing `replicaAdded' update:\n" << ex;
- }
+ TraceLevelsPtr traceLevels = getTraceLevels();
+ if(traceLevels)
+ {
+ Ice::Warning out(traceLevels->logger);
+ out << "unexpected exception while publishing `replicaAdded' update:\n" << ex;
+ }
}
return addImpl(name, new ReplicaEntry(name, session));
@@ -112,29 +112,29 @@ ReplicaCache::remove(const string& name, bool shutdown)
if(_traceLevels && _traceLevels->replica > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "replica `" << name << "' down";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "replica `" << name << "' down";
}
if(!shutdown)
{
- try
- {
- _observers->replicaRemoved(entry->getProxy());
- }
- catch(const Ice::ConnectionRefusedException&)
- {
- // Expected if the replica is being shutdown.
- }
- catch(const Ice::LocalException& ex)
- {
- TraceLevelsPtr traceLevels = getTraceLevels();
- if(traceLevels)
- {
- Ice::Warning out(traceLevels->logger);
- out << "unexpected exception while publishing `replicaRemoved' update:\n" << ex;
- }
- }
+ try
+ {
+ _observers->replicaRemoved(entry->getProxy());
+ }
+ catch(const Ice::ConnectionRefusedException&)
+ {
+ // Expected if the replica is being shutdown.
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ TraceLevelsPtr traceLevels = getTraceLevels();
+ if(traceLevels)
+ {
+ Ice::Warning out(traceLevels->logger);
+ out << "unexpected exception while publishing `replicaRemoved' update:\n" << ex;
+ }
+ }
}
return entry;
@@ -147,9 +147,9 @@ ReplicaCache::get(const string& name) const
ReplicaEntryPtr entry = getImpl(name);
if(!entry)
{
- RegistryNotExistException ex;
- ex.name = name;
- throw ex;
+ RegistryNotExistException ex;
+ ex.name = name;
+ throw ex;
}
return entry;
}
@@ -159,30 +159,30 @@ ReplicaCache::subscribe(const ReplicaObserverPrx& observer)
{
try
{
- Lock sync(*this);
- InternalRegistryPrxSeq replicas;
- for(map<string, ReplicaEntryPtr>::const_iterator p = _entries.begin(); p != _entries.end(); ++p)
- {
- replicas.push_back(p->second->getProxy());
- }
-
- IceStorm::QoS qos;
- qos["reliability"] = "ordered";
- Ice::ObjectPrx publisher = _topic->subscribeAndGetPublisher(qos, observer->ice_twoway());
- ReplicaObserverPrx::uncheckedCast(publisher)->replicaInit(replicas);
+ Lock sync(*this);
+ InternalRegistryPrxSeq replicas;
+ for(map<string, ReplicaEntryPtr>::const_iterator p = _entries.begin(); p != _entries.end(); ++p)
+ {
+ replicas.push_back(p->second->getProxy());
+ }
+
+ IceStorm::QoS qos;
+ qos["reliability"] = "ordered";
+ Ice::ObjectPrx publisher = _topic->subscribeAndGetPublisher(qos, observer->ice_twoway());
+ ReplicaObserverPrx::uncheckedCast(publisher)->replicaInit(replicas);
}
catch(const Ice::ConnectionRefusedException&)
{
- // The replica is being shutdown.
+ // The replica is being shutdown.
}
catch(const Ice::LocalException& ex)
{
- TraceLevelsPtr traceLevels = getTraceLevels();
- if(traceLevels)
- {
- Ice::Warning out(traceLevels->logger);
- out << "unexpected exception while subscribing observer from replica observer topic:\n" << ex;
- }
+ TraceLevelsPtr traceLevels = getTraceLevels();
+ if(traceLevels)
+ {
+ Ice::Warning out(traceLevels->logger);
+ out << "unexpected exception while subscribing observer from replica observer topic:\n" << ex;
+ }
}
}
@@ -191,20 +191,20 @@ ReplicaCache::unsubscribe(const ReplicaObserverPrx& observer)
{
try
{
- _topic->unsubscribe(observer);
+ _topic->unsubscribe(observer);
}
catch(const Ice::ConnectionRefusedException&)
{
- // The replica is being shutdown.
+ // The replica is being shutdown.
}
catch(const Ice::LocalException& ex)
{
- TraceLevelsPtr traceLevels = getTraceLevels();
- if(traceLevels)
- {
- Ice::Warning out(traceLevels->logger);
- out << "unexpected exception while unsubscribing observer from replica observer topic:\n" << ex;
- }
+ TraceLevelsPtr traceLevels = getTraceLevels();
+ if(traceLevels)
+ {
+ Ice::Warning out(traceLevels->logger);
+ out << "unexpected exception while unsubscribing observer from replica observer topic:\n" << ex;
+ }
}
}
@@ -215,19 +215,19 @@ ReplicaCache::getEndpoints(const string& name, const Ice::ObjectPrx& proxy) cons
if(proxy)
{
- Ice::EndpointSeq endpts = proxy->ice_getEndpoints();
- endpoints.insert(endpoints.end(), endpts.begin(), endpts.end());
+ Ice::EndpointSeq endpts = proxy->ice_getEndpoints();
+ endpoints.insert(endpoints.end(), endpts.begin(), endpts.end());
}
Lock sync(*this);
for(map<string, ReplicaEntryPtr>::const_iterator p = _entries.begin(); p != _entries.end(); ++p)
{
- Ice::ObjectPrx prx = p->second->getSession()->getEndpoint(name);
- if(prx)
- {
- Ice::EndpointSeq endpts = prx->ice_getEndpoints();
- endpoints.insert(endpoints.end(), endpts.begin(), endpts.end());
- }
+ Ice::ObjectPrx prx = p->second->getSession()->getEndpoint(name);
+ if(prx)
+ {
+ Ice::EndpointSeq endpts = prx->ice_getEndpoints();
+ endpoints.insert(endpoints.end(), endpts.begin(), endpts.end());
+ }
}
return _communicator->stringToProxy("dummy")->ice_endpoints(endpoints);
diff --git a/cpp/src/IceGrid/ReplicaSessionI.cpp b/cpp/src/IceGrid/ReplicaSessionI.cpp
index 67c633308ff..1fb589470a2 100644
--- a/cpp/src/IceGrid/ReplicaSessionI.cpp
+++ b/cpp/src/IceGrid/ReplicaSessionI.cpp
@@ -29,10 +29,10 @@ operator==(const ObjectInfo& info, const Ice::Identity& id)
}
ReplicaSessionI::ReplicaSessionI(const DatabasePtr& database,
- const WellKnownObjectsManagerPtr& wellKnownObjects,
- const InternalReplicaInfoPtr& info,
- const InternalRegistryPrx& proxy,
- int timeout) :
+ const WellKnownObjectsManagerPtr& wellKnownObjects,
+ const InternalReplicaInfoPtr& info,
+ const InternalRegistryPrx& proxy,
+ int timeout) :
_database(database),
_wellKnownObjects(wellKnownObjects),
_traceLevels(database->getTraceLevels()),
@@ -45,27 +45,27 @@ ReplicaSessionI::ReplicaSessionI(const DatabasePtr& database,
__setNoDelete(true);
try
{
- _database->getReplicaCache().add(info->name, this);
+ _database->getReplicaCache().add(info->name, this);
- ObserverTopicPtr obsv = _database->getObserverTopic(RegistryObserverTopicName);
- RegistryObserverTopicPtr::dynamicCast(obsv)->registryUp(toRegistryInfo(_info));
+ ObserverTopicPtr obsv = _database->getObserverTopic(RegistryObserverTopicName);
+ RegistryObserverTopicPtr::dynamicCast(obsv)->registryUp(toRegistryInfo(_info));
- _proxy = ReplicaSessionPrx::uncheckedCast(_database->getInternalAdapter()->addWithUUID(this));
+ _proxy = ReplicaSessionPrx::uncheckedCast(_database->getInternalAdapter()->addWithUUID(this));
}
catch(const ReplicaActiveException&)
{
- __setNoDelete(false);
- throw;
+ __setNoDelete(false);
+ throw;
}
catch(...)
{
- ObserverTopicPtr obsv = _database->getObserverTopic(RegistryObserverTopicName);
- RegistryObserverTopicPtr::dynamicCast(obsv)->registryDown(_info->name);
+ ObserverTopicPtr obsv = _database->getObserverTopic(RegistryObserverTopicName);
+ RegistryObserverTopicPtr::dynamicCast(obsv)->registryDown(_info->name);
- _database->getReplicaCache().remove(_info->name, false);
+ _database->getReplicaCache().remove(_info->name, false);
- __setNoDelete(false);
- throw;
+ __setNoDelete(false);
+ throw;
}
__setNoDelete(false);
}
@@ -76,15 +76,15 @@ ReplicaSessionI::keepAlive(const Ice::Current& current)
Lock sync(*this);
if(_destroy)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
}
_timestamp = IceUtil::Time::now();
if(_traceLevels->replica > 2)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "replica `" << _info->name << "' keep alive ";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "replica `" << _info->name << "' keep alive ";
}
}
@@ -100,8 +100,8 @@ ReplicaSessionI::setDatabaseObserver(const DatabaseObserverPrx& observer, const
Lock sync(*this);
if(_destroy)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
- }
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ }
_observer = observer;
_database->getObserverTopic(ApplicationObserverTopicName)->subscribe(_observer, _info->name);
_database->getObserverTopic(AdapterObserverTopicName)->subscribe(_observer, _info->name);
@@ -112,12 +112,12 @@ void
ReplicaSessionI::setEndpoints(const StringObjectProxyDict& endpoints, const Ice::Current& current)
{
{
- Lock sync(*this);
- if(_destroy)
- {
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
- }
- _replicaEndpoints = endpoints;
+ Lock sync(*this);
+ if(_destroy)
+ {
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ }
+ _replicaEndpoints = endpoints;
}
_wellKnownObjects->updateReplicatedWellKnownObjects();
}
@@ -127,13 +127,13 @@ ReplicaSessionI::registerWellKnownObjects(const ObjectInfoSeq& objects, const Ic
{
int serial;
{
- Lock sync(*this);
- if(_destroy)
- {
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
- }
- _replicaWellKnownObjects = objects;
- serial = _database->addOrUpdateObjectsInDatabase(objects);
+ Lock sync(*this);
+ if(_destroy)
+ {
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ }
+ _replicaWellKnownObjects = objects;
+ serial = _database->addOrUpdateObjectsInDatabase(objects);
}
//
@@ -147,13 +147,13 @@ ReplicaSessionI::registerWellKnownObjects(const ObjectInfoSeq& objects, const Ic
void
ReplicaSessionI::setAdapterDirectProxy(const string& adapterId,
- const string& replicaGroupId,
- const Ice::ObjectPrx& proxy,
- const Ice::Current&)
+ const string& replicaGroupId,
+ const Ice::ObjectPrx& proxy,
+ const Ice::Current&)
{
if(_database->getCommunicator()->getProperties()->getPropertyAsInt("IceGrid.Registry.DynamicRegistration") <= 0)
{
- throw AdapterNotExistException();
+ throw AdapterNotExistException();
}
_database->setAdapterDirectProxy(adapterId, replicaGroupId, proxy);
}
@@ -164,7 +164,7 @@ ReplicaSessionI::receivedUpdate(TopicName topicName, int serial, const string& f
ObserverTopicPtr topic = _database->getObserverTopic(topicName);
if(topic)
{
- topic->receivedUpdate(_info->name, serial, failure);
+ topic->receivedUpdate(_info->name, serial, failure);
}
}
@@ -180,7 +180,7 @@ ReplicaSessionI::timestamp() const
Lock sync(*this);
if(_destroy)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
}
return _timestamp;
}
@@ -215,7 +215,7 @@ ReplicaSessionI::getEndpoint(const std::string& name)
Lock sync(*this);
if(_destroy)
{
- return 0;
+ return 0;
}
return _replicaEndpoints[name];
}
@@ -231,38 +231,38 @@ void
ReplicaSessionI::destroyImpl(bool shutdown)
{
{
- Lock sync(*this);
- if(_destroy)
- {
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
- }
- _destroy = true;
+ Lock sync(*this);
+ if(_destroy)
+ {
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ }
+ _destroy = true;
}
if(_observer)
{
- _database->getObserverTopic(ApplicationObserverTopicName)->unsubscribe(_observer, _info->name);
- _database->getObserverTopic(AdapterObserverTopicName)->unsubscribe(_observer, _info->name);
- _database->getObserverTopic(ObjectObserverTopicName)->unsubscribe(_observer, _info->name);
+ _database->getObserverTopic(ApplicationObserverTopicName)->unsubscribe(_observer, _info->name);
+ _database->getObserverTopic(AdapterObserverTopicName)->unsubscribe(_observer, _info->name);
+ _database->getObserverTopic(ObjectObserverTopicName)->unsubscribe(_observer, _info->name);
}
if(!_replicaWellKnownObjects.empty())
{
- if(shutdown) // Don't remove the replica proxy from the database if the registry is being shutdown.
- {
- ObjectInfoSeq::iterator p = find(_replicaWellKnownObjects.begin(), _replicaWellKnownObjects.end(),
- _internalRegistry->ice_getIdentity());
- if(p != _replicaWellKnownObjects.end())
- {
- _replicaWellKnownObjects.erase(p);
- }
- }
- _database->removeObjectsInDatabase(_replicaWellKnownObjects);
+ if(shutdown) // Don't remove the replica proxy from the database if the registry is being shutdown.
+ {
+ ObjectInfoSeq::iterator p = find(_replicaWellKnownObjects.begin(), _replicaWellKnownObjects.end(),
+ _internalRegistry->ice_getIdentity());
+ if(p != _replicaWellKnownObjects.end())
+ {
+ _replicaWellKnownObjects.erase(p);
+ }
+ }
+ _database->removeObjectsInDatabase(_replicaWellKnownObjects);
}
if(!shutdown)
{
- _wellKnownObjects->updateReplicatedWellKnownObjects(); // No need to update these if we're shutting down.
+ _wellKnownObjects->updateReplicatedWellKnownObjects(); // No need to update these if we're shutting down.
}
//
@@ -280,12 +280,12 @@ ReplicaSessionI::destroyImpl(bool shutdown)
if(!shutdown)
{
- try
- {
- _database->getInternalAdapter()->remove(_proxy->ice_getIdentity());
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- }
+ try
+ {
+ _database->getInternalAdapter()->remove(_proxy->ice_getIdentity());
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ }
}
}
diff --git a/cpp/src/IceGrid/ReplicaSessionI.h b/cpp/src/IceGrid/ReplicaSessionI.h
index 0f9e37b5e79..28701165ece 100644
--- a/cpp/src/IceGrid/ReplicaSessionI.h
+++ b/cpp/src/IceGrid/ReplicaSessionI.h
@@ -30,7 +30,7 @@ class ReplicaSessionI : public ReplicaSession, public IceUtil::Mutex
public:
ReplicaSessionI(const DatabasePtr&, const WellKnownObjectsManagerPtr&, const InternalReplicaInfoPtr&,
- const InternalRegistryPrx&, int);
+ const InternalRegistryPrx&, int);
virtual void keepAlive(const Ice::Current&);
virtual int getTimeout(const Ice::Current&) const;
@@ -38,7 +38,7 @@ public:
virtual void setEndpoints(const StringObjectProxyDict&, const Ice::Current&);
virtual void registerWellKnownObjects(const ObjectInfoSeq&, const Ice::Current&);
virtual void setAdapterDirectProxy(const std::string&, const std::string&, const Ice::ObjectPrx&,
- const Ice::Current&);
+ const Ice::Current&);
virtual void receivedUpdate(TopicName, int, const std::string&, const Ice::Current&);
virtual void destroy(const Ice::Current& = Ice::Current());
diff --git a/cpp/src/IceGrid/ReplicaSessionManager.cpp b/cpp/src/IceGrid/ReplicaSessionManager.cpp
index f241b51eb62..0dd232d5247 100644
--- a/cpp/src/IceGrid/ReplicaSessionManager.cpp
+++ b/cpp/src/IceGrid/ReplicaSessionManager.cpp
@@ -24,197 +24,197 @@ class MasterDatabaseObserverI : public DatabaseObserver, public IceUtil::Mutex
public:
MasterDatabaseObserverI(const ReplicaSessionManager::ThreadPtr& thread,
- const DatabasePtr& database,
- const ReplicaSessionPrx& session) :
- _thread(thread),
- _database(database),
- _session(session)
+ const DatabasePtr& database,
+ const ReplicaSessionPrx& session) :
+ _thread(thread),
+ _database(database),
+ _session(session)
{
}
virtual void
applicationInit(int, const ApplicationInfoSeq& applications, const Ice::Current& current)
{
- _database->syncApplications(applications);
- receivedUpdate(ApplicationObserverTopicName, getSerial(current.ctx));
+ _database->syncApplications(applications);
+ receivedUpdate(ApplicationObserverTopicName, getSerial(current.ctx));
}
virtual void
applicationAdded(int, const ApplicationInfo& application, const Ice::Current& current)
{
- string failure;
- try
- {
- _database->addApplication(application);
- }
- catch(const DeploymentException& ex)
- {
- ostringstream os;
- os << ex << ":\n" << ex.reason;
- failure = os.str();
- }
- receivedUpdate(ApplicationObserverTopicName, getSerial(current.ctx), failure);
+ string failure;
+ try
+ {
+ _database->addApplication(application);
+ }
+ catch(const DeploymentException& ex)
+ {
+ ostringstream os;
+ os << ex << ":\n" << ex.reason;
+ failure = os.str();
+ }
+ receivedUpdate(ApplicationObserverTopicName, getSerial(current.ctx), failure);
}
virtual void
applicationRemoved(int, const std::string& name, const Ice::Current& current)
{
- string failure;
- try
- {
- _database->removeApplication(name);
- }
- catch(const ApplicationNotExistException& ex)
- {
- ostringstream os;
- os << ex << ":\napplication: " << ex.name;
- failure = os.str();
- }
- receivedUpdate(ApplicationObserverTopicName, getSerial(current.ctx), failure);
+ string failure;
+ try
+ {
+ _database->removeApplication(name);
+ }
+ catch(const ApplicationNotExistException& ex)
+ {
+ ostringstream os;
+ os << ex << ":\napplication: " << ex.name;
+ failure = os.str();
+ }
+ receivedUpdate(ApplicationObserverTopicName, getSerial(current.ctx), failure);
}
virtual void
applicationUpdated(int, const ApplicationUpdateInfo& update, const Ice::Current& current)
{
- string failure;
- try
- {
- _database->updateApplication(update);
- }
- catch(const DeploymentException& ex)
- {
- ostringstream os;
- os << ex << ":\n" << ex.reason;
- failure = os.str();
- }
- catch(const ApplicationNotExistException& ex)
- {
- ostringstream os;
- os << ex << ":\napplication: " << ex.name;
- failure = os.str();
- }
- receivedUpdate(ApplicationObserverTopicName, getSerial(current.ctx), failure);
+ string failure;
+ try
+ {
+ _database->updateApplication(update);
+ }
+ catch(const DeploymentException& ex)
+ {
+ ostringstream os;
+ os << ex << ":\n" << ex.reason;
+ failure = os.str();
+ }
+ catch(const ApplicationNotExistException& ex)
+ {
+ ostringstream os;
+ os << ex << ":\napplication: " << ex.name;
+ failure = os.str();
+ }
+ receivedUpdate(ApplicationObserverTopicName, getSerial(current.ctx), failure);
}
virtual void
adapterInit(const AdapterInfoSeq& adapters, const Ice::Current& current)
{
- _database->syncAdapters(adapters);
- receivedUpdate(AdapterObserverTopicName, getSerial(current.ctx));
+ _database->syncAdapters(adapters);
+ receivedUpdate(AdapterObserverTopicName, getSerial(current.ctx));
}
virtual void
adapterAdded(const AdapterInfo& info, const Ice::Current& current)
{
- string failure;
- try
- {
- _database->setAdapterDirectProxy(info.id, info.replicaGroupId, info.proxy);
- }
- catch(const AdapterExistsException&)
- {
- failure = "adapter `" + info.id + "' already exists and belongs to an application";
- }
- receivedUpdate(AdapterObserverTopicName, getSerial(current.ctx), failure);
+ string failure;
+ try
+ {
+ _database->setAdapterDirectProxy(info.id, info.replicaGroupId, info.proxy);
+ }
+ catch(const AdapterExistsException&)
+ {
+ failure = "adapter `" + info.id + "' already exists and belongs to an application";
+ }
+ receivedUpdate(AdapterObserverTopicName, getSerial(current.ctx), failure);
}
virtual void
adapterUpdated(const AdapterInfo& info, const Ice::Current& current)
{
- string failure;
- try
- {
- _database->setAdapterDirectProxy(info.id, info.replicaGroupId, info.proxy);
- }
- catch(const AdapterExistsException&)
- {
- failure = "adapter `" + info.id + "' already exists and belongs to an application";
- }
- receivedUpdate(AdapterObserverTopicName, getSerial(current.ctx), failure);
+ string failure;
+ try
+ {
+ _database->setAdapterDirectProxy(info.id, info.replicaGroupId, info.proxy);
+ }
+ catch(const AdapterExistsException&)
+ {
+ failure = "adapter `" + info.id + "' already exists and belongs to an application";
+ }
+ receivedUpdate(AdapterObserverTopicName, getSerial(current.ctx), failure);
}
virtual void
adapterRemoved(const std::string& id, const Ice::Current& current)
{
- string failure;
- try
- {
- _database->setAdapterDirectProxy(id, "", 0);
- }
- catch(const AdapterExistsException&)
- {
- failure = "adapter `" + id + "' already exists and belongs to an application";
- }
- receivedUpdate(AdapterObserverTopicName, getSerial(current.ctx), failure);
+ string failure;
+ try
+ {
+ _database->setAdapterDirectProxy(id, "", 0);
+ }
+ catch(const AdapterExistsException&)
+ {
+ failure = "adapter `" + id + "' already exists and belongs to an application";
+ }
+ receivedUpdate(AdapterObserverTopicName, getSerial(current.ctx), failure);
}
virtual void
objectInit(const ObjectInfoSeq& objects, const Ice::Current& current)
{
- _database->syncObjects(objects);
- receivedUpdate(ObjectObserverTopicName, getSerial(current.ctx));
+ _database->syncObjects(objects);
+ receivedUpdate(ObjectObserverTopicName, getSerial(current.ctx));
}
virtual void
objectAdded(const ObjectInfo& info, const Ice::Current& current)
{
- string failure;
- try
- {
- _database->addOrUpdateObject(info);
- }
- catch(const ObjectExistsException& ex)
- {
- ostringstream os;
- os << ex << ":\n";
- os << "id: " << info.proxy->ice_getCommunicator()->identityToString(info.proxy->ice_getIdentity());
- failure = os.str();
- }
- receivedUpdate(ObjectObserverTopicName, getSerial(current.ctx), failure);
+ string failure;
+ try
+ {
+ _database->addOrUpdateObject(info);
+ }
+ catch(const ObjectExistsException& ex)
+ {
+ ostringstream os;
+ os << ex << ":\n";
+ os << "id: " << info.proxy->ice_getCommunicator()->identityToString(info.proxy->ice_getIdentity());
+ failure = os.str();
+ }
+ receivedUpdate(ObjectObserverTopicName, getSerial(current.ctx), failure);
}
virtual void
objectUpdated(const ObjectInfo& info, const Ice::Current& current)
{
- string failure;
- try
- {
- _database->addOrUpdateObject(info);
- }
- catch(const ObjectExistsException& ex)
- {
- ostringstream os;
- os << ex << ":\n";
- os << "id: " << info.proxy->ice_getCommunicator()->identityToString(info.proxy->ice_getIdentity());
- failure = os.str();
- }
- catch(const DeploymentException& ex)
- {
- ostringstream os;
- os << ex << ":\n" << ex.reason;
- failure = os.str();
- }
- receivedUpdate(ObjectObserverTopicName, getSerial(current.ctx), failure);
+ string failure;
+ try
+ {
+ _database->addOrUpdateObject(info);
+ }
+ catch(const ObjectExistsException& ex)
+ {
+ ostringstream os;
+ os << ex << ":\n";
+ os << "id: " << info.proxy->ice_getCommunicator()->identityToString(info.proxy->ice_getIdentity());
+ failure = os.str();
+ }
+ catch(const DeploymentException& ex)
+ {
+ ostringstream os;
+ os << ex << ":\n" << ex.reason;
+ failure = os.str();
+ }
+ receivedUpdate(ObjectObserverTopicName, getSerial(current.ctx), failure);
}
virtual void
objectRemoved(const Ice::Identity& id, const Ice::Current& current)
{
- string failure;
- try
- {
- _database->removeObject(id);
- }
- catch(const DeploymentException& ex)
- {
- ostringstream os;
- os << ex << ":\n" << ex.reason;
- failure = os.str();
- }
- catch(const ObjectNotRegisteredException&)
- {
- }
- receivedUpdate(ObjectObserverTopicName, getSerial(current.ctx), failure);
+ string failure;
+ try
+ {
+ _database->removeObject(id);
+ }
+ catch(const DeploymentException& ex)
+ {
+ ostringstream os;
+ os << ex << ":\n" << ex.reason;
+ failure = os.str();
+ }
+ catch(const ObjectNotRegisteredException&)
+ {
+ }
+ receivedUpdate(ObjectObserverTopicName, getSerial(current.ctx), failure);
}
private:
@@ -222,31 +222,31 @@ private:
int
getSerial(const Ice::Context& context)
{
- Ice::Context::const_iterator p = context.find("serial");
- if(p != context.end())
- {
- int serial;
- istringstream is(p->second);
- is >> serial;
- return serial;
- }
- return -1;
+ Ice::Context::const_iterator p = context.find("serial");
+ if(p != context.end())
+ {
+ int serial;
+ istringstream is(p->second);
+ is >> serial;
+ return serial;
+ }
+ return -1;
}
void
receivedUpdate(TopicName name, int serial, const string& failure = string())
{
- try
- {
- _session->receivedUpdate(name, serial, failure);
- }
- catch(const Ice::LocalException&)
- {
- }
- if(!failure.empty())
- {
- _thread->destroyActiveSession();
- }
+ try
+ {
+ _session->receivedUpdate(name, serial, failure);
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
+ if(!failure.empty())
+ {
+ _thread->destroyActiveSession();
+ }
}
const ReplicaSessionManager::ThreadPtr _thread;
@@ -263,47 +263,47 @@ ReplicaSessionManager::ReplicaSessionManager()
void
ReplicaSessionManager::create(const string& name,
- const InternalReplicaInfoPtr& info,
- const DatabasePtr& database,
- const WellKnownObjectsManagerPtr& wellKnownObjects,
- const InternalRegistryPrx& internalRegistry)
+ const InternalReplicaInfoPtr& info,
+ const DatabasePtr& database,
+ const WellKnownObjectsManagerPtr& wellKnownObjects,
+ const InternalRegistryPrx& internalRegistry)
{
Ice::CommunicatorPtr comm = database->getCommunicator();
{
- Lock sync(*this);
-
- Ice::Identity id;
- id.category = comm->getDefaultLocator()->ice_getIdentity().category;
- id.name = "InternalRegistry-Master";
-
- _master = InternalRegistryPrx::uncheckedCast(comm->stringToProxy(comm->identityToString(id)));
- _name = name;
- _info = info;
- _internalRegistry = internalRegistry;
- _database = database;
- _wellKnownObjects = wellKnownObjects;
- _traceLevels = _database->getTraceLevels();
-
- //
- // Initialize the IceGrid::Query objects. The IceGrid::Query
- // interface is used to lookup the registry proxy in case it
- // becomes unavailable. Since replicas might not always have
- // an up to date registry proxy, we need to query all the
- // replicas.
- //
- Ice::EndpointSeq endpoints = comm->getDefaultLocator()->ice_getEndpoints();
- id.name = "Query";
- QueryPrx query = QueryPrx::uncheckedCast(comm->stringToProxy(comm->identityToString(id)));
- for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
- {
- Ice::EndpointSeq singleEndpoint;
- singleEndpoint.push_back(*p);
- _queryObjects.push_back(QueryPrx::uncheckedCast(query->ice_endpoints(singleEndpoint)));
- }
-
- _thread = new Thread(*this, _master);
- _thread->start();
- notifyAll();
+ Lock sync(*this);
+
+ Ice::Identity id;
+ id.category = comm->getDefaultLocator()->ice_getIdentity().category;
+ id.name = "InternalRegistry-Master";
+
+ _master = InternalRegistryPrx::uncheckedCast(comm->stringToProxy(comm->identityToString(id)));
+ _name = name;
+ _info = info;
+ _internalRegistry = internalRegistry;
+ _database = database;
+ _wellKnownObjects = wellKnownObjects;
+ _traceLevels = _database->getTraceLevels();
+
+ //
+ // Initialize the IceGrid::Query objects. The IceGrid::Query
+ // interface is used to lookup the registry proxy in case it
+ // becomes unavailable. Since replicas might not always have
+ // an up to date registry proxy, we need to query all the
+ // replicas.
+ //
+ Ice::EndpointSeq endpoints = comm->getDefaultLocator()->ice_getEndpoints();
+ id.name = "Query";
+ QueryPrx query = QueryPrx::uncheckedCast(comm->stringToProxy(comm->identityToString(id)));
+ for(Ice::EndpointSeq::const_iterator p = endpoints.begin(); p != endpoints.end(); ++p)
+ {
+ Ice::EndpointSeq singleEndpoint;
+ singleEndpoint.push_back(*p);
+ _queryObjects.push_back(QueryPrx::uncheckedCast(query->ice_endpoints(singleEndpoint)));
+ }
+
+ _thread = new Thread(*this, _master);
+ _thread->start();
+ notifyAll();
}
_thread->tryCreateSession();
@@ -313,17 +313,17 @@ void
ReplicaSessionManager::create(const InternalRegistryPrx& replica)
{
{
- Lock sync(*this);
- while(!_master) // Wait to be initialized.
- {
- wait();
- }
+ Lock sync(*this);
+ while(!_master) // Wait to be initialized.
+ {
+ wait();
+ }
}
if(replica->ice_getIdentity() != _master->ice_getIdentity())
{
- _database->getTraceLevels()->logger->error("can only create sessions with the master replica");
- return;
+ _database->getTraceLevels()->logger->error("can only create sessions with the master replica");
+ return;
}
_thread->setRegistry(replica);
@@ -336,11 +336,11 @@ ReplicaSessionManager::getNodes(const NodePrxSeq& nodes) const
assert(_thread && _thread->getRegistry());
try
{
- return _thread->getRegistry()->getNodes();
+ return _thread->getRegistry()->getNodes();
}
catch(const Ice::LocalException&)
{
- return nodes;
+ return nodes;
}
}
@@ -348,11 +348,11 @@ void
ReplicaSessionManager::destroy()
{
{
- Lock sync(*this);
- if(!_thread)
- {
- return;
- }
+ Lock sync(*this);
+ if(!_thread)
+ {
+ return;
+ }
}
_thread->terminate();
@@ -380,14 +380,14 @@ ReplicaSessionManager::registerAllWellKnownObjects()
ReplicaSessionPrx session = _thread->getSession();
if(session)
{
- try
- {
- _wellKnownObjects->registerAll(session);
- return;
- }
- catch(const Ice::LocalException&)
- {
- }
+ try
+ {
+ _wellKnownObjects->registerAll(session);
+ return;
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
}
}
@@ -396,23 +396,23 @@ ReplicaSessionManager::keepAlive(const ReplicaSessionPrx& session)
{
try
{
- if(_traceLevels && _traceLevels->replica > 2)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "sending keep alive message to master replica";
- }
+ if(_traceLevels && _traceLevels->replica > 2)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "sending keep alive message to master replica";
+ }
- session->keepAlive();
- return true;
+ session->keepAlive();
+ return true;
}
catch(const Ice::LocalException& ex)
{
- if(_traceLevels && _traceLevels->replica > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "lost session with master replica:\n" << ex;
- }
- return false;
+ if(_traceLevels && _traceLevels->replica > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "lost session with master replica:\n" << ex;
+ }
+ return false;
}
}
@@ -423,141 +423,141 @@ ReplicaSessionManager::createSession(InternalRegistryPrx& registry, IceUtil::Tim
auto_ptr<Ice::Exception> exception;
try
{
- if(_traceLevels && _traceLevels->replica > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "trying to establish session with master replica";
- }
-
- set<InternalRegistryPrx> used;
- if(!registry->ice_getEndpoints().empty())
- {
- try
- {
- session = createSessionImpl(registry, timeout);
- }
- catch(const Ice::LocalException& ex)
- {
- exception.reset(ex.ice_clone());
- used.insert(registry);
- registry = InternalRegistryPrx::uncheckedCast(registry->ice_endpoints(Ice::EndpointSeq()));
- }
- }
-
- if(!session)
- {
- for(vector<QueryPrx>::const_iterator p = _queryObjects.begin(); p != _queryObjects.end(); ++p)
- {
- InternalRegistryPrx newRegistry;
- try
- {
- Ice::ObjectPrx obj = (*p)->findObjectById(registry->ice_getIdentity());
- newRegistry = InternalRegistryPrx::uncheckedCast(obj);
- if(newRegistry && used.find(newRegistry) == used.end())
- {
- session = createSessionImpl(newRegistry, timeout);
- registry = newRegistry;
- break;
- }
- }
- catch(const Ice::LocalException& ex)
- {
- exception.reset(ex.ice_clone());
- if(newRegistry)
- {
- used.insert(newRegistry);
- }
- }
- }
- }
+ if(_traceLevels && _traceLevels->replica > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "trying to establish session with master replica";
+ }
+
+ set<InternalRegistryPrx> used;
+ if(!registry->ice_getEndpoints().empty())
+ {
+ try
+ {
+ session = createSessionImpl(registry, timeout);
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ exception.reset(ex.ice_clone());
+ used.insert(registry);
+ registry = InternalRegistryPrx::uncheckedCast(registry->ice_endpoints(Ice::EndpointSeq()));
+ }
+ }
+
+ if(!session)
+ {
+ for(vector<QueryPrx>::const_iterator p = _queryObjects.begin(); p != _queryObjects.end(); ++p)
+ {
+ InternalRegistryPrx newRegistry;
+ try
+ {
+ Ice::ObjectPrx obj = (*p)->findObjectById(registry->ice_getIdentity());
+ newRegistry = InternalRegistryPrx::uncheckedCast(obj);
+ if(newRegistry && used.find(newRegistry) == used.end())
+ {
+ session = createSessionImpl(newRegistry, timeout);
+ registry = newRegistry;
+ break;
+ }
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ exception.reset(ex.ice_clone());
+ if(newRegistry)
+ {
+ used.insert(newRegistry);
+ }
+ }
+ }
+ }
}
catch(const ReplicaActiveException& ex)
{
- if(_traceLevels)
- {
- _traceLevels->logger->error("a replica with the same name is already registered and active");
- }
- exception.reset(ex.ice_clone());
+ if(_traceLevels)
+ {
+ _traceLevels->logger->error("a replica with the same name is already registered and active");
+ }
+ exception.reset(ex.ice_clone());
}
catch(const Ice::Exception& ex)
{
- exception.reset(ex.ice_clone());
+ exception.reset(ex.ice_clone());
}
if(session)
{
- //
- // Register all the well-known objects with the replica session.
- //
- _wellKnownObjects->registerAll(session);
+ //
+ // Register all the well-known objects with the replica session.
+ //
+ _wellKnownObjects->registerAll(session);
}
else
{
- //
- // Re-register all the well known objects with the local database.
- //
- _wellKnownObjects->registerAll();
+ //
+ // Re-register all the well known objects with the local database.
+ //
+ _wellKnownObjects->registerAll();
}
if(_traceLevels && _traceLevels->replica > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- if(session)
- {
- out << "established session with master replica";
- }
- else
- {
- out << "failed to establish session with master replica:\n";
- if(exception.get())
- {
- out << *exception.get();
- }
- else
- {
- out << "failed to get replica proxy";
- }
- }
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ if(session)
+ {
+ out << "established session with master replica";
+ }
+ else
+ {
+ out << "failed to establish session with master replica:\n";
+ if(exception.get())
+ {
+ out << *exception.get();
+ }
+ else
+ {
+ out << "failed to get replica proxy";
+ }
+ }
}
return session;
}
ReplicaSessionPrx
ReplicaSessionManager::createSessionImpl(const InternalRegistryPrx& registry, IceUtil::Time& timeout)
-{
+{
try
{
- ReplicaSessionPrx session = registry->registerReplica(_info, _internalRegistry);
- int t = session->getTimeout();
- if(t > 0)
- {
- timeout = IceUtil::Time::seconds(t / 2);
- }
-
- //
- // Create a new database observer servant and give its proxy
- // to the session so that it can subscribe it. This call only
- // returns once the observer is subscribed and initialized.
- //
- DatabaseObserverPtr servant = new MasterDatabaseObserverI(_thread, _database, session);
- _observer = DatabaseObserverPrx::uncheckedCast(_database->getInternalAdapter()->addWithUUID(servant));
- session->setDatabaseObserver(_observer);
- return session;
+ ReplicaSessionPrx session = registry->registerReplica(_info, _internalRegistry);
+ int t = session->getTimeout();
+ if(t > 0)
+ {
+ timeout = IceUtil::Time::seconds(t / 2);
+ }
+
+ //
+ // Create a new database observer servant and give its proxy
+ // to the session so that it can subscribe it. This call only
+ // returns once the observer is subscribed and initialized.
+ //
+ DatabaseObserverPtr servant = new MasterDatabaseObserverI(_thread, _database, session);
+ _observer = DatabaseObserverPrx::uncheckedCast(_database->getInternalAdapter()->addWithUUID(servant));
+ session->setDatabaseObserver(_observer);
+ return session;
}
catch(const Ice::LocalException&)
{
- if(_observer)
- {
- try
- {
- _database->getInternalAdapter()->remove(_observer->ice_getIdentity());
- }
- catch(const Ice::LocalException&)
- {
- }
- _observer = 0;
- }
- throw;
+ if(_observer)
+ {
+ try
+ {
+ _database->getInternalAdapter()->remove(_observer->ice_getIdentity());
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
+ _observer = 0;
+ }
+ throw;
}
}
@@ -566,33 +566,33 @@ ReplicaSessionManager::destroySession(const ReplicaSessionPrx& session)
{
try
{
- session->destroy();
+ session->destroy();
- if(_traceLevels && _traceLevels->replica > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "destroyed master replica session";
- }
+ if(_traceLevels && _traceLevels->replica > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "destroyed master replica session";
+ }
}
catch(const Ice::LocalException& ex)
{
- if(_traceLevels && _traceLevels->replica > 1)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
- out << "couldn't destroy master replica session:\n" << ex;
- }
+ if(_traceLevels && _traceLevels->replica > 1)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->replicaCat);
+ out << "couldn't destroy master replica session:\n" << ex;
+ }
}
if(_observer)
{
- try
- {
- _database->getInternalAdapter()->remove(_observer->ice_getIdentity());
- }
- catch(const Ice::LocalException&)
- {
- }
- _observer = 0;
+ try
+ {
+ _database->getInternalAdapter()->remove(_observer->ice_getIdentity());
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
+ _observer = 0;
}
}
diff --git a/cpp/src/IceGrid/ReplicaSessionManager.h b/cpp/src/IceGrid/ReplicaSessionManager.h
index 32658fed0bf..21a1a261710 100644
--- a/cpp/src/IceGrid/ReplicaSessionManager.h
+++ b/cpp/src/IceGrid/ReplicaSessionManager.h
@@ -37,42 +37,42 @@ public:
{
public:
- Thread(ReplicaSessionManager& manager, const InternalRegistryPrx& master) :
- SessionKeepAliveThread<ReplicaSessionPrx>(master),
- _manager(manager)
+ Thread(ReplicaSessionManager& manager, const InternalRegistryPrx& master) :
+ SessionKeepAliveThread<ReplicaSessionPrx>(master),
+ _manager(manager)
{
- }
+ }
- virtual ReplicaSessionPrx
- createSession(InternalRegistryPrx& master, IceUtil::Time& timeout)
+ virtual ReplicaSessionPrx
+ createSession(InternalRegistryPrx& master, IceUtil::Time& timeout)
{
- return _manager.createSession(master, timeout);
- }
+ return _manager.createSession(master, timeout);
+ }
- virtual void
- destroySession(const ReplicaSessionPrx& session)
+ virtual void
+ destroySession(const ReplicaSessionPrx& session)
{
- _manager.destroySession(session);
- }
+ _manager.destroySession(session);
+ }
- virtual bool
- keepAlive(const ReplicaSessionPrx& session)
+ virtual bool
+ keepAlive(const ReplicaSessionPrx& session)
{
- return _manager.keepAlive(session);
- }
+ return _manager.keepAlive(session);
+ }
- void registerAllWellKnownObjects();
+ void registerAllWellKnownObjects();
private:
-
- ReplicaSessionManager& _manager;
+
+ ReplicaSessionManager& _manager;
};
typedef IceUtil::Handle<Thread> ThreadPtr;
ReplicaSessionManager();
void create(const std::string&, const InternalReplicaInfoPtr&, const DatabasePtr&,
- const WellKnownObjectsManagerPtr&, const InternalRegistryPrx&);
+ const WellKnownObjectsManagerPtr&, const InternalRegistryPrx&);
void create(const InternalRegistryPrx&);
NodePrxSeq getNodes(const NodePrxSeq&) const;
void destroy();
diff --git a/cpp/src/IceGrid/ServerAdapterI.cpp b/cpp/src/IceGrid/ServerAdapterI.cpp
index abf97e7ed12..52a63bb3de1 100644
--- a/cpp/src/IceGrid/ServerAdapterI.cpp
+++ b/cpp/src/IceGrid/ServerAdapterI.cpp
@@ -17,10 +17,10 @@ using namespace std;
using namespace IceGrid;
ServerAdapterI::ServerAdapterI(const NodeIPtr& node,
- ServerI* server,
- const string& serverName,
- const AdapterPrx& proxy,
- const string& id) :
+ ServerI* server,
+ const string& serverName,
+ const AdapterPrx& proxy,
+ const string& id) :
_node(node),
_this(proxy),
_serverId(serverName),
@@ -37,39 +37,39 @@ void
ServerAdapterI::activate_async(const AMD_Adapter_activatePtr& cb, const Ice::Current& current)
{
{
- Lock sync(*this);
- if(_proxy)
- {
- //
- // Return the adapter direct proxy.
- //
- cb->ice_response(_proxy);
- return;
- }
- else if(_activateCB.empty())
- {
- //
- // Nothing else waits for this adapter so we must make sure that this
- // adapter if still activatable.
- //
- if(!_server->isAdapterActivatable(_id))
- {
- cb->ice_response(0);
- return;
- }
- }
-
- if(_node->getTraceLevels()->adapter > 2)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->adapterCat);
- out << "waiting for activation of server `" + _serverId + "' adapter `" << _id << "'";
- }
-
- _activateCB.push_back(cb);
- if(_activateCB.size() > 1)
- {
- return;
- }
+ Lock sync(*this);
+ if(_proxy)
+ {
+ //
+ // Return the adapter direct proxy.
+ //
+ cb->ice_response(_proxy);
+ return;
+ }
+ else if(_activateCB.empty())
+ {
+ //
+ // Nothing else waits for this adapter so we must make sure that this
+ // adapter if still activatable.
+ //
+ if(!_server->isAdapterActivatable(_id))
+ {
+ cb->ice_response(0);
+ return;
+ }
+ }
+
+ if(_node->getTraceLevels()->adapter > 2)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->adapterCat);
+ out << "waiting for activation of server `" + _serverId + "' adapter `" << _id << "'";
+ }
+
+ _activateCB.push_back(cb);
+ if(_activateCB.size() > 1)
+ {
+ return;
+ }
}
//
@@ -79,21 +79,21 @@ ServerAdapterI::activate_async(const AMD_Adapter_activatePtr& cb, const Ice::Cur
//
try
{
- _server->start(ServerI::OnDemand);
- return;
+ _server->start(ServerI::OnDemand);
+ return;
}
catch(const ServerStartException& ex)
{
- activationFailed(ex.reason);
+ activationFailed(ex.reason);
}
catch(const Ice::ObjectNotExistException&)
{
- //
- // The server associated to this adapter doesn't exist anymore. Somehow the database is
- // inconsistent if this happens. The best thing to do is to destroy the adapter.
- //
- destroy();
- activationFailed("server destroyed");
+ //
+ // The server associated to this adapter doesn't exist anymore. Somehow the database is
+ // inconsistent if this happens. The best thing to do is to destroy the adapter.
+ //
+ destroy();
+ activationFailed("server destroyed");
}
}
@@ -108,13 +108,13 @@ ServerAdapterI::getDirectProxy(const Ice::Current& current) const
//
if(_proxy)
{
- return _proxy;
+ return _proxy;
}
else
{
- AdapterNotActiveException ex;
- ex.activatable = _server->isAdapterActivatable(_id);
- throw ex;
+ AdapterNotActiveException ex;
+ ex.activatable = _server->isAdapterActivatable(_id);
+ throw ex;
}
}
@@ -129,10 +129,10 @@ ServerAdapterI::setDirectProxy(const Ice::ObjectPrx& prx, const Ice::Current&)
//
if(prx && _proxy)
{
- if(_server->getState() == Active)
- {
- throw AdapterActiveException();
- }
+ if(_server->getState() == Active)
+ {
+ throw AdapterActiveException();
+ }
}
bool updated = _proxy != prx;
@@ -140,35 +140,35 @@ ServerAdapterI::setDirectProxy(const Ice::ObjectPrx& prx, const Ice::Current&)
for(vector<AMD_Adapter_activatePtr>::const_iterator p = _activateCB.begin(); p != _activateCB.end(); ++p)
{
- (*p)->ice_response(_proxy);
+ (*p)->ice_response(_proxy);
}
_activateCB.clear();
if(updated)
{
- AdapterDynamicInfo info;
- info.id = _id;
- info.proxy = _proxy;
- _node->observerUpdateAdapter(info);
+ AdapterDynamicInfo info;
+ info.id = _id;
+ info.proxy = _proxy;
+ _node->observerUpdateAdapter(info);
}
if(_proxy)
{
- _server->adapterActivated(_id);
+ _server->adapterActivated(_id);
}
else
{
- _server->adapterDeactivated(_id);
+ _server->adapterDeactivated(_id);
}
if(_node->getTraceLevels()->adapter > 1)
{
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->adapterCat);
- out << "server `" + _serverId + "' adapter `" << _id << "' " << (_proxy ? "activated" : "deactivated");
- if(_proxy)
- {
- out << ": " << _node->getCommunicator()->proxyToString(_proxy);
- }
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->adapterCat);
+ out << "server `" + _serverId + "' adapter `" << _id << "' " << (_proxy ? "activated" : "deactivated");
+ if(_proxy)
+ {
+ out << ": " << _node->getCommunicator()->proxyToString(_proxy);
+ }
}
}
@@ -194,14 +194,14 @@ ServerAdapterI::activationFailed(const std::string& reason)
//
if(_node->getTraceLevels()->adapter > 1)
{
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->adapterCat);
- out << "server `" + _serverId + "' adapter `" << _id << "' activation failed: " << reason;
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->adapterCat);
+ out << "server `" + _serverId + "' adapter `" << _id << "' activation failed: " << reason;
}
Lock sync(*this);
for(vector<AMD_Adapter_activatePtr>::const_iterator p = _activateCB.begin(); p != _activateCB.end(); ++p)
{
- (*p)->ice_response(0);
+ (*p)->ice_response(0);
}
_activateCB.clear();
}
diff --git a/cpp/src/IceGrid/ServerCache.cpp b/cpp/src/IceGrid/ServerCache.cpp
index 36c8a917717..14030eea69b 100644
--- a/cpp/src/IceGrid/ServerCache.cpp
+++ b/cpp/src/IceGrid/ServerCache.cpp
@@ -26,45 +26,45 @@ namespace IceGrid
struct AddCommunicator : std::unary_function<CommunicatorDescriptorPtr&, void>
{
- AddCommunicator(ServerCache& serverCache, const ServerEntryPtr& entry, const string& application) :
- _serverCache(serverCache), _entry(entry), _application(application)
- {
- }
-
- void
- operator()(const CommunicatorDescriptorPtr& desc)
- {
- _serverCache.addCommunicator(desc, _entry, _application);
- }
-
- ServerCache& _serverCache;
- const ServerEntryPtr _entry;
- const string _application;
+ AddCommunicator(ServerCache& serverCache, const ServerEntryPtr& entry, const string& application) :
+ _serverCache(serverCache), _entry(entry), _application(application)
+ {
+ }
+
+ void
+ operator()(const CommunicatorDescriptorPtr& desc)
+ {
+ _serverCache.addCommunicator(desc, _entry, _application);
+ }
+
+ ServerCache& _serverCache;
+ const ServerEntryPtr _entry;
+ const string _application;
};
struct RemoveCommunicator : std::unary_function<CommunicatorDescriptorPtr&, void>
{
- RemoveCommunicator(ServerCache& serverCache, const ServerEntryPtr& entry) :
- _serverCache(serverCache), _entry(entry)
- {
- }
+ RemoveCommunicator(ServerCache& serverCache, const ServerEntryPtr& entry) :
+ _serverCache(serverCache), _entry(entry)
+ {
+ }
- void
- operator()(const CommunicatorDescriptorPtr& desc)
- {
- _serverCache.removeCommunicator(desc, _entry);
- }
+ void
+ operator()(const CommunicatorDescriptorPtr& desc)
+ {
+ _serverCache.removeCommunicator(desc, _entry);
+ }
- ServerCache& _serverCache;
- const ServerEntryPtr _entry;
+ ServerCache& _serverCache;
+ const ServerEntryPtr _entry;
};
}
ServerCache::ServerCache(const Ice::CommunicatorPtr& communicator,
- NodeCache& nodeCache,
- AdapterCache& adapterCache,
- ObjectCache& objectCache,
- AllocatableObjectCache& allocatableObjectCache) :
+ NodeCache& nodeCache,
+ AdapterCache& adapterCache,
+ ObjectCache& objectCache,
+ AllocatableObjectCache& allocatableObjectCache) :
_communicator(communicator),
_nodeCache(nodeCache),
_adapterCache(adapterCache),
@@ -81,8 +81,8 @@ ServerCache::add(const ServerInfo& info)
ServerEntryPtr entry = getImpl(info.descriptor->id);
if(!entry)
{
- entry = new ServerEntry(*this, info.descriptor->id);
- addImpl(info.descriptor->id, entry);
+ entry = new ServerEntry(*this, info.descriptor->id);
+ addImpl(info.descriptor->id, entry);
}
entry->update(info);
_nodeCache.get(info.node, true)->addServer(entry);
@@ -91,9 +91,9 @@ ServerCache::add(const ServerInfo& info)
if(_traceLevels && _traceLevels->server > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "added server `" << info.descriptor->id << "' (`" << info.uuid << "', `" << info.revision << "')";
+ out << "added server `" << info.descriptor->id << "' (`" << info.uuid << "', `" << info.revision << "')";
}
return entry;
@@ -106,9 +106,9 @@ ServerCache::get(const string& id) const
ServerEntryPtr entry = getImpl(id);
if(!entry)
{
- ServerNotExistException ex;
- ex.id = id;
- throw ex;
+ ServerNotExistException ex;
+ ex.id = id;
+ throw ex;
}
return entry;
}
@@ -134,14 +134,14 @@ ServerCache::remove(const string& id, bool destroy)
if(destroy)
{
- entry->destroy(); // This must be done after otherwise some allocatable objects
- // might allocate a destroyed server.
+ entry->destroy(); // This must be done after otherwise some allocatable objects
+ // might allocate a destroyed server.
}
if(_traceLevels && _traceLevels->server > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
- out << "removed server `" << id << "'";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->serverCat);
+ out << "removed server `" << id << "'";
}
return entry;
@@ -156,30 +156,30 @@ ServerCache::clear(const string& id)
void
ServerCache::addCommunicator(const CommunicatorDescriptorPtr& comm,
- const ServerEntryPtr& server,
- const string& application)
+ const ServerEntryPtr& server,
+ const string& application)
{
for(AdapterDescriptorSeq::const_iterator q = comm->adapters.begin() ; q != comm->adapters.end(); ++q)
{
- assert(!q->id.empty());
- _adapterCache.addServerAdapter(*q, server, application);
+ assert(!q->id.empty());
+ _adapterCache.addServerAdapter(*q, server, application);
- ObjectDescriptorSeq::const_iterator r;
- for(r = q->objects.begin(); r != q->objects.end(); ++r)
- {
- ObjectInfo info;
- info.type = r->type;
- info.proxy = _communicator->stringToProxy("\"" + _communicator->identityToString(r->id) + "\" @ " + q->id);
- _objectCache.add(info, application);
- }
+ ObjectDescriptorSeq::const_iterator r;
+ for(r = q->objects.begin(); r != q->objects.end(); ++r)
+ {
+ ObjectInfo info;
+ info.type = r->type;
+ info.proxy = _communicator->stringToProxy("\"" + _communicator->identityToString(r->id) + "\" @ " + q->id);
+ _objectCache.add(info, application);
+ }
- for(r = q->allocatables.begin(); r != q->allocatables.end(); ++r)
- {
- ObjectInfo info;
- info.type = r->type;
- info.proxy = _communicator->stringToProxy("\"" + _communicator->identityToString(r->id) + "\" @ " + q->id);
- _allocatableObjectCache.add(info, server);
- }
+ for(r = q->allocatables.begin(); r != q->allocatables.end(); ++r)
+ {
+ ObjectInfo info;
+ info.type = r->type;
+ info.proxy = _communicator->stringToProxy("\"" + _communicator->identityToString(r->id) + "\" @ " + q->id);
+ _allocatableObjectCache.add(info, server);
+ }
}
}
@@ -188,16 +188,16 @@ ServerCache::removeCommunicator(const CommunicatorDescriptorPtr& comm, const Ser
{
for(AdapterDescriptorSeq::const_iterator q = comm->adapters.begin() ; q != comm->adapters.end(); ++q)
{
- ObjectDescriptorSeq::const_iterator r;
- for(r = q->objects.begin(); r != q->objects.end(); ++r)
- {
- _objectCache.remove(r->id);
- }
- for(r = q->allocatables.begin(); r != q->allocatables.end(); ++r)
- {
- _allocatableObjectCache.remove(r->id);
- }
- _adapterCache.removeServerAdapter(q->id);
+ ObjectDescriptorSeq::const_iterator r;
+ for(r = q->objects.begin(); r != q->objects.end(); ++r)
+ {
+ _objectCache.remove(r->id);
+ }
+ for(r = q->allocatables.begin(); r != q->allocatables.end(); ++r)
+ {
+ _allocatableObjectCache.remove(r->id);
+ }
+ _adapterCache.removeServerAdapter(q->id);
}
}
@@ -224,14 +224,14 @@ ServerEntry::syncAndWait()
syncImpl();
try
{
- waitImpl();
+ waitImpl();
}
catch(const NodeUnreachableException&)
{
- //
- // The node being unreachable isn't considered as a failure to
- // synchronize the server.
- //
+ //
+ // The node being unreachable isn't considered as a failure to
+ // synchronize the server.
+ //
}
}
@@ -240,7 +240,7 @@ ServerEntry::waitNoThrow()
{
try
{
- waitImpl();
+ waitImpl();
}
catch(const Ice::Exception&)
{
@@ -253,7 +253,7 @@ ServerEntry::unsync()
Lock sync(*this);
if(_loaded.get())
{
- _load = _loaded;
+ _load = _loaded;
}
_proxy = 0;
_adapters.clear();
@@ -273,14 +273,14 @@ ServerEntry::update(const ServerInfo& info)
if(!_destroy.get())
{
- if(_loaded.get() && descriptor->node != _loaded->node)
- {
- _destroy = _loaded;
- }
- else if(_load.get() && descriptor->node != _load->node)
- {
- _destroy = _load;
- }
+ if(_loaded.get() && descriptor->node != _loaded->node)
+ {
+ _destroy = _loaded;
+ }
+ else if(_load.get() && descriptor->node != _load->node)
+ {
+ _destroy = _load;
+ }
}
_load = descriptor;
@@ -298,16 +298,16 @@ ServerEntry::destroy()
assert(_loaded.get() || _load.get());
if(!_destroy.get())
{
- if(_loaded.get())
- {
- assert(!_destroy.get());
- _destroy = _loaded;
- }
- else if(_load.get())
- {
- assert(!_destroy.get());
- _destroy = _load;
- }
+ if(_loaded.get())
+ {
+ assert(!_destroy.get());
+ _destroy = _loaded;
+ }
+ else if(_load.get())
+ {
+ assert(!_destroy.get());
+ _destroy = _load;
+ }
}
_load.reset(0);
@@ -321,30 +321,30 @@ ServerEntry::getInfo(bool resolve) const
ServerInfo info;
SessionIPtr session;
{
- Lock sync(*this);
- if(!_loaded.get() && !_load.get())
- {
- throw ServerNotExistException();
- }
- info = _loaded.get() ? *_loaded : *_load;
- session = _session;
+ Lock sync(*this);
+ if(!_loaded.get() && !_load.get())
+ {
+ throw ServerNotExistException();
+ }
+ info = _loaded.get() ? *_loaded : *_load;
+ session = _session;
}
assert(info.descriptor);
if(resolve)
{
- try
- {
- return _cache.getNodeCache().get(info.node)->getServerInfo(info, session);
- }
- catch(const DeploymentException&)
- {
- }
- catch(const NodeNotExistException&)
- {
- }
- catch(const NodeUnreachableException&)
- {
- }
+ try
+ {
+ return _cache.getNodeCache().get(info.node)->getServerInfo(info, session);
+ }
+ catch(const DeploymentException&)
+ {
+ }
+ catch(const NodeNotExistException&)
+ {
+ }
+ catch(const NodeUnreachableException&)
+ {
+ }
}
return info;
}
@@ -367,45 +367,45 @@ ServerPrx
ServerEntry::getProxy(int& activationTimeout, int& deactivationTimeout, string& node, bool upToDate)
{
{
- Lock sync(*this);
- if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine
- {
- assert(_loaded.get() || _load.get() || _destroy.get());
- activationTimeout = _activationTimeout;
- deactivationTimeout = _deactivationTimeout;
- node = _loaded.get() ? _loaded->node : (_load.get() ? _load->node : _destroy->node);
- return _proxy;
- }
+ Lock sync(*this);
+ if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine
+ {
+ assert(_loaded.get() || _load.get() || _destroy.get());
+ activationTimeout = _activationTimeout;
+ deactivationTimeout = _deactivationTimeout;
+ node = _loaded.get() ? _loaded->node : (_load.get() ? _load->node : _destroy->node);
+ return _proxy;
+ }
}
while(true)
{
- //
- // Note that we don't call syncAndWait() because we want
- // NodeUnreachableException exceptions to go through.
- //
- syncImpl();
- waitImpl();
-
- {
- Lock sync(*this);
- if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine
- {
- assert(_loaded.get() || _load.get() || _destroy.get());
- activationTimeout = _activationTimeout;
- deactivationTimeout = _deactivationTimeout;
- node = _loaded.get() ? _loaded->node : (_load.get() ? _load->node : _destroy->node);
- return _proxy;
- }
- else if(_load.get())
- {
- continue; // Retry
- }
- else
- {
- throw ServerNotExistException(_id);
- }
- }
+ //
+ // Note that we don't call syncAndWait() because we want
+ // NodeUnreachableException exceptions to go through.
+ //
+ syncImpl();
+ waitImpl();
+
+ {
+ Lock sync(*this);
+ if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine
+ {
+ assert(_loaded.get() || _load.get() || _destroy.get());
+ activationTimeout = _activationTimeout;
+ deactivationTimeout = _deactivationTimeout;
+ node = _loaded.get() ? _loaded->node : (_load.get() ? _load->node : _destroy->node);
+ return _proxy;
+ }
+ else if(_load.get())
+ {
+ continue; // Retry
+ }
+ else
+ {
+ throw ServerNotExistException(_id);
+ }
+ }
}
}
@@ -420,58 +420,58 @@ AdapterPrx
ServerEntry::getAdapter(int& activationTimeout, int& deactivationTimeout, const string& id, bool upToDate)
{
{
- Lock sync(*this);
- if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine
- {
- AdapterPrxDict::const_iterator p = _adapters.find(id);
- if(p != _adapters.end())
- {
- assert(p->second);
- activationTimeout = _activationTimeout;
- deactivationTimeout = _deactivationTimeout;
- return p->second;
- }
- else
- {
- throw AdapterNotExistException(id);
- }
- }
+ Lock sync(*this);
+ if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine
+ {
+ AdapterPrxDict::const_iterator p = _adapters.find(id);
+ if(p != _adapters.end())
+ {
+ assert(p->second);
+ activationTimeout = _activationTimeout;
+ deactivationTimeout = _deactivationTimeout;
+ return p->second;
+ }
+ else
+ {
+ throw AdapterNotExistException(id);
+ }
+ }
}
while(true)
{
- //
- // Note that we don't call syncAndWait() because we want
- // NodeUnreachableException exceptions to go through.
- //
- syncImpl();
- waitImpl();
-
- {
- Lock sync(*this);
- if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine
- {
- AdapterPrxDict::const_iterator p = _adapters.find(id);
- if(p != _adapters.end())
- {
- activationTimeout = _activationTimeout;
- deactivationTimeout = _deactivationTimeout;
- return p->second;
- }
- else
- {
- throw AdapterNotExistException(id);
- }
- }
- else if(_load.get())
- {
- continue; // Retry
- }
- else
- {
- throw AdapterNotExistException(id);
- }
- }
+ //
+ // Note that we don't call syncAndWait() because we want
+ // NodeUnreachableException exceptions to go through.
+ //
+ syncImpl();
+ waitImpl();
+
+ {
+ Lock sync(*this);
+ if(_loaded.get() || _proxy && _synchronizing && !upToDate) // Synced or if not up to date is fine
+ {
+ AdapterPrxDict::const_iterator p = _adapters.find(id);
+ if(p != _adapters.end())
+ {
+ activationTimeout = _activationTimeout;
+ deactivationTimeout = _deactivationTimeout;
+ return p->second;
+ }
+ else
+ {
+ throw AdapterNotExistException(id);
+ }
+ }
+ else if(_load.get())
+ {
+ continue; // Retry
+ }
+ else
+ {
+ throw AdapterNotExistException(id);
+ }
+ }
}
}
@@ -481,21 +481,21 @@ ServerEntry::getLoad(LoadSample sample) const
string application;
string node;
{
- Lock sync(*this);
- if(_loaded.get())
- {
- application = _loaded->application;
- node = _loaded->node;
- }
- else if(_load.get())
- {
- application = _load->application;
- node = _load->node;
- }
- else
- {
- throw ServerNotExistException();
- }
+ Lock sync(*this);
+ if(_loaded.get())
+ {
+ application = _loaded->application;
+ node = _loaded->node;
+ }
+ else if(_load.get())
+ {
+ application = _load->application;
+ node = _load->node;
+ }
+ else
+ {
+ throw ServerNotExistException();
+ }
}
float factor;
@@ -503,14 +503,14 @@ ServerEntry::getLoad(LoadSample sample) const
switch(sample)
{
case LoadSample1:
- return load.avg1 < 0.f ? 1.0f : load.avg1 * factor;
+ return load.avg1 < 0.f ? 1.0f : load.avg1 * factor;
case LoadSample5:
- return load.avg5 < 0.f ? 1.0f : load.avg5 * factor;
+ return load.avg5 < 0.f ? 1.0f : load.avg5 * factor;
case LoadSample15:
- return load.avg15 < 0.f ? 1.0f : load.avg15 * factor;
+ return load.avg15 < 0.f ? 1.0f : load.avg15 * factor;
default:
- assert(false);
- return 1.0f;
+ assert(false);
+ return 1.0f;
}
}
@@ -523,60 +523,60 @@ ServerEntry::syncImpl()
int timeout = -1;
{
- Lock sync(*this);
- if(_synchronizing)
- {
- return;
- }
-
- if(!_load.get() && !_destroy.get())
- {
- _load = _loaded; // Re-load the current server.
- }
-
- _updated = false;
- _exception.reset(0);
-
- if(_destroy.get())
- {
- destroy = *_destroy;
- timeout = _deactivationTimeout;
- }
- else if(_load.get())
- {
- load = *_load;
- session = _session;
- timeout = _deactivationTimeout; // loadServer might block to deactivate the previous server.
- }
- else
- {
- return;
- }
-
- _synchronizing = true;
+ Lock sync(*this);
+ if(_synchronizing)
+ {
+ return;
+ }
+
+ if(!_load.get() && !_destroy.get())
+ {
+ _load = _loaded; // Re-load the current server.
+ }
+
+ _updated = false;
+ _exception.reset(0);
+
+ if(_destroy.get())
+ {
+ destroy = *_destroy;
+ timeout = _deactivationTimeout;
+ }
+ else if(_load.get())
+ {
+ load = *_load;
+ session = _session;
+ timeout = _deactivationTimeout; // loadServer might block to deactivate the previous server.
+ }
+ else
+ {
+ return;
+ }
+
+ _synchronizing = true;
}
if(destroy.descriptor)
{
- try
- {
- _cache.getNodeCache().get(destroy.node)->destroyServer(this, destroy, timeout);
- }
- catch(NodeNotExistException&)
- {
- exception(NodeUnreachableException(destroy.node, "node is not active"));
- }
+ try
+ {
+ _cache.getNodeCache().get(destroy.node)->destroyServer(this, destroy, timeout);
+ }
+ catch(NodeNotExistException&)
+ {
+ exception(NodeUnreachableException(destroy.node, "node is not active"));
+ }
}
else if(load.descriptor)
{
- try
- {
- _cache.getNodeCache().get(load.node)->loadServer(this, load, session, timeout);
- }
- catch(NodeNotExistException&)
- {
- exception(NodeUnreachableException(load.node, "node is not active"));
- }
+ try
+ {
+ _cache.getNodeCache().get(load.node)->loadServer(this, load, session, timeout);
+ }
+ catch(NodeNotExistException&)
+ {
+ exception(NodeUnreachableException(load.node, "node is not active"));
+ }
}
}
@@ -586,35 +586,35 @@ ServerEntry::waitImpl()
Lock sync(*this);
while(_synchronizing)
{
- wait();
+ wait();
}
if(_exception.get())
{
- try
- {
- _exception->ice_throw();
- }
- catch(const DeploymentException&)
- {
- throw;
- }
- catch(const NodeUnreachableException&)
- {
- throw;
- }
- catch(const Ice::Exception& ex) // This shouln't happen.
- {
- ostringstream os;
- os << "unexpected exception while synchronizing server `" + _id + "':\n" << ex;
- TraceLevelsPtr traceLevels = _cache.getTraceLevels();
- if(traceLevels)
- {
- Ice::Error err(traceLevels->logger);
- err << os.str();
- }
- throw DeploymentException(os.str());
- }
+ try
+ {
+ _exception->ice_throw();
+ }
+ catch(const DeploymentException&)
+ {
+ throw;
+ }
+ catch(const NodeUnreachableException&)
+ {
+ throw;
+ }
+ catch(const Ice::Exception& ex) // This shouln't happen.
+ {
+ ostringstream os;
+ os << "unexpected exception while synchronizing server `" + _id + "':\n" << ex;
+ TraceLevelsPtr traceLevels = _cache.getTraceLevels();
+ if(traceLevels)
+ {
+ Ice::Error err(traceLevels->logger);
+ err << os.str();
+ }
+ throw DeploymentException(os.str());
+ }
}
}
@@ -627,66 +627,66 @@ ServerEntry::loadCallback(const ServerPrx& proxy, const AdapterPrxDict& adpts, i
int timeout = -1;
{
- Lock sync(*this);
- if(!_updated)
- {
- //
- // Set timeout on server and adapter proxies. Most of the
- // calls on the proxies shouldn't block for longer than the
- // node session timeout. Calls that might block for a longer
- // time should set the correct timeout before invoking on the
- // proxy (e.g.: server start/stop, adapter activate).
- //
- _loaded = _load;
- assert(_loaded.get());
- _proxy = proxy;
- _adapters = adpts;
- _activationTimeout = at;
- _deactivationTimeout = dt;
-
- assert(!_destroy.get() && !_load.get());
- _synchronizing = false;
- notifyAll();
- return;
- }
- else
- {
- _updated = false;
- if(_destroy.get())
- {
- destroy = *_destroy;
- }
- else if(_load.get())
- {
- load = *_load;
- session = _session;
- timeout = _deactivationTimeout; // loadServer might block to deactivate the previous server.
- }
- }
+ Lock sync(*this);
+ if(!_updated)
+ {
+ //
+ // Set timeout on server and adapter proxies. Most of the
+ // calls on the proxies shouldn't block for longer than the
+ // node session timeout. Calls that might block for a longer
+ // time should set the correct timeout before invoking on the
+ // proxy (e.g.: server start/stop, adapter activate).
+ //
+ _loaded = _load;
+ assert(_loaded.get());
+ _proxy = proxy;
+ _adapters = adpts;
+ _activationTimeout = at;
+ _deactivationTimeout = dt;
+
+ assert(!_destroy.get() && !_load.get());
+ _synchronizing = false;
+ notifyAll();
+ return;
+ }
+ else
+ {
+ _updated = false;
+ if(_destroy.get())
+ {
+ destroy = *_destroy;
+ }
+ else if(_load.get())
+ {
+ load = *_load;
+ session = _session;
+ timeout = _deactivationTimeout; // loadServer might block to deactivate the previous server.
+ }
+ }
}
assert(destroy.descriptor || load.descriptor);
if(destroy.descriptor)
{
- try
- {
- _cache.getNodeCache().get(destroy.node)->destroyServer(this, destroy, timeout);
- }
- catch(NodeNotExistException&)
- {
- exception(NodeUnreachableException(destroy.node, "node is not active"));
- }
+ try
+ {
+ _cache.getNodeCache().get(destroy.node)->destroyServer(this, destroy, timeout);
+ }
+ catch(NodeNotExistException&)
+ {
+ exception(NodeUnreachableException(destroy.node, "node is not active"));
+ }
}
else if(load.descriptor)
{
- try
- {
- _cache.getNodeCache().get(load.node)->loadServer(this, load, session, timeout);
- }
- catch(NodeNotExistException&)
- {
- exception(NodeUnreachableException(load.node, "node is not active"));
- }
+ try
+ {
+ _cache.getNodeCache().get(load.node)->loadServer(this, load, session, timeout);
+ }
+ catch(NodeNotExistException&)
+ {
+ exception(NodeUnreachableException(load.node, "node is not active"));
+ }
}
}
@@ -697,41 +697,41 @@ ServerEntry::destroyCallback()
SessionIPtr session;
{
- Lock sync(*this);
- _destroy.reset(0);
- _proxy = 0;
- _adapters.clear();
- _activationTimeout = -1;
- _deactivationTimeout = -1;
+ Lock sync(*this);
+ _destroy.reset(0);
+ _proxy = 0;
+ _adapters.clear();
+ _activationTimeout = -1;
+ _deactivationTimeout = -1;
- if(!_load.get())
- {
- assert(!_load.get() && !_loaded.get());
- _synchronizing = false;
- notifyAll();
- }
- else
- {
- _updated = false;
- load = *_load;
- session = _session;
- }
+ if(!_load.get())
+ {
+ assert(!_load.get() && !_loaded.get());
+ _synchronizing = false;
+ notifyAll();
+ }
+ else
+ {
+ _updated = false;
+ load = *_load;
+ session = _session;
+ }
}
if(load.descriptor)
{
- try
- {
- _cache.getNodeCache().get(load.node)->loadServer(this, load, session, -1);
- }
- catch(NodeNotExistException&)
- {
- exception(NodeUnreachableException(load.node, "node is not active"));
- }
+ try
+ {
+ _cache.getNodeCache().get(load.node)->loadServer(this, load, session, -1);
+ }
+ catch(NodeNotExistException&)
+ {
+ exception(NodeUnreachableException(load.node, "node is not active"));
+ }
}
else
{
- _cache.clear(_id);
+ _cache.clear(_id);
}
}
@@ -744,43 +744,43 @@ ServerEntry::exception(const Ice::Exception& ex)
int timeout = -1;
{
- Lock sync(*this);
- if((_destroy.get() && !_load.get()) || (!_destroy.get() && !_updated))
- {
- remove = _destroy.get();
- _destroy.reset(0);
- _exception.reset(ex.ice_clone());
- _proxy = 0;
- _adapters.clear();
- _activationTimeout = -1;
- _deactivationTimeout = -1;
- _synchronizing = false;
- notifyAll();
- }
- else
- {
- _destroy.reset(0);
- _updated = false;
- load = *_load.get();
- session = _session;
- timeout = _deactivationTimeout; // loadServer might block to deactivate the previous server.
- }
+ Lock sync(*this);
+ if((_destroy.get() && !_load.get()) || (!_destroy.get() && !_updated))
+ {
+ remove = _destroy.get();
+ _destroy.reset(0);
+ _exception.reset(ex.ice_clone());
+ _proxy = 0;
+ _adapters.clear();
+ _activationTimeout = -1;
+ _deactivationTimeout = -1;
+ _synchronizing = false;
+ notifyAll();
+ }
+ else
+ {
+ _destroy.reset(0);
+ _updated = false;
+ load = *_load.get();
+ session = _session;
+ timeout = _deactivationTimeout; // loadServer might block to deactivate the previous server.
+ }
}
if(load.descriptor)
{
- try
- {
- _cache.getNodeCache().get(load.node)->loadServer(this, load, session, timeout);
- }
- catch(NodeNotExistException&)
- {
- exception(NodeUnreachableException(load.node, "node is not active"));
- }
+ try
+ {
+ _cache.getNodeCache().get(load.node)->loadServer(this, load, session, timeout);
+ }
+ catch(NodeNotExistException&)
+ {
+ exception(NodeUnreachableException(load.node, "node is not active"));
+ }
}
else if(remove)
{
- _cache.clear(_id);
+ _cache.clear(_id);
}
}
@@ -804,14 +804,14 @@ ServerEntry::allocated(const SessionIPtr& session)
{
if(!_loaded.get() && !_load.get())
{
- return;
+ return;
}
TraceLevelsPtr traceLevels = _cache.getTraceLevels();
if(traceLevels && traceLevels->server > 1)
{
- Ice::Trace out(traceLevels->logger, traceLevels->serverCat);
- out << "server `" << _id << "' allocated by `" << session->getId() << "' (" << _count << ")";
+ Ice::Trace out(traceLevels->logger, traceLevels->serverCat);
+ out << "server `" << _id << "' allocated by `" << session->getId() << "' (" << _count << ")";
}
ServerDescriptorPtr desc = _loaded.get() ? _loaded->descriptor : _load->descriptor;
@@ -824,52 +824,52 @@ ServerEntry::allocated(const SessionIPtr& session)
//
if(desc->activation == "session")
{
- _updated = true;
- if(!_load.get())
- {
- _load = _loaded;
- }
- _session = session;
- _load->sessionId = session->getId();
+ _updated = true;
+ if(!_load.get())
+ {
+ _load = _loaded;
+ }
+ _session = session;
+ _load->sessionId = session->getId();
}
Glacier2::SessionControlPrx ctl = session->getSessionControl();
if(ctl)
{
- ServerHelperPtr helper = createHelper(desc);
- multiset<string> adapterIds;
- multiset<Ice::Identity> identities;
- helper->getIds(adapterIds, identities);
- try
- {
- //
- // SunCC won't accept the following:
- //
- // ctl->adapterIds()->add(Ice::StringSeq(adapterIds.begin(), adapterIds.end()));
- // ctl->identities()->add(Ice::IdentitySeq(identities.begin(), identities.end()));
- //
- Ice::StringSeq adapterIdSeq;
- for(multiset<string>::iterator p = adapterIds.begin(); p != adapterIds.end(); ++p)
- {
- adapterIdSeq.push_back(*p);
- }
- Ice::IdentitySeq identitySeq;
- for(multiset<Ice::Identity>::iterator q = identities.begin(); q != identities.end(); ++q)
- {
- identitySeq.push_back(*q);
- }
- ctl->adapterIds()->add(adapterIdSeq);
- ctl->identities()->add(identitySeq);
- }
- catch(const Ice::LocalException& ex)
- {
- if(traceLevels && traceLevels->server > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->serverCat);
- out << "couldn't add Glacier2 filters for server `" << _id << "' allocated by `" << session->getId();
- out << ":\n" << ex;
- }
- }
+ ServerHelperPtr helper = createHelper(desc);
+ multiset<string> adapterIds;
+ multiset<Ice::Identity> identities;
+ helper->getIds(adapterIds, identities);
+ try
+ {
+ //
+ // SunCC won't accept the following:
+ //
+ // ctl->adapterIds()->add(Ice::StringSeq(adapterIds.begin(), adapterIds.end()));
+ // ctl->identities()->add(Ice::IdentitySeq(identities.begin(), identities.end()));
+ //
+ Ice::StringSeq adapterIdSeq;
+ for(multiset<string>::iterator p = adapterIds.begin(); p != adapterIds.end(); ++p)
+ {
+ adapterIdSeq.push_back(*p);
+ }
+ Ice::IdentitySeq identitySeq;
+ for(multiset<Ice::Identity>::iterator q = identities.begin(); q != identities.end(); ++q)
+ {
+ identitySeq.push_back(*q);
+ }
+ ctl->adapterIds()->add(adapterIdSeq);
+ ctl->identities()->add(identitySeq);
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ if(traceLevels && traceLevels->server > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->serverCat);
+ out << "couldn't add Glacier2 filters for server `" << _id << "' allocated by `" << session->getId();
+ out << ":\n" << ex;
+ }
+ }
}
}
@@ -877,13 +877,13 @@ void
ServerEntry::allocatedNoSync(const SessionIPtr& session)
{
{
- Lock sync(*this);
- if(!_updated ||
- _loaded.get() && _loaded->descriptor->activation != "session" ||
- _load.get() && _load->descriptor->activation != "session")
- {
- return;
- }
+ Lock sync(*this);
+ if(!_updated ||
+ _loaded.get() && _loaded->descriptor->activation != "session" ||
+ _load.get() && _load->descriptor->activation != "session")
+ {
+ return;
+ }
}
sync();
@@ -895,7 +895,7 @@ ServerEntry::released(const SessionIPtr& session)
{
if(!_loaded.get() && !_load.get())
{
- return;
+ return;
}
ServerDescriptorPtr desc = _loaded.get() ? _loaded->descriptor : _load->descriptor;
@@ -909,13 +909,13 @@ ServerEntry::released(const SessionIPtr& session)
//
if(desc->activation == "session")
{
- _updated = true;
- if(!_load.get())
- {
- _load = _loaded;
- }
- _load->sessionId = "";
- _session = 0;
+ _updated = true;
+ if(!_load.get())
+ {
+ _load = _loaded;
+ }
+ _load->sessionId = "";
+ _session = 0;
}
TraceLevelsPtr traceLevels = _cache.getTraceLevels();
@@ -923,46 +923,46 @@ ServerEntry::released(const SessionIPtr& session)
Glacier2::SessionControlPrx ctl = session->getSessionControl();
if(ctl)
{
- ServerHelperPtr helper = createHelper(desc);
- multiset<string> adapterIds;
- multiset<Ice::Identity> identities;
- helper->getIds(adapterIds, identities);
- try
- {
- //
- // SunCC won't accept the following:
- //
- // ctl->adapterIds()->remove(Ice::StringSeq(adapterIds.begin(), adapterIds.end()));
- // ctl->identities()->remove(Ice::IdentitySeq(identities.begin(), identities.end()));
- //
- Ice::StringSeq adapterIdSeq;
- for(multiset<string>::iterator p = adapterIds.begin(); p != adapterIds.end(); ++p)
- {
- adapterIdSeq.push_back(*p);
- }
- Ice::IdentitySeq identitySeq;
- for(multiset<Ice::Identity>::iterator q = identities.begin(); q != identities.end(); ++q)
- {
- identitySeq.push_back(*q);
- }
- ctl->adapterIds()->remove(adapterIdSeq);
- ctl->identities()->remove(identitySeq);
- }
- catch(const Ice::LocalException& ex)
- {
- if(traceLevels && traceLevels->server > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->serverCat);
- out << "couldn't remove Glacier2 filters for server `" << _id << "' allocated by `";
- out << session->getId() << ":\n" << ex;
- }
- }
+ ServerHelperPtr helper = createHelper(desc);
+ multiset<string> adapterIds;
+ multiset<Ice::Identity> identities;
+ helper->getIds(adapterIds, identities);
+ try
+ {
+ //
+ // SunCC won't accept the following:
+ //
+ // ctl->adapterIds()->remove(Ice::StringSeq(adapterIds.begin(), adapterIds.end()));
+ // ctl->identities()->remove(Ice::IdentitySeq(identities.begin(), identities.end()));
+ //
+ Ice::StringSeq adapterIdSeq;
+ for(multiset<string>::iterator p = adapterIds.begin(); p != adapterIds.end(); ++p)
+ {
+ adapterIdSeq.push_back(*p);
+ }
+ Ice::IdentitySeq identitySeq;
+ for(multiset<Ice::Identity>::iterator q = identities.begin(); q != identities.end(); ++q)
+ {
+ identitySeq.push_back(*q);
+ }
+ ctl->adapterIds()->remove(adapterIdSeq);
+ ctl->identities()->remove(identitySeq);
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ if(traceLevels && traceLevels->server > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->serverCat);
+ out << "couldn't remove Glacier2 filters for server `" << _id << "' allocated by `";
+ out << session->getId() << ":\n" << ex;
+ }
+ }
}
if(traceLevels && traceLevels->server > 1)
{
- Ice::Trace out(traceLevels->logger, traceLevels->serverCat);
- out << "server `" << _id << "' released by `" << session->getId() << "' (" << _count << ")";
+ Ice::Trace out(traceLevels->logger, traceLevels->serverCat);
+ out << "server `" << _id << "' released by `" << session->getId() << "' (" << _count << ")";
}
}
@@ -970,13 +970,13 @@ void
ServerEntry::releasedNoSync(const SessionIPtr& session)
{
{
- Lock sync(*this);
- if(!_updated ||
- _loaded.get() && _loaded->descriptor->activation != "session" ||
- _load.get() && _load->descriptor->activation != "session")
- {
- return;
- }
+ Lock sync(*this);
+ if(!_updated ||
+ _loaded.get() && _loaded->descriptor->activation != "session" ||
+ _load.get() && _load->descriptor->activation != "session")
+ {
+ return;
+ }
}
sync();
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index 2d25e742b74..4142e53fe91 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -50,7 +50,7 @@ chownRecursive(const string& path, uid_t uid, gid_t gid)
DIR* d;
if((d = opendir(path.c_str())) == 0)
{
- throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
+ throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
}
struct dirent* entry;
@@ -60,16 +60,16 @@ chownRecursive(const string& path, uid_t uid, gid_t gid)
namelist = (struct dirent**)realloc((void*)namelist, (size_t)((n + 1) * sizeof(struct dirent*)));
if(namelist == 0)
{
- closedir(d);
- throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
+ closedir(d);
+ throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
}
size_t entrysize = sizeof(struct dirent) - sizeof(entry->d_name) + strlen(entry->d_name) + 1;
namelist[n] = (struct dirent*)malloc(entrysize);
if(namelist[n] == 0)
{
- closedir(d);
- throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
+ closedir(d);
+ throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
}
memcpy(namelist[n], entry, entrysize);
++n;
@@ -77,34 +77,34 @@ chownRecursive(const string& path, uid_t uid, gid_t gid)
if(closedir(d))
{
- throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
+ throw "cannot read directory `" + path + "':\n" + IcePatch2::lastError();
}
for(int i = 0; i < n; ++i)
{
- string name = namelist[i]->d_name;
- assert(!name.empty());
- free(namelist[i]);
-
- if(name != ".." && name != ".")
- {
- name = path + "/" + name;
- if(chown(name.c_str(), uid, gid) != 0)
- {
- throw "can't change permissions on `" + name + "':\n" + IcePatch2::lastError();
- }
-
- OS::structstat buf;
- if(OS::osstat(name, &buf) == -1)
- {
- throw "cannot stat `" + name + "':\n" + IcePatch2::lastError();
- }
-
- if(S_ISDIR(buf.st_mode))
- {
- chownRecursive(name, uid, gid);
- }
- }
+ string name = namelist[i]->d_name;
+ assert(!name.empty());
+ free(namelist[i]);
+
+ if(name != ".." && name != ".")
+ {
+ name = path + "/" + name;
+ if(chown(name.c_str(), uid, gid) != 0)
+ {
+ throw "can't change permissions on `" + name + "':\n" + IcePatch2::lastError();
+ }
+
+ OS::structstat buf;
+ if(OS::osstat(name, &buf) == -1)
+ {
+ throw "cannot stat `" + name + "':\n" + IcePatch2::lastError();
+ }
+
+ if(S_ISDIR(buf.st_mode))
+ {
+ chownRecursive(name, uid, gid);
+ }
+ }
}
free(namelist);
@@ -132,57 +132,57 @@ descriptorWithoutRevisionEqual(const InternalServerDescriptorPtr& lhs, const Int
lhs->envs != rhs->envs ||
lhs->logs != rhs->logs)
{
- return false;
+ return false;
}
if(!lhs->distrib && rhs->distrib || lhs->distrib && !rhs->distrib)
{
- return false;
+ return false;
}
else if(lhs->distrib && rhs->distrib)
{
- if(lhs->distrib->icepatch != rhs->distrib->icepatch ||
- lhs->distrib->directories != rhs->distrib->directories)
- {
- return false;
- }
+ if(lhs->distrib->icepatch != rhs->distrib->icepatch ||
+ lhs->distrib->directories != rhs->distrib->directories)
+ {
+ return false;
+ }
}
if(lhs->adapters.size() != rhs->adapters.size())
{
- return false;
+ return false;
}
else
{
- InternalAdapterDescriptorSeq::const_iterator q = rhs->adapters.begin();
- for(InternalAdapterDescriptorSeq::const_iterator p = lhs->adapters.begin(); p != lhs->adapters.end(); ++p, ++q)
- {
- if((*p)->id != (*q)->id || (*p)->serverLifetime != (*q)->serverLifetime)
- {
- return false;
- }
- }
+ InternalAdapterDescriptorSeq::const_iterator q = rhs->adapters.begin();
+ for(InternalAdapterDescriptorSeq::const_iterator p = lhs->adapters.begin(); p != lhs->adapters.end(); ++p, ++q)
+ {
+ if((*p)->id != (*q)->id || (*p)->serverLifetime != (*q)->serverLifetime)
+ {
+ return false;
+ }
+ }
}
if(lhs->dbEnvs.size() != rhs->dbEnvs.size())
{
- return false;
+ return false;
}
else
{
- InternalDbEnvDescriptorSeq::const_iterator q = rhs->dbEnvs.begin();
- for(InternalDbEnvDescriptorSeq::const_iterator p = lhs->dbEnvs.begin(); p != lhs->dbEnvs.end(); ++p, ++q)
- {
- if((*p)->name != (*q)->name || (*p)->properties != (*q)->properties)
- {
- return false;
- }
- }
+ InternalDbEnvDescriptorSeq::const_iterator q = rhs->dbEnvs.begin();
+ for(InternalDbEnvDescriptorSeq::const_iterator p = lhs->dbEnvs.begin(); p != lhs->dbEnvs.end(); ++p, ++q)
+ {
+ if((*p)->name != (*q)->name || (*p)->properties != (*q)->properties)
+ {
+ return false;
+ }
+ }
}
if(lhs->properties != rhs->properties)
{
- return false;
+ return false;
}
return true;
@@ -193,13 +193,13 @@ class CommandTimeoutItem : public WaitItem
public:
CommandTimeoutItem(const TimedServerCommandPtr& command) :
- WaitItem(), _command(command)
+ WaitItem(), _command(command)
{
}
virtual void expired(bool destroyed)
{
- _command->timeout(destroyed);
+ _command->timeout(destroyed);
}
private:
@@ -212,30 +212,30 @@ class DelayedStart : public WaitItem
public:
DelayedStart(const ServerIPtr& server, const TraceLevelsPtr& traceLevels) :
- _server(server),
- _traceLevels(traceLevels)
+ _server(server),
+ _traceLevels(traceLevels)
{
}
virtual void expired(bool destroyed)
{
- if(!destroyed)
- {
- try
- {
- _server->start(ServerI::Always);
- }
- catch(const ServerStartException& ex)
- {
- Ice::Error out(_traceLevels->logger);
- out << "couldn't reactivate server `" << _server->getId()
- << "' with `always' activation mode after failure:\n"
- << ex.reason;
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
- }
+ if(!destroyed)
+ {
+ try
+ {
+ _server->start(ServerI::Always);
+ }
+ catch(const ServerStartException& ex)
+ {
+ Ice::Error out(_traceLevels->logger);
+ out << "couldn't reactivate server `" << _server->getId()
+ << "' with `always' activation mode after failure:\n"
+ << ex.reason;
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
+ }
}
private:
@@ -255,13 +255,13 @@ public:
virtual void
ice_response()
{
- _server->activate();
+ _server->activate();
}
virtual void
ice_exception(const Ice::Exception&)
{
- _server->activate();
+ _server->activate();
}
private:
@@ -274,62 +274,62 @@ struct EnvironmentEval : std::unary_function<string, string>
string
operator()(const std::string& value)
{
- string::size_type assignment = value.find("=");
- if(assignment == string::npos || assignment >= value.size() - 1)
- {
- return value;
- }
+ string::size_type assignment = value.find("=");
+ if(assignment == string::npos || assignment >= value.size() - 1)
+ {
+ return value;
+ }
- string v = value.substr(assignment + 1);
- assert(v.size());
- string::size_type beg = 0;
- string::size_type end;
+ string v = value.substr(assignment + 1);
+ assert(v.size());
+ string::size_type beg = 0;
+ string::size_type end;
#ifdef _WIN32
- char buf[32767];
- while((beg = v.find("%", beg)) != string::npos && beg < v.size() - 1)
- {
- end = v.find("%", beg + 1);
- if(end == string::npos)
- {
- break;
- }
- string variable = v.substr(beg + 1, end - beg - 1);
- int ret = GetEnvironmentVariable(variable.c_str(), buf, sizeof(buf));
- string valstr = (ret > 0 && ret < sizeof(buf)) ? string(buf) : string("");
- v.replace(beg, end - beg + 1, valstr);
- beg += valstr.size();
- }
+ char buf[32767];
+ while((beg = v.find("%", beg)) != string::npos && beg < v.size() - 1)
+ {
+ end = v.find("%", beg + 1);
+ if(end == string::npos)
+ {
+ break;
+ }
+ string variable = v.substr(beg + 1, end - beg - 1);
+ int ret = GetEnvironmentVariable(variable.c_str(), buf, sizeof(buf));
+ string valstr = (ret > 0 && ret < sizeof(buf)) ? string(buf) : string("");
+ v.replace(beg, end - beg + 1, valstr);
+ beg += valstr.size();
+ }
#else
- while((beg = v.find("$", beg)) != string::npos && beg < v.size() - 1)
- {
- string variable;
- if(v[beg + 1] == '{')
- {
- end = v.find("}");
- if(end == string::npos)
- {
- break;
- }
- variable = v.substr(beg + 2, end - beg - 2);
- }
- else
- {
- end = beg + 1;
- while((isalnum(v[end]) || v[end] == '_') && end < v.size())
- {
- ++end;
- }
- variable = v.substr(beg + 1, end - beg - 1);
- --end;
- }
-
- char* val = getenv(variable.c_str());
- string valstr = val ? string(val) : "";
- v.replace(beg, end - beg + 1, valstr);
- beg += valstr.size();
- }
+ while((beg = v.find("$", beg)) != string::npos && beg < v.size() - 1)
+ {
+ string variable;
+ if(v[beg + 1] == '{')
+ {
+ end = v.find("}");
+ if(end == string::npos)
+ {
+ break;
+ }
+ variable = v.substr(beg + 2, end - beg - 2);
+ }
+ else
+ {
+ end = beg + 1;
+ while((isalnum(v[end]) || v[end] == '_') && end < v.size())
+ {
+ ++end;
+ }
+ variable = v.substr(beg + 1, end - beg - 1);
+ --end;
+ }
+
+ char* val = getenv(variable.c_str());
+ string valstr = val ? string(val) : "";
+ v.replace(beg, end - beg + 1, valstr);
+ beg += valstr.size();
+ }
#endif
- return value.substr(0, assignment) + "=" + v;
+ return value.substr(0, assignment) + "=" + v;
}
};
@@ -360,8 +360,8 @@ TimedServerCommand::stopTimer()
{
if(_timer)
{
- _waitQueue->remove(_timer);
- _timer = 0;
+ _waitQueue->remove(_timer);
+ _timer = 0;
}
}
@@ -419,7 +419,7 @@ LoadCommand::failed(const Ice::Exception& ex)
for(vector<AMD_Node_loadServerPtr>::const_iterator p = _loadCB.begin(); p != _loadCB.end(); ++p)
{
(*p)->ice_exception(ex);
- }
+ }
}
void
@@ -571,7 +571,7 @@ StartCommand::failed(const string& reason)
for(vector<AMD_Server_startPtr>::const_iterator p = _startCB.begin(); p != _startCB.end(); ++p)
{
(*p)->ice_exception(ex);
- }
+ }
_startCB.clear();
}
@@ -636,7 +636,7 @@ StopCommand::failed(const string& reason)
for(vector<AMD_Server_stopPtr>::const_iterator p = _stopCB.begin(); p != _stopCB.end(); ++p)
{
(*p)->ice_exception(ex);
- }
+ }
_stopCB.clear();
}
@@ -665,7 +665,7 @@ ServerI::ServerI(const NodeIPtr& node, const ServerPrx& proxy, const string& ser
{
assert(_node->getActivator());
const_cast<int&>(_disableOnFailure) =
- _node->getCommunicator()->getProperties()->getPropertyAsIntWithDefault("IceGrid.Node.DisableOnFailure", 0);
+ _node->getCommunicator()->getProperties()->getPropertyAsIntWithDefault("IceGrid.Node.DisableOnFailure", 0);
}
ServerI::~ServerI()
@@ -683,31 +683,31 @@ ServerI::stop_async(const AMD_Server_stopPtr& amdCB, const Ice::Current&)
{
ServerCommandPtr command;
{
- Lock sync(*this);
- checkDestroyed();
-
- if(StopCommand::isStopped(_state))
- {
- throw ServerStopException(_id, "The server is already inactive.");
- }
- else if(_state == Destroying)
- {
- throw ServerStopException(_id, "The server is being destroyed.");
- }
-
- if(!_stop)
- {
- _stop = new StopCommand(this, _node->getWaitQueue(), _deactivationTimeout);
- }
- if(amdCB)
- {
- _stop->addCallback(amdCB);
- }
- command = nextCommand();
+ Lock sync(*this);
+ checkDestroyed();
+
+ if(StopCommand::isStopped(_state))
+ {
+ throw ServerStopException(_id, "The server is already inactive.");
+ }
+ else if(_state == Destroying)
+ {
+ throw ServerStopException(_id, "The server is being destroyed.");
+ }
+
+ if(!_stop)
+ {
+ _stop = new StopCommand(this, _node->getWaitQueue(), _deactivationTimeout);
+ }
+ if(amdCB)
+ {
+ _stop->addCallback(amdCB);
+ }
+ command = nextCommand();
}
if(command)
{
- command->execute();
+ command->execute();
}
}
@@ -724,13 +724,13 @@ ServerI::writeMessage(const string& message, Ice::Int fd, const Ice::Current& cu
checkDestroyed();
if(_process != 0)
{
- try
- {
- _process->writeMessage(message, fd);
- }
- catch(const Ice::LocalException&)
- {
- }
+ try
+ {
+ _process->writeMessage(message, fd);
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
}
}
@@ -753,49 +753,49 @@ ServerI::setEnabled(bool enabled, const ::Ice::Current&)
{
bool activate = false;
{
- Lock sync(*this);
- checkDestroyed();
- assert(_desc);
-
- if(enabled && _activation == Disabled)
- {
- _failureTime = IceUtil::Time();
- _activation = toServerActivation(_desc->activation);
- activate = _state == Inactive && _activation == Always;
- }
- else if(!enabled && (_activation != Disabled || _failureTime != IceUtil::Time()))
- {
- _failureTime = IceUtil::Time();
- _activation = Disabled;
- if(_timer)
- {
- _node->getWaitQueue()->remove(_timer);
- _timer = 0;
- }
- }
- else
- {
- return; // Nothing to change!
- }
-
- _node->observerUpdateServer(getDynamicInfo());
+ Lock sync(*this);
+ checkDestroyed();
+ assert(_desc);
+
+ if(enabled && _activation == Disabled)
+ {
+ _failureTime = IceUtil::Time();
+ _activation = toServerActivation(_desc->activation);
+ activate = _state == Inactive && _activation == Always;
+ }
+ else if(!enabled && (_activation != Disabled || _failureTime != IceUtil::Time()))
+ {
+ _failureTime = IceUtil::Time();
+ _activation = Disabled;
+ if(_timer)
+ {
+ _node->getWaitQueue()->remove(_timer);
+ _timer = 0;
+ }
+ }
+ else
+ {
+ return; // Nothing to change!
+ }
+
+ _node->observerUpdateServer(getDynamicInfo());
}
if(activate)
{
- try
- {
- start(Always);
- }
- catch(const ServerStartException& ex)
- {
- Ice::Error out(_node->getTraceLevels()->logger);
- out << "couldn't reactivate server `" << _id << "' with `always' activation mode:\n"
- << ex.reason;
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
+ try
+ {
+ start(Always);
+ }
+ catch(const ServerStartException& ex)
+ {
+ Ice::Error out(_node->getTraceLevels()->logger);
+ out << "couldn't reactivate server `" << _id << "' with `always' activation mode:\n"
+ << ex.reason;
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
}
}
@@ -812,15 +812,15 @@ ServerI::setProcess_async(const AMD_Server_setProcessPtr& amdCB, const Ice::Proc
{
bool deact = false;
{
- Lock sync(*this);
- checkDestroyed();
- _process = process;
- deact = _state == DeactivatingWaitForProcess;
+ Lock sync(*this);
+ checkDestroyed();
+ _process = process;
+ deact = _state == DeactivatingWaitForProcess;
}
amdCB->ice_response();
if(deact)
{
- deactivate();
+ deactivate();
}
}
@@ -832,7 +832,7 @@ ServerI::getOffsetFromEnd(const string& filename, int count, const Ice::Current&
bool
ServerI::read(const string& filename, Ice::Long pos, int size, Ice::Long& newPos, Ice::StringSeq& lines,
- const Ice::Current&) const
+ const Ice::Current&) const
{
return _node->getFileCache()->read(getFilePath(filename), pos, size, newPos, lines);
}
@@ -843,34 +843,34 @@ ServerI::isAdapterActivatable(const string& id) const
Lock sync(*this);
if(!_desc || _activation == Disabled)
{
- return false;
+ return false;
}
if(_desc->activation == "manual" ||
_desc->activation == "session" && _desc->sessionId.empty())
{
- return false;
+ return false;
}
if(_state <= WaitForActivation)
{
- if(_activatedAdapters.find(id) != _activatedAdapters.end())
- {
- return false; // The adapter was already activated once.
- }
- return true;
+ if(_activatedAdapters.find(id) != _activatedAdapters.end())
+ {
+ return false; // The adapter was already activated once.
+ }
+ return true;
}
else if(_state < Deactivating)
{
- return false; // The server is active or its activation timed out.
+ return false; // The server is active or its activation timed out.
}
else if(_state < Destroying)
{
- return true; // The server is being deactivated.
+ return true; // The server is being deactivated.
}
else
{
- return false;
+ return false;
}
}
@@ -892,84 +892,84 @@ ServerI::start(ServerActivation activation, const AMD_Server_startPtr& amdCB)
{
ServerCommandPtr command;
{
- Lock sync(*this);
- checkDestroyed();
-
- //
- // Eventually re-enable the server if it's disabled because of a failure.
- //
- if(_disableOnFailure > 0 && _failureTime != IceUtil::Time())
- {
- if(activation == Manual ||
- (_failureTime + IceUtil::Time::seconds(_disableOnFailure) < IceUtil::Time::now()))
- {
- _activation = _previousActivation;
- _failureTime = IceUtil::Time();
- }
- }
-
- //
- // Check the current activation mode and the requested activation.
- //
- if(_activation == Disabled)
- {
- throw ServerStartException(_id, "The server is disabled.");
- }
- else if(_activation != Always && activation == Always)
- {
- assert(!amdCB);
- return; // Nothing to do.
- }
- else if(_activation == Manual && activation != Manual)
- {
- throw ServerStartException(_id, "The server activation doesn't allow this activation mode.");
- }
- else if(_activation == Session && _desc->sessionId.empty())
- {
- throw ServerStartException(_id, "The server is not owned by a session.");
- }
-
- //
- // Check the current state.
- //
- if(_state == ActivationTimeout)
- {
- throw ServerStartException(_id, "The server activation timed out.");
- }
- else if(_state == Active)
- {
- if(activation == Always)
- {
- return; // Nothing to do, it's already active (and we
- // don't want to throw because it would be
- // considered as an error.)
- }
- throw ServerStartException(_id, "The server is already active.");
- }
- else if(_state == Destroying)
- {
- throw ServerStartException(_id, "The server is being destroyed.");
- }
-
- if(_timer)
- {
- _node->getWaitQueue()->remove(_timer);
- _timer = 0;
- }
-
- if(!_start)
- {
- _start = new StartCommand(this, _node->getWaitQueue(), _activationTimeout);
- }
- if(amdCB)
- {
- _start->addCallback(amdCB);
- }
- command = nextCommand();
+ Lock sync(*this);
+ checkDestroyed();
+
+ //
+ // Eventually re-enable the server if it's disabled because of a failure.
+ //
+ if(_disableOnFailure > 0 && _failureTime != IceUtil::Time())
+ {
+ if(activation == Manual ||
+ (_failureTime + IceUtil::Time::seconds(_disableOnFailure) < IceUtil::Time::now()))
+ {
+ _activation = _previousActivation;
+ _failureTime = IceUtil::Time();
+ }
+ }
+
+ //
+ // Check the current activation mode and the requested activation.
+ //
+ if(_activation == Disabled)
+ {
+ throw ServerStartException(_id, "The server is disabled.");
+ }
+ else if(_activation != Always && activation == Always)
+ {
+ assert(!amdCB);
+ return; // Nothing to do.
+ }
+ else if(_activation == Manual && activation != Manual)
+ {
+ throw ServerStartException(_id, "The server activation doesn't allow this activation mode.");
+ }
+ else if(_activation == Session && _desc->sessionId.empty())
+ {
+ throw ServerStartException(_id, "The server is not owned by a session.");
+ }
+
+ //
+ // Check the current state.
+ //
+ if(_state == ActivationTimeout)
+ {
+ throw ServerStartException(_id, "The server activation timed out.");
+ }
+ else if(_state == Active)
+ {
+ if(activation == Always)
+ {
+ return; // Nothing to do, it's already active (and we
+ // don't want to throw because it would be
+ // considered as an error.)
+ }
+ throw ServerStartException(_id, "The server is already active.");
+ }
+ else if(_state == Destroying)
+ {
+ throw ServerStartException(_id, "The server is being destroyed.");
+ }
+
+ if(_timer)
+ {
+ _node->getWaitQueue()->remove(_timer);
+ _timer = 0;
+ }
+
+ if(!_start)
+ {
+ _start = new StartCommand(this, _node->getWaitQueue(), _activationTimeout);
+ }
+ if(amdCB)
+ {
+ _start->addCallback(amdCB);
+ }
+ command = nextCommand();
}
if(command)
{
- command->execute();
+ command->execute();
}
}
@@ -994,40 +994,40 @@ ServerI::load(const AMD_Node_loadServerPtr& amdCB, const InternalServerDescripto
(replicaName != "Master" || _desc->sessionId == desc->sessionId) &&
(_desc->uuid == desc->uuid && _desc->revision == desc->revision || descriptorWithoutRevisionEqual(_desc, desc)))
{
- if(_desc->revision != desc->revision)
- {
- updateRevision(desc->uuid, desc->revision);
- }
-
- if(amdCB)
- {
- AdapterPrxDict adapters;
- for(ServerAdapterDict::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
- {
- adapters.insert(make_pair(p->first, p->second->getProxy()));
- }
- amdCB->ice_response(_this, adapters, _activationTimeout, _deactivationTimeout);
- }
- return 0;
+ if(_desc->revision != desc->revision)
+ {
+ updateRevision(desc->uuid, desc->revision);
+ }
+
+ if(amdCB)
+ {
+ AdapterPrxDict adapters;
+ for(ServerAdapterDict::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
+ {
+ adapters.insert(make_pair(p->first, p->second->getProxy()));
+ }
+ amdCB->ice_response(_this, adapters, _activationTimeout, _deactivationTimeout);
+ }
+ return 0;
}
if(!StopCommand::isStopped(_state) && !_stop)
{
- _stop = new StopCommand(this, _node->getWaitQueue(), _deactivationTimeout);
+ _stop = new StopCommand(this, _node->getWaitQueue(), _deactivationTimeout);
}
if(!_load)
{
- _load = new LoadCommand(this);
+ _load = new LoadCommand(this);
}
_load->setUpdate(desc, _destroy);
if(_destroy && _state != Destroying)
{
- _destroy->finished();
- _destroy = 0;
+ _destroy->finished();
+ _destroy = 0;
}
if(amdCB)
{
- _load->addCallback(amdCB);
+ _load->addCallback(amdCB);
}
return nextCommand();
}
@@ -1041,21 +1041,21 @@ ServerI::destroy(const AMD_Node_destroyServerPtr& amdCB, const string& uuid, int
if(!_desc)
{
- amdCB->ice_response();
- return 0; // Server is already destroyed.
+ amdCB->ice_response();
+ return 0; // Server is already destroyed.
}
if(!StopCommand::isStopped(_state) && !_stop)
{
- _stop = new StopCommand(this, _node->getWaitQueue(), _deactivationTimeout);
+ _stop = new StopCommand(this, _node->getWaitQueue(), _deactivationTimeout);
}
if(!_destroy)
{
- _destroy = new DestroyCommand(this);
+ _destroy = new DestroyCommand(this);
}
if(amdCB)
{
- _destroy->addCallback(amdCB);
+ _destroy->addCallback(amdCB);
}
return nextCommand();
}
@@ -1065,28 +1065,28 @@ ServerI::startPatch(bool shutdown)
{
ServerCommandPtr command;
{
- Lock sync(*this);
- checkDestroyed();
- if(!StopCommand::isStopped(_state))
- {
- if(!shutdown)
- {
- return false;
- }
- else if(!_stop)
- {
- _stop = new StopCommand(this, _node->getWaitQueue(), _deactivationTimeout);
- }
- }
- if(!_patch)
- {
- _patch = new PatchCommand(this);
- }
- command = nextCommand();
+ Lock sync(*this);
+ checkDestroyed();
+ if(!StopCommand::isStopped(_state))
+ {
+ if(!shutdown)
+ {
+ return false;
+ }
+ else if(!_stop)
+ {
+ _stop = new StopCommand(this, _node->getWaitQueue(), _deactivationTimeout);
+ }
+ }
+ if(!_patch)
+ {
+ _patch = new PatchCommand(this);
+ }
+ command = nextCommand();
}
if(command)
{
- command->execute();
+ command->execute();
}
return true;
}
@@ -1096,12 +1096,12 @@ ServerI::waitForPatch()
{
PatchCommandPtr patch;
{
- Lock sync(*this);
- if(!_patch)
- {
- return true;
- }
- patch = _patch;
+ Lock sync(*this);
+ if(!_patch)
+ {
+ return true;
+ }
+ patch = _patch;
}
return patch->waitForPatch();
}
@@ -1111,16 +1111,16 @@ ServerI::finishPatch()
{
#ifndef _WIN32
{
- Lock sync(*this);
- try
- {
- chownRecursive(_serverDir + "/distrib", _uid, _gid);
- }
- catch(const string& msg)
- {
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << msg;
- }
+ Lock sync(*this);
+ try
+ {
+ chownRecursive(_serverDir + "/distrib", _uid, _gid);
+ }
+ catch(const string& msg)
+ {
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << msg;
+ }
}
#endif
setState(Inactive);
@@ -1131,20 +1131,20 @@ ServerI::adapterActivated(const string& id)
{
ServerCommandPtr command;
{
- Lock sync(*this);
- if(_state != ServerI::Activating &&
- _state != ServerI::WaitForActivation &&
- _state != ServerI::ActivationTimeout)
- {
- return;
- }
- _activatedAdapters.insert(id);
- checkActivation();
- command = nextCommand();
+ Lock sync(*this);
+ if(_state != ServerI::Activating &&
+ _state != ServerI::WaitForActivation &&
+ _state != ServerI::ActivationTimeout)
+ {
+ return;
+ }
+ _activatedAdapters.insert(id);
+ checkActivation();
+ command = nextCommand();
}
if(command)
{
- command->execute();
+ command->execute();
}
}
@@ -1153,16 +1153,16 @@ ServerI::adapterDeactivated(const string& id)
{
ServerCommandPtr command;
{
- Lock sync(*this);
- if(_state == Active && _serverLifetimeAdapters.find(id) != _serverLifetimeAdapters.end())
- {
- setStateNoSync(Deactivating);
- }
- command = nextCommand();
+ Lock sync(*this);
+ if(_state == Active && _serverLifetimeAdapters.find(id) != _serverLifetimeAdapters.end())
+ {
+ setStateNoSync(Deactivating);
+ }
+ command = nextCommand();
}
if(command)
{
- command->execute();
+ command->execute();
}
}
@@ -1171,9 +1171,9 @@ ServerI::checkDestroyed() const
{
if(_state == Destroyed)
{
- Ice::ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = _this->ice_getIdentity();
- throw ex;
+ Ice::ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = _this->ice_getIdentity();
+ throw ex;
}
}
@@ -1185,7 +1185,7 @@ ServerI::disableOnFailure()
//
if(_activation == Disabled)
{
- return;
+ return;
}
//
@@ -1195,9 +1195,9 @@ ServerI::disableOnFailure()
//
if(_disableOnFailure != 0 || _activation == Always && (_state == Activating || _state == WaitForActivation))
{
- _previousActivation = _activation;
- _activation = Disabled;
- _failureTime = IceUtil::Time::now();
+ _previousActivation = _activation;
+ _activation = Disabled;
+ _failureTime = IceUtil::Time::now();
}
}
@@ -1206,20 +1206,20 @@ ServerI::enableAfterFailure(bool force)
{
if(_disableOnFailure == 0 || _failureTime == IceUtil::Time())
{
- return;
+ return;
}
if(force ||
_disableOnFailure > 0 && (_failureTime + IceUtil::Time::seconds(_disableOnFailure) < IceUtil::Time::now()))
{
- _activation = _previousActivation;
- _failureTime = IceUtil::Time();
+ _activation = _previousActivation;
+ _failureTime = IceUtil::Time();
}
if(_timer)
{
- _node->getWaitQueue()->remove(_timer);
- _timer = 0;
+ _node->getWaitQueue()->remove(_timer);
+ _timer = 0;
}
}
@@ -1229,51 +1229,51 @@ ServerI::activationFailed(bool destroyed)
ServerCommandPtr command;
ServerAdapterDict adapters;
{
- Lock sync(*this);
- if(_state != ServerI::WaitForActivation)
- {
- return;
- }
-
- if(!destroyed)
- {
- setStateNoSync(ServerI::ActivationTimeout, "The server activation timed out.");
- }
- else
- {
- setStateNoSync(ServerI::ActivationTimeout, "The node is being shutdown.");
- }
-
- if(_node->getTraceLevels()->server > 1)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- if(!destroyed)
- {
- out << "server `" << _id << "' activation timed out";
- }
- else
- {
- out << "server `" << _id << "' activation failed";
- }
- }
- adapters = _adapters;
- command = nextCommand();
+ Lock sync(*this);
+ if(_state != ServerI::WaitForActivation)
+ {
+ return;
+ }
+
+ if(!destroyed)
+ {
+ setStateNoSync(ServerI::ActivationTimeout, "The server activation timed out.");
+ }
+ else
+ {
+ setStateNoSync(ServerI::ActivationTimeout, "The node is being shutdown.");
+ }
+
+ if(_node->getTraceLevels()->server > 1)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ if(!destroyed)
+ {
+ out << "server `" << _id << "' activation timed out";
+ }
+ else
+ {
+ out << "server `" << _id << "' activation failed";
+ }
+ }
+ adapters = _adapters;
+ command = nextCommand();
}
for(ServerAdapterDict::const_iterator p = adapters.begin(); p != adapters.end(); ++p)
{
- try
- {
- p->second->activationFailed(destroyed ? "server destroyed" : "server activation timed out");
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
+ try
+ {
+ p->second->activationFailed(destroyed ? "server destroyed" : "server activation timed out");
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
}
if(command)
{
- command->execute();
+ command->execute();
}
}
@@ -1289,25 +1289,25 @@ ServerI::activate()
gid_t gid;
#endif
{
- Lock sync(*this);
- assert(_state == Activating && _desc);
- desc = _desc;
- adpts = _adapters;
-
- //
- // The first time the server is started, we ensure that the
- // replication of its descriptor is completed. This is to make
- // sure all the replicas are up to date when the server
- // starts for the first time with a given descriptor.
- //
- waitForReplication = _waitForReplication;
- _waitForReplication = false;
-
- _process = 0;
-
+ Lock sync(*this);
+ assert(_state == Activating && _desc);
+ desc = _desc;
+ adpts = _adapters;
+
+ //
+ // The first time the server is started, we ensure that the
+ // replication of its descriptor is completed. This is to make
+ // sure all the replicas are up to date when the server
+ // starts for the first time with a given descriptor.
+ //
+ waitForReplication = _waitForReplication;
+ _waitForReplication = false;
+
+ _process = 0;
+
#ifndef _WIN32
- uid = _uid;
- gid = _gid;
+ uid = _uid;
+ gid = _gid;
#endif
}
@@ -1318,13 +1318,13 @@ ServerI::activate()
//
if(waitForReplication)
{
- NodeSessionPrx session = _node->getMasterNodeSession();
- if(session)
- {
- AMI_NodeSession_waitForApplicationUpdatePtr cb = new WaitForApplicationUpdateCB(this);
- _node->getMasterNodeSession()->waitForApplicationUpdate_async(cb, desc->uuid, desc->revision);
- return;
- }
+ NodeSessionPrx session = _node->getMasterNodeSession();
+ if(session)
+ {
+ AMI_NodeSession_waitForApplicationUpdatePtr cb = new WaitForApplicationUpdateCB(this);
+ _node->getMasterNodeSession()->waitForApplicationUpdate_async(cb, desc->uuid, desc->revision);
+ return;
+ }
}
//
@@ -1343,69 +1343,69 @@ ServerI::activate()
//
for(ServerAdapterDict::iterator p = adpts.begin(); p != adpts.end(); ++p)
{
- try
- {
- p->second->clear();
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
+ try
+ {
+ p->second->clear();
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
}
string failure;
try
{
#ifndef _WIN32
- int pid = _node->getActivator()->activate(desc->id, desc->exe, desc->pwd, uid, gid, options, envs, this);
+ int pid = _node->getActivator()->activate(desc->id, desc->exe, desc->pwd, uid, gid, options, envs, this);
#else
- int pid = _node->getActivator()->activate(desc->id, desc->exe, desc->pwd, options, envs, this);
+ int pid = _node->getActivator()->activate(desc->id, desc->exe, desc->pwd, options, envs, this);
#endif
- ServerCommandPtr command;
- {
- Lock sync(*this);
- assert(_state == Activating);
- _pid = pid;
- setStateNoSync(ServerI::WaitForActivation);
- checkActivation();
- command = nextCommand();
- notifyAll(); // Terminated might be waiting for the state change.
- }
- if(command)
- {
- command->execute();
- }
- return;
+ ServerCommandPtr command;
+ {
+ Lock sync(*this);
+ assert(_state == Activating);
+ _pid = pid;
+ setStateNoSync(ServerI::WaitForActivation);
+ checkActivation();
+ command = nextCommand();
+ notifyAll(); // Terminated might be waiting for the state change.
+ }
+ if(command)
+ {
+ command->execute();
+ }
+ return;
}
catch(const std::string& ex)
{
- failure = ex;
+ failure = ex;
}
catch(const Ice::SyscallException& ex)
{
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "activation failed for server `" << _id << "':\n";
- out << ex;
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "activation failed for server `" << _id << "':\n";
+ out << ex;
- ostringstream os;
- os << ex;
- failure = os.str();
+ ostringstream os;
+ os << ex;
+ failure = os.str();
}
{
- Lock sync(*this);
- disableOnFailure();
- setStateNoSync(ServerI::Deactivating, failure);
+ Lock sync(*this);
+ disableOnFailure();
+ setStateNoSync(ServerI::Deactivating, failure);
}
for(ServerAdapterDict::iterator r = adpts.begin(); r != adpts.end(); ++r)
{
- try
- {
- r->second->activationFailed(failure);
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
+ try
+ {
+ r->second->activationFailed(failure);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
}
setState(ServerI::Inactive);
@@ -1415,23 +1415,23 @@ void
ServerI::kill()
{
{
- Lock sync(*this);
- if(_state != Destroying && _state != Deactivating && _state != DeactivatingWaitForProcess)
- {
- return;
- }
+ Lock sync(*this);
+ if(_state != Destroying && _state != Deactivating && _state != DeactivatingWaitForProcess)
+ {
+ return;
+ }
}
try
{
- _node->getActivator()->kill(_id);
+ _node->getActivator()->kill(_id);
}
catch(const Ice::SyscallException& ex)
{
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "deactivation failed for server `" << _id << "':\n";
- out << ex;
- setState(ServerI::Inactive); // TODO: Is this really correct?
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "deactivation failed for server `" << _id << "':\n";
+ out << ex;
+ setState(ServerI::Inactive); // TODO: Is this really correct?
}
}
@@ -1440,55 +1440,55 @@ ServerI::deactivate()
{
Ice::ProcessPrx process;
{
- Lock sync(*this);
- assert(_desc);
- if(_state != Deactivating && _state != DeactivatingWaitForProcess)
- {
- return;
- }
-
- //
- // If a process object is supposed to be registered and it's
- // not set yet, we wait for the server to set this process
- // object before attempting to deactivate the server again.
- //
- if(_desc->processRegistered && !_process)
- {
- setStateNoSync(ServerI::DeactivatingWaitForProcess);
- return;
- }
- process = _process;
+ Lock sync(*this);
+ assert(_desc);
+ if(_state != Deactivating && _state != DeactivatingWaitForProcess)
+ {
+ return;
+ }
+
+ //
+ // If a process object is supposed to be registered and it's
+ // not set yet, we wait for the server to set this process
+ // object before attempting to deactivate the server again.
+ //
+ if(_desc->processRegistered && !_process)
+ {
+ setStateNoSync(ServerI::DeactivatingWaitForProcess);
+ return;
+ }
+ process = _process;
}
try
{
- //
- // Deactivate the server and for the termination of the server.
- //
- _node->getActivator()->deactivate(_id, process);
- return;
+ //
+ // Deactivate the server and for the termination of the server.
+ //
+ _node->getActivator()->deactivate(_id, process);
+ return;
}
catch(const Ice::Exception& ex)
{
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "graceful server shutdown failed, killing server `" << _id << "':\n";
- out << ex;
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "graceful server shutdown failed, killing server `" << _id << "':\n";
+ out << ex;
}
try
{
- //
- // If we couldn't deactivate it we kill it.
- //
- _node->getActivator()->kill(_id);
- return;
+ //
+ // If we couldn't deactivate it we kill it.
+ //
+ _node->getActivator()->kill(_id);
+ return;
}
catch(const Ice::SyscallException& ex)
{
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "deactivation failed for server `" << _id << "':\n";
- out << ex;
- setState(ServerI::Inactive); // TODO: Is this really correct?
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "deactivation failed for server `" << _id << "':\n";
+ out << ex;
+ setState(ServerI::Inactive); // TODO: Is this really correct?
}
}
@@ -1497,25 +1497,25 @@ ServerI::destroy()
{
ServerAdapterDict adpts;
{
- Lock sync(*this);
- assert(_desc);
- assert(_state == Destroying);
- adpts = _adapters;
+ Lock sync(*this);
+ assert(_desc);
+ assert(_state == Destroying);
+ adpts = _adapters;
}
_node->removeServer(this, _desc->application, _desc->applicationDistrib);
try
{
- IcePatch2::removeRecursive(_serverDir);
+ IcePatch2::removeRecursive(_serverDir);
}
catch(const string& msg)
{
- if(!_destroy->loadFailure())
- {
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "removing server directory `" << _serverDir << "' failed: " << msg;
- }
+ if(!_destroy->loadFailure())
+ {
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "removing server directory `" << _serverDir << "' failed: " << msg;
+ }
}
//
@@ -1523,13 +1523,13 @@ ServerI::destroy()
//
for(ServerAdapterDict::const_iterator p = adpts.begin(); p != adpts.end(); ++p)
{
- try
- {
- p->second->destroy();
- }
- catch(const Ice::LocalException&)
- {
- }
+ try
+ {
+ p->second->destroy();
+ }
+ catch(const Ice::LocalException&)
+ {
+ }
}
setState(Destroyed);
@@ -1540,53 +1540,53 @@ ServerI::terminated(const string& msg, int status)
{
ServerAdapterDict adpts;
{
- Lock sync(*this);
- while(_state == ServerI::Activating)
- {
- wait(); // Wait for activate() to set the state to WaitForActivation
- }
+ Lock sync(*this);
+ while(_state == ServerI::Activating)
+ {
+ wait(); // Wait for activate() to set the state to WaitForActivation
+ }
- adpts = _adapters;
- _activatedAdapters.clear();
- _pid = 0;
+ adpts = _adapters;
+ _activatedAdapters.clear();
+ _pid = 0;
- bool failed = false;
+ bool failed = false;
#ifndef _WIN32
- failed = WIFEXITED(status) && WEXITSTATUS(status) != 0;
- if(WIFSIGNALED(status))
- {
- int s = WTERMSIG(status);
- failed = s == SIGABRT || s == SIGILL || s == SIGBUS || s == SIGFPE || s == SIGSEGV;
- }
+ failed = WIFEXITED(status) && WEXITSTATUS(status) != 0;
+ if(WIFSIGNALED(status))
+ {
+ int s = WTERMSIG(status);
+ failed = s == SIGABRT || s == SIGILL || s == SIGBUS || s == SIGFPE || s == SIGSEGV;
+ }
#else
- failed = status != 0;
+ failed = status != 0;
#endif
- if(failed)
- {
- disableOnFailure();
- }
-
- if(_state != ServerI::Deactivating &&
- _state != ServerI::DeactivatingWaitForProcess &&
- _state != ServerI::Destroying)
- {
- ostringstream os;
- os << "The server terminated unexpectedly";
+ if(failed)
+ {
+ disableOnFailure();
+ }
+
+ if(_state != ServerI::Deactivating &&
+ _state != ServerI::DeactivatingWaitForProcess &&
+ _state != ServerI::Destroying)
+ {
+ ostringstream os;
+ os << "The server terminated unexpectedly";
#ifndef _WIN32
- if(WIFEXITED(status))
- {
- os << " with exit code " << WEXITSTATUS(status);
- }
- else if(WIFSIGNALED(status))
- {
- os << " with signal " << signalToString(WTERMSIG(status));
- }
+ if(WIFEXITED(status))
+ {
+ os << " with exit code " << WEXITSTATUS(status);
+ }
+ else if(WIFSIGNALED(status))
+ {
+ os << " with signal " << signalToString(WTERMSIG(status));
+ }
#else
- os << " with exit code " << status;
+ os << " with exit code " << status;
#endif
- os << (msg.empty() ? string(".") : ":\n" + msg);
- setStateNoSync(ServerI::Deactivating, os.str());
- }
+ os << (msg.empty() ? string(".") : ":\n" + msg);
+ setStateNoSync(ServerI::Deactivating, os.str());
+ }
}
//
@@ -1596,36 +1596,36 @@ ServerI::terminated(const string& msg, int status)
//
for(ServerAdapterDict::iterator p = adpts.begin(); p != adpts.end(); ++p)
{
- try
- {
- p->second->setDirectProxy(0);
- }
- catch(const Ice::ObjectNotExistException&)
- {
- }
+ try
+ {
+ p->second->setDirectProxy(0);
+ }
+ catch(const Ice::ObjectNotExistException&)
+ {
+ }
}
bool doDestroy = false;
ServerCommandPtr command;
{
- Lock sync(*this);
- if(_state == ServerI::Destroying)
- {
- doDestroy = true;
- }
- else
- {
- setStateNoSync(ServerI::Inactive);
- command = nextCommand();
- }
+ Lock sync(*this);
+ if(_state == ServerI::Destroying)
+ {
+ doDestroy = true;
+ }
+ else
+ {
+ setStateNoSync(ServerI::Inactive);
+ command = nextCommand();
+ }
}
if(doDestroy)
{
- destroy();
+ destroy();
}
else if(command)
{
- command->execute();
+ command->execute();
}
}
@@ -1634,104 +1634,104 @@ ServerI::update()
{
ServerCommandPtr command;
{
- Lock sync(*this);
- if(_state != ServerI::Loading)
- {
- return;
- }
-
- InternalServerDescriptorPtr oldDescriptor = _desc;
- try
- {
- if(_load->clearDir())
- {
- //
- // The server was explicitely destroyed then updated,
- // we first need to cleanup the directory to remove
- // any user created files.
- //
- try
- {
- IcePatch2::removeRecursive(_serverDir);
- }
- catch(const string&)
- {
- }
- }
-
- try
- {
- updateImpl(_load->getInternalServerDescriptor());
- }
- catch(const Ice::Exception& ex)
- {
- ostringstream os;
- os << ex;
- throw DeploymentException(os.str());
- }
- catch(const string& msg)
- {
- throw DeploymentException(msg);
- }
- catch(const char* msg)
- {
- throw DeploymentException(msg);
- }
-
- if(oldDescriptor)
- {
- _node->removeServer(this, oldDescriptor->application, oldDescriptor->applicationDistrib);
- }
- _node->addServer(this, _desc->application, _desc->applicationDistrib);
-
- AdapterPrxDict adapters;
- for(ServerAdapterDict::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
- {
- adapters.insert(make_pair(p->first, p->second->getProxy()));
- }
- _load->finished(_this, adapters, _activationTimeout, _deactivationTimeout);
- }
- catch(const DeploymentException& ex)
- {
- //
- // Rollback old descriptor.
- //
- if(oldDescriptor)
- {
- try
- {
- updateImpl(oldDescriptor);
- }
- catch(const Ice::Exception& e)
- {
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "update failed:\n" << ex.reason << "\nand couldn't rollback old descriptor:\n" << e;
- }
- catch(const string& msg)
- {
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "update failed:\n" << ex.reason << "\nand couldn't rollback old descriptor:\n" << msg;
- }
- catch(const char* msg)
- {
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "update failed:\n" << ex.reason << "\nand couldn't rollback old descriptor:\n" << msg;
- }
- }
- else if(!_destroy)
- {
- _destroy = new DestroyCommand(this, true);
- }
-
- _load->failed(ex);
- }
-
- setStateNoSync(Inactive);
- command = nextCommand();
+ Lock sync(*this);
+ if(_state != ServerI::Loading)
+ {
+ return;
+ }
+
+ InternalServerDescriptorPtr oldDescriptor = _desc;
+ try
+ {
+ if(_load->clearDir())
+ {
+ //
+ // The server was explicitely destroyed then updated,
+ // we first need to cleanup the directory to remove
+ // any user created files.
+ //
+ try
+ {
+ IcePatch2::removeRecursive(_serverDir);
+ }
+ catch(const string&)
+ {
+ }
+ }
+
+ try
+ {
+ updateImpl(_load->getInternalServerDescriptor());
+ }
+ catch(const Ice::Exception& ex)
+ {
+ ostringstream os;
+ os << ex;
+ throw DeploymentException(os.str());
+ }
+ catch(const string& msg)
+ {
+ throw DeploymentException(msg);
+ }
+ catch(const char* msg)
+ {
+ throw DeploymentException(msg);
+ }
+
+ if(oldDescriptor)
+ {
+ _node->removeServer(this, oldDescriptor->application, oldDescriptor->applicationDistrib);
+ }
+ _node->addServer(this, _desc->application, _desc->applicationDistrib);
+
+ AdapterPrxDict adapters;
+ for(ServerAdapterDict::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
+ {
+ adapters.insert(make_pair(p->first, p->second->getProxy()));
+ }
+ _load->finished(_this, adapters, _activationTimeout, _deactivationTimeout);
+ }
+ catch(const DeploymentException& ex)
+ {
+ //
+ // Rollback old descriptor.
+ //
+ if(oldDescriptor)
+ {
+ try
+ {
+ updateImpl(oldDescriptor);
+ }
+ catch(const Ice::Exception& e)
+ {
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "update failed:\n" << ex.reason << "\nand couldn't rollback old descriptor:\n" << e;
+ }
+ catch(const string& msg)
+ {
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "update failed:\n" << ex.reason << "\nand couldn't rollback old descriptor:\n" << msg;
+ }
+ catch(const char* msg)
+ {
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "update failed:\n" << ex.reason << "\nand couldn't rollback old descriptor:\n" << msg;
+ }
+ }
+ else if(!_destroy)
+ {
+ _destroy = new DestroyCommand(this, true);
+ }
+
+ _load->failed(ex);
+ }
+
+ setStateNoSync(Inactive);
+ command = nextCommand();
}
if(command)
{
- command->execute();
+ command->execute();
}
}
@@ -1752,69 +1752,69 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
// can't start).
//
bool serverSessionReleased = _desc && _desc->activation == "session" &&
- _desc->revision == descriptor->revision && !_desc->sessionId.empty() && descriptor->sessionId.empty();
+ _desc->revision == descriptor->revision && !_desc->sessionId.empty() && descriptor->sessionId.empty();
//
// Go through the adapters and create the object adapter Ice
// objects if necessary, also remove the old ones.
//
{
- ServerAdapterDict oldAdapters;
- oldAdapters.swap(_adapters);
- _serverLifetimeAdapters.clear();
- Ice::ObjectAdapterPtr adapter = _node->getAdapter();
- for(InternalAdapterDescriptorSeq::const_iterator r = _desc->adapters.begin(); r != _desc->adapters.end(); ++r)
- {
- try
- {
- Ice::Identity id;
- id.category = _this->ice_getIdentity().category + "Adapter";
- id.name = _id + "-" + (*r)->id;
- ServerAdapterIPtr servant = ServerAdapterIPtr::dynamicCast(adapter->find(id));
- if(!servant)
- {
- AdapterPrx proxy = AdapterPrx::uncheckedCast(adapter->createProxy(id));
- servant = new ServerAdapterI(_node, this, _id, proxy, (*r)->id);
- adapter->add(servant, id);
- }
- _adapters.insert(make_pair((*r)->id, servant));
-
- if((*r)->serverLifetime)
- {
- _serverLifetimeAdapters.insert((*r)->id);
- }
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- // IGNORE
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Error out(_node->getTraceLevels()->logger);
- out << "couldn't add adapter `" << (*r)->id << "':\n" << ex;
- }
- oldAdapters.erase((*r)->id);
- }
-
- //
- // Remove old object adapters.
- //
- for(ServerAdapterDict::const_iterator t = oldAdapters.begin(); t != oldAdapters.end(); ++t)
- {
- try
- {
- t->second->destroy();
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- // IGNORE
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Error out(_node->getTraceLevels()->logger);
- out << "couldn't destroy adapter `" << t->first << "':\n" << ex;
- }
- }
+ ServerAdapterDict oldAdapters;
+ oldAdapters.swap(_adapters);
+ _serverLifetimeAdapters.clear();
+ Ice::ObjectAdapterPtr adapter = _node->getAdapter();
+ for(InternalAdapterDescriptorSeq::const_iterator r = _desc->adapters.begin(); r != _desc->adapters.end(); ++r)
+ {
+ try
+ {
+ Ice::Identity id;
+ id.category = _this->ice_getIdentity().category + "Adapter";
+ id.name = _id + "-" + (*r)->id;
+ ServerAdapterIPtr servant = ServerAdapterIPtr::dynamicCast(adapter->find(id));
+ if(!servant)
+ {
+ AdapterPrx proxy = AdapterPrx::uncheckedCast(adapter->createProxy(id));
+ servant = new ServerAdapterI(_node, this, _id, proxy, (*r)->id);
+ adapter->add(servant, id);
+ }
+ _adapters.insert(make_pair((*r)->id, servant));
+
+ if((*r)->serverLifetime)
+ {
+ _serverLifetimeAdapters.insert((*r)->id);
+ }
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ // IGNORE
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Error out(_node->getTraceLevels()->logger);
+ out << "couldn't add adapter `" << (*r)->id << "':\n" << ex;
+ }
+ oldAdapters.erase((*r)->id);
+ }
+
+ //
+ // Remove old object adapters.
+ //
+ for(ServerAdapterDict::const_iterator t = oldAdapters.begin(); t != oldAdapters.end(); ++t)
+ {
+ try
+ {
+ t->second->destroy();
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ // IGNORE
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Error out(_node->getTraceLevels()->logger);
+ out << "couldn't destroy adapter `" << t->first << "':\n" << ex;
+ }
+ }
}
//
@@ -1826,15 +1826,15 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
//
if(_activation != Disabled || _failureTime != IceUtil::Time())
{
- _activation = toServerActivation(_desc->activation);
- _failureTime = IceUtil::Time();
+ _activation = toServerActivation(_desc->activation);
+ _failureTime = IceUtil::Time();
}
if(_timer)
{
- _node->getWaitQueue()->remove(_timer);
- _timer = 0;
- }
+ _node->getWaitQueue()->remove(_timer);
+ _timer = 0;
+ }
//
// Don't change the user if the server has the session activation
@@ -1843,21 +1843,21 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
string user;
if(_desc->activation != "session" || !_desc->sessionId.empty())
{
- user = _desc->user;
+ user = _desc->user;
#ifndef _WIN32
- //
- // Check if the node is running as root, if that's the case we
- // make sure that a user is set for the process.
- //
- if(getuid() == 0 && user.empty())
- {
- //
- // If no user is configured and if this server is owned by
- // a session we set the user to the session id, otherwise
- // we set it to "nobody".
- //
- user = !_desc->sessionId.empty() ? _desc->sessionId : "nobody";
- }
+ //
+ // Check if the node is running as root, if that's the case we
+ // make sure that a user is set for the process.
+ //
+ if(getuid() == 0 && user.empty())
+ {
+ //
+ // If no user is configured and if this server is owned by
+ // a session we set the user to the session id, otherwise
+ // we set it to "nobody".
+ //
+ user = !_desc->sessionId.empty() ? _desc->sessionId : "nobody";
+ }
#endif
}
@@ -1867,108 +1867,108 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
if(!user.empty())
{
- UserAccountMapperPrx mapper = _node->getUserAccountMapper();
- if(mapper)
- {
- try
- {
- user = mapper->getUserAccount(user);
- }
- catch(const UserAccountNotFoundException&)
- {
- throw "couldn't find user account for user `" + user + "'";
- }
- catch(const Ice::LocalException& ex)
- {
- ostringstream os;
- os << "unexpected exception while trying to find user account for user `" << user << "':\n" << ex;
- throw os.str();
- }
- }
+ UserAccountMapperPrx mapper = _node->getUserAccountMapper();
+ if(mapper)
+ {
+ try
+ {
+ user = mapper->getUserAccount(user);
+ }
+ catch(const UserAccountNotFoundException&)
+ {
+ throw "couldn't find user account for user `" + user + "'";
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ ostringstream os;
+ os << "unexpected exception while trying to find user account for user `" << user << "':\n" << ex;
+ throw os.str();
+ }
+ }
#ifdef _WIN32
- //
- // Windows doesn't support running processes under another
- // account (at least not easily, see the CreateProcessAsUser
- // documentation). So if a user is specified, we just check
- // that the node is running under the same user account as the
- // one which is specified.
- //
- vector<char> buf(256);
- buf.resize(256);
- DWORD size = static_cast<DWORD>(buf.size());
- bool success = GetUserName(&buf[0], &size);
- if(!success && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
- {
- buf.resize(size);
- success = GetUserName(&buf[0], &size);
- }
- if(!success)
- {
- Ice::SyscallException ex(__FILE__, __LINE__);
- ex.error = getSystemErrno();
- throw ex;
- }
- if(user != string(&buf[0]))
- {
- throw "couldn't load server under user account `" + user + "': feature not supported on Windows";
- }
+ //
+ // Windows doesn't support running processes under another
+ // account (at least not easily, see the CreateProcessAsUser
+ // documentation). So if a user is specified, we just check
+ // that the node is running under the same user account as the
+ // one which is specified.
+ //
+ vector<char> buf(256);
+ buf.resize(256);
+ DWORD size = static_cast<DWORD>(buf.size());
+ bool success = GetUserName(&buf[0], &size);
+ if(!success && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
+ {
+ buf.resize(size);
+ success = GetUserName(&buf[0], &size);
+ }
+ if(!success)
+ {
+ Ice::SyscallException ex(__FILE__, __LINE__);
+ ex.error = getSystemErrno();
+ throw ex;
+ }
+ if(user != string(&buf[0]))
+ {
+ throw "couldn't load server under user account `" + user + "': feature not supported on Windows";
+ }
#else
- //
- // Get the uid/gid associated with the given user.
- //
- struct passwd* pw = getpwnam(user.c_str());
- if(!pw)
- {
- throw "unknown user account `" + user + "'";
- }
-
- //
- // If the node isn't running as root and if the uid of the
- // configured user is different from the uid of the userr
- // running the node we throw, a regular user can't run a
- // process as another user.
- //
- uid_t uid = getuid();
- if(uid != 0 && pw->pw_uid != uid)
- {
- throw "node has insufficient privileges to load server under user account `" + user + "'";
- }
-
- if(pw->pw_uid == 0) // Don't allow running proccesses as "root"
- {
- throw "running server as `root' is not allowed";
- }
-
- newUser = _uid != pw->pw_uid || _gid != pw->pw_gid;
- _uid = pw->pw_uid;
- _gid = pw->pw_gid;
+ //
+ // Get the uid/gid associated with the given user.
+ //
+ struct passwd* pw = getpwnam(user.c_str());
+ if(!pw)
+ {
+ throw "unknown user account `" + user + "'";
+ }
+
+ //
+ // If the node isn't running as root and if the uid of the
+ // configured user is different from the uid of the userr
+ // running the node we throw, a regular user can't run a
+ // process as another user.
+ //
+ uid_t uid = getuid();
+ if(uid != 0 && pw->pw_uid != uid)
+ {
+ throw "node has insufficient privileges to load server under user account `" + user + "'";
+ }
+
+ if(pw->pw_uid == 0) // Don't allow running proccesses as "root"
+ {
+ throw "running server as `root' is not allowed";
+ }
+
+ newUser = _uid != pw->pw_uid || _gid != pw->pw_gid;
+ _uid = pw->pw_uid;
+ _gid = pw->pw_gid;
#endif
}
#ifndef _WIN32
else
- {
- //
- // If no user is specified, we'll run the process as the
- // current user.
- //
- uid_t uid = getuid();
- uid_t gid = getgid();
- newUser = _uid != uid || _gid != gid;
- _uid = uid;
- _gid = gid;
+ {
+ //
+ // If no user is specified, we'll run the process as the
+ // current user.
+ //
+ uid_t uid = getuid();
+ uid_t gid = getgid();
+ newUser = _uid != uid || _gid != gid;
+ _uid = uid;
+ _gid = gid;
}
#endif
istringstream at(_desc->activationTimeout);
if(!(at >> _activationTimeout) || !at.eof() || _activationTimeout == 0)
{
- _activationTimeout = _waitTime;
+ _activationTimeout = _waitTime;
}
istringstream dt(_desc->deactivationTimeout);
if(!(dt >> _deactivationTimeout) || !dt.eof() || _deactivationTimeout == 0)
{
- _deactivationTimeout = _waitTime;
+ _deactivationTimeout = _waitTime;
}
//
@@ -2008,16 +2008,16 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
string outputDir = _node->getOutputDir();
if(!outputDir.empty())
{
- if(_stdErrFile.empty())
- {
- _stdErrFile = outputDir + "/" + _id + (_node->getRedirectErrToOut() ? ".out" : ".err");
- props.push_back(createProperty("Ice.StdErr", _stdErrFile));
- }
- if(_stdOutFile.empty())
- {
- _stdOutFile = outputDir + "/" + _id + ".out";
- props.push_back(createProperty("Ice.StdOut", _stdOutFile));
- }
+ if(_stdErrFile.empty())
+ {
+ _stdErrFile = outputDir + "/" + _id + (_node->getRedirectErrToOut() ? ".out" : ".err");
+ props.push_back(createProperty("Ice.StdErr", _stdErrFile));
+ }
+ if(_stdOutFile.empty())
+ {
+ _stdOutFile = outputDir + "/" + _id + ".out";
+ props.push_back(createProperty("Ice.StdOut", _stdOutFile));
+ }
}
//
@@ -2025,21 +2025,21 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
//
{
const PropertyDescriptorSeq& overrides = _node->getPropertiesOverride();
- for(PropertyDescriptorSeqDict::iterator p = properties.begin(); p != properties.end(); ++p)
- {
- if(getProperty(p->second, "Ice.Default.Locator").empty())
- {
- p->second.push_back(
- createProperty("Ice.Default.Locator",
- _node->getCommunicator()->getProperties()->getProperty("Ice.Default.Locator")));
- }
+ for(PropertyDescriptorSeqDict::iterator p = properties.begin(); p != properties.end(); ++p)
+ {
+ if(getProperty(p->second, "Ice.Default.Locator").empty())
+ {
+ p->second.push_back(
+ createProperty("Ice.Default.Locator",
+ _node->getCommunicator()->getProperties()->getProperty("Ice.Default.Locator")));
+ }
if(!overrides.empty())
{
p->second.push_back(createProperty("# Node properties override"));
p->second.insert(p->second.end(), overrides.begin(), overrides.end());
}
- }
+ }
}
//
@@ -2049,7 +2049,7 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
//
if(serverSessionReleased)
{
- return;
+ return;
}
//
@@ -2069,55 +2069,55 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
// Create the configuration files, remove the old ones.
//
{
- Ice::StringSeq knownFiles;
- for(PropertyDescriptorSeqDict::const_iterator p = properties.begin(); p != properties.end(); ++p)
- {
- knownFiles.push_back(p->first);
-
- const string configFilePath = _serverDir + "/config/" + p->first;
- ofstream configfile(configFilePath.c_str());
- if(!configfile.good())
- {
- throw "couldn't create configuration file: " + configFilePath;
- }
- configfile << "# Configuration file (" << IceUtil::Time::now().toDateTime();
- configfile << ", " << _desc->iceVersion << ")" << endl << endl;
- for(PropertyDescriptorSeq::const_iterator r = p->second.begin(); r != p->second.end(); ++r)
- {
- if(r->value.empty() && r->name.find('#') == 0)
- {
- configfile << r->name << endl;
- }
- else
- {
- configfile << r->name << "=" << r->value << endl;
- }
- }
- configfile.close();
- }
- sort(knownFiles.begin(), knownFiles.end());
-
- //
- // Remove old configuration files.
- //
- Ice::StringSeq files = IcePatch2::readDirectory(_serverDir + "/config");
- Ice::StringSeq toDel;
- set_difference(files.begin(), files.end(), knownFiles.begin(), knownFiles.end(), back_inserter(toDel));
- for(Ice::StringSeq::const_iterator q = toDel.begin(); q != toDel.end(); ++q)
- {
- if(q->find("config_") == 0)
- {
- try
- {
- IcePatch2::remove(_serverDir + "/config/" + *q);
- }
- catch(const string& msg)
- {
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "couldn't remove file `" + _serverDir + "/config/" + *q + "':\n" + msg;
- }
- }
- }
+ Ice::StringSeq knownFiles;
+ for(PropertyDescriptorSeqDict::const_iterator p = properties.begin(); p != properties.end(); ++p)
+ {
+ knownFiles.push_back(p->first);
+
+ const string configFilePath = _serverDir + "/config/" + p->first;
+ ofstream configfile(configFilePath.c_str());
+ if(!configfile.good())
+ {
+ throw "couldn't create configuration file: " + configFilePath;
+ }
+ configfile << "# Configuration file (" << IceUtil::Time::now().toDateTime();
+ configfile << ", " << _desc->iceVersion << ")" << endl << endl;
+ for(PropertyDescriptorSeq::const_iterator r = p->second.begin(); r != p->second.end(); ++r)
+ {
+ if(r->value.empty() && r->name.find('#') == 0)
+ {
+ configfile << r->name << endl;
+ }
+ else
+ {
+ configfile << r->name << "=" << r->value << endl;
+ }
+ }
+ configfile.close();
+ }
+ sort(knownFiles.begin(), knownFiles.end());
+
+ //
+ // Remove old configuration files.
+ //
+ Ice::StringSeq files = IcePatch2::readDirectory(_serverDir + "/config");
+ Ice::StringSeq toDel;
+ set_difference(files.begin(), files.end(), knownFiles.begin(), knownFiles.end(), back_inserter(toDel));
+ for(Ice::StringSeq::const_iterator q = toDel.begin(); q != toDel.end(); ++q)
+ {
+ if(q->find("config_") == 0)
+ {
+ try
+ {
+ IcePatch2::remove(_serverDir + "/config/" + *q);
+ }
+ catch(const string& msg)
+ {
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "couldn't remove file `" + _serverDir + "/config/" + *q + "':\n" + msg;
+ }
+ }
+ }
}
//
@@ -2125,67 +2125,67 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
// old ones.
//
{
- Ice::StringSeq knownDbEnvs;
- for(InternalDbEnvDescriptorSeq::const_iterator q = _desc->dbEnvs.begin(); q != _desc->dbEnvs.end(); ++q)
- {
- knownDbEnvs.push_back((*q)->name);
-
- string dbEnvHome = _serverDir + "/dbs/" + (*q)->name;
- createOrUpdateDirectory(dbEnvHome);
-
- if(!(*q)->properties.empty())
- {
- string file = dbEnvHome + "/DB_CONFIG";
- ofstream configfile(file.c_str());
- if(!configfile.good())
- {
- throw "couldn't create configuration file `" + file + "'";
- }
-
- PropertyDescriptorSeq::const_iterator p;
- for(p = (*q)->properties.begin(); p != (*q)->properties.end(); ++p)
- {
- if(!p->name.empty())
- {
- configfile << p->name;
- if(!p->value.empty())
- {
- configfile << " " << p->value;
- }
- configfile << endl;
- }
- }
- configfile.close();
- }
- }
- sort(knownDbEnvs.begin(), knownDbEnvs.end());
-
- //
- // Remove old database environments.
- //
- Ice::StringSeq dbEnvs = IcePatch2::readDirectory(_serverDir + "/dbs");
- Ice::StringSeq toDel;
- set_difference(dbEnvs.begin(), dbEnvs.end(), knownDbEnvs.begin(), knownDbEnvs.end(), back_inserter(toDel));
- for(Ice::StringSeq::const_iterator p = toDel.begin(); p != toDel.end(); ++p)
- {
- try
- {
- IcePatch2::removeRecursive(_serverDir + "/dbs/" + *p);
- }
- catch(const string& msg)
- {
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "couldn't remove directory `" + _serverDir + "/dbs/" + *p + "':\n" + msg;
- }
- }
+ Ice::StringSeq knownDbEnvs;
+ for(InternalDbEnvDescriptorSeq::const_iterator q = _desc->dbEnvs.begin(); q != _desc->dbEnvs.end(); ++q)
+ {
+ knownDbEnvs.push_back((*q)->name);
+
+ string dbEnvHome = _serverDir + "/dbs/" + (*q)->name;
+ createOrUpdateDirectory(dbEnvHome);
+
+ if(!(*q)->properties.empty())
+ {
+ string file = dbEnvHome + "/DB_CONFIG";
+ ofstream configfile(file.c_str());
+ if(!configfile.good())
+ {
+ throw "couldn't create configuration file `" + file + "'";
+ }
+
+ PropertyDescriptorSeq::const_iterator p;
+ for(p = (*q)->properties.begin(); p != (*q)->properties.end(); ++p)
+ {
+ if(!p->name.empty())
+ {
+ configfile << p->name;
+ if(!p->value.empty())
+ {
+ configfile << " " << p->value;
+ }
+ configfile << endl;
+ }
+ }
+ configfile.close();
+ }
+ }
+ sort(knownDbEnvs.begin(), knownDbEnvs.end());
+
+ //
+ // Remove old database environments.
+ //
+ Ice::StringSeq dbEnvs = IcePatch2::readDirectory(_serverDir + "/dbs");
+ Ice::StringSeq toDel;
+ set_difference(dbEnvs.begin(), dbEnvs.end(), knownDbEnvs.begin(), knownDbEnvs.end(), back_inserter(toDel));
+ for(Ice::StringSeq::const_iterator p = toDel.begin(); p != toDel.end(); ++p)
+ {
+ try
+ {
+ IcePatch2::removeRecursive(_serverDir + "/dbs/" + *p);
+ }
+ catch(const string& msg)
+ {
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "couldn't remove directory `" + _serverDir + "/dbs/" + *p + "':\n" + msg;
+ }
+ }
}
#ifndef _WIN32
if(newUser)
{
- chownRecursive(_serverDir + "/config", _uid, _gid);
- chownRecursive(_serverDir + "/dbs", _uid, _gid);
- chownRecursive(_serverDir + "/distrib", _uid, _gid);
+ chownRecursive(_serverDir + "/config", _uid, _gid);
+ chownRecursive(_serverDir + "/dbs", _uid, _gid);
+ chownRecursive(_serverDir + "/distrib", _uid, _gid);
}
#endif
}
@@ -2195,47 +2195,47 @@ ServerI::checkRevision(const string& replicaName, const string& uuid, int revisi
{
if(replicaName == "Master")
{
- return;
+ return;
}
string descUUID;
int descRevision;
if(_desc)
{
- descUUID = _desc->uuid;
- descRevision = _desc->revision;
+ descUUID = _desc->uuid;
+ descRevision = _desc->revision;
}
else
{
- string idFilePath = _serverDir + "/revision";
- ifstream is(idFilePath.c_str());
- if(!is.good())
- {
- return;
- }
-
- char line[1024];
- is.getline(line, 1024); // Ignore comments
- is.getline(line, 1024);
- is.getline(line, 1024);
- string ignore;
- is >> ignore >> descUUID;
- is >> ignore >> descRevision;
+ string idFilePath = _serverDir + "/revision";
+ ifstream is(idFilePath.c_str());
+ if(!is.good())
+ {
+ return;
+ }
+
+ char line[1024];
+ is.getline(line, 1024); // Ignore comments
+ is.getline(line, 1024);
+ is.getline(line, 1024);
+ string ignore;
+ is >> ignore >> descUUID;
+ is >> ignore >> descRevision;
}
if(uuid != descUUID)
{
- DeploymentException ex;
- ex.reason = "server from replica `" + replicaName + "' is from another application (`" + uuid + "')";
- throw ex;
+ DeploymentException ex;
+ ex.reason = "server from replica `" + replicaName + "' is from another application (`" + uuid + "')";
+ throw ex;
}
else if(revision != descRevision)
{
- ostringstream os;
- os << "server from replica `" + replicaName + "' has a different version:\n";
- os << "current revision: " << descRevision << "\n";
- os << "replica revision: " << revision;
- throw DeploymentException(os.str());
+ ostringstream os;
+ os << "server from replica `" + replicaName + "' has a different version:\n";
+ os << "current revision: " << descRevision << "\n";
+ os << "replica revision: " << revision;
+ throw DeploymentException(os.str());
}
}
@@ -2249,11 +2249,11 @@ ServerI::updateRevision(const string& uuid, int revision)
ofstream os(idFilePath.c_str());
if(os.good())
{
- os << "#" << endl;
- os << "# This server belongs to the application `" << _desc->application << "'" << endl;
- os << "#" << endl;
- os << "uuid: " << _desc->uuid << endl;
- os << "revision: " << _desc->revision << endl;
+ os << "#" << endl;
+ os << "# This server belongs to the application `" << _desc->application << "'" << endl;
+ os << "#" << endl;
+ os << "uuid: " << _desc->uuid << endl;
+ os << "revision: " << _desc->revision << endl;
}
}
@@ -2263,11 +2263,11 @@ ServerI::checkActivation()
//assert(locked());
if(_state == ServerI::WaitForActivation || _state == ServerI::ActivationTimeout)
{
- if(includes(_activatedAdapters.begin(), _activatedAdapters.end(),
- _serverLifetimeAdapters.begin(), _serverLifetimeAdapters.end()))
- {
- setStateNoSync(ServerI::Active);
- }
+ if(includes(_activatedAdapters.begin(), _activatedAdapters.end(),
+ _serverLifetimeAdapters.begin(), _serverLifetimeAdapters.end()))
+ {
+ setStateNoSync(ServerI::Active);
+ }
}
}
@@ -2276,13 +2276,13 @@ ServerI::setState(InternalServerState st, const std::string& reason)
{
ServerCommandPtr command;
{
- Lock sync(*this);
- setStateNoSync(st, reason);
- command = nextCommand();
+ Lock sync(*this);
+ setStateNoSync(st, reason);
+ command = nextCommand();
}
if(command)
{
- command->execute();
+ command->execute();
}
}
@@ -2292,27 +2292,27 @@ ServerI::nextCommand()
ServerCommandPtr command;
if(_stop && _stop->canExecute(_state))
{
- command = _stop;
+ command = _stop;
}
else if(_destroy && _destroy->canExecute(_state))
{
- command = _destroy;
+ command = _destroy;
}
else if(_load && _load->canExecute(_state))
{
- command = _load;
+ command = _load;
}
else if(_patch && _patch->canExecute(_state))
{
- command = _patch;
+ command = _patch;
}
else if(_start && _start->canExecute(_state))
{
- command = _start;
+ command = _start;
}
if(command)
{
- setStateNoSync(command->nextState());
+ setStateNoSync(command->nextState());
}
return command;
}
@@ -2326,37 +2326,37 @@ ServerI::setStateNoSync(InternalServerState st, const std::string& reason)
switch(st)
{
case Inactive:
- break;
+ break;
case Patching:
- assert(_patch && _patch->canExecute(_state));
- break;
+ assert(_patch && _patch->canExecute(_state));
+ break;
case Loading:
- assert(_load && _load->canExecute(_state));
- break;
+ assert(_load && _load->canExecute(_state));
+ break;
case Activating:
- assert(_start && _start->canExecute(_state));
- break;
+ assert(_start && _start->canExecute(_state));
+ break;
case WaitForActivation:
- assert(_state == Activating);
- break;
+ assert(_state == Activating);
+ break;
case ActivationTimeout:
- assert(_state == WaitForActivation);
- break;
+ assert(_state == WaitForActivation);
+ break;
case Active:
- assert(_state == WaitForActivation || _state == ActivationTimeout);
- break;
+ assert(_state == WaitForActivation || _state == ActivationTimeout);
+ break;
case Deactivating:
- //assert(_stop && _stop->canExecute(_state));
- break;
+ //assert(_stop && _stop->canExecute(_state));
+ break;
case DeactivatingWaitForProcess:
- assert(_state == Deactivating);
- break;
+ assert(_state == Deactivating);
+ break;
case Destroying:
- assert(_state == Inactive && _destroy && _destroy->canExecute(_state));
- break;
+ assert(_state == Inactive && _destroy && _destroy->canExecute(_state));
+ break;
case Destroyed:
- assert(_destroy);
- break;
+ assert(_destroy);
+ break;
}
//
@@ -2372,112 +2372,112 @@ ServerI::setStateNoSync(InternalServerState st, const std::string& reason)
switch(_state)
{
case Inactive:
- if(previous == Loading)
- {
- _load = 0;
- }
- if(previous == Patching)
- {
- _patch = 0;
- }
- if(_stop)
- {
- _stop->finished();
- _stop = 0;
- }
- break;
+ if(previous == Loading)
+ {
+ _load = 0;
+ }
+ if(previous == Patching)
+ {
+ _patch = 0;
+ }
+ if(_stop)
+ {
+ _stop->finished();
+ _stop = 0;
+ }
+ break;
case Active:
- if(_start)
- {
- _start->finished();
- _start = 0;
- }
- break;
+ if(_start)
+ {
+ _start->finished();
+ _start = 0;
+ }
+ break;
case ActivationTimeout:
- if(_start)
- {
- _start->failed(reason);
- _start = 0;
- }
- break;
+ if(_start)
+ {
+ _start->failed(reason);
+ _start = 0;
+ }
+ break;
case Deactivating:
- if(_start)
- {
- _start->failed(reason.empty() ? string("The server is being deactivated.") : reason);
- _start = 0;
- }
- break;
+ if(_start)
+ {
+ _start->failed(reason.empty() ? string("The server is being deactivated.") : reason);
+ _start = 0;
+ }
+ break;
case Destroying:
- loadFailure = _destroy->loadFailure();
- if(_patch)
- {
- _patch->destroyed();
- _patch = 0;
- }
- if(_load)
- {
- _load->failed(DeploymentException("The server is being destroyed."));
- _load = 0;
- }
- if(_start)
- {
- _start->failed("The server is being destroyed.");
- _start = 0;
- }
- if(_stop)
- {
- _stop->failed("The server is being destroyed.");
- _stop = 0;
- }
- break;
+ loadFailure = _destroy->loadFailure();
+ if(_patch)
+ {
+ _patch->destroyed();
+ _patch = 0;
+ }
+ if(_load)
+ {
+ _load->failed(DeploymentException("The server is being destroyed."));
+ _load = 0;
+ }
+ if(_start)
+ {
+ _start->failed("The server is being destroyed.");
+ _start = 0;
+ }
+ if(_stop)
+ {
+ _stop->failed("The server is being destroyed.");
+ _stop = 0;
+ }
+ break;
case Destroyed:
- if(_destroy)
- {
- loadFailure = _destroy->loadFailure();
- _destroy->finished();
- _destroy = 0;
- }
- break;
+ if(_destroy)
+ {
+ loadFailure = _destroy->loadFailure();
+ _destroy->finished();
+ _destroy = 0;
+ }
+ break;
default:
- break;
+ break;
}
if(_state == Destroyed && !_load)
{
- //
- // If the server is destroyed and there's no load command, we
- // remove the servant from the ASM.
- //
- try
- {
- _node->getAdapter()->remove(_this->ice_getIdentity());
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- // IGNORE
- }
- _desc = 0;
+ //
+ // If the server is destroyed and there's no load command, we
+ // remove the servant from the ASM.
+ //
+ try
+ {
+ _node->getAdapter()->remove(_this->ice_getIdentity());
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ // IGNORE
+ }
+ _desc = 0;
}
else if(_state == Inactive)
{
- if(_activation == Always)
- {
- _timer = new DelayedStart(this, _node->getTraceLevels());
- _node->getWaitQueue()->add(_timer, IceUtil::Time::milliSeconds(500));
- }
- else if(_activation == Disabled && _disableOnFailure > 0 && _failureTime != IceUtil::Time())
- {
- //
- // If the server was disabled because it failed, we
- // schedule a callback to re-enable it. We add 500ms to
- // the disable on failure duration to make sure that the
- // server will be ready to be reactivated when the
- // callback is executed.
- //
- _timer = new DelayedStart(this, _node->getTraceLevels());
- _node->getWaitQueue()->add(_timer,
- IceUtil::Time::seconds(_disableOnFailure) + IceUtil::Time::milliSeconds(500));
- }
+ if(_activation == Always)
+ {
+ _timer = new DelayedStart(this, _node->getTraceLevels());
+ _node->getWaitQueue()->add(_timer, IceUtil::Time::milliSeconds(500));
+ }
+ else if(_activation == Disabled && _disableOnFailure > 0 && _failureTime != IceUtil::Time())
+ {
+ //
+ // If the server was disabled because it failed, we
+ // schedule a callback to re-enable it. We add 500ms to
+ // the disable on failure duration to make sure that the
+ // server will be ready to be reactivated when the
+ // callback is executed.
+ //
+ _timer = new DelayedStart(this, _node->getTraceLevels());
+ _node->getWaitQueue()->add(_timer,
+ IceUtil::Time::seconds(_disableOnFailure) + IceUtil::Time::milliSeconds(500));
+ }
}
//
@@ -2491,69 +2491,69 @@ ServerI::setStateNoSync(InternalServerState st, const std::string& reason)
!(previous == Inactive && _state == Deactivating) &&
!loadFailure)
{
- _node->observerUpdateServer(getDynamicInfo());
+ _node->observerUpdateServer(getDynamicInfo());
}
if(_node->getTraceLevels()->server > 1)
{
- if(_state == ServerI::Active)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `Active'";
- }
- else if(_state == ServerI::Inactive)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `Inactive'";
- }
- else if(_state == ServerI::Destroyed)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `Destroyed'";
- }
- else if(_node->getTraceLevels()->server > 2)
- {
- if(_state == ServerI::WaitForActivation)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `WaitForActivation'";
- }
- else if(_state == ServerI::ActivationTimeout)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `ActivationTimeout'";
- }
- else if(_state == ServerI::Activating)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `Activating'";
- }
- else if(_state == ServerI::Deactivating)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `Deactivating'";
- }
- else if(_state == ServerI::DeactivatingWaitForProcess)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `DeactivatingWaitForProcess'";
- }
- else if(_state == ServerI::Destroying)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `Destroying'";
- }
- else if(_state == ServerI::Loading)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `Loading'";
- }
- else if(_state == ServerI::Patching)
- {
- Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
- out << "changed server `" << _id << "' state to `Loading'";
- }
- }
+ if(_state == ServerI::Active)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `Active'";
+ }
+ else if(_state == ServerI::Inactive)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `Inactive'";
+ }
+ else if(_state == ServerI::Destroyed)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `Destroyed'";
+ }
+ else if(_node->getTraceLevels()->server > 2)
+ {
+ if(_state == ServerI::WaitForActivation)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `WaitForActivation'";
+ }
+ else if(_state == ServerI::ActivationTimeout)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `ActivationTimeout'";
+ }
+ else if(_state == ServerI::Activating)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `Activating'";
+ }
+ else if(_state == ServerI::Deactivating)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `Deactivating'";
+ }
+ else if(_state == ServerI::DeactivatingWaitForProcess)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `DeactivatingWaitForProcess'";
+ }
+ else if(_state == ServerI::Destroying)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `Destroying'";
+ }
+ else if(_state == ServerI::Loading)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `Loading'";
+ }
+ else if(_state == ServerI::Patching)
+ {
+ Ice::Trace out(_node->getTraceLevels()->logger, _node->getTraceLevels()->serverCat);
+ out << "changed server `" << _id << "' state to `Loading'";
+ }
+ }
}
}
@@ -2562,7 +2562,7 @@ ServerI::createOrUpdateDirectory(const string& dir)
{
try
{
- IcePatch2::createDirectory(dir);
+ IcePatch2::createDirectory(dir);
}
catch(const string&)
{
@@ -2570,7 +2570,7 @@ ServerI::createOrUpdateDirectory(const string& dir)
#ifndef _WIN32
if(chown(dir.c_str(), _uid, _gid) != 0)
{
- throw "can't set permissions on directory `" + dir + "'";
+ throw "can't set permissions on directory `" + dir + "'";
}
#endif
}
@@ -2584,23 +2584,23 @@ ServerI::toServerState(InternalServerState st) const
case ServerI::Activating:
case ServerI::Patching:
case ServerI::Loading:
- return IceGrid::Inactive;
+ return IceGrid::Inactive;
case ServerI::WaitForActivation:
- return IceGrid::Activating;
+ return IceGrid::Activating;
case ServerI::ActivationTimeout:
- return IceGrid::ActivationTimedOut;
+ return IceGrid::ActivationTimedOut;
case ServerI::Active:
- return IceGrid::Active;
+ return IceGrid::Active;
case ServerI::Deactivating:
case ServerI::DeactivatingWaitForProcess:
- return IceGrid::Deactivating;
+ return IceGrid::Deactivating;
case ServerI::Destroying:
- return IceGrid::Destroying;
+ return IceGrid::Destroying;
case ServerI::Destroyed:
- return IceGrid::Destroyed;
+ return IceGrid::Destroyed;
default:
- assert(false);
- return IceGrid::Destroyed;
+ assert(false);
+ return IceGrid::Destroyed;
}
}
@@ -2609,25 +2609,25 @@ ServerI::toServerActivation(const string& activation) const
{
if(activation == "on-demand")
{
- return OnDemand;
+ return OnDemand;
}
else if(activation == "session")
{
- return Session;
+ return Session;
}
else if(activation == "always")
{
- return Always;
+ return Always;
}
else if(activation == "manual" || activation.empty())
{
- return Manual;
+ return Manual;
}
else
{
- Ice::Warning out(_node->getTraceLevels()->logger);
- out << "unknown activation mode `" << activation << "' for server `" << _id << "'";
- return Manual;
+ Ice::Warning out(_node->getTraceLevels()->logger);
+ out << "unknown activation mode `" << activation << "' for server `" << _id << "'";
+ return Manual;
}
}
@@ -2653,36 +2653,36 @@ ServerI::getFilePath(const string& filename) const
{
if(filename == "stderr")
{
- if(_stdErrFile.empty())
- {
- throw FileNotAvailableException("Ice.StdErr configuration property is not set");
- }
- return _stdErrFile;
+ if(_stdErrFile.empty())
+ {
+ throw FileNotAvailableException("Ice.StdErr configuration property is not set");
+ }
+ return _stdErrFile;
}
else if(filename == "stdout")
{
- if(_stdOutFile.empty())
- {
- throw FileNotAvailableException("Ice.StdOut configuration property is not set");
- }
- return _stdOutFile;
+ if(_stdOutFile.empty())
+ {
+ throw FileNotAvailableException("Ice.StdOut configuration property is not set");
+ }
+ return _stdOutFile;
}
else if(!filename.empty() && filename[0] == '#')
{
- string path = IcePatch2::simplify(filename.substr(1));
+ string path = IcePatch2::simplify(filename.substr(1));
if(!IcePatch2::isAbsolute(path))
{
path = _node->getPlatformInfo().getCwd() + "/" + path;
}
- if(find(_logs.begin(), _logs.end(), path) == _logs.end())
- {
- throw FileNotAvailableException("unknown log file `" + path + "'");
- }
- return path;
+ if(find(_logs.begin(), _logs.end(), path) == _logs.end())
+ {
+ throw FileNotAvailableException("unknown log file `" + path + "'");
+ }
+ return path;
}
else
{
- throw FileNotAvailableException("unknown file");
+ throw FileNotAvailableException("unknown file");
return ""; // Keep the compiler happy.
}
}
diff --git a/cpp/src/IceGrid/ServerI.h b/cpp/src/IceGrid/ServerI.h
index e0dcf3e7cf6..2e0ef5b9afa 100644
--- a/cpp/src/IceGrid/ServerI.h
+++ b/cpp/src/IceGrid/ServerI.h
@@ -47,26 +47,26 @@ public:
enum InternalServerState
{
- Loading,
- Patching,
- Inactive,
- Activating,
- WaitForActivation,
- ActivationTimeout,
- Active,
- Deactivating,
- DeactivatingWaitForProcess,
- Destroying,
- Destroyed
+ Loading,
+ Patching,
+ Inactive,
+ Activating,
+ WaitForActivation,
+ ActivationTimeout,
+ Active,
+ Deactivating,
+ DeactivatingWaitForProcess,
+ Destroying,
+ Destroyed
};
enum ServerActivation
{
- Always,
- Session,
- OnDemand,
- Manual,
- Disabled
+ Always,
+ Session,
+ OnDemand,
+ Manual,
+ Disabled
};
ServerI(const NodeIPtr&, const ServerPrx&, const std::string&, const std::string&, int);
diff --git a/cpp/src/IceGrid/SessionI.cpp b/cpp/src/IceGrid/SessionI.cpp
index daa64ddb7d7..f27ded104d5 100644
--- a/cpp/src/IceGrid/SessionI.cpp
+++ b/cpp/src/IceGrid/SessionI.cpp
@@ -31,24 +31,24 @@ class AllocateObject : public ObjectAllocationRequest
public:
AllocateObject(const SessionIPtr& session, const TPtr& cb) :
- ObjectAllocationRequest(session), _cb(cb)
+ ObjectAllocationRequest(session), _cb(cb)
{
}
virtual void
response(const Ice::ObjectPrx& proxy)
{
- assert(_cb);
- _cb->ice_response(proxy);
- _cb = 0;
+ assert(_cb);
+ _cb->ice_response(proxy);
+ _cb = 0;
}
virtual void
exception(const AllocationException& ex)
{
- assert(_cb);
- _cb->ice_exception(ex);
- _cb = 0;
+ assert(_cb);
+ _cb->ice_exception(ex);
+ _cb = 0;
}
private:
@@ -65,8 +65,8 @@ newAllocateObject(const SessionIPtr& session, const IceUtil::Handle<T>& cb)
}
BaseSessionI::BaseSessionI(const string& id,
- const string& prefix,
- const DatabasePtr& database) :
+ const string& prefix,
+ const DatabasePtr& database) :
_id(id),
_prefix(prefix),
_traceLevels(database->getTraceLevels()),
@@ -76,8 +76,8 @@ BaseSessionI::BaseSessionI(const string& id,
{
if(_traceLevels && _traceLevels->session > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->sessionCat);
- out << _prefix << " session `" << _id << "' created";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->sessionCat);
+ out << _prefix << " session `" << _id << "' created";
}
}
@@ -91,17 +91,17 @@ BaseSessionI::keepAlive(const Ice::Current& current)
Lock sync(*this);
if(_destroyed)
{
- Ice::ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = current.id;
- throw ex;
+ Ice::ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = current.id;
+ throw ex;
}
_timestamp = IceUtil::Time::now();
if(_traceLevels->session > 1)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->sessionCat);
- out << _prefix << " session `" << _id << "' keep alive";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->sessionCat);
+ out << _prefix << " session `" << _id << "' keep alive";
}
}
@@ -111,34 +111,34 @@ BaseSessionI::destroyImpl(bool shutdown)
Lock sync(*this);
if(_destroyed)
{
- Ice::ObjectNotExistException ex(__FILE__, __LINE__);
- ex.id = _identity;
- throw ex;
+ Ice::ObjectNotExistException ex(__FILE__, __LINE__);
+ ex.id = _identity;
+ throw ex;
}
_destroyed = true;
if(!shutdown)
{
- if(_servantLocator)
- {
- _servantLocator->remove(_identity);
- }
- else if(_adapter)
- {
- try
- {
- _adapter->remove(_identity);
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- }
- }
+ if(_servantLocator)
+ {
+ _servantLocator->remove(_identity);
+ }
+ else if(_adapter)
+ {
+ try
+ {
+ _adapter->remove(_identity);
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ }
+ }
}
-
+
if(_traceLevels && _traceLevels->session > 0)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->sessionCat);
- out << _prefix << " session `" << _id << "' destroyed";
+ Ice::Trace out(_traceLevels->logger, _traceLevels->sessionCat);
+ out << _prefix << " session `" << _id << "' destroyed";
}
}
@@ -180,9 +180,9 @@ BaseSessionI::registerWithObjectAdapter(const Ice::ObjectAdapterPtr& adapter)
}
SessionI::SessionI(const string& id,
- const DatabasePtr& database,
- const WaitQueuePtr& waitQueue,
- const Glacier2::SessionControlPrx& sessionControl) :
+ const DatabasePtr& database,
+ const WaitQueuePtr& waitQueue,
+ const Glacier2::SessionControlPrx& sessionControl) :
BaseSessionI(id, "client", database),
_waitQueue(waitQueue),
_sessionControl(sessionControl),
@@ -196,16 +196,16 @@ SessionI::~SessionI()
void
SessionI::allocateObjectById_async(const AMD_Session_allocateObjectByIdPtr& cb,
- const Ice::Identity& id,
- const Ice::Current&)
+ const Ice::Identity& id,
+ const Ice::Current&)
{
_database->getAllocatableObject(id)->allocate(newAllocateObject(this, cb));
}
void
SessionI::allocateObjectByType_async(const AMD_Session_allocateObjectByTypePtr& cb,
- const string& type,
- const Ice::Current&)
+ const string& type,
+ const Ice::Current&)
{
_database->getAllocatableObjectCache().allocateByType(type, newAllocateObject(this, cb));
}
@@ -242,7 +242,7 @@ SessionI::addAllocationRequest(const AllocationRequestPtr& request)
Lock sync(*this);
if(_destroyed)
{
- return false;
+ return false;
}
_requests.insert(request);
return true;
@@ -254,7 +254,7 @@ SessionI::removeAllocationRequest(const AllocationRequestPtr& request)
Lock sync(*this);
if(_destroyed)
{
- return;
+ return;
}
_requests.erase(request);
}
@@ -265,7 +265,7 @@ SessionI::addAllocation(const AllocatablePtr& allocatable)
Lock sync(*this);
if(_destroyed)
{
- throw SessionDestroyedException();
+ throw SessionDestroyedException();
}
_allocations.insert(allocatable);
}
@@ -276,7 +276,7 @@ SessionI::removeAllocation(const AllocatablePtr& allocatable)
Lock sync(*this);
if(_destroyed)
{
- return;
+ return;
}
_allocations.erase(allocatable);
}
@@ -294,27 +294,27 @@ SessionI::destroyImpl(bool shutdown)
for(set<AllocationRequestPtr>::const_iterator p = _requests.begin(); p != _requests.end(); ++p)
{
- (*p)->cancel(AllocationException("session destroyed"));
+ (*p)->cancel(AllocationException("session destroyed"));
}
_requests.clear();
for(set<AllocatablePtr>::const_iterator q = _allocations.begin(); q != _allocations.end(); ++q)
{
- try
- {
- (*q)->release(this);
- }
- catch(const AllocationException&)
- {
- }
+ try
+ {
+ (*q)->release(this);
+ }
+ catch(const AllocationException&)
+ {
+ }
}
_allocations.clear();
}
ClientSessionFactory::ClientSessionFactory(const Ice::ObjectAdapterPtr& adapter,
- const DatabasePtr& database,
- const WaitQueuePtr& waitQueue,
- const ReapThreadPtr& reaper) :
+ const DatabasePtr& database,
+ const WaitQueuePtr& waitQueue,
+ const ReapThreadPtr& reaper) :
_adapter(adapter),
_database(database),
_waitQueue(waitQueue),
@@ -341,21 +341,21 @@ ClientSessionFactory::createGlacier2Session(const string& sessionId, const Glaci
int timeout = 0;
if(ctl)
{
- try
- {
- ctl->identities()->add(ids);
- }
- catch(const Ice::LocalException&)
- {
- session->destroy(Ice::Current());
- return 0;
- }
- timeout = ctl->getSessionTimeout();
+ try
+ {
+ ctl->identities()->add(ids);
+ }
+ catch(const Ice::LocalException&)
+ {
+ session->destroy(Ice::Current());
+ return 0;
+ }
+ timeout = ctl->getSessionTimeout();
}
if(timeout > 0)
{
- _reaper->add(new SessionReapable<SessionI>(_database->getTraceLevels()->logger, session), timeout);
+ _reaper->add(new SessionReapable<SessionI>(_database->getTraceLevels()->logger, session), timeout);
}
return Glacier2::SessionPrx::uncheckedCast(proxy);
@@ -389,26 +389,26 @@ ClientSSLSessionManagerI::ClientSSLSessionManagerI(const ClientSessionFactoryPtr
Glacier2::SessionPrx
ClientSSLSessionManagerI::create(const Glacier2::SSLInfo& info,
- const Glacier2::SessionControlPrx& ctl,
- const Ice::Current& current)
+ const Glacier2::SessionControlPrx& ctl,
+ const Ice::Current& current)
{
string userDN;
if(!info.certs.empty()) // TODO: Require userDN?
{
- try
- {
- IceSSL::CertificatePtr cert = IceSSL::Certificate::decode(info.certs[0]);
- userDN = cert->getSubjectDN();
- }
- catch(const Ice::Exception& ex)
- {
- // This shouldn't happen, the SSLInfo is supposed to be encoded by Glacier2.
- Ice::Error out(_factory->getTraceLevels()->logger);
- out << "SSL session manager couldn't decode SSL certificates:\n" << ex;
- return 0;
- }
+ try
+ {
+ IceSSL::CertificatePtr cert = IceSSL::Certificate::decode(info.certs[0]);
+ userDN = cert->getSubjectDN();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ // This shouldn't happen, the SSLInfo is supposed to be encoded by Glacier2.
+ Ice::Error out(_factory->getTraceLevels()->logger);
+ out << "SSL session manager couldn't decode SSL certificates:\n" << ex;
+ return 0;
+ }
}
-
+
return _factory->createGlacier2Session(userDN, ctl);
}
diff --git a/cpp/src/IceGrid/SessionI.h b/cpp/src/IceGrid/SessionI.h
index 8d6d702ec91..9dbb5666b83 100644
--- a/cpp/src/IceGrid/SessionI.h
+++ b/cpp/src/IceGrid/SessionI.h
@@ -86,9 +86,9 @@ public:
virtual void keepAlive(const Ice::Current& current) { BaseSessionI::keepAlive(current); }
virtual void allocateObjectById_async(const AMD_Session_allocateObjectByIdPtr&, const Ice::Identity&,
- const Ice::Current&);
+ const Ice::Current&);
virtual void allocateObjectByType_async(const AMD_Session_allocateObjectByTypePtr&, const std::string&,
- const Ice::Current&);
+ const Ice::Current&);
virtual void releaseObject(const Ice::Identity&, const Ice::Current&);
virtual void setAllocationTimeout(int, const Ice::Current&);
virtual void destroy(const Ice::Current&);
@@ -154,7 +154,7 @@ public:
ClientSSLSessionManagerI(const ClientSessionFactoryPtr&);
virtual Glacier2::SessionPrx create(const Glacier2::SSLInfo&, const Glacier2::SessionControlPrx&,
- const Ice::Current&);
+ const Ice::Current&);
private:
diff --git a/cpp/src/IceGrid/SessionManager.h b/cpp/src/IceGrid/SessionManager.h
index c72924dbc53..7ce8ba23b0b 100644
--- a/cpp/src/IceGrid/SessionManager.h
+++ b/cpp/src/IceGrid/SessionManager.h
@@ -26,245 +26,245 @@ class SessionKeepAliveThread : public IceUtil::Thread, public IceUtil::Monitor<I
{
enum State
{
- Disconnected,
- Connected,
- InProgress,
- Destroyed
+ Disconnected,
+ Connected,
+ InProgress,
+ Destroyed
};
enum Action
{
- Connect,
- Disconnect,
- KeepAlive,
- None
+ Connect,
+ Disconnect,
+ KeepAlive,
+ None
};
public:
SessionKeepAliveThread(const InternalRegistryPrx& registry) :
- _registry(registry),
- _state(InProgress),
- _nextAction(None)
+ _registry(registry),
+ _state(InProgress),
+ _nextAction(None)
{
}
virtual void
run()
{
- TPrx session;
- InternalRegistryPrx registry;
- IceUtil::Time timeout = IceUtil::Time::seconds(15);
- Action action = Connect;
+ TPrx session;
+ InternalRegistryPrx registry;
+ IceUtil::Time timeout = IceUtil::Time::seconds(15);
+ Action action = Connect;
- while(true)
- {
- {
- Lock sync(*this);
- if(_state == Destroyed)
- {
- break;
- }
+ while(true)
+ {
+ {
+ Lock sync(*this);
+ if(_state == Destroyed)
+ {
+ break;
+ }
- //
- // Update the current state.
- //
- assert(_state == InProgress);
- _state = session ? Connected : Disconnected;
- _session = session;
- if(_session)
- {
- _registry = registry;
- }
+ //
+ // Update the current state.
+ //
+ assert(_state == InProgress);
+ _state = session ? Connected : Disconnected;
+ _session = session;
+ if(_session)
+ {
+ _registry = registry;
+ }
- if(_nextAction == Connect && _state == Connected)
- {
- _nextAction = KeepAlive;
- }
- else if(_nextAction == Disconnect && _state == Disconnected)
- {
- _nextAction = None;
- }
- else if(_nextAction == KeepAlive && _state == Disconnected)
- {
- _nextAction = Connect;
- }
- notifyAll();
+ if(_nextAction == Connect && _state == Connected)
+ {
+ _nextAction = KeepAlive;
+ }
+ else if(_nextAction == Disconnect && _state == Disconnected)
+ {
+ _nextAction = None;
+ }
+ else if(_nextAction == KeepAlive && _state == Disconnected)
+ {
+ _nextAction = Connect;
+ }
+ notifyAll();
- //
- // Wait if there's nothing to do and if we are
- // connected or if we've just tried to connect.
- //
- if(_nextAction == None)
- {
- if(_state == Connected || action == Connect || action == KeepAlive)
- {
- IceUtil::Time wakeTime = IceUtil::Time::now() + timeout;
- while(_state != Destroyed && _nextAction == None)
- {
- if(!timedWait(wakeTime - IceUtil::Time::now()))
- {
- break;
- }
- }
- }
- if(_nextAction == None)
- {
- _nextAction = session ? KeepAlive : Connect;
- }
- }
+ //
+ // Wait if there's nothing to do and if we are
+ // connected or if we've just tried to connect.
+ //
+ if(_nextAction == None)
+ {
+ if(_state == Connected || action == Connect || action == KeepAlive)
+ {
+ IceUtil::Time wakeTime = IceUtil::Time::now() + timeout;
+ while(_state != Destroyed && _nextAction == None)
+ {
+ if(!timedWait(wakeTime - IceUtil::Time::now()))
+ {
+ break;
+ }
+ }
+ }
+ if(_nextAction == None)
+ {
+ _nextAction = session ? KeepAlive : Connect;
+ }
+ }
- if(_state == Destroyed)
- {
- break;
- }
-
- assert(_nextAction != None);
-
- action = _nextAction;
- registry = InternalRegistryPrx::uncheckedCast(
- _registry->ice_timeout(static_cast<int>(timeout.toMilliSeconds())));
- _nextAction = None;
- _state = InProgress;
- notifyAll();
- }
+ if(_state == Destroyed)
+ {
+ break;
+ }
+
+ assert(_nextAction != None);
+
+ action = _nextAction;
+ registry = InternalRegistryPrx::uncheckedCast(
+ _registry->ice_timeout(static_cast<int>(timeout.toMilliSeconds())));
+ _nextAction = None;
+ _state = InProgress;
+ notifyAll();
+ }
- switch(action)
- {
- case Connect:
- assert(!session);
- session = createSession(registry, timeout);
- break;
- case Disconnect:
- assert(session);
- destroySession(session);
- session = 0;
- break;
- case KeepAlive:
- assert(session);
- if(!keepAlive(session))
- {
- session = createSession(registry, timeout);
- }
- break;
- case None:
- default:
- assert(false);
- }
- }
-
- //
- // Destroy the session.
- //
- if(_nextAction == Disconnect && session)
- {
- destroySession(session);
- }
+ switch(action)
+ {
+ case Connect:
+ assert(!session);
+ session = createSession(registry, timeout);
+ break;
+ case Disconnect:
+ assert(session);
+ destroySession(session);
+ session = 0;
+ break;
+ case KeepAlive:
+ assert(session);
+ if(!keepAlive(session))
+ {
+ session = createSession(registry, timeout);
+ }
+ break;
+ case None:
+ default:
+ assert(false);
+ }
+ }
+
+ //
+ // Destroy the session.
+ //
+ if(_nextAction == Disconnect && session)
+ {
+ destroySession(session);
+ }
}
virtual bool
waitForCreate()
{
- Lock sync(*this);
- while(_state != Destroyed && _state != Connected)
- {
- wait();
- }
- return _state != Destroyed;
+ Lock sync(*this);
+ while(_state != Destroyed && _state != Connected)
+ {
+ wait();
+ }
+ return _state != Destroyed;
}
virtual void
tryCreateSession(bool waitForTry = true)
{
- {
- Lock sync(*this);
- if(_state == Destroyed)
- {
- return;
- }
+ {
+ Lock sync(*this);
+ if(_state == Destroyed)
+ {
+ return;
+ }
- if(_state == Connected)
- {
- _nextAction = KeepAlive;
- }
- else
- {
- _nextAction = Connect;
- }
- notifyAll();
- }
+ if(_state == Connected)
+ {
+ _nextAction = KeepAlive;
+ }
+ else
+ {
+ _nextAction = Connect;
+ }
+ notifyAll();
+ }
- if(waitForTry)
- {
- Lock sync(*this);
- // Wait until the action is executed and the state changes.
- while(_nextAction == Connect || _nextAction == KeepAlive || _state == InProgress)
- {
- wait();
- }
- }
+ if(waitForTry)
+ {
+ Lock sync(*this);
+ // Wait until the action is executed and the state changes.
+ while(_nextAction == Connect || _nextAction == KeepAlive || _state == InProgress)
+ {
+ wait();
+ }
+ }
}
void
destroyActiveSession()
{
- Lock sync(*this);
- if(_state == Destroyed || _state == Disconnected)
- {
- return;
- }
- _nextAction = Disconnect;
- notifyAll();
+ Lock sync(*this);
+ if(_state == Destroyed || _state == Disconnected)
+ {
+ return;
+ }
+ _nextAction = Disconnect;
+ notifyAll();
}
bool
terminateIfDisconnected()
{
- Lock sync(*this);
- if(_state != Disconnected)
- {
- return false; // Nothing we can do for now.
- }
- assert(_state != Destroyed);
- _state = Destroyed;
- _nextAction = None;
- notifyAll();
- return true;
+ Lock sync(*this);
+ if(_state != Disconnected)
+ {
+ return false; // Nothing we can do for now.
+ }
+ assert(_state != Destroyed);
+ _state = Destroyed;
+ _nextAction = None;
+ notifyAll();
+ return true;
}
void
terminate(bool destroySession = true)
{
- Lock sync(*this);
- if(_state == Destroyed)
- {
- return;
- }
- assert(_state != Destroyed);
- _state = Destroyed;
- _nextAction = destroySession ? Disconnect : None;
- notifyAll();
+ Lock sync(*this);
+ if(_state == Destroyed)
+ {
+ return;
+ }
+ assert(_state != Destroyed);
+ _state = Destroyed;
+ _nextAction = destroySession ? Disconnect : None;
+ notifyAll();
}
TPrx
getSession()
{
- Lock sync(*this);
- return _session;
+ Lock sync(*this);
+ return _session;
}
void
setRegistry(const InternalRegistryPrx& registry)
{
- Lock sync(*this);
- _registry = registry;
+ Lock sync(*this);
+ _registry = registry;
}
InternalRegistryPrx
getRegistry() const
{
- Lock sync(*this);
- return _registry;
+ Lock sync(*this);
+ return _registry;
}
virtual TPrx createSession(InternalRegistryPrx&, IceUtil::Time&) = 0;
diff --git a/cpp/src/IceGrid/SessionServantLocatorI.cpp b/cpp/src/IceGrid/SessionServantLocatorI.cpp
index caebd2890a8..3e37cda4802 100644
--- a/cpp/src/IceGrid/SessionServantLocatorI.cpp
+++ b/cpp/src/IceGrid/SessionServantLocatorI.cpp
@@ -28,7 +28,7 @@ SessionServantLocatorI::locate(const Ice::Current& current, Ice::LocalObjectPtr&
map<Ice::Identity, SessionServant>::const_iterator p = _servants.find(current.id);
if(p == _servants.end() || p->second.connection != current.con)
{
- return 0;
+ return 0;
}
return p->second.servant;
}
@@ -54,7 +54,7 @@ SessionServantLocatorI::add(const Ice::ObjectPtr& servant, const Ice::Connection
id.category = _instanceName;
if(!_servants.insert(make_pair(id, SessionServant(servant, con))).second)
{
- throw Ice::AlreadyRegisteredException(__FILE__, __LINE__, "servant", id.name);
+ throw Ice::AlreadyRegisteredException(__FILE__, __LINE__, "servant", id.name);
}
return _adapter->createProxy(id);
}
diff --git a/cpp/src/IceGrid/SessionServantLocatorI.h b/cpp/src/IceGrid/SessionServantLocatorI.h
index 5dd51f1a2c6..3385a1233db 100644
--- a/cpp/src/IceGrid/SessionServantLocatorI.h
+++ b/cpp/src/IceGrid/SessionServantLocatorI.h
@@ -33,10 +33,10 @@ private:
struct SessionServant
{
- SessionServant(const Ice::ObjectPtr& s, const Ice::ConnectionPtr& con) : servant(s), connection(con) { }
+ SessionServant(const Ice::ObjectPtr& s, const Ice::ConnectionPtr& con) : servant(s), connection(con) { }
- const Ice::ObjectPtr servant;
- const Ice::ConnectionPtr connection;
+ const Ice::ObjectPtr servant;
+ const Ice::ConnectionPtr connection;
};
const Ice::ObjectAdapterPtr _adapter;
diff --git a/cpp/src/IceGrid/Topics.cpp b/cpp/src/IceGrid/Topics.cpp
index 546729cf464..51da20ee1ad 100644
--- a/cpp/src/IceGrid/Topics.cpp
+++ b/cpp/src/IceGrid/Topics.cpp
@@ -22,11 +22,11 @@ ObserverTopic::ObserverTopic(const IceStorm::TopicManagerPrx& topicManager, cons
IceStorm::TopicPrx t;
try
{
- t = topicManager->create(name);
+ t = topicManager->create(name);
}
catch(const IceStorm::TopicExists&)
{
- t = topicManager->retrieve(name);
+ t = topicManager->retrieve(name);
}
//
@@ -48,7 +48,7 @@ ObserverTopic::subscribe(const Ice::ObjectPrx& obsv, const string& name)
Lock sync(*this);
if(!_topic)
{
- return;
+ return;
}
assert(obsv);
@@ -60,15 +60,15 @@ ObserverTopic::subscribe(const Ice::ObjectPrx& obsv, const string& name)
}
catch(const IceStorm::AlreadySubscribed&)
{
- throw ObserverAlreadyRegisteredException(obsv->ice_getIdentity());
+ throw ObserverAlreadyRegisteredException(obsv->ice_getIdentity());
}
if(!name.empty())
{
- assert(_syncSubscribers.find(name) == _syncSubscribers.end());
- _syncSubscribers.insert(name);
- addExpectedUpdate(_serial, name);
- waitForSyncedSubscribersNoSync(_serial, name);
+ assert(_syncSubscribers.find(name) == _syncSubscribers.end());
+ _syncSubscribers.insert(name);
+ addExpectedUpdate(_serial, name);
+ waitForSyncedSubscribersNoSync(_serial, name);
}
}
@@ -78,36 +78,36 @@ ObserverTopic::unsubscribe(const Ice::ObjectPrx& observer, const string& name)
Lock sync(*this);
if(_topic)
{
- _topic->unsubscribe(observer);
+ _topic->unsubscribe(observer);
}
assert(observer);
if(!name.empty())
{
- assert(_syncSubscribers.find(name) != _syncSubscribers.end());
- _syncSubscribers.erase(name);
-
- map<int, set<string> >::iterator p = _waitForUpdates.begin();
- bool notifyMonitor = false;
- while(p != _waitForUpdates.end())
- {
- p->second.erase(name);
- if(p->second.empty())
- {
- _waitForUpdates.erase(p++);
- notifyMonitor = true;
- }
- else
- {
- ++p;
- }
- }
+ assert(_syncSubscribers.find(name) != _syncSubscribers.end());
+ _syncSubscribers.erase(name);
+
+ map<int, set<string> >::iterator p = _waitForUpdates.begin();
+ bool notifyMonitor = false;
+ while(p != _waitForUpdates.end())
+ {
+ p->second.erase(name);
+ if(p->second.empty())
+ {
+ _waitForUpdates.erase(p++);
+ notifyMonitor = true;
+ }
+ else
+ {
+ ++p;
+ }
+ }
- if(notifyMonitor)
- {
- notifyAll();
- }
+ if(notifyMonitor)
+ {
+ notifyAll();
+ }
}
}
@@ -126,24 +126,24 @@ ObserverTopic::receivedUpdate(const string& name, int serial, const string& fail
map<int, set<string> >::iterator p = _waitForUpdates.find(serial);
if(p != _waitForUpdates.end())
{
- p->second.erase(name);
-
- if(!failure.empty())
- {
- map<int, map<string, string> >::iterator q = _updateFailures.find(serial);
- if(q == _updateFailures.end())
- {
- q = _updateFailures.insert(make_pair(serial, map<string ,string>())).first;
- }
- q->second.insert(make_pair(name, failure));
- }
+ p->second.erase(name);
+
+ if(!failure.empty())
+ {
+ map<int, map<string, string> >::iterator q = _updateFailures.find(serial);
+ if(q == _updateFailures.end())
+ {
+ q = _updateFailures.insert(make_pair(serial, map<string ,string>())).first;
+ }
+ q->second.insert(make_pair(name, failure));
+ }
- if(p->second.empty())
- {
- _waitForUpdates.erase(p);
- }
+ if(p->second.empty())
+ {
+ _waitForUpdates.erase(p);
+ }
- notifyAll();
+ notifyAll();
}
}
@@ -159,18 +159,18 @@ ObserverTopic::addExpectedUpdate(int serial, const string& name)
{
if(_syncSubscribers.empty() && name.empty())
{
- return;
+ return;
}
// Must be called with the lock held.
if(name.empty())
{
- assert(_waitForUpdates[serial].empty());
- _waitForUpdates[serial] = _syncSubscribers;
+ assert(_waitForUpdates[serial].empty());
+ _waitForUpdates[serial] = _syncSubscribers;
}
else
{
- _waitForUpdates[serial].insert(name);
+ _waitForUpdates[serial].insert(name);
}
}
@@ -179,7 +179,7 @@ ObserverTopic::waitForSyncedSubscribersNoSync(int serial, const string& name)
{
if(serial < 0)
{
- return;
+ return;
}
//
@@ -187,33 +187,33 @@ ObserverTopic::waitForSyncedSubscribersNoSync(int serial, const string& name)
//
while(true)
{
- map<int, set<string> >::const_iterator p = _waitForUpdates.find(serial);
- if(p == _waitForUpdates.end())
- {
- map<int, map<string, string> >::iterator q = _updateFailures.find(serial);
- if(q != _updateFailures.end())
- {
- map<string, string> failures = q->second;
- _updateFailures.erase(q);
- ostringstream os;
- for(map<string, string>::const_iterator r = failures.begin(); r != failures.end(); ++r)
- {
- os << "replication failed on replica `" << r->first << "':\n" << r->second << "\n";
- }
-
- Ice::Error err(_logger);
- err << os.str();
- }
- return;
- }
- else
- {
- if(!name.empty() && p->second.find(name) == p->second.end())
- {
- return;
- }
- wait();
- }
+ map<int, set<string> >::const_iterator p = _waitForUpdates.find(serial);
+ if(p == _waitForUpdates.end())
+ {
+ map<int, map<string, string> >::iterator q = _updateFailures.find(serial);
+ if(q != _updateFailures.end())
+ {
+ map<string, string> failures = q->second;
+ _updateFailures.erase(q);
+ ostringstream os;
+ for(map<string, string>::const_iterator r = failures.begin(); r != failures.end(); ++r)
+ {
+ os << "replication failed on replica `" << r->first << "':\n" << r->second << "\n";
+ }
+
+ Ice::Error err(_logger);
+ err << os.str();
+ }
+ return;
+ }
+ else
+ {
+ if(!name.empty() && p->second.find(name) == p->second.end())
+ {
+ return;
+ }
+ wait();
+ }
}
}
@@ -247,18 +247,18 @@ RegistryObserverTopic::registryUp(const RegistryInfo& info)
Lock sync(*this);
if(!_topic)
{
- return;
+ return;
}
updateSerial(_serial + 1);
_registries.insert(make_pair(info.name, info));
try
{
- _publisher->registryUp(info);
+ _publisher->registryUp(info);
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `registryUp' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `registryUp' update:\n" << ex;
}
}
@@ -268,24 +268,24 @@ RegistryObserverTopic::registryDown(const string& name)
Lock sync(*this);
if(!_topic)
{
- return;
+ return;
}
if(_registries.find(name) == _registries.end())
{
- return;
+ return;
}
updateSerial(_serial + 1);
_registries.erase(name);
try
{
- _publisher->registryDown(name);
+ _publisher->registryDown(name);
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `registryDown' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `registryDown' update:\n" << ex;
}
}
@@ -297,19 +297,19 @@ RegistryObserverTopic::initObserver(const Ice::ObjectPrx& obsv)
registries.reserve(_registries.size());
for(map<string, RegistryInfo>::const_iterator p = _registries.begin(); p != _registries.end(); ++p)
{
- registries.push_back(p->second);
+ registries.push_back(p->second);
}
observer->registryInit(registries, getContext(_serial));
}
NodeObserverTopic::NodeObserverTopic(const IceStorm::TopicManagerPrx& topicManager,
- const Ice::ObjectAdapterPtr& adapter) :
+ const Ice::ObjectAdapterPtr& adapter) :
ObserverTopic(topicManager, "NodeObserver")
{
const_cast<NodeObserverPrx&>(_publisher) = NodeObserverPrx::uncheckedCast(_basePublisher);
try
{
- const_cast<NodeObserverPrx&>(_externalPublisher) = NodeObserverPrx::uncheckedCast(adapter->addWithUUID(this));
+ const_cast<NodeObserverPrx&>(_externalPublisher) = NodeObserverPrx::uncheckedCast(adapter->addWithUUID(this));
}
catch(const Ice::LocalException&)
{
@@ -328,18 +328,18 @@ NodeObserverTopic::nodeUp(const NodeDynamicInfo& info, const Ice::Current& curre
Lock sync(*this);
if(!_topic)
{
- return;
+ return;
}
updateSerial(_serial + 1);
_nodes.insert(make_pair(info.info.name, info));
try
{
- _publisher->nodeUp(info);
+ _publisher->nodeUp(info);
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing 'nodeUp' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing 'nodeUp' update:\n" << ex;
}
}
@@ -355,15 +355,15 @@ NodeObserverTopic::updateServer(const string& node, const ServerDynamicInfo& ser
Lock sync(*this);
if(!_topic)
{
- return;
+ return;
}
if(_nodes.find(node) == _nodes.end())
{
- //
- // If the node isn't known anymore, we ignore the update.
- //
- return;
+ //
+ // If the node isn't known anymore, we ignore the update.
+ //
+ return;
}
updateSerial(_serial + 1);
@@ -372,33 +372,33 @@ NodeObserverTopic::updateServer(const string& node, const ServerDynamicInfo& ser
ServerDynamicInfoSeq::iterator p = servers.begin();
while(p != servers.end())
{
- if(p->id == server.id)
- {
- if(server.state == Destroyed || (server.state == Inactive && server.enabled))
- {
- servers.erase(p);
- }
- else
- {
- *p = server;
- }
- break;
- }
- ++p;
+ if(p->id == server.id)
+ {
+ if(server.state == Destroyed || (server.state == Inactive && server.enabled))
+ {
+ servers.erase(p);
+ }
+ else
+ {
+ *p = server;
+ }
+ break;
+ }
+ ++p;
}
if(server.state != Destroyed && (server.state != Inactive || !server.enabled) && p == servers.end())
{
- servers.push_back(server);
+ servers.push_back(server);
}
try
{
- _publisher->updateServer(node, server);
+ _publisher->updateServer(node, server);
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `updateServer' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `updateServer' update:\n" << ex;
}
}
@@ -408,15 +408,15 @@ NodeObserverTopic::updateAdapter(const string& node, const AdapterDynamicInfo& a
Lock sync(*this);
if(!_topic)
{
- return;
+ return;
}
if(_nodes.find(node) == _nodes.end())
{
- //
- // If the node isn't known anymore, we ignore the update.
- //
- return;
+ //
+ // If the node isn't known anymore, we ignore the update.
+ //
+ return;
}
updateSerial(_serial + 1);
@@ -425,33 +425,33 @@ NodeObserverTopic::updateAdapter(const string& node, const AdapterDynamicInfo& a
AdapterDynamicInfoSeq::iterator p = adapters.begin();
while(p != adapters.end())
{
- if(p->id == adapter.id)
- {
- if(adapter.proxy)
- {
- *p = adapter;
- }
- else
- {
- adapters.erase(p);
- }
- break;
- }
- ++p;
+ if(p->id == adapter.id)
+ {
+ if(adapter.proxy)
+ {
+ *p = adapter;
+ }
+ else
+ {
+ adapters.erase(p);
+ }
+ break;
+ }
+ ++p;
}
if(adapter.proxy && p == adapters.end())
{
- adapters.push_back(adapter);
+ adapters.push_back(adapter);
}
try
{
- _publisher->updateAdapter(node, adapter);
+ _publisher->updateAdapter(node, adapter);
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `updateAdapter' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `updateAdapter' update:\n" << ex;
}
}
@@ -461,23 +461,23 @@ NodeObserverTopic::nodeDown(const string& name)
Lock sync(*this);
if(!_topic)
{
- return;
+ return;
}
updateSerial(_serial + 1);
if(_nodes.find(name) != _nodes.end())
{
- _nodes.erase(name);
- try
- {
- _publisher->nodeDown(name);
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `nodeDown' update:\n" << ex;
- }
+ _nodes.erase(name);
+ try
+ {
+ _publisher->nodeDown(name);
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `nodeDown' update:\n" << ex;
+ }
}
}
@@ -489,13 +489,13 @@ NodeObserverTopic::initObserver(const Ice::ObjectPrx& obsv)
nodes.reserve(_nodes.size());
for(map<string, NodeDynamicInfo>::const_iterator p = _nodes.begin(); p != _nodes.end(); ++p)
{
- nodes.push_back(p->second);
+ nodes.push_back(p->second);
}
observer->nodeInit(nodes, getContext(_serial));
}
ApplicationObserverTopic::ApplicationObserverTopic(const IceStorm::TopicManagerPrx& topicManager,
- const StringApplicationInfoDict& applications) :
+ const StringApplicationInfoDict& applications) :
ObserverTopic(topicManager, "ApplicationObserver")
#ifndef _RWSTD_NO_MEMBER_TEMPLATES
,_applications(applications.begin(), applications.end())
@@ -504,7 +504,7 @@ ApplicationObserverTopic::ApplicationObserverTopic(const IceStorm::TopicManagerP
#ifdef _RWSTD_NO_MEMBER_TEMPLATES
for(StringApplicationInfoDict::const_iterator p = applications.begin(); p != applications.end(); ++p)
{
- _applications[p->first] = p->second;
+ _applications[p->first] = p->second;
}
#endif
@@ -517,22 +517,22 @@ ApplicationObserverTopic::applicationInit(int serial, const ApplicationInfoSeq&
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(serial);
_applications.clear();
for(ApplicationInfoSeq::const_iterator p = apps.begin(); p != apps.end(); ++p)
{
- _applications.insert(make_pair(p->descriptor.name, *p));
+ _applications.insert(make_pair(p->descriptor.name, *p));
}
try
{
- _publisher->applicationInit(serial, apps, getContext(serial));
+ _publisher->applicationInit(serial, apps, getContext(serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `applicationInit' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `applicationInit' update:\n" << ex;
}
addExpectedUpdate(serial);
return serial;
@@ -544,19 +544,19 @@ ApplicationObserverTopic::applicationAdded(int serial, const ApplicationInfo& in
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(serial);
_applications.insert(make_pair(info.descriptor.name, info));
try
{
- _publisher->applicationAdded(serial, info, getContext(serial));
+ _publisher->applicationAdded(serial, info, getContext(serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `applicationAdded' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `applicationAdded' update:\n" << ex;
}
addExpectedUpdate(serial);
return serial;
@@ -568,18 +568,18 @@ ApplicationObserverTopic::applicationRemoved(int serial, const string& name)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(serial);
_applications.erase(name);
try
{
- _publisher->applicationRemoved(serial, name, getContext(serial));
+ _publisher->applicationRemoved(serial, name, getContext(serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `applicationRemoved' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `applicationRemoved' update:\n" << ex;
}
addExpectedUpdate(serial);
return serial;
@@ -591,49 +591,49 @@ ApplicationObserverTopic::applicationUpdated(int serial, const ApplicationUpdate
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(serial);
try
{
- map<string, ApplicationInfo>::iterator p = _applications.find(info.descriptor.name);
- if(p != _applications.end())
- {
- ApplicationHelper helper(_publisher->ice_getCommunicator(), p->second.descriptor);
- p->second.descriptor = helper.update(info.descriptor);
- p->second.updateTime = info.updateTime;
- p->second.updateUser = info.updateUser;
- p->second.revision = info.revision;
- }
+ map<string, ApplicationInfo>::iterator p = _applications.find(info.descriptor.name);
+ if(p != _applications.end())
+ {
+ ApplicationHelper helper(_publisher->ice_getCommunicator(), p->second.descriptor);
+ p->second.descriptor = helper.update(info.descriptor);
+ p->second.updateTime = info.updateTime;
+ p->second.updateUser = info.updateUser;
+ p->second.revision = info.revision;
+ }
}
catch(const DeploymentException& ex)
{
- cerr << ex.reason << endl;
- assert(false);
+ cerr << ex.reason << endl;
+ assert(false);
}
catch(const std::string& msg)
{
- cerr << msg << endl;
- assert(false);
+ cerr << msg << endl;
+ assert(false);
}
catch(const char* msg)
{
- cerr << msg << endl;
- assert(false);
+ cerr << msg << endl;
+ assert(false);
}
catch(...)
{
- assert(false);
+ assert(false);
}
try
{
- _publisher->applicationUpdated(serial, info, getContext(serial));
+ _publisher->applicationUpdated(serial, info, getContext(serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `applicationUpdated' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `applicationUpdated' update:\n" << ex;
}
addExpectedUpdate(serial);
return serial;
@@ -646,13 +646,13 @@ ApplicationObserverTopic::initObserver(const Ice::ObjectPrx& obsv)
ApplicationInfoSeq applications;
for(map<string, ApplicationInfo>::const_iterator p = _applications.begin(); p != _applications.end(); ++p)
{
- applications.push_back(p->second);
+ applications.push_back(p->second);
}
observer->applicationInit(_serial, applications, getContext(_serial));
}
AdapterObserverTopic::AdapterObserverTopic(const IceStorm::TopicManagerPrx& topicManager,
- const StringAdapterInfoDict& adapters) :
+ const StringAdapterInfoDict& adapters) :
ObserverTopic(topicManager, "AdapterObserver")
#ifndef _RWSTD_NO_MEMBER_TEMPLATES
, _adapters(adapters.begin(), adapters.end())
@@ -674,22 +674,22 @@ AdapterObserverTopic::adapterInit(const AdapterInfoSeq& adpts)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
_adapters.clear();
for(AdapterInfoSeq::const_iterator q = adpts.begin(); q != adpts.end(); ++q)
{
- _adapters.insert(make_pair(q->id, *q));
+ _adapters.insert(make_pair(q->id, *q));
}
try
{
- _publisher->adapterInit(adpts, getContext(_serial));
+ _publisher->adapterInit(adpts, getContext(_serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `adapterInit' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `adapterInit' update:\n" << ex;
}
addExpectedUpdate(_serial);
return _serial;
@@ -701,18 +701,18 @@ AdapterObserverTopic::adapterAdded(const AdapterInfo& info)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
_adapters.insert(make_pair(info.id, info));
try
{
- _publisher->adapterAdded(info, getContext(_serial));
+ _publisher->adapterAdded(info, getContext(_serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `adapterAdded' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `adapterAdded' update:\n" << ex;
}
addExpectedUpdate(_serial);
return _serial;
@@ -724,18 +724,18 @@ AdapterObserverTopic::adapterUpdated(const AdapterInfo& info)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
_adapters[info.id] = info;
try
{
- _publisher->adapterUpdated(info, getContext(_serial));
+ _publisher->adapterUpdated(info, getContext(_serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `adapterUpdated' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `adapterUpdated' update:\n" << ex;
}
addExpectedUpdate(_serial);
return _serial;
@@ -747,18 +747,18 @@ AdapterObserverTopic::adapterRemoved(const string& id)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
_adapters.erase(id);
try
{
- _publisher->adapterRemoved(id, getContext(_serial));
+ _publisher->adapterRemoved(id, getContext(_serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `adapterRemoved' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `adapterRemoved' update:\n" << ex;
}
addExpectedUpdate(_serial);
return _serial;
@@ -771,13 +771,13 @@ AdapterObserverTopic::initObserver(const Ice::ObjectPrx& obsv)
AdapterInfoSeq adapters;
for(map<string, AdapterInfo>::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
{
- adapters.push_back(p->second);
- }
+ adapters.push_back(p->second);
+ }
observer->adapterInit(adapters, getContext(_serial));
}
ObjectObserverTopic::ObjectObserverTopic(const IceStorm::TopicManagerPrx& topicManager,
- const IdentityObjectInfoDict& objects) :
+ const IdentityObjectInfoDict& objects) :
ObserverTopic(topicManager, "ObjectObserver")
#ifndef _RWSTD_NO_MEMBER_TEMPLATES
, _objects(objects.begin(), objects.end())
@@ -799,22 +799,22 @@ ObjectObserverTopic::objectInit(const ObjectInfoSeq& objects)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
_objects.clear();
for(ObjectInfoSeq::const_iterator r = objects.begin(); r != objects.end(); ++r)
{
- _objects.insert(make_pair(r->proxy->ice_getIdentity(), *r));
+ _objects.insert(make_pair(r->proxy->ice_getIdentity(), *r));
}
try
{
- _publisher->objectInit(objects, getContext(_serial));
+ _publisher->objectInit(objects, getContext(_serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `objectInit' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `objectInit' update:\n" << ex;
}
addExpectedUpdate(_serial);
return _serial;
@@ -826,18 +826,18 @@ ObjectObserverTopic::objectAdded(const ObjectInfo& info)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
_objects.insert(make_pair(info.proxy->ice_getIdentity(), info));
try
{
- _publisher->objectAdded(info, getContext(_serial));
+ _publisher->objectAdded(info, getContext(_serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `objectAdded' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `objectAdded' update:\n" << ex;
}
addExpectedUpdate(_serial);
return _serial;
@@ -849,18 +849,18 @@ ObjectObserverTopic::objectUpdated(const ObjectInfo& info)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
_objects[info.proxy->ice_getIdentity()] = info;
try
{
- _publisher->objectUpdated(info, getContext(_serial));
+ _publisher->objectUpdated(info, getContext(_serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `objectUpdated' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `objectUpdated' update:\n" << ex;
}
addExpectedUpdate(_serial);
return _serial;
@@ -872,18 +872,18 @@ ObjectObserverTopic::objectRemoved(const Ice::Identity& id)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
_objects.erase(id);
try
{
- _publisher->objectRemoved(id, getContext(_serial));
+ _publisher->objectRemoved(id, getContext(_serial));
}
catch(const Ice::LocalException& ex)
{
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `objectRemoved' update:\n" << ex;
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `objectRemoved' update:\n" << ex;
}
addExpectedUpdate(_serial);
return _serial;
@@ -895,39 +895,39 @@ ObjectObserverTopic::objectsAddedOrUpdated(const ObjectInfoSeq& infos)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
for(ObjectInfoSeq::const_iterator p = infos.begin(); p != infos.end(); ++p)
{
- map<Ice::Identity, ObjectInfo>::iterator q = _objects.find(p->proxy->ice_getIdentity());
- if(q != _objects.end())
- {
- q->second = *p;
- try
- {
- _publisher->objectUpdated(*p, getContext(_serial));
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `objectUpdated' update:\n" << ex;
- }
- }
- else
- {
- _objects.insert(make_pair(p->proxy->ice_getIdentity(), *p));
- try
- {
- _publisher->objectAdded(*p, getContext(_serial));
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `objectAdded' update:\n" << ex;
- }
- }
+ map<Ice::Identity, ObjectInfo>::iterator q = _objects.find(p->proxy->ice_getIdentity());
+ if(q != _objects.end())
+ {
+ q->second = *p;
+ try
+ {
+ _publisher->objectUpdated(*p, getContext(_serial));
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `objectUpdated' update:\n" << ex;
+ }
+ }
+ else
+ {
+ _objects.insert(make_pair(p->proxy->ice_getIdentity(), *p));
+ try
+ {
+ _publisher->objectAdded(*p, getContext(_serial));
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `objectAdded' update:\n" << ex;
+ }
+ }
}
//
@@ -945,22 +945,22 @@ ObjectObserverTopic::objectsRemoved(const ObjectInfoSeq& infos)
Lock sync(*this);
if(!_topic)
{
- return -1;
+ return -1;
}
updateSerial(_serial + 1);
for(ObjectInfoSeq::const_iterator p = infos.begin(); p != infos.end(); ++p)
{
- _objects.erase(p->proxy->ice_getIdentity());
- try
- {
- _publisher->objectRemoved(p->proxy->ice_getIdentity(), getContext(_serial));
- }
- catch(const Ice::LocalException& ex)
- {
- Ice::Warning out(_logger);
- out << "unexpected exception while publishing `objectUpdated' update:\n" << ex;
- }
+ _objects.erase(p->proxy->ice_getIdentity());
+ try
+ {
+ _publisher->objectRemoved(p->proxy->ice_getIdentity(), getContext(_serial));
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ Ice::Warning out(_logger);
+ out << "unexpected exception while publishing `objectUpdated' update:\n" << ex;
+ }
}
//
@@ -980,7 +980,7 @@ ObjectObserverTopic::initObserver(const Ice::ObjectPrx& obsv)
ObjectInfoSeq objects;
for(map<Ice::Identity, ObjectInfo>::const_iterator p = _objects.begin(); p != _objects.end(); ++p)
{
- objects.push_back(p->second);
+ objects.push_back(p->second);
}
observer->objectInit(objects, getContext(_serial));
}
diff --git a/cpp/src/IceGrid/Util.cpp b/cpp/src/IceGrid/Util.cpp
index 2a36351e916..f955fe69e4c 100644
--- a/cpp/src/IceGrid/Util.cpp
+++ b/cpp/src/IceGrid/Util.cpp
@@ -24,12 +24,12 @@ IceGrid::toString(const vector<string>& v, const string& sep)
Ice::StringSeq::const_iterator p = v.begin();
while(p != v.end())
{
- os << *p;
- ++p;
- if(p != v.end())
- {
- os << sep;
- }
+ os << *p;
+ ++p;
+ if(p != v.end())
+ {
+ os << sep;
+ }
}
return os.str();
}
@@ -40,22 +40,22 @@ IceGrid::toString(const Ice::Exception& exception)
std::ostringstream os;
try
{
- exception.ice_throw();
+ exception.ice_throw();
}
catch(const NodeUnreachableException& ex)
{
- os << ex << ":";
- os << "\nnode: " << ex.name;
- os << "\nreason: " << ex.reason;
+ os << ex << ":";
+ os << "\nnode: " << ex.name;
+ os << "\nreason: " << ex.reason;
}
catch(const DeploymentException& ex)
{
- os << ex << ":";
- os << "\nreason: " << ex.reason;
+ os << ex << ":";
+ os << "\nreason: " << ex.reason;
}
catch(const Ice::Exception& ex)
{
- os << ex;
+ os << ex;
}
return os.str();
}
@@ -65,10 +65,10 @@ IceGrid::getProperty(const PropertyDescriptorSeq& properties, const string& name
{
for(PropertyDescriptorSeq::const_iterator q = properties.begin(); q != properties.end(); ++q)
{
- if(q->name == name)
- {
- return q->value;
- }
+ if(q->name == name)
+ {
+ return q->value;
+ }
}
return def;
}
@@ -97,23 +97,23 @@ IceGrid::getMMVersion(const string& o)
if(minorPos != 1 && minorPos != 2)
{
- return -1;
+ return -1;
}
if(patchPos != string::npos)
{
- if((minorPos == 1 && patchPos != 3 && patchPos != 4) || (minorPos == 2 && patchPos != 4 && patchPos != 5))
- {
- return -1;
- }
- else if((version.size() - patchPos - 1) > 2)
- {
- return -1;
- }
+ if((minorPos == 1 && patchPos != 3 && patchPos != 4) || (minorPos == 2 && patchPos != 4 && patchPos != 5))
+ {
+ return -1;
+ }
+ else if((version.size() - patchPos - 1) > 2)
+ {
+ return -1;
+ }
}
else if((version.size() - minorPos - 1) > 2)
{
- return -1;
+ return -1;
}
int v, ver;
@@ -122,7 +122,7 @@ IceGrid::getMMVersion(const string& o)
major >> v;
if(major.fail() || v > 99 || v < 1)
{
- return -1;
+ return -1;
}
ver = v;
ver *= 100;
@@ -131,7 +131,7 @@ IceGrid::getMMVersion(const string& o)
minor >> v;
if(minor.fail() || v > 99 || v < 0)
{
- return -1;
+ return -1;
}
ver += v;
ver *= 100;
@@ -142,13 +142,13 @@ IceGrid::getMMVersion(const string& o)
//
// if(patchPos != string::npos)
// {
-// istringstream patch(version.substr(patchPos + 1));
-// patch >> v;
-// if(patch.fail() || v > 99 || v < 0)
-// {
-// return -1;
-// }
-// ver += v;
+// istringstream patch(version.substr(patchPos + 1));
+// patch >> v;
+// if(patch.fail() || v > 99 || v < 0)
+// {
+// return -1;
+// }
+// ver += v;
// }
return ver;
diff --git a/cpp/src/IceGrid/Util.h b/cpp/src/IceGrid/Util.h
index b3a2d7839dd..918ac4011a9 100644
--- a/cpp/src/IceGrid/Util.h
+++ b/cpp/src/IceGrid/Util.h
@@ -56,19 +56,19 @@ struct ForEachCommunicator : std::unary_function<CommunicatorDescriptorPtr&, voi
void
operator()(const ServiceInstanceDescriptor& descriptor)
{
- assert(descriptor.descriptor);
- operator()(descriptor.descriptor);
+ assert(descriptor.descriptor);
+ operator()(descriptor.descriptor);
}
void
operator()(const CommunicatorDescriptorPtr& descriptor)
{
- _function(descriptor);
- IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(descriptor);
- if(iceBox)
- {
- for_each(iceBox->services.begin(), iceBox->services.end(), forEachCommunicator(_function));
- }
+ _function(descriptor);
+ IceBoxDescriptorPtr iceBox = IceBoxDescriptorPtr::dynamicCast(descriptor);
+ if(iceBox)
+ {
+ for_each(iceBox->services.begin(), iceBox->services.end(), forEachCommunicator(_function));
+ }
}
Function _function;
@@ -92,7 +92,7 @@ public:
explicit ObjFunc(T& obj, void (T::*f)(A)) : _obj(obj), _mfn(f) { }
void operator()(A arg) const
{
- (_obj.*_mfn)(arg);
+ (_obj.*_mfn)(arg);
}
};
@@ -108,10 +108,10 @@ inline getMatchingKeys(const T& m, const std::string& expression)
std::vector<std::string> keys;
for(typename T::const_iterator p = m.begin(); p != m.end(); ++p)
{
- if(expression.empty() || IceUtil::match(p->first, expression, true))
- {
- keys.push_back(p->first);
- }
+ if(expression.empty() || IceUtil::match(p->first, expression, true))
+ {
+ keys.push_back(p->first);
+ }
}
return keys;
}
diff --git a/cpp/src/IceGrid/WaitQueue.cpp b/cpp/src/IceGrid/WaitQueue.cpp
index 24b7d9ccfba..06e18766558 100644
--- a/cpp/src/IceGrid/WaitQueue.cpp
+++ b/cpp/src/IceGrid/WaitQueue.cpp
@@ -42,74 +42,74 @@ WaitQueue::run()
{
while(true)
{
- list<WaitItemPtr> expired;
- {
- Lock sync(*this);
- if(_waitQueue.empty() && !_destroyed)
- {
- wait();
- }
-
- if(_destroyed)
- {
- break;
- }
-
- //
- // Notify expired items.
- //
- while(!_waitQueue.empty() && !_destroyed)
- {
- WaitItemPtr item = _waitQueue.front();
- if(item->getExpirationTime() <= IceUtil::Time::now())
- {
- expired.push_back(item);
- _waitQueue.pop_front();
- }
- else if(!expired.empty())
- {
- break;
- }
- else
- {
- //
- // Wait until the next item expire or a notification. Note: in any case we
- // get out of this loop to get a chance to execute the work queue.
- //
- timedWait(item->getExpirationTime() - IceUtil::Time::now());
- }
- }
- }
-
- if(!expired.empty())
- {
- for(list<WaitItemPtr>::iterator p = expired.begin(); p != expired.end(); ++p)
- {
- try
- {
- (*p)->expired(false);
- }
- catch(const Ice::LocalException&)
- {
- //
- // TODO: Add some tracing.
- //
- }
- }
- }
-
- if(_destroyed)
- {
- break;
- }
+ list<WaitItemPtr> expired;
+ {
+ Lock sync(*this);
+ if(_waitQueue.empty() && !_destroyed)
+ {
+ wait();
+ }
+
+ if(_destroyed)
+ {
+ break;
+ }
+
+ //
+ // Notify expired items.
+ //
+ while(!_waitQueue.empty() && !_destroyed)
+ {
+ WaitItemPtr item = _waitQueue.front();
+ if(item->getExpirationTime() <= IceUtil::Time::now())
+ {
+ expired.push_back(item);
+ _waitQueue.pop_front();
+ }
+ else if(!expired.empty())
+ {
+ break;
+ }
+ else
+ {
+ //
+ // Wait until the next item expire or a notification. Note: in any case we
+ // get out of this loop to get a chance to execute the work queue.
+ //
+ timedWait(item->getExpirationTime() - IceUtil::Time::now());
+ }
+ }
+ }
+
+ if(!expired.empty())
+ {
+ for(list<WaitItemPtr>::iterator p = expired.begin(); p != expired.end(); ++p)
+ {
+ try
+ {
+ (*p)->expired(false);
+ }
+ catch(const Ice::LocalException&)
+ {
+ //
+ // TODO: Add some tracing.
+ //
+ }
+ }
+ }
+
+ if(_destroyed)
+ {
+ break;
+ }
}
if(!_waitQueue.empty())
{
- for(list<WaitItemPtr>::iterator p = _waitQueue.begin(); p != _waitQueue.end(); ++p)
- {
- (*p)->expired(true);
- }
+ for(list<WaitItemPtr>::iterator p = _waitQueue.begin(); p != _waitQueue.end(); ++p)
+ {
+ (*p)->expired(true);
+ }
}
_waitQueue.clear(); // Break cyclic reference counts.
}
@@ -118,9 +118,9 @@ void
WaitQueue::destroy()
{
{
- Lock sync(*this);
- _destroyed = true;
- notify();
+ Lock sync(*this);
+ _destroyed = true;
+ notify();
}
getThreadControl().join();
@@ -132,7 +132,7 @@ WaitQueue::add(const WaitItemPtr& item, const IceUtil::Time& wait)
Lock sync(*this);
if(_destroyed)
{
- return;
+ return;
}
//
@@ -146,17 +146,17 @@ WaitQueue::add(const WaitItemPtr& item, const IceUtil::Time& wait)
list<WaitItemPtr>::iterator p = _waitQueue.begin();
while(p != _waitQueue.end())
{
- if((*p)->getExpirationTime() >= expire)
- {
- break;
- }
- ++p;
+ if((*p)->getExpirationTime() >= expire)
+ {
+ break;
+ }
+ ++p;
}
_waitQueue.insert(p, item);
if(notifyThread)
{
- notify();
+ notify();
}
}
@@ -167,12 +167,12 @@ WaitQueue::remove(const WaitItemPtr& item)
list<WaitItemPtr>::iterator p = _waitQueue.begin();
while(p != _waitQueue.end())
{
- if((*p).get() == item.get())
- {
- _waitQueue.erase(p);
- return true;
- }
- ++p;
+ if((*p).get() == item.get())
+ {
+ _waitQueue.erase(p);
+ return true;
+ }
+ ++p;
}
return false;
}
diff --git a/cpp/src/IceGrid/WellKnownObjectsManager.cpp b/cpp/src/IceGrid/WellKnownObjectsManager.cpp
index 44cd4adc872..c3aae53a5a2 100644
--- a/cpp/src/IceGrid/WellKnownObjectsManager.cpp
+++ b/cpp/src/IceGrid/WellKnownObjectsManager.cpp
@@ -48,7 +48,7 @@ WellKnownObjectsManager::registerAll(const ReplicaSessionPrx& session)
{
if(!initialized())
{
- return;
+ return;
}
assert(session);
@@ -65,7 +65,7 @@ WellKnownObjectsManager::registerAll()
{
if(!initialized())
{
- return;
+ return;
}
//
@@ -80,7 +80,7 @@ WellKnownObjectsManager::updateReplicatedWellKnownObjects()
{
if(!initialized())
{
- return;
+ return;
}
//
diff --git a/cpp/src/IcePatch2/Calc.cpp b/cpp/src/IcePatch2/Calc.cpp
index 33b76fdee44..01947ac9d75 100644
--- a/cpp/src/IcePatch2/Calc.cpp
+++ b/cpp/src/IcePatch2/Calc.cpp
@@ -25,7 +25,7 @@ struct FileInfoPathLess: public binary_function<const FileInfo&, const FileInfo&
bool
operator()(const FileInfo& lhs, const FileInfo& rhs)
{
- return lhs.path < rhs.path;
+ return lhs.path < rhs.path;
}
};
@@ -34,20 +34,20 @@ struct IFileInfoPathEqual: public binary_function<const FileInfo&, const FileInf
bool
operator()(const FileInfo& lhs, const FileInfo& rhs)
{
- if(lhs.path.size() != rhs.path.size())
- {
- return false;
- }
-
- for(string::size_type i = 0; i < lhs.path.size(); ++i)
- {
- if(::tolower(lhs.path[i]) != ::tolower(rhs.path[i]))
- {
- return false;
- }
- }
-
- return true;
+ if(lhs.path.size() != rhs.path.size())
+ {
+ return false;
+ }
+
+ for(string::size_type i = 0; i < lhs.path.size(); ++i)
+ {
+ if(::tolower(lhs.path[i]) != ::tolower(rhs.path[i]))
+ {
+ return false;
+ }
+ }
+
+ return true;
}
};
@@ -56,18 +56,18 @@ struct IFileInfoPathLess: public binary_function<const FileInfo&, const FileInfo
bool
operator()(const FileInfo& lhs, const FileInfo& rhs)
{
- for(string::size_type i = 0; i < lhs.path.size() && i < rhs.path.size(); ++i)
- {
- if(::tolower(lhs.path[i]) < ::tolower(rhs.path[i]))
- {
- return true;
- }
- else if(::tolower(lhs.path[i]) > ::tolower(rhs.path[i]))
- {
- return false;
- }
- }
- return lhs.path.size() < rhs.path.size();
+ for(string::size_type i = 0; i < lhs.path.size() && i < rhs.path.size(); ++i)
+ {
+ if(::tolower(lhs.path[i]) < ::tolower(rhs.path[i]))
+ {
+ return true;
+ }
+ else if(::tolower(lhs.path[i]) > ::tolower(rhs.path[i]))
+ {
+ return false;
+ }
+ }
+ return lhs.path.size() < rhs.path.size();
}
};
@@ -78,22 +78,22 @@ public:
virtual bool
remove(const string& path)
{
- cout << "removing: " << path << endl;
- return true;
+ cout << "removing: " << path << endl;
+ return true;
}
virtual bool
checksum(const string& path)
{
- cout << "checksum: " << path << endl;
- return true;
+ cout << "checksum: " << path << endl;
+ return true;
}
virtual bool
compress(const string& path)
{
- cout << "compress: " << path << endl;
- return true;
+ cout << "compress: " << path << endl;
+ return true;
}
};
@@ -132,32 +132,32 @@ main(int argc, char* argv[])
vector<string> args;
try
{
- args = opts.parse(argc, (const char**)argv);
+ args = opts.parse(argc, (const char**)argv);
}
catch(const IceUtil::BadOptException& e)
{
cerr << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(argv[0]);
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
bool doCompress = opts.isSet("compress");
bool dontCompress = opts.isSet("no-compress");
if(doCompress && dontCompress)
{
cerr << argv[0] << ": only one of -z and -Z are mutually exclusive" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(doCompress)
{
@@ -185,120 +185,120 @@ main(int argc, char* argv[])
try
{
- StringSeq::iterator p;
- string absDataDir = dataDir;
+ StringSeq::iterator p;
+ string absDataDir = dataDir;
- string cwd;
- if(OS::getcwd(cwd) != 0)
- {
- throw "cannot get the current directory:\n" + lastError();
- }
-
- if(!isAbsolute(absDataDir))
- {
- absDataDir = simplify(cwd + '/' + absDataDir);
- }
-
- for(p = fileSeq.begin(); p != fileSeq.end(); ++p)
- {
- if(!isAbsolute(*p))
- {
- *p = cwd + '/' + *p;
- }
- }
-
- //
- // We must call simplify() here: under Cygwin, any path starting with
- // a double slash simply doesn't work. But, if dataDir is "/", we end
- // up with paths that start with "//" unless we call simplify().
- //
- string absDataDirWithSlash = simplify(absDataDir + '/');
-
- for(p = fileSeq.begin(); p != fileSeq.end(); ++p)
- {
- if(p->compare(0, absDataDirWithSlash.size(), absDataDirWithSlash) != 0)
- {
- throw "`" + *p + "' is not a path in `" + dataDir + "'";
- }
-
- p->erase(0, absDataDirWithSlash.size());
- }
+ string cwd;
+ if(OS::getcwd(cwd) != 0)
+ {
+ throw "cannot get the current directory:\n" + lastError();
+ }
+
+ if(!isAbsolute(absDataDir))
+ {
+ absDataDir = simplify(cwd + '/' + absDataDir);
+ }
+
+ for(p = fileSeq.begin(); p != fileSeq.end(); ++p)
+ {
+ if(!isAbsolute(*p))
+ {
+ *p = cwd + '/' + *p;
+ }
+ }
+
+ //
+ // We must call simplify() here: under Cygwin, any path starting with
+ // a double slash simply doesn't work. But, if dataDir is "/", we end
+ // up with paths that start with "//" unless we call simplify().
+ //
+ string absDataDirWithSlash = simplify(absDataDir + '/');
+
+ for(p = fileSeq.begin(); p != fileSeq.end(); ++p)
+ {
+ if(p->compare(0, absDataDirWithSlash.size(), absDataDirWithSlash) != 0)
+ {
+ throw "`" + *p + "' is not a path in `" + dataDir + "'";
+ }
+
+ p->erase(0, absDataDirWithSlash.size());
+ }
- FileInfoSeq infoSeq;
-
- if(fileSeq.empty())
- {
- CalcCB calcCB;
- if(!getFileInfoSeq(absDataDir, compress, verbose ? &calcCB : 0, infoSeq))
- {
- return EXIT_FAILURE;
- }
- }
- else
- {
- loadFileInfoSeq(absDataDir, infoSeq);
-
- for(p = fileSeq.begin(); p != fileSeq.end(); ++p)
- {
- FileInfoSeq partialInfoSeq;
-
- CalcCB calcCB;
- if(!getFileInfoSeqSubDir(absDataDir, *p, compress, verbose ? &calcCB : 0, partialInfoSeq))
- {
- return EXIT_FAILURE;
- }
-
- FileInfoSeq newInfoSeq;
- newInfoSeq.reserve(infoSeq.size());
-
- set_difference(infoSeq.begin(),
- infoSeq.end(),
- partialInfoSeq.begin(),
- partialInfoSeq.end(),
- back_inserter(newInfoSeq),
- FileInfoPathLess());
-
- infoSeq.swap(newInfoSeq);
-
- newInfoSeq.clear();
- newInfoSeq.reserve(infoSeq.size() + partialInfoSeq.size());
-
- set_union(infoSeq.begin(),
- infoSeq.end(),
- partialInfoSeq.begin(),
- partialInfoSeq.end(),
- back_inserter(newInfoSeq),
- FileInfoPathLess());
-
- infoSeq.swap(newInfoSeq);
- }
- }
-
- if(caseInsensitive)
- {
- FileInfoSeq newInfoSeq = infoSeq;
- sort(newInfoSeq.begin(), newInfoSeq.end(), IFileInfoPathLess());
-
- string ex;
- FileInfoSeq::iterator p = newInfoSeq.begin();
- while((p = adjacent_find(p, newInfoSeq.end(), IFileInfoPathEqual())) != newInfoSeq.end())
- {
- do
- {
- ex += '\n' + dataDir + '/' + p->path;
- ++p;
- }
- while(p < newInfoSeq.end() && IFileInfoPathEqual()(*(p - 1), *p));
- }
-
- if(!ex.empty())
- {
- ex = "duplicate files:" + ex;
- throw ex;
- }
- }
-
- saveFileInfoSeq(absDataDir, infoSeq);
+ FileInfoSeq infoSeq;
+
+ if(fileSeq.empty())
+ {
+ CalcCB calcCB;
+ if(!getFileInfoSeq(absDataDir, compress, verbose ? &calcCB : 0, infoSeq))
+ {
+ return EXIT_FAILURE;
+ }
+ }
+ else
+ {
+ loadFileInfoSeq(absDataDir, infoSeq);
+
+ for(p = fileSeq.begin(); p != fileSeq.end(); ++p)
+ {
+ FileInfoSeq partialInfoSeq;
+
+ CalcCB calcCB;
+ if(!getFileInfoSeqSubDir(absDataDir, *p, compress, verbose ? &calcCB : 0, partialInfoSeq))
+ {
+ return EXIT_FAILURE;
+ }
+
+ FileInfoSeq newInfoSeq;
+ newInfoSeq.reserve(infoSeq.size());
+
+ set_difference(infoSeq.begin(),
+ infoSeq.end(),
+ partialInfoSeq.begin(),
+ partialInfoSeq.end(),
+ back_inserter(newInfoSeq),
+ FileInfoPathLess());
+
+ infoSeq.swap(newInfoSeq);
+
+ newInfoSeq.clear();
+ newInfoSeq.reserve(infoSeq.size() + partialInfoSeq.size());
+
+ set_union(infoSeq.begin(),
+ infoSeq.end(),
+ partialInfoSeq.begin(),
+ partialInfoSeq.end(),
+ back_inserter(newInfoSeq),
+ FileInfoPathLess());
+
+ infoSeq.swap(newInfoSeq);
+ }
+ }
+
+ if(caseInsensitive)
+ {
+ FileInfoSeq newInfoSeq = infoSeq;
+ sort(newInfoSeq.begin(), newInfoSeq.end(), IFileInfoPathLess());
+
+ string ex;
+ FileInfoSeq::iterator p = newInfoSeq.begin();
+ while((p = adjacent_find(p, newInfoSeq.end(), IFileInfoPathEqual())) != newInfoSeq.end())
+ {
+ do
+ {
+ ex += '\n' + dataDir + '/' + p->path;
+ ++p;
+ }
+ while(p < newInfoSeq.end() && IFileInfoPathEqual()(*(p - 1), *p));
+ }
+
+ if(!ex.empty())
+ {
+ ex = "duplicate files:" + ex;
+ throw ex;
+ }
+ }
+
+ saveFileInfoSeq(absDataDir, infoSeq);
}
catch(const string& ex)
{
diff --git a/cpp/src/IcePatch2/Client.cpp b/cpp/src/IcePatch2/Client.cpp
index 50cbbd474b1..5bdbf0c0e10 100644
--- a/cpp/src/IcePatch2/Client.cpp
+++ b/cpp/src/IcePatch2/Client.cpp
@@ -28,137 +28,137 @@ class TextPatcherFeedback : public PatcherFeedback
public:
TextPatcherFeedback() :
- _pressAnyKeyMessage(false)
+ _pressAnyKeyMessage(false)
{
#ifndef _WIN32
- tcgetattr(0, &_savedTerm);
- _savedFlags = fcntl(0, F_GETFL);
- _block = true;
+ tcgetattr(0, &_savedTerm);
+ _savedFlags = fcntl(0, F_GETFL);
+ _block = true;
#endif
}
virtual ~TextPatcherFeedback()
{
#ifndef _WIN32
- tcsetattr(0, TCSANOW, &_savedTerm);
- fcntl(0, F_SETFL, _savedFlags);
+ tcsetattr(0, TCSANOW, &_savedTerm);
+ fcntl(0, F_SETFL, _savedFlags);
#endif
}
virtual bool
noFileSummary(const string& reason)
{
- cout << "Cannot load file summary:\n" << reason << endl;
- string answer;
- do
- {
- cout << "Do a thorough patch? (yes/no)" << endl;
- cin >> answer;
- transform(answer.begin(), answer.end(), answer.begin(), ::tolower);
- if(answer == "no")
- {
- return false;
- }
- }
- while(answer != "yes");
- return true;
+ cout << "Cannot load file summary:\n" << reason << endl;
+ string answer;
+ do
+ {
+ cout << "Do a thorough patch? (yes/no)" << endl;
+ cin >> answer;
+ transform(answer.begin(), answer.end(), answer.begin(), ::tolower);
+ if(answer == "no")
+ {
+ return false;
+ }
+ }
+ while(answer != "yes");
+ return true;
}
virtual bool
checksumStart()
{
- if(!_pressAnyKeyMessage)
- {
- cout << "[Press any key to abort]" << endl;
- _pressAnyKeyMessage = true;
- }
+ if(!_pressAnyKeyMessage)
+ {
+ cout << "[Press any key to abort]" << endl;
+ _pressAnyKeyMessage = true;
+ }
- return !keyPressed();
+ return !keyPressed();
}
virtual bool
checksumProgress(const string& path)
{
- cout << "Calculating checksum for " << getBasename(path) << endl;
- return !keyPressed();
+ cout << "Calculating checksum for " << getBasename(path) << endl;
+ return !keyPressed();
}
virtual bool
checksumEnd()
{
- return !keyPressed();
+ return !keyPressed();
}
virtual bool
fileListStart()
{
- if(!_pressAnyKeyMessage)
- {
- cout << "[Press any key to abort]" << endl;
- _pressAnyKeyMessage = true;
- }
-
- _lastProgress = "0%";
- cout << "Getting list of files to patch: " << _lastProgress << flush;
- return !keyPressed();
+ if(!_pressAnyKeyMessage)
+ {
+ cout << "[Press any key to abort]" << endl;
+ _pressAnyKeyMessage = true;
+ }
+
+ _lastProgress = "0%";
+ cout << "Getting list of files to patch: " << _lastProgress << flush;
+ return !keyPressed();
}
virtual bool
fileListProgress(Int percent)
{
- for(unsigned int i = 0; i < _lastProgress.size(); ++i)
- {
- cout << '\b';
- }
- ostringstream s;
- s << percent << '%';
- _lastProgress = s.str();
- cout << _lastProgress << flush;
- return !keyPressed();
+ for(unsigned int i = 0; i < _lastProgress.size(); ++i)
+ {
+ cout << '\b';
+ }
+ ostringstream s;
+ s << percent << '%';
+ _lastProgress = s.str();
+ cout << _lastProgress << flush;
+ return !keyPressed();
}
virtual bool
fileListEnd()
{
- cout << endl;
- return !keyPressed();
+ cout << endl;
+ return !keyPressed();
}
virtual bool
patchStart(const string& path, Long size, Long totalProgress, Long totalSize)
{
- if(!_pressAnyKeyMessage)
- {
- cout << "[Press any key to abort]" << endl;
- _pressAnyKeyMessage = true;
- }
-
- ostringstream s;
- s << "0/" << size << " (" << totalProgress << '/' << totalSize << ')';
- _lastProgress = s.str();
- cout << getBasename(path) << ' ' << _lastProgress << flush;
- return !keyPressed();
+ if(!_pressAnyKeyMessage)
+ {
+ cout << "[Press any key to abort]" << endl;
+ _pressAnyKeyMessage = true;
+ }
+
+ ostringstream s;
+ s << "0/" << size << " (" << totalProgress << '/' << totalSize << ')';
+ _lastProgress = s.str();
+ cout << getBasename(path) << ' ' << _lastProgress << flush;
+ return !keyPressed();
}
virtual bool
patchProgress(Long progress, Long size, Long totalProgress, Long totalSize)
{
- for(unsigned int i = 0; i < _lastProgress.size(); ++i)
- {
- cout << '\b';
- }
- ostringstream s;
- s << progress << '/' << size << " (" << totalProgress << '/' << totalSize << ')';
- _lastProgress = s.str();
- cout << _lastProgress << flush;
- return !keyPressed();
+ for(unsigned int i = 0; i < _lastProgress.size(); ++i)
+ {
+ cout << '\b';
+ }
+ ostringstream s;
+ s << progress << '/' << size << " (" << totalProgress << '/' << totalSize << ')';
+ _lastProgress = s.str();
+ cout << _lastProgress << flush;
+ return !keyPressed();
}
virtual bool
patchEnd()
{
- cout << endl;
- return !keyPressed();
+ cout << endl;
+ return !keyPressed();
}
private:
@@ -168,17 +168,17 @@ private:
bool
keyPressed()
{
- bool pressed = false;
+ bool pressed = false;
#ifdef __BCPLUSPLUS__
- while(kbhit())
+ while(kbhit())
#else
- while(_kbhit())
+ while(_kbhit())
#endif
- {
- pressed = true;
- _getch();
- }
- return pressed;
+ {
+ pressed = true;
+ _getch();
+ }
+ return pressed;
}
#else
@@ -186,29 +186,29 @@ private:
bool
keyPressed()
{
- if(_block)
- {
- termios term;
- memcpy(&term, &_savedTerm, sizeof(termios));
- term.c_lflag &= ~(ECHO | ICANON);
- term.c_cc[VTIME] = 0;
- term.c_cc[VMIN] = 1;
- tcsetattr(0, TCSANOW, &term);
-
- int flags = _savedFlags;
- flags |= O_NONBLOCK;
- fcntl(0, F_SETFL, flags);
-
- _block = false;
- }
-
- bool pressed = false;
- char c;
- while(read(0, &c, 1) > 0)
- {
- pressed = true;
- }
- return pressed;
+ if(_block)
+ {
+ termios term;
+ memcpy(&term, &_savedTerm, sizeof(termios));
+ term.c_lflag &= ~(ECHO | ICANON);
+ term.c_cc[VTIME] = 0;
+ term.c_cc[VMIN] = 1;
+ tcsetattr(0, TCSANOW, &term);
+
+ int flags = _savedFlags;
+ flags |= O_NONBLOCK;
+ fcntl(0, F_SETFL, flags);
+
+ _block = false;
+ }
+
+ bool pressed = false;
+ char c;
+ while(read(0, &c, 1) > 0)
+ {
+ pressed = true;
+ }
+ return pressed;
}
termios _savedTerm;
@@ -245,59 +245,59 @@ Client::run(int argc, char* argv[])
vector<string> args;
try
{
- args = opts.parse(argc, (const char**)argv);
+ args = opts.parse(argc, (const char**)argv);
}
catch(const IceUtil::BadOptException& e)
{
cerr << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(argv[0]);
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
if(opts.isSet("thorough"))
{
- properties->setProperty("IcePatch2.Thorough", "1");
+ properties->setProperty("IcePatch2.Thorough", "1");
}
if(args.size() > 1)
{
- cerr << argv[0] << ": too many arguments" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": too many arguments" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(args.size() == 1)
{
- properties->setProperty("IcePatch2.Directory", simplify(args[0]));
+ properties->setProperty("IcePatch2.Directory", simplify(args[0]));
}
bool aborted = false;
try
{
- PatcherFeedbackPtr feedback = new TextPatcherFeedback;
- PatcherPtr patcher = new Patcher(communicator(), feedback);
+ PatcherFeedbackPtr feedback = new TextPatcherFeedback;
+ PatcherPtr patcher = new Patcher(communicator(), feedback);
- aborted = !patcher->prepare();
+ aborted = !patcher->prepare();
- if(!aborted)
- {
- aborted = !patcher->patch("");
- }
+ if(!aborted)
+ {
+ aborted = !patcher->patch("");
+ }
- if(!aborted)
- {
- patcher->finish();
- }
+ if(!aborted)
+ {
+ patcher->finish();
+ }
}
catch(const string& ex)
{
@@ -307,12 +307,12 @@ Client::run(int argc, char* argv[])
if(aborted)
{
- cout << "\n[Aborted]" << endl;
- return EXIT_FAILURE;
+ cout << "\n[Aborted]" << endl;
+ return EXIT_FAILURE;
}
else
{
- return EXIT_SUCCESS;
+ return EXIT_SUCCESS;
}
}
@@ -320,10 +320,10 @@ void
Client::usage(const string& appName)
{
string options =
- "Options:\n"
- "-h, --help Show this message.\n"
- "-v, --version Display the Ice version.\n"
- "-t, --thorough Recalculate all checksums.";
+ "Options:\n"
+ "-h, --help Show this message.\n"
+ "-v, --version Display the Ice version.\n"
+ "-t, --thorough Recalculate all checksums.";
cerr << "Usage: " << appName << " [options] [DIR]" << endl;
cerr << options << endl;
diff --git a/cpp/src/IcePatch2/ClientUtil.cpp b/cpp/src/IcePatch2/ClientUtil.cpp
index fd986e90d29..64b3f472bed 100755
--- a/cpp/src/IcePatch2/ClientUtil.cpp
+++ b/cpp/src/IcePatch2/ClientUtil.cpp
@@ -30,107 +30,107 @@ class Decompressor : public IceUtil::Thread, public IceUtil::Monitor<IceUtil::Mu
public:
Decompressor(const string& dataDir) :
- _dataDir(dataDir),
- _destroy(false)
+ _dataDir(dataDir),
+ _destroy(false)
{
}
virtual ~Decompressor()
{
- assert(_destroy);
+ assert(_destroy);
}
void
destroy()
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- _destroy = true;
- notify();
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ _destroy = true;
+ notify();
}
void
add(const FileInfo& info)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- if(!_exception.empty())
- {
- throw _exception;
- }
- _files.push_back(info);
- notify();
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ if(!_exception.empty())
+ {
+ throw _exception;
+ }
+ _files.push_back(info);
+ notify();
}
void
exception() const
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- if(!_exception.empty())
- {
- throw _exception;
- }
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ if(!_exception.empty())
+ {
+ throw _exception;
+ }
}
void
log(FILE* fp)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- for(FileInfoSeq::const_iterator p = _filesDone.begin(); p != _filesDone.end(); ++p)
- {
- if(fputc('+', fp) == EOF || !writeFileInfo(fp, *p))
- {
- throw "error writing log file:\n" + lastError();
- }
- }
+ for(FileInfoSeq::const_iterator p = _filesDone.begin(); p != _filesDone.end(); ++p)
+ {
+ if(fputc('+', fp) == EOF || !writeFileInfo(fp, *p))
+ {
+ throw "error writing log file:\n" + lastError();
+ }
+ }
- _filesDone.clear();
+ _filesDone.clear();
}
virtual void
run()
{
- FileInfo info;
-
- while(true)
- {
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- if(!info.path.empty())
- {
- _filesDone.push_back(info);
- }
-
- while(!_destroy && _files.empty())
- {
- wait();
- }
-
- if(!_files.empty())
- {
- info = _files.front();
- _files.pop_front();
- }
- else
- {
- return;
- }
- }
-
- try
- {
- decompressFile(_dataDir + '/' + info.path);
- setFileFlags(_dataDir + '/' + info.path, info);
- remove(_dataDir + '/' + info.path + ".bz2");
- }
- catch(const string& ex)
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- _destroy = true;
- _exception = ex;
- return;
- }
- }
+ FileInfo info;
+
+ while(true)
+ {
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ if(!info.path.empty())
+ {
+ _filesDone.push_back(info);
+ }
+
+ while(!_destroy && _files.empty())
+ {
+ wait();
+ }
+
+ if(!_files.empty())
+ {
+ info = _files.front();
+ _files.pop_front();
+ }
+ else
+ {
+ return;
+ }
+ }
+
+ try
+ {
+ decompressFile(_dataDir + '/' + info.path);
+ setFileFlags(_dataDir + '/' + info.path, info);
+ remove(_dataDir + '/' + info.path + ".bz2");
+ }
+ catch(const string& ex)
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ _destroy = true;
+ _exception = ex;
+ return;
+ }
+ }
}
private:
@@ -158,7 +158,7 @@ IcePatch2::Patcher::Patcher(const CommunicatorPtr& communicator, const PatcherFe
const char* endpointsProperty = "Ice.OA.IcePatch2.Endpoints";
string endpoints = properties->getPropertyWithDefault(endpointsProperty,
- properties->getProperty("IcePatch2.Endpoints"));
+ properties->getProperty("IcePatch2.Endpoints"));
if(endpoints.empty())
{
throw string("property `") + endpointsProperty + "' is not set";
@@ -172,18 +172,18 @@ IcePatch2::Patcher::Patcher(const CommunicatorPtr& communicator, const PatcherFe
FileServerPrx server = FileServerPrx::checkedCast(serverBase);
if(!server)
{
- throw "proxy `" + communicator->identityToString(id) + ':' + endpoints + "' is not a file server.";
+ throw "proxy `" + communicator->identityToString(id) + ':' + endpoints + "' is not a file server.";
}
init(server);
}
IcePatch2::Patcher::Patcher(const FileServerPrx& server,
- const PatcherFeedbackPtr& feedback,
- const string& dataDir,
- bool thorough,
- Ice::Int chunkSize,
- Ice::Int remove) :
+ const PatcherFeedbackPtr& feedback,
+ const string& dataDir,
+ bool thorough,
+ Ice::Int chunkSize,
+ Ice::Int remove) :
_feedback(feedback),
_dataDir(simplify(dataDir)),
_thorough(thorough),
@@ -202,26 +202,26 @@ class PatcherGetFileInfoSeqCB : public GetFileInfoSeqCB
public:
PatcherGetFileInfoSeqCB(const PatcherFeedbackPtr& feedback) :
- _feedback(feedback)
+ _feedback(feedback)
{
}
virtual bool
remove(const string&)
{
- return true;
+ return true;
}
virtual bool
checksum(const string& path)
{
- return _feedback->checksumProgress(path);
+ return _feedback->checksumProgress(path);
}
virtual bool compress(const string&)
{
- assert(false); // Nothing must get compressed when we are patching.
- return true;
+ assert(false); // Nothing must get compressed when we are patching.
+ return true;
}
private:
@@ -234,50 +234,50 @@ class AMIGetFileInfoSeq : public AMI_FileServer_getFileInfoSeq, public IceUtil::
public:
AMIGetFileInfoSeq() :
- _done(false)
+ _done(false)
{
}
FileInfoSeq
getFileInfoSeq()
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- while(!_done)
- {
- wait();
- }
+ while(!_done)
+ {
+ wait();
+ }
- _done = false;
+ _done = false;
- if(_exception.get())
- {
- auto_ptr<Exception> ex = _exception;
- _fileInfoSeq.clear();
- ex->ice_throw();
- }
+ if(_exception.get())
+ {
+ auto_ptr<Exception> ex = _exception;
+ _fileInfoSeq.clear();
+ ex->ice_throw();
+ }
- FileInfoSeq fileInfoSeq;
- fileInfoSeq.swap(_fileInfoSeq);
- return fileInfoSeq;
+ 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();
+ 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();
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ _exception.reset(ex.ice_clone());
+ _done = true;
+ notify();
}
private:
@@ -298,39 +298,39 @@ IcePatch2::Patcher::prepare()
if(!thorough)
{
- try
- {
- loadFileInfoSeq(_dataDir, _localFiles);
- }
- catch(const string& ex)
- {
- thorough = _feedback->noFileSummary(ex);
- if(!thorough)
- {
- return false;
- }
- }
+ try
+ {
+ loadFileInfoSeq(_dataDir, _localFiles);
+ }
+ catch(const string& ex)
+ {
+ thorough = _feedback->noFileSummary(ex);
+ if(!thorough)
+ {
+ return false;
+ }
+ }
}
if(thorough)
{
- if(!_feedback->checksumStart())
- {
- return false;
- }
+ if(!_feedback->checksumStart())
+ {
+ return false;
+ }
- PatcherGetFileInfoSeqCB cb(_feedback);
- if(!getFileInfoSeq(_dataDir, 0, &cb, _localFiles))
- {
- return false;
- }
+ PatcherGetFileInfoSeqCB cb(_feedback);
+ if(!getFileInfoSeq(_dataDir, 0, &cb, _localFiles))
+ {
+ return false;
+ }
- if(!_feedback->checksumEnd())
- {
- return false;
- }
+ if(!_feedback->checksumEnd())
+ {
+ return false;
+ }
- saveFileInfoSeq(_dataDir, _localFiles);
+ saveFileInfoSeq(_dataDir, _localFiles);
}
FileTree0 tree0;
@@ -338,124 +338,124 @@ IcePatch2::Patcher::prepare()
if(tree0.checksum != _serverCompress->getChecksum())
{
- if(!_feedback->fileListStart())
- {
- return false;
- }
-
- ByteSeqSeq checksumSeq = _serverCompress->getChecksumSeq();
- if(checksumSeq.size() != 256)
- {
- throw string("server returned illegal value");
- }
-
- AMIGetFileInfoSeqPtr curCB;
- AMIGetFileInfoSeqPtr nxtCB;
-
- for(int node0 = 0; node0 < 256; ++node0)
- {
- if(tree0.nodes[node0].checksum != checksumSeq[node0])
- {
- if(!curCB)
- {
- assert(!nxtCB);
- curCB = new AMIGetFileInfoSeq;
- nxtCB = new AMIGetFileInfoSeq;
- _serverCompress->getFileInfoSeq_async(curCB, node0);
- }
- else
- {
- assert(nxtCB);
- swap(nxtCB, curCB);
- }
-
- int node0Nxt = node0;
-
- do
- {
- ++node0Nxt;
- }
- while(node0Nxt < 256 && tree0.nodes[node0Nxt].checksum == checksumSeq[node0Nxt]);
-
- if(node0Nxt < 256)
- {
- _serverCompress->getFileInfoSeq_async(nxtCB, node0Nxt);
- }
-
- FileInfoSeq files = curCB->getFileInfoSeq();
-
- sort(files.begin(), files.end(), FileInfoLess());
- files.erase(unique(files.begin(), files.end(), FileInfoEqual()), files.end());
-
- //
- // Compute the set of files which were removed.
- //
- set_difference(tree0.nodes[node0].files.begin(),
- tree0.nodes[node0].files.end(),
- files.begin(),
- files.end(),
- back_inserter(_removeFiles),
- FileInfoWithoutFlagsLess()); // NOTE: We ignore the flags here.
-
- //
- // Compute the set of files which were updated (either the file contents, flags or both).
- //
- FileInfoSeq updatedFiles;
- updatedFiles.reserve(files.size());
-
- set_difference(files.begin(),
- files.end(),
- tree0.nodes[node0].files.begin(),
- tree0.nodes[node0].files.end(),
- back_inserter(updatedFiles),
- FileInfoLess());
-
- //
- // Compute the set of files whose contents was updated.
- //
- FileInfoSeq contentsUpdatedFiles;
- contentsUpdatedFiles.reserve(files.size());
-
- set_difference(files.begin(),
- files.end(),
- tree0.nodes[node0].files.begin(),
- tree0.nodes[node0].files.end(),
- back_inserter(contentsUpdatedFiles),
- FileInfoWithoutFlagsLess()); // NOTE: We ignore the flags here.
- copy(contentsUpdatedFiles.begin(), contentsUpdatedFiles.end(), back_inserter(_updateFiles));
-
- //
- // Compute the set of files whose flags were updated.
- //
- set_difference(updatedFiles.begin(),
- updatedFiles.end(),
- contentsUpdatedFiles.begin(),
- contentsUpdatedFiles.end(),
- back_inserter(_updateFlags),
- FileInfoLess());
- }
-
- if(!_feedback->fileListProgress((node0 + 1) * 100 / 256))
- {
- return false;
- }
- }
-
- if(!_feedback->fileListEnd())
- {
- return false;
- }
+ if(!_feedback->fileListStart())
+ {
+ return false;
+ }
+
+ ByteSeqSeq checksumSeq = _serverCompress->getChecksumSeq();
+ if(checksumSeq.size() != 256)
+ {
+ throw string("server returned illegal value");
+ }
+
+ AMIGetFileInfoSeqPtr curCB;
+ AMIGetFileInfoSeqPtr nxtCB;
+
+ for(int node0 = 0; node0 < 256; ++node0)
+ {
+ if(tree0.nodes[node0].checksum != checksumSeq[node0])
+ {
+ if(!curCB)
+ {
+ assert(!nxtCB);
+ curCB = new AMIGetFileInfoSeq;
+ nxtCB = new AMIGetFileInfoSeq;
+ _serverCompress->getFileInfoSeq_async(curCB, node0);
+ }
+ else
+ {
+ assert(nxtCB);
+ swap(nxtCB, curCB);
+ }
+
+ int node0Nxt = node0;
+
+ do
+ {
+ ++node0Nxt;
+ }
+ while(node0Nxt < 256 && tree0.nodes[node0Nxt].checksum == checksumSeq[node0Nxt]);
+
+ if(node0Nxt < 256)
+ {
+ _serverCompress->getFileInfoSeq_async(nxtCB, node0Nxt);
+ }
+
+ FileInfoSeq files = curCB->getFileInfoSeq();
+
+ sort(files.begin(), files.end(), FileInfoLess());
+ files.erase(unique(files.begin(), files.end(), FileInfoEqual()), files.end());
+
+ //
+ // Compute the set of files which were removed.
+ //
+ set_difference(tree0.nodes[node0].files.begin(),
+ tree0.nodes[node0].files.end(),
+ files.begin(),
+ files.end(),
+ back_inserter(_removeFiles),
+ FileInfoWithoutFlagsLess()); // NOTE: We ignore the flags here.
+
+ //
+ // Compute the set of files which were updated (either the file contents, flags or both).
+ //
+ FileInfoSeq updatedFiles;
+ updatedFiles.reserve(files.size());
+
+ set_difference(files.begin(),
+ files.end(),
+ tree0.nodes[node0].files.begin(),
+ tree0.nodes[node0].files.end(),
+ back_inserter(updatedFiles),
+ FileInfoLess());
+
+ //
+ // Compute the set of files whose contents was updated.
+ //
+ FileInfoSeq contentsUpdatedFiles;
+ contentsUpdatedFiles.reserve(files.size());
+
+ set_difference(files.begin(),
+ files.end(),
+ tree0.nodes[node0].files.begin(),
+ tree0.nodes[node0].files.end(),
+ back_inserter(contentsUpdatedFiles),
+ FileInfoWithoutFlagsLess()); // NOTE: We ignore the flags here.
+ copy(contentsUpdatedFiles.begin(), contentsUpdatedFiles.end(), back_inserter(_updateFiles));
+
+ //
+ // Compute the set of files whose flags were updated.
+ //
+ set_difference(updatedFiles.begin(),
+ updatedFiles.end(),
+ contentsUpdatedFiles.begin(),
+ contentsUpdatedFiles.end(),
+ back_inserter(_updateFlags),
+ FileInfoLess());
+ }
+
+ if(!_feedback->fileListProgress((node0 + 1) * 100 / 256))
+ {
+ return false;
+ }
+ }
+
+ if(!_feedback->fileListEnd())
+ {
+ return false;
+ }
}
sort(_removeFiles.begin(), _removeFiles.end(), FileInfoLess());
sort(_updateFiles.begin(), _updateFiles.end(), FileInfoLess());
sort(_updateFlags.begin(), _updateFlags.end(), FileInfoLess());
-
+
string pathLog = simplify(_dataDir + '/' + logFile);
_log = OS::fopen(pathLog, "w");
if(!_log)
{
- throw "cannot open `" + pathLog + "' for writing:\n" + lastError();
+ throw "cannot open `" + pathLog + "' for writing:\n" + lastError();
}
return true;
@@ -468,102 +468,102 @@ IcePatch2::Patcher::patch(const string& d)
if(dir.empty() || dir == ".")
{
- if(!_removeFiles.empty())
- {
- if(!removeFiles(_removeFiles))
- {
- return false;
- }
- }
-
- if(!_updateFiles.empty())
- {
- if(!updateFiles(_updateFiles))
- {
- return false;
- }
- }
-
- if(!_updateFlags.empty())
- {
- if(!updateFlags(_updateFlags))
- {
- return false;
- }
- }
-
- return true;
+ if(!_removeFiles.empty())
+ {
+ if(!removeFiles(_removeFiles))
+ {
+ return false;
+ }
+ }
+
+ if(!_updateFiles.empty())
+ {
+ if(!updateFiles(_updateFiles))
+ {
+ return false;
+ }
+ }
+
+ if(!_updateFlags.empty())
+ {
+ if(!updateFlags(_updateFlags))
+ {
+ return false;
+ }
+ }
+
+ return true;
}
else
{
- string dirWithSlash = simplify(dir + '/');
-
- FileInfoSeq::const_iterator p;
-
- FileInfoSeq remove;
- for(p = _removeFiles.begin(); p != _removeFiles.end(); ++p)
- {
- if(p->path == dir)
- {
- remove.push_back(*p);
- }
- else if(p->path.compare(0, dirWithSlash.size(), dirWithSlash) == 0)
- {
- remove.push_back(*p);
- }
- }
-
- FileInfoSeq update;
- for(p = _updateFiles.begin(); p != _updateFiles.end(); ++p)
- {
- if(p->path == dir)
- {
- update.push_back(*p);
- }
- else if(p->path.compare(0, dirWithSlash.size(), dirWithSlash) == 0)
- {
- update.push_back(*p);
- }
- }
-
- FileInfoSeq updateFlag;
- for(p = _updateFlags.begin(); p != _updateFlags.end(); ++p)
- {
- if(p->path == dir)
- {
- updateFlag.push_back(*p);
- }
- else if(p->path.compare(0, dirWithSlash.size(), dirWithSlash) == 0)
- {
- updateFlag.push_back(*p);
- }
- }
-
- if(!remove.empty())
- {
- if(!removeFiles(remove))
- {
- return false;
- }
- }
-
- if(!update.empty())
- {
- if(!updateFiles(update))
- {
- return false;
- }
- }
-
- if(!updateFlag.empty())
- {
- if(!updateFlags(updateFlag))
- {
- return false;
- }
- }
-
- return true;
+ string dirWithSlash = simplify(dir + '/');
+
+ FileInfoSeq::const_iterator p;
+
+ FileInfoSeq remove;
+ for(p = _removeFiles.begin(); p != _removeFiles.end(); ++p)
+ {
+ if(p->path == dir)
+ {
+ remove.push_back(*p);
+ }
+ else if(p->path.compare(0, dirWithSlash.size(), dirWithSlash) == 0)
+ {
+ remove.push_back(*p);
+ }
+ }
+
+ FileInfoSeq update;
+ for(p = _updateFiles.begin(); p != _updateFiles.end(); ++p)
+ {
+ if(p->path == dir)
+ {
+ update.push_back(*p);
+ }
+ else if(p->path.compare(0, dirWithSlash.size(), dirWithSlash) == 0)
+ {
+ update.push_back(*p);
+ }
+ }
+
+ FileInfoSeq updateFlag;
+ for(p = _updateFlags.begin(); p != _updateFlags.end(); ++p)
+ {
+ if(p->path == dir)
+ {
+ updateFlag.push_back(*p);
+ }
+ else if(p->path.compare(0, dirWithSlash.size(), dirWithSlash) == 0)
+ {
+ updateFlag.push_back(*p);
+ }
+ }
+
+ if(!remove.empty())
+ {
+ if(!removeFiles(remove))
+ {
+ return false;
+ }
+ }
+
+ if(!update.empty())
+ {
+ if(!updateFiles(update))
+ {
+ return false;
+ }
+ }
+
+ if(!updateFlag.empty())
+ {
+ if(!updateFlags(updateFlag))
+ {
+ return false;
+ }
+ }
+
+ return true;
}
}
@@ -572,8 +572,8 @@ IcePatch2::Patcher::finish()
{
if(_log != 0)
{
- fclose(_log);
- _log = 0;
+ fclose(_log);
+ _log = 0;
}
saveFileInfoSeq(_dataDir, _localFiles);
@@ -584,7 +584,7 @@ IcePatch2::Patcher::init(const FileServerPrx& server)
{
if(_dataDir.empty())
{
- throw string("no data directory specified");
+ throw string("no data directory specified");
}
//
@@ -595,7 +595,7 @@ IcePatch2::Patcher::init(const FileServerPrx& server)
server->ice_getCommunicator()->getProperties()->getPropertyAsIntWithDefault("Ice.MessageSizeMax", 1024);
if(_chunkSize < 1)
{
- const_cast<Int&>(_chunkSize) = 1;
+ const_cast<Int&>(_chunkSize) = 1;
}
else if(_chunkSize > sizeMax)
{
@@ -607,19 +607,19 @@ IcePatch2::Patcher::init(const FileServerPrx& server)
}
else
{
- const_cast<Int&>(_chunkSize) *= 1024;
+ const_cast<Int&>(_chunkSize) *= 1024;
}
if(!isAbsolute(_dataDir))
{
- string cwd;
- if(OS::getcwd(cwd) != 0)
- {
- throw "cannot get the current directory:\n" + lastError();
- }
- const_cast<string&>(_dataDir) = simplify(cwd + '/' + _dataDir);
+ string cwd;
+ if(OS::getcwd(cwd) != 0)
+ {
+ throw "cannot get the current directory:\n" + lastError();
+ }
+ const_cast<string&>(_dataDir) = simplify(cwd + '/' + _dataDir);
}
-
+
const_cast<FileServerPrx&>(_serverCompress) = FileServerPrx::uncheckedCast(server->ice_compress(true));
const_cast<FileServerPrx&>(_serverNoCompress) = FileServerPrx::uncheckedCast(server->ice_compress(false));
}
@@ -629,48 +629,48 @@ IcePatch2::Patcher::removeFiles(const FileInfoSeq& files)
{
if(_remove < 1)
{
- return true;
+ return true;
}
for(FileInfoSeq::const_reverse_iterator p = files.rbegin(); p != files.rend(); ++p)
{
- try
- {
- remove(_dataDir + '/' + p->path);
- if(fputc('-', _log) == EOF || ! writeFileInfo(_log, *p))
- {
- throw "error writing log file:\n" + lastError();
- }
- }
- catch(...)
- {
- if(_remove < 2) // We ignore errors if IcePatch2.Remove >= 2.
- {
- throw;
- }
- }
+ try
+ {
+ remove(_dataDir + '/' + p->path);
+ if(fputc('-', _log) == EOF || ! writeFileInfo(_log, *p))
+ {
+ throw "error writing log file:\n" + lastError();
+ }
+ }
+ catch(...)
+ {
+ if(_remove < 2) // We ignore errors if IcePatch2.Remove >= 2.
+ {
+ throw;
+ }
+ }
}
FileInfoSeq newLocalFiles;
newLocalFiles.reserve(_localFiles.size());
set_difference(_localFiles.begin(),
- _localFiles.end(),
- files.begin(),
- files.end(),
- back_inserter(newLocalFiles),
- FileInfoLess());
+ _localFiles.end(),
+ files.begin(),
+ files.end(),
+ back_inserter(newLocalFiles),
+ FileInfoLess());
_localFiles.swap(newLocalFiles);
FileInfoSeq newRemoveFiles;
set_difference(_removeFiles.begin(),
- _removeFiles.end(),
- files.begin(),
- files.end(),
- back_inserter(newRemoveFiles),
- FileInfoLess());
+ _removeFiles.end(),
+ files.begin(),
+ files.end(),
+ back_inserter(newRemoveFiles),
+ FileInfoLess());
_removeFiles.swap(newRemoveFiles);
@@ -694,14 +694,14 @@ IcePatch2::Patcher::updateFiles(const FileInfoSeq& files)
try
{
- result = updateFilesInternal(files, decompressor);
+ result = updateFilesInternal(files, decompressor);
}
catch(...)
{
- decompressor->destroy();
- decompressor->getThreadControl().join();
- decompressor->log(_log);
- throw;
+ decompressor->destroy();
+ decompressor->getThreadControl().join();
+ decompressor->log(_log);
+ throw;
}
decompressor->destroy();
@@ -717,50 +717,50 @@ class AMIGetFileCompressed : public AMI_FileServer_getFileCompressed, public Ice
public:
AMIGetFileCompressed() :
- _done(false)
+ _done(false)
{
}
ByteSeq
getFileCompressed()
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- while(!_done)
- {
- wait();
- }
+ while(!_done)
+ {
+ wait();
+ }
- _done = false;
+ _done = false;
- if(_exception.get())
- {
- auto_ptr<Exception> ex = _exception;
- _bytes.clear();
- ex->ice_throw();
- }
+ if(_exception.get())
+ {
+ auto_ptr<Exception> ex = _exception;
+ _bytes.clear();
+ ex->ice_throw();
+ }
- ByteSeq bytes;
- bytes.swap(_bytes);
- return bytes;
+ 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();
+ 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();
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ _exception.reset(ex.ice_clone());
+ _done = true;
+ notify();
}
private:
@@ -782,10 +782,10 @@ IcePatch2::Patcher::updateFilesInternal(const FileInfoSeq& files, const Decompre
for(p = files.begin(); p != files.end(); ++p)
{
- if(p->size > 0) // Regular, non-empty file?
- {
- total += p->size;
- }
+ if(p->size > 0) // Regular, non-empty file?
+ {
+ total += p->size;
+ }
}
AMIGetFileCompressedPtr curCB;
@@ -793,164 +793,164 @@ IcePatch2::Patcher::updateFilesInternal(const FileInfoSeq& files, const Decompre
for(p = files.begin(); p != files.end(); ++p)
{
- if(p->size < 0) // Directory?
- {
- createDirectoryRecursive(_dataDir + '/' + p->path);
- if(fputc('+', _log) == EOF || !writeFileInfo(_log, *p))
- {
- throw "error writing log file:\n" + lastError();
- }
- }
- else // Regular file.
- {
- if(!_feedback->patchStart(p->path, p->size, updated, total))
- {
- return false;
- }
-
- if(p->size == 0)
- {
- string path = simplify(_dataDir + '/' + p->path);
- FILE* fp = OS::fopen(path, "wb");
- if(fp == 0)
- {
- throw "cannot open `" + path +"' for writing:\n" + lastError();
- }
- fclose(fp);
- }
- else
- {
- string pathBZ2 = simplify(_dataDir + '/' + p->path + ".bz2");
-
- string dir = getDirname(pathBZ2);
- if(!dir.empty())
- {
- createDirectoryRecursive(dir);
- }
-
- try
- {
- removeRecursive(pathBZ2);
- }
- catch(...)
- {
- }
-
- FILE* fileBZ2 = OS::fopen(pathBZ2, "wb");
- if(fileBZ2 == 0)
- {
- throw "cannot open `" + pathBZ2 + "' for writing:\n" + lastError();
- }
-
- try
- {
- Int pos = 0;
-
- while(pos < p->size)
- {
- if(!curCB)
- {
- assert(!nxtCB);
- curCB = new AMIGetFileCompressed;
- nxtCB = new AMIGetFileCompressed;
- _serverNoCompress->getFileCompressed_async(curCB, p->path, pos, _chunkSize);
- }
- else
- {
- assert(nxtCB);
- swap(nxtCB, curCB);
- }
-
- if(pos + _chunkSize < p->size)
- {
- _serverNoCompress->getFileCompressed_async(nxtCB, p->path, pos + _chunkSize, _chunkSize);
- }
- else
- {
- FileInfoSeq::const_iterator q = p + 1;
-
- while(q != files.end() && q->size <= 0)
- {
- ++q;
- }
-
- if(q != files.end())
- {
- _serverNoCompress->getFileCompressed_async(nxtCB, q->path, 0, _chunkSize);
- }
- }
-
- ByteSeq bytes;
-
- try
- {
- bytes = curCB->getFileCompressed();
- }
- catch(const FileAccessException& ex)
- {
- throw "error from IcePatch2 server for `" + p->path + "': " + ex.reason;
- }
-
- if(bytes.empty())
- {
- throw "size mismatch for `" + p->path + "'";
- }
-
- if(fwrite(reinterpret_cast<char*>(&bytes[0]), bytes.size(), 1, fileBZ2) != 1)
- {
- throw ": cannot write `" + pathBZ2 + "':\n" + lastError();
- }
-
- pos += static_cast<int>(bytes.size());
- updated += bytes.size();
-
- if(!_feedback->patchProgress(pos, p->size, updated, total))
- {
- fclose(fileBZ2);
- return false;
- }
- }
- }
- catch(...)
- {
- fclose(fileBZ2);
- throw;
- }
-
- fclose(fileBZ2);
-
- decompressor->log(_log);
- decompressor->add(*p);
- }
-
- if(!_feedback->patchEnd())
- {
- return false;
- }
- }
+ if(p->size < 0) // Directory?
+ {
+ createDirectoryRecursive(_dataDir + '/' + p->path);
+ if(fputc('+', _log) == EOF || !writeFileInfo(_log, *p))
+ {
+ throw "error writing log file:\n" + lastError();
+ }
+ }
+ else // Regular file.
+ {
+ if(!_feedback->patchStart(p->path, p->size, updated, total))
+ {
+ return false;
+ }
+
+ if(p->size == 0)
+ {
+ string path = simplify(_dataDir + '/' + p->path);
+ FILE* fp = OS::fopen(path, "wb");
+ if(fp == 0)
+ {
+ throw "cannot open `" + path +"' for writing:\n" + lastError();
+ }
+ fclose(fp);
+ }
+ else
+ {
+ string pathBZ2 = simplify(_dataDir + '/' + p->path + ".bz2");
+
+ string dir = getDirname(pathBZ2);
+ if(!dir.empty())
+ {
+ createDirectoryRecursive(dir);
+ }
+
+ try
+ {
+ removeRecursive(pathBZ2);
+ }
+ catch(...)
+ {
+ }
+
+ FILE* fileBZ2 = OS::fopen(pathBZ2, "wb");
+ if(fileBZ2 == 0)
+ {
+ throw "cannot open `" + pathBZ2 + "' for writing:\n" + lastError();
+ }
+
+ try
+ {
+ Int pos = 0;
+
+ while(pos < p->size)
+ {
+ if(!curCB)
+ {
+ assert(!nxtCB);
+ curCB = new AMIGetFileCompressed;
+ nxtCB = new AMIGetFileCompressed;
+ _serverNoCompress->getFileCompressed_async(curCB, p->path, pos, _chunkSize);
+ }
+ else
+ {
+ assert(nxtCB);
+ swap(nxtCB, curCB);
+ }
+
+ if(pos + _chunkSize < p->size)
+ {
+ _serverNoCompress->getFileCompressed_async(nxtCB, p->path, pos + _chunkSize, _chunkSize);
+ }
+ else
+ {
+ FileInfoSeq::const_iterator q = p + 1;
+
+ while(q != files.end() && q->size <= 0)
+ {
+ ++q;
+ }
+
+ if(q != files.end())
+ {
+ _serverNoCompress->getFileCompressed_async(nxtCB, q->path, 0, _chunkSize);
+ }
+ }
+
+ ByteSeq bytes;
+
+ try
+ {
+ bytes = curCB->getFileCompressed();
+ }
+ catch(const FileAccessException& ex)
+ {
+ throw "error from IcePatch2 server for `" + p->path + "': " + ex.reason;
+ }
+
+ if(bytes.empty())
+ {
+ throw "size mismatch for `" + p->path + "'";
+ }
+
+ if(fwrite(reinterpret_cast<char*>(&bytes[0]), bytes.size(), 1, fileBZ2) != 1)
+ {
+ throw ": cannot write `" + pathBZ2 + "':\n" + lastError();
+ }
+
+ pos += static_cast<int>(bytes.size());
+ updated += bytes.size();
+
+ if(!_feedback->patchProgress(pos, p->size, updated, total))
+ {
+ fclose(fileBZ2);
+ return false;
+ }
+ }
+ }
+ catch(...)
+ {
+ fclose(fileBZ2);
+ throw;
+ }
+
+ fclose(fileBZ2);
+
+ decompressor->log(_log);
+ decompressor->add(*p);
+ }
+
+ if(!_feedback->patchEnd())
+ {
+ return false;
+ }
+ }
}
FileInfoSeq newLocalFiles;
newLocalFiles.reserve(_localFiles.size());
-
+
set_union(_localFiles.begin(),
- _localFiles.end(),
- files.begin(),
- files.end(),
- back_inserter(newLocalFiles),
- FileInfoLess());
-
+ _localFiles.end(),
+ files.begin(),
+ files.end(),
+ back_inserter(newLocalFiles),
+ FileInfoLess());
+
_localFiles.swap(newLocalFiles);
FileInfoSeq newUpdateFiles;
set_difference(_updateFiles.begin(),
- _updateFiles.end(),
- files.begin(),
- files.end(),
- back_inserter(newUpdateFiles),
- FileInfoLess());
-
+ _updateFiles.end(),
+ files.begin(),
+ files.end(),
+ back_inserter(newUpdateFiles),
+ FileInfoLess());
+
_updateFiles.swap(newUpdateFiles);
return true;
@@ -961,10 +961,10 @@ IcePatch2::Patcher::updateFlags(const FileInfoSeq& files)
{
for(FileInfoSeq::const_iterator p = files.begin(); p != files.end(); ++p)
{
- if(p->size >= 0) // Regular file?
- {
- setFileFlags(_dataDir + '/' + p->path, *p);
- }
+ if(p->size >= 0) // Regular file?
+ {
+ setFileFlags(_dataDir + '/' + p->path, *p);
+ }
}
//
@@ -974,32 +974,32 @@ IcePatch2::Patcher::updateFlags(const FileInfoSeq& files)
FileInfoSeq localFiles;
localFiles.reserve(_localFiles.size());
set_difference(_localFiles.begin(),
- _localFiles.end(),
- files.begin(),
- files.end(),
- back_inserter(localFiles),
- FileInfoWithoutFlagsLess()); // NOTE: We ignore the flags.
+ _localFiles.end(),
+ files.begin(),
+ files.end(),
+ back_inserter(localFiles),
+ FileInfoWithoutFlagsLess()); // NOTE: We ignore the flags.
//
// Add the new files to the set of local file.
//
_localFiles.clear();
set_union(localFiles.begin(),
- localFiles.end(),
- files.begin(),
- files.end(),
- back_inserter(_localFiles),
- FileInfoLess());
+ localFiles.end(),
+ files.begin(),
+ files.end(),
+ back_inserter(_localFiles),
+ FileInfoLess());
FileInfoSeq newUpdateFlags;
set_difference(_updateFlags.begin(),
- _updateFlags.end(),
- files.begin(),
- files.end(),
- back_inserter(newUpdateFlags),
- FileInfoLess());
-
+ _updateFlags.end(),
+ files.begin(),
+ files.end(),
+ back_inserter(newUpdateFlags),
+ FileInfoLess());
+
_updateFlags.swap(newUpdateFlags);
return true;
diff --git a/cpp/src/IcePatch2/FileServerI.cpp b/cpp/src/IcePatch2/FileServerI.cpp
index 3c647faf16c..c8fdcc2366c 100644
--- a/cpp/src/IcePatch2/FileServerI.cpp
+++ b/cpp/src/IcePatch2/FileServerI.cpp
@@ -35,7 +35,7 @@ IcePatch2::FileServerI::getFileInfoSeq(Int node0, const Current&) const
{
if(node0 < 0 || node0 > 255)
{
- throw PartitionOutOfRangeException();
+ throw PartitionOutOfRangeException();
}
return _tree0.nodes[node0].files;
@@ -48,7 +48,7 @@ IcePatch2::FileServerI::getChecksumSeq(const Current&) const
for(int node0 = 0; node0 < 256; ++node0)
{
- checksums[node0] = _tree0.nodes[node0].checksum;
+ checksums[node0] = _tree0.nodes[node0].checksum;
}
return checksums;
@@ -62,14 +62,14 @@ IcePatch2::FileServerI::getChecksum(const Current&) const
void
IcePatch2::FileServerI::getFileCompressed_async(const AMD_FileServer_getFileCompressedPtr& cb,
- const string& pa, Int pos, Int num, const Current&) const
+ const string& pa, Int pos, Int num, const Current&) const
{
if(isAbsolute(pa))
{
- FileAccessException ex;
- ex.reason = "illegal absolute path `" + pa + "'";
- cb->ice_exception(ex);
- return;
+ FileAccessException ex;
+ ex.reason = "illegal absolute path `" + pa + "'";
+ cb->ice_exception(ex);
+ return;
}
string path = simplify(pa);
@@ -78,39 +78,39 @@ IcePatch2::FileServerI::getFileCompressed_async(const AMD_FileServer_getFileComp
path.find("/../") != string::npos ||
path.size() >= 3 && (path.substr(0, 3) == "../" || path.substr(path.size() - 3, 3) == "/.."))
{
- FileAccessException ex;
- ex.reason = "illegal `..' component in path `" + path + "'";
- cb->ice_exception(ex);
- return;
+ FileAccessException ex;
+ ex.reason = "illegal `..' component in path `" + path + "'";
+ cb->ice_exception(ex);
+ return;
}
pair<const Byte*, const Byte*> ret(0, 0);
if(num <= 0 || pos < 0)
- {
+ {
cb->ice_response(ret);
- return;
+ return;
}
int fd = OS::open(_dataDir + '/' + path + ".bz2", O_RDONLY|O_BINARY);
if(fd == -1)
{
- FileAccessException ex;
- ex.reason = "cannot open `" + path + "' for reading: " + strerror(errno);
- cb->ice_exception(ex);
- return;
+ FileAccessException ex;
+ ex.reason = "cannot open `" + path + "' for reading: " + strerror(errno);
+ cb->ice_exception(ex);
+ return;
}
if(lseek(fd, static_cast<off_t>(pos), SEEK_SET) != static_cast<off_t>(pos))
{
- close(fd);
+ close(fd);
- ostringstream posStr;
- posStr << pos;
+ ostringstream posStr;
+ posStr << pos;
- FileAccessException ex;
- ex.reason = "cannot seek position " + posStr.str() + " in file `" + path + "': " + strerror(errno);
- cb->ice_exception(ex);
- return;
+ FileAccessException ex;
+ ex.reason = "cannot seek position " + posStr.str() + " in file `" + path + "': " + strerror(errno);
+ cb->ice_exception(ex);
+ return;
}
IceUtil::ScopedArray<Byte> bytes(new Byte[num]);
@@ -122,12 +122,12 @@ IcePatch2::FileServerI::getFileCompressed_async(const AMD_FileServer_getFileComp
if((r = read(fd, bytes.get(), static_cast<size_t>(num))) == -1)
#endif
{
- close(fd);
+ close(fd);
- FileAccessException ex;
- ex.reason = "cannot read `" + path + "': " + strerror(errno);
- cb->ice_exception(ex);
- return;
+ FileAccessException ex;
+ ex.reason = "cannot read `" + path + "': " + strerror(errno);
+ cb->ice_exception(ex);
+ return;
}
close(fd);
diff --git a/cpp/src/IcePatch2/FileServerI.h b/cpp/src/IcePatch2/FileServerI.h
index ae02fca4bd2..5c38e33a91b 100644
--- a/cpp/src/IcePatch2/FileServerI.h
+++ b/cpp/src/IcePatch2/FileServerI.h
@@ -29,7 +29,7 @@ public:
Ice::ByteSeq getChecksum(const Ice::Current&) const;
void getFileCompressed_async(const AMD_FileServer_getFileCompressedPtr&, const std::string&, Ice::Int pos,
- Ice::Int num, const Ice::Current&) const;
+ Ice::Int num, const Ice::Current&) const;
private:
diff --git a/cpp/src/IcePatch2/OS.cpp b/cpp/src/IcePatch2/OS.cpp
index 33eedc2d0b7..b57249f82de 100644
--- a/cpp/src/IcePatch2/OS.cpp
+++ b/cpp/src/IcePatch2/OS.cpp
@@ -68,7 +68,7 @@ OS::getcwd(string& cwd)
wchar_t cwdbuf[_MAX_PATH];
if(_wgetcwd(cwdbuf, _MAX_PATH) == NULL)
{
- return -1;
+ return -1;
}
cwd = IceUtil::wstringToString(cwdbuf);
return 0;
@@ -124,7 +124,7 @@ OS::getcwd(string& cwd)
char cwdbuf[PATH_MAX];
if(::getcwd(cwdbuf, PATH_MAX) == NULL)
{
- return -1;
+ return -1;
}
cwd = cwdbuf;
return 0;
diff --git a/cpp/src/IcePatch2/Server.cpp b/cpp/src/IcePatch2/Server.cpp
index a89db23f7af..98ac031b21a 100644
--- a/cpp/src/IcePatch2/Server.cpp
+++ b/cpp/src/IcePatch2/Server.cpp
@@ -25,14 +25,14 @@ class AdminI : public Admin
public:
AdminI(const CommunicatorPtr& communicator) :
- _communicator(communicator)
+ _communicator(communicator)
{
}
virtual void
shutdown(const Current&)
{
- _communicator->shutdown();
+ _communicator->shutdown();
}
private:
@@ -74,61 +74,61 @@ IcePatch2::PatcherService::start(int argc, char* argv[])
vector<string> args;
try
{
- args = opts.parse(argc, (const char**)argv);
+ args = opts.parse(argc, (const char**)argv);
}
catch(const IceUtil::BadOptException& e)
{
error(e.reason);
- usage(argv[0]);
- return false;
+ usage(argv[0]);
+ return false;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return false;
+ usage(argv[0]);
+ return false;
}
if(opts.isSet("version"))
{
- print(ICE_STRING_VERSION);
- return false;
+ print(ICE_STRING_VERSION);
+ return false;
}
if(args.size() > 1)
{
- error("too many arguments");
- usage(argv[0]);
- return false;
+ error("too many arguments");
+ usage(argv[0]);
+ return false;
}
if(args.size() == 1)
{
- properties->setProperty("IcePatch2.Directory", simplify(args[0]));
+ properties->setProperty("IcePatch2.Directory", simplify(args[0]));
}
string dataDir = properties->getPropertyWithDefault("IcePatch2.Directory", ".");
if(dataDir.empty())
{
- error("no data directory specified");
- usage(argv[0]);
- return false;
+ error("no data directory specified");
+ usage(argv[0]);
+ return false;
}
FileInfoSeq infoSeq;
try
{
- if(!isAbsolute(dataDir))
- {
- string cwd;
- if(OS::getcwd(cwd) != 0)
- {
- throw "cannot get the current directory:\n" + lastError();
- }
-
- dataDir = cwd + '/' + dataDir;
- }
-
- loadFileInfoSeq(dataDir, infoSeq);
+ if(!isAbsolute(dataDir))
+ {
+ string cwd;
+ if(OS::getcwd(cwd) != 0)
+ {
+ throw "cannot get the current directory:\n" + lastError();
+ }
+
+ dataDir = cwd + '/' + dataDir;
+ }
+
+ loadFileInfoSeq(dataDir, infoSeq);
}
catch(const string& ex)
{
@@ -146,7 +146,7 @@ IcePatch2::PatcherService::start(int argc, char* argv[])
//
const string endpointsProperty = "Ice.OA.IcePatch2.Endpoints";
string endpoints = properties->getPropertyWithDefault(endpointsProperty,
- properties->getProperty("IcePatch2.Endpoints"));
+ properties->getProperty("IcePatch2.Endpoints"));
if(endpoints.empty())
{
error("property `" + endpointsProperty + "' is not set");
@@ -161,7 +161,7 @@ IcePatch2::PatcherService::start(int argc, char* argv[])
if(!properties->getProperty("Ice.OA.IcePatch2.Admin.Endpoints").empty() ||
!properties->getProperty("IcePatch2.Admin.Endpoints").empty())
{
- adminAdapter = communicator()->createObjectAdapter("IcePatch2.Admin");
+ adminAdapter = communicator()->createObjectAdapter("IcePatch2.Admin");
}
const string instanceNameProperty = "IcePatch2.InstanceName";
@@ -174,16 +174,16 @@ IcePatch2::PatcherService::start(int argc, char* argv[])
if(adminAdapter)
{
- Identity adminId;
- adminId.category = instanceName;
- adminId.name = "admin";
- adminAdapter->add(new AdminI(communicator()), adminId);
+ Identity adminId;
+ adminId.category = instanceName;
+ adminId.name = "admin";
+ adminAdapter->add(new AdminI(communicator()), adminId);
}
adapter->activate();
if(adminAdapter)
{
- adminAdapter->activate();
+ adminAdapter->activate();
}
return true;
@@ -199,30 +199,30 @@ void
IcePatch2::PatcherService::usage(const string& appName)
{
string options =
- "Options:\n"
- "-h, --help Show this message.\n"
- "-v, --version Display the Ice version.";
+ "Options:\n"
+ "-h, --help Show this message.\n"
+ "-v, --version Display the Ice version.";
#ifdef _WIN32
if(checkSystem())
{
options.append(
- "\n"
- "\n"
- "--service NAME Run as the Windows service NAME.\n"
- "\n"
- "--install NAME [--display DISP] [--executable EXEC] [args]\n"
- " Install as Windows service NAME. If DISP is\n"
- " provided, use it as the display name,\n"
- " otherwise NAME is used. If EXEC is provided,\n"
- " use it as the service executable, otherwise\n"
- " this executable is used. Any additional\n"
- " arguments are passed unchanged to the\n"
- " service at startup.\n"
- "--uninstall NAME Uninstall Windows service NAME.\n"
- "--start NAME [args] Start Windows service NAME. Any additional\n"
- " arguments are passed unchanged to the\n"
- " service.\n"
- "--stop NAME Stop Windows service NAME."
+ "\n"
+ "\n"
+ "--service NAME Run as the Windows service NAME.\n"
+ "\n"
+ "--install NAME [--display DISP] [--executable EXEC] [args]\n"
+ " Install as Windows service NAME. If DISP is\n"
+ " provided, use it as the display name,\n"
+ " otherwise NAME is used. If EXEC is provided,\n"
+ " use it as the service executable, otherwise\n"
+ " this executable is used. Any additional\n"
+ " arguments are passed unchanged to the\n"
+ " service at startup.\n"
+ "--uninstall NAME Uninstall Windows service NAME.\n"
+ "--start NAME [args] Start Windows service NAME. Any additional\n"
+ " arguments are passed unchanged to the\n"
+ " service.\n"
+ "--stop NAME Stop Windows service NAME."
);
}
#else
@@ -232,7 +232,7 @@ IcePatch2::PatcherService::usage(const string& appName)
"--daemon Run as a daemon.\n"
"--noclose Do not close open file descriptors."
- // --nochdir is intentionally not shown here. (See the comment in main().)
+ // --nochdir is intentionally not shown here. (See the comment in main().)
);
#endif
print("Usage: " + appName + " [options] [DIR]\n" + options);
@@ -269,13 +269,13 @@ main(int argc, char* argv[])
{
v[i + 1] = new char[strlen(argv[i]) + 1];
strcpy(v[i + 1], argv[i]);
- vsave[i + 1] = v[i + 1];
+ vsave[i + 1] = v[i + 1];
}
v[argc + 1] = 0;
try
{
- int ac = argc + 1;
+ int ac = argc + 1;
status = svc.main(ac, v);
}
catch(...)
diff --git a/cpp/src/IcePatch2/Util.cpp b/cpp/src/IcePatch2/Util.cpp
index f18a1b86b75..57b7890f723 100644
--- a/cpp/src/IcePatch2/Util.cpp
+++ b/cpp/src/IcePatch2/Util.cpp
@@ -44,8 +44,8 @@ const char* IcePatch2::logFile = "IcePatch2.log";
extern "C" static int
ice_scandir(const char* dir, struct dirent*** namelist,
- int (*select)(const struct dirent*),
- int (*compar)(const void*, const void*))
+ int (*select)(const struct dirent*),
+ int (*compar)(const void*, const void*))
{
DIR* d;
struct dirent* entry;
@@ -54,46 +54,46 @@ ice_scandir(const char* dir, struct dirent*** namelist,
if((d = opendir(dir)) == 0)
{
- return -1;
+ return -1;
}
*namelist = 0;
while((entry = readdir(d)) != 0)
{
- if(select == 0 || (select != 0 && (*select)(entry)))
- {
- *namelist = (struct dirent**)realloc((void*)(*namelist), (size_t)((i + 1) * sizeof(struct dirent*)));
- if(*namelist == 0)
- {
- closedir(d);
- return -1;
- }
-
- entrysize = sizeof(struct dirent) - sizeof(entry->d_name) + strlen(entry->d_name) + 1;
- (*namelist)[i] = (struct dirent*)malloc(entrysize);
- if((*namelist)[i] == 0)
- {
- closedir(d);
- return -1;
- }
- memcpy((*namelist)[i], entry, entrysize);
- ++i;
- }
+ if(select == 0 || (select != 0 && (*select)(entry)))
+ {
+ *namelist = (struct dirent**)realloc((void*)(*namelist), (size_t)((i + 1) * sizeof(struct dirent*)));
+ if(*namelist == 0)
+ {
+ closedir(d);
+ return -1;
+ }
+
+ entrysize = sizeof(struct dirent) - sizeof(entry->d_name) + strlen(entry->d_name) + 1;
+ (*namelist)[i] = (struct dirent*)malloc(entrysize);
+ if((*namelist)[i] == 0)
+ {
+ closedir(d);
+ return -1;
+ }
+ memcpy((*namelist)[i], entry, entrysize);
+ ++i;
+ }
}
if(closedir(d))
{
- return -1;
+ return -1;
}
if(i == 0)
{
- return -1;
+ return -1;
}
if(compar != 0)
{
- qsort((void *)(*namelist), (size_t)i, sizeof(struct dirent *), compar);
+ qsort((void *)(*namelist), (size_t)i, sizeof(struct dirent *), compar);
}
return i;
@@ -117,10 +117,10 @@ bool
IcePatch2::writeFileInfo(FILE* fp, const FileInfo& info)
{
int rc = fprintf(fp, "%s\t%s\t%d\t%d\n",
- IceUtil::escapeString(info.path, "").c_str(),
- bytesToString(info.checksum).c_str(),
- info.size,
- static_cast<int>(info.executable));
+ IceUtil::escapeString(info.path, "").c_str(),
+ bytesToString(info.checksum).c_str(),
+ info.size,
+ static_cast<int>(info.executable));
return rc > 0;
}
@@ -131,17 +131,17 @@ IcePatch2::readFileInfo(FILE* fp, FileInfo& info)
char buf[BUFSIZ];
while(fgets(buf, static_cast<int>(sizeof(buf)), fp) != 0)
{
- data += buf;
+ data += buf;
- size_t len = strlen(buf);
- if(buf[len - 1] == '\n')
- {
- break;
- }
+ size_t len = strlen(buf);
+ if(buf[len - 1] == '\n')
+ {
+ break;
+ }
}
if(data.empty())
{
- return false;
+ return false;
}
istringstream is(data);
@@ -165,31 +165,31 @@ IcePatch2::lastError()
#ifdef _WIN32
LPVOID lpMsgBuf = 0;
DWORD ok = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPTSTR)&lpMsgBuf,
- 0,
- NULL);
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR)&lpMsgBuf,
+ 0,
+ NULL);
if(ok)
{
- LPCTSTR msg = (LPCTSTR)lpMsgBuf;
- assert(msg && strlen((const char*)msg) > 0);
- string result = (const char*)msg;
- LocalFree(lpMsgBuf);
+ LPCTSTR msg = (LPCTSTR)lpMsgBuf;
+ assert(msg && strlen((const char*)msg) > 0);
+ string result = (const char*)msg;
+ LocalFree(lpMsgBuf);
- while(result.size() >= 1 && (result[result.size() - 1] == '\n' || result[result.size() - 1] == '\r'))
- {
- result.erase(result.size() - 1);
- }
+ while(result.size() >= 1 && (result[result.size() - 1] == '\n' || result[result.size() - 1] == '\r'))
+ {
+ result.erase(result.size() - 1);
+ }
- return result;
+ return result;
}
else
{
- return "unknown error";
+ return "unknown error";
}
#else
return strerror(errno);
@@ -204,7 +204,7 @@ IcePatch2::bytesToString(const ByteSeq& bytes)
for(ByteSeq::const_iterator p = bytes.begin(); p != bytes.end(); ++p)
{
- s << setw(2) << setfill('0') << hex << static_cast<int>(*p);
+ s << setw(2) << setfill('0') << hex << static_cast<int>(*p);
}
return s.str();
@@ -217,8 +217,8 @@ IcePatch2::bytesToString(const ByteSeq& bytes)
for(unsigned int i = 0; i < bytes.size(); ++i)
{
- s[i * 2] = toHex[(bytes[i] >> 4) & 0xf];
- s[i * 2 + 1] = toHex[bytes[i] & 0xf];
+ s[i * 2] = toHex[(bytes[i] >> 4) & 0xf];
+ s[i * 2 + 1] = toHex[bytes[i] & 0xf];
}
return s;
@@ -233,37 +233,37 @@ IcePatch2::stringToBytes(const string& str)
for(unsigned int i = 0; i + 1 < str.size(); i += 2)
{
/*
- istringstream is(str.substr(i, 2));
- int byte;
- is >> hex >> byte;
+ istringstream is(str.substr(i, 2));
+ int byte;
+ is >> hex >> byte;
*/
- int byte = 0;
+ int byte = 0;
- for(int j = 0; j < 2; ++j)
- {
- char c = str[i + j];
+ for(int j = 0; j < 2; ++j)
+ {
+ char c = str[i + j];
- if(c >= '0' && c <= '9')
- {
- byte |= c - '0';
- }
- else if(c >= 'a' && c <= 'f')
- {
- byte |= 10 + c - 'a';
- }
- else if(c >= 'A' && c <= 'F')
- {
- byte |= 10 + c - 'A';
- }
+ if(c >= '0' && c <= '9')
+ {
+ byte |= c - '0';
+ }
+ else if(c >= 'a' && c <= 'f')
+ {
+ byte |= 10 + c - 'a';
+ }
+ else if(c >= 'A' && c <= 'F')
+ {
+ byte |= 10 + c - 'A';
+ }
- if(j == 0)
- {
- byte <<= 4;
- }
- }
+ if(j == 0)
+ {
+ byte <<= 4;
+ }
+ }
- bytes.push_back(static_cast<Byte>(byte));
+ bytes.push_back(static_cast<Byte>(byte));
}
return bytes;
@@ -279,23 +279,23 @@ IcePatch2::simplify(const string& path)
#ifdef _WIN32
for(pos = 0; pos < result.size(); ++pos)
{
- if(result[pos] == '\\')
- {
- result[pos] = '/';
- }
+ if(result[pos] == '\\')
+ {
+ result[pos] = '/';
+ }
}
#endif
pos = 0;
while((pos = result.find("//", pos)) != string::npos)
{
- result.erase(pos, 1);
+ result.erase(pos, 1);
}
pos = 0;
while((pos = result.find("/./", pos)) != string::npos)
{
- result.erase(pos, 2);
+ result.erase(pos, 2);
}
while(result.substr(0, 4) == "/../")
@@ -305,7 +305,7 @@ IcePatch2::simplify(const string& path)
if(result.substr(0, 2) == "./")
{
- result.erase(0, 2);
+ result.erase(0, 2);
}
if(result == "/." ||
@@ -316,7 +316,7 @@ IcePatch2::simplify(const string& path)
if(result.size() >= 2 && result.substr(result.size() - 2, 2) == "/.")
{
- result.erase(result.size() - 2, 2);
+ result.erase(result.size() - 2, 2);
}
if(result == "/" || result.size() == 3 && isalpha(result[0]) && result[1] == ':' && result[2] == '/')
@@ -326,7 +326,7 @@ IcePatch2::simplify(const string& path)
if(result.size() >= 1 && result[result.size() - 1] == '/')
{
- result.erase(result.size() - 1);
+ result.erase(result.size() - 1);
}
if(result == "/..")
@@ -342,7 +342,7 @@ IcePatch2::isAbsolute(const string& pa)
{
if(pa.empty())
{
- return false;
+ return false;
}
unsigned i = 0;
@@ -378,7 +378,7 @@ IcePatch2::getSuffix(const string& pa)
if(dotPos == string::npos || slashPos != string::npos && slashPos > dotPos)
{
- return string();
+ return string();
}
return path.substr(dotPos + 1);
@@ -394,7 +394,7 @@ IcePatch2::getWithoutSuffix(const string& pa)
if(dotPos == string::npos || slashPos != string::npos && slashPos > dotPos)
{
- return path;
+ return path;
}
return path.substr(0, dotPos);
@@ -405,9 +405,9 @@ IcePatch2::ignoreSuffix(const string& path)
{
string suffix = getSuffix(path);
return suffix == "md5" // For legacy IcePatch.
- || suffix == "tot" // For legacy IcePatch.
- || suffix == "bz2"
- || suffix == "bz2temp";
+ || suffix == "tot" // For legacy IcePatch.
+ || suffix == "bz2"
+ || suffix == "bz2temp";
}
string
@@ -418,11 +418,11 @@ IcePatch2::getBasename(const string& pa)
string::size_type pos = path.rfind('/');
if(pos == string::npos)
{
- return path;
+ return path;
}
else
{
- return path.substr(pos + 1);
+ return path.substr(pos + 1);
}
}
@@ -434,11 +434,11 @@ IcePatch2::getDirname(const string& pa)
string::size_type pos = path.rfind('/');
if(pos == string::npos)
{
- return string();
+ return string();
}
else
{
- return path.substr(0, pos);
+ return path.substr(0, pos);
}
}
@@ -453,7 +453,7 @@ IcePatch2::rename(const string& fromPa, const string& toPa)
if(OS::rename(fromPath ,toPath) == -1)
{
- throw "cannot rename `" + fromPath + "' to `" + toPath + "': " + lastError();
+ throw "cannot rename `" + fromPath + "' to `" + toPath + "': " + lastError();
}
}
@@ -465,26 +465,26 @@ IcePatch2::remove(const string& pa)
OS::structstat buf;
if(OS::osstat(path, &buf) == -1)
{
- throw "cannot stat `" + path + "':\n" + lastError();
+ throw "cannot stat `" + path + "':\n" + lastError();
}
if(S_ISDIR(buf.st_mode))
{
- if(OS::rmdir(path) == -1)
- {
- if(errno == EACCES)
- {
- assert(false);
- }
- throw "cannot remove directory `" + path + "':\n" + lastError();
- }
+ if(OS::rmdir(path) == -1)
+ {
+ if(errno == EACCES)
+ {
+ assert(false);
+ }
+ throw "cannot remove directory `" + path + "':\n" + lastError();
+ }
}
else
{
- if(OS::remove(path) == -1)
- {
- throw "cannot remove file `" + path + "':\n" + lastError();
- }
+ if(OS::remove(path) == -1)
+ {
+ throw "cannot remove file `" + path + "':\n" + lastError();
+ }
}
}
@@ -496,31 +496,31 @@ IcePatch2::removeRecursive(const string& pa)
OS::structstat buf;
if(OS::osstat(path, &buf) == -1)
{
- throw "cannot stat `" + path + "':\n" + lastError();
+ throw "cannot stat `" + path + "':\n" + lastError();
}
if(S_ISDIR(buf.st_mode))
{
- StringSeq paths = readDirectory(path);
- for(StringSeq::const_iterator p = paths.begin(); p != paths.end(); ++p)
- {
- removeRecursive(path + '/' + *p);
- }
+ StringSeq paths = readDirectory(path);
+ for(StringSeq::const_iterator p = paths.begin(); p != paths.end(); ++p)
+ {
+ removeRecursive(path + '/' + *p);
+ }
- if(!isRoot(path))
- {
- if(OS::rmdir(path) == -1)
- {
- throw "cannot remove directory `" + path + "':\n" + lastError();
- }
- }
+ if(!isRoot(path))
+ {
+ if(OS::rmdir(path) == -1)
+ {
+ throw "cannot remove directory `" + path + "':\n" + lastError();
+ }
+ }
}
else
{
- if(OS::remove(path) == -1)
- {
- throw "cannot remove file `" + path + "':\n" + lastError();
- }
+ if(OS::remove(path) == -1)
+ {
+ throw "cannot remove file `" + path + "':\n" + lastError();
+ }
}
}
@@ -539,35 +539,35 @@ IcePatch2::readDirectory(const string& pa)
int h = _wfindfirst(fs.c_str(), &data, FA_DIREC);
if(h == -1)
{
- if(_doserrno == ENMFILE)
- {
- return result;
- }
- throw "cannot read directory `" + path + "':\n" + lastError();
+ if(_doserrno == ENMFILE)
+ {
+ return result;
+ }
+ throw "cannot read directory `" + path + "':\n" + lastError();
}
while(true)
{
- string name = IceUtil::wstringToString(data.ff_name);
- assert(!name.empty());
+ string name = IceUtil::wstringToString(data.ff_name);
+ assert(!name.empty());
- if(name != ".." && name != ".")
- {
- result.push_back(name);
- }
+ if(name != ".." && name != ".")
+ {
+ result.push_back(name);
+ }
- if(_wfindnext(&data) == -1)
- {
- if(errno == ENOENT)
- {
- break;
- }
+ if(_wfindnext(&data) == -1)
+ {
+ if(errno == ENOENT)
+ {
+ break;
+ }
- string ex = "cannot read directory `" + path + "':\n" + lastError();
- _wfindclose(&data);
- throw ex;
- }
+ string ex = "cannot read directory `" + path + "':\n" + lastError();
+ _wfindclose(&data);
+ throw ex;
+ }
}
_wfindclose(&data);
@@ -623,7 +623,7 @@ IcePatch2::readDirectory(const string& pa)
#endif
if(n < 0)
{
- throw "cannot read directory `" + path + "':\n" + lastError();
+ throw "cannot read directory `" + path + "':\n" + lastError();
}
StringSeq result;
@@ -631,15 +631,15 @@ IcePatch2::readDirectory(const string& pa)
for(int i = 0; i < n; ++i)
{
- string name = namelist[i]->d_name;
- assert(!name.empty());
+ string name = namelist[i]->d_name;
+ assert(!name.empty());
- free(namelist[i]);
+ free(namelist[i]);
- if(name != ".." && name != ".")
- {
- result.push_back(name);
- }
+ if(name != ".." && name != ".")
+ {
+ result.push_back(name);
+ }
}
free(namelist);
@@ -655,10 +655,10 @@ IcePatch2::createDirectory(const string& pa)
if(OS::mkdir(path, 0777) == -1)
{
- if(errno != EEXIST)
- {
- throw "cannot create directory `" + path + "':\n" + lastError();
- }
+ if(errno != EEXIST)
+ {
+ throw "cannot create directory `" + path + "':\n" + lastError();
+ }
}
}
@@ -670,26 +670,26 @@ IcePatch2::createDirectoryRecursive(const string& pa)
string dir = getDirname(path);
if(!dir.empty())
{
- createDirectoryRecursive(dir);
+ createDirectoryRecursive(dir);
}
if(!isRoot(path + "/"))
{
- OS::structstat buf;
- if(OS::osstat(path, &buf) != -1)
- {
- if(S_ISDIR(buf.st_mode))
- {
- return;
- }
- }
+ OS::structstat buf;
+ if(OS::osstat(path, &buf) != -1)
+ {
+ if(S_ISDIR(buf.st_mode))
+ {
+ return;
+ }
+ }
if(OS::mkdir(path, 0777) == -1)
{
- if(errno != EEXIST)
- {
- throw "cannot create directory `" + path + "':\n" + lastError();
- }
+ if(errno != EEXIST)
+ {
+ throw "cannot create directory `" + path + "':\n" + lastError();
+ }
}
}
}
@@ -702,45 +702,45 @@ IcePatch2::compressBytesToFile(const string& pa, const ByteSeq& bytes, Int pos)
FILE* stdioFile = OS::fopen(path, "wb");
if(!stdioFile)
{
- throw "cannot open `" + path + "' for writing:\n" + lastError();
+ throw "cannot open `" + path + "' for writing:\n" + lastError();
}
int bzError;
BZFILE* bzFile = BZ2_bzWriteOpen(&bzError, stdioFile, 5, 0, 0);
if(bzError != BZ_OK)
{
- string ex = "BZ2_bzWriteOpen failed";
- if(bzError == BZ_IO_ERROR)
- {
- ex += string(": ") + lastError();
- }
- fclose(stdioFile);
- throw ex;
+ string ex = "BZ2_bzWriteOpen failed";
+ if(bzError == BZ_IO_ERROR)
+ {
+ ex += string(": ") + lastError();
+ }
+ fclose(stdioFile);
+ throw ex;
}
BZ2_bzWrite(&bzError, bzFile, const_cast<Byte*>(&bytes[pos]), static_cast<int>(bytes.size() - pos));
if(bzError != BZ_OK)
{
- string ex = "BZ2_bzWrite failed";
- if(bzError == BZ_IO_ERROR)
- {
- ex += string(": ") + lastError();
- }
- BZ2_bzWriteClose(&bzError, bzFile, 0, 0, 0);
- fclose(stdioFile);
- throw ex;
+ string ex = "BZ2_bzWrite failed";
+ if(bzError == BZ_IO_ERROR)
+ {
+ ex += string(": ") + lastError();
+ }
+ BZ2_bzWriteClose(&bzError, bzFile, 0, 0, 0);
+ fclose(stdioFile);
+ throw ex;
}
BZ2_bzWriteClose(&bzError, bzFile, 0, 0, 0);
if(bzError != BZ_OK)
{
- string ex = "BZ2_bzWriteClose failed";
- if(bzError == BZ_IO_ERROR)
- {
- ex += string(": ") + lastError();
- }
- fclose(stdioFile);
- throw ex;
+ string ex = "BZ2_bzWriteClose failed";
+ if(bzError == BZ_IO_ERROR)
+ {
+ ex += string(": ") + lastError();
+ }
+ fclose(stdioFile);
+ throw ex;
}
fclose(stdioFile);
@@ -759,136 +759,136 @@ IcePatch2::decompressFile(const string& pa)
try
{
- fp = OS::fopen(path, "wb");
- if(!fp)
- {
- throw "cannot open `" + path + "' for writing:\n" + lastError();
- }
-
- stdioFileBZ2 = OS::fopen(pathBZ2, "rb");
- if(!stdioFileBZ2)
- {
- throw "cannot open `" + pathBZ2 + "' for reading:\n" + lastError();
- }
+ fp = OS::fopen(path, "wb");
+ if(!fp)
+ {
+ throw "cannot open `" + path + "' for writing:\n" + lastError();
+ }
+
+ stdioFileBZ2 = OS::fopen(pathBZ2, "rb");
+ if(!stdioFileBZ2)
+ {
+ throw "cannot open `" + pathBZ2 + "' for reading:\n" + lastError();
+ }
#ifdef __BCPLUSPLUS__
- //
- // The BZ2_bzReadOpen/BZ2_bzRead/BZ2_bzReadClose functions fail with BCC
- //
- OS::structstat buf;
- if(OS::osstat(pathBZ2, &buf) == -1)
- {
- throw "cannot stat `" + pathBZ2 + "':\n" + lastError();
- }
-
- ByteSeq compressedBytes(buf.st_size);
- if(fread(&compressedBytes[0], buf.st_size, 1, stdioFileBZ2) == -1)
- {
- throw "cannot read from `" + pathBZ2 + "':\n" + lastError();
- }
-
- ByteSeq uncompressedBytes;
- unsigned int uncompressedLen = buf.st_size * 2;
- while(true)
- {
- uncompressedBytes.resize(uncompressedLen);
- int bzError = BZ2_bzBuffToBuffDecompress(&uncompressedBytes[0], &uncompressedLen, &compressedBytes[0],
- buf.st_size, 0, 0);
- if(bzError == BZ_OK)
- {
- break;
- }
- else if(bzError == BZ_OUTBUFF_FULL)
- {
- uncompressedLen *= 2;
- continue;
- }
- else
- {
- string ex = "BZ2_bzBuffToBuffDecompress failed";
- if(bzError == BZ_IO_ERROR)
- {
- ex += string(": ") + lastError();
- }
- throw ex;
- }
- }
-
- if(fwrite(&uncompressedBytes[0], uncompressedLen, 1, fp) != 1)
- {
- throw "cannot write to `" + path + "':\n" + lastError();
- }
+ //
+ // The BZ2_bzReadOpen/BZ2_bzRead/BZ2_bzReadClose functions fail with BCC
+ //
+ OS::structstat buf;
+ if(OS::osstat(pathBZ2, &buf) == -1)
+ {
+ throw "cannot stat `" + pathBZ2 + "':\n" + lastError();
+ }
+
+ ByteSeq compressedBytes(buf.st_size);
+ if(fread(&compressedBytes[0], buf.st_size, 1, stdioFileBZ2) == -1)
+ {
+ throw "cannot read from `" + pathBZ2 + "':\n" + lastError();
+ }
+
+ ByteSeq uncompressedBytes;
+ unsigned int uncompressedLen = buf.st_size * 2;
+ while(true)
+ {
+ uncompressedBytes.resize(uncompressedLen);
+ int bzError = BZ2_bzBuffToBuffDecompress(&uncompressedBytes[0], &uncompressedLen, &compressedBytes[0],
+ buf.st_size, 0, 0);
+ if(bzError == BZ_OK)
+ {
+ break;
+ }
+ else if(bzError == BZ_OUTBUFF_FULL)
+ {
+ uncompressedLen *= 2;
+ continue;
+ }
+ else
+ {
+ string ex = "BZ2_bzBuffToBuffDecompress failed";
+ if(bzError == BZ_IO_ERROR)
+ {
+ ex += string(": ") + lastError();
+ }
+ throw ex;
+ }
+ }
+
+ if(fwrite(&uncompressedBytes[0], uncompressedLen, 1, fp) != 1)
+ {
+ throw "cannot write to `" + path + "':\n" + lastError();
+ }
#else
- bzFile = BZ2_bzReadOpen(&bzError, stdioFileBZ2, 0, 0, 0, 0);
- if(bzError != BZ_OK)
- {
- string ex = "BZ2_bzReadOpen failed";
- if(bzError == BZ_IO_ERROR)
- {
- ex += string(": ") + lastError();
- }
- throw ex;
- }
-
- const Int numBZ2 = 64 * 1024;
- Byte bytesBZ2[numBZ2];
-
- while(bzError != BZ_STREAM_END)
- {
- int sz = BZ2_bzRead(&bzError, bzFile, bytesBZ2, numBZ2);
- if(bzError != BZ_OK && bzError != BZ_STREAM_END)
- {
- string ex = "BZ2_bzRead failed";
- if(bzError == BZ_IO_ERROR)
- {
- ex += string(": ") + lastError();
- }
- throw ex;
- }
-
- if(sz > 0)
- {
- long pos = ftell(stdioFileBZ2);
- if(pos == -1)
- {
- throw "cannot get read position for `" + pathBZ2 + "':\n" + lastError();
- }
-
- if(fwrite(bytesBZ2, sz, 1, fp) != 1)
- {
- throw "cannot write to `" + path + "':\n" + lastError();
- }
- }
- }
-
- BZ2_bzReadClose(&bzError, bzFile);
- bzFile = 0;
- if(bzError != BZ_OK)
- {
- string ex = "BZ2_bzReadClose failed";
- if(bzError == BZ_IO_ERROR)
- {
- ex += string(": ") + lastError();
- }
- throw ex;
- }
+ bzFile = BZ2_bzReadOpen(&bzError, stdioFileBZ2, 0, 0, 0, 0);
+ if(bzError != BZ_OK)
+ {
+ string ex = "BZ2_bzReadOpen failed";
+ if(bzError == BZ_IO_ERROR)
+ {
+ ex += string(": ") + lastError();
+ }
+ throw ex;
+ }
+
+ const Int numBZ2 = 64 * 1024;
+ Byte bytesBZ2[numBZ2];
+
+ while(bzError != BZ_STREAM_END)
+ {
+ int sz = BZ2_bzRead(&bzError, bzFile, bytesBZ2, numBZ2);
+ if(bzError != BZ_OK && bzError != BZ_STREAM_END)
+ {
+ string ex = "BZ2_bzRead failed";
+ if(bzError == BZ_IO_ERROR)
+ {
+ ex += string(": ") + lastError();
+ }
+ throw ex;
+ }
+
+ if(sz > 0)
+ {
+ long pos = ftell(stdioFileBZ2);
+ if(pos == -1)
+ {
+ throw "cannot get read position for `" + pathBZ2 + "':\n" + lastError();
+ }
+
+ if(fwrite(bytesBZ2, sz, 1, fp) != 1)
+ {
+ throw "cannot write to `" + path + "':\n" + lastError();
+ }
+ }
+ }
+
+ BZ2_bzReadClose(&bzError, bzFile);
+ bzFile = 0;
+ if(bzError != BZ_OK)
+ {
+ string ex = "BZ2_bzReadClose failed";
+ if(bzError == BZ_IO_ERROR)
+ {
+ ex += string(": ") + lastError();
+ }
+ throw ex;
+ }
#endif
}
catch(...)
{
- if(bzFile != 0)
- {
- BZ2_bzReadClose(&bzError, bzFile);
- }
- if(stdioFileBZ2 != 0)
- {
- fclose(stdioFileBZ2);
- }
- if(fp != 0)
- {
- fclose(fp);
- }
- throw;
+ if(bzFile != 0)
+ {
+ BZ2_bzReadClose(&bzError, bzFile);
+ }
+ if(stdioFileBZ2 != 0)
+ {
+ fclose(stdioFileBZ2);
+ }
+ if(fp != 0)
+ {
+ fclose(fp);
+ }
+ throw;
}
fclose(stdioFileBZ2);
@@ -903,7 +903,7 @@ IcePatch2::setFileFlags(const string& pa, const FileInfo& info)
OS::structstat buf;
if(OS::osstat(path, &buf) == -1)
{
- throw "cannot stat `" + path + "':\n" + lastError();
+ throw "cannot stat `" + path + "':\n" + lastError();
}
chmod(path.c_str(), info.executable ? buf.st_mode | S_IXUSR : buf.st_mode & ~S_IXUSR);
#endif
@@ -911,321 +911,321 @@ IcePatch2::setFileFlags(const string& pa, const FileInfo& info)
static bool
getFileInfoSeqInt(const string& basePath, const string& relPath, int compress, GetFileInfoSeqCB* cb,
- FileInfoSeq& infoSeq)
+ FileInfoSeq& infoSeq)
{
if(relPath == checksumFile || relPath == logFile)
{
- return true;
+ return true;
}
const string path = simplify(basePath + '/' + relPath);
if(ignoreSuffix(path))
{
- const string pathWithoutSuffix = getWithoutSuffix(path);
-
- if(ignoreSuffix(pathWithoutSuffix))
- {
- if(cb && !cb->remove(relPath))
- {
- return false;
- }
-
- remove(path); // Removing file with suffix for another file that already has a suffix.
- }
- else
- {
- OS::structstat buf;
- if(OS::osstat(getWithoutSuffix(path), &buf) == -1)
- {
- if(errno == ENOENT)
- {
- if(cb && !cb->remove(relPath))
- {
- return false;
- }
-
- remove(path); // Removing orphaned file.
- }
- else
- {
- throw "cannot stat `" + path + "':\n" + lastError();
- }
- }
- else if(buf.st_size == 0)
- {
- if(cb && !cb->remove(relPath))
- {
- return false;
- }
-
- remove(path); // Removing file with suffix for empty file.
- }
- }
+ const string pathWithoutSuffix = getWithoutSuffix(path);
+
+ if(ignoreSuffix(pathWithoutSuffix))
+ {
+ if(cb && !cb->remove(relPath))
+ {
+ return false;
+ }
+
+ remove(path); // Removing file with suffix for another file that already has a suffix.
+ }
+ else
+ {
+ OS::structstat buf;
+ if(OS::osstat(getWithoutSuffix(path), &buf) == -1)
+ {
+ if(errno == ENOENT)
+ {
+ if(cb && !cb->remove(relPath))
+ {
+ return false;
+ }
+
+ remove(path); // Removing orphaned file.
+ }
+ else
+ {
+ throw "cannot stat `" + path + "':\n" + lastError();
+ }
+ }
+ else if(buf.st_size == 0)
+ {
+ if(cb && !cb->remove(relPath))
+ {
+ return false;
+ }
+
+ remove(path); // Removing file with suffix for empty file.
+ }
+ }
}
else
{
- OS::structstat buf;
- if(OS::osstat(path, &buf) == -1)
- {
- throw "cannot stat `" + path + "':\n" + lastError();
- }
-
- if(S_ISDIR(buf.st_mode))
- {
- FileInfo info;
- info.path = relPath;
- info.size = -1;
- info.executable = false;
-
- ByteSeq bytes(relPath.size());
- copy(relPath.begin(), relPath.end(), bytes.begin());
-
- ByteSeq bytesSHA(20);
- if(!bytes.empty())
- {
- SHA1(reinterpret_cast<unsigned char*>(&bytes[0]), bytes.size(),
- reinterpret_cast<unsigned char*>(&bytesSHA[0]));
- }
- else
- {
- fill(bytesSHA.begin(), bytesSHA.end(), 0);
- }
- info.checksum.swap(bytesSHA);
-
- infoSeq.push_back(info);
-
- StringSeq content = readDirectory(path);
- for(StringSeq::const_iterator p = content.begin(); p != content.end() ; ++p)
- {
- if(!getFileInfoSeqInt(basePath, simplify(relPath + '/' + *p), compress, cb, infoSeq))
- {
- return false;
- }
- }
- }
- else if(S_ISREG(buf.st_mode))
- {
- FileInfo info;
- info.path = relPath;
- info.size = 0;
+ OS::structstat buf;
+ if(OS::osstat(path, &buf) == -1)
+ {
+ throw "cannot stat `" + path + "':\n" + lastError();
+ }
+
+ if(S_ISDIR(buf.st_mode))
+ {
+ FileInfo info;
+ info.path = relPath;
+ info.size = -1;
+ info.executable = false;
+
+ ByteSeq bytes(relPath.size());
+ copy(relPath.begin(), relPath.end(), bytes.begin());
+
+ ByteSeq bytesSHA(20);
+ if(!bytes.empty())
+ {
+ SHA1(reinterpret_cast<unsigned char*>(&bytes[0]), bytes.size(),
+ reinterpret_cast<unsigned char*>(&bytesSHA[0]));
+ }
+ else
+ {
+ fill(bytesSHA.begin(), bytesSHA.end(), 0);
+ }
+ info.checksum.swap(bytesSHA);
+
+ infoSeq.push_back(info);
+
+ StringSeq content = readDirectory(path);
+ for(StringSeq::const_iterator p = content.begin(); p != content.end() ; ++p)
+ {
+ if(!getFileInfoSeqInt(basePath, simplify(relPath + '/' + *p), compress, cb, infoSeq))
+ {
+ return false;
+ }
+ }
+ }
+ else if(S_ISREG(buf.st_mode))
+ {
+ FileInfo info;
+ info.path = relPath;
+ info.size = 0;
#ifdef _WIN32
- info.executable = false; // Windows doesn't support the executable flag
+ info.executable = false; // Windows doesn't support the executable flag
#else
- info.executable = buf.st_mode & S_IXUSR;
+ info.executable = buf.st_mode & S_IXUSR;
#endif
OS::structstat bufBZ2;
- const string pathBZ2 = path + ".bz2";
- bool doCompress = false;
- if(buf.st_size != 0 && compress > 0)
- {
- //
- // compress == 0: Never compress.
- // compress == 1: Compress if necessary.
- // compress >= 2: Always compress.
- //
- if(compress >= 2 || OS::osstat(pathBZ2, &bufBZ2) == -1 || buf.st_mtime >= bufBZ2.st_mtime)
- {
- if(cb && !cb->compress(relPath))
- {
- return false;
- }
-
- doCompress = true;
- }
- else
- {
- info.size = static_cast<Int>(bufBZ2.st_size);
- }
- }
-
- if(cb && !cb->checksum(relPath))
- {
- return false;
- }
-
- ByteSeq bytesSHA(20);
-
- if(relPath.size() + buf.st_size == 0)
- {
- fill(bytesSHA.begin(), bytesSHA.end(), 0);
- }
- else
- {
- SHA_CTX ctx;
- SHA1_Init(&ctx);
- if(relPath.size() != 0)
- {
- SHA1_Update(&ctx, reinterpret_cast<const void*>(relPath.c_str()), relPath.size());
- }
-
- if(buf.st_size != 0)
- {
+ const string pathBZ2 = path + ".bz2";
+ bool doCompress = false;
+ if(buf.st_size != 0 && compress > 0)
+ {
+ //
+ // compress == 0: Never compress.
+ // compress == 1: Compress if necessary.
+ // compress >= 2: Always compress.
+ //
+ if(compress >= 2 || OS::osstat(pathBZ2, &bufBZ2) == -1 || buf.st_mtime >= bufBZ2.st_mtime)
+ {
+ if(cb && !cb->compress(relPath))
+ {
+ return false;
+ }
+
+ doCompress = true;
+ }
+ else
+ {
+ info.size = static_cast<Int>(bufBZ2.st_size);
+ }
+ }
+
+ if(cb && !cb->checksum(relPath))
+ {
+ return false;
+ }
+
+ ByteSeq bytesSHA(20);
+
+ if(relPath.size() + buf.st_size == 0)
+ {
+ fill(bytesSHA.begin(), bytesSHA.end(), 0);
+ }
+ else
+ {
+ SHA_CTX ctx;
+ SHA1_Init(&ctx);
+ if(relPath.size() != 0)
+ {
+ SHA1_Update(&ctx, reinterpret_cast<const void*>(relPath.c_str()), relPath.size());
+ }
+
+ if(buf.st_size != 0)
+ {
#ifdef __BCPLUSPLUS__
- //
- // The BZ2_bzWriteOpen/BZ2_bzWrite/BZ2_bzWriteClose functions fail with BCC
- //
- if(doCompress)
- {
- int fd = OS::open(path.c_str(), O_BINARY|O_RDONLY);
- if(fd == -1)
- {
- throw "cannot open `" + path + "' for reading:\n" + lastError();
- }
-
- ByteSeq uncompressedBytes(buf.st_size);
-
- if(read(fd, &uncompressedBytes[0], buf.st_size) == -1)
- {
- close(fd);
- throw "cannot read from `" + path + "':\n" + lastError();
- }
-
- unsigned int compressedLen = buf.st_size * 1.01 + 600;
- ByteSeq compressedBytes(compressedLen);
-
- int bzError = BZ2_bzBuffToBuffCompress(&compressedBytes[0], &compressedLen,
- &uncompressedBytes[0], buf.st_size, 5, 0, 0);
- if(bzError != BZ_OK)
- {
- string ex = "BZ2_bzBuffToBuffCompress failed";
- if(bzError == BZ_IO_ERROR)
- {
- ex += string(": ") + lastError();
- }
- close(fd);
- throw ex;
- }
- close(fd);
-
- const string pathBZ2Temp = path + ".bz2temp";
- FILE* stdioFile = OS::fopen(pathBZ2Temp, "wb");
- if(fwrite(&compressedBytes[0], compressedLen, 1, stdioFile) != 1)
- {
- fclose(stdioFile);
- throw "cannot write to `" + pathBZ2Temp + "':\n" + lastError();
- }
- fclose(stdioFile);
-
- rename(pathBZ2Temp, pathBZ2);
-
- }
+ //
+ // The BZ2_bzWriteOpen/BZ2_bzWrite/BZ2_bzWriteClose functions fail with BCC
+ //
+ if(doCompress)
+ {
+ int fd = OS::open(path.c_str(), O_BINARY|O_RDONLY);
+ if(fd == -1)
+ {
+ throw "cannot open `" + path + "' for reading:\n" + lastError();
+ }
+
+ ByteSeq uncompressedBytes(buf.st_size);
+
+ if(read(fd, &uncompressedBytes[0], buf.st_size) == -1)
+ {
+ close(fd);
+ throw "cannot read from `" + path + "':\n" + lastError();
+ }
+
+ unsigned int compressedLen = buf.st_size * 1.01 + 600;
+ ByteSeq compressedBytes(compressedLen);
+
+ int bzError = BZ2_bzBuffToBuffCompress(&compressedBytes[0], &compressedLen,
+ &uncompressedBytes[0], buf.st_size, 5, 0, 0);
+ if(bzError != BZ_OK)
+ {
+ string ex = "BZ2_bzBuffToBuffCompress failed";
+ if(bzError == BZ_IO_ERROR)
+ {
+ ex += string(": ") + lastError();
+ }
+ close(fd);
+ throw ex;
+ }
+ close(fd);
+
+ const string pathBZ2Temp = path + ".bz2temp";
+ FILE* stdioFile = OS::fopen(pathBZ2Temp, "wb");
+ if(fwrite(&compressedBytes[0], compressedLen, 1, stdioFile) != 1)
+ {
+ fclose(stdioFile);
+ throw "cannot write to `" + pathBZ2Temp + "':\n" + lastError();
+ }
+ fclose(stdioFile);
+
+ rename(pathBZ2Temp, pathBZ2);
+
+ }
#endif
- int fd = OS::open(path.c_str(), O_BINARY|O_RDONLY);
- if(fd == -1)
- {
- throw "cannot open `" + path + "' for reading:\n" + lastError();
- }
+ int fd = OS::open(path.c_str(), O_BINARY|O_RDONLY);
+ if(fd == -1)
+ {
+ throw "cannot open `" + path + "' for reading:\n" + lastError();
+ }
#ifndef __BCPLUSPLUS__
- const string pathBZ2Temp = path + ".bz2temp";
- FILE* stdioFile = 0;
- int bzError = 0;
- BZFILE* bzFile = 0;
- if(doCompress)
- {
- stdioFile = OS::fopen(simplify(pathBZ2Temp), "wb");
- if(!stdioFile)
- {
- close(fd);
- throw "cannot open `" + pathBZ2Temp + "' for writing:\n" + lastError();
- }
-
- bzFile = BZ2_bzWriteOpen(&bzError, stdioFile, 5, 0, 0);
- if(bzError != BZ_OK)
- {
- string ex = "BZ2_bzWriteOpen failed";
- if(bzError == BZ_IO_ERROR)
- {
- ex += string(": ") + lastError();
- }
- fclose(stdioFile);
- close(fd);
- throw ex;
- }
- }
+ const string pathBZ2Temp = path + ".bz2temp";
+ FILE* stdioFile = 0;
+ int bzError = 0;
+ BZFILE* bzFile = 0;
+ if(doCompress)
+ {
+ stdioFile = OS::fopen(simplify(pathBZ2Temp), "wb");
+ if(!stdioFile)
+ {
+ close(fd);
+ throw "cannot open `" + pathBZ2Temp + "' for writing:\n" + lastError();
+ }
+
+ bzFile = BZ2_bzWriteOpen(&bzError, stdioFile, 5, 0, 0);
+ if(bzError != BZ_OK)
+ {
+ string ex = "BZ2_bzWriteOpen failed";
+ if(bzError == BZ_IO_ERROR)
+ {
+ ex += string(": ") + lastError();
+ }
+ fclose(stdioFile);
+ close(fd);
+ throw ex;
+ }
+ }
#endif
- unsigned int bytesLeft = static_cast<unsigned int>(buf.st_size);
- while(bytesLeft > 0)
- {
- ByteSeq bytes(min(bytesLeft, 1024u*1024));
- if(read(fd, &bytes[0], static_cast<unsigned int>(bytes.size())) == -1)
- {
+ unsigned int bytesLeft = static_cast<unsigned int>(buf.st_size);
+ while(bytesLeft > 0)
+ {
+ ByteSeq bytes(min(bytesLeft, 1024u*1024));
+ if(read(fd, &bytes[0], static_cast<unsigned int>(bytes.size())) == -1)
+ {
#ifndef __BCPLUSPLUS__
- if(doCompress)
- {
- fclose(stdioFile);
- }
+ if(doCompress)
+ {
+ fclose(stdioFile);
+ }
#endif
- close(fd);
- throw "cannot read from `" + path + "':\n" + lastError();
- }
- bytesLeft -= static_cast<unsigned int>(bytes.size());
+ close(fd);
+ throw "cannot read from `" + path + "':\n" + lastError();
+ }
+ bytesLeft -= static_cast<unsigned int>(bytes.size());
#ifndef __BCPLUSPLUS__
- if(doCompress)
- {
+ if(doCompress)
+ {
BZ2_bzWrite(&bzError, bzFile, const_cast<Byte*>(&bytes[0]), static_cast<int>(bytes.size()));
if(bzError != BZ_OK)
{
- string ex = "BZ2_bzWrite failed";
- if(bzError == BZ_IO_ERROR)
- {
- ex += string(": ") + lastError();
- }
- BZ2_bzWriteClose(&bzError, bzFile, 0, 0, 0);
- fclose(stdioFile);
- close(fd);
- throw ex;
+ string ex = "BZ2_bzWrite failed";
+ if(bzError == BZ_IO_ERROR)
+ {
+ ex += string(": ") + lastError();
+ }
+ BZ2_bzWriteClose(&bzError, bzFile, 0, 0, 0);
+ fclose(stdioFile);
+ close(fd);
+ throw ex;
}
- }
+ }
#endif
- SHA1_Update(&ctx, reinterpret_cast<const void*>(&bytes[0]), bytes.size());
- }
+ SHA1_Update(&ctx, reinterpret_cast<const void*>(&bytes[0]), bytes.size());
+ }
- close(fd);
+ close(fd);
#ifndef __BCPLUSPLUS__
- if(doCompress)
- {
+ if(doCompress)
+ {
BZ2_bzWriteClose(&bzError, bzFile, 0, 0, 0);
if(bzError != BZ_OK)
{
- string ex = "BZ2_bzWriteClose failed";
- if(bzError == BZ_IO_ERROR)
- {
- ex += string(": ") + lastError();
- }
- fclose(stdioFile);
- throw ex;
+ string ex = "BZ2_bzWriteClose failed";
+ if(bzError == BZ_IO_ERROR)
+ {
+ ex += string(": ") + lastError();
+ }
+ fclose(stdioFile);
+ throw ex;
}
- fclose(stdioFile);
+ fclose(stdioFile);
- rename(pathBZ2Temp, pathBZ2);
+ rename(pathBZ2Temp, pathBZ2);
- if(OS::osstat(pathBZ2, &bufBZ2) == -1)
- {
- throw "cannot stat `" + pathBZ2 + "':\n" + lastError();
- }
+ if(OS::osstat(pathBZ2, &bufBZ2) == -1)
+ {
+ throw "cannot stat `" + pathBZ2 + "':\n" + lastError();
+ }
- info.size = static_cast<Int>(bufBZ2.st_size);
- }
+ info.size = static_cast<Int>(bufBZ2.st_size);
+ }
#endif
- }
+ }
- SHA1_Final(reinterpret_cast<unsigned char*>(&bytesSHA[0]), &ctx);
- }
+ SHA1_Final(reinterpret_cast<unsigned char*>(&bytesSHA[0]), &ctx);
+ }
- info.checksum.swap(bytesSHA);
+ info.checksum.swap(bytesSHA);
- infoSeq.push_back(info);
- }
+ infoSeq.push_back(info);
+ }
}
return true;
@@ -1233,21 +1233,21 @@ getFileInfoSeqInt(const string& basePath, const string& relPath, int compress, G
bool
IcePatch2::getFileInfoSeq(const string& basePath, int compress, GetFileInfoSeqCB* cb,
- FileInfoSeq& infoSeq)
+ FileInfoSeq& infoSeq)
{
return getFileInfoSeqSubDir(basePath, ".", compress, cb, infoSeq);
}
bool
IcePatch2::getFileInfoSeqSubDir(const string& basePa, const string& relPa, int compress, GetFileInfoSeqCB* cb,
- FileInfoSeq& infoSeq)
+ FileInfoSeq& infoSeq)
{
const string basePath = simplify(basePa);
const string relPath = simplify(relPa);
if(!getFileInfoSeqInt(basePath, relPath, compress, cb, infoSeq))
{
- return false;
+ return false;
}
sort(infoSeq.begin(), infoSeq.end(), FileInfoLess());
@@ -1260,41 +1260,41 @@ void
IcePatch2::saveFileInfoSeq(const string& pa, const FileInfoSeq& infoSeq)
{
{
- const string path = simplify(pa + '/' + checksumFile);
-
- FILE* fp = OS::fopen(path, "w");
- if(!fp)
- {
- throw "cannot open `" + path + "' for writing:\n" + lastError();
- }
- try
- {
- for(FileInfoSeq::const_iterator p = infoSeq.begin(); p != infoSeq.end(); ++p)
- {
- if(!writeFileInfo(fp, *p))
- {
- throw "error writing `" + path + "':\n" + lastError();
- }
- }
- }
- catch(...)
- {
- fclose(fp);
- throw;
- }
- fclose(fp);
- }
-
- {
- const string pathLog = simplify(pa + '/' + logFile);
-
- try
- {
- remove(pathLog);
- }
- catch(...)
- {
- }
+ const string path = simplify(pa + '/' + checksumFile);
+
+ FILE* fp = OS::fopen(path, "w");
+ if(!fp)
+ {
+ throw "cannot open `" + path + "' for writing:\n" + lastError();
+ }
+ try
+ {
+ for(FileInfoSeq::const_iterator p = infoSeq.begin(); p != infoSeq.end(); ++p)
+ {
+ if(!writeFileInfo(fp, *p))
+ {
+ throw "error writing `" + path + "':\n" + lastError();
+ }
+ }
+ }
+ catch(...)
+ {
+ fclose(fp);
+ throw;
+ }
+ fclose(fp);
+ }
+
+ {
+ const string pathLog = simplify(pa + '/' + logFile);
+
+ try
+ {
+ remove(pathLog);
+ }
+ catch(...)
+ {
+ }
}
}
@@ -1302,98 +1302,98 @@ void
IcePatch2::loadFileInfoSeq(const string& pa, FileInfoSeq& infoSeq)
{
{
- const string path = simplify(pa + '/' + checksumFile);
-
- FILE* fp = OS::fopen(path, "r");
- if(!fp)
- {
- throw "cannot open `" + path + "' for reading:\n" + lastError();
- }
-
- while(true)
- {
- FileInfo info;
- if(readFileInfo(fp, info))
- {
- infoSeq.push_back(info);
- }
- else
- {
- break;
- }
- }
- fclose(fp);
-
- sort(infoSeq.begin(), infoSeq.end(), FileInfoLess());
- infoSeq.erase(unique(infoSeq.begin(), infoSeq.end(), FileInfoEqual()), infoSeq.end());
- }
-
- {
- const string pathLog = simplify(pa + '/' + logFile);
-
- FILE* fp = OS::fopen(pathLog, "r");
- if(fp != 0)
- {
- FileInfoSeq remove;
- FileInfoSeq update;
-
- while(true)
- {
- int c = fgetc(fp);
- if(c == EOF)
- {
- break;
- }
-
- FileInfo info;
- if(!readFileInfo(fp, info))
- {
- break;
- }
-
- if(c == '-')
- {
- remove.push_back(info);
- }
- else if(c == '+')
- {
- update.push_back(info);
- }
- }
- fclose(fp);
-
- sort(remove.begin(), remove.end(), FileInfoLess());
- remove.erase(unique(remove.begin(), remove.end(), FileInfoEqual()), remove.end());
-
- sort(update.begin(), update.end(), FileInfoLess());
- update.erase(unique(update.begin(), update.end(), FileInfoEqual()), update.end());
-
- FileInfoSeq newInfoSeq;
- newInfoSeq.reserve(infoSeq.size());
-
- set_difference(infoSeq.begin(),
- infoSeq.end(),
- remove.begin(),
- remove.end(),
- back_inserter(newInfoSeq),
- FileInfoLess());
-
- infoSeq.swap(newInfoSeq);
-
- newInfoSeq.clear();
- newInfoSeq.reserve(infoSeq.size());
-
- set_union(infoSeq.begin(),
- infoSeq.end(),
- update.begin(),
- update.end(),
- back_inserter(newInfoSeq),
- FileInfoLess());
-
- infoSeq.swap(newInfoSeq);
-
- saveFileInfoSeq(pa, infoSeq);
- }
+ const string path = simplify(pa + '/' + checksumFile);
+
+ FILE* fp = OS::fopen(path, "r");
+ if(!fp)
+ {
+ throw "cannot open `" + path + "' for reading:\n" + lastError();
+ }
+
+ while(true)
+ {
+ FileInfo info;
+ if(readFileInfo(fp, info))
+ {
+ infoSeq.push_back(info);
+ }
+ else
+ {
+ break;
+ }
+ }
+ fclose(fp);
+
+ sort(infoSeq.begin(), infoSeq.end(), FileInfoLess());
+ infoSeq.erase(unique(infoSeq.begin(), infoSeq.end(), FileInfoEqual()), infoSeq.end());
+ }
+
+ {
+ const string pathLog = simplify(pa + '/' + logFile);
+
+ FILE* fp = OS::fopen(pathLog, "r");
+ if(fp != 0)
+ {
+ FileInfoSeq remove;
+ FileInfoSeq update;
+
+ while(true)
+ {
+ int c = fgetc(fp);
+ if(c == EOF)
+ {
+ break;
+ }
+
+ FileInfo info;
+ if(!readFileInfo(fp, info))
+ {
+ break;
+ }
+
+ if(c == '-')
+ {
+ remove.push_back(info);
+ }
+ else if(c == '+')
+ {
+ update.push_back(info);
+ }
+ }
+ fclose(fp);
+
+ sort(remove.begin(), remove.end(), FileInfoLess());
+ remove.erase(unique(remove.begin(), remove.end(), FileInfoEqual()), remove.end());
+
+ sort(update.begin(), update.end(), FileInfoLess());
+ update.erase(unique(update.begin(), update.end(), FileInfoEqual()), update.end());
+
+ FileInfoSeq newInfoSeq;
+ newInfoSeq.reserve(infoSeq.size());
+
+ set_difference(infoSeq.begin(),
+ infoSeq.end(),
+ remove.begin(),
+ remove.end(),
+ back_inserter(newInfoSeq),
+ FileInfoLess());
+
+ infoSeq.swap(newInfoSeq);
+
+ newInfoSeq.clear();
+ newInfoSeq.reserve(infoSeq.size());
+
+ set_union(infoSeq.begin(),
+ infoSeq.end(),
+ update.begin(),
+ update.end(),
+ back_inserter(newInfoSeq),
+ FileInfoLess());
+
+ infoSeq.swap(newInfoSeq);
+
+ saveFileInfoSeq(pa, infoSeq);
+ }
}
}
@@ -1409,52 +1409,52 @@ IcePatch2::getFileTree0(const FileInfoSeq& infoSeq, FileTree0& tree0)
for(int i = 0; i < 256; ++i, c0 += 20)
{
- FileTree1& tree1 = tree0.nodes[i];
-
- tree1.files.clear();
- tree1.checksum.resize(20);
-
- FileInfoSeq::const_iterator p;
-
- for(p = infoSeq.begin(); p != infoSeq.end(); ++p)
- {
- if(i == static_cast<int>(p->checksum[0]))
- {
- tree1.files.push_back(*p);
- }
- }
-
- ByteSeq allChecksums1;
- allChecksums1.resize(tree1.files.size() * 21); // 20 bytes for the checksum + 1 byte for the flag
- ByteSeq::iterator c1 = allChecksums1.begin();
-
- for(p = tree1.files.begin(); p != tree1.files.end(); ++p, c1 += 21)
- {
- copy(p->checksum.begin(), p->checksum.end(), c1);
- *(c1 + 20) = p->executable;
- }
-
- if(!allChecksums1.empty())
- {
- SHA1(reinterpret_cast<unsigned char*>(&allChecksums1[0]), allChecksums1.size(),
- reinterpret_cast<unsigned char*>(&tree1.checksum[0]));
- }
- else
- {
- fill(tree1.checksum.begin(), tree1.checksum.end(), 0);
- }
-
- copy(tree1.checksum.begin(), tree1.checksum.end(), c0);
+ FileTree1& tree1 = tree0.nodes[i];
+
+ tree1.files.clear();
+ tree1.checksum.resize(20);
+
+ FileInfoSeq::const_iterator p;
+
+ for(p = infoSeq.begin(); p != infoSeq.end(); ++p)
+ {
+ if(i == static_cast<int>(p->checksum[0]))
+ {
+ tree1.files.push_back(*p);
+ }
+ }
+
+ ByteSeq allChecksums1;
+ allChecksums1.resize(tree1.files.size() * 21); // 20 bytes for the checksum + 1 byte for the flag
+ ByteSeq::iterator c1 = allChecksums1.begin();
+
+ for(p = tree1.files.begin(); p != tree1.files.end(); ++p, c1 += 21)
+ {
+ copy(p->checksum.begin(), p->checksum.end(), c1);
+ *(c1 + 20) = p->executable;
+ }
+
+ if(!allChecksums1.empty())
+ {
+ SHA1(reinterpret_cast<unsigned char*>(&allChecksums1[0]), allChecksums1.size(),
+ reinterpret_cast<unsigned char*>(&tree1.checksum[0]));
+ }
+ else
+ {
+ fill(tree1.checksum.begin(), tree1.checksum.end(), 0);
+ }
+
+ copy(tree1.checksum.begin(), tree1.checksum.end(), c0);
}
if(!allChecksums0.empty())
{
- SHA1(reinterpret_cast<unsigned char*>(&allChecksums0[0]), allChecksums0.size(),
- reinterpret_cast<unsigned char*>(&tree0.checksum[0]));
+ SHA1(reinterpret_cast<unsigned char*>(&allChecksums0[0]), allChecksums0.size(),
+ reinterpret_cast<unsigned char*>(&tree0.checksum[0]));
}
else
{
- fill(tree0.checksum.begin(), tree0.checksum.end(), 0);
+ fill(tree0.checksum.begin(), tree0.checksum.end(), 0);
}
}
diff --git a/cpp/src/IceSSL/AcceptorI.cpp b/cpp/src/IceSSL/AcceptorI.cpp
index 7d54e7d3ea3..2bd7a3e105c 100644
--- a/cpp/src/IceSSL/AcceptorI.cpp
+++ b/cpp/src/IceSSL/AcceptorI.cpp
@@ -33,8 +33,8 @@ IceSSL::AcceptorI::close()
{
if(_instance->networkTraceLevel() >= 1)
{
- Trace out(_logger, _instance->networkTraceCategory());
- out << "stopping to accept ssl connections at " << toString();
+ Trace out(_logger, _instance->networkTraceCategory());
+ out << "stopping to accept ssl connections at " << toString();
}
SOCKET fd = _fd;
@@ -47,18 +47,18 @@ IceSSL::AcceptorI::listen()
{
try
{
- IceInternal::doListen(_fd, _backlog);
+ IceInternal::doListen(_fd, _backlog);
}
catch(...)
{
- _fd = INVALID_SOCKET;
- throw;
+ _fd = INVALID_SOCKET;
+ throw;
}
if(_instance->networkTraceLevel() >= 1)
{
- Trace out(_logger, _instance->networkTraceCategory());
- out << "accepting ssl connections at " << toString();
+ Trace out(_logger, _instance->networkTraceCategory());
+ out << "accepting ssl connections at " << toString();
}
}
@@ -70,9 +70,9 @@ IceSSL::AcceptorI::accept(int timeout)
//
if(!_instance->context())
{
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: plugin is not initialized";
- throw ex;
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: plugin is not initialized";
+ throw ex;
}
SOCKET fd = IceInternal::doAccept(_fd, timeout);
@@ -81,19 +81,19 @@ IceSSL::AcceptorI::accept(int timeout)
BIO* bio = BIO_new_socket(static_cast<int>(fd), BIO_CLOSE);
if(!bio)
{
- IceInternal::closeSocketNoThrow(fd);
- SecurityException ex(__FILE__, __LINE__);
- ex.reason = "openssl failure";
- throw ex;
+ IceInternal::closeSocketNoThrow(fd);
+ SecurityException ex(__FILE__, __LINE__);
+ ex.reason = "openssl failure";
+ throw ex;
}
SSL* ssl = SSL_new(_instance->context());
if(!ssl)
{
- BIO_free(bio); // Also closes the socket.
- SecurityException ex(__FILE__, __LINE__);
- ex.reason = "openssl failure";
- throw ex;
+ BIO_free(bio); // Also closes the socket.
+ SecurityException ex(__FILE__, __LINE__);
+ ex.reason = "openssl failure";
+ throw ex;
}
SSL_set_bio(ssl, bio, bio);
@@ -152,20 +152,20 @@ IceSSL::AcceptorI::AcceptorI(const InstancePtr& instance, const string& adapterN
try
{
- _fd = IceInternal::createSocket(false);
- IceInternal::setBlock(_fd, false);
- IceInternal::getAddress(host, port, _addr);
- if(_instance->networkTraceLevel() >= 2)
- {
- Trace out(_logger, _instance->networkTraceCategory());
- out << "attempting to bind to ssl socket " << toString();
- }
- IceInternal::doBind(_fd, _addr);
+ _fd = IceInternal::createSocket(false);
+ IceInternal::setBlock(_fd, false);
+ IceInternal::getAddress(host, port, _addr);
+ if(_instance->networkTraceLevel() >= 2)
+ {
+ Trace out(_logger, _instance->networkTraceCategory());
+ out << "attempting to bind to ssl socket " << toString();
+ }
+ IceInternal::doBind(_fd, _addr);
}
catch(...)
{
- _fd = INVALID_SOCKET;
- throw;
+ _fd = INVALID_SOCKET;
+ throw;
}
}
diff --git a/cpp/src/IceSSL/Certificate.cpp b/cpp/src/IceSSL/Certificate.cpp
index ab9c47ee473..24c3df58ddc 100755
--- a/cpp/src/IceSSL/Certificate.cpp
+++ b/cpp/src/IceSSL/Certificate.cpp
@@ -93,7 +93,7 @@ ASMUtcTimeToIceUtilTime(const ASN1_UTCTIME* s)
#define g2(p) (((p)[0]-'0')*10+(p)[1]-'0')
tm.tm_year = g2(s->data);
if(tm.tm_year < 50)
- tm.tm_year += 100;
+ tm.tm_year += 100;
tm.tm_mon = g2(s->data + 2) - 1;
tm.tm_mday = g2(s->data + 4);
tm.tm_hour = g2(s->data + 6);
@@ -101,15 +101,15 @@ ASMUtcTimeToIceUtilTime(const ASN1_UTCTIME* s)
tm.tm_sec = g2(s->data + 10);
if(s->data[12] == 'Z')
{
- offset = 0;
+ offset = 0;
}
else
{
- offset = g2(s->data + 13) * 60 + g2(s->data + 15);
- if(s->data[12] == '-')
- {
- offset = -offset;
- }
+ offset = g2(s->data + 13) * 60 + g2(s->data + 15);
+ if(s->data[12] == '-')
+ {
+ offset = -offset;
+ }
}
#undef g2
@@ -121,10 +121,10 @@ ASMUtcTimeToIceUtilTime(const ASN1_UTCTIME* s)
//
time_t tzone;
{
- static IceUtil::StaticMutex mutex = ICE_STATIC_MUTEX_INITIALIZER;
- IceUtil::StaticMutex::Lock sync(mutex);
- time_t now = time(0);
- tzone = mktime(localtime(&now)) - mktime(gmtime(&now));
+ static IceUtil::StaticMutex mutex = ICE_STATIC_MUTEX_INITIALIZER;
+ IceUtil::StaticMutex::Lock sync(mutex);
+ time_t now = time(0);
+ tzone = mktime(localtime(&now)) - mktime(gmtime(&now));
}
return IceUtil::Time::seconds(mktime(&tm) - offset*60 + tzone);
}
@@ -147,81 +147,81 @@ convertGeneralNames(GENERAL_NAMES* gens)
vector<pair<int, string> > alt;
if(gens == 0)
{
- return alt;
+ return alt;
}
for(int i = 0; i < sk_GENERAL_NAME_num(gens); ++i)
{
- GENERAL_NAME* gen = sk_GENERAL_NAME_value(gens, i);
- pair<int, string> p;
- p.first = gen->type;
- switch(gen->type)
- {
- case GEN_EMAIL:
- {
- ASN1_IA5STRING* str = gen->d.rfc822Name;
- if(str && str->type == V_ASN1_IA5STRING && str->data && str->length > 0)
- {
- p.second = reinterpret_cast<const char*>(str->data);
- }
- break;
- }
- case GEN_DNS:
- {
- ASN1_IA5STRING* str = gen->d.dNSName;
- if(str && str->type == V_ASN1_IA5STRING && str->data && str->length > 0)
- {
- p.second = reinterpret_cast<const char*>(str->data);
- }
- break;
- }
- case GEN_DIRNAME:
- {
- p.second = convertX509NameToString(gen->d.directoryName);
- break;
- }
- case GEN_URI:
- {
- ASN1_IA5STRING* str = gen->d.uniformResourceIdentifier;
- if(str && str->type == V_ASN1_IA5STRING && str->data && str->length > 0)
- {
- p.second = reinterpret_cast<const char*>(str->data);
- }
- break;
- }
- case GEN_IPADD:
- {
- ASN1_OCTET_STRING* addr = gen->d.iPAddress;
- // TODO: Support IPv6 someday.
- if(addr && addr->type == V_ASN1_OCTET_STRING && addr->data && addr->length == 4)
- {
- ostringstream ostr;
- for(int j = 0; j < 4; ++j)
- {
- if(j > 0)
- {
- ostr << '.';
- }
- ostr << static_cast<int>(addr->data[j]);
- }
- p.second = ostr.str();
- }
- break;
- }
- case GEN_OTHERNAME:
- case GEN_EDIPARTY:
- case GEN_X400:
- case GEN_RID:
- {
- //
- // TODO: These types are not supported. If the user wants
- // them, they have to get at the certificate data. Another
- // alternative is to DER encode the data (as the Java
- // certificate does).
- //
- break;
- }
- }
- alt.push_back(p);
+ GENERAL_NAME* gen = sk_GENERAL_NAME_value(gens, i);
+ pair<int, string> p;
+ p.first = gen->type;
+ switch(gen->type)
+ {
+ case GEN_EMAIL:
+ {
+ ASN1_IA5STRING* str = gen->d.rfc822Name;
+ if(str && str->type == V_ASN1_IA5STRING && str->data && str->length > 0)
+ {
+ p.second = reinterpret_cast<const char*>(str->data);
+ }
+ break;
+ }
+ case GEN_DNS:
+ {
+ ASN1_IA5STRING* str = gen->d.dNSName;
+ if(str && str->type == V_ASN1_IA5STRING && str->data && str->length > 0)
+ {
+ p.second = reinterpret_cast<const char*>(str->data);
+ }
+ break;
+ }
+ case GEN_DIRNAME:
+ {
+ p.second = convertX509NameToString(gen->d.directoryName);
+ break;
+ }
+ case GEN_URI:
+ {
+ ASN1_IA5STRING* str = gen->d.uniformResourceIdentifier;
+ if(str && str->type == V_ASN1_IA5STRING && str->data && str->length > 0)
+ {
+ p.second = reinterpret_cast<const char*>(str->data);
+ }
+ break;
+ }
+ case GEN_IPADD:
+ {
+ ASN1_OCTET_STRING* addr = gen->d.iPAddress;
+ // TODO: Support IPv6 someday.
+ if(addr && addr->type == V_ASN1_OCTET_STRING && addr->data && addr->length == 4)
+ {
+ ostringstream ostr;
+ for(int j = 0; j < 4; ++j)
+ {
+ if(j > 0)
+ {
+ ostr << '.';
+ }
+ ostr << static_cast<int>(addr->data[j]);
+ }
+ p.second = ostr.str();
+ }
+ break;
+ }
+ case GEN_OTHERNAME:
+ case GEN_EDIPARTY:
+ case GEN_X400:
+ case GEN_RID:
+ {
+ //
+ // TODO: These types are not supported. If the user wants
+ // them, they have to get at the certificate data. Another
+ // alternative is to DER encode the data (as the Java
+ // certificate does).
+ //
+ break;
+ }
+ }
+ alt.push_back(p);
}
sk_GENERAL_NAME_pop_free(gens, GENERAL_NAME_free);
return alt;
@@ -298,22 +298,22 @@ DistinguishedName::match(const DistinguishedName& other) const
{
for(list< pair<string, string> >::const_iterator p = other._unescaped.begin(); p != other._unescaped.end(); ++p)
{
- bool found = false;
- for(list< pair<string, string> >::const_iterator q = _unescaped.begin(); q != _unescaped.end(); ++q)
- {
- if(p->first == q->first)
- {
- found = true;
- if(p->second != q->second)
- {
- return false;
- }
- }
- }
- if(!found)
- {
- return false;
- }
+ bool found = false;
+ for(list< pair<string, string> >::const_iterator q = _unescaped.begin(); q != _unescaped.end(); ++q)
+ {
+ if(p->first == q->first)
+ {
+ found = true;
+ if(p->second != q->second)
+ {
+ return false;
+ }
+ }
+ }
+ if(!found)
+ {
+ return false;
+ }
}
return true;
}
@@ -328,12 +328,12 @@ DistinguishedName::operator string() const
bool first = true;
for(list< pair<string, string> >::const_iterator p = _rdns.begin(); p != _rdns.end(); ++p)
{
- if(!first)
- {
- os << ",";
- }
- first = false;
- os << p->first << "=" << p->second;
+ if(!first)
+ {
+ os << ",";
+ }
+ first = false;
+ os << p->first << "=" << p->second;
}
return os.str();
}
@@ -343,9 +343,9 @@ DistinguishedName::unescape()
{
for(list< pair<string, string> >::const_iterator q = _rdns.begin(); q != _rdns.end(); ++q)
{
- pair<string, string> rdn = *q;
- rdn.second = RFC2253::unescape(rdn.second);
- _unescaped.push_back(rdn);
+ pair<string, string> rdn = *q;
+ rdn.second = RFC2253::unescape(rdn.second);
+ _unescaped.push_back(rdn);
}
}
@@ -385,15 +385,15 @@ Certificate::load(const string& file)
BIO *cert = BIO_new(BIO_s_file());
if(BIO_read_filename(cert, file.c_str()) <= 0)
{
- BIO_free(cert);
- throw CertificateReadException(__FILE__, __LINE__, "error opening file");
+ BIO_free(cert);
+ throw CertificateReadException(__FILE__, __LINE__, "error opening file");
}
X509* x = PEM_read_bio_X509_AUX(cert, NULL, NULL, NULL);
if(x == NULL)
{
- BIO_free(cert);
- throw CertificateReadException(__FILE__, __LINE__, "error reading file:\n" + getSslErrors(false));
+ BIO_free(cert);
+ throw CertificateReadException(__FILE__, __LINE__, "error reading file:\n" + getSslErrors(false));
}
BIO_free(cert);
return new Certificate(x);
@@ -406,8 +406,8 @@ Certificate::decode(const string& encoding)
X509* x = PEM_read_bio_X509_AUX(cert, NULL, NULL, NULL);
if(x == NULL)
{
- BIO_free(cert);
- throw CertificateReadException(__FILE__, __LINE__, "error decoding certificate:\n" + getSslErrors(false));
+ BIO_free(cert);
+ throw CertificateReadException(__FILE__, __LINE__, "error decoding certificate:\n" + getSslErrors(false));
}
BIO_free(cert);
return new Certificate(x);
@@ -444,8 +444,8 @@ Certificate::encode() const
int i = PEM_write_bio_X509_AUX(out, _cert);
if(i <= 0)
{
- BIO_free(out);
- throw CertificateEncodingException(__FILE__, __LINE__, getSslErrors(false));
+ BIO_free(out);
+ throw CertificateEncodingException(__FILE__, __LINE__, getSslErrors(false));
}
BUF_MEM* p;
BIO_get_mem_ptr(out, &p);
@@ -511,7 +511,7 @@ vector<pair<int, string> >
Certificate::getIssuerAlternativeNames()
{
return convertGeneralNames(reinterpret_cast<GENERAL_NAMES*>(
- X509_get_ext_d2i(_cert, NID_issuer_alt_name, 0, 0)));
+ X509_get_ext_d2i(_cert, NID_issuer_alt_name, 0, 0)));
}
DistinguishedName
@@ -524,7 +524,7 @@ vector<pair<int, string> >
Certificate::getSubjectAlternativeNames()
{
return convertGeneralNames(
- reinterpret_cast<GENERAL_NAMES*>(X509_get_ext_d2i(_cert, NID_subject_alt_name, 0, 0)));
+ reinterpret_cast<GENERAL_NAMES*>(X509_get_ext_d2i(_cert, NID_subject_alt_name, 0, 0)));
}
int
diff --git a/cpp/src/IceSSL/ConnectorI.cpp b/cpp/src/IceSSL/ConnectorI.cpp
index 29433f31f3f..8a68c3559c3 100644
--- a/cpp/src/IceSSL/ConnectorI.cpp
+++ b/cpp/src/IceSSL/ConnectorI.cpp
@@ -28,15 +28,15 @@ IceSSL::ConnectorI::connect(int timeout)
//
if(!_instance->context())
{
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: plugin is not initialized";
- throw ex;
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: plugin is not initialized";
+ throw ex;
}
if(_instance->networkTraceLevel() >= 2)
{
- Trace out(_logger, _instance->networkTraceCategory());
- out << "trying to establish ssl connection to " << toString();
+ Trace out(_logger, _instance->networkTraceCategory());
+ out << "trying to establish ssl connection to " << toString();
}
SOCKET fd = IceInternal::createSocket(false);
@@ -47,125 +47,125 @@ IceSSL::ConnectorI::connect(int timeout)
BIO* bio = BIO_new_socket(static_cast<int>(fd), BIO_CLOSE);
if(!bio)
{
- IceInternal::closeSocketNoThrow(fd);
- SecurityException ex(__FILE__, __LINE__);
- ex.reason = "openssl failure";
- throw ex;
+ IceInternal::closeSocketNoThrow(fd);
+ SecurityException ex(__FILE__, __LINE__);
+ ex.reason = "openssl failure";
+ throw ex;
}
SSL* ssl = SSL_new(_instance->context());
if(!ssl)
{
- BIO_free(bio); // Also closes the socket.
- SecurityException ex(__FILE__, __LINE__);
- ex.reason = "openssl failure";
- throw ex;
+ BIO_free(bio); // Also closes the socket.
+ SecurityException ex(__FILE__, __LINE__);
+ ex.reason = "openssl failure";
+ throw ex;
}
SSL_set_bio(ssl, bio, bio);
try
{
- do
- {
- int result = SSL_connect(ssl);
- switch(SSL_get_error(ssl, result))
- {
- case SSL_ERROR_NONE:
- break;
- case SSL_ERROR_ZERO_RETURN:
- {
- ConnectionLostException ex(__FILE__, __LINE__);
- ex.error = IceInternal::getSocketErrno();
- throw ex;
- }
- case SSL_ERROR_WANT_READ:
- if(!selectRead(fd, timeout))
- {
- throw ConnectTimeoutException(__FILE__, __LINE__);
- }
- break;
- case SSL_ERROR_WANT_WRITE:
- if(!selectWrite(fd, timeout))
- {
- throw ConnectTimeoutException(__FILE__, __LINE__);
- }
- break;
- case SSL_ERROR_SYSCALL:
- {
- if(result == -1)
- {
- if(IceInternal::interrupted())
- {
- break;
- }
-
- if(IceInternal::wouldBlock())
- {
- if(SSL_want_read(ssl))
- {
- if(!selectRead(fd, timeout))
- {
- throw ConnectTimeoutException(__FILE__, __LINE__);
- }
- }
- else if(SSL_want_write(ssl))
- {
- if(!selectWrite(fd, timeout))
- {
- throw ConnectTimeoutException(__FILE__, __LINE__);
- }
- }
-
- continue;
- }
-
- if(IceInternal::connectionLost())
- {
- ConnectionLostException ex(__FILE__, __LINE__);
- ex.error = IceInternal::getSocketErrno();
- throw ex;
- }
- }
-
- if(result == 0)
- {
- ConnectionLostException ex(__FILE__, __LINE__);
- ex.error = 0;
- throw ex;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = IceInternal::getSocketErrno();
- throw ex;
- }
- case SSL_ERROR_SSL:
- {
- ProtocolException ex(__FILE__, __LINE__);
- ex.reason = "SSL error for new outgoing connection:\nremote address = " +
- IceInternal::addrToString(_addr) + "\n" + _instance->sslErrors();
- throw ex;
- }
- }
- }
- while(!SSL_is_init_finished(ssl));
-
- _instance->verifyPeer(ssl, fd, _host, "", false);
+ do
+ {
+ int result = SSL_connect(ssl);
+ switch(SSL_get_error(ssl, result))
+ {
+ case SSL_ERROR_NONE:
+ break;
+ case SSL_ERROR_ZERO_RETURN:
+ {
+ ConnectionLostException ex(__FILE__, __LINE__);
+ ex.error = IceInternal::getSocketErrno();
+ throw ex;
+ }
+ case SSL_ERROR_WANT_READ:
+ if(!selectRead(fd, timeout))
+ {
+ throw ConnectTimeoutException(__FILE__, __LINE__);
+ }
+ break;
+ case SSL_ERROR_WANT_WRITE:
+ if(!selectWrite(fd, timeout))
+ {
+ throw ConnectTimeoutException(__FILE__, __LINE__);
+ }
+ break;
+ case SSL_ERROR_SYSCALL:
+ {
+ if(result == -1)
+ {
+ if(IceInternal::interrupted())
+ {
+ break;
+ }
+
+ if(IceInternal::wouldBlock())
+ {
+ if(SSL_want_read(ssl))
+ {
+ if(!selectRead(fd, timeout))
+ {
+ throw ConnectTimeoutException(__FILE__, __LINE__);
+ }
+ }
+ else if(SSL_want_write(ssl))
+ {
+ if(!selectWrite(fd, timeout))
+ {
+ throw ConnectTimeoutException(__FILE__, __LINE__);
+ }
+ }
+
+ continue;
+ }
+
+ if(IceInternal::connectionLost())
+ {
+ ConnectionLostException ex(__FILE__, __LINE__);
+ ex.error = IceInternal::getSocketErrno();
+ throw ex;
+ }
+ }
+
+ if(result == 0)
+ {
+ ConnectionLostException ex(__FILE__, __LINE__);
+ ex.error = 0;
+ throw ex;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = IceInternal::getSocketErrno();
+ throw ex;
+ }
+ case SSL_ERROR_SSL:
+ {
+ ProtocolException ex(__FILE__, __LINE__);
+ ex.reason = "SSL error for new outgoing connection:\nremote address = " +
+ IceInternal::addrToString(_addr) + "\n" + _instance->sslErrors();
+ throw ex;
+ }
+ }
+ }
+ while(!SSL_is_init_finished(ssl));
+
+ _instance->verifyPeer(ssl, fd, _host, "", false);
}
catch(...)
{
- SSL_free(ssl);
- throw;
+ SSL_free(ssl);
+ throw;
}
if(_instance->networkTraceLevel() >= 1)
{
- Trace out(_logger, _instance->networkTraceCategory());
- out << "ssl connection established\n" << IceInternal::fdToString(fd);
+ Trace out(_logger, _instance->networkTraceCategory());
+ out << "ssl connection established\n" << IceInternal::fdToString(fd);
}
if(_instance->securityTraceLevel() >= 1)
{
- _instance->traceConnection(ssl, false);
+ _instance->traceConnection(ssl, false);
}
return new TransceiverI(_instance, ssl, fd, false);
diff --git a/cpp/src/IceSSL/EndpointI.cpp b/cpp/src/IceSSL/EndpointI.cpp
index e962ff4b9a6..69866544132 100644
--- a/cpp/src/IceSSL/EndpointI.cpp
+++ b/cpp/src/IceSSL/EndpointI.cpp
@@ -22,7 +22,7 @@ using namespace Ice;
using namespace IceSSL;
IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& ho, Int po, Int ti, const string& conId,
- bool co, bool pub) :
+ bool co, bool pub) :
_instance(instance),
_host(ho),
_port(po),
@@ -47,96 +47,96 @@ IceSSL::EndpointI::EndpointI(const InstancePtr& instance, const string& str) :
while(true)
{
- beg = str.find_first_not_of(delim, end);
- if(beg == string::npos)
- {
- break;
- }
-
- end = str.find_first_of(delim, beg);
- if(end == string::npos)
- {
- end = str.length();
- }
-
- string option = str.substr(beg, end - beg);
- if(option.length() != 2 || option[0] != '-')
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "ssl " + str;
- throw ex;
- }
-
- string argument;
- string::size_type argumentBeg = str.find_first_not_of(delim, end);
- if(argumentBeg != string::npos && str[argumentBeg] != '-')
- {
- beg = argumentBeg;
- end = str.find_first_of(delim, beg);
- if(end == string::npos)
- {
- end = str.length();
- }
- argument = str.substr(beg, end - beg);
- }
-
- switch(option[1])
- {
- case 'h':
- {
- if(argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "ssl " + str;
- throw ex;
- }
- const_cast<string&>(_host) = argument;
- break;
- }
-
- case 'p':
- {
- istringstream p(argument);
- if(!(p >> const_cast<Int&>(_port)) || !p.eof() || _port < 0 || _port > 65535)
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "ssl " + str;
- throw ex;
- }
- break;
- }
-
- case 't':
- {
- istringstream t(argument);
- if(!(t >> const_cast<Int&>(_timeout)) || !t.eof())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "ssl " + str;
- throw ex;
- }
- break;
- }
-
- case 'z':
- {
- if(!argument.empty())
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "ssl " + str;
- throw ex;
- }
- const_cast<bool&>(_compress) = true;
- break;
- }
-
- default:
- {
- EndpointParseException ex(__FILE__, __LINE__);
- ex.str = "ssl " + str;
- throw ex;
- }
- }
+ beg = str.find_first_not_of(delim, end);
+ if(beg == string::npos)
+ {
+ break;
+ }
+
+ end = str.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ end = str.length();
+ }
+
+ string option = str.substr(beg, end - beg);
+ if(option.length() != 2 || option[0] != '-')
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "ssl " + str;
+ throw ex;
+ }
+
+ string argument;
+ string::size_type argumentBeg = str.find_first_not_of(delim, end);
+ if(argumentBeg != string::npos && str[argumentBeg] != '-')
+ {
+ beg = argumentBeg;
+ end = str.find_first_of(delim, beg);
+ if(end == string::npos)
+ {
+ end = str.length();
+ }
+ argument = str.substr(beg, end - beg);
+ }
+
+ switch(option[1])
+ {
+ case 'h':
+ {
+ if(argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "ssl " + str;
+ throw ex;
+ }
+ const_cast<string&>(_host) = argument;
+ break;
+ }
+
+ case 'p':
+ {
+ istringstream p(argument);
+ if(!(p >> const_cast<Int&>(_port)) || !p.eof() || _port < 0 || _port > 65535)
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "ssl " + str;
+ throw ex;
+ }
+ break;
+ }
+
+ case 't':
+ {
+ istringstream t(argument);
+ if(!(t >> const_cast<Int&>(_timeout)) || !t.eof())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "ssl " + str;
+ throw ex;
+ }
+ break;
+ }
+
+ case 'z':
+ {
+ if(!argument.empty())
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "ssl " + str;
+ throw ex;
+ }
+ const_cast<bool&>(_compress) = true;
+ break;
+ }
+
+ default:
+ {
+ EndpointParseException ex(__FILE__, __LINE__);
+ ex.str = "ssl " + str;
+ throw ex;
+ }
+ }
}
}
@@ -181,11 +181,11 @@ IceSSL::EndpointI::toString() const
s << "ssl -h " << _host << " -p " << _port;
if(_timeout != -1)
{
- s << " -t " << _timeout;
+ s << " -t " << _timeout;
}
if(_compress)
{
- s << " -z";
+ s << " -z";
}
return s.str();
}
@@ -207,11 +207,11 @@ IceSSL::EndpointI::timeout(Int timeout) const
{
if(timeout == _timeout)
{
- return const_cast<EndpointI*>(this);
+ return const_cast<EndpointI*>(this);
}
else
{
- return new EndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _publish);
+ return new EndpointI(_instance, _host, _port, timeout, _connectionId, _compress, _publish);
}
}
@@ -220,11 +220,11 @@ IceSSL::EndpointI::connectionId(const string& connectionId) const
{
if(connectionId == _connectionId)
{
- return const_cast<EndpointI*>(this);
+ return const_cast<EndpointI*>(this);
}
else
{
- return new EndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _publish);
+ return new EndpointI(_instance, _host, _port, _timeout, connectionId, _compress, _publish);
}
}
@@ -239,11 +239,11 @@ IceSSL::EndpointI::compress(bool compress) const
{
if(compress == _compress)
{
- return const_cast<EndpointI*>(this);
+ return const_cast<EndpointI*>(this);
}
else
{
- return new EndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _publish);
+ return new EndpointI(_instance, _host, _port, _timeout, _connectionId, compress, _publish);
}
}
@@ -319,11 +319,11 @@ IceSSL::EndpointI::expand(bool server) const
if(_host == "0.0.0.0")
{
vector<string> hosts = IceInternal::getLocalHosts();
- for(unsigned int i = 0; i < hosts.size(); ++i)
- {
- endps.push_back(new EndpointI(_instance, hosts[i], _port, _timeout, _connectionId, _compress,
- hosts.size() == 1 || hosts[i] != "127.0.0.1"));
- }
+ for(unsigned int i = 0; i < hosts.size(); ++i)
+ {
+ endps.push_back(new EndpointI(_instance, hosts[i], _port, _timeout, _connectionId, _compress,
+ hosts.size() == 1 || hosts[i] != "127.0.0.1"));
+ }
}
else
{
@@ -350,7 +350,7 @@ IceSSL::EndpointI::equivalent(const IceInternal::AcceptorPtr& acceptor) const
const AcceptorI* sslAcceptor = dynamic_cast<const AcceptorI*>(acceptor.get());
if(!sslAcceptor)
{
- return false;
+ return false;
}
return sslAcceptor->equivalent(_host, _port);
}
@@ -361,52 +361,52 @@ IceSSL::EndpointI::operator==(const IceInternal::EndpointI& r) const
const EndpointI* p = dynamic_cast<const EndpointI*>(&r);
if(!p)
{
- return false;
+ return false;
}
if(this == p)
{
- return true;
+ return true;
}
if(_port != p->_port)
{
- return false;
+ return false;
}
if(_timeout != p->_timeout)
{
- return false;
+ return false;
}
if(_connectionId != p->_connectionId)
{
- return false;
+ return false;
}
if(_compress != p->_compress)
{
- return false;
+ return false;
}
if(_host != p->_host)
{
- //
- // We do the most time-consuming part of the comparison last.
- //
- struct sockaddr_in laddr;
- struct sockaddr_in raddr;
- try
- {
- IceInternal::getAddress(_host, _port, laddr);
- IceInternal::getAddress(p->_host, p->_port, raddr);
- }
- catch(const DNSException&)
- {
- return false;
- }
+ //
+ // We do the most time-consuming part of the comparison last.
+ //
+ struct sockaddr_in laddr;
+ struct sockaddr_in raddr;
+ try
+ {
+ IceInternal::getAddress(_host, _port, laddr);
+ IceInternal::getAddress(p->_host, p->_port, raddr);
+ }
+ catch(const DNSException&)
+ {
+ return false;
+ }
- return IceInternal::compareAddress(laddr, raddr);
+ return IceInternal::compareAddress(laddr, raddr);
}
return true;
@@ -429,76 +429,76 @@ IceSSL::EndpointI::operator<(const IceInternal::EndpointI& r) const
if(this == p)
{
- return false;
+ return false;
}
if(_port < p->_port)
{
- return true;
+ return true;
}
else if(p->_port < _port)
{
- return false;
+ return false;
}
if(_timeout < p->_timeout)
{
- return true;
+ return true;
}
else if(p->_timeout < _timeout)
{
- return false;
+ return false;
}
if(_connectionId < p->_connectionId)
{
- return true;
+ return true;
}
else if(p->_connectionId < _connectionId)
{
- return false;
+ return false;
}
if(!_compress && p->_compress)
{
- return true;
+ return true;
}
else if(p->_compress < _compress)
{
- return false;
+ return false;
}
if(_host != p->_host)
{
- //
- // We do the most time-consuming part of the comparison last.
- //
- struct sockaddr_in laddr;
- try
- {
- IceInternal::getAddress(_host, _port, laddr);
- }
- catch(const DNSException&)
- {
- }
-
- struct sockaddr_in raddr;
- try
- {
- IceInternal::getAddress(p->_host, p->_port, raddr);
- }
- catch(const DNSException&)
- {
- }
-
- if(laddr.sin_addr.s_addr < raddr.sin_addr.s_addr)
- {
- return true;
- }
- else if(raddr.sin_addr.s_addr < laddr.sin_addr.s_addr)
- {
- return false;
- }
+ //
+ // We do the most time-consuming part of the comparison last.
+ //
+ struct sockaddr_in laddr;
+ try
+ {
+ IceInternal::getAddress(_host, _port, laddr);
+ }
+ catch(const DNSException&)
+ {
+ }
+
+ struct sockaddr_in raddr;
+ try
+ {
+ IceInternal::getAddress(p->_host, p->_port, raddr);
+ }
+ catch(const DNSException&)
+ {
+ }
+
+ if(laddr.sin_addr.s_addr < raddr.sin_addr.s_addr)
+ {
+ return true;
+ }
+ else if(raddr.sin_addr.s_addr < laddr.sin_addr.s_addr)
+ {
+ return false;
+ }
}
return false;
diff --git a/cpp/src/IceSSL/Instance.cpp b/cpp/src/IceSSL/Instance.cpp
index 78af13bbcd3..112e013cb2d 100644
--- a/cpp/src/IceSSL/Instance.cpp
+++ b/cpp/src/IceSSL/Instance.cpp
@@ -41,7 +41,7 @@ IceSSL_opensslPasswordCallback(char* buf, int size, int flag, void* userData)
int sz = static_cast<int>(passwd.size());
if(sz > size)
{
- sz = size - 1;
+ sz = size - 1;
}
strncpy(buf, passwd.c_str(), sz);
buf[sz] = '\0';
@@ -75,9 +75,9 @@ passwordError()
{
int reason = ERR_GET_REASON(ERR_peek_error());
return (reason == PEM_R_BAD_BASE64_DECODE ||
- reason == PEM_R_BAD_DECRYPT ||
- reason == PEM_R_BAD_PASSWORD_READ ||
- reason == PEM_R_PROBLEMS_GETTING_PASSWORD);
+ reason == PEM_R_BAD_DECRYPT ||
+ reason == PEM_R_BAD_PASSWORD_READ ||
+ reason == PEM_R_PROBLEMS_GETTING_PASSWORD);
}
IceSSL::Instance::Instance(const CommunicatorPtr& communicator) :
@@ -106,393 +106,393 @@ IceSSL::Instance::initialize()
{
if(_ctx)
{
- return;
+ return;
}
_ctx = SSL_CTX_new(SSLv23_method());
if(!_ctx)
{
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: unable to create SSL context:\n" + sslErrors();
- throw ex;
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: unable to create SSL context:\n" + sslErrors();
+ throw ex;
}
try
{
- //
- // Store a pointer to ourself for use in OpenSSL callbacks.
- //
- SSL_CTX_set_ex_data(_ctx, 0, this);
-
- //
- // This is necessary for successful interop with Java. Without it, a Java
- // client would fail to reestablish a connection: the server gets the
- // error "session id context uninitialized" and the client receives
- // "SSLHandshakeException: Remote host closed connection during handshake".
- //
- SSL_CTX_set_session_cache_mode(_ctx, SSL_SESS_CACHE_OFF);
-
- PropertiesPtr properties = communicator()->getProperties();
- const string propPrefix = "IceSSL.";
-
- //
- // Check for a default directory. We look in this directory for
- // files mentioned in the configuration.
- //
- {
- _defaultDir = properties->getProperty(propPrefix + "DefaultDir");
- }
-
- //
- // Select protocols.
- //
- {
- string protocols = properties->getProperty(propPrefix + "Protocols");
- if(!protocols.empty())
- {
- parseProtocols(protocols);
- }
- }
-
- //
- // CheckCertName determines whether we compare the name in a peer's
- // certificate against its hostname.
- //
- {
- _checkCertName = properties->getPropertyAsIntWithDefault(propPrefix + "CheckCertName", 0) > 0;
- }
-
- //
- // VerifyDepthMax establishes the maximum length of a peer's certificate
- // chain, including the peer's certificate. A value of 0 means there is
- // no maximum.
- //
- {
- _verifyDepthMax = properties->getPropertyAsIntWithDefault(propPrefix + "VerifyDepthMax", 2);
- }
-
- //
- // Determine whether a certificate is required from the peer.
- //
- {
- int verifyPeer = properties->getPropertyAsIntWithDefault(propPrefix + "VerifyPeer", 2);
- int sslVerifyMode;
- switch(verifyPeer)
- {
- case 0:
- sslVerifyMode = SSL_VERIFY_NONE;
- break;
- case 1:
- sslVerifyMode = SSL_VERIFY_PEER;
- break;
- case 2:
- sslVerifyMode = SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
- break;
- default:
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: invalid value for " + propPrefix + "VerifyPeer";
- throw ex;
- }
- }
- SSL_CTX_set_verify(_ctx, sslVerifyMode, IceSSL_opensslVerifyCallback);
- }
-
- //
- // If the configuration defines a password, or the application has supplied
- // a password prompt object, then register a password callback. Otherwise,
- // let OpenSSL use its default behavior.
- //
- {
- // TODO: Support quoted value?
- string password = properties->getProperty(propPrefix + "Password");
- if(!password.empty() || _prompt)
- {
- SSL_CTX_set_default_passwd_cb(_ctx, IceSSL_opensslPasswordCallback);
- SSL_CTX_set_default_passwd_cb_userdata(_ctx, this);
- _password = password;
- }
- }
-
- int passwordRetryMax = properties->getPropertyAsIntWithDefault(propPrefix + "PasswordRetryMax", 3);
-
- //
- // Establish the location of CA certificates.
- //
- {
- string caFile = properties->getProperty(propPrefix + "CertAuthFile");
- string caDir = properties->getPropertyWithDefault(propPrefix + "CertAuthDir", _defaultDir);
- const char* file = 0;
- const char* dir = 0;
- if(!caFile.empty())
- {
- if(!checkPath(caFile, _defaultDir, false))
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: CA certificate file not found:\n" + caFile;
- throw ex;
- }
- file = caFile.c_str();
- }
- if(!caDir.empty())
- {
- if(!checkPath(caDir, _defaultDir, true))
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: CA certificate directory not found:\n" + caDir;
- throw ex;
- }
- dir = caDir.c_str();
- }
- if(file || dir)
- {
- //
- // The certificate may be stored in an encrypted file, so handle
- // password retries.
- //
- int count = 0;
- int err = 0;
- while(count < passwordRetryMax)
- {
- ERR_clear_error();
- err = SSL_CTX_load_verify_locations(_ctx, file, dir);
- if(err || !passwordError())
- {
- break;
- }
- ++count;
- }
- if(err == 0)
- {
- string msg = "IceSSL: unable to establish CA certificates";
- if(passwordError())
- {
- msg += ":\ninvalid password";
- }
- else
- {
- string err = sslErrors();
- if(!err.empty())
- {
- msg += ":\n" + err;
- }
- }
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = msg;
- throw ex;
- }
- }
- }
-
- //
- // Establish the certificate chains and private keys. One RSA certificate and
- // one DSA certificate are allowed.
- //
- {
+ //
+ // Store a pointer to ourself for use in OpenSSL callbacks.
+ //
+ SSL_CTX_set_ex_data(_ctx, 0, this);
+
+ //
+ // This is necessary for successful interop with Java. Without it, a Java
+ // client would fail to reestablish a connection: the server gets the
+ // error "session id context uninitialized" and the client receives
+ // "SSLHandshakeException: Remote host closed connection during handshake".
+ //
+ SSL_CTX_set_session_cache_mode(_ctx, SSL_SESS_CACHE_OFF);
+
+ PropertiesPtr properties = communicator()->getProperties();
+ const string propPrefix = "IceSSL.";
+
+ //
+ // Check for a default directory. We look in this directory for
+ // files mentioned in the configuration.
+ //
+ {
+ _defaultDir = properties->getProperty(propPrefix + "DefaultDir");
+ }
+
+ //
+ // Select protocols.
+ //
+ {
+ string protocols = properties->getProperty(propPrefix + "Protocols");
+ if(!protocols.empty())
+ {
+ parseProtocols(protocols);
+ }
+ }
+
+ //
+ // CheckCertName determines whether we compare the name in a peer's
+ // certificate against its hostname.
+ //
+ {
+ _checkCertName = properties->getPropertyAsIntWithDefault(propPrefix + "CheckCertName", 0) > 0;
+ }
+
+ //
+ // VerifyDepthMax establishes the maximum length of a peer's certificate
+ // chain, including the peer's certificate. A value of 0 means there is
+ // no maximum.
+ //
+ {
+ _verifyDepthMax = properties->getPropertyAsIntWithDefault(propPrefix + "VerifyDepthMax", 2);
+ }
+
+ //
+ // Determine whether a certificate is required from the peer.
+ //
+ {
+ int verifyPeer = properties->getPropertyAsIntWithDefault(propPrefix + "VerifyPeer", 2);
+ int sslVerifyMode;
+ switch(verifyPeer)
+ {
+ case 0:
+ sslVerifyMode = SSL_VERIFY_NONE;
+ break;
+ case 1:
+ sslVerifyMode = SSL_VERIFY_PEER;
+ break;
+ case 2:
+ sslVerifyMode = SSL_VERIFY_PEER|SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
+ break;
+ default:
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: invalid value for " + propPrefix + "VerifyPeer";
+ throw ex;
+ }
+ }
+ SSL_CTX_set_verify(_ctx, sslVerifyMode, IceSSL_opensslVerifyCallback);
+ }
+
+ //
+ // If the configuration defines a password, or the application has supplied
+ // a password prompt object, then register a password callback. Otherwise,
+ // let OpenSSL use its default behavior.
+ //
+ {
+ // TODO: Support quoted value?
+ string password = properties->getProperty(propPrefix + "Password");
+ if(!password.empty() || _prompt)
+ {
+ SSL_CTX_set_default_passwd_cb(_ctx, IceSSL_opensslPasswordCallback);
+ SSL_CTX_set_default_passwd_cb_userdata(_ctx, this);
+ _password = password;
+ }
+ }
+
+ int passwordRetryMax = properties->getPropertyAsIntWithDefault(propPrefix + "PasswordRetryMax", 3);
+
+ //
+ // Establish the location of CA certificates.
+ //
+ {
+ string caFile = properties->getProperty(propPrefix + "CertAuthFile");
+ string caDir = properties->getPropertyWithDefault(propPrefix + "CertAuthDir", _defaultDir);
+ const char* file = 0;
+ const char* dir = 0;
+ if(!caFile.empty())
+ {
+ if(!checkPath(caFile, _defaultDir, false))
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: CA certificate file not found:\n" + caFile;
+ throw ex;
+ }
+ file = caFile.c_str();
+ }
+ if(!caDir.empty())
+ {
+ if(!checkPath(caDir, _defaultDir, true))
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: CA certificate directory not found:\n" + caDir;
+ throw ex;
+ }
+ dir = caDir.c_str();
+ }
+ if(file || dir)
+ {
+ //
+ // The certificate may be stored in an encrypted file, so handle
+ // password retries.
+ //
+ int count = 0;
+ int err = 0;
+ while(count < passwordRetryMax)
+ {
+ ERR_clear_error();
+ err = SSL_CTX_load_verify_locations(_ctx, file, dir);
+ if(err || !passwordError())
+ {
+ break;
+ }
+ ++count;
+ }
+ if(err == 0)
+ {
+ string msg = "IceSSL: unable to establish CA certificates";
+ if(passwordError())
+ {
+ msg += ":\ninvalid password";
+ }
+ else
+ {
+ string err = sslErrors();
+ if(!err.empty())
+ {
+ msg += ":\n" + err;
+ }
+ }
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = msg;
+ throw ex;
+ }
+ }
+ }
+
+ //
+ // Establish the certificate chains and private keys. One RSA certificate and
+ // one DSA certificate are allowed.
+ //
+ {
#ifdef _WIN32
- const string sep = ";";
+ const string sep = ";";
#else
- const string sep = ":";
+ const string sep = ":";
#endif
- string certFile = properties->getProperty(propPrefix + "CertFile");
- string keyFile = properties->getProperty(propPrefix + "KeyFile");
- vector<string>::size_type numCerts = 0;
- if(!certFile.empty())
- {
- vector<string> files;
- if(!splitString(certFile, sep, false, files) || files.size() > 2)
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: invalid value for " + propPrefix + "CertFile:\n" + certFile;
- throw ex;
- }
- numCerts = files.size();
- for(vector<string>::iterator p = files.begin(); p != files.end(); ++p)
- {
- string file = *p;
- if(!checkPath(file, _defaultDir, false))
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: certificate file not found:\n" + file;
- throw ex;
- }
- //
- // The certificate may be stored in an encrypted file, so handle
- // password retries.
- //
- int count = 0;
- int err = 0;
- while(count < passwordRetryMax)
- {
- ERR_clear_error();
- err = SSL_CTX_use_certificate_chain_file(_ctx, file.c_str());
- if(err || !passwordError())
- {
- break;
- }
- ++count;
- }
- if(err == 0)
- {
- string msg = "IceSSL: unable to load certificate chain from file " + file;
- if(passwordError())
- {
- msg += ":\ninvalid password";
- }
- else
- {
- string err = sslErrors();
- if(!err.empty())
- {
- msg += ":\n" + err;
- }
- }
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = msg;
- throw ex;
- }
- }
- }
- if(keyFile.empty())
- {
- keyFile = certFile; // Assume the certificate file also contains the private key.
- }
- if(!keyFile.empty())
- {
- vector<string> files;
- if(!splitString(keyFile, sep, false, files) || files.size() > 2)
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: invalid value for " + propPrefix + "KeyFile:\n" + keyFile;
- throw ex;
- }
- if(files.size() != numCerts)
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: " + propPrefix + "KeyFile does not agree with " + propPrefix + "CertFile";
- throw ex;
- }
- for(vector<string>::iterator p = files.begin(); p != files.end(); ++p)
- {
- string file = *p;
- if(!checkPath(file, _defaultDir, false))
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: key file not found:\n" + file;
- throw ex;
- }
- //
- // The private key may be stored in an encrypted file, so handle
- // password retries.
- //
- int count = 0;
- int err = 0;
- while(count < passwordRetryMax)
- {
- ERR_clear_error();
- err = SSL_CTX_use_PrivateKey_file(_ctx, file.c_str(), SSL_FILETYPE_PEM);
- if(err || !passwordError())
- {
- break;
- }
- ++count;
- }
- if(err == 0)
- {
- string msg = "IceSSL: unable to load private key from file " + file;
- if(passwordError())
- {
- msg += ":\ninvalid password";
- }
- else
- {
- string err = sslErrors();
- if(!err.empty())
- {
- msg += ":\n" + err;
- }
- }
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = msg;
- throw ex;
- }
- }
- if(!SSL_CTX_check_private_key(_ctx))
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: unable to validate private key(s):\n" + sslErrors();
- throw ex;
- }
- }
- }
-
- //
- // Establish the cipher list.
- //
- {
- string ciphers = properties->getProperty(propPrefix + "Ciphers");
- if(!ciphers.empty())
- {
- if(!SSL_CTX_set_cipher_list(_ctx, ciphers.c_str()))
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: unable to set ciphers using `" + ciphers + "':\n" + sslErrors();
- throw ex;
- }
- }
- }
-
- //
- // Diffie Hellman configuration.
- //
- {
+ string certFile = properties->getProperty(propPrefix + "CertFile");
+ string keyFile = properties->getProperty(propPrefix + "KeyFile");
+ vector<string>::size_type numCerts = 0;
+ if(!certFile.empty())
+ {
+ vector<string> files;
+ if(!splitString(certFile, sep, false, files) || files.size() > 2)
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: invalid value for " + propPrefix + "CertFile:\n" + certFile;
+ throw ex;
+ }
+ numCerts = files.size();
+ for(vector<string>::iterator p = files.begin(); p != files.end(); ++p)
+ {
+ string file = *p;
+ if(!checkPath(file, _defaultDir, false))
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: certificate file not found:\n" + file;
+ throw ex;
+ }
+ //
+ // The certificate may be stored in an encrypted file, so handle
+ // password retries.
+ //
+ int count = 0;
+ int err = 0;
+ while(count < passwordRetryMax)
+ {
+ ERR_clear_error();
+ err = SSL_CTX_use_certificate_chain_file(_ctx, file.c_str());
+ if(err || !passwordError())
+ {
+ break;
+ }
+ ++count;
+ }
+ if(err == 0)
+ {
+ string msg = "IceSSL: unable to load certificate chain from file " + file;
+ if(passwordError())
+ {
+ msg += ":\ninvalid password";
+ }
+ else
+ {
+ string err = sslErrors();
+ if(!err.empty())
+ {
+ msg += ":\n" + err;
+ }
+ }
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = msg;
+ throw ex;
+ }
+ }
+ }
+ if(keyFile.empty())
+ {
+ keyFile = certFile; // Assume the certificate file also contains the private key.
+ }
+ if(!keyFile.empty())
+ {
+ vector<string> files;
+ if(!splitString(keyFile, sep, false, files) || files.size() > 2)
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: invalid value for " + propPrefix + "KeyFile:\n" + keyFile;
+ throw ex;
+ }
+ if(files.size() != numCerts)
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: " + propPrefix + "KeyFile does not agree with " + propPrefix + "CertFile";
+ throw ex;
+ }
+ for(vector<string>::iterator p = files.begin(); p != files.end(); ++p)
+ {
+ string file = *p;
+ if(!checkPath(file, _defaultDir, false))
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: key file not found:\n" + file;
+ throw ex;
+ }
+ //
+ // The private key may be stored in an encrypted file, so handle
+ // password retries.
+ //
+ int count = 0;
+ int err = 0;
+ while(count < passwordRetryMax)
+ {
+ ERR_clear_error();
+ err = SSL_CTX_use_PrivateKey_file(_ctx, file.c_str(), SSL_FILETYPE_PEM);
+ if(err || !passwordError())
+ {
+ break;
+ }
+ ++count;
+ }
+ if(err == 0)
+ {
+ string msg = "IceSSL: unable to load private key from file " + file;
+ if(passwordError())
+ {
+ msg += ":\ninvalid password";
+ }
+ else
+ {
+ string err = sslErrors();
+ if(!err.empty())
+ {
+ msg += ":\n" + err;
+ }
+ }
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = msg;
+ throw ex;
+ }
+ }
+ if(!SSL_CTX_check_private_key(_ctx))
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: unable to validate private key(s):\n" + sslErrors();
+ throw ex;
+ }
+ }
+ }
+
+ //
+ // Establish the cipher list.
+ //
+ {
+ string ciphers = properties->getProperty(propPrefix + "Ciphers");
+ if(!ciphers.empty())
+ {
+ if(!SSL_CTX_set_cipher_list(_ctx, ciphers.c_str()))
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: unable to set ciphers using `" + ciphers + "':\n" + sslErrors();
+ throw ex;
+ }
+ }
+ }
+
+ //
+ // Diffie Hellman configuration.
+ //
+ {
#ifndef OPENSSL_NO_DH
- _dhParams = new DHParams;
- SSL_CTX_set_options(_ctx, SSL_OP_SINGLE_DH_USE);
- SSL_CTX_set_tmp_dh_callback(_ctx, IceSSL_opensslDHCallback);
+ _dhParams = new DHParams;
+ SSL_CTX_set_options(_ctx, SSL_OP_SINGLE_DH_USE);
+ SSL_CTX_set_tmp_dh_callback(_ctx, IceSSL_opensslDHCallback);
#endif
- //
- // Properties have the following form:
- //
- // ...DH.<keyLength>=file
- //
- const string dhPrefix = propPrefix + "DH.";
- PropertyDict d = properties->getPropertiesForPrefix(dhPrefix);
- if(!d.empty())
- {
+ //
+ // Properties have the following form:
+ //
+ // ...DH.<keyLength>=file
+ //
+ const string dhPrefix = propPrefix + "DH.";
+ PropertyDict d = properties->getPropertiesForPrefix(dhPrefix);
+ if(!d.empty())
+ {
#ifdef OPENSSL_NO_DH
- _logger->warning("IceSSL: OpenSSL is not configured for Diffie Hellman");
+ _logger->warning("IceSSL: OpenSSL is not configured for Diffie Hellman");
#else
- for(PropertyDict::iterator p = d.begin(); p != d.end(); ++p)
- {
- string s = p->first.substr(dhPrefix.size());
- int keyLength = atoi(s.c_str());
- if(keyLength > 0)
- {
- string file = p->second;
- if(!checkPath(file, _defaultDir, false))
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: DH parameter file not found:\n" + file;
- throw ex;
- }
- if(!_dhParams->add(keyLength, file))
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: unable to read DH parameter file " + file;
- throw ex;
- }
- }
- }
+ for(PropertyDict::iterator p = d.begin(); p != d.end(); ++p)
+ {
+ string s = p->first.substr(dhPrefix.size());
+ int keyLength = atoi(s.c_str());
+ if(keyLength > 0)
+ {
+ string file = p->second;
+ if(!checkPath(file, _defaultDir, false))
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: DH parameter file not found:\n" + file;
+ throw ex;
+ }
+ if(!_dhParams->add(keyLength, file))
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: unable to read DH parameter file " + file;
+ throw ex;
+ }
+ }
+ }
#endif
- }
- }
+ }
+ }
}
catch(...)
{
- SSL_CTX_free(_ctx);
- _ctx = 0;
- throw;
+ SSL_CTX_free(_ctx);
+ _ctx = 0;
+ throw;
}
}
@@ -501,9 +501,9 @@ IceSSL::Instance::context(SSL_CTX* context)
{
if(_ctx)
{
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: plugin is already initialized";
- throw ex;
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: plugin is already initialized";
+ throw ex;
}
_ctx = context;
@@ -569,23 +569,23 @@ IceSSL::Instance::verifyPeer(SSL* ssl, SOCKET fd, const string& address, const s
long result = SSL_get_verify_result(ssl);
if(result != X509_V_OK)
{
- ostringstream ostr;
- ostr << "IceSSL: certificate verification failed:\n" << X509_verify_cert_error_string(result);
- string msg = ostr.str();
- if(_securityTraceLevel >= 1)
- {
- _logger->trace(_securityTraceCategory, msg);
- }
- SecurityException ex(__FILE__, __LINE__);
- ex.reason = msg;
- throw ex;
+ ostringstream ostr;
+ ostr << "IceSSL: certificate verification failed:\n" << X509_verify_cert_error_string(result);
+ string msg = ostr.str();
+ if(_securityTraceLevel >= 1)
+ {
+ _logger->trace(_securityTraceCategory, msg);
+ }
+ SecurityException ex(__FILE__, __LINE__);
+ ex.reason = msg;
+ throw ex;
}
X509* rawCert = SSL_get_peer_certificate(ssl);
CertificatePtr cert;
if(rawCert != 0)
{
- cert = new Certificate(rawCert);
+ cert = new Certificate(rawCert);
}
//
@@ -594,148 +594,148 @@ IceSSL::Instance::verifyPeer(SSL* ssl, SOCKET fd, const string& address, const s
//
if(cert)
{
- vector<pair<int, string> > subjectAltNames = cert->getSubjectAlternativeNames();
- vector<string> ipAddresses;
- vector<string> dnsNames;
- for(vector<pair<int, string> >::const_iterator p = subjectAltNames.begin(); p != subjectAltNames.end(); ++p)
- {
- if(p->first == 7)
- {
- ipAddresses.push_back(p->second);
- }
- else if(p->first == 2)
- {
- dnsNames.push_back(p->second);
- }
- }
-
- //
- // Compare the peer's address against the dnsName and ipAddress values.
- // This is only relevant for an outgoing connection.
- //
- if(!address.empty())
- {
- bool certNameOK = false;
-
- for(vector<string>::const_iterator p = ipAddresses.begin(); p != ipAddresses.end() && !certNameOK; ++p)
- {
- if(address == *p)
- {
- certNameOK = true;
- break;
- }
- }
-
- if(!certNameOK && !dnsNames.empty())
- {
- string host = address;
- transform(host.begin(), host.end(), host.begin(), ::tolower);
- for(vector<string>::const_iterator p = dnsNames.begin(); p != dnsNames.end() && !certNameOK; ++p)
- {
- string s = *p;
- transform(s.begin(), s.end(), s.begin(), ::tolower);
- if(host == s)
- {
- certNameOK = true;
- }
- }
- }
-
- //
- // Log a message if the name comparison fails. If CheckCertName is defined,
- // we also raise an exception to abort the connection. Don't log a message if
- // CheckCertName is not defined and a verifier is present.
- //
- if(!certNameOK && (_checkCertName || (_securityTraceLevel >= 1 && !_verifier)))
- {
- ostringstream ostr;
- ostr << "IceSSL: ";
- if(!_checkCertName)
- {
- ostr << "ignoring ";
- }
- ostr << "certificate validation failure:\npeer certificate does not contain `"
- << address << "' in its subjectAltName extension";
- if(!dnsNames.empty())
- {
- ostr << "\nDNS names found in certificate: ";
- for(vector<string>::const_iterator p = dnsNames.begin(); p != dnsNames.end(); ++p)
- {
- if(p != dnsNames.begin())
- {
- ostr << ", ";
- }
- ostr << *p;
- }
- }
- if(!ipAddresses.empty())
- {
- ostr << "\nIP addresses found in certificate: ";
- for(vector<string>::const_iterator p = ipAddresses.begin(); p != ipAddresses.end(); ++p)
- {
- if(p != ipAddresses.begin())
- {
- ostr << ", ";
- }
- ostr << *p;
- }
- }
- string msg = ostr.str();
- if(_securityTraceLevel >= 1)
- {
- Trace out(_logger, _securityTraceCategory);
- out << msg;
- }
- if(_checkCertName)
- {
- SecurityException ex(__FILE__, __LINE__);
- ex.reason = msg;
- throw ex;
- }
- }
- }
+ vector<pair<int, string> > subjectAltNames = cert->getSubjectAlternativeNames();
+ vector<string> ipAddresses;
+ vector<string> dnsNames;
+ for(vector<pair<int, string> >::const_iterator p = subjectAltNames.begin(); p != subjectAltNames.end(); ++p)
+ {
+ if(p->first == 7)
+ {
+ ipAddresses.push_back(p->second);
+ }
+ else if(p->first == 2)
+ {
+ dnsNames.push_back(p->second);
+ }
+ }
+
+ //
+ // Compare the peer's address against the dnsName and ipAddress values.
+ // This is only relevant for an outgoing connection.
+ //
+ if(!address.empty())
+ {
+ bool certNameOK = false;
+
+ for(vector<string>::const_iterator p = ipAddresses.begin(); p != ipAddresses.end() && !certNameOK; ++p)
+ {
+ if(address == *p)
+ {
+ certNameOK = true;
+ break;
+ }
+ }
+
+ if(!certNameOK && !dnsNames.empty())
+ {
+ string host = address;
+ transform(host.begin(), host.end(), host.begin(), ::tolower);
+ for(vector<string>::const_iterator p = dnsNames.begin(); p != dnsNames.end() && !certNameOK; ++p)
+ {
+ string s = *p;
+ transform(s.begin(), s.end(), s.begin(), ::tolower);
+ if(host == s)
+ {
+ certNameOK = true;
+ }
+ }
+ }
+
+ //
+ // Log a message if the name comparison fails. If CheckCertName is defined,
+ // we also raise an exception to abort the connection. Don't log a message if
+ // CheckCertName is not defined and a verifier is present.
+ //
+ if(!certNameOK && (_checkCertName || (_securityTraceLevel >= 1 && !_verifier)))
+ {
+ ostringstream ostr;
+ ostr << "IceSSL: ";
+ if(!_checkCertName)
+ {
+ ostr << "ignoring ";
+ }
+ ostr << "certificate validation failure:\npeer certificate does not contain `"
+ << address << "' in its subjectAltName extension";
+ if(!dnsNames.empty())
+ {
+ ostr << "\nDNS names found in certificate: ";
+ for(vector<string>::const_iterator p = dnsNames.begin(); p != dnsNames.end(); ++p)
+ {
+ if(p != dnsNames.begin())
+ {
+ ostr << ", ";
+ }
+ ostr << *p;
+ }
+ }
+ if(!ipAddresses.empty())
+ {
+ ostr << "\nIP addresses found in certificate: ";
+ for(vector<string>::const_iterator p = ipAddresses.begin(); p != ipAddresses.end(); ++p)
+ {
+ if(p != ipAddresses.begin())
+ {
+ ostr << ", ";
+ }
+ ostr << *p;
+ }
+ }
+ string msg = ostr.str();
+ if(_securityTraceLevel >= 1)
+ {
+ Trace out(_logger, _securityTraceCategory);
+ out << msg;
+ }
+ if(_checkCertName)
+ {
+ SecurityException ex(__FILE__, __LINE__);
+ ex.reason = msg;
+ throw ex;
+ }
+ }
+ }
}
ConnectionInfo info = populateConnectionInfo(ssl, fd, adapterName, incoming);
if(_verifyDepthMax > 0 && static_cast<int>(info.certs.size()) > _verifyDepthMax)
{
- ostringstream ostr;
- ostr << (incoming ? "incoming" : "outgoing") << " connection rejected:\n"
- << "length of peer's certificate chain (" << info.certs.size() << ") exceeds maximum of "
- << _verifyDepthMax;
- string msg = ostr.str();
- if(_securityTraceLevel >= 1)
- {
- _logger->trace(_securityTraceCategory, msg + "\n" + IceInternal::fdToString(fd));
- }
- SecurityException ex(__FILE__, __LINE__);
- ex.reason = msg;
- throw ex;
+ ostringstream ostr;
+ ostr << (incoming ? "incoming" : "outgoing") << " connection rejected:\n"
+ << "length of peer's certificate chain (" << info.certs.size() << ") exceeds maximum of "
+ << _verifyDepthMax;
+ string msg = ostr.str();
+ if(_securityTraceLevel >= 1)
+ {
+ _logger->trace(_securityTraceCategory, msg + "\n" + IceInternal::fdToString(fd));
+ }
+ SecurityException ex(__FILE__, __LINE__);
+ ex.reason = msg;
+ throw ex;
}
if(!_trustManager->verify(info))
{
- string msg = string(incoming ? "incoming" : "outgoing") + " connection rejected by trust manager";
- if(_securityTraceLevel >= 1)
- {
- _logger->trace(_securityTraceCategory, msg + "\n" + IceInternal::fdToString(fd));
- }
- SecurityException ex(__FILE__, __LINE__);
- ex.reason = msg;
- throw ex;
+ string msg = string(incoming ? "incoming" : "outgoing") + " connection rejected by trust manager";
+ if(_securityTraceLevel >= 1)
+ {
+ _logger->trace(_securityTraceCategory, msg + "\n" + IceInternal::fdToString(fd));
+ }
+ SecurityException ex(__FILE__, __LINE__);
+ ex.reason = msg;
+ throw ex;
}
if(_verifier && !_verifier->verify(info))
{
- string msg = string(incoming ? "incoming" : "outgoing") + " connection rejected by certificate verifier";
- if(_securityTraceLevel >= 1)
- {
- _logger->trace(_securityTraceCategory, msg + "\n" + IceInternal::fdToString(fd));
- }
- SecurityException ex(__FILE__, __LINE__);
- ex.reason = msg;
- throw ex;
+ string msg = string(incoming ? "incoming" : "outgoing") + " connection rejected by certificate verifier";
+ if(_securityTraceLevel >= 1)
+ {
+ _logger->trace(_securityTraceCategory, msg + "\n" + IceInternal::fdToString(fd));
+ }
+ SecurityException ex(__FILE__, __LINE__);
+ ex.reason = msg;
+ throw ex;
}
}
@@ -752,7 +752,7 @@ IceSSL::Instance::destroy()
if(_ctx)
{
- SSL_CTX_free(_ctx);
+ SSL_CTX_free(_ctx);
}
}
@@ -761,21 +761,21 @@ IceSSL::Instance::password(bool /*encrypting*/)
{
if(_prompt)
{
- try
- {
- return _prompt->getPassword();
- }
- catch(...)
- {
- //
- // Don't allow exceptions to cross an OpenSSL boundary.
- //
- return string();
- }
+ try
+ {
+ return _prompt->getPassword();
+ }
+ catch(...)
+ {
+ //
+ // Don't allow exceptions to cross an OpenSSL boundary.
+ //
+ return string();
+ }
}
else
{
- return _password;
+ return _password;
}
}
@@ -784,20 +784,20 @@ IceSSL::Instance::verifyCallback(int ok, SSL* ssl, X509_STORE_CTX* c)
{
if(!ok && _securityTraceLevel >= 1)
{
- X509* cert = X509_STORE_CTX_get_current_cert(c);
- int err = X509_STORE_CTX_get_error(c);
- char buf[256];
-
- Trace out(_logger, _securityTraceCategory);
- out << "certificate verification failure\n";
-
- X509_NAME_oneline(X509_get_issuer_name(cert), buf, static_cast<int>(sizeof(buf)));
- out << "issuer = " << buf << '\n';
- X509_NAME_oneline(X509_get_subject_name(cert), buf, static_cast<int>(sizeof(buf)));
- out << "subject = " << buf << '\n';
- out << "depth = " << X509_STORE_CTX_get_error_depth(c) << '\n';
- out << "error = " << X509_verify_cert_error_string(err) << '\n';
- out << IceInternal::fdToString(SSL_get_fd(ssl));
+ X509* cert = X509_STORE_CTX_get_current_cert(c);
+ int err = X509_STORE_CTX_get_error(c);
+ char buf[256];
+
+ Trace out(_logger, _securityTraceCategory);
+ out << "certificate verification failure\n";
+
+ X509_NAME_oneline(X509_get_issuer_name(cert), buf, static_cast<int>(sizeof(buf)));
+ out << "issuer = " << buf << '\n';
+ X509_NAME_oneline(X509_get_subject_name(cert), buf, static_cast<int>(sizeof(buf)));
+ out << "subject = " << buf << '\n';
+ out << "depth = " << X509_STORE_CTX_get_error_depth(c) << '\n';
+ out << "error = " << X509_verify_cert_error_string(err) << '\n';
+ out << IceInternal::fdToString(SSL_get_fd(ssl));
}
return ok;
}
@@ -818,13 +818,13 @@ IceSSL::Instance::traceConnection(SSL* ssl, bool incoming)
SSL_CIPHER* cipher = SSL_get_current_cipher(ssl);
if(!cipher)
{
- out << "unknown cipher\n";
+ out << "unknown cipher\n";
}
else
{
- out << "cipher = " << SSL_CIPHER_get_name(cipher) << "\n";
- out << "bits = " << SSL_CIPHER_get_bits(cipher, 0) << "\n";
- out << "protocol = " << SSL_get_version(ssl) << "\n";
+ out << "cipher = " << SSL_CIPHER_get_name(cipher) << "\n";
+ out << "bits = " << SSL_CIPHER_get_bits(cipher, 0) << "\n";
+ out << "protocol = " << SSL_get_version(ssl) << "\n";
}
out << IceInternal::fdToString(SSL_get_fd(ssl));
}
@@ -837,48 +837,48 @@ IceSSL::Instance::parseProtocols(const string& val)
string::size_type pos = 0;
while(pos != string::npos)
{
- pos = val.find_first_not_of(delim, pos);
- if(pos == string::npos)
- {
- break;
- }
-
- string prot;
- string::size_type end = val.find_first_of(delim, pos);
- if(end == string::npos)
- {
- prot = val.substr(pos);
- }
- else
- {
- prot = val.substr(pos, end - pos);
- }
- pos = end;
-
- if(prot == "ssl3" || prot == "sslv3")
- {
- sslv3 = true;
- }
- else if(prot == "tls" || prot == "tls1" || prot == "tlsv1")
- {
- tlsv1 = true;
- }
- else
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: unrecognized protocol `" + prot + "'";
- throw ex;
- }
+ pos = val.find_first_not_of(delim, pos);
+ if(pos == string::npos)
+ {
+ break;
+ }
+
+ string prot;
+ string::size_type end = val.find_first_of(delim, pos);
+ if(end == string::npos)
+ {
+ prot = val.substr(pos);
+ }
+ else
+ {
+ prot = val.substr(pos, end - pos);
+ }
+ pos = end;
+
+ if(prot == "ssl3" || prot == "sslv3")
+ {
+ sslv3 = true;
+ }
+ else if(prot == "tls" || prot == "tls1" || prot == "tlsv1")
+ {
+ tlsv1 = true;
+ }
+ else
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: unrecognized protocol `" + prot + "'";
+ throw ex;
+ }
}
long opts = SSL_OP_NO_SSLv2; // SSLv2 is not supported.
if(!sslv3)
{
- opts |= SSL_OP_NO_SSLv3;
+ opts |= SSL_OP_NO_SSLv3;
}
if(!tlsv1)
{
- opts |= SSL_OP_NO_TLSv1;
+ opts |= SSL_OP_NO_TLSv1;
}
SSL_CTX_set_options(_ctx, opts);
}
diff --git a/cpp/src/IceSSL/PluginI.cpp b/cpp/src/IceSSL/PluginI.cpp
index 50f986c84d3..30f92d03015 100644
--- a/cpp/src/IceSSL/PluginI.cpp
+++ b/cpp/src/IceSSL/PluginI.cpp
@@ -60,11 +60,11 @@ IceSSL_opensslLockCallback(int mode, int n, const char* file, int line)
{
if(mode & CRYPTO_LOCK)
{
- locks[n].lock();
+ locks[n].lock();
}
else
{
- locks[n].unlock();
+ locks[n].unlock();
}
}
@@ -153,89 +153,89 @@ IceSSL::PluginI::setupSSL(const CommunicatorPtr& communicator)
if(instanceCount == 1)
{
- PropertiesPtr properties = communicator->getProperties();
-
- //
- // Create the mutexes and set the callbacks.
- //
- locks = new IceUtil::Mutex[CRYPTO_num_locks()];
- CRYPTO_set_locking_callback(IceSSL_opensslLockCallback);
- CRYPTO_set_id_callback(IceSSL_opensslThreadIdCallback);
-
- //
- // Load human-readable error messages.
- //
- SSL_load_error_strings();
-
- //
- // Initialize the SSL library.
- //
- SSL_library_init();
-
- //
- // Initialize the PRNG.
- //
+ PropertiesPtr properties = communicator->getProperties();
+
+ //
+ // Create the mutexes and set the callbacks.
+ //
+ locks = new IceUtil::Mutex[CRYPTO_num_locks()];
+ CRYPTO_set_locking_callback(IceSSL_opensslLockCallback);
+ CRYPTO_set_id_callback(IceSSL_opensslThreadIdCallback);
+
+ //
+ // Load human-readable error messages.
+ //
+ SSL_load_error_strings();
+
+ //
+ // Initialize the SSL library.
+ //
+ SSL_library_init();
+
+ //
+ // Initialize the PRNG.
+ //
#ifdef WINDOWS
- RAND_screen(); // Uses data from the screen if possible.
+ RAND_screen(); // Uses data from the screen if possible.
#endif
- char randFile[1024];
- if(RAND_file_name(randFile, sizeof(randFile))) // Gets the name of a default seed file.
- {
- RAND_load_file(randFile, 1024);
- }
- string randFiles = properties->getProperty("IceSSL.Random");
- if(!randFiles.empty())
- {
- vector<string> files;
+ char randFile[1024];
+ if(RAND_file_name(randFile, sizeof(randFile))) // Gets the name of a default seed file.
+ {
+ RAND_load_file(randFile, 1024);
+ }
+ string randFiles = properties->getProperty("IceSSL.Random");
+ if(!randFiles.empty())
+ {
+ vector<string> files;
#ifdef _WIN32
- const string sep = ";";
+ const string sep = ";";
#else
- const string sep = ":";
+ const string sep = ":";
#endif
- string defaultDir = properties->getProperty("IceSSL.DefaultDir");
- if(!splitString(randFiles, sep, false, files))
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: invalid value for IceSSL.Random:\n" + randFiles;
- throw ex;
- }
- for(vector<string>::iterator p = files.begin(); p != files.end(); ++p)
- {
- string file = *p;
- if(!checkPath(file, defaultDir, false))
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: entropy data file not found:\n" + file;
- throw ex;
- }
- if(!RAND_load_file(file.c_str(), 1024))
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: unable to load entropy data from " + file;
- throw ex;
- }
- }
- }
+ string defaultDir = properties->getProperty("IceSSL.DefaultDir");
+ if(!splitString(randFiles, sep, false, files))
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: invalid value for IceSSL.Random:\n" + randFiles;
+ throw ex;
+ }
+ for(vector<string>::iterator p = files.begin(); p != files.end(); ++p)
+ {
+ string file = *p;
+ if(!checkPath(file, defaultDir, false))
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: entropy data file not found:\n" + file;
+ throw ex;
+ }
+ if(!RAND_load_file(file.c_str(), 1024))
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: unable to load entropy data from " + file;
+ throw ex;
+ }
+ }
+ }
#ifndef _WIN32
- //
- // The Entropy Gathering Daemon (EGD) is not available on Windows.
- // The file should be a Unix domain socket for the daemon.
- //
- string entropyDaemon = properties->getProperty("IceSSL.EntropyDaemon");
- if(!entropyDaemon.empty())
- {
- if(RAND_egd(entropyDaemon.c_str()) <= 0)
- {
- PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: EGD failure using file " + entropyDaemon;
- throw ex;
- }
- }
+ //
+ // The Entropy Gathering Daemon (EGD) is not available on Windows.
+ // The file should be a Unix domain socket for the daemon.
+ //
+ string entropyDaemon = properties->getProperty("IceSSL.EntropyDaemon");
+ if(!entropyDaemon.empty())
+ {
+ if(RAND_egd(entropyDaemon.c_str()) <= 0)
+ {
+ PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: EGD failure using file " + entropyDaemon;
+ throw ex;
+ }
+ }
#endif
- if(!RAND_status())
- {
- communicator->getLogger()->warning("IceSSL: insufficient data to initialize PRNG");
- }
+ if(!RAND_status())
+ {
+ communicator->getLogger()->warning("IceSSL: insufficient data to initialize PRNG");
+ }
}
}
@@ -246,15 +246,15 @@ IceSSL::PluginI::cleanupSSL()
if(--instanceCount == 0)
{
- CRYPTO_set_locking_callback(0);
- CRYPTO_set_id_callback(0);
- delete[] locks;
- locks = 0;
-
- CRYPTO_cleanup_all_ex_data();
- RAND_cleanup();
- ERR_free_strings();
- EVP_cleanup();
+ CRYPTO_set_locking_callback(0);
+ CRYPTO_set_id_callback(0);
+ delete[] locks;
+ locks = 0;
+
+ CRYPTO_cleanup_all_ex_data();
+ RAND_cleanup();
+ ERR_free_strings();
+ EVP_cleanup();
}
}
@@ -303,23 +303,23 @@ IceSSL::getConnectionInfo(const ConnectionPtr& connection)
IceInternal::TransceiverPtr transceiver = con->getTransceiver();
if(!transceiver)
{
- throw ConnectionInvalidException(__FILE__, __LINE__, "connection closed");
+ throw ConnectionInvalidException(__FILE__, __LINE__, "connection closed");
}
TransceiverIPtr ssltransceiver = TransceiverIPtr::dynamicCast(con->getTransceiver());
if(!ssltransceiver)
{
- throw ConnectionInvalidException(__FILE__, __LINE__, "not ssl connection");
+ throw ConnectionInvalidException(__FILE__, __LINE__, "not ssl connection");
}
try
{
- return ssltransceiver->getConnectionInfo();
+ return ssltransceiver->getConnectionInfo();
}
catch(const Ice::LocalException& ex)
{
- ostringstream os;
- os << "couldn't get connection information:\n" << ex << endl;
- throw ConnectionInvalidException(__FILE__, __LINE__, os.str());
+ ostringstream os;
+ os << "couldn't get connection information:\n" << ex << endl;
+ throw ConnectionInvalidException(__FILE__, __LINE__, os.str());
}
}
diff --git a/cpp/src/IceSSL/RFC2253.cpp b/cpp/src/IceSSL/RFC2253.cpp
index ad221ef1ac5..72afe765070 100644
--- a/cpp/src/IceSSL/RFC2253.cpp
+++ b/cpp/src/IceSSL/RFC2253.cpp
@@ -37,26 +37,26 @@ IceSSL::RFC2253::parse(const string& data)
size_t pos = 0;
while(pos < data.size())
{
- current.push_back(parseNameComponent(data, pos));
- eatWhite(data, pos);
- if(pos < data.size() && data[pos] == ',')
- {
- ++pos;
- }
- else if(pos < data.size() && data[pos] == ';')
- {
- ++pos;
- results.push_back(current);
- current.clear();
- }
- else if(pos < data.size())
- {
- throw ParseException(__FILE__, __LINE__, "expected ',' or ';' at `" + data.substr(pos) + "'");
- }
+ current.push_back(parseNameComponent(data, pos));
+ eatWhite(data, pos);
+ if(pos < data.size() && data[pos] == ',')
+ {
+ ++pos;
+ }
+ else if(pos < data.size() && data[pos] == ';')
+ {
+ ++pos;
+ results.push_back(current);
+ current.clear();
+ }
+ else if(pos < data.size())
+ {
+ throw ParseException(__FILE__, __LINE__, "expected ',' or ';' at `" + data.substr(pos) + "'");
+ }
}
if(!current.empty())
{
- results.push_back(current);
+ results.push_back(current);
}
return results;
@@ -69,16 +69,16 @@ IceSSL::RFC2253::parseStrict(const string& data)
size_t pos = 0;
while(pos < data.size())
{
- results.push_back(parseNameComponent(data, pos));
- eatWhite(data, pos);
- if(pos < data.size() && (data[pos] == ',' || data[pos] == ';'))
- {
- ++pos;
- }
- else if(pos < data.size())
- {
- throw ParseException(__FILE__, __LINE__, "expected ',' or ';' at `" + data.substr(pos) + "'");
- }
+ results.push_back(parseNameComponent(data, pos));
+ eatWhite(data, pos);
+ if(pos < data.size() && (data[pos] == ',' || data[pos] == ';'))
+ {
+ ++pos;
+ }
+ else if(pos < data.size())
+ {
+ throw ParseException(__FILE__, __LINE__, "expected ',' or ';' at `" + data.substr(pos) + "'");
+ }
}
return results;
}
@@ -88,20 +88,20 @@ IceSSL::RFC2253::unescape(const string& data)
{
if(data.size() == 0)
{
- return data;
+ return data;
}
if(data[0] == '"')
{
- if(data[data.size() - 1] != '"')
- {
- throw ParseException(__FILE__, __LINE__, "unescape: missing \"");
- }
+ if(data[data.size() - 1] != '"')
+ {
+ throw ParseException(__FILE__, __LINE__, "unescape: missing \"");
+ }
- //
- // Return the string without quotes.
- //
- return data.substr(1, data.size() - 2);
+ //
+ // Return the string without quotes.
+ //
+ return data.substr(1, data.size() - 2);
}
//
@@ -110,61 +110,61 @@ IceSSL::RFC2253::unescape(const string& data)
string result;
if(data[0] == '#')
{
- size_t pos = 1;
- while(pos < data.size())
- {
- result += unescapeHex(data, pos);
- pos += 2;
- }
+ size_t pos = 1;
+ while(pos < data.size())
+ {
+ result += unescapeHex(data, pos);
+ pos += 2;
+ }
}
else
{
- size_t pos = 0;
- while(pos < data.size())
- {
- if(data[pos] != '\\')
- {
- result += data[pos];
- ++pos;
- }
- else
- {
- ++pos;
- if(pos >= data.size())
- {
- throw ParseException(__FILE__, __LINE__, "unescape: invalid escape sequence");
- }
- if(special.find(data[pos]) != string::npos || data[pos] != '\\' || data[pos] != '"')
- {
- result += data[pos];
- ++pos;
- }
- else
- {
- result += unescapeHex(data, pos);
- pos += 2;
- }
- }
- }
+ size_t pos = 0;
+ while(pos < data.size())
+ {
+ if(data[pos] != '\\')
+ {
+ result += data[pos];
+ ++pos;
+ }
+ else
+ {
+ ++pos;
+ if(pos >= data.size())
+ {
+ throw ParseException(__FILE__, __LINE__, "unescape: invalid escape sequence");
+ }
+ if(special.find(data[pos]) != string::npos || data[pos] != '\\' || data[pos] != '"')
+ {
+ result += data[pos];
+ ++pos;
+ }
+ else
+ {
+ result += unescapeHex(data, pos);
+ pos += 2;
+ }
+ }
+ }
}
return result;
}
-
+
static int
hexToInt(char v)
{
if(v >= '0' && v <= '9')
{
- return v - '0';
+ return v - '0';
}
if(v >= 'a' && v <= 'f')
{
- return 10 + (v - 'a');
+ return 10 + (v - 'a');
}
if(v >= 'A' && v <= 'F')
{
- return 10 + (v - 'A');
+ return 10 + (v - 'A');
}
throw ParseException(__FILE__, __LINE__, "unescape: invalid hex pair");
return 0; // To satisfy the compiler.
@@ -176,7 +176,7 @@ unescapeHex(const string& data, size_t pos)
assert(pos < data.size());
if(pos + 2 >= data.size())
{
- throw ParseException(__FILE__, __LINE__, "unescape: invalid hex pair");
+ throw ParseException(__FILE__, __LINE__, "unescape: invalid hex pair");
}
return (char)(hexToInt(data[pos]) * 16 + hexToInt(data[pos + 1]));
}
@@ -187,20 +187,20 @@ parseNameComponent(const string& data, size_t& pos)
pair<string, string> final = parseAttributeTypeAndValue(data, pos);
while(pos < data.size())
{
- eatWhite(data, pos);
- if(pos < data.size() && data[pos] == '+')
- {
- ++pos;
- }
- else
- {
- break;
- }
- pair<string, string> p = parseAttributeTypeAndValue(data, pos);
- final.second += "+";
- final.second += p.first;
- final.second += '=';
- final.second += p.second;
+ eatWhite(data, pos);
+ if(pos < data.size() && data[pos] == '+')
+ {
+ ++pos;
+ }
+ else
+ {
+ break;
+ }
+ pair<string, string> p = parseAttributeTypeAndValue(data, pos);
+ final.second += "+";
+ final.second += p.first;
+ final.second += '=';
+ final.second += p.second;
}
return final;
}
@@ -213,11 +213,11 @@ parseAttributeTypeAndValue(const string& data, size_t& pos)
eatWhite(data, pos);
if(pos >= data.size())
{
- throw ParseException(__FILE__, __LINE__, "invalid attribute type/value pair (unexpected end of data)");
+ throw ParseException(__FILE__, __LINE__, "invalid attribute type/value pair (unexpected end of data)");
}
if(data[pos] != '=')
{
- throw ParseException(__FILE__, __LINE__, "invalid attribute type/value pair (missing =)");
+ throw ParseException(__FILE__, __LINE__, "invalid attribute type/value pair (missing =)");
}
++pos;
p.second = parseAttributeValue(data, pos);
@@ -230,7 +230,7 @@ parseAttributeType(const string& data, size_t& pos)
eatWhite(data, pos);
if(pos >= data.size())
{
- throw ParseException(__FILE__, __LINE__, "invalid attribute type (expected end of data)");
+ throw ParseException(__FILE__, __LINE__, "invalid attribute type (expected end of data)");
}
string result;
@@ -256,56 +256,56 @@ parseAttributeType(const string& data, size_t& pos)
if(isdigit(data[pos]) ||
(data.size() - pos >= 4 && (data.substr(pos, 4) == "oid." || data.substr(pos, 4) == "OID.")))
{
- if(!isdigit(data[pos]))
- {
- result += data.substr(pos, 4);
- pos += 4;
- }
+ if(!isdigit(data[pos]))
+ {
+ result += data.substr(pos, 4);
+ pos += 4;
+ }
- while(true)
- {
- // 1*DIGIT
- while(pos < data.size() && isdigit(data[pos]))
- {
- result += data[pos];
- ++pos;
- }
- // "." 1*DIGIT
- if(pos < data.size() && data[pos] == '.')
- {
- result += data[pos];
- ++pos;
- // 1*DIGIT must follow "."
- if(pos < data.size() && !isdigit(data[pos]))
- {
- throw ParseException(__FILE__, __LINE__, "invalid attribute type (expected end of data)");
- }
- }
- else
- {
- break;
- }
- }
+ while(true)
+ {
+ // 1*DIGIT
+ while(pos < data.size() && isdigit(data[pos]))
+ {
+ result += data[pos];
+ ++pos;
+ }
+ // "." 1*DIGIT
+ if(pos < data.size() && data[pos] == '.')
+ {
+ result += data[pos];
+ ++pos;
+ // 1*DIGIT must follow "."
+ if(pos < data.size() && !isdigit(data[pos]))
+ {
+ throw ParseException(__FILE__, __LINE__, "invalid attribute type (expected end of data)");
+ }
+ }
+ else
+ {
+ break;
+ }
+ }
}
else if(isalpha(data[pos]))
{
- //
- // The grammar is wrong in this case. It should be ALPHA
- // KEYCHAR* otherwise it will not accept "O" as a valid
- // attribute type.
- //
- result += data[pos];
- ++pos;
- // 1* KEYCHAR
- while(pos < data.size() && (isalpha(data[pos]) || isdigit(data[pos]) || data[pos] == '-'))
- {
- result += data[pos];
- ++pos;
- }
+ //
+ // The grammar is wrong in this case. It should be ALPHA
+ // KEYCHAR* otherwise it will not accept "O" as a valid
+ // attribute type.
+ //
+ result += data[pos];
+ ++pos;
+ // 1* KEYCHAR
+ while(pos < data.size() && (isalpha(data[pos]) || isdigit(data[pos]) || data[pos] == '-'))
+ {
+ result += data[pos];
+ ++pos;
+ }
}
else
{
- throw ParseException(__FILE__, __LINE__, "invalid attribute type");
+ throw ParseException(__FILE__, __LINE__, "invalid attribute type");
}
return result;
}
@@ -317,7 +317,7 @@ parseAttributeValue(const string& data, size_t& pos)
string result;
if(pos >= data.size())
{
- return result;
+ return result;
}
//
@@ -326,17 +326,17 @@ parseAttributeValue(const string& data, size_t& pos)
//
if(data[pos] == '#')
{
- result += data[pos];
- ++pos;
- while(true)
- {
- string h = parseHexPair(data, pos, true);
- if(h.size() == 0)
- {
- break;
- }
- result += h;
- }
+ result += data[pos];
+ ++pos;
+ while(true)
+ {
+ string h = parseHexPair(data, pos, true);
+ if(h.size() == 0)
+ {
+ break;
+ }
+ result += h;
+ }
}
//
// RFC 2253
@@ -345,33 +345,33 @@ parseAttributeValue(const string& data, size_t& pos)
//
else if(data[pos] == '"')
{
- result += data[pos];
- ++pos;
- while(true)
- {
- if(pos >= data.size())
- {
- throw ParseException(__FILE__, __LINE__, "invalid attribute value (unexpected end of data)");
- }
- // final terminating "
- if(data[pos] == '"')
- {
- result += data[pos];
- ++pos;
- break;
- }
- // any character except '\'
- else if(data[pos] != '\\')
- {
- result += data[pos];
- ++pos;
- }
- // pair '\'
- else
- {
- result += parsePair(data, pos);
- }
- }
+ result += data[pos];
+ ++pos;
+ while(true)
+ {
+ if(pos >= data.size())
+ {
+ throw ParseException(__FILE__, __LINE__, "invalid attribute value (unexpected end of data)");
+ }
+ // final terminating "
+ if(data[pos] == '"')
+ {
+ result += data[pos];
+ ++pos;
+ break;
+ }
+ // any character except '\'
+ else if(data[pos] != '\\')
+ {
+ result += data[pos];
+ ++pos;
+ }
+ // pair '\'
+ else
+ {
+ result += parsePair(data, pos);
+ }
+ }
}
//
// RFC 2253
@@ -380,22 +380,22 @@ parseAttributeValue(const string& data, size_t& pos)
//
else
{
- while(pos < data.size())
- {
- if(data[pos] == '\\')
- {
- result += parsePair(data, pos);
- }
- else if(special.find(data[pos]) == string::npos && data[pos] != '"')
- {
- result += data[pos];
- ++pos;
- }
- else
- {
- break;
- }
- }
+ while(pos < data.size())
+ {
+ if(data[pos] == '\\')
+ {
+ result += parsePair(data, pos);
+ }
+ else if(special.find(data[pos]) == string::npos && data[pos] != '"')
+ {
+ result += data[pos];
+ ++pos;
+ }
+ else
+ {
+ break;
+ }
+ }
}
return result;
}
@@ -415,14 +415,14 @@ parsePair(const string& data, size_t& pos)
if(pos >= data.size())
{
- throw ParseException(__FILE__, __LINE__, "invalid escape format (unexpected end of data)");
+ throw ParseException(__FILE__, __LINE__, "invalid escape format (unexpected end of data)");
}
if(special.find(data[pos]) != string::npos || data[pos] != '\\' || data[pos] != '"')
{
- result += data[pos];
- ++pos;
- return result;
+ result += data[pos];
+ ++pos;
+ return result;
}
return parseHexPair(data, pos, false);
}
@@ -437,21 +437,21 @@ parseHexPair(const string& data, size_t& pos, bool allowEmpty)
string result;
if(pos < data.size() && hexvalid.find(data[pos]) != string::npos)
{
- result += data[pos];
- ++pos;
+ result += data[pos];
+ ++pos;
}
if(pos < data.size() && hexvalid.find(data[pos]) != string::npos)
{
- result += data[pos];
- ++pos;
+ result += data[pos];
+ ++pos;
}
if(result.size() != 2)
{
- if(allowEmpty && result.size() == 0)
- {
- return result;
- }
- throw ParseException(__FILE__, __LINE__, "invalid hex format");
+ if(allowEmpty && result.size() == 0)
+ {
+ return result;
+ }
+ throw ParseException(__FILE__, __LINE__, "invalid hex format");
}
return result;
}
@@ -469,7 +469,7 @@ eatWhite(const string& data, size_t& pos)
{
while(pos < data.size() && data[pos] == ' ')
{
- ++pos;
+ ++pos;
}
}
@@ -479,16 +479,16 @@ print(const list< list<pair<string, string> > >& r)
{
if(r.size() > 1)
{
- cout << "result: " << r.size() << " DNs" << endl;
+ cout << "result: " << r.size() << " DNs" << endl;
}
for(list< list<pair<string, string> > >::const_iterator q = r.begin(); q != r.end(); ++q)
{
- list<pair<string, string> > l = *q;
- cout << "result: " << l.size() << " RDNs" << endl;
- for(list<pair<string, string> >::const_iterator p = l.begin(); p != l.end(); ++p)
- {
- cout << "\t\"" << p->first << "\"=\"" << p->second << "\"" << endl;
- }
+ list<pair<string, string> > l = *q;
+ cout << "result: " << l.size() << " RDNs" << endl;
+ for(list<pair<string, string> >::const_iterator p = l.begin(); p != l.end(); ++p)
+ {
+ cout << "\t\"" << p->first << "\"=\"" << p->second << "\"" << endl;
+ }
}
}
@@ -496,24 +496,24 @@ int
main()
{
string examples[] = {
- "CN=Steve Kille,O=Isode Limited,C=GB",
- "OU=Sales+CN=J. Smith,O=Widget Inc.,C=US",
- "CN=L. Eagle,O=Sue\\, Grabbit and Runn,C=GB",
- "CN=Before\\0DAfter,O=Test,C=GB",
- "1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB",
- "SN=Lu\\C4\\8Di\\C4\\87",
+ "CN=Steve Kille,O=Isode Limited,C=GB",
+ "OU=Sales+CN=J. Smith,O=Widget Inc.,C=US",
+ "CN=L. Eagle,O=Sue\\, Grabbit and Runn,C=GB",
+ "CN=Before\\0DAfter,O=Test,C=GB",
+ "1.3.6.1.4.1.1466.0=#04024869,O=Test,C=GB",
+ "SN=Lu\\C4\\8Di\\C4\\87",
};
try
{
- for(int i = 0; i < sizeof(examples)/sizeof(examples[0]); ++i)
- {
- cout << "string: " << examples[i] << endl;
- print(RFC2253::parse(examples[i]));
- }
+ for(int i = 0; i < sizeof(examples)/sizeof(examples[0]); ++i)
+ {
+ cout << "string: " << examples[i] << endl;
+ print(RFC2253::parse(examples[i]));
+ }
}
catch(const RFC2253::ParseException& e)
{
- cout << "error: " << e.reason << endl;
+ cout << "error: " << e.reason << endl;
}
}
#endif
diff --git a/cpp/src/IceSSL/TrustManager.cpp b/cpp/src/IceSSL/TrustManager.cpp
index f505cca8e37..5e620615fe9 100644
--- a/cpp/src/IceSSL/TrustManager.cpp
+++ b/cpp/src/IceSSL/TrustManager.cpp
@@ -31,25 +31,25 @@ TrustManager::TrustManager(const Ice::CommunicatorPtr& communicator) :
string key;
try
{
- key = "IceSSL.TrustOnly";
- _all = parse(properties->getProperty(key));
- key = "IceSSL.TrustOnly.Client";
- _client = parse(properties->getProperty(key));
- key = "IceSSL.TrustOnly.Server";
- _allServer = parse(properties->getProperty(key));
- Ice::PropertyDict dict = properties->getPropertiesForPrefix("IceSSL.TrustOnly.Server.");
- for(Ice::PropertyDict::const_iterator p = dict.begin(); p != dict.end(); ++p)
- {
- string name = p->first.substr(string("IceSSL.TrustOnly.Server.").size());
- key = p->first;
- _server[name] = parse(p->second);
- }
+ key = "IceSSL.TrustOnly";
+ _all = parse(properties->getProperty(key));
+ key = "IceSSL.TrustOnly.Client";
+ _client = parse(properties->getProperty(key));
+ key = "IceSSL.TrustOnly.Server";
+ _allServer = parse(properties->getProperty(key));
+ Ice::PropertyDict dict = properties->getPropertiesForPrefix("IceSSL.TrustOnly.Server.");
+ for(Ice::PropertyDict::const_iterator p = dict.begin(); p != dict.end(); ++p)
+ {
+ string name = p->first.substr(string("IceSSL.TrustOnly.Server.").size());
+ key = p->first;
+ _server[name] = parse(p->second);
+ }
}
catch(const ParseException& e)
{
- Ice::PluginInitializationException ex(__FILE__, __LINE__);
- ex.reason = "IceSSL: invalid property " + key + ":\n" + e.reason;
- throw ex;
+ Ice::PluginInitializationException ex(__FILE__, __LINE__);
+ ex.reason = "IceSSL: invalid property " + key + ":\n" + e.reason;
+ throw ex;
}
}
@@ -59,30 +59,30 @@ TrustManager::verify(const ConnectionInfo& info)
list<list<DistinguishedName> > trustset;
if(_all.size() > 0)
{
- trustset.push_back(_all);
+ trustset.push_back(_all);
}
if(info.incoming)
{
- if(_allServer.size() > 0)
- {
- trustset.push_back(_allServer);
- }
- if(info.adapterName.size() > 0)
- {
- map<string, list<DistinguishedName> >::const_iterator p = _server.find(info.adapterName);
- if(p != _server.end())
- {
- trustset.push_back(p->second);
- }
- }
+ if(_allServer.size() > 0)
+ {
+ trustset.push_back(_allServer);
+ }
+ if(info.adapterName.size() > 0)
+ {
+ map<string, list<DistinguishedName> >::const_iterator p = _server.find(info.adapterName);
+ if(p != _server.end())
+ {
+ trustset.push_back(p->second);
+ }
+ }
}
else
{
- if(_client.size() > 0)
- {
- trustset.push_back(_client);
- }
+ if(_client.size() > 0)
+ {
+ trustset.push_back(_client);
+ }
}
//
@@ -90,7 +90,7 @@ TrustManager::verify(const ConnectionInfo& info)
//
if(trustset.size() == 0)
{
- return true;
+ return true;
}
//
@@ -98,50 +98,50 @@ TrustManager::verify(const ConnectionInfo& info)
//
if(info.certs.size() != 0)
{
- DistinguishedName subject = info.certs[0]->getSubjectDN();
- if(_traceLevel > 0)
- {
- Ice::Trace trace(_communicator->getLogger(), "Security");
- if(info.incoming)
- {
- trace << "trust manager evaluating client:\n"
- << "subject = " << string(subject) << '\n'
- << "adapter = " << info.adapterName << '\n'
- << "local addr = " << IceInternal::addrToString(info.localAddr) << '\n'
- << "remote addr = " << IceInternal::addrToString(info.remoteAddr);
- }
- else
- {
- trace << "trust manager evaluating server:\n"
- << "subject = " << string(subject) << '\n'
- << "local addr = " << IceInternal::addrToString(info.localAddr) << '\n'
- << "remote addr = " << IceInternal::addrToString(info.remoteAddr);
- }
- }
-
- //
- // Try matching against everything in the trust set.
- //
- for(list<list<DistinguishedName> >::const_iterator p = trustset.begin(); p != trustset.end(); ++p)
- {
- if(_traceLevel > 1)
- {
- Ice::Trace trace(_communicator->getLogger(), "Security");
- trace << "trust manager matching PDNs:\n";
- for(list<DistinguishedName>::const_iterator r = p->begin(); r != p->end(); ++r)
- {
- if(r != p->begin())
- {
- trace << ';';
- }
- trace << string(*r);
- }
- }
- if(match(*p, subject))
- {
- return true;
- }
- }
+ DistinguishedName subject = info.certs[0]->getSubjectDN();
+ if(_traceLevel > 0)
+ {
+ Ice::Trace trace(_communicator->getLogger(), "Security");
+ if(info.incoming)
+ {
+ trace << "trust manager evaluating client:\n"
+ << "subject = " << string(subject) << '\n'
+ << "adapter = " << info.adapterName << '\n'
+ << "local addr = " << IceInternal::addrToString(info.localAddr) << '\n'
+ << "remote addr = " << IceInternal::addrToString(info.remoteAddr);
+ }
+ else
+ {
+ trace << "trust manager evaluating server:\n"
+ << "subject = " << string(subject) << '\n'
+ << "local addr = " << IceInternal::addrToString(info.localAddr) << '\n'
+ << "remote addr = " << IceInternal::addrToString(info.remoteAddr);
+ }
+ }
+
+ //
+ // Try matching against everything in the trust set.
+ //
+ for(list<list<DistinguishedName> >::const_iterator p = trustset.begin(); p != trustset.end(); ++p)
+ {
+ if(_traceLevel > 1)
+ {
+ Ice::Trace trace(_communicator->getLogger(), "Security");
+ trace << "trust manager matching PDNs:\n";
+ for(list<DistinguishedName>::const_iterator r = p->begin(); r != p->end(); ++r)
+ {
+ if(r != p->begin())
+ {
+ trace << ';';
+ }
+ trace << string(*r);
+ }
+ }
+ if(match(*p, subject))
+ {
+ return true;
+ }
+ }
}
return false;
@@ -152,10 +152,10 @@ TrustManager::match(const list< DistinguishedName>& matchSet, const Distinguishe
{
for(list<DistinguishedName>::const_iterator r = matchSet.begin(); r != matchSet.end(); ++r)
{
- if(subject.match(*r))
- {
- return true;
- }
+ if(subject.match(*r))
+ {
+ return true;
+ }
}
return false;
}
@@ -166,11 +166,11 @@ TrustManager::parse(const string& value) const
list<DistinguishedName> result;
if(!value.empty())
{
- RFC2253::RDNSeqSeq dns = RFC2253::parse(value);
- for(RFC2253::RDNSeqSeq::const_iterator p = dns.begin(); p != dns.end(); ++p)
- {
- result.push_back(DistinguishedName(*p));
- }
+ RFC2253::RDNSeqSeq dns = RFC2253::parse(value);
+ for(RFC2253::RDNSeqSeq::const_iterator p = dns.begin(); p != dns.end(); ++p)
+ {
+ result.push_back(DistinguishedName(*p));
+ }
}
return result;
}
diff --git a/cpp/src/IceSSL/Util.cpp b/cpp/src/IceSSL/Util.cpp
index 1754bd62654..9adf539fac3 100644
--- a/cpp/src/IceSSL/Util.cpp
+++ b/cpp/src/IceSSL/Util.cpp
@@ -184,7 +184,7 @@ IceSSL::DHParams::~DHParams()
ParamList::iterator p;
for(p = _params.begin(); p != _params.end(); ++p)
{
- DH_free(p->second);
+ DH_free(p->second);
}
DH_free(_dh512);
DH_free(_dh1024);
@@ -198,19 +198,19 @@ IceSSL::DHParams::add(int keyLength, const string& file)
BIO* bio = BIO_new(BIO_s_file());
if(BIO_read_filename(bio, file.c_str()) <= 0)
{
- BIO_free(bio);
- return false;
+ BIO_free(bio);
+ return false;
}
DH* dh = PEM_read_bio_DHparams(bio, 0, 0, 0);
BIO_free(bio);
if(!dh)
{
- return false;
+ return false;
}
ParamList::iterator p = _params.begin();
while(p != _params.end() && keyLength > p->first)
{
- ++p;
+ ++p;
}
_params.insert(p, KeyParamPair(keyLength, dh));
return true;
@@ -226,10 +226,10 @@ IceSSL::DHParams::get(int keyLength)
ParamList::iterator p;
for(p = _params.begin(); p != _params.end(); ++p)
{
- if(p->first >= keyLength)
- {
- return p->second;
- }
+ if(p->first >= keyLength)
+ {
+ return p->second;
+ }
}
//
@@ -239,35 +239,35 @@ IceSSL::DHParams::get(int keyLength)
if(keyLength >= 4096)
{
- if(!_dh4096)
- {
- _dh4096 = convertDH(dh4096_p, (int) sizeof(dh4096_p), dh4096_g, (int) sizeof(dh4096_g));
- }
- return _dh4096;
+ if(!_dh4096)
+ {
+ _dh4096 = convertDH(dh4096_p, (int) sizeof(dh4096_p), dh4096_g, (int) sizeof(dh4096_g));
+ }
+ return _dh4096;
}
else if(keyLength >= 2048)
{
- if(!_dh2048)
- {
- _dh2048 = convertDH(dh2048_p, (int) sizeof(dh2048_p), dh2048_g, (int) sizeof(dh2048_g));
- }
- return _dh2048;
+ if(!_dh2048)
+ {
+ _dh2048 = convertDH(dh2048_p, (int) sizeof(dh2048_p), dh2048_g, (int) sizeof(dh2048_g));
+ }
+ return _dh2048;
}
else if(keyLength >= 1024)
{
- if(!_dh1024)
- {
- _dh1024 = convertDH(dh1024_p, (int) sizeof(dh1024_p), dh1024_g, (int) sizeof(dh1024_g));
- }
- return _dh1024;
+ if(!_dh1024)
+ {
+ _dh1024 = convertDH(dh1024_p, (int) sizeof(dh1024_p), dh1024_g, (int) sizeof(dh1024_g));
+ }
+ return _dh1024;
}
else
{
- if(!_dh512)
- {
- _dh512 = convertDH(dh512_p, (int) sizeof(dh512_p), dh512_g, (int) sizeof(dh512_g));
- }
- return _dh512;
+ if(!_dh512)
+ {
+ _dh512 = convertDH(dh512_p, (int) sizeof(dh512_p), dh512_g, (int) sizeof(dh512_g));
+ }
+ return _dh512;
}
}
@@ -282,11 +282,11 @@ selectReadWrite(SOCKET fd, bool read, int timeout)
FD_ZERO(&wFdSet);
if(read)
{
- FD_SET(fd, &rFdSet);
+ FD_SET(fd, &rFdSet);
}
else
{
- FD_SET(fd, &wFdSet);
+ FD_SET(fd, &wFdSet);
}
#else
struct pollfd pollfd[1];
@@ -299,14 +299,14 @@ repeatSelect:
#ifdef _WIN32
if(timeout >= 0)
{
- struct timeval tv;
- tv.tv_sec = timeout / 1000;
- tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000;
- ret = ::select(static_cast<int>(fd) + 1, &rFdSet, &wFdSet, 0, &tv);
+ struct timeval tv;
+ tv.tv_sec = timeout / 1000;
+ tv.tv_usec = (timeout - tv.tv_sec * 1000) * 1000;
+ ret = ::select(static_cast<int>(fd) + 1, &rFdSet, &wFdSet, 0, &tv);
}
else
{
- ret = ::select(static_cast<int>(fd) + 1, &rFdSet, &wFdSet, 0, 0);
+ ret = ::select(static_cast<int>(fd) + 1, &rFdSet, &wFdSet, 0, 0);
}
#else
ret = ::poll(pollfd, 1, timeout);
@@ -314,18 +314,18 @@ repeatSelect:
if(ret == 0)
{
- return false; // Timeout.
+ return false; // Timeout.
}
else if(ret == SOCKET_ERROR)
{
- if(IceInternal::interrupted())
- {
- goto repeatSelect;
- }
-
- SocketException ex(__FILE__, __LINE__);
- ex.error = IceInternal::getSocketErrno();
- throw ex;
+ if(IceInternal::interrupted())
+ {
+ goto repeatSelect;
+ }
+
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = IceInternal::getSocketErrno();
+ throw ex;
}
return true;
@@ -349,56 +349,56 @@ IceSSL::splitString(const string& str, const string& delim, bool handleQuotes, v
string::size_type pos = str.find_first_not_of(delim + " \t");
if(pos == string::npos)
{
- return true;
+ return true;
}
string::value_type quoteChar = 0;
while(pos != string::npos)
{
- if(handleQuotes && (str[pos] == '"' || str[pos] == '\''))
- {
- quoteChar = str[pos];
- ++pos;
- }
-
- string val;
- while(pos < str.size())
- {
- if((!handleQuotes || !quoteChar) && delim.find(str[pos]) != string::npos)
- {
- break;
- }
- if(handleQuotes)
- {
- if(str[pos] == '\\')
- {
- if(pos + 1 < str.size() && str[pos + 1] == quoteChar)
- {
- ++pos;
- }
- }
- else if(str[pos] == quoteChar)
- {
- quoteChar = 0;
- ++pos;
- continue;
- }
- }
- val.push_back(str[pos]);
- ++pos;
- }
-
- if(!val.empty())
- {
- result.push_back(val);
- }
-
- pos = str.find_first_not_of(delim, pos);
+ if(handleQuotes && (str[pos] == '"' || str[pos] == '\''))
+ {
+ quoteChar = str[pos];
+ ++pos;
+ }
+
+ string val;
+ while(pos < str.size())
+ {
+ if((!handleQuotes || !quoteChar) && delim.find(str[pos]) != string::npos)
+ {
+ break;
+ }
+ if(handleQuotes)
+ {
+ if(str[pos] == '\\')
+ {
+ if(pos + 1 < str.size() && str[pos + 1] == quoteChar)
+ {
+ ++pos;
+ }
+ }
+ else if(str[pos] == quoteChar)
+ {
+ quoteChar = 0;
+ ++pos;
+ continue;
+ }
+ }
+ val.push_back(str[pos]);
+ ++pos;
+ }
+
+ if(!val.empty())
+ {
+ result.push_back(val);
+ }
+
+ pos = str.find_first_not_of(delim, pos);
}
if(quoteChar) // Mismatched quote.
{
- return false;
+ return false;
}
return true;
@@ -422,23 +422,23 @@ IceSSL::checkPath(string& path, const string& defaultDir, bool dir)
#endif
if(err == 0)
{
- return dir ? S_ISDIR(st.st_mode) != 0 : S_ISREG(st.st_mode) != 0;
+ return dir ? S_ISDIR(st.st_mode) != 0 : S_ISREG(st.st_mode) != 0;
}
if(!defaultDir.empty())
{
#ifdef _WIN32
- string s = defaultDir + "\\" + path;
- err = ::_stat(s.c_str(), &st);
+ string s = defaultDir + "\\" + path;
+ err = ::_stat(s.c_str(), &st);
#else
- string s = defaultDir + "/" + path;
- err = ::stat(s.c_str(), &st);
+ string s = defaultDir + "/" + path;
+ err = ::stat(s.c_str(), &st);
#endif
- if(err == 0 && ((!dir && S_ISREG(st.st_mode)) || (dir && S_ISDIR(st.st_mode))))
- {
- path = s;
- return true;
- }
+ if(err == 0 && ((!dir && S_ISREG(st.st_mode)) || (dir && S_ISDIR(st.st_mode))))
+ {
+ path = s;
+ return true;
+ }
}
return false;
@@ -465,23 +465,23 @@ IceSSL::populateConnectionInfo(SSL* ssl, SOCKET fd, const string& adapterName, b
STACK_OF(X509)* chain = SSL_get_peer_cert_chain(ssl);
if(cert != 0 && (chain == 0 || sk_X509_num(chain) == 0 || cert != sk_X509_value(chain, 0)))
{
- info.certs.push_back(new Certificate(cert));
+ info.certs.push_back(new Certificate(cert));
}
else
{
- X509_free(cert);
+ X509_free(cert);
}
if(chain != 0)
{
- for(int i = 0; i < sk_X509_num(chain); ++i)
- {
- X509* cert = sk_X509_value(chain, i);
- //
- // Duplicate the certificate since the stack comes straight from the SSL connection.
- //
- info.certs.push_back(new Certificate(X509_dup(cert)));
- }
+ for(int i = 0; i < sk_X509_num(chain); ++i)
+ {
+ X509* cert = sk_X509_value(chain, i);
+ //
+ // Duplicate the certificate since the stack comes straight from the SSL connection.
+ //
+ info.certs.push_back(new Certificate(X509_dup(cert)));
+ }
}
info.cipher = SSL_get_cipher_name(ssl); // Nothing needs to be free'd.
@@ -490,9 +490,9 @@ IceSSL::populateConnectionInfo(SSL* ssl, SOCKET fd, const string& adapterName, b
if(!IceInternal::fdToRemoteAddress(fd, info.remoteAddr))
{
- SocketException ex(__FILE__, __LINE__);
- ex.error = IceInternal::getSocketErrno();
- throw ex;
+ SocketException ex(__FILE__, __LINE__);
+ ex.error = IceInternal::getSocketErrno();
+ throw ex;
}
return info;
@@ -511,41 +511,41 @@ IceSSL::getSslErrors(bool verbose)
int count = 0;
while((err = ERR_get_error_line_data(&file, &line, &data, &flags)) != 0)
{
- if(count > 0)
- {
- ostr << endl;
- }
-
- if(verbose)
- {
- if(count > 0)
- {
- ostr << endl;
- }
-
- char buf[200];
- ERR_error_string_n(err, buf, sizeof(buf));
-
- ostr << "error # = " << err << endl;
- ostr << "message = " << buf << endl;
- ostr << "location = " << file << ", " << line;
- if(flags & ERR_TXT_STRING)
- {
- ostr << endl;
- ostr << "data = " << data;
- }
- }
- else
- {
- const char* reason = ERR_reason_error_string(err);
- ostr << (reason == NULL ? "unknown reason" : reason);
- if(flags & ERR_TXT_STRING)
- {
- ostr << ": " << data;
- }
- }
-
- ++count;
+ if(count > 0)
+ {
+ ostr << endl;
+ }
+
+ if(verbose)
+ {
+ if(count > 0)
+ {
+ ostr << endl;
+ }
+
+ char buf[200];
+ ERR_error_string_n(err, buf, sizeof(buf));
+
+ ostr << "error # = " << err << endl;
+ ostr << "message = " << buf << endl;
+ ostr << "location = " << file << ", " << line;
+ if(flags & ERR_TXT_STRING)
+ {
+ ostr << endl;
+ ostr << "data = " << data;
+ }
+ }
+ else
+ {
+ const char* reason = ERR_reason_error_string(err);
+ ostr << (reason == NULL ? "unknown reason" : reason);
+ if(flags & ERR_TXT_STRING)
+ {
+ ostr << ": " << data;
+ }
+ }
+
+ ++count;
}
ERR_clear_error();
diff --git a/cpp/src/IceStorm/Admin.cpp b/cpp/src/IceStorm/Admin.cpp
index bd175b818d3..62ab8958c0a 100644
--- a/cpp/src/IceStorm/Admin.cpp
+++ b/cpp/src/IceStorm/Admin.cpp
@@ -39,17 +39,17 @@ void
Client::usage()
{
cerr << "Usage: " << appName() << " [options] [file...]\n";
- cerr <<
- "Options:\n"
- "-h, --help Show this message.\n"
- "-v, --version Display the Ice version.\n"
- "-DNAME Define NAME as 1.\n"
- "-DNAME=DEF Define NAME as DEF.\n"
- "-UNAME Remove any definition for NAME.\n"
- "-IDIR Put DIR in the include file search path.\n"
- "-e COMMANDS Execute COMMANDS.\n"
- "-d, --debug Print debug messages.\n"
- ;
+ cerr <<
+ "Options:\n"
+ "-h, --help Show this message.\n"
+ "-v, --version Display the Ice version.\n"
+ "-DNAME Define NAME as 1.\n"
+ "-DNAME=DEF Define NAME as DEF.\n"
+ "-UNAME Remove any definition for NAME.\n"
+ "-IDIR Put DIR in the include file search path.\n"
+ "-e COMMANDS Execute COMMANDS.\n"
+ "-d, --debug Print debug messages.\n"
+ ;
}
int
@@ -71,64 +71,64 @@ Client::run(int argc, char* argv[])
vector<string> args;
try
{
- args = opts.parse(argc, (const char**)argv);
+ args = opts.parse(argc, (const char**)argv);
}
catch(const IceUtil::BadOptException& e)
{
cerr << e.reason << endl;
- usage();
- return EXIT_FAILURE;
+ usage();
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage();
- return EXIT_SUCCESS;
+ usage();
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
if(opts.isSet("D"))
{
- vector<string> optargs = opts.argVec("D");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- cpp += " -D" + *i;
- }
+ vector<string> optargs = opts.argVec("D");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ cpp += " -D" + *i;
+ }
}
if(opts.isSet("U"))
{
- vector<string> optargs = opts.argVec("U");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- cpp += " -U" + *i;
- }
+ vector<string> optargs = opts.argVec("U");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ cpp += " -U" + *i;
+ }
}
if(opts.isSet("I"))
{
- vector<string> optargs = opts.argVec("I");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- cpp += " -I" + *i;
- }
+ vector<string> optargs = opts.argVec("I");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ cpp += " -I" + *i;
+ }
}
if(opts.isSet("e"))
{
- vector<string> optargs = opts.argVec("e");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- commands += *i + ";";
- }
+ vector<string> optargs = opts.argVec("e");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ commands += *i + ";";
+ }
}
debug = opts.isSet("debug");
if(!args.empty() && !commands.empty())
{
- cerr << appName() << ": `-e' option cannot be used if input files are given" << endl;
- usage();
- return EXIT_FAILURE;
+ cerr << appName() << ": `-e' option cannot be used if input files are given" << endl;
+ usage();
+ return EXIT_FAILURE;
}
// The complete set of Ice::Identity -> manager proxies.
@@ -141,14 +141,14 @@ Client::run(int argc, char* argv[])
IceStorm::TopicManagerPrx defaultManager;
if(!managerProxy.empty())
{
- defaultManager = IceStorm::TopicManagerPrx::checkedCast(communicator()->stringToProxy(managerProxy));
- if(!defaultManager)
- {
- cerr << appName() << ": `" << managerProxy << "' is not running" << endl;
- return EXIT_FAILURE;
- }
- managers.insert(map<Ice::Identity, IceStorm::TopicManagerPrx>::value_type(
- defaultManager->ice_getIdentity(), defaultManager));
+ defaultManager = IceStorm::TopicManagerPrx::checkedCast(communicator()->stringToProxy(managerProxy));
+ if(!defaultManager)
+ {
+ cerr << appName() << ": `" << managerProxy << "' is not running" << endl;
+ return EXIT_FAILURE;
+ }
+ managers.insert(map<Ice::Identity, IceStorm::TopicManagerPrx>::value_type(
+ defaultManager->ice_getIdentity(), defaultManager));
}
//
@@ -156,134 +156,134 @@ Client::run(int argc, char* argv[])
//
Ice::PropertyDict props = communicator()->getProperties()->getPropertiesForPrefix("IceStormAdmin.TopicManager.");
{
- for(Ice::PropertyDict::const_iterator p = props.begin(); p != props.end(); ++p)
- {
- try
- {
- IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::uncheckedCast(
- communicator()->stringToProxy(p->second));
- managers.insert(map<Ice::Identity, IceStorm::TopicManagerPrx>::value_type(
- manager->ice_getIdentity(), manager));
- }
- catch(const Ice::ProxyParseException&)
- {
- cerr << appName() << ": malformed proxy: " << p->second << endl;
- return EXIT_FAILURE;
- }
- }
- if(props.empty() && !defaultManager)
- {
- cerr << appName() << ": no manager proxies configured" << endl;
- return EXIT_FAILURE;
- }
+ for(Ice::PropertyDict::const_iterator p = props.begin(); p != props.end(); ++p)
+ {
+ try
+ {
+ IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::uncheckedCast(
+ communicator()->stringToProxy(p->second));
+ managers.insert(map<Ice::Identity, IceStorm::TopicManagerPrx>::value_type(
+ manager->ice_getIdentity(), manager));
+ }
+ catch(const Ice::ProxyParseException&)
+ {
+ cerr << appName() << ": malformed proxy: " << p->second << endl;
+ return EXIT_FAILURE;
+ }
+ }
+ if(props.empty() && !defaultManager)
+ {
+ cerr << appName() << ": no manager proxies configured" << endl;
+ return EXIT_FAILURE;
+ }
- if(!defaultManager)
- {
- string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default");
- if(!managerProxy.empty())
- {
- defaultManager = IceStorm::TopicManagerPrx::uncheckedCast(
- communicator()->stringToProxy(managerProxy));
- }
- else
- {
- defaultManager = managers.begin()->second;
- }
- }
+ if(!defaultManager)
+ {
+ string managerProxy = properties->getProperty("IceStormAdmin.TopicManager.Default");
+ if(!managerProxy.empty())
+ {
+ defaultManager = IceStorm::TopicManagerPrx::uncheckedCast(
+ communicator()->stringToProxy(managerProxy));
+ }
+ else
+ {
+ defaultManager = managers.begin()->second;
+ }
+ }
}
// Check slice checksums for each manager.
{
- for(map<Ice::Identity, IceStorm::TopicManagerPrx>::const_iterator p = managers.begin(); p != managers.end();
- ++p)
- {
- try
- {
- Ice::SliceChecksumDict serverChecksums = p->second->getSliceChecksums();
- Ice::SliceChecksumDict localChecksums = Ice::sliceChecksums();
- for(Ice::SliceChecksumDict::const_iterator q = localChecksums.begin(); q != localChecksums.end(); ++q)
- {
- Ice::SliceChecksumDict::const_iterator r = serverChecksums.find(q->first);
- if(r == serverChecksums.end())
- {
- cerr << appName() << ": " << communicator()->identityToString(p->first)
- << " is using unknown Slice type `" << q->first << "'" << endl;
- }
- else if(q->second != r->second)
- {
- cerr << appName() << ": " << communicator()->identityToString(p->first)
- << " is using a different Slice definition of `" << q->first << "'" << endl;
- }
- }
- }
- catch(const Ice::Exception& ex)
- {
- cerr << communicator()->identityToString(p->first) << ": " << ex << endl;
- }
- }
+ for(map<Ice::Identity, IceStorm::TopicManagerPrx>::const_iterator p = managers.begin(); p != managers.end();
+ ++p)
+ {
+ try
+ {
+ Ice::SliceChecksumDict serverChecksums = p->second->getSliceChecksums();
+ Ice::SliceChecksumDict localChecksums = Ice::sliceChecksums();
+ for(Ice::SliceChecksumDict::const_iterator q = localChecksums.begin(); q != localChecksums.end(); ++q)
+ {
+ Ice::SliceChecksumDict::const_iterator r = serverChecksums.find(q->first);
+ if(r == serverChecksums.end())
+ {
+ cerr << appName() << ": " << communicator()->identityToString(p->first)
+ << " is using unknown Slice type `" << q->first << "'" << endl;
+ }
+ else if(q->second != r->second)
+ {
+ cerr << appName() << ": " << communicator()->identityToString(p->first)
+ << " is using a different Slice definition of `" << q->first << "'" << endl;
+ }
+ }
+ }
+ catch(const Ice::Exception& ex)
+ {
+ cerr << communicator()->identityToString(p->first) << ": " << ex << endl;
+ }
+ }
}
-
+
ParserPtr p = Parser::createParser(communicator(), defaultManager, managers);
int status = EXIT_SUCCESS;
if(args.empty()) // No files given
{
- if(!commands.empty()) // Commands were given
- {
- int parseStatus = p->parse(commands, debug);
- if(parseStatus == EXIT_FAILURE)
- {
- status = EXIT_FAILURE;
- }
- }
- else // No commands, let's use standard input
- {
- p->showBanner();
+ if(!commands.empty()) // Commands were given
+ {
+ int parseStatus = p->parse(commands, debug);
+ if(parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
+ }
+ else // No commands, let's use standard input
+ {
+ p->showBanner();
- int parseStatus = p->parse(stdin, debug);
- if(parseStatus == EXIT_FAILURE)
- {
- status = EXIT_FAILURE;
- }
- }
+ int parseStatus = p->parse(stdin, debug);
+ if(parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
+ }
}
else // Process files given on the command line
{
- for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i)
- {
- ifstream test(i->c_str());
- if(!test)
- {
- cerr << appName() << ": can't open `" << *i << "' for reading: " << strerror(errno) << endl;
- return EXIT_FAILURE;
- }
- test.close();
-
- string cmd = cpp + " " + *i;
+ for(vector<string>::const_iterator i = args.begin(); i != args.end(); ++i)
+ {
+ ifstream test(i->c_str());
+ if(!test)
+ {
+ cerr << appName() << ": can't open `" << *i << "' for reading: " << strerror(errno) << endl;
+ return EXIT_FAILURE;
+ }
+ test.close();
+
+ string cmd = cpp + " " + *i;
#ifdef _WIN32
- FILE* cppHandle = _popen(cmd.c_str(), "r");
+ FILE* cppHandle = _popen(cmd.c_str(), "r");
#else
- FILE* cppHandle = popen(cmd.c_str(), "r");
+ FILE* cppHandle = popen(cmd.c_str(), "r");
#endif
- if(cppHandle == NULL)
- {
- cerr << appName() << ": can't run C++ preprocessor: " << strerror(errno) << endl;
- return EXIT_FAILURE;
- }
-
- int parseStatus = p->parse(cppHandle, debug);
-
+ if(cppHandle == NULL)
+ {
+ cerr << appName() << ": can't run C++ preprocessor: " << strerror(errno) << endl;
+ return EXIT_FAILURE;
+ }
+
+ int parseStatus = p->parse(cppHandle, debug);
+
#ifdef _WIN32
- _pclose(cppHandle);
+ _pclose(cppHandle);
#else
- pclose(cppHandle);
+ pclose(cppHandle);
#endif
- if(parseStatus == EXIT_FAILURE)
- {
- status = EXIT_FAILURE;
- }
- }
+ if(parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
+ }
}
return status;
diff --git a/cpp/src/IceStorm/BatchFlusher.cpp b/cpp/src/IceStorm/BatchFlusher.cpp
index 699a145db87..d38c93ea649 100644
--- a/cpp/src/IceStorm/BatchFlusher.cpp
+++ b/cpp/src/IceStorm/BatchFlusher.cpp
@@ -24,8 +24,8 @@ using namespace std;
BatchFlusher::BatchFlusher(const InstancePtr& instance) :
_traceLevels(instance->traceLevels()),
_flushTime(IceUtil::Time::milliSeconds(
- max(instance->properties()->getPropertyAsIntWithDefault(
- "IceStorm.Flush.Timeout", 1000), 100))), // Minimum of 100ms.
+ max(instance->properties()->getPropertyAsIntWithDefault(
+ "IceStorm.Flush.Timeout", 1000), 100))), // Minimum of 100ms.
_destroy(false)
{
start();
@@ -45,7 +45,7 @@ BatchFlusher::add(const Ice::ObjectPrx& subscriber)
//
if(_subscribers.empty())
{
- notify();
+ notify();
}
_subscribers.push_back(subscriber);
}
@@ -70,58 +70,58 @@ BatchFlusher::run()
{
for(;;)
{
- list<Ice::ObjectPrx> subscribers;
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- if(_destroy)
- {
- return;
- }
- if(_subscribers.empty())
- {
- wait();
- }
- else
- {
- timedWait(_flushTime);
- }
- if(_destroy)
- {
- return;
- }
- subscribers = _subscribers;
- }
+ list<Ice::ObjectPrx> subscribers;
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ if(_destroy)
+ {
+ return;
+ }
+ if(_subscribers.empty())
+ {
+ wait();
+ }
+ else
+ {
+ timedWait(_flushTime);
+ }
+ if(_destroy)
+ {
+ return;
+ }
+ subscribers = _subscribers;
+ }
- set<Ice::ConnectionPtr> flushSet;
- for(list<Ice::ObjectPrx>::const_iterator p = subscribers.begin(); p != subscribers.end(); ++p)
- {
- Ice::ConnectionPtr connection = (*p)->ice_getCachedConnection();
- if(connection)
- {
- flushSet.insert(connection);
- }
- }
-
- for(set<Ice::ConnectionPtr>::const_iterator q = flushSet.begin(); q != flushSet.end(); ++q)
- {
- try
- {
- (*q)->flushBatchRequests();
- }
- catch(const Ice::LocalException&)
- {
- // Ignore.
- }
- }
-
- //
- // Trace after the flush so that the correct number of objects
- // are displayed
- //
- if(_traceLevels->flush > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->flushCat);
- out << "connections: " << flushSet.size() << " subscribers: " << subscribers.size();
- }
+ set<Ice::ConnectionPtr> flushSet;
+ for(list<Ice::ObjectPrx>::const_iterator p = subscribers.begin(); p != subscribers.end(); ++p)
+ {
+ Ice::ConnectionPtr connection = (*p)->ice_getCachedConnection();
+ if(connection)
+ {
+ flushSet.insert(connection);
+ }
+ }
+
+ for(set<Ice::ConnectionPtr>::const_iterator q = flushSet.begin(); q != flushSet.end(); ++q)
+ {
+ try
+ {
+ (*q)->flushBatchRequests();
+ }
+ catch(const Ice::LocalException&)
+ {
+ // Ignore.
+ }
+ }
+
+ //
+ // Trace after the flush so that the correct number of objects
+ // are displayed
+ //
+ if(_traceLevels->flush > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->flushCat);
+ out << "connections: " << flushSet.size() << " subscribers: " << subscribers.size();
+ }
}
}
diff --git a/cpp/src/IceStorm/Instance.cpp b/cpp/src/IceStorm/Instance.cpp
index a5bcb3628d6..dac531d34f0 100644
--- a/cpp/src/IceStorm/Instance.cpp
+++ b/cpp/src/IceStorm/Instance.cpp
@@ -28,23 +28,23 @@ Instance::Instance(
_adapter(adapter),
_traceLevels(new TraceLevels(name, communicator->getProperties(), communicator->getLogger())),
_discardInterval(IceUtil::Time::seconds(communicator->getProperties()->getPropertyAsIntWithDefault(
- "IceStorm.Discard.Interval", 60))), // default one minute.
+ "IceStorm.Discard.Interval", 60))), // default one minute.
// default one minute.
_sendTimeout(communicator->getProperties()->getPropertyAsIntWithDefault("IceStorm.Send.Timeout", 60 * 1000))
{
try
{
- __setNoDelete(true);
+ __setNoDelete(true);
- _batchFlusher = new BatchFlusher(this);
- _subscriberPool = new SubscriberPool(this);
+ _batchFlusher = new BatchFlusher(this);
+ _subscriberPool = new SubscriberPool(this);
}
catch(...)
{
- shutdown();
- __setNoDelete(false);
+ shutdown();
+ __setNoDelete(false);
- throw;
+ throw;
}
__setNoDelete(false);
}
@@ -112,12 +112,12 @@ Instance::shutdown()
{
if(_batchFlusher)
{
- _batchFlusher->destroy();
- _batchFlusher->getThreadControl().join();
+ _batchFlusher->destroy();
+ _batchFlusher->getThreadControl().join();
}
if(_subscriberPool)
{
- _subscriberPool->destroy();
+ _subscriberPool->destroy();
}
}
diff --git a/cpp/src/IceStorm/Parser.cpp b/cpp/src/IceStorm/Parser.cpp
index aed113d2aec..3933ce6bd5a 100644
--- a/cpp/src/IceStorm/Parser.cpp
+++ b/cpp/src/IceStorm/Parser.cpp
@@ -39,8 +39,8 @@ class UnknownManagerException : public Exception
public:
UnknownManagerException(const string& name, const char* file, int line) :
- Exception(file, line),
- name(name)
+ Exception(file, line),
+ name(name)
{
}
@@ -51,18 +51,18 @@ public:
virtual string
ice_name() const
{
- return "UnknownManagerException";
+ return "UnknownManagerException";
}
virtual Exception*
ice_clone() const
{
- return new UnknownManagerException(*this);
+ return new UnknownManagerException(*this);
}
virtual void
ice_throw() const
{
- throw *this;
+ throw *this;
}
const string name;
};
@@ -71,7 +71,7 @@ public:
ParserPtr
Parser::createParser(const CommunicatorPtr& communicator, const TopicManagerPrx& admin,
- const map<Ice::Identity, IceStorm::TopicManagerPrx>& managers)
+ const map<Ice::Identity, IceStorm::TopicManagerPrx>& managers)
{
return new Parser(communicator, admin, managers);
}
@@ -102,18 +102,18 @@ Parser::create(const list<string>& args)
try
{
- for(list<string>::const_iterator i = args.begin(); i != args.end() ; ++i)
- {
- string arg;
- IceStorm::TopicManagerPrx manager = findManagerById(*i, arg);
- manager->create(arg);
- }
+ for(list<string>::const_iterator i = args.begin(); i != args.end() ; ++i)
+ {
+ string arg;
+ IceStorm::TopicManagerPrx manager = findManagerById(*i, arg);
+ manager->create(arg);
+ }
}
catch(const Exception& ex)
{
- ostringstream s;
- s << ex;
- error(s.str());
+ ostringstream s;
+ s << ex;
+ error(s.str());
}
}
@@ -122,19 +122,19 @@ Parser::destroy(const list<string>& args)
{
try
{
- for(list<string>::const_iterator i = args.begin(); i != args.end() ; ++i)
- {
- string arg;
- IceStorm::TopicManagerPrx manager = findManagerById(*i, arg);
- TopicPrx topic = manager->retrieve(arg);
- topic->destroy();
- }
+ for(list<string>::const_iterator i = args.begin(); i != args.end() ; ++i)
+ {
+ string arg;
+ IceStorm::TopicManagerPrx manager = findManagerById(*i, arg);
+ TopicPrx topic = manager->retrieve(arg);
+ topic->destroy();
+ }
}
catch(const Exception& ex)
{
- ostringstream s;
- s << ex;
- error(s.str());
+ ostringstream s;
+ s << ex;
+ error(s.str());
}
}
@@ -145,56 +145,56 @@ Parser::link(const list<string>& _args)
if(args.size() < 2)
{
- error("`link' requires at least two arguments (type `help' for more info)");
- return;
+ error("`link' requires at least two arguments (type `help' for more info)");
+ return;
}
try
{
- TopicPrx fromTopic;
- TopicPrx toTopic;
-
- try
- {
- string arg;
- IceStorm::TopicManagerPrx manager = findManagerById(args.front(), arg);
- fromTopic = manager->retrieve(arg);
- }
- catch(const IceStorm::NoSuchTopic&)
- {
- ostringstream s;
- s << args.front() << ": topic doesn't exist";
- error(s.str());
- return;
- }
- args.pop_front();
-
- try
- {
- string arg;
- IceStorm::TopicManagerPrx manager = findManagerById(args.front(), arg);
- toTopic = manager->retrieve(arg);
- }
- catch(const IceStorm::NoSuchTopic&)
- {
- ostringstream s;
- s << args.front() << ": topic doesn't exist";
- error(s.str());
- return;
- }
- args.pop_front();
- Ice::Int cost = 0;
- if(!args.empty())
- {
- cost = atoi(args.front().c_str());
- }
- fromTopic->link(toTopic, cost);
+ TopicPrx fromTopic;
+ TopicPrx toTopic;
+
+ try
+ {
+ string arg;
+ IceStorm::TopicManagerPrx manager = findManagerById(args.front(), arg);
+ fromTopic = manager->retrieve(arg);
+ }
+ catch(const IceStorm::NoSuchTopic&)
+ {
+ ostringstream s;
+ s << args.front() << ": topic doesn't exist";
+ error(s.str());
+ return;
+ }
+ args.pop_front();
+
+ try
+ {
+ string arg;
+ IceStorm::TopicManagerPrx manager = findManagerById(args.front(), arg);
+ toTopic = manager->retrieve(arg);
+ }
+ catch(const IceStorm::NoSuchTopic&)
+ {
+ ostringstream s;
+ s << args.front() << ": topic doesn't exist";
+ error(s.str());
+ return;
+ }
+ args.pop_front();
+ Ice::Int cost = 0;
+ if(!args.empty())
+ {
+ cost = atoi(args.front().c_str());
+ }
+ fromTopic->link(toTopic, cost);
}
catch(const Exception& ex)
{
- ostringstream s;
- s << ex;
- error(s.str());
+ ostringstream s;
+ s << ex;
+ error(s.str());
}
}
@@ -205,51 +205,51 @@ Parser::unlink(const list<string>& _args)
if(args.size() != 2)
{
- error("`unlink' requires exactly two arguments (type `help' for more info)");
- return;
+ error("`unlink' requires exactly two arguments (type `help' for more info)");
+ return;
}
try
{
- TopicPrx fromTopic;
- TopicPrx toTopic;
-
- try
- {
- string arg;
- IceStorm::TopicManagerPrx manager = findManagerById(args.front(), arg);
- fromTopic = manager->retrieve(arg);
- }
- catch(const IceStorm::NoSuchTopic&)
- {
- ostringstream s;
- s << args.front() << ": topic doesn't exist";
- error(s.str());
- return;
- }
- args.pop_front();
-
- try
- {
- string arg;
- IceStorm::TopicManagerPrx manager = findManagerById(args.front(), arg);
- toTopic = manager->retrieve(arg);
- }
- catch(const IceStorm::NoSuchTopic&)
- {
- ostringstream s;
- s << args.front() << ": topic doesn't exist";
- error(s.str());
- return;
- }
-
- fromTopic->unlink(toTopic);
+ TopicPrx fromTopic;
+ TopicPrx toTopic;
+
+ try
+ {
+ string arg;
+ IceStorm::TopicManagerPrx manager = findManagerById(args.front(), arg);
+ fromTopic = manager->retrieve(arg);
+ }
+ catch(const IceStorm::NoSuchTopic&)
+ {
+ ostringstream s;
+ s << args.front() << ": topic doesn't exist";
+ error(s.str());
+ return;
+ }
+ args.pop_front();
+
+ try
+ {
+ string arg;
+ IceStorm::TopicManagerPrx manager = findManagerById(args.front(), arg);
+ toTopic = manager->retrieve(arg);
+ }
+ catch(const IceStorm::NoSuchTopic&)
+ {
+ ostringstream s;
+ s << args.front() << ": topic doesn't exist";
+ error(s.str());
+ return;
+ }
+
+ fromTopic->unlink(toTopic);
}
catch(const Exception& ex)
{
- ostringstream s;
- s << ex;
- error(s.str());
+ ostringstream s;
+ s << ex;
+ error(s.str());
}
}
@@ -260,22 +260,22 @@ Parser::current(const list<string>& _args)
if(args.size() == 0)
{
- cout << _communicator->identityToString(_defaultManager->ice_getIdentity()) << endl;
- return;
+ cout << _communicator->identityToString(_defaultManager->ice_getIdentity()) << endl;
+ return;
}
try
{
- IceStorm::TopicManagerPrx manager = findManagerByCategory(args.front());
- manager->ice_ping();
- _defaultManager = manager;
+ IceStorm::TopicManagerPrx manager = findManagerByCategory(args.front());
+ manager->ice_ping();
+ _defaultManager = manager;
}
catch(const Exception& ex)
{
- ostringstream s;
- s << args.front() << ": " << ex;
- error(s.str());
- return;
+ ostringstream s;
+ s << args.front() << ": " << ex;
+ error(s.str());
+ return;
}
}
@@ -286,60 +286,60 @@ Parser::dolist(const list<string>& _args)
try
{
- if(args.size() <= 1)
- {
- IceStorm::TopicManagerPrx manager;
- if(args.size() == 1)
- {
- manager = findManagerByCategory(args.front());
- }
- else
- {
- manager = _defaultManager;
- }
- TopicDict d = manager->retrieveAll();
- if(!d.empty())
- {
- for(TopicDict::iterator i = d.begin(); i != d.end(); ++i)
- {
- if(i != d.begin())
- {
- cout << ", ";
- }
- cout << i->first;
- }
- cout << endl;
- }
- }
- else
- {
- IceStorm::TopicManagerPrx manager = findManagerByCategory(args.front());
- args.pop_front();
- while(!args.empty())
- {
- try
- {
- string arg = args.front();
- args.pop_front();
- TopicPrx topic = manager->retrieve(arg);
- LinkInfoSeq links = topic->getLinkInfoSeq();
- for(LinkInfoSeq::const_iterator p = links.begin(); p != links.end(); ++p)
- {
- cout << "\t" << (*p).name << " with cost " << (*p).cost << endl;
- }
- }
- catch(const NoSuchTopic&)
- {
- cout << "\tNo such topic" << endl;
- }
- }
- }
+ if(args.size() <= 1)
+ {
+ IceStorm::TopicManagerPrx manager;
+ if(args.size() == 1)
+ {
+ manager = findManagerByCategory(args.front());
+ }
+ else
+ {
+ manager = _defaultManager;
+ }
+ TopicDict d = manager->retrieveAll();
+ if(!d.empty())
+ {
+ for(TopicDict::iterator i = d.begin(); i != d.end(); ++i)
+ {
+ if(i != d.begin())
+ {
+ cout << ", ";
+ }
+ cout << i->first;
+ }
+ cout << endl;
+ }
+ }
+ else
+ {
+ IceStorm::TopicManagerPrx manager = findManagerByCategory(args.front());
+ args.pop_front();
+ while(!args.empty())
+ {
+ try
+ {
+ string arg = args.front();
+ args.pop_front();
+ TopicPrx topic = manager->retrieve(arg);
+ LinkInfoSeq links = topic->getLinkInfoSeq();
+ for(LinkInfoSeq::const_iterator p = links.begin(); p != links.end(); ++p)
+ {
+ cout << "\t" << (*p).name << " with cost " << (*p).cost << endl;
+ }
+ }
+ catch(const NoSuchTopic&)
+ {
+ cout << "\tNo such topic" << endl;
+ }
+ }
+ }
}
catch(const Exception& ex)
{
- ostringstream s;
- s << ex;
- error(s.str());
+ ostringstream s;
+ s << ex;
+ error(s.str());
}
}
@@ -366,105 +366,105 @@ Parser::getInput(char* buf, int& result, int maxSize)
{
if(!_commands.empty())
{
- if(_commands == ";")
- {
- result = 0;
- }
- else
- {
+ if(_commands == ";")
+ {
+ result = 0;
+ }
+ else
+ {
#if defined(_MSC_VER) && !defined(_STLP_MSVC)
- // COMPILERBUG: Stupid Visual C++ defines min and max as macros
- result = _MIN(maxSize, static_cast<int>(_commands.length()));
+ // COMPILERBUG: Stupid Visual C++ defines min and max as macros
+ result = _MIN(maxSize, static_cast<int>(_commands.length()));
#else
- result = min(maxSize, static_cast<int>(_commands.length()));
+ result = min(maxSize, static_cast<int>(_commands.length()));
#endif
- strncpy(buf, _commands.c_str(), result);
- _commands.erase(0, result);
- if(_commands.empty())
- {
- _commands = ";";
- }
- }
+ strncpy(buf, _commands.c_str(), result);
+ _commands.erase(0, result);
+ if(_commands.empty())
+ {
+ _commands = ";";
+ }
+ }
}
else if(isatty(fileno(yyin)))
{
#ifdef HAVE_READLINE
const char* prompt = parser->getPrompt();
- char* line = readline(const_cast<char*>(prompt));
- if(!line)
- {
- result = 0;
- }
- else
- {
- if(*line)
- {
- add_history(line);
- }
-
- result = strlen(line) + 1;
- if(result > maxSize)
- {
- free(line);
- error("input line too long");
- result = 0;
- }
- else
- {
- strcpy(buf, line);
- strcat(buf, "\n");
- free(line);
- }
- }
+ char* line = readline(const_cast<char*>(prompt));
+ if(!line)
+ {
+ result = 0;
+ }
+ else
+ {
+ if(*line)
+ {
+ add_history(line);
+ }
+
+ result = strlen(line) + 1;
+ if(result > maxSize)
+ {
+ free(line);
+ error("input line too long");
+ result = 0;
+ }
+ else
+ {
+ strcpy(buf, line);
+ strcat(buf, "\n");
+ free(line);
+ }
+ }
#else
- cout << parser->getPrompt() << flush;
-
- string line;
- while(true)
- {
- char c = static_cast<char>(getc(yyin));
- if(c == EOF)
- {
- if(line.size())
- {
- line += '\n';
- }
- break;
- }
-
- line += c;
-
- if(c == '\n')
- {
- break;
- }
- }
-
- result = (int) line.length();
- if(result > maxSize)
- {
- error("input line too long");
- buf[0] = EOF;
- result = 1;
- }
- else
- {
- strcpy(buf, line.c_str());
- }
+ cout << parser->getPrompt() << flush;
+
+ string line;
+ while(true)
+ {
+ char c = static_cast<char>(getc(yyin));
+ if(c == EOF)
+ {
+ if(line.size())
+ {
+ line += '\n';
+ }
+ break;
+ }
+
+ line += c;
+
+ if(c == '\n')
+ {
+ break;
+ }
+ }
+
+ result = (int) line.length();
+ if(result > maxSize)
+ {
+ error("input line too long");
+ buf[0] = EOF;
+ result = 1;
+ }
+ else
+ {
+ strcpy(buf, line.c_str());
+ }
#endif
}
else
{
- if(((result = (int) fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin))
- {
- error("input in flex scanner failed");
- buf[0] = EOF;
- result = 1;
- }
+ if(((result = (int) fread(buf, 1, maxSize, yyin)) == 0) && ferror(yyin))
+ {
+ error("input in flex scanner failed");
+ buf[0] = EOF;
+ result = 1;
+ }
}
}
@@ -487,12 +487,12 @@ Parser::getPrompt()
if(_continue)
{
- _continue = false;
- return "(cont) ";
+ _continue = false;
+ return "(cont) ";
}
else
{
- return ">>> ";
+ return ">>> ";
}
}
@@ -505,13 +505,13 @@ Parser::scanPosition(const char* s)
idx = line.find("line");
if(idx != string::npos)
{
- line.erase(0, idx + 4);
+ line.erase(0, idx + 4);
}
idx = line.find_first_not_of(" \t\r#");
if(idx != string::npos)
{
- line.erase(0, idx);
+ line.erase(0, idx);
}
_currentLine = atoi(line.c_str()) - 1;
@@ -519,24 +519,24 @@ Parser::scanPosition(const char* s)
idx = line.find_first_of(" \t\r");
if(idx != string::npos)
{
- line.erase(0, idx);
+ line.erase(0, idx);
}
idx = line.find_first_not_of(" \t\r\"");
if(idx != string::npos)
{
- line.erase(0, idx);
+ line.erase(0, idx);
- idx = line.find_first_of(" \t\r\"");
- if(idx != string::npos)
- {
- _currentFile = line.substr(0, idx);
- line.erase(0, idx + 1);
- }
- else
- {
- _currentFile = line;
- }
+ idx = line.find_first_of(" \t\r\"");
+ if(idx != string::npos)
+ {
+ _currentFile = line.substr(0, idx);
+ line.erase(0, idx + 1);
+ }
+ else
+ {
+ _currentFile = line;
+ }
}
}
@@ -545,11 +545,11 @@ Parser::error(const char* s)
{
if(_commands.empty() && !isatty(fileno(yyin)))
{
- cerr << _currentFile << ':' << _currentLine << ": " << s << endl;
+ cerr << _currentFile << ':' << _currentLine << ": " << s << endl;
}
else
{
- cerr << "error: " << s << endl;
+ cerr << "error: " << s << endl;
}
_errors++;
}
@@ -565,11 +565,11 @@ Parser::warning(const char* s)
{
if(_commands.empty() && !isatty(fileno(yyin)))
{
- cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl;
+ cerr << _currentFile << ':' << _currentLine << ": warning: " << s << endl;
}
else
{
- cerr << "warning: " << s << endl;
+ cerr << "warning: " << s << endl;
}
}
@@ -600,7 +600,7 @@ Parser::parse(FILE* file, bool debug)
int status = yyparse();
if(_errors)
{
- status = EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
parser = 0;
@@ -628,7 +628,7 @@ Parser::parse(const std::string& commands, bool debug)
int status = yyparse();
if(_errors)
{
- status = EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
parser = 0;
@@ -642,13 +642,13 @@ Parser::findManagerById(const string& full, string& arg) const
arg = id.name;
if(id.category.empty())
{
- return _defaultManager;
+ return _defaultManager;
}
id.name = "TopicManager";
map<Ice::Identity, IceStorm::TopicManagerPrx>::const_iterator p = _managers.find(id);
if(p == _managers.end())
{
- throw UnknownManagerException(id.category, __FILE__, __LINE__);
+ throw UnknownManagerException(id.category, __FILE__, __LINE__);
}
return p->second;
}
@@ -662,13 +662,13 @@ Parser::findManagerByCategory(const string& full) const
map<Ice::Identity, IceStorm::TopicManagerPrx>::const_iterator p = _managers.find(id);
if(p == _managers.end())
{
- throw UnknownManagerException(id.category, __FILE__, __LINE__);
+ throw UnknownManagerException(id.category, __FILE__, __LINE__);
}
return p->second;
}
Parser::Parser(const CommunicatorPtr& communicator, const TopicManagerPrx& admin,
- const map<Ice::Identity, IceStorm::TopicManagerPrx>& managers) :
+ const map<Ice::Identity, IceStorm::TopicManagerPrx>& managers) :
_communicator(communicator),
_defaultManager(admin),
_managers(managers)
diff --git a/cpp/src/IceStorm/Parser.h b/cpp/src/IceStorm/Parser.h
index be753288518..df8d77c0ea4 100644
--- a/cpp/src/IceStorm/Parser.h
+++ b/cpp/src/IceStorm/Parser.h
@@ -64,7 +64,7 @@ class Parser : public ::IceUtil::SimpleShared
public:
static ParserPtr createParser(const Ice::CommunicatorPtr&, const IceStorm::TopicManagerPrx&,
- const std::map<Ice::Identity, IceStorm::TopicManagerPrx>&);
+ const std::map<Ice::Identity, IceStorm::TopicManagerPrx>&);
void usage();
@@ -100,7 +100,7 @@ private:
IceStorm::TopicManagerPrx findManagerByCategory(const std::string&) const;
Parser(const Ice::CommunicatorPtr&, const IceStorm::TopicManagerPrx&,
- const std::map<Ice::Identity, IceStorm::TopicManagerPrx>&);
+ const std::map<Ice::Identity, IceStorm::TopicManagerPrx>&);
const Ice::CommunicatorPtr _communicator;
IceStorm::TopicManagerPrx _defaultManager;
diff --git a/cpp/src/IceStorm/Service.cpp b/cpp/src/IceStorm/Service.cpp
index be83f1c46a2..bf5b93951c6 100644
--- a/cpp/src/IceStorm/Service.cpp
+++ b/cpp/src/IceStorm/Service.cpp
@@ -32,15 +32,15 @@ public:
virtual ~ServiceI();
virtual void start(const string&,
- const CommunicatorPtr&,
- const StringSeq&);
+ const CommunicatorPtr&,
+ const StringSeq&);
virtual void start(const CommunicatorPtr&,
- const ObjectAdapterPtr&,
- const ObjectAdapterPtr&,
- const string&,
- const Ice::Identity&,
- const string&);
+ const ObjectAdapterPtr&,
+ const ObjectAdapterPtr&,
+ const string&,
+ const Ice::Identity&,
+ const string&);
virtual TopicManagerPrx getTopicManager() const;
@@ -70,11 +70,11 @@ createIceStorm(CommunicatorPtr communicator)
ServicePtr
IceStorm::Service::create(const CommunicatorPtr& communicator,
- const ObjectAdapterPtr& topicAdapter,
- const ObjectAdapterPtr& publishAdapter,
- const string& name,
- const Ice::Identity& id,
- const string& dbEnv)
+ const ObjectAdapterPtr& topicAdapter,
+ const ObjectAdapterPtr& publishAdapter,
+ const string& name,
+ const Ice::Identity& id,
+ const string& dbEnv)
{
ServiceI* service = new ServiceI;
ServicePtr svc = service;
@@ -113,26 +113,26 @@ IceStorm::ServiceI::start(
try
{
- _manager = new TopicManagerI(_instance, _topicAdapter, name, "topics");
- _managerProxy = TopicManagerPrx::uncheckedCast(_topicAdapter->add(_manager, topicManagerId));
+ _manager = new TopicManagerI(_instance, _topicAdapter, name, "topics");
+ _managerProxy = TopicManagerPrx::uncheckedCast(_topicAdapter->add(_manager, topicManagerId));
}
catch(const Ice::Exception&)
{
- _instance = 0;
- throw;
+ _instance = 0;
+ throw;
}
-
+
_topicAdapter->activate();
_publishAdapter->activate();
}
void
IceStorm::ServiceI::start(const CommunicatorPtr& communicator,
- const ObjectAdapterPtr& topicAdapter,
- const ObjectAdapterPtr& publishAdapter,
- const string& name,
- const Ice::Identity& id,
- const string& dbEnv)
+ const ObjectAdapterPtr& topicAdapter,
+ const ObjectAdapterPtr& publishAdapter,
+ const string& name,
+ const Ice::Identity& id,
+ const string& dbEnv)
{
string instanceName = communicator->getProperties()->getPropertyWithDefault(name + ".InstanceName", "IceStorm");
_instance = new Instance(instanceName, name, communicator, publishAdapter);
@@ -142,13 +142,13 @@ IceStorm::ServiceI::start(const CommunicatorPtr& communicator,
//
try
{
- _manager = new TopicManagerI(_instance, topicAdapter, dbEnv, "topics");
- _managerProxy = TopicManagerPrx::uncheckedCast(topicAdapter->add(_manager, id));
+ _manager = new TopicManagerI(_instance, topicAdapter, dbEnv, "topics");
+ _managerProxy = TopicManagerPrx::uncheckedCast(topicAdapter->add(_manager, id));
}
catch(const Ice::Exception&)
{
- _instance = 0;
- throw;
+ _instance = 0;
+ throw;
}
}
@@ -163,20 +163,20 @@ IceStorm::ServiceI::stop()
{
if(_topicAdapter)
{
- _topicAdapter->deactivate();
+ _topicAdapter->deactivate();
}
if(_publishAdapter)
{
- _publishAdapter->deactivate();
+ _publishAdapter->deactivate();
}
if(_topicAdapter)
{
- _topicAdapter->waitForDeactivate();
+ _topicAdapter->waitForDeactivate();
}
if(_publishAdapter)
{
- _publishAdapter->waitForDeactivate();
+ _publishAdapter->waitForDeactivate();
}
//
diff --git a/cpp/src/IceStorm/Subscriber.cpp b/cpp/src/IceStorm/Subscriber.cpp
index 9174eed5949..3162116566a 100644
--- a/cpp/src/IceStorm/Subscriber.cpp
+++ b/cpp/src/IceStorm/Subscriber.cpp
@@ -37,7 +37,7 @@ class PerSubscriberPublisherI : public Ice::BlobjectArray
public:
PerSubscriberPublisherI(const InstancePtr& instance) :
- _instance(instance)
+ _instance(instance)
{
}
@@ -48,36 +48,36 @@ public:
void
setSubscriber(const SubscriberPtr& subscriber)
{
- _subscriber = subscriber;
+ _subscriber = subscriber;
}
virtual bool
ice_invoke(const pair<const Ice::Byte*, const Ice::Byte*>& inParams,
- vector<Ice::Byte>&,
- const Ice::Current& current)
+ vector<Ice::Byte>&,
+ const Ice::Current& current)
{
- EventDataPtr event = new EventData(
- current.operation,
- current.mode,
- Ice::ByteSeq(),
- current.ctx);
+ EventDataPtr event = new EventData(
+ current.operation,
+ current.mode,
+ Ice::ByteSeq(),
+ current.ctx);
- //
- // COMPILERBUG: gcc 4.0.1 doesn't like this.
- //
- //event->data.swap(Ice::ByteSeq(inParams.first, inParams.second));
- Ice::ByteSeq data(inParams.first, inParams.second);
- event->data.swap(data);
+ //
+ // COMPILERBUG: gcc 4.0.1 doesn't like this.
+ //
+ //event->data.swap(Ice::ByteSeq(inParams.first, inParams.second));
+ Ice::ByteSeq data(inParams.first, inParams.second);
+ event->data.swap(data);
- EventDataSeq e;
- e.push_back(event);
- Subscriber::QueueState state = _subscriber->queue(false, e);
+ EventDataSeq e;
+ e.push_back(event);
+ Subscriber::QueueState state = _subscriber->queue(false, e);
- if(state == Subscriber::QueueStateFlush)
- {
- _instance->subscriberPool()->flush(_subscriber);
- }
- return true;
+ if(state == Subscriber::QueueStateFlush)
+ {
+ _instance->subscriberPool()->flush(_subscriber);
+ }
+ return true;
}
private:
@@ -188,7 +188,7 @@ SubscriberOneway::SubscriberOneway(
if(_batch)
{
- _instance->batchFlusher()->add(_obj);
+ _instance->batchFlusher()->add(_obj);
}
}
@@ -202,66 +202,66 @@ SubscriberOneway::flush()
//
if(_state == SubscriberStateError)
{
- return false;
+ return false;
}
assert(_state == SubscriberStateFlushPending);
assert(!_events.empty());
try
{
- //
- // Get the current set of events, but release the lock before
- // attempting to deliver the events. This allows other threads
- // to add events in case we block (such as during connection
- // establishment).
- //
- EventDataSeq v;
- v.swap(_events);
- sync.release();
-
- //
- // Deliver the events without holding the lock.
- //
- // If there are more than one event queued and we are not in
- // batch sending mode then send the events as a batch and then
- // flush immediately, otherwise send one at a time.
- //
- vector<Ice::Byte> dummy;
- if(v.size() > 1 && !_batch)
- {
- for(EventDataSeq::const_iterator p = v.begin(); p != v.end(); ++p)
- {
- _objBatch->ice_invoke((*p)->op, (*p)->mode, (*p)->data, dummy, (*p)->context);
- }
- Ice::ConnectionPtr conn = _objBatch->ice_getCachedConnection();
- assert(conn);
- conn->flushBatchRequests();
- }
- else
- {
- for(EventDataSeq::const_iterator p = v.begin(); p != v.end(); ++p)
- {
- _obj->ice_invoke((*p)->op, (*p)->mode, (*p)->data, dummy, (*p)->context);
- }
- }
-
- //
- // Reacquire the lock before we check the queue again.
- //
- sync.acquire();
+ //
+ // Get the current set of events, but release the lock before
+ // attempting to deliver the events. This allows other threads
+ // to add events in case we block (such as during connection
+ // establishment).
+ //
+ EventDataSeq v;
+ v.swap(_events);
+ sync.release();
+
+ //
+ // Deliver the events without holding the lock.
+ //
+ // If there are more than one event queued and we are not in
+ // batch sending mode then send the events as a batch and then
+ // flush immediately, otherwise send one at a time.
+ //
+ vector<Ice::Byte> dummy;
+ if(v.size() > 1 && !_batch)
+ {
+ for(EventDataSeq::const_iterator p = v.begin(); p != v.end(); ++p)
+ {
+ _objBatch->ice_invoke((*p)->op, (*p)->mode, (*p)->data, dummy, (*p)->context);
+ }
+ Ice::ConnectionPtr conn = _objBatch->ice_getCachedConnection();
+ assert(conn);
+ conn->flushBatchRequests();
+ }
+ else
+ {
+ for(EventDataSeq::const_iterator p = v.begin(); p != v.end(); ++p)
+ {
+ _obj->ice_invoke((*p)->op, (*p)->mode, (*p)->data, dummy, (*p)->context);
+ }
+ }
+
+ //
+ // Reacquire the lock before we check the queue again.
+ //
+ sync.acquire();
}
catch(const Ice::LocalException& ex)
{
- assert(!sync.acquired());
- // error will re-acquire and release the lock.
- error(ex);
- return false;
+ assert(!sync.acquired());
+ // error will re-acquire and release the lock.
+ error(ex);
+ return false;
}
if(!_events.empty())
{
- assert(_state == SubscriberStateFlushPending);
- return true;
+ assert(_state == SubscriberStateFlushPending);
+ return true;
}
_state = SubscriberStateOnline;
return false;
@@ -272,7 +272,7 @@ SubscriberOneway::destroy()
{
if(_batch)
{
- _instance->batchFlusher()->remove(_obj);
+ _instance->batchFlusher()->remove(_obj);
}
Subscriber::destroy();
}
@@ -285,7 +285,7 @@ class TwowayInvokeI : public Ice::AMI_Object_ice_invoke
public:
TwowayInvokeI(const SubscriberPtr& subscriber) :
- _subscriber(subscriber)
+ _subscriber(subscriber)
{
}
@@ -297,7 +297,7 @@ public:
virtual void
ice_exception(const Ice::Exception& e)
{
- _subscriber->error(e);
+ _subscriber->error(e);
}
private:
@@ -326,7 +326,7 @@ SubscriberTwoway::flush()
//
if(_state == SubscriberStateError)
{
- return false;
+ return false;
}
assert(_state == SubscriberStateFlushPending);
assert(!_events.empty());
@@ -346,7 +346,7 @@ SubscriberTwoway::flush()
//
for(EventDataSeq::const_iterator p = v.begin(); p != v.end(); ++p)
{
- _obj->ice_invoke_async(new TwowayInvokeI(this), (*p)->op, (*p)->mode, (*p)->data, (*p)->context);
+ _obj->ice_invoke_async(new TwowayInvokeI(this), (*p)->op, (*p)->mode, (*p)->data, (*p)->context);
}
//
@@ -360,8 +360,8 @@ SubscriberTwoway::flush()
//
if(!_events.empty())
{
- assert(_state == SubscriberStateFlushPending);
- return true;
+ assert(_state == SubscriberStateFlushPending);
+ return true;
}
_state = SubscriberStateOnline;
return false;
@@ -375,20 +375,20 @@ class TwowayOrderedInvokeI : public Ice::AMI_Object_ice_invoke
public:
TwowayOrderedInvokeI(const SubscriberTwowayOrderedPtr& subscriber) :
- _subscriber(subscriber)
+ _subscriber(subscriber)
{
}
virtual void
ice_response(bool, const std::vector<Ice::Byte>&)
{
- _subscriber->response();
+ _subscriber->response();
}
virtual void
ice_exception(const Ice::Exception& ex)
{
- _subscriber->error(ex);
+ _subscriber->error(ex);
}
private:
@@ -412,20 +412,20 @@ SubscriberTwowayOrdered::flush()
{
EventDataPtr e;
{
- IceUtil::Mutex::Lock sync(_mutex);
-
- //
- // If the subscriber errored out then we're done.
- //
- if(_state == SubscriberStateError)
- {
- return false;
- }
- assert(_state == SubscriberStateFlushPending);
- assert(!_events.empty());
-
- e = _events.front();
- _events.erase(_events.begin());
+ IceUtil::Mutex::Lock sync(_mutex);
+
+ //
+ // If the subscriber errored out then we're done.
+ //
+ if(_state == SubscriberStateError)
+ {
+ return false;
+ }
+ assert(_state == SubscriberStateFlushPending);
+ assert(!_events.empty());
+
+ e = _events.front();
+ _events.erase(_events.begin());
}
_obj->ice_invoke_async(new TwowayOrderedInvokeI(this), e->op, e->mode, e->data, e->context);
@@ -441,8 +441,8 @@ SubscriberTwowayOrdered::response()
assert(_state != SubscriberStateError);
if(_events.empty())
{
- _state = SubscriberStateOnline;
- return;
+ _state = SubscriberStateOnline;
+ return;
}
_instance->subscriberPool()->flush(this);
}
@@ -455,31 +455,31 @@ class Topiclink_forwardI : public IceStorm::AMI_TopicLink_forward
public:
Topiclink_forwardI(const SubscriberLinkPtr& subscriber) :
- _subscriber(subscriber)
+ _subscriber(subscriber)
{
}
virtual void
ice_response()
{
- _subscriber->response();
+ _subscriber->response();
}
virtual void
ice_exception(const Ice::Exception& ex)
{
- try
- {
- ex.ice_throw();
- }
- catch(const Ice::ObjectNotExistException& ex)
- {
- _subscriber->error(ex);
- }
- catch(const Ice::LocalException& ex)
- {
- _subscriber->offline(ex);
- }
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(const Ice::ObjectNotExistException& ex)
+ {
+ _subscriber->error(ex);
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ _subscriber->offline(ex);
+ }
}
private:
@@ -505,7 +505,7 @@ SubscriberLink::queue(bool forwarded, const EventDataSeq& events)
{
if(forwarded)
{
- return QueueStateNoFlush;
+ return QueueStateNoFlush;
}
//
@@ -518,7 +518,7 @@ SubscriberLink::queue(bool forwarded, const EventDataSeq& events)
if(_state == SubscriberStateError)
{
- return QueueStateError;
+ return QueueStateError;
}
//
@@ -527,53 +527,53 @@ SubscriberLink::queue(bool forwarded, const EventDataSeq& events)
//
if(_state == SubscriberStateOffline)
{
- //
- // If there are alot of subscribers offline then we will call
- // Time::now() alot, which could be costly. This could be
- // optimized to only one per event-batch by making the
- // forwarded argument an EventInfo thing where the queue-time
- // is lazy initialized.
- //
- if(IceUtil::Time::now() < _next)
- {
- return QueueStateNoFlush;
- }
-
- //
- // State transition to online.
- //
- _state = SubscriberStateOnline;
+ //
+ // If there are alot of subscribers offline then we will call
+ // Time::now() alot, which could be costly. This could be
+ // optimized to only one per event-batch by making the
+ // forwarded argument an EventInfo thing where the queue-time
+ // is lazy initialized.
+ //
+ if(IceUtil::Time::now() < _next)
+ {
+ return QueueStateNoFlush;
+ }
+
+ //
+ // State transition to online.
+ //
+ _state = SubscriberStateOnline;
}
int queued = 0;
for(EventDataSeq::const_iterator p = events.begin(); p != events.end(); ++p)
{
- if(_cost != 0)
- {
- //
- // Note that we could calculate this cost once and cache
- // it in a private form of the event to avoid this if this
- // really is a performance problem (this could use the
- // EventInfo thing discussed above).
- //
- int cost = 0;
- Ice::Context::const_iterator q = (*p)->context.find("cost");
- if(q != (*p)->context.end())
- {
- cost = atoi(q->second.c_str());
- }
- if(cost > _cost)
- {
- continue;
- }
- }
- ++queued;
- _events.push_back(*p);
+ if(_cost != 0)
+ {
+ //
+ // Note that we could calculate this cost once and cache
+ // it in a private form of the event to avoid this if this
+ // really is a performance problem (this could use the
+ // EventInfo thing discussed above).
+ //
+ int cost = 0;
+ Ice::Context::const_iterator q = (*p)->context.find("cost");
+ if(q != (*p)->context.end())
+ {
+ cost = atoi(q->second.c_str());
+ }
+ if(cost > _cost)
+ {
+ continue;
+ }
+ }
+ ++queued;
+ _events.push_back(*p);
}
if(_state == SubscriberStateFlushPending || queued == 0)
{
- return QueueStateNoFlush;
+ return QueueStateNoFlush;
}
_state = SubscriberStateFlushPending;
return QueueStateFlush;
@@ -584,20 +584,20 @@ SubscriberLink::flush()
{
EventDataSeq v;
{
- IceUtil::Mutex::Lock sync(_mutex);
-
- //
- // If the subscriber errored out then we're done.
- //
- if(_state == SubscriberStateError)
- {
- return false;
- }
+ IceUtil::Mutex::Lock sync(_mutex);
+
+ //
+ // If the subscriber errored out then we're done.
+ //
+ if(_state == SubscriberStateError)
+ {
+ return false;
+ }
- assert(_state == SubscriberStateFlushPending);
- assert(!_events.empty());
-
- v.swap(_events);
+ assert(_state == SubscriberStateFlushPending);
+ assert(!_events.empty());
+
+ v.swap(_events);
}
_obj->forward_async(new Topiclink_forwardI(this), v);
@@ -622,8 +622,8 @@ SubscriberLink::response()
//
if(_events.empty())
{
- _state = SubscriberStateOnline;
- return;
+ _state = SubscriberStateOnline;
+ return;
}
_instance->subscriberPool()->flush(this);
}
@@ -639,18 +639,18 @@ SubscriberLink::offline(const Ice::Exception& e)
TraceLevelsPtr traceLevels = _instance->traceLevels();
if(_warn)
{
- Ice::Warning warn(traceLevels->logger);
- warn << traceLevels->subscriberCat << ":" << _instance->communicator()->identityToString(_id)
- << ": link offline: " << e;
+ Ice::Warning warn(traceLevels->logger);
+ warn << traceLevels->subscriberCat << ":" << _instance->communicator()->identityToString(_id)
+ << ": link offline: " << e;
}
else
{
- if(traceLevels->subscriber > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->subscriberCat);
- out << _instance->communicator()->identityToString(_id) << ": link offline: " << e
- << " discarding events: " << _instance->discardInterval() << "s";
- }
+ if(traceLevels->subscriber > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->subscriberCat);
+ out << _instance->communicator()->identityToString(_id) << ": link offline: " << e
+ << " discarding events: " << _instance->discardInterval() << "s";
+ }
}
_state = SubscriberStateOffline;
@@ -675,57 +675,57 @@ Subscriber::create(
try
{
- string reliability;
- QoS::const_iterator p = qos.find("reliability");
- if(p != qos.end())
- {
- reliability = p->second;
- }
- if(!reliability.empty() && reliability != "ordered")
- {
- throw BadQoS("invalid reliability: " + reliability);
- }
-
- //
- // Override the timeout.
- //
- Ice::ObjectPrx newObj;
- try
- {
- newObj = obj->ice_timeout(instance->sendTimeout());
- }
- catch(const Ice::FixedProxyException&)
- {
- //
- // In the event IceStorm is collocated this could be a
- // fixed proxy in which case its not possible to set the
- // timeout.
- //
- newObj = obj;
- }
- if(reliability == "ordered")
- {
- if(!newObj->ice_isTwoway())
- {
- throw BadQoS("ordered reliability requires a twoway proxy");
- }
- subscriber = new SubscriberTwowayOrdered(instance, proxy, newObj);
- }
- else if(newObj->ice_isOneway() || newObj->ice_isDatagram() ||
- newObj->ice_isBatchOneway() || newObj->ice_isBatchDatagram())
- {
- subscriber = new SubscriberOneway(instance, proxy, newObj);
- }
- else if(newObj->ice_isTwoway())
- {
- subscriber = new SubscriberTwoway(instance, proxy, newObj);
- }
- per->setSubscriber(subscriber);
+ string reliability;
+ QoS::const_iterator p = qos.find("reliability");
+ if(p != qos.end())
+ {
+ reliability = p->second;
+ }
+ if(!reliability.empty() && reliability != "ordered")
+ {
+ throw BadQoS("invalid reliability: " + reliability);
+ }
+
+ //
+ // Override the timeout.
+ //
+ Ice::ObjectPrx newObj;
+ try
+ {
+ newObj = obj->ice_timeout(instance->sendTimeout());
+ }
+ catch(const Ice::FixedProxyException&)
+ {
+ //
+ // In the event IceStorm is collocated this could be a
+ // fixed proxy in which case its not possible to set the
+ // timeout.
+ //
+ newObj = obj;
+ }
+ if(reliability == "ordered")
+ {
+ if(!newObj->ice_isTwoway())
+ {
+ throw BadQoS("ordered reliability requires a twoway proxy");
+ }
+ subscriber = new SubscriberTwowayOrdered(instance, proxy, newObj);
+ }
+ else if(newObj->ice_isOneway() || newObj->ice_isDatagram() ||
+ newObj->ice_isBatchOneway() || newObj->ice_isBatchDatagram())
+ {
+ subscriber = new SubscriberOneway(instance, proxy, newObj);
+ }
+ else if(newObj->ice_isTwoway())
+ {
+ subscriber = new SubscriberTwoway(instance, proxy, newObj);
+ }
+ per->setSubscriber(subscriber);
}
catch(const Ice::Exception&)
{
- instance->objectAdapter()->remove(proxy->ice_getIdentity());
- throw;
+ instance->objectAdapter()->remove(proxy->ice_getIdentity());
+ throw;
}
return subscriber;
@@ -738,9 +738,9 @@ Subscriber::create(
int cost)
{
return new SubscriberLink(
- instance,
- TopicLinkPrx::uncheckedCast(link->ice_timeout(instance->sendTimeout())),
- cost);
+ instance,
+ TopicLinkPrx::uncheckedCast(link->ice_timeout(instance->sendTimeout())),
+ cost);
}
Subscriber::~Subscriber()
@@ -772,13 +772,13 @@ Subscriber::queue(bool, const EventDataSeq& events)
if(_state == SubscriberStateError)
{
- return QueueStateError;
+ return QueueStateError;
}
copy(events.begin(), events.end(), back_inserter(_events));
if(_state == SubscriberStateFlushPending)
{
- return QueueStateNoFlush;
+ return QueueStateNoFlush;
}
_state = SubscriberStateFlushPending;
@@ -793,18 +793,18 @@ Subscriber::destroy()
//
if(_proxy)
{
- try
- {
- _instance->objectAdapter()->remove(_proxy->ice_getIdentity());
- }
- catch(const Ice::NotRegisteredException&)
- {
- // Ignore
- }
- catch(const Ice::ObjectAdapterDeactivatedException&)
- {
- // Ignore
- }
+ try
+ {
+ _instance->objectAdapter()->remove(_proxy->ice_getIdentity());
+ }
+ catch(const Ice::NotRegisteredException&)
+ {
+ // Ignore
+ }
+ catch(const Ice::ObjectAdapterDeactivatedException&)
+ {
+ // Ignore
+ }
}
}
@@ -813,9 +813,9 @@ Subscriber::flushTime(const IceUtil::Time& interval)
{
if(_resetMax || interval > _maxSend)
{
- assert(interval != IceUtil::Time());
- _resetMax = false;
- _maxSend = interval;
+ assert(interval != IceUtil::Time());
+ _resetMax = false;
+ _maxSend = interval;
}
}
@@ -833,15 +833,15 @@ Subscriber::error(const Ice::Exception& e)
IceUtil::Mutex::Lock sync(_mutex);
if(_state != SubscriberStateError)
{
- _state = SubscriberStateError;
- _events.clear();
-
- TraceLevelsPtr traceLevels = _instance->traceLevels();
- if(traceLevels->subscriber > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->subscriberCat);
- out << _instance->communicator()->identityToString(_id) << ": topic publish failed: " << e;
- }
+ _state = SubscriberStateError;
+ _events.clear();
+
+ TraceLevelsPtr traceLevels = _instance->traceLevels();
+ if(traceLevels->subscriber > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->subscriberCat);
+ out << _instance->communicator()->identityToString(_id) << ": topic publish failed: " << e;
+ }
}
}
diff --git a/cpp/src/IceStorm/Subscriber.h b/cpp/src/IceStorm/Subscriber.h
index bbe83750874..166362f1128 100644
--- a/cpp/src/IceStorm/Subscriber.h
+++ b/cpp/src/IceStorm/Subscriber.h
@@ -36,9 +36,9 @@ public:
enum QueueState
{
- QueueStateError,
- QueueStateFlush,
- QueueStateNoFlush
+ QueueStateError,
+ QueueStateFlush,
+ QueueStateNoFlush
};
virtual QueueState queue(bool, const std::vector<EventDataPtr>&);
//
@@ -70,10 +70,10 @@ protected:
enum SubscriberState
{
- SubscriberStateOnline,
- SubscriberStateFlushPending,
- SubscriberStateOffline,
- SubscriberStateError
+ SubscriberStateOnline,
+ SubscriberStateFlushPending,
+ SubscriberStateOffline,
+ SubscriberStateError
};
SubscriberState _state; // The subscriber state.
EventDataSeq _events; // The queue of events to send.
diff --git a/cpp/src/IceStorm/SubscriberPool.cpp b/cpp/src/IceStorm/SubscriberPool.cpp
index 42c92fd97cf..1d1fd773028 100644
--- a/cpp/src/IceStorm/SubscriberPool.cpp
+++ b/cpp/src/IceStorm/SubscriberPool.cpp
@@ -27,9 +27,9 @@ class SubscriberPoolWorker : public IceUtil::Thread
public:
SubscriberPoolWorker(const SubscriberPoolPtr& manager) :
- _manager(manager)
+ _manager(manager)
{
- start();
+ start();
}
~SubscriberPoolWorker()
@@ -39,35 +39,35 @@ public:
virtual void
run()
{
- IceUtil::Time interval = IceUtil::Time::seconds(24 * 60); // A long time.
- SubscriberPtr sub;
- bool requeue = false;
- bool computeInterval = false;
- while(true)
- {
- _manager->dequeue(sub, requeue, interval, computeInterval);
- if(!sub)
- {
- return;
- }
-
- //
- // If SubscriberPool returns true then the subscriber
- // needs to be SubscriberPooled again, so therefore we
- // will re-enqueue the subscriber in the call to dequeue.
- //
- if(computeInterval)
- {
- IceUtil::Time start = IceUtil::Time::now();
- requeue = sub->flush();
- interval = IceUtil::Time::now() - start;
- }
- else
- {
- requeue = sub->flush();
- interval = IceUtil::Time::seconds(24 * 60); // A long time.
- }
- }
+ IceUtil::Time interval = IceUtil::Time::seconds(24 * 60); // A long time.
+ SubscriberPtr sub;
+ bool requeue = false;
+ bool computeInterval = false;
+ while(true)
+ {
+ _manager->dequeue(sub, requeue, interval, computeInterval);
+ if(!sub)
+ {
+ return;
+ }
+
+ //
+ // If SubscriberPool returns true then the subscriber
+ // needs to be SubscriberPooled again, so therefore we
+ // will re-enqueue the subscriber in the call to dequeue.
+ //
+ if(computeInterval)
+ {
+ IceUtil::Time start = IceUtil::Time::now();
+ requeue = sub->flush();
+ interval = IceUtil::Time::now() - start;
+ }
+ else
+ {
+ requeue = sub->flush();
+ interval = IceUtil::Time::seconds(24 * 60); // A long time.
+ }
+ }
}
private:
@@ -96,32 +96,32 @@ SubscriberPoolMonitor::run()
for(;;)
{
{
- Lock sync(*this);
- if(_destroyed)
- {
- return;
- }
+ Lock sync(*this);
+ if(_destroyed)
+ {
+ return;
+ }
- if(_needCheck)
- {
- timedWait(_timeout);
- //
- // Monitoring was stopped.
- //
- if(!_needCheck)
- {
- continue;
- }
- if(_destroyed)
- {
- return;
- }
- }
- else
- {
- wait();
- continue;
- }
+ if(_needCheck)
+ {
+ timedWait(_timeout);
+ //
+ // Monitoring was stopped.
+ //
+ if(!_needCheck)
+ {
+ continue;
+ }
+ if(_destroyed)
+ {
+ return;
+ }
+ }
+ else
+ {
+ wait();
+ continue;
+ }
}
//
// Call outside of the lock to prevent any deadlocks.
@@ -163,7 +163,7 @@ SubscriberPool::SubscriberPool(const InstancePtr& instance) :
_size(instance->properties()->getPropertyAsIntWithDefault("IceStorm.SubscriberPool.Size", 1)),
// minimum 50ms, default 1s.
_timeout(IceUtil::Time::milliSeconds(max(instance->properties()->getPropertyAsIntWithDefault(
- "IceStorm.SubscriberPool.Timeout", 1000), 50))),
+ "IceStorm.SubscriberPool.Timeout", 1000), 50))),
// 10 * the stall timeout.
_stallCheck(_timeout * 10),
_destroyed(false),
@@ -171,23 +171,23 @@ SubscriberPool::SubscriberPool(const InstancePtr& instance) :
{
try
{
- __setNoDelete(true);
- _subscriberPoolMonitor = new SubscriberPoolMonitor(this, _timeout);
- for(unsigned int i = 0; i < _size; ++i)
- {
- ++_inUse;
- _workers.push_back(new SubscriberPoolWorker(this));
- }
+ __setNoDelete(true);
+ _subscriberPoolMonitor = new SubscriberPoolMonitor(this, _timeout);
+ for(unsigned int i = 0; i < _size; ++i)
+ {
+ ++_inUse;
+ _workers.push_back(new SubscriberPoolWorker(this));
+ }
}
catch(const IceUtil::Exception& ex)
{
- {
- Ice::Error out(_traceLevels->logger);
- out << "SubscriberPool: " << ex;
- }
- destroy();
- __setNoDelete(false);
- throw;
+ {
+ Ice::Error out(_traceLevels->logger);
+ out << "SubscriberPool: " << ex;
+ }
+ destroy();
+ __setNoDelete(false);
+ throw;
}
__setNoDelete(false);
@@ -203,7 +203,7 @@ SubscriberPool::flush(list<SubscriberPtr>& subscribers)
Lock sync(*this);
if(_destroyed)
{
- return;
+ return;
}
//
// Splice on the new set of subscribers to SubscriberPool.
@@ -219,7 +219,7 @@ SubscriberPool::flush(const SubscriberPtr& subscriber)
Lock sync(*this);
if(_destroyed)
{
- return;
+ return;
}
_pending.push_back(subscriber);
assert(invariants());
@@ -232,7 +232,7 @@ SubscriberPool::add(const SubscriberPtr& subscriber)
Lock sync(*this);
if(_destroyed)
{
- return;
+ return;
}
_subscribers.push_back(subscriber);
assert(invariants());
@@ -244,7 +244,7 @@ SubscriberPool::remove(const SubscriberPtr& subscriber)
Lock sync(*this);
if(_destroyed)
{
- return;
+ return;
}
//
// Note that this cannot remove based on the subscriber id because
@@ -267,18 +267,18 @@ SubscriberPool::dequeue(SubscriberPtr& subscriber, bool requeue, const IceUtil::
if(_destroyed)
{
- subscriber = 0;
- return;
+ subscriber = 0;
+ return;
}
if(subscriber)
{
- if(requeue)
- {
- _pending.push_back(subscriber);
- assert(invariants());
- }
- subscriber->flushTime(interval);
+ if(requeue)
+ {
+ _pending.push_back(subscriber);
+ assert(invariants());
+ }
+ subscriber->flushTime(interval);
}
//
// Clear the reference.
@@ -297,99 +297,99 @@ SubscriberPool::dequeue(SubscriberPtr& subscriber, bool requeue, const IceUtil::
if(_sizeMax != 1)
{
- //
- // Reap dead workers, if necessary.
- //
- if(_reap > 0)
- {
- if(_traceLevels->subscriberPool > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberPoolCat);
- out << "reaping: " << _reap << " workers";
- }
- list<IceUtil::ThreadPtr>::iterator p = _workers.begin();
- while(p != _workers.end() && _reap > 0)
- {
- if(!(*p)->isAlive())
- {
- (*p)->getThreadControl().join();
- p = _workers.erase(p);
- --_reap;
- }
- else
- {
- ++p;
- }
- }
- }
-
- //
- // If we have extra workers every _stallCheck period we run
- // through the complete set of subscribers and determine how
- // many have stalled since the last check. If this number is
- // less than the number of extra threads then we terminate the
- // calling worker.
- //
- // - The flush time is protected by the subscriber pool mutex.
- // - The flush time is only computed if we have extra threads,
- // otherwise it is set to some large value.
- // - The max flush time is reset to the next sending interval
- // after after _stallCheck period.
- // - Every subscriber is considered to be stalled iff it has
- // never sent an event or we have just created the first
- // additional worker. The first handles the case where a
- // subscriber stalls for a long time on the first message
- // send. The second means that we can disable computation of
- // the flush latency if there are no additional threads.
- //
- if(_workers.size() > _size)
- {
- IceUtil::Time now = IceUtil::Time::now();
- if(now - _lastStallCheck > _stallCheck)
- {
- _lastStallCheck = now;
- unsigned int stalls = 0;
- for(list<SubscriberPtr>::const_iterator p = _subscribers.begin(); p != _subscribers.end(); ++p)
- {
- if((*p)->pollMaxFlushTime(now) > _timeout)
- {
- ++stalls;
- }
- }
-
- if(_traceLevels->subscriberPool > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberPoolCat);
- out << "checking stalls. extra workers: " << _workers.size() - _size
- << " subscribers: " << _subscribers.size() << " stalls: " << stalls;
- }
-
- if((_workers.size() - _size) > stalls)
- {
- if(_traceLevels->subscriberPool > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberPoolCat);
- out << "destroying workers";
- }
- ++_reap;
- return;
- }
- }
- }
+ //
+ // Reap dead workers, if necessary.
+ //
+ if(_reap > 0)
+ {
+ if(_traceLevels->subscriberPool > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberPoolCat);
+ out << "reaping: " << _reap << " workers";
+ }
+ list<IceUtil::ThreadPtr>::iterator p = _workers.begin();
+ while(p != _workers.end() && _reap > 0)
+ {
+ if(!(*p)->isAlive())
+ {
+ (*p)->getThreadControl().join();
+ p = _workers.erase(p);
+ --_reap;
+ }
+ else
+ {
+ ++p;
+ }
+ }
+ }
+
+ //
+ // If we have extra workers every _stallCheck period we run
+ // through the complete set of subscribers and determine how
+ // many have stalled since the last check. If this number is
+ // less than the number of extra threads then we terminate the
+ // calling worker.
+ //
+ // - The flush time is protected by the subscriber pool mutex.
+ // - The flush time is only computed if we have extra threads,
+ // otherwise it is set to some large value.
+ // - The max flush time is reset to the next sending interval
+ // after after _stallCheck period.
+ // - Every subscriber is considered to be stalled iff it has
+ // never sent an event or we have just created the first
+ // additional worker. The first handles the case where a
+ // subscriber stalls for a long time on the first message
+ // send. The second means that we can disable computation of
+ // the flush latency if there are no additional threads.
+ //
+ if(_workers.size() > _size)
+ {
+ IceUtil::Time now = IceUtil::Time::now();
+ if(now - _lastStallCheck > _stallCheck)
+ {
+ _lastStallCheck = now;
+ unsigned int stalls = 0;
+ for(list<SubscriberPtr>::const_iterator p = _subscribers.begin(); p != _subscribers.end(); ++p)
+ {
+ if((*p)->pollMaxFlushTime(now) > _timeout)
+ {
+ ++stalls;
+ }
+ }
+
+ if(_traceLevels->subscriberPool > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberPoolCat);
+ out << "checking stalls. extra workers: " << _workers.size() - _size
+ << " subscribers: " << _subscribers.size() << " stalls: " << stalls;
+ }
+
+ if((_workers.size() - _size) > stalls)
+ {
+ if(_traceLevels->subscriberPool > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberPoolCat);
+ out << "destroying workers";
+ }
+ ++_reap;
+ return;
+ }
+ }
+ }
}
-
+
while(_pending.empty() && !_destroyed)
{
- //
- // If we wait then there is no need to monitor anymore.
- //
- _subscriberPoolMonitor->stopMonitor();
- wait();
+ //
+ // If we wait then there is no need to monitor anymore.
+ //
+ _subscriberPoolMonitor->stopMonitor();
+ wait();
}
if(_destroyed)
{
- return;
+ return;
}
_lastDequeue = IceUtil::Time::now();
@@ -405,11 +405,11 @@ SubscriberPool::dequeue(SubscriberPtr& subscriber, bool requeue, const IceUtil::
//
if(_inUse == _workers.size() && (_workers.size() < _sizeMax || _sizeMax != 1))
{
- _subscriberPoolMonitor->startMonitor();
+ _subscriberPoolMonitor->startMonitor();
}
else
{
- _subscriberPoolMonitor->stopMonitor();
+ _subscriberPoolMonitor->stopMonitor();
}
//
// We only need to compute the push interval if we've created
@@ -429,22 +429,22 @@ SubscriberPool::destroy()
// _destroyed is set.
//
{
- Lock sync(*this);
- _destroyed = true;
- notifyAll();
- if(_subscriberPoolMonitor)
- {
- _subscriberPoolMonitor->destroy();
- }
- _subscribers.clear();
- _pending.clear();
+ Lock sync(*this);
+ _destroyed = true;
+ notifyAll();
+ if(_subscriberPoolMonitor)
+ {
+ _subscriberPoolMonitor->destroy();
+ }
+ _subscribers.clear();
+ _pending.clear();
}
//
// Next join with each worker.
//
for(list<IceUtil::ThreadPtr>::const_iterator p = _workers.begin(); p != _workers.end(); ++p)
{
- (*p)->getThreadControl().join();
+ (*p)->getThreadControl().join();
}
_workers.clear();
@@ -455,8 +455,8 @@ SubscriberPool::destroy()
//
if(_subscriberPoolMonitor)
{
- _subscriberPoolMonitor->getThreadControl().join();
- _subscriberPoolMonitor = 0;
+ _subscriberPoolMonitor->getThreadControl().join();
+ _subscriberPoolMonitor = 0;
}
}
@@ -466,7 +466,7 @@ SubscriberPool::check()
Lock sync(*this);
if(_destroyed)
{
- return;
+ return;
}
IceUtil::Time now = IceUtil::Time::now();
@@ -474,34 +474,34 @@ SubscriberPool::check()
/*
if(_traceLevels->subscriberPool > 1)
{
- Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberPoolCat);
- out << "check called: interval: " << interval << " timeout: " << _timeout
- << " pending: " << _pending.size() << " running: " << _workers.size()
- << " sizeMax: " << _sizeMax;
+ Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberPoolCat);
+ out << "check called: interval: " << interval << " timeout: " << _timeout
+ << " pending: " << _pending.size() << " running: " << _workers.size()
+ << " sizeMax: " << _sizeMax;
}
*/
if(interval > _timeout && _pending.size() > 0 && (_workers.size() < _sizeMax || _sizeMax == 0))
{
- if(_traceLevels->subscriberPool > 0)
- {
- Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberPoolCat);
- out << "detected stall: creating thread: threads: " << _workers.size();
- }
-
- //
- // We'll now start stall checking at regular intervals if this
- // is the first newly created worker. Here we need to
- // initially set the stall check and the number of requests at
- // this point.
- //
- if(_workers.size() == _size)
- {
- _lastStallCheck = now;
- }
-
- ++_inUse;
- _workers.push_back(new SubscriberPoolWorker(this));
+ if(_traceLevels->subscriberPool > 0)
+ {
+ Ice::Trace out(_traceLevels->logger, _traceLevels->subscriberPoolCat);
+ out << "detected stall: creating thread: threads: " << _workers.size();
+ }
+
+ //
+ // We'll now start stall checking at regular intervals if this
+ // is the first newly created worker. Here we need to
+ // initially set the stall check and the number of requests at
+ // this point.
+ //
+ if(_workers.size() == _size)
+ {
+ _lastStallCheck = now;
+ }
+
+ ++_inUse;
+ _workers.push_back(new SubscriberPoolWorker(this));
}
}
@@ -512,14 +512,14 @@ SubscriberPool::invariants()
list<SubscriberPtr>::const_iterator p;
for(p = _subscribers.begin(); p != _subscribers.end(); ++p)
{
- assert(subs.find(*p) == subs.end());
- subs.insert(*p);
+ assert(subs.find(*p) == subs.end());
+ subs.insert(*p);
}
subs.clear();
for(p = _pending.begin(); p != _pending.end(); ++p)
{
- assert(subs.find(*p) == subs.end());
- subs.insert(*p);
+ assert(subs.find(*p) == subs.end());
+ subs.insert(*p);
}
return true;
}
diff --git a/cpp/src/IceStorm/TopicI.cpp b/cpp/src/IceStorm/TopicI.cpp
index a88bc1c1744..1831a746ac5 100644
--- a/cpp/src/IceStorm/TopicI.cpp
+++ b/cpp/src/IceStorm/TopicI.cpp
@@ -35,33 +35,33 @@ class PublisherI : public Ice::BlobjectArray
public:
PublisherI(const TopicIPtr& topic) :
- _topic(topic)
+ _topic(topic)
{
}
virtual bool
ice_invoke(const pair<const Ice::Byte*, const Ice::Byte*>& inParams,
- Ice::ByteSeq&,
- const Ice::Current& current)
+ Ice::ByteSeq&,
+ const Ice::Current& current)
{
- EventDataPtr event = new EventData(
- current.operation,
- current.mode,
- Ice::ByteSeq(),
- current.ctx);
+ EventDataPtr event = new EventData(
+ current.operation,
+ current.mode,
+ Ice::ByteSeq(),
+ current.ctx);
- //
- // COMPILERBUG: gcc 4.0.1 doesn't like this.
- //
- //event->data.swap(Ice::ByteSeq(inParams.first, inParams.second));
- Ice::ByteSeq data(inParams.first, inParams.second);
- event->data.swap(data);
-
- EventDataSeq v;
- v.push_back(event);
- _topic->publish(false, v);
+ //
+ // COMPILERBUG: gcc 4.0.1 doesn't like this.
+ //
+ //event->data.swap(Ice::ByteSeq(inParams.first, inParams.second));
+ Ice::ByteSeq data(inParams.first, inParams.second);
+ event->data.swap(data);
+
+ EventDataSeq v;
+ v.push_back(event);
+ _topic->publish(false, v);
- return true;
+ return true;
}
private:
@@ -78,14 +78,14 @@ class TopicLinkI : public TopicLink
public:
TopicLinkI(const TopicIPtr& topic) :
- _topic(topic)
+ _topic(topic)
{
}
virtual void
forward(const EventDataSeq& v, const Ice::Current& current)
{
- _topic->publish(true, v);
+ _topic->publish(true, v);
}
private:
@@ -128,17 +128,17 @@ TopicI::TopicI(
Ice::Identity linkid;
if(id.category.empty())
{
- pubid.category = _name;
- pubid.name = "publish";
- linkid.category = _name;
- linkid.name = "link";
+ pubid.category = _name;
+ pubid.name = "publish";
+ linkid.category = _name;
+ linkid.name = "link";
}
else
{
- pubid.category = id.category;
- pubid.name = _name + ".publish";
- linkid.category = id.category;
- linkid.name = _name + ".link";
+ pubid.category = id.category;
+ pubid.name = _name + ".publish";
+ linkid.category = id.category;
+ linkid.name = _name + ".link";
}
_publisherPrx = _instance->objectAdapter()->add(new PublisherI(this), pubid);
@@ -149,20 +149,20 @@ TopicI::TopicI(
//
for(LinkRecordSeq::const_iterator p = _topicRecord.begin(); p != _topicRecord.end(); ++p)
{
- TraceLevelsPtr traceLevels = _instance->traceLevels();
- if(traceLevels->topic > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
- out << _name << " relink " << _instance->communicator()->identityToString(p->theTopic->ice_getIdentity());
- }
-
- //
- // Create the subscriber object add it to the set of
- // subscribers.
- //
- SubscriberPtr subscriber = Subscriber::create(_instance, p->obj, p->cost);
- _subscribers.push_back(subscriber);
- _instance->subscriberPool()->add(subscriber);
+ TraceLevelsPtr traceLevels = _instance->traceLevels();
+ if(traceLevels->topic > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
+ out << _name << " relink " << _instance->communicator()->identityToString(p->theTopic->ice_getIdentity());
+ }
+
+ //
+ // Create the subscriber object add it to the set of
+ // subscribers.
+ //
+ SubscriberPtr subscriber = Subscriber::create(_instance, p->obj, p->cost);
+ _subscribers.push_back(subscriber);
+ _instance->subscriberPool()->add(subscriber);
}
}
@@ -193,11 +193,11 @@ find(vector<SubscriberPtr>::iterator start, vector<SubscriberPtr>::iterator end,
{
while(start != end)
{
- if(*start == ident)
- {
- return start;
- }
- ++start;
+ if(*start == ident)
+ {
+ return start;
+ }
+ ++start;
}
return end;
}
@@ -211,74 +211,74 @@ TopicI::subscribe(const QoS& origQoS, const Ice::ObjectPrx& obj, const Ice::Curr
QoS qos = origQoS;
if(traceLevels->topic > 0)
{
- Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
- out << "Subscribe: " << _instance->communicator()->identityToString(id);
- if(traceLevels->topic > 1)
- {
- out << " QoS: ";
- for(QoS::const_iterator p = qos.begin(); p != qos.end() ; ++p)
- {
- if(p != qos.begin())
- {
- out << ',';
- }
- out << '[' << p->first << "," << p->second << ']';
- }
- }
+ Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
+ out << "Subscribe: " << _instance->communicator()->identityToString(id);
+ if(traceLevels->topic > 1)
+ {
+ out << " QoS: ";
+ for(QoS::const_iterator p = qos.begin(); p != qos.end() ; ++p)
+ {
+ if(p != qos.begin())
+ {
+ out << ',';
+ }
+ out << '[' << p->first << "," << p->second << ']';
+ }
+ }
}
string reliability = "oneway";
{
- QoS::iterator p = qos.find("reliability");
- if(p != qos.end())
- {
- reliability = p->second;
- qos.erase(p);
- }
+ QoS::iterator p = qos.find("reliability");
+ if(p != qos.end())
+ {
+ reliability = p->second;
+ qos.erase(p);
+ }
}
Ice::ObjectPrx newObj = obj;
if(reliability == "batch")
{
- if(newObj->ice_isDatagram())
- {
- newObj = newObj->ice_batchDatagram();
- }
- else
- {
- newObj = newObj->ice_batchOneway();
- }
+ if(newObj->ice_isDatagram())
+ {
+ newObj = newObj->ice_batchDatagram();
+ }
+ else
+ {
+ newObj = newObj->ice_batchOneway();
+ }
}
else if(reliability == "twoway")
{
- newObj = newObj->ice_twoway();
+ newObj = newObj->ice_twoway();
}
else if(reliability == "twoway ordered")
{
- qos["reliability"] = "ordered";
- newObj = newObj->ice_twoway();
+ qos["reliability"] = "ordered";
+ newObj = newObj->ice_twoway();
}
else // reliability == "oneway"
{
- if(reliability != "oneway" && traceLevels->subscriber > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->subscriberCat);
- out << reliability <<" mode not understood.";
- }
- if(!newObj->ice_isDatagram())
- {
- newObj = newObj->ice_oneway();
- }
+ if(reliability != "oneway" && traceLevels->subscriber > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->subscriberCat);
+ out << reliability <<" mode not understood.";
+ }
+ if(!newObj->ice_isDatagram())
+ {
+ newObj = newObj->ice_oneway();
+ }
}
IceUtil::Mutex::Lock sync(_subscribersMutex);
vector<SubscriberPtr>::iterator p = find(_subscribers.begin(), _subscribers.end(), id);
if(p != _subscribers.end())
{
- (*p)->destroy();
- _instance->subscriberPool()->remove(*p);
- _subscribers.erase(p);
+ (*p)->destroy();
+ _instance->subscriberPool()->remove(*p);
+ _subscribers.erase(p);
}
SubscriberPtr subscriber = Subscriber::create(_instance, newObj, qos);
@@ -293,27 +293,27 @@ TopicI::subscribeAndGetPublisher(const QoS& qos, const Ice::ObjectPrx& obj, cons
TraceLevelsPtr traceLevels = _instance->traceLevels();
if(traceLevels->topic > 0)
{
- Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
- out << "Subscribe: " << _instance->communicator()->identityToString(id);
- if(traceLevels->topic > 1)
- {
- out << " QoS: ";
- for(QoS::const_iterator p = qos.begin(); p != qos.end() ; ++p)
- {
- if(p != qos.begin())
- {
- out << ',';
- }
- out << '[' << p->first << "," << p->second << ']';
- }
- }
+ Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
+ out << "Subscribe: " << _instance->communicator()->identityToString(id);
+ if(traceLevels->topic > 1)
+ {
+ out << " QoS: ";
+ for(QoS::const_iterator p = qos.begin(); p != qos.end() ; ++p)
+ {
+ if(p != qos.begin())
+ {
+ out << ',';
+ }
+ out << '[' << p->first << "," << p->second << ']';
+ }
+ }
}
IceUtil::Mutex::Lock sync(_subscribersMutex);
vector<SubscriberPtr>::iterator p = find(_subscribers.begin(), _subscribers.end(), id);
if(p != _subscribers.end())
{
- throw AlreadySubscribed();
+ throw AlreadySubscribed();
}
SubscriberPtr subscriber = Subscriber::create(_instance, obj, qos);
@@ -329,20 +329,20 @@ TopicI::unsubscribe(const Ice::ObjectPrx& subscriber, const Ice::Current&)
TraceLevelsPtr traceLevels = _instance->traceLevels();
if(!subscriber)
{
- if(traceLevels->topic > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
- out << "unsubscribe with null subscriber.";
- }
- return;
+ if(traceLevels->topic > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
+ out << "unsubscribe with null subscriber.";
+ }
+ return;
}
Ice::Identity id = subscriber->ice_getIdentity();
if(traceLevels->topic > 0)
{
- Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
- out << "Unsubscribe: " << _instance->communicator()->identityToString(id);
+ Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
+ out << "Unsubscribe: " << _instance->communicator()->identityToString(id);
}
//
@@ -367,7 +367,7 @@ TopicI::link(const TopicPrx& topic, Ice::Int cost, const Ice::Current&)
IceUtil::RecMutex::Lock topicSync(_topicRecordMutex);
if(_destroyed)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
}
reap();
@@ -379,20 +379,20 @@ TopicI::link(const TopicPrx& topic, Ice::Int cost, const Ice::Current&)
// link.
for(LinkRecordSeq::const_iterator p = _topicRecord.begin(); p != _topicRecord.end(); ++p)
{
- if(p->theTopic->ice_getIdentity() == topic->ice_getIdentity())
- {
- LinkExists ex;
- ex.name = name;
- throw ex;
- }
+ if(p->theTopic->ice_getIdentity() == topic->ice_getIdentity())
+ {
+ LinkExists ex;
+ ex.name = name;
+ throw ex;
+ }
}
TraceLevelsPtr traceLevels = _instance->traceLevels();
if(traceLevels->topic > 0)
{
- Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
- out << _name << " link " << _instance->communicator()->identityToString(id)
- << " cost " << cost;
+ Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
+ out << _name << " link " << _instance->communicator()->identityToString(id)
+ << " cost " << cost;
}
SubscriberPtr subscriber = Subscriber::create(_instance, link, cost);
@@ -422,7 +422,7 @@ TopicI::unlink(const TopicPrx& topic, const Ice::Current& current)
IceUtil::RecMutex::Lock topicSync(_topicRecordMutex);
if(_destroyed)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
}
reap();
@@ -433,24 +433,24 @@ TopicI::unlink(const TopicPrx& topic, const Ice::Current& current)
LinkRecordSeq::iterator p = _topicRecord.begin();
while(p != _topicRecord.end())
{
- if(p->theTopic->ice_getIdentity() == topic->ice_getIdentity())
- {
- break;
- }
- ++p;
+ if(p->theTopic->ice_getIdentity() == topic->ice_getIdentity())
+ {
+ break;
+ }
+ ++p;
}
if(p == _topicRecord.end())
{
- TraceLevelsPtr traceLevels = _instance->traceLevels();
- if(traceLevels->topic > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
- out << _name << " unlink " << name << " failed - not linked";
- }
+ TraceLevelsPtr traceLevels = _instance->traceLevels();
+ if(traceLevels->topic > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
+ out << _name << " unlink " << name << " failed - not linked";
+ }
- NoSuchLink ex;
- ex.name = name;
- throw ex;
+ NoSuchLink ex;
+ ex.name = name;
+ throw ex;
}
Ice::ObjectPrx subscriber = p->obj;
@@ -464,8 +464,8 @@ TopicI::unlink(const TopicPrx& topic, const Ice::Current& current)
TraceLevelsPtr traceLevels = _instance->traceLevels();
if(traceLevels->topic > 0)
{
- Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
- out << _name << " unlink " << _instance->communicator()->identityToString(id);
+ Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
+ out << _name << " unlink " << _instance->communicator()->identityToString(id);
}
removeSubscriber(subscriber);
}
@@ -481,11 +481,11 @@ TopicI::getLinkInfoSeq(const Ice::Current&) const
for(LinkRecordSeq::const_iterator q = _topicRecord.begin(); q != _topicRecord.end(); ++q)
{
- LinkInfo info;
- info.name = identityToTopicName(q->theTopic->ice_getIdentity());
- info.cost = q->cost;
- info.theTopic = q->theTopic;
- seq.push_back(info);
+ LinkInfo info;
+ info.name = identityToTopicName(q->theTopic->ice_getIdentity());
+ info.cost = q->cost;
+ info.theTopic = q->theTopic;
+ seq.push_back(info);
}
return seq;
@@ -498,18 +498,18 @@ TopicI::destroy(const Ice::Current&)
if(_destroyed)
{
- throw Ice::ObjectNotExistException(__FILE__, __LINE__);
+ throw Ice::ObjectNotExistException(__FILE__, __LINE__);
}
_destroyed = true;
try
{
- _instance->objectAdapter()->remove(_linkPrx->ice_getIdentity());
- _instance->objectAdapter()->remove(_publisherPrx->ice_getIdentity());
+ _instance->objectAdapter()->remove(_linkPrx->ice_getIdentity());
+ _instance->objectAdapter()->remove(_publisherPrx->ice_getIdentity());
}
catch(const Ice::ObjectAdapterDeactivatedException&)
{
- // Ignore -- this could occur on shutdown.
+ // Ignore -- this could occur on shutdown.
}
}
@@ -533,7 +533,7 @@ TopicI::reap()
IceUtil::RecMutex::Lock topicSync(_topicRecordMutex);
if(_destroyed)
{
- return;
+ return;
}
bool updated = false;
@@ -543,46 +543,46 @@ TopicI::reap()
//
list<SubscriberPtr> error;
{
- IceUtil::Mutex::Lock errorSync(_errorMutex);
- _error.swap(error);
+ IceUtil::Mutex::Lock errorSync(_errorMutex);
+ _error.swap(error);
}
TraceLevelsPtr traceLevels = _instance->traceLevels();
for(list<SubscriberPtr>::const_iterator p = error.begin(); p != error.end(); ++p)
{
- SubscriberPtr subscriber = *p;
- assert(subscriber->persistent()); // Only persistent subscribers need to be reaped.
-
- bool found = false;
- //
- // If this turns out to be a performance problem then we
- // can create an in memory map cache.
- //
- LinkRecordSeq::iterator q = _topicRecord.begin();
- while(q != _topicRecord.end())
- {
- if(q->obj->ice_getIdentity() == subscriber->id())
- {
- _topicRecord.erase(q);
- updated = true;
- found = true;
- break;
- }
- ++q;
- }
- if(traceLevels->topic > 0)
- {
- Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
- out << "reaping " << _instance->communicator()->identityToString(subscriber->id());
- if(!found)
- {
- out << ": failed - not in database";
- }
- }
+ SubscriberPtr subscriber = *p;
+ assert(subscriber->persistent()); // Only persistent subscribers need to be reaped.
+
+ bool found = false;
+ //
+ // If this turns out to be a performance problem then we
+ // can create an in memory map cache.
+ //
+ LinkRecordSeq::iterator q = _topicRecord.begin();
+ while(q != _topicRecord.end())
+ {
+ if(q->obj->ice_getIdentity() == subscriber->id())
+ {
+ _topicRecord.erase(q);
+ updated = true;
+ found = true;
+ break;
+ }
+ ++q;
+ }
+ if(traceLevels->topic > 0)
+ {
+ Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
+ out << "reaping " << _instance->communicator()->identityToString(subscriber->id());
+ if(!found)
+ {
+ out << ": failed - not in database";
+ }
+ }
}
if(updated)
{
- _topics.put(PersistentTopicMap::value_type(_id, _topicRecord));
+ _topics.put(PersistentTopicMap::value_type(_id, _topicRecord));
}
}
@@ -595,8 +595,8 @@ TopicI::publish(bool forwarded, const EventDataSeq& events)
//
vector<SubscriberPtr> copy;
{
- IceUtil::Mutex::Lock sync(_subscribersMutex);
- copy = _subscribers;
+ IceUtil::Mutex::Lock sync(_subscribersMutex);
+ copy = _subscribers;
}
//
@@ -608,18 +608,18 @@ TopicI::publish(bool forwarded, const EventDataSeq& events)
list<SubscriberPtr> flush;
for(vector<SubscriberPtr>::const_iterator p = copy.begin(); p != copy.end(); ++p)
{
- Subscriber::QueueState state = (*p)->queue(forwarded, events);
- switch(state)
- {
- case Subscriber::QueueStateError:
- e.push_back((*p)->id());
- break;
- case Subscriber::QueueStateFlush:
- flush.push_back(*p);
- break;
- case Subscriber::QueueStateNoFlush:
- break;
- }
+ Subscriber::QueueState state = (*p)->queue(forwarded, events);
+ switch(state)
+ {
+ case Subscriber::QueueStateError:
+ e.push_back((*p)->id());
+ break;
+ case Subscriber::QueueStateFlush:
+ flush.push_back(*p);
+ break;
+ case Subscriber::QueueStateNoFlush:
+ break;
+ }
}
//
@@ -627,7 +627,7 @@ TopicI::publish(bool forwarded, const EventDataSeq& events)
//
if(!flush.empty())
{
- _instance->subscriberPool()->flush(flush);
+ _instance->subscriberPool()->flush(flush);
}
//
@@ -637,48 +637,48 @@ TopicI::publish(bool forwarded, const EventDataSeq& events)
list<SubscriberPtr> reap;
if(!e.empty())
{
- IceUtil::Mutex::Lock sync(_subscribersMutex);
- for(vector<Ice::Identity>::const_iterator ep = e.begin(); ep != e.end(); ++ep)
- {
- //
- // Its possible for the subscriber to already have been
- // removed since the copy is iterated over outside of
- // mutex protection.
- //
- // Note that although this could be quicker if we used a
- // map, the most optimal case should be pushing around
- // events not searching for a particular subscriber.
- //
- // The subscriber is immediately destroyed & removed from
- // the _subscribers list. If the subscriber is persistent
- // its added to an list of error'd subscribers and removed
- // from the database on the next reap.
- //
- vector<SubscriberPtr>::iterator q = find(_subscribers.begin(), _subscribers.end(), *ep);
- if(q != _subscribers.end())
- {
- //
- // Destroy the subscriber in any case.
- //
- (*q)->destroy();
- if((*q)->persistent())
- {
- reap.push_back(*q);
- }
- _instance->subscriberPool()->remove(*q);
- _subscribers.erase(q);
- }
- }
+ IceUtil::Mutex::Lock sync(_subscribersMutex);
+ for(vector<Ice::Identity>::const_iterator ep = e.begin(); ep != e.end(); ++ep)
+ {
+ //
+ // Its possible for the subscriber to already have been
+ // removed since the copy is iterated over outside of
+ // mutex protection.
+ //
+ // Note that although this could be quicker if we used a
+ // map, the most optimal case should be pushing around
+ // events not searching for a particular subscriber.
+ //
+ // The subscriber is immediately destroyed & removed from
+ // the _subscribers list. If the subscriber is persistent
+ // its added to an list of error'd subscribers and removed
+ // from the database on the next reap.
+ //
+ vector<SubscriberPtr>::iterator q = find(_subscribers.begin(), _subscribers.end(), *ep);
+ if(q != _subscribers.end())
+ {
+ //
+ // Destroy the subscriber in any case.
+ //
+ (*q)->destroy();
+ if((*q)->persistent())
+ {
+ reap.push_back(*q);
+ }
+ _instance->subscriberPool()->remove(*q);
+ _subscribers.erase(q);
+ }
+ }
}
if(!reap.empty())
{
- //
- // This is why _error is a list, so we can splice on the
- // reaped subscribers.
- //
- IceUtil::Mutex::Lock errorSync(_errorMutex);
- _error.splice(_error.begin(), reap);
+ //
+ // This is why _error is a list, so we can splice on the
+ // reaped subscribers.
+ //
+ IceUtil::Mutex::Lock errorSync(_errorMutex);
+ _error.splice(_error.begin(), reap);
}
}
@@ -691,10 +691,10 @@ TopicI::removeSubscriber(const Ice::ObjectPrx& obj)
vector<SubscriberPtr>::iterator p = find(_subscribers.begin(), _subscribers.end(), id);
if(p != _subscribers.end())
{
- (*p)->destroy();
- _instance->subscriberPool()->remove(*p);
- _subscribers.erase(p);
- return;
+ (*p)->destroy();
+ _instance->subscriberPool()->remove(*p);
+ _subscribers.erase(p);
+ return;
}
//
@@ -703,7 +703,7 @@ TopicI::removeSubscriber(const Ice::ObjectPrx& obj)
TraceLevelsPtr traceLevels = _instance->traceLevels();
if(traceLevels->topic > 0)
{
- Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
- out << _instance->communicator()->identityToString(id) << ": not subscribed.";
+ Ice::Trace out(traceLevels->logger, traceLevels->topicCat);
+ out << _instance->communicator()->identityToString(id) << ": not subscribed.";
}
}
diff --git a/cpp/src/IceStorm/TopicI.h b/cpp/src/IceStorm/TopicI.h
index 2ec61aee3c2..8db61085fa3 100644
--- a/cpp/src/IceStorm/TopicI.h
+++ b/cpp/src/IceStorm/TopicI.h
@@ -29,7 +29,7 @@ class TopicI : public TopicInternal
public:
TopicI(const InstancePtr&, const std::string&, const Ice::Identity&, const LinkRecordSeq&, const std::string&,
- const std::string&);
+ const std::string&);
~TopicI();
virtual std::string getName(const Ice::Current&) const;
diff --git a/cpp/src/IceStorm/TopicManagerI.cpp b/cpp/src/IceStorm/TopicManagerI.cpp
index 12c9706ceaa..f8ab5fe80bd 100644
--- a/cpp/src/IceStorm/TopicManagerI.cpp
+++ b/cpp/src/IceStorm/TopicManagerI.cpp
@@ -37,7 +37,7 @@ identityToTopicName(const Ice::Identity& id)
//
if(id.category.empty())
{
- return id.name;
+ return id.name;
}
assert(id.name.length() > 6 && id.name.compare(0, 6, "topic.") == 0);
@@ -63,7 +63,7 @@ TopicManagerI::TopicManagerI(
//
for(PersistentTopicMap::const_iterator p = _topics.begin(); p != _topics.end(); ++p)
{
- installTopic(identityToTopicName(p->first), p->first, p->second, false);
+ installTopic(identityToTopicName(p->first), p->first, p->second, false);
}
}
@@ -80,7 +80,7 @@ TopicManagerI::create(const string& name, const Ice::Current&)
if(_topicIMap.find(name) != _topicIMap.end())
{
TopicExists ex;
- ex.name = name;
+ ex.name = name;
throw ex;
}
@@ -105,9 +105,9 @@ TopicManagerI::retrieve(const string& name, const Ice::Current&) const
TopicIMap::const_iterator p = _topicIMap.find(name);
if(p == _topicIMap.end())
{
- NoSuchTopic ex;
- ex.name = name;
- throw ex;
+ NoSuchTopic ex;
+ ex.name = name;
+ throw ex;
}
// Here we cannot just reconstruct the identity since the
@@ -127,13 +127,13 @@ TopicManagerI::retrieveAll(const Ice::Current&) const
TopicDict all;
for(TopicIMap::const_iterator p = _topicIMap.begin(); p != _topicIMap.end(); ++p)
{
- //
- // Here we cannot just reconstruct the identity since the
- // identity could be either "<instanceName>/topic.<topicname>"
- // name, or if created with pre-3.2 IceStorm "/<topicname>".
- //
+ //
+ // Here we cannot just reconstruct the identity since the
+ // identity could be either "<instanceName>/topic.<topicname>"
+ // name, or if created with pre-3.2 IceStorm "/<topicname>".
+ //
all.insert(TopicDict::value_type(
- p->first, TopicPrx::uncheckedCast(_topicAdapter->createProxy(p->second->id()))));
+ p->first, TopicPrx::uncheckedCast(_topicAdapter->createProxy(p->second->id()))));
}
return all;
@@ -158,8 +158,8 @@ TopicManagerI::reap()
{
if(i->second->destroyed())
{
- Ice::Identity id = i->second->id();
- TraceLevelsPtr traceLevels = _instance->traceLevels();
+ Ice::Identity id = i->second->id();
+ TraceLevelsPtr traceLevels = _instance->traceLevels();
if(traceLevels->topicMgr > 0)
{
Ice::Trace out(traceLevels->logger, traceLevels->topicMgrCat);
@@ -195,7 +195,7 @@ TopicManagerI::shutdown()
for(TopicIMap::const_iterator p = _topicIMap.begin(); p != _topicIMap.end(); ++p)
{
- p->second->reap();
+ p->second->reap();
}
}
@@ -208,17 +208,17 @@ TopicManagerI::installTopic(const string& name, const Ice::Identity& id, const L
TraceLevelsPtr traceLevels = _instance->traceLevels();
if(traceLevels->topicMgr > 0)
{
- Ice::Trace out(traceLevels->logger, traceLevels->topicMgrCat);
- if(create)
- {
- out << "creating new topic \"" << name << "\". id: "
- << _instance->communicator()->identityToString(id);
- }
- else
- {
- out << "loading topic \"" << name << "\" from database. id: "
- << _instance->communicator()->identityToString(id);
- }
+ Ice::Trace out(traceLevels->logger, traceLevels->topicMgrCat);
+ if(create)
+ {
+ out << "creating new topic \"" << name << "\". id: "
+ << _instance->communicator()->identityToString(id);
+ }
+ else
+ {
+ out << "loading topic \"" << name << "\" from database. id: "
+ << _instance->communicator()->identityToString(id);
+ }
}
//
diff --git a/cpp/src/IceStorm/TopicManagerI.h b/cpp/src/IceStorm/TopicManagerI.h
index 61e6f30e223..ebddf8a9156 100644
--- a/cpp/src/IceStorm/TopicManagerI.h
+++ b/cpp/src/IceStorm/TopicManagerI.h
@@ -38,9 +38,9 @@ class TopicManagerI : public TopicManager, public IceUtil::Mutex
public:
TopicManagerI(const InstancePtr&,
- const Ice::ObjectAdapterPtr&,
- const std::string&,
- const std::string&);
+ const Ice::ObjectAdapterPtr&,
+ const std::string&,
+ const std::string&);
~TopicManagerI();
virtual TopicPrx create(const std::string&, const Ice::Current&);
diff --git a/cpp/src/IceUtil/Cond.cpp b/cpp/src/IceUtil/Cond.cpp
index ab59e63958e..0f895980c9a 100644
--- a/cpp/src/IceUtil/Cond.cpp
+++ b/cpp/src/IceUtil/Cond.cpp
@@ -20,7 +20,7 @@ IceUtil::Semaphore::Semaphore(long initial)
_sem = CreateSemaphore(0, initial, 0x7fffffff, 0);
if(_sem == INVALID_HANDLE_VALUE)
{
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
}
@@ -35,7 +35,7 @@ IceUtil::Semaphore::wait() const
int rc = WaitForSingleObject(_sem, INFINITE);
if(rc != WAIT_OBJECT_0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
}
@@ -45,7 +45,7 @@ IceUtil::Semaphore::timedWait(const Time& timeout) const
int rc = WaitForSingleObject(_sem, static_cast<long>(timeout.toMilliSeconds()));
if(rc != WAIT_TIMEOUT && rc != WAIT_OBJECT_0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
return rc != WAIT_TIMEOUT;
}
@@ -56,7 +56,7 @@ IceUtil::Semaphore::post(int count) const
int rc = ReleaseSemaphore(_sem, count, 0);
if(rc == 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
}
@@ -95,26 +95,26 @@ IceUtil::Cond::wake(bool broadcast)
if(_unblocked != 0)
{
- _blocked -= _unblocked;
- _unblocked = 0;
+ _blocked -= _unblocked;
+ _unblocked = 0;
}
if(_blocked > 0)
{
- //
- // Unblock some number of waiters.
- //
- _toUnblock = (broadcast) ? _blocked : 1;
- _internal.unlock();
- _queue.post();
+ //
+ // Unblock some number of waiters.
+ //
+ _toUnblock = (broadcast) ? _blocked : 1;
+ _internal.unlock();
+ _queue.post();
}
else
{
- //
- // Otherwise no blocked waiters, release gate & mutex.
- //
- _gate.post();
- _internal.unlock();
+ //
+ // Otherwise no blocked waiters, release gate & mutex.
+ //
+ _gate.post();
+ _internal.unlock();
}
}
@@ -134,26 +134,26 @@ IceUtil::Cond::postWait(bool timedOut) const
if(_toUnblock != 0)
{
- bool last = --_toUnblock == 0;
- _internal.unlock();
-
- if(timedOut)
- {
- _queue.wait();
- }
-
- if(last)
- {
- _gate.post();
- }
- else
- {
- _queue.post();
- }
+ bool last = --_toUnblock == 0;
+ _internal.unlock();
+
+ if(timedOut)
+ {
+ _queue.wait();
+ }
+
+ if(last)
+ {
+ _gate.post();
+ }
+ else
+ {
+ _queue.post();
+ }
}
else
{
- _internal.unlock();
+ _internal.unlock();
}
}
@@ -162,13 +162,13 @@ IceUtil::Cond::dowait() const
{
try
{
- _queue.wait();
- postWait(false);
+ _queue.wait();
+ postWait(false);
}
catch(...)
{
- postWait(false);
- throw;
+ postWait(false);
+ throw;
}
}
@@ -177,14 +177,14 @@ IceUtil::Cond::timedDowait(const Time& timeout) const
{
try
{
- bool rc = _queue.timedWait(timeout);
- postWait(!rc);
- return rc;
+ bool rc = _queue.timedWait(timeout);
+ postWait(!rc);
+ return rc;
}
catch(...)
{
- postWait(false);
- throw;
+ postWait(false);
+ throw;
}
}
@@ -199,19 +199,19 @@ IceUtil::Cond::Cond()
rc = pthread_condattr_init(&attr);
if(rc != 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
rc = pthread_cond_init(&_cond, &attr);
if(rc != 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
rc = pthread_condattr_destroy(&attr);
if(rc != 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
}
@@ -228,7 +228,7 @@ IceUtil::Cond::signal()
int rc = pthread_cond_signal(&_cond);
if(rc != 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
}
@@ -238,7 +238,7 @@ IceUtil::Cond::broadcast()
int rc = pthread_cond_broadcast(&_cond);
if(rc != 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
}
diff --git a/cpp/src/IceUtil/ConvertUTF.cpp b/cpp/src/IceUtil/ConvertUTF.cpp
index 34a827163f9..f44aea0f0b5 100755
--- a/cpp/src/IceUtil/ConvertUTF.cpp
+++ b/cpp/src/IceUtil/ConvertUTF.cpp
@@ -36,10 +36,10 @@
Author: Mark E. Davis, 1994.
Rev History: Rick McGowan, fixes & updates May 2001.
Sept 2001: fixed const & error conditions per
- mods suggested by S. Parent & A. Lillich.
+ mods suggested by S. Parent & A. Lillich.
June 2002: Tim Dodd added detection and handling of incomplete
- source sequences, enhanced error detection, added casts
- to eliminate compiler warnings.
+ source sequences, enhanced error detection, added casts
+ to eliminate compiler warnings.
July 2003: slight mods to back out aggressive FFFE detection.
Jan 2004: updated switches in from-UTF8 conversions.
Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions.
@@ -67,8 +67,8 @@ static const UTF32 halfMask = 0x3FFUL;
#define UNI_SUR_HIGH_END (UTF32)0xDBFF
#define UNI_SUR_LOW_START (UTF32)0xDC00
#define UNI_SUR_LOW_END (UTF32)0xDFFF
-// #define false 0
-// #define true 1
+// #define false 0
+// #define true 1
/* --------------------------------------------------------------------- */
@@ -97,7 +97,7 @@ static const char trailingBytesForUTF8[256] = {
* in a UTF-8 sequence.
*/
static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL,
- 0x03C82080UL, 0xFA082080UL, 0x82082080UL };
+ 0x03C82080UL, 0xFA082080UL, 0x82082080UL };
/*
* Once the bits are split out into bytes of UTF-8, this is a mask OR-ed
@@ -121,67 +121,67 @@ static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC
/* --------------------------------------------------------------------- */
ConversionResult ConvertUTF16toUTF8 (
- const UTF16** sourceStart, const UTF16* sourceEnd,
- UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) {
+ const UTF16** sourceStart, const UTF16* sourceEnd,
+ UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) {
ConversionResult result = conversionOK;
const UTF16* source = *sourceStart;
UTF8* target = *targetStart;
while (source < sourceEnd) {
- UTF32 ch;
- unsigned short bytesToWrite = 0;
- const UTF32 byteMask = 0xBF;
- const UTF32 byteMark = 0x80;
- const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */
- ch = *source++;
- /* If we have a surrogate pair, convert to UTF32 first. */
- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {
- /* If the 16 bits following the high surrogate are in the source buffer... */
- if (source < sourceEnd) {
- UTF32 ch2 = *source;
- /* If it's a low surrogate, convert to UTF32. */
- if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) {
- ch = ((ch - UNI_SUR_HIGH_START) << halfShift)
- + (ch2 - UNI_SUR_LOW_START) + halfBase;
- ++source;
- } else if (flags == strictConversion) { /* it's an unpaired high surrogate */
- --source; /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- }
- } else { /* We don't have the 16 bits following the high surrogate. */
- --source; /* return to the high surrogate */
- result = sourceExhausted;
- break;
- }
- } else if (flags == strictConversion) {
- /* UTF-16 surrogate values are illegal in UTF-32 */
- if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
- --source; /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- }
- }
- /* Figure out how many bytes the result will require */
- if (ch < (UTF32)0x80) { bytesToWrite = 1;
- } else if (ch < (UTF32)0x800) { bytesToWrite = 2;
- } else if (ch < (UTF32)0x10000) { bytesToWrite = 3;
- } else if (ch < (UTF32)0x110000) { bytesToWrite = 4;
- } else { bytesToWrite = 3;
- ch = UNI_REPLACEMENT_CHAR;
- }
-
- target += bytesToWrite;
- if (target > targetEnd) {
- source = oldSource; /* Back up source pointer! */
- target -= bytesToWrite; result = targetExhausted; break;
- }
- switch (bytesToWrite) { /* note: everything falls through. */
- case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
- case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
- case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
- case 1: *--target = (UTF8)(ch | firstByteMark[bytesToWrite]);
- }
- target += bytesToWrite;
+ UTF32 ch;
+ unsigned short bytesToWrite = 0;
+ const UTF32 byteMask = 0xBF;
+ const UTF32 byteMark = 0x80;
+ const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */
+ ch = *source++;
+ /* If we have a surrogate pair, convert to UTF32 first. */
+ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {
+ /* If the 16 bits following the high surrogate are in the source buffer... */
+ if (source < sourceEnd) {
+ UTF32 ch2 = *source;
+ /* If it's a low surrogate, convert to UTF32. */
+ if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) {
+ ch = ((ch - UNI_SUR_HIGH_START) << halfShift)
+ + (ch2 - UNI_SUR_LOW_START) + halfBase;
+ ++source;
+ } else if (flags == strictConversion) { /* it's an unpaired high surrogate */
+ --source; /* return to the illegal value itself */
+ result = sourceIllegal;
+ break;
+ }
+ } else { /* We don't have the 16 bits following the high surrogate. */
+ --source; /* return to the high surrogate */
+ result = sourceExhausted;
+ break;
+ }
+ } else if (flags == strictConversion) {
+ /* UTF-16 surrogate values are illegal in UTF-32 */
+ if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
+ --source; /* return to the illegal value itself */
+ result = sourceIllegal;
+ break;
+ }
+ }
+ /* Figure out how many bytes the result will require */
+ if (ch < (UTF32)0x80) { bytesToWrite = 1;
+ } else if (ch < (UTF32)0x800) { bytesToWrite = 2;
+ } else if (ch < (UTF32)0x10000) { bytesToWrite = 3;
+ } else if (ch < (UTF32)0x110000) { bytesToWrite = 4;
+ } else { bytesToWrite = 3;
+ ch = UNI_REPLACEMENT_CHAR;
+ }
+
+ target += bytesToWrite;
+ if (target > targetEnd) {
+ source = oldSource; /* Back up source pointer! */
+ target -= bytesToWrite; result = targetExhausted; break;
+ }
+ switch (bytesToWrite) { /* note: everything falls through. */
+ case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
+ case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
+ case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
+ case 1: *--target = (UTF8)(ch | firstByteMark[bytesToWrite]);
+ }
+ target += bytesToWrite;
}
*sourceStart = source;
*targetStart = target;
@@ -206,19 +206,19 @@ static Boolean isLegalUTF8(const UTF8 *source, int length) {
const UTF8 *srcptr = source+length;
switch (length) {
default: return false;
- /* Everything else falls through when "true"... */
+ /* Everything else falls through when "true"... */
case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
case 2: if ((a = (*--srcptr)) > 0xBF) return false;
- switch (*source) {
- /* no fall-through in this inner switch */
- case 0xE0: if (a < 0xA0) return false; break;
- case 0xED: if (a > 0x9F) return false; break;
- case 0xF0: if (a < 0x90) return false; break;
- case 0xF4: if (a > 0x8F) return false; break;
- default: if (a < 0x80) return false;
- }
+ switch (*source) {
+ /* no fall-through in this inner switch */
+ case 0xE0: if (a < 0xA0) return false; break;
+ case 0xED: if (a > 0x9F) return false; break;
+ case 0xF0: if (a < 0x90) return false; break;
+ case 0xF4: if (a > 0x8F) return false; break;
+ default: if (a < 0x80) return false;
+ }
case 1: if (*source >= 0x80 && *source < 0xC2) return false;
}
@@ -238,89 +238,89 @@ Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) {
}
while(true) {
int length = trailingBytesForUTF8[*source]+1;
- // Is buffer big enough to contain character?
+ // Is buffer big enough to contain character?
if (source+length > sourceEnd) {
- return false;
+ return false;
}
- // Is character legal UTF8?
+ // Is character legal UTF8?
if(!isLegalUTF8(source, length)) {
- return false;
- }
- // Are we at end of buffer?
- source += length;
- if(source == sourceEnd) {
- return true;
- }
+ return false;
+ }
+ // Are we at end of buffer?
+ source += length;
+ if(source == sourceEnd) {
+ return true;
+ }
}
}
/* --------------------------------------------------------------------- */
ConversionResult ConvertUTF8toUTF16 (
- const UTF8** sourceStart, const UTF8* sourceEnd,
- UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) {
+ const UTF8** sourceStart, const UTF8* sourceEnd,
+ UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) {
ConversionResult result = conversionOK;
const UTF8* source = *sourceStart;
UTF16* target = *targetStart;
while (source < sourceEnd) {
- UTF32 ch = 0;
- unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
- if (source + extraBytesToRead >= sourceEnd) {
- result = sourceExhausted; break;
- }
- /* Do this check whether lenient or strict */
- if (! isLegalUTF8(source, extraBytesToRead+1)) {
- result = sourceIllegal;
- break;
- }
- /*
- * The cases all fall through. See "Note A" below.
- */
- switch (extraBytesToRead) {
- case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
- case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
- case 3: ch += *source++; ch <<= 6;
- case 2: ch += *source++; ch <<= 6;
- case 1: ch += *source++; ch <<= 6;
- case 0: ch += *source++;
- }
- ch -= offsetsFromUTF8[extraBytesToRead];
-
- if (target >= targetEnd) {
- source -= (extraBytesToRead+1); /* Back up source pointer! */
- result = targetExhausted; break;
- }
- if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */
- /* UTF-16 surrogate values are illegal in UTF-32 */
- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
- if (flags == strictConversion) {
- source -= (extraBytesToRead+1); /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- } else {
- *target++ = UNI_REPLACEMENT_CHAR;
- }
- } else {
- *target++ = (UTF16)ch; /* normal case */
- }
- } else if (ch > UNI_MAX_UTF16) {
- if (flags == strictConversion) {
- result = sourceIllegal;
- source -= (extraBytesToRead+1); /* return to the start */
- break; /* Bail out; shouldn't continue */
- } else {
- *target++ = UNI_REPLACEMENT_CHAR;
- }
- } else {
- /* target is a character in range 0xFFFF - 0x10FFFF. */
- if (target + 1 >= targetEnd) {
- source -= (extraBytesToRead+1); /* Back up source pointer! */
- result = targetExhausted; break;
- }
- ch -= halfBase;
- *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START);
- *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START);
- }
+ UTF32 ch = 0;
+ unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
+ if (source + extraBytesToRead >= sourceEnd) {
+ result = sourceExhausted; break;
+ }
+ /* Do this check whether lenient or strict */
+ if (! isLegalUTF8(source, extraBytesToRead+1)) {
+ result = sourceIllegal;
+ break;
+ }
+ /*
+ * The cases all fall through. See "Note A" below.
+ */
+ switch (extraBytesToRead) {
+ case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
+ case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
+ case 3: ch += *source++; ch <<= 6;
+ case 2: ch += *source++; ch <<= 6;
+ case 1: ch += *source++; ch <<= 6;
+ case 0: ch += *source++;
+ }
+ ch -= offsetsFromUTF8[extraBytesToRead];
+
+ if (target >= targetEnd) {
+ source -= (extraBytesToRead+1); /* Back up source pointer! */
+ result = targetExhausted; break;
+ }
+ if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */
+ /* UTF-16 surrogate values are illegal in UTF-32 */
+ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
+ if (flags == strictConversion) {
+ source -= (extraBytesToRead+1); /* return to the illegal value itself */
+ result = sourceIllegal;
+ break;
+ } else {
+ *target++ = UNI_REPLACEMENT_CHAR;
+ }
+ } else {
+ *target++ = (UTF16)ch; /* normal case */
+ }
+ } else if (ch > UNI_MAX_UTF16) {
+ if (flags == strictConversion) {
+ result = sourceIllegal;
+ source -= (extraBytesToRead+1); /* return to the start */
+ break; /* Bail out; shouldn't continue */
+ } else {
+ *target++ = UNI_REPLACEMENT_CHAR;
+ }
+ } else {
+ /* target is a character in range 0xFFFF - 0x10FFFF. */
+ if (target + 1 >= targetEnd) {
+ source -= (extraBytesToRead+1); /* Back up source pointer! */
+ result = targetExhausted; break;
+ }
+ ch -= halfBase;
+ *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START);
+ *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START);
+ }
}
*sourceStart = source;
*targetStart = target;
@@ -330,50 +330,50 @@ ConversionResult ConvertUTF8toUTF16 (
/* --------------------------------------------------------------------- */
ConversionResult ConvertUTF32toUTF8 (
- const UTF32** sourceStart, const UTF32* sourceEnd,
- UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) {
+ const UTF32** sourceStart, const UTF32* sourceEnd,
+ UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) {
ConversionResult result = conversionOK;
const UTF32* source = *sourceStart;
UTF8* target = *targetStart;
while (source < sourceEnd) {
- UTF32 ch;
- unsigned short bytesToWrite = 0;
- const UTF32 byteMask = 0xBF;
- const UTF32 byteMark = 0x80;
- ch = *source++;
- if (flags == strictConversion ) {
- /* UTF-16 surrogate values are illegal in UTF-32 */
- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
- --source; /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- }
- }
- /*
- * Figure out how many bytes the result will require. Turn any
- * illegally large UTF32 things (> Plane 17) into replacement chars.
- */
- if (ch < (UTF32)0x80) { bytesToWrite = 1;
- } else if (ch < (UTF32)0x800) { bytesToWrite = 2;
- } else if (ch < (UTF32)0x10000) { bytesToWrite = 3;
- } else if (ch <= UNI_MAX_LEGAL_UTF32) { bytesToWrite = 4;
- } else { bytesToWrite = 3;
- ch = UNI_REPLACEMENT_CHAR;
- result = sourceIllegal;
- }
-
- target += bytesToWrite;
- if (target > targetEnd) {
- --source; /* Back up source pointer! */
- target -= bytesToWrite; result = targetExhausted; break;
- }
- switch (bytesToWrite) { /* note: everything falls through. */
- case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
- case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
- case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
- case 1: *--target = (UTF8) (ch | firstByteMark[bytesToWrite]);
- }
- target += bytesToWrite;
+ UTF32 ch;
+ unsigned short bytesToWrite = 0;
+ const UTF32 byteMask = 0xBF;
+ const UTF32 byteMark = 0x80;
+ ch = *source++;
+ if (flags == strictConversion ) {
+ /* UTF-16 surrogate values are illegal in UTF-32 */
+ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
+ --source; /* return to the illegal value itself */
+ result = sourceIllegal;
+ break;
+ }
+ }
+ /*
+ * Figure out how many bytes the result will require. Turn any
+ * illegally large UTF32 things (> Plane 17) into replacement chars.
+ */
+ if (ch < (UTF32)0x80) { bytesToWrite = 1;
+ } else if (ch < (UTF32)0x800) { bytesToWrite = 2;
+ } else if (ch < (UTF32)0x10000) { bytesToWrite = 3;
+ } else if (ch <= UNI_MAX_LEGAL_UTF32) { bytesToWrite = 4;
+ } else { bytesToWrite = 3;
+ ch = UNI_REPLACEMENT_CHAR;
+ result = sourceIllegal;
+ }
+
+ target += bytesToWrite;
+ if (target > targetEnd) {
+ --source; /* Back up source pointer! */
+ target -= bytesToWrite; result = targetExhausted; break;
+ }
+ switch (bytesToWrite) { /* note: everything falls through. */
+ case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
+ case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
+ case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
+ case 1: *--target = (UTF8) (ch | firstByteMark[bytesToWrite]);
+ }
+ target += bytesToWrite;
}
*sourceStart = source;
*targetStart = target;
@@ -383,59 +383,59 @@ ConversionResult ConvertUTF32toUTF8 (
/* --------------------------------------------------------------------- */
ConversionResult ConvertUTF8toUTF32 (
- const UTF8** sourceStart, const UTF8* sourceEnd,
- UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) {
+ const UTF8** sourceStart, const UTF8* sourceEnd,
+ UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) {
ConversionResult result = conversionOK;
const UTF8* source = *sourceStart;
UTF32* target = *targetStart;
while (source < sourceEnd) {
- UTF32 ch = 0;
- unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
- if (source + extraBytesToRead >= sourceEnd) {
- result = sourceExhausted; break;
- }
- /* Do this check whether lenient or strict */
- if (! isLegalUTF8(source, extraBytesToRead+1)) {
- result = sourceIllegal;
- break;
- }
- /*
- * The cases all fall through. See "Note A" below.
- */
- switch (extraBytesToRead) {
- case 5: ch += *source++; ch <<= 6;
- case 4: ch += *source++; ch <<= 6;
- case 3: ch += *source++; ch <<= 6;
- case 2: ch += *source++; ch <<= 6;
- case 1: ch += *source++; ch <<= 6;
- case 0: ch += *source++;
- }
- ch -= offsetsFromUTF8[extraBytesToRead];
-
- if (target >= targetEnd) {
- source -= (extraBytesToRead+1); /* Back up the source pointer! */
- result = targetExhausted; break;
- }
- if (ch <= UNI_MAX_LEGAL_UTF32) {
- /*
- * UTF-16 surrogate values are illegal in UTF-32, and anything
- * over Plane 17 (> 0x10FFFF) is illegal.
- */
- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
- if (flags == strictConversion) {
- source -= (extraBytesToRead+1); /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- } else {
- *target++ = UNI_REPLACEMENT_CHAR;
- }
- } else {
- *target++ = ch;
- }
- } else { /* i.e., ch > UNI_MAX_LEGAL_UTF32 */
- result = sourceIllegal;
- *target++ = UNI_REPLACEMENT_CHAR;
- }
+ UTF32 ch = 0;
+ unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
+ if (source + extraBytesToRead >= sourceEnd) {
+ result = sourceExhausted; break;
+ }
+ /* Do this check whether lenient or strict */
+ if (! isLegalUTF8(source, extraBytesToRead+1)) {
+ result = sourceIllegal;
+ break;
+ }
+ /*
+ * The cases all fall through. See "Note A" below.
+ */
+ switch (extraBytesToRead) {
+ case 5: ch += *source++; ch <<= 6;
+ case 4: ch += *source++; ch <<= 6;
+ case 3: ch += *source++; ch <<= 6;
+ case 2: ch += *source++; ch <<= 6;
+ case 1: ch += *source++; ch <<= 6;
+ case 0: ch += *source++;
+ }
+ ch -= offsetsFromUTF8[extraBytesToRead];
+
+ if (target >= targetEnd) {
+ source -= (extraBytesToRead+1); /* Back up the source pointer! */
+ result = targetExhausted; break;
+ }
+ if (ch <= UNI_MAX_LEGAL_UTF32) {
+ /*
+ * UTF-16 surrogate values are illegal in UTF-32, and anything
+ * over Plane 17 (> 0x10FFFF) is illegal.
+ */
+ if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
+ if (flags == strictConversion) {
+ source -= (extraBytesToRead+1); /* return to the illegal value itself */
+ result = sourceIllegal;
+ break;
+ } else {
+ *target++ = UNI_REPLACEMENT_CHAR;
+ }
+ } else {
+ *target++ = ch;
+ }
+ } else { /* i.e., ch > UNI_MAX_LEGAL_UTF32 */
+ result = sourceIllegal;
+ *target++ = UNI_REPLACEMENT_CHAR;
+ }
}
*sourceStart = source;
*targetStart = target;
@@ -448,14 +448,14 @@ ConversionResult ConvertUTF8toUTF32 (
The fall-through switches in UTF-8 reading code save a
temp variable, some decrements & conditionals. The switches
are equivalent to the following loop:
- {
- int tmpBytesToRead = extraBytesToRead+1;
- do {
- ch += *source++;
- --tmpBytesToRead;
- if (tmpBytesToRead) ch <<= 6;
- } while (tmpBytesToRead > 0);
- }
+ {
+ int tmpBytesToRead = extraBytesToRead+1;
+ do {
+ ch += *source++;
+ --tmpBytesToRead;
+ if (tmpBytesToRead) ch <<= 6;
+ } while (tmpBytesToRead > 0);
+ }
In UTF-8 writing code, the switches on "bytesToWrite" are
similarly unrolled loops.
diff --git a/cpp/src/IceUtil/ConvertUTF.h b/cpp/src/IceUtil/ConvertUTF.h
index daa2e98db52..a70e62fd1a9 100755
--- a/cpp/src/IceUtil/ConvertUTF.h
+++ b/cpp/src/IceUtil/ConvertUTF.h
@@ -60,12 +60,12 @@
the respective buffers.
Input parameters:
- sourceStart - pointer to a pointer to the source buffer.
- The contents of this are modified on return so that
- it points at the next thing to be converted.
- targetStart - similarly, pointer to pointer to the target buffer.
- sourceEnd, targetEnd - respectively pointers to the ends of the
- two buffers, for overflow checking only.
+ sourceStart - pointer to a pointer to the source buffer.
+ The contents of this are modified on return so that
+ it points at the next thing to be converted.
+ targetStart - similarly, pointer to pointer to the target buffer.
+ sourceEnd, targetEnd - respectively pointers to the ends of the
+ two buffers, for overflow checking only.
These conversion functions take a ConversionFlags argument. When this
flag is set to strict, both irregular sequences and isolated surrogates
@@ -82,15 +82,15 @@
they constitute an error.
Output parameters:
- The value "sourceIllegal" is returned from some routines if the input
- sequence is malformed. When "sourceIllegal" is returned, the source
- value will point to the illegal value that caused the problem. E.g.,
- in UTF-8 when a sequence is malformed, it points to the start of the
- malformed sequence.
+ The value "sourceIllegal" is returned from some routines if the input
+ sequence is malformed. When "sourceIllegal" is returned, the source
+ value will point to the illegal value that caused the problem. E.g.,
+ in UTF-8 when a sequence is malformed, it points to the start of the
+ malformed sequence.
Author: Mark E. Davis, 1994.
Rev History: Rick McGowan, fixes & updates May 2001.
- Fixes & updates, Sept 2001.
+ Fixes & updates, Sept 2001.
------------------------------------------------------------------------ */
@@ -105,10 +105,10 @@
namespace IceUtil
{
-typedef unsigned int UTF32; /* at least 32 bits */
-typedef unsigned short UTF16; /* at least 16 bits */
-typedef unsigned char UTF8; /* typically 8 bits */
-typedef bool Boolean; /* 0 or 1 */
+typedef unsigned int UTF32; /* at least 32 bits */
+typedef unsigned short UTF16; /* at least 16 bits */
+typedef unsigned char UTF8; /* typically 8 bits */
+typedef bool Boolean; /* 0 or 1 */
/* Some fundamental constants */
#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
@@ -125,7 +125,7 @@ ConversionResult ConvertUTF8toUTF16(
ConversionResult ConvertUTF16toUTF8 (
const UTF16** sourceStart, const UTF16* sourceEnd,
UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
-
+
ConversionResult ConvertUTF8toUTF32(
const UTF8** sourceStart, const UTF8* sourceEnd,
UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
diff --git a/cpp/src/IceUtil/CountDownLatch.cpp b/cpp/src/IceUtil/CountDownLatch.cpp
index b30fe718242..c54cc51240d 100644
--- a/cpp/src/IceUtil/CountDownLatch.cpp
+++ b/cpp/src/IceUtil/CountDownLatch.cpp
@@ -15,26 +15,26 @@ IceUtil::CountDownLatch::CountDownLatch(int count) :
{
if(count < 0)
{
- throw Exception(__FILE__, __LINE__);
+ throw Exception(__FILE__, __LINE__);
}
#ifdef _WIN32
_event = CreateEvent(0, TRUE, FALSE, 0);
if(_event == 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
#else
int rc = pthread_mutex_init(&_mutex, 0);
if(rc != 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
rc = pthread_cond_init(&_cond, 0);
if(rc != 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
#endif
}
@@ -58,24 +58,24 @@ IceUtil::CountDownLatch::await() const
#ifdef _WIN32
while(InterlockedExchangeAdd(&_count, 0) > 0)
{
- DWORD rc = WaitForSingleObject(_event, INFINITE);
- assert(rc == WAIT_OBJECT_0 || rc == WAIT_FAILED);
-
- if(rc == WAIT_FAILED)
- {
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
- }
+ DWORD rc = WaitForSingleObject(_event, INFINITE);
+ assert(rc == WAIT_OBJECT_0 || rc == WAIT_FAILED);
+
+ if(rc == WAIT_FAILED)
+ {
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ }
}
#else
lock();
while(_count > 0)
{
- int rc = pthread_cond_wait(&_cond, &_mutex);
- if(rc != 0)
- {
- pthread_mutex_unlock(&_mutex);
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
- }
+ int rc = pthread_cond_wait(&_cond, &_mutex);
+ if(rc != 0)
+ {
+ pthread_mutex_unlock(&_mutex);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ }
}
unlock();
@@ -88,10 +88,10 @@ IceUtil::CountDownLatch::countDown()
#ifdef _WIN32
if(InterlockedDecrement(&_count) == 0)
{
- if(SetEvent(_event) == 0)
- {
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
- }
+ if(SetEvent(_event) == 0)
+ {
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ }
}
#else
bool broadcast = false;
@@ -99,7 +99,7 @@ IceUtil::CountDownLatch::countDown()
lock();
if(_count > 0 && --_count == 0)
{
- broadcast = true;
+ broadcast = true;
}
#if defined(__APPLE__)
//
@@ -108,12 +108,12 @@ IceUtil::CountDownLatch::countDown()
//
if(broadcast)
{
- int rc = pthread_cond_broadcast(&_cond);
- if(rc != 0)
- {
- pthread_mutex_unlock(&_mutex);
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
- }
+ int rc = pthread_cond_broadcast(&_cond);
+ if(rc != 0)
+ {
+ pthread_mutex_unlock(&_mutex);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ }
}
unlock();
@@ -122,11 +122,11 @@ IceUtil::CountDownLatch::countDown()
if(broadcast)
{
- int rc = pthread_cond_broadcast(&_cond);
- if(rc != 0)
- {
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
- }
+ int rc = pthread_cond_broadcast(&_cond);
+ if(rc != 0)
+ {
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ }
}
#endif
@@ -154,7 +154,7 @@ IceUtil::CountDownLatch::lock() const
int rc = pthread_mutex_lock(&_mutex);
if(rc != 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
}
@@ -164,7 +164,7 @@ IceUtil::CountDownLatch::unlock() const
int rc = pthread_mutex_unlock(&_mutex);
if(rc != 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
}
diff --git a/cpp/src/IceUtil/CtrlCHandler.cpp b/cpp/src/IceUtil/CtrlCHandler.cpp
index a11f36f09a6..21338923e4b 100644
--- a/cpp/src/IceUtil/CtrlCHandler.cpp
+++ b/cpp/src/IceUtil/CtrlCHandler.cpp
@@ -70,7 +70,7 @@ static BOOL WINAPI handlerRoutine(DWORD dwCtrlType)
CtrlCHandlerCallback callback = _handler->getCallback();
if(callback != 0)
{
- callback(dwCtrlType);
+ callback(dwCtrlType);
}
return TRUE;
}
@@ -81,14 +81,14 @@ CtrlCHandler::CtrlCHandler(CtrlCHandlerCallback callback)
StaticMutex::Lock lock(globalMutex);
if(_handler != 0)
{
- throw CtrlCHandlerException(__FILE__, __LINE__);
+ throw CtrlCHandlerException(__FILE__, __LINE__);
}
else
{
- _callback = callback;
- _handler = this;
- lock.release();
- SetConsoleCtrlHandler(handlerRoutine, TRUE);
+ _callback = callback;
+ _handler = this;
+ lock.release();
+ SetConsoleCtrlHandler(handlerRoutine, TRUE);
}
}
@@ -96,8 +96,8 @@ CtrlCHandler::~CtrlCHandler()
{
SetConsoleCtrlHandler(handlerRoutine, FALSE);
{
- StaticMutex::Lock lock(globalMutex);
- _handler = 0;
+ StaticMutex::Lock lock(globalMutex);
+ _handler = 0;
}
}
@@ -120,38 +120,38 @@ sigwaitThread(void*)
//
for(;;)
{
- int signal = 0;
- int rc = sigwait(&ctrlCLikeSignals, &signal);
+ int signal = 0;
+ int rc = sigwait(&ctrlCLikeSignals, &signal);
#if defined(__APPLE__)
- //
- // WORKAROUND: sigwait is not a cancelation point on MacOS X. To cancel this thread, the
- // destructor cancels the thread and send a signal to the thread to unblock sigwait, then
- // we explicitly test for cancellation.
- //
- pthread_testcancel();
+ //
+ // WORKAROUND: sigwait is not a cancelation point on MacOS X. To cancel this thread, the
+ // destructor cancels the thread and send a signal to the thread to unblock sigwait, then
+ // we explicitly test for cancellation.
+ //
+ pthread_testcancel();
#endif
- //
- // Some sigwait() implementations incorrectly return EINTR
- // when interrupted by an unblocked caught signal
- //
- if(rc == EINTR)
- {
- continue;
- }
- assert(rc == 0);
-
- rc = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, 0);
- assert(rc == 0);
-
- CtrlCHandlerCallback callback = _handler->getCallback();
-
- if(callback != 0)
- {
- callback(signal);
- }
-
- rc = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0);
- assert(rc == 0);
+ //
+ // Some sigwait() implementations incorrectly return EINTR
+ // when interrupted by an unblocked caught signal
+ //
+ if(rc == EINTR)
+ {
+ continue;
+ }
+ assert(rc == 0);
+
+ rc = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, 0);
+ assert(rc == 0);
+
+ CtrlCHandlerCallback callback = _handler->getCallback();
+
+ if(callback != 0)
+ {
+ callback(signal);
+ }
+
+ rc = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0);
+ assert(rc == 0);
}
return 0;
}
@@ -164,29 +164,29 @@ CtrlCHandler::CtrlCHandler(CtrlCHandlerCallback callback)
StaticMutex::Lock lock(globalMutex);
if(_handler != 0)
{
- throw CtrlCHandlerException(__FILE__, __LINE__);
+ throw CtrlCHandlerException(__FILE__, __LINE__);
}
else
{
- _callback = callback;
- _handler = this;
- lock.release();
-
- // We block these CTRL+C like signals in the main thread,
- // and by default all other threads will inherit this signal
- // disposition.
-
- sigset_t ctrlCLikeSignals;
- sigemptyset(&ctrlCLikeSignals);
- sigaddset(&ctrlCLikeSignals, SIGHUP);
- sigaddset(&ctrlCLikeSignals, SIGINT);
- sigaddset(&ctrlCLikeSignals, SIGTERM);
- int rc = pthread_sigmask(SIG_BLOCK, &ctrlCLikeSignals, 0);
- assert(rc == 0);
-
- // Joinable thread
- rc = pthread_create(&_tid, 0, sigwaitThread, 0);
- assert(rc == 0);
+ _callback = callback;
+ _handler = this;
+ lock.release();
+
+ // We block these CTRL+C like signals in the main thread,
+ // and by default all other threads will inherit this signal
+ // disposition.
+
+ sigset_t ctrlCLikeSignals;
+ sigemptyset(&ctrlCLikeSignals);
+ sigaddset(&ctrlCLikeSignals, SIGHUP);
+ sigaddset(&ctrlCLikeSignals, SIGINT);
+ sigaddset(&ctrlCLikeSignals, SIGTERM);
+ int rc = pthread_sigmask(SIG_BLOCK, &ctrlCLikeSignals, 0);
+ assert(rc == 0);
+
+ // Joinable thread
+ rc = pthread_create(&_tid, 0, sigwaitThread, 0);
+ assert(rc == 0);
}
}
@@ -209,8 +209,8 @@ CtrlCHandler::~CtrlCHandler()
assert(status == PTHREAD_CANCELED);
#endif
{
- StaticMutex::Lock lock(globalMutex);
- _handler = 0;
+ StaticMutex::Lock lock(globalMutex);
+ _handler = 0;
}
}
diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp
index c7619eadcd3..adcced92d33 100644
--- a/cpp/src/IceUtil/Exception.cpp
+++ b/cpp/src/IceUtil/Exception.cpp
@@ -47,7 +47,7 @@ IceUtil::Exception::ice_print(ostream& out) const
{
if(_file && _line > 0)
{
- out << _file << ':' << _line << ": ";
+ out << _file << ':' << _line << ": ";
}
out << ice_name();
}
@@ -88,7 +88,7 @@ IceUtil::NullHandleException::NullHandleException(const char* file, int line) :
{
if(nullHandleAbort)
{
- abort();
+ abort();
}
}
diff --git a/cpp/src/IceUtil/InputUtil.cpp b/cpp/src/IceUtil/InputUtil.cpp
index b8cdb278e9f..293bd8b2107 100644
--- a/cpp/src/IceUtil/InputUtil.cpp
+++ b/cpp/src/IceUtil/InputUtil.cpp
@@ -36,11 +36,11 @@ static const string allDigits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//
static const char digitVal[] =
{
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // '0' - '9'
- 100, 100, 100, 100, 100, 100, 100, // punctuation
- 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, // 'A' - 'J'
- 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, // 'K' - 'T'
- 30, 31, 32, 33, 34, 35 // 'U' - 'Z'
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, // '0' - '9'
+ 100, 100, 100, 100, 100, 100, 100, // punctuation
+ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, // 'A' - 'J'
+ 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, // 'K' - 'T'
+ 30, 31, 32, 33, 34, 35 // 'U' - 'Z'
};
static IceUtil::Int64
@@ -51,7 +51,7 @@ strToInt64Impl(const char* s, char** endptr, int base)
//
if(endptr)
{
- *endptr = const_cast<char *>(s);
+ *endptr = const_cast<char *>(s);
}
//
@@ -59,7 +59,7 @@ strToInt64Impl(const char* s, char** endptr, int base)
//
while(*s && isspace(*s))
{
- ++s;
+ ++s;
}
//
@@ -68,12 +68,12 @@ strToInt64Impl(const char* s, char** endptr, int base)
int sign = 1;
if(*s == '+')
{
- ++s;
+ ++s;
}
else if(*s == '-')
{
- sign = -1;
- ++s;
+ sign = -1;
+ ++s;
}
//
@@ -81,34 +81,34 @@ strToInt64Impl(const char* s, char** endptr, int base)
//
if(base == 0)
{
- if(*s == '0')
- {
- base = 8;
- ++s;
-
- //
- // We have at least this zero
- //
- if(endptr)
- {
- *endptr = const_cast<char *>(s);
- }
-
- if(*s == 'x' || *s == 'X')
- {
- base = 16;
- ++s;
- }
- }
- else
- {
- base = 10;
- }
+ if(*s == '0')
+ {
+ base = 8;
+ ++s;
+
+ //
+ // We have at least this zero
+ //
+ if(endptr)
+ {
+ *endptr = const_cast<char *>(s);
+ }
+
+ if(*s == 'x' || *s == 'X')
+ {
+ base = 16;
+ ++s;
+ }
+ }
+ else
+ {
+ base = 10;
+ }
}
else if(base < 2 || base > 36)
{
- errno = EINVAL;
- return 0;
+ errno = EINVAL;
+ return 0;
}
//
@@ -116,10 +116,10 @@ strToInt64Impl(const char* s, char** endptr, int base)
//
if(*s == '\0')
{
- //
- // We did not read any new digit so we don't update endptr
- //
- return 0;
+ //
+ // We did not read any new digit so we don't update endptr
+ //
+ return 0;
}
Int64 result = 0;
@@ -127,43 +127,43 @@ strToInt64Impl(const char* s, char** endptr, int base)
bool digitFound = false;
const string validDigits(allDigits.begin(), allDigits.begin() + base);
while(*s && validDigits.find_first_of(toupper(*s)) != validDigits.npos)
- {
- digitFound = true;
- if(!overflow)
- {
- int digit = digitVal[toupper(*s) - '0'];
- assert(digit != 100);
- if(result < _I64_MAX / base)
- {
- result *= base;
- result += digit;
- }
- else if((digit <= _I64_MAX % base) || (sign == -1 && digit == _I64_MAX % base + 1))
- {
- result *= base;
- result += digit;
- }
- else
- {
- overflow = true;
- result = sign == -1 ? _I64_MIN : _I64_MAX;
- }
- }
- ++s;
+ {
+ digitFound = true;
+ if(!overflow)
+ {
+ int digit = digitVal[toupper(*s) - '0'];
+ assert(digit != 100);
+ if(result < _I64_MAX / base)
+ {
+ result *= base;
+ result += digit;
+ }
+ else if((digit <= _I64_MAX % base) || (sign == -1 && digit == _I64_MAX % base + 1))
+ {
+ result *= base;
+ result += digit;
+ }
+ else
+ {
+ overflow = true;
+ result = sign == -1 ? _I64_MIN : _I64_MAX;
+ }
+ }
+ ++s;
}
if(overflow)
{
- errno = ERANGE;
+ errno = ERANGE;
}
else
{
- result *= sign;
+ result *= sign;
}
if(digitFound && endptr != 0)
{
- *endptr = const_cast<char *>(s);
+ *endptr = const_cast<char *>(s);
}
return result;
diff --git a/cpp/src/IceUtil/MD5I.cpp b/cpp/src/IceUtil/MD5I.cpp
index dc96955a36a..ac5be31483e 100644
--- a/cpp/src/IceUtil/MD5I.cpp
+++ b/cpp/src/IceUtil/MD5I.cpp
@@ -27,7 +27,7 @@
This code implements the MD5 Algorithm defined in RFC 1321, whose
text is available at
- http://www.ietf.org/rfc/rfc1321.txt
+ http://www.ietf.org/rfc/rfc1321.txt
The code is derived from the text of the RFC, including the test suite
(section A.5) but excluding the rest of Appendix A. It does not include
any code or documentation that is identified in the RFC as being
@@ -38,14 +38,14 @@
that follows (in reverse chronological order):
2002-04-13 lpd Clarified derivation from RFC 1321; now handles byte order
- either statically or dynamically; added missing #include <string.h>
- in library.
+ either statically or dynamically; added missing #include <string.h>
+ in library.
2002-03-11 lpd Corrected argument list for main(), and added int return
- type, in test program and T value program.
+ type, in test program and T value program.
2002-02-21 lpd Added missing #include <stdio.h> in test program.
2000-07-03 lpd Patched to eliminate warnings about "constant is
- unsigned in ANSI C, signed in traditional"; made test program
- self-checking.
+ unsigned in ANSI C, signed in traditional"; made test program
+ self-checking.
1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5).
1999-05-03 lpd Original version.
@@ -54,7 +54,7 @@
#include <IceUtil/MD5I.h>
#include <string.h>
-#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
+#undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */
#ifdef ARCH_IS_BIG_ENDIAN
# define BYTE_ORDER (ARCH_IS_BIG_ENDIAN ? 1 : -1)
#else
@@ -132,8 +132,8 @@ static void
md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
{
md5_word_t
- a = pms->abcd[0], b = pms->abcd[1],
- c = pms->abcd[2], d = pms->abcd[3];
+ a = pms->abcd[0], b = pms->abcd[1],
+ c = pms->abcd[2], d = pms->abcd[3];
md5_word_t t;
#if BYTE_ORDER > 0
/* Define storage only for big-endian CPUs. */
@@ -146,51 +146,51 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/)
{
#if BYTE_ORDER == 0
- /*
- * Determine dynamically whether this is a big-endian or
- * little-endian machine, since we can use a more efficient
- * algorithm on the latter.
- */
- static const int w = 1;
-
- if (*((const md5_byte_t *)&w)) /* dynamic little-endian */
+ /*
+ * Determine dynamically whether this is a big-endian or
+ * little-endian machine, since we can use a more efficient
+ * algorithm on the latter.
+ */
+ static const int w = 1;
+
+ if (*((const md5_byte_t *)&w)) /* dynamic little-endian */
#endif
-#if BYTE_ORDER <= 0 /* little-endian */
- {
- /*
- * On little-endian machines, we can process properly aligned
- * data without copying it.
- */
- if (!((data - (const md5_byte_t *)0) & 3)) {
- /* data are properly aligned */
- X = (const md5_word_t *)data;
- } else {
- /* not aligned */
- memcpy(xbuf, data, 64);
- X = xbuf;
- }
- }
+#if BYTE_ORDER <= 0 /* little-endian */
+ {
+ /*
+ * On little-endian machines, we can process properly aligned
+ * data without copying it.
+ */
+ if (!((data - (const md5_byte_t *)0) & 3)) {
+ /* data are properly aligned */
+ X = (const md5_word_t *)data;
+ } else {
+ /* not aligned */
+ memcpy(xbuf, data, 64);
+ X = xbuf;
+ }
+ }
#endif
#if BYTE_ORDER == 0
- else /* dynamic big-endian */
+ else /* dynamic big-endian */
#endif
-#if BYTE_ORDER >= 0 /* big-endian */
- {
- /*
- * On big-endian machines, we must arrange the bytes in the
- * right order.
- */
- const md5_byte_t *xp = data;
- int i;
+#if BYTE_ORDER >= 0 /* big-endian */
+ {
+ /*
+ * On big-endian machines, we must arrange the bytes in the
+ * right order.
+ */
+ const md5_byte_t *xp = data;
+ int i;
# if BYTE_ORDER == 0
- X = xbuf; /* (dynamic only) */
+ X = xbuf; /* (dynamic only) */
# else
-# define xbuf X /* (static only) */
+# define xbuf X /* (static only) */
# endif
- for (i = 0; i < 16; ++i, xp += 4)
- xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
- }
+ for (i = 0; i < 16; ++i, xp += 4)
+ xbuf[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
+ }
#endif
}
@@ -328,54 +328,54 @@ md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
md5_word_t nbits = (md5_word_t)(nbytes << 3);
if (nbytes <= 0)
- return;
+ return;
/* Update the message length. */
pms->count[1] += nbytes >> 29;
pms->count[0] += nbits;
if (pms->count[0] < nbits)
- pms->count[1]++;
+ pms->count[1]++;
/* Process an initial partial block. */
if (offset) {
- int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
-
- memcpy(pms->buf + offset, p, copy);
- if (offset + copy < 64)
- return;
- p += copy;
- left -= copy;
- md5_process(pms, pms->buf);
+ int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
+
+ memcpy(pms->buf + offset, p, copy);
+ if (offset + copy < 64)
+ return;
+ p += copy;
+ left -= copy;
+ md5_process(pms, pms->buf);
}
/* Process full blocks. */
for (; left >= 64; p += 64, left -= 64)
- md5_process(pms, p);
+ md5_process(pms, p);
/* Process a final partial block. */
if (left)
- memcpy(pms->buf, p, left);
+ memcpy(pms->buf, p, left);
}
void
md5_finish(md5_state_t *pms, md5_byte_t digest[16])
{
static const md5_byte_t pad[64] = {
- 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+ 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
md5_byte_t data[8];
int i;
/* Save the length before padding. */
for (i = 0; i < 8; ++i)
- data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
+ data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
/* Pad to 56 bytes mod 64. */
md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
/* Append the length. */
md5_append(pms, data, 8);
for (i = 0; i < 16; ++i)
- digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
+ digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
}
diff --git a/cpp/src/IceUtil/MD5I.h b/cpp/src/IceUtil/MD5I.h
index 5eb6d6c469c..66588283e83 100644
--- a/cpp/src/IceUtil/MD5I.h
+++ b/cpp/src/IceUtil/MD5I.h
@@ -27,7 +27,7 @@
This code implements the MD5 Algorithm defined in RFC 1321, whose
text is available at
- http://www.ietf.org/rfc/rfc1321.txt
+ http://www.ietf.org/rfc/rfc1321.txt
The code is derived from the text of the RFC, including the test suite
(section A.5) but excluding the rest of Appendix A. It does not include
any code or documentation that is identified in the RFC as being
@@ -38,12 +38,12 @@
that follows (in reverse chronological order):
2002-04-13 lpd Removed support for non-ANSI compilers; removed
- references to Ghostscript; clarified derivation from RFC 1321;
- now handles byte order either statically or dynamically.
+ references to Ghostscript; clarified derivation from RFC 1321;
+ now handles byte order either statically or dynamically.
1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
- added conditionalization for C++ compilation from Martin
- Purschke <purschke@bnl.gov>.
+ added conditionalization for C++ compilation from Martin
+ Purschke <purschke@bnl.gov>.
1999-05-03 lpd Original version.
*/
@@ -65,9 +65,9 @@ typedef unsigned int md5_word_t; /* 32-bit word */
/* Define the state of the MD5 Algorithm. */
typedef struct md5_state_s {
- md5_word_t count[2]; /* message length in bits, lsw first */
- md5_word_t abcd[4]; /* digest buffer */
- md5_byte_t buf[64]; /* accumulate block */
+ md5_word_t count[2]; /* message length in bits, lsw first */
+ md5_word_t abcd[4]; /* digest buffer */
+ md5_byte_t buf[64]; /* accumulate block */
} md5_state_t;
#ifdef __cplusplus
diff --git a/cpp/src/IceUtil/Options.cpp b/cpp/src/IceUtil/Options.cpp
index c8fc3635177..9fe71cc1311 100755
--- a/cpp/src/IceUtil/Options.cpp
+++ b/cpp/src/IceUtil/Options.cpp
@@ -36,7 +36,7 @@ IceUtil::APIException::ice_print(ostream& out) const
Exception::ice_print(out);
if(!reason.empty())
{
- out << ": " << reason;
+ out << ": " << reason;
}
}
@@ -82,7 +82,7 @@ IceUtil::BadOptException::ice_print(ostream& out) const
Exception::ice_print(out);
if(!reason.empty())
{
- out << ": " << reason;
+ out << ": " << reason;
}
}
@@ -120,51 +120,51 @@ IceUtil::Options::checkArgs(const string& shortOpt, const string& longOpt, bool
if(!shortOpt.empty())
{
- if(shortOpt.size() != 1)
- {
- string err = "`";
- err += shortOpt;
- err += "': a short option cannot specify more than one option";
- throw IllegalArgumentException(__FILE__, __LINE__, err);
- }
- if(shortOpt.find_first_of(" \t\n\r\f\v") != string::npos)
- {
- string err = "`";
- err += shortOpt;
- err += "': a short option cannot be whitespace";
- throw IllegalArgumentException(__FILE__, __LINE__, err);
- }
- if(shortOpt[0] == '-')
- {
- string err = "`";
- err += shortOpt;
- err += "': a short option cannot be `-'";
- throw IllegalArgumentException(__FILE__, __LINE__, err);
- }
+ if(shortOpt.size() != 1)
+ {
+ string err = "`";
+ err += shortOpt;
+ err += "': a short option cannot specify more than one option";
+ throw IllegalArgumentException(__FILE__, __LINE__, err);
+ }
+ if(shortOpt.find_first_of(" \t\n\r\f\v") != string::npos)
+ {
+ string err = "`";
+ err += shortOpt;
+ err += "': a short option cannot be whitespace";
+ throw IllegalArgumentException(__FILE__, __LINE__, err);
+ }
+ if(shortOpt[0] == '-')
+ {
+ string err = "`";
+ err += shortOpt;
+ err += "': a short option cannot be `-'";
+ throw IllegalArgumentException(__FILE__, __LINE__, err);
+ }
}
if(!longOpt.empty())
{
- if(longOpt.find_first_of(" \t\n\r\f\v") != string::npos)
- {
- string err = "`";
- err += longOpt;
- err += "': a long option cannot contain whitespace";
- throw IllegalArgumentException(__FILE__, __LINE__, err);
- }
- if(longOpt[0] == '-')
- {
- string err = "`";
- err += longOpt;
- err += "': a long option must not contain a leading `-'";
- throw IllegalArgumentException(__FILE__, __LINE__, err);
- }
+ if(longOpt.find_first_of(" \t\n\r\f\v") != string::npos)
+ {
+ string err = "`";
+ err += longOpt;
+ err += "': a long option cannot contain whitespace";
+ throw IllegalArgumentException(__FILE__, __LINE__, err);
+ }
+ if(longOpt[0] == '-')
+ {
+ string err = "`";
+ err += longOpt;
+ err += "': a long option must not contain a leading `-'";
+ throw IllegalArgumentException(__FILE__, __LINE__, err);
+ }
}
if(!needArg && !dflt.empty())
{
- throw IllegalArgumentException(__FILE__, __LINE__,
- "a default value can be specified only for options requiring an argument");
+ throw IllegalArgumentException(__FILE__, __LINE__,
+ "a default value can be specified only for options requiring an argument");
}
}
@@ -175,7 +175,7 @@ IceUtil::Options::addOpt(const string& shortOpt, const string& longOpt, ArgType
if(parseCalled)
{
- throw APIException(__FILE__, __LINE__, "cannot add options after parse() was called");
+ throw APIException(__FILE__, __LINE__, "cannot add options after parse() was called");
}
checkArgs(shortOpt, longOpt, at == NeedArg, dflt);
@@ -217,361 +217,361 @@ IceUtil::Options::split(const string& line)
for(string::size_type i = 0; i < l.size(); ++i)
{
- char c = l[i];
+ char c = l[i];
switch(state)
- {
- case Normal:
- {
- switch(c)
- {
- case '\\':
- {
- //
- // Ignore a backslash at the end of the string,
- // and strip backslash-newline pairs. If a
- // backslash is followed by a space, single quote,
- // double quote, or dollar sign, we drop the backslash
- // and write the space, single quote, double quote,
- // or dollar sign. This is necessary to allow quotes
- // to be escaped. Dropping the backslash preceding a
- // space deviates from bash quoting rules, but is
- // necessary so we don't drop backslashes from Windows
- // path names.)
- //
- if(i < l.size() - 1 && l[++i] != '\n')
- {
- switch(l[i])
- {
- case ' ':
- case '$':
- case '\'':
- case '"':
- {
- arg.push_back(l[i]);
- break;
- }
- default:
- {
- arg.push_back('\\');
- arg.push_back(l[i]);
- break;
- }
- }
- }
- break;
- }
- case '\'':
- {
- state = SingleQuote;
- break;
- }
- case '"':
- {
- state = DoubleQuote;
- break;
- }
- case '$':
- {
- if(i < l.size() - 1 && l[i + 1] == '\'')
- {
- state = ANSIQuote; // Bash uses $'<text>' to allow ANSI escape sequences within <text>.
- ++i;
- }
- else
- {
- arg.push_back('$');
- }
- break;
- }
- default:
- {
- if(IFS.find(l[i]) != string::npos)
- {
- vec.push_back(arg);
- arg.clear();
-
- //
- // Move to start of next argument.
- //
- while(++i < l.size() && IFS.find(l[i]) != string::npos)
- {
- ;
- }
- --i;
- }
- else
- {
- arg.push_back(l[i]);
- }
- break;
- }
- }
- break;
- }
- case DoubleQuote:
- {
- //
- // Within double quotes, only backslash retains its special
- // meaning, and only if followed by double quote, backslash,
- // or newline. If not followed by one of these characters,
- // both the backslash and the character are preserved.
- //
- if(c == '\\' && i < l.size() - 1)
- {
- switch(c = l[++i])
- {
- case '"':
- case '\\':
- case '\n':
- {
- arg.push_back(c);
- break;
- }
- default:
- {
- arg.push_back('\\');
- arg.push_back(c);
- break;
- }
- }
- }
- else if(c == '"') // End of double-quote mode.
- {
- state = Normal;
- }
- else
- {
- arg.push_back(c); // Everything else is taken literally.
- }
- break;
- }
- case SingleQuote:
- {
- if(c == '\'') // End of single-quote mode.
- {
- state = Normal;
- }
- else
- {
- arg.push_back(c); // Everything else is taken literally.
- }
- break;
- }
- case ANSIQuote:
- {
- switch(c)
- {
- case '\\':
- {
- if(i == l.size() - 1)
- {
- break;
- }
- switch(c = l[++i])
- {
- //
- // Single-letter escape sequences.
- //
- case 'a':
- {
- arg.push_back('\a');
- break;
- }
- case 'b':
- {
- arg.push_back('\b');
- break;
- }
- case 'f':
- {
- arg.push_back('\f');
- break;
- }
- case 'n':
- {
- arg.push_back('\n');
- break;
- }
- case 'r':
- {
- arg.push_back('\r');
- break;
- }
- case 't':
- {
- arg.push_back('\t');
- break;
- }
- case 'v':
- {
- arg.push_back('\v');
- break;
- }
- case '\\':
- {
- arg.push_back('\\');
- break;
- }
- case '\'':
- {
- arg.push_back('\'');
- break;
- }
- case 'e': // Not ANSI-C, but used by bash.
- {
- arg.push_back('\033');
- break;
- }
-
- //
- // Process up to three octal digits.
- //
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- {
- static string octalDigits = "01234567";
- unsigned short us = 0;
- string::size_type j;
- for(j = i;
- j < i + 3 && j < l.size() && octalDigits.find_first_of(c = l[j]) != string::npos;
- ++j)
- {
- us = us * 8 + c - '0';
- }
- i = j - 1;
- arg.push_back(static_cast<char>(us));
- break;
- }
-
- //
- // Process up to two hex digits.
- //
- case 'x':
- {
- if(i < l.size() - 1 && !isxdigit(l[i + 1]))
- {
- arg.push_back('\\');
- arg.push_back('x');
- break;
- }
-
- IceUtil::Int64 ull = 0;
- string::size_type j;
- for(j = i + 1; j < i + 3 && j < l.size() && isxdigit(c = l[j]); ++j)
- {
- ull *= 16;
- if(isdigit(c))
- {
- ull += c - '0';
- }
- else if(islower(c))
- {
- ull += c - 'a' + 10;
- }
- else
- {
- ull += c - 'A' + 10;
- }
- }
- i = j - 1;
- arg.push_back(static_cast<char>(ull));
- break;
- }
-
- //
- // Process control-chars.
- //
- case 'c':
- {
- c = l[++i];
- if(isalpha(c) || c == '@' || (c >= '[' && c <= '_'))
- {
- arg.push_back(static_cast<char>(toupper(c) - '@'));
- }
- else
- {
- //
- // Bash does not define what should happen if a \c
- // is not followed by a recognized control character.
- // We simply treat this case like other unrecognized
- // escape sequences, that is, we preserve the escape
- // sequence unchanged.
- //
- arg.push_back('\\');
- arg.push_back('c');
- arg.push_back(c);
- }
- break;
- }
-
- //
- // If inside an ANSI-quoted string, a backslash isn't followed by
- // one of the recognized characters, both the backslash and the
- // character are preserved.
- //
- default:
- {
- arg.push_back('\\');
- arg.push_back(c);
- break;
- }
- }
- break;
- }
- case '\'': // End of ANSI-quote mode.
- {
- state = Normal;
- break;
- }
- default:
- {
- arg.push_back(c); // Everything else is taken literally.
- break;
- }
- }
- break;
- }
- default:
- {
- assert(!"Impossible parse state");
- break;
- }
- }
+ {
+ case Normal:
+ {
+ switch(c)
+ {
+ case '\\':
+ {
+ //
+ // Ignore a backslash at the end of the string,
+ // and strip backslash-newline pairs. If a
+ // backslash is followed by a space, single quote,
+ // double quote, or dollar sign, we drop the backslash
+ // and write the space, single quote, double quote,
+ // or dollar sign. This is necessary to allow quotes
+ // to be escaped. Dropping the backslash preceding a
+ // space deviates from bash quoting rules, but is
+ // necessary so we don't drop backslashes from Windows
+ // path names.)
+ //
+ if(i < l.size() - 1 && l[++i] != '\n')
+ {
+ switch(l[i])
+ {
+ case ' ':
+ case '$':
+ case '\'':
+ case '"':
+ {
+ arg.push_back(l[i]);
+ break;
+ }
+ default:
+ {
+ arg.push_back('\\');
+ arg.push_back(l[i]);
+ break;
+ }
+ }
+ }
+ break;
+ }
+ case '\'':
+ {
+ state = SingleQuote;
+ break;
+ }
+ case '"':
+ {
+ state = DoubleQuote;
+ break;
+ }
+ case '$':
+ {
+ if(i < l.size() - 1 && l[i + 1] == '\'')
+ {
+ state = ANSIQuote; // Bash uses $'<text>' to allow ANSI escape sequences within <text>.
+ ++i;
+ }
+ else
+ {
+ arg.push_back('$');
+ }
+ break;
+ }
+ default:
+ {
+ if(IFS.find(l[i]) != string::npos)
+ {
+ vec.push_back(arg);
+ arg.clear();
+
+ //
+ // Move to start of next argument.
+ //
+ while(++i < l.size() && IFS.find(l[i]) != string::npos)
+ {
+ ;
+ }
+ --i;
+ }
+ else
+ {
+ arg.push_back(l[i]);
+ }
+ break;
+ }
+ }
+ break;
+ }
+ case DoubleQuote:
+ {
+ //
+ // Within double quotes, only backslash retains its special
+ // meaning, and only if followed by double quote, backslash,
+ // or newline. If not followed by one of these characters,
+ // both the backslash and the character are preserved.
+ //
+ if(c == '\\' && i < l.size() - 1)
+ {
+ switch(c = l[++i])
+ {
+ case '"':
+ case '\\':
+ case '\n':
+ {
+ arg.push_back(c);
+ break;
+ }
+ default:
+ {
+ arg.push_back('\\');
+ arg.push_back(c);
+ break;
+ }
+ }
+ }
+ else if(c == '"') // End of double-quote mode.
+ {
+ state = Normal;
+ }
+ else
+ {
+ arg.push_back(c); // Everything else is taken literally.
+ }
+ break;
+ }
+ case SingleQuote:
+ {
+ if(c == '\'') // End of single-quote mode.
+ {
+ state = Normal;
+ }
+ else
+ {
+ arg.push_back(c); // Everything else is taken literally.
+ }
+ break;
+ }
+ case ANSIQuote:
+ {
+ switch(c)
+ {
+ case '\\':
+ {
+ if(i == l.size() - 1)
+ {
+ break;
+ }
+ switch(c = l[++i])
+ {
+ //
+ // Single-letter escape sequences.
+ //
+ case 'a':
+ {
+ arg.push_back('\a');
+ break;
+ }
+ case 'b':
+ {
+ arg.push_back('\b');
+ break;
+ }
+ case 'f':
+ {
+ arg.push_back('\f');
+ break;
+ }
+ case 'n':
+ {
+ arg.push_back('\n');
+ break;
+ }
+ case 'r':
+ {
+ arg.push_back('\r');
+ break;
+ }
+ case 't':
+ {
+ arg.push_back('\t');
+ break;
+ }
+ case 'v':
+ {
+ arg.push_back('\v');
+ break;
+ }
+ case '\\':
+ {
+ arg.push_back('\\');
+ break;
+ }
+ case '\'':
+ {
+ arg.push_back('\'');
+ break;
+ }
+ case 'e': // Not ANSI-C, but used by bash.
+ {
+ arg.push_back('\033');
+ break;
+ }
+
+ //
+ // Process up to three octal digits.
+ //
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ {
+ static string octalDigits = "01234567";
+ unsigned short us = 0;
+ string::size_type j;
+ for(j = i;
+ j < i + 3 && j < l.size() && octalDigits.find_first_of(c = l[j]) != string::npos;
+ ++j)
+ {
+ us = us * 8 + c - '0';
+ }
+ i = j - 1;
+ arg.push_back(static_cast<char>(us));
+ break;
+ }
+
+ //
+ // Process up to two hex digits.
+ //
+ case 'x':
+ {
+ if(i < l.size() - 1 && !isxdigit(l[i + 1]))
+ {
+ arg.push_back('\\');
+ arg.push_back('x');
+ break;
+ }
+
+ IceUtil::Int64 ull = 0;
+ string::size_type j;
+ for(j = i + 1; j < i + 3 && j < l.size() && isxdigit(c = l[j]); ++j)
+ {
+ ull *= 16;
+ if(isdigit(c))
+ {
+ ull += c - '0';
+ }
+ else if(islower(c))
+ {
+ ull += c - 'a' + 10;
+ }
+ else
+ {
+ ull += c - 'A' + 10;
+ }
+ }
+ i = j - 1;
+ arg.push_back(static_cast<char>(ull));
+ break;
+ }
+
+ //
+ // Process control-chars.
+ //
+ case 'c':
+ {
+ c = l[++i];
+ if(isalpha(c) || c == '@' || (c >= '[' && c <= '_'))
+ {
+ arg.push_back(static_cast<char>(toupper(c) - '@'));
+ }
+ else
+ {
+ //
+ // Bash does not define what should happen if a \c
+ // is not followed by a recognized control character.
+ // We simply treat this case like other unrecognized
+ // escape sequences, that is, we preserve the escape
+ // sequence unchanged.
+ //
+ arg.push_back('\\');
+ arg.push_back('c');
+ arg.push_back(c);
+ }
+ break;
+ }
+
+ //
+ // If inside an ANSI-quoted string, a backslash isn't followed by
+ // one of the recognized characters, both the backslash and the
+ // character are preserved.
+ //
+ default:
+ {
+ arg.push_back('\\');
+ arg.push_back(c);
+ break;
+ }
+ }
+ break;
+ }
+ case '\'': // End of ANSI-quote mode.
+ {
+ state = Normal;
+ break;
+ }
+ default:
+ {
+ arg.push_back(c); // Everything else is taken literally.
+ break;
+ }
+ }
+ break;
+ }
+ default:
+ {
+ assert(!"Impossible parse state");
+ break;
+ }
+ }
}
switch(state)
{
- case Normal:
- {
- vec.push_back(arg);
- break;
- }
- case SingleQuote:
- {
- throw BadOptException(__FILE__, __LINE__, "missing closing single quote");
- break;
- }
- case DoubleQuote:
- {
- throw BadOptException(__FILE__, __LINE__, "missing closing double quote");
- break;
- }
- case ANSIQuote:
- {
- throw BadOptException(__FILE__, __LINE__, "unterminated $' quote");
- break;
- }
- default:
- {
- assert(!"Impossible parse state");
- break;
- }
+ case Normal:
+ {
+ vec.push_back(arg);
+ break;
+ }
+ case SingleQuote:
+ {
+ throw BadOptException(__FILE__, __LINE__, "missing closing single quote");
+ break;
+ }
+ case DoubleQuote:
+ {
+ throw BadOptException(__FILE__, __LINE__, "missing closing double quote");
+ break;
+ }
+ case ANSIQuote:
+ {
+ throw BadOptException(__FILE__, __LINE__, "unterminated $' quote");
+ break;
+ }
+ default:
+ {
+ assert(!"Impossible parse state");
+ break;
+ }
}
return vec;
@@ -592,7 +592,7 @@ IceUtil::Options::parse(const StringVector& args)
if(parseCalled)
{
- throw APIException(__FILE__, __LINE__, "cannot call parse() more than once on the same Option instance");
+ throw APIException(__FILE__, __LINE__, "cannot call parse() more than once on the same Option instance");
}
parseCalled = true;
@@ -603,133 +603,133 @@ IceUtil::Options::parse(const StringVector& args)
string::size_type i;
for(i = 1; i < args.size(); ++i)
{
- if(args[i] == "-" || args[i] == "--")
- {
- ++i;
- break; // "-" and "--" indicate end of options.
- }
-
- string opt;
- ValidOpts::iterator pos;
+ if(args[i] == "-" || args[i] == "--")
+ {
+ ++i;
+ break; // "-" and "--" indicate end of options.
+ }
+
+ string opt;
+ ValidOpts::iterator pos;
bool argDone = false;
- if(args[i].compare(0, 2, "--") == 0)
- {
- //
- // Long option. If the option has an argument, it can either be separated by '='
- // or appear as a separate argument. For example, "--name value" is the same
- // as "--name=value".
- //
- string::size_type p = args[i].find('=', 2);
- if(p != string::npos)
- {
- opt = args[i].substr(2, p - 2);
- }
- else
- {
- opt = args[i].substr(2);
- }
-
- pos = checkOpt(opt, LongOpt);
-
- if(pos->second->repeat == NoRepeat)
- {
- set<string>::iterator seenPos = seenNonRepeatableOpts.find(opt);
- if(seenPos != seenNonRepeatableOpts.end())
- {
- string err = "`--";
- err += opt + ":' option cannot be repeated";
- throw BadOptException(__FILE__, __LINE__, err);
- }
- seenNonRepeatableOpts.insert(seenPos, opt);
- string synonym = getSynonym(opt);
- if(!synonym.empty())
- {
- seenNonRepeatableOpts.insert(synonym);
- }
- }
-
- if(p != string::npos)
- {
- if(pos->second->arg == NoArg && p != args[i].size() - 1)
- {
- string err = "`";
- err += args[i];
- err += "': option does not take an argument";
- throw BadOptException(__FILE__, __LINE__, err);
- }
- setOpt(opt, "", args[i].substr(p + 1), pos->second->repeat);
- argDone = true;
- }
- }
- else if(!args[i].empty() && args[i][0] == '-')
- {
- //
- // Short option.
- //
- for(string::size_type p = 1; p < args[i].size(); ++p)
- {
- opt.clear();
- opt.push_back(args[i][p]);
- pos = checkOpt(opt, ShortOpt);
-
- if(pos->second->repeat == NoRepeat)
- {
- set<string>::iterator seenPos = seenNonRepeatableOpts.find(opt);
- if(seenPos != seenNonRepeatableOpts.end())
- {
- string err = "`-";
- err += opt + ":' option cannot be repeated";
- throw BadOptException(__FILE__, __LINE__, err);
- }
- seenNonRepeatableOpts.insert(seenPos, opt);
- string synonym = getSynonym(opt);
- if(!synonym.empty())
- {
- seenNonRepeatableOpts.insert(synonym);
- }
- }
-
- if(pos->second->arg == NeedArg && p != args[i].size() - 1)
- {
- string optArg = args[i].substr(p + 1);
- setOpt(opt, "", optArg, pos->second->repeat);
- argDone = true;
- break;
- }
- }
- }
- else
- {
- //
- // Not an option or option argument.
- //
- result.push_back(args[i]);
- argDone = true;
- }
-
- if(!argDone)
- {
- if(pos->second->arg == NeedArg) // Need an argument that is separated by whitespace.
- {
- if(i == args.size() - 1)
- {
- string err = "`-";
- if(opt.size() != 1)
- {
- err += "-";
- }
- err += opt;
- err += "' option requires an argument";
- throw BadOptException(__FILE__, __LINE__, err);
- }
- setOpt(opt, "", args[++i], pos->second->repeat);
- }
- else
- {
- setOpt(opt, "", "1", pos->second->repeat);
- }
- }
+ if(args[i].compare(0, 2, "--") == 0)
+ {
+ //
+ // Long option. If the option has an argument, it can either be separated by '='
+ // or appear as a separate argument. For example, "--name value" is the same
+ // as "--name=value".
+ //
+ string::size_type p = args[i].find('=', 2);
+ if(p != string::npos)
+ {
+ opt = args[i].substr(2, p - 2);
+ }
+ else
+ {
+ opt = args[i].substr(2);
+ }
+
+ pos = checkOpt(opt, LongOpt);
+
+ if(pos->second->repeat == NoRepeat)
+ {
+ set<string>::iterator seenPos = seenNonRepeatableOpts.find(opt);
+ if(seenPos != seenNonRepeatableOpts.end())
+ {
+ string err = "`--";
+ err += opt + ":' option cannot be repeated";
+ throw BadOptException(__FILE__, __LINE__, err);
+ }
+ seenNonRepeatableOpts.insert(seenPos, opt);
+ string synonym = getSynonym(opt);
+ if(!synonym.empty())
+ {
+ seenNonRepeatableOpts.insert(synonym);
+ }
+ }
+
+ if(p != string::npos)
+ {
+ if(pos->second->arg == NoArg && p != args[i].size() - 1)
+ {
+ string err = "`";
+ err += args[i];
+ err += "': option does not take an argument";
+ throw BadOptException(__FILE__, __LINE__, err);
+ }
+ setOpt(opt, "", args[i].substr(p + 1), pos->second->repeat);
+ argDone = true;
+ }
+ }
+ else if(!args[i].empty() && args[i][0] == '-')
+ {
+ //
+ // Short option.
+ //
+ for(string::size_type p = 1; p < args[i].size(); ++p)
+ {
+ opt.clear();
+ opt.push_back(args[i][p]);
+ pos = checkOpt(opt, ShortOpt);
+
+ if(pos->second->repeat == NoRepeat)
+ {
+ set<string>::iterator seenPos = seenNonRepeatableOpts.find(opt);
+ if(seenPos != seenNonRepeatableOpts.end())
+ {
+ string err = "`-";
+ err += opt + ":' option cannot be repeated";
+ throw BadOptException(__FILE__, __LINE__, err);
+ }
+ seenNonRepeatableOpts.insert(seenPos, opt);
+ string synonym = getSynonym(opt);
+ if(!synonym.empty())
+ {
+ seenNonRepeatableOpts.insert(synonym);
+ }
+ }
+
+ if(pos->second->arg == NeedArg && p != args[i].size() - 1)
+ {
+ string optArg = args[i].substr(p + 1);
+ setOpt(opt, "", optArg, pos->second->repeat);
+ argDone = true;
+ break;
+ }
+ }
+ }
+ else
+ {
+ //
+ // Not an option or option argument.
+ //
+ result.push_back(args[i]);
+ argDone = true;
+ }
+
+ if(!argDone)
+ {
+ if(pos->second->arg == NeedArg) // Need an argument that is separated by whitespace.
+ {
+ if(i == args.size() - 1)
+ {
+ string err = "`-";
+ if(opt.size() != 1)
+ {
+ err += "-";
+ }
+ err += opt;
+ err += "' option requires an argument";
+ throw BadOptException(__FILE__, __LINE__, err);
+ }
+ setOpt(opt, "", args[++i], pos->second->repeat);
+ }
+ else
+ {
+ setOpt(opt, "", "1", pos->second->repeat);
+ }
+ }
}
_synonyms.clear(); // Don't need the contents anymore.
@@ -765,7 +765,7 @@ IceUtil::Options::isSet(const string& opt) const
if(!parseCalled)
{
- throw APIException(__FILE__, __LINE__, "cannot lookup options before calling parse()");
+ throw APIException(__FILE__, __LINE__, "cannot lookup options before calling parse()");
}
ValidOpts::const_iterator pos = checkOptIsValid(opt);
@@ -779,21 +779,21 @@ IceUtil::Options::optArg(const string& opt) const
if(!parseCalled)
{
- throw APIException(__FILE__, __LINE__, "cannot lookup options before calling parse()");
+ throw APIException(__FILE__, __LINE__, "cannot lookup options before calling parse()");
}
ValidOpts::const_iterator pos = checkOptHasArg(opt);
if(pos->second->repeat == Repeat)
{
- string err = "`-";
- if(pos->second->length == LongOpt)
- {
- err.push_back('-');
- }
- err += opt;
- err += "': is a repeating option -- use argVec() to get its arguments";
- throw IllegalArgumentException(__FILE__, __LINE__, err);
+ string err = "`-";
+ if(pos->second->length == LongOpt)
+ {
+ err.push_back('-');
+ }
+ err += opt;
+ err += "': is a repeating option -- use argVec() to get its arguments";
+ throw IllegalArgumentException(__FILE__, __LINE__, err);
}
Opts::const_iterator p = _opts.find(opt);
@@ -811,20 +811,20 @@ IceUtil::Options::argVec(const string& opt) const
if(!parseCalled)
{
- throw APIException(__FILE__, __LINE__, "cannot lookup options before calling parse()");
+ throw APIException(__FILE__, __LINE__, "cannot lookup options before calling parse()");
}
ValidOpts::const_iterator pos = checkOptHasArg(opt);
if(pos->second->repeat == NoRepeat)
{
- string err = "`-";
- if(pos->second->length == LongOpt)
- {
- err.push_back('-');
- }
- err += opt + "': is a non-repeating option -- use optArg() to get its argument";
- throw IllegalArgumentException(__FILE__, __LINE__, err);
+ string err = "`-";
+ if(pos->second->length == LongOpt)
+ {
+ err.push_back('-');
+ }
+ err += opt + "': is a non-repeating option -- use optArg() to get its argument";
+ throw IllegalArgumentException(__FILE__, __LINE__, err);
}
ROpts::const_iterator p = _ropts.find(opt);
@@ -837,17 +837,17 @@ IceUtil::Options::addValidOpt(const string& shortOpt, const string& longOpt,
{
if(!shortOpt.empty() && _validOpts.find(shortOpt) != _validOpts.end())
{
- string err = "`";
- err += shortOpt;
- err += "': duplicate option";
- throw IllegalArgumentException(__FILE__, __LINE__, err);
+ string err = "`";
+ err += shortOpt;
+ err += "': duplicate option";
+ throw IllegalArgumentException(__FILE__, __LINE__, err);
}
if(!longOpt.empty() && _validOpts.find(longOpt) != _validOpts.end())
{
- string err = "`";
- err += longOpt;
- err += "': duplicate option";
- throw IllegalArgumentException(__FILE__, __LINE__, err);
+ string err = "`";
+ err += longOpt;
+ err += "': duplicate option";
+ throw IllegalArgumentException(__FILE__, __LINE__, err);
}
ODPtr odp = new OptionDetails;
@@ -857,12 +857,12 @@ IceUtil::Options::addValidOpt(const string& shortOpt, const string& longOpt,
if(!shortOpt.empty())
{
- odp->length = ShortOpt;
- _validOpts[shortOpt] = odp;
+ odp->length = ShortOpt;
+ _validOpts[shortOpt] = odp;
}
if(!longOpt.empty())
{
- odp->length = LongOpt;
+ odp->length = LongOpt;
_validOpts[longOpt] = odp;
}
@@ -870,7 +870,7 @@ IceUtil::Options::addValidOpt(const string& shortOpt, const string& longOpt,
if(at == NeedArg && !dflt.empty())
{
- setOpt(shortOpt, longOpt, dflt, rt);
+ setOpt(shortOpt, longOpt, dflt, rt);
}
}
@@ -880,14 +880,14 @@ IceUtil::Options::checkOpt(const string& opt, LengthType lt)
ValidOpts::iterator pos = _validOpts.find(opt);
if(pos == _validOpts.end())
{
- string err = "invalid option: `-";
- if(lt == LongOpt)
- {
- err.push_back('-');
- }
- err += opt;
- err.push_back('\'');
- throw BadOptException(__FILE__, __LINE__, err);
+ string err = "invalid option: `-";
+ if(lt == LongOpt)
+ {
+ err.push_back('-');
+ }
+ err += opt;
+ err.push_back('\'');
+ throw BadOptException(__FILE__, __LINE__, err);
}
return pos;
}
@@ -902,13 +902,13 @@ IceUtil::Options::setOpt(const string& opt1, const string& opt2, const string& v
if(rt == NoRepeat)
{
- setNonRepeatingOpt(opt1, val);
- setNonRepeatingOpt(opt2, val);
+ setNonRepeatingOpt(opt1, val);
+ setNonRepeatingOpt(opt2, val);
}
else
{
- setRepeatingOpt(opt1, val);
- setRepeatingOpt(opt2, val);
+ setRepeatingOpt(opt1, val);
+ setRepeatingOpt(opt2, val);
}
}
@@ -933,7 +933,7 @@ IceUtil::Options::setNonRepeatingOpt(const string& opt, const string& val)
const string synonym = getSynonym(opt);
if(!synonym.empty())
{
- _opts[synonym] = ovp;
+ _opts[synonym] = ovp;
}
}
@@ -954,45 +954,45 @@ IceUtil::Options::setRepeatingOpt(const string& opt, const string& val)
if(pos != _ropts.end())
{
- assert(_validOpts.find(opt) != _validOpts.end());
- assert(vpos->second->repeat == Repeat);
-
- _ropts[opt] = pos->second;
- if(vpos->second->hasDefault && pos->second->vals.size() == 1)
- {
- pos->second->vals[0] = val;
- vpos->second->hasDefault = false;
- }
- else
- {
- pos->second->vals.push_back(val);
- }
+ assert(_validOpts.find(opt) != _validOpts.end());
+ assert(vpos->second->repeat == Repeat);
+
+ _ropts[opt] = pos->second;
+ if(vpos->second->hasDefault && pos->second->vals.size() == 1)
+ {
+ pos->second->vals[0] = val;
+ vpos->second->hasDefault = false;
+ }
+ else
+ {
+ pos->second->vals.push_back(val);
+ }
}
else if(spos != _ropts.end())
{
- assert(_validOpts.find(synonym) != _validOpts.end());
- assert(_validOpts.find(synonym)->second->repeat == Repeat);
-
- _ropts[synonym] = spos->second;
- if(vpos->second->hasDefault && spos->second->vals.size() == 1)
- {
- spos->second->vals[0] = val;
- vpos->second->hasDefault = false;
- }
- else
- {
- spos->second->vals.push_back(val);
- }
+ assert(_validOpts.find(synonym) != _validOpts.end());
+ assert(_validOpts.find(synonym)->second->repeat == Repeat);
+
+ _ropts[synonym] = spos->second;
+ if(vpos->second->hasDefault && spos->second->vals.size() == 1)
+ {
+ spos->second->vals[0] = val;
+ vpos->second->hasDefault = false;
+ }
+ else
+ {
+ spos->second->vals.push_back(val);
+ }
}
else
{
- OVecPtr ovp = new OptionValueVector;
- ovp->vals.push_back(val);
- _ropts[opt] = ovp;
- if(!synonym.empty())
- {
- _ropts[synonym] = ovp;
- }
+ OVecPtr ovp = new OptionValueVector;
+ ovp->vals.push_back(val);
+ _ropts[opt] = ovp;
+ if(!synonym.empty())
+ {
+ _ropts[synonym] = ovp;
+ }
}
}
@@ -1002,10 +1002,10 @@ IceUtil::Options::checkOptIsValid(const string& opt) const
ValidOpts::const_iterator pos = _validOpts.find(opt);
if(pos == _validOpts.end())
{
- string err = "`";
- err += opt;
- err += "': invalid option";
- throw IllegalArgumentException(__FILE__, __LINE__, err);
+ string err = "`";
+ err += opt;
+ err += "': invalid option";
+ throw IllegalArgumentException(__FILE__, __LINE__, err);
}
return pos;
}
@@ -1016,14 +1016,14 @@ IceUtil::Options::checkOptHasArg(const string& opt) const
ValidOpts::const_iterator pos = checkOptIsValid(opt);
if(pos->second->arg == NoArg)
{
- string err = "`-";
- if(pos->second->length == LongOpt)
- {
- err.push_back('-');
- }
- err += opt;
- err += "': option does not take arguments";
- throw IllegalArgumentException(__FILE__, __LINE__, err);
+ string err = "`-";
+ if(pos->second->length == LongOpt)
+ {
+ err.push_back('-');
+ }
+ err += opt;
+ err += "': option does not take arguments";
+ throw IllegalArgumentException(__FILE__, __LINE__, err);
}
return pos;
}
@@ -1034,7 +1034,7 @@ IceUtil::Options::updateSynonyms(const ::std::string& shortOpt, const ::std::str
if(!shortOpt.empty() && !longOpt.empty())
{
_synonyms[shortOpt] = longOpt;
- _synonyms[longOpt] = shortOpt;
+ _synonyms[longOpt] = shortOpt;
}
}
diff --git a/cpp/src/IceUtil/OutputUtil.cpp b/cpp/src/IceUtil/OutputUtil.cpp
index acf1a7a4590..e3ef63d1a45 100644
--- a/cpp/src/IceUtil/OutputUtil.cpp
+++ b/cpp/src/IceUtil/OutputUtil.cpp
@@ -84,14 +84,14 @@ IceUtil::OutputBase::print(const char* s)
{
for(unsigned int i = 0; i < strlen(s); ++i)
{
- if(s[i] == '\n')
- {
- _pos = 0;
- }
- else
- {
- ++_pos;
- }
+ if(s[i] == '\n')
+ {
+ _pos = 0;
+ }
+ else
+ {
+ ++_pos;
+ }
}
_out << s;
@@ -236,10 +236,10 @@ IceUtil::Output::print(const char* s)
{
if(_par >= 0)
{
- if(++_par > 1) // No comma for the first parameter.
- {
- _out << ", ";
- }
+ if(++_par > 1) // No comma for the first parameter.
+ {
+ _out << ", ";
+ }
}
OutputBase::print(s);
}
@@ -337,19 +337,19 @@ IceUtil::XMLOutput::print(const char* s)
{
if(_se)
{
- _out << '>';
- _se = false;
+ _out << '>';
+ _se = false;
}
_text = true;
if(_escape)
{
- string escaped = escape(s);
- OutputBase::print(escaped.c_str());
+ string escaped = escape(s);
+ OutputBase::print(escaped.c_str());
}
else
{
- OutputBase::print(s);
+ OutputBase::print(s);
}
}
@@ -358,8 +358,8 @@ IceUtil::XMLOutput::newline()
{
if(_se)
{
- _se = false;
- _out << '>';
+ _se = false;
+ _out << '>';
}
OutputBase::newline();
}
@@ -376,11 +376,11 @@ IceUtil::XMLOutput::startElement(const string& element)
//
if(_escape)
{
- _out << '<' << escape(element);
+ _out << '<' << escape(element);
}
else
{
- _out << '<' << element;
+ _out << '<' << element;
}
_se = true;
_text = false;
@@ -388,11 +388,11 @@ IceUtil::XMLOutput::startElement(const string& element)
string::size_type pos = element.find_first_of(" \t");
if(pos == string::npos)
{
- _elementStack.push(element);
+ _elementStack.push(element);
}
else
{
- _elementStack.push(element.substr(0, pos));
+ _elementStack.push(element.substr(0, pos));
}
++_pos; // TODO: ???
@@ -409,15 +409,15 @@ IceUtil::XMLOutput::endElement()
dec();
if(_se)
{
- _out << "></" << element << '>';
+ _out << "></" << element << '>';
}
else
{
- if(!_text)
- {
- newline();
- }
- _out << "</" << element << '>';
+ if(!_text)
+ {
+ newline();
+ }
+ _out << "</" << element << '>';
}
--_pos; // TODO: ???
@@ -472,50 +472,50 @@ IceUtil::XMLOutput::escape(const string& input) const
const string allReserved = "<>'\"&";
if(v.find_first_of(allReserved) != string::npos)
{
- //
- // First convert all & to &amp;
- //
- size_t pos = 0;
- while((pos = v.find_first_of('&', pos)) != string::npos)
- {
- v.insert(pos+1, "amp;");
- pos += 4;
- }
-
- //
- // Next convert remaining reserved characters.
- //
- const string reserved = "<>'\"";
- pos = 0;
- while((pos = v.find_first_of(reserved, pos)) != string::npos)
- {
- string replace;
- switch(v[pos])
- {
- case '>':
- replace = "&gt;";
- break;
-
- case '<':
- replace = "&lt;";
- break;
-
- case '\'':
- replace = "&apos;";
- break;
-
- case '"':
- replace = "&quot;";
- break;
-
- default:
- assert(false);
- }
-
- v.erase(pos, 1);
- v.insert(pos, replace);
- pos += replace.size();
- }
+ //
+ // First convert all & to &amp;
+ //
+ size_t pos = 0;
+ while((pos = v.find_first_of('&', pos)) != string::npos)
+ {
+ v.insert(pos+1, "amp;");
+ pos += 4;
+ }
+
+ //
+ // Next convert remaining reserved characters.
+ //
+ const string reserved = "<>'\"";
+ pos = 0;
+ while((pos = v.find_first_of(reserved, pos)) != string::npos)
+ {
+ string replace;
+ switch(v[pos])
+ {
+ case '>':
+ replace = "&gt;";
+ break;
+
+ case '<':
+ replace = "&lt;";
+ break;
+
+ case '\'':
+ replace = "&apos;";
+ break;
+
+ case '"':
+ replace = "&quot;";
+ break;
+
+ default:
+ assert(false);
+ }
+
+ v.erase(pos, 1);
+ v.insert(pos, replace);
+ pos += replace.size();
+ }
}
return v;
}
diff --git a/cpp/src/IceUtil/RWRecMutex.cpp b/cpp/src/IceUtil/RWRecMutex.cpp
index 8e78db985a3..d15d4acd98c 100644
--- a/cpp/src/IceUtil/RWRecMutex.cpp
+++ b/cpp/src/IceUtil/RWRecMutex.cpp
@@ -58,7 +58,7 @@ IceUtil::RWRecMutex::readLock() const
//
while(_count < 0 || _waitingWriters != 0)
{
- _readers.wait(lock);
+ _readers.wait(lock);
}
++_count;
}
@@ -74,7 +74,7 @@ IceUtil::RWRecMutex::tryReadLock() const
//
if(_count < 0 || _waitingWriters != 0)
{
- return false;
+ return false;
}
++_count;
return true;
@@ -92,18 +92,18 @@ IceUtil::RWRecMutex::timedReadLock(const Time& timeout) const
Time end = Time::now() + timeout;
while(_count < 0 || _waitingWriters != 0)
{
- Time remainder = end - Time::now();
- if(remainder > Time())
- {
- if(_readers.timedWait(lock, remainder) == false)
- {
- return false;
- }
- }
- else
- {
- return false;
- }
+ Time remainder = end - Time::now();
+ if(remainder > Time())
+ {
+ if(_readers.timedWait(lock, remainder) == false)
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
}
++_count;
@@ -121,8 +121,8 @@ IceUtil::RWRecMutex::writeLock() const
//
if(_count < 0 && _writerId == ThreadControl())
{
- --_count;
- return;
+ --_count;
+ return;
}
//
@@ -131,17 +131,17 @@ IceUtil::RWRecMutex::writeLock() const
//
while(_count != 0)
{
- ++_waitingWriters;
- try
- {
- _writers.wait(lock);
- }
- catch(...)
- {
- --_waitingWriters;
- throw;
- }
- --_waitingWriters;
+ ++_waitingWriters;
+ try
+ {
+ _writers.wait(lock);
+ }
+ catch(...)
+ {
+ --_waitingWriters;
+ throw;
+ }
+ --_waitingWriters;
}
//
@@ -162,8 +162,8 @@ IceUtil::RWRecMutex::tryWriteLock() const
//
if(_count < 0 && _writerId == ThreadControl())
{
- --_count;
- return true;
+ --_count;
+ return true;
}
//
@@ -171,7 +171,7 @@ IceUtil::RWRecMutex::tryWriteLock() const
//
if(_count != 0)
{
- return false;
+ return false;
}
//
@@ -192,8 +192,8 @@ IceUtil::RWRecMutex::timedWriteLock(const Time& timeout) const
// decrement _count, and return.
if(_count < 0 && _writerId == ThreadControl())
{
- --_count;
- return true;
+ --_count;
+ return true;
}
//
@@ -203,29 +203,29 @@ IceUtil::RWRecMutex::timedWriteLock(const Time& timeout) const
Time end = Time::now() + timeout;
while(_count != 0)
{
- Time remainder = end - Time::now();
- if(remainder > Time())
- {
- ++_waitingWriters;
- try
- {
- bool result = _writers.timedWait(lock, remainder);
- --_waitingWriters;
- if(result == false)
- {
- return false;
- }
- }
- catch(...)
- {
- --_waitingWriters;
- throw;
- }
- }
- else
- {
- return false;
- }
+ Time remainder = end - Time::now();
+ if(remainder > Time())
+ {
+ ++_waitingWriters;
+ try
+ {
+ bool result = _writers.timedWait(lock, remainder);
+ --_waitingWriters;
+ if(result == false)
+ {
+ return false;
+ }
+ }
+ catch(...)
+ {
+ --_waitingWriters;
+ throw;
+ }
+ }
+ else
+ {
+ return false;
+ }
}
//
@@ -242,46 +242,46 @@ IceUtil::RWRecMutex::unlock() const
bool ww = false;
bool wr = false;
{
- Mutex::Lock lock(_mutex);
-
- assert(_count != 0);
-
- //
- // If _count < 0, the calling thread is a writer that holds the
- // lock, so release the lock. Otherwise, _count is guaranteed to
- // be > 0, so the calling thread is a reader releasing the lock.
- //
- if(_count < 0)
- {
- //
- // Writer called unlock
- //
- ++_count;
-
- //
- // If the write lock wasn't totally released we're done.
- //
- if(_count != 0)
- {
- return;
- }
- }
- else
- {
- //
- // Reader called unlock
- //
- --_count;
- }
-
- //
- // Writers are waiting (ww) if _waitingWriters > 0. In that
- // case, it's OK to let another writer into the region once there
- // are no more readers (_count == 0). Otherwise, no writers are
- // waiting but readers may be waiting (wr).
- //
- ww = (_waitingWriters != 0 && _count == 0);
- wr = (_waitingWriters == 0);
+ Mutex::Lock lock(_mutex);
+
+ assert(_count != 0);
+
+ //
+ // If _count < 0, the calling thread is a writer that holds the
+ // lock, so release the lock. Otherwise, _count is guaranteed to
+ // be > 0, so the calling thread is a reader releasing the lock.
+ //
+ if(_count < 0)
+ {
+ //
+ // Writer called unlock
+ //
+ ++_count;
+
+ //
+ // If the write lock wasn't totally released we're done.
+ //
+ if(_count != 0)
+ {
+ return;
+ }
+ }
+ else
+ {
+ //
+ // Reader called unlock
+ //
+ --_count;
+ }
+
+ //
+ // Writers are waiting (ww) if _waitingWriters > 0. In that
+ // case, it's OK to let another writer into the region once there
+ // are no more readers (_count == 0). Otherwise, no writers are
+ // waiting but readers may be waiting (wr).
+ //
+ ww = (_waitingWriters != 0 && _count == 0);
+ wr = (_waitingWriters == 0);
} // Unlock mutex.
//
@@ -290,27 +290,27 @@ IceUtil::RWRecMutex::unlock() const
//
if(ww)
{
- if(_upgrading)
- {
- //
- // If there is an untimed upgrader, it runs.
- //
- _upgrader.signal();
- }
- else
- {
- //
- // Wake a normal writer.
- //
- _writers.signal();
- }
+ if(_upgrading)
+ {
+ //
+ // If there is an untimed upgrader, it runs.
+ //
+ _upgrader.signal();
+ }
+ else
+ {
+ //
+ // Wake a normal writer.
+ //
+ _writers.signal();
+ }
}
else if(wr)
{
- //
- // Wake readers
- //
- _readers.broadcast();
+ //
+ // Wake readers
+ //
+ _readers.broadcast();
}
}
@@ -336,19 +336,19 @@ IceUtil::RWRecMutex::upgrade() const
_upgrading = true;
while(_count != 0)
{
- ++_waitingWriters;
- try
- {
- _upgrader.wait(lock);
- }
- catch(...)
- {
- _upgrading = false;
- --_waitingWriters;
- ++_count;
- throw;
- }
- --_waitingWriters;
+ ++_waitingWriters;
+ try
+ {
+ _upgrader.wait(lock);
+ }
+ catch(...)
+ {
+ _upgrading = false;
+ --_waitingWriters;
+ ++_count;
+ throw;
+ }
+ --_waitingWriters;
}
//
@@ -385,38 +385,38 @@ IceUtil::RWRecMutex::timedUpgrade(const Time& timeout) const
Time end = Time::now() + timeout;
while(_count != 0)
{
- Time remainder = end - Time::now();
- if(remainder > Time())
- {
- ++_waitingWriters;
- try
- {
- bool result = _upgrader.timedWait(lock, remainder);
- --_waitingWriters;
- if(!result)
- {
- _upgrading = false;
- ++_count;
- return false;
- }
- }
- catch(...)
- {
- _upgrading = false;
- --_waitingWriters;
- ++_count;
- throw;
- }
- }
- else
- {
- //
- // The lock isn't acquired if a timeout occurred.
- //
- ++_count;
- _upgrading = false;
- return false;
- }
+ Time remainder = end - Time::now();
+ if(remainder > Time())
+ {
+ ++_waitingWriters;
+ try
+ {
+ bool result = _upgrader.timedWait(lock, remainder);
+ --_waitingWriters;
+ if(!result)
+ {
+ _upgrading = false;
+ ++_count;
+ return false;
+ }
+ }
+ catch(...)
+ {
+ _upgrading = false;
+ --_waitingWriters;
+ ++_count;
+ throw;
+ }
+ }
+ else
+ {
+ //
+ // The lock isn't acquired if a timeout occurred.
+ //
+ ++_count;
+ _upgrading = false;
+ return false;
+ }
}
//
@@ -435,6 +435,6 @@ IceUtil::RWRecMutex::downgrade() const
if(++_count == 0)
{
- _count = 1;
+ _count = 1;
}
}
diff --git a/cpp/src/IceUtil/Random.cpp b/cpp/src/IceUtil/Random.cpp
index f532d64d35e..bbe8b523198 100644
--- a/cpp/src/IceUtil/Random.cpp
+++ b/cpp/src/IceUtil/Random.cpp
@@ -60,17 +60,17 @@ public:
~RandomCleanup()
{
#ifdef _WIN32
- if(context != NULL)
- {
- CryptReleaseContext(context, 0);
- context = NULL;
- }
+ if(context != NULL)
+ {
+ CryptReleaseContext(context, 0);
+ context = NULL;
+ }
#else
- if(fd != -1)
- {
- close(fd);
- fd = -1;
- }
+ if(fd != -1)
+ {
+ close(fd);
+ fd = -1;
+ }
#endif
}
};
@@ -89,30 +89,30 @@ IceUtil::RandomGeneratorException::ice_print(ostream& os) const
Exception::ice_print(os);
if(_error != 0)
{
- os << ":\nrandom generator exception: ";
+ os << ":\nrandom generator exception: ";
#ifdef _WIN32
- LPVOID lpMsgBuf = 0;
- DWORD ok = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- _error,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPTSTR)&lpMsgBuf,
- 0,
- NULL);
-
- if(ok)
- {
- LPCTSTR msg = (LPCTSTR)lpMsgBuf;
- assert(msg && strlen((char*)msg) > 0);
- os << msg;
- LocalFree(lpMsgBuf);
- }
- else
- {
- os << "unknown random generator error";
- }
+ LPVOID lpMsgBuf = 0;
+ DWORD ok = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ _error,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR)&lpMsgBuf,
+ 0,
+ NULL);
+
+ if(ok)
+ {
+ LPCTSTR msg = (LPCTSTR)lpMsgBuf;
+ assert(msg && strlen((char*)msg) > 0);
+ os << msg;
+ LocalFree(lpMsgBuf);
+ }
+ else
+ {
+ os << "unknown random generator error";
+ }
#else
os << strerror(_error);
#endif
@@ -145,15 +145,15 @@ IceUtil::generateRandom(char* buffer, int size)
IceUtil::StaticMutex::Lock lock(staticMutex);
if(context == NULL)
{
- if(!CryptAcquireContext(&context, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
- {
- throw RandomGeneratorException(__FILE__, __LINE__, GetLastError());
- }
+ if(!CryptAcquireContext(&context, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
+ {
+ throw RandomGeneratorException(__FILE__, __LINE__, GetLastError());
+ }
}
if(!CryptGenRandom(context, size, reinterpret_cast<unsigned char*>(buffer)))
{
- throw RandomGeneratorException(__FILE__, __LINE__, GetLastError());
+ throw RandomGeneratorException(__FILE__, __LINE__, GetLastError());
}
#else
@@ -163,12 +163,12 @@ IceUtil::generateRandom(char* buffer, int size)
IceUtil::StaticMutex::Lock lock(staticMutex);
if(fd == -1)
{
- fd = open("/dev/urandom", O_RDONLY);
- if(fd == -1)
- {
- assert(0);
- throw RandomGeneratorException(__FILE__, __LINE__);
- }
+ fd = open("/dev/urandom", O_RDONLY);
+ if(fd == -1)
+ {
+ assert(0);
+ throw RandomGeneratorException(__FILE__, __LINE__);
+ }
}
//
@@ -179,26 +179,26 @@ IceUtil::generateRandom(char* buffer, int size)
size_t index = 0;
while(reads <= 20 && index != static_cast<size_t>(size))
{
- ssize_t bytesRead = read(fd, buffer + index, static_cast<size_t>(size) - index);
-
- if(bytesRead == -1 && errno != EINTR)
- {
- int err = errno;
- cerr << "Reading /dev/urandom returned " << strerror(err) << endl;
- assert(0);
- throw RandomGeneratorException(__FILE__, __LINE__, errno);
- }
- else
- {
- index += bytesRead;
- reads++;
- }
+ ssize_t bytesRead = read(fd, buffer + index, static_cast<size_t>(size) - index);
+
+ if(bytesRead == -1 && errno != EINTR)
+ {
+ int err = errno;
+ cerr << "Reading /dev/urandom returned " << strerror(err) << endl;
+ assert(0);
+ throw RandomGeneratorException(__FILE__, __LINE__, errno);
+ }
+ else
+ {
+ index += bytesRead;
+ reads++;
+ }
}
-
+
if(index != static_cast<size_t>(size))
{
- assert(0);
- throw RandomGeneratorException(__FILE__, __LINE__);
+ assert(0);
+ throw RandomGeneratorException(__FILE__, __LINE__);
}
#endif
}
@@ -210,11 +210,11 @@ IceUtil::random(int limit)
generateRandom(reinterpret_cast<char*>(&r), static_cast<int>(sizeof(int)));
if(limit > 0)
{
- r = r % limit;
+ r = r % limit;
}
if(r < 0)
{
- r = -r;
+ r = -r;
}
return r;
}
diff --git a/cpp/src/IceUtil/RecMutex.cpp b/cpp/src/IceUtil/RecMutex.cpp
index 1682917b2e0..4571750e030 100644
--- a/cpp/src/IceUtil/RecMutex.cpp
+++ b/cpp/src/IceUtil/RecMutex.cpp
@@ -34,7 +34,7 @@ IceUtil::RecMutex::lock() const
EnterCriticalSection(&_mutex);
if(++_count > 1)
{
- LeaveCriticalSection(&_mutex);
+ LeaveCriticalSection(&_mutex);
}
}
@@ -43,11 +43,11 @@ IceUtil::RecMutex::tryLock() const
{
if(!TryEnterCriticalSection(&_mutex))
{
- return false;
+ return false;
}
if(++_count > 1)
{
- LeaveCriticalSection(&_mutex);
+ LeaveCriticalSection(&_mutex);
}
return true;
}
@@ -57,7 +57,7 @@ IceUtil::RecMutex::unlock() const
{
if(--_count == 0)
{
- LeaveCriticalSection(&_mutex);
+ LeaveCriticalSection(&_mutex);
}
}
@@ -84,7 +84,7 @@ IceUtil::RecMutex::RecMutex() :
_mutex = CreateMutex(0, false, 0);
if(_mutex == 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
}
@@ -94,7 +94,7 @@ IceUtil::RecMutex::~RecMutex()
BOOL rc = CloseHandle(_mutex);
if(rc == 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
}
@@ -104,23 +104,23 @@ IceUtil::RecMutex::lock() const
DWORD rc = WaitForSingleObject(_mutex, INFINITE);
if(rc != WAIT_OBJECT_0)
{
- if(rc == WAIT_FAILED)
- {
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
- }
- else
- {
- throw ThreadSyscallException(__FILE__, __LINE__, 0);
- }
+ if(rc == WAIT_FAILED)
+ {
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ }
+ else
+ {
+ throw ThreadSyscallException(__FILE__, __LINE__, 0);
+ }
}
if(++_count > 1)
{
- BOOL rc2 = ReleaseMutex(_mutex);
- if(rc2 == 0)
- {
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
- }
+ BOOL rc2 = ReleaseMutex(_mutex);
+ if(rc2 == 0)
+ {
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ }
}
}
@@ -130,15 +130,15 @@ IceUtil::RecMutex::tryLock() const
DWORD rc = WaitForSingleObject(_mutex, 0);
if(rc != WAIT_OBJECT_0)
{
- return false;
+ return false;
}
if(++_count > 1)
{
- BOOL rc2 = ReleaseMutex(_mutex);
- if(rc2 == 0)
- {
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
- }
+ BOOL rc2 = ReleaseMutex(_mutex);
+ if(rc2 == 0)
+ {
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ }
}
return true;
}
@@ -148,11 +148,11 @@ IceUtil::RecMutex::unlock() const
{
if(--_count == 0)
{
- BOOL rc = ReleaseMutex(_mutex);
- if(rc == 0)
- {
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
- }
+ BOOL rc = ReleaseMutex(_mutex);
+ if(rc == 0)
+ {
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ }
}
}
@@ -164,7 +164,7 @@ IceUtil::RecMutex::unlock(LockState& state) const
BOOL rc = ReleaseMutex(_mutex);
if(rc == 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
}
@@ -174,14 +174,14 @@ IceUtil::RecMutex::lock(LockState& state) const
DWORD rc = WaitForSingleObject(_mutex, INFINITE);
if(rc != WAIT_OBJECT_0)
{
- if(rc == WAIT_FAILED)
- {
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
- }
- else
- {
- throw ThreadSyscallException(__FILE__, __LINE__, 0);
- }
+ if(rc == WAIT_FAILED)
+ {
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ }
+ else
+ {
+ throw ThreadSyscallException(__FILE__, __LINE__, 0);
+ }
}
_count = state.count;
@@ -203,19 +203,19 @@ IceUtil::RecMutex::RecMutex() :
rc = pthread_mutexattr_init(&attr);
if(rc != 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
rc = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
if(rc != 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
#endif
rc = pthread_mutex_init(&_mutex, &attr);
if(rc != 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
#if defined(__linux) && !defined(__USE_UNIX98)
@@ -224,7 +224,7 @@ IceUtil::RecMutex::RecMutex() :
rc = pthread_mutexattr_destroy(&attr);
if(rc != 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
#endif
}
@@ -243,12 +243,12 @@ IceUtil::RecMutex::lock() const
int rc = pthread_mutex_lock(&_mutex);
if(rc != 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
if(++_count > 1)
{
- rc = pthread_mutex_unlock(&_mutex);
- assert(rc == 0);
+ rc = pthread_mutex_unlock(&_mutex);
+ assert(rc == 0);
}
}
@@ -259,18 +259,18 @@ IceUtil::RecMutex::tryLock() const
bool result = (rc == 0);
if(!result)
{
- if(rc != EBUSY)
- {
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
- }
+ if(rc != EBUSY)
+ {
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ }
}
else if(++_count > 1)
{
- rc = pthread_mutex_unlock(&_mutex);
- if(rc != 0)
- {
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
- }
+ rc = pthread_mutex_unlock(&_mutex);
+ if(rc != 0)
+ {
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ }
}
return result;
}
@@ -280,9 +280,9 @@ IceUtil::RecMutex::unlock() const
{
if(--_count == 0)
{
- int rc = 0; // Prevent warnings when NDEBUG is defined.
- rc = pthread_mutex_unlock(&_mutex);
- assert(rc == 0);
+ int rc = 0; // Prevent warnings when NDEBUG is defined.
+ rc = pthread_mutex_unlock(&_mutex);
+ assert(rc == 0);
}
}
diff --git a/cpp/src/IceUtil/StaticMutex.cpp b/cpp/src/IceUtil/StaticMutex.cpp
index 857147a0496..f573bbbd4b9 100644
--- a/cpp/src/IceUtil/StaticMutex.cpp
+++ b/cpp/src/IceUtil/StaticMutex.cpp
@@ -55,14 +55,14 @@ Init::~Init()
{
# if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0400
for(MutexList::iterator p = _mutexList->begin();
- p != _mutexList->end(); ++p)
+ p != _mutexList->end(); ++p)
{
- DeleteCriticalSection(*p);
- delete *p;
+ DeleteCriticalSection(*p);
+ delete *p;
}
# else
for_each(_mutexList->begin(), _mutexList->end(),
- CloseHandle);
+ CloseHandle);
# endif
delete _mutexList;
DeleteCriticalSection(&_criticalSection);
@@ -83,25 +83,25 @@ void IceUtil::StaticMutex::initialize() const
if(_mutex == 0)
{
# if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0400
- CRITICAL_SECTION* newMutex = new CRITICAL_SECTION;
- InitializeCriticalSection(newMutex);
+ CRITICAL_SECTION* newMutex = new CRITICAL_SECTION;
+ InitializeCriticalSection(newMutex);
# else
- _recursionCount = 0;
-
- HANDLE newMutex = CreateMutex(0, false, 0);
- if(newMutex == 0)
- {
- LeaveCriticalSection(&_criticalSection);
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
- }
+ _recursionCount = 0;
+
+ HANDLE newMutex = CreateMutex(0, false, 0);
+ if(newMutex == 0)
+ {
+ LeaveCriticalSection(&_criticalSection);
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ }
# endif
- //
- // _mutex is written after the new initialized CRITICAL_SECTION/Mutex
- //
- void* oldVal = InterlockedCompareExchangePointer(reinterpret_cast<void**>(&_mutex), newMutex, 0);
- assert(oldVal == 0);
- _mutexList->push_back(_mutex);
+ //
+ // _mutex is written after the new initialized CRITICAL_SECTION/Mutex
+ //
+ void* oldVal = InterlockedCompareExchangePointer(reinterpret_cast<void**>(&_mutex), newMutex, 0);
+ assert(oldVal == 0);
+ _mutexList->push_back(_mutex);
}
LeaveCriticalSection(&_criticalSection);
diff --git a/cpp/src/IceUtil/StringUtil.cpp b/cpp/src/IceUtil/StringUtil.cpp
index 12ce3e3cd1e..30029300f59 100644
--- a/cpp/src/IceUtil/StringUtil.cpp
+++ b/cpp/src/IceUtil/StringUtil.cpp
@@ -42,86 +42,86 @@ encodeChar(string::value_type b, string& s, const string& special)
{
switch(b)
{
- case '\\':
- {
- s.append("\\\\");
- break;
- }
-
- case '\'':
- {
- s.append("\\'");
- break;
- }
-
- case '"':
- {
- s.append("\\\"");
- break;
- }
-
- case '\b':
- {
- s.append("\\b");
- break;
- }
-
- case '\f':
- {
- s.append("\\f");
- break;
- }
-
- case '\n':
- {
- s.append("\\n");
- break;
- }
-
- case '\r':
- {
- s.append("\\r");
- break;
- }
-
- case '\t':
- {
- s.append("\\t");
- break;
- }
-
- default:
- {
- unsigned char i = static_cast<unsigned char>(b);
- if(!(i >= 32 && i <= 126))
- {
- s.push_back('\\');
- string octal = toOctalString(i);
- //
- // Add leading zeroes so that we avoid problems during
- // decoding. For example, consider the escaped string
- // \0013 (i.e., a character with value 1 followed by the
- // character '3'). If the leading zeroes were omitted, the
- // result would be incorrectly interpreted as a single
- // character with value 11.
- //
- for(string::size_type j = octal.size(); j < 3; j++)
- {
- s.push_back('0');
- }
- s.append(octal);
- }
- else if(special.find(b) != string::npos)
- {
- s.push_back('\\');
- s.push_back(b);
- }
- else
- {
- s.push_back(b);
- }
- break;
- }
+ case '\\':
+ {
+ s.append("\\\\");
+ break;
+ }
+
+ case '\'':
+ {
+ s.append("\\'");
+ break;
+ }
+
+ case '"':
+ {
+ s.append("\\\"");
+ break;
+ }
+
+ case '\b':
+ {
+ s.append("\\b");
+ break;
+ }
+
+ case '\f':
+ {
+ s.append("\\f");
+ break;
+ }
+
+ case '\n':
+ {
+ s.append("\\n");
+ break;
+ }
+
+ case '\r':
+ {
+ s.append("\\r");
+ break;
+ }
+
+ case '\t':
+ {
+ s.append("\\t");
+ break;
+ }
+
+ default:
+ {
+ unsigned char i = static_cast<unsigned char>(b);
+ if(!(i >= 32 && i <= 126))
+ {
+ s.push_back('\\');
+ string octal = toOctalString(i);
+ //
+ // Add leading zeroes so that we avoid problems during
+ // decoding. For example, consider the escaped string
+ // \0013 (i.e., a character with value 1 followed by the
+ // character '3'). If the leading zeroes were omitted, the
+ // result would be incorrectly interpreted as a single
+ // character with value 11.
+ //
+ for(string::size_type j = octal.size(); j < 3; j++)
+ {
+ s.push_back('0');
+ }
+ s.append(octal);
+ }
+ else if(special.find(b) != string::npos)
+ {
+ s.push_back('\\');
+ s.push_back(b);
+ }
+ else
+ {
+ s.push_back(b);
+ }
+ break;
+ }
}
}
@@ -136,16 +136,16 @@ IceUtil::escapeString(const string& s, const string& special)
string::size_type i;
for(i = 0; i < special.size(); ++i)
{
- if(static_cast<unsigned char>(special[i]) < 32 || static_cast<unsigned char>(special[i]) > 126)
- {
- throw IllegalArgumentException(__FILE__, __LINE__, "special characters must be in ASCII range 32-126");
- }
+ if(static_cast<unsigned char>(special[i]) < 32 || static_cast<unsigned char>(special[i]) > 126)
+ {
+ throw IllegalArgumentException(__FILE__, __LINE__, "special characters must be in ASCII range 32-126");
+ }
}
string result;
for(i = 0; i < s.size(); ++i)
{
- encodeChar(s[i], result, special);
+ encodeChar(s[i], result, special);
}
return result;
@@ -178,86 +178,86 @@ decodeChar(const string& s, string::size_type start, string::size_type end, stri
if(s[start] != '\\')
{
- c = checkChar(s[start++]);
+ c = checkChar(s[start++]);
}
else
{
- if(start + 1 == end)
- {
- throw IllegalArgumentException(__FILE__, __LINE__, "trailing backslash in argument");
- }
- switch(s[++start])
- {
- case '\\':
- case '\'':
- case '"':
- {
- c = s[start++];
- break;
- }
- case 'b':
- {
- ++start;
- c = '\b';
- break;
- }
- case 'f':
- {
- ++start;
- c = '\f';
- break;
- }
- case 'n':
- {
- ++start;
- c = '\n';
- break;
- }
- case 'r':
- {
- ++start;
- c = '\r';
- break;
- }
- case 't':
- {
- ++start;
- c = '\t';
- break;
- }
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- {
- int oct = 0;
- for(int j = 0; j < 3 && start < end; ++j)
- {
- int charVal = s[start++] - '0';
- if(charVal < 0 || charVal > 7)
- {
- --start;
- break;
- }
- oct = oct * 8 + charVal;
- }
- if(oct > 255)
- {
- throw IllegalArgumentException(__FILE__, __LINE__, "octal value out of range");
- }
- c = (char)oct;
- break;
- }
- default:
- {
- c = checkChar(s[start++]);
- break;
- }
- }
+ if(start + 1 == end)
+ {
+ throw IllegalArgumentException(__FILE__, __LINE__, "trailing backslash in argument");
+ }
+ switch(s[++start])
+ {
+ case '\\':
+ case '\'':
+ case '"':
+ {
+ c = s[start++];
+ break;
+ }
+ case 'b':
+ {
+ ++start;
+ c = '\b';
+ break;
+ }
+ case 'f':
+ {
+ ++start;
+ c = '\f';
+ break;
+ }
+ case 'n':
+ {
+ ++start;
+ c = '\n';
+ break;
+ }
+ case 'r':
+ {
+ ++start;
+ c = '\r';
+ break;
+ }
+ case 't':
+ {
+ ++start;
+ c = '\t';
+ break;
+ }
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ {
+ int oct = 0;
+ for(int j = 0; j < 3 && start < end; ++j)
+ {
+ int charVal = s[start++] - '0';
+ if(charVal < 0 || charVal > 7)
+ {
+ --start;
+ break;
+ }
+ oct = oct * 8 + charVal;
+ }
+ if(oct > 255)
+ {
+ throw IllegalArgumentException(__FILE__, __LINE__, "octal value out of range");
+ }
+ c = (char)oct;
+ break;
+ }
+ default:
+ {
+ c = checkChar(s[start++]);
+ break;
+ }
+ }
}
nextStart = start;
return c;
@@ -271,7 +271,7 @@ static void decodeString(const string& s, string::size_type start, string::size_
{
while(start < end)
{
- sb.push_back(decodeChar(s, start, end, start));
+ sb.push_back(decodeChar(s, start, end, start));
}
}
@@ -291,20 +291,20 @@ IceUtil::unescapeString(const string& s, string::size_type start, string::size_t
}
if(start > end)
{
- throw IllegalArgumentException(__FILE__, __LINE__, "start offset must <= end offset");
+ throw IllegalArgumentException(__FILE__, __LINE__, "start offset must <= end offset");
}
result.reserve(end - start);
try
{
- result.clear();
- decodeString(s, start, end, result);
- return true;
+ result.clear();
+ decodeString(s, start, end, result);
+ return true;
}
catch(...)
{
- return false;
+ return false;
}
}
@@ -320,17 +320,17 @@ IceUtil::checkQuote(const string& s, string::size_type start)
string::value_type quoteChar = s[start];
if(quoteChar == '"' || quoteChar == '\'')
{
- start++;
- string::size_type pos;
- while(start < s.size() && (pos = s.find(quoteChar, start)) != string::npos)
- {
- if(s[pos - 1] != '\\')
- {
- return pos;
- }
- start = pos + 1;
- }
- return string::npos; // Unmatched quote.
+ start++;
+ string::size_type pos;
+ while(start < s.size() && (pos = s.find(quoteChar, start)) != string::npos)
+ {
+ if(s[pos - 1] != '\\')
+ {
+ return pos;
+ }
+ start = pos + 1;
+ }
+ return string::npos; // Unmatched quote.
}
return 0; // Not quoted.
}
diff --git a/cpp/src/IceUtil/Thread.cpp b/cpp/src/IceUtil/Thread.cpp
index 86658d581b4..70c4aa8b52c 100644
--- a/cpp/src/IceUtil/Thread.cpp
+++ b/cpp/src/IceUtil/Thread.cpp
@@ -44,13 +44,13 @@ IceUtil::ThreadControl::join()
{
if(_handle == 0)
{
- throw BadThreadControlException(__FILE__, __LINE__);
+ throw BadThreadControlException(__FILE__, __LINE__);
}
int rc = WaitForSingleObject(_handle, INFINITE);
if(rc != WAIT_OBJECT_0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
detach();
@@ -61,12 +61,12 @@ IceUtil::ThreadControl::detach()
{
if(_handle == 0)
{
- throw BadThreadControlException(__FILE__, __LINE__);
+ throw BadThreadControlException(__FILE__, __LINE__);
}
if(CloseHandle(_handle) == 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
}
@@ -115,13 +115,13 @@ WINAPI startHook(void* arg)
try
{
- IceUtil::Thread* rawThread = static_cast<IceUtil::Thread*>(arg);
+ IceUtil::Thread* rawThread = static_cast<IceUtil::Thread*>(arg);
- //
- // Ensure that the thread doesn't go away until run() has
- // completed.
- //
- thread = rawThread;
+ //
+ // Ensure that the thread doesn't go away until run() has
+ // completed.
+ //
+ thread = rawThread;
#ifdef _WIN32
//
@@ -132,20 +132,20 @@ WINAPI startHook(void* arg)
srand(seed ^ thread->getThreadControl().id());
#endif
- //
- // See the comment in IceUtil::Thread::start() for details.
- //
- rawThread->__decRef();
- thread->run();
+ //
+ // See the comment in IceUtil::Thread::start() for details.
+ //
+ rawThread->__decRef();
+ thread->run();
}
catch(const IceUtil::Exception& e)
{
- cerr << "IceUtil::Thread::run(): uncaught exception: ";
- cerr << e << endl;
+ cerr << "IceUtil::Thread::run(): uncaught exception: ";
+ cerr << e << endl;
}
catch(...)
{
- cerr << "IceUtil::Thread::run(): uncaught exception" << endl;
+ cerr << "IceUtil::Thread::run(): uncaught exception" << endl;
}
thread->_done();
@@ -166,7 +166,7 @@ IceUtil::Thread::start(size_t stackSize)
if(_started)
{
- throw ThreadStartedException(__FILE__, __LINE__);
+ throw ThreadStartedException(__FILE__, __LINE__);
}
//
@@ -185,19 +185,19 @@ IceUtil::Thread::start(size_t stackSize)
_handle =
reinterpret_cast<HANDLE>(
_beginthreadex(0,
- static_cast<unsigned int>(stackSize),
- startHook, this, 0, &id));
+ static_cast<unsigned int>(stackSize),
+ startHook, this, 0, &id));
_id = id;
if(_handle == 0)
{
- __decRef();
- throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
+ __decRef();
+ throw ThreadSyscallException(__FILE__, __LINE__, GetLastError());
}
_started = true;
_running = true;
-
+
return ThreadControl(_handle, _id);
}
@@ -207,7 +207,7 @@ IceUtil::Thread::getThreadControl() const
IceUtil::Mutex::Lock lock(_stateMutex);
if(!_started)
{
- throw ThreadNotStartedException(__FILE__, __LINE__);
+ throw ThreadNotStartedException(__FILE__, __LINE__);
}
return ThreadControl(_handle, _id);
}
@@ -275,14 +275,14 @@ IceUtil::ThreadControl::join()
{
if(!_detachable)
{
- throw BadThreadControlException(__FILE__, __LINE__);
+ throw BadThreadControlException(__FILE__, __LINE__);
}
void* ignore = 0;
int rc = pthread_join(_thread, &ignore);
if(rc != 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
}
@@ -291,13 +291,13 @@ IceUtil::ThreadControl::detach()
{
if(!_detachable)
{
- throw BadThreadControlException(__FILE__, __LINE__);
+ throw BadThreadControlException(__FILE__, __LINE__);
}
int rc = pthread_detach(_thread);
if(rc != 0)
{
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
}
}
@@ -346,24 +346,24 @@ startHook(void* arg)
try
{
- IceUtil::Thread* rawThread = static_cast<IceUtil::Thread*>(arg);
+ IceUtil::Thread* rawThread = static_cast<IceUtil::Thread*>(arg);
- thread = rawThread;
+ thread = rawThread;
- //
- // See the comment in IceUtil::Thread::start() for details.
- //
- rawThread->__decRef();
- thread->run();
+ //
+ // See the comment in IceUtil::Thread::start() for details.
+ //
+ rawThread->__decRef();
+ thread->run();
}
catch(const IceUtil::Exception& e)
{
- cerr << "IceUtil::Thread::run(): uncaught exception: ";
- cerr << e << endl;
+ cerr << "IceUtil::Thread::run(): uncaught exception: ";
+ cerr << e << endl;
}
catch(...)
{
- cerr << "IceUtil::Thread::run(): uncaught exception" << endl;
+ cerr << "IceUtil::Thread::run(): uncaught exception" << endl;
}
thread->_done();
@@ -383,7 +383,7 @@ IceUtil::Thread::start(size_t stackSize)
if(_started)
{
- throw ThreadStartedException(__FILE__, __LINE__);
+ throw ThreadStartedException(__FILE__, __LINE__);
}
//
@@ -399,34 +399,34 @@ IceUtil::Thread::start(size_t stackSize)
if(stackSize > 0)
{
- pthread_attr_t attr;
- int rc = pthread_attr_init(&attr);
- if(rc != 0)
- {
- __decRef();
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
- }
- rc = pthread_attr_setstacksize(&attr, stackSize);
- if(rc != 0)
- {
- __decRef();
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
- }
- rc = pthread_create(&_thread, &attr, startHook, this);
- if(rc != 0)
- {
- __decRef();
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
- }
+ pthread_attr_t attr;
+ int rc = pthread_attr_init(&attr);
+ if(rc != 0)
+ {
+ __decRef();
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ }
+ rc = pthread_attr_setstacksize(&attr, stackSize);
+ if(rc != 0)
+ {
+ __decRef();
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ }
+ rc = pthread_create(&_thread, &attr, startHook, this);
+ if(rc != 0)
+ {
+ __decRef();
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ }
}
else
{
- int rc = pthread_create(&_thread, 0, startHook, this);
- if(rc != 0)
- {
- __decRef();
- throw ThreadSyscallException(__FILE__, __LINE__, rc);
- }
+ int rc = pthread_create(&_thread, 0, startHook, this);
+ if(rc != 0)
+ {
+ __decRef();
+ throw ThreadSyscallException(__FILE__, __LINE__, rc);
+ }
}
_started = true;
@@ -441,7 +441,7 @@ IceUtil::Thread::getThreadControl() const
IceUtil::Mutex::Lock lock(_stateMutex);
if(!_started)
{
- throw ThreadNotStartedException(__FILE__, __LINE__);
+ throw ThreadNotStartedException(__FILE__, __LINE__);
}
return ThreadControl(_thread);
}
diff --git a/cpp/src/IceUtil/ThreadException.cpp b/cpp/src/IceUtil/ThreadException.cpp
index 83f162933e0..4f474723feb 100644
--- a/cpp/src/IceUtil/ThreadException.cpp
+++ b/cpp/src/IceUtil/ThreadException.cpp
@@ -31,30 +31,30 @@ IceUtil::ThreadSyscallException::ice_print(ostream& os) const
Exception::ice_print(os);
if(_error != 0)
{
- os << ":\nthread syscall exception: ";
+ os << ":\nthread syscall exception: ";
#ifdef _WIN32
- LPVOID lpMsgBuf = 0;
- DWORD ok = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- _error,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPTSTR)&lpMsgBuf,
- 0,
- NULL);
-
- if(ok)
- {
- LPCTSTR msg = (LPCTSTR)lpMsgBuf;
- assert(msg && strlen((char*)msg) > 0);
- os << msg;
- LocalFree(lpMsgBuf);
- }
- else
- {
- os << "unknown thread error";
- }
+ LPVOID lpMsgBuf = 0;
+ DWORD ok = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ _error,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR)&lpMsgBuf,
+ 0,
+ NULL);
+
+ if(ok)
+ {
+ LPCTSTR msg = (LPCTSTR)lpMsgBuf;
+ assert(msg && strlen((char*)msg) > 0);
+ os << msg;
+ LocalFree(lpMsgBuf);
+ }
+ else
+ {
+ os << "unknown thread error";
+ }
#else
os << strerror(_error);
#endif
diff --git a/cpp/src/IceUtil/Time.cpp b/cpp/src/IceUtil/Time.cpp
index 1325afe0d42..c39c2bcf53e 100644
--- a/cpp/src/IceUtil/Time.cpp
+++ b/cpp/src/IceUtil/Time.cpp
@@ -37,7 +37,7 @@ IceUtil::Time::now()
ftime(&tb);
# endif
return Time(static_cast<Int64>(tb.time) * ICE_INT64(1000000) +
- tb.millitm * 1000);
+ tb.millitm * 1000);
#else
struct timeval tv;
gettimeofday(&tv, 0);
diff --git a/cpp/src/IceUtil/UUID.cpp b/cpp/src/IceUtil/UUID.cpp
index 7c0eb5c7847..af8253b0991 100644
--- a/cpp/src/IceUtil/UUID.cpp
+++ b/cpp/src/IceUtil/UUID.cpp
@@ -40,9 +40,9 @@ public:
PidInitializer()
{
- pid_t p = getpid();
- myPid[0] = (p >> 8) & 0x7F;
- myPid[1] = p & 0xFF;
+ pid_t p = getpid();
+ myPid[0] = (p >> 8) & 0x7F;
+ myPid[1] = p & 0xFF;
}
};
static PidInitializer pidInitializer;
@@ -56,11 +56,11 @@ inline void halfByteToHex(unsigned char hb, char*& hexBuffer)
{
if(hb < 10)
{
- *hexBuffer++ = '0' + hb;
+ *hexBuffer++ = '0' + hb;
}
else
{
- *hexBuffer++ = 'A' + (hb - 10);
+ *hexBuffer++ = 'A' + (hb - 10);
}
}
@@ -68,8 +68,8 @@ inline void bytesToHex(unsigned char* bytes, size_t len, char*& hexBuffer)
{
for(size_t i = 0; i < len; i++)
{
- halfByteToHex((bytes[i] & 0xF0) >> 4, hexBuffer);
- halfByteToHex((bytes[i] & 0x0F), hexBuffer);
+ halfByteToHex((bytes[i] & 0xF0) >> 4, hexBuffer);
+ halfByteToHex((bytes[i] & 0x0F), hexBuffer);
}
}
@@ -93,12 +93,12 @@ IceUtil::generateUUID()
#else
struct UUID
{
- unsigned char timeLow[4];
- unsigned char timeMid[2];
- unsigned char timeHighAndVersion[2];
- unsigned char clockSeqHiAndReserved;
- unsigned char clockSeqLow;
- unsigned char node[6];
+ unsigned char timeLow[4];
+ unsigned char timeMid[2];
+ unsigned char timeHighAndVersion[2];
+ unsigned char clockSeqHiAndReserved;
+ unsigned char clockSeqLow;
+ unsigned char node[6];
};
UUID uuid;
diff --git a/cpp/src/IceUtil/Unicode.cpp b/cpp/src/IceUtil/Unicode.cpp
index fb7890e2a91..20fc1f89c01 100644
--- a/cpp/src/IceUtil/Unicode.cpp
+++ b/cpp/src/IceUtil/Unicode.cpp
@@ -23,35 +23,35 @@ template<size_t wcharSize>
struct WstringHelper
{
static ConversionResult toUTF8(
- const wchar_t*& sourceStart, const wchar_t* sourceEnd,
- Byte*& targetStart, Byte* targetEnd, ConversionFlags flags);
+ const wchar_t*& sourceStart, const wchar_t* sourceEnd,
+ Byte*& targetStart, Byte* targetEnd, ConversionFlags flags);
static ConversionResult fromUTF8(
- const Byte*& sourceStart, const Byte* sourceEnd,
- wchar_t*& targetStart, wchar_t* targetEnd, ConversionFlags flags);
+ const Byte*& sourceStart, const Byte* sourceEnd,
+ wchar_t*& targetStart, wchar_t* targetEnd, ConversionFlags flags);
};
template<>
struct WstringHelper<2>
{
static ConversionResult toUTF8(
- const wchar_t*& sourceStart, const wchar_t* sourceEnd,
- Byte*& targetStart, Byte* targetEnd, ConversionFlags flags)
+ const wchar_t*& sourceStart, const wchar_t* sourceEnd,
+ Byte*& targetStart, Byte* targetEnd, ConversionFlags flags)
{
- return ConvertUTF16toUTF8(
- reinterpret_cast<const UTF16**>(&sourceStart),
- reinterpret_cast<const UTF16*>(sourceEnd),
- &targetStart, targetEnd, flags);
+ return ConvertUTF16toUTF8(
+ reinterpret_cast<const UTF16**>(&sourceStart),
+ reinterpret_cast<const UTF16*>(sourceEnd),
+ &targetStart, targetEnd, flags);
}
static ConversionResult fromUTF8(
- const Byte*& sourceStart, const Byte* sourceEnd,
- wchar_t*& targetStart, wchar_t* targetEnd, ConversionFlags flags)
+ const Byte*& sourceStart, const Byte* sourceEnd,
+ wchar_t*& targetStart, wchar_t* targetEnd, ConversionFlags flags)
{
- return ConvertUTF8toUTF16(
- &sourceStart, sourceEnd,
- reinterpret_cast<UTF16**>(&targetStart),
- reinterpret_cast<UTF16*>(targetEnd), flags);
+ return ConvertUTF8toUTF16(
+ &sourceStart, sourceEnd,
+ reinterpret_cast<UTF16**>(&targetStart),
+ reinterpret_cast<UTF16*>(targetEnd), flags);
}
};
@@ -59,23 +59,23 @@ template<>
struct WstringHelper<4>
{
static ConversionResult toUTF8(
- const wchar_t*& sourceStart, const wchar_t* sourceEnd,
- Byte*& targetStart, Byte* targetEnd, ConversionFlags flags)
+ const wchar_t*& sourceStart, const wchar_t* sourceEnd,
+ Byte*& targetStart, Byte* targetEnd, ConversionFlags flags)
{
- return ConvertUTF32toUTF8(
- reinterpret_cast<const UTF32**>(&sourceStart),
- reinterpret_cast<const UTF32*>(sourceEnd),
- &targetStart, targetEnd, flags);
+ return ConvertUTF32toUTF8(
+ reinterpret_cast<const UTF32**>(&sourceStart),
+ reinterpret_cast<const UTF32*>(sourceEnd),
+ &targetStart, targetEnd, flags);
}
static ConversionResult fromUTF8(
- const Byte*& sourceStart, const Byte* sourceEnd,
- wchar_t*& targetStart, wchar_t* targetEnd, ConversionFlags flags)
+ const Byte*& sourceStart, const Byte* sourceEnd,
+ wchar_t*& targetStart, wchar_t* targetEnd, ConversionFlags flags)
{
- return ConvertUTF8toUTF32(
- &sourceStart, sourceEnd,
- reinterpret_cast<UTF32**>(&targetStart),
- reinterpret_cast<UTF32*>(targetEnd), flags);
+ return ConvertUTF8toUTF32(
+ &sourceStart, sourceEnd,
+ reinterpret_cast<UTF32**>(&targetStart),
+ reinterpret_cast<UTF32*>(targetEnd), flags);
}
};
}
@@ -90,7 +90,7 @@ IceUtil::convertUTFWstringToUTF8(
Byte*& targetStart, Byte* targetEnd, ConversionFlags flags)
{
return WstringHelper<sizeof(wchar_t)>::toUTF8(
- sourceStart, sourceEnd, targetStart, targetEnd, flags);
+ sourceStart, sourceEnd, targetStart, targetEnd, flags);
}
ConversionResult
@@ -99,12 +99,12 @@ IceUtil::convertUTF8ToUTFWstring(
wchar_t*& targetStart, wchar_t* targetEnd, ConversionFlags flags)
{
return WstringHelper<sizeof(wchar_t)>::fromUTF8(
- sourceStart, sourceEnd, targetStart, targetEnd, flags);
+ sourceStart, sourceEnd, targetStart, targetEnd, flags);
}
ConversionResult
IceUtil::convertUTF8ToUTFWstring(const Byte*& sourceStart, const Byte* sourceEnd,
- std::wstring& target, ConversionFlags flags)
+ std::wstring& target, ConversionFlags flags)
{
//
// Could be reimplemented without this temporary wchar_t buffer
@@ -115,13 +115,13 @@ IceUtil::convertUTF8ToUTFWstring(const Byte*& sourceStart, const Byte* sourceEnd
wchar_t* targetEnd = targetStart + size;
ConversionResult result =
- convertUTF8ToUTFWstring(sourceStart, sourceEnd, targetStart,
- targetEnd, flags);
+ convertUTF8ToUTFWstring(sourceStart, sourceEnd, targetStart,
+ targetEnd, flags);
if(result == conversionOK)
{
- std::wstring s(outBuf, static_cast<size_t>(targetStart - outBuf));
- s.swap(target);
+ std::wstring s(outBuf, static_cast<size_t>(targetStart - outBuf));
+ s.swap(target);
}
delete[] outBuf;
return result;
@@ -135,7 +135,7 @@ IceUtil::convertUTF8ToUTFWstring(const Byte*& sourceStart, const Byte* sourceEnd
const char* IceUtil::UTFConversionException::_name = "IceUtil::UTFConversionException";
IceUtil::UTFConversionException::UTFConversionException(const char* file, int line,
- ConversionResult cr):
+ ConversionResult cr):
Exception(file, line),
_conversionResult(cr)
{}
@@ -152,18 +152,18 @@ IceUtil::UTFConversionException::ice_print(ostream& os) const
Exception::ice_print(os);
switch(_conversionResult)
{
- case sourceExhausted:
- os << ": source exhausted";
- break;
- case targetExhausted:
- os << ": target exhausted";
- break;
- case sourceIllegal:
- os << ": illegal source";
- break;
- default:
- assert(0);
- break;
+ case sourceExhausted:
+ os << ": source exhausted";
+ break;
+ case targetExhausted:
+ os << ": target exhausted";
+ break;
+ case sourceIllegal:
+ os << ": illegal source";
+ break;
+ default:
+ assert(0);
+ break;
};
}
@@ -200,18 +200,18 @@ IceUtil::wstringToString(const wstring& wstr)
const wchar_t* sourceStart = wstr.data();
ConversionResult cr =
- convertUTFWstringToUTF8(
- sourceStart, sourceStart + wstr.size(),
- targetStart, targetEnd, lenientConversion);
-
+ convertUTFWstringToUTF8(
+ sourceStart, sourceStart + wstr.size(),
+ targetStart, targetEnd, lenientConversion);
+
if(cr != conversionOK)
{
- delete[] outBuf;
- throw UTFConversionException(__FILE__, __LINE__, cr);
+ delete[] outBuf;
+ throw UTFConversionException(__FILE__, __LINE__, cr);
}
string s(reinterpret_cast<char*>(outBuf),
- static_cast<size_t>(targetStart - outBuf));
+ static_cast<size_t>(targetStart - outBuf));
s.swap(target);
delete[] outBuf;
return target;
@@ -224,12 +224,12 @@ IceUtil::stringToWstring(const string& str)
const Byte* sourceStart = reinterpret_cast<const Byte*>(str.data());
ConversionResult cr
- = convertUTF8ToUTFWstring(sourceStart, sourceStart + str.size(),
- result, lenientConversion);
+ = convertUTF8ToUTFWstring(sourceStart, sourceStart + str.size(),
+ result, lenientConversion);
if(cr != conversionOK)
{
- throw UTFConversionException(__FILE__, __LINE__, cr);
+ throw UTFConversionException(__FILE__, __LINE__, cr);
}
return result;
}
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp
index b4f9d48f8d0..0bbd0750002 100644
--- a/cpp/src/Slice/CPlusPlusUtil.cpp
+++ b/cpp/src/Slice/CPlusPlusUtil.cpp
@@ -18,11 +18,11 @@ Slice::ToIfdef::operator()(char c)
{
if(!isalnum(c))
{
- return '_';
+ return '_';
}
else
{
- return c;
+ return c;
}
}
@@ -56,21 +56,21 @@ Slice::changeInclude(const string& orig, const vector<string>& includePaths)
string result = file;
for(vector<string>::const_iterator p = includePaths.begin(); p != includePaths.end(); ++p)
{
- string includePath = normalizePath(*p);
+ string includePath = normalizePath(*p);
- if(file.compare(0, includePath.length(), includePath) == 0)
- {
- string s = file.substr(includePath.length());
- if(s.size() < result.size())
- {
- result = s;
- }
- }
+ if(file.compare(0, includePath.length(), includePath) == 0)
+ {
+ string s = file.substr(includePath.length());
+ if(s.size() < result.size())
+ {
+ result = s;
+ }
+ }
}
if((pos = result.rfind('.')) != string::npos)
{
- result.erase(pos);
+ result.erase(pos);
}
return result;
@@ -101,29 +101,29 @@ Slice::printVersionCheck(Output& out)
out << "\n#ifndef ICE_IGNORE_VERSION";
if(ICE_INT_VERSION % 100 > 50)
{
- //
- // Beta version: exact match required
- //
- out << "\n# if ICE_INT_VERSION != " << ICE_INT_VERSION;
- out << "\n# error Ice version mismatch: an exact match is required for beta generated code";
- out << "\n# endif";
+ //
+ // Beta version: exact match required
+ //
+ out << "\n# if ICE_INT_VERSION != " << ICE_INT_VERSION;
+ out << "\n# error Ice version mismatch: an exact match is required for beta generated code";
+ out << "\n# endif";
}
else
{
- out << "\n# if ICE_INT_VERSION / 100 != " << ICE_INT_VERSION / 100;
- out << "\n# error Ice version mismatch!";
- out << "\n# endif";
-
- //
- // Generated code is release; reject beta header
- //
- out << "\n# if ICE_INT_VERSION % 100 > 50";
- out << "\n# error Beta header file detected";
- out << "\n# endif";
-
- out << "\n# if ICE_INT_VERSION % 100 < " << ICE_INT_VERSION % 100;
- out << "\n# error Ice patch level mismatch!";
- out << "\n# endif";
+ out << "\n# if ICE_INT_VERSION / 100 != " << ICE_INT_VERSION / 100;
+ out << "\n# error Ice version mismatch!";
+ out << "\n# endif";
+
+ //
+ // Generated code is release; reject beta header
+ //
+ out << "\n# if ICE_INT_VERSION % 100 > 50";
+ out << "\n# error Beta header file detected";
+ out << "\n# endif";
+
+ out << "\n# if ICE_INT_VERSION % 100 < " << ICE_INT_VERSION % 100;
+ out << "\n# error Ice patch level mismatch!";
+ out << "\n# endif";
}
out << "\n#endif";
}
@@ -133,14 +133,14 @@ Slice::printDllExportStuff(Output& out, const string& dllExport)
{
if(dllExport.size())
{
- out << sp;
- out << "\n#ifndef " << dllExport;
- out << "\n# ifdef " << dllExport << "_EXPORTS";
- out << "\n# define " << dllExport << " ICE_DECLSPEC_EXPORT";
- out << "\n# else";
- out << "\n# define " << dllExport << " ICE_DECLSPEC_IMPORT";
- out << "\n# endif";
- out << "\n#endif";
+ out << sp;
+ out << "\n#ifndef " << dllExport;
+ out << "\n# ifdef " << dllExport << "_EXPORTS";
+ out << "\n# define " << dllExport << " ICE_DECLSPEC_EXPORT";
+ out << "\n# else";
+ out << "\n# define " << dllExport << " ICE_DECLSPEC_IMPORT";
+ out << "\n# endif";
+ out << "\n#endif";
}
}
@@ -149,121 +149,121 @@ Slice::typeToString(const TypePtr& type, bool useWstring, const StringList& meta
{
static const char* builtinTable[] =
{
- "::Ice::Byte",
- "bool",
- "::Ice::Short",
- "::Ice::Int",
- "::Ice::Long",
- "::Ice::Float",
- "::Ice::Double",
- "::std::string",
- "::Ice::ObjectPtr",
- "::Ice::ObjectPrx",
- "::Ice::LocalObjectPtr"
+ "::Ice::Byte",
+ "bool",
+ "::Ice::Short",
+ "::Ice::Int",
+ "::Ice::Long",
+ "::Ice::Float",
+ "::Ice::Double",
+ "::std::string",
+ "::Ice::ObjectPtr",
+ "::Ice::ObjectPrx",
+ "::Ice::LocalObjectPtr"
};
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if(builtin)
{
if(builtin->kind() == Builtin::KindString)
- {
+ {
string strType = findMetaData(metaData, true);
- if(strType != "string" && (useWstring || strType == "wstring"))
- {
- return "::std::wstring";
- }
- }
- return builtinTable[builtin->kind()];
+ if(strType != "string" && (useWstring || strType == "wstring"))
+ {
+ return "::std::wstring";
+ }
+ }
+ return builtinTable[builtin->kind()];
}
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
if(cl)
{
- return fixKwd(cl->scoped() + "Ptr");
+ return fixKwd(cl->scoped() + "Ptr");
}
StructPtr st = StructPtr::dynamicCast(type);
if(st)
{
- if(findMetaData(st->getMetaData(), false) == "class")
- {
- return fixKwd(st->scoped() + "Ptr");
- }
- return fixKwd(st->scoped());
+ if(findMetaData(st->getMetaData(), false) == "class")
+ {
+ return fixKwd(st->scoped() + "Ptr");
+ }
+ return fixKwd(st->scoped());
}
-
+
ProxyPtr proxy = ProxyPtr::dynamicCast(type);
if(proxy)
{
- return fixKwd(proxy->_class()->scoped() + "Prx");
+ return fixKwd(proxy->_class()->scoped() + "Prx");
}
SequencePtr seq = SequencePtr::dynamicCast(type);
if(seq)
{
string seqType = findMetaData(metaData, true);
- if(!seqType.empty())
- {
- if(seqType == "array" || seqType == "range:array")
- {
- if(inParam)
- {
- TypePtr elemType = seq->type();
- string s = typeToString(elemType, inWstringModule(seq), seq->typeMetaData());
- return "::std::pair<const " + s + "*, const " + s + "*>";
- }
- else
- {
- return fixKwd(seq->scoped());
- }
- }
- else if(seqType.find("range") == 0)
- {
- if(inParam)
- {
- string s;
- if(seqType.find("range:") == 0)
- {
- s = seqType.substr(strlen("range:"));
- }
- else
- {
- s = fixKwd(seq->scoped());
- }
- if(s[0] == ':')
- {
- s = " " + s;
- }
- return "::std::pair<" + s + "::const_iterator, " + s + "::const_iterator>";
- }
- else
- {
- return fixKwd(seq->scoped());
- }
- }
- else
- {
- return seqType;
- }
- }
- else
- {
- return fixKwd(seq->scoped());
- }
- }
-
+ if(!seqType.empty())
+ {
+ if(seqType == "array" || seqType == "range:array")
+ {
+ if(inParam)
+ {
+ TypePtr elemType = seq->type();
+ string s = typeToString(elemType, inWstringModule(seq), seq->typeMetaData());
+ return "::std::pair<const " + s + "*, const " + s + "*>";
+ }
+ else
+ {
+ return fixKwd(seq->scoped());
+ }
+ }
+ else if(seqType.find("range") == 0)
+ {
+ if(inParam)
+ {
+ string s;
+ if(seqType.find("range:") == 0)
+ {
+ s = seqType.substr(strlen("range:"));
+ }
+ else
+ {
+ s = fixKwd(seq->scoped());
+ }
+ if(s[0] == ':')
+ {
+ s = " " + s;
+ }
+ return "::std::pair<" + s + "::const_iterator, " + s + "::const_iterator>";
+ }
+ else
+ {
+ return fixKwd(seq->scoped());
+ }
+ }
+ else
+ {
+ return seqType;
+ }
+ }
+ else
+ {
+ return fixKwd(seq->scoped());
+ }
+ }
+
ContainedPtr contained = ContainedPtr::dynamicCast(type);
if(contained)
{
- return fixKwd(contained->scoped());
+ return fixKwd(contained->scoped());
}
EnumPtr en = EnumPtr::dynamicCast(type);
if(en)
{
- return fixKwd(en->scoped());
+ return fixKwd(en->scoped());
}
-
+
return "???";
}
@@ -272,7 +272,7 @@ Slice::returnTypeToString(const TypePtr& type, bool useWstring, const StringList
{
if(!type)
{
- return "void";
+ return "void";
}
return typeToString(type, useWstring, metaData, false);
@@ -283,59 +283,59 @@ Slice::inputTypeToString(const TypePtr& type, bool useWstring, const StringList&
{
static const char* inputBuiltinTable[] =
{
- "::Ice::Byte",
- "bool",
- "::Ice::Short",
- "::Ice::Int",
- "::Ice::Long",
- "::Ice::Float",
- "::Ice::Double",
- "const ::std::string&",
- "const ::Ice::ObjectPtr&",
- "const ::Ice::ObjectPrx&",
- "const ::Ice::LocalObjectPtr&"
+ "::Ice::Byte",
+ "bool",
+ "::Ice::Short",
+ "::Ice::Int",
+ "::Ice::Long",
+ "::Ice::Float",
+ "::Ice::Double",
+ "const ::std::string&",
+ "const ::Ice::ObjectPtr&",
+ "const ::Ice::ObjectPrx&",
+ "const ::Ice::LocalObjectPtr&"
};
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if(builtin)
{
if(builtin->kind() == Builtin::KindString)
- {
+ {
string strType = findMetaData(metaData, true);
- if(strType != "string" && (useWstring || strType == "wstring"))
- {
- return "const ::std::wstring&";
- }
- }
- return inputBuiltinTable[builtin->kind()];
+ if(strType != "string" && (useWstring || strType == "wstring"))
+ {
+ return "const ::std::wstring&";
+ }
+ }
+ return inputBuiltinTable[builtin->kind()];
}
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
if(cl)
{
- return "const " + fixKwd(cl->scoped()) + "Ptr&";
+ return "const " + fixKwd(cl->scoped()) + "Ptr&";
}
StructPtr st = StructPtr::dynamicCast(type);
if(st)
{
- if(findMetaData(st->getMetaData(), false) == "class")
- {
- return "const " + fixKwd(st->scoped()) + "Ptr&";
- }
- return "const " + fixKwd(st->scoped()) + "&";
+ if(findMetaData(st->getMetaData(), false) == "class")
+ {
+ return "const " + fixKwd(st->scoped()) + "Ptr&";
+ }
+ return "const " + fixKwd(st->scoped()) + "&";
}
-
+
ProxyPtr proxy = ProxyPtr::dynamicCast(type);
if(proxy)
{
- return "const " + fixKwd(proxy->_class()->scoped()) + "Prx&";
+ return "const " + fixKwd(proxy->_class()->scoped()) + "Prx&";
}
-
+
EnumPtr en = EnumPtr::dynamicCast(type);
if(en)
{
- return fixKwd(en->scoped());
+ return fixKwd(en->scoped());
}
SequencePtr seq = SequencePtr::dynamicCast(type);
@@ -350,23 +350,23 @@ Slice::inputTypeToString(const TypePtr& type, bool useWstring, const StringList&
string s = typeToString(elemType, inWstringModule(seq), seq->typeMetaData());
return "const ::std::pair<const " + s + "*, const " + s + "*>&";
}
- else if(seqType.find("range") == 0)
- {
- string s;
- if(seqType.find("range:") == 0)
- {
- s = seqType.substr(strlen("range:"));
- }
- else
- {
- s = fixKwd(seq->scoped());
- }
- if(s[0] == ':')
- {
- s = " " + s;
- }
- return "const ::std::pair<" + s + "::const_iterator, " + s + "::const_iterator>&";
- }
+ else if(seqType.find("range") == 0)
+ {
+ string s;
+ if(seqType.find("range:") == 0)
+ {
+ s = seqType.substr(strlen("range:"));
+ }
+ else
+ {
+ s = fixKwd(seq->scoped());
+ }
+ if(s[0] == ':')
+ {
+ s = " " + s;
+ }
+ return "const ::std::pair<" + s + "::const_iterator, " + s + "::const_iterator>&";
+ }
else
{
return "const " + seqType + "&";
@@ -377,11 +377,11 @@ Slice::inputTypeToString(const TypePtr& type, bool useWstring, const StringList&
return "const " + fixKwd(seq->scoped()) + "&";
}
}
-
+
ContainedPtr contained = ContainedPtr::dynamicCast(type);
if(contained)
{
- return "const " + fixKwd(contained->scoped()) + "&";
+ return "const " + fixKwd(contained->scoped()) + "&";
}
return "???";
@@ -392,55 +392,55 @@ Slice::outputTypeToString(const TypePtr& type, bool useWstring, const StringList
{
static const char* outputBuiltinTable[] =
{
- "::Ice::Byte&",
- "bool&",
- "::Ice::Short&",
- "::Ice::Int&",
- "::Ice::Long&",
- "::Ice::Float&",
- "::Ice::Double&",
- "::std::string&",
- "::Ice::ObjectPtr&",
- "::Ice::ObjectPrx&",
- "::Ice::LocalObjectPtr&"
+ "::Ice::Byte&",
+ "bool&",
+ "::Ice::Short&",
+ "::Ice::Int&",
+ "::Ice::Long&",
+ "::Ice::Float&",
+ "::Ice::Double&",
+ "::std::string&",
+ "::Ice::ObjectPtr&",
+ "::Ice::ObjectPrx&",
+ "::Ice::LocalObjectPtr&"
};
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if(builtin)
{
if(builtin->kind() == Builtin::KindString)
- {
+ {
string strType = findMetaData(metaData, true);
- if(strType != "string" && (useWstring || strType == "wstring"))
- {
- return "::std::wstring&";
- }
- }
- return outputBuiltinTable[builtin->kind()];
+ if(strType != "string" && (useWstring || strType == "wstring"))
+ {
+ return "::std::wstring&";
+ }
+ }
+ return outputBuiltinTable[builtin->kind()];
}
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
if(cl)
{
- return fixKwd(cl->scoped()) + "Ptr&";
+ return fixKwd(cl->scoped()) + "Ptr&";
}
StructPtr st = StructPtr::dynamicCast(type);
if(st)
{
- if(findMetaData(st->getMetaData(), false) == "class")
- {
- return fixKwd(st->scoped()) + "Ptr&";
- }
- return fixKwd(st->scoped()) + "&";
+ if(findMetaData(st->getMetaData(), false) == "class")
+ {
+ return fixKwd(st->scoped()) + "Ptr&";
+ }
+ return fixKwd(st->scoped()) + "&";
}
-
+
ProxyPtr proxy = ProxyPtr::dynamicCast(type);
if(proxy)
{
- return fixKwd(proxy->_class()->scoped()) + "Prx&";
+ return fixKwd(proxy->_class()->scoped()) + "Prx&";
}
-
+
SequencePtr seq = SequencePtr::dynamicCast(type);
if(seq)
{
@@ -457,7 +457,7 @@ Slice::outputTypeToString(const TypePtr& type, bool useWstring, const StringList
ContainedPtr contained = ContainedPtr::dynamicCast(type);
if(contained)
{
- return fixKwd(contained->scoped()) + "&";
+ return fixKwd(contained->scoped()) + "&";
}
return "???";
@@ -468,25 +468,25 @@ Slice::operationModeToString(Operation::Mode mode)
{
switch(mode)
{
- case Operation::Normal:
- {
- return "::Ice::Normal";
- }
-
- case Operation::Nonmutating:
- {
- return "::Ice::Nonmutating";
- }
-
- case Operation::Idempotent:
- {
- return "::Ice::Idempotent";
- }
-
- default:
- {
- assert(false);
- }
+ case Operation::Normal:
+ {
+ return "::Ice::Normal";
+ }
+
+ case Operation::Nonmutating:
+ {
+ return "::Ice::Nonmutating";
+ }
+
+ case Operation::Idempotent:
+ {
+ return "::Ice::Idempotent";
+ }
+
+ default:
+ {
+ assert(false);
+ }
}
return "???";
@@ -505,18 +505,18 @@ lookupKwd(const string& name)
//
static const string keywordList[] =
{
- "and", "and_eq", "asm", "auto", "bit_and", "bit_or", "bool", "break", "case", "catch", "char",
- "class", "compl", "const", "const_cast", "continue", "default", "delete", "do", "double",
- "dynamic_cast", "else", "enum", "explicit", "export", "extern", "false", "float", "for",
- "friend", "goto", "if", "inline", "int", "long", "mutable", "namespace", "new", "not", "not_eq",
- "operator", "or", "or_eq", "private", "protected", "public", "register", "reinterpret_cast",
- "return", "short", "signed", "sizeof", "static", "static_cast", "struct", "switch", "template",
- "this", "throw", "true", "try", "typedef", "typeid", "typename", "union", "unsigned", "using",
- "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq"
+ "and", "and_eq", "asm", "auto", "bit_and", "bit_or", "bool", "break", "case", "catch", "char",
+ "class", "compl", "const", "const_cast", "continue", "default", "delete", "do", "double",
+ "dynamic_cast", "else", "enum", "explicit", "export", "extern", "false", "float", "for",
+ "friend", "goto", "if", "inline", "int", "long", "mutable", "namespace", "new", "not", "not_eq",
+ "operator", "or", "or_eq", "private", "protected", "public", "register", "reinterpret_cast",
+ "return", "short", "signed", "sizeof", "static", "static_cast", "struct", "switch", "template",
+ "this", "throw", "true", "try", "typedef", "typeid", "typename", "union", "unsigned", "using",
+ "virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq"
};
bool found = binary_search(&keywordList[0],
- &keywordList[sizeof(keywordList) / sizeof(*keywordList)],
- name);
+ &keywordList[sizeof(keywordList) / sizeof(*keywordList)],
+ name);
return found ? "_cpp_" + name : name;
}
@@ -532,24 +532,24 @@ splitScopedName(const string& scoped)
string::size_type pos;
while((pos = scoped.find("::", next)) != string::npos)
{
- pos += 2;
- if(pos != scoped.size())
- {
- string::size_type endpos = scoped.find("::", pos);
- if(endpos != string::npos)
- {
- ids.push_back(scoped.substr(pos, endpos - pos));
- }
- }
- next = pos;
+ pos += 2;
+ if(pos != scoped.size())
+ {
+ string::size_type endpos = scoped.find("::", pos);
+ if(endpos != string::npos)
+ {
+ ids.push_back(scoped.substr(pos, endpos - pos));
+ }
+ }
+ next = pos;
}
if(next != scoped.size())
{
- ids.push_back(scoped.substr(next));
+ ids.push_back(scoped.substr(next));
}
else
{
- ids.push_back("");
+ ids.push_back("");
}
return ids;
@@ -567,42 +567,42 @@ Slice::fixKwd(const string& name)
{
if(name[0] != ':')
{
- return lookupKwd(name);
+ return lookupKwd(name);
}
StringList ids = splitScopedName(name);
transform(ids.begin(), ids.end(), ids.begin(), ptr_fun(lookupKwd));
stringstream result;
for(StringList::const_iterator i = ids.begin(); i != ids.end(); ++i)
{
- result << "::" + *i;
+ result << "::" + *i;
}
return result.str();
}
void
Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& param, bool marshal,
- const string& str, bool pointer, const StringList& metaData, bool inParam)
+ const string& str, bool pointer, const StringList& metaData, bool inParam)
{
string fixedParam = fixKwd(param);
string stream;
if(str.empty())
{
- stream = marshal ? "__os" : "__is";
+ stream = marshal ? "__os" : "__is";
}
else
{
- stream = str;
+ stream = str;
}
string deref;
if(pointer)
{
- deref = "->";
+ deref = "->";
}
else
{
- deref = '.';
+ deref = '.';
}
string func = marshal ? "write(" : "read(";
@@ -610,284 +610,284 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string&
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if(builtin)
{
- if(builtin->kind() == Builtin::KindObject)
- {
- if(marshal)
- {
- out << nl << stream << deref << func << fixedParam << ");";
- }
- else
- {
- out << nl << stream << deref << func << "::Ice::__patch__ObjectPtr, &" << fixedParam << ");";
- }
- return;
- }
- else
- {
- out << nl << stream << deref << func << fixedParam << ");";
- return;
- }
+ if(builtin->kind() == Builtin::KindObject)
+ {
+ if(marshal)
+ {
+ out << nl << stream << deref << func << fixedParam << ");";
+ }
+ else
+ {
+ out << nl << stream << deref << func << "::Ice::__patch__ObjectPtr, &" << fixedParam << ");";
+ }
+ return;
+ }
+ else
+ {
+ out << nl << stream << deref << func << fixedParam << ");";
+ return;
+ }
}
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
if(cl)
{
- string scope = fixKwd(cl->scope());
- if(marshal)
- {
- out << nl << scope << "__write(" << (pointer ? "" : "&") << stream << ", " << fixedParam << ");";
- }
- else
- {
- out << nl << stream << deref << "read("
- << scope << "__patch__" << cl->name() << "Ptr, &" << fixedParam << ");";
- }
+ string scope = fixKwd(cl->scope());
+ if(marshal)
+ {
+ out << nl << scope << "__write(" << (pointer ? "" : "&") << stream << ", " << fixedParam << ");";
+ }
+ else
+ {
+ out << nl << stream << deref << "read("
+ << scope << "__patch__" << cl->name() << "Ptr, &" << fixedParam << ");";
+ }
- return;
+ return;
}
StructPtr st = StructPtr::dynamicCast(type);
if(st)
{
- string deref;
- if(findMetaData(st->getMetaData(), false) == "class")
- {
- if(!marshal)
- {
- out << nl << fixedParam << " = new " << fixKwd(st->scoped()) << ";";
- }
- out << nl << fixedParam << "->__" << func << (pointer ? "" : "&") << stream << ");";
- }
- else
- {
- out << nl << fixedParam << ".__" << func << (pointer ? "" : "&") << stream << ");";
- }
- return;
+ string deref;
+ if(findMetaData(st->getMetaData(), false) == "class")
+ {
+ if(!marshal)
+ {
+ out << nl << fixedParam << " = new " << fixKwd(st->scoped()) << ";";
+ }
+ out << nl << fixedParam << "->__" << func << (pointer ? "" : "&") << stream << ");";
+ }
+ else
+ {
+ out << nl << fixedParam << ".__" << func << (pointer ? "" : "&") << stream << ");";
+ }
+ return;
}
SequencePtr seq = SequencePtr::dynamicCast(type);
if(seq)
{
string seqType = findMetaData(metaData, inParam);
- builtin = BuiltinPtr::dynamicCast(seq->type());
+ builtin = BuiltinPtr::dynamicCast(seq->type());
if(marshal)
- {
- string scope = fixKwd(seq->scope());
- if(seqType == "array" || seqType == "range:array")
- {
- //
- // Use array (pair<const TYPE*, const TYPE*>). In parameters only.
- //
- if(!builtin || builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindObjectProxy)
- {
- //
- // Sequence type in not handled by BasicStream functions. If the sequence is the
- // default vector than we can use the sequences generated write function. Otherwise
- // we need to generate marshal code to write each element.
- //
+ {
+ string scope = fixKwd(seq->scope());
+ if(seqType == "array" || seqType == "range:array")
+ {
+ //
+ // Use array (pair<const TYPE*, const TYPE*>). In parameters only.
+ //
+ if(!builtin || builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindObjectProxy)
+ {
+ //
+ // Sequence type in not handled by BasicStream functions. If the sequence is the
+ // default vector than we can use the sequences generated write function. Otherwise
+ // we need to generate marshal code to write each element.
+ //
StringList l = seq->getMetaData();
seqType = findMetaData(l, false);
- if(seqType.empty())
- {
- out << nl << scope << "__" << func << (pointer ? "" : "&") << stream << ", "
- << fixedParam << ".first, " << fixedParam << ".second, " << scope
- << "__U__" << fixKwd(seq->name()) << "());";
- }
- else
- {
- out << nl << "::Ice::Int __sz_" << fixedParam << " = static_cast< ::Ice::Int>(" << fixedParam
- << ".second - " << fixedParam << ".first);";
- out << nl << stream << deref << "writeSize(__sz_" << fixedParam << ");";
- out << nl << "for(int __i_" << fixedParam << " = 0; __i_" << fixedParam << " < __sz_"
- << fixedParam << "; ++__i_" << fixedParam << ")";
- out << sb;
- writeMarshalUnmarshalCode(out, seq->type(), fixedParam + ".first[__i_" + fixedParam + "]",
- true);
- out << eb;
- }
- }
- else
- {
- //
- // Use BasicStream write functions.
- //
- out << nl << stream << deref << func << fixedParam << ".first, " << fixedParam << ".second);";
- }
- }
- else if(seqType.find("range") == 0)
- {
- //
- // Use range (pair<TYPE::const_iterator, TYPE::const_iterator). Only for in paramaters.
- // Need to check if the range defines an iterator type other than the actual sequence
- // type.
- //
- StringList l;
- if(seqType.find("range:") == 0)
- {
- seqType = seqType.substr(strlen("range:"));
- l.push_back("cpp:" + seqType);
- }
- else
- {
- seqType = fixKwd(seq->scoped());
- }
- out << nl << stream << deref << "writeSize(static_cast< ::Ice::Int>(ice_distance("
- << fixedParam << ".first, " << fixedParam << ".second)));";
- out << nl << "for(" << seqType << "::const_iterator ___" << fixedParam << " = "
- << fixedParam << ".first; ___" << fixedParam << " != " << fixedParam << ".second; ++___"
- << fixedParam << ")";
- out << sb;
- writeMarshalUnmarshalCode(out, seq->type(), "(*___" + fixedParam + ")", true, "", true, l, false);
- out << eb;
- }
- else if(!seqType.empty())
- {
+ if(seqType.empty())
+ {
+ out << nl << scope << "__" << func << (pointer ? "" : "&") << stream << ", "
+ << fixedParam << ".first, " << fixedParam << ".second, " << scope
+ << "__U__" << fixKwd(seq->name()) << "());";
+ }
+ else
+ {
+ out << nl << "::Ice::Int __sz_" << fixedParam << " = static_cast< ::Ice::Int>(" << fixedParam
+ << ".second - " << fixedParam << ".first);";
+ out << nl << stream << deref << "writeSize(__sz_" << fixedParam << ");";
+ out << nl << "for(int __i_" << fixedParam << " = 0; __i_" << fixedParam << " < __sz_"
+ << fixedParam << "; ++__i_" << fixedParam << ")";
+ out << sb;
+ writeMarshalUnmarshalCode(out, seq->type(), fixedParam + ".first[__i_" + fixedParam + "]",
+ true);
+ out << eb;
+ }
+ }
+ else
+ {
+ //
+ // Use BasicStream write functions.
+ //
+ out << nl << stream << deref << func << fixedParam << ".first, " << fixedParam << ".second);";
+ }
+ }
+ else if(seqType.find("range") == 0)
+ {
+ //
+ // Use range (pair<TYPE::const_iterator, TYPE::const_iterator). Only for in paramaters.
+ // Need to check if the range defines an iterator type other than the actual sequence
+ // type.
+ //
+ StringList l;
+ if(seqType.find("range:") == 0)
+ {
+ seqType = seqType.substr(strlen("range:"));
+ l.push_back("cpp:" + seqType);
+ }
+ else
+ {
+ seqType = fixKwd(seq->scoped());
+ }
+ out << nl << stream << deref << "writeSize(static_cast< ::Ice::Int>(ice_distance("
+ << fixedParam << ".first, " << fixedParam << ".second)));";
+ out << nl << "for(" << seqType << "::const_iterator ___" << fixedParam << " = "
+ << fixedParam << ".first; ___" << fixedParam << " != " << fixedParam << ".second; ++___"
+ << fixedParam << ")";
+ out << sb;
+ writeMarshalUnmarshalCode(out, seq->type(), "(*___" + fixedParam + ")", true, "", true, l, false);
+ out << eb;
+ }
+ else if(!seqType.empty())
+ {
out << nl << stream << deref << "writeSize(static_cast< ::Ice::Int>(" << fixedParam << ".size()));";
- out << nl << seqType << "::const_iterator __p_" << fixedParam << ";";
+ out << nl << seqType << "::const_iterator __p_" << fixedParam << ";";
out << nl << "for(__p_" << fixedParam << " = " << fixedParam << ".begin(); __p_" << fixedParam
- << " != " << fixedParam << ".end(); ++__p_" << fixedParam << ")";
+ << " != " << fixedParam << ".end(); ++__p_" << fixedParam << ")";
out << sb;
writeMarshalUnmarshalCode(out, seq->type(), "(*__p_" + fixedParam + ")", true);
out << eb;
- }
- else
- {
- //
- // No modifying metadata specified. Use appropriate write methods for type.
- //
+ }
+ else
+ {
+ //
+ // No modifying metadata specified. Use appropriate write methods for type.
+ //
StringList l = seq->getMetaData();
seqType = findMetaData(l, false);
- if(!seqType.empty())
- {
- out << nl << scope << "__" << func << (pointer ? "" : "&") << stream << ", " << fixedParam << ", "
- << scope << "__U__" << fixKwd(seq->name()) << "());";
- }
- else if(!builtin || builtin->kind() == Builtin::KindObject ||
- builtin->kind() == Builtin::KindObjectProxy)
- {
- out << nl << "if(" << fixedParam << ".size() == 0)";
- out << sb;
- out << nl << stream << deref << "writeSize(0);";
- out << eb;
- out << nl << "else";
- out << sb;
- out << nl << scope << "__" << func << (pointer ? "" : "&") << stream << ", &"
- << fixedParam << "[0], &" << fixedParam << "[0] + " << fixedParam << ".size(), " << scope
- << "__U__" << fixKwd(seq->name()) << "());";
- out << eb;
- }
- else if(builtin->kind() == Builtin::KindBool)
- {
- out << nl << stream << deref << func << fixedParam << ");";
- }
- else
- {
- out << nl << "if(" << fixedParam << ".size() == 0)";
- out << sb;
- out << nl << stream << deref << "writeSize(0);";
- out << eb;
- out << nl << "else";
- out << sb;
- out << nl << stream << deref << func << "&" << fixedParam << "[0], &" << fixedParam
- << "[0] + " << fixedParam << ".size());";
- out << eb;
- }
- }
- }
- else
- {
- string scope = fixKwd(seq->scope());
- if(seqType == "array" || seqType == "range:array")
- {
- //
- // Use array (pair<const TYPE*, const TYPE*>). In paramters only.
- //
- if(!builtin || builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindObjectProxy)
- {
+ if(!seqType.empty())
+ {
+ out << nl << scope << "__" << func << (pointer ? "" : "&") << stream << ", " << fixedParam << ", "
+ << scope << "__U__" << fixKwd(seq->name()) << "());";
+ }
+ else if(!builtin || builtin->kind() == Builtin::KindObject ||
+ builtin->kind() == Builtin::KindObjectProxy)
+ {
+ out << nl << "if(" << fixedParam << ".size() == 0)";
+ out << sb;
+ out << nl << stream << deref << "writeSize(0);";
+ out << eb;
+ out << nl << "else";
+ out << sb;
+ out << nl << scope << "__" << func << (pointer ? "" : "&") << stream << ", &"
+ << fixedParam << "[0], &" << fixedParam << "[0] + " << fixedParam << ".size(), " << scope
+ << "__U__" << fixKwd(seq->name()) << "());";
+ out << eb;
+ }
+ else if(builtin->kind() == Builtin::KindBool)
+ {
+ out << nl << stream << deref << func << fixedParam << ");";
+ }
+ else
+ {
+ out << nl << "if(" << fixedParam << ".size() == 0)";
+ out << sb;
+ out << nl << stream << deref << "writeSize(0);";
+ out << eb;
+ out << nl << "else";
+ out << sb;
+ out << nl << stream << deref << func << "&" << fixedParam << "[0], &" << fixedParam
+ << "[0] + " << fixedParam << ".size());";
+ out << eb;
+ }
+ }
+ }
+ else
+ {
+ string scope = fixKwd(seq->scope());
+ if(seqType == "array" || seqType == "range:array")
+ {
+ //
+ // Use array (pair<const TYPE*, const TYPE*>). In paramters only.
+ //
+ if(!builtin || builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindObjectProxy)
+ {
StringList l = seq->getMetaData();
seqType = findMetaData(l, false);
- if(seqType.empty())
- {
- out << nl << typeToString(type, false) << " ___" << fixedParam << ";";
- out << nl << scope << "__" << func << (pointer ? "" : "&") << stream << ", ___"
- << fixedParam << ", " << scope << "__U__" << fixKwd(seq->name()) << "());";
- }
- else
- {
- seqType = "::std::vector< " + typeToString(seq->type(), false) + ">";
- StringList l;
- l.push_back("cpp:type:" + seqType);
- out << nl << seqType << " ___" << fixedParam << ";";
- writeMarshalUnmarshalCode(out, seq, "___" + fixedParam, false, "", true, l, false);
- }
- }
- else if(builtin->kind() == Builtin::KindByte)
- {
- out << nl << stream << deref << func << fixedParam << ");";
- }
- else if(builtin->kind() != Builtin::KindString && builtin->kind() != Builtin::KindObject &&
- builtin->kind() != Builtin::KindObjectProxy)
- {
- string s = typeToString(builtin, false);
- if(s[0] == ':')
- {
- s = " " + s;
- }
- out << nl << "::IceUtil::ScopedArray<" << s << "> ___" << fixedParam << '('
- << stream << deref << func << fixedParam << "));";
- }
- else
- {
- out << nl << "::std::vector< "
- << typeToString(seq->type(), inWstringModule(seq), seq->typeMetaData()) << "> ___"
- << fixedParam << ";";
- out << nl << stream << deref << func << "___" << fixedParam << ");";
- }
-
- if(!builtin || builtin->kind() == Builtin::KindString || builtin->kind() == Builtin::KindObject ||
- builtin->kind() == Builtin::KindObjectProxy)
- {
- out << nl << fixedParam << ".first" << " = &___" << fixedParam << "[0];";
- out << nl << fixedParam << ".second" << " = " << fixedParam << ".first + " << "___"
- << fixedParam << ".size();";
- }
- }
- else if(seqType.find("range") == 0)
- {
- //
- // Use range (pair<TYPE::const_iterator, TYPE::const_iterator>). In paramters only.
- // Need to check if iterator type other than default is specified.
- //
- StringList md;
- if(seqType.find("range:") == 0)
- {
- md.push_back("cpp:type:" + seqType.substr(strlen("range:")));
- }
- writeMarshalUnmarshalCode(out, seq, "___" + fixedParam, false, "", true, md, false);
- out << nl << fixedParam << ".first = ___" << fixedParam << ".begin();";
- out << nl << fixedParam << ".second = ___" << fixedParam << ".end();";
- }
- else if(!seqType.empty())
- {
- //
- // Using alternate sequence type.
- //
+ if(seqType.empty())
+ {
+ out << nl << typeToString(type, false) << " ___" << fixedParam << ";";
+ out << nl << scope << "__" << func << (pointer ? "" : "&") << stream << ", ___"
+ << fixedParam << ", " << scope << "__U__" << fixKwd(seq->name()) << "());";
+ }
+ else
+ {
+ seqType = "::std::vector< " + typeToString(seq->type(), false) + ">";
+ StringList l;
+ l.push_back("cpp:type:" + seqType);
+ out << nl << seqType << " ___" << fixedParam << ";";
+ writeMarshalUnmarshalCode(out, seq, "___" + fixedParam, false, "", true, l, false);
+ }
+ }
+ else if(builtin->kind() == Builtin::KindByte)
+ {
+ out << nl << stream << deref << func << fixedParam << ");";
+ }
+ else if(builtin->kind() != Builtin::KindString && builtin->kind() != Builtin::KindObject &&
+ builtin->kind() != Builtin::KindObjectProxy)
+ {
+ string s = typeToString(builtin, false);
+ if(s[0] == ':')
+ {
+ s = " " + s;
+ }
+ out << nl << "::IceUtil::ScopedArray<" << s << "> ___" << fixedParam << '('
+ << stream << deref << func << fixedParam << "));";
+ }
+ else
+ {
+ out << nl << "::std::vector< "
+ << typeToString(seq->type(), inWstringModule(seq), seq->typeMetaData()) << "> ___"
+ << fixedParam << ";";
+ out << nl << stream << deref << func << "___" << fixedParam << ");";
+ }
+
+ if(!builtin || builtin->kind() == Builtin::KindString || builtin->kind() == Builtin::KindObject ||
+ builtin->kind() == Builtin::KindObjectProxy)
+ {
+ out << nl << fixedParam << ".first" << " = &___" << fixedParam << "[0];";
+ out << nl << fixedParam << ".second" << " = " << fixedParam << ".first + " << "___"
+ << fixedParam << ".size();";
+ }
+ }
+ else if(seqType.find("range") == 0)
+ {
+ //
+ // Use range (pair<TYPE::const_iterator, TYPE::const_iterator>). In paramters only.
+ // Need to check if iterator type other than default is specified.
+ //
+ StringList md;
+ if(seqType.find("range:") == 0)
+ {
+ md.push_back("cpp:type:" + seqType.substr(strlen("range:")));
+ }
+ writeMarshalUnmarshalCode(out, seq, "___" + fixedParam, false, "", true, md, false);
+ out << nl << fixedParam << ".first = ___" << fixedParam << ".begin();";
+ out << nl << fixedParam << ".second = ___" << fixedParam << ".end();";
+ }
+ else if(!seqType.empty())
+ {
+ //
+ // Using alternate sequence type.
+ //
out << nl << "::Ice::Int __sz_" << fixedParam << ";";
out << nl << stream << deref << "readSize(__sz_" << fixedParam << ");";
out << nl << seqType << "(__sz_" << fixedParam << ").swap(" << fixedParam << ");";
if(seq->type()->isVariableLength())
{
out << nl << stream << deref << "startSeq(__sz_" << fixedParam << ", "
- << seq->type()->minWireSize() << ");";
+ << seq->type()->minWireSize() << ");";
}
else
{
out << nl << stream << deref << "checkFixedSeq(__sz_" << fixedParam << ", "
- << seq->type()->minWireSize() << ");";
+ << seq->type()->minWireSize() << ");";
}
- out << nl << seqType << "::iterator __p_" << fixedParam << ";";
+ out << nl << seqType << "::iterator __p_" << fixedParam << ";";
out << nl << "for(__p_" << fixedParam << " = " << fixedParam << ".begin(); __p_" << fixedParam
- << " != " << fixedParam << ".end(); ++__p_" << fixedParam << ")";
+ << " != " << fixedParam << ".end(); ++__p_" << fixedParam << ")";
out << sb;
writeMarshalUnmarshalCode(out, seq->type(), "(*__p_" + fixedParam + ")", false);
if(seq->type()->isVariableLength())
@@ -903,114 +903,114 @@ Slice::writeMarshalUnmarshalCode(Output& out, const TypePtr& type, const string&
{
out << nl << stream << deref << "endSeq(__sz_" << fixedParam << ");";
}
- }
- else
- {
- //
- // No modifying metadata supplied. Just use appropriate read function.
- //
+ }
+ else
+ {
+ //
+ // No modifying metadata supplied. Just use appropriate read function.
+ //
StringList l = seq->getMetaData();
seqType = findMetaData(l, false);
- if(!seqType.empty() || !builtin || builtin->kind() == Builtin::KindObject ||
- builtin->kind() == Builtin::KindObjectProxy)
- {
- out << nl << scope << "__" << func << (pointer ? "" : "&") << stream << ", "
- << fixedParam << ", " << scope << "__U__" << fixKwd(seq->name()) << "());";
- }
- else if(builtin->kind() == Builtin::KindByte)
- {
- StringList md;
- md.push_back("cpp:array");
- string tmpParam = "___";
-
- //
- // Catch some case in which it is not possible to just prepend
- // underscores to param to use as temporary variable.
- //
- if(fixedParam.find("(*") == 0)
- {
- tmpParam += fixedParam.substr(2, fixedParam.length() - 3);
- }
- else if(fixedParam.find("[i]") != string::npos)
- {
- tmpParam += fixedParam.substr(0, fixedParam.length() - 3);
- }
- else if(fixedParam.find("->second") != string::npos)
- {
- tmpParam += fixedParam.substr(0, fixedParam.length() - 8);
- }
- else
- {
- tmpParam += fixedParam;
- }
- out << nl << typeToString(type, false, md) << " " << tmpParam << ";";
- out << nl << stream << deref << func << tmpParam << ");";
- out << nl << "::std::vector< ::Ice::Byte>(" << tmpParam << ".first, " << tmpParam
- << ".second).swap(" << fixedParam << ");";
- }
- else
- {
- out << nl << stream << deref << func << fixedParam << ");";
- }
- }
- }
- return;
+ if(!seqType.empty() || !builtin || builtin->kind() == Builtin::KindObject ||
+ builtin->kind() == Builtin::KindObjectProxy)
+ {
+ out << nl << scope << "__" << func << (pointer ? "" : "&") << stream << ", "
+ << fixedParam << ", " << scope << "__U__" << fixKwd(seq->name()) << "());";
+ }
+ else if(builtin->kind() == Builtin::KindByte)
+ {
+ StringList md;
+ md.push_back("cpp:array");
+ string tmpParam = "___";
+
+ //
+ // Catch some case in which it is not possible to just prepend
+ // underscores to param to use as temporary variable.
+ //
+ if(fixedParam.find("(*") == 0)
+ {
+ tmpParam += fixedParam.substr(2, fixedParam.length() - 3);
+ }
+ else if(fixedParam.find("[i]") != string::npos)
+ {
+ tmpParam += fixedParam.substr(0, fixedParam.length() - 3);
+ }
+ else if(fixedParam.find("->second") != string::npos)
+ {
+ tmpParam += fixedParam.substr(0, fixedParam.length() - 8);
+ }
+ else
+ {
+ tmpParam += fixedParam;
+ }
+ out << nl << typeToString(type, false, md) << " " << tmpParam << ";";
+ out << nl << stream << deref << func << tmpParam << ");";
+ out << nl << "::std::vector< ::Ice::Byte>(" << tmpParam << ".first, " << tmpParam
+ << ".second).swap(" << fixedParam << ");";
+ }
+ else
+ {
+ out << nl << stream << deref << func << fixedParam << ");";
+ }
+ }
+ }
+ return;
}
DictionaryPtr dict = DictionaryPtr::dynamicCast(type);
if(dict)
{
- string scope = fixKwd(dict->scope());
- out << nl << scope << "__" << func << (pointer ? "" : "&") << stream << ", "
- << fixedParam << ", " << scope << "__U__" << fixKwd(dict->name()) << "());";
- return;
+ string scope = fixKwd(dict->scope());
+ out << nl << scope << "__" << func << (pointer ? "" : "&") << stream << ", "
+ << fixedParam << ", " << scope << "__U__" << fixKwd(dict->name()) << "());";
+ return;
}
ConstructedPtr constructed = ConstructedPtr::dynamicCast(type);
if(!constructed)
{
- ProxyPtr proxy = ProxyPtr::dynamicCast(type);
- assert(proxy);
- constructed = proxy->_class();
+ ProxyPtr proxy = ProxyPtr::dynamicCast(type);
+ assert(proxy);
+ constructed = proxy->_class();
}
out << nl << fixKwd(constructed->scope()) << "__" << func << (pointer ? "" : "&") << stream << ", "
- << fixedParam << ");";
+ << fixedParam << ");";
}
void
Slice::writeMarshalCode(Output& out, const ParamDeclList& params, const TypePtr& ret, const StringList& metaData,
- bool inParam)
+ bool inParam)
{
for(ParamDeclList::const_iterator p = params.begin(); p != params.end(); ++p)
{
- writeMarshalUnmarshalCode(out, (*p)->type(), fixKwd((*p)->name()), true, "", true, (*p)->getMetaData(),
- inParam);
+ writeMarshalUnmarshalCode(out, (*p)->type(), fixKwd((*p)->name()), true, "", true, (*p)->getMetaData(),
+ inParam);
}
if(ret)
{
- writeMarshalUnmarshalCode(out, ret, "__ret", true, "", true, metaData, false);
+ writeMarshalUnmarshalCode(out, ret, "__ret", true, "", true, metaData, false);
}
}
void
Slice::writeUnmarshalCode(Output& out, const ParamDeclList& params, const TypePtr& ret, const StringList& metaData,
- bool inParam)
+ bool inParam)
{
for(ParamDeclList::const_iterator p = params.begin(); p != params.end(); ++p)
{
- writeMarshalUnmarshalCode(out, (*p)->type(), fixKwd((*p)->name()), false, "", true, (*p)->getMetaData(),
- inParam);
+ writeMarshalUnmarshalCode(out, (*p)->type(), fixKwd((*p)->name()), false, "", true, (*p)->getMetaData(),
+ inParam);
}
if(ret)
{
- writeMarshalUnmarshalCode(out, ret, "__ret", false, "", true, metaData, false);
+ writeMarshalUnmarshalCode(out, ret, "__ret", false, "", true, metaData, false);
}
}
static void
writeRangeAllocateCode(Output& out, const TypePtr& type, const string& fixedName, const StringList& metaData,
- bool inParam)
+ bool inParam)
{
if(!inParam)
{
@@ -1021,72 +1021,72 @@ writeRangeAllocateCode(Output& out, const TypePtr& type, const string& fixedName
if(seq)
{
string seqType = findMetaData(metaData, true);
- if(seqType.find("range") == 0 && seqType != "range:array")
- {
- StringList md;
- if(seqType.find("range:") == 0)
- {
- md.push_back("cpp:type:" + seqType.substr(strlen("range:")));
- }
+ if(seqType.find("range") == 0 && seqType != "range:array")
+ {
+ StringList md;
+ if(seqType.find("range:") == 0)
+ {
+ md.push_back("cpp:type:" + seqType.substr(strlen("range:")));
+ }
out << nl << typeToString(seq, false, md, false) << " ___" << fixedName << ";";
- }
+ }
}
}
void
Slice::writeAllocateCode(Output& out, const ParamDeclList& params, const TypePtr& ret, const StringList& metaData,
- bool useWstring, bool inParam)
+ bool useWstring, bool inParam)
{
for(ParamDeclList::const_iterator p = params.begin(); p != params.end(); ++p)
{
- out << nl << typeToString((*p)->type(), useWstring, (*p)->getMetaData(), inParam) << ' '
- << fixKwd((*p)->name());
- StructPtr st = StructPtr::dynamicCast((*p)->type());
- if(st && findMetaData(st->getMetaData(), false) == "class")
- {
- out << " = new " << fixKwd(st->scoped());
- }
- out << ';';
+ out << nl << typeToString((*p)->type(), useWstring, (*p)->getMetaData(), inParam) << ' '
+ << fixKwd((*p)->name());
+ StructPtr st = StructPtr::dynamicCast((*p)->type());
+ if(st && findMetaData(st->getMetaData(), false) == "class")
+ {
+ out << " = new " << fixKwd(st->scoped());
+ }
+ out << ';';
- //
- // If using a range we need to allocate the range container as well now to ensure they
- // are always in the same scope.
- //
- writeRangeAllocateCode(out, (*p)->type(), fixKwd((*p)->name()), (*p)->getMetaData(), inParam);
+ //
+ // If using a range we need to allocate the range container as well now to ensure they
+ // are always in the same scope.
+ //
+ writeRangeAllocateCode(out, (*p)->type(), fixKwd((*p)->name()), (*p)->getMetaData(), inParam);
}
if(ret)
{
- out << nl << typeToString(ret, useWstring, metaData, inParam) << " __ret";
- StructPtr st = StructPtr::dynamicCast(ret);
- if(st && findMetaData(st->getMetaData(), false) == "class")
- {
- out << " = new " << fixKwd(st->scoped());
- }
- out << ";";
+ out << nl << typeToString(ret, useWstring, metaData, inParam) << " __ret";
+ StructPtr st = StructPtr::dynamicCast(ret);
+ if(st && findMetaData(st->getMetaData(), false) == "class")
+ {
+ out << " = new " << fixKwd(st->scoped());
+ }
+ out << ";";
- //
- // If using a range we need to allocate the range container as well now to ensure they
- // are always in the same scope.
- //
- writeRangeAllocateCode(out, ret, "__ret", metaData, inParam);
+ //
+ // If using a range we need to allocate the range container as well now to ensure they
+ // are always in the same scope.
+ //
+ writeRangeAllocateCode(out, ret, "__ret", metaData, inParam);
}
}
void
Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const string& param, bool marshal,
- const string& str, bool useWstring, const StringList& metaData)
+ const string& str, bool useWstring, const StringList& metaData)
{
string fixedParam = fixKwd(param);
string stream;
if(str.empty())
{
- stream = marshal ? "__outS" : "__inS";
+ stream = marshal ? "__outS" : "__inS";
}
else
{
- stream = str;
+ stream = str;
}
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
@@ -1181,8 +1181,8 @@ Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const s
case Builtin::KindString:
{
string strType = findMetaData(metaData, true);
- if(strType != "string" && (useWstring || strType == "wstring"))
- {
+ if(strType != "string" && (useWstring || strType == "wstring"))
+ {
if(marshal)
{
out << nl << stream << "->writeWstring(" << fixedParam << ");";
@@ -1191,9 +1191,9 @@ Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const s
{
out << nl << fixedParam << " = " << stream << "->readWstring();";
}
- }
- else
- {
+ }
+ else
+ {
if(marshal)
{
out << nl << stream << "->writeString(" << fixedParam << ");";
@@ -1202,7 +1202,7 @@ Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const s
{
out << nl << fixedParam << " = " << stream << "->readString();";
}
- }
+ }
break;
}
case Builtin::KindObject:
@@ -1243,73 +1243,73 @@ Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const s
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
if(cl)
{
- string scope = fixKwd(cl->scope());
- if(marshal)
- {
+ string scope = fixKwd(cl->scope());
+ if(marshal)
+ {
out << nl << scope << "ice_write" << cl->name() << "(" << stream << ", " << fixedParam << ");";
- }
- else
- {
+ }
+ else
+ {
out << nl << scope << "ice_read" << cl->name() << "(" << stream << ", " << fixedParam << ");";
- }
+ }
- return;
+ return;
}
StructPtr st = StructPtr::dynamicCast(type);
if(st)
{
- string scope = fixKwd(st->scope());
- if(marshal)
- {
+ string scope = fixKwd(st->scope());
+ if(marshal)
+ {
out << nl << scope << "ice_write" << st->name() << "(" << stream << ", " << fixedParam << ");";
- }
- else
- {
- if(findMetaData(st->getMetaData(), false) == "class")
- {
- out << nl << fixedParam << " = new " << fixKwd(st->scoped()) << ";";
- }
+ }
+ else
+ {
+ if(findMetaData(st->getMetaData(), false) == "class")
+ {
+ out << nl << fixedParam << " = new " << fixKwd(st->scoped()) << ";";
+ }
out << nl << scope << "ice_read" << st->name() << "(" << stream << ", " << fixedParam << ");";
- }
+ }
- return;
+ return;
}
SequencePtr seq = SequencePtr::dynamicCast(type);
if(seq)
{
- string seqType = findMetaData(metaData, false);
- if(!seqType.empty())
- {
- if(marshal)
- {
- out << nl << stream << "->writeSize(static_cast< ::Ice::Int>(" << fixedParam << ".size()));";
- out << nl << seqType << "::const_iterator ___" << fixedParam << ";";
- out << nl << "for(___" << fixedParam << " = " << fixedParam << ".begin(); ___" << fixedParam << " != "
- << fixedParam << ".end(); ++___" << fixedParam << ")";
- out << sb;
- writeStreamMarshalUnmarshalCode(out, seq->type(), "(*___" + fixedParam + ")", true);
- out << eb;
- }
- else
- {
- out << nl << seqType << "(static_cast< ::Ice::Int>(" << stream << "->readSize())).swap("
- << fixedParam << ");";
- out << nl << seqType << "::iterator ___" << fixedParam << ";";
- out << nl << "for(___" << fixedParam << " = " << fixedParam << ".begin(); ___" << fixedParam << " != "
- << fixedParam << ".end(); ++___" << fixedParam << ")";
- out << sb;
- writeStreamMarshalUnmarshalCode(out, seq->type(), "(*___" + fixedParam + ")", false);
- out << eb;
- }
- }
- else
- {
- seqType = findMetaData(seq->getMetaData(), false);
+ string seqType = findMetaData(metaData, false);
+ if(!seqType.empty())
+ {
+ if(marshal)
+ {
+ out << nl << stream << "->writeSize(static_cast< ::Ice::Int>(" << fixedParam << ".size()));";
+ out << nl << seqType << "::const_iterator ___" << fixedParam << ";";
+ out << nl << "for(___" << fixedParam << " = " << fixedParam << ".begin(); ___" << fixedParam << " != "
+ << fixedParam << ".end(); ++___" << fixedParam << ")";
+ out << sb;
+ writeStreamMarshalUnmarshalCode(out, seq->type(), "(*___" + fixedParam + ")", true);
+ out << eb;
+ }
+ else
+ {
+ out << nl << seqType << "(static_cast< ::Ice::Int>(" << stream << "->readSize())).swap("
+ << fixedParam << ");";
+ out << nl << seqType << "::iterator ___" << fixedParam << ";";
+ out << nl << "for(___" << fixedParam << " = " << fixedParam << ".begin(); ___" << fixedParam << " != "
+ << fixedParam << ".end(); ++___" << fixedParam << ")";
+ out << sb;
+ writeStreamMarshalUnmarshalCode(out, seq->type(), "(*___" + fixedParam + ")", false);
+ out << eb;
+ }
+ }
+ else
+ {
+ seqType = findMetaData(seq->getMetaData(), false);
builtin = BuiltinPtr::dynamicCast(seq->type());
if(!seqType.empty() || !builtin || (builtin->kind() == Builtin::KindObject ||
- builtin->kind() == Builtin::KindObjectProxy))
+ builtin->kind() == Builtin::KindObjectProxy))
{
string scope = fixKwd(seq->scope());
if(marshal)
@@ -1412,8 +1412,8 @@ Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const s
case Builtin::KindString:
{
string strType = findMetaData(seq->typeMetaData(), true);
- if(strType != "string" && (useWstring || strType == "wstring"))
- {
+ if(strType != "string" && (useWstring || strType == "wstring"))
+ {
if(marshal)
{
out << nl << stream << "->writeWstringSeq(" << fixedParam << ");";
@@ -1422,9 +1422,9 @@ Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const s
{
out << nl << fixedParam << " = " << stream << "->readWstringSeq();";
}
- }
- else
- {
+ }
+ else
+ {
if(marshal)
{
out << nl << stream << "->writeStringSeq(" << fixedParam << ");";
@@ -1433,7 +1433,7 @@ Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const s
{
out << nl << fixedParam << " = " << stream << "->readStringSeq();";
}
- }
+ }
break;
}
case Builtin::KindObject:
@@ -1444,26 +1444,26 @@ Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const s
break;
}
}
- }
+ }
}
- return;
+ return;
}
DictionaryPtr dict = DictionaryPtr::dynamicCast(type);
if(dict)
{
string scope = fixKwd(dict->scope());
- if(marshal)
- {
+ if(marshal)
+ {
out << nl << scope << "ice_write" << dict->name() << "(" << stream << ", " << fixedParam << ");";
- }
- else
- {
+ }
+ else
+ {
out << nl << scope << "ice_read" << dict->name() << "(" << stream << ", " << fixedParam << ");";
- }
+ }
- return;
+ return;
}
EnumPtr en = EnumPtr::dynamicCast(type);
@@ -1479,7 +1479,7 @@ Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const s
out << nl << scope << "ice_read" << en->name() << "(" << stream << ", " << fixedParam << ");";
}
- return;
+ return;
}
ProxyPtr prx = ProxyPtr::dynamicCast(type);
@@ -1496,7 +1496,7 @@ Slice::writeStreamMarshalUnmarshalCode(Output& out, const TypePtr& type, const s
out << nl << scope << "ice_read" << cls->name() << "Prx(" << stream << ", " << fixedParam << ");";
}
- return;
+ return;
}
assert(false);
@@ -1509,50 +1509,50 @@ Slice::findMetaData(const StringList& metaData, bool inParam)
for(StringList::const_iterator q = metaData.begin(); q != metaData.end(); ++q)
{
string str = *q;
- if(str.find(prefix) == 0)
- {
- string::size_type pos = str.find(':', prefix.size());
- //
- // If the form is cpp:type:<...> the data after cpp:type:
- // is returned. If the form is cpp:range:<...> (and this
- // is an inParam) the data after cpp: is returned.
- //
- if(pos != string::npos)
- {
- string ss = str.substr(prefix.size(), pos - prefix.size());
- if(ss == "type")
- {
- return str.substr(pos + 1);
- }
- else if(inParam && ss == "range")
- {
- return str.substr(prefix.size());
- }
- }
- //
- // If the data is an inParam and the metadata is cpp:array
- // or cpp:range then array or range is returned.
- //
- else if(inParam)
- {
- string ss = str.substr(prefix.size());
- if(ss == "array" || ss == "range")
- {
- return ss;
- }
- }
- //
- // Otherwise if the data is "class" it is returned.
- //
- else
- {
- string ss = str.substr(prefix.size());
- if(ss == "class")
- {
- return ss;
- }
- }
- }
+ if(str.find(prefix) == 0)
+ {
+ string::size_type pos = str.find(':', prefix.size());
+ //
+ // If the form is cpp:type:<...> the data after cpp:type:
+ // is returned. If the form is cpp:range:<...> (and this
+ // is an inParam) the data after cpp: is returned.
+ //
+ if(pos != string::npos)
+ {
+ string ss = str.substr(prefix.size(), pos - prefix.size());
+ if(ss == "type")
+ {
+ return str.substr(pos + 1);
+ }
+ else if(inParam && ss == "range")
+ {
+ return str.substr(prefix.size());
+ }
+ }
+ //
+ // If the data is an inParam and the metadata is cpp:array
+ // or cpp:range then array or range is returned.
+ //
+ else if(inParam)
+ {
+ string ss = str.substr(prefix.size());
+ if(ss == "array" || ss == "range")
+ {
+ return ss;
+ }
+ }
+ //
+ // Otherwise if the data is "class" it is returned.
+ //
+ else
+ {
+ string ss = str.substr(prefix.size());
+ if(ss == "class")
+ {
+ return ss;
+ }
+ }
+ }
}
return "";
@@ -1565,20 +1565,20 @@ Slice::inWstringModule(const SequencePtr& seq)
while(cont)
{
ModulePtr mod = ModulePtr::dynamicCast(cont);
- if(!mod)
- {
- break;
- }
- StringList metaData = mod->getMetaData();
- if(find(metaData.begin(), metaData.end(), "cpp:type:wstring") != metaData.end())
- {
- return true;
- }
- else if(find(metaData.begin(), metaData.end(), "cpp:type:string") != metaData.end())
- {
- return false;
- }
- cont = mod->container();
+ if(!mod)
+ {
+ break;
+ }
+ StringList metaData = mod->getMetaData();
+ if(find(metaData.begin(), metaData.end(), "cpp:type:wstring") != metaData.end())
+ {
+ return true;
+ }
+ else if(find(metaData.begin(), metaData.end(), "cpp:type:string") != metaData.end())
+ {
+ return false;
+ }
+ cont = mod->container();
}
return false;
}
diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp
index 303870ec66d..061033bb802 100755
--- a/cpp/src/Slice/CsUtil.cpp
+++ b/cpp/src/Slice/CsUtil.cpp
@@ -34,25 +34,25 @@ lookupKwd(const string& name, int baseTypes, bool mangleCasts = false)
//
static const string keywordList[] =
{
- "abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const",
- "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern",
- "false", "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface",
- "internal", "is", "lock", "long", "namespace", "new", "null", "object", "operator", "out", "override",
- "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short",
- "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof",
- "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while"
+ "abstract", "as", "base", "bool", "break", "byte", "case", "catch", "char", "checked", "class", "const",
+ "continue", "decimal", "default", "delegate", "do", "double", "else", "enum", "event", "explicit", "extern",
+ "false", "finally", "fixed", "float", "for", "foreach", "goto", "if", "implicit", "in", "int", "interface",
+ "internal", "is", "lock", "long", "namespace", "new", "null", "object", "operator", "out", "override",
+ "params", "private", "protected", "public", "readonly", "ref", "return", "sbyte", "sealed", "short",
+ "sizeof", "stackalloc", "static", "string", "struct", "switch", "this", "throw", "true", "try", "typeof",
+ "uint", "ulong", "unchecked", "unsafe", "ushort", "using", "virtual", "void", "volatile", "while"
};
bool found = binary_search(&keywordList[0],
- &keywordList[sizeof(keywordList) / sizeof(*keywordList)],
- name,
- Slice::CICompare());
+ &keywordList[sizeof(keywordList) / sizeof(*keywordList)],
+ name,
+ Slice::CICompare());
if(found)
{
return "@" + name;
}
if(mangleCasts && (name == "checkedCast" || name == "uncheckedCast"))
{
- return string(DotNet::manglePrefix) + name;
+ return string(DotNet::manglePrefix) + name;
}
return Slice::DotNet::mangleName(name, baseTypes);
}
@@ -69,24 +69,24 @@ splitScopedName(const string& scoped)
string::size_type pos;
while((pos = scoped.find("::", next)) != string::npos)
{
- pos += 2;
- if(pos != scoped.size())
- {
- string::size_type endpos = scoped.find("::", pos);
- if(endpos != string::npos)
- {
- ids.push_back(scoped.substr(pos, endpos - pos));
- }
- }
- next = pos;
+ pos += 2;
+ if(pos != scoped.size())
+ {
+ string::size_type endpos = scoped.find("::", pos);
+ if(endpos != string::npos)
+ {
+ ids.push_back(scoped.substr(pos, endpos - pos));
+ }
+ }
+ next = pos;
}
if(next != scoped.size())
{
- ids.push_back(scoped.substr(next));
+ ids.push_back(scoped.substr(next));
}
else
{
- ids.push_back("");
+ ids.push_back("");
}
return ids;
@@ -105,26 +105,26 @@ Slice::CsGenerator::fixId(const string& name, int baseTypes, bool mangleCasts)
{
if(name.empty())
{
- return name;
+ return name;
}
if(name[0] != ':')
{
- return lookupKwd(name, baseTypes, mangleCasts);
+ return lookupKwd(name, baseTypes, mangleCasts);
}
StringList ids = splitScopedName(name);
StringList newIds;
for(StringList::const_iterator i = ids.begin(); i != ids.end(); ++i)
{
- newIds.push_back(lookupKwd(*i, baseTypes));
+ newIds.push_back(lookupKwd(*i, baseTypes));
}
stringstream result;
for(StringList::const_iterator j = newIds.begin(); j != newIds.end(); ++j)
{
- if(j != newIds.begin())
- {
- result << '.';
- }
- result << *j;
+ if(j != newIds.begin())
+ {
+ result << '.';
+ }
+ result << *j;
}
return result.str();
}
@@ -155,7 +155,7 @@ Slice::CsGenerator::typeToString(const TypePtr& type)
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if(builtin)
{
- return builtinTable[builtin->kind()];
+ return builtinTable[builtin->kind()];
}
ProxyPtr proxy = ProxyPtr::dynamicCast(type);
@@ -167,7 +167,7 @@ Slice::CsGenerator::typeToString(const TypePtr& type)
SequencePtr seq = SequencePtr::dynamicCast(type);
if(seq && !seq->hasMetaData("clr:collection"))
{
- return typeToString(seq->type()) + "[]";
+ return typeToString(seq->type()) + "[]";
}
ContainedPtr contained = ContainedPtr::dynamicCast(type);
@@ -186,54 +186,54 @@ Slice::CsGenerator::isValueType(const TypePtr& type)
if(builtin)
{
switch(builtin->kind())
- {
- case Builtin::KindString:
- case Builtin::KindObject:
- case Builtin::KindObjectProxy:
- case Builtin::KindLocalObject:
- {
- return false;
- break;
- }
- default:
- {
- return true;
- break;
- }
- }
+ {
+ case Builtin::KindString:
+ case Builtin::KindObject:
+ case Builtin::KindObjectProxy:
+ case Builtin::KindLocalObject:
+ {
+ return false;
+ break;
+ }
+ default:
+ {
+ return true;
+ break;
+ }
+ }
}
StructPtr s = StructPtr::dynamicCast(type);
if(s)
{
- if(s->hasMetaData("clr:class"))
- {
- return false;
- }
- DataMemberList dm = s->dataMembers();
- for(DataMemberList::const_iterator i = dm.begin(); i != dm.end(); ++i)
- {
- if(!isValueType((*i)->type()))
- {
- return false;
- }
- }
- return true;
+ if(s->hasMetaData("clr:class"))
+ {
+ return false;
+ }
+ DataMemberList dm = s->dataMembers();
+ for(DataMemberList::const_iterator i = dm.begin(); i != dm.end(); ++i)
+ {
+ if(!isValueType((*i)->type()))
+ {
+ return false;
+ }
+ }
+ return true;
}
if(EnumPtr::dynamicCast(type))
{
- return true;
+ return true;
}
return false;
}
void
Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out,
- const TypePtr& type,
- const string& param,
- bool marshal,
- bool streamingAPI,
- bool isOutParam,
- const string& patchParams)
+ const TypePtr& type,
+ const string& param,
+ bool marshal,
+ bool streamingAPI,
+ bool isOutParam,
+ const string& patchParams)
{
string stream;
@@ -355,32 +355,32 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out,
}
else
{
- if(isOutParam)
- {
- out << nl << "IceInternal.ParamPatcher " << param
- << "_PP = new IceInternal.ParamPatcher(typeof(Ice.Object), \"::Ice::Object\");";
- out << nl << stream << ".readObject(";
- if(streamingAPI)
- {
- out << "(Ice.ReadObjectCallback)";
- }
- out << param << "_PP);";
- }
- else
- {
- out << nl << stream << ".readObject(";
- if(streamingAPI)
- {
- out << "(Ice.ReadObjectCallback)";
- }
- out << "new Patcher__(" << patchParams << "));";
- }
+ if(isOutParam)
+ {
+ out << nl << "IceInternal.ParamPatcher " << param
+ << "_PP = new IceInternal.ParamPatcher(typeof(Ice.Object), \"::Ice::Object\");";
+ out << nl << stream << ".readObject(";
+ if(streamingAPI)
+ {
+ out << "(Ice.ReadObjectCallback)";
+ }
+ out << param << "_PP);";
+ }
+ else
+ {
+ out << nl << stream << ".readObject(";
+ if(streamingAPI)
+ {
+ out << "(Ice.ReadObjectCallback)";
+ }
+ out << "new Patcher__(" << patchParams << "));";
+ }
}
break;
}
case Builtin::KindObjectProxy:
{
- string typeS = typeToString(type);
+ string typeS = typeToString(type);
if(marshal)
{
out << nl << stream << ".writeProxy(" << param << ");";
@@ -407,20 +407,20 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out,
if(marshal)
{
out << nl << typeS << "Helper.write";
- if(!streamingAPI)
- {
- out << "__";
- }
- out << "(" << stream << ", " << param << ");";
+ if(!streamingAPI)
+ {
+ out << "__";
+ }
+ out << "(" << stream << ", " << param << ");";
}
else
{
out << nl << param << " = " << typeS << "Helper.read";
- if(!streamingAPI)
- {
- out << "__";
- }
- out << "(" << stream << ");";
+ if(!streamingAPI)
+ {
+ out << "__";
+ }
+ out << "(" << stream << ");";
}
return;
}
@@ -434,27 +434,27 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out,
}
else
{
- if(isOutParam)
- {
- ContainedPtr contained = ContainedPtr::dynamicCast(type);
- out << nl << "IceInternal.ParamPatcher " << param
- << "_PP = new IceInternal.ParamPatcher(typeof(" << typeToString(type) << "), \"" << contained->scoped() << "\");";
- out << nl << stream << ".readObject(";
- if(streamingAPI)
- {
- out << "(Ice.ReadObjectCallback)";
- }
- out << param << "_PP);";
- }
- else
- {
- out << nl << stream << ".readObject(";
- if(streamingAPI)
- {
- out << "(Ice.ReadObjectCallback)";
- }
- out << "new Patcher__(" << patchParams << "));";
- }
+ if(isOutParam)
+ {
+ ContainedPtr contained = ContainedPtr::dynamicCast(type);
+ out << nl << "IceInternal.ParamPatcher " << param
+ << "_PP = new IceInternal.ParamPatcher(typeof(" << typeToString(type) << "), \"" << contained->scoped() << "\");";
+ out << nl << stream << ".readObject(";
+ if(streamingAPI)
+ {
+ out << "(Ice.ReadObjectCallback)";
+ }
+ out << param << "_PP);";
+ }
+ else
+ {
+ out << nl << stream << ".readObject(";
+ if(streamingAPI)
+ {
+ out << "(Ice.ReadObjectCallback)";
+ }
+ out << "new Patcher__(" << patchParams << "));";
+ }
}
return;
}
@@ -464,27 +464,27 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out,
{
if(marshal)
{
- if(streamingAPI)
- {
- out << nl << param << ".ice_write(" << stream << ");";
- }
- else
- {
- out << nl << param << ".write__(" << stream << ");";
- }
+ if(streamingAPI)
+ {
+ out << nl << param << ".ice_write(" << stream << ");";
+ }
+ else
+ {
+ out << nl << param << ".write__(" << stream << ");";
+ }
}
else
{
string typeS = typeToString(type);
out << nl << param << " = new " << typeS << "();";
- if(streamingAPI)
- {
- out << nl << param << ".ice_read(" << stream << ");";
- }
- else
- {
- out << nl << param << ".read__(" << stream << ");";
- }
+ if(streamingAPI)
+ {
+ out << nl << param << ".ice_read(" << stream << ");";
+ }
+ else
+ {
+ out << nl << param << ".read__(" << stream << ");";
+ }
}
return;
}
@@ -492,32 +492,32 @@ 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)
- {
- out << nl << stream << '.' << func << '(' << cast << param << ");";
- }
- else
- {
- out << nl << param << " = " << cast << stream << '.' << func << "()" << ';';
- }
+ 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)
+ {
+ out << nl << stream << '.' << func << '(' << cast << param << ");";
+ }
+ else
+ {
+ out << nl << param << " = " << cast << stream << '.' << func << "()" << ';';
+ }
return;
}
@@ -545,7 +545,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
const SequencePtr& seq,
const string& param,
bool marshal,
- bool streamingAPI)
+ bool streamingAPI)
{
string stream;
if(marshal)
@@ -566,127 +566,127 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if(builtin)
{
- switch(builtin->kind())
- {
- case Builtin::KindObject:
- case Builtin::KindObjectProxy:
- {
- if(marshal)
- {
- out << nl << "if(" << param << " == null)";
- out << sb;
- out << nl << stream << ".writeSize(0);";
- out << eb;
- out << nl << "else";
- out << sb;
- out << nl << stream << ".writeSize(" << param << '.' << limitID << ");";
- out << nl << "for(int ix__ = 0; ix__ < " << param << '.' << limitID << "; ++ix__)";
- out << sb;
- string func = builtin->kind() == Builtin::KindObject ? "writeObject" : "writeProxy";
- out << nl << stream << '.' << func << '(' << param << "[ix__]);";
- out << eb;
- out << eb;
- }
- else
- {
- out << nl << "int lenx__ = " << stream << ".readSize();";
- if(!streamingAPI)
- {
- if(builtin->isVariableLength())
- {
- out << nl << stream << ".startSeq(lenx__, "
- << static_cast<unsigned>(builtin->minWireSize()) << ");";
- }
- else
- {
- out << nl << stream << ".checkFixedSeq(lenx__, "
- << static_cast<unsigned>(builtin->minWireSize()) << ");";
- }
- }
- out << nl << param << " = new ";
- if(builtin->kind() == Builtin::KindObject)
- {
- if(isArray)
- {
- out << "Ice.Object[lenx__];";
- }
- else
- {
- out << typeToString(seq) << "(lenx__);";
- }
- out << nl << "for(int ix__ = 0; ix__ < lenx__; ++ix__)";
- out << sb;
- out << nl << stream << ".readObject(";
- if(streamingAPI)
- {
- out << "(ReadObjectCallback)";
- }
- out << "new IceInternal.SequencePatcher(" << param << ", typeof(Ice.Object), ix__));";
- }
- else
- {
- if(isArray)
- {
- out << "Ice.ObjectPrx[lenx__];";
- }
- else
- {
- out << typeToString(seq) << "(lenx__);";
- }
- out << nl << "for(int ix__ = 0; ix__ < lenx__; ++ix__)";
- out << sb;
- if(isArray)
- {
- out << nl << param << "[ix__] = " << stream << ".readProxy();";
- }
- else
- {
- out << nl << "Ice.ObjectPrx val__ = new Ice.ObjectPrxHelperBase();";
- out << nl << "val__ = " << stream << ".readProxy();";
- out << nl << param << ".Add(val__);";
- }
- }
- if(!streamingAPI && builtin->isVariableLength())
- {
- out << nl << stream << ".checkSeq();";
- out << nl << stream << ".endElement();";
- }
- out << eb;
- if(!streamingAPI && builtin->isVariableLength())
- {
- out << nl << stream << ".endSeq(lenx__);";
- }
- }
- break;
- }
- default:
- {
- typeS[0] = toupper(typeS[0]);
- if(marshal)
- {
- out << nl << stream << ".write" << typeS << "Seq(" << param;
- if(!isArray)
- {
- out << " == null ? null : " << param << ".ToArray()";
- }
- out << ");";
- }
- else
- {
- if(!isArray)
- {
- out << nl << param << " = new " << fixId(seq->scoped())
- << '(' << stream << ".read" << typeS << "Seq());";
- }
- else
- {
- out << nl << param << " = " << stream << ".read" << typeS << "Seq();";
- }
- }
- break;
- }
- }
- return;
+ switch(builtin->kind())
+ {
+ case Builtin::KindObject:
+ case Builtin::KindObjectProxy:
+ {
+ if(marshal)
+ {
+ out << nl << "if(" << param << " == null)";
+ out << sb;
+ out << nl << stream << ".writeSize(0);";
+ out << eb;
+ out << nl << "else";
+ out << sb;
+ out << nl << stream << ".writeSize(" << param << '.' << limitID << ");";
+ out << nl << "for(int ix__ = 0; ix__ < " << param << '.' << limitID << "; ++ix__)";
+ out << sb;
+ string func = builtin->kind() == Builtin::KindObject ? "writeObject" : "writeProxy";
+ out << nl << stream << '.' << func << '(' << param << "[ix__]);";
+ out << eb;
+ out << eb;
+ }
+ else
+ {
+ out << nl << "int lenx__ = " << stream << ".readSize();";
+ if(!streamingAPI)
+ {
+ if(builtin->isVariableLength())
+ {
+ out << nl << stream << ".startSeq(lenx__, "
+ << static_cast<unsigned>(builtin->minWireSize()) << ");";
+ }
+ else
+ {
+ out << nl << stream << ".checkFixedSeq(lenx__, "
+ << static_cast<unsigned>(builtin->minWireSize()) << ");";
+ }
+ }
+ out << nl << param << " = new ";
+ if(builtin->kind() == Builtin::KindObject)
+ {
+ if(isArray)
+ {
+ out << "Ice.Object[lenx__];";
+ }
+ else
+ {
+ out << typeToString(seq) << "(lenx__);";
+ }
+ out << nl << "for(int ix__ = 0; ix__ < lenx__; ++ix__)";
+ out << sb;
+ out << nl << stream << ".readObject(";
+ if(streamingAPI)
+ {
+ out << "(ReadObjectCallback)";
+ }
+ out << "new IceInternal.SequencePatcher(" << param << ", typeof(Ice.Object), ix__));";
+ }
+ else
+ {
+ if(isArray)
+ {
+ out << "Ice.ObjectPrx[lenx__];";
+ }
+ else
+ {
+ out << typeToString(seq) << "(lenx__);";
+ }
+ out << nl << "for(int ix__ = 0; ix__ < lenx__; ++ix__)";
+ out << sb;
+ if(isArray)
+ {
+ out << nl << param << "[ix__] = " << stream << ".readProxy();";
+ }
+ else
+ {
+ out << nl << "Ice.ObjectPrx val__ = new Ice.ObjectPrxHelperBase();";
+ out << nl << "val__ = " << stream << ".readProxy();";
+ out << nl << param << ".Add(val__);";
+ }
+ }
+ if(!streamingAPI && builtin->isVariableLength())
+ {
+ out << nl << stream << ".checkSeq();";
+ out << nl << stream << ".endElement();";
+ }
+ out << eb;
+ if(!streamingAPI && builtin->isVariableLength())
+ {
+ out << nl << stream << ".endSeq(lenx__);";
+ }
+ }
+ break;
+ }
+ default:
+ {
+ typeS[0] = toupper(typeS[0]);
+ if(marshal)
+ {
+ out << nl << stream << ".write" << typeS << "Seq(" << param;
+ if(!isArray)
+ {
+ out << " == null ? null : " << param << ".ToArray()";
+ }
+ out << ");";
+ }
+ else
+ {
+ if(!isArray)
+ {
+ out << nl << param << " = new " << fixId(seq->scoped())
+ << '(' << stream << ".read" << typeS << "Seq());";
+ }
+ else
+ {
+ out << nl << param << " = " << stream << ".read" << typeS << "Seq();";
+ }
+ }
+ break;
+ }
+ }
+ return;
}
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
@@ -694,65 +694,65 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
{
if(marshal)
{
- out << nl << "if(" << param << " == null)";
- out << sb;
- out << nl << stream << ".writeSize(0);";
- out << eb;
- out << nl << "else";
- out << sb;
- out << nl << stream << ".writeSize(" << param << '.' << limitID << ");";
- out << nl << "for(int ix__ = 0; ix__ < " << param << '.' << limitID << "; ++ix__)";
- out << sb;
+ out << nl << "if(" << param << " == null)";
+ out << sb;
+ out << nl << stream << ".writeSize(0);";
+ out << eb;
+ out << nl << "else";
+ out << sb;
+ out << nl << stream << ".writeSize(" << param << '.' << limitID << ");";
+ out << nl << "for(int ix__ = 0; ix__ < " << param << '.' << limitID << "; ++ix__)";
+ out << sb;
out << nl << stream << ".writeObject(" << param << "[ix__]);";
- out << eb;
- out << eb;
+ out << eb;
+ out << eb;
}
else
{
- out << sb;
- out << nl << "int szx__ = " << stream << ".readSize();";
- if(!streamingAPI)
- {
- if(type->isVariableLength())
- {
- out << nl << stream << ".startSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ");";
- }
- else
- {
- out << nl << stream << ".checkFixedSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ");";
- }
- }
- out << nl << param << " = new ";
- if(isArray)
- {
- out << toArrayAlloc(typeS + "[]", "szx__");
- }
- else
- {
- out << fixId(seq->scoped()) << "(szx__)";
- }
- out << ';';
- out << nl << "for(int ix__ = 0; ix__ < szx__; ++ix__)";
- out << sb;
- out << nl << "IceInternal.SequencePatcher spx = new IceInternal.SequencePatcher("
- << param << ", " << "typeof(" << typeS << "), ix__);";
- out << nl << stream << ".readObject(";
- if(streamingAPI)
- {
- out << "(Ice.ReadObjectCallback)";
- }
- out << "spx);";
- if(!streamingAPI && type->isVariableLength())
- {
- out << nl << stream << ".checkSeq();";
- out << nl << stream << ".endElement();";
- }
- out << eb;
- if(!streamingAPI && type->isVariableLength())
- {
- out << nl << stream << ".endSeq(szx__);";
- }
- out << eb;
+ out << sb;
+ out << nl << "int szx__ = " << stream << ".readSize();";
+ if(!streamingAPI)
+ {
+ if(type->isVariableLength())
+ {
+ out << nl << stream << ".startSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ");";
+ }
+ else
+ {
+ out << nl << stream << ".checkFixedSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ");";
+ }
+ }
+ out << nl << param << " = new ";
+ if(isArray)
+ {
+ out << toArrayAlloc(typeS + "[]", "szx__");
+ }
+ else
+ {
+ out << fixId(seq->scoped()) << "(szx__)";
+ }
+ out << ';';
+ out << nl << "for(int ix__ = 0; ix__ < szx__; ++ix__)";
+ out << sb;
+ out << nl << "IceInternal.SequencePatcher spx = new IceInternal.SequencePatcher("
+ << param << ", " << "typeof(" << typeS << "), ix__);";
+ out << nl << stream << ".readObject(";
+ if(streamingAPI)
+ {
+ out << "(Ice.ReadObjectCallback)";
+ }
+ out << "spx);";
+ if(!streamingAPI && type->isVariableLength())
+ {
+ out << nl << stream << ".checkSeq();";
+ out << nl << stream << ".endElement();";
+ }
+ out << eb;
+ if(!streamingAPI && type->isVariableLength())
+ {
+ out << nl << stream << ".endSeq(szx__);";
+ }
+ out << eb;
}
return;
}
@@ -761,146 +761,146 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
if(st)
{
if(marshal)
- {
- out << nl << "if(" << param << " == null)";
- out << sb;
- out << nl << stream << ".writeSize(0);";
- out << eb;
- out << nl << "else";
- out << sb;
- out << nl << stream << ".writeSize(" << param << '.' << limitID << ");";
- out << nl << "for(int ix__ = 0; ix__ < " << param << '.' << limitID << "; ++ix__)";
- out << sb;
- if(streamingAPI)
- {
- out << nl << param << "[ix__].ice_write(" << stream << ");";
- }
- else
- {
- out << nl << param << "[ix__].write__(" << stream << ");";
- }
- out << eb;
- out << eb;
- }
- else
- {
- out << sb;
- out << nl << "int szx__ = " << stream << ".readSize();";
- if(!streamingAPI)
- {
- if(type->isVariableLength())
- {
- out << nl << stream << ".startSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ");";
- }
- else
- {
- out << nl << stream << ".checkFixedSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ");";
- }
- }
- out << nl << param << " = new ";
- if(isArray)
- {
- out << toArrayAlloc(typeS + "[]", "szx__");
- }
- else
- {
- out << fixId(seq->scoped()) << "(szx__)";
- }
- out << ';';
- out << nl << "for(int ix__ = 0; ix__ < szx__; ++ix__)";
- out << sb;
- if(isArray)
- {
- if(!isValueType(st))
- {
- out << nl << param << "[ix__] = new " << typeS << "();";
- }
- if(streamingAPI)
- {
- out << nl << param << "[ix__].ice_read(" << stream << ");";
- }
- else
- {
- out << nl << param << "[ix__].read__(" << stream << ");";
- }
- }
- else
- {
- out << nl << typeS << " val__ = new " << typeS << "();";
- if(streamingAPI)
- {
- out << nl << "val__.ice_read(" << stream << ");";
- }
- else
- {
- out << nl << "val__.read__(" << stream << ");";
- }
- out << nl << param << ".Add(val__);";
- }
- if(!streamingAPI && type->isVariableLength())
- {
- out << nl << stream << ".checkSeq();";
- out << nl << stream << ".endElement();";
- }
- out << eb;
- if(!streamingAPI && type->isVariableLength())
- {
- out << nl << stream << ".endSeq(szx__);";
- }
- out << eb;
- }
- return;
+ {
+ out << nl << "if(" << param << " == null)";
+ out << sb;
+ out << nl << stream << ".writeSize(0);";
+ out << eb;
+ out << nl << "else";
+ out << sb;
+ out << nl << stream << ".writeSize(" << param << '.' << limitID << ");";
+ out << nl << "for(int ix__ = 0; ix__ < " << param << '.' << limitID << "; ++ix__)";
+ out << sb;
+ if(streamingAPI)
+ {
+ out << nl << param << "[ix__].ice_write(" << stream << ");";
+ }
+ else
+ {
+ out << nl << param << "[ix__].write__(" << stream << ");";
+ }
+ out << eb;
+ out << eb;
+ }
+ else
+ {
+ out << sb;
+ out << nl << "int szx__ = " << stream << ".readSize();";
+ if(!streamingAPI)
+ {
+ if(type->isVariableLength())
+ {
+ out << nl << stream << ".startSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ");";
+ }
+ else
+ {
+ out << nl << stream << ".checkFixedSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ");";
+ }
+ }
+ out << nl << param << " = new ";
+ if(isArray)
+ {
+ out << toArrayAlloc(typeS + "[]", "szx__");
+ }
+ else
+ {
+ out << fixId(seq->scoped()) << "(szx__)";
+ }
+ out << ';';
+ out << nl << "for(int ix__ = 0; ix__ < szx__; ++ix__)";
+ out << sb;
+ if(isArray)
+ {
+ if(!isValueType(st))
+ {
+ out << nl << param << "[ix__] = new " << typeS << "();";
+ }
+ if(streamingAPI)
+ {
+ out << nl << param << "[ix__].ice_read(" << stream << ");";
+ }
+ else
+ {
+ out << nl << param << "[ix__].read__(" << stream << ");";
+ }
+ }
+ else
+ {
+ out << nl << typeS << " val__ = new " << typeS << "();";
+ if(streamingAPI)
+ {
+ out << nl << "val__.ice_read(" << stream << ");";
+ }
+ else
+ {
+ out << nl << "val__.read__(" << stream << ");";
+ }
+ out << nl << param << ".Add(val__);";
+ }
+ if(!streamingAPI && type->isVariableLength())
+ {
+ out << nl << stream << ".checkSeq();";
+ out << nl << stream << ".endElement();";
+ }
+ out << eb;
+ if(!streamingAPI && type->isVariableLength())
+ {
+ out << nl << stream << ".endSeq(szx__);";
+ }
+ out << eb;
+ }
+ return;
}
EnumPtr en = EnumPtr::dynamicCast(type);
if(en)
{
- if(marshal)
- {
- out << nl << "if(" << param << " == null)";
- out << sb;
- out << nl << stream << ".writeSize(0);";
- out << eb;
- out << nl << "else";
- out << sb;
- out << nl << stream << ".writeSize(" << param << '.'<< limitID << ");";
- out << nl << "for(int ix__ = 0; ix__ < " << param << '.' << limitID << "; ++ix__)";
- out << sb;
- out << nl << stream << ".writeByte((byte)" << param << "[ix__]);";
- out << eb;
- out << eb;
- }
- else
- {
- out << sb;
- out << nl << "int szx__ = " << stream << ".readSize();";
- if(!streamingAPI)
- {
- out << nl << stream << ".checkFixedSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ");";
- }
- out << nl << param << " = new ";
- if(isArray)
- {
- out << toArrayAlloc(typeS + "[]", "szx__");
- }
- else
- {
- out << fixId(seq->scoped()) << "(szx__)";
- }
- out << ';';
- out << nl << "for(int ix__ = 0; ix__ < szx__; ++ix__)";
- out << sb;
- if(isArray)
- {
- out << nl << param << "[ix__] = (" << typeS << ')' << stream << ".readByte();";
- }
- else
- {
- out << nl << param << ".Add((" << typeS << ')' << stream << ".readByte());";
- }
- out << eb;
- out << eb;
- }
+ if(marshal)
+ {
+ out << nl << "if(" << param << " == null)";
+ out << sb;
+ out << nl << stream << ".writeSize(0);";
+ out << eb;
+ out << nl << "else";
+ out << sb;
+ out << nl << stream << ".writeSize(" << param << '.'<< limitID << ");";
+ out << nl << "for(int ix__ = 0; ix__ < " << param << '.' << limitID << "; ++ix__)";
+ out << sb;
+ out << nl << stream << ".writeByte((byte)" << param << "[ix__]);";
+ out << eb;
+ out << eb;
+ }
+ else
+ {
+ out << sb;
+ out << nl << "int szx__ = " << stream << ".readSize();";
+ if(!streamingAPI)
+ {
+ out << nl << stream << ".checkFixedSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ");";
+ }
+ out << nl << param << " = new ";
+ if(isArray)
+ {
+ out << toArrayAlloc(typeS + "[]", "szx__");
+ }
+ else
+ {
+ out << fixId(seq->scoped()) << "(szx__)";
+ }
+ out << ';';
+ out << nl << "for(int ix__ = 0; ix__ < szx__; ++ix__)";
+ out << sb;
+ if(isArray)
+ {
+ out << nl << param << "[ix__] = (" << typeS << ')' << stream << ".readByte();";
+ }
+ else
+ {
+ out << nl << param << ".Add((" << typeS << ')' << stream << ".readByte());";
+ }
+ out << eb;
+ out << eb;
+ }
return;
}
@@ -918,77 +918,77 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
if(marshal)
{
func = "write";
- if(!streamingAPI && ProxyPtr::dynamicCast(type))
- {
- func += "__";
- }
- out << nl << "if(" << param << " == null)";
- out << sb;
- out << nl << stream << ".writeSize(0);";
- out << eb;
- out << nl << "else";
- out << sb;
- out << nl << stream << ".writeSize(" << param << '.' << limitID << ");";
- out << nl << "for(int ix__ = 0; ix__ < " << param << '.' << limitID << "; ++ix__)";
- out << sb;
- out << nl << helperName << '.' << func << '(' << stream << ", " << param << "[ix__]);";
- out << eb;
- out << eb;
+ if(!streamingAPI && ProxyPtr::dynamicCast(type))
+ {
+ func += "__";
+ }
+ out << nl << "if(" << param << " == null)";
+ out << sb;
+ out << nl << stream << ".writeSize(0);";
+ out << eb;
+ out << nl << "else";
+ out << sb;
+ out << nl << stream << ".writeSize(" << param << '.' << limitID << ");";
+ out << nl << "for(int ix__ = 0; ix__ < " << param << '.' << limitID << "; ++ix__)";
+ out << sb;
+ out << nl << helperName << '.' << func << '(' << stream << ", " << param << "[ix__]);";
+ out << eb;
+ out << eb;
}
else
{
func = "read";
- if(!streamingAPI && ProxyPtr::dynamicCast(type))
- {
- func += "__";
- }
- out << sb;
- out << nl << "int szx__ = " << stream << ".readSize();";
- if(!streamingAPI)
- {
- if(type->isVariableLength())
- {
- out << nl << stream << ".startSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ");";
- }
- else
- {
- out << nl << stream << ".checkFixedSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ");";
- }
- }
- out << nl << param << " = new ";
- if(isArray)
- {
- out << toArrayAlloc(typeS + "[]", "szx__");
- }
- else
- {
- out << fixId(seq->scoped()) << "(szx__)";
- }
- out << ';';
- out << nl << "for(int ix__ = 0; ix__ < szx__; ++ix__)";
- out << sb;
- if(isArray)
- {
- out << nl << param << "[ix__] = " << helperName << '.' << func << '(' << stream << ");";
- }
- else
- {
- out << nl << param << ".Add(" << helperName << '.' << func << '(' << stream << "));";
- }
- if(!streamingAPI && type->isVariableLength())
- {
- if(!SequencePtr::dynamicCast(type))
- {
- out << nl << stream << ".checkSeq();";
- }
- out << nl << stream << ".endElement();";
- }
- out << eb;
- if(!streamingAPI && type->isVariableLength())
- {
- out << nl << stream << ".endSeq(szx__);";
- }
- out << eb;
+ if(!streamingAPI && ProxyPtr::dynamicCast(type))
+ {
+ func += "__";
+ }
+ out << sb;
+ out << nl << "int szx__ = " << stream << ".readSize();";
+ if(!streamingAPI)
+ {
+ if(type->isVariableLength())
+ {
+ out << nl << stream << ".startSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ");";
+ }
+ else
+ {
+ out << nl << stream << ".checkFixedSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ");";
+ }
+ }
+ out << nl << param << " = new ";
+ if(isArray)
+ {
+ out << toArrayAlloc(typeS + "[]", "szx__");
+ }
+ else
+ {
+ out << fixId(seq->scoped()) << "(szx__)";
+ }
+ out << ';';
+ out << nl << "for(int ix__ = 0; ix__ < szx__; ++ix__)";
+ out << sb;
+ if(isArray)
+ {
+ out << nl << param << "[ix__] = " << helperName << '.' << func << '(' << stream << ");";
+ }
+ else
+ {
+ out << nl << param << ".Add(" << helperName << '.' << func << '(' << stream << "));";
+ }
+ if(!streamingAPI && type->isVariableLength())
+ {
+ if(!SequencePtr::dynamicCast(type))
+ {
+ out << nl << stream << ".checkSeq();";
+ }
+ out << nl << stream << ".endElement();";
+ }
+ out << eb;
+ if(!streamingAPI && type->isVariableLength())
+ {
+ out << nl << stream << ".endSeq(szx__);";
+ }
+ out << eb;
}
return;
@@ -1002,7 +1002,7 @@ Slice::CsGenerator::toArrayAlloc(const string& decl, const string& sz)
while(pos > 1 && decl.substr(pos - 2, 2) == "[]")
{
++count;
- pos -= 2;
+ pos -= 2;
}
assert(count > 0);
@@ -1028,31 +1028,31 @@ Slice::CsGenerator::MetaDataVisitor::visitModuleStart(const ModulePtr& p)
{
if(!_globalMetaDataDone)
{
- //
- // Validate global metadata.
- //
- DefinitionContextPtr dc = p->definitionContext();
- assert(dc);
- StringList globalMetaData = dc->getMetaData();
- string file = dc->filename();
- static const string prefix = "cs:";
- for(StringList::const_iterator q = globalMetaData.begin(); q != globalMetaData.end(); ++q)
- {
- string s = *q;
- if(_history.count(s) == 0)
- {
- if(s.find(prefix) == 0)
- {
- static const string attributePrefix = "cs:attribute:";
- if(s.find(attributePrefix) != 0 || s.size() == attributePrefix.size())
- {
- cout << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl;
- }
- }
- _history.insert(s);
- }
- }
- _globalMetaDataDone = true;
+ //
+ // Validate global metadata.
+ //
+ DefinitionContextPtr dc = p->definitionContext();
+ assert(dc);
+ StringList globalMetaData = dc->getMetaData();
+ string file = dc->filename();
+ static const string prefix = "cs:";
+ for(StringList::const_iterator q = globalMetaData.begin(); q != globalMetaData.end(); ++q)
+ {
+ string s = *q;
+ if(_history.count(s) == 0)
+ {
+ if(s.find(prefix) == 0)
+ {
+ static const string attributePrefix = "cs:attribute:";
+ if(s.find(attributePrefix) != 0 || s.size() == attributePrefix.size())
+ {
+ cout << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl;
+ }
+ }
+ _history.insert(s);
+ }
+ }
+ _globalMetaDataDone = true;
}
validate(p);
return true;
@@ -1160,83 +1160,83 @@ Slice::CsGenerator::MetaDataVisitor::validate(const ContainedPtr& cont)
for(p = localMetaData.begin(); p != localMetaData.end(); ++p)
{
- string s = *p;
+ string s = *p;
- if(s.find("cs:") == 0) // TODO: remove this statement once "cs:" is a hard error.
- {
- if(SequencePtr::dynamicCast(cont))
- {
- if(s.substr(3) == "collection")
- {
- cout << file << ":" << cont->line() << ": warning: `cs:' metadata prefix is deprecated; "
- << "use `clr:' instead" << endl;
- cont->addMetaData("clr:collection");
- }
- }
- else if(StructPtr::dynamicCast(cont))
- {
- if(s.substr(3) == "class")
- {
- cout << file << ":" << cont->line() << ": warning: `cs:' metadata prefix is deprecated; "
- << "use `clr:' instead" << endl;
- cont->addMetaData("clr:class");
- }
- }
- else if(s.find("cs:attribute:") == 0)
- {
- ; // Do nothing, "cs:attribute:" is OK
- }
- else
- {
- cout << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl;
- }
- } // End TODO
+ if(s.find("cs:") == 0) // TODO: remove this statement once "cs:" is a hard error.
+ {
+ if(SequencePtr::dynamicCast(cont))
+ {
+ if(s.substr(3) == "collection")
+ {
+ cout << file << ":" << cont->line() << ": warning: `cs:' metadata prefix is deprecated; "
+ << "use `clr:' instead" << endl;
+ cont->addMetaData("clr:collection");
+ }
+ }
+ else if(StructPtr::dynamicCast(cont))
+ {
+ if(s.substr(3) == "class")
+ {
+ cout << file << ":" << cont->line() << ": warning: `cs:' metadata prefix is deprecated; "
+ << "use `clr:' instead" << endl;
+ cont->addMetaData("clr:class");
+ }
+ }
+ else if(s.find("cs:attribute:") == 0)
+ {
+ ; // Do nothing, "cs:attribute:" is OK
+ }
+ else
+ {
+ cout << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl;
+ }
+ } // End TODO
- string prefix = "clr:";
+ string prefix = "clr:";
if(_history.count(s) == 0)
{
if(s.find(prefix) == 0)
{
- if(SequencePtr::dynamicCast(cont))
- {
- if(s.substr(prefix.size()) == "collection")
- {
- continue;
- }
- }
- if(StructPtr::dynamicCast(cont))
- {
- if(s.substr(prefix.size()) == "class")
- {
- continue;
- }
- if(s.substr(prefix.size()) == "property")
- {
- continue;
- }
- }
- if(ClassDefPtr::dynamicCast(cont))
- {
- if(s.substr(prefix.size()) == "property")
- {
- continue;
- }
- }
- cout << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl;
+ if(SequencePtr::dynamicCast(cont))
+ {
+ if(s.substr(prefix.size()) == "collection")
+ {
+ continue;
+ }
+ }
+ if(StructPtr::dynamicCast(cont))
+ {
+ if(s.substr(prefix.size()) == "class")
+ {
+ continue;
+ }
+ if(s.substr(prefix.size()) == "property")
+ {
+ continue;
+ }
+ }
+ if(ClassDefPtr::dynamicCast(cont))
+ {
+ if(s.substr(prefix.size()) == "property")
+ {
+ continue;
+ }
+ }
+ cout << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl;
}
_history.insert(s);
}
- prefix = "cs:";
+ prefix = "cs:";
if(_history.count(s) == 0)
{
if(s.find(prefix) == 0)
{
- if(s.substr(prefix.size()) == "attribute:")
- {
- continue;
- }
- cout << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl;
+ if(s.substr(prefix.size()) == "attribute:")
+ {
+ continue;
+ }
+ cout << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl;
}
_history.insert(s);
}
diff --git a/cpp/src/Slice/DotNetNames.cpp b/cpp/src/Slice/DotNetNames.cpp
index 5588f9a20c9..f55f6470454 100755
--- a/cpp/src/Slice/DotNetNames.cpp
+++ b/cpp/src/Slice/DotNetNames.cpp
@@ -25,81 +25,81 @@ struct Node
};
static const char* ObjectNames[] =
- {
- "Equals", "Finalize", "GetHashCode", "GetType",
- "MemberwiseClone", "ReferenceEquals", "ToString", 0
- };
+ {
+ "Equals", "Finalize", "GetHashCode", "GetType",
+ "MemberwiseClone", "ReferenceEquals", "ToString", 0
+ };
static const Node* ObjectParents[] =
- {
- 0
- };
+ {
+ 0
+ };
static const Node ObjectNode =
- {
- ObjectNames, &ObjectParents[0]
- };
+ {
+ ObjectNames, &ObjectParents[0]
+ };
static const char* ICloneableNames[] =
- {
- "Clone", 0
- };
+ {
+ "Clone", 0
+ };
static const Node* ICloneableParents[] =
- {
- &ObjectNode, 0
- };
+ {
+ &ObjectNode, 0
+ };
static const Node ICloneableNode =
- {
- ICloneableNames, &ICloneableParents[0]
- };
+ {
+ ICloneableNames, &ICloneableParents[0]
+ };
static const char* ExceptionNames[] =
- {
- "GetBaseException", "GetObjectData", "HelpLink", "HResult", "InnerException",
- "Message", "Source", "StackTrace", "TargetSite", 0
- };
+ {
+ "GetBaseException", "GetObjectData", "HelpLink", "HResult", "InnerException",
+ "Message", "Source", "StackTrace", "TargetSite", 0
+ };
static const Node* ExceptionParents[] =
- {
- &ObjectNode, 0
- };
+ {
+ &ObjectNode, 0
+ };
static const Node ExceptionNode =
- {
- ExceptionNames, &ExceptionParents[0]
- };
+ {
+ ExceptionNames, &ExceptionParents[0]
+ };
static const char* ApplicationExceptionNames[] =
- {
- 0
- };
+ {
+ 0
+ };
static const Node* ApplicationExceptionParents[] =
- {
- &ExceptionNode, 0
- };
+ {
+ &ExceptionNode, 0
+ };
static const Node ApplicationExceptionNode =
- {
- ApplicationExceptionNames, &ApplicationExceptionParents[0]
- };
+ {
+ ApplicationExceptionNames, &ApplicationExceptionParents[0]
+ };
//
// Must be kept in same order as definition of BaseType in header file!
//
static const Node* nodes[] =
- {
- &ObjectNode, &ICloneableNode, &ExceptionNode, &ApplicationExceptionNode
- };
+ {
+ &ObjectNode, &ICloneableNode, &ExceptionNode, &ApplicationExceptionNode
+ };
static bool
ciEquals(const string& s, const char* p)
{
if(s.size() != strlen(p))
{
- return false;
+ return false;
}
string::const_iterator i = s.begin();
while(i != s.end())
{
- if(tolower(*i++) != tolower(*p++))
- {
- return false;
- }
+ if(tolower(*i++) != tolower(*p++))
+ {
+ return false;
+ }
}
return true;
}
@@ -113,21 +113,21 @@ mangle(const string& s, const Node* np, string& newName)
const char** namep = np->names;
while(*namep)
{
- if(ciEquals(s, *namep))
- {
- newName = manglePrefix + s + mangleSuffix;
- return true;
- }
- ++namep;
+ if(ciEquals(s, *namep))
+ {
+ newName = manglePrefix + s + mangleSuffix;
+ return true;
+ }
+ ++namep;
}
const Node** parentp = np->parents;
while(*parentp)
{
- if(mangle(s, *parentp, newName))
- {
- return true;
- }
- ++parentp;
+ if(mangle(s, *parentp, newName))
+ {
+ return true;
+ }
+ ++parentp;
}
return false;
}
@@ -141,18 +141,18 @@ Slice::DotNet::mangleName(const string& s, int baseTypes)
{
if(baseTypes == 0)
{
- return s;
+ return s;
}
string newName;
for(unsigned int mask = 1, i=0; mask < END; mask <<= 1, ++i)
{
- if(baseTypes & mask)
- {
- if(mangle(s, nodes[i], newName))
- {
- return newName;
- }
- }
+ if(baseTypes & mask)
+ {
+ if(mangle(s, nodes[i], newName))
+ {
+ return newName;
+ }
+ }
}
return s;
}
diff --git a/cpp/src/Slice/JavaUtil.cpp b/cpp/src/Slice/JavaUtil.cpp
index 5406f1dedef..3c3d68afd0e 100644
--- a/cpp/src/Slice/JavaUtil.cpp
+++ b/cpp/src/Slice/JavaUtil.cpp
@@ -220,16 +220,16 @@ lookupKwd(const string& name)
"abstract", "assert", "boolean", "break", "byte", "case", "catch",
"char", "checkedCast", "class", "clone", "const", "continue", "default", "do",
"double", "else", "enum", "equals", "extends", "false", "final", "finalize",
- "finally", "float", "for", "getClass", "goto", "hashCode", "if",
- "implements", "import", "instanceof", "int", "interface", "long",
- "native", "new", "notify", "notifyAll", "null", "package", "private",
- "protected", "public", "return", "short", "static", "strictfp", "super", "switch",
+ "finally", "float", "for", "getClass", "goto", "hashCode", "if",
+ "implements", "import", "instanceof", "int", "interface", "long",
+ "native", "new", "notify", "notifyAll", "null", "package", "private",
+ "protected", "public", "return", "short", "static", "strictfp", "super", "switch",
"synchronized", "this", "throw", "throws", "toString", "transient",
"true", "try", "uncheckedCast", "void", "volatile", "wait", "while"
};
bool found = binary_search(&keywordList[0],
- &keywordList[sizeof(keywordList) / sizeof(*keywordList)],
- name);
+ &keywordList[sizeof(keywordList) / sizeof(*keywordList)],
+ name);
return found ? "_" + name : name;
}
@@ -245,24 +245,24 @@ splitScopedName(const string& scoped)
string::size_type pos;
while((pos = scoped.find("::", next)) != string::npos)
{
- pos += 2;
- if(pos != scoped.size())
- {
- string::size_type endpos = scoped.find("::", pos);
- if(endpos != string::npos)
- {
- ids.push_back(scoped.substr(pos, endpos - pos));
- }
- }
- next = pos;
+ pos += 2;
+ if(pos != scoped.size())
+ {
+ string::size_type endpos = scoped.find("::", pos);
+ if(endpos != string::npos)
+ {
+ ids.push_back(scoped.substr(pos, endpos - pos));
+ }
+ }
+ next = pos;
}
if(next != scoped.size())
{
- ids.push_back(scoped.substr(next));
+ ids.push_back(scoped.substr(next));
}
else
{
- ids.push_back("");
+ ids.push_back("");
}
return ids;
@@ -280,18 +280,18 @@ Slice::JavaGenerator::fixKwd(const string& name) const
{
if(name.empty())
{
- return name;
+ return name;
}
if(name[0] != ':')
{
- return lookupKwd(name);
+ return lookupKwd(name);
}
StringList ids = splitScopedName(name);
transform(ids.begin(), ids.end(), ids.begin(), ptr_fun(lookupKwd));
stringstream result;
for(StringList::const_iterator i = ids.begin(); i != ids.end(); ++i)
{
- result << "::" + *i;
+ result << "::" + *i;
}
return result.str();
}
@@ -403,7 +403,7 @@ Slice::JavaGenerator::typeToString(const TypePtr& type,
TypeMode mode,
const string& package,
const StringList& metaData,
- bool abstract) const
+ bool abstract) const
{
static const char* builtinTable[] =
{
@@ -470,48 +470,48 @@ Slice::JavaGenerator::typeToString(const TypePtr& type,
{
if(mode == TypeModeOut)
{
- if(_featureProfile == Slice::IceE)
- {
- return getAbsolute(dict, package, "", "Holder");
- }
- else
- {
- //
- // Only use the type's generated holder if the concrete and
- // abstract types match.
- //
- string concreteType, abstractType;
- getDictionaryTypes(dict, "", metaData, concreteType, abstractType);
- string origConcreteType, origAbstractType;
- getDictionaryTypes(dict, "", StringList(), origConcreteType, origAbstractType);
- if(abstractType == origAbstractType && concreteType == origConcreteType)
- {
- return getAbsolute(dict, package, "", "Holder");
- }
-
- bool java2 = dict->definitionContext()->findMetaData(_java2MetaData) == _java2MetaData;
-
- //
- // The custom type may or may not be compatible with the type used
- // in the generated holder. For Java5, we can use a generic holder
- // that holds a value of the abstract custom type. Otherwise, we
- // use MapHolder.
- //
- if(java2)
- {
- return "Ice.MapHolder";
- }
- else
- {
- return string("Ice.Holder<") + abstractType + " >";
- }
- }
+ if(_featureProfile == Slice::IceE)
+ {
+ return getAbsolute(dict, package, "", "Holder");
+ }
+ else
+ {
+ //
+ // Only use the type's generated holder if the concrete and
+ // abstract types match.
+ //
+ string concreteType, abstractType;
+ getDictionaryTypes(dict, "", metaData, concreteType, abstractType);
+ string origConcreteType, origAbstractType;
+ getDictionaryTypes(dict, "", StringList(), origConcreteType, origAbstractType);
+ if(abstractType == origAbstractType && concreteType == origConcreteType)
+ {
+ return getAbsolute(dict, package, "", "Holder");
+ }
+
+ bool java2 = dict->definitionContext()->findMetaData(_java2MetaData) == _java2MetaData;
+
+ //
+ // The custom type may or may not be compatible with the type used
+ // in the generated holder. For Java5, we can use a generic holder
+ // that holds a value of the abstract custom type. Otherwise, we
+ // use MapHolder.
+ //
+ if(java2)
+ {
+ return "Ice.MapHolder";
+ }
+ else
+ {
+ return string("Ice.Holder<") + abstractType + " >";
+ }
+ }
}
else
{
- string concreteType, abstractType;
- getDictionaryTypes(dict, package, metaData, concreteType, abstractType);
- return abstract ? abstractType : concreteType;
+ string concreteType, abstractType;
+ getDictionaryTypes(dict, package, metaData, concreteType, abstractType);
+ return abstract ? abstractType : concreteType;
}
}
@@ -520,59 +520,59 @@ Slice::JavaGenerator::typeToString(const TypePtr& type,
{
if(mode == TypeModeOut)
{
- if(_featureProfile == Slice::IceE)
- {
- return getAbsolute(seq, package, "", "Holder");
- }
- else
- {
- //
- // Only use the type's generated holder if the concrete and
- // abstract types match.
- //
- string concreteType, abstractType;
- getSequenceTypes(seq, "", metaData, concreteType, abstractType);
- string origConcreteType, origAbstractType;
- getSequenceTypes(seq, "", StringList(), origConcreteType, origAbstractType);
- if(abstractType == origAbstractType && concreteType == origConcreteType)
- {
- return getAbsolute(seq, package, "", "Holder");
- }
-
- bool java2 = seq->definitionContext()->findMetaData(_java2MetaData) == _java2MetaData;
-
- //
- // The custom type may or may not be compatible with the type used
- // in the generated holder. For Java5, we can use a generic holder
- // that holds a value of the abstract custom type. Otherwise, we
- // choose a predefined holder class.
- //
- if(java2)
- {
- if(abstractType == "java.util.ArrayList")
- {
- return "Ice.ArrayListHolder";
- }
- else if(abstractType == "java.util.LinkedList")
- {
- return "Ice.LinkedListHolder";
- }
- else
- {
- return "Ice.ListHolder";
- }
- }
- else
- {
- return string("Ice.Holder<") + abstractType + " >";
- }
- }
+ if(_featureProfile == Slice::IceE)
+ {
+ return getAbsolute(seq, package, "", "Holder");
+ }
+ else
+ {
+ //
+ // Only use the type's generated holder if the concrete and
+ // abstract types match.
+ //
+ string concreteType, abstractType;
+ getSequenceTypes(seq, "", metaData, concreteType, abstractType);
+ string origConcreteType, origAbstractType;
+ getSequenceTypes(seq, "", StringList(), origConcreteType, origAbstractType);
+ if(abstractType == origAbstractType && concreteType == origConcreteType)
+ {
+ return getAbsolute(seq, package, "", "Holder");
+ }
+
+ bool java2 = seq->definitionContext()->findMetaData(_java2MetaData) == _java2MetaData;
+
+ //
+ // The custom type may or may not be compatible with the type used
+ // in the generated holder. For Java5, we can use a generic holder
+ // that holds a value of the abstract custom type. Otherwise, we
+ // choose a predefined holder class.
+ //
+ if(java2)
+ {
+ if(abstractType == "java.util.ArrayList")
+ {
+ return "Ice.ArrayListHolder";
+ }
+ else if(abstractType == "java.util.LinkedList")
+ {
+ return "Ice.LinkedListHolder";
+ }
+ else
+ {
+ return "Ice.ListHolder";
+ }
+ }
+ else
+ {
+ return string("Ice.Holder<") + abstractType + " >";
+ }
+ }
}
else
{
- string concreteType, abstractType;
- getSequenceTypes(seq, package, metaData, concreteType, abstractType);
- return abstract ? abstractType : concreteType;
+ string concreteType, abstractType;
+ getSequenceTypes(seq, package, metaData, concreteType, abstractType);
+ return abstract ? abstractType : concreteType;
}
}
@@ -594,10 +594,10 @@ Slice::JavaGenerator::typeToString(const TypePtr& type,
string
Slice::JavaGenerator::typeToObjectString(const TypePtr& type,
- TypeMode mode,
- const string& package,
- const StringList& metaData,
- bool abstract) const
+ TypeMode mode,
+ const string& package,
+ const StringList& metaData,
+ bool abstract) const
{
static const char* builtinTable[] =
{
@@ -617,7 +617,7 @@ Slice::JavaGenerator::typeToObjectString(const TypePtr& type,
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if(builtin && mode != TypeModeOut)
{
- return builtinTable[builtin->kind()];
+ return builtinTable[builtin->kind()];
}
return typeToString(type, mode, package, metaData, abstract);
@@ -632,7 +632,7 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out,
int& iter,
bool holder,
const StringList& metaData,
- const string& patchParams)
+ const string& patchParams)
{
string stream = marshal ? "__os" : "__is";
string v;
@@ -748,31 +748,31 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out,
}
case Builtin::KindObject:
{
- if(_featureProfile != Slice::IceE)
- {
- if(marshal)
- {
- out << nl << stream << ".writeObject(" << v << ");";
- }
- else
- {
- if(holder)
- {
- out << nl << stream << ".readObject(" << param << ".getPatcher());";
- }
- else
- {
- if(patchParams.empty())
- {
- out << nl << stream << ".readObject(new Patcher());";
- }
- else
- {
- out << nl << stream << ".readObject(" << patchParams << ");";
- }
- }
- }
- }
+ if(_featureProfile != Slice::IceE)
+ {
+ if(marshal)
+ {
+ out << nl << stream << ".writeObject(" << v << ");";
+ }
+ else
+ {
+ if(holder)
+ {
+ out << nl << stream << ".readObject(" << param << ".getPatcher());";
+ }
+ else
+ {
+ if(patchParams.empty())
+ {
+ out << nl << stream << ".readObject(new Patcher());";
+ }
+ else
+ {
+ out << nl << stream << ".readObject(" << patchParams << ");";
+ }
+ }
+ }
+ }
break;
}
case Builtin::KindObjectProxy:
@@ -814,32 +814,32 @@ Slice::JavaGenerator::writeMarshalUnmarshalCode(Output& out,
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
if(cl)
{
- if(_featureProfile != Slice::IceE)
- {
- if(marshal)
- {
- out << nl << stream << ".writeObject(" << v << ");";
- }
- else
- {
- string typeS = typeToString(type, TypeModeIn, package);
- if(holder)
- {
- out << nl << stream << ".readObject(" << param << ".getPatcher());";
- }
- else
- {
- if(patchParams.empty())
- {
- out << nl << stream << ".readObject(new Patcher());";
- }
- else
- {
- out << nl << stream << ".readObject(" << patchParams << ");";
- }
- }
- }
- }
+ if(_featureProfile != Slice::IceE)
+ {
+ if(marshal)
+ {
+ out << nl << stream << ".writeObject(" << v << ");";
+ }
+ else
+ {
+ string typeS = typeToString(type, TypeModeIn, package);
+ if(holder)
+ {
+ out << nl << stream << ".readObject(" << param << ".getPatcher());";
+ }
+ else
+ {
+ if(patchParams.empty())
+ {
+ out << nl << stream << ".readObject(new Patcher());";
+ }
+ else
+ {
+ out << nl << stream << ".readObject(" << patchParams << ");";
+ }
+ }
+ }
+ }
return;
}
@@ -919,30 +919,30 @@ Slice::JavaGenerator::writeDictionaryMarshalUnmarshalCode(Output& out,
if(_featureProfile != Slice::IceE)
{
- java2 = dict->definitionContext()->findMetaData(_java2MetaData) == _java2MetaData;
-
- //
- // We have to determine whether it's possible to use the
- // type's generated helper class for this marshal/unmarshal
- // task. Since the user may have specified a custom type in
- // metadata, it's possible that the helper class is not
- // compatible and therefore we'll need to generate the code
- // in-line instead.
- //
- // Specifically, there may be "local" metadata (i.e., from
- // a data member or parameter definition) that overrides the
- // original type. We'll compare the mapped types with and
- // without local metadata to determine whether we can use
- // the helper.
- //
- string abstractType;
- getDictionaryTypes(dict, "", metaData, concreteType, abstractType);
- string origConcreteType, origAbstractType;
- getDictionaryTypes(dict, "", StringList(), origConcreteType, origAbstractType);
- if((abstractType != origAbstractType) || (!marshal && concreteType != origConcreteType))
- {
- useHelper = false;
- }
+ java2 = dict->definitionContext()->findMetaData(_java2MetaData) == _java2MetaData;
+
+ //
+ // We have to determine whether it's possible to use the
+ // type's generated helper class for this marshal/unmarshal
+ // task. Since the user may have specified a custom type in
+ // metadata, it's possible that the helper class is not
+ // compatible and therefore we'll need to generate the code
+ // in-line instead.
+ //
+ // Specifically, there may be "local" metadata (i.e., from
+ // a data member or parameter definition) that overrides the
+ // original type. We'll compare the mapped types with and
+ // without local metadata to determine whether we can use
+ // the helper.
+ //
+ string abstractType;
+ getDictionaryTypes(dict, "", metaData, concreteType, abstractType);
+ string origConcreteType, origAbstractType;
+ getDictionaryTypes(dict, "", StringList(), origConcreteType, origAbstractType);
+ if((abstractType != origAbstractType) || (!marshal && concreteType != origConcreteType))
+ {
+ useHelper = false;
+ }
}
//
@@ -950,16 +950,16 @@ Slice::JavaGenerator::writeDictionaryMarshalUnmarshalCode(Output& out,
//
if(useHelper)
{
- string typeS = getAbsolute(dict, package);
- if(marshal)
- {
- out << nl << typeS << "Helper.write(" << stream << ", " << v << ");";
- }
- else
- {
- out << nl << v << " = " << typeS << "Helper.read(" << stream << ");";
- }
- return;
+ string typeS = getAbsolute(dict, package);
+ if(marshal)
+ {
+ out << nl << typeS << "Helper.write(" << stream << ", " << v << ");";
+ }
+ else
+ {
+ out << nl << v << " = " << typeS << "Helper.read(" << stream << ");";
+ }
+ return;
}
TypePtr key = dict->keyType();
@@ -983,21 +983,21 @@ Slice::JavaGenerator::writeDictionaryMarshalUnmarshalCode(Output& out,
out << nl << "else";
out << sb;
out << nl << "__os.writeSize(" << v << ".size());";
- if(java2)
- {
- out << nl << "java.util.Iterator __i" << iterS << " = " << v << ".entrySet().iterator();";
- out << nl << "while(__i" << iterS << ".hasNext())";
- out << sb;
- out << nl << "java.util.Map.Entry __e = (java.util.Map.Entry)" << "__i" << iterS << ".next();";
- }
- else
- {
- string keyObjectS = typeToObjectString(key, TypeModeIn, package);
- string valueObjectS = typeToObjectString(value, TypeModeIn, package);
- out << nl << "for(java.util.Map.Entry<" << keyObjectS << ", " << valueObjectS << "> __e : " << v
- << ".entrySet())";
- out << sb;
- }
+ if(java2)
+ {
+ out << nl << "java.util.Iterator __i" << iterS << " = " << v << ".entrySet().iterator();";
+ out << nl << "while(__i" << iterS << ".hasNext())";
+ out << sb;
+ out << nl << "java.util.Map.Entry __e = (java.util.Map.Entry)" << "__i" << iterS << ".next();";
+ }
+ else
+ {
+ string keyObjectS = typeToObjectString(key, TypeModeIn, package);
+ string valueObjectS = typeToObjectString(value, TypeModeIn, package);
+ out << nl << "for(java.util.Map.Entry<" << keyObjectS << ", " << valueObjectS << "> __e : " << v
+ << ".entrySet())";
+ out << sb;
+ }
for(i = 0; i < 2; i++)
{
string val;
@@ -1014,74 +1014,74 @@ Slice::JavaGenerator::writeDictionaryMarshalUnmarshalCode(Output& out,
type = value;
}
- //
- // We have to downcast unless we're using Java5.
- //
- if(java2)
- {
- BuiltinPtr b = BuiltinPtr::dynamicCast(type);
- if(b)
- {
- switch(b->kind())
- {
- case Builtin::KindByte:
- {
- val = "((java.lang.Byte)" + arg + ").byteValue()";
- break;
- }
- case Builtin::KindBool:
- {
- val = "((java.lang.Boolean)" + arg + ").booleanValue()";
- break;
- }
- case Builtin::KindShort:
- {
- val = "((java.lang.Short)" + arg + ").shortValue()";
- break;
- }
- case Builtin::KindInt:
- {
- val = "((java.lang.Integer)" + arg + ").intValue()";
- break;
- }
- case Builtin::KindLong:
- {
- val = "((java.lang.Long)" + arg + ").longValue()";
- break;
- }
- case Builtin::KindFloat:
- {
- val = "((java.lang.Float)" + arg + ").floatValue()";
- break;
- }
- case Builtin::KindDouble:
- {
- val = "((java.lang.Double)" + arg + ").doubleValue()";
- break;
- }
- case Builtin::KindString:
- case Builtin::KindObject:
- case Builtin::KindObjectProxy:
- {
- break;
- }
- case Builtin::KindLocalObject:
- {
- assert(false);
- break;
- }
- }
- }
-
- if(val.empty())
- {
- val = "((" + typeToString(type, TypeModeIn, package) + ')' + arg + ')';
- }
- }
- else
- {
- val = arg;
- }
+ //
+ // We have to downcast unless we're using Java5.
+ //
+ if(java2)
+ {
+ BuiltinPtr b = BuiltinPtr::dynamicCast(type);
+ if(b)
+ {
+ switch(b->kind())
+ {
+ case Builtin::KindByte:
+ {
+ val = "((java.lang.Byte)" + arg + ").byteValue()";
+ break;
+ }
+ case Builtin::KindBool:
+ {
+ val = "((java.lang.Boolean)" + arg + ").booleanValue()";
+ break;
+ }
+ case Builtin::KindShort:
+ {
+ val = "((java.lang.Short)" + arg + ").shortValue()";
+ break;
+ }
+ case Builtin::KindInt:
+ {
+ val = "((java.lang.Integer)" + arg + ").intValue()";
+ break;
+ }
+ case Builtin::KindLong:
+ {
+ val = "((java.lang.Long)" + arg + ").longValue()";
+ break;
+ }
+ case Builtin::KindFloat:
+ {
+ val = "((java.lang.Float)" + arg + ").floatValue()";
+ break;
+ }
+ case Builtin::KindDouble:
+ {
+ val = "((java.lang.Double)" + arg + ").doubleValue()";
+ break;
+ }
+ case Builtin::KindString:
+ case Builtin::KindObject:
+ case Builtin::KindObjectProxy:
+ {
+ break;
+ }
+ case Builtin::KindLocalObject:
+ {
+ assert(false);
+ break;
+ }
+ }
+ }
+
+ if(val.empty())
+ {
+ val = "((" + typeToString(type, TypeModeIn, package) + ')' + arg + ')';
+ }
+ }
+ else
+ {
+ val = arg;
+ }
writeMarshalUnmarshalCode(out, package, type, val, true, iter, false);
}
out << eb;
@@ -1089,7 +1089,7 @@ Slice::JavaGenerator::writeDictionaryMarshalUnmarshalCode(Output& out,
}
else
{
- out << nl << v << " = new " << concreteType << "();";
+ out << nl << v << " = new " << concreteType << "();";
out << nl << "int __sz" << iterS << " = __is.readSize();";
out << nl << "for(int __i" << iterS << " = 0; __i" << iterS << " < __sz" << iterS << "; __i" << iterS << "++)";
out << sb;
@@ -1097,18 +1097,18 @@ Slice::JavaGenerator::writeDictionaryMarshalUnmarshalCode(Output& out,
{
string arg;
TypePtr type;
- string typeS;
+ string typeS;
if(i == 0)
{
arg = "__key";
type = key;
- typeS = keyS;
+ typeS = keyS;
}
else
{
arg = "__value";
type = value;
- typeS = valueS;
+ typeS = valueS;
}
BuiltinPtr b = BuiltinPtr::dynamicCast(type);
@@ -1118,37 +1118,37 @@ Slice::JavaGenerator::writeDictionaryMarshalUnmarshalCode(Output& out,
{
case Builtin::KindByte:
{
- out << nl << "java.lang.Byte " << arg << " = new java.lang.Byte(__is.readByte());";
+ out << nl << "java.lang.Byte " << arg << " = new java.lang.Byte(__is.readByte());";
break;
}
case Builtin::KindBool:
{
- out << nl << "java.lang.Boolean " << arg << " = new java.lang.Boolean(__is.readBool());";
+ out << nl << "java.lang.Boolean " << arg << " = new java.lang.Boolean(__is.readBool());";
break;
}
case Builtin::KindShort:
{
- out << nl << "java.lang.Short " << arg << " = new java.lang.Short(__is.readShort());";
+ out << nl << "java.lang.Short " << arg << " = new java.lang.Short(__is.readShort());";
break;
}
case Builtin::KindInt:
{
- out << nl << "java.lang.Integer " << arg << " = new java.lang.Integer(__is.readInt());";
+ out << nl << "java.lang.Integer " << arg << " = new java.lang.Integer(__is.readInt());";
break;
}
case Builtin::KindLong:
{
- out << nl << "java.lang.Long " << arg << " = new java.lang.Long(__is.readLong());";
+ out << nl << "java.lang.Long " << arg << " = new java.lang.Long(__is.readLong());";
break;
}
case Builtin::KindFloat:
{
- out << nl << "java.lang.Float " << arg << " = new java.lang.Float(__is.readFloat());";
+ out << nl << "java.lang.Float " << arg << " = new java.lang.Float(__is.readFloat());";
break;
}
case Builtin::KindDouble:
{
- out << nl << "java.lang.Double " << arg << " = new java.lang.Double(__is.readDouble());";
+ out << nl << "java.lang.Double " << arg << " = new java.lang.Double(__is.readDouble());";
break;
}
case Builtin::KindString:
@@ -1158,9 +1158,9 @@ Slice::JavaGenerator::writeDictionaryMarshalUnmarshalCode(Output& out,
}
case Builtin::KindObject:
{
- assert(i == 1); // Must be the element value, since an object cannot be a key.
+ assert(i == 1); // Must be the element value, since an object cannot be a key.
out << nl << "__is.readObject(new IceInternal.DictionaryPatcher(" << v << ", "
- << valueS << ".class, \"" << value->typeId() << "\", __key));";
+ << valueS << ".class, \"" << value->typeId() << "\", __key));";
break;
}
case Builtin::KindObjectProxy:
@@ -1177,24 +1177,24 @@ Slice::JavaGenerator::writeDictionaryMarshalUnmarshalCode(Output& out,
}
else
{
- if(ClassDeclPtr::dynamicCast(type) || (b && b->kind() == Builtin::KindObject))
- {
- writeMarshalUnmarshalCode(out, package, type, arg, false, iter, false, StringList(),
- "new IceInternal.DictionaryPatcher(" + v + ", " + typeS + ".class, \"" +
- type->typeId() + "\", __key)");
- }
- else
- {
- out << nl << typeS << ' ' << arg << ';';
- writeMarshalUnmarshalCode(out, package, type, arg, false, iter, false);
- }
- }
- }
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(value);
- if(!(builtin && builtin->kind() == Builtin::KindObject) && !ClassDeclPtr::dynamicCast(value))
- {
- out << nl << "" << v << ".put(__key, __value);";
- }
+ if(ClassDeclPtr::dynamicCast(type) || (b && b->kind() == Builtin::KindObject))
+ {
+ writeMarshalUnmarshalCode(out, package, type, arg, false, iter, false, StringList(),
+ "new IceInternal.DictionaryPatcher(" + v + ", " + typeS + ".class, \"" +
+ type->typeId() + "\", __key)");
+ }
+ else
+ {
+ out << nl << typeS << ' ' << arg << ';';
+ writeMarshalUnmarshalCode(out, package, type, arg, false, iter, false);
+ }
+ }
+ }
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(value);
+ if(!(builtin && builtin->kind() == Builtin::KindObject) && !ClassDeclPtr::dynamicCast(value))
+ {
+ out << nl << "" << v << ".put(__key, __value);";
+ }
out << eb;
}
}
@@ -1218,30 +1218,30 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
if(_featureProfile != Slice::IceE)
{
- java2 = seq->definitionContext()->findMetaData(_java2MetaData) == _java2MetaData;
-
- //
- // We have to determine whether it's possible to use the
- // type's generated helper class for this marshal/unmarshal
- // task. Since the user may have specified a custom type in
- // metadata, it's possible that the helper class is not
- // compatible and therefore we'll need to generate the code
- // in-line instead.
- //
- // Specifically, there may be "local" metadata (i.e., from
- // a data member or parameter definition) that overrides the
- // original type. We'll compare the mapped types with and
- // without local metadata to determine whether we can use
- // the helper.
- //
- string abstractType;
- customType = getSequenceTypes(seq, "", metaData, concreteType, abstractType);
- string origConcreteType, origAbstractType;
- getSequenceTypes(seq, "", StringList(), origConcreteType, origAbstractType);
- if((abstractType != origAbstractType) || (!marshal && concreteType != origConcreteType))
- {
- useHelper = false;
- }
+ java2 = seq->definitionContext()->findMetaData(_java2MetaData) == _java2MetaData;
+
+ //
+ // We have to determine whether it's possible to use the
+ // type's generated helper class for this marshal/unmarshal
+ // task. Since the user may have specified a custom type in
+ // metadata, it's possible that the helper class is not
+ // compatible and therefore we'll need to generate the code
+ // in-line instead.
+ //
+ // Specifically, there may be "local" metadata (i.e., from
+ // a data member or parameter definition) that overrides the
+ // original type. We'll compare the mapped types with and
+ // without local metadata to determine whether we can use
+ // the helper.
+ //
+ string abstractType;
+ customType = getSequenceTypes(seq, "", metaData, concreteType, abstractType);
+ string origConcreteType, origAbstractType;
+ getSequenceTypes(seq, "", StringList(), origConcreteType, origAbstractType);
+ if((abstractType != origAbstractType) || (!marshal && concreteType != origConcreteType))
+ {
+ useHelper = false;
+ }
}
//
@@ -1272,10 +1272,10 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
//
// Stop if the inner sequence type has a custom type.
//
- if(hasTypeMetaData(s) && _featureProfile != Slice::IceE)
- {
- break;
- }
+ if(hasTypeMetaData(s) && _featureProfile != Slice::IceE)
+ {
+ break;
+ }
depth++;
origContent = s->type();
s = SequencePtr::dynamicCast(origContent);
@@ -1301,12 +1301,12 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << nl << "else";
out << sb;
out << nl << stream << ".writeSize(" << v << ".size());";
- ostringstream o;
- o << "__i" << iter;
- string it = o.str();
- iter++;
- out << nl << "java.util.Iterator " << it << " = " << v << ".iterator();";
- out << nl << "while(" << it << ".hasNext())";
+ ostringstream o;
+ o << "__i" << iter;
+ string it = o.str();
+ iter++;
+ out << nl << "java.util.Iterator " << it << " = " << v << ".iterator();";
+ out << nl << "while(" << it << ".hasNext())";
out << sb;
switch(b->kind())
@@ -1484,14 +1484,14 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
else
{
string typeS = getAbsolute(seq, package);
- ostringstream o;
- o << origContentS;
- int d = depth;
- while(d--)
- {
- o << "[]";
- }
- string cont = o.str();
+ ostringstream o;
+ o << origContentS;
+ int d = depth;
+ while(d--)
+ {
+ o << "[]";
+ }
+ string cont = o.str();
if(marshal)
{
out << nl << "if(" << v << " == null)";
@@ -1501,47 +1501,47 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << nl << "else";
out << sb;
out << nl << stream << ".writeSize(" << v << ".size());";
- if(java2)
- {
- ostringstream oit;
- oit << "__i" << iter;
- iter++;
- string it = oit.str();
- out << nl << "java.util.Iterator " << it << " = " << v << ".iterator();";
- out << nl << "while(" << it << ".hasNext())";
- out << sb;
- out << nl << cont << " __elem = (" << cont << ")" << it << ".next();";
- writeMarshalUnmarshalCode(out, package, type, "__elem", true, iter, false);
- out << eb;
- }
- else
- {
- string typeS = typeToString(type, TypeModeIn, package);
- out << nl << "for(" << typeS << " __elem : " << v << ')';
- out << sb;
- writeMarshalUnmarshalCode(out, package, type, "__elem", true, iter, false);
- out << eb;
- }
+ if(java2)
+ {
+ ostringstream oit;
+ oit << "__i" << iter;
+ iter++;
+ string it = oit.str();
+ out << nl << "java.util.Iterator " << it << " = " << v << ".iterator();";
+ out << nl << "while(" << it << ".hasNext())";
+ out << sb;
+ out << nl << cont << " __elem = (" << cont << ")" << it << ".next();";
+ writeMarshalUnmarshalCode(out, package, type, "__elem", true, iter, false);
+ out << eb;
+ }
+ else
+ {
+ string typeS = typeToString(type, TypeModeIn, package);
+ out << nl << "for(" << typeS << " __elem : " << v << ')';
+ out << sb;
+ writeMarshalUnmarshalCode(out, package, type, "__elem", true, iter, false);
+ out << eb;
+ }
out << eb; // else
}
else
{
bool isObject = false;
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
- if((b && b->kind() == Builtin::KindObject) || cl)
+ if((b && b->kind() == Builtin::KindObject) || cl)
{
isObject = true;
}
- out << nl << v << " = new " << concreteType << "();";
+ out << nl << v << " = new " << concreteType << "();";
out << nl << "final int __len" << iter << " = " << stream << ".readSize();";
- if(type->isVariableLength())
- {
- out << nl << stream << ".startSeq(__len" << iter << ", " << type->minWireSize() << ");";
- }
- else
- {
- out << nl << stream << ".checkFixedSeq(__len" << iter << ", " << type->minWireSize() << ");";
- }
+ if(type->isVariableLength())
+ {
+ out << nl << stream << ".startSeq(__len" << iter << ", " << type->minWireSize() << ");";
+ }
+ else
+ {
+ out << nl << stream << ".checkFixedSeq(__len" << iter << ", " << type->minWireSize() << ");";
+ }
if(isObject)
{
if(b)
@@ -1565,54 +1565,54 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < __len" << iter << "; __i" << iter
<< "++)";
out << sb;
- if(isObject)
- {
+ if(isObject)
+ {
//
// Add a null value to the list as a placeholder for the element.
//
- out << nl << v << ".add(null);";
- ostringstream patchParams;
- patchParams << "new IceInternal.ListPatcher(" << v << ", " << origContentS << ".class, __type"
+ out << nl << v << ".add(null);";
+ ostringstream patchParams;
+ patchParams << "new IceInternal.ListPatcher(" << v << ", " << origContentS << ".class, __type"
<< iter << ", __i" << iter << ')';
- writeMarshalUnmarshalCode(out, package, type, "__elem", false, iter, false, StringList(),
- patchParams.str());
- }
- else
- {
- out << nl << cont << " __elem;";
- writeMarshalUnmarshalCode(out, package, type, "__elem", false, iter, false);
- }
- if(!isObject)
- {
- out << nl << v << ".add(__elem);";
- }
-
- //
- // After unmarshaling each element, check that there are still enough bytes left in the stream
- // to unmarshal the remainder of the sequence, and decrement the count of elements
- // yet to be unmarshaled for sequences with variable-length element type (that is, for sequences
- // of classes, structs, dictionaries, sequences, strings, or proxies). This allows us to
- // abort unmarshaling for bogus sequence sizes at the earliest possible moment.
- // (For fixed-length sequences, we don't need to do this because the prediction of how many
- // bytes will be taken up by the sequence is accurate.)
- //
- if(type->isVariableLength())
- {
- if(!SequencePtr::dynamicCast(type))
- {
- //
- // No need to check for directly nested sequences because, at the at start of each
- // sequence, we check anyway.
- //
- out << nl << stream << ".checkSeq();";
- }
- out << nl << stream << ".endElement();";
- }
- out << eb;
- if(type->isVariableLength())
- {
- out << nl << stream << ".endSeq(__len" << iter << ");";
- }
+ writeMarshalUnmarshalCode(out, package, type, "__elem", false, iter, false, StringList(),
+ patchParams.str());
+ }
+ else
+ {
+ out << nl << cont << " __elem;";
+ writeMarshalUnmarshalCode(out, package, type, "__elem", false, iter, false);
+ }
+ if(!isObject)
+ {
+ out << nl << v << ".add(__elem);";
+ }
+
+ //
+ // After unmarshaling each element, check that there are still enough bytes left in the stream
+ // to unmarshal the remainder of the sequence, and decrement the count of elements
+ // yet to be unmarshaled for sequences with variable-length element type (that is, for sequences
+ // of classes, structs, dictionaries, sequences, strings, or proxies). This allows us to
+ // abort unmarshaling for bogus sequence sizes at the earliest possible moment.
+ // (For fixed-length sequences, we don't need to do this because the prediction of how many
+ // bytes will be taken up by the sequence is accurate.)
+ //
+ if(type->isVariableLength())
+ {
+ if(!SequencePtr::dynamicCast(type))
+ {
+ //
+ // No need to check for directly nested sequences because, at the at start of each
+ // sequence, we check anyway.
+ //
+ out << nl << stream << ".checkSeq();";
+ }
+ out << nl << stream << ".endElement();";
+ }
+ out << eb;
+ if(type->isVariableLength())
+ {
+ out << nl << stream << ".endSeq(__len" << iter << ");";
+ }
iter++;
}
}
@@ -1754,19 +1754,19 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
{
bool isObject = false;
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(origContent);
- if((b && b->kind() == Builtin::KindObject) || cl)
+ if((b && b->kind() == Builtin::KindObject) || cl)
{
isObject = true;
}
out << nl << "final int __len" << iter << " = " << stream << ".readSize();";
- if(type->isVariableLength())
- {
- out << nl << stream << ".startSeq(__len" << iter << ", " << type->minWireSize() << ");";
- }
- else
- {
- out << nl << stream << ".checkFixedSeq(__len" << iter << ", " << type->minWireSize() << ");";
- }
+ if(type->isVariableLength())
+ {
+ out << nl << stream << ".startSeq(__len" << iter << ", " << type->minWireSize() << ");";
+ }
+ else
+ {
+ out << nl << stream << ".checkFixedSeq(__len" << iter << ", " << type->minWireSize() << ");";
+ }
if(isObject)
{
if(b)
@@ -1799,45 +1799,45 @@ Slice::JavaGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << sb;
ostringstream o;
o << v << "[__i" << iter << "]";
- ostringstream patchParams;
+ ostringstream patchParams;
if(isObject)
{
patchParams << "new IceInternal.SequencePatcher(" << v << ", " << origContentS
<< ".class, __type" << iter << ", __i" << iter << ')';
writeMarshalUnmarshalCode(out, package, type, o.str(), false, iter, false, StringList(),
- patchParams.str());
+ patchParams.str());
}
else
{
writeMarshalUnmarshalCode(out, package, type, o.str(), false, iter, false);
}
- //
- // After unmarshaling each element, check that there are still enough bytes left in the stream
- // to unmarshal the remainder of the sequence, and decrement the count of elements
- // yet to be unmarshaled for sequences with variable-length element type (that is, for sequences
- // of classes, structs, dictionaries, sequences, strings, or proxies). This allows us to
- // abort unmarshaling for bogus sequence sizes at the earliest possible moment.
- // (For fixed-length sequences, we don't need to do this because the prediction of how many
- // bytes will be taken up by the sequence is accurate.)
- //
- if(type->isVariableLength())
- {
- if(!SequencePtr::dynamicCast(type))
- {
- //
- // No need to check for directly nested sequences because, at the at start of each
- // sequence, we check anyway.
- //
- out << nl << stream << ".checkSeq();";
- }
- out << nl << stream << ".endElement();";
- }
+ //
+ // After unmarshaling each element, check that there are still enough bytes left in the stream
+ // to unmarshal the remainder of the sequence, and decrement the count of elements
+ // yet to be unmarshaled for sequences with variable-length element type (that is, for sequences
+ // of classes, structs, dictionaries, sequences, strings, or proxies). This allows us to
+ // abort unmarshaling for bogus sequence sizes at the earliest possible moment.
+ // (For fixed-length sequences, we don't need to do this because the prediction of how many
+ // bytes will be taken up by the sequence is accurate.)
+ //
+ if(type->isVariableLength())
+ {
+ if(!SequencePtr::dynamicCast(type))
+ {
+ //
+ // No need to check for directly nested sequences because, at the at start of each
+ // sequence, we check anyway.
+ //
+ out << nl << stream << ".checkSeq();";
+ }
+ out << nl << stream << ".endElement();";
+ }
out << eb;
- if(type->isVariableLength())
- {
- out << nl << stream << ".endSeq(__len" << iter << ");";
- }
+ if(type->isVariableLength())
+ {
+ out << nl << stream << ".endSeq(__len" << iter << ");";
+ }
iter++;
}
}
@@ -1969,31 +1969,31 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out,
}
case Builtin::KindObject:
{
- if(_featureProfile != Slice::IceE)
- {
- if(marshal)
- {
- out << nl << stream << ".writeObject(" << v << ");";
- }
- else
- {
- if(holder)
- {
- out << nl << stream << ".readObject((Ice.ReadObjectCallback)" << param << ".getPatcher());";
- }
- else
- {
- if(patchParams.empty())
- {
- out << nl << stream << ".readObject(new Patcher());";
- }
- else
- {
- out << nl << stream << ".readObject(" << patchParams << ");";
- }
- }
- }
- }
+ if(_featureProfile != Slice::IceE)
+ {
+ if(marshal)
+ {
+ out << nl << stream << ".writeObject(" << v << ");";
+ }
+ else
+ {
+ if(holder)
+ {
+ out << nl << stream << ".readObject((Ice.ReadObjectCallback)" << param << ".getPatcher());";
+ }
+ else
+ {
+ if(patchParams.empty())
+ {
+ out << nl << stream << ".readObject(new Patcher());";
+ }
+ else
+ {
+ out << nl << stream << ".readObject(" << patchParams << ");";
+ }
+ }
+ }
+ }
break;
}
case Builtin::KindObjectProxy:
@@ -2035,32 +2035,32 @@ Slice::JavaGenerator::writeStreamMarshalUnmarshalCode(Output& out,
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
if(cl)
{
- if(_featureProfile != Slice::IceE)
- {
- if(marshal)
- {
- out << nl << stream << ".writeObject(" << v << ");";
- }
- else
- {
- string typeS = typeToString(type, TypeModeIn, package);
- if(holder)
- {
- out << nl << stream << ".readObject(" << param << ".getPatcher());";
- }
- else
- {
- if(patchParams.empty())
- {
- out << nl << stream << ".readObject(new Patcher());";
- }
- else
- {
- out << nl << stream << ".readObject(" << patchParams << ");";
- }
- }
- }
- }
+ if(_featureProfile != Slice::IceE)
+ {
+ if(marshal)
+ {
+ out << nl << stream << ".writeObject(" << v << ");";
+ }
+ else
+ {
+ string typeS = typeToString(type, TypeModeIn, package);
+ if(holder)
+ {
+ out << nl << stream << ".readObject(" << param << ".getPatcher());";
+ }
+ else
+ {
+ if(patchParams.empty())
+ {
+ out << nl << stream << ".readObject(new Patcher());";
+ }
+ else
+ {
+ out << nl << stream << ".readObject(" << patchParams << ");";
+ }
+ }
+ }
+ }
return;
}
@@ -2157,7 +2157,7 @@ Slice::JavaGenerator::writeStreamDictionaryMarshalUnmarshalCode(Output& out,
getDictionaryTypes(dict, "", StringList(), origConcreteType, origAbstractType);
if((abstractType != origAbstractType) || (!marshal && concreteType != origConcreteType))
{
- useHelper = false;
+ useHelper = false;
}
//
@@ -2165,16 +2165,16 @@ Slice::JavaGenerator::writeStreamDictionaryMarshalUnmarshalCode(Output& out,
//
if(useHelper)
{
- string typeS = getAbsolute(dict, package);
- if(marshal)
- {
- out << nl << typeS << "Helper.write(" << stream << ", " << v << ");";
- }
- else
- {
- out << nl << v << " = " << typeS << "Helper.read(" << stream << ");";
- }
- return;
+ string typeS = getAbsolute(dict, package);
+ if(marshal)
+ {
+ out << nl << typeS << "Helper.write(" << stream << ", " << v << ");";
+ }
+ else
+ {
+ out << nl << v << " = " << typeS << "Helper.read(" << stream << ");";
+ }
+ return;
}
TypePtr key = dict->keyType();
@@ -2198,21 +2198,21 @@ Slice::JavaGenerator::writeStreamDictionaryMarshalUnmarshalCode(Output& out,
out << nl << "else";
out << sb;
out << nl << "__outS.writeSize(" << v << ".size());";
- if(java2)
- {
- out << nl << "java.util.Iterator __i" << iterS << " = " << v << ".entrySet().iterator();";
- out << nl << "while(__i" << iterS << ".hasNext())";
- out << sb;
- out << nl << "java.util.Map.Entry __e = (java.util.Map.Entry)" << "__i" << iterS << ".next();";
- }
- else
- {
- string keyObjectS = typeToObjectString(key, TypeModeIn, package);
- string valueObjectS = typeToObjectString(value, TypeModeIn, package);
- out << nl << "for(java.util.Map.Entry<" << keyObjectS << ", " << valueObjectS << "> __e : " << v
- << ".entrySet())";
- out << sb;
- }
+ if(java2)
+ {
+ out << nl << "java.util.Iterator __i" << iterS << " = " << v << ".entrySet().iterator();";
+ out << nl << "while(__i" << iterS << ".hasNext())";
+ out << sb;
+ out << nl << "java.util.Map.Entry __e = (java.util.Map.Entry)" << "__i" << iterS << ".next();";
+ }
+ else
+ {
+ string keyObjectS = typeToObjectString(key, TypeModeIn, package);
+ string valueObjectS = typeToObjectString(value, TypeModeIn, package);
+ out << nl << "for(java.util.Map.Entry<" << keyObjectS << ", " << valueObjectS << "> __e : " << v
+ << ".entrySet())";
+ out << sb;
+ }
for(i = 0; i < 2; i++)
{
string val;
@@ -2229,74 +2229,74 @@ Slice::JavaGenerator::writeStreamDictionaryMarshalUnmarshalCode(Output& out,
type = value;
}
- //
- // We have to downcast unless we're using Java5.
- //
- if(java2)
- {
- BuiltinPtr b = BuiltinPtr::dynamicCast(type);
- if(b)
- {
- switch(b->kind())
- {
- case Builtin::KindByte:
- {
- val = "((java.lang.Byte)" + arg + ").byteValue()";
- break;
- }
- case Builtin::KindBool:
- {
- val = "((java.lang.Boolean)" + arg + ").booleanValue()";
- break;
- }
- case Builtin::KindShort:
- {
- val = "((java.lang.Short)" + arg + ").shortValue()";
- break;
- }
- case Builtin::KindInt:
- {
- val = "((java.lang.Integer)" + arg + ").intValue()";
- break;
- }
- case Builtin::KindLong:
- {
- val = "((java.lang.Long)" + arg + ").longValue()";
- break;
- }
- case Builtin::KindFloat:
- {
- val = "((java.lang.Float)" + arg + ").floatValue()";
- break;
- }
- case Builtin::KindDouble:
- {
- val = "((java.lang.Double)" + arg + ").doubleValue()";
- break;
- }
- case Builtin::KindString:
- case Builtin::KindObject:
- case Builtin::KindObjectProxy:
- {
- break;
- }
- case Builtin::KindLocalObject:
- {
- assert(false);
- break;
- }
- }
- }
-
- if(val.empty())
- {
- val = "((" + typeToString(type, TypeModeIn, package) + ')' + arg + ')';
- }
- }
- else
- {
- val = arg;
- }
+ //
+ // We have to downcast unless we're using Java5.
+ //
+ if(java2)
+ {
+ BuiltinPtr b = BuiltinPtr::dynamicCast(type);
+ if(b)
+ {
+ switch(b->kind())
+ {
+ case Builtin::KindByte:
+ {
+ val = "((java.lang.Byte)" + arg + ").byteValue()";
+ break;
+ }
+ case Builtin::KindBool:
+ {
+ val = "((java.lang.Boolean)" + arg + ").booleanValue()";
+ break;
+ }
+ case Builtin::KindShort:
+ {
+ val = "((java.lang.Short)" + arg + ").shortValue()";
+ break;
+ }
+ case Builtin::KindInt:
+ {
+ val = "((java.lang.Integer)" + arg + ").intValue()";
+ break;
+ }
+ case Builtin::KindLong:
+ {
+ val = "((java.lang.Long)" + arg + ").longValue()";
+ break;
+ }
+ case Builtin::KindFloat:
+ {
+ val = "((java.lang.Float)" + arg + ").floatValue()";
+ break;
+ }
+ case Builtin::KindDouble:
+ {
+ val = "((java.lang.Double)" + arg + ").doubleValue()";
+ break;
+ }
+ case Builtin::KindString:
+ case Builtin::KindObject:
+ case Builtin::KindObjectProxy:
+ {
+ break;
+ }
+ case Builtin::KindLocalObject:
+ {
+ assert(false);
+ break;
+ }
+ }
+ }
+
+ if(val.empty())
+ {
+ val = "((" + typeToString(type, TypeModeIn, package) + ')' + arg + ')';
+ }
+ }
+ else
+ {
+ val = arg;
+ }
writeStreamMarshalUnmarshalCode(out, package, type, val, true, iter, false);
}
out << eb;
@@ -2304,7 +2304,7 @@ Slice::JavaGenerator::writeStreamDictionaryMarshalUnmarshalCode(Output& out,
}
else
{
- out << nl << v << " = new " << concreteType << "();";
+ out << nl << v << " = new " << concreteType << "();";
out << nl << "int __sz" << iterS << " = __inS.readSize();";
out << nl << "for(int __i" << iterS << " = 0; __i" << iterS << " < __sz" << iterS << "; __i" << iterS << "++)";
out << sb;
@@ -2312,18 +2312,18 @@ Slice::JavaGenerator::writeStreamDictionaryMarshalUnmarshalCode(Output& out,
{
string arg;
TypePtr type;
- string typeS;
+ string typeS;
if(i == 0)
{
arg = "__key";
type = key;
- typeS = keyS;
+ typeS = keyS;
}
else
{
arg = "__value";
type = value;
- typeS = valueS;
+ typeS = valueS;
}
BuiltinPtr b = BuiltinPtr::dynamicCast(type);
@@ -2374,7 +2374,7 @@ Slice::JavaGenerator::writeStreamDictionaryMarshalUnmarshalCode(Output& out,
case Builtin::KindObject:
{
out << nl << "__inS.readObject(new IceInternal.DictionaryPatcher(" << v << ", "
- << valueS << ".class, \"" << value->typeId() << "\", __key));";
+ << valueS << ".class, \"" << value->typeId() << "\", __key));";
break;
}
case Builtin::KindObjectProxy:
@@ -2392,11 +2392,11 @@ Slice::JavaGenerator::writeStreamDictionaryMarshalUnmarshalCode(Output& out,
else
{
string s = typeToString(type, TypeModeIn, package);
- if(ClassDeclPtr::dynamicCast(type) || (b && b->kind() == Builtin::KindObject))
+ if(ClassDeclPtr::dynamicCast(type) || (b && b->kind() == Builtin::KindObject))
{
writeStreamMarshalUnmarshalCode(out, package, type, arg, false, iter, false, StringList(),
"new IceInternal.DictionaryPatcher(" + v + ", " + s +
- ".class, \"" + type->typeId() + "\", __key)");
+ ".class, \"" + type->typeId() + "\", __key)");
}
else
{
@@ -2405,7 +2405,7 @@ Slice::JavaGenerator::writeStreamDictionaryMarshalUnmarshalCode(Output& out,
}
}
}
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(value);
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(value);
if(!(builtin && builtin->kind() == Builtin::KindObject) && !ClassDeclPtr::dynamicCast(value))
{
out << nl << "" << v << ".put(__key, __value);";
@@ -2449,7 +2449,7 @@ Slice::JavaGenerator::writeStreamSequenceMarshalUnmarshalCode(Output& out,
getSequenceTypes(seq, "", StringList(), origConcreteType, origAbstractType);
if((abstractType != origAbstractType) || (!marshal && concreteType != origConcreteType))
{
- useHelper = false;
+ useHelper = false;
}
//
@@ -2480,10 +2480,10 @@ Slice::JavaGenerator::writeStreamSequenceMarshalUnmarshalCode(Output& out,
//
// Stop if the inner sequence type has a custom type.
//
- if(hasTypeMetaData(s))
- {
- break;
- }
+ if(hasTypeMetaData(s))
+ {
+ break;
+ }
depth++;
origContent = s->type();
s = SequencePtr::dynamicCast(origContent);
@@ -2692,14 +2692,14 @@ Slice::JavaGenerator::writeStreamSequenceMarshalUnmarshalCode(Output& out,
else
{
string typeS = getAbsolute(seq, package);
- ostringstream o;
- o << origContentS;
- int d = depth;
- while(d--)
- {
- o << "[]";
- }
- string cont = o.str();
+ ostringstream o;
+ o << origContentS;
+ int d = depth;
+ while(d--)
+ {
+ o << "[]";
+ }
+ string cont = o.str();
if(marshal)
{
out << nl << "if(" << v << " == null)";
@@ -2709,27 +2709,27 @@ Slice::JavaGenerator::writeStreamSequenceMarshalUnmarshalCode(Output& out,
out << nl << "else";
out << sb;
out << nl << stream << ".writeSize(" << v << ".size());";
- if(java2)
- {
- ostringstream oit;
- oit << "__i" << iter;
- iter++;
- string it = oit.str();
- out << nl << "java.util.Iterator " << it << " = " << v << ".iterator();";
- out << nl << "while(" << it << ".hasNext())";
- out << sb;
- out << nl << cont << " __elem = (" << cont << ")" << it << ".next();";
- writeStreamMarshalUnmarshalCode(out, package, type, "__elem", true, iter, false);
- out << eb;
- }
- else
- {
- string typeS = typeToString(type, TypeModeIn, package);
- out << nl << "for(" << typeS << " __elem : " << v << ')';
- out << sb;
- writeStreamMarshalUnmarshalCode(out, package, type, "__elem", true, iter, false);
- out << eb;
- }
+ if(java2)
+ {
+ ostringstream oit;
+ oit << "__i" << iter;
+ iter++;
+ string it = oit.str();
+ out << nl << "java.util.Iterator " << it << " = " << v << ".iterator();";
+ out << nl << "while(" << it << ".hasNext())";
+ out << sb;
+ out << nl << cont << " __elem = (" << cont << ")" << it << ".next();";
+ writeStreamMarshalUnmarshalCode(out, package, type, "__elem", true, iter, false);
+ out << eb;
+ }
+ else
+ {
+ string typeS = typeToString(type, TypeModeIn, package);
+ out << nl << "for(" << typeS << " __elem : " << v << ')';
+ out << sb;
+ writeStreamMarshalUnmarshalCode(out, package, type, "__elem", true, iter, false);
+ out << eb;
+ }
out << eb; // else
}
else
@@ -2994,22 +2994,22 @@ Slice::JavaGenerator::getTypeMetaData(const StringList& metaData, string& concre
static const string prefix = "java:type:";
for(StringList::const_iterator q = metaData.begin(); q != metaData.end(); ++q)
{
- string str = *q;
- if(str.find(prefix) == 0)
- {
- string::size_type pos = str.find(':', prefix.size());
- if(pos != string::npos)
- {
- concreteType = str.substr(prefix.size(), pos - prefix.size());
- abstractType = str.substr(pos + 1);
- }
- else
- {
- concreteType = str.substr(prefix.size());
- abstractType.clear();
- }
- return true;
- }
+ string str = *q;
+ if(str.find(prefix) == 0)
+ {
+ string::size_type pos = str.find(':', prefix.size());
+ if(pos != string::npos)
+ {
+ concreteType = str.substr(prefix.size(), pos - prefix.size());
+ abstractType = str.substr(pos + 1);
+ }
+ else
+ {
+ concreteType = str.substr(prefix.size());
+ abstractType.clear();
+ }
+ return true;
+ }
}
return false;
@@ -3021,27 +3021,27 @@ Slice::JavaGenerator::hasTypeMetaData(const TypePtr& type, const StringList& loc
ContainedPtr cont = ContainedPtr::dynamicCast(type);
if(cont)
{
- static const string prefix = "java:type:";
-
- StringList::const_iterator q;
- for(q = localMetaData.begin(); q != localMetaData.end(); ++q)
- {
- string str = *q;
- if(str.find(prefix) == 0)
- {
- return true;
- }
- }
-
- StringList metaData = cont->getMetaData();
- for(q = metaData.begin(); q != metaData.end(); ++q)
- {
- string str = *q;
- if(str.find(prefix) == 0)
- {
- return true;
- }
- }
+ static const string prefix = "java:type:";
+
+ StringList::const_iterator q;
+ for(q = localMetaData.begin(); q != localMetaData.end(); ++q)
+ {
+ string str = *q;
+ if(str.find(prefix) == 0)
+ {
+ return true;
+ }
+ }
+
+ StringList metaData = cont->getMetaData();
+ for(q = metaData.begin(); q != metaData.end(); ++q)
+ {
+ string str = *q;
+ if(str.find(prefix) == 0)
+ {
+ return true;
+ }
+ }
}
return false;
@@ -3049,17 +3049,17 @@ Slice::JavaGenerator::hasTypeMetaData(const TypePtr& type, const StringList& loc
bool
Slice::JavaGenerator::getDictionaryTypes(const DictionaryPtr& dict,
- const string& package,
- const StringList& metaData,
- string& concreteType,
- string& abstractType) const
+ const string& package,
+ const StringList& metaData,
+ string& concreteType,
+ string& abstractType) const
{
bool customType = false;
if(_featureProfile == Slice::IceE)
{
- concreteType = abstractType = "java.util.Hashtable";
- return customType;
+ concreteType = abstractType = "java.util.Hashtable";
+ return customType;
}
bool java2 = dict->definitionContext()->findMetaData(_java2MetaData) == _java2MetaData;
@@ -3071,7 +3071,7 @@ Slice::JavaGenerator::getDictionaryTypes(const DictionaryPtr& dict,
customType = getTypeMetaData(metaData, ct, at);
if(!customType)
{
- customType = getTypeMetaData(dict->getMetaData(), ct, at);
+ customType = getTypeMetaData(dict->getMetaData(), ct, at);
}
//
@@ -3081,8 +3081,8 @@ Slice::JavaGenerator::getDictionaryTypes(const DictionaryPtr& dict,
string valueTypeStr;
if(!java2)
{
- keyTypeStr = typeToObjectString(dict->keyType(), TypeModeIn, package);
- valueTypeStr = typeToObjectString(dict->valueType(), TypeModeIn, package);
+ keyTypeStr = typeToObjectString(dict->keyType(), TypeModeIn, package);
+ valueTypeStr = typeToObjectString(dict->valueType(), TypeModeIn, package);
}
//
@@ -3090,47 +3090,47 @@ Slice::JavaGenerator::getDictionaryTypes(const DictionaryPtr& dict,
//
if(customType)
{
- assert(!ct.empty());
-
- //
- // Check for portable syntax. Convert {type} to type<key, value> for Java5.
- //
- if(ct[0] == '{')
- {
- string::size_type pos = ct.find('}');
- if(pos != string::npos)
- {
- concreteType = ct.substr(1, pos - 1);
- if(!java2)
- {
- concreteType += "<" + keyTypeStr + ", " + valueTypeStr + ">";
- }
- }
- }
- else
- {
- concreteType = ct;
- }
-
- if(!at.empty())
- {
- if(at[0] == '{')
- {
- string::size_type pos = at.find('}');
- if(pos != string::npos)
- {
- abstractType = at.substr(1, pos - 1);
- if(!java2)
- {
- abstractType += "<" + keyTypeStr + ", " + valueTypeStr + ">";
- }
- }
- }
- else
- {
- abstractType = at;
- }
- }
+ assert(!ct.empty());
+
+ //
+ // Check for portable syntax. Convert {type} to type<key, value> for Java5.
+ //
+ if(ct[0] == '{')
+ {
+ string::size_type pos = ct.find('}');
+ if(pos != string::npos)
+ {
+ concreteType = ct.substr(1, pos - 1);
+ if(!java2)
+ {
+ concreteType += "<" + keyTypeStr + ", " + valueTypeStr + ">";
+ }
+ }
+ }
+ else
+ {
+ concreteType = ct;
+ }
+
+ if(!at.empty())
+ {
+ if(at[0] == '{')
+ {
+ string::size_type pos = at.find('}');
+ if(pos != string::npos)
+ {
+ abstractType = at.substr(1, pos - 1);
+ if(!java2)
+ {
+ abstractType += "<" + keyTypeStr + ", " + valueTypeStr + ">";
+ }
+ }
+ }
+ else
+ {
+ abstractType = at;
+ }
+ }
}
//
@@ -3138,11 +3138,11 @@ Slice::JavaGenerator::getDictionaryTypes(const DictionaryPtr& dict,
//
if(concreteType.empty())
{
- concreteType = "java.util.HashMap";
- if(!java2)
- {
- concreteType += "<" + keyTypeStr + ", " + valueTypeStr + ">";
- }
+ concreteType = "java.util.HashMap";
+ if(!java2)
+ {
+ concreteType += "<" + keyTypeStr + ", " + valueTypeStr + ">";
+ }
}
//
@@ -3154,11 +3154,11 @@ Slice::JavaGenerator::getDictionaryTypes(const DictionaryPtr& dict,
//
if(abstractType.empty())
{
- abstractType = "java.util.Map";
- if(!java2)
- {
- abstractType += "<" + keyTypeStr + ", " + valueTypeStr + ">";
- }
+ abstractType = "java.util.Map";
+ if(!java2)
+ {
+ abstractType += "<" + keyTypeStr + ", " + valueTypeStr + ">";
+ }
}
return customType;
@@ -3166,17 +3166,17 @@ Slice::JavaGenerator::getDictionaryTypes(const DictionaryPtr& dict,
bool
Slice::JavaGenerator::getSequenceTypes(const SequencePtr& seq,
- const string& package,
- const StringList& metaData,
- string& concreteType,
- string& abstractType) const
+ const string& package,
+ const StringList& metaData,
+ string& concreteType,
+ string& abstractType) const
{
bool customType = false;
if(_featureProfile == Slice::IceE)
{
- concreteType = abstractType = typeToString(seq->type(), TypeModeIn, package) + "[]";
- return customType;
+ concreteType = abstractType = typeToString(seq->type(), TypeModeIn, package) + "[]";
+ return customType;
}
bool java2 = seq->definitionContext()->findMetaData(_java2MetaData) == _java2MetaData;
@@ -3188,7 +3188,7 @@ Slice::JavaGenerator::getSequenceTypes(const SequencePtr& seq,
customType = getTypeMetaData(metaData, ct, at);
if(!customType)
{
- customType = getTypeMetaData(seq->getMetaData(), ct, at);
+ customType = getTypeMetaData(seq->getMetaData(), ct, at);
}
//
@@ -3197,7 +3197,7 @@ Slice::JavaGenerator::getSequenceTypes(const SequencePtr& seq,
string typeStr;
if(!java2)
{
- typeStr = typeToObjectString(seq->type(), TypeModeIn, package);
+ typeStr = typeToObjectString(seq->type(), TypeModeIn, package);
}
//
@@ -3205,62 +3205,62 @@ Slice::JavaGenerator::getSequenceTypes(const SequencePtr& seq,
//
if(customType)
{
- assert(!ct.empty());
-
- //
- // Check for portable syntax. Convert {type} to type<key, value> for Java5.
- //
- if(ct[0] == '{')
- {
- string::size_type pos = ct.find('}');
- if(pos != string::npos)
- {
- concreteType = ct.substr(1, pos - 1);
- if(!java2)
- {
- concreteType += "<" + typeStr + ">";
- }
- }
- }
- else
- {
- concreteType = ct;
- }
-
- if(!at.empty())
- {
- if(at[0] == '{')
- {
- string::size_type pos = at.find('}');
- if(pos != string::npos)
- {
- abstractType = at.substr(1, pos - 1);
- if(!java2)
- {
- abstractType += "<" + typeStr + ">";
- }
- }
- }
- else
- {
- abstractType = at;
- }
- }
- else
- {
- //
- // If an abstract type is not defined, we use the concrete type as the default.
- // If instead we chose a default abstract type, such as List<T>, then we
- // might inadvertently generate uncompilable code. The Java5 compiler does not
- // allow polymorphic assignment between generic types if it can weaken the
- // compile-time type safety rules.
- //
- abstractType = "java.util.List";
- if(!java2)
- {
- abstractType += "<" + typeStr + ">";
- }
- }
+ assert(!ct.empty());
+
+ //
+ // Check for portable syntax. Convert {type} to type<key, value> for Java5.
+ //
+ if(ct[0] == '{')
+ {
+ string::size_type pos = ct.find('}');
+ if(pos != string::npos)
+ {
+ concreteType = ct.substr(1, pos - 1);
+ if(!java2)
+ {
+ concreteType += "<" + typeStr + ">";
+ }
+ }
+ }
+ else
+ {
+ concreteType = ct;
+ }
+
+ if(!at.empty())
+ {
+ if(at[0] == '{')
+ {
+ string::size_type pos = at.find('}');
+ if(pos != string::npos)
+ {
+ abstractType = at.substr(1, pos - 1);
+ if(!java2)
+ {
+ abstractType += "<" + typeStr + ">";
+ }
+ }
+ }
+ else
+ {
+ abstractType = at;
+ }
+ }
+ else
+ {
+ //
+ // If an abstract type is not defined, we use the concrete type as the default.
+ // If instead we chose a default abstract type, such as List<T>, then we
+ // might inadvertently generate uncompilable code. The Java5 compiler does not
+ // allow polymorphic assignment between generic types if it can weaken the
+ // compile-time type safety rules.
+ //
+ abstractType = "java.util.List";
+ if(!java2)
+ {
+ abstractType += "<" + typeStr + ">";
+ }
+ }
}
//
@@ -3268,7 +3268,7 @@ Slice::JavaGenerator::getSequenceTypes(const SequencePtr& seq,
//
if(concreteType.empty())
{
- concreteType = abstractType = typeToString(seq->type(), TypeModeIn, package) + "[]";
+ concreteType = abstractType = typeToString(seq->type(), TypeModeIn, package) + "[]";
}
return customType;
@@ -3305,26 +3305,26 @@ Slice::JavaGenerator::MetaDataVisitor::visitModuleStart(const ModulePtr& p)
{
if(s.find(prefix) == 0)
{
- bool ok = false;
-
- static const string packagePrefix = "java:package:";
- if(s.find(packagePrefix) == 0 && s.size() > packagePrefix.size())
- {
- ok = true;
- }
- else if(s == _java2MetaData)
- {
- ok = true;
- }
- else if(s == _java5MetaData)
- {
- ok = true;
- }
-
- if(!ok)
- {
- cout << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl;
- }
+ bool ok = false;
+
+ static const string packagePrefix = "java:package:";
+ if(s.find(packagePrefix) == 0 && s.size() > packagePrefix.size())
+ {
+ ok = true;
+ }
+ else if(s == _java2MetaData)
+ {
+ ok = true;
+ }
+ else if(s == _java5MetaData)
+ {
+ ok = true;
+ }
+
+ if(!ok)
+ {
+ cout << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl;
+ }
}
_history.insert(s);
}
@@ -3378,29 +3378,29 @@ Slice::JavaGenerator::MetaDataVisitor::visitOperation(const OperationPtr& p)
TypePtr returnType = p->returnType();
if(!metaData.empty())
{
- if(!returnType)
- {
- for(StringList::const_iterator q = metaData.begin(); q != metaData.end(); ++q)
- {
- if(q->find("java:type:", 0) == 0)
- {
- cout << p->definitionContext()->filename() << ":" << p->line()
- << ": warning: invalid metadata for operation" << endl;
- break;
- }
- }
- }
- else
- {
- validateType(returnType, metaData, p->definitionContext()->filename(), p->line());
- }
+ if(!returnType)
+ {
+ for(StringList::const_iterator q = metaData.begin(); q != metaData.end(); ++q)
+ {
+ if(q->find("java:type:", 0) == 0)
+ {
+ cout << p->definitionContext()->filename() << ":" << p->line()
+ << ": warning: invalid metadata for operation" << endl;
+ break;
+ }
+ }
+ }
+ else
+ {
+ validateType(returnType, metaData, p->definitionContext()->filename(), p->line());
+ }
}
ParamDeclList params = p->parameters();
for(ParamDeclList::iterator q = params.begin(); q != params.end(); ++q)
{
- metaData = getMetaData(*q);
- validateType((*q)->type(), metaData, p->definitionContext()->filename(), (*q)->line());
+ metaData = getMetaData(*q);
+ validateType((*q)->type(), metaData, p->definitionContext()->filename(), (*q)->line());
}
validateGetSet(p, metaData, p->definitionContext()->filename(), p->line());
@@ -3430,18 +3430,18 @@ Slice::JavaGenerator::MetaDataVisitor::visitSequence(const SequencePtr& p)
//
if(p->definitionContext()->findMetaData(_java2MetaData) != _java2MetaData && !hasTypeMetaData(p))
{
- SequencePtr innerSeq = SequencePtr::dynamicCast(p->type());
- DictionaryPtr innerDict = DictionaryPtr::dynamicCast(p->type());
- if((innerSeq && hasTypeMetaData(innerSeq)) || (innerDict && hasTypeMetaData(innerDict)))
- {
- string file = p->file();
- string line = p->line();
- if(!file.empty())
- {
- cout << file << ':' << line << ": ";
- }
- cout << "warning: Java5 forbids arrays of generic types";
- }
+ SequencePtr innerSeq = SequencePtr::dynamicCast(p->type());
+ DictionaryPtr innerDict = DictionaryPtr::dynamicCast(p->type());
+ if((innerSeq && hasTypeMetaData(innerSeq)) || (innerDict && hasTypeMetaData(innerDict)))
+ {
+ string file = p->file();
+ string line = p->line();
+ if(!file.empty())
+ {
+ cout << file << ':' << line << ": ";
+ }
+ cout << "warning: Java5 forbids arrays of generic types";
+ }
}
}
@@ -3490,23 +3490,23 @@ Slice::JavaGenerator::MetaDataVisitor::getMetaData(const ContainedPtr& cont)
string::size_type pos = s.find(':', prefix.size());
if(pos == string::npos)
{
- if(s.size() > prefix.size())
- {
- string rest = s.substr(prefix.size());
- if(rest == "getset")
- {
- result.push_back(s);
- }
- continue;
- }
+ if(s.size() > prefix.size())
+ {
+ string rest = s.substr(prefix.size());
+ if(rest == "getset")
+ {
+ result.push_back(s);
+ }
+ continue;
+ }
}
else if(s.substr(prefix.size(), pos - prefix.size()) == "type")
{
- result.push_back(s);
- continue;
+ result.push_back(s);
+ continue;
}
- cout << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl;
+ cout << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl;
}
_history.insert(s);
@@ -3518,58 +3518,58 @@ Slice::JavaGenerator::MetaDataVisitor::getMetaData(const ContainedPtr& cont)
void
Slice::JavaGenerator::MetaDataVisitor::validateType(const SyntaxTreeBasePtr& p, const StringList& metaData,
- const string& file, const string& line)
+ const string& file, const string& line)
{
for(StringList::const_iterator i = metaData.begin(); i != metaData.end(); ++i)
{
- //
- // Type metadata ("java:type:Foo") is only supported by sequences and dictionaries.
- //
- if(i->find("java:type:", 0) == 0 && (!SequencePtr::dynamicCast(p) && !DictionaryPtr::dynamicCast(p)))
- {
- string str;
- ContainedPtr cont = ContainedPtr::dynamicCast(p);
- if(cont)
- {
- str = cont->kindOf();
- }
- else
- {
- BuiltinPtr b = BuiltinPtr::dynamicCast(p);
- assert(b);
- str = b->typeId();
- }
- cout << file << ":" << line << ": warning: invalid metadata for " << str << endl;
- }
+ //
+ // Type metadata ("java:type:Foo") is only supported by sequences and dictionaries.
+ //
+ if(i->find("java:type:", 0) == 0 && (!SequencePtr::dynamicCast(p) && !DictionaryPtr::dynamicCast(p)))
+ {
+ string str;
+ ContainedPtr cont = ContainedPtr::dynamicCast(p);
+ if(cont)
+ {
+ str = cont->kindOf();
+ }
+ else
+ {
+ BuiltinPtr b = BuiltinPtr::dynamicCast(p);
+ assert(b);
+ str = b->typeId();
+ }
+ cout << file << ":" << line << ": warning: invalid metadata for " << str << endl;
+ }
}
}
void
Slice::JavaGenerator::MetaDataVisitor::validateGetSet(const SyntaxTreeBasePtr& p, const StringList& metaData,
- const string& file, const string& line)
+ const string& file, const string& line)
{
for(StringList::const_iterator i = metaData.begin(); i != metaData.end(); ++i)
{
- //
- // The "getset" metadata can only be specified on a class, struct, exception or data member.
- //
- if((*i) == "java:getset" &&
- (!ClassDefPtr::dynamicCast(p) && !StructPtr::dynamicCast(p) && !ExceptionPtr::dynamicCast(p) &&
- !DataMemberPtr::dynamicCast(p)))
- {
- string str;
- ContainedPtr cont = ContainedPtr::dynamicCast(p);
- if(cont)
- {
- str = cont->kindOf();
- }
- else
- {
- BuiltinPtr b = BuiltinPtr::dynamicCast(p);
- assert(b);
- str = b->typeId();
- }
- cout << file << ":" << line << ": warning: invalid metadata for " << str << endl;
- }
+ //
+ // The "getset" metadata can only be specified on a class, struct, exception or data member.
+ //
+ if((*i) == "java:getset" &&
+ (!ClassDefPtr::dynamicCast(p) && !StructPtr::dynamicCast(p) && !ExceptionPtr::dynamicCast(p) &&
+ !DataMemberPtr::dynamicCast(p)))
+ {
+ string str;
+ ContainedPtr cont = ContainedPtr::dynamicCast(p);
+ if(cont)
+ {
+ str = cont->kindOf();
+ }
+ else
+ {
+ BuiltinPtr b = BuiltinPtr::dynamicCast(p);
+ assert(b);
+ str = b->typeId();
+ }
+ cout << file << ":" << line << ": warning: invalid metadata for " << str << endl;
+ }
}
}
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp
index 57e43c1738a..45ae1635d78 100644
--- a/cpp/src/Slice/Parser.cpp
+++ b/cpp/src/Slice/Parser.cpp
@@ -168,61 +168,61 @@ Slice::Builtin::typeId() const
{
switch(_kind)
{
- case KindByte:
- {
- return "byte";
- break;
- }
- case KindBool:
- {
- return "bool";
- break;
- }
- case KindShort:
- {
- return "short";
- break;
- }
- case KindInt:
- {
- return "int";
- break;
- }
- case KindLong:
- {
- return "long";
- break;
- }
- case KindFloat:
- {
- return "float";
- break;
- }
- case KindDouble:
- {
- return "double";
- break;
- }
- case KindString:
- {
- return "string";
- break;
- }
- case KindObject:
- {
- return "::Ice::Object";
- break;
- }
- case KindObjectProxy:
- {
- return "::Ice::Object*";
- break;
- }
- case KindLocalObject:
- {
- return "::Ice::LocalObject";
- break;
- }
+ case KindByte:
+ {
+ return "byte";
+ break;
+ }
+ case KindBool:
+ {
+ return "bool";
+ break;
+ }
+ case KindShort:
+ {
+ return "short";
+ break;
+ }
+ case KindInt:
+ {
+ return "int";
+ break;
+ }
+ case KindLong:
+ {
+ return "long";
+ break;
+ }
+ case KindFloat:
+ {
+ return "float";
+ break;
+ }
+ case KindDouble:
+ {
+ return "double";
+ break;
+ }
+ case KindString:
+ {
+ return "string";
+ break;
+ }
+ case KindObject:
+ {
+ return "::Ice::Object";
+ break;
+ }
+ case KindObjectProxy:
+ {
+ return "::Ice::Object*";
+ break;
+ }
+ case KindLocalObject:
+ {
+ return "::Ice::LocalObject";
+ break;
+ }
}
assert(false);
return ""; // Keep the compiler happy.
@@ -239,16 +239,16 @@ Slice::Builtin::minWireSize() const
{
static size_t minWireSizeTable[] =
{
- 1, // KindByte
- 1, // KindBool
- 2, // KindShort
- 4, // KindInt
- 8, // KindLong
- 4, // KindFloat
- 8, // KindDouble
- 1, // KindString: at least one byte for an empty string.
- 4, // KindObject: at least 4 bytes (to marshal an index instead of an instance).
- 2 // KindObjectProxy: at least an empty identity for a nil proxy, that is, 2 bytes.
+ 1, // KindByte
+ 1, // KindBool
+ 2, // KindShort
+ 4, // KindInt
+ 8, // KindLong
+ 4, // KindFloat
+ 8, // KindDouble
+ 1, // KindString: at least one byte for an empty string.
+ 4, // KindObject: at least 4 bytes (to marshal an index instead of an instance).
+ 2 // KindObjectProxy: at least an empty identity for a nil proxy, that is, 2 bytes.
};
assert(_kind != KindLocalObject);
@@ -275,17 +275,17 @@ Builtin::kindAsString() const
const char* Slice::Builtin::builtinTable[] =
{
- "byte",
- "bool",
- "short",
- "int",
- "long",
- "float",
- "double",
- "string",
- "Object",
- "Object*",
- "LocalObject"
+ "byte",
+ "bool",
+ "short",
+ "int",
+ "long",
+ "float",
+ "double",
+ "string",
+ "Object",
+ "Object*",
+ "LocalObject"
};
Slice::Builtin::Builtin(const UnitPtr& unit, Kind kind) :
@@ -336,7 +336,7 @@ Slice::Contained::flattenedScope() const
string flattenedScope;
for(string::const_iterator r = s.begin(); r != s.end(); ++r)
{
- flattenedScope += ((*r) == ':') ? '_' : *r;
+ flattenedScope += ((*r) == ':') ? '_' : *r;
}
return flattenedScope;
}
@@ -382,11 +382,11 @@ Slice::Contained::findMetaData(const string& prefix, string& meta) const
{
for(list<string>::const_iterator p = _metaData.begin(); p != _metaData.end(); ++p)
{
- if(p->find(prefix) == 0)
- {
- meta = *p;
- return true;
- }
+ if(p->find(prefix) == 0)
+ {
+ meta = *p;
+ return true;
+ }
}
return false;
@@ -439,7 +439,7 @@ Slice::Contained::Contained(const ContainerPtr& container, const string& name) :
ContainedPtr cont = ContainedPtr::dynamicCast(_container);
if(cont)
{
- _scoped = cont->scoped();
+ _scoped = cont->scoped();
}
_scoped += "::" + _name;
assert(_unit);
@@ -475,37 +475,37 @@ Slice::Container::createModule(const string& name)
for(ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p)
{
- bool differsOnlyInCase = !_unit->caseSensitive() && matches.front()->name() != name;
- ModulePtr module = ModulePtr::dynamicCast(*p);
- if(module)
- {
- if(differsOnlyInCase) // Modules can be reopened only if they are capitalized correctly.
- {
- string msg = "module `" + name + "' is capitalized inconsistently with its previous name: `";
- msg += module->name() + "'";
- _unit->error(msg);
- return 0;
- }
- }
- else if(!differsOnlyInCase)
- {
- string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
- msg += "' as module";
- _unit->error(msg);
- return 0;
- }
- else
- {
- string msg = "module `" + name + "' differs only in capitalization from ";
- msg += matches.front()->kindOf() + " name `" + matches.front()->name() + "'";
- _unit->error(msg);
- return 0;
- }
+ bool differsOnlyInCase = !_unit->caseSensitive() && matches.front()->name() != name;
+ ModulePtr module = ModulePtr::dynamicCast(*p);
+ if(module)
+ {
+ if(differsOnlyInCase) // Modules can be reopened only if they are capitalized correctly.
+ {
+ string msg = "module `" + name + "' is capitalized inconsistently with its previous name: `";
+ msg += module->name() + "'";
+ _unit->error(msg);
+ return 0;
+ }
+ }
+ else if(!differsOnlyInCase)
+ {
+ string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
+ msg += "' as module";
+ _unit->error(msg);
+ return 0;
+ }
+ else
+ {
+ string msg = "module `" + name + "' differs only in capitalization from ";
+ msg += matches.front()->kindOf() + " name `" + matches.front()->name() + "'";
+ _unit->error(msg);
+ return 0;
+ }
}
if(!nameIsLegal(name, "module"))
{
- return 0;
+ return 0;
}
ModulePtr q = new Module(this, name);
@@ -520,65 +520,65 @@ Slice::Container::createClassDef(const string& name, bool intf, const ClassList&
ContainedList matches = _unit->findContents(thisScope() + name);
for(ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p)
{
- ClassDeclPtr decl = ClassDeclPtr::dynamicCast(*p);
- if(decl)
- {
- if(checkInterfaceAndLocal(name, false, intf, decl->isInterface(), local, decl->isLocal()))
- {
- continue;
- }
- return 0;
- }
-
- bool differsOnlyInCase = !_unit->caseSensitive() && matches.front()->name() != name;
- ClassDefPtr def = ClassDefPtr::dynamicCast(*p);
- if(def)
- {
- if(differsOnlyInCase)
- {
- string msg = intf ? "interface" : "class";
- msg += " definition `" + name + "' is capitalized inconsistently with its previous name: `";
- msg += def->name() + "'";
- _unit->error(msg);
- }
- else
- {
- if(_unit->ignRedefs())
- {
- def->updateIncludeLevel();
- return def;
- }
-
- string msg = "redefinition of ";
- msg += intf ? "interface" : "class";
- msg += " `" + name + "'";
- _unit->error(msg);
- }
- }
- else if(!_unit->caseSensitive() && differsOnlyInCase)
- {
- string msg = intf ? "interface" : "class";
- msg = " definition `" + name + "' differs only in capitalization from ";
- msg += matches.front()->kindOf() + " name `" + matches.front()->name() + "'";
- _unit->error(msg);
- }
- else
- {
- string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name() + "' as ";
- msg += intf ? "interface" : "class";
- _unit->error(msg);
- }
- return 0;
+ ClassDeclPtr decl = ClassDeclPtr::dynamicCast(*p);
+ if(decl)
+ {
+ if(checkInterfaceAndLocal(name, false, intf, decl->isInterface(), local, decl->isLocal()))
+ {
+ continue;
+ }
+ return 0;
+ }
+
+ bool differsOnlyInCase = !_unit->caseSensitive() && matches.front()->name() != name;
+ ClassDefPtr def = ClassDefPtr::dynamicCast(*p);
+ if(def)
+ {
+ if(differsOnlyInCase)
+ {
+ string msg = intf ? "interface" : "class";
+ msg += " definition `" + name + "' is capitalized inconsistently with its previous name: `";
+ msg += def->name() + "'";
+ _unit->error(msg);
+ }
+ else
+ {
+ if(_unit->ignRedefs())
+ {
+ def->updateIncludeLevel();
+ return def;
+ }
+
+ string msg = "redefinition of ";
+ msg += intf ? "interface" : "class";
+ msg += " `" + name + "'";
+ _unit->error(msg);
+ }
+ }
+ else if(!_unit->caseSensitive() && differsOnlyInCase)
+ {
+ string msg = intf ? "interface" : "class";
+ msg = " definition `" + name + "' differs only in capitalization from ";
+ msg += matches.front()->kindOf() + " name `" + matches.front()->name() + "'";
+ _unit->error(msg);
+ }
+ else
+ {
+ string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name() + "' as ";
+ msg += intf ? "interface" : "class";
+ _unit->error(msg);
+ }
+ return 0;
}
if(!nameIsLegal(name, intf ? "interface" : "class"))
{
- return 0;
+ return 0;
}
if(!checkForGlobalDef(name, intf ? "interface" : "class"))
{
- return 0;
+ return 0;
}
ClassDecl::checkBasesAreLegal(name, intf, local, bases, _unit);
@@ -588,8 +588,8 @@ Slice::Container::createClassDef(const string& name, bool intf, const ClassList&
for(ContainedList::const_iterator q = matches.begin(); q != matches.end(); ++q)
{
- ClassDeclPtr decl = ClassDeclPtr::dynamicCast(*q);
- decl->_definition = def;
+ ClassDeclPtr decl = ClassDeclPtr::dynamicCast(*q);
+ decl->_definition = def;
}
//
@@ -613,54 +613,54 @@ Slice::Container::createClassDecl(const string& name, bool intf, bool local)
ContainedList matches = _unit->findContents(thisScope() + name);
for(ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p)
{
- ClassDefPtr clDef = ClassDefPtr::dynamicCast(*p);
- if(clDef)
- {
- if(checkInterfaceAndLocal(name, true, intf, clDef->isInterface(), local, clDef->isLocal()))
- {
- assert(!def);
- def = clDef;
- continue;
- }
- return 0;
- }
-
- ClassDeclPtr clDecl = ClassDeclPtr::dynamicCast(*p);
- if(clDecl)
- {
- if(checkInterfaceAndLocal(name, false, intf, clDecl->isInterface(), local, clDecl->isLocal()))
- {
- continue;
- }
- return 0;
- }
-
- bool differsOnlyInCase = !_unit->caseSensitive() && matches.front()->name() != name;
- if(differsOnlyInCase)
- {
- string msg = "class declaration `" + name + "' differs only in capitalization from ";
- msg += matches.front()->kindOf() + " name `" + matches.front()->name() + "'";
- _unit->error(msg);
- }
- else
- {
- string msg = "declaration of already defined `";
- msg += name;
- msg += "' as ";
- msg += intf ? "interface" : "class";
- _unit->error(msg);
- return 0;
- }
+ ClassDefPtr clDef = ClassDefPtr::dynamicCast(*p);
+ if(clDef)
+ {
+ if(checkInterfaceAndLocal(name, true, intf, clDef->isInterface(), local, clDef->isLocal()))
+ {
+ assert(!def);
+ def = clDef;
+ continue;
+ }
+ return 0;
+ }
+
+ ClassDeclPtr clDecl = ClassDeclPtr::dynamicCast(*p);
+ if(clDecl)
+ {
+ if(checkInterfaceAndLocal(name, false, intf, clDecl->isInterface(), local, clDecl->isLocal()))
+ {
+ continue;
+ }
+ return 0;
+ }
+
+ bool differsOnlyInCase = !_unit->caseSensitive() && matches.front()->name() != name;
+ if(differsOnlyInCase)
+ {
+ string msg = "class declaration `" + name + "' differs only in capitalization from ";
+ msg += matches.front()->kindOf() + " name `" + matches.front()->name() + "'";
+ _unit->error(msg);
+ }
+ else
+ {
+ string msg = "declaration of already defined `";
+ msg += name;
+ msg += "' as ";
+ msg += intf ? "interface" : "class";
+ _unit->error(msg);
+ return 0;
+ }
}
if(!nameIsLegal(name, intf ? "interface" : "class"))
{
- return 0;
+ return 0;
}
if(!checkForGlobalDef(name, intf ? "interface" : "class"))
{
- return 0;
+ return 0;
}
//
@@ -670,16 +670,16 @@ Slice::Container::createClassDecl(const string& name, bool intf, bool local)
//
for(ContainedList::const_iterator q = _contents.begin(); q != _contents.end(); ++q)
{
- if((*q)->name() == name)
- {
- ClassDeclPtr decl = ClassDeclPtr::dynamicCast(*q);
- if(decl)
- {
- return decl;
- }
+ if((*q)->name() == name)
+ {
+ ClassDeclPtr decl = ClassDeclPtr::dynamicCast(*q);
+ if(decl)
+ {
+ return decl;
+ }
- assert(ClassDefPtr::dynamicCast(*q));
- }
+ assert(ClassDefPtr::dynamicCast(*q));
+ }
}
_unit->currentContainer();
@@ -688,7 +688,7 @@ Slice::Container::createClassDecl(const string& name, bool intf, bool local)
if(def)
{
- decl->_definition = def;
+ decl->_definition = def;
}
return decl;
@@ -702,27 +702,27 @@ Slice::Container::createException(const string& name, const ExceptionPtr& base,
ContainedList matches = _unit->findContents(thisScope() + name);
if(!matches.empty())
{
- ExceptionPtr p = ExceptionPtr::dynamicCast(matches.front());
- if(p)
- {
- if(_unit->ignRedefs())
- {
- p->updateIncludeLevel();
- return p;
- }
- }
- if(matches.front()->name() == name)
- {
- string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
- msg += "' as exception";
- _unit->error(msg);
- }
- else if(!_unit->caseSensitive())
- {
- string msg = "exception `" + name + "' differs only in capitalization from ";
- msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'";
- _unit->error(msg);
- }
+ ExceptionPtr p = ExceptionPtr::dynamicCast(matches.front());
+ if(p)
+ {
+ if(_unit->ignRedefs())
+ {
+ p->updateIncludeLevel();
+ return p;
+ }
+ }
+ if(matches.front()->name() == name)
+ {
+ string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
+ msg += "' as exception";
+ _unit->error(msg);
+ }
+ else if(!_unit->caseSensitive())
+ {
+ string msg = "exception `" + name + "' differs only in capitalization from ";
+ msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'";
+ _unit->error(msg);
+ }
}
nameIsLegal(name, "exception"); // Don't return here -- we create the exception anyway
@@ -734,7 +734,7 @@ Slice::Container::createException(const string& name, const ExceptionPtr& base,
//
if(!local && base && base->isLocal())
{
- _unit->error("non-local exception `" + name + "' cannot have local base exception `" + base->name() + "'");
+ _unit->error("non-local exception `" + name + "' cannot have local base exception `" + base->name() + "'");
}
ExceptionPtr p = new Exception(this, name, base, local);
@@ -750,27 +750,27 @@ Slice::Container::createStruct(const string& name, bool local)
ContainedList matches = _unit->findContents(thisScope() + name);
if(!matches.empty())
{
- StructPtr p = StructPtr::dynamicCast(matches.front());
- if(p)
- {
- if(_unit->ignRedefs())
- {
- p->updateIncludeLevel();
- return p;
- }
- }
- if(matches.front()->name() == name)
- {
- string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
- msg += "' as struct";
- _unit->error(msg);
- }
- else if(!_unit->caseSensitive())
- {
- string msg = "struct `" + name + "' differs only in capitalization from ";
- msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'";
- _unit->error(msg);
- }
+ StructPtr p = StructPtr::dynamicCast(matches.front());
+ if(p)
+ {
+ if(_unit->ignRedefs())
+ {
+ p->updateIncludeLevel();
+ return p;
+ }
+ }
+ if(matches.front()->name() == name)
+ {
+ string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
+ msg += "' as struct";
+ _unit->error(msg);
+ }
+ else if(!_unit->caseSensitive())
+ {
+ string msg = "struct `" + name + "' differs only in capitalization from ";
+ msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'";
+ _unit->error(msg);
+ }
}
nameIsLegal(name, "structure"); // Don't return here -- we create the struct anyway.
@@ -789,39 +789,39 @@ Slice::Container::createSequence(const string& name, const TypePtr& type, const
if(_unit->profile() == IceE && !local)
{
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(type))
- {
- string msg = "Sequence `" + name + "' cannot contain object values.";
- _unit->error(msg);
- return 0;
- }
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(type))
+ {
+ string msg = "Sequence `" + name + "' cannot contain object values.";
+ _unit->error(msg);
+ return 0;
+ }
}
ContainedList matches = _unit->findContents(thisScope() + name);
if(!matches.empty())
{
- SequencePtr p = SequencePtr::dynamicCast(matches.front());
- if(p)
- {
- if(_unit->ignRedefs())
- {
- p->updateIncludeLevel();
- return p;
- }
- }
- if(matches.front()->name() == name)
- {
- string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
- msg += "' as sequence";
- _unit->error(msg);
- }
- else if(!_unit->caseSensitive())
- {
- string msg = "sequence `" + name + "' differs only in capitalization from ";
- msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'";
- _unit->error(msg);
- }
+ SequencePtr p = SequencePtr::dynamicCast(matches.front());
+ if(p)
+ {
+ if(_unit->ignRedefs())
+ {
+ p->updateIncludeLevel();
+ return p;
+ }
+ }
+ if(matches.front()->name() == name)
+ {
+ string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
+ msg += "' as sequence";
+ _unit->error(msg);
+ }
+ else if(!_unit->caseSensitive())
+ {
+ string msg = "sequence `" + name + "' differs only in capitalization from ";
+ msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'";
+ _unit->error(msg);
+ }
}
nameIsLegal(name, "sequence"); // Don't return here -- we create the sequence anyway.
@@ -833,8 +833,8 @@ Slice::Container::createSequence(const string& name, const TypePtr& type, const
//
if(!local && type->isLocal())
{
- string msg = "non-local sequence `" + name + "' cannot have local element type";
- _unit->error(msg);
+ string msg = "non-local sequence `" + name + "' cannot have local element type";
+ _unit->error(msg);
}
SequencePtr p = new Sequence(this, name, type, metaData, local);
@@ -844,45 +844,45 @@ Slice::Container::createSequence(const string& name, const TypePtr& type, const
DictionaryPtr
Slice::Container::createDictionary(const string& name, const TypePtr& keyType, const StringList& keyMetaData,
- const TypePtr& valueType, const StringList& valueMetaData, bool local)
+ const TypePtr& valueType, const StringList& valueMetaData, bool local)
{
checkPrefix(name);
if(_unit->profile() == IceE && !local)
{
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(valueType);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(valueType))
- {
- string msg = "Dictionary `" + name + "' cannot contain object values.";
- _unit->error(msg);
- return 0;
- }
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(valueType);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(valueType))
+ {
+ string msg = "Dictionary `" + name + "' cannot contain object values.";
+ _unit->error(msg);
+ return 0;
+ }
}
ContainedList matches = _unit->findContents(thisScope() + name);
if(!matches.empty())
{
- DictionaryPtr p = DictionaryPtr::dynamicCast(matches.front());
- if(p)
- {
- if(_unit->ignRedefs())
- {
- p->updateIncludeLevel();
- return p;
- }
- }
- if(matches.front()->name() == name)
- {
- string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
- msg += "' as dictionary";
- _unit->error(msg);
- }
- else if(!_unit->caseSensitive())
- {
- string msg = "dictionary `" + name + "' differs only in capitalization from ";
- msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'";
- _unit->error(msg);
- }
+ DictionaryPtr p = DictionaryPtr::dynamicCast(matches.front());
+ if(p)
+ {
+ if(_unit->ignRedefs())
+ {
+ p->updateIncludeLevel();
+ return p;
+ }
+ }
+ if(matches.front()->name() == name)
+ {
+ string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
+ msg += "' as dictionary";
+ _unit->error(msg);
+ }
+ else if(!_unit->caseSensitive())
+ {
+ string msg = "dictionary `" + name + "' differs only in capitalization from ";
+ msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'";
+ _unit->error(msg);
+ }
}
nameIsLegal(name, "dictionary"); // Don't return here -- we create the dictionary anyway.
@@ -891,22 +891,22 @@ Slice::Container::createDictionary(const string& name, const TypePtr& keyType, c
if(!Dictionary::legalKeyType(keyType))
{
- _unit->error("dictionary `" + name + "' uses an illegal key type");
- return 0;
+ _unit->error("dictionary `" + name + "' uses an illegal key type");
+ return 0;
}
if(!local)
{
- if(keyType->isLocal())
- {
- string msg = "non-local dictionary `" + name + "' cannot have local key type";
- _unit->error(msg);
- }
- if(valueType->isLocal())
- {
- string msg = "non-local dictionary `" + name + "' cannot have local value type";
- _unit->error(msg);
- }
+ if(keyType->isLocal())
+ {
+ string msg = "non-local dictionary `" + name + "' cannot have local key type";
+ _unit->error(msg);
+ }
+ if(valueType->isLocal())
+ {
+ string msg = "non-local dictionary `" + name + "' cannot have local value type";
+ _unit->error(msg);
+ }
}
DictionaryPtr p = new Dictionary(this, name, keyType, keyMetaData, valueType, valueMetaData, local);
@@ -922,27 +922,27 @@ Slice::Container::createEnum(const string& name, bool local)
ContainedList matches = _unit->findContents(thisScope() + name);
if(!matches.empty())
{
- EnumPtr p = EnumPtr::dynamicCast(matches.front());
- if(p)
- {
- if(_unit->ignRedefs())
- {
- p->updateIncludeLevel();
- return p;
- }
- }
- if(matches.front()->name() == name)
- {
- string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
- msg += "' as enumeration";
- _unit->error(msg);
- }
- else if(!_unit->caseSensitive())
- {
- string msg = "enumeration `" + name + "' differs only in capitalization from ";
- msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'";
- _unit->error(msg);
- }
+ EnumPtr p = EnumPtr::dynamicCast(matches.front());
+ if(p)
+ {
+ if(_unit->ignRedefs())
+ {
+ p->updateIncludeLevel();
+ return p;
+ }
+ }
+ if(matches.front()->name() == name)
+ {
+ string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
+ msg += "' as enumeration";
+ _unit->error(msg);
+ }
+ else if(!_unit->caseSensitive())
+ {
+ string msg = "enumeration `" + name + "' differs only in capitalization from ";
+ msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'";
+ _unit->error(msg);
+ }
}
nameIsLegal(name, "enumeration"); // Don't return here -- we create the enumeration anyway.
@@ -962,27 +962,27 @@ Slice::Container::createEnumerator(const string& name)
ContainedList matches = _unit->findContents(thisScope() + name);
if(!matches.empty())
{
- EnumeratorPtr p = EnumeratorPtr::dynamicCast(matches.front());
- if(p)
- {
- if(_unit->ignRedefs())
- {
- p->updateIncludeLevel();
- return p;
- }
- }
- if(matches.front()->name() == name)
- {
- string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
- msg += "' as enumerator";
- _unit->error(msg);
- }
- else if(!_unit->caseSensitive())
- {
- string msg = "enumerator `" + name + "' differs only in capitalization from ";
- msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'";
- _unit->error(msg);
- }
+ EnumeratorPtr p = EnumeratorPtr::dynamicCast(matches.front());
+ if(p)
+ {
+ if(_unit->ignRedefs())
+ {
+ p->updateIncludeLevel();
+ return p;
+ }
+ }
+ if(matches.front()->name() == name)
+ {
+ string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
+ msg += "' as enumerator";
+ _unit->error(msg);
+ }
+ else if(!_unit->caseSensitive())
+ {
+ string msg = "enumerator `" + name + "' differs only in capitalization from ";
+ msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'";
+ _unit->error(msg);
+ }
}
nameIsLegal(name, "enumerator"); // Don't return here -- we create the enumerator anyway.
@@ -994,34 +994,34 @@ Slice::Container::createEnumerator(const string& name)
ConstPtr
Slice::Container::createConst(const string name, const TypePtr& constType, const StringList& metaData,
- const SyntaxTreeBasePtr& literalType, const string& value)
+ const SyntaxTreeBasePtr& literalType, const string& value)
{
checkPrefix(name);
ContainedList matches = _unit->findContents(thisScope() + name);
if(!matches.empty())
{
- ConstPtr p = ConstPtr::dynamicCast(matches.front());
- if(p)
- {
- if(_unit->ignRedefs())
- {
- p->updateIncludeLevel();
- return p;
- }
- }
- if(matches.front()->name() == name)
- {
- string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
- msg += "' as constant";
- _unit->error(msg);
- }
- else if(!_unit->caseSensitive())
- {
- string msg = "constant `" + name + "' differs only in capitalization from ";
- msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'";
- _unit->error(msg);
- }
+ ConstPtr p = ConstPtr::dynamicCast(matches.front());
+ if(p)
+ {
+ if(_unit->ignRedefs())
+ {
+ p->updateIncludeLevel();
+ return p;
+ }
+ }
+ if(matches.front()->name() == name)
+ {
+ string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
+ msg += "' as constant";
+ _unit->error(msg);
+ }
+ else if(!_unit->caseSensitive())
+ {
+ string msg = "constant `" + name + "' differs only in capitalization from ";
+ msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'";
+ _unit->error(msg);
+ }
}
nameIsLegal(name, "constant"); // Don't return here -- we create the constant anyway.
@@ -1033,7 +1033,7 @@ Slice::Container::createConst(const string name, const TypePtr& constType, const
//
if(!Const::isLegalType(name, constType, _unit))
{
- return 0;
+ return 0;
}
//
@@ -1041,7 +1041,7 @@ Slice::Container::createConst(const string name, const TypePtr& constType, const
//
if(!Const::typesAreCompatible(name, constType, literalType, value, _unit))
{
- return 0;
+ return 0;
}
//
@@ -1049,7 +1049,7 @@ Slice::Container::createConst(const string name, const TypePtr& constType, const
//
if(!Const::isInRange(name, constType, value, _unit))
{
- return 0;
+ return 0;
}
ConstPtr p = new Const(this, name, constType, metaData, value);
@@ -1067,7 +1067,7 @@ Slice::Container::lookupType(const string& scoped, bool printError)
string::size_type pos;
while((pos = sc.find_first_of(" \t\r\n")) != string::npos)
{
- sc.erase(pos, 1);
+ sc.erase(pos, 1);
}
//
@@ -1075,12 +1075,12 @@ Slice::Container::lookupType(const string& scoped, bool printError)
//
for(unsigned int i = 0; i < sizeof(Builtin::builtinTable) / sizeof(const char*); ++i)
{
- if(sc == Builtin::builtinTable[i])
- {
- TypeList result;
- result.push_back(_unit->builtin(static_cast<Builtin::Kind>(i)));
- return result;
- }
+ if(sc == Builtin::builtinTable[i])
+ {
+ TypeList result;
+ result.push_back(_unit->builtin(static_cast<Builtin::Kind>(i)));
+ return result;
+ }
}
//
@@ -1099,7 +1099,7 @@ Slice::Container::lookupTypeNoBuiltin(const string& scoped, bool printError)
string::size_type pos;
while((pos = sc.find_first_of(" \t\r\n")) != string::npos)
{
- sc.erase(pos, 1);
+ sc.erase(pos, 1);
}
//
@@ -1107,118 +1107,118 @@ Slice::Container::lookupTypeNoBuiltin(const string& scoped, bool printError)
//
if(sc.size() >= 2 && sc[0] == ':')
{
- return _unit->lookupTypeNoBuiltin(sc.substr(2), printError);
+ return _unit->lookupTypeNoBuiltin(sc.substr(2), printError);
}
TypeList results;
if(sc.rfind('*') == sc.length() - 1)
{
- //
- // Proxies.
- //
- ContainedList matches = _unit->findContents(thisScope() + sc.substr(0, sc.length() - 1));
- for(ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p)
- {
- ClassDefPtr def = ClassDefPtr::dynamicCast(*p);
- if(def)
- {
- continue; // Ignore class definitions.
- }
-
- if(printError && !_unit->caseSensitive() && matches.front()->scoped() != (thisScope() + sc))
- {
- string msg = (*p)->kindOf() + " name `" + scoped;
- msg += "' is capitalized inconsistently with its previous name: `";
- msg += matches.front()->scoped() + "'";
- _unit->error(msg);
- }
-
- ClassDeclPtr cl = ClassDeclPtr::dynamicCast(*p);
- if(!cl)
- {
- if(printError)
- {
- string msg = "`";
- msg += sc;
- msg += "' must be class or interface";
- _unit->error(msg);
- }
- return TypeList();
- }
- results.push_back(new Proxy(cl));
- }
+ //
+ // Proxies.
+ //
+ ContainedList matches = _unit->findContents(thisScope() + sc.substr(0, sc.length() - 1));
+ for(ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p)
+ {
+ ClassDefPtr def = ClassDefPtr::dynamicCast(*p);
+ if(def)
+ {
+ continue; // Ignore class definitions.
+ }
+
+ if(printError && !_unit->caseSensitive() && matches.front()->scoped() != (thisScope() + sc))
+ {
+ string msg = (*p)->kindOf() + " name `" + scoped;
+ msg += "' is capitalized inconsistently with its previous name: `";
+ msg += matches.front()->scoped() + "'";
+ _unit->error(msg);
+ }
+
+ ClassDeclPtr cl = ClassDeclPtr::dynamicCast(*p);
+ if(!cl)
+ {
+ if(printError)
+ {
+ string msg = "`";
+ msg += sc;
+ msg += "' must be class or interface";
+ _unit->error(msg);
+ }
+ return TypeList();
+ }
+ results.push_back(new Proxy(cl));
+ }
}
else
{
- //
- // Non-Proxies.
- //
- ContainedList matches = _unit->findContents(thisScope() + sc);
- for(ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p)
- {
- ClassDefPtr def = ClassDefPtr::dynamicCast(*p);
- if(def)
- {
- continue; // Ignore class definitions.
- }
-
- if(printError && !_unit->caseSensitive() && matches.front()->scoped() != (thisScope() + sc))
- {
- string msg = (*p)->kindOf() + " name `" + scoped;
- msg += "' is capitalized inconsistently with its previous name: `";
- msg += matches.front()->scoped() + "'";
- _unit->error(msg);
- }
-
-
- ExceptionPtr ex = ExceptionPtr::dynamicCast(*p);
- if(ex)
- {
- if(printError)
- {
- string msg = "`";
- msg += sc;
- msg += "' is an exception, which cannot be used as a type";
- _unit->error(msg);
- }
- return TypeList();
- }
-
- TypePtr type = TypePtr::dynamicCast(*p);
- if(!type)
- {
- if(printError)
- {
- string msg = "`";
- msg += sc;
- msg += "' is not a type";
- _unit->error(msg);
- }
- return TypeList();
- }
- results.push_back(type);
- }
+ //
+ // Non-Proxies.
+ //
+ ContainedList matches = _unit->findContents(thisScope() + sc);
+ for(ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p)
+ {
+ ClassDefPtr def = ClassDefPtr::dynamicCast(*p);
+ if(def)
+ {
+ continue; // Ignore class definitions.
+ }
+
+ if(printError && !_unit->caseSensitive() && matches.front()->scoped() != (thisScope() + sc))
+ {
+ string msg = (*p)->kindOf() + " name `" + scoped;
+ msg += "' is capitalized inconsistently with its previous name: `";
+ msg += matches.front()->scoped() + "'";
+ _unit->error(msg);
+ }
+
+
+ ExceptionPtr ex = ExceptionPtr::dynamicCast(*p);
+ if(ex)
+ {
+ if(printError)
+ {
+ string msg = "`";
+ msg += sc;
+ msg += "' is an exception, which cannot be used as a type";
+ _unit->error(msg);
+ }
+ return TypeList();
+ }
+
+ TypePtr type = TypePtr::dynamicCast(*p);
+ if(!type)
+ {
+ if(printError)
+ {
+ string msg = "`";
+ msg += sc;
+ msg += "' is not a type";
+ _unit->error(msg);
+ }
+ return TypeList();
+ }
+ results.push_back(type);
+ }
}
if(results.empty())
{
- ContainedPtr contained = ContainedPtr::dynamicCast(this);
- if(!contained)
- {
- if(printError)
- {
- string msg = "`";
- msg += sc;
- msg += "' is not defined";
- _unit->error(msg);
- }
- return TypeList();
- }
- return contained->container()->lookupTypeNoBuiltin(sc, printError);
+ ContainedPtr contained = ContainedPtr::dynamicCast(this);
+ if(!contained)
+ {
+ if(printError)
+ {
+ string msg = "`";
+ msg += sc;
+ msg += "' is not defined";
+ _unit->error(msg);
+ }
+ return TypeList();
+ }
+ return contained->container()->lookupTypeNoBuiltin(sc, printError);
}
else
{
- return results;
+ return results;
}
}
@@ -1232,7 +1232,7 @@ Slice::Container::lookupContained(const string& scoped, bool printError)
string::size_type pos;
while((pos = sc.find_first_of(" \t\r\n")) != string::npos)
{
- sc.erase(pos, 1);
+ sc.erase(pos, 1);
}
//
@@ -1240,45 +1240,45 @@ Slice::Container::lookupContained(const string& scoped, bool printError)
//
if(sc.size() >= 2 && sc[0] == ':')
{
- return _unit->lookupContained(sc.substr(2), printError);
+ return _unit->lookupContained(sc.substr(2), printError);
}
ContainedList matches = _unit->findContents(thisScope() + sc);
ContainedList results;
for(ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p)
{
- if(!ClassDefPtr::dynamicCast(*p)) // Ignore class definitions.
- {
- results.push_back(*p);
+ if(!ClassDefPtr::dynamicCast(*p)) // Ignore class definitions.
+ {
+ results.push_back(*p);
- if(printError && !_unit->caseSensitive() && (*p)->scoped() != (thisScope() + sc))
- {
- string msg = (*p)->kindOf() + " name `" + scoped;
- msg += "' is capitalized inconsistently with its previous name: `" + (*p)->scoped() + "'";
- _unit->error(msg);
- }
- }
+ if(printError && !_unit->caseSensitive() && (*p)->scoped() != (thisScope() + sc))
+ {
+ string msg = (*p)->kindOf() + " name `" + scoped;
+ msg += "' is capitalized inconsistently with its previous name: `" + (*p)->scoped() + "'";
+ _unit->error(msg);
+ }
+ }
}
if(results.empty())
{
- ContainedPtr contained = ContainedPtr::dynamicCast(this);
- if(!contained)
- {
- if(printError)
- {
- string msg = "`";
- msg += sc;
- msg += "' is not defined";
- _unit->error(msg);
- }
- return ContainedList();
- }
- return contained->container()->lookupContained(sc, printError);
+ ContainedPtr contained = ContainedPtr::dynamicCast(this);
+ if(!contained)
+ {
+ if(printError)
+ {
+ string msg = "`";
+ msg += sc;
+ msg += "' is not defined";
+ _unit->error(msg);
+ }
+ return ContainedList();
+ }
+ return contained->container()->lookupContained(sc, printError);
}
else
{
- return results;
+ return results;
}
}
@@ -1288,25 +1288,25 @@ Slice::Container::lookupException(const string& scoped, bool printError)
ContainedList contained = lookupContained(scoped, printError);
if(contained.empty())
{
- return 0;
+ return 0;
}
ExceptionList exceptions;
for(ContainedList::iterator p = contained.begin(); p != contained.end(); ++p)
{
- ExceptionPtr ex = ExceptionPtr::dynamicCast(*p);
- if(!ex)
- {
- if(printError)
- {
- string msg = "`";
- msg += scoped;
- msg += "' is not an exception";
- _unit->error(msg);
- }
- return 0;
- }
- exceptions.push_back(ex);
+ ExceptionPtr ex = ExceptionPtr::dynamicCast(*p);
+ if(!ex)
+ {
+ if(printError)
+ {
+ string msg = "`";
+ msg += scoped;
+ msg += "' is not an exception";
+ _unit->error(msg);
+ }
+ return 0;
+ }
+ exceptions.push_back(ex);
}
assert(exceptions.size() == 1);
return exceptions.front();
@@ -1318,11 +1318,11 @@ Slice::Container::modules() const
ModuleList result;
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- ModulePtr q = ModulePtr::dynamicCast(*p);
- if(q)
- {
- result.push_back(q);
- }
+ ModulePtr q = ModulePtr::dynamicCast(*p);
+ if(q)
+ {
+ result.push_back(q);
+ }
}
return result;
}
@@ -1333,11 +1333,11 @@ Slice::Container::classes() const
ClassList result;
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- ClassDefPtr q = ClassDefPtr::dynamicCast(*p);
- if(q)
- {
- result.push_back(q);
- }
+ ClassDefPtr q = ClassDefPtr::dynamicCast(*p);
+ if(q)
+ {
+ result.push_back(q);
+ }
}
return result;
}
@@ -1348,11 +1348,11 @@ Slice::Container::exceptions() const
ExceptionList result;
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- ExceptionPtr q = ExceptionPtr::dynamicCast(*p);
- if(q)
- {
- result.push_back(q);
- }
+ ExceptionPtr q = ExceptionPtr::dynamicCast(*p);
+ if(q)
+ {
+ result.push_back(q);
+ }
}
return result;
}
@@ -1363,11 +1363,11 @@ Slice::Container::structs() const
StructList result;
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- StructPtr q = StructPtr::dynamicCast(*p);
- if(q)
- {
- result.push_back(q);
- }
+ StructPtr q = StructPtr::dynamicCast(*p);
+ if(q)
+ {
+ result.push_back(q);
+ }
}
return result;
}
@@ -1378,11 +1378,11 @@ Slice::Container::sequences() const
SequenceList result;
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- SequencePtr q = SequencePtr::dynamicCast(*p);
- if(q)
- {
- result.push_back(q);
- }
+ SequencePtr q = SequencePtr::dynamicCast(*p);
+ if(q)
+ {
+ result.push_back(q);
+ }
}
return result;
}
@@ -1393,11 +1393,11 @@ Slice::Container::dictionaries() const
DictionaryList result;
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- DictionaryPtr q = DictionaryPtr::dynamicCast(*p);
- if(q)
- {
- result.push_back(q);
- }
+ DictionaryPtr q = DictionaryPtr::dynamicCast(*p);
+ if(q)
+ {
+ result.push_back(q);
+ }
}
return result;
}
@@ -1408,11 +1408,11 @@ Slice::Container::enums() const
EnumList result;
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- EnumPtr q = EnumPtr::dynamicCast(*p);
- if(q)
- {
- result.push_back(q);
- }
+ EnumPtr q = EnumPtr::dynamicCast(*p);
+ if(q)
+ {
+ result.push_back(q);
+ }
}
return result;
}
@@ -1428,17 +1428,17 @@ Slice::Container::hasNonLocalClassDecls() const
{
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- ClassDeclPtr cl = ClassDeclPtr::dynamicCast(*p);
- if(cl && !cl->isLocal())
- {
- return true;
- }
+ ClassDeclPtr cl = ClassDeclPtr::dynamicCast(*p);
+ if(cl && !cl->isLocal())
+ {
+ return true;
+ }
- ContainerPtr container = ContainerPtr::dynamicCast(*p);
- if(container && container->hasNonLocalClassDecls())
- {
- return true;
- }
+ ContainerPtr container = ContainerPtr::dynamicCast(*p);
+ if(container && container->hasNonLocalClassDecls())
+ {
+ return true;
+ }
}
return false;
@@ -1449,17 +1449,17 @@ Slice::Container::hasNonLocalClassDefs() const
{
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- ClassDefPtr cl = ClassDefPtr::dynamicCast(*p);
- if(cl && !cl->isLocal())
- {
- return true;
- }
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(*p);
+ if(cl && !cl->isLocal())
+ {
+ return true;
+ }
- ContainerPtr container = ContainerPtr::dynamicCast(*p);
- if(container && container->hasNonLocalClassDefs())
- {
- return true;
- }
+ ContainerPtr container = ContainerPtr::dynamicCast(*p);
+ if(container && container->hasNonLocalClassDefs())
+ {
+ return true;
+ }
}
return false;
@@ -1470,17 +1470,17 @@ Slice::Container::hasNonLocalSequences() const
{
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- SequencePtr s = SequencePtr::dynamicCast(*p);
- if(s && !s->isLocal())
- {
- return true;
- }
+ SequencePtr s = SequencePtr::dynamicCast(*p);
+ if(s && !s->isLocal())
+ {
+ return true;
+ }
- ContainerPtr container = ContainerPtr::dynamicCast(*p);
- if(container && container->hasNonLocalSequences())
- {
- return true;
- }
+ ContainerPtr container = ContainerPtr::dynamicCast(*p);
+ if(container && container->hasNonLocalSequences())
+ {
+ return true;
+ }
}
return false;
@@ -1491,17 +1491,17 @@ Slice::Container::hasNonLocalDictionaries() const
{
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- DictionaryPtr d = DictionaryPtr::dynamicCast(*p);
- if(d && !d->isLocal())
- {
- return true;
- }
+ DictionaryPtr d = DictionaryPtr::dynamicCast(*p);
+ if(d && !d->isLocal())
+ {
+ return true;
+ }
- ContainerPtr container = ContainerPtr::dynamicCast(*p);
- if(container && container->hasNonLocalDictionaries())
- {
- return true;
- }
+ ContainerPtr container = ContainerPtr::dynamicCast(*p);
+ if(container && container->hasNonLocalDictionaries())
+ {
+ return true;
+ }
}
return false;
@@ -1512,17 +1512,17 @@ Slice::Container::hasNonLocalExceptions() const
{
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- ExceptionPtr q = ExceptionPtr::dynamicCast(*p);
- if(q && !q->isLocal())
- {
- return true;
- }
+ ExceptionPtr q = ExceptionPtr::dynamicCast(*p);
+ if(q && !q->isLocal())
+ {
+ return true;
+ }
- ContainerPtr container = ContainerPtr::dynamicCast(*p);
- if(container && container->hasNonLocalExceptions())
- {
- return true;
- }
+ ContainerPtr container = ContainerPtr::dynamicCast(*p);
+ if(container && container->hasNonLocalExceptions())
+ {
+ return true;
+ }
}
return false;
@@ -1533,16 +1533,16 @@ Slice::Container::hasClassDecls() const
{
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- if(ClassDeclPtr::dynamicCast(*p))
- {
- return true;
- }
+ if(ClassDeclPtr::dynamicCast(*p))
+ {
+ return true;
+ }
- ContainerPtr container = ContainerPtr::dynamicCast(*p);
- if(container && container->hasClassDecls())
- {
- return true;
- }
+ ContainerPtr container = ContainerPtr::dynamicCast(*p);
+ if(container && container->hasClassDecls())
+ {
+ return true;
+ }
}
return false;
@@ -1553,16 +1553,16 @@ Slice::Container::hasClassDefs() const
{
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- if(ClassDefPtr::dynamicCast(*p))
- {
- return true;
- }
+ if(ClassDefPtr::dynamicCast(*p))
+ {
+ return true;
+ }
- ContainerPtr container = ContainerPtr::dynamicCast(*p);
- if(container && container->hasClassDefs())
- {
- return true;
- }
+ ContainerPtr container = ContainerPtr::dynamicCast(*p);
+ if(container && container->hasClassDefs())
+ {
+ return true;
+ }
}
return false;
@@ -1573,17 +1573,17 @@ Slice::Container::hasAbstractClassDefs() const
{
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- ClassDefPtr cl = ClassDefPtr::dynamicCast(*p);
- if(cl && cl->isAbstract())
- {
- return true;
- }
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(*p);
+ if(cl && cl->isAbstract())
+ {
+ return true;
+ }
- ContainerPtr container = ContainerPtr::dynamicCast(*p);
- if(container && container->hasAbstractClassDefs())
- {
- return true;
- }
+ ContainerPtr container = ContainerPtr::dynamicCast(*p);
+ if(container && container->hasAbstractClassDefs())
+ {
+ return true;
+ }
}
return false;
@@ -1594,20 +1594,20 @@ Slice::Container::hasDataOnlyClasses() const
{
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- ClassDefPtr q = ClassDefPtr::dynamicCast(*p);
- if(q)
- {
- if(!q->isAbstract())
- {
- return true;
- }
- }
+ ClassDefPtr q = ClassDefPtr::dynamicCast(*p);
+ if(q)
+ {
+ if(!q->isAbstract())
+ {
+ return true;
+ }
+ }
- ContainerPtr container = ContainerPtr::dynamicCast(*p);
- if(container && container->hasDataOnlyClasses())
- {
- return true;
- }
+ ContainerPtr container = ContainerPtr::dynamicCast(*p);
+ if(container && container->hasDataOnlyClasses())
+ {
+ return true;
+ }
}
return false;
@@ -1618,26 +1618,26 @@ Slice::Container::hasOtherConstructedOrExceptions() const
{
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- if(ConstructedPtr::dynamicCast(*p) && !ClassDeclPtr::dynamicCast(*p) && !ClassDefPtr::dynamicCast(*p))
- {
- return true;
- }
+ if(ConstructedPtr::dynamicCast(*p) && !ClassDeclPtr::dynamicCast(*p) && !ClassDefPtr::dynamicCast(*p))
+ {
+ return true;
+ }
- if(ExceptionPtr::dynamicCast(*p))
- {
- return true;
- }
+ if(ExceptionPtr::dynamicCast(*p))
+ {
+ return true;
+ }
- if(ConstPtr::dynamicCast(*p))
- {
- return true;
- }
+ if(ConstPtr::dynamicCast(*p))
+ {
+ return true;
+ }
- ContainerPtr container = ContainerPtr::dynamicCast(*p);
- if(container && container->hasOtherConstructedOrExceptions())
- {
- return true;
- }
+ ContainerPtr container = ContainerPtr::dynamicCast(*p);
+ if(container && container->hasOtherConstructedOrExceptions())
+ {
+ return true;
+ }
}
return false;
@@ -1648,16 +1648,16 @@ Slice::Container::hasContentsWithMetaData(const string& meta) const
{
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- if((*p)->hasMetaData(meta))
- {
- return true;
- }
+ if((*p)->hasMetaData(meta))
+ {
+ return true;
+ }
- ContainerPtr container = ContainerPtr::dynamicCast(*p);
- if(container && container->hasContentsWithMetaData(meta))
- {
- return true;
- }
+ ContainerPtr container = ContainerPtr::dynamicCast(*p);
+ if(container && container->hasContentsWithMetaData(meta))
+ {
+ return true;
+ }
}
return false;
@@ -1668,29 +1668,29 @@ Slice::Container::hasAsyncOps() const
{
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- ClassDefPtr cl = ClassDefPtr::dynamicCast(*p);
- if(cl && !cl->isLocal())
- {
- OperationList ops = cl->operations();
- if(!ops.empty() && (cl->hasMetaData("ami") || cl->hasMetaData("amd")))
- {
- return true;
- }
- for(OperationList::const_iterator i = ops.begin(); i != ops.end(); ++i)
- {
- OperationPtr op = *i;
- if(op->hasMetaData("ami") || op->hasMetaData("amd"))
- {
- return true;
- }
- }
- }
-
- ContainerPtr container = ContainerPtr::dynamicCast(*p);
- if(container && container->hasAsyncOps())
- {
- return true;
- }
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(*p);
+ if(cl && !cl->isLocal())
+ {
+ OperationList ops = cl->operations();
+ if(!ops.empty() && (cl->hasMetaData("ami") || cl->hasMetaData("amd")))
+ {
+ return true;
+ }
+ for(OperationList::const_iterator i = ops.begin(); i != ops.end(); ++i)
+ {
+ OperationPtr op = *i;
+ if(op->hasMetaData("ami") || op->hasMetaData("amd"))
+ {
+ return true;
+ }
+ }
+ }
+
+ ContainerPtr container = ContainerPtr::dynamicCast(*p);
+ if(container && container->hasAsyncOps())
+ {
+ return true;
+ }
}
return false;
@@ -1703,7 +1703,7 @@ Slice::Container::thisScope() const
ContainedPtr contained = ContainedPtr::dynamicCast(const_cast<Container*>(this));
if(contained)
{
- s = contained->scoped();
+ s = contained->scoped();
}
s += "::";
return s;
@@ -1714,34 +1714,34 @@ Slice::Container::mergeModules()
{
for(ContainedList::iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- ModulePtr mod1 = ModulePtr::dynamicCast(*p);
- if(!mod1)
- {
- continue;
- }
-
+ ModulePtr mod1 = ModulePtr::dynamicCast(*p);
+ if(!mod1)
+ {
+ continue;
+ }
+
DefinitionContextPtr dc1 = mod1->definitionContext();
assert(dc1);
StringList metaData1 = dc1->getMetaData();
metaData1.sort();
metaData1.unique();
- ContainedList::iterator q = p;
- ++q;
- while(q != _contents.end())
- {
- ModulePtr mod2 = ModulePtr::dynamicCast(*q);
- if(!mod2)
- {
- ++q;
- continue;
- }
-
- if(mod1->name() != mod2->name())
- {
- ++q;
- continue;
- }
+ ContainedList::iterator q = p;
+ ++q;
+ while(q != _contents.end())
+ {
+ ModulePtr mod2 = ModulePtr::dynamicCast(*q);
+ if(!mod2)
+ {
+ ++q;
+ continue;
+ }
+
+ if(mod1->name() != mod2->name())
+ {
+ ++q;
+ continue;
+ }
//
// Compare the global metadata of the two modules being merged.
@@ -1757,20 +1757,20 @@ Slice::Container::mergeModules()
dc1->filename() + " and " + dc2->filename());
}
- mod1->_contents.splice(mod1->_contents.end(), mod2->_contents);
+ mod1->_contents.splice(mod1->_contents.end(), mod2->_contents);
- if(mod1->_comment.length() < mod2->_comment.length())
- {
- mod1->_comment.swap(mod2->_comment);
- }
+ if(mod1->_comment.length() < mod2->_comment.length())
+ {
+ mod1->_comment.swap(mod2->_comment);
+ }
- mod1->_includeLevel = min(mod1->_includeLevel, mod2->_includeLevel);
+ mod1->_includeLevel = min(mod1->_includeLevel, mod2->_includeLevel);
- _unit->removeContent(*q);
- q = _contents.erase(q);
- }
-
- mod1->mergeModules();
+ _unit->removeContent(*q);
+ q = _contents.erase(q);
+ }
+
+ mod1->mergeModules();
}
}
@@ -1785,28 +1785,28 @@ Slice::Container::sortContents(bool sortFields)
{
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- ContainerPtr container = ContainerPtr::dynamicCast(*p);
- if(container)
- {
- if(!sortFields)
- {
- if(StructPtr::dynamicCast(container) ||
- ClassDefPtr::dynamicCast(container) ||
- ExceptionPtr::dynamicCast(container))
- {
- continue;
- }
- }
- //
- // Don't sort operation definitions, otherwise parameters are shown in the
- // wrong order in the synopsis.
- //
- if(!OperationPtr::dynamicCast(container))
- {
- container->sort();
- }
- container->sortContents(sortFields);
- }
+ ContainerPtr container = ContainerPtr::dynamicCast(*p);
+ if(container)
+ {
+ if(!sortFields)
+ {
+ if(StructPtr::dynamicCast(container) ||
+ ClassDefPtr::dynamicCast(container) ||
+ ExceptionPtr::dynamicCast(container))
+ {
+ continue;
+ }
+ }
+ //
+ // Don't sort operation definitions, otherwise parameters are shown in the
+ // wrong order in the synopsis.
+ //
+ if(!OperationPtr::dynamicCast(container))
+ {
+ container->sort();
+ }
+ container->sortContents(sortFields);
+ }
}
}
@@ -1815,10 +1815,10 @@ Slice::Container::visit(ParserVisitor* visitor, bool all)
{
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- if(all || (*p)->includeLevel() == 0)
- {
- (*p)->visit(visitor, all);
- }
+ if(all || (*p)->includeLevel() == 0)
+ {
+ (*p)->visit(visitor, all);
+ }
}
}
@@ -1828,12 +1828,12 @@ Slice::Container::containerRecDependencies(set<ConstructedPtr>& dependencies)
ContainedList::iterator p;
for(p = _contents.begin(); p != _contents.end(); ++p)
{
- ConstructedPtr constructed = ConstructedPtr::dynamicCast(*p);
- if(constructed && dependencies.find(constructed) != dependencies.end())
- {
- dependencies.insert(constructed);
- constructed->recDependencies(dependencies);
- }
+ ConstructedPtr constructed = ConstructedPtr::dynamicCast(*p);
+ if(constructed && dependencies.find(constructed) != dependencies.end())
+ {
+ dependencies.insert(constructed);
+ constructed->recDependencies(dependencies);
+ }
}
}
@@ -1842,7 +1842,7 @@ Slice::Container::checkIntroduced(const string& scoped, ContainedPtr namedThing)
{
if(scoped[0] == ':') // Only unscoped names introduce anything.
{
- return true;
+ return true;
}
//
@@ -1857,48 +1857,48 @@ Slice::Container::checkIntroduced(const string& scoped, ContainedPtr namedThing)
//
if(namedThing == 0)
{
- ContainedList cl = lookupContained(firstComponent, false);
- if(namedThing == 0)
- {
- if(cl.empty())
- {
- return true; // Ignore types whose creation failed previously.
- }
- }
- namedThing = cl.front();
+ ContainedList cl = lookupContained(firstComponent, false);
+ if(namedThing == 0)
+ {
+ if(cl.empty())
+ {
+ return true; // Ignore types whose creation failed previously.
+ }
+ }
+ namedThing = cl.front();
}
else
{
- //
- // For each scope, get the container until we have the container
- // for the first scope (which is the introduced one).
- //
- ContainerPtr c;
- bool first = true;
- while(pos != string::npos)
- {
- if(first)
- {
- c = namedThing->container();
- }
- else
- {
- ContainedPtr contained = ContainedPtr::dynamicCast(c);
- if(contained)
- {
- c = contained->container();
- }
- }
- first = false;
- if(pos != string::npos)
- {
- pos = scoped.find("::", pos + 2);
- }
- }
- if(ContainedPtr::dynamicCast(c))
- {
- namedThing = ContainedPtr::dynamicCast(c);
- }
+ //
+ // For each scope, get the container until we have the container
+ // for the first scope (which is the introduced one).
+ //
+ ContainerPtr c;
+ bool first = true;
+ while(pos != string::npos)
+ {
+ if(first)
+ {
+ c = namedThing->container();
+ }
+ else
+ {
+ ContainedPtr contained = ContainedPtr::dynamicCast(c);
+ if(contained)
+ {
+ c = contained->container();
+ }
+ }
+ first = false;
+ if(pos != string::npos)
+ {
+ pos = scoped.find("::", pos + 2);
+ }
+ }
+ if(ContainedPtr::dynamicCast(c))
+ {
+ namedThing = ContainedPtr::dynamicCast(c);
+ }
}
//
@@ -1907,22 +1907,22 @@ Slice::Container::checkIntroduced(const string& scoped, ContainedPtr namedThing)
map<string, ContainedPtr, CICompare>::const_iterator it = _introducedMap.find(firstComponent);
if(it == _introducedMap.end())
{
- //
- // We've just introduced the first component to the current scope.
- //
- _introducedMap[firstComponent] = namedThing; // No, insert it
+ //
+ // We've just introduced the first component to the current scope.
+ //
+ _introducedMap[firstComponent] = namedThing; // No, insert it
}
else
{
- //
- // We've previously introduced the first component to the current scope,
- // check that it has not changed meaning.
- //
- if(!_unit->caseSensitive() && it->second != namedThing)
- {
- _unit->error("`" + firstComponent + "' has changed meaning");
- return false;
- }
+ //
+ // We've previously introduced the first component to the current scope,
+ // check that it has not changed meaning.
+ //
+ if(!_unit->caseSensitive() && it->second != namedThing)
+ {
+ _unit->error("`" + firstComponent + "' has changed meaning");
+ return false;
+ }
}
return true;
}
@@ -1937,29 +1937,29 @@ Slice::Container::nameIsLegal(const string& newName, const char* newConstruct)
//
if(module)
{
- if(newName == module->name())
- {
- string msg = newConstruct;
- msg += " name `" + newName + "' must differ from the name of its immediately enclosing module";
- _unit->error(msg);
- return false;
- }
- if(!_unit->caseSensitive())
- {
- string name = newName;
- toLower(name);
- string thisName = module->name();
- toLower(thisName);
- if(name == thisName)
- {
- string msg = newConstruct;
- msg += " name `" + name + "' cannot differ only in capitalization from its immediately enclosing "
- "module name `" + module->name() + "'";
- _unit->error(msg);
- return false;
- }
- }
- module = ModulePtr::dynamicCast(module->container()); // Get enclosing module for test below.
+ if(newName == module->name())
+ {
+ string msg = newConstruct;
+ msg += " name `" + newName + "' must differ from the name of its immediately enclosing module";
+ _unit->error(msg);
+ return false;
+ }
+ if(!_unit->caseSensitive())
+ {
+ string name = newName;
+ toLower(name);
+ string thisName = module->name();
+ toLower(thisName);
+ if(name == thisName)
+ {
+ string msg = newConstruct;
+ msg += " name `" + name + "' cannot differ only in capitalization from its immediately enclosing "
+ "module name `" + module->name() + "'";
+ _unit->error(msg);
+ return false;
+ }
+ }
+ module = ModulePtr::dynamicCast(module->container()); // Get enclosing module for test below.
}
//
@@ -1967,30 +1967,30 @@ Slice::Container::nameIsLegal(const string& newName, const char* newConstruct)
//
while(module)
{
- if(newName == module->name())
- {
- string msg = newConstruct;
- msg += " name `" + newName + "' must differ from the name of enclosing module `" + module->name()
- + "' (first defined at " + module->file() + ":" + module->line() + ")";
- _unit->error(msg);
- return false;
- }
- if(!_unit->caseSensitive())
- {
- string name = newName;
- toLower(name);
- string thisName = module->name();
- toLower(thisName);
- if(name == thisName)
- {
- string msg = newConstruct;
- msg += " name `" + name + "' cannot differ only in capitalization from enclosing module `"
- + module->name() + "' (first defined at " + module->file() + ":" + module->line() + ")";
- _unit->error(msg);
- return false;
- }
- }
- module = ModulePtr::dynamicCast(module->container());
+ if(newName == module->name())
+ {
+ string msg = newConstruct;
+ msg += " name `" + newName + "' must differ from the name of enclosing module `" + module->name()
+ + "' (first defined at " + module->file() + ":" + module->line() + ")";
+ _unit->error(msg);
+ return false;
+ }
+ if(!_unit->caseSensitive())
+ {
+ string name = newName;
+ toLower(name);
+ string thisName = module->name();
+ toLower(thisName);
+ if(name == thisName)
+ {
+ string msg = newConstruct;
+ msg += " name `" + name + "' cannot differ only in capitalization from enclosing module `"
+ + module->name() + "' (first defined at " + module->file() + ":" + module->line() + ")";
+ _unit->error(msg);
+ return false;
+ }
+ }
+ module = ModulePtr::dynamicCast(module->container());
}
return true;
@@ -2001,15 +2001,15 @@ Slice::Container::checkForGlobalDef(const string& name, const char* newConstruct
{
if(dynamic_cast<Unit*>(this) && strcmp(newConstruct, "module"))
{
- static const string vowels = "aeiou";
- string glottalStop;
- if(vowels.find_first_of(newConstruct[0]) != string::npos)
- {
- glottalStop = "n";
- }
- _unit->error("`" + name + "': a" + glottalStop + " " + newConstruct +
- " can be defined only at module scope");
- return false;
+ static const string vowels = "aeiou";
+ string glottalStop;
+ if(vowels.find_first_of(newConstruct[0]) != string::npos)
+ {
+ glottalStop = "n";
+ }
+ _unit->error("`" + name + "': a" + glottalStop + " " + newConstruct +
+ " can be defined only at module scope");
+ return false;
}
return true;
}
@@ -2021,61 +2021,61 @@ Slice::Container::Container(const UnitPtr& unit) :
bool
Slice::Container::checkInterfaceAndLocal(const string& name, bool defined,
- bool intf, bool intfOther,
- bool local, bool localOther)
+ bool intf, bool intfOther,
+ bool local, bool localOther)
{
string definedOrDeclared;
if(defined)
{
- definedOrDeclared = "defined";
+ definedOrDeclared = "defined";
}
else
{
- definedOrDeclared = "declared";
+ definedOrDeclared = "declared";
}
if(!intf && intfOther)
{
- string msg = "class `";
- msg += name;
- msg += "' was ";
- msg += definedOrDeclared;
- msg += " as interface";
- _unit->error(msg);
- return false;
+ string msg = "class `";
+ msg += name;
+ msg += "' was ";
+ msg += definedOrDeclared;
+ msg += " as interface";
+ _unit->error(msg);
+ return false;
}
if(intf && !intfOther)
{
- string msg = "interface `";
- msg += name;
- msg += "' was ";
- msg += definedOrDeclared;
- msg += " as class";
- _unit->error(msg);
- return false;
+ string msg = "interface `";
+ msg += name;
+ msg += "' was ";
+ msg += definedOrDeclared;
+ msg += " as class";
+ _unit->error(msg);
+ return false;
}
if(!local && localOther)
{
- string msg = "non-local `";
- msg += name;
- msg += "' was ";
- msg += definedOrDeclared;
- msg += " local";
- _unit->error(msg);
- return false;
+ string msg = "non-local `";
+ msg += name;
+ msg += "' was ";
+ msg += definedOrDeclared;
+ msg += " local";
+ _unit->error(msg);
+ return false;
}
if(local && !localOther)
{
- string msg = "local `";
- msg += name;
- msg += "' was ";
- msg += definedOrDeclared;
- msg += " non-local";
- _unit->error(msg);
- return false;
+ string msg = "local `";
+ msg += name;
+ msg += "' was ";
+ msg += definedOrDeclared;
+ msg += " non-local";
+ _unit->error(msg);
+ return false;
}
return true;
@@ -2086,17 +2086,17 @@ Slice::Container::checkPrefix(const string& name) const
{
if(_unit->currentIncludeLevel() == 0 && !_unit->allowIcePrefix())
{
- if(name.size() >= 3)
- {
- string prefix3;
- prefix3 += ::tolower(name[0]);
- prefix3 += ::tolower(name[1]);
- prefix3 += ::tolower(name[2]);
- if(prefix3 == "ice")
- {
- _unit->error("illegal identifier `" + name + "': `" + name.substr(0, 3) + "' prefix is reserved");
- }
- }
+ if(name.size() >= 3)
+ {
+ string prefix3;
+ prefix3 += ::tolower(name[0]);
+ prefix3 += ::tolower(name[1]);
+ prefix3 += ::tolower(name[2]);
+ if(prefix3 == "ice")
+ {
+ _unit->error("illegal identifier `" + name + "': `" + name.substr(0, 3) + "' prefix is reserved");
+ }
+ }
}
}
@@ -2127,8 +2127,8 @@ Slice::Module::visit(ParserVisitor* visitor, bool all)
{
if(visitor->visitModuleStart(this))
{
- Container::visit(visitor, all);
- visitor->visitModuleEnd(this);
+ Container::visit(visitor, all);
+ visitor->visitModuleEnd(this);
}
}
@@ -2242,7 +2242,7 @@ Slice::ClassDecl::kindOf() const
string s;
if(isLocal())
{
- s += "local ";
+ s += "local ";
}
s += _interface ? "interface" : "class";
return s;
@@ -2259,33 +2259,33 @@ Slice::ClassDecl::recDependencies(set<ConstructedPtr>& dependencies)
{
if(_definition)
{
- _definition->containerRecDependencies(dependencies);
- ClassList bases = _definition->bases();
- ClassList::iterator p;
- for(p = bases.begin(); p != bases.end(); ++p)
- {
- (*p)->declaration()->recDependencies(dependencies);
- }
+ _definition->containerRecDependencies(dependencies);
+ ClassList bases = _definition->bases();
+ ClassList::iterator p;
+ for(p = bases.begin(); p != bases.end(); ++p)
+ {
+ (*p)->declaration()->recDependencies(dependencies);
+ }
}
}
void
Slice::ClassDecl::checkBasesAreLegal(const string& name, bool intf, bool local, const ClassList& bases,
- const UnitPtr& unit)
+ const UnitPtr& unit)
{
//
// Local definitions cannot have non-local bases, and vice versa.
//
for(ClassList::const_iterator p = bases.begin(); p != bases.end(); ++p)
{
- if(local != (*p)->isLocal())
- {
- ostringstream msg;
- msg << (local ? "local" : "non-local") << " " << (intf ? "interface" : "class") << " `"
- << name << "' cannot have " << ((*p)->isLocal() ? "local" : "non-local") << " base "
- << ((*p)->isInterface() ? "interface" : "class") << " `" << (*p)->name() << "'";
- unit->error(msg.str());
- }
+ if(local != (*p)->isLocal())
+ {
+ ostringstream msg;
+ msg << (local ? "local" : "non-local") << " " << (intf ? "interface" : "class") << " `"
+ << name << "' cannot have " << ((*p)->isLocal() ? "local" : "non-local") << " base "
+ << ((*p)->isInterface() ? "interface" : "class") << " `" << (*p)->name() << "'";
+ unit->error(msg.str());
+ }
}
//
@@ -2294,34 +2294,34 @@ Slice::ClassDecl::checkBasesAreLegal(const string& name, bool intf, bool local,
//
if(bases.size() > 1)
{
- //
- // We have multiple inheritance. Build a list of paths through the
- // inheritance graph, such that multiple inheritance is legal if
- // the union of the names defined in classes on each path are disjoint.
- //
- GraphPartitionList gpl;
- for(ClassList::const_iterator p = bases.begin(); p != bases.end(); ++p)
- {
- ClassList cl;
- gpl.push_back(cl);
- addPartition(gpl, gpl.rbegin(), *p);
- }
-
- //
- // We now have a list of partitions, with each partition containing
- // a list of class definitions. Turn the list of partitions of class
- // definitions into a list of sets of strings, with each
- // set containing the names of operations and data members defined in
- // the classes in each partition.
- //
- StringPartitionList spl = toStringPartitionList(gpl);
-
- //
- // Multiple inheritance is legal if no two partitions contain a common
- // name (that is, if the union of the intersections of all possible pairs
- // of partitions is empty).
- //
- checkPairIntersections(spl, name, unit);
+ //
+ // We have multiple inheritance. Build a list of paths through the
+ // inheritance graph, such that multiple inheritance is legal if
+ // the union of the names defined in classes on each path are disjoint.
+ //
+ GraphPartitionList gpl;
+ for(ClassList::const_iterator p = bases.begin(); p != bases.end(); ++p)
+ {
+ ClassList cl;
+ gpl.push_back(cl);
+ addPartition(gpl, gpl.rbegin(), *p);
+ }
+
+ //
+ // We now have a list of partitions, with each partition containing
+ // a list of class definitions. Turn the list of partitions of class
+ // definitions into a list of sets of strings, with each
+ // set containing the names of operations and data members defined in
+ // the classes in each partition.
+ //
+ StringPartitionList spl = toStringPartitionList(gpl);
+
+ //
+ // Multiple inheritance is legal if no two partitions contain a common
+ // name (that is, if the union of the intersections of all possible pairs
+ // of partitions is empty).
+ //
+ checkPairIntersections(spl, name, unit);
}
}
@@ -2343,25 +2343,25 @@ Slice::ClassDecl::isInList(const GraphPartitionList& gpl, const ClassDefPtr cdp)
{
for(GraphPartitionList::const_iterator i = gpl.begin(); i != gpl.end(); ++i)
{
- if(find(i->begin(), i->end(), cdp) != i->end())
- {
- return true;
- }
+ if(find(i->begin(), i->end(), cdp) != i->end())
+ {
+ return true;
+ }
}
return false;
}
void
Slice::ClassDecl::addPartition(GraphPartitionList& gpl,
- GraphPartitionList::reverse_iterator tail,
- const ClassDefPtr base)
+ GraphPartitionList::reverse_iterator tail,
+ const ClassDefPtr base)
{
//
// If this base is on one of the partition lists already, do nothing.
//
if(isInList(gpl, base))
{
- return;
+ return;
}
//
// Put the current base at the end of the current partition.
@@ -2373,7 +2373,7 @@ Slice::ClassDecl::addPartition(GraphPartitionList& gpl,
//
if(base->bases().size())
{
- addPartition(gpl, tail, *(base->bases().begin()));
+ addPartition(gpl, tail, *(base->bases().begin()));
}
//
// If the base has multiple bases, each of the "grandbases"
@@ -2382,14 +2382,14 @@ Slice::ClassDecl::addPartition(GraphPartitionList& gpl,
//
if(base->bases().size() > 1)
{
- ClassList grandBases = base->bases();
- ClassList::const_iterator i = grandBases.begin();
- while(++i != grandBases.end())
- {
- ClassList cl;
- gpl.push_back(cl);
- addPartition(gpl, gpl.rbegin(), *i);
- }
+ ClassList grandBases = base->bases();
+ ClassList::const_iterator i = grandBases.begin();
+ while(++i != grandBases.end())
+ {
+ ClassList cl;
+ gpl.push_back(cl);
+ addPartition(gpl, gpl.rbegin(), *i);
+ }
}
}
@@ -2404,16 +2404,16 @@ Slice::ClassDecl::toStringPartitionList(const GraphPartitionList& gpl)
StringPartitionList spl;
for(GraphPartitionList::const_iterator i = gpl.begin(); i != gpl.end(); ++i)
{
- StringList sl;
- spl.push_back(sl);
- for(ClassList::const_iterator j = i->begin(); j != i->end(); ++j)
- {
- OperationList operations = (*j)->operations();
- for(OperationList::const_iterator l = operations.begin(); l != operations.end(); ++l)
- {
- spl.rbegin()->push_back((*l)->name());
- }
- }
+ StringList sl;
+ spl.push_back(sl);
+ for(ClassList::const_iterator j = i->begin(); j != i->end(); ++j)
+ {
+ OperationList operations = (*j)->operations();
+ for(OperationList::const_iterator l = operations.begin(); l != operations.end(); ++l)
+ {
+ spl.rbegin()->push_back((*l)->name());
+ }
+ }
}
return spl;
}
@@ -2428,35 +2428,35 @@ Slice::ClassDecl::checkPairIntersections(const StringPartitionList& l, const str
set<string> reported;
for(StringPartitionList::const_iterator i = l.begin(); i != l.end(); ++i)
{
- StringPartitionList::const_iterator cursor = i;
- ++cursor;
- for(StringPartitionList::const_iterator j = cursor; j != l.end(); ++j)
- {
- for(StringList::const_iterator s1 = i->begin(); s1 != i->end(); ++s1)
- {
- for(StringList::const_iterator s2 = j->begin(); s2 != j->end(); ++s2)
- {
- if((*s1) == (*s2) && reported.find(*s1) == reported.end())
- {
- string msg = "ambiguous multiple inheritance: `" + name;
- msg += "' inherits operation `" + *s1 + "' from two or more unrelated base interfaces";
- unit->error(msg);
- reported.insert(*s1);
- }
- else if(!unit->caseSensitive() &&
- !CICompare()(*s1, *s2) && !CICompare()(*s2, *s1) &&
- reported.find(*s1) == reported.end() && reported.find(*s2) == reported.end())
- {
- string msg = "ambiguous multiple inheritance: `" + name;
- msg += "' inherits operations `" + *s1 + "' and `" + *s2;
- msg += "', which differ only in capitalization, from unrelated base interfaces";
- unit->error(msg);
- reported.insert(*s1);
- reported.insert(*s2);
- }
- }
- }
- }
+ StringPartitionList::const_iterator cursor = i;
+ ++cursor;
+ for(StringPartitionList::const_iterator j = cursor; j != l.end(); ++j)
+ {
+ for(StringList::const_iterator s1 = i->begin(); s1 != i->end(); ++s1)
+ {
+ for(StringList::const_iterator s2 = j->begin(); s2 != j->end(); ++s2)
+ {
+ if((*s1) == (*s2) && reported.find(*s1) == reported.end())
+ {
+ string msg = "ambiguous multiple inheritance: `" + name;
+ msg += "' inherits operation `" + *s1 + "' from two or more unrelated base interfaces";
+ unit->error(msg);
+ reported.insert(*s1);
+ }
+ else if(!unit->caseSensitive() &&
+ !CICompare()(*s1, *s2) && !CICompare()(*s2, *s1) &&
+ reported.find(*s1) == reported.end() && reported.find(*s2) == reported.end())
+ {
+ string msg = "ambiguous multiple inheritance: `" + name;
+ msg += "' inherits operations `" + *s1 + "' and `" + *s2;
+ msg += "', which differ only in capitalization, from unrelated base interfaces";
+ unit->error(msg);
+ reported.insert(*s1);
+ reported.insert(*s2);
+ }
+ }
+ }
+ }
}
}
@@ -2474,33 +2474,33 @@ Slice::ClassDef::destroy()
OperationPtr
Slice::ClassDef::createOperation(const string& name,
- const TypePtr& returnType,
- Operation::Mode mode)
+ const TypePtr& returnType,
+ Operation::Mode mode)
{
checkPrefix(name);
ContainedList matches = _unit->findContents(thisScope() + name);
if(!matches.empty())
{
- OperationPtr p = OperationPtr::dynamicCast(matches.front());
- if(p)
- {
- if(_unit->ignRedefs())
- {
- p->updateIncludeLevel();
- return p;
- }
- }
- if(!_unit->caseSensitive() && matches.front()->name() != name)
- {
- string msg = "operation `" + name + "' differs only in capitalization from ";
- msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'";
- _unit->error(msg);
- }
- string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
- msg += "' as operation `" + name + "'";
- _unit->error(msg);
- return 0;
+ OperationPtr p = OperationPtr::dynamicCast(matches.front());
+ if(p)
+ {
+ if(_unit->ignRedefs())
+ {
+ p->updateIncludeLevel();
+ return p;
+ }
+ }
+ if(!_unit->caseSensitive() && matches.front()->name() != name)
+ {
+ string msg = "operation `" + name + "' differs only in capitalization from ";
+ msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'";
+ _unit->error(msg);
+ }
+ string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
+ msg += "' as operation `" + name + "'";
+ _unit->error(msg);
+ return 0;
}
//
@@ -2508,24 +2508,24 @@ Slice::ClassDef::createOperation(const string& name,
//
if(name == this->name())
{
- string msg = isInterface() ? "interface" : "class";
- msg += " name `" + name + "' cannot be used as operation name";
- _unit->error(msg);
- return 0;
+ string msg = isInterface() ? "interface" : "class";
+ msg += " name `" + name + "' cannot be used as operation name";
+ _unit->error(msg);
+ return 0;
}
if(!_unit->caseSensitive())
{
- string newName = name;
- toLower(newName);
- string thisName = this->name();
- toLower(thisName);
- if(newName == thisName)
- {
- string msg = "operation `" + name + "' differs only in capitalization from enclosing ";
- msg += isInterface() ? "interface" : "class";
- msg += " name `" + this->name() + "'";
- _unit->error(msg);
- }
+ string newName = name;
+ toLower(newName);
+ string thisName = this->name();
+ toLower(thisName);
+ if(newName == thisName)
+ {
+ string msg = "operation `" + name + "' differs only in capitalization from enclosing ";
+ msg += isInterface() ? "interface" : "class";
+ msg += " name `" + this->name() + "'";
+ _unit->error(msg);
+ }
}
//
@@ -2533,41 +2533,41 @@ Slice::ClassDef::createOperation(const string& name,
//
for(ClassList::const_iterator p = _bases.begin(); p != _bases.end(); ++p)
{
- ContainedList cl;
- OperationList ol = (*p)->allOperations();
- copy(ol.begin(), ol.end(), back_inserter(cl));
- DataMemberList dml = (*p)->allDataMembers();
- copy(dml.begin(), dml.end(), back_inserter(cl));
- for(ContainedList::const_iterator q = cl.begin(); q != cl.end(); ++q)
- {
- if((*q)->name() == name)
- {
- string msg = "operation `" + name;
- msg += "' is already defined as a";
- static const string vowels = "aeiou";
- string kindOf = (*q)->kindOf();
- if(vowels.find_first_of(kindOf[0]) != string::npos)
- {
- msg += "n";
- }
- msg += " " + kindOf + " in a base interface or class";
- _unit->error(msg);
- return 0;
- }
- if(!_unit->caseSensitive())
- {
- string baseName = (*q)->name();
- toLower(baseName);
- string newName = name;
- toLower(newName);
- if(baseName == newName)
- {
- string msg = "operation `" + name + "' differs only in capitalization from " + (*q)->kindOf();
- msg += " `" + (*q)->name() + "', which is defined in a base interface or class";
- _unit->error(msg);
- }
- }
- }
+ ContainedList cl;
+ OperationList ol = (*p)->allOperations();
+ copy(ol.begin(), ol.end(), back_inserter(cl));
+ DataMemberList dml = (*p)->allDataMembers();
+ copy(dml.begin(), dml.end(), back_inserter(cl));
+ for(ContainedList::const_iterator q = cl.begin(); q != cl.end(); ++q)
+ {
+ if((*q)->name() == name)
+ {
+ string msg = "operation `" + name;
+ msg += "' is already defined as a";
+ static const string vowels = "aeiou";
+ string kindOf = (*q)->kindOf();
+ if(vowels.find_first_of(kindOf[0]) != string::npos)
+ {
+ msg += "n";
+ }
+ msg += " " + kindOf + " in a base interface or class";
+ _unit->error(msg);
+ return 0;
+ }
+ if(!_unit->caseSensitive())
+ {
+ string baseName = (*q)->name();
+ toLower(baseName);
+ string newName = name;
+ toLower(newName);
+ if(baseName == newName)
+ {
+ string msg = "operation `" + name + "' differs only in capitalization from " + (*q)->kindOf();
+ msg += " `" + (*q)->name() + "', which is defined in a base interface or class";
+ _unit->error(msg);
+ }
+ }
+ }
}
//
@@ -2575,9 +2575,9 @@ Slice::ClassDef::createOperation(const string& name,
//
if(!isLocal() && returnType && returnType->isLocal())
{
- string msg = "non-local " + this->kindOf() + " `" + this->name() + "' cannot have operation `";
- msg += name + "' with local return type";
- _unit->error(msg);
+ string msg = "non-local " + this->kindOf() + " `" + this->name() + "' cannot have operation `";
+ msg += name + "' with local return type";
+ _unit->error(msg);
}
_hasOperations = true;
@@ -2593,52 +2593,52 @@ Slice::ClassDef::createDataMember(const string& name, const TypePtr& type)
if(_unit->profile() == IceE)
{
- if(!isLocal())
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
- if((builtin && builtin->kind() == Builtin::KindObject))
- {
- string msg = "Class data member `" + name + "' cannot be a value object.";
- _unit->error(msg);
- return 0;
- }
-
- ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(type);
- if(classDecl != 0 && !classDecl->isLocal())
- {
- string msg = "Class data member `" + name + "' cannot be a value object.";
- _unit->error(msg);
- return 0;
- }
- }
+ if(!isLocal())
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
+ if((builtin && builtin->kind() == Builtin::KindObject))
+ {
+ string msg = "Class data member `" + name + "' cannot be a value object.";
+ _unit->error(msg);
+ return 0;
+ }
+
+ ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(type);
+ if(classDecl != 0 && !classDecl->isLocal())
+ {
+ string msg = "Class data member `" + name + "' cannot be a value object.";
+ _unit->error(msg);
+ return 0;
+ }
+ }
}
assert(!isInterface());
ContainedList matches = _unit->findContents(thisScope() + name);
if(!matches.empty())
{
- DataMemberPtr p = DataMemberPtr::dynamicCast(matches.front());
- if(p)
- {
- if(_unit->ignRedefs())
- {
- p->updateIncludeLevel();
- return p;
- }
- }
- if(!_unit->caseSensitive() && matches.front()->name() != name)
- {
- string msg = "data member `" + name + "' differs only in capitalization from ";
- msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'";
- _unit->error(msg);
- }
- else
- {
- string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
- msg += "' as data member `" + name + "'";
- _unit->error(msg);
- return 0;
- }
+ DataMemberPtr p = DataMemberPtr::dynamicCast(matches.front());
+ if(p)
+ {
+ if(_unit->ignRedefs())
+ {
+ p->updateIncludeLevel();
+ return p;
+ }
+ }
+ if(!_unit->caseSensitive() && matches.front()->name() != name)
+ {
+ string msg = "data member `" + name + "' differs only in capitalization from ";
+ msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'";
+ _unit->error(msg);
+ }
+ else
+ {
+ string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name();
+ msg += "' as data member `" + name + "'";
+ _unit->error(msg);
+ return 0;
+ }
}
//
@@ -2646,24 +2646,24 @@ Slice::ClassDef::createDataMember(const string& name, const TypePtr& type)
//
if(name == this->name())
{
- string msg = "class name `";
- msg += name;
- msg += "' cannot be used as data member name";
- _unit->error(msg);
- return 0;
+ string msg = "class name `";
+ msg += name;
+ msg += "' cannot be used as data member name";
+ _unit->error(msg);
+ return 0;
}
if(!_unit->caseSensitive())
{
- string newName = name;
- toLower(newName);
- string thisName = this->name();
- toLower(thisName);
- if(newName == thisName)
- {
- string msg = "data member `" + name + "' differs only in capitalization from enclosing class name `";
- msg += this->name() + "'";
- _unit->error(msg);
- }
+ string newName = name;
+ toLower(newName);
+ string thisName = this->name();
+ toLower(thisName);
+ if(newName == thisName)
+ {
+ string msg = "data member `" + name + "' differs only in capitalization from enclosing class name `";
+ msg += this->name() + "'";
+ _unit->error(msg);
+ }
}
//
@@ -2671,41 +2671,41 @@ Slice::ClassDef::createDataMember(const string& name, const TypePtr& type)
//
for(ClassList::const_iterator p = _bases.begin(); p != _bases.end(); ++p)
{
- ContainedList cl;
- OperationList ol = (*p)->allOperations();
- copy(ol.begin(), ol.end(), back_inserter(cl));
- DataMemberList dml = (*p)->allDataMembers();
- copy(dml.begin(), dml.end(), back_inserter(cl));
- for(ContainedList::const_iterator q = cl.begin(); q != cl.end(); ++q)
- {
- if((*q)->name() == name)
- {
- string msg = "data member `" + name;
- msg += "' is already defined as a";
- static const string vowels = "aeiou";
- string kindOf = (*q)->kindOf();
- if(vowels.find_first_of(kindOf[0]) != string::npos)
- {
- msg += "n";
- }
- msg += " " + kindOf + " in a base interface or class";
- _unit->error(msg);
- return 0;
- }
- if(!_unit->caseSensitive())
- {
- string baseName = (*q)->name();
- toLower(baseName);
- string newName = name;
- toLower(newName);
- if(baseName == newName)
- {
- string msg = "data member `" + name + "' differs only in capitalization from " + (*q)->kindOf();
- msg += " `" + (*q)->name() + "', which is defined in a base interface or class";
- _unit->error(msg);
- }
- }
- }
+ ContainedList cl;
+ OperationList ol = (*p)->allOperations();
+ copy(ol.begin(), ol.end(), back_inserter(cl));
+ DataMemberList dml = (*p)->allDataMembers();
+ copy(dml.begin(), dml.end(), back_inserter(cl));
+ for(ContainedList::const_iterator q = cl.begin(); q != cl.end(); ++q)
+ {
+ if((*q)->name() == name)
+ {
+ string msg = "data member `" + name;
+ msg += "' is already defined as a";
+ static const string vowels = "aeiou";
+ string kindOf = (*q)->kindOf();
+ if(vowels.find_first_of(kindOf[0]) != string::npos)
+ {
+ msg += "n";
+ }
+ msg += " " + kindOf + " in a base interface or class";
+ _unit->error(msg);
+ return 0;
+ }
+ if(!_unit->caseSensitive())
+ {
+ string baseName = (*q)->name();
+ toLower(baseName);
+ string newName = name;
+ toLower(newName);
+ if(baseName == newName)
+ {
+ string msg = "data member `" + name + "' differs only in capitalization from " + (*q)->kindOf();
+ msg += " `" + (*q)->name() + "', which is defined in a base interface or class";
+ _unit->error(msg);
+ }
+ }
+ }
}
//
@@ -2713,8 +2713,8 @@ Slice::ClassDef::createDataMember(const string& name, const TypePtr& type)
//
if(!isLocal() && type->isLocal())
{
- string msg = "non-local " + kindOf() + "`" + this->name() + "' cannot contain local member `" + name + "'";
- _unit->error(msg);
+ string msg = "non-local " + kindOf() + "`" + this->name() + "' cannot contain local member `" + name + "'";
+ _unit->error(msg);
}
_hasDataMembers = true;
@@ -2743,9 +2743,9 @@ Slice::ClassDef::allBases() const
result.unique();
for(ClassList::const_iterator p = _bases.begin(); p != _bases.end(); ++p)
{
- ClassList li = (*p)->allBases();
- result.merge(li);
- result.unique();
+ ClassList li = (*p)->allBases();
+ result.merge(li);
+ result.unique();
}
return result;
}
@@ -2756,11 +2756,11 @@ Slice::ClassDef::operations() const
OperationList result;
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- OperationPtr q = OperationPtr::dynamicCast(*p);
- if(q)
- {
- result.push_back(q);
- }
+ OperationPtr q = OperationPtr::dynamicCast(*p);
+ if(q)
+ {
+ result.push_back(q);
+ }
}
return result;
}
@@ -2773,9 +2773,9 @@ Slice::ClassDef::allOperations() const
result.unique();
for(ClassList::const_iterator p = _bases.begin(); p != _bases.end(); ++p)
{
- OperationList li = (*p)->allOperations();
- result.merge(li);
- result.unique();
+ OperationList li = (*p)->allOperations();
+ result.merge(li);
+ result.unique();
}
return result;
}
@@ -2786,11 +2786,11 @@ Slice::ClassDef::dataMembers() const
DataMemberList result;
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- DataMemberPtr q = DataMemberPtr::dynamicCast(*p);
- if(q)
- {
- result.push_back(q);
- }
+ DataMemberPtr q = DataMemberPtr::dynamicCast(*p);
+ if(q)
+ {
+ result.push_back(q);
+ }
}
return result;
}
@@ -2809,7 +2809,7 @@ Slice::ClassDef::allDataMembers() const
//
if(!_bases.empty() && !_bases.front()->isInterface())
{
- result = _bases.front()->allDataMembers();
+ result = _bases.front()->allDataMembers();
}
//
@@ -2827,15 +2827,15 @@ Slice::ClassDef::classDataMembers() const
DataMemberList result;
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- DataMemberPtr q = DataMemberPtr::dynamicCast(*p);
- if(q)
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->type());
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(q->type()))
- {
- result.push_back(q);
- }
- }
+ DataMemberPtr q = DataMemberPtr::dynamicCast(*p);
+ if(q)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->type());
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(q->type()))
+ {
+ result.push_back(q);
+ }
+ }
}
return result;
}
@@ -2854,7 +2854,7 @@ Slice::ClassDef::allClassDataMembers() const
//
if(!_bases.empty() && !_bases.front()->isInterface())
{
- result = _bases.front()->allClassDataMembers();
+ result = _bases.front()->allClassDataMembers();
}
//
@@ -2871,15 +2871,15 @@ Slice::ClassDef::canBeCyclic() const
{
if(!_bases.empty() && !_bases.front()->isInterface() && _bases.front()->canBeCyclic())
{
- return true;
+ return true;
}
DataMemberList dml = dataMembers();
for(DataMemberList::const_iterator i = dml.begin(); i != dml.end(); ++i)
{
- if((*i)->type()->usesClasses())
- {
- return true;
- }
+ if((*i)->type()->usesClasses())
+ {
+ return true;
+ }
}
return false;
}
@@ -2889,20 +2889,20 @@ Slice::ClassDef::isAbstract() const
{
if(isInterface() || _bases.size() > 1) // Is this an interface, or does it derive from interfaces?
{
- return true;
+ return true;
}
if(!_bases.empty() && _bases.front()->isAbstract())
{
- return true;
+ return true;
}
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- if(OperationPtr::dynamicCast(*p))
- {
- return true;
- }
+ if(OperationPtr::dynamicCast(*p))
+ {
+ return true;
+ }
}
return false;
@@ -2969,7 +2969,7 @@ Slice::ClassDef::kindOf() const
string s;
if(isLocal())
{
- s += "local ";
+ s += "local ";
}
s += isInterface() ? "interface" : "class";
return s;
@@ -2980,13 +2980,13 @@ Slice::ClassDef::visit(ParserVisitor* visitor, bool all)
{
if(visitor->visitClassDefStart(this))
{
- Container::visit(visitor, all);
- visitor->visitClassDefEnd(this);
+ Container::visit(visitor, all);
+ visitor->visitClassDefEnd(this);
}
}
Slice::ClassDef::ClassDef(const ContainerPtr& container, const string& name, bool intf, const ClassList& bases,
- bool local) :
+ bool local) :
SyntaxTreeBase(container->unit()),
Container(container->unit()),
Contained(container, name),
@@ -3003,7 +3003,7 @@ Slice::ClassDef::ClassDef(const ContainerPtr& container, const string& name, boo
#ifndef NDEBUG
for(ClassList::const_iterator p = _bases.begin(); p != _bases.end(); ++p)
{
- assert(p == _bases.begin() || (*p)->isInterface());
+ assert(p == _bases.begin() || (*p)->isInterface());
}
#endif
}
@@ -3073,50 +3073,50 @@ Slice::Exception::createDataMember(const string& name, const TypePtr& type)
if(_unit->profile() == IceE)
{
- if(!isLocal())
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
- if((builtin && builtin->kind() == Builtin::KindObject))
- {
- string msg = "Exception data member `" + name + "' cannot be a value object.";
- _unit->error(msg);
- return 0;
- }
-
- ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(type);
- if(classDecl != 0 && !classDecl->isLocal())
- {
- string msg = "Exception data member `" + name + "' cannot be a value object.";
- _unit->error(msg);
- return 0;
- }
- }
+ if(!isLocal())
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
+ if((builtin && builtin->kind() == Builtin::KindObject))
+ {
+ string msg = "Exception data member `" + name + "' cannot be a value object.";
+ _unit->error(msg);
+ return 0;
+ }
+
+ ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(type);
+ if(classDecl != 0 && !classDecl->isLocal())
+ {
+ string msg = "Exception data member `" + name + "' cannot be a value object.";
+ _unit->error(msg);
+ return 0;
+ }
+ }
}
ContainedList matches = _unit->findContents(thisScope() + name);
if(!matches.empty())
{
- DataMemberPtr p = DataMemberPtr::dynamicCast(matches.front());
- if(p)
- {
- if(_unit->ignRedefs())
- {
- p->updateIncludeLevel();
- return p;
- }
- }
- if(!_unit->caseSensitive() && matches.front()->name() != name)
- {
- string msg = "exception member `" + name + "' differs only in capitalization from ";
- msg += "exception member `" + matches.front()->name() + "'";
- _unit->error(msg);
- }
- else
- {
- string msg = "redefinition of exception member `" + name + "'";
- _unit->error(msg);
- return 0;
- }
+ DataMemberPtr p = DataMemberPtr::dynamicCast(matches.front());
+ if(p)
+ {
+ if(_unit->ignRedefs())
+ {
+ p->updateIncludeLevel();
+ return p;
+ }
+ }
+ if(!_unit->caseSensitive() && matches.front()->name() != name)
+ {
+ string msg = "exception member `" + name + "' differs only in capitalization from ";
+ msg += "exception member `" + matches.front()->name() + "'";
+ _unit->error(msg);
+ }
+ else
+ {
+ string msg = "redefinition of exception member `" + name + "'";
+ _unit->error(msg);
+ return 0;
+ }
}
//
@@ -3124,24 +3124,24 @@ Slice::Exception::createDataMember(const string& name, const TypePtr& type)
//
if(name == this->name())
{
- string msg = "exception name `";
- msg += name;
- msg += "' cannot be used as exception member name";
- _unit->error(msg);
- return 0;
+ string msg = "exception name `";
+ msg += name;
+ msg += "' cannot be used as exception member name";
+ _unit->error(msg);
+ return 0;
}
if(!_unit->caseSensitive())
{
- string newName = name;
- toLower(newName);
- string thisName = this->name();
- toLower(thisName);
- if(newName == thisName)
- {
- string msg = "exception member `" + name + "' differs only in capitalization ";
- msg += "from enclosing exception name `" + this->name() + "'";
- _unit->error(msg);
- }
+ string newName = name;
+ toLower(newName);
+ string thisName = this->name();
+ toLower(thisName);
+ if(newName == thisName)
+ {
+ string msg = "exception member `" + name + "' differs only in capitalization ";
+ msg += "from enclosing exception name `" + this->name() + "'";
+ _unit->error(msg);
+ }
}
//
@@ -3150,31 +3150,31 @@ Slice::Exception::createDataMember(const string& name, const TypePtr& type)
ExceptionList bl = allBases();
for(ExceptionList::const_iterator q = bl.begin(); q != bl.end(); ++q)
{
- ContainedList cl;
- DataMemberList dml = (*q)->dataMembers();
- copy(dml.begin(), dml.end(), back_inserter(cl));
- for(ContainedList::const_iterator r = cl.begin(); r != cl.end(); ++r)
- {
- if((*r)->name() == name)
- {
- string msg = "exception member `" + name + "' is already defined in a base exception";
- _unit->error(msg);
- return 0;
- }
- if(!_unit->caseSensitive())
- {
- string baseName = (*r)->name();
- toLower(baseName);
- string newName = name;
- toLower(newName);
- if(baseName == newName)
- {
- string msg = "exception member `" + name + "' differs only in capitalization from exception member `";
- msg += (*r)->name() + "', which is defined in a base exception";
- _unit->error(msg);
- }
- }
- }
+ ContainedList cl;
+ DataMemberList dml = (*q)->dataMembers();
+ copy(dml.begin(), dml.end(), back_inserter(cl));
+ for(ContainedList::const_iterator r = cl.begin(); r != cl.end(); ++r)
+ {
+ if((*r)->name() == name)
+ {
+ string msg = "exception member `" + name + "' is already defined in a base exception";
+ _unit->error(msg);
+ return 0;
+ }
+ if(!_unit->caseSensitive())
+ {
+ string baseName = (*r)->name();
+ toLower(baseName);
+ string newName = name;
+ toLower(newName);
+ if(baseName == newName)
+ {
+ string msg = "exception member `" + name + "' differs only in capitalization from exception member `";
+ msg += (*r)->name() + "', which is defined in a base exception";
+ _unit->error(msg);
+ }
+ }
+ }
}
//
@@ -3182,8 +3182,8 @@ Slice::Exception::createDataMember(const string& name, const TypePtr& type)
//
if(!isLocal() && type->isLocal())
{
- string msg = "non-local " + kindOf() + "`" + this->name() + "' cannot contain local member `" + name + "'";
- _unit->error(msg);
+ string msg = "non-local " + kindOf() + "`" + this->name() + "' cannot contain local member `" + name + "'";
+ _unit->error(msg);
}
DataMemberPtr p = new DataMember(this, name, type);
@@ -3197,11 +3197,11 @@ Slice::Exception::dataMembers() const
DataMemberList result;
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- DataMemberPtr q = DataMemberPtr::dynamicCast(*p);
- if(q)
- {
- result.push_back(q);
- }
+ DataMemberPtr q = DataMemberPtr::dynamicCast(*p);
+ if(q)
+ {
+ result.push_back(q);
+ }
}
return result;
}
@@ -3220,7 +3220,7 @@ Slice::Exception::allDataMembers() const
//
if(base())
{
- result = base()->allDataMembers();
+ result = base()->allDataMembers();
}
//
@@ -3238,15 +3238,15 @@ Slice::Exception::classDataMembers() const
DataMemberList result;
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- DataMemberPtr q = DataMemberPtr::dynamicCast(*p);
- if(q)
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->type());
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(q->type()))
- {
- result.push_back(q);
- }
- }
+ DataMemberPtr q = DataMemberPtr::dynamicCast(*p);
+ if(q)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->type());
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(q->type()))
+ {
+ result.push_back(q);
+ }
+ }
}
return result;
}
@@ -3265,7 +3265,7 @@ Slice::Exception::allClassDataMembers() const
//
if(base())
{
- result = base()->allClassDataMembers();
+ result = base()->allClassDataMembers();
}
//
@@ -3289,8 +3289,8 @@ Slice::Exception::allBases() const
ExceptionList result;
if(_base)
{
- result = _base->allBases();
- result.push_front(_base);
+ result = _base->allBases();
+ result.push_front(_base);
}
return result;
}
@@ -3300,15 +3300,15 @@ Slice::Exception::isBaseOf(const ExceptionPtr& other) const
{
if(this->scoped() == other->scoped())
{
- return false;
+ return false;
}
ExceptionList bases = other->allBases();
for(ExceptionList::const_iterator i = bases.begin(); i != bases.end(); ++i)
{
- if((*i)->scoped() == scoped())
- {
- return true;
- }
+ if((*i)->scoped() == scoped())
+ {
+ return true;
+ }
}
return false;
}
@@ -3338,14 +3338,14 @@ Slice::Exception::usesClasses() const
DataMemberList dml = dataMembers();
for(DataMemberList::const_iterator i = dml.begin(); i != dml.end(); ++i)
{
- if((*i)->type()->usesClasses())
- {
- return true;
- }
+ if((*i)->type()->usesClasses())
+ {
+ return true;
+ }
}
if(_base)
{
- return _base->usesClasses();
+ return _base->usesClasses();
}
return false;
}
@@ -3361,8 +3361,8 @@ Slice::Exception::visit(ParserVisitor* visitor, bool all)
{
if(visitor->visitExceptionStart(this))
{
- Container::visit(visitor, all);
- visitor->visitExceptionEnd(this);
+ Container::visit(visitor, all);
+ visitor->visitExceptionEnd(this);
}
}
@@ -3386,49 +3386,49 @@ Slice::Struct::createDataMember(const string& name, const TypePtr& type)
if(_unit->profile() == IceE)
{
- if(!isLocal())
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
- if((builtin && builtin->kind() == Builtin::KindObject))
- {
- string msg = "Struct data member `" + name + "' cannot be a value object.";
- _unit->error(msg);
- return 0;
- }
- ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(type);
- if(classDecl != 0 && !classDecl->isLocal())
- {
- string msg = "Struct data member `" + name + "' cannot be a value object.";
- _unit->error(msg);
- return 0;
- }
- }
+ if(!isLocal())
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
+ if((builtin && builtin->kind() == Builtin::KindObject))
+ {
+ string msg = "Struct data member `" + name + "' cannot be a value object.";
+ _unit->error(msg);
+ return 0;
+ }
+ ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(type);
+ if(classDecl != 0 && !classDecl->isLocal())
+ {
+ string msg = "Struct data member `" + name + "' cannot be a value object.";
+ _unit->error(msg);
+ return 0;
+ }
+ }
}
ContainedList matches = _unit->findContents(thisScope() + name);
if(!matches.empty())
{
- DataMemberPtr p = DataMemberPtr::dynamicCast(matches.front());
- if(p)
- {
- if(_unit->ignRedefs())
- {
- p->updateIncludeLevel();
- return p;
- }
- }
- if(!_unit->caseSensitive() && matches.front()->name() != name)
- {
- string msg = "member `" + name + "' differs only in capitalization from ";
- msg += "member `" + matches.front()->name() + "'";
- _unit->error(msg);
- }
- else
- {
- string msg = "redefinition of struct member `" + name + "'";
- _unit->error(msg);
- return 0;
- }
+ DataMemberPtr p = DataMemberPtr::dynamicCast(matches.front());
+ if(p)
+ {
+ if(_unit->ignRedefs())
+ {
+ p->updateIncludeLevel();
+ return p;
+ }
+ }
+ if(!_unit->caseSensitive() && matches.front()->name() != name)
+ {
+ string msg = "member `" + name + "' differs only in capitalization from ";
+ msg += "member `" + matches.front()->name() + "'";
+ _unit->error(msg);
+ }
+ else
+ {
+ string msg = "redefinition of struct member `" + name + "'";
+ _unit->error(msg);
+ return 0;
+ }
}
//
@@ -3436,24 +3436,24 @@ Slice::Struct::createDataMember(const string& name, const TypePtr& type)
//
if(name == this->name())
{
- string msg = "struct name `";
- msg += name;
- msg += "' cannot be used as member name";
- _unit->error(msg);
- return 0;
+ string msg = "struct name `";
+ msg += name;
+ msg += "' cannot be used as member name";
+ _unit->error(msg);
+ return 0;
}
if(!_unit->caseSensitive())
{
- string newName = name;
- toLower(newName);
- string thisName = this->name();
- toLower(thisName);
- if(newName == thisName)
- {
- string msg = "struct member `" + name + "' differs only in capitalization from enclosing struct name `";
- msg += this->name() + "'";
- _unit->error(msg);
- }
+ string newName = name;
+ toLower(newName);
+ string thisName = this->name();
+ toLower(thisName);
+ if(newName == thisName)
+ {
+ string msg = "struct member `" + name + "' differs only in capitalization from enclosing struct name `";
+ msg += this->name() + "'";
+ _unit->error(msg);
+ }
}
//
@@ -3461,11 +3461,11 @@ Slice::Struct::createDataMember(const string& name, const TypePtr& type)
//
if(type.get() == this)
{
- string msg = "struct `";
- msg += this->name();
- msg += "' cannot contain itself";
- _unit->error(msg);
- return 0;
+ string msg = "struct `";
+ msg += this->name();
+ msg += "' cannot contain itself";
+ _unit->error(msg);
+ return 0;
}
//
@@ -3473,8 +3473,8 @@ Slice::Struct::createDataMember(const string& name, const TypePtr& type)
//
if(!isLocal() && type->isLocal())
{
- string msg = "non-local " + kindOf() + "`" + this->name() + "' cannot contain local member `" + name + "'";
- _unit->error(msg);
+ string msg = "non-local " + kindOf() + "`" + this->name() + "' cannot contain local member `" + name + "'";
+ _unit->error(msg);
}
DataMemberPtr p = new DataMember(this, name, type);
@@ -3488,11 +3488,11 @@ Slice::Struct::dataMembers() const
DataMemberList result;
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- DataMemberPtr q = DataMemberPtr::dynamicCast(*p);
- if(q)
- {
- result.push_back(q);
- }
+ DataMemberPtr q = DataMemberPtr::dynamicCast(*p);
+ if(q)
+ {
+ result.push_back(q);
+ }
}
return result;
}
@@ -3503,15 +3503,15 @@ Slice::Struct::classDataMembers() const
DataMemberList result;
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- DataMemberPtr q = DataMemberPtr::dynamicCast(*p);
- if(q)
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->type());
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(q->type()))
- {
- result.push_back(q);
- }
- }
+ DataMemberPtr q = DataMemberPtr::dynamicCast(*p);
+ if(q)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->type());
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(q->type()))
+ {
+ result.push_back(q);
+ }
+ }
}
return result;
}
@@ -3533,15 +3533,15 @@ Slice::Struct::usesClasses() const
{
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- DataMemberPtr q = DataMemberPtr::dynamicCast(*p);
- if(q)
- {
- TypePtr t = q->type();
- if(t->usesClasses())
- {
- return true;
- }
- }
+ DataMemberPtr q = DataMemberPtr::dynamicCast(*p);
+ if(q)
+ {
+ TypePtr t = q->type();
+ if(t->usesClasses())
+ {
+ return true;
+ }
+ }
}
return false;
}
@@ -3556,7 +3556,7 @@ Slice::Struct::minWireSize() const
DataMemberList dml = dataMembers();
for(DataMemberList::const_iterator i = dml.begin(); i != dml.end(); ++i)
{
- sz += (*i)->type()->minWireSize();
+ sz += (*i)->type()->minWireSize();
}
return sz;
}
@@ -3567,10 +3567,10 @@ Slice::Struct::isVariableLength() const
DataMemberList dml = dataMembers();
for(DataMemberList::const_iterator i = dml.begin(); i != dml.end(); ++i)
{
- if((*i)->type()->isVariableLength())
- {
- return true;
- }
+ if((*i)->type()->isVariableLength())
+ {
+ return true;
+ }
}
return false;
}
@@ -3586,8 +3586,8 @@ Slice::Struct::visit(ParserVisitor* visitor, bool all)
{
if(visitor->visitStructStart(this))
{
- Container::visit(visitor, all);
- visitor->visitStructEnd(this);
+ Container::visit(visitor, all);
+ visitor->visitStructEnd(this);
}
}
@@ -3634,7 +3634,7 @@ Slice::Sequence::uses(const ContainedPtr& contained) const
ContainedPtr contained2 = ContainedPtr::dynamicCast(_type);
if(contained2 && contained2 == contained)
{
- return true;
+ return true;
}
return false;
@@ -3676,13 +3676,13 @@ Slice::Sequence::recDependencies(set<ConstructedPtr>& dependencies)
ConstructedPtr constructed = ConstructedPtr::dynamicCast(_type);
if(constructed && dependencies.find(constructed) != dependencies.end())
{
- dependencies.insert(constructed);
- constructed->recDependencies(dependencies);
+ dependencies.insert(constructed);
+ constructed->recDependencies(dependencies);
}
}
Slice::Sequence::Sequence(const ContainerPtr& container, const string& name, const TypePtr& type,
- const StringList& typeMetaData, bool local) :
+ const StringList& typeMetaData, bool local) :
SyntaxTreeBase(container->unit()),
Type(container->unit()),
Contained(container, name),
@@ -3730,19 +3730,19 @@ bool
Slice::Dictionary::uses(const ContainedPtr& contained) const
{
{
- ContainedPtr contained2 = ContainedPtr::dynamicCast(_keyType);
- if(contained2 && contained2 == contained)
- {
- return true;
- }
+ ContainedPtr contained2 = ContainedPtr::dynamicCast(_keyType);
+ if(contained2 && contained2 == contained)
+ {
+ return true;
+ }
}
{
- ContainedPtr contained2 = ContainedPtr::dynamicCast(_valueType);
- if(contained2 && contained2 == contained)
- {
- return true;
- }
+ ContainedPtr contained2 = ContainedPtr::dynamicCast(_valueType);
+ if(contained2 && contained2 == contained)
+ {
+ return true;
+ }
}
return false;
@@ -3782,21 +3782,21 @@ void
Slice::Dictionary::recDependencies(set<ConstructedPtr>& dependencies)
{
{
- ConstructedPtr constructed = ConstructedPtr::dynamicCast(_keyType);
- if(constructed && dependencies.find(constructed) != dependencies.end())
- {
- dependencies.insert(constructed);
- constructed->recDependencies(dependencies);
- }
+ ConstructedPtr constructed = ConstructedPtr::dynamicCast(_keyType);
+ if(constructed && dependencies.find(constructed) != dependencies.end())
+ {
+ dependencies.insert(constructed);
+ constructed->recDependencies(dependencies);
+ }
}
{
- ConstructedPtr constructed = ConstructedPtr::dynamicCast(_valueType);
- if(constructed && dependencies.find(constructed) != dependencies.end())
- {
- dependencies.insert(constructed);
- constructed->recDependencies(dependencies);
- }
+ ConstructedPtr constructed = ConstructedPtr::dynamicCast(_valueType);
+ if(constructed && dependencies.find(constructed) != dependencies.end())
+ {
+ dependencies.insert(constructed);
+ constructed->recDependencies(dependencies);
+ }
}
}
@@ -3811,63 +3811,63 @@ Slice::Dictionary::legalKeyType(const TypePtr& type)
BuiltinPtr bp = BuiltinPtr::dynamicCast(type);
if(bp)
{
- switch(bp->kind())
- {
- case Builtin::KindByte:
- case Builtin::KindBool:
- case Builtin::KindShort:
- case Builtin::KindInt:
- case Builtin::KindLong:
- case Builtin::KindString:
- {
- return true;
- break;
- }
-
- case Builtin::KindFloat:
- case Builtin::KindDouble:
- case Builtin::KindObject:
- case Builtin::KindObjectProxy:
- case Builtin::KindLocalObject:
- {
- return false;
- break;
- }
- }
+ switch(bp->kind())
+ {
+ case Builtin::KindByte:
+ case Builtin::KindBool:
+ case Builtin::KindShort:
+ case Builtin::KindInt:
+ case Builtin::KindLong:
+ case Builtin::KindString:
+ {
+ return true;
+ break;
+ }
+
+ case Builtin::KindFloat:
+ case Builtin::KindDouble:
+ case Builtin::KindObject:
+ case Builtin::KindObjectProxy:
+ case Builtin::KindLocalObject:
+ {
+ return false;
+ break;
+ }
+ }
}
EnumPtr ep = EnumPtr::dynamicCast(type);
if(ep)
{
- return true;
+ return true;
}
SequencePtr seqp = SequencePtr::dynamicCast(type);
if(seqp && legalKeyType(seqp->type()))
{
- return true;
+ return true;
}
StructPtr strp = StructPtr::dynamicCast(type);
if(strp)
{
- DataMemberList dml = strp->dataMembers();
- for(DataMemberList::const_iterator mem = dml.begin(); mem != dml.end(); ++mem)
- {
- if(!legalKeyType((*mem)->type()))
- {
- return false;
- }
- }
- return true;
+ DataMemberList dml = strp->dataMembers();
+ for(DataMemberList::const_iterator mem = dml.begin(); mem != dml.end(); ++mem)
+ {
+ if(!legalKeyType((*mem)->type()))
+ {
+ return false;
+ }
+ }
+ return true;
}
return false;
}
Slice::Dictionary::Dictionary(const ContainerPtr& container, const string& name, const TypePtr& keyType,
- const StringList& keyMetaData, const TypePtr& valueType,
- const StringList& valueMetaData, bool local) :
+ const StringList& keyMetaData, const TypePtr& valueType,
+ const StringList& valueMetaData, bool local) :
SyntaxTreeBase(container->unit()),
Type(container->unit()),
Contained(container, name),
@@ -3930,11 +3930,11 @@ Slice::Enum::minWireSize() const
size_t sz = _enumerators.size();
if(sz <= 0x7f)
{
- return 1;
+ return 1;
}
if(sz <= 0x7fff)
{
- return 2;
+ return 2;
}
return 4;
}
@@ -4057,50 +4057,50 @@ Slice::Const::isLegalType(const string& name, const TypePtr& constType, const Un
{
if(constType == 0)
{
- return false;
+ return false;
}
BuiltinPtr ct = BuiltinPtr::dynamicCast(constType);
if(ct)
{
- switch(ct->kind())
- {
- case Builtin::KindBool:
- case Builtin::KindByte:
- case Builtin::KindShort:
- case Builtin::KindInt:
- case Builtin::KindLong:
- case Builtin::KindFloat:
- case Builtin::KindDouble:
- case Builtin::KindString:
- {
- return true;
- break;
- }
- default:
- {
- string msg = "constant `" + name + "' has illegal type: `" + ct->kindAsString() + "'";
- unit->error(msg);
- return false;
- break;
- }
- }
+ switch(ct->kind())
+ {
+ case Builtin::KindBool:
+ case Builtin::KindByte:
+ case Builtin::KindShort:
+ case Builtin::KindInt:
+ case Builtin::KindLong:
+ case Builtin::KindFloat:
+ case Builtin::KindDouble:
+ case Builtin::KindString:
+ {
+ return true;
+ break;
+ }
+ default:
+ {
+ string msg = "constant `" + name + "' has illegal type: `" + ct->kindAsString() + "'";
+ unit->error(msg);
+ return false;
+ break;
+ }
+ }
}
EnumPtr ep = EnumPtr::dynamicCast(constType);
if(!ep)
{
- string msg = "constant `" + name + "' has illegal type";
- unit->error(msg);
- return false;
+ string msg = "constant `" + name + "' has illegal type";
+ unit->error(msg);
+ return false;
}
return true;
}
bool
Slice::Const::typesAreCompatible(const string& name, const TypePtr& constType,
- const SyntaxTreeBasePtr& literalType, const string& value,
- const UnitPtr& unit)
+ const SyntaxTreeBasePtr& literalType, const string& value,
+ const UnitPtr& unit)
{
BuiltinPtr ct = BuiltinPtr::dynamicCast(constType);
@@ -4114,66 +4114,66 @@ Slice::Const::typesAreCompatible(const string& name, const TypePtr& constType,
if(ct && lt)
{
- switch(ct->kind())
- {
- case Builtin::KindBool:
- {
- if(lt->kind() == Builtin::KindBool)
- {
- return true;
- }
- break;
- }
- case Builtin::KindByte:
- case Builtin::KindShort:
- case Builtin::KindInt:
- case Builtin::KindLong:
- {
- if(lt->kind() == Builtin::KindLong)
- {
- return true;
- }
- break;
- }
- case Builtin::KindFloat:
- case Builtin::KindDouble:
- {
- if(lt->kind() == Builtin::KindDouble)
- {
- return true;
- }
- break;
- }
- case Builtin::KindString:
- {
- if(lt->kind() == Builtin::KindString)
- {
- return true;
- }
- break;
- }
-
- case Builtin::KindObject:
- case Builtin::KindObjectProxy:
- case Builtin::KindLocalObject:
- {
- assert(false);
- break;
- }
- }
-
- string msg = "initializer of type `" + lt->kindAsString();
- msg += "' is incompatible with the type `" + ct->kindAsString() + "' of constant `" + name + "'";
- unit->error(msg);
- return false;
+ switch(ct->kind())
+ {
+ case Builtin::KindBool:
+ {
+ if(lt->kind() == Builtin::KindBool)
+ {
+ return true;
+ }
+ break;
+ }
+ case Builtin::KindByte:
+ case Builtin::KindShort:
+ case Builtin::KindInt:
+ case Builtin::KindLong:
+ {
+ if(lt->kind() == Builtin::KindLong)
+ {
+ return true;
+ }
+ break;
+ }
+ case Builtin::KindFloat:
+ case Builtin::KindDouble:
+ {
+ if(lt->kind() == Builtin::KindDouble)
+ {
+ return true;
+ }
+ break;
+ }
+ case Builtin::KindString:
+ {
+ if(lt->kind() == Builtin::KindString)
+ {
+ return true;
+ }
+ break;
+ }
+
+ case Builtin::KindObject:
+ case Builtin::KindObjectProxy:
+ case Builtin::KindLocalObject:
+ {
+ assert(false);
+ break;
+ }
+ }
+
+ string msg = "initializer of type `" + lt->kindAsString();
+ msg += "' is incompatible with the type `" + ct->kindAsString() + "' of constant `" + name + "'";
+ unit->error(msg);
+ return false;
}
if(ct && !lt)
{
- string msg = "type of initializer is incompatible with the type `" + ct->kindAsString();
- msg += "' of constant `" + name + "'";
- unit->error(msg);
- return false;
+ string msg = "type of initializer is incompatible with the type `" + ct->kindAsString();
+ msg += "' of constant `" + name + "'";
+ unit->error(msg);
+ return false;
}
EnumPtr enumP = EnumPtr::dynamicCast(constType);
@@ -4181,76 +4181,76 @@ Slice::Const::typesAreCompatible(const string& name, const TypePtr& constType,
EnumeratorPtr enumeratorP = EnumeratorPtr::dynamicCast(literalType);
if(!enumeratorP)
{
- string msg = "type of initializer is incompatible with the type of constant `" + name + "'";
- unit->error(msg);
- return false;
+ string msg = "type of initializer is incompatible with the type of constant `" + name + "'";
+ unit->error(msg);
+ return false;
}
EnumeratorList elist = enumP->getEnumerators();
if(find(elist.begin(), elist.end(), enumeratorP) == elist.end())
{
- string msg = "enumerator `" + value + "' is not defined in enumeration `" + enumP->scoped() + "'";
- unit->error(msg);
- return false;
+ string msg = "enumerator `" + value + "' is not defined in enumeration `" + enumP->scoped() + "'";
+ unit->error(msg);
+ return false;
}
return true;
}
bool
Slice::Const::isInRange(const string& name, const TypePtr& constType, const string& value,
- const UnitPtr& unit)
+ const UnitPtr& unit)
{
BuiltinPtr ct = BuiltinPtr::dynamicCast(constType);
if (!ct)
{
- return true; // Enums are checked elsewhere.
+ return true; // Enums are checked elsewhere.
}
switch(ct->kind())
{
- case Builtin::KindByte:
- {
- IceUtil::Int64 l = IceUtil::strToInt64(value.c_str(), 0, 0);
- if(l < ByteMin || l > ByteMax)
- {
- string msg = "initializer `" + value + "' for constant `" + name + "' out of range for type byte";
- unit->error(msg);
- return false;
- }
- break;
- }
- case Builtin::KindShort:
- {
- IceUtil::Int64 l = IceUtil::strToInt64(value.c_str(), 0, 0);
- if(l < Int16Min || l > Int16Max)
- {
- string msg = "initializer `" + value + "' for constant `" + name + "' out of range for type short";
- unit->error(msg);
- return false;
- }
- break;
- }
- case Builtin::KindInt:
- {
- IceUtil::Int64 l = IceUtil::strToInt64(value.c_str(), 0, 0);
- if(l < Int32Min || l > Int32Max)
- {
- string msg = "initializer `" + value + "' for constant `" + name + "' out of range for type int";
- unit->error(msg);
- return false;
- }
- break;
- }
-
- default:
- {
- break;
- }
+ case Builtin::KindByte:
+ {
+ IceUtil::Int64 l = IceUtil::strToInt64(value.c_str(), 0, 0);
+ if(l < ByteMin || l > ByteMax)
+ {
+ string msg = "initializer `" + value + "' for constant `" + name + "' out of range for type byte";
+ unit->error(msg);
+ return false;
+ }
+ break;
+ }
+ case Builtin::KindShort:
+ {
+ IceUtil::Int64 l = IceUtil::strToInt64(value.c_str(), 0, 0);
+ if(l < Int16Min || l > Int16Max)
+ {
+ string msg = "initializer `" + value + "' for constant `" + name + "' out of range for type short";
+ unit->error(msg);
+ return false;
+ }
+ break;
+ }
+ case Builtin::KindInt:
+ {
+ IceUtil::Int64 l = IceUtil::strToInt64(value.c_str(), 0, 0);
+ if(l < Int32Min || l > Int32Max)
+ {
+ string msg = "initializer `" + value + "' for constant `" + name + "' out of range for type int";
+ unit->error(msg);
+ return false;
+ }
+ break;
+ }
+
+ default:
+ {
+ break;
+ }
}
return true; // Everything else is either in range or doesn't need checking.
}
Slice::Const::Const(const ContainerPtr& container, const string& name, const TypePtr& type,
- const StringList& typeMetaData, const string& value) :
+ const StringList& typeMetaData, const string& value) :
SyntaxTreeBase(container->unit()),
Contained(container, name),
_type(type),
@@ -4280,11 +4280,11 @@ Slice::Operation::sendMode() const
{
if(_mode == Operation::Idempotent && hasMetaData("nonmutating"))
{
- return Operation::Nonmutating;
+ return Operation::Nonmutating;
}
else
{
- return _mode;
+ return _mode;
}
}
@@ -4295,51 +4295,51 @@ Slice::Operation::createParamDecl(const string& name, const TypePtr& type, bool
if(_unit->profile() == IceE)
{
- ClassDefPtr cl = ClassDefPtr::dynamicCast(this->container());
- assert(cl);
- if(!cl->isLocal())
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
- if((builtin && builtin->kind() == Builtin::KindObject))
- {
- string msg = "Object `" + name + "' cannot be passed by value.";
- _unit->error(msg);
- return 0;
- }
- ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(type);
- if(classDecl != 0 && !classDecl->isLocal())
- {
- string msg = "Object `" + name + "' cannot be passed by value.";
- _unit->error(msg);
- return 0;
- }
- }
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(this->container());
+ assert(cl);
+ if(!cl->isLocal())
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
+ if((builtin && builtin->kind() == Builtin::KindObject))
+ {
+ string msg = "Object `" + name + "' cannot be passed by value.";
+ _unit->error(msg);
+ return 0;
+ }
+ ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(type);
+ if(classDecl != 0 && !classDecl->isLocal())
+ {
+ string msg = "Object `" + name + "' cannot be passed by value.";
+ _unit->error(msg);
+ return 0;
+ }
+ }
}
ContainedList matches = _unit->findContents(thisScope() + name);
if(!matches.empty())
{
- ParamDeclPtr p = ParamDeclPtr::dynamicCast(matches.front());
- if(p)
- {
- if(_unit->ignRedefs())
- {
- p->updateIncludeLevel();
- return p;
- }
- }
- if(!_unit->caseSensitive() && matches.front()->name() != name)
- {
- string msg = "parameter `" + name + "' differs only in capitalization from ";
- msg += "parameter `" + matches.front()->name() + "'";
- _unit->error(msg);
- }
- else
- {
- string msg = "redefinition of parameter `" + name + "'";
- _unit->error(msg);
- return 0;
- }
+ ParamDeclPtr p = ParamDeclPtr::dynamicCast(matches.front());
+ if(p)
+ {
+ if(_unit->ignRedefs())
+ {
+ p->updateIncludeLevel();
+ return p;
+ }
+ }
+ if(!_unit->caseSensitive() && matches.front()->name() != name)
+ {
+ string msg = "parameter `" + name + "' differs only in capitalization from ";
+ msg += "parameter `" + matches.front()->name() + "'";
+ _unit->error(msg);
+ }
+ else
+ {
+ string msg = "redefinition of parameter `" + name + "'";
+ _unit->error(msg);
+ return 0;
+ }
}
//
@@ -4347,24 +4347,24 @@ Slice::Operation::createParamDecl(const string& name, const TypePtr& type, bool
//
if(name == this->name())
{
- string msg = "operation name `";
- msg += name;
- msg += "' cannot be used as parameter name";
- _unit->error(msg);
- return 0;
+ string msg = "operation name `";
+ msg += name;
+ msg += "' cannot be used as parameter name";
+ _unit->error(msg);
+ return 0;
}
if(!_unit->caseSensitive())
{
- string newName = name;
- toLower(newName);
- string thisName = this->name();
- toLower(thisName);
- if(newName == thisName)
- {
- string msg = "parameter `" + name + "' differs only in capitalization from operation name `";
- msg += this->name() + "'";
- _unit->error(msg);
- }
+ string newName = name;
+ toLower(newName);
+ string thisName = this->name();
+ toLower(thisName);
+ if(newName == thisName)
+ {
+ string msg = "parameter `" + name + "' differs only in capitalization from operation name `";
+ msg += this->name() + "'";
+ _unit->error(msg);
+ }
}
//
@@ -4372,12 +4372,12 @@ Slice::Operation::createParamDecl(const string& name, const TypePtr& type, bool
//
if(!_contents.empty())
{
- ParamDeclPtr p = ParamDeclPtr::dynamicCast(_contents.back());
- assert(p);
- if(p->isOutParam() && !isOutParam)
- {
- _unit->error("`" + name + "': in parameters cannot follow out parameters");
- }
+ ParamDeclPtr p = ParamDeclPtr::dynamicCast(_contents.back());
+ assert(p);
+ if(p->isOutParam() && !isOutParam)
+ {
+ _unit->error("`" + name + "': in parameters cannot follow out parameters");
+ }
}
//
@@ -4387,9 +4387,9 @@ Slice::Operation::createParamDecl(const string& name, const TypePtr& type, bool
assert(cl);
if(type->isLocal() && !cl->isLocal())
{
- string msg = "non-local " + cl->kindOf() + " `" + cl->name() + "' cannot have local parameter `";
- msg += name + "' in operation `" + this->name() + "'";
- _unit->error(msg);
+ string msg = "non-local " + cl->kindOf() + " `" + cl->name() + "' cannot have local parameter `";
+ msg += name + "' in operation `" + this->name() + "'";
+ _unit->error(msg);
}
ParamDeclPtr p = new ParamDecl(this, name, type, isOutParam);
@@ -4403,11 +4403,11 @@ Slice::Operation::parameters() const
ParamDeclList result;
for(ContainedList::const_iterator p = _contents.begin(); p != _contents.end(); ++p)
{
- ParamDeclPtr q = ParamDeclPtr::dynamicCast(*p);
- if(q)
- {
- result.push_back(q);
- }
+ ParamDeclPtr q = ParamDeclPtr::dynamicCast(*p);
+ if(q)
+ {
+ result.push_back(q);
+ }
}
return result;
}
@@ -4431,32 +4431,32 @@ Slice::Operation::setExceptionList(const ExceptionList& el)
uniqueExceptions.unique();
if(uniqueExceptions.size() != el.size())
{
- //
- // At least one exception appears twice.
- //
- ExceptionList tmp = el;
- tmp.sort();
- ExceptionList duplicates;
- set_difference(tmp.begin(), tmp.end(),
- uniqueExceptions.begin(), uniqueExceptions.end(),
- back_inserter(duplicates));
- string msg = "operation `" + name() + "' has a throws clause with ";
- if(duplicates.size() == 1)
- {
- msg += "a ";
- }
- msg += "duplicate exception";
- if(duplicates.size() > 1)
- {
- msg += "s";
- }
- ExceptionList::const_iterator i = duplicates.begin();
- msg += ": `" + (*i)->name() + "'";
- for(i = ++i; i != duplicates.end(); ++i)
- {
- msg += ", `" + (*i)->name() + "'";
- }
- _unit->error(msg);
+ //
+ // At least one exception appears twice.
+ //
+ ExceptionList tmp = el;
+ tmp.sort();
+ ExceptionList duplicates;
+ set_difference(tmp.begin(), tmp.end(),
+ uniqueExceptions.begin(), uniqueExceptions.end(),
+ back_inserter(duplicates));
+ string msg = "operation `" + name() + "' has a throws clause with ";
+ if(duplicates.size() == 1)
+ {
+ msg += "a ";
+ }
+ msg += "duplicate exception";
+ if(duplicates.size() > 1)
+ {
+ msg += "s";
+ }
+ ExceptionList::const_iterator i = duplicates.begin();
+ msg += ": `" + (*i)->name() + "'";
+ for(i = ++i; i != duplicates.end(); ++i)
+ {
+ msg += ", `" + (*i)->name() + "'";
+ }
+ _unit->error(msg);
}
//
@@ -4466,15 +4466,15 @@ Slice::Operation::setExceptionList(const ExceptionList& el)
assert(cl);
if(!cl->isLocal())
{
- for(ExceptionList::const_iterator ep = el.begin(); ep != el.end(); ++ep)
- {
- if((*ep)->isLocal())
- {
- string msg = "non-local " + cl->kindOf() + " `" + cl->name() + "' cannot have operation `";
- msg += name() + "' throwing local exception `" + (*ep)->name() + "'";
- _unit->error(msg);
- }
- }
+ for(ExceptionList::const_iterator ep = el.begin(); ep != el.end(); ++ep)
+ {
+ if((*ep)->isLocal())
+ {
+ string msg = "non-local " + cl->kindOf() + " `" + cl->name() + "' cannot have operation `";
+ msg += name() + "' throwing local exception `" + (*ep)->name() + "'";
+ _unit->error(msg);
+ }
+ }
}
}
@@ -4488,22 +4488,22 @@ bool
Slice::Operation::uses(const ContainedPtr& contained) const
{
{
- ContainedPtr contained2 = ContainedPtr::dynamicCast(_returnType);
- if(contained2 && contained2 == contained)
- {
- return true;
- }
+ ContainedPtr contained2 = ContainedPtr::dynamicCast(_returnType);
+ if(contained2 && contained2 == contained)
+ {
+ return true;
+ }
}
ExceptionList::const_iterator q;
for(q = _throws.begin(); q != _throws.end(); ++q)
{
- ContainedPtr contained2 = ContainedPtr::dynamicCast(*q);
- if(contained2 && contained2 == contained)
- {
- return true;
- }
+ ContainedPtr contained2 = ContainedPtr::dynamicCast(*q);
+ if(contained2 && contained2 == contained)
+ {
+ return true;
+ }
}
return false;
@@ -4515,10 +4515,10 @@ Slice::Operation::sendsClasses() const
ParamDeclList pdl = parameters();
for(ParamDeclList::const_iterator i = pdl.begin(); i != pdl.end(); ++i)
{
- if(!(*i)->isOutParam() && (*i)->type()->usesClasses())
- {
- return true;
- }
+ if(!(*i)->isOutParam() && (*i)->type()->usesClasses())
+ {
+ return true;
+ }
}
return false;
}
@@ -4529,15 +4529,15 @@ Slice::Operation::returnsClasses() const
TypePtr t = returnType();
if(t && t->usesClasses())
{
- return true;
+ return true;
}
ParamDeclList pdl = parameters();
for(ParamDeclList::const_iterator i = pdl.begin(); i != pdl.end(); ++i)
{
- if((*i)->isOutParam() && (*i)->type()->usesClasses())
- {
- return true;
- }
+ if((*i)->isOutParam() && (*i)->type()->usesClasses())
+ {
+ return true;
+ }
}
return false;
}
@@ -4548,15 +4548,15 @@ Slice::Operation::returnsData() const
TypePtr t = returnType();
if(t)
{
- return true;
+ return true;
}
ParamDeclList pdl = parameters();
for(ParamDeclList::const_iterator i = pdl.begin(); i != pdl.end(); ++i)
{
- if((*i)->isOutParam())
- {
- return true;
- }
+ if((*i)->isOutParam())
+ {
+ return true;
+ }
}
if(!throws().empty())
{
@@ -4578,9 +4578,9 @@ Slice::Operation::visit(ParserVisitor* visitor, bool)
}
Slice::Operation::Operation(const ContainerPtr& container,
- const string& name,
- const TypePtr& returnType,
- Mode mode) :
+ const string& name,
+ const TypePtr& returnType,
+ Mode mode) :
SyntaxTreeBase(container->unit()),
Contained(container, name),
Container(container->unit()),
@@ -4589,23 +4589,23 @@ Slice::Operation::Operation(const ContainerPtr& container,
{
if(_unit->profile() == IceE)
{
- ClassDefPtr cl = ClassDefPtr::dynamicCast(this->container());
- assert(cl);
- if(!cl->isLocal())
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(returnType);
- if((builtin && builtin->kind() == Builtin::KindObject))
- {
- string msg = "Method `" + name + "' cannot return an object by value.";
- _unit->error(msg);
- }
- ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(returnType);
- if(classDecl != 0 && !classDecl->isLocal())
- {
- string msg = "Method `" + name + "' cannot return an object by value.";
- _unit->error(msg);
- }
- }
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(this->container());
+ assert(cl);
+ if(!cl->isLocal())
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(returnType);
+ if((builtin && builtin->kind() == Builtin::KindObject))
+ {
+ string msg = "Method `" + name + "' cannot return an object by value.";
+ _unit->error(msg);
+ }
+ ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(returnType);
+ if(classDecl != 0 && !classDecl->isLocal())
+ {
+ string msg = "Method `" + name + "' cannot return an object by value.";
+ _unit->error(msg);
+ }
+ }
}
}
@@ -4637,7 +4637,7 @@ Slice::ParamDecl::uses(const ContainedPtr& contained) const
ContainedPtr contained2 = ContainedPtr::dynamicCast(_type);
if(contained2 && contained2 == contained)
{
- return true;
+ return true;
}
return false;
@@ -4685,7 +4685,7 @@ Slice::DataMember::uses(const ContainedPtr& contained) const
ContainedPtr contained2 = ContainedPtr::dynamicCast(_type);
if(contained2 && contained2 == contained)
{
- return true;
+ return true;
}
return false;
@@ -4716,7 +4716,7 @@ Slice::DataMember::DataMember(const ContainerPtr& container, const string& name,
UnitPtr
Slice::Unit::createUnit(bool ignRedefs, bool all, bool allowIcePrefix, bool caseSensitive,
- const StringList& defaultGlobalMetadata)
+ const StringList& defaultGlobalMetadata)
{
return new Unit(ignRedefs, all, allowIcePrefix, caseSensitive, defaultGlobalMetadata);
}
@@ -4746,32 +4746,32 @@ Slice::Unit::setComment(const string& comment)
string::size_type end = 0;
while(true)
{
- string::size_type begin = comment.find_first_not_of(" \t\r\n*", end);
- if(begin == string::npos)
- {
- break;
- }
-
- end = comment.find('\n', begin);
- if(end != string::npos)
- {
- if(end + 1 > begin)
- {
- _currentComment += comment.substr(begin, end + 1 - begin);
- }
- }
- else
- {
- end = comment.find_last_not_of(" \t\r\n*");
- if(end != string::npos)
- {
- if(end + 1 > begin)
- {
- _currentComment += comment.substr(begin, end + 1 - begin);
- }
- }
- break;
- }
+ string::size_type begin = comment.find_first_not_of(" \t\r\n*", end);
+ if(begin == string::npos)
+ {
+ break;
+ }
+
+ end = comment.find('\n', begin);
+ if(end != string::npos)
+ {
+ if(end + 1 > begin)
+ {
+ _currentComment += comment.substr(begin, end + 1 - begin);
+ }
+ }
+ else
+ {
+ end = comment.find_last_not_of(" \t\r\n*");
+ if(end != string::npos)
+ {
+ if(end + 1 > begin)
+ {
+ _currentComment += comment.substr(begin, end + 1 - begin);
+ }
+ }
+ break;
+ }
}
}
@@ -4814,12 +4814,12 @@ Slice::Unit::scanPosition(const char* s)
{
assert(*s == '#');
- string line(s + 1); // Skip leading #
+ string line(s + 1); // Skip leading #
eraseWhiteSpace(line);
- if(line.find("line", 0) == 0) // Erase optional "line"
+ if(line.find("line", 0) == 0) // Erase optional "line"
{
line.erase(0, 4);
- eraseWhiteSpace(line);
+ eraseWhiteSpace(line);
}
string::size_type idx;
@@ -4829,7 +4829,7 @@ Slice::Unit::scanPosition(const char* s)
idx = line.find_first_of(" \t\r"); // Erase line number
if(idx != string::npos)
{
- line.erase(0, idx);
+ line.erase(0, idx);
}
eraseWhiteSpace(line);
@@ -4843,71 +4843,71 @@ Slice::Unit::scanPosition(const char* s)
idx = line.find_last_of(" \t\r");
if(idx != string::npos)
{
- ++idx;
- if(line.substr(idx) == "1")
- {
- type = Push;
- line.erase(idx);
- eraseWhiteSpace(line);
+ ++idx;
+ if(line.substr(idx) == "1")
+ {
+ type = Push;
+ line.erase(idx);
+ eraseWhiteSpace(line);
- }
- else if(line.substr(idx) == "2")
- {
- type = Pop;
- line.erase(idx);
- eraseWhiteSpace(line);
- }
+ }
+ else if(line.substr(idx) == "2")
+ {
+ type = Pop;
+ line.erase(idx);
+ eraseWhiteSpace(line);
+ }
}
string currentFile;
if(!line.empty())
{
- if(line[0] == '"')
- {
- idx = line.rfind('"');
- if(idx != string::npos)
- {
- currentFile = line.substr(1, idx - 1);
- }
- }
- else
- {
- currentFile = line;
- }
+ if(line[0] == '"')
+ {
+ idx = line.rfind('"');
+ if(idx != string::npos)
+ {
+ currentFile = line.substr(1, idx - 1);
+ }
+ }
+ else
+ {
+ currentFile = line;
+ }
}
switch(type)
{
- case Push:
- {
- if(++_currentIncludeLevel == 1)
- {
- if(find(_includeFiles.begin(), _includeFiles.end(), currentFile) == _includeFiles.end())
- {
- _includeFiles.push_back(currentFile);
- }
- }
- pushDefinitionContext();
- _currentComment = "";
- break;
- }
- case Pop:
- {
- --_currentIncludeLevel;
- popDefinitionContext();
- _currentComment = "";
- break;
- }
+ case Push:
+ {
+ if(++_currentIncludeLevel == 1)
+ {
+ if(find(_includeFiles.begin(), _includeFiles.end(), currentFile) == _includeFiles.end())
+ {
+ _includeFiles.push_back(currentFile);
+ }
+ }
+ pushDefinitionContext();
+ _currentComment = "";
+ break;
+ }
+ case Pop:
+ {
+ --_currentIncludeLevel;
+ popDefinitionContext();
+ _currentComment = "";
+ break;
+ }
default:
- {
- break; // Do nothing
- }
+ {
+ break; // Do nothing
+ }
}
if(!currentFile.empty())
{
- DefinitionContextPtr dc = currentDefinitionContext();
- assert(dc);
- dc->setFilename(currentFile);
+ DefinitionContextPtr dc = currentDefinitionContext();
+ assert(dc);
+ dc->setFilename(currentFile);
}
}
@@ -4916,11 +4916,11 @@ Slice::Unit::currentIncludeLevel() const
{
if(_all)
{
- return 0;
+ return 0;
}
else
{
- return _currentIncludeLevel;
+ return _currentIncludeLevel;
}
}
@@ -4935,8 +4935,8 @@ Slice::Unit::addGlobalMetaData(const StringList& metaData)
}
else
{
- StringList l = dc->getMetaData();
- copy(metaData.begin(), metaData.end(), back_inserter(l));
+ StringList l = dc->getMetaData();
+ copy(metaData.begin(), metaData.end(), back_inserter(l));
dc->setMetaData(l);
}
}
@@ -5034,7 +5034,7 @@ Slice::Unit::addContent(const ContainedPtr& contained)
string scoped = contained->scoped();
if(!caseSensitive())
{
- toLower(scoped);
+ toLower(scoped);
}
_contentMap[scoped].push_back(contained);
}
@@ -5045,18 +5045,18 @@ Slice::Unit::removeContent(const ContainedPtr& contained)
string scoped = contained->scoped();
if(!caseSensitive())
{
- toLower(scoped);
+ toLower(scoped);
}
map<string, ContainedList>::iterator p = _contentMap.find(scoped);
assert(p != _contentMap.end());
ContainedList::iterator q;
for(q = p->second.begin(); q != p->second.end(); ++q)
{
- if(q->get() == contained.get())
- {
- p->second.erase(q);
- return;
- }
+ if(q->get() == contained.get())
+ {
+ p->second.erase(q);
+ return;
+ }
}
assert(false);
}
@@ -5070,17 +5070,17 @@ Slice::Unit::findContents(const string& scoped) const
string name = scoped;
if(!_unit->caseSensitive())
{
- toLower(name);
+ toLower(name);
}
map<string, ContainedList>::const_iterator p = _contentMap.find(name);
if(p != _contentMap.end())
{
- return p->second;
+ return p->second;
}
else
{
- return ContainedList();
+ return ContainedList();
}
}
@@ -5090,18 +5090,18 @@ Slice::Unit::findDerivedClasses(const ClassDefPtr& cl) const
ClassList derived;
for(map<string, ContainedList>::const_iterator p = _contentMap.begin(); p != _contentMap.end(); ++p)
{
- for(ContainedList::const_iterator q = p->second.begin(); q != p->second.end(); ++q)
- {
- ClassDefPtr r = ClassDefPtr::dynamicCast(*q);
- if(r)
- {
- ClassList bases = r->bases();
- if(find(bases.begin(), bases.end(), cl) != bases.end())
- {
- derived.push_back(r);
- }
- }
- }
+ for(ContainedList::const_iterator q = p->second.begin(); q != p->second.end(); ++q)
+ {
+ ClassDefPtr r = ClassDefPtr::dynamicCast(*q);
+ if(r)
+ {
+ ClassList bases = r->bases();
+ if(find(bases.begin(), bases.end(), cl) != bases.end())
+ {
+ derived.push_back(r);
+ }
+ }
+ }
}
derived.sort();
derived.unique();
@@ -5114,18 +5114,18 @@ Slice::Unit::findDerivedExceptions(const ExceptionPtr& ex) const
ExceptionList derived;
for(map<string, ContainedList>::const_iterator p = _contentMap.begin(); p != _contentMap.end(); ++p)
{
- for(ContainedList::const_iterator q = p->second.begin(); q != p->second.end(); ++q)
- {
- ExceptionPtr r = ExceptionPtr::dynamicCast(*q);
- if(r)
- {
- ExceptionPtr base = r->base();
- if(base && base == ex)
- {
- derived.push_back(r);
- }
- }
- }
+ for(ContainedList::const_iterator q = p->second.begin(); q != p->second.end(); ++q)
+ {
+ ExceptionPtr r = ExceptionPtr::dynamicCast(*q);
+ if(r)
+ {
+ ExceptionPtr base = r->base();
+ if(base && base == ex)
+ {
+ derived.push_back(r);
+ }
+ }
+ }
}
derived.sort();
derived.unique();
@@ -5138,13 +5138,13 @@ Slice::Unit::findUsedBy(const ContainedPtr& contained) const
ContainedList usedBy;
for(map<string, ContainedList>::const_iterator p = _contentMap.begin(); p != _contentMap.end(); ++p)
{
- for(ContainedList::const_iterator q = p->second.begin(); q != p->second.end(); ++q)
- {
- if((*q)->uses(contained))
- {
- usedBy.push_back(*q);
- }
- }
+ for(ContainedList::const_iterator q = p->second.begin(); q != p->second.end(); ++q)
+ {
+ if((*q)->uses(contained))
+ {
+ usedBy.push_back(*q);
+ }
+ }
}
usedBy.sort();
usedBy.unique();
@@ -5156,19 +5156,19 @@ Slice::Unit::usesProxies() const
{
for(map<string, ContainedList>::const_iterator p = _contentMap.begin(); p != _contentMap.end(); ++p)
{
- for(ContainedList::const_iterator q = p->second.begin(); q != p->second.end(); ++q)
- {
- ClassDeclPtr decl = ClassDeclPtr::dynamicCast(*q);
- if(decl && !decl->isLocal())
- {
- return true;
- }
- }
+ for(ContainedList::const_iterator q = p->second.begin(); q != p->second.end(); ++q)
+ {
+ ClassDeclPtr decl = ClassDeclPtr::dynamicCast(*q);
+ if(decl && !decl->isLocal())
+ {
+ return true;
+ }
+ }
}
if(_builtins.find(Builtin::KindObjectProxy) != _builtins.end())
{
- return true;
+ return true;
}
return false;
@@ -5179,30 +5179,30 @@ Slice::Unit::usesNonLocals() const
{
for(map<string, ContainedList>::const_iterator p = _contentMap.begin(); p != _contentMap.end(); ++p)
{
- for(ContainedList::const_iterator q = p->second.begin(); q != p->second.end(); ++q)
- {
- ConstructedPtr constr = ConstructedPtr::dynamicCast(*q);
- if(constr && !constr->isLocal())
- {
- return true;
- }
+ for(ContainedList::const_iterator q = p->second.begin(); q != p->second.end(); ++q)
+ {
+ ConstructedPtr constr = ConstructedPtr::dynamicCast(*q);
+ if(constr && !constr->isLocal())
+ {
+ return true;
+ }
- ExceptionPtr exc = ExceptionPtr::dynamicCast(*q);
- if(exc && !exc->isLocal())
- {
- return true;
- }
- }
+ ExceptionPtr exc = ExceptionPtr::dynamicCast(*q);
+ if(exc && !exc->isLocal())
+ {
+ return true;
+ }
+ }
}
if(_builtins.find(Builtin::KindObject) != _builtins.end())
{
- return true;
+ return true;
}
if(_builtins.find(Builtin::KindObjectProxy) != _builtins.end())
{
- return true;
+ return true;
}
return false;
@@ -5213,14 +5213,14 @@ Slice::Unit::usesConsts() const
{
for(map<string, ContainedList>::const_iterator p = _contentMap.begin(); p != _contentMap.end(); ++p)
{
- for(ContainedList::const_iterator q = p->second.begin(); q != p->second.end(); ++q)
- {
- ConstPtr cd = ConstPtr::dynamicCast(*q);
- if(cd)
- {
- return true;
- }
- }
+ for(ContainedList::const_iterator q = p->second.begin(); q != p->second.end(); ++q)
+ {
+ ConstPtr cd = ConstPtr::dynamicCast(*q);
+ if(cd)
+ {
+ return true;
+ }
+ }
}
return false;
@@ -5257,15 +5257,15 @@ Slice::Unit::parse(FILE* file, bool debug, Slice::FeatureProfile profile)
int status = slice_parse();
if(_errors)
{
- status = EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
if(status == EXIT_FAILURE)
{
- while(!_containerStack.empty())
- {
- popContainer();
- }
+ while(!_containerStack.empty())
+ {
+ popContainer();
+ }
while(!_definitionContextStack.empty())
{
popDefinitionContext();
@@ -5273,8 +5273,8 @@ Slice::Unit::parse(FILE* file, bool debug, Slice::FeatureProfile profile)
}
else
{
- assert(_containerStack.size() == 1);
- popContainer();
+ assert(_containerStack.size() == 1);
+ popContainer();
assert(_definitionContextStack.size() == 1);
popDefinitionContext();
}
@@ -5296,8 +5296,8 @@ Slice::Unit::visit(ParserVisitor* visitor, bool all)
{
if(visitor->visitUnitStart(this))
{
- Container::visit(visitor, all);
- visitor->visitUnitEnd(this);
+ Container::visit(visitor, all);
+ visitor->visitUnitEnd(this);
}
}
@@ -5307,7 +5307,7 @@ Slice::Unit::builtin(Builtin::Kind kind)
map<Builtin::Kind, BuiltinPtr>::const_iterator p = _builtins.find(kind);
if(p != _builtins.end())
{
- return p->second;
+ return p->second;
}
BuiltinPtr builtin = new Builtin(this, kind);
_builtins.insert(make_pair(kind, builtin));
@@ -5315,7 +5315,7 @@ Slice::Unit::builtin(Builtin::Kind kind)
}
Slice::Unit::Unit(bool ignRedefs, bool all, bool allowIcePrefix, bool caseSensitive,
- const StringList& defaultGlobalMetadata) :
+ const StringList& defaultGlobalMetadata) :
SyntaxTreeBase(0),
Container(0),
_ignRedefs(ignRedefs),
@@ -5354,24 +5354,24 @@ Slice::CICompare::operator()(const string& s1, const string& s2) const
string::const_iterator p2 = s2.begin();
while(p1 != s1.end() && p2 != s2.end() && ::tolower(*p1) == ::tolower(*p2))
{
- ++p1;
- ++p2;
+ ++p1;
+ ++p2;
}
if(p1 == s1.end() && p2 == s2.end())
{
- return false;
+ return false;
}
else if(p1 == s1.end())
{
- return true;
+ return true;
}
else if(p2 == s2.end())
{
- return false;
+ return false;
}
else
{
- return ::tolower(*p1) < ::tolower(*p2);
+ return ::tolower(*p1) < ::tolower(*p2);
}
}
diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp
index 69a5e30864b..e52188a4a7e 100644
--- a/cpp/src/Slice/Preprocessor.cpp
+++ b/cpp/src/Slice/Preprocessor.cpp
@@ -34,7 +34,7 @@ Slice::Preprocessor::~Preprocessor()
{
if(_cppHandle)
{
- close();
+ close();
}
}
@@ -46,7 +46,7 @@ Slice::Preprocessor::getBaseName()
string::size_type pos = base.rfind('.');
if(pos != string::npos)
{
- base.erase(pos);
+ base.erase(pos);
}
return base;
}
@@ -68,19 +68,19 @@ Slice::Preprocessor::preprocess(bool keepComments)
{
if(!checkInputFile())
{
- return 0;
+ return 0;
}
string cmd = searchIceCpp();
if(cmd.empty())
{
- return 0;
+ return 0;
}
if(keepComments)
{
- cmd += " -C";
+ cmd += " -C";
}
cmd += " " + _args + " \"" + _fileName + "\"";
@@ -101,14 +101,14 @@ Slice::Preprocessor::printMakefileDependencies(Language lang)
{
if(!checkInputFile())
{
- return;
+ return;
}
string cmd = searchIceCpp();
if(cmd.empty())
{
- return;
+ return;
}
cmd += " -M " + _args + " \"" + _fileName + "\"";
@@ -126,17 +126,17 @@ Slice::Preprocessor::printMakefileDependencies(Language lang)
* x.cpp: /path/x.ice /path/y.ice
*
* x.cpp: /path/x.ice \
- * /path/y.ice
+ * /path/y.ice
*
* x.cpp: /path/x.ice /path/y.ice \
- * /path/z.ice
+ * /path/z.ice
*
* x.cpp: \
- * /path/x.ice
+ * /path/x.ice
*
* x.cpp: \
- * /path/x.ice \
- * /path/y.ice
+ * /path/x.ice \
+ * /path/y.ice
*
* Spaces embedded within filenames are escaped with a backslash. Note that
* Windows filenames may contain colons.
@@ -145,16 +145,16 @@ Slice::Preprocessor::printMakefileDependencies(Language lang)
switch(lang)
{
case CPlusPlus:
- {
- char buf[1024];
- while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
- {
- fputs(buf, stdout);
- }
- break;
- }
- case Java:
- {
+ {
+ char buf[1024];
+ while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
+ {
+ fputs(buf, stdout);
+ }
+ break;
+ }
+ case Java:
+ {
//
// We want to shift the files left one position, so that
// "x.cpp: x.ice y.ice" becomes "x.ice: y.ice".
@@ -163,9 +163,9 @@ Slice::Preprocessor::printMakefileDependencies(Language lang)
// all of the output into one string before manipulating it.
//
string deps;
- char buf[1024];
- while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
- {
+ char buf[1024];
+ while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
+ {
deps.append(buf, strlen(buf));
}
@@ -209,75 +209,75 @@ Slice::Preprocessor::printMakefileDependencies(Language lang)
}
fputs(deps.c_str(), stdout);
- break;
- }
- case CSharp:
- {
- //
- // Change .cpp suffix to .cs suffix.
- //
- char buf[1024];
- while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
- {
- char* dot;
- char* colon = strchr(buf, ':');
- if(colon != NULL)
- {
- *colon = '\0';
- dot = strrchr(buf, '.');
- *colon = ':';
- if(dot != NULL)
- {
- if(strncmp(dot, ".cpp:", 5) == 0)
- {
- *dot = '\0';
- fputs(buf, stdout);
- fputs(".cs", stdout);
- fputs(colon, stdout);
- continue;
- }
- }
- }
- fputs(buf, stdout);
- }
- break;
- }
- case VisualBasic:
- {
- //
- // Change .cpp suffix to .vb suffix.
- //
- char buf[1024];
- while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
- {
- char* dot;
- char* colon = strchr(buf, ':');
- if(colon != NULL)
- {
- *colon = '\0';
- dot = strrchr(buf, '.');
- *colon = ':';
- if(dot != NULL)
- {
- if(strncmp(dot, ".cpp:", 5) == 0)
- {
- *dot = '\0';
- fputs(buf, stdout);
- fputs(".vb", stdout);
- fputs(colon, stdout);
- continue;
- }
- }
- }
- fputs(buf, stdout);
- }
- break;
- }
- default:
- {
- abort();
- break;
- }
+ break;
+ }
+ case CSharp:
+ {
+ //
+ // Change .cpp suffix to .cs suffix.
+ //
+ char buf[1024];
+ while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
+ {
+ char* dot;
+ char* colon = strchr(buf, ':');
+ if(colon != NULL)
+ {
+ *colon = '\0';
+ dot = strrchr(buf, '.');
+ *colon = ':';
+ if(dot != NULL)
+ {
+ if(strncmp(dot, ".cpp:", 5) == 0)
+ {
+ *dot = '\0';
+ fputs(buf, stdout);
+ fputs(".cs", stdout);
+ fputs(colon, stdout);
+ continue;
+ }
+ }
+ }
+ fputs(buf, stdout);
+ }
+ break;
+ }
+ case VisualBasic:
+ {
+ //
+ // Change .cpp suffix to .vb suffix.
+ //
+ char buf[1024];
+ while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
+ {
+ char* dot;
+ char* colon = strchr(buf, ':');
+ if(colon != NULL)
+ {
+ *colon = '\0';
+ dot = strrchr(buf, '.');
+ *colon = ':';
+ if(dot != NULL)
+ {
+ if(strncmp(dot, ".cpp:", 5) == 0)
+ {
+ *dot = '\0';
+ fputs(buf, stdout);
+ fputs(".vb", stdout);
+ fputs(colon, stdout);
+ continue;
+ }
+ }
+ }
+ fputs(buf, stdout);
+ }
+ break;
+ }
+ default:
+ {
+ abort();
+ break;
+ }
}
}
@@ -292,7 +292,7 @@ Slice::Preprocessor::close()
if(WIFEXITED(status) && WEXITSTATUS(status) != 0)
{
- return false;
+ return false;
}
#else
int status = _pclose(_cppHandle);
@@ -300,7 +300,7 @@ Slice::Preprocessor::close()
if(status != 0)
{
- return false;
+ return false;
}
#endif
@@ -315,20 +315,20 @@ Slice::Preprocessor::checkInputFile()
string::size_type pos = base.rfind('.');
if(pos != string::npos)
{
- suffix = base.substr(pos);
- transform(suffix.begin(), suffix.end(), suffix.begin(), ::tolower);
+ suffix = base.substr(pos);
+ transform(suffix.begin(), suffix.end(), suffix.begin(), ::tolower);
}
if(suffix != ".ice")
{
- cerr << _path << ": input files must end with `.ice'" << endl;
- return false;
+ cerr << _path << ": input files must end with `.ice'" << endl;
+ return false;
}
ifstream test(_fileName.c_str());
if(!test)
{
- cerr << _path << ": can't open `" << _fileName << "' for reading" << endl;
- return false;
+ cerr << _path << ": can't open `" << _fileName << "' for reading" << endl;
+ return false;
}
test.close();
@@ -347,21 +347,21 @@ Slice::Preprocessor::searchIceCpp()
string::size_type pos = _path.find_last_of("/\\");
if(pos != string::npos)
{
- string path = _path.substr(0, pos + 1);
- path += icecpp;
+ string path = _path.substr(0, pos + 1);
+ path += icecpp;
- struct stat st;
- if(stat(path.c_str(), &st) == 0)
- {
+ struct stat st;
+ if(stat(path.c_str(), &st) == 0)
+ {
#ifndef _WIN32
- if(st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
+ if(st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))
#else
- if(st.st_mode & (S_IEXEC))
+ if(st.st_mode & (S_IEXEC))
#endif
- {
- return path;
- }
- }
+ {
+ return path;
+ }
+ }
}
return icecpp;
diff --git a/cpp/src/Slice/PythonUtil.cpp b/cpp/src/Slice/PythonUtil.cpp
index c8cd601580b..426ceff6949 100644
--- a/cpp/src/Slice/PythonUtil.cpp
+++ b/cpp/src/Slice/PythonUtil.cpp
@@ -144,7 +144,7 @@ private:
string fixedName;
TypePtr type;
bool inherited;
- StringList metaData;
+ StringList metaData;
};
typedef list<MemberInfo> MemberInfoList;
@@ -222,7 +222,7 @@ getDictLookup(const ContainedPtr& cont, const string& suffix = string())
string package = Slice::Python::getPackageMetadata(cont);
if(!package.empty())
{
- scope = package + "." + scope;
+ scope = package + "." + scope;
}
return "_M_" + scope + "__dict__.has_key('" + suffix + Slice::Python::fixIdent(cont->name()) + "')";
@@ -361,15 +361,15 @@ Slice::Python::CodeVisitor::visitClassDecl(const ClassDeclPtr& p)
string scoped = p->scoped();
if(_classHistory.count(scoped) == 0)
{
- _out << sp << nl << "if not " << getDictLookup(p) << ':';
- _out.inc();
+ _out << sp << nl << "if not " << getDictLookup(p) << ':';
+ _out.inc();
string type = getAbsolute(p, "_t_");
_out << nl << "_M_" << type << " = IcePy.declareClass('" << scoped << "')";
- if(!p->isLocal())
- {
- _out << nl << "_M_" << type << "Prx = IcePy.declareProxy('" << scoped << "')";
- }
- _out.dec();
+ if(!p->isLocal())
+ {
+ _out << nl << "_M_" << type << "Prx = IcePy.declareProxy('" << scoped << "')";
+ }
+ _out.dec();
_classHistory.insert(scoped); // Avoid redundant declarations.
}
}
@@ -688,10 +688,10 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
if(_classHistory.count(scoped) == 0 && p->canBeCyclic())
{
- //
- // Emit a forward declaration for the class in case a data member refers to this type.
- //
- _out << sp << nl << "_M_" << type << " = IcePy.declareClass('" << scoped << "')";
+ //
+ // Emit a forward declaration for the class in case a data member refers to this type.
+ //
+ _out << sp << nl << "_M_" << type << " = IcePy.declareClass('" << scoped << "')";
}
DataMemberList members = p->dataMembers();
@@ -700,11 +700,11 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << ", " << (p->isAbstract() ? "True" : "False") << ", ";
if(!base)
{
- _out << "None";
+ _out << "None";
}
else
{
- _out << "_M_" << getAbsolute(base, "_t_");
+ _out << "_M_" << getAbsolute(base, "_t_");
}
_out << ", (";
//
@@ -713,19 +713,19 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
int interfaceCount = 0;
for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
{
- if((*q)->isInterface())
- {
- if(interfaceCount > 0)
- {
- _out << ", ";
- }
- _out << "_M_" << getAbsolute(*q, "_t_");
- ++interfaceCount;
- }
+ if((*q)->isInterface())
+ {
+ if(interfaceCount > 0)
+ {
+ _out << ", ";
+ }
+ _out << "_M_" << getAbsolute(*q, "_t_");
+ ++interfaceCount;
+ }
}
if(interfaceCount == 1)
{
- _out << ',';
+ _out << ',';
}
//
// Members
@@ -739,29 +739,29 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << "), (";
if(members.size() > 1)
{
- _out.inc();
- _out << nl;
+ _out.inc();
+ _out << nl;
}
for(DataMemberList::iterator r = members.begin(); r != members.end(); ++r)
{
- if(r != members.begin())
- {
- _out << ',' << nl;
- }
- _out << "('" << fixIdent((*r)->name()) << "', ";
- writeMetaData((*r)->getMetaData());
- _out << ", ";
- writeType((*r)->type());
- _out << ')';
+ if(r != members.begin())
+ {
+ _out << ',' << nl;
+ }
+ _out << "('" << fixIdent((*r)->name()) << "', ";
+ writeMetaData((*r)->getMetaData());
+ _out << ", ";
+ writeType((*r)->type());
+ _out << ')';
}
if(members.size() == 1)
{
- _out << ',';
+ _out << ',';
}
else if(members.size() > 1)
{
- _out.dec();
- _out << nl;
+ _out.dec();
+ _out << nl;
}
_out << "))";
_out << nl << name << ".ice_type = _M_" << type;
@@ -776,100 +776,100 @@ Slice::Python::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
//
if(!p->isLocal())
{
- if(!ops.empty())
- {
- _out << sp;
- }
- for(OperationList::iterator s = ops.begin(); s != ops.end(); ++s)
- {
- ParamDeclList params = (*s)->parameters();
- ParamDeclList::iterator t;
- int count;
-
- _out << nl << name << "._op_" << (*s)->name() << " = IcePy.Operation('" << (*s)->name() << "', "
- << getOperationMode((*s)->mode()) << ", " << getOperationMode((*s)->sendMode()) << ", "
- << ((p->hasMetaData("amd") || (*s)->hasMetaData("amd")) ? "True" : "False") << ", ";
- writeMetaData((*s)->getMetaData());
- _out << ", (";
- for(t = params.begin(), count = 0; t != params.end(); ++t)
- {
- if(!(*t)->isOutParam())
- {
- if(count > 0)
- {
- _out << ", ";
- }
- _out << '(';
- writeMetaData((*t)->getMetaData());
- _out << ", ";
- writeType((*t)->type());
- _out << ')';
- ++count;
- }
- }
- if(count == 1)
- {
- _out << ',';
- }
- _out << "), (";
- for(t = params.begin(), count = 0; t != params.end(); ++t)
- {
- if((*t)->isOutParam())
- {
- if(count > 0)
- {
- _out << ", ";
- }
- _out << '(';
- writeMetaData((*t)->getMetaData());
- _out << ", ";
- writeType((*t)->type());
- _out << ')';
- ++count;
- }
- }
- if(count == 1)
- {
- _out << ',';
- }
- _out << "), ";
- TypePtr returnType = (*s)->returnType();
- if(returnType)
- {
- writeType(returnType);
- }
- else
- {
- _out << "None";
- }
- _out << ", (";
- ExceptionList exceptions = (*s)->throws();
- for(ExceptionList::iterator u = exceptions.begin(); u != exceptions.end(); ++u)
- {
- if(u != exceptions.begin())
- {
- _out << ", ";
- }
- _out << "_M_" << getAbsolute(*u, "_t_");
- }
- if(exceptions.size() == 1)
- {
- _out << ',';
- }
- _out << "))";
-
- string deprecateMetadata;
- if((*s)->findMetaData("deprecate", deprecateMetadata) || p->findMetaData("deprecate", deprecateMetadata))
- {
- string msg;
- string::size_type pos = deprecateMetadata.find(':');
- if(pos != string::npos && pos < deprecateMetadata.size() - 1)
- {
- msg = deprecateMetadata.substr(pos + 1);
- }
- _out << nl << name << "._op_" << (*s)->name() << ".deprecate(\"" << msg << "\")";
- }
- }
+ if(!ops.empty())
+ {
+ _out << sp;
+ }
+ for(OperationList::iterator s = ops.begin(); s != ops.end(); ++s)
+ {
+ ParamDeclList params = (*s)->parameters();
+ ParamDeclList::iterator t;
+ int count;
+
+ _out << nl << name << "._op_" << (*s)->name() << " = IcePy.Operation('" << (*s)->name() << "', "
+ << getOperationMode((*s)->mode()) << ", " << getOperationMode((*s)->sendMode()) << ", "
+ << ((p->hasMetaData("amd") || (*s)->hasMetaData("amd")) ? "True" : "False") << ", ";
+ writeMetaData((*s)->getMetaData());
+ _out << ", (";
+ for(t = params.begin(), count = 0; t != params.end(); ++t)
+ {
+ if(!(*t)->isOutParam())
+ {
+ if(count > 0)
+ {
+ _out << ", ";
+ }
+ _out << '(';
+ writeMetaData((*t)->getMetaData());
+ _out << ", ";
+ writeType((*t)->type());
+ _out << ')';
+ ++count;
+ }
+ }
+ if(count == 1)
+ {
+ _out << ',';
+ }
+ _out << "), (";
+ for(t = params.begin(), count = 0; t != params.end(); ++t)
+ {
+ if((*t)->isOutParam())
+ {
+ if(count > 0)
+ {
+ _out << ", ";
+ }
+ _out << '(';
+ writeMetaData((*t)->getMetaData());
+ _out << ", ";
+ writeType((*t)->type());
+ _out << ')';
+ ++count;
+ }
+ }
+ if(count == 1)
+ {
+ _out << ',';
+ }
+ _out << "), ";
+ TypePtr returnType = (*s)->returnType();
+ if(returnType)
+ {
+ writeType(returnType);
+ }
+ else
+ {
+ _out << "None";
+ }
+ _out << ", (";
+ ExceptionList exceptions = (*s)->throws();
+ for(ExceptionList::iterator u = exceptions.begin(); u != exceptions.end(); ++u)
+ {
+ if(u != exceptions.begin())
+ {
+ _out << ", ";
+ }
+ _out << "_M_" << getAbsolute(*u, "_t_");
+ }
+ if(exceptions.size() == 1)
+ {
+ _out << ',';
+ }
+ _out << "))";
+
+ string deprecateMetadata;
+ if((*s)->findMetaData("deprecate", deprecateMetadata) || p->findMetaData("deprecate", deprecateMetadata))
+ {
+ string msg;
+ string::size_type pos = deprecateMetadata.find(':');
+ if(pos != string::npos && pos < deprecateMetadata.size() - 1)
+ {
+ msg = deprecateMetadata.substr(pos + 1);
+ }
+ _out << nl << name << "._op_" << (*s)->name() << ".deprecate(\"" << msg << "\")";
+ }
+ }
}
registerName(name);
@@ -993,17 +993,17 @@ Slice::Python::CodeVisitor::visitExceptionStart(const ExceptionPtr& p)
_out << ", ";
if(!base)
{
- _out << "None";
+ _out << "None";
}
else
{
- _out << "_M_" << getAbsolute(base, "_t_");
+ _out << "_M_" << getAbsolute(base, "_t_");
}
_out << ", (";
if(members.size() > 1)
{
- _out.inc();
- _out << nl;
+ _out.inc();
+ _out << nl;
}
//
// Data members are represented as a tuple:
@@ -1014,24 +1014,24 @@ Slice::Python::CodeVisitor::visitExceptionStart(const ExceptionPtr& p)
//
for(dmli = members.begin(); dmli != members.end(); ++dmli)
{
- if(dmli != members.begin())
- {
- _out << ',' << nl;
- }
- _out << "('" << fixIdent((*dmli)->name()) << "', ";
- writeMetaData((*dmli)->getMetaData());
- _out << ", ";
- writeType((*dmli)->type());
- _out << ')';
+ if(dmli != members.begin())
+ {
+ _out << ',' << nl;
+ }
+ _out << "('" << fixIdent((*dmli)->name()) << "', ";
+ writeMetaData((*dmli)->getMetaData());
+ _out << ", ";
+ writeType((*dmli)->type());
+ _out << ')';
}
if(members.size() == 1)
{
- _out << ',';
+ _out << ',';
}
else if(members.size() > 1)
{
- _out.dec();
- _out << nl;
+ _out.dec();
+ _out << nl;
}
_out << "))";
_out << nl << name << ".ice_type = _M_" << type;
@@ -1132,29 +1132,29 @@ Slice::Python::CodeVisitor::visitStructStart(const StructPtr& p)
//
if(memberList.size() > 1)
{
- _out.inc();
- _out << nl;
+ _out.inc();
+ _out << nl;
}
for(r = memberList.begin(); r != memberList.end(); ++r)
{
- if(r != memberList.begin())
- {
- _out << ',' << nl;
- }
- _out << "('" << r->fixedName << "', ";
- writeMetaData(r->metaData);
- _out << ", ";
- writeType(r->type);
- _out << ')';
+ if(r != memberList.begin())
+ {
+ _out << ',' << nl;
+ }
+ _out << "('" << r->fixedName << "', ";
+ writeMetaData(r->metaData);
+ _out << ", ";
+ writeType(r->type);
+ _out << ')';
}
if(memberList.size() == 1)
{
- _out << ',';
+ _out << ',';
}
else if(memberList.size() > 1)
{
- _out.dec();
- _out << nl;
+ _out.dec();
+ _out << nl;
}
_out << "))";
@@ -1271,21 +1271,21 @@ Slice::Python::CodeVisitor::visitEnum(const EnumPtr& p)
// Emit the type information.
//
_out << sp << nl << "_M_" << getAbsolute(p, "_t_") << " = IcePy.defineEnum('" << scoped << "', " << name
- << ", ";
+ << ", ";
writeMetaData(p->getMetaData());
_out << ", (";
for(q = enums.begin(); q != enums.end(); ++q)
{
- if(q != enums.begin())
- {
- _out << ", ";
- }
- string fixedEnum = fixIdent((*q)->name());
- _out << name << '.' << fixedEnum;
+ if(q != enums.begin())
+ {
+ _out << ", ";
+ }
+ string fixedEnum = fixIdent((*q)->name());
+ _out << name << '.' << fixedEnum;
}
if(enums.size() == 1)
{
- _out << ',';
+ _out << ',';
}
_out << "))";
@@ -1400,13 +1400,13 @@ Slice::Python::CodeVisitor::visitConst(const ConstPtr& p)
if(charSet.find(*c) == charSet.end())
{
unsigned char uc = *c; // Char may be signed, so make it positive.
- stringstream s;
+ stringstream s;
s << "\\"; // Print as octal if not in basic source character set.
s.flags(ios_base::oct);
s.width(3);
s.fill('0');
s << static_cast<unsigned>(uc);
- _out << s.str();
+ _out << s.str();
}
else
{
@@ -1653,19 +1653,19 @@ Slice::Python::CodeVisitor::writeMetaData(const StringList& meta)
_out << '(';
for(StringList::const_iterator p = meta.begin(); p != meta.end(); ++p)
{
- if(p->find("python:") == 0)
- {
- if(i > 0)
- {
- _out << ", ";
- }
- _out << "'" << *p << "'";
- ++i;
- }
+ if(p->find("python:") == 0)
+ {
+ if(i > 0)
+ {
+ _out << ", ";
+ }
+ _out << "'" << *p << "'";
+ ++i;
+ }
}
if(i == 1)
{
- _out << ',';
+ _out << ',';
}
_out << ')';
}
@@ -1677,14 +1677,14 @@ Slice::Python::CodeVisitor::getOperationMode(Slice::Operation::Mode mode)
switch(mode)
{
case Operation::Normal:
- result = "Ice.OperationMode.Normal";
- break;
+ result = "Ice.OperationMode.Normal";
+ break;
case Operation::Nonmutating:
- result = "Ice.OperationMode.Nonmutating";
- break;
+ result = "Ice.OperationMode.Nonmutating";
+ break;
case Operation::Idempotent:
- result = "Ice.OperationMode.Idempotent";
- break;
+ result = "Ice.OperationMode.Idempotent";
+ break;
}
return result;
}
@@ -1706,7 +1706,7 @@ Slice::Python::CodeVisitor::collectClassMembers(const ClassDefPtr& p, MemberInfo
m.fixedName = fixIdent((*q)->name());
m.type = (*q)->type();
m.inherited = inherited;
- m.metaData = (*q)->getMetaData();
+ m.metaData = (*q)->getMetaData();
allMembers.push_back(m);
}
}
@@ -1728,7 +1728,7 @@ Slice::Python::CodeVisitor::collectExceptionMembers(const ExceptionPtr& p, Membe
m.fixedName = fixIdent((*q)->name());
m.type = (*q)->type();
m.inherited = inherited;
- m.metaData = (*q)->getMetaData();
+ m.metaData = (*q)->getMetaData();
allMembers.push_back(m);
}
}
@@ -1988,10 +1988,10 @@ Slice::Python::MetaDataVisitor::visitModuleStart(const ModulePtr& p)
{
if(!ModulePtr::dynamicCast(p->container()))
{
- //
- // We only need to validate global metadata for top-level modules.
- //
- validateGlobal(p->definitionContext());
+ //
+ // We only need to validate global metadata for top-level modules.
+ //
+ validateGlobal(p->definitionContext());
}
reject(p);
return true;
@@ -2033,13 +2033,13 @@ Slice::Python::MetaDataVisitor::visitOperation(const OperationPtr& p)
TypePtr ret = p->returnType();
if(ret)
{
- validateSequence(dc, p->line(), ret, p->getMetaData());
+ validateSequence(dc, p->line(), ret, p->getMetaData());
}
ParamDeclList params = p->parameters();
for(ParamDeclList::iterator q = params.begin(); q != params.end(); ++q)
{
- validateSequence(dc, (*q)->line(), (*q)->type(), (*q)->getMetaData());
+ validateSequence(dc, (*q)->line(), (*q)->type(), (*q)->getMetaData());
}
}
@@ -2082,48 +2082,48 @@ Slice::Python::MetaDataVisitor::validateGlobal(const DefinitionContextPtr& dc)
for(StringList::const_iterator p = globalMetaData.begin(); p != globalMetaData.end(); ++p)
{
- string s = *p;
- if(_history.count(s) == 0)
- {
- if(s.find(prefix) == 0)
- {
- static const string packagePrefix = "python:package:";
- if(s.find(packagePrefix) != 0 || s.size() == packagePrefix.size())
- {
- cout << dc->filename() << ": warning: ignoring invalid global metadata `" << s << "'" << endl;
- }
- }
- _history.insert(s);
- }
+ string s = *p;
+ if(_history.count(s) == 0)
+ {
+ if(s.find(prefix) == 0)
+ {
+ static const string packagePrefix = "python:package:";
+ if(s.find(packagePrefix) != 0 || s.size() == packagePrefix.size())
+ {
+ cout << dc->filename() << ": warning: ignoring invalid global metadata `" << s << "'" << endl;
+ }
+ }
+ _history.insert(s);
+ }
}
}
void
Slice::Python::MetaDataVisitor::validateSequence(const DefinitionContextPtr& dc, const string& line,
- const TypePtr& type, const StringList& meta)
+ const TypePtr& type, const StringList& meta)
{
static const string prefix = "python:";
for(StringList::const_iterator p = meta.begin(); p != meta.end(); ++p)
{
string s = *p;
- if(s.find(prefix) == 0)
- {
- string::size_type pos = s.find(':', prefix.size());
- if(pos != string::npos && s.substr(prefix.size(), pos - prefix.size()) == "seq")
- {
- static const string seqPrefix = "python:seq:";
- string arg = s.substr(seqPrefix.size(), pos - seqPrefix.size());
- if(SequencePtr::dynamicCast(type))
- {
- if(arg == "tuple" || arg == "list" || arg == "default")
- {
- continue;
- }
- }
- }
- cout << dc->filename() << ":" << line << ": warning: ignoring metadata `" << s << "'" << endl;
- }
+ if(s.find(prefix) == 0)
+ {
+ string::size_type pos = s.find(':', prefix.size());
+ if(pos != string::npos && s.substr(prefix.size(), pos - prefix.size()) == "seq")
+ {
+ static const string seqPrefix = "python:seq:";
+ string arg = s.substr(seqPrefix.size(), pos - seqPrefix.size());
+ if(SequencePtr::dynamicCast(type))
+ {
+ if(arg == "tuple" || arg == "list" || arg == "default")
+ {
+ continue;
+ }
+ }
+ }
+ cout << dc->filename() << ":" << line << ": warning: ignoring metadata `" << s << "'" << endl;
+ }
}
}
@@ -2136,11 +2136,11 @@ Slice::Python::MetaDataVisitor::reject(const ContainedPtr& cont)
for(StringList::const_iterator p = localMetaData.begin(); p != localMetaData.end(); ++p)
{
- if(p->find(prefix) == 0)
- {
- DefinitionContextPtr dc = cont->definitionContext();
- assert(dc);
- cout << dc->filename() << ":" << cont->line() << ": warning: ignoring metadata `" << *p << "'" << endl;
- }
+ if(p->find(prefix) == 0)
+ {
+ DefinitionContextPtr dc = cont->definitionContext();
+ assert(dc);
+ cout << dc->filename() << ":" << cont->line() << ": warning: ignoring metadata `" << *p << "'" << endl;
+ }
}
}
diff --git a/cpp/src/Slice/RubyUtil.cpp b/cpp/src/Slice/RubyUtil.cpp
index 1a3703ae94c..5251e5db3f5 100644
--- a/cpp/src/Slice/RubyUtil.cpp
+++ b/cpp/src/Slice/RubyUtil.cpp
@@ -73,10 +73,10 @@ private:
struct MemberInfo
{
- string lowerName; // Mapped name beginning with a lower-case letter for use as the name of a local variable.
- string fixedName;
- TypePtr type;
- bool inherited;
+ string lowerName; // Mapped name beginning with a lower-case letter for use as the name of a local variable.
+ string fixedName;
+ TypePtr type;
+ bool inherited;
};
typedef list<MemberInfo> MemberInfoList;
@@ -105,14 +105,14 @@ lookupKwd(const string& name)
//
static const string keywordList[] =
{
- "BEGIN", "END", "alias", "and", "begin", "break", "case", "class", "clone", "def", "display", "do", "dup",
- "else", "elsif", "end", "ensure", "extend", "false", "for", "freeze", "hash", "if", "in", "inspect", "method",
- "methods", "module", "next", "new", "nil", "not", "or", "redo", "rescue", "retry", "return", "self", "send",
- "super", "taint", "then", "true", "undef", "unless", "untaint", "until", "when", "while", "yield"
+ "BEGIN", "END", "alias", "and", "begin", "break", "case", "class", "clone", "def", "display", "do", "dup",
+ "else", "elsif", "end", "ensure", "extend", "false", "for", "freeze", "hash", "if", "in", "inspect", "method",
+ "methods", "module", "next", "new", "nil", "not", "or", "redo", "rescue", "retry", "return", "self", "send",
+ "super", "taint", "then", "true", "undef", "unless", "untaint", "until", "when", "while", "yield"
};
bool found = binary_search(&keywordList[0],
- &keywordList[sizeof(keywordList) / sizeof(*keywordList)],
- name);
+ &keywordList[sizeof(keywordList) / sizeof(*keywordList)],
+ name);
return found ? "_" + name : name;
}
@@ -128,24 +128,24 @@ splitScopedName(const string& scoped)
string::size_type pos;
while((pos = scoped.find("::", next)) != string::npos)
{
- pos += 2;
- if(pos != scoped.size())
- {
- string::size_type endpos = scoped.find("::", pos);
- if(endpos != string::npos && endpos > pos)
- {
- ids.push_back(scoped.substr(pos, endpos - pos));
- }
- }
- next = pos;
+ pos += 2;
+ if(pos != scoped.size())
+ {
+ string::size_type endpos = scoped.find("::", pos);
+ if(endpos != string::npos && endpos > pos)
+ {
+ ids.push_back(scoped.substr(pos, endpos - pos));
+ }
+ }
+ next = pos;
}
if(next != scoped.size())
{
- ids.push_back(scoped.substr(next));
+ ids.push_back(scoped.substr(next));
}
else
{
- ids.push_back("");
+ ids.push_back("");
}
return ids;
@@ -183,17 +183,17 @@ Slice::Ruby::CodeVisitor::visitClassDecl(const ClassDeclPtr& p)
string scoped = p->scoped();
if(_classHistory.count(scoped) == 0)
{
- string name = "T_" + fixIdent(p->name(), IdentToUpper);
- _out << sp << nl << "if not defined?(" << getAbsolute(p, IdentToUpper, "T_") << ')';
- _out.inc();
- _out << nl << name << " = ::Ice::__declareClass('" << scoped << "')";
- if(!p->isLocal())
- {
- _out << nl << name << "Prx = ::Ice::__declareProxy('" << scoped << "')";
- }
- _out.dec();
- _out << nl << "end";
- _classHistory.insert(scoped); // Avoid redundant declarations.
+ string name = "T_" + fixIdent(p->name(), IdentToUpper);
+ _out << sp << nl << "if not defined?(" << getAbsolute(p, IdentToUpper, "T_") << ')';
+ _out.inc();
+ _out << nl << name << " = ::Ice::__declareClass('" << scoped << "')";
+ if(!p->isLocal())
+ {
+ _out << nl << name << "Prx = ::Ice::__declareProxy('" << scoped << "')";
+ }
+ _out.dec();
+ _out << nl << "end";
+ _classHistory.insert(scoped); // Avoid redundant declarations.
}
}
@@ -217,129 +217,129 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!p->isLocal())
{
- if(!bases.empty() && !bases.front()->isInterface())
- {
- base = bases.front();
- _out << nl << "include " << getAbsolute(bases.front(), IdentToUpper) << "_mixin";
- }
- else
- {
- _out << nl << "include ::Ice::Object_mixin";
- }
-
- //
- // ice_ids
- //
- ClassList allBases = p->allBases();
- StringList ids;
+ if(!bases.empty() && !bases.front()->isInterface())
+ {
+ base = bases.front();
+ _out << nl << "include " << getAbsolute(bases.front(), IdentToUpper) << "_mixin";
+ }
+ else
+ {
+ _out << nl << "include ::Ice::Object_mixin";
+ }
+
+ //
+ // ice_ids
+ //
+ ClassList allBases = p->allBases();
+ StringList ids;
#if defined(__IBMCPP__) && defined(NDEBUG)
//
// VisualAge C++ 6.0 does not see that ClassDef is a Contained,
// when inlining is on. The code below issues a warning: better
// than an error!
//
- transform(allBases.begin(), allBases.end(), back_inserter(ids),
- IceUtil::constMemFun<string,ClassDef>(&Contained::scoped));
+ transform(allBases.begin(), allBases.end(), back_inserter(ids),
+ IceUtil::constMemFun<string,ClassDef>(&Contained::scoped));
#else
- transform(allBases.begin(), allBases.end(), back_inserter(ids), IceUtil::constMemFun(&Contained::scoped));
+ transform(allBases.begin(), allBases.end(), back_inserter(ids), IceUtil::constMemFun(&Contained::scoped));
#endif
- StringList other;
- other.push_back(scoped);
- other.push_back("::Ice::Object");
- other.sort();
- ids.merge(other);
- ids.unique();
- _out << sp << nl << "def ice_ids(current=nil)";
- _out.inc();
- _out << nl << "[";
- for(StringList::iterator q = ids.begin(); q != ids.end(); ++q)
- {
- if(q != ids.begin())
- {
- _out << ", ";
- }
- _out << "'" << *q << "'";
- }
- _out << ']';
- _out.dec();
- _out << nl << "end";
-
- //
- // ice_id
- //
- _out << sp << nl << "def ice_id(current=nil)";
- _out.inc();
- _out << nl << "'" << scoped << "'";
- _out.dec();
- _out << nl << "end";
+ StringList other;
+ other.push_back(scoped);
+ other.push_back("::Ice::Object");
+ other.sort();
+ ids.merge(other);
+ ids.unique();
+ _out << sp << nl << "def ice_ids(current=nil)";
+ _out.inc();
+ _out << nl << "[";
+ for(StringList::iterator q = ids.begin(); q != ids.end(); ++q)
+ {
+ if(q != ids.begin())
+ {
+ _out << ", ";
+ }
+ _out << "'" << *q << "'";
+ }
+ _out << ']';
+ _out.dec();
+ _out << nl << "end";
+
+ //
+ // ice_id
+ //
+ _out << sp << nl << "def ice_id(current=nil)";
+ _out.inc();
+ _out << nl << "'" << scoped << "'";
+ _out.dec();
+ _out << nl << "end";
}
if(!ops.empty())
{
- //
- // Emit a comment for each operation.
- //
- _out << sp
- << nl << "#"
- << nl << "# Operation signatures."
- << nl << "#";
- for(oli = ops.begin(); oli != ops.end(); ++oli)
- {
- string fixedOpName = fixIdent((*oli)->name(), IdentNormal);
+ //
+ // Emit a comment for each operation.
+ //
+ _out << sp
+ << nl << "#"
+ << nl << "# Operation signatures."
+ << nl << "#";
+ for(oli = ops.begin(); oli != ops.end(); ++oli)
+ {
+ string fixedOpName = fixIdent((*oli)->name(), IdentNormal);
/* If AMI/AMD is ever implemented...
- if(!p->isLocal() && (p->hasMetaData("amd") || (*oli)->hasMetaData("amd")))
- {
- _out << nl << "# def " << fixedOpName << "_async(_cb";
-
- ParamDeclList params = (*oli)->parameters();
-
- for(ParamDeclList::iterator pli = params.begin(); pli != params.end(); ++pli)
- {
- if(!(*pli)->isOutParam())
- {
- _out << ", " << fixIdent((*pli)->name(), IdentToLower);
- }
- }
- if(!p->isLocal())
- {
- _out << ", current=nil";
- }
- _out << ")";
- }
- else
+ if(!p->isLocal() && (p->hasMetaData("amd") || (*oli)->hasMetaData("amd")))
+ {
+ _out << nl << "# def " << fixedOpName << "_async(_cb";
+
+ ParamDeclList params = (*oli)->parameters();
+
+ for(ParamDeclList::iterator pli = params.begin(); pli != params.end(); ++pli)
+ {
+ if(!(*pli)->isOutParam())
+ {
+ _out << ", " << fixIdent((*pli)->name(), IdentToLower);
+ }
+ }
+ if(!p->isLocal())
+ {
+ _out << ", current=nil";
+ }
+ _out << ")";
+ }
+ else
*/
- {
- _out << nl << "# def " << fixedOpName << "(";
-
- ParamDeclList params = (*oli)->parameters();
-
- bool first = true;
- for(ParamDeclList::iterator pli = params.begin(); pli != params.end(); ++pli)
- {
- if(!(*pli)->isOutParam())
- {
- if(first)
- {
- first = false;
- }
- else
- {
- _out << ", ";
- }
- _out << fixIdent((*pli)->name(), IdentToLower);
- }
- }
- if(!p->isLocal())
- {
- if(!first)
- {
- _out << ", ";
- }
- _out << "current=nil";
- }
- _out << ")";
- }
- }
+ {
+ _out << nl << "# def " << fixedOpName << "(";
+
+ ParamDeclList params = (*oli)->parameters();
+
+ bool first = true;
+ for(ParamDeclList::iterator pli = params.begin(); pli != params.end(); ++pli)
+ {
+ if(!(*pli)->isOutParam())
+ {
+ if(first)
+ {
+ first = false;
+ }
+ else
+ {
+ _out << ", ";
+ }
+ _out << fixIdent((*pli)->name(), IdentToLower);
+ }
+ }
+ if(!p->isLocal())
+ {
+ if(!first)
+ {
+ _out << ", ";
+ }
+ _out << "current=nil";
+ }
+ _out << ")";
+ }
+ }
}
//
@@ -357,15 +357,15 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
DataMemberList members = p->dataMembers();
if(!members.empty())
{
- _out << sp << nl << "attr_accessor ";
- for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q)
- {
- if(q != members.begin())
- {
- _out << ", ";
- }
- _out << ":" << fixIdent((*q)->name(), IdentNormal);
- }
+ _out << sp << nl << "attr_accessor ";
+ for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q)
+ {
+ if(q != members.begin())
+ {
+ _out << ", ";
+ }
+ _out << ":" << fixIdent((*q)->name(), IdentNormal);
+ }
}
_out.dec();
@@ -373,65 +373,65 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!p->isInterface())
{
- //
- // Class.
- //
- _out << nl << "class " << name;
- if(base)
- {
- _out << " < " << getAbsolute(base, IdentToUpper);
- }
- _out.inc();
- _out << nl << "include " << name << "_mixin";
-
- //
- // initialize
- //
- MemberInfoList allMembers;
- collectClassMembers(p, allMembers, false);
- bool inheritsMembers = false;
- if(!allMembers.empty())
- {
- _out << sp << nl << "def initialize";
- _out << spar;
- MemberInfoList::iterator q;
- for(q = allMembers.begin(); q != allMembers.end(); ++q)
- {
- ostringstream ostr;
- ostr << q->lowerName << '=' << getDefaultValue(q->type);
- _out << ostr.str();
- if(q->inherited)
- {
- inheritsMembers = true;
- }
- }
- _out << epar;
- _out.inc();
- if(inheritsMembers)
- {
- _out << nl << "super" << spar;
- for(q = allMembers.begin(); q != allMembers.end(); ++q)
- {
- if(q->inherited)
- {
- _out << q->lowerName;
- }
- }
- _out << epar;
- }
- for(q = allMembers.begin(); q != allMembers.end(); ++q)
- {
- if(!q->inherited)
- {
- _out << nl << '@' << q->fixedName << " = " << q->lowerName;
- }
- }
- _out.dec();
- _out << nl << "end";
- }
-
- _out.dec();
- _out << nl << "end"; // End of class.
+ //
+ // Class.
+ //
+ _out << nl << "class " << name;
+ if(base)
+ {
+ _out << " < " << getAbsolute(base, IdentToUpper);
+ }
+ _out.inc();
+ _out << nl << "include " << name << "_mixin";
+
+ //
+ // initialize
+ //
+ MemberInfoList allMembers;
+ collectClassMembers(p, allMembers, false);
+ bool inheritsMembers = false;
+ if(!allMembers.empty())
+ {
+ _out << sp << nl << "def initialize";
+ _out << spar;
+ MemberInfoList::iterator q;
+ for(q = allMembers.begin(); q != allMembers.end(); ++q)
+ {
+ ostringstream ostr;
+ ostr << q->lowerName << '=' << getDefaultValue(q->type);
+ _out << ostr.str();
+ if(q->inherited)
+ {
+ inheritsMembers = true;
+ }
+ }
+ _out << epar;
+ _out.inc();
+ if(inheritsMembers)
+ {
+ _out << nl << "super" << spar;
+ for(q = allMembers.begin(); q != allMembers.end(); ++q)
+ {
+ if(q->inherited)
+ {
+ _out << q->lowerName;
+ }
+ }
+ _out << epar;
+ }
+ for(q = allMembers.begin(); q != allMembers.end(); ++q)
+ {
+ if(!q->inherited)
+ {
+ _out << nl << '@' << q->fixedName << " = " << q->lowerName;
+ }
+ }
+ _out.dec();
+ _out << nl << "end";
+ }
+
+ _out.dec();
+ _out << nl << "end"; // End of class.
}
//
@@ -440,87 +440,87 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
//
if(!p->isLocal())
{
- _out << nl << "module " << name << "Prx_mixin";
- _out.inc();
- for(ClassList::iterator cli = bases.begin(); cli != bases.end(); ++cli)
- {
- _out << nl << "include " << getAbsolute(*cli, IdentToUpper) << "Prx_mixin";
- }
- for(oli = ops.begin(); oli != ops.end(); ++oli)
- {
- string fixedOpName = fixIdent((*oli)->name(), IdentNormal);
- if(fixedOpName == "checkedCast" || fixedOpName == "uncheckedCast")
- {
- fixedOpName.insert(0, "_");
- }
- TypePtr ret = (*oli)->returnType();
- ParamDeclList paramList = (*oli)->parameters();
- string inParams;
-
- for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
- {
- if(!(*q)->isOutParam())
- {
- if(!inParams.empty())
- {
- inParams.append(", ");
- }
- inParams.append(fixIdent((*q)->name(), IdentToLower));
- }
- }
-
- _out << sp << nl << "def " << fixedOpName << "(";
- if(!inParams.empty())
- {
- _out << inParams << ", ";
- }
- _out << "_ctx=nil)";
- _out.inc();
- _out << nl << name << "_mixin::OP_" << (*oli)->name() << ".invoke(self, [" << inParams;
- _out << "], _ctx)";
- _out.dec();
- _out << nl << "end";
-
- if(p->hasMetaData("ami") || (*oli)->hasMetaData("ami"))
- {
- _out << sp << nl << "def " << fixedOpName << "_async(_cb";
- if(!inParams.empty())
- {
- _out << ", " << inParams;
- }
- _out << ", _ctx=nil)";
- _out.inc();
- _out << nl << name << "_mixin::OP_" << (*oli)->name() << ".invokeAsync(self, _cb, [" << inParams;
- if(!inParams.empty() && inParams.find(',') == string::npos)
- {
- _out << ", ";
- }
- _out << "], _ctx)";
- _out.dec();
- _out << nl << "end";
- }
- }
- _out.dec();
- _out << nl << "end"; // End of mix-in module for proxy.
-
- _out << nl << "class " << name << "Prx < ::Ice::ObjectPrx";
- _out.inc();
- _out << nl << "include " << name << "Prx_mixin";
-
- _out << sp << nl << "def " << name << "Prx.checkedCast(proxy, facetOrCtx=nil, _ctx=nil)";
- _out.inc();
- _out << nl << "ice_checkedCast(proxy, '" << scoped << "', facetOrCtx, _ctx)";
- _out.dec();
- _out << nl << "end";
-
- _out << sp << nl << "def " << name << "Prx.uncheckedCast(proxy, facet='')";
- _out.inc();
- _out << nl << "ice_uncheckedCast(proxy, facet)";
- _out.dec();
- _out << nl << "end";
-
- _out.dec();
- _out << nl << "end"; // End of proxy class.
+ _out << nl << "module " << name << "Prx_mixin";
+ _out.inc();
+ for(ClassList::iterator cli = bases.begin(); cli != bases.end(); ++cli)
+ {
+ _out << nl << "include " << getAbsolute(*cli, IdentToUpper) << "Prx_mixin";
+ }
+ for(oli = ops.begin(); oli != ops.end(); ++oli)
+ {
+ string fixedOpName = fixIdent((*oli)->name(), IdentNormal);
+ if(fixedOpName == "checkedCast" || fixedOpName == "uncheckedCast")
+ {
+ fixedOpName.insert(0, "_");
+ }
+ TypePtr ret = (*oli)->returnType();
+ ParamDeclList paramList = (*oli)->parameters();
+ string inParams;
+
+ for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
+ {
+ if(!(*q)->isOutParam())
+ {
+ if(!inParams.empty())
+ {
+ inParams.append(", ");
+ }
+ inParams.append(fixIdent((*q)->name(), IdentToLower));
+ }
+ }
+
+ _out << sp << nl << "def " << fixedOpName << "(";
+ if(!inParams.empty())
+ {
+ _out << inParams << ", ";
+ }
+ _out << "_ctx=nil)";
+ _out.inc();
+ _out << nl << name << "_mixin::OP_" << (*oli)->name() << ".invoke(self, [" << inParams;
+ _out << "], _ctx)";
+ _out.dec();
+ _out << nl << "end";
+
+ if(p->hasMetaData("ami") || (*oli)->hasMetaData("ami"))
+ {
+ _out << sp << nl << "def " << fixedOpName << "_async(_cb";
+ if(!inParams.empty())
+ {
+ _out << ", " << inParams;
+ }
+ _out << ", _ctx=nil)";
+ _out.inc();
+ _out << nl << name << "_mixin::OP_" << (*oli)->name() << ".invokeAsync(self, _cb, [" << inParams;
+ if(!inParams.empty() && inParams.find(',') == string::npos)
+ {
+ _out << ", ";
+ }
+ _out << "], _ctx)";
+ _out.dec();
+ _out << nl << "end";
+ }
+ }
+ _out.dec();
+ _out << nl << "end"; // End of mix-in module for proxy.
+
+ _out << nl << "class " << name << "Prx < ::Ice::ObjectPrx";
+ _out.inc();
+ _out << nl << "include " << name << "Prx_mixin";
+
+ _out << sp << nl << "def " << name << "Prx.checkedCast(proxy, facetOrCtx=nil, _ctx=nil)";
+ _out.inc();
+ _out << nl << "ice_checkedCast(proxy, '" << scoped << "', facetOrCtx, _ctx)";
+ _out.dec();
+ _out << nl << "end";
+
+ _out << sp << nl << "def " << name << "Prx.uncheckedCast(proxy, facet='')";
+ _out.inc();
+ _out << nl << "ice_uncheckedCast(proxy, facet)";
+ _out.dec();
+ _out << nl << "end";
+
+ _out.dec();
+ _out << nl << "end"; // End of proxy class.
}
//
@@ -531,21 +531,21 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << nl << "T_" << name << " = ::Ice::__declareClass('" << scoped << "')";
if(!p->isLocal())
{
- _out << nl << "T_" << name << "Prx = ::Ice::__declareProxy('" << scoped << "')";
+ _out << nl << "T_" << name << "Prx = ::Ice::__declareProxy('" << scoped << "')";
}
_out.dec();
_out << nl << "end";
_classHistory.insert(scoped); // Avoid redundant declarations.
_out << sp << nl << "T_" << name << ".defineClass(" << (p->isInterface() ? string("nil") : name) << ", "
- << (p->isAbstract() ? "true" : "false") << ", ";
+ << (p->isAbstract() ? "true" : "false") << ", ";
if(!base)
{
- _out << "nil";
+ _out << "nil";
}
else
{
- _out << getAbsolute(base, IdentToUpper, "T_");
+ _out << getAbsolute(base, IdentToUpper, "T_");
}
_out << ", [";
//
@@ -554,19 +554,19 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
// TODO: Necessary?
//
{
- int interfaceCount = 0;
- for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
- {
- if((*q)->isInterface())
- {
- if(interfaceCount > 0)
- {
- _out << ", ";
- }
- _out << getAbsolute(*q, IdentToUpper, "T_");
- ++interfaceCount;
- }
- }
+ int interfaceCount = 0;
+ for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
+ {
+ if((*q)->isInterface())
+ {
+ if(interfaceCount > 0)
+ {
+ _out << ", ";
+ }
+ _out << getAbsolute(*q, IdentToUpper, "T_");
+ ++interfaceCount;
+ }
+ }
}
//
// Members
@@ -580,25 +580,25 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << "], [";
if(members.size() > 1)
{
- _out.inc();
- _out << nl;
+ _out.inc();
+ _out << nl;
}
{
- for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q)
- {
- if(q != members.begin())
- {
- _out << ',' << nl;
- }
- _out << "['" << fixIdent((*q)->name(), IdentNormal) << "', ";
- writeType((*q)->type());
- _out << ']';
- }
+ for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q)
+ {
+ if(q != members.begin())
+ {
+ _out << ',' << nl;
+ }
+ _out << "['" << fixIdent((*q)->name(), IdentNormal) << "', ";
+ writeType((*q)->type());
+ _out << ']';
+ }
}
if(members.size() > 1)
{
- _out.dec();
- _out << nl;
+ _out.dec();
+ _out << nl;
}
_out << "])";
_out << nl << name << "_mixin::ICE_TYPE = T_" << name;
@@ -613,106 +613,106 @@ Slice::Ruby::CodeVisitor::visitClassDefStart(const ClassDefPtr& p)
//
if(!p->isLocal())
{
- _out << sp << nl << "T_" << name << "Prx.defineProxy(" << name << "Prx, T_" << name << ')';
- _out << nl << name << "Prx::ICE_TYPE = T_" << name << "Prx";
-
- if(!ops.empty())
- {
- _out << sp;
- }
- for(OperationList::iterator s = ops.begin(); s != ops.end(); ++s)
- {
- ParamDeclList params = (*s)->parameters();
- ParamDeclList::iterator t;
- int count;
-
- _out << nl << name << "_mixin::OP_" << (*s)->name() << " = ::Ice::__defineOperation('"
- << (*s)->name() << "', ";
- switch((*s)->mode())
- {
- case Operation::Normal:
- _out << "::Ice::OperationMode::Normal";
- break;
- case Operation::Nonmutating:
- _out << "::Ice::OperationMode::Nonmutating";
- break;
- case Operation::Idempotent:
- _out << "::Ice::OperationMode::Idempotent";
- break;
- }
- _out << ", ";
- switch((*s)->sendMode())
- {
- case Operation::Normal:
- _out << "::Ice::OperationMode::Normal";
- break;
- case Operation::Nonmutating:
- _out << "::Ice::OperationMode::Nonmutating";
- break;
- case Operation::Idempotent:
- _out << "::Ice::OperationMode::Idempotent";
- break;
- }
- _out << ", " << ((p->hasMetaData("amd") || (*s)->hasMetaData("amd")) ? "true" : "false") << ", [";
- for(t = params.begin(), count = 0; t != params.end(); ++t)
- {
- if(!(*t)->isOutParam())
- {
- if(count > 0)
- {
- _out << ", ";
- }
- writeType((*t)->type());
- ++count;
- }
- }
- _out << "], [";
- for(t = params.begin(), count = 0; t != params.end(); ++t)
- {
- if((*t)->isOutParam())
- {
- if(count > 0)
- {
- _out << ", ";
- }
- writeType((*t)->type());
- ++count;
- }
- }
- _out << "], ";
- TypePtr returnType = (*s)->returnType();
- if(returnType)
- {
- writeType(returnType);
- }
- else
- {
- _out << "nil";
- }
- _out << ", [";
- ExceptionList exceptions = (*s)->throws();
- for(ExceptionList::iterator u = exceptions.begin(); u != exceptions.end(); ++u)
- {
- if(u != exceptions.begin())
- {
- _out << ", ";
- }
- _out << getAbsolute(*u, IdentToUpper, "T_");
- }
- _out << "])";
-
- string deprecateMetadata;
- if((*s)->findMetaData("deprecate", deprecateMetadata) || p->findMetaData("deprecate", deprecateMetadata))
- {
- string msg;
- string::size_type pos = deprecateMetadata.find(':');
- if(pos != string::npos && pos < deprecateMetadata.size() - 1)
- {
- msg = deprecateMetadata.substr(pos + 1);
- }
- _out << nl << name << "_mixin::OP_" << (*s)->name() << ".deprecate(\"" << msg << "\")";
- }
- }
+ _out << sp << nl << "T_" << name << "Prx.defineProxy(" << name << "Prx, T_" << name << ')';
+ _out << nl << name << "Prx::ICE_TYPE = T_" << name << "Prx";
+
+ if(!ops.empty())
+ {
+ _out << sp;
+ }
+ for(OperationList::iterator s = ops.begin(); s != ops.end(); ++s)
+ {
+ ParamDeclList params = (*s)->parameters();
+ ParamDeclList::iterator t;
+ int count;
+
+ _out << nl << name << "_mixin::OP_" << (*s)->name() << " = ::Ice::__defineOperation('"
+ << (*s)->name() << "', ";
+ switch((*s)->mode())
+ {
+ case Operation::Normal:
+ _out << "::Ice::OperationMode::Normal";
+ break;
+ case Operation::Nonmutating:
+ _out << "::Ice::OperationMode::Nonmutating";
+ break;
+ case Operation::Idempotent:
+ _out << "::Ice::OperationMode::Idempotent";
+ break;
+ }
+ _out << ", ";
+ switch((*s)->sendMode())
+ {
+ case Operation::Normal:
+ _out << "::Ice::OperationMode::Normal";
+ break;
+ case Operation::Nonmutating:
+ _out << "::Ice::OperationMode::Nonmutating";
+ break;
+ case Operation::Idempotent:
+ _out << "::Ice::OperationMode::Idempotent";
+ break;
+ }
+ _out << ", " << ((p->hasMetaData("amd") || (*s)->hasMetaData("amd")) ? "true" : "false") << ", [";
+ for(t = params.begin(), count = 0; t != params.end(); ++t)
+ {
+ if(!(*t)->isOutParam())
+ {
+ if(count > 0)
+ {
+ _out << ", ";
+ }
+ writeType((*t)->type());
+ ++count;
+ }
+ }
+ _out << "], [";
+ for(t = params.begin(), count = 0; t != params.end(); ++t)
+ {
+ if((*t)->isOutParam())
+ {
+ if(count > 0)
+ {
+ _out << ", ";
+ }
+ writeType((*t)->type());
+ ++count;
+ }
+ }
+ _out << "], ";
+ TypePtr returnType = (*s)->returnType();
+ if(returnType)
+ {
+ writeType(returnType);
+ }
+ else
+ {
+ _out << "nil";
+ }
+ _out << ", [";
+ ExceptionList exceptions = (*s)->throws();
+ for(ExceptionList::iterator u = exceptions.begin(); u != exceptions.end(); ++u)
+ {
+ if(u != exceptions.begin())
+ {
+ _out << ", ";
+ }
+ _out << getAbsolute(*u, IdentToUpper, "T_");
+ }
+ _out << "])";
+
+ string deprecateMetadata;
+ if((*s)->findMetaData("deprecate", deprecateMetadata) || p->findMetaData("deprecate", deprecateMetadata))
+ {
+ string msg;
+ string::size_type pos = deprecateMetadata.find(':');
+ if(pos != string::npos && pos < deprecateMetadata.size() - 1)
+ {
+ msg = deprecateMetadata.substr(pos + 1);
+ }
+ _out << nl << name << "_mixin::OP_" << (*s)->name() << ".deprecate(\"" << msg << "\")";
+ }
+ }
}
_out.dec();
@@ -734,16 +734,16 @@ Slice::Ruby::CodeVisitor::visitExceptionStart(const ExceptionPtr& p)
string baseName;
if(base)
{
- baseName = getAbsolute(base, IdentToUpper);
- _out << baseName;
+ baseName = getAbsolute(base, IdentToUpper);
+ _out << baseName;
}
else if(p->isLocal())
{
- _out << "Ice::LocalException";
+ _out << "Ice::LocalException";
}
else
{
- _out << "Ice::UserException";
+ _out << "Ice::UserException";
}
_out.inc();
@@ -759,41 +759,41 @@ Slice::Ruby::CodeVisitor::visitExceptionStart(const ExceptionPtr& p)
bool inheritsMembers = false;
if(!allMembers.empty())
{
- _out << spar;
- for(MemberInfoList::iterator q = allMembers.begin(); q != allMembers.end(); ++q)
- {
- ostringstream ostr;
- ostr << q->lowerName << '=' << getDefaultValue(q->type);
- _out << ostr.str();
- if(q->inherited)
- {
- inheritsMembers = true;
- }
- }
- _out << epar;
+ _out << spar;
+ for(MemberInfoList::iterator q = allMembers.begin(); q != allMembers.end(); ++q)
+ {
+ ostringstream ostr;
+ ostr << q->lowerName << '=' << getDefaultValue(q->type);
+ _out << ostr.str();
+ if(q->inherited)
+ {
+ inheritsMembers = true;
+ }
+ }
+ _out << epar;
}
_out.inc();
if(!allMembers.empty())
{
- if(inheritsMembers)
- {
- _out << nl << "super" << spar;
- for(MemberInfoList::iterator q = allMembers.begin(); q != allMembers.end(); ++q)
- {
- if(q->inherited)
- {
- _out << q->lowerName;
- }
- }
- _out << epar;
- }
- for(MemberInfoList::iterator q = allMembers.begin(); q != allMembers.end(); ++q)
- {
- if(!q->inherited)
- {
- _out << nl << '@' << q->fixedName << " = " << q->lowerName;
- }
- }
+ if(inheritsMembers)
+ {
+ _out << nl << "super" << spar;
+ for(MemberInfoList::iterator q = allMembers.begin(); q != allMembers.end(); ++q)
+ {
+ if(q->inherited)
+ {
+ _out << q->lowerName;
+ }
+ }
+ _out << epar;
+ }
+ for(MemberInfoList::iterator q = allMembers.begin(); q != allMembers.end(); ++q)
+ {
+ if(!q->inherited)
+ {
+ _out << nl << '@' << q->fixedName << " = " << q->lowerName;
+ }
+ }
}
_out.dec();
_out << nl << "end";
@@ -821,15 +821,15 @@ Slice::Ruby::CodeVisitor::visitExceptionStart(const ExceptionPtr& p)
//
if(!members.empty())
{
- _out << sp << nl << "attr_accessor ";
- for(dmli = members.begin(); dmli != members.end(); ++dmli)
- {
- if(dmli != members.begin())
- {
- _out << ", ";
- }
- _out << ':' << fixIdent((*dmli)->name(), IdentNormal);
- }
+ _out << sp << nl << "attr_accessor ";
+ for(dmli = members.begin(); dmli != members.end(); ++dmli)
+ {
+ if(dmli != members.begin())
+ {
+ _out << ", ";
+ }
+ _out << ':' << fixIdent((*dmli)->name(), IdentNormal);
+ }
}
_out.dec();
@@ -841,17 +841,17 @@ Slice::Ruby::CodeVisitor::visitExceptionStart(const ExceptionPtr& p)
_out << sp << nl << "T_" << name << " = ::Ice::__defineException('" << scoped << "', " << name << ", ";
if(!base)
{
- _out << "nil";
+ _out << "nil";
}
else
{
- _out << getAbsolute(base, IdentToUpper, "T_");
+ _out << getAbsolute(base, IdentToUpper, "T_");
}
_out << ", [";
if(members.size() > 1)
{
- _out.inc();
- _out << nl;
+ _out.inc();
+ _out << nl;
}
//
// Data members are represented as an array:
@@ -862,18 +862,18 @@ Slice::Ruby::CodeVisitor::visitExceptionStart(const ExceptionPtr& p)
//
for(dmli = members.begin(); dmli != members.end(); ++dmli)
{
- if(dmli != members.begin())
- {
- _out << ',' << nl;
- }
- _out << "[\"" << fixIdent((*dmli)->name(), IdentNormal) << "\", ";
- writeType((*dmli)->type());
- _out << ']';
+ if(dmli != members.begin())
+ {
+ _out << ',' << nl;
+ }
+ _out << "[\"" << fixIdent((*dmli)->name(), IdentNormal) << "\", ";
+ writeType((*dmli)->type());
+ _out << ']';
}
if(members.size() > 1)
{
- _out.dec();
- _out << nl;
+ _out.dec();
+ _out << nl;
}
_out << "])";
_out << nl << name << "::ICE_TYPE = T_" << name;
@@ -893,14 +893,14 @@ Slice::Ruby::CodeVisitor::visitStructStart(const StructPtr& p)
MemberInfoList::iterator r;
{
- DataMemberList members = p->dataMembers();
- for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q)
- {
- memberList.push_back(MemberInfo());
- memberList.back().lowerName = fixIdent((*q)->name(), IdentToLower);
- memberList.back().fixedName = fixIdent((*q)->name(), IdentNormal);
- memberList.back().type = (*q)->type();
- }
+ DataMemberList members = p->dataMembers();
+ for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q)
+ {
+ memberList.push_back(MemberInfo());
+ memberList.back().lowerName = fixIdent((*q)->name(), IdentToLower);
+ memberList.back().fixedName = fixIdent((*q)->name(), IdentNormal);
+ memberList.back().type = (*q)->type();
+ }
}
_out << sp << nl << "if not defined?(" << getAbsolute(p, IdentToUpper) << ')';
@@ -909,23 +909,23 @@ Slice::Ruby::CodeVisitor::visitStructStart(const StructPtr& p)
_out.inc();
if(!memberList.empty())
{
- _out << nl << "def initialize(";
- for(r = memberList.begin(); r != memberList.end(); ++r)
- {
- if(r != memberList.begin())
- {
- _out << ", ";
- }
- _out << r->lowerName << '=' << getDefaultValue(r->type);
- }
- _out << ")";
- _out.inc();
- for(r = memberList.begin(); r != memberList.end(); ++r)
- {
- _out << nl << '@' << r->fixedName << " = " << r->lowerName;
- }
- _out.dec();
- _out << nl << "end";
+ _out << nl << "def initialize(";
+ for(r = memberList.begin(); r != memberList.end(); ++r)
+ {
+ if(r != memberList.begin())
+ {
+ _out << ", ";
+ }
+ _out << r->lowerName << '=' << getDefaultValue(r->type);
+ }
+ _out << ")";
+ _out.inc();
+ for(r = memberList.begin(); r != memberList.end(); ++r)
+ {
+ _out << nl << '@' << r->fixedName << " = " << r->lowerName;
+ }
+ _out.dec();
+ _out << nl << "end";
}
//
@@ -937,7 +937,7 @@ Slice::Ruby::CodeVisitor::visitStructStart(const StructPtr& p)
int iter = 0;
for(r = memberList.begin(); r != memberList.end(); ++r)
{
- writeHash("@" + r->fixedName, r->type, iter);
+ writeHash("@" + r->fixedName, r->type, iter);
}
_out << nl << "_h % 0x7fffffff";
_out.dec();
@@ -952,11 +952,11 @@ Slice::Ruby::CodeVisitor::visitStructStart(const StructPtr& p)
_out.inc();
for(r = memberList.begin(); r != memberList.end(); ++r)
{
- if(r != memberList.begin())
- {
- _out << " or";
- }
- _out << nl << "@" << r->fixedName << " != other." << r->fixedName;
+ if(r != memberList.begin())
+ {
+ _out << " or";
+ }
+ _out << nl << "@" << r->fixedName << " != other." << r->fixedName;
}
_out.dec();
_out << nl << "true";
@@ -977,15 +977,15 @@ Slice::Ruby::CodeVisitor::visitStructStart(const StructPtr& p)
//
if(!memberList.empty())
{
- _out << sp << nl << "attr_accessor ";
- for(r = memberList.begin(); r != memberList.end(); ++r)
- {
- if(r != memberList.begin())
- {
- _out << ", ";
- }
- _out << ':' << r->fixedName;
- }
+ _out << sp << nl << "attr_accessor ";
+ for(r = memberList.begin(); r != memberList.end(); ++r)
+ {
+ if(r != memberList.begin())
+ {
+ _out << ", ";
+ }
+ _out << ':' << r->fixedName;
+ }
}
_out.dec();
@@ -1004,23 +1004,23 @@ Slice::Ruby::CodeVisitor::visitStructStart(const StructPtr& p)
//
if(memberList.size() > 1)
{
- _out.inc();
- _out << nl;
+ _out.inc();
+ _out << nl;
}
for(r = memberList.begin(); r != memberList.end(); ++r)
{
- if(r != memberList.begin())
- {
- _out << ',' << nl;
- }
- _out << "[\"" << r->fixedName << "\", ";
- writeType(r->type);
- _out << ']';
+ if(r != memberList.begin())
+ {
+ _out << ',' << nl;
+ }
+ _out << "[\"" << r->fixedName << "\", ";
+ writeType(r->type);
+ _out << ']';
}
if(memberList.size() > 1)
{
- _out.dec();
- _out << nl;
+ _out.dec();
+ _out << nl;
}
_out << "])";
@@ -1083,10 +1083,10 @@ Slice::Ruby::CodeVisitor::visitEnum(const EnumPtr& p)
_out << sp << nl << "def initialize(val)";
_out.inc();
{
- ostringstream assertion;
- assertion << "fail(\"invalid value #{val} for " << name << "\") unless(val >= 0 and val < "
- << enums.size() << ')';
- _out << nl << assertion.str();
+ ostringstream assertion;
+ assertion << "fail(\"invalid value #{val} for " << name << "\") unless(val >= 0 and val < "
+ << enums.size() << ')';
+ _out << nl << assertion.str();
}
_out << nl << "@val = val";
_out.dec();
@@ -1096,15 +1096,15 @@ Slice::Ruby::CodeVisitor::visitEnum(const EnumPtr& p)
// from_int
//
{
- _out << sp << nl << "def " << name << ".from_int(val)";
- ostringstream sz;
- sz << enums.size() - 1;
- _out.inc();
- _out << nl << "raise IndexError, \"#{val} is out of range 0.." << sz.str() << "\" if(val < 0 || val > "
- << sz.str() << ')';
- _out << nl << "@@_values[val]";
- _out.dec();
- _out << nl << "end";
+ _out << sp << nl << "def " << name << ".from_int(val)";
+ ostringstream sz;
+ sz << enums.size() - 1;
+ _out.inc();
+ _out << nl << "raise IndexError, \"#{val} is out of range 0.." << sz.str() << "\" if(val < 0 || val > "
+ << sz.str() << ')';
+ _out << nl << "@@_values[val]";
+ _out.dec();
+ _out << nl << "end";
}
//
@@ -1165,24 +1165,24 @@ Slice::Ruby::CodeVisitor::visitEnum(const EnumPtr& p)
_out << sp << nl << "@@_names = [";
for(q = enums.begin(); q != enums.end(); ++q)
{
- if(q != enums.begin())
- {
- _out << ", ";
- }
- _out << "'" << (*q)->name() << "'";
+ if(q != enums.begin())
+ {
+ _out << ", ";
+ }
+ _out << "'" << (*q)->name() << "'";
}
_out << ']';
_out << nl << "@@_values = [";
for(EnumeratorList::size_type j = 0; j < enums.size(); ++j)
{
- if(j > 0)
- {
- _out << ", ";
- }
- ostringstream idx;
- idx << j;
- _out << name << ".new(" << idx.str() << ')';
+ if(j > 0)
+ {
+ _out << ", ";
+ }
+ ostringstream idx;
+ idx << j;
+ _out << name << ".new(" << idx.str() << ')';
}
_out << ']';
@@ -1192,9 +1192,9 @@ Slice::Ruby::CodeVisitor::visitEnum(const EnumPtr& p)
_out << sp;
for(q = enums.begin(), i = 0; q != enums.end(); ++q, ++i)
{
- ostringstream idx;
- idx << i;
- _out << nl << fixIdent((*q)->name(), IdentToUpper) << " = @@_values[" << idx.str() << "]";
+ ostringstream idx;
+ idx << i;
+ _out << nl << fixIdent((*q)->name(), IdentToUpper) << " = @@_values[" << idx.str() << "]";
}
_out << sp << nl << "private_class_method :new";
@@ -1208,11 +1208,11 @@ Slice::Ruby::CodeVisitor::visitEnum(const EnumPtr& p)
_out << sp << nl << "T_" << name << " = ::Ice::__defineEnum('" << scoped << "', " << name << ", [";
for(q = enums.begin(); q != enums.end(); ++q)
{
- if(q != enums.begin())
- {
- _out << ", ";
- }
- _out << name << "::" << fixIdent((*q)->name(), IdentToUpper);
+ if(q != enums.begin())
+ {
+ _out << ", ";
+ }
+ _out << name << "::" << fixIdent((*q)->name(), IdentToUpper);
}
_out << "])";
@@ -1233,131 +1233,131 @@ Slice::Ruby::CodeVisitor::visitConst(const ConstPtr& p)
Slice::EnumPtr en = Slice::EnumPtr::dynamicCast(type);
if(b)
{
- switch(b->kind())
- {
- case Slice::Builtin::KindBool:
- {
- _out << value;
- break;
- }
- case Slice::Builtin::KindByte:
- case Slice::Builtin::KindShort:
- case Slice::Builtin::KindInt:
- case Slice::Builtin::KindFloat:
- case Slice::Builtin::KindDouble:
- {
- _out << value;
- break;
- }
- case Slice::Builtin::KindLong:
- {
- IceUtil::Int64 l;
- IceUtil::stringToInt64(value, l);
- _out << value;
- break;
- }
-
- case Slice::Builtin::KindString:
- {
- //
- // Expand strings into the basic source character set. We can't use isalpha() and the like
- // here because they are sensitive to the current locale.
- //
- static const string basicSourceChars = "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789"
- "_{}[]#()<>%:;.?*+-/^&|~!=, '";
- static const set<char> charSet(basicSourceChars.begin(), basicSourceChars.end());
-
- _out << "\""; // Opening "
-
- for(string::const_iterator c = value.begin(); c != value.end(); ++c)
- {
- switch(*c)
- {
- case '"':
- {
- _out << "\\\"";
- break;
- }
- case '\\':
- {
- _out << "\\\\";
- break;
- }
- case '\r':
- {
- _out << "\\r";
- break;
- }
- case '\n':
- {
- _out << "\\n";
- break;
- }
- case '\t':
- {
- _out << "\\t";
- break;
- }
- case '\b':
- {
- _out << "\\b";
- break;
- }
- case '\f':
- {
- _out << "\\f";
- break;
- }
- default:
- {
- if(charSet.find(*c) == charSet.end())
- {
- unsigned char uc = *c; // Char may be signed, so make it positive.
- stringstream s;
- s << "\\"; // Print as octal if not in basic source character set.
- s.flags(ios_base::oct);
- s.width(3);
- s.fill('0');
- s << static_cast<unsigned>(uc);
- _out << s.str();
- }
- else
- {
- _out << *c; // Print normally if in basic source character set.
- }
- break;
- }
- }
- }
-
- _out << "\""; // Closing "
- break;
- }
-
- case Slice::Builtin::KindObject:
- case Slice::Builtin::KindObjectProxy:
- case Slice::Builtin::KindLocalObject:
- assert(false);
- }
+ switch(b->kind())
+ {
+ case Slice::Builtin::KindBool:
+ {
+ _out << value;
+ break;
+ }
+ case Slice::Builtin::KindByte:
+ case Slice::Builtin::KindShort:
+ case Slice::Builtin::KindInt:
+ case Slice::Builtin::KindFloat:
+ case Slice::Builtin::KindDouble:
+ {
+ _out << value;
+ break;
+ }
+ case Slice::Builtin::KindLong:
+ {
+ IceUtil::Int64 l;
+ IceUtil::stringToInt64(value, l);
+ _out << value;
+ break;
+ }
+
+ case Slice::Builtin::KindString:
+ {
+ //
+ // Expand strings into the basic source character set. We can't use isalpha() and the like
+ // here because they are sensitive to the current locale.
+ //
+ static const string basicSourceChars = "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789"
+ "_{}[]#()<>%:;.?*+-/^&|~!=, '";
+ static const set<char> charSet(basicSourceChars.begin(), basicSourceChars.end());
+
+ _out << "\""; // Opening "
+
+ for(string::const_iterator c = value.begin(); c != value.end(); ++c)
+ {
+ switch(*c)
+ {
+ case '"':
+ {
+ _out << "\\\"";
+ break;
+ }
+ case '\\':
+ {
+ _out << "\\\\";
+ break;
+ }
+ case '\r':
+ {
+ _out << "\\r";
+ break;
+ }
+ case '\n':
+ {
+ _out << "\\n";
+ break;
+ }
+ case '\t':
+ {
+ _out << "\\t";
+ break;
+ }
+ case '\b':
+ {
+ _out << "\\b";
+ break;
+ }
+ case '\f':
+ {
+ _out << "\\f";
+ break;
+ }
+ default:
+ {
+ if(charSet.find(*c) == charSet.end())
+ {
+ unsigned char uc = *c; // Char may be signed, so make it positive.
+ stringstream s;
+ s << "\\"; // Print as octal if not in basic source character set.
+ s.flags(ios_base::oct);
+ s.width(3);
+ s.fill('0');
+ s << static_cast<unsigned>(uc);
+ _out << s.str();
+ }
+ else
+ {
+ _out << *c; // Print normally if in basic source character set.
+ }
+ break;
+ }
+ }
+ }
+
+ _out << "\""; // Closing "
+ break;
+ }
+
+ case Slice::Builtin::KindObject:
+ case Slice::Builtin::KindObjectProxy:
+ case Slice::Builtin::KindLocalObject:
+ assert(false);
+ }
}
else if(en)
{
- _out << getAbsolute(en, IdentToUpper) << "::";
- string::size_type colon = value.rfind(':');
- if(colon != string::npos)
- {
- _out << fixIdent(value.substr(colon + 1), IdentToUpper);
- }
- else
- {
- _out << fixIdent(value, IdentToUpper);
- }
+ _out << getAbsolute(en, IdentToUpper) << "::";
+ string::size_type colon = value.rfind(':');
+ if(colon != string::npos)
+ {
+ _out << fixIdent(value.substr(colon + 1), IdentToUpper);
+ }
+ else
+ {
+ _out << fixIdent(value, IdentToUpper);
+ }
}
else
{
- assert(false); // Unknown const type.
+ assert(false); // Unknown const type.
}
}
@@ -1367,72 +1367,72 @@ Slice::Ruby::CodeVisitor::writeType(const TypePtr& p)
BuiltinPtr builtin = BuiltinPtr::dynamicCast(p);
if(builtin)
{
- switch(builtin->kind())
- {
- case Builtin::KindBool:
- {
- _out << "::Ice::T_bool";
- break;
- }
- case Builtin::KindByte:
- {
- _out << "::Ice::T_byte";
- break;
- }
- case Builtin::KindShort:
- {
- _out << "::Ice::T_short";
- break;
- }
- case Builtin::KindInt:
- {
- _out << "::Ice::T_int";
- break;
- }
- case Builtin::KindLong:
- {
- _out << "::Ice::T_long";
- break;
- }
- case Builtin::KindFloat:
- {
- _out << "::Ice::T_float";
- break;
- }
- case Builtin::KindDouble:
- {
- _out << "::Ice::T_double";
- break;
- }
- case Builtin::KindString:
- {
- _out << "::Ice::T_string";
- break;
- }
- case Builtin::KindObject:
- {
- _out << "::Ice::T_Object";
- break;
- }
- case Builtin::KindObjectProxy:
- {
- _out << "::Ice::T_ObjectPrx";
- break;
- }
- case Builtin::KindLocalObject:
- {
- _out << "::Ice::T_LocalObject";
- break;
- }
- }
- return;
+ switch(builtin->kind())
+ {
+ case Builtin::KindBool:
+ {
+ _out << "::Ice::T_bool";
+ break;
+ }
+ case Builtin::KindByte:
+ {
+ _out << "::Ice::T_byte";
+ break;
+ }
+ case Builtin::KindShort:
+ {
+ _out << "::Ice::T_short";
+ break;
+ }
+ case Builtin::KindInt:
+ {
+ _out << "::Ice::T_int";
+ break;
+ }
+ case Builtin::KindLong:
+ {
+ _out << "::Ice::T_long";
+ break;
+ }
+ case Builtin::KindFloat:
+ {
+ _out << "::Ice::T_float";
+ break;
+ }
+ case Builtin::KindDouble:
+ {
+ _out << "::Ice::T_double";
+ break;
+ }
+ case Builtin::KindString:
+ {
+ _out << "::Ice::T_string";
+ break;
+ }
+ case Builtin::KindObject:
+ {
+ _out << "::Ice::T_Object";
+ break;
+ }
+ case Builtin::KindObjectProxy:
+ {
+ _out << "::Ice::T_ObjectPrx";
+ break;
+ }
+ case Builtin::KindLocalObject:
+ {
+ _out << "::Ice::T_LocalObject";
+ break;
+ }
+ }
+ return;
}
ProxyPtr prx = ProxyPtr::dynamicCast(p);
if(prx)
{
- _out << getAbsolute(prx->_class(), IdentToUpper, "T_") << "Prx";
- return;
+ _out << getAbsolute(prx->_class(), IdentToUpper, "T_") << "Prx";
+ return;
}
ContainedPtr cont = ContainedPtr::dynamicCast(p);
@@ -1446,48 +1446,48 @@ Slice::Ruby::CodeVisitor::getDefaultValue(const TypePtr& p)
BuiltinPtr builtin = BuiltinPtr::dynamicCast(p);
if(builtin)
{
- switch(builtin->kind())
- {
- case Builtin::KindBool:
- {
- return "false";
- }
- case Builtin::KindByte:
- case Builtin::KindShort:
- case Builtin::KindInt:
- case Builtin::KindLong:
- {
- return "0";
- }
- case Builtin::KindFloat:
- case Builtin::KindDouble:
- {
- return "0.0";
- }
- case Builtin::KindString:
- {
- return "''";
- }
- case Builtin::KindObject:
- case Builtin::KindObjectProxy:
- case Builtin::KindLocalObject:
- {
- return "nil";
- }
- }
+ switch(builtin->kind())
+ {
+ case Builtin::KindBool:
+ {
+ return "false";
+ }
+ case Builtin::KindByte:
+ case Builtin::KindShort:
+ case Builtin::KindInt:
+ case Builtin::KindLong:
+ {
+ return "0";
+ }
+ case Builtin::KindFloat:
+ case Builtin::KindDouble:
+ {
+ return "0.0";
+ }
+ case Builtin::KindString:
+ {
+ return "''";
+ }
+ case Builtin::KindObject:
+ case Builtin::KindObjectProxy:
+ case Builtin::KindLocalObject:
+ {
+ return "nil";
+ }
+ }
}
EnumPtr en = EnumPtr::dynamicCast(p);
if(en)
{
- EnumeratorList enums = en->getEnumerators();
- return getAbsolute(en, IdentToUpper) + "::" + fixIdent(enums.front()->name(), IdentToUpper);
+ EnumeratorList enums = en->getEnumerators();
+ return getAbsolute(en, IdentToUpper) + "::" + fixIdent(enums.front()->name(), IdentToUpper);
}
StructPtr st = StructPtr::dynamicCast(p);
if(st)
{
- return getAbsolute(st, IdentToUpper) + ".new";
+ return getAbsolute(st, IdentToUpper) + ".new";
}
return "nil";
@@ -1505,19 +1505,19 @@ Slice::Ruby::CodeVisitor::collectClassMembers(const ClassDefPtr& p, MemberInfoLi
ClassList bases = p->bases();
if(!bases.empty() && !bases.front()->isInterface())
{
- collectClassMembers(bases.front(), allMembers, true);
+ collectClassMembers(bases.front(), allMembers, true);
}
DataMemberList members = p->dataMembers();
for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q)
{
- MemberInfo m;
- m.lowerName = fixIdent((*q)->name(), IdentToLower);
- m.fixedName = fixIdent((*q)->name(), IdentNormal);
- m.type = (*q)->type();
- m.inherited = inherited;
- allMembers.push_back(m);
+ MemberInfo m;
+ m.lowerName = fixIdent((*q)->name(), IdentToLower);
+ m.fixedName = fixIdent((*q)->name(), IdentNormal);
+ m.type = (*q)->type();
+ m.inherited = inherited;
+ allMembers.push_back(m);
}
}
@@ -1527,19 +1527,19 @@ Slice::Ruby::CodeVisitor::collectExceptionMembers(const ExceptionPtr& p, MemberI
ExceptionPtr base = p->base();
if(base)
{
- collectExceptionMembers(base, allMembers, true);
+ collectExceptionMembers(base, allMembers, true);
}
DataMemberList members = p->dataMembers();
for(DataMemberList::iterator q = members.begin(); q != members.end(); ++q)
{
- MemberInfo m;
- m.lowerName = fixIdent((*q)->name(), IdentToLower);
- m.fixedName = fixIdent((*q)->name(), IdentNormal);
- m.type = (*q)->type();
- m.inherited = inherited;
- allMembers.push_back(m);
+ MemberInfo m;
+ m.lowerName = fixIdent((*q)->name(), IdentToLower);
+ m.fixedName = fixIdent((*q)->name(), IdentNormal);
+ m.type = (*q)->type();
+ m.inherited = inherited;
+ allMembers.push_back(m);
}
}
@@ -1551,7 +1551,7 @@ normalizePath(const string& path)
string::size_type pos;
while((pos = result.find("//")) != string::npos)
{
- result.replace(pos, 2, "/");
+ result.replace(pos, 2, "/");
}
return result;
}
@@ -1569,22 +1569,22 @@ changeInclude(const string& inc, const vector<string>& includePaths)
//
for(vector<string>::const_iterator p = includePaths.begin(); p != includePaths.end(); ++p)
{
- string includePath = *p;
+ string includePath = *p;
- if(orig.compare(0, p->size(), *p) == 0)
- {
- string s = orig.substr(p->size());
- if(s.size() < curr.size())
- {
- curr = s;
- }
- }
+ if(orig.compare(0, p->size(), *p) == 0)
+ {
+ string s = orig.substr(p->size());
+ if(s.size() < curr.size())
+ {
+ curr = s;
+ }
+ }
}
string::size_type pos = curr.rfind('.');
if(pos != string::npos)
{
- curr.erase(pos);
+ curr.erase(pos);
}
return curr;
@@ -1597,22 +1597,22 @@ Slice::Ruby::generate(const UnitPtr& un, bool all, bool checksum, const vector<s
if(!all)
{
- vector<string> paths = includePaths;
- for(vector<string>::iterator p = paths.begin(); p != paths.end(); ++p)
- {
- if(p->size() && (*p)[p->size() - 1] != '/')
- {
- *p += '/';
- }
- *p = normalizePath(*p);
- }
+ vector<string> paths = includePaths;
+ for(vector<string>::iterator p = paths.begin(); p != paths.end(); ++p)
+ {
+ if(p->size() && (*p)[p->size() - 1] != '/')
+ {
+ *p += '/';
+ }
+ *p = normalizePath(*p);
+ }
- StringList includes = un->includeFiles();
- for(StringList::const_iterator q = includes.begin(); q != includes.end(); ++q)
- {
- string file = changeInclude(*q, paths);
- out << nl << "require '" << file << ".rb'";
- }
+ StringList includes = un->includeFiles();
+ for(StringList::const_iterator q = includes.begin(); q != includes.end(); ++q)
+ {
+ string file = changeInclude(*q, paths);
+ out << nl << "require '" << file << ".rb'";
+ }
}
CodeVisitor codeVisitor(out);
@@ -1620,23 +1620,23 @@ Slice::Ruby::generate(const UnitPtr& un, bool all, bool checksum, const vector<s
if(checksum)
{
- ChecksumMap checksums = createChecksums(un);
- if(!checksums.empty())
- {
- out << sp;
- for(ChecksumMap::const_iterator p = checksums.begin(); p != checksums.end(); ++p)
- {
- out << nl << "::Ice::SliceChecksums[\"" << p->first << "\"] = \"";
- ostringstream str;
- str.flags(ios_base::hex);
- str.fill('0');
- for(vector<unsigned char>::const_iterator q = p->second.begin(); q != p->second.end(); ++q)
- {
- str << (int)(*q);
- }
- out << str.str() << "\"";
- }
- }
+ ChecksumMap checksums = createChecksums(un);
+ if(!checksums.empty())
+ {
+ out << sp;
+ for(ChecksumMap::const_iterator p = checksums.begin(); p != checksums.end(); ++p)
+ {
+ out << nl << "::Ice::SliceChecksums[\"" << p->first << "\"] = \"";
+ ostringstream str;
+ str.flags(ios_base::hex);
+ str.fill('0');
+ for(vector<unsigned char>::const_iterator q = p->second.begin(); q != p->second.end(); ++q)
+ {
+ str << (int)(*q);
+ }
+ out << str.str() << "\"";
+ }
+ }
}
out << nl; // Trailing newline.
@@ -1649,36 +1649,36 @@ Slice::Ruby::splitString(const string& str, vector<string>& args, const string&
string::size_type end = 0;
while(true)
{
- beg = str.find_first_not_of(delim, end);
- if(beg == string::npos)
- {
- break;
- }
-
- //
- // Check for quoted argument.
- //
- char ch = str[beg];
- if(ch == '"' || ch == '\'')
- {
- beg++;
- end = str.find(ch, beg);
- if(end == string::npos)
- {
- return false;
- }
- args.push_back(str.substr(beg, end - beg));
- end++; // Skip end quote.
- }
- else
- {
- end = str.find_first_of(delim + "'\"", beg);
- if(end == string::npos)
- {
- end = str.length();
- }
- args.push_back(str.substr(beg, end - beg));
- }
+ beg = str.find_first_not_of(delim, end);
+ if(beg == string::npos)
+ {
+ break;
+ }
+
+ //
+ // Check for quoted argument.
+ //
+ char ch = str[beg];
+ if(ch == '"' || ch == '\'')
+ {
+ beg++;
+ end = str.find(ch, beg);
+ if(end == string::npos)
+ {
+ return false;
+ }
+ args.push_back(str.substr(beg, end - beg));
+ end++; // Skip end quote.
+ }
+ else
+ {
+ end = str.find_first_of(delim + "'\"", beg);
+ if(end == string::npos)
+ {
+ end = str.length();
+ }
+ args.push_back(str.substr(beg, end - beg));
+ }
}
return true;
@@ -1689,25 +1689,25 @@ Slice::Ruby::fixIdent(const string& ident, IdentStyle style)
{
if(ident[0] != ':')
{
- string id = ident;
- switch(style)
- {
- case IdentNormal:
- break;
- case IdentToUpper:
- if(id[0] >= 'a' && id[0] <= 'z')
- {
- id[0] += 'A' - 'a';
- }
- break;
- case IdentToLower:
- if(id[0] >= 'A' && id[0] <= 'Z')
- {
- id[0] += 'a' - 'A';
- }
- break;
- }
- return lookupKwd(id);
+ string id = ident;
+ switch(style)
+ {
+ case IdentNormal:
+ break;
+ case IdentToUpper:
+ if(id[0] >= 'a' && id[0] <= 'z')
+ {
+ id[0] += 'A' - 'a';
+ }
+ break;
+ case IdentToLower:
+ if(id[0] >= 'A' && id[0] <= 'Z')
+ {
+ id[0] += 'a' - 'A';
+ }
+ break;
+ }
+ return lookupKwd(id);
}
vector<string> ids = splitScopedName(ident);
@@ -1716,11 +1716,11 @@ Slice::Ruby::fixIdent(const string& ident, IdentStyle style)
ostringstream result;
for(vector<string>::size_type i = 0; i < ids.size() - 1; ++i)
{
- //
- // We assume all intermediate names must be upper-case (i.e., they represent
- // the names of modules or classes).
- //
- result << "::" << fixIdent(ids[i], IdentToUpper);
+ //
+ // We assume all intermediate names must be upper-case (i.e., they represent
+ // the names of modules or classes).
+ //
+ result << "::" << fixIdent(ids[i], IdentToUpper);
}
result << "::" << fixIdent(ids[ids.size() - 1], style);
return result.str();
@@ -1733,11 +1733,11 @@ Slice::Ruby::getAbsolute(const ContainedPtr& cont, IdentStyle style, const strin
if(prefix.empty())
{
- return scope + fixIdent(cont->name(), style);
+ return scope + fixIdent(cont->name(), style);
}
else
{
- return scope + prefix + fixIdent(cont->name(), style);
+ return scope + prefix + fixIdent(cont->name(), style);
}
}
@@ -1753,7 +1753,7 @@ Slice::Ruby::printHeader(IceUtil::Output& out)
"# ICE_LICENSE file included in this distribution.\n"
"#\n"
"# **********************************************************************\n"
- ;
+ ;
out << header;
out << "\n# Ice version " << ICE_STRING_VERSION;
diff --git a/cpp/src/Slice/VbUtil.cpp b/cpp/src/Slice/VbUtil.cpp
index fe18bae01ef..68ce6b8942e 100755
--- a/cpp/src/Slice/VbUtil.cpp
+++ b/cpp/src/Slice/VbUtil.cpp
@@ -34,33 +34,33 @@ lookupKwd(const string& name, int baseTypes, bool mangleCasts = false)
//
static const string keywordList[] =
{
- "AddHandler", "AddressOf", "Alias", "And", "AndAlso", "Ansi", "As", "Assembly", "Auto",
- "Boolean", "ByRef", "Byte", "ByVal", "Call", "Case", "Catch", "CBool", "CByte", "CChar",
- "CDate", "CDbl", "CDec", "Char", "CInt", "Class", "CLng", "CObj", "Const", "CShort", "CSng",
- "CStr", "CType", "Date", "Decimal", "Declare", "Default", "Delegate", "Dim", "DirectCast",
- "Do", "Double", "Each", "Else", "ElseIf", "End", "EndIf", "Enum", "Erase", "Error", "Event",
- "Exit", "False", "Finally", "For", "Friend", "Function", "Get", "GetType", "GoSub", "GoTo",
- "Handles", "If", "Implements", "Imports", "In", "Inherits", "Integer", "Interface", "Is",
- "Let", "Lib", "Like", "Long", "Loop", "Me", "Mod", "Module", "MustInherit", "MustOverride",
- "MyBase", "MyClass", "Namespace", "New", "Next", "Not", "Nothing", "NotInheritable",
- "NotOverridable", "Object", "On", "Option", "Optional", "Or", "OrElse", "Overloads", "Overridable",
- "Overrides", "ParamArray", "Preserve", "Private", "Property", "Protected", "Public", "RaiseEvent",
- "ReadOnly", "ReDim", "REM", "RemoveHandler", "Resume", "Return", "Select", "Set",
- "Shadows", "Shared", "Short", "Single", "Static", "Step", "Stop", "String", "Structure",
- "Sub", "SyncLock", "Then", "Throw", "To", "True", "Try", "TypeOf", "Unicode", "Until",
- "Variant", "Wend", "When", "While", "With", "WithEvents", "WriteOnly", "Xor"
+ "AddHandler", "AddressOf", "Alias", "And", "AndAlso", "Ansi", "As", "Assembly", "Auto",
+ "Boolean", "ByRef", "Byte", "ByVal", "Call", "Case", "Catch", "CBool", "CByte", "CChar",
+ "CDate", "CDbl", "CDec", "Char", "CInt", "Class", "CLng", "CObj", "Const", "CShort", "CSng",
+ "CStr", "CType", "Date", "Decimal", "Declare", "Default", "Delegate", "Dim", "DirectCast",
+ "Do", "Double", "Each", "Else", "ElseIf", "End", "EndIf", "Enum", "Erase", "Error", "Event",
+ "Exit", "False", "Finally", "For", "Friend", "Function", "Get", "GetType", "GoSub", "GoTo",
+ "Handles", "If", "Implements", "Imports", "In", "Inherits", "Integer", "Interface", "Is",
+ "Let", "Lib", "Like", "Long", "Loop", "Me", "Mod", "Module", "MustInherit", "MustOverride",
+ "MyBase", "MyClass", "Namespace", "New", "Next", "Not", "Nothing", "NotInheritable",
+ "NotOverridable", "Object", "On", "Option", "Optional", "Or", "OrElse", "Overloads", "Overridable",
+ "Overrides", "ParamArray", "Preserve", "Private", "Property", "Protected", "Public", "RaiseEvent",
+ "ReadOnly", "ReDim", "REM", "RemoveHandler", "Resume", "Return", "Select", "Set",
+ "Shadows", "Shared", "Short", "Single", "Static", "Step", "Stop", "String", "Structure",
+ "Sub", "SyncLock", "Then", "Throw", "To", "True", "Try", "TypeOf", "Unicode", "Until",
+ "Variant", "Wend", "When", "While", "With", "WithEvents", "WriteOnly", "Xor"
};
bool found = binary_search(&keywordList[0],
- &keywordList[sizeof(keywordList) / sizeof(*keywordList)],
- name,
- Slice::CICompare());
+ &keywordList[sizeof(keywordList) / sizeof(*keywordList)],
+ name,
+ Slice::CICompare());
if(found)
{
return "[" + name + "]";
}
if(mangleCasts && (name == "checkedCast" || name == "uncheckedCast"))
{
- return string(DotNet::manglePrefix) + name;
+ return string(DotNet::manglePrefix) + name;
}
return Slice::DotNet::mangleName(name, baseTypes);
}
@@ -77,24 +77,24 @@ splitScopedName(const string& scoped)
string::size_type pos;
while((pos = scoped.find("::", next)) != string::npos)
{
- pos += 2;
- if(pos != scoped.size())
- {
- string::size_type endpos = scoped.find("::", pos);
- if(endpos != string::npos)
- {
- ids.push_back(scoped.substr(pos, endpos - pos));
- }
- }
- next = pos;
+ pos += 2;
+ if(pos != scoped.size())
+ {
+ string::size_type endpos = scoped.find("::", pos);
+ if(endpos != string::npos)
+ {
+ ids.push_back(scoped.substr(pos, endpos - pos));
+ }
+ }
+ next = pos;
}
if(next != scoped.size())
{
- ids.push_back(scoped.substr(next));
+ ids.push_back(scoped.substr(next));
}
else
{
- ids.push_back("");
+ ids.push_back("");
}
return ids;
@@ -113,26 +113,26 @@ Slice::VbGenerator::fixId(const string& name, int baseTypes, bool mangleCasts)
{
if(name.empty())
{
- return name;
+ return name;
}
if(name[0] != ':')
{
- return lookupKwd(name, baseTypes, mangleCasts);
+ return lookupKwd(name, baseTypes, mangleCasts);
}
StringList ids = splitScopedName(name);
StringList newIds;
for(StringList::const_iterator i = ids.begin(); i != ids.end(); ++i)
{
- newIds.push_back(lookupKwd(*i, baseTypes));
+ newIds.push_back(lookupKwd(*i, baseTypes));
}
stringstream result;
for(StringList::const_iterator j = ids.begin(); j != ids.end(); ++j)
{
- if(j != ids.begin())
- {
- result << '.';
- }
- result << *j;
+ if(j != ids.begin())
+ {
+ result << '.';
+ }
+ result << *j;
}
return result.str();
}
@@ -163,7 +163,7 @@ Slice::VbGenerator::typeToString(const TypePtr& type)
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if(builtin)
{
- return builtinTable[builtin->kind()];
+ return builtinTable[builtin->kind()];
}
ProxyPtr proxy = ProxyPtr::dynamicCast(type);
@@ -175,7 +175,7 @@ Slice::VbGenerator::typeToString(const TypePtr& type)
SequencePtr seq = SequencePtr::dynamicCast(type);
if(seq && !seq->hasMetaData("clr:collection"))
{
- return typeToString(seq->type()) + "()";
+ return typeToString(seq->type()) + "()";
}
ContainedPtr contained = ContainedPtr::dynamicCast(type);
@@ -194,60 +194,60 @@ Slice::VbGenerator::isValueType(const TypePtr& type)
if(builtin)
{
switch(builtin->kind())
- {
- case Builtin::KindString:
- case Builtin::KindObject:
- case Builtin::KindObjectProxy:
- case Builtin::KindLocalObject:
- {
- return false;
- break;
- }
- default:
- {
- return true;
- break;
- }
- }
+ {
+ case Builtin::KindString:
+ case Builtin::KindObject:
+ case Builtin::KindObjectProxy:
+ case Builtin::KindLocalObject:
+ {
+ return false;
+ break;
+ }
+ default:
+ {
+ return true;
+ break;
+ }
+ }
}
StructPtr s = StructPtr::dynamicCast(type);
if(s)
{
- if(s->hasMetaData("clr:class"))
- {
- return false;
- }
- DataMemberList dm = s->dataMembers();
- for(DataMemberList::const_iterator i = dm.begin(); i != dm.end(); ++i)
- {
- if(!isValueType((*i)->type()))
- {
- return false;
- }
- }
- return true;
+ if(s->hasMetaData("clr:class"))
+ {
+ return false;
+ }
+ DataMemberList dm = s->dataMembers();
+ for(DataMemberList::const_iterator i = dm.begin(); i != dm.end(); ++i)
+ {
+ if(!isValueType((*i)->type()))
+ {
+ return false;
+ }
+ }
+ return true;
}
if(EnumPtr::dynamicCast(type))
{
- return true;
+ return true;
}
return false;
}
void
Slice::VbGenerator::writeMarshalUnmarshalCode(Output &out,
- const TypePtr& type,
- const string& param,
- bool marshal,
- bool streamingAPI,
- bool isOutParam,
- const string& patchParams)
+ const TypePtr& type,
+ const string& param,
+ bool marshal,
+ bool streamingAPI,
+ bool isOutParam,
+ const string& patchParams)
{
string stream;
if(marshal)
{
- stream = streamingAPI ? "outS__" : "os__";
+ stream = streamingAPI ? "outS__" : "os__";
}
else
{
@@ -363,32 +363,32 @@ Slice::VbGenerator::writeMarshalUnmarshalCode(Output &out,
}
else
{
- if(isOutParam)
- {
- out << nl << "Dim " << param
- << "_PP As IceInternal.ParamPatcher = New IceInternal.ParamPatcher(GetType(Ice.Object), "
- << "\"::Ice::Object\")";
- if(streamingAPI)
- {
- out << nl << stream << ".readObject(CType(" << param << "_PP, Ice.ReadObjectCallback))";
- }
- else
- {
- out << nl << stream << ".readObject(" << param << "_PP)";
- }
- }
- else
- {
- if(streamingAPI)
- {
- out << nl << stream << ".readObject(CType(New Patcher__(" << patchParams
- << ", Ice.ReadObjectCallback)))";
- }
- else
- {
- out << nl << stream << ".readObject(New Patcher__(" << patchParams << "))";
- }
- }
+ if(isOutParam)
+ {
+ out << nl << "Dim " << param
+ << "_PP As IceInternal.ParamPatcher = New IceInternal.ParamPatcher(GetType(Ice.Object), "
+ << "\"::Ice::Object\")";
+ if(streamingAPI)
+ {
+ out << nl << stream << ".readObject(CType(" << param << "_PP, Ice.ReadObjectCallback))";
+ }
+ else
+ {
+ out << nl << stream << ".readObject(" << param << "_PP)";
+ }
+ }
+ else
+ {
+ if(streamingAPI)
+ {
+ out << nl << stream << ".readObject(CType(New Patcher__(" << patchParams
+ << ", Ice.ReadObjectCallback)))";
+ }
+ else
+ {
+ out << nl << stream << ".readObject(New Patcher__(" << patchParams << "))";
+ }
+ }
}
break;
}
@@ -416,25 +416,25 @@ Slice::VbGenerator::writeMarshalUnmarshalCode(Output &out,
ProxyPtr prx = ProxyPtr::dynamicCast(type);
if(prx)
{
- ContainedPtr contained = ContainedPtr::dynamicCast(type);
- string helperName = fixId((contained ? contained->scoped() : typeToString(type)) + "Helper");
+ ContainedPtr contained = ContainedPtr::dynamicCast(type);
+ string helperName = fixId((contained ? contained->scoped() : typeToString(type)) + "Helper");
if(marshal)
{
out << nl << helperName << ".write";
- if(!streamingAPI)
- {
- out << "__";
- }
- out << '(' << stream << ", " << param << ')';
+ if(!streamingAPI)
+ {
+ out << "__";
+ }
+ out << '(' << stream << ", " << param << ')';
}
else
{
out << nl << param << " = " << helperName << ".read";
- if(!streamingAPI)
- {
- out << "__";
- }
- out << "(" << stream << ')';
+ if(!streamingAPI)
+ {
+ out << "__";
+ }
+ out << "(" << stream << ')';
}
return;
}
@@ -448,33 +448,33 @@ Slice::VbGenerator::writeMarshalUnmarshalCode(Output &out,
}
else
{
- if(isOutParam)
- {
- ContainedPtr contained = ContainedPtr::dynamicCast(type);
- out << nl << "Dim " << param
- << "_PP As IceInternal.ParamPatcher = New IceInternal.ParamPatcher(GetType("
- << typeToString(type) << "), \"" << contained->scoped() << "\")";
- if(streamingAPI)
- {
- out << nl << stream << ".readObject(CType(" << param << "_PP, Ice.ReadObjectCallback))";
- }
- else
- {
- out << nl << stream << ".readObject(" << param << "_PP)";
- }
- }
- else
- {
- if(streamingAPI)
- {
- out << nl << stream << ".readObject(New Patcher__(CType(" << patchParams
- << ", Ice.ReadObjectCallback)))";
- }
- else
- {
- out << nl << stream << ".readObject(New Patcher__(" << patchParams << "))";
- }
- }
+ if(isOutParam)
+ {
+ ContainedPtr contained = ContainedPtr::dynamicCast(type);
+ out << nl << "Dim " << param
+ << "_PP As IceInternal.ParamPatcher = New IceInternal.ParamPatcher(GetType("
+ << typeToString(type) << "), \"" << contained->scoped() << "\")";
+ if(streamingAPI)
+ {
+ out << nl << stream << ".readObject(CType(" << param << "_PP, Ice.ReadObjectCallback))";
+ }
+ else
+ {
+ out << nl << stream << ".readObject(" << param << "_PP)";
+ }
+ }
+ else
+ {
+ if(streamingAPI)
+ {
+ out << nl << stream << ".readObject(New Patcher__(CType(" << patchParams
+ << ", Ice.ReadObjectCallback)))";
+ }
+ else
+ {
+ out << nl << stream << ".readObject(New Patcher__(" << patchParams << "))";
+ }
+ }
}
return;
}
@@ -484,27 +484,27 @@ Slice::VbGenerator::writeMarshalUnmarshalCode(Output &out,
{
if(marshal)
{
- if(streamingAPI)
- {
- out << nl << param << ".ice_write(" << stream << ')';
- }
- else
- {
- out << nl << param << ".write__(" << stream << ')';
- }
+ if(streamingAPI)
+ {
+ out << nl << param << ".ice_write(" << stream << ')';
+ }
+ else
+ {
+ out << nl << param << ".write__(" << stream << ')';
+ }
}
else
{
string typeS = typeToString(type);
out << nl << param << " = New " << typeS;
- if(streamingAPI)
- {
- out << nl << param << ".ice_read(" << stream << ")";
- }
- else
- {
- out << nl << param << ".read__(" << stream << ")";
- }
+ if(streamingAPI)
+ {
+ out << nl << param << ".ice_read(" << stream << ")";
+ }
+ else
+ {
+ out << nl << param << ".read__(" << stream << ")";
+ }
}
return;
}
@@ -512,32 +512,32 @@ Slice::VbGenerator::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("Integer") : fixId(en->scoped());
- }
- if(marshal)
- {
- out << nl << stream << '.' << func << "(CType(" << param << ", " << cast << "))";
- }
- else
- {
- out << nl << param << " = CType(" << stream << '.' << func << "(), " << cast << ')';
- }
+ 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("Integer") : fixId(en->scoped());
+ }
+ if(marshal)
+ {
+ out << nl << stream << '.' << func << "(CType(" << param << ", " << cast << "))";
+ }
+ else
+ {
+ out << nl << param << " = CType(" << stream << '.' << func << "(), " << cast << ')';
+ }
return;
}
@@ -565,7 +565,7 @@ Slice::VbGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
const SequencePtr& seq,
const string& param,
bool marshal,
- bool streamingAPI)
+ bool streamingAPI)
{
string stream;
if(marshal)
@@ -586,36 +586,36 @@ Slice::VbGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if(builtin)
{
- switch(builtin->kind())
- {
- case Builtin::KindObject:
- case Builtin::KindObjectProxy:
- {
- if(marshal)
- {
- out << nl << "If " << param << " Is Nothing Then";
- out.inc();
- out << nl << stream << ".writeSize(0)";
- out.dec();
- out << nl << "Else";
- out.inc();
- out << nl << stream << ".writeSize(" << param << '.' << limitID << ")";
- out << nl << "For ix__ As Integer = 0 To " << param << '.' << limitID << " - 1";
- out.inc();
- string func = builtin->kind() == Builtin::KindObject ? "writeObject" : "writeProxy";
- out << nl << stream << '.' << func << '(' << param << "(ix__))";
- out.dec();
- out << nl << "Next";
- out.dec();
- out << nl << "End If";
- }
- else
- {
- out << nl << "For block__ As Integer = 0 To 0";
- out.inc();
- out << nl << "Dim lenx__ As Integer = " << stream << ".readSize()";
- if(!streamingAPI)
- {
+ switch(builtin->kind())
+ {
+ case Builtin::KindObject:
+ case Builtin::KindObjectProxy:
+ {
+ if(marshal)
+ {
+ out << nl << "If " << param << " Is Nothing Then";
+ out.inc();
+ out << nl << stream << ".writeSize(0)";
+ out.dec();
+ out << nl << "Else";
+ out.inc();
+ out << nl << stream << ".writeSize(" << param << '.' << limitID << ")";
+ out << nl << "For ix__ As Integer = 0 To " << param << '.' << limitID << " - 1";
+ out.inc();
+ string func = builtin->kind() == Builtin::KindObject ? "writeObject" : "writeProxy";
+ out << nl << stream << '.' << func << '(' << param << "(ix__))";
+ out.dec();
+ out << nl << "Next";
+ out.dec();
+ out << nl << "End If";
+ }
+ else
+ {
+ out << nl << "For block__ As Integer = 0 To 0";
+ out.inc();
+ out << nl << "Dim lenx__ As Integer = " << stream << ".readSize()";
+ if(!streamingAPI)
+ {
if(builtin->isVariableLength())
{
out << nl << stream << ".startSeq(lenx__, " << static_cast<unsigned>(builtin->minWireSize())
@@ -626,127 +626,127 @@ Slice::VbGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << nl << stream << ".checkFixedSeq(lenx__, "
<< static_cast<unsigned>(builtin->minWireSize()) << ")";
}
- }
- out << nl << param << " = New ";
- if(builtin->kind() == Builtin::KindObject)
- {
- if(isArray)
- {
- out << "Ice.Object(lenx__ - 1) {}";
- }
- else
- {
- out << typeToString(seq);
- }
- out << nl << "For ix__ As Integer = 0 To lenx__ - 1";
- out.inc();
- if(streamingAPI)
- {
- out << nl << stream << ".readObject(CType(New IceInternal.SequencePatcher("
- << param << ", GetType(Ice.Object), ix__), Ice.ReadObjectCallback))";
- }
- else
- {
- out << nl << stream << ".readObject(New IceInternal.SequencePatcher("
- << param << ", GetType(Ice.Object), ix__))";
- }
- out.dec();
- out << nl << "Next";
- }
- else
- {
- if(isArray)
- {
- out << "Ice.ObjectPrx(lenx__ - 1) {}";
- }
- else
- {
- out << typeToString(seq);
- }
- out << nl << "For ix__ As Integer = 0 To lenx__ - 1";
- out.inc();
- if(isArray)
- {
- out << nl << param << "(ix__) = " << stream << ".readProxy()";
- }
- else
- {
- out << nl << "Dim val__ As Ice.ObjectPrx = New Ice.ObjectPrxHelperBase";
- out << nl << "val__ = " << stream << ".readProxy()";
- out << nl << param << ".Add(val__)";
- }
- out.dec();
- out << nl << "Next";
- }
- if(!streamingAPI && builtin->isVariableLength())
- {
- out << nl << stream << ".checkSeq()";
- out << nl << stream << ".endElement()";
- out << nl << stream << ".endSeq(lenx__)";
- }
- out.dec();
- out << nl << "Next";
- }
- break;
- }
- default:
- {
- string marshalName = builtin->kindAsString();
- marshalName[0] = toupper(marshalName[0]);
- if(marshal)
- {
- out << nl << stream << ".write" << marshalName << "Seq(" << param;
- if(!isArray)
- {
- out << ".ToArray()";
- }
- out << ')';
- }
- else
- {
- if(!isArray)
- {
- out << nl << param << " = New " << fixId(seq->scoped())
- << '(' << stream << ".read" << marshalName << "Seq())";
- }
- else
- {
- out << nl << param << " = " << stream << ".read" << marshalName << "Seq()";
- }
- }
- break;
- }
- }
- return;
+ }
+ out << nl << param << " = New ";
+ if(builtin->kind() == Builtin::KindObject)
+ {
+ if(isArray)
+ {
+ out << "Ice.Object(lenx__ - 1) {}";
+ }
+ else
+ {
+ out << typeToString(seq);
+ }
+ out << nl << "For ix__ As Integer = 0 To lenx__ - 1";
+ out.inc();
+ if(streamingAPI)
+ {
+ out << nl << stream << ".readObject(CType(New IceInternal.SequencePatcher("
+ << param << ", GetType(Ice.Object), ix__), Ice.ReadObjectCallback))";
+ }
+ else
+ {
+ out << nl << stream << ".readObject(New IceInternal.SequencePatcher("
+ << param << ", GetType(Ice.Object), ix__))";
+ }
+ out.dec();
+ out << nl << "Next";
+ }
+ else
+ {
+ if(isArray)
+ {
+ out << "Ice.ObjectPrx(lenx__ - 1) {}";
+ }
+ else
+ {
+ out << typeToString(seq);
+ }
+ out << nl << "For ix__ As Integer = 0 To lenx__ - 1";
+ out.inc();
+ if(isArray)
+ {
+ out << nl << param << "(ix__) = " << stream << ".readProxy()";
+ }
+ else
+ {
+ out << nl << "Dim val__ As Ice.ObjectPrx = New Ice.ObjectPrxHelperBase";
+ out << nl << "val__ = " << stream << ".readProxy()";
+ out << nl << param << ".Add(val__)";
+ }
+ out.dec();
+ out << nl << "Next";
+ }
+ if(!streamingAPI && builtin->isVariableLength())
+ {
+ out << nl << stream << ".checkSeq()";
+ out << nl << stream << ".endElement()";
+ out << nl << stream << ".endSeq(lenx__)";
+ }
+ out.dec();
+ out << nl << "Next";
+ }
+ break;
+ }
+ default:
+ {
+ string marshalName = builtin->kindAsString();
+ marshalName[0] = toupper(marshalName[0]);
+ if(marshal)
+ {
+ out << nl << stream << ".write" << marshalName << "Seq(" << param;
+ if(!isArray)
+ {
+ out << ".ToArray()";
+ }
+ out << ')';
+ }
+ else
+ {
+ if(!isArray)
+ {
+ out << nl << param << " = New " << fixId(seq->scoped())
+ << '(' << stream << ".read" << marshalName << "Seq())";
+ }
+ else
+ {
+ out << nl << param << " = " << stream << ".read" << marshalName << "Seq()";
+ }
+ }
+ break;
+ }
+ }
+ return;
}
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
if(cl)
{
- out << nl << "For block__ As Integer = 0 To 0";
- out.inc();
+ out << nl << "For block__ As Integer = 0 To 0";
+ out.inc();
if(marshal)
{
- out << nl << "If " << param << " Is Nothing";
- out.inc();
- out << nl << stream << ".writeSize(0)";
- out.dec();
- out << nl << "Else";
- out.inc();
- out << nl << stream << ".writeSize(" << param << '.' << limitID << ")";
- out << nl << "For ix__ As Integer = 0 To " << param << '.' << limitID << " - 1";
- out.inc();
+ out << nl << "If " << param << " Is Nothing";
+ out.inc();
+ out << nl << stream << ".writeSize(0)";
+ out.dec();
+ out << nl << "Else";
+ out.inc();
+ out << nl << stream << ".writeSize(" << param << '.' << limitID << ")";
+ out << nl << "For ix__ As Integer = 0 To " << param << '.' << limitID << " - 1";
+ out.inc();
out << nl << stream << ".writeObject(" << param << "(ix__))";
- out.dec();
- out << nl << "Next";
- out.dec();
- out << nl << "End If";
+ out.dec();
+ out << nl << "Next";
+ out.dec();
+ out << nl << "End If";
}
else
{
- out << nl << "Dim szx__ As Integer = " << stream << ".readSize()";
- if(!streamingAPI)
- {
+ out << nl << "Dim szx__ As Integer = " << stream << ".readSize()";
+ if(!streamingAPI)
+ {
if(type->isVariableLength())
{
out << nl << stream << ".startSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ')';
@@ -755,79 +755,79 @@ Slice::VbGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
{
out << nl << stream << ".checkFixedSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ')';
}
- }
- out << nl << param << " = New ";
- if(isArray)
- {
- out << toArrayAlloc(typeS + "()", "szx__ - 1") << " {}";
- }
- else
- {
- out << fixId(seq->scoped()) << "(szx__)";
- }
- out << nl << "For ix__ As Integer = 0 To szx__ - 1";
- out.inc();
- out << nl << "Dim spx__ As IceInternal.SequencePatcher = New IceInternal.SequencePatcher("
- << param << ", " << "GetType(" << typeS << "), ix__)";
- if(streamingAPI)
- {
- out << nl << stream << ".readObject(CType(spx__, Ice.ReadObjectCallback))";
- }
- else
- {
- out << nl << stream << ".readObject(spx__)";
- }
- if(!streamingAPI && type->isVariableLength())
- {
- out << nl << stream << ".checkSeq()";
- out << nl << stream << ".endElement()";
- }
- out.dec();
- out << nl << "Next";
- if(!streamingAPI && type->isVariableLength())
- {
- out << nl << stream << ".endSeq(szx__)";
- }
+ }
+ out << nl << param << " = New ";
+ if(isArray)
+ {
+ out << toArrayAlloc(typeS + "()", "szx__ - 1") << " {}";
+ }
+ else
+ {
+ out << fixId(seq->scoped()) << "(szx__)";
+ }
+ out << nl << "For ix__ As Integer = 0 To szx__ - 1";
+ out.inc();
+ out << nl << "Dim spx__ As IceInternal.SequencePatcher = New IceInternal.SequencePatcher("
+ << param << ", " << "GetType(" << typeS << "), ix__)";
+ if(streamingAPI)
+ {
+ out << nl << stream << ".readObject(CType(spx__, Ice.ReadObjectCallback))";
+ }
+ else
+ {
+ out << nl << stream << ".readObject(spx__)";
+ }
+ if(!streamingAPI && type->isVariableLength())
+ {
+ out << nl << stream << ".checkSeq()";
+ out << nl << stream << ".endElement()";
+ }
+ out.dec();
+ out << nl << "Next";
+ if(!streamingAPI && type->isVariableLength())
+ {
+ out << nl << stream << ".endSeq(szx__)";
+ }
}
- out.dec();
- out << nl << "Next";
+ out.dec();
+ out << nl << "Next";
return;
}
StructPtr st = StructPtr::dynamicCast(type);
if(st)
{
- out << nl << "For block__ As Integer = 0 To 0";
- out.inc();
+ out << nl << "For block__ As Integer = 0 To 0";
+ out.inc();
if(marshal)
- {
- out << nl << "If " << param << " Is Nothing";
- out.inc();
- out << nl << stream << ".writeSize(0)";
- out.dec();
- out << nl << "Else";
- out.inc();
- out << nl << stream << ".writeSize(" << param << '.' << limitID << ")";
- out << nl << "For ix__ As Integer = 0 To " << param << '.' << limitID << " - 1";
- out.inc();
- if(streamingAPI)
- {
- out << nl << param << "(ix__).ice_write(" << stream << ")";
- }
- else
- {
- out << nl << param << "(ix__).write__(" << stream << ")";
- }
- out.dec();
- out << nl << "Next";
- out.dec();
- out << nl << "End If";
- }
- else
- {
- out << nl << "Dim szx__ As Integer = " << stream << ".readSize()";
- if(!streamingAPI)
- {
+ {
+ out << nl << "If " << param << " Is Nothing";
+ out.inc();
+ out << nl << stream << ".writeSize(0)";
+ out.dec();
+ out << nl << "Else";
+ out.inc();
+ out << nl << stream << ".writeSize(" << param << '.' << limitID << ")";
+ out << nl << "For ix__ As Integer = 0 To " << param << '.' << limitID << " - 1";
+ out.inc();
+ if(streamingAPI)
+ {
+ out << nl << param << "(ix__).ice_write(" << stream << ")";
+ }
+ else
+ {
+ out << nl << param << "(ix__).write__(" << stream << ")";
+ }
+ out.dec();
+ out << nl << "Next";
+ out.dec();
+ out << nl << "End If";
+ }
+ else
+ {
+ out << nl << "Dim szx__ As Integer = " << stream << ".readSize()";
+ if(!streamingAPI)
+ {
if(type->isVariableLength())
{
out << nl << stream << ".startSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ')';
@@ -836,164 +836,164 @@ Slice::VbGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
{
out << nl << stream << ".checkFixedSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ')';
}
- }
- out << nl << param << " = New ";
- if(isArray)
- {
- out << toArrayAlloc(typeS + "()", "szx__ - 1") << " {}";
- }
- else
- {
- out << fixId(seq->scoped()) << "(szx__)";
- }
- out << nl << "For ix__ As Integer = 0 To szx__ - 1";
- out.inc();
- if(isArray)
- {
- if(!isValueType(st))
- {
- out << nl << param << "(ix__) = New " << typeS;
- }
- if(streamingAPI)
- {
- out << nl << param << "(ix__).ice_read(" << stream << ")";
- }
- else
- {
- out << nl << param << "(ix__).read__(" << stream << ")";
- }
- }
- else
- {
- out << nl << "Dim val__ As " << typeS << " = New " << typeS;
- if(streamingAPI)
- {
- out << nl << "val__.ice_read(" << stream << ')';
- }
- else
- {
- out << nl << "val__.read__(" << stream << ')';
- }
- out << nl << param << ".Add(val__)";
- }
- if(!streamingAPI && type->isVariableLength())
- {
- out << nl << stream << ".checkSeq()";
- out << nl << stream << ".endElement()";
- }
- out.dec();
- out << nl << "Next";
- if(!streamingAPI && type->isVariableLength())
- {
- out << nl << stream << ".endSeq(szx__)";
- }
- }
- out.dec();
- out << nl << "Next";
- return;
+ }
+ out << nl << param << " = New ";
+ if(isArray)
+ {
+ out << toArrayAlloc(typeS + "()", "szx__ - 1") << " {}";
+ }
+ else
+ {
+ out << fixId(seq->scoped()) << "(szx__)";
+ }
+ out << nl << "For ix__ As Integer = 0 To szx__ - 1";
+ out.inc();
+ if(isArray)
+ {
+ if(!isValueType(st))
+ {
+ out << nl << param << "(ix__) = New " << typeS;
+ }
+ if(streamingAPI)
+ {
+ out << nl << param << "(ix__).ice_read(" << stream << ")";
+ }
+ else
+ {
+ out << nl << param << "(ix__).read__(" << stream << ")";
+ }
+ }
+ else
+ {
+ out << nl << "Dim val__ As " << typeS << " = New " << typeS;
+ if(streamingAPI)
+ {
+ out << nl << "val__.ice_read(" << stream << ')';
+ }
+ else
+ {
+ out << nl << "val__.read__(" << stream << ')';
+ }
+ out << nl << param << ".Add(val__)";
+ }
+ if(!streamingAPI && type->isVariableLength())
+ {
+ out << nl << stream << ".checkSeq()";
+ out << nl << stream << ".endElement()";
+ }
+ out.dec();
+ out << nl << "Next";
+ if(!streamingAPI && type->isVariableLength())
+ {
+ out << nl << stream << ".endSeq(szx__)";
+ }
+ }
+ out.dec();
+ out << nl << "Next";
+ return;
}
EnumPtr en = EnumPtr::dynamicCast(type);
if(en)
{
- out << nl << "For block__ As Integer = 0 To 0";
- out.inc();
- if(marshal)
- {
- out << nl << "If " << param << " Is Nothing";
- out.inc();
- out << nl << stream << ".writeSize(0)";
- out.dec();
- out << nl << "Else";
- out.inc();
- out << nl << stream << ".writeSize(" << param << '.'<< limitID << ')';
- out << nl << "For ix__ As Integer = 0 To " << param << '.' << limitID << " - 1";
- out.inc();
- out << nl << stream << ".writeByte(CType(" << param << "(ix__), Byte))";
- out.dec();
- out << nl << "Next";
- out.dec();
- out << nl << "End If";
- }
- else
- {
- out << nl << "Dim szx__ As Integer = " << stream << ".readSize()";
- if(!streamingAPI)
- {
- out << nl << stream << ".checkFixedSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ')';
- }
- out << nl << param << " = New ";
- if(isArray)
- {
- out << toArrayAlloc(typeS + "()", "szx__ - 1") << " {}";
- }
- else
- {
- out << fixId(seq->scoped()) << "(szx__)";
- }
- out << nl << "For ix__ As Integer = 0 To szx__ - 1";
- out.inc();
- if(isArray)
- {
- out << nl << param << "(ix__) = CType(" << stream << ".readByte(), " << typeS << ')';
- }
- else
- {
- out << nl << param << ".Add(CType(" << stream << ".readByte(), " << typeS << "))";
- }
- out.dec();
- out << nl << "Next";
- }
- out.dec();
- out << nl << "Next";
+ out << nl << "For block__ As Integer = 0 To 0";
+ out.inc();
+ if(marshal)
+ {
+ out << nl << "If " << param << " Is Nothing";
+ out.inc();
+ out << nl << stream << ".writeSize(0)";
+ out.dec();
+ out << nl << "Else";
+ out.inc();
+ out << nl << stream << ".writeSize(" << param << '.'<< limitID << ')';
+ out << nl << "For ix__ As Integer = 0 To " << param << '.' << limitID << " - 1";
+ out.inc();
+ out << nl << stream << ".writeByte(CType(" << param << "(ix__), Byte))";
+ out.dec();
+ out << nl << "Next";
+ out.dec();
+ out << nl << "End If";
+ }
+ else
+ {
+ out << nl << "Dim szx__ As Integer = " << stream << ".readSize()";
+ if(!streamingAPI)
+ {
+ out << nl << stream << ".checkFixedSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ')';
+ }
+ out << nl << param << " = New ";
+ if(isArray)
+ {
+ out << toArrayAlloc(typeS + "()", "szx__ - 1") << " {}";
+ }
+ else
+ {
+ out << fixId(seq->scoped()) << "(szx__)";
+ }
+ out << nl << "For ix__ As Integer = 0 To szx__ - 1";
+ out.inc();
+ if(isArray)
+ {
+ out << nl << param << "(ix__) = CType(" << stream << ".readByte(), " << typeS << ')';
+ }
+ else
+ {
+ out << nl << param << ".Add(CType(" << stream << ".readByte(), " << typeS << "))";
+ }
+ out.dec();
+ out << nl << "Next";
+ }
+ out.dec();
+ out << nl << "Next";
return;
}
string helperName;
if(ProxyPtr::dynamicCast(type))
{
- helperName = fixId(ProxyPtr::dynamicCast(type)->_class()->scoped() + "PrxHelper");
+ helperName = fixId(ProxyPtr::dynamicCast(type)->_class()->scoped() + "PrxHelper");
}
else
{
- helperName = fixId(ContainedPtr::dynamicCast(type)->scoped() + "Helper");
+ helperName = fixId(ContainedPtr::dynamicCast(type)->scoped() + "Helper");
}
string func;
if(marshal)
{
- func = "write";
- if(!streamingAPI && ProxyPtr::dynamicCast(type))
- {
- func += "__";
- }
- out << nl << "If " << param << " Is Nothing";
- out.inc();
- out << nl << stream << ".writeSize(0)";
- out.dec();
- out << nl << "Else";
- out.inc();
- out << nl << stream << ".writeSize(" << param << '.' << limitID << ")";
- out << nl << "For ix__ As Integer = 0 To " << param << '.' << limitID << " - 1";
- out.inc();
- out << nl << helperName << '.' << func << '(' << stream << ", " << param << "(ix__))";
- out.dec();
- out << nl << "Next";
- out.dec();
- out << nl << "End If";
+ func = "write";
+ if(!streamingAPI && ProxyPtr::dynamicCast(type))
+ {
+ func += "__";
+ }
+ out << nl << "If " << param << " Is Nothing";
+ out.inc();
+ out << nl << stream << ".writeSize(0)";
+ out.dec();
+ out << nl << "Else";
+ out.inc();
+ out << nl << stream << ".writeSize(" << param << '.' << limitID << ")";
+ out << nl << "For ix__ As Integer = 0 To " << param << '.' << limitID << " - 1";
+ out.inc();
+ out << nl << helperName << '.' << func << '(' << stream << ", " << param << "(ix__))";
+ out.dec();
+ out << nl << "Next";
+ out.dec();
+ out << nl << "End If";
}
else
{
func = "read";
- if(!streamingAPI && ProxyPtr::dynamicCast(type))
- {
- func += "__";
- }
- out << nl << "For block__ As Integer = 0 To 0";
- out.inc();
- out << nl << "Dim szx__ As Integer = " << stream << ".readSize()";
- if(!streamingAPI)
- {
+ if(!streamingAPI && ProxyPtr::dynamicCast(type))
+ {
+ func += "__";
+ }
+ out << nl << "For block__ As Integer = 0 To 0";
+ out.inc();
+ out << nl << "Dim szx__ As Integer = " << stream << ".readSize()";
+ if(!streamingAPI)
+ {
if(type->isVariableLength())
{
out << nl << stream << ".startSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ")";
@@ -1002,42 +1002,42 @@ Slice::VbGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
{
out << nl << stream << ".checkFixedSeq(szx__, " << static_cast<unsigned>(type->minWireSize()) << ")";
}
- }
- out << nl << param << " = New ";
- if(isArray)
- {
- out << toArrayAlloc(typeS + "()", "szx__ - 1") << " {}";
- }
- else
- {
- out << fixId(seq->scoped()) << "(szx__)";
- }
- out << nl << "For ix__ As Integer = 0 To szx__ - 1";
- out.inc();
- if(isArray)
- {
- out << nl << param << "(ix__) = " << helperName << '.' << func << '(' << stream << ")";
- }
- else
- {
- out << nl << param << ".Add(" << helperName << '.' << func << '(' << stream << "))";
- }
- if(!streamingAPI && type->isVariableLength())
- {
- if(!SequencePtr::dynamicCast(type))
- {
- out << nl << stream << ".checkSeq()";
- }
+ }
+ out << nl << param << " = New ";
+ if(isArray)
+ {
+ out << toArrayAlloc(typeS + "()", "szx__ - 1") << " {}";
+ }
+ else
+ {
+ out << fixId(seq->scoped()) << "(szx__)";
+ }
+ out << nl << "For ix__ As Integer = 0 To szx__ - 1";
+ out.inc();
+ if(isArray)
+ {
+ out << nl << param << "(ix__) = " << helperName << '.' << func << '(' << stream << ")";
+ }
+ else
+ {
+ out << nl << param << ".Add(" << helperName << '.' << func << '(' << stream << "))";
+ }
+ if(!streamingAPI && type->isVariableLength())
+ {
+ if(!SequencePtr::dynamicCast(type))
+ {
+ out << nl << stream << ".checkSeq()";
+ }
out << nl << stream << ".endElement()";
- }
- out.dec();
- out << nl << "Next";
- if(!streamingAPI && type->isVariableLength())
- {
- out << nl << stream << ".endSeq(szx__)";
- }
- out.dec();
- out << nl << "Next";
+ }
+ out.dec();
+ out << nl << "Next";
+ if(!streamingAPI && type->isVariableLength())
+ {
+ out << nl << stream << ".endSeq(szx__)";
+ }
+ out.dec();
+ out << nl << "Next";
}
return;
@@ -1051,7 +1051,7 @@ Slice::VbGenerator::toArrayAlloc(const string& decl, const string& sz)
while(pos > 1 && decl.substr(pos - 2, 2) == "()")
{
++count;
- pos -= 2;
+ pos -= 2;
}
assert(count > 0);
@@ -1077,31 +1077,31 @@ Slice::VbGenerator::MetaDataVisitor::visitModuleStart(const ModulePtr& p)
{
if(!_globalMetaDataDone)
{
- //
- // Validate global metadata.
- //
- DefinitionContextPtr dc = p->definitionContext();
- assert(dc);
- StringList globalMetaData = dc->getMetaData();
- string file = dc->filename();
- static const string prefix = "vb:";
- for(StringList::const_iterator q = globalMetaData.begin(); q != globalMetaData.end(); ++q)
- {
- string s = *q;
- if(_history.count(s) == 0)
- {
- if(s.find(prefix) == 0)
- {
- static const string attributePrefix = "vb:attribute:";
- if(s.find(attributePrefix) != 0 || s.size() == attributePrefix.size())
- {
- cout << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl;
- }
- }
- _history.insert(s);
- }
- }
- _globalMetaDataDone = true;
+ //
+ // Validate global metadata.
+ //
+ DefinitionContextPtr dc = p->definitionContext();
+ assert(dc);
+ StringList globalMetaData = dc->getMetaData();
+ string file = dc->filename();
+ static const string prefix = "vb:";
+ for(StringList::const_iterator q = globalMetaData.begin(); q != globalMetaData.end(); ++q)
+ {
+ string s = *q;
+ if(_history.count(s) == 0)
+ {
+ if(s.find(prefix) == 0)
+ {
+ static const string attributePrefix = "vb:attribute:";
+ if(s.find(attributePrefix) != 0 || s.size() == attributePrefix.size())
+ {
+ cout << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl;
+ }
+ }
+ _history.insert(s);
+ }
+ }
+ _globalMetaDataDone = true;
}
validate(p);
return true;
@@ -1209,83 +1209,83 @@ Slice::VbGenerator::MetaDataVisitor::validate(const ContainedPtr& cont)
for(p = localMetaData.begin(); p != localMetaData.end(); ++p)
{
- string s = *p;
+ string s = *p;
- if(s.find("vb:") == 0) // TODO: remove this statement once "vb:" is a hard error.
- {
- if(SequencePtr::dynamicCast(cont))
- {
- if(s.substr(3) == "collection")
- {
- cout << file << ":" << cont->line() << ": warning: `vb:' metadata prefix is deprecated; "
- << "use `clr:' instead" << endl;
- cont->addMetaData("clr:collection");
- }
- }
- else if(StructPtr::dynamicCast(cont))
- {
- if(s.substr(3) == "class")
- {
- cout << file << ":" << cont->line() << ": warning: `vb:' metadata prefix is deprecated; "
- << "use `clr:' instead" << endl;
- cont->addMetaData("clr:class");
- }
- }
- else if(s.find("vb:attribute:") == 0)
- {
- ; // Do nothing, "vb:attribute:" is OK
- }
- else
- {
- cout << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl;
- }
- } // End TODO
+ if(s.find("vb:") == 0) // TODO: remove this statement once "vb:" is a hard error.
+ {
+ if(SequencePtr::dynamicCast(cont))
+ {
+ if(s.substr(3) == "collection")
+ {
+ cout << file << ":" << cont->line() << ": warning: `vb:' metadata prefix is deprecated; "
+ << "use `clr:' instead" << endl;
+ cont->addMetaData("clr:collection");
+ }
+ }
+ else if(StructPtr::dynamicCast(cont))
+ {
+ if(s.substr(3) == "class")
+ {
+ cout << file << ":" << cont->line() << ": warning: `vb:' metadata prefix is deprecated; "
+ << "use `clr:' instead" << endl;
+ cont->addMetaData("clr:class");
+ }
+ }
+ else if(s.find("vb:attribute:") == 0)
+ {
+ ; // Do nothing, "vb:attribute:" is OK
+ }
+ else
+ {
+ cout << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl;
+ }
+ } // End TODO
- string prefix = "clr:";
+ string prefix = "clr:";
if(_history.count(s) == 0)
{
if(s.find(prefix) == 0)
{
- if(SequencePtr::dynamicCast(cont))
- {
- if(s.substr(prefix.size()) == "collection")
- {
- continue;
- }
- }
- if(StructPtr::dynamicCast(cont))
- {
- if(s.substr(prefix.size()) == "class")
- {
- continue;
- }
- if(s.substr(prefix.size()) == "property")
- {
- continue;
- }
- }
- if(ClassDefPtr::dynamicCast(cont))
- {
- if(s.substr(prefix.size()) == "property")
- {
- continue;
- }
- }
- cout << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl;
+ if(SequencePtr::dynamicCast(cont))
+ {
+ if(s.substr(prefix.size()) == "collection")
+ {
+ continue;
+ }
+ }
+ if(StructPtr::dynamicCast(cont))
+ {
+ if(s.substr(prefix.size()) == "class")
+ {
+ continue;
+ }
+ if(s.substr(prefix.size()) == "property")
+ {
+ continue;
+ }
+ }
+ if(ClassDefPtr::dynamicCast(cont))
+ {
+ if(s.substr(prefix.size()) == "property")
+ {
+ continue;
+ }
+ }
+ cout << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl;
}
_history.insert(s);
}
- prefix = "vb:";
+ prefix = "vb:";
if(_history.count(s) == 0)
{
if(s.find(prefix) == 0)
{
- if(s.substr(prefix.size()) == "attribute:")
- {
- continue;
- }
- cout << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl;
+ if(s.substr(prefix.size()) == "attribute:")
+ {
+ continue;
+ }
+ cout << file << ":" << cont->line() << ": warning: ignoring invalid metadata `" << s << "'" << endl;
}
_history.insert(s);
}
diff --git a/cpp/src/ca/ImportKey.java b/cpp/src/ca/ImportKey.java
index 117de0f46fb..a8a41e0e932 100644
--- a/cpp/src/ca/ImportKey.java
+++ b/cpp/src/ca/ImportKey.java
@@ -23,108 +23,108 @@ public class ImportKey
static private char[]
readPassword(String f)
{
- try
- {
- java.io.InputStream s = new java.io.FileInputStream(f);
- int n = s.available();
- byte[] raw = new byte[n];
- s.read(raw);
- s.close();
-
- return (new String(raw)).toCharArray();
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- System.exit(1);
- }
- return null;
+ try
+ {
+ java.io.InputStream s = new java.io.FileInputStream(f);
+ int n = s.available();
+ byte[] raw = new byte[n];
+ s.read(raw);
+ s.close();
+
+ return (new String(raw)).toCharArray();
+ }
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ System.exit(1);
+ }
+ return null;
}
-
+
public static void
main(String[] args)
{
- if(args.length < 5)
- {
- //
- // Arguments:
- //
- // pkcs12-file A file in PKCS12 format that contains the
- // private key and certificate chain.
- //
- // alias The key's friendly name in pkcs12-file and the
- // alias for the key in the new keystore.
- //
- // cert-file The CA certificate file in DER format.
- //
- // keystore-file The name of the keystore file to update
- // or create.
- //
- // store-password The file containing the password to use
- // for the keystore.
- //
- // key-password The file containing the password to use
- // for the key.
- //
- // kstore-password The file containing the password to use
- // to store the key. If this isn't provided the
- // key-password is used. This is used to import an
- // unprotected private key.
- //
- System.err.println("Usage: ImportKey pkcs12-file alias cert-file " +
- "keystore-file store-password key-password [kstore-password]");
- System.exit(1);
- }
+ if(args.length < 5)
+ {
+ //
+ // Arguments:
+ //
+ // pkcs12-file A file in PKCS12 format that contains the
+ // private key and certificate chain.
+ //
+ // alias The key's friendly name in pkcs12-file and the
+ // alias for the key in the new keystore.
+ //
+ // cert-file The CA certificate file in DER format.
+ //
+ // keystore-file The name of the keystore file to update
+ // or create.
+ //
+ // store-password The file containing the password to use
+ // for the keystore.
+ //
+ // key-password The file containing the password to use
+ // for the key.
+ //
+ // kstore-password The file containing the password to use
+ // to store the key. If this isn't provided the
+ // key-password is used. This is used to import an
+ // unprotected private key.
+ //
+ System.err.println("Usage: ImportKey pkcs12-file alias cert-file " +
+ "keystore-file store-password key-password [kstore-password]");
+ System.exit(1);
+ }
- final String pkcs12File = args[0];
- final String alias = args[1];
- final String certFile = args[2];
- final String keystoreFile = args[3];
- final char[] storePassword = readPassword(args[4]);
- final char[] keyPassword = readPassword(args[5]);
- char[] kstorePassword = readPassword(args[5]);
- if(args.length > 6)
- {
- kstorePassword = readPassword(args[6]);
- }
- else
- {
- kstorePassword = keyPassword;
- }
+ final String pkcs12File = args[0];
+ final String alias = args[1];
+ final String certFile = args[2];
+ final String keystoreFile = args[3];
+ final char[] storePassword = readPassword(args[4]);
+ final char[] keyPassword = readPassword(args[5]);
+ char[] kstorePassword = readPassword(args[5]);
+ if(args.length > 6)
+ {
+ kstorePassword = readPassword(args[6]);
+ }
+ else
+ {
+ kstorePassword = keyPassword;
+ }
- try
- {
- KeyStore src = KeyStore.getInstance("PKCS12");
- src.load(new java.io.FileInputStream(pkcs12File), keyPassword);
+ try
+ {
+ KeyStore src = KeyStore.getInstance("PKCS12");
+ src.load(new java.io.FileInputStream(pkcs12File), keyPassword);
- KeyStore dest = KeyStore.getInstance("JKS");
- java.io.File f = new java.io.File(keystoreFile);
- if(f.exists())
- {
- dest.load(new java.io.FileInputStream(f), storePassword);
- }
- else
- {
- dest.load(null, null);
- }
- Certificate[] chain = src.getCertificateChain(alias);
- Key key = src.getKey(alias, keyPassword);
+ KeyStore dest = KeyStore.getInstance("JKS");
+ java.io.File f = new java.io.File(keystoreFile);
+ if(f.exists())
+ {
+ dest.load(new java.io.FileInputStream(f), storePassword);
+ }
+ else
+ {
+ dest.load(null, null);
+ }
+ Certificate[] chain = src.getCertificateChain(alias);
+ Key key = src.getKey(alias, keyPassword);
- CertificateFactory cf = CertificateFactory.getInstance("X.509");
- X509Certificate cert = (X509Certificate)
- cf.generateCertificate(new java.io.FileInputStream(certFile));
+ CertificateFactory cf = CertificateFactory.getInstance("X.509");
+ X509Certificate cert = (X509Certificate)
+ cf.generateCertificate(new java.io.FileInputStream(certFile));
- dest.setKeyEntry(alias, key, kstorePassword, chain);
- dest.setCertificateEntry("cacert", cert);
+ dest.setKeyEntry(alias, key, kstorePassword, chain);
+ dest.setCertificateEntry("cacert", cert);
- dest.store(new java.io.FileOutputStream(keystoreFile), storePassword);
- }
- catch(Exception ex)
- {
- ex.printStackTrace();
- System.exit(1);
- }
+ dest.store(new java.io.FileOutputStream(keystoreFile), storePassword);
+ }
+ catch(Exception ex)
+ {
+ ex.printStackTrace();
+ System.exit(1);
+ }
- System.exit(0);
+ System.exit(0);
}
}
diff --git a/cpp/src/icecpp/cccp.c b/cpp/src/icecpp/cccp.c
index 2e95afb6a19..7c350441055 100644
--- a/cpp/src/icecpp/cccp.c
+++ b/cpp/src/icecpp/cccp.c
@@ -130,10 +130,10 @@ extern char *getenv ();
/* VMS-specific definitions */
#ifdef VMS
#include <descrip.h>
-#define open(fname,mode,prot) VMS_open (fname,mode,prot)
-#define fopen(fname,mode) VMS_fopen (fname,mode)
+#define open(fname,mode,prot) VMS_open (fname,mode,prot)
+#define fopen(fname,mode) VMS_fopen (fname,mode)
#define freopen(fname,mode,ofile) VMS_freopen (fname,mode,ofile)
-#define fstat(fd,stbuf) VMS_fstat (fd,stbuf)
+#define fstat(fd,stbuf) VMS_fstat (fd,stbuf)
static int VMS_fstat (), VMS_stat ();
static int VMS_open ();
static FILE *VMS_fopen ();
@@ -141,7 +141,7 @@ static FILE *VMS_freopen ();
static void hack_vms_include_specification ();
#define INO_T_EQ(a, b) (!bcmp((char *) &(a), (char *) &(b), sizeof (a)))
#define INO_T_HASH(a) 0
-#define INCLUDE_LEN_FUDGE 12 /* leave room for VMS syntax conversion */
+#define INCLUDE_LEN_FUDGE 12 /* leave room for VMS syntax conversion */
#endif /* VMS */
/* Windows does not natively support inodes, and neither does MSDOS. */
@@ -207,10 +207,10 @@ extern char *update_path PROTO((char *, char *));
//#ifndef HAVE_STRERROR
//extern int sys_nerr;
//extern char *sys_errlist[];
-//#else /* HAVE_STRERROR */
+//#else /* HAVE_STRERROR */
//char *strerror ();
//#endif
-//#else /* VMS */
+//#else /* VMS */
//char *strerror (int,...);
//#endif
HOST_WIDE_INT parse_escape PROTO((char **, HOST_WIDE_INT));
@@ -429,18 +429,18 @@ static struct file_buf {
char system_header_p;
} instack[INPUT_STACK_MAX];
-static int last_error_tick; /* Incremented each time we print it. */
+static int last_error_tick; /* Incremented each time we print it. */
static int input_file_stack_tick; /* Incremented when the status changes. */
/* Current nesting level of input sources.
`instack[indepth]' is the level currently being read. */
static int indepth = -1;
#define CHECK_DEPTH(code) \
- if (indepth >= (INPUT_STACK_MAX - 1)) \
- { \
- error_with_line (line_for_error (instack[indepth].lineno), \
- "macro or `#include' recursion too deep"); \
- code; \
+ if (indepth >= (INPUT_STACK_MAX - 1)) \
+ { \
+ error_with_line (line_for_error (instack[indepth].lineno), \
+ "macro or `#include' recursion too deep"); \
+ code; \
}
/* Current depth in #include directives that use <...>. */
@@ -452,7 +452,7 @@ typedef struct file_buf FILE_BUF;
for the buffer, not the number of chars actually present. To get
that, subtract outbuf.buf from outbuf.bufp. */
-#define OUTBUF_SIZE 10 /* initial size of output buffer */
+#define OUTBUF_SIZE 10 /* initial size of output buffer */
static FILE_BUF outbuf;
/* Grow output buffer OBUF points at
@@ -485,12 +485,12 @@ struct file_name_list
/* -I directories are added to the end, then the defaults are added. */
/* The */
static struct default_include {
- char *fname; /* The name of the directory. */
- char *component; /* The component containing the directory */
- int cplusplus; /* Only look here if we're compiling C++. */
- int cxx_aware; /* Includes in this directory don't need to
- be wrapped in extern "C" when compiling
- C++. */
+ char *fname; /* The name of the directory. */
+ char *component; /* The component containing the directory */
+ int cplusplus; /* Only look here if we're compiling C++. */
+ int cxx_aware; /* Includes in this directory don't need to
+ be wrapped in extern "C" when compiling
+ C++. */
} include_defaults_array[]
#ifdef INCLUDE_DEFAULTS
= INCLUDE_DEFAULTS;
@@ -542,23 +542,23 @@ static struct default_include {
variable specifies other defaults. */
static struct default_include *include_defaults = include_defaults_array;
-static struct file_name_list *include = 0; /* First dir to search */
- /* First dir to search for <file> */
+static struct file_name_list *include = 0; /* First dir to search */
+ /* First dir to search for <file> */
/* This is the first element to use for #include <...>.
If it is 0, use the entire chain for such includes. */
static struct file_name_list *first_bracket_include = 0;
/* This is the first element in the chain that corresponds to
a directory of system header files. */
static struct file_name_list *first_system_include = 0;
-static struct file_name_list *last_include = 0; /* Last in chain */
+static struct file_name_list *last_include = 0; /* Last in chain */
/* Chain of include directories to put at the end of the other chain. */
static struct file_name_list *after_include = 0;
-static struct file_name_list *last_after_include = 0; /* Last in chain */
+static struct file_name_list *last_after_include = 0; /* Last in chain */
/* Chain to put at the start of the system include files. */
static struct file_name_list *before_system = 0;
-static struct file_name_list *last_before_system = 0; /* Last in chain */
+static struct file_name_list *last_before_system = 0; /* Last in chain */
/* Directory prefix that should replace `/usr' in the standard
include file directories. */
@@ -606,18 +606,18 @@ struct macrodef
};
enum sharp_token_type {
- NO_SHARP_TOKEN = 0, /* token not present */
+ NO_SHARP_TOKEN = 0, /* token not present */
- SHARP_TOKEN = '#', /* token spelled with # only */
- WHITE_SHARP_TOKEN, /* token spelled with # and white space */
+ SHARP_TOKEN = '#', /* token spelled with # only */
+ WHITE_SHARP_TOKEN, /* token spelled with # and white space */
- PERCENT_COLON_TOKEN = '%', /* token spelled with %: only */
- WHITE_PERCENT_COLON_TOKEN /* token spelled with %: and white space */
+ PERCENT_COLON_TOKEN = '%', /* token spelled with %: only */
+ WHITE_PERCENT_COLON_TOKEN /* token spelled with %: and white space */
};
/* Structure allocated for every #define. For a simple replacement
such as
- #define foo bar ,
+ #define foo bar ,
nargs = -1, the `pattern' list is null, and the expansion is just
the replacement text. Nargs = 0 means a functionlike macro with no args,
e.g.,
@@ -639,24 +639,24 @@ enum sharp_token_type {
typedef struct definition DEFINITION;
struct definition {
int nargs;
- int length; /* length of expansion string */
- int predefined; /* True if the macro was builtin or */
- /* came from the command line */
+ int length; /* length of expansion string */
+ int predefined; /* True if the macro was builtin or */
+ /* came from the command line */
U_CHAR *expansion;
- int line; /* Line number of definition */
- char *file; /* File of definition */
- char rest_args; /* Nonzero if last arg. absorbs the rest */
+ int line; /* Line number of definition */
+ char *file; /* File of definition */
+ char rest_args; /* Nonzero if last arg. absorbs the rest */
struct reflist {
struct reflist *next;
- enum sharp_token_type stringify; /* set if a # operator before arg */
- enum sharp_token_type raw_before; /* set if a ## operator before arg */
- enum sharp_token_type raw_after; /* set if a ## operator after arg */
+ enum sharp_token_type stringify; /* set if a # operator before arg */
+ enum sharp_token_type raw_before; /* set if a ## operator before arg */
+ enum sharp_token_type raw_after; /* set if a ## operator after arg */
- char rest_args; /* Nonzero if this arg. absorbs the rest */
- int nchars; /* Number of literal chars to copy before
- this arg occurrence. */
- int argno; /* Number of arg to substitute (origin-0) */
+ char rest_args; /* Nonzero if this arg. absorbs the rest */
+ int nchars; /* Number of literal chars to copy before
+ this arg occurrence. */
+ int argno; /* Number of arg to substitute (origin-0) */
} *pattern;
union {
/* Names of macro args, concatenated in reverse order
@@ -678,17 +678,17 @@ union hashval {
/*
* special extension string that can be added to the last macro argument to
* allow it to absorb the "rest" of the arguments when expanded. Ex:
- * #define wow(a, b...) process (b, a, b)
- * { wow (1, 2, 3); } -> { process (2, 3, 1, 2, 3); }
- * { wow (one, two); } -> { process (two, one, two); }
+ * #define wow(a, b...) process (b, a, b)
+ * { wow (1, 2, 3); } -> { process (2, 3, 1, 2, 3); }
+ * { wow (one, two); } -> { process (two, one, two); }
* if this "rest_arg" is used with the concat token '##' and if it is not
* supplied then the token attached to with ## will not be outputted. Ex:
- * #define wow (a, b...) process (b ## , a, ## b)
- * { wow (1, 2); } -> { process (2, 1, 2); }
- * { wow (one); } -> { process (one); {
+ * #define wow (a, b...) process (b ## , a, ## b)
+ * { wow (1, 2); } -> { process (2, 1, 2); }
+ * { wow (one); } -> { process (one); {
*/
static char rest_extension[] = "...";
-#define REST_EXTENSION_LENGTH (sizeof (rest_extension) - 1)
+#define REST_EXTENSION_LENGTH (sizeof (rest_extension) - 1)
/* The structure of a node in the hash table. The hash table
has entries for all tokens defined by #define directives (type T_MACRO),
@@ -699,56 +699,56 @@ static char rest_extension[] = "...";
/* different flavors of hash nodes --- also used in keyword table */
enum node_type {
- T_DEFINE = 1, /* the `#define' keyword */
- T_INCLUDE, /* the `#include' keyword */
+ T_DEFINE = 1, /* the `#define' keyword */
+ T_INCLUDE, /* the `#include' keyword */
T_INCLUDE_NEXT, /* the `#include_next' keyword */
T_IMPORT, /* the `#import' keyword */
- T_IFDEF, /* the `#ifdef' keyword */
- T_IFNDEF, /* the `#ifndef' keyword */
- T_IF, /* the `#if' keyword */
- T_ELSE, /* `#else' */
- T_PRAGMA, /* `#pragma' */
- T_ELIF, /* `#elif' */
- T_UNDEF, /* `#undef' */
- T_LINE, /* `#line' */
- T_ERROR, /* `#error' */
- T_WARNING, /* `#warning' */
- T_ENDIF, /* `#endif' */
- T_SCCS, /* `#sccs', used on system V. */
- T_IDENT, /* `#ident', used on system V. */
- T_ASSERT, /* `#assert', taken from system V. */
- T_UNASSERT, /* `#unassert', taken from system V. */
- T_SPECLINE, /* special symbol `__LINE__' */
- T_DATE, /* `__DATE__' */
- T_FILE, /* `__FILE__' */
- T_BASE_FILE, /* `__BASE_FILE__' */
+ T_IFDEF, /* the `#ifdef' keyword */
+ T_IFNDEF, /* the `#ifndef' keyword */
+ T_IF, /* the `#if' keyword */
+ T_ELSE, /* `#else' */
+ T_PRAGMA, /* `#pragma' */
+ T_ELIF, /* `#elif' */
+ T_UNDEF, /* `#undef' */
+ T_LINE, /* `#line' */
+ T_ERROR, /* `#error' */
+ T_WARNING, /* `#warning' */
+ T_ENDIF, /* `#endif' */
+ T_SCCS, /* `#sccs', used on system V. */
+ T_IDENT, /* `#ident', used on system V. */
+ T_ASSERT, /* `#assert', taken from system V. */
+ T_UNASSERT, /* `#unassert', taken from system V. */
+ T_SPECLINE, /* special symbol `__LINE__' */
+ T_DATE, /* `__DATE__' */
+ T_FILE, /* `__FILE__' */
+ T_BASE_FILE, /* `__BASE_FILE__' */
T_INCLUDE_LEVEL, /* `__INCLUDE_LEVEL__' */
- T_VERSION, /* `__VERSION__' */
+ T_VERSION, /* `__VERSION__' */
T_SIZE_TYPE, /* `__SIZE_TYPE__' */
T_PTRDIFF_TYPE, /* `__PTRDIFF_TYPE__' */
T_WCHAR_TYPE, /* `__WCHAR_TYPE__' */
T_USER_LABEL_PREFIX_TYPE, /* `__USER_LABEL_PREFIX__' */
T_REGISTER_PREFIX_TYPE, /* `__REGISTER_PREFIX__' */
T_IMMEDIATE_PREFIX_TYPE, /* `__IMMEDIATE_PREFIX__' */
- T_TIME, /* `__TIME__' */
- T_CONST, /* Constant value, used by `__STDC__' */
- T_MACRO, /* macro defined by `#define' */
- T_DISABLED, /* macro temporarily turned off for rescan */
+ T_TIME, /* `__TIME__' */
+ T_CONST, /* Constant value, used by `__STDC__' */
+ T_MACRO, /* macro defined by `#define' */
+ T_DISABLED, /* macro temporarily turned off for rescan */
T_SPEC_DEFINED, /* special `defined' macro for use in #if statements */
- T_PCSTRING, /* precompiled string (hashval is KEYDEF *) */
- T_UNUSED /* Used for something not defined. */
+ T_PCSTRING, /* precompiled string (hashval is KEYDEF *) */
+ T_UNUSED /* Used for something not defined. */
};
struct hashnode {
- struct hashnode *next; /* double links for easy deletion */
+ struct hashnode *next; /* double links for easy deletion */
struct hashnode *prev;
- struct hashnode **bucket_hdr; /* also, a back pointer to this node's hash
- chain is kept, in case the node is the head
- of the chain and gets deleted. */
- enum node_type type; /* type of special token */
- int length; /* length of token, for quick comparison */
- U_CHAR *name; /* the actual name */
- union hashval value; /* pointer to expansion, or whatever */
+ struct hashnode **bucket_hdr; /* also, a back pointer to this node's hash
+ chain is kept, in case the node is the head
+ of the chain and gets deleted. */
+ enum node_type type; /* type of special token */
+ int length; /* length of token, for quick comparison */
+ U_CHAR *name; /* the actual name */
+ union hashval value; /* pointer to expansion, or whatever */
};
typedef struct hashnode HASHNODE;
@@ -828,14 +828,14 @@ struct tokenlist_list {
};
struct assertion_hashnode {
- struct assertion_hashnode *next; /* double links for easy deletion */
+ struct assertion_hashnode *next; /* double links for easy deletion */
struct assertion_hashnode *prev;
/* also, a back pointer to this node's hash
chain is kept, in case the node is the head
of the chain and gets deleted. */
struct assertion_hashnode **bucket_hdr;
- int length; /* length of token, for quick comparison */
- U_CHAR *name; /* the actual name */
+ int length; /* length of token, for quick comparison */
+ U_CHAR *name; /* the actual name */
/* List of token-sequences. */
struct tokenlist_list *value;
};
@@ -861,10 +861,10 @@ static int assertions_flag;
#define DO_PROTO PROTO((U_CHAR *, U_CHAR *, FILE_BUF *, struct directive *))
struct directive {
- int length; /* Length of name */
- int (*func) DO_PROTO; /* Function to handle directive */
- char *name; /* Name of directive */
- enum node_type type; /* Code which describes which directive. */
+ int length; /* Length of name */
+ int (*func) DO_PROTO; /* Function to handle directive */
+ char *name; /* Name of directive */
+ enum node_type type; /* Code which describes which directive. */
};
#define IS_INCLUDE_DIRECTIVE_TYPE(t) \
@@ -938,7 +938,7 @@ static char *char_name[256];
#define SKIP_WHITE_SPACE(p) do { while (is_hor_space[*p]) p++; } while (0)
#define SKIP_ALL_WHITE_SPACE(p) do { while (is_space[*p]) p++; } while (0)
-static int errors = 0; /* Error counter for exit code */
+static int errors = 0; /* Error counter for exit code */
/* Name of output file, for error messages. */
static char *out_fname;
@@ -948,14 +948,14 @@ static char *out_fname;
(including both successful and failing conditionals). */
struct if_stack {
- struct if_stack *next; /* for chaining to the next stack frame */
- char *fname; /* copied from input when frame is made */
- int lineno; /* similarly */
- int if_succeeded; /* true if a leg of this if-group
- has been passed through rescan */
- U_CHAR *control_macro; /* For #ifndef at start of file,
- this is the macro name tested. */
- enum node_type type; /* type of last directive seen in this group */
+ struct if_stack *next; /* for chaining to the next stack frame */
+ char *fname; /* copied from input when frame is made */
+ int lineno; /* similarly */
+ int if_succeeded; /* true if a leg of this if-group
+ has been passed through rescan */
+ U_CHAR *control_macro; /* For #ifndef at start of file,
+ this is the macro name tested. */
+ enum node_type type; /* type of last directive seen in this group */
};
typedef struct if_stack IF_STACK_FRAME;
static IF_STACK_FRAME *if_stack = NULL;
@@ -1147,10 +1147,10 @@ safe_read (desc, ptr, len)
if (nchars < 0)
{
#ifdef EINTR
- if (errno == EINTR)
- continue;
+ if (errno == EINTR)
+ continue;
#endif
- return nchars;
+ return nchars;
}
if (nchars == 0)
break;
@@ -1182,10 +1182,10 @@ safe_write (desc, ptr, len)
if (written < 0)
{
#ifdef EINTR
- if (errno == EINTR)
- continue;
+ if (errno == EINTR)
+ continue;
#endif
- pfatal_with_name (out_fname);
+ pfatal_with_name (out_fname);
}
ptr += written;
len -= written;
@@ -1257,12 +1257,12 @@ main (argc, argv)
char *p;
char *s = progname = savestring (progname);
- if ((p = rindex (s, ';')) != 0) *p = '\0'; /* strip version number */
- if ((p = rindex (s, '.')) != 0 /* strip type iff ".exe" */
- && (p[1] == 'e' || p[1] == 'E')
- && (p[2] == 'x' || p[2] == 'X')
- && (p[3] == 'e' || p[3] == 'E')
- && !p[4])
+ if ((p = rindex (s, ';')) != 0) *p = '\0'; /* strip version number */
+ if ((p = rindex (s, '.')) != 0 /* strip type iff ".exe" */
+ && (p[1] == 'e' || p[1] == 'E')
+ && (p[2] == 'x' || p[2] == 'X')
+ && (p[3] == 'e' || p[3] == 'E')
+ && !p[4])
*p = '\0';
}
#endif
@@ -1291,406 +1291,406 @@ main (argc, argv)
for (i = 1; i < argc; i++) {
if (argv[i][0] != '-') {
if (out_fname != NULL)
- fatal ("Usage: %s [switches] input output", argv[0]);
+ fatal ("Usage: %s [switches] input output", argv[0]);
else if (in_fname != NULL)
- out_fname = argv[i];
+ out_fname = argv[i];
else
- in_fname = argv[i];
+ in_fname = argv[i];
} else {
switch (argv[i][1]) {
case 'i':
- if (!strcmp (argv[i], "-include")) {
- if (i + 1 == argc)
- fatal ("Filename missing after `-include' option");
- else
- simplify_filename (pend_includes[i] = argv[++i]);
- }
- if (!strcmp (argv[i], "-imacros")) {
- if (i + 1 == argc)
- fatal ("Filename missing after `-imacros' option");
- else
- simplify_filename (pend_files[i] = argv[++i]);
- }
- if (!strcmp (argv[i], "-iprefix")) {
- if (i + 1 == argc)
- fatal ("Filename missing after `-iprefix' option");
- else
- include_prefix = argv[++i];
- }
- if (!strcmp (argv[i], "-ifoutput")) {
- output_conditionals = 1;
- }
- if (!strcmp (argv[i], "-isystem")) {
- struct file_name_list *dirtmp;
-
- if (! (dirtmp = new_include_prefix (NULL_PTR, NULL_PTR,
- "", argv[++i])))
- break;
- dirtmp->c_system_include_path = 1;
-
- if (before_system == 0)
- before_system = dirtmp;
- else
- last_before_system->next = dirtmp;
- last_before_system = dirtmp; /* Tail follows the last one */
- }
- /* Add directory to end of path for includes,
- with the default prefix at the front of its name. */
- if (!strcmp (argv[i], "-iwithprefix")) {
- struct file_name_list *dirtmp;
- char *prefix;
-
- if (include_prefix != 0)
- prefix = include_prefix;
- else {
- prefix = savestring (GCC_INCLUDE_DIR);
- /* Remove the `include' from /usr/local/lib/gcc.../include. */
- if (!strcmp (prefix + strlen (prefix) - 8, "/include"))
- prefix[strlen (prefix) - 7] = 0;
- }
-
- if (! (dirtmp = new_include_prefix (NULL_PTR, NULL_PTR,
- prefix, argv[++i])))
- break;
-
- if (after_include == 0)
- after_include = dirtmp;
- else
- last_after_include->next = dirtmp;
- last_after_include = dirtmp; /* Tail follows the last one */
- }
- /* Add directory to main path for includes,
- with the default prefix at the front of its name. */
- if (!strcmp (argv[i], "-iwithprefixbefore")) {
- struct file_name_list *dirtmp;
- char *prefix;
-
- if (include_prefix != 0)
- prefix = include_prefix;
- else {
- prefix = savestring (GCC_INCLUDE_DIR);
- /* Remove the `include' from /usr/local/lib/gcc.../include. */
- if (!strcmp (prefix + strlen (prefix) - 8, "/include"))
- prefix[strlen (prefix) - 7] = 0;
- }
-
- dirtmp = new_include_prefix (NULL_PTR, NULL_PTR, prefix, argv[++i]);
- append_include_chain (dirtmp, dirtmp);
- }
- /* Add directory to end of path for includes. */
- if (!strcmp (argv[i], "-idirafter")) {
- struct file_name_list *dirtmp;
-
- if (! (dirtmp = new_include_prefix (NULL_PTR, NULL_PTR,
- "", argv[++i])))
- break;
-
- if (after_include == 0)
- after_include = dirtmp;
- else
- last_after_include->next = dirtmp;
- last_after_include = dirtmp; /* Tail follows the last one */
- }
- break;
+ if (!strcmp (argv[i], "-include")) {
+ if (i + 1 == argc)
+ fatal ("Filename missing after `-include' option");
+ else
+ simplify_filename (pend_includes[i] = argv[++i]);
+ }
+ if (!strcmp (argv[i], "-imacros")) {
+ if (i + 1 == argc)
+ fatal ("Filename missing after `-imacros' option");
+ else
+ simplify_filename (pend_files[i] = argv[++i]);
+ }
+ if (!strcmp (argv[i], "-iprefix")) {
+ if (i + 1 == argc)
+ fatal ("Filename missing after `-iprefix' option");
+ else
+ include_prefix = argv[++i];
+ }
+ if (!strcmp (argv[i], "-ifoutput")) {
+ output_conditionals = 1;
+ }
+ if (!strcmp (argv[i], "-isystem")) {
+ struct file_name_list *dirtmp;
+
+ if (! (dirtmp = new_include_prefix (NULL_PTR, NULL_PTR,
+ "", argv[++i])))
+ break;
+ dirtmp->c_system_include_path = 1;
+
+ if (before_system == 0)
+ before_system = dirtmp;
+ else
+ last_before_system->next = dirtmp;
+ last_before_system = dirtmp; /* Tail follows the last one */
+ }
+ /* Add directory to end of path for includes,
+ with the default prefix at the front of its name. */
+ if (!strcmp (argv[i], "-iwithprefix")) {
+ struct file_name_list *dirtmp;
+ char *prefix;
+
+ if (include_prefix != 0)
+ prefix = include_prefix;
+ else {
+ prefix = savestring (GCC_INCLUDE_DIR);
+ /* Remove the `include' from /usr/local/lib/gcc.../include. */
+ if (!strcmp (prefix + strlen (prefix) - 8, "/include"))
+ prefix[strlen (prefix) - 7] = 0;
+ }
+
+ if (! (dirtmp = new_include_prefix (NULL_PTR, NULL_PTR,
+ prefix, argv[++i])))
+ break;
+
+ if (after_include == 0)
+ after_include = dirtmp;
+ else
+ last_after_include->next = dirtmp;
+ last_after_include = dirtmp; /* Tail follows the last one */
+ }
+ /* Add directory to main path for includes,
+ with the default prefix at the front of its name. */
+ if (!strcmp (argv[i], "-iwithprefixbefore")) {
+ struct file_name_list *dirtmp;
+ char *prefix;
+
+ if (include_prefix != 0)
+ prefix = include_prefix;
+ else {
+ prefix = savestring (GCC_INCLUDE_DIR);
+ /* Remove the `include' from /usr/local/lib/gcc.../include. */
+ if (!strcmp (prefix + strlen (prefix) - 8, "/include"))
+ prefix[strlen (prefix) - 7] = 0;
+ }
+
+ dirtmp = new_include_prefix (NULL_PTR, NULL_PTR, prefix, argv[++i]);
+ append_include_chain (dirtmp, dirtmp);
+ }
+ /* Add directory to end of path for includes. */
+ if (!strcmp (argv[i], "-idirafter")) {
+ struct file_name_list *dirtmp;
+
+ if (! (dirtmp = new_include_prefix (NULL_PTR, NULL_PTR,
+ "", argv[++i])))
+ break;
+
+ if (after_include == 0)
+ after_include = dirtmp;
+ else
+ last_after_include->next = dirtmp;
+ last_after_include = dirtmp; /* Tail follows the last one */
+ }
+ break;
case 'o':
- if (out_fname != NULL)
- fatal ("Output filename specified twice");
- if (i + 1 == argc)
- fatal ("Filename missing after -o option");
- out_fname = argv[++i];
- if (!strcmp (out_fname, "-"))
- out_fname = "";
- break;
+ if (out_fname != NULL)
+ fatal ("Output filename specified twice");
+ if (i + 1 == argc)
+ fatal ("Filename missing after -o option");
+ out_fname = argv[++i];
+ if (!strcmp (out_fname, "-"))
+ out_fname = "";
+ break;
case 'p':
- if (!strcmp (argv[i], "-pedantic"))
- pedantic = 1;
- else if (!strcmp (argv[i], "-pedantic-errors")) {
- pedantic = 1;
- pedantic_errors = 1;
- } else if (!strcmp (argv[i], "-pcp")) {
- char *pcp_fname;
- if (i + 1 == argc)
- fatal ("Filename missing after -pcp option");
- pcp_fname = argv[++i];
- pcp_outfile
- = ((pcp_fname[0] != '-' || pcp_fname[1] != '\0')
- ? fopen (pcp_fname, "w")
- : stdout);
- if (pcp_outfile == 0)
- pfatal_with_name (pcp_fname);
- no_precomp = 1;
- }
- break;
+ if (!strcmp (argv[i], "-pedantic"))
+ pedantic = 1;
+ else if (!strcmp (argv[i], "-pedantic-errors")) {
+ pedantic = 1;
+ pedantic_errors = 1;
+ } else if (!strcmp (argv[i], "-pcp")) {
+ char *pcp_fname;
+ if (i + 1 == argc)
+ fatal ("Filename missing after -pcp option");
+ pcp_fname = argv[++i];
+ pcp_outfile
+ = ((pcp_fname[0] != '-' || pcp_fname[1] != '\0')
+ ? fopen (pcp_fname, "w")
+ : stdout);
+ if (pcp_outfile == 0)
+ pfatal_with_name (pcp_fname);
+ no_precomp = 1;
+ }
+ break;
case 't':
- if (!strcmp (argv[i], "-traditional")) {
- traditional = 1;
- cplusplus_comments = 0;
- } else if (!strcmp (argv[i], "-trigraphs")) {
- no_trigraphs = 0;
- }
- break;
+ if (!strcmp (argv[i], "-traditional")) {
+ traditional = 1;
+ cplusplus_comments = 0;
+ } else if (!strcmp (argv[i], "-trigraphs")) {
+ no_trigraphs = 0;
+ }
+ break;
case 'l':
- if (! strcmp (argv[i], "-lang-c"))
- cplusplus = 0, cplusplus_comments = 1, c89 = 0, objc = 0;
- if (! strcmp (argv[i], "-lang-c89"))
- cplusplus = 0, cplusplus_comments = 0, c89 = 1, objc = 0;
- if (! strcmp (argv[i], "-lang-c++"))
- cplusplus = 1, cplusplus_comments = 1, c89 = 0, objc = 0;
- if (! strcmp (argv[i], "-lang-objc"))
- cplusplus = 0, cplusplus_comments = 1, c89 = 0, objc = 1;
- if (! strcmp (argv[i], "-lang-objc++"))
- cplusplus = 1, cplusplus_comments = 1, c89 = 0, objc = 1;
- if (! strcmp (argv[i], "-lang-asm"))
- lang_asm = 1;
- if (! strcmp (argv[i], "-lint"))
- for_lint = 1;
- break;
+ if (! strcmp (argv[i], "-lang-c"))
+ cplusplus = 0, cplusplus_comments = 1, c89 = 0, objc = 0;
+ if (! strcmp (argv[i], "-lang-c89"))
+ cplusplus = 0, cplusplus_comments = 0, c89 = 1, objc = 0;
+ if (! strcmp (argv[i], "-lang-c++"))
+ cplusplus = 1, cplusplus_comments = 1, c89 = 0, objc = 0;
+ if (! strcmp (argv[i], "-lang-objc"))
+ cplusplus = 0, cplusplus_comments = 1, c89 = 0, objc = 1;
+ if (! strcmp (argv[i], "-lang-objc++"))
+ cplusplus = 1, cplusplus_comments = 1, c89 = 0, objc = 1;
+ if (! strcmp (argv[i], "-lang-asm"))
+ lang_asm = 1;
+ if (! strcmp (argv[i], "-lint"))
+ for_lint = 1;
+ break;
case '+':
- cplusplus = 1, cplusplus_comments = 1;
- break;
+ cplusplus = 1, cplusplus_comments = 1;
+ break;
case 'w':
- inhibit_warnings = 1;
- break;
+ inhibit_warnings = 1;
+ break;
case 'W':
- if (!strcmp (argv[i], "-Wtrigraphs"))
- warn_trigraphs = 1;
- else if (!strcmp (argv[i], "-Wno-trigraphs"))
- warn_trigraphs = 0;
- else if (!strcmp (argv[i], "-Wcomment"))
- warn_comments = 1;
- else if (!strcmp (argv[i], "-Wno-comment"))
- warn_comments = 0;
- else if (!strcmp (argv[i], "-Wcomments"))
- warn_comments = 1;
- else if (!strcmp (argv[i], "-Wno-comments"))
- warn_comments = 0;
- else if (!strcmp (argv[i], "-Wtraditional"))
- warn_stringify = 1;
- else if (!strcmp (argv[i], "-Wno-traditional"))
- warn_stringify = 0;
- else if (!strcmp (argv[i], "-Wundef"))
- warn_undef = 1;
- else if (!strcmp (argv[i], "-Wno-undef"))
- warn_undef = 0;
- else if (!strcmp (argv[i], "-Wimport"))
- warn_import = 1;
- else if (!strcmp (argv[i], "-Wno-import"))
- warn_import = 0;
- else if (!strcmp (argv[i], "-Werror"))
- warnings_are_errors = 1;
- else if (!strcmp (argv[i], "-Wno-error"))
- warnings_are_errors = 0;
- else if (!strcmp (argv[i], "-Wall"))
- {
- warn_trigraphs = 1;
- warn_comments = 1;
- }
- break;
+ if (!strcmp (argv[i], "-Wtrigraphs"))
+ warn_trigraphs = 1;
+ else if (!strcmp (argv[i], "-Wno-trigraphs"))
+ warn_trigraphs = 0;
+ else if (!strcmp (argv[i], "-Wcomment"))
+ warn_comments = 1;
+ else if (!strcmp (argv[i], "-Wno-comment"))
+ warn_comments = 0;
+ else if (!strcmp (argv[i], "-Wcomments"))
+ warn_comments = 1;
+ else if (!strcmp (argv[i], "-Wno-comments"))
+ warn_comments = 0;
+ else if (!strcmp (argv[i], "-Wtraditional"))
+ warn_stringify = 1;
+ else if (!strcmp (argv[i], "-Wno-traditional"))
+ warn_stringify = 0;
+ else if (!strcmp (argv[i], "-Wundef"))
+ warn_undef = 1;
+ else if (!strcmp (argv[i], "-Wno-undef"))
+ warn_undef = 0;
+ else if (!strcmp (argv[i], "-Wimport"))
+ warn_import = 1;
+ else if (!strcmp (argv[i], "-Wno-import"))
+ warn_import = 0;
+ else if (!strcmp (argv[i], "-Werror"))
+ warnings_are_errors = 1;
+ else if (!strcmp (argv[i], "-Wno-error"))
+ warnings_are_errors = 0;
+ else if (!strcmp (argv[i], "-Wall"))
+ {
+ warn_trigraphs = 1;
+ warn_comments = 1;
+ }
+ break;
case 'M':
- /* The style of the choices here is a bit mixed.
- The chosen scheme is a hybrid of keeping all options in one string
- and specifying each option in a separate argument:
- -M|-MM|-MD file|-MMD file [-MG]. An alternative is:
- -M|-MM|-MD file|-MMD file|-MG|-MMG; or more concisely:
- -M[M][G][D file]. This is awkward to handle in specs, and is not
- as extensible. */
- /* ??? -MG must be specified in addition to one of -M or -MM.
- This can be relaxed in the future without breaking anything.
- The converse isn't true. */
-
- /* -MG isn't valid with -MD or -MMD. This is checked for later. */
- if (!strcmp (argv[i], "-MG"))
- {
- print_deps_missing_files = 1;
- break;
- }
- if (!strcmp (argv[i], "-M"))
- print_deps = 2;
- else if (!strcmp (argv[i], "-MM"))
- print_deps = 1;
- else if (!strcmp (argv[i], "-MD"))
- print_deps = 2;
- else if (!strcmp (argv[i], "-MMD"))
- print_deps = 1;
- /* For -MD and -MMD options, write deps on file named by next arg. */
- if (!strcmp (argv[i], "-MD")
- || !strcmp (argv[i], "-MMD")) {
- if (i + 1 == argc)
- fatal ("Filename missing after %s option", argv[i]);
- i++;
- deps_file = argv[i];
- deps_mode = "w";
- } else {
- /* For -M and -MM, write deps on standard output
- and suppress the usual output. */
- deps_stream = stdout;
- inhibit_output = 1;
- }
- break;
+ /* The style of the choices here is a bit mixed.
+ The chosen scheme is a hybrid of keeping all options in one string
+ and specifying each option in a separate argument:
+ -M|-MM|-MD file|-MMD file [-MG]. An alternative is:
+ -M|-MM|-MD file|-MMD file|-MG|-MMG; or more concisely:
+ -M[M][G][D file]. This is awkward to handle in specs, and is not
+ as extensible. */
+ /* ??? -MG must be specified in addition to one of -M or -MM.
+ This can be relaxed in the future without breaking anything.
+ The converse isn't true. */
+
+ /* -MG isn't valid with -MD or -MMD. This is checked for later. */
+ if (!strcmp (argv[i], "-MG"))
+ {
+ print_deps_missing_files = 1;
+ break;
+ }
+ if (!strcmp (argv[i], "-M"))
+ print_deps = 2;
+ else if (!strcmp (argv[i], "-MM"))
+ print_deps = 1;
+ else if (!strcmp (argv[i], "-MD"))
+ print_deps = 2;
+ else if (!strcmp (argv[i], "-MMD"))
+ print_deps = 1;
+ /* For -MD and -MMD options, write deps on file named by next arg. */
+ if (!strcmp (argv[i], "-MD")
+ || !strcmp (argv[i], "-MMD")) {
+ if (i + 1 == argc)
+ fatal ("Filename missing after %s option", argv[i]);
+ i++;
+ deps_file = argv[i];
+ deps_mode = "w";
+ } else {
+ /* For -M and -MM, write deps on standard output
+ and suppress the usual output. */
+ deps_stream = stdout;
+ inhibit_output = 1;
+ }
+ break;
case 'd':
- {
- char *p = argv[i] + 2;
- char c;
- while ((c = *p++)) {
- /* Arg to -d specifies what parts of macros to dump */
- switch (c) {
- case 'M':
- dump_macros = dump_only;
- no_output = 1;
- break;
- case 'N':
- dump_macros = dump_names;
- break;
- case 'D':
- dump_macros = dump_definitions;
- break;
- case 'I':
- dump_includes = 1;
- break;
- }
- }
- }
- break;
+ {
+ char *p = argv[i] + 2;
+ char c;
+ while ((c = *p++)) {
+ /* Arg to -d specifies what parts of macros to dump */
+ switch (c) {
+ case 'M':
+ dump_macros = dump_only;
+ no_output = 1;
+ break;
+ case 'N':
+ dump_macros = dump_names;
+ break;
+ case 'D':
+ dump_macros = dump_definitions;
+ break;
+ case 'I':
+ dump_includes = 1;
+ break;
+ }
+ }
+ }
+ break;
case 'g':
- if (argv[i][2] == '3')
- debug_output = 1;
- break;
+ if (argv[i][2] == '3')
+ debug_output = 1;
+ break;
case 'v':
- fprintf (stderr, "GNU CPP version %s", version_string);
+ fprintf (stderr, "GNU CPP version %s", version_string);
#ifdef TARGET_VERSION
- TARGET_VERSION;
+ TARGET_VERSION;
#endif
- fprintf (stderr, "\n");
- verbose = 1;
- break;
+ fprintf (stderr, "\n");
+ verbose = 1;
+ break;
case 'H':
- print_include_names = 1;
- break;
+ print_include_names = 1;
+ break;
case 'D':
- if (argv[i][2] != 0)
- pend_defs[i] = argv[i] + 2;
- else if (i + 1 == argc)
- fatal ("Macro name missing after -D option");
- else
- i++, pend_defs[i] = argv[i];
- break;
+ if (argv[i][2] != 0)
+ pend_defs[i] = argv[i] + 2;
+ else if (i + 1 == argc)
+ fatal ("Macro name missing after -D option");
+ else
+ i++, pend_defs[i] = argv[i];
+ break;
case 'A':
- {
- char *p;
-
- if (argv[i][2] != 0)
- p = argv[i] + 2;
- else if (i + 1 == argc)
- fatal ("Assertion missing after -A option");
- else
- p = argv[++i];
-
- if (!strcmp (p, "-")) {
- /* -A- eliminates all predefined macros and assertions.
- Let's include also any that were specified earlier
- on the command line. That way we can get rid of any
- that were passed automatically in from GCC. */
- int j;
- inhibit_predefs = 1;
- for (j = 0; j < i; j++)
- pend_defs[j] = pend_assertions[j] = 0;
- } else {
- pend_assertions[i] = p;
- pend_assertion_options[i] = "-A";
- }
- }
- break;
-
- case 'U': /* JF #undef something */
- if (argv[i][2] != 0)
- pend_undefs[i] = argv[i] + 2;
- else if (i + 1 == argc)
- fatal ("Macro name missing after -U option");
- else
- pend_undefs[i] = argv[i+1], i++;
- break;
+ {
+ char *p;
+
+ if (argv[i][2] != 0)
+ p = argv[i] + 2;
+ else if (i + 1 == argc)
+ fatal ("Assertion missing after -A option");
+ else
+ p = argv[++i];
+
+ if (!strcmp (p, "-")) {
+ /* -A- eliminates all predefined macros and assertions.
+ Let's include also any that were specified earlier
+ on the command line. That way we can get rid of any
+ that were passed automatically in from GCC. */
+ int j;
+ inhibit_predefs = 1;
+ for (j = 0; j < i; j++)
+ pend_defs[j] = pend_assertions[j] = 0;
+ } else {
+ pend_assertions[i] = p;
+ pend_assertion_options[i] = "-A";
+ }
+ }
+ break;
+
+ case 'U': /* JF #undef something */
+ if (argv[i][2] != 0)
+ pend_undefs[i] = argv[i] + 2;
+ else if (i + 1 == argc)
+ fatal ("Macro name missing after -U option");
+ else
+ pend_undefs[i] = argv[i+1], i++;
+ break;
case 'C':
- put_out_comments = 1;
- break;
+ put_out_comments = 1;
+ break;
- case 'E': /* -E comes from cc -E; ignore it. */
- break;
+ case 'E': /* -E comes from cc -E; ignore it. */
+ break;
case 'P':
- no_line_directives = 1;
- break;
-
- case '$': /* Don't include $ in identifiers. */
- is_idchar['$'] = is_idstart['$'] = 0;
- break;
-
- case 'I': /* Add directory to path for includes. */
- {
- struct file_name_list *dirtmp;
-
- if (! ignore_srcdir && !strcmp (argv[i] + 2, "-")) {
- ignore_srcdir = 1;
- /* Don't use any preceding -I directories for #include <...>. */
- first_bracket_include = 0;
- }
- else {
- dirtmp = new_include_prefix (last_include, NULL_PTR, "",
- argv[i][2] ? argv[i] + 2 : argv[++i]);
- append_include_chain (dirtmp, dirtmp);
- }
- }
- break;
+ no_line_directives = 1;
+ break;
+
+ case '$': /* Don't include $ in identifiers. */
+ is_idchar['$'] = is_idstart['$'] = 0;
+ break;
+
+ case 'I': /* Add directory to path for includes. */
+ {
+ struct file_name_list *dirtmp;
+
+ if (! ignore_srcdir && !strcmp (argv[i] + 2, "-")) {
+ ignore_srcdir = 1;
+ /* Don't use any preceding -I directories for #include <...>. */
+ first_bracket_include = 0;
+ }
+ else {
+ dirtmp = new_include_prefix (last_include, NULL_PTR, "",
+ argv[i][2] ? argv[i] + 2 : argv[++i]);
+ append_include_chain (dirtmp, dirtmp);
+ }
+ }
+ break;
case 'n':
- if (!strcmp (argv[i], "-nostdinc"))
- /* -nostdinc causes no default include directories.
- You must specify all include-file directories with -I. */
- no_standard_includes = 1;
- else if (!strcmp (argv[i], "-nostdinc++"))
- /* -nostdinc++ causes no default C++-specific include directories. */
- no_standard_cplusplus_includes = 1;
- else if (!strcmp (argv[i], "-noprecomp"))
- no_precomp = 1;
- break;
+ if (!strcmp (argv[i], "-nostdinc"))
+ /* -nostdinc causes no default include directories.
+ You must specify all include-file directories with -I. */
+ no_standard_includes = 1;
+ else if (!strcmp (argv[i], "-nostdinc++"))
+ /* -nostdinc++ causes no default C++-specific include directories. */
+ no_standard_cplusplus_includes = 1;
+ else if (!strcmp (argv[i], "-noprecomp"))
+ no_precomp = 1;
+ break;
case 'r':
- if (!strcmp (argv[i], "-remap"))
- remap = 1;
- break;
+ if (!strcmp (argv[i], "-remap"))
+ remap = 1;
+ break;
case 'u':
- /* Sun compiler passes undocumented switch "-undef".
- Let's assume it means to inhibit the predefined symbols. */
- inhibit_predefs = 1;
- break;
+ /* Sun compiler passes undocumented switch "-undef".
+ Let's assume it means to inhibit the predefined symbols. */
+ inhibit_predefs = 1;
+ break;
case '\0': /* JF handle '-' as file name meaning stdin or stdout */
- if (in_fname == NULL) {
- in_fname = "";
- break;
- } else if (out_fname == NULL) {
- out_fname = "";
- break;
- } /* else fall through into error */
+ if (in_fname == NULL) {
+ in_fname = "";
+ break;
+ } else if (out_fname == NULL) {
+ out_fname = "";
+ break;
+ } /* else fall through into error */
default:
- fatal ("Invalid option `%s'", argv[i]);
+ fatal ("Invalid option `%s'", argv[i]);
}
}
}
@@ -1738,65 +1738,65 @@ main (argc, argv)
while (*p) {
char *q;
while (*p == ' ' || *p == '\t')
- p++;
+ p++;
/* Handle -D options. */
if (p[0] == '-' && p[1] == 'D') {
- q = &p[2];
- while (*p && *p != ' ' && *p != '\t')
- p++;
- if (*p != 0)
- *p++= 0;
- if (debug_output)
- output_line_directive (fp, &outbuf, 0, same_file);
- make_definition (q, &outbuf);
- while (*p == ' ' || *p == '\t')
- p++;
+ q = &p[2];
+ while (*p && *p != ' ' && *p != '\t')
+ p++;
+ if (*p != 0)
+ *p++= 0;
+ if (debug_output)
+ output_line_directive (fp, &outbuf, 0, same_file);
+ make_definition (q, &outbuf);
+ while (*p == ' ' || *p == '\t')
+ p++;
} else if (p[0] == '-' && p[1] == 'A') {
- /* Handle -A options (assertions). */
- char *assertion;
- char *past_name;
- char *value;
- char *past_value;
- char *termination;
- int save_char;
-
- assertion = &p[2];
- past_name = assertion;
- /* Locate end of name. */
- while (*past_name && *past_name != ' '
- && *past_name != '\t' && *past_name != '(')
- past_name++;
- /* Locate `(' at start of value. */
- value = past_name;
- while (*value && (*value == ' ' || *value == '\t'))
- value++;
- if (*value++ != '(')
- abort ();
- while (*value && (*value == ' ' || *value == '\t'))
- value++;
- past_value = value;
- /* Locate end of value. */
- while (*past_value && *past_value != ' '
- && *past_value != '\t' && *past_value != ')')
- past_value++;
- termination = past_value;
- while (*termination && (*termination == ' ' || *termination == '\t'))
- termination++;
- if (*termination++ != ')')
- abort ();
- if (*termination && *termination != ' ' && *termination != '\t')
- abort ();
- /* Temporarily null-terminate the value. */
- save_char = *termination;
- *termination = '\0';
- /* Install the assertion. */
- make_assertion ("-A", assertion);
- *termination = (char) save_char;
- p = termination;
- while (*p == ' ' || *p == '\t')
- p++;
+ /* Handle -A options (assertions). */
+ char *assertion;
+ char *past_name;
+ char *value;
+ char *past_value;
+ char *termination;
+ int save_char;
+
+ assertion = &p[2];
+ past_name = assertion;
+ /* Locate end of name. */
+ while (*past_name && *past_name != ' '
+ && *past_name != '\t' && *past_name != '(')
+ past_name++;
+ /* Locate `(' at start of value. */
+ value = past_name;
+ while (*value && (*value == ' ' || *value == '\t'))
+ value++;
+ if (*value++ != '(')
+ abort ();
+ while (*value && (*value == ' ' || *value == '\t'))
+ value++;
+ past_value = value;
+ /* Locate end of value. */
+ while (*past_value && *past_value != ' '
+ && *past_value != '\t' && *past_value != ')')
+ past_value++;
+ termination = past_value;
+ while (*termination && (*termination == ' ' || *termination == '\t'))
+ termination++;
+ if (*termination++ != ')')
+ abort ();
+ if (*termination && *termination != ' ' && *termination != '\t')
+ abort ();
+ /* Temporarily null-terminate the value. */
+ save_char = *termination;
+ *termination = '\0';
+ /* Install the assertion. */
+ make_assertion ("-A", assertion);
+ *termination = (char) save_char;
+ p = termination;
+ while (*p == ' ' || *p == '\t')
+ p++;
} else {
- abort ();
+ abort ();
}
}
}
@@ -1827,17 +1827,17 @@ main (argc, argv)
switch ((objc << 1) + cplusplus)
{
case 0:
- epath = getenv ("C_INCLUDE_PATH");
- break;
+ epath = getenv ("C_INCLUDE_PATH");
+ break;
case 1:
- epath = getenv ("CPLUS_INCLUDE_PATH");
- break;
+ epath = getenv ("CPLUS_INCLUDE_PATH");
+ break;
case 2:
- epath = getenv ("OBJC_INCLUDE_PATH");
- break;
+ epath = getenv ("OBJC_INCLUDE_PATH");
+ break;
case 3:
- epath = getenv ("OBJCPLUS_INCLUDE_PATH");
- break;
+ epath = getenv ("OBJCPLUS_INCLUDE_PATH");
+ break;
}
/* If the environment var for this language is set,
add to the default list of include directories. */
@@ -1846,34 +1846,34 @@ main (argc, argv)
char *startp, *endp;
for (num_dirs = 1, startp = epath; *startp; startp++)
- if (*startp == PATH_SEPARATOR)
- num_dirs++;
+ if (*startp == PATH_SEPARATOR)
+ num_dirs++;
include_defaults
- = (struct default_include *) xmalloc ((num_dirs
- * sizeof (struct default_include))
- + sizeof (include_defaults_array));
+ = (struct default_include *) xmalloc ((num_dirs
+ * sizeof (struct default_include))
+ + sizeof (include_defaults_array));
startp = endp = epath;
num_dirs = 0;
while (1) {
- char c = *endp++;
- if (c == PATH_SEPARATOR || !c) {
- endp[-1] = 0;
- include_defaults[num_dirs].fname
- = startp == endp ? "." : savestring (startp);
- endp[-1] = c;
- include_defaults[num_dirs].component = 0;
- include_defaults[num_dirs].cplusplus = cplusplus;
- include_defaults[num_dirs].cxx_aware = 1;
- num_dirs++;
- if (!c)
- break;
- startp = endp;
- }
+ char c = *endp++;
+ if (c == PATH_SEPARATOR || !c) {
+ endp[-1] = 0;
+ include_defaults[num_dirs].fname
+ = startp == endp ? "." : savestring (startp);
+ endp[-1] = c;
+ include_defaults[num_dirs].component = 0;
+ include_defaults[num_dirs].cplusplus = cplusplus;
+ include_defaults[num_dirs].cxx_aware = 1;
+ num_dirs++;
+ if (!c)
+ break;
+ startp = endp;
+ }
}
/* Put the usual defaults back in at the end. */
bcopy ((char *) include_defaults_array,
- (char *) &include_defaults[num_dirs],
- sizeof (include_defaults_array));
+ (char *) &include_defaults[num_dirs],
+ sizeof (include_defaults_array));
}
}
@@ -1896,35 +1896,35 @@ main (argc, argv)
These have /usr/local/lib/gcc... replaced by specd_prefix. */
if (specd_prefix != 0 && default_len != 0)
for (p = include_defaults; p->fname; p++) {
- /* Some standard dirs are only for C++. */
- if (!p->cplusplus || (cplusplus && !no_standard_cplusplus_includes)) {
- /* Does this dir start with the prefix? */
- if (!strncmp (p->fname, default_prefix, default_len)) {
- /* Yes; change prefix and add to search list. */
- struct file_name_list *new
- = new_include_prefix (NULL_PTR, NULL_PTR, specd_prefix,
- p->fname + default_len);
- if (new) {
- new->c_system_include_path = !p->cxx_aware;
- append_include_chain (new, new);
- if (first_system_include == 0)
- first_system_include = new;
- }
- }
- }
+ /* Some standard dirs are only for C++. */
+ if (!p->cplusplus || (cplusplus && !no_standard_cplusplus_includes)) {
+ /* Does this dir start with the prefix? */
+ if (!strncmp (p->fname, default_prefix, default_len)) {
+ /* Yes; change prefix and add to search list. */
+ struct file_name_list *new
+ = new_include_prefix (NULL_PTR, NULL_PTR, specd_prefix,
+ p->fname + default_len);
+ if (new) {
+ new->c_system_include_path = !p->cxx_aware;
+ append_include_chain (new, new);
+ if (first_system_include == 0)
+ first_system_include = new;
+ }
+ }
+ }
}
/* Search ordinary names for GNU include directories. */
for (p = include_defaults; p->fname; p++) {
/* Some standard dirs are only for C++. */
if (!p->cplusplus || (cplusplus && !no_standard_cplusplus_includes)) {
- struct file_name_list *new
- = new_include_prefix (NULL_PTR, p->component, "", p->fname);
- if (new) {
- new->c_system_include_path = !p->cxx_aware;
- append_include_chain (new, new);
- if (first_system_include == 0)
- first_system_include = new;
- }
+ struct file_name_list *new
+ = new_include_prefix (NULL_PTR, p->component, "", p->fname);
+ if (new) {
+ new->c_system_include_path = !p->cxx_aware;
+ append_include_chain (new, new);
+ if (first_system_include == 0)
+ first_system_include = new;
+ }
}
}
}
@@ -1940,14 +1940,14 @@ main (argc, argv)
fprintf (stderr, "#include \"...\" search starts here:\n");
for (p = include; p; p = p->next) {
if (p == first_bracket_include)
- fprintf (stderr, "#include <...> search starts here:\n");
+ fprintf (stderr, "#include <...> search starts here:\n");
if (!p->fname[0])
- fprintf (stderr, " .\n");
+ fprintf (stderr, " .\n");
else if (!strcmp (p->fname, "/") || !strcmp (p->fname, "//"))
- fprintf (stderr, " %s\n", p->fname);
+ fprintf (stderr, " %s\n", p->fname);
else
- /* Omit trailing '/'. */
- fprintf (stderr, " %.*s\n", (int) strlen (p->fname) - 1, p->fname);
+ /* Omit trailing '/'. */
+ fprintf (stderr, " %.*s\n", (int) strlen (p->fname) - 1, p->fname);
}
fprintf (stderr, "End of search list.\n");
}
@@ -1965,7 +1965,7 @@ main (argc, argv)
if (print_deps == 0
&& (getenv ("SUNPRO_DEPENDENCIES") != 0
- || getenv ("DEPENDENCIES_OUTPUT") != 0)) {
+ || getenv ("DEPENDENCIES_OUTPUT") != 0)) {
char *spec = getenv ("DEPENDENCIES_OUTPUT");
char *s;
char *output_file;
@@ -2023,35 +2023,35 @@ main (argc, argv)
len = strlen (p);
q = p + len;
if (len >= 2
- && p[len - 2] == '.'
- && index("cCsSm", p[len - 1]))
- q = p + (len - 2);
+ && p[len - 2] == '.'
+ && index("cCsSm", p[len - 1]))
+ q = p + (len - 2);
else if (len >= 3
- && p[len - 3] == '.'
- && p[len - 2] == 'c'
- && p[len - 1] == 'c')
- q = p + (len - 3);
+ && p[len - 3] == '.'
+ && p[len - 2] == 'c'
+ && p[len - 1] == 'c')
+ q = p + (len - 3);
else if (len >= 4
- && p[len - 4] == '.'
- && p[len - 3] == 'c'
- && p[len - 2] == 'x'
- && p[len - 1] == 'x')
- q = p + (len - 4);
+ && p[len - 4] == '.'
+ && p[len - 3] == 'c'
+ && p[len - 2] == 'x'
+ && p[len - 1] == 'x')
+ q = p + (len - 4);
else if (len >= 4
- && p[len - 4] == '.'
- && p[len - 3] == 'c'
- && p[len - 2] == 'p'
- && p[len - 1] == 'p')
- q = p + (len - 4);
+ && p[len - 4] == '.'
+ && p[len - 3] == 'c'
+ && p[len - 2] == 'p'
+ && p[len - 1] == 'p')
+ q = p + (len - 4);
/*
* The slice suffix.
*/
else if (len >= 4
- && p[len - 4] == '.'
- && p[len - 3] == 'i'
- && p[len - 2] == 'c'
- && p[len - 1] == 'e')
- q = p + (len - 4);
+ && p[len - 4] == '.'
+ && p[len - 3] == 'i'
+ && p[len - 2] == 'c'
+ && p[len - 1] == 'e')
+ q = p + (len - 4);
/* Supply our own suffix. */
strcpy (q, OBJECT_SUFFIX);
@@ -2071,8 +2071,8 @@ main (argc, argv)
struct include_file *inc;
int fd = open_include_file (pend_files[i], NULL_PTR, NULL_PTR, &inc);
if (fd < 0) {
- perror_with_name (pend_files[i]);
- return FATAL_EXIT_CODE;
+ perror_with_name (pend_files[i]);
+ return FATAL_EXIT_CODE;
}
finclude (fd, inc, &outbuf, 0, NULL_PTR);
}
@@ -2110,9 +2110,9 @@ main (argc, argv)
fp->buf = (U_CHAR *) xmalloc (bsize + 2);
for (;;) {
cnt = safe_read (f, (char *) fp->buf + size, bsize - size);
- if (cnt < 0) goto perror; /* error! */
+ if (cnt < 0) goto perror; /* error! */
size += cnt;
- if (size != bsize) break; /* End of file */
+ if (size != bsize) break; /* End of file */
bsize *= 2;
fp->buf = (U_CHAR *) xrealloc (fp->buf, bsize + 2);
}
@@ -2162,8 +2162,8 @@ main (argc, argv)
struct include_file *inc;
int fd = open_include_file (pend_includes[i], NULL_PTR, NULL_PTR, &inc);
if (fd < 0) {
- perror_with_name (pend_includes[i]);
- return FATAL_EXIT_CODE;
+ perror_with_name (pend_includes[i]);
+ return FATAL_EXIT_CODE;
}
finclude (fd, inc, &outbuf, 0, NULL_PTR);
}
@@ -2192,12 +2192,12 @@ main (argc, argv)
/* Don't actually write the deps file if compilation has failed. */
if (errors == 0) {
if (deps_file && ! (deps_stream = fopen (deps_file, deps_mode)))
- pfatal_with_name (deps_file);
+ pfatal_with_name (deps_file);
fputs (deps_buffer, deps_stream);
putc ('\n', deps_stream);
if (deps_file) {
- if (ferror (deps_stream) || fclose (deps_stream) != 0)
- fatal ("I/O error on output");
+ if (ferror (deps_stream) || fclose (deps_stream) != 0)
+ fatal ("I/O error on output");
}
}
}
@@ -2237,18 +2237,18 @@ path_include (path)
/* Find the end of this name. */
while ((c = *q++) != PATH_SEPARATOR && c)
- continue;
+ continue;
q[-1] = 0;
dirtmp = new_include_prefix (last_include, NULL_PTR,
- "", p == q ? "." : p);
+ "", p == q ? "." : p);
q[-1] = c;
append_include_chain (dirtmp, dirtmp);
/* Advance past this name. */
p = q;
if (! c)
- break;
+ break;
}
}
@@ -2272,7 +2272,7 @@ index0 (s, c, n)
else {
size_t l = strlen (p);
if (l == n)
- return 0;
+ return 0;
l++;
p += l;
n -= l;
@@ -2353,7 +2353,7 @@ trigraph_pcp (buf)
buf->buf[buf->length] = '\0';
if (warn_trigraphs && fptr != bptr)
warning_with_line (0, "%lu trigraph(s) encountered",
- (unsigned long) (fptr - bptr) / 2);
+ (unsigned long) (fptr - bptr) / 2);
}
/* Move all backslash-newline pairs out of embarrassing places.
@@ -2439,11 +2439,11 @@ static char *
get_lintcmd (ibp, limit, argstart, arglen, cmdlen)
register U_CHAR *ibp;
register U_CHAR *limit;
- U_CHAR **argstart; /* point to command arg */
- int *arglen, *cmdlen; /* how long they are */
+ U_CHAR **argstart; /* point to command arg */
+ int *arglen, *cmdlen; /* how long they are */
{
HOST_WIDE_INT linsize;
- register U_CHAR *numptr; /* temp for arg parsing */
+ register U_CHAR *numptr; /* temp for arg parsing */
*arglen = 0;
@@ -2473,7 +2473,7 @@ get_lintcmd (ibp, limit, argstart, arglen, cmdlen)
/* OK, read a number */
for (numptr = *argstart = ibp; (numptr < limit) && isdigit (*numptr);
- numptr++);
+ numptr++);
*arglen = numptr - *argstart;
return "VARARGS";
}
@@ -2564,20 +2564,20 @@ rescan (op, output_marks)
/* Pop the innermost input stack level, assuming it is a macro expansion. */
#define POPMACRO \
-do { ip->macro->type = T_MACRO; \
- if (ip->free_ptr) free (ip->free_ptr); \
+do { ip->macro->type = T_MACRO; \
+ if (ip->free_ptr) free (ip->free_ptr); \
--indepth; } while (0)
/* Reload `rescan's local variables that describe the current
level of the input stack. */
#define RECACHE \
-do { ip = &instack[indepth]; \
- ibp = ip->bufp; \
- limit = ip->buf + ip->length; \
- op->bufp = obp; \
- check_expand (op, limit - ibp); \
- beg_of_line = 0; \
+do { ip = &instack[indepth]; \
+ ibp = ip->bufp; \
+ limit = ip->buf + ip->length; \
+ op->bufp = obp; \
+ check_expand (op, limit - ibp); \
+ beg_of_line = 0; \
obp = op->bufp; } while (0)
if (no_output && instack[indepth].fname != 0)
@@ -2600,176 +2600,176 @@ do { ip = &instack[indepth]; \
switch (c) {
case '\\':
if (*ibp == '\n' && !ip->macro) {
- /* At the top level, always merge lines ending with backslash-newline,
- even in middle of identifier. But do not merge lines in a macro,
- since backslash might be followed by a newline-space marker. */
- ++ibp;
- ++ip->lineno;
- --obp; /* remove backslash from obuf */
- break;
+ /* At the top level, always merge lines ending with backslash-newline,
+ even in middle of identifier. But do not merge lines in a macro,
+ since backslash might be followed by a newline-space marker. */
+ ++ibp;
+ ++ip->lineno;
+ --obp; /* remove backslash from obuf */
+ break;
}
/* If ANSI, backslash is just another character outside a string. */
if (!traditional)
- goto randomchar;
+ goto randomchar;
/* Otherwise, backslash suppresses specialness of following char,
- so copy it here to prevent the switch from seeing it.
- But first get any pending identifier processed. */
+ so copy it here to prevent the switch from seeing it.
+ But first get any pending identifier processed. */
if (ident_length > 0)
- goto specialchar;
+ goto specialchar;
if (ibp < limit)
- *obp++ = *ibp++;
+ *obp++ = *ibp++;
break;
case '%':
if (ident_length || ip->macro || traditional)
- goto randomchar;
+ goto randomchar;
while (*ibp == '\\' && ibp[1] == '\n') {
- ibp += 2;
- ++ip->lineno;
+ ibp += 2;
+ ++ip->lineno;
}
if (*ibp != ':')
- break;
+ break;
/* Treat this %: digraph as if it were #. */
/* Fall through. */
case '#':
if (assertions_flag) {
- if (ident_length)
- goto specialchar;
- /* Copy #foo (bar lose) without macro expansion. */
- obp[-1] = '#'; /* In case it was '%'. */
- SKIP_WHITE_SPACE (ibp);
- while (is_idchar[*ibp])
- *obp++ = *ibp++;
- SKIP_WHITE_SPACE (ibp);
- if (*ibp == '(') {
- ip->bufp = ibp;
- skip_paren_group (ip);
- bcopy ((char *) ibp, (char *) obp, ip->bufp - ibp);
- obp += ip->bufp - ibp;
- ibp = ip->bufp;
- }
- break;
+ if (ident_length)
+ goto specialchar;
+ /* Copy #foo (bar lose) without macro expansion. */
+ obp[-1] = '#'; /* In case it was '%'. */
+ SKIP_WHITE_SPACE (ibp);
+ while (is_idchar[*ibp])
+ *obp++ = *ibp++;
+ SKIP_WHITE_SPACE (ibp);
+ if (*ibp == '(') {
+ ip->bufp = ibp;
+ skip_paren_group (ip);
+ bcopy ((char *) ibp, (char *) obp, ip->bufp - ibp);
+ obp += ip->bufp - ibp;
+ ibp = ip->bufp;
+ }
+ break;
}
/* If this is expanding a macro definition, don't recognize
- preprocessing directives. */
+ preprocessing directives. */
if (ip->macro != 0)
- goto randomchar;
+ goto randomchar;
/* If this is expand_into_temp_buffer,
- don't recognize them either. Warn about them
- only after an actual newline at this level,
- not at the beginning of the input level. */
+ don't recognize them either. Warn about them
+ only after an actual newline at this level,
+ not at the beginning of the input level. */
if (! ip->fname) {
- if (ip->buf != beg_of_line)
- warning ("preprocessing directive not recognized within macro arg");
- goto randomchar;
+ if (ip->buf != beg_of_line)
+ warning ("preprocessing directive not recognized within macro arg");
+ goto randomchar;
}
if (ident_length)
- goto specialchar;
+ goto specialchar;
/* # keyword: a # must be first nonblank char on the line */
if (beg_of_line == 0)
- goto randomchar;
+ goto randomchar;
{
- U_CHAR *bp;
-
- /* Scan from start of line, skipping whitespace, comments
- and backslash-newlines, and see if we reach this #.
- If not, this # is not special. */
- bp = beg_of_line;
- /* If -traditional, require # to be at beginning of line. */
- if (!traditional) {
- while (1) {
- if (is_hor_space[*bp])
- bp++;
- else if (*bp == '\\' && bp[1] == '\n')
- bp += 2;
- else if (*bp == '/' && bp[1] == '*') {
- bp += 2;
- while (!(*bp == '*' && bp[1] == '/'))
- bp++;
- bp += 2;
- }
- /* There is no point in trying to deal with C++ // comments here,
- because if there is one, then this # must be part of the
- comment and we would never reach here. */
- else break;
- }
- if (c == '%') {
- if (bp[0] != '%')
- break;
- while (bp[1] == '\\' && bp[2] == '\n')
- bp += 2;
- if (bp + 1 != ibp)
- break;
- /* %: appears at start of line; skip past the ':' too. */
- bp++;
- ibp++;
- }
- }
- if (bp + 1 != ibp)
- goto randomchar;
+ U_CHAR *bp;
+
+ /* Scan from start of line, skipping whitespace, comments
+ and backslash-newlines, and see if we reach this #.
+ If not, this # is not special. */
+ bp = beg_of_line;
+ /* If -traditional, require # to be at beginning of line. */
+ if (!traditional) {
+ while (1) {
+ if (is_hor_space[*bp])
+ bp++;
+ else if (*bp == '\\' && bp[1] == '\n')
+ bp += 2;
+ else if (*bp == '/' && bp[1] == '*') {
+ bp += 2;
+ while (!(*bp == '*' && bp[1] == '/'))
+ bp++;
+ bp += 2;
+ }
+ /* There is no point in trying to deal with C++ // comments here,
+ because if there is one, then this # must be part of the
+ comment and we would never reach here. */
+ else break;
+ }
+ if (c == '%') {
+ if (bp[0] != '%')
+ break;
+ while (bp[1] == '\\' && bp[2] == '\n')
+ bp += 2;
+ if (bp + 1 != ibp)
+ break;
+ /* %: appears at start of line; skip past the ':' too. */
+ bp++;
+ ibp++;
+ }
+ }
+ if (bp + 1 != ibp)
+ goto randomchar;
}
/* This # can start a directive. */
- --obp; /* Don't copy the '#' */
+ --obp; /* Don't copy the '#' */
ip->bufp = ibp;
op->bufp = obp;
if (! handle_directive (ip, op)) {
#ifdef USE_C_ALLOCA
- alloca (0);
+ alloca (0);
#endif
- /* Not a known directive: treat it as ordinary text.
- IP, OP, IBP, etc. have not been changed. */
- if (no_output && instack[indepth].fname) {
- /* If not generating expanded output,
- what we do with ordinary text is skip it.
- Discard everything until next # directive. */
- skip_if_group (&instack[indepth], 1, 0);
- RECACHE;
- beg_of_line = ibp;
- break;
- }
- *obp++ = '#'; /* Copy # (even if it was originally %:). */
- /* Don't expand an identifier that could be a macro directive.
- (Section 3.8.3 of the ANSI C standard) */
- SKIP_WHITE_SPACE (ibp);
- if (is_idstart[*ibp])
- {
- *obp++ = *ibp++;
- while (is_idchar[*ibp])
- *obp++ = *ibp++;
- }
- goto randomchar;
+ /* Not a known directive: treat it as ordinary text.
+ IP, OP, IBP, etc. have not been changed. */
+ if (no_output && instack[indepth].fname) {
+ /* If not generating expanded output,
+ what we do with ordinary text is skip it.
+ Discard everything until next # directive. */
+ skip_if_group (&instack[indepth], 1, 0);
+ RECACHE;
+ beg_of_line = ibp;
+ break;
+ }
+ *obp++ = '#'; /* Copy # (even if it was originally %:). */
+ /* Don't expand an identifier that could be a macro directive.
+ (Section 3.8.3 of the ANSI C standard) */
+ SKIP_WHITE_SPACE (ibp);
+ if (is_idstart[*ibp])
+ {
+ *obp++ = *ibp++;
+ while (is_idchar[*ibp])
+ *obp++ = *ibp++;
+ }
+ goto randomchar;
}
#ifdef USE_C_ALLOCA
alloca (0);
#endif
/* A # directive has been successfully processed. */
/* If not generating expanded output, ignore everything until
- next # directive. */
+ next # directive. */
if (no_output && instack[indepth].fname)
- skip_if_group (&instack[indepth], 1, 0);
+ skip_if_group (&instack[indepth], 1, 0);
obp = op->bufp;
RECACHE;
beg_of_line = ibp;
break;
- case '\"': /* skip quoted string */
+ case '\"': /* skip quoted string */
case '\'':
/* A single quoted string is treated like a double -- some
- programs (e.g., troff) are perverse this way */
+ programs (e.g., troff) are perverse this way */
/* Handle any pending identifier;
- but the L in L'...' or L"..." is not an identifier. */
+ but the L in L'...' or L"..." is not an identifier. */
if (ident_length) {
- if (! (ident_length == 1 && hash == HASHSTEP (0, 'L')))
- goto specialchar;
- ident_length = hash = 0;
+ if (! (ident_length == 1 && hash == HASHSTEP (0, 'L')))
+ goto specialchar;
+ ident_length = hash = 0;
}
start_line = ip->lineno;
@@ -2777,274 +2777,274 @@ do { ip = &instack[indepth]; \
/* Skip ahead to a matching quote. */
while (1) {
- if (ibp >= limit) {
- if (ip->macro != 0) {
- /* try harder: this string crosses a macro expansion boundary.
- This can happen naturally if -traditional.
- Otherwise, only -D can make a macro with an unmatched quote. */
- POPMACRO;
- RECACHE;
- continue;
- }
- if (!traditional) {
- error_with_line (line_for_error (start_line),
- "unterminated string or character constant");
- if (multiline_string_line) {
- error_with_line (multiline_string_line,
- "possible real start of unterminated constant");
- multiline_string_line = 0;
- }
- }
- break;
- }
- *obp++ = *ibp;
- switch (*ibp++) {
- case '\n':
- ++ip->lineno;
- ++op->lineno;
- /* Traditionally, end of line ends a string constant with no error.
- So exit the loop and record the new line. */
- if (traditional) {
- beg_of_line = ibp;
- goto while2end;
- }
- if (c == '\'') {
- error_with_line (line_for_error (start_line),
- "unterminated character constant");
- goto while2end;
- }
- if (multiline_string_line == 0) {
- if (pedantic)
- pedwarn_with_line (line_for_error (start_line),
- "string constant runs past end of line");
- multiline_string_line = ip->lineno - 1;
- }
- break;
-
- case '\\':
- if (*ibp == '\n') {
- /* Backslash newline is replaced by nothing at all, but
- keep the line counts correct. But if we are reading
- from a macro, keep the backslash newline, since backslash
- newlines have already been processed. */
- if (ip->macro)
- *obp++ = '\n';
- else
- --obp;
- ++ibp;
- ++ip->lineno;
- } else {
- /* ANSI stupidly requires that in \\ the second \
- is *not* prevented from combining with a newline. */
- if (!ip->macro) {
- while (*ibp == '\\' && ibp[1] == '\n') {
- ibp += 2;
- ++ip->lineno;
- }
- }
- *obp++ = *ibp++;
- }
- break;
-
- case '\"':
- case '\'':
- if (ibp[-1] == c)
- goto while2end;
- break;
- }
+ if (ibp >= limit) {
+ if (ip->macro != 0) {
+ /* try harder: this string crosses a macro expansion boundary.
+ This can happen naturally if -traditional.
+ Otherwise, only -D can make a macro with an unmatched quote. */
+ POPMACRO;
+ RECACHE;
+ continue;
+ }
+ if (!traditional) {
+ error_with_line (line_for_error (start_line),
+ "unterminated string or character constant");
+ if (multiline_string_line) {
+ error_with_line (multiline_string_line,
+ "possible real start of unterminated constant");
+ multiline_string_line = 0;
+ }
+ }
+ break;
+ }
+ *obp++ = *ibp;
+ switch (*ibp++) {
+ case '\n':
+ ++ip->lineno;
+ ++op->lineno;
+ /* Traditionally, end of line ends a string constant with no error.
+ So exit the loop and record the new line. */
+ if (traditional) {
+ beg_of_line = ibp;
+ goto while2end;
+ }
+ if (c == '\'') {
+ error_with_line (line_for_error (start_line),
+ "unterminated character constant");
+ goto while2end;
+ }
+ if (multiline_string_line == 0) {
+ if (pedantic)
+ pedwarn_with_line (line_for_error (start_line),
+ "string constant runs past end of line");
+ multiline_string_line = ip->lineno - 1;
+ }
+ break;
+
+ case '\\':
+ if (*ibp == '\n') {
+ /* Backslash newline is replaced by nothing at all, but
+ keep the line counts correct. But if we are reading
+ from a macro, keep the backslash newline, since backslash
+ newlines have already been processed. */
+ if (ip->macro)
+ *obp++ = '\n';
+ else
+ --obp;
+ ++ibp;
+ ++ip->lineno;
+ } else {
+ /* ANSI stupidly requires that in \\ the second \
+ is *not* prevented from combining with a newline. */
+ if (!ip->macro) {
+ while (*ibp == '\\' && ibp[1] == '\n') {
+ ibp += 2;
+ ++ip->lineno;
+ }
+ }
+ *obp++ = *ibp++;
+ }
+ break;
+
+ case '\"':
+ case '\'':
+ if (ibp[-1] == c)
+ goto while2end;
+ break;
+ }
}
while2end:
break;
case '/':
if (ip->macro != 0)
- goto randomchar;
+ goto randomchar;
if (*ibp == '\\' && ibp[1] == '\n')
- newline_fix (ibp);
+ newline_fix (ibp);
if (*ibp != '*'
- && !(cplusplus_comments && *ibp == '/'))
- goto randomchar;
+ && !(cplusplus_comments && *ibp == '/'))
+ goto randomchar;
if (ident_length)
- goto specialchar;
+ goto specialchar;
if (*ibp == '/') {
- /* C++ style comment... */
- start_line = ip->lineno;
-
- /* Comments are equivalent to spaces. */
- if (! put_out_comments)
- obp[-1] = ' ';
-
- {
- U_CHAR *before_bp = ibp;
-
- while (++ibp < limit) {
- if (*ibp == '\n') {
- if (ibp[-1] != '\\') {
- if (put_out_comments) {
- bcopy ((char *) before_bp, (char *) obp, ibp - before_bp);
- obp += ibp - before_bp;
- }
- break;
- }
- if (warn_comments)
- warning ("multiline `//' comment");
- ++ip->lineno;
- /* Copy the newline into the output buffer, in order to
- avoid the pain of a #line every time a multiline comment
- is seen. */
- if (!put_out_comments)
- *obp++ = '\n';
- ++op->lineno;
- }
- }
- break;
- }
+ /* C++ style comment... */
+ start_line = ip->lineno;
+
+ /* Comments are equivalent to spaces. */
+ if (! put_out_comments)
+ obp[-1] = ' ';
+
+ {
+ U_CHAR *before_bp = ibp;
+
+ while (++ibp < limit) {
+ if (*ibp == '\n') {
+ if (ibp[-1] != '\\') {
+ if (put_out_comments) {
+ bcopy ((char *) before_bp, (char *) obp, ibp - before_bp);
+ obp += ibp - before_bp;
+ }
+ break;
+ }
+ if (warn_comments)
+ warning ("multiline `//' comment");
+ ++ip->lineno;
+ /* Copy the newline into the output buffer, in order to
+ avoid the pain of a #line every time a multiline comment
+ is seen. */
+ if (!put_out_comments)
+ *obp++ = '\n';
+ ++op->lineno;
+ }
+ }
+ break;
+ }
}
/* Ordinary C comment. Skip it, optionally copying it to output. */
start_line = ip->lineno;
- ++ibp; /* Skip the star. */
+ ++ibp; /* Skip the star. */
/* If this cpp is for lint, we peek inside the comments: */
if (for_lint) {
- U_CHAR *argbp;
- int cmdlen, arglen;
- char *lintcmd = get_lintcmd (ibp, limit, &argbp, &arglen, &cmdlen);
-
- if (lintcmd != NULL) {
- op->bufp = obp;
- check_expand (op, cmdlen + arglen + 14);
- obp = op->bufp;
- /* I believe it is always safe to emit this newline: */
- obp[-1] = '\n';
- bcopy ("#pragma lint ", (char *) obp, 13);
- obp += 13;
- bcopy (lintcmd, (char *) obp, cmdlen);
- obp += cmdlen;
-
- if (arglen != 0) {
- *(obp++) = ' ';
- bcopy (argbp, (char *) obp, arglen);
- obp += arglen;
- }
-
- /* OK, now bring us back to the state we were in before we entered
- this branch. We need #line because the #pragma's newline always
- messes up the line count. */
- op->bufp = obp;
- output_line_directive (ip, op, 0, same_file);
- check_expand (op, limit - ibp + 2);
- obp = op->bufp;
- *(obp++) = '/';
- }
+ U_CHAR *argbp;
+ int cmdlen, arglen;
+ char *lintcmd = get_lintcmd (ibp, limit, &argbp, &arglen, &cmdlen);
+
+ if (lintcmd != NULL) {
+ op->bufp = obp;
+ check_expand (op, cmdlen + arglen + 14);
+ obp = op->bufp;
+ /* I believe it is always safe to emit this newline: */
+ obp[-1] = '\n';
+ bcopy ("#pragma lint ", (char *) obp, 13);
+ obp += 13;
+ bcopy (lintcmd, (char *) obp, cmdlen);
+ obp += cmdlen;
+
+ if (arglen != 0) {
+ *(obp++) = ' ';
+ bcopy (argbp, (char *) obp, arglen);
+ obp += arglen;
+ }
+
+ /* OK, now bring us back to the state we were in before we entered
+ this branch. We need #line because the #pragma's newline always
+ messes up the line count. */
+ op->bufp = obp;
+ output_line_directive (ip, op, 0, same_file);
+ check_expand (op, limit - ibp + 2);
+ obp = op->bufp;
+ *(obp++) = '/';
+ }
}
/* Comments are equivalent to spaces.
- Note that we already output the slash; we might not want it.
- For -traditional, a comment is equivalent to nothing. */
+ Note that we already output the slash; we might not want it.
+ For -traditional, a comment is equivalent to nothing. */
if (! put_out_comments) {
- if (traditional)
- obp--;
- else
- obp[-1] = ' ';
+ if (traditional)
+ obp--;
+ else
+ obp[-1] = ' ';
}
else
- *obp++ = '*';
+ *obp++ = '*';
{
- U_CHAR *before_bp = ibp;
-
- for (;;) {
- switch (*ibp++) {
- case '*':
- if (ibp[-2] == '/' && warn_comments)
- warning ("`/*' within comment");
- if (*ibp == '\\' && ibp[1] == '\n')
- newline_fix (ibp);
- if (*ibp == '/')
- goto comment_end;
- break;
-
- case '\n':
- ++ip->lineno;
- /* Copy the newline into the output buffer, in order to
- avoid the pain of a #line every time a multiline comment
- is seen. */
- if (!put_out_comments)
- *obp++ = '\n';
- ++op->lineno;
- break;
-
- case 0:
- if (limit < ibp) {
- error_with_line (line_for_error (start_line),
- "unterminated comment");
- goto limit_reached;
- }
- break;
- }
- }
+ U_CHAR *before_bp = ibp;
+
+ for (;;) {
+ switch (*ibp++) {
+ case '*':
+ if (ibp[-2] == '/' && warn_comments)
+ warning ("`/*' within comment");
+ if (*ibp == '\\' && ibp[1] == '\n')
+ newline_fix (ibp);
+ if (*ibp == '/')
+ goto comment_end;
+ break;
+
+ case '\n':
+ ++ip->lineno;
+ /* Copy the newline into the output buffer, in order to
+ avoid the pain of a #line every time a multiline comment
+ is seen. */
+ if (!put_out_comments)
+ *obp++ = '\n';
+ ++op->lineno;
+ break;
+
+ case 0:
+ if (limit < ibp) {
+ error_with_line (line_for_error (start_line),
+ "unterminated comment");
+ goto limit_reached;
+ }
+ break;
+ }
+ }
comment_end:
- ibp++;
- if (put_out_comments) {
- bcopy ((char *) before_bp, (char *) obp, ibp - before_bp);
- obp += ibp - before_bp;
- }
+ ibp++;
+ if (put_out_comments) {
+ bcopy ((char *) before_bp, (char *) obp, ibp - before_bp);
+ obp += ibp - before_bp;
+ }
}
break;
case '$':
if (! is_idchar['$'])
- goto randomchar;
+ goto randomchar;
if (pedantic)
- pedwarn ("`$' in identifier");
+ pedwarn ("`$' in identifier");
goto letter;
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
/* If digit is not part of identifier, it starts a number,
- which means that following letters are not an identifier.
- "0x5" does not refer to an identifier "x5".
- So copy all alphanumerics that follow without accumulating
- as an identifier. Periods also, for sake of "3.e7". */
+ which means that following letters are not an identifier.
+ "0x5" does not refer to an identifier "x5".
+ So copy all alphanumerics that follow without accumulating
+ as an identifier. Periods also, for sake of "3.e7". */
if (ident_length == 0) {
- for (;;) {
- if (!ip->macro) {
- while (ibp[0] == '\\' && ibp[1] == '\n') {
- ++ip->lineno;
- ibp += 2;
- }
- }
- c = *ibp++;
- if (!is_idchar[c] && c != '.') {
- --ibp;
- break;
- }
- *obp++ = c;
- /* A sign can be part of a preprocessing number
- if it follows an `e' or `p'. */
- if (c == 'e' || c == 'E' || c == 'p' || c == 'P') {
- if (!ip->macro) {
- while (ibp[0] == '\\' && ibp[1] == '\n') {
- ++ip->lineno;
- ibp += 2;
- }
- }
- if (*ibp == '+' || *ibp == '-') {
- *obp++ = *ibp++;
- /* But traditional C does not let the token go past the sign,
- and C89 does not allow `p'. */
- if (traditional || (c89 && (c == 'p' || c == 'P')))
- break;
- }
- }
- }
- break;
+ for (;;) {
+ if (!ip->macro) {
+ while (ibp[0] == '\\' && ibp[1] == '\n') {
+ ++ip->lineno;
+ ibp += 2;
+ }
+ }
+ c = *ibp++;
+ if (!is_idchar[c] && c != '.') {
+ --ibp;
+ break;
+ }
+ *obp++ = c;
+ /* A sign can be part of a preprocessing number
+ if it follows an `e' or `p'. */
+ if (c == 'e' || c == 'E' || c == 'p' || c == 'P') {
+ if (!ip->macro) {
+ while (ibp[0] == '\\' && ibp[1] == '\n') {
+ ++ip->lineno;
+ ibp += 2;
+ }
+ }
+ if (*ibp == '+' || *ibp == '-') {
+ *obp++ = *ibp++;
+ /* But traditional C does not let the token go past the sign,
+ and C89 does not allow `p'. */
+ if (traditional || (c89 && (c == 'p' || c == 'P')))
+ break;
+ }
+ }
+ }
+ break;
}
/* fall through */
@@ -3067,56 +3067,56 @@ do { ip = &instack[indepth]; \
case '\n':
if (ip->fname == 0 && *ibp == '-') {
- /* Newline - inhibits expansion of preceding token.
- If expanding a macro arg, we keep the newline -.
- In final output, it is deleted.
- We recognize Newline - in macro bodies and macro args. */
- if (! concatenated) {
- ident_length = 0;
- hash = 0;
- }
- ibp++;
- if (!output_marks) {
- obp--;
- } else {
- /* If expanding a macro arg, keep the newline -. */
- *obp++ = '-';
- }
- break;
+ /* Newline - inhibits expansion of preceding token.
+ If expanding a macro arg, we keep the newline -.
+ In final output, it is deleted.
+ We recognize Newline - in macro bodies and macro args. */
+ if (! concatenated) {
+ ident_length = 0;
+ hash = 0;
+ }
+ ibp++;
+ if (!output_marks) {
+ obp--;
+ } else {
+ /* If expanding a macro arg, keep the newline -. */
+ *obp++ = '-';
+ }
+ break;
}
/* If reprocessing a macro expansion, newline is a special marker. */
else if (ip->macro != 0) {
- /* Newline White is a "funny space" to separate tokens that are
- supposed to be separate but without space between.
- Here White means any whitespace character.
- Newline - marks a recursive macro use that is not
- supposed to be expandable. */
-
- if (is_space[*ibp]) {
- /* Newline Space does not prevent expansion of preceding token
- so expand the preceding token and then come back. */
- if (ident_length > 0)
- goto specialchar;
-
- /* If generating final output, newline space makes a space. */
- if (!output_marks) {
- obp[-1] = *ibp++;
- /* And Newline Newline makes a newline, so count it. */
- if (obp[-1] == '\n')
- op->lineno++;
- } else {
- /* If expanding a macro arg, keep the newline space.
- If the arg gets stringified, newline space makes nothing. */
- *obp++ = *ibp++;
- }
- } else abort (); /* Newline followed by something random? */
- break;
+ /* Newline White is a "funny space" to separate tokens that are
+ supposed to be separate but without space between.
+ Here White means any whitespace character.
+ Newline - marks a recursive macro use that is not
+ supposed to be expandable. */
+
+ if (is_space[*ibp]) {
+ /* Newline Space does not prevent expansion of preceding token
+ so expand the preceding token and then come back. */
+ if (ident_length > 0)
+ goto specialchar;
+
+ /* If generating final output, newline space makes a space. */
+ if (!output_marks) {
+ obp[-1] = *ibp++;
+ /* And Newline Newline makes a newline, so count it. */
+ if (obp[-1] == '\n')
+ op->lineno++;
+ } else {
+ /* If expanding a macro arg, keep the newline space.
+ If the arg gets stringified, newline space makes nothing. */
+ *obp++ = *ibp++;
+ }
+ } else abort (); /* Newline followed by something random? */
+ break;
}
/* If there is a pending identifier, handle it and come back here. */
if (ident_length > 0)
- goto specialchar;
+ goto specialchar;
beg_of_line = ibp;
@@ -3124,59 +3124,59 @@ do { ip = &instack[indepth]; \
++ip->lineno;
++op->lineno;
if (ip->lineno != op->lineno) {
- op->bufp = obp;
- output_line_directive (ip, op, 1, same_file);
- check_expand (op, limit - ibp);
- obp = op->bufp;
+ op->bufp = obp;
+ output_line_directive (ip, op, 1, same_file);
+ check_expand (op, limit - ibp);
+ obp = op->bufp;
}
break;
/* Come here either after (1) a null character that is part of the input
- or (2) at the end of the input, because there is a null there. */
+ or (2) at the end of the input, because there is a null there. */
case 0:
if (ibp <= limit)
- /* Our input really contains a null character. */
- goto randomchar;
+ /* Our input really contains a null character. */
+ goto randomchar;
limit_reached:
/* At end of a macro-expansion level, pop it and read next level. */
if (ip->macro != 0) {
- obp--;
- ibp--;
- /* If traditional, and we have an identifier that ends here,
- process it now, so we get the right error for recursion. */
- if (traditional && ident_length
- && ! is_idchar[*instack[indepth - 1].bufp]) {
- redo_char = 1;
- goto randomchar;
- }
- POPMACRO;
- RECACHE;
- break;
+ obp--;
+ ibp--;
+ /* If traditional, and we have an identifier that ends here,
+ process it now, so we get the right error for recursion. */
+ if (traditional && ident_length
+ && ! is_idchar[*instack[indepth - 1].bufp]) {
+ redo_char = 1;
+ goto randomchar;
+ }
+ POPMACRO;
+ RECACHE;
+ break;
}
/* If we don't have a pending identifier,
- return at end of input. */
+ return at end of input. */
if (ident_length == 0) {
- obp--;
- ibp--;
- op->bufp = obp;
- ip->bufp = ibp;
- goto ending;
+ obp--;
+ ibp--;
+ op->bufp = obp;
+ ip->bufp = ibp;
+ goto ending;
}
/* If we do have a pending identifier, just consider this null
- a special character and arrange to dispatch on it again.
- The second time, IDENT_LENGTH will be zero so we will return. */
+ a special character and arrange to dispatch on it again.
+ The second time, IDENT_LENGTH will be zero so we will return. */
/* Fall through */
specialchar:
/* Handle the case of a character such as /, ', " or null
- seen following an identifier. Back over it so that
- after the identifier is processed the special char
- will be dispatched on again. */
+ seen following an identifier. Back over it so that
+ after the identifier is processed the special char
+ will be dispatched on again. */
ibp--;
obp--;
@@ -3187,258 +3187,258 @@ specialchar:
randomchar:
if (ident_length > 0) {
- register HASHNODE *hp;
-
- /* We have just seen an identifier end. If it's a macro, expand it.
-
- IDENT_LENGTH is the length of the identifier
- and HASH is its hash code.
-
- The identifier has already been copied to the output,
- so if it is a macro we must remove it.
-
- If REDO_CHAR is 0, the char that terminated the identifier
- has been skipped in the output and the input.
- OBP-IDENT_LENGTH-1 points to the identifier.
- If the identifier is a macro, we must back over the terminator.
-
- If REDO_CHAR is 1, the terminating char has already been
- backed over. OBP-IDENT_LENGTH points to the identifier. */
-
- if (!pcp_outfile || pcp_inside_if) {
- for (hp = hashtab[MAKE_POS (hash) % HASHSIZE]; hp != NULL;
- hp = hp->next) {
-
- if (hp->length == ident_length) {
- int obufp_before_macroname;
- int op_lineno_before_macroname;
- register int i = ident_length;
- register U_CHAR *p = hp->name;
- register U_CHAR *q = obp - i;
- int disabled;
-
- if (! redo_char)
- q--;
-
- do { /* All this to avoid a strncmp () */
- if (*p++ != *q++)
- goto hashcollision;
- } while (--i);
-
- /* We found a use of a macro name.
- see if the context shows it is a macro call. */
-
- /* Back up over terminating character if not already done. */
- if (! redo_char) {
- ibp--;
- obp--;
- }
-
- /* Save this as a displacement from the beginning of the output
- buffer. We can not save this as a position in the output
- buffer, because it may get realloc'ed by RECACHE. */
- obufp_before_macroname = (obp - op->buf) - ident_length;
- op_lineno_before_macroname = op->lineno;
-
- if (hp->type == T_PCSTRING) {
- pcstring_used (hp); /* Mark the definition of this key
- as needed, ensuring that it
- will be output. */
- break; /* Exit loop, since the key cannot have a
- definition any longer. */
- }
-
- /* Record whether the macro is disabled. */
- disabled = hp->type == T_DISABLED;
-
- /* This looks like a macro ref, but if the macro was disabled,
- just copy its name and put in a marker if requested. */
-
- if (disabled) {
+ register HASHNODE *hp;
+
+ /* We have just seen an identifier end. If it's a macro, expand it.
+
+ IDENT_LENGTH is the length of the identifier
+ and HASH is its hash code.
+
+ The identifier has already been copied to the output,
+ so if it is a macro we must remove it.
+
+ If REDO_CHAR is 0, the char that terminated the identifier
+ has been skipped in the output and the input.
+ OBP-IDENT_LENGTH-1 points to the identifier.
+ If the identifier is a macro, we must back over the terminator.
+
+ If REDO_CHAR is 1, the terminating char has already been
+ backed over. OBP-IDENT_LENGTH points to the identifier. */
+
+ if (!pcp_outfile || pcp_inside_if) {
+ for (hp = hashtab[MAKE_POS (hash) % HASHSIZE]; hp != NULL;
+ hp = hp->next) {
+
+ if (hp->length == ident_length) {
+ int obufp_before_macroname;
+ int op_lineno_before_macroname;
+ register int i = ident_length;
+ register U_CHAR *p = hp->name;
+ register U_CHAR *q = obp - i;
+ int disabled;
+
+ if (! redo_char)
+ q--;
+
+ do { /* All this to avoid a strncmp () */
+ if (*p++ != *q++)
+ goto hashcollision;
+ } while (--i);
+
+ /* We found a use of a macro name.
+ see if the context shows it is a macro call. */
+
+ /* Back up over terminating character if not already done. */
+ if (! redo_char) {
+ ibp--;
+ obp--;
+ }
+
+ /* Save this as a displacement from the beginning of the output
+ buffer. We can not save this as a position in the output
+ buffer, because it may get realloc'ed by RECACHE. */
+ obufp_before_macroname = (obp - op->buf) - ident_length;
+ op_lineno_before_macroname = op->lineno;
+
+ if (hp->type == T_PCSTRING) {
+ pcstring_used (hp); /* Mark the definition of this key
+ as needed, ensuring that it
+ will be output. */
+ break; /* Exit loop, since the key cannot have a
+ definition any longer. */
+ }
+
+ /* Record whether the macro is disabled. */
+ disabled = hp->type == T_DISABLED;
+
+ /* This looks like a macro ref, but if the macro was disabled,
+ just copy its name and put in a marker if requested. */
+
+ if (disabled) {
#if 0
- /* This error check caught useful cases such as
- #define foo(x,y) bar (x (y,0), y)
- foo (foo, baz) */
- if (traditional)
- error ("recursive use of macro `%s'", hp->name);
+ /* This error check caught useful cases such as
+ #define foo(x,y) bar (x (y,0), y)
+ foo (foo, baz) */
+ if (traditional)
+ error ("recursive use of macro `%s'", hp->name);
#endif
-
- if (output_marks) {
- check_expand (op, limit - ibp + 2);
- *obp++ = '\n';
- *obp++ = '-';
- }
- break;
- }
-
- /* If macro wants an arglist, verify that a '(' follows.
- first skip all whitespace, copying it to the output
- after the macro name. Then, if there is no '(',
- decide this is not a macro call and leave things that way. */
- if ((hp->type == T_MACRO || hp->type == T_DISABLED)
- && hp->value.defn->nargs >= 0)
- {
- U_CHAR *old_ibp = ibp;
- U_CHAR *old_obp = obp;
- int old_iln = ip->lineno;
- int old_oln = op->lineno;
-
- while (1) {
- /* Scan forward over whitespace, copying it to the output. */
- if (ibp == limit && ip->macro != 0) {
- POPMACRO;
- RECACHE;
- old_ibp = ibp;
- old_obp = obp;
- old_iln = ip->lineno;
- old_oln = op->lineno;
- }
- else if (is_space[*ibp]) {
- *obp++ = *ibp++;
- if (ibp[-1] == '\n') {
- if (ip->macro == 0) {
- /* Newline in a file. Count it. */
- ++ip->lineno;
- ++op->lineno;
- } else if (!output_marks) {
- /* A newline mark, and we don't want marks
- in the output. If it is newline-hyphen,
- discard it entirely. Otherwise, it is
- newline-whitechar, so keep the whitechar. */
- obp--;
- if (*ibp == '-')
- ibp++;
- else {
- if (*ibp == '\n')
- ++op->lineno;
- *obp++ = *ibp++;
- }
- } else {
- /* A newline mark; copy both chars to the output. */
- *obp++ = *ibp++;
- }
- }
- }
- else if (ip->macro)
- break;
- else if (*ibp == '/') {
- /* If a comment, copy it unchanged or discard it. */
- if (ibp[1] == '\\' && ibp[2] == '\n')
- newline_fix (ibp + 1);
- if (ibp[1] == '*') {
- if (put_out_comments) {
- *obp++ = '/';
- *obp++ = '*';
- } else if (! traditional) {
- *obp++ = ' ';
- }
- for (ibp += 2; ibp < limit; ibp++) {
- /* We need not worry about newline-marks,
- since they are never found in comments. */
- if (ibp[0] == '*') {
- if (ibp[1] == '\\' && ibp[2] == '\n')
- newline_fix (ibp + 1);
- if (ibp[1] == '/') {
- ibp += 2;
- if (put_out_comments) {
- *obp++ = '*';
- *obp++ = '/';
- }
- break;
- }
- }
- if (*ibp == '\n') {
- /* Newline in a file. Count it. */
- ++ip->lineno;
- ++op->lineno;
- }
- if (put_out_comments)
- *obp++ = *ibp;
- }
- } else if (ibp[1] == '/' && cplusplus_comments) {
- if (put_out_comments) {
- *obp++ = '/';
- *obp++ = '/';
- } else if (! traditional) {
- *obp++ = ' ';
- }
- for (ibp += 2; *ibp != '\n' || ibp[-1] == '\\'; ibp++)
- if (put_out_comments)
- *obp++ = *ibp;
- } else
- break;
- }
- else if (ibp[0] == '\\' && ibp[1] == '\n') {
- ibp += 2;
- ++ip->lineno;
- }
- else break;
- }
- if (*ibp != '(') {
- /* It isn't a macro call.
- Put back the space that we just skipped. */
- ibp = old_ibp;
- obp = old_obp;
- ip->lineno = old_iln;
- op->lineno = old_oln;
- /* Exit the for loop. */
- break;
- }
- }
-
- /* This is now known to be a macro call.
- Discard the macro name from the output,
- along with any following whitespace just copied,
- but preserve newlines if not outputting marks since this
- is more likely to do the right thing with line numbers. */
- obp = op->buf + obufp_before_macroname;
- if (output_marks)
- op->lineno = op_lineno_before_macroname;
- else {
- int newlines = op->lineno - op_lineno_before_macroname;
- while (0 < newlines--)
- *obp++ = '\n';
- }
-
- /* Prevent accidental token-pasting with a character
- before the macro call. */
- if (!traditional && obp != op->buf) {
- switch (obp[-1]) {
- case '!': case '%': case '&': case '*':
- case '+': case '-': case '.': case '/':
- case ':': case '<': case '=': case '>':
- case '^': case '|':
- /* If we are expanding a macro arg, make a newline marker
- to separate the tokens. If we are making real output,
- a plain space will do. */
- if (output_marks)
- *obp++ = '\n';
- *obp++ = ' ';
- }
- }
-
- /* Expand the macro, reading arguments as needed,
- and push the expansion on the input stack. */
- ip->bufp = ibp;
- op->bufp = obp;
- macroexpand (hp, op);
-
- /* Reexamine input stack, since macroexpand has pushed
- a new level on it. */
- obp = op->bufp;
- RECACHE;
- break;
- }
+
+ if (output_marks) {
+ check_expand (op, limit - ibp + 2);
+ *obp++ = '\n';
+ *obp++ = '-';
+ }
+ break;
+ }
+
+ /* If macro wants an arglist, verify that a '(' follows.
+ first skip all whitespace, copying it to the output
+ after the macro name. Then, if there is no '(',
+ decide this is not a macro call and leave things that way. */
+ if ((hp->type == T_MACRO || hp->type == T_DISABLED)
+ && hp->value.defn->nargs >= 0)
+ {
+ U_CHAR *old_ibp = ibp;
+ U_CHAR *old_obp = obp;
+ int old_iln = ip->lineno;
+ int old_oln = op->lineno;
+
+ while (1) {
+ /* Scan forward over whitespace, copying it to the output. */
+ if (ibp == limit && ip->macro != 0) {
+ POPMACRO;
+ RECACHE;
+ old_ibp = ibp;
+ old_obp = obp;
+ old_iln = ip->lineno;
+ old_oln = op->lineno;
+ }
+ else if (is_space[*ibp]) {
+ *obp++ = *ibp++;
+ if (ibp[-1] == '\n') {
+ if (ip->macro == 0) {
+ /* Newline in a file. Count it. */
+ ++ip->lineno;
+ ++op->lineno;
+ } else if (!output_marks) {
+ /* A newline mark, and we don't want marks
+ in the output. If it is newline-hyphen,
+ discard it entirely. Otherwise, it is
+ newline-whitechar, so keep the whitechar. */
+ obp--;
+ if (*ibp == '-')
+ ibp++;
+ else {
+ if (*ibp == '\n')
+ ++op->lineno;
+ *obp++ = *ibp++;
+ }
+ } else {
+ /* A newline mark; copy both chars to the output. */
+ *obp++ = *ibp++;
+ }
+ }
+ }
+ else if (ip->macro)
+ break;
+ else if (*ibp == '/') {
+ /* If a comment, copy it unchanged or discard it. */
+ if (ibp[1] == '\\' && ibp[2] == '\n')
+ newline_fix (ibp + 1);
+ if (ibp[1] == '*') {
+ if (put_out_comments) {
+ *obp++ = '/';
+ *obp++ = '*';
+ } else if (! traditional) {
+ *obp++ = ' ';
+ }
+ for (ibp += 2; ibp < limit; ibp++) {
+ /* We need not worry about newline-marks,
+ since they are never found in comments. */
+ if (ibp[0] == '*') {
+ if (ibp[1] == '\\' && ibp[2] == '\n')
+ newline_fix (ibp + 1);
+ if (ibp[1] == '/') {
+ ibp += 2;
+ if (put_out_comments) {
+ *obp++ = '*';
+ *obp++ = '/';
+ }
+ break;
+ }
+ }
+ if (*ibp == '\n') {
+ /* Newline in a file. Count it. */
+ ++ip->lineno;
+ ++op->lineno;
+ }
+ if (put_out_comments)
+ *obp++ = *ibp;
+ }
+ } else if (ibp[1] == '/' && cplusplus_comments) {
+ if (put_out_comments) {
+ *obp++ = '/';
+ *obp++ = '/';
+ } else if (! traditional) {
+ *obp++ = ' ';
+ }
+ for (ibp += 2; *ibp != '\n' || ibp[-1] == '\\'; ibp++)
+ if (put_out_comments)
+ *obp++ = *ibp;
+ } else
+ break;
+ }
+ else if (ibp[0] == '\\' && ibp[1] == '\n') {
+ ibp += 2;
+ ++ip->lineno;
+ }
+ else break;
+ }
+ if (*ibp != '(') {
+ /* It isn't a macro call.
+ Put back the space that we just skipped. */
+ ibp = old_ibp;
+ obp = old_obp;
+ ip->lineno = old_iln;
+ op->lineno = old_oln;
+ /* Exit the for loop. */
+ break;
+ }
+ }
+
+ /* This is now known to be a macro call.
+ Discard the macro name from the output,
+ along with any following whitespace just copied,
+ but preserve newlines if not outputting marks since this
+ is more likely to do the right thing with line numbers. */
+ obp = op->buf + obufp_before_macroname;
+ if (output_marks)
+ op->lineno = op_lineno_before_macroname;
+ else {
+ int newlines = op->lineno - op_lineno_before_macroname;
+ while (0 < newlines--)
+ *obp++ = '\n';
+ }
+
+ /* Prevent accidental token-pasting with a character
+ before the macro call. */
+ if (!traditional && obp != op->buf) {
+ switch (obp[-1]) {
+ case '!': case '%': case '&': case '*':
+ case '+': case '-': case '.': case '/':
+ case ':': case '<': case '=': case '>':
+ case '^': case '|':
+ /* If we are expanding a macro arg, make a newline marker
+ to separate the tokens. If we are making real output,
+ a plain space will do. */
+ if (output_marks)
+ *obp++ = '\n';
+ *obp++ = ' ';
+ }
+ }
+
+ /* Expand the macro, reading arguments as needed,
+ and push the expansion on the input stack. */
+ ip->bufp = ibp;
+ op->bufp = obp;
+ macroexpand (hp, op);
+
+ /* Reexamine input stack, since macroexpand has pushed
+ a new level on it. */
+ obp = op->bufp;
+ RECACHE;
+ break;
+ }
hashcollision:
- ;
- } /* End hash-table-search loop */
- }
- ident_length = hash = 0; /* Stop collecting identifier */
- redo_char = 0;
- concatenated = 0;
- } /* End if (ident_length > 0) */
- } /* End switch */
- } /* End per-char loop */
+ ;
+ } /* End hash-table-search loop */
+ }
+ ident_length = hash = 0; /* Stop collecting identifier */
+ redo_char = 0;
+ concatenated = 0;
+ } /* End if (ident_length > 0) */
+ } /* End switch */
+ } /* End per-char loop */
/* Come here to return -- but first give an error message
if there was an unterminated successful conditional. */
@@ -3448,28 +3448,28 @@ hashcollision:
char *str;
switch (if_stack->type)
- {
- case T_IF:
- str = "if";
- break;
- case T_IFDEF:
- str = "ifdef";
- break;
- case T_IFNDEF:
- str = "ifndef";
- break;
- case T_ELSE:
- str = "else";
- break;
- case T_ELIF:
- str = "elif";
- break;
- default:
- abort ();
- }
+ {
+ case T_IF:
+ str = "if";
+ break;
+ case T_IFDEF:
+ str = "ifdef";
+ break;
+ case T_IFNDEF:
+ str = "ifndef";
+ break;
+ case T_ELSE:
+ str = "else";
+ break;
+ case T_ELIF:
+ str = "elif";
+ break;
+ default:
+ abort ();
+ }
error_with_line (line_for_error (if_stack->lineno),
- "unterminated `#%s' conditional", str);
+ "unterminated `#%s' conditional", str);
}
if_stack = ip->if_stack;
}
@@ -3591,13 +3591,13 @@ handle_directive (ip, op)
while (1) {
if (is_hor_space[*bp]) {
if (*bp != ' ' && *bp != '\t' && pedantic)
- pedwarn ("%s in preprocessing directive", char_name[*bp]);
+ pedwarn ("%s in preprocessing directive", char_name[*bp]);
bp++;
} else if (*bp == '/') {
if (bp[1] == '\\' && bp[2] == '\n')
- newline_fix (bp + 1);
+ newline_fix (bp + 1);
if (! (bp[1] == '*' || (cplusplus_comments && bp[1] == '/')))
- break;
+ break;
ip->bufp = bp + 2;
skip_to_end_of_comment (ip, &ip->lineno, 0);
bp = ip->bufp;
@@ -3616,9 +3616,9 @@ handle_directive (ip, op)
cp++;
else {
if (*cp == '\\' && cp[1] == '\n')
- name_newline_fix (cp);
+ name_newline_fix (cp);
if (is_idchar[*cp])
- cp++;
+ cp++;
else break;
}
}
@@ -3637,16 +3637,16 @@ handle_directive (ip, op)
U_CHAR *p = ident;
while (is_idchar[*p]) {
if (*p < '0' || *p > '9')
- break;
+ break;
p++;
}
/* Handle # followed by a line number. */
if (p != ident && !is_idchar[*p]) {
static struct directive line_directive_table[] = {
- { 4, do_line, "line", T_LINE},
+ { 4, do_line, "line", T_LINE},
};
if (pedantic)
- pedwarn ("`#' followed by integer");
+ pedwarn ("`#' followed by integer");
after_ident = ident;
kt = line_directive_table;
goto old_linenum;
@@ -3656,9 +3656,9 @@ handle_directive (ip, op)
if (p == ident) {
while (*p == '#' || is_hor_space[*p]) p++;
if (*p == '\n') {
- if (pedantic && !lang_asm)
- warning ("invalid preprocessing directive");
- return 0;
+ if (pedantic && !lang_asm)
+ warning ("invalid preprocessing directive");
+ return 0;
}
}
@@ -3681,7 +3681,7 @@ handle_directive (ip, op)
int *already_output;
/* Nonzero means do not delete comments within the directive.
- #define needs this when -traditional. */
+ #define needs this when -traditional. */
int keep_comments;
old_linenum:
@@ -3692,286 +3692,286 @@ handle_directive (ip, op)
keep_comments = traditional && kt->type == T_DEFINE;
/* #import is defined only in Objective C, or when on the NeXT. */
if (kt->type == T_IMPORT
- && !(objc || lookup ((U_CHAR *) "__NeXT__", -1, -1)))
- break;
+ && !(objc || lookup ((U_CHAR *) "__NeXT__", -1, -1)))
+ break;
/* Find the end of this directive (first newline not backslashed
- and not in a string or comment).
- Set COPY_DIRECTIVE if the directive must be copied
- (it contains a backslash-newline or a comment). */
+ and not in a string or comment).
+ Set COPY_DIRECTIVE if the directive must be copied
+ (it contains a backslash-newline or a comment). */
buf = bp = after_ident;
while (bp < limit) {
- register U_CHAR c = *bp++;
- switch (c) {
- case '\\':
- if (bp < limit) {
- if (*bp == '\n') {
- ip->lineno++;
- copy_directive = 1;
- bp++;
- } else if (traditional)
- bp++;
- }
- break;
-
- case '"':
- /* "..." is special for #include. */
- if (IS_INCLUDE_DIRECTIVE_TYPE (kt->type)) {
- while (bp < limit && *bp != '\n') {
- if (*bp == '"') {
- bp++;
- break;
- }
- if (*bp == '\\' && bp[1] == '\n') {
- ip->lineno++;
- copy_directive = 1;
- bp++;
- }
- bp++;
- }
- break;
- }
- /* Fall through. */
- case '\'':
- bp = skip_quoted_string (bp - 1, limit, ip->lineno, &ip->lineno, &copy_directive, &unterminated);
- /* Don't bother calling the directive if we already got an error
- message due to unterminated string. Skip everything and pretend
- we called the directive. */
- if (unterminated) {
- if (traditional) {
- /* Traditional preprocessing permits unterminated strings. */
- ip->bufp = bp;
- goto endloop1;
- }
- ip->bufp = bp;
- return 1;
- }
- break;
-
- /* <...> is special for #include. */
- case '<':
- if (! IS_INCLUDE_DIRECTIVE_TYPE (kt->type))
- break;
- while (bp < limit && *bp != '>' && *bp != '\n') {
- if (*bp == '\\' && bp[1] == '\n') {
- ip->lineno++;
- copy_directive = 1;
- bp++;
- }
- bp++;
- }
- break;
-
- case '/':
- if (*bp == '\\' && bp[1] == '\n')
- newline_fix (bp);
- if (*bp == '*'
- || (cplusplus_comments && *bp == '/')) {
- U_CHAR *obp = bp - 1;
- ip->bufp = bp + 1;
- skip_to_end_of_comment (ip, &ip->lineno, 0);
- bp = ip->bufp;
- /* No need to copy the directive because of a comment at the end;
- just don't include the comment in the directive. */
- if (!put_out_comments) {
- U_CHAR *p;
- for (p = bp; *p == ' ' || *p == '\t'; p++)
- continue;
- if (*p == '\n') {
- bp = obp;
- goto endloop1;
- }
- }
- /* Don't remove the comments if -traditional. */
- if (! keep_comments)
- copy_directive++;
- }
- break;
-
- case '\f':
- case '\r':
- case '\v':
- if (pedantic)
- pedwarn ("%s in preprocessing directive", char_name[c]);
- break;
-
- case '\n':
- --bp; /* Point to the newline */
- ip->bufp = bp;
- goto endloop1;
- }
+ register U_CHAR c = *bp++;
+ switch (c) {
+ case '\\':
+ if (bp < limit) {
+ if (*bp == '\n') {
+ ip->lineno++;
+ copy_directive = 1;
+ bp++;
+ } else if (traditional)
+ bp++;
+ }
+ break;
+
+ case '"':
+ /* "..." is special for #include. */
+ if (IS_INCLUDE_DIRECTIVE_TYPE (kt->type)) {
+ while (bp < limit && *bp != '\n') {
+ if (*bp == '"') {
+ bp++;
+ break;
+ }
+ if (*bp == '\\' && bp[1] == '\n') {
+ ip->lineno++;
+ copy_directive = 1;
+ bp++;
+ }
+ bp++;
+ }
+ break;
+ }
+ /* Fall through. */
+ case '\'':
+ bp = skip_quoted_string (bp - 1, limit, ip->lineno, &ip->lineno, &copy_directive, &unterminated);
+ /* Don't bother calling the directive if we already got an error
+ message due to unterminated string. Skip everything and pretend
+ we called the directive. */
+ if (unterminated) {
+ if (traditional) {
+ /* Traditional preprocessing permits unterminated strings. */
+ ip->bufp = bp;
+ goto endloop1;
+ }
+ ip->bufp = bp;
+ return 1;
+ }
+ break;
+
+ /* <...> is special for #include. */
+ case '<':
+ if (! IS_INCLUDE_DIRECTIVE_TYPE (kt->type))
+ break;
+ while (bp < limit && *bp != '>' && *bp != '\n') {
+ if (*bp == '\\' && bp[1] == '\n') {
+ ip->lineno++;
+ copy_directive = 1;
+ bp++;
+ }
+ bp++;
+ }
+ break;
+
+ case '/':
+ if (*bp == '\\' && bp[1] == '\n')
+ newline_fix (bp);
+ if (*bp == '*'
+ || (cplusplus_comments && *bp == '/')) {
+ U_CHAR *obp = bp - 1;
+ ip->bufp = bp + 1;
+ skip_to_end_of_comment (ip, &ip->lineno, 0);
+ bp = ip->bufp;
+ /* No need to copy the directive because of a comment at the end;
+ just don't include the comment in the directive. */
+ if (!put_out_comments) {
+ U_CHAR *p;
+ for (p = bp; *p == ' ' || *p == '\t'; p++)
+ continue;
+ if (*p == '\n') {
+ bp = obp;
+ goto endloop1;
+ }
+ }
+ /* Don't remove the comments if -traditional. */
+ if (! keep_comments)
+ copy_directive++;
+ }
+ break;
+
+ case '\f':
+ case '\r':
+ case '\v':
+ if (pedantic)
+ pedwarn ("%s in preprocessing directive", char_name[c]);
+ break;
+
+ case '\n':
+ --bp; /* Point to the newline */
+ ip->bufp = bp;
+ goto endloop1;
+ }
}
ip->bufp = bp;
endloop1:
resume_p = ip->bufp;
/* BP is the end of the directive.
- RESUME_P is the next interesting data after the directive.
- A comment may come between. */
+ RESUME_P is the next interesting data after the directive.
+ A comment may come between. */
/* If a directive should be copied through, and -C was given,
- pass it through before removing comments. */
+ pass it through before removing comments. */
if (!no_output && put_out_comments
- && (kt->type == T_DEFINE ? dump_macros == dump_definitions
- : IS_INCLUDE_DIRECTIVE_TYPE (kt->type) ? dump_includes
- : kt->type == T_PRAGMA)) {
+ && (kt->type == T_DEFINE ? dump_macros == dump_definitions
+ : IS_INCLUDE_DIRECTIVE_TYPE (kt->type) ? dump_includes
+ : kt->type == T_PRAGMA)) {
int len;
- /* Output directive name. */
+ /* Output directive name. */
check_expand (op, kt->length + 2);
- /* Make sure # is at the start of a line */
- if (op->bufp > op->buf && op->bufp[-1] != '\n') {
- op->lineno++;
- *op->bufp++ = '\n';
- }
+ /* Make sure # is at the start of a line */
+ if (op->bufp > op->buf && op->bufp[-1] != '\n') {
+ op->lineno++;
+ *op->bufp++ = '\n';
+ }
*op->bufp++ = '#';
bcopy (kt->name, op->bufp, kt->length);
op->bufp += kt->length;
- /* Output arguments. */
- len = (bp - buf);
- check_expand (op, len);
- bcopy (buf, (char *) op->bufp, len);
- op->bufp += len;
- /* Take account of any (escaped) newlines just output. */
- while (--len >= 0)
- if (buf[len] == '\n')
- op->lineno++;
+ /* Output arguments. */
+ len = (bp - buf);
+ check_expand (op, len);
+ bcopy (buf, (char *) op->bufp, len);
+ op->bufp += len;
+ /* Take account of any (escaped) newlines just output. */
+ while (--len >= 0)
+ if (buf[len] == '\n')
+ op->lineno++;
- already_output = &junk;
- } /* Don't we need a newline or #line? */
+ already_output = &junk;
+ } /* Don't we need a newline or #line? */
if (copy_directive) {
- register U_CHAR *xp = buf;
- /* Need to copy entire directive into temp buffer before dispatching */
-
- cp = (U_CHAR *) alloca (bp - buf + 5); /* room for directive plus
- some slop */
- buf = cp;
-
- /* Copy to the new buffer, deleting comments
- and backslash-newlines (and whitespace surrounding the latter). */
-
- while (xp < bp) {
- register U_CHAR c = *xp++;
- *cp++ = c;
-
- switch (c) {
- case '\n':
- abort (); /* A bare newline should never part of the line. */
- break;
-
- /* <...> is special for #include. */
- case '<':
- if (! IS_INCLUDE_DIRECTIVE_TYPE (kt->type))
- break;
- while (xp < bp && c != '>') {
- c = *xp++;
- if (c == '\\' && xp < bp && *xp == '\n')
- xp++;
- else
- *cp++ = c;
- }
- break;
-
- case '\\':
- if (*xp == '\n') {
- xp++;
- cp--;
- if (cp != buf && is_hor_space[cp[-1]]) {
- while (cp - 1 != buf && is_hor_space[cp[-2]])
- cp--;
- SKIP_WHITE_SPACE (xp);
- } else if (is_hor_space[*xp]) {
- *cp++ = *xp++;
- SKIP_WHITE_SPACE (xp);
- }
- } else if (traditional && xp < bp) {
- *cp++ = *xp++;
- }
- break;
-
- case '\'':
- case '\"':
- {
- register U_CHAR *bp1
- = skip_quoted_string (xp - 1, bp, ip->lineno,
- NULL_PTR, NULL_PTR, NULL_PTR);
- while (xp != bp1)
- *cp++ = *xp++;
- }
- break;
-
- case '/':
- if (*xp == '*'
- || (cplusplus_comments && *xp == '/')) {
- ip->bufp = xp + 1;
- /* If we already copied the directive through,
- already_output != 0 prevents outputting comment now. */
- skip_to_end_of_comment (ip, already_output, 0);
- if (keep_comments)
- while (xp != ip->bufp)
- *cp++ = *xp++;
- /* Delete or replace the slash. */
- else if (traditional)
- cp--;
- else
- cp[-1] = ' ';
- xp = ip->bufp;
- }
- }
- }
-
- /* Null-terminate the copy. */
-
- *cp = 0;
+ register U_CHAR *xp = buf;
+ /* Need to copy entire directive into temp buffer before dispatching */
+
+ cp = (U_CHAR *) alloca (bp - buf + 5); /* room for directive plus
+ some slop */
+ buf = cp;
+
+ /* Copy to the new buffer, deleting comments
+ and backslash-newlines (and whitespace surrounding the latter). */
+
+ while (xp < bp) {
+ register U_CHAR c = *xp++;
+ *cp++ = c;
+
+ switch (c) {
+ case '\n':
+ abort (); /* A bare newline should never part of the line. */
+ break;
+
+ /* <...> is special for #include. */
+ case '<':
+ if (! IS_INCLUDE_DIRECTIVE_TYPE (kt->type))
+ break;
+ while (xp < bp && c != '>') {
+ c = *xp++;
+ if (c == '\\' && xp < bp && *xp == '\n')
+ xp++;
+ else
+ *cp++ = c;
+ }
+ break;
+
+ case '\\':
+ if (*xp == '\n') {
+ xp++;
+ cp--;
+ if (cp != buf && is_hor_space[cp[-1]]) {
+ while (cp - 1 != buf && is_hor_space[cp[-2]])
+ cp--;
+ SKIP_WHITE_SPACE (xp);
+ } else if (is_hor_space[*xp]) {
+ *cp++ = *xp++;
+ SKIP_WHITE_SPACE (xp);
+ }
+ } else if (traditional && xp < bp) {
+ *cp++ = *xp++;
+ }
+ break;
+
+ case '\'':
+ case '\"':
+ {
+ register U_CHAR *bp1
+ = skip_quoted_string (xp - 1, bp, ip->lineno,
+ NULL_PTR, NULL_PTR, NULL_PTR);
+ while (xp != bp1)
+ *cp++ = *xp++;
+ }
+ break;
+
+ case '/':
+ if (*xp == '*'
+ || (cplusplus_comments && *xp == '/')) {
+ ip->bufp = xp + 1;
+ /* If we already copied the directive through,
+ already_output != 0 prevents outputting comment now. */
+ skip_to_end_of_comment (ip, already_output, 0);
+ if (keep_comments)
+ while (xp != ip->bufp)
+ *cp++ = *xp++;
+ /* Delete or replace the slash. */
+ else if (traditional)
+ cp--;
+ else
+ cp[-1] = ' ';
+ xp = ip->bufp;
+ }
+ }
+ }
+
+ /* Null-terminate the copy. */
+
+ *cp = 0;
} else
- cp = bp;
+ cp = bp;
ip->bufp = resume_p;
/* Some directives should be written out for cc1 to process,
- just as if they were not defined. And sometimes we're copying
- directives through. */
+ just as if they were not defined. And sometimes we're copying
+ directives through. */
if (!no_output && already_output == 0
- && (kt->type == T_DEFINE ? (int) dump_names <= (int) dump_macros
- : IS_INCLUDE_DIRECTIVE_TYPE (kt->type) ? dump_includes
- : kt->type == T_PRAGMA)) {
+ && (kt->type == T_DEFINE ? (int) dump_names <= (int) dump_macros
+ : IS_INCLUDE_DIRECTIVE_TYPE (kt->type) ? dump_includes
+ : kt->type == T_PRAGMA)) {
int len;
- /* Output directive name. */
+ /* Output directive name. */
check_expand (op, kt->length + 1);
*op->bufp++ = '#';
bcopy (kt->name, (char *) op->bufp, kt->length);
op->bufp += kt->length;
- if (kt->type == T_DEFINE && dump_macros == dump_names) {
- /* Output `#define name' only. */
- U_CHAR *xp = buf;
- U_CHAR *yp;
- SKIP_WHITE_SPACE (xp);
- yp = xp;
- while (is_idchar[*xp]) xp++;
- len = (xp - yp);
- check_expand (op, len + 1);
- *op->bufp++ = ' ';
- bcopy (yp, (char *) op->bufp, len);
- } else {
- /* Output entire directive. */
- len = (cp - buf);
- check_expand (op, len);
- bcopy (buf, (char *) op->bufp, len);
- }
- op->bufp += len;
- } /* Don't we need a newline or #line? */
+ if (kt->type == T_DEFINE && dump_macros == dump_names) {
+ /* Output `#define name' only. */
+ U_CHAR *xp = buf;
+ U_CHAR *yp;
+ SKIP_WHITE_SPACE (xp);
+ yp = xp;
+ while (is_idchar[*xp]) xp++;
+ len = (xp - yp);
+ check_expand (op, len + 1);
+ *op->bufp++ = ' ';
+ bcopy (yp, (char *) op->bufp, len);
+ } else {
+ /* Output entire directive. */
+ len = (cp - buf);
+ check_expand (op, len);
+ bcopy (buf, (char *) op->bufp, len);
+ }
+ op->bufp += len;
+ } /* Don't we need a newline or #line? */
/* Call the appropriate directive handler. buf now points to
- either the appropriate place in the input buffer, or to
- the temp buffer if it was necessary to make one. cp
- points to the first char after the contents of the (possibly
- copied) directive, in either case. */
+ either the appropriate place in the input buffer, or to
+ the temp buffer if it was necessary to make one. cp
+ points to the first char after the contents of the (possibly
+ copied) directive, in either case. */
(*kt->func) (buf, cp, op, kt);
check_expand (op, ip->length - (ip->bufp - ip->buf));
@@ -3996,8 +3996,8 @@ timestamp ()
}
static char *monthnames[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
- };
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
+ };
/*
* expand things like __FILE__. Place the expansion into the output
@@ -4015,12 +4015,12 @@ special_symbol (hp, op)
FILE_BUF *ip = NULL;
struct tm *timebuf;
- int paren = 0; /* For special `defined' keyword */
+ int paren = 0; /* For special `defined' keyword */
if (pcp_outfile && pcp_inside_if
&& hp->type != T_SPEC_DEFINED && hp->type != T_CONST)
error ("Predefined macro `%s' used inside `#if' during precompilation",
- hp->name);
+ hp->name);
for (i = indepth; i >= 0; i--)
if (instack[i].fname != NULL) {
@@ -4029,7 +4029,7 @@ special_symbol (hp, op)
}
if (ip == NULL) {
error ("cccp error: not in any file?!");
- return; /* the show must go on */
+ return; /* the show must go on */
}
switch (hp->type) {
@@ -4038,17 +4038,17 @@ special_symbol (hp, op)
{
char *string;
if (hp->type == T_FILE)
- string = ip->nominal_fname;
+ string = ip->nominal_fname;
else
- string = instack[0].nominal_fname;
+ string = instack[0].nominal_fname;
if (string)
- {
- buf = (char *) alloca (3 + 4 * strlen (string));
- quote_string (buf, string);
- }
+ {
+ buf = (char *) alloca (3 + 4 * strlen (string));
+ quote_string (buf, string);
+ }
else
- buf = "\"\"";
+ buf = "\"\"";
break;
}
@@ -4059,7 +4059,7 @@ special_symbol (hp, op)
if (instack[i].fname != NULL)
true_indepth++;
- buf = (char *) alloca (8); /* Eight bytes ought to be more than enough */
+ buf = (char *) alloca (8); /* Eight bytes ought to be more than enough */
sprintf (buf, "%d", true_indepth - 1);
break;
@@ -4100,8 +4100,8 @@ special_symbol (hp, op)
buf = hp->value.cpval;
#ifdef STDC_0_IN_SYSTEM_HEADERS
if (ip->system_header_p
- && hp->length == 8 && bcmp (hp->name, "__STDC__", 8) == 0
- && !lookup ((U_CHAR *) "__STRICT_ANSI__", -1, -1))
+ && hp->length == 8 && bcmp (hp->name, "__STDC__", 8) == 0
+ && !lookup ((U_CHAR *) "__STRICT_ANSI__", -1, -1))
buf = "0";
#endif
if (pcp_inside_if && pcp_outfile)
@@ -4120,19 +4120,19 @@ special_symbol (hp, op)
timebuf = timestamp ();
if (hp->type == T_DATE)
sprintf (buf, "\"%s %2d %4d\"", monthnames[timebuf->tm_mon],
- timebuf->tm_mday, timebuf->tm_year + 1900);
+ timebuf->tm_mday, timebuf->tm_year + 1900);
else
sprintf (buf, "\"%02d:%02d:%02d\"", timebuf->tm_hour, timebuf->tm_min,
- timebuf->tm_sec);
+ timebuf->tm_sec);
break;
case T_SPEC_DEFINED:
- buf = " 0 "; /* Assume symbol is not defined */
+ buf = " 0 "; /* Assume symbol is not defined */
ip = &instack[indepth];
SKIP_WHITE_SPACE (ip->bufp);
if (*ip->bufp == '(') {
paren++;
- ip->bufp++; /* Skip over the paren */
+ ip->bufp++; /* Skip over the paren */
SKIP_WHITE_SPACE (ip->bufp);
}
@@ -4142,27 +4142,27 @@ special_symbol (hp, op)
goto oops;
if ((hp = lookup (ip->bufp, -1, -1))) {
if (pcp_outfile && pcp_inside_if
- && (hp->type == T_CONST
- || (hp->type == T_MACRO && hp->value.defn->predefined)))
- /* Output a precondition for this macro use. */
- fprintf (pcp_outfile, "#define %s\n", hp->name);
+ && (hp->type == T_CONST
+ || (hp->type == T_MACRO && hp->value.defn->predefined)))
+ /* Output a precondition for this macro use. */
+ fprintf (pcp_outfile, "#define %s\n", hp->name);
buf = " 1 ";
}
else
- if (pcp_outfile && pcp_inside_if) {
- /* Output a precondition for this macro use */
- U_CHAR *cp = ip->bufp;
- fprintf (pcp_outfile, "#undef ");
- while (is_idchar[*cp]) /* Ick! */
- fputc (*cp++, pcp_outfile);
- putc ('\n', pcp_outfile);
+ if (pcp_outfile && pcp_inside_if) {
+ /* Output a precondition for this macro use */
+ U_CHAR *cp = ip->bufp;
+ fprintf (pcp_outfile, "#undef ");
+ while (is_idchar[*cp]) /* Ick! */
+ fputc (*cp++, pcp_outfile);
+ putc ('\n', pcp_outfile);
}
while (is_idchar[*ip->bufp])
++ip->bufp;
SKIP_WHITE_SPACE (ip->bufp);
if (paren) {
if (*ip->bufp != ')')
- goto oops;
+ goto oops;
++ip->bufp;
}
break;
@@ -4199,25 +4199,25 @@ do_include (buf, limit, op, keyword)
U_CHAR *importing = keyword->type == T_IMPORT ? (U_CHAR *) "" : (U_CHAR *) 0;
int skip_dirs = (keyword->type == T_INCLUDE_NEXT);
static int import_warning = 0;
- char *fname; /* Dynamically allocated fname buffer */
+ char *fname; /* Dynamically allocated fname buffer */
char *pcftry;
char *pcfname;
- char *fbeg, *fend; /* Beginning and end of fname */
+ char *fbeg, *fend; /* Beginning and end of fname */
U_CHAR *fin;
struct file_name_list *search_start = include; /* Chain of dirs to search */
- struct file_name_list *dsp; /* First in chain, if #include "..." */
+ struct file_name_list *dsp; /* First in chain, if #include "..." */
struct file_name_list *searchptr = 0;
size_t flen;
- int f = -3; /* file number */
+ int f = -3; /* file number */
struct include_file *inc = 0;
- int retried = 0; /* Have already tried macro
- expanding the include line*/
- int angle_brackets = 0; /* 0 for "...", 1 for <...> */
+ int retried = 0; /* Have already tried macro
+ expanding the include line*/
+ int angle_brackets = 0; /* 0 for "...", 1 for <...> */
#ifdef VMS
- int vaxc_include = 0; /* 1 for token without punctuation */
+ int vaxc_include = 0; /* 1 for token without punctuation */
#endif
int pcf = -1;
char *pcfbuf;
@@ -4227,9 +4227,9 @@ do_include (buf, limit, op, keyword)
if (pedantic && !instack[indepth].system_header_p)
{
if (importing)
- pedwarn ("ANSI C does not allow `#import'");
+ pedwarn ("ANSI C does not allow `#import'");
if (skip_dirs)
- pedwarn ("ANSI C does not allow `#include_next'");
+ pedwarn ("ANSI C does not allow `#include_next'");
}
if (importing && warn_import && !inhibit_warnings
@@ -4263,60 +4263,60 @@ get_filename:
FILE_BUF *fp;
/* Copy the operand text, concatenating the strings. */
{
- for (;;) {
- for (;;) {
- if (fin == limit)
- goto invalid_include_file_name;
- *fend = *fin++;
- if (*fend == '"')
- break;
- fend++;
- }
- if (fin == limit)
- break;
- /* If not at the end, there had better be another string. */
- /* Skip just horiz space, and don't go past limit. */
- while (fin != limit && is_hor_space[*fin]) fin++;
- if (fin != limit && *fin == '\"')
- fin++;
- else
- goto fail;
- }
+ for (;;) {
+ for (;;) {
+ if (fin == limit)
+ goto invalid_include_file_name;
+ *fend = *fin++;
+ if (*fend == '"')
+ break;
+ fend++;
+ }
+ if (fin == limit)
+ break;
+ /* If not at the end, there had better be another string. */
+ /* Skip just horiz space, and don't go past limit. */
+ while (fin != limit && is_hor_space[*fin]) fin++;
+ if (fin != limit && *fin == '\"')
+ fin++;
+ else
+ goto fail;
+ }
}
/* We have "filename". Figure out directory this source
- file is coming from and put it on the front of the list. */
+ file is coming from and put it on the front of the list. */
/* If -I- was specified, don't search current dir, only spec'd ones. */
if (ignore_srcdir) break;
for (fp = &instack[indepth]; fp >= instack; fp--)
- {
- int n;
- char *nam;
-
- if ((nam = fp->nominal_fname) != NULL) {
- /* Found a named file. Figure out dir of the file,
- and put it in front of the search list. */
- dsp = ((struct file_name_list *)
- alloca (sizeof (struct file_name_list) + strlen (nam)));
- strcpy (dsp->fname, nam);
- simplify_filename (dsp->fname);
- nam = base_name (dsp->fname);
- *nam = 0;
- /* But for efficiency's sake, do not insert the dir
- if it matches the search list's first dir. */
- dsp->next = search_start;
- if (!search_start || strcmp (dsp->fname, search_start->fname)) {
- search_start = dsp;
- n = nam - dsp->fname;
- if (n + INCLUDE_LEN_FUDGE > max_include_len)
- max_include_len = n + INCLUDE_LEN_FUDGE;
- }
- dsp[0].got_name_map = 0;
- break;
- }
- }
+ {
+ int n;
+ char *nam;
+
+ if ((nam = fp->nominal_fname) != NULL) {
+ /* Found a named file. Figure out dir of the file,
+ and put it in front of the search list. */
+ dsp = ((struct file_name_list *)
+ alloca (sizeof (struct file_name_list) + strlen (nam)));
+ strcpy (dsp->fname, nam);
+ simplify_filename (dsp->fname);
+ nam = base_name (dsp->fname);
+ *nam = 0;
+ /* But for efficiency's sake, do not insert the dir
+ if it matches the search list's first dir. */
+ dsp->next = search_start;
+ if (!search_start || strcmp (dsp->fname, search_start->fname)) {
+ search_start = dsp;
+ n = nam - dsp->fname;
+ if (n + INCLUDE_LEN_FUDGE > max_include_len)
+ max_include_len = n + INCLUDE_LEN_FUDGE;
+ }
+ dsp[0].got_name_map = 0;
+ break;
+ }
+ }
break;
}
@@ -4341,14 +4341,14 @@ get_filename:
*/
if (retried && isalpha(*(U_CHAR *) (--fbeg))) {
while (fin != limit && (!isspace(*fin)))
- *fend++ = *fin++;
+ *fend++ = *fin++;
warning ("VAX-C-style include specification found, use '#include <filename.h>' !");
vaxc_include = 1;
if (fin == limit) {
- angle_brackets = 1;
- /* If -I-, start with the first -I dir after the -I-. */
- search_start = first_bracket_include;
- break;
+ angle_brackets = 1;
+ /* If -I-, start with the first -I dir after the -I-. */
+ search_start = first_bracket_include;
+ break;
}
}
#endif
@@ -4356,36 +4356,36 @@ get_filename:
fail:
if (! retried) {
/* Expand buffer and then remove any newline markers.
- We can't just tell expand_to_temp_buffer to omit the markers,
- since it would put extra spaces in include file names. */
+ We can't just tell expand_to_temp_buffer to omit the markers,
+ since it would put extra spaces in include file names. */
FILE_BUF trybuf;
U_CHAR *src;
int errors_before_expansion = errors;
trybuf = expand_to_temp_buffer (buf, limit, 1, 0);
if (errors != errors_before_expansion) {
- free (trybuf.buf);
- goto invalid_include_file_name;
+ free (trybuf.buf);
+ goto invalid_include_file_name;
}
src = trybuf.buf;
buf = (U_CHAR *) alloca (trybuf.bufp - trybuf.buf + 1);
limit = buf;
while (src != trybuf.bufp) {
- switch ((*limit++ = *src++)) {
- case '\n':
- limit--;
- src++;
- break;
-
- case '\'':
- case '\"':
- {
- U_CHAR *src1 = skip_quoted_string (src - 1, trybuf.bufp, 0,
- NULL_PTR, NULL_PTR, NULL_PTR);
- while (src != src1)
- *limit++ = *src++;
- }
- break;
- }
+ switch ((*limit++ = *src++)) {
+ case '\n':
+ limit--;
+ src++;
+ break;
+
+ case '\'':
+ case '\"':
+ {
+ U_CHAR *src1 = skip_quoted_string (src - 1, trybuf.bufp, 0,
+ NULL_PTR, NULL_PTR, NULL_PTR);
+ while (src != src1)
+ *limit++ = *src++;
+ }
+ break;
+ }
}
*limit = 0;
free (trybuf.buf);
@@ -4404,11 +4404,11 @@ get_filename:
FILE_BUF *fp;
for (fp = &instack[indepth]; fp >= instack; fp--)
if (fp->fname != NULL) {
- /* fp->dir is null if the containing file was specified
- with an absolute file name. In that case, don't skip anything. */
- if (fp->dir)
- search_start = fp->dir->next;
- break;
+ /* fp->dir is null if the containing file was specified
+ with an absolute file name. In that case, don't skip anything. */
+ if (fp->dir)
+ search_start = fp->dir->next;
+ break;
}
}
@@ -4447,17 +4447,17 @@ get_filename:
for (searchptr = search_start; searchptr; searchptr = searchptr->next) {
if (searchptr == first_bracket_include) {
- /* Go to bypass directory if we know we've seen this file before. */
- static struct bypass_dir *bypass_hashtab[INCLUDE_HASHSIZE];
- struct bypass_dir *p;
- bypass_slot = &bypass_hashtab[hashf ((U_CHAR *) fbeg, flen,
- INCLUDE_HASHSIZE)];
- for (p = *bypass_slot; p; p = p->next)
- if (!strcmp (fbeg, p->fname)) {
- searchptr = p->searchptr;
- bypass_slot = 0;
- break;
- }
+ /* Go to bypass directory if we know we've seen this file before. */
+ static struct bypass_dir *bypass_hashtab[INCLUDE_HASHSIZE];
+ struct bypass_dir *p;
+ bypass_slot = &bypass_hashtab[hashf ((U_CHAR *) fbeg, flen,
+ INCLUDE_HASHSIZE)];
+ for (p = *bypass_slot; p; p = p->next)
+ if (!strcmp (fbeg, p->fname)) {
+ searchptr = p->searchptr;
+ bypass_slot = 0;
+ break;
+ }
}
strcpy (fname, searchptr->fname);
@@ -4466,40 +4466,40 @@ get_filename:
/* Change this 1/2 Unix 1/2 VMS file specification into a
full VMS file specification */
if (searchptr->fname[0]) {
- /* Fix up the filename */
- hack_vms_include_specification (fname, vaxc_include);
+ /* Fix up the filename */
+ hack_vms_include_specification (fname, vaxc_include);
} else {
- /* This is a normal VMS filespec, so use it unchanged. */
- strcpy (fname, fbeg);
- /* if it's '#include filename', add the missing .h */
- if (vaxc_include && index(fname,'.')==NULL) {
- strcat (fname, ".h");
- }
+ /* This is a normal VMS filespec, so use it unchanged. */
+ strcpy (fname, fbeg);
+ /* if it's '#include filename', add the missing .h */
+ if (vaxc_include && index(fname,'.')==NULL) {
+ strcat (fname, ".h");
+ }
}
#endif /* VMS */
f = open_include_file (fname, searchptr, importing, &inc);
if (f != -1) {
- if (bypass_slot && searchptr != first_bracket_include) {
- /* This is the first time we found this include file,
- and we found it after first_bracket_include.
- Record its location so that we can bypass to here next time. */
- struct bypass_dir *p
- = (struct bypass_dir *) xmalloc (sizeof (struct bypass_dir));
- p->next = *bypass_slot;
- p->fname = fname + strlen (searchptr->fname);
- p->searchptr = searchptr;
- *bypass_slot = p;
- }
- break;
+ if (bypass_slot && searchptr != first_bracket_include) {
+ /* This is the first time we found this include file,
+ and we found it after first_bracket_include.
+ Record its location so that we can bypass to here next time. */
+ struct bypass_dir *p
+ = (struct bypass_dir *) xmalloc (sizeof (struct bypass_dir));
+ p->next = *bypass_slot;
+ p->fname = fname + strlen (searchptr->fname);
+ p->searchptr = searchptr;
+ *bypass_slot = p;
+ }
+ break;
}
#ifdef VMS
/* Our VMS hacks can produce invalid filespecs, so don't worry
- about errors other than EACCES. */
+ about errors other than EACCES. */
if (errno == EACCES)
- break;
+ break;
#else
if (errno != ENOENT && errno != ENOTDIR)
- break;
+ break;
#endif
}
}
@@ -4515,26 +4515,26 @@ get_filename:
or other similar place; these missing files may be generated from
other files and may not exist yet (eg: y.tab.h). */
} else if (print_deps_missing_files
- && (system_include_depth != 0) < print_deps)
+ && (system_include_depth != 0) < print_deps)
{
- /* If it was requested as a system header file,
- then assume it belongs in the first place to look for such. */
- if (angle_brackets)
- {
- if (search_start) {
- char *p = (char *) alloca (strlen (search_start->fname)
- + strlen (fbeg) + 1);
- strcpy (p, search_start->fname);
- strcat (p, fbeg);
- deps_output (p, ' ');
- }
- }
- else
- {
- /* Otherwise, omit the directory, as if the file existed
- in the directory with the source. */
- deps_output (fbeg, ' ');
- }
+ /* If it was requested as a system header file,
+ then assume it belongs in the first place to look for such. */
+ if (angle_brackets)
+ {
+ if (search_start) {
+ char *p = (char *) alloca (strlen (search_start->fname)
+ + strlen (fbeg) + 1);
+ strcpy (p, search_start->fname);
+ strcat (p, fbeg);
+ deps_output (p, ' ');
+ }
+ }
+ else
+ {
+ /* Otherwise, omit the directory, as if the file existed
+ in the directory with the source. */
+ deps_output (fbeg, ' ');
+ }
}
/* If -M was specified, and this header file won't be added to the
dependency list, then don't count this as an error, because we can
@@ -4558,31 +4558,31 @@ get_filename:
if (!no_precomp)
{
- do {
- sprintf (pcftry, "%s%d", fname, pcfnum++);
-
- pcf = open (pcftry, O_RDONLY, 0666);
- if (pcf != -1)
- {
- struct stat s;
-
- if (fstat (pcf, &s) != 0)
- pfatal_with_name (pcftry);
- if (! INO_T_EQ (inc->st.st_ino, s.st_ino)
- || inc->st.st_dev != s.st_dev)
- {
- pcfbuf = check_precompiled (pcf, &s, fname, &pcfbuflimit);
- /* Don't need it any more. */
- close (pcf);
- }
- else
- {
- /* Don't need it at all. */
- close (pcf);
- break;
- }
- }
- } while (pcf != -1 && !pcfbuf);
+ do {
+ sprintf (pcftry, "%s%d", fname, pcfnum++);
+
+ pcf = open (pcftry, O_RDONLY, 0666);
+ if (pcf != -1)
+ {
+ struct stat s;
+
+ if (fstat (pcf, &s) != 0)
+ pfatal_with_name (pcftry);
+ if (! INO_T_EQ (inc->st.st_ino, s.st_ino)
+ || inc->st.st_dev != s.st_dev)
+ {
+ pcfbuf = check_precompiled (pcf, &s, fname, &pcfbuflimit);
+ /* Don't need it any more. */
+ close (pcf);
+ }
+ else
+ {
+ /* Don't need it at all. */
+ close (pcf);
+ break;
+ }
+ }
+ } while (pcf != -1 && !pcfbuf);
}
/* Actually process the file */
@@ -4590,7 +4590,7 @@ get_filename:
pcfname = xmalloc (strlen (pcftry) + 1);
strcpy (pcfname, pcftry);
pcfinclude ((U_CHAR *) pcfbuf, (U_CHAR *) pcfbuflimit,
- (U_CHAR *) fname, op);
+ (U_CHAR *) fname, op);
}
else
finclude (f, inc, op, is_system_include (fname), searchptr);
@@ -4637,9 +4637,9 @@ base_name (fname)
if (isalpha (s[0]) && s[1] == ':') s += 2;
#endif
#ifdef VMS
- if ((p = rindex (s, ':'))) s = p + 1; /* Skip device. */
- if ((p = rindex (s, ']'))) s = p + 1; /* Skip directory. */
- if ((p = rindex (s, '>'))) s = p + 1; /* Skip alternate (int'n'l) dir. */
+ if ((p = rindex (s, ':'))) s = p + 1; /* Skip device. */
+ if ((p = rindex (s, ']'))) s = p + 1; /* Skip directory. */
+ if ((p = rindex (s, '>'))) s = p + 1; /* Skip alternate (int'n'l) dir. */
if (s != fname)
return s;
#endif
@@ -4691,21 +4691,21 @@ simplify_filename (filename)
*to++ = '/';
if (*++from == '/') {
if (*++from == '/') {
- /* 3 or more initial /s are equivalent to 1 /. */
- while (*++from == '/')
- continue;
+ /* 3 or more initial /s are equivalent to 1 /. */
+ while (*++from == '/')
+ continue;
} else {
- /* On some hosts // differs from /; Posix allows this. */
- static int slashslash_vs_slash;
- if (slashslash_vs_slash == 0) {
- struct stat s1, s2;
- slashslash_vs_slash = ((stat ("/", &s1) == 0 && stat ("//", &s2) == 0
- && INO_T_EQ (s1.st_ino, s2.st_ino)
- && s1.st_dev == s2.st_dev)
- ? 1 : -1);
- }
- if (slashslash_vs_slash < 0)
- *to++ = '/';
+ /* On some hosts // differs from /; Posix allows this. */
+ static int slashslash_vs_slash;
+ if (slashslash_vs_slash == 0) {
+ struct stat s1, s2;
+ slashslash_vs_slash = ((stat ("/", &s1) == 0 && stat ("//", &s2) == 0
+ && INO_T_EQ (s1.st_ino, s2.st_ino)
+ && s1.st_dev == s2.st_dev)
+ ? 1 : -1);
+ }
+ if (slashslash_vs_slash < 0)
+ *to++ = '/';
}
}
}
@@ -4717,17 +4717,17 @@ simplify_filename (filename)
else {
/* Copy this component and trailing /, if any. */
while ((*to++ = *from++) != '/') {
- if (!to[-1]) {
- /* Trim . component at end of nonempty name. */
- to -= filename <= to - 3 && to[-3] == '/' && to[-2] == '.';
+ if (!to[-1]) {
+ /* Trim . component at end of nonempty name. */
+ to -= filename <= to - 3 && to[-3] == '/' && to[-2] == '.';
- /* Trim unnecessary trailing /s. */
- while (to0 < --to && to[-1] == '/')
- continue;
+ /* Trim unnecessary trailing /s. */
+ while (to0 < --to && to[-1] == '/')
+ continue;
- *to = 0;
- return to - filename;
- }
+ *to = 0;
+ return to - filename;
+ }
}
}
@@ -4771,15 +4771,15 @@ read_filename_string (ch, f)
{
*set++ = ch;
while ((ch = getc (f)) != EOF && ! is_space[ch])
- {
- if (set - alloc == len)
- {
- len *= 2;
- alloc = xrealloc (alloc, len + 1);
- set = alloc + len / 2;
- }
- *set++ = ch;
- }
+ {
+ if (set - alloc == len)
+ {
+ len *= 2;
+ alloc = xrealloc (alloc, len + 1);
+ set = alloc + len / 2;
+ }
+ *set++ = ch;
+ }
}
*set = '\0';
ungetc (ch, f);
@@ -4814,7 +4814,7 @@ read_name_map (dirname)
return map_list_ptr->map_list_map;
map_list_ptr = ((struct file_name_map_list *)
- xmalloc (sizeof (struct file_name_map_list)));
+ xmalloc (sizeof (struct file_name_map_list)));
map_list_ptr->map_list_name = savestring (dirname);
map_list_ptr->map_list_map = NULL;
@@ -4830,43 +4830,43 @@ read_name_map (dirname)
int ch;
while ((ch = getc (f)) != EOF)
- {
- char *from, *to;
- struct file_name_map *ptr;
- size_t tolen;
-
- if (is_space[ch])
- continue;
- from = read_filename_string (ch, f);
- while ((ch = getc (f)) != EOF && is_hor_space[ch])
- ;
- to = read_filename_string (ch, f);
-
- simplify_filename (from);
- tolen = simplify_filename (to);
-
- ptr = ((struct file_name_map *)
- xmalloc (sizeof (struct file_name_map)));
- ptr->map_from = from;
-
- /* Make the real filename absolute. */
- if (absolute_filename (to))
- ptr->map_to = to;
- else
- {
- ptr->map_to = xmalloc (dirlen + tolen + 1);
- strcpy (ptr->map_to, dirname);
- strcat (ptr->map_to, to);
- free (to);
- }
-
- ptr->map_next = map_list_ptr->map_list_map;
- map_list_ptr->map_list_map = ptr;
-
- while ((ch = getc (f)) != '\n')
- if (ch == EOF)
- break;
- }
+ {
+ char *from, *to;
+ struct file_name_map *ptr;
+ size_t tolen;
+
+ if (is_space[ch])
+ continue;
+ from = read_filename_string (ch, f);
+ while ((ch = getc (f)) != EOF && is_hor_space[ch])
+ ;
+ to = read_filename_string (ch, f);
+
+ simplify_filename (from);
+ tolen = simplify_filename (to);
+
+ ptr = ((struct file_name_map *)
+ xmalloc (sizeof (struct file_name_map)));
+ ptr->map_from = from;
+
+ /* Make the real filename absolute. */
+ if (absolute_filename (to))
+ ptr->map_to = to;
+ else
+ {
+ ptr->map_to = xmalloc (dirlen + tolen + 1);
+ strcpy (ptr->map_to, dirname);
+ strcat (ptr->map_to, to);
+ free (to);
+ }
+
+ ptr->map_next = map_list_ptr->map_list_map;
+ map_list_ptr->map_list_map = ptr;
+
+ while ((ch = getc (f)) != '\n')
+ if (ch == EOF)
+ break;
+ }
fclose (f);
}
@@ -4898,8 +4898,8 @@ open_include_file (filename, searchptr, importing, pinc)
/* Look up FNAME in include_hashtab. */
struct include_file **phead = &include_hashtab[hashf ((U_CHAR *) fname,
- strlen (fname),
- INCLUDE_HASHSIZE)];
+ strlen (fname),
+ INCLUDE_HASHSIZE)];
struct include_file *inc, *head = *phead;
for (inc = head; inc; inc = inc->next)
if (!strcmp (fname, inc->fname))
@@ -4922,15 +4922,15 @@ open_include_file (filename, searchptr, importing, pinc)
inc->control_macro = 0;
inc->deps_output = 0;
if (fstat (fd, &inc->st) != 0)
- pfatal_with_name (fname);
+ pfatal_with_name (fname);
*phead = inc;
/* Look for another file with the same inode and device. */
if (lookup_ino_include (inc)
- && inc->control_macro
- && (!inc->control_macro[0] || lookup (inc->control_macro, -1, -1))) {
- close (fd);
- fd = -2;
+ && inc->control_macro
+ && (!inc->control_macro[0] || lookup (inc->control_macro, -1, -1))) {
+ close (fd);
+ fd = -2;
}
}
@@ -4966,16 +4966,16 @@ remap_include_file (filename, searchptr)
if (searchptr)
{
if (! searchptr->got_name_map)
- {
- searchptr->name_map = read_name_map (searchptr->fname);
- searchptr->got_name_map = 1;
- }
+ {
+ searchptr->name_map = read_name_map (searchptr->fname);
+ searchptr->got_name_map = 1;
+ }
/* Check the mapping for the directory we are using. */
from = filename + strlen (searchptr->fname);
for (map = searchptr->name_map; map; map = map->map_next)
- if (! strcmp (map->map_from, from))
- return map->map_to;
+ if (! strcmp (map->map_from, from))
+ return map->map_to;
}
from = base_name (filename);
@@ -4983,17 +4983,17 @@ remap_include_file (filename, searchptr)
if (from != filename || !searchptr)
{
/* Try to find a mapping file for the particular directory we are
- looking in. Thus #include <sys/types.h> will look up sys/types.h
- in /usr/include/header.gcc and look up types.h in
- /usr/include/sys/header.gcc. */
+ looking in. Thus #include <sys/types.h> will look up sys/types.h
+ in /usr/include/header.gcc and look up types.h in
+ /usr/include/sys/header.gcc. */
char *dir = (char *) alloca (from - filename + 1);
bcopy (filename, dir, from - filename);
dir[from - filename] = '\0';
for (map = read_name_map (dir); map; map = map->map_next)
- if (! strcmp (map->map_from, from))
- return map->map_to;
+ if (! strcmp (map->map_from, from))
+ return map->map_to;
}
return filename;
@@ -5008,14 +5008,14 @@ lookup_ino_include (inc)
struct include_file *inc;
{
int hash = ((unsigned) (inc->st.st_dev + INO_T_HASH (inc->st.st_ino))
- % INCLUDE_HASHSIZE);
+ % INCLUDE_HASHSIZE);
struct include_file *i = include_ino_hashtab[hash];
inc->next_ino = i;
include_ino_hashtab[hash] = inc;
for (; i; i = i->next_ino)
if (INO_T_EQ (inc->st.st_ino, i->st.st_ino)
- && inc->st.st_dev == i->st.st_dev) {
+ && inc->st.st_dev == i->st.st_dev) {
inc->control_macro = i->control_macro;
return 1;
}
@@ -5041,7 +5041,7 @@ finclude (f, inc, op, system_header_p, dirptr)
{
char *fname = inc->fname;
int i;
- FILE_BUF *fp; /* For input stack frame */
+ FILE_BUF *fp; /* For input stack frame */
int missing_newline = 0;
CHECK_DEPTH (return;);
@@ -5085,10 +5085,10 @@ finclude (f, inc, op, system_header_p, dirptr)
for (;;) {
i = safe_read (f, (char *) fp->buf + st_size, bsize - st_size);
if (i < 0)
- goto nope; /* error! */
+ goto nope; /* error! */
st_size += i;
if (st_size != bsize)
- break; /* End of file */
+ break; /* End of file */
bsize *= 2;
fp->buf = (U_CHAR *) xrealloc (fp->buf, bsize + 2);
}
@@ -5182,11 +5182,11 @@ check_precompiled (pcf, st, fname, limit)
{
size_t s = (size_t) st->st_size;
if (s != st->st_size || s + 2 < s)
- memory_full ();
+ memory_full ();
buf = xmalloc (s + 2);
length = safe_read (pcf, buf, s);
if (length < 0)
- goto nope;
+ goto nope;
}
else
abort ();
@@ -5241,30 +5241,30 @@ check_preconditions (prec)
mdef = create_definition ((U_CHAR *) prec, (U_CHAR *) lineend, NULL_PTR);
if (mdef.defn == 0)
- abort ();
+ abort ();
if ((hp = lookup (mdef.symnam, mdef.symlen, -1)) == NULL
- || (hp->type != T_MACRO && hp->type != T_CONST)
- || (hp->type == T_MACRO
- && !compare_defs (mdef.defn, hp->value.defn)
- && (mdef.defn->length != 2
- || mdef.defn->expansion[0] != '\n'
- || mdef.defn->expansion[1] != ' ')))
- return 0;
+ || (hp->type != T_MACRO && hp->type != T_CONST)
+ || (hp->type == T_MACRO
+ && !compare_defs (mdef.defn, hp->value.defn)
+ && (mdef.defn->length != 2
+ || mdef.defn->expansion[0] != '\n'
+ || mdef.defn->expansion[1] != ' ')))
+ return 0;
} else if (!strncmp (prec, "undef", 5)) {
char *name;
int len;
prec += 5;
while (is_hor_space[(U_CHAR) *prec])
- prec++;
+ prec++;
name = prec;
while (is_idchar[(U_CHAR) *prec])
- prec++;
+ prec++;
len = prec - name;
if (lookup ((U_CHAR *) name, len, -1))
- return 0;
+ return 0;
} else {
error ("Bad format encountered while reading precompiled file");
return 0;
@@ -5319,7 +5319,7 @@ pcfinclude (buf, limit, name, op)
str = (STRINGDEF *) (GENERIC_PTR) cp;
string_start = cp += sizeof (STRINGDEF);
- for (; *cp; cp++) /* skip the string */
+ for (; *cp; cp++) /* skip the string */
;
/* We need to macro expand the string here to ensure that the
@@ -5351,40 +5351,40 @@ pcfinclude (buf, limit, name, op)
else
/* Otherwise, for each key, */
for (; nkeys--; free (tmpbuf.buf), cp = endofthiskey + 1) {
- KEYDEF *kp = (KEYDEF *) (GENERIC_PTR) cp;
- HASHNODE *hp;
-
- /* It starts with a KEYDEF structure */
- cp += sizeof (KEYDEF);
-
- /* Find the end of the key. At the end of this for loop we
- advance CP to the start of the next key using this variable. */
- endofthiskey = cp + strlen ((char *) cp);
- kp->str = str;
-
- /* Expand the key, and enter it into the hash table. */
- tmpbuf = expand_to_temp_buffer (cp, endofthiskey, 0, 0);
- tmpbuf.bufp = tmpbuf.buf;
-
- while (is_hor_space[*tmpbuf.bufp])
- tmpbuf.bufp++;
- if (!is_idstart[*tmpbuf.bufp]
- || tmpbuf.bufp == tmpbuf.buf + tmpbuf.length) {
- str->writeflag = 1;
- continue;
- }
-
- hp = lookup (tmpbuf.bufp, -1, -1);
- if (hp == NULL) {
- kp->chain = 0;
- install (tmpbuf.bufp, -1, T_PCSTRING, (char *) kp, -1);
- }
- else if (hp->type == T_PCSTRING) {
- kp->chain = hp->value.keydef;
- hp->value.keydef = kp;
- }
- else
- str->writeflag = 1;
+ KEYDEF *kp = (KEYDEF *) (GENERIC_PTR) cp;
+ HASHNODE *hp;
+
+ /* It starts with a KEYDEF structure */
+ cp += sizeof (KEYDEF);
+
+ /* Find the end of the key. At the end of this for loop we
+ advance CP to the start of the next key using this variable. */
+ endofthiskey = cp + strlen ((char *) cp);
+ kp->str = str;
+
+ /* Expand the key, and enter it into the hash table. */
+ tmpbuf = expand_to_temp_buffer (cp, endofthiskey, 0, 0);
+ tmpbuf.bufp = tmpbuf.buf;
+
+ while (is_hor_space[*tmpbuf.bufp])
+ tmpbuf.bufp++;
+ if (!is_idstart[*tmpbuf.bufp]
+ || tmpbuf.bufp == tmpbuf.buf + tmpbuf.length) {
+ str->writeflag = 1;
+ continue;
+ }
+
+ hp = lookup (tmpbuf.bufp, -1, -1);
+ if (hp == NULL) {
+ kp->chain = 0;
+ install (tmpbuf.bufp, -1, T_PCSTRING, (char *) kp, -1);
+ }
+ else if (hp->type == T_PCSTRING) {
+ kp->chain = hp->value.keydef;
+ hp->value.keydef = kp;
+ }
+ else
+ str->writeflag = 1;
}
}
/* This output_line_directive serves to switch us back to the current
@@ -5428,27 +5428,27 @@ write_output ()
while (cur_buf_loc < outbuf.bufp || next_string) {
if (next_string
- && cur_buf_loc - outbuf.buf == next_string->output_mark) {
+ && cur_buf_loc - outbuf.buf == next_string->output_mark) {
if (next_string->writeflag) {
- len = 4 * strlen ((char *) next_string->filename) + 32;
- while (len > line_directive_len)
- line_directive = xrealloc (line_directive,
- line_directive_len *= 2);
- sprintf (line_directive, "\n# %d ", next_string->lineno);
- strcpy (quote_string (line_directive + strlen (line_directive),
- (char *) next_string->filename),
- "\n");
- safe_write (fileno (stdout), line_directive, strlen (line_directive));
- safe_write (fileno (stdout),
- (char *) next_string->contents, next_string->len);
- }
+ len = 4 * strlen ((char *) next_string->filename) + 32;
+ while (len > line_directive_len)
+ line_directive = xrealloc (line_directive,
+ line_directive_len *= 2);
+ sprintf (line_directive, "\n# %d ", next_string->lineno);
+ strcpy (quote_string (line_directive + strlen (line_directive),
+ (char *) next_string->filename),
+ "\n");
+ safe_write (fileno (stdout), line_directive, strlen (line_directive));
+ safe_write (fileno (stdout),
+ (char *) next_string->contents, next_string->len);
+ }
next_string = next_string->chain;
}
else {
len = (next_string
- ? (next_string->output_mark
- - (cur_buf_loc - outbuf.buf))
- : outbuf.bufp - cur_buf_loc);
+ ? (next_string->output_mark
+ - (cur_buf_loc - outbuf.buf))
+ : outbuf.bufp - cur_buf_loc);
safe_write (fileno (stdout), (char *) cur_buf_loc, len);
cur_buf_loc += len;
@@ -5513,16 +5513,16 @@ create_definition (buf, limit, op)
U_CHAR *buf, *limit;
FILE_BUF *op;
{
- U_CHAR *bp; /* temp ptr into input buffer */
- U_CHAR *symname; /* remember where symbol name starts */
- int sym_length; /* and how long it is */
+ U_CHAR *bp; /* temp ptr into input buffer */
+ U_CHAR *symname; /* remember where symbol name starts */
+ int sym_length; /* and how long it is */
int line = instack[indepth].lineno;
char *file = instack[indepth].nominal_fname;
int rest_args = 0;
DEFINITION *defn;
- int arglengths = 0; /* Accumulate lengths of arg names
- plus number of args. */
+ int arglengths = 0; /* Accumulate lengths of arg names
+ plus number of args. */
MACRODEF mdef;
bp = buf;
@@ -5530,7 +5530,7 @@ create_definition (buf, limit, op)
while (is_hor_space[*bp])
bp++;
- symname = bp; /* remember where it starts */
+ symname = bp; /* remember where it starts */
sym_length = check_macro_name (bp, "macro");
bp += sym_length;
@@ -5542,7 +5542,7 @@ create_definition (buf, limit, op)
struct arglist *arg_ptrs = NULL;
int argno = 0;
- bp++; /* skip '(' */
+ bp++; /* skip '(' */
SKIP_WHITE_SPACE (bp);
/* Loop over macro argument names. */
@@ -5557,59 +5557,59 @@ create_definition (buf, limit, op)
arg_ptrs = temp;
if (rest_args)
- pedwarn ("another parameter follows `%s'",
- rest_extension);
+ pedwarn ("another parameter follows `%s'",
+ rest_extension);
if (!is_idstart[*bp])
- pedwarn ("invalid character in macro parameter name");
+ pedwarn ("invalid character in macro parameter name");
/* Find the end of the arg name. */
while (is_idchar[*bp]) {
- bp++;
- /* do we have a "special" rest-args extension here? */
- if (limit - bp > REST_EXTENSION_LENGTH
- && bcmp (rest_extension, bp, REST_EXTENSION_LENGTH) == 0) {
- rest_args = 1;
- temp->rest_args = 1;
- break;
- }
+ bp++;
+ /* do we have a "special" rest-args extension here? */
+ if (limit - bp > REST_EXTENSION_LENGTH
+ && bcmp (rest_extension, bp, REST_EXTENSION_LENGTH) == 0) {
+ rest_args = 1;
+ temp->rest_args = 1;
+ break;
+ }
}
temp->length = bp - temp->name;
if (rest_args == 1)
- bp += REST_EXTENSION_LENGTH;
+ bp += REST_EXTENSION_LENGTH;
arglengths += temp->length + 2;
SKIP_WHITE_SPACE (bp);
if (temp->length == 0 || (*bp != ',' && *bp != ')')) {
- error ("badly punctuated parameter list in `#define'");
- goto nope;
+ error ("badly punctuated parameter list in `#define'");
+ goto nope;
}
if (*bp == ',') {
- bp++;
- SKIP_WHITE_SPACE (bp);
- /* A comma at this point can only be followed by an identifier. */
- if (!is_idstart[*bp]) {
- error ("badly punctuated parameter list in `#define'");
- goto nope;
- }
+ bp++;
+ SKIP_WHITE_SPACE (bp);
+ /* A comma at this point can only be followed by an identifier. */
+ if (!is_idstart[*bp]) {
+ error ("badly punctuated parameter list in `#define'");
+ goto nope;
+ }
}
if (bp >= limit) {
- error ("unterminated parameter list in `#define'");
- goto nope;
+ error ("unterminated parameter list in `#define'");
+ goto nope;
}
{
- struct arglist *otemp;
-
- for (otemp = temp->next; otemp != NULL; otemp = otemp->next)
- if (temp->length == otemp->length
- && bcmp (temp->name, otemp->name, temp->length) == 0) {
- error ("duplicate argument name `%.*s' in `#define'",
- temp->length, temp->name);
- goto nope;
- }
+ struct arglist *otemp;
+
+ for (otemp = temp->next; otemp != NULL; otemp = otemp->next)
+ if (temp->length == otemp->length
+ && bcmp (temp->name, otemp->name, temp->length) == 0) {
+ error ("duplicate argument name `%.*s' in `#define'",
+ temp->length, temp->name);
+ goto nope;
+ }
}
}
- ++bp; /* skip paren */
+ ++bp; /* skip paren */
SKIP_WHITE_SPACE (bp);
/* now everything from bp before limit is the definition. */
defn = collect_expansion (bp, limit, argno, arg_ptrs);
@@ -5623,12 +5623,12 @@ create_definition (buf, limit, op)
struct arglist *temp;
int i = 0;
for (temp = arg_ptrs; temp; temp = temp->next) {
- bcopy (temp->name, &defn->args.argnames[i], temp->length);
- i += temp->length;
- if (temp->next != 0) {
- defn->args.argnames[i++] = ',';
- defn->args.argnames[i++] = ' ';
- }
+ bcopy (temp->name, &defn->args.argnames[i], temp->length);
+ i += temp->length;
+ if (temp->next != 0) {
+ defn->args.argnames[i++] = ',';
+ defn->args.argnames[i++] = ' ';
+ }
}
defn->args.argnames[i] = 0;
}
@@ -5637,26 +5637,26 @@ create_definition (buf, limit, op)
if (bp < limit)
{
- if (is_hor_space[*bp]) {
- bp++;
- SKIP_WHITE_SPACE (bp);
- } else if (sym_length) {
- switch (*bp) {
- case '!': case '"': case '#': case '%': case '&': case '\'':
- case ')': case '*': case '+': case ',': case '-': case '.':
- case '/': case ':': case ';': case '<': case '=': case '>':
- case '?': case '[': case '\\': case ']': case '^': case '{':
- case '|': case '}': case '~':
- warning ("missing white space after `#define %.*s'",
- sym_length, symname);
- break;
-
- default:
- pedwarn ("missing white space after `#define %.*s'",
- sym_length, symname);
- break;
- }
- }
+ if (is_hor_space[*bp]) {
+ bp++;
+ SKIP_WHITE_SPACE (bp);
+ } else if (sym_length) {
+ switch (*bp) {
+ case '!': case '"': case '#': case '%': case '&': case '\'':
+ case ')': case '*': case '+': case ',': case '-': case '.':
+ case '/': case ':': case ';': case '<': case '=': case '>':
+ case '?': case '[': case '\\': case ']': case '^': case '{':
+ case '|': case '}': case '~':
+ warning ("missing white space after `#define %.*s'",
+ sym_length, symname);
+ break;
+
+ default:
+ pedwarn ("missing white space after `#define %.*s'",
+ sym_length, symname);
+ break;
+ }
+ }
}
/* Now everything from bp before limit is the definition. */
defn = collect_expansion (bp, limit, -1, NULL_PTR);
@@ -5709,35 +5709,35 @@ do_define (buf, limit, op, keyword)
int ok = 0;
/* Redefining a precompiled key is ok. */
if (hp->type == T_PCSTRING)
- ok = 1;
+ ok = 1;
/* Redefining a macro is ok if the definitions are the same. */
else if (hp->type == T_MACRO)
- ok = ! compare_defs (mdef.defn, hp->value.defn);
+ ok = ! compare_defs (mdef.defn, hp->value.defn);
/* Redefining a constant is ok with -D. */
else if (hp->type == T_CONST)
ok = ! done_initializing;
/* Print the warning if it's not ok. */
if (!ok) {
/* If we are passing through #define and #undef directives, do
- that for this re-definition now. */
+ that for this re-definition now. */
if (debug_output && op)
- pass_thru_directive (buf, limit, op, keyword);
+ pass_thru_directive (buf, limit, op, keyword);
- pedwarn ("`%.*s' redefined", mdef.symlen, mdef.symnam);
- if (hp->type == T_MACRO)
- pedwarn_with_file_and_line (hp->value.defn->file, hp->value.defn->line,
- "this is the location of the previous definition");
+ pedwarn ("`%.*s' redefined", mdef.symlen, mdef.symnam);
+ if (hp->type == T_MACRO)
+ pedwarn_with_file_and_line (hp->value.defn->file, hp->value.defn->line,
+ "this is the location of the previous definition");
}
/* Replace the old definition. */
hp->type = T_MACRO;
hp->value.defn = mdef.defn;
} else {
/* If we are passing through #define and #undef directives, do
- that for this new definition now. */
+ that for this new definition now. */
if (debug_output && op)
- pass_thru_directive (buf, limit, op, keyword);
+ pass_thru_directive (buf, limit, op, keyword);
install (mdef.symnam, mdef.symlen, T_MACRO,
- (char *) mdef.defn, hashcode);
+ (char *) mdef.defn, hashcode);
}
}
@@ -5766,7 +5766,7 @@ check_macro_name (symname, usage)
|| (sym_length == 1 && *symname == 'L' && (*p == '\'' || *p == '"')))
error ("invalid %s name", usage);
else if (!is_idstart[*symname]
- || (sym_length == 7 && ! bcmp (symname, "defined", 7)))
+ || (sym_length == 7 && ! bcmp (symname, "defined", 7)))
error ("invalid %s name `%.*s'", usage, sym_length, symname);
return sym_length;
}
@@ -5790,11 +5790,11 @@ compare_defs (d1, d2)
for (a1 = d1->pattern, a2 = d2->pattern; a1 && a2;
a1 = a1->next, a2 = a2->next) {
if (!((a1->nchars == a2->nchars && ! bcmp (p1, p2, a1->nchars))
- || ! comp_def_part (first, p1, a1->nchars, p2, a2->nchars, 0))
- || a1->argno != a2->argno
- || a1->stringify != a2->stringify
- || a1->raw_before != a2->raw_before
- || a1->raw_after != a2->raw_after)
+ || ! comp_def_part (first, p1, a1->nchars, p2, a2->nchars, 0))
+ || a1->argno != a2->argno
+ || a1->stringify != a2->stringify
+ || a1->raw_before != a2->raw_before
+ || a1->raw_after != a2->raw_after)
return 1;
first = 0;
p1 += a1->nchars;
@@ -5803,7 +5803,7 @@ compare_defs (d1, d2)
if (a1 != a2)
return 1;
if (comp_def_part (first, p1, d1->length - (p1 - d1->expansion),
- p2, d2->length - (p2 - d2->expansion), 1))
+ p2, d2->length - (p2 - d2->expansion), 1))
return 1;
return 0;
}
@@ -5897,7 +5897,7 @@ collect_expansion (buf, end, nargs, arglist)
so this is an upper bound.
The extra 3 are for invented trailing newline-marker and final null. */
maxsize = (sizeof (DEFINITION)
- + (limit - p) + 3);
+ + (limit - p) + 3);
defn = (DEFINITION *) xcalloc (1, maxsize);
defn->nargs = nargs;
@@ -5927,121 +5927,121 @@ collect_expansion (buf, end, nargs, arglist)
expected_delimiter = '\0';
} else
expected_delimiter = c;
- break;
+ break;
case '\\':
- if (p < limit && expected_delimiter) {
- /* In a string, backslash goes through
- and makes next char ordinary. */
- *exp_p++ = *p++;
- }
- break;
+ if (p < limit && expected_delimiter) {
+ /* In a string, backslash goes through
+ and makes next char ordinary. */
+ *exp_p++ = *p++;
+ }
+ break;
case '%':
- if (!expected_delimiter && *p == ':') {
- /* %: is not a digraph if preceded by an odd number of '<'s. */
- U_CHAR *p0 = p - 1;
- while (buf < p0 && p0[-1] == '<')
- p0--;
- if ((p - p0) & 1) {
- /* Treat %:%: as ## and %: as #. */
- if (p[1] == '%' && p[2] == ':') {
- p += 2;
- goto sharp_sharp_token;
- }
- if (nargs >= 0) {
- p++;
- goto sharp_token;
- }
- }
- }
- break;
+ if (!expected_delimiter && *p == ':') {
+ /* %: is not a digraph if preceded by an odd number of '<'s. */
+ U_CHAR *p0 = p - 1;
+ while (buf < p0 && p0[-1] == '<')
+ p0--;
+ if ((p - p0) & 1) {
+ /* Treat %:%: as ## and %: as #. */
+ if (p[1] == '%' && p[2] == ':') {
+ p += 2;
+ goto sharp_sharp_token;
+ }
+ if (nargs >= 0) {
+ p++;
+ goto sharp_token;
+ }
+ }
+ }
+ break;
case '#':
- /* # is ordinary inside a string. */
- if (expected_delimiter)
- break;
- if (*p == '#') {
- sharp_sharp_token:
- /* ##: concatenate preceding and following tokens. */
- /* Take out the first #, discard preceding whitespace. */
- exp_p--;
- while (exp_p > lastp && is_hor_space[exp_p[-1]])
- --exp_p;
- /* Skip the second #. */
- p++;
- concat_sharp_token_type = c;
- if (is_hor_space[*p]) {
- concat_sharp_token_type = c + 1;
- p++;
- SKIP_WHITE_SPACE (p);
- }
- concat = p;
- if (p == limit)
- error ("`##' at end of macro definition");
- } else if (nargs >= 0) {
- /* Single #: stringify following argument ref.
- Don't leave the # in the expansion. */
- sharp_token:
- exp_p--;
- stringify_sharp_token_type = c;
- if (is_hor_space[*p]) {
- stringify_sharp_token_type = c + 1;
- p++;
- SKIP_WHITE_SPACE (p);
- }
- if (! is_idstart[*p] || nargs == 0
- || (*p == 'L' && (p[1] == '\'' || p[1] == '"')))
- error ("`#' operator is not followed by a macro argument name");
- else
- stringify = p;
- }
- break;
+ /* # is ordinary inside a string. */
+ if (expected_delimiter)
+ break;
+ if (*p == '#') {
+ sharp_sharp_token:
+ /* ##: concatenate preceding and following tokens. */
+ /* Take out the first #, discard preceding whitespace. */
+ exp_p--;
+ while (exp_p > lastp && is_hor_space[exp_p[-1]])
+ --exp_p;
+ /* Skip the second #. */
+ p++;
+ concat_sharp_token_type = c;
+ if (is_hor_space[*p]) {
+ concat_sharp_token_type = c + 1;
+ p++;
+ SKIP_WHITE_SPACE (p);
+ }
+ concat = p;
+ if (p == limit)
+ error ("`##' at end of macro definition");
+ } else if (nargs >= 0) {
+ /* Single #: stringify following argument ref.
+ Don't leave the # in the expansion. */
+ sharp_token:
+ exp_p--;
+ stringify_sharp_token_type = c;
+ if (is_hor_space[*p]) {
+ stringify_sharp_token_type = c + 1;
+ p++;
+ SKIP_WHITE_SPACE (p);
+ }
+ if (! is_idstart[*p] || nargs == 0
+ || (*p == 'L' && (p[1] == '\'' || p[1] == '"')))
+ error ("`#' operator is not followed by a macro argument name");
+ else
+ stringify = p;
+ }
+ break;
}
} else {
/* In -traditional mode, recognize arguments inside strings and
- and character constants, and ignore special properties of #.
- Arguments inside strings are considered "stringified", but no
- extra quote marks are supplied. */
+ and character constants, and ignore special properties of #.
+ Arguments inside strings are considered "stringified", but no
+ extra quote marks are supplied. */
switch (c) {
case '\'':
case '\"':
- if (expected_delimiter != '\0') {
- if (c == expected_delimiter)
- expected_delimiter = '\0';
- } else
- expected_delimiter = c;
- break;
+ if (expected_delimiter != '\0') {
+ if (c == expected_delimiter)
+ expected_delimiter = '\0';
+ } else
+ expected_delimiter = c;
+ break;
case '\\':
- /* Backslash quotes delimiters and itself, but not macro args. */
- if (expected_delimiter != 0 && p < limit
- && (*p == expected_delimiter || *p == '\\')) {
- *exp_p++ = *p++;
- continue;
- }
- break;
+ /* Backslash quotes delimiters and itself, but not macro args. */
+ if (expected_delimiter != 0 && p < limit
+ && (*p == expected_delimiter || *p == '\\')) {
+ *exp_p++ = *p++;
+ continue;
+ }
+ break;
case '/':
- if (expected_delimiter != '\0') /* No comments inside strings. */
- break;
- if (*p == '*') {
- /* If we find a comment that wasn't removed by handle_directive,
- this must be -traditional. So replace the comment with
- nothing at all. */
- exp_p--;
- while (++p < limit) {
- if (p[0] == '*' && p[1] == '/') {
- p += 2;
- break;
- }
- }
+ if (expected_delimiter != '\0') /* No comments inside strings. */
+ break;
+ if (*p == '*') {
+ /* If we find a comment that wasn't removed by handle_directive,
+ this must be -traditional. So replace the comment with
+ nothing at all. */
+ exp_p--;
+ while (++p < limit) {
+ if (p[0] == '*' && p[1] == '/') {
+ p += 2;
+ break;
+ }
+ }
#if 0
- /* Mark this as a concatenation-point, as if it had been ##. */
- concat = p;
+ /* Mark this as a concatenation-point, as if it had been ##. */
+ concat = p;
#endif
- }
- break;
+ }
+ break;
}
}
@@ -6055,76 +6055,76 @@ collect_expansion (buf, end, nargs, arglist)
id_len = p - id_beg;
if (is_idstart[c]
- && ! (id_len == 1 && c == 'L' && (*p == '\'' || *p == '"'))) {
- register struct arglist *arg;
-
- for (arg = arglist; arg != NULL; arg = arg->next) {
- struct reflist *tpat;
-
- if (arg->name[0] == c
- && arg->length == id_len
- && bcmp (arg->name, id_beg, id_len) == 0) {
- enum sharp_token_type tpat_stringify;
- if (expected_delimiter) {
- if (warn_stringify) {
- if (traditional) {
- warning ("macro argument `%.*s' is stringified.",
- id_len, arg->name);
- } else {
- warning ("macro arg `%.*s' would be stringified with -traditional.",
- id_len, arg->name);
- }
- }
- /* If ANSI, don't actually substitute inside a string. */
- if (!traditional)
- break;
- tpat_stringify = SHARP_TOKEN;
- } else {
- tpat_stringify
- = (stringify == id_beg
- ? stringify_sharp_token_type : NO_SHARP_TOKEN);
- }
- /* make a pat node for this arg and append it to the end of
- the pat list */
- tpat = (struct reflist *) xmalloc (sizeof (struct reflist));
- tpat->next = NULL;
- tpat->raw_before
- = concat == id_beg ? concat_sharp_token_type : NO_SHARP_TOKEN;
- tpat->raw_after = NO_SHARP_TOKEN;
- tpat->rest_args = arg->rest_args;
- tpat->stringify = tpat_stringify;
-
- if (endpat == NULL)
- defn->pattern = tpat;
- else
- endpat->next = tpat;
- endpat = tpat;
-
- tpat->argno = arg->argno;
- tpat->nchars = exp_p - lastp;
- {
- register U_CHAR *p1 = p;
- SKIP_WHITE_SPACE (p1);
- if (p1[0]=='#'
- ? p1[1]=='#'
- : p1[0]=='%' && p1[1]==':' && p1[2]=='%' && p1[3]==':')
- tpat->raw_after = p1[0] + (p != p1);
- }
- lastp = exp_p; /* place to start copying from next time */
- skipped_arg = 1;
- break;
- }
- }
+ && ! (id_len == 1 && c == 'L' && (*p == '\'' || *p == '"'))) {
+ register struct arglist *arg;
+
+ for (arg = arglist; arg != NULL; arg = arg->next) {
+ struct reflist *tpat;
+
+ if (arg->name[0] == c
+ && arg->length == id_len
+ && bcmp (arg->name, id_beg, id_len) == 0) {
+ enum sharp_token_type tpat_stringify;
+ if (expected_delimiter) {
+ if (warn_stringify) {
+ if (traditional) {
+ warning ("macro argument `%.*s' is stringified.",
+ id_len, arg->name);
+ } else {
+ warning ("macro arg `%.*s' would be stringified with -traditional.",
+ id_len, arg->name);
+ }
+ }
+ /* If ANSI, don't actually substitute inside a string. */
+ if (!traditional)
+ break;
+ tpat_stringify = SHARP_TOKEN;
+ } else {
+ tpat_stringify
+ = (stringify == id_beg
+ ? stringify_sharp_token_type : NO_SHARP_TOKEN);
+ }
+ /* make a pat node for this arg and append it to the end of
+ the pat list */
+ tpat = (struct reflist *) xmalloc (sizeof (struct reflist));
+ tpat->next = NULL;
+ tpat->raw_before
+ = concat == id_beg ? concat_sharp_token_type : NO_SHARP_TOKEN;
+ tpat->raw_after = NO_SHARP_TOKEN;
+ tpat->rest_args = arg->rest_args;
+ tpat->stringify = tpat_stringify;
+
+ if (endpat == NULL)
+ defn->pattern = tpat;
+ else
+ endpat->next = tpat;
+ endpat = tpat;
+
+ tpat->argno = arg->argno;
+ tpat->nchars = exp_p - lastp;
+ {
+ register U_CHAR *p1 = p;
+ SKIP_WHITE_SPACE (p1);
+ if (p1[0]=='#'
+ ? p1[1]=='#'
+ : p1[0]=='%' && p1[1]==':' && p1[2]=='%' && p1[3]==':')
+ tpat->raw_after = p1[0] + (p != p1);
+ }
+ lastp = exp_p; /* place to start copying from next time */
+ skipped_arg = 1;
+ break;
+ }
+ }
}
/* If this was not a macro arg, copy it into the expansion. */
if (! skipped_arg) {
- register U_CHAR *lim1 = p;
- p = id_beg;
- while (p != lim1)
- *exp_p++ = *p++;
- if (stringify == id_beg)
- error ("`#' operator should be followed by a macro argument name");
+ register U_CHAR *lim1 = p;
+ p = id_beg;
+ while (p != lim1)
+ *exp_p++ = *p++;
+ if (stringify == id_beg)
+ error ("`#' operator should be followed by a macro argument name");
}
}
}
@@ -6160,9 +6160,9 @@ do_assert (buf, limit, op, keyword)
FILE_BUF *op;
struct directive *keyword;
{
- U_CHAR *bp; /* temp ptr into input buffer */
- U_CHAR *symname; /* remember where symbol name starts */
- int sym_length; /* and how long it is */
+ U_CHAR *bp; /* temp ptr into input buffer */
+ U_CHAR *symname; /* remember where symbol name starts */
+ int sym_length; /* and how long it is */
struct arglist *tokens = NULL;
if (pedantic && done_initializing && !instack[indepth].system_header_p)
@@ -6173,7 +6173,7 @@ do_assert (buf, limit, op, keyword)
while (is_hor_space[*bp])
bp++;
- symname = bp; /* remember where it starts */
+ symname = bp; /* remember where it starts */
sym_length = check_macro_name (bp, "assertion");
bp += sym_length;
/* #define doesn't do this, but we should. */
@@ -6191,7 +6191,7 @@ do_assert (buf, limit, op, keyword)
{
int error_flag = 0;
- bp++; /* skip '(' */
+ bp++; /* skip '(' */
SKIP_WHITE_SPACE (bp);
tokens = read_token_list (&bp, limit, &error_flag);
@@ -6202,7 +6202,7 @@ do_assert (buf, limit, op, keyword)
return 1;
}
- ++bp; /* skip paren */
+ ++bp; /* skip paren */
SKIP_WHITE_SPACE (bp);
}
@@ -6218,7 +6218,7 @@ do_assert (buf, limit, op, keyword)
hp = assertion_lookup (symname, sym_length, hashcode);
if (hp == NULL) {
if (sym_length == 7 && ! bcmp (symname, "defined", 7))
- error ("`defined' redefined as assertion");
+ error ("`defined' redefined as assertion");
hp = assertion_install (symname, sym_length, hashcode);
}
@@ -6237,9 +6237,9 @@ do_unassert (buf, limit, op, keyword)
FILE_BUF *op;
struct directive *keyword;
{
- U_CHAR *bp; /* temp ptr into input buffer */
- U_CHAR *symname; /* remember where symbol name starts */
- int sym_length; /* and how long it is */
+ U_CHAR *bp; /* temp ptr into input buffer */
+ U_CHAR *symname; /* remember where symbol name starts */
+ int sym_length; /* and how long it is */
struct arglist *tokens = NULL;
int tokens_specified = 0;
@@ -6252,7 +6252,7 @@ do_unassert (buf, limit, op, keyword)
while (is_hor_space[*bp])
bp++;
- symname = bp; /* remember where it starts */
+ symname = bp; /* remember where it starts */
sym_length = check_macro_name (bp, "assertion");
bp += sym_length;
/* #define doesn't do this, but we should. */
@@ -6265,7 +6265,7 @@ do_unassert (buf, limit, op, keyword)
if (*bp == '(') {
int error_flag = 0;
- bp++; /* skip '(' */
+ bp++; /* skip '(' */
SKIP_WHITE_SPACE (bp);
tokens = read_token_list (&bp, limit, &error_flag);
@@ -6278,7 +6278,7 @@ do_unassert (buf, limit, op, keyword)
tokens_specified = 1;
- ++bp; /* skip paren */
+ ++bp; /* skip paren */
SKIP_WHITE_SPACE (bp);
}
@@ -6296,9 +6296,9 @@ do_unassert (buf, limit, op, keyword)
if (! tokens_specified) {
struct tokenlist_list *next;
for (tail = hp->value; tail; tail = next) {
- next = tail->next;
- free_token_list (tail->tokens);
- free (tail);
+ next = tail->next;
+ free_token_list (tail->tokens);
+ free (tail);
}
delete_assertion (hp);
} else {
@@ -6307,18 +6307,18 @@ do_unassert (buf, limit, op, keyword)
tail = hp->value;
prev = 0;
while (tail) {
- struct tokenlist_list *next = tail->next;
- if (compare_token_lists (tail->tokens, tokens)) {
- if (prev)
- prev->next = next;
- else
- hp->value = tail->next;
- free_token_list (tail->tokens);
- free (tail);
- } else {
- prev = tail;
- }
- tail = next;
+ struct tokenlist_list *next = tail->next;
+ if (compare_token_lists (tail->tokens, tokens)) {
+ if (prev)
+ prev->next = next;
+ else
+ hp->value = tail->next;
+ free_token_list (tail->tokens);
+ free (tail);
+ } else {
+ prev = tail;
+ }
+ tail = next;
}
}
}
@@ -6363,7 +6363,7 @@ check_assertion (name, sym_length, tokens_specified, tokens)
while (tail) {
if (compare_token_lists (tail->tokens, tokens))
- return 1;
+ return 1;
tail = tail->next;
}
@@ -6422,14 +6422,14 @@ read_token_list (bpp, limit, error_flag)
} else if (*bp == ')') {
depth--;
if (depth == 0)
- break;
+ break;
bp++;
} else if (*bp == '"' || *bp == '\'')
bp = skip_quoted_string (bp, limit, 0, NULL_PTR, NULL_PTR, &eofp);
else
while (! is_hor_space[*bp] && *bp != '(' && *bp != ')'
- && *bp != '"' && *bp != '\'' && bp != limit)
- bp++;
+ && *bp != '"' && *bp != '\'' && bp != limit)
+ bp++;
temp = (struct arglist *) xmalloc (sizeof (struct arglist));
temp->name = (U_CHAR *) xmalloc (bp - beg + 1);
@@ -6622,24 +6622,24 @@ do_line (buf, limit, op, keyword)
for (;;)
switch ((*p++ = *bp++)) {
case '\0':
- error ("invalid format `#line' directive");
- return 0;
+ error ("invalid format `#line' directive");
+ return 0;
case '\\':
- {
- char *bpc = (char *) bp;
- HOST_WIDE_INT c = parse_escape (&bpc, (HOST_WIDE_INT) (U_CHAR) (-1));
- bp = (U_CHAR *) bpc;
- if (c < 0)
- p--;
- else
- p[-1] = c;
- }
- break;
+ {
+ char *bpc = (char *) bp;
+ HOST_WIDE_INT c = parse_escape (&bpc, (HOST_WIDE_INT) (U_CHAR) (-1));
+ bp = (U_CHAR *) bpc;
+ if (c < 0)
+ p--;
+ else
+ p[-1] = c;
+ }
+ break;
case '\"':
- p[-1] = 0;
- goto fname_done;
+ p[-1] = 0;
+ goto fname_done;
}
fname_done:
fname_length = p - fname;
@@ -6647,44 +6647,44 @@ do_line (buf, limit, op, keyword)
SKIP_WHITE_SPACE (bp);
if (*bp) {
if (pedantic)
- pedwarn ("garbage at end of `#line' directive");
+ pedwarn ("garbage at end of `#line' directive");
if (*bp == '1')
- file_change = enter_file;
+ file_change = enter_file;
else if (*bp == '2')
- file_change = leave_file;
+ file_change = leave_file;
else if (*bp == '3')
- ip->system_header_p = 1;
+ ip->system_header_p = 1;
else if (*bp == '4')
- ip->system_header_p = 2;
+ ip->system_header_p = 2;
else {
- error ("invalid format `#line' directive");
- return 0;
+ error ("invalid format `#line' directive");
+ return 0;
}
bp++;
SKIP_WHITE_SPACE (bp);
if (*bp == '3') {
- ip->system_header_p = 1;
- bp++;
- SKIP_WHITE_SPACE (bp);
+ ip->system_header_p = 1;
+ bp++;
+ SKIP_WHITE_SPACE (bp);
}
if (*bp == '4') {
- ip->system_header_p = 2;
- bp++;
- SKIP_WHITE_SPACE (bp);
+ ip->system_header_p = 2;
+ bp++;
+ SKIP_WHITE_SPACE (bp);
}
if (*bp) {
- error ("invalid format `#line' directive");
- return 0;
+ error ("invalid format `#line' directive");
+ return 0;
}
}
hash_bucket = &fname_table[hashf (fname, fname_length, FNAME_HASHSIZE)];
for (hp = *hash_bucket; hp != NULL; hp = hp->next)
if (hp->length == fname_length &&
- bcmp (hp->value.cpval, fname, fname_length) == 0) {
- ip->nominal_fname = hp->value.cpval;
- break;
+ bcmp (hp->value.cpval, fname, fname_length) == 0) {
+ ip->nominal_fname = hp->value.cpval;
+ break;
}
if (hp == 0) {
/* Didn't find it; cons up a new one. */
@@ -6867,10 +6867,10 @@ do_pragma (buf, limit, op, keyword)
for (h = 0; h < INCLUDE_HASHSIZE; h++) {
struct include_file *inc;
for (inc = include_hashtab[h]; inc; inc = inc->next) {
- if (!strcmp (base_name (inc->fname), (char *) fname)) {
- warning ("`#pragma implementation' for \"%s\" appears after its #include",fname);
- return 0;
- }
+ if (!strcmp (base_name (inc->fname), (char *) fname)) {
+ warning ("`#pragma implementation' for \"%s\" appears after its #include",fname);
+ return 0;
+ }
}
}
}
@@ -6921,8 +6921,8 @@ do_sccs (buf, limit, op, keyword)
/* Handle #if directive by
1) inserting special `defined' keyword into the hash table
- that gets turned into 0 or 1 by special_symbol (thus,
- if the luser has a symbol called `defined' already, it won't
+ that gets turned into 0 or 1 by special_symbol (thus,
+ if the luser has a symbol called `defined' already, it won't
work inside the #if directive)
2) rescan the input into a temporary output buffer
3) pass the output buffer to the yacc parser and collect a value
@@ -6964,8 +6964,8 @@ do_elif (buf, limit, op, keyword)
error ("`#elif' after `#else'");
fprintf (stderr, " (matches line %d", if_stack->lineno);
if (if_stack->fname != NULL && ip->fname != NULL
- && strcmp (if_stack->fname, ip->nominal_fname) != 0)
- fprintf (stderr, ", file %s", if_stack->fname);
+ && strcmp (if_stack->fname, ip->nominal_fname) != 0)
+ fprintf (stderr, ", file %s", if_stack->fname);
fprintf (stderr, ")\n");
}
if_stack->type = T_ELIF;
@@ -6978,7 +6978,7 @@ do_elif (buf, limit, op, keyword)
if (value == 0)
skip_if_group (ip, 0, op);
else {
- ++if_stack->if_succeeded; /* continue processing input */
+ ++if_stack->if_succeeded; /* continue processing input */
output_line_directive (ip, op, 1, same_file);
}
}
@@ -6998,15 +6998,15 @@ eval_if_expression (buf, length)
HOST_WIDE_INT value;
save_defined = install ((U_CHAR *) "defined", -1, T_SPEC_DEFINED,
- NULL_PTR, -1);
+ NULL_PTR, -1);
pcp_inside_if = 1;
temp_obuf = expand_to_temp_buffer (buf, buf + length, 0, 1);
pcp_inside_if = 0;
- delete_macro (save_defined); /* clean up special symbol */
+ delete_macro (save_defined); /* clean up special symbol */
temp_obuf.buf[temp_obuf.length] = '\n';
value = parse_c_expression ((char *) temp_obuf.buf,
- warn_undef && !instack[indepth].system_header_p);
+ warn_undef && !instack[indepth].system_header_p);
free (temp_obuf.buf);
@@ -7035,20 +7035,20 @@ do_xifdef (buf, limit, op, keyword)
while (p != directive_start) {
U_CHAR c = *p++;
if (is_space[c])
- ;
+ ;
/* Make no special provision for backslash-newline here; this is
- slower if backslash-newlines are present, but it's correct,
- and it's not worth it to tune for the rare backslash-newline. */
+ slower if backslash-newlines are present, but it's correct,
+ and it's not worth it to tune for the rare backslash-newline. */
else if (c == '/'
- && (*p == '*' || (cplusplus_comments && *p == '/'))) {
- /* Skip this comment. */
- int junk = 0;
- U_CHAR *save_bufp = ip->bufp;
- ip->bufp = p + 1;
- p = skip_to_end_of_comment (ip, &junk, 1);
- ip->bufp = save_bufp;
+ && (*p == '*' || (cplusplus_comments && *p == '/'))) {
+ /* Skip this comment. */
+ int junk = 0;
+ U_CHAR *save_bufp = ip->bufp;
+ ip->bufp = p + 1;
+ p = skip_to_end_of_comment (ip, &junk, 1);
+ ip->bufp = save_bufp;
} else {
- goto fail;
+ goto fail;
}
}
/* If we get here, this conditional is the beginning of the file. */
@@ -7067,16 +7067,16 @@ do_xifdef (buf, limit, op, keyword)
skip = (keyword->type == T_IFDEF);
if (! traditional)
pedwarn (end == limit ? "`#%s' with no argument"
- : "`#%s' argument starts with punctuation",
- keyword->name);
+ : "`#%s' argument starts with punctuation",
+ keyword->name);
} else {
HASHNODE *hp;
if (! traditional) {
if (isdigit (buf[0]))
- pedwarn ("`#%s' argument starts with a digit", keyword->name);
+ pedwarn ("`#%s' argument starts with a digit", keyword->name);
else if (end != limit)
- pedwarn ("garbage at end of `#%s' argument", keyword->name);
+ pedwarn ("garbage at end of `#%s' argument", keyword->name);
}
hp = lookup (buf, end-buf, -1);
@@ -7084,15 +7084,15 @@ do_xifdef (buf, limit, op, keyword)
if (pcp_outfile) {
/* Output a precondition for this macro. */
if (hp
- && (hp->type == T_CONST
- || (hp->type == T_MACRO && hp->value.defn->predefined)))
- fprintf (pcp_outfile, "#define %s\n", hp->name);
+ && (hp->type == T_CONST
+ || (hp->type == T_MACRO && hp->value.defn->predefined)))
+ fprintf (pcp_outfile, "#define %s\n", hp->name);
else {
- U_CHAR *cp = buf;
- fprintf (pcp_outfile, "#undef ");
- while (is_idchar[*cp]) /* Ick! */
- fputc (*cp++, pcp_outfile);
- putc ('\n', pcp_outfile);
+ U_CHAR *cp = buf;
+ fprintf (pcp_outfile, "#undef ");
+ while (is_idchar[*cp]) /* Ick! */
+ fputc (*cp++, pcp_outfile);
+ putc ('\n', pcp_outfile);
}
}
@@ -7169,8 +7169,8 @@ skip_if_group (ip, any, op)
if (op->bufp > op->buf && op->bufp[-1] != '\n')
{
- *op->bufp++ = '\n';
- op->lineno++;
+ *op->bufp++ = '\n';
+ op->lineno++;
}
check_expand (op, len);
bcopy (ptr, (char *) op->bufp, len);
@@ -7181,53 +7181,53 @@ skip_if_group (ip, any, op)
while (bp < endb) {
switch (*bp++) {
- case '/': /* possible comment */
+ case '/': /* possible comment */
if (*bp == '\\' && bp[1] == '\n')
- newline_fix (bp);
+ newline_fix (bp);
if (*bp == '*'
- || (cplusplus_comments && *bp == '/')) {
- ip->bufp = ++bp;
- bp = skip_to_end_of_comment (ip, &ip->lineno, 0);
+ || (cplusplus_comments && *bp == '/')) {
+ ip->bufp = ++bp;
+ bp = skip_to_end_of_comment (ip, &ip->lineno, 0);
}
break;
case '<':
if (skipping_include_directive) {
- while (bp < endb && *bp != '>' && *bp != '\n') {
- if (*bp == '\\' && bp[1] == '\n') {
- ip->lineno++;
- bp++;
- }
- bp++;
- }
+ while (bp < endb && *bp != '>' && *bp != '\n') {
+ if (*bp == '\\' && bp[1] == '\n') {
+ ip->lineno++;
+ bp++;
+ }
+ bp++;
+ }
}
break;
case '\"':
if (skipping_include_directive) {
- while (bp < endb && *bp != '\n') {
- if (*bp == '"') {
- bp++;
- break;
- }
- if (*bp == '\\' && bp[1] == '\n') {
- ip->lineno++;
- bp++;
- }
- bp++;
- }
- break;
+ while (bp < endb && *bp != '\n') {
+ if (*bp == '"') {
+ bp++;
+ break;
+ }
+ if (*bp == '\\' && bp[1] == '\n') {
+ ip->lineno++;
+ bp++;
+ }
+ bp++;
+ }
+ break;
}
/* Fall through. */
case '\'':
bp = skip_quoted_string (bp - 1, endb, ip->lineno, &ip->lineno,
- NULL_PTR, NULL_PTR);
+ NULL_PTR, NULL_PTR);
break;
case '\\':
/* Char after backslash loses its special meaning in some cases. */
if (*bp == '\n') {
- ++ip->lineno;
- bp++;
+ ++ip->lineno;
+ bp++;
} else if (traditional && bp < endb)
- bp++;
+ bp++;
break;
case '\n':
++ip->lineno;
@@ -7236,112 +7236,112 @@ skip_if_group (ip, any, op)
break;
case '%':
if (beg_of_line == 0 || traditional)
- break;
+ break;
ip->bufp = bp - 1;
while (bp[0] == '\\' && bp[1] == '\n')
- bp += 2;
+ bp += 2;
if (*bp == ':')
- goto sharp_token;
+ goto sharp_token;
break;
case '#':
/* # keyword: a # must be first nonblank char on the line */
if (beg_of_line == 0)
- break;
+ break;
ip->bufp = bp - 1;
sharp_token:
/* Scan from start of line, skipping whitespace, comments
- and backslash-newlines, and see if we reach this #.
- If not, this # is not special. */
+ and backslash-newlines, and see if we reach this #.
+ If not, this # is not special. */
bp = beg_of_line;
/* If -traditional, require # to be at beginning of line. */
if (!traditional) {
- while (1) {
- if (is_hor_space[*bp])
- bp++;
- else if (*bp == '\\' && bp[1] == '\n')
- bp += 2;
- else if (*bp == '/' && bp[1] == '*') {
- bp += 2;
- while (!(*bp == '*' && bp[1] == '/'))
- bp++;
- bp += 2;
- }
- /* There is no point in trying to deal with C++ // comments here,
- because if there is one, then this # must be part of the
- comment and we would never reach here. */
- else break;
- }
+ while (1) {
+ if (is_hor_space[*bp])
+ bp++;
+ else if (*bp == '\\' && bp[1] == '\n')
+ bp += 2;
+ else if (*bp == '/' && bp[1] == '*') {
+ bp += 2;
+ while (!(*bp == '*' && bp[1] == '/'))
+ bp++;
+ bp += 2;
+ }
+ /* There is no point in trying to deal with C++ // comments here,
+ because if there is one, then this # must be part of the
+ comment and we would never reach here. */
+ else break;
+ }
}
if (bp != ip->bufp) {
- bp = ip->bufp + 1; /* Reset bp to after the #. */
- break;
+ bp = ip->bufp + 1; /* Reset bp to after the #. */
+ break;
}
- bp = ip->bufp + 1; /* Point after the '#' */
+ bp = ip->bufp + 1; /* Point after the '#' */
if (ip->bufp[0] == '%') {
- /* Skip past the ':' again. */
- while (*bp == '\\') {
- ip->lineno++;
- bp += 2;
- }
- bp++;
+ /* Skip past the ':' again. */
+ while (*bp == '\\') {
+ ip->lineno++;
+ bp += 2;
+ }
+ bp++;
}
/* Skip whitespace and \-newline. */
while (1) {
- if (is_hor_space[*bp])
- bp++;
- else if (*bp == '\\' && bp[1] == '\n')
- bp += 2;
- else if (*bp == '/') {
- if (bp[1] == '\\' && bp[2] == '\n')
- newline_fix (bp + 1);
- if (bp[1] == '*') {
- for (bp += 2; ; bp++) {
- if (*bp == '\n')
- ip->lineno++;
- else if (*bp == '*') {
- if (bp[-1] == '/' && warn_comments)
- warning ("`/*' within comment");
- if (bp[1] == '\\' && bp[2] == '\n')
- newline_fix (bp + 1);
- if (bp[1] == '/')
- break;
- }
- }
- bp += 2;
- } else if (bp[1] == '/' && cplusplus_comments) {
- for (bp += 2; ; bp++) {
- if (*bp == '\n') {
- if (bp[-1] != '\\')
- break;
- if (warn_comments)
- warning ("multiline `//' comment");
- ip->lineno++;
- }
- }
- } else
- break;
+ if (is_hor_space[*bp])
+ bp++;
+ else if (*bp == '\\' && bp[1] == '\n')
+ bp += 2;
+ else if (*bp == '/') {
+ if (bp[1] == '\\' && bp[2] == '\n')
+ newline_fix (bp + 1);
+ if (bp[1] == '*') {
+ for (bp += 2; ; bp++) {
+ if (*bp == '\n')
+ ip->lineno++;
+ else if (*bp == '*') {
+ if (bp[-1] == '/' && warn_comments)
+ warning ("`/*' within comment");
+ if (bp[1] == '\\' && bp[2] == '\n')
+ newline_fix (bp + 1);
+ if (bp[1] == '/')
+ break;
+ }
+ }
+ bp += 2;
+ } else if (bp[1] == '/' && cplusplus_comments) {
+ for (bp += 2; ; bp++) {
+ if (*bp == '\n') {
+ if (bp[-1] != '\\')
+ break;
+ if (warn_comments)
+ warning ("multiline `//' comment");
+ ip->lineno++;
+ }
+ }
+ } else
+ break;
} else
- break;
+ break;
}
cp = bp;
/* Now find end of directive name.
- If we encounter a backslash-newline, exchange it with any following
- symbol-constituents so that we end up with a contiguous name. */
+ If we encounter a backslash-newline, exchange it with any following
+ symbol-constituents so that we end up with a contiguous name. */
while (1) {
- if (is_idchar[*bp])
- bp++;
- else {
- if (*bp == '\\' && bp[1] == '\n')
- name_newline_fix (bp);
- if (is_idchar[*bp])
- bp++;
- else break;
- }
+ if (is_idchar[*bp])
+ bp++;
+ else {
+ if (*bp == '\\' && bp[1] == '\n')
+ name_newline_fix (bp);
+ if (is_idchar[*bp])
+ bp++;
+ else break;
+ }
}
ident_length = bp - cp;
ident = cp;
@@ -7350,96 +7350,96 @@ skip_if_group (ip, any, op)
/* A line of just `#' becomes blank. */
if (ident_length == 0 && *after_ident == '\n') {
- continue;
+ continue;
}
if (ident_length == 0 || !is_idstart[*ident]) {
- U_CHAR *p = ident;
- while (is_idchar[*p]) {
- if (*p < '0' || *p > '9')
- break;
- p++;
- }
- /* Handle # followed by a line number. */
- if (p != ident && !is_idchar[*p]) {
- if (pedantic)
- pedwarn ("`#' followed by integer");
- continue;
- }
-
- /* Avoid error for `###' and similar cases unless -pedantic. */
- if (p == ident) {
- while (*p == '#' || is_hor_space[*p]) p++;
- if (*p == '\n') {
- if (pedantic && !lang_asm)
- pedwarn ("invalid preprocessing directive");
- continue;
- }
- }
-
- if (!lang_asm && pedantic)
- pedwarn ("invalid preprocessing directive name");
- continue;
+ U_CHAR *p = ident;
+ while (is_idchar[*p]) {
+ if (*p < '0' || *p > '9')
+ break;
+ p++;
+ }
+ /* Handle # followed by a line number. */
+ if (p != ident && !is_idchar[*p]) {
+ if (pedantic)
+ pedwarn ("`#' followed by integer");
+ continue;
+ }
+
+ /* Avoid error for `###' and similar cases unless -pedantic. */
+ if (p == ident) {
+ while (*p == '#' || is_hor_space[*p]) p++;
+ if (*p == '\n') {
+ if (pedantic && !lang_asm)
+ pedwarn ("invalid preprocessing directive");
+ continue;
+ }
+ }
+
+ if (!lang_asm && pedantic)
+ pedwarn ("invalid preprocessing directive name");
+ continue;
}
for (kt = directive_table; kt->length >= 0; kt++) {
- IF_STACK_FRAME *temp;
- if (ident_length == kt->length
- && bcmp (cp, kt->name, kt->length) == 0) {
- /* If we are asked to return on next directive, do so now. */
- if (any)
- goto done;
-
- switch (kt->type) {
- case T_IF:
- case T_IFDEF:
- case T_IFNDEF:
- temp = (IF_STACK_FRAME *) xcalloc (1, sizeof (IF_STACK_FRAME));
- temp->next = if_stack;
- if_stack = temp;
- temp->lineno = ip->lineno;
- temp->fname = ip->nominal_fname;
- temp->type = kt->type;
- break;
- case T_ELSE:
- case T_ENDIF:
- if (pedantic && if_stack != save_if_stack)
- validate_else (bp, endb);
- case T_ELIF:
- if (if_stack == instack[indepth].if_stack) {
- error ("`#%s' not within a conditional", kt->name);
- break;
- }
- else if (if_stack == save_if_stack)
- goto done; /* found what we came for */
-
- if (kt->type != T_ENDIF) {
- if (if_stack->type == T_ELSE)
- error ("`#else' or `#elif' after `#else'");
- if_stack->type = kt->type;
- break;
- }
-
- temp = if_stack;
- if_stack = if_stack->next;
- free (temp);
- break;
-
- case T_INCLUDE:
- case T_INCLUDE_NEXT:
- case T_IMPORT:
- skipping_include_directive = 1;
- break;
-
- default:
- break;
- }
- break;
- }
+ IF_STACK_FRAME *temp;
+ if (ident_length == kt->length
+ && bcmp (cp, kt->name, kt->length) == 0) {
+ /* If we are asked to return on next directive, do so now. */
+ if (any)
+ goto done;
+
+ switch (kt->type) {
+ case T_IF:
+ case T_IFDEF:
+ case T_IFNDEF:
+ temp = (IF_STACK_FRAME *) xcalloc (1, sizeof (IF_STACK_FRAME));
+ temp->next = if_stack;
+ if_stack = temp;
+ temp->lineno = ip->lineno;
+ temp->fname = ip->nominal_fname;
+ temp->type = kt->type;
+ break;
+ case T_ELSE:
+ case T_ENDIF:
+ if (pedantic && if_stack != save_if_stack)
+ validate_else (bp, endb);
+ case T_ELIF:
+ if (if_stack == instack[indepth].if_stack) {
+ error ("`#%s' not within a conditional", kt->name);
+ break;
+ }
+ else if (if_stack == save_if_stack)
+ goto done; /* found what we came for */
+
+ if (kt->type != T_ENDIF) {
+ if (if_stack->type == T_ELSE)
+ error ("`#else' or `#elif' after `#else'");
+ if_stack->type = kt->type;
+ break;
+ }
+
+ temp = if_stack;
+ if_stack = if_stack->next;
+ free (temp);
+ break;
+
+ case T_INCLUDE:
+ case T_INCLUDE_NEXT:
+ case T_IMPORT:
+ skipping_include_directive = 1;
+ break;
+
+ default:
+ break;
+ }
+ break;
+ }
}
/* Don't let erroneous code go by. */
if (kt->length < 0 && !lang_asm && pedantic)
- pedwarn ("invalid preprocessing directive name");
+ pedwarn ("invalid preprocessing directive name");
}
}
@@ -7455,12 +7455,12 @@ skip_if_group (ip, any, op)
if (op->bufp > op->buf && op->bufp[-1] != '\n')
{
- *op->bufp++ = '\n';
- op->lineno++;
+ *op->bufp++ = '\n';
+ op->lineno++;
}
check_expand (op, beg_of_line - beg_of_group);
bcopy ((char *) beg_of_group, (char *) op->bufp,
- beg_of_line - beg_of_group);
+ beg_of_line - beg_of_group);
op->bufp += beg_of_line - beg_of_group;
op->lineno += ip->lineno - beg_lineno;
check_expand (op, len);
@@ -7501,7 +7501,7 @@ do_else (buf, limit, op, keyword)
error ("`#else' after `#else'");
fprintf (stderr, " (matches line %d", if_stack->lineno);
if (strcmp (if_stack->fname, ip->nominal_fname) != 0)
- fprintf (stderr, ", file %s", if_stack->fname);
+ fprintf (stderr, ", file %s", if_stack->fname);
fprintf (stderr, ")\n");
}
if_stack->type = T_ELSE;
@@ -7510,7 +7510,7 @@ do_else (buf, limit, op, keyword)
if (if_stack->if_succeeded)
skip_if_group (ip, 0, op);
else {
- ++if_stack->if_succeeded; /* continue processing input */
+ ++if_stack->if_succeeded; /* continue processing input */
output_line_directive (ip, op, 1, same_file);
}
return 0;
@@ -7537,37 +7537,37 @@ do_endif (buf, limit, op, keyword)
if_stack = if_stack->next;
if (temp->control_macro != 0) {
/* This #endif matched a #ifndef at the start of the file.
- See if it is at the end of the file. */
+ See if it is at the end of the file. */
FILE_BUF *ip = &instack[indepth];
U_CHAR *p = ip->bufp;
U_CHAR *ep = ip->buf + ip->length;
while (p != ep) {
- U_CHAR c = *p++;
- if (!is_space[c]) {
- if (c == '/'
- && (*p == '*' || (cplusplus_comments && *p == '/'))) {
- /* Skip this comment. */
- int junk = 0;
- U_CHAR *save_bufp = ip->bufp;
- ip->bufp = p + 1;
- p = skip_to_end_of_comment (ip, &junk, 1);
- ip->bufp = save_bufp;
- } else
- goto fail;
- }
+ U_CHAR c = *p++;
+ if (!is_space[c]) {
+ if (c == '/'
+ && (*p == '*' || (cplusplus_comments && *p == '/'))) {
+ /* Skip this comment. */
+ int junk = 0;
+ U_CHAR *save_bufp = ip->bufp;
+ ip->bufp = p + 1;
+ p = skip_to_end_of_comment (ip, &junk, 1);
+ ip->bufp = save_bufp;
+ } else
+ goto fail;
+ }
}
/* If we get here, this #endif ends a #ifndef
- that contains all of the file (aside from whitespace).
- Arrange not to include the file again
- if the macro that was tested is defined.
+ that contains all of the file (aside from whitespace).
+ Arrange not to include the file again
+ if the macro that was tested is defined.
- Do not do this for the top-level file in a -include or any
- file in a -imacros. */
+ Do not do this for the top-level file in a -include or any
+ file in a -imacros. */
if (indepth != 0
- && ! (indepth == 1 && no_record_file)
- && ! (no_record_file && no_output))
- record_control_macro (ip->inc, temp->control_macro);
+ && ! (indepth == 1 && no_record_file)
+ && ! (no_record_file && no_output))
+ record_control_macro (ip->inc, temp->control_macro);
fail: ;
}
free (temp);
@@ -7594,25 +7594,25 @@ validate_else (p, limit)
p++;
else if (*p == '/') {
while (p[1] == '\\' && p[2] == '\n')
- p += 2;
+ p += 2;
if (p[1] == '*') {
- /* Don't bother warning about unterminated comments
- since that will happen later. Just be sure to exit. */
- for (p += 2; ; p++) {
- if (p == limit)
- return;
- if (*p == '*') {
- while (p[1] == '\\' && p[2] == '\n')
- p += 2;
- if (p[1] == '/') {
- p += 2;
- break;
- }
- }
- }
+ /* Don't bother warning about unterminated comments
+ since that will happen later. Just be sure to exit. */
+ for (p += 2; ; p++) {
+ if (p == limit)
+ return;
+ if (*p == '*') {
+ while (p[1] == '\\' && p[2] == '\n')
+ p += 2;
+ if (p[1] == '/') {
+ p += 2;
+ break;
+ }
+ }
+ }
}
else if (cplusplus_comments && p[1] == '/')
- return;
+ return;
else break;
} else break;
}
@@ -7635,7 +7635,7 @@ validate_else (p, limit)
static U_CHAR *
skip_to_end_of_comment (ip, line_counter, nowarn)
register FILE_BUF *ip;
- int *line_counter; /* place to remember newlines, or NULL */
+ int *line_counter; /* place to remember newlines, or NULL */
int nowarn;
{
register U_CHAR *limit = ip->buf + ip->length;
@@ -7643,9 +7643,9 @@ skip_to_end_of_comment (ip, line_counter, nowarn)
FILE_BUF *op = put_out_comments && !line_counter ? &outbuf : (FILE_BUF *) 0;
int start_line = line_counter ? *line_counter : 0;
- /* JF this line_counter stuff is a crock to make sure the
- comment is only put out once, no matter how many times
- the comment is skipped. It almost works */
+ /* JF this line_counter stuff is a crock to make sure the
+ comment is only put out once, no matter how many times
+ the comment is skipped. It almost works */
if (op) {
*op->bufp++ = '/';
*op->bufp++ = bp[-1];
@@ -7653,17 +7653,17 @@ skip_to_end_of_comment (ip, line_counter, nowarn)
if (cplusplus_comments && bp[-1] == '/') {
for (; bp < limit; bp++) {
if (*bp == '\n') {
- if (bp[-1] != '\\')
- break;
- if (!nowarn && warn_comments)
- warning ("multiline `//' comment");
- if (line_counter)
- ++*line_counter;
- if (op)
- ++op->lineno;
+ if (bp[-1] != '\\')
+ break;
+ if (!nowarn && warn_comments)
+ warning ("multiline `//' comment");
+ if (line_counter)
+ ++*line_counter;
+ if (op)
+ ++op->lineno;
}
if (op)
- *op->bufp++ = *bp;
+ *op->bufp++ = *bp;
}
ip->bufp = bp;
return bp;
@@ -7674,29 +7674,29 @@ skip_to_end_of_comment (ip, line_counter, nowarn)
switch (*bp++) {
case '\n':
/* If this is the end of the file, we have an unterminated comment.
- Don't swallow the newline. We are guaranteed that there will be a
- trailing newline and various pieces assume it's there. */
+ Don't swallow the newline. We are guaranteed that there will be a
+ trailing newline and various pieces assume it's there. */
if (bp == limit)
- {
- --bp;
- --limit;
- break;
- }
+ {
+ --bp;
+ --limit;
+ break;
+ }
if (line_counter != NULL)
- ++*line_counter;
+ ++*line_counter;
if (op)
- ++op->lineno;
+ ++op->lineno;
break;
case '*':
if (bp[-2] == '/' && !nowarn && warn_comments)
- warning ("`/*' within comment");
+ warning ("`/*' within comment");
if (*bp == '\\' && bp[1] == '\n')
- newline_fix (bp);
+ newline_fix (bp);
if (*bp == '/') {
if (op)
- *op->bufp++ = '/';
- ip->bufp = ++bp;
- return bp;
+ *op->bufp++ = '/';
+ ip->bufp = ++bp;
+ return bp;
}
break;
}
@@ -7738,54 +7738,54 @@ skip_quoted_string (bp, limit, start_line, count_newlines, backslash_newlines_p,
while (1) {
if (bp >= limit) {
error_with_line (line_for_error (start_line),
- "unterminated string or character constant");
+ "unterminated string or character constant");
error_with_line (multiline_string_line,
- "possible real start of unterminated constant");
+ "possible real start of unterminated constant");
multiline_string_line = 0;
if (eofp)
- *eofp = 1;
+ *eofp = 1;
break;
}
c = *bp++;
if (c == '\\') {
while (*bp == '\\' && bp[1] == '\n') {
- if (backslash_newlines_p)
- *backslash_newlines_p = 1;
- if (count_newlines)
- ++*count_newlines;
- bp += 2;
+ if (backslash_newlines_p)
+ *backslash_newlines_p = 1;
+ if (count_newlines)
+ ++*count_newlines;
+ bp += 2;
}
if (*bp == '\n') {
- if (backslash_newlines_p)
- *backslash_newlines_p = 1;
- if (count_newlines)
- ++*count_newlines;
+ if (backslash_newlines_p)
+ *backslash_newlines_p = 1;
+ if (count_newlines)
+ ++*count_newlines;
}
bp++;
} else if (c == '\n') {
if (traditional) {
- /* Unterminated strings and character constants are 'valid'. */
- bp--; /* Don't consume the newline. */
- if (eofp)
- *eofp = 1;
- break;
+ /* Unterminated strings and character constants are 'valid'. */
+ bp--; /* Don't consume the newline. */
+ if (eofp)
+ *eofp = 1;
+ break;
}
if (match == '\'') {
- error_with_line (line_for_error (start_line),
- "unterminated string or character constant");
- bp--;
- if (eofp)
- *eofp = 1;
- break;
+ error_with_line (line_for_error (start_line),
+ "unterminated string or character constant");
+ bp--;
+ if (eofp)
+ *eofp = 1;
+ break;
}
/* If not traditional, then allow newlines inside strings. */
if (count_newlines)
- ++*count_newlines;
+ ++*count_newlines;
if (multiline_string_line == 0) {
- if (pedantic)
- pedwarn_with_line (line_for_error (start_line),
- "string constant runs past end of line");
- multiline_string_line = start_line;
+ if (pedantic)
+ pedwarn_with_line (line_for_error (start_line),
+ "string constant runs past end of line");
+ multiline_string_line = start_line;
}
} else if (c == match)
break;
@@ -7808,24 +7808,24 @@ quote_string (dst, src)
{
default:
if (isprint (c))
- *dst++ = c;
- else
- {
- sprintf (dst, "\\%03o", c);
- dst += 4;
- }
- break;
+ *dst++ = c;
+ else
+ {
+ sprintf (dst, "\\%03o", c);
+ dst += 4;
+ }
+ break;
case '\"':
case '\\':
- *dst++ = '\\';
- *dst++ = c;
- break;
+ *dst++ = '\\';
+ *dst++ = c;
+ break;
case '\0':
- *dst++ = '\"';
- *dst = '\0';
- return dst;
+ *dst++ = '\"';
+ *dst = '\0';
+ return dst;
}
}
@@ -7854,23 +7854,23 @@ skip_paren_group (ip)
case ')':
depth--;
if (depth == 0)
- return ip->bufp = p;
+ return ip->bufp = p;
break;
case '/':
if (*p == '*') {
- ip->bufp = p;
- p = skip_to_end_of_comment (ip, &lines_dummy, 0);
- p = ip->bufp;
+ ip->bufp = p;
+ p = skip_to_end_of_comment (ip, &lines_dummy, 0);
+ p = ip->bufp;
}
case '"':
case '\'':
{
- int eofp = 0;
- p = skip_quoted_string (p - 1, limit, 0, NULL_PTR, NULL_PTR, &eofp);
- if (eofp)
- return ip->bufp = p;
+ int eofp = 0;
+ p = skip_quoted_string (p - 1, limit, 0, NULL_PTR, NULL_PTR, &eofp);
+ if (eofp)
+ return ip->bufp = p;
}
break;
}
@@ -7911,8 +7911,8 @@ output_line_directive (ip, op, conditional, file_change)
if (ip->lineno > op->lineno && ip->lineno < op->lineno + 8) {
check_expand (op, 10);
while (ip->lineno > op->lineno) {
- *op->bufp++ = '\n';
- op->lineno++;
+ *op->bufp++ = '\n';
+ op->lineno++;
}
return;
}
@@ -7920,7 +7920,7 @@ output_line_directive (ip, op, conditional, file_change)
/* Output a positive line number if possible. */
while (ip->lineno <= 0 && ip->bufp - ip->buf < ip->length
- && *ip->bufp == '\n') {
+ && *ip->bufp == '\n') {
ip->lineno++;
ip->bufp++;
}
@@ -7928,7 +7928,7 @@ output_line_directive (ip, op, conditional, file_change)
line_directive_buf = (char *) alloca (4 * strlen (ip->nominal_fname) + 100);
sprintf (line_directive_buf, "# %d ", ip->lineno);
line_end = quote_string (line_directive_buf + strlen (line_directive_buf),
- ip->nominal_fname);
+ ip->nominal_fname);
if (file_change != same_file) {
*line_end++ = ' ';
*line_end++ = file_change == enter_file ? '1' : '2';
@@ -8022,7 +8022,7 @@ macroexpand (hp, op)
args[i].raw = (U_CHAR *) "";
args[i].expanded = 0;
args[i].raw_length = args[i].expand_length
- = args[i].stringified_length = 0;
+ = args[i].stringified_length = 0;
args[i].free1 = args[i].free2 = 0;
args[i].use_count = 0;
}
@@ -8038,18 +8038,18 @@ macroexpand (hp, op)
/* Discard the open-parenthesis or comma before the next arg. */
++instack[indepth].bufp;
if (rest_args)
- continue;
+ continue;
if (i < nargs || (nargs == 0 && i == 0)) {
- /* If we are working on last arg which absorbs rest of args... */
- if (i == nargs - 1 && defn->rest_args)
- rest_args = 1;
- parse_error = macarg (&args[i], rest_args);
+ /* If we are working on last arg which absorbs rest of args... */
+ if (i == nargs - 1 && defn->rest_args)
+ rest_args = 1;
+ parse_error = macarg (&args[i], rest_args);
}
else
- parse_error = macarg (NULL_PTR, 0);
+ parse_error = macarg (NULL_PTR, 0);
if (parse_error) {
- error_with_line (line_for_error (start_line), parse_error);
- break;
+ error_with_line (line_for_error (start_line), parse_error);
+ break;
}
i++;
} while (*instack[indepth].bufp != ')');
@@ -8059,11 +8059,11 @@ macroexpand (hp, op)
register U_CHAR *bp = args[0].raw;
register U_CHAR *lim = bp + args[0].raw_length;
/* cpp.texi says for foo ( ) we provide one argument.
- However, if foo wants just 0 arguments, treat this as 0. */
+ However, if foo wants just 0 arguments, treat this as 0. */
if (nargs == 0)
- while (bp != lim && is_space[*bp]) bp++;
+ while (bp != lim && is_space[*bp]) bp++;
if (bp == lim)
- i = 0;
+ i = 0;
}
/* Don't output an error message if we have already output one for
@@ -8071,25 +8071,25 @@ macroexpand (hp, op)
rest_zero = 0;
if (nargs == 0 && i > 0) {
if (! parse_error)
- error ("arguments given to macro `%s'", hp->name);
+ error ("arguments given to macro `%s'", hp->name);
} else if (i < nargs) {
/* traditional C allows foo() if foo wants one argument. */
if (nargs == 1 && i == 0 && traditional)
- ;
+ ;
/* the rest args token is allowed to absorb 0 tokens */
else if (i == nargs - 1 && defn->rest_args)
- rest_zero = 1;
+ rest_zero = 1;
else if (parse_error)
- ;
+ ;
else if (i == 0)
- error ("macro `%s' used without args", hp->name);
+ error ("macro `%s' used without args", hp->name);
else if (i == 1)
- error ("macro `%s' used with just one arg", hp->name);
+ error ("macro `%s' used with just one arg", hp->name);
else
- error ("macro `%s' used with only %d args", hp->name, i);
+ error ("macro `%s' used with only %d args", hp->name, i);
} else if (i > nargs) {
if (! parse_error)
- error ("macro `%s' used with too many (%d) args", hp->name, i);
+ error ("macro `%s' used with too many (%d) args", hp->name, i);
}
/* Swallow the closeparen. */
@@ -8102,241 +8102,241 @@ macroexpand (hp, op)
xbuf_len = defn->length;
} else {
register U_CHAR *exp = defn->expansion;
- register int offset; /* offset in expansion,
- copied a piece at a time */
- register int totlen; /* total amount of exp buffer filled so far */
+ register int offset; /* offset in expansion,
+ copied a piece at a time */
+ register int totlen; /* total amount of exp buffer filled so far */
register struct reflist *ap, *last_ap;
/* Macro really takes args. Compute the expansion of this call. */
/* Compute length in characters of the macro's expansion.
- Also count number of times each arg is used. */
+ Also count number of times each arg is used. */
xbuf_len = defn->length;
for (ap = defn->pattern; ap != NULL; ap = ap->next) {
- if (ap->stringify)
- xbuf_len += args[ap->argno].stringified_length;
- else if (ap->raw_before != 0 || ap->raw_after != 0 || traditional)
- /* Add 4 for two newline-space markers to prevent
- token concatenation. */
- xbuf_len += args[ap->argno].raw_length + 4;
- else {
- /* We have an ordinary (expanded) occurrence of the arg.
- So compute its expansion, if we have not already. */
- if (args[ap->argno].expanded == 0) {
- FILE_BUF obuf;
- obuf = expand_to_temp_buffer (args[ap->argno].raw,
- args[ap->argno].raw + args[ap->argno].raw_length,
- 1, 0);
-
- args[ap->argno].expanded = obuf.buf;
- args[ap->argno].expand_length = obuf.length;
- args[ap->argno].free2 = obuf.buf;
- }
-
- /* Add 4 for two newline-space markers to prevent
- token concatenation. */
- xbuf_len += args[ap->argno].expand_length + 4;
- }
- if (args[ap->argno].use_count < 10)
- args[ap->argno].use_count++;
+ if (ap->stringify)
+ xbuf_len += args[ap->argno].stringified_length;
+ else if (ap->raw_before != 0 || ap->raw_after != 0 || traditional)
+ /* Add 4 for two newline-space markers to prevent
+ token concatenation. */
+ xbuf_len += args[ap->argno].raw_length + 4;
+ else {
+ /* We have an ordinary (expanded) occurrence of the arg.
+ So compute its expansion, if we have not already. */
+ if (args[ap->argno].expanded == 0) {
+ FILE_BUF obuf;
+ obuf = expand_to_temp_buffer (args[ap->argno].raw,
+ args[ap->argno].raw + args[ap->argno].raw_length,
+ 1, 0);
+
+ args[ap->argno].expanded = obuf.buf;
+ args[ap->argno].expand_length = obuf.length;
+ args[ap->argno].free2 = obuf.buf;
+ }
+
+ /* Add 4 for two newline-space markers to prevent
+ token concatenation. */
+ xbuf_len += args[ap->argno].expand_length + 4;
+ }
+ if (args[ap->argno].use_count < 10)
+ args[ap->argno].use_count++;
}
xbuf = (U_CHAR *) xmalloc (xbuf_len + 1);
/* Generate in XBUF the complete expansion
- with arguments substituted in.
- TOTLEN is the total size generated so far.
- OFFSET is the index in the definition
- of where we are copying from. */
+ with arguments substituted in.
+ TOTLEN is the total size generated so far.
+ OFFSET is the index in the definition
+ of where we are copying from. */
offset = totlen = 0;
for (last_ap = NULL, ap = defn->pattern; ap != NULL;
- last_ap = ap, ap = ap->next) {
- register struct argdata *arg = &args[ap->argno];
- int count_before = totlen;
-
- /* Add chars to XBUF. */
- for (i = 0; i < ap->nchars; i++, offset++)
- xbuf[totlen++] = exp[offset];
-
- /* If followed by an empty rest arg with concatenation,
- delete the last run of nonwhite chars. */
- if (rest_zero && totlen > count_before
- && ((ap->rest_args && ap->raw_before != 0)
- || (last_ap != NULL && last_ap->rest_args
- && last_ap->raw_after != 0))) {
- /* Delete final whitespace. */
- while (totlen > count_before && is_space[xbuf[totlen - 1]]) {
- totlen--;
- }
-
- /* Delete the nonwhites before them. */
- while (totlen > count_before && ! is_space[xbuf[totlen - 1]]) {
- totlen--;
- }
- }
-
- if (ap->stringify != 0) {
- int arglen = arg->raw_length;
- int escaped = 0;
- int in_string = 0;
- int c;
- i = 0;
- while (i < arglen
- && (c = arg->raw[i], is_space[c]))
- i++;
- while (i < arglen
- && (c = arg->raw[arglen - 1], is_space[c]))
- arglen--;
- if (!traditional)
- xbuf[totlen++] = '\"'; /* insert beginning quote */
- for (; i < arglen; i++) {
- c = arg->raw[i];
-
- if (! in_string) {
- /* Special markers Newline Space
- generate nothing for a stringified argument. */
- if (c == '\n' && arg->raw[i+1] != '\n') {
- i++;
- continue;
- }
-
- /* Internal sequences of whitespace are replaced by one space
- except within an string or char token. */
- if (c == '\n' ? arg->raw[i+1] == '\n' : is_space[c]) {
- while (1) {
- /* Note that Newline Space does occur within whitespace
- sequences; consider it part of the sequence. */
- if (c == '\n' && is_space[arg->raw[i+1]])
- i += 2;
- else if (c != '\n' && is_space[c])
- i++;
- else break;
- c = arg->raw[i];
- }
- i--;
- c = ' ';
- }
- }
-
- if (escaped)
- escaped = 0;
- else {
- if (c == '\\')
- escaped = 1;
- if (in_string) {
- if (c == in_string)
- in_string = 0;
- } else if (c == '\"' || c == '\'')
- in_string = c;
- }
-
- /* Escape these chars */
- if (c == '\"' || (in_string && c == '\\'))
- xbuf[totlen++] = '\\';
- /* We used to output e.g. \008 for control characters here,
- but this doesn't conform to the C Standard.
- Just output the characters as-is. */
- xbuf[totlen++] = c;
- }
- if (!traditional)
- xbuf[totlen++] = '\"'; /* insert ending quote */
- } else if (ap->raw_before != 0 || ap->raw_after != 0 || traditional) {
- U_CHAR *p1 = arg->raw;
- U_CHAR *l1 = p1 + arg->raw_length;
- if (ap->raw_before != 0) {
- while (p1 != l1 && is_space[*p1]) p1++;
- while (p1 != l1 && is_idchar[*p1])
- xbuf[totlen++] = *p1++;
- /* Delete any no-reexpansion marker that follows
- an identifier at the beginning of the argument
- if the argument is concatenated with what precedes it. */
- if (p1[0] == '\n' && p1[1] == '-')
- p1 += 2;
- } else if (!traditional) {
- /* Ordinary expanded use of the argument.
- Put in newline-space markers to prevent token pasting. */
- xbuf[totlen++] = '\n';
- xbuf[totlen++] = ' ';
- }
- if (ap->raw_after != 0) {
- /* Arg is concatenated after: delete trailing whitespace,
- whitespace markers, and no-reexpansion markers. */
- while (p1 != l1) {
- if (is_space[l1[-1]]) l1--;
- else if (l1[-1] == '-') {
- U_CHAR *p2 = l1 - 1;
- /* If a `-' is preceded by an odd number of newlines then it
- and the last newline are a no-reexpansion marker. */
- while (p2 != p1 && p2[-1] == '\n') p2--;
- if ((l1 - 1 - p2) & 1) {
- l1 -= 2;
- }
- else break;
- }
- else break;
- }
- }
-
- bcopy ((char *) p1, (char *) (xbuf + totlen), l1 - p1);
- totlen += l1 - p1;
- if (!traditional && ap->raw_after == 0) {
- /* Ordinary expanded use of the argument.
- Put in newline-space markers to prevent token pasting. */
- xbuf[totlen++] = '\n';
- xbuf[totlen++] = ' ';
- }
- } else {
- /* Ordinary expanded use of the argument.
- Put in newline-space markers to prevent token pasting. */
- if (!traditional) {
- xbuf[totlen++] = '\n';
- xbuf[totlen++] = ' ';
- }
- bcopy ((char *) arg->expanded, (char *) (xbuf + totlen),
- arg->expand_length);
- totlen += arg->expand_length;
- if (!traditional) {
- xbuf[totlen++] = '\n';
- xbuf[totlen++] = ' ';
- }
- /* If a macro argument with newlines is used multiple times,
- then only expand the newlines once. This avoids creating output
- lines which don't correspond to any input line, which confuses
- gdb and gcov. */
- if (arg->use_count > 1 && arg->newlines > 0) {
- /* Don't bother doing change_newlines for subsequent
- uses of arg. */
- arg->use_count = 1;
- arg->expand_length
- = change_newlines (arg->expanded, arg->expand_length);
- }
- }
-
- if (totlen > xbuf_len)
- abort ();
+ last_ap = ap, ap = ap->next) {
+ register struct argdata *arg = &args[ap->argno];
+ int count_before = totlen;
+
+ /* Add chars to XBUF. */
+ for (i = 0; i < ap->nchars; i++, offset++)
+ xbuf[totlen++] = exp[offset];
+
+ /* If followed by an empty rest arg with concatenation,
+ delete the last run of nonwhite chars. */
+ if (rest_zero && totlen > count_before
+ && ((ap->rest_args && ap->raw_before != 0)
+ || (last_ap != NULL && last_ap->rest_args
+ && last_ap->raw_after != 0))) {
+ /* Delete final whitespace. */
+ while (totlen > count_before && is_space[xbuf[totlen - 1]]) {
+ totlen--;
+ }
+
+ /* Delete the nonwhites before them. */
+ while (totlen > count_before && ! is_space[xbuf[totlen - 1]]) {
+ totlen--;
+ }
+ }
+
+ if (ap->stringify != 0) {
+ int arglen = arg->raw_length;
+ int escaped = 0;
+ int in_string = 0;
+ int c;
+ i = 0;
+ while (i < arglen
+ && (c = arg->raw[i], is_space[c]))
+ i++;
+ while (i < arglen
+ && (c = arg->raw[arglen - 1], is_space[c]))
+ arglen--;
+ if (!traditional)
+ xbuf[totlen++] = '\"'; /* insert beginning quote */
+ for (; i < arglen; i++) {
+ c = arg->raw[i];
+
+ if (! in_string) {
+ /* Special markers Newline Space
+ generate nothing for a stringified argument. */
+ if (c == '\n' && arg->raw[i+1] != '\n') {
+ i++;
+ continue;
+ }
+
+ /* Internal sequences of whitespace are replaced by one space
+ except within an string or char token. */
+ if (c == '\n' ? arg->raw[i+1] == '\n' : is_space[c]) {
+ while (1) {
+ /* Note that Newline Space does occur within whitespace
+ sequences; consider it part of the sequence. */
+ if (c == '\n' && is_space[arg->raw[i+1]])
+ i += 2;
+ else if (c != '\n' && is_space[c])
+ i++;
+ else break;
+ c = arg->raw[i];
+ }
+ i--;
+ c = ' ';
+ }
+ }
+
+ if (escaped)
+ escaped = 0;
+ else {
+ if (c == '\\')
+ escaped = 1;
+ if (in_string) {
+ if (c == in_string)
+ in_string = 0;
+ } else if (c == '\"' || c == '\'')
+ in_string = c;
+ }
+
+ /* Escape these chars */
+ if (c == '\"' || (in_string && c == '\\'))
+ xbuf[totlen++] = '\\';
+ /* We used to output e.g. \008 for control characters here,
+ but this doesn't conform to the C Standard.
+ Just output the characters as-is. */
+ xbuf[totlen++] = c;
+ }
+ if (!traditional)
+ xbuf[totlen++] = '\"'; /* insert ending quote */
+ } else if (ap->raw_before != 0 || ap->raw_after != 0 || traditional) {
+ U_CHAR *p1 = arg->raw;
+ U_CHAR *l1 = p1 + arg->raw_length;
+ if (ap->raw_before != 0) {
+ while (p1 != l1 && is_space[*p1]) p1++;
+ while (p1 != l1 && is_idchar[*p1])
+ xbuf[totlen++] = *p1++;
+ /* Delete any no-reexpansion marker that follows
+ an identifier at the beginning of the argument
+ if the argument is concatenated with what precedes it. */
+ if (p1[0] == '\n' && p1[1] == '-')
+ p1 += 2;
+ } else if (!traditional) {
+ /* Ordinary expanded use of the argument.
+ Put in newline-space markers to prevent token pasting. */
+ xbuf[totlen++] = '\n';
+ xbuf[totlen++] = ' ';
+ }
+ if (ap->raw_after != 0) {
+ /* Arg is concatenated after: delete trailing whitespace,
+ whitespace markers, and no-reexpansion markers. */
+ while (p1 != l1) {
+ if (is_space[l1[-1]]) l1--;
+ else if (l1[-1] == '-') {
+ U_CHAR *p2 = l1 - 1;
+ /* If a `-' is preceded by an odd number of newlines then it
+ and the last newline are a no-reexpansion marker. */
+ while (p2 != p1 && p2[-1] == '\n') p2--;
+ if ((l1 - 1 - p2) & 1) {
+ l1 -= 2;
+ }
+ else break;
+ }
+ else break;
+ }
+ }
+
+ bcopy ((char *) p1, (char *) (xbuf + totlen), l1 - p1);
+ totlen += l1 - p1;
+ if (!traditional && ap->raw_after == 0) {
+ /* Ordinary expanded use of the argument.
+ Put in newline-space markers to prevent token pasting. */
+ xbuf[totlen++] = '\n';
+ xbuf[totlen++] = ' ';
+ }
+ } else {
+ /* Ordinary expanded use of the argument.
+ Put in newline-space markers to prevent token pasting. */
+ if (!traditional) {
+ xbuf[totlen++] = '\n';
+ xbuf[totlen++] = ' ';
+ }
+ bcopy ((char *) arg->expanded, (char *) (xbuf + totlen),
+ arg->expand_length);
+ totlen += arg->expand_length;
+ if (!traditional) {
+ xbuf[totlen++] = '\n';
+ xbuf[totlen++] = ' ';
+ }
+ /* If a macro argument with newlines is used multiple times,
+ then only expand the newlines once. This avoids creating output
+ lines which don't correspond to any input line, which confuses
+ gdb and gcov. */
+ if (arg->use_count > 1 && arg->newlines > 0) {
+ /* Don't bother doing change_newlines for subsequent
+ uses of arg. */
+ arg->use_count = 1;
+ arg->expand_length
+ = change_newlines (arg->expanded, arg->expand_length);
+ }
+ }
+
+ if (totlen > xbuf_len)
+ abort ();
}
/* If there is anything left of the definition after handling
- the arg list, copy that in too. */
+ the arg list, copy that in too. */
for (i = offset; i < defn->length; i++) {
- /* if we've reached the end of the macro */
- if (exp[i] == ')')
- rest_zero = 0;
- if (! (rest_zero && last_ap != NULL && last_ap->rest_args
- && last_ap->raw_after != 0))
- xbuf[totlen++] = exp[i];
+ /* if we've reached the end of the macro */
+ if (exp[i] == ')')
+ rest_zero = 0;
+ if (! (rest_zero && last_ap != NULL && last_ap->rest_args
+ && last_ap->raw_after != 0))
+ xbuf[totlen++] = exp[i];
}
xbuf[totlen] = 0;
xbuf_len = totlen;
for (i = 0; i < nargs; i++) {
- if (args[i].free1 != 0)
- free (args[i].free1);
- if (args[i].free2 != 0)
- free (args[i].free2);
+ if (args[i].free1 != 0)
+ free (args[i].free1);
+ if (args[i].free2 != 0)
+ free (args[i].free2);
}
}
} else {
@@ -8392,7 +8392,7 @@ macarg (argptr, rest_args)
/* Try to parse as much of the argument as exists at this
input stack level. */
U_CHAR *bp = macarg1 (ip->bufp, ip->buf + ip->length, ip->macro,
- &paren, &newlines, &comments, rest_args);
+ &paren, &newlines, &comments, rest_args);
/* If we find the end of the argument at this level,
set up *ARGPTR to point at it in the input stack. */
@@ -8420,23 +8420,23 @@ macarg (argptr, rest_args)
while (bp == ip->buf + ip->length) {
if (instack[indepth].macro == 0) {
- result = "unterminated macro call";
- break;
+ result = "unterminated macro call";
+ break;
}
ip->macro->type = T_MACRO;
if (ip->free_ptr)
- free (ip->free_ptr);
+ free (ip->free_ptr);
ip = &instack[--indepth];
newlines = 0;
comments = 0;
bp = macarg1 (ip->bufp, ip->buf + ip->length, ip->macro, &paren,
- &newlines, &comments, rest_args);
+ &newlines, &comments, rest_args);
final_start = bufsize;
bufsize += bp - ip->bufp;
extra += newlines;
buffer = (U_CHAR *) xrealloc (buffer, bufsize + extra + 1);
bcopy ((char *) ip->bufp, (char *) (buffer + bufsize - (bp - ip->bufp)),
- bp - ip->bufp);
+ bp - ip->bufp);
ip->bufp = bp;
ip->lineno += newlines;
}
@@ -8452,14 +8452,14 @@ macarg (argptr, rest_args)
argptr->free1 = buffer;
argptr->newlines = newlines;
if ((newlines || comments) && ip->fname != 0)
- argptr->raw_length
- = final_start +
- discard_comments (argptr->raw + final_start,
- argptr->raw_length - final_start,
- newlines);
+ argptr->raw_length
+ = final_start +
+ discard_comments (argptr->raw + final_start,
+ argptr->raw_length - final_start,
+ newlines);
argptr->raw[argptr->raw_length] = 0;
if (argptr->raw_length > bufsize + extra)
- abort ();
+ abort ();
}
}
@@ -8478,20 +8478,20 @@ macarg (argptr, rest_args)
buf++;
while (buf != lim && is_space[lim[-1]])
lim--;
- totlen = traditional ? 0 : 2; /* Count opening and closing quote. */
+ totlen = traditional ? 0 : 2; /* Count opening and closing quote. */
while (buf != lim) {
register U_CHAR c = *buf++;
totlen++;
/* Internal sequences of whitespace are replaced by one space
- in most cases, but not always. So count all the whitespace
- in case we need to keep it all. */
+ in most cases, but not always. So count all the whitespace
+ in case we need to keep it all. */
#if 0
if (is_space[c])
- SKIP_ALL_WHITE_SPACE (buf);
+ SKIP_ALL_WHITE_SPACE (buf);
else
#endif
if (c == '\"' || c == '\\') /* escape these chars */
- totlen++;
+ totlen++;
}
argptr->stringified_length = totlen;
}
@@ -8529,77 +8529,77 @@ macarg1 (start, limit, macro, depthptr, newlines, comments, rest_args)
break;
case ')':
if (--(*depthptr) < 0)
- return bp;
+ return bp;
break;
case '\\':
/* Traditionally, backslash makes following char not special. */
if (traditional && bp + 1 < limit && bp[1] != '\n')
- bp++;
+ bp++;
break;
case '\n':
++*newlines;
break;
case '/':
if (macro)
- break;
+ break;
if (bp[1] == '\\' && bp[2] == '\n')
- newline_fix (bp + 1);
+ newline_fix (bp + 1);
if (bp[1] == '*') {
- *comments = 1;
- for (bp += 2; bp < limit; bp++) {
- if (*bp == '\n')
- ++*newlines;
- else if (*bp == '*') {
- if (bp[-1] == '/' && warn_comments)
- warning ("`/*' within comment");
- if (bp[1] == '\\' && bp[2] == '\n')
- newline_fix (bp + 1);
- if (bp[1] == '/') {
- bp++;
- break;
- }
- }
- }
+ *comments = 1;
+ for (bp += 2; bp < limit; bp++) {
+ if (*bp == '\n')
+ ++*newlines;
+ else if (*bp == '*') {
+ if (bp[-1] == '/' && warn_comments)
+ warning ("`/*' within comment");
+ if (bp[1] == '\\' && bp[2] == '\n')
+ newline_fix (bp + 1);
+ if (bp[1] == '/') {
+ bp++;
+ break;
+ }
+ }
+ }
} else if (bp[1] == '/' && cplusplus_comments) {
- *comments = 1;
- for (bp += 2; bp < limit; bp++) {
- if (*bp == '\n') {
- ++*newlines;
- if (bp[-1] != '\\')
- break;
- if (warn_comments)
- warning ("multiline `//' comment");
- }
- }
+ *comments = 1;
+ for (bp += 2; bp < limit; bp++) {
+ if (*bp == '\n') {
+ ++*newlines;
+ if (bp[-1] != '\\')
+ break;
+ if (warn_comments)
+ warning ("multiline `//' comment");
+ }
+ }
}
break;
case '\'':
case '\"':
{
- int quotec;
- for (quotec = *bp++; bp + 1 < limit && *bp != quotec; bp++) {
- if (*bp == '\\') {
- bp++;
- if (*bp == '\n')
- ++*newlines;
- if (!macro) {
- while (*bp == '\\' && bp[1] == '\n') {
- bp += 2;
- ++*newlines;
- }
- }
- } else if (*bp == '\n') {
- ++*newlines;
- if (quotec == '\'')
- break;
- }
- }
+ int quotec;
+ for (quotec = *bp++; bp + 1 < limit && *bp != quotec; bp++) {
+ if (*bp == '\\') {
+ bp++;
+ if (*bp == '\n')
+ ++*newlines;
+ if (!macro) {
+ while (*bp == '\\' && bp[1] == '\n') {
+ bp += 2;
+ ++*newlines;
+ }
+ }
+ } else if (*bp == '\n') {
+ ++*newlines;
+ if (quotec == '\'')
+ break;
+ }
+ }
}
break;
case ',':
/* if we've returned to lowest level and we aren't absorbing all args */
if ((*depthptr) == 0 && rest_args == 0)
- return bp;
+ return bp;
break;
}
bp++;
@@ -8657,68 +8657,68 @@ discard_comments (start, length, newlines)
case '\\':
if (*ibp == '\n') {
- obp--;
- ibp++;
+ obp--;
+ ibp++;
}
break;
case '/':
if (*ibp == '\\' && ibp[1] == '\n')
- newline_fix (ibp);
+ newline_fix (ibp);
/* Delete any comment. */
if (cplusplus_comments && ibp[0] == '/') {
- /* Comments are equivalent to spaces. */
- obp[-1] = ' ';
- ibp++;
- while (ibp < limit && (*ibp != '\n' || ibp[-1] == '\\'))
- ibp++;
- break;
+ /* Comments are equivalent to spaces. */
+ obp[-1] = ' ';
+ ibp++;
+ while (ibp < limit && (*ibp != '\n' || ibp[-1] == '\\'))
+ ibp++;
+ break;
}
if (ibp[0] != '*' || ibp + 1 >= limit)
- break;
+ break;
/* Comments are equivalent to spaces.
- For -traditional, a comment is equivalent to nothing. */
+ For -traditional, a comment is equivalent to nothing. */
if (traditional)
- obp--;
+ obp--;
else
- obp[-1] = ' ';
+ obp[-1] = ' ';
while (++ibp < limit) {
- if (ibp[0] == '*') {
- if (ibp[1] == '\\' && ibp[2] == '\n')
- newline_fix (ibp + 1);
- if (ibp[1] == '/') {
- ibp += 2;
- break;
- }
- }
+ if (ibp[0] == '*') {
+ if (ibp[1] == '\\' && ibp[2] == '\n')
+ newline_fix (ibp + 1);
+ if (ibp[1] == '/') {
+ ibp += 2;
+ break;
+ }
+ }
}
break;
case '\'':
case '\"':
/* Notice and skip strings, so that we don't
- think that comments start inside them,
- and so we don't duplicate newlines in them. */
+ think that comments start inside them,
+ and so we don't duplicate newlines in them. */
{
- int quotec = c;
- while (ibp < limit) {
- *obp++ = c = *ibp++;
- if (c == quotec)
- break;
- if (c == '\n' && quotec == '\'')
- break;
- if (c == '\\') {
- if (ibp < limit && *ibp == '\n') {
- ibp++;
- obp--;
- } else {
- while (*ibp == '\\' && ibp[1] == '\n')
- ibp += 2;
- if (ibp < limit)
- *obp++ = *ibp++;
- }
- }
- }
+ int quotec = c;
+ while (ibp < limit) {
+ *obp++ = c = *ibp++;
+ if (c == quotec)
+ break;
+ if (c == '\n' && quotec == '\'')
+ break;
+ if (c == '\\') {
+ if (ibp < limit && *ibp == '\n') {
+ ibp++;
+ obp--;
+ } else {
+ while (*ibp == '\\' && ibp[1] == '\n')
+ ibp += 2;
+ if (ibp < limit)
+ *obp++ = *ibp++;
+ }
+ }
+ }
}
break;
}
@@ -8750,28 +8750,28 @@ change_newlines (start, length)
switch (c) {
case '\n':
/* If this is a NEWLINE NEWLINE, then this is a real newline in the
- string. Skip past the newline and its duplicate.
- Put a space in the output. */
+ string. Skip past the newline and its duplicate.
+ Put a space in the output. */
if (*ibp == '\n')
- {
- ibp++;
- obp--;
- *obp++ = ' ';
- }
+ {
+ ibp++;
+ obp--;
+ *obp++ = ' ';
+ }
break;
case '\'':
case '\"':
/* Notice and skip strings, so that we don't delete newlines in them. */
{
- int quotec = c;
- while (ibp < limit) {
- *obp++ = c = *ibp++;
- if (c == quotec && ibp[-2] != '\\')
- break;
- if (c == '\n' && quotec == '\'')
- break;
- }
+ int quotec = c;
+ while (ibp < limit) {
+ *obp++ = c = *ibp++;
+ if (c == quotec && ibp[-2] != '\\')
+ break;
+ if (c == '\n' && quotec == '\'')
+ break;
+ }
}
break;
}
@@ -8795,7 +8795,7 @@ my_strerror (errnum)
#else
result = strerror (errnum);
#endif
-#else /* VMS */
+#else /* VMS */
/* VAXCRTL's strerror() takes an optional second argument, which only
matters when the first argument is EVMSERR. However, it's simplest
just to pass it unconditionally. `vaxc$errno' is declared in
@@ -9096,10 +9096,10 @@ print_containing_files ()
if (instack[i].fname != NULL) {
ip = &instack[i];
if (first) {
- first = 0;
- fprintf (stderr, "In file included");
+ first = 0;
+ fprintf (stderr, "In file included");
} else {
- fprintf (stderr, ",\n ");
+ fprintf (stderr, ",\n ");
}
fprintf (stderr, " from %s:%d", ip->nominal_fname, ip->lineno);
@@ -9363,7 +9363,7 @@ dump_single_macro (hp, of)
for (i = 0; i < defn->nargs; i++) {
dump_arg_n (defn, i, of);
if (i + 1 < defn->nargs)
- fprintf (of, ", ");
+ fprintf (of, ", ");
}
fprintf (of, ")");
}
@@ -9377,35 +9377,35 @@ dump_single_macro (hp, of)
offset += ap->nchars;
if (!traditional) {
if (ap->nchars != 0)
- concat = 0;
+ concat = 0;
if (ap->stringify) {
- switch (ap->stringify) {
- case SHARP_TOKEN: fprintf (of, "#"); break;
- case WHITE_SHARP_TOKEN: fprintf (of, "# "); break;
- case PERCENT_COLON_TOKEN: fprintf (of, "%%:"); break;
- case WHITE_PERCENT_COLON_TOKEN: fprintf (of, "%%: "); break;
- default: abort ();
- }
+ switch (ap->stringify) {
+ case SHARP_TOKEN: fprintf (of, "#"); break;
+ case WHITE_SHARP_TOKEN: fprintf (of, "# "); break;
+ case PERCENT_COLON_TOKEN: fprintf (of, "%%:"); break;
+ case WHITE_PERCENT_COLON_TOKEN: fprintf (of, "%%: "); break;
+ default: abort ();
+ }
}
if (ap->raw_before != 0) {
- if (concat) {
- switch (ap->raw_before) {
- case WHITE_SHARP_TOKEN:
- case WHITE_PERCENT_COLON_TOKEN:
- fprintf (of, " ");
- break;
- default:
- break;
- }
- } else {
- switch (ap->raw_before) {
- case SHARP_TOKEN: fprintf (of, "##"); break;
- case WHITE_SHARP_TOKEN: fprintf (of, "## "); break;
- case PERCENT_COLON_TOKEN: fprintf (of, "%%:%%:"); break;
- case WHITE_PERCENT_COLON_TOKEN: fprintf (of, "%%:%%: "); break;
- default: abort ();
- }
- }
+ if (concat) {
+ switch (ap->raw_before) {
+ case WHITE_SHARP_TOKEN:
+ case WHITE_PERCENT_COLON_TOKEN:
+ fprintf (of, " ");
+ break;
+ default:
+ break;
+ }
+ } else {
+ switch (ap->raw_before) {
+ case SHARP_TOKEN: fprintf (of, "##"); break;
+ case WHITE_SHARP_TOKEN: fprintf (of, "## "); break;
+ case PERCENT_COLON_TOKEN: fprintf (of, "%%:%%:"); break;
+ case WHITE_PERCENT_COLON_TOKEN: fprintf (of, "%%:%%: "); break;
+ default: abort ();
+ }
+ }
}
concat = 0;
}
@@ -9437,7 +9437,7 @@ dump_all_macros ()
for (hp = hashtab[bucket]; hp; hp= hp->next) {
if (hp->type == T_MACRO)
- dump_single_macro (hp, stdout);
+ dump_single_macro (hp, stdout);
}
}
}
@@ -9463,14 +9463,14 @@ dump_defn_1 (base, start, length, of)
else {
while (p < limit) {
if (*p == '\"' || *p =='\'') {
- U_CHAR *p1 = skip_quoted_string (p, limit, 0, NULL_PTR,
- NULL_PTR, NULL_PTR);
- fwrite (p, sizeof (*p), p1 - p, of);
- p = p1;
+ U_CHAR *p1 = skip_quoted_string (p, limit, 0, NULL_PTR,
+ NULL_PTR, NULL_PTR);
+ fwrite (p, sizeof (*p), p1 - p, of);
+ p = p1;
} else {
- if (*p != '\n')
- putc (*p, of);
- p++;
+ if (*p != '\n')
+ putc (*p, of);
+ p++;
}
}
}
@@ -9565,11 +9565,11 @@ initialize_builtins (inp, outp)
#endif
install ((U_CHAR *) "__WCHAR_TYPE__", -1, T_WCHAR_TYPE, NULL_PTR, -1);
install ((U_CHAR *) "__USER_LABEL_PREFIX__", -1, T_USER_LABEL_PREFIX_TYPE,
- NULL_PTR, -1);
+ NULL_PTR, -1);
install ((U_CHAR *) "__REGISTER_PREFIX__", -1, T_REGISTER_PREFIX_TYPE,
- NULL_PTR, -1);
+ NULL_PTR, -1);
install ((U_CHAR *) "__IMMEDIATE_PREFIX__", -1, T_IMMEDIATE_PREFIX_TYPE,
- NULL_PTR, -1);
+ NULL_PTR, -1);
install ((U_CHAR *) "__TIME__", -1, T_TIME, NULL_PTR, -1);
if (!traditional) {
install ((U_CHAR *) "__STDC__", -1, T_CONST, "1", -1);
@@ -9590,62 +9590,62 @@ initialize_builtins (inp, outp)
struct tm *timebuf = timestamp ();
sprintf (directive, " __BASE_FILE__ \"%s\"\n",
- instack[0].nominal_fname);
+ instack[0].nominal_fname);
output_line_directive (inp, outp, 0, same_file);
pass_thru_directive (udirective, &udirective[strlen (directive)],
- outp, dp);
+ outp, dp);
sprintf (directive, " __VERSION__ \"%s\"\n", version_string);
output_line_directive (inp, outp, 0, same_file);
pass_thru_directive (udirective, &udirective[strlen (directive)],
- outp, dp);
+ outp, dp);
#ifndef NO_BUILTIN_SIZE_TYPE
sprintf (directive, " __SIZE_TYPE__ %s\n", SIZE_TYPE);
output_line_directive (inp, outp, 0, same_file);
pass_thru_directive (udirective, &udirective[strlen (directive)],
- outp, dp);
+ outp, dp);
#endif
#ifndef NO_BUILTIN_PTRDIFF_TYPE
sprintf (directive, " __PTRDIFF_TYPE__ %s\n", PTRDIFF_TYPE);
output_line_directive (inp, outp, 0, same_file);
pass_thru_directive (udirective, &udirective[strlen (directive)],
- outp, dp);
+ outp, dp);
#endif
sprintf (directive, " __WCHAR_TYPE__ %s\n", wchar_type);
output_line_directive (inp, outp, 0, same_file);
pass_thru_directive (udirective, &udirective[strlen (directive)],
- outp, dp);
+ outp, dp);
sprintf (directive, " __DATE__ \"%s %2d %4d\"\n",
- monthnames[timebuf->tm_mon],
- timebuf->tm_mday, timebuf->tm_year + 1900);
+ monthnames[timebuf->tm_mon],
+ timebuf->tm_mday, timebuf->tm_year + 1900);
output_line_directive (inp, outp, 0, same_file);
pass_thru_directive (udirective, &udirective[strlen (directive)],
- outp, dp);
+ outp, dp);
sprintf (directive, " __TIME__ \"%02d:%02d:%02d\"\n",
- timebuf->tm_hour, timebuf->tm_min, timebuf->tm_sec);
+ timebuf->tm_hour, timebuf->tm_min, timebuf->tm_sec);
output_line_directive (inp, outp, 0, same_file);
pass_thru_directive (udirective, &udirective[strlen (directive)],
- outp, dp);
+ outp, dp);
if (!traditional)
- {
+ {
sprintf (directive, " __STDC__ 1");
output_line_directive (inp, outp, 0, same_file);
pass_thru_directive (udirective, &udirective[strlen (directive)],
- outp, dp);
- }
+ outp, dp);
+ }
if (objc)
- {
+ {
sprintf (directive, " __OBJC__ 1");
output_line_directive (inp, outp, 0, same_file);
pass_thru_directive (udirective, &udirective[strlen (directive)],
- outp, dp);
- }
+ outp, dp);
+ }
}
}
@@ -9676,7 +9676,7 @@ make_definition (str, op)
while (is_idchar[*++p] || *p == ',' || is_hor_space[*p])
;
if (*p++ != ')')
- p = (U_CHAR *) str; /* Error */
+ p = (U_CHAR *) str; /* Error */
}
if (*p == 0) {
buf = (U_CHAR *) alloca (p - buf + 4);
@@ -9697,24 +9697,24 @@ make_definition (str, op)
q = &buf[p - (U_CHAR *) str];
while (*p) {
if (*p == '\"' || *p == '\'') {
- int unterminated = 0;
- U_CHAR *p1 = skip_quoted_string (p, p + strlen ((char *) p), 0,
- NULL_PTR, NULL_PTR, &unterminated);
- if (unterminated)
- return;
- while (p != p1)
- *q++ = *p++;
+ int unterminated = 0;
+ U_CHAR *p1 = skip_quoted_string (p, p + strlen ((char *) p), 0,
+ NULL_PTR, NULL_PTR, &unterminated);
+ if (unterminated)
+ return;
+ while (p != p1)
+ *q++ = *p++;
} else if (*p == '\\' && p[1] == '\n')
- p += 2;
+ p += 2;
/* Change newline chars into newline-markers. */
else if (*p == '\n')
- {
- *q++ = '\n';
- *q++ = '\n';
- p++;
- }
+ {
+ *q++ = '\n';
+ *q++ = '\n';
+ p++;
+ }
else
- *q++ = *p++;
+ *q++ = *p++;
}
*q = 0;
}
@@ -9856,8 +9856,8 @@ new_include_prefix (prev_file_name, component, prefix, name)
{
struct file_name_list *dir
= ((struct file_name_list *)
- xmalloc (sizeof (struct file_name_list)
- + strlen (prefix) + strlen (name) + 2));
+ xmalloc (sizeof (struct file_name_list)
+ + strlen (prefix) + strlen (name) + 2));
size_t len;
strcpy (dir->fname, prefix);
strcat (dir->fname, name);
@@ -9866,9 +9866,9 @@ new_include_prefix (prev_file_name, component, prefix, name)
/* Convert directory name to a prefix. */
if (dir->fname[len - 1] != DIR_SEPARATOR) {
if (len == 1 && dir->fname[len - 1] == '.')
- len = 0;
+ len = 0;
else
- dir->fname[len++] = DIR_SEPARATOR;
+ dir->fname[len++] = DIR_SEPARATOR;
dir->fname[len] = 0;
}
@@ -9876,7 +9876,7 @@ new_include_prefix (prev_file_name, component, prefix, name)
if (prev_file_name && !strcmp (prev_file_name->fname, dir->fname)) {
/* But treat `-Idir -I- -Idir' as `-I- -Idir'. */
if (!first_bracket_include)
- first_bracket_include = prev_file_name;
+ first_bracket_include = prev_file_name;
free (dir);
return 0;
}
@@ -9888,14 +9888,14 @@ new_include_prefix (prev_file_name, component, prefix, name)
of systems that can stat directories. We remove it below. */
if (len != 0)
{
- dir->fname[len] = '.';
- dir->fname[len + 1] = 0;
+ dir->fname[len] = '.';
+ dir->fname[len + 1] = 0;
}
/* Ignore a nonexistent directory. */
if (stat (len ? dir->fname : ".", &dir->st) != 0) {
if (errno != ENOENT && errno != ENOTDIR)
- error_from_errno (dir->fname);
+ error_from_errno (dir->fname);
free (dir);
return 0;
}
@@ -9905,11 +9905,11 @@ new_include_prefix (prev_file_name, component, prefix, name)
/* Ignore a directory whose identity matches the previous one. */
if (prev_file_name
- && INO_T_EQ (prev_file_name->st.st_ino, dir->st.st_ino)
- && prev_file_name->st.st_dev == dir->st.st_dev) {
+ && INO_T_EQ (prev_file_name->st.st_ino, dir->st.st_ino)
+ && prev_file_name->st.st_dev == dir->st.st_dev) {
/* But treat `-Idir -I- -Idir' as `-I- -Idir'. */
if (!first_bracket_include)
- first_bracket_include = prev_file_name;
+ first_bracket_include = prev_file_name;
free (dir);
return 0;
}
@@ -9969,50 +9969,50 @@ quote_string_for_make (dst, src)
{
char c = *p++;
switch (c)
- {
- case '\0':
- case ' ':
- case '\t':
- {
- /* GNU make uses a weird quoting scheme for white space.
- A space or tab preceded by 2N+1 backslashes represents
- N backslashes followed by space; a space or tab
- preceded by 2N backslashes represents N backslashes at
- the end of a file name; and backslashes in other
- contexts should not be doubled. */
- char *q;
- for (q = p - 1; src < q && q[-1] == '\\'; q--)
- {
- if (dst)
- dst[i] = '\\';
- i++;
- }
- }
- if (!c)
- return i;
- if (dst)
- dst[i] = '\\';
- i++;
- goto ordinary_char;
-
- case '$':
- if (dst)
- dst[i] = c;
- i++;
- /* Fall through. This can mishandle things like "$(" but
- there's no easy fix. */
- default:
- ordinary_char:
- /* This can mishandle characters in the string "\0\n%*?[\\~";
- exactly which chars are mishandled depends on the `make' version.
- We know of no portable solution for this;
- even GNU make 3.76.1 doesn't solve the problem entirely.
- (Also, '\0' is mishandled due to our calling conventions.) */
- if (dst)
- dst[i] = c;
- i++;
- break;
- }
+ {
+ case '\0':
+ case ' ':
+ case '\t':
+ {
+ /* GNU make uses a weird quoting scheme for white space.
+ A space or tab preceded by 2N+1 backslashes represents
+ N backslashes followed by space; a space or tab
+ preceded by 2N backslashes represents N backslashes at
+ the end of a file name; and backslashes in other
+ contexts should not be doubled. */
+ char *q;
+ for (q = p - 1; src < q && q[-1] == '\\'; q--)
+ {
+ if (dst)
+ dst[i] = '\\';
+ i++;
+ }
+ }
+ if (!c)
+ return i;
+ if (dst)
+ dst[i] = '\\';
+ i++;
+ goto ordinary_char;
+
+ case '$':
+ if (dst)
+ dst[i] = c;
+ i++;
+ /* Fall through. This can mishandle things like "$(" but
+ there's no easy fix. */
+ default:
+ ordinary_char:
+ /* This can mishandle characters in the string "\0\n%*?[\\~";
+ exactly which chars are mishandled depends on the `make' version.
+ We know of no portable solution for this;
+ even GNU make 3.76.1 doesn't solve the problem entirely.
+ (Also, '\0' is mishandled due to our calling conventions.) */
+ if (dst)
+ dst[i] = c;
+ i++;
+ break;
+ }
}
}
@@ -10190,7 +10190,7 @@ hack_vms_include_specification (fname, vaxc_include)
if (vaxc_include && !index (cp,'.'))
strcat (cp, ".h");
- cp2 = Local; /* initialize */
+ cp2 = Local; /* initialize */
/* We are trying to do a number of things here. First of all, we are
trying to hammer the filenames into a standard format, such that later
@@ -10204,8 +10204,8 @@ hack_vms_include_specification (fname, vaxc_include)
a device name (or a rooted logical). */
/* See if we found that 1st slash */
- if (cp == 0) return; /* Nothing to do!!! */
- if (*cp != '/') return; /* Nothing to do!!! */
+ if (cp == 0) return; /* Nothing to do!!! */
+ if (*cp != '/') return; /* Nothing to do!!! */
/* Point to the UNIX filename part (which needs to be fixed!) */
cp1 = cp+1;
/* If the directory spec is not rooted, we can just copy
@@ -10218,8 +10218,8 @@ hack_vms_include_specification (fname, vaxc_include)
* usual way. Given the default locations for include files in cccp.c,
* we will only use this code if the user specifies alternate locations
* with the /include (-I) switch on the command line. */
- cp -= 1; /* Strip "]" */
- cp1--; /* backspace */
+ cp -= 1; /* Strip "]" */
+ cp1--; /* backspace */
} else {
/*
* The VMS part has a ".]" at the end, and this will not do. Later
@@ -10229,8 +10229,8 @@ hack_vms_include_specification (fname, vaxc_include)
* generation of the 000000 root directory spec (which does not belong here
* in this case).
*/
- cp -= 2; /* Strip ".]" */
- cp1--; }; /* backspace */
+ cp -= 2; /* Strip ".]" */
+ cp1--; }; /* backspace */
} else {
/* We drop in here if there is no VMS style directory specification yet.
@@ -10242,7 +10242,7 @@ hack_vms_include_specification (fname, vaxc_include)
* processing will fill this in, and close the bracket.
*/
if (cp[-1] != ':') *cp2++ = ':'; /* dev not in spec. take first dir */
- *cp2++ = '['; /* Open the directory specification */
+ *cp2++ = '['; /* Open the directory specification */
}
/* at this point we assume that we have the device spec, and (at least
@@ -10262,25 +10262,25 @@ hack_vms_include_specification (fname, vaxc_include)
while (index (cp1, '/') != 0) {
/* If this token is "." we can ignore it */
if ((cp1[0] == '.') && (cp1[1] == '/')) {
- cp1 += 2;
- continue;
+ cp1 += 2;
+ continue;
}
/* Add a subdirectory spec. Do not duplicate "." */
if (cp2[-1] != '.' && cp2[-1] != '[' && cp2[-1] != '<')
- *cp2++ = '.';
+ *cp2++ = '.';
/* If this is ".." then the spec becomes "-" */
if ((cp1[0] == '.') && (cp1[1] == '.') && (cp[2] == '/')) {
- /* Add "-" and skip the ".." */
- *cp2++ = '-';
- cp1 += 3;
- continue;
+ /* Add "-" and skip the ".." */
+ *cp2++ = '-';
+ cp1 += 3;
+ continue;
}
/* Copy the subdirectory */
while (*cp1 != '/') *cp2++= *cp1++;
- cp1++; /* Skip the "/" */
+ cp1++; /* Skip the "/" */
}
/* Close the directory specification */
- if (cp2[-1] == '.') /* no trailing periods */
+ if (cp2[-1] == '.') /* no trailing periods */
cp2--;
*cp2++ = ']';
}
@@ -10306,13 +10306,13 @@ hack_vms_include_specification (fname, vaxc_include)
and return it. */
cp = index (fname, '[');
cp2 = index (fname, ']') + 1;
- strcpy (cp, cp2); /* this gets rid of it */
+ strcpy (cp, cp2); /* this gets rid of it */
}
return;
}
-#endif /* VMS */
+#endif /* VMS */
-#ifdef VMS
+#ifdef VMS
/* The following wrapper functions supply additional arguments to the VMS
I/O routines to optimize performance with file handling. The arguments
@@ -10328,10 +10328,10 @@ VMS_freopen (fname, type, oldfile)
char *type;
FILE *oldfile;
{
-#undef freopen /* Get back the real freopen routine. */
+#undef freopen /* Get back the real freopen routine. */
if (strcmp (type, "w") == 0)
return freopen (fname, type, oldfile,
- "mbc=16", "deq=64", "fop=tef", "shr=nil");
+ "mbc=16", "deq=64", "fop=tef", "shr=nil");
return freopen (fname, type, oldfile, "mbc=16");
}
@@ -10340,7 +10340,7 @@ VMS_fopen (fname, type)
char *fname;
char *type;
{
-#undef fopen /* Get back the real fopen routine. */
+#undef fopen /* Get back the real fopen routine. */
/* The gcc-vms-1.42 distribution's header files prototype fopen with two
fixed arguments, which matches ANSI's specification but not VAXCRTL's
pre-ANSI implementation. This hack circumvents the mismatch problem. */
@@ -10348,7 +10348,7 @@ VMS_fopen (fname, type)
if (*type == 'w')
return (*vmslib_fopen) (fname, type, "mbc=32",
- "deq=64", "fop=tef", "shr=nil");
+ "deq=64", "fop=tef", "shr=nil");
else
return (*vmslib_fopen) (fname, type, "mbc=32");
}
@@ -10359,7 +10359,7 @@ VMS_open (fname, flags, prot)
int flags;
int prot;
{
-#undef open /* Get back the real open routine. */
+#undef open /* Get back the real open routine. */
return open (fname, flags, prot, "mbc=16", "deq=64", "fop=tef");
}
@@ -10381,7 +10381,7 @@ extern unsigned long sys$parse(), sys$search();
bad enough, but then compounding the problem by reporting the reason for
failure as "normal successful completion." */
-#undef fstat /* Get back to the library version. */
+#undef fstat /* Get back to the library version. */
static int
VMS_fstat (fd, statbuf)
@@ -10396,7 +10396,7 @@ VMS_fstat (fd, statbuf)
char nambuf[NAM$C_MAXRSS+1];
if ((fp = fdopen (fd, "r")) != 0 && fgetname (fp, nambuf) != 0)
- result = VMS_stat (nambuf, statbuf);
+ result = VMS_stat (nambuf, statbuf);
/* No fclose(fp) here; that would close(fd) as well. */
}
@@ -10415,7 +10415,7 @@ VMS_stat (name, statbuf)
struct FAB fab;
struct NAM nam;
char exp_nam[NAM$C_MAXRSS+1], /* expanded name buffer for sys$parse */
- res_nam[NAM$C_MAXRSS+1]; /* resultant name buffer for sys$search */
+ res_nam[NAM$C_MAXRSS+1]; /* resultant name buffer for sys$search */
fab = cc$rms_fab;
fab.fab$l_fna = (char *) name;
@@ -10426,17 +10426,17 @@ VMS_stat (name, statbuf)
nam.nam$l_rsa = res_nam, nam.nam$b_rss = sizeof res_nam - 1;
nam.nam$b_nop = NAM$M_PWD | NAM$M_NOCONCEAL;
if (sys$parse (&fab) & 1)
- {
- if (sys$search (&fab) & 1)
- {
- res_nam[nam.nam$b_rsl] = '\0';
- result = stat (res_nam, statbuf);
- }
- /* Clean up searchlist context cached by the system. */
- nam.nam$b_nop = NAM$M_SYNCHK;
- fab.fab$l_fna = 0, fab.fab$b_fns = 0;
- (void) sys$parse (&fab);
- }
+ {
+ if (sys$search (&fab) & 1)
+ {
+ res_nam[nam.nam$b_rsl] = '\0';
+ result = stat (res_nam, statbuf);
+ }
+ /* Clean up searchlist context cached by the system. */
+ nam.nam$b_nop = NAM$M_SYNCHK;
+ fab.fab$l_fna = 0, fab.fab$b_fns = 0;
+ (void) sys$parse (&fab);
+ }
}
return result;
diff --git a/cpp/src/icecpp/gansidecl.h b/cpp/src/icecpp/gansidecl.h
index ad4b66403ba..770386f84a6 100644
--- a/cpp/src/icecpp/gansidecl.h
+++ b/cpp/src/icecpp/gansidecl.h
@@ -22,8 +22,8 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
in binutils and gdb releases.
??? Over time the two should be merged into one. */
-#ifndef ANSIDECL_H
-#define ANSIDECL_H
+#ifndef ANSIDECL_H
+#define ANSIDECL_H
/* Add prototype support. */
#ifndef PROTO
@@ -36,11 +36,11 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#ifndef VPROTO
#ifdef __STDC__
-#define PVPROTO(ARGS) ARGS
+#define PVPROTO(ARGS) ARGS
#define VPROTO(ARGS) ARGS
#define VA_START(va_list,var) va_start(va_list,var)
#else
-#define PVPROTO(ARGS) ()
+#define PVPROTO(ARGS) ()
#define VPROTO(ARGS) (va_alist) va_dcl
#define VA_START(va_list,var) va_start(va_list)
#endif
@@ -66,11 +66,11 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#ifdef __STDC__
-#define PTR void *
+#define PTR void *
#else
-#define PTR char *
+#define PTR char *
#ifndef const
#define const
#endif
diff --git a/cpp/src/icecpp/pcp.h b/cpp/src/icecpp/pcp.h
index 2bced48066b..fabd88dbe7c 100644
--- a/cpp/src/icecpp/pcp.h
+++ b/cpp/src/icecpp/pcp.h
@@ -24,13 +24,13 @@ Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
typedef struct stringdef STRINGDEF;
struct stringdef
{
- U_CHAR *contents; /* String to include */
- int len; /* Its length */
- int writeflag; /* Whether we write this */
- int lineno; /* Linenumber of source file */
- U_CHAR *filename; /* Name of source file */
- STRINGDEF *chain; /* Global list of strings in natural order */
- int output_mark; /* Where in the output this goes */
+ U_CHAR *contents; /* String to include */
+ int len; /* Its length */
+ int writeflag; /* Whether we write this */
+ int lineno; /* Linenumber of source file */
+ U_CHAR *filename; /* Name of source file */
+ STRINGDEF *chain; /* Global list of strings in natural order */
+ int output_mark; /* Where in the output this goes */
};
typedef struct keydef KEYDEF;
diff --git a/cpp/src/icecpp/prefix.c b/cpp/src/icecpp/prefix.c
index bf08496cd4e..5516d376360 100644
--- a/cpp/src/icecpp/prefix.c
+++ b/cpp/src/icecpp/prefix.c
@@ -79,13 +79,13 @@ Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
#include <windows.h>
#endif
-static char *get_key_value PROTO((char *));
-static char *translate_name PROTO((char *));
-static char *concat PVPROTO((char *, ...));
-static char *save_string PROTO((char *, int));
+static char *get_key_value PROTO((char *));
+static char *translate_name PROTO((char *));
+static char *concat PVPROTO((char *, ...));
+static char *save_string PROTO((char *, int));
#ifdef _WIN32
-static char *lookup_key PROTO((char *));
+static char *lookup_key PROTO((char *));
static HKEY reg_key = (HKEY) INVALID_HANDLE_VALUE;
#endif
@@ -158,7 +158,7 @@ concat VPROTO((char *first, ...))
while (arg != 0)
{
while (*arg)
- *end++ = *arg++;
+ *end++ = *arg++;
arg = va_arg (args, char *);
}
*end = '\000';
@@ -197,11 +197,11 @@ lookup_key (key)
if (reg_key == (HKEY) INVALID_HANDLE_VALUE)
{
res = RegOpenKeyExA (HKEY_LOCAL_MACHINE, "SOFTWARE", 0,
- KEY_READ, &reg_key);
+ KEY_READ, &reg_key);
if (res == ERROR_SUCCESS)
- res = RegOpenKeyExA (reg_key, "Free Software Foundation", 0,
- KEY_READ, &reg_key);
+ res = RegOpenKeyExA (reg_key, "Free Software Foundation", 0,
+ KEY_READ, &reg_key);
if (res != ERROR_SUCCESS)
{
@@ -247,9 +247,9 @@ translate_name (name)
for (keylen = 0;
(name[keylen + 1] != 0 && name[keylen + 1] != '/'
#ifdef DIR_SEPARATOR
- && name[keylen + 1] != DIR_SEPARATOR
+ && name[keylen + 1] != DIR_SEPARATOR
#endif
- );
+ );
keylen++)
;
@@ -291,12 +291,12 @@ update_path (path, key)
if (! strncmp (path, PREFIX, strlen (PREFIX)) && key != 0)
{
if (key[0] != '$')
- key = concat ("@", key, NULL_PTR);
+ key = concat ("@", key, NULL_PTR);
path = concat (key, &path[strlen (PREFIX)], NULL_PTR);
while (path[0] == '@' || path[0] == '$')
- path = translate_name (path);
+ path = translate_name (path);
}
#ifdef DIR_SEPARATOR
@@ -307,8 +307,8 @@ update_path (path, key)
path = save_string (path, len);
for (i = 0; i < len; i++)
- if (path[i] == '/')
- path[i] = DIR_SEPARATOR;
+ if (path[i] == '/')
+ path[i] = DIR_SEPARATOR;
}
#endif
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 654838c5217..0f376838af2 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -27,15 +27,15 @@ getDeprecateSymbol(const ContainedPtr& p1, const ContainedPtr& p2)
if(p1->findMetaData("deprecate", deprecateMetadata) ||
(p2 != 0 && p2->findMetaData("deprecate", deprecateMetadata)))
{
- deprecateSymbol = "ICE_DEPRECATED_API ";
+ deprecateSymbol = "ICE_DEPRECATED_API ";
}
return deprecateSymbol;
}
-Slice::Gen::Gen(const string& name, const string& base, const string& headerExtension,
- const string& sourceExtension, const vector<string>& extraHeaders, const string& include,
- const vector<string>& includePaths, const string& dllExport, const string& dir,
- bool imp, bool checksum, bool stream, bool ice) :
+Slice::Gen::Gen(const string& name, const string& base, const string& headerExtension,
+ const string& sourceExtension, const vector<string>& extraHeaders, const string& include,
+ const vector<string>& includePaths, const string& dllExport, const string& dir,
+ bool imp, bool checksum, bool stream, bool ice) :
_base(base),
_headerExtension(headerExtension),
_sourceExtension(sourceExtension),
@@ -50,16 +50,16 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte
{
for(vector<string>::iterator p = _includePaths.begin(); p != _includePaths.end(); ++p)
{
- if(p->length() && (*p)[p->length() - 1] != '/')
- {
- *p += '/';
- }
+ if(p->length() && (*p)[p->length() - 1] != '/')
+ {
+ *p += '/';
+ }
}
string::size_type pos = _base.find_last_of("/\\");
if(pos != string::npos)
{
- _base.erase(0, pos + 1);
+ _base.erase(0, pos + 1);
}
if(_impl)
@@ -113,22 +113,22 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte
string fileC = _base + "." + _sourceExtension;
if(!dir.empty())
{
- fileH = dir + '/' + fileH;
- fileC = dir + '/' + fileC;
+ fileH = dir + '/' + fileH;
+ fileC = dir + '/' + fileC;
}
H.open(fileH.c_str());
if(!H)
{
- cerr << name << ": can't open `" << fileH << "' for writing" << endl;
- return;
+ cerr << name << ": can't open `" << fileH << "' for writing" << endl;
+ return;
}
C.open(fileC.c_str());
if(!C)
{
- cerr << name << ": can't open `" << fileC << "' for writing" << endl;
- return;
+ cerr << name << ": can't open `" << fileC << "' for writing" << endl;
+ return;
}
printHeader(H);
@@ -139,7 +139,7 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte
string s = fileH;
if(_include.size())
{
- s = _include + '/' + s;
+ s = _include + '/' + s;
}
transform(s.begin(), s.end(), s.begin(), ToIfdef());
H << "\n#ifndef __" << s << "__";
@@ -183,7 +183,7 @@ Slice::Gen::generate(const UnitPtr& p)
C << "\n#include <";
if(_include.size())
{
- C << _include << '/';
+ C << _include << '/';
}
C << _base << "." << _headerExtension << ">";
@@ -195,57 +195,57 @@ Slice::Gen::generate(const UnitPtr& p)
if(p->usesProxies())
{
- H << "\n#include <Ice/Proxy.h>";
+ H << "\n#include <Ice/Proxy.h>";
}
if(p->hasNonLocalClassDefs())
{
- H << "\n#include <Ice/Object.h>";
- H << "\n#include <Ice/Outgoing.h>";
- if(p->hasContentsWithMetaData("ami"))
- {
- H << "\n#include <Ice/OutgoingAsync.h>";
- }
- H << "\n#include <Ice/Incoming.h>";
- if(p->hasContentsWithMetaData("amd"))
- {
- H << "\n#include <Ice/IncomingAsync.h>";
- }
- H << "\n#include <Ice/Direct.h>";
+ H << "\n#include <Ice/Object.h>";
+ H << "\n#include <Ice/Outgoing.h>";
+ if(p->hasContentsWithMetaData("ami"))
+ {
+ H << "\n#include <Ice/OutgoingAsync.h>";
+ }
+ H << "\n#include <Ice/Incoming.h>";
+ if(p->hasContentsWithMetaData("amd"))
+ {
+ H << "\n#include <Ice/IncomingAsync.h>";
+ }
+ H << "\n#include <Ice/Direct.h>";
- C << "\n#include <Ice/LocalException.h>";
- C << "\n#include <Ice/ObjectFactory.h>";
+ C << "\n#include <Ice/LocalException.h>";
+ C << "\n#include <Ice/ObjectFactory.h>";
}
if(p->hasNonLocalExceptions())
{
- H << "\n#include <Ice/UserExceptionFactory.h>";
+ H << "\n#include <Ice/UserExceptionFactory.h>";
}
if(p->hasDataOnlyClasses() || p->hasNonLocalExceptions())
{
- H << "\n#include <Ice/FactoryTable.h>";
+ H << "\n#include <Ice/FactoryTable.h>";
}
if(p->usesNonLocals())
{
- C << "\n#include <Ice/BasicStream.h>";
- C << "\n#include <Ice/Object.h>";
+ C << "\n#include <Ice/BasicStream.h>";
+ C << "\n#include <Ice/Object.h>";
}
if(_stream || p->hasNonLocalClassDefs() || p->hasNonLocalExceptions())
{
- H << "\n#include <Ice/StreamF.h>";
+ H << "\n#include <Ice/StreamF.h>";
- if(!p->hasNonLocalClassDefs())
- {
- C << "\n#include <Ice/LocalException.h>";
- }
+ if(!p->hasNonLocalClassDefs())
+ {
+ C << "\n#include <Ice/LocalException.h>";
+ }
- if(_stream)
- {
- C << "\n#include <Ice/Stream.h>";
- }
+ if(_stream)
+ {
+ C << "\n#include <Ice/Stream.h>";
+ }
}
if(_checksum)
@@ -260,7 +260,7 @@ Slice::Gen::generate(const UnitPtr& p)
for(StringList::const_iterator q = includes.begin(); q != includes.end(); ++q)
{
- H << "\n#include <" << changeInclude(*q, _includePaths) << "." << _headerExtension << ">";
+ H << "\n#include <" << changeInclude(*q, _includePaths) << "." << _headerExtension << ">";
}
H << "\n#include <Ice/UndefSysMacros.h>";
@@ -279,7 +279,7 @@ Slice::Gen::generate(const UnitPtr& p)
printDllExportStuff(H, _dllExport);
if(_dllExport.size())
{
- _dllExport += " ";
+ _dllExport += " ";
}
ProxyDeclVisitor proxyDeclVisitor(H, C, _dllExport);
@@ -327,7 +327,7 @@ Slice::Gen::generate(const UnitPtr& p)
}
implH << _base << ".h>";
- writeExtraHeaders(implC);
+ writeExtraHeaders(implC);
implC << "\n#include <";
if(_include.size())
@@ -371,29 +371,29 @@ Slice::Gen::writeExtraHeaders(IceUtil::Output& out)
{
for(vector<string>::const_iterator i = _extraHeaders.begin(); i != _extraHeaders.end(); ++i)
{
- string hdr = *i;
- string guard;
- string::size_type pos = hdr.rfind(',');
- if(pos != string::npos)
- {
- hdr = i->substr(0, pos);
- guard = i->substr(pos + 1);
- }
- if(!guard.empty())
- {
- out << "\n#ifndef " << guard;
- out << "\n#define " << guard;
- }
- out << "\n#include <";
- if(!_include.empty())
- {
- out << _include << '/';
- }
- out << hdr << '>';
- if(!guard.empty())
- {
- out << "\n#endif";
- }
+ string hdr = *i;
+ string guard;
+ string::size_type pos = hdr.rfind(',');
+ if(pos != string::npos)
+ {
+ hdr = i->substr(0, pos);
+ guard = i->substr(pos + 1);
+ }
+ if(!guard.empty())
+ {
+ out << "\n#ifndef " << guard;
+ out << "\n#define " << guard;
+ }
+ out << "\n#include <";
+ if(!_include.empty())
+ {
+ out << _include << '/';
+ }
+ out << hdr << '>';
+ if(!guard.empty())
+ {
+ out << "\n#endif";
+ }
}
}
@@ -418,10 +418,10 @@ Slice::Gen::GlobalIncludeVisitor::visitModuleStart(const ModulePtr& p)
string s = *q;
if(s.find(includePrefix) == 0)
{
- H << nl << "#include <" << s.substr(includePrefix.size()) << ">";
+ H << nl << "#include <" << s.substr(includePrefix.size()) << ">";
}
}
- _finished = true;
+ _finished = true;
}
return false;
@@ -457,32 +457,32 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
{
if(!p->isLocal())
{
- string name = fixKwd(p->name());
- string scope = fixKwd(p->scope());
-
- C << sp << nl << "void";
- C << nl << scope.substr(2) << "__addObject(const " << name << "Ptr& p, ::IceInternal::GCCountMap& c)";
- C << sb;
- C << nl << "p->__addObject(c);";
- C << eb;
-
- C << sp << nl << "bool";
- C << nl << scope.substr(2) << "__usesClasses(const " << name << "Ptr& p)";
- C << sb;
- C << nl << "return p->__usesClasses();";
- C << eb;
-
- C << sp << nl << "void";
- C << nl << scope.substr(2) << "__decRefUnsafe(const " << name << "Ptr& p)";
- C << sb;
- C << nl << "p->__decRefUnsafe();";
- C << eb;
-
- C << sp << nl << "void";
- C << nl << scope.substr(2) << "__clearHandleUnsafe(" << name << "Ptr& p)";
- C << sb;
- C << nl << "p.__clearHandleUnsafe();";
- C << eb;
+ string name = fixKwd(p->name());
+ string scope = fixKwd(p->scope());
+
+ C << sp << nl << "void";
+ C << nl << scope.substr(2) << "__addObject(const " << name << "Ptr& p, ::IceInternal::GCCountMap& c)";
+ C << sb;
+ C << nl << "p->__addObject(c);";
+ C << eb;
+
+ C << sp << nl << "bool";
+ C << nl << scope.substr(2) << "__usesClasses(const " << name << "Ptr& p)";
+ C << sb;
+ C << nl << "return p->__usesClasses();";
+ C << eb;
+
+ C << sp << nl << "void";
+ C << nl << scope.substr(2) << "__decRefUnsafe(const " << name << "Ptr& p)";
+ C << sb;
+ C << nl << "p->__decRefUnsafe();";
+ C << eb;
+
+ C << sp << nl << "void";
+ C << nl << scope.substr(2) << "__clearHandleUnsafe(" << name << "Ptr& p)";
+ C << sb;
+ C << nl << "p.__clearHandleUnsafe();";
+ C << eb;
}
return false;
}
@@ -507,23 +507,23 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- params.push_back(fixKwd((*q)->name()));
+ params.push_back(fixKwd((*q)->name()));
}
for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q)
{
- string typeName = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData());
- allTypes.push_back(typeName);
- allParamDecls.push_back(typeName + " __ice_" + (*q)->name());
+ string typeName = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData());
+ allTypes.push_back(typeName);
+ allParamDecls.push_back(typeName + " __ice_" + (*q)->name());
}
if(base)
{
- DataMemberList baseDataMembers = base->allDataMembers();
- for(q = baseDataMembers.begin(); q != baseDataMembers.end(); ++q)
- {
- baseParams.push_back("__ice_" + (*q)->name());
- }
+ DataMemberList baseDataMembers = base->allDataMembers();
+ for(q = baseDataMembers.begin(); q != baseDataMembers.end(); ++q)
+ {
+ baseParams.push_back("__ice_" + (*q)->name());
+ }
}
H << sp << nl << "class " << _dllExport << name << " : ";
@@ -531,11 +531,11 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
H << "public ";
if(!base)
{
- H << (p->isLocal() ? "::Ice::LocalException" : "::Ice::UserException");
+ H << (p->isLocal() ? "::Ice::LocalException" : "::Ice::UserException");
}
else
{
- H << fixKwd(base->scoped());
+ H << fixKwd(base->scoped());
}
H.restoreIndent();
H << sb;
@@ -547,96 +547,96 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
H << sp << nl << name << spar;
if(p->isLocal())
{
- H << "const char*" << "int";
+ H << "const char*" << "int";
}
H << epar;
if(!p->isLocal())
{
- H << " {}";
+ H << " {}";
}
else
{
- H << ';';
+ H << ';';
}
if(!allTypes.empty())
{
- H << nl;
- if(!p->isLocal() && allTypes.size() == 1)
- {
- H << "explicit ";
- }
- H << name << spar;
- if(p->isLocal())
- {
- H << "const char*" << "int";
- }
- H << allTypes << epar << ';';
+ H << nl;
+ if(!p->isLocal() && allTypes.size() == 1)
+ {
+ H << "explicit ";
+ }
+ H << name << spar;
+ if(p->isLocal())
+ {
+ H << "const char*" << "int";
+ }
+ H << allTypes << epar << ';';
}
H << nl << "virtual ~" << name << "() throw();";
H << sp;
if(p->isLocal())
{
- C << sp << nl << scoped.substr(2) << "::" << name << spar << "const char* __file" << "int __line" << epar
- << " :";
- C.inc();
- emitUpcall(base, "(__file, __line)", true);
- C.dec();
- C << sb;
- C << eb;
+ C << sp << nl << scoped.substr(2) << "::" << name << spar << "const char* __file" << "int __line" << epar
+ << " :";
+ C.inc();
+ emitUpcall(base, "(__file, __line)", true);
+ C.dec();
+ C << sb;
+ C << eb;
}
if(!allTypes.empty())
{
- C << sp << nl;
- C << scoped.substr(2) << "::" << name << spar;
- if(p->isLocal())
- {
- C << "const char* __file" << "int __line";
- }
- C << allParamDecls << epar;
- if(p->isLocal() || !baseParams.empty() || !params.empty())
- {
- C << " :";
- C.inc();
- string upcall;
- if(!allParamDecls.empty())
- {
- upcall = "(";
- if(p->isLocal())
- {
- upcall += "__file, __line";
- }
- for(pi = baseParams.begin(); pi != baseParams.end(); ++pi)
- {
- if(p->isLocal() || pi != baseParams.begin())
- {
- upcall += ", ";
- }
- upcall += *pi;
- }
- upcall += ")";
- }
- if(!params.empty())
- {
- upcall += ",";
- }
- emitUpcall(base, upcall, p->isLocal());
- }
- for(pi = params.begin(); pi != params.end(); ++pi)
- {
- if(pi != params.begin())
- {
- C << ",";
- }
- C << nl << *pi << "(__ice_" << *pi << ')';
- }
- if(p->isLocal() || !baseParams.empty() || !params.empty())
- {
- C.dec();
- }
- C << sb;
- C << eb;
+ C << sp << nl;
+ C << scoped.substr(2) << "::" << name << spar;
+ if(p->isLocal())
+ {
+ C << "const char* __file" << "int __line";
+ }
+ C << allParamDecls << epar;
+ if(p->isLocal() || !baseParams.empty() || !params.empty())
+ {
+ C << " :";
+ C.inc();
+ string upcall;
+ if(!allParamDecls.empty())
+ {
+ upcall = "(";
+ if(p->isLocal())
+ {
+ upcall += "__file, __line";
+ }
+ for(pi = baseParams.begin(); pi != baseParams.end(); ++pi)
+ {
+ if(p->isLocal() || pi != baseParams.begin())
+ {
+ upcall += ", ";
+ }
+ upcall += *pi;
+ }
+ upcall += ")";
+ }
+ if(!params.empty())
+ {
+ upcall += ",";
+ }
+ emitUpcall(base, upcall, p->isLocal());
+ }
+ for(pi = params.begin(); pi != params.end(); ++pi)
+ {
+ if(pi != params.begin())
+ {
+ C << ",";
+ }
+ C << nl << *pi << "(__ice_" << *pi << ')';
+ }
+ if(p->isLocal() || !baseParams.empty() || !params.empty())
+ {
+ C.dec();
+ }
+ C << sb;
+ C << eb;
}
C << sp << nl;
@@ -656,7 +656,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
if(p->isLocal())
{
- H << nl << "virtual void ice_print(::std::ostream&) const;";
+ H << nl << "virtual void ice_print(::std::ostream&) const;";
}
H << nl << "virtual ::Ice::Exception* ice_clone() const;";
@@ -673,11 +673,11 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
if(!p->isLocal())
{
- H << sp << nl << "static const ::IceInternal::UserExceptionFactoryPtr& ice_factory();";
+ H << sp << nl << "static const ::IceInternal::UserExceptionFactoryPtr& ice_factory();";
}
if(!dataMembers.empty())
{
- H << sp;
+ H << sp;
}
return true;
}
@@ -695,65 +695,65 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
if(!p->isLocal())
{
- ExceptionPtr base = p->base();
+ ExceptionPtr base = p->base();
- H << sp << nl << "virtual void __write(::IceInternal::BasicStream*) const;";
- H << nl << "virtual void __read(::IceInternal::BasicStream*, bool);";
+ H << sp << nl << "virtual void __write(::IceInternal::BasicStream*) const;";
+ H << nl << "virtual void __read(::IceInternal::BasicStream*, bool);";
H << sp << nl << "virtual void __write(const ::Ice::OutputStreamPtr&) const;";
H << nl << "virtual void __read(const ::Ice::InputStreamPtr&, bool);";
- C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const";
- C << sb;
- C << nl << "__os->write(::std::string(\"" << p->scoped() << "\"), false);";
- C << nl << "__os->startWriteSlice();";
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), true, "", true, (*q)->getMetaData());
- }
- C << nl << "__os->endWriteSlice();";
- if(base)
- {
- emitUpcall(base, "::__write(__os);");
- }
- C << eb;
-
- C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is, bool __rid)";
- C << sb;
- C << nl << "if(__rid)";
- C << sb;
- C << nl << "::std::string myId;";
- C << nl << "__is->read(myId, false);";
- C << eb;
- C << nl << "__is->startReadSlice();";
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), false, "", true, (*q)->getMetaData());
- }
- C << nl << "__is->endReadSlice();";
- if(base)
- {
- emitUpcall(base, "::__read(__is, true);");
- }
- C << eb;
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const";
+ C << sb;
+ C << nl << "__os->write(::std::string(\"" << p->scoped() << "\"), false);";
+ C << nl << "__os->startWriteSlice();";
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), true, "", true, (*q)->getMetaData());
+ }
+ C << nl << "__os->endWriteSlice();";
+ if(base)
+ {
+ emitUpcall(base, "::__write(__os);");
+ }
+ C << eb;
+
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is, bool __rid)";
+ C << sb;
+ C << nl << "if(__rid)";
+ C << sb;
+ C << nl << "::std::string myId;";
+ C << nl << "__is->read(myId, false);";
+ C << eb;
+ C << nl << "__is->startReadSlice();";
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), false, "", true, (*q)->getMetaData());
+ }
+ C << nl << "__is->endReadSlice();";
+ if(base)
+ {
+ emitUpcall(base, "::__read(__is, true);");
+ }
+ C << eb;
if(_stream)
{
C << sp << nl << "void" << nl << scoped.substr(2)
- << "::__write(const ::Ice::OutputStreamPtr& __outS) const";
+ << "::__write(const ::Ice::OutputStreamPtr& __outS) const";
C << sb;
C << nl << "__outS->writeString(::std::string(\"" << p->scoped() << "\"));";
C << nl << "__outS->startSlice();";
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), true, "", _useWstring,
- (*q)->getMetaData());
- }
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), true, "", _useWstring,
+ (*q)->getMetaData());
+ }
C << nl << "__outS->endSlice();";
- if(base)
- {
- emitUpcall(base, "::__write(__outS);");
- }
+ if(base)
+ {
+ emitUpcall(base, "::__write(__outS);");
+ }
C << eb;
C << sp << nl << "void" << nl << scoped.substr(2)
@@ -764,16 +764,16 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
C << nl << "__inS->readString();";
C << eb;
C << nl << "__inS->startSlice();";
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), false, "", _useWstring,
- (*q)->getMetaData());
- }
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), false, "", _useWstring,
+ (*q)->getMetaData());
+ }
C << nl << "__inS->endSlice();";
- if(base)
- {
- emitUpcall(base, "::__read(__inS, true);");
- }
+ if(base)
+ {
+ emitUpcall(base, "::__read(__inS, true);");
+ }
C << eb;
}
else
@@ -796,76 +796,76 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
C << eb;
}
- if(p->usesClasses())
- {
- if(!base || (base && !base->usesClasses()))
- {
- H << nl << "virtual bool __usesClasses() const;";
-
- C << sp << nl << "bool";
- C << nl << scoped.substr(2) << "::__usesClasses() const";
- C << sb;
- C << nl << "return true;";
- C << eb;
- }
- }
-
- factoryName = "__F" + p->flattenedScope() + p->name();
-
- C << sp << nl << "struct " << factoryName << " : public ::IceInternal::UserExceptionFactory";
- C << sb;
- C << sp << nl << "virtual void";
- C << nl << "createAndThrow()";
- C << sb;
- C << nl << "throw " << scoped << "();";
- C << eb;
- C << eb << ';';
-
- C << sp << nl << "static ::IceInternal::UserExceptionFactoryPtr " << factoryName
- << "__Ptr = new " << factoryName << ';';
-
- C << sp << nl << "const ::IceInternal::UserExceptionFactoryPtr&";
- C << nl << scoped.substr(2) << "::ice_factory()";
- C << sb;
- C << nl << "return " << factoryName << "__Ptr;";
- C << eb;
-
- C << sp << nl << "class " << factoryName << "__Init";
- C << sb;
- C.dec();
- C << nl << "public:";
- C.inc();
- C << sp << nl << factoryName << "__Init()";
- C << sb;
- C << nl << "::IceInternal::factoryTable->addExceptionFactory(\"" << p->scoped() << "\", " << scoped
- << "::ice_factory());";
- C << eb;
- C << sp << nl << "~" << factoryName << "__Init()";
- C << sb;
- C << nl << "::IceInternal::factoryTable->removeExceptionFactory(\"" << p->scoped() << "\");";
- C << eb;
- C << eb << ';';
- C << sp << nl << "static " << factoryName << "__Init "<< factoryName << "__i;";
- C << sp << nl << "#ifdef __APPLE__";
-
- string initfuncname = "__F" + p->flattenedScope() + p->name() + "__initializer";
- C << nl << "extern \"C\" { void " << initfuncname << "() {} }";
- C << nl << "#endif";
+ if(p->usesClasses())
+ {
+ if(!base || (base && !base->usesClasses()))
+ {
+ H << nl << "virtual bool __usesClasses() const;";
+
+ C << sp << nl << "bool";
+ C << nl << scoped.substr(2) << "::__usesClasses() const";
+ C << sb;
+ C << nl << "return true;";
+ C << eb;
+ }
+ }
+
+ factoryName = "__F" + p->flattenedScope() + p->name();
+
+ C << sp << nl << "struct " << factoryName << " : public ::IceInternal::UserExceptionFactory";
+ C << sb;
+ C << sp << nl << "virtual void";
+ C << nl << "createAndThrow()";
+ C << sb;
+ C << nl << "throw " << scoped << "();";
+ C << eb;
+ C << eb << ';';
+
+ C << sp << nl << "static ::IceInternal::UserExceptionFactoryPtr " << factoryName
+ << "__Ptr = new " << factoryName << ';';
+
+ C << sp << nl << "const ::IceInternal::UserExceptionFactoryPtr&";
+ C << nl << scoped.substr(2) << "::ice_factory()";
+ C << sb;
+ C << nl << "return " << factoryName << "__Ptr;";
+ C << eb;
+
+ C << sp << nl << "class " << factoryName << "__Init";
+ C << sb;
+ C.dec();
+ C << nl << "public:";
+ C.inc();
+ C << sp << nl << factoryName << "__Init()";
+ C << sb;
+ C << nl << "::IceInternal::factoryTable->addExceptionFactory(\"" << p->scoped() << "\", " << scoped
+ << "::ice_factory());";
+ C << eb;
+ C << sp << nl << "~" << factoryName << "__Init()";
+ C << sb;
+ C << nl << "::IceInternal::factoryTable->removeExceptionFactory(\"" << p->scoped() << "\");";
+ C << eb;
+ C << eb << ';';
+ C << sp << nl << "static " << factoryName << "__Init "<< factoryName << "__i;";
+ C << sp << nl << "#ifdef __APPLE__";
+
+ string initfuncname = "__F" + p->flattenedScope() + p->name() + "__initializer";
+ C << nl << "extern \"C\" { void " << initfuncname << "() {} }";
+ C << nl << "#endif";
}
H << eb << ';';
if(!p->isLocal())
{
- //
- // We need an instance here to trigger initialization if the implementation is in a shared libarry.
- // But we do this only once per source file, because a single instance is sufficient to initialize
- // all of the globals in a shared library.
- //
- if(!_doneStaticSymbol)
- {
- _doneStaticSymbol = true;
- H << sp << nl << "static " << name << " __" << p->name() << "_init;";
- }
+ //
+ // We need an instance here to trigger initialization if the implementation is in a shared libarry.
+ // But we do this only once per source file, because a single instance is sufficient to initialize
+ // all of the globals in a shared library.
+ //
+ if(!_doneStaticSymbol)
+ {
+ _doneStaticSymbol = true;
+ H << sp << nl << "static " << name << " __" << p->name() << "_init;";
+ }
}
_useWstring = resetUseWstring(_useWstringHist);
@@ -880,56 +880,56 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p)
if(findMetaData(p->getMetaData(), false) == "class")
{
- H << sp << nl << "class " << _dllExport << name << " : public IceUtil::Shared";
- H << sb;
- H.dec();
- H << nl << "public:";
- H.inc();
- H << nl;
- H << nl << name << "() {}";
-
- DataMemberList dataMembers = p->dataMembers();
- if(!dataMembers.empty())
- {
- DataMemberList::const_iterator q;
- vector<string> paramDecls;
- vector<string> types;
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- string typeName = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData());
- types.push_back(typeName);
- paramDecls.push_back(typeName + " __ice_" + (*q)->name());
- }
-
- H << nl;
- if(paramDecls.size() == 1)
- {
- H << "explicit ";
- }
- H << name << spar << types << epar << ';';
-
- C << sp << nl << p->scoped().substr(2) << "::" << fixKwd(p->name()) << spar << paramDecls << epar << " :";
- C.inc();
-
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- if(q != dataMembers.begin())
- {
- C << ',' << nl;
- }
- string memberName = fixKwd((*q)->name());
- C << memberName << '(' << "__ice_" << (*q)->name() << ')';
- }
-
- C.dec();
- C << sb;
- C << eb;
- }
+ H << sp << nl << "class " << _dllExport << name << " : public IceUtil::Shared";
+ H << sb;
+ H.dec();
+ H << nl << "public:";
+ H.inc();
+ H << nl;
+ H << nl << name << "() {}";
+
+ DataMemberList dataMembers = p->dataMembers();
+ if(!dataMembers.empty())
+ {
+ DataMemberList::const_iterator q;
+ vector<string> paramDecls;
+ vector<string> types;
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ string typeName = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData());
+ types.push_back(typeName);
+ paramDecls.push_back(typeName + " __ice_" + (*q)->name());
+ }
+
+ H << nl;
+ if(paramDecls.size() == 1)
+ {
+ H << "explicit ";
+ }
+ H << name << spar << types << epar << ';';
+
+ C << sp << nl << p->scoped().substr(2) << "::" << fixKwd(p->name()) << spar << paramDecls << epar << " :";
+ C.inc();
+
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ if(q != dataMembers.begin())
+ {
+ C << ',' << nl;
+ }
+ string memberName = fixKwd((*q)->name());
+ C << memberName << '(' << "__ice_" << (*q)->name() << ')';
+ }
+
+ C.dec();
+ C << sb;
+ C << eb;
+ }
}
else
{
- H << sp << nl << "struct " << name;
- H << sb;
+ H << sp << nl << "struct " << name;
+ H << sb;
}
return true;
@@ -950,13 +950,13 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- params.push_back(fixKwd((*q)->name()));
+ params.push_back(fixKwd((*q)->name()));
}
string dllExport;
if(findMetaData(p->getMetaData(), false) != "class")
{
- dllExport = _dllExport;
+ dllExport = _dllExport;
}
H << sp;
@@ -988,10 +988,10 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
C << eb;
for(pi = params.begin(); pi != params.end(); ++pi)
{
- C << nl << "if(" << *pi << " != __rhs." << *pi << ')';
- C << sb;
- C << nl << "return true;";
- C << eb;
+ C << nl << "if(" << *pi << " != __rhs." << *pi << ')';
+ C << sb;
+ C << nl << "return true;";
+ C << eb;
}
C << nl << "return false;";
C << eb;
@@ -1003,25 +1003,25 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
C << eb;
for(pi = params.begin(); pi != params.end(); ++pi)
{
- C << nl << "if(" << *pi << " < __rhs." << *pi << ')';
- C << sb;
- C << nl << "return true;";
- C << eb;
- C << nl << "else if(__rhs." << *pi << " < " << *pi << ')';
- C << sb;
- C << nl << "return false;";
- C << eb;
+ C << nl << "if(" << *pi << " < __rhs." << *pi << ')';
+ C << sb;
+ C << nl << "return true;";
+ C << eb;
+ C << nl << "else if(__rhs." << *pi << " < " << *pi << ')';
+ C << sb;
+ C << nl << "return false;";
+ C << eb;
}
C << nl << "return false;";
C << eb;
if(!p->isLocal())
{
- //
- // None of these member functions is virtual!
- //
- H << sp << nl << dllExport << "void __write(::IceInternal::BasicStream*) const;";
- H << nl << dllExport << "void __read(::IceInternal::BasicStream*);";
+ //
+ // None of these member functions is virtual!
+ //
+ H << sp << nl << dllExport << "void __write(::IceInternal::BasicStream*) const;";
+ H << nl << dllExport << "void __read(::IceInternal::BasicStream*);";
if(_stream)
{
@@ -1029,92 +1029,92 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
H << nl << dllExport << "void ice_read(const ::Ice::InputStreamPtr&);";
}
- C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const";
- C << sb;
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const";
+ C << sb;
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), true, "", true, (*q)->getMetaData());
}
- C << eb;
+ C << eb;
- C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is)";
- C << sb;
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is)";
+ C << sb;
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), false, "", true, (*q)->getMetaData());
}
- C << eb;
-
- if(_stream)
- {
- C << sp << nl << "void" << nl << scoped.substr(2)
- << "::ice_write(const ::Ice::OutputStreamPtr& __outS) const";
- C << sb;
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), true, "", _useWstring,
- (*q)->getMetaData());
- }
- C << eb;
-
- C << sp << nl << "void" << nl << scoped.substr(2) << "::ice_read(const ::Ice::InputStreamPtr& __inS)";
- C << sb;
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), false, "", _useWstring,
- (*q)->getMetaData());
- }
- C << eb;
- }
+ C << eb;
+
+ if(_stream)
+ {
+ C << sp << nl << "void" << nl << scoped.substr(2)
+ << "::ice_write(const ::Ice::OutputStreamPtr& __outS) const";
+ C << sb;
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), true, "", _useWstring,
+ (*q)->getMetaData());
+ }
+ C << eb;
+
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::ice_read(const ::Ice::InputStreamPtr& __inS)";
+ C << sb;
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), false, "", _useWstring,
+ (*q)->getMetaData());
+ }
+ C << eb;
+ }
}
H << eb << ';';
if(findMetaData(p->getMetaData(), false) == "class")
{
- H << sp << nl << "typedef ::IceUtil::Handle< " << scoped << "> " << name << "Ptr;";
-
- if(!p->isLocal() && _stream)
- {
- H << sp << nl << "void ice_write" << p->name() << "(const ::Ice::OutputStreamPtr&, const "
- << name << "Ptr&);";
- H << nl << "void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << name
- << "Ptr&);";
-
- C << sp << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name()
- << "(const ::Ice::OutputStreamPtr& __outS, const " << scoped << "Ptr& __v)";
- C << sb;
- C << nl << "__v->ice_write(__outS);";
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name()
- << "(const ::Ice::InputStreamPtr& __inS, " << scoped << "Ptr& __v)";
- C << sb;
- C << nl << "__v->ice_read(__inS);";
- C << eb;
- }
+ H << sp << nl << "typedef ::IceUtil::Handle< " << scoped << "> " << name << "Ptr;";
+
+ if(!p->isLocal() && _stream)
+ {
+ H << sp << nl << "void ice_write" << p->name() << "(const ::Ice::OutputStreamPtr&, const "
+ << name << "Ptr&);";
+ H << nl << "void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << name
+ << "Ptr&);";
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name()
+ << "(const ::Ice::OutputStreamPtr& __outS, const " << scoped << "Ptr& __v)";
+ C << sb;
+ C << nl << "__v->ice_write(__outS);";
+ C << eb;
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name()
+ << "(const ::Ice::InputStreamPtr& __inS, " << scoped << "Ptr& __v)";
+ C << sb;
+ C << nl << "__v->ice_read(__inS);";
+ C << eb;
+ }
}
else
{
- if(!p->isLocal() && _stream)
- {
- H << sp << nl << dllExport << "void ice_write" << p->name() << "(const ::Ice::OutputStreamPtr&, const "
- << name << "&);";
- H << nl << dllExport << "void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << name << "&);";
-
- C << sp << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name()
- << "(const ::Ice::OutputStreamPtr& __outS, const " << scoped << "& __v)";
- C << sb;
- C << nl << "__v.ice_write(__outS);";
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name()
- << "(const ::Ice::InputStreamPtr& __inS, " << scoped << "& __v)";
- C << sb;
- C << nl << "__v.ice_read(__inS);";
- C << eb;
- }
- }
-
+ if(!p->isLocal() && _stream)
+ {
+ H << sp << nl << dllExport << "void ice_write" << p->name() << "(const ::Ice::OutputStreamPtr&, const "
+ << name << "&);";
+ H << nl << dllExport << "void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << name << "&);";
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name()
+ << "(const ::Ice::OutputStreamPtr& __outS, const " << scoped << "& __v)";
+ C << sb;
+ C << nl << "__v.ice_write(__outS);";
+ C << eb;
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name()
+ << "(const ::Ice::InputStreamPtr& __inS, " << scoped << "& __v)";
+ C << sb;
+ C << nl << "__v.ice_read(__inS);";
+ C << eb;
+ }
+ }
+
_useWstring = resetUseWstring(_useWstringHist);
}
@@ -1146,10 +1146,10 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if(!p->isLocal())
{
- string scoped = fixKwd(p->scoped());
- string scope = fixKwd(p->scope());
+ string scoped = fixKwd(p->scoped());
+ string scope = fixKwd(p->scope());
- H << sp << nl << "class __U__" << name << " { };";
+ H << sp << nl << "class __U__" << name << " { };";
if(!seqType.empty())
{
@@ -1162,7 +1162,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
H << nl << _dllExport << "void ice_write" << p->name() << "(const ::Ice::OutputStreamPtr&, const "
<< name << "&);";
H << nl << _dllExport << "void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << name
- << "&);";
+ << "&);";
}
C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
@@ -1251,75 +1251,75 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
}
else if(!builtin || builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindObjectProxy)
{
- H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << s << "*, const " << s
- << "*, __U__" << name << ");";
- H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&, __U__" << name << ");";
+ H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << s << "*, const " << s
+ << "*, __U__" << name << ");";
+ H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&, __U__" << name << ");";
if(_stream)
{
H << nl << _dllExport << "void ice_write" << p->name() << "(const ::Ice::OutputStreamPtr&, const "
<< name << "&);";
H << nl << _dllExport << "void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << name
- << "&);";
+ << "&);";
}
- C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
- << s << "* begin, const " << s << "* end, " << scope << "__U__" << name << ")";
- C << sb;
- C << nl << "::Ice::Int size = static_cast< ::Ice::Int>(end - begin);";
- C << nl << "__os->writeSize(size);";
- C << nl << "for(int i = 0; i < size; ++i)";
- C << sb;
- writeMarshalUnmarshalCode(C, type, "begin[i]", true);
- C << eb;
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
- << "& v, " << scope << "__U__" << name << ')';
- C << sb;
- C << nl << "::Ice::Int sz;";
- C << nl << "__is->readSize(sz);";
- if(type->isVariableLength())
- {
- // Protect against bogus sequence sizes.
- C << nl << "__is->startSeq(sz, " << type->minWireSize() << ");";
- }
- else
- {
- C << nl << "__is->checkFixedSeq(sz, " << type->minWireSize() << ");";
- }
- C << nl << "v.resize(sz);";
- C << nl << "for(int i = 0; i < sz; ++i)";
- C << sb;
- writeMarshalUnmarshalCode(C, type, "v[i]", false);
-
- //
- // After unmarshaling each element, check that there are still enough bytes left in the stream
- // to unmarshal the remainder of the sequence, and decrement the count of elements
- // yet to be unmarshaled for sequences with variable-length element type (that is, for sequences
- // of classes, structs, dictionaries, sequences, strings, or proxies). This allows us to
- // abort unmarshaling for bogus sequence sizes at the earliest possible moment.
- // (For fixed-length sequences, we don't need to do this because the prediction of how many
- // bytes will be taken up by the sequence is accurate.)
- //
- if(type->isVariableLength())
- {
- if(!SequencePtr::dynamicCast(type))
- {
- //
- // No need to check for directly nested sequences because, at the start of each
- // sequence, we check anyway.
- //
- C << nl << "__is->checkSeq();";
- }
- C << nl << "__is->endElement();";
- }
- C << eb;
- if(type->isVariableLength())
- {
- C << nl << "__is->endSeq(sz);";
- }
- C << eb;
+ C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
+ << s << "* begin, const " << s << "* end, " << scope << "__U__" << name << ")";
+ C << sb;
+ C << nl << "::Ice::Int size = static_cast< ::Ice::Int>(end - begin);";
+ C << nl << "__os->writeSize(size);";
+ C << nl << "for(int i = 0; i < size; ++i)";
+ C << sb;
+ writeMarshalUnmarshalCode(C, type, "begin[i]", true);
+ C << eb;
+ C << eb;
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
+ << "& v, " << scope << "__U__" << name << ')';
+ C << sb;
+ C << nl << "::Ice::Int sz;";
+ C << nl << "__is->readSize(sz);";
+ if(type->isVariableLength())
+ {
+ // Protect against bogus sequence sizes.
+ C << nl << "__is->startSeq(sz, " << type->minWireSize() << ");";
+ }
+ else
+ {
+ C << nl << "__is->checkFixedSeq(sz, " << type->minWireSize() << ");";
+ }
+ C << nl << "v.resize(sz);";
+ C << nl << "for(int i = 0; i < sz; ++i)";
+ C << sb;
+ writeMarshalUnmarshalCode(C, type, "v[i]", false);
+
+ //
+ // After unmarshaling each element, check that there are still enough bytes left in the stream
+ // to unmarshal the remainder of the sequence, and decrement the count of elements
+ // yet to be unmarshaled for sequences with variable-length element type (that is, for sequences
+ // of classes, structs, dictionaries, sequences, strings, or proxies). This allows us to
+ // abort unmarshaling for bogus sequence sizes at the earliest possible moment.
+ // (For fixed-length sequences, we don't need to do this because the prediction of how many
+ // bytes will be taken up by the sequence is accurate.)
+ //
+ if(type->isVariableLength())
+ {
+ if(!SequencePtr::dynamicCast(type))
+ {
+ //
+ // No need to check for directly nested sequences because, at the start of each
+ // sequence, we check anyway.
+ //
+ C << nl << "__is->checkSeq();";
+ }
+ C << nl << "__is->endElement();";
+ }
+ C << eb;
+ if(type->isVariableLength())
+ {
+ C << nl << "__is->endSeq(sz);";
+ }
+ C << eb;
if(_stream)
{
@@ -1345,7 +1345,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
C << eb;
C << eb;
}
- }
+ }
}
}
@@ -1358,83 +1358,83 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
string ks = typeToString(keyType, _useWstring, p->keyMetaData());
if(ks[0] == ':')
{
- ks.insert(0, " ");
+ ks.insert(0, " ");
}
string vs = typeToString(valueType, _useWstring, p->valueMetaData());
H << sp << nl << "typedef ::std::map<" << ks << ", " << vs << "> " << name << ';';
if(!p->isLocal())
{
- string scoped = fixKwd(p->scoped());
- string scope = fixKwd(p->scope());
-
- H << sp << nl << "class __U__" << name << " { };";
- H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name
- << "&, __U__" << name << ");";
- H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name
- << "&, __U__" << name << ");";
-
- if(_stream)
- {
- H << nl << _dllExport << "void ice_write" << p->name() << "(const ::Ice::OutputStreamPtr&, const " << name
- << "&);";
- H << nl << _dllExport << "void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << name << "&);";
- }
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
- << scoped << "& v, " << scope << "__U__" << name << ")";
- C << sb;
- C << nl << "__os->writeSize(::Ice::Int(v.size()));";
- C << nl << scoped << "::const_iterator p;";
- C << nl << "for(p = v.begin(); p != v.end(); ++p)";
- C << sb;
- writeMarshalUnmarshalCode(C, keyType, "p->first", true);
- writeMarshalUnmarshalCode(C, valueType, "p->second", true);
- C << eb;
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
- << "& v, " << scope << "__U__" << name << ')';
- C << sb;
- C << nl << "::Ice::Int sz;";
- C << nl << "__is->readSize(sz);";
- C << nl << "while(sz--)";
- C << sb;
- C << nl << "::std::pair<const " << ks << ", " << vs << "> pair;";
- const string pf = string("const_cast<") + ks + "&>(pair.first)";
- writeMarshalUnmarshalCode(C, keyType, pf, false);
- C << nl << scoped << "::iterator __i = v.insert(v.end(), pair);";
- writeMarshalUnmarshalCode(C, valueType, "__i->second", false);
- C << eb;
- C << eb;
-
- if(_stream)
- {
- C << sp << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name()
- << "(const ::Ice::OutputStreamPtr& __outS, const " << scoped << "& v)";
- C << sb;
- C << nl << "__outS->writeSize(::Ice::Int(v.size()));";
- C << nl << scoped << "::const_iterator p;";
- C << nl << "for(p = v.begin(); p != v.end(); ++p)";
- C << sb;
- writeStreamMarshalUnmarshalCode(C, keyType, "p->first", true, "", _useWstring, p->keyMetaData());
- writeStreamMarshalUnmarshalCode(C, valueType, "p->second", true, "", _useWstring, p->valueMetaData());
- C << eb;
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name()
- << "(const ::Ice::InputStreamPtr& __inS, " << scoped << "& v)";
- C << sb;
- C << nl << "::Ice::Int sz = __inS->readSize();";
- C << nl << "while(sz--)";
- C << sb;
- C << nl << "::std::pair<const " << ks << ", " << vs << "> pair;";
- writeStreamMarshalUnmarshalCode(C, keyType, pf, false, "", _useWstring, p->keyMetaData());
- C << nl << scoped << "::iterator __i = v.insert(v.end(), pair);";
- writeStreamMarshalUnmarshalCode(C, valueType, "__i->second", false, "", _useWstring, p->valueMetaData());
- C << eb;
- C << eb;
- }
+ string scoped = fixKwd(p->scoped());
+ string scope = fixKwd(p->scope());
+
+ H << sp << nl << "class __U__" << name << " { };";
+ H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name
+ << "&, __U__" << name << ");";
+ H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name
+ << "&, __U__" << name << ");";
+
+ if(_stream)
+ {
+ H << nl << _dllExport << "void ice_write" << p->name() << "(const ::Ice::OutputStreamPtr&, const " << name
+ << "&);";
+ H << nl << _dllExport << "void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << name << "&);";
+ }
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
+ << scoped << "& v, " << scope << "__U__" << name << ")";
+ C << sb;
+ C << nl << "__os->writeSize(::Ice::Int(v.size()));";
+ C << nl << scoped << "::const_iterator p;";
+ C << nl << "for(p = v.begin(); p != v.end(); ++p)";
+ C << sb;
+ writeMarshalUnmarshalCode(C, keyType, "p->first", true);
+ writeMarshalUnmarshalCode(C, valueType, "p->second", true);
+ C << eb;
+ C << eb;
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
+ << "& v, " << scope << "__U__" << name << ')';
+ C << sb;
+ C << nl << "::Ice::Int sz;";
+ C << nl << "__is->readSize(sz);";
+ C << nl << "while(sz--)";
+ C << sb;
+ C << nl << "::std::pair<const " << ks << ", " << vs << "> pair;";
+ const string pf = string("const_cast<") + ks + "&>(pair.first)";
+ writeMarshalUnmarshalCode(C, keyType, pf, false);
+ C << nl << scoped << "::iterator __i = v.insert(v.end(), pair);";
+ writeMarshalUnmarshalCode(C, valueType, "__i->second", false);
+ C << eb;
+ C << eb;
+
+ if(_stream)
+ {
+ C << sp << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name()
+ << "(const ::Ice::OutputStreamPtr& __outS, const " << scoped << "& v)";
+ C << sb;
+ C << nl << "__outS->writeSize(::Ice::Int(v.size()));";
+ C << nl << scoped << "::const_iterator p;";
+ C << nl << "for(p = v.begin(); p != v.end(); ++p)";
+ C << sb;
+ writeStreamMarshalUnmarshalCode(C, keyType, "p->first", true, "", _useWstring, p->keyMetaData());
+ writeStreamMarshalUnmarshalCode(C, valueType, "p->second", true, "", _useWstring, p->valueMetaData());
+ C << eb;
+ C << eb;
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name()
+ << "(const ::Ice::InputStreamPtr& __inS, " << scoped << "& v)";
+ C << sb;
+ C << nl << "::Ice::Int sz = __inS->readSize();";
+ C << nl << "while(sz--)";
+ C << sb;
+ C << nl << "::std::pair<const " << ks << ", " << vs << "> pair;";
+ writeStreamMarshalUnmarshalCode(C, keyType, pf, false, "", _useWstring, p->keyMetaData());
+ C << nl << scoped << "::iterator __i = v.insert(v.end(), pair);";
+ writeStreamMarshalUnmarshalCode(C, valueType, "__i->second", false, "", _useWstring, p->valueMetaData());
+ C << eb;
+ C << eb;
+ }
}
}
@@ -1448,111 +1448,111 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
EnumeratorList::const_iterator en = enumerators.begin();
while(en != enumerators.end())
{
- H << nl << fixKwd((*en)->name());
- if(++en != enumerators.end())
- {
- H << ',';
- }
+ H << nl << fixKwd((*en)->name());
+ if(++en != enumerators.end())
+ {
+ H << ',';
+ }
}
H << eb << ';';
if(!p->isLocal())
{
- string scoped = fixKwd(p->scoped());
- string scope = fixKwd(p->scope());
-
- size_t sz = enumerators.size();
- assert(sz <= 0x7fffffff); // 64-bit enums are not supported
-
- H << sp << nl << _dllExport << "void __write(::IceInternal::BasicStream*, " << name << ");";
- H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&);";
-
- if(_stream)
- {
- H << sp << nl << _dllExport << "void ice_write" << p->name()
+ string scoped = fixKwd(p->scoped());
+ string scope = fixKwd(p->scope());
+
+ size_t sz = enumerators.size();
+ assert(sz <= 0x7fffffff); // 64-bit enums are not supported
+
+ H << sp << nl << _dllExport << "void __write(::IceInternal::BasicStream*, " << name << ");";
+ H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&);";
+
+ if(_stream)
+ {
+ H << sp << nl << _dllExport << "void ice_write" << p->name()
<< "(const ::Ice::OutputStreamPtr&, " << name << ");";
- H << nl << _dllExport << "void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << name << "&);";
- }
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, " << scoped
- << " v)";
- C << sb;
- if(sz <= 0x7f)
- {
- C << nl << "__os->write(static_cast< ::Ice::Byte>(v));";
- }
- else if(sz <= 0x7fff)
- {
- C << nl << "__os->write(static_cast< ::Ice::Short>(v));";
- }
- else
- {
- C << nl << "__os->write(static_cast< ::Ice::Int>(v));";
- }
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
- << "& v)";
- C << sb;
- if(sz <= 0x7f)
- {
- C << nl << "::Ice::Byte val;";
- C << nl << "__is->read(val);";
- C << nl << "v = static_cast< " << scoped << ">(val);";
- }
- else if(sz <= 0x7fff)
- {
- C << nl << "::Ice::Short val;";
- C << nl << "__is->read(val);";
- C << nl << "v = static_cast< " << scoped << ">(val);";
- }
- else
- {
- C << nl << "::Ice::Int val;";
- C << nl << "__is->read(val);";
- C << nl << "v = static_cast< " << scoped << ">(val);";
- }
- C << eb;
-
- if(_stream)
- {
- C << sp << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name()
+ H << nl << _dllExport << "void ice_read" << p->name() << "(const ::Ice::InputStreamPtr&, " << name << "&);";
+ }
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, " << scoped
+ << " v)";
+ C << sb;
+ if(sz <= 0x7f)
+ {
+ C << nl << "__os->write(static_cast< ::Ice::Byte>(v));";
+ }
+ else if(sz <= 0x7fff)
+ {
+ C << nl << "__os->write(static_cast< ::Ice::Short>(v));";
+ }
+ else
+ {
+ C << nl << "__os->write(static_cast< ::Ice::Int>(v));";
+ }
+ C << eb;
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
+ << "& v)";
+ C << sb;
+ if(sz <= 0x7f)
+ {
+ C << nl << "::Ice::Byte val;";
+ C << nl << "__is->read(val);";
+ C << nl << "v = static_cast< " << scoped << ">(val);";
+ }
+ else if(sz <= 0x7fff)
+ {
+ C << nl << "::Ice::Short val;";
+ C << nl << "__is->read(val);";
+ C << nl << "v = static_cast< " << scoped << ">(val);";
+ }
+ else
+ {
+ C << nl << "::Ice::Int val;";
+ C << nl << "__is->read(val);";
+ C << nl << "v = static_cast< " << scoped << ">(val);";
+ }
+ C << eb;
+
+ if(_stream)
+ {
+ C << sp << nl << "void" << nl << scope.substr(2) << "ice_write" << p->name()
<< "(const ::Ice::OutputStreamPtr& __outS, " << scoped << " v)";
- C << sb;
- if(sz <= 0x7f)
- {
- C << nl << "__outS->writeByte(static_cast< ::Ice::Byte>(v));";
- }
- else if(sz <= 0x7fff)
- {
- C << nl << "__outS->writeShort(static_cast< ::Ice::Short>(v));";
- }
- else
- {
- C << nl << "__outS->writeInt(static_cast< ::Ice::Int>(v));";
- }
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name()
+ C << sb;
+ if(sz <= 0x7f)
+ {
+ C << nl << "__outS->writeByte(static_cast< ::Ice::Byte>(v));";
+ }
+ else if(sz <= 0x7fff)
+ {
+ C << nl << "__outS->writeShort(static_cast< ::Ice::Short>(v));";
+ }
+ else
+ {
+ C << nl << "__outS->writeInt(static_cast< ::Ice::Int>(v));";
+ }
+ C << eb;
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "ice_read" << p->name()
<< "(const ::Ice::InputStreamPtr& __inS, " << scoped << "& v)";
- C << sb;
- if(sz <= 0x7f)
- {
- C << nl << "::Ice::Byte val = __inS->readByte();";
- C << nl << "v = static_cast< " << scoped << ">(val);";
- }
- else if(sz <= 0x7fff)
- {
- C << nl << "::Ice::Short val = __inS->readShort();";
- C << nl << "v = static_cast< " << scoped << ">(val);";
- }
- else
- {
- C << nl << "::Ice::Int val = __inS->readInt();";
- C << nl << "v = static_cast< " << scoped << ">(val);";
- }
- C << eb;
- }
+ C << sb;
+ if(sz <= 0x7f)
+ {
+ C << nl << "::Ice::Byte val = __inS->readByte();";
+ C << nl << "v = static_cast< " << scoped << ">(val);";
+ }
+ else if(sz <= 0x7fff)
+ {
+ C << nl << "::Ice::Short val = __inS->readShort();";
+ C << nl << "v = static_cast< " << scoped << ">(val);";
+ }
+ else
+ {
+ C << nl << "::Ice::Int val = __inS->readInt();";
+ C << nl << "v = static_cast< " << scoped << ">(val);";
+ }
+ C << eb;
+ }
}
}
@@ -1566,59 +1566,59 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
BuiltinPtr bp = BuiltinPtr::dynamicCast(p->type());
if(bp && bp->kind() == Builtin::KindString)
{
- //
- // Expand strings into the basic source character set. We can't use isalpha() and the like
- // here because they are sensitive to the current locale.
- //
- static const string basicSourceChars = "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789"
- "_{}[]#()<>%:;.?*+-/^&|~!=,\\\"' ";
- static const set<char> charSet(basicSourceChars.begin(), basicSourceChars.end());
-
- if(_useWstring || findMetaData(p->typeMetaData(), true) == "wstring")
- {
- H << 'L';
- }
- H << "\""; // Opening "
-
- const string val = p->value();
- for(string::const_iterator c = val.begin(); c != val.end(); ++c)
- {
- if(charSet.find(*c) == charSet.end())
- {
- unsigned char uc = *c; // char may be signed, so make it positive
- ostringstream s;
- s << "\\"; // Print as octal if not in basic source character set
- s.width(3);
- s.fill('0');
- s << oct;
- s << static_cast<unsigned>(uc);
- H << s.str();
- }
- else
- {
- H << *c; // Print normally if in basic source character set
- }
- }
-
- H << "\""; // Closing "
+ //
+ // Expand strings into the basic source character set. We can't use isalpha() and the like
+ // here because they are sensitive to the current locale.
+ //
+ static const string basicSourceChars = "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789"
+ "_{}[]#()<>%:;.?*+-/^&|~!=,\\\"' ";
+ static const set<char> charSet(basicSourceChars.begin(), basicSourceChars.end());
+
+ if(_useWstring || findMetaData(p->typeMetaData(), true) == "wstring")
+ {
+ H << 'L';
+ }
+ H << "\""; // Opening "
+
+ const string val = p->value();
+ for(string::const_iterator c = val.begin(); c != val.end(); ++c)
+ {
+ if(charSet.find(*c) == charSet.end())
+ {
+ unsigned char uc = *c; // char may be signed, so make it positive
+ ostringstream s;
+ s << "\\"; // Print as octal if not in basic source character set
+ s.width(3);
+ s.fill('0');
+ s << oct;
+ s << static_cast<unsigned>(uc);
+ H << s.str();
+ }
+ else
+ {
+ H << *c; // Print normally if in basic source character set
+ }
+ }
+
+ H << "\""; // Closing "
}
else if(bp && bp->kind() == Builtin::KindLong)
{
- H << "ICE_INT64(" << p->value() << ")";
+ H << "ICE_INT64(" << p->value() << ")";
}
else
{
- EnumPtr ep = EnumPtr::dynamicCast(p->type());
- if(ep)
- {
- H << fixKwd(p->value());
- }
- else
- {
- H << p->value();
- }
+ EnumPtr ep = EnumPtr::dynamicCast(p->type());
+ if(ep)
+ {
+ H << fixKwd(p->value());
+ }
+ else
+ {
+ H << p->value();
+ }
}
H << ';';
@@ -1651,7 +1651,7 @@ Slice::Gen::ProxyDeclVisitor::visitUnitStart(const UnitPtr& p)
{
if(!p->hasNonLocalClassDecls())
{
- return false;
+ return false;
}
H << sp << nl << "namespace IceProxy" << nl << '{';
@@ -1670,7 +1670,7 @@ Slice::Gen::ProxyDeclVisitor::visitModuleStart(const ModulePtr& p)
{
if(!p->hasNonLocalClassDecls())
{
- return false;
+ return false;
}
string name = fixKwd(p->name());
@@ -1691,7 +1691,7 @@ Slice::Gen::ProxyDeclVisitor::visitClassDecl(const ClassDeclPtr& p)
{
if(p->isLocal())
{
- return;
+ return;
}
string name = fixKwd(p->name());
@@ -1715,7 +1715,7 @@ Slice::Gen::ProxyVisitor::visitUnitStart(const UnitPtr& p)
{
if(!p->hasNonLocalClassDecls())
{
- return false;
+ return false;
}
H << sp << nl << "namespace IceProxy" << nl << '{';
@@ -1734,7 +1734,7 @@ Slice::Gen::ProxyVisitor::visitModuleStart(const ModulePtr& p)
{
if(!p->hasNonLocalClassDecls())
{
- return false;
+ return false;
}
_useWstring = setUseWstring(p, _useWstringHist, _useWstring);
@@ -1759,7 +1759,7 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
{
if(p->isLocal())
{
- return false;
+ return false;
}
_useWstring = setUseWstring(p, _useWstringHist, _useWstring);
@@ -1771,21 +1771,21 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
H << sp << nl << "class " << _dllExport << name << " : ";
if(bases.empty())
{
- H << "virtual public ::IceProxy::Ice::Object";
+ H << "virtual public ::IceProxy::Ice::Object";
}
else
{
- H.useCurrentPosAsIndent();
- ClassList::const_iterator q = bases.begin();
- while(q != bases.end())
- {
- H << "virtual public ::IceProxy" << fixKwd((*q)->scoped());
- if(++q != bases.end())
- {
- H << ',' << nl;
- }
- }
- H.restoreIndent();
+ H.useCurrentPosAsIndent();
+ ClassList::const_iterator q = bases.begin();
+ while(q != bases.end())
+ {
+ H << "virtual public ::IceProxy" << fixKwd((*q)->scoped());
+ if(++q != bases.end())
+ {
+ H << ',' << nl;
+ }
+ }
+ H.restoreIndent();
}
H << sb;
@@ -1895,39 +1895,39 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
ParamDeclList paramList = p->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- string paramName = fixKwd((*q)->name());
+ string paramName = fixKwd((*q)->name());
- StringList metaData = (*q)->getMetaData();
+ StringList metaData = (*q)->getMetaData();
#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550)
- //
- // Work around for Sun CC 5.5 bug #4853566
- //
- string typeString;
- if((*q)->isOutParam())
- {
- typeString = outputTypeToString((*q)->type(), _useWstring, metaData);
- }
- else
- {
- typeString = inputTypeToString((*q)->type(), _useWstring, metaData);
- }
+ //
+ // Work around for Sun CC 5.5 bug #4853566
+ //
+ string typeString;
+ if((*q)->isOutParam())
+ {
+ typeString = outputTypeToString((*q)->type(), _useWstring, metaData);
+ }
+ else
+ {
+ typeString = inputTypeToString((*q)->type(), _useWstring, metaData);
+ }
#else
- string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), _useWstring, metaData)
- : inputTypeToString((*q)->type(), _useWstring, metaData);
+ string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), _useWstring, metaData)
+ : inputTypeToString((*q)->type(), _useWstring, metaData);
#endif
- params.push_back(typeString);
- paramsDecl.push_back(typeString + ' ' + paramName);
- args.push_back(paramName);
+ params.push_back(typeString);
+ paramsDecl.push_back(typeString + ' ' + paramName);
+ args.push_back(paramName);
- if(!(*q)->isOutParam())
- {
- string inputTypeString = inputTypeToString((*q)->type(), _useWstring, metaData);
+ if(!(*q)->isOutParam())
+ {
+ string inputTypeString = inputTypeToString((*q)->type(), _useWstring, metaData);
- paramsAMI.push_back(inputTypeString);
- paramsDeclAMI.push_back(inputTypeString + ' ' + paramName);
- argsAMI.push_back(paramName);
- }
+ paramsAMI.push_back(inputTypeString);
+ paramsDeclAMI.push_back(inputTypeString + ' ' + paramName);
+ argsAMI.push_back(paramName);
+ }
}
string thisPointer = fixKwd(scope.substr(0, scope.size() - 2)) + "*";
@@ -1938,7 +1938,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
H << nl;
if(ret)
{
- H << "return ";
+ H << "return ";
}
H << fixKwd(name) << spar << args << "0" << epar << ';';
H << eb;
@@ -1947,7 +1947,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
H << nl;
if(ret)
{
- H << "return ";
+ H << "return ";
}
H << fixKwd(name) << spar << args << "&__ctx" << epar << ';';
H << eb;
@@ -1980,23 +1980,23 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
C << nl;
if(ret)
{
- C << "return ";
+ C << "return ";
}
C << "__del->" << fixKwd(name) << spar << args << "__ctx" << epar << ';';
if(!ret)
{
- C << nl << "return;";
+ C << nl << "return;";
}
C << eb;
C << nl << "catch(const ::IceInternal::LocalExceptionWrapper& __ex)";
C << sb;
if(p->mode() == Operation::Idempotent || p->mode() == Operation::Nonmutating)
{
- C << nl << "__handleExceptionWrapperRelaxed(__delBase, __ex, __cnt);";
+ C << nl << "__handleExceptionWrapperRelaxed(__delBase, __ex, __cnt);";
}
else
{
- C << nl << "__handleExceptionWrapper(__delBase, __ex);";
+ C << nl << "__handleExceptionWrapper(__delBase, __ex);";
}
C << eb;
C << nl << "catch(const ::Ice::LocalException& __ex)";
@@ -2008,27 +2008,27 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
if(cl->hasMetaData("ami") || p->hasMetaData("ami"))
{
- string classNameAMI = "AMI_" + cl->name();
- string classScope = fixKwd(cl->scope());
- string classScopedAMI = classScope + classNameAMI;
+ string classNameAMI = "AMI_" + cl->name();
+ string classScope = fixKwd(cl->scope());
+ string classScopedAMI = classScope + classNameAMI;
- H << nl << "void " << name << "_async" << spar << ("const " + classScopedAMI + '_' + name + "Ptr&")
- << paramsAMI << epar << ';';
- H << nl << "void " << name << "_async" << spar << ("const " + classScopedAMI + '_' + name + "Ptr&")
- << paramsAMI << "const ::Ice::Context&" << epar << ';';
+ H << nl << "void " << name << "_async" << spar << ("const " + classScopedAMI + '_' + name + "Ptr&")
+ << paramsAMI << epar << ';';
+ H << nl << "void " << name << "_async" << spar << ("const " + classScopedAMI + '_' + name + "Ptr&")
+ << paramsAMI << "const ::Ice::Context&" << epar << ';';
- C << sp << nl << "void" << nl << "IceProxy" << scope << name << "_async" << spar
- << ("const " + classScopedAMI + '_' + name + "Ptr& __cb") << paramsDeclAMI << epar;
- C << sb;
- C << nl << "__cb->__invoke" << spar << "this" << argsAMI << "0" << epar << ';';
- C << eb;
+ C << sp << nl << "void" << nl << "IceProxy" << scope << name << "_async" << spar
+ << ("const " + classScopedAMI + '_' + name + "Ptr& __cb") << paramsDeclAMI << epar;
+ C << sb;
+ C << nl << "__cb->__invoke" << spar << "this" << argsAMI << "0" << epar << ';';
+ C << eb;
- C << sp << nl << "void" << nl << "IceProxy" << scope << name << "_async" << spar
- << ("const " + classScopedAMI + '_' + name + "Ptr& __cb") << paramsDeclAMI << "const ::Ice::Context& __ctx"
- << epar;
- C << sb;
- C << nl << "__cb->__invoke" << spar << "this" << argsAMI << "&__ctx" << epar << ';';
- C << eb;
+ C << sp << nl << "void" << nl << "IceProxy" << scope << name << "_async" << spar
+ << ("const " + classScopedAMI + '_' + name + "Ptr& __cb") << paramsDeclAMI << "const ::Ice::Context& __ctx"
+ << epar;
+ C << sb;
+ C << nl << "__cb->__invoke" << spar << "this" << argsAMI << "&__ctx" << epar << ';';
+ C << eb;
}
@@ -2045,7 +2045,7 @@ Slice::Gen::DelegateVisitor::visitUnitStart(const UnitPtr& p)
{
if(!p->hasNonLocalClassDecls())
{
- return false;
+ return false;
}
H << sp << nl << "namespace IceDelegate" << nl << '{';
@@ -2064,7 +2064,7 @@ Slice::Gen::DelegateVisitor::visitModuleStart(const ModulePtr& p)
{
if(!p->hasNonLocalClassDecls())
{
- return false;
+ return false;
}
_useWstring = setUseWstring(p, _useWstringHist, _useWstring);
@@ -2089,7 +2089,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p)
{
if(p->isLocal())
{
- return false;
+ return false;
}
_useWstring = setUseWstring(p, _useWstringHist, _useWstring);
@@ -2100,21 +2100,21 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p)
H << sp << nl << "class " << _dllExport << name << " : ";
if(bases.empty())
{
- H << "virtual public ::IceDelegate::Ice::Object";
+ H << "virtual public ::IceDelegate::Ice::Object";
}
else
{
- H.useCurrentPosAsIndent();
- ClassList::const_iterator q = bases.begin();
- while(q != bases.end())
- {
- H << "virtual public ::IceDelegate" << fixKwd((*q)->scoped());
- if(++q != bases.end())
- {
- H << ',' << nl;
- }
- }
- H.restoreIndent();
+ H.useCurrentPosAsIndent();
+ ClassList::const_iterator q = bases.begin();
+ while(q != bases.end())
+ {
+ H << "virtual public ::IceDelegate" << fixKwd((*q)->scoped());
+ if(++q != bases.end())
+ {
+ H << ',' << nl;
+ }
+ }
+ H.restoreIndent();
}
H << sb;
H.dec();
@@ -2147,24 +2147,24 @@ Slice::Gen::DelegateVisitor::visitOperation(const OperationPtr& p)
{
StringList metaData = (*q)->getMetaData();
#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550)
- //
- // Work around for Sun CC 5.5 bug #4853566
- //
- string typeString;
- if((*q)->isOutParam())
- {
- typeString = outputTypeToString((*q)->type(), _useWstring, metaData);
- }
- else
- {
- typeString = inputTypeToString((*q)->type(), _useWstring, metaData);
- }
+ //
+ // Work around for Sun CC 5.5 bug #4853566
+ //
+ string typeString;
+ if((*q)->isOutParam())
+ {
+ typeString = outputTypeToString((*q)->type(), _useWstring, metaData);
+ }
+ else
+ {
+ typeString = inputTypeToString((*q)->type(), _useWstring, metaData);
+ }
#else
- string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), _useWstring, metaData)
- : inputTypeToString((*q)->type(), _useWstring, metaData);
+ string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), _useWstring, metaData)
+ : inputTypeToString((*q)->type(), _useWstring, metaData);
#endif
- params.push_back(typeString);
+ params.push_back(typeString);
}
params.push_back("const ::Ice::Context*");
@@ -2182,7 +2182,7 @@ Slice::Gen::DelegateMVisitor::visitUnitStart(const UnitPtr& p)
{
if(!p->hasNonLocalClassDecls())
{
- return false;
+ return false;
}
H << sp << nl << "namespace IceDelegateM" << nl << '{';
@@ -2201,7 +2201,7 @@ Slice::Gen::DelegateMVisitor::visitModuleStart(const ModulePtr& p)
{
if(!p->hasNonLocalClassDecls())
{
- return false;
+ return false;
}
_useWstring = setUseWstring(p, _useWstringHist, _useWstring);
@@ -2226,7 +2226,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
{
if(p->isLocal())
{
- return false;
+ return false;
}
_useWstring = setUseWstring(p, _useWstringHist, _useWstring);
@@ -2240,19 +2240,19 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
H << "virtual public ::IceDelegate" << scoped << ',';
if(bases.empty())
{
- H << nl << "virtual public ::IceDelegateM::Ice::Object";
+ H << nl << "virtual public ::IceDelegateM::Ice::Object";
}
else
{
- ClassList::const_iterator q = bases.begin();
- while(q != bases.end())
- {
- H << nl << "virtual public ::IceDelegateM" << fixKwd((*q)->scoped());
- if(++q != bases.end())
- {
- H << ',';
- }
- }
+ ClassList::const_iterator q = bases.begin();
+ while(q != bases.end())
+ {
+ H << nl << "virtual public ::IceDelegateM" << fixKwd((*q)->scoped());
+ if(++q != bases.end())
+ {
+ H << ',';
+ }
+ }
}
H.restoreIndent();
H << sb;
@@ -2288,24 +2288,24 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
ParamDeclList paramList = p->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- string paramName = fixKwd((*q)->name());
- TypePtr type = (*q)->type();
- bool isOutParam = (*q)->isOutParam();
- StringList metaData = (*q)->getMetaData();
- string typeString;
- if(isOutParam)
- {
- outParams.push_back(*q);
- typeString = outputTypeToString(type, _useWstring, metaData);
- }
- else
- {
- inParams.push_back(*q);
- typeString = inputTypeToString(type, _useWstring, metaData);
- }
-
- params.push_back(typeString);
- paramsDecl.push_back(typeString + ' ' + paramName);
+ string paramName = fixKwd((*q)->name());
+ TypePtr type = (*q)->type();
+ bool isOutParam = (*q)->isOutParam();
+ StringList metaData = (*q)->getMetaData();
+ string typeString;
+ if(isOutParam)
+ {
+ outParams.push_back(*q);
+ typeString = outputTypeToString(type, _useWstring, metaData);
+ }
+ else
+ {
+ inParams.push_back(*q);
+ typeString = inputTypeToString(type, _useWstring, metaData);
+ }
+
+ params.push_back(typeString);
+ paramsDecl.push_back(typeString + ' ' + paramName);
}
params.push_back("const ::Ice::Context*");
@@ -2320,19 +2320,19 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
<< operationModeToString(p->sendMode()) << ", __context, __compress);";
if(!inParams.empty())
{
- C << nl << "try";
- C << sb;
- C << nl << "::IceInternal::BasicStream* __os = __og.os();";
- writeMarshalCode(C, inParams, 0, StringList(), true);
- if(p->sendsClasses())
- {
- C << nl << "__os->writePendingObjects();";
- }
- C << eb;
- C << nl << "catch(const ::Ice::LocalException& __ex)";
- C << sb;
- C << nl << "__og.abort(__ex);";
- C << eb;
+ C << nl << "try";
+ C << sb;
+ C << nl << "::IceInternal::BasicStream* __os = __og.os();";
+ writeMarshalCode(C, inParams, 0, StringList(), true);
+ if(p->sendsClasses())
+ {
+ C << nl << "__os->writePendingObjects();";
+ }
+ C << eb;
+ C << nl << "catch(const ::Ice::LocalException& __ex)";
+ C << sb;
+ C << nl << "__og.abort(__ex);";
+ C << eb;
}
C << nl << "bool __ok = __og.invoke();";
C << nl << "try";
@@ -2378,10 +2378,10 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
#endif
for(ExceptionList::const_iterator i = throws.begin(); i != throws.end(); ++i)
{
- C << nl << "catch(const " << fixKwd((*i)->scoped()) << "&)";
- C << sb;
- C << nl << "throw;";
- C << eb;
+ C << nl << "catch(const " << fixKwd((*i)->scoped()) << "&)";
+ C << sb;
+ C << nl << "throw;";
+ C << eb;
}
C << nl << "catch(const ::Ice::UserException& __ex)";
C << sb;
@@ -2392,20 +2392,20 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
writeAllocateCode(C, ParamDeclList(), ret, p->getMetaData(), _useWstring);
for(ParamDeclList::const_iterator opi = outParams.begin(); opi != outParams.end(); ++opi)
{
- StructPtr st = StructPtr::dynamicCast((*opi)->type());
- if(st && findMetaData(st->getMetaData(), false) == "class")
- {
- C << nl << fixKwd((*opi)->name()) << " = new " << fixKwd(st->scoped()) << ";";
- }
+ StructPtr st = StructPtr::dynamicCast((*opi)->type());
+ if(st && findMetaData(st->getMetaData(), false) == "class")
+ {
+ C << nl << fixKwd((*opi)->name()) << " = new " << fixKwd(st->scoped()) << ";";
+ }
}
writeUnmarshalCode(C, outParams, ret, p->getMetaData());
if(p->returnsClasses())
{
- C << nl << "__is->readPendingObjects();";
+ C << nl << "__is->readPendingObjects();";
}
if(ret)
{
- C << nl << "return __ret;";
+ C << nl << "return __ret;";
}
C << eb;
C << nl << "catch(const ::Ice::LocalException& __ex)";
@@ -2425,7 +2425,7 @@ Slice::Gen::DelegateDVisitor::visitUnitStart(const UnitPtr& p)
{
if(!p->hasNonLocalClassDecls())
{
- return false;
+ return false;
}
H << sp << nl << "namespace IceDelegateD" << nl << '{';
@@ -2444,7 +2444,7 @@ Slice::Gen::DelegateDVisitor::visitModuleStart(const ModulePtr& p)
{
if(!p->hasNonLocalClassDecls())
{
- return false;
+ return false;
}
_useWstring = setUseWstring(p, _useWstringHist, _useWstring);
@@ -2469,7 +2469,7 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
{
if(p->isLocal())
{
- return false;
+ return false;
}
_useWstring = setUseWstring(p, _useWstringHist, _useWstring);
@@ -2483,19 +2483,19 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
H << "virtual public ::IceDelegate" << scoped << ',';
if(bases.empty())
{
- H << nl << "virtual public ::IceDelegateD::Ice::Object";
+ H << nl << "virtual public ::IceDelegateD::Ice::Object";
}
else
{
- ClassList::const_iterator q = bases.begin();
- while(q != bases.end())
- {
- H << nl << "virtual public ::IceDelegateD" << fixKwd((*q)->scoped());
- if(++q != bases.end())
- {
- H << ',';
- }
- }
+ ClassList::const_iterator q = bases.begin();
+ while(q != bases.end())
+ {
+ H << nl << "virtual public ::IceDelegateD" << fixKwd((*q)->scoped());
+ if(++q != bases.end())
+ {
+ H << ',';
+ }
+ }
}
H.restoreIndent();
H << sb;
@@ -2530,30 +2530,30 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p)
ParamDeclList paramList = p->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- string paramName = fixKwd((*q)->name());
+ string paramName = fixKwd((*q)->name());
- StringList metaData = (*q)->getMetaData();
+ StringList metaData = (*q)->getMetaData();
#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550)
- //
- // Work around for Sun CC 5.5 bug #4853566
- //
- string typeString;
- if((*q)->isOutParam())
- {
- typeString = outputTypeToString((*q)->type(), _useWstring, metaData);
- }
- else
- {
- typeString = inputTypeToString((*q)->type(), _useWstring, metaData);
- }
+ //
+ // Work around for Sun CC 5.5 bug #4853566
+ //
+ string typeString;
+ if((*q)->isOutParam())
+ {
+ typeString = outputTypeToString((*q)->type(), _useWstring, metaData);
+ }
+ else
+ {
+ typeString = inputTypeToString((*q)->type(), _useWstring, metaData);
+ }
#else
- string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), _useWstring, metaData)
- : inputTypeToString((*q)->type(), _useWstring, metaData);
+ string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), _useWstring, metaData)
+ : inputTypeToString((*q)->type(), _useWstring, metaData);
#endif
- params.push_back(typeString);
- paramsDecl.push_back(typeString + ' ' + paramName);
- args.push_back(paramName);
+ params.push_back(typeString);
+ paramsDecl.push_back(typeString + ' ' + paramName);
+ args.push_back(paramName);
}
params.push_back("const ::Ice::Context*");
@@ -2570,70 +2570,70 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p)
bool amd = !cl->isLocal() && (cl->hasMetaData("amd") || p->hasMetaData("amd"));
if(amd)
{
- C << sp << nl << retS << nl << "IceDelegateD" << scoped << spar << params << epar;
- C << sb;
- C << nl << "throw ::Ice::CollocationOptimizationException(__FILE__, __LINE__);";
- if(ret != 0)
- {
- C << nl << "return " << retS << "(); // to avoid a warning with some compilers;";
- }
- C << eb;
+ C << sp << nl << retS << nl << "IceDelegateD" << scoped << spar << params << epar;
+ C << sb;
+ C << nl << "throw ::Ice::CollocationOptimizationException(__FILE__, __LINE__);";
+ if(ret != 0)
+ {
+ C << nl << "return " << retS << "(); // to avoid a warning with some compilers;";
+ }
+ C << eb;
}
else
{
- C << sp << nl << retS << nl << "IceDelegateD" << scoped << spar << paramsDecl << epar;
- C << sb;
- C << nl << "::Ice::Current __current;";
- C << nl << "__initCurrent(__current, " << p->flattenedScope() + p->name() + "_name, "
- << operationModeToString(p->sendMode()) << ", __context);";
- C << nl << "while(true)";
- C << sb;
- C << nl << "::IceInternal::Direct __direct(__current);";
- if(ret)
- {
- C << nl << retS << " __ret;";
- }
- C << nl << "try";
- C << sb;
- C << nl << thisPointer << " __servant = dynamic_cast< " << thisPointer << ">(__direct.servant().get());";
- C << nl << "if(!__servant)";
- C << sb;
- C << nl << "::Ice::OperationNotExistException __opEx(__FILE__, __LINE__);";
- C << nl << "__opEx.id = __current.id;";
- C << nl << "__opEx.facet = __current.facet;";
- C << nl << "__opEx.operation = __current.operation;";
- C << nl << "throw __opEx;";
- C << eb;
+ C << sp << nl << retS << nl << "IceDelegateD" << scoped << spar << paramsDecl << epar;
+ C << sb;
+ C << nl << "::Ice::Current __current;";
+ C << nl << "__initCurrent(__current, " << p->flattenedScope() + p->name() + "_name, "
+ << operationModeToString(p->sendMode()) << ", __context);";
+ C << nl << "while(true)";
+ C << sb;
+ C << nl << "::IceInternal::Direct __direct(__current);";
+ if(ret)
+ {
+ C << nl << retS << " __ret;";
+ }
+ C << nl << "try";
+ C << sb;
+ C << nl << thisPointer << " __servant = dynamic_cast< " << thisPointer << ">(__direct.servant().get());";
+ C << nl << "if(!__servant)";
+ C << sb;
+ C << nl << "::Ice::OperationNotExistException __opEx(__FILE__, __LINE__);";
+ C << nl << "__opEx.id = __current.id;";
+ C << nl << "__opEx.facet = __current.facet;";
+ C << nl << "__opEx.operation = __current.operation;";
+ C << nl << "throw __opEx;";
+ C << eb;
C << nl << "try";
C << sb;
- C << nl;
- if(ret)
- {
- C << "__ret = ";
- }
- C << "__servant->" << name << spar << args << epar << ';';
- C << eb;
+ C << nl;
+ if(ret)
+ {
+ C << "__ret = ";
+ }
+ C << "__servant->" << name << spar << args << epar << ';';
+ C << eb;
C << nl << "catch(const ::Ice::LocalException& __ex)";
C << sb;
C << nl << "throw ::IceInternal::LocalExceptionWrapper(__ex, false);";
- C << eb;
- C << eb;
- C << nl << "catch(...)";
- C << sb;
- C << nl << "__direct.destroy();";
- C << nl << "throw;";
- C << eb;
- C << nl << "__direct.destroy();";
- if(ret)
- {
- C << nl << "return __ret;";
- }
- else
- {
- C << nl << "return;";
- }
- C << eb;
- C << eb;
+ C << eb;
+ C << eb;
+ C << nl << "catch(...)";
+ C << sb;
+ C << nl << "__direct.destroy();";
+ C << nl << "throw;";
+ C << eb;
+ C << nl << "__direct.destroy();";
+ if(ret)
+ {
+ C << nl << "return __ret;";
+ }
+ else
+ {
+ C << nl << "return;";
+ }
+ C << eb;
+ C << eb;
}
}
@@ -2647,7 +2647,7 @@ Slice::Gen::ObjectDeclVisitor::visitModuleStart(const ModulePtr& p)
{
if(!p->hasClassDecls())
{
- return false;
+ return false;
}
string name = fixKwd(p->name());
@@ -2694,7 +2694,7 @@ Slice::Gen::ObjectVisitor::visitModuleStart(const ModulePtr& p)
{
if(!p->hasClassDefs())
{
- return false;
+ return false;
}
_useWstring = setUseWstring(p, _useWstringHist, _useWstring);
@@ -2726,7 +2726,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
ClassDefPtr base;
if(!bases.empty() && !bases.front()->isInterface())
{
- base = bases.front();
+ base = bases.front();
}
DataMemberList dataMembers = p->dataMembers();
DataMemberList allDataMembers = p->allDataMembers();
@@ -2735,26 +2735,26 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
H.useCurrentPosAsIndent();
if(bases.empty())
{
- if(p->isLocal())
- {
- H << "virtual public ::Ice::LocalObject";
- }
- else
- {
- H << "virtual public ::Ice::Object";
- }
+ if(p->isLocal())
+ {
+ H << "virtual public ::Ice::LocalObject";
+ }
+ else
+ {
+ H << "virtual public ::Ice::Object";
+ }
}
else
{
- ClassList::const_iterator q = bases.begin();
- while(q != bases.end())
- {
- H << "virtual public " << fixKwd((*q)->scoped());
- if(++q != bases.end())
- {
- H << ',' << nl;
- }
- }
+ ClassList::const_iterator q = bases.begin();
+ while(q != bases.end())
+ {
+ H << "virtual public " << fixKwd((*q)->scoped());
+ if(++q != bases.end())
+ {
+ H << ',' << nl;
+ }
+ }
}
H.restoreIndent();
H << sb;
@@ -2776,249 +2776,249 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- params.push_back(fixKwd((*q)->name()));
+ params.push_back(fixKwd((*q)->name()));
}
for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q)
{
- string typeName = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData());
- allTypes.push_back(typeName);
- allParamDecls.push_back(typeName + " __ice_" + (*q)->name());
+ string typeName = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData());
+ allTypes.push_back(typeName);
+ allParamDecls.push_back(typeName + " __ice_" + (*q)->name());
}
if(!p->isInterface())
{
- H << nl << name << "() {}";
- if(!allParamDecls.empty())
- {
- H << nl;
- if(allParamDecls.size() == 1)
- {
- H << "explicit ";
- }
- H << name << spar << allTypes << epar << ';';
- }
-
- /*
- * Strong guarantee: commented-out code marked "Strong guarantee" generates
- * a copy-assignment operator that provides the strong exception guarantee.
- * For now, this is commented out, and we use the compiler-generated
- * copy-assignment operator. However, that one does not provide the strong
- * guarantee.
-
- H << ';';
- if(!p->isAbstract())
- {
- H << nl << name << "& operator=(const " << name << "&)";
- if(allDataMembers.empty())
- {
- H << " { return *this; }";
- }
- H << ';';
- }
-
- //
- // __swap() is static because classes may be abstract, so we
- // can't use a non-static member function when we do an upcall
- // from a non-abstract derived __swap to the __swap in an abstract base.
- //
- H << sp << nl << "static void __swap(" << name << "&, " << name << "&) throw()";
- if(allDataMembers.empty())
- {
- H << " {}";
- }
- H << ';';
- H << nl << "void swap(" << name << "& rhs) throw()";
- H << sb;
- if(!allDataMembers.empty())
- {
- H << nl << "__swap(*this, rhs);";
- }
- H << eb;
-
- * Strong guarantee
- */
+ H << nl << name << "() {}";
+ if(!allParamDecls.empty())
+ {
+ H << nl;
+ if(allParamDecls.size() == 1)
+ {
+ H << "explicit ";
+ }
+ H << name << spar << allTypes << epar << ';';
+ }
+
+ /*
+ * Strong guarantee: commented-out code marked "Strong guarantee" generates
+ * a copy-assignment operator that provides the strong exception guarantee.
+ * For now, this is commented out, and we use the compiler-generated
+ * copy-assignment operator. However, that one does not provide the strong
+ * guarantee.
+
+ H << ';';
+ if(!p->isAbstract())
+ {
+ H << nl << name << "& operator=(const " << name << "&)";
+ if(allDataMembers.empty())
+ {
+ H << " { return *this; }";
+ }
+ H << ';';
+ }
+
+ //
+ // __swap() is static because classes may be abstract, so we
+ // can't use a non-static member function when we do an upcall
+ // from a non-abstract derived __swap to the __swap in an abstract base.
+ //
+ H << sp << nl << "static void __swap(" << name << "&, " << name << "&) throw()";
+ if(allDataMembers.empty())
+ {
+ H << " {}";
+ }
+ H << ';';
+ H << nl << "void swap(" << name << "& rhs) throw()";
+ H << sb;
+ if(!allDataMembers.empty())
+ {
+ H << nl << "__swap(*this, rhs);";
+ }
+ H << eb;
+
+ * Strong guarantee
+ */
emitOneShotConstructor(p);
- /*
- * Strong guarantee
-
- if(!allDataMembers.empty())
- {
- C << sp << nl << "void";
- C << nl << scoped.substr(2) << "::__swap(" << name << "& __lhs, " << name << "& __rhs) throw()";
- C << sb;
-
- if(base)
- {
- emitUpcall(base, "::__swap(__lhs, __rhs);");
- }
-
- //
- // We use a map to remember for which types we have already declared
- // a temporary variable and reuse that variable if a class has
- // more than one member of the same type. That way, we don't use more
- // temporaries than necessary. (::std::swap() instantiates a new temporary
- // each time it is used.)
- //
- map<string, int> tmpMap;
- map<string, int>::iterator pos;
- int tmpCount = 0;
-
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- string memberName = fixKwd((*q)->name());
- TypePtr type = (*q)->type();
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
- if(builtin && builtin->kind() != Builtin::KindString
- || EnumPtr::dynamicCast(type) || ProxyPtr::dynamicCast(type)
- || ClassDeclPtr::dynamicCast(type) || StructPtr::dynamicCast(type))
- {
- //
- // For built-in types (except string), enums, proxies, structs, and classes,
- // do the swap via a temporary variable.
- //
- string typeName = typeToString(type);
- pos = tmpMap.find(typeName);
- if(pos == tmpMap.end())
- {
- pos = tmpMap.insert(pos, make_pair(typeName, tmpCount));
- C << nl << typeName << " __tmp" << tmpCount << ';';
- tmpCount++;
- }
- C << nl << "__tmp" << pos->second << " = __rhs." << memberName << ';';
- C << nl << "__rhs." << memberName << " = __lhs." << memberName << ';';
- C << nl << "__lhs." << memberName << " = __tmp" << pos->second << ';';
- }
- else
- {
- //
- // For dictionaries, vectors, and maps, use the standard container's
- // swap() (which is usually optimized).
- //
- C << nl << "__lhs." << memberName << ".swap(__rhs." << memberName << ");";
- }
- }
- C << eb;
-
- if(!p->isAbstract())
- {
- C << sp << nl << scoped << "&";
- C << nl << scoped.substr(2) << "::operator=(const " << name << "& __rhs)";
- C << sb;
- C << nl << name << " __tmp(__rhs);";
- C << nl << "__swap(*this, __tmp);";
- C << nl << "return *this;";
- C << eb;
- }
- }
-
- * Strong guarantee
- */
+ /*
+ * Strong guarantee
+
+ if(!allDataMembers.empty())
+ {
+ C << sp << nl << "void";
+ C << nl << scoped.substr(2) << "::__swap(" << name << "& __lhs, " << name << "& __rhs) throw()";
+ C << sb;
+
+ if(base)
+ {
+ emitUpcall(base, "::__swap(__lhs, __rhs);");
+ }
+
+ //
+ // We use a map to remember for which types we have already declared
+ // a temporary variable and reuse that variable if a class has
+ // more than one member of the same type. That way, we don't use more
+ // temporaries than necessary. (::std::swap() instantiates a new temporary
+ // each time it is used.)
+ //
+ map<string, int> tmpMap;
+ map<string, int>::iterator pos;
+ int tmpCount = 0;
+
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ string memberName = fixKwd((*q)->name());
+ TypePtr type = (*q)->type();
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
+ if(builtin && builtin->kind() != Builtin::KindString
+ || EnumPtr::dynamicCast(type) || ProxyPtr::dynamicCast(type)
+ || ClassDeclPtr::dynamicCast(type) || StructPtr::dynamicCast(type))
+ {
+ //
+ // For built-in types (except string), enums, proxies, structs, and classes,
+ // do the swap via a temporary variable.
+ //
+ string typeName = typeToString(type);
+ pos = tmpMap.find(typeName);
+ if(pos == tmpMap.end())
+ {
+ pos = tmpMap.insert(pos, make_pair(typeName, tmpCount));
+ C << nl << typeName << " __tmp" << tmpCount << ';';
+ tmpCount++;
+ }
+ C << nl << "__tmp" << pos->second << " = __rhs." << memberName << ';';
+ C << nl << "__rhs." << memberName << " = __lhs." << memberName << ';';
+ C << nl << "__lhs." << memberName << " = __tmp" << pos->second << ';';
+ }
+ else
+ {
+ //
+ // For dictionaries, vectors, and maps, use the standard container's
+ // swap() (which is usually optimized).
+ //
+ C << nl << "__lhs." << memberName << ".swap(__rhs." << memberName << ");";
+ }
+ }
+ C << eb;
+
+ if(!p->isAbstract())
+ {
+ C << sp << nl << scoped << "&";
+ C << nl << scoped.substr(2) << "::operator=(const " << name << "& __rhs)";
+ C << sb;
+ C << nl << name << " __tmp(__rhs);";
+ C << nl << "__swap(*this, __tmp);";
+ C << nl << "return *this;";
+ C << eb;
+ }
+ }
+
+ * Strong guarantee
+ */
}
if(!p->isLocal())
{
- H << nl << "virtual ::Ice::ObjectPtr ice_clone() const;";
-
- C << sp;
- C << nl << "::Ice::ObjectPtr";
- C << nl << fixKwd(p->scoped()).substr(2) << "::ice_clone() const";
- C << sb;
- if(!p->isAbstract())
- {
- C << nl << fixKwd(p->scope()) << p->name() << "Ptr __p = new " << fixKwd(p->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;
-
- ClassList allBases = p->allBases();
- StringList ids;
+ H << nl << "virtual ::Ice::ObjectPtr ice_clone() const;";
+
+ C << sp;
+ C << nl << "::Ice::ObjectPtr";
+ C << nl << fixKwd(p->scoped()).substr(2) << "::ice_clone() const";
+ C << sb;
+ if(!p->isAbstract())
+ {
+ C << nl << fixKwd(p->scope()) << p->name() << "Ptr __p = new " << fixKwd(p->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;
+
+ ClassList allBases = p->allBases();
+ StringList ids;
#if defined(__IBMCPP__) && defined(NDEBUG)
//
// VisualAge C++ 6.0 does not see that ClassDef is a Contained,
// when inlining is on. The code below issues a warning: better
// than an error!
//
- transform(allBases.begin(), allBases.end(), back_inserter(ids), ::IceUtil::constMemFun<string,ClassDef>(&Contained::scoped));
+ transform(allBases.begin(), allBases.end(), back_inserter(ids), ::IceUtil::constMemFun<string,ClassDef>(&Contained::scoped));
#else
- transform(allBases.begin(), allBases.end(), back_inserter(ids), ::IceUtil::constMemFun(&Contained::scoped));
+ transform(allBases.begin(), allBases.end(), back_inserter(ids), ::IceUtil::constMemFun(&Contained::scoped));
#endif
- StringList other;
- other.push_back(p->scoped());
- other.push_back("::Ice::Object");
- other.sort();
- ids.merge(other);
- ids.unique();
+ StringList other;
+ other.push_back(p->scoped());
+ other.push_back("::Ice::Object");
+ other.sort();
+ ids.merge(other);
+ ids.unique();
StringList::const_iterator firstIter = ids.begin();
StringList::const_iterator scopedIter = find(ids.begin(), ids.end(), p->scoped());
assert(scopedIter != ids.end());
StringList::difference_type scopedPos = ice_distance(firstIter, scopedIter);
- H << sp;
- H << nl << "virtual bool ice_isA"
- << "(const ::std::string&, const ::Ice::Current& = ::Ice::Current()) const;";
- H << nl << "virtual ::std::vector< ::std::string> ice_ids"
- << "(const ::Ice::Current& = ::Ice::Current()) const;";
- H << nl << "virtual const ::std::string& ice_id(const ::Ice::Current& = ::Ice::Current()) const;";
- H << nl << "static const ::std::string& ice_staticId();";
- if(!dataMembers.empty())
- {
- H << sp;
- }
-
- string flatName = p->flattenedScope() + p->name() + "_ids";
-
- C << sp;
- C << nl << "static const ::std::string " << flatName << '[' << ids.size() << "] =";
- C << sb;
-
- StringList::const_iterator r = ids.begin();
- while(r != ids.end())
- {
- C << nl << '"' << *r << '"';
- if(++r != ids.end())
- {
- C << ',';
- }
- }
- C << eb << ';';
-
- C << sp;
- C << nl << "bool" << nl << fixKwd(p->scoped()).substr(2)
+ H << sp;
+ H << nl << "virtual bool ice_isA"
+ << "(const ::std::string&, const ::Ice::Current& = ::Ice::Current()) const;";
+ H << nl << "virtual ::std::vector< ::std::string> ice_ids"
+ << "(const ::Ice::Current& = ::Ice::Current()) const;";
+ H << nl << "virtual const ::std::string& ice_id(const ::Ice::Current& = ::Ice::Current()) const;";
+ H << nl << "static const ::std::string& ice_staticId();";
+ if(!dataMembers.empty())
+ {
+ H << sp;
+ }
+
+ string flatName = p->flattenedScope() + p->name() + "_ids";
+
+ C << sp;
+ C << nl << "static const ::std::string " << flatName << '[' << ids.size() << "] =";
+ C << sb;
+
+ StringList::const_iterator r = ids.begin();
+ while(r != ids.end())
+ {
+ C << nl << '"' << *r << '"';
+ if(++r != ids.end())
+ {
+ C << ',';
+ }
+ }
+ C << eb << ';';
+
+ C << sp;
+ C << nl << "bool" << nl << fixKwd(p->scoped()).substr(2)
<< "::ice_isA(const ::std::string& _s, const ::Ice::Current&) const";
- C << sb;
- C << nl << "return ::std::binary_search(" << flatName << ", " << flatName << " + " << ids.size() << ", _s);";
- C << eb;
-
- C << sp;
- C << nl << "::std::vector< ::std::string>" << nl << fixKwd(p->scoped()).substr(2)
- << "::ice_ids(const ::Ice::Current&) const";
- C << sb;
- C << nl << "return ::std::vector< ::std::string>(&" << flatName << "[0], &" << flatName
- << '[' << ids.size() << "]);";
- C << eb;
-
- C << sp;
- C << nl << "const ::std::string&" << nl << fixKwd(p->scoped()).substr(2)
- << "::ice_id(const ::Ice::Current&) const";
- C << sb;
- C << nl << "return " << flatName << '[' << scopedPos << "];";
- C << eb;
-
- C << sp;
- C << nl << "const ::std::string&" << nl << fixKwd(p->scoped()).substr(2) << "::ice_staticId()";
- C << sb;
- C << nl << "return " << flatName << '[' << scopedPos << "];";
- C << eb;
-
- emitGCFunctions(p);
+ C << sb;
+ C << nl << "return ::std::binary_search(" << flatName << ", " << flatName << " + " << ids.size() << ", _s);";
+ C << eb;
+
+ C << sp;
+ C << nl << "::std::vector< ::std::string>" << nl << fixKwd(p->scoped()).substr(2)
+ << "::ice_ids(const ::Ice::Current&) const";
+ C << sb;
+ C << nl << "return ::std::vector< ::std::string>(&" << flatName << "[0], &" << flatName
+ << '[' << ids.size() << "]);";
+ C << eb;
+
+ C << sp;
+ C << nl << "const ::std::string&" << nl << fixKwd(p->scoped()).substr(2)
+ << "::ice_id(const ::Ice::Current&) const";
+ C << sb;
+ C << nl << "return " << flatName << '[' << scopedPos << "];";
+ C << eb;
+
+ C << sp;
+ C << nl << "const ::std::string&" << nl << fixKwd(p->scoped()).substr(2) << "::ice_staticId()";
+ C << sb;
+ C << nl << "return " << flatName << '[' << scopedPos << "];";
+ C << eb;
+
+ emitGCFunctions(p);
}
return true;
@@ -3031,383 +3031,383 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
string scope = fixKwd(p->scope());
if(!p->isLocal())
- {
- ClassList bases = p->bases();
- ClassDefPtr base;
- if(!bases.empty() && !bases.front()->isInterface())
- {
- base = bases.front();
- }
+ {
+ ClassList bases = p->bases();
+ ClassDefPtr base;
+ if(!bases.empty() && !bases.front()->isInterface())
+ {
+ base = bases.front();
+ }
- OperationList allOps = p->allOperations();
- if(!allOps.empty())
- {
- StringList allOpNames;
+ OperationList allOps = p->allOperations();
+ if(!allOps.empty())
+ {
+ StringList allOpNames;
#if defined(__IBMCPP__) && defined(NDEBUG)
//
// See comment for transform above
//
- transform(allOps.begin(), allOps.end(), back_inserter(allOpNames),
- ::IceUtil::constMemFun<string,Operation>(&Contained::name));
+ transform(allOps.begin(), allOps.end(), back_inserter(allOpNames),
+ ::IceUtil::constMemFun<string,Operation>(&Contained::name));
#else
- transform(allOps.begin(), allOps.end(), back_inserter(allOpNames),
+ transform(allOps.begin(), allOps.end(), back_inserter(allOpNames),
::IceUtil::constMemFun(&Contained::name));
#endif
- allOpNames.push_back("ice_id");
- allOpNames.push_back("ice_ids");
- allOpNames.push_back("ice_isA");
- allOpNames.push_back("ice_ping");
- allOpNames.sort();
- allOpNames.unique();
-
- StringList::const_iterator q;
-
- H << sp;
- H << nl
- << "virtual ::IceInternal::DispatchStatus __dispatch(::IceInternal::Incoming&, const ::Ice::Current&);";
-
- string flatName = p->flattenedScope() + p->name() + "_all";
- C << sp;
- C << nl << "static ::std::string " << flatName << "[] =";
- C << sb;
- q = allOpNames.begin();
- while(q != allOpNames.end())
- {
- C << nl << '"' << *q << '"';
- if(++q != allOpNames.end())
- {
- C << ',';
- }
- }
- C << eb << ';';
- C << sp;
- C << nl << "::IceInternal::DispatchStatus" << nl << scoped.substr(2)
- << "::__dispatch(::IceInternal::Incoming& in, const ::Ice::Current& current)";
- C << sb;
-
- C << nl << "::std::pair< ::std::string*, ::std::string*> r = "
- << "::std::equal_range(" << flatName << ", " << flatName << " + " << allOpNames.size()
- << ", current.operation);";
- C << nl << "if(r.first == r.second)";
- C << sb;
- C << nl << "return ::IceInternal::DispatchOperationNotExist;";
- C << eb;
- C << sp;
- C << nl << "switch(r.first - " << flatName << ')';
- C << sb;
- int i = 0;
- for(q = allOpNames.begin(); q != allOpNames.end(); ++q)
- {
- C << nl << "case " << i++ << ':';
- C << sb;
- C << nl << "return ___" << *q << "(in, current);";
- C << eb;
- }
- C << eb;
- C << sp;
- C << nl << "assert(false);";
- C << nl << "return ::IceInternal::DispatchOperationNotExist;";
- C << eb;
-
-
- //
- // Check if we need to generate ice_operationAttributes()
- //
-
- StringList freezeWriteOpNames;
- for(OperationList::iterator r = allOps.begin(); r != allOps.end(); ++r)
- {
- ClassDefPtr classDef = ClassDefPtr::dynamicCast((*r)->container());
- assert(classDef != 0);
-
- if((*r)->hasMetaData("freeze:write") ||
- (classDef->hasMetaData("freeze:write") && !(*r)->hasMetaData("freeze:read")))
- {
- freezeWriteOpNames.push_back((*r)->name());
- }
- }
-
- if(!freezeWriteOpNames.empty())
- {
- freezeWriteOpNames.sort();
-
- H << sp;
- H << nl
- << "virtual ::Ice::Int ice_operationAttributes(const ::std::string&) const;";
-
- flatName = p->flattenedScope() + p->name() + "_freezeWriteOperations";
- C << sp;
- C << nl << "static ::std::string " << flatName << "[] =";
- C << sb;
- q = freezeWriteOpNames.begin();
- while(q != freezeWriteOpNames.end())
- {
- C << nl << '"' << *q << '"';
- if(++q != freezeWriteOpNames.end())
- {
- C << ',';
- }
- }
- C << eb << ';';
- C << sp;
-
- C << nl << "::Ice::Int" << nl << scoped.substr(2)
- << "::ice_operationAttributes(const ::std::string& opName) const";
- C << sb;
-
- C << nl << "::std::string* end = " << flatName << " + " << freezeWriteOpNames.size() << ";";
- C << nl << "::std::string* r = ::std::find(" << flatName << ", end, opName);";
-
- C << nl << "return r == end ? 0 : 1;";
- C << eb;
- }
- }
-
- H << sp;
- H << nl << "virtual void __write(::IceInternal::BasicStream*) const;";
- H << nl << "virtual void __read(::IceInternal::BasicStream*, bool);";
+ allOpNames.push_back("ice_id");
+ allOpNames.push_back("ice_ids");
+ allOpNames.push_back("ice_isA");
+ allOpNames.push_back("ice_ping");
+ allOpNames.sort();
+ allOpNames.unique();
+
+ StringList::const_iterator q;
+
+ H << sp;
+ H << nl
+ << "virtual ::IceInternal::DispatchStatus __dispatch(::IceInternal::Incoming&, const ::Ice::Current&);";
+
+ string flatName = p->flattenedScope() + p->name() + "_all";
+ C << sp;
+ C << nl << "static ::std::string " << flatName << "[] =";
+ C << sb;
+ q = allOpNames.begin();
+ while(q != allOpNames.end())
+ {
+ C << nl << '"' << *q << '"';
+ if(++q != allOpNames.end())
+ {
+ C << ',';
+ }
+ }
+ C << eb << ';';
+ C << sp;
+ C << nl << "::IceInternal::DispatchStatus" << nl << scoped.substr(2)
+ << "::__dispatch(::IceInternal::Incoming& in, const ::Ice::Current& current)";
+ C << sb;
+
+ C << nl << "::std::pair< ::std::string*, ::std::string*> r = "
+ << "::std::equal_range(" << flatName << ", " << flatName << " + " << allOpNames.size()
+ << ", current.operation);";
+ C << nl << "if(r.first == r.second)";
+ C << sb;
+ C << nl << "return ::IceInternal::DispatchOperationNotExist;";
+ C << eb;
+ C << sp;
+ C << nl << "switch(r.first - " << flatName << ')';
+ C << sb;
+ int i = 0;
+ for(q = allOpNames.begin(); q != allOpNames.end(); ++q)
+ {
+ C << nl << "case " << i++ << ':';
+ C << sb;
+ C << nl << "return ___" << *q << "(in, current);";
+ C << eb;
+ }
+ C << eb;
+ C << sp;
+ C << nl << "assert(false);";
+ C << nl << "return ::IceInternal::DispatchOperationNotExist;";
+ C << eb;
+
+
+ //
+ // Check if we need to generate ice_operationAttributes()
+ //
+
+ StringList freezeWriteOpNames;
+ for(OperationList::iterator r = allOps.begin(); r != allOps.end(); ++r)
+ {
+ ClassDefPtr classDef = ClassDefPtr::dynamicCast((*r)->container());
+ assert(classDef != 0);
+
+ if((*r)->hasMetaData("freeze:write") ||
+ (classDef->hasMetaData("freeze:write") && !(*r)->hasMetaData("freeze:read")))
+ {
+ freezeWriteOpNames.push_back((*r)->name());
+ }
+ }
+
+ if(!freezeWriteOpNames.empty())
+ {
+ freezeWriteOpNames.sort();
+
+ H << sp;
+ H << nl
+ << "virtual ::Ice::Int ice_operationAttributes(const ::std::string&) const;";
+
+ flatName = p->flattenedScope() + p->name() + "_freezeWriteOperations";
+ C << sp;
+ C << nl << "static ::std::string " << flatName << "[] =";
+ C << sb;
+ q = freezeWriteOpNames.begin();
+ while(q != freezeWriteOpNames.end())
+ {
+ C << nl << '"' << *q << '"';
+ if(++q != freezeWriteOpNames.end())
+ {
+ C << ',';
+ }
+ }
+ C << eb << ';';
+ C << sp;
+
+ C << nl << "::Ice::Int" << nl << scoped.substr(2)
+ << "::ice_operationAttributes(const ::std::string& opName) const";
+ C << sb;
+
+ C << nl << "::std::string* end = " << flatName << " + " << freezeWriteOpNames.size() << ";";
+ C << nl << "::std::string* r = ::std::find(" << flatName << ", end, opName);";
+
+ C << nl << "return r == end ? 0 : 1;";
+ C << eb;
+ }
+ }
+
+ H << sp;
+ H << nl << "virtual void __write(::IceInternal::BasicStream*) const;";
+ H << nl << "virtual void __read(::IceInternal::BasicStream*, bool);";
H << nl << "virtual void __write(const ::Ice::OutputStreamPtr&) const;";
H << nl << "virtual void __read(const ::Ice::InputStreamPtr&, bool);";
- C << sp;
- C << nl << "void" << nl << scoped.substr(2)
+ C << sp;
+ C << nl << "void" << nl << scoped.substr(2)
<< "::__write(::IceInternal::BasicStream* __os) const";
- C << sb;
- C << nl << "__os->writeTypeId(ice_staticId());";
- C << nl << "__os->startWriteSlice();";
- DataMemberList dataMembers = p->dataMembers();
- DataMemberList::const_iterator q;
+ C << sb;
+ C << nl << "__os->writeTypeId(ice_staticId());";
+ C << nl << "__os->startWriteSlice();";
+ DataMemberList dataMembers = p->dataMembers();
+ DataMemberList::const_iterator q;
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), true, "", true, (*q)->getMetaData());
}
- C << nl << "__os->endWriteSlice();";
- emitUpcall(base, "::__write(__os);");
- C << eb;
- C << sp;
- C << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is, bool __rid)";
- C << sb;
- C << nl << "if(__rid)";
- C << sb;
- C << nl << "::std::string myId;";
- C << nl << "__is->readTypeId(myId);";
- C << eb;
- C << nl << "__is->startReadSlice();";
+ C << nl << "__os->endWriteSlice();";
+ emitUpcall(base, "::__write(__os);");
+ C << eb;
+ C << sp;
+ C << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is, bool __rid)";
+ C << sb;
+ C << nl << "if(__rid)";
+ C << sb;
+ C << nl << "::std::string myId;";
+ C << nl << "__is->readTypeId(myId);";
+ C << eb;
+ C << nl << "__is->startReadSlice();";
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), false, "", true, (*q)->getMetaData());
}
- C << nl << "__is->endReadSlice();";
- emitUpcall(base, "::__read(__is, true);");
- C << eb;
-
- if(_stream)
- {
- C << sp;
- C << nl << "void" << nl << scoped.substr(2) << "::__write(const ::Ice::OutputStreamPtr& __outS) const";
- C << sb;
- C << nl << "__outS->writeTypeId(ice_staticId());";
- C << nl << "__outS->startSlice();";
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), true, "", _useWstring,
- (*q)->getMetaData());
- }
- C << nl << "__outS->endSlice();";
- emitUpcall(base, "::__write(__outS);");
- C << eb;
- C << sp;
- C << nl << "void" << nl << scoped.substr(2) << "::__read(const ::Ice::InputStreamPtr& __inS, bool __rid)";
- C << sb;
- C << nl << "if(__rid)";
- C << sb;
- C << nl << "__inS->readTypeId();";
- C << eb;
- C << nl << "__inS->startSlice();";
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), false, "", _useWstring,
- (*q)->getMetaData());
- }
- C << nl << "__inS->endSlice();";
- emitUpcall(base, "::__read(__inS, true);");
- C << eb;
- }
+ C << nl << "__is->endReadSlice();";
+ emitUpcall(base, "::__read(__is, true);");
+ C << eb;
+
+ if(_stream)
+ {
+ C << sp;
+ C << nl << "void" << nl << scoped.substr(2) << "::__write(const ::Ice::OutputStreamPtr& __outS) const";
+ C << sb;
+ C << nl << "__outS->writeTypeId(ice_staticId());";
+ C << nl << "__outS->startSlice();";
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), true, "", _useWstring,
+ (*q)->getMetaData());
+ }
+ C << nl << "__outS->endSlice();";
+ emitUpcall(base, "::__write(__outS);");
+ C << eb;
+ C << sp;
+ C << nl << "void" << nl << scoped.substr(2) << "::__read(const ::Ice::InputStreamPtr& __inS, bool __rid)";
+ C << sb;
+ C << nl << "if(__rid)";
+ C << sb;
+ C << nl << "__inS->readTypeId();";
+ C << eb;
+ C << nl << "__inS->startSlice();";
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeStreamMarshalUnmarshalCode(C, (*q)->type(), (*q)->name(), false, "", _useWstring,
+ (*q)->getMetaData());
+ }
+ C << nl << "__inS->endSlice();";
+ emitUpcall(base, "::__read(__inS, true);");
+ C << eb;
+ }
else
- {
+ {
//
// Emit placeholder functions to catch errors.
//
- C << sp;
- C << nl << "void" << nl << scoped.substr(2) << "::__write(const ::Ice::OutputStreamPtr&) const";
- C << sb;
+ C << sp;
+ C << nl << "void" << nl << scoped.substr(2) << "::__write(const ::Ice::OutputStreamPtr&) const";
+ C << sb;
C << nl << "Ice::MarshalException ex(__FILE__, __LINE__);";
C << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\";";
C << nl << "throw ex;";
- C << eb;
- C << sp;
- C << nl << "void" << nl << scoped.substr(2) << "::__read(const ::Ice::InputStreamPtr&, bool)";
- C << sb;
+ C << eb;
+ C << sp;
+ C << nl << "void" << nl << scoped.substr(2) << "::__read(const ::Ice::InputStreamPtr&, bool)";
+ C << sb;
C << nl << "Ice::MarshalException ex(__FILE__, __LINE__);";
C << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\";";
C << nl << "throw ex;";
- C << eb;
- }
-
- if(!p->isAbstract())
- {
- H << sp << nl << "static const ::Ice::ObjectFactoryPtr& ice_factory();";
-
- string factoryName = "__F" + p->flattenedScope() + p->name();
- C << sp;
- C << nl << "class " << factoryName << " : public ::Ice::ObjectFactory";
- C << sb;
- C.dec();
- C << nl << "public:";
- C.inc();
- C << sp << nl << "virtual ::Ice::ObjectPtr" << nl << "create(const ::std::string& type)";
- C << sb;
- C << nl << "assert(type == " << scoped << "::ice_staticId());";
- C << nl << "return new " << scoped << ';';
- C << eb;
- C << sp << nl << "virtual void" << nl << "destroy()";
- C << sb;
- C << eb;
- C << eb << ';';
-
- string flatName = factoryName + "_Ptr";
- C << sp;
- C << nl << "static ::Ice::ObjectFactoryPtr " << flatName << " = new " << factoryName << ';';
-
- C << sp << nl << "const ::Ice::ObjectFactoryPtr&" << nl << scoped.substr(2) << "::ice_factory()";
- C << sb;
- C << nl << "return " << flatName << ';';
- C << eb;
-
- C << sp;
- C << nl << "class " << factoryName << "__Init";
- C << sb;
- C.dec();
- C << nl << "public:";
- C.inc();
- C << sp << nl << factoryName << "__Init()";
- C << sb;
- C << nl << "::IceInternal::factoryTable->addObjectFactory(" << scoped << "::ice_staticId(), "
- << scoped << "::ice_factory());";
- C << eb;
- C << sp << nl << "~" << factoryName << "__Init()";
- C << sb;
- C << nl << "::IceInternal::factoryTable->removeObjectFactory(" << scoped << "::ice_staticId());";
- C << eb;
- C << eb << ';';
-
- C << sp;
- C << nl << "static " << factoryName << "__Init " << factoryName << "__i;";
- C << sp << nl << "#ifdef __APPLE__";
- std::string initfuncname = "__F" + p->flattenedScope() + p->name() + "__initializer";
- C << nl << "extern \"C\" { void " << initfuncname << "() {} }";
- C << nl << "#endif";
- }
+ C << eb;
+ }
+
+ if(!p->isAbstract())
+ {
+ H << sp << nl << "static const ::Ice::ObjectFactoryPtr& ice_factory();";
+
+ string factoryName = "__F" + p->flattenedScope() + p->name();
+ C << sp;
+ C << nl << "class " << factoryName << " : public ::Ice::ObjectFactory";
+ C << sb;
+ C.dec();
+ C << nl << "public:";
+ C.inc();
+ C << sp << nl << "virtual ::Ice::ObjectPtr" << nl << "create(const ::std::string& type)";
+ C << sb;
+ C << nl << "assert(type == " << scoped << "::ice_staticId());";
+ C << nl << "return new " << scoped << ';';
+ C << eb;
+ C << sp << nl << "virtual void" << nl << "destroy()";
+ C << sb;
+ C << eb;
+ C << eb << ';';
+
+ string flatName = factoryName + "_Ptr";
+ C << sp;
+ C << nl << "static ::Ice::ObjectFactoryPtr " << flatName << " = new " << factoryName << ';';
+
+ C << sp << nl << "const ::Ice::ObjectFactoryPtr&" << nl << scoped.substr(2) << "::ice_factory()";
+ C << sb;
+ C << nl << "return " << flatName << ';';
+ C << eb;
+
+ C << sp;
+ C << nl << "class " << factoryName << "__Init";
+ C << sb;
+ C.dec();
+ C << nl << "public:";
+ C.inc();
+ C << sp << nl << factoryName << "__Init()";
+ C << sb;
+ C << nl << "::IceInternal::factoryTable->addObjectFactory(" << scoped << "::ice_staticId(), "
+ << scoped << "::ice_factory());";
+ C << eb;
+ C << sp << nl << "~" << factoryName << "__Init()";
+ C << sb;
+ C << nl << "::IceInternal::factoryTable->removeObjectFactory(" << scoped << "::ice_staticId());";
+ C << eb;
+ C << eb << ';';
+
+ C << sp;
+ C << nl << "static " << factoryName << "__Init " << factoryName << "__i;";
+ C << sp << nl << "#ifdef __APPLE__";
+ std::string initfuncname = "__F" + p->flattenedScope() + p->name() + "__initializer";
+ C << nl << "extern \"C\" { void " << initfuncname << "() {} }";
+ C << nl << "#endif";
+ }
}
if(!p->isAbstract())
{
- //
- // We add a protected destructor to force heap instantiation of the class.
- //
- H.dec();
- H << sp << nl << "protected:";
- H.inc();
- H << sp << nl << "virtual ~" << fixKwd(p->name()) << "() {}";
+ //
+ // We add a protected destructor to force heap instantiation of the class.
+ //
+ H.dec();
+ H << sp << nl << "protected:";
+ H.inc();
+ H << sp << nl << "virtual ~" << fixKwd(p->name()) << "() {}";
- if(!_doneStaticSymbol)
- {
- H << sp << nl << "friend class " << p->name() << "__staticInit;";
- }
+ if(!_doneStaticSymbol)
+ {
+ H << sp << nl << "friend class " << p->name() << "__staticInit;";
+ }
}
H << eb << ';';
if(!p->isAbstract() && !_doneStaticSymbol)
{
- //
- // We need an instance here to trigger initialization if the implementation is in a shared library.
- // But we do this only once per source file, because a single instance is sufficient to initialize
- // all of the globals in a shared library.
- // For a Slice class Foo, we instantiate a dummy class Foo__staticInit instead of using a static
- // Foo instance directly because Foo has a protected destructor.
- //
- H << sp << nl << "class " << p->name() << "__staticInit";
- H << sb;
- H.dec();
- H << nl << "public:";
- H.inc();
- H << sp << nl << scoped << " _init;";
- H << eb << ';';
- _doneStaticSymbol = true;
- H << sp << nl << "static " << scoped << "__staticInit _" << p->name() << "_init;";
+ //
+ // We need an instance here to trigger initialization if the implementation is in a shared library.
+ // But we do this only once per source file, because a single instance is sufficient to initialize
+ // all of the globals in a shared library.
+ // For a Slice class Foo, we instantiate a dummy class Foo__staticInit instead of using a static
+ // Foo instance directly because Foo has a protected destructor.
+ //
+ H << sp << nl << "class " << p->name() << "__staticInit";
+ H << sb;
+ H.dec();
+ H << nl << "public:";
+ H.inc();
+ H << sp << nl << scoped << " _init;";
+ H << eb << ';';
+ _doneStaticSymbol = true;
+ H << sp << nl << "static " << scoped << "__staticInit _" << p->name() << "_init;";
}
if(p->isLocal())
{
- C << sp;
- C << nl << "bool" << nl << scope.substr(2) << "operator==(const " << scoped
- << "& l, const " << scoped << "& r)";
- C << sb;
- C << nl << "return static_cast<const ::Ice::LocalObject&>(l) == static_cast<const ::Ice::LocalObject&>(r);";
- C << eb;
- C << sp;
- C << nl << "bool" << nl << scope.substr(2) << "operator!=(const " << scoped
- << "& l, const " << scoped << "& r)";
- C << sb;
- C << nl << "return static_cast<const ::Ice::LocalObject&>(l) != static_cast<const ::Ice::LocalObject&>(r);";
- C << eb;
- C << sp;
- C << nl << "bool" << nl << scope.substr(2) << "operator<(const " << scoped
- << "& l, const " << scoped << "& r)";
- C << sb;
- C << nl << "return static_cast<const ::Ice::LocalObject&>(l) < static_cast<const ::Ice::LocalObject&>(r);";
- C << eb;
+ C << sp;
+ C << nl << "bool" << nl << scope.substr(2) << "operator==(const " << scoped
+ << "& l, const " << scoped << "& r)";
+ C << sb;
+ C << nl << "return static_cast<const ::Ice::LocalObject&>(l) == static_cast<const ::Ice::LocalObject&>(r);";
+ C << eb;
+ C << sp;
+ C << nl << "bool" << nl << scope.substr(2) << "operator!=(const " << scoped
+ << "& l, const " << scoped << "& r)";
+ C << sb;
+ C << nl << "return static_cast<const ::Ice::LocalObject&>(l) != static_cast<const ::Ice::LocalObject&>(r);";
+ C << eb;
+ C << sp;
+ C << nl << "bool" << nl << scope.substr(2) << "operator<(const " << scoped
+ << "& l, const " << scoped << "& r)";
+ C << sb;
+ C << nl << "return static_cast<const ::Ice::LocalObject&>(l) < static_cast<const ::Ice::LocalObject&>(r);";
+ C << eb;
}
else
{
- string name = p->name();
-
- H << sp << nl << "void " << _dllExport << "__patch__" << name << "Ptr(void*, ::Ice::ObjectPtr&);";
-
- C << sp << nl << "void " << _dllExport;
- C << nl << scope.substr(2) << "__patch__" << name << "Ptr(void* __addr, ::Ice::ObjectPtr& v)";
- C << sb;
- C << nl << scope << name << "Ptr* p = static_cast< " << scope << name << "Ptr*>(__addr);";
- C << nl << "assert(p);";
- C << nl << "*p = " << scope << name << "Ptr::dynamicCast(v);";
- C << nl << "if(v && !*p)";
- C << sb;
- C << nl << "::Ice::UnexpectedObjectException e(__FILE__, __LINE__);";
- C << nl << "e.type = v->ice_id();";
- C << nl << "e.expectedType = " << scope << fixKwd(name) << "::ice_staticId();";
- C << nl << "throw e;";
- C << eb;
- C << eb;
-
- C << sp;
- C << nl << "bool" << nl << scope.substr(2) << "operator==(const " << scoped
- << "& l, const " << scoped << "& r)";
- C << sb;
- C << nl << "return static_cast<const ::Ice::Object&>(l) == static_cast<const ::Ice::Object&>(r);";
- C << eb;
- C << sp;
- C << nl << "bool" << nl << scope.substr(2) << "operator!=(const " << scoped
- << "& l, const " << scoped << "& r)";
- C << sb;
- C << nl << "return static_cast<const ::Ice::Object&>(l) != static_cast<const ::Ice::Object&>(r);";
- C << eb;
- C << sp;
- C << nl << "bool" << nl << scope.substr(2) << "operator<(const " << scoped
- << "& l, const " << scoped << "& r)";
- C << sb;
- C << nl << "return static_cast<const ::Ice::Object&>(l) < static_cast<const ::Ice::Object&>(r);";
- C << eb;
+ string name = p->name();
+
+ H << sp << nl << "void " << _dllExport << "__patch__" << name << "Ptr(void*, ::Ice::ObjectPtr&);";
+
+ C << sp << nl << "void " << _dllExport;
+ C << nl << scope.substr(2) << "__patch__" << name << "Ptr(void* __addr, ::Ice::ObjectPtr& v)";
+ C << sb;
+ C << nl << scope << name << "Ptr* p = static_cast< " << scope << name << "Ptr*>(__addr);";
+ C << nl << "assert(p);";
+ C << nl << "*p = " << scope << name << "Ptr::dynamicCast(v);";
+ C << nl << "if(v && !*p)";
+ C << sb;
+ C << nl << "::Ice::UnexpectedObjectException e(__FILE__, __LINE__);";
+ C << nl << "e.type = v->ice_id();";
+ C << nl << "e.expectedType = " << scope << fixKwd(name) << "::ice_staticId();";
+ C << nl << "throw e;";
+ C << eb;
+ C << eb;
+
+ C << sp;
+ C << nl << "bool" << nl << scope.substr(2) << "operator==(const " << scoped
+ << "& l, const " << scoped << "& r)";
+ C << sb;
+ C << nl << "return static_cast<const ::Ice::Object&>(l) == static_cast<const ::Ice::Object&>(r);";
+ C << eb;
+ C << sp;
+ C << nl << "bool" << nl << scope.substr(2) << "operator!=(const " << scoped
+ << "& l, const " << scoped << "& r)";
+ C << sb;
+ C << nl << "return static_cast<const ::Ice::Object&>(l) != static_cast<const ::Ice::Object&>(r);";
+ C << eb;
+ C << sp;
+ C << nl << "bool" << nl << scope.substr(2) << "operator<(const " << scoped
+ << "& l, const " << scoped << "& r)";
+ C << sb;
+ C << nl << "return static_cast<const ::Ice::Object&>(l) < static_cast<const ::Ice::Object&>(r);";
+ C << eb;
}
C << sp;
@@ -3470,65 +3470,65 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
ParamDeclList paramList = p->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- string paramName = fixKwd((*q)->name());
- TypePtr type = (*q)->type();
- bool isOutParam = (*q)->isOutParam();
- string typeString;
- if(isOutParam)
- {
- outParams.push_back(*q);
- typeString = outputTypeToString(type, _useWstring, (*q)->getMetaData());
- }
- else
- {
- inParams.push_back(*q);
- typeString = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData());
- }
-
- if(q != paramList.begin())
- {
- params += ", ";
- paramsDecl += ", ";
- args += ", ";
- }
-
- params += typeString;
- paramsDecl += typeString;
- paramsDecl += ' ';
- paramsDecl += paramName;
- args += paramName;
-
- if(!isOutParam)
- {
- paramsAMD += typeString;
- paramsAMD += ", ";
- paramsDeclAMD += typeString;
- paramsDeclAMD += ' ';
- paramsDeclAMD += paramName;
- paramsDeclAMD += ", ";
- argsAMD += paramName;
- argsAMD += ", ";
- }
+ string paramName = fixKwd((*q)->name());
+ TypePtr type = (*q)->type();
+ bool isOutParam = (*q)->isOutParam();
+ string typeString;
+ if(isOutParam)
+ {
+ outParams.push_back(*q);
+ typeString = outputTypeToString(type, _useWstring, (*q)->getMetaData());
+ }
+ else
+ {
+ inParams.push_back(*q);
+ typeString = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData());
+ }
+
+ if(q != paramList.begin())
+ {
+ params += ", ";
+ paramsDecl += ", ";
+ args += ", ";
+ }
+
+ params += typeString;
+ paramsDecl += typeString;
+ paramsDecl += ' ';
+ paramsDecl += paramName;
+ args += paramName;
+
+ if(!isOutParam)
+ {
+ paramsAMD += typeString;
+ paramsAMD += ", ";
+ paramsDeclAMD += typeString;
+ paramsDeclAMD += ' ';
+ paramsDeclAMD += paramName;
+ paramsDeclAMD += ", ";
+ argsAMD += paramName;
+ argsAMD += ", ";
+ }
}
if(!cl->isLocal())
{
- if(!paramList.empty())
- {
- params += ", ";
- paramsDecl += ", ";
- args += ", ";
- }
+ if(!paramList.empty())
+ {
+ params += ", ";
+ paramsDecl += ", ";
+ args += ", ";
+ }
- params += "const ::Ice::Current& = ::Ice::Current())";
- paramsDecl += "const ::Ice::Current& __current)";
- args += "__current)";
+ params += "const ::Ice::Current& = ::Ice::Current())";
+ paramsDecl += "const ::Ice::Current& __current)";
+ args += "__current)";
}
else
{
- params += ')';
- paramsDecl += ')';
- args += ')';
+ params += ')';
+ paramsDecl += ')';
+ args += ')';
}
paramsAMD += "const ::Ice::Current& = ::Ice::Current())";
@@ -3543,132 +3543,132 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
H << sp;
if(!amd)
{
- H << nl << deprecateSymbol << "virtual " << retS << ' ' << fixKwd(name) << params
- << (isConst ? " const" : "") << " = 0;";
+ H << nl << deprecateSymbol << "virtual " << retS << ' ' << fixKwd(name) << params
+ << (isConst ? " const" : "") << " = 0;";
}
else
{
- H << nl << deprecateSymbol << "virtual void " << name << "_async" << paramsAMD
- << (isConst ? " const" : "") << " = 0;";
- }
+ H << nl << deprecateSymbol << "virtual void " << name << "_async" << paramsAMD
+ << (isConst ? " const" : "") << " = 0;";
+ }
if(!cl->isLocal())
{
- H << nl << "::IceInternal::DispatchStatus ___" << name
- << "(::IceInternal::Incoming&, const ::Ice::Current&)" << (isConst ? " const" : "") << ';';
-
- C << sp;
- C << nl << "::IceInternal::DispatchStatus" << nl << scope.substr(2) << "___" << name
- << "(::IceInternal::Incoming&";
- if(!paramList.empty() || !p->throws().empty() || ret || amd)
- {
- C << "__inS";
- }
- C << ", const ::Ice::Current& __current)" << (isConst ? " const" : "");
- C << sb;
- if(!amd)
- {
- ExceptionList throws = p->throws();
- throws.sort();
- throws.unique();
-
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
+ H << nl << "::IceInternal::DispatchStatus ___" << name
+ << "(::IceInternal::Incoming&, const ::Ice::Current&)" << (isConst ? " const" : "") << ';';
+
+ C << sp;
+ C << nl << "::IceInternal::DispatchStatus" << nl << scope.substr(2) << "___" << name
+ << "(::IceInternal::Incoming&";
+ if(!paramList.empty() || !p->throws().empty() || ret || amd)
+ {
+ C << "__inS";
+ }
+ C << ", const ::Ice::Current& __current)" << (isConst ? " const" : "");
+ C << sb;
+ if(!amd)
+ {
+ ExceptionList throws = p->throws();
+ throws.sort();
+ throws.unique();
+
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
#if defined(__SUNPRO_CC)
- throws.sort(derivedToBaseCompare);
+ throws.sort(derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
- C << nl << "__checkMode(" << operationModeToString(p->mode()) << ", __current.mode);";
-
- if(!inParams.empty())
- {
- C << nl << "::IceInternal::BasicStream* __is = __inS.is();";
- }
- if(ret || !outParams.empty() || !throws.empty())
- {
- C << nl << "::IceInternal::BasicStream* __os = __inS.os();";
- }
- writeAllocateCode(C, inParams, 0, StringList(), _useWstring, true);
- writeUnmarshalCode(C, inParams, 0, StringList(), true);
- if(p->sendsClasses())
- {
- C << nl << "__is->readPendingObjects();";
- }
- writeAllocateCode(C, outParams, 0, StringList(), _useWstring);
- if(!throws.empty())
- {
- C << nl << "try";
- C << sb;
- }
- C << nl;
- if(ret)
- {
- C << retS << " __ret = ";
- }
- C << fixKwd(name) << args << ';';
- writeMarshalCode(C, outParams, ret, p->getMetaData());
- if(p->returnsClasses())
- {
- C << nl << "__os->writePendingObjects();";
- }
- if(!throws.empty())
- {
- C << eb;
- ExceptionList::const_iterator r;
- for(r = throws.begin(); r != throws.end(); ++r)
- {
- C << nl << "catch(const " << fixKwd((*r)->scoped()) << "& __ex)";
- C << sb;
- C << nl << "__os->write(__ex);";
- C << nl << "return ::IceInternal::DispatchUserException;";
- C << eb;
- }
- }
- C << nl << "return ::IceInternal::DispatchOK;";
- }
- else
- {
- C << nl << "__checkMode(" << operationModeToString(p->mode()) << ", __current.mode);";
-
- if(!inParams.empty())
- {
- C << nl << "::IceInternal::BasicStream* __is = __inS.is();";
- }
- writeAllocateCode(C, inParams, 0, StringList(), _useWstring, true);
- writeUnmarshalCode(C, inParams, 0, StringList(), true);
- if(p->sendsClasses())
- {
- C << nl << "__is->readPendingObjects();";
- }
- C << nl << classScopedAMD << '_' << name << "Ptr __cb = new IceAsync" << classScopedAMD << '_' << name
- << "(__inS);";
- C << nl << "try";
- C << sb;
- C << nl << name << "_async" << argsAMD << ';';
- C << eb;
- C << nl << "catch(const ::Ice::Exception& __ex)";
- C << sb;
- C << nl << "__cb->ice_exception(__ex);";
- C << eb;
- C << nl << "catch(const ::std::exception& __ex)";
- C << sb;
- C << nl << "__cb->ice_exception(__ex);";
- C << eb;
- C << nl << "catch(...)";
- C << sb;
- C << nl << "__cb->ice_exception();";
- C << eb;
- C << nl << "return ::IceInternal::DispatchAsync;";
- }
- C << eb;
- }
+ C << nl << "__checkMode(" << operationModeToString(p->mode()) << ", __current.mode);";
+
+ if(!inParams.empty())
+ {
+ C << nl << "::IceInternal::BasicStream* __is = __inS.is();";
+ }
+ if(ret || !outParams.empty() || !throws.empty())
+ {
+ C << nl << "::IceInternal::BasicStream* __os = __inS.os();";
+ }
+ writeAllocateCode(C, inParams, 0, StringList(), _useWstring, true);
+ writeUnmarshalCode(C, inParams, 0, StringList(), true);
+ if(p->sendsClasses())
+ {
+ C << nl << "__is->readPendingObjects();";
+ }
+ writeAllocateCode(C, outParams, 0, StringList(), _useWstring);
+ if(!throws.empty())
+ {
+ C << nl << "try";
+ C << sb;
+ }
+ C << nl;
+ if(ret)
+ {
+ C << retS << " __ret = ";
+ }
+ C << fixKwd(name) << args << ';';
+ writeMarshalCode(C, outParams, ret, p->getMetaData());
+ if(p->returnsClasses())
+ {
+ C << nl << "__os->writePendingObjects();";
+ }
+ if(!throws.empty())
+ {
+ C << eb;
+ ExceptionList::const_iterator r;
+ for(r = throws.begin(); r != throws.end(); ++r)
+ {
+ C << nl << "catch(const " << fixKwd((*r)->scoped()) << "& __ex)";
+ C << sb;
+ C << nl << "__os->write(__ex);";
+ C << nl << "return ::IceInternal::DispatchUserException;";
+ C << eb;
+ }
+ }
+ C << nl << "return ::IceInternal::DispatchOK;";
+ }
+ else
+ {
+ C << nl << "__checkMode(" << operationModeToString(p->mode()) << ", __current.mode);";
+
+ if(!inParams.empty())
+ {
+ C << nl << "::IceInternal::BasicStream* __is = __inS.is();";
+ }
+ writeAllocateCode(C, inParams, 0, StringList(), _useWstring, true);
+ writeUnmarshalCode(C, inParams, 0, StringList(), true);
+ if(p->sendsClasses())
+ {
+ C << nl << "__is->readPendingObjects();";
+ }
+ C << nl << classScopedAMD << '_' << name << "Ptr __cb = new IceAsync" << classScopedAMD << '_' << name
+ << "(__inS);";
+ C << nl << "try";
+ C << sb;
+ C << nl << name << "_async" << argsAMD << ';';
+ C << eb;
+ C << nl << "catch(const ::Ice::Exception& __ex)";
+ C << sb;
+ C << nl << "__cb->ice_exception(__ex);";
+ C << eb;
+ C << nl << "catch(const ::std::exception& __ex)";
+ C << sb;
+ C << nl << "__cb->ice_exception(__ex);";
+ C << eb;
+ C << nl << "catch(...)";
+ C << sb;
+ C << nl << "__cb->ice_exception();";
+ C << eb;
+ C << nl << "return ::IceInternal::DispatchAsync;";
+ }
+ C << eb;
+ }
}
void
@@ -3699,41 +3699,41 @@ Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p)
if(override)
{
- H << nl << "virtual void __incRef();";
+ H << nl << "virtual void __incRef();";
- C << sp << nl << "void" << nl << scoped.substr(2) << "::__incRef()";
- C << sb;
- C << nl << "__gcIncRef();";
- C << eb;
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__incRef()";
+ C << sb;
+ C << nl << "__gcIncRef();";
+ C << eb;
- H << nl << "virtual void __decRef();";
+ H << nl << "virtual void __decRef();";
- C << sp << nl << "void" << nl << scoped.substr(2) << "::__decRef()";
- C << sb;
- C << nl << "__gcDecRef();";
- C << eb;
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__decRef()";
+ C << sb;
+ C << nl << "__gcDecRef();";
+ C << eb;
- H << nl << "virtual void __addObject(::IceInternal::GCCountMap&);";
+ H << nl << "virtual void __addObject(::IceInternal::GCCountMap&);";
- C << sp << nl << "void" << nl << scoped.substr(2) << "::__addObject(::IceInternal::GCCountMap& _c)";
- C << sb;
- C << nl << "::IceInternal::GCCountMap::iterator pos = _c.find(this);";
- C << nl << "if(pos == _c.end())";
- C << sb;
- C << nl << "_c[this] = 1;";
- C << eb;
- C << nl << "else";
- C << sb;
- C << nl << "++pos->second;";
- C << eb;
- C << eb;
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__addObject(::IceInternal::GCCountMap& _c)";
+ C << sb;
+ C << nl << "::IceInternal::GCCountMap::iterator pos = _c.find(this);";
+ C << nl << "if(pos == _c.end())";
+ C << sb;
+ C << nl << "_c[this] = 1;";
+ C << eb;
+ C << nl << "else";
+ C << sb;
+ C << nl << "++pos->second;";
+ C << eb;
+ C << eb;
- H << nl << "virtual bool __usesClasses();";
+ H << nl << "virtual bool __usesClasses();";
- C << sp << nl << "bool" << nl << scoped.substr(2) << "::__usesClasses()";
- C << sb;
- C << nl << "return true;";
- C << eb;
+ C << sp << nl << "bool" << nl << scoped.substr(2) << "::__usesClasses()";
+ C << sb;
+ C << nl << "return true;";
+ C << eb;
}
//
@@ -3742,41 +3742,41 @@ Slice::Gen::ObjectVisitor::emitGCFunctions(const ClassDefPtr& p)
//
if(canBeCyclic)
{
- H << nl << "virtual void __gcReachable(::IceInternal::GCCountMap&) const;";
-
- C << sp << nl << "void" << nl << scoped.substr(2) << "::__gcReachable(::IceInternal::GCCountMap& _c) const";
- C << sb;
-
- bool hasCyclicBase = hasBaseClass && bases.front()->canBeCyclic();
- if(hasCyclicBase)
- {
- emitUpcall(bases.front(), "::__gcReachable(_c);");
- }
- for(DataMemberList::const_iterator i = dataMembers.begin(); i != dataMembers.end(); ++i)
- {
- if((*i)->type()->usesClasses())
- {
- emitGCInsertCode((*i)->type(), fixKwd((*i)->name()), "", 0);
- }
- }
- C << eb;
-
- H << nl << "virtual void __gcClear();";
-
- C << sp << nl << "void" << nl << scoped.substr(2) << "::__gcClear()";
- C << sb;
- if(hasCyclicBase)
- {
- emitUpcall(bases.front(), "::__gcClear();");
- }
- for(DataMemberList::const_iterator j = dataMembers.begin(); j != dataMembers.end(); ++j)
- {
- if((*j)->type()->usesClasses())
- {
- emitGCClearCode((*j)->type(), fixKwd((*j)->name()), "", 0);
- }
- }
- C << eb;
+ H << nl << "virtual void __gcReachable(::IceInternal::GCCountMap&) const;";
+
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__gcReachable(::IceInternal::GCCountMap& _c) const";
+ C << sb;
+
+ bool hasCyclicBase = hasBaseClass && bases.front()->canBeCyclic();
+ if(hasCyclicBase)
+ {
+ emitUpcall(bases.front(), "::__gcReachable(_c);");
+ }
+ for(DataMemberList::const_iterator i = dataMembers.begin(); i != dataMembers.end(); ++i)
+ {
+ if((*i)->type()->usesClasses())
+ {
+ emitGCInsertCode((*i)->type(), fixKwd((*i)->name()), "", 0);
+ }
+ }
+ C << eb;
+
+ H << nl << "virtual void __gcClear();";
+
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__gcClear()";
+ C << sb;
+ if(hasCyclicBase)
+ {
+ emitUpcall(bases.front(), "::__gcClear();");
+ }
+ for(DataMemberList::const_iterator j = dataMembers.begin(); j != dataMembers.end(); ++j)
+ {
+ if((*j)->type()->usesClasses())
+ {
+ emitGCClearCode((*j)->type(), fixKwd((*j)->name()), "", 0);
+ }
+ }
+ C << eb;
}
}
@@ -3786,60 +3786,60 @@ Slice::Gen::ObjectVisitor::emitGCInsertCode(const TypePtr& p, const string& pref
if((BuiltinPtr::dynamicCast(p) && BuiltinPtr::dynamicCast(p)->kind() == Builtin::KindObject)
|| ClassDeclPtr::dynamicCast(p))
{
- C << nl << "if(" << prefix << name << ')';
- C << sb;
- ClassDeclPtr decl = ClassDeclPtr::dynamicCast(p);
- if(decl)
- {
- C << nl << decl->scope() << "__addObject(" << prefix << name << ", _c);";
- }
- else
- {
- C << nl << prefix << name << "->__addObject(_c);";
- }
- C << eb;
+ C << nl << "if(" << prefix << name << ')';
+ C << sb;
+ ClassDeclPtr decl = ClassDeclPtr::dynamicCast(p);
+ if(decl)
+ {
+ C << nl << decl->scope() << "__addObject(" << prefix << name << ", _c);";
+ }
+ else
+ {
+ C << nl << prefix << name << "->__addObject(_c);";
+ }
+ C << eb;
}
else if(StructPtr::dynamicCast(p))
{
StructPtr s = StructPtr::dynamicCast(p);
- DataMemberList dml = s->dataMembers();
- for(DataMemberList::const_iterator i = dml.begin(); i != dml.end(); ++i)
- {
- if((*i)->type()->usesClasses())
- {
- emitGCInsertCode((*i)->type(), prefix + name + ".", fixKwd((*i)->name()), ++level);
- }
- }
+ DataMemberList dml = s->dataMembers();
+ for(DataMemberList::const_iterator i = dml.begin(); i != dml.end(); ++i)
+ {
+ if((*i)->type()->usesClasses())
+ {
+ emitGCInsertCode((*i)->type(), prefix + name + ".", fixKwd((*i)->name()), ++level);
+ }
+ }
}
else if(DictionaryPtr::dynamicCast(p))
{
DictionaryPtr d = DictionaryPtr::dynamicCast(p);
- string scoped = fixKwd(d->scoped());
- ostringstream tmp;
- tmp << "_i" << level;
- string iterName = tmp.str();
- C << sb;
- C << nl << "for(" << scoped << "::const_iterator " << iterName << " = " << prefix + name
+ string scoped = fixKwd(d->scoped());
+ ostringstream tmp;
+ tmp << "_i" << level;
+ string iterName = tmp.str();
+ C << sb;
+ C << nl << "for(" << scoped << "::const_iterator " << iterName << " = " << prefix + name
<< ".begin(); " << iterName << " != " << prefix + name << ".end(); ++" << iterName << ")";
- C << sb;
- emitGCInsertCode(d->valueType(), "", string("(*") + iterName + ").second", ++level);
- C << eb;
- C << eb;
+ C << sb;
+ emitGCInsertCode(d->valueType(), "", string("(*") + iterName + ").second", ++level);
+ C << eb;
+ C << eb;
}
else if(SequencePtr::dynamicCast(p))
{
- SequencePtr s = SequencePtr::dynamicCast(p);
- string scoped = fixKwd(s->scoped());
- ostringstream tmp;
- tmp << "_i" << level;
- string iterName = tmp.str();
- C << sb;
- C << nl << "for(" << scoped << "::const_iterator " << iterName << " = " << prefix + name
+ SequencePtr s = SequencePtr::dynamicCast(p);
+ string scoped = fixKwd(s->scoped());
+ ostringstream tmp;
+ tmp << "_i" << level;
+ string iterName = tmp.str();
+ C << sb;
+ C << nl << "for(" << scoped << "::const_iterator " << iterName << " = " << prefix + name
<< ".begin(); " << iterName << " != " << prefix + name << ".end(); ++" << iterName << ")";
- C << sb;
- emitGCInsertCode(s->type(), string("(*") + iterName + ")", "", ++level);
- C << eb;
- C << eb;
+ C << sb;
+ emitGCInsertCode(s->type(), string("(*") + iterName + ")", "", ++level);
+ C << eb;
+ C << eb;
}
}
@@ -3849,71 +3849,71 @@ Slice::Gen::ObjectVisitor::emitGCClearCode(const TypePtr& p, const string& prefi
if((BuiltinPtr::dynamicCast(p) && BuiltinPtr::dynamicCast(p)->kind() == Builtin::KindObject)
|| ClassDeclPtr::dynamicCast(p))
{
- C << nl << "if(" << prefix << name << ")";
- C << sb;
- ClassDeclPtr decl = ClassDeclPtr::dynamicCast(p);
- if(decl)
- {
- C << nl << "if(" << decl->scope() << "__usesClasses(" << prefix << name << "))";
- C << sb;
- C << nl << decl->scope() << "__decRefUnsafe(" << prefix << name << ");";
- C << nl << decl->scope() << "__clearHandleUnsafe(" << prefix << name << ");";
- }
- else
- {
- C << nl << "if(" << prefix << name << "->__usesClasses())";
- C << sb;
- C << nl << prefix << name << "->__decRefUnsafe();";
- C << nl << prefix << name << ".__clearHandleUnsafe();";
- }
- C << eb;
- C << nl << "else";
- C << sb;
- C << nl << prefix << name << " = 0;";
- C << eb;
- C << eb;
+ C << nl << "if(" << prefix << name << ")";
+ C << sb;
+ ClassDeclPtr decl = ClassDeclPtr::dynamicCast(p);
+ if(decl)
+ {
+ C << nl << "if(" << decl->scope() << "__usesClasses(" << prefix << name << "))";
+ C << sb;
+ C << nl << decl->scope() << "__decRefUnsafe(" << prefix << name << ");";
+ C << nl << decl->scope() << "__clearHandleUnsafe(" << prefix << name << ");";
+ }
+ else
+ {
+ C << nl << "if(" << prefix << name << "->__usesClasses())";
+ C << sb;
+ C << nl << prefix << name << "->__decRefUnsafe();";
+ C << nl << prefix << name << ".__clearHandleUnsafe();";
+ }
+ C << eb;
+ C << nl << "else";
+ C << sb;
+ C << nl << prefix << name << " = 0;";
+ C << eb;
+ C << eb;
}
else if(StructPtr::dynamicCast(p))
{
- StructPtr s = StructPtr::dynamicCast(p);
- DataMemberList dml = s->dataMembers();
- for(DataMemberList::const_iterator i = dml.begin(); i != dml.end(); ++i)
- {
- if((*i)->type()->usesClasses())
- {
- emitGCClearCode((*i)->type(), prefix + name + ".", fixKwd((*i)->name()), ++level);
- }
- }
+ StructPtr s = StructPtr::dynamicCast(p);
+ DataMemberList dml = s->dataMembers();
+ for(DataMemberList::const_iterator i = dml.begin(); i != dml.end(); ++i)
+ {
+ if((*i)->type()->usesClasses())
+ {
+ emitGCClearCode((*i)->type(), prefix + name + ".", fixKwd((*i)->name()), ++level);
+ }
+ }
}
else if(DictionaryPtr::dynamicCast(p))
{
- DictionaryPtr d = DictionaryPtr::dynamicCast(p);
- string scoped = fixKwd(d->scoped());
- ostringstream tmp;
- tmp << "_i" << level;
- string iterName = tmp.str();
- C << sb;
- C << nl << "for(" << scoped << "::iterator " << iterName << " = " << prefix + name
+ DictionaryPtr d = DictionaryPtr::dynamicCast(p);
+ string scoped = fixKwd(d->scoped());
+ ostringstream tmp;
+ tmp << "_i" << level;
+ string iterName = tmp.str();
+ C << sb;
+ C << nl << "for(" << scoped << "::iterator " << iterName << " = " << prefix + name
<< ".begin(); " << iterName << " != " << prefix + name << ".end(); ++" << iterName << ")";
- C << sb;
- emitGCClearCode(d->valueType(), "", string("(*") + iterName + ").second", ++level);
- C << eb;
- C << eb;
+ C << sb;
+ emitGCClearCode(d->valueType(), "", string("(*") + iterName + ").second", ++level);
+ C << eb;
+ C << eb;
}
else if(SequencePtr::dynamicCast(p))
{
- SequencePtr s = SequencePtr::dynamicCast(p);
- string scoped = fixKwd(s->scoped());
- ostringstream tmp;
- tmp << "_i" << level;
- string iterName = tmp.str();
- C << sb;
- C << nl << "for(" << scoped << "::iterator " << iterName << " = " << prefix + name
+ SequencePtr s = SequencePtr::dynamicCast(p);
+ string scoped = fixKwd(s->scoped());
+ ostringstream tmp;
+ tmp << "_i" << level;
+ string iterName = tmp.str();
+ C << sb;
+ C << nl << "for(" << scoped << "::iterator " << iterName << " = " << prefix + name
<< ".begin(); " << iterName << " != " << prefix + name << ".end(); ++" << iterName << ")";
- C << sb;
- emitGCClearCode(s->type(), "", string("(*") + iterName + ")", ++level);
- C << eb;
- C << eb;;
+ C << sb;
+ emitGCClearCode(s->type(), "", string("(*") + iterName + ")", ++level);
+ C << eb;
+ C << eb;;
}
}
@@ -3929,21 +3929,21 @@ Slice::Gen::ObjectVisitor::emitVirtualBaseInitializers(const ClassDefPtr& p)
ClassList bases = p->bases();
if(!bases.empty() && !bases.front()->isInterface())
{
- if(emitVirtualBaseInitializers(bases.front()))
- {
- C << ',';
- }
+ if(emitVirtualBaseInitializers(bases.front()))
+ {
+ C << ',';
+ }
}
string upcall = "(";
DataMemberList::const_iterator q;
for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q)
{
- if(q != allDataMembers.begin())
- {
- upcall += ", ";
- }
- upcall += "__ice_" + (*q)->name();
+ if(q != allDataMembers.begin())
+ {
+ upcall += ", ";
+ }
+ upcall += "__ice_" + (*q)->name();
}
upcall += ")";
@@ -3973,47 +3973,47 @@ Slice::Gen::ObjectVisitor::emitOneShotConstructor(const ClassDefPtr& p)
for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q)
{
- string typeName = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData());
- allParamDecls.push_back(typeName + " __ice_" + (*q)->name());
+ string typeName = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData());
+ allParamDecls.push_back(typeName + " __ice_" + (*q)->name());
}
if(!allDataMembers.empty())
{
- C << sp << nl << p->scoped().substr(2) << "::" << fixKwd(p->name()) << spar << allParamDecls << epar << " :";
- C.inc();
-
- DataMemberList dataMembers = p->dataMembers();
-
- ClassList bases = p->bases();
- ClassDefPtr base;
- if(!bases.empty() && !bases.front()->isInterface())
- {
- if(emitVirtualBaseInitializers(bases.front()))
- {
- if(!dataMembers.empty())
- {
- C << ',';
- }
- }
- }
-
- if(!dataMembers.empty())
- {
- C << nl;
- }
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- if(q != dataMembers.begin())
- {
- C << ',' << nl;
- }
- string memberName = fixKwd((*q)->name());
- C << memberName << '(' << "__ice_" << (*q)->name() << ')';
- }
-
- C.dec();
- C << sb;
- C << eb;
+ C << sp << nl << p->scoped().substr(2) << "::" << fixKwd(p->name()) << spar << allParamDecls << epar << " :";
+ C.inc();
+
+ DataMemberList dataMembers = p->dataMembers();
+
+ ClassList bases = p->bases();
+ ClassDefPtr base;
+ if(!bases.empty() && !bases.front()->isInterface())
+ {
+ if(emitVirtualBaseInitializers(bases.front()))
+ {
+ if(!dataMembers.empty())
+ {
+ C << ',';
+ }
+ }
+ }
+
+ if(!dataMembers.empty())
+ {
+ C << nl;
+ }
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ if(q != dataMembers.begin())
+ {
+ C << ',' << nl;
+ }
+ string memberName = fixKwd((*q)->name());
+ C << memberName << '(' << "__ice_" << (*q)->name() << ')';
+ }
+
+ C.dec();
+ C << sb;
+ C << eb;
}
}
@@ -4043,7 +4043,7 @@ Slice::Gen::IceInternalVisitor::visitUnitStart(const UnitPtr& p)
{
if(!p->hasClassDecls())
{
- return false;
+ return false;
}
H << sp;
@@ -4069,9 +4069,9 @@ Slice::Gen::IceInternalVisitor::visitClassDecl(const ClassDeclPtr& p)
H << nl << _dllExport << "void decRef(" << scoped << "*);";
if(!p->isLocal())
{
- H << sp;
- H << nl << _dllExport << "void incRef(::IceProxy" << scoped << "*);";
- H << nl << _dllExport << "void decRef(::IceProxy" << scoped << "*);";
+ H << sp;
+ H << nl << _dllExport << "void incRef(::IceProxy" << scoped << "*);";
+ H << nl << _dllExport << "void decRef(::IceProxy" << scoped << "*);";
}
}
@@ -4094,17 +4094,17 @@ Slice::Gen::IceInternalVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!p->isLocal())
{
- C << sp;
- C << nl << "void" << nl << "IceInternal::incRef(::IceProxy" << scoped << "* p)";
- C << sb;
- C << nl << "p->__incRef();";
- C << eb;
+ C << sp;
+ C << nl << "void" << nl << "IceInternal::incRef(::IceProxy" << scoped << "* p)";
+ C << sb;
+ C << nl << "p->__incRef();";
+ C << eb;
- C << sp;
- C << nl << "void" << nl << "IceInternal::decRef(::IceProxy" << scoped << "* p)";
- C << sb;
- C << nl << "p->__decRef();";
- C << eb;
+ C << sp;
+ C << nl << "void" << nl << "IceInternal::decRef(::IceProxy" << scoped << "* p)";
+ C << sb;
+ C << nl << "p->__decRef();";
+ C << eb;
}
return true;
@@ -4120,7 +4120,7 @@ Slice::Gen::HandleVisitor::visitModuleStart(const ModulePtr& p)
{
if(!p->hasClassDecls())
{
- return false;
+ return false;
}
string name = fixKwd(p->name());
@@ -4149,30 +4149,30 @@ Slice::Gen::HandleVisitor::visitClassDecl(const ClassDeclPtr& p)
if(!p->isLocal())
{
- H << nl << "typedef ::IceInternal::ProxyHandle< ::IceProxy" << scoped << "> " << name << "Prx;";
+ H << nl << "typedef ::IceInternal::ProxyHandle< ::IceProxy" << scoped << "> " << name << "Prx;";
- H << sp;
- H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "Prx&);";
- H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "Prx&);";
- H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "Ptr&);";
- H << nl << _dllExport << "void __patch__" << name << "Ptr(void*, ::Ice::ObjectPtr&);";
- if(_stream)
- {
+ H << sp;
+ H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "Prx&);";
+ H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "Prx&);";
+ H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "Ptr&);";
+ H << nl << _dllExport << "void __patch__" << name << "Ptr(void*, ::Ice::ObjectPtr&);";
+ if(_stream)
+ {
H << sp;
- H << nl << _dllExport << "void ice_write" << name << "Prx(const ::Ice::OutputStreamPtr&, const " << name
+ H << nl << _dllExport << "void ice_write" << name << "Prx(const ::Ice::OutputStreamPtr&, const " << name
<< "Prx&);";
- H << nl << _dllExport << "void ice_read" << name << "Prx(const ::Ice::InputStreamPtr&, " << name
+ H << nl << _dllExport << "void ice_read" << name << "Prx(const ::Ice::InputStreamPtr&, " << name
<< "Prx&);";
H << nl << _dllExport << "void ice_write" << name << "(const ::Ice::OutputStreamPtr&, const "
<< name << "Ptr&);";
H << nl << _dllExport << "void ice_read" << name << "(const ::Ice::InputStreamPtr&, " << name << "Ptr&);";
- }
+ }
- H << sp << nl << _dllExport << "void __addObject(const " << name << "Ptr&, ::IceInternal::GCCountMap&);";
- H << nl << _dllExport << "bool __usesClasses(const " << name << "Ptr&);";
- H << nl << _dllExport << "void __decRefUnsafe(const " << name << "Ptr&);";
- H << nl << _dllExport << "void __clearHandleUnsafe(" << name << "Ptr&);";
+ H << sp << nl << _dllExport << "void __addObject(const " << name << "Ptr&, ::IceInternal::GCCountMap&);";
+ H << nl << _dllExport << "bool __usesClasses(const " << name << "Ptr&);";
+ H << nl << _dllExport << "void __decRefUnsafe(const " << name << "Ptr&);";
+ H << nl << _dllExport << "void __clearHandleUnsafe(" << name << "Ptr&);";
}
}
@@ -4182,84 +4182,84 @@ Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!p->isLocal())
{
string name = p->name();
- string scoped = fixKwd(p->scoped());
- string scope = fixKwd(p->scope());
-
- string factory;
- string type;
- if(!p->isAbstract())
- {
- type = scoped + "::ice_staticId()";
- factory = scoped + "::ice_factory()";
- }
- else
- {
- type = "\"\"";
- factory = "0";
- }
-
- C << sp;
- C << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
- << scope << name << "Prx& v)";
- C << sb;
- C << nl << "__os->write(::Ice::ObjectPrx(v));";
- C << eb;
-
- C << sp;
- C << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, "
- << scope << name << "Prx& v)";
- C << sb;
- C << nl << "::Ice::ObjectPrx proxy;";
- C << nl << "__is->read(proxy);";
- C << nl << "if(!proxy)";
- C << sb;
- C << nl << "v = 0;";
- C << eb;
- C << nl << "else";
- C << sb;
- C << nl << "v = new ::IceProxy" << scoped << ';';
- C << nl << "v->__copyFrom(proxy);";
- C << eb;
- C << eb;
-
- C << sp;
- C << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
- << scope << name << "Ptr& v)";
- C << sb;
- C << nl << "__os->write(::Ice::ObjectPtr(v));";
- C << eb;
-
- if(_stream)
- {
- C << sp;
- C << nl << "void" << nl << scope.substr(2) << "ice_write" << name
+ string scoped = fixKwd(p->scoped());
+ string scope = fixKwd(p->scope());
+
+ string factory;
+ string type;
+ if(!p->isAbstract())
+ {
+ type = scoped + "::ice_staticId()";
+ factory = scoped + "::ice_factory()";
+ }
+ else
+ {
+ type = "\"\"";
+ factory = "0";
+ }
+
+ C << sp;
+ C << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
+ << scope << name << "Prx& v)";
+ C << sb;
+ C << nl << "__os->write(::Ice::ObjectPrx(v));";
+ C << eb;
+
+ C << sp;
+ C << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, "
+ << scope << name << "Prx& v)";
+ C << sb;
+ C << nl << "::Ice::ObjectPrx proxy;";
+ C << nl << "__is->read(proxy);";
+ C << nl << "if(!proxy)";
+ C << sb;
+ C << nl << "v = 0;";
+ C << eb;
+ C << nl << "else";
+ C << sb;
+ C << nl << "v = new ::IceProxy" << scoped << ';';
+ C << nl << "v->__copyFrom(proxy);";
+ C << eb;
+ C << eb;
+
+ C << sp;
+ C << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
+ << scope << name << "Ptr& v)";
+ C << sb;
+ C << nl << "__os->write(::Ice::ObjectPtr(v));";
+ C << eb;
+
+ if(_stream)
+ {
+ C << sp;
+ C << nl << "void" << nl << scope.substr(2) << "ice_write" << name
<< "Prx(const ::Ice::OutputStreamPtr& __outS, const " << scope << name << "Prx& v)";
- C << sb;
- C << nl << "__outS->writeProxy(v);";
- C << eb;
+ C << sb;
+ C << nl << "__outS->writeProxy(v);";
+ C << eb;
- C << sp;
- C << nl << "void" << nl << scope.substr(2) << "ice_read" << name
+ C << sp;
+ C << nl << "void" << nl << scope.substr(2) << "ice_read" << name
<< "Prx(const ::Ice::InputStreamPtr& __inS, " << scope << name << "Prx& v)";
- C << sb;
- C << nl << "::Ice::ObjectPrx proxy = __inS->readProxy();";
- C << nl << "if(!proxy)";
- C << sb;
- C << nl << "v = 0;";
- C << eb;
- C << nl << "else";
- C << sb;
- C << nl << "v = new ::IceProxy" << scoped << ';';
- C << nl << "v->__copyFrom(proxy);";
- C << eb;
- C << eb;
-
- C << sp;
- C << nl << "void" << nl << scope.substr(2) << "ice_write" << name
+ C << sb;
+ C << nl << "::Ice::ObjectPrx proxy = __inS->readProxy();";
+ C << nl << "if(!proxy)";
+ C << sb;
+ C << nl << "v = 0;";
+ C << eb;
+ C << nl << "else";
+ C << sb;
+ C << nl << "v = new ::IceProxy" << scoped << ';';
+ C << nl << "v->__copyFrom(proxy);";
+ C << eb;
+ C << eb;
+
+ C << sp;
+ C << nl << "void" << nl << scope.substr(2) << "ice_write" << name
<< "(const ::Ice::OutputStreamPtr& __outS, const " << scope << name << "Ptr& v)";
- C << sb;
- C << nl << "__outS->writeObject(v);";
- C << eb;
+ C << sb;
+ C << nl << "__outS->writeObject(v);";
+ C << eb;
C << sp;
C << nl << "void" << nl << scope.substr(2) << "ice_read" << name << "(const ::Ice::InputStreamPtr& __inS, "
@@ -4269,7 +4269,7 @@ Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p)
<< name << "Ptr, &__v);";
C << nl << "__inS->readObject(__cb);";
C << eb;
- }
+ }
}
return true;
@@ -4375,48 +4375,48 @@ Slice::Gen::ImplVisitor::writeReturn(Output& out, const TypePtr& type, const Str
{
ProxyPtr prx = ProxyPtr::dynamicCast(type);
if(prx)
- {
- out << nl << "return 0;";
- }
- else
- {
- ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
- if(cl)
- {
- out << nl << "return 0;";
- }
- else
- {
- StructPtr st = StructPtr::dynamicCast(type);
- if(st)
- {
- out << nl << "return " << fixKwd(st->scoped()) << "();";
- }
- else
- {
- EnumPtr en = EnumPtr::dynamicCast(type);
- if(en)
- {
- EnumeratorList enumerators = en->getEnumerators();
- out << nl << "return " << fixKwd(en->scope()) << fixKwd(enumerators.front()->name()) << ';';
- }
- else
- {
- SequencePtr seq = SequencePtr::dynamicCast(type);
- if(seq)
- {
- out << nl << "return " << typeToString(seq, _useWstring, metaData) << "();";
- }
- else
- {
- DictionaryPtr dict = DictionaryPtr::dynamicCast(type);
- assert(dict);
- out << nl << "return " << fixKwd(dict->scoped()) << "();";
- }
- }
- }
- }
- }
+ {
+ out << nl << "return 0;";
+ }
+ else
+ {
+ ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
+ if(cl)
+ {
+ out << nl << "return 0;";
+ }
+ else
+ {
+ StructPtr st = StructPtr::dynamicCast(type);
+ if(st)
+ {
+ out << nl << "return " << fixKwd(st->scoped()) << "();";
+ }
+ else
+ {
+ EnumPtr en = EnumPtr::dynamicCast(type);
+ if(en)
+ {
+ EnumeratorList enumerators = en->getEnumerators();
+ out << nl << "return " << fixKwd(en->scope()) << fixKwd(enumerators.front()->name()) << ';';
+ }
+ else
+ {
+ SequencePtr seq = SequencePtr::dynamicCast(type);
+ if(seq)
+ {
+ out << nl << "return " << typeToString(seq, _useWstring, metaData) << "();";
+ }
+ else
+ {
+ DictionaryPtr dict = DictionaryPtr::dynamicCast(type);
+ assert(dict);
+ out << nl << "return " << fixKwd(dict->scoped()) << "();";
+ }
+ }
+ }
+ }
+ }
}
}
@@ -4475,14 +4475,14 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
{
H << ',' << nl << "virtual public " << fixKwd((*q)->scope());
- if((*q)->isAbstract())
- {
- H << (*q)->name() << "I";
- }
- else
- {
- H << fixKwd((*q)->name());
- }
+ if((*q)->isAbstract())
+ {
+ H << (*q)->name() << "I";
+ }
+ else
+ {
+ H << fixKwd((*q)->name());
+ }
}
H.restoreIndent();
@@ -4531,7 +4531,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!(*q)->isOutParam())
{
C << ',' << nl << inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData()) << ' '
- << fixKwd((*q)->name());
+ << fixKwd((*q)->name());
}
}
C << ',' << nl << "const Ice::Current& current";
@@ -4592,23 +4592,23 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
{
H << ',' << nl;
}
- StringList metaData = (*q)->getMetaData();
+ StringList metaData = (*q)->getMetaData();
#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550)
- //
- // Work around for Sun CC 5.5 bug #4853566
- //
- string typeString;
- if((*q)->isOutParam())
- {
- typeString = outputTypeToString((*q)->type(), _useWstring, metaData);
- }
- else
- {
- typeString = inputTypeToString((*q)->type(), _useWstring, metaData);
- }
+ //
+ // Work around for Sun CC 5.5 bug #4853566
+ //
+ string typeString;
+ if((*q)->isOutParam())
+ {
+ typeString = outputTypeToString((*q)->type(), _useWstring, metaData);
+ }
+ else
+ {
+ typeString = inputTypeToString((*q)->type(), _useWstring, metaData);
+ }
#else
string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), _useWstring, metaData)
- : inputTypeToString((*q)->type(), _useWstring, metaData);
+ : inputTypeToString((*q)->type(), _useWstring, metaData);
#endif
H << typeString;
}
@@ -4627,7 +4627,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
H << ")" << (isConst ? " const" : "") << ';';
C << sp << nl << retS << nl;
- C << scope.substr(2) << name << "I::" << fixKwd(opName) << '(';
+ C << scope.substr(2) << name << "I::" << fixKwd(opName) << '(';
C.useCurrentPosAsIndent();
for(q = paramList.begin(); q != paramList.end(); ++q)
{
@@ -4635,23 +4635,23 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
{
C << ',' << nl;
}
- StringList metaData = (*q)->getMetaData();
+ StringList metaData = (*q)->getMetaData();
#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550)
- //
- // Work around for Sun CC 5.5 bug #4853566
- //
- string typeString;
- if((*q)->isOutParam())
- {
- typeString = outputTypeToString((*q)->type(), _useWstring, metaData);
- }
- else
- {
- typeString = inputTypeToString((*q)->type(), _useWstring, metaData);
- }
+ //
+ // Work around for Sun CC 5.5 bug #4853566
+ //
+ string typeString;
+ if((*q)->isOutParam())
+ {
+ typeString = outputTypeToString((*q)->type(), _useWstring, metaData);
+ }
+ else
+ {
+ typeString = inputTypeToString((*q)->type(), _useWstring, metaData);
+ }
#else
string typeString = (*q)->isOutParam() ? outputTypeToString((*q)->type(), _useWstring, metaData)
- : inputTypeToString((*q)->type(), _useWstring, metaData);
+ : inputTypeToString((*q)->type(), _useWstring, metaData);
#endif
C << typeString << ' ' << fixKwd((*q)->name());
}
@@ -4665,7 +4665,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
}
C.restoreIndent();
C << ')';
- C << (isConst ? " const" : "");
+ C << (isConst ? " const" : "");
C << sb;
if(ret)
@@ -4694,7 +4694,7 @@ Slice::Gen::AsyncVisitor::visitModuleStart(const ModulePtr& p)
{
if(!p->hasNonLocalClassDecls() || (!p->hasContentsWithMetaData("ami") && !p->hasContentsWithMetaData("amd")))
{
- return false;
+ return false;
}
_useWstring = setUseWstring(p, _useWstringHist, _useWstring);
@@ -4736,7 +4736,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
if(cl->isLocal() ||
(!cl->hasMetaData("ami") && !p->hasMetaData("ami") && !cl->hasMetaData("amd") && !p->hasMetaData("amd")))
{
- return;
+ return;
}
string name = p->name();
@@ -4765,10 +4765,10 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
if(ret)
{
- params.push_back(retS);
- paramsAMD.push_back(inputTypeToString(ret, _useWstring, p->getMetaData()));
- paramsDecl.push_back(retS + " __ret");
- args.push_back("__ret");
+ params.push_back(retS);
+ paramsAMD.push_back(inputTypeToString(ret, _useWstring, p->getMetaData()));
+ paramsDecl.push_back(retS + " __ret");
+ args.push_back("__ret");
}
ParamDeclList inParams;
@@ -4776,26 +4776,26 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
ParamDeclList paramList = p->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- string paramName = fixKwd((*q)->name());
- TypePtr type = (*q)->type();
- string typeString = inputTypeToString(type, _useWstring, (*q)->getMetaData());
+ string paramName = fixKwd((*q)->name());
+ TypePtr type = (*q)->type();
+ string typeString = inputTypeToString(type, _useWstring, (*q)->getMetaData());
- if((*q)->isOutParam())
- {
- params.push_back(typeString);
- paramsAMD.push_back(inputTypeToString(type, _useWstring, (*q)->getMetaData()));
- paramsDecl.push_back(typeString + ' ' + paramName);
- args.push_back(paramName);
+ if((*q)->isOutParam())
+ {
+ params.push_back(typeString);
+ paramsAMD.push_back(inputTypeToString(type, _useWstring, (*q)->getMetaData()));
+ paramsDecl.push_back(typeString + ' ' + paramName);
+ args.push_back(paramName);
- outParams.push_back(*q);
- }
- else
- {
- paramsInvoke.push_back(typeString);
- paramsDeclInvoke.push_back(typeString + ' ' + paramName);
+ outParams.push_back(*q);
+ }
+ else
+ {
+ paramsInvoke.push_back(typeString);
+ paramsDeclInvoke.push_back(typeString + ' ' + paramName);
- inParams.push_back(*q);
- }
+ inParams.push_back(*q);
+ }
}
paramsInvoke.push_back("const ::Ice::Context*");
@@ -4803,123 +4803,123 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
if(cl->hasMetaData("ami") || p->hasMetaData("ami"))
{
- H << sp << nl << "class " << _dllExport << classNameAMI << '_' << name
- << " : public ::IceInternal::OutgoingAsync";
- H << sb;
- H.dec();
- H << nl << "public:";
- H.inc();
- H << sp;
- H << nl << "virtual void ice_response" << spar << params << epar << " = 0;";
- H << nl << "virtual void ice_exception(const ::Ice::Exception&) = 0;";
- H << sp;
- H << nl << "void __invoke" << spar << paramsInvoke << epar << ';';
- H << sp;
- H.dec();
- H << nl << "protected:";
- H.inc();
- H << sp;
- H << nl << "virtual void __response(bool);";
- H << eb << ';';
- H << sp << nl << "typedef ::IceUtil::Handle< " << classScopedAMI << '_' << name << "> " << classNameAMI
- << '_' << name << "Ptr;";
-
- string flatName = p->flattenedScope() + name + "_name";
-
- C << sp << nl << "void" << nl << classScopedAMI.substr(2) << '_' << name << "::__invoke" << spar
- << paramsDeclInvoke << epar;
- C << sb;
- C << nl << "try";
- C << sb;
- C << nl << "__prepare(__prx, " << flatName << ", " << operationModeToString(p->sendMode()) << ", __ctx);";
- writeMarshalCode(C, inParams, 0, StringList(), true);
- if(p->sendsClasses())
- {
- C << nl << "__os->writePendingObjects();";
- }
- C << nl << "__os->endWriteEncaps();";
- C << eb;
- C << nl << "catch(const ::Ice::LocalException& __ex)";
- C << sb;
- C << nl << "__finished(__ex);";
- C << nl << "return;";
- C << eb;
- C << nl << "__send();";
- C << eb;
-
- C << sp << nl << "void" << nl << classScopedAMI.substr(2) << '_' << name << "::__response(bool __ok)";
- C << sb;
- writeAllocateCode(C, outParams, ret, p->getMetaData(), _useWstring, true);
- C << nl << "try";
- C << sb;
- C << nl << "if(!__ok)";
- C << sb;
- C << nl << "try";
- C << sb;
- C << nl << "__is->throwException();";
- C << eb;
- //
- // Generate a catch block for each legal user exception.
- // (See comment in DelegateMVisitor::visitOperation() for details.)
- //
- ExceptionList throws = p->throws();
- throws.sort();
- throws.unique();
+ H << sp << nl << "class " << _dllExport << classNameAMI << '_' << name
+ << " : public ::IceInternal::OutgoingAsync";
+ H << sb;
+ H.dec();
+ H << nl << "public:";
+ H.inc();
+ H << sp;
+ H << nl << "virtual void ice_response" << spar << params << epar << " = 0;";
+ H << nl << "virtual void ice_exception(const ::Ice::Exception&) = 0;";
+ H << sp;
+ H << nl << "void __invoke" << spar << paramsInvoke << epar << ';';
+ H << sp;
+ H.dec();
+ H << nl << "protected:";
+ H.inc();
+ H << sp;
+ H << nl << "virtual void __response(bool);";
+ H << eb << ';';
+ H << sp << nl << "typedef ::IceUtil::Handle< " << classScopedAMI << '_' << name << "> " << classNameAMI
+ << '_' << name << "Ptr;";
+
+ string flatName = p->flattenedScope() + name + "_name";
+
+ C << sp << nl << "void" << nl << classScopedAMI.substr(2) << '_' << name << "::__invoke" << spar
+ << paramsDeclInvoke << epar;
+ C << sb;
+ C << nl << "try";
+ C << sb;
+ C << nl << "__prepare(__prx, " << flatName << ", " << operationModeToString(p->sendMode()) << ", __ctx);";
+ writeMarshalCode(C, inParams, 0, StringList(), true);
+ if(p->sendsClasses())
+ {
+ C << nl << "__os->writePendingObjects();";
+ }
+ C << nl << "__os->endWriteEncaps();";
+ C << eb;
+ C << nl << "catch(const ::Ice::LocalException& __ex)";
+ C << sb;
+ C << nl << "__finished(__ex);";
+ C << nl << "return;";
+ C << eb;
+ C << nl << "__send();";
+ C << eb;
+
+ C << sp << nl << "void" << nl << classScopedAMI.substr(2) << '_' << name << "::__response(bool __ok)";
+ C << sb;
+ writeAllocateCode(C, outParams, ret, p->getMetaData(), _useWstring, true);
+ C << nl << "try";
+ C << sb;
+ C << nl << "if(!__ok)";
+ C << sb;
+ C << nl << "try";
+ C << sb;
+ C << nl << "__is->throwException();";
+ C << eb;
+ //
+ // Generate a catch block for each legal user exception.
+ // (See comment in DelegateMVisitor::visitOperation() for details.)
+ //
+ ExceptionList throws = p->throws();
+ throws.sort();
+ throws.unique();
#if defined(__SUNPRO_CC)
- throws.sort(derivedToBaseCompare);
+ throws.sort(derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
- for(ExceptionList::const_iterator i = throws.begin(); i != throws.end(); ++i)
- {
- string scoped = (*i)->scoped();
- C << nl << "catch(const " << fixKwd((*i)->scoped()) << "& __ex)";
- C << sb;
- C << nl << "ice_exception(__ex);";
- C << nl << "return;";
- C << eb;
- }
- C << nl << "catch(const ::Ice::UserException& __ex)";
- C << sb;
- C << nl << "throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());";
- C << eb;
- C << eb;
-
- writeUnmarshalCode(C, outParams, 0, StringList(), true);
- if(ret)
- {
- writeMarshalUnmarshalCode(C, ret, "__ret", false, "", true, p->getMetaData(), true);
- }
- if(p->returnsClasses())
- {
- C << nl << "__is->readPendingObjects();";
- }
- C << eb;
- C << nl << "catch(const ::Ice::LocalException& __ex)";
- C << sb;
- C << nl << "__finished(__ex);";
- C << nl << "return;";
- C << eb;
- C << nl << "ice_response" << spar << args << epar << ';';
- C << eb;
+ for(ExceptionList::const_iterator i = throws.begin(); i != throws.end(); ++i)
+ {
+ string scoped = (*i)->scoped();
+ C << nl << "catch(const " << fixKwd((*i)->scoped()) << "& __ex)";
+ C << sb;
+ C << nl << "ice_exception(__ex);";
+ C << nl << "return;";
+ C << eb;
+ }
+ C << nl << "catch(const ::Ice::UserException& __ex)";
+ C << sb;
+ C << nl << "throw ::Ice::UnknownUserException(__FILE__, __LINE__, __ex.ice_name());";
+ C << eb;
+ C << eb;
+
+ writeUnmarshalCode(C, outParams, 0, StringList(), true);
+ if(ret)
+ {
+ writeMarshalUnmarshalCode(C, ret, "__ret", false, "", true, p->getMetaData(), true);
+ }
+ if(p->returnsClasses())
+ {
+ C << nl << "__is->readPendingObjects();";
+ }
+ C << eb;
+ C << nl << "catch(const ::Ice::LocalException& __ex)";
+ C << sb;
+ C << nl << "__finished(__ex);";
+ C << nl << "return;";
+ C << eb;
+ C << nl << "ice_response" << spar << args << epar << ';';
+ C << eb;
}
if(cl->hasMetaData("amd") || p->hasMetaData("amd"))
{
- H << sp << nl << "class " << _dllExport << classNameAMD << '_' << name
- << " : virtual public ::IceUtil::Shared";
- H << sb;
- H.dec();
- H << nl << "public:";
- H.inc();
- H << sp;
- H << nl << "virtual void ice_response" << spar << paramsAMD << epar << " = 0;";
- H << nl << "virtual void ice_exception(const ::Ice::Exception&) = 0;";
- H << nl << "virtual void ice_exception(const ::std::exception&) = 0;";
- H << nl << "virtual void ice_exception() = 0;";
- H << eb << ';';
- H << sp << nl << "typedef ::IceUtil::Handle< " << classScopedAMD << '_' << name << "> "
- << classNameAMD << '_' << name << "Ptr;";
+ H << sp << nl << "class " << _dllExport << classNameAMD << '_' << name
+ << " : virtual public ::IceUtil::Shared";
+ H << sb;
+ H.dec();
+ H << nl << "public:";
+ H.inc();
+ H << sp;
+ H << nl << "virtual void ice_response" << spar << paramsAMD << epar << " = 0;";
+ H << nl << "virtual void ice_exception(const ::Ice::Exception&) = 0;";
+ H << nl << "virtual void ice_exception(const ::std::exception&) = 0;";
+ H << nl << "virtual void ice_exception() = 0;";
+ H << eb << ';';
+ H << sp << nl << "typedef ::IceUtil::Handle< " << classScopedAMD << '_' << name << "> "
+ << classNameAMD << '_' << name << "Ptr;";
}
}
@@ -4933,7 +4933,7 @@ Slice::Gen::AsyncImplVisitor::visitUnitStart(const UnitPtr& p)
{
if(!p->hasNonLocalClassDecls() || !p->hasContentsWithMetaData("amd"))
{
- return false;
+ return false;
}
H << sp << nl << "namespace IceAsync" << nl << '{';
@@ -4952,7 +4952,7 @@ Slice::Gen::AsyncImplVisitor::visitModuleStart(const ModulePtr& p)
{
if(!p->hasNonLocalClassDecls() || !p->hasContentsWithMetaData("amd"))
{
- return false;
+ return false;
}
_useWstring = setUseWstring(p, _useWstringHist, _useWstring);
@@ -4993,7 +4993,7 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p)
if(cl->isLocal() || (!cl->hasMetaData("amd") && !p->hasMetaData("amd")))
{
- return;
+ return;
}
string name = p->name();
@@ -5027,38 +5027,38 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p)
if(ret)
{
- params += retS;
- paramsDecl += retS;
- paramsDecl += ' ';
- paramsDecl += "__ret";
- args += "__ret";
+ params += retS;
+ paramsDecl += retS;
+ paramsDecl += ' ';
+ paramsDecl += "__ret";
+ args += "__ret";
}
ParamDeclList outParams;
ParamDeclList paramList = p->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- if((*q)->isOutParam())
- {
- string paramName = fixKwd((*q)->name());
- TypePtr type = (*q)->type();
- string typeString = inputTypeToString(type, _useWstring, (*q)->getMetaData());
-
- if(ret || !outParams.empty())
- {
- params += ", ";
- paramsDecl += ", ";
- args += ", ";
- }
-
- params += typeString;
- paramsDecl += typeString;
- paramsDecl += ' ';
- paramsDecl += paramName;
- args += paramName;
-
- outParams.push_back(*q);
- }
+ if((*q)->isOutParam())
+ {
+ string paramName = fixKwd((*q)->name());
+ TypePtr type = (*q)->type();
+ string typeString = inputTypeToString(type, _useWstring, (*q)->getMetaData());
+
+ if(ret || !outParams.empty())
+ {
+ params += ", ";
+ paramsDecl += ", ";
+ args += ", ";
+ }
+
+ params += typeString;
+ paramsDecl += typeString;
+ paramsDecl += ' ';
+ paramsDecl += paramName;
+ args += paramName;
+
+ outParams.push_back(*q);
+ }
}
H << sp << nl << "class " << _dllExport << classNameAMD << '_' << name
@@ -5091,24 +5091,24 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p)
C << sb;
if(ret || !outParams.empty())
{
- C << nl << "try";
- C << sb;
- C << nl << "::IceInternal::BasicStream* __os = this->__os();";
- writeMarshalCode(C, outParams, 0, StringList(), true);
- if(ret)
- {
- writeMarshalUnmarshalCode(C, ret, "__ret", true, "", true, p->getMetaData(), true);
- }
- if(p->returnsClasses())
- {
- C << nl << "__os->writePendingObjects();";
- }
- C << eb;
- C << nl << "catch(const ::Ice::Exception& __ex)";
- C << sb;
- C << nl << "__exception(__ex);";
- C << nl << "return;";
- C << eb;
+ C << nl << "try";
+ C << sb;
+ C << nl << "::IceInternal::BasicStream* __os = this->__os();";
+ writeMarshalCode(C, outParams, 0, StringList(), true);
+ if(ret)
+ {
+ writeMarshalUnmarshalCode(C, ret, "__ret", true, "", true, p->getMetaData(), true);
+ }
+ if(p->returnsClasses())
+ {
+ C << nl << "__os->writePendingObjects();";
+ }
+ C << eb;
+ C << nl << "catch(const ::Ice::Exception& __ex)";
+ C << sb;
+ C << nl << "__exception(__ex);";
+ C << nl << "return;";
+ C << eb;
}
C << nl << "__response(true);";
C << eb;
@@ -5118,31 +5118,31 @@ Slice::Gen::AsyncImplVisitor::visitOperation(const OperationPtr& p)
C << sb;
if(throws.empty())
{
- C << nl << "__exception(ex);";
+ C << nl << "__exception(ex);";
}
else
{
- C << nl << "try";
- C << sb;
- C << nl << "ex.ice_throw();";
- C << eb;
- ExceptionList::const_iterator r;
- for(r = throws.begin(); r != throws.end(); ++r)
- {
- C << nl << "catch(const " << fixKwd((*r)->scoped()) << "& __ex)";
- C << sb;
- C << nl << "__os()->write(__ex);";
- if((*r)->usesClasses())
- {
- C << nl << "__os()->writePendingObjects();";
- }
- C << nl << "__response(false);";
- C << eb;
- }
- C << nl << "catch(const ::Ice::Exception& __ex)";
- C << sb;
- C << nl << "__exception(__ex);";
- C << eb;
+ C << nl << "try";
+ C << sb;
+ C << nl << "ex.ice_throw();";
+ C << eb;
+ ExceptionList::const_iterator r;
+ for(r = throws.begin(); r != throws.end(); ++r)
+ {
+ C << nl << "catch(const " << fixKwd((*r)->scoped()) << "& __ex)";
+ C << sb;
+ C << nl << "__os()->write(__ex);";
+ if((*r)->usesClasses())
+ {
+ C << nl << "__os()->writePendingObjects();";
+ }
+ C << nl << "__response(false);";
+ C << eb;
+ }
+ C << nl << "catch(const ::Ice::Exception& __ex)";
+ C << sb;
+ C << nl << "__exception(__ex);";
+ C << eb;
}
C << eb;
@@ -5185,10 +5185,10 @@ Slice::Gen::MetaDataVisitor::visitModuleStart(const ModulePtr& p)
if(s.find(prefix) == 0)
{
string ss = s.substr(prefix.size());
- if(ss.find("include:") == 0)
- {
- continue;
- }
+ if(ss.find("include:") == 0)
+ {
+ continue;
+ }
cout << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl;
}
_history.insert(s);
@@ -5275,7 +5275,7 @@ Slice::Gen::MetaDataVisitor::visitOperation(const OperationPtr& p)
}
else
{
- validate(returnType, metaData, p->definitionContext()->filename(), p->line(), ami);
+ validate(returnType, metaData, p->definitionContext()->filename(), p->line(), ami);
}
}
@@ -5325,7 +5325,7 @@ Slice::Gen::MetaDataVisitor::visitConst(const ConstPtr& p)
void
Slice::Gen::MetaDataVisitor::validate(const SyntaxTreeBasePtr& cont, const StringList& metaData,
- const string& file, const string& line, bool inParam)
+ const string& file, const string& line, bool inParam)
{
static const string prefix = "cpp:";
for(StringList::const_iterator p = metaData.begin(); p != metaData.end(); ++p)
@@ -5335,19 +5335,19 @@ Slice::Gen::MetaDataVisitor::validate(const SyntaxTreeBasePtr& cont, const Strin
{
if(s.find(prefix) == 0)
{
- string ss = s.substr(prefix.size());
- if(ss.find("type:wstring") == 0 || ss.find("type:string") == 0)
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(cont);
- ModulePtr module = ModulePtr::dynamicCast(cont);
- ClassDefPtr clss = ClassDefPtr::dynamicCast(cont);
- StructPtr strct = StructPtr::dynamicCast(cont);
- ExceptionPtr exception = ExceptionPtr::dynamicCast(cont);
- if((builtin && builtin->kind() == Builtin::KindString) || module || clss || strct || exception)
- {
- continue;
- }
- }
+ string ss = s.substr(prefix.size());
+ if(ss.find("type:wstring") == 0 || ss.find("type:string") == 0)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(cont);
+ ModulePtr module = ModulePtr::dynamicCast(cont);
+ ClassDefPtr clss = ClassDefPtr::dynamicCast(cont);
+ StructPtr strct = StructPtr::dynamicCast(cont);
+ ExceptionPtr exception = ExceptionPtr::dynamicCast(cont);
+ if((builtin && builtin->kind() == Builtin::KindString) || module || clss || strct || exception)
+ {
+ continue;
+ }
+ }
if(SequencePtr::dynamicCast(cont))
{
if(ss.find("type:") == 0 || (inParam && (ss == "array" || ss.find("range") == 0)))
@@ -5356,9 +5356,9 @@ Slice::Gen::MetaDataVisitor::validate(const SyntaxTreeBasePtr& cont, const Strin
}
}
if(StructPtr::dynamicCast(cont) && ss.find("class") == 0)
- {
- continue;
- }
+ {
+ continue;
+ }
cout << file << ":" << line << ": warning: ignoring invalid metadata `" << s << "'" << endl;
}
diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h
index be675175fff..11ae44bf575 100644
--- a/cpp/src/slice2cpp/Gen.h
+++ b/cpp/src/slice2cpp/Gen.h
@@ -21,18 +21,18 @@ class Gen : private ::IceUtil::noncopyable
public:
Gen(const std::string&,
- const std::string&,
- const std::string&,
- const std::string&,
- const std::vector<std::string>&,
- const std::string&,
- const std::vector<std::string>&,
- const std::string&,
- const std::string&,
+ const std::string&,
+ const std::string&,
+ const std::string&,
+ const std::vector<std::string>&,
+ const std::string&,
+ const std::vector<std::string>&,
+ const std::string&,
+ const std::string&,
bool,
bool,
bool,
- bool);
+ bool);
~Gen();
bool operator!() const; // Returns true if there was a constructor error
@@ -68,255 +68,255 @@ private:
{
public:
- GlobalIncludeVisitor(::IceUtil::Output&);
+ GlobalIncludeVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
private:
- ::IceUtil::Output& H;
+ ::IceUtil::Output& H;
- bool _finished;
+ bool _finished;
};
class TypesVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
- TypesVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&, bool);
-
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual bool visitExceptionStart(const ExceptionPtr&);
- virtual void visitExceptionEnd(const ExceptionPtr&);
- virtual bool visitStructStart(const StructPtr&);
- virtual void visitStructEnd(const StructPtr&);
- virtual void visitSequence(const SequencePtr&);
- virtual void visitDictionary(const DictionaryPtr&);
- virtual void visitEnum(const EnumPtr&);
- virtual void visitConst(const ConstPtr&);
- virtual void visitDataMember(const DataMemberPtr&);
+ TypesVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&, bool);
+
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual bool visitExceptionStart(const ExceptionPtr&);
+ virtual void visitExceptionEnd(const ExceptionPtr&);
+ virtual bool visitStructStart(const StructPtr&);
+ virtual void visitStructEnd(const StructPtr&);
+ virtual void visitSequence(const SequencePtr&);
+ virtual void visitDictionary(const DictionaryPtr&);
+ virtual void visitEnum(const EnumPtr&);
+ virtual void visitConst(const ConstPtr&);
+ virtual void visitDataMember(const DataMemberPtr&);
private:
- void emitUpcall(const ExceptionPtr&, const std::string&, bool = false);
+ void emitUpcall(const ExceptionPtr&, const std::string&, bool = false);
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
+ std::string _dllExport;
bool _stream;
- bool _doneStaticSymbol;
- bool _useWstring;
- std::list<bool> _useWstringHist;
+ bool _doneStaticSymbol;
+ bool _useWstring;
+ std::list<bool> _useWstringHist;
};
class ProxyDeclVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
- ProxyDeclVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+ ProxyDeclVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
- virtual bool visitUnitStart(const UnitPtr&);
- virtual void visitUnitEnd(const UnitPtr&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual void visitClassDecl(const ClassDeclPtr&);
+ virtual bool visitUnitStart(const UnitPtr&);
+ virtual void visitUnitEnd(const UnitPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual void visitClassDecl(const ClassDeclPtr&);
private:
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
+ std::string _dllExport;
};
class ProxyVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
- ProxyVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+ ProxyVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
- virtual bool visitUnitStart(const UnitPtr&);
- virtual void visitUnitEnd(const UnitPtr&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
- virtual void visitOperation(const OperationPtr&);
+ virtual bool visitUnitStart(const UnitPtr&);
+ virtual void visitUnitEnd(const UnitPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
private:
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
- bool _useWstring;
- std::list<bool> _useWstringHist;
+ std::string _dllExport;
+ bool _useWstring;
+ std::list<bool> _useWstringHist;
};
class DelegateVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
- DelegateVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+ DelegateVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
- virtual bool visitUnitStart(const UnitPtr&);
- virtual void visitUnitEnd(const UnitPtr&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
- virtual void visitOperation(const OperationPtr&);
+ virtual bool visitUnitStart(const UnitPtr&);
+ virtual void visitUnitEnd(const UnitPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
private:
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
- bool _useWstring;
- std::list<bool> _useWstringHist;
+ std::string _dllExport;
+ bool _useWstring;
+ std::list<bool> _useWstringHist;
};
class DelegateMVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
- DelegateMVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+ DelegateMVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
- virtual bool visitUnitStart(const UnitPtr&);
- virtual void visitUnitEnd(const UnitPtr&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
- virtual void visitOperation(const OperationPtr&);
+ virtual bool visitUnitStart(const UnitPtr&);
+ virtual void visitUnitEnd(const UnitPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
private:
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
- bool _useWstring;
- std::list<bool> _useWstringHist;
+ std::string _dllExport;
+ bool _useWstring;
+ std::list<bool> _useWstringHist;
};
class DelegateDVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
- DelegateDVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+ DelegateDVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
- virtual bool visitUnitStart(const UnitPtr&);
- virtual void visitUnitEnd(const UnitPtr&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
- virtual void visitOperation(const OperationPtr&);
+ virtual bool visitUnitStart(const UnitPtr&);
+ virtual void visitUnitEnd(const UnitPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
private:
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
- bool _useWstring;
- std::list<bool> _useWstringHist;
+ std::string _dllExport;
+ bool _useWstring;
+ std::list<bool> _useWstringHist;
};
class ObjectDeclVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
- ObjectDeclVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+ ObjectDeclVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual void visitClassDecl(const ClassDeclPtr&);
- virtual void visitOperation(const OperationPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual void visitClassDecl(const ClassDeclPtr&);
+ virtual void visitOperation(const OperationPtr&);
private:
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
+ std::string _dllExport;
};
class ObjectVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
- ObjectVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&, bool);
+ ObjectVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&, bool);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
- virtual bool visitExceptionStart(const ExceptionPtr&);
- virtual bool visitStructStart(const StructPtr&);
- virtual void visitOperation(const OperationPtr&);
- virtual void visitDataMember(const DataMemberPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual bool visitExceptionStart(const ExceptionPtr&);
+ virtual bool visitStructStart(const StructPtr&);
+ virtual void visitOperation(const OperationPtr&);
+ virtual void visitDataMember(const DataMemberPtr&);
private:
- void emitGCFunctions(const ClassDefPtr&);
- void emitGCInsertCode(const TypePtr&, const std::string&, const std::string&, int);
- void emitGCClearCode(const TypePtr&, const std::string&, const std::string&, int);
- bool emitVirtualBaseInitializers(const ClassDefPtr&);
- void emitOneShotConstructor(const ClassDefPtr&);
- void emitUpcall(const ClassDefPtr&, const std::string&);
+ void emitGCFunctions(const ClassDefPtr&);
+ void emitGCInsertCode(const TypePtr&, const std::string&, const std::string&, int);
+ void emitGCClearCode(const TypePtr&, const std::string&, const std::string&, int);
+ bool emitVirtualBaseInitializers(const ClassDefPtr&);
+ void emitOneShotConstructor(const ClassDefPtr&);
+ void emitUpcall(const ClassDefPtr&, const std::string&);
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
+ std::string _dllExport;
bool _stream;
- bool _doneStaticSymbol;
- bool _useWstring;
- std::list<bool> _useWstringHist;
+ bool _doneStaticSymbol;
+ bool _useWstring;
+ std::list<bool> _useWstringHist;
};
class IceInternalVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
- IceInternalVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+ IceInternalVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
- virtual bool visitUnitStart(const UnitPtr&);
- virtual void visitUnitEnd(const UnitPtr&);
- virtual void visitClassDecl(const ClassDeclPtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual bool visitUnitStart(const UnitPtr&);
+ virtual void visitUnitEnd(const UnitPtr&);
+ virtual void visitClassDecl(const ClassDeclPtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
private:
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
+ std::string _dllExport;
};
class HandleVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
- HandleVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&, bool);
+ HandleVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&, bool);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual void visitClassDecl(const ClassDeclPtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual void visitClassDecl(const ClassDeclPtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
private:
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
+ std::string _dllExport;
bool _stream;
};
@@ -324,20 +324,20 @@ private:
{
public:
- ImplVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+ ImplVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
private:
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
- bool _useWstring;
- std::list<bool> _useWstringHist;
+ std::string _dllExport;
+ bool _useWstring;
+ std::list<bool> _useWstringHist;
//
// Generate code to emit a local variable declaration and initialize it
@@ -355,46 +355,46 @@ private:
{
public:
- AsyncVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+ AsyncVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
- virtual void visitOperation(const OperationPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
private:
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
- bool _useWstring;
- std::list<bool> _useWstringHist;
+ std::string _dllExport;
+ bool _useWstring;
+ std::list<bool> _useWstringHist;
};
class AsyncImplVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
- AsyncImplVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+ AsyncImplVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
- virtual bool visitUnitStart(const UnitPtr&);
- virtual void visitUnitEnd(const UnitPtr&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
- virtual void visitOperation(const OperationPtr&);
+ virtual bool visitUnitStart(const UnitPtr&);
+ virtual void visitUnitEnd(const UnitPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
private:
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
- bool _useWstring;
- std::list<bool> _useWstringHist;
+ std::string _dllExport;
+ bool _useWstring;
+ std::list<bool> _useWstringHist;
};
private:
@@ -423,7 +423,7 @@ private:
private:
void validate(const SyntaxTreeBasePtr&, const StringList&, const std::string&, const std::string&,
- bool = false);
+ bool = false);
StringSet _history;
};
diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp
index 0be665f5b6a..8d3c6db4d78 100644
--- a/cpp/src/slice2cpp/Main.cpp
+++ b/cpp/src/slice2cpp/Main.cpp
@@ -18,18 +18,18 @@ void
usage(const char* n)
{
cerr << "Usage: " << n << " [options] slice-files...\n";
- cerr <<
+ cerr <<
"Options:\n"
"-h, --help Show this message.\n"
"-v, --version Display the Ice version.\n"
"--header-ext EXT Use EXT instead of the default `h' extension.\n"
"--source-ext EXT Use EXT instead of the default `cpp' extension.\n"
- "--add-header HDR[,GUARD] Add #include for HDR (with guard GUARD) to generated source file.\n"
+ "--add-header HDR[,GUARD] Add #include for HDR (with guard GUARD) to generated source file.\n"
"-DNAME Define NAME as 1.\n"
"-DNAME=DEF Define NAME as DEF.\n"
"-UNAME Remove any definition for NAME.\n"
"-IDIR Put DIR in the include file search path.\n"
- "-E Print preprocessor output on stdout.\n"
+ "-E Print preprocessor output on stdout.\n"
"--include-dir DIR Use DIR as the header include directory in source files.\n"
"--output-dir DIR Create files in the directory DIR.\n"
"--dll-export SYMBOL Use SYMBOL for DLL exports.\n"
@@ -74,21 +74,21 @@ main(int argc, char* argv[])
}
catch(const IceUtil::BadOptException& e)
{
- cerr << argv[0] << ": " << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": " << e.reason << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(argv[0]);
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
string headerExtension = opts.optArg("header-ext");
@@ -101,20 +101,20 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D" + Preprocessor::addQuotes(*i);
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U" + Preprocessor::addQuotes(*i);
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
vector<string> includePaths;
includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I" + Preprocessor::addQuotes(*i);
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
@@ -141,75 +141,75 @@ main(int argc, char* argv[])
if(args.empty())
{
- cerr << argv[0] << ": no input file" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": no input file" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
int status = EXIT_SUCCESS;
for(i = args.begin(); i != args.end(); ++i)
{
- if(depend)
- {
- Preprocessor icecpp(argv[0], *i, cppArgs);
- icecpp.printMakefileDependencies(Preprocessor::CPlusPlus);
- }
- else
- {
- Preprocessor icecpp(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp.preprocess(false);
-
- if(cppHandle == 0)
- {
- return EXIT_FAILURE;
- }
-
- if(preprocess)
- {
- char buf[4096];
- while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
- {
- if(fputs(buf, stdout) == EOF)
- {
- return EXIT_FAILURE;
- }
- }
- if(!icecpp.close())
- {
- return EXIT_FAILURE;
- }
- }
- else
- {
- UnitPtr u = Unit::createUnit(false, false, ice, caseSensitive);
- int parseStatus = u->parse(cppHandle, debug);
-
- if(!icecpp.close())
- {
- u->destroy();
- return EXIT_FAILURE;
- }
-
- if(parseStatus == EXIT_FAILURE)
- {
- status = EXIT_FAILURE;
- }
- else
- {
- Gen gen(argv[0], icecpp.getBaseName(), headerExtension, sourceExtension, extraHeaders, include,
- includePaths, dllExport, output, impl, checksum, stream, ice);
- if(!gen)
- {
- u->destroy();
- return EXIT_FAILURE;
- }
- gen.generate(u);
- }
-
- u->destroy();
- }
- }
+ if(depend)
+ {
+ Preprocessor icecpp(argv[0], *i, cppArgs);
+ icecpp.printMakefileDependencies(Preprocessor::CPlusPlus);
+ }
+ else
+ {
+ Preprocessor icecpp(argv[0], *i, cppArgs);
+ FILE* cppHandle = icecpp.preprocess(false);
+
+ if(cppHandle == 0)
+ {
+ return EXIT_FAILURE;
+ }
+
+ if(preprocess)
+ {
+ char buf[4096];
+ while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
+ {
+ if(fputs(buf, stdout) == EOF)
+ {
+ return EXIT_FAILURE;
+ }
+ }
+ if(!icecpp.close())
+ {
+ return EXIT_FAILURE;
+ }
+ }
+ else
+ {
+ UnitPtr u = Unit::createUnit(false, false, ice, caseSensitive);
+ int parseStatus = u->parse(cppHandle, debug);
+
+ if(!icecpp.close())
+ {
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+
+ if(parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
+ else
+ {
+ Gen gen(argv[0], icecpp.getBaseName(), headerExtension, sourceExtension, extraHeaders, include,
+ includePaths, dllExport, output, impl, checksum, stream, ice);
+ if(!gen)
+ {
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+ gen.generate(u);
+ }
+
+ u->destroy();
+ }
+ }
}
return status;
diff --git a/cpp/src/slice2cppe/Gen.cpp b/cpp/src/slice2cppe/Gen.cpp
index f4f4c341824..f616f28d264 100644
--- a/cpp/src/slice2cppe/Gen.cpp
+++ b/cpp/src/slice2cppe/Gen.cpp
@@ -53,10 +53,10 @@ getDeprecateSymbol(const ContainedPtr& p1, const ContainedPtr& p2)
return deprecateSymbol;
}
-Slice::Gen::Gen(const string& name, const string& base, const string& headerExtension,
- const string& sourceExtension, const vector<string>& extraHeaders, const string& include,
- const vector<string>& includePaths, const string& dllExport, const string& dir, bool imp,
- bool ice) :
+Slice::Gen::Gen(const string& name, const string& base, const string& headerExtension,
+ const string& sourceExtension, const vector<string>& extraHeaders, const string& include,
+ const vector<string>& includePaths, const string& dllExport, const string& dir, bool imp,
+ bool ice) :
_base(base),
_headerExtension(headerExtension),
_sourceExtension(sourceExtension),
@@ -69,16 +69,16 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte
{
for(vector<string>::iterator p = _includePaths.begin(); p != _includePaths.end(); ++p)
{
- if(p->length() && (*p)[p->length() - 1] != '/')
- {
- *p += '/';
- }
+ if(p->length() && (*p)[p->length() - 1] != '/')
+ {
+ *p += '/';
+ }
}
string::size_type pos = _base.find_last_of("/\\");
if(pos != string::npos)
{
- _base.erase(0, pos + 1);
+ _base.erase(0, pos + 1);
}
if(_impl)
@@ -132,22 +132,22 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte
string fileC = _base + "." + _sourceExtension;
if(!dir.empty())
{
- fileH = dir + '/' + fileH;
- fileC = dir + '/' + fileC;
+ fileH = dir + '/' + fileH;
+ fileC = dir + '/' + fileC;
}
H.open(fileH.c_str());
if(!H)
{
- cerr << name << ": can't open `" << fileH << "' for writing" << endl;
- return;
+ cerr << name << ": can't open `" << fileH << "' for writing" << endl;
+ return;
}
C.open(fileC.c_str());
if(!C)
{
- cerr << name << ": can't open `" << fileC << "' for writing" << endl;
- return;
+ cerr << name << ": can't open `" << fileC << "' for writing" << endl;
+ return;
}
printHeader(H);
@@ -158,7 +158,7 @@ Slice::Gen::Gen(const string& name, const string& base, const string& headerExte
string s = fileH;
if(_include.size())
{
- s = _include + '/' + s;
+ s = _include + '/' + s;
}
transform(s.begin(), s.end(), s.begin(), ToIfdef());
H << "\n#ifndef __" << s << "__";
@@ -202,7 +202,7 @@ Slice::Gen::generate(const UnitPtr& p)
C << "\n#include <";
if(_include.size())
{
- C << _include << '/';
+ C << _include << '/';
}
C << _base << "." << _headerExtension << ">";
@@ -217,35 +217,35 @@ Slice::Gen::generate(const UnitPtr& p)
if(p->usesProxies())
{
- H << "\n#include <IceE/Proxy.h>";
+ H << "\n#include <IceE/Proxy.h>";
}
if(p->hasNonLocalClassDefs())
{
H << "\n#ifndef ICEE_PURE_CLIENT";
- H << "\n# include <IceE/Object.h>";
- H << "\n# include <IceE/Incoming.h>";
+ H << "\n# include <IceE/Object.h>";
+ H << "\n# include <IceE/Incoming.h>";
H << "\n#endif";
- H << "\n#include <IceE/Outgoing.h>";
- C << "\n#include <IceE/Connection.h>";
- C << "\n#include <IceE/LocalException.h>";
+ H << "\n#include <IceE/Outgoing.h>";
+ C << "\n#include <IceE/Connection.h>";
+ C << "\n#include <IceE/LocalException.h>";
}
if(p->hasNonLocalExceptions())
{
- H << "\n#include <IceE/UserExceptionFactory.h>";
+ H << "\n#include <IceE/UserExceptionFactory.h>";
}
if(p->hasDataOnlyClasses() || p->hasNonLocalExceptions())
{
- H << "\n#include <IceE/FactoryTable.h>";
+ H << "\n#include <IceE/FactoryTable.h>";
}
if(p->usesNonLocals())
{
- C << "\n#include <IceE/BasicStream.h>";
+ C << "\n#include <IceE/BasicStream.h>";
C << "\n#ifndef ICEE_PURE_CLIENT";
- C << "\n# include <IceE/Object.h>";
+ C << "\n# include <IceE/Object.h>";
C << "\n#endif";
}
@@ -260,7 +260,7 @@ Slice::Gen::generate(const UnitPtr& p)
for(StringList::const_iterator q = includes.begin(); q != includes.end(); ++q)
{
- H << "\n#include <" << changeInclude(*q, _includePaths) << "." << _headerExtension << ">";
+ H << "\n#include <" << changeInclude(*q, _includePaths) << "." << _headerExtension << ">";
}
H << "\n#include <IceE/UndefSysMacros.h>";
@@ -279,7 +279,7 @@ Slice::Gen::generate(const UnitPtr& p)
printDllExportStuff(H, _dllExport);
if(_dllExport.size())
{
- _dllExport += " ";
+ _dllExport += " ";
}
ProxyDeclVisitor proxyDeclVisitor(H, C, _dllExport);
@@ -312,7 +312,7 @@ Slice::Gen::generate(const UnitPtr& p)
}
implH << _base << ".h>";
- writeExtraHeaders(implC);
+ writeExtraHeaders(implC);
implC << "\n#include <";
if(_include.size())
@@ -331,29 +331,29 @@ Slice::Gen::writeExtraHeaders(Output& out)
{
for(vector<string>::const_iterator i = _extraHeaders.begin(); i != _extraHeaders.end(); ++i)
{
- string hdr = *i;
- string guard;
- string::size_type pos = hdr.rfind(',');
- if(pos != string::npos)
- {
- hdr = i->substr(0, pos);
- guard = i->substr(pos + 1);
- }
- if(!guard.empty())
- {
- out << "\n#ifndef " << guard;
- out << "\n#define " << guard;
- }
- out << "\n#include <";
- if(!_include.empty())
- {
- out << _include << '/';
- }
- out << hdr << '>';
- if(!guard.empty())
- {
- out << "\n#endif";
- }
+ string hdr = *i;
+ string guard;
+ string::size_type pos = hdr.rfind(',');
+ if(pos != string::npos)
+ {
+ hdr = i->substr(0, pos);
+ guard = i->substr(pos + 1);
+ }
+ if(!guard.empty())
+ {
+ out << "\n#ifndef " << guard;
+ out << "\n#define " << guard;
+ }
+ out << "\n#include <";
+ if(!_include.empty())
+ {
+ out << _include << '/';
+ }
+ out << hdr << '>';
+ if(!guard.empty())
+ {
+ out << "\n#endif";
+ }
}
}
@@ -378,7 +378,7 @@ Slice::Gen::GlobalIncludeVisitor::visitModuleStart(const ModulePtr& p)
string s = *q;
if(s.find(includePrefix) == 0)
{
- H << nl << "#include <" << s.substr(includePrefix.size()) << ">";
+ H << nl << "#include <" << s.substr(includePrefix.size()) << ">";
}
}
_finished = true;
@@ -438,23 +438,23 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- params.push_back(fixKwd((*q)->name()));
+ params.push_back(fixKwd((*q)->name()));
}
for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q)
{
- string typeName = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData());
- allTypes.push_back(typeName);
- allParamDecls.push_back(typeName + " __ice_" + (*q)->name());
+ string typeName = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData());
+ allTypes.push_back(typeName);
+ allParamDecls.push_back(typeName + " __ice_" + (*q)->name());
}
if(base)
{
- DataMemberList baseDataMembers = base->allDataMembers();
- for(q = baseDataMembers.begin(); q != baseDataMembers.end(); ++q)
- {
- baseParams.push_back("__ice_" + (*q)->name());
- }
+ DataMemberList baseDataMembers = base->allDataMembers();
+ for(q = baseDataMembers.begin(); q != baseDataMembers.end(); ++q)
+ {
+ baseParams.push_back("__ice_" + (*q)->name());
+ }
}
H << sp << nl << "class " << _dllExport << name << " : ";
@@ -462,11 +462,11 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
H << "public ";
if(!base)
{
- H << (p->isLocal() ? "::Ice::LocalException" : "::Ice::UserException");
+ H << (p->isLocal() ? "::Ice::LocalException" : "::Ice::UserException");
}
else
{
- H << fixKwd(base->scoped());
+ H << fixKwd(base->scoped());
}
H.restoreIndent();
H << sb;
@@ -478,96 +478,96 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
H << sp << nl << name << spar;
if(p->isLocal())
{
- H << "const char*" << "int";
+ H << "const char*" << "int";
}
H << epar;
if(!p->isLocal())
{
- H << " {}";
+ H << " {}";
}
else
{
- H << ';';
+ H << ';';
}
if(!allTypes.empty())
{
- H << nl;
- if(!p->isLocal() && allTypes.size() == 1)
- {
- H << "explicit ";
- }
- H << name << spar;
- if(p->isLocal())
- {
- H << "const char*" << "int";
- }
- H << allTypes << epar << ';';
+ H << nl;
+ if(!p->isLocal() && allTypes.size() == 1)
+ {
+ H << "explicit ";
+ }
+ H << name << spar;
+ if(p->isLocal())
+ {
+ H << "const char*" << "int";
+ }
+ H << allTypes << epar << ';';
}
H << nl << "virtual ~" << name << "() throw();";
H << sp;
if(p->isLocal())
{
- C << sp << nl << scoped.substr(2) << "::" << name << spar << "const char* __file" << "int __line" << epar
- << " :";
- C.inc();
- emitUpcall(base, "(__file, __line)", true);
- C.dec();
- C << sb;
- C << eb;
+ C << sp << nl << scoped.substr(2) << "::" << name << spar << "const char* __file" << "int __line" << epar
+ << " :";
+ C.inc();
+ emitUpcall(base, "(__file, __line)", true);
+ C.dec();
+ C << sb;
+ C << eb;
}
if(!allTypes.empty())
{
- C << sp << nl;
- C << scoped.substr(2) << "::" << name << spar;
- if(p->isLocal())
- {
- C << "const char* __file" << "int __line";
- }
- C << allParamDecls << epar;
- if(p->isLocal() || !baseParams.empty() || !params.empty())
- {
- C << " :";
- C.inc();
- string upcall;
- if(!allParamDecls.empty())
- {
- upcall = "(";
- if(p->isLocal())
- {
- upcall += "__file, __line";
- }
- for(pi = baseParams.begin(); pi != baseParams.end(); ++pi)
- {
- if(p->isLocal() || pi != baseParams.begin())
- {
- upcall += ", ";
- }
- upcall += *pi;
- }
- upcall += ")";
- }
- if(!params.empty())
- {
- upcall += ",";
- }
- emitUpcall(base, upcall, p->isLocal());
- }
- for(pi = params.begin(); pi != params.end(); ++pi)
- {
- if(pi != params.begin())
- {
- C << ",";
- }
- C << nl << *pi << "(__ice_" << *pi << ')';
- }
- if(p->isLocal() || !baseParams.empty() || !params.empty())
- {
- C.dec();
- }
- C << sb;
- C << eb;
+ C << sp << nl;
+ C << scoped.substr(2) << "::" << name << spar;
+ if(p->isLocal())
+ {
+ C << "const char* __file" << "int __line";
+ }
+ C << allParamDecls << epar;
+ if(p->isLocal() || !baseParams.empty() || !params.empty())
+ {
+ C << " :";
+ C.inc();
+ string upcall;
+ if(!allParamDecls.empty())
+ {
+ upcall = "(";
+ if(p->isLocal())
+ {
+ upcall += "__file, __line";
+ }
+ for(pi = baseParams.begin(); pi != baseParams.end(); ++pi)
+ {
+ if(p->isLocal() || pi != baseParams.begin())
+ {
+ upcall += ", ";
+ }
+ upcall += *pi;
+ }
+ upcall += ")";
+ }
+ if(!params.empty())
+ {
+ upcall += ",";
+ }
+ emitUpcall(base, upcall, p->isLocal());
+ }
+ for(pi = params.begin(); pi != params.end(); ++pi)
+ {
+ if(pi != params.begin())
+ {
+ C << ",";
+ }
+ C << nl << *pi << "(__ice_" << *pi << ')';
+ }
+ if(p->isLocal() || !baseParams.empty() || !params.empty())
+ {
+ C.dec();
+ }
+ C << sb;
+ C << eb;
}
C << sp << nl;
@@ -587,7 +587,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
if(p->isLocal())
{
- H << nl << "virtual ::std::string toString() const;";
+ H << nl << "virtual ::std::string toString() const;";
}
H << nl << "virtual ::Ice::Exception* ice_clone() const;";
@@ -604,11 +604,11 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
if(!p->isLocal())
{
- H << sp << nl << "static const ::IceInternal::UserExceptionFactoryPtr& ice_factory();";
+ H << sp << nl << "static const ::IceInternal::UserExceptionFactoryPtr& ice_factory();";
}
if(!dataMembers.empty())
{
- H << sp;
+ H << sp;
}
return true;
}
@@ -626,100 +626,100 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
if(!p->isLocal())
{
- ExceptionPtr base = p->base();
+ ExceptionPtr base = p->base();
- H << sp << nl << "virtual void __write(::IceInternal::BasicStream*) const;";
- H << nl << "virtual void __read(::IceInternal::BasicStream*, bool);";
- C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const";
- C << sb;
- C << nl << "__os->write(::std::string(\"" << p->scoped() << "\"), false);";
- C << nl << "__os->startWriteSlice();";
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), true, "", true, (*q)->getMetaData());
- }
- C << nl << "__os->endWriteSlice();";
- if(base)
- {
- emitUpcall(base, "::__write(__os);");
- }
- C << eb;
-
- C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is, bool __rid)";
- C << sb;
- C << nl << "if(__rid)";
- C << sb;
- C << nl << "::std::string myId;";
- C << nl << "__is->read(myId, false);";
- C << eb;
- C << nl << "__is->startReadSlice();";
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), false, "", true, (*q)->getMetaData());
- }
- C << nl << "__is->endReadSlice();";
- if(base)
- {
- emitUpcall(base, "::__read(__is, true);");
- }
- C << eb;
-
- factoryName = "__F" + p->flattenedScope() + p->name();
-
- C << sp << nl << "struct " << factoryName << " : public ::IceInternal::UserExceptionFactory";
- C << sb;
- C << sp << nl << "virtual void";
- C << nl << "createAndThrow()";
- C << sb;
- C << nl << "throw " << scoped << "();";
- C << eb;
- C << eb << ';';
-
- C << sp << nl << "static ::IceInternal::UserExceptionFactoryPtr " << factoryName
- << "__Ptr = new " << factoryName << ';';
-
- C << sp << nl << "const ::IceInternal::UserExceptionFactoryPtr&";
- C << nl << scoped.substr(2) << "::ice_factory()";
- C << sb;
- C << nl << "return " << factoryName << "__Ptr;";
- C << eb;
-
- C << sp << nl << "class " << factoryName << "__Init";
- C << sb;
- C.dec();
- C << nl << "public:";
- C.inc();
- C << sp << nl << factoryName << "__Init()";
- C << sb;
- C << nl << "::IceInternal::factoryTable->addExceptionFactory(\"" << p->scoped() << "\", " << scoped
- << "::ice_factory());";
- C << eb;
- C << sp << nl << "~" << factoryName << "__Init()";
- C << sb;
- C << nl << "::IceInternal::factoryTable->removeExceptionFactory(\"" << p->scoped() << "\");";
- C << eb;
- C << eb << ';';
- C << sp << nl << "static " << factoryName << "__Init "<< factoryName << "__i;";
- C << sp << nl << "#ifdef __APPLE__";
-
- string initfuncname = "__F" + p->flattenedScope() + p->name() + "__initializer";
- C << nl << "extern \"C\" { void " << initfuncname << "() {} }";
- C << nl << "#endif";
+ H << sp << nl << "virtual void __write(::IceInternal::BasicStream*) const;";
+ H << nl << "virtual void __read(::IceInternal::BasicStream*, bool);";
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const";
+ C << sb;
+ C << nl << "__os->write(::std::string(\"" << p->scoped() << "\"), false);";
+ C << nl << "__os->startWriteSlice();";
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), true, "", true, (*q)->getMetaData());
+ }
+ C << nl << "__os->endWriteSlice();";
+ if(base)
+ {
+ emitUpcall(base, "::__write(__os);");
+ }
+ C << eb;
+
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is, bool __rid)";
+ C << sb;
+ C << nl << "if(__rid)";
+ C << sb;
+ C << nl << "::std::string myId;";
+ C << nl << "__is->read(myId, false);";
+ C << eb;
+ C << nl << "__is->startReadSlice();";
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), false, "", true, (*q)->getMetaData());
+ }
+ C << nl << "__is->endReadSlice();";
+ if(base)
+ {
+ emitUpcall(base, "::__read(__is, true);");
+ }
+ C << eb;
+
+ factoryName = "__F" + p->flattenedScope() + p->name();
+
+ C << sp << nl << "struct " << factoryName << " : public ::IceInternal::UserExceptionFactory";
+ C << sb;
+ C << sp << nl << "virtual void";
+ C << nl << "createAndThrow()";
+ C << sb;
+ C << nl << "throw " << scoped << "();";
+ C << eb;
+ C << eb << ';';
+
+ C << sp << nl << "static ::IceInternal::UserExceptionFactoryPtr " << factoryName
+ << "__Ptr = new " << factoryName << ';';
+
+ C << sp << nl << "const ::IceInternal::UserExceptionFactoryPtr&";
+ C << nl << scoped.substr(2) << "::ice_factory()";
+ C << sb;
+ C << nl << "return " << factoryName << "__Ptr;";
+ C << eb;
+
+ C << sp << nl << "class " << factoryName << "__Init";
+ C << sb;
+ C.dec();
+ C << nl << "public:";
+ C.inc();
+ C << sp << nl << factoryName << "__Init()";
+ C << sb;
+ C << nl << "::IceInternal::factoryTable->addExceptionFactory(\"" << p->scoped() << "\", " << scoped
+ << "::ice_factory());";
+ C << eb;
+ C << sp << nl << "~" << factoryName << "__Init()";
+ C << sb;
+ C << nl << "::IceInternal::factoryTable->removeExceptionFactory(\"" << p->scoped() << "\");";
+ C << eb;
+ C << eb << ';';
+ C << sp << nl << "static " << factoryName << "__Init "<< factoryName << "__i;";
+ C << sp << nl << "#ifdef __APPLE__";
+
+ string initfuncname = "__F" + p->flattenedScope() + p->name() + "__initializer";
+ C << nl << "extern \"C\" { void " << initfuncname << "() {} }";
+ C << nl << "#endif";
}
H << eb << ';';
if(!p->isLocal())
{
- //
- // We need an instance here to trigger initialization if the implementation is in a shared libarry.
- // But we do this only once per source file, because a single instance is sufficient to initialize
- // all of the globals in a shared library.
- //
- if(!_doneStaticSymbol)
- {
- _doneStaticSymbol = true;
- H << sp << nl << "static " << name << " __" << p->name() << "_init;";
- }
+ //
+ // We need an instance here to trigger initialization if the implementation is in a shared libarry.
+ // But we do this only once per source file, because a single instance is sufficient to initialize
+ // all of the globals in a shared library.
+ //
+ if(!_doneStaticSymbol)
+ {
+ _doneStaticSymbol = true;
+ H << sp << nl << "static " << name << " __" << p->name() << "_init;";
+ }
}
_useWstring = resetUseWstring(_useWstringHist);
@@ -753,7 +753,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- params.push_back(fixKwd((*q)->name()));
+ params.push_back(fixKwd((*q)->name()));
}
H << sp;
@@ -785,10 +785,10 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
C << eb;
for(pi = params.begin(); pi != params.end(); ++pi)
{
- C << nl << "if(" << *pi << " != __rhs." << *pi << ')';
- C << sb;
- C << nl << "return true;";
- C << eb;
+ C << nl << "if(" << *pi << " != __rhs." << *pi << ')';
+ C << sb;
+ C << nl << "return true;";
+ C << eb;
}
C << nl << "return false;";
C << eb;
@@ -800,41 +800,41 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
C << eb;
for(pi = params.begin(); pi != params.end(); ++pi)
{
- C << nl << "if(" << *pi << " < __rhs." << *pi << ')';
- C << sb;
- C << nl << "return true;";
- C << eb;
- C << nl << "else if(__rhs." << *pi << " < " << *pi << ')';
- C << sb;
- C << nl << "return false;";
- C << eb;
+ C << nl << "if(" << *pi << " < __rhs." << *pi << ')';
+ C << sb;
+ C << nl << "return true;";
+ C << eb;
+ C << nl << "else if(__rhs." << *pi << " < " << *pi << ')';
+ C << sb;
+ C << nl << "return false;";
+ C << eb;
}
C << nl << "return false;";
C << eb;
if(!p->isLocal())
{
- //
- // None of these member functions is virtual!
- //
- H << sp << nl << _dllExport << "void __write(::IceInternal::BasicStream*) const;";
- H << nl << _dllExport << "void __read(::IceInternal::BasicStream*);";
-
- C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const";
- C << sb;
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), true, "", true, (*q)->getMetaData());
- }
- C << eb;
-
- C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is)";
- C << sb;
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), false, "", true, (*q)->getMetaData());
- }
- C << eb;
+ //
+ // None of these member functions is virtual!
+ //
+ H << sp << nl << _dllExport << "void __write(::IceInternal::BasicStream*) const;";
+ H << nl << _dllExport << "void __read(::IceInternal::BasicStream*);";
+
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__write(::IceInternal::BasicStream* __os) const";
+ C << sb;
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), true, "", true, (*q)->getMetaData());
+ }
+ C << eb;
+
+ C << sp << nl << "void" << nl << scoped.substr(2) << "::__read(::IceInternal::BasicStream* __is)";
+ C << sb;
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeMarshalUnmarshalCode(C, (*q)->type(), fixKwd((*q)->name()), false, "", true, (*q)->getMetaData());
+ }
+ C << eb;
}
H << eb << ';';
@@ -870,139 +870,139 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if(!p->isLocal())
{
- string scoped = fixKwd(p->scoped());
- string scope = fixKwd(p->scope());
-
- H << sp << nl << "class __U__" << name << " { };";
+ string scoped = fixKwd(p->scoped());
+ string scope = fixKwd(p->scope());
+
+ H << sp << nl << "class __U__" << name << " { };";
if(!seqType.empty())
- {
- H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "&, __U__"
- << name << ");";
- H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&, __U__" << name << ");";
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
- << scoped << "& v, " << scope << "__U__" << name << ")";
- C << sb;
- C << nl << "::Ice::Int size = static_cast< ::Ice::Int>(v.size());";
- C << nl << "__os->writeSize(size);";
- C << nl << "for(" << name << "::const_iterator p = v.begin(); p != v.end(); ++p)";
- C << sb;
- writeMarshalUnmarshalCode(C, type, "(*p)", true);
- C << eb;
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
- << "& v, " << scope << "__U__" << name << ')';
- C << sb;
- C << nl << "::Ice::Int sz;";
- C << nl << "__is->readSize(sz);";
- C << nl << name << "(sz).swap(v);";
- if(type->isVariableLength())
- {
- // Protect against bogus sequence sizes.
- C << nl << "__is->startSeq(sz, " << type->minWireSize() << ");";
- }
- else
- {
- C << nl << "__is->checkFixedSeq(sz, " << type->minWireSize() << ");";
- }
- C << nl << "for(" << name << "::iterator p = v.begin(); p != v.end(); ++p)";
- C << sb;
- writeMarshalUnmarshalCode(C, type, "(*p)", false);
-
- //
- // After unmarshaling each element, check that there are still enough bytes left in the stream
- // to unmarshal the remainder of the sequence, and decrement the count of elements
- // yet to be unmarshaled for sequences with variable-length element type (that is, for sequences
- // of classes, structs, dictionaries, sequences, strings, or proxies). This allows us to
- // abort unmarshaling for bogus sequence sizes at the earliest possible moment.
- // (For fixed-length sequences, we don't need to do this because the prediction of how many
- // bytes will be taken up by the sequence is accurate.)
- //
- if(type->isVariableLength())
- {
- if(!SequencePtr::dynamicCast(type))
- {
- //
- // No need to check for directly nested sequences because, at the start of each
- // sequence, we check anyway.
- //
- C << nl << "__is->checkSeq();";
- }
- C << nl << "__is->endElement();";
- }
- C << eb;
- if(type->isVariableLength())
- {
- C << nl << "__is->endSeq(sz);";
- }
- C << eb;
- }
- else if(!builtin || builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindObjectProxy)
- {
- H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << s << "*, const " << s
- << "*, __U__" << name << ");";
- H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&, __U__" << name << ");";
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
- << s << "* begin, const " << s << "* end, " << scope << "__U__" << name << ")";
- C << sb;
- C << nl << "::Ice::Int size = static_cast< ::Ice::Int>(end - begin);";
- C << nl << "__os->writeSize(size);";
- C << nl << "for(int i = 0; i < size; ++i)";
- C << sb;
- writeMarshalUnmarshalCode(C, type, "begin[i]", true);
- C << eb;
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
- << "& v, " << scope << "__U__" << name << ')';
- C << sb;
- C << nl << "::Ice::Int sz;";
- C << nl << "__is->readSize(sz);";
- if(type->isVariableLength())
- {
- // Protect against bogus sequence sizes.
- C << nl << "__is->startSeq(sz, " << type->minWireSize() << ");";
- }
- else
- {
- C << nl << "__is->checkFixedSeq(sz, " << type->minWireSize() << ");";
- }
- C << nl << "v.resize(sz);";
- C << nl << "for(int i = 0; i < sz; ++i)";
- C << sb;
- writeMarshalUnmarshalCode(C, type, "v[i]", false);
-
- //
- // After unmarshaling each element, check that there are still enough bytes left in the stream
- // to unmarshal the remainder of the sequence, and decrement the count of elements
- // yet to be unmarshaled for sequences with variable-length element type (that is, for sequences
- // of classes, structs, dictionaries, sequences, strings, or proxies). This allows us to
- // abort unmarshaling for bogus sequence sizes at the earliest possible moment.
- // (For fixed-length sequences, we don't need to do this because the prediction of how many
- // bytes will be taken up by the sequence is accurate.)
- //
- if(type->isVariableLength())
- {
- if(!SequencePtr::dynamicCast(type))
- {
- //
- // No need to check for directly nested sequences because, at the start of each
- // sequence, we check anyway.
- //
- C << nl << "__is->checkSeq();";
- }
- C << nl << "__is->endElement();";
- }
- C << eb;
- if(type->isVariableLength())
- {
- C << nl << "__is->endSeq(sz);";
- }
- C << eb;
- }
+ {
+ H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "&, __U__"
+ << name << ");";
+ H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&, __U__" << name << ");";
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
+ << scoped << "& v, " << scope << "__U__" << name << ")";
+ C << sb;
+ C << nl << "::Ice::Int size = static_cast< ::Ice::Int>(v.size());";
+ C << nl << "__os->writeSize(size);";
+ C << nl << "for(" << name << "::const_iterator p = v.begin(); p != v.end(); ++p)";
+ C << sb;
+ writeMarshalUnmarshalCode(C, type, "(*p)", true);
+ C << eb;
+ C << eb;
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
+ << "& v, " << scope << "__U__" << name << ')';
+ C << sb;
+ C << nl << "::Ice::Int sz;";
+ C << nl << "__is->readSize(sz);";
+ C << nl << name << "(sz).swap(v);";
+ if(type->isVariableLength())
+ {
+ // Protect against bogus sequence sizes.
+ C << nl << "__is->startSeq(sz, " << type->minWireSize() << ");";
+ }
+ else
+ {
+ C << nl << "__is->checkFixedSeq(sz, " << type->minWireSize() << ");";
+ }
+ C << nl << "for(" << name << "::iterator p = v.begin(); p != v.end(); ++p)";
+ C << sb;
+ writeMarshalUnmarshalCode(C, type, "(*p)", false);
+
+ //
+ // After unmarshaling each element, check that there are still enough bytes left in the stream
+ // to unmarshal the remainder of the sequence, and decrement the count of elements
+ // yet to be unmarshaled for sequences with variable-length element type (that is, for sequences
+ // of classes, structs, dictionaries, sequences, strings, or proxies). This allows us to
+ // abort unmarshaling for bogus sequence sizes at the earliest possible moment.
+ // (For fixed-length sequences, we don't need to do this because the prediction of how many
+ // bytes will be taken up by the sequence is accurate.)
+ //
+ if(type->isVariableLength())
+ {
+ if(!SequencePtr::dynamicCast(type))
+ {
+ //
+ // No need to check for directly nested sequences because, at the start of each
+ // sequence, we check anyway.
+ //
+ C << nl << "__is->checkSeq();";
+ }
+ C << nl << "__is->endElement();";
+ }
+ C << eb;
+ if(type->isVariableLength())
+ {
+ C << nl << "__is->endSeq(sz);";
+ }
+ C << eb;
+ }
+ else if(!builtin || builtin->kind() == Builtin::KindObject || builtin->kind() == Builtin::KindObjectProxy)
+ {
+ H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << s << "*, const " << s
+ << "*, __U__" << name << ");";
+ H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&, __U__" << name << ");";
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
+ << s << "* begin, const " << s << "* end, " << scope << "__U__" << name << ")";
+ C << sb;
+ C << nl << "::Ice::Int size = static_cast< ::Ice::Int>(end - begin);";
+ C << nl << "__os->writeSize(size);";
+ C << nl << "for(int i = 0; i < size; ++i)";
+ C << sb;
+ writeMarshalUnmarshalCode(C, type, "begin[i]", true);
+ C << eb;
+ C << eb;
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
+ << "& v, " << scope << "__U__" << name << ')';
+ C << sb;
+ C << nl << "::Ice::Int sz;";
+ C << nl << "__is->readSize(sz);";
+ if(type->isVariableLength())
+ {
+ // Protect against bogus sequence sizes.
+ C << nl << "__is->startSeq(sz, " << type->minWireSize() << ");";
+ }
+ else
+ {
+ C << nl << "__is->checkFixedSeq(sz, " << type->minWireSize() << ");";
+ }
+ C << nl << "v.resize(sz);";
+ C << nl << "for(int i = 0; i < sz; ++i)";
+ C << sb;
+ writeMarshalUnmarshalCode(C, type, "v[i]", false);
+
+ //
+ // After unmarshaling each element, check that there are still enough bytes left in the stream
+ // to unmarshal the remainder of the sequence, and decrement the count of elements
+ // yet to be unmarshaled for sequences with variable-length element type (that is, for sequences
+ // of classes, structs, dictionaries, sequences, strings, or proxies). This allows us to
+ // abort unmarshaling for bogus sequence sizes at the earliest possible moment.
+ // (For fixed-length sequences, we don't need to do this because the prediction of how many
+ // bytes will be taken up by the sequence is accurate.)
+ //
+ if(type->isVariableLength())
+ {
+ if(!SequencePtr::dynamicCast(type))
+ {
+ //
+ // No need to check for directly nested sequences because, at the start of each
+ // sequence, we check anyway.
+ //
+ C << nl << "__is->checkSeq();";
+ }
+ C << nl << "__is->endElement();";
+ }
+ C << eb;
+ if(type->isVariableLength())
+ {
+ C << nl << "__is->endSeq(sz);";
+ }
+ C << eb;
+ }
}
}
@@ -1015,48 +1015,48 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
string ks = typeToString(keyType, _useWstring, p->keyMetaData());
if(ks[0] == ':')
{
- ks.insert(0, " ");
+ ks.insert(0, " ");
}
string vs = typeToString(valueType, _useWstring, p->valueMetaData());
H << sp << nl << "typedef ::std::map<" << ks << ", " << vs << "> " << name << ';';
if(!p->isLocal())
{
- string scoped = fixKwd(p->scoped());
- string scope = fixKwd(p->scope());
-
- H << sp << nl << "class __U__" << name << " { };";
- H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name
- << "&, __U__" << name << ");";
- H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name
- << "&, __U__" << name << ");";
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
- << scoped << "& v, " << scope << "__U__" << name << ")";
- C << sb;
- C << nl << "__os->writeSize(::Ice::Int(v.size()));";
- C << nl << scoped << "::const_iterator p;";
- C << nl << "for(p = v.begin(); p != v.end(); ++p)";
- C << sb;
- writeMarshalUnmarshalCode(C, keyType, "p->first", true);
- writeMarshalUnmarshalCode(C, valueType, "p->second", true);
- C << eb;
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
- << "& v, " << scope << "__U__" << name << ')';
- C << sb;
- C << nl << "::Ice::Int sz;";
- C << nl << "__is->readSize(sz);";
- C << nl << "while(sz--)";
- C << sb;
- C << nl << "::std::pair<const " << ks << ", " << vs << "> pair;";
- string pf = string("const_cast<") + ks + "&>(pair.first)";
- writeMarshalUnmarshalCode(C, keyType, pf, false);
- C << nl << scoped << "::iterator __i = v.insert(v.end(), pair);";
- writeMarshalUnmarshalCode(C, valueType, "__i->second", false);
- C << eb;
- C << eb;
+ string scoped = fixKwd(p->scoped());
+ string scope = fixKwd(p->scope());
+
+ H << sp << nl << "class __U__" << name << " { };";
+ H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name
+ << "&, __U__" << name << ");";
+ H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name
+ << "&, __U__" << name << ");";
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
+ << scoped << "& v, " << scope << "__U__" << name << ")";
+ C << sb;
+ C << nl << "__os->writeSize(::Ice::Int(v.size()));";
+ C << nl << scoped << "::const_iterator p;";
+ C << nl << "for(p = v.begin(); p != v.end(); ++p)";
+ C << sb;
+ writeMarshalUnmarshalCode(C, keyType, "p->first", true);
+ writeMarshalUnmarshalCode(C, valueType, "p->second", true);
+ C << eb;
+ C << eb;
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
+ << "& v, " << scope << "__U__" << name << ')';
+ C << sb;
+ C << nl << "::Ice::Int sz;";
+ C << nl << "__is->readSize(sz);";
+ C << nl << "while(sz--)";
+ C << sb;
+ C << nl << "::std::pair<const " << ks << ", " << vs << "> pair;";
+ string pf = string("const_cast<") + ks + "&>(pair.first)";
+ writeMarshalUnmarshalCode(C, keyType, pf, false);
+ C << nl << scoped << "::iterator __i = v.insert(v.end(), pair);";
+ writeMarshalUnmarshalCode(C, valueType, "__i->second", false);
+ C << eb;
+ C << eb;
}
}
@@ -1070,64 +1070,64 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
EnumeratorList::const_iterator en = enumerators.begin();
while(en != enumerators.end())
{
- H << nl << fixKwd((*en)->name());
- if(++en != enumerators.end())
- {
- H << ',';
- }
+ H << nl << fixKwd((*en)->name());
+ if(++en != enumerators.end())
+ {
+ H << ',';
+ }
}
H << eb << ';';
if(!p->isLocal())
{
- string scoped = fixKwd(p->scoped());
- string scope = fixKwd(p->scope());
-
- size_t sz = enumerators.size();
- assert(sz <= 0x7fffffff); // 64-bit enums are not supported
-
- H << sp << nl << _dllExport << "void __write(::IceInternal::BasicStream*, " << name << ");";
- H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&);";
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, " << scoped
- << " v)";
- C << sb;
- if(sz <= 0x7f)
- {
- C << nl << "__os->write(static_cast< ::Ice::Byte>(v));";
- }
- else if(sz <= 0x7fff)
- {
- C << nl << "__os->write(static_cast< ::Ice::Short>(v));";
- }
- else
- {
- C << nl << "__os->write(static_cast< ::Ice::Int>(v));";
- }
- C << eb;
-
- C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
- << "& v)";
- C << sb;
- if(sz <= 0x7f)
- {
- C << nl << "::Ice::Byte val;";
- C << nl << "__is->read(val);";
- C << nl << "v = static_cast< " << scoped << ">(val);";
- }
- else if(sz <= 0x7fff)
- {
- C << nl << "::Ice::Short val;";
- C << nl << "__is->read(val);";
- C << nl << "v = static_cast< " << scoped << ">(val);";
- }
- else
- {
- C << nl << "::Ice::Int val;";
- C << nl << "__is->read(val);";
- C << nl << "v = static_cast< " << scoped << ">(val);";
- }
- C << eb;
+ string scoped = fixKwd(p->scoped());
+ string scope = fixKwd(p->scope());
+
+ size_t sz = enumerators.size();
+ assert(sz <= 0x7fffffff); // 64-bit enums are not supported
+
+ H << sp << nl << _dllExport << "void __write(::IceInternal::BasicStream*, " << name << ");";
+ H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "&);";
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, " << scoped
+ << " v)";
+ C << sb;
+ if(sz <= 0x7f)
+ {
+ C << nl << "__os->write(static_cast< ::Ice::Byte>(v));";
+ }
+ else if(sz <= 0x7fff)
+ {
+ C << nl << "__os->write(static_cast< ::Ice::Short>(v));";
+ }
+ else
+ {
+ C << nl << "__os->write(static_cast< ::Ice::Int>(v));";
+ }
+ C << eb;
+
+ C << sp << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, " << scoped
+ << "& v)";
+ C << sb;
+ if(sz <= 0x7f)
+ {
+ C << nl << "::Ice::Byte val;";
+ C << nl << "__is->read(val);";
+ C << nl << "v = static_cast< " << scoped << ">(val);";
+ }
+ else if(sz <= 0x7fff)
+ {
+ C << nl << "::Ice::Short val;";
+ C << nl << "__is->read(val);";
+ C << nl << "v = static_cast< " << scoped << ">(val);";
+ }
+ else
+ {
+ C << nl << "::Ice::Int val;";
+ C << nl << "__is->read(val);";
+ C << nl << "v = static_cast< " << scoped << ">(val);";
+ }
+ C << eb;
}
}
@@ -1141,59 +1141,59 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
BuiltinPtr bp = BuiltinPtr::dynamicCast(p->type());
if(bp && bp->kind() == Builtin::KindString)
{
- //
- // Expand strings into the basic source character set. We can't use isalpha() and the like
- // here because they are sensitive to the current locale.
- //
- static const string basicSourceChars = "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789"
- "_{}[]#()<>%:;.?*+-/^&|~!=,\\\"' ";
- static const set<char> charSet(basicSourceChars.begin(), basicSourceChars.end());
-
- if(_useWstring || findMetaData(p->typeMetaData(), true) == "wstring")
- {
- H << 'L';
- }
- H << "\""; // Opening "
-
- const string val = p->value();
- for(string::const_iterator c = val.begin(); c != val.end(); ++c)
- {
- if(charSet.find(*c) == charSet.end())
- {
- unsigned char uc = *c; // char may be signed, so make it positive
- ostringstream s;
- s << "\\"; // Print as octal if not in basic source character set
- s.flags(ios_base::oct);
- s.width(3);
- s.fill('0');
- s << static_cast<unsigned>(uc);
- H << s.str();
- }
- else
- {
- H << *c; // Print normally if in basic source character set
- }
- }
-
- H << "\""; // Closing "
+ //
+ // Expand strings into the basic source character set. We can't use isalpha() and the like
+ // here because they are sensitive to the current locale.
+ //
+ static const string basicSourceChars = "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789"
+ "_{}[]#()<>%:;.?*+-/^&|~!=,\\\"' ";
+ static const set<char> charSet(basicSourceChars.begin(), basicSourceChars.end());
+
+ if(_useWstring || findMetaData(p->typeMetaData(), true) == "wstring")
+ {
+ H << 'L';
+ }
+ H << "\""; // Opening "
+
+ const string val = p->value();
+ for(string::const_iterator c = val.begin(); c != val.end(); ++c)
+ {
+ if(charSet.find(*c) == charSet.end())
+ {
+ unsigned char uc = *c; // char may be signed, so make it positive
+ ostringstream s;
+ s << "\\"; // Print as octal if not in basic source character set
+ s.flags(ios_base::oct);
+ s.width(3);
+ s.fill('0');
+ s << static_cast<unsigned>(uc);
+ H << s.str();
+ }
+ else
+ {
+ H << *c; // Print normally if in basic source character set
+ }
+ }
+
+ H << "\""; // Closing "
}
else if(bp && bp->kind() == Builtin::KindLong)
{
- H << "ICE_INT64(" << p->value() << ")";
+ H << "ICE_INT64(" << p->value() << ")";
}
else
{
- EnumPtr ep = EnumPtr::dynamicCast(p->type());
- if(ep)
- {
- H << fixKwd(p->value());
- }
- else
- {
- H << p->value();
- }
+ EnumPtr ep = EnumPtr::dynamicCast(p->type());
+ if(ep)
+ {
+ H << fixKwd(p->value());
+ }
+ else
+ {
+ H << p->value();
+ }
}
H << ';';
@@ -1225,7 +1225,7 @@ Slice::Gen::ProxyDeclVisitor::visitUnitStart(const UnitPtr& p)
{
if(!p->hasNonLocalClassDecls())
{
- return false;
+ return false;
}
H << sp << nl << "namespace IceProxy" << nl << '{';
@@ -1244,7 +1244,7 @@ Slice::Gen::ProxyDeclVisitor::visitModuleStart(const ModulePtr& p)
{
if(!p->hasNonLocalClassDecls())
{
- return false;
+ return false;
}
string name = fixKwd(p->name());
@@ -1265,7 +1265,7 @@ Slice::Gen::ProxyDeclVisitor::visitClassDecl(const ClassDeclPtr& p)
{
if(p->isLocal())
{
- return;
+ return;
}
string name = fixKwd(p->name());
@@ -1289,7 +1289,7 @@ Slice::Gen::ProxyVisitor::visitUnitStart(const UnitPtr& p)
{
if(!p->hasNonLocalClassDecls())
{
- return false;
+ return false;
}
H << sp << nl << "namespace IceProxy" << nl << '{';
@@ -1308,7 +1308,7 @@ Slice::Gen::ProxyVisitor::visitModuleStart(const ModulePtr& p)
{
if(!p->hasNonLocalClassDecls())
{
- return false;
+ return false;
}
_useWstring = setUseWstring(p, _useWstringHist, _useWstring);
@@ -1333,7 +1333,7 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
{
if(p->isLocal())
{
- return false;
+ return false;
}
_useWstring = setUseWstring(p, _useWstringHist, _useWstring);
@@ -1345,21 +1345,21 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
H << sp << nl << "class " << _dllExport << name << " : ";
if(bases.empty())
{
- H << "virtual public ::IceProxy::Ice::Object";
+ H << "virtual public ::IceProxy::Ice::Object";
}
else
{
- H.useCurrentPosAsIndent();
- ClassList::const_iterator q = bases.begin();
- while(q != bases.end())
- {
- H << "virtual public ::IceProxy" << fixKwd((*q)->scoped());
- if(++q != bases.end())
- {
- H << ',' << nl;
- }
- }
- H.restoreIndent();
+ H.useCurrentPosAsIndent();
+ ClassList::const_iterator q = bases.begin();
+ while(q != bases.end())
+ {
+ H << "virtual public ::IceProxy" << fixKwd((*q)->scoped());
+ if(++q != bases.end())
+ {
+ H << ',' << nl;
+ }
+ }
+ H.restoreIndent();
}
H << sb;
@@ -1458,25 +1458,25 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
ParamDeclList paramList = p->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- string paramName = fixKwd((*q)->name());
- StringList metaData = (*q)->getMetaData();
+ string paramName = fixKwd((*q)->name());
+ StringList metaData = (*q)->getMetaData();
- string typeString;
- if((*q)->isOutParam())
- {
- outParams.push_back(*q);
- typeString = outputTypeToString((*q)->type(), _useWstring, metaData);
- }
- else
- {
- inParams.push_back(*q);
- typeString = inputTypeToString((*q)->type(), _useWstring, metaData);
- }
+ string typeString;
+ if((*q)->isOutParam())
+ {
+ outParams.push_back(*q);
+ typeString = outputTypeToString((*q)->type(), _useWstring, metaData);
+ }
+ else
+ {
+ inParams.push_back(*q);
+ typeString = inputTypeToString((*q)->type(), _useWstring, metaData);
+ }
- params.push_back(typeString);
- paramsDecl.push_back(typeString + ' ' + paramName);
- paramsName.push_back(paramName);
- args.push_back(paramName);
+ params.push_back(typeString);
+ paramsDecl.push_back(typeString + ' ' + paramName);
+ paramsName.push_back(paramName);
+ args.push_back(paramName);
}
paramsName.push_back("__outS");
@@ -1491,7 +1491,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
H << nl;
if(ret)
{
- H << "return ";
+ H << "return ";
}
H << fixKwd(name) << spar << args << "__defaultContext()" << epar << ';';
H << eb;
@@ -1608,18 +1608,18 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
C.restoreIndent();
if(!ret)
{
- C << nl << "return;";
+ C << nl << "return;";
}
C << eb;
C << nl << "catch(const ::IceInternal::LocalExceptionWrapper& __ex)";
C << sb;
if(p->mode() == Operation::Idempotent || p->mode() == Operation::Nonmutating)
{
- C << nl << "__handleExceptionWrapperRelaxed(__connection, __ex, __cnt);";
+ C << nl << "__handleExceptionWrapperRelaxed(__connection, __ex, __cnt);";
}
else
{
- C << nl << "__handleExceptionWrapper(__connection, __ex);";
+ C << nl << "__handleExceptionWrapper(__connection, __ex);";
}
C << eb;
C << nl << "catch(const ::Ice::LocalException& __ex)";
@@ -1652,7 +1652,7 @@ Slice::Gen::ObjectDeclVisitor::visitModuleStart(const ModulePtr& p)
{
if(!p->hasClassDecls())
{
- return false;
+ return false;
}
string name = fixKwd(p->name());
@@ -1703,7 +1703,7 @@ Slice::Gen::ObjectVisitor::visitModuleStart(const ModulePtr& p)
{
if(!p->hasClassDefs())
{
- return false;
+ return false;
}
_useWstring = setUseWstring(p, _useWstringHist, _useWstring);
@@ -1735,7 +1735,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
ClassDefPtr base;
if(!bases.empty() && !bases.front()->isInterface())
{
- base = bases.front();
+ base = bases.front();
}
DataMemberList dataMembers = p->dataMembers();
DataMemberList allDataMembers = p->allDataMembers();
@@ -1749,26 +1749,26 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
H.useCurrentPosAsIndent();
if(bases.empty())
{
- if(p->isLocal())
- {
- H << "virtual public ::Ice::LocalObject";
- }
- else
- {
- H << "virtual public ::Ice::Object";
- }
+ if(p->isLocal())
+ {
+ H << "virtual public ::Ice::LocalObject";
+ }
+ else
+ {
+ H << "virtual public ::Ice::Object";
+ }
}
else
{
- ClassList::const_iterator q = bases.begin();
- while(q != bases.end())
- {
- H << "virtual public " << fixKwd((*q)->scoped());
- if(++q != bases.end())
- {
- H << ',' << nl;
- }
- }
+ ClassList::const_iterator q = bases.begin();
+ while(q != bases.end())
+ {
+ H << "virtual public " << fixKwd((*q)->scoped());
+ if(++q != bases.end())
+ {
+ H << ',' << nl;
+ }
+ }
}
H.restoreIndent();
H << sb;
@@ -1790,217 +1790,217 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- params.push_back(fixKwd((*q)->name()));
+ params.push_back(fixKwd((*q)->name()));
}
for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q)
{
- string typeName = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData());
- allTypes.push_back(typeName);
- allParamDecls.push_back(typeName + " __ice_" + (*q)->name());
+ string typeName = inputTypeToString((*q)->type(), _useWstring, (*q)->getMetaData());
+ allTypes.push_back(typeName);
+ allParamDecls.push_back(typeName + " __ice_" + (*q)->name());
}
if(!p->isInterface())
{
- H << nl << name << "() {}";
- if(!allParamDecls.empty())
- {
- H << nl;
- if(allParamDecls.size() == 1)
- {
- H << "explicit ";
- }
- H << name << spar << allTypes << epar << ';';
- }
-
- /*
- * Strong guarantee: commented-out code marked "Strong guarantee" generates
- * a copy-assignment operator that provides the strong exception guarantee.
- * For now, this is commented out, and we use the compiler-generated
- * copy-assignment operator. However, that one does not provide the strong
- * guarantee.
-
- H << ';';
- if(!p->isAbstract())
- {
- H << nl << name << "& operator=(const " << name << "&)";
- if(allDataMembers.empty())
- {
- H << " { return *this; }";
- }
- H << ';';
- }
-
- //
- // __swap() is static because classes may be abstract, so we
- // can't use a non-static member function when we do an upcall
- // from a non-abstract derived __swap to the __swap in an abstract base.
- //
- H << sp << nl << "static void __swap(" << name << "&, " << name << "&) throw()";
- if(allDataMembers.empty())
- {
- H << " {}";
- }
- H << ';';
- H << nl << "void swap(" << name << "& rhs) throw()";
- H << sb;
- if(!allDataMembers.empty())
- {
- H << nl << "__swap(*this, rhs);";
- }
- H << eb;
-
- * Strong guarantee
- */
+ H << nl << name << "() {}";
+ if(!allParamDecls.empty())
+ {
+ H << nl;
+ if(allParamDecls.size() == 1)
+ {
+ H << "explicit ";
+ }
+ H << name << spar << allTypes << epar << ';';
+ }
+
+ /*
+ * Strong guarantee: commented-out code marked "Strong guarantee" generates
+ * a copy-assignment operator that provides the strong exception guarantee.
+ * For now, this is commented out, and we use the compiler-generated
+ * copy-assignment operator. However, that one does not provide the strong
+ * guarantee.
+
+ H << ';';
+ if(!p->isAbstract())
+ {
+ H << nl << name << "& operator=(const " << name << "&)";
+ if(allDataMembers.empty())
+ {
+ H << " { return *this; }";
+ }
+ H << ';';
+ }
+
+ //
+ // __swap() is static because classes may be abstract, so we
+ // can't use a non-static member function when we do an upcall
+ // from a non-abstract derived __swap to the __swap in an abstract base.
+ //
+ H << sp << nl << "static void __swap(" << name << "&, " << name << "&) throw()";
+ if(allDataMembers.empty())
+ {
+ H << " {}";
+ }
+ H << ';';
+ H << nl << "void swap(" << name << "& rhs) throw()";
+ H << sb;
+ if(!allDataMembers.empty())
+ {
+ H << nl << "__swap(*this, rhs);";
+ }
+ H << eb;
+
+ * Strong guarantee
+ */
emitOneShotConstructor(p);
- /*
- * Strong guarantee
-
- if(!allDataMembers.empty())
- {
- C << sp << nl << "void";
- C << nl << scoped.substr(2) << "::__swap(" << name << "& __lhs, " << name << "& __rhs) throw()";
- C << sb;
-
- if(base)
- {
- emitUpcall(base, "::__swap(__lhs, __rhs);");
- }
-
- //
- // We use a map to remember for which types we have already declared
- // a temporary variable and reuse that variable if a class has
- // more than one member of the same type. That way, we don't use more
- // temporaries than necessary. (::std::swap() instantiates a new temporary
- // each time it is used.)
- //
- map<string, int> tmpMap;
- map<string, int>::iterator pos;
- int tmpCount = 0;
-
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- string memberName = fixKwd((*q)->name());
- TypePtr type = (*q)->type();
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
- if(builtin && builtin->kind() != Builtin::KindString
- || EnumPtr::dynamicCast(type) || ProxyPtr::dynamicCast(type)
- || ClassDeclPtr::dynamicCast(type) || StructPtr::dynamicCast(type))
- {
- //
- // For built-in types (except string), enums, proxies, structs, and classes,
- // do the swap via a temporary variable.
- //
- string typeName = typeToString(type);
- pos = tmpMap.find(typeName);
- if(pos == tmpMap.end())
- {
- pos = tmpMap.insert(pos, make_pair(typeName, tmpCount));
- C << nl << typeName << " __tmp" << tmpCount << ';';
- tmpCount++;
- }
- C << nl << "__tmp" << pos->second << " = __rhs." << memberName << ';';
- C << nl << "__rhs." << memberName << " = __lhs." << memberName << ';';
- C << nl << "__lhs." << memberName << " = __tmp" << pos->second << ';';
- }
- else
- {
- //
- // For dictionaries, vectors, and maps, use the standard container's
- // swap() (which is usually optimized).
- //
- C << nl << "__lhs." << memberName << ".swap(__rhs." << memberName << ");";
- }
- }
- C << eb;
-
- if(!p->isAbstract())
- {
- C << sp << nl << scoped << "&";
- C << nl << scoped.substr(2) << "::operator=(const " << name << "& __rhs)";
- C << sb;
- C << nl << name << " __tmp(__rhs);";
- C << nl << "__swap(*this, __tmp);";
- C << nl << "return *this;";
- C << eb;
- }
- }
-
- * Strong guarantee
- */
+ /*
+ * Strong guarantee
+
+ if(!allDataMembers.empty())
+ {
+ C << sp << nl << "void";
+ C << nl << scoped.substr(2) << "::__swap(" << name << "& __lhs, " << name << "& __rhs) throw()";
+ C << sb;
+
+ if(base)
+ {
+ emitUpcall(base, "::__swap(__lhs, __rhs);");
+ }
+
+ //
+ // We use a map to remember for which types we have already declared
+ // a temporary variable and reuse that variable if a class has
+ // more than one member of the same type. That way, we don't use more
+ // temporaries than necessary. (::std::swap() instantiates a new temporary
+ // each time it is used.)
+ //
+ map<string, int> tmpMap;
+ map<string, int>::iterator pos;
+ int tmpCount = 0;
+
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ string memberName = fixKwd((*q)->name());
+ TypePtr type = (*q)->type();
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
+ if(builtin && builtin->kind() != Builtin::KindString
+ || EnumPtr::dynamicCast(type) || ProxyPtr::dynamicCast(type)
+ || ClassDeclPtr::dynamicCast(type) || StructPtr::dynamicCast(type))
+ {
+ //
+ // For built-in types (except string), enums, proxies, structs, and classes,
+ // do the swap via a temporary variable.
+ //
+ string typeName = typeToString(type);
+ pos = tmpMap.find(typeName);
+ if(pos == tmpMap.end())
+ {
+ pos = tmpMap.insert(pos, make_pair(typeName, tmpCount));
+ C << nl << typeName << " __tmp" << tmpCount << ';';
+ tmpCount++;
+ }
+ C << nl << "__tmp" << pos->second << " = __rhs." << memberName << ';';
+ C << nl << "__rhs." << memberName << " = __lhs." << memberName << ';';
+ C << nl << "__lhs." << memberName << " = __tmp" << pos->second << ';';
+ }
+ else
+ {
+ //
+ // For dictionaries, vectors, and maps, use the standard container's
+ // swap() (which is usually optimized).
+ //
+ C << nl << "__lhs." << memberName << ".swap(__rhs." << memberName << ");";
+ }
+ }
+ C << eb;
+
+ if(!p->isAbstract())
+ {
+ C << sp << nl << scoped << "&";
+ C << nl << scoped.substr(2) << "::operator=(const " << name << "& __rhs)";
+ C << sb;
+ C << nl << name << " __tmp(__rhs);";
+ C << nl << "__swap(*this, __tmp);";
+ C << nl << "return *this;";
+ C << eb;
+ }
+ }
+
+ * Strong guarantee
+ */
}
if(!p->isLocal())
{
- StringList ids;
- getIds(p, ids);
+ StringList ids;
+ getIds(p, ids);
StringList::const_iterator firstIter = ids.begin();
StringList::const_iterator scopedIter = find(ids.begin(), ids.end(), p->scoped());
assert(scopedIter != ids.end());
StringList::difference_type scopedPos = ice_distance(firstIter, scopedIter);
- StringList::const_iterator q;
-
- H << sp;
- H << nl << "virtual bool ice_isA"
- << "(const ::std::string&, const ::Ice::Current& = ::Ice::Current()) const;";
- H << nl << "virtual ::std::vector< ::std::string> ice_ids"
- << "(const ::Ice::Current& = ::Ice::Current()) const;";
- H << nl << "virtual const ::std::string& ice_id(const ::Ice::Current& = ::Ice::Current()) const;";
- H << nl << "static const ::std::string& ice_staticId();";
- if(!dataMembers.empty())
- {
- H << sp;
- }
-
- string flatName = p->flattenedScope() + p->name() + "_ids";
-
- C << sp;
- C << nl << "static const ::std::string " << flatName << '[' << ids.size() << "] =";
- C << sb;
- q = ids.begin();
- while(q != ids.end())
- {
- C << nl << '"' << *q << '"';
- if(++q != ids.end())
- {
- C << ',';
- }
- }
- C << eb << ';';
-
- C << sp << nl << "#ifndef ICEE_PURE_CLIENT";
-
- C << sp;
- C << nl << "bool" << nl << fixKwd(p->scoped()).substr(2)
+ StringList::const_iterator q;
+
+ H << sp;
+ H << nl << "virtual bool ice_isA"
+ << "(const ::std::string&, const ::Ice::Current& = ::Ice::Current()) const;";
+ H << nl << "virtual ::std::vector< ::std::string> ice_ids"
+ << "(const ::Ice::Current& = ::Ice::Current()) const;";
+ H << nl << "virtual const ::std::string& ice_id(const ::Ice::Current& = ::Ice::Current()) const;";
+ H << nl << "static const ::std::string& ice_staticId();";
+ if(!dataMembers.empty())
+ {
+ H << sp;
+ }
+
+ string flatName = p->flattenedScope() + p->name() + "_ids";
+
+ C << sp;
+ C << nl << "static const ::std::string " << flatName << '[' << ids.size() << "] =";
+ C << sb;
+ q = ids.begin();
+ while(q != ids.end())
+ {
+ C << nl << '"' << *q << '"';
+ if(++q != ids.end())
+ {
+ C << ',';
+ }
+ }
+ C << eb << ';';
+
+ C << sp << nl << "#ifndef ICEE_PURE_CLIENT";
+
+ C << sp;
+ C << nl << "bool" << nl << fixKwd(p->scoped()).substr(2)
<< "::ice_isA(const ::std::string& _s, const ::Ice::Current&) const";
- C << sb;
- C << nl << "return ::std::binary_search(" << flatName << ", " << flatName << " + " << ids.size() << ", _s);";
- C << eb;
-
- C << sp;
- C << nl << "::std::vector< ::std::string>" << nl << fixKwd(p->scoped()).substr(2)
- << "::ice_ids(const ::Ice::Current&) const";
- C << sb;
- C << nl << "return ::std::vector< ::std::string>(&" << flatName << "[0], &" << flatName
- << '[' << ids.size() << "]);";
- C << eb;
-
- C << sp;
- C << nl << "const ::std::string&" << nl << fixKwd(p->scoped()).substr(2)
- << "::ice_id(const ::Ice::Current&) const";
- C << sb;
- C << nl << "return " << flatName << '[' << scopedPos << "];";
- C << eb;
-
- C << sp;
- C << nl << "const ::std::string&" << nl << fixKwd(p->scoped()).substr(2) << "::ice_staticId()";
- C << sb;
- C << nl << "return " << flatName << '[' << scopedPos << "];";
- C << eb;
+ C << sb;
+ C << nl << "return ::std::binary_search(" << flatName << ", " << flatName << " + " << ids.size() << ", _s);";
+ C << eb;
+
+ C << sp;
+ C << nl << "::std::vector< ::std::string>" << nl << fixKwd(p->scoped()).substr(2)
+ << "::ice_ids(const ::Ice::Current&) const";
+ C << sb;
+ C << nl << "return ::std::vector< ::std::string>(&" << flatName << "[0], &" << flatName
+ << '[' << ids.size() << "]);";
+ C << eb;
+
+ C << sp;
+ C << nl << "const ::std::string&" << nl << fixKwd(p->scoped()).substr(2)
+ << "::ice_id(const ::Ice::Current&) const";
+ C << sb;
+ C << nl << "return " << flatName << '[' << scopedPos << "];";
+ C << eb;
+
+ C << sp;
+ C << nl << "const ::std::string&" << nl << fixKwd(p->scoped()).substr(2) << "::ice_staticId()";
+ C << sb;
+ C << nl << "return " << flatName << '[' << scopedPos << "];";
+ C << eb;
}
return true;
@@ -2013,85 +2013,85 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
string scope = fixKwd(p->scope());
if(!p->isLocal())
- {
- ClassList bases = p->bases();
- ClassDefPtr base;
- if(!bases.empty() && !bases.front()->isInterface())
- {
- base = bases.front();
- }
+ {
+ ClassList bases = p->bases();
+ ClassDefPtr base;
+ if(!bases.empty() && !bases.front()->isInterface())
+ {
+ base = bases.front();
+ }
- OperationList allOps = p->allOperations();
- if(!allOps.empty())
- {
- StringList allOpNames;
+ OperationList allOps = p->allOperations();
+ if(!allOps.empty())
+ {
+ StringList allOpNames;
#if defined(__IBMCPP__) && defined(NDEBUG)
//
// See comment for transform above
//
- transform(allOps.begin(), allOps.end(), back_inserter(allOpNames),
- ::IceUtil::constMemFun<string,Operation>(&Contained::name));
+ transform(allOps.begin(), allOps.end(), back_inserter(allOpNames),
+ ::IceUtil::constMemFun<string,Operation>(&Contained::name));
#else
- transform(allOps.begin(), allOps.end(), back_inserter(allOpNames),
+ transform(allOps.begin(), allOps.end(), back_inserter(allOpNames),
::IceUtil::constMemFun(&Contained::name));
#endif
- allOpNames.push_back("ice_id");
- allOpNames.push_back("ice_ids");
- allOpNames.push_back("ice_isA");
- allOpNames.push_back("ice_ping");
- allOpNames.sort();
- allOpNames.unique();
-
- StringList::const_iterator q;
-
- H << sp;
- H << nl
- << "virtual ::IceInternal::DispatchStatus __dispatch(::IceInternal::Incoming&, const ::Ice::Current&);";
-
- string flatName = p->flattenedScope() + p->name() + "_all";
- C << sp;
- C << nl << "static ::std::string " << flatName << "[] =";
- C << sb;
- q = allOpNames.begin();
- while(q != allOpNames.end())
- {
- C << nl << '"' << *q << '"';
- if(++q != allOpNames.end())
- {
- C << ',';
- }
- }
- C << eb << ';';
- C << sp;
- C << nl << "::IceInternal::DispatchStatus" << nl << scoped.substr(2)
- << "::__dispatch(::IceInternal::Incoming& in, const ::Ice::Current& current)";
- C << sb;
-
- C << nl << "::std::pair< ::std::string*, ::std::string*> r = "
- << "::std::equal_range(" << flatName << ", " << flatName << " + " << allOpNames.size()
- << ", current.operation);";
- C << nl << "if(r.first == r.second)";
- C << sb;
- C << nl << "return ::IceInternal::DispatchOperationNotExist;";
- C << eb;
- C << sp;
- C << nl << "switch(r.first - " << flatName << ')';
- C << sb;
- int i = 0;
- for(q = allOpNames.begin(); q != allOpNames.end(); ++q)
- {
- C << nl << "case " << i++ << ':';
- C << sb;
- C << nl << "return ___" << *q << "(in, current);";
- C << eb;
- }
- C << eb;
- C << sp;
- C << nl << "assert(false);";
- C << nl << "return ::IceInternal::DispatchOperationNotExist;";
- C << eb;
- }
-
+ allOpNames.push_back("ice_id");
+ allOpNames.push_back("ice_ids");
+ allOpNames.push_back("ice_isA");
+ allOpNames.push_back("ice_ping");
+ allOpNames.sort();
+ allOpNames.unique();
+
+ StringList::const_iterator q;
+
+ H << sp;
+ H << nl
+ << "virtual ::IceInternal::DispatchStatus __dispatch(::IceInternal::Incoming&, const ::Ice::Current&);";
+
+ string flatName = p->flattenedScope() + p->name() + "_all";
+ C << sp;
+ C << nl << "static ::std::string " << flatName << "[] =";
+ C << sb;
+ q = allOpNames.begin();
+ while(q != allOpNames.end())
+ {
+ C << nl << '"' << *q << '"';
+ if(++q != allOpNames.end())
+ {
+ C << ',';
+ }
+ }
+ C << eb << ';';
+ C << sp;
+ C << nl << "::IceInternal::DispatchStatus" << nl << scoped.substr(2)
+ << "::__dispatch(::IceInternal::Incoming& in, const ::Ice::Current& current)";
+ C << sb;
+
+ C << nl << "::std::pair< ::std::string*, ::std::string*> r = "
+ << "::std::equal_range(" << flatName << ", " << flatName << " + " << allOpNames.size()
+ << ", current.operation);";
+ C << nl << "if(r.first == r.second)";
+ C << sb;
+ C << nl << "return ::IceInternal::DispatchOperationNotExist;";
+ C << eb;
+ C << sp;
+ C << nl << "switch(r.first - " << flatName << ')';
+ C << sb;
+ int i = 0;
+ for(q = allOpNames.begin(); q != allOpNames.end(); ++q)
+ {
+ C << nl << "case " << i++ << ':';
+ C << sb;
+ C << nl << "return ___" << *q << "(in, current);";
+ C << eb;
+ }
+ C << eb;
+ C << sp;
+ C << nl << "assert(false);";
+ C << nl << "return ::IceInternal::DispatchOperationNotExist;";
+ C << eb;
+ }
+
}
//
@@ -2099,10 +2099,10 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
//
if(!p->isAbstract())
{
- H.dec();
- H << sp << nl << "protected:";
- H.inc();
- H << sp << nl << "virtual ~" << fixKwd(p->name()) << "() {}";
+ H.dec();
+ H << sp << nl << "protected:";
+ H.inc();
+ H << sp << nl << "virtual ~" << fixKwd(p->name()) << "() {}";
}
H << eb << ';';
@@ -2114,47 +2114,47 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
if(p->isLocal())
{
- C << sp;
- C << nl << "bool" << nl << scope.substr(2) << "operator==(const " << scoped
- << "& l, const " << scoped << "& r)";
- C << sb;
- C << nl << "return static_cast<const ::Ice::LocalObject&>(l) == static_cast<const ::Ice::LocalObject&>(r);";
- C << eb;
- C << sp;
- C << nl << "bool" << nl << scope.substr(2) << "operator!=(const " << scoped
- << "& l, const " << scoped << "& r)";
- C << sb;
- C << nl << "return static_cast<const ::Ice::LocalObject&>(l) != static_cast<const ::Ice::LocalObject&>(r);";
- C << eb;
- C << sp;
- C << nl << "bool" << nl << scope.substr(2) << "operator<(const " << scoped
- << "& l, const " << scoped << "& r)";
- C << sb;
- C << nl << "return static_cast<const ::Ice::LocalObject&>(l) < static_cast<const ::Ice::LocalObject&>(r);";
- C << eb;
+ C << sp;
+ C << nl << "bool" << nl << scope.substr(2) << "operator==(const " << scoped
+ << "& l, const " << scoped << "& r)";
+ C << sb;
+ C << nl << "return static_cast<const ::Ice::LocalObject&>(l) == static_cast<const ::Ice::LocalObject&>(r);";
+ C << eb;
+ C << sp;
+ C << nl << "bool" << nl << scope.substr(2) << "operator!=(const " << scoped
+ << "& l, const " << scoped << "& r)";
+ C << sb;
+ C << nl << "return static_cast<const ::Ice::LocalObject&>(l) != static_cast<const ::Ice::LocalObject&>(r);";
+ C << eb;
+ C << sp;
+ C << nl << "bool" << nl << scope.substr(2) << "operator<(const " << scoped
+ << "& l, const " << scoped << "& r)";
+ C << sb;
+ C << nl << "return static_cast<const ::Ice::LocalObject&>(l) < static_cast<const ::Ice::LocalObject&>(r);";
+ C << eb;
}
else
{
- string name = p->name();
-
- C << sp;
- C << nl << "bool" << nl << scope.substr(2) << "operator==(const " << scoped
- << "& l, const " << scoped << "& r)";
- C << sb;
- C << nl << "return static_cast<const ::Ice::Object&>(l) == static_cast<const ::Ice::Object&>(r);";
- C << eb;
- C << sp;
- C << nl << "bool" << nl << scope.substr(2) << "operator!=(const " << scoped
- << "& l, const " << scoped << "& r)";
- C << sb;
- C << nl << "return static_cast<const ::Ice::Object&>(l) != static_cast<const ::Ice::Object&>(r);";
- C << eb;
- C << sp;
- C << nl << "bool" << nl << scope.substr(2) << "operator<(const " << scoped
- << "& l, const " << scoped << "& r)";
- C << sb;
- C << nl << "return static_cast<const ::Ice::Object&>(l) < static_cast<const ::Ice::Object&>(r);";
- C << eb;
+ string name = p->name();
+
+ C << sp;
+ C << nl << "bool" << nl << scope.substr(2) << "operator==(const " << scoped
+ << "& l, const " << scoped << "& r)";
+ C << sb;
+ C << nl << "return static_cast<const ::Ice::Object&>(l) == static_cast<const ::Ice::Object&>(r);";
+ C << eb;
+ C << sp;
+ C << nl << "bool" << nl << scope.substr(2) << "operator!=(const " << scoped
+ << "& l, const " << scoped << "& r)";
+ C << sb;
+ C << nl << "return static_cast<const ::Ice::Object&>(l) != static_cast<const ::Ice::Object&>(r);";
+ C << eb;
+ C << sp;
+ C << nl << "bool" << nl << scope.substr(2) << "operator<(const " << scoped
+ << "& l, const " << scoped << "& r)";
+ C << sb;
+ C << nl << "return static_cast<const ::Ice::Object&>(l) < static_cast<const ::Ice::Object&>(r);";
+ C << eb;
}
C << sp;
@@ -2215,55 +2215,55 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
ParamDeclList paramList = p->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- string paramName = fixKwd((*q)->name());
- TypePtr type = (*q)->type();
- bool isOutParam = (*q)->isOutParam();
- StringList metaData = (*q)->getMetaData();
-
- string typeString;
- if(isOutParam)
- {
- outParams.push_back(*q);
- typeString = outputTypeToString(type, _useWstring, metaData);
- }
- else
- {
- inParams.push_back(*q);
- typeString = inputTypeToString(type, _useWstring, metaData);
- }
-
- if(q != paramList.begin())
- {
- params += ", ";
- paramsDecl += ", ";
- args += ", ";
- }
-
- params += typeString;
- paramsDecl += typeString;
- paramsDecl += ' ';
- paramsDecl += paramName;
- args += paramName;
+ string paramName = fixKwd((*q)->name());
+ TypePtr type = (*q)->type();
+ bool isOutParam = (*q)->isOutParam();
+ StringList metaData = (*q)->getMetaData();
+
+ string typeString;
+ if(isOutParam)
+ {
+ outParams.push_back(*q);
+ typeString = outputTypeToString(type, _useWstring, metaData);
+ }
+ else
+ {
+ inParams.push_back(*q);
+ typeString = inputTypeToString(type, _useWstring, metaData);
+ }
+
+ if(q != paramList.begin())
+ {
+ params += ", ";
+ paramsDecl += ", ";
+ args += ", ";
+ }
+
+ params += typeString;
+ paramsDecl += typeString;
+ paramsDecl += ' ';
+ paramsDecl += paramName;
+ args += paramName;
}
if(!cl->isLocal())
{
- if(!paramList.empty())
- {
- params += ", ";
- paramsDecl += ", ";
- args += ", ";
- }
+ if(!paramList.empty())
+ {
+ params += ", ";
+ paramsDecl += ", ";
+ args += ", ";
+ }
- params += "const ::Ice::Current& = ::Ice::Current())";
- paramsDecl += "const ::Ice::Current& __current)";
- args += "__current)";
+ params += "const ::Ice::Current& = ::Ice::Current())";
+ paramsDecl += "const ::Ice::Current& __current)";
+ args += "__current)";
}
else
{
- params += ')';
- paramsDecl += ')';
- args += ')';
+ params += ')';
+ paramsDecl += ')';
+ args += ')';
}
bool isConst = (p->mode() == Operation::Nonmutating) || p->hasMetaData("cpp:const");
@@ -2276,73 +2276,73 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
if(!cl->isLocal())
{
- H << nl << "::IceInternal::DispatchStatus ___" << name
- << "(::IceInternal::Incoming&, const ::Ice::Current&)" << (isConst ? " const" : "") << ';';
+ H << nl << "::IceInternal::DispatchStatus ___" << name
+ << "(::IceInternal::Incoming&, const ::Ice::Current&)" << (isConst ? " const" : "") << ';';
- C << sp;
- C << nl << "::IceInternal::DispatchStatus" << nl << scope.substr(2) << "___" << name
- << "(::IceInternal::Incoming& __inS, const ::Ice::Current& __current)" << (isConst ? " const" : "");
- C << sb;
+ C << sp;
+ C << nl << "::IceInternal::DispatchStatus" << nl << scope.substr(2) << "___" << name
+ << "(::IceInternal::Incoming& __inS, const ::Ice::Current& __current)" << (isConst ? " const" : "");
+ C << sb;
- ExceptionList throws = p->throws();
- throws.sort();
- throws.unique();
+ ExceptionList throws = p->throws();
+ throws.sort();
+ throws.unique();
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
#if defined(__SUNPRO_CC)
- throws.sort(derivedToBaseCompare);
+ throws.sort(derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
- C << nl << "__checkMode(" << operationModeToString(p->mode()) << ", __current.mode);";
-
- if(!inParams.empty())
- {
- C << nl << "::IceInternal::BasicStream* __is = __inS.is();";
- }
- if(ret || !outParams.empty() || !throws.empty())
- {
- C << nl << "::IceInternal::BasicStream* __os = __inS.os();";
- }
-
- writeAllocateCode(C, inParams, 0, StringList(), _useWstring, true);
- writeUnmarshalCode(C, inParams, 0, StringList(), true);
- writeAllocateCode(C, outParams, 0, StringList(), _useWstring);
- if(!throws.empty())
- {
- C << nl << "try";
- C << sb;
- }
- C << nl;
- if(ret)
- {
- C << retS << " __ret = ";
- }
- C << fixKwd(name) << args << ';';
- writeMarshalCode(C, outParams, ret, p->getMetaData());
- if(!throws.empty())
- {
- C << eb;
- ExceptionList::const_iterator r;
- for(r = throws.begin(); r != throws.end(); ++r)
- {
- C << nl << "catch(const " << fixKwd((*r)->scoped()) << "& __ex)";
- C << sb;
- C << nl << "__os->write(__ex);";
- C << nl << "return ::IceInternal::DispatchUserException;";
- C << eb;
- }
- }
- C << nl << "return ::IceInternal::DispatchOK;";
- C << eb;
- }
+ C << nl << "__checkMode(" << operationModeToString(p->mode()) << ", __current.mode);";
+
+ if(!inParams.empty())
+ {
+ C << nl << "::IceInternal::BasicStream* __is = __inS.is();";
+ }
+ if(ret || !outParams.empty() || !throws.empty())
+ {
+ C << nl << "::IceInternal::BasicStream* __os = __inS.os();";
+ }
+
+ writeAllocateCode(C, inParams, 0, StringList(), _useWstring, true);
+ writeUnmarshalCode(C, inParams, 0, StringList(), true);
+ writeAllocateCode(C, outParams, 0, StringList(), _useWstring);
+ if(!throws.empty())
+ {
+ C << nl << "try";
+ C << sb;
+ }
+ C << nl;
+ if(ret)
+ {
+ C << retS << " __ret = ";
+ }
+ C << fixKwd(name) << args << ';';
+ writeMarshalCode(C, outParams, ret, p->getMetaData());
+ if(!throws.empty())
+ {
+ C << eb;
+ ExceptionList::const_iterator r;
+ for(r = throws.begin(); r != throws.end(); ++r)
+ {
+ C << nl << "catch(const " << fixKwd((*r)->scoped()) << "& __ex)";
+ C << sb;
+ C << nl << "__os->write(__ex);";
+ C << nl << "return ::IceInternal::DispatchUserException;";
+ C << eb;
+ }
+ }
+ C << nl << "return ::IceInternal::DispatchOK;";
+ C << eb;
+ }
}
void
@@ -2365,21 +2365,21 @@ Slice::Gen::ObjectVisitor::emitVirtualBaseInitializers(const ClassDefPtr& p)
ClassList bases = p->bases();
if(!bases.empty() && !bases.front()->isInterface())
{
- if(emitVirtualBaseInitializers(bases.front()))
- {
- C << ',';
- }
+ if(emitVirtualBaseInitializers(bases.front()))
+ {
+ C << ',';
+ }
}
string upcall = "(";
DataMemberList::const_iterator q;
for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q)
{
- if(q != allDataMembers.begin())
- {
- upcall += ", ";
- }
- upcall += "__ice_" + (*q)->name();
+ if(q != allDataMembers.begin())
+ {
+ upcall += ", ";
+ }
+ upcall += "__ice_" + (*q)->name();
}
upcall += ")";
@@ -2409,47 +2409,47 @@ Slice::Gen::ObjectVisitor::emitOneShotConstructor(const ClassDefPtr& p)
for(q = allDataMembers.begin(); q != allDataMembers.end(); ++q)
{
- string typeName = inputTypeToString((*q)->type(), _useWstring);
- allParamDecls.push_back(typeName + " __ice_" + (*q)->name());
+ string typeName = inputTypeToString((*q)->type(), _useWstring);
+ allParamDecls.push_back(typeName + " __ice_" + (*q)->name());
}
if(!allDataMembers.empty())
{
- C << sp << nl << p->scoped().substr(2) << "::" << fixKwd(p->name()) << spar << allParamDecls << epar << " :";
- C.inc();
-
- DataMemberList dataMembers = p->dataMembers();
-
- ClassList bases = p->bases();
- ClassDefPtr base;
- if(!bases.empty() && !bases.front()->isInterface())
- {
- if(emitVirtualBaseInitializers(bases.front()))
- {
- if(!dataMembers.empty())
- {
- C << ',';
- }
- }
- }
-
- if(!dataMembers.empty())
- {
- C << nl;
- }
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- if(q != dataMembers.begin())
- {
- C << ',' << nl;
- }
- string memberName = fixKwd((*q)->name());
- C << memberName << '(' << "__ice_" << (*q)->name() << ')';
- }
-
- C.dec();
- C << sb;
- C << eb;
+ C << sp << nl << p->scoped().substr(2) << "::" << fixKwd(p->name()) << spar << allParamDecls << epar << " :";
+ C.inc();
+
+ DataMemberList dataMembers = p->dataMembers();
+
+ ClassList bases = p->bases();
+ ClassDefPtr base;
+ if(!bases.empty() && !bases.front()->isInterface())
+ {
+ if(emitVirtualBaseInitializers(bases.front()))
+ {
+ if(!dataMembers.empty())
+ {
+ C << ',';
+ }
+ }
+ }
+
+ if(!dataMembers.empty())
+ {
+ C << nl;
+ }
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ if(q != dataMembers.begin())
+ {
+ C << ',' << nl;
+ }
+ string memberName = fixKwd((*q)->name());
+ C << memberName << '(' << "__ice_" << (*q)->name() << ')';
+ }
+
+ C.dec();
+ C << sb;
+ C << eb;
}
}
@@ -2479,7 +2479,7 @@ Slice::Gen::IceInternalVisitor::visitUnitStart(const UnitPtr& p)
{
if(!p->hasClassDecls())
{
- return false;
+ return false;
}
H << sp;
@@ -2514,9 +2514,9 @@ Slice::Gen::IceInternalVisitor::visitClassDecl(const ClassDeclPtr& p)
{
H << sp << nl << "#endif // ICEE_PURE_CLIENT";
- H << sp;
- H << nl << _dllExport << "void incRef(::IceProxy" << scoped << "*);";
- H << nl << _dllExport << "void decRef(::IceProxy" << scoped << "*);";
+ H << sp;
+ H << nl << _dllExport << "void incRef(::IceProxy" << scoped << "*);";
+ H << nl << _dllExport << "void decRef(::IceProxy" << scoped << "*);";
}
}
@@ -2546,17 +2546,17 @@ Slice::Gen::IceInternalVisitor::visitClassDefStart(const ClassDefPtr& p)
{
C << sp << nl << "#endif // ICEE_PURE_CLIENT";
- C << sp;
- C << nl << "void" << nl << "IceInternal::incRef(::IceProxy" << scoped << "* p)";
- C << sb;
- C << nl << "p->__incRef();";
- C << eb;
+ C << sp;
+ C << nl << "void" << nl << "IceInternal::incRef(::IceProxy" << scoped << "* p)";
+ C << sb;
+ C << nl << "p->__incRef();";
+ C << eb;
- C << sp;
- C << nl << "void" << nl << "IceInternal::decRef(::IceProxy" << scoped << "* p)";
- C << sb;
- C << nl << "p->__decRef();";
- C << eb;
+ C << sp;
+ C << nl << "void" << nl << "IceInternal::decRef(::IceProxy" << scoped << "* p)";
+ C << sb;
+ C << nl << "p->__decRef();";
+ C << eb;
}
return true;
@@ -2572,7 +2572,7 @@ Slice::Gen::HandleVisitor::visitModuleStart(const ModulePtr& p)
{
if(!p->hasClassDecls())
{
- return false;
+ return false;
}
string name = fixKwd(p->name());
@@ -2608,11 +2608,11 @@ Slice::Gen::HandleVisitor::visitClassDecl(const ClassDeclPtr& p)
{
H << sp << nl << "#endif // ICEE_PURE_CLIENT" << sp;
- H << nl << "typedef ::IceInternal::ProxyHandle< ::IceProxy" << scoped << "> " << name << "Prx;";
+ H << nl << "typedef ::IceInternal::ProxyHandle< ::IceProxy" << scoped << "> " << name << "Prx;";
- H << sp;
- H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "Prx&);";
- H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "Prx&);";
+ H << sp;
+ H << nl << _dllExport << "void __write(::IceInternal::BasicStream*, const " << name << "Prx&);";
+ H << nl << _dllExport << "void __read(::IceInternal::BasicStream*, " << name << "Prx&);";
}
}
@@ -2622,45 +2622,45 @@ Slice::Gen::HandleVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!p->isLocal())
{
string name = p->name();
- string scoped = fixKwd(p->scoped());
- string scope = fixKwd(p->scope());
-
- string factory;
- string type;
- if(!p->isAbstract())
- {
- type = scoped + "::ice_staticId()";
- factory = scoped + "::ice_factory()";
- }
- else
- {
- type = "\"\"";
- factory = "0";
- }
-
- C << sp;
- C << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
- << scope << name << "Prx& v)";
- C << sb;
- C << nl << "__os->write(::Ice::ObjectPrx(v));";
- C << eb;
-
- C << sp;
- C << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, "
- << scope << name << "Prx& v)";
- C << sb;
- C << nl << "::Ice::ObjectPrx proxy;";
- C << nl << "__is->read(proxy);";
- C << nl << "if(!proxy)";
- C << sb;
- C << nl << "v = 0;";
- C << eb;
- C << nl << "else";
- C << sb;
- C << nl << "v = new ::IceProxy" << scoped << ';';
- C << nl << "v->__copyFrom(proxy);";
- C << eb;
- C << eb;
+ string scoped = fixKwd(p->scoped());
+ string scope = fixKwd(p->scope());
+
+ string factory;
+ string type;
+ if(!p->isAbstract())
+ {
+ type = scoped + "::ice_staticId()";
+ factory = scoped + "::ice_factory()";
+ }
+ else
+ {
+ type = "\"\"";
+ factory = "0";
+ }
+
+ C << sp;
+ C << nl << "void" << nl << scope.substr(2) << "__write(::IceInternal::BasicStream* __os, const "
+ << scope << name << "Prx& v)";
+ C << sb;
+ C << nl << "__os->write(::Ice::ObjectPrx(v));";
+ C << eb;
+
+ C << sp;
+ C << nl << "void" << nl << scope.substr(2) << "__read(::IceInternal::BasicStream* __is, "
+ << scope << name << "Prx& v)";
+ C << sb;
+ C << nl << "::Ice::ObjectPrx proxy;";
+ C << nl << "__is->read(proxy);";
+ C << nl << "if(!proxy)";
+ C << sb;
+ C << nl << "v = 0;";
+ C << eb;
+ C << nl << "else";
+ C << sb;
+ C << nl << "v = new ::IceProxy" << scoped << ';';
+ C << nl << "v->__copyFrom(proxy);";
+ C << eb;
+ C << eb;
}
return true;
@@ -2704,9 +2704,9 @@ Slice::Gen::ImplVisitor::writeReturn(Output& out, const TypePtr& type, const Str
out << nl << "return ::std::string();";
break;
}
- case Builtin::KindObject:
- case Builtin::KindObjectProxy:
- case Builtin::KindLocalObject:
+ case Builtin::KindObject:
+ case Builtin::KindObjectProxy:
+ case Builtin::KindLocalObject:
{
out << nl << "return 0;";
break;
@@ -2717,48 +2717,48 @@ Slice::Gen::ImplVisitor::writeReturn(Output& out, const TypePtr& type, const Str
{
ProxyPtr prx = ProxyPtr::dynamicCast(type);
if(prx)
- {
- out << nl << "return 0;";
- }
- else
- {
- ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
- if(cl)
- {
- out << nl << "return 0;";
- }
- else
- {
- StructPtr st = StructPtr::dynamicCast(type);
- if(st)
- {
- out << nl << "return " << fixKwd(st->scoped()) << "();";
- }
- else
- {
- EnumPtr en = EnumPtr::dynamicCast(type);
- if(en)
- {
- EnumeratorList enumerators = en->getEnumerators();
- out << nl << "return " << fixKwd(en->scope()) << fixKwd(enumerators.front()->name()) << ';';
- }
- else
- {
- SequencePtr seq = SequencePtr::dynamicCast(type);
- if(seq)
- {
- out << nl << "return " << typeToString(seq, _useWstring, metaData) << "();";
- }
- else
- {
- DictionaryPtr dict = DictionaryPtr::dynamicCast(type);
- assert(dict);
- out << nl << "return " << fixKwd(dict->scoped()) << "();";
- }
- }
- }
- }
- }
+ {
+ out << nl << "return 0;";
+ }
+ else
+ {
+ ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
+ if(cl)
+ {
+ out << nl << "return 0;";
+ }
+ else
+ {
+ StructPtr st = StructPtr::dynamicCast(type);
+ if(st)
+ {
+ out << nl << "return " << fixKwd(st->scoped()) << "();";
+ }
+ else
+ {
+ EnumPtr en = EnumPtr::dynamicCast(type);
+ if(en)
+ {
+ EnumeratorList enumerators = en->getEnumerators();
+ out << nl << "return " << fixKwd(en->scope()) << fixKwd(enumerators.front()->name()) << ';';
+ }
+ else
+ {
+ SequencePtr seq = SequencePtr::dynamicCast(type);
+ if(seq)
+ {
+ out << nl << "return " << typeToString(seq, _useWstring, metaData) << "();";
+ }
+ else
+ {
+ DictionaryPtr dict = DictionaryPtr::dynamicCast(type);
+ assert(dict);
+ out << nl << "return " << fixKwd(dict->scoped()) << "();";
+ }
+ }
+ }
+ }
+ }
}
}
@@ -2816,14 +2816,14 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
{
H << ',' << nl << "virtual public " << fixKwd((*q)->scope());
- if((*q)->isAbstract())
- {
- H << (*q)->name() << "I";
- }
- else
- {
- H << fixKwd((*q)->name());
- }
+ if((*q)->isAbstract())
+ {
+ H << (*q)->name() << "I";
+ }
+ else
+ {
+ H << fixKwd((*q)->name());
+ }
}
H.restoreIndent();
@@ -2854,20 +2854,20 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
H << ',' << nl;
}
- StringList metaData = (*q)->getMetaData();
+ StringList metaData = (*q)->getMetaData();
#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550)
- //
- // Work around for Sun CC 5.5 bug #4853566
- //
- string typeString;
- if((*q)->isOutParam())
- {
- typeString = outputTypeToString((*q)->type(), _useWstring, metaData);
- }
- else
- {
- typeString = inputTypeToString((*q)->type(), _useWstring, metaData);
- }
+ //
+ // Work around for Sun CC 5.5 bug #4853566
+ //
+ string typeString;
+ if((*q)->isOutParam())
+ {
+ typeString = outputTypeToString((*q)->type(), _useWstring, metaData);
+ }
+ else
+ {
+ typeString = inputTypeToString((*q)->type(), _useWstring, metaData);
+ }
#else
string typeString = (*q)->isOutParam() ?
outputTypeToString((*q)->type(), _useWstring, metaData) : inputTypeToString((*q)->type(), _useWstring, metaData);
@@ -2884,12 +2884,12 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
}
H.restoreIndent();
- bool isConst = (op->mode() == Operation::Nonmutating) || op->hasMetaData("cpp:const");
+ bool isConst = (op->mode() == Operation::Nonmutating) || op->hasMetaData("cpp:const");
H << ")" << (isConst ? " const" : "") << ';';
C << sp << nl << retS << nl;
- C << scope.substr(2) << name << "I::" << fixKwd(opName) << '(';
+ C << scope.substr(2) << name << "I::" << fixKwd(opName) << '(';
C.useCurrentPosAsIndent();
for(q = paramList.begin(); q != paramList.end(); ++q)
{
@@ -2898,20 +2898,20 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
C << ',' << nl;
}
- StringList metaData = (*q)->getMetaData();
+ StringList metaData = (*q)->getMetaData();
#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550)
- //
- // Work around for Sun CC 5.5 bug #4853566
- //
- string typeString;
- if((*q)->isOutParam())
- {
- typeString = outputTypeToString((*q)->type(), _useWstring, metaData);
- }
- else
- {
- typeString = inputTypeToString((*q)->type(), _useWstring, metaData);
- }
+ //
+ // Work around for Sun CC 5.5 bug #4853566
+ //
+ string typeString;
+ if((*q)->isOutParam())
+ {
+ typeString = outputTypeToString((*q)->type(), _useWstring, metaData);
+ }
+ else
+ {
+ typeString = inputTypeToString((*q)->type(), _useWstring, metaData);
+ }
#else
string typeString = (*q)->isOutParam() ?
outputTypeToString((*q)->type(), _useWstring, metaData) : inputTypeToString((*q)->type(), _useWstring, metaData);
@@ -2928,7 +2928,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
}
C.restoreIndent();
C << ')';
- C << (isConst ? " const" : "");
+ C << (isConst ? " const" : "");
C << sb;
if(ret)
@@ -2967,7 +2967,7 @@ Slice::Gen::MetaDataVisitor::visitModuleStart(const ModulePtr& p)
{
continue;
}
- cout << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl;
+ cout << file << ": warning: ignoring invalid global metadata `" << s << "'" << endl;
}
_history.insert(s);
}
@@ -3053,7 +3053,7 @@ Slice::Gen::MetaDataVisitor::visitOperation(const OperationPtr& p)
for(ParamDeclList::iterator q = params.begin(); q != params.end(); ++q)
{
validate((*q)->type(), (*q)->getMetaData(), p->definitionContext()->filename(), (*q)->line(),
- !(*q)->isOutParam());
+ !(*q)->isOutParam());
}
}
@@ -3095,12 +3095,12 @@ Slice::Gen::MetaDataVisitor::visitConst(const ConstPtr& p)
void
Slice::Gen::MetaDataVisitor::validate(const SyntaxTreeBasePtr& cont, const StringList& metaData,
- const string& file, const string& line, bool inParam)
+ const string& file, const string& line, bool inParam)
{
static const string prefix = "cpp:";
for(StringList::const_iterator p = metaData.begin(); p != metaData.end(); ++p)
{
- string s = *p;
+ string s = *p;
if(_history.count(s) == 0)
{
if(s.find(prefix) == 0)
@@ -3118,14 +3118,14 @@ Slice::Gen::MetaDataVisitor::validate(const SyntaxTreeBasePtr& cont, const Strin
continue;
}
}
- if(SequencePtr::dynamicCast(cont))
- {
- if(ss.find("type:") == 0 || (inParam && (ss == "array" || ss.find("range") == 0)))
- {
- continue;
- }
- }
- cout << file << ":" << line << ": warning: ignoring invalid metadata `" << s << "'" << endl;
+ if(SequencePtr::dynamicCast(cont))
+ {
+ if(ss.find("type:") == 0 || (inParam && (ss == "array" || ss.find("range") == 0)))
+ {
+ continue;
+ }
+ }
+ cout << file << ":" << line << ": warning: ignoring invalid metadata `" << s << "'" << endl;
}
_history.insert(s);
}
@@ -3200,13 +3200,13 @@ Slice::Gen::printDllExportStuff(Output& out, const string& dllExport)
{
if(dllExport.size())
{
- out << sp;
- out << "\n#ifndef " << dllExport;
- out << "\n# ifdef " << dllExport << "_EXPORTS";
- out << "\n# define " << dllExport << " ICE_DECLSPEC_EXPORT";
- out << "\n# else";
- out << "\n# define " << dllExport << " ICE_DECLSPEC_IMPORT";
- out << "\n# endif";
- out << "\n#endif";
+ out << sp;
+ out << "\n#ifndef " << dllExport;
+ out << "\n# ifdef " << dllExport << "_EXPORTS";
+ out << "\n# define " << dllExport << " ICE_DECLSPEC_EXPORT";
+ out << "\n# else";
+ out << "\n# define " << dllExport << " ICE_DECLSPEC_IMPORT";
+ out << "\n# endif";
+ out << "\n#endif";
}
}
diff --git a/cpp/src/slice2cppe/Gen.h b/cpp/src/slice2cppe/Gen.h
index 5922aa76b47..a6308a7e430 100644
--- a/cpp/src/slice2cppe/Gen.h
+++ b/cpp/src/slice2cppe/Gen.h
@@ -27,16 +27,16 @@ class Gen : private ::IceUtil::noncopyable
public:
Gen(const std::string&,
- const std::string&,
- const std::string&,
- const std::string&,
- const std::vector<std::string>&,
- const std::string&,
- const std::vector<std::string>&,
- const std::string&,
- const std::string&,
+ const std::string&,
+ const std::string&,
+ const std::string&,
+ const std::vector<std::string>&,
+ const std::string&,
+ const std::vector<std::string>&,
+ const std::string&,
+ const std::string&,
bool,
- bool);
+ bool);
~Gen();
bool operator!() const; // Returns true if there was a constructor error
@@ -84,181 +84,181 @@ private:
{
public:
- TypesVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
-
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual bool visitExceptionStart(const ExceptionPtr&);
- virtual void visitExceptionEnd(const ExceptionPtr&);
- virtual bool visitStructStart(const StructPtr&);
- virtual void visitStructEnd(const StructPtr&);
- virtual void visitSequence(const SequencePtr&);
- virtual void visitDictionary(const DictionaryPtr&);
- virtual void visitEnum(const EnumPtr&);
- virtual void visitConst(const ConstPtr&);
- virtual void visitDataMember(const DataMemberPtr&);
+ TypesVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual bool visitExceptionStart(const ExceptionPtr&);
+ virtual void visitExceptionEnd(const ExceptionPtr&);
+ virtual bool visitStructStart(const StructPtr&);
+ virtual void visitStructEnd(const StructPtr&);
+ virtual void visitSequence(const SequencePtr&);
+ virtual void visitDictionary(const DictionaryPtr&);
+ virtual void visitEnum(const EnumPtr&);
+ virtual void visitConst(const ConstPtr&);
+ virtual void visitDataMember(const DataMemberPtr&);
private:
- void emitUpcall(const ExceptionPtr&, const std::string&, bool = false);
+ void emitUpcall(const ExceptionPtr&, const std::string&, bool = false);
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
- bool _doneStaticSymbol;
- bool _useWstring;
- std::list<bool> _useWstringHist;
+ std::string _dllExport;
+ bool _doneStaticSymbol;
+ bool _useWstring;
+ std::list<bool> _useWstringHist;
};
class ProxyDeclVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
- ProxyDeclVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+ ProxyDeclVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
- virtual bool visitUnitStart(const UnitPtr&);
- virtual void visitUnitEnd(const UnitPtr&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual void visitClassDecl(const ClassDeclPtr&);
+ virtual bool visitUnitStart(const UnitPtr&);
+ virtual void visitUnitEnd(const UnitPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual void visitClassDecl(const ClassDeclPtr&);
private:
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
+ std::string _dllExport;
};
class ProxyVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
- ProxyVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+ ProxyVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
- virtual bool visitUnitStart(const UnitPtr&);
- virtual void visitUnitEnd(const UnitPtr&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
- virtual void visitOperation(const OperationPtr&);
+ virtual bool visitUnitStart(const UnitPtr&);
+ virtual void visitUnitEnd(const UnitPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
private:
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
- bool _useWstring;
- std::list<bool> _useWstringHist;
+ std::string _dllExport;
+ bool _useWstring;
+ std::list<bool> _useWstringHist;
};
class ObjectDeclVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
- ObjectDeclVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+ ObjectDeclVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual void visitClassDecl(const ClassDeclPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual void visitClassDecl(const ClassDeclPtr&);
private:
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
+ std::string _dllExport;
};
class ObjectVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
- ObjectVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+ ObjectVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
- virtual bool visitExceptionStart(const ExceptionPtr&);
- virtual bool visitStructStart(const StructPtr&);
- virtual void visitOperation(const OperationPtr&);
- virtual void visitDataMember(const DataMemberPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual bool visitExceptionStart(const ExceptionPtr&);
+ virtual bool visitStructStart(const StructPtr&);
+ virtual void visitOperation(const OperationPtr&);
+ virtual void visitDataMember(const DataMemberPtr&);
private:
- bool emitVirtualBaseInitializers(const ClassDefPtr&);
- void emitOneShotConstructor(const ClassDefPtr&);
- void emitUpcall(const ClassDefPtr&, const std::string&);
+ bool emitVirtualBaseInitializers(const ClassDefPtr&);
+ void emitOneShotConstructor(const ClassDefPtr&);
+ void emitUpcall(const ClassDefPtr&, const std::string&);
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
- bool _useWstring;
- std::list<bool> _useWstringHist;
+ std::string _dllExport;
+ bool _useWstring;
+ std::list<bool> _useWstringHist;
};
class IceInternalVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
- IceInternalVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+ IceInternalVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
- virtual bool visitUnitStart(const UnitPtr&);
- virtual void visitUnitEnd(const UnitPtr&);
- virtual void visitClassDecl(const ClassDeclPtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual bool visitUnitStart(const UnitPtr&);
+ virtual void visitUnitEnd(const UnitPtr&);
+ virtual void visitClassDecl(const ClassDeclPtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
private:
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
+ std::string _dllExport;
};
class HandleVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
- HandleVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+ HandleVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual void visitClassDecl(const ClassDeclPtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual void visitClassDecl(const ClassDeclPtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
private:
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
+ std::string _dllExport;
};
class ImplVisitor : private ::IceUtil::noncopyable, public ParserVisitor
{
public:
- ImplVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
+ ImplVisitor(::IceUtil::Output&, ::IceUtil::Output&, const std::string&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
private:
- ::IceUtil::Output& H;
- ::IceUtil::Output& C;
+ ::IceUtil::Output& H;
+ ::IceUtil::Output& C;
- std::string _dllExport;
- bool _useWstring;
- std::list<bool> _useWstringHist;
+ std::string _dllExport;
+ bool _useWstring;
+ std::list<bool> _useWstringHist;
//
// Generate code to return a dummy value
@@ -290,7 +290,7 @@ private:
private:
void validate(const SyntaxTreeBasePtr&, const StringList&, const std::string&, const std::string&,
- bool = false);
+ bool = false);
StringSet _history;
};
diff --git a/cpp/src/slice2cppe/Main.cpp b/cpp/src/slice2cppe/Main.cpp
index ff2dfe7f93e..1fda6e41dcd 100644
--- a/cpp/src/slice2cppe/Main.cpp
+++ b/cpp/src/slice2cppe/Main.cpp
@@ -18,18 +18,18 @@ void
usage(const char* n)
{
cerr << "Usage: " << n << " [options] slice-files...\n";
- cerr <<
+ cerr <<
"Options:\n"
"-h, --help Show this message.\n"
"-v, --version Display the Ice version.\n"
"--header-ext EXT Use EXT instead of the default `h' extension.\n"
"--source-ext EXT Use EXT instead of the default `cpp' extension.\n"
- "--add-header HDR[,GUARD] Add #include for HDR (with guard GUARD) to generated source file.\n"
+ "--add-header HDR[,GUARD] Add #include for HDR (with guard GUARD) to generated source file.\n"
"-DNAME Define NAME as 1.\n"
"-DNAME=DEF Define NAME as DEF.\n"
"-UNAME Remove any definition for NAME.\n"
"-IDIR Put DIR in the include file search path.\n"
- "-E Print preprocessor output on stdout.\n"
+ "-E Print preprocessor output on stdout.\n"
"--include-dir DIR Use DIR as the header include directory in source files.\n"
"--output-dir DIR Create files in the directory DIR.\n"
"--dll-export SYMBOL Use SYMBOL for DLL exports.\n"
@@ -70,21 +70,21 @@ main(int argc, char* argv[])
}
catch(const IceUtil::BadOptException& e)
{
- cerr << argv[0] << ": " << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": " << e.reason << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(argv[0]);
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICEE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICEE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
string headerExtension = opts.optArg("header-ext");
@@ -97,19 +97,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D" + Preprocessor::addQuotes(*i);
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U" + Preprocessor::addQuotes(*i);
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I" + Preprocessor::addQuotes(*i);
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
@@ -132,74 +132,74 @@ main(int argc, char* argv[])
if(args.empty())
{
- cerr << argv[0] << ": no input file" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": no input file" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
int status = EXIT_SUCCESS;
for(i = args.begin(); i != args.end(); ++i)
{
- if(depend)
- {
- Preprocessor icecpp(argv[0], *i, cppArgs);
- icecpp.printMakefileDependencies(Preprocessor::CPlusPlus);
- }
- else
- {
- Preprocessor icecpp(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp.preprocess(false);
-
- if(cppHandle == 0)
- {
- return EXIT_FAILURE;
- }
- if(preprocess)
- {
- char buf[4096];
- while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
- {
- if(fputs(buf, stdout) == EOF)
- {
- return EXIT_FAILURE;
- }
- }
- if(!icecpp.close())
- {
- return EXIT_FAILURE;
- }
- }
- else
- {
- UnitPtr u = Unit::createUnit(false, false, ice, caseSensitive);
- int parseStatus = u->parse(cppHandle, debug, Slice::IceE);
-
- if(!icecpp.close())
- {
- u->destroy();
- return EXIT_FAILURE;
- }
-
- if(parseStatus == EXIT_FAILURE)
- {
- status = EXIT_FAILURE;
- }
- else
- {
- Gen gen(argv[0], icecpp.getBaseName(), headerExtension, sourceExtension, extraHeaders, include,
- includePaths, dllExport, output, impl, ice);
- if(!gen)
- {
- u->destroy();
- return EXIT_FAILURE;
- }
- gen.generate(u);
- }
-
- u->destroy();
- }
- }
+ if(depend)
+ {
+ Preprocessor icecpp(argv[0], *i, cppArgs);
+ icecpp.printMakefileDependencies(Preprocessor::CPlusPlus);
+ }
+ else
+ {
+ Preprocessor icecpp(argv[0], *i, cppArgs);
+ FILE* cppHandle = icecpp.preprocess(false);
+
+ if(cppHandle == 0)
+ {
+ return EXIT_FAILURE;
+ }
+ if(preprocess)
+ {
+ char buf[4096];
+ while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
+ {
+ if(fputs(buf, stdout) == EOF)
+ {
+ return EXIT_FAILURE;
+ }
+ }
+ if(!icecpp.close())
+ {
+ return EXIT_FAILURE;
+ }
+ }
+ else
+ {
+ UnitPtr u = Unit::createUnit(false, false, ice, caseSensitive);
+ int parseStatus = u->parse(cppHandle, debug, Slice::IceE);
+
+ if(!icecpp.close())
+ {
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+
+ if(parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
+ else
+ {
+ Gen gen(argv[0], icecpp.getBaseName(), headerExtension, sourceExtension, extraHeaders, include,
+ includePaths, dllExport, output, impl, ice);
+ if(!gen)
+ {
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+ gen.generate(u);
+ }
+
+ u->destroy();
+ }
+ }
}
return status;
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index a60479dd0d1..82a9ac5f2f8 100755
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -45,26 +45,26 @@ sliceModeToIceMode(Operation::Mode opMode)
string mode;
switch(opMode)
{
- case Operation::Normal:
- {
- mode = "Ice.OperationMode.Normal";
- break;
- }
- case Operation::Nonmutating:
- {
- mode = "Ice.OperationMode.Nonmutating";
- break;
- }
- case Operation::Idempotent:
- {
- mode = "Ice.OperationMode.Idempotent";
- break;
- }
- default:
- {
- assert(false);
- break;
- }
+ case Operation::Normal:
+ {
+ mode = "Ice.OperationMode.Normal";
+ break;
+ }
+ case Operation::Nonmutating:
+ {
+ mode = "Ice.OperationMode.Nonmutating";
+ break;
+ }
+ case Operation::Idempotent:
+ {
+ mode = "Ice.OperationMode.Idempotent";
+ break;
+ }
+ default:
+ {
+ assert(false);
+ break;
+ }
}
return mode;
}
@@ -76,12 +76,12 @@ emitDeprecate(const ContainedPtr& p1, const ContainedPtr& p2, Output& out, const
if(p1->findMetaData("deprecate", deprecateMetadata) ||
(p2 != 0 && p2->findMetaData("deprecate", deprecateMetadata)))
{
- string deprecateReason = "This " + type + " has been deprecated.";
- if(deprecateMetadata.find("deprecate:") == 0 && deprecateMetadata.size() > 10)
- {
- deprecateReason = deprecateMetadata.substr(10);
- }
- out << nl << "[System.Obsolete(\"" << deprecateReason << "\")]";
+ string deprecateReason = "This " + type + " has been deprecated.";
+ if(deprecateMetadata.find("deprecate:") == 0 && deprecateMetadata.size() > 10)
+ {
+ deprecateReason = deprecateMetadata.substr(10);
+ }
+ out << nl << "[System.Obsolete(\"" << deprecateReason << "\")]";
}
}
@@ -99,64 +99,64 @@ Slice::CsVisitor::writeInheritedOperations(const ClassDefPtr& p)
ClassList bases = p->bases();
if(!bases.empty() && !bases.front()->isInterface())
{
- bases.pop_front();
+ bases.pop_front();
}
if(!bases.empty())
{
- _out << sp << nl << "#region Inherited Slice operations";
+ _out << sp << nl << "#region Inherited Slice operations";
OperationList allOps;
- for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
- {
- OperationList tmp = (*q)->allOperations();
- allOps.splice(allOps.end(), tmp);
- }
- allOps.sort();
- allOps.unique();
- for(OperationList::const_iterator op = allOps.begin(); op != allOps.end(); ++op)
- {
- ClassDefPtr containingClass = ClassDefPtr::dynamicCast((*op)->container());
- bool amd = containingClass->hasMetaData("amd") || (*op)->hasMetaData("amd");
- string name = fixId((*op)->name(), DotNet::ICloneable, true);
- if(!amd)
- {
- vector<string> params = getParams(*op);
- vector<string> args = getArgs(*op);
- string retS = typeToString((*op)->returnType());
-
- _out << sp << nl << "public " << retS << ' ' << name << spar << params << epar;
- _out << sb;
- _out << nl;
- if((*op)->returnType())
- {
- _out << "return ";
- }
- _out << name << spar << args << "Ice.ObjectImpl.defaultCurrent" << epar << ';';
- _out << eb;
-
- _out << sp << nl << "public abstract " << retS << ' ' << name << spar << params;
- if(!containingClass->isLocal())
- {
- _out << "Ice.Current current__";
- }
- _out << epar << ';';
- }
- else
- {
- vector<string> params = getParamsAsync(*op, true);
- vector<string> args = getArgsAsync(*op);
-
- _out << sp << nl << "public void " << name << "_async" << spar << params << epar;
- _out << sb;
- _out << nl << name << "_async" << spar << args << epar << ';';
- _out << eb;
-
- _out << sp << nl << "public abstract void " << name << "_async"
- << spar << params << "Ice.Current current__" << epar << ';';
- }
- }
-
- _out << sp << nl << "#endregion"; // Inherited Slice operations
+ for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
+ {
+ OperationList tmp = (*q)->allOperations();
+ allOps.splice(allOps.end(), tmp);
+ }
+ allOps.sort();
+ allOps.unique();
+ for(OperationList::const_iterator op = allOps.begin(); op != allOps.end(); ++op)
+ {
+ ClassDefPtr containingClass = ClassDefPtr::dynamicCast((*op)->container());
+ bool amd = containingClass->hasMetaData("amd") || (*op)->hasMetaData("amd");
+ string name = fixId((*op)->name(), DotNet::ICloneable, true);
+ if(!amd)
+ {
+ vector<string> params = getParams(*op);
+ vector<string> args = getArgs(*op);
+ string retS = typeToString((*op)->returnType());
+
+ _out << sp << nl << "public " << retS << ' ' << name << spar << params << epar;
+ _out << sb;
+ _out << nl;
+ if((*op)->returnType())
+ {
+ _out << "return ";
+ }
+ _out << name << spar << args << "Ice.ObjectImpl.defaultCurrent" << epar << ';';
+ _out << eb;
+
+ _out << sp << nl << "public abstract " << retS << ' ' << name << spar << params;
+ if(!containingClass->isLocal())
+ {
+ _out << "Ice.Current current__";
+ }
+ _out << epar << ';';
+ }
+ else
+ {
+ vector<string> params = getParamsAsync(*op, true);
+ vector<string> args = getArgsAsync(*op);
+
+ _out << sp << nl << "public void " << name << "_async" << spar << params << epar;
+ _out << sb;
+ _out << nl << name << "_async" << spar << args << epar << ';';
+ _out << eb;
+
+ _out << sp << nl << "public abstract void " << name << "_async"
+ << spar << params << "Ice.Current current__" << epar << ';';
+ }
+ }
+
+ _out << sp << nl << "#endregion"; // Inherited Slice operations
}
}
@@ -207,15 +207,15 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p)
_out << sb;
{
- StringList::const_iterator q = ids.begin();
- while(q != ids.end())
- {
- _out << nl << '"' << *q << '"';
- if(++q != ids.end())
- {
- _out << ',';
- }
- }
+ StringList::const_iterator q = ids.begin();
+ while(q != ids.end())
+ {
+ _out << nl << '"' << *q << '"';
+ if(++q != ids.end())
+ {
+ _out << ',';
+ }
+ }
}
_out << eb << ";";
@@ -309,406 +309,406 @@ Slice::CsVisitor::writeDispatch(const ClassDefPtr& p)
OperationList ops = p->operations();
if(!p->isInterface() || ops.size() != 0)
{
- _out << sp << nl << "#region Operation dispatch";
+ _out << sp << nl << "#region Operation dispatch";
}
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
OperationPtr op = *r;
- ContainerPtr container = op->container();
+ ContainerPtr container = op->container();
ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
assert(cl);
string opName = op->name();
_out << sp << nl << "public static IceInternal.DispatchStatus " << opName << "___(" << name
- << " obj__, IceInternal.Incoming inS__, Ice.Current current__)";
+ << " obj__, IceInternal.Incoming inS__, Ice.Current current__)";
_out << sb;
- bool amd = p->hasMetaData("amd") || op->hasMetaData("amd");
- if(!amd)
- {
- TypePtr ret = op->returnType();
-
- TypeStringList inParams;
- TypeStringList outParams;
- ParamDeclList paramList = op->parameters();
- for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
- {
- if((*pli)->isOutParam())
- {
- outParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
- }
- else
- {
- inParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
- }
- }
-
- ExceptionList throws = op->throws();
- throws.sort();
- throws.unique();
-
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
+ bool amd = p->hasMetaData("amd") || op->hasMetaData("amd");
+ if(!amd)
+ {
+ TypePtr ret = op->returnType();
+
+ TypeStringList inParams;
+ TypeStringList outParams;
+ ParamDeclList paramList = op->parameters();
+ for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
+ {
+ if((*pli)->isOutParam())
+ {
+ outParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
+ }
+ else
+ {
+ inParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
+ }
+ }
+
+ ExceptionList throws = op->throws();
+ throws.sort();
+ throws.unique();
+
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
#if defined(__SUNPRO_CC)
- throws.sort(Slice::derivedToBaseCompare);
+ throws.sort(Slice::derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
- TypeStringList::const_iterator q;
-
- _out << nl << "checkMode__(" << sliceModeToIceMode(op->mode()) << ", current__.mode);";
- if(!inParams.empty())
- {
- _out << nl << "IceInternal.BasicStream is__ = inS__.istr();";
- }
- if(!outParams.empty() || ret || !throws.empty())
- {
- _out << nl << "IceInternal.BasicStream os__ = inS__.ostr();";
- }
-
- //
- // Unmarshal 'in' parameters.
- //
- for(q = inParams.begin(); q != inParams.end(); ++q)
- {
- string param = fixId(q->second);
- string typeS = typeToString(q->first);
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
- bool isClass = (builtin && builtin->kind() == Builtin::KindObject)
- || ClassDeclPtr::dynamicCast(q->first);
- if(!isClass)
- {
- _out << nl << typeS << ' ' << param << ';';
- }
- writeMarshalUnmarshalCode(_out, q->first, param, false, false, true);
- }
- if(op->sendsClasses())
- {
- _out << nl << "is__.readPendingObjects();";
- }
-
- for(q = outParams.begin(); q != outParams.end(); ++q)
- {
- string typeS = typeToString(q->first);
- _out << nl << typeS << ' ' << fixId(q->second) << ";";
- }
-
- //
- // Call on the servant.
- //
- if(!throws.empty())
- {
- _out << nl << "try";
- _out << sb;
- }
- _out << nl;
- if(ret)
- {
- string retS = typeToString(ret);
- _out << retS << " ret__ = ";
- }
- _out << "obj__." << fixId(opName, DotNet::ICloneable, true) << spar;
- for(q = inParams.begin(); q != inParams.end(); ++q)
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
- bool isClass = (builtin && builtin->kind() == Builtin::KindObject)
- || ClassDeclPtr::dynamicCast(q->first);
-
- string arg;
- if(isClass)
- {
- arg += "(" + typeToString(q->first) + ")";
- }
- arg += fixId(q->second);
- if(isClass)
- {
- arg += "_PP.value";
- }
- _out << arg;
- }
- for(q = outParams.begin(); q != outParams.end(); ++q)
- {
- _out << "out " + fixId(q->second);
- }
- _out << "current__" << epar << ';';
-
- //
- // Marshal 'out' parameters and return value.
- //
- for(q = outParams.begin(); q != outParams.end(); ++q)
- {
- writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, true, "");
- }
- if(ret)
- {
- writeMarshalUnmarshalCode(_out, ret, "ret__", true, false, true, "");
- }
- if(op->returnsClasses())
- {
- _out << nl << "os__.writePendingObjects();";
- }
- _out << nl << "return IceInternal.DispatchStatus.DispatchOK;";
-
- //
- // Handle user exceptions.
- //
- if(!throws.empty())
- {
- _out << eb;
- ExceptionList::const_iterator t;
- for(t = throws.begin(); t != throws.end(); ++t)
- {
- string exS = fixId((*t)->scoped());
- _out << nl << "catch(" << exS << " ex)";
- _out << sb;
- _out << nl << "os__.writeUserException(ex);";
- _out << nl << "return IceInternal.DispatchStatus.DispatchUserException;";
- _out << eb;
- }
- }
-
- _out << eb;
- }
- else
- {
- TypeStringList inParams;
- ParamDeclList paramList = op->parameters();
- for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
- {
- if(!(*pli)->isOutParam())
- {
- inParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
- }
- }
-
- TypeStringList::const_iterator q;
- _out << nl << "checkMode__(" << sliceModeToIceMode(op->mode()) << ", current__.mode);";
+ TypeStringList::const_iterator q;
+
+ _out << nl << "checkMode__(" << sliceModeToIceMode(op->mode()) << ", current__.mode);";
+ if(!inParams.empty())
+ {
+ _out << nl << "IceInternal.BasicStream is__ = inS__.istr();";
+ }
+ if(!outParams.empty() || ret || !throws.empty())
+ {
+ _out << nl << "IceInternal.BasicStream os__ = inS__.ostr();";
+ }
+
+ //
+ // Unmarshal 'in' parameters.
+ //
+ for(q = inParams.begin(); q != inParams.end(); ++q)
+ {
+ string param = fixId(q->second);
+ string typeS = typeToString(q->first);
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
+ bool isClass = (builtin && builtin->kind() == Builtin::KindObject)
+ || ClassDeclPtr::dynamicCast(q->first);
+ if(!isClass)
+ {
+ _out << nl << typeS << ' ' << param << ';';
+ }
+ writeMarshalUnmarshalCode(_out, q->first, param, false, false, true);
+ }
+ if(op->sendsClasses())
+ {
+ _out << nl << "is__.readPendingObjects();";
+ }
+
+ for(q = outParams.begin(); q != outParams.end(); ++q)
+ {
+ string typeS = typeToString(q->first);
+ _out << nl << typeS << ' ' << fixId(q->second) << ";";
+ }
+
+ //
+ // Call on the servant.
+ //
+ if(!throws.empty())
+ {
+ _out << nl << "try";
+ _out << sb;
+ }
+ _out << nl;
+ if(ret)
+ {
+ string retS = typeToString(ret);
+ _out << retS << " ret__ = ";
+ }
+ _out << "obj__." << fixId(opName, DotNet::ICloneable, true) << spar;
+ for(q = inParams.begin(); q != inParams.end(); ++q)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
+ bool isClass = (builtin && builtin->kind() == Builtin::KindObject)
+ || ClassDeclPtr::dynamicCast(q->first);
+
+ string arg;
+ if(isClass)
+ {
+ arg += "(" + typeToString(q->first) + ")";
+ }
+ arg += fixId(q->second);
+ if(isClass)
+ {
+ arg += "_PP.value";
+ }
+ _out << arg;
+ }
+ for(q = outParams.begin(); q != outParams.end(); ++q)
+ {
+ _out << "out " + fixId(q->second);
+ }
+ _out << "current__" << epar << ';';
+
+ //
+ // Marshal 'out' parameters and return value.
+ //
+ for(q = outParams.begin(); q != outParams.end(); ++q)
+ {
+ writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, true, "");
+ }
+ if(ret)
+ {
+ writeMarshalUnmarshalCode(_out, ret, "ret__", true, false, true, "");
+ }
+ if(op->returnsClasses())
+ {
+ _out << nl << "os__.writePendingObjects();";
+ }
+ _out << nl << "return IceInternal.DispatchStatus.DispatchOK;";
+
+ //
+ // Handle user exceptions.
+ //
+ if(!throws.empty())
+ {
+ _out << eb;
+ ExceptionList::const_iterator t;
+ for(t = throws.begin(); t != throws.end(); ++t)
+ {
+ string exS = fixId((*t)->scoped());
+ _out << nl << "catch(" << exS << " ex)";
+ _out << sb;
+ _out << nl << "os__.writeUserException(ex);";
+ _out << nl << "return IceInternal.DispatchStatus.DispatchUserException;";
+ _out << eb;
+ }
+ }
+
+ _out << eb;
+ }
+ else
+ {
+ TypeStringList inParams;
+ ParamDeclList paramList = op->parameters();
+ for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
+ {
+ if(!(*pli)->isOutParam())
+ {
+ inParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
+ }
+ }
+
+ TypeStringList::const_iterator q;
+ _out << nl << "checkMode__(" << sliceModeToIceMode(op->mode()) << ", current__.mode);";
- if(!inParams.empty())
- {
- _out << nl << "IceInternal.BasicStream is__ = inS__.istr();";
- }
-
- //
- // Unmarshal 'in' parameters.
- //
- for(q = inParams.begin(); q != inParams.end(); ++q)
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
- bool isClass = (builtin && builtin->kind() == Builtin::KindObject)
- || ClassDeclPtr::dynamicCast(q->first);
- if(!isClass)
- {
- _out << nl << typeToString(q->first) << ' ' << fixId(q->second) << ';';
- }
- writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, false, true);
- }
- if(op->sendsClasses())
- {
- _out << nl << "is__.readPendingObjects();";
- }
-
- //
- // Call on the servant.
- //
- string classNameAMD = "AMD_" + p->name();
- _out << nl << classNameAMD << '_' << opName << " cb__ = new _" << classNameAMD << '_' << opName
- << "(inS__);";
+ if(!inParams.empty())
+ {
+ _out << nl << "IceInternal.BasicStream is__ = inS__.istr();";
+ }
+
+ //
+ // Unmarshal 'in' parameters.
+ //
+ for(q = inParams.begin(); q != inParams.end(); ++q)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
+ bool isClass = (builtin && builtin->kind() == Builtin::KindObject)
+ || ClassDeclPtr::dynamicCast(q->first);
+ if(!isClass)
+ {
+ _out << nl << typeToString(q->first) << ' ' << fixId(q->second) << ';';
+ }
+ writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, false, true);
+ }
+ if(op->sendsClasses())
+ {
+ _out << nl << "is__.readPendingObjects();";
+ }
+
+ //
+ // Call on the servant.
+ //
+ string classNameAMD = "AMD_" + p->name();
+ _out << nl << classNameAMD << '_' << opName << " cb__ = new _" << classNameAMD << '_' << opName
+ << "(inS__);";
_out << nl << "try";
_out << sb;
- _out << nl << "obj__.";
- if(amd)
- {
- _out << opName << "_async";
- }
- else
- {
- _out << fixId(opName, DotNet::ICloneable, true);
- }
- _out << spar;
- if(amd)
- {
- _out << "cb__";
- }
- for(q = inParams.begin(); q != inParams.end(); ++q)
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
- bool isClass = (builtin && builtin->kind() == Builtin::KindObject)
- || ClassDeclPtr::dynamicCast(q->first);
- string arg;
- if(isClass)
- {
- arg += "(" + typeToString(q->first) + ")";
- }
- arg += fixId(q->second);
- if(isClass)
- {
- arg += "_PP.value";
- }
- _out << arg;
- }
- _out << "current__" << epar << ';';
- _out << eb;
- _out << nl << "catch(_System.Exception ex)";
- _out << sb;
- _out << nl << "cb__.ice_exception(ex);";
- _out << eb;
- _out << nl << "return IceInternal.DispatchStatus.DispatchAsync;";
-
- _out << eb;
- }
+ _out << nl << "obj__.";
+ if(amd)
+ {
+ _out << opName << "_async";
+ }
+ else
+ {
+ _out << fixId(opName, DotNet::ICloneable, true);
+ }
+ _out << spar;
+ if(amd)
+ {
+ _out << "cb__";
+ }
+ for(q = inParams.begin(); q != inParams.end(); ++q)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
+ bool isClass = (builtin && builtin->kind() == Builtin::KindObject)
+ || ClassDeclPtr::dynamicCast(q->first);
+ string arg;
+ if(isClass)
+ {
+ arg += "(" + typeToString(q->first) + ")";
+ }
+ arg += fixId(q->second);
+ if(isClass)
+ {
+ arg += "_PP.value";
+ }
+ _out << arg;
+ }
+ _out << "current__" << epar << ';';
+ _out << eb;
+ _out << nl << "catch(_System.Exception ex)";
+ _out << sb;
+ _out << nl << "cb__.ice_exception(ex);";
+ _out << eb;
+ _out << nl << "return IceInternal.DispatchStatus.DispatchAsync;";
+
+ _out << eb;
+ }
}
OperationList allOps = p->allOperations();
if(!allOps.empty())
{
- StringList allOpNames;
+ StringList allOpNames;
#if defined(__IBMCPP__) && defined(NDEBUG)
- //
- // See comment for transform above
- //
- transform(allOps.begin(), allOps.end(), back_inserter(allOpNames), ::IceUtil::constMemFun<string,Operation>(&Contained::name));
+ //
+ // See comment for transform above
+ //
+ transform(allOps.begin(), allOps.end(), back_inserter(allOpNames), ::IceUtil::constMemFun<string,Operation>(&Contained::name));
#else
- transform(allOps.begin(), allOps.end(), back_inserter(allOpNames), ::IceUtil::constMemFun(&Contained::name));
+ transform(allOps.begin(), allOps.end(), back_inserter(allOpNames), ::IceUtil::constMemFun(&Contained::name));
#endif
- allOpNames.push_back("ice_id");
- allOpNames.push_back("ice_ids");
- allOpNames.push_back("ice_isA");
- allOpNames.push_back("ice_ping");
-
- //
- // We sort into case-insensitive order here because, at run time,
- // the sort order must match the sort order used by System.Array.Sort().
- // (C# has no notion of the default ASCII ordering.)
- //
+ allOpNames.push_back("ice_id");
+ allOpNames.push_back("ice_ids");
+ allOpNames.push_back("ice_isA");
+ allOpNames.push_back("ice_ping");
+
+ //
+ // We sort into case-insensitive order here because, at run time,
+ // the sort order must match the sort order used by System.Array.Sort().
+ // (C# has no notion of the default ASCII ordering.)
+ //
#if defined(__SUNPRO_CC)
- allOpNames.sort(Slice::cICompare);
+ allOpNames.sort(Slice::cICompare);
#else
- allOpNames.sort(Slice::CICompare());
+ allOpNames.sort(Slice::CICompare());
#endif
- allOpNames.unique();
-
- StringList::const_iterator q;
-
- _out << sp << nl << "private static string[] all__ =";
- _out << sb;
- q = allOpNames.begin();
- while(q != allOpNames.end())
- {
- _out << nl << '"' << *q << '"';
- if(++q != allOpNames.end())
- {
- _out << ',';
- }
- }
- _out << eb << ';';
-
- _out << sp << nl << "public override IceInternal.DispatchStatus "
- << "dispatch__(IceInternal.Incoming inS__, Ice.Current current__)";
- _out << sb;
- _out << nl << "int pos;";
- //
- // TODO: Remove linear search for Mono once this bug is fixed.
- //
- _out << nl << "if(IceInternal.AssemblyUtil.runtime_ == IceInternal.AssemblyUtil.Runtime.Mono)";
- _out << sb;
- _out << nl << "// Mono bug: System.Array.BinarySearch() uses the wrong collation sequence,";
- _out << nl << "// so we do a linear search for the time being";
- _out << nl << "pos = 0;";
- _out << nl << "while(pos < all__.Length)";
- _out << sb;
- _out << nl << "if(all__[pos] == current__.operation)";
- _out << sb;
- _out << nl << "break;";
- _out << eb;
- _out << nl << "++pos;";
- _out << eb;
- _out << nl << "if(pos == all__.Length)";
- _out << sb;
- _out << nl << "pos = -1;";
- _out << eb;
- _out << eb;
- _out << nl << "else";
- _out << sb;
- _out << nl << "pos = _System.Array.BinarySearch(all__, current__.operation, "
- << "_System.Collections.Comparer.DefaultInvariant);";
- _out << eb;
- _out << nl << "if(pos < 0)";
- _out << sb;
- _out << nl << "return IceInternal.DispatchStatus.DispatchOperationNotExist;";
- _out << eb;
- _out << sp << nl << "switch(pos)";
- _out << sb;
- int i = 0;
- for(q = allOpNames.begin(); q != allOpNames.end(); ++q)
- {
- string opName = *q;
-
- _out << nl << "case " << i++ << ':';
- _out << sb;
- if(opName == "ice_id")
- {
- _out << nl << "return ice_id___(this, inS__, current__);";
- }
- else if(opName == "ice_ids")
- {
- _out << nl << "return ice_ids___(this, inS__, current__);";
- }
- else if(opName == "ice_isA")
- {
- _out << nl << "return ice_isA___(this, inS__, current__);";
- }
- else if(opName == "ice_ping")
- {
- _out << nl << "return ice_ping___(this, inS__, current__);";
- }
- else
- {
- //
- // There's probably a better way to do this
- //
- for(OperationList::const_iterator t = allOps.begin(); t != allOps.end(); ++t)
- {
- if((*t)->name() == (*q))
- {
- ContainerPtr container = (*t)->container();
- ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- assert(cl);
- if(cl->scoped() == p->scoped())
- {
- _out << nl << "return " << opName << "___(this, inS__, current__);";
- }
- else
- {
- string base = cl->scoped();
- if(cl->isInterface())
- {
- base += "Disp_";
- }
- _out << nl << "return " << fixId(base) << "." << opName << "___(this, inS__, current__);";
- }
- break;
- }
- }
- }
- _out << eb;
- }
- _out << eb;
- _out << sp << nl << "_System.Diagnostics.Debug.Assert(false);";
- _out << nl << "return IceInternal.DispatchStatus.DispatchOperationNotExist;";
- _out << eb;
+ allOpNames.unique();
+
+ StringList::const_iterator q;
+
+ _out << sp << nl << "private static string[] all__ =";
+ _out << sb;
+ q = allOpNames.begin();
+ while(q != allOpNames.end())
+ {
+ _out << nl << '"' << *q << '"';
+ if(++q != allOpNames.end())
+ {
+ _out << ',';
+ }
+ }
+ _out << eb << ';';
+
+ _out << sp << nl << "public override IceInternal.DispatchStatus "
+ << "dispatch__(IceInternal.Incoming inS__, Ice.Current current__)";
+ _out << sb;
+ _out << nl << "int pos;";
+ //
+ // TODO: Remove linear search for Mono once this bug is fixed.
+ //
+ _out << nl << "if(IceInternal.AssemblyUtil.runtime_ == IceInternal.AssemblyUtil.Runtime.Mono)";
+ _out << sb;
+ _out << nl << "// Mono bug: System.Array.BinarySearch() uses the wrong collation sequence,";
+ _out << nl << "// so we do a linear search for the time being";
+ _out << nl << "pos = 0;";
+ _out << nl << "while(pos < all__.Length)";
+ _out << sb;
+ _out << nl << "if(all__[pos] == current__.operation)";
+ _out << sb;
+ _out << nl << "break;";
+ _out << eb;
+ _out << nl << "++pos;";
+ _out << eb;
+ _out << nl << "if(pos == all__.Length)";
+ _out << sb;
+ _out << nl << "pos = -1;";
+ _out << eb;
+ _out << eb;
+ _out << nl << "else";
+ _out << sb;
+ _out << nl << "pos = _System.Array.BinarySearch(all__, current__.operation, "
+ << "_System.Collections.Comparer.DefaultInvariant);";
+ _out << eb;
+ _out << nl << "if(pos < 0)";
+ _out << sb;
+ _out << nl << "return IceInternal.DispatchStatus.DispatchOperationNotExist;";
+ _out << eb;
+ _out << sp << nl << "switch(pos)";
+ _out << sb;
+ int i = 0;
+ for(q = allOpNames.begin(); q != allOpNames.end(); ++q)
+ {
+ string opName = *q;
+
+ _out << nl << "case " << i++ << ':';
+ _out << sb;
+ if(opName == "ice_id")
+ {
+ _out << nl << "return ice_id___(this, inS__, current__);";
+ }
+ else if(opName == "ice_ids")
+ {
+ _out << nl << "return ice_ids___(this, inS__, current__);";
+ }
+ else if(opName == "ice_isA")
+ {
+ _out << nl << "return ice_isA___(this, inS__, current__);";
+ }
+ else if(opName == "ice_ping")
+ {
+ _out << nl << "return ice_ping___(this, inS__, current__);";
+ }
+ else
+ {
+ //
+ // There's probably a better way to do this
+ //
+ for(OperationList::const_iterator t = allOps.begin(); t != allOps.end(); ++t)
+ {
+ if((*t)->name() == (*q))
+ {
+ ContainerPtr container = (*t)->container();
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
+ assert(cl);
+ if(cl->scoped() == p->scoped())
+ {
+ _out << nl << "return " << opName << "___(this, inS__, current__);";
+ }
+ else
+ {
+ string base = cl->scoped();
+ if(cl->isInterface())
+ {
+ base += "Disp_";
+ }
+ _out << nl << "return " << fixId(base) << "." << opName << "___(this, inS__, current__);";
+ }
+ break;
+ }
+ }
+ }
+ _out << eb;
+ }
+ _out << eb;
+ _out << sp << nl << "_System.Diagnostics.Debug.Assert(false);";
+ _out << nl << "return IceInternal.DispatchStatus.DispatchOperationNotExist;";
+ _out << eb;
}
if(!p->isInterface() || ops.size() != 0)
{
- _out << sp << nl << "#endregion"; // Operation dispatch
+ _out << sp << nl << "#endregion"; // Operation dispatch
}
}
@@ -719,11 +719,11 @@ Slice::CsVisitor::getParamAttributes(const ParamDeclPtr& p)
StringList metaData = p->getMetaData();
for(StringList::const_iterator i = metaData.begin(); i != metaData.end(); ++i)
{
- static const string prefix = "cs:attribute:";
+ static const string prefix = "cs:attribute:";
if(i->find(prefix) == 0)
- {
- result += "[" + i->substr(prefix.size()) + "] ";
- }
+ {
+ result += "[" + i->substr(prefix.size()) + "] ";
+ }
}
return result;
}
@@ -735,13 +735,13 @@ Slice::CsVisitor::getParams(const OperationPtr& op)
ParamDeclList paramList = op->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- string param = getParamAttributes(*q);
- if((*q)->isOutParam())
- {
- param += "out ";
- }
- param += typeToString((*q)->type()) + " " + fixId((*q)->name());
- params.push_back(param);
+ string param = getParamAttributes(*q);
+ if((*q)->isOutParam())
+ {
+ param += "out ";
+ }
+ param += typeToString((*q)->type()) + " " + fixId((*q)->name());
+ params.push_back(param);
}
return params;
}
@@ -760,10 +760,10 @@ Slice::CsVisitor::getParamsAsync(const OperationPtr& op, bool amd)
ParamDeclList paramList = op->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- if(!(*q)->isOutParam())
- {
- params.push_back(getParamAttributes(*q) + typeToString((*q)->type()) + " " + fixId((*q)->name()));
- }
+ if(!(*q)->isOutParam())
+ {
+ params.push_back(getParamAttributes(*q) + typeToString((*q)->type()) + " " + fixId((*q)->name()));
+ }
}
return params;
}
@@ -776,16 +776,16 @@ Slice::CsVisitor::getParamsAsyncCB(const OperationPtr& op)
TypePtr ret = op->returnType();
if(ret)
{
- params.push_back(typeToString(ret) + " ret__");
+ params.push_back(typeToString(ret) + " ret__");
}
ParamDeclList paramList = op->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- if((*q)->isOutParam())
- {
- params.push_back(getParamAttributes(*q) + typeToString((*q)->type()) + ' ' + fixId((*q)->name()));
- }
+ if((*q)->isOutParam())
+ {
+ params.push_back(getParamAttributes(*q) + typeToString((*q)->type()) + ' ' + fixId((*q)->name()));
+ }
}
return params;
@@ -798,11 +798,11 @@ Slice::CsVisitor::getArgs(const OperationPtr& op)
ParamDeclList paramList = op->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- string arg = fixId((*q)->name());
- if((*q)->isOutParam())
- {
- arg = "out " + arg;
- }
+ string arg = fixId((*q)->name());
+ if((*q)->isOutParam())
+ {
+ arg = "out " + arg;
+ }
args.push_back(arg);
}
return args;
@@ -819,9 +819,9 @@ Slice::CsVisitor::getArgsAsync(const OperationPtr& op)
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
if(!(*q)->isOutParam())
- {
- args.push_back(fixId((*q)->name()));
- }
+ {
+ args.push_back(fixId((*q)->name()));
+ }
}
return args;
}
@@ -841,9 +841,9 @@ Slice::CsVisitor::getArgsAsyncCB(const OperationPtr& op)
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
if((*q)->isOutParam())
- {
- args.push_back(fixId((*q)->name()));
- }
+ {
+ args.push_back(fixId((*q)->name()));
+ }
}
return args;
@@ -855,11 +855,11 @@ Slice::CsVisitor::emitAttributes(const ContainedPtr& p)
StringList metaData = p->getMetaData();
for(StringList::const_iterator i = metaData.begin(); i != metaData.end(); ++i)
{
- static const string prefix = "cs:attribute:";
+ static const string prefix = "cs:attribute:";
if(i->find(prefix) == 0)
- {
- _out << nl << '[' << i->substr(prefix.size()) << ']';
- }
+ {
+ _out << nl << '[' << i->substr(prefix.size()) << ']';
+ }
}
}
@@ -872,22 +872,22 @@ Slice::Gen::Gen(const string& name, const string& base, const vector<string>& in
string::size_type pos = base.find_last_of("/\\");
if(pos != string::npos)
{
- fileBase = base.substr(pos + 1);
+ fileBase = base.substr(pos + 1);
}
string file = fileBase + ".cs";
string fileImpl = fileBase + "I.cs";
if(!dir.empty())
{
- file = dir + '/' + file;
- fileImpl = dir + '/' + fileImpl;
+ file = dir + '/' + file;
+ fileImpl = dir + '/' + fileImpl;
}
_out.open(file.c_str());
if(!_out)
{
cerr << name << ": can't open `" << file << "' for writing" << endl;
- return;
+ return;
}
printHeader();
@@ -899,17 +899,17 @@ Slice::Gen::Gen(const string& name, const string& base, const vector<string>& in
if(impl || implTie)
{
struct stat st;
- if(stat(fileImpl.c_str(), &st) == 0)
- {
- cerr << name << ": `" << fileImpl << "' already exists--will not overwrite" << endl;
- return;
- }
- _impl.open(fileImpl.c_str());
- if(!_impl)
- {
- cerr << name << ": can't open `" << fileImpl << "' for writing" << endl;
- return;
- }
+ if(stat(fileImpl.c_str(), &st) == 0)
+ {
+ cerr << name << ": `" << fileImpl << "' already exists--will not overwrite" << endl;
+ return;
+ }
+ _impl.open(fileImpl.c_str());
+ if(!_impl)
+ {
+ cerr << name << ": can't open `" << fileImpl << "' for writing" << endl;
+ return;
+ }
}
}
@@ -1060,25 +1060,25 @@ Slice::Gen::UnitVisitor::visitModuleStart(const ModulePtr& p)
{
if(!_globalMetaDataDone)
{
- DefinitionContextPtr dc = p->definitionContext();
- StringList globalMetaData = dc->getMetaData();
-
- static const string attributePrefix = "cs:attribute:";
-
- if(!globalMetaData.empty())
- {
- _out << sp;
- }
- for(StringList::const_iterator q = globalMetaData.begin(); q != globalMetaData.end(); ++q)
- {
- string::size_type pos = q->find(attributePrefix);
- if(pos == 0)
- {
- string attrib = q->substr(pos + attributePrefix.size());
- _out << nl << '[' << attrib << ']';
- }
- }
- _globalMetaDataDone = true; // Do this only once per source file.
+ DefinitionContextPtr dc = p->definitionContext();
+ StringList globalMetaData = dc->getMetaData();
+
+ static const string attributePrefix = "cs:attribute:";
+
+ if(!globalMetaData.empty())
+ {
+ _out << sp;
+ }
+ for(StringList::const_iterator q = globalMetaData.begin(); q != globalMetaData.end(); ++q)
+ {
+ string::size_type pos = q->find(attributePrefix);
+ if(pos == 0)
+ {
+ string attrib = q->substr(pos + attributePrefix.size());
+ _out << nl << '[' << attrib << ']';
+ }
+ }
+ _globalMetaDataDone = true; // Do this only once per source file.
}
return false;
}
@@ -1119,107 +1119,107 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!p->isLocal() && _stream)
{
_out << sp << nl << "public sealed class " << name << "Helper";
- _out << sb;
+ _out << sb;
- _out << sp << nl << "public " << name << "Helper(Ice.InputStream inS__)";
- _out << sb;
- _out << nl << "_in = inS__;";
- _out << nl << "_pp = new IceInternal.ParamPatcher(typeof(" << scoped << "), \"" << p->scoped() << "\");";
- _out << eb;
+ _out << sp << nl << "public " << name << "Helper(Ice.InputStream inS__)";
+ _out << sb;
+ _out << nl << "_in = inS__;";
+ _out << nl << "_pp = new IceInternal.ParamPatcher(typeof(" << scoped << "), \"" << p->scoped() << "\");";
+ _out << eb;
- _out << sp << nl << "public static void write(Ice.OutputStream outS__, " << fixId(name) << " v__)";
- _out << sb;
- _out << nl << "outS__.writeObject(v__);";
- _out << eb;
+ _out << sp << nl << "public static void write(Ice.OutputStream outS__, " << fixId(name) << " v__)";
+ _out << sb;
+ _out << nl << "outS__.writeObject(v__);";
+ _out << eb;
- _out << sp << nl << "public void read()";
- _out << sb;
- _out << nl << "_in.readObject(_pp);";
- _out << eb;
+ _out << sp << nl << "public void read()";
+ _out << sb;
+ _out << nl << "_in.readObject(_pp);";
+ _out << eb;
- _out << sp << nl << "public " << scoped << " value";
- _out << sb;
- _out << nl << "get";
- _out << sb;
- _out << nl << "return (" << scoped << ")_pp.value;";
- _out << eb;
- _out << eb;
+ _out << sp << nl << "public " << scoped << " value";
+ _out << sb;
+ _out << nl << "get";
+ _out << sb;
+ _out << nl << "return (" << scoped << ")_pp.value;";
+ _out << eb;
+ _out << eb;
- _out << sp << nl << "private Ice.InputStream _in;";
- _out << nl << "private IceInternal.ParamPatcher _pp;";
+ _out << sp << nl << "private Ice.InputStream _in;";
+ _out << nl << "private IceInternal.ParamPatcher _pp;";
- _out << eb;
+ _out << eb;
}
_out << sp;
emitAttributes(p);
if(p->isInterface())
{
- _out << nl << "public interface " << fixId(name) << " : ";
- if(p->isLocal())
- {
- _out << "Ice.LocalObject";
- }
- else
- {
- _out << "Ice.Object";
- }
- _out << ", " << name;
- if(!p->isLocal())
- {
- _out << "Operations_, " << name;
- }
- _out << "OperationsNC_";
- if(!bases.empty())
- {
- ClassList::const_iterator q = bases.begin();
- while(q != bases.end())
- {
- _out << ", " << fixId((*q)->scoped());
- q++;
- }
- }
+ _out << nl << "public interface " << fixId(name) << " : ";
+ if(p->isLocal())
+ {
+ _out << "Ice.LocalObject";
+ }
+ else
+ {
+ _out << "Ice.Object";
+ }
+ _out << ", " << name;
+ if(!p->isLocal())
+ {
+ _out << "Operations_, " << name;
+ }
+ _out << "OperationsNC_";
+ if(!bases.empty())
+ {
+ ClassList::const_iterator q = bases.begin();
+ while(q != bases.end())
+ {
+ _out << ", " << fixId((*q)->scoped());
+ q++;
+ }
+ }
}
else
{
- _out << nl << "public ";
- if(p->isAbstract())
- {
- _out << "abstract ";
- }
- _out << "class " << fixId(name) << " : ";
-
- if(!hasBaseClass)
- {
- if(p->isLocal())
- {
- _out << "Ice.LocalObjectImpl";
- }
- else
- {
- _out << "Ice.ObjectImpl";
- }
- }
- else
- {
- _out << fixId(bases.front()->scoped());
- bases.pop_front();
- }
- if(p->isAbstract())
- {
- if(!p->isLocal())
- {
- _out << ", " << name << "Operations_";
- }
- _out << ", " << name << "OperationsNC_";
- }
- for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
- {
- if((*q)->isAbstract())
- {
- _out << ", " << fixId((*q)->scoped());
- }
- }
+ _out << nl << "public ";
+ if(p->isAbstract())
+ {
+ _out << "abstract ";
+ }
+ _out << "class " << fixId(name) << " : ";
+
+ if(!hasBaseClass)
+ {
+ if(p->isLocal())
+ {
+ _out << "Ice.LocalObjectImpl";
+ }
+ else
+ {
+ _out << "Ice.ObjectImpl";
+ }
+ }
+ else
+ {
+ _out << fixId(bases.front()->scoped());
+ bases.pop_front();
+ }
+ if(p->isAbstract())
+ {
+ if(!p->isLocal())
+ {
+ _out << ", " << name << "Operations_";
+ }
+ _out << ", " << name << "OperationsNC_";
+ }
+ for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
+ {
+ if((*q)->isAbstract())
+ {
+ _out << ", " << fixId((*q)->scoped());
+ }
+ }
}
_out << sb;
@@ -1227,17 +1227,17 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!p->isInterface())
{
if(p->hasDataMembers() && !p->hasOperations())
- {
- _out << sp << nl << "#region Slice data members";
- }
- else if(p->hasDataMembers())
- {
- _out << sp << nl << "#region Slice data members and operations";
- }
- else if(p->hasOperations())
- {
- _out << sp << nl << "#region Slice operations";
- }
+ {
+ _out << sp << nl << "#region Slice data members";
+ }
+ else if(p->hasDataMembers())
+ {
+ _out << sp << nl << "#region Slice data members and operations";
+ }
+ else if(p->hasOperations())
+ {
+ _out << sp << nl << "#region Slice operations";
+ }
}
return true;
@@ -1258,261 +1258,261 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
if(!p->isInterface())
{
if(p->hasDataMembers() && !p->hasOperations())
- {
- _out << sp << nl << "#endregion"; // Slice data members"
- }
- else if(p->hasDataMembers())
- {
- _out << sp << nl << "#endregion"; // Slice data members and operations"
- }
- else if(p->hasOperations())
- {
- _out << sp << nl << "#endregion"; // Slice operations"
- }
-
- if(!allDataMembers.empty())
- {
- _out << sp << nl << "#region Constructors";
-
- _out << sp << nl << "public " << name << spar << epar;
- if(hasBaseClass)
- {
- _out << " : base()";
- }
- _out << sb;
- _out << eb;
-
- _out << sp << nl << "public " << name << spar;
- vector<string> paramDecl;
- for(d = allDataMembers.begin(); d != allDataMembers.end(); ++d)
- {
- string memberName = fixId((*d)->name());
- string memberType = typeToString((*d)->type());
- paramDecl.push_back(memberType + " " + memberName);
- }
- _out << paramDecl << epar;
- if(hasBaseClass && allDataMembers.size() != dataMembers.size())
- {
- _out << " : base" << spar;
- vector<string> baseParamNames;
- DataMemberList baseDataMembers = bases.front()->allDataMembers();
- for(d = baseDataMembers.begin(); d != baseDataMembers.end(); ++d)
- {
- baseParamNames.push_back(fixId((*d)->name()));
- }
- _out << baseParamNames << epar;
- }
- _out << sb;
- vector<string> paramNames;
- for(d = dataMembers.begin(); d != dataMembers.end(); ++d)
- {
- paramNames.push_back(fixId((*d)->name()));
- }
- for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i)
- {
- _out << nl << "this." << *i << " = " << *i << ';';
- }
- _out << eb;
-
- _out << sp << nl << "#endregion"; // Constructors
- }
-
- writeInheritedOperations(p);
+ {
+ _out << sp << nl << "#endregion"; // Slice data members"
+ }
+ else if(p->hasDataMembers())
+ {
+ _out << sp << nl << "#endregion"; // Slice data members and operations"
+ }
+ else if(p->hasOperations())
+ {
+ _out << sp << nl << "#endregion"; // Slice operations"
+ }
+
+ if(!allDataMembers.empty())
+ {
+ _out << sp << nl << "#region Constructors";
+
+ _out << sp << nl << "public " << name << spar << epar;
+ if(hasBaseClass)
+ {
+ _out << " : base()";
+ }
+ _out << sb;
+ _out << eb;
+
+ _out << sp << nl << "public " << name << spar;
+ vector<string> paramDecl;
+ for(d = allDataMembers.begin(); d != allDataMembers.end(); ++d)
+ {
+ string memberName = fixId((*d)->name());
+ string memberType = typeToString((*d)->type());
+ paramDecl.push_back(memberType + " " + memberName);
+ }
+ _out << paramDecl << epar;
+ if(hasBaseClass && allDataMembers.size() != dataMembers.size())
+ {
+ _out << " : base" << spar;
+ vector<string> baseParamNames;
+ DataMemberList baseDataMembers = bases.front()->allDataMembers();
+ for(d = baseDataMembers.begin(); d != baseDataMembers.end(); ++d)
+ {
+ baseParamNames.push_back(fixId((*d)->name()));
+ }
+ _out << baseParamNames << epar;
+ }
+ _out << sb;
+ vector<string> paramNames;
+ for(d = dataMembers.begin(); d != dataMembers.end(); ++d)
+ {
+ paramNames.push_back(fixId((*d)->name()));
+ }
+ for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i)
+ {
+ _out << nl << "this." << *i << " = " << *i << ';';
+ }
+ _out << eb;
+
+ _out << sp << nl << "#endregion"; // Constructors
+ }
+
+ writeInheritedOperations(p);
}
if(!p->isInterface() && !p->isLocal())
{
- writeDispatch(p);
-
- DataMemberList members = p->dataMembers();
-
- _out << sp << nl << "#region Marshaling support";
-
- _out << sp << nl << "public override void write__(IceInternal.BasicStream os__)";
- _out << sb;
- _out << nl << "os__.writeTypeId(ice_staticId());";
- _out << nl << "os__.startWriteSlice();";
- for(d = members.begin(); d != members.end(); ++d)
- {
- writeMarshalUnmarshalCode(_out, (*d)->type(),
- fixId((*d)->name(), DotNet::ICloneable, true),
- true, false, false);
- }
- _out << nl << "os__.endWriteSlice();";
- _out << nl << "base.write__(os__);";
- _out << eb;
-
- if(allClassMembers.size() != 0)
- {
- _out << sp << nl << "public sealed ";
- if(hasBaseClass && bases.front()->declaration()->usesClasses())
- {
- _out << "new ";
- }
- _out << "class Patcher__ : IceInternal.Patcher";
- _out << sb;
- _out << sp << nl << "internal Patcher__(Ice.ObjectImpl instance";
- if(allClassMembers.size() > 1)
- {
- _out << ", int member";
- }
- _out << ")";
- _out << sb;
- _out << nl << "_instance = (" << name << ")instance;";
- if(allClassMembers.size() > 1)
- {
- _out << nl << "_member = member;";
- }
- _out << eb;
-
- _out << sp << nl << "public override void patch(Ice.Object v)";
- _out << sb;
- _out << nl << "try";
- _out << sb;
- if(allClassMembers.size() > 1)
- {
- _out << nl << "switch(_member)";
- _out << sb;
- }
- int memberCount = 0;
- for(d = allClassMembers.begin(); d != allClassMembers.end(); ++d)
- {
- if(allClassMembers.size() > 1)
- {
- _out.dec();
- _out << nl << "case " << memberCount << ":";
- _out.inc();
- }
- string memberName = fixId((*d)->name(), DotNet::ICloneable, true);
- string memberType = typeToString((*d)->type());
- _out << nl << "type_ = typeof(" << memberType << ");";
- _out << nl << "_instance." << memberName << " = (" << memberType << ")v;";
- _out << nl << "_typeId = \"" << (*d)->type()->typeId() << "\";";
- if(allClassMembers.size() > 1)
- {
- _out << nl << "break;";
- }
- memberCount++;
- }
- if(allClassMembers.size() > 1)
- {
- _out << eb;
- }
- _out << eb;
- _out << nl << "catch(System.InvalidCastException)";
- _out << sb;
- _out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
- _out << nl << "_e.type = v.ice_id();";
- _out << nl << "_e.expectedType = _typeId;";
- _out << nl << "throw _e;";
- _out << eb;
- _out << eb;
-
- _out << sp << nl << "private " << name << " _instance;";
- if(allClassMembers.size() > 1)
- {
- _out << nl << "private int _member;";
- }
- _out << nl << "private string _typeId;";
- _out << eb;
- }
-
- _out << sp << nl << "public override void read__(IceInternal.BasicStream is__, bool rid__)";
- _out << sb;
- _out << nl << "if(rid__)";
- _out << sb;
- _out << nl << "/* string myId = */ is__.readTypeId();";
- _out << eb;
- _out << nl << "is__.startReadSlice();";
- int 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)->name(), DotNet::ICloneable, true),
- false, false, false, patchParams.str());
- }
- _out << nl << "is__.endReadSlice();";
- _out << nl << "base.read__(is__, true);";
- _out << eb;
-
- //
- // Write streaming API.
- //
- if(_stream)
- {
- _out << sp << nl << "public override void write__(Ice.OutputStream outS__)";
- _out << sb;
- _out << nl << "outS__.writeTypeId(ice_staticId());";
- _out << nl << "outS__.startSlice();";
- for(d = members.begin(); d != members.end(); ++d)
- {
- writeMarshalUnmarshalCode(_out, (*d)->type(),
- fixId((*d)->name(), DotNet::ICloneable, true),
- true, true, false);
- }
- _out << nl << "outS__.endSlice();";
- _out << nl << "base.write__(outS__);";
- _out << eb;
-
- _out << sp << nl << "public override void read__(Ice.InputStream inS__, bool rid__)";
- _out << sb;
- _out << nl << "if(rid__)";
- _out << sb;
- _out << nl << "/* string myId = */ inS__.readTypeId();";
- _out << eb;
- _out << nl << "inS__.startSlice();";
- 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)->name(), DotNet::ICloneable, true),
- false, true, false, patchParams.str());
- }
- _out << nl << "inS__.endSlice();";
- _out << nl << "base.read__(inS__, true);";
- _out << eb;
- }
- else
- {
- //
- // Emit placeholder functions to catch errors.
- //
+ writeDispatch(p);
+
+ DataMemberList members = p->dataMembers();
+
+ _out << sp << nl << "#region Marshaling support";
+
+ _out << sp << nl << "public override void write__(IceInternal.BasicStream os__)";
+ _out << sb;
+ _out << nl << "os__.writeTypeId(ice_staticId());";
+ _out << nl << "os__.startWriteSlice();";
+ for(d = members.begin(); d != members.end(); ++d)
+ {
+ writeMarshalUnmarshalCode(_out, (*d)->type(),
+ fixId((*d)->name(), DotNet::ICloneable, true),
+ true, false, false);
+ }
+ _out << nl << "os__.endWriteSlice();";
+ _out << nl << "base.write__(os__);";
+ _out << eb;
+
+ if(allClassMembers.size() != 0)
+ {
+ _out << sp << nl << "public sealed ";
+ if(hasBaseClass && bases.front()->declaration()->usesClasses())
+ {
+ _out << "new ";
+ }
+ _out << "class Patcher__ : IceInternal.Patcher";
+ _out << sb;
+ _out << sp << nl << "internal Patcher__(Ice.ObjectImpl instance";
+ if(allClassMembers.size() > 1)
+ {
+ _out << ", int member";
+ }
+ _out << ")";
+ _out << sb;
+ _out << nl << "_instance = (" << name << ")instance;";
+ if(allClassMembers.size() > 1)
+ {
+ _out << nl << "_member = member;";
+ }
+ _out << eb;
+
+ _out << sp << nl << "public override void patch(Ice.Object v)";
+ _out << sb;
+ _out << nl << "try";
+ _out << sb;
+ if(allClassMembers.size() > 1)
+ {
+ _out << nl << "switch(_member)";
+ _out << sb;
+ }
+ int memberCount = 0;
+ for(d = allClassMembers.begin(); d != allClassMembers.end(); ++d)
+ {
+ if(allClassMembers.size() > 1)
+ {
+ _out.dec();
+ _out << nl << "case " << memberCount << ":";
+ _out.inc();
+ }
+ string memberName = fixId((*d)->name(), DotNet::ICloneable, true);
+ string memberType = typeToString((*d)->type());
+ _out << nl << "type_ = typeof(" << memberType << ");";
+ _out << nl << "_instance." << memberName << " = (" << memberType << ")v;";
+ _out << nl << "_typeId = \"" << (*d)->type()->typeId() << "\";";
+ if(allClassMembers.size() > 1)
+ {
+ _out << nl << "break;";
+ }
+ memberCount++;
+ }
+ if(allClassMembers.size() > 1)
+ {
+ _out << eb;
+ }
+ _out << eb;
+ _out << nl << "catch(System.InvalidCastException)";
+ _out << sb;
+ _out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
+ _out << nl << "_e.type = v.ice_id();";
+ _out << nl << "_e.expectedType = _typeId;";
+ _out << nl << "throw _e;";
+ _out << eb;
+ _out << eb;
+
+ _out << sp << nl << "private " << name << " _instance;";
+ if(allClassMembers.size() > 1)
+ {
+ _out << nl << "private int _member;";
+ }
+ _out << nl << "private string _typeId;";
+ _out << eb;
+ }
+
+ _out << sp << nl << "public override void read__(IceInternal.BasicStream is__, bool rid__)";
+ _out << sb;
+ _out << nl << "if(rid__)";
+ _out << sb;
+ _out << nl << "/* string myId = */ is__.readTypeId();";
+ _out << eb;
+ _out << nl << "is__.startReadSlice();";
+ int 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)->name(), DotNet::ICloneable, true),
+ false, false, false, patchParams.str());
+ }
+ _out << nl << "is__.endReadSlice();";
+ _out << nl << "base.read__(is__, true);";
+ _out << eb;
+
+ //
+ // Write streaming API.
+ //
+ if(_stream)
+ {
+ _out << sp << nl << "public override void write__(Ice.OutputStream outS__)";
+ _out << sb;
+ _out << nl << "outS__.writeTypeId(ice_staticId());";
+ _out << nl << "outS__.startSlice();";
+ for(d = members.begin(); d != members.end(); ++d)
+ {
+ writeMarshalUnmarshalCode(_out, (*d)->type(),
+ fixId((*d)->name(), DotNet::ICloneable, true),
+ true, true, false);
+ }
+ _out << nl << "outS__.endSlice();";
+ _out << nl << "base.write__(outS__);";
+ _out << eb;
+
+ _out << sp << nl << "public override void read__(Ice.InputStream inS__, bool rid__)";
+ _out << sb;
+ _out << nl << "if(rid__)";
+ _out << sb;
+ _out << nl << "/* string myId = */ inS__.readTypeId();";
+ _out << eb;
+ _out << nl << "inS__.startSlice();";
+ 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)->name(), DotNet::ICloneable, true),
+ false, true, false, patchParams.str());
+ }
+ _out << nl << "inS__.endSlice();";
+ _out << nl << "base.read__(inS__, true);";
+ _out << eb;
+ }
+ else
+ {
+ //
+ // Emit placeholder functions to catch errors.
+ //
string scoped = p->scoped();
- _out << sp << nl << "public override void write__(Ice.OutputStream outS__)";
- _out << sb;
- _out << nl << "Ice.MarshalException ex = new Ice.MarshalException();";
- _out << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\";";
- _out << nl << "throw ex;";
- _out << eb;
+ _out << sp << nl << "public override void write__(Ice.OutputStream outS__)";
+ _out << sb;
+ _out << nl << "Ice.MarshalException ex = new Ice.MarshalException();";
+ _out << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\";";
+ _out << nl << "throw ex;";
+ _out << eb;
- _out << sp << nl << "public override void read__(Ice.InputStream inS__, bool rid__)";
- _out << sb;
- _out << nl << "Ice.MarshalException ex = new Ice.MarshalException();";
- _out << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\";";
- _out << nl << "throw ex;";
- _out << eb;
- }
+ _out << sp << nl << "public override void read__(Ice.InputStream inS__, bool rid__)";
+ _out << sb;
+ _out << nl << "Ice.MarshalException ex = new Ice.MarshalException();";
+ _out << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\";";
+ _out << nl << "throw ex;";
+ _out << eb;
+ }
- _out << sp << nl << "#endregion"; // Marshalling support
+ _out << sp << nl << "#endregion"; // Marshalling support
}
_out << eb;
@@ -1539,17 +1539,17 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p)
if(!amd)
{
- params = getParams(p);
- args = getArgs(p);
- name = fixId(name, DotNet::ICloneable, true);
- retS = typeToString(p->returnType());
+ params = getParams(p);
+ args = getArgs(p);
+ name = fixId(name, DotNet::ICloneable, true);
+ retS = typeToString(p->returnType());
}
else
{
- params = getParamsAsync(p, true);
- args = getArgsAsync(p);
- retS = "void";
- name = name + "_async";
+ params = getParamsAsync(p, true);
+ args = getArgsAsync(p);
+ retS = "void";
+ name = name + "_async";
}
_out << sp;
@@ -1566,20 +1566,20 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p)
}
else
{
- _out << sb;
- _out << nl;
- if(!amd && p->returnType())
- {
- _out << "return ";
- }
- _out << name << spar << args << "Ice.ObjectImpl.defaultCurrent" << epar << ';';
- _out << eb;
+ _out << sb;
+ _out << nl;
+ if(!amd && p->returnType())
+ {
+ _out << "return ";
+ }
+ _out << name << spar << args << "Ice.ObjectImpl.defaultCurrent" << epar << ';';
+ _out << eb;
}
if(!isLocal)
{
- _out << nl << "public abstract " << retS << " " << name
- << spar << params << "Ice.Current current__" << epar << ';';
+ _out << nl << "public abstract " << retS << " " << name
+ << spar << params << "Ice.Current current__" << epar << ';';
}
}
@@ -1879,13 +1879,13 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
_out << sb;
if(!isValue)
{
- _out << nl << "if((object)InnerList[i] != null)";
- _out << sb;
+ _out << nl << "if((object)InnerList[i] != null)";
+ _out << sb;
}
_out << nl << "hash = 5 * hash + InnerList[i].GetHashCode();";
if(!isValue)
{
- _out << eb;
+ _out << eb;
}
_out << eb;
_out << nl << "return hash;";
@@ -1909,15 +1909,15 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
_out << sb;
if(!isValue)
{
- _out << nl << "if(InnerList[i__] == null)";
- _out << sb;
- _out << nl << "if(((" << name << ")other)[i__] != null)";
- _out << sb;
- _out << nl << "return false;";
- _out << eb;
- _out << eb;
- _out << nl << "else";
- _out << sb;
+ _out << nl << "if(InnerList[i__] == null)";
+ _out << sb;
+ _out << nl << "if(((" << name << ")other)[i__] != null)";
+ _out << sb;
+ _out << nl << "return false;";
+ _out << eb;
+ _out << eb;
+ _out << nl << "else";
+ _out << sb;
}
_out << nl << "if(!((" << s << ")(InnerList[i__])).Equals(((" << name << ")other)[i__]))";
_out << sb;
@@ -1974,7 +1974,7 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
if(!p->dataMembers().empty())
{
- _out << sp << nl << "#region Slice data members";
+ _out << sp << nl << "#region Slice data members";
}
return true;
@@ -1991,7 +1991,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
if(!dataMembers.empty())
{
- _out << sp << nl << "#endregion"; // Slice data members
+ _out << sp << nl << "#endregion"; // Slice data members
}
_out << sp << nl << "#region Constructors";
@@ -2024,17 +2024,17 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
string memberName = fixId((*q)->name(), DotNet::ApplicationException);
- bool isValue = isValueType((*q)->type());
- if(!isValue)
- {
- _out << nl << "if((object)" << memberName << " != null)";
- _out << sb;
- }
- _out << nl << "h__ = 5 * h__ + " << memberName << ".GetHashCode();";
- if(!isValue)
- {
- _out << eb;
- }
+ bool isValue = isValueType((*q)->type());
+ if(!isValue)
+ {
+ _out << nl << "if((object)" << memberName << " != null)";
+ _out << sb;
+ }
+ _out << nl << "h__ = 5 * h__ + " << memberName << ".GetHashCode();";
+ if(!isValue)
+ {
+ _out << eb;
+ }
}
_out << nl << "return h__;";
_out << eb;
@@ -2056,27 +2056,27 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
string memberName = fixId((*q)->name(), DotNet::ApplicationException);
- bool isValue = isValueType((*q)->type());
- if(!isValue)
- {
- _out << nl << "if(" << memberName << " == null)";
- _out << sb;
- _out << nl << "if(((" << name << ")other__)." << memberName << " != null)";
- _out << sb;
- _out << nl << "return false;";
- _out << eb;
- _out << eb;
- _out << nl << "else";
- _out << sb;
- }
- _out << nl << "if(!" << memberName << ".Equals(((" << name << ")other__)." << memberName << "))";
- _out << sb;
- _out << nl << "return false;";
- _out << eb;
- if(!isValue)
- {
- _out << eb;
- }
+ bool isValue = isValueType((*q)->type());
+ if(!isValue)
+ {
+ _out << nl << "if(" << memberName << " == null)";
+ _out << sb;
+ _out << nl << "if(((" << name << ")other__)." << memberName << " != null)";
+ _out << sb;
+ _out << nl << "return false;";
+ _out << eb;
+ _out << eb;
+ _out << nl << "else";
+ _out << sb;
+ }
+ _out << nl << "if(!" << memberName << ".Equals(((" << name << ")other__)." << memberName << "))";
+ _out << sb;
+ _out << nl << "return false;";
+ _out << eb;
+ if(!isValue)
+ {
+ _out << eb;
+ }
}
_out << nl << "return true;";
_out << eb;
@@ -2107,206 +2107,206 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
_out << sp << nl << "public override void write__(IceInternal.BasicStream os__)";
_out << sb;
- _out << nl << "os__.writeString(\"" << scoped << "\");";
- _out << nl << "os__.startWriteSlice();";
+ _out << nl << "os__.writeString(\"" << scoped << "\");";
+ _out << nl << "os__.startWriteSlice();";
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
writeMarshalUnmarshalCode(_out, (*q)->type(),
- fixId((*q)->name(), DotNet::ApplicationException),
- true, false, false);
+ fixId((*q)->name(), DotNet::ApplicationException),
+ true, false, false);
}
- _out << nl << "os__.endWriteSlice();";
+ _out << nl << "os__.endWriteSlice();";
if(base)
{
_out << nl << "base.write__(os__);";
}
_out << eb;
- DataMemberList allClassMembers = p->allClassDataMembers();
- if(allClassMembers.size() != 0)
- {
- _out << sp << nl << "public sealed ";
- if(base && base->usesClasses())
- {
- _out << "new ";
- }
- _out << "class Patcher__ : IceInternal.Patcher";
- _out << sb;
- _out << sp << nl << "internal Patcher__(Ice.Exception instance";
- if(allClassMembers.size() > 1)
- {
- _out << ", int member";
- }
- _out << ")";
- _out << sb;
- _out << nl << "_instance = (" << name << ")instance;";
- if(allClassMembers.size() > 1)
- {
- _out << nl << "_member = member;";
- }
- _out << eb;
-
- _out << sp << nl << "public override void patch(Ice.Object v)";
- _out << sb;
- _out << nl << "try";
- _out << sb;
- if(allClassMembers.size() > 1)
- {
- _out << nl << "switch(_member)";
- _out << sb;
- }
- int memberCount = 0;
- for(q = allClassMembers.begin(); q != allClassMembers.end(); ++q)
- {
- if(allClassMembers.size() > 1)
- {
- _out.dec();
- _out << nl << "case " << memberCount << ":";
- _out.inc();
- }
- string memberName = fixId((*q)->name(), DotNet::ApplicationException);
- string memberType = typeToString((*q)->type());
- _out << nl << "type_ = typeof(" << memberType << ");";
- _out << nl << "_instance." << memberName << " = (" << memberType << ")v;";
- _out << nl << "_typeId = \"" << (*q)->type()->typeId() << "\";";
- if(allClassMembers.size() > 1)
- {
- _out << nl << "break;";
- }
- memberCount++;
- }
- if(allClassMembers.size() > 1)
- {
- _out << eb;
- }
- _out << eb;
- _out << nl << "catch(System.InvalidCastException)";
- _out << sb;
- _out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
- _out << nl << "_e.type = v.ice_id();";
- _out << nl << "_e.expectedType = _typeId;";
- _out << nl << "throw _e;";
- _out << eb;
- _out << eb;
-
- _out << sp << nl << "private " << name << " _instance;";
- if(allClassMembers.size() > 1)
- {
- _out << nl << "private int _member;";
- }
- _out << nl << "private string _typeId;";
- _out << eb;
- }
+ DataMemberList allClassMembers = p->allClassDataMembers();
+ if(allClassMembers.size() != 0)
+ {
+ _out << sp << nl << "public sealed ";
+ if(base && base->usesClasses())
+ {
+ _out << "new ";
+ }
+ _out << "class Patcher__ : IceInternal.Patcher";
+ _out << sb;
+ _out << sp << nl << "internal Patcher__(Ice.Exception instance";
+ if(allClassMembers.size() > 1)
+ {
+ _out << ", int member";
+ }
+ _out << ")";
+ _out << sb;
+ _out << nl << "_instance = (" << name << ")instance;";
+ if(allClassMembers.size() > 1)
+ {
+ _out << nl << "_member = member;";
+ }
+ _out << eb;
+
+ _out << sp << nl << "public override void patch(Ice.Object v)";
+ _out << sb;
+ _out << nl << "try";
+ _out << sb;
+ if(allClassMembers.size() > 1)
+ {
+ _out << nl << "switch(_member)";
+ _out << sb;
+ }
+ int memberCount = 0;
+ for(q = allClassMembers.begin(); q != allClassMembers.end(); ++q)
+ {
+ if(allClassMembers.size() > 1)
+ {
+ _out.dec();
+ _out << nl << "case " << memberCount << ":";
+ _out.inc();
+ }
+ string memberName = fixId((*q)->name(), DotNet::ApplicationException);
+ string memberType = typeToString((*q)->type());
+ _out << nl << "type_ = typeof(" << memberType << ");";
+ _out << nl << "_instance." << memberName << " = (" << memberType << ")v;";
+ _out << nl << "_typeId = \"" << (*q)->type()->typeId() << "\";";
+ if(allClassMembers.size() > 1)
+ {
+ _out << nl << "break;";
+ }
+ memberCount++;
+ }
+ if(allClassMembers.size() > 1)
+ {
+ _out << eb;
+ }
+ _out << eb;
+ _out << nl << "catch(System.InvalidCastException)";
+ _out << sb;
+ _out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
+ _out << nl << "_e.type = v.ice_id();";
+ _out << nl << "_e.expectedType = _typeId;";
+ _out << nl << "throw _e;";
+ _out << eb;
+ _out << eb;
+
+ _out << sp << nl << "private " << name << " _instance;";
+ if(allClassMembers.size() > 1)
+ {
+ _out << nl << "private int _member;";
+ }
+ _out << nl << "private string _typeId;";
+ _out << eb;
+ }
_out << sp << nl << "public override void read__(IceInternal.BasicStream is__, bool rid__)";
_out << sb;
- _out << nl << "if(rid__)";
- _out << sb;
- _out << nl << "/* string myId = */ is__.readString();";
- _out << eb;
- _out << nl << "is__.startReadSlice();";
- DataMemberList classMembers = p->classDataMembers();
- int classMemberCount = static_cast<int>(allClassMembers.size() - classMembers.size());
+ _out << nl << "if(rid__)";
+ _out << sb;
+ _out << nl << "/* string myId = */ is__.readString();";
+ _out << eb;
+ _out << nl << "is__.startReadSlice();";
+ DataMemberList classMembers = p->classDataMembers();
+ int 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++;
- }
- }
+ 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::ApplicationException),
- false, false, false, patchParams.str());
+ fixId((*q)->name(), DotNet::ApplicationException),
+ false, false, false, patchParams.str());
}
- _out << nl << "is__.endReadSlice();";
+ _out << nl << "is__.endReadSlice();";
if(base)
{
_out << nl << "base.read__(is__, true);";
}
_out << eb;
- if(_stream)
- {
- _out << sp << nl << "public override void write__(Ice.OutputStream outS__)";
- _out << sb;
- _out << nl << "outS__.writeString(\"" << scoped << "\");";
- _out << nl << "outS__.startSlice();";
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeMarshalUnmarshalCode(_out, (*q)->type(),
- fixId((*q)->name(), DotNet::ApplicationException),
- true, true, false);
- }
- _out << nl << "outS__.endSlice();";
- if(base)
- {
- _out << nl << "base.write__(outS__);";
- }
- _out << eb;
-
- _out << sp << nl << "public override void read__(Ice.InputStream inS__, bool rid__)";
- _out << sb;
- _out << nl << "if(rid__)";
- _out << sb;
- _out << nl << "/* string myId = */ inS__.readString();";
- _out << eb;
- _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::ApplicationException),
- false, true, false, patchParams.str());
- }
- _out << nl << "inS__.endSlice();";
- if(base)
- {
- _out << nl << "base.read__(inS__, true);";
- }
- _out << eb;
- }
- else
- {
- //
- // Emit placeholder functions to catch errors.
- //
- _out << sp << nl << "public override void write__(Ice.OutputStream outS__)";
- _out << sb;
- _out << nl << "Ice.MarshalException ex = new Ice.MarshalException();";
- _out << nl << "ex.reason = \"exception " << scoped.substr(2) << " was not generated with stream support\";";
- _out << nl << "throw ex;";
- _out << eb;
-
- _out << sp << nl << "public override void read__(Ice.InputStream inS__, bool rid__)";
- _out << sb;
- _out << nl << "Ice.MarshalException ex = new Ice.MarshalException();";
- _out << nl << "ex.reason = \"exception " << scoped.substr(2) << " was not generated with stream support\";";
- _out << nl << "throw ex;";
- _out << eb;
- }
-
- if(!base || base && !base->usesClasses())
- {
- _out << sp << nl << "public override bool usesClasses__()";
- _out << sb;
- _out << nl << "return true;";
- _out << eb;
- }
+ if(_stream)
+ {
+ _out << sp << nl << "public override void write__(Ice.OutputStream outS__)";
+ _out << sb;
+ _out << nl << "outS__.writeString(\"" << scoped << "\");";
+ _out << nl << "outS__.startSlice();";
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeMarshalUnmarshalCode(_out, (*q)->type(),
+ fixId((*q)->name(), DotNet::ApplicationException),
+ true, true, false);
+ }
+ _out << nl << "outS__.endSlice();";
+ if(base)
+ {
+ _out << nl << "base.write__(outS__);";
+ }
+ _out << eb;
+
+ _out << sp << nl << "public override void read__(Ice.InputStream inS__, bool rid__)";
+ _out << sb;
+ _out << nl << "if(rid__)";
+ _out << sb;
+ _out << nl << "/* string myId = */ inS__.readString();";
+ _out << eb;
+ _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::ApplicationException),
+ false, true, false, patchParams.str());
+ }
+ _out << nl << "inS__.endSlice();";
+ if(base)
+ {
+ _out << nl << "base.read__(inS__, true);";
+ }
+ _out << eb;
+ }
+ else
+ {
+ //
+ // Emit placeholder functions to catch errors.
+ //
+ _out << sp << nl << "public override void write__(Ice.OutputStream outS__)";
+ _out << sb;
+ _out << nl << "Ice.MarshalException ex = new Ice.MarshalException();";
+ _out << nl << "ex.reason = \"exception " << scoped.substr(2) << " was not generated with stream support\";";
+ _out << nl << "throw ex;";
+ _out << eb;
+
+ _out << sp << nl << "public override void read__(Ice.InputStream inS__, bool rid__)";
+ _out << sb;
+ _out << nl << "Ice.MarshalException ex = new Ice.MarshalException();";
+ _out << nl << "ex.reason = \"exception " << scoped.substr(2) << " was not generated with stream support\";";
+ _out << nl << "throw ex;";
+ _out << eb;
+ }
+
+ if(!base || base && !base->usesClasses())
+ {
+ _out << sp << nl << "public override bool usesClasses__()";
+ _out << sb;
+ _out << nl << "return true;";
+ _out << eb;
+ }
_out << sp << nl << "#endregion"; // Marshalling support
}
@@ -2322,21 +2322,21 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p)
if(!p->isLocal() && _stream)
{
_out << sp << nl << "public sealed class " << p->name() << "Helper";
- _out << sb;
+ _out << sb;
- _out << sp << nl << "public static void write(Ice.OutputStream outS__, " << name << " v__)";
- _out << sb;
- _out << nl << "v__.ice_write(outS__);";
- _out << eb;
+ _out << sp << nl << "public static void write(Ice.OutputStream outS__, " << name << " v__)";
+ _out << sb;
+ _out << nl << "v__.ice_write(outS__);";
+ _out << eb;
- _out << sp << nl << "public static " << name << " read(Ice.InputStream inS__)";
- _out << sb;
- _out << nl << name << " v__ = new " << name << "();";
- _out << nl << "v__.ice_read(inS__);";
- _out << nl << "return v__;";
- _out << eb;
+ _out << sp << nl << "public static " << name << " read(Ice.InputStream inS__)";
+ _out << sb;
+ _out << nl << name << " v__ = new " << name << "();";
+ _out << nl << "v__.ice_read(inS__);";
+ _out << nl << "return v__;";
+ _out << eb;
- _out << eb;
+ _out << eb;
}
_out << sp;
@@ -2346,11 +2346,11 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p)
emitAttributes(p);
if(isValueType(p))
{
- _out << nl << "public struct " << name;
+ _out << nl << "public struct " << name;
}
else
{
- _out << nl << "public class " << name << " : _System.ICloneable";
+ _out << nl << "public class " << name << " : _System.ICloneable";
}
_out << sb;
@@ -2376,9 +2376,9 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
if(isClass)
{
_out << "s";
- _out << sp << nl << "public " << name << "()";
- _out << sb;
- _out << eb;
+ _out << sp << nl << "public " << name << "()";
+ _out << sb;
+ _out << eb;
}
_out << sp << nl << "public " << name << spar;
@@ -2387,15 +2387,15 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
string memberName = fixId((*q)->name());
- string memberType = typeToString((*q)->type());
- paramDecl.push_back(memberType + " " + memberName);
- paramNames.push_back(memberName);
+ string memberType = typeToString((*q)->type());
+ paramDecl.push_back(memberType + " " + memberName);
+ paramNames.push_back(memberName);
}
_out << paramDecl << epar;
_out << sb;
for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i)
{
- _out << nl << "this." << *i << " = " << *i << ';';
+ _out << nl << "this." << *i << " = " << *i << ';';
}
_out << eb;
@@ -2403,14 +2403,14 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
if(isClass)
{
- _out << sp << nl << "#region ICloneable members";
+ _out << sp << nl << "#region ICloneable members";
- _out << sp << nl << "public object Clone()";
- _out << sb;
- _out << nl << "return MemberwiseClone();";
- _out << eb;
+ _out << sp << nl << "public object Clone()";
+ _out << sb;
+ _out << nl << "return MemberwiseClone();";
+ _out << eb;
- _out << sp << nl << "#endregion"; // ICloneable members
+ _out << sp << nl << "#endregion"; // ICloneable members
}
_out << sp << nl << "#region Object members";
@@ -2421,17 +2421,17 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
- bool isValue = isValueType((*q)->type());
- if(!isValue)
- {
- _out << nl << "if(" << memberName << " != null)";
- _out << sb;
- }
- _out << nl << "h__ = 5 * h__ + " << memberName << ".GetHashCode();";
- if(!isValue)
- {
- _out << eb;
- }
+ bool isValue = isValueType((*q)->type());
+ if(!isValue)
+ {
+ _out << nl << "if(" << memberName << " != null)";
+ _out << sb;
+ }
+ _out << nl << "h__ = 5 * h__ + " << memberName << ".GetHashCode();";
+ if(!isValue)
+ {
+ _out << eb;
+ }
}
_out << nl << "return h__;";
_out << eb;
@@ -2440,22 +2440,22 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
_out << sb;
if(isClass)
{
- _out << nl << "if(object.ReferenceEquals(this, other__))";
- _out << sb;
- _out << nl << "return true;";
- _out << eb;
+ _out << nl << "if(object.ReferenceEquals(this, other__))";
+ _out << sb;
+ _out << nl << "return true;";
+ _out << eb;
}
if(isClass)
{
- _out << nl << "if(other__ == null)";
- _out << sb;
- _out << nl << "return false;";
- _out << eb;
+ _out << nl << "if(other__ == null)";
+ _out << sb;
+ _out << nl << "return false;";
+ _out << eb;
_out << nl << "if(GetType() != other__.GetType())";
}
else
{
- _out << nl << "if(!(other__ is " << name << "))";
+ _out << nl << "if(!(other__ is " << name << "))";
}
_out << sb;
_out << nl << "return false;";
@@ -2466,31 +2466,31 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
}
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
- if(!isValueType((*q)->type()))
- {
- _out << nl << "if(" << memberName << " == null)";
- _out << sb;
- _out << nl << "if(o__." << memberName << " != null)";
- _out << sb;
- _out << nl << "return false;";
- _out << eb;
- _out << eb;
- _out << nl << "else";
- _out << sb;
- _out << nl << "if(!" << memberName << ".Equals(o__." << memberName << "))";
- _out << sb;
- _out << nl << "return false;";
- _out << eb;
- _out << eb;
- }
- else
- {
- _out << nl << "if(!" << memberName << ".Equals(o__." << memberName << "))";
- _out << sb;
- _out << nl << "return false;";
- _out << eb;
- }
+ string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
+ if(!isValueType((*q)->type()))
+ {
+ _out << nl << "if(" << memberName << " == null)";
+ _out << sb;
+ _out << nl << "if(o__." << memberName << " != null)";
+ _out << sb;
+ _out << nl << "return false;";
+ _out << eb;
+ _out << eb;
+ _out << nl << "else";
+ _out << sb;
+ _out << nl << "if(!" << memberName << ".Equals(o__." << memberName << "))";
+ _out << sb;
+ _out << nl << "return false;";
+ _out << eb;
+ _out << eb;
+ }
+ else
+ {
+ _out << nl << "if(!" << memberName << ".Equals(o__." << memberName << "))";
+ _out << sb;
+ _out << nl << "return false;";
+ _out << eb;
+ }
}
_out << nl << "return true;";
_out << eb;
@@ -2517,140 +2517,140 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
_out << sp << nl << "public void write__(IceInternal.BasicStream os__)";
_out << sb;
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeMarshalUnmarshalCode(_out, (*q)->type(),
- fixId((*q)->name(), isClass ? DotNet::ICloneable : 0),
- true, false, false);
- }
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeMarshalUnmarshalCode(_out, (*q)->type(),
+ fixId((*q)->name(), isClass ? DotNet::ICloneable : 0),
+ true, false, false);
+ }
_out << eb;
- if(isClass && classMembers.size() != 0)
- {
- _out << sp << nl << "public sealed class Patcher__ : IceInternal.Patcher";
- _out << sb;
- _out << sp << nl << "internal Patcher__(" << name << " instance";
- if(classMembers.size() > 1)
- {
- _out << ", int member";
- }
- _out << ")";
- _out << sb;
- _out << nl << "_instance = instance;";
- if(classMembers.size() > 1)
- {
- _out << nl << "_member = member;";
- }
- _out << eb;
-
- _out << sp << nl << "public override void patch(Ice.Object v)";
- _out << sb;
- _out << nl << "try";
- _out << sb;
- if(classMembers.size() > 1)
- {
- _out << nl << "switch(_member)";
- _out << sb;
- }
- int memberCount = 0;
- for(q = classMembers.begin(); q != classMembers.end(); ++q)
- {
- if(classMembers.size() > 1)
- {
- _out.dec();
- _out << nl << "case " << memberCount << ":";
- _out.inc();
- }
- string memberType = typeToString((*q)->type());
- string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
- _out << nl << "type_ = typeof(" << memberType << ");";
- _out << nl << "_instance." << memberName << " = (" << memberType << ")v;";
- _out << nl << "_typeId = \"" << (*q)->type()->typeId() << "\";";
- if(classMembers.size() > 1)
- {
- _out << nl << "break;";
- }
- memberCount++;
- }
- if(classMembers.size() > 1)
- {
- _out << eb;
- }
- _out << eb;
- _out << nl << "catch(System.InvalidCastException)";
- _out << sb;
- _out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
- _out << nl << "_e.type = v.ice_id();";
- _out << nl << "_e.expectedType = _typeId;";
- _out << nl << "throw _e;";
- _out << eb;
- _out << eb;
-
- _out << sp << nl << "private " << name;
- _out << " _instance;";
- if(classMembers.size() > 1)
- {
- _out << nl << "private int _member;";
- }
- _out << nl << "private string _typeId;";
- _out << eb;
- }
+ if(isClass && classMembers.size() != 0)
+ {
+ _out << sp << nl << "public sealed class Patcher__ : IceInternal.Patcher";
+ _out << sb;
+ _out << sp << nl << "internal Patcher__(" << name << " instance";
+ if(classMembers.size() > 1)
+ {
+ _out << ", int member";
+ }
+ _out << ")";
+ _out << sb;
+ _out << nl << "_instance = instance;";
+ if(classMembers.size() > 1)
+ {
+ _out << nl << "_member = member;";
+ }
+ _out << eb;
+
+ _out << sp << nl << "public override void patch(Ice.Object v)";
+ _out << sb;
+ _out << nl << "try";
+ _out << sb;
+ if(classMembers.size() > 1)
+ {
+ _out << nl << "switch(_member)";
+ _out << sb;
+ }
+ int memberCount = 0;
+ for(q = classMembers.begin(); q != classMembers.end(); ++q)
+ {
+ if(classMembers.size() > 1)
+ {
+ _out.dec();
+ _out << nl << "case " << memberCount << ":";
+ _out.inc();
+ }
+ string memberType = typeToString((*q)->type());
+ string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
+ _out << nl << "type_ = typeof(" << memberType << ");";
+ _out << nl << "_instance." << memberName << " = (" << memberType << ")v;";
+ _out << nl << "_typeId = \"" << (*q)->type()->typeId() << "\";";
+ if(classMembers.size() > 1)
+ {
+ _out << nl << "break;";
+ }
+ memberCount++;
+ }
+ if(classMembers.size() > 1)
+ {
+ _out << eb;
+ }
+ _out << eb;
+ _out << nl << "catch(System.InvalidCastException)";
+ _out << sb;
+ _out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
+ _out << nl << "_e.type = v.ice_id();";
+ _out << nl << "_e.expectedType = _typeId;";
+ _out << nl << "throw _e;";
+ _out << eb;
+ _out << eb;
+
+ _out << sp << nl << "private " << name;
+ _out << " _instance;";
+ if(classMembers.size() > 1)
+ {
+ _out << nl << "private int _member;";
+ }
+ _out << nl << "private string _typeId;";
+ _out << eb;
+ }
_out << sp << nl << "public void read__(IceInternal.BasicStream is__)";
_out << sb;
- int classMemberCount = 0;
+ int classMemberCount = 0;
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)
- {
- patchParams << ", " << classMemberCount++;
- }
- }
+ ostringstream patchParams;
+ patchParams << "this";
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast((*q)->type());
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*q)->type()))
+ {
+ if(classMembers.size() > 1)
+ {
+ patchParams << ", " << classMemberCount++;
+ }
+ }
writeMarshalUnmarshalCode(_out, (*q)->type(),
- fixId((*q)->name(), isClass ? DotNet::ICloneable : 0 ),
- false, false, false, patchParams.str());
+ fixId((*q)->name(), isClass ? DotNet::ICloneable : 0 ),
+ false, false, false, patchParams.str());
}
_out << eb;
- if(_stream)
- {
- _out << sp << nl << "public void ice_write(Ice.OutputStream outS__)";
- _out << sb;
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeMarshalUnmarshalCode(_out, (*q)->type(),
- fixId((*q)->name(), isClass ? DotNet::ICloneable : 0),
- true, true, false);
- }
- _out << eb;
-
- _out << sp << nl << "public void ice_read(Ice.InputStream inS__)";
- _out << sb;
- classMemberCount = 0;
- 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)
- {
- patchParams << ", " << classMemberCount++;
- }
- }
- writeMarshalUnmarshalCode(_out, (*q)->type(),
- fixId((*q)->name(), isClass ? DotNet::ICloneable : 0 ),
- false, true, false, patchParams.str());
- }
- _out << eb;
- }
+ if(_stream)
+ {
+ _out << sp << nl << "public void ice_write(Ice.OutputStream outS__)";
+ _out << sb;
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeMarshalUnmarshalCode(_out, (*q)->type(),
+ fixId((*q)->name(), isClass ? DotNet::ICloneable : 0),
+ true, true, false);
+ }
+ _out << eb;
+
+ _out << sp << nl << "public void ice_read(Ice.InputStream inS__)";
+ _out << sb;
+ classMemberCount = 0;
+ 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)
+ {
+ patchParams << ", " << classMemberCount++;
+ }
+ }
+ writeMarshalUnmarshalCode(_out, (*q)->type(),
+ fixId((*q)->name(), isClass ? DotNet::ICloneable : 0 ),
+ false, true, false, patchParams.str());
+ }
+ _out << eb;
+ }
_out << sp << nl << "#endregion"; // Marshalling support
}
@@ -2806,13 +2806,13 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
_out << nl << "hash = 5 * hash + e.Key.GetHashCode();";
if(!valueIsValue)
{
- _out << nl << "if(e.Value != null)";
- _out << sb;
+ _out << nl << "if(e.Value != null)";
+ _out << sb;
}
_out << nl << "hash = 5 * hash + e.Value.GetHashCode();";
if(!valueIsValue)
{
- _out << eb;
+ _out << eb;
}
_out << eb;
_out << nl << "return hash;";
@@ -2849,22 +2849,22 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
bool valueIsArray = seq && !seq->hasMetaData("clr:collection");
if(valueIsArray)
{
- _out << nl << vs << "[] vlhs__ = new " << toArrayAlloc(vs + "[]", "Count") << ';';
+ _out << nl << vs << "[] vlhs__ = new " << toArrayAlloc(vs + "[]", "Count") << ';';
}
else
{
- _out << nl << vs << "[] vlhs__ = new " << vs << "[Count];";
+ _out << nl << vs << "[] vlhs__ = new " << vs << "[Count];";
}
_out << nl << "Values.CopyTo(vlhs__, 0);";
_out << nl << "_System.Array.Sort(vlhs__);";
string vrhsCount = "((" + name + ")other).Count";
if(valueIsArray)
{
- _out << nl << vs << "[] vrhs__ = new " << toArrayAlloc(vs + "[]", vrhsCount) << ';';
+ _out << nl << vs << "[] vrhs__ = new " << toArrayAlloc(vs + "[]", vrhsCount) << ';';
}
else
{
- _out << nl << vs << "[] vrhs__ = new " << vs << '[' << vrhsCount << "];";
+ _out << nl << vs << "[] vrhs__ = new " << vs << '[' << vrhsCount << "];";
}
_out << nl << "((" << name << ")other).Values.CopyTo(vrhs__, 0);";
_out << nl << "_System.Array.Sort(vrhs__);";
@@ -2872,24 +2872,24 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
_out << sb;
if(!valueIsValue)
{
- _out << nl << "if(vlhs__[i] == null)";
- _out << sb;
- _out << nl << "if(vrhs__[i] != null)";
- _out << sb;
- _out << nl << "return false;";
- _out << eb;
- _out << eb;
- _out << nl << "else if(!vlhs__[i].Equals(vrhs__[i]))";
- _out << sb;
- _out << nl << "return false;";
- _out << eb;
+ _out << nl << "if(vlhs__[i] == null)";
+ _out << sb;
+ _out << nl << "if(vrhs__[i] != null)";
+ _out << sb;
+ _out << nl << "return false;";
+ _out << eb;
+ _out << eb;
+ _out << nl << "else if(!vlhs__[i].Equals(vrhs__[i]))";
+ _out << sb;
+ _out << nl << "return false;";
+ _out << eb;
}
else
{
- _out << nl << "if(!vlhs__[i].Equals(vrhs__[i]))";
- _out << sb;
- _out << nl << "return false;";
- _out << eb;
+ _out << nl << "if(!vlhs__[i].Equals(vrhs__[i]))";
+ _out << sb;
+ _out << nl << "return false;";
+ _out << eb;
}
_out << eb;
_out << nl << "return true;";
@@ -2931,29 +2931,29 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
while(en != enumerators.end())
{
_out << nl << fixId((*en)->name());
- if(++en != enumerators.end())
- {
- _out << ',';
- }
+ if(++en != enumerators.end())
+ {
+ _out << ',';
+ }
}
_out << eb;
if(_stream)
{
- _out << sp << nl << "public sealed class " << name << "Helper";
- _out << sb;
+ _out << sp << nl << "public sealed class " << name << "Helper";
+ _out << sb;
- _out << sp << nl << "public static void write(Ice.OutputStream outS__, " << scoped << " v__)";
- _out << sb;
- writeMarshalUnmarshalCode(_out, p, "v__", true, true, false);
- _out << eb;
+ _out << sp << nl << "public static void write(Ice.OutputStream outS__, " << scoped << " v__)";
+ _out << sb;
+ writeMarshalUnmarshalCode(_out, p, "v__", true, true, false);
+ _out << eb;
- _out << sp << nl << "public static " << scoped << " read(Ice.InputStream inS__)";
- _out << sb;
- _out << nl << scoped << " v__;";
- writeMarshalUnmarshalCode(_out, p, "v__", false, true, false);
- _out << nl << "return v__;";
- _out << eb;
+ _out << sp << nl << "public static " << scoped << " read(Ice.InputStream inS__)";
+ _out << sb;
+ _out << nl << scoped << " v__;";
+ writeMarshalUnmarshalCode(_out, p, "v__", false, true, false);
+ _out << nl << "return v__;";
+ _out << eb;
_out << eb;
}
@@ -2971,59 +2971,59 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
BuiltinPtr bp = BuiltinPtr::dynamicCast(p->type());
if(bp && bp->kind() == Builtin::KindString)
{
- //
- // Expand strings into the basic source character set. We can't use isalpha() and the like
- // here because they are sensitive to the current locale.
- //
- static const string basicSourceChars = "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789"
- "_{}[]#()<>%:;.?*+-/^&|~!=,\\\"' ";
- static const set<char> charSet(basicSourceChars.begin(), basicSourceChars.end());
-
- _out << "\""; // Opening "
-
- const string val = p->value();
- for(string::const_iterator c = val.begin(); c != val.end(); ++c)
- {
- if(charSet.find(*c) == charSet.end())
- {
- unsigned char uc = *c; // char may be signed, so make it positive
- ostringstream s;
- s << "\\u"; // Print as unicode if not in basic source character set
- s << hex;
- s.width(4);
- s.fill('0');
- s << static_cast<unsigned>(uc);
- _out << s.str();
- }
- else
- {
- _out << *c; // Print normally if in basic source character set
- }
- }
-
- _out << "\""; // Closing "
+ //
+ // Expand strings into the basic source character set. We can't use isalpha() and the like
+ // here because they are sensitive to the current locale.
+ //
+ static const string basicSourceChars = "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789"
+ "_{}[]#()<>%:;.?*+-/^&|~!=,\\\"' ";
+ static const set<char> charSet(basicSourceChars.begin(), basicSourceChars.end());
+
+ _out << "\""; // Opening "
+
+ const string val = p->value();
+ for(string::const_iterator c = val.begin(); c != val.end(); ++c)
+ {
+ if(charSet.find(*c) == charSet.end())
+ {
+ unsigned char uc = *c; // char may be signed, so make it positive
+ ostringstream s;
+ s << "\\u"; // Print as unicode if not in basic source character set
+ s << hex;
+ s.width(4);
+ s.fill('0');
+ s << static_cast<unsigned>(uc);
+ _out << s.str();
+ }
+ else
+ {
+ _out << *c; // Print normally if in basic source character set
+ }
+ }
+
+ _out << "\""; // Closing "
}
else if(bp && bp->kind() == Builtin::KindLong)
{
- _out << p->value() << "L";
+ _out << p->value() << "L";
}
else if(bp && bp->kind() == Builtin::KindFloat)
{
- _out << p->value() << "F";
+ _out << p->value() << "F";
}
else
{
- EnumPtr ep = EnumPtr::dynamicCast(p->type());
- if(ep)
- {
- _out << typeToString(p->type()) << "." << fixId(p->value());
- }
- else
- {
- _out << p->value();
- }
+ EnumPtr ep = EnumPtr::dynamicCast(p->type());
+ if(ep)
+ {
+ _out << typeToString(p->type()) << "." << fixId(p->value());
+ }
+ else
+ {
+ _out << p->value();
+ }
}
_out << ";";
_out << eb;
@@ -3041,14 +3041,14 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
if(StructPtr::dynamicCast(cont))
{
isValue = isValueType(StructPtr::dynamicCast(cont));
- if(!isValue || cont->hasMetaData("clr:class"))
- {
- baseTypes = DotNet::ICloneable;
- }
- if(cont->hasMetaData("clr:property"))
- {
- propertyMapping = true;
- }
+ if(!isValue || cont->hasMetaData("clr:class"))
+ {
+ baseTypes = DotNet::ICloneable;
+ }
+ if(cont->hasMetaData("clr:property"))
+ {
+ propertyMapping = true;
+ }
}
else if(ExceptionPtr::dynamicCast(cont))
{
@@ -3056,12 +3056,12 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
}
else if(ClassDefPtr::dynamicCast(cont))
{
- baseTypes = DotNet::ICloneable;
- isClass = true;
- if(cont->hasMetaData("clr:property"))
- {
- propertyMapping = true;
- }
+ baseTypes = DotNet::ICloneable;
+ isClass = true;
+ if(cont->hasMetaData("clr:property"))
+ {
+ propertyMapping = true;
+ }
}
_out << sp;
@@ -3075,7 +3075,7 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
string dataMemberName = propertyName;
if(propertyMapping)
{
- dataMemberName += "_prop";
+ dataMemberName += "_prop";
}
_out << nl << (propertyMapping ? "private" : "public") << ' ' << type << ' ' << dataMemberName << ';';
@@ -3087,7 +3087,7 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
_out << nl << "public";
if(!isValue)
{
- _out << " virtual";
+ _out << " virtual";
}
_out << ' ' << type << ' ' << propertyName;
_out << sb;
@@ -3112,7 +3112,7 @@ Slice::Gen::ProxyVisitor::visitModuleStart(const ModulePtr& p)
{
if(!p->hasNonLocalClassDecls())
{
- return false;
+ return false;
}
_out << sp << nl << "namespace " << fixId(p->name());
@@ -3131,7 +3131,7 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
{
if(p->isLocal())
{
- return false;
+ return false;
}
string name = p->name();
@@ -3144,15 +3144,15 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
}
else
{
- ClassList::const_iterator q = bases.begin();
- while(q != bases.end())
- {
- _out << fixId((*q)->scoped() + "Prx");
- if(++q != bases.end())
- {
- _out << ", ";
- }
- }
+ ClassList::const_iterator q = bases.begin();
+ while(q != bases.end())
+ {
+ _out << fixId((*q)->scoped() + "Prx");
+ if(++q != bases.end())
+ {
+ _out << ", ";
+ }
+ }
}
_out << sb;
@@ -3178,11 +3178,11 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
string deprecateMetadata, deprecateReason;
if(p->findMetaData("deprecate", deprecateMetadata) || cl->findMetaData("deprecate", deprecateMetadata))
{
- deprecateReason = "This operation has been deprecated.";
- if(deprecateMetadata.find("deprecate:") == 0 && deprecateMetadata.size() > 10)
- {
- deprecateReason = deprecateMetadata.substr(10);
- }
+ deprecateReason = "This operation has been deprecated.";
+ if(deprecateMetadata.find("deprecate:") == 0 && deprecateMetadata.size() > 10)
+ {
+ deprecateReason = deprecateMetadata.substr(10);
+ }
}
//
@@ -3191,13 +3191,13 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
//
if(!deprecateReason.empty())
{
- _out << nl << "[System.Obsolete(\"" << deprecateReason << "\")]";
+ _out << nl << "[System.Obsolete(\"" << deprecateReason << "\")]";
}
_out << nl << typeToString(p->returnType()) << " " << name << spar << params << epar << ';';
if(!deprecateReason.empty())
{
- _out << nl << "[System.Obsolete(\"" << deprecateReason << "\")]";
+ _out << nl << "[System.Obsolete(\"" << deprecateReason << "\")]";
}
_out << nl << typeToString(p->returnType()) << " " << name
<< spar << params << "Ice.Context context__" << epar << ';';
@@ -3206,21 +3206,21 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
{
vector<string> paramsAMI = getParamsAsync(p, false);
- //
- // Write two versions of the operation - with and without a
- // context parameter.
- //
- _out << sp;
- if(!deprecateReason.empty())
- {
- _out << nl << "[System.Obsolete(\"" << deprecateReason << "\")]";
- }
- _out << nl << "void " << p->name() << "_async" << spar << paramsAMI << epar << ';';
- if(!deprecateReason.empty())
- {
- _out << nl << "[System.Obsolete(\"" << deprecateReason << "\")]";
- }
- _out << nl << "void " << p->name() << "_async" << spar << paramsAMI << "Ice.Context ctx__" << epar << ';';
+ //
+ // Write two versions of the operation - with and without a
+ // context parameter.
+ //
+ _out << sp;
+ if(!deprecateReason.empty())
+ {
+ _out << nl << "[System.Obsolete(\"" << deprecateReason << "\")]";
+ }
+ _out << nl << "void " << p->name() << "_async" << spar << paramsAMI << epar << ';';
+ if(!deprecateReason.empty())
+ {
+ _out << nl << "[System.Obsolete(\"" << deprecateReason << "\")]";
+ }
+ _out << nl << "void " << p->name() << "_async" << spar << paramsAMI << "Ice.Context ctx__" << epar << ';';
}
}
@@ -3256,12 +3256,12 @@ Slice::Gen::OpsVisitor::visitClassDefStart(const ClassDefPtr& p)
//
if(!p->isAbstract())
{
- return false;
+ return false;
}
if(!p->isLocal())
{
- writeOperations(p, false);
+ writeOperations(p, false);
}
writeOperations(p, true);
@@ -3284,30 +3284,30 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent)
if((bases.size() == 1 && bases.front()->isAbstract()) || bases.size() > 1)
{
_out << " : ";
- ClassList::const_iterator q = bases.begin();
- bool first = true;
- while(q != bases.end())
- {
- if((*q)->isAbstract())
- {
- if(!first)
- {
- _out << ", ";
- }
- else
- {
- first = false;
- }
- string s = (*q)->scoped();
- s += "Operations";
- if(noCurrent)
- {
- s += "NC";
- }
- _out << fixId(s) << '_';
- }
- ++q;
- }
+ ClassList::const_iterator q = bases.begin();
+ bool first = true;
+ while(q != bases.end())
+ {
+ if((*q)->isAbstract())
+ {
+ if(!first)
+ {
+ _out << ", ";
+ }
+ else
+ {
+ first = false;
+ }
+ string s = (*q)->scoped();
+ s += "Operations";
+ if(noCurrent)
+ {
+ s += "NC";
+ }
+ _out << fixId(s) << '_';
+ }
+ ++q;
+ }
}
_out << sb;
@@ -3315,35 +3315,35 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent)
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
- OperationPtr op = *r;
- bool amd = !p->isLocal() && (p->hasMetaData("amd") || op->hasMetaData("amd"));
- string opname = amd ? (op->name() + "_async") : fixId(op->name(), DotNet::ICloneable, true);
-
- TypePtr ret;
- vector<string> params;
-
- if(amd)
- {
- params = getParamsAsync(op, true);
- }
- else
- {
- params = getParams(op);
- ret = op->returnType();
- }
-
- _out << sp;
+ OperationPtr op = *r;
+ bool amd = !p->isLocal() && (p->hasMetaData("amd") || op->hasMetaData("amd"));
+ string opname = amd ? (op->name() + "_async") : fixId(op->name(), DotNet::ICloneable, true);
+
+ TypePtr ret;
+ vector<string> params;
+
+ if(amd)
+ {
+ params = getParamsAsync(op, true);
+ }
+ else
+ {
+ params = getParams(op);
+ ret = op->returnType();
+ }
+
+ _out << sp;
emitDeprecate(op, p, _out, "operation");
- emitAttributes(op);
- string retS = typeToString(ret);
- _out << nl << retS << ' ' << opname << spar << params;
- if(!noCurrent && !p->isLocal())
- {
- _out << "Ice.Current current__";
- }
- _out << epar << ';';
+ emitAttributes(op);
+ string retS = typeToString(ret);
+ _out << nl << retS << ' ' << opname << spar << params;
+ if(!noCurrent && !p->isLocal())
+ {
+ _out << "Ice.Current current__";
+ }
+ _out << epar << ';';
}
_out << eb;
@@ -3389,140 +3389,140 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!ops.empty())
{
- _out << sp << nl << "#region Synchronous operations";
+ _out << sp << nl << "#region Synchronous operations";
}
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
OperationPtr op = *r;
- string opName = fixId(op->name(), DotNet::ICloneable, true);
- TypePtr ret = op->returnType();
- string retS = typeToString(ret);
-
- vector<string> params = getParams(op);
- vector<string> args = getArgs(op);
-
- _out << sp << nl << "public " << retS << " " << opName << spar << params << epar;
- _out << sb;
- _out << nl;
- if(ret)
- {
- _out << "return ";
- }
- _out << opName << spar << args << "null" << "false" << epar << ';';
- _out << eb;
-
- _out << sp << nl << "public " << retS << " " << opName << spar << params
- << "Ice.Context context__" << epar;
- _out << sb;
- _out << nl;
- if(ret)
- {
- _out << "return ";
- }
- _out << opName << spar << args << "context__" << "true" << epar << ';';
- _out << eb;
-
- _out << sp << nl << "private " << retS << " " << opName << spar << params
- << "Ice.Context context__" << "bool explicitContext__" << epar;
- _out << sb;
-
- _out << nl << "if(explicitContext__ && context__ == null)";
- _out << sb;
- _out << nl << "context__ = emptyContext_;";
- _out << eb;
- _out << nl << "int cnt__ = 0;";
- _out << nl << "while(true)";
- _out << sb;
- _out << nl << "Ice.ObjectDel_ delBase__ = null;";
- _out << nl << "try";
- _out << sb;
- if(op->returnsData())
- {
- _out << nl << "checkTwowayOnly__(\"" << op->name() << "\");";
- }
- _out << nl << "delBase__ = getDelegate__();";
- _out << nl << name << "Del_ del__ = (" << name << "Del_)delBase__;";
- _out << nl;
- if(ret)
- {
- _out << "return ";
- }
- _out << "del__." << opName << spar << args << "context__" << epar << ';';
- if(!ret)
- {
- _out << nl << "return;";
- }
- _out << eb;
- _out << nl << "catch(IceInternal.LocalExceptionWrapper ex__)";
- _out << sb;
- if(op->mode() == Operation::Idempotent || op->mode() == Operation::Nonmutating)
- {
- _out << nl << "cnt__ = handleExceptionWrapperRelaxed__(delBase__, ex__, cnt__);";
- }
- else
- {
- _out << nl << "handleExceptionWrapper__(delBase__, ex__);";
- }
- _out << eb;
- _out << nl << "catch(Ice.LocalException ex__)";
- _out << sb;
- _out << nl << "cnt__ = handleException__(delBase__, ex__, cnt__);";
- _out << eb;
- _out << eb;
-
- _out << eb;
+ string opName = fixId(op->name(), DotNet::ICloneable, true);
+ TypePtr ret = op->returnType();
+ string retS = typeToString(ret);
+
+ vector<string> params = getParams(op);
+ vector<string> args = getArgs(op);
+
+ _out << sp << nl << "public " << retS << " " << opName << spar << params << epar;
+ _out << sb;
+ _out << nl;
+ if(ret)
+ {
+ _out << "return ";
+ }
+ _out << opName << spar << args << "null" << "false" << epar << ';';
+ _out << eb;
+
+ _out << sp << nl << "public " << retS << " " << opName << spar << params
+ << "Ice.Context context__" << epar;
+ _out << sb;
+ _out << nl;
+ if(ret)
+ {
+ _out << "return ";
+ }
+ _out << opName << spar << args << "context__" << "true" << epar << ';';
+ _out << eb;
+
+ _out << sp << nl << "private " << retS << " " << opName << spar << params
+ << "Ice.Context context__" << "bool explicitContext__" << epar;
+ _out << sb;
+
+ _out << nl << "if(explicitContext__ && context__ == null)";
+ _out << sb;
+ _out << nl << "context__ = emptyContext_;";
+ _out << eb;
+ _out << nl << "int cnt__ = 0;";
+ _out << nl << "while(true)";
+ _out << sb;
+ _out << nl << "Ice.ObjectDel_ delBase__ = null;";
+ _out << nl << "try";
+ _out << sb;
+ if(op->returnsData())
+ {
+ _out << nl << "checkTwowayOnly__(\"" << op->name() << "\");";
+ }
+ _out << nl << "delBase__ = getDelegate__();";
+ _out << nl << name << "Del_ del__ = (" << name << "Del_)delBase__;";
+ _out << nl;
+ if(ret)
+ {
+ _out << "return ";
+ }
+ _out << "del__." << opName << spar << args << "context__" << epar << ';';
+ if(!ret)
+ {
+ _out << nl << "return;";
+ }
+ _out << eb;
+ _out << nl << "catch(IceInternal.LocalExceptionWrapper ex__)";
+ _out << sb;
+ if(op->mode() == Operation::Idempotent || op->mode() == Operation::Nonmutating)
+ {
+ _out << nl << "cnt__ = handleExceptionWrapperRelaxed__(delBase__, ex__, cnt__);";
+ }
+ else
+ {
+ _out << nl << "handleExceptionWrapper__(delBase__, ex__);";
+ }
+ _out << eb;
+ _out << nl << "catch(Ice.LocalException ex__)";
+ _out << sb;
+ _out << nl << "cnt__ = handleException__(delBase__, ex__, cnt__);";
+ _out << eb;
+ _out << eb;
+
+ _out << eb;
}
if(!ops.empty())
{
- _out << sp << nl << "#endregion"; // Synchronous operations
+ _out << sp << nl << "#endregion"; // Synchronous operations
}
bool hasAsyncOps = false;
for(r = ops.begin(); r != ops.end(); ++r)
{
- OperationPtr op = *r;
-
- ClassDefPtr containingClass = ClassDefPtr::dynamicCast(op->container());
- if(containingClass->hasMetaData("ami") || op->hasMetaData("ami"))
- {
- if(!hasAsyncOps)
- {
- _out << sp << nl << "#region Asynchronous operations";
- hasAsyncOps = true;
- }
- vector<string> paramsAMI = getParamsAsync(op, false);
- vector<string> argsAMI = getArgsAsync(op);
-
- string opName = op->name();
-
- //
- // Write two versions of the operation - with and without a
- // context parameter
- //
- _out << sp;
- _out << nl << "public void " << opName << "_async" << spar << paramsAMI << epar;
- _out << sb;
- _out << nl << "cb__.invoke__" << spar << "this" << argsAMI << "null" << epar << ';';
- _out << eb;
-
- _out << nl << "public void " << opName << "_async" << spar << paramsAMI << "Ice.Context ctx__" << epar;
- _out << sb;
- _out << nl << "if(ctx__ == null)";
- _out << sb;
- _out << nl << "ctx__ = emptyContext_;";
- _out << eb;
- _out << nl << "cb__.invoke__" << spar << "this" << argsAMI << "ctx__" << epar << ';';
- _out << eb;
- }
+ OperationPtr op = *r;
+
+ ClassDefPtr containingClass = ClassDefPtr::dynamicCast(op->container());
+ if(containingClass->hasMetaData("ami") || op->hasMetaData("ami"))
+ {
+ if(!hasAsyncOps)
+ {
+ _out << sp << nl << "#region Asynchronous operations";
+ hasAsyncOps = true;
+ }
+ vector<string> paramsAMI = getParamsAsync(op, false);
+ vector<string> argsAMI = getArgsAsync(op);
+
+ string opName = op->name();
+
+ //
+ // Write two versions of the operation - with and without a
+ // context parameter
+ //
+ _out << sp;
+ _out << nl << "public void " << opName << "_async" << spar << paramsAMI << epar;
+ _out << sb;
+ _out << nl << "cb__.invoke__" << spar << "this" << argsAMI << "null" << epar << ';';
+ _out << eb;
+
+ _out << nl << "public void " << opName << "_async" << spar << paramsAMI << "Ice.Context ctx__" << epar;
+ _out << sb;
+ _out << nl << "if(ctx__ == null)";
+ _out << sb;
+ _out << nl << "ctx__ = emptyContext_;";
+ _out << eb;
+ _out << nl << "cb__.invoke__" << spar << "this" << argsAMI << "ctx__" << epar << ';';
+ _out << eb;
+ }
}
if(hasAsyncOps)
{
- _out << sp << nl << "#endregion"; // Asynchronous operations
+ _out << sp << nl << "#endregion"; // Asynchronous operations
}
_out << sp << nl << "#region Checked and unchecked cast operations";
@@ -3665,22 +3665,22 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
if(_stream)
{
- _out << sp << nl << "public static void write(Ice.OutputStream outS__, " << name << "Prx v__)";
- _out << sb;
- _out << nl << "outS__.writeProxy(v__);";
- _out << eb;
+ _out << sp << nl << "public static void write(Ice.OutputStream outS__, " << name << "Prx v__)";
+ _out << sb;
+ _out << nl << "outS__.writeProxy(v__);";
+ _out << eb;
- _out << sp << nl << "public static " << name << "Prx read(Ice.InputStream inS__)";
- _out << sb;
- _out << nl << "Ice.ObjectPrx proxy = inS__.readProxy();";
- _out << nl << "if(proxy != null)";
- _out << sb;
- _out << nl << name << "PrxHelper result = new " << name << "PrxHelper();";
- _out << nl << "result.copyFrom__(proxy);";
- _out << nl << "return result;";
- _out << eb;
- _out << nl << "return null;";
- _out << eb;
+ _out << sp << nl << "public static " << name << "Prx read(Ice.InputStream inS__)";
+ _out << sb;
+ _out << nl << "Ice.ObjectPrx proxy = inS__.readProxy();";
+ _out << nl << "if(proxy != null)";
+ _out << sb;
+ _out << nl << name << "PrxHelper result = new " << name << "PrxHelper();";
+ _out << nl << "result.copyFrom__(proxy);";
+ _out << nl << "return result;";
+ _out << eb;
+ _out << nl << "return null;";
+ _out << eb;
}
_out << sp << nl << "#endregion"; // Marshaling support
@@ -3725,17 +3725,17 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p)
if(_stream)
{
- _out << sp << nl << "public static void write(Ice.OutputStream outS__, " << typeS << " v__)";
- _out << sb;
- writeSequenceMarshalUnmarshalCode(_out, p, "v__", true, true);
- _out << eb;
+ _out << sp << nl << "public static void write(Ice.OutputStream outS__, " << typeS << " v__)";
+ _out << sb;
+ writeSequenceMarshalUnmarshalCode(_out, p, "v__", true, true);
+ _out << eb;
- _out << sp << nl << "public static " << typeS << " read(Ice.InputStream inS__)";
- _out << sb;
- _out << nl << typeS << " v__;";
- writeSequenceMarshalUnmarshalCode(_out, p, "v__", false, true);
- _out << nl << "return v__;";
- _out << eb;
+ _out << sp << nl << "public static " << typeS << " read(Ice.InputStream inS__)";
+ _out << sb;
+ _out << nl << typeS << " v__;";
+ writeSequenceMarshalUnmarshalCode(_out, p, "v__", false, true);
+ _out << nl << "return v__;";
+ _out << eb;
}
_out << eb;
@@ -3785,33 +3785,33 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
bool hasClassValue = (builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(value);
if(hasClassValue)
{
- _out << sp << nl << "public sealed class Patcher__ : IceInternal.Patcher";
- _out << sb;
- _out << sp << nl << "internal Patcher__(" << name << " m, " << keyS << " key)";
- _out << sb;
- _out << nl << "_m = m;";
- _out << nl << "_key = key;";
- _out << eb;
-
- _out << sp << nl << "public override void" << nl << "patch(Ice.Object v)";
- _out << sb;
- _out << nl << "type_ = typeof(" << typeToString(p->valueType()) << ");";
- _out << nl << "try";
- _out << sb;
- _out << nl << "_m[_key] = (" << valueS << ")v;";
- _out << eb;
- _out << nl << "catch(System.InvalidCastException)";
- _out << sb;
- _out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
- _out << nl << "_e.type = v.ice_id();";
- _out << nl << "_e.expectedType = \"" << value->typeId() << "\";";
- _out << nl << "throw _e;";
- _out << eb;
- _out << eb;
-
- _out << sp << nl << "private " << name << " _m;";
- _out << nl << "private " << keyS << " _key;";
- _out << eb;
+ _out << sp << nl << "public sealed class Patcher__ : IceInternal.Patcher";
+ _out << sb;
+ _out << sp << nl << "internal Patcher__(" << name << " m, " << keyS << " key)";
+ _out << sb;
+ _out << nl << "_m = m;";
+ _out << nl << "_key = key;";
+ _out << eb;
+
+ _out << sp << nl << "public override void" << nl << "patch(Ice.Object v)";
+ _out << sb;
+ _out << nl << "type_ = typeof(" << typeToString(p->valueType()) << ");";
+ _out << nl << "try";
+ _out << sb;
+ _out << nl << "_m[_key] = (" << valueS << ")v;";
+ _out << eb;
+ _out << nl << "catch(System.InvalidCastException)";
+ _out << sb;
+ _out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
+ _out << nl << "_e.type = v.ice_id();";
+ _out << nl << "_e.expectedType = \"" << value->typeId() << "\";";
+ _out << nl << "throw _e;";
+ _out << eb;
+ _out << eb;
+
+ _out << sp << nl << "private " << name << " _m;";
+ _out << nl << "private " << keyS << " _key;";
+ _out << eb;
}
_out << sp << nl << "public static " << name << " read(IceInternal.BasicStream is__)";
@@ -3824,12 +3824,12 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
writeMarshalUnmarshalCode(_out, key, "k__", false, false, false);
if(!hasClassValue)
{
- _out << nl << valueS << " v__;";
+ _out << nl << valueS << " v__;";
}
writeMarshalUnmarshalCode(_out, value, "v__", false, false, false, "r__, k__");
if(!hasClassValue)
{
- _out << nl << "r__[k__] = v__;";
+ _out << nl << "r__[k__] = v__;";
}
_out << eb;
_out << nl << "return r__;";
@@ -3837,43 +3837,43 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
if(_stream)
{
- _out << sp << nl << "public static void write(Ice.OutputStream outS__, " << name << " v__)";
- _out << sb;
- _out << nl << "if(v__ == null)";
- _out << sb;
- _out << nl << "outS__.writeSize(0);";
- _out << eb;
- _out << nl << "else";
- _out << sb;
- _out << nl << "outS__.writeSize(v__.Count);";
- _out << nl << "foreach(_System.Collections.DictionaryEntry e__ in v__)";
- _out << sb;
- writeMarshalUnmarshalCode(_out, key, keyArg, true, true, false);
- writeMarshalUnmarshalCode(_out, value, valueArg, true, true, false);
- _out << eb;
- _out << eb;
- _out << eb;
-
- _out << sp << nl << "public static " << name << " read(Ice.InputStream inS__)";
- _out << sb;
- _out << nl << "int sz__ = inS__.readSize();";
- _out << nl << name << " r__ = new " << name << "();";
- _out << nl << "for(int i__ = 0; i__ < sz__; ++i__)";
- _out << sb;
- _out << nl << keyS << " k__;";
- writeMarshalUnmarshalCode(_out, key, "k__", false, true, false);
- if(!hasClassValue)
- {
- _out << nl << valueS << " v__;";
- }
- writeMarshalUnmarshalCode(_out, value, "v__", false, true, false, "r__, k__");
- if(!hasClassValue)
- {
- _out << nl << "r__[k__] = v__;";
- }
- _out << eb;
- _out << nl << "return r__;";
- _out << eb;
+ _out << sp << nl << "public static void write(Ice.OutputStream outS__, " << name << " v__)";
+ _out << sb;
+ _out << nl << "if(v__ == null)";
+ _out << sb;
+ _out << nl << "outS__.writeSize(0);";
+ _out << eb;
+ _out << nl << "else";
+ _out << sb;
+ _out << nl << "outS__.writeSize(v__.Count);";
+ _out << nl << "foreach(_System.Collections.DictionaryEntry e__ in v__)";
+ _out << sb;
+ writeMarshalUnmarshalCode(_out, key, keyArg, true, true, false);
+ writeMarshalUnmarshalCode(_out, value, valueArg, true, true, false);
+ _out << eb;
+ _out << eb;
+ _out << eb;
+
+ _out << sp << nl << "public static " << name << " read(Ice.InputStream inS__)";
+ _out << sb;
+ _out << nl << "int sz__ = inS__.readSize();";
+ _out << nl << name << " r__ = new " << name << "();";
+ _out << nl << "for(int i__ = 0; i__ < sz__; ++i__)";
+ _out << sb;
+ _out << nl << keyS << " k__;";
+ writeMarshalUnmarshalCode(_out, key, "k__", false, true, false);
+ if(!hasClassValue)
+ {
+ _out << nl << valueS << " v__;";
+ }
+ writeMarshalUnmarshalCode(_out, value, "v__", false, true, false, "r__, k__");
+ if(!hasClassValue)
+ {
+ _out << nl << "r__[k__] = v__;";
+ }
+ _out << eb;
+ _out << nl << "return r__;";
+ _out << eb;
}
_out << eb;
@@ -3908,7 +3908,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p)
{
if(p->isLocal())
{
- return false;
+ return false;
}
string name = p->name();
@@ -3917,21 +3917,21 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << sp << nl << "public interface " << name << "Del_ : ";
if(bases.empty())
{
- _out << "Ice.ObjectDel_";
+ _out << "Ice.ObjectDel_";
}
else
{
- ClassList::const_iterator q = bases.begin();
- while(q != bases.end())
- {
- string s = (*q)->scoped();
- s += "Del_";
- _out << fixId(s);
- if(++q != bases.end())
- {
- _out << ", ";
- }
- }
+ ClassList::const_iterator q = bases.begin();
+ while(q != bases.end())
+ {
+ string s = (*q)->scoped();
+ s += "Del_";
+ _out << fixId(s);
+ if(++q != bases.end())
+ {
+ _out << ", ";
+ }
+ }
}
_out << sb;
@@ -3941,13 +3941,13 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p)
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
- OperationPtr op = *r;
- string opName = fixId(op->name(), DotNet::ICloneable, true);
- TypePtr ret = op->returnType();
- string retS = typeToString(ret);
- vector<string> params = getParams(op);
+ OperationPtr op = *r;
+ string opName = fixId(op->name(), DotNet::ICloneable, true);
+ TypePtr ret = op->returnType();
+ string retS = typeToString(ret);
+ vector<string> params = getParams(op);
- _out << sp << nl << retS << ' ' << opName << spar << params << "Ice.Context context__" << epar << ';';
+ _out << sp << nl << retS << ' ' << opName << spar << params << "Ice.Context context__" << epar << ';';
}
return true;
@@ -4002,168 +4002,168 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
- OperationPtr op = *r;
- string opName = fixId(op->name(), DotNet::ICloneable, true);
- TypePtr ret = op->returnType();
- string retS = typeToString(ret);
-
- TypeStringList inParams;
- TypeStringList outParams;
- ParamDeclList paramList = op->parameters();
- for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
- {
- if((*pli)->isOutParam())
- {
- outParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
- }
- else
- {
- inParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
- }
- }
-
- TypeStringList::const_iterator q;
-
- ExceptionList throws = op->throws();
- throws.sort();
- throws.unique();
-
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
+ OperationPtr op = *r;
+ string opName = fixId(op->name(), DotNet::ICloneable, true);
+ TypePtr ret = op->returnType();
+ string retS = typeToString(ret);
+
+ TypeStringList inParams;
+ TypeStringList outParams;
+ ParamDeclList paramList = op->parameters();
+ for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
+ {
+ if((*pli)->isOutParam())
+ {
+ outParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
+ }
+ else
+ {
+ inParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
+ }
+ }
+
+ TypeStringList::const_iterator q;
+
+ ExceptionList throws = op->throws();
+ throws.sort();
+ throws.unique();
+
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
#if defined(__SUNPRO_CC)
- throws.sort(Slice::derivedToBaseCompare);
+ throws.sort(Slice::derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
- vector<string> params = getParams(op);
-
- _out << sp << nl << "public " << retS << ' ' << opName << spar << params << "Ice.Context context__" << epar;
- _out << sb;
-
- _out << nl << "IceInternal.Outgoing og__ = getOutgoing(\"" << op->name() << "\", "
- << sliceModeToIceMode(op->sendMode())
- << ", context__);";
- _out << nl << "try";
- _out << sb;
- if(!inParams.empty())
- {
- _out << nl << "try";
- _out << sb;
- _out << nl << "IceInternal.BasicStream os__ = og__.ostr();";
- for(q = inParams.begin(); q != inParams.end(); ++q)
- {
- writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, false);
- }
- if(op->sendsClasses())
- {
- _out << nl << "os__.writePendingObjects();";
- }
- _out << eb;
- _out << nl << "catch(Ice.LocalException ex__)";
- _out << sb;
- _out << nl << "og__.abort(ex__);";
- _out << eb;
- }
- _out << nl << "bool ok__ = og__.invoke();";
- _out << nl << "try";
- _out << sb;
- _out << nl << "IceInternal.BasicStream is__ = og__.istr();";
- _out << nl << "if(!ok__)";
- _out << sb;
- //
- // The try/catch block is necessary because throwException()
- // can raise UserException.
- //
- _out << nl << "try";
- _out << sb;
- _out << nl << "is__.throwException();";
- _out << eb;
- for(ExceptionList::const_iterator t = throws.begin(); t != throws.end(); ++t)
- {
- _out << nl << "catch(" << fixId((*t)->scoped()) << ')';
- _out << sb;
- _out << nl << "throw;";
- _out << eb;
- }
- _out << nl << "catch(Ice.UserException ex)";
- _out << sb;
- _out << nl << "throw new Ice.UnknownUserException(ex);";
- _out << eb;
- _out << eb;
- for(q = outParams.begin(); q != outParams.end(); ++q)
- {
- writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, false, true, "");
- }
- if(ret)
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
- {
- _out << nl << retS << " ret__;";
- ContainedPtr contained = ContainedPtr::dynamicCast(ret);
- _out << nl << "IceInternal.ParamPatcher ret___PP = new IceInternal.ParamPatcher(typeof("
- << retS << "), \"" << (contained? contained->scoped() : string("::Ice::Object")) << "\");";
- _out << nl << "is__.readObject(ret___PP);";
- }
- else
- {
- _out << nl << retS << " ret__;";
- writeMarshalUnmarshalCode(_out, ret, "ret__", false, false, true, "");
- }
- }
- if(op->returnsClasses())
- {
- _out << nl << "is__.readPendingObjects();";
- for(q = outParams.begin(); q != outParams.end(); ++q)
- {
- string param = fixId(q->second);
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(q->first))
- {
- string type = typeToString(q->first);
- _out << nl << "try";
- _out << sb;
- _out << nl << param << " = (" << type << ")" << param << "_PP.value;";
- _out << eb;
- _out << nl << "catch(System.InvalidCastException)";
- _out << sb;
- _out << nl << "Ice.UnexpectedObjectException ex = new Ice.UnexpectedObjectException();";
- _out << nl << "ex.type = " << param << "_PP.value.ice_id();";
- _out << nl << "ex.expectedType = \"" << q->first->typeId() << "\";";
- _out << nl << "throw ex;";
- _out << eb;
- }
- }
- }
- if(ret)
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
- {
- _out << nl << "try";
- _out << sb;
- _out << nl << "ret__ = (" << retS << ")ret___PP.value;";
- _out << eb;
- _out << nl << "catch(System.InvalidCastException)";
- _out << sb;
- _out << nl << "Ice.UnexpectedObjectException ex = new Ice.UnexpectedObjectException();";
- _out << nl << "ex.type = ret___PP.value.ice_id();";
- _out << nl << "ex.expectedType = \"" << ret->typeId() << "\";";
- _out << nl << "throw ex;";
- _out << eb;
- }
- _out << nl << "return ret__;";
- }
- _out << eb;
- _out << nl << "catch(Ice.LocalException ex__)";
- _out << sb;
- _out << nl << "throw new IceInternal.LocalExceptionWrapper(ex__, false);";
- _out << eb;
+ vector<string> params = getParams(op);
+
+ _out << sp << nl << "public " << retS << ' ' << opName << spar << params << "Ice.Context context__" << epar;
+ _out << sb;
+
+ _out << nl << "IceInternal.Outgoing og__ = getOutgoing(\"" << op->name() << "\", "
+ << sliceModeToIceMode(op->sendMode())
+ << ", context__);";
+ _out << nl << "try";
+ _out << sb;
+ if(!inParams.empty())
+ {
+ _out << nl << "try";
+ _out << sb;
+ _out << nl << "IceInternal.BasicStream os__ = og__.ostr();";
+ for(q = inParams.begin(); q != inParams.end(); ++q)
+ {
+ writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, false);
+ }
+ if(op->sendsClasses())
+ {
+ _out << nl << "os__.writePendingObjects();";
+ }
+ _out << eb;
+ _out << nl << "catch(Ice.LocalException ex__)";
+ _out << sb;
+ _out << nl << "og__.abort(ex__);";
+ _out << eb;
+ }
+ _out << nl << "bool ok__ = og__.invoke();";
+ _out << nl << "try";
+ _out << sb;
+ _out << nl << "IceInternal.BasicStream is__ = og__.istr();";
+ _out << nl << "if(!ok__)";
+ _out << sb;
+ //
+ // The try/catch block is necessary because throwException()
+ // can raise UserException.
+ //
+ _out << nl << "try";
+ _out << sb;
+ _out << nl << "is__.throwException();";
+ _out << eb;
+ for(ExceptionList::const_iterator t = throws.begin(); t != throws.end(); ++t)
+ {
+ _out << nl << "catch(" << fixId((*t)->scoped()) << ')';
+ _out << sb;
+ _out << nl << "throw;";
+ _out << eb;
+ }
+ _out << nl << "catch(Ice.UserException ex)";
+ _out << sb;
+ _out << nl << "throw new Ice.UnknownUserException(ex);";
+ _out << eb;
+ _out << eb;
+ for(q = outParams.begin(); q != outParams.end(); ++q)
+ {
+ writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, false, true, "");
+ }
+ if(ret)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
+ {
+ _out << nl << retS << " ret__;";
+ ContainedPtr contained = ContainedPtr::dynamicCast(ret);
+ _out << nl << "IceInternal.ParamPatcher ret___PP = new IceInternal.ParamPatcher(typeof("
+ << retS << "), \"" << (contained? contained->scoped() : string("::Ice::Object")) << "\");";
+ _out << nl << "is__.readObject(ret___PP);";
+ }
+ else
+ {
+ _out << nl << retS << " ret__;";
+ writeMarshalUnmarshalCode(_out, ret, "ret__", false, false, true, "");
+ }
+ }
+ if(op->returnsClasses())
+ {
+ _out << nl << "is__.readPendingObjects();";
+ for(q = outParams.begin(); q != outParams.end(); ++q)
+ {
+ string param = fixId(q->second);
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(q->first))
+ {
+ string type = typeToString(q->first);
+ _out << nl << "try";
+ _out << sb;
+ _out << nl << param << " = (" << type << ")" << param << "_PP.value;";
+ _out << eb;
+ _out << nl << "catch(System.InvalidCastException)";
+ _out << sb;
+ _out << nl << "Ice.UnexpectedObjectException ex = new Ice.UnexpectedObjectException();";
+ _out << nl << "ex.type = " << param << "_PP.value.ice_id();";
+ _out << nl << "ex.expectedType = \"" << q->first->typeId() << "\";";
+ _out << nl << "throw ex;";
+ _out << eb;
+ }
+ }
+ }
+ if(ret)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
+ {
+ _out << nl << "try";
+ _out << sb;
+ _out << nl << "ret__ = (" << retS << ")ret___PP.value;";
+ _out << eb;
+ _out << nl << "catch(System.InvalidCastException)";
+ _out << sb;
+ _out << nl << "Ice.UnexpectedObjectException ex = new Ice.UnexpectedObjectException();";
+ _out << nl << "ex.type = ret___PP.value.ice_id();";
+ _out << nl << "ex.expectedType = \"" << ret->typeId() << "\";";
+ _out << nl << "throw ex;";
+ _out << eb;
+ }
+ _out << nl << "return ret__;";
+ }
+ _out << eb;
+ _out << nl << "catch(Ice.LocalException ex__)";
+ _out << sb;
+ _out << nl << "throw new IceInternal.LocalExceptionWrapper(ex__, false);";
+ _out << eb;
_out << eb;
_out << nl << "finally";
_out << sb;
@@ -4228,64 +4228,64 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
string opName = fixId(op->name(), DotNet::ICloneable, true);
TypePtr ret = op->returnType();
string retS = typeToString(ret);
- ClassDefPtr containingClass = ClassDefPtr::dynamicCast(op->container());
+ ClassDefPtr containingClass = ClassDefPtr::dynamicCast(op->container());
vector<string> params = getParams(op);
vector<string> args = getArgs(op);
- _out << sp;
+ _out << sp;
_out << nl << "public " << retS << ' ' << opName << spar << params << "Ice.Context context__" << epar;
_out << sb;
- if(containingClass->hasMetaData("amd") || op->hasMetaData("amd"))
- {
- _out << nl << "throw new Ice.CollocationOptimizationException();";
- }
- else
- {
- _out << nl << "Ice.Current current__ = new Ice.Current();";
- _out << nl << "initCurrent__(ref current__, \"" << op->name() << "\", "
- << sliceModeToIceMode(op->sendMode())
- << ", context__);";
- _out << nl << "while(true)";
- _out << sb;
- _out << nl << "IceInternal.Direct direct__ = new IceInternal.Direct(current__);";
- _out << nl << "object servant__ = direct__.servant();";
- _out << nl << "if(servant__ is " << fixId(name) << ")";
- _out << sb;
- _out << nl << "try";
- _out << sb;
- _out << nl;
- if(ret)
- {
- _out << "return ";
- }
- _out << "((" << fixId(containingClass->scoped()) << ")servant__)."
- << opName << spar << args << "current__" << epar << ';';
- if(!ret)
- {
- _out << nl << "return;";
- }
- _out << eb;
- _out << nl << "catch(Ice.LocalException ex__)";
- _out << sb;
- _out << nl << "throw new IceInternal.LocalExceptionWrapper(ex__, false);";
- _out << eb;
- _out << nl << "finally";
- _out << sb;
- _out << nl << "direct__.destroy();";
- _out << eb;
- _out << eb;
- _out << nl << "else";
- _out << sb;
- _out << nl << "direct__.destroy();";
- _out << nl << "Ice.OperationNotExistException opEx__ = new Ice.OperationNotExistException();";
- _out << nl << "opEx__.id = current__.id;";
- _out << nl << "opEx__.facet = current__.facet;";
- _out << nl << "opEx__.operation = current__.operation;";
- _out << nl << "throw opEx__;";
- _out << eb;
- _out << eb;
- }
+ if(containingClass->hasMetaData("amd") || op->hasMetaData("amd"))
+ {
+ _out << nl << "throw new Ice.CollocationOptimizationException();";
+ }
+ else
+ {
+ _out << nl << "Ice.Current current__ = new Ice.Current();";
+ _out << nl << "initCurrent__(ref current__, \"" << op->name() << "\", "
+ << sliceModeToIceMode(op->sendMode())
+ << ", context__);";
+ _out << nl << "while(true)";
+ _out << sb;
+ _out << nl << "IceInternal.Direct direct__ = new IceInternal.Direct(current__);";
+ _out << nl << "object servant__ = direct__.servant();";
+ _out << nl << "if(servant__ is " << fixId(name) << ")";
+ _out << sb;
+ _out << nl << "try";
+ _out << sb;
+ _out << nl;
+ if(ret)
+ {
+ _out << "return ";
+ }
+ _out << "((" << fixId(containingClass->scoped()) << ")servant__)."
+ << opName << spar << args << "current__" << epar << ';';
+ if(!ret)
+ {
+ _out << nl << "return;";
+ }
+ _out << eb;
+ _out << nl << "catch(Ice.LocalException ex__)";
+ _out << sb;
+ _out << nl << "throw new IceInternal.LocalExceptionWrapper(ex__, false);";
+ _out << eb;
+ _out << nl << "finally";
+ _out << sb;
+ _out << nl << "direct__.destroy();";
+ _out << eb;
+ _out << eb;
+ _out << nl << "else";
+ _out << sb;
+ _out << nl << "direct__.destroy();";
+ _out << nl << "Ice.OperationNotExistException opEx__ = new Ice.OperationNotExistException();";
+ _out << nl << "opEx__.id = current__.id;";
+ _out << nl << "opEx__.facet = current__.facet;";
+ _out << nl << "opEx__.operation = current__.operation;";
+ _out << nl << "throw opEx__;";
+ _out << eb;
+ _out << eb;
+ }
_out << eb;
}
@@ -4343,42 +4343,42 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p)
for(OperationList::const_iterator op = ops.begin(); op != ops.end(); ++op)
{
- bool amd = p->hasMetaData("amd") || (*op)->hasMetaData("amd");
-
- string opname = (*op)->name();
- vector<string> params;
- vector<string> args;
- TypePtr ret;
-
- if(amd)
- {
- opname = opname + "_async";
- params = getParamsAsync(*op, true);
- args = getArgsAsync(*op);
- }
- else
- {
- opname = fixId(opname, DotNet::ICloneable, true);
- params = getParams(*op);
- ret = (*op)->returnType();
- args = getArgs(*op);
- }
-
- _out << sp << nl << "public " << typeToString(ret) << " " << opname << spar << params << epar;
- _out << sb << nl;
- if(ret)
- {
- _out << "return ";
- }
- _out << opname << spar << args << "Ice.ObjectImpl.defaultCurrent" << epar << ';';
- _out << eb;
-
- _out << sp << nl << "public abstract " << typeToString(ret) << " " << opname << spar << params;
- if(!p->isLocal())
- {
- _out << "Ice.Current current__";
- }
- _out << epar << ';';
+ bool amd = p->hasMetaData("amd") || (*op)->hasMetaData("amd");
+
+ string opname = (*op)->name();
+ vector<string> params;
+ vector<string> args;
+ TypePtr ret;
+
+ if(amd)
+ {
+ opname = opname + "_async";
+ params = getParamsAsync(*op, true);
+ args = getArgsAsync(*op);
+ }
+ else
+ {
+ opname = fixId(opname, DotNet::ICloneable, true);
+ params = getParams(*op);
+ ret = (*op)->returnType();
+ args = getArgs(*op);
+ }
+
+ _out << sp << nl << "public " << typeToString(ret) << " " << opname << spar << params << epar;
+ _out << sb << nl;
+ if(ret)
+ {
+ _out << "return ";
+ }
+ _out << opname << spar << args << "Ice.ObjectImpl.defaultCurrent" << epar << ';';
+ _out << eb;
+
+ _out << sp << nl << "public abstract " << typeToString(ret) << " " << opname << spar << params;
+ if(!p->isLocal())
+ {
+ _out << "Ice.Current current__";
+ }
+ _out << epar << ';';
}
if(!ops.empty())
@@ -4438,7 +4438,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
if(cl->isLocal())
{
- return;
+ return;
}
string name = p->name();
@@ -4449,266 +4449,266 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
TypePtr ret = p->returnType();
string retS = typeToString(ret);
- TypeStringList inParams;
+ TypeStringList inParams;
TypeStringList outParams;
- ParamDeclList paramList = p->parameters();
- for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
- {
- if((*pli)->isOutParam())
- {
- outParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
- }
- else
- {
- inParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
- }
- }
+ ParamDeclList paramList = p->parameters();
+ for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
+ {
+ if((*pli)->isOutParam())
+ {
+ outParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
+ }
+ else
+ {
+ inParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
+ }
+ }
ExceptionList throws = p->throws();
throws.sort();
throws.unique();
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
#if defined(__SUNPRO_CC)
- throws.sort(Slice::derivedToBaseCompare);
+ throws.sort(Slice::derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
TypeStringList::const_iterator q;
- vector<string> params = getParamsAsyncCB(p);
- vector<string> args = getArgsAsyncCB(p);
-
- vector<string> paramsInvoke = getParamsAsync(p, false);
-
- _out << sp << nl << "public abstract class AMI_" << cl->name() << '_'
- << name << " : IceInternal.OutgoingAsync";
- _out << sb;
- _out << sp;
- _out << nl << "public abstract void ice_response" << spar << params << epar << ';';
-
- _out << sp << nl << "public void invoke__" << spar << "Ice.ObjectPrx prx__"
- << paramsInvoke << "Ice.Context ctx__" << epar;
- _out << sb;
- _out << nl << "try";
- _out << sb;
- _out << nl << "prepare__(prx__, \"" << name << "\", " << sliceModeToIceMode(p->sendMode())
- << ", ctx__);";
- for(q = inParams.begin(); q != inParams.end(); ++q)
- {
- string typeS = typeToString(q->first);
- writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, false);
- }
- if(p->sendsClasses())
- {
- _out << nl << "os__.writePendingObjects();";
- }
- _out << nl << "os__.endWriteEncaps();";
- _out << eb;
- _out << nl << "catch(Ice.LocalException ex__)";
- _out << sb;
- _out << nl << "finished__(ex__);";
- _out << nl << "return;";
- _out << eb;
- _out << nl << "send__();";
- _out << eb;
-
- _out << sp << nl << "protected override void response__(bool ok__)";
- _out << sb;
+ vector<string> params = getParamsAsyncCB(p);
+ vector<string> args = getArgsAsyncCB(p);
+
+ vector<string> paramsInvoke = getParamsAsync(p, false);
+
+ _out << sp << nl << "public abstract class AMI_" << cl->name() << '_'
+ << name << " : IceInternal.OutgoingAsync";
+ _out << sb;
+ _out << sp;
+ _out << nl << "public abstract void ice_response" << spar << params << epar << ';';
+
+ _out << sp << nl << "public void invoke__" << spar << "Ice.ObjectPrx prx__"
+ << paramsInvoke << "Ice.Context ctx__" << epar;
+ _out << sb;
+ _out << nl << "try";
+ _out << sb;
+ _out << nl << "prepare__(prx__, \"" << name << "\", " << sliceModeToIceMode(p->sendMode())
+ << ", ctx__);";
+ for(q = inParams.begin(); q != inParams.end(); ++q)
+ {
+ string typeS = typeToString(q->first);
+ writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, false);
+ }
+ if(p->sendsClasses())
+ {
+ _out << nl << "os__.writePendingObjects();";
+ }
+ _out << nl << "os__.endWriteEncaps();";
+ _out << eb;
+ _out << nl << "catch(Ice.LocalException ex__)";
+ _out << sb;
+ _out << nl << "finished__(ex__);";
+ _out << nl << "return;";
+ _out << eb;
+ _out << nl << "send__();";
+ _out << eb;
+
+ _out << sp << nl << "protected override void response__(bool ok__)";
+ _out << sb;
for(q = outParams.begin(); q != outParams.end(); ++q)
{
- _out << nl << typeToString(q->first) << ' ' << fixId(q->second) << ';';
+ _out << nl << typeToString(q->first) << ' ' << fixId(q->second) << ';';
}
if(ret)
{
- _out << nl << retS << " ret__;";
+ _out << nl << retS << " ret__;";
+ }
+ _out << nl << "try";
+ _out << sb;
+ _out << nl << "if(!ok__)";
+ _out << sb;
+ _out << nl << "try";
+ _out << sb;
+ _out << nl << "is__.throwException();";
+ _out << eb;
+ for(ExceptionList::const_iterator r = throws.begin(); r != throws.end(); ++r)
+ {
+ _out << nl << "catch(" << fixId((*r)->scoped()) << ')';
+ _out << sb;
+ _out << nl << "throw;";
+ _out << eb;
}
- _out << nl << "try";
- _out << sb;
- _out << nl << "if(!ok__)";
+ _out << nl << "catch(Ice.UserException ex)";
_out << sb;
- _out << nl << "try";
- _out << sb;
- _out << nl << "is__.throwException();";
- _out << eb;
- for(ExceptionList::const_iterator r = throws.begin(); r != throws.end(); ++r)
- {
- _out << nl << "catch(" << fixId((*r)->scoped()) << ')';
- _out << sb;
- _out << nl << "throw;";
- _out << eb;
- }
- _out << nl << "catch(Ice.UserException ex)";
- _out << sb;
_out << nl << "throw new Ice.UnknownUserException(ex);";
- _out << eb;
+ _out << eb;
_out << eb;
for(q = outParams.begin(); q != outParams.end(); ++q)
{
- writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, false, true);
+ writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, false, true);
}
if(ret)
{
- writeMarshalUnmarshalCode(_out, ret, "ret__", false, false, true);
- }
- if(p->returnsClasses())
- {
- _out << nl << "is__.readPendingObjects();";
- }
- for(q = outParams.begin(); q != outParams.end(); ++q)
- {
- string param = fixId(q->second);
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(q->first))
- {
- string type = typeToString(q->first);
- _out << nl << param << " = (" << type << ")" << param << "_PP.value;";
- }
- }
- if(ret)
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
- {
- string type = typeToString(ret);
- _out << nl << "ret__ = (" << retS << ")ret___PP.value;";
- }
- }
- _out << eb;
- _out << nl << "catch(Ice.LocalException ex__)";
- _out << sb;
- _out << nl << "finished__(ex__);";
- _out << nl << "return;";
- _out << eb;
- if(!throws.empty())
- {
- _out << nl << "catch(Ice.UserException ex__)";
- _out << sb;
- _out << nl << "ice_exception(ex__);";
- _out << nl << "return;";
- _out << eb;
- }
- _out << nl << "ice_response" << spar << args << epar << ';';
- _out << eb;
- _out << eb;
+ writeMarshalUnmarshalCode(_out, ret, "ret__", false, false, true);
+ }
+ if(p->returnsClasses())
+ {
+ _out << nl << "is__.readPendingObjects();";
+ }
+ for(q = outParams.begin(); q != outParams.end(); ++q)
+ {
+ string param = fixId(q->second);
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(q->first))
+ {
+ string type = typeToString(q->first);
+ _out << nl << param << " = (" << type << ")" << param << "_PP.value;";
+ }
+ }
+ if(ret)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
+ {
+ string type = typeToString(ret);
+ _out << nl << "ret__ = (" << retS << ")ret___PP.value;";
+ }
+ }
+ _out << eb;
+ _out << nl << "catch(Ice.LocalException ex__)";
+ _out << sb;
+ _out << nl << "finished__(ex__);";
+ _out << nl << "return;";
+ _out << eb;
+ if(!throws.empty())
+ {
+ _out << nl << "catch(Ice.UserException ex__)";
+ _out << sb;
+ _out << nl << "ice_exception(ex__);";
+ _out << nl << "return;";
+ _out << eb;
+ }
+ _out << nl << "ice_response" << spar << args << epar << ';';
+ _out << eb;
+ _out << eb;
}
if(cl->hasMetaData("amd") || p->hasMetaData("amd"))
{
- string classNameAMD = "AMD_" + cl->name();
- string classNameAMDI = "_AMD_" + cl->name();
+ string classNameAMD = "AMD_" + cl->name();
+ string classNameAMDI = "_AMD_" + cl->name();
- vector<string> paramsAMD = getParamsAsyncCB(p);
+ vector<string> paramsAMD = getParamsAsyncCB(p);
- _out << sp << nl << "public interface " << classNameAMD << '_' << name;
- _out << sb;
- _out << sp << nl << "void ice_response" << spar << paramsAMD << epar << ';';
- _out << sp << nl << "void ice_exception(_System.Exception ex);";
- _out << eb;
+ _out << sp << nl << "public interface " << classNameAMD << '_' << name;
+ _out << sb;
+ _out << sp << nl << "void ice_response" << spar << paramsAMD << epar << ';';
+ _out << sp << nl << "void ice_exception(_System.Exception ex);";
+ _out << eb;
- TypePtr ret = p->returnType();
-
- TypeStringList outParams;
- ParamDeclList paramList = p->parameters();
- for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
- {
- if((*pli)->isOutParam())
- {
- outParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
- }
- }
-
- ExceptionList throws = p->throws();
- throws.sort();
- throws.unique();
-
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
+ TypePtr ret = p->returnType();
+
+ TypeStringList outParams;
+ ParamDeclList paramList = p->parameters();
+ for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
+ {
+ if((*pli)->isOutParam())
+ {
+ outParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
+ }
+ }
+
+ ExceptionList throws = p->throws();
+ throws.sort();
+ throws.unique();
+
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
#if defined(__SUNPRO_CC)
- throws.sort(Slice::derivedToBaseCompare);
+ throws.sort(Slice::derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
- TypeStringList::const_iterator q;
- _out << sp << nl << "class " << classNameAMDI << '_' << name
- << " : IceInternal.IncomingAsync, " << classNameAMD << '_' << name;
- _out << sb;
-
- _out << sp << nl << "public " << classNameAMDI << '_' << name << "(IceInternal.Incoming inc) : base(inc)";
- _out << sb;
- _out << eb;
-
- _out << sp << nl << "public void ice_response" << spar << paramsAMD << epar;
- _out << sb;
- if(ret || !outParams.empty())
- {
- _out << nl << "try";
- _out << sb;
- _out << nl << "IceInternal.BasicStream os__ = this.os__();";
- for(q = outParams.begin(); q != outParams.end(); ++q)
- {
- string typeS = typeToString(q->first);
- writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, false);
- }
- if(ret)
- {
- string retS = typeToString(ret);
- writeMarshalUnmarshalCode(_out, ret, "ret__", true, false, false);
- }
- if(p->returnsClasses())
- {
- _out << nl << "os__.writePendingObjects();";
- }
- _out << eb;
- _out << nl << "catch(Ice.LocalException ex__)";
- _out << sb;
- _out << nl << "ice_exception(ex__);";
- _out << eb;
- }
- _out << nl << "response__(true);";
- _out << eb;
-
- _out << sp << nl << "public void ice_exception(_System.Exception ex)";
- _out << sb;
- if(throws.empty())
- {
- _out << nl << "exception__(ex);";
- }
- else
- {
- _out << nl << "try";
- _out << sb;
- _out << nl << "throw ex;";
- _out << eb;
- ExceptionList::const_iterator r;
- for(r = throws.begin(); r != throws.end(); ++r)
- {
- string exS = fixId((*r)->scoped());
- _out << nl << "catch(" << exS << " ex__)";
- _out << sb;
- _out << nl << "os__().writeUserException(ex__);";
- _out << nl << "response__(false);";
- _out << eb;
- }
- _out << nl << "catch(_System.Exception ex__)";
- _out << sb;
- _out << nl << "exception__(ex__);";
- _out << eb;
- }
- _out << eb;
-
- _out << eb;
+ TypeStringList::const_iterator q;
+ _out << sp << nl << "class " << classNameAMDI << '_' << name
+ << " : IceInternal.IncomingAsync, " << classNameAMD << '_' << name;
+ _out << sb;
+
+ _out << sp << nl << "public " << classNameAMDI << '_' << name << "(IceInternal.Incoming inc) : base(inc)";
+ _out << sb;
+ _out << eb;
+
+ _out << sp << nl << "public void ice_response" << spar << paramsAMD << epar;
+ _out << sb;
+ if(ret || !outParams.empty())
+ {
+ _out << nl << "try";
+ _out << sb;
+ _out << nl << "IceInternal.BasicStream os__ = this.os__();";
+ for(q = outParams.begin(); q != outParams.end(); ++q)
+ {
+ string typeS = typeToString(q->first);
+ writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, false);
+ }
+ if(ret)
+ {
+ string retS = typeToString(ret);
+ writeMarshalUnmarshalCode(_out, ret, "ret__", true, false, false);
+ }
+ if(p->returnsClasses())
+ {
+ _out << nl << "os__.writePendingObjects();";
+ }
+ _out << eb;
+ _out << nl << "catch(Ice.LocalException ex__)";
+ _out << sb;
+ _out << nl << "ice_exception(ex__);";
+ _out << eb;
+ }
+ _out << nl << "response__(true);";
+ _out << eb;
+
+ _out << sp << nl << "public void ice_exception(_System.Exception ex)";
+ _out << sb;
+ if(throws.empty())
+ {
+ _out << nl << "exception__(ex);";
+ }
+ else
+ {
+ _out << nl << "try";
+ _out << sb;
+ _out << nl << "throw ex;";
+ _out << eb;
+ ExceptionList::const_iterator r;
+ for(r = throws.begin(); r != throws.end(); ++r)
+ {
+ string exS = fixId((*r)->scoped());
+ _out << nl << "catch(" << exS << " ex__)";
+ _out << sb;
+ _out << nl << "os__().writeUserException(ex__);";
+ _out << nl << "response__(false);";
+ _out << eb;
+ }
+ _out << nl << "catch(_System.Exception ex__)";
+ _out << sb;
+ _out << nl << "exception__(ex__);";
+ _out << eb;
+ }
+ _out << eb;
+
+ _out << eb;
}
}
@@ -4755,14 +4755,14 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << sp << nl << "public class " << name << "Tie_ : ";
if(p->isInterface())
{
- if(p->isLocal())
- {
- _out << fixId(name) << ", Ice.TieBase";
- }
- else
- {
- _out << name << "Disp_, Ice.TieBase";
- }
+ if(p->isLocal())
+ {
+ _out << fixId(name) << ", Ice.TieBase";
+ }
+ else
+ {
+ _out << name << "Disp_, Ice.TieBase";
+ }
}
else
{
@@ -4826,14 +4826,14 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
- bool hasAMD = p->hasMetaData("amd") || (*r)->hasMetaData("amd");
+ bool hasAMD = p->hasMetaData("amd") || (*r)->hasMetaData("amd");
string opName = hasAMD ? (*r)->name() + "_async" : fixId((*r)->name(), DotNet::ICloneable, true);
TypePtr ret = (*r)->returnType();
string retS = typeToString(ret);
vector<string> params;
- vector<string> args;
+ vector<string> args;
if(hasAMD)
{
params = getParamsAsync((*r), true);
@@ -4846,11 +4846,11 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
}
_out << sp << nl << "public ";
- if(!p->isInterface() || !p->isLocal())
- {
- _out << "override ";
- }
- _out << (hasAMD ? string("void") : retS) << ' ' << opName << spar << params;
+ if(!p->isInterface() || !p->isLocal())
+ {
+ _out << "override ";
+ }
+ _out << (hasAMD ? string("void") : retS) << ' ' << opName << spar << params;
if(!p->isLocal())
{
_out << "Ice.Current current__";
@@ -4896,19 +4896,19 @@ Slice::Gen::TieVisitor::writeInheritedOperationsWithOpNames(const ClassDefPtr& p
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
- bool hasAMD = p->hasMetaData("amd") || (*r)->hasMetaData("amd");
+ bool hasAMD = p->hasMetaData("amd") || (*r)->hasMetaData("amd");
string opName = hasAMD ? (*r)->name() + "_async" : fixId((*r)->name(), DotNet::ICloneable, true);
- if(opNames.find(opName) != opNames.end())
- {
- continue;
- }
- opNames.insert(opName);
+ if(opNames.find(opName) != opNames.end())
+ {
+ continue;
+ }
+ opNames.insert(opName);
TypePtr ret = (*r)->returnType();
string retS = typeToString(ret);
vector<string> params;
- vector<string> args;
+ vector<string> args;
if(hasAMD)
{
params = getParamsAsync((*r), true);
@@ -4921,11 +4921,11 @@ Slice::Gen::TieVisitor::writeInheritedOperationsWithOpNames(const ClassDefPtr& p
}
_out << sp << nl << "public ";
- if(!p->isInterface() || !p->isLocal())
- {
- _out << "override ";
- }
- _out << (hasAMD ? string("void") : retS) << ' ' << opName << spar << params;
+ if(!p->isInterface() || !p->isLocal())
+ {
+ _out << "override ";
+ }
+ _out << (hasAMD ? string("void") : retS) << ' ' << opName << spar << params;
if(!p->isLocal())
{
_out << "Ice.Current current__";
@@ -4969,96 +4969,96 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment
if(comment)
{
- _out << nl << "// ";
+ _out << nl << "// ";
}
else
{
- _out << sp << nl;
+ _out << sp << nl;
}
- ParamDeclList::const_iterator i;
+ ParamDeclList::const_iterator i;
if(!cl->isLocal() && (cl->hasMetaData("amd") || op->hasMetaData("amd")))
{
- ParamDeclList::const_iterator i;
+ ParamDeclList::const_iterator i;
vector<string> pDecl = getParamsAsync(op, true);
- _out << "public ";
- if(!forTie)
- {
- _out << "override ";
- }
- _out << "void " << opName << "_async" << spar << pDecl << "Ice.Current current__" << epar;
-
- if(comment)
- {
- _out << ';';
- return;
- }
-
- _out << sb;
- if(ret)
- {
- _out << nl << typeToString(ret) << " ret__ = " << writeValue(ret) << ';';
- }
- for(i = params.begin(); i != params.end(); ++i)
- {
- if((*i)->isOutParam())
- {
- string name = fixId((*i)->name());
- TypePtr type = (*i)->type();
- _out << nl << typeToString(type) << ' ' << name << " = " << writeValue(type) << ';';
- }
- }
- _out << nl << "cb__.ice_response" << spar;
- if(ret)
- {
- _out << "ret__";
- }
- for(i = params.begin(); i != params.end(); ++i)
- {
- if((*i)->isOutParam())
- {
- _out << fixId((*i)->name());
- }
- }
- _out << epar << ';';
- _out << eb;
+ _out << "public ";
+ if(!forTie)
+ {
+ _out << "override ";
+ }
+ _out << "void " << opName << "_async" << spar << pDecl << "Ice.Current current__" << epar;
+
+ if(comment)
+ {
+ _out << ';';
+ return;
+ }
+
+ _out << sb;
+ if(ret)
+ {
+ _out << nl << typeToString(ret) << " ret__ = " << writeValue(ret) << ';';
+ }
+ for(i = params.begin(); i != params.end(); ++i)
+ {
+ if((*i)->isOutParam())
+ {
+ string name = fixId((*i)->name());
+ TypePtr type = (*i)->type();
+ _out << nl << typeToString(type) << ' ' << name << " = " << writeValue(type) << ';';
+ }
+ }
+ _out << nl << "cb__.ice_response" << spar;
+ if(ret)
+ {
+ _out << "ret__";
+ }
+ for(i = params.begin(); i != params.end(); ++i)
+ {
+ if((*i)->isOutParam())
+ {
+ _out << fixId((*i)->name());
+ }
+ }
+ _out << epar << ';';
+ _out << eb;
}
else
{
- vector<string> pDecls = getParams(op);
-
- _out << "public ";
- if(!forTie && !cl->isLocal())
- {
- _out << "override ";
- }
- _out << retS << ' ' << fixId(opName, DotNet::ICloneable, true) << spar << pDecls;
- if(!cl->isLocal())
- {
- _out << "Ice.Current current__";
- }
- _out << epar;
- if(comment)
- {
- _out << ';';
- return;
- }
- _out << sb;
- for(ParamDeclList::const_iterator i = params.begin(); i != params.end(); ++i)
- {
- if((*i)->isOutParam())
- {
- string name = fixId((*i)->name());
- TypePtr type = (*i)->type();
- _out << nl << name << " = " << writeValue(type) << ';';
- }
- }
- if(ret)
- {
- _out << nl << "return " << writeValue(ret) << ';';
- }
- _out << eb;
+ vector<string> pDecls = getParams(op);
+
+ _out << "public ";
+ if(!forTie && !cl->isLocal())
+ {
+ _out << "override ";
+ }
+ _out << retS << ' ' << fixId(opName, DotNet::ICloneable, true) << spar << pDecls;
+ if(!cl->isLocal())
+ {
+ _out << "Ice.Current current__";
+ }
+ _out << epar;
+ if(comment)
+ {
+ _out << ';';
+ return;
+ }
+ _out << sb;
+ for(ParamDeclList::const_iterator i = params.begin(); i != params.end(); ++i)
+ {
+ if((*i)->isOutParam())
+ {
+ string name = fixId((*i)->name());
+ TypePtr type = (*i)->type();
+ _out << nl << name << " = " << writeValue(type) << ';';
+ }
+ }
+ if(ret)
+ {
+ _out << nl << "return " << writeValue(ret) << ';';
+ }
+ _out << eb;
}
}
@@ -5070,43 +5070,43 @@ Slice::Gen::BaseImplVisitor::writeValue(const TypePtr& type)
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if(builtin)
{
- switch(builtin->kind())
- {
- case Builtin::KindBool:
- {
- return "false";
- break;
- }
- case Builtin::KindByte:
- case Builtin::KindShort:
- case Builtin::KindInt:
- case Builtin::KindLong:
- {
- return "0";
- break;
- }
- case Builtin::KindFloat:
- {
- return "0.0f";
- break;
- }
- case Builtin::KindDouble:
- {
- return "0.0";
- break;
- }
- default:
- {
- return "null";
- break;
- }
- }
+ switch(builtin->kind())
+ {
+ case Builtin::KindBool:
+ {
+ return "false";
+ break;
+ }
+ case Builtin::KindByte:
+ case Builtin::KindShort:
+ case Builtin::KindInt:
+ case Builtin::KindLong:
+ {
+ return "0";
+ break;
+ }
+ case Builtin::KindFloat:
+ {
+ return "0.0f";
+ break;
+ }
+ case Builtin::KindDouble:
+ {
+ return "0.0";
+ break;
+ }
+ default:
+ {
+ return "null";
+ break;
+ }
+ }
}
EnumPtr en = EnumPtr::dynamicCast(type);
if(en)
{
- return fixId(en->scoped()) + "." + fixId((*en->getEnumerators().begin())->name());
+ return fixId(en->scoped()) + "." + fixId((*en->getEnumerators().begin())->name());
}
StructPtr st = StructPtr::dynamicCast(type);
@@ -5157,13 +5157,13 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
if(p->isInterface())
{
if(p->isLocal())
- {
- _out << " : Ice.LocalObjectImpl, " << fixId(name);
- }
- else
- {
- _out << " : " << name << "Disp_";
- }
+ {
+ _out << " : Ice.LocalObjectImpl, " << fixId(name);
+ }
+ else
+ {
+ _out << " : " << name << "Disp_";
+ }
}
else
{
@@ -5234,15 +5234,15 @@ Slice::Gen::ImplTieVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << sp << nl << "public class " << name << "I : ";
if(inheritImpl)
{
- if(bases.front()->isAbstract())
- {
- _out << bases.front()->name() << 'I';
- }
- else
- {
- _out << fixId(bases.front()->name());
- }
- _out << ", ";
+ if(bases.front()->isAbstract())
+ {
+ _out << bases.front()->name() << 'I';
+ }
+ else
+ {
+ _out << fixId(bases.front()->name());
+ }
+ _out << ", ";
}
_out << name << "Operations";
if(p->isLocal())
diff --git a/cpp/src/slice2cs/Gen.h b/cpp/src/slice2cs/Gen.h
index c14c66202f5..64f4f90d828 100644
--- a/cpp/src/slice2cs/Gen.h
+++ b/cpp/src/slice2cs/Gen.h
@@ -47,10 +47,10 @@ public:
Gen(const std::string&,
const std::string&,
const std::vector<std::string>&,
- const std::string&,
- bool,
- bool,
- bool);
+ const std::string&,
+ bool,
+ bool,
+ bool);
~Gen();
bool operator!() const; // Returns true if there was a constructor error
@@ -78,12 +78,12 @@ private:
UnitVisitor(::IceUtil::Output&, bool);
- virtual bool visitModuleStart(const ModulePtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
private:
- bool _stream;
- bool _globalMetaDataDone;
+ bool _stream;
+ bool _globalMetaDataDone;
};
class TypesVisitor : public CsVisitor
@@ -92,24 +92,24 @@ private:
TypesVisitor(::IceUtil::Output&, bool);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitOperation(const OperationPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
- virtual bool visitExceptionStart(const ExceptionPtr&);
- virtual void visitExceptionEnd(const ExceptionPtr&);
- virtual bool visitStructStart(const StructPtr&);
- virtual void visitStructEnd(const StructPtr&);
- virtual void visitSequence(const SequencePtr&);
- virtual void visitDictionary(const DictionaryPtr&);
- virtual void visitEnum(const EnumPtr&);
- virtual void visitConst(const ConstPtr&);
- virtual void visitDataMember(const DataMemberPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual bool visitExceptionStart(const ExceptionPtr&);
+ virtual void visitExceptionEnd(const ExceptionPtr&);
+ virtual bool visitStructStart(const StructPtr&);
+ virtual void visitStructEnd(const StructPtr&);
+ virtual void visitSequence(const SequencePtr&);
+ virtual void visitDictionary(const DictionaryPtr&);
+ virtual void visitEnum(const EnumPtr&);
+ virtual void visitConst(const ConstPtr&);
+ virtual void visitDataMember(const DataMemberPtr&);
private:
- bool _stream;
+ bool _stream;
};
class ProxyVisitor : public CsVisitor
@@ -118,11 +118,11 @@ private:
ProxyVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
- virtual void visitOperation(const OperationPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
};
class OpsVisitor : public CsVisitor
@@ -131,9 +131,9 @@ private:
OpsVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
private:
void writeOperations(const ClassDefPtr&, bool);
@@ -145,16 +145,16 @@ private:
HelperVisitor(::IceUtil::Output&, bool);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
- virtual void visitSequence(const SequencePtr&);
- virtual void visitDictionary(const DictionaryPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitSequence(const SequencePtr&);
+ virtual void visitDictionary(const DictionaryPtr&);
private:
- bool _stream;
+ bool _stream;
};
class DelegateVisitor : public CsVisitor
@@ -163,10 +163,10 @@ private:
DelegateVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
};
class DelegateMVisitor : public CsVisitor
@@ -175,10 +175,10 @@ private:
DelegateMVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
};
class DelegateDVisitor : public CsVisitor
@@ -187,10 +187,10 @@ private:
DelegateDVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
};
class DispatcherVisitor : public CsVisitor
@@ -199,9 +199,9 @@ private:
DispatcherVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
};
class AsyncVisitor : public CsVisitor
@@ -210,11 +210,11 @@ private:
AsyncVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
- virtual void visitOperation(const OperationPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
};
class TieVisitor : public CsVisitor
@@ -223,15 +223,15 @@ private:
TieVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
private:
- typedef ::std::set< ::std::string> NameSet;
- void writeInheritedOperationsWithOpNames(const ClassDefPtr&, NameSet&);
+ typedef ::std::set< ::std::string> NameSet;
+ void writeInheritedOperationsWithOpNames(const ClassDefPtr&, NameSet&);
};
class BaseImplVisitor : public CsVisitor
@@ -242,11 +242,11 @@ private:
protected:
- void writeOperation(const OperationPtr&, bool, bool);
+ void writeOperation(const OperationPtr&, bool, bool);
private:
- ::std::string writeValue(const TypePtr&);
+ ::std::string writeValue(const TypePtr&);
};
class ImplVisitor : public BaseImplVisitor
@@ -255,10 +255,10 @@ private:
ImplVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
};
class ImplTieVisitor : public BaseImplVisitor
@@ -267,9 +267,9 @@ private:
ImplTieVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
};
};
diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp
index fe5118175a0..a34d32301cb 100644
--- a/cpp/src/slice2cs/Main.cpp
+++ b/cpp/src/slice2cs/Main.cpp
@@ -26,12 +26,12 @@ usage(const char* n)
"-DNAME=DEF Define NAME as DEF.\n"
"-UNAME Remove any definition for NAME.\n"
"-IDIR Put DIR in the include file search path.\n"
- "-E Print preprocessor output on stdout.\n"
+ "-E Print preprocessor output on stdout.\n"
"--output-dir DIR Create files in the directory DIR.\n"
"--tie Generate TIE classes.\n"
"--impl Generate sample implementations.\n"
"--impl-tie Generate sample TIE implementations.\n"
- "--depend Generate Makefile dependencies.\n"
+ "--depend Generate Makefile dependencies.\n"
"-d, --debug Print debug messages.\n"
"--ice Permit `Ice' prefix (for building Ice source code only)\n"
"--checksum Generate checksums for Slice definitions.\n"
@@ -69,20 +69,20 @@ main(int argc, char* argv[])
catch(const IceUtil::BadOptException& e)
{
cerr << argv[0] << ": " << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(argv[0]);
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
string cppArgs;
@@ -90,19 +90,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D" + Preprocessor::addQuotes(*i);
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U" + Preprocessor::addQuotes(*i);
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I" + Preprocessor::addQuotes(*i);
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
@@ -145,80 +145,80 @@ main(int argc, char* argv[])
for(i = args.begin(); i != args.end(); ++i)
{
- if(depend)
- {
- Preprocessor icecpp(argv[0], *i, cppArgs);
- icecpp.printMakefileDependencies(Preprocessor::CSharp);
- }
- else
- {
- Preprocessor icecpp(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp.preprocess(false);
-
- if(cppHandle == 0)
- {
- return EXIT_FAILURE;
- }
- if(preprocess)
- {
- char buf[4096];
- while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
- {
- if(fputs(buf, stdout) == EOF)
- {
- return EXIT_FAILURE;
- }
- }
- if(!icecpp.close())
- {
- return EXIT_FAILURE;
- }
- }
- else
- {
- UnitPtr p = Unit::createUnit(false, false, ice, caseSensitive);
- int parseStatus = p->parse(cppHandle, debug);
-
- if(!icecpp.close())
- {
- p->destroy();
- return EXIT_FAILURE;
- }
-
- if(parseStatus == EXIT_FAILURE)
- {
- status = EXIT_FAILURE;
- }
- else
- {
- Gen gen(argv[0], icecpp.getBaseName(), includePaths, output, impl, implTie, stream);
- if(!gen)
- {
- p->destroy();
- return EXIT_FAILURE;
- }
- gen.generate(p);
- if(tie)
- {
- gen.generateTie(p);
- }
- if(impl)
- {
- gen.generateImpl(p);
- }
- if(implTie)
- {
- gen.generateImplTie(p);
- }
- if(checksum)
- {
- gen.generateChecksums(p);
- }
- }
-
- p->destroy();
- }
- }
+ if(depend)
+ {
+ Preprocessor icecpp(argv[0], *i, cppArgs);
+ icecpp.printMakefileDependencies(Preprocessor::CSharp);
+ }
+ else
+ {
+ Preprocessor icecpp(argv[0], *i, cppArgs);
+ FILE* cppHandle = icecpp.preprocess(false);
+
+ if(cppHandle == 0)
+ {
+ return EXIT_FAILURE;
+ }
+ if(preprocess)
+ {
+ char buf[4096];
+ while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
+ {
+ if(fputs(buf, stdout) == EOF)
+ {
+ return EXIT_FAILURE;
+ }
+ }
+ if(!icecpp.close())
+ {
+ return EXIT_FAILURE;
+ }
+ }
+ else
+ {
+ UnitPtr p = Unit::createUnit(false, false, ice, caseSensitive);
+ int parseStatus = p->parse(cppHandle, debug);
+
+ if(!icecpp.close())
+ {
+ p->destroy();
+ return EXIT_FAILURE;
+ }
+
+ if(parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
+ else
+ {
+ Gen gen(argv[0], icecpp.getBaseName(), includePaths, output, impl, implTie, stream);
+ if(!gen)
+ {
+ p->destroy();
+ return EXIT_FAILURE;
+ }
+ gen.generate(p);
+ if(tie)
+ {
+ gen.generateTie(p);
+ }
+ if(impl)
+ {
+ gen.generateImpl(p);
+ }
+ if(implTie)
+ {
+ gen.generateImplTie(p);
+ }
+ if(checksum)
+ {
+ gen.generateChecksums(p);
+ }
+ }
+
+ p->destroy();
+ }
+ }
}
return status;
diff --git a/cpp/src/slice2docbook/Gen.cpp b/cpp/src/slice2docbook/Gen.cpp
index d2da7f62034..86b8beac068 100644
--- a/cpp/src/slice2docbook/Gen.cpp
+++ b/cpp/src/slice2docbook/Gen.cpp
@@ -27,18 +27,18 @@ Slice::Gen::Gen(const string& name, const string& file, bool standAlone, bool ch
{
if(chapter)
{
- _chapter = "chapter";
+ _chapter = "chapter";
}
else
{
- _chapter = "section";
+ _chapter = "section";
}
-
+
O.open(file.c_str());
if(!O)
{
- cerr << name << ": can't open `" << file << "' for writing: " << strerror(errno) << endl;
- return;
+ cerr << name << ": can't open `" << file << "' for writing: " << strerror(errno) << endl;
+ return;
}
}
@@ -71,13 +71,13 @@ Slice::Gen::visitUnitStart(const UnitPtr& p)
{
if(_standAlone)
{
- O << "<!DOCTYPE article PUBLIC \"-//OASIS//DTD DocBook V3.1//EN\">";
- printHeader();
- start("article");
+ O << "<!DOCTYPE article PUBLIC \"-//OASIS//DTD DocBook V3.1//EN\">";
+ printHeader();
+ start("article");
}
else
{
- printHeader();
+ printHeader();
}
return true;
@@ -88,7 +88,7 @@ Slice::Gen::visitUnitEnd(const UnitPtr& p)
{
if(_standAlone)
{
- end();
+ end();
}
}
@@ -100,11 +100,11 @@ Slice::Gen::visitModuleStart(const ModulePtr& p)
string metadata, deprecateReason;
if(p->findMetaData("deprecate", metadata))
{
- deprecateReason = "This module has been deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- deprecateReason = metadata.substr(10);
- }
+ deprecateReason = "This module has been deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ deprecateReason = metadata.substr(10);
+ }
}
start("section", "Overview", false);
@@ -125,262 +125,262 @@ Slice::Gen::visitContainer(const ContainerPtr& p)
{
ModuleList modules = p->modules();
modules.erase(remove_if(modules.begin(), modules.end(), ::IceUtil::constMemFun(&Contained::includeLevel)),
- modules.end());
+ modules.end());
if(!modules.empty() && !_noIndex)
{
- start("section", "Module Index", false);
- start("variablelist");
- for(ModuleList::const_iterator q = modules.begin(); q != modules.end(); ++q)
- {
- start("varlistentry");
- start("term");
- O << toString(*q, p);
- end();
- start("listitem");
- string metadata;
- printSummary(*q, (*q)->findMetaData("deprecate", metadata));
- end();
- end();
- }
- end();
- end();
+ start("section", "Module Index", false);
+ start("variablelist");
+ for(ModuleList::const_iterator q = modules.begin(); q != modules.end(); ++q)
+ {
+ start("varlistentry");
+ start("term");
+ O << toString(*q, p);
+ end();
+ start("listitem");
+ string metadata;
+ printSummary(*q, (*q)->findMetaData("deprecate", metadata));
+ end();
+ end();
+ }
+ end();
+ end();
}
ClassList classesAndInterfaces = p->classes();
classesAndInterfaces.erase(remove_if(classesAndInterfaces.begin(), classesAndInterfaces.end(),
- ::IceUtil::constMemFun(&Contained::includeLevel)),
- classesAndInterfaces.end());
+ ::IceUtil::constMemFun(&Contained::includeLevel)),
+ classesAndInterfaces.end());
ClassList classes;
ClassList interfaces;
remove_copy_if(classesAndInterfaces.begin(), classesAndInterfaces.end(), back_inserter(classes),
- ::IceUtil::constMemFun(&ClassDef::isInterface));
+ ::IceUtil::constMemFun(&ClassDef::isInterface));
remove_copy_if(classesAndInterfaces.begin(), classesAndInterfaces.end(), back_inserter(interfaces),
- not1(::IceUtil::constMemFun(&ClassDef::isInterface)));
+ not1(::IceUtil::constMemFun(&ClassDef::isInterface)));
if(!classes.empty() && !_noIndex)
{
- start("section", "Class Index", false);
- start("variablelist");
- for(ClassList::const_iterator q = classes.begin(); q != classes.end(); ++q)
- {
- start("varlistentry");
- start("term");
- O << toString(*q, p);
- end();
- start("listitem");
- string metadata;
- printSummary(*q, (*q)->findMetaData("deprecate", metadata));
- end();
- end();
- }
- end();
- end();
+ start("section", "Class Index", false);
+ start("variablelist");
+ for(ClassList::const_iterator q = classes.begin(); q != classes.end(); ++q)
+ {
+ start("varlistentry");
+ start("term");
+ O << toString(*q, p);
+ end();
+ start("listitem");
+ string metadata;
+ printSummary(*q, (*q)->findMetaData("deprecate", metadata));
+ end();
+ end();
+ }
+ end();
+ end();
}
if(!interfaces.empty() && !_noIndex)
{
- start("section", "Interface Index", false);
- start("variablelist");
- for(ClassList::const_iterator q = interfaces.begin(); q != interfaces.end(); ++q)
- {
- start("varlistentry");
- start("term");
- O << toString(*q, p);
- end();
- start("listitem");
- string metadata;
- printSummary(*q, (*q)->findMetaData("deprecate", metadata));
- end();
- end();
- }
- end();
- end();
+ start("section", "Interface Index", false);
+ start("variablelist");
+ for(ClassList::const_iterator q = interfaces.begin(); q != interfaces.end(); ++q)
+ {
+ start("varlistentry");
+ start("term");
+ O << toString(*q, p);
+ end();
+ start("listitem");
+ string metadata;
+ printSummary(*q, (*q)->findMetaData("deprecate", metadata));
+ end();
+ end();
+ }
+ end();
+ end();
}
ExceptionList exceptions = p->exceptions();
exceptions.erase(remove_if(exceptions.begin(), exceptions.end(), ::IceUtil::constMemFun(&Contained::includeLevel)),
- exceptions.end());
+ exceptions.end());
if(!exceptions.empty() && !_noIndex)
{
- start("section", "Exception Index", false);
- start("variablelist");
- for(ExceptionList::const_iterator q = exceptions.begin(); q != exceptions.end(); ++q)
- {
- start("varlistentry");
- start("term");
- O << toString(*q, p);
- end();
- start("listitem");
- string metadata;
- printSummary(*q, (*q)->findMetaData("deprecate", metadata));
- end();
- end();
- }
- end();
- end();
+ start("section", "Exception Index", false);
+ start("variablelist");
+ for(ExceptionList::const_iterator q = exceptions.begin(); q != exceptions.end(); ++q)
+ {
+ start("varlistentry");
+ start("term");
+ O << toString(*q, p);
+ end();
+ start("listitem");
+ string metadata;
+ printSummary(*q, (*q)->findMetaData("deprecate", metadata));
+ end();
+ end();
+ }
+ end();
+ end();
}
StructList structs = p->structs();
structs.erase(remove_if(structs.begin(), structs.end(), ::IceUtil::constMemFun(&Contained::includeLevel)),
- structs.end());
+ structs.end());
if(!structs.empty() && !_noIndex)
{
- start("section", "Struct Index", false);
- start("variablelist");
- for(StructList::const_iterator q = structs.begin(); q != structs.end(); ++q)
- {
- start("varlistentry");
- start("term");
- O << toString(*q, p);
- end();
- start("listitem");
- string metadata;
- printSummary(*q, (*q)->findMetaData("deprecate", metadata));
- end();
- end();
- }
- end();
- end();
+ start("section", "Struct Index", false);
+ start("variablelist");
+ for(StructList::const_iterator q = structs.begin(); q != structs.end(); ++q)
+ {
+ start("varlistentry");
+ start("term");
+ O << toString(*q, p);
+ end();
+ start("listitem");
+ string metadata;
+ printSummary(*q, (*q)->findMetaData("deprecate", metadata));
+ end();
+ end();
+ }
+ end();
+ end();
}
SequenceList sequences = p->sequences();
sequences.erase(remove_if(sequences.begin(), sequences.end(), ::IceUtil::constMemFun(&Contained::includeLevel)),
- sequences.end());
+ sequences.end());
if(!sequences.empty() && !_noIndex)
{
- start("section", "Sequence Index", false);
- start("variablelist");
- for(SequenceList::const_iterator q = sequences.begin(); q != sequences.end(); ++q)
- {
- start("varlistentry");
- start("term");
- O << toString(*q, p);
- end();
- start("listitem");
- string metadata;
- printSummary(*q, (*q)->findMetaData("deprecate", metadata));
- end();
- end();
- }
- end();
- end();
+ start("section", "Sequence Index", false);
+ start("variablelist");
+ for(SequenceList::const_iterator q = sequences.begin(); q != sequences.end(); ++q)
+ {
+ start("varlistentry");
+ start("term");
+ O << toString(*q, p);
+ end();
+ start("listitem");
+ string metadata;
+ printSummary(*q, (*q)->findMetaData("deprecate", metadata));
+ end();
+ end();
+ }
+ end();
+ end();
}
DictionaryList dictionaries = p->dictionaries();
dictionaries.erase(remove_if(dictionaries.begin(), dictionaries.end(),
- ::IceUtil::constMemFun(&Contained::includeLevel)),
- dictionaries.end());
+ ::IceUtil::constMemFun(&Contained::includeLevel)),
+ dictionaries.end());
if(!dictionaries.empty() && !_noIndex)
{
- start("section", "Dictionary Index", false);
- start("variablelist");
- for(DictionaryList::const_iterator q = dictionaries.begin(); q != dictionaries.end(); ++q)
- {
- start("varlistentry");
- start("term");
- O << toString(*q, p);
- end();
- start("listitem");
- string metadata;
- printSummary(*q, (*q)->findMetaData("deprecate", metadata));
- end();
- end();
- }
- end();
- end();
+ start("section", "Dictionary Index", false);
+ start("variablelist");
+ for(DictionaryList::const_iterator q = dictionaries.begin(); q != dictionaries.end(); ++q)
+ {
+ start("varlistentry");
+ start("term");
+ O << toString(*q, p);
+ end();
+ start("listitem");
+ string metadata;
+ printSummary(*q, (*q)->findMetaData("deprecate", metadata));
+ end();
+ end();
+ }
+ end();
+ end();
}
EnumList enums = p->enums();
enums.erase(remove_if(enums.begin(), enums.end(), ::IceUtil::constMemFun(&Contained::includeLevel)),
- enums.end());
+ enums.end());
if(!enums.empty() && !_noIndex)
{
- start("section", "Enum Index", false);
- start("variablelist");
- for(EnumList::const_iterator q = enums.begin(); q != enums.end(); ++q)
- {
- start("varlistentry");
- start("term");
- O << toString(*q, p);
- end();
- start("listitem");
- string metadata;
- printSummary(*q, (*q)->findMetaData("deprecate", metadata));
- end();
- end();
- }
- end();
- end();
+ start("section", "Enum Index", false);
+ start("variablelist");
+ for(EnumList::const_iterator q = enums.begin(); q != enums.end(); ++q)
+ {
+ start("varlistentry");
+ start("term");
+ O << toString(*q, p);
+ end();
+ start("listitem");
+ string metadata;
+ printSummary(*q, (*q)->findMetaData("deprecate", metadata));
+ end();
+ end();
+ }
+ end();
+ end();
}
end();
{
- for(SequenceList::const_iterator q = sequences.begin(); q != sequences.end(); ++q)
- {
- start("section id=" + containedToId(*q), (*q)->name());
- O.zeroIndent();
- O << nl << "<synopsis>";
- printMetaData(*q);
- if((*q)->isLocal())
- {
- O << "local ";
- }
- TypePtr type = (*q)->type();
- O << "sequence&lt;" << toString(type, p) << "&gt; <type>" << (*q)->name() << "</type>;</synopsis>";
- O.restoreIndent();
-
- string metadata, deprecateReason;
- if((*q)->findMetaData("deprecate", metadata))
- {
- deprecateReason = "This type has been deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- deprecateReason = metadata.substr(10);
- }
- }
-
- printComment(*q, deprecateReason);
- end();
- }
+ for(SequenceList::const_iterator q = sequences.begin(); q != sequences.end(); ++q)
+ {
+ start("section id=" + containedToId(*q), (*q)->name());
+ O.zeroIndent();
+ O << nl << "<synopsis>";
+ printMetaData(*q);
+ if((*q)->isLocal())
+ {
+ O << "local ";
+ }
+ TypePtr type = (*q)->type();
+ O << "sequence&lt;" << toString(type, p) << "&gt; <type>" << (*q)->name() << "</type>;</synopsis>";
+ O.restoreIndent();
+
+ string metadata, deprecateReason;
+ if((*q)->findMetaData("deprecate", metadata))
+ {
+ deprecateReason = "This type has been deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ deprecateReason = metadata.substr(10);
+ }
+ }
+
+ printComment(*q, deprecateReason);
+ end();
+ }
}
{
- for(DictionaryList::const_iterator q = dictionaries.begin(); q != dictionaries.end(); ++q)
- {
- start("section id=" + containedToId(*q), (*q)->name());
- O.zeroIndent();
- O << nl << "<synopsis>";
- printMetaData(*q);
- if((*q)->isLocal())
- {
- O << "local ";
- }
- TypePtr keyType = (*q)->keyType();
- TypePtr valueType = (*q)->valueType();
- O << "dictionary&lt;" << toString(keyType, p) << ", " << toString(valueType, p) << "&gt; <type>"
- << (*q)->name() << "</type>;</synopsis>";
- O.restoreIndent();
-
- string metadata, deprecateReason;
- if((*q)->findMetaData("deprecate", metadata))
- {
- deprecateReason = "This type has been deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- deprecateReason = metadata.substr(10);
- }
- }
-
- printComment(*q, deprecateReason);
- end();
- }
+ for(DictionaryList::const_iterator q = dictionaries.begin(); q != dictionaries.end(); ++q)
+ {
+ start("section id=" + containedToId(*q), (*q)->name());
+ O.zeroIndent();
+ O << nl << "<synopsis>";
+ printMetaData(*q);
+ if((*q)->isLocal())
+ {
+ O << "local ";
+ }
+ TypePtr keyType = (*q)->keyType();
+ TypePtr valueType = (*q)->valueType();
+ O << "dictionary&lt;" << toString(keyType, p) << ", " << toString(valueType, p) << "&gt; <type>"
+ << (*q)->name() << "</type>;</synopsis>";
+ O.restoreIndent();
+
+ string metadata, deprecateReason;
+ if((*q)->findMetaData("deprecate", metadata))
+ {
+ deprecateReason = "This type has been deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ deprecateReason = metadata.substr(10);
+ }
+ }
+
+ printComment(*q, deprecateReason);
+ end();
+ }
}
}
@@ -395,11 +395,11 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p)
bool deprecatedClass = p->findMetaData("deprecate", metadata);
if(deprecatedClass)
{
- deprecateReason = "This type has been deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- deprecateReason = metadata.substr(10);
- }
+ deprecateReason = "This type has been deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ deprecateReason = metadata.substr(10);
+ }
}
O.zeroIndent();
@@ -407,51 +407,51 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p)
printMetaData(p);
if(p->isLocal())
{
- O << "local ";
+ O << "local ";
}
if(p->isInterface())
{
- O << "interface";
+ O << "interface";
}
else
{
- O << "class";
+ O << "class";
}
O << " <classname>" << p->name() << "</classname>";
ClassList bases = p->bases();
if(!bases.empty() && !bases.front()->isInterface())
{
- O.inc();
- O << nl << "extends ";
- O.inc();
- O << nl << toString(bases.front(), p);
- bases.pop_front();
- O.dec();
- O.dec();
+ O.inc();
+ O << nl << "extends ";
+ O.inc();
+ O << nl << toString(bases.front(), p);
+ bases.pop_front();
+ O.dec();
+ O.dec();
}
if(!bases.empty())
{
- O.inc();
- if(p->isInterface())
- {
- O << nl << "extends ";
- }
- else
- {
- O << nl << "implements ";
- }
- O.inc();
- ClassList::const_iterator q = bases.begin();
- while(q != bases.end())
- {
- O << nl << toString(*q, p);
- if(++q != bases.end())
- {
- O << ",";
- }
- }
- O.dec();
- O.dec();
+ O.inc();
+ if(p->isInterface())
+ {
+ O << nl << "extends ";
+ }
+ else
+ {
+ O << nl << "implements ";
+ }
+ O.inc();
+ ClassList::const_iterator q = bases.begin();
+ while(q != bases.end())
+ {
+ O << nl << toString(*q, p);
+ if(++q != bases.end())
+ {
+ O << ",";
+ }
+ }
+ O.dec();
+ O.dec();
}
O << "</synopsis>";
O.restoreIndent();
@@ -460,138 +460,138 @@ Slice::Gen::visitClassDefStart(const ClassDefPtr& p)
OperationList operations = p->operations();
if(!operations.empty() && !_noIndex)
{
- start("section", "Operation Index", false);
- start("variablelist");
- for(OperationList::const_iterator q = operations.begin(); q != operations.end(); ++q)
- {
- start("varlistentry");
- start("term");
- O << toString(*q, p);
- end();
- start("listitem");
- printSummary(*q, deprecatedClass || (*q)->findMetaData("deprecate", metadata));
- end();
- end();
- }
- end();
- end();
+ start("section", "Operation Index", false);
+ start("variablelist");
+ for(OperationList::const_iterator q = operations.begin(); q != operations.end(); ++q)
+ {
+ start("varlistentry");
+ start("term");
+ O << toString(*q, p);
+ end();
+ start("listitem");
+ printSummary(*q, deprecatedClass || (*q)->findMetaData("deprecate", metadata));
+ end();
+ end();
+ }
+ end();
+ end();
}
DataMemberList dataMembers = p->dataMembers();
if(!dataMembers.empty() && !_noIndex)
{
- start("section", "Data Member Index", false);
- start("variablelist");
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- start("varlistentry");
- start("term");
- O << toString(*q, p);
- end();
- start("listitem");
- printSummary(*q, deprecatedClass || (*q)->findMetaData("deprecate", metadata));
- end();
- end();
- }
- end();
- end();
+ start("section", "Data Member Index", false);
+ start("variablelist");
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ start("varlistentry");
+ start("term");
+ O << toString(*q, p);
+ end();
+ start("listitem");
+ printSummary(*q, deprecatedClass || (*q)->findMetaData("deprecate", metadata));
+ end();
+ end();
+ }
+ end();
+ end();
}
end();
{
- for(OperationList::const_iterator q = operations.begin(); q != operations.end(); ++q)
- {
- start("section id=" + containedToId(*q), (*q)->name());
- O.zeroIndent();
- O << nl << "<synopsis>";
- printMetaData(*q);
- TypePtr returnType = (*q)->returnType();
- O << (returnType ? toString(returnType, p) : string("<type>void</type>")) << " <function>" << (*q)->name()
- << "</function>(";
- O.inc();
- ParamDeclList paramList = (*q)->parameters();
- ParamDeclList::const_iterator r = paramList.begin();
- while(r != paramList.end())
- {
- if((*r)->isOutParam())
- {
- O << "out ";
- }
- O << toString((*r)->type(), *q) << " <parameter>";
- O << (*r)->name() << "</parameter>";
- if(++r != paramList.end())
- {
- O << ',';
- O << nl;
- }
- }
- O << ')';
- O.dec();
- ExceptionList throws = (*q)->throws();
- if(!throws.empty())
- {
- O.inc();
- O << nl << "throws";
- O.inc();
- ExceptionList::const_iterator t = throws.begin();
- while(t != throws.end())
- {
- O << nl << toString(*t, p);
- if(++t != throws.end())
- {
- O << ',';
- }
- }
- O.dec();
- O.dec();
- }
- O << ";</synopsis>";
- O.restoreIndent();
-
- string reason;
- metadata.clear();
- if(deprecatedClass || (*q)->findMetaData("deprecate", metadata))
- {
- reason = "This operation has been deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- reason = metadata.substr(10);
- }
- }
-
- printComment(*q, reason);
- end();
- }
- }
-
- {
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- start("section id=" + containedToId(*q), (*q)->name());
- O.zeroIndent();
- O << nl << "<synopsis>";
- printMetaData(*q);
- TypePtr type = (*q)->type();
- O << toString(type, p) << " <structfield>" << (*q)->name() << "</structfield>;</synopsis>";
- O.restoreIndent();
-
- string reason;
- metadata.clear();
- if(deprecatedClass || (*q)->findMetaData("deprecate", metadata))
- {
- reason = "This member has been deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- reason = metadata.substr(10);
- }
- }
-
- printComment(*q, reason);
- end();
- }
- }
-
+ for(OperationList::const_iterator q = operations.begin(); q != operations.end(); ++q)
+ {
+ start("section id=" + containedToId(*q), (*q)->name());
+ O.zeroIndent();
+ O << nl << "<synopsis>";
+ printMetaData(*q);
+ TypePtr returnType = (*q)->returnType();
+ O << (returnType ? toString(returnType, p) : string("<type>void</type>")) << " <function>" << (*q)->name()
+ << "</function>(";
+ O.inc();
+ ParamDeclList paramList = (*q)->parameters();
+ ParamDeclList::const_iterator r = paramList.begin();
+ while(r != paramList.end())
+ {
+ if((*r)->isOutParam())
+ {
+ O << "out ";
+ }
+ O << toString((*r)->type(), *q) << " <parameter>";
+ O << (*r)->name() << "</parameter>";
+ if(++r != paramList.end())
+ {
+ O << ',';
+ O << nl;
+ }
+ }
+ O << ')';
+ O.dec();
+ ExceptionList throws = (*q)->throws();
+ if(!throws.empty())
+ {
+ O.inc();
+ O << nl << "throws";
+ O.inc();
+ ExceptionList::const_iterator t = throws.begin();
+ while(t != throws.end())
+ {
+ O << nl << toString(*t, p);
+ if(++t != throws.end())
+ {
+ O << ',';
+ }
+ }
+ O.dec();
+ O.dec();
+ }
+ O << ";</synopsis>";
+ O.restoreIndent();
+
+ string reason;
+ metadata.clear();
+ if(deprecatedClass || (*q)->findMetaData("deprecate", metadata))
+ {
+ reason = "This operation has been deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ reason = metadata.substr(10);
+ }
+ }
+
+ printComment(*q, reason);
+ end();
+ }
+ }
+
+ {
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ start("section id=" + containedToId(*q), (*q)->name());
+ O.zeroIndent();
+ O << nl << "<synopsis>";
+ printMetaData(*q);
+ TypePtr type = (*q)->type();
+ O << toString(type, p) << " <structfield>" << (*q)->name() << "</structfield>;</synopsis>";
+ O.restoreIndent();
+
+ string reason;
+ metadata.clear();
+ if(deprecatedClass || (*q)->findMetaData("deprecate", metadata))
+ {
+ reason = "This member has been deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ reason = metadata.substr(10);
+ }
+ }
+
+ printComment(*q, reason);
+ end();
+ }
+ }
+
end();
return true;
@@ -608,11 +608,11 @@ Slice::Gen::visitExceptionStart(const ExceptionPtr& p)
bool deprecatedException = p->findMetaData("deprecate", metadata);
if(deprecatedException)
{
- deprecateReason = "This type has been deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- deprecateReason = metadata.substr(10);
- }
+ deprecateReason = "This type has been deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ deprecateReason = metadata.substr(10);
+ }
}
O.zeroIndent();
@@ -620,18 +620,18 @@ Slice::Gen::visitExceptionStart(const ExceptionPtr& p)
printMetaData(p);
if(p->isLocal())
{
- O << "local ";
+ O << "local ";
}
O << "exception <classname>" << p->name() << "</classname>";
ExceptionPtr base = p->base();
if(base)
{
- O.inc();
- O << nl << "extends ";
- O.inc();
- O << nl << toString(base, p);
- O.dec();
- O.dec();
+ O.inc();
+ O << nl << "extends ";
+ O.inc();
+ O << nl << toString(base, p);
+ O.dec();
+ O.dec();
}
O << "</synopsis>";
O.restoreIndent();
@@ -640,52 +640,52 @@ Slice::Gen::visitExceptionStart(const ExceptionPtr& p)
DataMemberList dataMembers = p->dataMembers();
if(!dataMembers.empty() && !_noIndex)
{
- start("section", "Data Member Index", false);
- start("variablelist");
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- start("varlistentry");
- start("term");
- O << toString(*q, p);
- end();
- start("listitem");
- printSummary(*q, deprecatedException || (*q)->findMetaData("deprecate", metadata));
- end();
- end();
- }
- end();
- end();
+ start("section", "Data Member Index", false);
+ start("variablelist");
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ start("varlistentry");
+ start("term");
+ O << toString(*q, p);
+ end();
+ start("listitem");
+ printSummary(*q, deprecatedException || (*q)->findMetaData("deprecate", metadata));
+ end();
+ end();
+ }
+ end();
+ end();
}
end();
{
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- start("section id=" + containedToId(*q), (*q)->name());
- O.zeroIndent();
- O << nl << "<synopsis>";
- printMetaData(*q);
- TypePtr type = (*q)->type();
- O << toString(type, p) << " <structfield>" << (*q)->name() << "</structfield>;</synopsis>";
- O.restoreIndent();
-
- string reason;
- metadata.clear();
- if(deprecatedException || (*q)->findMetaData("deprecate", metadata))
- {
- reason = "This member has been deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- reason = metadata.substr(10);
- }
- }
-
- printComment(*q, reason);
- end();
- }
- }
-
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ start("section id=" + containedToId(*q), (*q)->name());
+ O.zeroIndent();
+ O << nl << "<synopsis>";
+ printMetaData(*q);
+ TypePtr type = (*q)->type();
+ O << toString(type, p) << " <structfield>" << (*q)->name() << "</structfield>;</synopsis>";
+ O.restoreIndent();
+
+ string reason;
+ metadata.clear();
+ if(deprecatedException || (*q)->findMetaData("deprecate", metadata))
+ {
+ reason = "This member has been deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ reason = metadata.substr(10);
+ }
+ }
+
+ printComment(*q, reason);
+ end();
+ }
+ }
+
end();
return true;
@@ -702,11 +702,11 @@ Slice::Gen::visitStructStart(const StructPtr& p)
bool deprecatedStruct = p->findMetaData("deprecate", metadata);
if(deprecatedStruct)
{
- deprecateReason = "This type has been deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- deprecateReason = metadata.substr(10);
- }
+ deprecateReason = "This type has been deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ deprecateReason = metadata.substr(10);
+ }
}
O.zeroIndent();
@@ -714,7 +714,7 @@ Slice::Gen::visitStructStart(const StructPtr& p)
printMetaData(p);
if(p->isLocal())
{
- O << "local ";
+ O << "local ";
}
O << "struct <structname>" << p->name() << "</structname>";
O << "</synopsis>";
@@ -724,52 +724,52 @@ Slice::Gen::visitStructStart(const StructPtr& p)
DataMemberList dataMembers = p->dataMembers();
if(!dataMembers.empty() && !_noIndex)
{
- start("section", "Data Member Index", false);
- start("variablelist");
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- start("varlistentry");
- start("term");
- O << toString(*q, p);
- end();
- start("listitem");
- printSummary(*q, deprecatedStruct || (*q)->findMetaData("deprecate", metadata));
- end();
- end();
- }
- end();
- end();
+ start("section", "Data Member Index", false);
+ start("variablelist");
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ start("varlistentry");
+ start("term");
+ O << toString(*q, p);
+ end();
+ start("listitem");
+ printSummary(*q, deprecatedStruct || (*q)->findMetaData("deprecate", metadata));
+ end();
+ end();
+ }
+ end();
+ end();
}
end();
{
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- start("section id=" + containedToId(*q), (*q)->name());
- O.zeroIndent();
- O << nl << "<synopsis>";
- printMetaData(*q);
- TypePtr type = (*q)->type();
- O << toString(type, p) << " <structfield>" << (*q)->name() << "</structfield>;</synopsis>";
- O.restoreIndent();
-
- string reason;
- metadata.clear();
- if(deprecatedStruct || (*q)->findMetaData("deprecate", metadata))
- {
- reason = "This member has been deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- reason = metadata.substr(10);
- }
- }
-
- printComment(*q, reason);
- end();
- }
- }
-
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ start("section id=" + containedToId(*q), (*q)->name());
+ O.zeroIndent();
+ O << nl << "<synopsis>";
+ printMetaData(*q);
+ TypePtr type = (*q)->type();
+ O << toString(type, p) << " <structfield>" << (*q)->name() << "</structfield>;</synopsis>";
+ O.restoreIndent();
+
+ string reason;
+ metadata.clear();
+ if(deprecatedStruct || (*q)->findMetaData("deprecate", metadata))
+ {
+ reason = "This member has been deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ reason = metadata.substr(10);
+ }
+ }
+
+ printComment(*q, reason);
+ end();
+ }
+ }
+
end();
return true;
@@ -785,11 +785,11 @@ Slice::Gen::visitEnum(const EnumPtr& p)
bool deprecatedEnum = p->findMetaData("deprecate", metadata);
if(deprecatedEnum)
{
- deprecateReason = "This type has been deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- deprecateReason = metadata.substr(10);
- }
+ deprecateReason = "This type has been deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ deprecateReason = metadata.substr(10);
+ }
}
O.zeroIndent();
@@ -797,7 +797,7 @@ Slice::Gen::visitEnum(const EnumPtr& p)
printMetaData(p);
if(p->isLocal())
{
- O << "local ";
+ O << "local ";
}
O << "enum <type>" << p->name() << "</type>";
O << "</synopsis>";
@@ -807,49 +807,49 @@ Slice::Gen::visitEnum(const EnumPtr& p)
EnumeratorList enumerators = p->getEnumerators();
if(!enumerators.empty() && !_noIndex)
{
- start("section", "Enumerator Index", false);
- start("variablelist");
- for(EnumeratorList::const_iterator q = enumerators.begin(); q != enumerators.end(); ++q)
- {
- start("varlistentry");
- start("term");
- O << toString(*q, p->container());
- end();
- start("listitem");
- printSummary(*q, deprecatedEnum || (*q)->findMetaData("deprecate", metadata));
- end();
- end();
- }
- end();
- end();
+ start("section", "Enumerator Index", false);
+ start("variablelist");
+ for(EnumeratorList::const_iterator q = enumerators.begin(); q != enumerators.end(); ++q)
+ {
+ start("varlistentry");
+ start("term");
+ O << toString(*q, p->container());
+ end();
+ start("listitem");
+ printSummary(*q, deprecatedEnum || (*q)->findMetaData("deprecate", metadata));
+ end();
+ end();
+ }
+ end();
+ end();
}
end();
{
- for(EnumeratorList::const_iterator q = enumerators.begin(); q != enumerators.end(); ++q)
- {
- start("section id=" + containedToId(*q), (*q)->name());
- O.zeroIndent();
- O << nl << "<synopsis>";
- printMetaData(*q);
- O << "<constant>" << (*q)->name() << "</constant></synopsis>";
- O.restoreIndent();
-
- //
- // Enumerators do not support metadata.
- //
- string reason;
- if(deprecatedEnum)
- {
- reason = "This enumerator has been deprecated.";
- }
-
- printComment(*q, reason);
- end();
- }
- }
-
+ for(EnumeratorList::const_iterator q = enumerators.begin(); q != enumerators.end(); ++q)
+ {
+ start("section id=" + containedToId(*q), (*q)->name());
+ O.zeroIndent();
+ O << nl << "<synopsis>";
+ printMetaData(*q);
+ O << "<constant>" << (*q)->name() << "</constant></synopsis>";
+ O.restoreIndent();
+
+ //
+ // Enumerators do not support metadata.
+ //
+ string reason;
+ if(deprecatedEnum)
+ {
+ reason = "This enumerator has been deprecated.";
+ }
+
+ printComment(*q, reason);
+ end();
+ }
+ }
+
end();
}
@@ -887,34 +887,34 @@ Slice::Gen::getComment(const ContainedPtr& contained, const ContainerPtr& contai
string comment;
for(unsigned int i = 0; i < s.size(); ++i)
{
- if(s[i] == '\\' && i + 1 < s.size() && s[i + 1] == '[')
- {
- comment += '[';
- ++i;
- }
- else if(s[i] == '[')
- {
- string literal;
- for(++i; i < s.size(); ++i)
- {
- if(s[i] == ']')
- {
- break;
- }
-
- literal += s[i];
- }
- comment += toString(literal, container);
- }
- else if(summary && s[i] == '.' && (i + 1 >= s.size() || isspace(s[i + 1])))
- {
- comment += '.';
- break;
- }
- else
- {
- comment += s[i];
- }
+ if(s[i] == '\\' && i + 1 < s.size() && s[i + 1] == '[')
+ {
+ comment += '[';
+ ++i;
+ }
+ else if(s[i] == '[')
+ {
+ string literal;
+ for(++i; i < s.size(); ++i)
+ {
+ if(s[i] == ']')
+ {
+ break;
+ }
+
+ literal += s[i];
+ }
+ comment += toString(literal, container);
+ }
+ else if(summary && s[i] == '.' && (i + 1 >= s.size() || isspace(s[i + 1])))
+ {
+ comment += '.';
+ break;
+ }
+ else
+ {
+ comment += s[i];
+ }
}
return comment;
@@ -927,29 +927,29 @@ Slice::Gen::getTagged(const string& tag, string& comment)
string::size_type begin = 0;
while(begin < comment.size())
{
- begin = comment.find("@" + tag, begin);
- if(begin == string::npos)
- {
- return result;
- }
-
- string::size_type pos1 = comment.find_first_not_of(" \t\r\n", begin + tag.size() + 1);
- if(pos1 == string::npos)
- {
- comment.erase(begin);
- return result;
- }
-
- string::size_type pos2 = comment.find('@', pos1);
- string line = comment.substr(pos1, pos2 - pos1);
- comment.erase(begin, pos2 - 1 - begin);
-
- string::size_type pos3 = line.find_last_not_of(" \t\r\n");
- if(pos3 != string::npos)
- {
- line.erase(pos3 + 1);
- }
- result.push_back(line);
+ begin = comment.find("@" + tag, begin);
+ if(begin == string::npos)
+ {
+ return result;
+ }
+
+ string::size_type pos1 = comment.find_first_not_of(" \t\r\n", begin + tag.size() + 1);
+ if(pos1 == string::npos)
+ {
+ comment.erase(begin);
+ return result;
+ }
+
+ string::size_type pos2 = comment.find('@', pos1);
+ string line = comment.substr(pos1, pos2 - pos1);
+ comment.erase(begin, pos2 - 1 - begin);
+
+ string::size_type pos3 = line.find_last_not_of(" \t\r\n");
+ if(pos3 != string::npos)
+ {
+ line.erase(pos3 + 1);
+ }
+ result.push_back(line);
}
return result;
@@ -962,17 +962,17 @@ Slice::Gen::printMetaData(const ContainedPtr& p)
if(!metaData.empty())
{
- O << "[";
- list<string>::const_iterator q = metaData.begin();
- while(q != metaData.end())
- {
- O << " \"" << *q << "\"";
- if(++q != metaData.end())
- {
- O << ",";
- }
- }
- O << " ]" << nl;
+ O << "[";
+ list<string>::const_iterator q = metaData.begin();
+ while(q != metaData.end())
+ {
+ O << " \"" << *q << "\"";
+ if(++q != metaData.end())
+ {
+ O << ",";
+ }
+ }
+ O << " ]" << nl;
}
}
@@ -982,7 +982,7 @@ Slice::Gen::printComment(const ContainedPtr& p, const string& deprecateReason)
ContainerPtr container = ContainerPtr::dynamicCast(p);
if(!container)
{
- container = p->container();
+ container = p->container();
}
string comment = getComment(p, container, false);
@@ -996,223 +996,223 @@ Slice::Gen::printComment(const ContainedPtr& p, const string& deprecateReason)
string::size_type pos = comment.find_last_not_of(" \t\r\n");
if(pos != string::npos)
{
- comment.erase(pos + 1);
- O.zeroIndent();
- O << nl << comment;
- O.restoreIndent();
+ comment.erase(pos + 1);
+ O.zeroIndent();
+ O << nl << comment;
+ O.restoreIndent();
}
end();
if(!deprecateReason.empty())
{
- start("caution");
- start("title");
- O << nl << "Deprecated";
- end();
- start("para");
- O << nl << deprecateReason;
- end();
- end();
+ start("caution");
+ start("title");
+ O << nl << "Deprecated";
+ end();
+ start("para");
+ O << nl << deprecateReason;
+ end();
+ end();
}
if(!par.empty())
{
- start("section", "Parameters", false);
- start("variablelist");
- for(StringList::const_iterator q = par.begin(); q != par.end(); ++q)
- {
- string term;
- pos = q->find_first_of(" \t\r\n");
- if(pos != string::npos)
- {
- term = q->substr(0, pos);
- }
- string item;
- pos = q->find_first_not_of(" \t\r\n", pos);
- if(pos != string::npos)
- {
- item = q->substr(pos);
- }
-
- start("varlistentry");
- start("term");
- O << "<parameter>" << term << "</parameter>";
- end();
- start("listitem");
- start("para");
- O << nl << item;
- end();
- end();
- end();
- }
- end();
- end();
+ start("section", "Parameters", false);
+ start("variablelist");
+ for(StringList::const_iterator q = par.begin(); q != par.end(); ++q)
+ {
+ string term;
+ pos = q->find_first_of(" \t\r\n");
+ if(pos != string::npos)
+ {
+ term = q->substr(0, pos);
+ }
+ string item;
+ pos = q->find_first_not_of(" \t\r\n", pos);
+ if(pos != string::npos)
+ {
+ item = q->substr(pos);
+ }
+
+ start("varlistentry");
+ start("term");
+ O << "<parameter>" << term << "</parameter>";
+ end();
+ start("listitem");
+ start("para");
+ O << nl << item;
+ end();
+ end();
+ end();
+ }
+ end();
+ end();
}
if(!ret.empty())
{
- start("section", "Return Value", false);
- start("para");
- O << nl << ret.front();
- end();
- end();
+ start("section", "Return Value", false);
+ start("para");
+ O << nl << ret.front();
+ end();
+ end();
}
if(!throws.empty())
{
- start("section", "Exceptions", false);
- start("variablelist");
- for(StringList::const_iterator q = throws.begin(); q != throws.end(); ++q)
- {
- string term;
- pos = q->find_first_of(" \t\r\n");
- if(pos != string::npos)
- {
- term = q->substr(0, pos);
- }
- string item;
- pos = q->find_first_not_of(" \t\r\n", pos);
- if(pos != string::npos)
- {
- item = q->substr(pos);
- }
-
- start("varlistentry");
- start("term");
- O << toString(term, container);
- end();
- start("listitem");
- start("para");
- O << nl << item;
- end();
- end();
- end();
- }
- end();
- end();
+ start("section", "Exceptions", false);
+ start("variablelist");
+ for(StringList::const_iterator q = throws.begin(); q != throws.end(); ++q)
+ {
+ string term;
+ pos = q->find_first_of(" \t\r\n");
+ if(pos != string::npos)
+ {
+ term = q->substr(0, pos);
+ }
+ string item;
+ pos = q->find_first_not_of(" \t\r\n", pos);
+ if(pos != string::npos)
+ {
+ item = q->substr(pos);
+ }
+
+ start("varlistentry");
+ start("term");
+ O << toString(term, container);
+ end();
+ start("listitem");
+ start("para");
+ O << nl << item;
+ end();
+ end();
+ end();
+ }
+ end();
+ end();
}
ClassList derivedClasses;
ClassDefPtr def = ClassDefPtr::dynamicCast(p);
if(def)
{
- derivedClasses = p->unit()->findDerivedClasses(def);
+ derivedClasses = p->unit()->findDerivedClasses(def);
}
if(!derivedClasses.empty())
{
- start("section", "Derived Classes and Interfaces", false);
- O << nl << "<para>";
- start("simplelist type=\"inline\"");
- for(ClassList::const_iterator q = derivedClasses.begin(); q != derivedClasses.end(); ++q)
- {
- start("member");
- O << toString(*q, container);
- end();
- }
- end();
- O << "</para>";
- end();
+ start("section", "Derived Classes and Interfaces", false);
+ O << nl << "<para>";
+ start("simplelist type=\"inline\"");
+ for(ClassList::const_iterator q = derivedClasses.begin(); q != derivedClasses.end(); ++q)
+ {
+ start("member");
+ O << toString(*q, container);
+ end();
+ }
+ end();
+ O << "</para>";
+ end();
}
ExceptionList derivedExceptions;
ExceptionPtr ex = ExceptionPtr::dynamicCast(p);
if(ex)
{
- derivedExceptions = p->unit()->findDerivedExceptions(ex);
- if(!derivedExceptions.empty())
- {
- start("section", "Derived Exceptions", false);
- O << nl << "<para>";
- start("simplelist type=\"inline\"");
- for(ExceptionList::const_iterator q = derivedExceptions.begin(); q != derivedExceptions.end(); ++q)
- {
- start("member");
- O << toString(*q, container);
- end();
- }
- end();
- O << "</para>";
- end();
- }
- ContainedList usedBy;
- usedBy = p->unit()->findUsedBy(ex);
- if(!usedBy.empty())
- {
- start("section", "Used By", false);
- O << nl << "<para>";
- start("simplelist type=\"inline\"");
- for(ContainedList::const_iterator q = usedBy.begin(); q != usedBy.end(); ++q)
- {
- start("member");
- O << toString(*q, container);
- end();
- }
- end();
- O << "</para>";
- end();
- }
+ derivedExceptions = p->unit()->findDerivedExceptions(ex);
+ if(!derivedExceptions.empty())
+ {
+ start("section", "Derived Exceptions", false);
+ O << nl << "<para>";
+ start("simplelist type=\"inline\"");
+ for(ExceptionList::const_iterator q = derivedExceptions.begin(); q != derivedExceptions.end(); ++q)
+ {
+ start("member");
+ O << toString(*q, container);
+ end();
+ }
+ end();
+ O << "</para>";
+ end();
+ }
+ ContainedList usedBy;
+ usedBy = p->unit()->findUsedBy(ex);
+ if(!usedBy.empty())
+ {
+ start("section", "Used By", false);
+ O << nl << "<para>";
+ start("simplelist type=\"inline\"");
+ for(ContainedList::const_iterator q = usedBy.begin(); q != usedBy.end(); ++q)
+ {
+ start("member");
+ O << toString(*q, container);
+ end();
+ }
+ end();
+ O << "</para>";
+ end();
+ }
}
ContainedList usedBy;
ConstructedPtr constructed;
if(def)
{
- constructed = def->declaration();
+ constructed = def->declaration();
}
else
{
- constructed = ConstructedPtr::dynamicCast(p);
+ constructed = ConstructedPtr::dynamicCast(p);
}
if(constructed)
{
- usedBy = p->unit()->findUsedBy(constructed);
+ usedBy = p->unit()->findUsedBy(constructed);
}
if(!usedBy.empty())
{
- //
- // We first accumulate the strings in a list instead of printing
- // each stringified entry in the usedBy list. This is necessary because
- // the usedBy list can contain operations and parameters. But toString()
- // on a parameter returns the string for the parameter's operation, so
- // we can end up printing the same operation name more than once.
- //
- list<string> strings;
- for(ContainedList::const_iterator q = usedBy.begin(); q != usedBy.end(); ++q)
- {
- strings.push_back(toString(*q, container));
- }
- strings.sort();
- strings.unique();
-
- start("section", "Used By", false);
- O << nl << "<para>";
- start("simplelist type=\"inline\"");
- for(list<string>::const_iterator p = strings.begin(); p != strings.end(); ++p)
- {
- start("member");
- O << *p;
- end();
- }
- end();
- O << "</para>";
- end();
+ //
+ // We first accumulate the strings in a list instead of printing
+ // each stringified entry in the usedBy list. This is necessary because
+ // the usedBy list can contain operations and parameters. But toString()
+ // on a parameter returns the string for the parameter's operation, so
+ // we can end up printing the same operation name more than once.
+ //
+ list<string> strings;
+ for(ContainedList::const_iterator q = usedBy.begin(); q != usedBy.end(); ++q)
+ {
+ strings.push_back(toString(*q, container));
+ }
+ strings.sort();
+ strings.unique();
+
+ start("section", "Used By", false);
+ O << nl << "<para>";
+ start("simplelist type=\"inline\"");
+ for(list<string>::const_iterator p = strings.begin(); p != strings.end(); ++p)
+ {
+ start("member");
+ O << *p;
+ end();
+ }
+ end();
+ O << "</para>";
+ end();
}
if(!see.empty())
{
- start("section", "See Also", false);
- O << nl << "<para>";
- start("simplelist type=\"inline\"");
- for(StringList::const_iterator q = see.begin(); q != see.end(); ++q)
- {
- start("member");
- O << toString(*q, container);
- end();
- }
- end();
- O << "</para>";
- end();
+ start("section", "See Also", false);
+ O << nl << "<para>";
+ start("simplelist type=\"inline\"");
+ for(StringList::const_iterator q = see.begin(); q != see.end(); ++q)
+ {
+ start("member");
+ O << toString(*q, container);
+ end();
+ }
+ end();
+ O << "</para>";
+ end();
}
}
@@ -1222,7 +1222,7 @@ Slice::Gen::printSummary(const ContainedPtr& p, bool deprecated)
ContainerPtr container = ContainerPtr::dynamicCast(p);
if(!container)
{
- container = p->container();
+ container = p->container();
}
string summary = getComment(p, container, true);
@@ -1231,7 +1231,7 @@ Slice::Gen::printSummary(const ContainedPtr& p, bool deprecated)
O << nl << summary;
if(deprecated)
{
- O << nl << "<emphasis>Deprecated.</emphasis>";
+ O << nl << "<emphasis>Deprecated.</emphasis>";
}
O.restoreIndent();
end();
@@ -1251,12 +1251,12 @@ Slice::Gen::start(const std::string& element, const std::string& title, bool asL
O << se(titleElement);
if(asLiteral)
{
- O << "<literal>";
+ O << "<literal>";
}
O << title;
if(asLiteral)
{
- O << "</literal>";
+ O << "</literal>";
}
end();
}
@@ -1275,7 +1275,7 @@ Slice::Gen::containedToId(const ContainedPtr& contained)
string scoped = contained->scoped();
if(scoped[0] == ':')
{
- scoped.erase(0, 2);
+ scoped.erase(0, 2);
}
string id;
@@ -1283,15 +1283,15 @@ Slice::Gen::containedToId(const ContainedPtr& contained)
for(unsigned int i = 0; i < scoped.size(); ++i)
{
- if(scoped[i] == ':')
- {
- id += '.';
- ++i;
- }
- else
- {
- id += scoped[i];
- }
+ if(scoped[i] == ':')
+ {
+ id += '.';
+ ++i;
+ }
+ else
+ {
+ id += scoped[i];
+ }
}
//
@@ -1300,8 +1300,8 @@ Slice::Gen::containedToId(const ContainedPtr& contained)
//
if(id.size() > 44)
{
- id.erase(0, id.size() - 44);
- assert(id.size() == 44);
+ id.erase(0, id.size() - 44);
+ assert(id.size() == 44);
}
//
@@ -1309,7 +1309,7 @@ Slice::Gen::containedToId(const ContainedPtr& contained)
//
if(id[0] == '.')
{
- id.erase(0, 1);
+ id.erase(0, 1);
}
return '"' + id + '"';
@@ -1324,21 +1324,21 @@ Slice::Gen::getScopedMinimized(const ContainedPtr& contained, const ContainerPtr
if(!q) // Container is the global module
{
- return s.substr(2);
+ return s.substr(2);
}
do
{
- string s2 = q->scoped();
- s2 += "::";
+ string s2 = q->scoped();
+ s2 += "::";
- if(s.find(s2) == 0)
- {
- return s.substr(s2.size());
- }
+ if(s.find(s2) == 0)
+ {
+ return s.substr(s2.size());
+ }
- p = q->container();
- q = ContainedPtr::dynamicCast(p);
+ p = q->container();
+ q = ContainedPtr::dynamicCast(p);
}
while(q);
@@ -1354,130 +1354,130 @@ Slice::Gen::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& container,
static const char* builtinTable[] =
{
- "byte",
- "bool",
- "short",
- "int",
- "long",
- "float",
- "double",
- "string",
- "Object",
- "Object*",
- "LocalObject"
+ "byte",
+ "bool",
+ "short",
+ "int",
+ "long",
+ "float",
+ "double",
+ "string",
+ "Object",
+ "Object*",
+ "LocalObject"
};
BuiltinPtr builtin = BuiltinPtr::dynamicCast(p);
if(builtin)
{
- s = builtinTable[builtin->kind()];
- tag = "type";
+ s = builtinTable[builtin->kind()];
+ tag = "type";
}
ProxyPtr proxy = ProxyPtr::dynamicCast(p);
if(proxy)
{
- if(withLink && proxy->_class()->includeLevel() == 0)
- {
- linkend = containedToId(proxy->_class());
- }
- s = getScopedMinimized(proxy->_class(), container);
- s += "*";
- tag = "classname";
+ if(withLink && proxy->_class()->includeLevel() == 0)
+ {
+ linkend = containedToId(proxy->_class());
+ }
+ s = getScopedMinimized(proxy->_class(), container);
+ s += "*";
+ tag = "classname";
}
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(p);
if(cl)
{
- //
+ //
// We must generate the id from the definition, not from the
// declaration, provided that a definition is available.
- //
- ContainedPtr definition = cl->definition();
- if(withLink && definition && definition->includeLevel() == 0)
- {
- linkend = containedToId(definition);
- }
- s = getScopedMinimized(cl, container);
- tag = "classname";
+ //
+ ContainedPtr definition = cl->definition();
+ if(withLink && definition && definition->includeLevel() == 0)
+ {
+ linkend = containedToId(definition);
+ }
+ s = getScopedMinimized(cl, container);
+ tag = "classname";
}
ExceptionPtr ex = ExceptionPtr::dynamicCast(p);
if(ex)
{
- if(withLink && ex->includeLevel() == 0)
- {
- linkend = containedToId(ex);
- }
- s = getScopedMinimized(ex, container);
- tag = "classname";
+ if(withLink && ex->includeLevel() == 0)
+ {
+ linkend = containedToId(ex);
+ }
+ s = getScopedMinimized(ex, container);
+ tag = "classname";
}
StructPtr st = StructPtr::dynamicCast(p);
if(st)
{
- if(withLink && st->includeLevel() == 0)
- {
- linkend = containedToId(st);
- }
- s = getScopedMinimized(st, container);
- tag = "structname";
+ if(withLink && st->includeLevel() == 0)
+ {
+ linkend = containedToId(st);
+ }
+ s = getScopedMinimized(st, container);
+ tag = "structname";
}
EnumeratorPtr en = EnumeratorPtr::dynamicCast(p);
if(en)
{
- if(withLink && en->includeLevel() == 0)
- {
- linkend = containedToId(en);
- }
- s = getScopedMinimized(en, container);
- tag = "constant";
+ if(withLink && en->includeLevel() == 0)
+ {
+ linkend = containedToId(en);
+ }
+ s = getScopedMinimized(en, container);
+ tag = "constant";
}
OperationPtr op = OperationPtr::dynamicCast(p);
if(op)
{
- if(withLink && op->includeLevel() == 0)
- {
- linkend = containedToId(op);
- }
- s = getScopedMinimized(op, container);
- tag = "function";
+ if(withLink && op->includeLevel() == 0)
+ {
+ linkend = containedToId(op);
+ }
+ s = getScopedMinimized(op, container);
+ tag = "function";
}
ParamDeclPtr pd = ParamDeclPtr::dynamicCast(p);
if(pd)
{
- op = OperationPtr::dynamicCast(pd->container());
- assert(op);
- if(withLink && pd->includeLevel() == 0)
- {
- linkend = containedToId(op);
- }
- s = getScopedMinimized(op, container);
- tag = "function";
+ op = OperationPtr::dynamicCast(pd->container());
+ assert(op);
+ if(withLink && pd->includeLevel() == 0)
+ {
+ linkend = containedToId(op);
+ }
+ s = getScopedMinimized(op, container);
+ tag = "function";
}
if(s.empty())
{
- ContainedPtr contained = ContainedPtr::dynamicCast(p);
- assert(contained);
- if(withLink && contained->includeLevel() == 0)
- {
- linkend = containedToId(contained);
- }
- s = getScopedMinimized(contained, container);
- tag = "type";
+ ContainedPtr contained = ContainedPtr::dynamicCast(p);
+ assert(contained);
+ if(withLink && contained->includeLevel() == 0)
+ {
+ linkend = containedToId(contained);
+ }
+ s = getScopedMinimized(contained, container);
+ tag = "type";
}
if(linkend.empty())
{
- return "<" + tag + ">" + s + "</" + tag + ">";
+ return "<" + tag + ">" + s + "</" + tag + ">";
}
else
{
- return "<link linkend=" + linkend + "><" + tag + ">" + s + "</" + tag + "></link>";
+ return "<link linkend=" + linkend + "><" + tag + ">" + s + "</" + tag + "></link>";
}
}
@@ -1489,13 +1489,13 @@ Slice::Gen::toString(const string& str, const ContainerPtr& container, bool with
TypeList types = container->lookupType(s, false);
if(!types.empty())
{
- return toString(types.front(), container, withLink);
+ return toString(types.front(), container, withLink);
}
ContainedList contList = container->lookupContained(s, false);
if(!contList.empty())
{
- return toString(contList.front(), container, withLink);
+ return toString(contList.front(), container, withLink);
}
//
diff --git a/cpp/src/slice2docbook/Main.cpp b/cpp/src/slice2docbook/Main.cpp
index 4850ec97814..4f0f063526b 100644
--- a/cpp/src/slice2docbook/Main.cpp
+++ b/cpp/src/slice2docbook/Main.cpp
@@ -27,12 +27,12 @@ usage(const char* n)
"-DNAME=DEF Define NAME as DEF.\n"
"-UNAME Remove any definition for NAME.\n"
"-IDIR Put DIR in the include file search path.\n"
- "-E Print preprocessor output on stdout.\n"
+ "-E Print preprocessor output on stdout.\n"
"-s, --stand-alone Create stand-alone docbook file.\n"
"--chapter Use \"chapter\" instead of \"section\" as\n"
" top-level element.\n"
- "--noindex Suppress generation of index pages.\n"
- "--sort-fields Sort fields of structures, classes, and exceptions.\n"
+ "--noindex Suppress generation of index pages.\n"
+ "--sort-fields Sort fields of structures, classes, and exceptions.\n"
"-d, --debug Print debug messages.\n"
"--ice Permit `Ice' prefix (for building Ice source code only)\n"
;
@@ -64,21 +64,21 @@ main(int argc, char* argv[])
}
catch(const IceUtil::BadOptException& e)
{
- cerr << argv[0] << ": " << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": " << e.reason << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(argv[0]);
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
string cppArgs;
@@ -86,19 +86,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D" + Preprocessor::addQuotes(*i);
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U" + Preprocessor::addQuotes(*i);
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("I");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -I" + Preprocessor::addQuotes(*i);
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
@@ -119,9 +119,9 @@ main(int argc, char* argv[])
if(args.empty())
{
- cerr << argv[0] << ": no docbook file specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": no docbook file specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
string docbook(args[0]);
@@ -129,20 +129,20 @@ main(int argc, char* argv[])
string::size_type pos = docbook.rfind('.');
if(pos != string::npos)
{
- suffix = docbook.substr(pos);
- transform(suffix.begin(), suffix.end(), suffix.begin(), ::tolower);
+ suffix = docbook.substr(pos);
+ transform(suffix.begin(), suffix.end(), suffix.begin(), ::tolower);
}
if(suffix != ".sgml")
{
- cerr << argv[0] << ": docbook file must end with `.sgml'" << endl;
- return EXIT_FAILURE;
+ cerr << argv[0] << ": docbook file must end with `.sgml'" << endl;
+ return EXIT_FAILURE;
}
if(args.size() < 2)
{
- cerr << argv[0] << ": no input file" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": no input file" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
UnitPtr p = Unit::createUnit(true, false, ice, caseSensitive);
@@ -151,47 +151,47 @@ main(int argc, char* argv[])
for(vector<string>::size_type idx = 1; idx < args.size(); ++idx)
{
- Preprocessor icecpp(argv[0], args[idx], cppArgs);
- FILE* cppHandle = icecpp.preprocess(true);
-
- if(cppHandle == 0)
- {
- p->destroy();
- return EXIT_FAILURE;
- }
- if(preprocess)
- {
- char buf[4096];
- while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
- {
- if(fputs(buf, stdout) == EOF)
- {
- p->destroy();
- return EXIT_FAILURE;
- }
- }
- }
- else
- {
- status = p->parse(cppHandle, debug);
- }
-
- if(!icecpp.close())
- {
- p->destroy();
- return EXIT_FAILURE;
- }
+ Preprocessor icecpp(argv[0], args[idx], cppArgs);
+ FILE* cppHandle = icecpp.preprocess(true);
+
+ if(cppHandle == 0)
+ {
+ p->destroy();
+ return EXIT_FAILURE;
+ }
+ if(preprocess)
+ {
+ char buf[4096];
+ while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
+ {
+ if(fputs(buf, stdout) == EOF)
+ {
+ p->destroy();
+ return EXIT_FAILURE;
+ }
+ }
+ }
+ else
+ {
+ status = p->parse(cppHandle, debug);
+ }
+
+ if(!icecpp.close())
+ {
+ p->destroy();
+ return EXIT_FAILURE;
+ }
}
if(status == EXIT_SUCCESS && !preprocess)
{
- Gen gen(argv[0], docbook, standAlone, chapter, noIndex, sortFields);
- if(!gen)
- {
- p->destroy();
- return EXIT_FAILURE;
- }
- gen.generate(p);
+ Gen gen(argv[0], docbook, standAlone, chapter, noIndex, sortFields);
+ if(!gen)
+ {
+ p->destroy();
+ return EXIT_FAILURE;
+ }
+ gen.generate(p);
}
p->destroy();
diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp
index 9b138b20959..97a495da2c2 100644
--- a/cpp/src/slice2freeze/Main.cpp
+++ b/cpp/src/slice2freeze/Main.cpp
@@ -28,12 +28,12 @@ struct DictIndex
bool operator==(const DictIndex& rhs) const
{
- return member == rhs.member;
+ return member == rhs.member;
}
bool operator!=(const DictIndex& rhs) const
{
- return member != rhs.member;
+ return member != rhs.member;
}
};
@@ -74,44 +74,44 @@ usage(const char* n)
"-v, --version Display the Ice version.\n"
"--header-ext EXT Use EXT instead of the default `h' extension.\n"
"--source-ext EXT Use EXT instead of the default `cpp' extension.\n"
- "--add-header HDR[,GUARD]\n"
- " Add #include for HDR (with guard GUARD) to generated source file.\n"
+ "--add-header HDR[,GUARD]\n"
+ " Add #include for HDR (with guard GUARD) to generated source file.\n"
"-DNAME Define NAME as 1.\n"
"-DNAME=DEF Define NAME as DEF.\n"
"-UNAME Remove any definition for NAME.\n"
"-IDIR Put DIR in the include file search path.\n"
- "-E Print preprocessor output on stdout.\n"
+ "-E Print preprocessor output on stdout.\n"
"--include-dir DIR Use DIR as the header include directory in source files.\n"
"--dll-export SYMBOL Use SYMBOL for DLL exports.\n"
"--dict NAME,KEY,VALUE[,sort[,COMPARE]]\n"
- " Create a Freeze dictionary with the name NAME,\n"
+ " Create a Freeze dictionary with the name NAME,\n"
" using KEY as key, and VALUE as value. This\n"
" option may be specified multiple times for\n"
" different names. NAME may be a scoped name.\n"
- " By default, keys are sorted using their binary\n"
- " Ice-encoding representation. Use 'sort' to sort\n"
- " with the COMPARE functor class. COMPARE's default\n"
- " value is std::less<KEY>\n"
- "--index NAME,TYPE,MEMBER[,{case-sensitive|case-insensitive}]\n"
+ " By default, keys are sorted using their binary\n"
+ " Ice-encoding representation. Use 'sort' to sort\n"
+ " with the COMPARE functor class. COMPARE's default\n"
+ " value is std::less<KEY>\n"
+ "--index NAME,TYPE,MEMBER[,{case-sensitive|case-insensitive}]\n"
" Create a Freeze evictor index with the name\n"
" NAME for member MEMBER of class TYPE. This\n"
" option may be specified multiple times for\n"
" different names. NAME may be a scoped name.\n"
" When member is a string, the case can be\n"
" sensitive or insensitive (default is sensitive).\n"
- "--dict-index DICT[,MEMBER][,{case-sensitive|case-insensitive}]\n"
- " [,sort[,COMPARE]]\n"
- " Add an index to dictionary DICT. If MEMBER is \n"
+ "--dict-index DICT[,MEMBER][,{case-sensitive|case-insensitive}]\n"
+ " [,sort[,COMPARE]]\n"
+ " Add an index to dictionary DICT. If MEMBER is \n"
" specified, then DICT's VALUE must be a class or\n"
- " a struct, and MEMBER must designate a member of\n"
- " VALUE. Otherwise, the entire VALUE is used for \n"
- " indexing. When the secondary key is a string, \n"
- " the case can be sensitive or insensitive (default\n"
- " is sensitive).\n"
- " By default, keys are sorted using their binary\n"
- " Ice-encoding representation. Use 'sort' to sort\n"
- " with the COMPARE functor class. COMPARE's default\n"
- " value is std::less<secondary key type>.\n"
+ " a struct, and MEMBER must designate a member of\n"
+ " VALUE. Otherwise, the entire VALUE is used for \n"
+ " indexing. When the secondary key is a string, \n"
+ " the case can be sensitive or insensitive (default\n"
+ " is sensitive).\n"
+ " By default, keys are sorted using their binary\n"
+ " Ice-encoding representation. Use 'sort' to sort\n"
+ " with the COMPARE functor class. COMPARE's default\n"
+ " value is std::less<secondary key type>.\n"
"--output-dir DIR Create files in the directory DIR.\n"
"-d, --debug Print debug messages.\n"
"--ice Permit `Ice' prefix (for building Ice source code only)\n"
@@ -124,17 +124,17 @@ checkIdentifier(string n, string t, string s)
{
if(s.empty() || (!isalpha(s[0]) && s[0] != '_'))
{
- cerr << n << ": `" << t << "' is not a valid type name" << endl;
- return false;
+ cerr << n << ": `" << t << "' is not a valid type name" << endl;
+ return false;
}
for(unsigned int i = 1; i < s.size(); ++i)
{
- if(!isalnum(s[i]) && s[i] != '_')
- {
- cerr << n << ": `" << t << "' is not a valid type name" << endl;
- return false;
- }
+ if(!isalnum(s[i]) && s[i] != '_')
+ {
+ cerr << n << ": `" << t << "' is not a valid type name" << endl;
+ return false;
+ }
}
return true;
@@ -147,18 +147,18 @@ printFreezeTypes(Output& out, const vector<Dict>& dicts, const vector<Index>& in
out << "\n// Freeze types in this file:";
for(vector<Dict>::const_iterator p = dicts.begin(); p != dicts.end(); ++p)
{
- out << "\n// name=\"" << p->name << "\", key=\""
- << p->key << "\", value=\"" << p->value << "\"";
+ out << "\n// name=\"" << p->name << "\", key=\""
+ << p->key << "\", value=\"" << p->value << "\"";
}
for(vector<Index>::const_iterator q = indices.begin(); q != indices.end(); ++q)
{
- out << "\n// name=\"" << q->name << "\", type=\"" << q->type
- << "\", member=\"" << q->member << "\"";
- if(q->caseSensitive == false)
- {
- out << " (case insensitive)";
- }
+ out << "\n// name=\"" << q->name << "\", type=\"" << q->type
+ << "\", member=\"" << q->member << "\"";
+ if(q->caseSensitive == false)
+ {
+ out << " (case insensitive)";
+ }
}
out << '\n';
}
@@ -169,24 +169,24 @@ getCompare(const T& t, const string& keyType)
{
if(t.sort)
{
- if(t.userCompare == "")
- {
- return "std::less< " + keyType + ">";
- }
- else
- {
- return t.userCompare;
- }
+ if(t.userCompare == "")
+ {
+ return "std::less< " + keyType + ">";
+ }
+ else
+ {
+ return t.userCompare;
+ }
}
else
{
- return ICE_ENCODING_COMPARE;
+ return ICE_ENCODING_COMPARE;
}
}
void
writeCodecH(const TypePtr& type, const StringList& metaData, const string& name, const string& freezeType, Output& H,
- const string& dllExport)
+ const string& dllExport)
{
H << sp << nl << "class " << dllExport << name;
H << sb;
@@ -259,14 +259,14 @@ writeCodecC(const TypePtr& type, const StringList& metaData, const string& name,
string staticName = "__";
for(string::const_iterator p = name.begin(); p != name.end(); ++p)
{
- if((*p) == ':')
- {
- staticName += '_';
- }
- else
- {
- staticName += *p;
- }
+ if((*p) == ':')
+ {
+ staticName += '_';
+ }
+ else
+ {
+ staticName += *p;
+ }
}
staticName += "_typeId";
@@ -288,35 +288,35 @@ writeCodecC(const TypePtr& type, const StringList& metaData, const string& name,
void
writeDictWithIndicesH(const string& name, const Dict& dict,
- const vector<IndexType> indexTypes,
- const TypePtr& keyType, const StringList& keyMetaData, const TypePtr& valueType,
- const StringList& valueMetaData, Output& H, const string& dllExport)
+ const vector<IndexType> indexTypes,
+ const TypePtr& keyType, const StringList& keyMetaData, const TypePtr& valueType,
+ const StringList& valueMetaData, Output& H, const string& dllExport)
{
string compare = getCompare(dict, typeToString(keyType, false, keyMetaData));
string templateParams = string("< ") + typeToString(keyType, false, keyMetaData) + ", "
- + typeToString(valueType, false, valueMetaData) + ", " + name + "KeyCodec, "
- + name + "ValueCodec, " + compare + " >";
+ + typeToString(valueType, false, valueMetaData) + ", " + name + "KeyCodec, "
+ + name + "ValueCodec, " + compare + " >";
string keyCompareParams =
- string("< ") + typeToString(keyType, false, keyMetaData) + ", "
- + name + "KeyCodec, " + compare + " >";
+ string("< ") + typeToString(keyType, false, keyMetaData) + ", "
+ + name + "KeyCodec, " + compare + " >";
vector<string> capitalizedMembers;
size_t i;
for(i = 0; i < dict.indices.size(); ++i)
{
- const string& member = dict.indices[i].member;
- if(!member.empty())
- {
- string capitalizedMember = member;
- capitalizedMember[0] = toupper(capitalizedMember[0]);
- capitalizedMembers.push_back(capitalizedMember);
- }
- else
- {
- capitalizedMembers.push_back("Value");
- }
+ const string& member = dict.indices[i].member;
+ if(!member.empty())
+ {
+ string capitalizedMember = member;
+ capitalizedMember[0] = toupper(capitalizedMember[0]);
+ capitalizedMembers.push_back(capitalizedMember);
+ }
+ else
+ {
+ capitalizedMembers.push_back("Value");
+ }
}
H << sp << nl << "class " << dllExport << name
@@ -346,46 +346,46 @@ writeDictWithIndicesH(const string& name, const Dict& dict,
for(i = 0; i < capitalizedMembers.size(); ++i)
{
- string className = capitalizedMembers[i] + "Index";
-
- string indexCompare =
- getCompare(dict.indices[i], typeToString(indexTypes[i].type, false, indexTypes[i].metaData));
-
- string indexCompareParams =
- string("< ") + typeToString(indexTypes[i].type, false, indexTypes[i].metaData) + ", "
- + className + ", " + indexCompare + " >";
-
- H << sp << nl << "class " << dllExport << className
- << " : public Freeze::MapIndex" << indexCompareParams;
- H << sb;
-
- H.dec();
- H << sp << nl << "public:";
- H << sp;
- H.inc();
- H << nl << capitalizedMembers[i] << "Index(const std::string&, const "
- << indexCompare << "& = " << indexCompare << "());";
-
- H << sp;
-
- //
- // Codec
- //
- H << nl << "static void write(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData)
- << ", Freeze::Key&, const Ice::CommunicatorPtr&);";
-
- H << nl << "static void read("
- << typeToString(indexTypes[i].type, false, indexTypes[i].metaData)
- << "&, const Freeze::Key&, const ::Ice::CommunicatorPtr&);";
-
- H.dec();
- H << sp << nl << "protected:";
- H << sp;
- H.inc();
-
- H << nl << "virtual void marshalKey(const Freeze::Value&, Freeze::Key&) const;";
-
- H << eb << ';';
+ string className = capitalizedMembers[i] + "Index";
+
+ string indexCompare =
+ getCompare(dict.indices[i], typeToString(indexTypes[i].type, false, indexTypes[i].metaData));
+
+ string indexCompareParams =
+ string("< ") + typeToString(indexTypes[i].type, false, indexTypes[i].metaData) + ", "
+ + className + ", " + indexCompare + " >";
+
+ H << sp << nl << "class " << dllExport << className
+ << " : public Freeze::MapIndex" << indexCompareParams;
+ H << sb;
+
+ H.dec();
+ H << sp << nl << "public:";
+ H << sp;
+ H.inc();
+ H << nl << capitalizedMembers[i] << "Index(const std::string&, const "
+ << indexCompare << "& = " << indexCompare << "());";
+
+ H << sp;
+
+ //
+ // Codec
+ //
+ H << nl << "static void write(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData)
+ << ", Freeze::Key&, const Ice::CommunicatorPtr&);";
+
+ H << nl << "static void read("
+ << typeToString(indexTypes[i].type, false, indexTypes[i].metaData)
+ << "&, const Freeze::Key&, const ::Ice::CommunicatorPtr&);";
+
+ H.dec();
+ H << sp << nl << "protected:";
+ H << sp;
+ H.inc();
+
+ H << nl << "virtual void marshalKey(const Freeze::Value&, Freeze::Key&) const;";
+
+ H << eb << ';';
}
//
@@ -409,14 +409,14 @@ writeDictWithIndicesH(const string& name, const Dict& dict,
H << nl << "std::vector<Freeze::MapIndexBasePtr> __indices;";
for(i = 0; i < capitalizedMembers.size(); ++i)
{
- string indexName = dict.indices[i].member;
- if(indexName.empty())
- {
- indexName = "index";
- }
- indexName = string("\"") + indexName + "\"";
-
- H << nl << "__indices.push_back(new " << capitalizedMembers[i] << "Index(" << indexName << "));";
+ string indexName = dict.indices[i].member;
+ if(indexName.empty())
+ {
+ indexName = "index";
+ }
+ indexName = string("\"") + indexName + "\"";
+
+ H << nl << "__indices.push_back(new " << capitalizedMembers[i] << "Index(" << indexName << "));";
}
H << nl << "this->_helper.reset(Freeze::MapHelper::create(__connection, __dbName, "
<< name + "KeyCodec::typeId(), "
@@ -433,35 +433,35 @@ writeDictWithIndicesH(const string& name, const Dict& dict,
//
for(i = 0; i < capitalizedMembers.size(); ++i)
{
- H << sp;
- H << nl << "iterator findBy" << capitalizedMembers[i]
- << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ", bool = true);";
- H << nl << "const_iterator findBy" << capitalizedMembers[i]
- << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ", bool = true) const;";
-
- H << nl << "iterator lowerBoundFor" << capitalizedMembers[i]
- << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ");";
- H << nl << "const_iterator lowerBoundFor" << capitalizedMembers[i]
- << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ") const;";
-
- H << nl << "iterator upperBoundFor" << capitalizedMembers[i]
- << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ");";
- H << nl << "const_iterator upperBoundFor" << capitalizedMembers[i]
- << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ") const;";
-
- H << nl << "std::pair<iterator, iterator> equalRangeFor"
- << capitalizedMembers[i] << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData)
- << ");";
-
- H << nl << "std::pair<const_iterator, const_iterator> equalRangeFor"
- << capitalizedMembers[i] << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData)
- << ") const;";
-
- string countFunction = dict.indices[i].member.empty() ? string("valueCount")
- : dict.indices[i].member + "Count";
-
- H << nl << "int " << countFunction
- << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ") const;";
+ H << sp;
+ H << nl << "iterator findBy" << capitalizedMembers[i]
+ << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ", bool = true);";
+ H << nl << "const_iterator findBy" << capitalizedMembers[i]
+ << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ", bool = true) const;";
+
+ H << nl << "iterator lowerBoundFor" << capitalizedMembers[i]
+ << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ");";
+ H << nl << "const_iterator lowerBoundFor" << capitalizedMembers[i]
+ << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ") const;";
+
+ H << nl << "iterator upperBoundFor" << capitalizedMembers[i]
+ << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ");";
+ H << nl << "const_iterator upperBoundFor" << capitalizedMembers[i]
+ << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ") const;";
+
+ H << nl << "std::pair<iterator, iterator> equalRangeFor"
+ << capitalizedMembers[i] << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData)
+ << ");";
+
+ H << nl << "std::pair<const_iterator, const_iterator> equalRangeFor"
+ << capitalizedMembers[i] << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData)
+ << ") const;";
+
+ string countFunction = dict.indices[i].member.empty() ? string("valueCount")
+ : dict.indices[i].member + "Count";
+
+ H << nl << "int " << countFunction
+ << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << ") const;";
}
H << eb << ';';
@@ -469,35 +469,35 @@ writeDictWithIndicesH(const string& name, const Dict& dict,
void
writeDictWithIndicesC(const string& name, const string& absolute, const Dict& dict,
- const vector<IndexType> indexTypes,
- const TypePtr& keyType, const StringList& keyMetaData, const TypePtr& valueType,
- const StringList& valueMetaData, Output& C)
+ const vector<IndexType> indexTypes,
+ const TypePtr& keyType, const StringList& keyMetaData, const TypePtr& valueType,
+ const StringList& valueMetaData, Output& C)
{
string compare = getCompare(dict, typeToString(keyType, false, keyMetaData));
string templateParams = string("< ") + typeToString(keyType, false, keyMetaData) + ", "
- + typeToString(valueType, false, valueMetaData) + ", " + name + "KeyCodec, "
- + name + "ValueCodec, " + compare + " >";
+ + typeToString(valueType, false, valueMetaData) + ", " + name + "KeyCodec, "
+ + name + "ValueCodec, " + compare + " >";
string keyCompareParams =
- string("< ") + typeToString(keyType, false, keyMetaData) + ", "
- + name + "KeyCodec, " + compare + " >";
+ string("< ") + typeToString(keyType, false, keyMetaData) + ", "
+ + name + "KeyCodec, " + compare + " >";
vector<string> capitalizedMembers;
size_t i;
for(i = 0; i < dict.indices.size(); ++i)
{
- const string& member = dict.indices[i].member;
- if(!member.empty())
- {
- string capitalizedMember = member;
- capitalizedMember[0] = toupper(capitalizedMember[0]);
- capitalizedMembers.push_back(capitalizedMember);
- }
- else
- {
- capitalizedMembers.push_back("Value");
- }
+ const string& member = dict.indices[i].member;
+ if(!member.empty())
+ {
+ string capitalizedMember = member;
+ capitalizedMember[0] = toupper(capitalizedMember[0]);
+ capitalizedMembers.push_back(capitalizedMember);
+ }
+ else
+ {
+ capitalizedMembers.push_back("Value");
+ }
}
@@ -506,119 +506,119 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di
//
for(i = 0; i < capitalizedMembers.size(); ++i)
{
- string className = capitalizedMembers[i] + "Index";
-
- string indexCompare =
- getCompare(dict.indices[i], typeToString(indexTypes[i].type, false, indexTypes[i].metaData));
-
- string indexCompareParams =
- string("< ") + typeToString(indexTypes[i].type, false, indexTypes[i].metaData) + ", "
- + className + ", " + indexCompare + " >";
-
- C << sp << nl << absolute << "::" << className << "::" << className
- << "(const std::string& __name, "
- << "const " << indexCompare << "& __compare)";
-
- C.inc();
- C << nl << ": Freeze::MapIndex"
- << indexCompareParams << "(__name, __compare)";
- C.dec();
- C << sb;
- C << eb;
-
- C << sp << nl << "void"
- << nl << absolute << "::" << className << "::"
- << "marshalKey(const Freeze::Value& __v, Freeze::Key& __k) const";
- C << sb;
-
- bool optimize = false;
-
- if(dict.indices[i].member.empty() && dict.indices[i].caseSensitive)
- {
- optimize = true;
- C << nl << "__k = __v;";
- }
- else
- {
- //
- // Can't optimize
- //
- C << nl << typeToString(valueType, false, valueMetaData) << " __x;";
- C << nl << absolute << "ValueCodec::read(__x, __v, _communicator);";
- string param = "__x";
-
- if(!dict.indices[i].member.empty())
- {
- if(ClassDeclPtr::dynamicCast(valueType) != 0)
- {
- param += "->" + dict.indices[i].member;
- }
- else
- {
- param += "." + dict.indices[i].member;
- }
- }
- C << nl << "write(" << param << ", __k, _communicator);";
- }
- C << eb;
-
- C << sp << nl << "void"
- << nl << absolute << "::" << className << "::"
- << "write(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData)
- << " __index, Freeze::Key& __bytes, const Ice::CommunicatorPtr& __communicator)";
- C << sb;
-
- if(optimize)
- {
- C << nl << absolute << "ValueCodec::write(__index, __bytes, __communicator);";
- }
- else
- {
- assert(!indexTypes[i].type->usesClasses());
-
- C << nl << "IceInternal::InstancePtr __instance = IceInternal::getInstance(__communicator);";
- C << nl << "IceInternal::BasicStream __stream(__instance.get());";
-
- string valueS;
- if(dict.indices[i].caseSensitive)
- {
- valueS = "__index";
- }
- else
- {
- C << nl << typeToString(indexTypes[i].type, false, indexTypes[i].metaData)
- << " __lowerCaseIndex = __index;";
- C << nl << "std::transform(__lowerCaseIndex.begin(), __lowerCaseIndex.end(), __lowerCaseIndex.begin(), tolower);";
- valueS = "__lowerCaseIndex";
- }
-
- writeMarshalUnmarshalCode(C, indexTypes[i].type, valueS, true, "__stream", false, indexTypes[i].metaData);
- C << nl << "::std::vector<Ice::Byte>(__stream.b.begin(), __stream.b.end()).swap(__bytes);";
- }
- C << eb;
-
- C << sp << nl << "void"
- << nl << absolute << "::" << className << "::"
- << "read(" << typeToString(indexTypes[i].type, false, indexTypes[i].metaData)
- << "& __index, const Freeze::Key& __bytes, const Ice::CommunicatorPtr& __communicator)";
- C << sb;
-
- if(optimize)
- {
- C << nl << absolute << "ValueCodec::read(__index, __bytes, __communicator);";
- }
- else
- {
- C << nl << "IceInternal::InstancePtr __instance = IceInternal::getInstance(__communicator);";
- C << nl << "IceInternal::BasicStream __stream(__instance.get());";
-
- C << nl << "__stream.b.resize(__bytes.size());";
- C << nl << "::memcpy(&__stream.b[0], &__bytes[0], __bytes.size());";
- C << nl << "__stream.i = __stream.b.begin();";
- writeMarshalUnmarshalCode(C, indexTypes[i].type, "__index", false, "__stream", false,
- indexTypes[i].metaData);
- }
- C << eb;
+ string className = capitalizedMembers[i] + "Index";
+
+ string indexCompare =
+ getCompare(dict.indices[i], typeToString(indexTypes[i].type, false, indexTypes[i].metaData));
+
+ string indexCompareParams =
+ string("< ") + typeToString(indexTypes[i].type, false, indexTypes[i].metaData) + ", "
+ + className + ", " + indexCompare + " >";
+
+ C << sp << nl << absolute << "::" << className << "::" << className
+ << "(const std::string& __name, "
+ << "const " << indexCompare << "& __compare)";
+
+ C.inc();
+ C << nl << ": Freeze::MapIndex"
+ << indexCompareParams << "(__name, __compare)";
+ C.dec();
+ C << sb;
+ C << eb;
+
+ C << sp << nl << "void"
+ << nl << absolute << "::" << className << "::"
+ << "marshalKey(const Freeze::Value& __v, Freeze::Key& __k) const";
+ C << sb;
+
+ bool optimize = false;
+
+ if(dict.indices[i].member.empty() && dict.indices[i].caseSensitive)
+ {
+ optimize = true;
+ C << nl << "__k = __v;";
+ }
+ else
+ {
+ //
+ // Can't optimize
+ //
+ C << nl << typeToString(valueType, false, valueMetaData) << " __x;";
+ C << nl << absolute << "ValueCodec::read(__x, __v, _communicator);";
+ string param = "__x";
+
+ if(!dict.indices[i].member.empty())
+ {
+ if(ClassDeclPtr::dynamicCast(valueType) != 0)
+ {
+ param += "->" + dict.indices[i].member;
+ }
+ else
+ {
+ param += "." + dict.indices[i].member;
+ }
+ }
+ C << nl << "write(" << param << ", __k, _communicator);";
+ }
+ C << eb;
+
+ C << sp << nl << "void"
+ << nl << absolute << "::" << className << "::"
+ << "write(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData)
+ << " __index, Freeze::Key& __bytes, const Ice::CommunicatorPtr& __communicator)";
+ C << sb;
+
+ if(optimize)
+ {
+ C << nl << absolute << "ValueCodec::write(__index, __bytes, __communicator);";
+ }
+ else
+ {
+ assert(!indexTypes[i].type->usesClasses());
+
+ C << nl << "IceInternal::InstancePtr __instance = IceInternal::getInstance(__communicator);";
+ C << nl << "IceInternal::BasicStream __stream(__instance.get());";
+
+ string valueS;
+ if(dict.indices[i].caseSensitive)
+ {
+ valueS = "__index";
+ }
+ else
+ {
+ C << nl << typeToString(indexTypes[i].type, false, indexTypes[i].metaData)
+ << " __lowerCaseIndex = __index;";
+ C << nl << "std::transform(__lowerCaseIndex.begin(), __lowerCaseIndex.end(), __lowerCaseIndex.begin(), tolower);";
+ valueS = "__lowerCaseIndex";
+ }
+
+ writeMarshalUnmarshalCode(C, indexTypes[i].type, valueS, true, "__stream", false, indexTypes[i].metaData);
+ C << nl << "::std::vector<Ice::Byte>(__stream.b.begin(), __stream.b.end()).swap(__bytes);";
+ }
+ C << eb;
+
+ C << sp << nl << "void"
+ << nl << absolute << "::" << className << "::"
+ << "read(" << typeToString(indexTypes[i].type, false, indexTypes[i].metaData)
+ << "& __index, const Freeze::Key& __bytes, const Ice::CommunicatorPtr& __communicator)";
+ C << sb;
+
+ if(optimize)
+ {
+ C << nl << absolute << "ValueCodec::read(__index, __bytes, __communicator);";
+ }
+ else
+ {
+ C << nl << "IceInternal::InstancePtr __instance = IceInternal::getInstance(__communicator);";
+ C << nl << "IceInternal::BasicStream __stream(__instance.get());";
+
+ C << nl << "__stream.b.resize(__bytes.size());";
+ C << nl << "::memcpy(&__stream.b[0], &__bytes[0], __bytes.size());";
+ C << nl << "__stream.i = __stream.b.begin();";
+ writeMarshalUnmarshalCode(C, indexTypes[i].type, "__index", false, "__stream", false,
+ indexTypes[i].metaData);
+ }
+ C << eb;
}
//
@@ -637,14 +637,14 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di
C << nl << "std::vector<Freeze::MapIndexBasePtr> __indices;";
for(i = 0; i < capitalizedMembers.size(); ++i)
{
- string indexName = dict.indices[i].member;
- if(indexName.empty())
- {
- indexName = "index";
- }
- indexName = string("\"") + indexName + "\"";
-
- C << nl << "__indices.push_back(new " << capitalizedMembers[i] << "Index(" << indexName << "));";
+ string indexName = dict.indices[i].member;
+ if(indexName.empty())
+ {
+ indexName = "index";
+ }
+ indexName = string("\"") + indexName + "\"";
+
+ C << nl << "__indices.push_back(new " << capitalizedMembers[i] << "Index(" << indexName << "));";
}
C << nl << "_helper.reset(Freeze::MapHelper::create(__connection, __dbName, "
<< absolute + "KeyCodec::typeId(), "
@@ -655,108 +655,108 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di
// Find and count functions
//
for(i = 0; i < capitalizedMembers.size(); ++i)
- {
- string indexClassName = capitalizedMembers[i] + "Index";
-
- string indexName = dict.indices[i].member;
- if(indexName.empty())
- {
- indexName = "index";
- }
- indexName = string("\"") + indexName + "\"";
-
- C << sp << nl << absolute << "::iterator"
- << nl << absolute << "::" << "findBy" << capitalizedMembers[i]
- << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData)
- << " __index, bool __onlyDups)";
- C << sb;
- C << nl << "Freeze::Key __bytes;";
- C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);";
- C << nl << "return iterator(_helper->index(" << indexName
- << ")->untypedFind(__bytes, false, __onlyDups), _communicator);";
- C << eb;
-
- C << sp << nl << absolute << "::const_iterator"
- << nl << absolute << "::" << "findBy" << capitalizedMembers[i]
- << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData)
- << " __index, bool __onlyDups) const";
- C << sb;
- C << nl << "Freeze::Key __bytes;";
- C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);";
- C << nl << "return const_iterator(_helper->index(" << indexName
- << ")->untypedFind(__bytes, true, __onlyDups), _communicator);";
- C << eb;
-
- C << sp << nl << absolute << "::iterator"
- << nl << absolute << "::" << "lowerBoundFor" << capitalizedMembers[i]
- << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index)";
- C << sb;
- C << nl << "Freeze::Key __bytes;";
- C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);";
- C << nl << "return iterator(_helper->index(" << indexName
- << ")->untypedLowerBound(__bytes, false), _communicator);";
- C << eb;
-
- C << sp << nl << absolute << "::const_iterator"
- << nl << absolute << "::" << "lowerBoundFor" << capitalizedMembers[i]
- << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index) const";
- C << sb;
- C << nl << "Freeze::Key __bytes;";
- C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);";
- C << nl << "return const_iterator(_helper->index(" << indexName
- << ")->untypedLowerBound(__bytes, true), _communicator);";
- C << eb;
-
- C << sp << nl << absolute << "::iterator"
- << nl << absolute << "::" << "upperBoundFor" << capitalizedMembers[i]
- << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index)";
- C << sb;
- C << nl << "Freeze::Key __bytes;";
- C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);";
- C << nl << "return iterator(_helper->index(" << indexName
- << ")->untypedUpperBound(__bytes, false), _communicator);";
- C << eb;
-
- C << sp << nl << absolute << "::const_iterator"
- << nl << absolute << "::" << "upperBoundFor" << capitalizedMembers[i]
- << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index) const";
- C << sb;
- C << nl << "Freeze::Key __bytes;";
- C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);";
- C << nl << "return const_iterator(_helper->index(" << indexName
- << ")->untypedUpperBound(__bytes, true), _communicator);";
- C << eb;
-
- C << sp << nl << "std::pair<" << absolute << "::iterator, "
- << absolute << "::iterator>"
- << nl << absolute << "::" << "equalRangeFor" << capitalizedMembers[i]
- << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index)";
- C << sb;
- C << nl << "return std::make_pair(lowerBoundFor" << capitalizedMembers[i]
- << "(__index), upperBoundFor" << capitalizedMembers[i] << "(__index));";
- C << eb;
-
- C << sp << nl << "std::pair<" << absolute << "::const_iterator, "
- << absolute << "::const_iterator>"
- << nl << absolute << "::" << "equalRangeFor" << capitalizedMembers[i]
- << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index) const";
- C << sb;
- C << nl << "return std::make_pair(lowerBoundFor" << capitalizedMembers[i]
- << "(__index), upperBoundFor" << capitalizedMembers[i] << "(__index));";
- C << eb;
-
- string countFunction = dict.indices[i].member.empty() ? string("valueCount")
- : dict.indices[i].member + "Count";
-
- C << sp << nl << "int"
- << nl << absolute << "::" << countFunction
- << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index) const";
- C << sb;
- C << nl << "Freeze::Key __bytes;";
- C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);";
- C << nl << "return _helper->index(" << indexName
- << ")->untypedCount(__bytes);";
- C << eb;
+ {
+ string indexClassName = capitalizedMembers[i] + "Index";
+
+ string indexName = dict.indices[i].member;
+ if(indexName.empty())
+ {
+ indexName = "index";
+ }
+ indexName = string("\"") + indexName + "\"";
+
+ C << sp << nl << absolute << "::iterator"
+ << nl << absolute << "::" << "findBy" << capitalizedMembers[i]
+ << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData)
+ << " __index, bool __onlyDups)";
+ C << sb;
+ C << nl << "Freeze::Key __bytes;";
+ C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);";
+ C << nl << "return iterator(_helper->index(" << indexName
+ << ")->untypedFind(__bytes, false, __onlyDups), _communicator);";
+ C << eb;
+
+ C << sp << nl << absolute << "::const_iterator"
+ << nl << absolute << "::" << "findBy" << capitalizedMembers[i]
+ << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData)
+ << " __index, bool __onlyDups) const";
+ C << sb;
+ C << nl << "Freeze::Key __bytes;";
+ C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);";
+ C << nl << "return const_iterator(_helper->index(" << indexName
+ << ")->untypedFind(__bytes, true, __onlyDups), _communicator);";
+ C << eb;
+
+ C << sp << nl << absolute << "::iterator"
+ << nl << absolute << "::" << "lowerBoundFor" << capitalizedMembers[i]
+ << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index)";
+ C << sb;
+ C << nl << "Freeze::Key __bytes;";
+ C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);";
+ C << nl << "return iterator(_helper->index(" << indexName
+ << ")->untypedLowerBound(__bytes, false), _communicator);";
+ C << eb;
+
+ C << sp << nl << absolute << "::const_iterator"
+ << nl << absolute << "::" << "lowerBoundFor" << capitalizedMembers[i]
+ << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index) const";
+ C << sb;
+ C << nl << "Freeze::Key __bytes;";
+ C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);";
+ C << nl << "return const_iterator(_helper->index(" << indexName
+ << ")->untypedLowerBound(__bytes, true), _communicator);";
+ C << eb;
+
+ C << sp << nl << absolute << "::iterator"
+ << nl << absolute << "::" << "upperBoundFor" << capitalizedMembers[i]
+ << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index)";
+ C << sb;
+ C << nl << "Freeze::Key __bytes;";
+ C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);";
+ C << nl << "return iterator(_helper->index(" << indexName
+ << ")->untypedUpperBound(__bytes, false), _communicator);";
+ C << eb;
+
+ C << sp << nl << absolute << "::const_iterator"
+ << nl << absolute << "::" << "upperBoundFor" << capitalizedMembers[i]
+ << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index) const";
+ C << sb;
+ C << nl << "Freeze::Key __bytes;";
+ C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);";
+ C << nl << "return const_iterator(_helper->index(" << indexName
+ << ")->untypedUpperBound(__bytes, true), _communicator);";
+ C << eb;
+
+ C << sp << nl << "std::pair<" << absolute << "::iterator, "
+ << absolute << "::iterator>"
+ << nl << absolute << "::" << "equalRangeFor" << capitalizedMembers[i]
+ << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index)";
+ C << sb;
+ C << nl << "return std::make_pair(lowerBoundFor" << capitalizedMembers[i]
+ << "(__index), upperBoundFor" << capitalizedMembers[i] << "(__index));";
+ C << eb;
+
+ C << sp << nl << "std::pair<" << absolute << "::const_iterator, "
+ << absolute << "::const_iterator>"
+ << nl << absolute << "::" << "equalRangeFor" << capitalizedMembers[i]
+ << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index) const";
+ C << sb;
+ C << nl << "return std::make_pair(lowerBoundFor" << capitalizedMembers[i]
+ << "(__index), upperBoundFor" << capitalizedMembers[i] << "(__index));";
+ C << eb;
+
+ string countFunction = dict.indices[i].member.empty() ? string("valueCount")
+ : dict.indices[i].member + "Count";
+
+ C << sp << nl << "int"
+ << nl << absolute << "::" << countFunction
+ << "(" << inputTypeToString(indexTypes[i].type, false, indexTypes[i].metaData) << " __index) const";
+ C << sb;
+ C << nl << "Freeze::Key __bytes;";
+ C << nl << indexClassName << "::" << "write(__index, __bytes, _communicator);";
+ C << nl << "return _helper->index(" << indexName
+ << ")->untypedCount(__bytes);";
+ C << eb;
}
}
@@ -767,42 +767,42 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c
string absolute = dict.name;
if(absolute.find("::") == 0)
{
- absolute.erase(0, 2);
+ absolute.erase(0, 2);
}
string name = absolute;
vector<string> scope;
string::size_type pos;
while((pos = name.find("::")) != string::npos)
{
- string s = name.substr(0, pos);
- name.erase(0, pos + 2);
-
- if(!checkIdentifier(n, absolute, s))
- {
- return false;
- }
-
- scope.push_back(s);
+ string s = name.substr(0, pos);
+ name.erase(0, pos + 2);
+
+ if(!checkIdentifier(n, absolute, s))
+ {
+ return false;
+ }
+
+ scope.push_back(s);
}
if(!checkIdentifier(n, absolute, name))
{
- return false;
+ return false;
}
TypeList keyTypes = u->lookupType(dict.key, false);
if(keyTypes.empty())
{
- cerr << n << ": `" << dict.key << "' is not a valid type" << endl;
- return false;
+ cerr << n << ": `" << dict.key << "' is not a valid type" << endl;
+ return false;
}
TypePtr keyType = keyTypes.front();
TypeList valueTypes = u->lookupType(dict.value, false);
if(valueTypes.empty())
{
- cerr << n << ": `" << dict.value << "' is not a valid type" << endl;
- return false;
+ cerr << n << ": `" << dict.value << "' is not a valid type" << endl;
+ return false;
}
TypePtr valueType = valueTypes.front();
@@ -810,8 +810,8 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c
for(q = scope.begin(); q != scope.end(); ++q)
{
- H << sp;
- H << nl << "namespace " << *q << nl << '{';
+ H << sp;
+ H << nl << "namespace " << *q << nl << '{';
}
writeCodecH(keyType, dict.keyMetaData, name + "KeyCodec", "Key", H, dllExport);
@@ -821,127 +821,127 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c
if(dict.indices.size() == 0)
{
- string compare = getCompare(dict, typeToString(keyType, false, dict.keyMetaData));
+ string compare = getCompare(dict, typeToString(keyType, false, dict.keyMetaData));
- H << sp << nl << "typedef Freeze::Map< " << typeToString(keyType, false, dict.keyMetaData)
- << ", " << typeToString(valueType, false, dict.valueMetaData) << ", "
- << name << "KeyCodec, " << name << "ValueCodec, " << compare
- << " > " << name << ";";
+ H << sp << nl << "typedef Freeze::Map< " << typeToString(keyType, false, dict.keyMetaData)
+ << ", " << typeToString(valueType, false, dict.valueMetaData) << ", "
+ << name << "KeyCodec, " << name << "ValueCodec, " << compare
+ << " > " << name << ";";
}
else
{
- for(vector<DictIndex>::const_iterator p = dict.indices.begin();
- p != dict.indices.end(); ++p)
- {
- const DictIndex& index = *p;
- if(index.member.empty())
- {
- if(dict.indices.size() > 1)
- {
- cerr << n << ": bad index for dictionary `" << dict.name << "'" << endl;
- return false;
- }
-
- if(!Dictionary::legalKeyType(valueType))
- {
- cerr << n << ": `" << dict.value << "' is not a valid index type" << endl;
- return false;
- }
-
-
- if(index.caseSensitive == false)
- {
- //
- // Let's check value is a string
- //
-
- BuiltinPtr builtInType = BuiltinPtr::dynamicCast(valueType);
-
- if(builtInType == 0 || builtInType->kind() != Builtin::KindString)
- {
- cerr << n << ": VALUE is a `" << dict.value << "', not a string" << endl;
- return false;
- }
- }
- IndexType iType;
- iType.type = valueType;
- iType.metaData = dict.valueMetaData;
- indexTypes.push_back(iType);
- }
- else
- {
- DataMemberPtr dataMember = 0;
- DataMemberList dataMembers;
-
- ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(valueType);
- if(classDecl != 0)
- {
- dataMembers = classDecl->definition()->allDataMembers();
- }
- else
- {
- StructPtr structDecl = StructPtr::dynamicCast(valueType);
- if(structDecl == 0)
- {
- cerr << n << ": `" << dict.value << "' is neither a class nor a struct." << endl;
- return false;
- }
- dataMembers = structDecl->dataMembers();
- }
- DataMemberList::const_iterator d = dataMembers.begin();
- while(d != dataMembers.end() && dataMember == 0)
- {
- if((*d)->name() == index.member)
- {
- dataMember = *d;
- }
- else
- {
- ++d;
- }
- }
-
- if(dataMember == 0)
- {
- cerr << n << ": The value of `" << dict.name
- << "' has no data member named `" << index.member << "'" << endl;
- return false;
- }
-
- TypePtr dataMemberType = dataMember->type();
-
- if(!Dictionary::legalKeyType(dataMemberType))
- {
- cerr << n << ": `" << index.member << "' cannot be used as an index" << endl;
- return false;
- }
-
- if(index.caseSensitive == false)
- {
- //
- // Let's check member is a string
- //
- BuiltinPtr memberType = BuiltinPtr::dynamicCast(dataMemberType);
- if(memberType == 0 || memberType->kind() != Builtin::KindString)
- {
- cerr << n << ": `" << index.member << "' is not a string " << endl;
- return false;
- }
- }
- IndexType iType;
- iType.type = dataMemberType;
- indexTypes.push_back(iType);
- }
- }
- writeDictWithIndicesH(name, dict, indexTypes, keyType, dict.keyMetaData, valueType, dict.valueMetaData, H,
- dllExport);
+ for(vector<DictIndex>::const_iterator p = dict.indices.begin();
+ p != dict.indices.end(); ++p)
+ {
+ const DictIndex& index = *p;
+ if(index.member.empty())
+ {
+ if(dict.indices.size() > 1)
+ {
+ cerr << n << ": bad index for dictionary `" << dict.name << "'" << endl;
+ return false;
+ }
+
+ if(!Dictionary::legalKeyType(valueType))
+ {
+ cerr << n << ": `" << dict.value << "' is not a valid index type" << endl;
+ return false;
+ }
+
+
+ if(index.caseSensitive == false)
+ {
+ //
+ // Let's check value is a string
+ //
+
+ BuiltinPtr builtInType = BuiltinPtr::dynamicCast(valueType);
+
+ if(builtInType == 0 || builtInType->kind() != Builtin::KindString)
+ {
+ cerr << n << ": VALUE is a `" << dict.value << "', not a string" << endl;
+ return false;
+ }
+ }
+ IndexType iType;
+ iType.type = valueType;
+ iType.metaData = dict.valueMetaData;
+ indexTypes.push_back(iType);
+ }
+ else
+ {
+ DataMemberPtr dataMember = 0;
+ DataMemberList dataMembers;
+
+ ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(valueType);
+ if(classDecl != 0)
+ {
+ dataMembers = classDecl->definition()->allDataMembers();
+ }
+ else
+ {
+ StructPtr structDecl = StructPtr::dynamicCast(valueType);
+ if(structDecl == 0)
+ {
+ cerr << n << ": `" << dict.value << "' is neither a class nor a struct." << endl;
+ return false;
+ }
+ dataMembers = structDecl->dataMembers();
+ }
+ DataMemberList::const_iterator d = dataMembers.begin();
+ while(d != dataMembers.end() && dataMember == 0)
+ {
+ if((*d)->name() == index.member)
+ {
+ dataMember = *d;
+ }
+ else
+ {
+ ++d;
+ }
+ }
+
+ if(dataMember == 0)
+ {
+ cerr << n << ": The value of `" << dict.name
+ << "' has no data member named `" << index.member << "'" << endl;
+ return false;
+ }
+
+ TypePtr dataMemberType = dataMember->type();
+
+ if(!Dictionary::legalKeyType(dataMemberType))
+ {
+ cerr << n << ": `" << index.member << "' cannot be used as an index" << endl;
+ return false;
+ }
+
+ if(index.caseSensitive == false)
+ {
+ //
+ // Let's check member is a string
+ //
+ BuiltinPtr memberType = BuiltinPtr::dynamicCast(dataMemberType);
+ if(memberType == 0 || memberType->kind() != Builtin::KindString)
+ {
+ cerr << n << ": `" << index.member << "' is not a string " << endl;
+ return false;
+ }
+ }
+ IndexType iType;
+ iType.type = dataMemberType;
+ indexTypes.push_back(iType);
+ }
+ }
+ writeDictWithIndicesH(name, dict, indexTypes, keyType, dict.keyMetaData, valueType, dict.valueMetaData, H,
+ dllExport);
}
for(q = scope.begin(); q != scope.end(); ++q)
{
- H << sp;
- H << nl << '}';
+ H << sp;
+ H << nl << '}';
}
writeCodecC(keyType, dict.keyMetaData, absolute + "KeyCodec", "Key", false, C);
@@ -949,8 +949,8 @@ writeDict(const string& n, UnitPtr& u, const Dict& dict, Output& H, Output& C, c
if(indexTypes.size() > 0)
{
- writeDictWithIndicesC(name, absolute, dict, indexTypes, keyType, dict.keyMetaData, valueType,
- dict.valueMetaData, C);
+ writeDictWithIndicesC(name, absolute, dict, indexTypes, keyType, dict.keyMetaData, valueType,
+ dict.valueMetaData, C);
}
return true;
@@ -995,7 +995,7 @@ writeIndexH(const string& memberTypeString, const string& name, Output& H, const
void
writeIndexC(const TypePtr& type, const TypePtr& memberType, const string& memberName,
- bool caseSensitive, const string& fullName, const string& name, Output& C)
+ bool caseSensitive, const string& fullName, const string& name, Output& C)
{
string inputType = inputTypeToString(memberType, false);
@@ -1057,13 +1057,13 @@ writeIndexC(const TypePtr& type, const TypePtr& memberType, const string& member
string valueS;
if(caseSensitive)
{
- valueS = "__index";
+ valueS = "__index";
}
else
{
- C << nl << typeToString(memberType, false) << " __lowerCaseIndex = __index;";
- C << nl << "std::transform(__lowerCaseIndex.begin(), __lowerCaseIndex.end(), __lowerCaseIndex.begin(), tolower);";
- valueS = "__lowerCaseIndex";
+ C << nl << typeToString(memberType, false) << " __lowerCaseIndex = __index;";
+ C << nl << "std::transform(__lowerCaseIndex.begin(), __lowerCaseIndex.end(), __lowerCaseIndex.begin(), tolower);";
+ valueS = "__lowerCaseIndex";
}
writeMarshalUnmarshalCode(C, memberType, valueS, true, "__stream", false);
@@ -1081,41 +1081,41 @@ writeIndex(const string& n, UnitPtr& u, const Index& index, Output& H, Output& C
string absolute = index.name;
if(absolute.find("::") == 0)
{
- absolute.erase(0, 2);
+ absolute.erase(0, 2);
}
string name = absolute;
vector<string> scope;
string::size_type pos;
while((pos = name.find("::")) != string::npos)
{
- string s = name.substr(0, pos);
- name.erase(0, pos + 2);
-
- if(!checkIdentifier(n, absolute, s))
- {
- return false;
- }
-
- scope.push_back(s);
+ string s = name.substr(0, pos);
+ name.erase(0, pos + 2);
+
+ if(!checkIdentifier(n, absolute, s))
+ {
+ return false;
+ }
+
+ scope.push_back(s);
}
if(!checkIdentifier(n, absolute, name))
{
- return false;
+ return false;
}
TypeList types = u->lookupType(index.type, false);
if(types.empty())
{
- cerr << n << ": `" << index.type << "' is not a valid type" << endl;
- return false;
+ cerr << n << ": `" << index.type << "' is not a valid type" << endl;
+ return false;
}
TypePtr type = types.front();
ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(type);
if(classDecl == 0)
{
- cerr << n << ": `" << index.type << "' is not a class" << endl;
+ cerr << n << ": `" << index.type << "' is not a class" << endl;
return false;
}
@@ -1124,49 +1124,49 @@ writeIndex(const string& n, UnitPtr& u, const Index& index, Output& H, Output& C
DataMemberList::const_iterator p = dataMembers.begin();
while(p != dataMembers.end() && dataMember == 0)
{
- if((*p)->name() == index.member)
- {
- dataMember = *p;
- }
- else
- {
- ++p;
- }
+ if((*p)->name() == index.member)
+ {
+ dataMember = *p;
+ }
+ else
+ {
+ ++p;
+ }
}
if(dataMember == 0)
{
- cerr << n << ": `" << index.type << "' has no data member named `" << index.member << "'" << endl;
+ cerr << n << ": `" << index.type << "' has no data member named `" << index.member << "'" << endl;
return false;
}
if(index.caseSensitive == false)
{
- //
- // Let's check member is a string
- //
- BuiltinPtr memberType = BuiltinPtr::dynamicCast(dataMember->type());
- if(memberType == 0 || memberType->kind() != Builtin::KindString)
- {
- cerr << n << ": `" << index.member << "'is not a string " << endl;
- return false;
- }
+ //
+ // Let's check member is a string
+ //
+ BuiltinPtr memberType = BuiltinPtr::dynamicCast(dataMember->type());
+ if(memberType == 0 || memberType->kind() != Builtin::KindString)
+ {
+ cerr << n << ": `" << index.member << "'is not a string " << endl;
+ return false;
+ }
}
vector<string>::const_iterator q;
for(q = scope.begin(); q != scope.end(); ++q)
{
- H << sp;
- H << nl << "namespace " << *q << nl << '{';
+ H << sp;
+ H << nl << "namespace " << *q << nl << '{';
}
writeIndexH(inputTypeToString(dataMember->type(), false), name, H, dllExport);
for(q = scope.begin(); q != scope.end(); ++q)
{
- H << sp;
- H << nl << '}';
+ H << sp;
+ H << nl << '}';
}
writeIndexC(type, dataMember->type(), index.member, index.caseSensitive, absolute, name, C);
@@ -1203,21 +1203,21 @@ main(int argc, char* argv[])
}
catch(const IceUtil::BadOptException& e)
{
- cerr << argv[0] << ": " << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": " << e.reason << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(argv[0]);
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
string headerExtension = opts.optArg("header-ext");
@@ -1229,19 +1229,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D" + Preprocessor::addQuotes(*i);
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U" + Preprocessor::addQuotes(*i);
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I" + Preprocessor::addQuotes(*i);
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess= opts.isSet("E");
@@ -1254,330 +1254,330 @@ main(int argc, char* argv[])
optargs = opts.argVec("dict");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- string s = *i;
- s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
-
- Dict dict;
-
- string::size_type pos;
- pos = s.find(',');
- if(pos != string::npos)
- {
- dict.name = s.substr(0, pos);
- s.erase(0, pos + 1);
- }
- pos = s.find(',');
- if(pos != string::npos)
- {
- if(s.find("[\"") == 0)
- {
- string::size_type end = s.find("\"]");
- if(end != string::npos && end < pos)
- {
- dict.key = s.substr(end + 2, pos - end - 2);
- dict.keyMetaData.push_back(s.substr(2, end - 2));
- }
- else
- {
- dict.key = s.substr(0, pos);
- }
- }
- else
- {
- dict.key = s.substr(0, pos);
- }
- s.erase(0, pos + 1);
- }
- pos = s.find(',');
- if(pos == string::npos)
- {
- if(s.find("[\"") == 0)
- {
- string::size_type end = s.find("\"]");
- if(end != string::npos)
- {
- dict.value = s.substr(end + 2);
- dict.valueMetaData.push_back(s.substr(2, end - 2));
- }
- else
- {
- dict.value = s;
- }
- }
- else
- {
- dict.value = s;
- }
- dict.sort = false;
- }
- else
- {
- if(s.find("[\"") == 0)
- {
- string::size_type end = s.find("\"]");
- if(end != string::npos && end < pos)
- {
- dict.value = s.substr(end + 2, pos - end - 2);
- dict.valueMetaData.push_back(s.substr(2, end - 2));
- }
- else
- {
- dict.value = s.substr(0, pos);
- }
- }
- else
- {
- dict.value = s.substr(0, pos);
- }
- s.erase(0, pos + 1);
-
- pos = s.find(',');
- if(pos == string::npos)
- {
- if(s != "sort")
- {
- cerr << argv[0] << ": " << *i
- << ": nothing or ',sort' expected after value-type" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- dict.sort = true;
- }
- else
- {
- string sort = s.substr(0, pos);
- s.erase(0, pos + 1);
- if(sort != "sort")
- {
- cerr << argv[0] << ": " << *i
- << ": nothing or ',sort' expected after value-type" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- dict.sort = true;
- dict.userCompare = s;
- }
- }
-
- if(dict.name.empty())
- {
- cerr << argv[0] << ": " << *i << ": no name specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
-
- if(dict.key.empty())
- {
- cerr << argv[0] << ": " << *i << ": no key specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
-
- if(dict.value.empty())
- {
- cerr << argv[0] << ": " << *i << ": no value specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
-
- dicts.push_back(dict);
+ string s = *i;
+ s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
+
+ Dict dict;
+
+ string::size_type pos;
+ pos = s.find(',');
+ if(pos != string::npos)
+ {
+ dict.name = s.substr(0, pos);
+ s.erase(0, pos + 1);
+ }
+ pos = s.find(',');
+ if(pos != string::npos)
+ {
+ if(s.find("[\"") == 0)
+ {
+ string::size_type end = s.find("\"]");
+ if(end != string::npos && end < pos)
+ {
+ dict.key = s.substr(end + 2, pos - end - 2);
+ dict.keyMetaData.push_back(s.substr(2, end - 2));
+ }
+ else
+ {
+ dict.key = s.substr(0, pos);
+ }
+ }
+ else
+ {
+ dict.key = s.substr(0, pos);
+ }
+ s.erase(0, pos + 1);
+ }
+ pos = s.find(',');
+ if(pos == string::npos)
+ {
+ if(s.find("[\"") == 0)
+ {
+ string::size_type end = s.find("\"]");
+ if(end != string::npos)
+ {
+ dict.value = s.substr(end + 2);
+ dict.valueMetaData.push_back(s.substr(2, end - 2));
+ }
+ else
+ {
+ dict.value = s;
+ }
+ }
+ else
+ {
+ dict.value = s;
+ }
+ dict.sort = false;
+ }
+ else
+ {
+ if(s.find("[\"") == 0)
+ {
+ string::size_type end = s.find("\"]");
+ if(end != string::npos && end < pos)
+ {
+ dict.value = s.substr(end + 2, pos - end - 2);
+ dict.valueMetaData.push_back(s.substr(2, end - 2));
+ }
+ else
+ {
+ dict.value = s.substr(0, pos);
+ }
+ }
+ else
+ {
+ dict.value = s.substr(0, pos);
+ }
+ s.erase(0, pos + 1);
+
+ pos = s.find(',');
+ if(pos == string::npos)
+ {
+ if(s != "sort")
+ {
+ cerr << argv[0] << ": " << *i
+ << ": nothing or ',sort' expected after value-type" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ dict.sort = true;
+ }
+ else
+ {
+ string sort = s.substr(0, pos);
+ s.erase(0, pos + 1);
+ if(sort != "sort")
+ {
+ cerr << argv[0] << ": " << *i
+ << ": nothing or ',sort' expected after value-type" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ dict.sort = true;
+ dict.userCompare = s;
+ }
+ }
+
+ if(dict.name.empty())
+ {
+ cerr << argv[0] << ": " << *i << ": no name specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ if(dict.key.empty())
+ {
+ cerr << argv[0] << ": " << *i << ": no key specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ if(dict.value.empty())
+ {
+ cerr << argv[0] << ": " << *i << ": no value specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ dicts.push_back(dict);
}
vector<Index> indices;
optargs = opts.argVec("index");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- string s = *i;
- s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
-
- Index index;
-
- string::size_type pos;
- pos = s.find(',');
- if(pos != string::npos)
- {
- index.name = s.substr(0, pos);
- s.erase(0, pos + 1);
- }
- pos = s.find(',');
- if(pos != string::npos)
- {
- index.type = s.substr(0, pos);
- s.erase(0, pos + 1);
- }
- pos = s.find(',');
- string caseString;
- if(pos != string::npos)
- {
- index.member = s.substr(0, pos);
- s.erase(0, pos + 1);
- caseString = s;
- }
- else
- {
- index.member = s;
- caseString = "case-sensitive";
- }
-
- if(index.name.empty())
- {
- cerr << argv[0] << ": " << *i << ": no name specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
-
- if(index.type.empty())
- {
- cerr << argv[0] << ": " << *i << ": no type specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
-
- if(index.member.empty())
- {
- cerr << argv[0] << ": " << *i << ": no member specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
-
- if(caseString != "case-sensitive" && caseString != "case-insensitive")
- {
- cerr << argv[0] << ": " << *i << ": the case can be `case-sensitive' or `case-insensitive'" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- index.caseSensitive = (caseString == "case-sensitive");
-
- indices.push_back(index);
+ string s = *i;
+ s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
+
+ Index index;
+
+ string::size_type pos;
+ pos = s.find(',');
+ if(pos != string::npos)
+ {
+ index.name = s.substr(0, pos);
+ s.erase(0, pos + 1);
+ }
+ pos = s.find(',');
+ if(pos != string::npos)
+ {
+ index.type = s.substr(0, pos);
+ s.erase(0, pos + 1);
+ }
+ pos = s.find(',');
+ string caseString;
+ if(pos != string::npos)
+ {
+ index.member = s.substr(0, pos);
+ s.erase(0, pos + 1);
+ caseString = s;
+ }
+ else
+ {
+ index.member = s;
+ caseString = "case-sensitive";
+ }
+
+ if(index.name.empty())
+ {
+ cerr << argv[0] << ": " << *i << ": no name specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ if(index.type.empty())
+ {
+ cerr << argv[0] << ": " << *i << ": no type specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ if(index.member.empty())
+ {
+ cerr << argv[0] << ": " << *i << ": no member specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ if(caseString != "case-sensitive" && caseString != "case-insensitive")
+ {
+ cerr << argv[0] << ": " << *i << ": the case can be `case-sensitive' or `case-insensitive'" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ index.caseSensitive = (caseString == "case-sensitive");
+
+ indices.push_back(index);
}
optargs = opts.argVec("dict-index");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- string s = *i;
- s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
-
- string dictName;
- DictIndex index;
- index.sort = false;
- index.caseSensitive = true;
-
- string::size_type pos = s.find(',');
- if(pos == string::npos)
- {
- dictName = s;
- }
- else
- {
- dictName = s.substr(0, pos);
- s.erase(0, pos + 1);
-
- bool done = false;
- while(!done)
- {
- pos = s.find(',');
- if(pos == string::npos)
- {
- if(s == "sort")
- {
- index.sort = true;
- }
- else if(s == "case-sensitive")
- {
- index.caseSensitive = true;
- }
- else if(s == "case-insensitive")
- {
- index.caseSensitive = false;
- }
- else if(index.member.empty())
- {
- if(s == "\\sort")
- {
- index.member = "sort";
- }
- else
- {
- index.member = s;
- }
- }
- else
- {
- cerr << argv[0] << ": " << *i << ": syntax error" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- done = true;
- }
- else
- {
- string subs = s.substr(0, pos);
- s.erase(0, pos + 1);
-
- if(subs == "sort")
- {
- index.sort = true;
- index.userCompare = s;
- done = true;
- }
- else if(subs == "case-sensitive")
- {
- index.caseSensitive = true;
- }
- else if(subs == "case-insensitive")
- {
- index.caseSensitive = false;
- }
- else if(index.member.empty())
- {
- if(subs == "\\sort")
- {
- index.member = "sort";
- }
- else
- {
- index.member = subs;
- }
- }
- else
- {
- cerr << argv[0] << ": " << *i << ": syntax error" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- }
- }
- }
-
- if(dictName.empty())
- {
- cerr << argv[0] << ": " << *i << ": no dictionary specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
-
- bool found = false;
- for(vector<Dict>::iterator p = dicts.begin(); p != dicts.end(); ++p)
- {
- if(p->name == dictName)
- {
- if(find(p->indices.begin(), p->indices.end(), index) != p->indices.end())
- {
- cerr << argv[0] << ": --dict-index " << *i
- << ": this dict-index is defined twice" << endl;
- return EXIT_FAILURE;
- }
- p->indices.push_back(index);
- found = true;
- break;
- }
- }
- if(!found)
- {
- cerr << argv[0] << ": " << *i << ": unknown dictionary" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
+ string s = *i;
+ s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
+
+ string dictName;
+ DictIndex index;
+ index.sort = false;
+ index.caseSensitive = true;
+
+ string::size_type pos = s.find(',');
+ if(pos == string::npos)
+ {
+ dictName = s;
+ }
+ else
+ {
+ dictName = s.substr(0, pos);
+ s.erase(0, pos + 1);
+
+ bool done = false;
+ while(!done)
+ {
+ pos = s.find(',');
+ if(pos == string::npos)
+ {
+ if(s == "sort")
+ {
+ index.sort = true;
+ }
+ else if(s == "case-sensitive")
+ {
+ index.caseSensitive = true;
+ }
+ else if(s == "case-insensitive")
+ {
+ index.caseSensitive = false;
+ }
+ else if(index.member.empty())
+ {
+ if(s == "\\sort")
+ {
+ index.member = "sort";
+ }
+ else
+ {
+ index.member = s;
+ }
+ }
+ else
+ {
+ cerr << argv[0] << ": " << *i << ": syntax error" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ done = true;
+ }
+ else
+ {
+ string subs = s.substr(0, pos);
+ s.erase(0, pos + 1);
+
+ if(subs == "sort")
+ {
+ index.sort = true;
+ index.userCompare = s;
+ done = true;
+ }
+ else if(subs == "case-sensitive")
+ {
+ index.caseSensitive = true;
+ }
+ else if(subs == "case-insensitive")
+ {
+ index.caseSensitive = false;
+ }
+ else if(index.member.empty())
+ {
+ if(subs == "\\sort")
+ {
+ index.member = "sort";
+ }
+ else
+ {
+ index.member = subs;
+ }
+ }
+ else
+ {
+ cerr << argv[0] << ": " << *i << ": syntax error" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ }
+ }
+ }
+
+ if(dictName.empty())
+ {
+ cerr << argv[0] << ": " << *i << ": no dictionary specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ bool found = false;
+ for(vector<Dict>::iterator p = dicts.begin(); p != dicts.end(); ++p)
+ {
+ if(p->name == dictName)
+ {
+ if(find(p->indices.begin(), p->indices.end(), index) != p->indices.end())
+ {
+ cerr << argv[0] << ": --dict-index " << *i
+ << ": this dict-index is defined twice" << endl;
+ return EXIT_FAILURE;
+ }
+ p->indices.push_back(index);
+ found = true;
+ break;
+ }
+ }
+ if(!found)
+ {
+ cerr << argv[0] << ": " << *i << ": unknown dictionary" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
}
string output = opts.optArg("output-dir");
@@ -1590,16 +1590,16 @@ main(int argc, char* argv[])
if(dicts.empty() && indices.empty())
{
- cerr << argv[0] << ": no Freeze types specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": no Freeze types specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(args.empty())
{
- cerr << argv[0] << ": no file name base specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": no file name base specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
string fileH = args[0];
@@ -1609,8 +1609,8 @@ main(int argc, char* argv[])
fileC += "." + sourceExtension;
if(!output.empty())
{
- fileH = output + '/' + fileH;
- fileC = output + '/' + fileC;
+ fileH = output + '/' + fileH;
+ fileC = output + '/' + fileC;
}
UnitPtr u = Unit::createUnit(true, false, ice, caseSensitive);
@@ -1621,193 +1621,193 @@ main(int argc, char* argv[])
for(vector<string>::size_type idx = 1; idx < args.size(); ++idx)
{
- Preprocessor icecpp(argv[0], args[idx], cppArgs);
+ Preprocessor icecpp(argv[0], args[idx], cppArgs);
//
// Add an include file for each Slice file. Note that the .h extension
// is replaced with headerExtension later.
//
- includes.push_back(icecpp.getBaseName() + ".h");
-
- FILE* cppHandle = icecpp.preprocess(false);
-
- if(cppHandle == 0)
- {
- u->destroy();
- return EXIT_FAILURE;
- }
-
- if(preprocess)
- {
- char buf[4096];
- while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
- {
- if(fputs(buf, stdout) == EOF)
- {
- u->destroy();
- return EXIT_FAILURE;
- }
- }
- }
- else
- {
- status = u->parse(cppHandle, debug);
- }
-
- if(!icecpp.close())
- {
- u->destroy();
- return EXIT_FAILURE;
- }
+ includes.push_back(icecpp.getBaseName() + ".h");
+
+ FILE* cppHandle = icecpp.preprocess(false);
+
+ if(cppHandle == 0)
+ {
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+
+ if(preprocess)
+ {
+ char buf[4096];
+ while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
+ {
+ if(fputs(buf, stdout) == EOF)
+ {
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+ }
+ }
+ else
+ {
+ status = u->parse(cppHandle, debug);
+ }
+
+ if(!icecpp.close())
+ {
+ u->destroy();
+ return EXIT_FAILURE;
+ }
}
if(status == EXIT_SUCCESS && !preprocess)
{
- u->mergeModules();
- u->sort();
-
- {
- for(vector<string>::iterator p = includePaths.begin(); p != includePaths.end(); ++p)
- {
- if(p->length() && (*p)[p->length() - 1] != '/')
- {
- *p += '/';
- }
- }
- }
-
- Output H;
- H.open(fileH.c_str());
- if(!H)
- {
- cerr << argv[0] << ": can't open `" << fileH << "' for writing: " << strerror(errno) << endl;
- u->destroy();
- return EXIT_FAILURE;
- }
- printHeader(H);
- printFreezeTypes(H, dicts, indices);
-
- Output C;
- C.open(fileC.c_str());
- if(!C)
- {
- cerr << argv[0] << ": can't open `" << fileC << "' for writing: " << strerror(errno) << endl;
- u->destroy();
- return EXIT_FAILURE;
- }
- printHeader(C);
- printFreezeTypes(C, dicts, indices);
-
- for(vector<string>::const_iterator i = extraHeaders.begin(); i != extraHeaders.end(); ++i)
- {
- string hdr = *i;
- string guard;
- string::size_type pos = hdr.rfind(',');
- if(pos != string::npos)
- {
- hdr = i->substr(0, pos);
- guard = i->substr(pos + 1);
- }
- if(!guard.empty())
- {
- C << "\n#ifndef " << guard;
- C << "\n#define " << guard;
- }
- C << "\n#include <";
- if(!include.empty())
- {
- C << include << '/';
- }
- C << hdr << '>';
- if(!guard.empty())
- {
- C << "\n#endif";
- }
- }
-
- string s = fileH;
- transform(s.begin(), s.end(), s.begin(), ToIfdef());
- H << "\n#ifndef __" << s << "__";
- H << "\n#define __" << s << "__";
- H << '\n';
-
- if(dicts.size() > 0)
- {
- H << "\n#include <Freeze/Map.h>";
- }
-
- if(indices.size() > 0)
- {
- H << "\n#include <Freeze/Index.h>";
- }
-
-
- {
- for(StringList::const_iterator p = includes.begin(); p != includes.end(); ++p)
- {
- H << "\n#include <" << changeInclude(*p, includePaths) << "." + headerExtension + ">";
- }
- }
+ u->mergeModules();
+ u->sort();
+
+ {
+ for(vector<string>::iterator p = includePaths.begin(); p != includePaths.end(); ++p)
+ {
+ if(p->length() && (*p)[p->length() - 1] != '/')
+ {
+ *p += '/';
+ }
+ }
+ }
+
+ Output H;
+ H.open(fileH.c_str());
+ if(!H)
+ {
+ cerr << argv[0] << ": can't open `" << fileH << "' for writing: " << strerror(errno) << endl;
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+ printHeader(H);
+ printFreezeTypes(H, dicts, indices);
+
+ Output C;
+ C.open(fileC.c_str());
+ if(!C)
+ {
+ cerr << argv[0] << ": can't open `" << fileC << "' for writing: " << strerror(errno) << endl;
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+ printHeader(C);
+ printFreezeTypes(C, dicts, indices);
+
+ for(vector<string>::const_iterator i = extraHeaders.begin(); i != extraHeaders.end(); ++i)
+ {
+ string hdr = *i;
+ string guard;
+ string::size_type pos = hdr.rfind(',');
+ if(pos != string::npos)
+ {
+ hdr = i->substr(0, pos);
+ guard = i->substr(pos + 1);
+ }
+ if(!guard.empty())
+ {
+ C << "\n#ifndef " << guard;
+ C << "\n#define " << guard;
+ }
+ C << "\n#include <";
+ if(!include.empty())
+ {
+ C << include << '/';
+ }
+ C << hdr << '>';
+ if(!guard.empty())
+ {
+ C << "\n#endif";
+ }
+ }
+
+ string s = fileH;
+ transform(s.begin(), s.end(), s.begin(), ToIfdef());
+ H << "\n#ifndef __" << s << "__";
+ H << "\n#define __" << s << "__";
+ H << '\n';
+
+ if(dicts.size() > 0)
+ {
+ H << "\n#include <Freeze/Map.h>";
+ }
+
+ if(indices.size() > 0)
+ {
+ H << "\n#include <Freeze/Index.h>";
+ }
+
+
+ {
+ for(StringList::const_iterator p = includes.begin(); p != includes.end(); ++p)
+ {
+ H << "\n#include <" << changeInclude(*p, includePaths) << "." + headerExtension + ">";
+ }
+ }
C << "\n#include <Ice/BasicStream.h>";
- C << "\n#include <";
- if(include.size())
- {
- C << include << '/';
- }
- C << includeH << '>';
-
- printVersionCheck(H);
- printVersionCheck(C);
-
- printDllExportStuff(H, dllExport);
- if(dllExport.size())
- {
- dllExport += " ";
- }
-
- {
- for(vector<Dict>::const_iterator p = dicts.begin(); p != dicts.end(); ++p)
- {
- try
- {
- if(!writeDict(argv[0], u, *p, H, C, dllExport))
- {
- u->destroy();
- return EXIT_FAILURE;
- }
- }
- catch(...)
- {
- cerr << argv[0] << ": unknown exception" << endl;
- u->destroy();
- return EXIT_FAILURE;
- }
- }
-
-
- for(vector<Index>::const_iterator q = indices.begin(); q != indices.end(); ++q)
- {
- try
- {
- if(!writeIndex(argv[0], u, *q, H, C, dllExport))
- {
- u->destroy();
- return EXIT_FAILURE;
- }
- }
- catch(...)
- {
- cerr << argv[0] << ": unknown exception" << endl;
- u->destroy();
- return EXIT_FAILURE;
- }
- }
-
- }
-
- H << "\n\n#endif\n";
- C << '\n';
+ C << "\n#include <";
+ if(include.size())
+ {
+ C << include << '/';
+ }
+ C << includeH << '>';
+
+ printVersionCheck(H);
+ printVersionCheck(C);
+
+ printDllExportStuff(H, dllExport);
+ if(dllExport.size())
+ {
+ dllExport += " ";
+ }
+
+ {
+ for(vector<Dict>::const_iterator p = dicts.begin(); p != dicts.end(); ++p)
+ {
+ try
+ {
+ if(!writeDict(argv[0], u, *p, H, C, dllExport))
+ {
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+ }
+ catch(...)
+ {
+ cerr << argv[0] << ": unknown exception" << endl;
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+ }
+
+
+ for(vector<Index>::const_iterator q = indices.begin(); q != indices.end(); ++q)
+ {
+ try
+ {
+ if(!writeIndex(argv[0], u, *q, H, C, dllExport))
+ {
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+ }
+ catch(...)
+ {
+ cerr << argv[0] << ": unknown exception" << endl;
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+ }
+
+ }
+
+ H << "\n\n#endif\n";
+ C << '\n';
}
u->destroy();
diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp
index adf009ee4d6..bbca3691695 100644
--- a/cpp/src/slice2freezej/Main.cpp
+++ b/cpp/src/slice2freezej/Main.cpp
@@ -26,12 +26,12 @@ struct DictIndex
bool operator==(const DictIndex& rhs) const
{
- return member == rhs.member;
+ return member == rhs.member;
}
bool operator!=(const DictIndex& rhs) const
{
- return member != rhs.member;
+ return member != rhs.member;
}
};
@@ -82,49 +82,49 @@ FreezeGenerator::varToObject(const TypePtr& type, const string& param)
BuiltinPtr b = BuiltinPtr::dynamicCast(type);
if(b != 0)
{
- switch(b->kind())
- {
- case Builtin::KindByte:
- {
- result = string("new java.lang.Byte(") + param + ")";
- break;
- }
- case Builtin::KindBool:
- {
- result = string("new java.lang.Boolean(") + param + ")";
- break;
- }
- case Builtin::KindShort:
- {
- result = string("new java.lang.Short(") + param + ")";
- break;
- }
- case Builtin::KindInt:
- {
- result = string("new java.lang.Integer(") + param + ")";
- break;
- }
- case Builtin::KindLong:
- {
- result = string("new java.lang.Long(") + param + ")";
- break;
- }
- case Builtin::KindFloat:
- {
- result = string("new java.lang.Float(") + param + ")";
- break;
- }
- case Builtin::KindDouble:
- {
- result = string("new java.lang.Double(") + param + ")";
- break;
- }
- case Builtin::KindString:
- case Builtin::KindObject:
- case Builtin::KindObjectProxy:
- case Builtin::KindLocalObject:
- break;
- }
+ switch(b->kind())
+ {
+ case Builtin::KindByte:
+ {
+ result = string("new java.lang.Byte(") + param + ")";
+ break;
+ }
+ case Builtin::KindBool:
+ {
+ result = string("new java.lang.Boolean(") + param + ")";
+ break;
+ }
+ case Builtin::KindShort:
+ {
+ result = string("new java.lang.Short(") + param + ")";
+ break;
+ }
+ case Builtin::KindInt:
+ {
+ result = string("new java.lang.Integer(") + param + ")";
+ break;
+ }
+ case Builtin::KindLong:
+ {
+ result = string("new java.lang.Long(") + param + ")";
+ break;
+ }
+ case Builtin::KindFloat:
+ {
+ result = string("new java.lang.Float(") + param + ")";
+ break;
+ }
+ case Builtin::KindDouble:
+ {
+ result = string("new java.lang.Double(") + param + ")";
+ break;
+ }
+ case Builtin::KindString:
+ case Builtin::KindObject:
+ case Builtin::KindObjectProxy:
+ case Builtin::KindLocalObject:
+ break;
+ }
}
return result;
}
@@ -137,49 +137,49 @@ FreezeGenerator::objectToVar(const TypePtr& type, const string& param)
BuiltinPtr b = BuiltinPtr::dynamicCast(type);
if(b != 0)
{
- switch(b->kind())
- {
- case Builtin::KindByte:
- {
- result = string("((java.lang.Byte)") + param + ").byteValue()";
- break;
- }
- case Builtin::KindBool:
- {
- result = string("((java.lang.Boolean)") + param + ").booleanValue()";
- break;
- }
- case Builtin::KindShort:
- {
- result = string("((java.lang.Short)") + param + ").shortValue()";
- break;
- }
- case Builtin::KindInt:
- {
- result = string("((java.lang.Integer)") + param + ").intValue()";
- break;
- }
- case Builtin::KindLong:
- {
- result = string("((java.lang.Long)") + param + ").longValue()";
- break;
- }
- case Builtin::KindFloat:
- {
- result = string("((java.lang.Float)") + param + ").floatValue()";
- break;
- }
- case Builtin::KindDouble:
- {
- result = string("((java.lang.Double)") + param + ").doubleValue()";
- break;
- }
- case Builtin::KindString:
- case Builtin::KindObject:
- case Builtin::KindObjectProxy:
- case Builtin::KindLocalObject:
- break;
- }
+ switch(b->kind())
+ {
+ case Builtin::KindByte:
+ {
+ result = string("((java.lang.Byte)") + param + ").byteValue()";
+ break;
+ }
+ case Builtin::KindBool:
+ {
+ result = string("((java.lang.Boolean)") + param + ").booleanValue()";
+ break;
+ }
+ case Builtin::KindShort:
+ {
+ result = string("((java.lang.Short)") + param + ").shortValue()";
+ break;
+ }
+ case Builtin::KindInt:
+ {
+ result = string("((java.lang.Integer)") + param + ").intValue()";
+ break;
+ }
+ case Builtin::KindLong:
+ {
+ result = string("((java.lang.Long)") + param + ").longValue()";
+ break;
+ }
+ case Builtin::KindFloat:
+ {
+ result = string("((java.lang.Float)") + param + ").floatValue()";
+ break;
+ }
+ case Builtin::KindDouble:
+ {
+ result = string("((java.lang.Double)") + param + ").doubleValue()";
+ break;
+ }
+ case Builtin::KindString:
+ case Builtin::KindObject:
+ case Builtin::KindObjectProxy:
+ case Builtin::KindLocalObject:
+ break;
+ }
}
return result;
}
@@ -236,108 +236,108 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict)
for(i = 0; i < dict.indices.size(); ++i)
{
- const DictIndex& index = dict.indices[i];
- const string& member = index.member;
-
- if(index.member.empty())
- {
- if(dict.indices.size() > 1)
- {
- cerr << _prog << ": bad index for dictionary `" << dict.name << "'" << endl;
- return false;
- }
-
- if(!Dictionary::legalKeyType(valueType))
- {
- cerr << _prog << ": `" << dict.value << "' is not a valid index type" << endl;
- return false;
- }
-
- if(index.caseSensitive == false)
- {
- //
- // Let's check value is a string
- //
-
- BuiltinPtr builtInType = BuiltinPtr::dynamicCast(valueType);
-
- if(builtInType == 0 || builtInType->kind() != Builtin::KindString)
- {
- cerr << _prog << ": VALUE is a `" << dict.value << "', not a string " << endl;
- return false;
- }
- }
- indexTypes.push_back(valueType);
- capitalizedMembers.push_back("Value");
- indexNames.push_back("index");
- }
- else
- {
- DataMemberPtr dataMember = 0;
- DataMemberList dataMembers;
-
- ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(valueType);
- if(classDecl != 0)
- {
- dataMembers = classDecl->definition()->allDataMembers();
- }
- else
- {
- StructPtr structDecl = StructPtr::dynamicCast(valueType);
- if(structDecl == 0)
- {
- cerr << _prog << ": `" << dict.value << "' is neither a class nor a struct." << endl;
- return false;
- }
- dataMembers = structDecl->dataMembers();
- }
- DataMemberList::const_iterator q = dataMembers.begin();
- while(q != dataMembers.end() && dataMember == 0)
- {
- if((*q)->name() == index.member)
- {
- dataMember = *q;
- }
- else
- {
- ++q;
- }
- }
-
- if(dataMember == 0)
- {
- cerr << _prog << ": The value of `" << dict.name
- << "' has no data member named `" << index.member << "'" << endl;
- return false;
- }
-
- TypePtr dataMemberType = dataMember->type();
-
- if(!Dictionary::legalKeyType(dataMemberType))
- {
- cerr << _prog << ": `" << index.member << "' cannot be used as an index" << endl;
- return false;
- }
-
- if(index.caseSensitive == false)
- {
- //
- // Let's check member is a string
- //
- BuiltinPtr memberType = BuiltinPtr::dynamicCast(dataMemberType);
- if(memberType == 0 || memberType->kind() != Builtin::KindString)
- {
- cerr << _prog << ": `" << index.member << "' is not a string " << endl;
- return false;
- }
- }
- indexTypes.push_back(dataMemberType);
-
- string capitalizedMember = member;
- capitalizedMember[0] = toupper(capitalizedMember[0]);
- capitalizedMembers.push_back(capitalizedMember);
- indexNames.push_back(member);
- }
+ const DictIndex& index = dict.indices[i];
+ const string& member = index.member;
+
+ if(index.member.empty())
+ {
+ if(dict.indices.size() > 1)
+ {
+ cerr << _prog << ": bad index for dictionary `" << dict.name << "'" << endl;
+ return false;
+ }
+
+ if(!Dictionary::legalKeyType(valueType))
+ {
+ cerr << _prog << ": `" << dict.value << "' is not a valid index type" << endl;
+ return false;
+ }
+
+ if(index.caseSensitive == false)
+ {
+ //
+ // Let's check value is a string
+ //
+
+ BuiltinPtr builtInType = BuiltinPtr::dynamicCast(valueType);
+
+ if(builtInType == 0 || builtInType->kind() != Builtin::KindString)
+ {
+ cerr << _prog << ": VALUE is a `" << dict.value << "', not a string " << endl;
+ return false;
+ }
+ }
+ indexTypes.push_back(valueType);
+ capitalizedMembers.push_back("Value");
+ indexNames.push_back("index");
+ }
+ else
+ {
+ DataMemberPtr dataMember = 0;
+ DataMemberList dataMembers;
+
+ ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(valueType);
+ if(classDecl != 0)
+ {
+ dataMembers = classDecl->definition()->allDataMembers();
+ }
+ else
+ {
+ StructPtr structDecl = StructPtr::dynamicCast(valueType);
+ if(structDecl == 0)
+ {
+ cerr << _prog << ": `" << dict.value << "' is neither a class nor a struct." << endl;
+ return false;
+ }
+ dataMembers = structDecl->dataMembers();
+ }
+ DataMemberList::const_iterator q = dataMembers.begin();
+ while(q != dataMembers.end() && dataMember == 0)
+ {
+ if((*q)->name() == index.member)
+ {
+ dataMember = *q;
+ }
+ else
+ {
+ ++q;
+ }
+ }
+
+ if(dataMember == 0)
+ {
+ cerr << _prog << ": The value of `" << dict.name
+ << "' has no data member named `" << index.member << "'" << endl;
+ return false;
+ }
+
+ TypePtr dataMemberType = dataMember->type();
+
+ if(!Dictionary::legalKeyType(dataMemberType))
+ {
+ cerr << _prog << ": `" << index.member << "' cannot be used as an index" << endl;
+ return false;
+ }
+
+ if(index.caseSensitive == false)
+ {
+ //
+ // Let's check member is a string
+ //
+ BuiltinPtr memberType = BuiltinPtr::dynamicCast(dataMemberType);
+ if(memberType == 0 || memberType->kind() != Builtin::KindString)
+ {
+ cerr << _prog << ": `" << index.member << "' is not a string " << endl;
+ return false;
+ }
+ }
+ indexTypes.push_back(dataMemberType);
+
+ string capitalizedMember = member;
+ capitalizedMember[0] = toupper(capitalizedMember[0]);
+ capitalizedMembers.push_back(capitalizedMember);
+ indexNames.push_back(member);
+ }
}
@@ -357,46 +357,46 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict)
//
if(dict.indices.size() > 0)
{
- out << sp << nl << "public" << nl << name
- << "(Freeze.Connection __connection, String __dbName, boolean __createDb, "
- << "java.util.Comparator __comparator, java.util.Map __indexComparators)";
- out << sb;
-
- out << nl << "super(__connection, __dbName, __comparator);";
- out << nl << "_indices = new Freeze.Map.Index[" << dict.indices.size() << "];";
- for(i = 0; i < dict.indices.size(); ++i)
- {
- out << nl << "_indices[" << i << "] = new " << capitalizedMembers[i]
- << "Index(\"" << indexNames[i] << "\");";
- }
- out << nl << "init(_indices, __dbName, \"" << keyType->typeId() << "\", \""
- << valueType->typeId() << "\", __createDb, __indexComparators);";
- out << eb;
+ out << sp << nl << "public" << nl << name
+ << "(Freeze.Connection __connection, String __dbName, boolean __createDb, "
+ << "java.util.Comparator __comparator, java.util.Map __indexComparators)";
+ out << sb;
+
+ out << nl << "super(__connection, __dbName, __comparator);";
+ out << nl << "_indices = new Freeze.Map.Index[" << dict.indices.size() << "];";
+ for(i = 0; i < dict.indices.size(); ++i)
+ {
+ out << nl << "_indices[" << i << "] = new " << capitalizedMembers[i]
+ << "Index(\"" << indexNames[i] << "\");";
+ }
+ out << nl << "init(_indices, __dbName, \"" << keyType->typeId() << "\", \""
+ << valueType->typeId() << "\", __createDb, __indexComparators);";
+ out << eb;
}
out << sp << nl << "public" << nl << name
- << "(Freeze.Connection __connection, String __dbName, boolean __createDb, "
- << "java.util.Comparator __comparator)";
+ << "(Freeze.Connection __connection, String __dbName, boolean __createDb, "
+ << "java.util.Comparator __comparator)";
out << sb;
if(dict.indices.size() > 0)
{
- out << nl << "this(__connection, __dbName, __createDb, __comparator, null);";
+ out << nl << "this(__connection, __dbName, __createDb, __comparator, null);";
}
else
{
- out << nl << "super(__connection, __dbName, \"" << keyType->typeId() << "\", \""
- << valueType->typeId() << "\", __createDb, __comparator);";
+ out << nl << "super(__connection, __dbName, \"" << keyType->typeId() << "\", \""
+ << valueType->typeId() << "\", __createDb, __comparator);";
}
out << eb;
out << sp << nl << "public" << nl << name
- << "(Freeze.Connection __connection, String __dbName, boolean __createDb)";
+ << "(Freeze.Connection __connection, String __dbName, boolean __createDb)";
out << sb;
out << nl << "this(__connection, __dbName, __createDb, null);";
out << eb;
out << sp << nl << "public" << nl << name
- << "(Freeze.Connection __connection, String __dbName)";
+ << "(Freeze.Connection __connection, String __dbName)";
out << sb;
out << nl << "this(__connection, __dbName, true);";
out << eb;
@@ -406,33 +406,33 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict)
//
for(i = 0; i < capitalizedMembers.size(); ++i)
{
- string indexClassName = capitalizedMembers[i] + "Index";
-
- out << sp << nl << "public Freeze.Map.EntryIterator";
- out << nl << "findBy" << capitalizedMembers[i] << "("
- << typeToString(indexTypes[i], TypeModeIn) << " __index, boolean __onlyDups)";
- out << sb;
- out << nl << "return _indices[" << i << "].untypedFind("
- << varToObject(indexTypes[i], "__index") << ", __onlyDups);";
- out << eb;
-
- out << sp << nl << "public Freeze.Map.EntryIterator";
- out << nl << "findBy" << capitalizedMembers[i] << "("
- << typeToString(indexTypes[i], TypeModeIn) << " __index)";
- out << sb;
- out << nl << "return _indices[" << i << "].untypedFind("
- << varToObject(indexTypes[i], "__index") << ", true);";
- out << eb;
-
- string countMethod = dict.indices[i].member.empty() ?
- string("valueCount") : dict.indices[i].member + "Count";
- out << sp << nl << "public int";
- out << nl << countMethod << "("
- << typeToString(indexTypes[i], TypeModeIn) << " __index)";
- out << sb;
- out << nl << "return _indices[" << i << "].untypedCount("
- << varToObject(indexTypes[i], "__index") << ");";
- out << eb;
+ string indexClassName = capitalizedMembers[i] + "Index";
+
+ out << sp << nl << "public Freeze.Map.EntryIterator";
+ out << nl << "findBy" << capitalizedMembers[i] << "("
+ << typeToString(indexTypes[i], TypeModeIn) << " __index, boolean __onlyDups)";
+ out << sb;
+ out << nl << "return _indices[" << i << "].untypedFind("
+ << varToObject(indexTypes[i], "__index") << ", __onlyDups);";
+ out << eb;
+
+ out << sp << nl << "public Freeze.Map.EntryIterator";
+ out << nl << "findBy" << capitalizedMembers[i] << "("
+ << typeToString(indexTypes[i], TypeModeIn) << " __index)";
+ out << sb;
+ out << nl << "return _indices[" << i << "].untypedFind("
+ << varToObject(indexTypes[i], "__index") << ", true);";
+ out << eb;
+
+ string countMethod = dict.indices[i].member.empty() ?
+ string("valueCount") : dict.indices[i].member + "Count";
+ out << sp << nl << "public int";
+ out << nl << countMethod << "("
+ << typeToString(indexTypes[i], TypeModeIn) << " __index)";
+ out << sb;
+ out << nl << "return _indices[" << i << "].untypedCount("
+ << varToObject(indexTypes[i], "__index") << ");";
+ out << eb;
}
//
@@ -460,18 +460,18 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict)
encaps = true;
}
- string valS = objectToVar(type, "o");
- string typeS;
+ string valS = objectToVar(type, "o");
+ string typeS;
BuiltinPtr b = BuiltinPtr::dynamicCast(type);
if(b != 0)
{
typeS = builtinTable[b->kind()];
- }
- else
- {
- typeS = typeToString(type, TypeModeIn);
- }
+ }
+ else
+ {
+ typeS = typeToString(type, TypeModeIn);
+ }
int iter;
@@ -614,213 +614,213 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict)
//
for(i = 0; i < capitalizedMembers.size(); ++i)
{
- string indexClassName = capitalizedMembers[i] + "Index";
- out << sp << nl << "private class " << indexClassName << " extends Freeze.Map.Index";
- out << sb;
-
- //
- // encodeKey
- //
- out << sp << nl << "public byte[]";
- out << nl << "encodeKey(Object key, Ice.Communicator communicator)";
- out << sb;
- if(dict.indices[i].member.empty())
- {
- //
- // Encode the full value (with an encaps!)
- //
- string keyS = "key";
- if(!dict.indices[i].caseSensitive)
- {
- keyS = "((String)key).toLowerCase()";
- }
-
- out << nl << "return encodeValue(" << keyS << ", communicator);";
- }
- else
- {
- //
- // No encaps
- //
- string keyS = dict.indices[i].caseSensitive ?
- "key" : "((String)key).toLowerCase()";
-
- keyS = objectToVar(indexTypes[i], keyS);
-
- out << nl << "IceInternal.BasicStream __os = "
- << "new IceInternal.BasicStream(Ice.Util.getInstance(communicator));";
- int iter = 0;
- writeMarshalUnmarshalCode(out, "", indexTypes[i], keyS, true, iter, false);
- assert(!indexTypes[i]->usesClasses());
-
- out << nl << "java.nio.ByteBuffer buf = __os.prepareWrite();";
- out << nl << "byte[] r = new byte[buf.limit()];";
- out << nl << "buf.get(r);";
- out << nl << "return r;";
- }
- out << eb;
-
- //
- // decodekey
- //
- out << sp << nl << "public Object";
- out << nl << "decodeKey(byte[] bytes, Ice.Communicator communicator)";
- out << sb;
- if(dict.indices[i].member.empty())
- {
- //
- // Decode the full value (with an encaps!)
- //
- out << nl << "return decodeValue(bytes, communicator);";
- }
- else
- {
- out << nl << "IceInternal.BasicStream __is = new IceInternal.BasicStream(Ice.Util.getInstance(communicator));";
- out << nl << "__is.resize(bytes.length, true);";
- out << nl << "java.nio.ByteBuffer buf = __is.prepareRead();";
- out << nl << "buf.position(0);";
- out << nl << "buf.put(bytes);";
- out << nl << "buf.position(0);";
-
- int iter = 0;
- list<string> metaData;
- string patchParams;
-
- string typeS;
- BuiltinPtr b = BuiltinPtr::dynamicCast(indexTypes[i]);
- if(b != 0)
- {
- typeS = builtinTable[b->kind()];
- }
- else
- {
- typeS = typeToString(indexTypes[i], TypeModeIn);
- }
+ string indexClassName = capitalizedMembers[i] + "Index";
+ out << sp << nl << "private class " << indexClassName << " extends Freeze.Map.Index";
+ out << sb;
+
+ //
+ // encodeKey
+ //
+ out << sp << nl << "public byte[]";
+ out << nl << "encodeKey(Object key, Ice.Communicator communicator)";
+ out << sb;
+ if(dict.indices[i].member.empty())
+ {
+ //
+ // Encode the full value (with an encaps!)
+ //
+ string keyS = "key";
+ if(!dict.indices[i].caseSensitive)
+ {
+ keyS = "((String)key).toLowerCase()";
+ }
+
+ out << nl << "return encodeValue(" << keyS << ", communicator);";
+ }
+ else
+ {
+ //
+ // No encaps
+ //
+ string keyS = dict.indices[i].caseSensitive ?
+ "key" : "((String)key).toLowerCase()";
+
+ keyS = objectToVar(indexTypes[i], keyS);
+
+ out << nl << "IceInternal.BasicStream __os = "
+ << "new IceInternal.BasicStream(Ice.Util.getInstance(communicator));";
+ int iter = 0;
+ writeMarshalUnmarshalCode(out, "", indexTypes[i], keyS, true, iter, false);
+ assert(!indexTypes[i]->usesClasses());
+
+ out << nl << "java.nio.ByteBuffer buf = __os.prepareWrite();";
+ out << nl << "byte[] r = new byte[buf.limit()];";
+ out << nl << "buf.get(r);";
+ out << nl << "return r;";
+ }
+ out << eb;
+
+ //
+ // decodekey
+ //
+ out << sp << nl << "public Object";
+ out << nl << "decodeKey(byte[] bytes, Ice.Communicator communicator)";
+ out << sb;
+ if(dict.indices[i].member.empty())
+ {
+ //
+ // Decode the full value (with an encaps!)
+ //
+ out << nl << "return decodeValue(bytes, communicator);";
+ }
+ else
+ {
+ out << nl << "IceInternal.BasicStream __is = new IceInternal.BasicStream(Ice.Util.getInstance(communicator));";
+ out << nl << "__is.resize(bytes.length, true);";
+ out << nl << "java.nio.ByteBuffer buf = __is.prepareRead();";
+ out << nl << "buf.position(0);";
+ out << nl << "buf.put(bytes);";
+ out << nl << "buf.position(0);";
+
+ int iter = 0;
+ list<string> metaData;
+ string patchParams;
+
+ string typeS;
+ BuiltinPtr b = BuiltinPtr::dynamicCast(indexTypes[i]);
+ if(b != 0)
+ {
+ typeS = builtinTable[b->kind()];
+ }
+ else
+ {
+ typeS = typeToString(indexTypes[i], TypeModeIn);
+ }
out << nl << typeS << " r;";
-
- if(b != 0)
- {
- switch(b->kind())
- {
- case Builtin::KindByte:
- {
- out << nl << "r = new java.lang.Byte(__is.readByte());";
- break;
- }
- case Builtin::KindBool:
- {
- out << nl << "r = new java.lang.Boolean(__is.readBool());";
- break;
- }
- case Builtin::KindShort:
- {
- out << nl << "r = new java.lang.Short(__is.readShort());";
- break;
- }
- case Builtin::KindInt:
- {
- out << nl << "r = new java.lang.Integer(__is.readInt());";
- break;
- }
- case Builtin::KindLong:
- {
- out << nl << "r = new java.lang.Long(__is.readLong());";
- break;
- }
- case Builtin::KindFloat:
- {
- out << nl << "r = new java.lang.Float(__is.readFloat());";
- break;
- }
- case Builtin::KindDouble:
- {
- out << nl << "r = new java.lang.Double(__is.readDouble());";
- break;
- }
- case Builtin::KindString:
- case Builtin::KindObject:
- case Builtin::KindObjectProxy:
- case Builtin::KindLocalObject:
- {
- writeMarshalUnmarshalCode(out, "", indexTypes[i], "r", false, iter, false, metaData, patchParams);
- break;
- }
- }
- }
- else
- {
- writeMarshalUnmarshalCode(out, "", indexTypes[i], "r", false, iter, false, metaData, patchParams);
- }
+
+ if(b != 0)
+ {
+ switch(b->kind())
+ {
+ case Builtin::KindByte:
+ {
+ out << nl << "r = new java.lang.Byte(__is.readByte());";
+ break;
+ }
+ case Builtin::KindBool:
+ {
+ out << nl << "r = new java.lang.Boolean(__is.readBool());";
+ break;
+ }
+ case Builtin::KindShort:
+ {
+ out << nl << "r = new java.lang.Short(__is.readShort());";
+ break;
+ }
+ case Builtin::KindInt:
+ {
+ out << nl << "r = new java.lang.Integer(__is.readInt());";
+ break;
+ }
+ case Builtin::KindLong:
+ {
+ out << nl << "r = new java.lang.Long(__is.readLong());";
+ break;
+ }
+ case Builtin::KindFloat:
+ {
+ out << nl << "r = new java.lang.Float(__is.readFloat());";
+ break;
+ }
+ case Builtin::KindDouble:
+ {
+ out << nl << "r = new java.lang.Double(__is.readDouble());";
+ break;
+ }
+ case Builtin::KindString:
+ case Builtin::KindObject:
+ case Builtin::KindObjectProxy:
+ case Builtin::KindLocalObject:
+ {
+ writeMarshalUnmarshalCode(out, "", indexTypes[i], "r", false, iter, false, metaData, patchParams);
+ break;
+ }
+ }
+ }
+ else
+ {
+ writeMarshalUnmarshalCode(out, "", indexTypes[i], "r", false, iter, false, metaData, patchParams);
+ }
out << nl << "return r;";
}
out << eb;
- //
- // compare
- //
- out << sp << nl << "public int";
- out << nl << "compare(Object o1, Object o2)";
- out << sb;
- out << nl << "assert _comparator != null;";
- out << nl << "byte[] d1 = (byte[])o1;";
- out << nl << "byte[] d2 = (byte[])o2;";
- out << nl << "Ice.Communicator communicator = ((Freeze.Connection)_connection).getCommunicator();";
- out << nl << "return _comparator.compare(";
- out.inc();
- out << nl << "decodeKey(d1, communicator),";
- out << nl << "decodeKey(d2, communicator));";
- out.dec();
- out << eb;
-
- //
- // extractKey from value
- //
- out << sp << nl << "public Object";
- out << nl << "extractKey(Object value)";
- out << sb;
- if(dict.indices[i].member.empty())
- {
- if(dict.indices[i].caseSensitive)
- {
- out << nl << "return value;";
- }
- else
- {
- out << nl << "return value.toLowerCase();";
- }
- }
- else
- {
- out << nl << typeToString(valueType, TypeModeIn)
- << " typedValue = ("
- << typeToString(valueType, TypeModeIn) << ")value;";
-
- string member = string("typedValue.") + dict.indices[i].member;
- if(!dict.indices[i].caseSensitive)
- {
- member += ".toLowerCase()";
- }
- out << nl << "return " << varToObject(indexTypes[i], member) << ";";
- }
- out << eb;
-
- //
- // marshalKey optimization
- //
- if(dict.indices[i].member.empty() && dict.indices[i].caseSensitive)
- {
- out << sp << nl << "protected byte[]";
- out << nl << "marshalKey(byte[] value)";
- out << sb;
- out << nl << "return value;";
- out << eb;
- }
-
- out << sp << nl << "private " << indexClassName << "(String name)";
- out << sb;
- out << nl << "super(name);";
- out << eb;
- out << eb;
+ //
+ // compare
+ //
+ out << sp << nl << "public int";
+ out << nl << "compare(Object o1, Object o2)";
+ out << sb;
+ out << nl << "assert _comparator != null;";
+ out << nl << "byte[] d1 = (byte[])o1;";
+ out << nl << "byte[] d2 = (byte[])o2;";
+ out << nl << "Ice.Communicator communicator = ((Freeze.Connection)_connection).getCommunicator();";
+ out << nl << "return _comparator.compare(";
+ out.inc();
+ out << nl << "decodeKey(d1, communicator),";
+ out << nl << "decodeKey(d2, communicator));";
+ out.dec();
+ out << eb;
+
+ //
+ // extractKey from value
+ //
+ out << sp << nl << "public Object";
+ out << nl << "extractKey(Object value)";
+ out << sb;
+ if(dict.indices[i].member.empty())
+ {
+ if(dict.indices[i].caseSensitive)
+ {
+ out << nl << "return value;";
+ }
+ else
+ {
+ out << nl << "return value.toLowerCase();";
+ }
+ }
+ else
+ {
+ out << nl << typeToString(valueType, TypeModeIn)
+ << " typedValue = ("
+ << typeToString(valueType, TypeModeIn) << ")value;";
+
+ string member = string("typedValue.") + dict.indices[i].member;
+ if(!dict.indices[i].caseSensitive)
+ {
+ member += ".toLowerCase()";
+ }
+ out << nl << "return " << varToObject(indexTypes[i], member) << ";";
+ }
+ out << eb;
+
+ //
+ // marshalKey optimization
+ //
+ if(dict.indices[i].member.empty() && dict.indices[i].caseSensitive)
+ {
+ out << sp << nl << "protected byte[]";
+ out << nl << "marshalKey(byte[] value)";
+ out << sb;
+ out << nl << "return value;";
+ out << eb;
+ }
+
+ out << sp << nl << "private " << indexClassName << "(String name)";
+ out << sb;
+ out << nl << "super(name);";
+ out << eb;
+ out << eb;
}
//
@@ -897,7 +897,7 @@ FreezeGenerator::generate(UnitPtr& u, const Index& index)
ClassDeclPtr classDecl = ClassDeclPtr::dynamicCast(type);
if(classDecl == 0)
{
- cerr << _prog << ": `" << index.type << "' is not a class" << endl;
+ cerr << _prog << ": `" << index.type << "' is not a class" << endl;
return false;
}
@@ -906,33 +906,33 @@ FreezeGenerator::generate(UnitPtr& u, const Index& index)
DataMemberList::const_iterator p = dataMembers.begin();
while(p != dataMembers.end() && dataMember == 0)
{
- if((*p)->name() == index.member)
- {
- dataMember = *p;
- }
- else
- {
- ++p;
- }
+ if((*p)->name() == index.member)
+ {
+ dataMember = *p;
+ }
+ else
+ {
+ ++p;
+ }
}
if(dataMember == 0)
{
- cerr << _prog << ": `" << index.type << "' has no data member named `" << index.member << "'" << endl;
+ cerr << _prog << ": `" << index.type << "' has no data member named `" << index.member << "'" << endl;
return false;
}
if(index.caseSensitive == false)
{
- //
- // Let's check member is a string
- //
- BuiltinPtr memberType = BuiltinPtr::dynamicCast(dataMember->type());
- if(memberType == 0 || memberType->kind() != Builtin::KindString)
- {
- cerr << _prog << ": `" << index.member << "'is not a string " << endl;
- return false;
- }
+ //
+ // Let's check member is a string
+ //
+ BuiltinPtr memberType = BuiltinPtr::dynamicCast(dataMember->type());
+ if(memberType == 0 || memberType->kind() != Builtin::KindString)
+ {
+ cerr << _prog << ": `" << index.member << "'is not a string " << endl;
+ return false;
+ }
}
string memberTypeString = typeToString(dataMember->type(), TypeModeIn);
@@ -965,19 +965,19 @@ FreezeGenerator::generate(UnitPtr& u, const Index& index)
// find and count
//
out << sp << nl << "public Ice.Identity[]" << nl
- << "findFirst(" << memberTypeString << " __index, int __firstN)";
+ << "findFirst(" << memberTypeString << " __index, int __firstN)";
out << sb;
out << nl << "return untypedFindFirst(marshalKey(__index), __firstN);";
out << eb;
out << sp << nl << "public Ice.Identity[]" << nl
- << "find(" << memberTypeString << " __index)";
+ << "find(" << memberTypeString << " __index)";
out << sb;
out << nl << "return untypedFind(marshalKey(__index));";
out << eb;
out << sp << nl << "public int" << nl
- << "count(" << memberTypeString << " __index)";
+ << "count(" << memberTypeString << " __index)";
out << sb;
out << nl << "return untypedCount(marshalKey(__index));";
out << eb;
@@ -988,7 +988,7 @@ FreezeGenerator::generate(UnitPtr& u, const Index& index)
string typeString = typeToString(type, TypeModeIn);
out << sp << nl << "protected byte[]" << nl
- << "marshalKey(Ice.Object __servant)";
+ << "marshalKey(Ice.Object __servant)";
out << sb;
out << nl << "if(__servant instanceof " << typeString << ")";
out << sb;
@@ -1004,15 +1004,15 @@ FreezeGenerator::generate(UnitPtr& u, const Index& index)
string valueS = index.caseSensitive ? "__key" : "__key.toLowerCase()";
out << sp << nl << "private byte[]" << nl
- << "marshalKey(" << memberTypeString << " __key)";
+ << "marshalKey(" << memberTypeString << " __key)";
out << sb;
out << nl << "IceInternal.BasicStream __os = "
- << "new IceInternal.BasicStream(Ice.Util.getInstance(communicator()));";
+ << "new IceInternal.BasicStream(Ice.Util.getInstance(communicator()));";
int iter = 0;
writeMarshalUnmarshalCode(out, "", dataMember->type(), valueS, true, iter, false);
if(type->usesClasses())
{
- out << nl << "__os.writePendingObjects();";
+ out << nl << "__os.writePendingObjects();";
}
out << nl << "java.nio.ByteBuffer __buf = __os.prepareWrite();";
out << nl << "byte[] __r = new byte[__buf.limit()];";
@@ -1040,29 +1040,29 @@ usage(const char* n)
"-DNAME=DEF Define NAME as DEF.\n"
"-UNAME Remove any definition for NAME.\n"
"-IDIR Put DIR in the include file search path.\n"
- "-E Print preprocessor output on stdout.\n"
+ "-E Print preprocessor output on stdout.\n"
"--include-dir DIR Use DIR as the header include directory.\n"
"--dict NAME,KEY,VALUE Create a Freeze dictionary with the name NAME,\n"
" using KEY as key, and VALUE as value. This\n"
" option may be specified multiple times for\n"
" different names. NAME may be a scoped name.\n"
- "--index NAME,TYPE,MEMBER[,{case-sensitive|case-insensitive}]\n"
+ "--index NAME,TYPE,MEMBER[,{case-sensitive|case-insensitive}]\n"
" Create a Freeze evictor index with the name\n"
" NAME for member MEMBER of class TYPE. This\n"
" option may be specified multiple times for\n"
" different names. NAME may be a scoped name.\n"
" When member is a string, the case can be\n"
" sensitive or insensitive (default is sensitive).\n"
- "--dict-index DICT[,MEMBER][,{case-sensitive|case-insensitive}] \n"
- " Add an index to dictionary DICT. If MEMBER is \n"
+ "--dict-index DICT[,MEMBER][,{case-sensitive|case-insensitive}] \n"
+ " Add an index to dictionary DICT. If MEMBER is \n"
" specified, then DICT's VALUE must be a class or\n"
- " a struct, and MEMBER must designate a member of\n"
- " VALUE. Otherwise, the entire VALUE is used for \n"
- " indexing. When the secondary key is a string, \n"
- " the case can be sensitive or insensitive (default\n"
- " is sensitive).\n"
+ " a struct, and MEMBER must designate a member of\n"
+ " VALUE. Otherwise, the entire VALUE is used for \n"
+ " indexing. When the secondary key is a string, \n"
+ " the case can be sensitive or insensitive (default\n"
+ " is sensitive).\n"
"--output-dir DIR Create files in the directory DIR.\n"
- "--depend Generate Makefile dependencies.\n"
+ "--depend Generate Makefile dependencies.\n"
"-d, --debug Print debug messages.\n"
"--ice Permit `Ice' prefix (for building Ice source code only)\n"
"--meta META Define global metadata directive META.\n"
@@ -1098,21 +1098,21 @@ main(int argc, char* argv[])
}
catch(const IceUtil::BadOptException& e)
{
- cerr << argv[0] << ": " << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": " << e.reason << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(argv[0]);
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
string cppArgs;
@@ -1120,19 +1120,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D" + Preprocessor::addQuotes(*i);
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U" + Preprocessor::addQuotes(*i);
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I" + Preprocessor::addQuotes(*i);
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
@@ -1143,199 +1143,199 @@ main(int argc, char* argv[])
optargs = opts.argVec("dict");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- string s = *i;
- s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
-
- Dict dict;
-
- string::size_type pos;
- pos = s.find(',');
- if(pos != string::npos)
- {
- dict.name = s.substr(0, pos);
- s.erase(0, pos + 1);
- }
- pos = s.find(',');
- if(pos != string::npos)
- {
- dict.key = s.substr(0, pos);
- s.erase(0, pos + 1);
- }
- dict.value = s;
-
- if(dict.name.empty())
- {
- cerr << argv[0] << ": " << *i << ": no name specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
-
- if(dict.key.empty())
- {
- cerr << argv[0] << ": " << *i << ": no key specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
-
- if(dict.value.empty())
- {
- cerr << argv[0] << ": " << *i << ": no value specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
-
- dicts.push_back(dict);
+ string s = *i;
+ s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
+
+ Dict dict;
+
+ string::size_type pos;
+ pos = s.find(',');
+ if(pos != string::npos)
+ {
+ dict.name = s.substr(0, pos);
+ s.erase(0, pos + 1);
+ }
+ pos = s.find(',');
+ if(pos != string::npos)
+ {
+ dict.key = s.substr(0, pos);
+ s.erase(0, pos + 1);
+ }
+ dict.value = s;
+
+ if(dict.name.empty())
+ {
+ cerr << argv[0] << ": " << *i << ": no name specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ if(dict.key.empty())
+ {
+ cerr << argv[0] << ": " << *i << ": no key specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ if(dict.value.empty())
+ {
+ cerr << argv[0] << ": " << *i << ": no value specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ dicts.push_back(dict);
}
vector<Index> indices;
optargs = opts.argVec("index");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- string s = *i;
- s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
-
- Index index;
-
- string::size_type pos;
- pos = s.find(',');
- if(pos != string::npos)
- {
- index.name = s.substr(0, pos);
- s.erase(0, pos + 1);
- }
- pos = s.find(',');
- if(pos != string::npos)
- {
- index.type = s.substr(0, pos);
- s.erase(0, pos + 1);
- }
- pos = s.find(',');
- string caseString;
- if(pos != string::npos)
- {
- index.member = s.substr(0, pos);
- s.erase(0, pos + 1);
- caseString = s;
- }
- else
- {
- index.member = s;
- caseString = "case-sensitive";
- }
-
- if(index.name.empty())
- {
- cerr << argv[0] << ": " << *i << ": no name specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
-
- if(index.type.empty())
- {
- cerr << argv[0] << ": " << *i << ": no type specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
-
- if(index.member.empty())
- {
- cerr << argv[0] << ": " << *i << ": no member specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
-
- if(caseString != "case-sensitive" && caseString != "case-insensitive")
- {
- cerr << argv[0] << ": " << *i << ": the case can be `case-sensitive' or `case-insensitive'" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- index.caseSensitive = (caseString == "case-sensitive");
-
- indices.push_back(index);
+ string s = *i;
+ s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
+
+ Index index;
+
+ string::size_type pos;
+ pos = s.find(',');
+ if(pos != string::npos)
+ {
+ index.name = s.substr(0, pos);
+ s.erase(0, pos + 1);
+ }
+ pos = s.find(',');
+ if(pos != string::npos)
+ {
+ index.type = s.substr(0, pos);
+ s.erase(0, pos + 1);
+ }
+ pos = s.find(',');
+ string caseString;
+ if(pos != string::npos)
+ {
+ index.member = s.substr(0, pos);
+ s.erase(0, pos + 1);
+ caseString = s;
+ }
+ else
+ {
+ index.member = s;
+ caseString = "case-sensitive";
+ }
+
+ if(index.name.empty())
+ {
+ cerr << argv[0] << ": " << *i << ": no name specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ if(index.type.empty())
+ {
+ cerr << argv[0] << ": " << *i << ": no type specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ if(index.member.empty())
+ {
+ cerr << argv[0] << ": " << *i << ": no member specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ if(caseString != "case-sensitive" && caseString != "case-insensitive")
+ {
+ cerr << argv[0] << ": " << *i << ": the case can be `case-sensitive' or `case-insensitive'" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ index.caseSensitive = (caseString == "case-sensitive");
+
+ indices.push_back(index);
}
if(opts.isSet("dict-index"))
{
- vector<string> optargs = opts.argVec("dict-index");
- for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
- {
- string s = *i;
- s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
-
- string dictName;
- DictIndex index;
- string::size_type pos;
-
- string caseString = "case-sensitive";
- pos = s.find(',');
- if(pos != string::npos)
- {
- dictName = s.substr(0, pos);
- s.erase(0, pos + 1);
-
- pos = s.find(',');
- if(pos != string::npos)
- {
- index.member = s.substr(0, pos);
- s.erase(0, pos + 1);
- caseString = s;
- }
- else
- {
- if(s == "case-sensitive" || s == "case-insensitive")
- {
- caseString = s;
- }
- else
- {
- index.member = s;
- }
- }
- }
- else
- {
- dictName = s;
- }
-
- if(dictName.empty())
- {
- cerr << argv[0] << ": " << *i << ": no dictionary specified" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
-
- if(caseString != "case-sensitive" && caseString != "case-insensitive")
- {
- cerr << argv[0] << ": " << *i << ": the case can be `case-sensitive' or `case-insensitive'" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- index.caseSensitive = (caseString == "case-sensitive");
-
- bool found = false;
- for(vector<Dict>::iterator p = dicts.begin(); p != dicts.end(); ++p)
- {
- if(p->name == dictName)
- {
- if(find(p->indices.begin(), p->indices.end(), index) != p->indices.end())
- {
- cerr << argv[0] << ": --dict-index " << *i << ": this dict-index is defined twice" << endl;
- return EXIT_FAILURE;
- }
-
- p->indices.push_back(index);
- found = true;
- break;
- }
- }
- if(!found)
- {
- cerr << argv[0] << ": " << *i << ": unknown dictionary" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
- }
+ vector<string> optargs = opts.argVec("dict-index");
+ for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
+ {
+ string s = *i;
+ s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
+
+ string dictName;
+ DictIndex index;
+ string::size_type pos;
+
+ string caseString = "case-sensitive";
+ pos = s.find(',');
+ if(pos != string::npos)
+ {
+ dictName = s.substr(0, pos);
+ s.erase(0, pos + 1);
+
+ pos = s.find(',');
+ if(pos != string::npos)
+ {
+ index.member = s.substr(0, pos);
+ s.erase(0, pos + 1);
+ caseString = s;
+ }
+ else
+ {
+ if(s == "case-sensitive" || s == "case-insensitive")
+ {
+ caseString = s;
+ }
+ else
+ {
+ index.member = s;
+ }
+ }
+ }
+ else
+ {
+ dictName = s;
+ }
+
+ if(dictName.empty())
+ {
+ cerr << argv[0] << ": " << *i << ": no dictionary specified" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ if(caseString != "case-sensitive" && caseString != "case-insensitive")
+ {
+ cerr << argv[0] << ": " << *i << ": the case can be `case-sensitive' or `case-insensitive'" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ index.caseSensitive = (caseString == "case-sensitive");
+
+ bool found = false;
+ for(vector<Dict>::iterator p = dicts.begin(); p != dicts.end(); ++p)
+ {
+ if(p->name == dictName)
+ {
+ if(find(p->indices.begin(), p->indices.end(), index) != p->indices.end())
+ {
+ cerr << argv[0] << ": --dict-index " << *i << ": this dict-index is defined twice" << endl;
+ return EXIT_FAILURE;
+ }
+
+ p->indices.push_back(index);
+ found = true;
+ break;
+ }
+ }
+ if(!found)
+ {
+ cerr << argv[0] << ": " << *i << ": unknown dictionary" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
+ }
}
string output = opts.optArg("output-dir");
@@ -1365,51 +1365,51 @@ main(int argc, char* argv[])
for(vector<string>::size_type idx = 0; idx < args.size(); ++idx)
{
- if(depend)
- {
- Preprocessor icecpp(argv[0], args[idx], cppArgs);
- icecpp.printMakefileDependencies(Preprocessor::Java);
- }
- else
- {
- Preprocessor icecpp(argv[0], args[idx], cppArgs);
- FILE* cppHandle = icecpp.preprocess(false);
-
- if(cppHandle == 0)
- {
- u->destroy();
- return EXIT_FAILURE;
- }
-
- if(preprocess)
- {
- char buf[4096];
- while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
- {
- if(fputs(buf, stdout) == EOF)
- {
- u->destroy();
- return EXIT_FAILURE;
- }
- }
- }
- else
- {
- status = u->parse(cppHandle, debug);
- }
-
- if(!icecpp.close())
- {
- u->destroy();
- return EXIT_FAILURE;
- }
- }
+ if(depend)
+ {
+ Preprocessor icecpp(argv[0], args[idx], cppArgs);
+ icecpp.printMakefileDependencies(Preprocessor::Java);
+ }
+ else
+ {
+ Preprocessor icecpp(argv[0], args[idx], cppArgs);
+ FILE* cppHandle = icecpp.preprocess(false);
+
+ if(cppHandle == 0)
+ {
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+
+ if(preprocess)
+ {
+ char buf[4096];
+ while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
+ {
+ if(fputs(buf, stdout) == EOF)
+ {
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+ }
+ }
+ else
+ {
+ status = u->parse(cppHandle, debug);
+ }
+
+ if(!icecpp.close())
+ {
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+ }
}
if(depend)
{
u->destroy();
- return EXIT_SUCCESS;
+ return EXIT_SUCCESS;
}
if(status == EXIT_SUCCESS && !preprocess)
@@ -1439,7 +1439,7 @@ main(int argc, char* argv[])
}
}
- for(vector<Index>::const_iterator q = indices.begin(); q != indices.end(); ++q)
+ for(vector<Index>::const_iterator q = indices.begin(); q != indices.end(); ++q)
{
try
{
diff --git a/cpp/src/slice2html/Gen.cpp b/cpp/src/slice2html/Gen.cpp
index 3c694561ec7..dba70089b34 100644
--- a/cpp/src/slice2html/Gen.cpp
+++ b/cpp/src/slice2html/Gen.cpp
@@ -33,9 +33,9 @@ namespace Slice
void
generate(const UnitPtr& unit, const string& dir,
- const string& header, const string& footer,
- const string& indexHeader, const string& indexFooter,
- const string& imageDir, const string& logoURL, const string& searchAction, unsigned indexCount, unsigned warnSummary)
+ const string& header, const string& footer,
+ const string& indexHeader, const string& indexFooter,
+ const string& imageDir, const string& logoURL, const string& searchAction, unsigned indexCount, unsigned warnSummary)
{
unit->mergeModules();
@@ -110,8 +110,8 @@ Slice::GeneratorBase::setOutputDir(const string& dir)
{
if(!dir.empty())
{
- _dir = dir;
- makeDir(_dir);
+ _dir = dir;
+ makeDir(_dir);
}
}
@@ -215,21 +215,21 @@ Slice::GeneratorBase::openDoc(const string& file, const string& title, const str
string h2;
if(header.empty())
{
- _out << _header1;
+ _out << _header1;
}
else
{
- getHeaders(header, h1, h2);
- _out << h1;
+ getHeaders(header, h1, h2);
+ _out << h1;
}
_out << title;
if(header.empty())
{
- _out << _header2;
+ _out << _header2;
}
else
{
- _out << h2;
+ _out << h2;
}
_indexFooter = getFooter(footer);
_out.inc();
@@ -250,12 +250,12 @@ Slice::GeneratorBase::openDoc(const ContainedPtr& c)
StringList::size_type num = 0;
for(StringList::const_iterator i = components.begin(); i != components.end(); ++i)
{
- path += "/" + *i;
- ++num;
- if(num < components.size())
- {
- makeDir(path);
- }
+ path += "/" + *i;
+ ++num;
+ if(num < components.size())
+ {
+ makeDir(path);
+ }
}
path += ".html";
@@ -286,7 +286,7 @@ Slice::GeneratorBase::start(const std::string& element, const std::string& class
string s = element;
if(!classes.empty())
{
- s += " class=\"" + classes + "\"";
+ s += " class=\"" + classes + "\"";
}
_out << se(s);
}
@@ -299,7 +299,7 @@ Slice::GeneratorBase::end()
void
Slice::GeneratorBase::printComment(const ContainedPtr& p, const ContainerPtr& container,
- const string& deprecateReason, bool forIndex)
+ const string& deprecateReason, bool forIndex)
{
#ifndef NDEBUG
int indent = _out.currIndent();
@@ -314,221 +314,221 @@ Slice::GeneratorBase::printComment(const ContainedPtr& p, const ContainerPtr& co
string::size_type pos = comment.find_last_not_of(" \t\r\n");
if(pos != string::npos)
{
- comment.erase(pos + 1);
- start("p");
- _out.zeroIndent();
- _out << nl << comment;
- _out.restoreIndent();
- end();
+ comment.erase(pos + 1);
+ start("p");
+ _out.zeroIndent();
+ _out << nl << comment;
+ _out.restoreIndent();
+ end();
}
if(!deprecateReason.empty())
{
- start("p", "Deprecated");
- _out << nl << deprecateReason;
- end();
+ start("p", "Deprecated");
+ _out << nl << deprecateReason;
+ end();
}
assert(_out.currIndent() == indent);
if(!par.empty())
{
- start("h4");
- _out << "Parameters";
- end();
- start("dl");
- for(StringList::const_iterator q = par.begin(); q != par.end(); ++q)
- {
- string term;
- pos = q->find_first_of(" \t\r\n");
- if(pos != string::npos)
- {
- term = q->substr(0, pos);
- }
- string item;
- pos = q->find_first_not_of(" \t\r\n", pos);
- if(pos != string::npos)
- {
- item = q->substr(pos);
- }
-
- start("dt", "Symbol");
- _out << term;
- end();
- start("dd");
- _out << nl << item;
- end();
- }
- end();
+ start("h4");
+ _out << "Parameters";
+ end();
+ start("dl");
+ for(StringList::const_iterator q = par.begin(); q != par.end(); ++q)
+ {
+ string term;
+ pos = q->find_first_of(" \t\r\n");
+ if(pos != string::npos)
+ {
+ term = q->substr(0, pos);
+ }
+ string item;
+ pos = q->find_first_not_of(" \t\r\n", pos);
+ if(pos != string::npos)
+ {
+ item = q->substr(pos);
+ }
+
+ start("dt", "Symbol");
+ _out << term;
+ end();
+ start("dd");
+ _out << nl << item;
+ end();
+ }
+ end();
}
if(!ret.empty())
{
- start("h4");
- _out << "Return Value";
- end();
- start("p");
- _out << ret.front();
- end();
+ start("h4");
+ _out << "Return Value";
+ end();
+ start("p");
+ _out << ret.front();
+ end();
}
if(!throws.empty())
{
- start("h4");
- _out << "Exceptions";
- end();
- start("dl");
- for(StringList::const_iterator q = throws.begin(); q != throws.end(); ++q)
- {
- string term;
- pos = q->find_first_of(" \t\r\n");
- if(pos != string::npos)
- {
- term = q->substr(0, pos);
- }
- string item;
- pos = q->find_first_not_of(" \t\r\n", pos);
- if(pos != string::npos)
- {
- item = q->substr(pos);
- }
-
- start("dt", "Symbol");
- _out << toString(term, container, false, forIndex);
- end();
- start("dd");
- _out << nl << item;
- end();
- }
- end();
+ start("h4");
+ _out << "Exceptions";
+ end();
+ start("dl");
+ for(StringList::const_iterator q = throws.begin(); q != throws.end(); ++q)
+ {
+ string term;
+ pos = q->find_first_of(" \t\r\n");
+ if(pos != string::npos)
+ {
+ term = q->substr(0, pos);
+ }
+ string item;
+ pos = q->find_first_not_of(" \t\r\n", pos);
+ if(pos != string::npos)
+ {
+ item = q->substr(pos);
+ }
+
+ start("dt", "Symbol");
+ _out << toString(term, container, false, forIndex);
+ end();
+ start("dd");
+ _out << nl << item;
+ end();
+ }
+ end();
}
ClassList derivedClasses;
ClassDefPtr def = ClassDefPtr::dynamicCast(p);
if(def)
{
- derivedClasses = p->unit()->findDerivedClasses(def);
+ derivedClasses = p->unit()->findDerivedClasses(def);
}
if(!derivedClasses.empty())
{
- start("h4");
- _out << "Derived Classes and Interfaces";
- end();
- start("dl");
- for(ClassList::const_iterator q = derivedClasses.begin(); q != derivedClasses.end(); ++q)
- {
- start("dt", "Symbol");
- _out << toString(*q, container, false, forIndex);
- end();
- }
- end();
+ start("h4");
+ _out << "Derived Classes and Interfaces";
+ end();
+ start("dl");
+ for(ClassList::const_iterator q = derivedClasses.begin(); q != derivedClasses.end(); ++q)
+ {
+ start("dt", "Symbol");
+ _out << toString(*q, container, false, forIndex);
+ end();
+ }
+ end();
}
ExceptionList derivedExceptions;
ExceptionPtr ex = ExceptionPtr::dynamicCast(p);
if(ex)
{
- derivedExceptions = p->unit()->findDerivedExceptions(ex);
- if(!derivedExceptions.empty())
- {
- start("h4");
- _out << "Derived Exceptions";
- end();
- start("dl");
- for(ExceptionList::const_iterator q = derivedExceptions.begin(); q != derivedExceptions.end(); ++q)
- {
- start("dt", "Symbol");
- _out << toString(*q, container, false, forIndex);
- end();
- }
- end();
- }
-
- ContainedList usedBy;
- usedBy = p->unit()->findUsedBy(ex);
- if(!usedBy.empty())
- {
- start("h4");
- _out << "Used By";
- end();
- start("dl");
- //
- // We first extract the symbol names from the used-by list and sort
- // them, otherwise the symbols appear in random order.
- //
- StringList sl;
- for(ContainedList::const_iterator q = usedBy.begin(); q != usedBy.end(); ++q)
- {
- sl.push_back(toString(*q, container, false, forIndex));
- }
- sl.sort();
- for(StringList::const_iterator r = sl.begin(); r != sl.end(); ++r)
- {
- start("dt", "Symbol");
- _out << *r;
- end();
- }
- end();
- }
+ derivedExceptions = p->unit()->findDerivedExceptions(ex);
+ if(!derivedExceptions.empty())
+ {
+ start("h4");
+ _out << "Derived Exceptions";
+ end();
+ start("dl");
+ for(ExceptionList::const_iterator q = derivedExceptions.begin(); q != derivedExceptions.end(); ++q)
+ {
+ start("dt", "Symbol");
+ _out << toString(*q, container, false, forIndex);
+ end();
+ }
+ end();
+ }
+
+ ContainedList usedBy;
+ usedBy = p->unit()->findUsedBy(ex);
+ if(!usedBy.empty())
+ {
+ start("h4");
+ _out << "Used By";
+ end();
+ start("dl");
+ //
+ // We first extract the symbol names from the used-by list and sort
+ // them, otherwise the symbols appear in random order.
+ //
+ StringList sl;
+ for(ContainedList::const_iterator q = usedBy.begin(); q != usedBy.end(); ++q)
+ {
+ sl.push_back(toString(*q, container, false, forIndex));
+ }
+ sl.sort();
+ for(StringList::const_iterator r = sl.begin(); r != sl.end(); ++r)
+ {
+ start("dt", "Symbol");
+ _out << *r;
+ end();
+ }
+ end();
+ }
}
ContainedList usedBy;
ConstructedPtr constructed;
if(def)
{
- constructed = def->declaration();
+ constructed = def->declaration();
}
else
{
- constructed = ConstructedPtr::dynamicCast(p);
+ constructed = ConstructedPtr::dynamicCast(p);
}
if(constructed)
{
- usedBy = p->unit()->findUsedBy(constructed);
+ usedBy = p->unit()->findUsedBy(constructed);
}
if(!usedBy.empty())
{
- //
- // We first accumulate the strings in a list instead of printing
- // each stringified entry in the usedBy list. This is necessary because
- // the usedBy list can contain operations and parameters. But toString()
- // on a parameter returns the string for the parameter's operation, so
- // we can end up printing the same operation name more than once.
- //
- StringList strings;
- for(ContainedList::const_iterator q = usedBy.begin(); q != usedBy.end(); ++q)
- {
- strings.push_back(toString(*q, container, false, forIndex));
- }
- strings.sort();
- strings.unique();
-
- start("h4");
- _out << "Used By";
- end();
- start("dl");
- for(list<string>::const_iterator p = strings.begin(); p != strings.end(); ++p)
- {
- start("dt", "Symbol");
- _out << *p;
- end();
- }
- end();
+ //
+ // We first accumulate the strings in a list instead of printing
+ // each stringified entry in the usedBy list. This is necessary because
+ // the usedBy list can contain operations and parameters. But toString()
+ // on a parameter returns the string for the parameter's operation, so
+ // we can end up printing the same operation name more than once.
+ //
+ StringList strings;
+ for(ContainedList::const_iterator q = usedBy.begin(); q != usedBy.end(); ++q)
+ {
+ strings.push_back(toString(*q, container, false, forIndex));
+ }
+ strings.sort();
+ strings.unique();
+
+ start("h4");
+ _out << "Used By";
+ end();
+ start("dl");
+ for(list<string>::const_iterator p = strings.begin(); p != strings.end(); ++p)
+ {
+ start("dt", "Symbol");
+ _out << *p;
+ end();
+ }
+ end();
}
if(!see.empty())
{
- start("h4");
- _out << "See Also";
- end();
- start("dl");
- for(StringList::const_iterator q = see.begin(); q != see.end(); ++q)
- {
- start("dt", "Symbol");
- _out << toString(*q, container, false, forIndex);
- end();
- }
- end();
+ start("h4");
+ _out << "See Also";
+ end();
+ start("dl");
+ for(StringList::const_iterator q = see.begin(); q != see.end(); ++q)
+ {
+ start("dt", "Symbol");
+ _out << toString(*q, container, false, forIndex);
+ end();
+ }
+ end();
}
assert(_out.currIndent() == indent);
@@ -541,17 +541,17 @@ Slice::GeneratorBase::printMetaData(const ContainedPtr& p)
if(!metaData.empty())
{
- _out << "[";
- list<string>::const_iterator q = metaData.begin();
- while(q != metaData.end())
- {
- _out << " \"" << *q << "\"";
- if(++q != metaData.end())
- {
- _out << ",";
- }
- }
- _out << " ]" << nl;
+ _out << "[";
+ list<string>::const_iterator q = metaData.begin();
+ while(q != metaData.end())
+ {
+ _out << " \"" << *q << "\"";
+ if(++q != metaData.end())
+ {
+ _out << ",";
+ }
+ }
+ _out << " ]" << nl;
}
}
@@ -561,12 +561,12 @@ Slice::GeneratorBase::printSummary(const ContainedPtr& p, const ContainerPtr& mo
ContainerPtr container = ContainerPtr::dynamicCast(p);
if(!container)
{
- container = p->container();
+ container = p->container();
}
if(module)
{
- container = module;
+ container = module;
}
string summary = getComment(p, container, true, module);
@@ -574,9 +574,9 @@ Slice::GeneratorBase::printSummary(const ContainedPtr& p, const ContainerPtr& mo
if(deprecated)
{
- start("p", "Deprecated");
- _out << nl << "Deprecated.";
- end();
+ start("p", "Deprecated");
+ _out << nl << "Deprecated.";
+ end();
}
}
@@ -589,11 +589,11 @@ Slice::GeneratorBase::printHeaderFooter(const ContainedPtr& c)
ContainedList::const_iterator pos = _symbols.begin();
while(pos != _symbols.end())
{
- if((*pos)->scoped() == scoped)
- {
- break;
- }
- prev = pos++;
+ if((*pos)->scoped() == scoped)
+ {
+ break;
+ }
+ prev = pos++;
}
ContainedList::const_iterator next = pos == _symbols.end() ? _symbols.end() : ++pos;
@@ -607,49 +607,49 @@ Slice::GeneratorBase::printHeaderFooter(const ContainedPtr& c)
string prevClass;
if(!isFirst)
{
- prevLink = getLinkPath(*prev, container, false, onEnumPage) + ".html";
- prevClass = "Button";
+ prevLink = getLinkPath(*prev, container, false, onEnumPage) + ".html";
+ prevClass = "Button";
}
else
{
- prevClass = "ButtonGrey";
+ prevClass = "ButtonGrey";
}
string nextLink;
string nextClass;
if(!isLast)
{
- nextLink = getLinkPath(*next, container, false, onEnumPage) + ".html";
- nextClass = "Button";
+ nextLink = getLinkPath(*next, container, false, onEnumPage) + ".html";
+ nextClass = "Button";
}
else
{
- nextClass = "ButtonGrey";
+ nextClass = "ButtonGrey";
}
string upLink;
string upClass;
if(hasParent)
{
- upLink = getLinkPath(c->container(), container, ModulePtr::dynamicCast(c), onEnumPage) + ".html";
- upClass = "Button";
+ upLink = getLinkPath(c->container(), container, ModulePtr::dynamicCast(c), onEnumPage) + ".html";
+ upClass = "Button";
}
else
{
- upClass = "ButtonGrey";
+ upClass = "ButtonGrey";
}
string homeLink = getLinkPath(0, container, ModulePtr::dynamicCast(c), onEnumPage);
if(!homeLink.empty())
{
- homeLink += "/";
+ homeLink += "/";
}
homeLink += "index.html";
string indexLink = getLinkPath(0, container, ModulePtr::dynamicCast(c), onEnumPage);
if(!indexLink.empty())
{
- indexLink += "/";
+ indexLink += "/";
}
indexLink += "_sindex.html";
@@ -664,18 +664,18 @@ Slice::GeneratorBase::printHeaderFooter(const ContainedPtr& c)
if(!imageDir.empty())
{
- string path = getLinkPath(0, container, ModulePtr::dynamicCast(c), onEnumPage);
- if(!path.empty())
- {
- path += "/";
- }
- path += imageDir + "/";
+ string path = getLinkPath(0, container, ModulePtr::dynamicCast(c), onEnumPage);
+ if(!path.empty())
+ {
+ path += "/";
+ }
+ path += imageDir + "/";
- prevImage = "<img class=\"" + prevClass + "\" src=\"" + path + prevImage + "\" alt=\"Previous\"/>";
- nextImage = "<img class=\"" + nextClass + "\" src=\"" + path + nextImage + "\" alt=\"Next\"/>";
- upImage = "<img class=\"" + upClass + "\" src=\"" + path + upImage + "\" alt=\"Up\"/>";
- homeImage = "<img class=\"Button\" src=\"" + path + homeImage + "\" alt=\"Home\"/>";
- indexImage = "<img class=\"Button\" src=\"" + path + indexImage + "\" alt=\"Index\"/>";
+ prevImage = "<img class=\"" + prevClass + "\" src=\"" + path + prevImage + "\" alt=\"Previous\"/>";
+ nextImage = "<img class=\"" + nextClass + "\" src=\"" + path + nextImage + "\" alt=\"Next\"/>";
+ upImage = "<img class=\"" + upClass + "\" src=\"" + path + upImage + "\" alt=\"Up\"/>";
+ homeImage = "<img class=\"Button\" src=\"" + path + homeImage + "\" alt=\"Home\"/>";
+ indexImage = "<img class=\"Button\" src=\"" + path + indexImage + "\" alt=\"Index\"/>";
}
start("div", "HeaderFooter");
@@ -689,47 +689,47 @@ Slice::GeneratorBase::printHeaderFooter(const ContainedPtr& c)
if(!imageDir.empty() || !isFirst)
{
- start("td");
- if(!isFirst)
- {
- _out << "<a href=\"" << prevLink << "\">";
- }
- _out << prevImage;
- if(!isFirst)
- {
- _out << "</a>";
- }
- end();
+ start("td");
+ if(!isFirst)
+ {
+ _out << "<a href=\"" << prevLink << "\">";
+ }
+ _out << prevImage;
+ if(!isFirst)
+ {
+ _out << "</a>";
+ }
+ end();
}
if(!imageDir.empty() || hasParent)
{
- start("td");
- if(hasParent)
- {
- _out << "<a href=\"" << upLink << "\">";
- }
- _out << upImage;
- if(hasParent)
- {
- _out << "</a>";
- }
- end();
+ start("td");
+ if(hasParent)
+ {
+ _out << "<a href=\"" << upLink << "\">";
+ }
+ _out << upImage;
+ if(hasParent)
+ {
+ _out << "</a>";
+ }
+ end();
}
if(!imageDir.empty() || !isLast)
{
- start("td");
- if(!isLast)
- {
- _out << "<a href=\"" << nextLink << "\">";
- }
- _out << nextImage;
- if(!isLast)
- {
- _out << "</a>";
- }
- end();
+ start("td");
+ if(!isLast)
+ {
+ _out << "<a href=\"" << nextLink << "\">";
+ }
+ _out << nextImage;
+ if(!isLast)
+ {
+ _out << "</a>";
+ }
+ end();
}
start("td");
@@ -779,33 +779,33 @@ Slice::GeneratorBase::printLogo(const ContainedPtr& c, const ContainerPtr& conta
string imageDir = getImageDir();
if(!imageDir.empty())
{
- string path = getLinkPath(0, container, ModulePtr::dynamicCast(c), forEnum);
- if(!path.empty())
- {
- path += "/";
- }
- path += imageDir + "/logo.gif";
- start("table", "LogoTable");
- start("tr");
- start("td");
- if(!_logoURL.empty())
- {
- _out << "<a href=\"" + _logoURL + "\">";
- }
- _out << "<img class=\"Logo\" src=\"" + path + "\" alt=\"Logo\"/>";
- if(!_logoURL.empty())
- {
- _out << "</a>";
- }
- end();
- end();
- end();
+ string path = getLinkPath(0, container, ModulePtr::dynamicCast(c), forEnum);
+ if(!path.empty())
+ {
+ path += "/";
+ }
+ path += imageDir + "/logo.gif";
+ start("table", "LogoTable");
+ start("tr");
+ start("td");
+ if(!_logoURL.empty())
+ {
+ _out << "<a href=\"" + _logoURL + "\">";
+ }
+ _out << "<img class=\"Logo\" src=\"" + path + "\" alt=\"Logo\"/>";
+ if(!_logoURL.empty())
+ {
+ _out << "</a>";
+ }
+ end();
+ end();
+ end();
}
}
string
Slice::GeneratorBase::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& container, bool asTarget, bool forIndex,
- unsigned* summarySize, bool shortName)
+ unsigned* summarySize, bool shortName)
{
string anchor;
string linkpath;
@@ -813,149 +813,149 @@ Slice::GeneratorBase::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& c
static const char* builtinTable[] =
{
- "byte",
- "bool",
- "short",
- "int",
- "long",
- "float",
- "double",
- "string",
- "Object",
- "Object*",
- "LocalObject"
+ "byte",
+ "bool",
+ "short",
+ "int",
+ "long",
+ "float",
+ "double",
+ "string",
+ "Object",
+ "Object*",
+ "LocalObject"
};
BuiltinPtr builtin = BuiltinPtr::dynamicCast(p);
if(builtin)
{
- s = builtinTable[builtin->kind()];
- return s;
+ s = builtinTable[builtin->kind()];
+ return s;
}
ProxyPtr proxy = ProxyPtr::dynamicCast(p);
if(proxy)
{
- if(_files.find(p->definitionContext()->filename()) != _files.end())
- {
- linkpath = getLinkPath(proxy->_class()->definition(), container, forIndex);
- }
- s = getScopedMinimized(proxy->_class(), container, shortName);
+ if(_files.find(p->definitionContext()->filename()) != _files.end())
+ {
+ linkpath = getLinkPath(proxy->_class()->definition(), container, forIndex);
+ }
+ s = getScopedMinimized(proxy->_class(), container, shortName);
}
ClassDeclPtr cl = ClassDeclPtr::dynamicCast(p);
if(cl)
{
- //
+ //
// We must generate the id from the definition, not from the
// declaration, provided that a definition is available.
- //
- ContainedPtr definition = cl->definition();
- if(definition && _files.find(p->definitionContext()->filename()) != _files.end())
- {
- linkpath = getLinkPath(definition, container, forIndex);
- }
- s = getScopedMinimized(cl, container, shortName);
+ //
+ ContainedPtr definition = cl->definition();
+ if(definition && _files.find(p->definitionContext()->filename()) != _files.end())
+ {
+ linkpath = getLinkPath(definition, container, forIndex);
+ }
+ s = getScopedMinimized(cl, container, shortName);
}
ExceptionPtr ex = ExceptionPtr::dynamicCast(p);
if(ex)
{
- if(_files.find(p->definitionContext()->filename()) != _files.end())
- {
- linkpath = getLinkPath(ex, container, forIndex);
- }
- s = getScopedMinimized(ex, container, shortName);
+ if(_files.find(p->definitionContext()->filename()) != _files.end())
+ {
+ linkpath = getLinkPath(ex, container, forIndex);
+ }
+ s = getScopedMinimized(ex, container, shortName);
}
StructPtr st = StructPtr::dynamicCast(p);
if(st)
{
- if(_files.find(p->definitionContext()->filename()) != _files.end())
- {
- linkpath = getLinkPath(st, container, forIndex);
- }
- s = getScopedMinimized(st, container, shortName);
+ if(_files.find(p->definitionContext()->filename()) != _files.end())
+ {
+ linkpath = getLinkPath(st, container, forIndex);
+ }
+ s = getScopedMinimized(st, container, shortName);
}
EnumeratorPtr en = EnumeratorPtr::dynamicCast(p);
if(en)
{
- if(_files.find(p->definitionContext()->filename()) != _files.end())
- {
- anchor = getAnchor(en);
- linkpath = getLinkPath(en, container, forIndex);
- }
- s = getScopedMinimized(en, container, shortName);
+ if(_files.find(p->definitionContext()->filename()) != _files.end())
+ {
+ anchor = getAnchor(en);
+ linkpath = getLinkPath(en, container, forIndex);
+ }
+ s = getScopedMinimized(en, container, shortName);
}
OperationPtr op = OperationPtr::dynamicCast(p);
if(op)
{
- if(_files.find(p->definitionContext()->filename()) != _files.end())
- {
- anchor = getAnchor(op);
- linkpath = getLinkPath(op, container, forIndex);
- }
- s = getScopedMinimized(op, container, shortName);
+ if(_files.find(p->definitionContext()->filename()) != _files.end())
+ {
+ anchor = getAnchor(op);
+ linkpath = getLinkPath(op, container, forIndex);
+ }
+ s = getScopedMinimized(op, container, shortName);
}
ParamDeclPtr pd = ParamDeclPtr::dynamicCast(p);
if(pd)
{
- op = OperationPtr::dynamicCast(pd->container());
- assert(op);
- if(_files.find(p->definitionContext()->filename()) != _files.end())
- {
- anchor = getAnchor(op);
- linkpath = getLinkPath(op, container, forIndex);
- }
- s = getScopedMinimized(op, container, shortName);
+ op = OperationPtr::dynamicCast(pd->container());
+ assert(op);
+ if(_files.find(p->definitionContext()->filename()) != _files.end())
+ {
+ anchor = getAnchor(op);
+ linkpath = getLinkPath(op, container, forIndex);
+ }
+ s = getScopedMinimized(op, container, shortName);
}
if(s.empty())
{
- ContainedPtr contained = ContainedPtr::dynamicCast(p);
- assert(contained);
- if(_files.find(p->definitionContext()->filename()) != _files.end())
- {
- if(!(EnumPtr::dynamicCast(p) || ModulePtr::dynamicCast(p) || ClassDeclPtr::dynamicCast(p)))
- {
- anchor = getAnchor(contained);
- }
-
- //
- // Sequences and dictionaries are documented on the page for their
- // enclosing module.
- //
- if(SequencePtr::dynamicCast(p) || DictionaryPtr::dynamicCast(p))
- {
- linkpath = getLinkPath(contained->container(), container, forIndex);
- }
- else
- {
- linkpath = getLinkPath(contained, container, forIndex);
- }
- }
- s = getScopedMinimized(contained, container, shortName);
+ ContainedPtr contained = ContainedPtr::dynamicCast(p);
+ assert(contained);
+ if(_files.find(p->definitionContext()->filename()) != _files.end())
+ {
+ if(!(EnumPtr::dynamicCast(p) || ModulePtr::dynamicCast(p) || ClassDeclPtr::dynamicCast(p)))
+ {
+ anchor = getAnchor(contained);
+ }
+
+ //
+ // Sequences and dictionaries are documented on the page for their
+ // enclosing module.
+ //
+ if(SequencePtr::dynamicCast(p) || DictionaryPtr::dynamicCast(p))
+ {
+ linkpath = getLinkPath(contained->container(), container, forIndex);
+ }
+ else
+ {
+ linkpath = getLinkPath(contained, container, forIndex);
+ }
+ }
+ s = getScopedMinimized(contained, container, shortName);
}
if(summarySize)
{
- *summarySize = s.size();
+ *summarySize = s.size();
}
if(linkpath.empty() && anchor.empty())
{
- if(ProxyPtr::dynamicCast(p))
- {
- s += '*';
- if(summarySize)
- {
- ++(*summarySize);
- }
- }
- return s;
+ if(ProxyPtr::dynamicCast(p))
+ {
+ s += '*';
+ if(summarySize)
+ {
+ ++(*summarySize);
+ }
+ }
+ return s;
}
string ret = "<a class=\"Symbol\" ";
@@ -963,46 +963,46 @@ Slice::GeneratorBase::toString(const SyntaxTreeBasePtr& p, const ContainerPtr& c
ret += "=\"";
if(asTarget)
{
- ret += anchor;
+ ret += anchor;
}
else
{
- ret += linkpath;
- if(!linkpath.empty())
- {
- ret += ".html";
- }
- if(!anchor.empty())
- {
- ret += "#" + anchor;
- }
+ ret += linkpath;
+ if(!linkpath.empty())
+ {
+ ret += ".html";
+ }
+ if(!anchor.empty())
+ {
+ ret += "#" + anchor;
+ }
}
ret += "\">";
ret += s;
ret += "</a>";
if(ProxyPtr::dynamicCast(p))
{
- ret += '*';
+ ret += '*';
}
return ret;
}
string
Slice::GeneratorBase::toString(const string& str, const ContainerPtr& container, bool asTarget, bool forIndex,
- unsigned* summarySize)
+ unsigned* summarySize)
{
string s = str;
TypeList types = container->lookupType(s, false);
if(!types.empty())
{
- return toString(types.front(), container, asTarget, forIndex, summarySize);
+ return toString(types.front(), container, asTarget, forIndex, summarySize);
}
ContainedList contList = container->lookupContained(s, false);
if(!contList.empty())
{
- return toString(contList.front(), container, asTarget, forIndex, summarySize);
+ return toString(contList.front(), container, asTarget, forIndex, summarySize);
}
//
@@ -1014,52 +1014,52 @@ Slice::GeneratorBase::toString(const string& str, const ContainerPtr& container,
string
Slice::GeneratorBase::getComment(const ContainedPtr& contained, const ContainerPtr& container,
- bool summary, bool forIndex)
+ bool summary, bool forIndex)
{
unsigned summarySize = 0;
string s = contained->comment();
string comment;
for(unsigned int i = 0; i < s.size(); ++i)
{
- if(s[i] == '\\' && i + 1 < s.size() && s[i + 1] == '[')
- {
- comment += '[';
- ++summarySize;
- ++i;
- }
- else if(s[i] == '[')
- {
- string literal;
- for(++i; i < s.size(); ++i)
- {
- if(s[i] == ']')
- {
- break;
- }
-
- literal += s[i];
- }
- unsigned sz = 0;
- comment += toString(literal, container, false, forIndex, summary ? &sz : 0);
- summarySize += sz;
- }
- else if(summary && s[i] == '.' && (i + 1 >= s.size() || isspace(s[i + 1])))
- {
- comment += '.';
- ++summarySize;
- break;
- }
- else
- {
- comment += s[i];
- ++summarySize;
- }
+ if(s[i] == '\\' && i + 1 < s.size() && s[i + 1] == '[')
+ {
+ comment += '[';
+ ++summarySize;
+ ++i;
+ }
+ else if(s[i] == '[')
+ {
+ string literal;
+ for(++i; i < s.size(); ++i)
+ {
+ if(s[i] == ']')
+ {
+ break;
+ }
+
+ literal += s[i];
+ }
+ unsigned sz = 0;
+ comment += toString(literal, container, false, forIndex, summary ? &sz : 0);
+ summarySize += sz;
+ }
+ else if(summary && s[i] == '.' && (i + 1 >= s.size() || isspace(s[i + 1])))
+ {
+ comment += '.';
+ ++summarySize;
+ break;
+ }
+ else
+ {
+ comment += s[i];
+ ++summarySize;
+ }
}
if(summary && _warnSummary && summarySize > _warnSummary)
{
- cerr << contained->definitionContext()->filename() << ": summary size (" << summarySize << ") exceeds "
- << _warnSummary << " characters: `" << comment << "'" << endl;
+ cerr << contained->definitionContext()->filename() << ": summary size (" << summarySize << ") exceeds "
+ << _warnSummary << " characters: `" << comment << "'" << endl;
}
return comment;
@@ -1072,11 +1072,11 @@ Slice::GeneratorBase::getAnchor(const SyntaxTreeBasePtr& p)
string anchor;
for(StringList::const_iterator i = symbols.begin(); i != symbols.end(); ++i)
{
- if(i != symbols.begin())
- {
- anchor += "::";
- }
- anchor += *i;
+ if(i != symbols.begin())
+ {
+ anchor += "::";
+ }
+ anchor += *i;
}
return anchor;
}
@@ -1092,7 +1092,7 @@ Slice::GeneratorBase::getLinkPath(const SyntaxTreeBasePtr& p, const ContainerPtr
//
if(forIndex && ContainedPtr::dynamicCast(container))
{
- c = ContainedPtr::dynamicCast(c)->container();
+ c = ContainedPtr::dynamicCast(c)->container();
}
//
@@ -1103,32 +1103,32 @@ Slice::GeneratorBase::getLinkPath(const SyntaxTreeBasePtr& p, const ContainerPtr
EnumeratorPtr enumerator = EnumeratorPtr::dynamicCast(p);
if(enumerator)
{
- target = toStringList(enumerator->type());
+ target = toStringList(enumerator->type());
}
else
{
- target = getContainer(p);
+ target = getContainer(p);
}
StringList from = getContainer(c);
while(!target.empty() && !from.empty() && target.front() == from.front())
{
- target.pop_front();
- from.pop_front();
- commonEnclosingScope = true;
+ target.pop_front();
+ from.pop_front();
+ commonEnclosingScope = true;
}
if(commonEnclosingScope && target.empty())
{
- ModulePtr module = ModulePtr::dynamicCast(p);
- if(module)
- {
- target.push_front(module->name());
- }
+ ModulePtr module = ModulePtr::dynamicCast(p);
+ if(module)
+ {
+ target.push_front(module->name());
+ }
}
else if(!from.empty())
{
- from.pop_front();
+ from.pop_front();
}
//
@@ -1137,12 +1137,12 @@ Slice::GeneratorBase::getLinkPath(const SyntaxTreeBasePtr& p, const ContainerPtr
string path;
while(!from.empty())
{
- if(!path.empty())
- {
- path += "/";
- }
- path += "..";
- from.pop_front();
+ if(!path.empty())
+ {
+ path += "/";
+ }
+ path += "..";
+ from.pop_front();
}
//
@@ -1150,24 +1150,24 @@ Slice::GeneratorBase::getLinkPath(const SyntaxTreeBasePtr& p, const ContainerPtr
//
while(!target.empty())
{
- if(!path.empty())
- {
- path += "/";
- }
- path += target.front() == "index" ? string("_index") : target.front();
- target.pop_front();
+ if(!path.empty())
+ {
+ path += "/";
+ }
+ path += target.front() == "index" ? string("_index") : target.front();
+ target.pop_front();
}
if(forEnum)
{
- if(!path.empty())
- {
- path = "../" + path;
- }
- else
- {
- path = "..";
- }
+ if(!path.empty())
+ {
+ path = "../" + path;
+ }
+ else
+ {
+ path = "..";
+ }
}
return path;
}
@@ -1190,8 +1190,8 @@ Slice::GeneratorBase::openStream(const string& path)
_out.open(path.c_str());
if(!_out.isOpen())
{
- string err = "cannot open `" + path + "' for writing";
- throw err;
+ string err = "cannot open `" + path + "' for writing";
+ throw err;
}
}
@@ -1203,7 +1203,7 @@ Slice::GeneratorBase::containedToId(const ContainedPtr& contained, bool asTarget
string scoped = contained->scoped();
if(scoped[0] == ':')
{
- scoped.erase(0, 2);
+ scoped.erase(0, 2);
}
string id;
@@ -1211,15 +1211,15 @@ Slice::GeneratorBase::containedToId(const ContainedPtr& contained, bool asTarget
for(unsigned int i = 0; i < scoped.size(); ++i)
{
- if(scoped[i] == ':')
- {
- id += '.';
- ++i;
- }
- else
- {
- id += scoped[i];
- }
+ if(scoped[i] == ':')
+ {
+ id += '.';
+ ++i;
+ }
+ else
+ {
+ id += scoped[i];
+ }
}
//
@@ -1227,7 +1227,7 @@ Slice::GeneratorBase::containedToId(const ContainedPtr& contained, bool asTarget
//
if(id[0] == '.')
{
- id.erase(0, 1);
+ id.erase(0, 1);
}
return '"' + id + '"';
@@ -1240,29 +1240,29 @@ Slice::GeneratorBase::getTagged(const string& tag, string& comment)
string::size_type begin = 0;
while(begin < comment.size())
{
- begin = comment.find("@" + tag, begin);
- if(begin == string::npos)
- {
- return result;
- }
-
- string::size_type pos1 = comment.find_first_not_of(" \t\r\n", begin + tag.size() + 1);
- if(pos1 == string::npos)
- {
- comment.erase(begin);
- return result;
- }
-
- string::size_type pos2 = comment.find('@', pos1);
- string line = comment.substr(pos1, pos2 - pos1);
- comment.erase(begin, pos2 - 1 - begin);
-
- string::size_type pos3 = line.find_last_not_of(" \t\r\n");
- if(pos3 != string::npos)
- {
- line.erase(pos3 + 1);
- }
- result.push_back(line);
+ begin = comment.find("@" + tag, begin);
+ if(begin == string::npos)
+ {
+ return result;
+ }
+
+ string::size_type pos1 = comment.find_first_not_of(" \t\r\n", begin + tag.size() + 1);
+ if(pos1 == string::npos)
+ {
+ comment.erase(begin);
+ return result;
+ }
+
+ string::size_type pos2 = comment.find('@', pos1);
+ string line = comment.substr(pos1, pos2 - pos1);
+ comment.erase(begin, pos2 - 1 - begin);
+
+ string::size_type pos3 = line.find_last_not_of(" \t\r\n");
+ if(pos3 != string::npos)
+ {
+ line.erase(pos3 + 1);
+ }
+ result.push_back(line);
}
return result;
@@ -1273,7 +1273,7 @@ Slice::GeneratorBase::getScopedMinimized(const ContainedPtr& contained, const Co
{
if(shortName)
{
- return contained->name();
+ return contained->name();
}
string s = contained->scoped();
@@ -1282,21 +1282,21 @@ Slice::GeneratorBase::getScopedMinimized(const ContainedPtr& contained, const Co
if(!q) // Container is the global module
{
- return s.substr(2);
+ return s.substr(2);
}
do
{
- string s2 = q->scoped();
- s2 += "::";
+ string s2 = q->scoped();
+ s2 += "::";
- if(s.find(s2) == 0)
- {
- return s.substr(s2.size());
- }
+ if(s.find(s2) == 0)
+ {
+ return s.substr(s2.size());
+ }
- p = q->container();
- q = ContainedPtr::dynamicCast(p);
+ p = q->container();
+ q = ContainedPtr::dynamicCast(p);
}
while(q);
@@ -1309,17 +1309,17 @@ Slice::GeneratorBase::getContained(const SyntaxTreeBasePtr& p)
StringList result;
if(!p)
{
- return result;
+ return result;
}
SyntaxTreeBasePtr c = p;
do
{
- ContainedPtr contained = ContainedPtr::dynamicCast(c);
- assert(contained);
- result.push_front(contained->name());
- c = contained->container();
+ ContainedPtr contained = ContainedPtr::dynamicCast(c);
+ assert(contained);
+ result.push_front(contained->name());
+ c = contained->container();
}
while(!ContainerPtr::dynamicCast(c));
return result;
@@ -1332,24 +1332,24 @@ Slice::GeneratorBase::getContainer(const SyntaxTreeBasePtr& p)
if(!p)
{
- return result;
+ return result;
}
ContainedPtr contained = ContainedPtr::dynamicCast(p);
while(contained &&
- !ModulePtr::dynamicCast(contained) &&
- !ExceptionPtr::dynamicCast(contained) &&
- !ClassDefPtr::dynamicCast(contained) &&
- !StructPtr::dynamicCast(contained) &&
- !EnumPtr::dynamicCast(contained))
+ !ModulePtr::dynamicCast(contained) &&
+ !ExceptionPtr::dynamicCast(contained) &&
+ !ClassDefPtr::dynamicCast(contained) &&
+ !StructPtr::dynamicCast(contained) &&
+ !EnumPtr::dynamicCast(contained))
{
- contained = ContainedPtr::dynamicCast(contained->container());
+ contained = ContainedPtr::dynamicCast(contained->container());
}
while(contained)
{
- result.push_front(contained->name());
- contained = ContainedPtr::dynamicCast(contained->container());
+ result.push_front(contained->name());
+ contained = ContainedPtr::dynamicCast(contained->container());
}
return result;
}
@@ -1367,13 +1367,13 @@ Slice::GeneratorBase::toStringList(const ContainedPtr& c)
string::size_type endpos;
while((endpos = scoped.find("::", next)) != string::npos)
{
- ids.push_back(scoped.substr(next, endpos - next));
- next = endpos;
- if(next != string::npos)
- {
- ++next;
- ++next;
- }
+ ids.push_back(scoped.substr(next, endpos - next));
+ next = endpos;
+ if(next != string::npos)
+ {
+ ++next;
+ ++next;
+ }
}
ids.push_back(scoped.substr(next));
@@ -1387,7 +1387,7 @@ Slice::GeneratorBase::makeDir(const string& dir)
int rc = stat(dir.c_str(), &st);
if(rc == 0)
{
- return;
+ return;
}
#ifdef _WIN32
rc = mkdir(dir.c_str());
@@ -1396,8 +1396,8 @@ Slice::GeneratorBase::makeDir(const string& dir)
#endif
if(rc != 0)
{
- string err = "cannot create directory `" + dir + "'";
- throw err;
+ string err = "cannot create directory `" + dir + "'";
+ throw err;
}
}
@@ -1407,8 +1407,8 @@ Slice::GeneratorBase::readFile(const string& file)
ifstream in(file.c_str());
if(!in)
{
- string err = "cannot open `" + file + "' for reading";
- throw err;
+ string err = "cannot open `" + file + "' for reading";
+ throw err;
}
ostringstream result;
@@ -1416,8 +1416,8 @@ Slice::GeneratorBase::readFile(const string& file)
getline(in, line);
while(!line.empty())
{
- result << line << '\n';
- getline(in, line);
+ result << line << '\n';
+ getline(in, line);
}
return result.str();
@@ -1428,32 +1428,32 @@ Slice::GeneratorBase::getHeaders(const string& header, string& h1, string& h2)
{
if(header.empty())
{
- ostringstream hdr1;
- XMLOutput O1(hdr1);
- O1 << "<!-- Generated by Ice version " << ICE_STRING_VERSION << " -->";
- O1 << sp;
- O1 << nl << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">";
- O1 << se("html");
- O1 << se("head");
- O1 << se("title") << nl;
- h1 = hdr1.str();
-
- // _header1 and _header2 store the bit preceding and following the title.
- // _header1, the title text, and _header2 are written by openDoc().
-
- ostringstream hdr2;
- XMLOutput O2(hdr2);
- O2.inc();
- O2.inc();
- O2 << nl << "</title>";
- O2.dec();
- O2 << nl << "</head>";
- O2 << nl << "<body>";
- h2 = hdr2.str();
+ ostringstream hdr1;
+ XMLOutput O1(hdr1);
+ O1 << "<!-- Generated by Ice version " << ICE_STRING_VERSION << " -->";
+ O1 << sp;
+ O1 << nl << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">";
+ O1 << se("html");
+ O1 << se("head");
+ O1 << se("title") << nl;
+ h1 = hdr1.str();
+
+ // _header1 and _header2 store the bit preceding and following the title.
+ // _header1, the title text, and _header2 are written by openDoc().
+
+ ostringstream hdr2;
+ XMLOutput O2(hdr2);
+ O2.inc();
+ O2.inc();
+ O2 << nl << "</title>";
+ O2.dec();
+ O2 << nl << "</head>";
+ O2 << nl << "<body>";
+ h2 = hdr2.str();
}
else
{
- readFile(header, h1, h2);
+ readFile(header, h1, h2);
}
}
@@ -1464,11 +1464,11 @@ Slice::GeneratorBase::getFooter(const string& footer)
XMLOutput O(ftr);
if(footer.empty())
{
- O << " </body>";
+ O << " </body>";
}
else
{
- O << readFile(footer);
+ O << readFile(footer);
}
O << nl << "</html>";
return ftr.str();
@@ -1480,8 +1480,8 @@ Slice::GeneratorBase::readFile(const string& file, string& part1, string& part2)
ifstream in(file.c_str());
if(!in)
{
- string err = "cannot open `" + file + "' for reading";
- throw err;
+ string err = "cannot open `" + file + "' for reading";
+ throw err;
}
string line;
@@ -1490,28 +1490,28 @@ Slice::GeneratorBase::readFile(const string& file, string& part1, string& part2)
ostringstream p1;
while(!foundTitle && getline(in, line))
{
- if(line == "TITLE")
- {
- foundTitle = true;
- }
- else
- {
- p1 << line << '\n';
- }
+ if(line == "TITLE")
+ {
+ foundTitle = true;
+ }
+ else
+ {
+ p1 << line << '\n';
+ }
}
part1 = p1.str();
if(!foundTitle)
{
- string err = "no TITLE marker in `" + file + "'";
- throw err;
+ string err = "no TITLE marker in `" + file + "'";
+ throw err;
}
ostringstream p2;
p2 << endl;
while(getline(in, line))
{
- p2 << line << '\n';
+ p2 << line << '\n';
}
part2 = p2.str();
}
@@ -1539,12 +1539,12 @@ Slice::StartPageGenerator::~StartPageGenerator()
start("dl");
for(ModuleDescriptions::const_iterator i = _modules.begin(); i != _modules.end(); ++i)
{
- start("dt", "Symbol");
- _out << i->first;
- end();
- start("dd");
- _out << i->second;
- end();
+ start("dt", "Symbol");
+ _out << i->first;
+ end();
+ start("dd");
+ _out << i->second;
+ end();
}
end();
@@ -1573,12 +1573,12 @@ Slice::StartPageGenerator::printHeaderFooter()
string imageDir = getImageDir();
if(imageDir.empty())
{
- _out << "<a href=\"_sindex.html\">Index</a>";
+ _out << "<a href=\"_sindex.html\">Index</a>";
}
else
{
- string src = imageDir + "/index.gif";
- _out << "<a href=\"_sindex.html\"><img class=\"Button\" src=\"" + src + "\" alt=\"Index Button\"/></a>";
+ string src = imageDir + "/index.gif";
+ _out << "<a href=\"_sindex.html\"><img class=\"Button\" src=\"" + src + "\" alt=\"Index Button\"/></a>";
}
end();
end();
@@ -1588,22 +1588,22 @@ Slice::StartPageGenerator::printHeaderFooter()
if(!imageDir.empty())
{
- start("table", "LogoTable");
- start("tr");
- start("td");
- string logoURL = getLogoURL();
- if(!logoURL.empty())
- {
- _out << "<a href=\"" + logoURL + "\">";
- }
- _out << "<img class=\"Logo\" src=\"" + imageDir + "/logo.gif\" alt=\"Logo\"/>";
- if(!logoURL.empty())
- {
- _out << "</a>";
- }
- end();
- end();
- end();
+ start("table", "LogoTable");
+ start("tr");
+ start("td");
+ string logoURL = getLogoURL();
+ if(!logoURL.empty())
+ {
+ _out << "<a href=\"" + logoURL + "\">";
+ }
+ _out << "<img class=\"Logo\" src=\"" + imageDir + "/logo.gif\" alt=\"Logo\"/>";
+ if(!logoURL.empty())
+ {
+ _out << "</a>";
+ }
+ end();
+ end();
+ end();
}
end();
@@ -1731,7 +1731,7 @@ TOCGenerator::writeTOC()
_out.inc();
for(ModuleList::const_iterator i = _modules.begin(); i != _modules.end(); ++i)
{
- writeEntry(*i);
+ writeEntry(*i);
}
_out.dec();
_out << nl << "</ul>";
@@ -1757,89 +1757,89 @@ TOCGenerator::writeEntry(const ContainedPtr& c)
ModulePtr m = ModulePtr::dynamicCast(c);
if(m)
{
- cl = m->contents();
+ cl = m->contents();
}
EnumPtr en = EnumPtr::dynamicCast(c);
if(en)
{
- EnumeratorList enumerators = en->getEnumerators();
- for(EnumeratorList::const_iterator i = enumerators.begin(); i != enumerators.end(); ++i)
- {
- cl.push_back(*i);
- }
+ EnumeratorList enumerators = en->getEnumerators();
+ for(EnumeratorList::const_iterator i = enumerators.begin(); i != enumerators.end(); ++i)
+ {
+ cl.push_back(*i);
+ }
}
StructPtr s = StructPtr::dynamicCast(c);
if(s)
{
- DataMemberList dml = s->dataMembers();
- for(DataMemberList::const_iterator i = dml.begin(); i != dml.end(); ++i)
- {
- cl.push_back(*i);
- }
+ DataMemberList dml = s->dataMembers();
+ for(DataMemberList::const_iterator i = dml.begin(); i != dml.end(); ++i)
+ {
+ cl.push_back(*i);
+ }
}
ExceptionPtr e = ExceptionPtr::dynamicCast(c);
if(e)
{
- DataMemberList dml = e->dataMembers();
- for(DataMemberList::const_iterator i = dml.begin(); i != dml.end(); ++i)
- {
- cl.push_back(*i);
- }
+ DataMemberList dml = e->dataMembers();
+ for(DataMemberList::const_iterator i = dml.begin(); i != dml.end(); ++i)
+ {
+ cl.push_back(*i);
+ }
}
ClassDefPtr cdef = ClassDefPtr::dynamicCast(c);
if(!cdef)
{
- ClassDeclPtr cdec = ClassDeclPtr::dynamicCast(c);
- if(cdec)
- {
- cdef = cdec->definition();
- }
+ ClassDeclPtr cdec = ClassDeclPtr::dynamicCast(c);
+ if(cdec)
+ {
+ cdef = cdec->definition();
+ }
}
if(cdef)
{
- DataMemberList dml = cdef->dataMembers();
- for(DataMemberList::const_iterator i = dml.begin(); i != dml.end(); ++i)
- {
- cl.push_back(*i);
- }
- OperationList ol = cdef->operations();
- for(OperationList::const_iterator j = ol.begin(); j != ol.end(); ++j)
- {
- cl.push_back(*j);
- }
+ DataMemberList dml = cdef->dataMembers();
+ for(DataMemberList::const_iterator i = dml.begin(); i != dml.end(); ++i)
+ {
+ cl.push_back(*i);
+ }
+ OperationList ol = cdef->operations();
+ for(OperationList::const_iterator j = ol.begin(); j != ol.end(); ++j)
+ {
+ cl.push_back(*j);
+ }
}
start("li");
if(!cl.empty())
{
- cl.sort();
- cl.unique();
+ cl.sort();
+ cl.unique();
- _out << nl << toString(c, 0, false, true, 0, true);
- start("ul");
- for(ContainedList::const_iterator i = cl.begin(); i != cl.end(); ++i)
- {
- writeEntry(*i);
- }
- end();
+ _out << nl << toString(c, 0, false, true, 0, true);
+ start("ul");
+ for(ContainedList::const_iterator i = cl.begin(); i != cl.end(); ++i)
+ {
+ writeEntry(*i);
+ }
+ end();
}
else
{
- _out << nl << toString(c, 0, false, true, 0, true);
+ _out << nl << toString(c, 0, false, true, 0, true);
}
if(ModulePtr::dynamicCast(c) || ExceptionPtr::dynamicCast(c) || ClassDefPtr::dynamicCast(c) ||
StructPtr::dynamicCast(c) || EnumPtr::dynamicCast(c))
{
- _symbols.push_back(c);
+ _symbols.push_back(c);
}
else if(ClassDeclPtr::dynamicCast(c))
{
- _symbols.push_back(ClassDeclPtr::dynamicCast(c)->definition());
+ _symbols.push_back(ClassDeclPtr::dynamicCast(c)->definition());
}
end();
}
@@ -1898,11 +1898,11 @@ Slice::ModuleGenerator::generate(const ModulePtr& m)
string metadata, deprecateReason;
if(m->findMetaData("deprecate", metadata))
{
- deprecateReason = "This module is deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- deprecateReason = metadata.substr(10);
- }
+ deprecateReason = "This module is deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ deprecateReason = metadata.substr(10);
+ }
}
start("h2");
_out << "Overview";
@@ -1935,21 +1935,21 @@ Slice::ModuleGenerator::visitContainer(const ContainerPtr& p)
if(!modules.empty())
{
- start("h2");
- _out << "Module Index";
- end();
- start("dl");
- for(ModuleList::const_iterator q = modules.begin(); q != modules.end(); ++q)
- {
- start("dt", "Symbol");
- _out << toString(*q, p, false, true);
- end();
- start("dd");
- string metadata;
- printSummary(*q, p, (*q)->findMetaData("deprecate", metadata));
- end();
- }
- end();
+ start("h2");
+ _out << "Module Index";
+ end();
+ start("dl");
+ for(ModuleList::const_iterator q = modules.begin(); q != modules.end(); ++q)
+ {
+ start("dt", "Symbol");
+ _out << toString(*q, p, false, true);
+ end();
+ start("dd");
+ string metadata;
+ printSummary(*q, p, (*q)->findMetaData("deprecate", metadata));
+ end();
+ }
+ end();
}
assert(_out.currIndent() == indent);
@@ -1958,48 +1958,48 @@ Slice::ModuleGenerator::visitContainer(const ContainerPtr& p)
ClassList classes;
ClassList interfaces;
remove_copy_if(classesAndInterfaces.begin(), classesAndInterfaces.end(), back_inserter(classes),
- ::IceUtil::constMemFun(&ClassDef::isInterface));
+ ::IceUtil::constMemFun(&ClassDef::isInterface));
remove_copy_if(classesAndInterfaces.begin(), classesAndInterfaces.end(), back_inserter(interfaces),
- not1(::IceUtil::constMemFun(&ClassDef::isInterface)));
+ not1(::IceUtil::constMemFun(&ClassDef::isInterface)));
if(!classes.empty())
{
- start("h2");
- _out << "Class Index";
- end();
- start("dl");
- for(ClassList::const_iterator q = classes.begin(); q != classes.end(); ++q)
- {
- start("dt", "Symbol");
- _out << toString(*q, p, false, true);
- end();
- start("dd");
- string metadata;
- printSummary(*q, p, (*q)->findMetaData("deprecate", metadata));
- end();
- }
- end();
+ start("h2");
+ _out << "Class Index";
+ end();
+ start("dl");
+ for(ClassList::const_iterator q = classes.begin(); q != classes.end(); ++q)
+ {
+ start("dt", "Symbol");
+ _out << toString(*q, p, false, true);
+ end();
+ start("dd");
+ string metadata;
+ printSummary(*q, p, (*q)->findMetaData("deprecate", metadata));
+ end();
+ }
+ end();
}
assert(_out.currIndent() == indent);
if(!interfaces.empty())
{
- start("h2");
- _out << "Interface Index";
- end();
- start("dl");
- for(ClassList::const_iterator q = interfaces.begin(); q != interfaces.end(); ++q)
- {
- start("dt", "Symbol");
- _out << toString(*q, p, false, true);
- end();
- start("dd");
- string metadata;
- printSummary(*q, p, (*q)->findMetaData("deprecate", metadata));
- end();
- }
- end();
+ start("h2");
+ _out << "Interface Index";
+ end();
+ start("dl");
+ for(ClassList::const_iterator q = interfaces.begin(); q != interfaces.end(); ++q)
+ {
+ start("dt", "Symbol");
+ _out << toString(*q, p, false, true);
+ end();
+ start("dd");
+ string metadata;
+ printSummary(*q, p, (*q)->findMetaData("deprecate", metadata));
+ end();
+ }
+ end();
}
assert(_out.currIndent() == indent);
@@ -2008,21 +2008,21 @@ Slice::ModuleGenerator::visitContainer(const ContainerPtr& p)
if(!exceptions.empty())
{
- start("h2");
- _out << "Exception Index";
- end();
- start("dl");
- for(ExceptionList::const_iterator q = exceptions.begin(); q != exceptions.end(); ++q)
- {
- start("dt", "Symbol");
- _out << toString(*q, p, false, true);
- end();
- start("dd");
- string metadata;
- printSummary(*q, p, (*q)->findMetaData("deprecate", metadata));
- end();
- }
- end();
+ start("h2");
+ _out << "Exception Index";
+ end();
+ start("dl");
+ for(ExceptionList::const_iterator q = exceptions.begin(); q != exceptions.end(); ++q)
+ {
+ start("dt", "Symbol");
+ _out << toString(*q, p, false, true);
+ end();
+ start("dd");
+ string metadata;
+ printSummary(*q, p, (*q)->findMetaData("deprecate", metadata));
+ end();
+ }
+ end();
}
assert(_out.currIndent() == indent);
@@ -2031,21 +2031,21 @@ Slice::ModuleGenerator::visitContainer(const ContainerPtr& p)
if(!structs.empty())
{
- start("h2");
- _out << "Structure Index";
- end();
- start("dl");
- for(StructList::const_iterator q = structs.begin(); q != structs.end(); ++q)
- {
- start("dt", "Symbol");
- _out << toString(*q, p, false, true);
- end();
- start("dd");
- string metadata;
- printSummary(*q, p, (*q)->findMetaData("deprecate", metadata));
- end();
- }
- end();
+ start("h2");
+ _out << "Structure Index";
+ end();
+ start("dl");
+ for(StructList::const_iterator q = structs.begin(); q != structs.end(); ++q)
+ {
+ start("dt", "Symbol");
+ _out << toString(*q, p, false, true);
+ end();
+ start("dd");
+ string metadata;
+ printSummary(*q, p, (*q)->findMetaData("deprecate", metadata));
+ end();
+ }
+ end();
}
assert(_out.currIndent() == indent);
@@ -2054,21 +2054,21 @@ Slice::ModuleGenerator::visitContainer(const ContainerPtr& p)
if(!sequences.empty())
{
- start("h2");
- _out << "Sequence Index";
- end();
- start("dl");
- for(SequenceList::const_iterator q = sequences.begin(); q != sequences.end(); ++q)
- {
- start("dt", "Symbol");
- _out << toString(*q, p, false, true);
- end();
- start("dd");
- string metadata;
- printSummary(*q, p, (*q)->findMetaData("deprecate", metadata));
- end();
- }
- end();
+ start("h2");
+ _out << "Sequence Index";
+ end();
+ start("dl");
+ for(SequenceList::const_iterator q = sequences.begin(); q != sequences.end(); ++q)
+ {
+ start("dt", "Symbol");
+ _out << toString(*q, p, false, true);
+ end();
+ start("dd");
+ string metadata;
+ printSummary(*q, p, (*q)->findMetaData("deprecate", metadata));
+ end();
+ }
+ end();
}
assert(_out.currIndent() == indent);
@@ -2077,21 +2077,21 @@ Slice::ModuleGenerator::visitContainer(const ContainerPtr& p)
if(!dictionaries.empty())
{
- start("h2");
- _out << "Dictionary Index";
- end();
- start("dl");
- for(DictionaryList::const_iterator q = dictionaries.begin(); q != dictionaries.end(); ++q)
- {
- start("dt", "Symbol");
- _out << toString(*q, p, false, true);
- end();
- start("dd");
- string metadata;
- printSummary(*q, p, (*q)->findMetaData("deprecate", metadata));
- end();
- }
- end();
+ start("h2");
+ _out << "Dictionary Index";
+ end();
+ start("dl");
+ for(DictionaryList::const_iterator q = dictionaries.begin(); q != dictionaries.end(); ++q)
+ {
+ start("dt", "Symbol");
+ _out << toString(*q, p, false, true);
+ end();
+ start("dd");
+ string metadata;
+ printSummary(*q, p, (*q)->findMetaData("deprecate", metadata));
+ end();
+ }
+ end();
}
assert(_out.currIndent() == indent);
@@ -2100,99 +2100,99 @@ Slice::ModuleGenerator::visitContainer(const ContainerPtr& p)
if(!enums.empty())
{
- start("h2");
- _out << "Enumeration Index";
- end();
- start("dl");
- for(EnumList::const_iterator q = enums.begin(); q != enums.end(); ++q)
- {
- start("dt", "Symbol");
- _out << toString(*q, p, false, true);
- end();
- start("dd");
- string metadata;
- printSummary(*q, p, (*q)->findMetaData("deprecate", metadata));
- end();
- }
- end();
+ start("h2");
+ _out << "Enumeration Index";
+ end();
+ start("dl");
+ for(EnumList::const_iterator q = enums.begin(); q != enums.end(); ++q)
+ {
+ start("dt", "Symbol");
+ _out << toString(*q, p, false, true);
+ end();
+ start("dd");
+ string metadata;
+ printSummary(*q, p, (*q)->findMetaData("deprecate", metadata));
+ end();
+ }
+ end();
}
assert(_out.currIndent() == indent);
if(!sequences.empty())
{
- start("h2");
- _out << "Sequences";
- end();
- for(SequenceList::const_iterator q = sequences.begin(); q != sequences.end(); ++q)
- {
- start("dl");
- start("dt");
- start("span", "Synopsis");
- printMetaData(*q);
- if((*q)->isLocal())
- {
- _out << "local ";
- }
- TypePtr type = (*q)->type();
- _out << "sequence&lt;" << toString(type, p, false, true) << "&gt; " << toString(*q, p);
- end();
- end();
-
- start("dd");
- string metadata, deprecateReason;
- if((*q)->findMetaData("deprecate", metadata))
- {
- deprecateReason = "This type is deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- deprecateReason = metadata.substr(10);
- }
- }
-
- printComment(*q, p, deprecateReason, true);
- end();
- end();
- }
+ start("h2");
+ _out << "Sequences";
+ end();
+ for(SequenceList::const_iterator q = sequences.begin(); q != sequences.end(); ++q)
+ {
+ start("dl");
+ start("dt");
+ start("span", "Synopsis");
+ printMetaData(*q);
+ if((*q)->isLocal())
+ {
+ _out << "local ";
+ }
+ TypePtr type = (*q)->type();
+ _out << "sequence&lt;" << toString(type, p, false, true) << "&gt; " << toString(*q, p);
+ end();
+ end();
+
+ start("dd");
+ string metadata, deprecateReason;
+ if((*q)->findMetaData("deprecate", metadata))
+ {
+ deprecateReason = "This type is deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ deprecateReason = metadata.substr(10);
+ }
+ }
+
+ printComment(*q, p, deprecateReason, true);
+ end();
+ end();
+ }
}
if(!dictionaries.empty())
{
- start("h2");
- _out << "Dictionaries";
- end();
- for(DictionaryList::const_iterator q = dictionaries.begin(); q != dictionaries.end(); ++q)
- {
- start("dl");
- start("dt");
- start("span", "Synopsis");
- printMetaData(*q);
- if((*q)->isLocal())
- {
- _out << "local ";
- }
- TypePtr keyType = (*q)->keyType();
- TypePtr valueType = (*q)->valueType();
- _out << "dictionary&lt;" << toString(keyType, p, false, true) << ", "
- << toString(valueType, p, false, true) << "&gt; " << toString(*q, p);
- end();
- end();
-
- start("dd");
- string metadata, deprecateReason;
- if((*q)->findMetaData("deprecate", metadata))
- {
- deprecateReason = "This type is deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- deprecateReason = metadata.substr(10);
- }
- }
-
- printComment(*q, p, deprecateReason, true);
- end();
- end();
- }
+ start("h2");
+ _out << "Dictionaries";
+ end();
+ for(DictionaryList::const_iterator q = dictionaries.begin(); q != dictionaries.end(); ++q)
+ {
+ start("dl");
+ start("dt");
+ start("span", "Synopsis");
+ printMetaData(*q);
+ if((*q)->isLocal())
+ {
+ _out << "local ";
+ }
+ TypePtr keyType = (*q)->keyType();
+ TypePtr valueType = (*q)->valueType();
+ _out << "dictionary&lt;" << toString(keyType, p, false, true) << ", "
+ << toString(valueType, p, false, true) << "&gt; " << toString(*q, p);
+ end();
+ end();
+
+ start("dd");
+ string metadata, deprecateReason;
+ if((*q)->findMetaData("deprecate", metadata))
+ {
+ deprecateReason = "This type is deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ deprecateReason = metadata.substr(10);
+ }
+ }
+
+ printComment(*q, p, deprecateReason, true);
+ end();
+ end();
+ }
}
}
@@ -2221,11 +2221,11 @@ Slice::ExceptionGenerator::generate(const ExceptionPtr& e)
bool deprecatedException = e->findMetaData("deprecate", metadata);
if(deprecatedException)
{
- deprecateReason = "This module is deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- deprecateReason = metadata.substr(10);
- }
+ deprecateReason = "This module is deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ deprecateReason = metadata.substr(10);
+ }
}
start("h2");
@@ -2236,18 +2236,18 @@ Slice::ExceptionGenerator::generate(const ExceptionPtr& e)
printMetaData(e);
if(e->isLocal())
{
- _out << "local ";
+ _out << "local ";
}
_out << "exception " << e->name();
ExceptionPtr base = e->base();
if(base)
{
- _out.inc();
- _out << nl << "extends ";
- _out.inc();
- _out << nl << toString(base, e);
- _out.dec();
- _out.dec();
+ _out.inc();
+ _out << nl << "extends ";
+ _out.inc();
+ _out << nl << toString(base, e);
+ _out.dec();
+ _out.dec();
}
end();
@@ -2257,55 +2257,55 @@ Slice::ExceptionGenerator::generate(const ExceptionPtr& e)
if(_indexCount > 0 && dataMembers.size() >= _indexCount)
{
- start("h2");
- _out << "Data Member Index";
- end();
- start("dl");
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- start("dt", "Symbol");
- _out << toString(*q, e, false);
- end();
- start("dd");
- string metadata;
- printSummary(*q, e, (*q)->findMetaData("deprecate", metadata));
- end();
- }
- end();
+ start("h2");
+ _out << "Data Member Index";
+ end();
+ start("dl");
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ start("dt", "Symbol");
+ _out << toString(*q, e, false);
+ end();
+ start("dd");
+ string metadata;
+ printSummary(*q, e, (*q)->findMetaData("deprecate", metadata));
+ end();
+ }
+ end();
}
if(!dataMembers.empty())
{
- start("h2");
- _out << "Data Members";
- end();
- start("dl");
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- start("dt", "Symbol");
- printMetaData(*q);
- TypePtr type = (*q)->type();
- _out << toString(type, e) << " " << toString(*q, e) << ";";
- end();
-
- start("dd");
- string reason;
- metadata.clear();
- if(deprecatedException || (*q)->findMetaData("deprecate", metadata))
- {
- reason = "This member is deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- reason = metadata.substr(10);
- }
- }
-
- printComment(*q, e, reason);
- end();
- }
- end();
- }
-
+ start("h2");
+ _out << "Data Members";
+ end();
+ start("dl");
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ start("dt", "Symbol");
+ printMetaData(*q);
+ TypePtr type = (*q)->type();
+ _out << toString(type, e) << " " << toString(*q, e) << ";";
+ end();
+
+ start("dd");
+ string reason;
+ metadata.clear();
+ if(deprecatedException || (*q)->findMetaData("deprecate", metadata))
+ {
+ reason = "This member is deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ reason = metadata.substr(10);
+ }
+ }
+
+ printComment(*q, e, reason);
+ end();
+ }
+ end();
+ }
+
_out << nl << "<hr>";
printHeaderFooter(e);
@@ -2339,13 +2339,13 @@ Slice::ClassGenerator::generate(const ClassDefPtr& c)
bool deprecatedClass = c->findMetaData("deprecate", metadata);
if(deprecatedClass)
{
- deprecateReason = "This ";
- deprecateReason += c->isInterface() ? "interface" : "class";
- deprecateReason += " is deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- deprecateReason = metadata.substr(10);
- }
+ deprecateReason = "This ";
+ deprecateReason += c->isInterface() ? "interface" : "class";
+ deprecateReason += " is deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ deprecateReason = metadata.substr(10);
+ }
}
start("h2");
@@ -2355,29 +2355,29 @@ Slice::ClassGenerator::generate(const ClassDefPtr& c)
printMetaData(c);
if(c->isLocal())
{
- _out << "local ";
+ _out << "local ";
}
_out << (c->isInterface() ? "interface" : "class" )<< " " << c->name();
ClassList bases = c->bases();
if(!bases.empty() && !bases.front()->isInterface())
{
- _out << " extends " << toString(bases.front(), c);
- bases.pop_front();
+ _out << " extends " << toString(bases.front(), c);
+ bases.pop_front();
}
if(!bases.empty())
{
- _out << (c->isInterface() ? " extends " : " implements ");
- ClassList::const_iterator q = bases.begin();
- while(q != bases.end())
- {
- _out << toString(*q, c, false);
- if(++q != bases.end())
- {
- _out << ", ";
- }
- }
+ _out << (c->isInterface() ? " extends " : " implements ");
+ ClassList::const_iterator q = bases.begin();
+ while(q != bases.end())
+ {
+ _out << toString(*q, c, false);
+ if(++q != bases.end())
+ {
+ _out << ", ";
+ }
+ }
}
end();
@@ -2387,127 +2387,127 @@ Slice::ClassGenerator::generate(const ClassDefPtr& c)
if(_indexCount > 0 && operations.size() >= _indexCount)
{
- start("h2");
- _out << "Operation Index";
- end();
- start("dl");
- for(OperationList::const_iterator q = operations.begin(); q != operations.end(); ++q)
- {
- start("dt", "Symbol");
- _out << toString(*q, c, false);
- end();
- start("dd");
- string metadata;
- printSummary(*q, c, (*q)->findMetaData("deprecate", metadata));
- end();
- }
- end();
+ start("h2");
+ _out << "Operation Index";
+ end();
+ start("dl");
+ for(OperationList::const_iterator q = operations.begin(); q != operations.end(); ++q)
+ {
+ start("dt", "Symbol");
+ _out << toString(*q, c, false);
+ end();
+ start("dd");
+ string metadata;
+ printSummary(*q, c, (*q)->findMetaData("deprecate", metadata));
+ end();
+ }
+ end();
}
DataMemberList dataMembers = c->dataMembers();
if(_indexCount > 0 && dataMembers.size() >= _indexCount)
{
- start("h2");
- _out << "Data Member Index";
- end();
- start("dl");
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- start("dt", "Symbol");
- _out << toString(*q, c, false);
- end();
- start("dd");
- string metadata;
- printSummary(*q, c, (*q)->findMetaData("deprecate", metadata));
- end();
- }
- end();
+ start("h2");
+ _out << "Data Member Index";
+ end();
+ start("dl");
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ start("dt", "Symbol");
+ _out << toString(*q, c, false);
+ end();
+ start("dd");
+ string metadata;
+ printSummary(*q, c, (*q)->findMetaData("deprecate", metadata));
+ end();
+ }
+ end();
}
if(!operations.empty())
{
- start("h2");
- _out << "Operations";
- end();
- for(OperationList::const_iterator q = operations.begin(); q != operations.end(); ++q)
- {
- start("h3", "Synopsis");
- TypePtr returnType = (*q)->returnType();
- _out << (returnType ? toString(returnType, c, false) : string("void")) << " "
- << toString(*q, c) << "(";
- ParamDeclList params = (*q)->parameters();
- ParamDeclList::const_iterator r = params.begin();
- while(r != params.end())
- {
- if((*r)->isOutParam())
- {
- _out << "out ";
- }
- _out << toString((*r)->type(), ContainedPtr::dynamicCast(*q)->container(), false)
- << " " << (*r)->name();
- if(++r != params.end())
- {
- _out << ", ";
- }
- }
- _out << ")";
- ExceptionList throws = (*q)->throws();
- if(!throws.empty())
- {
- _out << " throws ";
- ExceptionList::const_iterator t = throws.begin();
- while(t != throws.end())
- {
- _out << toString(*t, c, false);
- if(++t != throws.end())
- {
- _out << ", ";
- }
- }
- }
- end();
-
- string reason;
- metadata.clear();
- if(deprecatedClass || (*q)->findMetaData("deprecate", metadata))
- {
- reason = "This operation is deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- reason = metadata.substr(10);
- }
- }
- printComment(*q, c, reason);
- }
+ start("h2");
+ _out << "Operations";
+ end();
+ for(OperationList::const_iterator q = operations.begin(); q != operations.end(); ++q)
+ {
+ start("h3", "Synopsis");
+ TypePtr returnType = (*q)->returnType();
+ _out << (returnType ? toString(returnType, c, false) : string("void")) << " "
+ << toString(*q, c) << "(";
+ ParamDeclList params = (*q)->parameters();
+ ParamDeclList::const_iterator r = params.begin();
+ while(r != params.end())
+ {
+ if((*r)->isOutParam())
+ {
+ _out << "out ";
+ }
+ _out << toString((*r)->type(), ContainedPtr::dynamicCast(*q)->container(), false)
+ << " " << (*r)->name();
+ if(++r != params.end())
+ {
+ _out << ", ";
+ }
+ }
+ _out << ")";
+ ExceptionList throws = (*q)->throws();
+ if(!throws.empty())
+ {
+ _out << " throws ";
+ ExceptionList::const_iterator t = throws.begin();
+ while(t != throws.end())
+ {
+ _out << toString(*t, c, false);
+ if(++t != throws.end())
+ {
+ _out << ", ";
+ }
+ }
+ }
+ end();
+
+ string reason;
+ metadata.clear();
+ if(deprecatedClass || (*q)->findMetaData("deprecate", metadata))
+ {
+ reason = "This operation is deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ reason = metadata.substr(10);
+ }
+ }
+ printComment(*q, c, reason);
+ }
}
if(!dataMembers.empty())
{
- start("h2");
- _out << "Data Members";
- end();
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- start("h3", "Synopsis");
- printMetaData(*q);
- TypePtr type = (*q)->type();
- _out << toString(type, c, false) << " " << toString(*q, c) << ";";
- end();
-
- string reason;
- metadata.clear();
- if(deprecatedClass || (*q)->findMetaData("deprecate", metadata))
- {
- reason = "This member is deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- reason = metadata.substr(10);
- }
- }
-
- printComment(*q, c, reason);
- }
+ start("h2");
+ _out << "Data Members";
+ end();
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ start("h3", "Synopsis");
+ printMetaData(*q);
+ TypePtr type = (*q)->type();
+ _out << toString(type, c, false) << " " << toString(*q, c) << ";";
+ end();
+
+ string reason;
+ metadata.clear();
+ if(deprecatedClass || (*q)->findMetaData("deprecate", metadata))
+ {
+ reason = "This member is deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ reason = metadata.substr(10);
+ }
+ }
+
+ printComment(*q, c, reason);
+ }
}
_out << nl << "<hr>";
@@ -2543,11 +2543,11 @@ Slice::StructGenerator::generate(const StructPtr& s)
bool deprecatedException = s->findMetaData("deprecate", metadata);
if(deprecatedException)
{
- deprecateReason = "This module is deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- deprecateReason = metadata.substr(10);
- }
+ deprecateReason = "This module is deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ deprecateReason = metadata.substr(10);
+ }
}
start("h2");
@@ -2558,7 +2558,7 @@ Slice::StructGenerator::generate(const StructPtr& s)
printMetaData(s);
if(s->isLocal())
{
- _out << "local ";
+ _out << "local ";
}
_out << "struct " << s->name();
end();
@@ -2569,55 +2569,55 @@ Slice::StructGenerator::generate(const StructPtr& s)
if(_indexCount > 0 && dataMembers.size() >= _indexCount)
{
- start("h2");
- _out << "Data Member Index";
- end();
- start("dl");
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- start("dt", "Symbol");
- _out << toString(*q, s, false);
- end();
- start("dd");
- string metadata;
- printSummary(*q, s, (*q)->findMetaData("deprecate", metadata));
- end();
- }
- end();
+ start("h2");
+ _out << "Data Member Index";
+ end();
+ start("dl");
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ start("dt", "Symbol");
+ _out << toString(*q, s, false);
+ end();
+ start("dd");
+ string metadata;
+ printSummary(*q, s, (*q)->findMetaData("deprecate", metadata));
+ end();
+ }
+ end();
}
if(!dataMembers.empty())
{
- start("h2");
- _out << "Data Members";
- end();
- start("dl");
- for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- start("dt", "Symbol");
- printMetaData(*q);
- TypePtr type = (*q)->type();
- _out << toString(type, s, false) << " " << toString(*q, s) << ";";
- end();
-
- start("dd");
- string reason;
- metadata.clear();
- if(deprecatedException || (*q)->findMetaData("deprecate", metadata))
- {
- reason = "This member is deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- reason = metadata.substr(10);
- }
- }
-
- printComment(*q, s, reason);
- end();
- }
- end();
- }
-
+ start("h2");
+ _out << "Data Members";
+ end();
+ start("dl");
+ for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ start("dt", "Symbol");
+ printMetaData(*q);
+ TypePtr type = (*q)->type();
+ _out << toString(type, s, false) << " " << toString(*q, s) << ";";
+ end();
+
+ start("dd");
+ string reason;
+ metadata.clear();
+ if(deprecatedException || (*q)->findMetaData("deprecate", metadata))
+ {
+ reason = "This member is deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ reason = metadata.substr(10);
+ }
+ }
+
+ printComment(*q, s, reason);
+ end();
+ }
+ end();
+ }
+
_out << nl << "<hr>";
printHeaderFooter(s);
@@ -2651,11 +2651,11 @@ Slice::EnumGenerator::generate(const EnumPtr& e)
bool deprecatedException = e->findMetaData("deprecate", metadata);
if(deprecatedException)
{
- deprecateReason = "This enumeration is deprecated.";
- if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
- {
- deprecateReason = metadata.substr(10);
- }
+ deprecateReason = "This enumeration is deprecated.";
+ if(metadata.find("deprecate:") == 0 && metadata.size() > 10)
+ {
+ deprecateReason = metadata.substr(10);
+ }
}
start("h2");
@@ -2666,7 +2666,7 @@ Slice::EnumGenerator::generate(const EnumPtr& e)
printMetaData(e);
if(e->isLocal())
{
- _out << "local ";
+ _out << "local ";
}
_out << "enum " << e->name();
end();
@@ -2676,27 +2676,27 @@ Slice::EnumGenerator::generate(const EnumPtr& e)
EnumeratorList enumerators = e->getEnumerators();
if(!enumerators.empty())
{
- start("h2");
- _out << "Enumerators";
- end();
- start("dl");
- for(EnumeratorList::const_iterator q = enumerators.begin(); q != enumerators.end(); ++q)
- {
- start("dt", "Symbol");
- _out << (*q)->name();
- end();
-
- start("dd");
- string reason;
- //
- // Enumerators do not support metadata.
- //
- printComment(*q, e->container(), reason, false);
- end();
- }
- end();
- }
-
+ start("h2");
+ _out << "Enumerators";
+ end();
+ start("dl");
+ for(EnumeratorList::const_iterator q = enumerators.begin(); q != enumerators.end(); ++q)
+ {
+ start("dt", "Symbol");
+ _out << (*q)->name();
+ end();
+
+ start("dd");
+ string reason;
+ //
+ // Enumerators do not support metadata.
+ //
+ printComment(*q, e->container(), reason, false);
+ end();
+ }
+ end();
+ }
+
closeDoc();
_out << nl << "<hr>";
diff --git a/cpp/src/slice2html/Gen.h b/cpp/src/slice2html/Gen.h
index 408ee5772ed..88abf9651e3 100644
--- a/cpp/src/slice2html/Gen.h
+++ b/cpp/src/slice2html/Gen.h
@@ -17,7 +17,7 @@ namespace Slice
{
void generate(const UnitPtr&, const ::std::string&, const ::std::string&, const ::std::string&, const std::string&,
- const ::std::string&, const ::std::string&, const ::std::string&, const ::std::string&,
+ const ::std::string&, const ::std::string&, const ::std::string&, const ::std::string&,
unsigned, unsigned);
typedef ::std::set< ::std::string> Files;
@@ -57,7 +57,7 @@ protected:
void printLogo(const ContainedPtr&, const ContainerPtr&, bool);
::std::string toString(const SyntaxTreeBasePtr&, const ContainerPtr&, bool = true, bool = false,
- unsigned* = 0, bool = false);
+ unsigned* = 0, bool = false);
::std::string toString(const ::std::string&, const ContainerPtr&, bool = true, bool = false, unsigned* = 0);
::std::string getComment(const ContainedPtr&, const ContainerPtr&, bool, bool = false);
diff --git a/cpp/src/slice2html/Main.cpp b/cpp/src/slice2html/Main.cpp
index 4befc462ca3..bda3228acbe 100644
--- a/cpp/src/slice2html/Main.cpp
+++ b/cpp/src/slice2html/Main.cpp
@@ -28,17 +28,17 @@ usage(const char* n)
"-DNAME=DEF Define NAME as DEF.\n"
"-UNAME Remove any definition for NAME.\n"
"-IDIR Put DIR in the include file search path.\n"
- "-E Print preprocessor output on stdout.\n"
- "--output-dir DIR Create files in the directory DIR.\n"
+ "-E Print preprocessor output on stdout.\n"
+ "--output-dir DIR Create files in the directory DIR.\n"
"--hdr FILE Use the contents of FILE as the header.\n"
- "--ftr FILe Use the contents of FILE as the footer.\n"
- "--indexhdr FILE Use the contents of FILE as the header of the index/toc page (default=--hdr).\n"
- "--indexftr FILE Use the contents of FILE as the footer of the index/toc page (default=--ftr).\n"
- "--image-dir DIR Directory containing images for style sheets.\n"
- "--logo-url URL Link to URL from logo image (requires --image-dir).\n"
+ "--ftr FILe Use the contents of FILE as the footer.\n"
+ "--indexhdr FILE Use the contents of FILE as the header of the index/toc page (default=--hdr).\n"
+ "--indexftr FILE Use the contents of FILE as the footer of the index/toc page (default=--ftr).\n"
+ "--image-dir DIR Directory containing images for style sheets.\n"
+ "--logo-url URL Link to URL from logo image (requires --image-dir).\n"
"--search ACTION Generate search box with specified ACTION.\n"
- "--index NUM Generate subindex if it has at least NUM entries (0 for no index, default=1).\n"
- "--summary NUM Print a warning if a summary sentence exceeds NUM characters.\n"
+ "--index NUM Generate subindex if it has at least NUM entries (0 for no index, default=1).\n"
+ "--summary NUM Print a warning if a summary sentence exceeds NUM characters.\n"
"-d, --debug Print debug messages.\n"
"--ice Permit `Ice' prefix (for building Ice source code only).\n"
;
@@ -74,21 +74,21 @@ main(int argc, char* argv[])
}
catch(const IceUtil::BadOptException& e)
{
- cerr << argv[0] << ": " << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": " << e.reason << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(argv[0]);
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
string cppArgs;
@@ -96,19 +96,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D" + Preprocessor::addQuotes(*i);
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U" + Preprocessor::addQuotes(*i);
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("I");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -I" + Preprocessor::addQuotes(*i);
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
@@ -127,14 +127,14 @@ main(int argc, char* argv[])
unsigned indexCount;
if(!ind.empty())
{
- istringstream s(ind);
- s >> indexCount;
- if(!s)
- {
- cerr << argv[0] << ": the --index operation requires a positive integer argument" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
+ istringstream s(ind);
+ s >> indexCount;
+ if(!s)
+ {
+ cerr << argv[0] << ": the --index operation requires a positive integer argument" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
}
string imageDir = opts.optArg("image-dir");
@@ -147,14 +147,14 @@ main(int argc, char* argv[])
unsigned summaryCount;
if(!warnSummary.empty())
{
- istringstream s(warnSummary);
- s >> summaryCount;
- if(!s)
- {
- cerr << argv[0] << ": the --summary operation requires a positive integer argument" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
- }
+ istringstream s(warnSummary);
+ s >> summaryCount;
+ if(!s)
+ {
+ cerr << argv[0] << ": the --summary operation requires a positive integer argument" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
+ }
}
bool debug = opts.isSet("debug");
@@ -163,9 +163,9 @@ main(int argc, char* argv[])
if(args.empty())
{
- cerr << argv[0] << ": no input file" << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": no input file" << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
UnitPtr p = Unit::createUnit(true, false, ice, false);
@@ -174,55 +174,55 @@ main(int argc, char* argv[])
for(vector<string>::size_type idx = 0; idx < args.size(); ++idx)
{
- Preprocessor icecpp(argv[0], args[idx], cppArgs);
- FILE* cppHandle = icecpp.preprocess(true);
-
- if(cppHandle == 0)
- {
- p->destroy();
- return EXIT_FAILURE;
- }
- if(preprocess)
- {
- char buf[4096];
- while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
- {
- if(fputs(buf, stdout) == EOF)
- {
- p->destroy();
- return EXIT_FAILURE;
- }
- }
- }
- else
- {
- status = p->parse(cppHandle, debug);
- }
-
- if(!icecpp.close())
- {
- p->destroy();
- return EXIT_FAILURE;
- }
+ Preprocessor icecpp(argv[0], args[idx], cppArgs);
+ FILE* cppHandle = icecpp.preprocess(true);
+
+ if(cppHandle == 0)
+ {
+ p->destroy();
+ return EXIT_FAILURE;
+ }
+ if(preprocess)
+ {
+ char buf[4096];
+ while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
+ {
+ if(fputs(buf, stdout) == EOF)
+ {
+ p->destroy();
+ return EXIT_FAILURE;
+ }
+ }
+ }
+ else
+ {
+ status = p->parse(cppHandle, debug);
+ }
+
+ if(!icecpp.close())
+ {
+ p->destroy();
+ return EXIT_FAILURE;
+ }
}
if(status == EXIT_SUCCESS && !preprocess)
{
- try
- {
- Slice::generate(p, output, header, footer, indexHeader, indexFooter, imageDir, logoURL,
+ try
+ {
+ Slice::generate(p, output, header, footer, indexHeader, indexFooter, imageDir, logoURL,
searchAction, indexCount, summaryCount);
- }
- catch(const string& err)
- {
- cerr << argv[0] << ": " << err << endl;
- status = EXIT_FAILURE;
- }
- catch(const char* err)
- {
- cerr << argv[0] << ": " << err << endl;
- status = EXIT_FAILURE;
- }
+ }
+ catch(const string& err)
+ {
+ cerr << argv[0] << ": " << err << endl;
+ status = EXIT_FAILURE;
+ }
+ catch(const char* err)
+ {
+ cerr << argv[0] << ": " << err << endl;
+ status = EXIT_FAILURE;
+ }
}
p->destroy();
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index 03d04934dca..aa163075dfb 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -38,26 +38,26 @@ sliceModeToIceMode(Operation::Mode opMode)
string mode;
switch(opMode)
{
- case Operation::Normal:
- {
- mode = "Ice.OperationMode.Normal";
- break;
- }
- case Operation::Nonmutating:
- {
- mode = "Ice.OperationMode.Nonmutating";
- break;
- }
- case Operation::Idempotent:
- {
- mode = "Ice.OperationMode.Idempotent";
- break;
- }
- default:
- {
- assert(false);
- break;
- }
+ case Operation::Normal:
+ {
+ mode = "Ice.OperationMode.Normal";
+ break;
+ }
+ case Operation::Nonmutating:
+ {
+ mode = "Ice.OperationMode.Nonmutating";
+ break;
+ }
+ case Operation::Idempotent:
+ {
+ mode = "Ice.OperationMode.Idempotent";
+ break;
+ }
+ default:
+ {
+ assert(false);
+ break;
+ }
}
return mode;
}
@@ -72,7 +72,7 @@ getDeprecateReason(const ContainedPtr& p1, const ContainedPtr& p2, const string&
deprecateReason = "This " + type + " has been deprecated.";
if(deprecateMetadata.find("deprecate:") == 0 && deprecateMetadata.size() > 10)
{
- deprecateReason = deprecateMetadata.substr(10);
+ deprecateReason = deprecateMetadata.substr(10);
}
}
return deprecateReason;
@@ -96,7 +96,7 @@ Slice::JavaVisitor::getParams(const OperationPtr& op, const string& package)
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
StringList metaData = (*q)->getMetaData();
- string typeString = typeToString((*q)->type(), (*q)->isOutParam() ? TypeModeOut : TypeModeIn, package,
+ string typeString = typeToString((*q)->type(), (*q)->isOutParam() ? TypeModeOut : TypeModeIn, package,
metaData);
params.push_back(typeString + ' ' + fixKwd((*q)->name()));
}
@@ -118,12 +118,12 @@ Slice::JavaVisitor::getParamsAsync(const OperationPtr& op, const string& package
ParamDeclList paramList = op->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- if(!(*q)->isOutParam())
- {
+ if(!(*q)->isOutParam())
+ {
StringList metaData = (*q)->getMetaData();
- string typeString = typeToString((*q)->type(), TypeModeIn, package, metaData);
- params.push_back(typeString + ' ' + fixKwd((*q)->name()));
- }
+ string typeString = typeToString((*q)->type(), TypeModeIn, package, metaData);
+ params.push_back(typeString + ' ' + fixKwd((*q)->name()));
+ }
}
return params;
@@ -137,18 +137,18 @@ Slice::JavaVisitor::getParamsAsyncCB(const OperationPtr& op, const string& packa
TypePtr ret = op->returnType();
if(ret)
{
- string retS = typeToString(ret, TypeModeIn, package, op->getMetaData());
- params.push_back(retS + " __ret");
+ string retS = typeToString(ret, TypeModeIn, package, op->getMetaData());
+ params.push_back(retS + " __ret");
}
ParamDeclList paramList = op->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- if((*q)->isOutParam())
- {
- string typeString = typeToString((*q)->type(), TypeModeIn, package, (*q)->getMetaData());
- params.push_back(typeString + ' ' + fixKwd((*q)->name()));
- }
+ if((*q)->isOutParam())
+ {
+ string typeString = typeToString((*q)->type(), TypeModeIn, package, (*q)->getMetaData());
+ params.push_back(typeString + ' ' + fixKwd((*q)->name()));
+ }
}
return params;
@@ -178,10 +178,10 @@ Slice::JavaVisitor::getArgsAsync(const OperationPtr& op)
ParamDeclList paramList = op->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- if(!(*q)->isOutParam())
- {
- args.push_back(fixKwd((*q)->name()));
- }
+ if(!(*q)->isOutParam())
+ {
+ args.push_back(fixKwd((*q)->name()));
+ }
}
return args;
@@ -195,32 +195,32 @@ Slice::JavaVisitor::getArgsAsyncCB(const OperationPtr& op)
TypePtr ret = op->returnType();
if(ret)
{
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
- {
- args.push_back("__ret.value");
- }
- else
- {
- args.push_back("__ret");
- }
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
+ {
+ args.push_back("__ret.value");
+ }
+ else
+ {
+ args.push_back("__ret");
+ }
}
ParamDeclList paramList = op->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- if((*q)->isOutParam())
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast((*q)->type());
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*q)->type()))
- {
- args.push_back(fixKwd((*q)->name()) + ".value");
- }
- else
- {
- args.push_back(fixKwd((*q)->name()));
- }
- }
+ if((*q)->isOutParam())
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast((*q)->type());
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*q)->type()))
+ {
+ args.push_back(fixKwd((*q)->name()) + ".value");
+ }
+ else
+ {
+ args.push_back(fixKwd((*q)->name()));
+ }
+ }
}
return args;
@@ -239,12 +239,12 @@ Slice::JavaVisitor::writeThrowsClause(const string& package, const ExceptionList
int count = 0;
for(r = throws.begin(); r != throws.end(); ++r)
{
- if(count > 0)
- {
- out << "," << nl;
- }
- out << getAbsolute(*r, package);
- count++;
+ if(count > 0)
+ {
+ out << "," << nl;
+ }
+ out << getAbsolute(*r, package);
+ count++;
}
out.restoreIndent();
out.dec();
@@ -263,8 +263,8 @@ Slice::JavaVisitor::writeDelegateThrowsClause(const string& package, const Excep
ExceptionList::const_iterator r;
for(r = throws.begin(); r != throws.end(); ++r)
{
- out << "," << nl;
- out << getAbsolute(*r, package);
+ out << "," << nl;
+ out << getAbsolute(*r, package);
}
out.restoreIndent();
out.dec();
@@ -343,7 +343,7 @@ Slice::JavaVisitor::writeHashCode(Output& out, const TypePtr& type, const string
SequencePtr seq = SequencePtr::dynamicCast(type);
if(seq)
{
- bool customType = hasTypeMetaData(seq, metaData);
+ bool customType = hasTypeMetaData(seq, metaData);
out << nl << "if(" << name << " != null)";
out << sb;
@@ -354,7 +354,7 @@ Slice::JavaVisitor::writeHashCode(Output& out, const TypePtr& type, const string
else
{
out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < " << name << ".length; __i" << iter
- << "++)";
+ << "++)";
out << sb;
ostringstream elem;
elem << name << "[__i" << iter << ']';
@@ -397,15 +397,15 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
out << sb;
{
- StringList::const_iterator q = ids.begin();
- while(q != ids.end())
- {
- out << nl << '"' << *q << '"';
- if(++q != ids.end())
- {
- out << ',';
- }
- }
+ StringList::const_iterator q = ids.begin();
+ while(q != ids.end())
+ {
+ out << nl << '"' << *q << '"';
+ if(++q != ids.end())
+ {
+ out << ',';
+ }
+ }
}
out << eb << ';';
@@ -452,96 +452,96 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
//
for(r = ops.begin(); r != ops.end(); ++r)
{
- OperationPtr op = *r;
+ OperationPtr op = *r;
string opName = op->name();
ContainerPtr container = op->container();
ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- assert(cl);
-
- bool amd = cl->hasMetaData("amd") || op->hasMetaData("amd");
-
- vector<string> params;
- vector<string> args;
- TypePtr ret;
-
- if(amd)
- {
- opName += "_async";
- params = getParamsAsync(op, package, true);
- args = getArgsAsync(op);
- }
- else
- {
- opName = fixKwd(opName);
- ret = op->returnType();
- params = getParams(op, package);
- args = getArgs(op);
- }
-
- ExceptionList throws = op->throws();
- throws.sort();
- throws.unique();
-
- //
- // Only generate a "no current" version of the operation if it hasn't been done in a base
- // class already, because the "no current" version is final.
- //
- bool generateOperation = cl == p; // Generate if the operation is defined in this class.
- if(!generateOperation)
- {
- //
- // The operation is not defined in this class.
- //
- if(!bases.empty())
- {
- //
- // Check if the operation is already implemented by a base class.
- //
- bool implementedByBase = false;
- if(!bases.front()->isInterface())
- {
- OperationList baseOps = bases.front()->allOperations();
- OperationList::const_iterator i;
- for(i = baseOps.begin(); i != baseOps.end(); ++i)
- {
- if((*i)->name() == op->name())
- {
- implementedByBase = true;
- break;
- }
- }
- if(i == baseOps.end())
- {
- generateOperation = true;
- }
- }
- if(!generateOperation && !implementedByBase)
- {
- //
- // No base class defines the operation. Check if one of the
- // interfaces defines it, in which case this class must provide it.
- //
- if(bases.front()->isInterface() || bases.size() > 1)
- {
- generateOperation = true;
- }
- }
- }
- }
- if(generateOperation)
- {
- out << sp << nl << "public final " << typeToString(ret, TypeModeReturn, package, op->getMetaData())
- << nl << opName << spar << params << epar;
- writeThrowsClause(package, throws);
- out << sb << nl;
- if(ret)
- {
- out << "return ";
- }
- out << opName << spar << args << "null" << epar << ';';
- out << eb;
- }
+ assert(cl);
+
+ bool amd = cl->hasMetaData("amd") || op->hasMetaData("amd");
+
+ vector<string> params;
+ vector<string> args;
+ TypePtr ret;
+
+ if(amd)
+ {
+ opName += "_async";
+ params = getParamsAsync(op, package, true);
+ args = getArgsAsync(op);
+ }
+ else
+ {
+ opName = fixKwd(opName);
+ ret = op->returnType();
+ params = getParams(op, package);
+ args = getArgs(op);
+ }
+
+ ExceptionList throws = op->throws();
+ throws.sort();
+ throws.unique();
+
+ //
+ // Only generate a "no current" version of the operation if it hasn't been done in a base
+ // class already, because the "no current" version is final.
+ //
+ bool generateOperation = cl == p; // Generate if the operation is defined in this class.
+ if(!generateOperation)
+ {
+ //
+ // The operation is not defined in this class.
+ //
+ if(!bases.empty())
+ {
+ //
+ // Check if the operation is already implemented by a base class.
+ //
+ bool implementedByBase = false;
+ if(!bases.front()->isInterface())
+ {
+ OperationList baseOps = bases.front()->allOperations();
+ OperationList::const_iterator i;
+ for(i = baseOps.begin(); i != baseOps.end(); ++i)
+ {
+ if((*i)->name() == op->name())
+ {
+ implementedByBase = true;
+ break;
+ }
+ }
+ if(i == baseOps.end())
+ {
+ generateOperation = true;
+ }
+ }
+ if(!generateOperation && !implementedByBase)
+ {
+ //
+ // No base class defines the operation. Check if one of the
+ // interfaces defines it, in which case this class must provide it.
+ //
+ if(bases.front()->isInterface() || bases.size() > 1)
+ {
+ generateOperation = true;
+ }
+ }
+ }
+ }
+ if(generateOperation)
+ {
+ out << sp << nl << "public final " << typeToString(ret, TypeModeReturn, package, op->getMetaData())
+ << nl << opName << spar << params << epar;
+ writeThrowsClause(package, throws);
+ out << sb << nl;
+ if(ret)
+ {
+ out << "return ";
+ }
+ out << opName << spar << args << "null" << epar << ';';
+ out << eb;
+ }
}
//
@@ -556,250 +556,250 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
StringList opMetaData = op->getMetaData();
ContainerPtr container = op->container();
ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- assert(cl);
+ assert(cl);
string opName = op->name();
out << sp << nl << "public static IceInternal.DispatchStatus" << nl << "___" << opName << '(' << name
- << " __obj, IceInternal.Incoming __inS, Ice.Current __current)";
+ << " __obj, IceInternal.Incoming __inS, Ice.Current __current)";
out << sb;
- bool amd = cl->hasMetaData("amd") || op->hasMetaData("amd");
- if(!amd)
- {
- TypePtr ret = op->returnType();
-
- ParamDeclList inParams;
- ParamDeclList outParams;
- ParamDeclList paramList = op->parameters();
- ParamDeclList::const_iterator pli;
- for(pli = paramList.begin(); pli != paramList.end(); ++pli)
- {
- if((*pli)->isOutParam())
- {
- outParams.push_back(*pli);
- }
- else
- {
- inParams.push_back(*pli);
- }
- }
-
- ExceptionList throws = op->throws();
- throws.sort();
- throws.unique();
-
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
+ bool amd = cl->hasMetaData("amd") || op->hasMetaData("amd");
+ if(!amd)
+ {
+ TypePtr ret = op->returnType();
+
+ ParamDeclList inParams;
+ ParamDeclList outParams;
+ ParamDeclList paramList = op->parameters();
+ ParamDeclList::const_iterator pli;
+ for(pli = paramList.begin(); pli != paramList.end(); ++pli)
+ {
+ if((*pli)->isOutParam())
+ {
+ outParams.push_back(*pli);
+ }
+ else
+ {
+ inParams.push_back(*pli);
+ }
+ }
+
+ ExceptionList throws = op->throws();
+ throws.sort();
+ throws.unique();
+
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
#if defined(__SUNPRO_CC)
- throws.sort(Slice::derivedToBaseCompare);
+ throws.sort(Slice::derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
- int iter;
-
- out << nl << "__checkMode(" << sliceModeToIceMode(op->mode()) << ", __current.mode);";
-
- if(!inParams.empty())
- {
- out << nl << "IceInternal.BasicStream __is = __inS.is();";
- }
- if(!outParams.empty() || ret || !throws.empty())
- {
- out << nl << "IceInternal.BasicStream __os = __inS.os();";
- }
-
- //
- // Unmarshal 'in' parameters.
- //
- iter = 0;
- for(pli = inParams.begin(); pli != inParams.end(); ++pli)
- {
+ int iter;
+
+ out << nl << "__checkMode(" << sliceModeToIceMode(op->mode()) << ", __current.mode);";
+
+ if(!inParams.empty())
+ {
+ out << nl << "IceInternal.BasicStream __is = __inS.is();";
+ }
+ if(!outParams.empty() || ret || !throws.empty())
+ {
+ out << nl << "IceInternal.BasicStream __os = __inS.os();";
+ }
+
+ //
+ // Unmarshal 'in' parameters.
+ //
+ iter = 0;
+ for(pli = inParams.begin(); pli != inParams.end(); ++pli)
+ {
StringList metaData = (*pli)->getMetaData();
TypePtr paramType = (*pli)->type();
string paramName = fixKwd((*pli)->name());
- string typeS = typeToString(paramType, TypeModeIn, package, metaData);
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType))
- {
- out << nl << typeS << "Holder " << paramName << " = new " << typeS << "Holder();";
- writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, true,
- metaData, string());
- }
- else
- {
- out << nl << typeS << ' ' << paramName << ';';
- writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, false, metaData);
- }
- }
- if(op->sendsClasses())
- {
- out << nl << "__is.readPendingObjects();";
- }
-
- //
- // Create holders for 'out' parameters.
- //
- for(pli = outParams.begin(); pli != outParams.end(); ++pli)
- {
- string typeS = typeToString((*pli)->type(), TypeModeOut, package, (*pli)->getMetaData());
- out << nl << typeS << ' ' << fixKwd((*pli)->name()) << " = new " << typeS << "();";
- }
-
- //
- // Call on the servant.
- //
- if(!throws.empty())
- {
- out << nl << "try";
- out << sb;
- }
- out << nl;
- if(ret)
- {
- string retS = typeToString(ret, TypeModeReturn, package, opMetaData);
- out << retS << " __ret = ";
- }
- out << "__obj." << fixKwd(opName) << '(';
- for(pli = inParams.begin(); pli != inParams.end(); ++pli)
- {
+ string typeS = typeToString(paramType, TypeModeIn, package, metaData);
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType))
+ {
+ out << nl << typeS << "Holder " << paramName << " = new " << typeS << "Holder();";
+ writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, true,
+ metaData, string());
+ }
+ else
+ {
+ out << nl << typeS << ' ' << paramName << ';';
+ writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, false, metaData);
+ }
+ }
+ if(op->sendsClasses())
+ {
+ out << nl << "__is.readPendingObjects();";
+ }
+
+ //
+ // Create holders for 'out' parameters.
+ //
+ for(pli = outParams.begin(); pli != outParams.end(); ++pli)
+ {
+ string typeS = typeToString((*pli)->type(), TypeModeOut, package, (*pli)->getMetaData());
+ out << nl << typeS << ' ' << fixKwd((*pli)->name()) << " = new " << typeS << "();";
+ }
+
+ //
+ // Call on the servant.
+ //
+ if(!throws.empty())
+ {
+ out << nl << "try";
+ out << sb;
+ }
+ out << nl;
+ if(ret)
+ {
+ string retS = typeToString(ret, TypeModeReturn, package, opMetaData);
+ out << retS << " __ret = ";
+ }
+ out << "__obj." << fixKwd(opName) << '(';
+ for(pli = inParams.begin(); pli != inParams.end(); ++pli)
+ {
TypePtr paramType = (*pli)->type();
- out << fixKwd((*pli)->name());
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType))
- {
- out << ".value";
- }
- out << ", ";
- }
- for(pli = outParams.begin(); pli != outParams.end(); ++pli)
- {
- out << fixKwd((*pli)->name()) << ", ";
- }
- out << "__current);";
-
- //
- // Marshal 'out' parameters and return value.
- //
- for(pli = outParams.begin(); pli != outParams.end(); ++pli)
- {
- writeMarshalUnmarshalCode(out, package, (*pli)->type(), fixKwd((*pli)->name()), true, iter, true,
+ out << fixKwd((*pli)->name());
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType))
+ {
+ out << ".value";
+ }
+ out << ", ";
+ }
+ for(pli = outParams.begin(); pli != outParams.end(); ++pli)
+ {
+ out << fixKwd((*pli)->name()) << ", ";
+ }
+ out << "__current);";
+
+ //
+ // Marshal 'out' parameters and return value.
+ //
+ for(pli = outParams.begin(); pli != outParams.end(); ++pli)
+ {
+ writeMarshalUnmarshalCode(out, package, (*pli)->type(), fixKwd((*pli)->name()), true, iter, true,
(*pli)->getMetaData());
- }
- if(ret)
- {
- writeMarshalUnmarshalCode(out, package, ret, "__ret", true, iter, false, opMetaData);
- }
- if(op->returnsClasses())
- {
- out << nl << "__os.writePendingObjects();";
- }
- out << nl << "return IceInternal.DispatchStatus.DispatchOK;";
-
- //
- // Handle user exceptions.
- //
- if(!throws.empty())
- {
- out << eb;
- ExceptionList::const_iterator t;
- for(t = throws.begin(); t != throws.end(); ++t)
- {
- string exS = getAbsolute(*t, package);
- out << nl << "catch(" << exS << " ex)";
- out << sb;
- out << nl << "__os.writeUserException(ex);";
- out << nl << "return IceInternal.DispatchStatus.DispatchUserException;";
- out << eb;
- }
- }
-
- out << eb;
- }
- else
- {
- ParamDeclList inParams;
- ParamDeclList paramList = op->parameters();
- ParamDeclList::const_iterator pli;
- for(pli = paramList.begin(); pli != paramList.end(); ++pli)
- {
- if(!(*pli)->isOutParam())
- {
- inParams.push_back(*pli);
- }
- }
-
- int iter;
-
- out << nl << "__checkMode(" << sliceModeToIceMode(op->mode()) << ", __current.mode);";
-
- if(!inParams.empty())
- {
- out << nl << "IceInternal.BasicStream __is = __inS.is();";
- }
-
- //
- // Unmarshal 'in' parameters.
- //
- iter = 0;
- for(pli = inParams.begin(); pli != inParams.end(); ++pli)
- {
+ }
+ if(ret)
+ {
+ writeMarshalUnmarshalCode(out, package, ret, "__ret", true, iter, false, opMetaData);
+ }
+ if(op->returnsClasses())
+ {
+ out << nl << "__os.writePendingObjects();";
+ }
+ out << nl << "return IceInternal.DispatchStatus.DispatchOK;";
+
+ //
+ // Handle user exceptions.
+ //
+ if(!throws.empty())
+ {
+ out << eb;
+ ExceptionList::const_iterator t;
+ for(t = throws.begin(); t != throws.end(); ++t)
+ {
+ string exS = getAbsolute(*t, package);
+ out << nl << "catch(" << exS << " ex)";
+ out << sb;
+ out << nl << "__os.writeUserException(ex);";
+ out << nl << "return IceInternal.DispatchStatus.DispatchUserException;";
+ out << eb;
+ }
+ }
+
+ out << eb;
+ }
+ else
+ {
+ ParamDeclList inParams;
+ ParamDeclList paramList = op->parameters();
+ ParamDeclList::const_iterator pli;
+ for(pli = paramList.begin(); pli != paramList.end(); ++pli)
+ {
+ if(!(*pli)->isOutParam())
+ {
+ inParams.push_back(*pli);
+ }
+ }
+
+ int iter;
+
+ out << nl << "__checkMode(" << sliceModeToIceMode(op->mode()) << ", __current.mode);";
+
+ if(!inParams.empty())
+ {
+ out << nl << "IceInternal.BasicStream __is = __inS.is();";
+ }
+
+ //
+ // Unmarshal 'in' parameters.
+ //
+ iter = 0;
+ for(pli = inParams.begin(); pli != inParams.end(); ++pli)
+ {
StringList metaData = (*pli)->getMetaData();
TypePtr paramType = (*pli)->type();
string paramName = fixKwd((*pli)->name());
- string typeS = typeToString(paramType, TypeModeIn, package, metaData);
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType))
- {
- out << nl << typeS << "Holder " << paramName << " = new " << typeS << "Holder();";
- writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, true, metaData,
+ string typeS = typeToString(paramType, TypeModeIn, package, metaData);
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType))
+ {
+ out << nl << typeS << "Holder " << paramName << " = new " << typeS << "Holder();";
+ writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, true, metaData,
string());
- }
- else
- {
- out << nl << typeS << ' ' << paramName << ';';
- writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, false, metaData);
- }
- }
- if(op->sendsClasses())
- {
- out << nl << "__is.readPendingObjects();";
- }
-
- //
- // Call on the servant.
- //
- string classNameAMD = "AMD_" + p->name();
- out << nl << classNameAMD << '_' << opName << " __cb = new _" << classNameAMD << '_' << opName
- << "(__inS);";
+ }
+ else
+ {
+ out << nl << typeS << ' ' << paramName << ';';
+ writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, false, metaData);
+ }
+ }
+ if(op->sendsClasses())
+ {
+ out << nl << "__is.readPendingObjects();";
+ }
+
+ //
+ // Call on the servant.
+ //
+ string classNameAMD = "AMD_" + p->name();
+ out << nl << classNameAMD << '_' << opName << " __cb = new _" << classNameAMD << '_' << opName
+ << "(__inS);";
out << nl << "try";
out << sb;
- out << nl << "__obj." << (amd ? opName + "_async" : fixKwd(opName)) << (amd ? "(__cb, " : "(");
- for(pli = inParams.begin(); pli != inParams.end(); ++pli)
- {
+ out << nl << "__obj." << (amd ? opName + "_async" : fixKwd(opName)) << (amd ? "(__cb, " : "(");
+ for(pli = inParams.begin(); pli != inParams.end(); ++pli)
+ {
TypePtr paramType = (*pli)->type();
- out << fixKwd((*pli)->name());
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType))
- {
- out << ".value";
- }
- out << ", ";
- }
- out << "__current);";
- out << eb;
- out << nl << "catch(java.lang.Exception ex)";
- out << sb;
- out << nl << "__cb.ice_exception(ex);";
- out << eb;
- out << nl << "return IceInternal.DispatchStatus.DispatchAsync;";
-
- out << eb;
- }
+ out << fixKwd((*pli)->name());
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType))
+ {
+ out << ".value";
+ }
+ out << ", ";
+ }
+ out << "__current);";
+ out << eb;
+ out << nl << "catch(java.lang.Exception ex)";
+ out << sb;
+ out << nl << "__cb.ice_exception(ex);";
+ out << eb;
+ out << nl << "return IceInternal.DispatchStatus.DispatchAsync;";
+
+ out << eb;
+ }
}
OperationList allOps = p->allOperations();
@@ -830,7 +830,7 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
out << eb << ';';
out << sp << nl << "public IceInternal.DispatchStatus" << nl
- << "__dispatch(IceInternal.Incoming in, Ice.Current __current)";
+ << "__dispatch(IceInternal.Incoming in, Ice.Current __current)";
out << sb;
out << nl << "int pos = java.util.Arrays.binarySearch(__all, __current.operation);";
out << nl << "if(pos < 0)";
@@ -903,47 +903,47 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
out << eb;
- //
- // Check if we need to generate ice_operationAttributes()
- //
-
- StringList freezeWriteOpNames;
- for(OperationList::iterator r = allOps.begin(); r != allOps.end(); ++r)
- {
- ClassDefPtr classDef = ClassDefPtr::dynamicCast((*r)->container());
- assert(classDef != 0);
-
- if((*r)->hasMetaData("freeze:write") ||
- (classDef->hasMetaData("freeze:write") && !(*r)->hasMetaData("freeze:read")))
- {
- freezeWriteOpNames.push_back((*r)->name());
- }
- }
-
- if(!freezeWriteOpNames.empty())
- {
- freezeWriteOpNames.sort();
-
- StringList::iterator q;
-
- out << sp << nl << "private final static String[] __freezeWriteOperations =";
- out << sb;
- q = freezeWriteOpNames.begin();
- while(q != freezeWriteOpNames.end())
- {
- out << nl << '"' << *q << '"';
- if(++q != freezeWriteOpNames.end())
- {
- out << ',';
- }
- }
- out << eb << ';';
-
- out << sp << nl << "public int ice_operationAttributes(String operation)";
- out << sb;
- out << nl << "return (java.util.Arrays.binarySearch(__freezeWriteOperations, operation) >= 0) ? 1 : 0;";
- out << eb;
- }
+ //
+ // Check if we need to generate ice_operationAttributes()
+ //
+
+ StringList freezeWriteOpNames;
+ for(OperationList::iterator r = allOps.begin(); r != allOps.end(); ++r)
+ {
+ ClassDefPtr classDef = ClassDefPtr::dynamicCast((*r)->container());
+ assert(classDef != 0);
+
+ if((*r)->hasMetaData("freeze:write") ||
+ (classDef->hasMetaData("freeze:write") && !(*r)->hasMetaData("freeze:read")))
+ {
+ freezeWriteOpNames.push_back((*r)->name());
+ }
+ }
+
+ if(!freezeWriteOpNames.empty())
+ {
+ freezeWriteOpNames.sort();
+
+ StringList::iterator q;
+
+ out << sp << nl << "private final static String[] __freezeWriteOperations =";
+ out << sb;
+ q = freezeWriteOpNames.begin();
+ while(q != freezeWriteOpNames.end())
+ {
+ out << nl << '"' << *q << '"';
+ if(++q != freezeWriteOpNames.end())
+ {
+ out << ',';
+ }
+ }
+ out << eb << ';';
+
+ out << sp << nl << "public int ice_operationAttributes(String operation)";
+ out << sb;
+ out << nl << "return (java.util.Arrays.binarySearch(__freezeWriteOperations, operation) >= 0) ? 1 : 0;";
+ out << eb;
+ }
}
}
@@ -1062,21 +1062,21 @@ Slice::Gen::writeChecksumClass(const string& checksumClass, const string& dir, c
//
if(java2)
{
- out << sp << nl << "public static java.util.Map checksums;";
+ out << sp << nl << "public static java.util.Map checksums;";
}
else
{
- out << sp << nl << "public static java.util.Map<String, String> checksums;";
+ out << sp << nl << "public static java.util.Map<String, String> checksums;";
}
out << sp << nl << "static";
out << sb;
if(java2)
{
- out << nl << "java.util.Map map = new java.util.HashMap();";
+ out << nl << "java.util.Map map = new java.util.HashMap();";
}
else
{
- out << nl << "java.util.Map<String, String> map = new java.util.HashMap<String, String>();";
+ out << nl << "java.util.Map<String, String> map = new java.util.HashMap<String, String>();";
}
for(ChecksumMap::const_iterator p = m.begin(); p != m.end(); ++p)
{
@@ -1115,7 +1115,7 @@ Slice::Gen::OpsVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!p->isLocal())
{
- writeOperations(p, false);
+ writeOperations(p, false);
}
writeOperations(p, true);
@@ -1131,7 +1131,7 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent)
string opIntfName = "Operations";
if(noCurrent || p->isLocal())
{
- opIntfName += "NC";
+ opIntfName += "NC";
}
string absolute = getAbsolute(p, "", "_", opIntfName);
@@ -1176,47 +1176,47 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent)
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
- OperationPtr op = *r;
+ OperationPtr op = *r;
ContainerPtr container = op->container();
- ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- string opname = op->name();
-
- TypePtr ret;
- vector<string> params;
-
- bool amd = !p->isLocal() && (cl->hasMetaData("amd") || op->hasMetaData("amd"));
-
- if(amd)
- {
- params = getParamsAsync(op, package, true);
- }
- else
- {
- params = getParams(op, package);
- ret = op->returnType();
- }
-
- string deprecateReason = getDeprecateReason(*r, p, "operation");
-
- string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData());
- ExceptionList throws = op->throws();
- throws.sort();
- throws.unique();
- out << sp;
- if(!deprecateReason.empty())
- {
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
- }
- out << nl << retS << ' ' << (amd ? opname + "_async" : fixKwd(opname)) << spar << params;
- if(!noCurrent && !p->isLocal())
- {
- out << "Ice.Current __current";
- }
- out << epar;
- writeThrowsClause(package, throws);
- out << ';';
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
+ string opname = op->name();
+
+ TypePtr ret;
+ vector<string> params;
+
+ bool amd = !p->isLocal() && (cl->hasMetaData("amd") || op->hasMetaData("amd"));
+
+ if(amd)
+ {
+ params = getParamsAsync(op, package, true);
+ }
+ else
+ {
+ params = getParams(op, package);
+ ret = op->returnType();
+ }
+
+ string deprecateReason = getDeprecateReason(*r, p, "operation");
+
+ string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData());
+ ExceptionList throws = op->throws();
+ throws.sort();
+ throws.unique();
+ out << sp;
+ if(!deprecateReason.empty())
+ {
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
+ }
+ out << nl << retS << ' ' << (amd ? opname + "_async" : fixKwd(opname)) << spar << params;
+ if(!noCurrent && !p->isLocal())
+ {
+ out << "Ice.Current __current";
+ }
+ out << epar;
+ writeThrowsClause(package, throws);
+ out << ';';
}
out << eb;
@@ -1320,47 +1320,47 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
if(p->isLocal())
{
out << sp << nl << "public int" << nl << "ice_hash()";
- out << sb;
- out << nl << "return hashCode();";
- out << eb;
+ 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";
- out.dec();
- out << sb;
- out << nl << "return super.clone();";
- out << eb;
+ out << sp << nl << "public java.lang.Object" << nl << "clone()";
+ out.inc();
+ out << nl << "throws java.lang.CloneNotSupportedException";
+ out.dec();
+ out << sb;
+ out << nl << "return super.clone();";
+ out << eb;
}
OperationList ops = p->allOperations();
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
- ContainerPtr container = (*r)->container();
- ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- bool hasAMD = cl->hasMetaData("amd") || (*r)->hasMetaData("amd");
+ ContainerPtr container = (*r)->container();
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
+ bool hasAMD = cl->hasMetaData("amd") || (*r)->hasMetaData("amd");
#if defined(__SUNPRO_CC) && (__SUNPRO_CC==0x550)
//
// Work around for Sun CC 5.5 bug #4853566
//
- string opName;
- if(hasAMD)
- {
- opName = (*r)->name() + "_async";
- }
- else
- {
- opName = fixKwd((*r)->name());
- }
-#else
+ string opName;
+ if(hasAMD)
+ {
+ opName = (*r)->name() + "_async";
+ }
+ else
+ {
+ opName = fixKwd((*r)->name());
+ }
+#else
string opName = hasAMD ? (*r)->name() + "_async" : fixKwd((*r)->name());
#endif
TypePtr ret = (*r)->returnType();
string retS = typeToString(ret, TypeModeReturn, package, (*r)->getMetaData());
vector<string> params;
- vector<string> args;
+ vector<string> args;
if(hasAMD)
{
params = getParamsAsync((*r), package, true);
@@ -1458,7 +1458,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
ClassDefPtr baseClass;
if(!bases.empty() && !bases.front()->isInterface())
{
- baseClass = bases.front();
+ baseClass = bases.front();
}
string package = getPackage(p);
@@ -1489,15 +1489,15 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
{
out << "Ice.Object";
}
- out << "," << nl << '_' << name;
- if(!p->isLocal())
- {
- out << "Operations, _" << name << "OperationsNC";
- }
- else
- {
- out << "OperationsNC";
- }
+ out << "," << nl << '_' << name;
+ if(!p->isLocal())
+ {
+ out << "Operations, _" << name << "OperationsNC";
+ }
+ else
+ {
+ out << "OperationsNC";
+ }
if(!bases.empty())
{
ClassList::const_iterator q = bases.begin();
@@ -1542,10 +1542,10 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
StringList implements;
if(p->isAbstract())
{
- if(!p->isLocal())
- {
- implements.push_back("_" + name + "Operations");
- }
+ if(!p->isLocal())
+ {
+ implements.push_back("_" + name + "Operations");
+ }
implements.push_back("_" + name + "OperationsNC");
}
if(!bases.empty())
@@ -1584,49 +1584,49 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!p->isInterface() && !allDataMembers.empty())
{
- //
- // Constructors.
- //
- out << sp;
- out << nl << "public " << name << "()";
- out << sb;
- if(baseClass)
- {
- out << nl << "super();";
- }
- out << eb;
-
- out << sp << nl << "public " << name << spar;
- vector<string> paramDecl;
- for(d = allDataMembers.begin(); d != allDataMembers.end(); ++d)
- {
- string memberName = fixKwd((*d)->name());
- string memberType = typeToString((*d)->type(), TypeModeMember, package, (*d)->getMetaData());
- paramDecl.push_back(memberType + " " + memberName);
- }
- out << paramDecl << epar;
- out << sb;
- if(baseClass && allDataMembers.size() != members.size())
- {
- out << nl << "super" << spar;
- vector<string> baseParamNames;
- DataMemberList baseDataMembers = baseClass->allDataMembers();
- for(d = baseDataMembers.begin(); d != baseDataMembers.end(); ++d)
- {
- baseParamNames.push_back(fixKwd((*d)->name()));
- }
- out << baseParamNames << epar << ';';
- }
- vector<string> paramNames;
- for(d = members.begin(); d != members.end(); ++d)
- {
- paramNames.push_back(fixKwd((*d)->name()));
- }
- for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i)
- {
- out << nl << "this." << *i << " = " << *i << ';';
- }
- out << eb;
+ //
+ // Constructors.
+ //
+ out << sp;
+ out << nl << "public " << name << "()";
+ out << sb;
+ if(baseClass)
+ {
+ out << nl << "super();";
+ }
+ out << eb;
+
+ out << sp << nl << "public " << name << spar;
+ vector<string> paramDecl;
+ for(d = allDataMembers.begin(); d != allDataMembers.end(); ++d)
+ {
+ string memberName = fixKwd((*d)->name());
+ string memberType = typeToString((*d)->type(), TypeModeMember, package, (*d)->getMetaData());
+ paramDecl.push_back(memberType + " " + memberName);
+ }
+ out << paramDecl << epar;
+ out << sb;
+ if(baseClass && allDataMembers.size() != members.size())
+ {
+ out << nl << "super" << spar;
+ vector<string> baseParamNames;
+ DataMemberList baseDataMembers = baseClass->allDataMembers();
+ for(d = baseDataMembers.begin(); d != baseDataMembers.end(); ++d)
+ {
+ baseParamNames.push_back(fixKwd((*d)->name()));
+ }
+ out << baseParamNames << epar << ';';
+ }
+ vector<string> paramNames;
+ for(d = members.begin(); d != members.end(); ++d)
+ {
+ paramNames.push_back(fixKwd((*d)->name()));
+ }
+ for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i)
+ {
+ out << nl << "this." << *i << " = " << *i << ';';
+ }
+ out << eb;
}
//
@@ -1665,91 +1665,91 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sp << nl << "public void" << nl << "__write(IceInternal.BasicStream __os)";
out << sb;
- out << nl << "__os.writeTypeId(ice_staticId());";
- out << nl << "__os.startWriteSlice();";
+ out << nl << "__os.writeTypeId(ice_staticId());";
+ out << nl << "__os.startWriteSlice();";
iter = 0;
for(d = members.begin(); d != members.end(); ++d)
{
StringList metaData = (*d)->getMetaData();
writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), true, iter, false, metaData);
}
- out << nl << "__os.endWriteSlice();";
+ out << nl << "__os.endWriteSlice();";
out << nl << "super.__write(__os);";
out << eb;
- DataMemberList allClassMembers = p->allClassDataMembers();
- if(allClassMembers.size() != 0)
- {
- out << sp << nl << "private class Patcher implements IceInternal.Patcher";
+ DataMemberList allClassMembers = p->allClassDataMembers();
+ if(allClassMembers.size() != 0)
+ {
+ out << sp << nl << "private class Patcher implements IceInternal.Patcher";
if(_stream)
{
out << ", Ice.ReadObjectCallback";
}
- out << sb;
- if(allClassMembers.size() > 1)
- {
- out << sp << nl << "Patcher(int member)";
- out << sb;
- out << nl << "__member = member;";
- out << eb;
- }
-
- out << sp << nl << "public void" << nl << "patch(Ice.Object v)";
- out << sb;
- out << nl << "try";
- out << sb;
- if(allClassMembers.size() > 1)
- {
- out << nl << "switch(__member)";
- out << sb;
- }
- int memberCount = 0;
- for(d = allClassMembers.begin(); d != allClassMembers.end(); ++d)
- {
- if(allClassMembers.size() > 1)
- {
- out.dec();
- out << nl << "case " << memberCount << ":";
- out.inc();
- }
- if(allClassMembers.size() > 1)
- {
- out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";";
- }
- string memberName = fixKwd((*d)->name());
- string memberType = typeToString((*d)->type(), TypeModeMember, package);
- out << nl << memberName << " = (" << memberType << ")v;";
- if(allClassMembers.size() > 1)
- {
- out << nl << "break;";
- }
- memberCount++;
- }
- if(allClassMembers.size() > 1)
- {
- out << eb;
- }
- out << eb;
- out << nl << "catch(ClassCastException ex)";
- out << sb;
- out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
- out << nl << "_e.type = v.ice_id();";
- out << nl << "_e.expectedType = type();";
- out << nl << "throw _e;";
- out << eb;
- out << eb;
-
- out << sp << nl << "public String" << nl << "type()";
- out << sb;
- if(allClassMembers.size() > 1)
- {
- out << nl << "return __typeId;";
- }
- else
- {
- out << nl << "return \"" << (*allClassMembers.begin())->type()->typeId() << "\";";
- }
- out << eb;
+ out << sb;
+ if(allClassMembers.size() > 1)
+ {
+ out << sp << nl << "Patcher(int member)";
+ out << sb;
+ out << nl << "__member = member;";
+ out << eb;
+ }
+
+ out << sp << nl << "public void" << nl << "patch(Ice.Object v)";
+ out << sb;
+ out << nl << "try";
+ out << sb;
+ if(allClassMembers.size() > 1)
+ {
+ out << nl << "switch(__member)";
+ out << sb;
+ }
+ int memberCount = 0;
+ for(d = allClassMembers.begin(); d != allClassMembers.end(); ++d)
+ {
+ if(allClassMembers.size() > 1)
+ {
+ out.dec();
+ out << nl << "case " << memberCount << ":";
+ out.inc();
+ }
+ if(allClassMembers.size() > 1)
+ {
+ out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";";
+ }
+ string memberName = fixKwd((*d)->name());
+ string memberType = typeToString((*d)->type(), TypeModeMember, package);
+ out << nl << memberName << " = (" << memberType << ")v;";
+ if(allClassMembers.size() > 1)
+ {
+ out << nl << "break;";
+ }
+ memberCount++;
+ }
+ if(allClassMembers.size() > 1)
+ {
+ out << eb;
+ }
+ out << eb;
+ out << nl << "catch(ClassCastException ex)";
+ out << sb;
+ out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
+ out << nl << "_e.type = v.ice_id();";
+ out << nl << "_e.expectedType = type();";
+ out << nl << "throw _e;";
+ out << eb;
+ out << eb;
+
+ out << sp << nl << "public String" << nl << "type()";
+ out << sb;
+ if(allClassMembers.size() > 1)
+ {
+ out << nl << "return __typeId;";
+ }
+ else
+ {
+ out << nl << "return \"" << (*allClassMembers.begin())->type()->typeId() << "\";";
+ }
+ out << eb;
if(_stream)
{
@@ -1759,40 +1759,40 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
out << eb;
}
- if(allClassMembers.size() > 1)
- {
- out << sp << nl << "private int __member;";
- out << nl << "private String __typeId;";
- }
- out << eb;
- }
+ if(allClassMembers.size() > 1)
+ {
+ out << sp << nl << "private int __member;";
+ out << nl << "private String __typeId;";
+ }
+ out << eb;
+ }
out << sp << nl << "public void" << nl << "__read(IceInternal.BasicStream __is, boolean __rid)";
out << sb;
- out << nl << "if(__rid)";
- out << sb;
- out << nl << "__is.readTypeId();";
- out << eb;
- out << nl << "__is.startReadSlice();";
+ out << nl << "if(__rid)";
+ out << sb;
+ out << nl << "__is.readTypeId();";
+ out << eb;
+ out << nl << "__is.startReadSlice();";
iter = 0;
- DataMemberList classMembers = p->classDataMembers();
- size_t classMemberCount = allClassMembers.size() - classMembers.size();
+ DataMemberList classMembers = p->classDataMembers();
+ size_t classMemberCount = allClassMembers.size() - classMembers.size();
for(d = members.begin(); d != members.end(); ++d)
{
StringList metaData = (*d)->getMetaData();
- ostringstream patchParams;
- BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type());
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*d)->type()))
- {
- if(classMembers.size() > 1 || allClassMembers.size() > 1)
- {
- patchParams << "new Patcher(" << classMemberCount++ << ')';
- }
- }
+ ostringstream patchParams;
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type());
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*d)->type()))
+ {
+ if(classMembers.size() > 1 || allClassMembers.size() > 1)
+ {
+ patchParams << "new Patcher(" << classMemberCount++ << ')';
+ }
+ }
writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), false, iter, false, metaData,
- patchParams.str());
+ patchParams.str());
}
- out << nl << "__is.endReadSlice();";
+ out << nl << "__is.endReadSlice();";
out << nl << "super.__read(__is, true);";
out << eb;
@@ -1897,9 +1897,9 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
string deprecateReason = getDeprecateReason(p, 0, "type");
if(!deprecateReason.empty())
{
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
}
out << nl << "public class " << name << " extends ";
@@ -1923,49 +1923,49 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
if(!allDataMembers.empty())
{
- //
- // Constructors.
- //
- out << sp;
- out << nl << "public " << name << "()";
- out << sb;
- if(base)
- {
- out << nl << "super();";
- }
- out << eb;
-
- out << sp << nl << "public " << name << spar;
- vector<string> paramDecl;
- for(d = allDataMembers.begin(); d != allDataMembers.end(); ++d)
- {
- string memberName = fixKwd((*d)->name());
- string memberType = typeToString((*d)->type(), TypeModeMember, package, (*d)->getMetaData());
- paramDecl.push_back(memberType + " " + memberName);
- }
- out << paramDecl << epar;
- out << sb;
- if(base && allDataMembers.size() != members.size())
- {
- out << nl << "super" << spar;
- vector<string> baseParamNames;
- DataMemberList baseDataMembers = base->allDataMembers();
- for(d = baseDataMembers.begin(); d != baseDataMembers.end(); ++d)
- {
- baseParamNames.push_back(fixKwd((*d)->name()));
- }
- out << baseParamNames << epar << ';';
- }
- vector<string> paramNames;
- for(d = members.begin(); d != members.end(); ++d)
- {
- paramNames.push_back(fixKwd((*d)->name()));
- }
- for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i)
- {
- out << nl << "this." << *i << " = " << *i << ';';
- }
- out << eb;
+ //
+ // Constructors.
+ //
+ out << sp;
+ out << nl << "public " << name << "()";
+ out << sb;
+ if(base)
+ {
+ out << nl << "super();";
+ }
+ out << eb;
+
+ out << sp << nl << "public " << name << spar;
+ vector<string> paramDecl;
+ for(d = allDataMembers.begin(); d != allDataMembers.end(); ++d)
+ {
+ string memberName = fixKwd((*d)->name());
+ string memberType = typeToString((*d)->type(), TypeModeMember, package, (*d)->getMetaData());
+ paramDecl.push_back(memberType + " " + memberName);
+ }
+ out << paramDecl << epar;
+ out << sb;
+ if(base && allDataMembers.size() != members.size())
+ {
+ out << nl << "super" << spar;
+ vector<string> baseParamNames;
+ DataMemberList baseDataMembers = base->allDataMembers();
+ for(d = baseDataMembers.begin(); d != baseDataMembers.end(); ++d)
+ {
+ baseParamNames.push_back(fixKwd((*d)->name()));
+ }
+ out << baseParamNames << epar << ';';
+ }
+ vector<string> paramNames;
+ for(d = members.begin(); d != members.end(); ++d)
+ {
+ paramNames.push_back(fixKwd((*d)->name()));
+ }
+ for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i)
+ {
+ out << nl << "this." << *i << " = " << *i << ';';
+ }
+ out << eb;
}
out << sp << nl << "public String" << nl << "ice_name()";
@@ -1994,94 +1994,94 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
out << sp << nl << "public void" << nl << "__write(IceInternal.BasicStream __os)";
out << sb;
- out << nl << "__os.writeString(\"" << scoped << "\");";
- out << nl << "__os.startWriteSlice();";
+ out << nl << "__os.writeString(\"" << scoped << "\");";
+ out << nl << "__os.startWriteSlice();";
iter = 0;
for(d = members.begin(); d != members.end(); ++d)
{
StringList metaData = (*d)->getMetaData();
writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), true, iter, false, metaData);
}
- out << nl << "__os.endWriteSlice();";
+ out << nl << "__os.endWriteSlice();";
if(base)
{
out << nl << "super.__write(__os);";
}
out << eb;
- DataMemberList allClassMembers = p->allClassDataMembers();
- if(allClassMembers.size() != 0)
- {
- out << sp << nl << "private class Patcher implements IceInternal.Patcher";
+ DataMemberList allClassMembers = p->allClassDataMembers();
+ if(allClassMembers.size() != 0)
+ {
+ out << sp << nl << "private class Patcher implements IceInternal.Patcher";
if(_stream)
{
out << ", Ice.ReadObjectCallback";
}
- out << sb;
- if(allClassMembers.size() > 1)
- {
- out << sp << nl << "Patcher(int member)";
- out << sb;
- out << nl << "__member = member;";
- out << eb;
- }
-
- out << sp << nl << "public void" << nl << "patch(Ice.Object v)";
- out << sb;
- out << nl << "try";
- out << sb;
- if(allClassMembers.size() > 1)
- {
- out << nl << "switch(__member)";
- out << sb;
- }
- int memberCount = 0;
- for(d = allClassMembers.begin(); d != allClassMembers.end(); ++d)
- {
- if(allClassMembers.size() > 1)
- {
- out.dec();
- out << nl << "case " << memberCount << ":";
- out.inc();
- }
- if(allClassMembers.size() > 1)
- {
- out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";";
- }
- string memberName = fixKwd((*d)->name());
- string memberType = typeToString((*d)->type(), TypeModeMember, package);
- out << nl << memberName << " = (" << memberType << ")v;";
- if(allClassMembers.size() > 1)
- {
- out << nl << "break;";
- }
- memberCount++;
- }
- if(allClassMembers.size() > 1)
- {
- out << eb;
- }
- out << eb;
- out << nl << "catch(ClassCastException ex)";
- out << sb;
- out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
- out << nl << "_e.type = v.ice_id();";
- out << nl << "_e.expectedType = type();";
- out << nl << "throw _e;";
- out << eb;
- out << eb;
-
- out << sp << nl << "public String" << nl << "type()";
- out << sb;
- if(allClassMembers.size() > 1)
- {
- out << nl << "return __typeId;";
- }
- else
- {
- out << nl << "return \"" << (*allClassMembers.begin())->type()->typeId() << "\";";
- }
- out << eb;
+ out << sb;
+ if(allClassMembers.size() > 1)
+ {
+ out << sp << nl << "Patcher(int member)";
+ out << sb;
+ out << nl << "__member = member;";
+ out << eb;
+ }
+
+ out << sp << nl << "public void" << nl << "patch(Ice.Object v)";
+ out << sb;
+ out << nl << "try";
+ out << sb;
+ if(allClassMembers.size() > 1)
+ {
+ out << nl << "switch(__member)";
+ out << sb;
+ }
+ int memberCount = 0;
+ for(d = allClassMembers.begin(); d != allClassMembers.end(); ++d)
+ {
+ if(allClassMembers.size() > 1)
+ {
+ out.dec();
+ out << nl << "case " << memberCount << ":";
+ out.inc();
+ }
+ if(allClassMembers.size() > 1)
+ {
+ out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";";
+ }
+ string memberName = fixKwd((*d)->name());
+ string memberType = typeToString((*d)->type(), TypeModeMember, package);
+ out << nl << memberName << " = (" << memberType << ")v;";
+ if(allClassMembers.size() > 1)
+ {
+ out << nl << "break;";
+ }
+ memberCount++;
+ }
+ if(allClassMembers.size() > 1)
+ {
+ out << eb;
+ }
+ out << eb;
+ out << nl << "catch(ClassCastException ex)";
+ out << sb;
+ out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
+ out << nl << "_e.type = v.ice_id();";
+ out << nl << "_e.expectedType = type();";
+ out << nl << "throw _e;";
+ out << eb;
+ out << eb;
+
+ out << sp << nl << "public String" << nl << "type()";
+ out << sb;
+ if(allClassMembers.size() > 1)
+ {
+ out << nl << "return __typeId;";
+ }
+ else
+ {
+ out << nl << "return \"" << (*allClassMembers.begin())->type()->typeId() << "\";";
+ }
+ out << eb;
if(_stream)
{
@@ -2091,39 +2091,39 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
out << eb;
}
- if(allClassMembers.size() > 1)
- {
- out << sp << nl << "private int __member;";
- out << nl << "private String __typeId;";
- }
- out << eb;
- }
+ if(allClassMembers.size() > 1)
+ {
+ out << sp << nl << "private int __member;";
+ out << nl << "private String __typeId;";
+ }
+ out << eb;
+ }
out << sp << nl << "public void" << nl << "__read(IceInternal.BasicStream __is, boolean __rid)";
out << sb;
- out << nl << "if(__rid)";
- out << sb;
- out << nl << "__is.readString();";
- out << eb;
- out << nl << "__is.startReadSlice();";
+ out << nl << "if(__rid)";
+ out << sb;
+ out << nl << "__is.readString();";
+ out << eb;
+ out << nl << "__is.startReadSlice();";
iter = 0;
- DataMemberList classMembers = p->classDataMembers();
- size_t classMemberCount = allClassMembers.size() - classMembers.size();
+ DataMemberList classMembers = p->classDataMembers();
+ size_t classMemberCount = allClassMembers.size() - classMembers.size();
for(d = members.begin(); d != members.end(); ++d)
{
- ostringstream patchParams;
- BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type());
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*d)->type()))
- {
- if(classMembers.size() > 1 || allClassMembers.size() > 1)
- {
- patchParams << "new Patcher(" << classMemberCount++ << ')';
- }
- }
+ ostringstream patchParams;
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type());
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*d)->type()))
+ {
+ if(classMembers.size() > 1 || allClassMembers.size() > 1)
+ {
+ patchParams << "new Patcher(" << classMemberCount++ << ')';
+ }
+ }
StringList metaData = (*d)->getMetaData();
writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), false, iter, false, metaData,
- patchParams.str());
+ patchParams.str());
}
- out << nl << "__is.endReadSlice();";
+ out << nl << "__is.endReadSlice();";
if(base)
{
out << nl << "super.__read(__is, true);";
@@ -2200,16 +2200,16 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
out << eb;
}
- if(p->usesClasses())
- {
- if(!base || base && !base->usesClasses())
- {
- out << sp << nl << "public boolean" << nl << "__usesClasses()";
- out << sb;
- out << nl << "return true;";
- out << eb;
- }
- }
+ if(p->usesClasses())
+ {
+ if(!base || base && !base->usesClasses())
+ {
+ out << sp << nl << "public boolean" << nl << "__usesClasses()";
+ out << sb;
+ out << nl << "return true;";
+ out << eb;
+ }
+ }
}
out << eb;
@@ -2234,9 +2234,9 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p)
string deprecateReason = getDeprecateReason(p, 0, "type");
if(!deprecateReason.empty())
{
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
}
out << nl << "public final class " << name << " implements java.lang.Cloneable";
@@ -2267,17 +2267,17 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
vector<string> paramNames;
for(d = members.begin(); d != members.end(); ++d)
{
- string memberName = fixKwd((*d)->name());
- string memberType = typeToString((*d)->type(), TypeModeMember, package, (*d)->getMetaData());
- paramDecl.push_back(memberType + " " + memberName);
- paramNames.push_back(memberName);
+ string memberName = fixKwd((*d)->name());
+ string memberType = typeToString((*d)->type(), TypeModeMember, package, (*d)->getMetaData());
+ paramDecl.push_back(memberType + " " + memberName);
+ paramNames.push_back(memberName);
}
out << sp << nl << "public " << name << spar << paramDecl << epar;
out << sb;
for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i)
{
- out << nl << "this." << *i << " = " << *i << ';';
+ out << nl << "this." << *i << " = " << *i << ';';
}
out << eb;
@@ -2347,7 +2347,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
SequencePtr seq = SequencePtr::dynamicCast((*d)->type());
if(seq)
{
- if(hasTypeMetaData(seq, (*d)->getMetaData()))
+ if(hasTypeMetaData(seq, (*d)->getMetaData()))
{
out << nl << "if(" << memberName << " != _r." << memberName << " && " << memberName
<< " != null && !" << memberName << ".equals(_r." << memberName << "))";
@@ -2417,80 +2417,80 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
}
out << eb;
- DataMemberList classMembers = p->classDataMembers();
+ DataMemberList classMembers = p->classDataMembers();
- if(classMembers.size() != 0)
- {
- out << sp << nl << "private class Patcher implements IceInternal.Patcher";
+ if(classMembers.size() != 0)
+ {
+ out << sp << nl << "private class Patcher implements IceInternal.Patcher";
if(_stream)
{
out << ", Ice.ReadObjectCallback";
}
- out << sb;
- if(classMembers.size() > 1)
- {
- out << sp << nl << "Patcher(int member)";
- out << sb;
- out << nl << "__member = member;";
- out << eb;
- }
-
- out << sp << nl << "public void" << nl << "patch(Ice.Object v)";
- out << sb;
- out << nl << "try";
- out << sb;
- if(classMembers.size() > 1)
- {
- out << nl << "switch(__member)";
- out << sb;
- }
- int memberCount = 0;
- for(d = classMembers.begin(); d != classMembers.end(); ++d)
- {
- if(classMembers.size() > 1)
- {
- out.dec();
- out << nl << "case " << memberCount << ":";
- out.inc();
- }
- if(classMembers.size() > 1)
- {
- out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";";
- }
- string memberName = fixKwd((*d)->name());
- string memberType = typeToString((*d)->type(), TypeModeMember, package);
- out << nl << memberName << " = (" << memberType << ")v;";
- if(classMembers.size() > 1)
- {
- out << nl << "break;";
- }
- memberCount++;
- }
- if(classMembers.size() > 1)
- {
- out << eb;
- }
- out << eb;
- out << nl << "catch(ClassCastException ex)";
- out << sb;
- out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
- out << nl << "_e.type = v.ice_id();";
- out << nl << "_e.expectedType = type();";
- out << nl << "throw _e;";
- out << eb;
- out << eb;
-
- out << sp << nl << "public String" << nl << "type()";
- out << sb;
- if(classMembers.size() > 1)
- {
- out << nl << "return __typeId;";
- }
- else
- {
- out << nl << "return \"" << (*classMembers.begin())->type()->typeId() << "\";";
- }
- out << eb;
+ out << sb;
+ if(classMembers.size() > 1)
+ {
+ out << sp << nl << "Patcher(int member)";
+ out << sb;
+ out << nl << "__member = member;";
+ out << eb;
+ }
+
+ out << sp << nl << "public void" << nl << "patch(Ice.Object v)";
+ out << sb;
+ out << nl << "try";
+ out << sb;
+ if(classMembers.size() > 1)
+ {
+ out << nl << "switch(__member)";
+ out << sb;
+ }
+ int memberCount = 0;
+ for(d = classMembers.begin(); d != classMembers.end(); ++d)
+ {
+ if(classMembers.size() > 1)
+ {
+ out.dec();
+ out << nl << "case " << memberCount << ":";
+ out.inc();
+ }
+ if(classMembers.size() > 1)
+ {
+ out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";";
+ }
+ string memberName = fixKwd((*d)->name());
+ string memberType = typeToString((*d)->type(), TypeModeMember, package);
+ out << nl << memberName << " = (" << memberType << ")v;";
+ if(classMembers.size() > 1)
+ {
+ out << nl << "break;";
+ }
+ memberCount++;
+ }
+ if(classMembers.size() > 1)
+ {
+ out << eb;
+ }
+ out << eb;
+ out << nl << "catch(ClassCastException ex)";
+ out << sb;
+ out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
+ out << nl << "_e.type = v.ice_id();";
+ out << nl << "_e.expectedType = type();";
+ out << nl << "throw _e;";
+ out << eb;
+ out << eb;
+
+ out << sp << nl << "public String" << nl << "type()";
+ out << sb;
+ if(classMembers.size() > 1)
+ {
+ out << nl << "return __typeId;";
+ }
+ else
+ {
+ out << nl << "return \"" << (*classMembers.begin())->type()->typeId() << "\";";
+ }
+ out << eb;
if(_stream)
{
@@ -2500,32 +2500,32 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
out << eb;
}
- if(classMembers.size() > 1)
- {
- out << sp << nl << "private int __member;";
- out << nl << "private String __typeId;";
- }
- out << eb;
- }
+ if(classMembers.size() > 1)
+ {
+ out << sp << nl << "private int __member;";
+ out << nl << "private String __typeId;";
+ }
+ out << eb;
+ }
out << sp << nl << "public void" << nl << "__read(IceInternal.BasicStream __is)";
out << sb;
iter = 0;
- int classMemberCount = 0;
+ int classMemberCount = 0;
for(d = members.begin(); d != members.end(); ++d)
{
- ostringstream patchParams;
- BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type());
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*d)->type()))
- {
- if(classMembers.size() > 1)
- {
- patchParams << "new Patcher(" << classMemberCount++ << ')';
- }
- }
+ ostringstream patchParams;
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type());
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*d)->type()))
+ {
+ if(classMembers.size() > 1)
+ {
+ patchParams << "new Patcher(" << classMemberCount++ << ')';
+ }
+ }
StringList metaData = (*d)->getMetaData();
writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), false, iter, false, metaData,
- patchParams.str());
+ patchParams.str());
}
out << eb;
@@ -2585,9 +2585,9 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
string deprecateReason = getDeprecateReason(p, contained, "member");
if(!deprecateReason.empty())
{
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
}
out << nl << "public " << s << ' ' << name << ';';
@@ -2596,134 +2596,134 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
//
if(p->hasMetaData(_getSetMetaData) || contained->hasMetaData(_getSetMetaData))
{
- string capName = p->name();
- capName[0] = toupper(capName[0]);
-
- //
- // If container is a class, get all of its operations so that we can check for conflicts.
- //
- OperationList ops;
- string file, line;
- ClassDefPtr cls = ClassDefPtr::dynamicCast(container);
- if(cls)
- {
- ops = cls->allOperations();
- DefinitionContextPtr dc = p->definitionContext();
- file = dc->filename();
- line = p->line();
- if(!validateGetterSetter(ops, "get" + capName, 0, file, line) ||
- !validateGetterSetter(ops, "set" + capName, 1, file, line))
- {
- return;
- }
- }
-
- //
- // Getter.
- //
- out << sp;
- if(!deprecateReason.empty())
- {
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
- }
- out << nl << "public " << s;
- out << nl << "get" << capName << "()";
- out << sb;
- out << nl << "return " << name << ';';
- out << eb;
-
- //
- // Setter.
- //
- out << sp;
- if(!deprecateReason.empty())
- {
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
- }
- out << nl << "public void";
- out << nl << "set" << capName << '(' << s << " _" << name << ')';
- out << sb;
- out << nl << name << " = _" << name << ';';
- out << eb;
-
- //
- // Check for bool type.
- //
- BuiltinPtr b = BuiltinPtr::dynamicCast(type);
- if(b && b->kind() == Builtin::KindBool)
- {
- if(cls && !validateGetterSetter(ops, "is" + capName, 0, file, line))
- {
- return;
- }
- out << sp;
- if(!deprecateReason.empty())
- {
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
- }
- out << nl << "public boolean";
- out << nl << "is" << capName << "()";
- out << sb;
- out << nl << "return " << name << ';';
- out << eb;
- }
-
- //
- // Check for unmodified sequence type and emit indexing methods.
- //
- SequencePtr seq = SequencePtr::dynamicCast(type);
- if(seq)
- {
- if(!hasTypeMetaData(seq, metaData))
- {
- if(cls &&
- (!validateGetterSetter(ops, "get" + capName, 1, file, line) ||
- !validateGetterSetter(ops, "set" + capName, 2, file, line)))
- {
- return;
- }
-
- string elem = typeToString(seq->type(), TypeModeMember, getPackage(contained));
-
- //
- // Indexed getter.
- //
- out << sp;
- if(!deprecateReason.empty())
- {
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
- }
- out << nl << "public " << elem;
- out << nl << "get" << capName << "(int _index)";
- out << sb;
- out << nl << "return " << name << "[_index];";
- out << eb;
-
- //
- // Indexed setter.
- //
- out << sp;
- if(!deprecateReason.empty())
- {
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
- }
- out << nl << "public void";
- out << nl << "set" << capName << "(int _index, " << elem << " _val)";
- out << sb;
- out << nl << name << "[_index] = _val;";
- out << eb;
- }
- }
+ string capName = p->name();
+ capName[0] = toupper(capName[0]);
+
+ //
+ // If container is a class, get all of its operations so that we can check for conflicts.
+ //
+ OperationList ops;
+ string file, line;
+ ClassDefPtr cls = ClassDefPtr::dynamicCast(container);
+ if(cls)
+ {
+ ops = cls->allOperations();
+ DefinitionContextPtr dc = p->definitionContext();
+ file = dc->filename();
+ line = p->line();
+ if(!validateGetterSetter(ops, "get" + capName, 0, file, line) ||
+ !validateGetterSetter(ops, "set" + capName, 1, file, line))
+ {
+ return;
+ }
+ }
+
+ //
+ // Getter.
+ //
+ out << sp;
+ if(!deprecateReason.empty())
+ {
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
+ }
+ out << nl << "public " << s;
+ out << nl << "get" << capName << "()";
+ out << sb;
+ out << nl << "return " << name << ';';
+ out << eb;
+
+ //
+ // Setter.
+ //
+ out << sp;
+ if(!deprecateReason.empty())
+ {
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
+ }
+ out << nl << "public void";
+ out << nl << "set" << capName << '(' << s << " _" << name << ')';
+ out << sb;
+ out << nl << name << " = _" << name << ';';
+ out << eb;
+
+ //
+ // Check for bool type.
+ //
+ BuiltinPtr b = BuiltinPtr::dynamicCast(type);
+ if(b && b->kind() == Builtin::KindBool)
+ {
+ if(cls && !validateGetterSetter(ops, "is" + capName, 0, file, line))
+ {
+ return;
+ }
+ out << sp;
+ if(!deprecateReason.empty())
+ {
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
+ }
+ out << nl << "public boolean";
+ out << nl << "is" << capName << "()";
+ out << sb;
+ out << nl << "return " << name << ';';
+ out << eb;
+ }
+
+ //
+ // Check for unmodified sequence type and emit indexing methods.
+ //
+ SequencePtr seq = SequencePtr::dynamicCast(type);
+ if(seq)
+ {
+ if(!hasTypeMetaData(seq, metaData))
+ {
+ if(cls &&
+ (!validateGetterSetter(ops, "get" + capName, 1, file, line) ||
+ !validateGetterSetter(ops, "set" + capName, 2, file, line)))
+ {
+ return;
+ }
+
+ string elem = typeToString(seq->type(), TypeModeMember, getPackage(contained));
+
+ //
+ // Indexed getter.
+ //
+ out << sp;
+ if(!deprecateReason.empty())
+ {
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
+ }
+ out << nl << "public " << elem;
+ out << nl << "get" << capName << "(int _index)";
+ out << sb;
+ out << nl << "return " << name << "[_index];";
+ out << eb;
+
+ //
+ // Indexed setter.
+ //
+ out << sp;
+ if(!deprecateReason.empty())
+ {
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
+ }
+ out << nl << "public void";
+ out << nl << "set" << capName << "(int _index, " << elem << " _val)";
+ out << sb;
+ out << nl << name << "[_index] = _val;";
+ out << eb;
+ }
+ }
}
}
@@ -2748,49 +2748,49 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
string deprecateReason = getDeprecateReason(p, 0, "type");
if(!deprecateReason.empty())
{
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
}
bool java2 = p->definitionContext()->findMetaData("java:java2") == "java:java2";
if(java2)
{
- out << nl << "public final class " << name;
+ out << nl << "public final class " << name;
}
else
{
- out << nl << "public enum " << name;
+ out << nl << "public enum " << name;
}
out << sb;
if(!java2)
{
- int n;
- for(en = enumerators.begin(), n = 0; en != enumerators.end(); ++en, ++n)
- {
- if(en != enumerators.begin())
- {
- out << ',';
- }
- out << nl << fixKwd((*en)->name()) << '(' << n << ')';
- }
- out << ';';
- out << sp;
+ int n;
+ for(en = enumerators.begin(), n = 0; en != enumerators.end(); ++en, ++n)
+ {
+ if(en != enumerators.begin())
+ {
+ out << ',';
+ }
+ out << nl << fixKwd((*en)->name()) << '(' << n << ')';
+ }
+ out << ';';
+ out << sp;
}
out << nl << "private static " << name << "[] __values = new " << name << "[" << sz << "];";
if(!java2)
{
- out << nl << "static";
- out << sb;
- int n;
- for(en = enumerators.begin(), n = 0; en != enumerators.end(); ++en, ++n)
- {
- out << nl << "__values[" << n << "] = " << fixKwd((*en)->name()) << ';';
- }
- out << eb;
+ out << nl << "static";
+ out << sb;
+ int n;
+ for(en = enumerators.begin(), n = 0; en != enumerators.end(); ++en, ++n)
+ {
+ out << nl << "__values[" << n << "] = " << fixKwd((*en)->name()) << ';';
+ }
+ out << eb;
}
out << nl << "private int __value;";
@@ -2798,18 +2798,18 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
// For backward compatibility, we keep the integer member in the Java5 mapping.
//
{
- out << sp;
- int n;
- for(en = enumerators.begin(), n = 0; en != enumerators.end(); ++en, ++n)
- {
- string member = fixKwd((*en)->name());
- out << nl << "public static final int _" << member << " = " << n << ';';
- if(java2)
- {
- out << nl << "public static final " << name << ' ' << fixKwd(member)
- << " = new " << name << "(_" << member << ");";
- }
- }
+ out << sp;
+ int n;
+ for(en = enumerators.begin(), n = 0; en != enumerators.end(); ++en, ++n)
+ {
+ string member = fixKwd((*en)->name());
+ out << nl << "public static final int _" << member << " = " << n << ';';
+ if(java2)
+ {
+ out << nl << "public static final " << name << ' ' << fixKwd(member)
+ << " = new " << name << "(_" << member << ");";
+ }
+ }
}
out << sp << nl << "public static " << name << nl << "convert(int val)";
@@ -2838,10 +2838,10 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
if(java2)
{
- out << sp << nl << "public String" << nl << "toString()";
- out << sb;
- out << nl << "return __T[__value];";
- out << eb;
+ out << sp << nl << "public String" << nl << "toString()";
+ out << sb;
+ out << nl << "return __T[__value];";
+ out << eb;
}
out << sp << nl << "private" << nl << name << "(int val)";
@@ -2849,7 +2849,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
out << nl << "__value = val;";
if(java2)
{
- out << nl << "__values[val] = this;";
+ out << nl << "__values[val] = this;";
}
out << eb;
@@ -2935,18 +2935,18 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
if(java2)
{
- out << sp << nl << "final static private String[] __T =";
- out << sb;
- en = enumerators.begin();
- while(en != enumerators.end())
- {
- out << nl << "\"" << (*en)->name() << "\"";
- if(++en != enumerators.end())
- {
- out << ',';
- }
- }
- out << eb << ';';
+ out << sp << nl << "final static private String[] __T =";
+ out << sb;
+ en = enumerators.begin();
+ while(en != enumerators.end())
+ {
+ out << nl << "\"" << (*en)->name() << "\"";
+ if(++en != enumerators.end())
+ {
+ out << ',';
+ }
+ }
+ out << eb << ';';
}
out << eb;
@@ -2974,76 +2974,76 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
EnumPtr ep;
if(bp = BuiltinPtr::dynamicCast(type))
{
- switch(bp->kind())
- {
- case Builtin::KindString:
- {
- out << "\"";
-
- const string val = p->value();
- for(string::const_iterator c = val.begin(); c != val.end(); ++c)
- {
- if(isascii(*c) && isprint(*c))
- {
- switch(*c)
- {
- case '\\':
- case '"':
- {
- out << "\\";
- break;
- }
- }
- out << *c;
- }
- else
- {
- switch(*c)
- {
- case '\r':
- {
- out << "\\r";
- break;
- }
- case '\n':
- {
- out << "\\n";
- break;
- }
- default:
- {
- unsigned char uc = *c;
- ostringstream s;
- s << "\\u";
- s.flags(ios_base::hex);
- s.width(4);
- s.fill('0');
- s << static_cast<unsigned>(uc);
- out << s.str();
- break;
- }
- }
- }
- }
-
- out << "\"";
- break;
- }
- case Builtin::KindByte:
- {
- int i = atoi(p->value().c_str());
- if(i > 127)
- {
- i -= 256;
- }
- out << i; // Slice byte runs from 0-255, Java byte runs from -128 - 127.
- break;
- }
- case Builtin::KindLong:
- {
- out << p->value() << "L"; // Need to append "L" modifier for long constants.
- break;
- }
+ switch(bp->kind())
+ {
+ case Builtin::KindString:
+ {
+ out << "\"";
+
+ const string val = p->value();
+ for(string::const_iterator c = val.begin(); c != val.end(); ++c)
+ {
+ if(isascii(*c) && isprint(*c))
+ {
+ switch(*c)
+ {
+ case '\\':
+ case '"':
+ {
+ out << "\\";
+ break;
+ }
+ }
+ out << *c;
+ }
+ else
+ {
+ switch(*c)
+ {
+ case '\r':
+ {
+ out << "\\r";
+ break;
+ }
+ case '\n':
+ {
+ out << "\\n";
+ break;
+ }
+ default:
+ {
+ unsigned char uc = *c;
+ ostringstream s;
+ s << "\\u";
+ s.flags(ios_base::hex);
+ s.width(4);
+ s.fill('0');
+ s << static_cast<unsigned>(uc);
+ out << s.str();
+ break;
+ }
+ }
+ }
+ }
+
+ out << "\"";
+ break;
+ }
+ case Builtin::KindByte:
+ {
+ int i = atoi(p->value().c_str());
+ if(i > 127)
+ {
+ i -= 256;
+ }
+ out << i; // Slice byte runs from 0-255, Java byte runs from -128 - 127.
+ break;
+ }
+ case Builtin::KindLong:
+ {
+ out << p->value() << "L"; // Need to append "L" modifier for long constants.
+ break;
+ }
case Builtin::KindBool:
case Builtin::KindShort:
case Builtin::KindInt:
@@ -3052,11 +3052,11 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
case Builtin::KindObject:
case Builtin::KindObjectProxy:
case Builtin::KindLocalObject:
- {
- out << p->value();
+ {
+ out << p->value();
break;
- }
- }
+ }
+ }
}
else if(ep = EnumPtr::dynamicCast(type))
@@ -3067,11 +3067,11 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
{
val.erase(0, pos + 1);
}
- out << getAbsolute(ep, package) << '.' << fixKwd(val);
+ out << getAbsolute(ep, package) << '.' << fixKwd(val);
}
else
{
- out << p->value();
+ out << p->value();
}
out << ';' << eb;
close();
@@ -3079,21 +3079,21 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
bool
Slice::Gen::TypesVisitor::validateGetterSetter(const OperationList& ops, const std::string& name, int numArgs,
- const string& file, const string& line)
+ const string& file, const string& line)
{
for(OperationList::const_iterator i = ops.begin(); i != ops.end(); ++i)
{
- if((*i)->name() == name)
- {
- int numParams = static_cast<int>((*i)->parameters().size());
- if(numArgs >= numParams && numArgs - numParams <= 1)
- {
- cerr << file << ":" << line
- << ": error: operation `" << name << "' conflicts with getter/setter method" << endl;
- return false;
- }
- break;
- }
+ if((*i)->name() == name)
+ {
+ int numParams = static_cast<int>((*i)->parameters().size());
+ if(numArgs >= numParams && numArgs - numParams <= 1)
+ {
+ cerr << file << ":" << line
+ << ": error: operation `" << name << "' conflicts with getter/setter method" << endl;
+ return false;
+ }
+ break;
+ }
}
return true;
}
@@ -3181,37 +3181,37 @@ Slice::Gen::HolderVisitor::writeHolder(const TypePtr& p)
out << sb;
out << nl << "this.value = value;";
out << eb;
- if(!p->isLocal())
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(p);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(p))
- {
- out << sp << nl << "public class Patcher implements IceInternal.Patcher";
+ if(!p->isLocal())
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(p);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(p))
+ {
+ out << sp << nl << "public class Patcher implements IceInternal.Patcher";
if(_stream)
{
out << ", Ice.ReadObjectCallback";
}
- out << sb;
- out << nl << "public void";
- out << nl << "patch(Ice.Object v)";
- out << sb;
- out << nl << "try";
- out << sb;
- out << nl << "value = (" << typeS << ")v;";
- out << eb;
- out << nl << "catch(ClassCastException ex)";
- out << sb;
- out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
- out << nl << "_e.type = v.ice_id();";
- out << nl << "_e.expectedType = type();";
- out << nl << "throw _e;";
- out << eb;
- out << eb;
-
- out << sp << nl << "public String" << nl << "type()";
- out << sb;
- out << nl << "return \"" << p->typeId() << "\";";
- out << eb;
+ out << sb;
+ out << nl << "public void";
+ out << nl << "patch(Ice.Object v)";
+ out << sb;
+ out << nl << "try";
+ out << sb;
+ out << nl << "value = (" << typeS << ")v;";
+ out << eb;
+ out << nl << "catch(ClassCastException ex)";
+ out << sb;
+ out << nl << "Ice.UnexpectedObjectException _e = new Ice.UnexpectedObjectException();";
+ out << nl << "_e.type = v.ice_id();";
+ out << nl << "_e.expectedType = type();";
+ out << nl << "throw _e;";
+ out << eb;
+ out << eb;
+
+ out << sp << nl << "public String" << nl << "type()";
+ out << sb;
+ out << nl << "return \"" << p->typeId() << "\";";
+ out << eb;
if(_stream)
{
@@ -3220,15 +3220,15 @@ Slice::Gen::HolderVisitor::writeHolder(const TypePtr& p)
out << nl << "patch(v);";
out << eb;
}
- out << eb;
-
- out << sp << nl << "public Patcher";
- out << nl << "getPatcher()";
- out << sb;
- out << nl << "return new Patcher();";
- out << eb;
- }
- }
+ out << eb;
+
+ out << sp << nl << "public Patcher";
+ out << nl << "getPatcher()";
+ out << sb;
+ out << nl << "return new Patcher();";
+ out << eb;
+ }
+ }
out << sp << nl << "public " << typeS << " value;";
out << eb;
close();
@@ -3285,8 +3285,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
for(r = ops.begin(); r != ops.end(); ++r)
{
OperationPtr op = *r;
- ContainerPtr container = op->container();
- ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
+ ContainerPtr container = op->container();
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
string opName = fixKwd(op->name());
TypePtr ret = op->returnType();
string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData());
@@ -3311,51 +3311,51 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
{
out << "return ";
}
- out << opName << spar << args << "null" << "false" << epar << ';';
+ out << opName << spar << args << "null" << "false" << epar << ';';
out << eb;
- out << sp;
+ out << sp;
out << nl << "public " << retS << nl << opName << spar << params << contextParam << epar;
writeThrowsClause(package, throws);
out << sb;
- out << nl;
+ out << nl;
if(ret)
{
out << "return ";
}
- out << opName << spar << args << "__ctx" << "true" << epar << ';';
+ out << opName << spar << args << "__ctx" << "true" << epar << ';';
out << eb;
out << sp;
- //
- // TODO: If we eventually drop support for Java2, we can remove this
- // SupressWarnings annotation. Meanwhile, it is necessary to prevent
- // a compiler warning about an unchecked conversion. This is caused
- // by the fact that _emptyContext returns the unchecked type
- // java.util.Map but Ice.Context is mapped to Map<String, String>.
- //
- if(!java2)
- {
- out << nl << "@SuppressWarnings(\"unchecked\")";
- }
+ //
+ // TODO: If we eventually drop support for Java2, we can remove this
+ // SupressWarnings annotation. Meanwhile, it is necessary to prevent
+ // a compiler warning about an unchecked conversion. This is caused
+ // by the fact that _emptyContext returns the unchecked type
+ // java.util.Map but Ice.Context is mapped to Map<String, String>.
+ //
+ if(!java2)
+ {
+ out << nl << "@SuppressWarnings(\"unchecked\")";
+ }
out << nl << "private " << retS << nl << opName << spar << params << contextParam
- << explicitContextParam << epar;
+ << explicitContextParam << epar;
writeThrowsClause(package, throws);
out << sb;
- out << nl << "if(__explicitCtx && __ctx == null)";
- out << sb;
- out << nl << "__ctx = _emptyContext;";
- out << eb;
+ out << nl << "if(__explicitCtx && __ctx == null)";
+ out << sb;
+ out << nl << "__ctx = _emptyContext;";
+ out << eb;
out << nl << "int __cnt = 0;";
out << nl << "while(true)";
out << sb;
out << nl << "Ice._ObjectDel __delBase = null;";
out << nl << "try";
out << sb;
- if(op->returnsData())
- {
- out << nl << "__checkTwowayOnly(\"" << opName << "\");";
- }
+ if(op->returnsData())
+ {
+ out << nl << "__checkTwowayOnly(\"" << opName << "\");";
+ }
out << nl << "__delBase = __getDelegate();";
out << nl << '_' << name << "Del __del = (_" << name << "Del)__delBase;";
out << nl;
@@ -3387,43 +3387,43 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << eb;
out << eb;
- if(cl->hasMetaData("ami") || op->hasMetaData("ami"))
- {
- vector<string> paramsAMI = getParamsAsync(op, package, false);
- vector<string> argsAMI = getArgsAsync(op);
-
- //
- // Write two versions of the operation - with and without a
- // context parameter
- //
- out << sp;
- out << nl << "public void" << nl << op->name() << "_async" << spar << paramsAMI << epar;
- out << sb;
- out << nl << "__cb.__invoke" << spar << "this" << argsAMI << "null" << epar << ';';
- out << eb;
-
- out << sp;
- //
- // TODO: If we eventually drop support for Java2, we can remove this
- // SupressWarnings annotation. Meanwhile, it is necessary to prevent
- // a compiler warning about an unchecked conversion. This is caused
- // by the fact that _emptyContext returns the unchecked type
- // java.util.Map but Ice.Context is mapped to Map<String, String>.
- //
- if(!java2)
- {
- out << nl << "@SuppressWarnings(\"unchecked\")";
- }
- out << nl << "public void" << nl << op->name() << "_async" << spar << paramsAMI
- << contextParam << epar;
- out << sb;
- out << nl << "if( __ctx == null)";
- out << sb;
- out << nl << "__ctx = _emptyContext;";
- out << eb;
- out << nl << "__cb.__invoke" << spar << "this" << argsAMI << "__ctx" << epar << ';';
- out << eb;
- }
+ if(cl->hasMetaData("ami") || op->hasMetaData("ami"))
+ {
+ vector<string> paramsAMI = getParamsAsync(op, package, false);
+ vector<string> argsAMI = getArgsAsync(op);
+
+ //
+ // Write two versions of the operation - with and without a
+ // context parameter
+ //
+ out << sp;
+ out << nl << "public void" << nl << op->name() << "_async" << spar << paramsAMI << epar;
+ out << sb;
+ out << nl << "__cb.__invoke" << spar << "this" << argsAMI << "null" << epar << ';';
+ out << eb;
+
+ out << sp;
+ //
+ // TODO: If we eventually drop support for Java2, we can remove this
+ // SupressWarnings annotation. Meanwhile, it is necessary to prevent
+ // a compiler warning about an unchecked conversion. This is caused
+ // by the fact that _emptyContext returns the unchecked type
+ // java.util.Map but Ice.Context is mapped to Map<String, String>.
+ //
+ if(!java2)
+ {
+ out << nl << "@SuppressWarnings(\"unchecked\")";
+ }
+ out << nl << "public void" << nl << op->name() << "_async" << spar << paramsAMI
+ << contextParam << epar;
+ out << sb;
+ out << nl << "if( __ctx == null)";
+ out << sb;
+ out << nl << "__ctx = _emptyContext;";
+ out << eb;
+ out << nl << "__cb.__invoke" << spar << "this" << argsAMI << "__ctx" << epar << ';';
+ out << eb;
+ }
}
out << sp << nl << "public static " << name << "Prx" << nl << "checkedCast(Ice.ObjectPrx __obj)";
@@ -3449,7 +3449,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << eb;
out << sp << nl << "public static " << name << "Prx" << nl << "checkedCast(Ice.ObjectPrx __obj, " << contextParam
- << ')';
+ << ')';
out << sb;
out << nl << name << "Prx __d = null;";
out << nl << "if(__obj != null)";
@@ -3695,7 +3695,7 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p)
out << sb;
out << nl << typeS << " __v;";
iter = 0;
- writeSequenceMarshalUnmarshalCode(out, package, p, "__v", false, iter, false);
+ writeSequenceMarshalUnmarshalCode(out, package, p, "__v", false, iter, false);
out << nl << "return __v;";
out << eb;
@@ -3746,42 +3746,42 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
if(open(helper))
{
Output& out = output();
- int iter;
+ int iter;
out << sp << nl << "public final class " << name << "Helper";
out << sb;
out << nl << "public static void" << nl << "write(IceInternal.BasicStream __os, " << abstractType << " __v)";
out << sb;
- iter = 0;
+ iter = 0;
writeDictionaryMarshalUnmarshalCode(out, package, p, "__v", true, iter, false);
- out << eb;
+ out << eb;
- out << sp << nl << "public static " << abstractType
- << nl << "read(IceInternal.BasicStream __is)";
- out << sb;
- out << nl << abstractType << " __v = new " << concreteType << "();";
- iter = 0;
- writeDictionaryMarshalUnmarshalCode(out, package, p, "__v", false, iter, false);
- out << nl << "return __v;";
- out << eb;
+ out << sp << nl << "public static " << abstractType
+ << nl << "read(IceInternal.BasicStream __is)";
+ out << sb;
+ out << nl << abstractType << " __v = new " << concreteType << "();";
+ iter = 0;
+ writeDictionaryMarshalUnmarshalCode(out, package, p, "__v", false, iter, false);
+ out << nl << "return __v;";
+ out << eb;
if(_stream)
{
out << sp << nl << "public static void" << nl << "write(Ice.OutputStream __outS, " << abstractType
- << " __v)";
+ << " __v)";
out << sb;
- iter = 0;
- writeStreamDictionaryMarshalUnmarshalCode(out, package, p, "__v", true, iter, false);
+ iter = 0;
+ writeStreamDictionaryMarshalUnmarshalCode(out, package, p, "__v", true, iter, false);
out << eb;
- out << sp << nl << "public static " << abstractType
+ out << sp << nl << "public static " << abstractType
<< nl << "read(Ice.InputStream __inS)";
out << sb;
- out << nl << abstractType << " __v = new " << concreteType << "();";
- iter = 0;
- writeStreamDictionaryMarshalUnmarshalCode(out, package, p, "__v", false, iter, false);
- out << nl << "return __v;";
+ out << nl << abstractType << " __v = new " << concreteType << "();";
+ iter = 0;
+ writeStreamDictionaryMarshalUnmarshalCode(out, package, p, "__v", false, iter, false);
+ out << nl << "return __v;";
out << eb;
}
@@ -3910,18 +3910,18 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
out << sp;
if(!deprecateReason.empty())
{
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
}
out << nl << "public " << retS << ' ' << name << spar << params << epar;
writeThrowsClause(package, throws);
out << ';';
if(!deprecateReason.empty())
{
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
}
bool java2 = p->definitionContext()->findMetaData("java:java2") == "java:java2";
@@ -3933,27 +3933,27 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
if(cl->hasMetaData("ami") || p->hasMetaData("ami"))
{
- vector<string> paramsAMI = getParamsAsync(p, package, false);
-
- //
- // Write two versions of the operation - with and without a
- // context parameter.
- //
- out << sp;
- if(!deprecateReason.empty())
- {
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
- }
- out << nl << "public void " << p->name() << "_async" << spar << paramsAMI << epar << ';';
- if(!deprecateReason.empty())
- {
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
- }
- out << nl << "public void " << p->name() << "_async" << spar << paramsAMI << contextParam << epar << ';';
+ vector<string> paramsAMI = getParamsAsync(p, package, false);
+
+ //
+ // Write two versions of the operation - with and without a
+ // context parameter.
+ //
+ out << sp;
+ if(!deprecateReason.empty())
+ {
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
+ }
+ out << nl << "public void " << p->name() << "_async" << spar << paramsAMI << epar << ';';
+ if(!deprecateReason.empty())
+ {
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
+ }
+ out << nl << "public void " << p->name() << "_async" << spar << paramsAMI << contextParam << epar << ';';
}
}
@@ -4080,34 +4080,34 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
ParamDeclList inParams;
ParamDeclList outParams;
- ParamDeclList paramList = op->parameters();
- ParamDeclList::const_iterator pli;
- for(pli = paramList.begin(); pli != paramList.end(); ++pli)
- {
- if((*pli)->isOutParam())
- {
- outParams.push_back(*pli);
- }
- else
- {
- inParams.push_back(*pli);
- }
- }
+ ParamDeclList paramList = op->parameters();
+ ParamDeclList::const_iterator pli;
+ for(pli = paramList.begin(); pli != paramList.end(); ++pli)
+ {
+ if((*pli)->isOutParam())
+ {
+ outParams.push_back(*pli);
+ }
+ else
+ {
+ inParams.push_back(*pli);
+ }
+ }
ExceptionList throws = op->throws();
throws.sort();
throws.unique();
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
#if defined(__SUNPRO_CC)
- throws.sort(Slice::derivedToBaseCompare);
+ throws.sort(Slice::derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
vector<string> params = getParams(op, package);
@@ -4118,50 +4118,50 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sb;
out << nl << "IceInternal.Outgoing __og = __connection.getOutgoing(__reference, \"" << op->name() << "\", "
- << sliceModeToIceMode(op->sendMode()) << ", __ctx, __compress);";
+ << sliceModeToIceMode(op->sendMode()) << ", __ctx, __compress);";
out << nl << "try";
out << sb;
if(!inParams.empty())
{
- out << nl << "try";
- out << sb;
+ out << nl << "try";
+ out << sb;
out << nl << "IceInternal.BasicStream __os = __og.os();";
- for(pli = inParams.begin(); pli != inParams.end(); ++pli)
- {
- writeMarshalUnmarshalCode(out, package, (*pli)->type(), fixKwd((*pli)->name()), true, iter, false,
- (*pli)->getMetaData());
- }
- if(op->sendsClasses())
- {
- out << nl << "__os.writePendingObjects();";
- }
- out << eb;
- out << nl << "catch(Ice.LocalException __ex)";
- out << sb;
- out << nl << "__og.abort(__ex);";
- out << eb;
- }
- out << nl << "boolean __ok = __og.invoke();";
- out << nl << "try";
- out << sb;
- out << nl << "IceInternal.BasicStream __is = __og.is();";
+ for(pli = inParams.begin(); pli != inParams.end(); ++pli)
+ {
+ writeMarshalUnmarshalCode(out, package, (*pli)->type(), fixKwd((*pli)->name()), true, iter, false,
+ (*pli)->getMetaData());
+ }
+ if(op->sendsClasses())
+ {
+ out << nl << "__os.writePendingObjects();";
+ }
+ out << eb;
+ out << nl << "catch(Ice.LocalException __ex)";
+ out << sb;
+ out << nl << "__og.abort(__ex);";
+ out << eb;
+ }
+ out << nl << "boolean __ok = __og.invoke();";
+ out << nl << "try";
+ out << sb;
+ out << nl << "IceInternal.BasicStream __is = __og.is();";
out << nl << "if(!__ok)";
out << sb;
out << nl << "try";
out << sb;
- out << nl << "__is.throwException();";
+ out << nl << "__is.throwException();";
out << eb;
- for(ExceptionList::const_iterator t = throws.begin(); t != throws.end(); ++t)
- {
- out << nl << "catch(" << getAbsolute(*t, package) << " __ex)";
- out << sb;
- out << nl << "throw __ex;";
- out << eb;
- }
- out << nl << "catch(Ice.UserException __ex)";
- out << sb;
+ for(ExceptionList::const_iterator t = throws.begin(); t != throws.end(); ++t)
+ {
+ out << nl << "catch(" << getAbsolute(*t, package) << " __ex)";
+ out << sb;
+ out << nl << "throw __ex;";
+ out << eb;
+ }
+ out << nl << "catch(Ice.UserException __ex)";
+ out << sb;
out << nl << "throw new Ice.UnknownUserException(__ex.ice_name());";
- out << eb;
+ out << eb;
out << eb;
for(pli = outParams.begin(); pli != outParams.end(); ++pli)
{
@@ -4170,39 +4170,39 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
}
if(ret)
{
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
- {
- out << nl << retS << "Holder __ret = new " << retS << "Holder();";
- out << nl << "__is.readObject(__ret.getPatcher());";
- }
- else
- {
- out << nl << retS << " __ret;";
- writeMarshalUnmarshalCode(out, package, ret, "__ret", false, iter, false, opMetaData);
- }
- }
- if(op->returnsClasses())
- {
- out << nl << "__is.readPendingObjects();";
- }
- if(ret)
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
- {
- out << nl << "return __ret.value;";
- }
- else
- {
- out << nl << "return __ret;";
- }
- }
- out << eb;
- out << nl << "catch(Ice.LocalException __ex)";
- out << sb;
- out << nl << "throw new IceInternal.LocalExceptionWrapper(__ex, false);";
- out << eb;
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
+ {
+ out << nl << retS << "Holder __ret = new " << retS << "Holder();";
+ out << nl << "__is.readObject(__ret.getPatcher());";
+ }
+ else
+ {
+ out << nl << retS << " __ret;";
+ writeMarshalUnmarshalCode(out, package, ret, "__ret", false, iter, false, opMetaData);
+ }
+ }
+ if(op->returnsClasses())
+ {
+ out << nl << "__is.readPendingObjects();";
+ }
+ if(ret)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
+ {
+ out << nl << "return __ret.value;";
+ }
+ else
+ {
+ out << nl << "return __ret;";
+ }
+ }
+ out << eb;
+ out << nl << "catch(Ice.LocalException __ex)";
+ out << sb;
+ out << nl << "throw new IceInternal.LocalExceptionWrapper(__ex, false);";
+ out << eb;
out << eb;
out << nl << "finally";
out << sb;
@@ -4254,8 +4254,8 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
for(r = ops.begin(); r != ops.end(); ++r)
{
OperationPtr op = *r;
- ContainerPtr container = op->container();
- ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
+ ContainerPtr container = op->container();
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
string opName = fixKwd(op->name());
TypePtr ret = op->returnType();
string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData());
@@ -4267,63 +4267,63 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
vector<string> params = getParams(op, package);
vector<string> args = getArgs(op);
- out << sp;
+ out << sp;
out << nl << "public " << retS << nl << opName << spar << params << contextParam << epar;
writeDelegateThrowsClause(package, throws);
out << sb;
- if(cl->hasMetaData("amd") || op->hasMetaData("amd"))
- {
- out << nl << "throw new Ice.CollocationOptimizationException();";
- }
- else
- {
- StringList metaData = op->getMetaData();
- out << nl << "Ice.Current __current = new Ice.Current();";
- out << nl << "__initCurrent(__current, \"" << op->name() << "\", "
- << sliceModeToIceMode(op->sendMode())
- << ", __ctx);";
- out << nl << "while(true)";
- out << sb;
- out << nl << "IceInternal.Direct __direct = new IceInternal.Direct(__current);";
- out << nl << "try";
- out << sb;
- out << nl << fixKwd(name) << " __servant = null;";
- out << nl << "try";
- out << sb;
- out << nl << "__servant = (" << fixKwd(name) << ")__direct.servant();";
- out << eb;
- out << nl << "catch(ClassCastException __ex)";
- out << sb;
- out << nl << "Ice.OperationNotExistException __opEx = new Ice.OperationNotExistException();";
- out << nl << "__opEx.id = __current.id;";
- out << nl << "__opEx.facet = __current.facet;";
- out << nl << "__opEx.operation = __current.operation;";
- out << nl << "throw __opEx;";
- out << eb;
+ if(cl->hasMetaData("amd") || op->hasMetaData("amd"))
+ {
+ out << nl << "throw new Ice.CollocationOptimizationException();";
+ }
+ else
+ {
+ StringList metaData = op->getMetaData();
+ out << nl << "Ice.Current __current = new Ice.Current();";
+ out << nl << "__initCurrent(__current, \"" << op->name() << "\", "
+ << sliceModeToIceMode(op->sendMode())
+ << ", __ctx);";
+ out << nl << "while(true)";
+ out << sb;
+ out << nl << "IceInternal.Direct __direct = new IceInternal.Direct(__current);";
+ out << nl << "try";
+ out << sb;
+ out << nl << fixKwd(name) << " __servant = null;";
out << nl << "try";
out << sb;
- out << nl;
- if(ret)
- {
- out << "return ";
- }
- out << "__servant." << opName << spar << args << "__current" << epar << ';';
- if(!ret)
- {
- out << nl << "return;";
- }
+ out << nl << "__servant = (" << fixKwd(name) << ")__direct.servant();";
+ out << eb;
+ out << nl << "catch(ClassCastException __ex)";
+ out << sb;
+ out << nl << "Ice.OperationNotExistException __opEx = new Ice.OperationNotExistException();";
+ out << nl << "__opEx.id = __current.id;";
+ out << nl << "__opEx.facet = __current.facet;";
+ out << nl << "__opEx.operation = __current.operation;";
+ out << nl << "throw __opEx;";
+ out << eb;
+ out << nl << "try";
+ out << sb;
+ out << nl;
+ if(ret)
+ {
+ out << "return ";
+ }
+ out << "__servant." << opName << spar << args << "__current" << epar << ';';
+ if(!ret)
+ {
+ out << nl << "return;";
+ }
out << eb;
out << nl << "catch(Ice.LocalException __ex)";
out << sb;
out << nl << "throw new IceInternal.LocalExceptionWrapper(__ex, false);";
- out << eb;
- out << eb;
- out << nl << "finally";
- out << sb;
- out << nl << "__direct.destroy();";
- out << eb;
- out << eb;
- }
+ out << eb;
+ out << eb;
+ out << nl << "finally";
+ out << sb;
+ out << nl << "__direct.destroy();";
+ out << eb;
+ out << eb;
+ }
out << eb;
}
@@ -4523,25 +4523,25 @@ Slice::Gen::BaseImplVisitor::writeOperation(Output& out, const string& package,
if(!local && (cl->hasMetaData("amd") || op->hasMetaData("amd")))
{
- vector<string> paramsAMD = getParamsAsync(op, package, true);
+ vector<string> paramsAMD = getParamsAsync(op, package, true);
out << sp << nl << "public void" << nl << opName << "_async" << spar << paramsAMD << "Ice.Current __current"
- << epar;
+ << epar;
ExceptionList throws = op->throws();
throws.sort();
throws.unique();
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
#if defined(__SUNPRO_CC)
- throws.sort(Slice::derivedToBaseCompare);
+ throws.sort(Slice::derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
writeThrowsClause(package, throws);
@@ -4717,15 +4717,15 @@ Slice::Gen::ImplTieVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sp << nl << "public class " << name << 'I';
if(inheritImpl)
{
- out << " extends ";
+ out << " extends ";
if(bases.front()->isAbstract())
- {
- out << bases.front()->name() << 'I';
- }
- else
- {
- out << fixKwd(bases.front()->name());
- }
+ {
+ out << bases.front()->name() << 'I';
+ }
+ else
+ {
+ out << fixKwd(bases.front()->name());
+ }
}
out << " implements " << '_' << name << "Operations";
if(p->isLocal())
@@ -4786,7 +4786,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
if(cl->isLocal())
{
- return;
+ return;
}
string name = p->name();
@@ -4795,148 +4795,148 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
if(cl->hasMetaData("ami") || p->hasMetaData("ami"))
{
- string classNameAMI = "AMI_" + cl->name();
- string absoluteAMI = getAbsolute(cl, "", "AMI_", "_" + name);
+ string classNameAMI = "AMI_" + cl->name();
+ string absoluteAMI = getAbsolute(cl, "", "AMI_", "_" + name);
- if(!open(absoluteAMI))
- {
- return;
- }
-
- Output& out = output();
+ if(!open(absoluteAMI))
+ {
+ return;
+ }
+
+ Output& out = output();
TypePtr ret = p->returnType();
- ParamDeclList inParams;
+ ParamDeclList inParams;
ParamDeclList outParams;
- ParamDeclList paramList = p->parameters();
- ParamDeclList::const_iterator pli;
- for(pli = paramList.begin(); pli != paramList.end(); ++pli)
- {
- if((*pli)->isOutParam())
- {
- outParams.push_back(*pli);
- }
- else
- {
- inParams.push_back(*pli);
- }
- }
+ ParamDeclList paramList = p->parameters();
+ ParamDeclList::const_iterator pli;
+ for(pli = paramList.begin(); pli != paramList.end(); ++pli)
+ {
+ if((*pli)->isOutParam())
+ {
+ outParams.push_back(*pli);
+ }
+ else
+ {
+ inParams.push_back(*pli);
+ }
+ }
ExceptionList throws = p->throws();
throws.sort();
throws.unique();
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
#if defined(__SUNPRO_CC)
- throws.sort(Slice::derivedToBaseCompare);
+ throws.sort(Slice::derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
int iter;
- vector<string> params = getParamsAsyncCB(p, classPkg);
- vector<string> args = getArgsAsyncCB(p);
-
- vector<string> paramsInvoke = getParamsAsync(p, classPkg, false);
-
- out << sp << nl << "public abstract class " << classNameAMI << '_' << name
- << " extends IceInternal.OutgoingAsync";
- out << sb;
- out << sp;
- out << nl << "public abstract void ice_response" << spar << params << epar << ';';
- out << nl << "public abstract void ice_exception(Ice.LocalException ex);";
- if(!throws.empty())
- {
- out << nl << "public abstract void ice_exception(Ice.UserException ex);";
- }
-
- bool java2 = p->definitionContext()->findMetaData("java:java2") == "java:java2";
- string contextParam = java2 ? "java.util.Map __ctx" : "java.util.Map<String, String> __ctx";
-
- out << sp << nl << "public final void" << nl << "__invoke" << spar << "Ice.ObjectPrx __prx"
- << paramsInvoke << contextParam << epar;
- out << sb;
- out << nl << "try";
- out << sb;
- out << nl << "__prepare(__prx, \"" << p->name() << "\", "
- << sliceModeToIceMode(p->sendMode()) << ", __ctx);";
+ vector<string> params = getParamsAsyncCB(p, classPkg);
+ vector<string> args = getArgsAsyncCB(p);
+
+ vector<string> paramsInvoke = getParamsAsync(p, classPkg, false);
+
+ out << sp << nl << "public abstract class " << classNameAMI << '_' << name
+ << " extends IceInternal.OutgoingAsync";
+ out << sb;
+ out << sp;
+ out << nl << "public abstract void ice_response" << spar << params << epar << ';';
+ out << nl << "public abstract void ice_exception(Ice.LocalException ex);";
+ if(!throws.empty())
+ {
+ out << nl << "public abstract void ice_exception(Ice.UserException ex);";
+ }
+
+ bool java2 = p->definitionContext()->findMetaData("java:java2") == "java:java2";
+ string contextParam = java2 ? "java.util.Map __ctx" : "java.util.Map<String, String> __ctx";
+
+ out << sp << nl << "public final void" << nl << "__invoke" << spar << "Ice.ObjectPrx __prx"
+ << paramsInvoke << contextParam << epar;
+ out << sb;
+ out << nl << "try";
+ out << sb;
+ out << nl << "__prepare(__prx, \"" << p->name() << "\", "
+ << sliceModeToIceMode(p->sendMode()) << ", __ctx);";
iter = 0;
- for(pli = inParams.begin(); pli != inParams.end(); ++pli)
- {
+ for(pli = inParams.begin(); pli != inParams.end(); ++pli)
+ {
StringList metaData = (*pli)->getMetaData();
- string typeS = typeToString((*pli)->type(), TypeModeIn, classPkg, metaData);
- writeMarshalUnmarshalCode(out, classPkg, (*pli)->type(), fixKwd((*pli)->name()), true, iter, false,
+ string typeS = typeToString((*pli)->type(), TypeModeIn, classPkg, metaData);
+ writeMarshalUnmarshalCode(out, classPkg, (*pli)->type(), fixKwd((*pli)->name()), true, iter, false,
metaData);
- }
- if(p->sendsClasses())
- {
- out << nl << "__os.writePendingObjects();";
- }
- out << nl << "__os.endWriteEncaps();";
- out << eb;
- out << nl << "catch(Ice.LocalException __ex)";
- out << sb;
- out << nl << "__finished(__ex);";
- out << nl << "return;";
- out << eb;
- out << nl << "__send();";
- out << eb;
-
- out << sp << nl << "protected final void" << nl << "__response(boolean __ok)";
- out << sb;
+ }
+ if(p->sendsClasses())
+ {
+ out << nl << "__os.writePendingObjects();";
+ }
+ out << nl << "__os.endWriteEncaps();";
+ out << eb;
+ out << nl << "catch(Ice.LocalException __ex)";
+ out << sb;
+ out << nl << "__finished(__ex);";
+ out << nl << "return;";
+ out << eb;
+ out << nl << "__send();";
+ out << eb;
+
+ out << sp << nl << "protected final void" << nl << "__response(boolean __ok)";
+ out << sb;
for(pli = outParams.begin(); pli != outParams.end(); ++pli)
{
TypePtr paramType = (*pli)->type();
string paramName = fixKwd((*pli)->name());
string typeS = typeToString(paramType, TypeModeIn, classPkg, (*pli)->getMetaData());
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType))
- {
- out << nl << typeS << "Holder " << paramName << " = new " << typeS << "Holder();";
- }
- else
- {
- out << nl << typeS << ' ' << paramName << ';';
- }
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType))
+ {
+ out << nl << typeS << "Holder " << paramName << " = new " << typeS << "Holder();";
+ }
+ else
+ {
+ out << nl << typeS << ' ' << paramName << ';';
+ }
}
if(ret)
{
- string retS = typeToString(ret, TypeModeIn, classPkg, opMetaData);
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
- {
- out << nl << retS << "Holder __ret = new " << retS << "Holder();";
- }
- else
- {
- out << nl << retS << " __ret;";
- }
- }
- out << nl << "try";
- out << sb;
- out << nl << "if(!__ok)";
+ string retS = typeToString(ret, TypeModeIn, classPkg, opMetaData);
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
+ {
+ out << nl << retS << "Holder __ret = new " << retS << "Holder();";
+ }
+ else
+ {
+ out << nl << retS << " __ret;";
+ }
+ }
+ out << nl << "try";
+ out << sb;
+ out << nl << "if(!__ok)";
+ out << sb;
+ out << nl << "try";
+ out << sb;
+ out << nl << "__is.throwException();";
+ out << eb;
+ for(ExceptionList::const_iterator r = throws.begin(); r != throws.end(); ++r)
+ {
+ out << nl << "catch(" << getAbsolute(*r, classPkg) << " __ex)";
+ out << sb;
+ out << nl << "ice_exception(__ex);";
+ out << nl << "return;";
+ out << eb;
+ }
+ out << nl << "catch(Ice.UserException __ex)";
out << sb;
- out << nl << "try";
- out << sb;
- out << nl << "__is.throwException();";
- out << eb;
- for(ExceptionList::const_iterator r = throws.begin(); r != throws.end(); ++r)
- {
- out << nl << "catch(" << getAbsolute(*r, classPkg) << " __ex)";
- out << sb;
- out << nl << "ice_exception(__ex);";
- out << nl << "return;";
- out << eb;
- }
- out << nl << "catch(Ice.UserException __ex)";
- out << sb;
out << nl << "throw new Ice.UnknownUserException(__ex.ice_name());";
out << eb;
out << eb;
@@ -4944,186 +4944,186 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
{
TypePtr paramType = (*pli)->type();
string paramName = fixKwd((*pli)->name());
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType))
- {
- out << nl << "__is.readObject(" << paramName << ".getPatcher());";
- }
- else
- {
- writeMarshalUnmarshalCode(out, classPkg, paramType, paramName, false, iter, false,
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType))
+ {
+ out << nl << "__is.readObject(" << paramName << ".getPatcher());";
+ }
+ else
+ {
+ writeMarshalUnmarshalCode(out, classPkg, paramType, paramName, false, iter, false,
(*pli)->getMetaData());
- }
+ }
}
if(ret)
{
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
- {
- out << nl << "__is.readObject(__ret.getPatcher());";
- }
- else
- {
- writeMarshalUnmarshalCode(out, classPkg, ret, "__ret", false, iter, false, opMetaData);
- }
- }
- if(p->returnsClasses())
- {
- out << nl << "__is.readPendingObjects();";
- }
- out << eb;
- out << nl << "catch(Ice.LocalException __ex)";
- out << sb;
- out << nl << "__finished(__ex);";
- out << nl << "return;";
- out << eb;
- out << nl << "ice_response" << spar << args << epar << ';';
- out << eb;
- out << eb;
-
- close();
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
+ {
+ out << nl << "__is.readObject(__ret.getPatcher());";
+ }
+ else
+ {
+ writeMarshalUnmarshalCode(out, classPkg, ret, "__ret", false, iter, false, opMetaData);
+ }
+ }
+ if(p->returnsClasses())
+ {
+ out << nl << "__is.readPendingObjects();";
+ }
+ out << eb;
+ out << nl << "catch(Ice.LocalException __ex)";
+ out << sb;
+ out << nl << "__finished(__ex);";
+ out << nl << "return;";
+ out << eb;
+ out << nl << "ice_response" << spar << args << epar << ';';
+ out << eb;
+ out << eb;
+
+ close();
}
if(cl->hasMetaData("amd") || p->hasMetaData("amd"))
{
- string classNameAMD = "AMD_" + cl->name();
- string absoluteAMD = getAbsolute(cl, "", "AMD_", "_" + name);
-
- string classNameAMDI = "_AMD_" + cl->name();
- string absoluteAMDI = getAbsolute(cl, "", "_AMD_", "_" + name);
-
- vector<string> paramsAMD = getParamsAsyncCB(p, classPkg);
-
- {
- if(!open(absoluteAMD))
- {
- return;
- }
-
- Output& out = output();
-
- out << sp << nl << "public interface " << classNameAMD << '_' << name;
- out << sb;
- out << sp << nl << "void ice_response" << spar << paramsAMD << epar << ';';
- out << sp << nl << "void ice_exception(java.lang.Exception ex);";
- out << eb;
-
- close();
- }
-
- {
- if(!open(absoluteAMDI))
- {
- return;
- }
-
- Output& out = output();
-
- TypePtr ret = p->returnType();
-
- ParamDeclList outParams;
- ParamDeclList paramList = p->parameters();
- ParamDeclList::const_iterator pli;
- for(pli = paramList.begin(); pli != paramList.end(); ++pli)
- {
- if((*pli)->isOutParam())
- {
- outParams.push_back(*pli);
- }
- }
-
- ExceptionList throws = p->throws();
- throws.sort();
- throws.unique();
-
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
+ string classNameAMD = "AMD_" + cl->name();
+ string absoluteAMD = getAbsolute(cl, "", "AMD_", "_" + name);
+
+ string classNameAMDI = "_AMD_" + cl->name();
+ string absoluteAMDI = getAbsolute(cl, "", "_AMD_", "_" + name);
+
+ vector<string> paramsAMD = getParamsAsyncCB(p, classPkg);
+
+ {
+ if(!open(absoluteAMD))
+ {
+ return;
+ }
+
+ Output& out = output();
+
+ out << sp << nl << "public interface " << classNameAMD << '_' << name;
+ out << sb;
+ out << sp << nl << "void ice_response" << spar << paramsAMD << epar << ';';
+ out << sp << nl << "void ice_exception(java.lang.Exception ex);";
+ out << eb;
+
+ close();
+ }
+
+ {
+ if(!open(absoluteAMDI))
+ {
+ return;
+ }
+
+ Output& out = output();
+
+ TypePtr ret = p->returnType();
+
+ ParamDeclList outParams;
+ ParamDeclList paramList = p->parameters();
+ ParamDeclList::const_iterator pli;
+ for(pli = paramList.begin(); pli != paramList.end(); ++pli)
+ {
+ if((*pli)->isOutParam())
+ {
+ outParams.push_back(*pli);
+ }
+ }
+
+ ExceptionList throws = p->throws();
+ throws.sort();
+ throws.unique();
+
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
#if defined(__SUNPRO_CC)
- throws.sort(Slice::derivedToBaseCompare);
+ throws.sort(Slice::derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
- int iter;
+ int iter;
- out << sp << nl << "final class " << classNameAMDI << '_' << name
- << " extends IceInternal.IncomingAsync implements " << classNameAMD << '_' << name;
- out << sb;
+ out << sp << nl << "final class " << classNameAMDI << '_' << name
+ << " extends IceInternal.IncomingAsync implements " << classNameAMD << '_' << name;
+ out << sb;
- out << sp << nl << "public" << nl << classNameAMDI << '_' << name << "(IceInternal.Incoming in)";
- out << sb;
- out << nl << "super(in);";
- out << eb;
+ out << sp << nl << "public" << nl << classNameAMDI << '_' << name << "(IceInternal.Incoming in)";
+ out << sb;
+ out << nl << "super(in);";
+ out << eb;
- out << sp << nl << "public void" << nl << "ice_response" << spar << paramsAMD << epar;
- out << sb;
+ out << sp << nl << "public void" << nl << "ice_response" << spar << paramsAMD << epar;
+ out << sb;
iter = 0;
- if(ret || !outParams.empty())
- {
- out << nl << "try";
- out << sb;
- out << nl << "IceInternal.BasicStream __os = this.__os();";
- for(pli = outParams.begin(); pli != outParams.end(); ++pli)
- {
+ if(ret || !outParams.empty())
+ {
+ out << nl << "try";
+ out << sb;
+ out << nl << "IceInternal.BasicStream __os = this.__os();";
+ for(pli = outParams.begin(); pli != outParams.end(); ++pli)
+ {
StringList metaData = (*pli)->getMetaData();
- string typeS = typeToString((*pli)->type(), TypeModeIn, classPkg, metaData);
- writeMarshalUnmarshalCode(out, classPkg, (*pli)->type(), fixKwd((*pli)->name()), true, iter,
+ string typeS = typeToString((*pli)->type(), TypeModeIn, classPkg, metaData);
+ writeMarshalUnmarshalCode(out, classPkg, (*pli)->type(), fixKwd((*pli)->name()), true, iter,
false, metaData);
- }
- if(ret)
- {
- string retS = typeToString(ret, TypeModeIn, classPkg, opMetaData);
- writeMarshalUnmarshalCode(out, classPkg, ret, "__ret", true, iter, false, opMetaData);
- }
- if(p->returnsClasses())
- {
- out << nl << "__os.writePendingObjects();";
- }
- out << eb;
- out << nl << "catch(Ice.LocalException __ex)";
- out << sb;
- out << nl << "ice_exception(__ex);";
- out << eb;
- }
- out << nl << "__response(true);";
- out << eb;
-
- out << sp << nl << "public void" << nl << "ice_exception(java.lang.Exception ex)";
- out << sb;
- if(throws.empty())
- {
- out << nl << "__exception(ex);";
- }
- else
- {
- out << nl << "try";
- out << sb;
- out << nl << "throw ex;";
- out << eb;
- ExceptionList::const_iterator r;
- for(r = throws.begin(); r != throws.end(); ++r)
- {
- string exS = getAbsolute(*r, classPkg);
- out << nl << "catch(" << exS << " __ex)";
- out << sb;
- out << nl << "__os().writeUserException(__ex);";
- out << nl << "__response(false);";
- out << eb;
- }
- out << nl << "catch(java.lang.Exception __ex)";
- out << sb;
- out << nl << "__exception(__ex);";
- out << eb;
- }
- out << eb;
-
- out << eb;
-
- close();
- }
+ }
+ if(ret)
+ {
+ string retS = typeToString(ret, TypeModeIn, classPkg, opMetaData);
+ writeMarshalUnmarshalCode(out, classPkg, ret, "__ret", true, iter, false, opMetaData);
+ }
+ if(p->returnsClasses())
+ {
+ out << nl << "__os.writePendingObjects();";
+ }
+ out << eb;
+ out << nl << "catch(Ice.LocalException __ex)";
+ out << sb;
+ out << nl << "ice_exception(__ex);";
+ out << eb;
+ }
+ out << nl << "__response(true);";
+ out << eb;
+
+ out << sp << nl << "public void" << nl << "ice_exception(java.lang.Exception ex)";
+ out << sb;
+ if(throws.empty())
+ {
+ out << nl << "__exception(ex);";
+ }
+ else
+ {
+ out << nl << "try";
+ out << sb;
+ out << nl << "throw ex;";
+ out << eb;
+ ExceptionList::const_iterator r;
+ for(r = throws.begin(); r != throws.end(); ++r)
+ {
+ string exS = getAbsolute(*r, classPkg);
+ out << nl << "catch(" << exS << " __ex)";
+ out << sb;
+ out << nl << "__os().writeUserException(__ex);";
+ out << nl << "__response(false);";
+ out << eb;
+ }
+ out << nl << "catch(java.lang.Exception __ex)";
+ out << sb;
+ out << nl << "__exception(__ex);";
+ out << eb;
+ }
+ out << eb;
+
+ out << eb;
+
+ close();
+ }
}
}
diff --git a/cpp/src/slice2java/Gen.h b/cpp/src/slice2java/Gen.h
index 07cfd847a4c..8326dd115e3 100644
--- a/cpp/src/slice2java/Gen.h
+++ b/cpp/src/slice2java/Gen.h
@@ -98,7 +98,7 @@ private:
virtual bool visitClassDefStart(const ClassDefPtr&);
private:
- void writeOperations(const ClassDefPtr&, bool);
+ void writeOperations(const ClassDefPtr&, bool);
};
class TieVisitor : public JavaVisitor
@@ -137,11 +137,11 @@ private:
private:
- //
- // Verifies that a getter/setter method does not conflict with an operation.
- //
- bool validateGetterSetter(const OperationList&, const std::string&, int, const std::string&,
- const std::string&);
+ //
+ // Verifies that a getter/setter method does not conflict with an operation.
+ //
+ bool validateGetterSetter(const OperationList&, const std::string&, int, const std::string&,
+ const std::string&);
bool _stream;
};
diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp
index b2014f0e247..6daeac74c03 100644
--- a/cpp/src/slice2java/Main.cpp
+++ b/cpp/src/slice2java/Main.cpp
@@ -30,12 +30,12 @@ usage(const char* n)
"-DNAME=DEF Define NAME as DEF.\n"
"-UNAME Remove any definition for NAME.\n"
"-IDIR Put DIR in the include file search path.\n"
- "-E Print preprocessor output on stdout.\n"
+ "-E Print preprocessor output on stdout.\n"
"--output-dir DIR Create files in the directory DIR.\n"
"--tie Generate TIE classes.\n"
"--impl Generate sample implementations.\n"
"--impl-tie Generate sample TIE implementations.\n"
- "--depend Generate Makefile dependencies.\n"
+ "--depend Generate Makefile dependencies.\n"
"-d, --debug Print debug messages.\n"
"--ice Permit `Ice' prefix (for building Ice source code only)\n"
"--checksum CLASS Generate checksums for Slice definitions into CLASS.\n"
@@ -75,20 +75,20 @@ main(int argc, char* argv[])
catch(const IceUtil::BadOptException& e)
{
cerr << argv[0] << ": " << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(argv[0]);
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
string cppArgs;
@@ -96,19 +96,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D" + Preprocessor::addQuotes(*i);
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U" + Preprocessor::addQuotes(*i);
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I" + Preprocessor::addQuotes(*i);
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
@@ -157,101 +157,101 @@ main(int argc, char* argv[])
for(i = args.begin(); i != args.end(); ++i)
{
- if(depend)
- {
- Preprocessor icecpp(argv[0], *i, cppArgs);
- icecpp.printMakefileDependencies(Preprocessor::Java);
- }
- else
- {
- Preprocessor icecpp(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp.preprocess(false);
-
- if(cppHandle == 0)
- {
- return EXIT_FAILURE;
- }
-
- if(preprocess)
- {
- char buf[4096];
- while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
- {
- if(fputs(buf, stdout) == EOF)
- {
- return EXIT_FAILURE;
- }
- }
- if(!icecpp.close())
- {
- return EXIT_FAILURE;
- }
- }
- else
- {
- UnitPtr p = Unit::createUnit(false, false, ice, caseSensitive, globalMetadata);
- int parseStatus = p->parse(cppHandle, debug, Ice);
-
- if(!icecpp.close())
- {
- p->destroy();
- return EXIT_FAILURE;
- }
-
- if(parseStatus == EXIT_FAILURE)
- {
- status = EXIT_FAILURE;
- }
- else
- {
- Gen gen(argv[0], icecpp.getBaseName(), includePaths, output);
- if(!gen)
- {
- p->destroy();
- return EXIT_FAILURE;
- }
- gen.generate(p, stream);
- if(tie)
- {
- gen.generateTie(p);
- }
- if(impl)
- {
- gen.generateImpl(p);
- }
- if(implTie)
- {
- gen.generateImplTie(p);
- }
- if(!checksumClass.empty())
- {
- //
- // Calculate checksums for the Slice definitions in the unit.
- //
- ChecksumMap m = createChecksums(p);
- copy(m.begin(), m.end(), inserter(checksums, checksums.begin()));
- }
- }
- p->destroy();
- }
- }
+ if(depend)
+ {
+ Preprocessor icecpp(argv[0], *i, cppArgs);
+ icecpp.printMakefileDependencies(Preprocessor::Java);
+ }
+ else
+ {
+ Preprocessor icecpp(argv[0], *i, cppArgs);
+ FILE* cppHandle = icecpp.preprocess(false);
+
+ if(cppHandle == 0)
+ {
+ return EXIT_FAILURE;
+ }
+
+ if(preprocess)
+ {
+ char buf[4096];
+ while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
+ {
+ if(fputs(buf, stdout) == EOF)
+ {
+ return EXIT_FAILURE;
+ }
+ }
+ if(!icecpp.close())
+ {
+ return EXIT_FAILURE;
+ }
+ }
+ else
+ {
+ UnitPtr p = Unit::createUnit(false, false, ice, caseSensitive, globalMetadata);
+ int parseStatus = p->parse(cppHandle, debug, Ice);
+
+ if(!icecpp.close())
+ {
+ p->destroy();
+ return EXIT_FAILURE;
+ }
+
+ if(parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
+ else
+ {
+ Gen gen(argv[0], icecpp.getBaseName(), includePaths, output);
+ if(!gen)
+ {
+ p->destroy();
+ return EXIT_FAILURE;
+ }
+ gen.generate(p, stream);
+ if(tie)
+ {
+ gen.generateTie(p);
+ }
+ if(impl)
+ {
+ gen.generateImpl(p);
+ }
+ if(implTie)
+ {
+ gen.generateImplTie(p);
+ }
+ if(!checksumClass.empty())
+ {
+ //
+ // Calculate checksums for the Slice definitions in the unit.
+ //
+ ChecksumMap m = createChecksums(p);
+ copy(m.begin(), m.end(), inserter(checksums, checksums.begin()));
+ }
+ }
+ p->destroy();
+ }
+ }
}
if(!checksumClass.empty())
{
- //
- // Look for the Java2 metadata.
- //
- bool java2 = false;
- for(StringList::iterator p = globalMetadata.begin(); p != globalMetadata.end(); ++p)
- {
- if((*p) == "java:java2")
- {
- java2 = true;
- break;
- }
- }
- Gen::writeChecksumClass(checksumClass, output, checksums, java2);
+ //
+ // Look for the Java2 metadata.
+ //
+ bool java2 = false;
+ for(StringList::iterator p = globalMetadata.begin(); p != globalMetadata.end(); ++p)
+ {
+ if((*p) == "java:java2")
+ {
+ java2 = true;
+ break;
+ }
+ }
+ Gen::writeChecksumClass(checksumClass, output, checksums, java2);
}
return status;
diff --git a/cpp/src/slice2javae/Gen.cpp b/cpp/src/slice2javae/Gen.cpp
index 38f6cca5c5f..13e728b15cb 100644
--- a/cpp/src/slice2javae/Gen.cpp
+++ b/cpp/src/slice2javae/Gen.cpp
@@ -37,26 +37,26 @@ sliceModeToIceMode(Operation::Mode opMode)
string mode;
switch(opMode)
{
- case Operation::Normal:
- {
- mode = "Ice.OperationMode.Normal";
- break;
- }
- case Operation::Nonmutating:
- {
- mode = "Ice.OperationMode.Nonmutating";
- break;
- }
- case Operation::Idempotent:
- {
- mode = "Ice.OperationMode.Idempotent";
- break;
- }
- default:
- {
- assert(false);
- break;
- }
+ case Operation::Normal:
+ {
+ mode = "Ice.OperationMode.Normal";
+ break;
+ }
+ case Operation::Nonmutating:
+ {
+ mode = "Ice.OperationMode.Nonmutating";
+ break;
+ }
+ case Operation::Idempotent:
+ {
+ mode = "Ice.OperationMode.Idempotent";
+ break;
+ }
+ default:
+ {
+ assert(false);
+ break;
+ }
}
return mode;
}
@@ -120,7 +120,7 @@ Slice::JavaVisitor::getParams(const OperationPtr& op, const string& package)
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
StringList metaData = (*q)->getMetaData();
- string typeString = typeToString((*q)->type(), (*q)->isOutParam() ? TypeModeOut : TypeModeIn, package,
+ string typeString = typeToString((*q)->type(), (*q)->isOutParam() ? TypeModeOut : TypeModeIn, package,
metaData);
params.push_back(typeString + ' ' + fixKwd((*q)->name()));
}
@@ -155,12 +155,12 @@ Slice::JavaVisitor::writeThrowsClause(const string& package, const ExceptionList
int count = 0;
for(r = throws.begin(); r != throws.end(); ++r)
{
- if(count > 0)
- {
- out << "," << nl;
- }
- out << getAbsolute(*r, package);
- count++;
+ if(count > 0)
+ {
+ out << "," << nl;
+ }
+ out << getAbsolute(*r, package);
+ count++;
}
out.restoreIndent();
out.dec();
@@ -239,18 +239,18 @@ Slice::JavaVisitor::writeHashCode(Output& out, const TypePtr& type, const string
SequencePtr seq = SequencePtr::dynamicCast(type);
if(seq)
{
- out << nl << "if(" << name << " != null)";
- out << sb;
- 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;
+ out << nl << "if(" << name << " != null)";
+ out << sb;
+ 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);
@@ -284,15 +284,15 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
out << sb;
{
- StringList::const_iterator q = ids.begin();
- while(q != ids.end())
- {
- out << nl << '"' << *q << '"';
- if(++q != ids.end())
- {
- out << ',';
- }
- }
+ StringList::const_iterator q = ids.begin();
+ while(q != ids.end())
+ {
+ out << nl << '"' << *q << '"';
+ if(++q != ids.end())
+ {
+ out << ',';
+ }
+ }
}
out << eb << ';';
@@ -339,85 +339,85 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
//
for(r = ops.begin(); r != ops.end(); ++r)
{
- OperationPtr op = *r;
+ OperationPtr op = *r;
string opName = op->name();
ContainerPtr container = op->container();
ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- assert(cl);
-
- vector<string> params;
- vector<string> args;
- TypePtr ret;
-
- opName = fixKwd(opName);
- ret = op->returnType();
- params = getParams(op, package);
- args = getArgs(op);
-
- ExceptionList throws = op->throws();
- throws.sort();
- throws.unique();
-
- //
- // Only generate a "no current" version of the operation if it hasn't been done in a base
- // class already, because the "no current" version is final.
- //
- bool generateOperation = cl == p; // Generate if the operation is defined in this class.
- if(!generateOperation)
- {
- //
- // The operation is not defined in this class.
- //
- if(!bases.empty())
- {
- //
- // Check if the operation is already implemented by a base class.
- //
- bool implementedByBase = false;
- if(!bases.front()->isInterface())
- {
- OperationList baseOps = bases.front()->allOperations();
- OperationList::const_iterator i;
- for(i = baseOps.begin(); i != baseOps.end(); ++i)
- {
- if((*i)->name() == op->name())
- {
- implementedByBase = true;
- break;
- }
- }
- if(i == baseOps.end())
- {
- generateOperation = true;
- }
- }
- if(!generateOperation && !implementedByBase)
- {
- //
- // No base class defines the operation. Check if one of the
- // interfaces defines it, in which case this class must provide it.
- //
- if(bases.front()->isInterface() || bases.size() > 1)
- {
- generateOperation = true;
- }
- }
- }
- }
- if(generateOperation)
- {
- out << sp << nl << "public final " << typeToString(ret, TypeModeReturn, package, op->getMetaData())
- << nl << opName << spar << params << epar;
- writeThrowsClause(package, throws);
- out << sb << nl;
- if(ret)
- {
- out << nl << "return ";
- }
- out << opName << spar << args << "null" << epar << ';';
- out << eb;
- }
+ assert(cl);
+
+ vector<string> params;
+ vector<string> args;
+ TypePtr ret;
+
+ opName = fixKwd(opName);
+ ret = op->returnType();
+ params = getParams(op, package);
+ args = getArgs(op);
+
+ ExceptionList throws = op->throws();
+ throws.sort();
+ throws.unique();
+
+ //
+ // Only generate a "no current" version of the operation if it hasn't been done in a base
+ // class already, because the "no current" version is final.
+ //
+ bool generateOperation = cl == p; // Generate if the operation is defined in this class.
+ if(!generateOperation)
+ {
+ //
+ // The operation is not defined in this class.
+ //
+ if(!bases.empty())
+ {
+ //
+ // Check if the operation is already implemented by a base class.
+ //
+ bool implementedByBase = false;
+ if(!bases.front()->isInterface())
+ {
+ OperationList baseOps = bases.front()->allOperations();
+ OperationList::const_iterator i;
+ for(i = baseOps.begin(); i != baseOps.end(); ++i)
+ {
+ if((*i)->name() == op->name())
+ {
+ implementedByBase = true;
+ break;
+ }
+ }
+ if(i == baseOps.end())
+ {
+ generateOperation = true;
+ }
+ }
+ if(!generateOperation && !implementedByBase)
+ {
+ //
+ // No base class defines the operation. Check if one of the
+ // interfaces defines it, in which case this class must provide it.
+ //
+ if(bases.front()->isInterface() || bases.size() > 1)
+ {
+ generateOperation = true;
+ }
+ }
+ }
+ }
+ if(generateOperation)
+ {
+ out << sp << nl << "public final " << typeToString(ret, TypeModeReturn, package, op->getMetaData())
+ << nl << opName << spar << params << epar;
+ writeThrowsClause(package, throws);
+ out << sb << nl;
+ if(ret)
+ {
+ out << nl << "return ";
+ }
+ out << opName << spar << args << "null" << epar << ';';
+ out << eb;
+ }
}
//
@@ -432,157 +432,157 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
StringList opMetaData = op->getMetaData();
ContainerPtr container = op->container();
ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- assert(cl);
+ assert(cl);
string opName = op->name();
out << sp << nl << "public static IceInternal.DispatchStatus" << nl << "___" << opName << '(' << name
- << " __obj, IceInternal.Incoming __in, Ice.Current __current)";
+ << " __obj, IceInternal.Incoming __in, Ice.Current __current)";
out << sb;
- TypePtr ret = op->returnType();
-
- ParamDeclList inParams;
- ParamDeclList outParams;
- ParamDeclList paramList = op->parameters();
- ParamDeclList::const_iterator pli;
- for(pli = paramList.begin(); pli != paramList.end(); ++pli)
- {
- if((*pli)->isOutParam())
- {
- outParams.push_back(*pli);
- }
- else
- {
- inParams.push_back(*pli);
- }
- }
-
- ExceptionList throws = op->throws();
- throws.sort();
- throws.unique();
-
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
+ TypePtr ret = op->returnType();
+
+ ParamDeclList inParams;
+ ParamDeclList outParams;
+ ParamDeclList paramList = op->parameters();
+ ParamDeclList::const_iterator pli;
+ for(pli = paramList.begin(); pli != paramList.end(); ++pli)
+ {
+ if((*pli)->isOutParam())
+ {
+ outParams.push_back(*pli);
+ }
+ else
+ {
+ inParams.push_back(*pli);
+ }
+ }
+
+ ExceptionList throws = op->throws();
+ throws.sort();
+ throws.unique();
+
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
#if defined(__SUNPRO_CC)
- throws.sort(Slice::derivedToBaseCompare);
+ throws.sort(Slice::derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
- int iter;
-
- out << nl << "__checkMode(" << sliceModeToIceMode(op->mode()) << ", __current.mode);";
- if(!inParams.empty())
- {
- out << nl << "IceInternal.BasicStream __is = __in.is();";
- }
- if(!outParams.empty() || ret || !throws.empty())
- {
- out << nl << "IceInternal.BasicStream __os = __in.os();";
- }
-
- //
- // Unmarshal 'in' parameters.
- //
- iter = 0;
- for(pli = inParams.begin(); pli != inParams.end(); ++pli)
- {
+ int iter;
+
+ out << nl << "__checkMode(" << sliceModeToIceMode(op->mode()) << ", __current.mode);";
+ if(!inParams.empty())
+ {
+ out << nl << "IceInternal.BasicStream __is = __in.is();";
+ }
+ if(!outParams.empty() || ret || !throws.empty())
+ {
+ out << nl << "IceInternal.BasicStream __os = __in.os();";
+ }
+
+ //
+ // Unmarshal 'in' parameters.
+ //
+ iter = 0;
+ for(pli = inParams.begin(); pli != inParams.end(); ++pli)
+ {
StringList metaData = (*pli)->getMetaData();
TypePtr paramType = (*pli)->type();
string paramName = fixKwd((*pli)->name());
- string typeS = typeToString(paramType, TypeModeIn, package, metaData);
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType))
- {
- out << nl << typeS << "Holder " << paramName << " = new " << typeS << "Holder();";
- writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, true,
- metaData, string());
- }
- else
- {
- out << nl << typeS << ' ' << paramName << ';';
- writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, false, metaData);
- }
- }
-
- //
- // Create holders for 'out' parameters.
- //
- for(pli = outParams.begin(); pli != outParams.end(); ++pli)
- {
- string typeS = typeToString((*pli)->type(), TypeModeOut, package, (*pli)->getMetaData());
- out << nl << typeS << ' ' << fixKwd((*pli)->name()) << " = new " << typeS << "();";
- }
-
- //
- // Call on the servant.
- //
- if(!throws.empty())
- {
- out << nl << "try";
- out << sb;
- }
- out << nl;
- if(ret)
- {
- string retS = typeToString(ret, TypeModeReturn, package, opMetaData);
- out << retS << " __ret = ";
- }
- out << "__obj." << fixKwd(opName) << '(';
- for(pli = inParams.begin(); pli != inParams.end(); ++pli)
- {
+ string typeS = typeToString(paramType, TypeModeIn, package, metaData);
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType))
+ {
+ out << nl << typeS << "Holder " << paramName << " = new " << typeS << "Holder();";
+ writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, true,
+ metaData, string());
+ }
+ else
+ {
+ out << nl << typeS << ' ' << paramName << ';';
+ writeMarshalUnmarshalCode(out, package, paramType, paramName, false, iter, false, metaData);
+ }
+ }
+
+ //
+ // Create holders for 'out' parameters.
+ //
+ for(pli = outParams.begin(); pli != outParams.end(); ++pli)
+ {
+ string typeS = typeToString((*pli)->type(), TypeModeOut, package, (*pli)->getMetaData());
+ out << nl << typeS << ' ' << fixKwd((*pli)->name()) << " = new " << typeS << "();";
+ }
+
+ //
+ // Call on the servant.
+ //
+ if(!throws.empty())
+ {
+ out << nl << "try";
+ out << sb;
+ }
+ out << nl;
+ if(ret)
+ {
+ string retS = typeToString(ret, TypeModeReturn, package, opMetaData);
+ out << retS << " __ret = ";
+ }
+ out << "__obj." << fixKwd(opName) << '(';
+ for(pli = inParams.begin(); pli != inParams.end(); ++pli)
+ {
TypePtr paramType = (*pli)->type();
- out << fixKwd((*pli)->name());
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType))
- {
- out << ".value";
- }
- out << ", ";
- }
- for(pli = outParams.begin(); pli != outParams.end(); ++pli)
- {
- out << fixKwd((*pli)->name()) << ", ";
- }
- out << "__current);";
-
- //
- // Marshal 'out' parameters and return value.
- //
- for(pli = outParams.begin(); pli != outParams.end(); ++pli)
- {
- writeMarshalUnmarshalCode(out, package, (*pli)->type(), fixKwd((*pli)->name()), true, iter, true,
+ out << fixKwd((*pli)->name());
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(paramType);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(paramType))
+ {
+ out << ".value";
+ }
+ out << ", ";
+ }
+ for(pli = outParams.begin(); pli != outParams.end(); ++pli)
+ {
+ out << fixKwd((*pli)->name()) << ", ";
+ }
+ out << "__current);";
+
+ //
+ // Marshal 'out' parameters and return value.
+ //
+ for(pli = outParams.begin(); pli != outParams.end(); ++pli)
+ {
+ writeMarshalUnmarshalCode(out, package, (*pli)->type(), fixKwd((*pli)->name()), true, iter, true,
(*pli)->getMetaData());
- }
- if(ret)
- {
- writeMarshalUnmarshalCode(out, package, ret, "__ret", true, iter, false, opMetaData);
- }
- out << nl << "return IceInternal.DispatchStatus.DispatchOK;";
-
- //
- // Handle user exceptions.
- //
- if(!throws.empty())
- {
- out << eb;
- ExceptionList::const_iterator t;
- for(t = throws.begin(); t != throws.end(); ++t)
- {
- string exS = getAbsolute(*t, package);
- out << nl << "catch(" << exS << " ex)";
- out << sb;
- out << nl << "__os.writeUserException(ex);";
- out << nl << "return IceInternal.DispatchStatus.DispatchUserException;";
- out << eb;
- }
- }
-
- out << eb;
+ }
+ if(ret)
+ {
+ writeMarshalUnmarshalCode(out, package, ret, "__ret", true, iter, false, opMetaData);
+ }
+ out << nl << "return IceInternal.DispatchStatus.DispatchOK;";
+
+ //
+ // Handle user exceptions.
+ //
+ if(!throws.empty())
+ {
+ out << eb;
+ ExceptionList::const_iterator t;
+ for(t = throws.begin(); t != throws.end(); ++t)
+ {
+ string exS = getAbsolute(*t, package);
+ out << nl << "catch(" << exS << " ex)";
+ out << sb;
+ out << nl << "__os.writeUserException(ex);";
+ out << nl << "return IceInternal.DispatchStatus.DispatchUserException;";
+ out << eb;
+ }
+ }
+
+ out << eb;
}
OperationList allOps = p->allOperations();
@@ -613,7 +613,7 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
out << eb << ';';
out << sp << nl << "public IceInternal.DispatchStatus" << nl
- << "__dispatch(IceInternal.Incoming in, Ice.Current __current)";
+ << "__dispatch(IceInternal.Incoming in, Ice.Current __current)";
out << sb;
out << nl << "int pos = IceUtil.Arrays.search(__all, __current.operation);";
out << nl << "if(pos < 0)";
@@ -681,8 +681,8 @@ Slice::JavaVisitor::writeDispatch(Output& out, const ClassDefPtr& p)
out << eb;
}
out << eb;
- out << nl << "if(IceUtil.Debug.ASSERT)";
- out << sb;
+ out << nl << "if(IceUtil.Debug.ASSERT)";
+ out << sb;
out << sp << nl << "IceUtil.Debug.Assert(false);";
out << eb;
out << nl << "return IceInternal.DispatchStatus.DispatchOperationNotExist;";
@@ -773,7 +773,7 @@ Slice::Gen::OpsVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!p->isLocal())
{
- writeOperations(p, false);
+ writeOperations(p, false);
}
writeOperations(p, true);
@@ -789,7 +789,7 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent)
string opIntfName = "Operations";
if(noCurrent || p->isLocal())
{
- opIntfName += "NC";
+ opIntfName += "NC";
}
string absolute = getAbsolute(p, "", "_", opIntfName);
@@ -834,39 +834,39 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent)
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
- OperationPtr op = *r;
+ OperationPtr op = *r;
ContainerPtr container = op->container();
- ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- string opname = op->name();
-
- TypePtr ret;
- vector<string> params;
-
- params = getParams(op, package);
- ret = op->returnType();
-
- string deprecateReason = getDeprecateReason(op, p, "operation");
-
- string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData());
-
- ExceptionList throws = op->throws();
- throws.sort();
- throws.unique();
- out << sp;
- if(!deprecateReason.empty())
- {
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
- }
- out << nl << retS << ' ' << fixKwd(opname) << spar << params;
- if(!noCurrent && !p->isLocal())
- {
- out << "Ice.Current __current";
- }
- out << epar;
- writeThrowsClause(package, throws);
- out << ';';
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
+ string opname = op->name();
+
+ TypePtr ret;
+ vector<string> params;
+
+ params = getParams(op, package);
+ ret = op->returnType();
+
+ string deprecateReason = getDeprecateReason(op, p, "operation");
+
+ string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData());
+
+ ExceptionList throws = op->throws();
+ throws.sort();
+ throws.unique();
+ out << sp;
+ if(!deprecateReason.empty())
+ {
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
+ }
+ out << nl << retS << ' ' << fixKwd(opname) << spar << params;
+ if(!noCurrent && !p->isLocal())
+ {
+ out << "Ice.Current __current";
+ }
+ out << epar;
+ writeThrowsClause(package, throws);
+ out << ';';
}
out << eb;
@@ -964,18 +964,18 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
if(p->isLocal())
{
- out << sp << nl << "public java.lang.Object" << nl << "ice_clone()";
- out.inc();
- out << nl << "throws IceUtil.CloneException";
- out.dec();
- out << sb;
- out << sp << nl << "return new _" << name << "Tie(_ice_delegate);";
- out << eb;
+ out << sp << nl << "public java.lang.Object" << nl << "ice_clone()";
+ out.inc();
+ out << nl << "throws IceUtil.CloneException";
+ out.dec();
+ out << sb;
+ out << sp << nl << "return new _" << name << "Tie(_ice_delegate);";
+ out << eb;
out << sp << nl << "public int" << nl << "ice_hash()";
- out << sb;
- out << nl << "return hashCode();";
- out << eb;
+ out << sb;
+ out << nl << "return hashCode();";
+ out << eb;
}
out << sp << nl << "public int" << nl << "hashCode()";
@@ -987,16 +987,16 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
- ContainerPtr container = (*r)->container();
- ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
+ ContainerPtr container = (*r)->container();
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- string opName = fixKwd((*r)->name());
+ string opName = fixKwd((*r)->name());
TypePtr ret = (*r)->returnType();
string retS = typeToString(ret, TypeModeReturn, package, (*r)->getMetaData());
vector<string> params = getParams((*r), package);
- vector<string> args = getArgs(*r);
+ vector<string> args = getArgs(*r);
out << sp;
out << nl << "public " << retS << nl << opName << spar << params;
@@ -1084,7 +1084,7 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
ClassDefPtr baseClass;
if(!bases.empty() && !bases.front()->isInterface())
{
- baseClass = bases.front();
+ baseClass = bases.front();
}
string package = getPackage(p);
@@ -1115,15 +1115,15 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
{
out << "Ice.Object";
}
- out << "," << nl << '_' << name;
- if(!p->isLocal())
- {
- out << "Operations, _" << name << "OperationsNC";
- }
- else
- {
- out << "OperationsNC";
- }
+ out << "," << nl << '_' << name;
+ if(!p->isLocal())
+ {
+ out << "Operations, _" << name << "OperationsNC";
+ }
+ else
+ {
+ out << "OperationsNC";
+ }
if(!bases.empty())
{
ClassList::const_iterator q = bases.begin();
@@ -1168,10 +1168,10 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
StringList implements;
if(p->isAbstract())
{
- if(!p->isLocal())
- {
- implements.push_back("_" + name + "Operations");
- }
+ if(!p->isLocal())
+ {
+ implements.push_back("_" + name + "Operations");
+ }
implements.push_back("_" + name + "OperationsNC");
}
if(!bases.empty())
@@ -1210,49 +1210,49 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!p->isInterface() && !allDataMembers.empty())
{
- //
- // Constructors.
- //
- out << sp;
- out << nl << "public " << name << "()";
- out << sb;
- if(baseClass)
- {
- out << nl << "super();";
- }
- out << eb;
-
- out << sp << nl << "public " << name << spar;
- vector<string> paramDecl;
- for(d = allDataMembers.begin(); d != allDataMembers.end(); ++d)
- {
- string memberName = fixKwd((*d)->name());
- string memberType = typeToString((*d)->type(), TypeModeMember, package, (*d)->getMetaData());
- paramDecl.push_back(memberType + " " + memberName);
- }
- out << paramDecl << epar;
- out << sb;
- if(baseClass && allDataMembers.size() != members.size())
- {
- out << nl << "super" << spar;
- vector<string> baseParamNames;
- DataMemberList baseDataMembers = baseClass->allDataMembers();
- for(d = baseDataMembers.begin(); d != baseDataMembers.end(); ++d)
- {
- baseParamNames.push_back(fixKwd((*d)->name()));
- }
- out << baseParamNames << epar << ';';
- }
- vector<string> paramNames;
- for(d = members.begin(); d != members.end(); ++d)
- {
- paramNames.push_back(fixKwd((*d)->name()));
- }
- for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i)
- {
- out << nl << "this." << *i << " = " << *i << ';';
- }
- out << eb;
+ //
+ // Constructors.
+ //
+ out << sp;
+ out << nl << "public " << name << "()";
+ out << sb;
+ if(baseClass)
+ {
+ out << nl << "super();";
+ }
+ out << eb;
+
+ out << sp << nl << "public " << name << spar;
+ vector<string> paramDecl;
+ for(d = allDataMembers.begin(); d != allDataMembers.end(); ++d)
+ {
+ string memberName = fixKwd((*d)->name());
+ string memberType = typeToString((*d)->type(), TypeModeMember, package, (*d)->getMetaData());
+ paramDecl.push_back(memberType + " " + memberName);
+ }
+ out << paramDecl << epar;
+ out << sb;
+ if(baseClass && allDataMembers.size() != members.size())
+ {
+ out << nl << "super" << spar;
+ vector<string> baseParamNames;
+ DataMemberList baseDataMembers = baseClass->allDataMembers();
+ for(d = baseDataMembers.begin(); d != baseDataMembers.end(); ++d)
+ {
+ baseParamNames.push_back(fixKwd((*d)->name()));
+ }
+ out << baseParamNames << epar << ';';
+ }
+ vector<string> paramNames;
+ for(d = members.begin(); d != members.end(); ++d)
+ {
+ paramNames.push_back(fixKwd((*d)->name()));
+ }
+ for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i)
+ {
+ out << nl << "this." << *i << " = " << *i << ';';
+ }
+ out << eb;
}
//
@@ -1265,19 +1265,19 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!p->isInterface() && !members.empty())
{
- out << sp << nl << "protected void" << nl << "__copyFrom(java.lang.Object __obj)";
- out << sb;
- if(baseClass)
- {
- out << nl << "super.__copyFrom(__obj);";
- }
- out << nl << name << " __src = (" << name << ")__obj;";
- for(d = members.begin(); d != members.end(); ++d)
- {
- string memberName = fixKwd((*d)->name());
- out << nl << memberName << " = __src." << memberName << ";";
- }
- out << eb;
+ out << sp << nl << "protected void" << nl << "__copyFrom(java.lang.Object __obj)";
+ out << sb;
+ if(baseClass)
+ {
+ out << nl << "super.__copyFrom(__obj);";
+ }
+ out << nl << name << " __src = (" << name << ")__obj;";
+ for(d = members.begin(); d != members.end(); ++d)
+ {
+ string memberName = fixKwd((*d)->name());
+ out << nl << memberName << " = __src." << memberName << ";";
+ }
+ out << eb;
}
return true;
@@ -1315,9 +1315,9 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
string deprecateReason = getDeprecateReason(p, 0, "type");
if(!deprecateReason.empty())
{
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
}
out << nl << "public class " << name << " extends ";
@@ -1341,49 +1341,49 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
if(!allDataMembers.empty())
{
- //
- // Constructors.
- //
- out << sp;
- out << nl << "public " << name << "()";
- out << sb;
- if(base)
- {
- out << nl << "super();";
- }
- out << eb;
-
- out << sp << nl << "public " << name << spar;
- vector<string> paramDecl;
- for(d = allDataMembers.begin(); d != allDataMembers.end(); ++d)
- {
- string memberName = fixKwd((*d)->name());
- string memberType = typeToString((*d)->type(), TypeModeMember, package, (*d)->getMetaData());
- paramDecl.push_back(memberType + " " + memberName);
- }
- out << paramDecl << epar;
- out << sb;
- if(base && allDataMembers.size() != members.size())
- {
- out << nl << "super" << spar;
- vector<string> baseParamNames;
- DataMemberList baseDataMembers = base->allDataMembers();
- for(d = baseDataMembers.begin(); d != baseDataMembers.end(); ++d)
- {
- baseParamNames.push_back(fixKwd((*d)->name()));
- }
- out << baseParamNames << epar << ';';
- }
- vector<string> paramNames;
- for(d = members.begin(); d != members.end(); ++d)
- {
- paramNames.push_back(fixKwd((*d)->name()));
- }
- for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i)
- {
- out << nl << "this." << *i << " = " << *i << ';';
- }
- out << eb;
+ //
+ // Constructors.
+ //
+ out << sp;
+ out << nl << "public " << name << "()";
+ out << sb;
+ if(base)
+ {
+ out << nl << "super();";
+ }
+ out << eb;
+
+ out << sp << nl << "public " << name << spar;
+ vector<string> paramDecl;
+ for(d = allDataMembers.begin(); d != allDataMembers.end(); ++d)
+ {
+ string memberName = fixKwd((*d)->name());
+ string memberType = typeToString((*d)->type(), TypeModeMember, package, (*d)->getMetaData());
+ paramDecl.push_back(memberType + " " + memberName);
+ }
+ out << paramDecl << epar;
+ out << sb;
+ if(base && allDataMembers.size() != members.size())
+ {
+ out << nl << "super" << spar;
+ vector<string> baseParamNames;
+ DataMemberList baseDataMembers = base->allDataMembers();
+ for(d = baseDataMembers.begin(); d != baseDataMembers.end(); ++d)
+ {
+ baseParamNames.push_back(fixKwd((*d)->name()));
+ }
+ out << baseParamNames << epar << ';';
+ }
+ vector<string> paramNames;
+ for(d = members.begin(); d != members.end(); ++d)
+ {
+ paramNames.push_back(fixKwd((*d)->name()));
+ }
+ for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i)
+ {
+ out << nl << "this." << *i << " = " << *i << ';';
+ }
+ out << eb;
}
out << sp << nl << "public String" << nl << "ice_name()";
@@ -1412,105 +1412,105 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
out << sp << nl << "public void" << nl << "__write(IceInternal.BasicStream __os)";
out << sb;
- out << nl << "__os.writeString(\"" << scoped << "\");";
- out << nl << "__os.startWriteSlice();";
+ out << nl << "__os.writeString(\"" << scoped << "\");";
+ out << nl << "__os.startWriteSlice();";
iter = 0;
for(d = members.begin(); d != members.end(); ++d)
{
StringList metaData = (*d)->getMetaData();
writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), true, iter, false, metaData);
}
- out << nl << "__os.endWriteSlice();";
+ out << nl << "__os.endWriteSlice();";
if(base)
{
out << nl << "super.__write(__os);";
}
out << eb;
- DataMemberList allClassMembers = p->allClassDataMembers();
- if(allClassMembers.size() != 0)
- {
- out << sp << nl << "private class Patcher implements IceInternal.Patcher";
- out << sb;
- if(allClassMembers.size() > 1)
- {
- out << sp << nl << "Patcher(int member)";
- out << sb;
- out << nl << "__member = member;";
- out << eb;
- }
-
- out << sp << nl << "public void" << nl << "patch(Ice.Object v)";
- out << sb;
- if(allClassMembers.size() > 1)
- {
- out << nl << "switch(__member)";
- out << sb;
- }
- int memberCount = 0;
- for(d = allClassMembers.begin(); d != allClassMembers.end(); ++d)
- {
- if(allClassMembers.size() > 1)
- {
- out.dec();
- out << nl << "case " << memberCount << ":";
- out.inc();
- }
- if(allClassMembers.size() > 1)
- {
- out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";";
- }
- string memberName = fixKwd((*d)->name());
- string memberType = typeToString((*d)->type(), TypeModeMember, package);
- out << nl << memberName << " = (" << memberType << ")v;";
- if(allClassMembers.size() > 1)
- {
- out << nl << "break;";
- }
- memberCount++;
- }
- if(allClassMembers.size() > 1)
- {
- out << eb;
- }
- out << eb;
-
- out << sp << nl << "public String" << nl << "type()";
- out << sb;
- if(allClassMembers.size() > 1)
- {
- out << nl << "return __typeId;";
- }
- else
- {
- out << nl << "return \"" << (*allClassMembers.begin())->type()->typeId() << "\";";
- }
- out << eb;
-
- if(allClassMembers.size() > 1)
- {
- out << sp << nl << "private int __member;";
- out << nl << "private String __typeId;";
- }
- out << eb;
- }
+ DataMemberList allClassMembers = p->allClassDataMembers();
+ if(allClassMembers.size() != 0)
+ {
+ out << sp << nl << "private class Patcher implements IceInternal.Patcher";
+ out << sb;
+ if(allClassMembers.size() > 1)
+ {
+ out << sp << nl << "Patcher(int member)";
+ out << sb;
+ out << nl << "__member = member;";
+ out << eb;
+ }
+
+ out << sp << nl << "public void" << nl << "patch(Ice.Object v)";
+ out << sb;
+ if(allClassMembers.size() > 1)
+ {
+ out << nl << "switch(__member)";
+ out << sb;
+ }
+ int memberCount = 0;
+ for(d = allClassMembers.begin(); d != allClassMembers.end(); ++d)
+ {
+ if(allClassMembers.size() > 1)
+ {
+ out.dec();
+ out << nl << "case " << memberCount << ":";
+ out.inc();
+ }
+ if(allClassMembers.size() > 1)
+ {
+ out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";";
+ }
+ string memberName = fixKwd((*d)->name());
+ string memberType = typeToString((*d)->type(), TypeModeMember, package);
+ out << nl << memberName << " = (" << memberType << ")v;";
+ if(allClassMembers.size() > 1)
+ {
+ out << nl << "break;";
+ }
+ memberCount++;
+ }
+ if(allClassMembers.size() > 1)
+ {
+ out << eb;
+ }
+ out << eb;
+
+ out << sp << nl << "public String" << nl << "type()";
+ out << sb;
+ if(allClassMembers.size() > 1)
+ {
+ out << nl << "return __typeId;";
+ }
+ else
+ {
+ out << nl << "return \"" << (*allClassMembers.begin())->type()->typeId() << "\";";
+ }
+ out << eb;
+
+ if(allClassMembers.size() > 1)
+ {
+ out << sp << nl << "private int __member;";
+ out << nl << "private String __typeId;";
+ }
+ out << eb;
+ }
out << sp << nl << "public void" << nl << "__read(IceInternal.BasicStream __is, boolean __rid)";
out << sb;
- out << nl << "if(__rid)";
- out << sb;
- out << nl << "String myId = __is.readString();";
- out << eb;
- out << nl << "__is.startReadSlice();";
+ out << nl << "if(__rid)";
+ out << sb;
+ out << nl << "String myId = __is.readString();";
+ out << eb;
+ out << nl << "__is.startReadSlice();";
iter = 0;
- DataMemberList classMembers = p->classDataMembers();
+ DataMemberList classMembers = p->classDataMembers();
for(d = members.begin(); d != members.end(); ++d)
{
- ostringstream patchParams;
+ ostringstream patchParams;
StringList metaData = (*d)->getMetaData();
writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), false, iter, false, metaData,
- patchParams.str());
+ patchParams.str());
}
- out << nl << "__is.endReadSlice();";
+ out << nl << "__is.endReadSlice();";
if(base)
{
out << nl << "super.__read(__is, true);";
@@ -1541,9 +1541,9 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p)
string deprecateReason = getDeprecateReason(p, 0, "type");
if(!deprecateReason.empty())
{
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
}
out << nl << "public final class " << name;
@@ -1575,17 +1575,17 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
vector<string>::const_iterator q;
for(d = members.begin(); d != members.end(); ++d)
{
- string memberName = fixKwd((*d)->name());
- string memberType = typeToString((*d)->type(), TypeModeMember, package, (*d)->getMetaData());
- paramDecl.push_back(memberType + " " + memberName);
- paramNames.push_back(memberName);
+ string memberName = fixKwd((*d)->name());
+ string memberType = typeToString((*d)->type(), TypeModeMember, package, (*d)->getMetaData());
+ paramDecl.push_back(memberType + " " + memberName);
+ paramNames.push_back(memberName);
}
out << sp << nl << "public " << name << spar << paramDecl << epar;
out << sb;
for(q = paramNames.begin(); q != paramNames.end(); ++q)
{
- out << nl << "this." << *q << " = " << *q << ';';
+ out << nl << "this." << *q << " = " << *q << ';';
}
out << eb;
@@ -1650,10 +1650,10 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
SequencePtr seq = SequencePtr::dynamicCast((*d)->type());
if(seq)
{
- out << nl << "if(!IceUtil.Arrays.equals(" << memberName << ", _r." << memberName << "))";
- out << sb;
- out << nl << "return false;";
- out << eb;
+ out << nl << "if(!IceUtil.Arrays.equals(" << memberName << ", _r." << memberName << "))";
+ out << sb;
+ out << nl << "return false;";
+ out << eb;
}
else
{
@@ -1690,11 +1690,11 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
out << nl << "return new " << name << '(';
for(q = paramNames.begin(); q != paramNames.end(); ++q)
{
- if(q != paramNames.begin())
- {
- out << ", ";
- }
- out << *q;
+ if(q != paramNames.begin())
+ {
+ out << ", ";
+ }
+ out << *q;
}
out << ");";
out << eb;
@@ -1711,84 +1711,84 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
}
out << eb;
- DataMemberList classMembers = p->classDataMembers();
-
- if(classMembers.size() != 0)
- {
- out << sp << nl << "private class Patcher implements IceInternal.Patcher";
- out << sb;
- if(classMembers.size() > 1)
- {
- out << sp << nl << "Patcher(int member)";
- out << sb;
- out << nl << "__member = member;";
- out << eb;
- }
-
- out << sp << nl << "public void" << nl << "patch(Ice.Object v)";
- out << sb;
- if(classMembers.size() > 1)
- {
- out << nl << "switch(__member)";
- out << sb;
- }
- int memberCount = 0;
- for(d = classMembers.begin(); d != classMembers.end(); ++d)
- {
- if(classMembers.size() > 1)
- {
- out.dec();
- out << nl << "case " << memberCount << ":";
- out.inc();
- }
- if(classMembers.size() > 1)
- {
- out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";";
- }
- string memberName = fixKwd((*d)->name());
- string memberType = typeToString((*d)->type(), TypeModeMember, package);
- out << nl << memberName << " = (" << memberType << ")v;";
- if(classMembers.size() > 1)
- {
- out << nl << "break;";
- }
- memberCount++;
- }
- if(classMembers.size() > 1)
- {
- out << eb;
- }
- out << eb;
-
- out << sp << nl << "public String" << nl << "type()";
- out << sb;
- if(classMembers.size() > 1)
- {
- out << nl << "return __typeId;";
- }
- else
- {
- out << nl << "return \"" << (*classMembers.begin())->type()->typeId() << "\";";
- }
- out << eb;
-
- if(classMembers.size() > 1)
- {
- out << sp << nl << "private int __member;";
- out << nl << "private String __typeId;";
- }
- out << eb;
- }
+ DataMemberList classMembers = p->classDataMembers();
+
+ if(classMembers.size() != 0)
+ {
+ out << sp << nl << "private class Patcher implements IceInternal.Patcher";
+ out << sb;
+ if(classMembers.size() > 1)
+ {
+ out << sp << nl << "Patcher(int member)";
+ out << sb;
+ out << nl << "__member = member;";
+ out << eb;
+ }
+
+ out << sp << nl << "public void" << nl << "patch(Ice.Object v)";
+ out << sb;
+ if(classMembers.size() > 1)
+ {
+ out << nl << "switch(__member)";
+ out << sb;
+ }
+ int memberCount = 0;
+ for(d = classMembers.begin(); d != classMembers.end(); ++d)
+ {
+ if(classMembers.size() > 1)
+ {
+ out.dec();
+ out << nl << "case " << memberCount << ":";
+ out.inc();
+ }
+ if(classMembers.size() > 1)
+ {
+ out << nl << "__typeId = \"" << (*d)->type()->typeId() << "\";";
+ }
+ string memberName = fixKwd((*d)->name());
+ string memberType = typeToString((*d)->type(), TypeModeMember, package);
+ out << nl << memberName << " = (" << memberType << ")v;";
+ if(classMembers.size() > 1)
+ {
+ out << nl << "break;";
+ }
+ memberCount++;
+ }
+ if(classMembers.size() > 1)
+ {
+ out << eb;
+ }
+ out << eb;
+
+ out << sp << nl << "public String" << nl << "type()";
+ out << sb;
+ if(classMembers.size() > 1)
+ {
+ out << nl << "return __typeId;";
+ }
+ else
+ {
+ out << nl << "return \"" << (*classMembers.begin())->type()->typeId() << "\";";
+ }
+ out << eb;
+
+ if(classMembers.size() > 1)
+ {
+ out << sp << nl << "private int __member;";
+ out << nl << "private String __typeId;";
+ }
+ out << eb;
+ }
out << sp << nl << "public void" << nl << "__read(IceInternal.BasicStream __is)";
out << sb;
iter = 0;
for(d = members.begin(); d != members.end(); ++d)
{
- ostringstream patchParams;
+ ostringstream patchParams;
StringList metaData = (*d)->getMetaData();
writeMarshalUnmarshalCode(out, package, (*d)->type(), fixKwd((*d)->name()), false, iter, false, metaData,
- patchParams.str());
+ patchParams.str());
}
out << eb;
}
@@ -1812,9 +1812,9 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
string deprecateReason = getDeprecateReason(p, contained, "member");
if(!deprecateReason.empty())
{
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
}
out << nl << "public " << s << ' ' << name << ';';
}
@@ -1840,9 +1840,9 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
string deprecateReason = getDeprecateReason(p, 0, "type");
if(!deprecateReason.empty())
{
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
}
out << nl << "public final class " << name;
@@ -1856,7 +1856,7 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
string member = fixKwd((*en)->name());
out << nl << "public static final int _" << member << " = " << n << ';';
out << nl << "public static final " << name << ' ' << fixKwd(member)
- << " = new " << name << "(_" << member << ");";
+ << " = new " << name << "(_" << member << ");";
}
out << sp << nl << "public static " << name << nl << "convert(int val)";
@@ -1962,76 +1962,76 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
EnumPtr ep;
if(bp = BuiltinPtr::dynamicCast(type))
{
- switch(bp->kind())
- {
- case Builtin::KindString:
- {
- out << "\"";
-
- const string val = p->value();
- for(string::const_iterator c = val.begin(); c != val.end(); ++c)
- {
- if(isascii(*c) && isprint(*c))
- {
- switch(*c)
- {
- case '\\':
- case '"':
- {
- out << "\\";
- break;
- }
- }
- out << *c;
- }
- else
- {
- switch(*c)
- {
- case '\r':
- {
- out << "\\r";
- break;
- }
- case '\n':
- {
- out << "\\n";
- break;
- }
- default:
- {
- unsigned char uc = *c;
- ostringstream s;
- s << "\\u";
- s.flags(ios_base::hex);
- s.width(4);
- s.fill('0');
- s << static_cast<unsigned>(uc);
- out << s.str();
- break;
- }
- }
- }
- }
-
- out << "\"";
- break;
- }
- case Builtin::KindByte:
- {
- int i = atoi(p->value().c_str());
- if(i > 127)
- {
- i -= 256;
- }
- out << i; // Slice byte runs from 0-255, Java byte runs from -128 - 127.
- break;
- }
- case Builtin::KindLong:
- {
- out << p->value() << "L"; // Need to append "L" modifier for long constants.
- break;
- }
+ switch(bp->kind())
+ {
+ case Builtin::KindString:
+ {
+ out << "\"";
+
+ const string val = p->value();
+ for(string::const_iterator c = val.begin(); c != val.end(); ++c)
+ {
+ if(isascii(*c) && isprint(*c))
+ {
+ switch(*c)
+ {
+ case '\\':
+ case '"':
+ {
+ out << "\\";
+ break;
+ }
+ }
+ out << *c;
+ }
+ else
+ {
+ switch(*c)
+ {
+ case '\r':
+ {
+ out << "\\r";
+ break;
+ }
+ case '\n':
+ {
+ out << "\\n";
+ break;
+ }
+ default:
+ {
+ unsigned char uc = *c;
+ ostringstream s;
+ s << "\\u";
+ s.flags(ios_base::hex);
+ s.width(4);
+ s.fill('0');
+ s << static_cast<unsigned>(uc);
+ out << s.str();
+ break;
+ }
+ }
+ }
+ }
+
+ out << "\"";
+ break;
+ }
+ case Builtin::KindByte:
+ {
+ int i = atoi(p->value().c_str());
+ if(i > 127)
+ {
+ i -= 256;
+ }
+ out << i; // Slice byte runs from 0-255, Java byte runs from -128 - 127.
+ break;
+ }
+ case Builtin::KindLong:
+ {
+ out << p->value() << "L"; // Need to append "L" modifier for long constants.
+ break;
+ }
case Builtin::KindBool:
case Builtin::KindShort:
case Builtin::KindInt:
@@ -2040,11 +2040,11 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
case Builtin::KindObject:
case Builtin::KindObjectProxy:
case Builtin::KindLocalObject:
- {
- out << p->value();
+ {
+ out << p->value();
break;
- }
- }
+ }
+ }
}
else if(ep = EnumPtr::dynamicCast(type))
@@ -2055,11 +2055,11 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
{
val.erase(0, pos + 1);
}
- out << getAbsolute(ep, package) << '.' << fixKwd(val);
+ out << getAbsolute(ep, package) << '.' << fixKwd(val);
}
else
{
- out << p->value();
+ out << p->value();
}
out << ';' << eb;
close();
@@ -2200,12 +2200,12 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
{
OperationPtr op = *r;
StringList opMetaData = op->getMetaData();
- ContainerPtr container = op->container();
- ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
+ ContainerPtr container = op->container();
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
string opName = fixKwd(op->name());
TypePtr ret = op->returnType();
string retS = typeToString(ret, TypeModeReturn, package, op->getMetaData());
- int iter;
+ int iter;
vector<string> params = getParams(op, package);
vector<string> args = getArgs(op);
@@ -2253,14 +2253,14 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << nl << "int __cnt = 0;";
out << nl << "while(true)";
out << sb;
- out << nl << "Ice.Connection __connection = null;";
+ out << nl << "Ice.Connection __connection = null;";
out << nl << "try";
out << sb;
- if(op->returnsData())
- {
- out << nl << "__checkTwowayOnly(\"" << opName << "\");";
- }
- out << nl << "__connection = ice_getConnection();";
+ if(op->returnsData())
+ {
+ out << nl << "__checkTwowayOnly(\"" << opName << "\");";
+ }
+ out << nl << "__connection = ice_getConnection();";
out << nl << "IceInternal.Outgoing __og = __connection.getOutgoing(_reference, \"" << op->name() << "\", "
<< sliceModeToIceMode(op->sendMode()) << ", __ctx);";
out << nl << "try";
@@ -2330,10 +2330,10 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sb;
out << nl << "__connection.reclaimOutgoing(__og);";
out << eb;
- if(!ret)
- {
+ if(!ret)
+ {
out << nl << "return ;";
- }
+ }
out << eb;
out << nl << "catch(IceInternal.LocalExceptionWrapper __ex)";
out << sb;
@@ -2532,7 +2532,7 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p)
out << sb;
out << nl << typeS << " __v;";
iter = 0;
- writeSequenceMarshalUnmarshalCode(out, package, p, "__v", false, iter, false);
+ writeSequenceMarshalUnmarshalCode(out, package, p, "__v", false, iter, false);
out << nl << "return __v;";
out << eb;
@@ -2583,8 +2583,8 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
out << nl << "java.util.Enumeration __i = __v.keys();";
out << nl << "while(__i.hasMoreElements())";
out << sb;
- out << nl << "java.lang.Object key = __i.nextElement();";
- out << nl << "java.lang.Object value = __v.get(key);";
+ out << nl << "java.lang.Object key = __i.nextElement();";
+ out << nl << "java.lang.Object value = __v.get(key);";
iter = 0;
for(i = 0; i < 2; i++)
{
@@ -2648,7 +2648,7 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
break;
}
- case Builtin::KindObject:
+ case Builtin::KindObject:
case Builtin::KindLocalObject:
{
assert(false);
@@ -2670,9 +2670,9 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
out << sp << nl << "public static java.util.Hashtable";
out << nl << "read(IceInternal.BasicStream __is)";
out << sb;
- //
- // JDK 1.1 raises IllegalArgumentException if you pass 0 to the Hashtable constructor.
- //
+ //
+ // JDK 1.1 raises IllegalArgumentException if you pass 0 to the Hashtable constructor.
+ //
out << nl << "int __sz = __is.readSize();";
out << nl << "java.util.Hashtable __r = new java.util.Hashtable(__sz == 0 ? 1 : __sz);";
out << nl << "for(int __i = 0; __i < __sz; __i++)";
@@ -2754,11 +2754,11 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
else
{
string s = typeToString(type, TypeModeIn, package);
- out << nl << s << ' ' << arg << ';';
- writeMarshalUnmarshalCode(out, package, type, arg, false, iter, false);
+ out << nl << s << ' ' << arg << ';';
+ writeMarshalUnmarshalCode(out, package, type, arg, false, iter, false);
}
}
- out << nl << "__r.put(__key, __value);";
+ out << nl << "__r.put(__key, __value);";
out << eb;
out << nl << "return __r;";
out << eb;
@@ -2860,18 +2860,18 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
out << sp;
if(!deprecateReason.empty())
{
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
}
out << nl << "public " << retS << ' ' << name << spar << params << epar;
writeThrowsClause(package, throws);
out << ';';
if(!deprecateReason.empty())
{
- out << nl << "/**";
- out << nl << " * @deprecated " << deprecateReason;
- out << nl << " **/";
+ out << nl << "/**";
+ out << nl << " * @deprecated " << deprecateReason;
+ out << nl << " **/";
}
out << nl << "public " << retS << ' ' << name << spar << params << "java.util.Hashtable __ctx" << epar;
writeThrowsClause(package, throws);
@@ -3046,10 +3046,10 @@ Slice::Gen::BaseImplVisitor::writeReturn(Output& out, const TypePtr& type)
break;
}
case Builtin::KindObject:
- {
- cerr << "Ice objects cannot be returned by value in IceE." << endl;
- break;
- }
+ {
+ cerr << "Ice objects cannot be returned by value in IceE." << endl;
+ break;
+ }
}
return;
}
@@ -3194,15 +3194,15 @@ Slice::Gen::ImplTieVisitor::visitClassDefStart(const ClassDefPtr& p)
out << sp << nl << "public class " << name << 'I';
if(inheritImpl)
{
- out << " extends ";
+ out << " extends ";
if(bases.front()->isAbstract())
- {
- out << bases.front()->name() << 'I';
- }
- else
- {
- out << fixKwd(bases.front()->name());
- }
+ {
+ out << bases.front()->name() << 'I';
+ }
+ else
+ {
+ out << fixKwd(bases.front()->name());
+ }
}
out << " implements " << '_' << name << "Operations";
if(p->isLocal())
diff --git a/cpp/src/slice2javae/Gen.h b/cpp/src/slice2javae/Gen.h
index f61fcee5f9e..667847b5164 100644
--- a/cpp/src/slice2javae/Gen.h
+++ b/cpp/src/slice2javae/Gen.h
@@ -99,7 +99,7 @@ private:
virtual bool visitClassDefStart(const ClassDefPtr&);
private:
- void writeOperations(const ClassDefPtr&, bool);
+ void writeOperations(const ClassDefPtr&, bool);
};
class TieVisitor : public JavaVisitor
diff --git a/cpp/src/slice2javae/Main.cpp b/cpp/src/slice2javae/Main.cpp
index d47d6d0b054..a431e9f5865 100644
--- a/cpp/src/slice2javae/Main.cpp
+++ b/cpp/src/slice2javae/Main.cpp
@@ -26,12 +26,12 @@ usage(const char* n)
"-DNAME=DEF Define NAME as DEF.\n"
"-UNAME Remove any definition for NAME.\n"
"-IDIR Put DIR in the include file search path.\n"
- "-E Print preprocessor output on stdout.\n"
+ "-E Print preprocessor output on stdout.\n"
"--output-dir DIR Create files in the directory DIR.\n"
"--tie Generate TIE classes.\n"
"--impl Generate sample implementations.\n"
"--impl-tie Generate sample TIE implementations.\n"
- "--depend Generate Makefile dependencies.\n"
+ "--depend Generate Makefile dependencies.\n"
"-d, --debug Print debug messages.\n"
"--ice Permit `Ice' prefix (for building Ice source code only)\n"
;
@@ -65,20 +65,20 @@ main(int argc, char* argv[])
catch(const IceUtil::BadOptException& e)
{
cerr << argv[0] << ": " << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(argv[0]);
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICEE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICEE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
string cppArgs;
@@ -86,19 +86,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D" + Preprocessor::addQuotes(*i);
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U" + Preprocessor::addQuotes(*i);
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I" + Preprocessor::addQuotes(*i);
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
@@ -137,76 +137,76 @@ main(int argc, char* argv[])
for(i = args.begin(); i != args.end(); ++i)
{
- if(depend)
- {
- Preprocessor icecpp(argv[0], *i, cppArgs);
- icecpp.printMakefileDependencies(Preprocessor::Java);
- }
- else
- {
- Preprocessor icecpp(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp.preprocess(false);
-
- if(cppHandle == 0)
- {
- return EXIT_FAILURE;
- }
-
- if(preprocess)
- {
- char buf[4096];
- while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
- {
- if(fputs(buf, stdout) == EOF)
- {
- return EXIT_FAILURE;
- }
- }
- if(!icecpp.close())
- {
- return EXIT_FAILURE;
- }
- }
- else
- {
- UnitPtr p = Unit::createUnit(false, false, ice, caseSensitive);
- int parseStatus = p->parse(cppHandle, debug, Slice::IceE);
-
- if(!icecpp.close())
- {
- p->destroy();
- return EXIT_FAILURE;
- }
-
- if(parseStatus == EXIT_FAILURE)
- {
- status = EXIT_FAILURE;
- }
- else
- {
- Gen gen(argv[0], icecpp.getBaseName(), includePaths, output);
- if(!gen)
- {
- p->destroy();
- return EXIT_FAILURE;
- }
- gen.generate(p);
- if(tie)
- {
- gen.generateTie(p);
- }
- if(impl)
- {
- gen.generateImpl(p);
- }
- if(implTie)
- {
- gen.generateImplTie(p);
- }
- }
- p->destroy();
- }
- }
+ if(depend)
+ {
+ Preprocessor icecpp(argv[0], *i, cppArgs);
+ icecpp.printMakefileDependencies(Preprocessor::Java);
+ }
+ else
+ {
+ Preprocessor icecpp(argv[0], *i, cppArgs);
+ FILE* cppHandle = icecpp.preprocess(false);
+
+ if(cppHandle == 0)
+ {
+ return EXIT_FAILURE;
+ }
+
+ if(preprocess)
+ {
+ char buf[4096];
+ while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
+ {
+ if(fputs(buf, stdout) == EOF)
+ {
+ return EXIT_FAILURE;
+ }
+ }
+ if(!icecpp.close())
+ {
+ return EXIT_FAILURE;
+ }
+ }
+ else
+ {
+ UnitPtr p = Unit::createUnit(false, false, ice, caseSensitive);
+ int parseStatus = p->parse(cppHandle, debug, Slice::IceE);
+
+ if(!icecpp.close())
+ {
+ p->destroy();
+ return EXIT_FAILURE;
+ }
+
+ if(parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
+ else
+ {
+ Gen gen(argv[0], icecpp.getBaseName(), includePaths, output);
+ if(!gen)
+ {
+ p->destroy();
+ return EXIT_FAILURE;
+ }
+ gen.generate(p);
+ if(tie)
+ {
+ gen.generateTie(p);
+ }
+ if(impl)
+ {
+ gen.generateImpl(p);
+ }
+ if(implTie)
+ {
+ gen.generateImplTie(p);
+ }
+ }
+ p->destroy();
+ }
+ }
}
return status;
diff --git a/cpp/src/slice2py/Main.cpp b/cpp/src/slice2py/Main.cpp
index dcb1fd7b5d4..c0ff6b7dce0 100644
--- a/cpp/src/slice2py/Main.cpp
+++ b/cpp/src/slice2py/Main.cpp
@@ -369,7 +369,7 @@ usage(const char* n)
"-DNAME=DEF Define NAME as DEF.\n"
"-UNAME Remove any definition for NAME.\n"
"-IDIR Put DIR in the include file search path.\n"
- "-E Print preprocessor output on stdout.\n"
+ "-E Print preprocessor output on stdout.\n"
"--output-dir DIR Create files in the directory DIR.\n"
"-d, --debug Print debug messages.\n"
"--ice Permit `Ice' prefix (for building Ice source code only)\n"
@@ -407,21 +407,21 @@ main(int argc, char* argv[])
}
catch(const IceUtil::BadOptException& e)
{
- cerr << argv[0] << ": " << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": " << e.reason << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(argv[0]);
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
string cppArgs;
@@ -429,19 +429,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D" + Preprocessor::addQuotes(*i);
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U" + Preprocessor::addQuotes(*i);
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I" + Preprocessor::addQuotes(*i);
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
@@ -481,86 +481,86 @@ main(int argc, char* argv[])
return EXIT_FAILURE;
}
- if(preprocess)
- {
- char buf[4096];
- while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
- {
- if(fputs(buf, stdout) == EOF)
- {
- return EXIT_FAILURE;
- }
- }
- if(!icecpp.close())
- {
- return EXIT_FAILURE;
- }
- }
- else
- {
- UnitPtr u = Unit::createUnit(false, all, ice, caseSensitive);
- int parseStatus = u->parse(cppHandle, debug);
-
- if(!icecpp.close())
- {
- u->destroy();
- return EXIT_FAILURE;
- }
-
- if(parseStatus == EXIT_FAILURE)
- {
- status = EXIT_FAILURE;
- }
- else
- {
- string base = icecpp.getBaseName();
- string::size_type pos = base.find_last_of("/\\");
- if(pos != string::npos)
- {
- base.erase(0, pos + 1);
- }
-
- //
- // Append the suffix "_ice" to the filename in order to avoid any conflicts
- // with Slice module names. For example, if the file Test.ice defines a
- // Slice module named "Test", then we couldn't create a Python package named
- // "Test" and also call the generated file "Test.py".
- //
- string file = prefix + base + "_ice.py";
- if(!output.empty())
- {
- file = output + '/' + file;
- }
-
- IceUtil::Output out;
- out.open(file.c_str());
- if(!out)
- {
- cerr << argv[0] << ": can't open `" << file << "' for writing" << endl;
- u->destroy();
- return EXIT_FAILURE;
- }
-
- printHeader(out);
- out << "\n# Generated from file `" << base << ".ice'\n";
-
- //
- // Generate the Python mapping.
- //
- generate(u, all, checksum, includePaths, out);
-
- //
- // Create or update the Python package hierarchy.
- //
- if(!noPackage)
- {
- PackageVisitor visitor(argv[0], prefix + base + "_ice", output);
- u->visit(&visitor, false);
- }
- }
-
- u->destroy();
- }
+ if(preprocess)
+ {
+ char buf[4096];
+ while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
+ {
+ if(fputs(buf, stdout) == EOF)
+ {
+ return EXIT_FAILURE;
+ }
+ }
+ if(!icecpp.close())
+ {
+ return EXIT_FAILURE;
+ }
+ }
+ else
+ {
+ UnitPtr u = Unit::createUnit(false, all, ice, caseSensitive);
+ int parseStatus = u->parse(cppHandle, debug);
+
+ if(!icecpp.close())
+ {
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+
+ if(parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
+ else
+ {
+ string base = icecpp.getBaseName();
+ string::size_type pos = base.find_last_of("/\\");
+ if(pos != string::npos)
+ {
+ base.erase(0, pos + 1);
+ }
+
+ //
+ // Append the suffix "_ice" to the filename in order to avoid any conflicts
+ // with Slice module names. For example, if the file Test.ice defines a
+ // Slice module named "Test", then we couldn't create a Python package named
+ // "Test" and also call the generated file "Test.py".
+ //
+ string file = prefix + base + "_ice.py";
+ if(!output.empty())
+ {
+ file = output + '/' + file;
+ }
+
+ IceUtil::Output out;
+ out.open(file.c_str());
+ if(!out)
+ {
+ cerr << argv[0] << ": can't open `" << file << "' for writing" << endl;
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+
+ printHeader(out);
+ out << "\n# Generated from file `" << base << ".ice'\n";
+
+ //
+ // Generate the Python mapping.
+ //
+ generate(u, all, checksum, includePaths, out);
+
+ //
+ // Create or update the Python package hierarchy.
+ //
+ if(!noPackage)
+ {
+ PackageVisitor visitor(argv[0], prefix + base + "_ice", output);
+ u->visit(&visitor, false);
+ }
+ }
+
+ u->destroy();
+ }
}
return status;
diff --git a/cpp/src/slice2rb/Main.cpp b/cpp/src/slice2rb/Main.cpp
index 7025196520b..47867199325 100644
--- a/cpp/src/slice2rb/Main.cpp
+++ b/cpp/src/slice2rb/Main.cpp
@@ -41,7 +41,7 @@ usage(const char* n)
"-DNAME=DEF Define NAME as DEF.\n"
"-UNAME Remove any definition for NAME.\n"
"-IDIR Put DIR in the include file search path.\n"
- "-E Print preprocessor output on stdout.\n"
+ "-E Print preprocessor output on stdout.\n"
"--output-dir DIR Create files in the directory DIR.\n"
"-d, --debug Print debug messages.\n"
"--ice Permit `Ice' prefix (for building Ice source code only)\n"
@@ -75,21 +75,21 @@ main(int argc, char* argv[])
}
catch(const IceUtil::BadOptException& e)
{
- cerr << argv[0] << ": " << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ cerr << argv[0] << ": " << e.reason << endl;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(argv[0]);
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
string cppArgs;
@@ -97,19 +97,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D" + *i;
+ cppArgs += " -D" + *i;
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U" + *i;
+ cppArgs += " -U" + *i;
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I" + *i;
+ cppArgs += " -I" + *i;
}
bool preprocess = opts.isSet("E");
@@ -145,71 +145,71 @@ main(int argc, char* argv[])
return EXIT_FAILURE;
}
- if(preprocess)
- {
- char buf[4096];
- while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
- {
- if(fputs(buf, stdout) == EOF)
- {
- return EXIT_FAILURE;
- }
- }
- if(!icecpp.close())
- {
- return EXIT_FAILURE;
- }
- }
- else
- {
- UnitPtr u = Unit::createUnit(false, all, ice, caseSensitive);
- int parseStatus = u->parse(cppHandle, debug);
-
- if(!icecpp.close())
- {
- u->destroy();
- return EXIT_FAILURE;
- }
-
- if(parseStatus == EXIT_FAILURE)
- {
- status = EXIT_FAILURE;
- }
- else
- {
- string base = icecpp.getBaseName();
- string::size_type pos = base.find_last_of("/\\");
- if(pos != string::npos)
- {
- base.erase(0, pos + 1);
- }
-
- string file = base + ".rb";
- if(!output.empty())
- {
- file = output + '/' + file;
- }
-
- IceUtil::Output out;
- out.open(file.c_str());
- if(!out)
- {
- cerr << argv[0] << ": can't open `" << file << "' for writing" << endl;
- u->destroy();
- return EXIT_FAILURE;
- }
-
- printHeader(out);
- out << "\n# Generated from file `" << base << ".ice'\n";
-
- //
- // Generate the Ruby mapping.
- //
- generate(u, all, checksum, includePaths, out);
- }
-
- u->destroy();
- }
+ if(preprocess)
+ {
+ char buf[4096];
+ while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
+ {
+ if(fputs(buf, stdout) == EOF)
+ {
+ return EXIT_FAILURE;
+ }
+ }
+ if(!icecpp.close())
+ {
+ return EXIT_FAILURE;
+ }
+ }
+ else
+ {
+ UnitPtr u = Unit::createUnit(false, all, ice, caseSensitive);
+ int parseStatus = u->parse(cppHandle, debug);
+
+ if(!icecpp.close())
+ {
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+
+ if(parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
+ else
+ {
+ string base = icecpp.getBaseName();
+ string::size_type pos = base.find_last_of("/\\");
+ if(pos != string::npos)
+ {
+ base.erase(0, pos + 1);
+ }
+
+ string file = base + ".rb";
+ if(!output.empty())
+ {
+ file = output + '/' + file;
+ }
+
+ IceUtil::Output out;
+ out.open(file.c_str());
+ if(!out)
+ {
+ cerr << argv[0] << ": can't open `" << file << "' for writing" << endl;
+ u->destroy();
+ return EXIT_FAILURE;
+ }
+
+ printHeader(out);
+ out << "\n# Generated from file `" << base << ".ice'\n";
+
+ //
+ // Generate the Ruby mapping.
+ //
+ generate(u, all, checksum, includePaths, out);
+ }
+
+ u->destroy();
+ }
}
return status;
diff --git a/cpp/src/slice2vb/Gen.cpp b/cpp/src/slice2vb/Gen.cpp
index cab9cb3918a..2b2be18c899 100755
--- a/cpp/src/slice2vb/Gen.cpp
+++ b/cpp/src/slice2vb/Gen.cpp
@@ -43,26 +43,26 @@ sliceModeToIceMode(Operation::Mode opMode)
string mode;
switch(opMode)
{
- case Operation::Normal:
- {
- mode = "Ice.OperationMode.Normal";
- break;
- }
- case Operation::Nonmutating:
- {
- mode = "Ice.OperationMode.Nonmutating";
- break;
- }
- case Operation::Idempotent:
- {
- mode = "Ice.OperationMode.Idempotent";
- break;
- }
- default:
- {
- assert(false);
- break;
- }
+ case Operation::Normal:
+ {
+ mode = "Ice.OperationMode.Normal";
+ break;
+ }
+ case Operation::Nonmutating:
+ {
+ mode = "Ice.OperationMode.Nonmutating";
+ break;
+ }
+ case Operation::Idempotent:
+ {
+ mode = "Ice.OperationMode.Idempotent";
+ break;
+ }
+ default:
+ {
+ assert(false);
+ break;
+ }
}
return mode;
}
@@ -74,12 +74,12 @@ emitDeprecate(const ContainedPtr& p1, const ContainedPtr& p2, Output& out, strin
if(p1->findMetaData("deprecate", deprecateMetadata) ||
(p2 != 0 && p2->findMetaData("deprecate", deprecateMetadata)))
{
- string deprecateReason = "This " + type + " has been deprecated.";
- if(deprecateMetadata.find("deprecate:") == 0 && deprecateMetadata.size() > 10)
- {
- deprecateReason = deprecateMetadata.substr(10);
- }
- out << nl << "<System.Obsolete(\"" << deprecateReason << "\")>";
+ string deprecateReason = "This " + type + " has been deprecated.";
+ if(deprecateMetadata.find("deprecate:") == 0 && deprecateMetadata.size() > 10)
+ {
+ deprecateReason = deprecateMetadata.substr(10);
+ }
+ out << nl << "<System.Obsolete(\"" << deprecateReason << "\")>";
}
}
@@ -97,92 +97,92 @@ Slice::VbVisitor::writeInheritedOperations(const ClassDefPtr& p)
ClassList bases = p->bases();
if(!bases.empty() && !bases.front()->isInterface())
{
- bases.pop_front();
+ bases.pop_front();
}
if(!bases.empty())
{
- _out.zeroIndent();
- _out << sp << nl << "#Region \"Inherited Slice operations\"";
- _out.restoreIndent();
+ _out.zeroIndent();
+ _out << sp << nl << "#Region \"Inherited Slice operations\"";
+ _out.restoreIndent();
OperationList allOps;
- for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
- {
- OperationList tmp = (*q)->allOperations();
- allOps.splice(allOps.end(), tmp);
- }
- allOps.sort();
- allOps.unique();
- for(OperationList::const_iterator op = allOps.begin(); op != allOps.end(); ++op)
- {
- ClassDefPtr containingClass = ClassDefPtr::dynamicCast((*op)->container());
- bool amd = containingClass->hasMetaData("amd") || (*op)->hasMetaData("amd");
- string name = (*op)->name();
- TypePtr ret = (*op)->returnType();
-
- if(!amd)
- {
- vector<string> params = getParams(*op);
- vector<string> args = getArgs(*op);
- string retS = typeToString((*op)->returnType());
-
- string vbOp = ret ? "Function" : "Sub";
- _out << sp << nl << "Public " << vbOp << ' ' << fixId(name, DotNet::ICloneable, true)
- << spar << params << epar;
- if(ret)
- {
- _out << " As " << retS;
- }
- _out << " Implements " << fixId(containingClass->scoped() + "OperationsNC_.")
- << fixId(name, DotNet::ICloneable, true);
- _out.inc();
- _out << nl;
- if((*op)->returnType())
- {
- _out << "Return ";
- }
- _out << fixId(name, DotNet::ICloneable, true)
- << spar << args << "Ice.ObjectImpl.defaultCurrent" << epar;
- _out.dec();
- _out << nl << "End " << vbOp;
-
- _out << sp << nl << "Public MustOverride " << vbOp << ' ' << fixId(name, DotNet::ICloneable, true)
- << spar << params;
- if(!containingClass->isLocal())
- {
- _out << "ByVal current__ As Ice.Current";
- }
- _out << epar;
- if(ret)
- {
- _out << " As " << retS;
- }
- _out << " Implements " << fixId(containingClass->scoped() + "Operations_.")
- << fixId(name, DotNet::ICloneable, true);
- }
- else
- {
- vector<string> params = getParamsAsync(*op, true);
- vector<string> args = getArgsAsync(*op);
-
- _out << sp << nl << "Public Sub " << ' ' << name << "_async" << spar << params << epar
- << " Implements " << fixId(containingClass->scoped() + "OperationsNC_.")
- << name << "_async";
- _out.inc();
- _out << nl << name << "_async" << spar << args << epar;
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public MustOverride Sub " << name << "_async"
- << spar << params << "ByVal current__ As Ice.Current" << epar
- << " Implements " << fixId(containingClass->scoped() + "Operations_.")
- << name << "_async";
- }
- }
-
- _out.zeroIndent();
- _out << sp << nl << "#End Region"; // Inherited Slice operations
- _out.restoreIndent();
+ for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
+ {
+ OperationList tmp = (*q)->allOperations();
+ allOps.splice(allOps.end(), tmp);
+ }
+ allOps.sort();
+ allOps.unique();
+ for(OperationList::const_iterator op = allOps.begin(); op != allOps.end(); ++op)
+ {
+ ClassDefPtr containingClass = ClassDefPtr::dynamicCast((*op)->container());
+ bool amd = containingClass->hasMetaData("amd") || (*op)->hasMetaData("amd");
+ string name = (*op)->name();
+ TypePtr ret = (*op)->returnType();
+
+ if(!amd)
+ {
+ vector<string> params = getParams(*op);
+ vector<string> args = getArgs(*op);
+ string retS = typeToString((*op)->returnType());
+
+ string vbOp = ret ? "Function" : "Sub";
+ _out << sp << nl << "Public " << vbOp << ' ' << fixId(name, DotNet::ICloneable, true)
+ << spar << params << epar;
+ if(ret)
+ {
+ _out << " As " << retS;
+ }
+ _out << " Implements " << fixId(containingClass->scoped() + "OperationsNC_.")
+ << fixId(name, DotNet::ICloneable, true);
+ _out.inc();
+ _out << nl;
+ if((*op)->returnType())
+ {
+ _out << "Return ";
+ }
+ _out << fixId(name, DotNet::ICloneable, true)
+ << spar << args << "Ice.ObjectImpl.defaultCurrent" << epar;
+ _out.dec();
+ _out << nl << "End " << vbOp;
+
+ _out << sp << nl << "Public MustOverride " << vbOp << ' ' << fixId(name, DotNet::ICloneable, true)
+ << spar << params;
+ if(!containingClass->isLocal())
+ {
+ _out << "ByVal current__ As Ice.Current";
+ }
+ _out << epar;
+ if(ret)
+ {
+ _out << " As " << retS;
+ }
+ _out << " Implements " << fixId(containingClass->scoped() + "Operations_.")
+ << fixId(name, DotNet::ICloneable, true);
+ }
+ else
+ {
+ vector<string> params = getParamsAsync(*op, true);
+ vector<string> args = getArgsAsync(*op);
+
+ _out << sp << nl << "Public Sub " << ' ' << name << "_async" << spar << params << epar
+ << " Implements " << fixId(containingClass->scoped() + "OperationsNC_.")
+ << name << "_async";
+ _out.inc();
+ _out << nl << name << "_async" << spar << args << epar;
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public MustOverride Sub " << name << "_async"
+ << spar << params << "ByVal current__ As Ice.Current" << epar
+ << " Implements " << fixId(containingClass->scoped() + "Operations_.")
+ << name << "_async";
+ }
+ }
+
+ _out.zeroIndent();
+ _out << sp << nl << "#End Region"; // Inherited Slice operations
+ _out.restoreIndent();
}
}
@@ -237,16 +237,16 @@ Slice::VbVisitor::writeDispatch(const ClassDefPtr& p)
_out.inc();
{
- StringList::const_iterator q = ids.begin();
- while(q != ids.end())
- {
- _out << nl << '"' << *q << '"';
- if(++q != ids.end())
- {
- _out << ',';
- }
- _out << " _";
- }
+ StringList::const_iterator q = ids.begin();
+ while(q != ids.end())
+ {
+ _out << nl << '"' << *q << '"';
+ if(++q != ids.end())
+ {
+ _out << ',';
+ }
+ _out << " _";
+ }
}
_out.dec();
_out << nl << '}';
@@ -302,398 +302,398 @@ Slice::VbVisitor::writeDispatch(const ClassDefPtr& p)
OperationList ops = p->operations();
if(!p->isInterface() || ops.size() != 0)
{
- _out.zeroIndent();
- _out << sp << nl << "#Region \"Operation dispatch\"";
- _out.restoreIndent();
+ _out.zeroIndent();
+ _out << sp << nl << "#Region \"Operation dispatch\"";
+ _out.restoreIndent();
}
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
OperationPtr op = *r;
- ContainerPtr container = op->container();
+ ContainerPtr container = op->container();
ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
assert(cl);
string opName = op->name();
_out << sp << nl << "Public Shared Function "<< opName << "___( _";
- _out.inc();
- _out.inc();
- _out << nl << "ByVal obj__ As " << p->name() << "Operations_, _";
- _out << nl << "ByVal inS__ As IceInternal.Incoming, _";
- _out << nl << "ByVal current__ As Ice.Current) As IceInternal.DispatchStatus";
+ _out.inc();
+ _out.inc();
+ _out << nl << "ByVal obj__ As " << p->name() << "Operations_, _";
+ _out << nl << "ByVal inS__ As IceInternal.Incoming, _";
+ _out << nl << "ByVal current__ As Ice.Current) As IceInternal.DispatchStatus";
_out.dec();
- bool amd = p->hasMetaData("amd") || op->hasMetaData("amd");
- if(!amd)
- {
- TypePtr ret = op->returnType();
-
- TypeStringList inParams;
- TypeStringList outParams;
- ParamDeclList paramList = op->parameters();
- for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
- {
- if((*pli)->isOutParam())
- {
- outParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
- }
- else
- {
- inParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
- }
- }
-
- ExceptionList throws = op->throws();
- throws.sort();
- throws.unique();
-
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
+ bool amd = p->hasMetaData("amd") || op->hasMetaData("amd");
+ if(!amd)
+ {
+ TypePtr ret = op->returnType();
+
+ TypeStringList inParams;
+ TypeStringList outParams;
+ ParamDeclList paramList = op->parameters();
+ for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
+ {
+ if((*pli)->isOutParam())
+ {
+ outParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
+ }
+ else
+ {
+ inParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
+ }
+ }
+
+ ExceptionList throws = op->throws();
+ throws.sort();
+ throws.unique();
+
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
#if defined(__SUNPRO_CC)
- throws.sort(Slice::derivedToBaseCompare);
+ throws.sort(Slice::derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
- TypeStringList::const_iterator q;
- _out << nl << "checkMode__(" << sliceModeToIceMode(op->mode()) << ", current__.mode)";
- if(!inParams.empty())
- {
- _out << nl << "Dim is__ As IceInternal.BasicStream = inS__.istr()";
- }
- if(!outParams.empty() || ret || !throws.empty())
- {
- _out << nl << "Dim os__ As IceInternal.BasicStream = inS__.ostr()";
- }
-
- //
- // Unmarshal 'in' parameters.
- //
- for(q = inParams.begin(); q != inParams.end(); ++q)
- {
- string param = fixId(q->second);
- string typeS = typeToString(q->first);
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
- bool isClass = (builtin && builtin->kind() == Builtin::KindObject)
- || ClassDeclPtr::dynamicCast(q->first);
- if(!isClass)
- {
- _out << nl << "Dim " << param << " As " << typeS << " = Nothing";
- }
- writeMarshalUnmarshalCode(_out, q->first, param, false, false, true);
- }
- if(op->sendsClasses())
- {
- _out << nl << "is__.readPendingObjects()";
- }
-
- for(q = outParams.begin(); q != outParams.end(); ++q)
- {
- string typeS = typeToString(q->first);
- _out << nl << "Dim " << fixId(q->second) << " As " << typeS << " = Nothing";
- }
-
- //
- // Call on the servant.
- //
- if(!throws.empty())
- {
- _out << nl << "Try";
- _out.inc();
- }
- _out << nl;
- if(ret)
- {
- string retS = typeToString(ret);
- _out << "Dim ret__ As " << retS << " = ";
- }
- _out << "obj__." << fixId(opName, DotNet::ICloneable, true) << spar;
- for(q = inParams.begin(); q != inParams.end(); ++q)
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
- bool isClass = (builtin && builtin->kind() == Builtin::KindObject)
- || ClassDeclPtr::dynamicCast(q->first);
-
- if(isClass)
- {
- _out << "CType(" + fixId(q->second) + "_PP.value, " + typeToString(q->first) + ")";
- }
- else
- {
- _out << fixId(q->second);
- }
- }
- for(q = outParams.begin(); q != outParams.end(); ++q)
- {
- _out << fixId(q->second);
- }
- _out << "current__" << epar;
-
- //
- // Marshal 'out' parameters and return value.
- //
- for(q = outParams.begin(); q != outParams.end(); ++q)
- {
- writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, true, "");
- }
- if(ret)
- {
- writeMarshalUnmarshalCode(_out, ret, "ret__", true, false, true, "");
- }
- if(op->returnsClasses())
- {
- _out << nl << "os__.writePendingObjects()";
- }
- _out << nl << "Return IceInternal.DispatchStatus.DispatchOK";
-
- //
- // Handle user exceptions.
- //
- if(!throws.empty())
- {
- _out.dec();
- ExceptionList::const_iterator t;
- for(t = throws.begin(); t != throws.end(); ++t)
- {
- string exS = fixId((*t)->scoped());
- _out << nl << "Catch ex As " << exS;
- _out.inc();
- _out << nl << "os__.writeUserException(ex)";
- _out << nl << "Return IceInternal.DispatchStatus.DispatchUserException";
- }
- _out.dec();
- _out << nl << "End Try";
- }
-
- _out.dec();
- _out << nl << "End Function";
- }
- else
- {
- TypeStringList inParams;
- ParamDeclList paramList = op->parameters();
- for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
- {
- if(!(*pli)->isOutParam())
- {
- inParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
- }
- }
-
- TypeStringList::const_iterator q;
- _out << nl << "checkMode__(" << sliceModeToIceMode(op->mode()) << ", current__.mode)";
- if(!inParams.empty())
- {
- _out << nl << "Dim is__ As IceInternal.BasicStream = inS__.istr()";
- }
-
- //
- // Unmarshal 'in' parameters.
- //
- for(q = inParams.begin(); q != inParams.end(); ++q)
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
- bool isClass = (builtin && builtin->kind() == Builtin::KindObject)
- || ClassDeclPtr::dynamicCast(q->first);
- if(!isClass)
- {
- _out << nl << "Dim " << fixId(q->second) << " As " << typeToString(q->first);
- }
- writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, false, true);
- }
- if(op->sendsClasses())
- {
- _out << nl << "is__.readPendingObjects()";
- }
-
- //
- // Call on the servant.
- //
- string classNameAMD = "AMD_" + p->name();
- _out << nl << "Dim cb__ As " << classNameAMD << '_' << op->name() << " = new _"
- << classNameAMD << '_' << op->name() << "(inS__)";
+ TypeStringList::const_iterator q;
+ _out << nl << "checkMode__(" << sliceModeToIceMode(op->mode()) << ", current__.mode)";
+ if(!inParams.empty())
+ {
+ _out << nl << "Dim is__ As IceInternal.BasicStream = inS__.istr()";
+ }
+ if(!outParams.empty() || ret || !throws.empty())
+ {
+ _out << nl << "Dim os__ As IceInternal.BasicStream = inS__.ostr()";
+ }
+
+ //
+ // Unmarshal 'in' parameters.
+ //
+ for(q = inParams.begin(); q != inParams.end(); ++q)
+ {
+ string param = fixId(q->second);
+ string typeS = typeToString(q->first);
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
+ bool isClass = (builtin && builtin->kind() == Builtin::KindObject)
+ || ClassDeclPtr::dynamicCast(q->first);
+ if(!isClass)
+ {
+ _out << nl << "Dim " << param << " As " << typeS << " = Nothing";
+ }
+ writeMarshalUnmarshalCode(_out, q->first, param, false, false, true);
+ }
+ if(op->sendsClasses())
+ {
+ _out << nl << "is__.readPendingObjects()";
+ }
+
+ for(q = outParams.begin(); q != outParams.end(); ++q)
+ {
+ string typeS = typeToString(q->first);
+ _out << nl << "Dim " << fixId(q->second) << " As " << typeS << " = Nothing";
+ }
+
+ //
+ // Call on the servant.
+ //
+ if(!throws.empty())
+ {
+ _out << nl << "Try";
+ _out.inc();
+ }
+ _out << nl;
+ if(ret)
+ {
+ string retS = typeToString(ret);
+ _out << "Dim ret__ As " << retS << " = ";
+ }
+ _out << "obj__." << fixId(opName, DotNet::ICloneable, true) << spar;
+ for(q = inParams.begin(); q != inParams.end(); ++q)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
+ bool isClass = (builtin && builtin->kind() == Builtin::KindObject)
+ || ClassDeclPtr::dynamicCast(q->first);
+
+ if(isClass)
+ {
+ _out << "CType(" + fixId(q->second) + "_PP.value, " + typeToString(q->first) + ")";
+ }
+ else
+ {
+ _out << fixId(q->second);
+ }
+ }
+ for(q = outParams.begin(); q != outParams.end(); ++q)
+ {
+ _out << fixId(q->second);
+ }
+ _out << "current__" << epar;
+
+ //
+ // Marshal 'out' parameters and return value.
+ //
+ for(q = outParams.begin(); q != outParams.end(); ++q)
+ {
+ writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, true, "");
+ }
+ if(ret)
+ {
+ writeMarshalUnmarshalCode(_out, ret, "ret__", true, false, true, "");
+ }
+ if(op->returnsClasses())
+ {
+ _out << nl << "os__.writePendingObjects()";
+ }
+ _out << nl << "Return IceInternal.DispatchStatus.DispatchOK";
+
+ //
+ // Handle user exceptions.
+ //
+ if(!throws.empty())
+ {
+ _out.dec();
+ ExceptionList::const_iterator t;
+ for(t = throws.begin(); t != throws.end(); ++t)
+ {
+ string exS = fixId((*t)->scoped());
+ _out << nl << "Catch ex As " << exS;
+ _out.inc();
+ _out << nl << "os__.writeUserException(ex)";
+ _out << nl << "Return IceInternal.DispatchStatus.DispatchUserException";
+ }
+ _out.dec();
+ _out << nl << "End Try";
+ }
+
+ _out.dec();
+ _out << nl << "End Function";
+ }
+ else
+ {
+ TypeStringList inParams;
+ ParamDeclList paramList = op->parameters();
+ for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
+ {
+ if(!(*pli)->isOutParam())
+ {
+ inParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
+ }
+ }
+
+ TypeStringList::const_iterator q;
+ _out << nl << "checkMode__(" << sliceModeToIceMode(op->mode()) << ", current__.mode)";
+ if(!inParams.empty())
+ {
+ _out << nl << "Dim is__ As IceInternal.BasicStream = inS__.istr()";
+ }
+
+ //
+ // Unmarshal 'in' parameters.
+ //
+ for(q = inParams.begin(); q != inParams.end(); ++q)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
+ bool isClass = (builtin && builtin->kind() == Builtin::KindObject)
+ || ClassDeclPtr::dynamicCast(q->first);
+ if(!isClass)
+ {
+ _out << nl << "Dim " << fixId(q->second) << " As " << typeToString(q->first);
+ }
+ writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, false, true);
+ }
+ if(op->sendsClasses())
+ {
+ _out << nl << "is__.readPendingObjects()";
+ }
+
+ //
+ // Call on the servant.
+ //
+ string classNameAMD = "AMD_" + p->name();
+ _out << nl << "Dim cb__ As " << classNameAMD << '_' << op->name() << " = new _"
+ << classNameAMD << '_' << op->name() << "(inS__)";
_out << nl << "Try";
_out.inc();
- _out << nl << "obj__.";
- if(amd)
- {
- _out << opName << "_async";
- }
- else
- {
- _out << fixId(opName, DotNet::ICloneable, true);
- }
- _out << spar;
- if(amd)
- {
- _out << "cb__";
- }
- for(q = inParams.begin(); q != inParams.end(); ++q)
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
- bool isClass = (builtin && builtin->kind() == Builtin::KindObject)
- || ClassDeclPtr::dynamicCast(q->first);
- if(isClass)
- {
- _out << "CType(" + q->second + "__PP.value, " + typeToString(q->first);
- }
- else
- {
- _out << fixId(q->second);
- }
- }
- _out << "current__" << epar;
- _out.dec();
- _out << nl << "Catch ex As _System.Exception";
- _out.inc();
- _out << nl << "cb__.ice_exception(ex)";
- _out.dec();
- _out << nl << "End Try";
- _out << nl << "Return IceInternal.DispatchStatus.DispatchAsync";
-
- _out.dec();
- _out << nl << "End Function";
- }
+ _out << nl << "obj__.";
+ if(amd)
+ {
+ _out << opName << "_async";
+ }
+ else
+ {
+ _out << fixId(opName, DotNet::ICloneable, true);
+ }
+ _out << spar;
+ if(amd)
+ {
+ _out << "cb__";
+ }
+ for(q = inParams.begin(); q != inParams.end(); ++q)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
+ bool isClass = (builtin && builtin->kind() == Builtin::KindObject)
+ || ClassDeclPtr::dynamicCast(q->first);
+ if(isClass)
+ {
+ _out << "CType(" + q->second + "__PP.value, " + typeToString(q->first);
+ }
+ else
+ {
+ _out << fixId(q->second);
+ }
+ }
+ _out << "current__" << epar;
+ _out.dec();
+ _out << nl << "Catch ex As _System.Exception";
+ _out.inc();
+ _out << nl << "cb__.ice_exception(ex)";
+ _out.dec();
+ _out << nl << "End Try";
+ _out << nl << "Return IceInternal.DispatchStatus.DispatchAsync";
+
+ _out.dec();
+ _out << nl << "End Function";
+ }
}
OperationList allOps = p->allOperations();
if(!allOps.empty())
{
- StringList allOpNames;
+ StringList allOpNames;
#if defined(__IBMCPP__) && defined(NDEBUG)
- //
- // See comment for transform above
- //
- transform(allOps.begin(), allOps.end(), back_inserter(allOpNames), ::IceUtil::constMemFun<string,Operation>(&Contained::name));
+ //
+ // See comment for transform above
+ //
+ transform(allOps.begin(), allOps.end(), back_inserter(allOpNames), ::IceUtil::constMemFun<string,Operation>(&Contained::name));
#else
- transform(allOps.begin(), allOps.end(), back_inserter(allOpNames), ::IceUtil::constMemFun(&Contained::name));
+ transform(allOps.begin(), allOps.end(), back_inserter(allOpNames), ::IceUtil::constMemFun(&Contained::name));
#endif
- allOpNames.push_back("ice_id");
- allOpNames.push_back("ice_ids");
- allOpNames.push_back("ice_isA");
- allOpNames.push_back("ice_ping");
-
- //
- // We sort into case-insensitive order here because, at run time,
- // the sort order must match the sort order used by System.Array.Sort().
- // (C# has no notion of the default ASCII ordering.)
- //
+ allOpNames.push_back("ice_id");
+ allOpNames.push_back("ice_ids");
+ allOpNames.push_back("ice_isA");
+ allOpNames.push_back("ice_ping");
+
+ //
+ // We sort into case-insensitive order here because, at run time,
+ // the sort order must match the sort order used by System.Array.Sort().
+ // (C# has no notion of the default ASCII ordering.)
+ //
#if defined(__SUNPRO_CC)
- allOpNames.sort(Slice::cICompare);
+ allOpNames.sort(Slice::cICompare);
#else
- allOpNames.sort(Slice::CICompare());
+ allOpNames.sort(Slice::CICompare());
#endif
- allOpNames.unique();
-
- StringList::const_iterator q;
-
- _out << sp << nl << "Public Shared Shadows all__ As String() = New String() _";
- _out.inc();
- _out << nl << "{ _";
- _out.inc();
-
- q = allOpNames.begin();
- while(q != allOpNames.end())
- {
- _out << nl << '"' << *q << '"';
- if(++q != allOpNames.end())
- {
- _out << ',';
- }
- _out << " _";
- }
- _out.dec();
- _out << nl << '}';
- _out.dec();
-
- _out << sp << nl << "Public Overloads Overrides Function dispatch__( _";
- _out.inc();
- _out.inc();
- _out << nl << "ByVal inS__ As IceInternal.Incoming, _";
- _out << nl << "ByVal current__ As Ice.Current) As IceInternal.DispatchStatus";
- _out.dec();
- _out << nl << "Dim pos As Integer";
- _out << nl << "pos = _System.Array.BinarySearch(all__, current__.operation, "
- << "_System.Collections.Comparer.DefaultInvariant)";
- _out << nl << "If pos < 0 Then";
- _out.inc();
- _out << nl << "Return IceInternal.DispatchStatus.DispatchOperationNotExist";
- _out.dec();
- _out << nl << "End If";
- _out << nl << "Select Case pos";
- _out.inc();
- int i = 0;
- for(q = allOpNames.begin(); q != allOpNames.end(); ++q)
- {
- string opName = *q;
-
- _out << nl << "Case " << i++;
- _out.inc();
- if(opName == "ice_id")
- {
- _out << nl << "Return ice_id___(Me, inS__, current__)";
- }
- else if(opName == "ice_ids")
- {
- _out << nl << "Return ice_ids___(Me, inS__, current__)";
- }
- else if(opName == "ice_isA")
- {
- _out << nl << "Return ice_isA___(Me, inS__, current__)";
- }
- else if(opName == "ice_ping")
- {
- _out << nl << "Return ice_ping___(Me, inS__, current__)";
- }
- else
- {
- //
- // There's probably a better way to do this
- //
- for(OperationList::const_iterator t = allOps.begin(); t != allOps.end(); ++t)
- {
- if((*t)->name() == (*q))
- {
- ContainerPtr container = (*t)->container();
- ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
- assert(cl);
- if(cl->scoped() == p->scoped())
- {
- _out << nl << "Return " << opName << "___(Me, inS__, current__)";
- }
- else
- {
- string base = cl->scoped();
- if(cl->isInterface())
- {
- base += "Disp_";
- }
- _out << nl << "Return " << fixId(base) << "." << opName << "___(Me, inS__, current__)";
- }
- break;
- }
- }
- }
- _out.dec();
- }
- _out.dec();
- _out << nl << "End Select";
- _out << sp << nl << "' _System.Diagnostics.Debug.Assert(false) ' Bug in VB 7.1: Diagnostics.Debug is not found";
- _out << nl << "Return IceInternal.DispatchStatus.DispatchOperationNotExist";
- _out.dec();
- _out << nl << "End Function";
+ allOpNames.unique();
+
+ StringList::const_iterator q;
+
+ _out << sp << nl << "Public Shared Shadows all__ As String() = New String() _";
+ _out.inc();
+ _out << nl << "{ _";
+ _out.inc();
+
+ q = allOpNames.begin();
+ while(q != allOpNames.end())
+ {
+ _out << nl << '"' << *q << '"';
+ if(++q != allOpNames.end())
+ {
+ _out << ',';
+ }
+ _out << " _";
+ }
+ _out.dec();
+ _out << nl << '}';
+ _out.dec();
+
+ _out << sp << nl << "Public Overloads Overrides Function dispatch__( _";
+ _out.inc();
+ _out.inc();
+ _out << nl << "ByVal inS__ As IceInternal.Incoming, _";
+ _out << nl << "ByVal current__ As Ice.Current) As IceInternal.DispatchStatus";
+ _out.dec();
+ _out << nl << "Dim pos As Integer";
+ _out << nl << "pos = _System.Array.BinarySearch(all__, current__.operation, "
+ << "_System.Collections.Comparer.DefaultInvariant)";
+ _out << nl << "If pos < 0 Then";
+ _out.inc();
+ _out << nl << "Return IceInternal.DispatchStatus.DispatchOperationNotExist";
+ _out.dec();
+ _out << nl << "End If";
+ _out << nl << "Select Case pos";
+ _out.inc();
+ int i = 0;
+ for(q = allOpNames.begin(); q != allOpNames.end(); ++q)
+ {
+ string opName = *q;
+
+ _out << nl << "Case " << i++;
+ _out.inc();
+ if(opName == "ice_id")
+ {
+ _out << nl << "Return ice_id___(Me, inS__, current__)";
+ }
+ else if(opName == "ice_ids")
+ {
+ _out << nl << "Return ice_ids___(Me, inS__, current__)";
+ }
+ else if(opName == "ice_isA")
+ {
+ _out << nl << "Return ice_isA___(Me, inS__, current__)";
+ }
+ else if(opName == "ice_ping")
+ {
+ _out << nl << "Return ice_ping___(Me, inS__, current__)";
+ }
+ else
+ {
+ //
+ // There's probably a better way to do this
+ //
+ for(OperationList::const_iterator t = allOps.begin(); t != allOps.end(); ++t)
+ {
+ if((*t)->name() == (*q))
+ {
+ ContainerPtr container = (*t)->container();
+ ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
+ assert(cl);
+ if(cl->scoped() == p->scoped())
+ {
+ _out << nl << "Return " << opName << "___(Me, inS__, current__)";
+ }
+ else
+ {
+ string base = cl->scoped();
+ if(cl->isInterface())
+ {
+ base += "Disp_";
+ }
+ _out << nl << "Return " << fixId(base) << "." << opName << "___(Me, inS__, current__)";
+ }
+ break;
+ }
+ }
+ }
+ _out.dec();
+ }
+ _out.dec();
+ _out << nl << "End Select";
+ _out << sp << nl << "' _System.Diagnostics.Debug.Assert(false) ' Bug in VB 7.1: Diagnostics.Debug is not found";
+ _out << nl << "Return IceInternal.DispatchStatus.DispatchOperationNotExist";
+ _out.dec();
+ _out << nl << "End Function";
}
if(!p->isInterface() || ops.size() != 0)
{
- _out.zeroIndent();
- _out << sp << nl << "#End Region"; // Operation dispatch
- _out.restoreIndent();
+ _out.zeroIndent();
+ _out << sp << nl << "#End Region"; // Operation dispatch
+ _out.restoreIndent();
}
}
@@ -704,11 +704,11 @@ Slice::VbVisitor::getParamAttributes(const ParamDeclPtr& p)
StringList metaData = p->getMetaData();
for(StringList::const_iterator i = metaData.begin(); i != metaData.end(); ++i)
{
- static const string prefix = "vb:attribute:";
+ static const string prefix = "vb:attribute:";
if(i->find(prefix) == 0)
- {
- result += "<" + i->substr(prefix.size()) + "> ";
- }
+ {
+ result += "<" + i->substr(prefix.size()) + "> ";
+ }
}
return result;
}
@@ -721,9 +721,9 @@ Slice::VbVisitor::getParams(const OperationPtr& op)
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
string param = getParamAttributes(*q);
- param += ((*q)->isOutParam() ? "<_System.Runtime.InteropServices.Out()> ByRef " : "ByVal ")
- + fixId((*q)->name()) + " As " + typeToString((*q)->type());
- params.push_back(param);
+ param += ((*q)->isOutParam() ? "<_System.Runtime.InteropServices.Out()> ByRef " : "ByVal ")
+ + fixId((*q)->name()) + " As " + typeToString((*q)->type());
+ params.push_back(param);
}
return params;
}
@@ -744,11 +744,11 @@ Slice::VbVisitor::getParamsAsync(const OperationPtr& op, bool amd)
ParamDeclList paramList = op->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- if(!(*q)->isOutParam())
- {
- params.push_back(getParamAttributes(*q) + "ByVal " + fixId((*q)->name()) + " As "
- + typeToString((*q)->type()));
- }
+ if(!(*q)->isOutParam())
+ {
+ params.push_back(getParamAttributes(*q) + "ByVal " + fixId((*q)->name()) + " As "
+ + typeToString((*q)->type()));
+ }
}
return params;
}
@@ -761,17 +761,17 @@ Slice::VbVisitor::getParamsAsyncCB(const OperationPtr& op)
TypePtr ret = op->returnType();
if(ret)
{
- params.push_back("ByVal ret__ As " + typeToString(ret));
+ params.push_back("ByVal ret__ As " + typeToString(ret));
}
ParamDeclList paramList = op->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- if((*q)->isOutParam())
- {
- params.push_back(getParamAttributes(*q) + "ByVal " + fixId((*q)->name()) + " As "
- + typeToString((*q)->type()));
- }
+ if((*q)->isOutParam())
+ {
+ params.push_back(getParamAttributes(*q) + "ByVal " + fixId((*q)->name()) + " As "
+ + typeToString((*q)->type()));
+ }
}
return params;
@@ -784,7 +784,7 @@ Slice::VbVisitor::getArgs(const OperationPtr& op)
ParamDeclList paramList = op->parameters();
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
- string arg = fixId((*q)->name());
+ string arg = fixId((*q)->name());
args.push_back(arg);
}
return args;
@@ -801,9 +801,9 @@ Slice::VbVisitor::getArgsAsync(const OperationPtr& op)
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
if(!(*q)->isOutParam())
- {
- args.push_back(fixId((*q)->name()));
- }
+ {
+ args.push_back(fixId((*q)->name()));
+ }
}
return args;
}
@@ -823,9 +823,9 @@ Slice::VbVisitor::getArgsAsyncCB(const OperationPtr& op)
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
if((*q)->isOutParam())
- {
- args.push_back(fixId((*q)->name()));
- }
+ {
+ args.push_back(fixId((*q)->name()));
+ }
}
return args;
@@ -837,11 +837,11 @@ Slice::VbVisitor::emitAttributes(const ContainedPtr& p)
StringList metaData = p->getMetaData();
for(StringList::const_iterator i = metaData.begin(); i != metaData.end(); ++i)
{
- static const string prefix = "vb:attribute:";
+ static const string prefix = "vb:attribute:";
if(i->find(prefix) == 0)
- {
- _out << nl << '<' << i->substr(prefix.size()) << '>';
- }
+ {
+ _out << nl << '<' << i->substr(prefix.size()) << '>';
+ }
}
}
@@ -854,22 +854,22 @@ Slice::Gen::Gen(const string& name, const string& base, const vector<string>& in
string::size_type pos = base.find_last_of("/\\");
if(pos != string::npos)
{
- fileBase = base.substr(pos + 1);
+ fileBase = base.substr(pos + 1);
}
string file = fileBase + ".vb";
string fileImpl = fileBase + "I.vb";
if(!dir.empty())
{
- file = dir + '/' + file;
- fileImpl = dir + '/' + fileImpl;
+ file = dir + '/' + file;
+ fileImpl = dir + '/' + fileImpl;
}
_out.open(file.c_str());
if(!_out)
{
cerr << name << ": can't open `" << file << "' for writing" << endl;
- return;
+ return;
}
printHeader();
@@ -881,17 +881,17 @@ Slice::Gen::Gen(const string& name, const string& base, const vector<string>& in
if(impl || implTie)
{
struct stat st;
- if(stat(fileImpl.c_str(), &st) == 0)
- {
- cerr << name << ": `" << fileImpl << "' already exists - will not overwrite" << endl;
- return;
- }
- _impl.open(fileImpl.c_str());
- if(!_impl)
- {
- cerr << name << ": can't open `" << fileImpl << "' for writing" << endl;
- return;
- }
+ if(stat(fileImpl.c_str(), &st) == 0)
+ {
+ cerr << name << ": `" << fileImpl << "' already exists - will not overwrite" << endl;
+ return;
+ }
+ _impl.open(fileImpl.c_str());
+ if(!_impl)
+ {
+ cerr << name << ": can't open `" << fileImpl << "' for writing" << endl;
+ return;
+ }
}
}
@@ -993,7 +993,7 @@ Slice::Gen::generateChecksums(const UnitPtr& p)
_out << sp << nl << "Public NotInheritable Class " << className;
_out.inc();
_out << nl << "Public Shared Readonly map As _System.Collections.Hashtable"
- << " = new _System.Collections.Hashtable()";
+ << " = new _System.Collections.Hashtable()";
_out << sp << nl << "Shared Sub New()";
_out.inc();
for(ChecksumMap::const_iterator q = map.begin(); q != map.end(); ++q)
@@ -1009,13 +1009,13 @@ Slice::Gen::generateChecksums(const UnitPtr& p)
_out << str.str() << "\")";
}
_out.dec();
- _out << nl << "End Sub";
+ _out << nl << "End Sub";
_out.dec();
- _out << sp << nl << "End Class";
+ _out << sp << nl << "End Class";
_out.dec();
- _out << sp << nl << "End Namespace";
+ _out << sp << nl << "End Namespace";
_out.dec();
- _out << sp << nl << "End Namespace";
+ _out << sp << nl << "End Namespace";
}
}
@@ -1047,25 +1047,25 @@ Slice::Gen::UnitVisitor::visitModuleStart(const ModulePtr& p)
{
if(!_globalMetaDataDone)
{
- DefinitionContextPtr dc = p->definitionContext();
- StringList globalMetaData = dc->getMetaData();
-
- static const string attributePrefix = "vb:attribute:";
-
- if(!globalMetaData.empty())
- {
- _out << sp;
- }
- for(StringList::const_iterator q = globalMetaData.begin(); q != globalMetaData.end(); ++q)
- {
- string::size_type pos = q->find(attributePrefix);
- if(pos == 0)
- {
- string attrib = q->substr(pos + attributePrefix.size());
- _out << nl << '<' << attrib << '>';
- }
- }
- _globalMetaDataDone = true; // Do this only once per source file.
+ DefinitionContextPtr dc = p->definitionContext();
+ StringList globalMetaData = dc->getMetaData();
+
+ static const string attributePrefix = "vb:attribute:";
+
+ if(!globalMetaData.empty())
+ {
+ _out << sp;
+ }
+ for(StringList::const_iterator q = globalMetaData.begin(); q != globalMetaData.end(); ++q)
+ {
+ string::size_type pos = q->find(attributePrefix);
+ if(pos == 0)
+ {
+ string attrib = q->substr(pos + attributePrefix.size());
+ _out << nl << '<' << attrib << '>';
+ }
+ }
+ _globalMetaDataDone = true; // Do this only once per source file.
}
return false;
}
@@ -1107,42 +1107,42 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!p->isLocal() && _stream)
{
_out << sp << nl << "Public NotInheritable Class " << p->name() << "Helper";
- _out.inc();
-
- _out << sp << nl << "Public Sub New(ByVal inS__ As Ice.InputStream)";
- _out.inc();
- _out << nl << "_in = inS__";
- _out << nl << "_pp = New IceInternal.ParamPatcher(GetType(" << scoped << "), \"" << p->scoped() << "\")";
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public Shared Sub write(ByVal outS__ As Ice.OutputStream, ByVal v__ As " << name << ')';
- _out.inc();
- _out << nl << "outS__.writeObject(v__)";
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public Sub read()";
- _out.inc();
- _out << nl << "_in.readObject(_pp)";
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public ReadOnly Property value() As " << scoped;
- _out.inc();
- _out << nl << "Get";
- _out.inc();
- _out << nl << "Return CType(_pp.value, " << scoped << ')';
- _out.dec();
- _out << nl << "End Get";
- _out.dec();
- _out << nl << "End Property";
-
- _out << sp << nl << "Private _in As Ice.InputStream";
- _out << nl << "Private _pp As IceInternal.ParamPatcher";
-
- _out.dec();
- _out << sp << nl << "End Class";
+ _out.inc();
+
+ _out << sp << nl << "Public Sub New(ByVal inS__ As Ice.InputStream)";
+ _out.inc();
+ _out << nl << "_in = inS__";
+ _out << nl << "_pp = New IceInternal.ParamPatcher(GetType(" << scoped << "), \"" << p->scoped() << "\")";
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public Shared Sub write(ByVal outS__ As Ice.OutputStream, ByVal v__ As " << name << ')';
+ _out.inc();
+ _out << nl << "outS__.writeObject(v__)";
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public Sub read()";
+ _out.inc();
+ _out << nl << "_in.readObject(_pp)";
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public ReadOnly Property value() As " << scoped;
+ _out.inc();
+ _out << nl << "Get";
+ _out.inc();
+ _out << nl << "Return CType(_pp.value, " << scoped << ')';
+ _out.dec();
+ _out << nl << "End Get";
+ _out.dec();
+ _out << nl << "End Property";
+
+ _out << sp << nl << "Private _in As Ice.InputStream";
+ _out << nl << "Private _pp As IceInternal.ParamPatcher";
+
+ _out.dec();
+ _out << sp << nl << "End Class";
}
_out << sp;
@@ -1150,91 +1150,91 @@ Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr& p)
if(p->isInterface())
{
_out << nl << "Public Interface " << name;
- _out.inc();
- if(p->isLocal())
- {
- _out << nl << "Inherits Ice.LocalObject";
- }
- else
- {
- _out << nl << "Inherits Ice.Object";
- }
- _out << ", " << p->name();
- if(!p->isLocal())
- {
- _out << "Operations_, " << p->name();
- }
- _out << "OperationsNC_";
- if(!bases.empty())
- {
- ClassList::const_iterator q = bases.begin();
- while(q != bases.end())
- {
- _out << ", " << fixId((*q)->scoped());
- q++;
- }
- }
+ _out.inc();
+ if(p->isLocal())
+ {
+ _out << nl << "Inherits Ice.LocalObject";
+ }
+ else
+ {
+ _out << nl << "Inherits Ice.Object";
+ }
+ _out << ", " << p->name();
+ if(!p->isLocal())
+ {
+ _out << "Operations_, " << p->name();
+ }
+ _out << "OperationsNC_";
+ if(!bases.empty())
+ {
+ ClassList::const_iterator q = bases.begin();
+ while(q != bases.end())
+ {
+ _out << ", " << fixId((*q)->scoped());
+ q++;
+ }
+ }
}
else
{
- _out << nl << "Public ";
- if(p->isAbstract())
- {
- _out << "MustInherit ";
- }
- _out << "Class " << name;
- _out.inc();
-
- if(!hasBaseClass)
- {
- if(p->isLocal())
- {
- _out << nl << "Inherits Ice.LocalObjectImpl";
- }
- else
- {
- _out << nl << "Inherits Ice.ObjectImpl";
- }
- }
- else
- {
- _out << nl << "Inherits " << fixId(bases.front()->scoped());
- bases.pop_front();
- }
- if(p->isAbstract())
- {
- _out << nl << "Implements " << p->name();
- if(!p->isLocal())
- {
- _out << "Operations_, " << p->name();
- }
- _out << "OperationsNC_";
- }
- for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
- {
- if((*q)->isAbstract())
- {
- _out << ", " << fixId((*q)->scoped());
- }
- }
+ _out << nl << "Public ";
+ if(p->isAbstract())
+ {
+ _out << "MustInherit ";
+ }
+ _out << "Class " << name;
+ _out.inc();
+
+ if(!hasBaseClass)
+ {
+ if(p->isLocal())
+ {
+ _out << nl << "Inherits Ice.LocalObjectImpl";
+ }
+ else
+ {
+ _out << nl << "Inherits Ice.ObjectImpl";
+ }
+ }
+ else
+ {
+ _out << nl << "Inherits " << fixId(bases.front()->scoped());
+ bases.pop_front();
+ }
+ if(p->isAbstract())
+ {
+ _out << nl << "Implements " << p->name();
+ if(!p->isLocal())
+ {
+ _out << "Operations_, " << p->name();
+ }
+ _out << "OperationsNC_";
+ }
+ for(ClassList::const_iterator q = bases.begin(); q != bases.end(); ++q)
+ {
+ if((*q)->isAbstract())
+ {
+ _out << ", " << fixId((*q)->scoped());
+ }
+ }
}
if(!p->isInterface())
{
- _out.zeroIndent();
+ _out.zeroIndent();
if(p->hasDataMembers() && !p->hasOperations())
- {
- _out << sp << nl << "#Region \"Slice data members\"";
- }
- else if(p->hasDataMembers())
- {
- _out << sp << nl << "#Region \"Slice data members and operations\"";
- }
- else if(p->hasOperations())
- {
- _out << sp << nl << "#Region \"Slice operations\"";
- }
- _out.restoreIndent();
+ {
+ _out << sp << nl << "#Region \"Slice data members\"";
+ }
+ else if(p->hasDataMembers())
+ {
+ _out << sp << nl << "#Region \"Slice data members and operations\"";
+ }
+ else if(p->hasOperations())
+ {
+ _out << sp << nl << "#Region \"Slice operations\"";
+ }
+ _out.restoreIndent();
}
return true;
@@ -1254,283 +1254,283 @@ Slice::Gen::TypesVisitor::visitClassDefEnd(const ClassDefPtr& p)
{
_out.zeroIndent();
if(p->hasDataMembers() && !p->hasOperations())
- {
- _out << sp << nl << "#End Region"; // Slice data members
- }
- else if(p->hasDataMembers())
- {
- _out << sp << nl << "#End Region"; // Slice data members and operations
- }
- else if(p->hasOperations())
- {
- _out << sp << nl << "#End Region"; // Slice operations
- }
- _out.restoreIndent();
-
- if(!allDataMembers.empty())
- {
- _out.zeroIndent();
- _out << sp << nl << "#Region \"Constructors\"";
- _out.restoreIndent();
-
- _out << sp << nl << "Public Sub New" << spar << epar;
- _out.inc();
- if(hasBaseClass)
- {
- _out << nl << "MyBase.New()";
- }
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public Sub New" << spar;
- vector<string> paramDecl;
- for(d = allDataMembers.begin(); d != allDataMembers.end(); ++d)
- {
- string memberName = fixId((*d)->name());
- string memberType = typeToString((*d)->type());
- paramDecl.push_back("ByVal " + memberName + " As " + memberType);
- }
- _out << paramDecl << epar;
- _out.inc();
- if(hasBaseClass && allDataMembers.size() != dataMembers.size())
- {
- _out << nl << "MyBase.New" << spar;
- vector<string> baseParamNames;
- DataMemberList baseDataMembers = bases.front()->allDataMembers();
- for(d = baseDataMembers.begin(); d != baseDataMembers.end(); ++d)
- {
- baseParamNames.push_back(fixId((*d)->name()));
- }
- _out << baseParamNames << epar;
- }
- vector<string> paramNames;
- for(d = dataMembers.begin(); d != dataMembers.end(); ++d)
- {
- paramNames.push_back(fixId((*d)->name()));
- }
- for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i)
- {
- _out << nl << "Me." << *i << " = " << *i;
- }
- _out.dec();
- _out << nl << "End Sub";
-
- _out.zeroIndent();
- _out << sp << nl << "#End Region"; // Constructors
- _out.restoreIndent();
- }
-
- writeInheritedOperations(p);
+ {
+ _out << sp << nl << "#End Region"; // Slice data members
+ }
+ else if(p->hasDataMembers())
+ {
+ _out << sp << nl << "#End Region"; // Slice data members and operations
+ }
+ else if(p->hasOperations())
+ {
+ _out << sp << nl << "#End Region"; // Slice operations
+ }
+ _out.restoreIndent();
+
+ if(!allDataMembers.empty())
+ {
+ _out.zeroIndent();
+ _out << sp << nl << "#Region \"Constructors\"";
+ _out.restoreIndent();
+
+ _out << sp << nl << "Public Sub New" << spar << epar;
+ _out.inc();
+ if(hasBaseClass)
+ {
+ _out << nl << "MyBase.New()";
+ }
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public Sub New" << spar;
+ vector<string> paramDecl;
+ for(d = allDataMembers.begin(); d != allDataMembers.end(); ++d)
+ {
+ string memberName = fixId((*d)->name());
+ string memberType = typeToString((*d)->type());
+ paramDecl.push_back("ByVal " + memberName + " As " + memberType);
+ }
+ _out << paramDecl << epar;
+ _out.inc();
+ if(hasBaseClass && allDataMembers.size() != dataMembers.size())
+ {
+ _out << nl << "MyBase.New" << spar;
+ vector<string> baseParamNames;
+ DataMemberList baseDataMembers = bases.front()->allDataMembers();
+ for(d = baseDataMembers.begin(); d != baseDataMembers.end(); ++d)
+ {
+ baseParamNames.push_back(fixId((*d)->name()));
+ }
+ _out << baseParamNames << epar;
+ }
+ vector<string> paramNames;
+ for(d = dataMembers.begin(); d != dataMembers.end(); ++d)
+ {
+ paramNames.push_back(fixId((*d)->name()));
+ }
+ for(vector<string>::const_iterator i = paramNames.begin(); i != paramNames.end(); ++i)
+ {
+ _out << nl << "Me." << *i << " = " << *i;
+ }
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out.zeroIndent();
+ _out << sp << nl << "#End Region"; // Constructors
+ _out.restoreIndent();
+ }
+
+ writeInheritedOperations(p);
}
if(!p->isInterface() && !p->isLocal())
{
- writeDispatch(p);
-
- DataMemberList members = p->dataMembers();
-
- _out.zeroIndent();
- _out << sp << nl << "#Region \"Marshaling support\"";
- _out.restoreIndent();
-
- _out << sp << nl << "Public Overloads Overrides Sub write__(ByVal os__ As IceInternal.BasicStream)";
- _out.inc();
- _out << nl << "os__.writeTypeId(ice_staticId())";
- _out << nl << "os__.startWriteSlice()";
- for(d = members.begin(); d != members.end(); ++d)
- {
- writeMarshalUnmarshalCode(_out, (*d)->type(), fixId((*d)->name(), DotNet::ICloneable, true), true, false,
- false);
- }
- _out << nl << "os__.endWriteSlice()";
- _out << nl << "MyBase.write__(os__)";
- _out.dec();
- _out << nl << "End Sub";
-
- DataMemberList allClassMembers = p->allClassDataMembers();
- if(allClassMembers.size() != 0)
- {
- _out << sp << nl << "Public Shadows NotInheritable Class Patcher__";
- _out.inc();
- _out << nl << "Inherits IceInternal.Patcher";
- _out << sp << nl << "Friend Sub New(ByVal instance As Ice.ObjectImpl";
- if(allClassMembers.size() > 1)
- {
- _out << ", ByVal member As Integer";
- }
- _out << ')';
- _out.inc();
- _out << nl << "_instance = CType(instance, " << name << ')';
- if(allClassMembers.size() > 1)
- {
- _out << nl << "_member = member";
- }
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public Overrides Sub patch(ByVal v As Ice.Object)";
- _out.inc();
- _out << nl << "Try";
- _out.inc();
- if(allClassMembers.size() > 1)
- {
- _out << nl << "Select Case _member";
- _out.inc();
- }
- int memberCount = 0;
- for(d = allClassMembers.begin(); d != allClassMembers.end(); ++d)
- {
- if(allClassMembers.size() > 1)
- {
- _out << nl << "Case " << memberCount;
- _out.inc();
- }
- string memberName = fixId((*d)->name(), DotNet::ICloneable, true);
- string memberType = typeToString((*d)->type());
- _out << nl << "type_ = GetType(" << memberType << ')';
- _out << nl << "_instance." << memberName << " = CType(v, " << memberType << ')';
- _out << nl << "_typeId = \"" << (*d)->type()->typeId() << "\"";
- if(allClassMembers.size() > 1)
- {
- _out.dec();
- }
- memberCount++;
- }
- if(allClassMembers.size() > 1)
- {
- _out << nl << "End Select";
- }
- _out.dec();
- _out << nl << "Catch _ex As System.InvalidCastException";
- _out.inc();
- _out << nl << "Dim _e As Ice.UnexpectedObjectException = New Ice.UnexpectedObjectException";
- _out << nl << "_e.type = v.ice_id()";
- _out << nl << "_e.expectedType = _typeId";
- _out << nl << "Throw _e";
- _out.dec();
- _out << nl << "End Try";
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Private _instance As " << name;
- if(allClassMembers.size() > 1)
- {
- _out << nl << "Private _member As Integer";
- }
- _out << nl << "Private _typeId As String";
- _out.dec();
- _out << sp << nl << "End Class";
- }
-
- _out << sp << nl << "Public Overloads Overrides Sub read__(ByVal is__ As IceInternal.BasicStream, "
- "ByVal rid__ As Boolean)";
- _out.inc();
- _out << nl << "If rid__ Then";
- _out.inc();
- _out << nl << "Dim myId As String = is__.readTypeId()";
- _out.dec();
- _out << nl << "End If";
- _out << nl << "is__.startReadSlice()";
- DataMemberList classMembers = p->classDataMembers();
- int classMemberCount = static_cast<int>(allClassMembers.size() - classMembers.size());
- for(d = members.begin(); d != members.end(); ++d)
- {
- ostringstream patchParams;
- patchParams << "Me";
- 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)->name(), DotNet::ICloneable, true),
- false, false, false, patchParams.str());
- }
- _out << nl << "is__.endReadSlice()";
- _out << nl << "MyBase.read__(is__, true)";
- _out.dec();
- _out << nl << "End Sub";
-
- //
- // Write streaming API.
- //
- if(_stream)
- {
- _out << sp << nl << "Public Overloads Overrides Sub write__(ByVal outS__ As Ice.OutputStream)";
- _out.inc();
- _out << nl << "outS__.writeTypeId(ice_staticId())";
- _out << nl << "outS__.startSlice()";
- for(d = members.begin(); d != members.end(); ++d)
- {
- writeMarshalUnmarshalCode(_out, (*d)->type(),
- fixId((*d)->name(), DotNet::ICloneable, true),
- true, true, false);
- }
- _out << nl << "outS__.endSlice()";
- _out << nl << "MyBase.write__(outS__)";
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public Overloads Overrides Sub read__"
- << "(ByVal inS__ As Ice.InputStream, ByVal rid__ As Boolean)";
- _out.inc();
- _out << nl << "If rid__ Then";
- _out.inc();
- _out << nl << "Dim myId As String = inS__.readTypeId()";
- _out.dec();
- _out << nl << "End If";
- _out << nl << "inS__.startSlice()";
- for(d = members.begin(); d != members.end(); ++d)
- {
- ostringstream patchParams;
- patchParams << "Me";
- 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)->name(), DotNet::ICloneable, true),
- false, true, false, patchParams.str());
- }
- _out << nl << "inS__.endSlice()";
- _out << nl << "MyBase.read__(inS__, True)";
- _out.dec();
- _out << nl << "End Sub";
- }
- else
- {
- //
- // Emit placeholder functions to catch errors.
- //
+ writeDispatch(p);
+
+ DataMemberList members = p->dataMembers();
+
+ _out.zeroIndent();
+ _out << sp << nl << "#Region \"Marshaling support\"";
+ _out.restoreIndent();
+
+ _out << sp << nl << "Public Overloads Overrides Sub write__(ByVal os__ As IceInternal.BasicStream)";
+ _out.inc();
+ _out << nl << "os__.writeTypeId(ice_staticId())";
+ _out << nl << "os__.startWriteSlice()";
+ for(d = members.begin(); d != members.end(); ++d)
+ {
+ writeMarshalUnmarshalCode(_out, (*d)->type(), fixId((*d)->name(), DotNet::ICloneable, true), true, false,
+ false);
+ }
+ _out << nl << "os__.endWriteSlice()";
+ _out << nl << "MyBase.write__(os__)";
+ _out.dec();
+ _out << nl << "End Sub";
+
+ DataMemberList allClassMembers = p->allClassDataMembers();
+ if(allClassMembers.size() != 0)
+ {
+ _out << sp << nl << "Public Shadows NotInheritable Class Patcher__";
+ _out.inc();
+ _out << nl << "Inherits IceInternal.Patcher";
+ _out << sp << nl << "Friend Sub New(ByVal instance As Ice.ObjectImpl";
+ if(allClassMembers.size() > 1)
+ {
+ _out << ", ByVal member As Integer";
+ }
+ _out << ')';
+ _out.inc();
+ _out << nl << "_instance = CType(instance, " << name << ')';
+ if(allClassMembers.size() > 1)
+ {
+ _out << nl << "_member = member";
+ }
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public Overrides Sub patch(ByVal v As Ice.Object)";
+ _out.inc();
+ _out << nl << "Try";
+ _out.inc();
+ if(allClassMembers.size() > 1)
+ {
+ _out << nl << "Select Case _member";
+ _out.inc();
+ }
+ int memberCount = 0;
+ for(d = allClassMembers.begin(); d != allClassMembers.end(); ++d)
+ {
+ if(allClassMembers.size() > 1)
+ {
+ _out << nl << "Case " << memberCount;
+ _out.inc();
+ }
+ string memberName = fixId((*d)->name(), DotNet::ICloneable, true);
+ string memberType = typeToString((*d)->type());
+ _out << nl << "type_ = GetType(" << memberType << ')';
+ _out << nl << "_instance." << memberName << " = CType(v, " << memberType << ')';
+ _out << nl << "_typeId = \"" << (*d)->type()->typeId() << "\"";
+ if(allClassMembers.size() > 1)
+ {
+ _out.dec();
+ }
+ memberCount++;
+ }
+ if(allClassMembers.size() > 1)
+ {
+ _out << nl << "End Select";
+ }
+ _out.dec();
+ _out << nl << "Catch _ex As System.InvalidCastException";
+ _out.inc();
+ _out << nl << "Dim _e As Ice.UnexpectedObjectException = New Ice.UnexpectedObjectException";
+ _out << nl << "_e.type = v.ice_id()";
+ _out << nl << "_e.expectedType = _typeId";
+ _out << nl << "Throw _e";
+ _out.dec();
+ _out << nl << "End Try";
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Private _instance As " << name;
+ if(allClassMembers.size() > 1)
+ {
+ _out << nl << "Private _member As Integer";
+ }
+ _out << nl << "Private _typeId As String";
+ _out.dec();
+ _out << sp << nl << "End Class";
+ }
+
+ _out << sp << nl << "Public Overloads Overrides Sub read__(ByVal is__ As IceInternal.BasicStream, "
+ "ByVal rid__ As Boolean)";
+ _out.inc();
+ _out << nl << "If rid__ Then";
+ _out.inc();
+ _out << nl << "Dim myId As String = is__.readTypeId()";
+ _out.dec();
+ _out << nl << "End If";
+ _out << nl << "is__.startReadSlice()";
+ DataMemberList classMembers = p->classDataMembers();
+ int classMemberCount = static_cast<int>(allClassMembers.size() - classMembers.size());
+ for(d = members.begin(); d != members.end(); ++d)
+ {
+ ostringstream patchParams;
+ patchParams << "Me";
+ 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)->name(), DotNet::ICloneable, true),
+ false, false, false, patchParams.str());
+ }
+ _out << nl << "is__.endReadSlice()";
+ _out << nl << "MyBase.read__(is__, true)";
+ _out.dec();
+ _out << nl << "End Sub";
+
+ //
+ // Write streaming API.
+ //
+ if(_stream)
+ {
+ _out << sp << nl << "Public Overloads Overrides Sub write__(ByVal outS__ As Ice.OutputStream)";
+ _out.inc();
+ _out << nl << "outS__.writeTypeId(ice_staticId())";
+ _out << nl << "outS__.startSlice()";
+ for(d = members.begin(); d != members.end(); ++d)
+ {
+ writeMarshalUnmarshalCode(_out, (*d)->type(),
+ fixId((*d)->name(), DotNet::ICloneable, true),
+ true, true, false);
+ }
+ _out << nl << "outS__.endSlice()";
+ _out << nl << "MyBase.write__(outS__)";
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public Overloads Overrides Sub read__"
+ << "(ByVal inS__ As Ice.InputStream, ByVal rid__ As Boolean)";
+ _out.inc();
+ _out << nl << "If rid__ Then";
+ _out.inc();
+ _out << nl << "Dim myId As String = inS__.readTypeId()";
+ _out.dec();
+ _out << nl << "End If";
+ _out << nl << "inS__.startSlice()";
+ for(d = members.begin(); d != members.end(); ++d)
+ {
+ ostringstream patchParams;
+ patchParams << "Me";
+ 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)->name(), DotNet::ICloneable, true),
+ false, true, false, patchParams.str());
+ }
+ _out << nl << "inS__.endSlice()";
+ _out << nl << "MyBase.read__(inS__, True)";
+ _out.dec();
+ _out << nl << "End Sub";
+ }
+ else
+ {
+ //
+ // Emit placeholder functions to catch errors.
+ //
string scoped = p->scoped();
- _out << sp << nl << "Public Overloads Overrides Sub write__(ByVal outS__ As Ice.OutputStream)";
- _out.inc();
- _out << nl << "Dim ex As Ice.MarshalException = New Ice.MarshalException";
- _out << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\"";
- _out << nl << "Throw ex";
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public Overloads Overrides Sub read__"
- << "(ByVal inS__ As Ice.InputStream, ByVal rid__ As Boolean)";
- _out.inc();
- _out << nl << "Dim ex As Ice.MarshalException = New Ice.MarshalException";
- _out << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\"";
- _out << nl << "Throw ex";
- _out.dec();
- _out << nl << "End Sub";
- }
-
- _out.zeroIndent();
- _out << sp << nl << "#End Region"; // Marshalling support
- _out.restoreIndent();
+ _out << sp << nl << "Public Overloads Overrides Sub write__(ByVal outS__ As Ice.OutputStream)";
+ _out.inc();
+ _out << nl << "Dim ex As Ice.MarshalException = New Ice.MarshalException";
+ _out << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\"";
+ _out << nl << "Throw ex";
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public Overloads Overrides Sub read__"
+ << "(ByVal inS__ As Ice.InputStream, ByVal rid__ As Boolean)";
+ _out.inc();
+ _out << nl << "Dim ex As Ice.MarshalException = New Ice.MarshalException";
+ _out << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\"";
+ _out << nl << "Throw ex";
+ _out.dec();
+ _out << nl << "End Sub";
+ }
+
+ _out.zeroIndent();
+ _out << sp << nl << "#End Region"; // Marshalling support
+ _out.restoreIndent();
}
_out.dec();
@@ -1559,17 +1559,17 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p)
if(!amd)
{
- params = getParams(p);
- args = getArgs(p);
- name = fixId(name, DotNet::ICloneable, true);
- ret = p->returnType();
- retS = typeToString(ret);
+ params = getParams(p);
+ args = getArgs(p);
+ name = fixId(name, DotNet::ICloneable, true);
+ ret = p->returnType();
+ retS = typeToString(ret);
}
else
{
- params = getParamsAsync(p, true);
- args = getArgsAsync(p);
- name = name + "_async";
+ params = getParamsAsync(p, true);
+ args = getArgsAsync(p);
+ name = name + "_async";
}
string vbOp = ret ? "Function" : "Sub";
@@ -1589,26 +1589,26 @@ Slice::Gen::TypesVisitor::visitOperation(const OperationPtr& p)
_out << " Implements " << classDef->name() << "OperationsNC_." << name;
if(!isLocal)
{
- _out.inc();
- _out << nl;
- if(!amd && p->returnType())
- {
- _out << "Return ";
- }
- _out << name << spar << args << "Ice.ObjectImpl.defaultCurrent" << epar;
- _out.dec();
- _out << nl << "End " << vbOp;
+ _out.inc();
+ _out << nl;
+ if(!amd && p->returnType())
+ {
+ _out << "Return ";
+ }
+ _out << name << spar << args << "Ice.ObjectImpl.defaultCurrent" << epar;
+ _out.dec();
+ _out << nl << "End " << vbOp;
}
if(!isLocal)
{
- _out << sp << nl << "Public MustOverride " << vbOp << ' ' << name
- << spar << params << "ByVal current__ As Ice.Current" << epar;
- if(ret)
- {
- _out << " As " << retS;
- }
- _out << " Implements " << classDef->name() << "Operations_." << name;
+ _out << sp << nl << "Public MustOverride " << vbOp << ' ' << name
+ << spar << params << "ByVal current__ As Ice.Current" << epar;
+ if(ret)
+ {
+ _out << " As " << retS;
+ }
+ _out << " Implements " << classDef->name() << "Operations_." << name;
}
}
@@ -2011,14 +2011,14 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
_out.inc();
if(!isValue)
{
- _out << nl << "If Not InnerList(i) Is Nothing Then";
- _out.inc();
+ _out << nl << "If Not InnerList(i) Is Nothing Then";
+ _out.inc();
}
_out << nl << "hash = 5 * hash + InnerList(i).GetHashCode()";
if(!isValue)
{
- _out.dec();
- _out << nl << "End If";
+ _out.dec();
+ _out << nl << "End If";
}
_out.dec();
_out << nl << "Next";
@@ -2047,16 +2047,16 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
_out.inc();
if(!isValue)
{
- _out << nl << "If InnerList(i__) Is Nothing Then";
- _out.inc();
- _out << nl << "If Not CType(other, " << name << ")(i__) Is Nothing Then";
- _out.inc();
- _out << nl << "Return False";
- _out.dec();
- _out << nl << "End If";
- _out.dec();
- _out << nl << "Else";
- _out.inc();
+ _out << nl << "If InnerList(i__) Is Nothing Then";
+ _out.inc();
+ _out << nl << "If Not CType(other, " << name << ")(i__) Is Nothing Then";
+ _out.inc();
+ _out << nl << "Return False";
+ _out.dec();
+ _out << nl << "End If";
+ _out.dec();
+ _out << nl << "Else";
+ _out.inc();
}
_out << nl << "If Not InnerList(i__).Equals(CType(other, " << name << ")(i__)) Then";
_out.inc();
@@ -2067,7 +2067,7 @@ Slice::Gen::TypesVisitor::visitSequence(const SequencePtr& p)
if(!isValue)
{
_out.dec();
- _out << nl << "End If";
+ _out << nl << "End If";
}
_out << nl << "Next";
_out << nl << "Return True";
@@ -2106,9 +2106,9 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
if(!p->dataMembers().empty())
{
- _out.zeroIndent();
- _out << sp << nl << "#Region \"Slice data members\"";
- _out.restoreIndent();
+ _out.zeroIndent();
+ _out << sp << nl << "#Region \"Slice data members\"";
+ _out.restoreIndent();
}
return true;
@@ -2124,9 +2124,9 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
if(!dataMembers.empty())
{
- _out.zeroIndent();
- _out << sp << nl << "#End Region"; // Slice data members
- _out.restoreIndent();
+ _out.zeroIndent();
+ _out << sp << nl << "#End Region"; // Slice data members
+ _out.restoreIndent();
}
_out.zeroIndent();
@@ -2171,19 +2171,19 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
string memberName = fixId((*q)->name(), DotNet::ApplicationException);
- bool isValue = isValueType((*q)->type());
- if(!isValue)
- {
- _out << nl << "If Not " << memberName << " Is Nothing Then";
- _out.inc();
- }
- _out << nl << "h__ = 5 * h__ + ";
- invokeObjectMethod((*q)->type(), memberName, "GetHashCode", "");
- if(!isValue)
- {
- _out.dec();
- _out << nl << "End If";
- }
+ bool isValue = isValueType((*q)->type());
+ if(!isValue)
+ {
+ _out << nl << "If Not " << memberName << " Is Nothing Then";
+ _out.inc();
+ }
+ _out << nl << "h__ = 5 * h__ + ";
+ invokeObjectMethod((*q)->type(), memberName, "GetHashCode", "");
+ if(!isValue)
+ {
+ _out.dec();
+ _out << nl << "End If";
+ }
}
_out << nl << "Return h__";
_out.dec();
@@ -2209,33 +2209,33 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
string memberName = fixId((*q)->name(), DotNet::ApplicationException);
- bool isValue = isValueType((*q)->type());
-
- if(!isValue)
- {
- _out << nl << "If " << memberName << " Is Nothing Then";
- _out.inc();
- _out << nl << "If Not (CType(other__, " + name + "))." << memberName << " Is Nothing";
- _out.inc();
- _out << nl << "Return False";
- _out.dec();
- _out << nl << "End If";
- _out.dec();
- _out << nl << "Else";
- _out.inc();
- }
- _out << nl << "If Not ";
- invokeObjectMethod((*q)->type(), memberName, "Equals", "CType(other__, " + name + ")." + memberName);
- _out << " Then";
- _out.inc();
- _out << nl << "Return False";
- _out.dec();
- _out << nl << "End If";
- if(!isValue)
- {
- _out.dec();
- _out << nl << "End If";
- }
+ bool isValue = isValueType((*q)->type());
+
+ if(!isValue)
+ {
+ _out << nl << "If " << memberName << " Is Nothing Then";
+ _out.inc();
+ _out << nl << "If Not (CType(other__, " + name + "))." << memberName << " Is Nothing";
+ _out.inc();
+ _out << nl << "Return False";
+ _out.dec();
+ _out << nl << "End If";
+ _out.dec();
+ _out << nl << "Else";
+ _out.inc();
+ }
+ _out << nl << "If Not ";
+ invokeObjectMethod((*q)->type(), memberName, "Equals", "CType(other__, " + name + ")." + memberName);
+ _out << " Then";
+ _out.inc();
+ _out << nl << "Return False";
+ _out.dec();
+ _out << nl << "End If";
+ if(!isValue)
+ {
+ _out.dec();
+ _out << nl << "End If";
+ }
}
_out << nl << "Return True";
_out.dec();
@@ -2247,9 +2247,9 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
if(!p->isLocal())
{
- _out.zeroIndent();
+ _out.zeroIndent();
_out << sp << nl << "#Region \"Marshaling support\"";
- _out.restoreIndent();
+ _out.restoreIndent();
string scoped = p->scoped();
ExceptionPtr base = p->base();
@@ -2257,221 +2257,221 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
_out << sp << nl << "Public Overloads Overrides Sub write__(ByVal os__ As IceInternal.BasicStream)";
_out.inc();
- _out << nl << "os__.writeString(\"" << scoped << "\")";
- _out << nl << "os__.startWriteSlice()";
+ _out << nl << "os__.writeString(\"" << scoped << "\")";
+ _out << nl << "os__.startWriteSlice()";
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
writeMarshalUnmarshalCode(_out, (*q)->type(),
- fixId((*q)->name(), DotNet::ApplicationException),
- true, false, false);
+ fixId((*q)->name(), DotNet::ApplicationException),
+ true, false, false);
}
- _out << nl << "os__.endWriteSlice()";
+ _out << nl << "os__.endWriteSlice()";
if(base)
{
_out << nl << "MyBase.write__(os__)";
}
- _out.dec();
- _out << nl << "End Sub";
-
- DataMemberList allClassMembers = p->allClassDataMembers();
- if(allClassMembers.size() != 0)
- {
- _out << sp << nl << "Public Shadows NotInheritable Class Patcher__";
- _out.inc();
- _out << nl << "Inherits IceInternal.Patcher";
- _out << sp << nl << "Friend Sub New(ByVal instance As Ice.Exception";
- if(allClassMembers.size() > 1)
- {
- _out << ", ByVal member As Integer";
- }
- _out << ')';
- _out.inc();
- _out << nl << "_instance = CType(instance, " << name << ')';
- if(allClassMembers.size() > 1)
- {
- _out << nl << "_member = member";
- }
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public Overrides Sub patch(ByVal v As Ice.Object)";
- _out.inc();
- _out << nl << "Try";
- _out.inc();
- if(allClassMembers.size() > 1)
- {
- _out << nl << "Select Case _member";
- _out.inc();
- }
- int memberCount = 0;
- for(q = allClassMembers.begin(); q != allClassMembers.end(); ++q)
- {
- if(allClassMembers.size() > 1)
- {
- _out << nl << "Case " << memberCount;
- _out.inc();
- }
- string memberName = fixId((*q)->name(), DotNet::ApplicationException);
- string memberType = typeToString((*q)->type());
- _out << nl << "type_ = GetType(" << memberType << ')';
- _out << nl << "_instance." << memberName << " = CType(v, " << memberType << ')';
- _out << nl << "_typeId = \"" << (*q)->type()->typeId() << "\"";
- if(allClassMembers.size() > 1)
- {
- _out.dec();
- }
- memberCount++;
- }
- if(allClassMembers.size() > 1)
- {
- _out.dec();
- _out << nl << "End Select";
- }
- _out.dec();
- _out << nl << "Catch _ex As System.InvalidCastException";
- _out.inc();
- _out << nl << "Dim _e As Ice.UnexpectedObjectException = New Ice.UnexpectedObjectException";
- _out << nl << "_e.type = v.ice_id()";
- _out << nl << "_e.expectedType = _typeId";
- _out << nl << "Throw _e";
- _out.dec();
- _out << nl << "End Try";
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Private _instance As " << name;
- if(allClassMembers.size() > 1)
- {
- _out << nl << "Private _member As Integer";
- }
- _out << nl << "Private _typeId As String";
- _out.dec();
- _out << sp << nl << "End Class";
- }
+ _out.dec();
+ _out << nl << "End Sub";
+
+ DataMemberList allClassMembers = p->allClassDataMembers();
+ if(allClassMembers.size() != 0)
+ {
+ _out << sp << nl << "Public Shadows NotInheritable Class Patcher__";
+ _out.inc();
+ _out << nl << "Inherits IceInternal.Patcher";
+ _out << sp << nl << "Friend Sub New(ByVal instance As Ice.Exception";
+ if(allClassMembers.size() > 1)
+ {
+ _out << ", ByVal member As Integer";
+ }
+ _out << ')';
+ _out.inc();
+ _out << nl << "_instance = CType(instance, " << name << ')';
+ if(allClassMembers.size() > 1)
+ {
+ _out << nl << "_member = member";
+ }
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public Overrides Sub patch(ByVal v As Ice.Object)";
+ _out.inc();
+ _out << nl << "Try";
+ _out.inc();
+ if(allClassMembers.size() > 1)
+ {
+ _out << nl << "Select Case _member";
+ _out.inc();
+ }
+ int memberCount = 0;
+ for(q = allClassMembers.begin(); q != allClassMembers.end(); ++q)
+ {
+ if(allClassMembers.size() > 1)
+ {
+ _out << nl << "Case " << memberCount;
+ _out.inc();
+ }
+ string memberName = fixId((*q)->name(), DotNet::ApplicationException);
+ string memberType = typeToString((*q)->type());
+ _out << nl << "type_ = GetType(" << memberType << ')';
+ _out << nl << "_instance." << memberName << " = CType(v, " << memberType << ')';
+ _out << nl << "_typeId = \"" << (*q)->type()->typeId() << "\"";
+ if(allClassMembers.size() > 1)
+ {
+ _out.dec();
+ }
+ memberCount++;
+ }
+ if(allClassMembers.size() > 1)
+ {
+ _out.dec();
+ _out << nl << "End Select";
+ }
+ _out.dec();
+ _out << nl << "Catch _ex As System.InvalidCastException";
+ _out.inc();
+ _out << nl << "Dim _e As Ice.UnexpectedObjectException = New Ice.UnexpectedObjectException";
+ _out << nl << "_e.type = v.ice_id()";
+ _out << nl << "_e.expectedType = _typeId";
+ _out << nl << "Throw _e";
+ _out.dec();
+ _out << nl << "End Try";
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Private _instance As " << name;
+ if(allClassMembers.size() > 1)
+ {
+ _out << nl << "Private _member As Integer";
+ }
+ _out << nl << "Private _typeId As String";
+ _out.dec();
+ _out << sp << nl << "End Class";
+ }
_out << sp << nl << "Public Overloads Overrides Sub read__(ByVal is__ As IceInternal.BasicStream, "
- "ByVal rid__ As Boolean)";
+ "ByVal rid__ As Boolean)";
_out.inc();
- _out << nl << "If rid__ Then";
- _out.inc();
- _out << nl << "Dim myId As String = is__.readString()";
- _out.dec();
- _out << nl << "End If";
- _out << nl << "is__.startReadSlice()";
- DataMemberList classMembers = p->classDataMembers();
- int classMemberCount = static_cast<int>(allClassMembers.size() - classMembers.size());
+ _out << nl << "If rid__ Then";
+ _out.inc();
+ _out << nl << "Dim myId As String = is__.readString()";
+ _out.dec();
+ _out << nl << "End If";
+ _out << nl << "is__.startReadSlice()";
+ DataMemberList classMembers = p->classDataMembers();
+ int classMemberCount = static_cast<int>(allClassMembers.size() - classMembers.size());
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- ostringstream patchParams;
- patchParams << "Me";
- 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++;
- }
- }
+ ostringstream patchParams;
+ patchParams << "Me";
+ 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::ApplicationException),
- false, false, false, patchParams.str());
+ fixId((*q)->name(), DotNet::ApplicationException),
+ false, false, false, patchParams.str());
}
- _out << nl << "is__.endReadSlice()";
+ _out << nl << "is__.endReadSlice()";
if(base)
{
_out << nl << "MyBase.read__(is__, true)";
}
_out.dec();
- _out << nl << "End Sub";
-
- if(_stream)
- {
- _out << sp << nl << "Public Overloads Overrides Sub write__(ByVal outS__ As Ice.OutputStream)";
- _out.inc();
- _out << nl << "outS__.writeString(\"" << scoped << "\")";
- _out << nl << "outS__.startSlice()";
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeMarshalUnmarshalCode(_out, (*q)->type(),
- fixId((*q)->name(), DotNet::ApplicationException),
- true, true, false);
- }
- _out << nl << "outS__.endSlice()";
- if(base)
- {
- _out << nl << "MyBase.write__(outS__)";
- }
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public Overloads Overrides Sub read__(ByVal inS__ As Ice.InputStream, "
- << "ByVal rid__ As Boolean)";
- _out.inc();
- _out << nl << "If rid__ Then";
- _out.inc();
- _out << nl << "Dim myId As String = inS__.readString()";
- _out.dec();
- _out << nl << "End If";
- _out << nl << "inS__.startSlice()";
- classMemberCount = static_cast<int>(allClassMembers.size() - classMembers.size());
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- ostringstream patchParams;
- patchParams << "Me";
- 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::ApplicationException),
- false, true, false, patchParams.str());
- }
- _out << nl << "inS__.endSlice()";
- if(base)
- {
- _out << nl << "MyBase.read__(inS__, true)";
- }
- _out.dec();
- _out << nl << "End Sub";
- }
- else
- {
- //
- // Emit placeholder functions to catch errors.
- //
- _out << sp << nl << "Public Overloads Overrides Sub write__(ByVal outS__ As Ice.OutputStream)";
- _out.inc();
- _out << nl << "Dim ex As Ice.MarshalException = New Ice.MarshalException";
- _out << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\"";
- _out << nl << "Throw ex";
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public Overloads Overrides Sub read__"
- << "(ByVal inS__ As Ice.InputStream, ByVal rid__ As Boolean)";
- _out.inc();
- _out << nl << "Dim ex As Ice.MarshalException = New Ice.MarshalException";
- _out << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\"";
- _out << nl << "Throw ex";
- _out.dec();
- _out << nl << "End Sub";
- }
-
- if(!base || base && !base->usesClasses())
- {
- _out << sp << nl << "Public Overrides Function usesClasses__() As Boolean";
- _out.inc();
- _out << nl << "Return True";
- _out.dec();
- _out << nl << "End Function";
- }
-
- _out.zeroIndent();
+ _out << nl << "End Sub";
+
+ if(_stream)
+ {
+ _out << sp << nl << "Public Overloads Overrides Sub write__(ByVal outS__ As Ice.OutputStream)";
+ _out.inc();
+ _out << nl << "outS__.writeString(\"" << scoped << "\")";
+ _out << nl << "outS__.startSlice()";
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeMarshalUnmarshalCode(_out, (*q)->type(),
+ fixId((*q)->name(), DotNet::ApplicationException),
+ true, true, false);
+ }
+ _out << nl << "outS__.endSlice()";
+ if(base)
+ {
+ _out << nl << "MyBase.write__(outS__)";
+ }
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public Overloads Overrides Sub read__(ByVal inS__ As Ice.InputStream, "
+ << "ByVal rid__ As Boolean)";
+ _out.inc();
+ _out << nl << "If rid__ Then";
+ _out.inc();
+ _out << nl << "Dim myId As String = inS__.readString()";
+ _out.dec();
+ _out << nl << "End If";
+ _out << nl << "inS__.startSlice()";
+ classMemberCount = static_cast<int>(allClassMembers.size() - classMembers.size());
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ ostringstream patchParams;
+ patchParams << "Me";
+ 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::ApplicationException),
+ false, true, false, patchParams.str());
+ }
+ _out << nl << "inS__.endSlice()";
+ if(base)
+ {
+ _out << nl << "MyBase.read__(inS__, true)";
+ }
+ _out.dec();
+ _out << nl << "End Sub";
+ }
+ else
+ {
+ //
+ // Emit placeholder functions to catch errors.
+ //
+ _out << sp << nl << "Public Overloads Overrides Sub write__(ByVal outS__ As Ice.OutputStream)";
+ _out.inc();
+ _out << nl << "Dim ex As Ice.MarshalException = New Ice.MarshalException";
+ _out << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\"";
+ _out << nl << "Throw ex";
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public Overloads Overrides Sub read__"
+ << "(ByVal inS__ As Ice.InputStream, ByVal rid__ As Boolean)";
+ _out.inc();
+ _out << nl << "Dim ex As Ice.MarshalException = New Ice.MarshalException";
+ _out << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\"";
+ _out << nl << "Throw ex";
+ _out.dec();
+ _out << nl << "End Sub";
+ }
+
+ if(!base || base && !base->usesClasses())
+ {
+ _out << sp << nl << "Public Overrides Function usesClasses__() As Boolean";
+ _out.inc();
+ _out << nl << "Return True";
+ _out.dec();
+ _out << nl << "End Function";
+ }
+
+ _out.zeroIndent();
_out << sp << nl << "#End Region"; // Marshalling support
- _out.restoreIndent();
+ _out.restoreIndent();
}
_out.dec();
@@ -2486,24 +2486,24 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p)
if(!p->isLocal() && _stream)
{
_out << sp << nl << "Public NotInheritable Class " << p->name() << "Helper";
- _out.inc();
+ _out.inc();
- _out << sp << nl << "Public Shared Sub write(ByVal outS__ As Ice.OutputStream, ByVal v__ As " << name << ')';
- _out.inc();
- _out << nl << "v__.ice_write(outS__)";
- _out.dec();
- _out << nl << "End Sub";
+ _out << sp << nl << "Public Shared Sub write(ByVal outS__ As Ice.OutputStream, ByVal v__ As " << name << ')';
+ _out.inc();
+ _out << nl << "v__.ice_write(outS__)";
+ _out.dec();
+ _out << nl << "End Sub";
- _out << sp << nl << "Public Shared Function read(ByVal inS__ As Ice.InputStream) As " << name;
- _out.inc();
- _out << nl << "Dim v__ As " << name << " = New " << name;
- _out << nl << "v__.ice_read(inS__)";
- _out << nl << "Return v__";
- _out.dec();
- _out << nl << "End Function";
+ _out << sp << nl << "Public Shared Function read(ByVal inS__ As Ice.InputStream) As " << name;
+ _out.inc();
+ _out << nl << "Dim v__ As " << name << " = New " << name;
+ _out << nl << "v__.ice_read(inS__)";
+ _out << nl << "Return v__";
+ _out.dec();
+ _out << nl << "End Function";
- _out.dec();
- _out << sp << nl << "End Class";
+ _out.dec();
+ _out << sp << nl << "End Class";
}
_out << sp;
@@ -2513,14 +2513,14 @@ Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p)
emitAttributes(p);
if(isValueType(p))
{
- _out << nl << "Public Structure " << name;
+ _out << nl << "Public Structure " << name;
}
else
{
- _out << nl << "Public Class " << name;
- _out.inc();
- _out << nl << " Implements _System.ICloneable";
- _out.dec();
+ _out << nl << "Public Class " << name;
+ _out.inc();
+ _out << nl << " Implements _System.ICloneable";
+ _out.dec();
}
_out.inc();
@@ -2556,7 +2556,7 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
if(isClass)
{
_out << sp << nl << "Public Sub New()";
- _out << nl << "End Sub";
+ _out << nl << "End Sub";
}
_out << sp << nl << "Public Sub New" << spar;
@@ -2565,9 +2565,9 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
string memberName = fixId((*q)->name());
- string memberType = typeToString((*q)->type());
- paramDecl.push_back("ByVal " + memberName + " As " + memberType);
- paramNames.push_back(memberName);
+ string memberType = typeToString((*q)->type());
+ paramDecl.push_back("ByVal " + memberName + " As " + memberType);
+ paramNames.push_back(memberName);
}
_out << paramDecl << epar;
_out.inc();
@@ -2584,19 +2584,19 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
if(isClass)
{
- _out.zeroIndent();
- _out << sp << nl << "#Region \"ICloneable members\"";
- _out.restoreIndent();
+ _out.zeroIndent();
+ _out << sp << nl << "#Region \"ICloneable members\"";
+ _out.restoreIndent();
- _out << sp << nl << "Function Clone() As Object Implements _System.ICloneable.Clone";
- _out.inc();
- _out << nl << "Return MemberwiseClone()";
- _out.dec();
- _out << nl << "End Function";
+ _out << sp << nl << "Function Clone() As Object Implements _System.ICloneable.Clone";
+ _out.inc();
+ _out << nl << "Return MemberwiseClone()";
+ _out.dec();
+ _out << nl << "End Function";
- _out.zeroIndent();
- _out << sp << nl << "#End Region"; // ICloneable members
- _out.restoreIndent();
+ _out.zeroIndent();
+ _out << sp << nl << "#End Region"; // ICloneable members
+ _out.restoreIndent();
}
_out.zeroIndent();
@@ -2609,19 +2609,19 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
- bool isValue = isValueType((*q)->type());
- if(!isValue)
- {
- _out << nl << "If Not " << memberName << " Is Nothing Then";
- _out.inc();
- }
- _out << nl << "h__ = 5 * h__ + ";
- invokeObjectMethod((*q)->type(), memberName, "GetHashCode", "");
- if(!isValue)
- {
- _out.dec();
- _out << nl << "End If";
- }
+ bool isValue = isValueType((*q)->type());
+ if(!isValue)
+ {
+ _out << nl << "If Not " << memberName << " Is Nothing Then";
+ _out.inc();
+ }
+ _out << nl << "h__ = 5 * h__ + ";
+ invokeObjectMethod((*q)->type(), memberName, "GetHashCode", "");
+ if(!isValue)
+ {
+ _out.dec();
+ _out << nl << "End If";
+ }
}
_out << nl << "Return h__";
_out.dec();
@@ -2631,27 +2631,27 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
_out.inc();
if(isClass)
{
- _out << nl << "If Object.ReferenceEquals(Me, other__) Then";
- _out.inc();
- _out << nl << "Return True";
- _out.dec();
- _out << nl << "End If";
+ _out << nl << "If Object.ReferenceEquals(Me, other__) Then";
+ _out.inc();
+ _out << nl << "Return True";
+ _out.dec();
+ _out << nl << "End If";
}
if(isClass)
{
_out << nl << "If other__ Is Nothing Then";
- _out.inc();
- _out << nl << "Return False";
- _out.dec();
- _out << nl << "End If";
+ _out.inc();
+ _out << nl << "Return False";
+ _out.dec();
+ _out << nl << "End If";
}
else
{
- _out << nl << "If Not TypeOf other__ Is " << name << " Then";
- _out.inc();
- _out << nl << "Return False";
- _out.dec();
- _out << nl << "End If";
+ _out << nl << "If Not TypeOf other__ Is " << name << " Then";
+ _out.inc();
+ _out << nl << "Return False";
+ _out.dec();
+ _out << nl << "End If";
}
if(!dataMembers.empty())
{
@@ -2660,36 +2660,36 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
- if(!isValueType((*q)->type()))
- {
- _out << nl << "If " << memberName << " Is Nothing Then";
- _out.inc();
- _out << nl << "If Not o__." << memberName << " Is Nothing Then";
- _out.inc();
- _out << nl << "Return False";
- _out.dec();
- _out << nl << "End If";
- _out.dec();
- _out << nl << "Else";
- _out.inc();
- _out << nl << "If Not ";
- invokeObjectMethod((*q)->type(), memberName, "Equals", "o__." + memberName);
- _out << " Then";
- _out.inc();
- _out << nl << "Return False";
- _out.dec();
- _out << nl << "End If";
- _out.dec();
- _out << nl << "End If";
- }
- else
- {
- _out << nl << "If Not " << memberName << ".Equals(o__." << memberName << ") Then";
- _out.inc();
- _out << nl << "Return False";
- _out.dec();
- _out << nl << "End If";
- }
+ if(!isValueType((*q)->type()))
+ {
+ _out << nl << "If " << memberName << " Is Nothing Then";
+ _out.inc();
+ _out << nl << "If Not o__." << memberName << " Is Nothing Then";
+ _out.inc();
+ _out << nl << "Return False";
+ _out.dec();
+ _out << nl << "End If";
+ _out.dec();
+ _out << nl << "Else";
+ _out.inc();
+ _out << nl << "If Not ";
+ invokeObjectMethod((*q)->type(), memberName, "Equals", "o__." + memberName);
+ _out << " Then";
+ _out.inc();
+ _out << nl << "Return False";
+ _out.dec();
+ _out << nl << "End If";
+ _out.dec();
+ _out << nl << "End If";
+ }
+ else
+ {
+ _out << nl << "If Not " << memberName << ".Equals(o__." << memberName << ") Then";
+ _out.inc();
+ _out << nl << "Return False";
+ _out.dec();
+ _out << nl << "End If";
+ }
}
_out << nl << "Return True";
_out.dec();
@@ -2701,158 +2701,158 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
if(!p->isLocal())
{
- _out.zeroIndent();
+ _out.zeroIndent();
_out << sp << nl << "#Region \"Marshalling support\"";
- _out.restoreIndent();
+ _out.restoreIndent();
_out << sp << nl << "Public Sub write__(ByVal os__ As IceInternal.BasicStream)";
_out.inc();
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeMarshalUnmarshalCode(_out, (*q)->type(),
- fixId((*q)->name(), isClass ? DotNet::ICloneable : 0),
- true, false, false);
- }
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeMarshalUnmarshalCode(_out, (*q)->type(),
+ fixId((*q)->name(), isClass ? DotNet::ICloneable : 0),
+ true, false, false);
+ }
_out.dec();
- _out << nl << "End Sub";
-
-
- if(isClass && classMembers.size() != 0)
- {
- _out << sp << nl << "Public NotInheritable Class Patcher__";
- _out.inc();
- _out << nl << "Inherits IceInternal.Patcher";
- _out << sp << nl << "Friend Sub New(ByVal instance As " << name;
- if(classMembers.size() > 1)
- {
- _out << ", ByVal member As Integer";
- }
- _out << ')';
- _out.inc();
- _out << nl << "_instance = instance";
- if(classMembers.size() > 1)
- {
- _out << nl << "_member = member";
- }
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public Overrides Sub patch(ByVal v As Ice.Object)";
- _out.inc();
- _out << nl << "Try";
- _out.inc();
- if(classMembers.size() > 1)
- {
- _out << nl << "Select Case _member";
- _out.inc();
- }
- int memberCount = 0;
- for(q = classMembers.begin(); q != classMembers.end(); ++q)
- {
- if(classMembers.size() > 1)
- {
- _out << nl << "Case " << memberCount;
- _out.inc();
- }
- string memberType = typeToString((*q)->type());
- string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
- _out << nl << "type_ = GetType(" << memberType << ')';
- _out << nl << "_instance." << memberName << " = CType(v, " << memberType << ')';
- _out << nl << "_typeId = \"" << (*q)->type()->typeId() << "\"";
- if(classMembers.size() > 1)
- {
- _out.dec();
- }
- memberCount++;
- }
- if(classMembers.size() > 1)
- {
- _out.dec();
- _out << nl << "End Select";
- }
- _out.dec();
- _out << nl << "Catch _ex As System.InvalidCastException";
- _out.inc();
- _out << nl << "Dim _e As Ice.UnexpectedObjectException = New Ice.UnexpectedObjectException";
- _out << nl << "_e.type = v.ice_id()";
- _out << nl << "_e.expectedType = _typeId";
- _out << nl << "Throw _e";
- _out.dec();
- _out << nl << "End Try";
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Private _instance As " << name;
- if(classMembers.size() > 1)
- {
- _out << nl << "Private _member As Integer";
- }
- _out << nl << "Private _typeId As String";
- _out.dec();
- _out << sp << nl << "End Class";
- }
+ _out << nl << "End Sub";
+
+
+ if(isClass && classMembers.size() != 0)
+ {
+ _out << sp << nl << "Public NotInheritable Class Patcher__";
+ _out.inc();
+ _out << nl << "Inherits IceInternal.Patcher";
+ _out << sp << nl << "Friend Sub New(ByVal instance As " << name;
+ if(classMembers.size() > 1)
+ {
+ _out << ", ByVal member As Integer";
+ }
+ _out << ')';
+ _out.inc();
+ _out << nl << "_instance = instance";
+ if(classMembers.size() > 1)
+ {
+ _out << nl << "_member = member";
+ }
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public Overrides Sub patch(ByVal v As Ice.Object)";
+ _out.inc();
+ _out << nl << "Try";
+ _out.inc();
+ if(classMembers.size() > 1)
+ {
+ _out << nl << "Select Case _member";
+ _out.inc();
+ }
+ int memberCount = 0;
+ for(q = classMembers.begin(); q != classMembers.end(); ++q)
+ {
+ if(classMembers.size() > 1)
+ {
+ _out << nl << "Case " << memberCount;
+ _out.inc();
+ }
+ string memberType = typeToString((*q)->type());
+ string memberName = fixId((*q)->name(), isClass ? DotNet::ICloneable : 0);
+ _out << nl << "type_ = GetType(" << memberType << ')';
+ _out << nl << "_instance." << memberName << " = CType(v, " << memberType << ')';
+ _out << nl << "_typeId = \"" << (*q)->type()->typeId() << "\"";
+ if(classMembers.size() > 1)
+ {
+ _out.dec();
+ }
+ memberCount++;
+ }
+ if(classMembers.size() > 1)
+ {
+ _out.dec();
+ _out << nl << "End Select";
+ }
+ _out.dec();
+ _out << nl << "Catch _ex As System.InvalidCastException";
+ _out.inc();
+ _out << nl << "Dim _e As Ice.UnexpectedObjectException = New Ice.UnexpectedObjectException";
+ _out << nl << "_e.type = v.ice_id()";
+ _out << nl << "_e.expectedType = _typeId";
+ _out << nl << "Throw _e";
+ _out.dec();
+ _out << nl << "End Try";
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Private _instance As " << name;
+ if(classMembers.size() > 1)
+ {
+ _out << nl << "Private _member As Integer";
+ }
+ _out << nl << "Private _typeId As String";
+ _out.dec();
+ _out << sp << nl << "End Class";
+ }
_out << sp << nl << "Public Sub read__(ByVal is__ As IceInternal.BasicStream)";
_out.inc();
- int classMemberCount = 0;
+ int classMemberCount = 0;
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- ostringstream patchParams;
- patchParams << "Me";
- BuiltinPtr builtin = BuiltinPtr::dynamicCast((*q)->type());
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*q)->type()))
- {
- if(classMembers.size() > 1)
- {
- patchParams << ", " << classMemberCount++;
- }
- }
+ ostringstream patchParams;
+ patchParams << "Me";
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast((*q)->type());
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*q)->type()))
+ {
+ if(classMembers.size() > 1)
+ {
+ patchParams << ", " << classMemberCount++;
+ }
+ }
writeMarshalUnmarshalCode(_out, (*q)->type(),
- fixId((*q)->name(), isClass ? DotNet::ICloneable : 0),
- false, false, false, patchParams.str());
+ fixId((*q)->name(), isClass ? DotNet::ICloneable : 0),
+ false, false, false, patchParams.str());
}
_out.dec();
- _out << nl << "End Sub";
-
- if(_stream)
- {
- _out << sp << nl << "Public Sub ice_write(ByVal outS__ As Ice.OutputStream)";
- _out.inc();
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- writeMarshalUnmarshalCode(_out, (*q)->type(),
- fixId((*q)->name(), isClass ? DotNet::ICloneable : 0),
- true, true, false);
- }
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public Sub ice_read(ByVal inS__ As Ice.InputStream)";
- _out.inc();
- classMemberCount = 0;
- for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
- {
- ostringstream patchParams;
- patchParams << "Me";
- BuiltinPtr builtin = BuiltinPtr::dynamicCast((*q)->type());
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*q)->type()))
- {
- if(classMembers.size() > 1)
- {
- patchParams << ", " << classMemberCount++;
- }
- }
- writeMarshalUnmarshalCode(_out, (*q)->type(),
- fixId((*q)->name(), isClass ? DotNet::ICloneable : 0 ),
- false, true, false, patchParams.str());
- }
- _out.dec();
- _out << nl << "End Sub";
- }
-
- _out.zeroIndent();
+ _out << nl << "End Sub";
+
+ if(_stream)
+ {
+ _out << sp << nl << "Public Sub ice_write(ByVal outS__ As Ice.OutputStream)";
+ _out.inc();
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ writeMarshalUnmarshalCode(_out, (*q)->type(),
+ fixId((*q)->name(), isClass ? DotNet::ICloneable : 0),
+ true, true, false);
+ }
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public Sub ice_read(ByVal inS__ As Ice.InputStream)";
+ _out.inc();
+ classMemberCount = 0;
+ for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
+ {
+ ostringstream patchParams;
+ patchParams << "Me";
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast((*q)->type());
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*q)->type()))
+ {
+ if(classMembers.size() > 1)
+ {
+ patchParams << ", " << classMemberCount++;
+ }
+ }
+ writeMarshalUnmarshalCode(_out, (*q)->type(),
+ fixId((*q)->name(), isClass ? DotNet::ICloneable : 0 ),
+ false, true, false, patchParams.str());
+ }
+ _out.dec();
+ _out << nl << "End Sub";
+ }
+
+ _out.zeroIndent();
_out << sp << nl << "#End Region"; // Marshalling support
- _out.restoreIndent();
+ _out.restoreIndent();
}
_out.dec();
@@ -3045,14 +3045,14 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
_out << nl << "hash = 5 * hash + e.Key.GetHashCode()";
if(!valueIsValue)
{
- _out << nl << "If Not e.Value Is Nothing";
- _out.inc();
+ _out << nl << "If Not e.Value Is Nothing";
+ _out.inc();
}
_out << nl << "hash = 5 * hash + e.Value.GetHashCode()";
if(!valueIsValue)
{
- _out.dec();
- _out << nl << "End If";
+ _out.dec();
+ _out << nl << "End If";
}
_out.dec();
_out << nl << "Next";
@@ -3096,22 +3096,22 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
bool valueIsArray = seq && !seq->hasMetaData("clr:collection");
if(valueIsArray)
{
- _out << nl << "Dim vlhs__ As " << vs << "() = New " << toArrayAlloc(vs + "()", "Count - 1") << " {}";
+ _out << nl << "Dim vlhs__ As " << vs << "() = New " << toArrayAlloc(vs + "()", "Count - 1") << " {}";
}
else
{
- _out << nl << "Dim vlhs__ As " << vs << "() = New " << vs << "(Count - 1) {}";
+ _out << nl << "Dim vlhs__ As " << vs << "() = New " << vs << "(Count - 1) {}";
}
_out << nl << "Values.CopyTo(vlhs__, 0)";
_out << nl << "_System.Array.Sort(vlhs__)";
string vrhsCount = "Ctype(other, " + name + ").Count - 1";
if(valueIsArray)
{
- _out << nl << "Dim vrhs__ As " << vs << "() = New " << toArrayAlloc(vs + "()", vrhsCount) << " {}";
+ _out << nl << "Dim vrhs__ As " << vs << "() = New " << toArrayAlloc(vs + "()", vrhsCount) << " {}";
}
else
{
- _out << nl << "Dim vrhs__ As " << vs << "() = New " << vs << '(' << vrhsCount << ") {}";
+ _out << nl << "Dim vrhs__ As " << vs << "() = New " << vs << '(' << vrhsCount << ") {}";
}
_out << nl << "CType(other, " << name << ").Values.CopyTo(vrhs__, 0)";
_out << nl << "_System.Array.Sort(vrhs__)";
@@ -3119,29 +3119,29 @@ Slice::Gen::TypesVisitor::visitDictionary(const DictionaryPtr& p)
_out.inc();
if(!valueIsValue)
{
- _out << nl << "If vlhs__(i) Is Nothing";
- _out.inc();
- _out << nl << "If Not vrhs__(i) Is Nothing";
- _out.inc();
- _out << nl << "Return False";
- _out.dec();
- _out << nl << "End If";
- _out.dec();
- _out << nl << "ElseIf Not CType(vlhs__(i), Object).Equals(vrhs__(i)) Then";
- _out.inc();
- _out << nl << "Return False";
- _out.dec();
- _out << nl << "End If";
- _out.dec();
+ _out << nl << "If vlhs__(i) Is Nothing";
+ _out.inc();
+ _out << nl << "If Not vrhs__(i) Is Nothing";
+ _out.inc();
+ _out << nl << "Return False";
+ _out.dec();
+ _out << nl << "End If";
+ _out.dec();
+ _out << nl << "ElseIf Not CType(vlhs__(i), Object).Equals(vrhs__(i)) Then";
+ _out.inc();
+ _out << nl << "Return False";
+ _out.dec();
+ _out << nl << "End If";
+ _out.dec();
}
else
{
- _out << nl << "If Not vlhs__(i).Equals(vrhs__(i)) Then";
- _out.inc();
- _out << nl << "Return False";
- _out.dec();
- _out << nl << "End If";
- _out.dec();
+ _out << nl << "If Not vlhs__(i).Equals(vrhs__(i)) Then";
+ _out.inc();
+ _out << nl << "Return False";
+ _out.dec();
+ _out << nl << "End If";
+ _out.dec();
}
_out << nl << "Next";
_out << nl << "Return True";
@@ -3178,25 +3178,25 @@ Slice::Gen::TypesVisitor::visitEnum(const EnumPtr& p)
if(_stream)
{
- _out << sp << nl << "Public NotInheritable Class " << name << "Helper";
- _out.inc();
+ _out << sp << nl << "Public NotInheritable Class " << name << "Helper";
+ _out.inc();
- _out << sp << nl << "Public Shared Sub write(ByVal outS__ As Ice.OutputStream, ByVal v__ As " << scoped << ')';
- _out.inc();
- writeMarshalUnmarshalCode(_out, p, "v__", true, true, false);
- _out.dec();
- _out << nl << "End Sub";
+ _out << sp << nl << "Public Shared Sub write(ByVal outS__ As Ice.OutputStream, ByVal v__ As " << scoped << ')';
+ _out.inc();
+ writeMarshalUnmarshalCode(_out, p, "v__", true, true, false);
+ _out.dec();
+ _out << nl << "End Sub";
- _out << sp << nl << "Public Shared Function read(ByVal inS__ As Ice.InputStream) As " << scoped;
- _out.inc();
- _out << nl << "Dim v__ As " << scoped;
- writeMarshalUnmarshalCode(_out, p, "v__", false, true, false);
- _out << nl << "Return v__";
- _out.dec();
- _out << nl << "End Function";
+ _out << sp << nl << "Public Shared Function read(ByVal inS__ As Ice.InputStream) As " << scoped;
+ _out.inc();
+ _out << nl << "Dim v__ As " << scoped;
+ writeMarshalUnmarshalCode(_out, p, "v__", false, true, false);
+ _out << nl << "Return v__";
+ _out.dec();
+ _out << nl << "End Function";
- _out.dec();
- _out << sp << nl << "End Class";
+ _out.dec();
+ _out << sp << nl << "End Class";
}
}
@@ -3212,108 +3212,108 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
BuiltinPtr bp = BuiltinPtr::dynamicCast(p->type());
if(bp && bp->kind() == Builtin::KindString)
{
- static const string basicStringChars = "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789"
- "_{}[]#()<>%:;.?*+-/^&|~!=,\\\"' ";
- static const set<char> charSet(basicStringChars.begin(), basicStringChars.end());
-
- enum Position { Beginning, InString, NotInString };
- Position pos = Beginning;
-
- const string val = p->value();
- for(string::const_iterator c = val.begin(); c != val.end(); ++c)
- {
- if(charSet.find(*c) == charSet.end())
- {
- //
- // The character is something non-printable, such as a line feed,
- // so get it into the string literal using the VB Chr() function.
- //
- if(pos == InString)
- {
- _out << '"'; // Close previous string literal.
- pos = NotInString;
- }
- if(pos == NotInString)
- {
- _out << " + ";
- }
-
- //
- // char may be signed, so make it positive.
- //
- unsigned char uc = *c;
- _out << " + Chr(" << static_cast<unsigned>(uc) << ')';
-
- pos = NotInString;
- }
- else
- {
- if(pos == NotInString)
- {
- _out << " + ";
- pos = Beginning;
- }
- if(pos == Beginning)
- {
- _out << '"';
- }
-
- if(*c == '"')
- {
- _out << "\"\"";
- }
- else
- {
- _out << *c;
- }
-
- pos = InString;
- }
- }
- if(pos == InString)
- {
- _out << '"'; // Terminate final string literal.
- }
+ static const string basicStringChars = "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789"
+ "_{}[]#()<>%:;.?*+-/^&|~!=,\\\"' ";
+ static const set<char> charSet(basicStringChars.begin(), basicStringChars.end());
+
+ enum Position { Beginning, InString, NotInString };
+ Position pos = Beginning;
+
+ const string val = p->value();
+ for(string::const_iterator c = val.begin(); c != val.end(); ++c)
+ {
+ if(charSet.find(*c) == charSet.end())
+ {
+ //
+ // The character is something non-printable, such as a line feed,
+ // so get it into the string literal using the VB Chr() function.
+ //
+ if(pos == InString)
+ {
+ _out << '"'; // Close previous string literal.
+ pos = NotInString;
+ }
+ if(pos == NotInString)
+ {
+ _out << " + ";
+ }
+
+ //
+ // char may be signed, so make it positive.
+ //
+ unsigned char uc = *c;
+ _out << " + Chr(" << static_cast<unsigned>(uc) << ')';
+
+ pos = NotInString;
+ }
+ else
+ {
+ if(pos == NotInString)
+ {
+ _out << " + ";
+ pos = Beginning;
+ }
+ if(pos == Beginning)
+ {
+ _out << '"';
+ }
+
+ if(*c == '"')
+ {
+ _out << "\"\"";
+ }
+ else
+ {
+ _out << *c;
+ }
+
+ pos = InString;
+ }
+ }
+ if(pos == InString)
+ {
+ _out << '"'; // Terminate final string literal.
+ }
}
else if(bp && bp->kind() == Builtin::KindBool)
{
- string val = p->value();
- val[0] = toupper(val[0]);
- _out << val;
+ string val = p->value();
+ val[0] = toupper(val[0]);
+ _out << val;
}
else if(bp && bp->kind() == Builtin::KindShort)
{
- _out << p->value() << 'S';
+ _out << p->value() << 'S';
}
else if(bp && bp->kind() == Builtin::KindInt)
{
- _out << p->value() << 'I';
+ _out << p->value() << 'I';
}
else if(bp && bp->kind() == Builtin::KindLong)
{
- _out << p->value() << 'L';
+ _out << p->value() << 'L';
}
else if(bp && bp->kind() == Builtin::KindFloat)
{
- _out << p->value() << 'F';
+ _out << p->value() << 'F';
}
else if(bp && bp->kind() == Builtin::KindDouble)
{
- _out << p->value() << 'R';
+ _out << p->value() << 'R';
}
else
{
- EnumPtr ep = EnumPtr::dynamicCast(p->type());
- if(ep)
- {
- _out << fixId(typeToString(p->type())) << '.' << fixId(p->value());
- }
- else
- {
- _out << p->value(); // byte
- }
+ EnumPtr ep = EnumPtr::dynamicCast(p->type());
+ if(ep)
+ {
+ _out << fixId(typeToString(p->type())) << '.' << fixId(p->value());
+ }
+ else
+ {
+ _out << p->value(); // byte
+ }
}
_out.dec();
_out << sp << nl << "End Class";
@@ -3330,15 +3330,15 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
assert(cont);
if(StructPtr::dynamicCast(cont))
{
- isValue = isValueType(StructPtr::dynamicCast(cont));
- if(!isValue || cont->hasMetaData("clr:class"))
- {
- baseTypes = DotNet::ICloneable;
- }
- if(cont->hasMetaData("clr:property"))
- {
- propertyMapping = true;
- }
+ isValue = isValueType(StructPtr::dynamicCast(cont));
+ if(!isValue || cont->hasMetaData("clr:class"))
+ {
+ baseTypes = DotNet::ICloneable;
+ }
+ if(cont->hasMetaData("clr:property"))
+ {
+ propertyMapping = true;
+ }
}
else if(ExceptionPtr::dynamicCast(cont))
{
@@ -3346,12 +3346,12 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
}
else if(ClassDefPtr::dynamicCast(cont))
{
- baseTypes = DotNet::ICloneable;
- isClass = true;
- if(cont->hasMetaData("clr:property"))
- {
- propertyMapping = true;
- }
+ baseTypes = DotNet::ICloneable;
+ isClass = true;
+ if(cont->hasMetaData("clr:property"))
+ {
+ propertyMapping = true;
+ }
}
_out << sp;
@@ -3397,13 +3397,13 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
void
Slice::Gen::TypesVisitor::invokeObjectMethod(const TypePtr& type, const string& obj, const string& method,
- const string& arg)
+ const string& arg)
{
BuiltinPtr b = BuiltinPtr::dynamicCast(type);
ClassDeclPtr cl;
if(!b)
{
- cl = ClassDeclPtr::dynamicCast(type);
+ cl = ClassDeclPtr::dynamicCast(type);
}
//
@@ -3413,11 +3413,11 @@ Slice::Gen::TypesVisitor::invokeObjectMethod(const TypePtr& type, const string&
if((b && (b->kind() == Builtin::KindObject || b->kind() == Builtin::KindObjectProxy)) ||
(cl && cl->isInterface()) || ProxyPtr::dynamicCast(type))
{
- _out << "CType(" << obj << ", Object)." << method << '(' << arg << ')';
+ _out << "CType(" << obj << ", Object)." << method << '(' << arg << ')';
}
else
{
- _out << obj << '.' << method << '(' << arg << ')';
+ _out << obj << '.' << method << '(' << arg << ')';
}
}
@@ -3431,7 +3431,7 @@ Slice::Gen::ProxyVisitor::visitModuleStart(const ModulePtr& p)
{
if(!p->hasNonLocalClassDecls())
{
- return false;
+ return false;
}
_out << sp;
@@ -3453,7 +3453,7 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
{
if(p->isLocal())
{
- return false;
+ return false;
}
string name = p->name();
@@ -3468,15 +3468,15 @@ Slice::Gen::ProxyVisitor::visitClassDefStart(const ClassDefPtr& p)
}
else
{
- ClassList::const_iterator q = bases.begin();
- while(q != bases.end())
- {
- _out << fixId((*q)->scoped() + "Prx");
- if(++q != bases.end())
- {
- _out << ", ";
- }
- }
+ ClassList::const_iterator q = bases.begin();
+ while(q != bases.end())
+ {
+ _out << fixId((*q)->scoped() + "Prx");
+ if(++q != bases.end())
+ {
+ _out << ", ";
+ }
+ }
}
return true;
@@ -3505,11 +3505,11 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
string deprecateMetadata, deprecateReason;
if(p->findMetaData("deprecate", deprecateMetadata) || cl->findMetaData("deprecate", deprecateMetadata))
{
- deprecateReason = "This operation has been deprecated.";
- if(deprecateMetadata.find("deprecate:") == 0 && deprecateMetadata.size() > 10)
- {
- deprecateReason = deprecateMetadata.substr(10);
- }
+ deprecateReason = "This operation has been deprecated.";
+ if(deprecateMetadata.find("deprecate:") == 0 && deprecateMetadata.size() > 10)
+ {
+ deprecateReason = deprecateMetadata.substr(10);
+ }
}
//
@@ -3518,7 +3518,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
//
if(!deprecateReason.empty())
{
- _out << nl << "<System.Obsolete(\"" << deprecateReason << "\")>";
+ _out << nl << "<System.Obsolete(\"" << deprecateReason << "\")>";
}
_out << nl << vbOp << ' ' << name << spar << params << epar;
if(ret)
@@ -3528,7 +3528,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
if(!deprecateReason.empty())
{
- _out << nl << "<System.Obsolete(\"" << deprecateReason << "\")>";
+ _out << nl << "<System.Obsolete(\"" << deprecateReason << "\")>";
}
_out << nl << vbOp << ' ' << name << spar << params << "ByVal context__ As Ice.Context" << epar;
if(ret)
@@ -3540,21 +3540,21 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
{
vector<string> paramsAMI = getParamsAsync(p, false);
- //
- // Write two versions of the operation - with and without a
- // context parameter.
- //
- _out << sp;
- if(!deprecateReason.empty())
- {
- _out << nl << "<System.Obsolete(\"" << deprecateReason << "\")>";
- }
- _out << nl << "Sub " << p->name() << "_async" << spar << paramsAMI << epar;
- if(!deprecateReason.empty())
- {
- _out << nl << "<System.Obsolete(\"" << deprecateReason << "\")>";
- }
- _out << nl << "Sub " << p->name() << "_async" << spar << paramsAMI << "ByVal ctx__ As Ice.Context" << epar;
+ //
+ // Write two versions of the operation - with and without a
+ // context parameter.
+ //
+ _out << sp;
+ if(!deprecateReason.empty())
+ {
+ _out << nl << "<System.Obsolete(\"" << deprecateReason << "\")>";
+ }
+ _out << nl << "Sub " << p->name() << "_async" << spar << paramsAMI << epar;
+ if(!deprecateReason.empty())
+ {
+ _out << nl << "<System.Obsolete(\"" << deprecateReason << "\")>";
+ }
+ _out << nl << "Sub " << p->name() << "_async" << spar << paramsAMI << "ByVal ctx__ As Ice.Context" << epar;
}
}
@@ -3591,12 +3591,12 @@ Slice::Gen::OpsVisitor::visitClassDefStart(const ClassDefPtr& p)
//
if(!p->isAbstract())
{
- return false;
+ return false;
}
if(!p->isLocal())
{
- writeOperations(p, false);
+ writeOperations(p, false);
}
writeOperations(p, true);
@@ -3620,71 +3620,71 @@ Slice::Gen::OpsVisitor::writeOperations(const ClassDefPtr& p, bool noCurrent)
if((bases.size() == 1 && bases.front()->isAbstract()) || bases.size() > 1)
{
_out << nl << "Inherits ";
- ClassList::const_iterator q = bases.begin();
- bool first = true;
- while(q != bases.end())
- {
- if((*q)->isAbstract())
- {
- if(!first)
- {
- _out << ", ";
- }
- else
- {
- first = false;
- }
- string s = (*q)->scoped();
- s += "Operations";
- if(noCurrent)
- {
- s += "NC";
- }
- s += "_";
- _out << fixId(s);
- }
- ++q;
- }
+ ClassList::const_iterator q = bases.begin();
+ bool first = true;
+ while(q != bases.end())
+ {
+ if((*q)->isAbstract())
+ {
+ if(!first)
+ {
+ _out << ", ";
+ }
+ else
+ {
+ first = false;
+ }
+ string s = (*q)->scoped();
+ s += "Operations";
+ if(noCurrent)
+ {
+ s += "NC";
+ }
+ s += "_";
+ _out << fixId(s);
+ }
+ ++q;
+ }
}
OperationList ops = p->operations();
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
- OperationPtr op = *r;
- bool amd = !p->isLocal() && (p->hasMetaData("amd") || op->hasMetaData("amd"));
- string opname = amd ? (op->name() + "_async") : fixId(op->name(), DotNet::ICloneable, true);
+ OperationPtr op = *r;
+ bool amd = !p->isLocal() && (p->hasMetaData("amd") || op->hasMetaData("amd"));
+ string opname = amd ? (op->name() + "_async") : fixId(op->name(), DotNet::ICloneable, true);
- TypePtr ret;
- vector<string> params;
+ TypePtr ret;
+ vector<string> params;
- if(amd)
- {
- params = getParamsAsync(op, true);
- }
- else
- {
- params = getParams(op);
- ret = op->returnType();
- }
+ if(amd)
+ {
+ params = getParamsAsync(op, true);
+ }
+ else
+ {
+ params = getParams(op);
+ ret = op->returnType();
+ }
- string vbOp = ret ? "Function" : "Sub";
+ string vbOp = ret ? "Function" : "Sub";
- _out << sp;
+ _out << sp;
emitDeprecate(op, p, _out, "operation");
- emitAttributes(op);
- _out << nl << vbOp << ' ' << opname << spar << params;
- if(!noCurrent && !p->isLocal())
- {
- _out << "ByVal current__ As Ice.Current";
- }
- _out << epar;
- if(ret)
- {
- _out << " As " << typeToString(ret);
- }
+ emitAttributes(op);
+ _out << nl << vbOp << ' ' << opname << spar << params;
+ if(!noCurrent && !p->isLocal())
+ {
+ _out << "ByVal current__ As Ice.Current";
+ }
+ _out << epar;
+ if(ret)
+ {
+ _out << " As " << typeToString(ret);
+ }
}
_out.dec();
@@ -3735,178 +3735,178 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!ops.empty())
{
- _out.zeroIndent();
- _out << sp << nl << "#Region \"Synchronous operations\"";
- _out.restoreIndent();
+ _out.zeroIndent();
+ _out << sp << nl << "#Region \"Synchronous operations\"";
+ _out.restoreIndent();
}
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
OperationPtr op = *r;
- string opName = fixId(op->name(), DotNet::ICloneable, true);
- TypePtr ret = op->returnType();
- string retS = typeToString(ret);
+ string opName = fixId(op->name(), DotNet::ICloneable, true);
+ TypePtr ret = op->returnType();
+ string retS = typeToString(ret);
- vector<string> params = getParams(op);
- vector<string> args = getArgs(op);
+ vector<string> params = getParams(op);
+ vector<string> args = getArgs(op);
string vbOp = ret ? "Function" : "Sub";
- _out << sp << nl << "Public " << vbOp << ' ' << opName << spar << params << epar;
- if(ret)
- {
- _out << " As " << retS;
- }
- _out << " Implements " << name << "Prx." << opName;
- _out.inc();
- _out << nl;
- if(ret)
- {
- _out << "Return ";
- }
- _out << opName << spar << args << "Nothing" << "False" << epar;
- _out.dec();
- _out << nl << "End " << vbOp;
-
-
- _out << sp << nl << "Public " << vbOp << ' ' << opName << spar << params
- << "ByVal context__ As Ice.Context" << epar;
- if(ret)
- {
- _out << " As " << retS;
- }
- _out << " Implements " << name << "Prx." << opName;
- _out.inc();
- _out << nl;
- if(ret)
- {
- _out << "Return ";
- }
- _out << opName << spar << args << "context__" << "True" << epar;
- _out.dec();
- _out << nl << "End " << vbOp;
-
- _out << sp << nl << "Private " << vbOp << ' ' << opName << spar << params
- << "ByVal context__ As Ice.Context" << "explicitContext__ As Boolean" << epar;
- if(ret)
- {
- _out << " As " << retS;
- }
- _out.inc();
- _out << nl << "If explicitContext__ And context__ Is Nothing Then";
- _out.inc();
- _out << nl << "context__ = emptyContext_";
- _out.dec();
- _out << nl << "End If";
- _out << nl << "Dim cnt__ As Integer = 0";
- _out << nl << "While True";
- _out.inc();
- _out << nl << "Dim delBase__ As Ice.ObjectDel_ = Nothing";
- _out << nl << "Try";
- _out.inc();
- if(op->returnsData())
- {
- _out << nl << "checkTwowayOnly__(\"" << op->name() << "\")";
- }
- _out << nl << "delBase__ = getDelegate__()";
- _out << nl << "Dim del__ As _" << name << "Del = CType(delBase__, _" << name << "Del)";
- _out << nl;
- if(ret)
- {
- _out << "Return ";
- }
- _out << "del__." << opName << spar << args << "context__" << epar;
- if(!ret)
- {
- _out << nl << "Return";
- }
- _out.dec();
- _out << nl << "Catch ex__ As IceInternal.LocalExceptionWrapper";
- _out.inc();
- if(op->mode() == Operation::Idempotent || op->mode() == Operation::Nonmutating)
- {
- _out << nl << "cnt__ = handleExceptionWrapperRelaxed__(delBase__, ex__, cnt__)";
- }
- else
- {
- _out << nl << "handleExceptionWrapper__(delBase__, ex__)";
- }
- _out.dec();
- _out << nl << "Catch ex__ As Ice.LocalException";
- _out.inc();
- _out << nl << "cnt__ = handleException__(delBase__, ex__, cnt__)";
- _out.dec();
- _out << nl << "End Try";
- _out.dec();
- _out << nl << "End While";
- if(ret)
- {
- _out << nl << "Return Nothing"; // Satisfy the VB2005 compiler.
- }
-
- _out.dec();
- _out << nl << "End " << vbOp;
+ _out << sp << nl << "Public " << vbOp << ' ' << opName << spar << params << epar;
+ if(ret)
+ {
+ _out << " As " << retS;
+ }
+ _out << " Implements " << name << "Prx." << opName;
+ _out.inc();
+ _out << nl;
+ if(ret)
+ {
+ _out << "Return ";
+ }
+ _out << opName << spar << args << "Nothing" << "False" << epar;
+ _out.dec();
+ _out << nl << "End " << vbOp;
+
+
+ _out << sp << nl << "Public " << vbOp << ' ' << opName << spar << params
+ << "ByVal context__ As Ice.Context" << epar;
+ if(ret)
+ {
+ _out << " As " << retS;
+ }
+ _out << " Implements " << name << "Prx." << opName;
+ _out.inc();
+ _out << nl;
+ if(ret)
+ {
+ _out << "Return ";
+ }
+ _out << opName << spar << args << "context__" << "True" << epar;
+ _out.dec();
+ _out << nl << "End " << vbOp;
+
+ _out << sp << nl << "Private " << vbOp << ' ' << opName << spar << params
+ << "ByVal context__ As Ice.Context" << "explicitContext__ As Boolean" << epar;
+ if(ret)
+ {
+ _out << " As " << retS;
+ }
+ _out.inc();
+ _out << nl << "If explicitContext__ And context__ Is Nothing Then";
+ _out.inc();
+ _out << nl << "context__ = emptyContext_";
+ _out.dec();
+ _out << nl << "End If";
+ _out << nl << "Dim cnt__ As Integer = 0";
+ _out << nl << "While True";
+ _out.inc();
+ _out << nl << "Dim delBase__ As Ice.ObjectDel_ = Nothing";
+ _out << nl << "Try";
+ _out.inc();
+ if(op->returnsData())
+ {
+ _out << nl << "checkTwowayOnly__(\"" << op->name() << "\")";
+ }
+ _out << nl << "delBase__ = getDelegate__()";
+ _out << nl << "Dim del__ As _" << name << "Del = CType(delBase__, _" << name << "Del)";
+ _out << nl;
+ if(ret)
+ {
+ _out << "Return ";
+ }
+ _out << "del__." << opName << spar << args << "context__" << epar;
+ if(!ret)
+ {
+ _out << nl << "Return";
+ }
+ _out.dec();
+ _out << nl << "Catch ex__ As IceInternal.LocalExceptionWrapper";
+ _out.inc();
+ if(op->mode() == Operation::Idempotent || op->mode() == Operation::Nonmutating)
+ {
+ _out << nl << "cnt__ = handleExceptionWrapperRelaxed__(delBase__, ex__, cnt__)";
+ }
+ else
+ {
+ _out << nl << "handleExceptionWrapper__(delBase__, ex__)";
+ }
+ _out.dec();
+ _out << nl << "Catch ex__ As Ice.LocalException";
+ _out.inc();
+ _out << nl << "cnt__ = handleException__(delBase__, ex__, cnt__)";
+ _out.dec();
+ _out << nl << "End Try";
+ _out.dec();
+ _out << nl << "End While";
+ if(ret)
+ {
+ _out << nl << "Return Nothing"; // Satisfy the VB2005 compiler.
+ }
+
+ _out.dec();
+ _out << nl << "End " << vbOp;
}
if(!ops.empty())
{
- _out.zeroIndent();
- _out << sp << nl << "#End Region"; // Synchronous operations
- _out.restoreIndent();
+ _out.zeroIndent();
+ _out << sp << nl << "#End Region"; // Synchronous operations
+ _out.restoreIndent();
}
bool hasAsyncOps = false;
for(r = ops.begin(); r != ops.end(); ++r)
{
- OperationPtr op = *r;
-
- ClassDefPtr containingClass = ClassDefPtr::dynamicCast(op->container());
- if(containingClass->hasMetaData("ami") || op->hasMetaData("ami"))
- {
- if(!hasAsyncOps)
- {
- _out.zeroIndent();
- _out << sp << nl << "#Region \"Asynchronous operations\"";
- _out.restoreIndent();
- hasAsyncOps = true;
- }
- vector<string> paramsAMI = getParamsAsync(op, false);
- vector<string> argsAMI = getArgsAsync(op);
-
- string opName = op->name();
-
- //
- // Write two versions of the operation - with and without a
- // context parameter
- //
- _out << sp << nl << "Public Sub " << opName << "_async" << spar << paramsAMI << epar
- << " Implements " << name << "Prx." << opName << "_async"; // TODO: should be containing class?
- _out.inc();
- _out << nl << opName << "_async" << spar << argsAMI << "Nothing" << epar;
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public Sub " << opName << "_async" << spar << paramsAMI
- << "ByVal ctx__ As Ice.Context" << epar
- << " Implements " << name << "Prx." << opName << "_async"; // TODO: should be containing class?
- _out.inc();
- _out << nl << "If ctx__ Is Nothing Then";
- _out.inc();
- _out << nl << "ctx__ = emptyContext_";
- _out.dec();
- _out << nl << "End If";
- _out << nl << "cb__.invoke__" << spar << "Me" << argsAMI << "ctx__" << epar;
- _out.dec();
- _out << nl << "End Sub";
- }
+ OperationPtr op = *r;
+
+ ClassDefPtr containingClass = ClassDefPtr::dynamicCast(op->container());
+ if(containingClass->hasMetaData("ami") || op->hasMetaData("ami"))
+ {
+ if(!hasAsyncOps)
+ {
+ _out.zeroIndent();
+ _out << sp << nl << "#Region \"Asynchronous operations\"";
+ _out.restoreIndent();
+ hasAsyncOps = true;
+ }
+ vector<string> paramsAMI = getParamsAsync(op, false);
+ vector<string> argsAMI = getArgsAsync(op);
+
+ string opName = op->name();
+
+ //
+ // Write two versions of the operation - with and without a
+ // context parameter
+ //
+ _out << sp << nl << "Public Sub " << opName << "_async" << spar << paramsAMI << epar
+ << " Implements " << name << "Prx." << opName << "_async"; // TODO: should be containing class?
+ _out.inc();
+ _out << nl << opName << "_async" << spar << argsAMI << "Nothing" << epar;
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public Sub " << opName << "_async" << spar << paramsAMI
+ << "ByVal ctx__ As Ice.Context" << epar
+ << " Implements " << name << "Prx." << opName << "_async"; // TODO: should be containing class?
+ _out.inc();
+ _out << nl << "If ctx__ Is Nothing Then";
+ _out.inc();
+ _out << nl << "ctx__ = emptyContext_";
+ _out.dec();
+ _out << nl << "End If";
+ _out << nl << "cb__.invoke__" << spar << "Me" << argsAMI << "ctx__" << epar;
+ _out.dec();
+ _out << nl << "End Sub";
+ }
}
if(hasAsyncOps)
{
- _out.zeroIndent();
- _out << sp << nl << "#End Region"; // Asynchronous operations
- _out.restoreIndent();
+ _out.zeroIndent();
+ _out << sp << nl << "#End Region"; // Asynchronous operations
+ _out.restoreIndent();
}
_out.zeroIndent();
@@ -4080,25 +4080,25 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
if(_stream)
{
- _out << sp << nl << "Public Shared Sub write(ByVal outS__ As Ice.OutputStream, ByVal v__ As " << name << "Prx)";
- _out.inc();
- _out << nl << "outS__.writeProxy(v__)";
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public Shared Function read(ByVal inS__ As Ice.InputStream) As " << name << "Prx";
- _out.inc();
- _out << nl << "Dim proxy As Ice.ObjectPrx = inS__.readProxy()";
- _out << nl << "If Not proxy Is Nothing";
- _out.inc();
- _out << nl << "Dim result As " << name << "PrxHelper = New " << name << "PrxHelper";
- _out << nl << "result.copyFrom__(proxy)";
- _out << nl << "Return result";
- _out.dec();
- _out << nl << "End If";
- _out << nl << "Return Nothing";
- _out.dec();
- _out << nl << "End Function";
+ _out << sp << nl << "Public Shared Sub write(ByVal outS__ As Ice.OutputStream, ByVal v__ As " << name << "Prx)";
+ _out.inc();
+ _out << nl << "outS__.writeProxy(v__)";
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public Shared Function read(ByVal inS__ As Ice.InputStream) As " << name << "Prx";
+ _out.inc();
+ _out << nl << "Dim proxy As Ice.ObjectPrx = inS__.readProxy()";
+ _out << nl << "If Not proxy Is Nothing";
+ _out.inc();
+ _out << nl << "Dim result As " << name << "PrxHelper = New " << name << "PrxHelper";
+ _out << nl << "result.copyFrom__(proxy)";
+ _out << nl << "Return result";
+ _out.dec();
+ _out << nl << "End If";
+ _out << nl << "Return Nothing";
+ _out.dec();
+ _out << nl << "End Function";
}
_out.zeroIndent();
@@ -4148,19 +4148,19 @@ Slice::Gen::HelperVisitor::visitSequence(const SequencePtr& p)
if(_stream)
{
- _out << sp << nl << "Public Shared Sub write(ByVal outS__ As Ice.OutputStream, ByVal v__ As " << typeS << ')';
- _out.inc();
- writeSequenceMarshalUnmarshalCode(_out, p, "v__", true, true);
- _out.dec();
- _out << nl << "End Sub";
+ _out << sp << nl << "Public Shared Sub write(ByVal outS__ As Ice.OutputStream, ByVal v__ As " << typeS << ')';
+ _out.inc();
+ writeSequenceMarshalUnmarshalCode(_out, p, "v__", true, true);
+ _out.dec();
+ _out << nl << "End Sub";
- _out << sp << nl << "Public Shared Function read(ByVal inS__ As Ice.InputStream) As " << typeS;
- _out.inc();
- _out << nl << "Dim v__ As " << typeS << " = Nothing";
- writeSequenceMarshalUnmarshalCode(_out, p, "v__", false, true);
- _out << nl << "Return v__";
- _out.dec();
- _out << nl << "End Function";
+ _out << sp << nl << "Public Shared Function read(ByVal inS__ As Ice.InputStream) As " << typeS;
+ _out.inc();
+ _out << nl << "Dim v__ As " << typeS << " = Nothing";
+ writeSequenceMarshalUnmarshalCode(_out, p, "v__", false, true);
+ _out << nl << "Return v__";
+ _out.dec();
+ _out << nl << "End Function";
}
_out.dec();
@@ -4215,38 +4215,38 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
bool hasClassValue = (builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(value);
if(hasClassValue)
{
- _out << sp << nl << "Public NotInheritable Class Patcher__";
- _out.inc();
- _out << nl << "Inherits IceInternal.Patcher";
- _out << sp << nl << "Friend Sub New(ByVal m As " << name << ", ByVal key As " << keyS << ')';
- _out.inc();
- _out << nl << "_m = m";
- _out << nl << "_key = key";
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public Overrides Sub patch(ByVal v As Ice.Object)";
- _out.inc();
- _out << nl << "type_ = GetType(" << typeToString(p->valueType()) << ')';
- _out << nl << "Try";
- _out.inc();
- _out << nl << "_m(_key) = CType(v, " << valueS << ')';
- _out.dec();
- _out << nl << "Catch _ex As System.InvalidCastException";
- _out.inc();
- _out << nl << "Dim _e As Ice.UnexpectedObjectException = New Ice.UnexpectedObjectException";
- _out << nl << "_e.type = v.ice_id()";
- _out << nl << "_e.expectedType = \"" << value->typeId() << "\"";
- _out << nl << "Throw _e";
- _out.dec();
- _out << nl << "End Try";
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Private _m As " << name;
- _out << nl << "Private _key As " << keyS;
- _out.dec();
- _out << sp << nl << "End Class";
+ _out << sp << nl << "Public NotInheritable Class Patcher__";
+ _out.inc();
+ _out << nl << "Inherits IceInternal.Patcher";
+ _out << sp << nl << "Friend Sub New(ByVal m As " << name << ", ByVal key As " << keyS << ')';
+ _out.inc();
+ _out << nl << "_m = m";
+ _out << nl << "_key = key";
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public Overrides Sub patch(ByVal v As Ice.Object)";
+ _out.inc();
+ _out << nl << "type_ = GetType(" << typeToString(p->valueType()) << ')';
+ _out << nl << "Try";
+ _out.inc();
+ _out << nl << "_m(_key) = CType(v, " << valueS << ')';
+ _out.dec();
+ _out << nl << "Catch _ex As System.InvalidCastException";
+ _out.inc();
+ _out << nl << "Dim _e As Ice.UnexpectedObjectException = New Ice.UnexpectedObjectException";
+ _out << nl << "_e.type = v.ice_id()";
+ _out << nl << "_e.expectedType = \"" << value->typeId() << "\"";
+ _out << nl << "Throw _e";
+ _out.dec();
+ _out << nl << "End Try";
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Private _m As " << name;
+ _out << nl << "Private _key As " << keyS;
+ _out.dec();
+ _out << sp << nl << "End Class";
}
_out << sp << nl << "Public Shared Function " << " read(ByVal is__ As IceInternal.BasicStream) As " << name;
@@ -4261,12 +4261,12 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
if(!hasClassValue)
{
- _out << nl << "Dim v__ As " << valueS;
+ _out << nl << "Dim v__ As " << valueS;
}
writeMarshalUnmarshalCode(_out, value, "v__", false, false, false, "r__, k__");
if(!hasClassValue)
{
- _out << nl << "r__(k__) = v__";
+ _out << nl << "r__(k__) = v__";
}
_out.dec();
_out << nl << "Next";
@@ -4277,48 +4277,48 @@ Slice::Gen::HelperVisitor::visitDictionary(const DictionaryPtr& p)
if(_stream)
{
- _out << nl << "Public Shared Sub write(ByVal outS__ As Ice.OutputStream, ByVal v__ As " << name << ')';
- _out.inc();
- _out << nl << "If v__ Is Nothing Then";
- _out.inc();
- _out << nl << "outS__.writeSize(0)";
- _out.dec();
- _out << nl << "Else";
- _out.inc();
- _out << nl << "outS__.writeSize(v__.Count)";
- _out << nl << "For Each e__ As _System.Collections.DictionaryEntry In v__";
- _out.inc();
- writeMarshalUnmarshalCode(_out, key, keyArg, true, true, false);
- writeMarshalUnmarshalCode(_out, value, valueArg, true, true, false);
- _out.dec();
- _out << nl << "Next";
- _out.dec();
- _out << nl << "End If";
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public Shared Function read(ByVal inS__ As Ice.InputStream) As " << name;
- _out.inc();
- _out << nl << "Dim sz__ As Integer = inS__.readSize()";
- _out << nl << "Dim r__ As " << name << " = New " << name;
- _out << nl << "For i__ As Integer = 0 To sz__ - 1";
- _out.inc();
- _out << nl << "Dim k__ As " << keyS;
- writeMarshalUnmarshalCode(_out, key, "k__", false, true, false);
- if(!hasClassValue)
- {
- _out << nl << "Dim v__ As " << valueS;
- }
- writeMarshalUnmarshalCode(_out, value, "v__", false, true, false, "r__, k__");
- if(!hasClassValue)
- {
- _out << nl << "r__(k__) = v__";
- }
- _out.dec();
- _out << nl << "Next";
- _out << nl << "Return r__";
- _out.dec();
- _out << nl << "End Function";
+ _out << nl << "Public Shared Sub write(ByVal outS__ As Ice.OutputStream, ByVal v__ As " << name << ')';
+ _out.inc();
+ _out << nl << "If v__ Is Nothing Then";
+ _out.inc();
+ _out << nl << "outS__.writeSize(0)";
+ _out.dec();
+ _out << nl << "Else";
+ _out.inc();
+ _out << nl << "outS__.writeSize(v__.Count)";
+ _out << nl << "For Each e__ As _System.Collections.DictionaryEntry In v__";
+ _out.inc();
+ writeMarshalUnmarshalCode(_out, key, keyArg, true, true, false);
+ writeMarshalUnmarshalCode(_out, value, valueArg, true, true, false);
+ _out.dec();
+ _out << nl << "Next";
+ _out.dec();
+ _out << nl << "End If";
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public Shared Function read(ByVal inS__ As Ice.InputStream) As " << name;
+ _out.inc();
+ _out << nl << "Dim sz__ As Integer = inS__.readSize()";
+ _out << nl << "Dim r__ As " << name << " = New " << name;
+ _out << nl << "For i__ As Integer = 0 To sz__ - 1";
+ _out.inc();
+ _out << nl << "Dim k__ As " << keyS;
+ writeMarshalUnmarshalCode(_out, key, "k__", false, true, false);
+ if(!hasClassValue)
+ {
+ _out << nl << "Dim v__ As " << valueS;
+ }
+ writeMarshalUnmarshalCode(_out, value, "v__", false, true, false, "r__, k__");
+ if(!hasClassValue)
+ {
+ _out << nl << "r__(k__) = v__";
+ }
+ _out.dec();
+ _out << nl << "Next";
+ _out << nl << "Return r__";
+ _out.dec();
+ _out << nl << "End Function";
}
_out.dec();
@@ -4355,7 +4355,7 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p)
{
if(p->isLocal())
{
- return false;
+ return false;
}
string name = p->name();
@@ -4366,24 +4366,24 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << nl << "Inherits ";
if(bases.empty())
{
- _out << "Ice.ObjectDel_";
+ _out << "Ice.ObjectDel_";
}
else
{
- ClassList::const_iterator q = bases.begin();
- while(q != bases.end())
- {
- string s = (*q)->scoped();
- string::size_type pos = s.rfind("::");
- assert(pos != string::npos);
- s = s.insert(pos + 2, "_");
- s += "Del";
- _out << fixId(s);
- if(++q != bases.end())
- {
- _out << ", ";
- }
- }
+ ClassList::const_iterator q = bases.begin();
+ while(q != bases.end())
+ {
+ string s = (*q)->scoped();
+ string::size_type pos = s.rfind("::");
+ assert(pos != string::npos);
+ s = s.insert(pos + 2, "_");
+ s += "Del";
+ _out << fixId(s);
+ if(++q != bases.end())
+ {
+ _out << ", ";
+ }
+ }
}
OperationList ops = p->operations();
@@ -4391,18 +4391,18 @@ Slice::Gen::DelegateVisitor::visitClassDefStart(const ClassDefPtr& p)
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
- OperationPtr op = *r;
- string opName = fixId(op->name(), DotNet::ICloneable, true);
- TypePtr ret = op->returnType();
- string retS = typeToString(ret);
- vector<string> params = getParams(op);
- string vbOp = ret ? "Function" : "Sub";
+ OperationPtr op = *r;
+ string opName = fixId(op->name(), DotNet::ICloneable, true);
+ TypePtr ret = op->returnType();
+ string retS = typeToString(ret);
+ vector<string> params = getParams(op);
+ string vbOp = ret ? "Function" : "Sub";
- _out << sp << nl << vbOp << ' ' << opName << spar << params << "ByVal context__ As Ice.Context" << epar;
- if(ret)
- {
- _out << " As " << retS;
- }
+ _out << sp << nl << vbOp << ' ' << opName << spar << params << "ByVal context__ As Ice.Context" << epar;
+ if(ret)
+ {
+ _out << " As " << retS;
+ }
}
return true;
@@ -4461,168 +4461,168 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
- OperationPtr op = *r;
- string opName = fixId(op->name(), DotNet::ICloneable, true);
- TypePtr ret = op->returnType();
- string retS = typeToString(ret);
-
- TypeStringList inParams;
- TypeStringList outParams;
- ParamDeclList paramList = op->parameters();
- for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
- {
- if((*pli)->isOutParam())
- {
- outParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
- }
- else
- {
- inParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
- }
- }
-
- TypeStringList::const_iterator q;
-
- ExceptionList throws = op->throws();
- throws.sort();
- throws.unique();
-
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
+ OperationPtr op = *r;
+ string opName = fixId(op->name(), DotNet::ICloneable, true);
+ TypePtr ret = op->returnType();
+ string retS = typeToString(ret);
+
+ TypeStringList inParams;
+ TypeStringList outParams;
+ ParamDeclList paramList = op->parameters();
+ for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
+ {
+ if((*pli)->isOutParam())
+ {
+ outParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
+ }
+ else
+ {
+ inParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
+ }
+ }
+
+ TypeStringList::const_iterator q;
+
+ ExceptionList throws = op->throws();
+ throws.sort();
+ throws.unique();
+
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
#if defined(__SUNPRO_CC)
- throws.sort(Slice::derivedToBaseCompare);
+ throws.sort(Slice::derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
- vector<string> params = getParams(op);
-
- string vbOp = ret ? "Function" : "Sub";
-
- _out << sp << nl << "Public " << vbOp << ' ' << opName << spar << params
- << "ByVal context__ As Ice.Context" << epar;
- if(ret)
- {
- _out << " As " << retS;
- }
- _out << " Implements _" << name << "Del." << opName; // TODO: should be containing class?
- _out.inc();
-
- _out << nl << "Dim og__ As IceInternal.Outgoing = getOutgoing(\""
- << op->name() << "\", " << sliceModeToIceMode(op->sendMode()) << ", context__)";
- _out << nl << "Try";
- _out.inc();
- if(!inParams.empty())
- {
- _out << nl << "Try";
- _out.inc();
- _out << nl << "Dim os__ As IceInternal.BasicStream = og__.ostr()";
- for(q = inParams.begin(); q != inParams.end(); ++q)
- {
- writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, false);
- }
- if(op->sendsClasses())
- {
- _out << nl << "os__.writePendingObjects()";
- }
- _out.dec();
- _out << nl << "Catch ex__ As Ice.LocalException";
- _out.inc();
- _out << nl << "og__.abort(ex__)";
- _out.dec();
- _out << nl << "End Try";
- }
- _out << nl << "Dim ok__ As Boolean = og__.invoke()";
- _out << nl << "Try";
- _out.inc();
- _out << nl << "Dim is__ As IceInternal.BasicStream = og__.istr()";
- _out << nl << "If Not ok__ Then";
- _out.inc();
- //
- // The try/catch block is necessary because throwException()
- // can raise UserException.
- //
- _out << nl << "Try";
- _out.inc();
- _out << nl << "is__.throwException()";
- _out.dec();
- for(ExceptionList::const_iterator t = throws.begin(); t != throws.end(); ++t)
- {
- _out << nl << "Catch ex__ As " << fixId((*t)->scoped());
- _out.inc();
- _out << nl << "Throw";
- _out.dec();
- }
- _out << nl << "Catch ex__ As Ice.UserException";
- _out.inc();
- _out << nl << "Throw New Ice.UnknownUserException(ex__)";
- _out.dec();
- _out << nl << "End Try";
- _out.dec();
- _out << nl << "End If";
- for(q = outParams.begin(); q != outParams.end(); ++q)
- {
- writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, false, true, "");
- }
- if(ret)
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
- {
- ContainedPtr contained = ContainedPtr::dynamicCast(ret);
- _out << nl << "Dim ret__ As " << retS << " = Nothing";
- _out << nl << "Dim ret___PP As IceInternal.ParamPatcher = New IceInternal.ParamPatcher(GetType("
- << retS << "), \"" << (contained ? contained->scoped() : string("::Ice::Object")) << "\")";
- _out << nl << "is__.readObject(ret___PP)";
- }
- else
- {
- _out << nl << "Dim ret__ As " << retS << " = Nothing";
- writeMarshalUnmarshalCode(_out, ret, "ret__", false, false, true, "");
- }
- }
- if(op->returnsClasses())
- {
- _out << nl << "is__.readPendingObjects()";
- for(q = outParams.begin(); q != outParams.end(); ++q)
- {
- string param = fixId(q->second);
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(q->first))
- {
- string type = typeToString(q->first);
- _out << nl << param << " = CType(" << param << "_PP.value, " << type << ')';
- }
- }
- }
- if(ret)
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
- {
- _out << nl << "ret__ = CType(ret___PP.value, " << retS << ')';
- }
- _out << nl << "Return ret__";
- }
- _out.dec();
- _out << nl << "Catch ex__ As Ice.LocalException";
- _out.inc();
- _out << nl << "throw New IceInternal.LocalExceptionWrapper(ex__, false)";
- _out.dec();
- _out << nl << "End Try";
+ vector<string> params = getParams(op);
+
+ string vbOp = ret ? "Function" : "Sub";
+
+ _out << sp << nl << "Public " << vbOp << ' ' << opName << spar << params
+ << "ByVal context__ As Ice.Context" << epar;
+ if(ret)
+ {
+ _out << " As " << retS;
+ }
+ _out << " Implements _" << name << "Del." << opName; // TODO: should be containing class?
+ _out.inc();
+
+ _out << nl << "Dim og__ As IceInternal.Outgoing = getOutgoing(\""
+ << op->name() << "\", " << sliceModeToIceMode(op->sendMode()) << ", context__)";
+ _out << nl << "Try";
+ _out.inc();
+ if(!inParams.empty())
+ {
+ _out << nl << "Try";
+ _out.inc();
+ _out << nl << "Dim os__ As IceInternal.BasicStream = og__.ostr()";
+ for(q = inParams.begin(); q != inParams.end(); ++q)
+ {
+ writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, false);
+ }
+ if(op->sendsClasses())
+ {
+ _out << nl << "os__.writePendingObjects()";
+ }
+ _out.dec();
+ _out << nl << "Catch ex__ As Ice.LocalException";
+ _out.inc();
+ _out << nl << "og__.abort(ex__)";
+ _out.dec();
+ _out << nl << "End Try";
+ }
+ _out << nl << "Dim ok__ As Boolean = og__.invoke()";
+ _out << nl << "Try";
+ _out.inc();
+ _out << nl << "Dim is__ As IceInternal.BasicStream = og__.istr()";
+ _out << nl << "If Not ok__ Then";
+ _out.inc();
+ //
+ // The try/catch block is necessary because throwException()
+ // can raise UserException.
+ //
+ _out << nl << "Try";
+ _out.inc();
+ _out << nl << "is__.throwException()";
+ _out.dec();
+ for(ExceptionList::const_iterator t = throws.begin(); t != throws.end(); ++t)
+ {
+ _out << nl << "Catch ex__ As " << fixId((*t)->scoped());
+ _out.inc();
+ _out << nl << "Throw";
+ _out.dec();
+ }
+ _out << nl << "Catch ex__ As Ice.UserException";
+ _out.inc();
+ _out << nl << "Throw New Ice.UnknownUserException(ex__)";
+ _out.dec();
+ _out << nl << "End Try";
+ _out.dec();
+ _out << nl << "End If";
+ for(q = outParams.begin(); q != outParams.end(); ++q)
+ {
+ writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, false, true, "");
+ }
+ if(ret)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
+ {
+ ContainedPtr contained = ContainedPtr::dynamicCast(ret);
+ _out << nl << "Dim ret__ As " << retS << " = Nothing";
+ _out << nl << "Dim ret___PP As IceInternal.ParamPatcher = New IceInternal.ParamPatcher(GetType("
+ << retS << "), \"" << (contained ? contained->scoped() : string("::Ice::Object")) << "\")";
+ _out << nl << "is__.readObject(ret___PP)";
+ }
+ else
+ {
+ _out << nl << "Dim ret__ As " << retS << " = Nothing";
+ writeMarshalUnmarshalCode(_out, ret, "ret__", false, false, true, "");
+ }
+ }
+ if(op->returnsClasses())
+ {
+ _out << nl << "is__.readPendingObjects()";
+ for(q = outParams.begin(); q != outParams.end(); ++q)
+ {
+ string param = fixId(q->second);
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(q->first))
+ {
+ string type = typeToString(q->first);
+ _out << nl << param << " = CType(" << param << "_PP.value, " << type << ')';
+ }
+ }
+ }
+ if(ret)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
+ {
+ _out << nl << "ret__ = CType(ret___PP.value, " << retS << ')';
+ }
+ _out << nl << "Return ret__";
+ }
+ _out.dec();
+ _out << nl << "Catch ex__ As Ice.LocalException";
+ _out.inc();
+ _out << nl << "throw New IceInternal.LocalExceptionWrapper(ex__, false)";
+ _out.dec();
+ _out << nl << "End Try";
_out.dec();
_out << nl << "Finally";
_out.inc();
_out << nl << "reclaimOutgoing(og__)";
_out.dec();
- _out << nl << "End Try";
+ _out << nl << "End Try";
_out.dec();
- _out << nl << "End " << vbOp;
+ _out << nl << "End " << vbOp;
}
return true;
@@ -4685,78 +4685,78 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
string opName = fixId(op->name(), DotNet::ICloneable, true);
TypePtr ret = op->returnType();
string retS = typeToString(ret);
- string vbOp = ret ? "Function" : "Sub";
- ClassDefPtr containingClass = ClassDefPtr::dynamicCast(op->container());
+ string vbOp = ret ? "Function" : "Sub";
+ ClassDefPtr containingClass = ClassDefPtr::dynamicCast(op->container());
vector<string> params = getParams(op);
vector<string> args = getArgs(op);
- _out << sp;
+ _out << sp;
_out << nl << "Public " << vbOp << ' ' << opName << spar << params << "ByVal context__ As Ice.Context" << epar;
- if(ret)
- {
- _out << " As " << retS;
- }
- _out << " Implements _" << name << "Del." << opName; // TODO: should be containing class?
+ if(ret)
+ {
+ _out << " As " << retS;
+ }
+ _out << " Implements _" << name << "Del." << opName; // TODO: should be containing class?
_out.inc();
- if(containingClass->hasMetaData("amd") || op->hasMetaData("amd"))
- {
- _out << nl << "Throw New Ice.CollocationOptimizationException()";
- }
- else
- {
- _out << nl << "Dim current__ As Ice.Current = New Ice.Current";
- _out << nl << "initCurrent__(current__, \"" << op->name() << "\", "
- << sliceModeToIceMode(op->sendMode())
- << ", context__)";
- _out << nl << "While True";
- _out.inc();
- _out << nl << "Dim direct__ As IceInternal.Direct = New IceInternal.Direct(current__)";
- _out << nl << "Dim servant__ As Object = direct__.servant()";
- _out << nl << "If TypeOf servant__ Is " << fixId(name) << " Then";
- _out.inc();
- _out << nl << "Try";
- _out.inc();
- _out << nl;
- if(ret)
- {
- _out << "Return ";
- }
- _out << "CType(servant__, " << fixId(containingClass->scoped() + "Operations_")
- << ")." << opName << spar << args << "current__" << epar;
- if(!ret)
- {
- _out << nl << "Return";
- }
- _out.dec();
- _out << nl << "Catch ex__ As Ice.LocalException";
- _out.inc();
- _out << nl << "Throw New IceInternal.LocalExceptionWrapper(ex__, false)";
- _out.dec();
- _out << nl << "Finally";
- _out.inc();
- _out << nl << "direct__.destroy()";
- _out.dec();
- _out << nl << "End Try";
- _out.dec();
- _out << nl << "Else";
- _out.inc();
- _out << nl << "direct__.destroy()";
- _out << nl << "Dim opEx__ As Ice.OperationNotExistException = new Ice.OperationNotExistException()";
- _out << nl << "opEx__.id = current__.id";
- _out << nl << "opEx__.facet = current__.facet";
- _out << nl << "opEx__.operation = current__.operation";
- _out << nl << "Throw opEx__";
- _out.dec();
- _out << nl << "End If";
- _out.dec();
- _out << nl << "End While";
- if(ret)
- {
- _out << nl << "Return Nothing"; // Satisfy the VB2005 compiler.
- }
- }
- _out.dec();
+ if(containingClass->hasMetaData("amd") || op->hasMetaData("amd"))
+ {
+ _out << nl << "Throw New Ice.CollocationOptimizationException()";
+ }
+ else
+ {
+ _out << nl << "Dim current__ As Ice.Current = New Ice.Current";
+ _out << nl << "initCurrent__(current__, \"" << op->name() << "\", "
+ << sliceModeToIceMode(op->sendMode())
+ << ", context__)";
+ _out << nl << "While True";
+ _out.inc();
+ _out << nl << "Dim direct__ As IceInternal.Direct = New IceInternal.Direct(current__)";
+ _out << nl << "Dim servant__ As Object = direct__.servant()";
+ _out << nl << "If TypeOf servant__ Is " << fixId(name) << " Then";
+ _out.inc();
+ _out << nl << "Try";
+ _out.inc();
+ _out << nl;
+ if(ret)
+ {
+ _out << "Return ";
+ }
+ _out << "CType(servant__, " << fixId(containingClass->scoped() + "Operations_")
+ << ")." << opName << spar << args << "current__" << epar;
+ if(!ret)
+ {
+ _out << nl << "Return";
+ }
+ _out.dec();
+ _out << nl << "Catch ex__ As Ice.LocalException";
+ _out.inc();
+ _out << nl << "Throw New IceInternal.LocalExceptionWrapper(ex__, false)";
+ _out.dec();
+ _out << nl << "Finally";
+ _out.inc();
+ _out << nl << "direct__.destroy()";
+ _out.dec();
+ _out << nl << "End Try";
+ _out.dec();
+ _out << nl << "Else";
+ _out.inc();
+ _out << nl << "direct__.destroy()";
+ _out << nl << "Dim opEx__ As Ice.OperationNotExistException = new Ice.OperationNotExistException()";
+ _out << nl << "opEx__.id = current__.id";
+ _out << nl << "opEx__.facet = current__.facet";
+ _out << nl << "opEx__.operation = current__.operation";
+ _out << nl << "Throw opEx__";
+ _out.dec();
+ _out << nl << "End If";
+ _out.dec();
+ _out << nl << "End While";
+ if(ret)
+ {
+ _out << nl << "Return Nothing"; // Satisfy the VB2005 compiler.
+ }
+ }
+ _out.dec();
_out << nl << "End " << vbOp;
}
@@ -4811,70 +4811,70 @@ Slice::Gen::DispatcherVisitor::visitClassDefStart(const ClassDefPtr& p)
OperationList ops = p->operations();
if(!ops.empty())
{
- _out.zeroIndent();
+ _out.zeroIndent();
_out << sp << nl << "#Region \"Slice operations\"";
- _out.restoreIndent();
+ _out.restoreIndent();
}
for(OperationList::const_iterator op = ops.begin(); op != ops.end(); ++op)
{
- bool amd = p->hasMetaData("amd") || (*op)->hasMetaData("amd");
-
- string name = (*op)->name();
- vector<string> params;
- vector<string> args;
- TypePtr ret;
-
- if(amd)
- {
- name = name + "_async";
- params = getParamsAsync(*op, true);
- args = getArgsAsync(*op);
- }
- else
- {
- name = fixId(name, DotNet::ICloneable, true);
- params = getParams(*op);
- ret = (*op)->returnType();
- args = getArgs(*op);
- }
-
- string vbOp = ret ? "Function" : "Sub";
-
- _out << sp << nl << "Public " << vbOp << ' ' << name << spar << params << epar;
- if(ret)
- {
- _out << " As " << typeToString(ret);
- }
- _out << " Implements " << p->name() << "OperationsNC_" << '.' << name; // TODO: should be containing class?
- _out.inc();
- _out << nl;
- if(ret)
- {
- _out << "Return ";
- }
- _out << name << spar << args << "Ice.ObjectImpl.defaultCurrent" << epar;
- _out.dec();
- _out << nl << "End " << vbOp;
-
- _out << sp << nl << "Public MustOverride " << vbOp << ' ' << name << spar << params;
- if(!p->isLocal())
- {
- _out << "ByVal current__ As Ice.Current";
- }
- _out << epar;
- if(ret)
- {
- _out << " As " << typeToString(ret);
- }
- _out << " Implements " << p->name() << "Operations_" << '.' << name; // TODO: should be containing class?
+ bool amd = p->hasMetaData("amd") || (*op)->hasMetaData("amd");
+
+ string name = (*op)->name();
+ vector<string> params;
+ vector<string> args;
+ TypePtr ret;
+
+ if(amd)
+ {
+ name = name + "_async";
+ params = getParamsAsync(*op, true);
+ args = getArgsAsync(*op);
+ }
+ else
+ {
+ name = fixId(name, DotNet::ICloneable, true);
+ params = getParams(*op);
+ ret = (*op)->returnType();
+ args = getArgs(*op);
+ }
+
+ string vbOp = ret ? "Function" : "Sub";
+
+ _out << sp << nl << "Public " << vbOp << ' ' << name << spar << params << epar;
+ if(ret)
+ {
+ _out << " As " << typeToString(ret);
+ }
+ _out << " Implements " << p->name() << "OperationsNC_" << '.' << name; // TODO: should be containing class?
+ _out.inc();
+ _out << nl;
+ if(ret)
+ {
+ _out << "Return ";
+ }
+ _out << name << spar << args << "Ice.ObjectImpl.defaultCurrent" << epar;
+ _out.dec();
+ _out << nl << "End " << vbOp;
+
+ _out << sp << nl << "Public MustOverride " << vbOp << ' ' << name << spar << params;
+ if(!p->isLocal())
+ {
+ _out << "ByVal current__ As Ice.Current";
+ }
+ _out << epar;
+ if(ret)
+ {
+ _out << " As " << typeToString(ret);
+ }
+ _out << " Implements " << p->name() << "Operations_" << '.' << name; // TODO: should be containing class?
}
if(!ops.empty())
{
- _out.zeroIndent();
+ _out.zeroIndent();
_out << sp << nl << "#End Region"; // Slice operations
- _out.restoreIndent();
+ _out.restoreIndent();
}
writeInheritedOperations(p);
@@ -4931,7 +4931,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
if(cl->isLocal())
{
- return;
+ return;
}
string name = p->name();
@@ -4942,285 +4942,285 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
TypePtr ret = p->returnType();
string retS = typeToString(ret);
- TypeStringList inParams;
+ TypeStringList inParams;
TypeStringList outParams;
- ParamDeclList paramList = p->parameters();
- for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
- {
- if((*pli)->isOutParam())
- {
- outParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
- }
- else
- {
- inParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
- }
- }
+ ParamDeclList paramList = p->parameters();
+ for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
+ {
+ if((*pli)->isOutParam())
+ {
+ outParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
+ }
+ else
+ {
+ inParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
+ }
+ }
ExceptionList throws = p->throws();
throws.sort();
throws.unique();
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
#if defined(__SUNPRO_CC)
- throws.sort(Slice::derivedToBaseCompare);
+ throws.sort(Slice::derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
TypeStringList::const_iterator q;
- vector<string> params = getParamsAsyncCB(p);
- vector<string> args = getArgsAsyncCB(p);
-
- vector<string> paramsInvoke = getParamsAsync(p, false);
-
- _out << sp << nl << "Public MustInherit Class AMI_" << cl->name() << '_' << name;
- _out.inc();
- _out << nl << "Inherits IceInternal.OutgoingAsync";
- _out << sp;
- _out << nl << "Public MustOverride Sub ice_response" << spar << params << epar;
-
- _out << sp << nl << "Public Sub invoke__" << spar << "ByVal prx__ As Ice.ObjectPrx"
- << paramsInvoke << "ByVal ctx__ As Ice.Context" << epar;
- _out.inc();
- _out << nl << "Try";
- _out.inc();
- _out << nl << "prepare__(prx__, \"" << p->name() << "\", "
- << sliceModeToIceMode(p->sendMode()) << ", ctx__)";
- if(p->returnsData())
- for(q = inParams.begin(); q != inParams.end(); ++q)
- {
- string typeS = typeToString(q->first);
- writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, false);
- }
- if(p->sendsClasses())
- {
- _out << nl << "os__.writePendingObjects()";
- }
- _out << nl << "os__.endWriteEncaps()";
- _out.dec();
- _out << nl << "Catch ex__ As Ice.LocalException";
- _out.inc();
- _out << nl << "finished__(ex__)";
- _out << nl << "Return";
- _out.dec();
- _out << nl << "End Try";
- _out << nl << "send__()";
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Protected Overrides Sub response__(ok__ As Boolean)";
- _out.inc();
+ vector<string> params = getParamsAsyncCB(p);
+ vector<string> args = getArgsAsyncCB(p);
+
+ vector<string> paramsInvoke = getParamsAsync(p, false);
+
+ _out << sp << nl << "Public MustInherit Class AMI_" << cl->name() << '_' << name;
+ _out.inc();
+ _out << nl << "Inherits IceInternal.OutgoingAsync";
+ _out << sp;
+ _out << nl << "Public MustOverride Sub ice_response" << spar << params << epar;
+
+ _out << sp << nl << "Public Sub invoke__" << spar << "ByVal prx__ As Ice.ObjectPrx"
+ << paramsInvoke << "ByVal ctx__ As Ice.Context" << epar;
+ _out.inc();
+ _out << nl << "Try";
+ _out.inc();
+ _out << nl << "prepare__(prx__, \"" << p->name() << "\", "
+ << sliceModeToIceMode(p->sendMode()) << ", ctx__)";
+ if(p->returnsData())
+ for(q = inParams.begin(); q != inParams.end(); ++q)
+ {
+ string typeS = typeToString(q->first);
+ writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, false);
+ }
+ if(p->sendsClasses())
+ {
+ _out << nl << "os__.writePendingObjects()";
+ }
+ _out << nl << "os__.endWriteEncaps()";
+ _out.dec();
+ _out << nl << "Catch ex__ As Ice.LocalException";
+ _out.inc();
+ _out << nl << "finished__(ex__)";
+ _out << nl << "Return";
+ _out.dec();
+ _out << nl << "End Try";
+ _out << nl << "send__()";
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Protected Overrides Sub response__(ok__ As Boolean)";
+ _out.inc();
for(q = outParams.begin(); q != outParams.end(); ++q)
{
- _out << nl << "Dim " << fixId(q->second) << " As " << typeToString(q->first) << " = Nothing";
+ _out << nl << "Dim " << fixId(q->second) << " As " << typeToString(q->first) << " = Nothing";
}
if(ret)
{
- _out << nl << "Dim ret__ As " << retS << " = Nothing";
+ _out << nl << "Dim ret__ As " << retS << " = Nothing";
+ }
+ _out << nl << "Try";
+ _out.inc();
+ _out << nl << "If Not ok__ Then";
+ _out.inc();
+ _out << nl << "Try";
+ _out.inc();
+ _out << nl << "is__.throwException()";
+ _out.dec();
+ for(ExceptionList::const_iterator r = throws.begin(); r != throws.end(); ++r)
+ {
+ _out << nl << "Catch ex__ As " << fixId((*r)->scoped());
+ _out.inc();
+ _out << nl << "Throw";
+ _out.dec();
}
- _out << nl << "Try";
- _out.inc();
- _out << nl << "If Not ok__ Then";
+ _out << nl << "Catch ex__ As Ice.UserException";
_out.inc();
- _out << nl << "Try";
- _out.inc();
- _out << nl << "is__.throwException()";
- _out.dec();
- for(ExceptionList::const_iterator r = throws.begin(); r != throws.end(); ++r)
- {
- _out << nl << "Catch ex__ As " << fixId((*r)->scoped());
- _out.inc();
- _out << nl << "Throw";
- _out.dec();
- }
- _out << nl << "Catch ex__ As Ice.UserException";
- _out.inc();
_out << nl << "Throw New Ice.UnknownUserException(ex__)";
- _out.dec();
- _out << nl << "End Try";
- _out.dec();
- _out << nl << "End If";
+ _out.dec();
+ _out << nl << "End Try";
+ _out.dec();
+ _out << nl << "End If";
for(q = outParams.begin(); q != outParams.end(); ++q)
{
- writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, false, true);
+ writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), false, false, true);
}
if(ret)
{
- writeMarshalUnmarshalCode(_out, ret, "ret__", false, false, true);
- }
- if(p->returnsClasses())
- {
- _out << nl << "is__.readPendingObjects()";
- }
- for(q = outParams.begin(); q != outParams.end(); ++q)
- {
- string param = fixId(q->second);
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(q->first))
- {
- string type = typeToString(q->first);
- _out << nl << param << " = CType(" << param << "_PP.value, " << type << ')';
- }
- }
- if(ret)
- {
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
- {
- string type = typeToString(ret);
- _out << nl << "ret__ = CType(ret___PP.value, " << retS << ')';
- }
- }
- _out.dec();
- _out << nl << "Catch ex__ As Ice.LocalException";
- _out.inc();
- _out << nl << "finished__(ex__)";
- _out << nl << "Return";
- _out.dec();
- if(!throws.empty())
- {
- _out << nl << "Catch ex__ As Ice.UserException";
- _out.inc();
- _out << nl << "ice_exception(ex__)";
- _out << nl << "Return";
- _out.dec();
- }
- _out << nl << "End Try";
- _out << nl << "ice_response" << spar << args << epar;
- _out.dec();
- _out << nl << "End Sub";
- _out.dec();
- _out << sp << nl << "End Class";
+ writeMarshalUnmarshalCode(_out, ret, "ret__", false, false, true);
+ }
+ if(p->returnsClasses())
+ {
+ _out << nl << "is__.readPendingObjects()";
+ }
+ for(q = outParams.begin(); q != outParams.end(); ++q)
+ {
+ string param = fixId(q->second);
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(q->first);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(q->first))
+ {
+ string type = typeToString(q->first);
+ _out << nl << param << " = CType(" << param << "_PP.value, " << type << ')';
+ }
+ }
+ if(ret)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(ret);
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(ret))
+ {
+ string type = typeToString(ret);
+ _out << nl << "ret__ = CType(ret___PP.value, " << retS << ')';
+ }
+ }
+ _out.dec();
+ _out << nl << "Catch ex__ As Ice.LocalException";
+ _out.inc();
+ _out << nl << "finished__(ex__)";
+ _out << nl << "Return";
+ _out.dec();
+ if(!throws.empty())
+ {
+ _out << nl << "Catch ex__ As Ice.UserException";
+ _out.inc();
+ _out << nl << "ice_exception(ex__)";
+ _out << nl << "Return";
+ _out.dec();
+ }
+ _out << nl << "End Try";
+ _out << nl << "ice_response" << spar << args << epar;
+ _out.dec();
+ _out << nl << "End Sub";
+ _out.dec();
+ _out << sp << nl << "End Class";
}
if(cl->hasMetaData("amd") || p->hasMetaData("amd"))
{
- string classNameAMD = "AMD_" + cl->name();
- string classNameAMDI = "_AMD_" + cl->name();
+ string classNameAMD = "AMD_" + cl->name();
+ string classNameAMDI = "_AMD_" + cl->name();
- vector<string> paramsAMD = getParamsAsyncCB(p);
+ vector<string> paramsAMD = getParamsAsyncCB(p);
- _out << sp << nl << "Public Interface " << classNameAMD << '_' << name;
- _out.inc();
- _out << sp << nl << "Sub ice_response" << spar << paramsAMD << epar;
- _out << sp << nl << "Sub ice_exception(ex As _System.Exception)";
- _out.dec();
- _out << nl << "End Interface";
+ _out << sp << nl << "Public Interface " << classNameAMD << '_' << name;
+ _out.inc();
+ _out << sp << nl << "Sub ice_response" << spar << paramsAMD << epar;
+ _out << sp << nl << "Sub ice_exception(ex As _System.Exception)";
+ _out.dec();
+ _out << nl << "End Interface";
- TypePtr ret = p->returnType();
-
- TypeStringList outParams;
- ParamDeclList paramList = p->parameters();
- for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
- {
- if((*pli)->isOutParam())
- {
- outParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
- }
- }
-
- ExceptionList throws = p->throws();
- throws.sort();
- throws.unique();
-
- //
- // Arrange exceptions into most-derived to least-derived order. If we don't
- // do this, a base exception handler can appear before a derived exception
- // handler, causing compiler warnings and resulting in the base exception
- // being marshaled instead of the derived exception.
- //
+ TypePtr ret = p->returnType();
+
+ TypeStringList outParams;
+ ParamDeclList paramList = p->parameters();
+ for(ParamDeclList::const_iterator pli = paramList.begin(); pli != paramList.end(); ++pli)
+ {
+ if((*pli)->isOutParam())
+ {
+ outParams.push_back(make_pair((*pli)->type(), (*pli)->name()));
+ }
+ }
+
+ ExceptionList throws = p->throws();
+ throws.sort();
+ throws.unique();
+
+ //
+ // Arrange exceptions into most-derived to least-derived order. If we don't
+ // do this, a base exception handler can appear before a derived exception
+ // handler, causing compiler warnings and resulting in the base exception
+ // being marshaled instead of the derived exception.
+ //
#if defined(__SUNPRO_CC)
- throws.sort(Slice::derivedToBaseCompare);
+ throws.sort(Slice::derivedToBaseCompare);
#else
- throws.sort(Slice::DerivedToBaseCompare());
+ throws.sort(Slice::DerivedToBaseCompare());
#endif
- TypeStringList::const_iterator q;
- _out << sp << nl << "Class " << classNameAMDI << '_' << name;
- _out.inc();
- _out << nl << "Inherits IceInternal.IncomingAsync";
- _out << nl << "Implements " << classNameAMD << '_' << name;
-
- _out << sp << nl << "Public Sub New(ByVal inc As IceInternal.Incoming)";
- _out.inc();
- _out << nl << "MyBase.New(inc)";
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public Sub ice_response" << spar << paramsAMD << epar
- << " Implements " << classNameAMD << '_' << name << ".ice_response"; // TODO: should be containing class?
- _out.inc();
- if(ret || !outParams.empty())
- {
- _out << nl << "Try";
- _out.inc();
- _out << nl << "Dim os__ As IceInternal.BasicStream = Me.os__()";
- for(q = outParams.begin(); q != outParams.end(); ++q)
- {
- string typeS = typeToString(q->first);
- writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, false);
- }
- if(ret)
- {
- string retS = typeToString(ret);
- writeMarshalUnmarshalCode(_out, ret, "ret__", true, false, false);
- }
- if(p->returnsClasses())
- {
- _out << nl << "os__.writePendingObjects()";
- }
- _out.dec();
- _out << nl << "Catch ex__ As Ice.LocalException";
- _out.inc();
- _out << nl << "ice_exception(ex__)";
- _out.dec();
- _out << nl << "End Try";
- }
- _out << nl << "response__(true)";
- _out.dec();
- _out << nl << "End Sub";
-
- _out << sp << nl << "Public Sub ice_exception(ByVal ex As _System.Exception)"
- << " Implements " << classNameAMD << '_' << name << ".ice_exception"; // TODO: should be containing class?
- _out.inc();
- if(throws.empty())
- {
- _out << nl << "exception__(ex)";
- }
- else
- {
- _out << nl << "Try";
- _out.inc();
- _out << nl << "throw ex";
- _out.dec();
- ExceptionList::const_iterator r;
- for(r = throws.begin(); r != throws.end(); ++r)
- {
- string exS = fixId((*r)->scoped());
- _out << nl << "Catch ex__ As " << exS;
- _out.inc();
- _out << nl << "os__().writeUserException(ex__)";
- _out << nl << "response__(false)";
- _out.dec();
- }
- _out << nl << "Catch ex__ As _System.Exception";
- _out.inc();
- _out << nl << "exception__(ex__)";
- _out.dec();
- _out << nl << "End Try";
- }
- _out.dec();
- _out << nl << "End Sub";
-
- _out.dec();
- _out << sp << nl << "End Class";
+ TypeStringList::const_iterator q;
+ _out << sp << nl << "Class " << classNameAMDI << '_' << name;
+ _out.inc();
+ _out << nl << "Inherits IceInternal.IncomingAsync";
+ _out << nl << "Implements " << classNameAMD << '_' << name;
+
+ _out << sp << nl << "Public Sub New(ByVal inc As IceInternal.Incoming)";
+ _out.inc();
+ _out << nl << "MyBase.New(inc)";
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public Sub ice_response" << spar << paramsAMD << epar
+ << " Implements " << classNameAMD << '_' << name << ".ice_response"; // TODO: should be containing class?
+ _out.inc();
+ if(ret || !outParams.empty())
+ {
+ _out << nl << "Try";
+ _out.inc();
+ _out << nl << "Dim os__ As IceInternal.BasicStream = Me.os__()";
+ for(q = outParams.begin(); q != outParams.end(); ++q)
+ {
+ string typeS = typeToString(q->first);
+ writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, false);
+ }
+ if(ret)
+ {
+ string retS = typeToString(ret);
+ writeMarshalUnmarshalCode(_out, ret, "ret__", true, false, false);
+ }
+ if(p->returnsClasses())
+ {
+ _out << nl << "os__.writePendingObjects()";
+ }
+ _out.dec();
+ _out << nl << "Catch ex__ As Ice.LocalException";
+ _out.inc();
+ _out << nl << "ice_exception(ex__)";
+ _out.dec();
+ _out << nl << "End Try";
+ }
+ _out << nl << "response__(true)";
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out << sp << nl << "Public Sub ice_exception(ByVal ex As _System.Exception)"
+ << " Implements " << classNameAMD << '_' << name << ".ice_exception"; // TODO: should be containing class?
+ _out.inc();
+ if(throws.empty())
+ {
+ _out << nl << "exception__(ex)";
+ }
+ else
+ {
+ _out << nl << "Try";
+ _out.inc();
+ _out << nl << "throw ex";
+ _out.dec();
+ ExceptionList::const_iterator r;
+ for(r = throws.begin(); r != throws.end(); ++r)
+ {
+ string exS = fixId((*r)->scoped());
+ _out << nl << "Catch ex__ As " << exS;
+ _out.inc();
+ _out << nl << "os__().writeUserException(ex__)";
+ _out << nl << "response__(false)";
+ _out.dec();
+ }
+ _out << nl << "Catch ex__ As _System.Exception";
+ _out.inc();
+ _out << nl << "exception__(ex__)";
+ _out.dec();
+ _out << nl << "End Try";
+ }
+ _out.dec();
+ _out << nl << "End Sub";
+
+ _out.dec();
+ _out << sp << nl << "End Class";
}
}
@@ -5270,14 +5270,14 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
_out << nl << "Inherits ";
if(p->isInterface())
{
- if(p->isLocal())
- {
- _out << fixId(name);
- }
- else
- {
- _out << name << "Disp_";
- }
+ if(p->isLocal())
+ {
+ _out << fixId(name);
+ }
+ else
+ {
+ _out << name << "Disp_";
+ }
}
else
{
@@ -5359,14 +5359,14 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
- bool hasAMD = p->hasMetaData("amd") || (*r)->hasMetaData("amd");
+ bool hasAMD = p->hasMetaData("amd") || (*r)->hasMetaData("amd");
string opName = hasAMD ? (*r)->name() + "_async" : fixId((*r)->name(), DotNet::ICloneable, true);
TypePtr ret = (*r)->returnType();
string retS = typeToString(ret);
vector<string> params;
- vector<string> args;
+ vector<string> args;
if(hasAMD)
{
params = getParamsAsync((*r), true);
@@ -5379,21 +5379,21 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
}
_out << sp << nl << "Public Overloads ";
- if(!p->isInterface() || !p->isLocal())
- {
- _out << "Overrides ";
- }
- string vbOp = (!ret || hasAMD) ? "Sub" : "Function";
- _out << vbOp << ' ' << opName << spar << params;
+ if(!p->isInterface() || !p->isLocal())
+ {
+ _out << "Overrides ";
+ }
+ string vbOp = (!ret || hasAMD) ? "Sub" : "Function";
+ _out << vbOp << ' ' << opName << spar << params;
if(!p->isLocal())
{
_out << "ByVal current__ As Ice.Current";
}
_out << epar;
- if(ret && !hasAMD)
- {
- _out << " As " << retS;
- }
+ if(ret && !hasAMD)
+ {
+ _out << " As " << retS;
+ }
_out.inc();
_out << nl;
if(ret && !hasAMD)
@@ -5407,7 +5407,7 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
}
_out << epar;
_out.dec();
- _out << nl << "End " << vbOp;
+ _out << nl << "End " << vbOp;
}
NameSet opNames;
@@ -5436,19 +5436,19 @@ Slice::Gen::TieVisitor::writeInheritedOperationsWithOpNames(const ClassDefPtr& p
OperationList::const_iterator r;
for(r = ops.begin(); r != ops.end(); ++r)
{
- bool hasAMD = p->hasMetaData("amd") || (*r)->hasMetaData("amd");
+ bool hasAMD = p->hasMetaData("amd") || (*r)->hasMetaData("amd");
string opName = hasAMD ? (*r)->name() + "_async" : fixId((*r)->name(), DotNet::ICloneable, true);
- if(opNames.find(opName) != opNames.end())
- {
- continue;
- }
- opNames.insert(opName);
+ if(opNames.find(opName) != opNames.end())
+ {
+ continue;
+ }
+ opNames.insert(opName);
TypePtr ret = (*r)->returnType();
string retS = typeToString(ret);
vector<string> params;
- vector<string> args;
+ vector<string> args;
if(hasAMD)
{
params = getParamsAsync((*r), true);
@@ -5461,21 +5461,21 @@ Slice::Gen::TieVisitor::writeInheritedOperationsWithOpNames(const ClassDefPtr& p
}
_out << sp << nl << "Public Overloads ";
- if(!p->isInterface() || !p->isLocal())
- {
- _out << "Overrides ";
- }
- string vbOp = (ret && !hasAMD) ? "Function" : "Sub";
- _out << vbOp << ' ' << opName << spar << params;
+ if(!p->isInterface() || !p->isLocal())
+ {
+ _out << "Overrides ";
+ }
+ string vbOp = (ret && !hasAMD) ? "Function" : "Sub";
+ _out << vbOp << ' ' << opName << spar << params;
if(!p->isLocal())
{
_out << "ByVal current__ As Ice.Current";
}
_out << epar;
- if(ret && !hasAMD)
- {
- _out << " As " << retS;
- }
+ if(ret && !hasAMD)
+ {
+ _out << " As " << retS;
+ }
_out.inc();
_out << nl;
if(ret && !hasAMD)
@@ -5488,7 +5488,7 @@ Slice::Gen::TieVisitor::writeInheritedOperationsWithOpNames(const ClassDefPtr& p
_out << "current__";
}
_out << epar;
- _out.dec();
+ _out.dec();
_out << nl << "End " << vbOp;
}
@@ -5516,113 +5516,113 @@ Slice::Gen::BaseImplVisitor::writeOperation(const OperationPtr& op, bool comment
if(comment)
{
- _out << nl << "' ";
+ _out << nl << "' ";
}
else
{
- _out << sp << nl;
+ _out << sp << nl;
}
if(!cl->isLocal() && (cl->hasMetaData("amd") || op->hasMetaData("amd")))
{
vector<string> pDecl = getParamsAsync(op, true);
- _out << "Public Overloads ";
- if(!forTie)
- {
- _out << "Overrides ";
- }
- _out << "Sub " << opName << "_async" << spar << pDecl << "ByVal current__ As Ice.Current" << epar;
-
- if(comment)
- {
- return;
- }
- else
- {
- if(forTie)
- {
- _out << " Implements " << cl->name() << "Operations_." << opName << "_async"; // TODO: should be containing class?
- }
- }
-
- _out.inc();
- if(ret)
- {
- _out << nl << "Dim ret__ As " << typeToString(ret) << " = " << writeValue(ret);
- }
- for(i = params.begin(); i != params.end(); ++i)
- {
- if((*i)->isOutParam())
- {
- string name = fixId((*i)->name());
- TypePtr type = (*i)->type();
- _out << nl << "Dim " << name << " As " << typeToString(type) << " = " << writeValue(type);
- }
- }
- _out << nl << "cb__.ice_response" << spar;
- if(ret)
- {
- _out << "ret__";
- }
- for(i = params.begin(); i != params.end(); ++i)
- {
- if((*i)->isOutParam())
- {
- _out << fixId((*i)->name());
- }
- }
- _out << epar;
- _out.dec();
- _out << nl << "End Sub";
+ _out << "Public Overloads ";
+ if(!forTie)
+ {
+ _out << "Overrides ";
+ }
+ _out << "Sub " << opName << "_async" << spar << pDecl << "ByVal current__ As Ice.Current" << epar;
+
+ if(comment)
+ {
+ return;
+ }
+ else
+ {
+ if(forTie)
+ {
+ _out << " Implements " << cl->name() << "Operations_." << opName << "_async"; // TODO: should be containing class?
+ }
+ }
+
+ _out.inc();
+ if(ret)
+ {
+ _out << nl << "Dim ret__ As " << typeToString(ret) << " = " << writeValue(ret);
+ }
+ for(i = params.begin(); i != params.end(); ++i)
+ {
+ if((*i)->isOutParam())
+ {
+ string name = fixId((*i)->name());
+ TypePtr type = (*i)->type();
+ _out << nl << "Dim " << name << " As " << typeToString(type) << " = " << writeValue(type);
+ }
+ }
+ _out << nl << "cb__.ice_response" << spar;
+ if(ret)
+ {
+ _out << "ret__";
+ }
+ for(i = params.begin(); i != params.end(); ++i)
+ {
+ if((*i)->isOutParam())
+ {
+ _out << fixId((*i)->name());
+ }
+ }
+ _out << epar;
+ _out.dec();
+ _out << nl << "End Sub";
}
else
{
- vector<string> pDecls = getParams(op);
- string vbOp = ret ? "Function" : "Sub";
-
- _out << "Public Overloads ";
- if(!forTie && !cl->isLocal())
- {
- _out << "Overrides ";
- }
- _out << vbOp << ' ' << fixId(opName, DotNet::ICloneable, true) << spar << pDecls;
- if(!cl->isLocal())
- {
- _out << "ByVal current__ As Ice.Current";
- }
- _out << epar;
- if(ret)
- {
- _out << " As " << retS;
- }
- if(comment)
- {
- return;
- }
- else
- {
- if(forTie)
- {
- _out << " Implements " << cl->name() << "Operations_." << fixId(opName, DotNet::ICloneable, true); // TODO: should be containing class?
- }
- }
- _out.inc();
- for(i = params.begin(); i != params.end(); ++i)
- {
- if((*i)->isOutParam())
- {
- string name = fixId((*i)->name());
- TypePtr type = (*i)->type();
- _out << nl << name << " = " << writeValue(type);
- }
- }
- if(ret)
- {
- _out << nl << "Return " << writeValue(ret);
- }
- _out.dec();
- _out << nl << "End " << vbOp;
+ vector<string> pDecls = getParams(op);
+ string vbOp = ret ? "Function" : "Sub";
+
+ _out << "Public Overloads ";
+ if(!forTie && !cl->isLocal())
+ {
+ _out << "Overrides ";
+ }
+ _out << vbOp << ' ' << fixId(opName, DotNet::ICloneable, true) << spar << pDecls;
+ if(!cl->isLocal())
+ {
+ _out << "ByVal current__ As Ice.Current";
+ }
+ _out << epar;
+ if(ret)
+ {
+ _out << " As " << retS;
+ }
+ if(comment)
+ {
+ return;
+ }
+ else
+ {
+ if(forTie)
+ {
+ _out << " Implements " << cl->name() << "Operations_." << fixId(opName, DotNet::ICloneable, true); // TODO: should be containing class?
+ }
+ }
+ _out.inc();
+ for(i = params.begin(); i != params.end(); ++i)
+ {
+ if((*i)->isOutParam())
+ {
+ string name = fixId((*i)->name());
+ TypePtr type = (*i)->type();
+ _out << nl << name << " = " << writeValue(type);
+ }
+ }
+ if(ret)
+ {
+ _out << nl << "Return " << writeValue(ret);
+ }
+ _out.dec();
+ _out << nl << "End " << vbOp;
}
}
@@ -5634,43 +5634,43 @@ Slice::Gen::BaseImplVisitor::writeValue(const TypePtr& type)
BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
if(builtin)
{
- switch(builtin->kind())
- {
- case Builtin::KindBool:
- {
- return "false";
- break;
- }
- case Builtin::KindByte:
- case Builtin::KindShort:
- case Builtin::KindInt:
- case Builtin::KindLong:
- {
- return "0";
- break;
- }
- case Builtin::KindFloat:
- {
- return "0.0F";
- break;
- }
- case Builtin::KindDouble:
- {
- return "0.0R";
- break;
- }
- default:
- {
- return "Nothing";
- break;
- }
- }
+ switch(builtin->kind())
+ {
+ case Builtin::KindBool:
+ {
+ return "false";
+ break;
+ }
+ case Builtin::KindByte:
+ case Builtin::KindShort:
+ case Builtin::KindInt:
+ case Builtin::KindLong:
+ {
+ return "0";
+ break;
+ }
+ case Builtin::KindFloat:
+ {
+ return "0.0F";
+ break;
+ }
+ case Builtin::KindDouble:
+ {
+ return "0.0R";
+ break;
+ }
+ default:
+ {
+ return "Nothing";
+ break;
+ }
+ }
}
EnumPtr en = EnumPtr::dynamicCast(type);
if(en)
{
- return fixId(en->scoped()) + "." + fixId((*en->getEnumerators().begin())->name());
+ return fixId(en->scoped()) + "." + fixId((*en->getEnumerators().begin())->name());
}
StructPtr st = StructPtr::dynamicCast(type);
@@ -5723,14 +5723,14 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
if(p->isInterface())
{
if(p->isLocal())
- {
- _out << "Inherits Ice.LocalObjectImpl";
- _out << nl << "Implements fixId(name)";
- }
- else
- {
- _out << "Inherits " << name << "Disp_";
- }
+ {
+ _out << "Inherits Ice.LocalObjectImpl";
+ _out << nl << "Implements fixId(name)";
+ }
+ else
+ {
+ _out << "Inherits " << name << "Disp_";
+ }
}
else
{
@@ -5805,14 +5805,14 @@ Slice::Gen::ImplTieVisitor::visitClassDefStart(const ClassDefPtr& p)
if(inheritImpl)
{
_out << nl << "Inherits ";
- if(bases.front()->isAbstract())
- {
- _out << bases.front()->name() << 'I';
- }
- else
- {
- _out << fixId(bases.front()->name());
- }
+ if(bases.front()->isAbstract())
+ {
+ _out << bases.front()->name() << 'I';
+ }
+ else
+ {
+ _out << fixId(bases.front()->name());
+ }
}
_out << nl << "Implements " << name << "Operations_";
diff --git a/cpp/src/slice2vb/Gen.h b/cpp/src/slice2vb/Gen.h
index 85ad4d6fcde..0d743201b07 100644
--- a/cpp/src/slice2vb/Gen.h
+++ b/cpp/src/slice2vb/Gen.h
@@ -46,10 +46,10 @@ public:
Gen(const std::string&,
const std::string&,
const std::vector<std::string>&,
- const std::string&,
- bool,
- bool,
- bool);
+ const std::string&,
+ bool,
+ bool,
+ bool);
~Gen();
bool operator!() const; // Returns true if there was a constructor error
@@ -77,12 +77,12 @@ private:
UnitVisitor(::IceUtil::Output&, bool);
- virtual bool visitModuleStart(const ModulePtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
private:
bool _stream;
- bool _globalMetaDataDone;
+ bool _globalMetaDataDone;
};
class TypesVisitor : public VbVisitor
@@ -91,24 +91,24 @@ private:
TypesVisitor(::IceUtil::Output&, bool);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitOperation(const OperationPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
- virtual bool visitExceptionStart(const ExceptionPtr&);
- virtual void visitExceptionEnd(const ExceptionPtr&);
- virtual bool visitStructStart(const StructPtr&);
- virtual void visitStructEnd(const StructPtr&);
- virtual void visitSequence(const SequencePtr&);
- virtual void visitDictionary(const DictionaryPtr&);
- virtual void visitEnum(const EnumPtr&);
- virtual void visitConst(const ConstPtr&);
- virtual void visitDataMember(const DataMemberPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual bool visitExceptionStart(const ExceptionPtr&);
+ virtual void visitExceptionEnd(const ExceptionPtr&);
+ virtual bool visitStructStart(const StructPtr&);
+ virtual void visitStructEnd(const StructPtr&);
+ virtual void visitSequence(const SequencePtr&);
+ virtual void visitDictionary(const DictionaryPtr&);
+ virtual void visitEnum(const EnumPtr&);
+ virtual void visitConst(const ConstPtr&);
+ virtual void visitDataMember(const DataMemberPtr&);
private:
- void invokeObjectMethod(const TypePtr&, const std::string&, const std::string&, const std::string&);
+ void invokeObjectMethod(const TypePtr&, const std::string&, const std::string&, const std::string&);
bool _stream;
};
@@ -119,11 +119,11 @@ private:
ProxyVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
- virtual void visitOperation(const OperationPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
};
class OpsVisitor : public VbVisitor
@@ -132,9 +132,9 @@ private:
OpsVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
private:
void writeOperations(const ClassDefPtr&, bool);
@@ -146,12 +146,12 @@ private:
HelperVisitor(::IceUtil::Output&, bool);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
- virtual void visitSequence(const SequencePtr&);
- virtual void visitDictionary(const DictionaryPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitSequence(const SequencePtr&);
+ virtual void visitDictionary(const DictionaryPtr&);
private:
@@ -164,10 +164,10 @@ private:
DelegateVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
};
class DelegateMVisitor : public VbVisitor
@@ -176,10 +176,10 @@ private:
DelegateMVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
};
class DelegateDVisitor : public VbVisitor
@@ -188,10 +188,10 @@ private:
DelegateDVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
};
class DispatcherVisitor : public VbVisitor
@@ -200,9 +200,9 @@ private:
DispatcherVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
};
class AsyncVisitor : public VbVisitor
@@ -211,11 +211,11 @@ private:
AsyncVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
- virtual void visitOperation(const OperationPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual void visitOperation(const OperationPtr&);
};
class TieVisitor : public VbVisitor
@@ -224,15 +224,15 @@ private:
TieVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
private:
- typedef ::std::set< ::std::string> NameSet;
- void writeInheritedOperationsWithOpNames(const ClassDefPtr&, NameSet&);
+ typedef ::std::set< ::std::string> NameSet;
+ void writeInheritedOperationsWithOpNames(const ClassDefPtr&, NameSet&);
};
class BaseImplVisitor : public VbVisitor
@@ -243,11 +243,11 @@ private:
protected:
- void writeOperation(const OperationPtr&, bool, bool);
+ void writeOperation(const OperationPtr&, bool, bool);
private:
- ::std::string writeValue(const TypePtr&);
+ ::std::string writeValue(const TypePtr&);
};
class ImplVisitor : public BaseImplVisitor
@@ -256,10 +256,10 @@ private:
ImplVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
- virtual void visitClassDefEnd(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual void visitClassDefEnd(const ClassDefPtr&);
};
class ImplTieVisitor : public BaseImplVisitor
@@ -268,9 +268,9 @@ private:
ImplTieVisitor(::IceUtil::Output&);
- virtual bool visitModuleStart(const ModulePtr&);
- virtual void visitModuleEnd(const ModulePtr&);
- virtual bool visitClassDefStart(const ClassDefPtr&);
+ virtual bool visitModuleStart(const ModulePtr&);
+ virtual void visitModuleEnd(const ModulePtr&);
+ virtual bool visitClassDefStart(const ClassDefPtr&);
};
};
diff --git a/cpp/src/slice2vb/Main.cpp b/cpp/src/slice2vb/Main.cpp
index 767b93257b2..e16990e3c3a 100644
--- a/cpp/src/slice2vb/Main.cpp
+++ b/cpp/src/slice2vb/Main.cpp
@@ -31,7 +31,7 @@ usage(const char* n)
"--tie Generate TIE classes.\n"
"--impl Generate sample implementations.\n"
"--impl-tie Generate sample TIE implementations.\n"
- "--depend Generate Makefile dependencies.\n"
+ "--depend Generate Makefile dependencies.\n"
"-d, --debug Print debug messages.\n"
"--ice Permit `Ice' prefix (for building Ice source code only)\n"
"--checksum Generate checksums for Slice definitions.\n"
@@ -69,20 +69,20 @@ main(int argc, char* argv[])
catch(const IceUtil::BadOptException& e)
{
cerr << argv[0] << ": " << e.reason << endl;
- usage(argv[0]);
- return EXIT_FAILURE;
+ usage(argv[0]);
+ return EXIT_FAILURE;
}
if(opts.isSet("help"))
{
- usage(argv[0]);
- return EXIT_SUCCESS;
+ usage(argv[0]);
+ return EXIT_SUCCESS;
}
if(opts.isSet("version"))
{
- cout << ICE_STRING_VERSION << endl;
- return EXIT_SUCCESS;
+ cout << ICE_STRING_VERSION << endl;
+ return EXIT_SUCCESS;
}
string cppArgs;
@@ -90,19 +90,19 @@ main(int argc, char* argv[])
vector<string>::const_iterator i;
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -D" + Preprocessor::addQuotes(*i);
+ cppArgs += " -D" + Preprocessor::addQuotes(*i);
}
optargs = opts.argVec("U");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- cppArgs += " -U" + Preprocessor::addQuotes(*i);
+ cppArgs += " -U" + Preprocessor::addQuotes(*i);
}
vector<string> includePaths = opts.argVec("I");
for(i = includePaths.begin(); i != includePaths.end(); ++i)
{
- cppArgs += " -I" + Preprocessor::addQuotes(*i);
+ cppArgs += " -I" + Preprocessor::addQuotes(*i);
}
bool preprocess = opts.isSet("E");
@@ -145,81 +145,81 @@ main(int argc, char* argv[])
for(i = args.begin(); i != args.end(); ++i)
{
- if(depend)
- {
- Preprocessor icecpp(argv[0], *i, cppArgs);
- icecpp.printMakefileDependencies(Preprocessor::VisualBasic);
- }
- else
- {
- Preprocessor icecpp(argv[0], *i, cppArgs);
- FILE* cppHandle = icecpp.preprocess(false);
-
- if(cppHandle == 0)
- {
- return EXIT_FAILURE;
- }
-
- if(preprocess)
- {
- char buf[4096];
- while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
- {
- if(fputs(buf, stdout) == EOF)
- {
- return EXIT_FAILURE;
- }
- }
- if(!icecpp.close())
- {
- return EXIT_FAILURE;
- }
- }
- else
- {
- UnitPtr p = Unit::createUnit(false, false, ice, caseSensitive);
- int parseStatus = p->parse(cppHandle, debug);
-
- if(!icecpp.close())
- {
- p->destroy();
- return EXIT_FAILURE;
- }
-
- if(parseStatus == EXIT_FAILURE)
- {
- status = EXIT_FAILURE;
- }
- else
- {
- Gen gen(argv[0], icecpp.getBaseName(), includePaths, output, impl, implTie, stream);
- if(!gen)
- {
- p->destroy();
- return EXIT_FAILURE;
- }
- gen.generate(p);
- if(tie)
- {
- gen.generateTie(p);
- }
- if(impl)
- {
- gen.generateImpl(p);
- }
- if(implTie)
- {
- gen.generateImplTie(p);
- }
- if(checksum)
- {
- gen.generateChecksums(p);
- }
- }
-
- p->destroy();
- }
- }
+ if(depend)
+ {
+ Preprocessor icecpp(argv[0], *i, cppArgs);
+ icecpp.printMakefileDependencies(Preprocessor::VisualBasic);
+ }
+ else
+ {
+ Preprocessor icecpp(argv[0], *i, cppArgs);
+ FILE* cppHandle = icecpp.preprocess(false);
+
+ if(cppHandle == 0)
+ {
+ return EXIT_FAILURE;
+ }
+
+ if(preprocess)
+ {
+ char buf[4096];
+ while(fgets(buf, static_cast<int>(sizeof(buf)), cppHandle) != NULL)
+ {
+ if(fputs(buf, stdout) == EOF)
+ {
+ return EXIT_FAILURE;
+ }
+ }
+ if(!icecpp.close())
+ {
+ return EXIT_FAILURE;
+ }
+ }
+ else
+ {
+ UnitPtr p = Unit::createUnit(false, false, ice, caseSensitive);
+ int parseStatus = p->parse(cppHandle, debug);
+
+ if(!icecpp.close())
+ {
+ p->destroy();
+ return EXIT_FAILURE;
+ }
+
+ if(parseStatus == EXIT_FAILURE)
+ {
+ status = EXIT_FAILURE;
+ }
+ else
+ {
+ Gen gen(argv[0], icecpp.getBaseName(), includePaths, output, impl, implTie, stream);
+ if(!gen)
+ {
+ p->destroy();
+ return EXIT_FAILURE;
+ }
+ gen.generate(p);
+ if(tie)
+ {
+ gen.generateTie(p);
+ }
+ if(impl)
+ {
+ gen.generateImpl(p);
+ }
+ if(implTie)
+ {
+ gen.generateImplTie(p);
+ }
+ if(checksum)
+ {
+ gen.generateChecksums(p);
+ }
+ }
+
+ p->destroy();
+ }
+ }
}
return status;