Skip to content

Commit

Permalink
Restyled by clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
restyled-commits authored and woody-apple committed Aug 17, 2024
1 parent 8e8d4d5 commit 19a222e
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 143 deletions.
51 changes: 27 additions & 24 deletions src/darwin/Framework/CHIP/MTRCluster.mm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ - (id)copyWithZone:(NSZone * _Nullable)zone

#pragma mark - Coding

+ (BOOL)supportsSecureCoding {
+ (BOOL)supportsSecureCoding
{
return YES;
}

Expand All @@ -96,17 +97,17 @@ - (nullable instancetype)initWithCoder:(NSCoder *)decoder
return nil;
}

self.timedWriteTimeout = [decoder decodeObjectOfClass:[NSNumber class] forKey: sTimedWriteTimeoutCodingKey];
self.dataVersion = [decoder decodeObjectOfClass:[NSNumber class] forKey: sDataVersionCodingKey];
self.timedWriteTimeout = [decoder decodeObjectOfClass:[NSNumber class] forKey:sTimedWriteTimeoutCodingKey];
self.dataVersion = [decoder decodeObjectOfClass:[NSNumber class] forKey:sDataVersionCodingKey];

return self;
}

- (void)encodeWithCoder:(NSCoder *)coder
{
if ( self.timedWriteTimeout )
if (self.timedWriteTimeout)
[coder encodeObject:self.timedWriteTimeout forKey:sTimedWriteTimeoutCodingKey];
if ( self.dataVersion )
if (self.dataVersion)
[coder encodeObject:self.dataVersion forKey:sDataVersionCodingKey];
}

Expand All @@ -124,7 +125,8 @@ - (instancetype)init

#pragma mark - Coding

+ (BOOL)supportsSecureCoding {
+ (BOOL)supportsSecureCoding
{
return YES;
}

Expand All @@ -140,19 +142,19 @@ - (nullable instancetype)initWithCoder:(NSCoder *)decoder
return nil;
}

self.filterByFabric = [decoder decodeBoolForKey: sFilterByFabricCoderKey];
self.assumeUnknownAttributesReportable = [decoder decodeBoolForKey: sAssumeUnknownAttributesReportableCoderKey];
self.minEventNumber = [decoder decodeObjectOfClass:[NSNumber class] forKey: sMinEventNumberCoderKey];
self.filterByFabric = [decoder decodeBoolForKey:sFilterByFabricCoderKey];
self.assumeUnknownAttributesReportable = [decoder decodeBoolForKey:sAssumeUnknownAttributesReportableCoderKey];
self.minEventNumber = [decoder decodeObjectOfClass:[NSNumber class] forKey:sMinEventNumberCoderKey];

return self;
}

- (void)encodeWithCoder:(NSCoder *)coder
{
[coder encodeBool:self.filterByFabric forKey:sFilterByFabricCoderKey];
[coder encodeBool: self.assumeUnknownAttributesReportable forKey:sAssumeUnknownAttributesReportableCoderKey];
[coder encodeBool:self.assumeUnknownAttributesReportable forKey:sAssumeUnknownAttributesReportableCoderKey];

if ( self.minEventNumber )
if (self.minEventNumber)
[coder encodeObject:self.minEventNumber forKey:sMinEventNumberCoderKey];
}

Expand Down Expand Up @@ -210,7 +212,8 @@ - (id)copyWithZone:(NSZone * _Nullable)zone
}

