From 3956454ed1dadaece26a698799a48850fa6c436c Mon Sep 17 00:00:00 2001 From: David Symonds Date: Mon, 17 Sep 2007 16:56:49 +1000 Subject: [PATCH] Write some initial generic poset code. --- Framework/SUPoset.h | 22 +++++++++++++++++ Framework/SUPoset.m | 50 +++++++++++++++++++++++++++++++++++++++ Sparkle.xcodeproj/project.pbxproj | 8 ++++++- 3 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 Framework/SUPoset.h create mode 100644 Framework/SUPoset.m diff --git a/Framework/SUPoset.h b/Framework/SUPoset.h new file mode 100644 index 0000000..9658f7f --- /dev/null +++ b/Framework/SUPoset.h @@ -0,0 +1,22 @@ +// +// SUPoset.h +// Sparkle +// +// Created by David Symonds on 17/09/07. +// Copyright 2007 __MyCompanyName__. All rights reserved. +// + +#import + + +@interface SUPoset : NSObject { + NSMutableArray *declaredOrderings; +} + +- (SUPoset *)init; + +- (void)clearOrderings; + +- (void)setOrdering:(id)object1 toObject:(id)object2 as:(NSComparisonResult)order; + +@end diff --git a/Framework/SUPoset.m b/Framework/SUPoset.m new file mode 100644 index 0000000..8d529ce --- /dev/null +++ b/Framework/SUPoset.m @@ -0,0 +1,50 @@ +// +// SUPoset.m +// Sparkle +// +// Created by David Symonds on 17/09/07. +// Copyright 2007 __MyCompanyName__. All rights reserved. +// + +#import "SUPoset.h" + + +@implementation SUPoset + +- (SUPoset *)init +{ + if (!(self = [super init])) + return nil; + + declaredOrderings = [[NSMutableArray alloc] init]; + + return self; +} + +- (void)dealloc +{ + [declaredOrderings release]; + + [super dealloc]; +} + +#pragma mark - + +- (void)clearOrderings +{ + [declaredOrderings removeAllObjects]; +} + +#pragma mark - + +- (void)setOrdering:(id)object1 toObject:(id)object2 as:(NSComparisonResult)order +{ + if (order == NSOrderedSame) // TODO: is there a sensible use case for this being accepted? + [NSException raise:@"Logic Error" format:@"Poset elements can't be equal."]; + else if (order == NSOrderedAscending) + [declaredOrderings addObject:[NSArray arrayWithObjects:object1, object2, nil]]; + else + [declaredOrderings addObject:[NSArray arrayWithObjects:object2, object1, nil]]; +} + +@end diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 65b625a..9a77fa4 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -156,8 +156,10 @@ 61D9B16B0C96529F00D774C4 /* BLAuthentication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BLAuthentication.h; sourceTree = ""; }; 61D9B16C0C96529F00D774C4 /* BLAuthentication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BLAuthentication.m; sourceTree = ""; }; 61D9B1C30C96545900D774C4 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = ""; }; - 8D202CF70486D31800D8A456 /* PrefPane-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "PrefPane-Info.plist"; path = "PrefPane/PrefPane-Info.plist"; sourceTree = ""; }; + 8D202CF70486D31800D8A456 /* PrefPane-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; name = "PrefPane-Info.plist"; path = "PrefPane/PrefPane-Info.plist"; sourceTree = ""; }; 8D202CF80486D31800D8A456 /* Sparkle.prefPane */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Sparkle.prefPane; sourceTree = BUILT_PRODUCTS_DIR; }; + 8DD4ED4E0C9E58F3005CE26A /* SUPoset.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUPoset.h; sourceTree = ""; }; + 8DD4ED4F0C9E58F3005CE26A /* SUPoset.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUPoset.m; sourceTree = ""; }; F506C035013D953901CA16C8 /* PreferencePanes.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = PreferencePanes.framework; path = /System/Library/Frameworks/PreferencePanes.framework; sourceTree = ""; }; F506C03C013D9D7901CA16C8 /* SparklePref.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SparklePref.h; path = PrefPane/SparklePref.h; sourceTree = ""; }; F506C03D013D9D7901CA16C8 /* SparklePref.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = SparklePref.m; path = PrefPane/SparklePref.m; sourceTree = ""; }; @@ -327,6 +329,8 @@ 619D26900C98F08D0034B7EE /* Sparkle Framework-Info.plist */, 6184C9DE0C6D01CA002684BC /* SUProduct.h */, 6184C9DF0C6D01CA002684BC /* SUProduct.m */, + 8DD4ED4E0C9E58F3005CE26A /* SUPoset.h */, + 8DD4ED4F0C9E58F3005CE26A /* SUPoset.m */, ); path = Framework; sourceTree = ""; @@ -391,6 +395,7 @@ files = ( 619D26BF0C98F1620034B7EE /* SUProduct.h in Headers */, 619D26E10C98F2370034B7EE /* NDAlias.h in Headers */, + 8DD4ED500C9E58F3005CE26A /* SUPoset.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -631,6 +636,7 @@ 619D26E60C98F23B0034B7EE /* NDResourceFork.m in Sources */, 619D26E80C98F23D0034B7EE /* NSString+NDCarbonUtilities.m in Sources */, 619D26EA0C98F23E0034B7EE /* NSURL+NDCarbonUtilities.m in Sources */, + 8DD4ED510C9E58F3005CE26A /* SUPoset.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; -- 2.11.4.GIT