-
Notifications
You must be signed in to change notification settings - Fork 82
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
Add support for typedef #1458
base: master
Are you sure you want to change the base?
Add support for typedef #1458
Conversation
…inct types that aliases to the raw type for better readability & documentation-by-code, e.g. IDs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good and thorough. It would be nice if you could fix the schema format to be consistent.
…inct types that aliases to the raw type for better readability & documentation-by-code, e.g. IDs
@brdandu or @tecimovic could I get one of you to review? Thank you! |
I am wondering if this is very similar to base type implementation in #1472 . Do you think that can work the same way as your implementation? |
This seems to be a superset of that - in fact, this new typedef should probably supercede many of the base types - for example, in Not only does this PR allow for block helpers, it also allows for dynamic specifying of simple types alongside structs/etc. instead of having to have a definition in |
I do see some of the benefits of having a typedef implementation for better spec readability. Here a couple of things I am thinking from the top of my head and worried about:
Should we have a corresponding chip repo PR which uses this to validate some of this behavior? @bzbarsky-apple @andy31415 do you guys have any input here? |
I think so? I think we'd want to move some of the types currently defined in
Assuming I understand your question: typedef is treated exactly like enum & struct, i.e. the name is added to its own SQL table & it is checked for uniqueness against all types
Yes, although in general there are shared functions - for example, when we lookup the type to output in code, we just do a redirect to the underlying type |
For reference, corresponding chip repo PR: project-chip/connectedhomeip#36124 |
I could be wrong here but I believe we pass the atomic identifier in our zcl read and write attribute calls if I am not wrong. It is worth checking that our generated code continues to extract the right atomic identifier here when the typedef is introduced to the attribute types and this continues to work the same way:
In our templates we very frequently pass the attribute type to a bunch of helpers for processing. What happens to the those helpers when the typedef is passed?
Can this be verified by adding more unit tests here based on the above example? |
I added tests such that they are 1:1 with the enum & struct tests Unfortunately, the tests are somewhat split between here & the matter SDK repo Here, the tests just check for the basic functionality: i.e. if we find a Those tests here are updated to handle typedefs & pass Then, in the Matter SDK repo, there are numerous other tests around the zap templates there (including the compiler itself - i.e. if the generated files compile) Those tests are not yet complete, but are more testing the templates rather than ZAP itself (I am working on those now, though some are complete) |
Adds support for
typedef
in zap, supporting things like defining aVideoStreamID
as auint16
, see the camera spec: https://github.com/CHIP-Specifications/connectedhomeip-spec/pull/10004See also Matter SDK template changes @ project-chip/connectedhomeip#36124
This should also eliminate the need for many of the things in
chip-types.xml
, which can now be simply defined in the XML files as a simpletypedef
See also discussion with @bzbarsky-apple: project-chip/connectedhomeip#35773 (comment)