blob: 83f1183648330b71dfeb2279292de47cf23d3c30 [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 preserveAcronyms=true) "Cluster" (asUpperCamelCase name preserveAcronyms=true))}}
{{!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}}
{{#unless (isStrEqual (asUpperCamelCase parent.name preserveAcronyms=true) (compatClusterNameRemapping parent.name))}}
@implementation MTR{{compatClusterNameRemapping parent.name}}Cluster{{asUpperCamelCase name}} : MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}
@end
{{/unless}}
{{/if}}
{{/zcl_structs}}
{{#zcl_events}}
@implementation MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}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 preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}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
{{#unless (isStrEqual (asUpperCamelCase parent.name preserveAcronyms=true) (compatClusterNameRemapping parent.name))}}
@implementation MTR{{compatClusterNameRemapping parent.name}}Cluster{{asUpperCamelCase name}}Event : MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}Event
@end
{{/unless}}
{{/zcl_events}}
{{/zcl_clusters}}
NS_ASSUME_NONNULL_END