Skip to content

Commit

Permalink
Switch SimpleEnum to being an enum class. (#12442)
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Mar 2, 2022
1 parent 4bafafc commit 1748372
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ uint8_t gListUint8Data[kAttributeListLength];
OctetStringData gListOctetStringData[kAttributeListLength];
OctetStringData gListOperationalCert[kAttributeListLength];
Structs::TestListStructOctet::Type listStructOctetStringData[kAttributeListLength];
Structs::SimpleStruct::Type gStructAttributeValue = { 0, false, SimpleEnum::EMBER_ZCL_SIMPLE_ENUM_VALUE_A,
Structs::SimpleStruct::Type gStructAttributeValue = { 0, false, SimpleEnum::kValueA,
ByteSpan(), CharSpan(), BitFlags<SimpleBitmap>(),
0, 0 };

Expand Down
56 changes: 0 additions & 56 deletions src/app/tests/TestDataModelSerialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,7 @@ void TestDataModelSerialization::TestDataModelSerialization_EncAndDecSimpleStruc

t.a = 20;
t.b = true;
#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.c = TestCluster::SimpleEnum::kValueA;
#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.c = EMBER_ZCL_SIMPLE_ENUM_VALUE_A;
#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.d = buf;

t.e = Span<char>{ strbuf, strlen(strbuf) };
Expand Down Expand Up @@ -211,11 +207,7 @@ void TestDataModelSerialization::TestDataModelSerialization_EncAndDecSimpleStruc

NL_TEST_ASSERT(apSuite, t.a == 20);
NL_TEST_ASSERT(apSuite, t.b == true);
#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
NL_TEST_ASSERT(apSuite, t.c == TestCluster::SimpleEnum::kValueA);
#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
NL_TEST_ASSERT(apSuite, t.c == EMBER_ZCL_SIMPLE_ENUM_VALUE_A);
#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM

NL_TEST_ASSERT(apSuite, t.d.size() == 4);

Expand Down Expand Up @@ -249,11 +241,7 @@ void TestDataModelSerialization::TestDataModelSerialization_EncAndDecNestedStruc
t.b = true;
t.c.a = 11;
t.c.b = true;
#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.c.c = TestCluster::SimpleEnum::kValueB;
#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.c.c = EMBER_ZCL_SIMPLE_ENUM_VALUE_B;
#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.c.d = buf;

t.c.e = Span<char>{ strbuf, strlen(strbuf) };
Expand Down Expand Up @@ -282,11 +270,7 @@ void TestDataModelSerialization::TestDataModelSerialization_EncAndDecNestedStruc
NL_TEST_ASSERT(apSuite, t.b == true);
NL_TEST_ASSERT(apSuite, t.c.a == 11);
NL_TEST_ASSERT(apSuite, t.c.b == true);
#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
NL_TEST_ASSERT(apSuite, t.c.c == TestCluster::SimpleEnum::kValueB);
#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
NL_TEST_ASSERT(apSuite, t.c.c == EMBER_ZCL_SIMPLE_ENUM_VALUE_B);
#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM

NL_TEST_ASSERT(apSuite, t.c.d.size() == 4);

Expand Down Expand Up @@ -324,11 +308,7 @@ void TestDataModelSerialization::TestDataModelSerialization_EncAndDecDecodableNe
t.b = true;
t.c.a = 11;
t.c.b = true;
#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.c.c = TestCluster::SimpleEnum::kValueB;
#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.c.c = EMBER_ZCL_SIMPLE_ENUM_VALUE_B;
#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.c.d = buf;
t.e = intBuf;

Expand Down Expand Up @@ -376,11 +356,7 @@ void TestDataModelSerialization::TestDataModelSerialization_EncAndDecDecodableNe
NL_TEST_ASSERT(apSuite, t.b == true);
NL_TEST_ASSERT(apSuite, t.c.a == 11);
NL_TEST_ASSERT(apSuite, t.c.b == true);
#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
NL_TEST_ASSERT(apSuite, t.c.c == TestCluster::SimpleEnum::kValueB);
#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
NL_TEST_ASSERT(apSuite, t.c.c == EMBER_ZCL_SIMPLE_ENUM_VALUE_B);
#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM

NL_TEST_ASSERT(apSuite, StringMatches(t.c.e, "chip"));

Expand Down Expand Up @@ -548,11 +524,7 @@ void TestDataModelSerialization::TestDataModelSerialization_OptionalFields(nlTes

t.a = 20;
t.b = true;
#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.c = TestCluster::SimpleEnum::kValueA;
#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.c = EMBER_ZCL_SIMPLE_ENUM_VALUE_A;
#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.d = buf;

t.e = Span<char>{ strbuf, strlen(strbuf) };
Expand Down Expand Up @@ -592,11 +564,7 @@ void TestDataModelSerialization::TestDataModelSerialization_OptionalFields(nlTes
NL_TEST_ASSERT(apSuite, t.a == 150);

NL_TEST_ASSERT(apSuite, t.b == true);
#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
NL_TEST_ASSERT(apSuite, t.c == TestCluster::SimpleEnum::kValueA);
#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
NL_TEST_ASSERT(apSuite, t.c == EMBER_ZCL_SIMPLE_ENUM_VALUE_A);
#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM

NL_TEST_ASSERT(apSuite, t.d.size() == 4);

Expand Down Expand Up @@ -627,11 +595,7 @@ void TestDataModelSerialization::TestDataModelSerialization_ExtraField(nlTestSui

t.a = 20;
t.b = true;
#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.c = TestCluster::SimpleEnum::kValueA;
#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.c = EMBER_ZCL_SIMPLE_ENUM_VALUE_A;
#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.d = buf;

t.e = Span<char>{ strbuf, strlen(strbuf) };
Expand Down Expand Up @@ -669,11 +633,7 @@ void TestDataModelSerialization::TestDataModelSerialization_ExtraField(nlTestSui

NL_TEST_ASSERT(apSuite, t.a == 20);
NL_TEST_ASSERT(apSuite, t.b == true);
#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
NL_TEST_ASSERT(apSuite, t.c == TestCluster::SimpleEnum::kValueA);
#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
NL_TEST_ASSERT(apSuite, t.c == EMBER_ZCL_SIMPLE_ENUM_VALUE_A);
#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM

NL_TEST_ASSERT(apSuite, t.d.size() == 4);

Expand Down Expand Up @@ -708,11 +668,7 @@ void TestDataModelSerialization::TestDataModelSerialization_InvalidSimpleFieldTy

t.a = 20;
t.b = true;
#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.c = TestCluster::SimpleEnum::kValueA;
#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.c = EMBER_ZCL_SIMPLE_ENUM_VALUE_A;
#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.d = buf;

t.e = Span<char>{ strbuf, strlen(strbuf) };
Expand Down Expand Up @@ -764,11 +720,7 @@ void TestDataModelSerialization::TestDataModelSerialization_InvalidSimpleFieldTy

t.a = 20;
t.b = true;
#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.c = TestCluster::SimpleEnum::kValueA;
#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.c = EMBER_ZCL_SIMPLE_ENUM_VALUE_A;
#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
t.d = buf;

t.e = Span<char>{ strbuf, strlen(strbuf) };
Expand Down Expand Up @@ -915,20 +867,12 @@ void TestDataModelSerialization::NullablesOptionalsEncodeDecodeCheck(nlTestSuite
TestCluster::Structs::SimpleStruct::Type myStruct;
myStruct.a = 17;
myStruct.b = true;
#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
myStruct.c = TestCluster::SimpleEnum::kValueB;
#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
myStruct.c = EMBER_ZCL_SIMPLE_ENUM_VALUE_B;
#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
myStruct.d = ByteSpan(structBytes);
myStruct.e = CharSpan(structStr, strlen(structStr));
myStruct.f = TestCluster::SimpleBitmap(2);

#ifdef CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
TestCluster::SimpleEnum enumListVals[] = { TestCluster::SimpleEnum::kValueA, TestCluster::SimpleEnum::kValueC };
#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
TestCluster::SimpleEnum enumListVals[] = { EMBER_ZCL_SIMPLE_ENUM_VALUE_A, EMBER_ZCL_SIMPLE_ENUM_VALUE_C };
#endif // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM
DataModel::List<TestCluster::SimpleEnum> enumList(enumListVals);

// Encode
Expand Down
1 change: 0 additions & 1 deletion src/app/zap-templates/templates/app/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,6 @@ function isWeaklyTypedEnum(label)
"SaturationStepMode",
"SecurityType",
"SetpointAdjustMode",
"SimpleEnum",
"StartUpOnOffValue",
"StatusCode",
"StepMode",
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions zzz_generated/app-common/app-common/zap-generated/enums.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1748372

Please sign in to comment.