diff --git a/cpp/src/IceGrid/DescriptorBuilder.cpp b/cpp/src/IceGrid/DescriptorBuilder.cpp index 372033e8c35..5ce8c03fa75 100644 --- a/cpp/src/IceGrid/DescriptorBuilder.cpp +++ b/cpp/src/IceGrid/DescriptorBuilder.cpp @@ -408,7 +408,7 @@ ApplicationDescriptorBuilder::isOverride(const string& name) ServerInstanceDescriptorBuilder::ServerInstanceDescriptorBuilder(const XmlAttributesHelper& attrs) { - _descriptor._cpp_template = attrs("template"); + _descriptor.templateName = attrs("template"); _descriptor.parameterValues = attrs.asMap(); _descriptor.parameterValues.erase("template"); } @@ -724,7 +724,7 @@ CommunicatorDescriptorBuilder::addProperty(PropertyDescriptorSeq& properties, co ServiceInstanceDescriptorBuilder::ServiceInstanceDescriptorBuilder(const XmlAttributesHelper& attrs) { - _descriptor._cpp_template = attrs("template"); + _descriptor.templateName = attrs("template"); _descriptor.parameterValues = attrs.asMap(); _descriptor.parameterValues.erase("template"); } diff --git a/cpp/src/IceGrid/DescriptorHelper.cpp b/cpp/src/IceGrid/DescriptorHelper.cpp index 5d54234c154..983d40e0e4c 100644 --- a/cpp/src/IceGrid/DescriptorHelper.cpp +++ b/cpp/src/IceGrid/DescriptorHelper.cpp @@ -1732,7 +1732,7 @@ ServiceInstanceHelper::ServiceInstanceHelper(ServiceInstanceDescriptor desc, boo // descriptor must be set and contain the definition of the // service. // - if (_def._cpp_template.empty() && !_def.descriptor) + if (_def.templateName.empty() && !_def.descriptor) { throw DeploymentException("invalid service instance: no template defined"); } @@ -1746,13 +1746,13 @@ ServiceInstanceHelper::ServiceInstanceHelper(ServiceInstanceDescriptor desc, boo bool ServiceInstanceHelper::operator==(const ServiceInstanceHelper& helper) const { - if (_def._cpp_template.empty()) + if (_def.templateName.empty()) { return _service == helper._service; } else { - return _def._cpp_template == helper._def._cpp_template && _def.parameterValues == helper._def.parameterValues && + return _def.templateName == helper._def.templateName && _def.parameterValues == helper._def.parameterValues && _def.propertySet == helper._def.propertySet; } } @@ -1770,12 +1770,12 @@ ServiceInstanceHelper::instantiate(const Resolver& resolve, const PropertySetDes std::map parameterValues; if (!def.getDescriptor()) { - assert(!_def._cpp_template.empty()); - TemplateDescriptor tmpl = resolve.getServiceTemplate(_def._cpp_template); + assert(!_def.templateName.empty()); + TemplateDescriptor tmpl = resolve.getServiceTemplate(_def.templateName); def = ServiceHelper(dynamic_pointer_cast(tmpl.descriptor)); parameterValues = instantiateParams( resolve, - _def._cpp_template, + _def.templateName, _def.parameterValues, tmpl.parameters, tmpl.parameterDefaults); @@ -1800,7 +1800,7 @@ ServiceInstanceHelper::instantiate(const Resolver& resolve, const PropertySetDes // the template + parameters which would be wrong (if the template // changed the instance also changed.) // - // desc._cpp_template = _template; + // desc.templateName = _template; // desc.parameterValues = _parameters; return desc; } @@ -1828,10 +1828,10 @@ ServiceInstanceHelper::print(const shared_ptr& communicator, } else { - assert(!_def._cpp_template.empty()); + assert(!_def.templateName.empty()); out << "service instance"; out << sb; - out << nl << "template = '" << _def._cpp_template << "'"; + out << nl << "template = '" << _def.templateName << "'"; out << nl << "parameters"; out << sb; for (StringStringDict::const_iterator p = _def.parameterValues.begin(); p != _def.parameterValues.end(); ++p) @@ -1868,7 +1868,7 @@ ServerInstanceHelper::init(const shared_ptr& definition, const std::map parameterValues; if (!def) { - if (_def._cpp_template.empty()) + if (_def.templateName.empty()) { resolve.exception("invalid server instance: template is not defined"); } @@ -1876,11 +1876,11 @@ ServerInstanceHelper::init(const shared_ptr& definition, const // // Get the server definition and the template property sets. // - TemplateDescriptor tmpl = resolve.getServerTemplate(_def._cpp_template); + TemplateDescriptor tmpl = resolve.getServerTemplate(_def.templateName); def = dynamic_pointer_cast(tmpl.descriptor); parameterValues = instantiateParams( resolve, - _def._cpp_template, + _def.templateName, _def.parameterValues, tmpl.parameters, tmpl.parameterDefaults); @@ -1919,9 +1919,9 @@ ServerInstanceHelper::init(const shared_ptr& definition, const // Instantiate the server instance definition (we use the server // resolver above, so using parameters in properties is possible). // - if (!_def._cpp_template.empty()) + if (!_def.templateName.empty()) { - _instance._cpp_template = _def._cpp_template; + _instance.templateName = _def.templateName; _instance.parameterValues = parameterValues; _instance.propertySet = svrResolve(_def.propertySet); for (PropertySetDescriptorDict::const_iterator p = _def.servicePropertySets.begin(); @@ -1943,13 +1943,13 @@ ServerInstanceHelper::init(const shared_ptr& definition, const bool ServerInstanceHelper::operator==(const ServerInstanceHelper& helper) const { - if (_def._cpp_template.empty()) + if (_def.templateName.empty()) { return *_serverDefinition == *helper._serverDefinition; } else { - return _def._cpp_template == helper._def._cpp_template && _def.parameterValues == helper._def.parameterValues && + return _def.templateName == helper._def.templateName && _def.parameterValues == helper._def.parameterValues && _def.propertySet == helper._def.propertySet && _def.servicePropertySets == helper._def.servicePropertySets; } @@ -1970,21 +1970,21 @@ ServerInstanceHelper::getId() const ServerInstanceDescriptor ServerInstanceHelper::getDefinition() const { - assert(!_def._cpp_template.empty()); + assert(!_def.templateName.empty()); return _def; } ServerInstanceDescriptor ServerInstanceHelper::getInstance() const { - assert(!_def._cpp_template.empty() && !_instance._cpp_template.empty()); + assert(!_def.templateName.empty() && !_instance.templateName.empty()); return _instance; } shared_ptr ServerInstanceHelper::getServerDefinition() const { - assert(_def._cpp_template.empty()); + assert(_def.templateName.empty()); return _serverDefinition->getDescriptor(); } diff --git a/cpp/src/IceGrid/Parser.cpp b/cpp/src/IceGrid/Parser.cpp index fd10829c44e..4e73682eacf 100644 --- a/cpp/src/IceGrid/Parser.cpp +++ b/cpp/src/IceGrid/Parser.cpp @@ -821,7 +821,7 @@ Parser::instantiateServerTemplate(const list& args) } ServerInstanceDescriptor desc; - desc._cpp_template = templ; + desc.templateName = templ; desc.parameterValues = vars; _admin->instantiateServer(application, node, desc); } diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index 1221268a6ac..1741696f995 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -581,9 +581,12 @@ Slice::Contained::scope() const string Slice::Contained::mappedName() const { + const string languageName = _unit->languageName(); + assert(!languageName.empty()); + // First check if any 'xxx:identifier' has been applied to this element. // If so, we return that instead of the element's Slice identifier. - const string metadata = _unit->languagePrefix() + ":identifier"; + const string metadata = languageName + ":identifier"; if (auto customName = getMetadataArgs(metadata)) { return *customName; @@ -4592,7 +4595,7 @@ Slice::DataMember::DataMember( // ---------------------------------------------------------------------- UnitPtr -Slice::Unit::createUnit(string languagePrefix, bool all, const StringList& defaultFileMetadata) +Slice::Unit::createUnit(string languageName, bool all, const StringList& defaultFileMetadata) { MetadataList defaultMetadata; for (const auto& metadataString : defaultFileMetadata) @@ -4600,15 +4603,15 @@ Slice::Unit::createUnit(string languagePrefix, bool all, const StringList& defau defaultMetadata.push_back(make_shared(metadataString, "", 0)); } - UnitPtr unit{new Unit{std::move(languagePrefix), all, std::move(defaultMetadata)}}; + UnitPtr unit{new Unit{std::move(languageName), all, std::move(defaultMetadata)}}; unit->_unit = unit; return unit; } string -Slice::Unit::languagePrefix() const +Slice::Unit::languageName() const { - return _languagePrefix; + return _languageName; } void @@ -5060,16 +5063,16 @@ Slice::Unit::getTopLevelModules(const string& file) const } } -Slice::Unit::Unit(string languagePrefix, bool all, MetadataList defaultFileMetadata) +Slice::Unit::Unit(string languageName, bool all, MetadataList defaultFileMetadata) : SyntaxTreeBase(nullptr), Container(nullptr), - _languagePrefix(std::move(languagePrefix)), + _languageName(std::move(languageName)), _all(all), _defaultFileMetadata(std::move(defaultFileMetadata)), _errors(0), _currentIncludeLevel(0) { - assert(binary_search(&languages[0], &languages[sizeof(languages) / sizeof(*languages)], _languagePrefix)); + assert(binary_search(&languages[0], &languages[sizeof(languages) / sizeof(*languages)], _languageName)); } // ---------------------------------------------------------------------- diff --git a/cpp/src/Slice/Parser.h b/cpp/src/Slice/Parser.h index 38fef9428d3..3524808b2a6 100644 --- a/cpp/src/Slice/Parser.h +++ b/cpp/src/Slice/Parser.h @@ -364,18 +364,18 @@ namespace Slice public: [[nodiscard]] ContainerPtr container() const; - /// @return The Slice identifier of this element. + /// Returns the Slice identifier of this element. [[nodiscard]] std::string name() const; - /// @return The Slice scope that this element is contained within (with a trailing '::'). + /// Returns the Slice scope that this element is contained within (with a trailing '::'). [[nodiscard]] std::string scope() const; - /// @return The fully-scoped Slice identifier of this element (equivalent to `scope() + name()`). + /// Returns the fully-scoped Slice identifier of this element (equivalent to `scope() + name()`). [[nodiscard]] std::string scoped() const; - /// @return The mapped identifier that this element will use in the target language. + /// Returns the mapped identifier that this element will use in the target language. [[nodiscard]] std::string mappedName() const; - /// @return The mapped scope that this element will be generated in in the target language. + /// Returns the mapped scope that this element will be generated in in the target language. [[nodiscard]] std::string mappedScoped() const; - /// @return The mapped fully-scoped identifier that this element will use in the target language. + /// Returns the mapped fully-scoped identifier that this element will use in the target language. /// (equivalent to `mappedScoped() + mappedName()`). [[nodiscard]] std::string mappedScope() const; @@ -1002,9 +1002,9 @@ namespace Slice { public: static UnitPtr - createUnit(std::string languagePrefix, bool all, const StringList& defaultFileMetadata = StringList()); + createUnit(std::string languageName, bool all, const StringList& defaultFileMetadata = StringList()); - [[nodiscard]] std::string languagePrefix() const; + [[nodiscard]] std::string languageName() const; void setDocComment(const std::string& comment); void addToDocComment(const std::string& comment); @@ -1056,12 +1056,12 @@ namespace Slice [[nodiscard]] std::set getTopLevelModules(const std::string& file) const; private: - Unit(std::string languagePrefix, bool all, MetadataList defaultFileMetadata); + Unit(std::string languageName, bool all, MetadataList defaultFileMetadata); void pushDefinitionContext(); void popDefinitionContext(); - const std::string _languagePrefix; + const std::string _languageName; bool _all; MetadataList _defaultFileMetadata; int _errors; diff --git a/cpp/src/ice2slice/Main.cpp b/cpp/src/ice2slice/Main.cpp index dd78cc6249c..b36fca65bb7 100644 --- a/cpp/src/ice2slice/Main.cpp +++ b/cpp/src/ice2slice/Main.cpp @@ -176,7 +176,7 @@ compile(const vector& argv) } else { - UnitPtr p = Unit::createUnit("icerpc", false); + UnitPtr p = Unit::createUnit("", false); int parseStatus = p->parse(*i, cppHandle, debug); if (!icecpp->close()) diff --git a/cpp/test/Ice/servantLocator/Test.ice b/cpp/test/Ice/servantLocator/Test.ice index 362d3105424..73a08353aac 100644 --- a/cpp/test/Ice/servantLocator/Test.ice +++ b/cpp/test/Ice/servantLocator/Test.ice @@ -28,8 +28,9 @@ interface TestIntf void unknownExceptionWithServantException(); - string impossibleException(["cpp:identifier:_cpp_throw"] bool throw) throws TestImpossibleException; - string intfUserException(["cpp:identifier:_cpp_throw"] bool throw) throws TestIntfUserException, TestImpossibleException; + // TODO rename the throw variable in all language mappings before adding more 'xxx:identifier'. + string impossibleException(["cpp:identifier:shouldThrow"] bool throw) throws TestImpossibleException; + string intfUserException(["cpp:identifier:shouldThrow"] bool throw) throws TestIntfUserException, TestImpossibleException; void asyncResponse() throws TestIntfUserException, TestImpossibleException; void asyncException() throws TestIntfUserException, TestImpossibleException; diff --git a/cpp/test/Ice/servantLocator/TestAMD.ice b/cpp/test/Ice/servantLocator/TestAMD.ice index 79bb77346c1..5889a636c26 100644 --- a/cpp/test/Ice/servantLocator/TestAMD.ice +++ b/cpp/test/Ice/servantLocator/TestAMD.ice @@ -28,8 +28,9 @@ exception TestImpossibleException void unknownExceptionWithServantException(); - string impossibleException(["cpp:identifier:_cpp_throw"] bool throw) throws TestImpossibleException; - string intfUserException(["cpp:identifier:_cpp_throw"] bool throw) throws TestIntfUserException, TestImpossibleException; + // TODO rename the throw variable in all language mappings before adding more 'xxx:identifier'. + string impossibleException(["cpp:identifier:shouldThrow"] bool throw) throws TestImpossibleException; + string intfUserException(["cpp:identifier:shouldThrow"] bool throw) throws TestIntfUserException, TestImpossibleException; void asyncResponse() throws TestIntfUserException, TestImpossibleException; void asyncException() throws TestIntfUserException, TestImpossibleException; diff --git a/cpp/test/Ice/servantLocator/TestAMDI.cpp b/cpp/test/Ice/servantLocator/TestAMDI.cpp index e95b65c137d..444035f9ce8 100644 --- a/cpp/test/Ice/servantLocator/TestAMDI.cpp +++ b/cpp/test/Ice/servantLocator/TestAMDI.cpp @@ -74,12 +74,12 @@ TestAMDI::unknownExceptionWithServantExceptionAsync( void TestAMDI::impossibleExceptionAsync( - bool _cpp_throw, + bool shouldThrow, function response, function error, const Current&) { - if (_cpp_throw) + if (shouldThrow) { try { @@ -102,12 +102,12 @@ TestAMDI::impossibleExceptionAsync( void TestAMDI::intfUserExceptionAsync( - bool _cpp_throw, + bool shouldThrow, function response, function error, const Current&) { - if (_cpp_throw) + if (shouldThrow) { try { diff --git a/cpp/test/Ice/servantLocator/TestI.cpp b/cpp/test/Ice/servantLocator/TestI.cpp index 6223e186a8b..79ee1d4fa6d 100644 --- a/cpp/test/Ice/servantLocator/TestI.cpp +++ b/cpp/test/Ice/servantLocator/TestI.cpp @@ -55,9 +55,9 @@ TestI::unknownExceptionWithServantException(const Current&) } string -TestI::impossibleException(bool _cpp_throw, const Current&) +TestI::impossibleException(bool shouldThrow, const Current&) { - if (_cpp_throw) + if (shouldThrow) { throw Test::TestImpossibleException(); } @@ -69,9 +69,9 @@ TestI::impossibleException(bool _cpp_throw, const Current&) } string -TestI::intfUserException(bool _cpp_throw, const Current&) +TestI::intfUserException(bool shouldThrow, const Current&) { - if (_cpp_throw) + if (shouldThrow) { throw Test::TestIntfUserException(); } diff --git a/cpp/test/IceGrid/activation/AllTests.cpp b/cpp/test/IceGrid/activation/AllTests.cpp index 5fde1dc5cba..1a64faef122 100644 --- a/cpp/test/IceGrid/activation/AllTests.cpp +++ b/cpp/test/IceGrid/activation/AllTests.cpp @@ -744,7 +744,7 @@ allTests(Test::TestHelper* helper) ostringstream id; id << "server-" << i; IceGrid::ServerInstanceDescriptor server; - server._cpp_template = "Server"; + server.templateName = "Server"; server.parameterValues["id"] = id.str(); testApp.nodes["localnode"].serverInstances.push_back(server); } diff --git a/cpp/test/IceGrid/noRestartUpdate/AllTests.cpp b/cpp/test/IceGrid/noRestartUpdate/AllTests.cpp index 8cb3e47167f..9120616764a 100644 --- a/cpp/test/IceGrid/noRestartUpdate/AllTests.cpp +++ b/cpp/test/IceGrid/noRestartUpdate/AllTests.cpp @@ -250,7 +250,7 @@ allTests(Test::TestHelper* helper) update.variables["server.dir"] = properties->getProperty("ServerDir"); update.variables["variable"] = ""; instance = ServerInstanceDescriptor(); - instance._cpp_template = "ServerTemplate"; + instance.templateName = "ServerTemplate"; instance.parameterValues["name"] = "Server1"; update.nodes[0].serverInstances.push_back(instance); try @@ -381,7 +381,7 @@ allTests(Test::TestHelper* helper) update = empty; update.serverTemplates["ServerTemplate"] = templ; instance = ServerInstanceDescriptor(); - instance._cpp_template = "ServerTemplate"; + instance.templateName = "ServerTemplate"; instance.parameterValues["name"] = "Server1"; update.nodes[0].serverInstances.push_back(instance); admin->updateApplicationWithoutRestart(update); diff --git a/cpp/test/IceGrid/replicaGroup/AllTests.cpp b/cpp/test/IceGrid/replicaGroup/AllTests.cpp index 82b88488df6..1a764482acd 100644 --- a/cpp/test/IceGrid/replicaGroup/AllTests.cpp +++ b/cpp/test/IceGrid/replicaGroup/AllTests.cpp @@ -26,7 +26,7 @@ instantiateServer( bool startServer = true) { ServerInstanceDescriptor desc; - desc._cpp_template = templ; + desc.templateName = templ; desc.parameterValues = params; NodeUpdateDescriptor nodeUpdate; nodeUpdate.name = node; diff --git a/cpp/test/IceGrid/replication/AllTests.cpp b/cpp/test/IceGrid/replication/AllTests.cpp index d218beb88c6..951c90ebcc4 100644 --- a/cpp/test/IceGrid/replication/AllTests.cpp +++ b/cpp/test/IceGrid/replication/AllTests.cpp @@ -128,7 +128,7 @@ namespace void instantiateServer(const optional& admin, string templ, const map& params) { ServerInstanceDescriptor desc; - desc._cpp_template = std::move(templ); + desc.templateName = std::move(templ); desc.parameterValues = params; NodeUpdateDescriptor nodeUpdate; nodeUpdate.name = "localnode"; diff --git a/cpp/test/IceGrid/update/AllTests.cpp b/cpp/test/IceGrid/update/AllTests.cpp index 6767b7c7834..a67047ba237 100644 --- a/cpp/test/IceGrid/update/AllTests.cpp +++ b/cpp/test/IceGrid/update/AllTests.cpp @@ -188,7 +188,7 @@ allTests(Test::TestHelper* helper) update = empty; ServerInstanceDescriptor instance; - instance._cpp_template = "ServerTemplate"; + instance.templateName = "ServerTemplate"; update.nodes[0].serverInstances.push_back(instance); try { @@ -209,7 +209,7 @@ allTests(Test::TestHelper* helper) update.variables["test.dir"] = properties->getProperty("ServerDir"); update.variables["variable"] = ""; instance = ServerInstanceDescriptor(); - instance._cpp_template = "ServerTemplate"; + instance.templateName = "ServerTemplate"; instance.parameterValues["name"] = "Server1"; update.nodes[0].serverInstances.push_back(instance); try @@ -335,7 +335,7 @@ allTests(Test::TestHelper* helper) update = empty; update.serverTemplates["ServerTemplate"] = templ; instance = ServerInstanceDescriptor(); - instance._cpp_template = "ServerTemplate"; + instance.templateName = "ServerTemplate"; instance.parameterValues["name"] = "Server1"; update.nodes[0].serverInstances.push_back(instance); try @@ -738,7 +738,7 @@ allTests(Test::TestHelper* helper) node.variables["nodevar"] = "NodeValue"; ServerInstanceDescriptor serverInstance; - serverInstance._cpp_template = "ServerTemplate"; + serverInstance.templateName = "ServerTemplate"; serverInstance.parameterValues["name"] = "Server"; serverInstance.parameterValues["serverparamvar"] = "ServerParamValue"; node.serverInstances.push_back(serverInstance); @@ -803,7 +803,7 @@ allTests(Test::TestHelper* helper) update = empty; serverInstance = ServerInstanceDescriptor(); - serverInstance._cpp_template = "ServerTemplate"; + serverInstance.templateName = "ServerTemplate"; serverInstance.parameterValues["name"] = "Server"; nodeUpdate = NodeUpdateDescriptor(); nodeUpdate.name = "node1"; @@ -884,7 +884,7 @@ allTests(Test::TestHelper* helper) svcTempl.descriptor = service; ServiceInstanceDescriptor serviceInstance; - serviceInstance._cpp_template = "ServiceTemplate"; + serviceInstance.templateName = "ServiceTemplate"; serviceInstance.parameterValues["name"] = "Service"; serviceInstance.propertySet.properties.push_back(createProperty("ServiceInstanceProp", "test")); @@ -917,7 +917,7 @@ allTests(Test::TestHelper* helper) node.propertySets["NodePropertySet1"].properties.push_back(createProperty("NodeProp", "test")); ServerInstanceDescriptor serverInstance; - serverInstance._cpp_template = "ServerTemplate"; + serverInstance.templateName = "ServerTemplate"; serverInstance.parameterValues["name"] = "Server"; serverInstance.propertySet.properties.push_back(createProperty("ServerInstanceProp", "test")); node.serverInstances.push_back(serverInstance); @@ -1111,7 +1111,7 @@ allTests(Test::TestHelper* helper) nodeApp.serverTemplates["nodeTemplate"].parameters.push_back("index"); ServerInstanceDescriptor instance; - instance._cpp_template = "nodeTemplate"; + instance.templateName = "nodeTemplate"; instance.parameterValues["index"] = "1"; nodeApp.nodes["localnode"].serverInstances.push_back(instance); instance.parameterValues["index"] = "2"; diff --git a/slice/IceGrid/Descriptor.ice b/slice/IceGrid/Descriptor.ice index 1683c538a5e..cf06aa7c753 100644 --- a/slice/IceGrid/Descriptor.ice +++ b/slice/IceGrid/Descriptor.ice @@ -197,7 +197,7 @@ module IceGrid struct ServerInstanceDescriptor { /// The template used by this instance. - ["cpp:identifier:_cpp_template"] + ["cpp:identifier:templateName"] string template; /// The template parameter values. @@ -235,7 +235,7 @@ module IceGrid struct ServiceInstanceDescriptor { /// The template used by this instance. - ["cpp:identifier:_cpp_template"] + ["cpp:identifier:templateName"] string template; /// The template parameter values.