diff options
author | Michi Henning <michi@zeroc.com> | 2002-07-25 23:09:48 +0000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2002-07-25 23:09:48 +0000 |
commit | 997c78b8c2911a3787d9ca9b4b10e587cb8cbb2d (patch) | |
tree | 267560499341128d631b40e1caff8e9435b55552 | |
parent | Added generation of Yellow.Query in service configuration. (diff) | |
download | ice-997c78b8c2911a3787d9ca9b4b10e587cb8cbb2d.tar.bz2 ice-997c78b8c2911a3787d9ca9b4b10e587cb8cbb2d.tar.xz ice-997c78b8c2911a3787d9ca9b4b10e587cb8cbb2d.zip |
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.
51 files changed, 408 insertions, 235 deletions
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<Contact*> 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; } diff --git a/cpp/doc/Makefile b/cpp/doc/Makefile index 4a4008e4838..789fa7da850 100644 --- a/cpp/doc/Makefile +++ b/cpp/doc/Makefile @@ -70,7 +70,7 @@ clean:: SliceDoc.sgml: $(SLICEFILES) $(SLICE2DOCBOOK) rm -f $@ - $(SLICE2DOCBOOK) -I$(top_srcdir)/slice $@ $(SLICEFILES) + $(SLICE2DOCBOOK) --ice -I$(top_srcdir)/slice $@ $(SLICEFILES) clean:: rm -f SliceDoc.sgml diff --git a/cpp/include/Slice/Parser.h b/cpp/include/Slice/Parser.h index aec3c2e934b..f48004a9acc 100644 --- a/cpp/include/Slice/Parser.h +++ b/cpp/include/Slice/Parser.h @@ -364,6 +364,7 @@ protected: Container(const UnitPtr&); + void checkPrefix(const std::string&) const; bool checkInterfaceAndLocal(const std::string&, bool, bool, bool, bool, bool); ContainedList _contents; @@ -771,10 +772,12 @@ class SLICE_API Unit : virtual public Container { public: - static UnitPtr createUnit(bool, bool); + static UnitPtr createUnit(bool, bool, bool); bool ignRedefs() const; + bool allowIcePrefix() const; + void setComment(const std::string&); std::string currentComment(); // Not const, as this function removes the current comment. std::string currentFile() const; @@ -816,10 +819,11 @@ public: private: - Unit(bool, bool); + Unit(bool, bool, bool); bool _ignRedefs; bool _all; + bool _allowIcePrefix; int _errors; std::string _currentComment; int _currentLine; @@ -832,7 +836,7 @@ private: std::map<std::string, ContainedList> _contentMap; }; -extern SLICE_API Unit* unit; // The current parser for bison/flex +extern SLICE_API Unit* unit; // The current parser for bison/flex // ---------------------------------------------------------------------- // CICompare -- function object to do case-insensitive string comparison. diff --git a/cpp/slice/IceSSL/Exception.ice b/cpp/slice/IceSSL/Exception.ice index 8ef2de550d4..6e920c719a5 100644 --- a/cpp/slice/IceSSL/Exception.ice +++ b/cpp/slice/IceSSL/Exception.ice @@ -33,7 +33,7 @@ local exception SslException * implementation and/or debugging trace. * **/ - string _message; + string message; }; /** diff --git a/cpp/src/Freeze/Makefile b/cpp/src/Freeze/Makefile index 91281d1cf52..5fb7b6344d2 100644 --- a/cpp/src/Freeze/Makefile +++ b/cpp/src/Freeze/Makefile @@ -30,8 +30,8 @@ SRCS = $(OBJS:.o=.cpp) HDIR = $(includedir)/Freeze SDIR = $(slicedir)/Freeze -SLICECMD = $(SLICE2CPP) --include-dir Freeze --dll-export FREEZE_API -I$(slicedir) -SLICE2FREEZECMD = $(SLICE2FREEZE) --include-dir Freeze -I$(slicedir) +SLICECMD = $(SLICE2CPP) --ice --include-dir Freeze --dll-export FREEZE_API -I$(slicedir) +SLICE2FREEZECMD = $(SLICE2FREEZE) --ice --include-dir Freeze -I$(slicedir) include $(top_srcdir)/config/Make.rules diff --git a/cpp/src/Ice/Makefile b/cpp/src/Ice/Makefile index df5b7019a25..2262ab8675e 100644 --- a/cpp/src/Ice/Makefile +++ b/cpp/src/Ice/Makefile @@ -90,7 +90,7 @@ SRCS = $(OBJS:.o=.cpp) HDIR = $(includedir)/Ice SDIR = $(slicedir)/Ice -SLICECMD = $(SLICE2CPP) --include-dir Ice --dll-export ICE_API -I$(slicedir) +SLICECMD = $(SLICE2CPP) --ice --include-dir Ice --dll-export ICE_API -I$(slicedir) include $(top_srcdir)/config/Make.rules diff --git a/cpp/src/IceBox/Makefile b/cpp/src/IceBox/Makefile index 94580eb53fc..1f53ecd6151 100644 --- a/cpp/src/IceBox/Makefile +++ b/cpp/src/IceBox/Makefile @@ -34,8 +34,8 @@ SRCS = $(OBJS:.o=.cpp) \ HDIR = $(includedir)/IceBox SDIR = $(slicedir)/IceBox -SLICECMD = $(SLICE2CPP) --include-dir IceBox -I$(slicedir) -SLICE2FREEZECMD = $(SLICE2FREEZE) --include-dir IceBox -I$(slicedir) +SLICECMD = $(SLICE2CPP) --ice --include-dir IceBox -I$(slicedir) +SLICE2FREEZECMD = $(SLICE2FREEZE) --ice --include-dir IceBox -I$(slicedir) include $(top_srcdir)/config/Make.rules diff --git a/cpp/src/IcePack/AdapterManager.ice b/cpp/src/IcePack/AdapterManager.ice index 69ae45c89e1..f9a6e59697b 100644 --- a/cpp/src/IcePack/AdapterManager.ice +++ b/cpp/src/IcePack/AdapterManager.ice @@ -110,14 +110,14 @@ class Adapter * The description of this objet adapter. * */ - AdapterDescription _description; + AdapterDescription description; /** * * A direct proxy created from the adapter. * */ - Object* _proxy; + Object* proxy; }; /** diff --git a/cpp/src/IcePack/AdapterManagerI.cpp b/cpp/src/IcePack/AdapterManagerI.cpp index f5bfc92a7f4..13c0bf73e26 100644 --- a/cpp/src/IcePack/AdapterManagerI.cpp +++ b/cpp/src/IcePack/AdapterManagerI.cpp @@ -87,7 +87,7 @@ IcePack::AdapterI::~AdapterI() AdapterDescription IcePack::AdapterI::getAdapterDescription(const Current&) { - return _description; + return description; } ObjectPrx @@ -95,16 +95,16 @@ IcePack::AdapterI::getDirectProxy(bool activate, const Current&) { ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this); - if(!activate || !_description.server || _active) + if(!activate || !description.server || _active) { - return _proxy; + return proxy; } // // If there's a server associated to this adapter, try to start // the server and wait for the adapter state to change. // - if(_description.server && _description.server->start()) + if(description.server && description.server->start()) { // // Wait for this adapter to be marked as active or the @@ -120,14 +120,14 @@ IcePack::AdapterI::getDirectProxy(bool activate, const Current&) } } - return _proxy; + return proxy; } void IcePack::AdapterI::setDirectProxy(const ObjectPrx& proxy, const Current&) { ::IceUtil::Monitor< ::IceUtil::Mutex>::Lock sync(*this); - _proxy = proxy; + this->proxy = proxy; } void @@ -194,8 +194,8 @@ IcePack::AdapterManagerI::create(const AdapterDescription& description, const Cu } AdapterPtr adapterI = new AdapterI(_waitTime); - adapterI->_description = description; - adapterI->_proxy = 0; + adapterI->description = description; + adapterI->proxy = 0; // // Add this adapter name to our adapter names internal set. diff --git a/cpp/src/IcePack/Makefile b/cpp/src/IcePack/Makefile index 8dc42d2c99a..4833dcd761c 100644 --- a/cpp/src/IcePack/Makefile +++ b/cpp/src/IcePack/Makefile @@ -50,7 +50,7 @@ SRCS = $(OBJS:.o=.cpp) \ HDIR = $(includedir)/IcePack LOCAL_HDIR = ../IcePack SDIR = $(slicedir)/IcePack -SLICECMD = $(SLICE2CPP) --include-dir IcePack --dll-export ICE_PACK_API -I$(slicedir) +SLICECMD = $(SLICE2CPP) --ice --include-dir IcePack --dll-export ICE_PACK_API -I$(slicedir) include $(top_srcdir)/config/Make.rules diff --git a/cpp/src/IcePack/ServerManager.ice b/cpp/src/IcePack/ServerManager.ice index 577b376beb8..d9dfed8f3ef 100644 --- a/cpp/src/IcePack/ServerManager.ice +++ b/cpp/src/IcePack/ServerManager.ice @@ -66,14 +66,14 @@ class Server * The description of this server. * */ - ServerDescription _description; + ServerDescription description; /** * * The adapter proxies. * **/ - Adapters _adapters; + Adapters adapters; }; class ServerManager diff --git a/cpp/src/IcePack/ServerManagerI.cpp b/cpp/src/IcePack/ServerManagerI.cpp index 6dd9a240582..0ac1d4bbbec 100644 --- a/cpp/src/IcePack/ServerManagerI.cpp +++ b/cpp/src/IcePack/ServerManagerI.cpp @@ -94,7 +94,7 @@ IcePack::ServerI::~ServerI() ServerDescription IcePack::ServerI::getServerDescription(const Current&) { - return _description; + return description; } bool @@ -131,14 +131,14 @@ IcePack::ServerI::start(const Current&) try { - bool activated = _activator->activate(ServerNameToServer(_adapter)(_description.name)); + bool activated = _activator->activate(ServerNameToServer(_adapter)(description.name)); setState(activated ? Active : Inactive); return activated; } catch (const SystemException& ex) { Warning out(_adapter->getCommunicator()->getLogger()); - out << "activation failed for server `" << _description.name << "':\n"; + out << "activation failed for server `" << description.name << "':\n"; out << ex; setState(Inactive); @@ -157,10 +157,10 @@ IcePack::ServerI::terminationCallback(const Current&) setState(Deactivating); // - // Mark each adapter as inactive. _adapters is immutable when + // Mark each adapter as inactive. adapters is immutable when // state == Deactivating. // - for(Adapters::iterator p = _adapters.begin(); p != _adapters.end(); ++p) + for(Adapters::iterator p = adapters.begin(); p != adapters.end(); ++p) { (*p)->markAsInactive(); } @@ -238,11 +238,11 @@ IcePack::ServerManagerI::create(const ServerDescription& desc, const Current&) } ServerPtr serverI = new ServerI(_adapter, _activator); - serverI->_description = desc; + serverI->description = desc; for(AdapterNames::const_iterator p = desc.adapters.begin(); p != desc.adapters.end(); ++p) { AdapterPrx adapter = _adapterManager->findByName(*p); - serverI->_adapters.push_back(adapter); + serverI->adapters.push_back(adapter); } _evictor->createObject(server->ice_getIdentity(), serverI); diff --git a/cpp/src/IcePatch/Makefile b/cpp/src/IcePatch/Makefile index 1b5b96640c6..3bb1adc60c3 100644 --- a/cpp/src/IcePatch/Makefile +++ b/cpp/src/IcePatch/Makefile @@ -37,7 +37,7 @@ SRCS = $(OBJS:.o=.cpp) \ HDIR = $(includedir)/IcePatch SDIR = $(slicedir)/IcePatch -SLICECMD = $(SLICE2CPP) --include-dir IcePatch --dll-export ICE_PATCH_API -I$(slicedir) +SLICECMD = $(SLICE2CPP) --ice --include-dir IcePatch --dll-export ICE_PATCH_API -I$(slicedir) include $(top_srcdir)/config/Make.rules diff --git a/cpp/src/IceSSL/ConfigParser.cpp b/cpp/src/IceSSL/ConfigParser.cpp index e7f689c8b65..124d51b4069 100644 --- a/cpp/src/IceSSL/ConfigParser.cpp +++ b/cpp/src/IceSSL/ConfigParser.cpp @@ -66,7 +66,7 @@ IceSSL::ConfigParser::process() s << "while parsing " << _configFile << ": " << endl; s << "xerces-c init exception: " << DOMString(toCatch.getMessage()); - configEx._message = s.str(); + configEx.message = s.str(); throw configEx; } @@ -129,7 +129,7 @@ IceSSL::ConfigParser::process() s << "while parsing " << _configFile << ": " << endl; s << "xerces-c parsing error: " << DOMString(e.getMessage()); - configEx._message = s.str(); + configEx.message = s.str(); throw configEx; } @@ -142,7 +142,7 @@ IceSSL::ConfigParser::process() s << "xerces-c DOM parsing error, DOMException code: " << e.code; s << ", message: " << e.msg; - configEx._message = s.str(); + configEx.message = s.str(); throw configEx; } @@ -150,7 +150,7 @@ IceSSL::ConfigParser::process() { ConfigParseException configEx(__FILE__, __LINE__); - configEx._message = "while parsing " + _configFile + "\n" + "unknown error occured during parsing"; + configEx.message = "while parsing " + _configFile + "\n" + "unknown error occured during parsing"; throw configEx; } @@ -163,14 +163,14 @@ IceSSL::ConfigParser::process() errStr << dec << errorCount << " errors occured during parsing"; - configEx._message = errStr.str(); + configEx.message = errStr.str(); string reporterErrors = errReporter->getErrors(); if(!reporterErrors.empty()) { - configEx._message += "\n"; - configEx._message += reporterErrors; + configEx.message += "\n"; + configEx.message += reporterErrors; } throw configEx; @@ -205,7 +205,7 @@ IceSSL::ConfigParser::loadClientConfig(GeneralConfig& general, s << "xerces-c DOM parsing error, DOMException code: " << e.code; s << ", message: " << e.msg; - configEx._message = s.str(); + configEx.message = s.str(); throw configEx; } @@ -243,7 +243,7 @@ IceSSL::ConfigParser::loadServerConfig(GeneralConfig& general, s << "xerces-c DOM parsing error, DOMException code: " << e.code; s << ", message: " << e.msg; - configEx._message = s.str(); + configEx.message = s.str(); throw configEx; } diff --git a/cpp/src/IceSSL/ContextOpenSSL.cpp b/cpp/src/IceSSL/ContextOpenSSL.cpp index 649fe46de9a..3362a876efe 100644 --- a/cpp/src/IceSSL/ContextOpenSSL.cpp +++ b/cpp/src/IceSSL/ContextOpenSSL.cpp @@ -78,7 +78,7 @@ IceSSL::OpenSSL::Context::setRSAKeysBase64(const string& privateKey, { IceSSL::PrivateKeyException privateKeyEx(__FILE__, __LINE__); - privateKeyEx._message = "Empty private key supplied."; + privateKeyEx.message = "Empty private key supplied."; throw privateKeyEx; } @@ -93,7 +93,7 @@ IceSSL::OpenSSL::Context::setRSAKeys(const Ice::ByteSeq& privateKey, const Ice:: { IceSSL::PrivateKeyException privateKeyEx(__FILE__, __LINE__); - privateKeyEx._message = "Empty private key supplied."; + privateKeyEx.message = "Empty private key supplied."; throw privateKeyEx; } @@ -219,7 +219,7 @@ IceSSL::OpenSSL::Context::createContext(SslProtocol sslProtocol) { ContextInitializationException contextInitEx(__FILE__, __LINE__); - contextInitEx._message = "unable to create ssl context\n" + sslGetErrors(); + contextInitEx.message = "unable to create ssl context\n" + sslGetErrors(); throw contextInitEx; } @@ -325,13 +325,13 @@ IceSSL::OpenSSL::Context::checkKeyCert() { CertificateKeyMatchException certKeyMatchEx(__FILE__, __LINE__); - certKeyMatchEx._message = "private key does not match the certificate public key"; + certKeyMatchEx.message = "private key does not match the certificate public key"; string sslError = sslGetErrors(); if(!sslError.empty()) { - certKeyMatchEx._message += "\n"; - certKeyMatchEx._message += sslError; + certKeyMatchEx.message += "\n"; + certKeyMatchEx.message += sslError; } throw certKeyMatchEx; @@ -345,7 +345,7 @@ IceSSL::OpenSSL::Context::addTrustedCertificate(const RSAPublicKey& trustedCerti { ContextNotConfiguredException contextConfigEx(__FILE__, __LINE__); - contextConfigEx._message = "ssl context not configured"; + contextConfigEx.message = "ssl context not configured"; throw contextConfigEx; } @@ -358,7 +358,7 @@ IceSSL::OpenSSL::Context::addTrustedCertificate(const RSAPublicKey& trustedCerti { TrustedCertificateAddException trustEx(__FILE__, __LINE__); - trustEx._message = sslGetErrors(); + trustEx.message = sslGetErrors(); throw trustEx; } @@ -384,10 +384,10 @@ IceSSL::OpenSSL::Context::addKeyCert(const CertificateFile& privateKey, const Ce { CertificateLoadException certLoadEx(__FILE__, __LINE__); - certLoadEx._message = "unable to load certificate from '"; - certLoadEx._message += publicFile; - certLoadEx._message += "'\n"; - certLoadEx._message += sslGetErrors(); + certLoadEx.message = "unable to load certificate from '"; + certLoadEx.message += publicFile; + certLoadEx.message += "'\n"; + certLoadEx.message += sslGetErrors(); throw certLoadEx; } @@ -449,13 +449,13 @@ IceSSL::OpenSSL::Context::addKeyCert(const CertificateFile& privateKey, const Ce { CertificateKeyMatchException certKeyMatchEx(__FILE__, __LINE__); - certKeyMatchEx._message = "private key does not match the certificate public key"; + certKeyMatchEx.message = "private key does not match the certificate public key"; string sslError = sslGetErrors(); if(!sslError.empty()) { - certKeyMatchEx._message += "\n"; - certKeyMatchEx._message += sslError; + certKeyMatchEx.message += "\n"; + certKeyMatchEx.message += sslError; } throw certKeyMatchEx; @@ -464,10 +464,10 @@ IceSSL::OpenSSL::Context::addKeyCert(const CertificateFile& privateKey, const Ce { PrivateKeyLoadException pklEx(__FILE__, __LINE__); - pklEx._message = "unable to load private key from '"; - pklEx._message += privKeyFile; - pklEx._message += "'\n"; - pklEx._message += sslGetErrors(); + pklEx.message = "unable to load private key from '"; + pklEx.message += privKeyFile; + pklEx.message += "'\n"; + pklEx.message += sslGetErrors(); throw pklEx; } @@ -484,7 +484,7 @@ IceSSL::OpenSSL::Context::addKeyCert(const RSAKeyPair& keyPair) { ContextNotConfiguredException contextConfigEx(__FILE__, __LINE__); - contextConfigEx._message = "ssl context not configured"; + contextConfigEx.message = "ssl context not configured"; throw contextConfigEx; } @@ -499,13 +499,13 @@ IceSSL::OpenSSL::Context::addKeyCert(const RSAKeyPair& keyPair) { CertificateLoadException certLoadEx(__FILE__, __LINE__); - certLoadEx._message = "unable to set certificate from memory"; + certLoadEx.message = "unable to set certificate from memory"; string sslError = sslGetErrors(); if(!sslError.empty()) { - certLoadEx._message += "\n"; - certLoadEx._message += sslError; + certLoadEx.message += "\n"; + certLoadEx.message += sslError; } throw certLoadEx; @@ -522,13 +522,13 @@ IceSSL::OpenSSL::Context::addKeyCert(const RSAKeyPair& keyPair) { CertificateKeyMatchException certKeyMatchEx(__FILE__, __LINE__); - certKeyMatchEx._message = "private key does not match the certificate public key"; + certKeyMatchEx.message = "private key does not match the certificate public key"; string sslError = sslGetErrors(); if(!sslError.empty()) { - certKeyMatchEx._message += "\n"; - certKeyMatchEx._message += sslError; + certKeyMatchEx.message += "\n"; + certKeyMatchEx.message += sslError; } throw certKeyMatchEx; @@ -537,13 +537,13 @@ IceSSL::OpenSSL::Context::addKeyCert(const RSAKeyPair& keyPair) { PrivateKeyLoadException pklEx(__FILE__, __LINE__); - pklEx._message = "unable to set private key from memory"; + pklEx.message = "unable to set private key from memory"; string sslError = sslGetErrors(); if(!sslError.empty()) { - pklEx._message += "\n"; - pklEx._message += sslError; + pklEx.message += "\n"; + pklEx.message += sslError; } throw pklEx; diff --git a/cpp/src/IceSSL/Makefile b/cpp/src/IceSSL/Makefile index 8a5c2a70503..eabd9908d6e 100644 --- a/cpp/src/IceSSL/Makefile +++ b/cpp/src/IceSSL/Makefile @@ -59,7 +59,7 @@ SRCS = $(OBJS:.o=.cpp) HDIR = $(includedir)/IceSSL SDIR = $(slicedir)/IceSSL -SLICECMD = $(SLICE2CPP) --include-dir IceSSL --dll-export ICE_SSL_API -I$(slicedir) +SLICECMD = $(SLICE2CPP) --ice --include-dir IceSSL --dll-export ICE_SSL_API -I$(slicedir) include $(top_srcdir)/config/Make.rules diff --git a/cpp/src/IceSSL/OpenSSLPluginI.cpp b/cpp/src/IceSSL/OpenSSLPluginI.cpp index 03bc1c9f1fb..1116c7405ac 100644 --- a/cpp/src/IceSSL/OpenSSLPluginI.cpp +++ b/cpp/src/IceSSL/OpenSSLPluginI.cpp @@ -142,7 +142,7 @@ IceSSL::OpenSSL::PluginI::createConnection(ContextType connectionType, int socke { UnsupportedContextException unsupportedException(__FILE__, __LINE__); - unsupportedException._message = "unable to create client/server connections"; + unsupportedException.message = "unable to create client/server connections"; throw unsupportedException; } @@ -298,8 +298,8 @@ IceSSL::OpenSSL::PluginI::loadConfig(ContextType contextType, } } - configEx._message = "no ssl configuration file specified for "; - configEx._message += contextString; + configEx.message = "no ssl configuration file specified for "; + configEx.message += contextString; throw configEx; } diff --git a/cpp/src/IceSSL/RSACertificateGen.cpp b/cpp/src/IceSSL/RSACertificateGen.cpp index a0a21d33cad..77aaeb10b8e 100644 --- a/cpp/src/IceSSL/RSACertificateGen.cpp +++ b/cpp/src/IceSSL/RSACertificateGen.cpp @@ -301,10 +301,10 @@ IceSSL::OpenSSL::RSACertificateGen::loadKeyPair(const std::string& keyFile, cons { IceSSL::OpenSSL::CertificateLoadException certLoadEx(__FILE__, __LINE__); - certLoadEx._message = "unable to load certificate from '"; - certLoadEx._message += certFile; - certLoadEx._message += "'\n"; - certLoadEx._message += sslGetErrors(); + certLoadEx.message = "unable to load certificate from '"; + certLoadEx.message += certFile; + certLoadEx.message += "'\n"; + certLoadEx.message += sslGetErrors(); throw certLoadEx; } @@ -315,10 +315,10 @@ IceSSL::OpenSSL::RSACertificateGen::loadKeyPair(const std::string& keyFile, cons { IceSSL::OpenSSL::CertificateLoadException certLoadEx(__FILE__, __LINE__); - certLoadEx._message = "unable to load certificate from '"; - certLoadEx._message += certFile; - certLoadEx._message += "'\n"; - certLoadEx._message += sslGetErrors(); + certLoadEx.message = "unable to load certificate from '"; + certLoadEx.message += certFile; + certLoadEx.message += "'\n"; + certLoadEx.message += sslGetErrors(); throw certLoadEx; } @@ -331,10 +331,10 @@ IceSSL::OpenSSL::RSACertificateGen::loadKeyPair(const std::string& keyFile, cons { IceSSL::OpenSSL::PrivateKeyLoadException pklEx(__FILE__, __LINE__); - pklEx._message = "unable to load private key from '"; - pklEx._message += keyFile; - pklEx._message += "'\n"; - pklEx._message += sslGetErrors(); + pklEx.message = "unable to load private key from '"; + pklEx.message += keyFile; + pklEx.message += "'\n"; + pklEx.message += sslGetErrors(); throw pklEx; } @@ -345,10 +345,10 @@ IceSSL::OpenSSL::RSACertificateGen::loadKeyPair(const std::string& keyFile, cons { IceSSL::OpenSSL::PrivateKeyLoadException pklEx(__FILE__, __LINE__); - pklEx._message = "unable to load private key from '"; - pklEx._message += keyFile; - pklEx._message += "'\n"; - pklEx._message += sslGetErrors(); + pklEx.message = "unable to load private key from '"; + pklEx.message += keyFile; + pklEx.message += "'\n"; + pklEx.message += sslGetErrors(); throw pklEx; } diff --git a/cpp/src/IceSSL/RSAPrivateKey.cpp b/cpp/src/IceSSL/RSAPrivateKey.cpp index 4b8499ec31a..a3a5f0f98f0 100644 --- a/cpp/src/IceSSL/RSAPrivateKey.cpp +++ b/cpp/src/IceSSL/RSAPrivateKey.cpp @@ -112,7 +112,7 @@ IceSSL::OpenSSL::RSAPrivateKey::byteSeqToKey(const ByteSeq& keySeq) { IceSSL::PrivateKeyParseException pkParseException(__FILE__, __LINE__); - pkParseException._message = "unable to parse provided private key\n" + sslGetErrors(); + pkParseException.message = "unable to parse provided private key\n" + sslGetErrors(); throw pkParseException; } diff --git a/cpp/src/IceSSL/RSAPublicKey.cpp b/cpp/src/IceSSL/RSAPublicKey.cpp index 76c61a6b8f1..4e2e02ea97c 100644 --- a/cpp/src/IceSSL/RSAPublicKey.cpp +++ b/cpp/src/IceSSL/RSAPublicKey.cpp @@ -111,7 +111,7 @@ IceSSL::OpenSSL::RSAPublicKey::byteSeqToCert(const ByteSeq& certSeq) { IceSSL::CertificateParseException certParseException(__FILE__, __LINE__); - certParseException._message = "unable to parse provided public key\n" + sslGetErrors(); + certParseException.message = "unable to parse provided public key\n" + sslGetErrors(); throw certParseException; } diff --git a/cpp/src/IceSSL/SslConnectionOpenSSL.cpp b/cpp/src/IceSSL/SslConnectionOpenSSL.cpp index d7edd9b2dde..32de83aa15a 100644 --- a/cpp/src/IceSSL/SslConnectionOpenSSL.cpp +++ b/cpp/src/IceSSL/SslConnectionOpenSSL.cpp @@ -202,8 +202,8 @@ IceSSL::OpenSSL::Connection::shutdown(int timeout) ProtocolException protocolEx(__FILE__, __LINE__); - protocolEx._message = "encountered a violation of the ssl protocol during shutdown\n"; - protocolEx._message += sslGetErrors(); + protocolEx.message = "encountered a violation of the ssl protocol during shutdown\n"; + protocolEx.message += sslGetErrors(); throw protocolEx; } @@ -671,8 +671,8 @@ IceSSL::OpenSSL::Connection::read(Buffer& buf, int timeout) { ProtocolException protocolEx(__FILE__, __LINE__); - protocolEx._message = "encountered a violation of the ssl protocol\n"; - protocolEx._message += sslGetErrors(); + protocolEx.message = "encountered a violation of the ssl protocol\n"; + protocolEx.message += sslGetErrors(); throw protocolEx; } diff --git a/cpp/src/IceSSL/SslConnectionOpenSSLClient.cpp b/cpp/src/IceSSL/SslConnectionOpenSSLClient.cpp index c2d82b52ff3..a84d0a82431 100644 --- a/cpp/src/IceSSL/SslConnectionOpenSSLClient.cpp +++ b/cpp/src/IceSSL/SslConnectionOpenSSLClient.cpp @@ -169,14 +169,14 @@ IceSSL::OpenSSL::ClientConnection::handshake(int timeout) { CertificateVerificationException certVerEx(__FILE__, __LINE__); - certVerEx._message = getVerificationError(verifyError); + certVerEx.message = getVerificationError(verifyError); string errors = sslGetErrors(); if(!errors.empty()) { - certVerEx._message += "\n"; - certVerEx._message += errors; + certVerEx.message += "\n"; + certVerEx.message += errors; } throw certVerEx; @@ -185,8 +185,8 @@ IceSSL::OpenSSL::ClientConnection::handshake(int timeout) { ProtocolException protocolEx(__FILE__, __LINE__); - protocolEx._message = "encountered a violation of the ssl protocol during handshake\n"; - protocolEx._message += sslGetErrors(); + protocolEx.message = "encountered a violation of the ssl protocol during handshake\n"; + protocolEx.message += sslGetErrors(); throw protocolEx; } @@ -329,8 +329,8 @@ IceSSL::OpenSSL::ClientConnection::write(Buffer& buf, int timeout) ProtocolException protocolEx(__FILE__, __LINE__); // Protocol Error: Unexpected EOF - protocolEx._message = "encountered an EOF that violates the ssl protocol\n"; - protocolEx._message += sslGetErrors(); + protocolEx.message = "encountered an EOF that violates the ssl protocol\n"; + protocolEx.message += sslGetErrors(); throw protocolEx; } @@ -345,8 +345,8 @@ IceSSL::OpenSSL::ClientConnection::write(Buffer& buf, int timeout) { ProtocolException protocolEx(__FILE__, __LINE__); - protocolEx._message = "encountered a violation of the ssl protocol\n"; - protocolEx._message += sslGetErrors(); + protocolEx.message = "encountered a violation of the ssl protocol\n"; + protocolEx.message += sslGetErrors(); throw protocolEx; } diff --git a/cpp/src/IceSSL/SslConnectionOpenSSLServer.cpp b/cpp/src/IceSSL/SslConnectionOpenSSLServer.cpp index fbc43e78391..5548ee82bcc 100644 --- a/cpp/src/IceSSL/SslConnectionOpenSSLServer.cpp +++ b/cpp/src/IceSSL/SslConnectionOpenSSLServer.cpp @@ -107,8 +107,8 @@ IceSSL::OpenSSL::ServerConnection::handshake(int timeout) { ProtocolException protocolEx(__FILE__, __LINE__); - protocolEx._message = "encountered an ssl protocol violation during handshake\n"; - protocolEx._message += sslGetErrors(); + protocolEx.message = "encountered an ssl protocol violation during handshake\n"; + protocolEx.message += sslGetErrors(); throw protocolEx; } @@ -170,8 +170,8 @@ IceSSL::OpenSSL::ServerConnection::handshake(int timeout) ProtocolException protocolEx(__FILE__, __LINE__); // Protocol Error: Unexpected EOF - protocolEx._message = "encountered an eof during handshake that violates the ssl protocol\n"; - protocolEx._message += sslGetErrors(); + protocolEx.message = "encountered an eof during handshake that violates the ssl protocol\n"; + protocolEx.message += sslGetErrors(); throw protocolEx; } @@ -181,8 +181,8 @@ IceSSL::OpenSSL::ServerConnection::handshake(int timeout) { ProtocolException protocolEx(__FILE__, __LINE__); - protocolEx._message = "encountered a violation of the ssl protocol during handshake\n"; - protocolEx._message += sslGetErrors(); + protocolEx.message = "encountered a violation of the ssl protocol during handshake\n"; + protocolEx.message += sslGetErrors(); throw protocolEx; } @@ -310,8 +310,8 @@ IceSSL::OpenSSL::ServerConnection::write(Buffer& buf, int timeout) ProtocolException protocolEx(__FILE__, __LINE__); // Protocol Error: Unexpected EOF. - protocolEx._message = "encountered an EOF that violates the ssl protocol\n"; - protocolEx._message += sslGetErrors(); + protocolEx.message = "encountered an EOF that violates the ssl protocol\n"; + protocolEx.message += sslGetErrors(); throw protocolEx; } @@ -321,8 +321,8 @@ IceSSL::OpenSSL::ServerConnection::write(Buffer& buf, int timeout) { ProtocolException protocolEx(__FILE__, __LINE__); - protocolEx._message = "encountered a violation of the ssl protocol\n"; - protocolEx._message += sslGetErrors(); + protocolEx.message = "encountered a violation of the ssl protocol\n"; + protocolEx.message += sslGetErrors(); throw protocolEx; } diff --git a/cpp/src/IceSSL/SslException.cpp b/cpp/src/IceSSL/SslException.cpp index 202436db850..d621b041bbe 100644 --- a/cpp/src/IceSSL/SslException.cpp +++ b/cpp/src/IceSSL/SslException.cpp @@ -18,9 +18,9 @@ void IceSSL::SslException::ice_print(ostream& out) const { Exception::ice_print(out); - if(!_message.empty()) + if(!message.empty()) { - out << ":\n" << _message; + out << ":\n" << message; } } diff --git a/cpp/src/IceStorm/Makefile b/cpp/src/IceStorm/Makefile index 8834e81e94f..ee89e05fad7 100644 --- a/cpp/src/IceStorm/Makefile +++ b/cpp/src/IceStorm/Makefile @@ -57,8 +57,8 @@ SRCS = $(OBJS:.o=.cpp) \ HDIR = $(includedir)/IceStorm SDIR = $(slicedir)/IceStorm -SLICECMD = $(SLICE2CPP) --include-dir IceStorm -I$(slicedir) -I.. -SLICE2FREEZECMD = $(SLICE2FREEZE) --include-dir IceStorm -I$(slicedir) -I.. +SLICECMD = $(SLICE2CPP) --ice --include-dir IceStorm -I$(slicedir) -I.. +SLICE2FREEZECMD = $(SLICE2FREEZE) --ice --include-dir IceStorm -I$(slicedir) -I.. include $(top_srcdir)/config/Make.rules diff --git a/cpp/src/Slice/Grammar.y b/cpp/src/Slice/Grammar.y index c119d4af163..e0fae075334 100644 --- a/cpp/src/Slice/Grammar.y +++ b/cpp/src/Slice/Grammar.y @@ -68,7 +68,7 @@ yyerror(const char* s) // // Other tokens. // -%token ICE_SCOPE_DELIMITOR +%token ICE_SCOPE_DELIMITER %token ICE_IDENTIFIER %token ICE_STRING_LITERAL %token ICE_INTEGER_LITERAL @@ -1141,13 +1141,13 @@ scoped_name : ICE_IDENTIFIER { } -| ICE_SCOPE_DELIMITOR ICE_IDENTIFIER +| ICE_SCOPE_DELIMITER ICE_IDENTIFIER { StringTokPtr ident = StringTokPtr::dynamicCast($2); ident->v = "::" + ident->v; $$ = ident; } -| scoped_name ICE_SCOPE_DELIMITOR ICE_IDENTIFIER +| scoped_name ICE_SCOPE_DELIMITER ICE_IDENTIFIER { StringTokPtr scoped = StringTokPtr::dynamicCast($1); StringTokPtr ident = StringTokPtr::dynamicCast($3); diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index 8dd38a14f25..fff5079b331 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -231,6 +231,7 @@ Slice::Container::destroy() ModulePtr Slice::Container::createModule(const string& name) { + checkPrefix(name); ContainedList matches = _unit->findContents(thisScope() + name); matches.sort(); // Modules can occur many times... matches.unique(); // ... but we only want one instance of each @@ -276,6 +277,7 @@ Slice::Container::createModule(const string& name) ClassDefPtr Slice::Container::createClassDef(const string& name, bool intf, const ClassList& bases, bool local) { + checkPrefix(name); ContainedList matches = _unit->findContents(thisScope() + name); for(ContainedList::const_iterator p = matches.begin(); p != matches.end(); ++p) { @@ -359,6 +361,8 @@ Slice::Container::createClassDef(const string& name, bool intf, const ClassList& ClassDeclPtr Slice::Container::createClassDecl(const string& name, bool intf, bool local) { + checkPrefix(name); + ClassDefPtr def; ContainedList matches = _unit->findContents(thisScope() + name); @@ -440,6 +444,8 @@ Slice::Container::createClassDecl(const string& name, bool intf, bool local) ExceptionPtr Slice::Container::createException(const string& name, const ExceptionPtr& base, bool local) { + checkPrefix(name); + ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { @@ -481,6 +487,8 @@ Slice::Container::createException(const string& name, const ExceptionPtr& base, StructPtr Slice::Container::createStruct(const string& name, bool local) { + checkPrefix(name); + ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { @@ -514,6 +522,8 @@ Slice::Container::createStruct(const string& name, bool local) SequencePtr Slice::Container::createSequence(const string& name, const TypePtr& type, bool local) { + checkPrefix(name); + ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { @@ -555,6 +565,8 @@ Slice::Container::createSequence(const string& name, const TypePtr& type, bool l DictionaryPtr Slice::Container::createDictionary(const string& name, const TypePtr& keyType, const TypePtr& valueType, bool local) { + checkPrefix(name); + ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { @@ -607,6 +619,8 @@ Slice::Container::createDictionary(const string& name, const TypePtr& keyType, c EnumPtr Slice::Container::createEnum(const string& name, bool local) { + checkPrefix(name); + ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { @@ -639,6 +653,8 @@ Slice::Container::createEnum(const string& name, bool local) EnumeratorPtr Slice::Container::createEnumerator(const string& name) { + checkPrefix(name); + ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { @@ -672,9 +688,8 @@ ConstDefPtr Slice::Container::createConstDef(const string name, const TypePtr& constType, const SyntaxTreeBasePtr& literalType, const string& value) { - // - // Check that the constant name is legal - // + checkPrefix(name); + ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { @@ -1395,6 +1410,18 @@ Slice::Container::checkInterfaceAndLocal(const string& name, bool defined, return true; } +void +Slice::Container::checkPrefix(const string& name) const +{ + if(_unit->currentIncludeLevel() == 0 && !_unit->allowIcePrefix()) + { + if(name.find("Ice", 0) == 0) + { + _unit->error("illegal identifier `" + name + "': `Ice' prefix is reserved"); + } + } +} + // ---------------------------------------------------------------------- // Module // ---------------------------------------------------------------------- @@ -1738,6 +1765,8 @@ OperationPtr Slice::ClassDef::createOperation(const string& name, const TypePtr& returnType) { + checkPrefix(name); + ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { @@ -1843,6 +1872,8 @@ Slice::ClassDef::createOperation(const string& name, DataMemberPtr Slice::ClassDef::createDataMember(const string& name, const TypePtr& type) { + checkPrefix(name); + assert(!isInterface()); ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) @@ -2176,6 +2207,8 @@ Slice::Exception::destroy() DataMemberPtr Slice::Exception::createDataMember(const string& name, const TypePtr& type) { + checkPrefix(name); + ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { @@ -2357,6 +2390,8 @@ Slice::Exception::Exception(const ContainerPtr& container, const string& name, c DataMemberPtr Slice::Struct::createDataMember(const string& name, const TypePtr& type) { + checkPrefix(name); + ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { @@ -3021,6 +3056,8 @@ Slice::Operation::returnType() const ParamDeclPtr Slice::Operation::createParamDecl(const string& name, const TypePtr& type, bool isOutParam) { + checkPrefix(name); + ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { @@ -3344,9 +3381,9 @@ Slice::DataMember::DataMember(const ContainerPtr& container, const string& name, // ---------------------------------------------------------------------- UnitPtr -Slice::Unit::createUnit(bool ignRedefs, bool all) +Slice::Unit::createUnit(bool ignRedefs, bool all, bool allowIcePrefix) { - return new Unit(ignRedefs, all); + return new Unit(ignRedefs, all, allowIcePrefix); } bool @@ -3355,6 +3392,12 @@ Slice::Unit::ignRedefs() const return _ignRedefs; } +bool +Slice::Unit::allowIcePrefix() const +{ + return _allowIcePrefix; +} + void Slice::Unit::setComment(const string& comment) { @@ -3814,11 +3857,12 @@ Slice::Unit::builtin(Builtin::Kind kind) return builtin; } -Slice::Unit::Unit(bool ignRedefs, bool all) : +Slice::Unit::Unit(bool ignRedefs, bool all, bool allowIcePrefix) : SyntaxTreeBase(0), Container(0), _ignRedefs(ignRedefs), _all(all), + _allowIcePrefix(allowIcePrefix), _errors(0) { _unit = this; diff --git a/cpp/src/Slice/Scanner.l b/cpp/src/Slice/Scanner.l index 264c76ce7ee..410c71ac45e 100644 --- a/cpp/src/Slice/Scanner.l +++ b/cpp/src/Slice/Scanner.l @@ -118,21 +118,29 @@ floating_literal (({fractional_constant}{exponent_part}?)|([[:digit:]]+{exponent } "::" { - return ICE_SCOPE_DELIMITOR; + return ICE_SCOPE_DELIMITER; } \\?[[:alpha:]_][[:alnum:]_]* { StringTokPtr ident = new StringTok; - if(*yytext == '\\') // Backslash escapes keyword meaning + ident->v = *yytext == '\\' ? yytext + 1 : yytext; + *yylvalp = ident; + if(ident->v[0] == '_') { - ident->v = yytext + 1; - *yylvalp = ident; - return ICE_IDENTIFIER; + unit->error("illegal leading underscore for identifier `" + ident->v + "'"); } - else + static const string suffixBlacklist[] = { "Helper", "Holder", "Operations", "Prx", "Ptr" }; + for(size_t i = 0; i < sizeof(suffixBlacklist) / sizeof(*suffixBlacklist); ++i) { - ident->v = yytext; - *yylvalp = ident; + if(ident->v.find(suffixBlacklist[i], ident->v.size() - suffixBlacklist[i].size()) != string::npos) + { + unit->error("illegal identifier `" + ident->v + "': `" + suffixBlacklist[i] + "' suffix is reserved"); + } + } + + if(*yytext == '\\') + { + return ICE_IDENTIFIER; } StringTokenMap::const_iterator pos = keywordMap.find(ident->v); diff --git a/cpp/src/Yellow/Makefile b/cpp/src/Yellow/Makefile index 61f12b22121..f14ff8b080f 100644 --- a/cpp/src/Yellow/Makefile +++ b/cpp/src/Yellow/Makefile @@ -45,8 +45,8 @@ SRCS = $(OBJS:.o=.cpp) \ HDIR = $(includedir)/Yellow SDIR = $(slicedir)/Yellow -SLICECMD = $(SLICE2CPP) --include-dir Yellow -I$(slicedir) -I.. -SLICE2FREEZECMD = $(SLICE2FREEZE) --include-dir Yellow -I$(slicedir) -I.. +SLICECMD = $(SLICE2CPP) --ice --include-dir Yellow -I$(slicedir) -I.. +SLICE2FREEZECMD = $(SLICE2FREEZE) --ice --include-dir Yellow -I$(slicedir) -I.. include $(top_srcdir)/config/Make.rules diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index 5eb13c1a3a5..db69a5f8396 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -31,6 +31,7 @@ usage(const char* n) "--dll-export SYMBOL Use SYMBOL for DLL exports.\n" "--impl Generate sample implementations.\n" "-d, --debug Print debug messages.\n" + "--ice Permit `Ice' prefix (for building Ice source code only)\n" ; } @@ -44,6 +45,7 @@ main(int argc, char* argv[]) string dllExport; bool impl = false; bool debug = false; + bool ice = false; int idx = 1; while(idx < argc) @@ -95,6 +97,15 @@ main(int argc, char* argv[]) } --argc; } + else if(strcmp(argv[idx], "--ice") == 0) + { + ice = true; + for(int i = idx ; i + 1 < argc ; ++i) + { + argv[i] = argv[i + 1]; + } + --argc; + } else if(strcmp(argv[idx], "--include-dir") == 0) { if(idx + 1 >= argc) @@ -210,7 +221,7 @@ main(int argc, char* argv[]) return EXIT_FAILURE; } - UnitPtr unit = Unit::createUnit(false, false); + UnitPtr unit = Unit::createUnit(false, false, ice); int parseStatus = unit->parse(cppHandle, debug); #ifdef _WIN32 diff --git a/cpp/src/slice2docbook/Main.cpp b/cpp/src/slice2docbook/Main.cpp index 4eb55e53690..4d8e2cd6112 100644 --- a/cpp/src/slice2docbook/Main.cpp +++ b/cpp/src/slice2docbook/Main.cpp @@ -32,6 +32,7 @@ usage(const char* n) "--chapter Use \"chapter\" instead of \"section\" as\n" " top-level element.\n" "-d, --debug Print debug messages.\n" + "--ice Permit `Ice' prefix (for building Ice source code only)\n" ; } @@ -40,6 +41,7 @@ main(int argc, char* argv[]) { string cpp("cpp -C"); bool debug = false; + bool ice = false; bool standAlone = false; bool noGlobals = false; bool chapter = false; @@ -115,6 +117,15 @@ main(int argc, char* argv[]) } --argc; } + else if(strcmp(argv[idx], "--ice") == 0) + { + ice = true; + for(int i = idx ; i + 1 < argc ; ++i) + { + argv[i] = argv[i + 1]; + } + --argc; + } else if(argv[idx][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; @@ -155,7 +166,7 @@ main(int argc, char* argv[]) return EXIT_FAILURE; } - UnitPtr unit = Unit::createUnit(true, false); + UnitPtr unit = Unit::createUnit(true, false, ice); int status = EXIT_SUCCESS; diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp index 4692dcf2581..047defaa62c 100644 --- a/cpp/src/slice2freeze/Main.cpp +++ b/cpp/src/slice2freeze/Main.cpp @@ -43,6 +43,7 @@ usage(const char* n) " different names. NAME may be a scoped name.\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" ; } @@ -198,6 +199,7 @@ main(int argc, char* argv[]) string dllExport; string output; bool debug = false; + bool ice = false; vector<Dict> dicts; int idx = 1; @@ -308,6 +310,15 @@ main(int argc, char* argv[]) } --argc; } + else if(strcmp(argv[idx], "--ice") == 0) + { + ice = true; + for(int i = idx ; i + 1 < argc ; ++i) + { + argv[i] = argv[i + 1]; + } + --argc; + } else if(strcmp(argv[idx], "--include-dir") == 0) { if(idx + 1 >= argc) @@ -392,7 +403,7 @@ main(int argc, char* argv[]) fileC = output + '/' + fileC; } - UnitPtr unit = Unit::createUnit(true, false); + UnitPtr unit = Unit::createUnit(true, false, ice); StringList includes; diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp index b06ce6efeab..c841716a8cc 100644 --- a/cpp/src/slice2freezej/Main.cpp +++ b/cpp/src/slice2freezej/Main.cpp @@ -308,8 +308,8 @@ usage(const char* n) " option may be specified multiple times for\n" " different names. NAME may be a scoped name.\n" "--output-dir DIR Create files in the directory DIR.\n" - "--ice TBD.\n" "-d, --debug Print debug messages.\n" + "--ice Permit `Ice' prefix (for building Ice source code only)\n" ; } @@ -321,6 +321,7 @@ main(int argc, char* argv[]) string include; string output; bool debug = false; + bool ice = false; vector<Dict> dicts; int idx = 1; @@ -431,6 +432,15 @@ main(int argc, char* argv[]) } --argc; } + else if(strcmp(argv[idx], "--ice") == 0) + { + ice = true; + for(int i = idx ; i + 1 < argc ; ++i) + { + argv[i] = argv[i + 1]; + } + --argc; + } else if(strcmp(argv[idx], "--include-dir") == 0) { if(idx + 1 >= argc) @@ -463,15 +473,6 @@ main(int argc, char* argv[]) } argc -= 2; } - else if(strcmp(argv[idx], "--ice") == 0) - { - // TBD - for(int i = idx ; i + 1 < argc ; ++i) - { - argv[i] = argv[i + 1]; - } - --argc; - } else if(argv[idx][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; @@ -491,7 +492,7 @@ main(int argc, char* argv[]) return EXIT_FAILURE; } - UnitPtr unit = Unit::createUnit(true, false); + UnitPtr unit = Unit::createUnit(true, false, ice); StringList includes; diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp index 0d01dd27769..fd39fe0d277 100644 --- a/cpp/src/slice2java/Main.cpp +++ b/cpp/src/slice2java/Main.cpp @@ -32,8 +32,8 @@ usage(const char* n) "--impl Generate sample implementations.\n" "--impl-tie Generate sample TIE implementations.\n" "--clone Generate clone().\n" - "--ice TBD.\n" "-d, --debug Print debug messages.\n" + "--ice Permit `Ice' prefix (for building Ice source code only)\n" ; } @@ -49,6 +49,7 @@ main(int argc, char* argv[]) bool implTie = false; bool clone = false; bool debug = false; + bool ice = false; int idx = 1; while(idx < argc) @@ -104,6 +105,15 @@ main(int argc, char* argv[]) } --argc; } + else if(strcmp(argv[idx], "--ice") == 0) + { + ice = true; + for(int i = idx ; i + 1 < argc ; ++i) + { + argv[i] = argv[i + 1]; + } + --argc; + } else if(strcmp(argv[idx], "--output-dir") == 0) { if(idx + 1 >= argc) @@ -174,15 +184,6 @@ main(int argc, char* argv[]) } --argc; } - else if(strcmp(argv[idx], "--ice") == 0) - { - // TBD - for(int i = idx ; i + 1 < argc ; ++i) - { - argv[i] = argv[i + 1]; - } - --argc; - } else if(argv[idx][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[idx] << "'" @@ -251,7 +252,7 @@ main(int argc, char* argv[]) return EXIT_FAILURE; } - UnitPtr unit = Unit::createUnit(false, false); + UnitPtr unit = Unit::createUnit(false, false, ice); int parseStatus = unit->parse(cppHandle, debug); #ifdef _WIN32 diff --git a/cpp/src/slice2wsdl/Main.cpp b/cpp/src/slice2wsdl/Main.cpp index a0eb13321ec..132c429cb45 100644 --- a/cpp/src/slice2wsdl/Main.cpp +++ b/cpp/src/slice2wsdl/Main.cpp @@ -26,8 +26,8 @@ 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" - "--ice TBD.\n" "-d, --debug Print debug messages.\n" + "--ice Permit `Ice' prefix (for building Ice source code only)\n" ; } @@ -36,6 +36,7 @@ main(int argc, char* argv[]) { string cpp("cpp -C"); bool debug = false; + bool ice = false; string include; string output; vector<string> includePaths; @@ -90,6 +91,15 @@ main(int argc, char* argv[]) } --argc; } + else if(strcmp(argv[idx], "--ice") == 0) + { + ice = true; + for(int i = idx ; i + 1 < argc ; ++i) + { + argv[i] = argv[i + 1]; + } + --argc; + } else if(strcmp(argv[idx], "--include-dir") == 0) { if(idx + 1 >= argc) @@ -122,15 +132,6 @@ main(int argc, char* argv[]) } argc -= 2; } - else if(strcmp(argv[idx], "--ice") == 0) - { - // TBD - for(int i = idx ; i + 1 < argc ; ++i) - { - argv[i] = argv[i + 1]; - } - --argc; - } else if(argv[idx][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; @@ -190,7 +191,7 @@ main(int argc, char* argv[]) return EXIT_FAILURE; } - UnitPtr unit = Unit::createUnit(false, false); + UnitPtr unit = Unit::createUnit(false, false, ice); int parseStatus = unit->parse(cppHandle, debug); #ifdef _WIN32 diff --git a/cpp/src/slice2xsd/Main.cpp b/cpp/src/slice2xsd/Main.cpp index f3c485ad95c..82395018af4 100644 --- a/cpp/src/slice2xsd/Main.cpp +++ b/cpp/src/slice2xsd/Main.cpp @@ -26,8 +26,8 @@ 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" - "--ice TBD.\n" "-d, --debug Print debug messages.\n" + "--ice Permit `Ice' prefix (for building Ice source code only)\n" ; } @@ -36,6 +36,7 @@ main(int argc, char* argv[]) { string cpp("cpp -C"); bool debug = false; + bool ice = false; string include; string output; vector<string> includePaths; @@ -90,6 +91,15 @@ main(int argc, char* argv[]) } --argc; } + else if(strcmp(argv[idx], "--ice") == 0) + { + ice = true; + for(int i = idx ; i + 1 < argc ; ++i) + { + argv[i] = argv[i + 1]; + } + --argc; + } else if(strcmp(argv[idx], "--include-dir") == 0) { if(idx + 1 >= argc) @@ -122,15 +132,6 @@ main(int argc, char* argv[]) } argc -= 2; } - else if(strcmp(argv[idx], "--ice") == 0) - { - // TBD - for(int i = idx ; i + 1 < argc ; ++i) - { - argv[i] = argv[i + 1]; - } - --argc; - } else if(argv[idx][0] == '-') { cerr << argv[0] << ": unknown option `" << argv[idx] << "'" << endl; @@ -191,7 +192,7 @@ main(int argc, char* argv[]) return EXIT_FAILURE; } - UnitPtr unit = Unit::createUnit(false, false); + UnitPtr unit = Unit::createUnit(false, false, ice); int parseStatus = unit->parse(cppHandle, debug); #ifdef _WIN32 diff --git a/cpp/test/Freeze/complex/Complex.ice b/cpp/test/Freeze/complex/Complex.ice index 35591d2fd25..70a507ba683 100644 --- a/cpp/test/Freeze/complex/Complex.ice +++ b/cpp/test/Freeze/complex/Complex.ice @@ -30,13 +30,13 @@ class Node { class NumberNode extends Node { - int _number; + int number; }; class BinaryNode extends Node { - Node _left; - Node _right; + Node left; + Node right; }; class AddNode extends BinaryNode diff --git a/cpp/test/Freeze/complex/NodeI.h b/cpp/test/Freeze/complex/NodeI.h index 0b9d0fa3dd5..328c5db7062 100644 --- a/cpp/test/Freeze/complex/NodeI.h +++ b/cpp/test/Freeze/complex/NodeI.h @@ -27,12 +27,12 @@ public: NumberNodeI(int number) { - _number = number; + this->number = number; } virtual int calc(const Ice::Current&) { - return _number; + return number; } }; @@ -46,13 +46,13 @@ public: AddNodeI(const NodePtr& left, const NodePtr& right) { - _left = left; - _right = right; + this->left = left; + this->right = right; } virtual int calc(const Ice::Current&) { - return _left->calc() + _right->calc(); + return left->calc() + right->calc(); } }; @@ -66,13 +66,13 @@ public: MultiplyNodeI(const NodePtr& left, const NodePtr& right) { - _left = left; - _right = right; + this->left = left; + this->right = right; } virtual int calc(const Ice::Current&) { - return _left->calc() * _right->calc(); + return left->calc() * right->calc(); } }; diff --git a/cpp/test/Slice/errorDetection/IdentAsKeyword.err b/cpp/test/Slice/errorDetection/IdentAsKeyword.err index 058922b7cab..d1558009ba6 100644 --- a/cpp/test/Slice/errorDetection/IdentAsKeyword.err +++ b/cpp/test/Slice/errorDetection/IdentAsKeyword.err @@ -84,3 +84,6 @@ IdentAsKeyword.ice:77: keyword `byte' cannot be used as parameter name IdentAsKeyword.ice:79: keyword `byte' cannot be used as parameter name IdentAsKeyword.ice:80: illegal identifier: `BYTE' differs from keyword `byte' only in capitalization IdentAsKeyword.ice:80: keyword `byte' cannot be used as parameter name +IdentAsKeyword.ice:84: illegal leading underscore for identifier `_a' +IdentAsKeyword.ice:85: illegal leading underscore for identifier `_true' +IdentAsKeyword.ice:86: illegal leading underscore for identifier `_true' diff --git a/cpp/test/Slice/errorDetection/IdentAsKeyword.ice b/cpp/test/Slice/errorDetection/IdentAsKeyword.ice index cd7b13d6c2a..0af740c836b 100644 --- a/cpp/test/Slice/errorDetection/IdentAsKeyword.ice +++ b/cpp/test/Slice/errorDetection/IdentAsKeyword.ice @@ -80,3 +80,7 @@ interface i9 { void op(out double byte); }; interface i10 { void op(out double BYTE); }; interface \true {}; // OK, escaped keyword + +interface _a; // Illegal leading underscore +interface _true; // Illegal leading underscore +interface \_true; // Illegal leading underscore diff --git a/cpp/test/Slice/errorDetection/Reserved.err b/cpp/test/Slice/errorDetection/Reserved.err new file mode 100644 index 00000000000..a78f24e8ba8 --- /dev/null +++ b/cpp/test/Slice/errorDetection/Reserved.err @@ -0,0 +1,15 @@ +Reserved.ice:31: illegal identifier `Prx': `Prx' suffix is reserved +Reserved.ice:32: illegal identifier `abcPrx': `Prx' suffix is reserved +Reserved.ice:33: illegal identifier `Ptr': `Ptr' suffix is reserved +Reserved.ice:34: illegal identifier `abcPtr': `Ptr' suffix is reserved +Reserved.ice:35: illegal identifier `Helper': `Helper' suffix is reserved +Reserved.ice:36: illegal identifier `abcHelper': `Helper' suffix is reserved +Reserved.ice:37: illegal identifier `Holder': `Holder' suffix is reserved +Reserved.ice:38: illegal identifier `abcHolder': `Holder' suffix is reserved +Reserved.ice:39: illegal identifier `Operations': `Operations' suffix is reserved +Reserved.ice:40: illegal identifier `abcOperations': `Operations' suffix is reserved +Reserved.ice:41: illegal identifier `Ice': `Ice' prefix is reserved +Reserved.ice:42: illegal identifier `Iceblah': `Ice' prefix is reserved +Reserved.ice:43: illegal identifier `IceFoo': `Ice' prefix is reserved +Reserved.ice:46: illegal identifier `Ice': `Ice' prefix is reserved +Reserved.ice:47: illegal identifier `IceFoo': `Ice' prefix is reserved diff --git a/cpp/test/Slice/errorDetection/Reserved.ice b/cpp/test/Slice/errorDetection/Reserved.ice new file mode 100644 index 00000000000..4560f79354f --- /dev/null +++ b/cpp/test/Slice/errorDetection/Reserved.ice @@ -0,0 +1,47 @@ +// ********************************************************************** +// +// Copyright (c) 2001 +// Mutable Realms, Inc. +// Huntsville, AL, USA +// +// All Rights Reserved +// +// ********************************************************************** + +#include <include/IcePrefix.ice> // No error should be caused by this file + +module OK +{ +const long PrxA = 0; +const long APrxA = 0; +const long prxB = 0; +const long Bprx = 0; +const long prx = 0; +const long PtrA = 0; +const long HelperA = 0; +const long HolderA = 0; +const long OperationsA = 0; +const long aIce = 0; +const long ice = 0; +const long icea = 0; +}; + +module errors +{ +const long Prx = 0; +const long abcPrx = 0; +const long Ptr = 0; +const long abcPtr = 0; +const long Helper = 0; +const long abcHelper = 0; +const long Holder = 0; +const long abcHolder = 0; +const long Operations = 0; +const long abcOperations = 0; +const long Ice = 0; +const long Iceblah = 0; +const long IceFoo = 0; +}; + +module Ice {}; +module IceFoo {}; diff --git a/cpp/test/Slice/errorDetection/include/IcePrefix.ice b/cpp/test/Slice/errorDetection/include/IcePrefix.ice new file mode 100644 index 00000000000..bfcd2357fe3 --- /dev/null +++ b/cpp/test/Slice/errorDetection/include/IcePrefix.ice @@ -0,0 +1,11 @@ +// ********************************************************************** +// +// Copyright (c) 2001 +// Mutable Realms, Inc. +// Huntsville, AL, USA +// +// All Rights Reserved +// +// ********************************************************************** + +module IceSomething {}; diff --git a/cpp/test/Slice/errorDetection/run.py b/cpp/test/Slice/errorDetection/run.py index 0cc00280539..ee206bf5098 100755 --- a/cpp/test/Slice/errorDetection/run.py +++ b/cpp/test/Slice/errorDetection/run.py @@ -32,7 +32,7 @@ for file in files: print file + "...", - command = slice2cpp + " " + os.path.join(directory, file); + command = slice2cpp + " -I. " + os.path.join(directory, file); stdin, stdout, stderr = os.popen3(command) lines1 = stdout.readlines() lines2 = open(os.path.join(directory, regex1.sub(".err", file)), "r").readlines() |