[28888] users/rhwood/MacPorts.Framework
source_changes at macosforge.org
source_changes at macosforge.org
Mon Sep 10 15:13:34 PDT 2007
Revision: 28888
http://trac.macosforge.org/projects/macports/changeset/28888
Author: rhwood at macports.org
Date: 2007-09-10 15:13:34 -0700 (Mon, 10 Sep 2007)
Log Message:
-----------
Add getVariableAs* methods
Tweak dumpConfiguration method
Modified Paths:
--------------
users/rhwood/MacPorts.Framework/MPInterpreter.h
users/rhwood/MacPorts.Framework/MPInterpreter.m
Modified: users/rhwood/MacPorts.Framework/MPInterpreter.h
===================================================================
--- users/rhwood/MacPorts.Framework/MPInterpreter.h 2007-09-10 21:57:34 UTC (rev 28887)
+++ users/rhwood/MacPorts.Framework/MPInterpreter.h 2007-09-10 22:13:34 UTC (rev 28888)
@@ -21,8 +21,13 @@
- (NSArray *)search:(NSString *)query;
+#pragma Port Settings
+
#pragma Utilities
- (void)dumpConfiguration;
+- (NSArray *)getVariableAsArray:(NSString *)variable;
+- (NSString *)getVariableAsString:(NSString *)variable;
+
@end
Modified: users/rhwood/MacPorts.Framework/MPInterpreter.m
===================================================================
--- users/rhwood/MacPorts.Framework/MPInterpreter.m 2007-09-10 21:57:34 UTC (rev 28887)
+++ users/rhwood/MacPorts.Framework/MPInterpreter.m 2007-09-10 22:13:34 UTC (rev 28888)
@@ -80,11 +80,38 @@
return [result componentsSeparatedByString:@" "];
}
+#pragma Port Settings
+
#pragma Utilities
- (void)dumpConfiguration {
- Tcl_VarEval(_interpreter, "set r $system_options");
+ // DOES NOT WORK?
+ Tcl_GetVar(_interpreter, [@"system_options" UTF8String], TCL_GLOBAL_ONLY);
NSLog([NSString stringWithUTF8String:Tcl_GetStringResult(_interpreter)]);
}
+- (NSArray *)getVariableAsArray:(NSString *)variable {
+ NSMutableArray *array;
+ int tclCount;
+ int tclResult;
+ int i;
+ const char **tclElements;
+ NSString *contents;
+ contents = [NSString stringWithUTF8String:Tcl_GetVar(_interpreter, [variable UTF8String], TCL_LIST_ELEMENT)];
+ tclResult = Tcl_SplitList(_interpreter, [contents UTF8String], &tclCount, &tclElements);
+ if (tclResult == TCL_OK) {
+ array = [[NSMutableArray alloc] initWithCapacity:tclCount];
+ for (i = 0; i < tclCount; i++) {
+ [array addObject:[NSString stringWithUTF8String:tclElements[i]]];
+ }
+ return [NSArray arrayWithArray:array];
+ }
+ return [[NSArray alloc] init];
+}
+
+- (NSString *)getVariableAsString:(NSString *)variable {
+ return [NSString stringWithUTF8String:Tcl_GetVar(_interpreter, [variable UTF8String], 0)];
+}
+
+
@end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20070910/e42ad62c/attachment.html
More information about the macports-changes
mailing list