55
55
// Disabling pending crashes
56
56
#define ENABLE_CONNECTIVITY_MONITORING 0
57
57
58
+ #ifdef DEBUG
59
+ #define MTR_REQUIRE_SUBCLASS_IMPL_PASTED (message ) \
60
+ MTR_LOG_ERROR (message); \
61
+ NSAssert (NO , @message)
62
+ #else // DEBUG
63
+ #debug MTR_REQUIRE_SUBCLASS_IMPL_PASTED (message) \
64
+ MTR_LOG_ERROR(message)
65
+ #endif // DEBUG
66
+
67
+ #define MTR_REQUIRE_SUBCLASS_IMPL (selectorString ) \
68
+ MTR_REQUIRE_SUBCLASS_IMPL_PASTED (" MTRDevice " selectorString " must be handled by subclasses" )
69
+
58
70
@implementation MTRDeviceDelegateInfo
59
71
- (instancetype )initWithDelegate:(id <MTRDeviceDelegate>)delegate queue:(dispatch_queue_t )queue interestedPathsForAttributes:(NSArray * _Nullable)interestedPathsForAttributes interestedPathsForEvents:(NSArray * _Nullable)interestedPathsForEvents
60
72
{
@@ -1248,12 +1260,7 @@ - (NSUInteger)unitTestNonnullDelegateCount
1248
1260
attributeID : (NSNumber *)attributeID
1249
1261
params : (MTRReadParams * _Nullable)params
1250
1262
{
1251
- #define MTRDeviceErrorStr " MTRDevice readAttributeWithEndpointID:clusterID:attributeID:params: must be handled by subclasses"
1252
- MTR_LOG_ERROR (MTRDeviceErrorStr);
1253
- #ifdef DEBUG
1254
- NSAssert (NO , @MTRDeviceErrorStr);
1255
- #endif // DEBUG
1256
- #undef MTRDeviceErrorStr
1263
+ MTR_REQUIRE_SUBCLASS_IMPL (" readAttributeWithEndpointID:clusterID:attributeID:params:" );
1257
1264
return nil ;
1258
1265
}
1259
1266
@@ -1264,22 +1271,12 @@ - (void)writeAttributeWithEndpointID:(NSNumber *)endpointID
1264
1271
expectedValueInterval : (NSNumber *)expectedValueInterval
1265
1272
timedWriteTimeout : (NSNumber * _Nullable)timeout
1266
1273
{
1267
- #define MTRDeviceErrorStr " MTRDevice writeAttributeWithEndpointID:clusterID:attributeID:value:expectedValueInterval:timedWriteTimeout: must be handled by subclasses"
1268
- MTR_LOG_ERROR (MTRDeviceErrorStr);
1269
- #ifdef DEBUG
1270
- NSAssert (NO , @MTRDeviceErrorStr);
1271
- #endif // DEBUG
1272
- #undef MTRDeviceErrorStr
1274
+ MTR_REQUIRE_SUBCLASS_IMPL (" writeAttributeWithEndpointID:clusterID:attributeID:value:expectedValueInterval:timedWriteTimeout:" );
1273
1275
}
1274
1276
1275
1277
- (NSArray <NSDictionary<NSString *, id> *> *)readAttributePaths : (NSArray <MTRAttributeRequestPath *> *)attributePaths
1276
1278
{
1277
- #define MTRDeviceErrorStr " MTRDevice readAttributePaths: must be handled by subclasses"
1278
- MTR_LOG_ERROR (MTRDeviceErrorStr);
1279
- #ifdef DEBUG
1280
- NSAssert (NO , @MTRDeviceErrorStr);
1281
- #endif // DEBUG
1282
- #undef MTRDeviceErrorStr
1279
+ MTR_REQUIRE_SUBCLASS_IMPL (" readAttributePaths:" );
1283
1280
return [NSArray array ];
1284
1281
}
1285
1282
@@ -1362,12 +1359,7 @@ - (void)_invokeCommandWithEndpointID:(NSNumber *)endpointID
1362
1359
queue : (dispatch_queue_t )queue
1363
1360
completion : (MTRDeviceResponseHandler)completion
1364
1361
{
1365
- #define MTRDeviceErrorStr " MTRDevice _invokeCommandWithEndpointID: must be handled by subclasses"
1366
- MTR_LOG_ERROR (MTRDeviceErrorStr);
1367
- #ifdef DEBUG
1368
- NSAssert (NO , @MTRDeviceErrorStr);
1369
- #endif // DEBUG
1370
- #undef MTRDeviceErrorStr
1362
+ MTR_REQUIRE_SUBCLASS_IMPL (" _invokeCommandWithEndpointID:clusterID:commandID:commandFields:expectedValues:expectedValueInterval:timedInvokeTimeout:serverSideProcessingTimeout:queue:completion:" );
1371
1363
}
1372
1364
1373
1365
- (void )_invokeKnownCommandWithEndpointID : (NSNumber *)endpointID
@@ -1476,12 +1468,7 @@ - (NSDictionary *)_dataValueWithoutDataVersion:(NSDictionary *)attributeValue
1476
1468
1477
1469
- (NSArray <NSDictionary<NSString *, id> *> *)getAllAttributesReport
1478
1470
{
1479
- #define MTRDeviceErrorStr " MTRDevice getAllAttributesReport must be handled by subclasses that support it"
1480
- MTR_LOG_ERROR (MTRDeviceErrorStr);
1481
- #ifdef DEBUG
1482
- NSAssert (NO , @MTRDeviceErrorStr);
1483
- #endif // DEBUG
1484
- #undef MTRDeviceErrorStr
1471
+ MTR_REQUIRE_SUBCLASS_IMPL (" getAllAttributesReport" );
1485
1472
return nil ;
1486
1473
}
1487
1474
0 commit comments