summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2001-09-20 08:26:05 +0000
committerMarc Laukien <marc@zeroc.com>2001-09-20 08:26:05 +0000
commit6f7cc45e3461e90cf2658a01f16758af31c8d814 (patch)
tree47bb813dfffa39bc0bbe00cd7669245cbd14eac8 /cpp/src
parentfixes (diff)
downloadice-6f7cc45e3461e90cf2658a01f16758af31c8d814.tar.bz2
ice-6f7cc45e3461e90cf2658a01f16758af31c8d814.tar.xz
ice-6f7cc45e3461e90cf2658a01f16758af31c8d814.zip
evictor modes
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Freeze/.depend2
-rw-r--r--cpp/src/Freeze/EvictorI.cpp102
-rw-r--r--cpp/src/Freeze/EvictorI.h10
-rw-r--r--cpp/src/Ice/Incoming.cpp29
-rw-r--r--cpp/src/Ice/Object.cpp6
-rw-r--r--cpp/src/IcePack/Forward.cpp4
-rw-r--r--cpp/src/IcePack/Forward.h5
-rw-r--r--cpp/src/Slice/Grammer.y103
-rw-r--r--cpp/src/slice2cpp/Gen.cpp94
9 files changed, 291 insertions, 64 deletions
diff --git a/cpp/src/Freeze/.depend b/cpp/src/Freeze/.depend
index e9d21b797a5..e05833aa45d 100644
--- a/cpp/src/Freeze/.depend
+++ b/cpp/src/Freeze/.depend
@@ -1,4 +1,4 @@
DB.o: DB.cpp ../../include/Freeze/DB.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/IceUtil/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Freeze/EvictorF.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h
DBI.o: DBI.cpp ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/IceUtil/Config.h ../../include/Ice/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Buffer.h ../Freeze/DBI.h ../../include/IceUtil/IceUtil.h ../../include/IceUtil/Functional.h ../../include/IceUtil/Shared.h ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ServantFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ServantFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../../include/Freeze/DB.h ../../include/Freeze/EvictorF.h ../Freeze/EvictorI.h ../../include/Freeze/Evictor.h ../../include/Freeze/Initialize.h ../../include/Freeze/DBF.h
Evictor.o: Evictor.cpp ../../include/Freeze/Evictor.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/IceUtil/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/Stream.h ../../include/Ice/InstanceF.h ../../include/Ice/Buffer.h
-EvictorI.o: EvictorI.cpp ../Freeze/EvictorI.h ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/Config.h ../../include/IceUtil/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/IceUtil/Shared.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ServantFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ServantFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../../include/Ice/InstanceF.h ../../include/Freeze/DB.h ../../include/Freeze/EvictorF.h ../../include/Freeze/Evictor.h
+EvictorI.o: EvictorI.cpp ../../include/Ice/Object.h ../../include/IceUtil/Shared.h ../../include/IceUtil/Config.h ../../include/Ice/ObjectF.h ../../include/Ice/Handle.h ../../include/IceUtil/Handle.h ../../include/Ice/Config.h ../../include/Ice/Proxy.h ../../include/Ice/ProxyF.h ../../include/Ice/ProxyHandle.h ../../include/Ice/ProxyFactoryF.h ../../include/Ice/EmitterF.h ../../include/Ice/ReferenceF.h ../Freeze/EvictorI.h ../../include/Ice/Ice.h ../../include/Ice/Communicator.h ../../include/Ice/LocalObjectF.h ../../include/Ice/Native.h ../../include/Ice/LocalObject.h ../../include/Ice/LoggerF.h ../../include/Ice/ObjectAdapterF.h ../../include/Ice/PicklerF.h ../../include/Ice/PropertiesF.h ../../include/Ice/ServantFactoryF.h ../../include/Ice/ObjectAdapter.h ../../include/Ice/CommunicatorF.h ../../include/Ice/LocalException.h ../../include/Ice/Properties.h ../../include/Ice/Logger.h ../../include/Ice/ServantFactory.h ../../include/Ice/Pickler.h ../../include/Ice/Initialize.h ../../include/Ice/InstanceF.h ../../include/Freeze/DB.h ../../include/Freeze/EvictorF.h ../../include/Freeze/Evictor.h
diff --git a/cpp/src/Freeze/EvictorI.cpp b/cpp/src/Freeze/EvictorI.cpp
index f5ca9f75c74..dc402c0bf89 100644
--- a/cpp/src/Freeze/EvictorI.cpp
+++ b/cpp/src/Freeze/EvictorI.cpp
@@ -8,6 +8,7 @@
//
// **********************************************************************
+#include <Ice/Object.h> // Not included in Ice/Ice.h
#include <Freeze/EvictorI.h>
#include <sstream>
@@ -18,6 +19,7 @@ using namespace Freeze;
Freeze::EvictorI::EvictorI(const DBPtr& db, const CommunicatorPtr& communicator) :
_db(db),
_evictorSize(static_cast<map<string, EvictorElement>::size_type>(10)),
+ _persistenceMode(SaveUponEviction),
_logger(communicator->getLogger()),
_trace(0)
{
@@ -25,7 +27,7 @@ Freeze::EvictorI::EvictorI(const DBPtr& db, const CommunicatorPtr& communicator)
string value;
value = properties->getProperty("Freeze.Trace.Evictor");
- if(!value.empty())
+ if (!value.empty())
{
_trace = atoi(value.c_str());
}
@@ -65,6 +67,46 @@ Freeze::EvictorI::getSize()
}
void
+Freeze::EvictorI::setPersistenceMode(EvictorPersistenceMode persistenceMode)
+{
+ JTCSyncT<JTCMutex> sync(*this);
+
+ if (_persistenceMode != persistenceMode)
+ {
+ _persistenceMode = persistenceMode;
+
+ //
+ // If we switch to SaveAfterMutatingOperation, we save all
+ // Servants now, so that it can safely be assumed that no data
+ // can get lost after the mode has been changed.
+ //
+ if (_persistenceMode == SaveAfterMutatingOperation && !_evictorMap.empty())
+ {
+ if (_trace >= 1)
+ {
+ ostringstream s;
+ s << "switching to SaveUponEviction\n"
+ << "saving all Ice Objects in the queue to the database";
+ _logger->trace("Evictor", s.str());
+ }
+
+ for (map<string, EvictorElement>::iterator p = _evictorMap.begin(); p != _evictorMap.end(); ++p)
+ {
+ _db->put(*(p->second.position), p->second.servant);
+ }
+ }
+ }
+}
+
+EvictorPersistenceMode
+Freeze::EvictorI::getPersistenceMode()
+{
+ JTCSyncT<JTCMutex> sync(*this);
+
+ return _persistenceMode;
+}
+
+void
Freeze::EvictorI::createObject(const string& identity, const ObjectPtr& servant)
{
JTCSyncT<JTCMutex> sync(*this);
@@ -111,7 +153,7 @@ Freeze::EvictorI::installServantInitializer(const ServantInitializerPtr& initial
}
ObjectPtr
-Freeze::EvictorI::locate(const ObjectAdapterPtr& adapter, const string& identity, ObjectPtr&)
+Freeze::EvictorI::locate(const ObjectAdapterPtr& adapter, const string& identity, const string&, ObjectPtr&)
{
JTCSyncT<JTCMutex> sync(*this);
@@ -121,7 +163,7 @@ Freeze::EvictorI::locate(const ObjectAdapterPtr& adapter, const string& identity
if (_trace >= 2)
{
ostringstream s;
- s << "found \"" << identity << "\" in queue";
+ s << "found \"" << identity << "\" in the queue";
_logger->trace("Evictor", s.str());
}
@@ -143,8 +185,8 @@ Freeze::EvictorI::locate(const ObjectAdapterPtr& adapter, const string& identity
if (_trace >= 2)
{
ostringstream s;
- s << "couldn't find \"" << identity << "\" in queue\n"
- << "loading \"" << identity << "\" from database";
+ s << "couldn't find \"" << identity << "\" in the queue\n"
+ << "loading \"" << identity << "\" from the database";
_logger->trace("Evictor", s.str());
}
@@ -179,9 +221,24 @@ Freeze::EvictorI::locate(const ObjectAdapterPtr& adapter, const string& identity
}
void
-Freeze::EvictorI::finished(const ObjectAdapterPtr&, const string&, const ObjectPtr&, const ObjectPtr&)
+Freeze::EvictorI::finished(const ObjectAdapterPtr&, const string& identity, const ObjectPtr& servant,
+ const string& operation, const ObjectPtr&)
{
- //JTCSyncT<JTCMutex> sync(*this);
+ JTCSyncT<JTCMutex> sync(*this);
+
+ assert(servant);
+
+ //
+ // If we are in SaveAfterMutatingOperation mode, we must save the
+ // Ice Object if this was a mutating call.
+ //
+ if (_persistenceMode == SaveAfterMutatingOperation)
+ {
+ if (servant->_isMutating(operation))
+ {
+ _db->put(identity, servant);
+ }
+ }
}
void
@@ -192,18 +249,25 @@ Freeze::EvictorI::deactivate()
if (_trace >= 1)
{
ostringstream s;
- s << "deactivating, saving all Ice Objects in queue in database";
+ s << "deactivating, saving all Ice Objects in the queue to the database";
_logger->trace("Evictor", s.str());
}
//
- // Save all Ice Objects in the database upon deactivation, and
- // clear the evictor map and list.
+ // If we are not in SaveAfterMutatingOperation mode, we must save
+ // all Ice Objects in the database upon deactivation.
//
- for (map<string, EvictorElement>::iterator p = _evictorMap.begin(); p != _evictorMap.end(); ++p)
+ if (_persistenceMode != SaveAfterMutatingOperation)
{
- _db->put(*(p->second.position), p->second.servant);
+ for (map<string, EvictorElement>::iterator p = _evictorMap.begin(); p != _evictorMap.end(); ++p)
+ {
+ _db->put(*(p->second.position), p->second.servant);
+ }
}
+
+ //
+ // We must clear the evictor map and list up deactivation.
+ //
_evictorMap.clear();
_evictorList.clear();
}
@@ -234,15 +298,19 @@ Freeze::EvictorI::evict()
assert(_evictorMap.size() == _evictorSize);
//
- // Save the evicted Ice Object to the database.
+ // If we are in SaveUponEviction mode, we must save the
+ // evicted Ice Object to the database.
//
- _db->put(identity, servant);
+ if (_persistenceMode == SaveUponEviction)
+ {
+ _db->put(identity, servant);
+ }
if (_trace >= 2)
{
ostringstream s;
- s << "evicted \"" << identity << "\" from queue\n"
- << "number of elements in queue: " << _evictorMap.size();
+ s << "evicted \"" << identity << "\" from the queue\n"
+ << "number of elements in the queue: " << _evictorMap.size();
_logger->trace("Evictor", s.str());
}
}
@@ -254,7 +322,7 @@ Freeze::EvictorI::add(const string& identity, const ObjectPtr& servant)
//
// Ignore the request if the Ice Object is already in the queue.
//
- if(_evictorMap.find(identity) != _evictorMap.end())
+ if (_evictorMap.find(identity) != _evictorMap.end())
{
return;
}
diff --git a/cpp/src/Freeze/EvictorI.h b/cpp/src/Freeze/EvictorI.h
index 6041b10d6aa..89164c8d17e 100644
--- a/cpp/src/Freeze/EvictorI.h
+++ b/cpp/src/Freeze/EvictorI.h
@@ -28,13 +28,17 @@ public:
virtual void setSize(Ice::Int);
virtual Ice::Int getSize();
+ virtual void setPersistenceMode(EvictorPersistenceMode);
+ virtual EvictorPersistenceMode getPersistenceMode();
+
virtual void createObject(const std::string&, const Ice::ObjectPtr&);
virtual void destroyObject(const std::string&);
virtual void installServantInitializer(const ServantInitializerPtr&);
- virtual Ice::ObjectPtr locate(const Ice::ObjectAdapterPtr&, const std::string&, Ice::ObjectPtr&);
- virtual void finished(const Ice::ObjectAdapterPtr&, const std::string&, const Ice::ObjectPtr&,
+ virtual Ice::ObjectPtr locate(const Ice::ObjectAdapterPtr&, const std::string&, const std::string&,
+ Ice::ObjectPtr&);
+ virtual void finished(const Ice::ObjectAdapterPtr&, const std::string&, const Ice::ObjectPtr&, const std::string&,
const Ice::ObjectPtr&);
virtual void deactivate();
@@ -55,6 +59,8 @@ private:
std::list<std::string> _evictorList;
std::map<std::string, EvictorElement>::size_type _evictorSize;
+ EvictorPersistenceMode _persistenceMode;
+
ServantInitializerPtr _initializer;
::Ice::LoggerPtr _logger;
diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp
index 799b129ab16..4d9b0c2cc8b 100644
--- a/cpp/src/Ice/Incoming.cpp
+++ b/cpp/src/Ice/Incoming.cpp
@@ -51,33 +51,42 @@ IceInternal::Incoming::invoke(Stream& is)
locator = _adapter->getServantLocator();
if (locator)
{
- servant = locator->locate(_adapter, identity, cookie);
+ servant = locator->locate(_adapter, identity, operation, cookie);
}
}
if(!servant)
{
*(_os.b.begin() + statusPos) = static_cast<Byte>(DispatchObjectNotExist);
- return;
}
-
- DispatchStatus status = servant->__dispatch(*this, operation);
- if (status != DispatchOK && status != DispatchException && status != DispatchOperationNotExist)
+ else
{
- throw UnknownReplyStatusException(__FILE__, __LINE__);
+ DispatchStatus status = servant->__dispatch(*this, operation);
+ if (status != DispatchOK && status != DispatchException && status != DispatchOperationNotExist)
+ {
+ throw UnknownReplyStatusException(__FILE__, __LINE__);
+ }
+
+ *(_os.b.begin() + statusPos) = static_cast<Byte>(status);
}
-
- *(_os.b.begin() + statusPos) = static_cast<Byte>(status);
}
catch(const LocationForward& p)
{
*(_os.b.begin() + statusPos) = static_cast<Byte>(DispatchLocationForward);
_os.write(p._prx);
}
+ catch(...)
+ {
+ if (locator && servant)
+ {
+ locator->finished(_adapter, identity, servant, operation, cookie);
+ }
+ throw;
+ }
- if (locator)
+ if (locator && servant)
{
- locator->finished(_adapter, identity, servant, cookie);
+ locator->finished(_adapter, identity, servant, operation, cookie);
}
}
diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp
index ae02d78afe9..a97fc148d9c 100644
--- a/cpp/src/Ice/Object.cpp
+++ b/cpp/src/Ice/Object.cpp
@@ -130,3 +130,9 @@ Ice::Object::__dispatch(Incoming& in, const string& name)
assert(false);
return DispatchOperationNotExist;
}
+
+bool
+Ice::Object::_isMutating(const std::string&)
+{
+ return false;
+}
diff --git a/cpp/src/IcePack/Forward.cpp b/cpp/src/IcePack/Forward.cpp
index 4cc4669d356..7051ba2267c 100644
--- a/cpp/src/IcePack/Forward.cpp
+++ b/cpp/src/IcePack/Forward.cpp
@@ -49,7 +49,7 @@ IcePack::Forward::~Forward()
}
ObjectPtr
-IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const string& identity, ObjectPtr&)
+IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const string& identity, const string&, ObjectPtr&)
{
//
// Look up the server description
@@ -160,7 +160,7 @@ IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const string& identity
}
void
-IcePack::Forward::finished(const ObjectAdapterPtr&, const string&, const ObjectPtr&, const ObjectPtr&)
+IcePack::Forward::finished(const ObjectAdapterPtr&, const string&, const ObjectPtr&, const string&, const ObjectPtr&)
{
// Nothing to do
}
diff --git a/cpp/src/IcePack/Forward.h b/cpp/src/IcePack/Forward.h
index 990e200d250..a905485e587 100644
--- a/cpp/src/IcePack/Forward.h
+++ b/cpp/src/IcePack/Forward.h
@@ -26,8 +26,9 @@ public:
Forward(const Ice::CommunicatorPtr& communicator, const AdminPtr&);
virtual ~Forward();
- virtual Ice::ObjectPtr locate(const Ice::ObjectAdapterPtr&, const std::string&, Ice::ObjectPtr&);
- virtual void finished(const Ice::ObjectAdapterPtr&, const std::string&, const Ice::ObjectPtr&,
+ virtual Ice::ObjectPtr locate(const Ice::ObjectAdapterPtr&, const std::string&, const std::string&,
+ Ice::ObjectPtr&);
+ virtual void finished(const Ice::ObjectAdapterPtr&, const std::string&, const Ice::ObjectPtr&, const std::string&,
const Ice::ObjectPtr&);
virtual void deactivate();
diff --git a/cpp/src/Slice/Grammer.y b/cpp/src/Slice/Grammer.y
index 8b76b8c7361..ad41425efcf 100644
--- a/cpp/src/Slice/Grammer.y
+++ b/cpp/src/Slice/Grammer.y
@@ -25,18 +25,21 @@ yyerror(const char* s)
%pure_parser
-%token ICE_SCOPE_DELIMITOR
+//
+// All keyword tokens. Make sure to modify the "keyword" rule in this
+// file if the list of keywords is changed.
+//
%token ICE_MODULE
-%token ICE_LOCAL
%token ICE_CLASS
%token ICE_INTERFACE
%token ICE_STRUCT
+%token ICE_LOCAL
%token ICE_EXTENDS
%token ICE_IMPLEMENTS
%token ICE_THROWS
%token ICE_VOID
-%token ICE_BOOL
%token ICE_BYTE
+%token ICE_BOOL
%token ICE_SHORT
%token ICE_INT
%token ICE_LONG
@@ -51,6 +54,11 @@ yyerror(const char* s)
%token ICE_DICTIONARY
%token ICE_ENUM
%token ICE_NONMUTATING
+
+//
+// Other tokens.
+//
+%token ICE_SCOPE_DELIMITOR
%token ICE_IDENTIFIER
%token ICE_OP_IDENTIFIER
@@ -535,6 +543,16 @@ parameters
unit->error("missing declarator");
$$ = new TypeStringListTok;
}
+| type keyword ',' parameters
+{
+ unit->error("keyword can not be used as declarator");
+ $$ = $4
+}
+| type keyword
+{
+ unit->error("keyword can not be used as declarator");
+ $$ = new TypeStringListTok;
+}
|
{
$$ = new TypeStringListTok;
@@ -808,4 +826,83 @@ scoped_name
}
;
+// ----------------------------------------------------------------------
+keyword
+// ----------------------------------------------------------------------
+: ICE_MODULE
+{
+}
+| ICE_CLASS
+{
+}
+| ICE_INTERFACE
+{
+}
+| ICE_STRUCT
+{
+}
+| ICE_LOCAL
+{
+}
+| ICE_EXTENDS
+{
+}
+| ICE_IMPLEMENTS
+{
+}
+| ICE_THROWS
+{
+}
+| ICE_VOID
+{
+}
+| ICE_BYTE
+{
+}
+| ICE_BOOL
+{
+}
+| ICE_SHORT
+{
+}
+| ICE_INT
+{
+}
+| ICE_LONG
+{
+}
+| ICE_FLOAT
+{
+}
+| ICE_DOUBLE
+{
+}
+| ICE_STRING
+{
+}
+| ICE_WSTRING
+{
+}
+| ICE_OBJECT
+{
+}
+| ICE_LOCAL_OBJECT
+{
+}
+| ICE_NATIVE
+{
+}
+| ICE_SEQUENCE
+{
+}
+| ICE_DICTIONARY
+{
+}
+| ICE_ENUM
+{
+}
+| ICE_NONMUTATING
+{
+}
+
%%
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 79375e7f16c..93b0172359e 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -1443,15 +1443,15 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
StringList::iterator q;
H << sp;
- H << nl << exp2 << "static std::string __ids[" << ids.size() << "];";
+ H << nl << exp2 << "static ::std::string __ids[" << ids.size() << "];";
H << sp;
- H << nl << exp2 << "static std::string __classIds[" << classIds.size() << "];";
+ H << nl << exp2 << "static ::std::string __classIds[" << classIds.size() << "];";
H << sp;
- H << nl << exp2 << "virtual bool _isA(const std::string&);";
+ H << nl << exp2 << "virtual bool _isA(const ::std::string&);";
H << sp;
- H << nl << exp2 << "virtual const std::string* _classIds();";
+ H << nl << exp2 << "virtual const ::std::string* _classIds();";
C << sp;
- C << nl << "std::string " << scoped.substr(2) << "::__ids[" << ids.size() << "] =";
+ C << nl << "::std::string " << scoped.substr(2) << "::__ids[" << ids.size() << "] =";
C << sb;
q = ids.begin();
while (q != ids.end())
@@ -1464,7 +1464,7 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
}
C << eb << ';';
C << sp;
- C << nl << "std::string " << scoped.substr(2) << "::__classIds[" << classIds.size() << "] =";
+ C << nl << "::std::string " << scoped.substr(2) << "::__classIds[" << classIds.size() << "] =";
C << sb;
q = classIds.begin();
while (q != classIds.end())
@@ -1477,15 +1477,15 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
}
C << eb << ';';
C << sp;
- C << nl << "bool" << nl << scoped.substr(2) << "::_isA(const std::string& s)";
+ C << nl << "bool" << nl << scoped.substr(2) << "::_isA(const ::std::string& s)";
C << sb;
- C << nl << "std::string* b = __ids;";
- C << nl << "std::string* e = __ids + " << ids.size() << ';';
- C << nl << "std::pair<std::string*, std::string*> r = std::equal_range(b, e, s);";
+ C << nl << "::std::string* b = __ids;";
+ C << nl << "::std::string* e = __ids + " << ids.size() << ';';
+ C << nl << "::std::pair< ::std::string*, ::std::string*> r = ::std::equal_range(b, e, s);";
C << nl << "return r.first != r.second;";
C << eb;
C << sp;
- C << nl << "const std::string*" << nl << scoped.substr(2) << "::_classIds()";
+ C << nl << "const ::std::string*" << nl << scoped.substr(2) << "::_classIds()";
C << sb;
C << nl << "return __classIds;";
C << eb;
@@ -1518,25 +1518,36 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
}
}
- OperationList allOperations = p->allOperations();
- if (!p->allOperations().empty())
+ OperationList allOps = p->allOperations();
+ if (!allOps.empty())
{
StringList allOpNames;
- transform(allOperations.begin(), allOperations.end(), back_inserter(allOpNames),
- ::IceUtil::memFun(&Operation::name));
+ transform(allOps.begin(), allOps.end(), back_inserter(allOpNames), ::IceUtil::memFun(&Operation::name));
allOpNames.push_back("_isA");
allOpNames.push_back("_ping");
allOpNames.sort();
allOpNames.unique();
+
+ OperationList allMutatingOps;
+ remove_copy_if(allOps.begin(), allOps.end(), back_inserter(allMutatingOps),
+ ::IceUtil::memFun(&Operation::nonmutating));
+ StringList allMutatingOpNames;
+ transform(allMutatingOps.begin(), allMutatingOps.end(), back_inserter(allMutatingOpNames),
+ ::IceUtil::memFun(&Operation::name));
+ // Don't add _isA and _ping. These operations are non-mutating.
+ allMutatingOpNames.sort();
+ allMutatingOpNames.unique();
StringList::iterator q;
H << sp;
- H << nl << exp2 << "static std::string __names[" << allOpNames.size() << "];";
+ H << nl << exp2 << "static ::std::string __all[" << allOpNames.size() << "];";
+ H << nl << exp2 << "static ::std::string __mutating[" << allMutatingOpNames.size() << "];";
H << nl << exp2 << "virtual ::IceInternal::DispatchStatus "
- << "__dispatch(::IceInternal::Incoming&, const std::string&);";
+ << "__dispatch(::IceInternal::Incoming&, const ::std::string&);";
+ H << nl << exp2 << "virtual bool _isMutating(const ::std::string&);";
C << sp;
- C << nl << "std::string " << scoped.substr(2) << "::__names[" << allOpNames.size() << "] =";
+ C << nl << "::std::string " << scoped.substr(2) << "::__all[" << allOpNames.size() << "] =";
C << sb;
q = allOpNames.begin();
while (q != allOpNames.end())
@@ -1549,18 +1560,31 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
}
C << eb << ';';
C << sp;
+ C << nl << "::std::string " << scoped.substr(2) << "::__mutating[" << allMutatingOpNames.size() << "] =";
+ C << sb;
+ q = allMutatingOpNames.begin();
+ while (q != allMutatingOpNames.end())
+ {
+ C << nl << '"' << *q << '"';
+ if (++q != allMutatingOpNames.end())
+ {
+ C << ',';
+ }
+ }
+ C << eb << ';';
+ C << sp;
C << nl << "::IceInternal::DispatchStatus" << nl << scoped.substr(2)
- << "::__dispatch(::IceInternal::Incoming& in, const std::string& s)";
+ << "::__dispatch(::IceInternal::Incoming& in, const ::std::string& s)";
C << sb;
- C << nl << "std::string* b = __names;";
- C << nl << "std::string* e = __names + " << allOpNames.size() << ';';
- C << nl << "std::pair<std::string*, std::string*> r = std::equal_range(b, e, s);";
+ C << nl << "::std::string* b = __all;";
+ C << nl << "::std::string* e = __all + " << allOpNames.size() << ';';
+ C << nl << "::std::pair< ::std::string*, ::std::string*> r = ::std::equal_range(b, e, s);";
C << nl << "if (r.first == r.second)";
C << sb;
C << nl << "return ::IceInternal::DispatchOperationNotExist;";
C << eb;
C << sp;
- C << nl << "switch (r.first - __names)";
+ C << nl << "switch (r.first - __all)";
C << sb;
int i = 0;
for (q = allOpNames.begin(); q != allOpNames.end(); ++q)
@@ -1575,6 +1599,14 @@ Slice::Gen::ObjectVisitor::visitClassDefEnd(const ClassDefPtr& p)
C << nl << "assert(false);";
C << nl << "return ::IceInternal::DispatchOperationNotExist;";
C << eb;
+ C << sp;
+ C << nl << "bool" << nl << scoped.substr(2)
+ << "::_isMutating(const ::std::string& s)";
+ C << sb;
+ C << nl << "::std::string* b = __mutating;";
+ C << nl << "::std::string* e = __mutating + " << allMutatingOpNames.size() << ';';
+ C << nl << "return ::std::binary_search(b, e, s);";
+ C << eb;
}
H << sp;
H << nl << exp2 << "virtual void __write(::IceInternal::Stream*);";
@@ -1835,10 +1867,17 @@ Slice::Gen::IceVisitor::visitClassDefStart(const ClassDefPtr& p)
if (!p->isLocal())
{
C << sp;
- C << nl << "void IceInternal::incRef(::IceProxy" << scoped << "* p) { p->__incRef(); }";
- C << nl << "void IceInternal::decRef(::IceProxy" << scoped << "* p) { p->__decRef(); }";
+ C << nl << "void" << nl << "IceInternal::incRef(::IceProxy" << scoped << "* p)";
+ C << sb;
+ C << "p->__incRef();";
+ C << eb;
+ C << nl << "void" << nl << "IceInternal::decRef(::IceProxy" << scoped << "* p)";
+ C << sb;
+ C << "p->__decRef();";
+ C << eb;
C << sp;
- C << nl << "void IceInternal::checkedCast(::IceProxy::Ice::Object* b, ::IceProxy" << scoped << "*& d)";
+ C << nl << "void" << nl << "IceInternal::checkedCast(::IceProxy::Ice::Object* b, ::IceProxy" << scoped
+ << "*& d)";
C << sb;
C << nl << "d = dynamic_cast< ::IceProxy" << scoped << "*>(b);";
C << nl << "if (!d && b->_isA(\"" << scoped << "\"))";
@@ -1848,7 +1887,8 @@ Slice::Gen::IceVisitor::visitClassDefStart(const ClassDefPtr& p)
C << eb;
C << eb;
C << sp;
- C << nl << "void IceInternal::uncheckedCast(::IceProxy::Ice::Object* b, ::IceProxy" << scoped << "*& d)";
+ C << nl << "void" << nl << "IceInternal::uncheckedCast(::IceProxy::Ice::Object* b, ::IceProxy" << scoped
+ << "*& d)";
C << sb;
C << nl << "d = dynamic_cast< ::IceProxy" << scoped << "*>(b);";
C << nl << "if (!d)";