blob: 16b19bd07566e09ac97a956ebbbad03b168e149c [file] [log] [blame]
{{#if isOptional}}
{{! Just go ahead and assign to the value, stripping the optionality bit off. }}
{{>test_value target=target definedValue=definedValue cluster=cluster isOptional=false depth=(incrementDepth depth)}}
{{else if isNullable}}
{{#if (isLiteralNull definedValue)}}
{{target}} = nil;
{{else}}
{{>test_value target=target definedValue=definedValue cluster=cluster isNullable=false depth=(incrementDepth depth)}}
{{/if}}
{{else if isArray}}
{{ensureIsArray definedValue~}}
{
NSMutableArray * temp_{{depth}} = [[NSMutableArray alloc] init];
{{#each definedValue}}
{{>test_value target=(concat "temp_" ../depth "[" @index "]") definedValue=this cluster=../cluster depth=(incrementDepth ../depth) type=../type isArray=false parent=../parent}}
{{/each}}
{{target}} = temp_{{depth}};
}
{{else}}
{{#if_is_struct type}}
{{target}} = [[MTR{{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}} alloc] init];
{{#zcl_struct_items_by_struct_name type}}
{{#if_include_struct_item_value ../definedValue name}}
{{! target may be some place where we lost type information (e.g. an
id), so add explicit cast when trying to assign to our
properties. }}
{{>test_value target=(concat "((MTR" (asUpperCamelCase ../cluster) "Cluster" (asUpperCamelCase ../type) " *)" ../target ")." (asStructPropertyName label)) definedValue=(lookup ../definedValue name) cluster=../cluster depth=(incrementDepth ../depth)}}
{{/if_include_struct_item_value}}
{{/zcl_struct_items_by_struct_name}}
{{else}}
{{target}} =
{{#if (chip_tests_variables_has definedValue)}}
[{{definedValue}} copy];
{{else if (chip_tests_config_has definedValue)}}
m{{asUpperCamelCase definedValue}}.HasValue() ?
{{#if (isCharString type)}}
m{{asUpperCamelCase definedValue}}.Value() : @"{{chip_tests_config_get_default_value definedValue}}";
{{else if (isOctetString type)}}
{{> octetStringValue value=(chip_tests_config_get_default_value definedValue)}};
{{else}}
[NSNumber numberWith{{asObjectiveCNumberType definedValue type false}}:m{{asUpperCamelCase definedValue}}.Value()] :
[NSNumber numberWith{{asObjectiveCNumberType definedValue type false}}:{{asTypedExpressionFromObjectiveC (chip_tests_config_get_default_value definedValue) type}}];
{{/if}}
{{else}}
{{#if (isCharString type)}}
@"{{definedValue}}";
{{else if (isOctetString type)}}
{{> octetStringValue value=definedValue}};
{{else}}
[NSNumber numberWith{{asObjectiveCNumberType definedValue type false}}:{{asTypedExpressionFromObjectiveC definedValue type}}];
{{/if}}
{{/if}}
{{/if_is_struct}}
{{/if}}