diff --git a/.github/actions/setup-dependencies/action.yml b/.github/actions/setup-dependencies/action.yml index ff283c368b2..9e41409a609 100644 --- a/.github/actions/setup-dependencies/action.yml +++ b/.github/actions/setup-dependencies/action.yml @@ -1,6 +1,14 @@ name: Setup Dependencies inputs: + use_matlab: + description: "Indicates whether to install and configure MATLAB" + type: choice + required: true + default: "false" + options: + - true + - false use_ccache: description: "Indicates whether to install and configure ccache" type: choice @@ -100,50 +108,9 @@ runs: # # MATLAB # - - name: Setup MATLAB - id: setup-matlab - uses: matlab-actions/setup-matlab@v2 - with: - release: "R2024a" - if: matrix.config == 'matlab' - - - name: Set MATLAB_HOME and MATLAB_VERSION - run: | - # Needed for MATLAB R2024a - sudo apt install -y libgtk2.0-0 - echo "MATLAB_VERSION=R2024a" >> $GITHUB_ENV - echo "MATLAB_HOME=${{ steps.setup-matlab.outputs.matlabroot }}" >> $GITHUB_ENV - shell: bash - if: runner.os == 'Linux' && matrix.config == 'matlab' - - - name: Set MATLAB_HOME and MATLAB_VERSION - run: | - echo "MATLAB_VERSION=R2024a" >> $env:GITHUB_ENV - echo "MATLAB_HOME=${{ steps.setup-matlab.outputs.matlabroot }}" >> $env:GITHUB_ENV - shell: powershell - if: runner.os == 'Windows' && matrix.config == 'matlab' - - # https://github.com/matlab-actions/run-command/issues/53 - - name: Get run-matlab-command - run: | - wget -O /usr/local/bin/run-matlab-command https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/glnxa64/run-matlab-command - chmod +x /usr/local/bin/run-matlab-command - echo "MATLAB_COMMAND=/usr/local/bin/run-matlab-command" >> $GITHUB_ENV - - # https://www.mathworks.com/matlabcentral/answers/1907290-how-to-manually-select-the-libstdc-library-to-use-to-resolve-a-version-glibcxx_-not-found - echo "LD_PRELOAD=/lib/x86_64-linux-gnu/libstdc++.so.6" >> $GITHUB_ENV - - shell: bash - if: runner.os == 'Linux' && matrix.config == 'matlab' - - # Windows is currently not working. We get an error: "'matlab' executable not found on the system path" - # However, MATLAB is installed and the path is (seemingly) set correctly - - name: Get run-matlab-command - run: | - Invoke-WebRequest https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/win64/run-matlab-command.exe -OutFile C:\Windows\System32\run-matlab-command.exe - echo "MATLAB_COMMAND=C:\Windows\System32\run-matlab-command.exe" >> $env:GITHUB_ENV - shell: powershell - if: runner.os == 'Windows' && matrix.config == 'matlab' + - name: Setup Dependencies + uses: ./.github/actions/setup-matlab + if: inputs.use_matlab == 'true' # # Cache diff --git a/.github/actions/setup-matlab/action.yml b/.github/actions/setup-matlab/action.yml new file mode 100644 index 00000000000..fa9c7f1a28c --- /dev/null +++ b/.github/actions/setup-matlab/action.yml @@ -0,0 +1,51 @@ +name: Setup MATLAB +description: Setup MATLAB for use in GitHub Actions +runs: + using: "composite" + steps: + # + # MATLAB + # + - name: Setup MATLAB + id: setup-matlab + uses: matlab-actions/setup-matlab@v2 + with: + release: "R2024a" + + - name: Set MATLAB_HOME and MATLAB_VERSION + run: | + # Needed for MATLAB R2024a + sudo apt install -y libgtk2.0-0 + echo "MATLAB_VERSION=R2024a" >> $GITHUB_ENV + echo "MATLAB_HOME=${{ steps.setup-matlab.outputs.matlabroot }}" >> $GITHUB_ENV + shell: bash + if: runner.os == 'Linux' + + - name: Set MATLAB_HOME and MATLAB_VERSION + run: | + echo "MATLAB_VERSION=R2024a" >> $env:GITHUB_ENV + echo "MATLAB_HOME=${{ steps.setup-matlab.outputs.matlabroot }}" >> $env:GITHUB_ENV + shell: powershell + if: runner.os == 'Windows' + + # https://github.com/matlab-actions/run-command/issues/53 + - name: Get run-matlab-command + run: | + wget -O /usr/local/bin/run-matlab-command https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/glnxa64/run-matlab-command + chmod +x /usr/local/bin/run-matlab-command + echo "MATLAB_COMMAND=/usr/local/bin/run-matlab-command" >> $GITHUB_ENV + + # https://www.mathworks.com/matlabcentral/answers/1907290-how-to-manually-select-the-libstdc-library-to-use-to-resolve-a-version-glibcxx_-not-found + echo "LD_PRELOAD=/lib/x86_64-linux-gnu/libstdc++.so.6" >> $GITHUB_ENV + + shell: bash + if: runner.os == 'Linux' + + # Windows is currently not working. We get an error: "'matlab' executable not found on the system path" + # However, MATLAB is installed and the path is (seemingly) set correctly + - name: Get run-matlab-command + run: | + Invoke-WebRequest https://ssd.mathworks.com/supportfiles/ci/run-matlab-command/v2/win64/run-matlab-command.exe -OutFile C:\Windows\System32\run-matlab-command.exe + echo "MATLAB_COMMAND=C:\Windows\System32\run-matlab-command.exe" >> $env:GITHUB_ENV + shell: powershell + if: runner.os == 'Windows' && matrix.config == 'matlab' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7fcda668691..8f7813a68ad 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,6 +81,10 @@ jobs: - os: ubuntu-24.04 config: "cross" test_flags: "--all-cross" + - os: macos-15 + config: "cross" + # We want to test C++ and Swift only (in each direction) + test_flags: "--all-cross --filter cpp --filter swift" runs-on: ${{ matrix.os }} steps: @@ -89,6 +93,8 @@ jobs: - name: Setup Dependencies uses: ./.github/actions/setup-dependencies + with: + use_matlab: ${{ matrix.config == 'matlab' }} - name: Build ${{ matrix.config }} on ${{ matrix.os }} uses: ./.github/actions/build @@ -123,4 +129,5 @@ jobs: with: name: crash-diagnostics-${{ matrix.config }}-${{ matrix.os }} path: ~/Library/Logs/DiagnosticReports/*.ips + if-no-files-found: ignore if: runner.os == 'macOS' && always() diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index f6544f2458d..f26a5b2fd8d 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -23,8 +23,11 @@ jobs: - name: Install awscli run: brew install awscli || true + # Use --formula to silence homebrew warning when installing doxygen from a formula. - name: Install doxygen and graphviz (a dependency of Doxygen for generating diagrams) - run: brew install doxygen graphviz || true + run: | + brew install graphviz || true + brew install doxygen --formula || true - name: Install docfx for C# API reference run: brew install docfx diff --git a/.github/workflows/matlab_analyzer.yml b/.github/workflows/matlab_analyzer.yml new file mode 100644 index 00000000000..120a3d25107 --- /dev/null +++ b/.github/workflows/matlab_analyzer.yml @@ -0,0 +1,42 @@ +name: Matlab Analyzer + +on: + workflow_dispatch: + push: + branches: ["main"] + pull_request: + # The branches below must be a subset of the branches above + branches: ["main"] + +jobs: + matlab-analyzer: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Dependencies + uses: ./.github/actions/setup-dependencies + with: + use_matlab: true + + - name: Build MATLAB on Ubuntu + uses: ./.github/actions/build + timeout-minutes: 90 + with: + working_directory: "matlab" + build_cpp_and_python: true + + - name: MATLAB Analyzer + run: | + $MATLAB_COMMAND code_analyzer + working-directory: ./matlab/config + shell: bash + + - name: Upload Analyzer Report + uses: actions/upload-artifact@v4 + with: + name: matlab-analyzer-report + path: ./matlab/config/result.json + if-no-files-found: ignore + if: always() diff --git a/config/Make.project.rules b/config/Make.project.rules index 234a39c8fbb..d7a3ab8e0a8 100644 --- a/config/Make.project.rules +++ b/config/Make.project.rules @@ -665,7 +665,7 @@ $2_distclean:: # ifeq ($$($2_devinstall),yes) ifneq ($$(and $$($2_components),$(filter library,$3),$$(filter $(includedir)/%,$$($2_includedir))),) -$$(eval $$(call install-data-files,$$(wildcard $$($2_includedir)/*.h),$(includedir),$(install_includedir),$2_install)) +$$(eval $$(call install-data-files,$$(wildcard $$($2_includedir)/*.h) $$(wildcard $$($2_includedir)/**/*.h),$(includedir),$(install_includedir),$2_install)) ifneq ($$($2_generated_headers),) $$(eval $$(call install-data-files,$$($2_generated_headers),$(includedir)/generated,$(install_includedir),$2_install)) endif diff --git a/config/makeprops.py b/config/makeprops.py index a310214ddd4..a8d506a0abd 100755 --- a/config/makeprops.py +++ b/config/makeprops.py @@ -273,9 +273,9 @@ def openFiles(self): {{ const char* name; const bool prefixOnly; + const bool isOptIn; const Property* properties; const int length; - const bool isOptIn; }}; class PropertyNames @@ -330,9 +330,9 @@ def writePropertyArray(self, propertyArray): {{ .name="{name}", .prefixOnly={prefixOnly}, + .isOptIn={isOptIn}, .properties={name}PropsData, - .length={len(propertyArray.properties)}, - .isOptIn={isOptIn} + .length={len(propertyArray.properties)} }}; """) @@ -408,6 +408,7 @@ def fix(self, propertyName): def writePropertyArray(self, propertyArray): name = propertyArray.name prefixOnly = "true" if propertyArray.prefixOnly else "false" + isOptIn = "true" if propertyArray.isOptIn else "false" properties = ( "\n " + ",\n ".join(propertyArray.properties) if propertyArray.properties @@ -418,6 +419,7 @@ def writePropertyArray(self, propertyArray): f""" public static final PropertyArray {name}Props = new PropertyArray( "{name}", {prefixOnly}, + {isOptIn}, new Property[] {{{properties} }}); @@ -505,6 +507,7 @@ def fix(self, propertyName): def writePropertyArray(self, propertyArray): name = propertyArray.name prefixOnly = "true" if propertyArray.prefixOnly else "false" + isOptIn = "true" if propertyArray.isOptIn else "false" properties = ( f"\n {",\n ".join(propertyArray.properties)}\n " if propertyArray.properties @@ -515,6 +518,7 @@ def writePropertyArray(self, propertyArray): internal static PropertyArray {name}Props = new( "{name}", {prefixOnly}, + {isOptIn}, [{properties}]); """) @@ -583,6 +587,7 @@ def fix(self, propertyName): def writePropertyArray(self, propertyArray): name = propertyArray.name prefixOnly = "true" if propertyArray.prefixOnly else "false" + isOptIn = "true" if propertyArray.isOptIn else "false" properties = ( "\n " + ",\n ".join(propertyArray.properties) if propertyArray.properties @@ -591,7 +596,7 @@ def writePropertyArray(self, propertyArray): # We assign the properties to the property array after creating it so that we can reference the array # in the properties themselves self.srcFile.write(f"""\ -PropertyNames.{name}Props = new PropertyArray("{name}", {prefixOnly}); +PropertyNames.{name}Props = new PropertyArray("{name}", {prefixOnly}, {isOptIn}); PropertyNames.{name}Props.properties = [{properties} ]; diff --git a/cpp/include/DataStorm/DataStorm.h b/cpp/include/DataStorm/DataStorm.h index 7132242d108..640f68493c5 100644 --- a/cpp/include/DataStorm/DataStorm.h +++ b/cpp/include/DataStorm/DataStorm.h @@ -24,7 +24,6 @@ namespace DataStorm { - /** * A sample provides information about a data element update. * @@ -510,7 +509,7 @@ namespace DataStorm * @param node The node. * @param name The name of the topic. */ - Topic(const Node& node, const std::string& name) noexcept; + Topic(const Node& node, std::string name) noexcept; /** * Construct a new Topic by taking ownership of the given topic. @@ -618,7 +617,7 @@ namespace DataStorm */ template void setKeyFilter( - const std::string& name, + std::string name, std::function(const Criteria&)> factory) noexcept; /** @@ -630,7 +629,7 @@ namespace DataStorm */ template void setSampleFilter( - const std::string& name, + std::string name, std::function(const Criteria&)> factory) noexcept; private: @@ -673,8 +672,8 @@ namespace DataStorm * @param criteria The criteria */ template - Filter(const std::string& name, TT&& criteria) noexcept : name(name), - criteria(std::forward(criteria)) + Filter(std::string name, TT&& criteria) noexcept : name(std::move(name)), + criteria(std::forward(criteria)) { } @@ -706,7 +705,7 @@ namespace DataStorm SingleKeyReader( const Topic& topic, const Key& key, - const std::string& name = std::string(), + std::string name = std::string(), const ReaderConfig& config = ReaderConfig()); /** @@ -725,7 +724,7 @@ namespace DataStorm const Topic& topic, const Key& key, const Filter& sampleFilter, - const std::string& name = std::string(), + std::string name = std::string(), const ReaderConfig& config = ReaderConfig()); /** @@ -765,7 +764,7 @@ namespace DataStorm MultiKeyReader( const Topic& topic, const std::vector& keys, - const std::string& name = std::string(), + std::string name = std::string(), const ReaderConfig& config = ReaderConfig()); /** @@ -785,7 +784,7 @@ namespace DataStorm const Topic& topic, const std::vector& keys, const Filter& sampleFilter, - const std::string& name = std::string(), + std::string name = std::string(), const ReaderConfig& config = ReaderConfig()); /** @@ -816,10 +815,10 @@ namespace DataStorm SingleKeyReader makeSingleKeyReader( const Topic& topic, const typename Topic::KeyType& key, - const std::string& name = std::string(), + std::string name = std::string(), const ReaderConfig& config = ReaderConfig()) { - return SingleKeyReader(topic, key, name, config); + return SingleKeyReader(topic, key, std::move(name), config); } /** @@ -837,10 +836,10 @@ namespace DataStorm const Topic& topic, const typename Topic::KeyType& key, const Filter& sampleFilter, - const std::string& name = std::string(), + std::string name = std::string(), const ReaderConfig& config = ReaderConfig()) { - return SingleKeyReader(topic, key, sampleFilter, name, config); + return SingleKeyReader(topic, key, sampleFilter, std::move(name), config); } /** @@ -858,10 +857,10 @@ namespace DataStorm MultiKeyReader makeMultiKeyReader( const Topic& topic, const std::vector::KeyType>& keys, - const std::string& name = std::string(), + std::string name = std::string(), const ReaderConfig& config = ReaderConfig()) { - return MultiKeyReader(topic, keys, name, config); + return MultiKeyReader(topic, keys, std::move(name), config); } /** @@ -881,10 +880,10 @@ namespace DataStorm const Topic& topic, const std::vector::KeyType>& keys, const Filter& sampleFilter, - const std::string& name = std::string(), + std::string name = std::string(), const ReaderConfig& config = ReaderConfig()) { - return MultiKeyReader(topic, keys, sampleFilter, name, config); + return MultiKeyReader(topic, keys, sampleFilter, std::move(name), config); } /** @@ -900,10 +899,10 @@ namespace DataStorm template MultiKeyReader makeAnyKeyReader( const Topic& topic, - const std::string& name = std::string(), + std::string name = std::string(), const ReaderConfig& config = ReaderConfig()) { - return MultiKeyReader(topic, {}, name, config); + return MultiKeyReader(topic, {}, std::move(name), config); } /** @@ -921,10 +920,10 @@ namespace DataStorm MultiKeyReader makeAnyKeyReader( const Topic& topic, const Filter& sampleFilter, - const std::string& name = std::string(), + std::string name = std::string(), const ReaderConfig& config = ReaderConfig()) { - return MultiKeyReader(topic, {}, sampleFilter, name, config); + return MultiKeyReader(topic, {}, sampleFilter, std::move(name), config); } /** @@ -952,7 +951,7 @@ namespace DataStorm FilteredKeyReader( const Topic& topic, const Filter& keyFilter, - const std::string& name = std::string(), + std::string name = std::string(), const ReaderConfig& config = ReaderConfig()); /** @@ -973,7 +972,7 @@ namespace DataStorm const Topic& topic, const Filter& keyFilter, const Filter& sampleFilter, - const std::string& name = std::string(), + std::string name = std::string(), const ReaderConfig& config = ReaderConfig()); /** @@ -1004,10 +1003,10 @@ namespace DataStorm FilteredKeyReader makeFilteredKeyReader( const Topic& topic, const Filter& filter, - const std::string& name = std::string(), + std::string name = std::string(), const ReaderConfig& config = ReaderConfig()) { - return FilteredKeyReader(topic, filter, name, config); + return FilteredKeyReader(topic, filter, std::move(name), config); } /** @@ -1025,10 +1024,10 @@ namespace DataStorm const Topic& topic, const Filter& keyFilter, const Filter& sampleFilter, - const std::string& name = std::string(), + std::string name = std::string(), const ReaderConfig& config = ReaderConfig()) { - return FilteredKeyReader(topic, keyFilter, sampleFilter, name, config); + return FilteredKeyReader(topic, keyFilter, sampleFilter, std::move(name), config); } /** @@ -1052,7 +1051,7 @@ namespace DataStorm SingleKeyWriter( const Topic& topic, const Key& key, - const std::string& name = std::string(), + std::string name = std::string(), const WriterConfig& config = WriterConfig()) noexcept; /** @@ -1128,7 +1127,7 @@ namespace DataStorm MultiKeyWriter( const Topic& topic, const std::vector& keys, - const std::string& name = std::string(), + std::string name = std::string(), const WriterConfig& config = WriterConfig()) noexcept; /** @@ -1198,10 +1197,10 @@ namespace DataStorm SingleKeyWriter makeSingleKeyWriter( const Topic& topic, const typename Topic::KeyType& key, - const std::string& name = std::string(), + std::string name = std::string(), const WriterConfig& config = WriterConfig()) noexcept { - return SingleKeyWriter(topic, key, name, config); + return SingleKeyWriter(topic, key, std::move(name), config); } /** @@ -1217,10 +1216,10 @@ namespace DataStorm MultiKeyWriter makeMultiKeyWriter( const Topic& topic, const std::vector::KeyType>& keys, - const std::string& name = std::string(), + std::string name = std::string(), const WriterConfig& config = WriterConfig()) noexcept { - return MultiKeyWriter(topic, keys, name, config); + return MultiKeyWriter(topic, keys, std::move(name), config); } /** @@ -1234,10 +1233,10 @@ namespace DataStorm template MultiKeyWriter makeAnyKeyWriter( const Topic& topic, - const std::string& name = std::string(), + std::string name = std::string(), const WriterConfig& config = WriterConfig()) noexcept { - return MultiKeyWriter(topic, {}, name, config); + return MultiKeyWriter(topic, {}, std::move(name), config); } } @@ -1451,9 +1450,10 @@ namespace DataStorm SingleKeyReader::SingleKeyReader( const Topic& topic, const Key& key, - const std::string& name, + std::string name, const ReaderConfig& config) - : Reader(topic.getReader()->create({topic._keyFactory->create(key)}, name, config)) + : Reader( + topic.getReader()->create({topic._keyFactory->create(key)}, std::move(name), config)) { } @@ -1463,11 +1463,11 @@ namespace DataStorm const Topic& topic, const Key& key, const Filter& sampleFilter, - const std::string& name, + std::string name, const ReaderConfig& config) : Reader(topic.getReader()->create( {topic._keyFactory->create(key)}, - name, + std::move(name), config, sampleFilter.name, DataStormI::EncoderT::encode(topic.getCommunicator(), sampleFilter.criteria))) @@ -1492,9 +1492,10 @@ namespace DataStorm MultiKeyReader::MultiKeyReader( const Topic& topic, const std::vector& keys, - const std::string& name, + std::string name, const ReaderConfig& config) - : Reader(topic.getReader()->create(topic._keyFactory->create(keys), name, config)) + : Reader( + topic.getReader()->create(topic._keyFactory->create(keys), std::move(name), config)) { } @@ -1504,11 +1505,11 @@ namespace DataStorm const Topic& topic, const std::vector& keys, const Filter& sampleFilter, - const std::string& name, + std::string name, const ReaderConfig& config) : Reader(topic.getReader()->create( topic._keyFactory->create(keys), - name, + std::move(name), config, sampleFilter.name, Encoder::encode(topic.getCommunicator(), sampleFilter.criteria))) @@ -1534,11 +1535,11 @@ namespace DataStorm FilteredKeyReader::FilteredKeyReader( const Topic& topic, const Filter& filter, - const std::string& name, + std::string name, const ReaderConfig& config) : Reader(topic.getReader()->createFiltered( topic._keyFilterFactories->create(filter.name, filter.criteria), - name, + std::move(name), config)) { } @@ -1549,11 +1550,11 @@ namespace DataStorm const Topic& topic, const Filter& keyFilter, const Filter& sampleFilter, - const std::string& name, + std::string name, const ReaderConfig& config) : Reader(topic.getReader()->createFiltered( topic._keyFilterFactories->create(keyFilter.name, keyFilter.criteria), - name, + std::move(name), config, sampleFilter.name, Encoder::encode(topic.getCommunicator(), sampleFilter.criteria))) @@ -1696,9 +1697,10 @@ namespace DataStorm SingleKeyWriter::SingleKeyWriter( const Topic& topic, const Key& key, - const std::string& name, + std::string name, const WriterConfig& config) noexcept - : Writer(topic.getWriter()->create({topic._keyFactory->create(key)}, name, config)), + : Writer( + topic.getWriter()->create({topic._keyFactory->create(key)}, std::move(name), config)), _tagFactory(topic._tagFactory) { } @@ -1760,9 +1762,10 @@ namespace DataStorm MultiKeyWriter::MultiKeyWriter( const Topic& topic, const std::vector& keys, - const std::string& name, + std::string name, const WriterConfig& config) noexcept - : Writer(topic.getWriter()->create(topic._keyFactory->create(keys), name, config)), + : Writer( + topic.getWriter()->create(topic._keyFactory->create(keys), std::move(name), config)), _keyFactory(topic._keyFactory), _tagFactory(topic._tagFactory) { @@ -1829,6 +1832,7 @@ namespace DataStorm template std::function(const std::string&)> makeRegexFilter() noexcept { + // std::regex's constructor accepts a const string&; it does not accept a string_view. return [](const std::string& criteria) { std::regex expr(criteria); @@ -1873,8 +1877,8 @@ namespace DataStorm // Topic template implementation // template - Topic::Topic(const Node& node, const std::string& name) noexcept - : _name(name), + Topic::Topic(const Node& node, std::string name) noexcept + : _name(std::move(name)), _topicFactory(node._factory), _keyFactory(DataStormI::KeyFactoryT::createFactory()), _tagFactory(DataStormI::TagFactoryT::createFactory()), @@ -2017,21 +2021,21 @@ namespace DataStorm template template void Topic::setKeyFilter( - const std::string& name, + std::string name, std::function(const Criteria&)> factory) noexcept { std::lock_guard lock(_mutex); - _keyFilterFactories->set(name, factory); + _keyFilterFactories->set(std::move(name), factory); } template template void Topic::setSampleFilter( - const std::string& name, + std::string name, std::function&)>(const Criteria&)> factory) noexcept { std::lock_guard lock(_mutex); - _sampleFilterFactories->set(name, factory); + _sampleFilterFactories->set(std::move(name), factory); } template @@ -2078,7 +2082,6 @@ namespace DataStorm { return _topicFactory->getCommunicator(); } - } #if defined(__clang__) diff --git a/cpp/include/DataStorm/InternalI.h b/cpp/include/DataStorm/InternalI.h index c2d6a64a491..f67cf339bad 100644 --- a/cpp/include/DataStorm/InternalI.h +++ b/cpp/include/DataStorm/InternalI.h @@ -43,7 +43,7 @@ namespace DataStormI virtual std::int64_t getId() const = 0; }; - class Key : public Filterable, virtual public Element + class Key : public Filterable, public virtual Element { }; @@ -55,7 +55,7 @@ namespace DataStormI virtual std::shared_ptr decode(const Ice::CommunicatorPtr&, const Ice::ByteSeq&) = 0; }; - class Tag : virtual public Element + class Tag : public virtual Element { }; @@ -71,16 +71,16 @@ namespace DataStormI { public: Sample( - const std::string& session, - const std::string& origin, + std::string session, + std::string origin, std::int64_t id, DataStorm::SampleEvent event, const std::shared_ptr& key, const std::shared_ptr& tag, Ice::ByteSeq value, std::int64_t timestamp) - : session(session), - origin(origin), + : session(std::move(session)), + origin(std::move(origin)), id(id), event(event), key(key), @@ -119,8 +119,8 @@ namespace DataStormI virtual ~SampleFactory() = default; virtual std::shared_ptr create( - const std::string&, - const std::string&, + std::string, + std::string, std::int64_t, DataStorm::SampleEvent, const std::shared_ptr&, @@ -129,7 +129,7 @@ namespace DataStormI std::int64_t) = 0; }; - class Filter : virtual public Element + class Filter : public virtual Element { public: virtual bool match(const std::shared_ptr&) const = 0; @@ -176,7 +176,7 @@ namespace DataStormI virtual Ice::CommunicatorPtr getCommunicator() const = 0; }; - class DataReader : virtual public DataElement + class DataReader : public virtual DataElement { public: virtual bool hasWriters() = 0; @@ -193,7 +193,7 @@ namespace DataStormI std::function&)>) = 0; }; - class DataWriter : virtual public DataElement + class DataWriter : public virtual DataElement { public: virtual bool hasReaders() const = 0; @@ -222,21 +222,21 @@ namespace DataStormI virtual void destroy() = 0; }; - class TopicReader : virtual public Topic + class TopicReader : public virtual Topic { public: virtual std::shared_ptr createFiltered( const std::shared_ptr&, - const std::string&, + std::string, DataStorm::ReaderConfig, - const std::string& = std::string(), + std::string = std::string(), Ice::ByteSeq = {}) = 0; virtual std::shared_ptr create( const std::vector>&, - const std::string&, + std::string, DataStorm::ReaderConfig, - const std::string& = std::string(), + std::string = std::string(), Ice::ByteSeq = {}) = 0; virtual void setDefaultConfig(DataStorm::ReaderConfig) = 0; @@ -244,11 +244,11 @@ namespace DataStormI virtual void waitForWriters(int) const = 0; }; - class TopicWriter : virtual public Topic + class TopicWriter : public virtual Topic { public: virtual std::shared_ptr - create(const std::vector>&, const std::string&, DataStorm::WriterConfig) = 0; + create(const std::vector>&, std::string, DataStorm::WriterConfig) = 0; virtual void setDefaultConfig(DataStorm::WriterConfig) = 0; virtual bool hasReaders() const = 0; @@ -261,20 +261,20 @@ namespace DataStormI virtual ~TopicFactory() = default; virtual std::shared_ptr createTopicReader( - const std::string&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&) = 0; + std::string, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr) = 0; virtual std::shared_ptr createTopicWriter( - const std::string&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&) = 0; + std::string, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr) = 0; virtual Ice::CommunicatorPtr getCommunicator() const = 0; }; diff --git a/cpp/include/DataStorm/InternalT.h b/cpp/include/DataStorm/InternalT.h index 9e4ce29e7a7..aefc4088b1f 100644 --- a/cpp/include/DataStorm/InternalT.h +++ b/cpp/include/DataStorm/InternalT.h @@ -106,24 +106,24 @@ namespace DataStormI } }; - template class AbstractElementT : virtual public Element + template class AbstractElementT : public virtual Element { public: template AbstractElementT(TT&& v, std::int64_t id) : _value(std::forward(v)), _id(id) {} - virtual std::string toString() const override + std::string toString() const override { std::ostringstream os; os << _id << ':' << Stringifier::toString(_value); return os.str(); } - virtual Ice::ByteSeq encode(const Ice::CommunicatorPtr& communicator) const override + Ice::ByteSeq encode(const Ice::CommunicatorPtr& communicator) const override { return EncoderT::encode(communicator, _value); } - virtual std::int64_t getId() const override { return _id; } + std::int64_t getId() const override { return _id; } const T& get() const { return _value; } @@ -242,26 +242,23 @@ namespace DataStormI std::int64_t _nextId; }; - template class KeyT : public Key, public AbstractElementT + template class KeyT final : public Key, public AbstractElementT { public: - virtual std::string toString() const override { return "k" + AbstractElementT::toString(); } + std::string toString() const final { return "k" + AbstractElementT::toString(); } using AbstractElementT::AbstractElementT; using BaseClassType = Key; }; - template class KeyFactoryT : public KeyFactory, public AbstractFactoryT> + template class KeyFactoryT final : public KeyFactory, public AbstractFactoryT> { public: using AbstractFactoryT>::AbstractFactoryT; - virtual std::shared_ptr get(std::int64_t id) const override - { - return AbstractFactoryT>::getImpl(id); - } + std::shared_ptr get(std::int64_t id) const final { return AbstractFactoryT>::getImpl(id); } - virtual std::shared_ptr decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& data) override + std::shared_ptr decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& data) final { return AbstractFactoryT>::create(DecoderT::decode(communicator, data)); } @@ -274,26 +271,23 @@ namespace DataStormI } }; - template class TagT : public Tag, public AbstractElementT + template class TagT final : public Tag, public AbstractElementT { public: - virtual std::string toString() const override { return "t" + AbstractElementT::toString(); } + std::string toString() const final { return "t" + AbstractElementT::toString(); } using AbstractElementT::AbstractElementT; using BaseClassType = Tag; }; - template class TagFactoryT : public TagFactory, public AbstractFactoryT> + template class TagFactoryT final : public TagFactory, public AbstractFactoryT> { public: using AbstractFactoryT>::AbstractFactoryT; - virtual std::shared_ptr get(std::int64_t id) const override - { - return AbstractFactoryT>::getImpl(id); - } + std::shared_ptr get(std::int64_t id) const final { return AbstractFactoryT>::getImpl(id); } - virtual std::shared_ptr decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& data) override + std::shared_ptr decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& data) final { return AbstractFactoryT>::create(DecoderT::decode(communicator, data)); } @@ -307,19 +301,19 @@ namespace DataStormI }; template - class SampleT : public Sample, public std::enable_shared_from_this> + class SampleT final : public Sample, public std::enable_shared_from_this> { public: SampleT( - const std::string& session, - const std::string& origin, + std::string session, + std::string origin, std::int64_t id, DataStorm::SampleEvent event, const std::shared_ptr& key, const std::shared_ptr& tag, Ice::ByteSeq value, std::int64_t timestamp) - : Sample(session, origin, id, event, key, tag, value, timestamp), + : Sample(std::move(session), std::move(origin), id, event, key, tag, value, timestamp), _hasValue(false) { } @@ -357,9 +351,9 @@ namespace DataStormI _hasValue = true; } - virtual bool hasValue() const override { return _hasValue; } + bool hasValue() const final { return _hasValue; } - virtual void setValue(const std::shared_ptr& sample) override + void setValue(const std::shared_ptr& sample) final { if (sample) { @@ -373,7 +367,7 @@ namespace DataStormI _hasValue = true; } - virtual const Ice::ByteSeq& encode(const Ice::CommunicatorPtr& communicator) override + const Ice::ByteSeq& encode(const Ice::CommunicatorPtr& communicator) final { if (_encodedValue.empty()) { @@ -382,13 +376,13 @@ namespace DataStormI return _encodedValue; } - virtual Ice::ByteSeq encodeValue(const Ice::CommunicatorPtr& communicator) override + Ice::ByteSeq encodeValue(const Ice::CommunicatorPtr& communicator) final { assert(_hasValue || event == DataStorm::SampleEvent::Remove); return EncoderT::encode(communicator, _value); } - virtual void decode(const Ice::CommunicatorPtr& communicator) override + void decode(const Ice::CommunicatorPtr& communicator) final { if (!_encodedValue.empty()) { @@ -403,25 +397,32 @@ namespace DataStormI Value _value; }; - template class SampleFactoryT : public SampleFactory + template class SampleFactoryT final : public SampleFactory { public: - virtual std::shared_ptr create( - const std::string& session, - const std::string& origin, + std::shared_ptr create( + std::string session, + std::string origin, std::int64_t id, DataStorm::SampleEvent type, const std::shared_ptr& key, const std::shared_ptr& tag, Ice::ByteSeq value, - std::int64_t timestamp) - { - return std::make_shared< - SampleT>(session, origin, id, type, key, tag, std::move(value), timestamp); + std::int64_t timestamp) final + { + return std::make_shared>( + std::move(session), + std::move(origin), + id, + type, + key, + tag, + std::move(value), + timestamp); } }; - template class FilterT : public Filter, public AbstractElementT + template class FilterT final : public Filter, public AbstractElementT { public: template @@ -429,14 +430,14 @@ namespace DataStormI { } - virtual std::string toString() const override { return "f" + AbstractElementT::toString(); } + std::string toString() const final { return "f" + AbstractElementT::toString(); } - virtual bool match(const std::shared_ptr& value) const override + bool match(const std::shared_ptr& value) const final { return _lambda(std::static_pointer_cast(value)->get()); } - virtual const std::string& getName() const override { return _name; } + const std::string& getName() const final { return _name; } template void init(const std::string& name, FF&& lambda) { @@ -452,18 +453,17 @@ namespace DataStormI }; template - class FilterFactoryT : public FilterFactory, public AbstractFactoryT> + class FilterFactoryT final : public FilterFactory, public AbstractFactoryT> { public: FilterFactoryT() {} - virtual std::shared_ptr get(std::int64_t id) const override + std::shared_ptr get(std::int64_t id) const final { return AbstractFactoryT>::getImpl(id); } - virtual std::shared_ptr - decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& data) override + std::shared_ptr decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& data) final { return AbstractFactoryT>::create(DecoderT::decode(communicator, data)); } @@ -476,7 +476,7 @@ namespace DataStormI } }; - template class FilterManagerT : public FilterManager + template class FilterManagerT final : public FilterManager { using Value = typename std::remove_reference().get())>::type; @@ -489,10 +489,10 @@ namespace DataStormI virtual std::shared_ptr decode(const Ice::CommunicatorPtr&, const Ice::ByteSeq&) = 0; }; - template struct FactoryT : Factory + template struct FactoryT final : Factory { - FactoryT(const std::string& name, std::function(const Criteria&)> lambda) - : name(name), + FactoryT(std::string name, std::function(const Criteria&)> lambda) + : name(std::move(name)), lambda(std::move(lambda)) { } @@ -504,9 +504,9 @@ namespace DataStormI return filter; } - virtual std::shared_ptr get(std::int64_t id) const { return filterFactory.get(id); } + std::shared_ptr get(std::int64_t id) const final { return filterFactory.get(id); } - virtual std::shared_ptr decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& data) + std::shared_ptr decode(const Ice::CommunicatorPtr& communicator, const Ice::ByteSeq& data) final { return create(DecoderT::decode(communicator, data)); } @@ -536,8 +536,8 @@ namespace DataStormI return factory->create(criteria); } - virtual std::shared_ptr - decode(const Ice::CommunicatorPtr& communicator, const std::string& name, const Ice::ByteSeq& data) override + std::shared_ptr + decode(const Ice::CommunicatorPtr& communicator, const std::string& name, const Ice::ByteSeq& data) final { auto p = _factories.find(name); if (p == _factories.end()) @@ -548,7 +548,7 @@ namespace DataStormI return p->second->decode(communicator, data); } - virtual std::shared_ptr get(const std::string& name, std::int64_t id) const override + std::shared_ptr get(const std::string& name, std::int64_t id) const final { auto p = _factories.find(name); if (p == _factories.end()) @@ -560,11 +560,12 @@ namespace DataStormI } template - void set(const std::string& name, std::function(const Criteria&)> lambda) + void set(std::string name, std::function(const Criteria&)> lambda) { if (lambda) { - _factories[name] = std::unique_ptr(new FactoryT(name, std::move(lambda))); + auto factory = std::make_unique>(name, std::move(lambda)); + _factories.emplace(std::move(name), std::move(factory)); } else { diff --git a/cpp/include/DataStorm/Node.h b/cpp/include/DataStorm/Node.h index 7ab53d6254f..bdb7cfe5f40 100644 --- a/cpp/include/DataStorm/Node.h +++ b/cpp/include/DataStorm/Node.h @@ -19,10 +19,10 @@ namespace DataStorm * * @headerfile DataStorm/DataStorm.h */ - class DATASTORM_API NodeShutdownException : public std::exception + class DATASTORM_API NodeShutdownException final : public std::exception { public: - virtual const char* what() const noexcept; + const char* what() const noexcept final; }; /** @@ -193,7 +193,7 @@ namespace DataStorm * @return The connection associated with the given session * @see DataStorm::Sample::ElementId DataStorm::Sample::getSession */ - Ice::ConnectionPtr getSessionConnection(const std::string& ident) const noexcept; + Ice::ConnectionPtr getSessionConnection(std::string_view ident) const noexcept; private: Node( diff --git a/cpp/include/Ice/InputStream.h b/cpp/include/Ice/InputStream.h index bcf7fb3d9f1..c6633b08b2e 100644 --- a/cpp/include/Ice/InputStream.h +++ b/cpp/include/Ice/InputStream.h @@ -410,7 +410,7 @@ namespace Ice std::string startSlice() { assert(_currentEncaps && _currentEncaps->decoder); - return std::string{_currentEncaps->decoder->startSlice()}; + return _currentEncaps->decoder->startSlice(); } /** @@ -972,7 +972,7 @@ namespace Ice virtual void startInstance(SliceType) = 0; virtual SlicedDataPtr endInstance() = 0; - virtual std::string_view startSlice() = 0; + virtual const std::string& startSlice() = 0; virtual void endSlice() = 0; virtual void skipSlice() = 0; @@ -1048,7 +1048,7 @@ namespace Ice virtual void startInstance(SliceType); virtual SlicedDataPtr endInstance(); - virtual std::string_view startSlice(); + virtual const std::string& startSlice(); virtual void endSlice(); virtual void skipSlice(); @@ -1086,7 +1086,7 @@ namespace Ice virtual void startInstance(SliceType); virtual SlicedDataPtr endInstance(); - virtual std::string_view startSlice(); + virtual const std::string& startSlice(); virtual void endSlice(); virtual void skipSlice(); diff --git a/cpp/include/Ice/Logger.h b/cpp/include/Ice/Logger.h index 4f3477e803c..90e1b0338ed 100644 --- a/cpp/include/Ice/Logger.h +++ b/cpp/include/Ice/Logger.h @@ -22,6 +22,10 @@ namespace Ice public: virtual ~Logger() = default; + // We use const std::string& and not std::string_view for the log messages because implementations commonly + // send the message to C APIs that require null-terminated strings. + // The message itself is also often constructed from a string produced by an ostringstream. + /** * Print a message. The message is printed literally, without any decorations such as executable name or time * stamp. @@ -61,7 +65,7 @@ namespace Ice * @param prefix The new prefix for the logger. * @return A logger instance. */ - virtual LoggerPtr cloneWithPrefix(const std::string& prefix) = 0; + virtual LoggerPtr cloneWithPrefix(std::string prefix) = 0; }; } diff --git a/cpp/include/Ice/StringConverter.h b/cpp/include/Ice/StringConverter.h index 590d4841a86..13efea0604d 100644 --- a/cpp/include/Ice/StringConverter.h +++ b/cpp/include/Ice/StringConverter.h @@ -148,7 +148,7 @@ namespace Ice * @param nc The narrow string converter. If null, the UTF-8 string is returned. * @return A native narrow string. */ - ICE_API std::string UTF8ToNative(const std::string& str, const StringConverterPtr& nc); + ICE_API std::string UTF8ToNative(std::string_view str, const StringConverterPtr& nc); #ifdef _WIN32 diff --git a/cpp/include/IceBox/Service.h b/cpp/include/IceBox/Service.h index fc0a61e61a4..a312589a08c 100644 --- a/cpp/include/IceBox/Service.h +++ b/cpp/include/IceBox/Service.h @@ -1,6 +1,4 @@ -// -// Copyright (c) ZeroC, Inc. All rights reserved. -// +// Copyright (c) ZeroC, Inc. #ifndef ICEBOX_SERVICE_H #define ICEBOX_SERVICE_H @@ -8,14 +6,6 @@ #include "Config.h" #include "Ice/Ice.h" -#if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wshadow-field-in-constructor" -#elif defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wshadow" -#endif - namespace IceBox { /** @@ -61,10 +51,4 @@ namespace IceBox using ServicePtr = std::shared_ptr; } -#if defined(__clang__) -# pragma clang diagnostic pop -#elif defined(__GNUC__) -# pragma GCC diagnostic pop -#endif - #endif diff --git a/cpp/src/DataStorm/CallbackExecutor.h b/cpp/src/DataStorm/CallbackExecutor.h index 99429e48312..ec166185cc1 100644 --- a/cpp/src/DataStorm/CallbackExecutor.h +++ b/cpp/src/DataStorm/CallbackExecutor.h @@ -16,7 +16,7 @@ namespace DataStormI { class DataElementI; - class CallbackExecutor + class CallbackExecutor final { public: CallbackExecutor(std::function call)> customExecutor); diff --git a/cpp/src/DataStorm/ConnectionManager.h b/cpp/src/DataStorm/ConnectionManager.h index 35a9fac0ee9..d4ddc6611f7 100644 --- a/cpp/src/DataStorm/ConnectionManager.h +++ b/cpp/src/DataStorm/ConnectionManager.h @@ -12,7 +12,7 @@ namespace DataStormI { class CallbackExecutor; - class ConnectionManager : public std::enable_shared_from_this + class ConnectionManager final : public std::enable_shared_from_this { public: ConnectionManager(const std::shared_ptr&); diff --git a/cpp/src/DataStorm/DataElementI.cpp b/cpp/src/DataStorm/DataElementI.cpp index 6c510ccc750..b84200dab23 100644 --- a/cpp/src/DataStorm/DataElementI.cpp +++ b/cpp/src/DataStorm/DataElementI.cpp @@ -45,9 +45,9 @@ namespace } } -DataElementI::DataElementI(TopicI* parent, const string& name, int64_t id, const DataStorm::Config& config) +DataElementI::DataElementI(TopicI* parent, string name, int64_t id, const DataStorm::Config& config) : _traceLevels(parent->getInstance()->getTraceLevels()), - _name(name), + _name(std::move(name)), _id(id), _config(make_shared()), _executor(parent->getInstance()->getCallbackExecutor()), @@ -63,9 +63,9 @@ DataElementI::DataElementI(TopicI* parent, const string& name, int64_t id, const { _config->sampleCount = config.sampleCount; _config->sampleLifetime = config.sampleLifetime; - if (!name.empty()) + if (!_name.empty()) { - _config->name = name; + _config->name = _name; } if (config.clearHistory) { @@ -643,18 +643,18 @@ DataElementI::forward(const Ice::ByteSeq& inParams, const Ice::Current& current) DataReaderI::DataReaderI( TopicReaderI* topic, - const string& name, + string name, int64_t id, - const string& sampleFilterName, + string sampleFilterName, Ice::ByteSeq sampleFilterCriteria, const DataStorm::ReaderConfig& config) - : DataElementI(topic, name, id, config), + : DataElementI(topic, std::move(name), id, config), _parent(topic), _discardPolicy(config.discardPolicy ? *config.discardPolicy : DataStorm::DiscardPolicy::None) { if (!sampleFilterName.empty()) { - _config->sampleFilter = FilterInfo{sampleFilterName, std::move(sampleFilterCriteria)}; + _config->sampleFilter = FilterInfo{std::move(sampleFilterName), std::move(sampleFilterCriteria)}; } } @@ -979,8 +979,8 @@ DataReaderI::addConnectedKey(const shared_ptr& key, const shared_ptr(_forwarder)} { @@ -1043,13 +1043,13 @@ DataWriterI::publish(const shared_ptr& key, const shared_ptr& sampl KeyDataReaderI::KeyDataReaderI( TopicReaderI* topic, - const string& name, + string name, int64_t id, const vector>& keys, - const string& sampleFilterName, + string sampleFilterName, const Ice::ByteSeq sampleFilterCriteria, const DataStorm::ReaderConfig& config) - : DataReaderI(topic, name, id, sampleFilterName, sampleFilterCriteria, config), + : DataReaderI(topic, std::move(name), id, std::move(sampleFilterName), sampleFilterCriteria, config), _keys(keys) { if (_traceLevels->data > 0) @@ -1131,11 +1131,11 @@ KeyDataReaderI::matchKey(const shared_ptr& key) const KeyDataWriterI::KeyDataWriterI( TopicWriterI* topic, - const string& name, + string name, int64_t id, const vector>& keys, const DataStorm::WriterConfig& config) - : DataWriterI(topic, name, id, config), + : DataWriterI(topic, std::move(name), id, config), _keys(keys) { if (_traceLevels->data > 0) @@ -1325,13 +1325,13 @@ KeyDataWriterI::forward(const Ice::ByteSeq& inParams, const Ice::Current& curren FilteredDataReaderI::FilteredDataReaderI( TopicReaderI* topic, - const string& name, + string name, int64_t id, const shared_ptr& filter, - const string& sampleFilterName, + string sampleFilterName, Ice::ByteSeq sampleFilterCriteria, const DataStorm::ReaderConfig& config) - : DataReaderI(topic, name, id, sampleFilterName, sampleFilterCriteria, config), + : DataReaderI(topic, std::move(name), id, std::move(sampleFilterName), std::move(sampleFilterCriteria), config), _filter(filter) { if (_traceLevels->data > 0) diff --git a/cpp/src/DataStorm/DataElementI.h b/cpp/src/DataStorm/DataElementI.h index 0ecab7e09b5..bd55f90baf6 100644 --- a/cpp/src/DataStorm/DataElementI.h +++ b/cpp/src/DataStorm/DataElementI.h @@ -25,7 +25,8 @@ namespace DataStormI class CallbackExecutor; class TraceLevels; - class DataElementI : virtual public DataElement, public std::enable_shared_from_this + // Base class for DataReaderI and DataWriterI. + class DataElementI : public virtual DataElement, public std::enable_shared_from_this { protected: struct Subscriber @@ -34,12 +35,12 @@ namespace DataStormI std::int64_t id, const std::shared_ptr& filter, const std::shared_ptr& sampleFilter, - const std::string& name, + std::string name, int priority) : id(id), filter(filter), sampleFilter(sampleFilter), - name(name), + name(std::move(name)), priority(priority) { } @@ -133,10 +134,10 @@ namespace DataStormI }; public: - DataElementI(TopicI*, const std::string&, std::int64_t, const DataStorm::Config&); - virtual ~DataElementI(); + DataElementI(TopicI*, std::string, std::int64_t, const DataStorm::Config&); + ~DataElementI() override; - virtual void destroy() override; + void destroy() override; void attach( std::int64_t, @@ -201,12 +202,14 @@ namespace DataStormI const std::string&, bool); - virtual std::vector> getConnectedKeys() const override; - virtual std::vector getConnectedElements() const override; - virtual void onConnectedKeys( + std::vector> getConnectedKeys() const override; + std::vector getConnectedElements() const override; + + void onConnectedKeys( std::function>)>, std::function)>) override; - virtual void onConnectedElements( + + void onConnectedElements( std::function)>, std::function) override; @@ -217,6 +220,7 @@ namespace DataStormI int, const std::chrono::time_point&, bool); + virtual DataStormContract::DataSamples getSamples( const std::shared_ptr&, const std::shared_ptr&, @@ -233,7 +237,8 @@ namespace DataStormI bool); virtual std::string toString() const = 0; - virtual Ice::CommunicatorPtr getCommunicator() const override; + + Ice::CommunicatorPtr getCommunicator() const override; std::int64_t getId() const { return _id; } @@ -281,27 +286,28 @@ namespace DataStormI public: DataReaderI( TopicReaderI*, - const std::string&, + std::string, std::int64_t, - const std::string&, + std::string, Ice::ByteSeq, const DataStorm::ReaderConfig&); - virtual int getInstanceCount() const override; + int getInstanceCount() const override; - virtual std::vector> getAllUnread() override; - virtual void waitForUnread(unsigned int) const override; - virtual bool hasUnread() const override; - virtual std::shared_ptr getNextUnread() override; + std::vector> getAllUnread() override; + void waitForUnread(unsigned int) const override; + bool hasUnread() const override; + std::shared_ptr getNextUnread() override; - virtual void initSamples( + void initSamples( const std::vector>&, std::int64_t, std::int64_t, int, const std::chrono::time_point&, bool) override; - virtual void queue( + + void queue( const std::shared_ptr&, int, const std::shared_ptr&, @@ -309,13 +315,13 @@ namespace DataStormI const std::chrono::time_point&, bool) override; - virtual void onSamples( + void onSamples( std::function>&)>, std::function&)>) override; protected: virtual bool matchKey(const std::shared_ptr&) const = 0; - virtual bool addConnectedKey(const std::shared_ptr&, const std::shared_ptr&) override; + bool addConnectedKey(const std::shared_ptr&, const std::shared_ptr&) override; TopicReaderI* _parent; @@ -330,9 +336,9 @@ namespace DataStormI class DataWriterI : public DataElementI, public DataWriter { public: - DataWriterI(TopicWriterI*, const std::string&, std::int64_t, const DataStorm::WriterConfig&); + DataWriterI(TopicWriterI*, std::string, std::int64_t, const DataStorm::WriterConfig&); - virtual void publish(const std::shared_ptr&, const std::shared_ptr&) override; + void publish(const std::shared_ptr&, const std::shared_ptr&) override; protected: virtual void send(const std::shared_ptr&, const std::shared_ptr&) const = 0; @@ -343,85 +349,86 @@ namespace DataStormI std::shared_ptr _last; }; - class KeyDataReaderI : public DataReaderI + class KeyDataReaderI final : public DataReaderI { public: KeyDataReaderI( TopicReaderI*, - const std::string&, + std::string, std::int64_t, const std::vector>&, - const std::string&, + std::string, Ice::ByteSeq, const DataStorm::ReaderConfig&); - virtual void destroyImpl() override; + void destroyImpl() final; - virtual void waitForWriters(int) override; - virtual bool hasWriters() override; + void waitForWriters(int) final; + bool hasWriters() final; - virtual std::string toString() const override; + std::string toString() const final; private: - virtual bool matchKey(const std::shared_ptr&) const override; + bool matchKey(const std::shared_ptr&) const final; const std::vector> _keys; }; - class KeyDataWriterI : public DataWriterI + class KeyDataWriterI final : public DataWriterI { public: KeyDataWriterI( TopicWriterI*, - const std::string&, + std::string, std::int64_t, const std::vector>&, const DataStorm::WriterConfig&); - virtual void destroyImpl() override; + void destroyImpl() final; - virtual void waitForReaders(int) const override; - virtual bool hasReaders() const override; + void waitForReaders(int) const final; + bool hasReaders() const final; - virtual std::shared_ptr getLast() const override; - virtual std::vector> getAll() const override; + std::shared_ptr getLast() const final; + std::vector> getAll() const final; - virtual std::string toString() const override; - virtual DataStormContract::DataSamples getSamples( + std::string toString() const final; + + DataStormContract::DataSamples getSamples( const std::shared_ptr&, const std::shared_ptr&, const std::shared_ptr&, std::int64_t, - const std::chrono::time_point&) override; + const std::chrono::time_point&) final; private: - virtual void send(const std::shared_ptr&, const std::shared_ptr&) const override; - virtual void forward(const Ice::ByteSeq&, const Ice::Current&) const override; + void send(const std::shared_ptr&, const std::shared_ptr&) const final; + void forward(const Ice::ByteSeq&, const Ice::Current&) const final; const std::vector> _keys; }; - class FilteredDataReaderI : public DataReaderI + class FilteredDataReaderI final : public DataReaderI { public: FilteredDataReaderI( TopicReaderI*, - const std::string&, + std::string, std::int64_t, const std::shared_ptr&, - const std::string&, + std::string, Ice::ByteSeq, const DataStorm::ReaderConfig&); - virtual void destroyImpl() override; + void destroyImpl() final; - virtual void waitForWriters(int) override; - virtual bool hasWriters() override; + void waitForWriters(int) final; + bool hasWriters() final; - virtual std::string toString() const override; + std::string toString() const final; private: - virtual bool matchKey(const std::shared_ptr&) const override; + bool matchKey(const std::shared_ptr&) const final; const std::shared_ptr _filter; }; diff --git a/cpp/src/DataStorm/ForwarderManager.h b/cpp/src/DataStorm/ForwarderManager.h index fe4a6505869..455b1972baa 100644 --- a/cpp/src/DataStorm/ForwarderManager.h +++ b/cpp/src/DataStorm/ForwarderManager.h @@ -13,7 +13,7 @@ namespace DataStormI { - class ForwarderManager : public Ice::BlobjectAsync + class ForwarderManager final : public Ice::BlobjectAsync { public: using Response = std::function; @@ -57,11 +57,11 @@ namespace DataStormI void destroy(); private: - virtual void ice_invokeAsync( + void ice_invokeAsync( Ice::ByteSeq, std::function, std::function, - const Ice::Current&); + const Ice::Current&) final; const Ice::ObjectAdapterPtr _adapter; const std::string _category; diff --git a/cpp/src/DataStorm/Instance.h b/cpp/src/DataStorm/Instance.h index a44a2a22e8b..05e6fc17e62 100644 --- a/cpp/src/DataStorm/Instance.h +++ b/cpp/src/DataStorm/Instance.h @@ -22,7 +22,7 @@ namespace DataStormI class NodeI; class CallbackExecutor; - class Instance : public std::enable_shared_from_this + class Instance final : public std::enable_shared_from_this { public: Instance( diff --git a/cpp/src/DataStorm/Node.cpp b/cpp/src/DataStorm/Node.cpp index d3319d0291c..e6b54e2dfab 100644 --- a/cpp/src/DataStorm/Node.cpp +++ b/cpp/src/DataStorm/Node.cpp @@ -169,7 +169,7 @@ Node::getCommunicator() const noexcept } Ice::ConnectionPtr -Node::getSessionConnection(const string& ident) const noexcept +Node::getSessionConnection(string_view ident) const noexcept { return _instance ? _instance->getNode()->getSessionConnection(ident) : nullptr; } diff --git a/cpp/src/DataStorm/NodeI.cpp b/cpp/src/DataStorm/NodeI.cpp index 30162787319..326f310d132 100644 --- a/cpp/src/DataStorm/NodeI.cpp +++ b/cpp/src/DataStorm/NodeI.cpp @@ -388,7 +388,7 @@ NodeI::removePublisherSession(NodePrx node, const shared_ptr& } Ice::ConnectionPtr -NodeI::getSessionConnection(const string& id) const +NodeI::getSessionConnection(string_view id) const { auto session = getSession(Ice::stringToIdentity(id)); if (session) diff --git a/cpp/src/DataStorm/NodeI.h b/cpp/src/DataStorm/NodeI.h index 555de763017..394a37e4e65 100644 --- a/cpp/src/DataStorm/NodeI.h +++ b/cpp/src/DataStorm/NodeI.h @@ -20,11 +20,11 @@ namespace DataStormI class PublisherSessionI; class SubscriberSessionI; - class NodeI final : virtual public DataStormContract::Node, public std::enable_shared_from_this + class NodeI final : public virtual DataStormContract::Node, public std::enable_shared_from_this { public: NodeI(const std::shared_ptr&); - virtual ~NodeI(); + ~NodeI() final; void init(); void destroy(bool); @@ -62,7 +62,7 @@ namespace DataStormI const std::shared_ptr&, std::exception_ptr); - Ice::ConnectionPtr getSessionConnection(const std::string&) const; + Ice::ConnectionPtr getSessionConnection(std::string_view) const; std::shared_ptr getSession(const Ice::Identity&) const; diff --git a/cpp/src/DataStorm/NodeSessionI.h b/cpp/src/DataStorm/NodeSessionI.h index 3fce2ad98cd..f2a09e2df79 100644 --- a/cpp/src/DataStorm/NodeSessionI.h +++ b/cpp/src/DataStorm/NodeSessionI.h @@ -13,7 +13,7 @@ namespace DataStormI { class TraceLevels; - class NodeSessionI : public std::enable_shared_from_this + class NodeSessionI final : public std::enable_shared_from_this { public: NodeSessionI(std::shared_ptr, std::optional, Ice::ConnectionPtr, bool); diff --git a/cpp/src/DataStorm/NodeSessionManager.h b/cpp/src/DataStorm/NodeSessionManager.h index 1ff9cf0e216..9363138b49b 100644 --- a/cpp/src/DataStorm/NodeSessionManager.h +++ b/cpp/src/DataStorm/NodeSessionManager.h @@ -17,7 +17,7 @@ namespace DataStormI class TraceLevels; class NodeI; - class NodeSessionManager : public std::enable_shared_from_this + class NodeSessionManager final : public std::enable_shared_from_this { public: NodeSessionManager(const std::shared_ptr&, const std::shared_ptr&); diff --git a/cpp/src/DataStorm/SessionI.h b/cpp/src/DataStorm/SessionI.h index b7b0de1d8d3..e797ef51a11 100644 --- a/cpp/src/DataStorm/SessionI.h +++ b/cpp/src/DataStorm/SessionI.h @@ -24,7 +24,7 @@ namespace DataStormI class Instance; class TraceLevels; - class SessionI : virtual public DataStormContract::Session, public std::enable_shared_from_this + class SessionI : public virtual DataStormContract::Session, public std::enable_shared_from_this { protected: struct ElementSubscriber @@ -48,8 +48,8 @@ namespace DataStormI class ElementSubscribers { public: - ElementSubscribers(const std::string& name, int priority) - : name(name), + ElementSubscribers(std::string name, int priority) + : name(std::move(name)), priority(priority), _sessionInstanceId(0) { @@ -124,12 +124,12 @@ namespace DataStormI public: TopicSubscriber(int sessionInstanceId) : sessionInstanceId(sessionInstanceId) {} - ElementSubscribers* add(std::int64_t id, const std::string& name, int priority) + ElementSubscribers* add(std::int64_t id, std::string name, int priority) { auto p = _elements.find(id); if (p == _elements.end()) { - p = _elements.emplace(id, ElementSubscribers(name, priority)).first; + p = _elements.emplace(id, ElementSubscribers(std::move(name), priority)).first; } return &p->second; } @@ -353,12 +353,12 @@ namespace DataStormI public: SubscriberSessionI(const std::shared_ptr&, DataStormContract::NodePrx, DataStormContract::SessionPrx); - virtual void s(std::int64_t, std::int64_t, DataStormContract::DataSample, const Ice::Current&) final; + void s(std::int64_t, std::int64_t, DataStormContract::DataSample, const Ice::Current&) final; private: - virtual std::vector> getTopics(const std::string&) const final; - virtual void reconnect(DataStormContract::NodePrx) final; - virtual void remove() final; + std::vector> getTopics(const std::string&) const final; + void reconnect(DataStormContract::NodePrx) final; + void remove() final; }; class PublisherSessionI : public SessionI, public DataStormContract::PublisherSession diff --git a/cpp/src/DataStorm/TopicFactoryI.cpp b/cpp/src/DataStorm/TopicFactoryI.cpp index 19348d92990..d81432552c7 100644 --- a/cpp/src/DataStorm/TopicFactoryI.cpp +++ b/cpp/src/DataStorm/TopicFactoryI.cpp @@ -22,12 +22,12 @@ TopicFactoryI::TopicFactoryI(const shared_ptr& instance) shared_ptr TopicFactoryI::createTopicReader( - const string& name, - const shared_ptr& keyFactory, - const shared_ptr& tagFactory, - const shared_ptr& sampleFactory, - const shared_ptr& keyFilterFactories, - const shared_ptr& sampleFilterFactories) + string name, + shared_ptr keyFactory, + shared_ptr tagFactory, + shared_ptr sampleFactory, + shared_ptr keyFilterFactories, + shared_ptr sampleFilterFactories) { shared_ptr reader; bool hasWriters; @@ -35,12 +35,12 @@ TopicFactoryI::createTopicReader( lock_guard lock(_mutex); reader = make_shared( shared_from_this(), - keyFactory, - tagFactory, - sampleFactory, - keyFilterFactories, - sampleFilterFactories, - name, + std::move(keyFactory), + std::move(tagFactory), + std::move(sampleFactory), + std::move(keyFilterFactories), + std::move(sampleFilterFactories), + name, // we keep using name below _nextReaderId++); _readers[name].push_back(reader); if (_traceLevels->topic > 0) @@ -79,12 +79,12 @@ TopicFactoryI::createTopicReader( shared_ptr TopicFactoryI::createTopicWriter( - const string& name, - const shared_ptr& keyFactory, - const shared_ptr& tagFactory, - const shared_ptr& sampleFactory, - const shared_ptr& keyFilterFactories, - const shared_ptr& sampleFilterFactories) + string name, + shared_ptr keyFactory, + shared_ptr tagFactory, + shared_ptr sampleFactory, + shared_ptr keyFilterFactories, + shared_ptr sampleFilterFactories) { shared_ptr writer; bool hasReaders; @@ -92,12 +92,12 @@ TopicFactoryI::createTopicWriter( lock_guard lock(_mutex); writer = make_shared( shared_from_this(), - keyFactory, - tagFactory, - sampleFactory, - keyFilterFactories, - sampleFilterFactories, - name, + std::move(keyFactory), + std::move(tagFactory), + std::move(sampleFactory), + std::move(keyFilterFactories), + std::move(sampleFilterFactories), + name, // we keep using name below _nextWriterId++); _writers[name].push_back(writer); if (_traceLevels->topic > 0) diff --git a/cpp/src/DataStorm/TopicFactoryI.h b/cpp/src/DataStorm/TopicFactoryI.h index b064a9ea8b1..210c5478d97 100644 --- a/cpp/src/DataStorm/TopicFactoryI.h +++ b/cpp/src/DataStorm/TopicFactoryI.h @@ -15,28 +15,28 @@ namespace DataStormI class TopicI; - class TopicFactoryI : public TopicFactory, public std::enable_shared_from_this + class TopicFactoryI final : public TopicFactory, public std::enable_shared_from_this { public: TopicFactoryI(const std::shared_ptr&); - virtual std::shared_ptr createTopicReader( - const std::string&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&) override; - - virtual std::shared_ptr createTopicWriter( - const std::string&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&) override; - - virtual Ice::CommunicatorPtr getCommunicator() const override; + std::shared_ptr createTopicReader( + std::string, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr) final; + + std::shared_ptr createTopicWriter( + std::string, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr) final; + + Ice::CommunicatorPtr getCommunicator() const final; void removeTopicReader(const std::string&, const std::shared_ptr&); void removeTopicWriter(const std::string&, const std::shared_ptr&); diff --git a/cpp/src/DataStorm/TopicI.cpp b/cpp/src/DataStorm/TopicI.cpp index 8891934e782..33dbb82e862 100644 --- a/cpp/src/DataStorm/TopicI.cpp +++ b/cpp/src/DataStorm/TopicI.cpp @@ -36,46 +36,46 @@ namespace { next->setValue(previous); }; // The always match filter always matches the value, it's used by the any key reader/writer. - class AlwaysMatchFilter : public Filter + class AlwaysMatchFilter final : public Filter { public: - virtual string toString() const { return "f1:alwaysmatch"; } + string toString() const final { return "f1:alwaysmatch"; } - virtual const string& getName() const + const string& getName() const final { static string alwaysmatch("alwaysmatch"); return alwaysmatch; } - virtual Ice::ByteSeq encode(const Ice::CommunicatorPtr&) const { return {}; } + Ice::ByteSeq encode(const Ice::CommunicatorPtr&) const final { return {}; } - virtual int64_t getId() const + int64_t getId() const final { return 1; // 1 is reserved for the match all filter. } - virtual bool match(const shared_ptr&) const { return true; } + bool match(const shared_ptr&) const final { return true; } }; const auto alwaysMatchFilter = make_shared(); } TopicI::TopicI( - const weak_ptr& factory, - const shared_ptr& keyFactory, - const shared_ptr& tagFactory, - const shared_ptr& sampleFactory, - const shared_ptr& keyFilterFactories, - const shared_ptr& sampleFilterFactories, - const string& name, + weak_ptr factory, + shared_ptr keyFactory, + shared_ptr tagFactory, + shared_ptr sampleFactory, + shared_ptr keyFilterFactories, + shared_ptr sampleFilterFactories, + string name, int64_t id) - : _factory(factory), - _keyFactory(keyFactory), - _tagFactory(tagFactory), + : _factory(std::move(factory)), + _keyFactory(std::move(keyFactory)), + _tagFactory(std::move(tagFactory)), _sampleFactory(std::move(sampleFactory)), - _keyFilterFactories(keyFilterFactories), - _sampleFilterFactories(sampleFilterFactories), - _name(name), - _instance(factory.lock()->getInstance()), + _keyFilterFactories(std::move(keyFilterFactories)), + _sampleFilterFactories(std::move(sampleFilterFactories)), + _name(std::move(name)), + _instance(_factory.lock()->getInstance()), _traceLevels(_instance->getTraceLevels()), _id(id), _forwarder{_instance->getCollocatedForwarder()->add( @@ -857,15 +857,23 @@ TopicI::parseConfigImpl(const Ice::PropertyDict& properties, const string& prefi } TopicReaderI::TopicReaderI( - const shared_ptr& factory, - const shared_ptr& keyFactory, - const shared_ptr& tagFactory, - const shared_ptr& sampleFactory, - const shared_ptr& keyFilterFactories, - const shared_ptr& sampleFilterFactories, - const string& name, + shared_ptr factory, + shared_ptr keyFactory, + shared_ptr tagFactory, + shared_ptr sampleFactory, + shared_ptr keyFilterFactories, + shared_ptr sampleFilterFactories, + string name, int64_t id) - : TopicI(factory, keyFactory, tagFactory, sampleFactory, keyFilterFactories, sampleFilterFactories, name, id) + : TopicI( + std::move(factory), + std::move(keyFactory), + std::move(tagFactory), + std::move(sampleFactory), + std::move(keyFilterFactories), + std::move(sampleFilterFactories), + std::move(name), + id) { _defaultConfig = {-1, 0, DataStorm::ClearHistoryPolicy::OnAll, DataStorm::DiscardPolicy::None}; _defaultConfig = mergeConfigs(parseConfig("DataStorm.Topic")); @@ -874,18 +882,18 @@ TopicReaderI::TopicReaderI( shared_ptr TopicReaderI::createFiltered( const shared_ptr& filter, - const string& name, + string name, DataStorm::ReaderConfig config, - const string& sampleFilterName, + string sampleFilterName, Ice::ByteSeq sampleFilterCriteria) { lock_guard lock(_mutex); auto element = make_shared( this, - name, + std::move(name), ++_nextFilteredId, filter, - sampleFilterName, + std::move(sampleFilterName), std::move(sampleFilterCriteria), mergeConfigs(std::move(config))); addFiltered(element, filter); @@ -895,18 +903,18 @@ TopicReaderI::createFiltered( shared_ptr TopicReaderI::create( const vector>& keys, - const string& name, + string name, DataStorm::ReaderConfig config, - const string& sampleFilterName, + string sampleFilterName, Ice::ByteSeq sampleFilterCriteria) { lock_guard lock(_mutex); auto element = make_shared( this, - name, + std::move(name), ++_nextId, keys, - sampleFilterName, + std::move(sampleFilterName), std::move(sampleFilterCriteria), mergeConfigs(std::move(config))); add(element, keys); @@ -992,25 +1000,33 @@ TopicReaderI::mergeConfigs(DataStorm::ReaderConfig config) const } TopicWriterI::TopicWriterI( - const shared_ptr& factory, - const shared_ptr& keyFactory, - const shared_ptr& tagFactory, - const shared_ptr& sampleFactory, - const shared_ptr& keyFilterFactories, - const shared_ptr& sampleFilterFactories, - const string& name, + shared_ptr factory, + shared_ptr keyFactory, + shared_ptr tagFactory, + shared_ptr sampleFactory, + shared_ptr keyFilterFactories, + shared_ptr sampleFilterFactories, + string name, int64_t id) - : TopicI(factory, keyFactory, tagFactory, sampleFactory, keyFilterFactories, sampleFilterFactories, name, id) + : TopicI( + std::move(factory), + std::move(keyFactory), + std::move(tagFactory), + std::move(sampleFactory), + std::move(keyFilterFactories), + std::move(sampleFilterFactories), + std::move(name), + id) { _defaultConfig = {-1, 0, DataStorm::ClearHistoryPolicy::OnAll}; _defaultConfig = mergeConfigs(parseConfig("DataStorm.Topic")); } shared_ptr -TopicWriterI::create(const vector>& keys, const string& name, DataStorm::WriterConfig config) +TopicWriterI::create(const vector>& keys, string name, DataStorm::WriterConfig config) { lock_guard lock(_mutex); - auto element = make_shared(this, name, ++_nextId, keys, mergeConfigs(std::move(config))); + auto element = make_shared(this, std::move(name), ++_nextId, keys, mergeConfigs(std::move(config))); add(element, keys); return element; } diff --git a/cpp/src/DataStorm/TopicI.h b/cpp/src/DataStorm/TopicI.h index d4d604d7f90..7647d88928d 100644 --- a/cpp/src/DataStorm/TopicI.h +++ b/cpp/src/DataStorm/TopicI.h @@ -11,20 +11,12 @@ #include "ForwarderManager.h" #include "Instance.h" -#if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wshadow-field-in-constructor" -#elif defined(__GNUC__) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wshadow" -#endif - namespace DataStormI { class SessionI; class TopicFactoryI; - class TopicI : virtual public Topic, public std::enable_shared_from_this + class TopicI : public virtual Topic, public std::enable_shared_from_this { struct ListenerKey { @@ -35,7 +27,7 @@ namespace DataStormI struct Listener { - Listener(DataStormContract::SessionPrx proxy) : proxy(std::move(proxy)) {} + Listener(DataStormContract::SessionPrx sessionPrx) : proxy(std::move(sessionPrx)) {} std::set topics; DataStormContract::SessionPrx proxy; @@ -43,19 +35,19 @@ namespace DataStormI public: TopicI( - const std::weak_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::string&, + std::weak_ptr, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::string, std::int64_t); - virtual ~TopicI(); + ~TopicI() override; - virtual std::string getName() const override; - virtual void destroy() override; + std::string getName() const override; + void destroy() override; void shutdown(); @@ -84,11 +76,11 @@ namespace DataStormI const std::chrono::time_point&, Ice::LongSeq&); - virtual void setUpdater(const std::shared_ptr&, Updater) override; + void setUpdater(const std::shared_ptr&, Updater) override; const Updater& getUpdater(const std::shared_ptr&) const; - virtual void setUpdaters(std::map, Updater>) override; - virtual std::map, Updater> getUpdaters() const override; + void setUpdaters(std::map, Updater>) override; + std::map, Updater> getUpdaters() const override; bool isDestroyed() const { return _destroyed; } @@ -160,36 +152,34 @@ namespace DataStormI std::int64_t _nextSampleId; }; - class TopicReaderI : public TopicReader, public TopicI + class TopicReaderI final : public TopicReader, public TopicI { public: TopicReaderI( - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::string&, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::string, std::int64_t); - virtual std::shared_ptr createFiltered( - const std::shared_ptr&, - const std::string&, - DataStorm::ReaderConfig, - const std::string&, - Ice::ByteSeq) override; - virtual std::shared_ptr create( + std::shared_ptr + createFiltered(const std::shared_ptr&, std::string, DataStorm::ReaderConfig, std::string, Ice::ByteSeq) + final; + + std::shared_ptr create( const std::vector>&, - const std::string&, + std::string, DataStorm::ReaderConfig, - const std::string&, - Ice::ByteSeq) override; + std::string, + Ice::ByteSeq) final; - virtual void setDefaultConfig(DataStorm::ReaderConfig) override; - virtual void waitForWriters(int) const override; - virtual bool hasWriters() const override; - virtual void destroy() override; + void setDefaultConfig(DataStorm::ReaderConfig) final; + void waitForWriters(int) const final; + bool hasWriters() const final; + void destroy() final; private: DataStorm::ReaderConfig parseConfig(const std::string&) const; @@ -198,26 +188,26 @@ namespace DataStormI DataStorm::ReaderConfig _defaultConfig; }; - class TopicWriterI : public TopicWriter, public TopicI + class TopicWriterI final : public TopicWriter, public TopicI { public: TopicWriterI( - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::shared_ptr&, - const std::string&, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::shared_ptr, + std::string, std::int64_t); - virtual std::shared_ptr - create(const std::vector>&, const std::string&, DataStorm::WriterConfig) override; + std::shared_ptr + create(const std::vector>&, std::string, DataStorm::WriterConfig) final; - virtual void setDefaultConfig(DataStorm::WriterConfig) override; - virtual void waitForReaders(int) const override; - virtual bool hasReaders() const override; - virtual void destroy() override; + void setDefaultConfig(DataStorm::WriterConfig) final; + void waitForReaders(int) const final; + bool hasReaders() const final; + void destroy() final; private: DataStorm::WriterConfig parseConfig(const std::string&) const; @@ -227,10 +217,4 @@ namespace DataStormI }; } -#if defined(__clang__) -# pragma clang diagnostic pop -#elif defined(__GNUC__) -# pragma GCC diagnostic pop -#endif - #endif diff --git a/cpp/src/Ice/InputStream.cpp b/cpp/src/Ice/InputStream.cpp index 06687370a7f..51ef1c4116b 100644 --- a/cpp/src/Ice/InputStream.cpp +++ b/cpp/src/Ice/InputStream.cpp @@ -1877,7 +1877,7 @@ Ice::InputStream::EncapsDecoder10::endInstance() return 0; } -string_view +const string& Ice::InputStream::EncapsDecoder10::startSlice() { // @@ -2158,7 +2158,7 @@ Ice::InputStream::EncapsDecoder11::endInstance() return slicedData; } -string_view +const string& Ice::InputStream::EncapsDecoder11::startSlice() { // diff --git a/cpp/src/Ice/LoggerAdminI.cpp b/cpp/src/Ice/LoggerAdminI.cpp index 787ee06073d..d8b02ba9434 100644 --- a/cpp/src/Ice/LoggerAdminI.cpp +++ b/cpp/src/Ice/LoggerAdminI.cpp @@ -111,7 +111,8 @@ namespace void warning(const std::string&) final; void error(const std::string&) final; std::string getPrefix() final; - LoggerPtr cloneWithPrefix(const std::string&) final; + LoggerPtr cloneWithPrefix(std::string) final; + ObjectPtr getFacet() const; void destroy() final; @@ -629,9 +630,9 @@ namespace string LoggerAdminLoggerI::getPrefix() { return _localLogger->getPrefix(); } - LoggerPtr LoggerAdminLoggerI::cloneWithPrefix(const string& prefix) + LoggerPtr LoggerAdminLoggerI::cloneWithPrefix(string prefix) { - return _localLogger->cloneWithPrefix(prefix); + return _localLogger->cloneWithPrefix(std::move(prefix)); } ObjectPtr LoggerAdminLoggerI::getFacet() const { return _loggerAdmin; } diff --git a/cpp/src/Ice/LoggerI.cpp b/cpp/src/Ice/LoggerI.cpp index d6163efb645..15448a42429 100644 --- a/cpp/src/Ice/LoggerI.cpp +++ b/cpp/src/Ice/LoggerI.cpp @@ -25,21 +25,21 @@ namespace const chrono::minutes retryTimeout = chrono::minutes(5); } -Ice::LoggerI::LoggerI(const string& prefix, const string& file, bool convert, size_t sizeMax) - : _prefix(prefix), +Ice::LoggerI::LoggerI(string prefix, string file, bool convert, size_t sizeMax) + : _prefix(std::move(prefix)), _convert(convert), _converter(getProcessStringConverter()), + _file(std::move(file)), _sizeMax(sizeMax) { - if (!prefix.empty()) + if (!_prefix.empty()) { - _formattedPrefix = prefix + ": "; + _formattedPrefix = _prefix + ": "; } - if (!file.empty()) + if (!_file.empty()) { - _file = file; - _out.open(IceInternal::streamFilename(file).c_str(), fstream::out | fstream::app); + _out.open(IceInternal::streamFilename(_file).c_str(), fstream::out | fstream::app); if (!_out.is_open()) { throw InitializationException(__FILE__, __LINE__, "FileLogger: cannot open " + _file); @@ -102,10 +102,10 @@ Ice::LoggerI::getPrefix() } LoggerPtr -Ice::LoggerI::cloneWithPrefix(const std::string& prefix) +Ice::LoggerI::cloneWithPrefix(std::string prefix) { lock_guard lock(outputMutex); // for _sizeMax - return make_shared(prefix, _file, _convert, _sizeMax); + return make_shared(std::move(prefix), _file, _convert, _sizeMax); } void diff --git a/cpp/src/Ice/LoggerI.h b/cpp/src/Ice/LoggerI.h index e498ea0b04c..69076a71176 100644 --- a/cpp/src/Ice/LoggerI.h +++ b/cpp/src/Ice/LoggerI.h @@ -12,18 +12,18 @@ namespace Ice { - class LoggerI : public Logger + class LoggerI final : public Logger { public: - LoggerI(const std::string&, const std::string&, bool convert = true, std::size_t sizeMax = 0); + LoggerI(std::string prefix, std::string file, bool convert = true, std::size_t sizeMax = 0); ~LoggerI(); - virtual void print(const std::string&); - virtual void trace(const std::string&, const std::string&); - virtual void warning(const std::string&); - virtual void error(const std::string&); - virtual std::string getPrefix(); - virtual LoggerPtr cloneWithPrefix(const std::string&); + void print(const std::string&) final; + void trace(const std::string& category, const std::string& message) final; + void warning(const std::string&) final; + void error(const std::string&) final; + std::string getPrefix() final; + LoggerPtr cloneWithPrefix(std::string) final; private: void write(const std::string&, bool); @@ -34,7 +34,7 @@ namespace Ice const StringConverterPtr _converter; std::ofstream _out; - std::string _file; + const std::string _file; std::size_t _sizeMax; // diff --git a/cpp/src/Ice/OSLogLoggerI.cpp b/cpp/src/Ice/OSLogLoggerI.cpp index 74068f1b37d..caaf407a6d4 100644 --- a/cpp/src/Ice/OSLogLoggerI.cpp +++ b/cpp/src/Ice/OSLogLoggerI.cpp @@ -10,48 +10,48 @@ using namespace std; using namespace Ice; -Ice::OSLogLoggerI::OSLogLoggerI(const std::string& prefix) : _prefix(prefix) +Ice::OSLogLoggerI::OSLogLoggerI(string prefix) + : _prefix(std::move(prefix)), + _subsystem(_prefix.empty() ? "com.zeroc.ice" : "com.zeroc.ice." + _prefix), + _log(os_log_create(_subsystem.c_str(), "")) { - const string subsystem = prefix.empty() ? "com.zeroc.ice" : "com.zeroc.ice." + prefix; - _log.reset(os_log_create(subsystem.c_str(), "")); } void -Ice::OSLogLoggerI::print(const std::string& message) +Ice::OSLogLoggerI::print(const string& message) { os_log_with_type(_log.get(), OS_LOG_TYPE_DEFAULT, "%{public}s.", message.c_str()); } void -Ice::OSLogLoggerI::trace(const std::string& category, const std::string& message) +Ice::OSLogLoggerI::trace(const string& category, const string& message) { - const string subsystem = _prefix.empty() ? "com.zeroc.ice" : "com.zeroc.ice." + _prefix; - IceInternal::UniqueRef log(os_log_create(subsystem.c_str(), category.c_str())); + IceInternal::UniqueRef log(os_log_create(_subsystem.c_str(), category.c_str())); os_log_with_type(log.get(), OS_LOG_TYPE_INFO, "%{public}s.", message.c_str()); } void -Ice::OSLogLoggerI::warning(const std::string& message) +Ice::OSLogLoggerI::warning(const string& message) { os_log_with_type(_log.get(), OS_LOG_TYPE_ERROR, "%{public}s.", message.c_str()); } void -Ice::OSLogLoggerI::error(const std::string& message) +Ice::OSLogLoggerI::error(const string& message) { os_log_with_type(_log.get(), OS_LOG_TYPE_FAULT, "%{public}s.", message.c_str()); } -std::string +string Ice::OSLogLoggerI::getPrefix() { return _prefix; } LoggerPtr -Ice::OSLogLoggerI::cloneWithPrefix(const std::string& prefix) +Ice::OSLogLoggerI::cloneWithPrefix(string prefix) { - return make_shared(prefix); + return make_shared(std::move(prefix)); } #endif diff --git a/cpp/src/Ice/OSLogLoggerI.h b/cpp/src/Ice/OSLogLoggerI.h index 3b3e9aa609b..019dfd4408b 100644 --- a/cpp/src/Ice/OSLogLoggerI.h +++ b/cpp/src/Ice/OSLogLoggerI.h @@ -13,20 +13,21 @@ namespace Ice { - class OSLogLoggerI : public Logger + class OSLogLoggerI final : public Logger { public: - OSLogLoggerI(const std::string&); + OSLogLoggerI(std::string); - virtual void print(const std::string&); - virtual void trace(const std::string&, const std::string&); - virtual void warning(const std::string&); - virtual void error(const std::string&); - virtual std::string getPrefix(); - virtual LoggerPtr cloneWithPrefix(const std::string&); + void print(const std::string&) final; + void trace(const std::string&, const std::string&) final; + void warning(const std::string&) final; + void error(const std::string&) final; + std::string getPrefix() final; + LoggerPtr cloneWithPrefix(std::string) final; private: const std::string _prefix; + const std::string _subsystem; IceInternal::UniqueRef _log; }; } diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index aeeae2e42d5..4b679d043b7 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -327,13 +327,13 @@ Ice::ObjectAdapterI::destroy() noexcept // // Remove object references (some of them cyclic). // - _instance = 0; - _threadPool = 0; - _routerInfo = 0; + _instance = nullptr; + _threadPool = nullptr; + _routerInfo = nullptr; _publishedEndpoints.clear(); - _locatorInfo = 0; - _reference = 0; - _objectAdapterFactory = 0; + _locatorInfo = nullptr; + _reference = nullptr; + _objectAdapterFactory = nullptr; _state = StateDestroyed; _conditionVariable.notify_all(); @@ -582,7 +582,6 @@ optional Ice::ObjectAdapterI::getLocator() const noexcept { lock_guard lock(_mutex); - checkForDeactivation(); return _locatorInfo ? optional(_locatorInfo->getLocator()) : nullopt; } diff --git a/cpp/src/Ice/Properties.cpp b/cpp/src/Ice/Properties.cpp index 484c6a77ea6..afd9e7569b9 100644 --- a/cpp/src/Ice/Properties.cpp +++ b/cpp/src/Ice/Properties.cpp @@ -603,7 +603,7 @@ Ice::Properties::parseOptions(string_view prefix, const StringSeq& options) } else { - unmatched.emplace_back(opt); + unmatched.push_back(std::move(opt)); } } diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp index ca567bcb79f..d3a1ca4393a 100644 --- a/cpp/src/Ice/PropertyNames.cpp +++ b/cpp/src/Ice/PropertyNames.cpp @@ -26,9 +26,9 @@ const PropertyArray PropertyNames::ProxyProps { .name="Proxy", .prefixOnly=false, + .isOptIn=false, .properties=ProxyPropsData, - .length=9, - .isOptIn=false + .length=9 }; const Property ConnectionPropsData[] = @@ -45,9 +45,9 @@ const PropertyArray PropertyNames::ConnectionProps { .name="Connection", .prefixOnly=true, + .isOptIn=false, .properties=ConnectionPropsData, - .length=6, - .isOptIn=false + .length=6 }; const Property ThreadPoolPropsData[] = @@ -63,9 +63,9 @@ const PropertyArray PropertyNames::ThreadPoolProps { .name="ThreadPool", .prefixOnly=true, + .isOptIn=false, .properties=ThreadPoolPropsData, - .length=5, - .isOptIn=false + .length=5 }; const Property ObjectAdapterPropsData[] = @@ -88,9 +88,9 @@ const PropertyArray PropertyNames::ObjectAdapterProps { .name="ObjectAdapter", .prefixOnly=true, + .isOptIn=false, .properties=ObjectAdapterPropsData, - .length=12, - .isOptIn=false + .length=12 }; const Property LMDBPropsData[] = @@ -103,9 +103,9 @@ const PropertyArray PropertyNames::LMDBProps { .name="LMDB", .prefixOnly=true, + .isOptIn=false, .properties=LMDBPropsData, - .length=2, - .isOptIn=false + .length=2 }; const Property IcePropsData[] = @@ -199,9 +199,9 @@ const PropertyArray PropertyNames::IceProps { .name="Ice", .prefixOnly=false, + .isOptIn=false, .properties=IcePropsData, - .length=83, - .isOptIn=false + .length=83 }; const Property IceMXPropsData[] = @@ -218,9 +218,9 @@ const PropertyArray PropertyNames::IceMXProps { .name="IceMX", .prefixOnly=false, + .isOptIn=false, .properties=IceMXPropsData, - .length=6, - .isOptIn=false + .length=6 }; const Property IceDiscoveryPropsData[] = @@ -242,9 +242,9 @@ const PropertyArray PropertyNames::IceDiscoveryProps { .name="IceDiscovery", .prefixOnly=false, + .isOptIn=false, .properties=IceDiscoveryPropsData, - .length=11, - .isOptIn=false + .length=11 }; const Property IceLocatorDiscoveryPropsData[] = @@ -266,9 +266,9 @@ const PropertyArray PropertyNames::IceLocatorDiscoveryProps { .name="IceLocatorDiscovery", .prefixOnly=false, + .isOptIn=false, .properties=IceLocatorDiscoveryPropsData, - .length=11, - .isOptIn=false + .length=11 }; const Property IceBoxPropsData[] = @@ -285,9 +285,9 @@ const PropertyArray PropertyNames::IceBoxProps { .name="IceBox", .prefixOnly=false, + .isOptIn=true, .properties=IceBoxPropsData, - .length=6, - .isOptIn=true + .length=6 }; const Property IceBoxAdminPropsData[] = @@ -299,9 +299,9 @@ const PropertyArray PropertyNames::IceBoxAdminProps { .name="IceBoxAdmin", .prefixOnly=false, + .isOptIn=true, .properties=IceBoxAdminPropsData, - .length=1, - .isOptIn=true + .length=1 }; const Property IceBridgePropsData[] = @@ -315,9 +315,9 @@ const PropertyArray PropertyNames::IceBridgeProps { .name="IceBridge", .prefixOnly=false, + .isOptIn=true, .properties=IceBridgePropsData, - .length=3, - .isOptIn=true + .length=3 }; const Property IceGridAdminPropsData[] = @@ -341,9 +341,9 @@ const PropertyArray PropertyNames::IceGridAdminProps { .name="IceGridAdmin", .prefixOnly=false, + .isOptIn=true, .properties=IceGridAdminPropsData, - .length=13, - .isOptIn=true + .length=13 }; const Property IceGridPropsData[] = @@ -416,9 +416,9 @@ const PropertyArray PropertyNames::IceGridProps { .name="IceGrid", .prefixOnly=false, + .isOptIn=true, .properties=IceGridPropsData, - .length=62, - .isOptIn=true + .length=62 }; const Property IceSSLPropsData[] = @@ -450,9 +450,9 @@ const PropertyArray PropertyNames::IceSSLProps { .name="IceSSL", .prefixOnly=false, + .isOptIn=false, .properties=IceSSLPropsData, - .length=21, - .isOptIn=false + .length=21 }; const Property IceStormPropsData[] = @@ -487,9 +487,9 @@ const PropertyArray PropertyNames::IceStormProps { .name="IceStorm", .prefixOnly=false, + .isOptIn=true, .properties=IceStormPropsData, - .length=24, - .isOptIn=true + .length=24 }; const Property IceStormAdminPropsData[] = @@ -503,9 +503,9 @@ const PropertyArray PropertyNames::IceStormAdminProps { .name="IceStormAdmin", .prefixOnly=false, + .isOptIn=true, .properties=IceStormAdminPropsData, - .length=3, - .isOptIn=true + .length=3 }; const Property IceBTPropsData[] = @@ -518,9 +518,9 @@ const PropertyArray PropertyNames::IceBTProps { .name="IceBT", .prefixOnly=false, + .isOptIn=false, .properties=IceBTPropsData, - .length=2, - .isOptIn=false + .length=2 }; const Property Glacier2PropsData[] = @@ -555,9 +555,9 @@ const PropertyArray PropertyNames::Glacier2Props { .name="Glacier2", .prefixOnly=false, + .isOptIn=true, .properties=Glacier2PropsData, - .length=24, - .isOptIn=true + .length=24 }; const Property DataStormPropsData[] = @@ -581,9 +581,9 @@ const PropertyArray PropertyNames::DataStormProps { .name="DataStorm", .prefixOnly=false, + .isOptIn=true, .properties=DataStormPropsData, - .length=13, - .isOptIn=true + .length=13 }; const std::array PropertyNames::validProps = diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h index b679b18b841..bef9b29b7d5 100644 --- a/cpp/src/Ice/PropertyNames.h +++ b/cpp/src/Ice/PropertyNames.h @@ -29,9 +29,9 @@ namespace IceInternal { const char* name; const bool prefixOnly; + const bool isOptIn; const Property* properties; const int length; - const bool isOptIn; }; class PropertyNames diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp index 253d8916413..e70c900e74e 100644 --- a/cpp/src/Ice/Service.cpp +++ b/cpp/src/Ice/Service.cpp @@ -117,27 +117,29 @@ namespace }; using SMEventLoggerPtr = std::shared_ptr; - class SMEventLoggerIWrapper : public Ice::Logger + class SMEventLoggerIWrapper final : public Ice::Logger { public: - SMEventLoggerIWrapper(const SMEventLoggerPtr& logger, const string& prefix) : _logger(logger), _prefix(prefix) + SMEventLoggerIWrapper(const SMEventLoggerPtr& logger, string prefix) + : _logger(logger), + _prefix(std::move(prefix)) { assert(_logger); } - virtual void print(const string& message) { _logger->print(_prefix, message); } + void print(const string& message) final { _logger->print(_prefix, message); } - void trace(const string& category, const string& message) { _logger->trace(_prefix, category, message); } + void trace(const string& category, const string& message) final { _logger->trace(_prefix, category, message); } - virtual void warning(const string& message) { _logger->warning(_prefix, message); } + void warning(const string& message) final { _logger->warning(_prefix, message); } - virtual void error(const string& message) { _logger->error(_prefix, message); } + void error(const string& message) final { _logger->error(_prefix, message); } - virtual string getPrefix() { return _prefix; } + string getPrefix() final { return _prefix; } - virtual Ice::LoggerPtr cloneWithPrefix(const string& prefix) + Ice::LoggerPtr cloneWithPrefix(string prefix) final { - return make_shared(_logger, prefix); + return make_shared(_logger, std::move(prefix)); } private: diff --git a/cpp/src/Ice/StringConverter.cpp b/cpp/src/Ice/StringConverter.cpp index 8e246609591..b5c1c7560e5 100644 --- a/cpp/src/Ice/StringConverter.cpp +++ b/cpp/src/Ice/StringConverter.cpp @@ -341,11 +341,11 @@ Ice::nativeToUTF8(string_view str, const Ice::StringConverterPtr& converter) } string -Ice::UTF8ToNative(const string& str, const Ice::StringConverterPtr& converter) +Ice::UTF8ToNative(string_view str, const Ice::StringConverterPtr& converter) { if (!converter || str.empty()) { - return str; + return string{str}; } string tmp; converter->fromUTF8( diff --git a/cpp/src/Ice/SysLoggerI.cpp b/cpp/src/Ice/SysLoggerI.cpp index f68a7e45db1..4dd939ad714 100644 --- a/cpp/src/Ice/SysLoggerI.cpp +++ b/cpp/src/Ice/SysLoggerI.cpp @@ -12,7 +12,7 @@ using namespace std; using namespace Ice; using namespace IceInternal; -Ice::SysLoggerI::SysLoggerI(const string& prefix, const string& facilityString) : _facility(0), _prefix(prefix) +Ice::SysLoggerI::SysLoggerI(string prefix, string_view facilityString) : _facility(0), _prefix(std::move(prefix)) { if (facilityString == "LOG_KERN") { @@ -100,14 +100,17 @@ Ice::SysLoggerI::SysLoggerI(const string& prefix, const string& facilityString) } else { - throw InitializationException(__FILE__, __LINE__, "Invalid value for Ice.SyslogFacility: " + facilityString); + throw InitializationException( + __FILE__, + __LINE__, + "Invalid value for Ice.SyslogFacility: " + string{facilityString}); } int logopt = LOG_PID | LOG_CONS; openlog(_prefix.c_str(), logopt, _facility); } -Ice::SysLoggerI::SysLoggerI(const string& prefix, int facility) : _facility(facility), _prefix(prefix) +Ice::SysLoggerI::SysLoggerI(string prefix, int facility) : _facility(facility), _prefix(std::move(prefix)) { int logopt = LOG_PID | LOG_CONS; openlog(_prefix.c_str(), logopt, facility); @@ -151,9 +154,9 @@ Ice::SysLoggerI::getPrefix() } Ice::LoggerPtr -Ice::SysLoggerI::cloneWithPrefix(const string& prefix) +Ice::SysLoggerI::cloneWithPrefix(string prefix) { - return make_shared(prefix, _facility); + return make_shared(std::move(prefix), _facility); } #endif diff --git a/cpp/src/Ice/SysLoggerI.h b/cpp/src/Ice/SysLoggerI.h index fdd866420f7..eec068cd0f0 100644 --- a/cpp/src/Ice/SysLoggerI.h +++ b/cpp/src/Ice/SysLoggerI.h @@ -8,22 +8,23 @@ #include "Ice/Logger.h" #include +#include namespace Ice { - class SysLoggerI : public Logger + class SysLoggerI final : public Logger { public: - SysLoggerI(const std::string&, const std::string&); - SysLoggerI(const std::string&, int); + SysLoggerI(std::string prefix, std::string_view facilityString); + SysLoggerI(std::string prefix, int facility); ~SysLoggerI(); - virtual void print(const std::string&); - virtual void trace(const std::string&, const std::string&); - virtual void warning(const std::string&); - virtual void error(const std::string&); - virtual std::string getPrefix(); - virtual LoggerPtr cloneWithPrefix(const std::string&); + void print(const std::string&) final; + void trace(const std::string&, const std::string&) final; + void warning(const std::string&) final; + void error(const std::string&) final; + std::string getPrefix() final; + LoggerPtr cloneWithPrefix(std::string) final; private: int _facility; diff --git a/cpp/src/Ice/SystemdJournalI.cpp b/cpp/src/Ice/SystemdJournalI.cpp index 96158479b33..43fd1a037f9 100644 --- a/cpp/src/Ice/SystemdJournalI.cpp +++ b/cpp/src/Ice/SystemdJournalI.cpp @@ -13,7 +13,7 @@ using namespace std; using namespace Ice; using namespace IceInternal; -Ice::SystemdJournalI::SystemdJournalI(const string& prefix) : _prefix(prefix) {} +Ice::SystemdJournalI::SystemdJournalI(string prefix) : _prefix(std::move(prefix)) {} void Ice::SystemdJournalI::print(const string& message) @@ -46,9 +46,9 @@ Ice::SystemdJournalI::getPrefix() } Ice::LoggerPtr -Ice::SystemdJournalI::cloneWithPrefix(const string& prefix) +Ice::SystemdJournalI::cloneWithPrefix(string prefix) { - return make_shared(prefix); + return make_shared(std::move(prefix)); } void diff --git a/cpp/src/Ice/SystemdJournalI.h b/cpp/src/Ice/SystemdJournalI.h index cdad3eb0b98..1e86d632f24 100644 --- a/cpp/src/Ice/SystemdJournalI.h +++ b/cpp/src/Ice/SystemdJournalI.h @@ -11,17 +11,17 @@ namespace Ice { - class SystemdJournalI : public Logger + class SystemdJournalI final : public Logger { public: - SystemdJournalI(const std::string&); - - virtual void print(const std::string&); - virtual void trace(const std::string&, const std::string&); - virtual void warning(const std::string&); - virtual void error(const std::string&); - virtual std::string getPrefix(); - virtual LoggerPtr cloneWithPrefix(const std::string&); + SystemdJournalI(std::string); + + void print(const std::string&) final; + void trace(const std::string&, const std::string&) final; + void warning(const std::string&) final; + void error(const std::string&) final; + std::string getPrefix() final; + LoggerPtr cloneWithPrefix(std::string) final; private: void write(int, const std::string&) const; diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index a3ed6471ebb..0689602863f 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -141,13 +141,13 @@ Slice::Metadata::Metadata(string rawMetadata, string file, int line) : GrammarBa _arguments = rawMetadata.substr(splitPos + 1); } -string_view +const string& Slice::Metadata::directive() const { return _directive; } -string_view +const string& Slice::Metadata::arguments() const { return _arguments; diff --git a/cpp/src/Slice/Parser.h b/cpp/src/Slice/Parser.h index aea82853498..09b372fd715 100644 --- a/cpp/src/Slice/Parser.h +++ b/cpp/src/Slice/Parser.h @@ -180,8 +180,8 @@ namespace Slice { public: Metadata(std::string rawMetadata, std::string file, int line); - std::string_view directive() const; - std::string_view arguments() const; + const std::string& directive() const; + const std::string& arguments() const; std::string file() const; int line() const; diff --git a/cpp/src/Slice/Scanner.cpp b/cpp/src/Slice/Scanner.cpp index a9551ccbe6d..0bde7d88f00 100644 --- a/cpp/src/Slice/Scanner.cpp +++ b/cpp/src/Slice/Scanner.cpp @@ -1721,7 +1721,7 @@ case 16: YY_RULE_SETUP #line 233 "src/Slice/Scanner.l" { - currentUnit->warning(All, "unknown escape sequence in string literal: `" + string(yytext) + "'"); + currentUnit->warning(All, "unknown escape sequence in string literal: '" + string{yytext} + "'"); StringTokPtr str = dynamic_pointer_cast(*yylval); // Escape the entire sequence. diff --git a/cpp/src/Slice/Scanner.l b/cpp/src/Slice/Scanner.l index 16f69c58716..3f19cc96ad1 100644 --- a/cpp/src/Slice/Scanner.l +++ b/cpp/src/Slice/Scanner.l @@ -230,7 +230,7 @@ floating_literal (({fractional_constant}{exponent_part}?)|((\+|-)?{dec}+{expo /* Matches an unknown escape value. This rule has a lower priority than all the other escape rules because * it only matches 2 characters (the lowest any match), and it's beneath the others. */ "\\". { - currentUnit->warning(All, "unknown escape sequence in string literal: `" + string(yytext) + "'"); + currentUnit->warning(All, "unknown escape sequence in string literal: '" + string{yytext} + "'"); StringTokPtr str = dynamic_pointer_cast(*yylval); // Escape the entire sequence. diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp index 2827198fa92..8c8c789735b 100644 --- a/cpp/src/slice2cpp/Gen.cpp +++ b/cpp/src/slice2cpp/Gen.cpp @@ -786,7 +786,7 @@ Slice::Gen::generate(const UnitPtr& p) { ostringstream ostr; ostr << "ignoring invalid file metadata '" << *metadata << "'"; - dc->warning(InvalidMetadata, file, -1, ostr.str()); + dc->warning(InvalidMetadata, metadata->file(), metadata->line(), ostr.str()); fileMetadata.remove(metadata); } } @@ -800,7 +800,7 @@ Slice::Gen::generate(const UnitPtr& p) { ostringstream ostr; ostr << "ignoring invalid file metadata '" << *metadata << "'"; - dc->warning(InvalidMetadata, file, -1, ostr.str()); + dc->warning(InvalidMetadata, metadata->file(), metadata->line(), ostr.str()); fileMetadata.remove(metadata); } } @@ -947,7 +947,7 @@ Slice::Gen::MetadataVisitor::visitUnitStart(const UnitPtr& unit) ostringstream ostr; ostr << "ignoring invalid file metadata '" << *s << "': directive can appear only once per file"; - dc->warning(InvalidMetadata, file, -1, ostr.str()); + dc->warning(InvalidMetadata, s->file(), s->line(), ostr.str()); fileMetadata.remove(s); } seenHeaderExtension = true; @@ -960,7 +960,7 @@ Slice::Gen::MetadataVisitor::visitUnitStart(const UnitPtr& unit) ostringstream ostr; ostr << "ignoring invalid file metadata '" << *s << "': directive can appear only once per file"; - dc->warning(InvalidMetadata, file, -1, ostr.str()); + dc->warning(InvalidMetadata, s->file(), s->line(), ostr.str()); fileMetadata.remove(s); } seenSourceExtension = true; @@ -973,7 +973,7 @@ Slice::Gen::MetadataVisitor::visitUnitStart(const UnitPtr& unit) ostringstream ostr; ostr << "ignoring invalid file metadata '" << *s << "': directive can appear only once per file"; - dc->warning(InvalidMetadata, file, -1, ostr.str()); + dc->warning(InvalidMetadata, s->file(), s->line(), ostr.str()); fileMetadata.remove(s); } seenDllExport = true; @@ -986,7 +986,7 @@ Slice::Gen::MetadataVisitor::visitUnitStart(const UnitPtr& unit) ostringstream ostr; ostr << "ignoring invalid file metadata '" << *s << "'"; - dc->warning(InvalidMetadata, file, -1, ostr.str()); + dc->warning(InvalidMetadata, s->file(), s->line(), ostr.str()); fileMetadata.remove(s); } } @@ -999,34 +999,34 @@ Slice::Gen::MetadataVisitor::visitUnitStart(const UnitPtr& unit) bool Slice::Gen::MetadataVisitor::visitModuleStart(const ModulePtr& p) { - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p->getMetadata(), p->file())); return true; } void Slice::Gen::MetadataVisitor::visitClassDecl(const ClassDeclPtr& p) { - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p->getMetadata(), p->file())); } bool Slice::Gen::MetadataVisitor::visitClassDefStart(const ClassDefPtr& p) { - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p->getMetadata(), p->file())); return true; } bool Slice::Gen::MetadataVisitor::visitExceptionStart(const ExceptionPtr& p) { - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p->getMetadata(), p->file())); return true; } bool Slice::Gen::MetadataVisitor::visitStructStart(const StructPtr& p) { - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p->getMetadata(), p->file())); return true; } @@ -1047,7 +1047,7 @@ Slice::Gen::MetadataVisitor::visitOperation(const OperationPtr& p) { ostringstream ostr; ostr << "ignoring invalid metadata '" << *s << "' for operation with void return type"; - dc->warning(InvalidMetadata, p->file(), p->line(), ostr.str()); + dc->warning(InvalidMetadata, s->file(), s->line(), ostr.str()); metadata.remove(s); } } @@ -1055,43 +1055,43 @@ Slice::Gen::MetadataVisitor::visitOperation(const OperationPtr& p) } else { - p->setMetadata(validate(returnType, p->getMetadata(), p->file(), p->line(), true)); + p->setMetadata(validate(returnType, p->getMetadata(), p->file(), true)); } for (const auto& param : p->parameters()) { - param->setMetadata(validate(param->type(), param->getMetadata(), p->file(), param->line(), true)); + param->setMetadata(validate(param->type(), param->getMetadata(), p->file(), true)); } } void Slice::Gen::MetadataVisitor::visitDataMember(const DataMemberPtr& p) { - p->setMetadata(validate(p->type(), p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p->type(), p->getMetadata(), p->file())); } void Slice::Gen::MetadataVisitor::visitSequence(const SequencePtr& p) { - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p->getMetadata(), p->file())); } void Slice::Gen::MetadataVisitor::visitDictionary(const DictionaryPtr& p) { - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p->getMetadata(), p->file())); } void Slice::Gen::MetadataVisitor::visitEnum(const EnumPtr& p) { - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p->getMetadata(), p->file())); } void Slice::Gen::MetadataVisitor::visitConst(const ConstPtr& p) { - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p->getMetadata(), p->file())); } MetadataList @@ -1099,7 +1099,6 @@ Slice::Gen::MetadataVisitor::validate( const SyntaxTreeBasePtr& cont, MetadataList metadata, const string& file, - int line, bool operation) { const UnitPtr ut = cont->unit(); @@ -1118,7 +1117,7 @@ Slice::Gen::MetadataVisitor::validate( { ostringstream ostr; ostr << "ignoring invalid metadata '" << *meta << "'"; - dc->warning(InvalidMetadata, file, line, ostr.str()); + dc->warning(InvalidMetadata, meta->file(), meta->line(), ostr.str()); metadata.remove(meta); continue; } @@ -1184,7 +1183,7 @@ Slice::Gen::MetadataVisitor::validate( ostringstream ostr; ostr << "ignoring invalid metadata '" << *meta << "'"; - dc->warning(InvalidMetadata, file, line, ostr.str()); + dc->warning(InvalidMetadata, meta->file(), meta->line(), ostr.str()); metadata.remove(meta); } return metadata; diff --git a/cpp/src/slice2cpp/Gen.h b/cpp/src/slice2cpp/Gen.h index 8409c5809dd..85040c90094 100644 --- a/cpp/src/slice2cpp/Gen.h +++ b/cpp/src/slice2cpp/Gen.h @@ -218,7 +218,14 @@ namespace Slice void visitConst(const ConstPtr&) final; private: - MetadataList validate(const SyntaxTreeBasePtr&, MetadataList, const std::string&, int, bool = false); + /// Validates any 'cpp' specific metadata that's been applied to `cont`. + /// Additional metadata to validate can also be passed in with the `metadata` field. + /// For example, type metadata applied to a sequence where it's being used instead of just defined. + MetadataList validate( + const SyntaxTreeBasePtr& cont, + MetadataList metadata, + const std::string& file, + bool operation = false); }; static void validateMetadata(const UnitPtr&); diff --git a/cpp/src/slice2cs/CsUtil.cpp b/cpp/src/slice2cs/CsUtil.cpp index eea19193cd8..25b06e91cb7 100644 --- a/cpp/src/slice2cs/CsUtil.cpp +++ b/cpp/src/slice2cs/CsUtil.cpp @@ -1982,7 +1982,7 @@ Slice::CsGenerator::MetadataVisitor::visitUnitStart(const UnitPtr& unit) { ostringstream msg; msg << "ignoring invalid file metadata '" << *metadata << "'"; - dc->warning(InvalidMetadata, file, -1, msg.str()); + dc->warning(InvalidMetadata, metadata->file(), metadata->line(), msg.str()); continue; } newFileMetadata.push_back(metadata); @@ -2173,7 +2173,7 @@ Slice::CsGenerator::MetadataVisitor::validate(const ContainedPtr& cont) ostringstream msg; msg << "ignoring invalid metadata '" << *metadata << "'"; - dc->warning(InvalidMetadata, cont->file(), cont->line(), msg.str()); + dc->warning(InvalidMetadata, metadata->file(), metadata->line(), msg.str()); continue; } newLocalMetadata.push_back(metadata); diff --git a/cpp/src/slice2java/JavaUtil.cpp b/cpp/src/slice2java/JavaUtil.cpp index a073dfad9dc..efb40928197 100644 --- a/cpp/src/slice2java/JavaUtil.cpp +++ b/cpp/src/slice2java/JavaUtil.cpp @@ -102,7 +102,7 @@ namespace { ostringstream msg; msg << "ignoring invalid file metadata '" << *metadata << "'"; - dc->warning(InvalidMetadata, file, -1, msg.str()); + dc->warning(InvalidMetadata, metadata->file(), metadata->line(), msg.str()); fileMetadata.remove(metadata); } } @@ -115,7 +115,7 @@ namespace bool visitModuleStart(const ModulePtr& p) final { MetadataList metadata = getMetadata(p); - metadata = validateType(p, metadata, p->file(), p->line()); + metadata = validateType(p, metadata, p->file()); metadata = validateGetSet(p, metadata); p->setMetadata(std::move(metadata)); return true; @@ -124,7 +124,7 @@ namespace void visitClassDecl(const ClassDeclPtr& p) final { MetadataList metadata = getMetadata(p); - metadata = validateType(p, metadata, p->file(), p->line()); + metadata = validateType(p, metadata, p->file()); metadata = validateGetSet(p, metadata); p->setMetadata(std::move(metadata)); } @@ -132,7 +132,7 @@ namespace bool visitClassDefStart(const ClassDefPtr& p) final { MetadataList metadata = getMetadata(p); - metadata = validateType(p, metadata, p->file(), p->line()); + metadata = validateType(p, metadata, p->file()); metadata = validateGetSet(p, metadata); p->setMetadata(std::move(metadata)); return true; @@ -141,7 +141,7 @@ namespace bool visitExceptionStart(const ExceptionPtr& p) final { MetadataList metadata = getMetadata(p); - metadata = validateType(p, metadata, p->file(), p->line()); + metadata = validateType(p, metadata, p->file()); metadata = validateGetSet(p, metadata); p->setMetadata(std::move(metadata)); return true; @@ -150,7 +150,7 @@ namespace bool visitStructStart(const StructPtr& p) final { MetadataList metadata = getMetadata(p); - metadata = validateType(p, metadata, p->file(), p->line()); + metadata = validateType(p, metadata, p->file()); metadata = validateGetSet(p, metadata); p->setMetadata(std::move(metadata)); return true; @@ -182,7 +182,7 @@ namespace } else { - metadata = validateType(returnType, metadata, p->file(), p->line()); + metadata = validateType(returnType, metadata, p->file()); metadata = validateGetSet(p, metadata); } p->setMetadata(std::move(metadata)); @@ -190,7 +190,7 @@ namespace for (const auto& param : p->parameters()) { metadata = getMetadata(param); - metadata = validateType(param->type(), metadata, param->file(), param->line()); + metadata = validateType(param->type(), metadata, param->file()); metadata = validateGetSet(param, metadata); param->setMetadata(std::move(metadata)); } @@ -199,7 +199,7 @@ namespace void visitDataMember(const DataMemberPtr& p) final { MetadataList metadata = getMetadata(p); - metadata = validateType(p->type(), metadata, p->file(), p->line()); + metadata = validateType(p->type(), metadata, p->file()); metadata = validateGetSet(p, metadata); p->setMetadata(std::move(metadata)); } @@ -210,7 +210,6 @@ namespace MetadataList newMetadata; const string file = p->file(); - int line = p->line(); const UnitPtr unt = p->unit(); const DefinitionContextPtr dc = unt->findDefinitionContext(file); @@ -228,7 +227,7 @@ namespace ostringstream msg; msg << "ignoring invalid metadata '" << *m << "': this metadata can only be used with a byte sequence"; - dc->warning(InvalidMetadata, file, line, msg.str()); + dc->warning(InvalidMetadata, m->file(), m->line(), msg.str()); continue; } newMetadata.push_back(m); @@ -244,14 +243,14 @@ namespace { ostringstream msg; msg << "ignoring invalid metadata '" << *m << "': this metadata can not be used with this type"; - dc->warning(InvalidMetadata, file, line, msg.str()); + dc->warning(InvalidMetadata, m->file(), m->line(), msg.str()); continue; } newMetadata.push_back(m); } } - metadata = validateType(p, metadata, file, line); + metadata = validateType(p, metadata, file); metadata = validateGetSet(p, metadata); newMetadata.insert(newMetadata.begin(), metadata.begin(), metadata.end()); p->setMetadata(std::move(newMetadata)); @@ -260,7 +259,7 @@ namespace void visitDictionary(const DictionaryPtr& p) final { MetadataList metadata = getMetadata(p); - metadata = validateType(p, metadata, p->file(), p->line()); + metadata = validateType(p, metadata, p->file()); metadata = validateGetSet(p, metadata); p->setMetadata(std::move(metadata)); } @@ -268,7 +267,7 @@ namespace void visitEnum(const EnumPtr& p) final { MetadataList metadata = getMetadata(p); - metadata = validateType(p, metadata, p->file(), p->line()); + metadata = validateType(p, metadata, p->file()); metadata = validateGetSet(p, metadata); p->setMetadata(std::move(metadata)); } @@ -276,7 +275,7 @@ namespace void visitConst(const ConstPtr& p) final { MetadataList metadata = getMetadata(p); - metadata = validateType(p, metadata, p->file(), p->line()); + metadata = validateType(p, metadata, p->file()); metadata = validateGetSet(p, metadata); p->setMetadata(std::move(metadata)); } @@ -366,8 +365,7 @@ namespace return result; } - MetadataList - validateType(const SyntaxTreeBasePtr& p, const MetadataList& metadata, const string& file, int line) + MetadataList validateType(const SyntaxTreeBasePtr& p, const MetadataList& metadata, const string& file) { const UnitPtr unt = p->unit(); const DefinitionContextPtr dc = unt->findDefinitionContext(file); @@ -396,7 +394,7 @@ namespace } ostringstream msg; msg << "ignoring invalid metadata '" << *m << "' for " << str; - dc->warning(InvalidMetadata, file, line, msg.str()); + dc->warning(InvalidMetadata, m->file(), m->line(), msg.str()); } else if (directive == "java:buffer") { @@ -416,14 +414,14 @@ namespace ostringstream msg; msg << "ignoring invalid metadata '" << *m << "'"; - dc->warning(InvalidMetadata, file, line, msg.str()); + dc->warning(InvalidMetadata, m->file(), m->line(), msg.str()); } else if (directive == "java:serializable") { // Only valid in sequence definition which is checked in visitSequence ostringstream msg; msg << "ignoring invalid metadata '" << *m << "'"; - dc->warning(InvalidMetadata, file, line, msg.str()); + dc->warning(InvalidMetadata, m->file(), m->line(), msg.str()); } else if (directive == "java:implements") { @@ -435,7 +433,7 @@ namespace { ostringstream msg; msg << "ignoring invalid metadata '" << *m << "'"; - dc->warning(InvalidMetadata, file, line, msg.str()); + dc->warning(InvalidMetadata, m->file(), m->line(), msg.str()); } } else if (directive == "java:package") @@ -449,7 +447,7 @@ namespace { ostringstream msg; msg << "ignoring invalid metadata '" << *m << "'"; - dc->warning(InvalidMetadata, file, line, msg.str()); + dc->warning(InvalidMetadata, m->file(), m->line(), msg.str()); } } else diff --git a/cpp/src/slice2matlab/Main.cpp b/cpp/src/slice2matlab/Main.cpp index 24304695e6d..c73f4d8d4d9 100644 --- a/cpp/src/slice2matlab/Main.cpp +++ b/cpp/src/slice2matlab/Main.cpp @@ -1785,7 +1785,7 @@ CodeVisitor::visitClassDefStart(const ClassDefPtr& p) out.inc(); writeBaseClassArrayParams(out, allMembers, false); out.dec(); - out << nl << "end;"; + out << nl << "end"; out << nl << self << " = " << self << "@" << getAbsolute(base) << "(v{:});"; @@ -1817,7 +1817,7 @@ CodeVisitor::visitClassDefStart(const ClassDefPtr& p) out << nl << self << "." << q->fixedName << " = " << q->fixedName << ';'; } out.dec(); - out << nl << "end;"; + out << nl << "end"; } out.dec(); diff --git a/cpp/src/slice2py/Python.cpp b/cpp/src/slice2py/Python.cpp index aae5a95e70d..c1773b5082e 100644 --- a/cpp/src/slice2py/Python.cpp +++ b/cpp/src/slice2py/Python.cpp @@ -415,7 +415,9 @@ namespace "--depend-xml Generate dependencies in XML format.\n" "--depend-file FILE Write dependencies to FILE instead of standard output.\n" "--all Generate code for Slice definitions in included files.\n" - "--prefix PREFIX Prepend filenames of Python modules with PREFIX.\n"; + "--prefix PREFIX Prepend filenames of Python modules with PREFIX.\n" + "--no-package Do not generate Python package hierarchy.\n" + "--build-package Only generate Python package hierarchy.\n"; } } diff --git a/cpp/src/slice2py/PythonUtil.cpp b/cpp/src/slice2py/PythonUtil.cpp index 75c733ead6c..b9d5dabf8a0 100644 --- a/cpp/src/slice2py/PythonUtil.cpp +++ b/cpp/src/slice2py/PythonUtil.cpp @@ -151,7 +151,7 @@ namespace Slice private: /// Validates sequence metadata. - MetadataList validateSequence(const string&, int, const TypePtr&, const MetadataList&); + MetadataList validateSequence(const ContainedPtr&, const TypePtr&); /// Checks a definition that doesn't currently support Python metadata. void reject(const ContainedPtr&); @@ -2933,7 +2933,7 @@ Slice::Python::MetadataVisitor::visitUnitStart(const UnitPtr& unit) ostringstream msg; msg << "ignoring invalid file metadata '" << *meta << "'"; - dc->warning(InvalidMetadata, file, -1, msg.str()); + dc->warning(InvalidMetadata, meta->file(), meta->line(), msg.str()); fileMetadata.remove(meta); } } @@ -2961,7 +2961,7 @@ Slice::Python::MetadataVisitor::visitModuleStart(const ModulePtr& p) ostringstream msg; msg << "ignoring invalid file metadata '" << *meta << "'"; - p->definitionContext()->warning(InvalidMetadata, p->file(), -1, msg.str()); + p->definitionContext()->warning(InvalidMetadata, meta->file(), meta->line(), msg.str()); metadata.remove(meta); } } @@ -3016,25 +3016,25 @@ Slice::Python::MetadataVisitor::visitOperation(const OperationPtr& p) TypePtr ret = p->returnType(); if (ret) { - validateSequence(p->file(), p->line(), ret, p->getMetadata()); + validateSequence(p, ret); } for (const auto& param : p->parameters()) { - validateSequence(p->file(), param->line(), param->type(), param->getMetadata()); + validateSequence(param, param->type()); } } void Slice::Python::MetadataVisitor::visitDataMember(const DataMemberPtr& p) { - validateSequence(p->file(), p->line(), p->type(), p->getMetadata()); + validateSequence(p, p->type()); } void Slice::Python::MetadataVisitor::visitSequence(const SequencePtr& p) { - p->setMetadata(validateSequence(p->file(), p->line(), p, p->getMetadata())); + p->setMetadata(validateSequence(p, p)); } void @@ -3056,18 +3056,14 @@ Slice::Python::MetadataVisitor::visitConst(const ConstPtr& p) } MetadataList -Slice::Python::MetadataVisitor::validateSequence( - const string& file, - int line, - const TypePtr& type, - const MetadataList& metadata) +Slice::Python::MetadataVisitor::validateSequence(const ContainedPtr& cont, const TypePtr& type) { const UnitPtr ut = type->unit(); - const DefinitionContextPtr dc = ut->findDefinitionContext(file); + const DefinitionContextPtr dc = ut->findDefinitionContext(cont->file()); assert(dc); static const string prefix = "python:"; - MetadataList newMetadata = metadata; + MetadataList newMetadata = cont->getMetadata(); for (MetadataList::const_iterator p = newMetadata.begin(); p != newMetadata.end();) { MetadataPtr s = *p++; @@ -3123,7 +3119,7 @@ Slice::Python::MetadataVisitor::validateSequence( } ostringstream msg; msg << "ignoring invalid metadata '" << *s << "'"; - dc->warning(InvalidMetadata, file, line, msg.str()); + dc->warning(InvalidMetadata, s->file(), s->line(), msg.str()); newMetadata.remove(s); } } @@ -3146,7 +3142,7 @@ Slice::Python::MetadataVisitor::reject(const ContainedPtr& cont) { ostringstream msg; msg << "ignoring invalid metadata '" << *s << "'"; - dc->warning(InvalidMetadata, cont->file(), cont->line(), msg.str()); + dc->warning(InvalidMetadata, s->file(), s->line(), msg.str()); localMetadata.remove(s); } } diff --git a/cpp/src/slice2rb/RubyUtil.cpp b/cpp/src/slice2rb/RubyUtil.cpp index bc7738c6bde..35798bdffc4 100644 --- a/cpp/src/slice2rb/RubyUtil.cpp +++ b/cpp/src/slice2rb/RubyUtil.cpp @@ -516,7 +516,7 @@ Slice::Ruby::CodeVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) // // Define each operation. The arguments to __defineOperation are: // - // 'opName', Mode, IsAmd, FormatType, [InParams], [OutParams], ReturnParam, [Exceptions] + // 'opName', Mode, FormatType, [InParams], [OutParams], ReturnParam, [Exceptions] // // where InParams and OutParams are arrays of type descriptions, and Exceptions // is an array of exception types. @@ -582,8 +582,7 @@ Slice::Ruby::CodeVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) _out << "::Ice::OperationMode::Idempotent"; break; } - _out << ", " << ((p->hasMetadata("amd") || op->hasMetadata("amd")) ? "true" : "false") << ", " << format - << ", ["; + _out << ", " << format << ", ["; for (t = params.begin(), count = 0; t != params.end(); ++t) { if (!(*t)->isOutParam()) diff --git a/cpp/src/slice2swift/SwiftUtil.cpp b/cpp/src/slice2swift/SwiftUtil.cpp index 227174e3b40..b1afc0b0863 100644 --- a/cpp/src/slice2swift/SwiftUtil.cpp +++ b/cpp/src/slice2swift/SwiftUtil.cpp @@ -1709,7 +1709,7 @@ SwiftGenerator::MetadataVisitor::visitModuleStart(const ModulePtr& p) } } } - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p)); return true; } @@ -2376,12 +2376,12 @@ SwiftGenerator::writeDispatchOperation(::IceInternal::Output& out, const Operati bool SwiftGenerator::MetadataVisitor::visitClassDefStart(const ClassDefPtr& p) { - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p)); for (const auto& member : p->dataMembers()) { // TODO we should probably be passing `member` instead of `member->type()`. // Otherwise I'm pretty sure we're just skipping the data-member metadata. - member->setMetadata(validate(member->type(), member->getMetadata(), p->file(), member->line())); + member->setMetadata(validate(member->type(), member)); } return true; } @@ -2389,27 +2389,27 @@ SwiftGenerator::MetadataVisitor::visitClassDefStart(const ClassDefPtr& p) bool SwiftGenerator::MetadataVisitor::visitInterfaceDefStart(const InterfaceDefPtr& p) { - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p)); return true; } void SwiftGenerator::MetadataVisitor::visitOperation(const OperationPtr& p) { - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p)); for (const auto& param : p->parameters()) { - param->setMetadata(validate(param->type(), param->getMetadata(), param->file(), param->line())); + param->setMetadata(validate(param->type(), param)); } } bool SwiftGenerator::MetadataVisitor::visitExceptionStart(const ExceptionPtr& p) { - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p)); for (const auto& member : p->dataMembers()) { - member->setMetadata(validate(member->type(), member->getMetadata(), member->file(), member->line())); + member->setMetadata(validate(member->type(), member)); } return true; } @@ -2417,10 +2417,10 @@ SwiftGenerator::MetadataVisitor::visitExceptionStart(const ExceptionPtr& p) bool SwiftGenerator::MetadataVisitor::visitStructStart(const StructPtr& p) { - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p)); for (const auto& member : p->dataMembers()) { - member->setMetadata(validate(member->type(), member->getMetadata(), member->file(), member->line())); + member->setMetadata(validate(member->type(), member)); } return true; } @@ -2428,7 +2428,7 @@ SwiftGenerator::MetadataVisitor::visitStructStart(const StructPtr& p) void SwiftGenerator::MetadataVisitor::visitSequence(const SequencePtr& p) { - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p)); } void @@ -2444,7 +2444,7 @@ SwiftGenerator::MetadataVisitor::visitDictionary(const DictionaryPtr& p) { ostringstream msg; msg << "ignoring invalid metadata '" << *metadata << "' for dictionary key type"; - dc->warning(InvalidMetadata, p->file(), p->line(), msg.str()); + dc->warning(InvalidMetadata, metadata->file(), metadata->line(), msg.str()); } } @@ -2454,40 +2454,36 @@ SwiftGenerator::MetadataVisitor::visitDictionary(const DictionaryPtr& p) { ostringstream msg; msg << "ignoring invalid metadata '" << *metadata << "' for dictionary value type"; - dc->warning(InvalidMetadata, p->file(), p->line(), msg.str()); + dc->warning(InvalidMetadata, metadata->file(), metadata->line(), msg.str()); } } - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p)); } void SwiftGenerator::MetadataVisitor::visitEnum(const EnumPtr& p) { - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p)); } void SwiftGenerator::MetadataVisitor::visitConst(const ConstPtr& p) { - p->setMetadata(validate(p, p->getMetadata(), p->file(), p->line())); + p->setMetadata(validate(p, p)); } MetadataList -SwiftGenerator::MetadataVisitor::validate( - const SyntaxTreeBasePtr& cont, - const MetadataList& metadata, - const string& file, - int line) +SwiftGenerator::MetadataVisitor::validate(const SyntaxTreeBasePtr& p, const ContainedPtr& cont) { - MetadataList newMetadata = metadata; - const UnitPtr ut = cont->unit(); - const DefinitionContextPtr dc = ut->findDefinitionContext(file); + MetadataList newMetadata = cont->getMetadata(); + const UnitPtr ut = p->unit(); + const DefinitionContextPtr dc = ut->findDefinitionContext(cont->file()); assert(dc); - for (MetadataList::const_iterator p = newMetadata.begin(); p != newMetadata.end();) + for (MetadataList::const_iterator m = newMetadata.begin(); m != newMetadata.end();) { - MetadataPtr meta = *p++; + MetadataPtr meta = *m++; string_view directive = meta->directive(); string_view arguments = meta->arguments(); @@ -2496,18 +2492,18 @@ SwiftGenerator::MetadataVisitor::validate( continue; } - if (dynamic_pointer_cast(cont) && directive == "swift:module" && !arguments.empty()) + if (dynamic_pointer_cast(p) && directive == "swift:module" && !arguments.empty()) { continue; } - if (dynamic_pointer_cast(cont) && directive == "swift:inherits" && !arguments.empty()) + if (dynamic_pointer_cast(p) && directive == "swift:inherits" && !arguments.empty()) { continue; } - if ((dynamic_pointer_cast(cont) || dynamic_pointer_cast(cont) || - dynamic_pointer_cast(cont) || dynamic_pointer_cast(cont)) && + if ((dynamic_pointer_cast(p) || dynamic_pointer_cast(p) || + dynamic_pointer_cast(p) || dynamic_pointer_cast(p)) && directive == "swift:attribute" && !arguments.empty()) { continue; @@ -2515,7 +2511,7 @@ SwiftGenerator::MetadataVisitor::validate( ostringstream msg; msg << "ignoring invalid metadata '" << *meta << "'"; - dc->warning(InvalidMetadata, file, line, msg.str()); + dc->warning(InvalidMetadata, meta->file(), meta->line(), msg.str()); newMetadata.remove(meta); continue; } diff --git a/cpp/src/slice2swift/SwiftUtil.h b/cpp/src/slice2swift/SwiftUtil.h index 184470ee1ae..d0d8e4c2268 100644 --- a/cpp/src/slice2swift/SwiftUtil.h +++ b/cpp/src/slice2swift/SwiftUtil.h @@ -159,7 +159,7 @@ namespace Slice bool shouldVisitIncludedDefinitions() const final { return true; } private: - MetadataList validate(const SyntaxTreeBasePtr&, const MetadataList&, const std::string&, int); + MetadataList validate(const SyntaxTreeBasePtr&, const ContainedPtr&); typedef std::map ModuleMap; typedef std::map ModulePrefix; diff --git a/cpp/test/Ice/admin/TestI.cpp b/cpp/test/Ice/admin/TestI.cpp index 2044267df3c..a7486c718f7 100644 --- a/cpp/test/Ice/admin/TestI.cpp +++ b/cpp/test/Ice/admin/TestI.cpp @@ -28,7 +28,7 @@ namespace string getPrefix() final { return "NullLogger"; } - LoggerPtr cloneWithPrefix(const string&) final { return shared_from_this(); } + LoggerPtr cloneWithPrefix(string) final { return shared_from_this(); } }; } diff --git a/cpp/test/Ice/ami/AllTests.cpp b/cpp/test/Ice/ami/AllTests.cpp index d3e871c1830..6c2e5878af2 100644 --- a/cpp/test/Ice/ami/AllTests.cpp +++ b/cpp/test/Ice/ami/AllTests.cpp @@ -1258,26 +1258,31 @@ allTests(TestHelper* helper, bool collocated) if (p->ice_getConnection()) { - cout << "testing back pressure... " << flush; + if (p->supportsBackPressureTests()) { - // Keep the 3 server thread pool threads busy. - auto sleep1Future = p->sleepAsync(1000); - auto sleep2Future = p->sleepAsync(1000); - auto sleep3Future = p->sleepAsync(1000); - - auto onewayProxy = Ice::uncheckedCast(p->ice_oneway()); - - // Sending should block because the TCP send/receive buffer size on the server is set to 50KB. - Ice::ByteSeq seq; - seq.resize(768 * 1024); - auto future = onewayProxy->opWithPayloadAsync(seq); - - test(future.wait_for(200ms) == future_status::timeout && sleep1Future.wait_for(0s) != future_status::ready); - sleep1Future.wait(); - sleep2Future.wait(); - sleep3Future.wait(); + cout << "testing back pressure... " << flush; + { + // Keep the 3 server thread pool threads busy. + auto sleep1Future = p->sleepAsync(1000); + auto sleep2Future = p->sleepAsync(1000); + auto sleep3Future = p->sleepAsync(1000); + + auto onewayProxy = Ice::uncheckedCast(p->ice_oneway()); + + // Sending should block because the TCP send/receive buffer size on the server is set to 50KB. + Ice::ByteSeq seq; + seq.resize(768 * 1024); + auto future = onewayProxy->opWithPayloadAsync(seq); + + test( + future.wait_for(200ms) == future_status::timeout && + sleep1Future.wait_for(0s) != future_status::ready); + sleep1Future.wait(); + sleep2Future.wait(); + sleep3Future.wait(); + } + cout << "ok" << endl; } - cout << "ok" << endl; cout << "testing bi-dir... " << flush; auto adapter = communicator->createObjectAdapter(""); diff --git a/cpp/test/Ice/ami/Test.ice b/cpp/test/Ice/ami/Test.ice index 652ee536132..040f7675503 100644 --- a/cpp/test/Ice/ami/Test.ice +++ b/cpp/test/Ice/ami/Test.ice @@ -43,6 +43,7 @@ interface TestIntf bool supportsAMD(); bool supportsFunctionalTests(); + bool supportsBackPressureTests(); ["amd"] void pingBiDir(PingReply* reply); } diff --git a/cpp/test/Ice/ami/TestI.cpp b/cpp/test/Ice/ami/TestI.cpp index b19827ffe1e..c6c33b8686f 100644 --- a/cpp/test/Ice/ami/TestI.cpp +++ b/cpp/test/Ice/ami/TestI.cpp @@ -172,6 +172,12 @@ TestIntfI::supportsFunctionalTests(const Ice::Current&) return false; } +bool +TestIntfI::supportsBackPressureTests(const Ice::Current&) +{ + return true; +} + void TestIntfI::pingBiDirAsync( optional reply, diff --git a/cpp/test/Ice/ami/TestI.h b/cpp/test/Ice/ami/TestI.h index 315087e956e..89152b63b9b 100644 --- a/cpp/test/Ice/ami/TestI.h +++ b/cpp/test/Ice/ami/TestI.h @@ -46,6 +46,7 @@ class TestIntfI final : public Test::TestIntf bool supportsAMD(const Ice::Current&) final; bool supportsFunctionalTests(const Ice::Current&) final; + bool supportsBackPressureTests(const Ice::Current&) final; void pingBiDirAsync( std::optional, diff --git a/cpp/test/Ice/binding/Server.cpp b/cpp/test/Ice/binding/Server.cpp index da93372a512..ca8df603d1a 100644 --- a/cpp/test/Ice/binding/Server.cpp +++ b/cpp/test/Ice/binding/Server.cpp @@ -14,20 +14,15 @@ namespace // A no-op Logger, used when testing the Logger Admin // - class NullLogger : public Ice::Logger, public std::enable_shared_from_this + class NullLogger final : public Ice::Logger, public std::enable_shared_from_this { public: - virtual void print(const string&) {} - - virtual void trace(const string&, const string&) {} - - virtual void warning(const string&) {} - - virtual void error(const string&) {} - - virtual string getPrefix() { return "NullLogger"; } - - virtual Ice::LoggerPtr cloneWithPrefix(const string&) { return shared_from_this(); } + void print(const string&) final {} + void trace(const string&, const string&) final {} + void warning(const string&) final {} + void error(const string&) final {} + string getPrefix() final { return "NullLogger"; } + Ice::LoggerPtr cloneWithPrefix(string) final { return shared_from_this(); } }; } diff --git a/cpp/test/IceBox/configuration/config.icebox2 b/cpp/test/IceBox/configuration/config.icebox2 index 56b137cf492..3c3df857eef 100644 --- a/cpp/test/IceBox/configuration/config.icebox2 +++ b/cpp/test/IceBox/configuration/config.icebox2 @@ -3,7 +3,6 @@ Ice.Admin.Endpoints=default -p 9996 -h 127.0.0.1 Ice.ProgramName=IceBox2 IceBox.InheritProperties=1 - TestInheritProperties=1 ServerProp=1 diff --git a/cpp/test/Slice/errorDetection/ConstDef.err b/cpp/test/Slice/errorDetection/ConstDef.err index 3188d5f65d8..9a1e8e244c5 100644 --- a/cpp/test/Slice/errorDetection/ConstDef.err +++ b/cpp/test/Slice/errorDetection/ConstDef.err @@ -22,7 +22,7 @@ ConstDef.ice:118: initializer `256' for constant `b4' out of range for type byte ConstDef.ice:130: initializer `32767' for constant `c5' out of range for type byte ConstDef.ice:131: initializer `2147483647' for constant `c6' out of range for type short ConstDef.ice:132: initializer `9223372036854775807' for constant `c7' out of range for type int -ConstDef.ice:143: warning: unknown escape sequence in string literal: `\g' +ConstDef.ice:143: warning: unknown escape sequence in string literal: '\g' ConstDef.ice:144: unknown escape sequence in string literal: `\u000N' ConstDef.ice:145: unknown escape sequence in string literal: `\U0000000K' ConstDef.ice:146: octal escape sequence out of range: `\455' diff --git a/cpp/test/Slice/errorDetection/WarningInvalidMetadata.err b/cpp/test/Slice/errorDetection/WarningInvalidMetadata.err index efd49bc27d4..35d855bc865 100644 --- a/cpp/test/Slice/errorDetection/WarningInvalidMetadata.err +++ b/cpp/test/Slice/errorDetection/WarningInvalidMetadata.err @@ -1,21 +1,21 @@ -WarningInvalidMetadata.ice: warning: ignoring invalid file metadata 'cpp:header-ext:hh': directive can appear only once per file -WarningInvalidMetadata.ice: warning: ignoring invalid file metadata 'cpp:source-ext:cc': directive can appear only once per file -WarningInvalidMetadata.ice: warning: ignoring invalid file metadata 'cpp:dll-export:Test': directive can appear only once per file -WarningInvalidMetadata.ice: warning: ignoring invalid file metadata 'cpp:header-ext' -WarningInvalidMetadata.ice: warning: ignoring invalid file metadata 'cpp:header-ext' -WarningInvalidMetadata.ice: warning: ignoring invalid file metadata 'cpp:source-ext' -WarningInvalidMetadata.ice: warning: ignoring invalid file metadata 'cpp:source-ext' -WarningInvalidMetadata.ice: warning: ignoring invalid file metadata 'cpp:dll-export' -WarningInvalidMetadata.ice: warning: ignoring invalid file metadata 'cpp:dll-export' -WarningInvalidMetadata.ice: warning: ignoring invalid file metadata 'cpp:include' -WarningInvalidMetadata.ice: warning: ignoring invalid file metadata 'cpp:include' -WarningInvalidMetadata.ice:35: warning: ignoring invalid metadata 'cpp:type:std::list<::std::string>' for operation with void return type -WarningInvalidMetadata.ice:38: warning: ignoring invalid metadata 'cpp:array' for operation with void return type +WarningInvalidMetadata.ice:6: warning: ignoring invalid file metadata 'cpp:header-ext:hh': directive can appear only once per file +WarningInvalidMetadata.ice:9: warning: ignoring invalid file metadata 'cpp:source-ext:cc': directive can appear only once per file +WarningInvalidMetadata.ice:12: warning: ignoring invalid file metadata 'cpp:dll-export:Test': directive can appear only once per file +WarningInvalidMetadata.ice:14: warning: ignoring invalid file metadata 'cpp:header-ext' +WarningInvalidMetadata.ice:15: warning: ignoring invalid file metadata 'cpp:header-ext' +WarningInvalidMetadata.ice:17: warning: ignoring invalid file metadata 'cpp:source-ext' +WarningInvalidMetadata.ice:18: warning: ignoring invalid file metadata 'cpp:source-ext' +WarningInvalidMetadata.ice:20: warning: ignoring invalid file metadata 'cpp:dll-export' +WarningInvalidMetadata.ice:21: warning: ignoring invalid file metadata 'cpp:dll-export' +WarningInvalidMetadata.ice:23: warning: ignoring invalid file metadata 'cpp:include' +WarningInvalidMetadata.ice:24: warning: ignoring invalid file metadata 'cpp:include' +WarningInvalidMetadata.ice:34: warning: ignoring invalid metadata 'cpp:type:std::list<::std::string>' for operation with void return type +WarningInvalidMetadata.ice:37: warning: ignoring invalid metadata 'cpp:array' for operation with void return type WarningInvalidMetadata.ice:40: warning: ignoring invalid metadata 'cpp:type:my_string' WarningInvalidMetadata.ice:42: warning: ignoring invalid metadata 'cpp:view-type:my_string' -WarningInvalidMetadata.ice:47: warning: ignoring invalid metadata 'cpp:const' -WarningInvalidMetadata.ice:47: warning: ignoring invalid metadata 'cpp:ice_print' -WarningInvalidMetadata.ice:53: warning: ignoring invalid metadata 'cpp:virtual' -WarningInvalidMetadata.ice:58: warning: ignoring invalid metadata 'cpp:bad' -WarningInvalidMetadata.ice:63: warning: ignoring invalid metadata 'cpp98:foo' -WarningInvalidMetadata.ice:63: warning: ignoring invalid metadata 'cpp11:bar' +WarningInvalidMetadata.ice:45: warning: ignoring invalid metadata 'cpp:const' +WarningInvalidMetadata.ice:45: warning: ignoring invalid metadata 'cpp:ice_print' +WarningInvalidMetadata.ice:51: warning: ignoring invalid metadata 'cpp:virtual' +WarningInvalidMetadata.ice:56: warning: ignoring invalid metadata 'cpp:bad' +WarningInvalidMetadata.ice:61: warning: ignoring invalid metadata 'cpp98:foo' +WarningInvalidMetadata.ice:61: warning: ignoring invalid metadata 'cpp11:bar' diff --git a/csharp/src/Ice/Internal/Property.cs b/csharp/src/Ice/Internal/Property.cs index 7c814b6c616..9e936d7a6f9 100644 --- a/csharp/src/Ice/Internal/Property.cs +++ b/csharp/src/Ice/Internal/Property.cs @@ -4,7 +4,7 @@ namespace Ice.Internal; -internal sealed record class PropertyArray(string name, bool prefixOnly, Property[] properties); +internal sealed record class PropertyArray(string name, bool prefixOnly, bool isOptIn, Property[] properties); internal sealed record class Property( string pattern, diff --git a/csharp/src/Ice/Internal/PropertyNames.cs b/csharp/src/Ice/Internal/PropertyNames.cs index 20687886313..ef29433c5ec 100644 --- a/csharp/src/Ice/Internal/PropertyNames.cs +++ b/csharp/src/Ice/Internal/PropertyNames.cs @@ -11,6 +11,7 @@ internal sealed class PropertyNames internal static PropertyArray ProxyProps = new( "Proxy", false, + false, [ new(pattern: @"EndpointSelection", usesRegex: false, defaultValue: "", deprecated: false, propertyArray: null), new(pattern: @"ConnectionCached", usesRegex: false, defaultValue: "", deprecated: false, propertyArray: null), @@ -26,6 +27,7 @@ internal sealed class PropertyNames internal static PropertyArray ConnectionProps = new( "Connection", true, + false, [ new(pattern: @"CloseTimeout", usesRegex: false, defaultValue: "10", deprecated: false, propertyArray: null), new(pattern: @"ConnectTimeout", usesRegex: false, defaultValue: "10", deprecated: false, propertyArray: null), @@ -38,6 +40,7 @@ internal sealed class PropertyNames internal static PropertyArray ThreadPoolProps = new( "ThreadPool", true, + false, [ new(pattern: @"Size", usesRegex: false, defaultValue: "1", deprecated: false, propertyArray: null), new(pattern: @"SizeMax", usesRegex: false, defaultValue: "", deprecated: false, propertyArray: null), @@ -51,6 +54,7 @@ internal sealed class PropertyNames internal static PropertyArray ObjectAdapterProps = new( "ObjectAdapter", true, + false, [ new(pattern: @"AdapterId", usesRegex: false, defaultValue: "", deprecated: false, propertyArray: null), new(pattern: @"Connection", usesRegex: false, defaultValue: "", deprecated: false, propertyArray: ConnectionProps), @@ -69,11 +73,13 @@ internal sealed class PropertyNames internal static PropertyArray LMDBProps = new( "LMDB", true, + false, []); internal static PropertyArray IceProps = new( "Ice", false, + false, [ new(pattern: @"AcceptClassCycles", usesRegex: false, defaultValue: "0", deprecated: false, propertyArray: null), new(pattern: @"Admin", usesRegex: false, defaultValue: "", deprecated: false, propertyArray: ObjectAdapterProps), @@ -158,6 +164,7 @@ internal sealed class PropertyNames internal static PropertyArray IceMXProps = new( "IceMX", false, + false, [ new(pattern: @"^Metrics\.[^\s]+\.GroupBy$", usesRegex: true, defaultValue: "", deprecated: false, propertyArray: null), new(pattern: @"^Metrics\.[^\s]+\.Map$", usesRegex: true, defaultValue: "", deprecated: false, propertyArray: null), @@ -170,6 +177,7 @@ internal sealed class PropertyNames internal static PropertyArray IceDiscoveryProps = new( "IceDiscovery", false, + false, [ new(pattern: @"Multicast", usesRegex: false, defaultValue: "", deprecated: false, propertyArray: ObjectAdapterProps), new(pattern: @"Reply", usesRegex: false, defaultValue: "", deprecated: false, propertyArray: ObjectAdapterProps), @@ -187,6 +195,7 @@ internal sealed class PropertyNames internal static PropertyArray IceLocatorDiscoveryProps = new( "IceLocatorDiscovery", false, + false, [ new(pattern: @"Reply", usesRegex: false, defaultValue: "", deprecated: false, propertyArray: ObjectAdapterProps), new(pattern: @"Locator", usesRegex: false, defaultValue: "", deprecated: false, propertyArray: ObjectAdapterProps), @@ -204,6 +213,7 @@ internal sealed class PropertyNames internal static PropertyArray IceBoxProps = new( "IceBox", false, + true, [ new(pattern: @"InheritProperties", usesRegex: false, defaultValue: "", deprecated: false, propertyArray: null), new(pattern: @"LoadOrder", usesRegex: false, defaultValue: "", deprecated: false, propertyArray: null), @@ -216,26 +226,31 @@ internal sealed class PropertyNames internal static PropertyArray IceBoxAdminProps = new( "IceBoxAdmin", false, + true, []); internal static PropertyArray IceBridgeProps = new( "IceBridge", false, + true, []); internal static PropertyArray IceGridAdminProps = new( "IceGridAdmin", false, + true, []); internal static PropertyArray IceGridProps = new( "IceGrid", false, + true, []); internal static PropertyArray IceSSLProps = new( "IceSSL", false, + false, [ new(pattern: @"CAs", usesRegex: false, defaultValue: "", deprecated: false, propertyArray: null), new(pattern: @"CertStore", usesRegex: false, defaultValue: "My", deprecated: false, propertyArray: null), @@ -258,26 +273,31 @@ internal sealed class PropertyNames internal static PropertyArray IceStormProps = new( "IceStorm", false, + true, []); internal static PropertyArray IceStormAdminProps = new( "IceStormAdmin", false, + true, []); internal static PropertyArray IceBTProps = new( "IceBT", false, + false, []); internal static PropertyArray Glacier2Props = new( "Glacier2", false, + true, []); internal static PropertyArray DataStormProps = new( "DataStorm", false, + true, []); internal static PropertyArray[] validProps = diff --git a/csharp/src/Ice/ObjectAdapter.cs b/csharp/src/Ice/ObjectAdapter.cs index b52fe2d16ab..14e98081440 100644 --- a/csharp/src/Ice/ObjectAdapter.cs +++ b/csharp/src/Ice/ObjectAdapter.cs @@ -765,7 +765,6 @@ public void setLocator(LocatorPrx? locator) { lock (_mutex) { - checkForDeactivation(); return _locatorInfo?.getLocator(); } } diff --git a/csharp/src/Ice/Properties.cs b/csharp/src/Ice/Properties.cs index 365d0f919f9..f17df2b4119 100644 --- a/csharp/src/Ice/Properties.cs +++ b/csharp/src/Ice/Properties.cs @@ -37,6 +37,8 @@ public Properties() { } + public Properties(List optInPrefixes) => _optInPrefixes = optInPrefixes; + /// /// Initializes a new instance of the class. The property set is initialized from the /// provided argument vector. @@ -55,6 +57,8 @@ public Properties(ref string[] args, Properties? defaults = null) { _properties[entry.Key] = entry.Value.Clone(); } + + _optInPrefixes.AddRange(defaults._optInPrefixes); } if (_properties.TryGetValue("Ice.ProgramName", out PropertyValue? pv)) @@ -324,6 +328,12 @@ public void setProperty(string key, string value) // Check if the property is in an Ice property prefix. If so, check that it's a valid property. if (findIcePropertyArray(key) is PropertyArray propertyArray) { + if (propertyArray.isOptIn && !_optInPrefixes.Contains(propertyArray.name)) + { + throw new PropertyException( + $"Unable to set '{key}': property prefix '{propertyArray.name}' is opt-in and must be explicitly enabled"); + } + Property prop = findProperty(key[(propertyArray.name.Length + 1)..], propertyArray) ?? throw new PropertyException($"unknown Ice property: {key}"); // If the property is deprecated, log a warning. @@ -842,5 +852,6 @@ private void loadConfig() } private readonly Dictionary _properties = []; + private readonly List _optInPrefixes = []; private readonly object _mutex = new(); } diff --git a/csharp/src/IceBoxNet/Server.cs b/csharp/src/IceBoxNet/Server.cs index 6e5634efdbc..9cb67460575 100644 --- a/csharp/src/IceBoxNet/Server.cs +++ b/csharp/src/IceBoxNet/Server.cs @@ -55,7 +55,7 @@ public static int Main(string[] args) int status = 0; Ice.InitializationData initData = new Ice.InitializationData(); - initData.properties = new Ice.Properties(); + initData.properties = new Ice.Properties(["IceBox"]); initData.properties.setProperty("Ice.Admin.DelayCreation", "1"); try diff --git a/csharp/src/IceBoxNet/ServiceManagerI.cs b/csharp/src/IceBoxNet/ServiceManagerI.cs index 22576920e50..4cd3252fed5 100644 --- a/csharp/src/IceBoxNet/ServiceManagerI.cs +++ b/csharp/src/IceBoxNet/ServiceManagerI.cs @@ -896,21 +896,20 @@ public StartServiceInfo(string service, string value, string[] serverArgs) private Ice.Properties createServiceProperties(string service) { - Ice.Properties properties; + var properties = new Ice.Properties(); Ice.Properties communicatorProperties = _communicator.getProperties(); if (communicatorProperties.getIcePropertyAsInt("IceBox.InheritProperties") > 0) { - properties = communicatorProperties.Clone(); - // Inherit all except Ice.Admin.xxx properties - foreach (string p in properties.getPropertiesForPrefix("Ice.Admin.").Keys) + // Inherit all except IceBox. and Ice.Admin. properties + foreach (var property in communicatorProperties.getPropertiesForPrefix("")) { - properties.setProperty(p, ""); + if (!property.Key.StartsWith("IceBox.", StringComparison.Ordinal) && + !property.Key.StartsWith("Ice.Admin.", StringComparison.Ordinal)) + { + properties.setProperty(property.Key, property.Value); + } } } - else - { - properties = new Ice.Properties(); - } string programName = communicatorProperties.getIceProperty("Ice.ProgramName"); if (programName.Length == 0) diff --git a/csharp/test/Ice/ami/AllTests.cs b/csharp/test/Ice/ami/AllTests.cs index f845076637b..3b702bc1819 100644 --- a/csharp/test/Ice/ami/AllTests.cs +++ b/csharp/test/Ice/ami/AllTests.cs @@ -896,34 +896,37 @@ public static async Task allTestsAsync(global::Test.TestHelper helper, bool coll } output.WriteLine("ok"); - output.Write("testing back pressure... "); - output.Flush(); + if (p.supportsBackPressureTests()) { - // Keep the 3 server thread pool threads busy. - Task sleep1Task = p.sleepAsync(1000); - Task sleep2Task = p.sleepAsync(1000); - Task sleep3Task = p.sleepAsync(1000); - bool canceled = false; - using var cts = new CancellationTokenSource(200); - try + output.Write("testing back pressure... "); + output.Flush(); { - var onewayProxy = (Test.TestIntfPrx)p.ice_oneway(); + // Keep the 3 server thread pool threads busy. + Task sleep1Task = p.sleepAsync(1000); + Task sleep2Task = p.sleepAsync(1000); + Task sleep3Task = p.sleepAsync(1000); + bool canceled = false; + using var cts = new CancellationTokenSource(200); + try + { + var onewayProxy = (Test.TestIntfPrx)p.ice_oneway(); - // Sending should be canceled because the TCP send/receive buffer size on the server is set - // to 50KB. Note: we don't use the cancel parameter of the operation here because the - // cancellation doesn't cancel the operation whose payload is being sent. - await onewayProxy.opWithPayloadAsync(new byte[768 * 1024]).WaitAsync(cts.Token); - } - catch (OperationCanceledException) - { - canceled = true; + // Sending should be canceled because the TCP send/receive buffer size on the server is set + // to 50KB. Note: we don't use the cancel parameter of the operation here because the + // cancellation doesn't cancel the operation whose payload is being sent. + await onewayProxy.opWithPayloadAsync(new byte[768 * 1024]).WaitAsync(cts.Token); + } + catch (OperationCanceledException) + { + canceled = true; + } + test(canceled && !sleep1Task.IsCompleted); + await sleep1Task; + await sleep2Task; + await sleep3Task; } - test(canceled && !sleep1Task.IsCompleted); - await sleep1Task; - await sleep2Task; - await sleep3Task; + output.WriteLine("ok"); } - output.WriteLine("ok"); p.shutdown(); } diff --git a/csharp/test/Ice/ami/Test.ice b/csharp/test/Ice/ami/Test.ice index 095f815b45c..4bafec2996e 100644 --- a/csharp/test/Ice/ami/Test.ice +++ b/csharp/test/Ice/ami/Test.ice @@ -40,6 +40,7 @@ interface TestIntf bool supportsAMD(); bool supportsFunctionalTests(); + bool supportsBackPressureTests(); ["amd"] void opAsyncDispatch(); ["amd"] int opWithResultAsyncDispatch(); diff --git a/csharp/test/Ice/ami/TestI.cs b/csharp/test/Ice/ami/TestI.cs index 2bd7825e29b..d4f9dba2b44 100644 --- a/csharp/test/Ice/ami/TestI.cs +++ b/csharp/test/Ice/ami/TestI.cs @@ -121,6 +121,12 @@ public override bool return false; } + public override bool + supportsBackPressureTests(Ice.Current current) + { + return true; + } + public override async Task opAsyncDispatchAsync(Ice.Current current) { @@ -174,7 +180,7 @@ public override Task { if (_shutdown) { - // Ignore, this can occur with the forcefull connection close test, shutdown can be dispatch + // Ignore, this can occur with the forceful connection close test, shutdown can be dispatch // before start dispatch. var v = new TaskCompletionSource(); v.SetResult(null); diff --git a/csharp/test/Ice/properties/Client.cs b/csharp/test/Ice/properties/Client.cs index c699b211711..784e3e385dc 100644 --- a/csharp/test/Ice/properties/Client.cs +++ b/csharp/test/Ice/properties/Client.cs @@ -164,6 +164,18 @@ public override void run(string[] args) } Console.Out.WriteLine("ok"); + + Console.Out.Write("testing that setting a property in an opt-in prefix that is not configured throws an exception..."); + Console.Out.Flush(); + try + { + properties.setProperty("IceGrid.InstanceName", "TestGrid"); + test(false); + } + catch (Ice.PropertyException) + { + } + Console.Out.WriteLine("ok"); } } diff --git a/csharp/test/IceBox/configuration/AllTests.cs b/csharp/test/IceBox/configuration/AllTests.cs index 9e689be4a8c..d9867a15c0a 100644 --- a/csharp/test/IceBox/configuration/AllTests.cs +++ b/csharp/test/IceBox/configuration/AllTests.cs @@ -16,7 +16,7 @@ public static void allTests(Test.TestHelper helper) TestIntfPrx service4 = TestIntfPrxHelper.uncheckedCast(communicator.stringToProxy("test:" + helper.getTestEndpoint(3))); - if (service1.getProperty("IceBox.InheritProperties").Length == 0) + if (service1.getProperty("TestInheritProperties").Length == 0) { Console.Out.Write("testing service properties... "); Console.Out.Flush(); @@ -33,7 +33,6 @@ public static void allTests(Test.TestHelper helper) test(service2.getProperty("Ice.ProgramName") == "Test"); test(service2.getProperty("Service") == "2"); test(service2.getProperty("Service1.ArgProp").Length == 0); - test(service2.getProperty("IceBox.InheritProperties") == "1"); string[] args2 = { "--Service1.ArgProp=1" }; test(Enumerable.SequenceEqual(service2.getArgs(), args2)); diff --git a/csharp/test/IceBox/configuration/config.icebox b/csharp/test/IceBox/configuration/config.icebox index e290f851fca..22cb86f8636 100644 --- a/csharp/test/IceBox/configuration/config.icebox +++ b/csharp/test/IceBox/configuration/config.icebox @@ -3,7 +3,7 @@ Ice.Admin.Endpoints=default -p 9996 -h 127.0.0.1 Ice.ProgramName=IceBox IceBox.Service.Service1=msbuild/testservice/net8.0/testservice.dll:TestServiceI --Ice.Config=config.service1 --Service1.ArgProp=1 --Service1.Ovrd=2 --Service1.Unset= -a --Arg=2 -IceBox.Service.Service2=msbuild/testservice/net8.0/testservice.dll:TestServiceI --Ice.Config=config.service2 --Service1.ArgProp=1 --IceBox.InheritProperties +IceBox.Service.Service2=msbuild/testservice/net8.0/testservice.dll:TestServiceI --Ice.Config=config.service2 --Service1.ArgProp=1 IceBox.UseSharedCommunicator.Service3=1 IceBox.Service.Service3=msbuild/testservice/net8.0/testservice.dll:TestServiceI --Ice.Config=config.service3 diff --git a/csharp/test/IceBox/configuration/config.icebox2 b/csharp/test/IceBox/configuration/config.icebox2 index 965a34ec0ae..a72b94e8b5d 100644 --- a/csharp/test/IceBox/configuration/config.icebox2 +++ b/csharp/test/IceBox/configuration/config.icebox2 @@ -3,6 +3,7 @@ Ice.Admin.Endpoints=default -p 9996 -h 127.0.0.1 Ice.ProgramName=IceBox2 IceBox.InheritProperties=1 +TestInheritProperties=1 ServerProp=1 OverrideMe=1 diff --git a/java/src/IceGridGUI/src/main/java/com/zeroc/IceGridGUI/Coordinator.java b/java/src/IceGridGUI/src/main/java/com/zeroc/IceGridGUI/Coordinator.java index be18fb4dc9c..b35ab6be9d0 100644 --- a/java/src/IceGridGUI/src/main/java/com/zeroc/IceGridGUI/Coordinator.java +++ b/java/src/IceGridGUI/src/main/java/com/zeroc/IceGridGUI/Coordinator.java @@ -29,6 +29,7 @@ import java.security.KeyStore.TrustedCertificateEntry; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; +import java.util.Collections; import java.util.Enumeration; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -2255,7 +2256,8 @@ public JFileChooser getSaveIceLogChooser() { private static com.zeroc.Ice.Properties createProperties( String[] args, java.util.List rArgs) { - com.zeroc.Ice.Properties properties = new com.zeroc.Ice.Properties(); + com.zeroc.Ice.Properties properties = + new com.zeroc.Ice.Properties(Collections.singletonList("IceGridAdmin")); // Disable retries properties.setProperty("Ice.RetryIntervals", "-1"); diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java index 1f6f516ba01..2da766ff0dc 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/ObjectAdapter.java @@ -863,7 +863,6 @@ public synchronized void setLocator(LocatorPrx locator) { * @see #setLocator */ public synchronized LocatorPrx getLocator() { - checkForDeactivation(); if (_locatorInfo == null) { return null; } else { diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/Properties.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/Properties.java index b78d79b028c..837e8c29e13 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/Properties.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/Properties.java @@ -29,6 +29,10 @@ public PropertyValue clone() { /** Creates a new empty property set. */ public Properties() {} + public Properties(java.util.List optInPrefixes) { + _optInPrefixes.addAll(optInPrefixes); + } + /** * Creates a property set initialized from an argument vector. * @@ -94,6 +98,8 @@ public Properties(String[] args, Properties defaults, java.util.List rem for (java.util.Map.Entry p : defaults._properties.entrySet()) { _properties.put(p.getKey(), p.getValue().clone()); } + + _optInPrefixes.addAll(defaults._optInPrefixes); } boolean loadConfigFiles = false; @@ -361,6 +367,17 @@ public void setProperty(String key, String value) { // property. PropertyArray propertyArray = findIcePropertyArray(key); if (propertyArray != null) { + if (propertyArray.isOptIn() + && _optInPrefixes.stream().noneMatch(propertyArray.name()::equals)) { + + throw new PropertyException( + "unable to set '" + + key + + "': property prefix '" + + propertyArray.name() + + "' is opt-in and must be explicitly enabled"); + } + Property prop = findProperty(key.substring(propertyArray.name().length() + 1), propertyArray); if (prop == null) { @@ -904,5 +921,6 @@ private static String getDefaultProperty(String key) { private static final int ParseStateKey = 0; private static final int ParseStateValue = 1; - private java.util.HashMap _properties = new java.util.HashMap<>(); + private final java.util.HashMap _properties = new java.util.HashMap<>(); + private final java.util.List _optInPrefixes = new java.util.ArrayList<>(); } diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/PropertyArray.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/PropertyArray.java index 1b33dd42c8b..2e485fc874d 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/PropertyArray.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/PropertyArray.java @@ -2,4 +2,4 @@ package com.zeroc.Ice; -record PropertyArray(String name, boolean prefixOnly, Property[] properties) {} +record PropertyArray(String name, boolean prefixOnly, boolean isOptIn, Property[] properties) {} diff --git a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/PropertyNames.java b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/PropertyNames.java index c69380e0492..bd30a6dfe40 100644 --- a/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/PropertyNames.java +++ b/java/src/com.zeroc.ice/src/main/java/com/zeroc/Ice/PropertyNames.java @@ -11,6 +11,7 @@ final class PropertyNames public static final PropertyArray ProxyProps = new PropertyArray( "Proxy", false, + false, new Property[] { new Property("EndpointSelection", false, "", false, null), new Property("ConnectionCached", false, "", false, null), @@ -26,6 +27,7 @@ final class PropertyNames public static final PropertyArray ConnectionProps = new PropertyArray( "Connection", true, + false, new Property[] { new Property("CloseTimeout", false, "10", false, null), new Property("ConnectTimeout", false, "10", false, null), @@ -38,6 +40,7 @@ final class PropertyNames public static final PropertyArray ThreadPoolProps = new PropertyArray( "ThreadPool", true, + false, new Property[] { new Property("Size", false, "1", false, null), new Property("SizeMax", false, "", false, null), @@ -51,6 +54,7 @@ final class PropertyNames public static final PropertyArray ObjectAdapterProps = new PropertyArray( "ObjectAdapter", true, + false, new Property[] { new Property("AdapterId", false, "", false, null), new Property("Connection", false, "", false, PropertyNames.ConnectionProps), @@ -69,12 +73,14 @@ final class PropertyNames public static final PropertyArray LMDBProps = new PropertyArray( "LMDB", true, + false, new Property[] { }); public static final PropertyArray IceProps = new PropertyArray( "Ice", false, + false, new Property[] { new Property("AcceptClassCycles", false, "0", false, null), new Property("Admin", false, "", false, PropertyNames.ObjectAdapterProps), @@ -163,6 +169,7 @@ final class PropertyNames public static final PropertyArray IceMXProps = new PropertyArray( "IceMX", false, + false, new Property[] { new Property("Metrics\\.[^\\s]+\\.GroupBy", true, "", false, null), new Property("Metrics\\.[^\\s]+\\.Map", true, "", false, null), @@ -175,6 +182,7 @@ final class PropertyNames public static final PropertyArray IceDiscoveryProps = new PropertyArray( "IceDiscovery", false, + false, new Property[] { new Property("Multicast", false, "", false, PropertyNames.ObjectAdapterProps), new Property("Reply", false, "", false, PropertyNames.ObjectAdapterProps), @@ -192,6 +200,7 @@ final class PropertyNames public static final PropertyArray IceLocatorDiscoveryProps = new PropertyArray( "IceLocatorDiscovery", false, + false, new Property[] { new Property("Reply", false, "", false, PropertyNames.ObjectAdapterProps), new Property("Locator", false, "", false, PropertyNames.ObjectAdapterProps), @@ -209,6 +218,7 @@ final class PropertyNames public static final PropertyArray IceBoxProps = new PropertyArray( "IceBox", false, + true, new Property[] { new Property("InheritProperties", false, "", false, null), new Property("LoadOrder", false, "", false, null), @@ -221,6 +231,7 @@ final class PropertyNames public static final PropertyArray IceBoxAdminProps = new PropertyArray( "IceBoxAdmin", false, + true, new Property[] { new Property("ServiceManager.Proxy", false, "", false, PropertyNames.ProxyProps) }); @@ -228,12 +239,14 @@ final class PropertyNames public static final PropertyArray IceBridgeProps = new PropertyArray( "IceBridge", false, + true, new Property[] { }); public static final PropertyArray IceGridAdminProps = new PropertyArray( "IceGridAdmin", false, + true, new Property[] { new Property("MetricsConfig", false, "", false, null), new Property("Trace.Observers", false, "", false, null), @@ -243,12 +256,14 @@ final class PropertyNames public static final PropertyArray IceGridProps = new PropertyArray( "IceGrid", false, + true, new Property[] { }); public static final PropertyArray IceSSLProps = new PropertyArray( "IceSSL", false, + false, new Property[] { new Property("Alias", false, "", false, null), new Property("CheckCertName", false, "0", false, null), @@ -272,18 +287,21 @@ final class PropertyNames public static final PropertyArray IceStormProps = new PropertyArray( "IceStorm", false, + true, new Property[] { }); public static final PropertyArray IceStormAdminProps = new PropertyArray( "IceStormAdmin", false, + true, new Property[] { }); public static final PropertyArray IceBTProps = new PropertyArray( "IceBT", false, + false, new Property[] { new Property("RcvSize", false, "", false, null), new Property("SndSize", false, "", false, null) @@ -292,12 +310,14 @@ final class PropertyNames public static final PropertyArray Glacier2Props = new PropertyArray( "Glacier2", false, + true, new Property[] { }); public static final PropertyArray DataStormProps = new PropertyArray( "DataStorm", false, + true, new Property[] { }); diff --git a/java/src/com.zeroc.icebox/src/main/java/com/zeroc/IceBox/Admin.java b/java/src/com.zeroc.icebox/src/main/java/com/zeroc/IceBox/Admin.java index 33c335e7f98..fa0444aa794 100644 --- a/java/src/com.zeroc.icebox/src/main/java/com/zeroc/IceBox/Admin.java +++ b/java/src/com.zeroc.icebox/src/main/java/com/zeroc/IceBox/Admin.java @@ -2,6 +2,8 @@ package com.zeroc.IceBox; +import java.util.Collections; + public final class Admin { private static void usage() { System.err.println( @@ -18,10 +20,14 @@ private static void usage() { public static void main(String[] args) { int status = 0; - java.util.List commands = new java.util.ArrayList(); + java.util.List commands = new java.util.ArrayList<>(); + + com.zeroc.Ice.InitializationData initData = new com.zeroc.Ice.InitializationData(); + initData.properties = + new com.zeroc.Ice.Properties(Collections.singletonList("IceBoxAdmin")); try (com.zeroc.Ice.Communicator communicator = - com.zeroc.Ice.Util.initialize(args, commands)) { + com.zeroc.Ice.Util.initialize(args, initData, commands)) { Runtime.getRuntime() .addShutdownHook( new Thread( diff --git a/java/src/com.zeroc.icebox/src/main/java/com/zeroc/IceBox/Server.java b/java/src/com.zeroc.icebox/src/main/java/com/zeroc/IceBox/Server.java index e9242066bf5..74a2ad99b91 100644 --- a/java/src/com.zeroc.icebox/src/main/java/com/zeroc/IceBox/Server.java +++ b/java/src/com.zeroc.icebox/src/main/java/com/zeroc/IceBox/Server.java @@ -2,6 +2,8 @@ package com.zeroc.IceBox; +import java.util.Collections; + public final class Server { static class ShutdownHook extends Thread { private com.zeroc.Ice.Communicator _communicator; @@ -80,10 +82,10 @@ private static int run(com.zeroc.Ice.Communicator communicator, java.util.List argSeq = new java.util.ArrayList(); + java.util.List argSeq = new java.util.ArrayList<>(); com.zeroc.Ice.InitializationData initData = new com.zeroc.Ice.InitializationData(); - initData.properties = new com.zeroc.Ice.Properties(); + initData.properties = new com.zeroc.Ice.Properties(Collections.singletonList("IceBox")); initData.properties.setProperty("Ice.Admin.DelayCreation", "1"); ShutdownHook shutdownHook = null; diff --git a/java/src/com.zeroc.icebox/src/main/java/com/zeroc/IceBox/ServiceManagerI.java b/java/src/com.zeroc.icebox/src/main/java/com/zeroc/IceBox/ServiceManagerI.java index 89c73a69c11..5c1d16795e8 100644 --- a/java/src/com.zeroc.icebox/src/main/java/com/zeroc/IceBox/ServiceManagerI.java +++ b/java/src/com.zeroc.icebox/src/main/java/com/zeroc/IceBox/ServiceManagerI.java @@ -799,16 +799,18 @@ static class StartServiceInfo { } private Properties createServiceProperties(String service) { - Properties properties; + Properties properties = new Properties(); Properties communicatorProperties = _communicator.getProperties(); if (communicatorProperties.getPropertyAsInt("IceBox.InheritProperties") > 0) { - properties = communicatorProperties._clone(); - // Inherit all except Ice.Admin.xxx properties - for (String p : properties.getPropertiesForPrefix("Ice.Admin.").keySet()) { - properties.setProperty(p, ""); + + // Inherit all except IceBox. and Ice.Admin. properties + for (java.util.Map.Entry p : + communicatorProperties.getPropertiesForPrefix("").entrySet()) { + String key = p.getKey(); + if (!key.startsWith("IceBox.") && !key.startsWith("Ice.Admin.")) { + properties.setProperty(key, p.getValue()); + } } - } else { - properties = new Properties(); } String programName = communicatorProperties.getProperty("Ice.ProgramName"); diff --git a/java/test/src/main/java/test/Ice/ami/AllTests.java b/java/test/src/main/java/test/Ice/ami/AllTests.java index c4b065391ae..db79a8e2511 100644 --- a/java/test/src/main/java/test/Ice/ami/AllTests.java +++ b/java/test/src/main/java/test/Ice/ami/AllTests.java @@ -1081,7 +1081,7 @@ public static void allTests(test.TestHelper helper, boolean collocated) { } out.println("ok"); - if (p.ice_getConnection() != null) { + if (p.ice_getConnection() != null && p.supportsBackPressureTests()) { out.print("testing back pressure... "); out.flush(); try { diff --git a/java/test/src/main/java/test/Ice/ami/Test.ice b/java/test/src/main/java/test/Ice/ami/Test.ice index aac507999fb..3b16ef126b8 100644 --- a/java/test/src/main/java/test/Ice/ami/Test.ice +++ b/java/test/src/main/java/test/Ice/ami/Test.ice @@ -39,6 +39,8 @@ interface TestIntf bool supportsAMD(); bool supportsFunctionalTests(); + bool supportsBackPressureTests(); + bool opBool(bool b); byte opByte(byte b); short opShort(short s); diff --git a/java/test/src/main/java/test/Ice/ami/TestI.java b/java/test/src/main/java/test/Ice/ami/TestI.java index 1822f17960c..3e629ddb457 100644 --- a/java/test/src/main/java/test/Ice/ami/TestI.java +++ b/java/test/src/main/java/test/Ice/ami/TestI.java @@ -61,6 +61,11 @@ public boolean supportsFunctionalTests(com.zeroc.Ice.Current current) { return true; } + @Override + public boolean supportsBackPressureTests(com.zeroc.Ice.Current current) { + return true; + } + @Override public boolean opBool(boolean b, com.zeroc.Ice.Current current) { return b; @@ -149,7 +154,7 @@ public void sleep(int ms, com.zeroc.Ice.Current current) { @Override public synchronized CompletionStage startDispatchAsync(com.zeroc.Ice.Current current) { if (_shutdown) { - // Ignore, this can occur with the forcefull connection close test, shutdown can be + // Ignore, this can occur with the forceful connection close test, shutdown can be // dispatch // before start dispatch. CompletableFuture v = new CompletableFuture<>(); diff --git a/java/test/src/main/java/test/Ice/properties/Client.java b/java/test/src/main/java/test/Ice/properties/Client.java index 9f45ce4a9f7..4b1534825a8 100644 --- a/java/test/src/main/java/test/Ice/properties/Client.java +++ b/java/test/src/main/java/test/Ice/properties/Client.java @@ -15,6 +15,7 @@ public static void test(boolean b) { } } + @Override public void run(String[] args) { { System.out.print("testing load properties from UTF-8 path... "); @@ -160,9 +161,20 @@ public void run(String[] args) { } catch (PropertyException ex) { } System.out.println("ok"); + + System.out.print( + "testing that setting a property in an opt-in prefix that is not configured" + + " throws an exception..."); + System.out.flush(); + try { + properties.setProperty("IceGrid.InstanceName", "TestGrid"); + test(false); + } catch (PropertyException ex) { + } + System.out.println("ok"); } } } - private static String configPath = "./config/\u4E2D\u56FD_client.config"; + private static final String configPath = "./config/\u4E2D\u56FD_client.config"; } diff --git a/java/test/src/main/java/test/IceBox/configuration/AllTests.java b/java/test/src/main/java/test/IceBox/configuration/AllTests.java index 3150d8e64ca..e5ebffc8a32 100644 --- a/java/test/src/main/java/test/IceBox/configuration/AllTests.java +++ b/java/test/src/main/java/test/IceBox/configuration/AllTests.java @@ -21,7 +21,7 @@ public static void allTests(test.TestHelper helper) { var service3 = TestIntfPrx.createProxy(communicator, "test:" + helper.getTestEndpoint(2)); var service4 = TestIntfPrx.createProxy(communicator, "test:" + helper.getTestEndpoint(3)); - if (service1.getProperty("IceBox.InheritProperties").isEmpty()) { + if (service1.getProperty("TestInheritProperties").isEmpty()) { out.print("testing service properties... "); out.flush(); @@ -37,7 +37,6 @@ public static void allTests(test.TestHelper helper) { test(service2.getProperty("Ice.ProgramName").equals("Test")); test(service2.getProperty("Service").equals("2")); test(service2.getProperty("Service1.ArgProp").isEmpty()); - test(service2.getProperty("IceBox.InheritProperties").equals("1")); String[] args2 = {"--Service1.ArgProp=1"}; test(java.util.Arrays.equals(service2.getArgs(), args2)); diff --git a/java/test/src/main/java/test/IceBox/configuration/config.icebox b/java/test/src/main/java/test/IceBox/configuration/config.icebox index 1dd4b90957c..c4ece8fb977 100644 --- a/java/test/src/main/java/test/IceBox/configuration/config.icebox +++ b/java/test/src/main/java/test/IceBox/configuration/config.icebox @@ -3,7 +3,7 @@ Ice.Admin.Endpoints=default -p 9996 -h 127.0.0.1 Ice.ProgramName=IceBox IceBox.Service.Service1=test.IceBox.configuration.TestServiceI --Ice.Config=config.service1 --Service1.ArgProp=1 --Service1.Ovrd=2 --Service1.Unset= -a --Arg=2 -IceBox.Service.Service2=test.IceBox.configuration.TestServiceI --Ice.Config=config.service2 --Service1.ArgProp=1 --IceBox.InheritProperties +IceBox.Service.Service2=test.IceBox.configuration.TestServiceI --Ice.Config=config.service2 --Service1.ArgProp=1 IceBox.UseSharedCommunicator.Service3=1 IceBox.Service.Service3=test.IceBox.configuration.TestServiceI --Ice.Config=config.service3 diff --git a/java/test/src/main/java/test/IceBox/configuration/config.icebox2 b/java/test/src/main/java/test/IceBox/configuration/config.icebox2 index 2866764f19f..4ee84ed963f 100644 --- a/java/test/src/main/java/test/IceBox/configuration/config.icebox2 +++ b/java/test/src/main/java/test/IceBox/configuration/config.icebox2 @@ -3,6 +3,7 @@ Ice.Admin.Endpoints=default -p 9996 -h 127.0.0.1 Ice.ProgramName=IceBox2 IceBox.InheritProperties=1 +TestInheritProperties=1 ServerProp=1 OverrideMe=1 diff --git a/js/src/Ice/Property.js b/js/src/Ice/Property.js index ea056e5099d..0e1bda2843d 100644 --- a/js/src/Ice/Property.js +++ b/js/src/Ice/Property.js @@ -11,9 +11,10 @@ export class Property { } export class PropertyArray { - constructor(name, prefixOnly, properties) { + constructor(name, prefixOnly, isOptIn, properties) { this.name = name; this.prefixOnly = prefixOnly; + this.isOptIn = isOptIn; this.properties = properties; } } diff --git a/js/src/Ice/PropertyNames.js b/js/src/Ice/PropertyNames.js index eaa1bca3e8c..e1bee7d57a5 100644 --- a/js/src/Ice/PropertyNames.js +++ b/js/src/Ice/PropertyNames.js @@ -8,7 +8,7 @@ import { Property, PropertyArray } from "./Property.js"; export const PropertyNames = {}; -PropertyNames.ProxyProps = new PropertyArray("Proxy", false); +PropertyNames.ProxyProps = new PropertyArray("Proxy", false, false); PropertyNames.ProxyProps.properties = [ new Property("EndpointSelection", false, "", false, null), new Property("ConnectionCached", false, "", false, null), @@ -20,7 +20,7 @@ PropertyNames.ProxyProps.properties = [ new Property(/^Context\../, true, "", false, null) ]; -PropertyNames.ConnectionProps = new PropertyArray("Connection", true); +PropertyNames.ConnectionProps = new PropertyArray("Connection", true, false); PropertyNames.ConnectionProps.properties = [ new Property("CloseTimeout", false, "10", false, null), new Property("ConnectTimeout", false, "10", false, null), @@ -29,11 +29,11 @@ PropertyNames.ConnectionProps.properties = [ new Property("InactivityTimeout", false, "300", false, null) ]; -PropertyNames.ThreadPoolProps = new PropertyArray("ThreadPool", true); +PropertyNames.ThreadPoolProps = new PropertyArray("ThreadPool", true, false); PropertyNames.ThreadPoolProps.properties = [ ]; -PropertyNames.ObjectAdapterProps = new PropertyArray("ObjectAdapter", true); +PropertyNames.ObjectAdapterProps = new PropertyArray("ObjectAdapter", true, false); PropertyNames.ObjectAdapterProps.properties = [ new Property("PublishedEndpoints", false, "", false, null), new Property("Router", false, "", false, PropertyNames.ProxyProps), @@ -41,11 +41,11 @@ PropertyNames.ObjectAdapterProps.properties = [ new Property("MessageSizeMax", false, "", false, null) ]; -PropertyNames.LMDBProps = new PropertyArray("LMDB", true); +PropertyNames.LMDBProps = new PropertyArray("LMDB", true, false); PropertyNames.LMDBProps.properties = [ ]; -PropertyNames.IceProps = new PropertyArray("Ice", false); +PropertyNames.IceProps = new PropertyArray("Ice", false, false); PropertyNames.IceProps.properties = [ new Property("BackgroundLocatorCacheUpdates", false, "0", false, null), new Property("BatchAutoFlush", false, "", true, null), @@ -79,59 +79,59 @@ PropertyNames.IceProps.properties = [ new Property("Warn.UnusedProperties", false, "0", false, null) ]; -PropertyNames.IceMXProps = new PropertyArray("IceMX", false); +PropertyNames.IceMXProps = new PropertyArray("IceMX", false, false); PropertyNames.IceMXProps.properties = [ ]; -PropertyNames.IceDiscoveryProps = new PropertyArray("IceDiscovery", false); +PropertyNames.IceDiscoveryProps = new PropertyArray("IceDiscovery", false, false); PropertyNames.IceDiscoveryProps.properties = [ ]; -PropertyNames.IceLocatorDiscoveryProps = new PropertyArray("IceLocatorDiscovery", false); +PropertyNames.IceLocatorDiscoveryProps = new PropertyArray("IceLocatorDiscovery", false, false); PropertyNames.IceLocatorDiscoveryProps.properties = [ ]; -PropertyNames.IceBoxProps = new PropertyArray("IceBox", false); +PropertyNames.IceBoxProps = new PropertyArray("IceBox", false, true); PropertyNames.IceBoxProps.properties = [ ]; -PropertyNames.IceBoxAdminProps = new PropertyArray("IceBoxAdmin", false); +PropertyNames.IceBoxAdminProps = new PropertyArray("IceBoxAdmin", false, true); PropertyNames.IceBoxAdminProps.properties = [ ]; -PropertyNames.IceBridgeProps = new PropertyArray("IceBridge", false); +PropertyNames.IceBridgeProps = new PropertyArray("IceBridge", false, true); PropertyNames.IceBridgeProps.properties = [ ]; -PropertyNames.IceGridAdminProps = new PropertyArray("IceGridAdmin", false); +PropertyNames.IceGridAdminProps = new PropertyArray("IceGridAdmin", false, true); PropertyNames.IceGridAdminProps.properties = [ ]; -PropertyNames.IceGridProps = new PropertyArray("IceGrid", false); +PropertyNames.IceGridProps = new PropertyArray("IceGrid", false, true); PropertyNames.IceGridProps.properties = [ ]; -PropertyNames.IceSSLProps = new PropertyArray("IceSSL", false); +PropertyNames.IceSSLProps = new PropertyArray("IceSSL", false, false); PropertyNames.IceSSLProps.properties = [ ]; -PropertyNames.IceStormProps = new PropertyArray("IceStorm", false); +PropertyNames.IceStormProps = new PropertyArray("IceStorm", false, true); PropertyNames.IceStormProps.properties = [ ]; -PropertyNames.IceStormAdminProps = new PropertyArray("IceStormAdmin", false); +PropertyNames.IceStormAdminProps = new PropertyArray("IceStormAdmin", false, true); PropertyNames.IceStormAdminProps.properties = [ ]; -PropertyNames.IceBTProps = new PropertyArray("IceBT", false); +PropertyNames.IceBTProps = new PropertyArray("IceBT", false, false); PropertyNames.IceBTProps.properties = [ ]; -PropertyNames.Glacier2Props = new PropertyArray("Glacier2", false); +PropertyNames.Glacier2Props = new PropertyArray("Glacier2", false, true); PropertyNames.Glacier2Props.properties = [ ]; -PropertyNames.DataStormProps = new PropertyArray("DataStorm", false); +PropertyNames.DataStormProps = new PropertyArray("DataStorm", false, true); PropertyNames.DataStormProps.properties = [ ]; diff --git a/man/man1/slice2py.1 b/man/man1/slice2py.1 index a589c4d78be..9c29922eb23 100644 --- a/man/man1/slice2py.1 +++ b/man/man1/slice2py.1 @@ -93,6 +93,16 @@ Generate code for all Slice definitions, including those from included files. .br Use PREFIX as the prefix for generated file names. +.TP +.BR \-\-no-package\fR +.br +Do not generate Python package hierarchy. + +.TP +.BR \-\-build-package\fR +.br +Only generate Python package hierarchy. + .SH SEE ALSO .BR slice2cpp (1), diff --git a/matlab/.gitignore b/matlab/.gitignore index 5b10f35ff6c..f5042a72765 100644 --- a/matlab/.gitignore +++ b/matlab/.gitignore @@ -5,3 +5,4 @@ lib/x86_64-linux-gnu/ toolbox/build toolbox/toolbox.prj toolbox/info.xml +config/result.json diff --git a/matlab/config/analyzer.json b/matlab/config/analyzer.json new file mode 100644 index 00000000000..7974e5604dc --- /dev/null +++ b/matlab/config/analyzer.json @@ -0,0 +1,14 @@ +{ + "baseConfiguration" : "factory", + "checks": + { + "PROPLC": + { + "enabled" : false + }, + "PROP": + { + "enabled" : false + } + } +} diff --git a/matlab/config/code_analyzer.m b/matlab/config/code_analyzer.m new file mode 100644 index 00000000000..608d21e8d7f --- /dev/null +++ b/matlab/config/code_analyzer.m @@ -0,0 +1,10 @@ +function code_analyzer() + result = codeIssues(["../lib/+Ice", "../lib/+IceInternal", "../lib/generated"], CodeAnalyzerConfiguration="analyzer.json"); + export(result, "result.json", FileFormat="json"); + disp(result); + if height(result.Issues) > 0 + exit(1); + else + exit(0); + end +end diff --git a/matlab/lib/+Ice/InputStream.m b/matlab/lib/+Ice/InputStream.m index 1cbc38a45b9..0022b189ad2 100644 --- a/matlab/lib/+Ice/InputStream.m +++ b/matlab/lib/+Ice/InputStream.m @@ -531,11 +531,11 @@ function skipSlice(obj) end end function r = readOptional(obj, tag, fmt) + import IceInternal.Protocol; %assert(isobject(obj.encapsStack)); if obj.encoding_1_0 r = false; % Optional members aren't supported with the 1.0 encoding. elseif isobject(obj.encapsStackDecoder) - import IceInternal.Protocol; current = obj.encapsStackDecoder.current; if ~isobject(current) || bitand(current.sliceFlags, Protocol.FLAG_HAS_OPTIONAL_MEMBERS) r = readOptionalImpl(tag, fmt, obj.encapsStack.endPos); diff --git a/matlab/lib/+Ice/ObjectPrx.m b/matlab/lib/+Ice/ObjectPrx.m index 981689add96..1d5d84cd1c8 100644 --- a/matlab/lib/+Ice/ObjectPrx.m +++ b/matlab/lib/+Ice/ObjectPrx.m @@ -959,7 +959,7 @@ function iceEndWriteParams(~, os) size = os.buf.size; end - if length(varargin) == 1 + if isscalar(varargin) % % Avoid the string concatenation % @@ -1056,7 +1056,7 @@ function iceEndWriteParams(~, os) size = os.buf.size; end futPtr = libpointer('voidPtr'); % Output param - if length(varargin) == 1 + if isscalar(varargin) % % Avoid the string concatenation % @@ -1116,7 +1116,7 @@ function iceThrowUserException(~, is, varargin) % Varargs are user exception typ function r = uncheckedCast(p, varargin) if isempty(varargin) r = p; - elseif length(varargin) == 1 + elseif isscalar(varargin) if ~isempty(p) r = p.ice_facet(varargin{1}); else @@ -1133,9 +1133,9 @@ function iceThrowUserException(~, is, varargin) % Varargs are user exception typ hasFacet = false; facet = []; context = {}; - if length(varargin) == 1 + if isscalar(varargin) if isa(varargin{1}, 'containers.Map') - context = { varargin{1} }; + context = varargin(1); elseif isempty(varargin{1}) || isa(varargin{1}, 'char') hasFacet = true; facet = varargin{1}; @@ -1145,7 +1145,7 @@ function iceThrowUserException(~, is, varargin) % Varargs are user exception typ elseif length(varargin) == 2 hasFacet = true; facet = varargin{1}; - context = { varargin{2} }; + context = varargin(2); elseif length(varargin) > 2 throw(LocalException('Ice:ArgumentException', 'too many arguments to checkedCast')); end @@ -1167,7 +1167,7 @@ function iceThrowUserException(~, is, varargin) % Varargs are user exception typ function r = iceUncheckedCast(p, cls, varargin) hasFacet = false; facet = []; - if length(varargin) == 1 + if isscalar(varargin) hasFacet = true; facet = varargin{1}; elseif length(varargin) > 1 diff --git a/matlab/lib/+Ice/identityToString.m b/matlab/lib/+Ice/identityToString.m index a5e76a7b478..f87769feb73 100644 --- a/matlab/lib/+Ice/identityToString.m +++ b/matlab/lib/+Ice/identityToString.m @@ -10,7 +10,7 @@ % Copyright (c) ZeroC, Inc. All rights reserved. - if length(varargin) == 1 + if isscalar(varargin) mode = varargin{1}; elseif isempty(varargin) mode = Ice.ToStringMode.Unicode; diff --git a/matlab/lib/+IceInternal/EncapsDecoder10.m b/matlab/lib/+IceInternal/EncapsDecoder10.m index 5c63f9fb5a6..bfa235b3404 100644 --- a/matlab/lib/+IceInternal/EncapsDecoder10.m +++ b/matlab/lib/+IceInternal/EncapsDecoder10.m @@ -119,7 +119,7 @@ function throwException(obj) end end - function startInstance(obj, sliceType) + function startInstance(obj, ~) %assert(obj.sliceType == sliceType); obj.skipFirstSlice = true; end @@ -203,7 +203,6 @@ function readInstance(obj) % obj.startSlice(); mostDerivedId = obj.typeId; - v = []; while true % % For the 1.0 encoding, the type ID for the base Object class diff --git a/matlab/lib/+IceInternal/EncapsDecoder11.m b/matlab/lib/+IceInternal/EncapsDecoder11.m index 6ff00e3f063..5cc6f752ee1 100644 --- a/matlab/lib/+IceInternal/EncapsDecoder11.m +++ b/matlab/lib/+IceInternal/EncapsDecoder11.m @@ -108,7 +108,7 @@ function throwException(obj) end end - function startInstance(obj, sliceType) + function startInstance(obj, ~) %assert(obj.current.sliceType == sliceType); obj.current.skipFirstSlice = true; end diff --git a/matlab/lib/+IceInternal/EncapsEncoder10.m b/matlab/lib/+IceInternal/EncapsEncoder10.m index 8d68ef9cf3c..235d1f4f513 100644 --- a/matlab/lib/+IceInternal/EncapsEncoder10.m +++ b/matlab/lib/+IceInternal/EncapsEncoder10.m @@ -73,7 +73,7 @@ function endSlice(obj) end function writePendingValues(obj) - while length(obj.toBeMarshaledMap) > 0 + while ~isempty(obj.toBeMarshaledMap) % % Consider the to be marshaled instances as marshaled now, % this is necessary to avoid adding again the "to be diff --git a/python/modules/IcePy/Logger.cpp b/python/modules/IcePy/Logger.cpp index a60787b4e1c..d67ec475c4b 100644 --- a/python/modules/IcePy/Logger.cpp +++ b/python/modules/IcePy/Logger.cpp @@ -86,7 +86,7 @@ IcePy::LoggerWrapper::getPrefix() } Ice::LoggerPtr -IcePy::LoggerWrapper::cloneWithPrefix(const string& prefix) +IcePy::LoggerWrapper::cloneWithPrefix(string prefix) { AdoptThread adoptThread; // Ensure the current thread is able to call into Python. diff --git a/python/modules/IcePy/Logger.h b/python/modules/IcePy/Logger.h index 72cb88fe9ab..778252329f2 100644 --- a/python/modules/IcePy/Logger.h +++ b/python/modules/IcePy/Logger.h @@ -16,17 +16,17 @@ namespace IcePy // // LoggerWrapper delegates to a Python implementation. // - class LoggerWrapper : public Ice::Logger + class LoggerWrapper final : public Ice::Logger { public: LoggerWrapper(PyObject*); - virtual void print(const std::string&); - virtual void trace(const std::string&, const std::string&); - virtual void warning(const std::string&); - virtual void error(const std::string&); - virtual std::string getPrefix(); - virtual Ice::LoggerPtr cloneWithPrefix(const std::string&); + void print(const std::string&) final; + void trace(const std::string&, const std::string&) final; + void warning(const std::string&) final; + void error(const std::string&) final; + std::string getPrefix() final; + Ice::LoggerPtr cloneWithPrefix(std::string) final; PyObject* getObject(); private: diff --git a/python/modules/IcePy/ObjectAdapter.cpp b/python/modules/IcePy/ObjectAdapter.cpp index a0c90ee3d62..87e8e980a65 100644 --- a/python/modules/IcePy/ObjectAdapter.cpp +++ b/python/modules/IcePy/ObjectAdapter.cpp @@ -1393,16 +1393,7 @@ extern "C" PyObject* adapterGetLocator(ObjectAdapterObject* self, PyObject* /*args*/) { assert(self->adapter); - optional locator; - try - { - locator = (*self->adapter)->getLocator(); - } - catch (...) - { - setPythonException(current_exception()); - return nullptr; - } + optional locator = (*self->adapter)->getLocator(); if (!locator) { diff --git a/python/test/Ice/ami/Test.ice b/python/test/Ice/ami/Test.ice index 2adfe72d791..7f01fa563f1 100644 --- a/python/test/Ice/ami/Test.ice +++ b/python/test/Ice/ami/Test.ice @@ -38,6 +38,7 @@ interface TestIntf bool supportsAMD(); bool supportsFunctionalTests(); + bool supportsBackPressureTests(); ["amd"] void pingBiDir(PingReply* reply); } diff --git a/python/test/Ice/ami/TestI.py b/python/test/Ice/ami/TestI.py index c226e11b9c4..bcfd9ee5909 100644 --- a/python/test/Ice/ami/TestI.py +++ b/python/test/Ice/ami/TestI.py @@ -90,6 +90,9 @@ def supportsAMD(self, current): def supportsFunctionalTests(self, current): return False + def supportsBackPressureTests(self, current): + return True + async def pingBiDir(self, reply, current): expectSuccess = "ONE" not in current.ctx try: @@ -100,6 +103,7 @@ async def pingBiDir(self, reply, current): if expectSuccess: raise Test.TestIntfException() + class TestIntfII(Test.Outer.Inner.TestIntf): def op(self, i, current): return (i, i) diff --git a/ruby/src/IceRuby/Operation.cpp b/ruby/src/IceRuby/Operation.cpp index a91e228a56b..0b20a4cdb13 100644 --- a/ruby/src/IceRuby/Operation.cpp +++ b/ruby/src/IceRuby/Operation.cpp @@ -40,7 +40,7 @@ namespace IceRuby class OperationI final : public Operation { public: - OperationI(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE); + OperationI(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE); VALUE invoke(const Ice::ObjectPrx&, VALUE, VALUE) final; void deprecate(const string&) final; @@ -48,7 +48,6 @@ namespace IceRuby private: string _name; Ice::OperationMode _mode; - bool _amd; std::optional _format; ParamInfoList _inParams; ParamInfoList _optionalInParams; @@ -56,7 +55,6 @@ namespace IceRuby ParamInfoList _optionalOutParams; ParamInfoPtr _returnType; ExceptionInfoList _exceptions; - string _dispatchName; bool _sendsClasses; bool _returnsClasses; string _deprecateMessage; @@ -83,7 +81,6 @@ IceRuby_defineOperation( VALUE /*self*/, VALUE name, VALUE mode, - VALUE amd, VALUE format, VALUE inParams, VALUE outParams, @@ -92,8 +89,7 @@ IceRuby_defineOperation( { ICE_RUBY_TRY { - OperationIPtr op = - make_shared(name, mode, amd, format, inParams, outParams, returnType, exceptions); + OperationIPtr op = make_shared(name, mode, format, inParams, outParams, returnType, exceptions); return Data_Wrap_Struct(_operationClass, 0, IceRuby_Operation_free, new OperationPtr(op)); } ICE_RUBY_CATCH @@ -151,7 +147,6 @@ IceRuby::ParamInfo::unmarshaled(VALUE val, VALUE target, void* closure) IceRuby::OperationI::OperationI( VALUE name, VALUE mode, - VALUE amd, VALUE format, VALUE inParams, VALUE outParams, @@ -159,15 +154,6 @@ IceRuby::OperationI::OperationI( VALUE exceptions) { _name = getString(name); - _amd = amd == Qtrue; - if (_amd) - { - _dispatchName = fixIdent(_name, IdentNormal) + "_async"; - } - else - { - _dispatchName = fixIdent(_name, IdentNormal); - } // // mode @@ -611,7 +597,7 @@ IceRuby::OperationI::checkTwowayOnly(const Ice::ObjectPrx& proxy) const bool IceRuby::initOperation(VALUE iceModule) { - rb_define_module_function(iceModule, "__defineOperation", CAST_METHOD(IceRuby_defineOperation), 8); + rb_define_module_function(iceModule, "__defineOperation", CAST_METHOD(IceRuby_defineOperation), 7); // // Define a class to represent an operation. diff --git a/scripts/Util.py b/scripts/Util.py index 27d5e0948bf..5306555c4c7 100644 --- a/scripts/Util.py +++ b/scripts/Util.py @@ -204,7 +204,10 @@ def getSliceDir(self, mapping, current): if installDir.endswith(mapping.name): installDir = installDir[0 : len(installDir) - len(mapping.name) - 1] if platform.getInstallDir() and installDir == platform.getInstallDir(): - return os.path.join(installDir, "share", "ice", "slice") + if sys.platform == "darwin": + return os.path.join(installDir, "opt", "ice", "share", "ice", "slice") + else: + return os.path.join(installDir, "share", "ice", "slice") else: return os.path.join(installDir, "slice") @@ -378,7 +381,7 @@ def getLdPathEnvName(self): return "DYLD_LIBRARY_PATH" def getInstallDir(self): - return "/usr/local" + return "/opt/homebrew" if platform_machine() == "arm64" else "/usr/local" class Linux(Platform): diff --git a/swift/src/IceImpl/LoggerWrapperI.h b/swift/src/IceImpl/LoggerWrapperI.h index b69783ce935..b140a7788b5 100644 --- a/swift/src/IceImpl/LoggerWrapperI.h +++ b/swift/src/IceImpl/LoggerWrapperI.h @@ -1,30 +1,28 @@ // Copyright (c) ZeroC, Inc. #import "Convert.h" -class LoggerWrapperI : public Ice::Logger +class LoggerWrapperI final : public Ice::Logger { public: LoggerWrapperI(id logger) : _logger(logger) {} - virtual ~LoggerWrapperI() {} + void print(const std::string& msg) final { [_logger print:toNSString(msg)]; } - virtual void print(const std::string& msg) { [_logger print:toNSString(msg)]; } - - virtual void trace(const std::string& category, const std::string& msg) + void trace(const std::string& category, const std::string& msg) final { [_logger trace:toNSString(category) message:toNSString(msg)]; } - virtual void warning(const std::string& msg) { [_logger warning:toNSString(msg)]; } + void warning(const std::string& msg) final { [_logger warning:toNSString(msg)]; } - virtual void error(const std::string& msg) { [_logger error:toNSString(msg)]; } + void error(const std::string& msg) final { [_logger error:toNSString(msg)]; } - virtual std::shared_ptr cloneWithPrefix(const std::string& prefix) + std::shared_ptr cloneWithPrefix(std::string prefix) final { return std::make_shared([_logger cloneWithPrefix:toNSString(prefix)]); } - virtual std::string getPrefix() { return fromNSString([_logger getPrefix]); } + std::string getPrefix() final { return fromNSString([_logger getPrefix]); } id getLogger() { return _logger; } diff --git a/swift/test/Ice/ami/Test.ice b/swift/test/Ice/ami/Test.ice index 95a7f0b121d..ebbaaba9b6b 100644 --- a/swift/test/Ice/ami/Test.ice +++ b/swift/test/Ice/ami/Test.ice @@ -40,6 +40,7 @@ interface TestIntf bool supportsAMD(); bool supportsFunctionalTests(); + bool supportsBackPressureTests(); void pingBiDir(PingReply* reply); } diff --git a/swift/test/Ice/ami/TestI.swift b/swift/test/Ice/ami/TestI.swift index 7d34cabb9c3..bfb0daea134 100644 --- a/swift/test/Ice/ami/TestI.swift +++ b/swift/test/Ice/ami/TestI.swift @@ -172,6 +172,10 @@ class TestI: TestIntf { func supportsFunctionalTests(current _: Current) async throws -> Bool { return false } + + func supportsBackPressureTests(current _: Current) async throws -> Bool { + return false + } } class TestII: OuterInnerTestIntf {