Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop hardcoding the list of signed integer attribute types. #35412

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/app/util/attribute-metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,7 @@ struct EmberAfAttributeMetadata
/**
* Check wether this attribute is signed based on its type according to the spec.
*/
bool IsSignedIntegerAttribute() const
{
return (attributeType >= ZCL_INT8S_ATTRIBUTE_TYPE && attributeType <= ZCL_INT64S_ATTRIBUTE_TYPE) ||
attributeType == ZCL_TEMPERATURE_ATTRIBUTE_TYPE;
}
bool IsSignedIntegerAttribute() const { return chip::app::IsSignedAttributeType(attributeType); }

/**
* Check whether this attribute has a define min and max.
Expand Down
20 changes: 20 additions & 0 deletions src/app/zap-templates/templates/app/attribute-type.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,29 @@
// Prevent multiple inclusion
#pragma once

#include <cstdint>

// ZCL attribute types
enum {
{{#zcl_atomics}}
{{ident}}ZCL_{{asDelimitedMacro name}}_ATTRIBUTE_TYPE = {{asHex atomicId 2}}, // {{description}}
{{/zcl_atomics}}
};

namespace chip {
namespace app {
inline bool IsSignedAttributeType(uint8_t attributeType)
{
switch (attributeType) {
{{#zcl_atomics}}
{{#if isSigned}}
case ZCL_{{asDelimitedMacro name}}_ATTRIBUTE_TYPE:
return true;
{{/if}}
{{/zcl_atomics}}
default:
return false;
}
}
} // namespace app
} // namespace chip
41 changes: 41 additions & 0 deletions zzz_generated/app-common/app-common/zap-generated/attribute-type.h

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

Loading