From 9099989cb51879508aacac93a7644dc7f50a0847 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 2 Dec 2021 17:31:49 -0500 Subject: [PATCH] Convert ApplicationBasicStatus to an enum class. (#12500) --- .../include/application-basic/Application.h | 17 +++++++++-------- .../ApplicationBasicManager.cpp | 8 +++++--- .../include/application-basic/Application.h | 18 ++++++++++-------- .../ApplicationBasicManager.cpp | 8 +++++--- .../application-basic-server.cpp | 5 ++--- src/app/zap-templates/templates/app/helper.js | 1 - .../app-common/zap-generated/cluster-objects.h | 6 ------ .../app-common/zap-generated/enums.h | 9 --------- 8 files changed, 31 insertions(+), 41 deletions(-) diff --git a/examples/tv-app/android/include/application-basic/Application.h b/examples/tv-app/android/include/application-basic/Application.h index bdea7a71c2b6f3..11ef8bf72e4618 100644 --- a/examples/tv-app/android/include/application-basic/Application.h +++ b/examples/tv-app/android/include/application-basic/Application.h @@ -18,15 +18,16 @@ #pragma once -#include +#include struct Application { - char vendorName[32] = ""; - char name[32] = ""; - char id[32] = ""; - uint16_t vendorId = 0; - uint16_t productId = 0; - uint16_t catalogVendorId = 0; - EmberAfApplicationBasicStatus status = EMBER_ZCL_APPLICATION_BASIC_STATUS_STOPPED; + using ApplicationBasicStatus = chip::app::Clusters::ApplicationBasic::ApplicationBasicStatus; + char vendorName[32] = ""; + char name[32] = ""; + char id[32] = ""; + uint16_t vendorId = 0; + uint16_t productId = 0; + uint16_t catalogVendorId = 0; + ApplicationBasicStatus status = ApplicationBasicStatus::kStopped; }; diff --git a/examples/tv-app/android/include/application-basic/ApplicationBasicManager.cpp b/examples/tv-app/android/include/application-basic/ApplicationBasicManager.cpp index e3c893f40f8ad1..6c6a1d7f9be7b4 100644 --- a/examples/tv-app/android/include/application-basic/ApplicationBasicManager.cpp +++ b/examples/tv-app/android/include/application-basic/ApplicationBasicManager.cpp @@ -20,11 +20,12 @@ #include #include #include +#include #include -#include #include #include #include +#include #include #include @@ -153,9 +154,10 @@ Application ApplicationBasicManager::getApplicationForEndpoint(chip::EndpointId return app; } -bool applicationBasicClusterChangeApplicationStatus(EmberAfApplicationBasicStatus status, chip::EndpointId endpoint) +bool applicationBasicClusterChangeApplicationStatus(app::Clusters::ApplicationBasic::ApplicationBasicStatus status, + chip::EndpointId endpoint) { // TODO: Insert code here - ChipLogProgress(Zcl, "Sent an application status change request %d for endpoint %d", status, endpoint); + ChipLogProgress(Zcl, "Sent an application status change request %d for endpoint %d", to_underlying(status), endpoint); return true; } diff --git a/examples/tv-app/linux/include/application-basic/Application.h b/examples/tv-app/linux/include/application-basic/Application.h index bdea7a71c2b6f3..dae0e236c90c61 100644 --- a/examples/tv-app/linux/include/application-basic/Application.h +++ b/examples/tv-app/linux/include/application-basic/Application.h @@ -18,15 +18,17 @@ #pragma once -#include +#include struct Application { - char vendorName[32] = ""; - char name[32] = ""; - char id[32] = ""; - uint16_t vendorId = 0; - uint16_t productId = 0; - uint16_t catalogVendorId = 0; - EmberAfApplicationBasicStatus status = EMBER_ZCL_APPLICATION_BASIC_STATUS_STOPPED; + using ApplicationBasicStatus = chip::app::Clusters::ApplicationBasic::ApplicationBasicStatus; + + char vendorName[32] = ""; + char name[32] = ""; + char id[32] = ""; + uint16_t vendorId = 0; + uint16_t productId = 0; + uint16_t catalogVendorId = 0; + ApplicationBasicStatus status = ApplicationBasicStatus::kStopped; }; diff --git a/examples/tv-app/linux/include/application-basic/ApplicationBasicManager.cpp b/examples/tv-app/linux/include/application-basic/ApplicationBasicManager.cpp index e3c893f40f8ad1..6c6a1d7f9be7b4 100644 --- a/examples/tv-app/linux/include/application-basic/ApplicationBasicManager.cpp +++ b/examples/tv-app/linux/include/application-basic/ApplicationBasicManager.cpp @@ -20,11 +20,12 @@ #include #include #include +#include #include -#include #include #include #include +#include #include #include @@ -153,9 +154,10 @@ Application ApplicationBasicManager::getApplicationForEndpoint(chip::EndpointId return app; } -bool applicationBasicClusterChangeApplicationStatus(EmberAfApplicationBasicStatus status, chip::EndpointId endpoint) +bool applicationBasicClusterChangeApplicationStatus(app::Clusters::ApplicationBasic::ApplicationBasicStatus status, + chip::EndpointId endpoint) { // TODO: Insert code here - ChipLogProgress(Zcl, "Sent an application status change request %d for endpoint %d", status, endpoint); + ChipLogProgress(Zcl, "Sent an application status change request %d for endpoint %d", to_underlying(status), endpoint); return true; } diff --git a/src/app/clusters/application-basic-server/application-basic-server.cpp b/src/app/clusters/application-basic-server/application-basic-server.cpp index 78a7f85a1d2ed4..248ebe48e4c5b6 100644 --- a/src/app/clusters/application-basic-server/application-basic-server.cpp +++ b/src/app/clusters/application-basic-server/application-basic-server.cpp @@ -32,7 +32,7 @@ using namespace chip; using namespace chip::app::Clusters::ApplicationBasic; -bool applicationBasicClusterChangeApplicationStatus(EmberAfApplicationBasicStatus status, EndpointId endpoint); +bool applicationBasicClusterChangeApplicationStatus(ApplicationBasicStatus status, EndpointId endpoint); bool emberAfApplicationBasicClusterChangeStatusCallback(app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, @@ -40,8 +40,7 @@ bool emberAfApplicationBasicClusterChangeStatusCallback(app::CommandHandler * co { auto & newApplicationStatus = commandData.status; - bool success = applicationBasicClusterChangeApplicationStatus(static_cast(newApplicationStatus), - emberAfCurrentEndpoint()); + bool success = applicationBasicClusterChangeApplicationStatus(newApplicationStatus, emberAfCurrentEndpoint()); EmberAfStatus status = success ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE; emberAfSendImmediateDefaultResponse(status); return true; diff --git a/src/app/zap-templates/templates/app/helper.js b/src/app/zap-templates/templates/app/helper.js index 6af4162840ae55..de3898340fa12b 100644 --- a/src/app/zap-templates/templates/app/helper.js +++ b/src/app/zap-templates/templates/app/helper.js @@ -529,7 +529,6 @@ async function getResponseCommandName(responseRef, options) function isWeaklyTypedEnum(label) { return [ - "ApplicationBasicStatus", "ApplicationLauncherStatus", "AttributeWritePermission", "AudioOutputType", diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index 1e8c6b160e95bd..33092c6c16a65f 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -28601,9 +28601,6 @@ struct TypeInfo } // namespace Attributes } // namespace ApplicationLauncher namespace ApplicationBasic { -// Need to convert consumers to using the new enum classes, so we -// don't just have casts all over. -#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM // Enum for ApplicationBasicStatus enum class ApplicationBasicStatus : uint8_t { @@ -28612,9 +28609,6 @@ enum class ApplicationBasicStatus : uint8_t kActiveHidden = 0x02, kActiveVisibleNotFocus = 0x03, }; -#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM -using ApplicationBasicStatus = EmberAfApplicationBasicStatus; -#endif namespace Commands { // Forward-declarations so we can reference these later. diff --git a/zzz_generated/app-common/app-common/zap-generated/enums.h b/zzz_generated/app-common/app-common/zap-generated/enums.h index fa3cec57c0ca6a..3d721067c00174 100644 --- a/zzz_generated/app-common/app-common/zap-generated/enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/enums.h @@ -24,15 +24,6 @@ // ZCL enums -// Enum for ApplicationBasicStatus -enum EmberAfApplicationBasicStatus : uint8_t -{ - EMBER_ZCL_APPLICATION_BASIC_STATUS_STOPPED = 0, - EMBER_ZCL_APPLICATION_BASIC_STATUS_ACTIVE_VISIBLE_FOCUS = 1, - EMBER_ZCL_APPLICATION_BASIC_STATUS_ACTIVE_HIDDEN = 2, - EMBER_ZCL_APPLICATION_BASIC_STATUS_ACTIVE_VISIBLE_NOT_FOCUS = 3, -}; - // Enum for ApplicationLauncherStatus enum EmberAfApplicationLauncherStatus : uint8_t {