blob: fe5a9a1a7a19f369ba3c1b736856a3103938a5c6 [file] [log] [blame]
{{> header excludeZapComment=true}}
#import "MTRStructsObjc.h"
NS_ASSUME_NONNULL_BEGIN
{{#zcl_clusters}}
{{#zcl_structs}}
{{#*inline "interfaceImpl"}}
@implementation {{interfaceName}}
- (instancetype)init
{
if (self = [super init]) {
{{#zcl_struct_items}}
{{>init_struct_member label=label type=type cluster=parent.parent.name}}
{{/zcl_struct_items}}
}
return self;
}
- (id)copyWithZone:(NSZone * _Nullable)zone
{
auto other = [[{{interfaceName}} alloc] init];
{{#zcl_struct_items}}
other.{{asStructPropertyName label}} = self.{{asStructPropertyName label}};
{{/zcl_struct_items}}
return other;
}
- (NSString *)description
{
NSString *descriptionString = [NSString stringWithFormat:@"<%@: {{#zcl_struct_items}}{{asStructPropertyName label}}:%@; {{/zcl_struct_items}}>", NSStringFromClass([self class]){{#zcl_struct_items}},{{#if isArray}}_{{asStructPropertyName label}}{{else if (isOctetString type)}}[_{{asStructPropertyName label}} base64EncodedStringWithOptions:0]{{else}}_{{asStructPropertyName label}}{{/if}}{{/zcl_struct_items}}];
return descriptionString;
}
@end
{{/inline}}
{{> interfaceImpl interfaceName=(concat "MTR" (asUpperCamelCase parent.name) "Cluster" (asUpperCamelCase name))}}
{{!Backwards compat for now: Add a DeviceType thing that is API-compatible with DeviceTypeStruct. }}
{{#if (isStrEqual (asUpperCamelCase parent.name) "Descriptor")}}
{{#if (isStrEqual (asUpperCamelCase name) "DeviceTypeStruct")}}
{{> interfaceImpl interfaceName="MTRDescriptorClusterDeviceType"}}
{{/if}}
{{else if (isStrEqual (asUpperCamelCase parent.name) "UnitTesting")}}
@implementation MTRTestClusterCluster{{asUpperCamelCase name}} : MTRUnitTestingCluster{{asUpperCamelCase name}}
@end
{{/if}}
{{/zcl_structs}}
{{#zcl_events}}
@implementation MTR{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Event
- (instancetype)init
{
if (self = [super init]) {
{{#zcl_event_fields}}
{{>init_struct_member label=name type=type cluster=parent.parent.name}}
{{/zcl_event_fields}}
}
return self;
}
- (id)copyWithZone:(NSZone * _Nullable)zone
{
auto other = [[MTR{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Event alloc] init];
{{#zcl_event_fields}}
other.{{asStructPropertyName name}} = self.{{asStructPropertyName name}};
{{/zcl_event_fields}}
return other;
}
- (NSString *)description
{
NSString *descriptionString = [NSString stringWithFormat:@"<%@: {{#zcl_event_fields}}{{asStructPropertyName name}}:%@; {{/zcl_event_fields}}>", NSStringFromClass([self class]){{#zcl_event_fields}},{{#if isArray}}_{{asStructPropertyName name}}{{else if (isOctetString type)}}[_{{asStructPropertyName name}} base64EncodedStringWithOptions:0]{{else}}_{{asStructPropertyName name}}{{/if}}{{/zcl_event_fields}}];
return descriptionString;
}
@end
{{#if (isStrEqual (asUpperCamelCase parent.name) "UnitTesting")}}
@implementation MTRTestClusterCluster{{asUpperCamelCase name}}Event : MTRUnitTestingCluster{{asUpperCamelCase name}}Event
@end
{{/if}}
{{/zcl_events}}
{{/zcl_clusters}}
NS_ASSUME_NONNULL_END