Skip to content

Commit e4b9bf4

Browse files
committed
Cleanup zap templates
1 parent d2e664c commit e4b9bf4

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

examples/darwin-framework-tool/templates/commands.zapt

+7-22
Original file line numberDiff line numberDiff line change
@@ -223,29 +223,14 @@ public:
223223
params.timedWriteTimeout = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil;
224224
params.dataVersion = mDataVersion.HasValue() ? [NSNumber numberWithUnsignedInt:mDataVersion.Value()] : nil;
225225
{{#if_chip_complex}}
226-
{{asObjectiveCType type parent.name}} value;
227-
{{>decodable_value target="value" source="mValue" cluster=parent.name errorCode="return err;" depth=0}}
226+
{{asObjectiveCType type parent.name}} value;
227+
{{>decodable_value target="value" source="mValue" cluster=parent.name errorCode="return err;" depth=0}}
228+
{{else if isNullable}}
229+
{{asObjectiveCType type parent.name}} value;
230+
{{>decodable_value target="value" source="mValue" cluster=parent.name isOptional=false isArray=false errorCode="return err;" depth=0}}
228231
{{else}}
229-
{{#if isNullable}}
230-
{{asObjectiveCType type parent.name}} value = nil;
231-
if (!mValue.IsNull()) {
232-
{{#if (isOctetString type)}}
233-
value = [[NSData alloc] initWithBytes:mValue.Value().data() length:mValue.Value().size()];
234-
{{else if (isString type)}}
235-
value = [[NSString alloc] initWithBytes:mValue.Value().data() length:mValue.Value().size() encoding:NSUTF8StringEncoding];
236-
{{else}}
237-
value = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:mValue.Value()];
238-
{{/if}}
239-
}
240-
{{else}}
241-
{{#if (isOctetString type)}}
242-
{{asObjectiveCType type parent.name}} value = [[NSData alloc] initWithBytes:mValue.data() length:mValue.size()];
243-
{{else if (isString type)}}
244-
{{asObjectiveCType type parent.name}} value = [[NSString alloc] initWithBytes:mValue.data() length:mValue.size() encoding:NSUTF8StringEncoding];
245-
{{else}}
246-
{{asObjectiveCType type parent.name}} value = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:mValue{{#if isNullable}}.Value(){{/if}}];
247-
{{/if}}
248-
{{/if}}
232+
{{asObjectiveCType type parent.name}}
233+
{{>decodable_value target="value" source="mValue" cluster=parent.name isOptional=false isArray=false errorCode="return err;" depth=0}}
249234
{{/if_chip_complex}}
250235

251236
[cluster write{{>attribute}}WithValue:value params:params completion:^(NSError * _Nullable error) {

0 commit comments

Comments
 (0)