[29757] users/rhwood/MacPorts.Framework

source_changes at macosforge.org source_changes at macosforge.org
Mon Oct 8 12:27:59 PDT 2007


Revision: 29757
          http://trac.macosforge.org/projects/macports/changeset/29757
Author:   rhwood at macports.org
Date:     2007-10-08 12:27:59 -0700 (Mon, 08 Oct 2007)

Log Message:
-----------
Method search now returns a dictionary of MPPorts instead of an array of strings.

Modified Paths:
--------------
    users/rhwood/MacPorts.Framework/MPMacPorts.h
    users/rhwood/MacPorts.Framework/MPMacPorts.m

Modified: users/rhwood/MacPorts.Framework/MPMacPorts.h
===================================================================
--- users/rhwood/MacPorts.Framework/MPMacPorts.h	2007-10-08 19:25:37 UTC (rev 29756)
+++ users/rhwood/MacPorts.Framework/MPMacPorts.h	2007-10-08 19:27:59 UTC (rev 29757)
@@ -9,6 +9,7 @@
 #import <Cocoa/Cocoa.h>
 #import "MPConstants.h"
 #import "MPInterpreter.h"
+#import "MPPort.h"
 
 @interface MPMacPorts : NSObject {
 
@@ -20,7 +21,7 @@
 	
 }
 
-- (NSArray *)search:(NSString *)query;
+- (NSDictionary *)search:(NSString *)query;
 
 - (NSString *)prefix;
 - (NSArray *)sources:(BOOL)refresh;

Modified: users/rhwood/MacPorts.Framework/MPMacPorts.m
===================================================================
--- users/rhwood/MacPorts.Framework/MPMacPorts.m	2007-10-08 19:25:37 UTC (rev 29756)
+++ users/rhwood/MacPorts.Framework/MPMacPorts.m	2007-10-08 19:27:59 UTC (rev 29757)
@@ -24,12 +24,20 @@
 	[super dealloc];
 }
 
-- (NSArray *)search:(NSString *)query {
-	return [[interpreter evaluateArrayAsString:[NSArray arrayWithObjects:
-		@"set r {}; set res [mportsearch",
+- (NSDictionary *)search:(NSString *)query {
+	NSMutableDictionary *result;
+	NSEnumerator *enumerator;
+	id key;
+	result = [NSMutableDictionary dictionaryWithDictionary:[interpreter dictionaryFromTclListAsString:[interpreter evaluateArrayAsString:[NSArray arrayWithObjects:
+		@"return [mportsearch",
 		query,
-		@"]; foreach {name info} $res { set r [concat $r $name] }; return $r",
-		nil]] componentsSeparatedByString:@" "];
+		@"]",
+		nil]]]];
+	enumerator = [result keyEnumerator];
+	while (key = [enumerator nextObject]) {
+		[result setObject:[[MPPort alloc] initWithTclListAsString:[result objectForKey:key]] forKey:key];
+	}
+	return [NSDictionary dictionaryWithDictionary:result];
 }
 
 #pragma settings

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20071008/d6e2c066/attachment.html


More information about the macports-changes mailing list