Comments (11)
<struct name="SimpleStruct"> <cluster code="0x050F"/> <item name="a" type="UINT8U" optional="false"/> <item name="b" type="BOOLEAN" optional="false"/> <item name="c" define="SimpleEnum" type="ENUM8" optional="false"/>
DROP TABLE IF EXISTS "STRUCT_ITEM"; CREATE TABLE IF NOT EXISTS "STRUCT_ITEM" ( "STRUCT_REF" integer, "FIELD_IDENTIFIER" integer, "NAME" text, "TYPE" text, "IS_ARRAY" integer, "MIN_LENGTH" integer, "MAX_LENGTH" integer, "IS_WRITABLE" integer, foreign key (STRUCT_REF) references STRUCT(STRUCT_ID) );
looks like currently zap don't support struct item with define ?
for enum type, we would like to get "define"
then I can write {{asType label}} = static_cast<{{define}}>(v);
An alternate way to do this with the existing version can be {{asType label}} = static_cast<{{as_delimited_macro name}}>(v);
from zap.
it does not work as expected if using {{asType label}} = static_cast<{{as_delimited_macro name}}>(v), which returns c = static_cast(v);
from zap.
Could you give me the example template on how you are using this?
from zap.
I'm a bit confused with this, @yunhanw-google :
why would we not simply do:
<item name="c" type="SimpleEnum" optional="false"/>
instead of:
<item name="c" define="SimpleEnum" type="ENUM8" optional="false"/>
from zap.
If I define this way,
how can I check SimpleEnum is enum type?
{{#if (isEnum type) }}
uint8_t v;
ReturnErrorOnFailure(ClusterObjectUtils::Decode(reader, v));
//zap issue 231 to return right enum type
{{asType label}} = static_cast<{{asUnderlyingZclType type}}>(v);
break;
i need to write this kind of code
check if it is enum type, then generate some code
from zap.
Could you give me the example template on how you are using this?
{{#zcl_struct_items}}
case k{{asType label}}FieldId:
{{#if (isEnum type) }}
uint8_t v;
ReturnErrorOnFailure(ClusterObjectUtils::Decode(reader, v));
//zap issue 231 to return right enum type
{{asType label}} = static_cast<{{define}}>(v);
break;
{{else if isArray}}
return CHIP_ERROR_NOT_IMPLEMENTED;
{{else}}
ReturnErrorOnFailure(ClusterObjectUtils::Decode(reader, {{asType label}}));
break;
{{/if}}
{{/zcl_struct_items}}
from zap.
another alternative is that, we add one additional flag, isEnum similar to isArray for struct item(#229)
from zap.
There is this helper which may be helpful.
{{#if_is_enum type}}
type is enum
{{else}}
type is not enum
{{/if_is_enum}}
Regarding "static_cast<{{as_delimited_macro name}}>(v), which returns c = static_cast(v);" I am not sure why this happened. Is this for a particular struct item or all of them?
from zap.
There is this helper which may be helpful.
{{#if_is_enum type}}
type is enum
{{else}}
type is not enum
{{/if_is_enum}}
Just tried, it cannot detect SimpleEnum is enum.
The issue here is that the internal zap don't have knowledge about the customized enum type currently. Either zap know how to parse define, or parse isEnum or some other way zap get knowledge from xml to know it is enum
from zap.
So if I do this, does this meet your meeds:
1.) Add the IS_ENUM field in the DB.
2.) Allow for isEnum="true" in the XML.
3.) load and populate these flags.
4.) Give you a helper is_enum_type or something like that that will allow to modify how these types are generated.
from zap.
Closed in PR 235
from zap.
Related Issues (20)
- External attributes should not have an editable (or any, really) Default field in the UI
- [Feature Request] PICS XML Export
- [Feature Request] Matter "Strict" Mode
- ZAP UI - Matter HOT 2
- zcl_attributes does not produce the correct data HOT 1
- [Bug / Matter Non Conformance] Missing Binding Clusters for Simple device types HOT 11
- [Feature Request] ensure responses are enabled for any enabled commands
- [Feature Request] Support for NameSpaces+SemanticTags from XML -> ZAP -> API
- Vue tour issues HOT 1
- Command warnings not showing up in ZAP
- The zap tool does not work on Windows HOT 6
- Modify enable "enable all" btn position in clusterview
- Monitor and report on validity of configuration HOT 4
- min/max not supported for attribute size larger than 2 bytes HOT 4
- Move to CSA xml HOT 2
- Externalized Helpers
- Do not store xml data in .zap file
- Matter Centric ZAP UI HOT 2
- Spec Check UI/Console Feature
- .ZAP repo deletion HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zap.