#pragma mark - Coding
+ (BOOL)supportsSecureCoding {
+ (BOOL)supportsSecureCoding
{
return YES;
}

Expand All @@ -222,32 +225,32 @@ + (BOOL)supportsSecureCoding {

- (nullable instancetype)initWithCoder:(NSCoder *)decoder
{
self = [super initWithCoder: decoder];
self = [super initWithCoder:decoder];

if (self == nil) {
return nil;
}

self.replaceExistingSubscriptions = [decoder decodeBoolForKey: sReplaceExistingSubscriptionsCoderKey];
self.reportEventsUrgently = [decoder decodeBoolForKey: sReportEventsUrgentlyCoderKey];
self.resubscribeAutomatically = [decoder decodeBoolForKey: sResubscribeAutomaticallyCoderKey];
self.minInterval = [decoder decodeObjectOfClass:[NSNumber class] forKey: sMinIntervalKeyCoderKey];
self.maxInterval = [decoder decodeObjectOfClass:[NSNumber class] forKey: sMaxIntervalKeyCoderKey];
self.replaceExistingSubscriptions = [decoder decodeBoolForKey:sReplaceExistingSubscriptionsCoderKey];
self.reportEventsUrgently = [decoder decodeBoolForKey:sReportEventsUrgentlyCoderKey];
self.resubscribeAutomatically = [decoder decodeBoolForKey:sResubscribeAutomaticallyCoderKey];
self.minInterval = [decoder decodeObjectOfClass:[NSNumber class] forKey:sMinIntervalKeyCoderKey];
self.maxInterval = [decoder decodeObjectOfClass:[NSNumber class] forKey:sMaxIntervalKeyCoderKey];

return self;
}

- (void)encodeWithCoder:(NSCoder *)coder
{
[super encodeWithCoder: coder];
[super encodeWithCoder:coder];

[coder encodeBool: self.replaceExistingSubscriptions forKey:sReplaceExistingSubscriptionsCoderKey];
[coder encodeBool: self.reportEventsUrgently forKey:sReportEventsUrgentlyCoderKey];
[coder encodeBool: self.resubscribeAutomatically forKey:sResubscribeAutomaticallyCoderKey];
[coder encodeBool:self.replaceExistingSubscriptions forKey:sReplaceExistingSubscriptionsCoderKey];
[coder encodeBool:self.reportEventsUrgently forKey:sReportEventsUrgentlyCoderKey];
[coder encodeBool:self.resubscribeAutomatically forKey:sResubscribeAutomaticallyCoderKey];

if ( self.minInterval )
if (self.minInterval)
[coder encodeObject:self.minInterval forKey:sMinIntervalKeyCoderKey];
if ( self.maxInterval )
if (self.maxInterval)
[coder encodeObject:self.maxInterval forKey:sMaxIntervalKeyCoderKey];
}

Expand Down
79 changes: 39 additions & 40 deletions src/darwin/Framework/CHIP/MTRDefines_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,50 +65,49 @@ typedef struct {} variable_hidden_by_mtr_hide;
// Default timed interaction timeout, in ms, if another one is not provided.
#define MTR_DEFAULT_TIMED_INTERACTION_TIMEOUT_MS 10000


#pragma mark - XPC Defines

#define MTR_SIMPLE_REMOTE_XPC_GETTER(NAME, TYPE, DEFAULT_VALUE, GETTER_NAME, PREFIX) \
\
-(TYPE) NAME \
{ \
__block TYPE outValue = DEFAULT_VALUE; \
\
NSXPCConnection * xpcConnection = nil; \
\
[[xpcConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { \
MTR_LOG_ERROR("Error: %@", error); \
}] PREFIX \
GETTER_NAME:^(TYPE returnValue) { \
outValue = returnValue; \
}]; \
\
return outValue; \
#define MTR_SIMPLE_REMOTE_XPC_GETTER(NAME, TYPE, DEFAULT_VALUE, GETTER_NAME, PREFIX) \
\
-(TYPE) NAME \
{ \
__block TYPE outValue = DEFAULT_VALUE; \
\
NSXPCConnection * xpcConnection = nil; \
\
[[xpcConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { \
MTR_LOG_ERROR("Error: %@", error); \
}] PREFIX \
GETTER_NAME:^(TYPE returnValue) { \
outValue = returnValue; \
}]; \
\
return outValue; \
}

#define MTR_SIMPLE_REMOTE_XPC_COMMAND(METHOD_SIGNATURE, ADDITIONAL_ARGUMENTS, PREFIX) \
\
-(void) METHOD_SIGNATURE \
{ \
NSXPCConnection * xpcConnection = nil; \
\
[[xpcConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { \
MTR_LOG_ERROR("Error: %@", error); \
}] PREFIX ADDITIONAL_ARGUMENTS]; \
#define MTR_SIMPLE_REMOTE_XPC_COMMAND(METHOD_SIGNATURE, ADDITIONAL_ARGUMENTS, PREFIX) \
\
-(void) METHOD_SIGNATURE \
{ \
NSXPCConnection * xpcConnection = nil; \
\
[[xpcConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { \
MTR_LOG_ERROR("Error: %@", error); \
}] PREFIX ADDITIONAL_ARGUMENTS]; \
}

#define MTR_COMPLEX_REMOTE_XPC_GETTER(SIGNATURE, TYPE, DEFAULT_VALUE, ADDITIONAL_ARGUMENTS, PREFIX) \
- (TYPE) SIGNATURE \
{ \
__block TYPE outValue = DEFAULT_VALUE; \
\
NSXPCConnection * xpcConnection = nil; \
\
[[xpcConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { \
MTR_LOG_ERROR("Error: %@", error); \
}] PREFIX ADDITIONAL_ARGUMENTS:^(TYPE returnValue) { \
outValue = returnValue; \
}]; \
\
return outValue; \
#define MTR_COMPLEX_REMOTE_XPC_GETTER(SIGNATURE, TYPE, DEFAULT_VALUE, ADDITIONAL_ARGUMENTS, PREFIX) \
-(TYPE) SIGNATURE \
{ \
__block TYPE outValue = DEFAULT_VALUE; \
\
NSXPCConnection * xpcConnection = nil; \
\
[[xpcConnection synchronousRemoteObjectProxyWithErrorHandler:^(NSError * _Nonnull error) { \
MTR_LOG_ERROR("Error: %@", error); \
}] PREFIX ADDITIONAL_ARGUMENTS:^(TYPE returnValue) { \
outValue = returnValue; \
}]; \
\
return outValue; \
}
2 changes: 1 addition & 1 deletion src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ - (nullable instancetype)initWithParameters:(MTRDeviceControllerAbstractParamete
/// because of the enormous overlap of params.
if ([parameters isKindOfClass:MTRDeviceControllerXPCParameters.class]) {
if ([parameters isKindOfClass:MTRDeviceControllerMachServiceXPCParameters.class]) {
MTRDeviceControllerMachServiceXPCParameters * xpcParameters = (MTRDeviceControllerMachServiceXPCParameters *)parameters;
MTRDeviceControllerMachServiceXPCParameters * xpcParameters = (MTRDeviceControllerMachServiceXPCParameters *) parameters;
MTR_LOG_DEBUG("%s: got XPC parameters, getting XPC device controller", __PRETTY_FUNCTION__);

NSString * machServiceName = xpcParameters.machServiceName;
Expand Down
8 changes: 4 additions & 4 deletions src/darwin/Framework/CHIP/MTRDeviceController_XPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
NS_ASSUME_NONNULL_BEGIN

MTR_TESTABLE
@interface MTRDeviceController_XPC : MTRDeviceController<MTRXPCClientProtocol>
- (id)initWithUniqueIdentifier:(NSUUID *)UUID xpConnectionBlock:(NSXPCConnection * (^)(void))connectionBlock;
@interface MTRDeviceController_XPC : MTRDeviceController <MTRXPCClientProtocol>
- (id)initWithUniqueIdentifier:(NSUUID *)UUID xpConnectionBlock:(NSXPCConnection * (^)(void) )connectionBlock;
#ifdef MTR_HAVE_MACH_SERVICE_NAME_CONSTRUCTOR
- (id)initWithUniqueIdentifier:(NSUUID *)UUID machServiceName:(NSString *)machServiceName options:(NSXPCConnectionOptions)options
#endif

@end
@end

NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_END
Loading

0 comments on commit 19a222e

Please sign in to comment.