-
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.
Add complex types to chip tool darwin (#16909)
* Add complex types to chip-tool darwin. * Generated Code
- Loading branch information
Showing
5 changed files
with
3,680 additions
and
1,780 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
44 changes: 44 additions & 0 deletions
44
examples/chip-tool-darwin/templates/partials/decodable_value.zapt
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,44 @@ | ||
{{#if isOptional}} | ||
if ({{source}}.HasValue()) { | ||
{{>decodable_value target=target source=(concat source ".Value()") cluster=cluster depth=(incrementDepth depth) isOptional=false}} | ||
} else { | ||
{{target}} = nil; | ||
} | ||
{{else if isNullable}} | ||
if ({{source}}.IsNull()) { | ||
{{target}} = nil; | ||
} else { | ||
{{>decodable_value target=target source=(concat source ".Value()") cluster=cluster depth=(incrementDepth depth) isNullable=false}} | ||
} | ||
{{else if isArray}} | ||
{ // Scope for our temporary variables | ||
auto * array_{{depth}} = [NSMutableArray new]; | ||
for (auto & entry_{{depth}} : {{source}}) { | ||
{{asObjectiveCClass type cluster forceNotList=true}} * newElement_{{depth}}; | ||
{{>decodable_value target=(concat "newElement_" depth) source=(concat "entry_" depth) cluster=cluster depth=(incrementDepth depth) isArray=false}} | ||
[array_{{depth}} addObject:newElement_{{depth}}]; | ||
} | ||
{{target}} = array_{{depth}}; | ||
} | ||
{{else}} | ||
{{#if_is_struct type}} | ||
{{target}} = [{{asObjectiveCClass type cluster forceNotList=true}} new]; | ||
{{#zcl_struct_items_by_struct_name type}} | ||
{{>decodable_value target=(concat ../target "." (asStructPropertyName label)) source=(concat ../source "." (asLowerCamelCase label)) cluster=../cluster depth=(incrementDepth ../depth) }} | ||
{{/zcl_struct_items_by_struct_name}} | ||
{{else}} | ||
{{#if_chip_enum type}} | ||
{{target}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:chip::to_underlying({{source}})]; | ||
{{else}} | ||
{{#if_is_bitmap type}} | ||
{{target}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:{{source}}.Raw()]; | ||
{{else if (isOctetString type)}} | ||
{{target}} = [NSData dataWithBytes:{{source}}.data() length:{{source}}.size()]; | ||
{{else if (isCharString type)}} | ||
{{target}} = [[NSString alloc] initWithBytes:{{source}}.data() length:{{source}}.size() encoding:NSUTF8StringEncoding]; | ||
{{else}} | ||
{{target}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:{{source}}]; | ||
{{/if_is_bitmap}} | ||
{{/if_chip_enum}} | ||
{{/if_is_struct}} | ||
{{/if}} |
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
Oops, something went wrong.