From ce7cdeffb431a6dbc5560ba961a16cc840f62230 Mon Sep 17 00:00:00 2001 From: Jakob Hasse Date: Fri, 19 Nov 2021 16:07:32 +0800 Subject: [PATCH] bugfix (cxx)!: added missing explicit for some strong value types BREAKING CHANGE: Users who have been using the GPIO and SPI classes may need to revisit their code as it's now not allowed anymore to pass raw numbers for classes like MOSI or GPIONum. --- .../experimental_cpp_component/include/gpio_cxx.hpp | 8 ++++---- .../experimental_cpp_component/include/spi_cxx.hpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/cxx/experimental/experimental_cpp_component/include/gpio_cxx.hpp b/examples/cxx/experimental/experimental_cpp_component/include/gpio_cxx.hpp index 24de17cdb9..8cd347f26b 100644 --- a/examples/cxx/experimental/experimental_cpp_component/include/gpio_cxx.hpp +++ b/examples/cxx/experimental/experimental_cpp_component/include/gpio_cxx.hpp @@ -46,7 +46,7 @@ public: * * @throw GPIOException if the number does not reflect a valid GPIO number on the current hardware. */ - GPIONumBase(uint32_t pin) : StrongValueComparable(pin) + explicit GPIONumBase(uint32_t pin) : StrongValueComparable(pin) { esp_err_t pin_check_result = check_gpio_pin_num(pin); if (pin_check_result != ESP_OK) { @@ -93,7 +93,7 @@ private: * * @param pull_mode A valid numerical respresentation of the pull up configuration. Must be valid! */ - GPIOPullMode(uint32_t pull_mode) : StrongValueComparable(pull_mode) { } + explicit GPIOPullMode(uint32_t pull_mode) : StrongValueComparable(pull_mode) { } public: /** @@ -137,7 +137,7 @@ private: * * @param pull_mode A valid numerical respresentation of a possible interrupt level to wake up. Must be valid! */ - GPIOWakeupIntrType(uint32_t interrupt_level) : StrongValueComparable(interrupt_level) { } + explicit GPIOWakeupIntrType(uint32_t interrupt_level) : StrongValueComparable(interrupt_level) { } public: static GPIOWakeupIntrType LOW_LEVEL(); @@ -170,7 +170,7 @@ public: * static creation functions below. * @throws GPIOException if the supplied number is out of the hardware capable range. */ - GPIODriveStrength(uint32_t strength) : StrongValueComparable(strength) + explicit GPIODriveStrength(uint32_t strength) : StrongValueComparable(strength) { esp_err_t strength_check_result = check_gpio_drive_strength(strength); if (strength_check_result != ESP_OK) { diff --git a/examples/cxx/experimental/experimental_cpp_component/include/spi_cxx.hpp b/examples/cxx/experimental/experimental_cpp_component/include/spi_cxx.hpp index 4ff48f9fdb..fc50db0bb6 100644 --- a/examples/cxx/experimental/experimental_cpp_component/include/spi_cxx.hpp +++ b/examples/cxx/experimental/experimental_cpp_component/include/spi_cxx.hpp @@ -57,7 +57,7 @@ public: * * @throw SPIException if the passed SPI host number is incorrect. */ - SPINum(uint32_t host_id_raw) : StrongValueComparable(host_id_raw) + explicit SPINum(uint32_t host_id_raw) : StrongValueComparable(host_id_raw) { esp_err_t spi_num_check_result = check_spi_num(host_id_raw); if (spi_num_check_result != ESP_OK) {