Changeset 40518 for contrib/MacPorts_Framework
- Timestamp:
- Oct 5, 2008, 2:52:05 AM (16 years ago)
- Location:
- contrib/MacPorts_Framework
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
contrib/MacPorts_Framework/MPInterpreter.h
r40216 r40518 98 98 @interface MPInterpreter : NSObject { 99 99 100 Tcl_Interp* _interpreter; 101 NSString * helperToolInterpCommand; 102 NSString * helperToolCommandResult; 100 Tcl_Interp* _interpreter; 101 NSString * helperToolInterpCommand; 102 NSString * helperToolCommandResult; 103 NSArray * defaultPortOptions; 103 104 104 105 } 105 106 106 107 //Internal methods 108 -(BOOL) setOptionsForNewTclPort:(NSArray *)options; 107 109 108 110 /*! … … 110 112 */ 111 113 + (MPInterpreter *)sharedInterpreter; 114 115 112 116 113 117 … … 116 120 @param path An NSString specifying the absolute path for the macports tcl package 117 121 */ 118 + (MPInterpreter *)sharedInterpreterWithPkgPath:(NSString *)path ;122 + (MPInterpreter *)sharedInterpreterWithPkgPath:(NSString *)path portOptions:(NSArray *)options; 119 123 120 124 … … 190 194 191 195 // METHODS FOR INTERNAL USE ONLY 192 - (id) initWithPkgPath:(NSString *)path;193 196 - (Tcl_Interp *) sharedInternalTclInterpreter; 194 197 - (int) execute:(NSString *)pathToExecutable withArgs:(NSArray*)args; -
contrib/MacPorts_Framework/MPInterpreter.m
r40301 r40518 165 165 static NSString * tclInterpreterPkgPath = nil; 166 166 167 168 - (id) init { 169 return [self initWithPkgPath:MP_DEFAULT_PKG_PATH]; 170 } 171 172 //Internal method for initializing Tcl interpreter 167 #pragma mark - 168 #pragma mark Internal Methods 169 //Internal method for initializing actual C Tcl interpreter 173 170 //Should I be using a double pointer like is done for NSError ? 174 171 -(BOOL) initTclInterpreter:(Tcl_Interp * *)interp withPath:(NSString *)path { 175 172 BOOL result = NO; 176 177 173 *interp = Tcl_CreateInterp(); 178 174 … … 187 183 return result; 188 184 } 185 186 if (path == nil) 187 path = MP_DEFAULT_PKG_PATH; 189 188 190 189 … … 206 205 207 206 if( Tcl_EvalFile(*interp, [[[NSBundle bundleWithIdentifier:@"org.macports.frameworks.macports"] 208 209 207 pathForResource:@"init" 208 ofType:@"tcl"] UTF8String]) != TCL_OK) { 210 209 NSLog(@"Error in Tcl_EvalFile init.tcl: %s", Tcl_GetStringResult(*interp)); 211 210 Tcl_DeleteInterp(*interp); … … 228 227 229 228 while ((opt = [optionsEnum nextObject])) { 230 if (Tcl_Eval(*interp , [[NSString stringWithFormat:@"set ui_options(%@) \"yes\"", opt] UTF8String]) != TCL_OK) 229 if (Tcl_Eval(*interp , [[NSString stringWithFormat:@"set ui_options(%@) \"yes\"", opt] UTF8String]) != TCL_OK) { 230 NSLog(@"Error in Tcl_Eval for set ui_options: %s", Tcl_GetStringResult(*interp)); 231 231 return result; 232 } 232 233 } 233 234 result = YES; … … 239 240 } 240 241 241 - (id) initWithPkgPath:(NSString *)path { 242 //Wrapper method for above. Used when 243 -(BOOL) setOptionsForNewTclPort:(NSArray *)options { 244 BOOL result = NO; 245 246 //First delete our internal Tcl interpreter 247 Tcl_DeleteInterp(_interpreter); 248 249 if (tclInterpreterPkgPath == nil) 250 result = [self initTclInterpreter:&_interpreter withPath:MP_DEFAULT_PKG_PATH]; 251 else 252 result = [self initTclInterpreter:&_interpreter withPath:tclInterpreterPkgPath]; 253 254 BOOL tempResult = [self setOptions:options forTclInterpreter:&_interpreter]; 255 256 257 258 259 return (result && tempResult) ; 260 } 261 262 - (id) initWithPkgPath:(NSString *)path portOptions:(NSArray *)options { 242 263 if (self = [super init]) { 243 264 244 265 [self initTclInterpreter:&_interpreter withPath:path]; 266 267 //set port options maybe I should do this elsewhere? 268 defaultPortOptions = [NSArray arrayWithObjects: MPDEBUGOPTION, nil]; 269 if (options == nil) 270 options = defaultPortOptions; 271 [self setOptions:options forTclInterpreter:&_interpreter]; 245 272 246 273 //Initialize helperToolInterpCommand … … 256 283 257 284 258 + (MPInterpreter*)sharedInterpreter { 259 260 return [self sharedInterpreterWithPkgPath:MP_DEFAULT_PKG_PATH];285 #pragma mark API methods 286 - (id) init { 287 return [self initWithPkgPath:MP_DEFAULT_PKG_PATH portOptions:nil]; 261 288 } 262 289 … … 264 291 @synchronized(self) { 265 292 if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"] == nil) { 266 [[self alloc] initWithPkgPath:path]; // assignment not done here 293 [[self alloc] initWithPkgPath:path portOptions:nil]; // assignment not done here 294 } 295 } 296 return [[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"]; 297 } 298 299 + (MPInterpreter*)sharedInterpreter{ 300 return [self sharedInterpreterWithPkgPath:MP_DEFAULT_PKG_PATH]; 301 } 302 303 304 305 + (MPInterpreter*)sharedInterpreterWithPkgPath:(NSString *)path portOptions:(NSArray *)options { 306 @synchronized(self) { 307 if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"] == nil) { 308 [[self alloc] initWithPkgPath:path portOptions:options]; // assignment not done here 267 309 } 268 310 } -
contrib/MacPorts_Framework/MPMacPorts.h
r39766 r40518 82 82 + (MPMacPorts *)sharedInstance; 83 83 84 + (MPMacPorts *)sharedInstanceWithPortOptions:(NSArray *)options; 85 84 86 //Names of messages below are subject to change 85 87 + (MPMacPorts *)sharedInstanceWithPkgPath:(NSString *)path; 86 - (id) initWithPkgPath:(NSString *)path; 88 + (MPMacPorts *)sharedInstanceWithPkgPath:(NSString *)path portOptions:(NSArray *)options; 89 - (id) initWithPkgPath:(NSString *)path portOptions:(NSArray *)options; 90 - (BOOL) setPortOptions:(NSArray *)options; 87 91 88 92 /*! -
contrib/MacPorts_Framework/MPMacPorts.m
r39766 r40518 42 42 43 43 - (id) init { 44 return [self initWithPkgPath:MP_DEFAULT_PKG_PATH ];45 } 46 47 48 - (id) initWithPkgPath:(NSString *)path {44 return [self initWithPkgPath:MP_DEFAULT_PKG_PATH portOptions:nil]; 45 } 46 47 48 - (id) initWithPkgPath:(NSString *)path portOptions:(NSArray *)options { 49 49 if (self = [super init]) { 50 interpreter = [MPInterpreter sharedInterpreterWithPkgPath:path ];50 interpreter = [MPInterpreter sharedInterpreterWithPkgPath:path portOptions:nil]; 51 51 //[self registerForLocalNotifications]; 52 52 } … … 56 56 + (MPMacPorts *)sharedInstance { 57 57 return [self sharedInstanceWithPkgPath:MP_DEFAULT_PKG_PATH]; 58 } 59 60 + (MPMacPorts *)sharedInstanceWithPortOptions:(NSArray *)options { 61 return [self sharedInstanceWithPkgPath:MP_DEFAULT_PKG_PATH portOptions:options]; 62 } 63 64 + (MPMacPorts *)sharedInstanceWithPkgPath:(NSString *)path portOptions:(NSArray *)options { 65 @synchronized(self) { 66 if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"] == nil) { 67 [[self alloc] initWithPkgPath:path portOptions:options ]; // assignment not done here 68 } 69 } 70 return [[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"]; 58 71 } 59 72 … … 61 74 @synchronized(self) { 62 75 if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"] == nil) { 63 [[self alloc] initWithPkgPath:path ]; // assignment not done here76 [[self alloc] initWithPkgPath:path portOptions:nil ]; // assignment not done here 64 77 } 65 78 } … … 67 80 } 68 81 69 82 - (BOOL) setPortOptions:(NSArray *)options { 83 return [interpreter setOptionsForNewTclPort:options]; 84 } 70 85 71 86 -
contrib/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj
r39766 r40518 88 88 remoteGlobalIDString = 8DC2EF4F0486A6940098B216; 89 89 remoteInfo = MacPorts; 90 };91 6E31A2890E6F7910002804D0 /* PBXContainerItemProxy */ = {92 isa = PBXContainerItemProxy;93 containerPortal = 0867D690FE84028FC02AAC07 /* Project object */;94 proxyType = 1;95 remoteGlobalIDString = DFE353650CFB8F0C003BACFC;96 remoteInfo = Docs;97 90 }; 98 91 6EC2608B0E4270110013BC48 /* PBXContainerItemProxy */ = { … … 522 515 6ED12A530E3E55A50026773D /* PBXTargetDependency */, 523 516 6EC2608C0E4270110013BC48 /* PBXTargetDependency */, 524 6E31A28A0E6F7910002804D0 /* PBXTargetDependency */,525 517 ); 526 518 name = MacPorts; … … 694 686 target = 8DC2EF4F0486A6940098B216 /* MacPorts */; 695 687 targetProxy = 6E1AE8460E232D0700F6D7BC /* PBXContainerItemProxy */; 696 };697 6E31A28A0E6F7910002804D0 /* PBXTargetDependency */ = {698 isa = PBXTargetDependency;699 target = DFE353650CFB8F0C003BACFC /* Docs */;700 targetProxy = 6E31A2890E6F7910002804D0 /* PBXContainerItemProxy */;701 688 }; 702 689 6EC2608C0E4270110013BC48 /* PBXTargetDependency */ = {
Note: See TracChangeset
for help on using the changeset viewer.