[40518] contrib/MacPorts_Framework
armahg at macports.org
armahg at macports.org
Sat Oct 4 19:52:05 PDT 2008
Revision: 40518
http://trac.macports.org/changeset/40518
Author: armahg at macports.org
Date: 2008-10-04 19:52:05 -0700 (Sat, 04 Oct 2008)
Log Message:
-----------
Added setPortOptions method to MPMacPorts. Builds ok. Yet to document funcionality and test method
Modified Paths:
--------------
contrib/MacPorts_Framework/MPInterpreter.h
contrib/MacPorts_Framework/MPInterpreter.m
contrib/MacPorts_Framework/MPMacPorts.h
contrib/MacPorts_Framework/MPMacPorts.m
contrib/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj
Modified: contrib/MacPorts_Framework/MPInterpreter.h
===================================================================
--- contrib/MacPorts_Framework/MPInterpreter.h 2008-10-05 02:32:35 UTC (rev 40517)
+++ contrib/MacPorts_Framework/MPInterpreter.h 2008-10-05 02:52:05 UTC (rev 40518)
@@ -97,25 +97,29 @@
*/
@interface MPInterpreter : NSObject {
- Tcl_Interp* _interpreter;
- NSString * helperToolInterpCommand;
- NSString * helperToolCommandResult;
+ Tcl_Interp* _interpreter;
+ NSString * helperToolInterpCommand;
+ NSString * helperToolCommandResult;
+ NSArray * defaultPortOptions;
}
+//Internal methods
+-(BOOL) setOptionsForNewTclPort:(NSArray *)options;
-
/*!
@brief Return singleton shared MPInterpreter instance
*/
+ (MPInterpreter *)sharedInterpreter;
+
+
/*!
@brief Return singleton shared MPInterpreter instance for specified macports tcl package path
@param path An NSString specifying the absolute path for the macports tcl package
*/
-+ (MPInterpreter *)sharedInterpreterWithPkgPath:(NSString *)path;
++ (MPInterpreter *)sharedInterpreterWithPkgPath:(NSString *)path portOptions:(NSArray *)options;
@@ -189,7 +193,6 @@
// METHODS FOR INTERNAL USE ONLY
-- (id) initWithPkgPath:(NSString *)path;
- (Tcl_Interp *) sharedInternalTclInterpreter;
- (int) execute:(NSString *)pathToExecutable withArgs:(NSArray*)args;
- (void)setAuthorizationRef:(AuthorizationRef)authRef;
Modified: contrib/MacPorts_Framework/MPInterpreter.m
===================================================================
--- contrib/MacPorts_Framework/MPInterpreter.m 2008-10-05 02:32:35 UTC (rev 40517)
+++ contrib/MacPorts_Framework/MPInterpreter.m 2008-10-05 02:52:05 UTC (rev 40518)
@@ -164,16 +164,12 @@
//tool
static NSString * tclInterpreterPkgPath = nil;
-
-- (id) init {
- return [self initWithPkgPath:MP_DEFAULT_PKG_PATH];
-}
-
-//Internal method for initializing Tcl interpreter
+#pragma mark -
+#pragma mark Internal Methods
+//Internal method for initializing actual C Tcl interpreter
//Should I be using a double pointer like is done for NSError ?
-(BOOL) initTclInterpreter:(Tcl_Interp * *)interp withPath:(NSString *)path {
BOOL result = NO;
-
*interp = Tcl_CreateInterp();
if(*interp == NULL) {
@@ -187,7 +183,10 @@
return result;
}
+ if (path == nil)
+ path = MP_DEFAULT_PKG_PATH;
+
NSString * mport_fastload = [[@"source [file join \"" stringByAppendingString:path]
stringByAppendingString:@"\" macports1.0 macports_fastload.tcl]"];
if(Tcl_Eval(*interp, [mport_fastload UTF8String]) != TCL_OK) {
@@ -205,8 +204,8 @@
}
if( Tcl_EvalFile(*interp, [[[NSBundle bundleWithIdentifier:@"org.macports.frameworks.macports"]
- pathForResource:@"init"
- ofType:@"tcl"] UTF8String]) != TCL_OK) {
+ pathForResource:@"init"
+ ofType:@"tcl"] UTF8String]) != TCL_OK) {
NSLog(@"Error in Tcl_EvalFile init.tcl: %s", Tcl_GetStringResult(*interp));
Tcl_DeleteInterp(*interp);
return result;
@@ -227,8 +226,10 @@
id opt;
while ((opt = [optionsEnum nextObject])) {
- if (Tcl_Eval(*interp , [[NSString stringWithFormat:@"set ui_options(%@) \"yes\"", opt] UTF8String]) != TCL_OK)
+ if (Tcl_Eval(*interp , [[NSString stringWithFormat:@"set ui_options(%@) \"yes\"", opt] UTF8String]) != TCL_OK) {
+ NSLog(@"Error in Tcl_Eval for set ui_options: %s", Tcl_GetStringResult(*interp));
return result;
+ }
}
result = YES;
return result;
@@ -238,11 +239,37 @@
return result;
}
-- (id) initWithPkgPath:(NSString *)path {
+//Wrapper method for above. Used when
+-(BOOL) setOptionsForNewTclPort:(NSArray *)options {
+ BOOL result = NO;
+
+ //First delete our internal Tcl interpreter
+ Tcl_DeleteInterp(_interpreter);
+
+ if (tclInterpreterPkgPath == nil)
+ result = [self initTclInterpreter:&_interpreter withPath:MP_DEFAULT_PKG_PATH];
+ else
+ result = [self initTclInterpreter:&_interpreter withPath:tclInterpreterPkgPath];
+
+ BOOL tempResult = [self setOptions:options forTclInterpreter:&_interpreter];
+
+
+
+
+ return (result && tempResult) ;
+}
+
+- (id) initWithPkgPath:(NSString *)path portOptions:(NSArray *)options {
if (self = [super init]) {
[self initTclInterpreter:&_interpreter withPath:path];
+ //set port options maybe I should do this elsewhere?
+ defaultPortOptions = [NSArray arrayWithObjects: MPDEBUGOPTION, nil];
+ if (options == nil)
+ options = defaultPortOptions;
+ [self setOptions:options forTclInterpreter:&_interpreter];
+
//Initialize helperToolInterpCommand
helperToolInterpCommand = @"";
helperToolCommandResult = @"";
@@ -255,21 +282,36 @@
}
-+ (MPInterpreter*)sharedInterpreter {
-
- return [self sharedInterpreterWithPkgPath:MP_DEFAULT_PKG_PATH];
+#pragma mark API methods
+- (id) init {
+ return [self initWithPkgPath:MP_DEFAULT_PKG_PATH portOptions:nil];
}
+ (MPInterpreter*)sharedInterpreterWithPkgPath:(NSString *)path {
@synchronized(self) {
if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"] == nil) {
- [[self alloc] initWithPkgPath:path]; // assignment not done here
+ [[self alloc] initWithPkgPath:path portOptions:nil]; // assignment not done here
}
}
return [[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"];
}
++ (MPInterpreter*)sharedInterpreter{
+ return [self sharedInterpreterWithPkgPath:MP_DEFAULT_PKG_PATH];
+}
+
+
++ (MPInterpreter*)sharedInterpreterWithPkgPath:(NSString *)path portOptions:(NSArray *)options {
+ @synchronized(self) {
+ if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"] == nil) {
+ [[self alloc] initWithPkgPath:path portOptions:options]; // assignment not done here
+ }
+ }
+ return [[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"];
+}
+
+
+ (id)allocWithZone:(NSZone*)zone {
@synchronized(self) {
if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"] == nil) {
Modified: contrib/MacPorts_Framework/MPMacPorts.h
===================================================================
--- contrib/MacPorts_Framework/MPMacPorts.h 2008-10-05 02:32:35 UTC (rev 40517)
+++ contrib/MacPorts_Framework/MPMacPorts.h 2008-10-05 02:52:05 UTC (rev 40518)
@@ -81,9 +81,13 @@
*/
+ (MPMacPorts *)sharedInstance;
++ (MPMacPorts *)sharedInstanceWithPortOptions:(NSArray *)options;
+
//Names of messages below are subject to change
+ (MPMacPorts *)sharedInstanceWithPkgPath:(NSString *)path;
-- (id) initWithPkgPath:(NSString *)path;
++ (MPMacPorts *)sharedInstanceWithPkgPath:(NSString *)path portOptions:(NSArray *)options;
+- (id) initWithPkgPath:(NSString *)path portOptions:(NSArray *)options;
+- (BOOL) setPortOptions:(NSArray *)options;
/*!
@brief Synchronizes the ports tree without checking for upgrades to the MacPorts base.
Modified: contrib/MacPorts_Framework/MPMacPorts.m
===================================================================
--- contrib/MacPorts_Framework/MPMacPorts.m 2008-10-05 02:32:35 UTC (rev 40517)
+++ contrib/MacPorts_Framework/MPMacPorts.m 2008-10-05 02:52:05 UTC (rev 40518)
@@ -41,13 +41,13 @@
- (id) init {
- return [self initWithPkgPath:MP_DEFAULT_PKG_PATH];
+ return [self initWithPkgPath:MP_DEFAULT_PKG_PATH portOptions:nil];
}
-- (id) initWithPkgPath:(NSString *)path {
+- (id) initWithPkgPath:(NSString *)path portOptions:(NSArray *)options {
if (self = [super init]) {
- interpreter = [MPInterpreter sharedInterpreterWithPkgPath:path];
+ interpreter = [MPInterpreter sharedInterpreterWithPkgPath:path portOptions:nil];
//[self registerForLocalNotifications];
}
return self;
@@ -57,18 +57,33 @@
return [self sharedInstanceWithPkgPath:MP_DEFAULT_PKG_PATH];
}
++ (MPMacPorts *)sharedInstanceWithPortOptions:(NSArray *)options {
+ return [self sharedInstanceWithPkgPath:MP_DEFAULT_PKG_PATH portOptions:options];
+}
+
++ (MPMacPorts *)sharedInstanceWithPkgPath:(NSString *)path portOptions:(NSArray *)options {
+ @synchronized(self) {
+ if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"] == nil) {
+ [[self alloc] initWithPkgPath:path portOptions:options ]; // assignment not done here
+ }
+ }
+ return [[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"];
+}
+
+ (MPMacPorts *)sharedInstanceWithPkgPath:(NSString *)path {
@synchronized(self) {
if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"] == nil) {
- [[self alloc] initWithPkgPath:path]; // assignment not done here
+ [[self alloc] initWithPkgPath:path portOptions:nil ]; // assignment not done here
}
}
return [[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"];
}
+- (BOOL) setPortOptions:(NSArray *)options {
+ return [interpreter setOptionsForNewTclPort:options];
+}
-
+ (id)allocWithZone:(NSZone*)zone {
@synchronized(self) {
if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"] == nil) {
Modified: contrib/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj
===================================================================
--- contrib/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj 2008-10-05 02:32:35 UTC (rev 40517)
+++ contrib/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj 2008-10-05 02:52:05 UTC (rev 40518)
@@ -88,13 +88,6 @@
remoteGlobalIDString = 8DC2EF4F0486A6940098B216;
remoteInfo = MacPorts;
};
- 6E31A2890E6F7910002804D0 /* PBXContainerItemProxy */ = {
- isa = PBXContainerItemProxy;
- containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
- proxyType = 1;
- remoteGlobalIDString = DFE353650CFB8F0C003BACFC;
- remoteInfo = Docs;
- };
6EC2608B0E4270110013BC48 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;
@@ -521,7 +514,6 @@
dependencies = (
6ED12A530E3E55A50026773D /* PBXTargetDependency */,
6EC2608C0E4270110013BC48 /* PBXTargetDependency */,
- 6E31A28A0E6F7910002804D0 /* PBXTargetDependency */,
);
name = MacPorts;
productInstallPath = "$(HOME)/Library/Frameworks";
@@ -694,11 +686,6 @@
target = 8DC2EF4F0486A6940098B216 /* MacPorts */;
targetProxy = 6E1AE8460E232D0700F6D7BC /* PBXContainerItemProxy */;
};
- 6E31A28A0E6F7910002804D0 /* PBXTargetDependency */ = {
- isa = PBXTargetDependency;
- target = DFE353650CFB8F0C003BACFC /* Docs */;
- targetProxy = 6E31A2890E6F7910002804D0 /* PBXContainerItemProxy */;
- };
6EC2608C0E4270110013BC48 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 6EC260860E426FF10013BC48 /* MPHelperInstallTool */;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20081004/b8fb7cb6/attachment-0001.html
More information about the macports-changes
mailing list