Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Address review comments.
Browse files Browse the repository at this point in the history
bzbarsky-apple committed Sep 19, 2024
1 parent 2d7ea48 commit 106bcce
Showing 2 changed files with 21 additions and 16 deletions.
14 changes: 14 additions & 0 deletions src/darwin/Framework/CHIP/MTRDefines_Internal.h
Original file line number Diff line number Diff line change
@@ -152,3 +152,17 @@ typedef struct {} variable_hidden_by_mtr_hide;
#endif

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

// Implementation details for MTR_REQUIRE_SUBCLASS_IMPL_FOR_CLASS.
#ifdef DEBUG
#define MTR_REQUIRE_SUBCLASS_IMPL_WITH_CLASS_AND_SELECTOR(message, className, selector) \
MTR_LOG_ERROR(message, className, selector); \
NSAssert(NO, @message, className, selector)
#else // DEBUG
#define MTR_REQUIRE_SUBCLASS_IMPL_WITH_SELECTOR(message, selector) \
MTR_LOG_ERROR(message, className, selector)
#endif // DEBUG

// Class is expected to be a Class
#define MTR_REQUIRE_SUBCLASS_IMPL_FOR_CLASS(class) \
MTR_REQUIRE_SUBCLASS_IMPL_WITH_CLASS_AND_SELECTOR("%@ %@ must be handled by subclasses", NSStringFromClass(class), NSStringFromSelector(_cmd))
23 changes: 7 additions & 16 deletions src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
@@ -55,17 +55,8 @@
// 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")
#define MTR_REQUIRE_SUBCLASS_IMPL() \
MTR_REQUIRE_SUBCLASS_IMPL_FOR_CLASS(MTRDevice.class)

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

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

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

@@ -1359,7 +1350,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_REQUIRE_SUBCLASS_IMPL();
}

- (void)_invokeKnownCommandWithEndpointID:(NSNumber *)endpointID
@@ -1468,7 +1459,7 @@ - (NSDictionary *)_dataValueWithoutDataVersion:(NSDictionary *)attributeValue

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

0 comments on commit 106bcce

Please sign in to comment.