diff --git a/examples/chip-tool-darwin/main.m b/examples/chip-tool-darwin/main.m index 41057656779108..18b028b5d6deba 100644 --- a/examples/chip-tool-darwin/main.m +++ b/examples/chip-tool-darwin/main.m @@ -19,7 +19,6 @@ #import #import #import -#import #import #import #import diff --git a/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj b/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj index 46c561108c8a30..4aa1e2121c19a3 100644 --- a/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/CHIP.xcodeproj/project.pbxproj @@ -49,6 +49,7 @@ 2CB7163C252E8A7C0026E2BB /* CHIPDevicePairingDelegateBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2CB71639252E8A7B0026E2BB /* CHIPDevicePairingDelegateBridge.mm */; }; 2CB7163F252F731E0026E2BB /* CHIPDevicePairingDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = 2CB7163E252F731E0026E2BB /* CHIPDevicePairingDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; 2FD775552695557E00FF4B12 /* error-mapping.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2FD775542695557E00FF4B12 /* error-mapping.cpp */; }; + 5129BCFD26A9EE3300122DDF /* CHIPError.h in Headers */ = {isa = PBXBuildFile; fileRef = 5129BCFC26A9EE3300122DDF /* CHIPError.h */; settings = {ATTRIBUTES = (Public, ); }; }; 991DC0842475F45400C13860 /* CHIPDeviceController.h in Headers */ = {isa = PBXBuildFile; fileRef = 991DC0822475F45400C13860 /* CHIPDeviceController.h */; settings = {ATTRIBUTES = (Public, ); }; }; 991DC0892475F47D00C13860 /* CHIPDeviceController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 991DC0872475F47D00C13860 /* CHIPDeviceController.mm */; }; 991DC08B247704DC00C13860 /* CHIPLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 991DC08A247704DC00C13860 /* CHIPLogging.h */; }; @@ -63,7 +64,7 @@ B2E0D7B1245B0B5C003C5B48 /* CHIP.h in Headers */ = {isa = PBXBuildFile; fileRef = B2E0D7A8245B0B5C003C5B48 /* CHIP.h */; settings = {ATTRIBUTES = (Public, ); }; }; B2E0D7B2245B0B5C003C5B48 /* CHIPManualSetupPayloadParser.h in Headers */ = {isa = PBXBuildFile; fileRef = B2E0D7A9245B0B5C003C5B48 /* CHIPManualSetupPayloadParser.h */; settings = {ATTRIBUTES = (Public, ); }; }; B2E0D7B3245B0B5C003C5B48 /* CHIPError.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2E0D7AA245B0B5C003C5B48 /* CHIPError.mm */; }; - B2E0D7B4245B0B5C003C5B48 /* CHIPError.h in Headers */ = {isa = PBXBuildFile; fileRef = B2E0D7AB245B0B5C003C5B48 /* CHIPError.h */; settings = {ATTRIBUTES = (Public, ); }; }; + B2E0D7B4245B0B5C003C5B48 /* CHIPError_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = B2E0D7AB245B0B5C003C5B48 /* CHIPError_Internal.h */; }; B2E0D7B5245B0B5C003C5B48 /* CHIPQRCodeSetupPayloadParser.h in Headers */ = {isa = PBXBuildFile; fileRef = B2E0D7AC245B0B5C003C5B48 /* CHIPQRCodeSetupPayloadParser.h */; settings = {ATTRIBUTES = (Public, ); }; }; B2E0D7B6245B0B5C003C5B48 /* CHIPManualSetupPayloadParser.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2E0D7AD245B0B5C003C5B48 /* CHIPManualSetupPayloadParser.mm */; }; B2E0D7B7245B0B5C003C5B48 /* CHIPQRCodeSetupPayloadParser.mm in Sources */ = {isa = PBXBuildFile; fileRef = B2E0D7AE245B0B5C003C5B48 /* CHIPQRCodeSetupPayloadParser.mm */; }; @@ -126,6 +127,7 @@ 2CB71639252E8A7B0026E2BB /* CHIPDevicePairingDelegateBridge.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CHIPDevicePairingDelegateBridge.mm; sourceTree = ""; }; 2CB7163E252F731E0026E2BB /* CHIPDevicePairingDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHIPDevicePairingDelegate.h; sourceTree = ""; }; 2FD775542695557E00FF4B12 /* error-mapping.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = "error-mapping.cpp"; path = "../../../app/util/error-mapping.cpp"; sourceTree = ""; }; + 5129BCFC26A9EE3300122DDF /* CHIPError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CHIPError.h; path = CHIP/CHIPError.h; sourceTree = ""; }; 991DC0822475F45400C13860 /* CHIPDeviceController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CHIPDeviceController.h; sourceTree = ""; }; 991DC0872475F47D00C13860 /* CHIPDeviceController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = CHIPDeviceController.mm; sourceTree = ""; }; 991DC08A247704DC00C13860 /* CHIPLogging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CHIPLogging.h; sourceTree = ""; }; @@ -143,7 +145,7 @@ B2E0D7A8245B0B5C003C5B48 /* CHIP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHIP.h; sourceTree = ""; }; B2E0D7A9245B0B5C003C5B48 /* CHIPManualSetupPayloadParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHIPManualSetupPayloadParser.h; sourceTree = ""; }; B2E0D7AA245B0B5C003C5B48 /* CHIPError.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CHIPError.mm; sourceTree = ""; }; - B2E0D7AB245B0B5C003C5B48 /* CHIPError.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHIPError.h; sourceTree = ""; }; + B2E0D7AB245B0B5C003C5B48 /* CHIPError_Internal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHIPError_Internal.h; sourceTree = ""; }; B2E0D7AC245B0B5C003C5B48 /* CHIPQRCodeSetupPayloadParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHIPQRCodeSetupPayloadParser.h; sourceTree = ""; }; B2E0D7AD245B0B5C003C5B48 /* CHIPManualSetupPayloadParser.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CHIPManualSetupPayloadParser.mm; sourceTree = ""; }; B2E0D7AE245B0B5C003C5B48 /* CHIPQRCodeSetupPayloadParser.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CHIPQRCodeSetupPayloadParser.mm; sourceTree = ""; }; @@ -219,6 +221,7 @@ B20252832459E34F00F97062 = { isa = PBXGroup; children = ( + 5129BCFC26A9EE3300122DDF /* CHIPError.h */, BA107AEE2470CFBB004287EB /* chip_xcode_build_connector.sh */, B202528F2459E34F00F97062 /* CHIP */, B202529A2459E34F00F97062 /* CHIPTests */, @@ -257,7 +260,7 @@ 2CB71638252E8A7B0026E2BB /* CHIPDevicePairingDelegateBridge.h */, 2CB71639252E8A7B0026E2BB /* CHIPDevicePairingDelegateBridge.mm */, B2E0D7A8245B0B5C003C5B48 /* CHIP.h */, - B2E0D7AB245B0B5C003C5B48 /* CHIPError.h */, + B2E0D7AB245B0B5C003C5B48 /* CHIPError_Internal.h */, B2E0D7AA245B0B5C003C5B48 /* CHIPError.mm */, 991DC08A247704DC00C13860 /* CHIPLogging.h */, B289D41F2639C0D300D4E314 /* CHIPOnboardingPayloadParser.h */, @@ -315,6 +318,7 @@ B2E0D7B8245B0B5C003C5B48 /* CHIPSetupPayload.h in Headers */, 997DED182695344800975E97 /* CHIPThreadOperationalDataset.h in Headers */, 9956064426420367000C28DE /* CHIPSetupPayload_Internal.h in Headers */, + 5129BCFD26A9EE3300122DDF /* CHIPError.h in Headers */, 2C8C8FC1253E0C2100797F05 /* CHIPPersistentStorageDelegate.h in Headers */, B2E0D7B5245B0B5C003C5B48 /* CHIPQRCodeSetupPayloadParser.h in Headers */, 1EC4CE6425CC276600D7304F /* CHIPClustersObjc.h in Headers */, @@ -322,7 +326,7 @@ 2C8C8FC0253E0C2100797F05 /* CHIPPersistentStorageDelegateBridge.h in Headers */, 2C222ADF255C811800E446B9 /* CHIPDevice_Internal.h in Headers */, 991DC08B247704DC00C13860 /* CHIPLogging.h in Headers */, - B2E0D7B4245B0B5C003C5B48 /* CHIPError.h in Headers */, + B2E0D7B4245B0B5C003C5B48 /* CHIPError_Internal.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/src/darwin/Framework/CHIP/BUILD.gn b/src/darwin/Framework/CHIP/BUILD.gn index 56e89333449abc..381fd179878288 100644 --- a/src/darwin/Framework/CHIP/BUILD.gn +++ b/src/darwin/Framework/CHIP/BUILD.gn @@ -39,6 +39,7 @@ static_library("framework") { "CHIPDevice_Internal.h", "CHIPError.h", "CHIPError.mm", + "CHIPError_Internal.h", "CHIPLogging.h", "CHIPManualSetupPayloadParser.h", "CHIPManualSetupPayloadParser.mm", diff --git a/src/darwin/Framework/CHIP/CHIPDevice.mm b/src/darwin/Framework/CHIP/CHIPDevice.mm index f101ab0f172717..f248c60f5e043d 100644 --- a/src/darwin/Framework/CHIP/CHIPDevice.mm +++ b/src/darwin/Framework/CHIP/CHIPDevice.mm @@ -16,8 +16,8 @@ */ #import "CHIPDevice_Internal.h" +#import "CHIPError_Internal.h" #import "CHIPLogging.h" -#import #import #import diff --git a/src/darwin/Framework/CHIP/CHIPDeviceConnectionBridge.mm b/src/darwin/Framework/CHIP/CHIPDeviceConnectionBridge.mm index 0271293f9a93f0..ac1adc8fe97311 100644 --- a/src/darwin/Framework/CHIP/CHIPDeviceConnectionBridge.mm +++ b/src/darwin/Framework/CHIP/CHIPDeviceConnectionBridge.mm @@ -17,7 +17,7 @@ #import "CHIPDeviceConnectionBridge.h" #import "CHIPDevice_Internal.h" -#import "CHIPError.h" +#import "CHIPError_Internal.h" void CHIPDeviceConnectionBridge::OnConnected(void * context, chip::Controller::Device * device) { diff --git a/src/darwin/Framework/CHIP/CHIPDeviceController.mm b/src/darwin/Framework/CHIP/CHIPDeviceController.mm index 71c055195cf8a6..5e5ac5222f1371 100644 --- a/src/darwin/Framework/CHIP/CHIPDeviceController.mm +++ b/src/darwin/Framework/CHIP/CHIPDeviceController.mm @@ -18,7 +18,7 @@ #import "CHIPDevicePairingDelegateBridge.h" #import "CHIPDevice_Internal.h" -#import "CHIPError.h" +#import "CHIPError_Internal.h" #import "CHIPLogging.h" #import "CHIPOperationalCredentialsDelegate.h" #import "CHIPPersistentStorageDelegateBridge.h" diff --git a/src/darwin/Framework/CHIP/CHIPDevicePairingDelegateBridge.mm b/src/darwin/Framework/CHIP/CHIPDevicePairingDelegateBridge.mm index a0251ea14c30fb..e3d455a41d57c4 100644 --- a/src/darwin/Framework/CHIP/CHIPDevicePairingDelegateBridge.mm +++ b/src/darwin/Framework/CHIP/CHIPDevicePairingDelegateBridge.mm @@ -16,7 +16,7 @@ */ #import "CHIPDevicePairingDelegateBridge.h" -#import "CHIPError.h" +#import "CHIPError_Internal.h" CHIPDevicePairingDelegateBridge::CHIPDevicePairingDelegateBridge(void) : mDelegate(nil) diff --git a/src/darwin/Framework/CHIP/CHIPError.h b/src/darwin/Framework/CHIP/CHIPError.h index 8ae4f07ba57752..69c13374293219 100644 --- a/src/darwin/Framework/CHIP/CHIPError.h +++ b/src/darwin/Framework/CHIP/CHIPError.h @@ -20,25 +20,18 @@ NS_ASSUME_NONNULL_BEGIN FOUNDATION_EXPORT NSErrorDomain const CHIPErrorDomain; -typedef uint32_t CHIP_ERROR; - -typedef NS_ERROR_ENUM(CHIPErrorDomain, CHIPErrorCode) { - CHIPSuccess = 0, - CHIPErrorCodeUndefinedError = 1, - CHIPErrorCodeInvalidStringLength = 2, - CHIPErrorCodeInvalidIntegerValue = 3, - CHIPErrorCodeInvalidArgument = 4, +typedef NS_ERROR_ENUM(CHIPErrorDomain, CHIPErrorCode){ + CHIPSuccess = 0, + CHIPErrorCodeUndefinedError = 1, + CHIPErrorCodeInvalidStringLength = 2, + CHIPErrorCodeInvalidIntegerValue = 3, + CHIPErrorCodeInvalidArgument = 4, CHIPErrorCodeInvalidMessageLength = 5, - CHIPErrorCodeInvalidState = 6, - CHIPErrorCodeWrongAddressType = 7, + CHIPErrorCodeInvalidState = 6, + CHIPErrorCodeWrongAddressType = 7, CHIPErrorCodeIntegrityCheckFailed = 8, - CHIPErrorCodeDuplicateExists = 9, + CHIPErrorCodeDuplicateExists = 9, CHIPErrorCodeUnsupportedAttribute = 10, }; -@interface CHIPError : NSObject -+ (nullable NSError *)errorForCHIPErrorCode:(CHIP_ERROR)errorCode; -+ (CHIP_ERROR)errorToCHIPErrorCode:(NSError *)errorCode; -@end - NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/CHIPError.mm b/src/darwin/Framework/CHIP/CHIPError.mm index 98fb6c3eee9350..60ea4cbc2852e2 100644 --- a/src/darwin/Framework/CHIP/CHIPError.mm +++ b/src/darwin/Framework/CHIP/CHIPError.mm @@ -16,9 +16,9 @@ */ #import "CHIPError.h" +#import "CHIPError_Internal.h" #import -#import #import NSString * const CHIPErrorDomain = @"CHIPErrorDomain"; diff --git a/src/darwin/Framework/CHIP/CHIPError_Internal.h b/src/darwin/Framework/CHIP/CHIPError_Internal.h new file mode 100644 index 00000000000000..f6d312d33e367e --- /dev/null +++ b/src/darwin/Framework/CHIP/CHIPError_Internal.h @@ -0,0 +1,29 @@ +/** + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#import + +#include + +NS_ASSUME_NONNULL_BEGIN + +@interface CHIPError : NSObject ++ (nullable NSError *)errorForCHIPErrorCode:(CHIP_ERROR)errorCode; ++ (CHIP_ERROR)errorToCHIPErrorCode:(NSError *)errorCode; +@end + +NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/CHIPManualSetupPayloadParser.mm b/src/darwin/Framework/CHIP/CHIPManualSetupPayloadParser.mm index d6e2912159d226..48275205dc71f7 100644 --- a/src/darwin/Framework/CHIP/CHIPManualSetupPayloadParser.mm +++ b/src/darwin/Framework/CHIP/CHIPManualSetupPayloadParser.mm @@ -16,7 +16,7 @@ */ #import "CHIPManualSetupPayloadParser.h" -#import "CHIPError.h" +#import "CHIPError_Internal.h" #import "CHIPLogging.h" #import "CHIPSetupPayload_Internal.h" diff --git a/src/darwin/Framework/CHIP/CHIPOperationalCredentialsDelegate.h b/src/darwin/Framework/CHIP/CHIPOperationalCredentialsDelegate.h index e51ed0b3779cdf..6358895dd59f78 100644 --- a/src/darwin/Framework/CHIP/CHIPOperationalCredentialsDelegate.h +++ b/src/darwin/Framework/CHIP/CHIPOperationalCredentialsDelegate.h @@ -18,7 +18,7 @@ #import #import -#import "CHIPError.h" +#import "CHIPError_Internal.h" #import "CHIPPersistentStorageDelegateBridge.h" #include diff --git a/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.h b/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.h index 473c55486151a7..c000354345e918 100644 --- a/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.h +++ b/src/darwin/Framework/CHIP/CHIPPersistentStorageDelegateBridge.h @@ -17,7 +17,7 @@ #import "CHIPPersistentStorageDelegate.h" -#import "CHIPError.h" +#import "CHIPError_Internal.h" #include NS_ASSUME_NONNULL_BEGIN diff --git a/src/darwin/Framework/CHIP/CHIPQRCodeSetupPayloadParser.mm b/src/darwin/Framework/CHIP/CHIPQRCodeSetupPayloadParser.mm index ac7bbebe3008be..ce59d29f3133c7 100644 --- a/src/darwin/Framework/CHIP/CHIPQRCodeSetupPayloadParser.mm +++ b/src/darwin/Framework/CHIP/CHIPQRCodeSetupPayloadParser.mm @@ -16,7 +16,7 @@ */ #import "CHIPQRCodeSetupPayloadParser.h" -#import "CHIPError.h" +#import "CHIPError_Internal.h" #import "CHIPLogging.h" #import "CHIPSetupPayload_Internal.h" diff --git a/src/darwin/Framework/CHIP/CHIPSetupPayload.mm b/src/darwin/Framework/CHIP/CHIPSetupPayload.mm index 61a2c489d16cb8..12ed1485ff4cbd 100644 --- a/src/darwin/Framework/CHIP/CHIPSetupPayload.mm +++ b/src/darwin/Framework/CHIP/CHIPSetupPayload.mm @@ -16,6 +16,7 @@ */ #import "CHIPError.h" +#import "CHIPError_Internal.h" #import "CHIPSetupPayload_Internal.h" #import diff --git a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm index a055c6cd2ec72d..d6f2afd9aa1569 100644 --- a/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm +++ b/src/darwin/Framework/CHIP/gen/CHIPClustersObjc.mm @@ -21,7 +21,7 @@ #import "CHIPDevice.h" #import "CHIPDevice_Internal.h" -#import "CHIPError.h" +#import "CHIPError_Internal.h" #import "app/util/af.h" #import "gen/CHIPClientCallbacks.h" #import "gen/CHIPClusters.h" diff --git a/src/darwin/Framework/CHIP/templates/CHIPClustersObjc-src.zapt b/src/darwin/Framework/CHIP/templates/CHIPClustersObjc-src.zapt index aa876c46ef9b98..acae31ac74940b 100644 --- a/src/darwin/Framework/CHIP/templates/CHIPClustersObjc-src.zapt +++ b/src/darwin/Framework/CHIP/templates/CHIPClustersObjc-src.zapt @@ -5,7 +5,7 @@ #import "CHIPDevice.h" #import "CHIPDevice_Internal.h" -#import "CHIPError.h" +#import "CHIPError_Internal.h" #import "gen/CHIPClusters.h" #import "gen/CHIPClustersObjc.h" #import "gen/CHIPClientCallbacks.h" diff --git a/src/darwin/Framework/CHIP/templates/clusters-tests.zapt b/src/darwin/Framework/CHIP/templates/clusters-tests.zapt index ae22ee7ecd01f2..870fbd5acbbc73 100644 --- a/src/darwin/Framework/CHIP/templates/clusters-tests.zapt +++ b/src/darwin/Framework/CHIP/templates/clusters-tests.zapt @@ -6,9 +6,6 @@ // module headers #import -// additional includes -#import "CHIPError.h" - // system dependencies #import diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index 5816f053ed0f0d..12c6d9f674fdf0 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -23,9 +23,6 @@ // module headers #import -// additional includes -#import "CHIPError.h" - // system dependencies #import