Skip to content

Commit

Permalink
Address review comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed Sep 19, 2024
1 parent 2d7ea48 commit eb4db0f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
14 changes: 14 additions & 0 deletions src/darwin/Framework/CHIP/MTRDefines_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,17 @@ typedef struct {} variable_hidden_by_mtr_hide;
#endif

#define MTR_YES_NO(x) ((x) ? @"YES" : @"NO")

#ifdef DEBUG
#define _MTR_ABSTRACT_METHOD_IMPL(message, ...) \
do { \
MTR_LOG_ERROR(message, __VA_ARGS__); \
@throw [NSException exceptionWithName:NSInternalInconsistencyException reason:[NSString stringWithFormat:@message, __VA_ARGS__] userInfo:nil]; \
} while (0)
#else // DEBUG
#define _MTR_ABSTRACT_METHOD_IMPL(message, ...) \
MTR_LOG_ERROR(message, __VA_ARGS__)
#endif // DEBUG

#define MTR_ABSTRACT_METHOD() \
_MTR_ABSTRACT_METHOD_IMPL("%@ or some ancestor must implement %@", self.class, NSStringFromSelector(_cmd))
22 changes: 5 additions & 17 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,6 @@
// Disabling pending crashes
#define ENABLE_CONNECTIVITY_MONITORING 0

#ifdef DEBUG
#define MTR_REQUIRE_SUBCLASS_IMPL_PASTED(message) \
MTR_LOG_ERROR(message); \
NSAssert(NO, @message)
#else // DEBUG
#debug MTR_REQUIRE_SUBCLASS_IMPL_PASTED(message) \
MTR_LOG_ERROR(message)
#endif // DEBUG

#define MTR_REQUIRE_SUBCLASS_IMPL(selectorString) \
MTR_REQUIRE_SUBCLASS_IMPL_PASTED("MTRDevice " selectorString " must be handled by subclasses")

@implementation MTRDeviceDelegateInfo
- (instancetype)initWithDelegate:(id<MTRDeviceDelegate>)delegate queue:(dispatch_queue_t)queue interestedPathsForAttributes:(NSArray * _Nullable)interestedPathsForAttributes interestedPathsForEvents:(NSArray * _Nullable)interestedPathsForEvents
{
Expand Down Expand Up @@ -1260,7 +1248,7 @@ - (NSUInteger)unitTestNonnullDelegateCount
attributeID:(NSNumber *)attributeID
params:(MTRReadParams * _Nullable)params
{
MTR_REQUIRE_SUBCLASS_IMPL("readAttributeWithEndpointID:clusterID:attributeID:params:");
MTR_ABSTRACT_METHOD();
return nil;
}

Expand All @@ -1271,12 +1259,12 @@ - (void)writeAttributeWithEndpointID:(NSNumber *)endpointID
expectedValueInterval:(NSNumber *)expectedValueInterval
timedWriteTimeout:(NSNumber * _Nullable)timeout
{
MTR_REQUIRE_SUBCLASS_IMPL("writeAttributeWithEndpointID:clusterID:attributeID:value:expectedValueInterval:timedWriteTimeout:");
MTR_ABSTRACT_METHOD();
}

- (NSArray<NSDictionary<NSString *, id> *> *)readAttributePaths:(NSArray<MTRAttributeRequestPath *> *)attributePaths
{
MTR_REQUIRE_SUBCLASS_IMPL("readAttributePaths:");
MTR_ABSTRACT_METHOD();
return [NSArray array];
}

Expand Down Expand Up @@ -1359,7 +1347,7 @@ - (void)_invokeCommandWithEndpointID:(NSNumber *)endpointID
queue:(dispatch_queue_t)queue
completion:(MTRDeviceResponseHandler)completion
{
MTR_REQUIRE_SUBCLASS_IMPL("_invokeCommandWithEndpointID:clusterID:commandID:commandFields:expectedValues:expectedValueInterval:timedInvokeTimeout:serverSideProcessingTimeout:queue:completion:");
MTR_ABSTRACT_METHOD();
}

- (void)_invokeKnownCommandWithEndpointID:(NSNumber *)endpointID
Expand Down Expand Up @@ -1468,7 +1456,7 @@ - (NSDictionary *)_dataValueWithoutDataVersion:(NSDictionary *)attributeValue

- (NSArray<NSDictionary<NSString *, id> *> *)getAllAttributesReport
{
MTR_REQUIRE_SUBCLASS_IMPL("getAllAttributesReport");
MTR_ABSTRACT_METHOD();
return nil;
}

Expand Down

0 comments on commit eb4db0f

Please sign in to comment.