Skip to content

Commit

Permalink
Better logging when Darwin.framework is asked to encode an incorrect …
Browse files Browse the repository at this point in the history
…type in a list. (#36599)
  • Loading branch information
bzbarsky-apple authored Nov 22, 2024
1 parent ab838dd commit e634040
Show file tree
Hide file tree
Showing 5 changed files with 250 additions and 164 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "MTRClusterStateCacheContainer_Internal.h"
#import "MTRCommandPayloadsObjc.h"
#import "MTRDevice_Internal.h"
#import "MTRLogging_Internal.h"
#import "MTRStructsObjc.h"
#import "NSStringSpanConversion.h"
#import "NSDataSpanConversion.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#import "MTRCommandPayloads_Internal.h"
#import "MTRCommandPayloadExtensions_Internal.h"
#import "MTRBaseDevice_Internal.h"
#import "MTRDefines_Internal.h"
#import "MTRError_Internal.h"
#import "MTRLogging_Internal.h"
#import "NSStringSpanConversion.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
}
listFreer.add(listHolder_{{depth}});
for (size_t i_{{depth}} = 0; i_{{depth}} < {{source}}.count; ++i_{{depth}}) {
if ( ! [{{source}}[i_{{depth}}] isKindOfClass: [{{asObjectiveCClass type cluster forceNotList=true}} class]] ) {
auto element_{{depth}} = MTR_SAFE_CAST({{source}}[i_{{depth}}], {{asObjectiveCClass type cluster forceNotList=true}});
if (!element_{{depth}}) {
// Wrong kind of value.
MTR_LOG_ERROR("%@ incorrectly present in list of %@", {{source}}[i_{{depth}}], NSStringFromClass({{asObjectiveCClass type cluster forceNotList=true}}.class));
{{errorCode}}
}
auto element_{{depth}} = ({{asObjectiveCClass type cluster forceNotList=true}} *){{source}}[i_{{depth}}];
{{>encode_value target=(concat "listHolder_" depth "->mList[i_" depth "]") source=(concat "element_" depth) cluster=cluster errorCode=errorCode depth=(incrementDepth depth) isArray=false}}
}
{{target}} = ListType_{{depth}}(listHolder_{{depth}}->mList, {{source}}.count);
Expand Down
Loading

0 comments on commit e634040

Please sign in to comment.