diff options
author | Marc Laukien <marc@zeroc.com> | 2001-09-09 22:31:50 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2001-09-09 22:31:50 +0000 |
commit | 8260c9c3a8b6fbf43f0403c8082a713a94c83eaf (patch) | |
tree | d7aaede8d1fea68b31e39736d116c7567a1f218c | |
parent | completed structs; parser visitor changes (diff) | |
download | ice-8260c9c3a8b6fbf43f0403c8082a713a94c83eaf.tar.bz2 ice-8260c9c3a8b6fbf43f0403c8082a713a94c83eaf.tar.xz ice-8260c9c3a8b6fbf43f0403c8082a713a94c83eaf.zip |
fixes, tests, etc.
-rw-r--r-- | cpp/include/Ice/Config.h | 1 | ||||
-rw-r--r-- | cpp/include/Ice/Stream.h | 1 | ||||
-rw-r--r-- | cpp/slice/IcePack/Admin.ice | 17 | ||||
-rw-r--r-- | cpp/src/Ice/Emitter.h | 1 | ||||
-rw-r--r-- | cpp/src/Ice/ObjectAdapterFactory.h | 1 | ||||
-rw-r--r-- | cpp/src/Ice/ObjectAdapterI.h | 1 | ||||
-rw-r--r-- | cpp/src/Ice/PropertiesI.h | 1 | ||||
-rw-r--r-- | cpp/src/Ice/ThreadPool.h | 1 | ||||
-rw-r--r-- | cpp/src/Ice/ValueFactoryManager.h | 1 | ||||
-rw-r--r-- | cpp/src/IcePack/Activator.cpp | 10 | ||||
-rw-r--r-- | cpp/src/IcePack/Activator.h | 3 | ||||
-rw-r--r-- | cpp/src/IcePack/AdminI.cpp | 24 | ||||
-rw-r--r-- | cpp/src/IcePack/AdminI.h | 6 | ||||
-rw-r--r-- | cpp/src/IcePack/Forward.cpp | 12 | ||||
-rw-r--r-- | cpp/src/IcePack/Forward.h | 1 | ||||
-rw-r--r-- | cpp/src/IcePack/Parser.cpp | 21 | ||||
-rw-r--r-- | cpp/src/Slice/Grammer.y | 12 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.cpp | 6 | ||||
-rw-r--r-- | cpp/src/slice2cpp/Gen.h | 1 | ||||
-rw-r--r-- | cpp/test/Slice/errorDetection/StructDeclaration.err | 1 | ||||
-rw-r--r-- | cpp/test/Slice/errorDetection/StructDeclaration.ice | 11 |
21 files changed, 78 insertions, 55 deletions
diff --git a/cpp/include/Ice/Config.h b/cpp/include/Ice/Config.h index ce3212f2d1c..fb908c28e11 100644 --- a/cpp/include/Ice/Config.h +++ b/cpp/include/Ice/Config.h @@ -80,6 +80,7 @@ typedef double Double; #include <iostream> #include <string> #include <vector> +#include <map> // // Define the Ice and IceInternal namespace, so that we can use the following diff --git a/cpp/include/Ice/Stream.h b/cpp/include/Ice/Stream.h index 251886dfdf5..851cfe9f9a3 100644 --- a/cpp/include/Ice/Stream.h +++ b/cpp/include/Ice/Stream.h @@ -15,7 +15,6 @@ #include <Ice/ObjectF.h> #include <Ice/ProxyF.h> #include <Ice/Buffer.h> -#include <map> namespace IceInternal { diff --git a/cpp/slice/IcePack/Admin.ice b/cpp/slice/IcePack/Admin.ice index ea84a58c600..13a060c4d9a 100644 --- a/cpp/slice/IcePack/Admin.ice +++ b/cpp/slice/IcePack/Admin.ice @@ -28,11 +28,11 @@ sequence<string> Args; /** * - * Data describing a server one or more objects implemented by that + * Data describing a server and one or more objects implemented by that * server. * **/ -class ServerDescription +struct ServerDescription { /** * @@ -93,10 +93,12 @@ class ServerDescription /** * - * A vector of server descriptions. + * A dictionary of server descriptions. A dictionary key is an object + * identity (which might be a regular expression), and the values is + * the corresponding server description. * **/ -sequence<ServerDescription> ServerDescriptions; +dictionary<string, ServerDescription> ServerDescriptions; /** * @@ -109,6 +111,13 @@ class Admin { /** * + * All server descriptions. + * + **/ + ServerDescriptions _serverDescriptions; + + /** + * * Add a server and objects implemented by that server to &IcePack;. * * @param description The server's description. diff --git a/cpp/src/Ice/Emitter.h b/cpp/src/Ice/Emitter.h index d76b0d6c7ac..d2820ddf5ba 100644 --- a/cpp/src/Ice/Emitter.h +++ b/cpp/src/Ice/Emitter.h @@ -20,7 +20,6 @@ #include <Ice/TraceLevelsF.h> #include <Ice/LoggerF.h> #include <Ice/EventHandler.h> -#include <map> namespace Ice { diff --git a/cpp/src/Ice/ObjectAdapterFactory.h b/cpp/src/Ice/ObjectAdapterFactory.h index 51be702eebc..abcefa0df04 100644 --- a/cpp/src/Ice/ObjectAdapterFactory.h +++ b/cpp/src/Ice/ObjectAdapterFactory.h @@ -17,7 +17,6 @@ #include <Ice/ObjectAdapterF.h> #include <Ice/ProxyF.h> #include <Ice/ObjectF.h> -#include <map> namespace IceInternal { diff --git a/cpp/src/Ice/ObjectAdapterI.h b/cpp/src/Ice/ObjectAdapterI.h index af0a8733e6a..3f6c5522d8d 100644 --- a/cpp/src/Ice/ObjectAdapterI.h +++ b/cpp/src/Ice/ObjectAdapterI.h @@ -20,7 +20,6 @@ #include <Ice/ProxyF.h> #include <Ice/ObjectF.h> #include <Ice/LocalException.h> -#include <map> namespace Ice { diff --git a/cpp/src/Ice/PropertiesI.h b/cpp/src/Ice/PropertiesI.h index 651ac559543..0a4027d18d6 100644 --- a/cpp/src/Ice/PropertiesI.h +++ b/cpp/src/Ice/PropertiesI.h @@ -12,7 +12,6 @@ #define ICE_PROPERTIES_I_H #include <Ice/Properties.h> -#include <map> namespace Ice { diff --git a/cpp/src/Ice/ThreadPool.h b/cpp/src/Ice/ThreadPool.h index 01365b4c9ff..c1374167d06 100644 --- a/cpp/src/Ice/ThreadPool.h +++ b/cpp/src/Ice/ThreadPool.h @@ -15,7 +15,6 @@ #include <Ice/ThreadPoolF.h> #include <Ice/InstanceF.h> #include <Ice/EventHandlerF.h> -#include <map> namespace IceInternal { diff --git a/cpp/src/Ice/ValueFactoryManager.h b/cpp/src/Ice/ValueFactoryManager.h index 85aa1936d2c..9ec1a797b0e 100644 --- a/cpp/src/Ice/ValueFactoryManager.h +++ b/cpp/src/Ice/ValueFactoryManager.h @@ -14,7 +14,6 @@ #include <IceUtil/Shared.h> #include <Ice/ValueFactoryManagerF.h> #include <Ice/ValueFactoryF.h> -#include <map> namespace IceInternal { diff --git a/cpp/src/IcePack/Activator.cpp b/cpp/src/IcePack/Activator.cpp index a75bc1b4874..57b29be7978 100644 --- a/cpp/src/IcePack/Activator.cpp +++ b/cpp/src/IcePack/Activator.cpp @@ -86,7 +86,7 @@ IcePack::Activator::destroy() } bool -IcePack::Activator::activate(const ServerDescriptionPtr& desc) +IcePack::Activator::activate(const ServerDescription& desc) { JTCSyncT<JTCMutex> sync(*this); @@ -95,7 +95,7 @@ IcePack::Activator::activate(const ServerDescriptionPtr& desc) return false; } - string path = desc->path; + string path = desc.path; if (path.empty()) { return false; @@ -153,12 +153,12 @@ IcePack::Activator::activate(const ServerDescriptionPtr& desc) } } - int argc = desc->args.size() + 2; + int argc = desc.args.size() + 2; char** argv = static_cast<char**>(malloc(argc * sizeof(char*))); argv[0] = strdup(path.c_str()); - for (unsigned int i = 0; i < desc->args.size(); ++i) + for (unsigned int i = 0; i < desc.args.size(); ++i) { - argv[i + 1] = strdup(desc->args[i].c_str()); + argv[i + 1] = strdup(desc.args[i].c_str()); } argv[argc - 1] = 0; diff --git a/cpp/src/IcePack/Activator.h b/cpp/src/IcePack/Activator.h index a0f6e086fba..d433783fc2f 100644 --- a/cpp/src/IcePack/Activator.h +++ b/cpp/src/IcePack/Activator.h @@ -12,7 +12,6 @@ #define ICE_PACK_ACTIVATOR_H #include <IcePack/AdminF.h> -#include <map> namespace IcePack { @@ -26,7 +25,7 @@ public: virtual void run(); void destroy(); - bool activate(const IcePack::ServerDescriptionPtr&); + bool activate(const IcePack::ServerDescription&); private: diff --git a/cpp/src/IcePack/AdminI.cpp b/cpp/src/IcePack/AdminI.cpp index 4a09e24b281..453e9debab7 100644 --- a/cpp/src/IcePack/AdminI.cpp +++ b/cpp/src/IcePack/AdminI.cpp @@ -21,13 +21,13 @@ IcePack::AdminI::AdminI(const CommunicatorPtr& communicator) : } void -IcePack::AdminI::add(const ServerDescriptionPtr& p) +IcePack::AdminI::add(const ServerDescription& desc) { JTCSyncT<JTCMutex> sync(*this); - if (p && p->object) + if (desc.object) { - _map[p->object->_getIdentity()] = p; + _serverDescriptions[desc.object->_getIdentity()] = desc; } } @@ -35,35 +35,29 @@ void IcePack::AdminI::remove(const string& identity) { JTCSyncT<JTCMutex> sync(*this); - _map.erase(identity); + _serverDescriptions.erase(identity); } -ServerDescriptionPtr +ServerDescription IcePack::AdminI::find(const string& identity) { JTCSyncT<JTCMutex> sync(*this); - map<string, ServerDescriptionPtr>::iterator p = _map.find(identity); - if (p != _map.end()) + ServerDescriptions::iterator p = _serverDescriptions.find(identity); + if (p != _serverDescriptions.end()) { return p->second; } else { - return 0; + return ServerDescription(); } } ServerDescriptions IcePack::AdminI::getAll() { - ServerDescriptions result; - result.reserve(_map.size()); - for (map<string, ServerDescriptionPtr>::iterator p = _map.begin(); p != _map.end(); ++p) - { - result.push_back(p->second); - } - return result; + return _serverDescriptions; } void diff --git a/cpp/src/IcePack/AdminI.h b/cpp/src/IcePack/AdminI.h index 591c58fdf84..3cca838faff 100644 --- a/cpp/src/IcePack/AdminI.h +++ b/cpp/src/IcePack/AdminI.h @@ -12,7 +12,6 @@ #define ICE_PACK_ADMIN_I_H #include <IcePack/Admin.h> -#include <map> namespace IcePack { @@ -23,16 +22,15 @@ public: AdminI(const Ice::CommunicatorPtr&); - virtual void add(const ServerDescriptionPtr&); + virtual void add(const ServerDescription&); virtual void remove(const std::string&); - virtual ServerDescriptionPtr find(const std::string&); + virtual ServerDescription find(const std::string&); virtual ServerDescriptions getAll(); virtual void shutdown(); private: Ice::CommunicatorPtr _communicator; - std::map<std::string, ServerDescriptionPtr> _map; }; } diff --git a/cpp/src/IcePack/Forward.cpp b/cpp/src/IcePack/Forward.cpp index cfdf25e3bde..6f35d679ef1 100644 --- a/cpp/src/IcePack/Forward.cpp +++ b/cpp/src/IcePack/Forward.cpp @@ -57,24 +57,22 @@ IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const string& identity // // Look up the server description // - ServerDescriptionPtr desc = _admin->find(identity); + ServerDescription desc = _admin->find(identity); // // If we didn't find a server description, we return null, meaning // that the client will get an "object not exist" exception. // - if (!desc) + if (!desc.object) { return 0; } - ObjectPrx object = desc->object; - #ifndef WIN32 // // We only try to activate if we have a path for the server // - if (!desc->path.empty()) + if (!desc.path.empty()) { try { @@ -113,7 +111,7 @@ IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const string& identity // server timeout, a crash, or an explicit // shutdown method. // - object->_ping(); + desc.object->_ping(); // // Everything ok, the server is now up and @@ -157,7 +155,7 @@ IcePack::Forward::locate(const ObjectAdapterPtr& adapter, const string& identity } #endif - throw LocationForward(object); + throw LocationForward(desc.object); } void diff --git a/cpp/src/IcePack/Forward.h b/cpp/src/IcePack/Forward.h index 7ba5bd7022b..966b7276ceb 100644 --- a/cpp/src/IcePack/Forward.h +++ b/cpp/src/IcePack/Forward.h @@ -15,7 +15,6 @@ #ifndef WIN32 # include <IcePack/Activator.h> #endif -#include <map> namespace IcePack { diff --git a/cpp/src/IcePack/Parser.cpp b/cpp/src/IcePack/Parser.cpp index 9c82492b6bf..b53be9d841e 100644 --- a/cpp/src/IcePack/Parser.cpp +++ b/cpp/src/IcePack/Parser.cpp @@ -50,16 +50,16 @@ IcePack::Parser::add(const list<string>& args) try { - ServerDescriptionPtr desc = new ServerDescription; + ServerDescription desc; list<string>::const_iterator p = args.begin(); - desc->object = _communicator->stringToProxy(*p); - desc->regex = false; + desc.object = _communicator->stringToProxy(*p); + desc.regex = false; if (++p != args.end()) { - desc->path = *p; + desc.path = *p; while (++p != args.end()) { - desc->args.push_back(*p); + desc.args.push_back(*p); } } _admin->add(desc); @@ -99,12 +99,13 @@ IcePack::Parser::getAll() ServerDescriptions::iterator p = descriptions.begin(); while(p != descriptions.end()) { - cout << "object = " << _communicator->proxyToString((*p)->object) << endl; - cout << "regex = " << boolalpha << (*p)->regex << endl; - cout << "host = " << (*p)->host << endl; - cout << "path = " << (*p)->path << endl; + cout << "identity = " << p->first << endl; + cout << "object = " << _communicator->proxyToString(p->second.object) << endl; + cout << "regex = " << boolalpha << p->second.regex << endl; + cout << "host = " << p->second.host << endl; + cout << "path = " << p->second.path << endl; cout << "args ="; - for (Args::iterator q = (*p)->args.begin(); q != (*p)->args.end(); ++q) + for (Args::iterator q = p->second.args.begin(); q != p->second.args.end(); ++q) { cout << ' ' << *q; } diff --git a/cpp/src/Slice/Grammer.y b/cpp/src/Slice/Grammer.y index 90023395846..8b76b8c7361 100644 --- a/cpp/src/Slice/Grammer.y +++ b/cpp/src/Slice/Grammer.y @@ -101,6 +101,9 @@ definition | interface_def { } +| struct_decl +{ +} | struct_def { } @@ -174,6 +177,15 @@ interface_export ; // ---------------------------------------------------------------------- +struct_decl +// ---------------------------------------------------------------------- +: ICE_STRUCT ICE_IDENTIFIER +{ + unit->error("structs can not be forward declared"); +} +; + +// ---------------------------------------------------------------------- struct_def // ---------------------------------------------------------------------- : ICE_STRUCT ICE_IDENTIFIER diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 37d0491360f..c067b5536b6 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -277,6 +277,12 @@ Slice::Gen::TypesVisitor::visitModuleEnd(const ModulePtr& p) } bool +Slice::Gen::TypesVisitor::visitClassDefStart(const ClassDefPtr&) +{ + return false; +} + +bool Slice::Gen::TypesVisitor::visitStructStart(const StructPtr& p) { string name = p->name(); diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h index 42ab3f41d30..cddd62692aa 100644 --- a/cpp/src/slice2cpp/Gen.h +++ b/cpp/src/slice2cpp/Gen.h @@ -53,6 +53,7 @@ private: virtual bool visitModuleStart(const ModulePtr&); virtual void visitModuleEnd(const ModulePtr&); + virtual bool visitClassDefStart(const ClassDefPtr&); virtual bool visitStructStart(const StructPtr&); virtual void visitStructEnd(const StructPtr&); virtual void visitSequence(const SequencePtr&); diff --git a/cpp/test/Slice/errorDetection/StructDeclaration.err b/cpp/test/Slice/errorDetection/StructDeclaration.err new file mode 100644 index 00000000000..1f39ae523b4 --- /dev/null +++ b/cpp/test/Slice/errorDetection/StructDeclaration.err @@ -0,0 +1 @@ +StructDeclaration.ice:11: structs can not be forward declared diff --git a/cpp/test/Slice/errorDetection/StructDeclaration.ice b/cpp/test/Slice/errorDetection/StructDeclaration.ice new file mode 100644 index 00000000000..1acf2030ebf --- /dev/null +++ b/cpp/test/Slice/errorDetection/StructDeclaration.ice @@ -0,0 +1,11 @@ +// ********************************************************************** +// +// Copyright (c) 2001 +// MutableRealms, Inc. +// Huntsville, AL, USA +// +// All Rights Reserved +// +// ********************************************************************** + +struct S; |