summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Freeze/EvictorI.cpp2
-rw-r--r--cpp/src/Glacier/Blobject.cpp6
-rw-r--r--cpp/src/Glacier/Missive.cpp6
-rw-r--r--cpp/src/Ice/Incoming.cpp2
-rw-r--r--cpp/src/Ice/Proxy.cpp2
-rw-r--r--cpp/src/IcePack/AdapterManager.ice2
-rw-r--r--cpp/src/IceStorm/TopicI.cpp2
-rw-r--r--cpp/src/Slice/Grammar.y168
-rw-r--r--cpp/src/Slice/Parser.cpp24
-rw-r--r--cpp/src/Slice/Scanner.l1
-rw-r--r--cpp/src/slice2cpp/Gen.cpp18
-rw-r--r--cpp/src/slice2java/Gen.cpp10
12 files changed, 144 insertions, 99 deletions
diff --git a/cpp/src/Freeze/EvictorI.cpp b/cpp/src/Freeze/EvictorI.cpp
index 88a35b81f80..9744072f18c 100644
--- a/cpp/src/Freeze/EvictorI.cpp
+++ b/cpp/src/Freeze/EvictorI.cpp
@@ -319,7 +319,7 @@ Freeze::EvictorI::finished(const ObjectAdapterPtr&, const Current& current,
//
if(_persistenceMode == SaveAfterMutatingOperation)
{
- if(!current.nonmutating)
+ if(!current.isNonmutating)
{
_dict.insert(make_pair(current.id, servant));
}
diff --git a/cpp/src/Glacier/Blobject.cpp b/cpp/src/Glacier/Blobject.cpp
index 5ee9a56a7e4..b584f5c4018 100644
--- a/cpp/src/Glacier/Blobject.cpp
+++ b/cpp/src/Glacier/Blobject.cpp
@@ -74,16 +74,16 @@ Glacier::Blobject::invoke(ObjectPrx& proxy, const vector<Byte>& inParams, vector
out << "routing to:\n"
<< "proxy = " << _communicator->proxyToString(proxy) << '\n'
<< "operation = " << current.operation << '\n'
- << "nonmutating = " << (current.nonmutating ? "true" : "false");
+ << "nonmutating = " << (current.isNonmutating ? "true" : "false");
}
if(_forwardContext)
{
- return proxy->ice_invoke(current.operation, current.nonmutating, inParams, outParams, current.ctx);
+ return proxy->ice_invoke(current.operation, current.isNonmutating, inParams, outParams, current.ctx);
}
else
{
- return proxy->ice_invoke(current.operation, current.nonmutating, inParams, outParams);
+ return proxy->ice_invoke(current.operation, current.isNonmutating, inParams, outParams);
}
}
}
diff --git a/cpp/src/Glacier/Missive.cpp b/cpp/src/Glacier/Missive.cpp
index ec9757e27f2..ca3351850d4 100644
--- a/cpp/src/Glacier/Missive.cpp
+++ b/cpp/src/Glacier/Missive.cpp
@@ -34,11 +34,11 @@ Glacier::Missive::invoke()
std::vector<Byte> dummy;
if(_forwardContext)
{
- _proxy->ice_invoke(_current.operation, _current.nonmutating, _inParams, dummy, _current.ctx);
+ _proxy->ice_invoke(_current.operation, _current.isNonmutating, _inParams, dummy, _current.ctx);
}
else
{
- _proxy->ice_invoke(_current.operation, _current.nonmutating, _inParams, dummy);
+ _proxy->ice_invoke(_current.operation, _current.isNonmutating, _inParams, dummy);
}
}
@@ -161,7 +161,7 @@ Glacier::MissiveQueue::run()
out << "batch routing to:\n"
<< "proxy = " << _communicator->proxyToString(proxy) << '\n'
<< "operation = " << current.operation << '\n'
- << "nonmutating = " << (current.nonmutating ? "true" : "false");
+ << "isNonmutating = " << (current.isNonmutating ? "true" : "false");
}
(*p)->invoke();
diff --git a/cpp/src/Ice/Incoming.cpp b/cpp/src/Ice/Incoming.cpp
index fdd68423339..d077da7bac2 100644
--- a/cpp/src/Ice/Incoming.cpp
+++ b/cpp/src/Ice/Incoming.cpp
@@ -32,7 +32,7 @@ IceInternal::Incoming::invoke(bool response)
current.id.__read(&_is);
_is.read(current.facet);
_is.read(current.operation);
- _is.read(current.nonmutating);
+ _is.read(current.isNonmutating);
Int sz;
_is.readSize(sz);
while(sz--)
diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp
index ef526510f2a..e63615c0d8a 100644
--- a/cpp/src/Ice/Proxy.cpp
+++ b/cpp/src/Ice/Proxy.cpp
@@ -1258,7 +1258,7 @@ IceDelegateD::Ice::Object::__initCurrent(Current& current, const string& op, boo
current.id = __reference->identity;
current.facet = __reference->facet;
current.operation = op;
- current.nonmutating = nonmutating;
+ current.isNonmutating = nonmutating;
current.ctx = context;
}
diff --git a/cpp/src/IcePack/AdapterManager.ice b/cpp/src/IcePack/AdapterManager.ice
index f9a6e59697b..610d85f58fc 100644
--- a/cpp/src/IcePack/AdapterManager.ice
+++ b/cpp/src/IcePack/AdapterManager.ice
@@ -107,7 +107,7 @@ class Adapter
/**
*
- * The description of this objet adapter.
+ * The description of this object adapter.
*
*/
AdapterDescription description;
diff --git a/cpp/src/IceStorm/TopicI.cpp b/cpp/src/IceStorm/TopicI.cpp
index a88a6c48854..ea568ddcd48 100644
--- a/cpp/src/IceStorm/TopicI.cpp
+++ b/cpp/src/IceStorm/TopicI.cpp
@@ -294,7 +294,7 @@ PublisherProxyI::ice_invoke(const vector< Ice::Byte>& inParams, vector< Ice::Byt
event.cost = 0; // TODO: Default comes from property?
}
event.op = current.operation;
- event.nonmutating = current.nonmutating;
+ event.nonmutating = current.isNonmutating;
event.data = inParams;
event.context = context;
diff --git a/cpp/src/Slice/Grammar.y b/cpp/src/Slice/Grammar.y
index c6a1d19bfcf..002bb45d8c6 100644
--- a/cpp/src/Slice/Grammar.y
+++ b/cpp/src/Slice/Grammar.y
@@ -33,6 +33,14 @@ yyerror(const char* s)
%pure_parser
//
+// Need precedence declarations to avoid shift/reduce conflicts for nonmutating qualifier.
+// By default, we'd get a shift, but we want a reduce. (Note: excess line length is
+// necessary here because bison doesn't recognize backslash-newline as a continuation sequence.)
+//
+%nonassoc ICE_BYTE ICE_BOOL ICE_SHORT ICE_INT ICE_LONG ICE_FLOAT ICE_DOUBLE ICE_STRING ICE_OBJECT ICE_LOCAL_OBJECT ICE_SCOPE_DELIMITER ICE_IDENTIFIER
+%nonassoc ICE_NONMUTATING
+
+//
// All keyword tokens. Make sure to modify the "keyword" rule in this
// file if the list of keywords is changed. Also make sure to add the
// keyword to the keyword table in Scanner.l.
@@ -64,6 +72,7 @@ yyerror(const char* s)
%token ICE_CONST
%token ICE_FALSE
%token ICE_TRUE
+%token ICE_NONMUTATING
//
// Other tokens.
@@ -569,12 +578,9 @@ class_exports
// ----------------------------------------------------------------------
class_export
// ----------------------------------------------------------------------
-: operation
-{
-}
-| type_id
+: nonmutating_qualifier type_id
{
- TypeStringTokPtr tsp = TypeStringTokPtr::dynamicCast($1);
+ TypeStringTokPtr tsp = TypeStringTokPtr::dynamicCast($2);
TypePtr type = tsp->v.first;
string ident = tsp->v.second;
ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer());
@@ -583,18 +589,48 @@ class_export
cl->checkIntroduced(ident, dm);
$$ = dm;
}
-| type keyword
+| operation_preamble '(' parameters ')'
{
- TypePtr type = TypePtr::dynamicCast($1);
- StringTokPtr ident = StringTokPtr::dynamicCast($2);
+ unit->popContainer();
+ $$ = $1;
+}
+throws
+{
+ OperationPtr op = OperationPtr::dynamicCast($5);
+ ExceptionListTokPtr el = ExceptionListTokPtr::dynamicCast($6);
+ assert(el);
+ if(op)
+ {
+ op->setExceptionList(el->v);
+ }
+}
+| operation_preamble '(' error ')'
+{
+ unit->popContainer();
+ yyerrok;
+}
+throws
+{
+ OperationPtr op = OperationPtr::dynamicCast($5);
+ ExceptionListTokPtr el = ExceptionListTokPtr::dynamicCast($6);
+ assert(el);
+ if(op)
+ {
+ op->setExceptionList(el->v);
+ }
+}
+| nonmutating_qualifier type keyword
+{
+ TypePtr type = TypePtr::dynamicCast($2);
+ StringTokPtr ident = StringTokPtr::dynamicCast($3);
ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer());
assert(cl);
unit->error("keyword `" + ident->v + "' cannot be used as data member name");
$$ = cl->createDataMember(ident->v, type);
}
-| type
+| nonmutating_qualifier type
{
- TypePtr type = TypePtr::dynamicCast($1);
+ TypePtr type = TypePtr::dynamicCast($2);
ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer());
assert(cl);
unit->error("missing data member name");
@@ -771,8 +807,35 @@ interface_exports
// ----------------------------------------------------------------------
interface_export
// ----------------------------------------------------------------------
-: operation
+: operation_preamble '(' parameters ')'
{
+ unit->popContainer();
+ $$ = $1;
+}
+throws
+{
+ OperationPtr op = OperationPtr::dynamicCast($5);
+ ExceptionListTokPtr el = ExceptionListTokPtr::dynamicCast($6);
+ assert(el);
+ if(op)
+ {
+ op->setExceptionList(el->v);
+ }
+}
+| operation_preamble '(' error ')'
+{
+ unit->popContainer();
+ yyerrok;
+}
+throws
+{
+ OperationPtr op = OperationPtr::dynamicCast($5);
+ ExceptionListTokPtr el = ExceptionListTokPtr::dynamicCast($6);
+ assert(el);
+ if(op)
+ {
+ op->setExceptionList(el->v);
+ }
}
;
@@ -951,6 +1014,23 @@ enumerator
;
// ----------------------------------------------------------------------
+nonmutating_qualifier
+// ----------------------------------------------------------------------
+: ICE_NONMUTATING
+{
+ BoolTokPtr nonmutating = new BoolTok;
+ nonmutating->v = true;
+ $$ = nonmutating;
+}
+| %prec ICE_NONMUTATING
+{
+ BoolTokPtr nonmutating = new BoolTok;
+ nonmutating->v = false;
+ $$ = nonmutating;
+}
+;
+
+// ----------------------------------------------------------------------
type_id
// ----------------------------------------------------------------------
: type ICE_IDENTIFIER
@@ -966,87 +1046,54 @@ type_id
// ----------------------------------------------------------------------
operation_preamble
// ----------------------------------------------------------------------
-: type_id
+: nonmutating_qualifier type_id
{
- TypeStringTokPtr tsp = TypeStringTokPtr::dynamicCast($1);
+ BoolTokPtr nonmutating = BoolTokPtr::dynamicCast($1);
+ TypeStringTokPtr tsp = TypeStringTokPtr::dynamicCast($2);
TypePtr returnType = tsp->v.first;
string name = tsp->v.second;
ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer());
assert(cl);
- OperationPtr op = cl->createOperation(name, returnType);
+ OperationPtr op = cl->createOperation(name, returnType, nonmutating->v);
cl->checkIntroduced(name, op);
unit->pushContainer(op);
$$ = op;
}
-| ICE_VOID ICE_IDENTIFIER
+| nonmutating_qualifier ICE_VOID ICE_IDENTIFIER
{
- StringTokPtr ident = StringTokPtr::dynamicCast($2);
+ BoolTokPtr nonmutating = BoolTokPtr::dynamicCast($1);
+ StringTokPtr ident = StringTokPtr::dynamicCast($3);
ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer());
assert(cl);
- OperationPtr op = cl->createOperation(ident->v, 0);
+ OperationPtr op = cl->createOperation(ident->v, 0, nonmutating->v);
unit->currentContainer()->checkIntroduced(ident->v, op);
unit->pushContainer(op);
$$ = op;
}
-| type keyword
+| nonmutating_qualifier type keyword
{
- TypePtr returnType = TypePtr::dynamicCast($1);
- StringTokPtr ident = StringTokPtr::dynamicCast($2);
+ TypePtr returnType = TypePtr::dynamicCast($2);
+ StringTokPtr ident = StringTokPtr::dynamicCast($3);
ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer());
assert(cl);
unit->error("keyword `" + ident->v + "' cannot be used as operation name");
- OperationPtr op = cl->createOperation(ident->v, returnType);
+ OperationPtr op = cl->createOperation(ident->v, returnType, false);
unit->pushContainer(op);
$$ = op;
}
-| ICE_VOID keyword
+| nonmutating_qualifier ICE_VOID keyword
{
- StringTokPtr ident = StringTokPtr::dynamicCast($2);
+ StringTokPtr ident = StringTokPtr::dynamicCast($3);
ClassDefPtr cl = ClassDefPtr::dynamicCast(unit->currentContainer());
assert(cl);
unit->error("keyword `" + ident->v + "' cannot be used as operation name");
- OperationPtr op = cl->createOperation(ident->v, 0);
+ OperationPtr op = cl->createOperation(ident->v, 0, false);
unit->pushContainer(op);
$$ = op;
}
;
// ----------------------------------------------------------------------
-operation
-// ----------------------------------------------------------------------
-: operation_preamble '(' parameters ')'
-{
- unit->popContainer();
- $$ = $1;
-}
-throws
-{
- OperationPtr op = OperationPtr::dynamicCast($5);
- ExceptionListTokPtr el = ExceptionListTokPtr::dynamicCast($6);
- assert(el);
- if(op)
- {
- op->setExceptionList(el->v);
- }
-}
-| operation_preamble '(' error ')'
-{
- unit->popContainer();
- yyerrok;
-}
-throws
-{
- OperationPtr op = OperationPtr::dynamicCast($5);
- ExceptionListTokPtr el = ExceptionListTokPtr::dynamicCast($6);
- assert(el);
- if(op)
- {
- op->setExceptionList(el->v);
- }
-}
-;
-
-// ----------------------------------------------------------------------
out_qualifier
// ----------------------------------------------------------------------
: ICE_OUT
@@ -1487,6 +1534,9 @@ keyword
| ICE_TRUE
{
}
+| ICE_NONMUTATING
+{
+}
;
%%
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp
index 1b319f3fa9d..dec77656af9 100644
--- a/cpp/src/Slice/Parser.cpp
+++ b/cpp/src/Slice/Parser.cpp
@@ -1763,7 +1763,8 @@ Slice::ClassDef::destroy()
OperationPtr
Slice::ClassDef::createOperation(const string& name,
- const TypePtr& returnType)
+ const TypePtr& returnType,
+ bool nonmutating)
{
checkPrefix(name);
@@ -1864,7 +1865,7 @@ Slice::ClassDef::createOperation(const string& name,
_unit->error(msg);
}
- OperationPtr op = new Operation(this, name, returnType);
+ OperationPtr op = new Operation(this, name, returnType, nonmutating);
_contents.push_back(op);
return op;
}
@@ -3157,6 +3158,12 @@ Slice::Operation::throws() const
return _throws;
}
+bool
+Slice::Operation::nonmutating() const
+{
+ return _nonmutating;
+}
+
void
Slice::Operation::setExceptionList(const ExceptionList& el)
{
@@ -3262,16 +3269,15 @@ Slice::Operation::visit(ParserVisitor* visitor)
visitor->visitOperation(this);
}
-Slice::Operation::Operation(const ContainerPtr& container, const string& name, const TypePtr& returnType) :
- //const TypeStringList& inParams, const TypeStringList& outParams,
- //const ExceptionList& throws) :
+Slice::Operation::Operation(const ContainerPtr& container,
+ const string& name,
+ const TypePtr& returnType,
+ bool nonmutating) :
Contained(container, name),
Container(container->unit()),
SyntaxTreeBase(container->unit()),
- _returnType(returnType)
- //_inParams(inParams),
- //_outParams(outParams),
- //_throws(throws)
+ _returnType(returnType),
+ _nonmutating(nonmutating)
{
}
diff --git a/cpp/src/Slice/Scanner.l b/cpp/src/Slice/Scanner.l
index 22de810fd60..e49569aecf9 100644
--- a/cpp/src/Slice/Scanner.l
+++ b/cpp/src/Slice/Scanner.l
@@ -402,6 +402,7 @@ initScanner()
keywordMap["const"] = ICE_CONST;
keywordMap["false"] = ICE_FALSE;
keywordMap["true"] = ICE_TRUE;
+ keywordMap["nonmutating"] = ICE_NONMUTATING;
}
}
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index f9a5e77543f..53894d74b0c 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -1276,9 +1276,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
C << eb;
C << nl << "catch(const ::IceInternal::NonRepeatable& __ex)";
C << sb;
- list<string> metaData = p->getMetaData();
- bool nonmutating = find(metaData.begin(), metaData.end(), "nonmutating") != metaData.end();
- if(nonmutating)
+ if(p->nonmutating())
{
C << nl << "__handleException(*__ex.get(), __cnt);";
}
@@ -1548,10 +1546,8 @@ Slice::Gen::DelegateMVisitor::visitOperation(const OperationPtr& p)
C << sp << nl << retS << nl << "IceDelegateM" << scoped << paramsDecl;
C << sb;
C << nl << "static const ::std::string __operation(\"" << p->name() << "\");";
- list<string> metaData = p->getMetaData();
- bool nonmutating = find(metaData.begin(), metaData.end(), "nonmutating") != metaData.end();
C << nl << "::IceInternal::Outgoing __out(__connection, __reference, __operation, "
- << (nonmutating ? "true" : "false") << ", __context);";
+ << (p->nonmutating() ? "true" : "false") << ", __context);";
if(ret || !outParams.empty() || !throws.empty())
{
C << nl << "::IceInternal::BasicStream* __is = __out.is();";
@@ -1736,9 +1732,7 @@ Slice::Gen::DelegateDVisitor::visitOperation(const OperationPtr& p)
C << sp << nl << retS << nl << "IceDelegateD" << scoped << paramsDecl;
C << sb;
C << nl << "::Ice::Current __current;";
- list<string> metaData = p->getMetaData();
- bool nonmutating = find(metaData.begin(), metaData.end(), "nonmutating") != metaData.end();
- C << nl << "__initCurrent(__current, \"" << p->name() << "\", " << (nonmutating ? "true" : "false")
+ C << nl << "__initCurrent(__current, \"" << p->name() << "\", " << (p->nonmutating() ? "true" : "false")
<< ", __context);";
C << nl << "while(true)";
C << sb;
@@ -2286,8 +2280,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
}
}
- list<string> metaData = p->getMetaData();
- bool nonmutating = find(metaData.begin(), metaData.end(), "nonmutating") != metaData.end();
+ bool nonmutating = p->nonmutating();
H << sp;
H << nl << exp2 << "virtual " << retS << ' ' << name << params << (nonmutating ? " const" : "") << " = 0;";
@@ -2839,8 +2832,7 @@ Slice::Gen::ImplVisitor::visitClassDefStart(const ClassDefPtr& p)
}
H.restoreIndent();
- list<string> metaData = op->getMetaData();
- bool nonmutating = find(metaData.begin(), metaData.end(), "nonmutating") != metaData.end();
+ bool nonmutating = op->nonmutating();
H << ")" << (nonmutating ? " const" : "") << ";";
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index 4e62239e824..b8408efe757 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -2067,9 +2067,7 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
out << eb;
out << nl << "catch(IceInternal.NonRepeatable __ex)";
out << sb;
- list<string> metaData = op->getMetaData();
- bool nonmutating = find(metaData.begin(), metaData.end(), "nonmutating") != metaData.end();
- if(nonmutating)
+ if(op->nonmutating())
{
out << nl << "__cnt = __handleException(__ex.get(), __cnt);";
}
@@ -3006,9 +3004,8 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
writeDelegateThrowsClause(scope, throws);
out << sb;
list<string> metaData = op->getMetaData();
- bool nonmutating = find(metaData.begin(), metaData.end(), "nonmutating") != metaData.end();
out << nl << "IceInternal.Outgoing __out = getOutgoing(\"" << op->name() << "\", "
- << (nonmutating ? "true" : "false") << ", __context);";
+ << (op->nonmutating() ? "true" : "false") << ", __context);";
out << nl << "try";
out << sb;
if(!inParams.empty())
@@ -3172,9 +3169,8 @@ Slice::Gen::DelegateDVisitor::visitClassDefStart(const ClassDefPtr& p)
writeDelegateThrowsClause(scope, throws);
out << sb;
list<string> metaData = op->getMetaData();
- bool nonmutating = find(metaData.begin(), metaData.end(), "nonmutating") != metaData.end();
out << nl << "Ice.Current __current = new Ice.Current();";
- out << nl << "__initCurrent(__current, \"" << op->name() << "\", " << (nonmutating ? "true" : "false")
+ out << nl << "__initCurrent(__current, \"" << op->name() << "\", " << (op->nonmutating() ? "true" : "false")
<< ", __context);";
out << nl << "while(true)";
out << sb;