-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move cluster-defined enums/bitmaps into a separate header. (#15686)
We want to put basic cluster-defined constants (enums/bitmaps) into a header we can use from anywhere (just like data model concepts like NodeId and whatnot). But we don't want that for the C++ structs in cluster-objects, which can have ABI issues. Move the constants into a separate header, put that header into src/lib/core in terms of include dependencies.
- Loading branch information
1 parent
c7c5d0a
commit 35ff021
Showing
7 changed files
with
2,572 additions
and
2,042 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{{> header}} | ||
|
||
#include <stdint.h> | ||
|
||
#pragma once | ||
|
||
namespace chip { | ||
namespace app { | ||
namespace Clusters { | ||
|
||
{{#zcl_clusters}} | ||
namespace {{asUpperCamelCase name}} { | ||
{{#zcl_enums}} | ||
|
||
{{#if (isWeaklyTypedEnum label)}} | ||
// 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 | ||
{{/if}} | ||
// Enum for {{label}} | ||
enum class {{asType label}} : {{asUnderlyingZclType type}} { | ||
{{#zcl_enum_items}} | ||
k{{asUpperCamelCase label}} = {{asHex value 2}}, | ||
{{/zcl_enum_items}} | ||
}; | ||
{{#if (isWeaklyTypedEnum label)}} | ||
#else // CHIP_USE_ENUM_CLASS_FOR_IM_ENUM | ||
using {{asType label}} = EmberAf{{asType label}}; | ||
#endif | ||
{{/if}} | ||
{{/zcl_enums}} | ||
{{#zcl_bitmaps}} | ||
|
||
// Bitmap for {{label}} | ||
enum class {{asType label}} : {{asUnderlyingZclType type}} { | ||
{{#zcl_bitmap_items}} | ||
k{{asUpperCamelCase label}} = {{asHex mask}}, | ||
{{/zcl_bitmap_items}} | ||
}; | ||
{{/zcl_bitmaps}} | ||
} // namespace {{asUpperCamelCase name}} | ||
|
||
{{/zcl_clusters}} | ||
} // namespace Clusters | ||
} // namespace app | ||
} // namespace chip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* | ||
* Copyright (c) 2022 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
/** | ||
* Enum and bitmap definitions from cluster specifications. | ||
*/ | ||
|
||
// For now, include the generated enum file, since we are still working on | ||
// converting our enums to enum classes. Once that is complete and things are | ||
// more stable, we can consider other options here. | ||
|
||
#include <app-common/zap-generated/cluster-enums.h> |
Oops, something went wrong.