Index: ObjFW.xcodeproj/project.pbxproj ================================================================== --- ObjFW.xcodeproj/project.pbxproj +++ ObjFW.xcodeproj/project.pbxproj @@ -88,11 +88,10 @@ 4B29BC53133AC7DD0004B236 /* OFDeleteFileFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B29BC4B133AC7DC0004B236 /* OFDeleteFileFailedException.m */; }; 4B29BC57133AC8420004B236 /* OFRenameFileFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B29BC55133AC81B0004B236 /* OFRenameFileFailedException.m */; }; 4B29BC58133AC8540004B236 /* OFConditionBroadcastFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8B1701133A3B8E007CD8B3 /* OFConditionBroadcastFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B29BC59133AC8540004B236 /* OFConditionSignalFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8B1703133A3B8E007CD8B3 /* OFConditionSignalFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B29BC5A133AC8540004B236 /* OFConditionWaitFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8B1705133A3B8E007CD8B3 /* OFConditionWaitFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 4B29BC5B133AC8540004B236 /* OFConditionWaitingException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8B1707133A3B8E007CD8B3 /* OFConditionWaitingException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B29BC5C133AC8540004B236 /* OFRenameFileFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B29BC54133AC81B0004B236 /* OFRenameFileFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B29BC61133AC9CB0004B236 /* OFLinkFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B29BC5D133AC9C40004B236 /* OFLinkFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B29BC62133AC9CB0004B236 /* OFLinkFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B29BC5E133AC9C40004B236 /* OFLinkFailedException.m */; }; 4B29BC63133AC9CB0004B236 /* OFSymlinkFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B29BC5F133AC9C60004B236 /* OFSymlinkFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B29BC64133AC9CB0004B236 /* OFSymlinkFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B29BC60133AC9C90004B236 /* OFSymlinkFailedException.m */; }; @@ -202,16 +201,17 @@ 4B55A115133AC24600B58A93 /* OFReadOrWriteFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B55A10F133AC24500B58A93 /* OFReadOrWriteFailedException.m */; }; 4B55A116133AC24600B58A93 /* OFWriteFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B55A110133AC24500B58A93 /* OFWriteFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B55A117133AC24600B58A93 /* OFWriteFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B55A111133AC24600B58A93 /* OFWriteFailedException.m */; }; 4B7FF3B0133CE6DE00000324 /* OFMutexStillLockedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B7FF3AE133CE6DE00000324 /* OFMutexStillLockedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B7FF3B1133CE6DE00000324 /* OFMutexStillLockedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B7FF3AF133CE6DE00000324 /* OFMutexStillLockedException.m */; }; + 4B7FF3B4133CED6200000324 /* OFConditionStillWaitingException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B7FF3B2133CED6100000324 /* OFConditionStillWaitingException.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 4B7FF3B5133CED6200000324 /* OFConditionStillWaitingException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B7FF3B3133CED6100000324 /* OFConditionStillWaitingException.m */; }; 4B8B16FE133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8B16FC133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B8B16FF133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B16FD133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.m */; }; 4B8B170D133A3C11007CD8B3 /* OFConditionBroadcastFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B1702133A3B8E007CD8B3 /* OFConditionBroadcastFailedException.m */; }; 4B8B170E133A3C11007CD8B3 /* OFConditionSignalFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B1704133A3B8E007CD8B3 /* OFConditionSignalFailedException.m */; }; 4B8B170F133A3C11007CD8B3 /* OFConditionWaitFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B1706133A3B8E007CD8B3 /* OFConditionWaitFailedException.m */; }; - 4B8B1710133A3C11007CD8B3 /* OFConditionWaitingException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B1708133A3B8E007CD8B3 /* OFConditionWaitingException.m */; }; 4B8B1719133A3D04007CD8B3 /* OFMutexLockFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8B1713133A3D04007CD8B3 /* OFMutexLockFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B8B171A133A3D04007CD8B3 /* OFMutexLockFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B1714133A3D04007CD8B3 /* OFMutexLockFailedException.m */; }; 4B8B171B133A3D04007CD8B3 /* OFMutexUnlockFailedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8B1715133A3D04007CD8B3 /* OFMutexUnlockFailedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 4B8B171C133A3D04007CD8B3 /* OFMutexUnlockFailedException.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B8B1716133A3D04007CD8B3 /* OFMutexUnlockFailedException.m */; }; 4B90B78D133AD46700BD33CB /* OFAlreadyConnectedException.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B90B787133AD46700BD33CB /* OFAlreadyConnectedException.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -479,20 +479,20 @@ 4B6EF6811235358D0076B512 /* TestsAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TestsAppDelegate.m; path = tests/TestsAppDelegate.m; sourceTree = SOURCE_ROOT; }; 4B6EF684123535B60076B512 /* TestPlugin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TestPlugin.m; path = tests/plugin/TestPlugin.m; sourceTree = SOURCE_ROOT; }; 4B6EF685123535C80076B512 /* test.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = test.m; path = tests/objc_sync/test.m; sourceTree = SOURCE_ROOT; }; 4B7FF3AE133CE6DE00000324 /* OFMutexStillLockedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFMutexStillLockedException.h; path = src/exceptions/OFMutexStillLockedException.h; sourceTree = ""; }; 4B7FF3AF133CE6DE00000324 /* OFMutexStillLockedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFMutexStillLockedException.m; path = src/exceptions/OFMutexStillLockedException.m; sourceTree = ""; }; + 4B7FF3B2133CED6100000324 /* OFConditionStillWaitingException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFConditionStillWaitingException.h; path = src/exceptions/OFConditionStillWaitingException.h; sourceTree = ""; }; + 4B7FF3B3133CED6100000324 /* OFConditionStillWaitingException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFConditionStillWaitingException.m; path = src/exceptions/OFConditionStillWaitingException.m; sourceTree = ""; }; 4B8B16FC133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFHashAlreadyCalculatedException.h; path = src/exceptions/OFHashAlreadyCalculatedException.h; sourceTree = ""; }; 4B8B16FD133A3B84007CD8B3 /* OFHashAlreadyCalculatedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFHashAlreadyCalculatedException.m; path = src/exceptions/OFHashAlreadyCalculatedException.m; sourceTree = ""; }; 4B8B1701133A3B8E007CD8B3 /* OFConditionBroadcastFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFConditionBroadcastFailedException.h; path = src/exceptions/OFConditionBroadcastFailedException.h; sourceTree = ""; }; 4B8B1702133A3B8E007CD8B3 /* OFConditionBroadcastFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFConditionBroadcastFailedException.m; path = src/exceptions/OFConditionBroadcastFailedException.m; sourceTree = ""; }; 4B8B1703133A3B8E007CD8B3 /* OFConditionSignalFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFConditionSignalFailedException.h; path = src/exceptions/OFConditionSignalFailedException.h; sourceTree = ""; }; 4B8B1704133A3B8E007CD8B3 /* OFConditionSignalFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFConditionSignalFailedException.m; path = src/exceptions/OFConditionSignalFailedException.m; sourceTree = ""; }; 4B8B1705133A3B8E007CD8B3 /* OFConditionWaitFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFConditionWaitFailedException.h; path = src/exceptions/OFConditionWaitFailedException.h; sourceTree = ""; }; 4B8B1706133A3B8E007CD8B3 /* OFConditionWaitFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFConditionWaitFailedException.m; path = src/exceptions/OFConditionWaitFailedException.m; sourceTree = ""; }; - 4B8B1707133A3B8E007CD8B3 /* OFConditionWaitingException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFConditionWaitingException.h; path = src/exceptions/OFConditionWaitingException.h; sourceTree = ""; }; - 4B8B1708133A3B8E007CD8B3 /* OFConditionWaitingException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFConditionWaitingException.m; path = src/exceptions/OFConditionWaitingException.m; sourceTree = ""; }; 4B8B1713133A3D04007CD8B3 /* OFMutexLockFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFMutexLockFailedException.h; path = src/exceptions/OFMutexLockFailedException.h; sourceTree = ""; }; 4B8B1714133A3D04007CD8B3 /* OFMutexLockFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFMutexLockFailedException.m; path = src/exceptions/OFMutexLockFailedException.m; sourceTree = ""; }; 4B8B1715133A3D04007CD8B3 /* OFMutexUnlockFailedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFMutexUnlockFailedException.h; path = src/exceptions/OFMutexUnlockFailedException.h; sourceTree = ""; }; 4B8B1716133A3D04007CD8B3 /* OFMutexUnlockFailedException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OFMutexUnlockFailedException.m; path = src/exceptions/OFMutexUnlockFailedException.m; sourceTree = ""; }; 4B90B787133AD46700BD33CB /* OFAlreadyConnectedException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OFAlreadyConnectedException.h; path = src/exceptions/OFAlreadyConnectedException.h; sourceTree = ""; }; @@ -621,14 +621,14 @@ 4B29BC36133AC4E80004B236 /* OFChangeFileModeFailedException.m */, 4B8B1701133A3B8E007CD8B3 /* OFConditionBroadcastFailedException.h */, 4B8B1702133A3B8E007CD8B3 /* OFConditionBroadcastFailedException.m */, 4B8B1703133A3B8E007CD8B3 /* OFConditionSignalFailedException.h */, 4B8B1704133A3B8E007CD8B3 /* OFConditionSignalFailedException.m */, + 4B7FF3B2133CED6100000324 /* OFConditionStillWaitingException.h */, + 4B7FF3B3133CED6100000324 /* OFConditionStillWaitingException.m */, 4B8B1705133A3B8E007CD8B3 /* OFConditionWaitFailedException.h */, 4B8B1706133A3B8E007CD8B3 /* OFConditionWaitFailedException.m */, - 4B8B1707133A3B8E007CD8B3 /* OFConditionWaitingException.h */, - 4B8B1708133A3B8E007CD8B3 /* OFConditionWaitingException.m */, 4B90B79A133AD87D00BD33CB /* OFConnectionFailedException.h */, 4B90B79B133AD87D00BD33CB /* OFConnectionFailedException.m */, 4B29BC46133AC7DB0004B236 /* OFCopyFileFailedException.h */, 4B29BC47133AC7DB0004B236 /* OFCopyFileFailedException.m */, 4B29BC37133AC4E80004B236 /* OFCreateDirectoryFailedException.h */, @@ -982,12 +982,12 @@ 4B29BC3B133AC4E80004B236 /* OFChangeDirectoryFailedException.h in Headers */, 4B29BC3D133AC4E80004B236 /* OFChangeFileModeFailedException.h in Headers */, 4B29BC4C133AC7DD0004B236 /* OFChangeFileOwnerFailedException.h in Headers */, 4B29BC58133AC8540004B236 /* OFConditionBroadcastFailedException.h in Headers */, 4B29BC59133AC8540004B236 /* OFConditionSignalFailedException.h in Headers */, + 4B7FF3B4133CED6200000324 /* OFConditionStillWaitingException.h in Headers */, 4B29BC5A133AC8540004B236 /* OFConditionWaitFailedException.h in Headers */, - 4B29BC5B133AC8540004B236 /* OFConditionWaitingException.h in Headers */, 4B90B7A4133AD87D00BD33CB /* OFConnectionFailedException.h in Headers */, 4B29BC4E133AC7DD0004B236 /* OFCopyFileFailedException.h in Headers */, 4B29BC3F133AC4E80004B236 /* OFCreateDirectoryFailedException.h in Headers */, 4B29BC50133AC7DD0004B236 /* OFDeleteDirectoryFailedException.h in Headers */, 4B29BC52133AC7DD0004B236 /* OFDeleteFileFailedException.h in Headers */, @@ -1227,12 +1227,12 @@ 4B29BC3C133AC4E80004B236 /* OFChangeDirectoryFailedException.m in Sources */, 4B29BC3E133AC4E80004B236 /* OFChangeFileModeFailedException.m in Sources */, 4B29BC4D133AC7DD0004B236 /* OFChangeFileOwnerFailedException.m in Sources */, 4B8B170D133A3C11007CD8B3 /* OFConditionBroadcastFailedException.m in Sources */, 4B8B170E133A3C11007CD8B3 /* OFConditionSignalFailedException.m in Sources */, + 4B7FF3B5133CED6200000324 /* OFConditionStillWaitingException.m in Sources */, 4B8B170F133A3C11007CD8B3 /* OFConditionWaitFailedException.m in Sources */, - 4B8B1710133A3C11007CD8B3 /* OFConditionWaitingException.m in Sources */, 4B90B7A5133AD87D00BD33CB /* OFConnectionFailedException.m in Sources */, 4B29BC4F133AC7DD0004B236 /* OFCopyFileFailedException.m in Sources */, 4B29BC40133AC4E80004B236 /* OFCreateDirectoryFailedException.m in Sources */, 4B29BC51133AC7DD0004B236 /* OFDeleteDirectoryFailedException.m in Sources */, 4B29BC53133AC7DD0004B236 /* OFDeleteFileFailedException.m in Sources */, Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -28,12 +28,12 @@ #import "OFDate.h" #import "OFAutoreleasePool.h" #import "OFConditionBroadcastFailedException.h" #import "OFConditionSignalFailedException.h" +#import "OFConditionStillWaitingException.h" #import "OFConditionWaitFailedException.h" -#import "OFConditionWaitingException.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFMutexLockFailedException.h" #import "OFMutexStillLockedException.h" #import "OFMutexUnlockFailedException.h" @@ -434,29 +434,34 @@ } - (void)wait { if (!of_condition_wait(&condition, &mutex)) - @throw [OFConditionWaitFailedException newWithClass: isa]; + @throw [OFConditionWaitFailedException newWithClass: isa + condition: self]; } - (void)signal { if (!of_condition_signal(&condition)) - @throw [OFConditionSignalFailedException newWithClass: isa]; + @throw [OFConditionSignalFailedException newWithClass: isa + condition: self]; } - (void)broadcast { if (!of_condition_broadcast(&condition)) - @throw [OFConditionBroadcastFailedException newWithClass: isa]; + @throw [OFConditionBroadcastFailedException newWithClass: isa + condition: self]; } - (void)dealloc { if (cond_initialized) if (!of_condition_free(&condition)) - @throw [OFConditionWaitingException newWithClass: isa]; + @throw [OFConditionStillWaitingException + newWithClass: isa + condition: self]; [super dealloc]; } @end Index: src/ObjFW.h ================================================================== --- src/ObjFW.h +++ src/ObjFW.h @@ -62,12 +62,12 @@ #import "OFChangeDirectoryFailedException.h" #import "OFChangeFileModeFailedException.h" #import "OFChangeFileOwnerFailedException.h" #import "OFConditionBroadcastFailedException.h" #import "OFConditionSignalFailedException.h" +#import "OFConditionStillWaitingException.h" #import "OFConditionWaitFailedException.h" -#import "OFConditionWaitingException.h" #import "OFConnectionFailedException.h" #import "OFCopyFileFailedException.h" #import "OFCreateDirectoryFailedException.h" #import "OFDeleteDirectoryFailedException.h" #import "OFDeleteFileFailedException.h" Index: src/exceptions/Makefile ================================================================== --- src/exceptions/Makefile +++ src/exceptions/Makefile @@ -11,12 +11,12 @@ OFChangeDirectoryFailedException.m \ OFChangeFileModeFailedException.m \ OFChangeFileOwnerFailedException.m \ OFConditionBroadcastFailedException.m \ OFConditionSignalFailedException.m \ + OFConditionStillWaitingException.m \ OFConditionWaitFailedException.m \ - OFConditionWaitingException.m \ OFConnectionFailedException.m \ OFCopyFileFailedException.m \ OFCreateDirectoryFailedException.m \ OFDeleteDirectoryFailedException.m \ OFDeleteFileFailedException.m \ Index: src/exceptions/OFConditionBroadcastFailedException.h ================================================================== --- src/exceptions/OFConditionBroadcastFailedException.h +++ src/exceptions/OFConditionBroadcastFailedException.h @@ -14,10 +14,42 @@ * file. */ #import "OFException.h" +@class OFCondition; + /** * \brief An exception indicating broadcasting a condition failed. */ @interface OFConditionBroadcastFailedException: OFException +{ + OFCondition *condition; +} + +#ifdef OF_HAVE_PROPERTIES +@property (readonly, nonatomic) OFCondition *condition; +#endif + +/** + * \param class_ The class of the object which caused the exception + * \param condition The condition which could not be broadcasted + * \return A new condition broadcast failed exception + */ ++ newWithClass: (Class)class_ + condition: (OFCondition*)condition; + +/** + * Initializes an already allocated condition broadcast failed exception. + * + * \param class_ The class of the object which caused the exception + * \param condition The condition which could not be broadcasted + * \return An initialized condition broadcast failed exception + */ +- initWithClass: (Class)class_ + condition: (OFCondition*)condition; + +/** + * \return The condition which could not be broadcasted + */ +- (OFCondition*)condition; @end Index: src/exceptions/OFConditionBroadcastFailedException.m ================================================================== --- src/exceptions/OFConditionBroadcastFailedException.m +++ src/exceptions/OFConditionBroadcastFailedException.m @@ -16,12 +16,51 @@ #include "config.h" #import "OFConditionBroadcastFailedException.h" #import "OFString.h" + +#import "OFNotImplementedException.h" @implementation OFConditionBroadcastFailedException ++ newWithClass: (Class)class_ + condition: (OFCondition*)condition +{ + return [[self alloc] initWithClass: class_ + condition: condition]; +} + +- initWithClass: (Class)class_ +{ + Class c = isa; + [self release]; + @throw [OFNotImplementedException newWithClass: c + selector: _cmd]; +} + +- initWithClass: (Class)class_ + condition: (OFCondition*)condition_ +{ + self = [super initWithClass: class_]; + + @try { + condition = [condition_ retain]; + } @catch (id e) { + [self release]; + @throw e; + } + + return self; +} + +- (void)dealloc +{ + [condition release]; + + [super dealloc]; +} + - (OFString*)description { if (description != nil) return description; @@ -28,6 +67,11 @@ description = [[OFString alloc] initWithFormat: @"Broadcasting a condition of type %@ failed!", inClass]; return description; } + +- (OFCondition*)condition +{ + return condition; +} @end Index: src/exceptions/OFConditionSignalFailedException.h ================================================================== --- src/exceptions/OFConditionSignalFailedException.h +++ src/exceptions/OFConditionSignalFailedException.h @@ -14,10 +14,42 @@ * file. */ #import "OFException.h" +@class OFCondition; + /** - * \brief An exception indicating signalling a condition failed. + * \brief An exception indicating signaling a condition failed. */ @interface OFConditionSignalFailedException: OFException +{ + OFCondition *condition; +} + +#ifdef OF_HAVE_PROPERTIES +@property (readonly, nonatomic) OFCondition *condition; +#endif + +/** + * \param class_ The class of the object which caused the exception + * \param condition The condition which could not be signaled + * \return A new condition signal failed exception + */ ++ newWithClass: (Class)class_ + condition: (OFCondition*)condition; + +/** + * Initializes an already allocated condition signal failed exception. + * + * \param class_ The class of the object which caused the exception + * \param condition The condition which could not be signaled + * \return An initialized condition signal failed exception + */ +- initWithClass: (Class)class_ + condition: (OFCondition*)condition; + +/** + * \return The condition which could not be signaled + */ +- (OFCondition*)condition; @end Index: src/exceptions/OFConditionSignalFailedException.m ================================================================== --- src/exceptions/OFConditionSignalFailedException.m +++ src/exceptions/OFConditionSignalFailedException.m @@ -16,12 +16,51 @@ #include "config.h" #import "OFConditionSignalFailedException.h" #import "OFString.h" + +#import "OFNotImplementedException.h" @implementation OFConditionSignalFailedException ++ newWithClass: (Class)class_ + condition: (OFCondition*)condition +{ + return [[self alloc] initWithClass: class_ + condition: condition]; +} + +- initWithClass: (Class)class_ +{ + Class c = isa; + [self release]; + @throw [OFNotImplementedException newWithClass: c + selector: _cmd]; +} + +- initWithClass: (Class)class_ + condition: (OFCondition*)condition_ +{ + self = [super initWithClass: class_]; + + @try { + condition = [condition_ retain]; + } @catch (id e) { + [self release]; + @throw e; + } + + return self; +} + +- (void)dealloc +{ + [condition release]; + + [super dealloc]; +} + - (OFString*)description { if (description != nil) return description; @@ -28,6 +67,11 @@ description = [[OFString alloc] initWithFormat: @"Signaling a condition of type %@ failed!", inClass]; return description; } + +- (OFCondition*)condition +{ + return condition; +} @end ADDED src/exceptions/OFConditionStillWaitingException.h Index: src/exceptions/OFConditionStillWaitingException.h ================================================================== --- src/exceptions/OFConditionStillWaitingException.h +++ src/exceptions/OFConditionStillWaitingException.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#import "OFException.h" + +@class OFCondition; + +/** + * \brief An exception indicating that a thread is still waiting for a + * condition. + */ +@interface OFConditionStillWaitingException: OFException +{ + OFCondition *condition; +} + +#ifdef OF_HAVE_PROPERTIES +@property (readonly, nonatomic) OFCondition *condition; +#endif + +/** + * \param class_ The class of the object which caused the exception + * \param condition The condition for which is still being waited + * \return A new condition still waiting exception + */ ++ newWithClass: (Class)class_ + condition: (OFCondition*)condition; + +/** + * Initializes an already allocated condition still waiting exception. + * + * \param class_ The class of the object which caused the exception + * \param condition The condition for which is still being waited + * \return An initialized condition still waiting exception + */ +- initWithClass: (Class)class_ + condition: (OFCondition*)condition; + +/** + * \return The condition for which is still being waited + */ +- (OFCondition*)condition; +@end ADDED src/exceptions/OFConditionStillWaitingException.m Index: src/exceptions/OFConditionStillWaitingException.m ================================================================== --- src/exceptions/OFConditionStillWaitingException.m +++ src/exceptions/OFConditionStillWaitingException.m @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2008, 2009, 2010, 2011 + * Jonathan Schleifer + * + * All rights reserved. + * + * This file is part of ObjFW. It may be distributed under the terms of the + * Q Public License 1.0, which can be found in the file LICENSE.QPL included in + * the packaging of this file. + * + * Alternatively, it may be distributed under the terms of the GNU General + * Public License, either version 2 or 3, which can be found in the file + * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this + * file. + */ + +#include "config.h" + +#import "OFConditionStillWaitingException.h" +#import "OFString.h" + +#import "OFNotImplementedException.h" + +@implementation OFConditionStillWaitingException ++ newWithClass: (Class)class_ + condition: (OFCondition*)condition +{ + return [[self alloc] initWithClass: class_ + condition: condition]; +} + +- initWithClass: (Class)class_ +{ + Class c = isa; + [self release]; + @throw [OFNotImplementedException newWithClass: c + selector: _cmd]; +} + +- initWithClass: (Class)class_ + condition: (OFCondition*)condition_ +{ + self = [super initWithClass: class_]; + + @try { + condition = [condition_ retain]; + } @catch (id e) { + [self release]; + @throw e; + } + + return self; +} + +- (void)dealloc +{ + [condition release]; + + [super dealloc]; +} + +- (OFString*)description +{ + if (description != nil) + return description; + + description = [[OFString alloc] initWithFormat: + @"Deallocation of a condition of type %@ was tried, even though a " + @"thread was still waiting for it!", inClass]; + + return description; +} + +- (OFCondition*)condition +{ + return condition; +} +@end Index: src/exceptions/OFConditionWaitFailedException.h ================================================================== --- src/exceptions/OFConditionWaitFailedException.h +++ src/exceptions/OFConditionWaitFailedException.h @@ -14,10 +14,42 @@ * file. */ #import "OFException.h" +@class OFCondition; + /** * \brief An exception indicating waiting for a condition failed. */ @interface OFConditionWaitFailedException: OFException +{ + OFCondition *condition; +} + +#ifdef OF_HAVE_PROPERTIES +@property (readonly, nonatomic) OFCondition *condition; +#endif + +/** + * \param class_ The class of the object which caused the exception + * \param condition The condition for which could not be waited + * \return A new condition wait failed exception + */ ++ newWithClass: (Class)class_ + condition: (OFCondition*)condition; + +/** + * Initializes an already allocated condition wait failed exception. + * + * \param class_ The class of the object which caused the exception + * \param condition The condition for which could not be waited + * \return An initialized condition wait failed exception + */ +- initWithClass: (Class)class_ + condition: (OFCondition*)condition; + +/** + * \return The condition for which could not be waited + */ +- (OFCondition*)condition; @end Index: src/exceptions/OFConditionWaitFailedException.m ================================================================== --- src/exceptions/OFConditionWaitFailedException.m +++ src/exceptions/OFConditionWaitFailedException.m @@ -16,12 +16,51 @@ #include "config.h" #import "OFConditionWaitFailedException.h" #import "OFString.h" + +#import "OFNotImplementedException.h" @implementation OFConditionWaitFailedException ++ newWithClass: (Class)class_ + condition: (OFCondition*)condition +{ + return [[self alloc] initWithClass: class_ + condition: condition]; +} + +- initWithClass: (Class)class_ +{ + Class c = isa; + [self release]; + @throw [OFNotImplementedException newWithClass: c + selector: _cmd]; +} + +- initWithClass: (Class)class_ + condition: (OFCondition*)condition_ +{ + self = [super initWithClass: class_]; + + @try { + condition = [condition_ retain]; + } @catch (id e) { + [self release]; + @throw e; + } + + return self; +} + +- (void)dealloc +{ + [condition release]; + + [super dealloc]; +} + - (OFString*)description { if (description != nil) return description; @@ -28,6 +67,11 @@ description = [[OFString alloc] initWithFormat: @"Waiting for a condition of type %@ failed!", inClass]; return description; } + +- (OFCondition*)condition +{ + return condition; +} @end DELETED src/exceptions/OFConditionWaitingException.h Index: src/exceptions/OFConditionWaitingException.h ================================================================== --- src/exceptions/OFConditionWaitingException.h +++ src/exceptions/OFConditionWaitingException.h @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#import "OFException.h" - -/** - * \brief An exception indicating that a thread is still waiting for a - * condition. - */ -@interface OFConditionWaitingException: OFException -@end DELETED src/exceptions/OFConditionWaitingException.m Index: src/exceptions/OFConditionWaitingException.m ================================================================== --- src/exceptions/OFConditionWaitingException.m +++ src/exceptions/OFConditionWaitingException.m @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2008, 2009, 2010, 2011 - * Jonathan Schleifer - * - * All rights reserved. - * - * This file is part of ObjFW. It may be distributed under the terms of the - * Q Public License 1.0, which can be found in the file LICENSE.QPL included in - * the packaging of this file. - * - * Alternatively, it may be distributed under the terms of the GNU General - * Public License, either version 2 or 3, which can be found in the file - * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this - * file. - */ - -#include "config.h" - -#import "OFConditionWaitingException.h" -#import "OFString.h" - -@implementation OFConditionWaitingException -- (OFString*)description -{ - if (description != nil) - return description; - - description = [[OFString alloc] initWithFormat: - @"Deallocation of a condition of type %@ was tried, even though a " - @"thread was still waiting for it!", inClass]; - - return description; -} -@end