diff options
author | Michi Henning <michi@zeroc.com> | 2002-08-12 02:18:24 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2002-08-12 02:18:24 +0000 |
commit | 0b1443640cd95bc0c22db88ab00f7948e955bcfb (patch) | |
tree | 2ad713c4e6dd0b49f4a092f8615f99b688854269 /cpp | |
parent | Fixed a bug where we would move the buffer iterator beyond the buffer end. (diff) | |
download | ice-0b1443640cd95bc0c22db88ab00f7948e955bcfb.tar.bz2 ice-0b1443640cd95bc0c22db88ab00f7948e955bcfb.tar.xz ice-0b1443640cd95bc0c22db88ab00f7948e955bcfb.zip |
Changed nonmutating from metadata do keyword.
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/demo/Freeze/library/Library.ice | 14 | ||||
-rw-r--r-- | cpp/demo/Freeze/phonebook/PhoneBook.ice | 12 | ||||
-rw-r--r-- | cpp/demo/Ice/hello/Hello.ice | 2 | ||||
-rw-r--r-- | cpp/include/Slice/Parser.h | 6 | ||||
-rw-r--r-- | cpp/slice/Glacier/Starter.ice | 2 | ||||
-rw-r--r-- | cpp/slice/Ice/Current.ice | 2 | ||||
-rw-r--r-- | cpp/slice/Ice/Locator.ice | 4 | ||||
-rw-r--r-- | cpp/slice/Ice/Router.ice | 4 | ||||
-rw-r--r-- | cpp/slice/IcePack/Admin.ice | 12 | ||||
-rw-r--r-- | cpp/slice/IceStorm/IceStorm.ice | 10 | ||||
-rw-r--r-- | cpp/src/Freeze/EvictorI.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Glacier/Blobject.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Glacier/Missive.cpp | 6 | ||||
-rw-r--r-- | cpp/src/Ice/Incoming.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Ice/Proxy.cpp | 2 | ||||
-rw-r--r-- | cpp/src/IcePack/AdapterManager.ice | 2 | ||||
-rw-r--r-- | cpp/src/IceStorm/TopicI.cpp | 2 | ||||
-rw-r--r-- | cpp/src/Slice/Grammar.y | 168 | ||||
-rw-r--r-- | cpp/src/Slice/Parser.cpp | 24 | ||||
-rw-r--r-- | cpp/src/Slice/Scanner.l | 1 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 18 | ||||
-rw-r--r-- | cpp/src/slice2java/Gen.cpp | 10 | ||||
-rw-r--r-- | cpp/test/Ice/faultTolerance/Test.ice | 2 |
23 files changed, 180 insertions, 133 deletions
diff --git a/cpp/demo/Freeze/library/Library.ice b/cpp/demo/Freeze/library/Library.ice index 7c4440200b1..a423f1f3ce2 100644 --- a/cpp/demo/Freeze/library/Library.ice +++ b/cpp/demo/Freeze/library/Library.ice @@ -79,7 +79,7 @@ class Book * @return The book description. * **/ - ["nonmutating"] BookDescription getBookDescription(); + nonmutating BookDescription getBookDescription(); /** * @@ -91,7 +91,7 @@ class Book * database system. * **/ - ["nonmutating"] void destroy() + nonmutating void destroy() throws DatabaseException; /** @@ -117,7 +117,7 @@ class Book * currently rented. * **/ - ["nonmutating"] string getRenterName() + nonmutating string getRenterName() throws BookNotRentedException; /** @@ -191,7 +191,7 @@ interface Library * @throws DatabaseException Raised if there is a problem with the database. * **/ - ["nonmutating"] Book* findByIsbn(string isbn) + nonmutating Book* findByIsbn(string isbn) throws DatabaseException; /** @@ -206,7 +206,7 @@ interface Library * @throws DatabaseException Raised if there is a problem with the database. * **/ - ["nonmutating"] BookPrxSeq findByAuthors(string authors) + nonmutating BookPrxSeq findByAuthors(string authors) throws DatabaseException; /** @@ -219,7 +219,7 @@ interface Library * database. * **/ - ["nonmutating"] void setEvictorSize(int size) + nonmutating void setEvictorSize(int size) throws DatabaseException; /** @@ -227,7 +227,7 @@ interface Library * Shutdown the server. * **/ - ["nonmutating"] void shutdown(); + nonmutating void shutdown(); }; #endif diff --git a/cpp/demo/Freeze/phonebook/PhoneBook.ice b/cpp/demo/Freeze/phonebook/PhoneBook.ice index c86b5432b38..fe7881f662f 100644 --- a/cpp/demo/Freeze/phonebook/PhoneBook.ice +++ b/cpp/demo/Freeze/phonebook/PhoneBook.ice @@ -20,14 +20,14 @@ exception DatabaseException class Contact { - ["nonmutating"] string getName(); + nonmutating string getName(); void setName(string name) throws DatabaseException; - ["nonmutating"] string getAddress(); + nonmutating string getAddress(); void setAddress(string address); - ["nonmutating"] string getPhone(); + nonmutating string getPhone(); void setPhone(string phone); // @@ -35,7 +35,7 @@ class Contact // the Contact. It removes the Contact completely, but doesn't // touch state. // - ["nonmutating"] void destroy() + nonmutating void destroy() throws DatabaseException; string name; @@ -50,12 +50,12 @@ interface PhoneBook { Contact* createContact() throws DatabaseException; - ["nonmutating"] Contacts findContacts(string name) + nonmutating Contacts findContacts(string name) throws DatabaseException; void setEvictorSize(int size) throws DatabaseException; - ["nonmutating"] void shutdown(); + nonmutating void shutdown(); }; #endif diff --git a/cpp/demo/Ice/hello/Hello.ice b/cpp/demo/Ice/hello/Hello.ice index b5a94d8b618..00ae1a30a48 100644 --- a/cpp/demo/Ice/hello/Hello.ice +++ b/cpp/demo/Ice/hello/Hello.ice @@ -13,7 +13,7 @@ class Hello { - ["nonmutating"] void sayHello(); + nonmutating void sayHello(); void shutdown(); }; diff --git a/cpp/include/Slice/Parser.h b/cpp/include/Slice/Parser.h index f48004a9acc..ff7d0fa0ab7 100644 --- a/cpp/include/Slice/Parser.h +++ b/cpp/include/Slice/Parser.h @@ -464,7 +464,7 @@ class SLICE_API ClassDef : virtual public Container, virtual public Contained public: virtual void destroy(); - OperationPtr createOperation(const std::string&, const TypePtr&); + OperationPtr createOperation(const std::string&, const TypePtr&, bool); DataMemberPtr createDataMember(const std::string&, const TypePtr&); ClassDeclPtr declaration() const; ClassList bases() const; @@ -701,6 +701,7 @@ public: ParamDeclPtr createParamDecl(const std::string&, const TypePtr&, bool); ParamDeclList parameters() const; ExceptionList throws() const; + bool nonmutating() const; void setExceptionList(const ExceptionList&); virtual ContainedType containedType() const; virtual bool uses(const ContainedPtr&) const; @@ -709,11 +710,12 @@ public: protected: - Operation(const ContainerPtr&, const std::string&, const TypePtr&); + Operation(const ContainerPtr&, const std::string&, const TypePtr&, bool); friend class SLICE_API ClassDef; TypePtr _returnType; ExceptionList _throws; + bool _nonmutating; }; // ---------------------------------------------------------------------- diff --git a/cpp/slice/Glacier/Starter.ice b/cpp/slice/Glacier/Starter.ice index fff3e741282..67ccd6f65dc 100644 --- a/cpp/slice/Glacier/Starter.ice +++ b/cpp/slice/Glacier/Starter.ice @@ -94,7 +94,7 @@ interface PasswordVerifier * @return True if the password is valid, or false otherwise. * **/ - ["nonmutating"] + nonmutating bool checkPassword(string userId, string password); }; diff --git a/cpp/slice/Ice/Current.ice b/cpp/slice/Ice/Current.ice index e1162a08c68..5c6419f8683 100644 --- a/cpp/slice/Ice/Current.ice +++ b/cpp/slice/Ice/Current.ice @@ -66,7 +66,7 @@ local struct Current * Set to true if the operation is nonmutating. * **/ - bool nonmutating; + bool isNonmutating; /** * diff --git a/cpp/slice/Ice/Locator.ice b/cpp/slice/Ice/Locator.ice index 742eee34e17..2d911c7599a 100644 --- a/cpp/slice/Ice/Locator.ice +++ b/cpp/slice/Ice/Locator.ice @@ -39,7 +39,7 @@ interface Locator * @return The adapter proxy or null if the adapter is not found. * **/ - ["nonmutating"] Object* findAdapterByName(string name); + nonmutating Object* findAdapterByName(string name); /** * @@ -48,7 +48,7 @@ interface Locator * @return The locator registry. * **/ - ["nonmutating"] LocatorRegistry* getRegistry(); + nonmutating LocatorRegistry* getRegistry(); }; /** diff --git a/cpp/slice/Ice/Router.ice b/cpp/slice/Ice/Router.ice index 889c05828b4..d1552bb23fc 100644 --- a/cpp/slice/Ice/Router.ice +++ b/cpp/slice/Ice/Router.ice @@ -36,7 +36,7 @@ interface Router * @return The router's client proxy. * **/ - ["nonmutating"] Object* getClientProxy(); + nonmutating Object* getClientProxy(); /** * @@ -46,7 +46,7 @@ interface Router * @return The router's server proxy. * **/ - ["nonmutating"] Object* getServerProxy(); + nonmutating Object* getServerProxy(); /** * diff --git a/cpp/slice/IcePack/Admin.ice b/cpp/slice/IcePack/Admin.ice index 4ab7bf2d35e..66cf7625b8b 100644 --- a/cpp/slice/IcePack/Admin.ice +++ b/cpp/slice/IcePack/Admin.ice @@ -310,7 +310,7 @@ class Admin * @see getAllServerNames * **/ - ["nonmutating"] ServerDescription getServerDescription(string name) + nonmutating ServerDescription getServerDescription(string name) throws ServerNotExistException; /** @@ -329,7 +329,7 @@ class Admin * @see getAllServerNames * **/ - ["nonmutating"] ServerState getServerState(string name) + nonmutating ServerState getServerState(string name) throws ServerNotExistException; /** @@ -350,7 +350,7 @@ class Admin * @see getAllServerNames * **/ - ["nonmutating"] int getServerPid(string name) + nonmutating int getServerPid(string name) throws ServerNotExistException; /** @@ -400,7 +400,7 @@ class Admin * @see getServerState * **/ - ["nonmutating"] ServerNames getAllServerNames(); + nonmutating ServerNames getAllServerNames(); /** * @@ -444,7 +444,7 @@ class Admin * found. * **/ - ["nonmutating"] string getAdapterEndpoints(string name) + nonmutating string getAdapterEndpoints(string name) throws AdapterNotExistException; /** @@ -454,7 +454,7 @@ class Admin * @return The adapter names. * **/ - ["nonmutating"] AdapterNames getAllAdapterNames(); + nonmutating AdapterNames getAllAdapterNames(); /** * diff --git a/cpp/slice/IceStorm/IceStorm.ice b/cpp/slice/IceStorm/IceStorm.ice index b9fcae4f25d..2ba034878a8 100644 --- a/cpp/slice/IceStorm/IceStorm.ice +++ b/cpp/slice/IceStorm/IceStorm.ice @@ -79,7 +79,7 @@ interface Topic * @see TopicManager::subscribe * **/ - ["nonmutating"] string getName(); + nonmutating string getName(); /** * @@ -91,7 +91,7 @@ interface Topic * @return A proxy to publish data on this Topic. * **/ - ["nonmutating"] Object* getPublisher(); + nonmutating Object* getPublisher(); /** * @@ -122,7 +122,7 @@ interface Topic * @return A sequence of LinkInfo objects. * **/ - ["nonmutating"] LinkInfoSeq getLinkInfoSeq(); + nonmutating LinkInfoSeq getLinkInfoSeq(); /** * @@ -213,7 +213,7 @@ interface TopicManager * @throws NoSuchTopic Raised if the Topic doesn't exist. * **/ - ["nonmutating"] Topic* retrieve(string name) throws NoSuchTopic; + nonmutating Topic* retrieve(string name) throws NoSuchTopic; /** * @@ -222,7 +222,7 @@ interface TopicManager * @return A dictionary of string, Topic proxy pairs. * **/ - ["nonmutating"] TopicDict retrieveAll(); + nonmutating TopicDict retrieveAll(); /** * 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; diff --git a/cpp/test/Ice/faultTolerance/Test.ice b/cpp/test/Ice/faultTolerance/Test.ice index 5faa3fd7fc9..5197ad3d3e6 100644 --- a/cpp/test/Ice/faultTolerance/Test.ice +++ b/cpp/test/Ice/faultTolerance/Test.ice @@ -15,7 +15,7 @@ interface Test { void shutdown(); void abort(); - ["nonmutating"] void nonmutatingAbort(); + nonmutating void nonmutatingAbort(); int pid(); }; |