[28933] users/rhwood/MacPorts.Framework

source_changes at macosforge.org source_changes at macosforge.org
Wed Sep 12 02:56:41 PDT 2007


Revision: 28933
          http://trac.macosforge.org/projects/macports/changeset/28933
Author:   rhwood at macports.org
Date:     2007-09-12 02:56:40 -0700 (Wed, 12 Sep 2007)

Log Message:
-----------
Replace method [evaluateAsString] with methods [evaluateStringAsString] and [evaluateArrayAsString] and rewrite all methods that used [evaluateAsString].
Also rewrite [search] to use [evaluateArrayAsString]

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

Modified: users/rhwood/MacPorts.Framework/MPInterpreter.h
===================================================================
--- users/rhwood/MacPorts.Framework/MPInterpreter.h	2007-09-12 09:19:14 UTC (rev 28932)
+++ users/rhwood/MacPorts.Framework/MPInterpreter.h	2007-09-12 09:56:40 UTC (rev 28933)
@@ -27,7 +27,7 @@
 
 - (void)dumpConfiguration;
 
-- (NSString *)evaluateAsString:(NSString *)statement;
+- (NSString *)evaluateAsString:(NSObject *)statement;
 
 - (NSArray *)getVariableAsArray:(NSString *)variable;
 - (NSString *)getVariableAsString:(NSString *)variable;

Modified: users/rhwood/MacPorts.Framework/MPInterpreter.m
===================================================================
--- users/rhwood/MacPorts.Framework/MPInterpreter.m	2007-09-12 09:19:14 UTC (rev 28932)
+++ users/rhwood/MacPorts.Framework/MPInterpreter.m	2007-09-12 09:56:40 UTC (rev 28933)
@@ -74,10 +74,11 @@
 #pragma Port Operations
 
 - (NSArray *)search:(NSString *)query {
-	const char *string = [query UTF8String];
-	Tcl_VarEval(_interpreter, "set r {}; set res [mportsearch ", string, "]; foreach {name info} $res { set r [concat $r $name] }; return $r", NULL);    
-    NSString *result = [NSString stringWithUTF8String:Tcl_GetStringResult(_interpreter)];
-	return [result componentsSeparatedByString:@" "];
+	return [self evaluateArrayAsString:[NSArray arrayWithObjects:
+		@"set r {}; set res [mportsearch",
+		query,
+		@"]; foreach {name info} $res { set r [concat $r $name] }; return $r",
+		nil]];
 }
 
 #pragma Port Settings
@@ -90,7 +91,11 @@
 	NSLog([NSString stringWithUTF8String:Tcl_GetStringResult(_interpreter)]);
 }
 
-- (NSString *)evaluateAsString:(NSString *)statement {
+- (NSString *)evaluateArrayAsString:(NSArray *)statement {
+	return [self evaluateStringAsString:[statement componentsJoinedByString:@" "]];
+}
+
+- (NSString *)evaluateStringAsString:(NSString *)statement {
 	Tcl_Eval(_interpreter, [statement UTF8String]);
 	return [NSString stringWithUTF8String:Tcl_GetStringResult(_interpreter)];
 }

Modified: users/rhwood/MacPorts.Framework/MPMacPorts.m
===================================================================
--- users/rhwood/MacPorts.Framework/MPMacPorts.m	2007-09-12 09:19:14 UTC (rev 28932)
+++ users/rhwood/MacPorts.Framework/MPMacPorts.m	2007-09-12 09:56:40 UTC (rev 28933)
@@ -39,11 +39,15 @@
 }
 
 - (NSString *)pathToPortIndex:(NSString *)source {
-	return [interpreter evaluateAsString:[[@"return [macports::getindex " stringByAppendingString:source] stringByAppendingString:@" ]"]];
+	return [interpreter evaluateArrayAsString:[NSArray arrayWithObjects:
+		@"return [macports::getindex",
+		source,
+		@"]",
+		nil]];
 }
 
 - (NSString *)version {
-	return [interpreter evaluateAsString:@"return [macports::version]"];
+	return [interpreter evaluateStringAsString:@"return [macports::version]"];
 }
 
 @end

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


More information about the macports-changes mailing list