[30902] users/rhwood/MacPorts.Framework
source_changes at macosforge.org
source_changes at macosforge.org
Sat Nov 10 11:39:24 PST 2007
Revision: 30902
http://trac.macosforge.org/projects/macports/changeset/30902
Author: rhwood at macports.org
Date: 2007-11-10 11:39:24 -0800 (Sat, 10 Nov 2007)
Log Message:
-----------
Make a subclass of MPMutableDictionary
object:forKey caches and returns port contents when requested
Modified Paths:
--------------
users/rhwood/MacPorts.Framework/MPReceipt.h
users/rhwood/MacPorts.Framework/MPReceipt.m
Modified: users/rhwood/MacPorts.Framework/MPReceipt.h
===================================================================
--- users/rhwood/MacPorts.Framework/MPReceipt.h 2007-11-10 19:31:34 UTC (rev 30901)
+++ users/rhwood/MacPorts.Framework/MPReceipt.h 2007-11-10 19:39:24 UTC (rev 30902)
@@ -38,24 +38,12 @@
#import "MPInterpreter.h"
#import "MPRegistery.h"
- at interface MPReceipt : NSMutableDictionary {
+ at interface MPReceipt : MPMutableDictionary {
- NSMutableDictionary *embeddedDictionary;
-
}
-- (id)init;
-- (id)initWithCapacity:(unsigned)numItems;
- (id)initWithContentsOfArray:(NSArray *)array;
-- (unsigned)count;
-- (NSEnumerator *)keyEnumerator;
-- (id)objectForKey:(id)aKey;
-- (void)removeObjectForKey:(id)aKey;
-- (void)setObject:(id)anObject forKey:(id)aKey;
-- (void)setDictionary:(NSDictionary *)otherDictionary;
-- (NSString *)description;
-
+ (Class)classForKeyedUnarchiver;
- (Class)classForKeyedArchiver;
Modified: users/rhwood/MacPorts.Framework/MPReceipt.m
===================================================================
--- users/rhwood/MacPorts.Framework/MPReceipt.m 2007-11-10 19:31:34 UTC (rev 30901)
+++ users/rhwood/MacPorts.Framework/MPReceipt.m 2007-11-10 19:39:24 UTC (rev 30902)
@@ -38,75 +38,39 @@
@implementation MPReceipt
-- (id)init {
- self = [super init];
- if (self != nil) {
- embeddedDictionary = [[NSMutableDictionary alloc] initWithCapacity:6];
- }
- return self;
-}
-
-- (id)initWithCapacity:(unsigned)numItems {
- self = [super init];
- if (self != nil) {
- embeddedDictionary = [[NSMutableDictionary alloc] initWithCapacity:numItems];
- }
- return self;
-}
-
- (id)initWithContentsOfArray:(NSArray *)array {
self = [super init];
if (self != nil) {
- embeddedDictionary = [[NSMutableDictionary alloc] initWithObjects:array
- forKeys:[NSArray arrayWithObjects:
- @"name",
- @"version",
- @"revision",
- @"variants",
- @"active",
- @"whatIsThis",
- nil]];
+ [self setDictionary:[NSDictionary dictionaryWithObjects:array
+ forKeys:[NSArray arrayWithObjects:
+ @"name",
+ @"version",
+ @"revision",
+ @"variants",
+ @"active",
+ @"whatIsThis",
+ nil]]];
}
return self;
}
- (void) dealloc {
- [embeddedDictionary release];
[super dealloc];
}
-#pragma NSMutableDictionary Protocal
+#pragma MPMutableDictionary Protocal
-- (unsigned)count {
- return [embeddedDictionary count];
-}
-
-- (NSEnumerator *)keyEnumerator {
- return [embeddedDictionary keyEnumerator];
-}
-
- (id)objectForKey:(id)aKey {
- return [embeddedDictionary objectForKey:aKey];
+ if ([aKey isEqualToString:@"contents"] && ![super objectForKey:aKey]) {
+ if ([[self objectForKey:@"active"] intValue]) {
+ [self setObject:[[MPRegistery sharedRegistery] filesForPort:[self objectForKey:@"name"]] forKey:aKey];
+ } else {
+ return nil;
+ }
+ }
+ return [super objectForKey:aKey];
}
-- (void)removeObjectForKey:(id)aKey {
- [embeddedDictionary removeObjectForKey:aKey];
-}
-
-- (void)setObject:(id)anObject forKey:(id)aKey {
- [self willChangeValueForKey:aKey];
- [embeddedDictionary setObject:anObject forKey:aKey];
- [self didChangeValueForKey:aKey];
-}
-
-- (void)setDictionary:(NSDictionary *)otherDictionary {
- [embeddedDictionary setDictionary:otherDictionary];
-}
-
-- (NSString *)description {
- return [embeddedDictionary description];
-}
-
- (Class)classForKeyedArchiver {
return [MPPort class];
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20071110/efa49d68/attachment-0001.html
More information about the macports-changes
mailing list