From 997c78b8c2911a3787d9ca9b4b10e587cb8cbb2d Mon Sep 17 00:00:00 2001 From: Michi Henning Date: Thu, 25 Jul 2002 23:09:48 +0000 Subject: Changed Slice parser to disallow leading underscore for identifiers. Changed Slice parser to reject identifiers beginning with "Ice", unless the --ice option is used. Changed Slice parser to disallow identifiers that have a trailing "Operations", "Holder", "Helper", "Prx", or "Ptr", to avoid clashes with language mappings. Fixed tests and remaining code base to work correctly with the changed rules. --- cpp/demo/Freeze/library/Library.ice | 4 ++-- cpp/demo/Freeze/library/LibraryI.cpp | 18 +++++++++--------- cpp/demo/Freeze/library/Makefile | 4 ++-- cpp/demo/Freeze/phonebook/PhoneBook.ice | 6 +++--- cpp/demo/Freeze/phonebook/PhoneBookI.cpp | 16 ++++++++-------- cpp/demo/Ice/value/Client.cpp | 8 ++++---- cpp/demo/Ice/value/Value.ice | 6 +++--- cpp/demo/Ice/value/ValueI.cpp | 16 ++++++++-------- 8 files changed, 39 insertions(+), 39 deletions(-) (limited to 'cpp/demo') diff --git a/cpp/demo/Freeze/library/Library.ice b/cpp/demo/Freeze/library/Library.ice index 93f1e980048..7c4440200b1 100644 --- a/cpp/demo/Freeze/library/Library.ice +++ b/cpp/demo/Freeze/library/Library.ice @@ -137,7 +137,7 @@ class Book * this information is immutable. * **/ - BookDescription _description; + BookDescription description; /** * @@ -145,7 +145,7 @@ class Book * the book is not currently rented. * **/ - string _rentalCustomerName; + string rentalCustomerName; }; /** diff --git a/cpp/demo/Freeze/library/LibraryI.cpp b/cpp/demo/Freeze/library/LibraryI.cpp index cdf84bc827c..298ed23c374 100644 --- a/cpp/demo/Freeze/library/LibraryI.cpp +++ b/cpp/demo/Freeze/library/LibraryI.cpp @@ -29,7 +29,7 @@ BookI::destroy(const Ice::Current&) try { - _library->remove(_description); + _library->remove(description); } catch(const Freeze::DBNotFoundException&) { @@ -49,7 +49,7 @@ BookI::destroy(const Ice::Current&) BookI::getBookDescription(const Ice::Current&) { // Immutable - return _description; + return description; } ::std::string @@ -57,11 +57,11 @@ BookI::getRenterName(const Ice::Current&) { IceUtil::RWRecMutex::RLock sync(*this); - if(_rentalCustomerName.empty()) + if(rentalCustomerName.empty()) { throw BookNotRentedException(); } - return _rentalCustomerName; + return rentalCustomerName; } void @@ -69,11 +69,11 @@ BookI::rentBook(const ::std::string& name, const Ice::Current&) { IceUtil::RWRecMutex::WLock sync(*this); - if(!_rentalCustomerName.empty()) + if(!rentalCustomerName.empty()) { throw BookRentedException(); } - _rentalCustomerName = name; + rentalCustomerName = name; } void @@ -81,11 +81,11 @@ BookI::returnBook(const Ice::Current&) { IceUtil::RWRecMutex::WLock sync(*this); - if(_rentalCustomerName.empty()) + if(rentalCustomerName.empty()) { throw BookNotRentedException(); } - _rentalCustomerName.clear();; + rentalCustomerName.clear();; } static Ice::Identity @@ -156,7 +156,7 @@ LibraryI::createBook(const ::BookDescription& description, const Ice::Current&) } BookPtr bookI = new BookI(this); - bookI->_description = description; + bookI->description = description; // // Create a new Ice Object in the evictor, using the new identity diff --git a/cpp/demo/Freeze/library/Makefile b/cpp/demo/Freeze/library/Makefile index e1a07c5e5ef..3537e924cbf 100644 --- a/cpp/demo/Freeze/library/Makefile +++ b/cpp/demo/Freeze/library/Makefile @@ -77,14 +77,14 @@ clean:: Library.h Library.cpp: Library.ice $(SLICE2CPP) rm -f Library.h Library.cpp - $(SLICE2CPP) -I$(slicedir) Library.ice + $(SLICE2CPP) --ice -I$(slicedir) Library.ice clean:: rm -f Library.h Library.cpp LibraryTypes.h LibraryTypes.cpp: Library.ice $(SLICE2FREEZE) rm -f LibraryTypes.h LibraryTypes.cpp - $(SLICE2FREEZE) -I$(slicedir) --dict StringIsbnSeqDict,string,Ice::StringSeq LibraryTypes $(slicedir)/Ice/BuiltinSequences.ice Library.ice + $(SLICE2FREEZE) --ice -I$(slicedir) --dict StringIsbnSeqDict,string,Ice::StringSeq LibraryTypes $(slicedir)/Ice/BuiltinSequences.ice Library.ice clean:: rm -f LibraryTypes.h LibraryTypes.cpp diff --git a/cpp/demo/Freeze/phonebook/PhoneBook.ice b/cpp/demo/Freeze/phonebook/PhoneBook.ice index 6d018961c82..c86b5432b38 100644 --- a/cpp/demo/Freeze/phonebook/PhoneBook.ice +++ b/cpp/demo/Freeze/phonebook/PhoneBook.ice @@ -38,9 +38,9 @@ class Contact ["nonmutating"] void destroy() throws DatabaseException; - string _name; - string _address; - string _phone; + string name; + string address; + string phone; }; sequence Contacts; diff --git a/cpp/demo/Freeze/phonebook/PhoneBookI.cpp b/cpp/demo/Freeze/phonebook/PhoneBookI.cpp index 48202164eb6..4526e510a7b 100644 --- a/cpp/demo/Freeze/phonebook/PhoneBookI.cpp +++ b/cpp/demo/Freeze/phonebook/PhoneBookI.cpp @@ -30,7 +30,7 @@ string ContactI::getName(const Ice::Current&) { IceUtil::RWRecMutex::RLock sync(*this); - return _name; + return name; } void @@ -39,36 +39,36 @@ ContactI::setName(const string& name, const Ice::Current&) IceUtil::RWRecMutex::WLock sync(*this); assert(!_identity.name.empty()); - _phoneBook->move(_identity, _name, name); - _name = name; + _phoneBook->move(_identity, this->name, name); + this->name = name; } string ContactI::getAddress(const Ice::Current&) { IceUtil::RWRecMutex::RLock sync(*this); - return _address; + return address; } void ContactI::setAddress(const string& address, const Ice::Current&) { IceUtil::RWRecMutex::WLock sync(*this); - _address = address; + this->address = address; } string ContactI::getPhone(const Ice::Current&) { IceUtil::RWRecMutex::RLock sync(*this); - return _phone; + return phone; } void ContactI::setPhone(const string& phone, const Ice::Current&) { IceUtil::RWRecMutex::WLock sync(*this); - _phone = phone; + this->phone = phone; } void @@ -79,7 +79,7 @@ ContactI::destroy(const Ice::Current&) try { assert(!_identity.name.empty()); - _phoneBook->remove(_identity, _name); + _phoneBook->remove(_identity, name); // // This can throw EvictorDeactivatedException (which indicates diff --git a/cpp/demo/Ice/value/Client.cpp b/cpp/demo/Ice/value/Client.cpp index ae230990a4b..07fc0a07cf4 100644 --- a/cpp/demo/Ice/value/Client.cpp +++ b/cpp/demo/Ice/value/Client.cpp @@ -44,7 +44,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) cin.getline(&c, 1); SimplePtr simple = initial->getSimple(); - cout << "==> " << simple->_message << endl; + cout << "==> " << simple->message << endl; cout << '\n' << "Ok, this worked. Now let's try to transfer an object for a class\n" @@ -75,7 +75,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) communicator->addObjectFactory(factory, "::Printer"); initial->getPrinter(printer, printerProxy); - cout << "==> " << printer->_message << endl; + cout << "==> " << printer->message << endl; cout << '\n' << "Cool, it worked! Let's try calling the printBackwards() method\n" @@ -135,7 +135,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) << "[press enter]\n"; cin.getline(&c, 1); - cout << "==> " << derived->_derivedMessage << endl; + cout << "==> " << derived->derivedMessage << endl; cout << "==> "; derived->printUppercase(); @@ -156,7 +156,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator) assert(derived); } - cout << "==> " << derived->_derivedMessage << endl; + cout << "==> " << derived->derivedMessage << endl; cout << "==> "; derived->printUppercase(); diff --git a/cpp/demo/Ice/value/Value.ice b/cpp/demo/Ice/value/Value.ice index 8dbe0e42b88..4c5c860ecf7 100644 --- a/cpp/demo/Ice/value/Value.ice +++ b/cpp/demo/Ice/value/Value.ice @@ -13,18 +13,18 @@ class Simple { - string _message; + string message; }; class Printer { - string _message; + string message; void printBackwards(); }; class DerivedPrinter extends Printer { - string _derivedMessage; + string derivedMessage; void printUppercase(); }; diff --git a/cpp/demo/Ice/value/ValueI.cpp b/cpp/demo/Ice/value/ValueI.cpp index c594db07d09..19df231608a 100644 --- a/cpp/demo/Ice/value/ValueI.cpp +++ b/cpp/demo/Ice/value/ValueI.cpp @@ -17,15 +17,15 @@ InitialI::InitialI(const Ice::ObjectAdapterPtr& adapter) : _adapter(adapter) { _simple = new Simple; - _simple->_message = "a message 4 u"; + _simple->message = "a message 4 u"; _printer = new PrinterI; - _printer->_message = "Ice rulez!"; + _printer->message = "Ice rulez!"; _printerProxy = PrinterPrx::uncheckedCast(adapter->addWithUUID(_printer)); _derivedPrinter = new DerivedPrinterI; - _derivedPrinter->_message = _printer->_message; - _derivedPrinter->_derivedMessage = "Coming soon: the ultimate online game from MutableRealms!"; + _derivedPrinter->message = _printer->message; + _derivedPrinter->derivedMessage = "Coming soon: the ultimate online game from MutableRealms!"; adapter->addWithUUID(_derivedPrinter); } @@ -60,8 +60,8 @@ void PrinterI::printBackwards(const Ice::Current&) { string s; - s.resize(_message.length()); - reverse_copy(_message.begin(), _message.end(), s.begin()); + s.resize(message.length()); + reverse_copy(message.begin(), message.end(), s.begin()); cout << s << endl; } @@ -69,7 +69,7 @@ void DerivedPrinterI::printUppercase(const Ice::Current&) { string s; - s.resize(_derivedMessage.length()); - transform(_derivedMessage.begin(), _derivedMessage.end(), s.begin(), toupper); + s.resize(derivedMessage.length()); + transform(derivedMessage.begin(), derivedMessage.end(), s.begin(), toupper); cout << s << endl; } -- cgit v1.2.3