Skip to content

Commit 1605828

Browse files
kiel-applerestyled-commits
authored andcommitted
Darwin: Namespace common class names (#33459)
* Darwin: Namespace `Download` and `Downloads` * Restyled by clang-format * namespace `UUIDHelper` * fix `gn` build for `MTRUUIDHelper` * Restyled by clang-format --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent eef8ea4 commit 1605828

File tree

7 files changed

+49
-49
lines changed

7 files changed

+49
-49
lines changed

src/controller/python/chip/ble/darwin/Scanning.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <ble/Ble.h>
22
#include <lib/support/CHIPMem.h>
33
#include <lib/support/logging/CHIPLogging.h>
4-
#include <platform/Darwin/UUIDHelper.h>
4+
#include <platform/Darwin/MTRUUIDHelper.h>
55

66
#import <CoreBluetooth/CoreBluetooth.h>
77

@@ -45,7 +45,7 @@ - (id)initWithContext:(PyObject *)context
4545
{
4646
self = [super init];
4747
if (self) {
48-
self.shortServiceUUID = [UUIDHelper GetShortestServiceUUID:&chip::Ble::CHIP_BLE_SVC_ID];
48+
self.shortServiceUUID = [MTRUUIDHelper GetShortestServiceUUID:&chip::Ble::CHIP_BLE_SVC_ID];
4949

5050
_workQueue = dispatch_queue_create("com.chip.python.ble.work_queue", DISPATCH_QUEUE_SERIAL);
5151
_timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, _workQueue);

src/darwin/Framework/CHIP/MTRDiagnosticLogsDownloader.mm

+36-36
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
NS_ASSUME_NONNULL_BEGIN
4343

44-
@interface Download : NSObject
44+
@interface MTRDownload : NSObject
4545
@property (nonatomic) NSString * fileDesignator;
4646
@property (nonatomic) NSNumber * fabricIndex;
4747
@property (nonatomic) NSNumber * nodeID;
@@ -55,7 +55,7 @@ - (instancetype)initWithType:(MTRDiagnosticLogType)type
5555
nodeID:(NSNumber *)nodeID
5656
queue:(dispatch_queue_t)queue
5757
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
58-
done:(void (^)(Download * finishedDownload))done;
58+
done:(void (^)(MTRDownload * finishedDownload))done;
5959

6060
- (void)writeToFile:(NSData *)data error:(out NSError **)error;
6161

@@ -69,24 +69,24 @@ - (void)success;
6969
- (void)failure:(NSError * _Nullable)error;
7070
@end
7171

72-
@interface Downloads : NSObject
73-
@property (nonatomic, strong) NSMutableArray<Download *> * downloads;
72+
@interface MTRDownloads : NSObject
73+
@property (nonatomic, strong) NSMutableArray<MTRDownload *> * downloads;
7474

75-
- (Download * _Nullable)get:(NSString *)fileDesignator
76-
fabricIndex:(NSNumber *)fabricIndex
77-
nodeID:(NSNumber *)nodeID;
75+
- (MTRDownload * _Nullable)get:(NSString *)fileDesignator
76+
fabricIndex:(NSNumber *)fabricIndex
77+
nodeID:(NSNumber *)nodeID;
7878

79-
- (Download * _Nullable)add:(MTRDiagnosticLogType)type
80-
fabricIndex:(NSNumber *)fabricIndex
81-
nodeID:(NSNumber *)nodeID
82-
queue:(dispatch_queue_t)queue
83-
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
84-
done:(void (^)(Download * finishedDownload))done;
79+
- (MTRDownload * _Nullable)add:(MTRDiagnosticLogType)type
80+
fabricIndex:(NSNumber *)fabricIndex
81+
nodeID:(NSNumber *)nodeID
82+
queue:(dispatch_queue_t)queue
83+
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
84+
done:(void (^)(MTRDownload * finishedDownload))done;
8585
@end
8686

8787
@interface MTRDiagnosticLogsDownloader ()
8888
@property (readonly) DiagnosticLogsDownloaderBridge * bridge;
89-
@property (nonatomic, strong) Downloads * downloads;
89+
@property (nonatomic, strong) MTRDownloads * downloads;
9090

9191
/**
9292
* Notify the delegate when a BDX Session starts for some logs.
@@ -134,21 +134,21 @@ - (void)handleBDXTransferSessionEndForFileDesignator:(NSString *)fileDesignator
134134
CHIP_ERROR OnTransferEnd(chip::bdx::BDXTransferProxy * transfer, CHIP_ERROR error) override;
135135
CHIP_ERROR OnTransferData(chip::bdx::BDXTransferProxy * transfer, const chip::ByteSpan & data) override;
136136

137-
CHIP_ERROR StartBDXTransferTimeout(Download * download, uint16_t timeoutInSeconds);
138-
void CancelBDXTransferTimeout(Download * download);
137+
CHIP_ERROR StartBDXTransferTimeout(MTRDownload * download, uint16_t timeoutInSeconds);
138+
void CancelBDXTransferTimeout(MTRDownload * download);
139139

140140
private:
141141
static void OnTransferTimeout(chip::System::Layer * layer, void * context);
142142
MTRDiagnosticLogsDownloader * __weak mDelegate;
143143
};
144144

145-
@implementation Download
145+
@implementation MTRDownload
146146
- (instancetype)initWithType:(MTRDiagnosticLogType)type
147147
fabricIndex:(NSNumber *)fabricIndex
148148
nodeID:(NSNumber *)nodeID
149149
queue:(dispatch_queue_t)queue
150150
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
151-
done:(void (^)(Download * finishedDownload))done;
151+
done:(void (^)(MTRDownload * finishedDownload))done;
152152
{
153153
self = [super init];
154154
if (self) {
@@ -158,7 +158,7 @@ - (instancetype)initWithType:(MTRDiagnosticLogType)type
158158
__weak typeof(self) weakSelf = self;
159159
auto bdxTransferDone = ^(NSError * bdxError) {
160160
dispatch_async(queue, ^{
161-
Download * strongSelf = weakSelf;
161+
MTRDownload * strongSelf = weakSelf;
162162
if (strongSelf) {
163163
// If a fileHandle exists, it means that the BDX session has been initiated and a file has
164164
// been created to host the data of the session. So even if there is an error there may be some
@@ -303,7 +303,7 @@ - (NSString *)_toTypeString:(MTRDiagnosticLogType)type
303303

304304
@end
305305

306-
@implementation Downloads
306+
@implementation MTRDownloads
307307
- (instancetype)init
308308
{
309309
if (self = [super init]) {
@@ -315,15 +315,15 @@ - (instancetype)init
315315
- (void)dealloc
316316
{
317317
auto error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INTERNAL];
318-
for (Download * download in _downloads) {
318+
for (MTRDownload * download in _downloads) {
319319
[download failure:error];
320320
}
321321
_downloads = nil;
322322
}
323323

324-
- (Download * _Nullable)get:(NSString *)fileDesignator fabricIndex:(NSNumber *)fabricIndex nodeID:(NSNumber *)nodeID
324+
- (MTRDownload * _Nullable)get:(NSString *)fileDesignator fabricIndex:(NSNumber *)fabricIndex nodeID:(NSNumber *)nodeID
325325
{
326-
for (Download * download in _downloads) {
326+
for (MTRDownload * download in _downloads) {
327327
if ([download matches:fileDesignator fabricIndex:fabricIndex nodeID:nodeID]) {
328328
return download;
329329
}
@@ -332,23 +332,23 @@ - (Download * _Nullable)get:(NSString *)fileDesignator fabricIndex:(NSNumber *)f
332332
return nil;
333333
}
334334

335-
- (Download * _Nullable)add:(MTRDiagnosticLogType)type
336-
fabricIndex:(NSNumber *)fabricIndex
337-
nodeID:(NSNumber *)nodeID
338-
queue:(dispatch_queue_t)queue
339-
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
340-
done:(void (^)(Download * finishedDownload))done
335+
- (MTRDownload * _Nullable)add:(MTRDiagnosticLogType)type
336+
fabricIndex:(NSNumber *)fabricIndex
337+
nodeID:(NSNumber *)nodeID
338+
queue:(dispatch_queue_t)queue
339+
completion:(void (^)(NSURL * _Nullable url, NSError * _Nullable error))completion
340+
done:(void (^)(MTRDownload * finishedDownload))done
341341
{
342342
assertChipStackLockedByCurrentThread();
343343

344-
auto download = [[Download alloc] initWithType:type fabricIndex:fabricIndex nodeID:nodeID queue:queue completion:completion done:done];
344+
auto download = [[MTRDownload alloc] initWithType:type fabricIndex:fabricIndex nodeID:nodeID queue:queue completion:completion done:done];
345345
VerifyOrReturnValue(nil != download, nil);
346346

347347
[_downloads addObject:download];
348348
return download;
349349
}
350350

351-
- (void)remove:(Download *)download
351+
- (void)remove:(MTRDownload *)download
352352
{
353353
assertChipStackLockedByCurrentThread();
354354

@@ -362,7 +362,7 @@ - (instancetype)init
362362
assertChipStackLockedByCurrentThread();
363363

364364
if (self = [super init]) {
365-
_downloads = [[Downloads alloc] init];
365+
_downloads = [[MTRDownloads alloc] init];
366366
_bridge = new DiagnosticLogsDownloaderBridge(self);
367367
if (_bridge == nullptr) {
368368
MTR_LOG_ERROR("Error: %@", kErrorInitDiagnosticLogsDownloader);
@@ -406,7 +406,7 @@ - (void)downloadLogFromNodeWithID:(NSNumber *)nodeID
406406
}
407407

408408
// This block is always called when a download is finished.
409-
auto done = ^(Download * finishedDownload) {
409+
auto done = ^(MTRDownload * finishedDownload) {
410410
[controller asyncDispatchToMatterQueue:^() {
411411
[self->_downloads remove:finishedDownload];
412412

@@ -593,13 +593,13 @@ - (void)handleBDXTransferSessionEndForFileDesignator:(NSString *)fileDesignator
593593
return CHIP_NO_ERROR;
594594
}
595595

596-
CHIP_ERROR DiagnosticLogsDownloaderBridge::StartBDXTransferTimeout(Download * download, uint16_t timeoutInSeconds)
596+
CHIP_ERROR DiagnosticLogsDownloaderBridge::StartBDXTransferTimeout(MTRDownload * download, uint16_t timeoutInSeconds)
597597
{
598598
assertChipStackLockedByCurrentThread();
599599
return chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(timeoutInSeconds), OnTransferTimeout, (__bridge void *) download);
600600
}
601601

602-
void DiagnosticLogsDownloaderBridge::CancelBDXTransferTimeout(Download * download)
602+
void DiagnosticLogsDownloaderBridge::CancelBDXTransferTimeout(MTRDownload * download)
603603
{
604604
assertChipStackLockedByCurrentThread();
605605
chip::DeviceLayer::SystemLayer().CancelTimer(OnTransferTimeout, (__bridge void *) download);
@@ -609,7 +609,7 @@ - (void)handleBDXTransferSessionEndForFileDesignator:(NSString *)fileDesignator
609609
{
610610
assertChipStackLockedByCurrentThread();
611611

612-
auto * download = (__bridge Download *) context;
612+
auto * download = (__bridge MTRDownload *) context;
613613
VerifyOrReturn(nil != download);
614614

615615
// If there is no abortHandler, it means that the BDX transfer has not started.

src/platform/Darwin/BUILD.gn

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ static_library("Darwin") {
130130
"BleConnectionDelegateImpl.mm",
131131
"BlePlatformDelegate.h",
132132
"BlePlatformDelegateImpl.mm",
133-
"UUIDHelper.h",
134-
"UUIDHelperImpl.mm",
133+
"MTRUUIDHelper.h",
134+
"MTRUUIDHelperImpl.mm",
135135
]
136136
}
137137
}

src/platform/Darwin/BleConnectionDelegateImpl.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
#include <setup_payload/SetupPayload.h>
3535
#include <tracing/metric_event.h>
3636

37+
#import "MTRUUIDHelper.h"
3738
#import "PlatformMetricKeys.h"
38-
#import "UUIDHelper.h"
3939

4040
using namespace chip::Ble;
4141
using namespace chip::DeviceLayer;
@@ -245,7 +245,7 @@ - (id)initWithQueue:(dispatch_queue_t)queue
245245
{
246246
self = [super init];
247247
if (self) {
248-
self.shortServiceUUID = [UUIDHelper GetShortestServiceUUID:&chip::Ble::CHIP_BLE_SVC_ID];
248+
self.shortServiceUUID = [MTRUUIDHelper GetShortestServiceUUID:&chip::Ble::CHIP_BLE_SVC_ID];
249249
_chipWorkQueue = chip::DeviceLayer::PlatformMgrImpl().GetWorkQueue();
250250
_workQueue = queue;
251251
_centralManager = [CBCentralManager alloc];

src/platform/Darwin/BlePlatformDelegateImpl.mm

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <lib/support/logging/CHIPLogging.h>
3030
#include <platform/Darwin/BlePlatformDelegate.h>
3131

32-
#import "UUIDHelper.h"
32+
#import "MTRUUIDHelper.h"
3333

3434
using namespace ::chip;
3535
using namespace ::chip::Ble;
@@ -47,7 +47,7 @@
4747
return found;
4848
}
4949

50-
CBUUID * serviceId = [UUIDHelper GetShortestServiceUUID:svcId];
50+
CBUUID * serviceId = [MTRUUIDHelper GetShortestServiceUUID:svcId];
5151
CBUUID * characteristicId = [CBUUID UUIDWithData:[NSData dataWithBytes:charId->bytes length:sizeof(charId->bytes)]];
5252
CBPeripheral * peripheral = (__bridge CBPeripheral *) connObj;
5353

@@ -74,7 +74,7 @@
7474
return found;
7575
}
7676

77-
CBUUID * serviceId = [UUIDHelper GetShortestServiceUUID:svcId];
77+
CBUUID * serviceId = [MTRUUIDHelper GetShortestServiceUUID:svcId];
7878
CBUUID * characteristicId = characteristicId = [CBUUID UUIDWithData:[NSData dataWithBytes:charId->bytes
7979
length:sizeof(charId->bytes)]];
8080
CBPeripheral * peripheral = (__bridge CBPeripheral *) connObj;
@@ -131,7 +131,7 @@
131131
return found;
132132
}
133133

134-
CBUUID * serviceId = [UUIDHelper GetShortestServiceUUID:svcId];
134+
CBUUID * serviceId = [MTRUUIDHelper GetShortestServiceUUID:svcId];
135135
CBUUID * characteristicId = [CBUUID UUIDWithData:[NSData dataWithBytes:charId->bytes length:sizeof(charId->bytes)]];
136136
NSData * data = [NSData dataWithBytes:pBuf->Start() length:pBuf->DataLength()];
137137
CBPeripheral * peripheral = (__bridge CBPeripheral *) connObj;

src/platform/Darwin/UUIDHelper.h src/platform/Darwin/MTRUUIDHelper.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121

2222
#import <CoreBluetooth/CoreBluetooth.h>
2323

24-
@interface UUIDHelper : NSObject
24+
@interface MTRUUIDHelper : NSObject
2525
+ (CBUUID *)GetShortestServiceUUID:(const chip::Ble::ChipBleUUID *)svcId;
2626
@end

src/platform/Darwin/UUIDHelperImpl.mm src/platform/Darwin/MTRUUIDHelperImpl.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
#error This file must be compiled with ARC. Use -fobjc-arc flag (or convert project to ARC).
2121
#endif
2222

23-
#import "UUIDHelper.h"
23+
#import "MTRUUIDHelper.h"
2424

25-
@implementation UUIDHelper
25+
@implementation MTRUUIDHelper
2626

2727
+ (CBUUID *)GetShortestServiceUUID:(const chip::Ble::ChipBleUUID *)svcId
2828
{

0 commit comments

Comments
 (0)