Skip to content

Commit 82579f1

Browse files
kiel-applerestyled-commitswoody-applebzbarsky-apple
authored
[Darwin] MTRDevice -> MTRDevice_Concrete (#34813)
* step 1: duplicate MTRDevice start closing off `MTRDevice` direct use add a note to self / reviewers fix `newBaseDevice` / `removeExpectedValue[s]` error ty @bzbarsky-apple move `MTRDevice_Concrete.h` to Project scope was Public note to self about coming change in MTRDeviceController move some MTRDevice utilities to MTRDevice_Internal.h where they are at least shared between MTRDevice and MTRDevice_Concrete. but probably they merit their own files - the header is getting heavy add subclass-facing init to `MTRDevice` superclass for `MTRDevice_Concrete` code was `NSObject`, but now is `MTRDevice`, which hides its `init`s. fix build of `MTRDevice_Internal.h` Revert "move some MTRDevice utilities" This reverts commit ba7331f. fix MTRDevice_Concrete block-scoped pointer types move clamped number to utilities remove duplicated MTRClampedNumber implementations more `MTRClampedNumber` cleanup duplicate MTRDeviceDelegateInfo for now restore prematurely removed `MTRDevice` methods move common `MTRDeviceClusterData` keys remove now-obsolete include for CodeUtils remove duplicate `MTRDeviceClusterData` remove duplicate key symbols from `MTRDevice_Concrete` remove availability annotations for nonpublic API Restyled by whitespace Restyled by clang-format remove superfluous init/new signatures available by default * remove now-obvious comment * start using `MTRDevice_Concrete` when vending from `MTRDeviceController` * Restyled by clang-format * Update src/darwin/Framework/CHIP/MTRDevice_Concrete.h Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Restyled by clang-format --------- Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Justin Wood <woody@apple.com> Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent 212d6ab commit 82579f1

8 files changed

+4284
-20
lines changed

src/darwin/Framework/CHIP/MTRDevice.mm

+9-14
Original file line numberDiff line numberDiff line change
@@ -142,16 +142,6 @@ - (BOOL)callDelegateSynchronouslyWithBlock:(void (^)(id<MTRDeviceDelegate>))bloc
142142
#endif
143143
@end
144144

145-
NSNumber * MTRClampedNumber(NSNumber * aNumber, NSNumber * min, NSNumber * max)
146-
{
147-
if ([aNumber compare:min] == NSOrderedAscending) {
148-
return min;
149-
} else if ([aNumber compare:max] == NSOrderedDescending) {
150-
return max;
151-
}
152-
return aNumber;
153-
}
154-
155145
/* BEGIN DRAGONS: Note methods here cannot be renamed, and are used by private callers, do not rename, remove or modify behavior here */
156146

157147
@interface NSObject (MatterPrivateForInternalDragonsDoNotFeed)
@@ -252,10 +242,6 @@ @implementation MTRDeviceClusterData {
252242
NSMutableDictionary<NSNumber *, MTRDeviceDataValueDictionary> * _attributes;
253243
}
254244

255-
static NSString * const sDataVersionKey = @"dataVersion";
256-
static NSString * const sAttributesKey = @"attributes";
257-
static NSString * const sLastInitialSubscribeLatencyKey = @"lastInitialSubscribeLatency";
258-
259245
- (void)storeValue:(MTRDeviceDataValueDictionary _Nullable)value forAttribute:(NSNumber *)attribute
260246
{
261247
_attributes[attribute] = value;
@@ -498,6 +484,15 @@ @implementation MTRDevice {
498484
NSMutableSet<MTRDeviceDelegateInfo *> * _delegates;
499485
}
500486

487+
- (instancetype)initForSubclasses
488+
{
489+
if (self = [super init]) {
490+
// nothing, as superclass of MTRDevice is NSObject
491+
}
492+
493+
return self;
494+
}
495+
501496
- (instancetype)initWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller
502497
{
503498
if (self = [super init]) {

src/darwin/Framework/CHIP/MTRDeviceController.mm

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#import "MTRDeviceControllerLocalTestStorage.h"
3232
#import "MTRDeviceControllerStartupParams.h"
3333
#import "MTRDeviceControllerStartupParams_Internal.h"
34+
#import "MTRDevice_Concrete.h"
3435
#import "MTRDevice_Internal.h"
3536
#import "MTRError_Internal.h"
3637
#import "MTRKeypair.h"
@@ -988,7 +989,7 @@ - (MTRDevice *)_setupDeviceForNodeID:(NSNumber *)nodeID prefetchedClusterData:(N
988989
{
989990
os_unfair_lock_assert_owner(&_deviceMapLock);
990991

991-
MTRDevice * deviceToReturn = [[MTRDevice alloc] initWithNodeID:nodeID controller:self];
992+
MTRDevice * deviceToReturn = [[MTRDevice_Concrete alloc] initWithNodeID:nodeID controller:self];
992993
// If we're not running, don't add the device to our map. That would
993994
// create a cycle that nothing would break. Just return the device,
994995
// which will be in exactly the state it would be in if it were created
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
*
3+
* Copyright (c) 2022-2023 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#import <Foundation/Foundation.h>
19+
#import <Matter/MTRDevice.h>
20+
21+
NS_ASSUME_NONNULL_BEGIN
22+
23+
@interface MTRDevice_Concrete : MTRDevice
24+
25+
@end
26+
27+
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)