[38611] branches/gsoc08-framework/MacPorts_Framework

armahg at macports.org armahg at macports.org
Fri Jul 25 15:59:26 PDT 2008


Revision: 38611
          http://trac.macosforge.org/projects/macports/changeset/38611
Author:   armahg at macports.org
Date:     2008-07-25 15:59:26 -0700 (Fri, 25 Jul 2008)
Log Message:
-----------
Implemented preliminary NSError handling for MPInterpreter's evaluateStringAsString method and other relevant classes that use this method.

Modified Paths:
--------------
    branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.h
    branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m
    branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.h
    branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.m
    branches/gsoc08-framework/MacPorts_Framework/MPMacPortsTest.m
    branches/gsoc08-framework/MacPorts_Framework/MPPort.h
    branches/gsoc08-framework/MacPorts_Framework/MPPort.m
    branches/gsoc08-framework/MacPorts_Framework/MPRegistry.m
    branches/gsoc08-framework/MacPorts_Framework/ToDo.txt

Modified: branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.h
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.h	2008-07-25 22:07:08 UTC (rev 38610)
+++ branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.h	2008-07-25 22:59:26 UTC (rev 38611)
@@ -43,11 +43,12 @@
 #include <tcl.h>  
 #import "MPNotifications.h"
 
-#define	MPPackage			@"macports"
-#define MPPackageVersion	@"1.0"
-#define MP_DEFAULT_PKG_PATH @"/Library/Tcl"
-#define TCL_RETURN_CODE @"return code"
-#define TCL_RETURN_STRING @"return string"
+#define	MPPackage				@"macports"
+#define MPPackageVersion		@"1.0"
+#define MP_DEFAULT_PKG_PATH		@"/Library/Tcl"
+#define TCL_RETURN_CODE			@"return code"
+#define TCL_RETURN_STRING		@"return string"
+#define MPFrameworkErrorDomain	@"MacPortsFrameworkErrorDomain"
 
 /*!
  @class MPInterpreter
@@ -109,7 +110,7 @@
  [SomeMPInterpreterObject evaluateStringAsString:
 							[NSString stringWithString:@"return [macports::getindex SomeValidMacPortsSourcePath]"]];
  */
-//- (NSString *)evaluateStringAsString:(NSString *)statement;
+- (NSString *)evaluateStringAsString:(NSString *)statement error:(NSError **)mportError;
 
 
 //Redoing evaluateStringAsString and evaluateArrayAsString to return a two element NSDictionary.
@@ -120,10 +121,16 @@
 //a commit. Obtaining the return code will make error handling in the framework much less
 //cumbersome
 //- (NSDictionary *)evaluateArrayAsString:(NSArray *)statement;
-- (NSDictionary *)evaluateStringAsString:(NSString *)statement;
+//- (NSDictionary *)evaluateStringAsString:(NSString *)statement;
 
 
+//After eliminating evaluateArrayAsString ... I'm wondering if I should take jberry's advice
+//hmm ... well this method needs to return two pieces of information ... the string
+//and an indicator of success .. oh wait ... I can jut check the returned error variable
+//for a successful method ... back to Randall's implementation with some tweaks then ... 
 
+
+
 /*!
  @brief Returns an NSArray whose elements are the the elements of a Tcl list in the form of an NSString
  @param list A Tcl list in the form of an NSString

Modified: branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m	2008-07-25 22:07:08 UTC (rev 38610)
+++ branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m	2008-07-25 22:59:26 UTC (rev 38611)
@@ -239,22 +239,56 @@
 	return [self evaluateStringAsString:[statement componentsJoinedByString:@" "]];
 }
 
-/*
-- (NSString *)evaluateStringAsString:(NSString *)statement {
-	Tcl_Eval(_interpreter, [statement UTF8String]);
+*/
+- (NSString *)evaluateStringAsString:(NSString *)statement error:(NSError**)mportError{
+	int return_code = Tcl_Eval(_interpreter, [statement UTF8String]);
+	
+	//Should I check for (return_code != TCL_Ok && return_code != TCL_RETURN) instead ?
+	if (return_code == TCL_ERROR) {
+		
+		Tcl_Obj * interpObj = Tcl_GetObjResult(_interpreter);
+		int length, errCode;
+		NSString * errString = [NSString stringWithUTF8String:Tcl_GetStringFromObj(interpObj, &length)];
+		NSLog(@"TclObj string is %@ with length %d", errString , length);
+		errCode = Tcl_GetErrno();
+		NSLog(@"Errno Id is %@ with value %d", [NSString stringWithUTF8String:Tcl_ErrnoId()], errCode);
+		NSLog(@"Errno Msg is %@", [NSString stringWithUTF8String:Tcl_ErrnoMsg(errCode)]);
+		
+		//Handle errors here ... Framework users can do !mportError to find out if
+		//method was successful
+		NSString *descrip = NSLocalizedString(errString, @"");
+		NSDictionary *errDict;
+		//For now all error codes are TCL_ERROR
+		
+		//Create underlying error - For now I'll create the underlying Posix Error
+		NSError *undError = [[[NSError alloc] initWithDomain:NSPOSIXErrorDomain
+														code:errCode 
+													userInfo:nil] autorelease];
+		//Create and return custom domain error
+		NSArray *objArray = [NSArray arrayWithObjects:descrip, undError, nil];
+		NSArray *keyArray = [NSArray arrayWithObjects:NSLocalizedDescriptionKey,
+							 NSUnderlyingErrorKey, nil];
+		errDict = [NSDictionary dictionaryWithObjects:objArray forKeys:keyArray];
+		if (mportError != NULL)
+			*mportError = [[[NSError alloc] initWithDomain:MPFrameworkErrorDomain 
+													  code:TCL_ERROR 
+												  userInfo:errDict] autorelease];
+		return nil;
+	}
+	
 	return [NSString stringWithUTF8String:Tcl_GetStringResult(_interpreter)];
 }
-*/
 
 
+/*
 - (NSDictionary *)evaluateStringAsString:(NSString *)statement {
 	int return_code = Tcl_Eval(_interpreter, [statement UTF8String]);
 	return [NSDictionary dictionaryWithObjectsAndKeys:
 			[NSNumber numberWithInt:return_code], TCL_RETURN_CODE, 
 			[NSString stringWithUTF8String:Tcl_GetStringResult(_interpreter)], TCL_RETURN_STRING, nil];
 }
+*/
 
-
 - (NSArray *)arrayFromTclListAsString:(NSString *)list {
 	NSMutableArray *array;
 	int tclCount;

Modified: branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.h
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.h	2008-07-25 22:07:08 UTC (rev 38610)
+++ branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.h	2008-07-25 22:59:26 UTC (rev 38611)
@@ -77,12 +77,12 @@
 /*!
  @brief Synchronizes the ports tree without checking for upgrades to the MacPorts base.
  */
-- (void)sync;
+- (void)sync:(NSError **)sError;
 /*!
  @brief Synchronizes the ports tree and checks for upgrades to MacPorts base.
  @discussion The selfupdate port command is available only on Mac OS X systems.
  */
-- (void)selfUpdate;
+- (void)selfUpdate:(NSError **)sError;
 
 
 
@@ -138,7 +138,7 @@
  @Discussion See -exec: withOptions: withVariants: in @link //apple_ref/doc/header/MPPort.h MPPort @/link for discussion
  of this method.
  */
-- (void)exec:(MPPort *)port withTarget:(NSString *)target withOptions:(NSArray *)options withVariants:(NSArray *)variants;
+- (void)exec:(MPPort *)port withTarget:(NSString *)target withOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError **)execError;
 
 /*!
  @brief Returns the NSString path to the directory where ports are installed.

Modified: branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.m
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.m	2008-07-25 22:07:08 UTC (rev 38610)
+++ branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.m	2008-07-25 22:59:26 UTC (rev 38611)
@@ -101,33 +101,23 @@
 
 #pragma MacPorts API
 
-- (void)sync {
+- (void)sync:(NSError**)sError {
 	// This needs to throw an exception if things don't go well
 	[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"MacPortsSyncStarted" object:nil];
 	[[MPNotifications sharedListener] setPerformingTclCommand:@"YES_sync"];
 	
-	NSDictionary * returnDict = [interpreter evaluateStringAsString:@"mportsync"];
+	[interpreter evaluateStringAsString:@"mportsync" error:sError];
 	
-	Tcl_Interp * interp = [interpreter sharedTclInterpreter];
-	Tcl_Obj * interpObj = Tcl_GetObjResult(interp);
-	int length, errCode;
-	NSLog(@"TclObj string is %@ with length %d", 
-		  [NSString stringWithUTF8String:Tcl_GetStringFromObj(interpObj, &length)] , \
-		  length);
-	errCode = Tcl_GetErrno();
-	NSLog(@"Errno Id is %@ with value %d", [NSString stringWithUTF8String:Tcl_ErrnoId()], errCode);
-	NSLog(@"Errno Msg is %@", [NSString stringWithUTF8String:Tcl_ErrnoMsg(errCode)]);
-	
 	[[MPNotifications sharedListener] setPerformingTclCommand:@""];
 	[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"MacPortsSyncFinished" object:nil];
 }
 
-- (void)selfUpdate {
+- (void)selfUpdate:(NSError**)sError {
 	//Also needs to throw an exception if things don't go well
 	[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"MacPortsSelfupdateStarted" object:nil];
 	[[MPNotifications sharedListener] setPerformingTclCommand:@"YES_selfUpdate"];
 	
-	NSDictionary * returnDict = [interpreter evaluateStringAsString:@"macports::selfupdate"];
+	[interpreter evaluateStringAsString:@"macports::selfupdate" error:sError];
 	
 	[[MPNotifications sharedListener] setPerformingTclCommand:@""];
 	[[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"MacPortsSelfupdateFinished" object:nil];
@@ -170,12 +160,14 @@
 										  fieldName,
 										  @"]",
 				 nil]] objectForKey:TCL_RETURN_STRING] ]];*/
+	NSError * sError;
 	
 	result = [NSMutableDictionary dictionaryWithDictionary:
 			  [interpreter dictionaryFromTclListAsString:
-			   [[interpreter evaluateStringAsString:
-				 [NSString stringWithFormat:@"return [mportsearch %@ %@ %@ %@]",
-				  query, caseSensitivity, style, fieldName]] objectForKey:TCL_RETURN_STRING]]];
+			   [interpreter evaluateStringAsString:
+				[NSString stringWithFormat:@"return [mportsearch %@ %@ %@ %@]",
+				 query, caseSensitivity, style, fieldName] 
+											 error:&sError]]];
 	
 	newResult = [NSMutableDictionary dictionaryWithCapacity:[result count]];
 	enumerator = [result keyEnumerator];
@@ -192,8 +184,13 @@
 }
 
 
-- (void)exec:(MPPort *)port withTarget:(NSString *)target withOptions:(NSArray *)options withVariants:(NSArray *)variants {
-	[port exec:target withOptions:options withVariants:variants];
+- (void)exec:(MPPort *)port 
+  withTarget:(NSString *)target 
+ withOptions:(NSArray *)options 
+withVariants:(NSArray *)variants
+	   error:(NSError **)execError
+{
+	[port exec:target withOptions:options withVariants:variants error:execError ];
 }
 
 #pragma settings
@@ -222,15 +219,19 @@
 
 
 - (NSURL *)pathToPortIndex:(NSString *)source {
+	NSError * pError;
 	return [NSURL fileURLWithPath:
-			[[interpreter evaluateStringAsString:
-			 [NSString stringWithFormat:@"return [macports::getindex %@ ]", source]] objectForKey:TCL_RETURN_STRING]];
+			[interpreter evaluateStringAsString:
+			 [NSString stringWithFormat:@"return [macports::getindex %@ ]", source]
+										  error:&pError]];
 }
 
 
 - (NSString *)version {
 	if (version == nil) {
-		version = [[interpreter evaluateStringAsString:@"return [macports::version]"] objectForKey:TCL_RETURN_STRING];
+		
+		NSError * vError;
+		version = [interpreter evaluateStringAsString:@"return [macports::version]" error:&vError];
 	}
 	return version;
 }

Modified: branches/gsoc08-framework/MacPorts_Framework/MPMacPortsTest.m
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPMacPortsTest.m	2008-07-25 22:07:08 UTC (rev 38610)
+++ branches/gsoc08-framework/MacPorts_Framework/MPMacPortsTest.m	2008-07-25 22:59:26 UTC (rev 38611)
@@ -76,7 +76,8 @@
 
 
 -(void) testSync {
-	[testPort sync];
+	NSError * syncError;
+	[testPort sync:&syncError];
 }
 
 /*

Modified: branches/gsoc08-framework/MacPorts_Framework/MPPort.h
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPPort.h	2008-07-25 22:07:08 UTC (rev 38610)
+++ branches/gsoc08-framework/MacPorts_Framework/MPPort.h	2008-07-25 22:59:26 UTC (rev 38611)
@@ -111,9 +111,9 @@
 - (NSArray *)depends;
 
 //Wrapper method for the 3 functions below
-- (void)execPortProc:(NSString *)procedure withOptions:(NSArray *)options withVersion:(NSString *)version;
+- (void)execPortProc:(NSString *)procedure withOptions:(NSArray *)options withVersion:(NSString *)version error:(NSError **)execError;
 //Even more generic method to execute a Tcl command with any given number of args
-- (void)execPortProc:(NSString *)procedure withParams:(NSArray *)params;
+- (void)execPortProc:(NSString *)procedure withParams:(NSArray *)params error:(NSError **)execError;
 
 
 /*!
@@ -122,7 +122,7 @@
  @param version An NSString indicating which version of this port to uninstall
  @discussion version should NOT be nil
  */
-- (void)uninstallWithOptions:(NSArray *)options withVersion:(NSString *)version;
+- (void)uninstallWithOptions:(NSArray *)options withVersion:(NSString *)version error:(NSError**)mpError;
 /*!
  @brief Activates an installed MPPort.
  @param options An NSArray of NSStrings of options for port activation
@@ -132,7 +132,7 @@
  of a port. This means activation of a port should occur only if the port
  had been previously deactivated after a default installation.
  */
-- (void)activateWithOptions:(NSArray *)options withVersion:(NSString *)version;
+- (void)activateWithOptions:(NSArray *)options withVersion:(NSString *)version error:(NSError**)mpError;
 /*!
  @brief Deactivates an installed  MPPort.
  @param options An NSArray of NSStrings of options for port deactivation
@@ -140,7 +140,7 @@
  @discussion version should NOT be nil. Only installed and active ports
  should be deactivated
 */
-- (void)deactivateWithOptions:(NSArray *)options withVersion:(NSString *)version;
+- (void)deactivateWithOptions:(NSArray *)options withVersion:(NSString *)version error:(NSError**)mpError;
 
 
 /*!
@@ -155,7 +155,7 @@
  
  ADD SOMETHING HERE ABOUT VARIANTS AND OPTIONS
  */
--(void)exec:(NSString *)target withOptions:(NSArray *)options withVariants:(NSArray *)variants;
+-(void)exec:(NSString *)target withOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError **)execError;
 
 /*Convenience methods based on the exec: withTarget: method
  These methods and -exec: need to be rewritten to handle variants
@@ -170,32 +170,32 @@
  @param options An NSArray of NSStrings of the various options for this target
  @param variants An NSArray of NSStrings of the various variants for this target
  */
--(void)configureWithOptions:(NSArray *)options withVariants:(NSArray *)variants;
+-(void)configureWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError**)mError;
 /*!
  @brief Builds this port.
  @param options An NSArray of NSStrings of the various options for this target
  @param variants An NSArray of NSStrings of the various variants for this target
  */
--(void)buildWithOptions:(NSArray *)options withVariants:(NSArray *)variants;
+-(void)buildWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError**)mError;
 /*!
  @brief Tests this port.
  @param options An NSArray of NSStrings of the various options for this target
  @param variants An NSArray of NSStrings of the various variants for this target
  */
--(void)testWithOptions:(NSArray *)options withVariants:(NSArray *)variants;
+-(void)testWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError**)mError;
 /*!
  @brief Installs this port to a temporary directory
  @param options An NSArray of NSStrings of the various options for this target
  @param variants An NSArray of NSStrings of the various variants for this target
  */
--(void)destrootWithOptions:(NSArray *)options withVariants:(NSArray *)variants;
+-(void)destrootWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError**)mError;
 /*!
  @brief Installs this port.
  @param options An NSArray of NSStrings of the various options for this target
  @param variants An NSArray of NSStrings of the various variants for this target
  @discussion Installing a port automatically activates it.
  */
--(void)installWithOptions:(NSArray *)options withVariants:(NSArray *)variants;
+-(void)installWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError**)mError;
 /*!
  @brief Archives port for later unarchving. 
  @discussion Archive mode must be enabled for this command to work.
@@ -203,53 +203,53 @@
  located in ${prefix}/etc/macports/macports.conf. With archive mode enabled,
  binary archives are created automatically whenever an install is performed.
  */
--(void)archiveWithOptions:(NSArray *)options withVariants:(NSArray *)variants;
+-(void)archiveWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError**)mError;
 /*!
  @brief Creates an internet-enabled disk image containing OS X package of this
  port
  @param options An NSArray of NSStrings of the various options for this target
  @param variants An NSArray of NSStrings of the various variants for this target
  */
--(void)createDmgWithOptions:(NSArray *)options withVariants:(NSArray *)variants;
+-(void)createDmgWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError**)mError;
 /*!
  @brief Create an internet-enabled disk image containing an OS X metapackage of this
  port
  @param options An NSArray of NSStrings of the various options for this target
  @param variants An NSArray of NSStrings of the various variants for this target
  */
--(void)createMdmgWithOptions:(NSArray *)options withVariants:(NSArray *)variants;
+-(void)createMdmgWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError**)mError;
 /*!
  @brief Creates an OS X installer package of this port
  @param options An NSArray of NSStrings of the various options for this target
  @param variants An NSArray of NSStrings of the various variants for this target
  */
--(void)createPkgWithOptions:(NSArray *)options withVariants:(NSArray *)variants;
+-(void)createPkgWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError**)mError;
 /*!
  @brief Creates an OS X installer metapackage of this this port and 
  its dependencies
  @param options An NSArray of NSStrings of the various options for this target
  @param variants An NSArray of NSStrings of the various variants for this target
  */
--(void)createMpkgWithOptions:(NSArray *)options withVariants:(NSArray *)variants;
+-(void)createMpkgWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError**)mError;
 /*!
  @brief Creates and RPM binary package of this port. This is similar to a
  tgz "archive".
  @param options An NSArray of NSStrings of the various options for this target
  @param variants An NSArray of NSStrings of the various variants for this target
  */
--(void)createRpmWithOptions:(NSArray *)options withVariants:(NSArray *)variants;
+-(void)createRpmWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError**)mError;
 /*!
  @brief Creates a DEB binary package of this port.
  @param options An NSArray of NSStrings of the various options for this target
  @param variants An NSArray of NSStrings of the various variants for this target
  */
--(void)createDpkgWithOptions:(NSArray *)options withVariants:(NSArray *)variants;
+-(void)createDpkgWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError**)mError;
 /*!
  @brief Creates an SRPM source package of this port, similar to a xar "portpkg".
  @param options An NSArray of NSStrings of the various options for this target
  @param variants An NSArray of NSStrings of the various variants for this target
  */
--(void)createSrpmWithOptions:(NSArray *)options withVariants:(NSArray *)variants;
+-(void)createSrpmWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError**)mError;
 
 /*!
  @brief Sets the attributes of this MPPort using the given string

Modified: branches/gsoc08-framework/MacPorts_Framework/MPPort.m
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPPort.m	2008-07-25 22:07:08 UTC (rev 38610)
+++ branches/gsoc08-framework/MacPorts_Framework/MPPort.m	2008-07-25 22:59:26 UTC (rev 38611)
@@ -157,7 +157,8 @@
 
 
 //This method is nice but really isn't used.
-- (void)execPortProc:(NSString *)procedure withParams:(NSArray *)params {
+- (void)execPortProc:(NSString *)procedure withParams:(NSArray *)params error:(NSError **)execError {
+	
 	//params can contain either NSStrings or NSArrays
 	NSString * sparams = [NSString stringWithString:@" "];
 	NSEnumerator * penums = [params objectEnumerator];
@@ -179,13 +180,19 @@
 		}
 	}
 	
-	NSDictionary * returnDict = [interpreter evaluateStringAsString:
-								 [NSString stringWithFormat:@"[%@ %@]" , procedure, sparams]];
+	
+	[interpreter evaluateStringAsString:[NSString stringWithFormat:@"[%@ %@]" , procedure, sparams] 
+								  error:execError];
+	
 }
 
 
 //Used for mportactivate, mportdeactivate and mportuninstall
--(void)execPortProc:(NSString *)procedure withOptions:(NSArray *)options withVersion:(NSString *)version {
+-(void)execPortProc:(NSString *)procedure 
+		withOptions:(NSArray *)options 
+		withVersion:(NSString *)version
+			  error:(NSError **)execError {
+	
 	NSString *opts, *v;
 	MPInterpreter *interpreter;
 	opts = [NSString stringWithString:@" "];
@@ -205,17 +212,22 @@
 	NSString * tclCmd = [@"YES_" stringByAppendingString:procedure];
 	[[MPNotifications sharedListener] setPerformingTclCommand:tclCmd];
 	
-	NSDictionary * returnDict = [interpreter evaluateStringAsString:
-								 [NSString stringWithFormat:
-								  @"[%@ %@ %@ %@]" ,
-								  procedure, [self name], v, opts]];
+	[interpreter evaluateStringAsString:
+	 [NSString stringWithFormat:
+	  @"[%@ %@ %@ %@]" ,
+	  procedure, [self name], v, opts]
+								  error:execError];
 	
 	[[MPNotifications sharedListener] setPerformingTclCommand:@""];
 	[self sendGlobalExecNotification:procedure withStatus:@"Finished"];
 }
 
 //Used for the rest of other exec procedures
--(void)exec:(NSString *)target withOptions:(NSArray *)options withVariants:(NSArray *)variants {
+-(void) exec:(NSString *)target 
+ withOptions:(NSArray *)options 
+withVariants:(NSArray *)variants 
+	   error:(NSError **)execError{
+	
 	NSString *opts; 
 	NSString *vrnts;
 	MPInterpreter *interpreter;
@@ -235,12 +247,13 @@
 	NSString * tclCmd = [@"YES_" stringByAppendingString:target];
 	[[MPNotifications sharedListener] setPerformingTclCommand:tclCmd];
 	
-	NSDictionary * returnDict = [interpreter evaluateStringAsString:
-								 [NSString stringWithFormat:
-								  @"set portHandle [mportopen  %@  %@  %@]; \
-								  mportexec portHandle %@; \
-								  mportclose portHandle", 
-								  [self valueForKey:@"portURL"], opts, vrnts, target]];
+	[interpreter evaluateStringAsString:
+	 [NSString stringWithFormat:
+	  @"set portHandle [mportopen  %@  %@  %@]; \
+	  mportexec portHandle %@; \
+	  mportclose portHandle", 
+	  [self valueForKey:@"portURL"], opts, vrnts, target]
+								  error:execError];
 	
 	[[MPNotifications sharedListener] setPerformingTclCommand:@""];
 	[self sendGlobalExecNotification:target withStatus:@"Finished"];
@@ -252,68 +265,68 @@
 
 #pragma mark -
 # pragma mark Exec methods 
-- (void)uninstallWithOptions:(NSArray *)options withVersion:(NSString *)version {
-	[self execPortProc:@"mportuninstall" withOptions:options withVersion:version];
+- (void)uninstallWithOptions:(NSArray *)options withVersion:(NSString *)version error:(NSError **)mError {
+	[self execPortProc:@"mportuninstall" withOptions:options withVersion:version error:mError];
 }
 
-- (void)activateWithOptions:(NSArray *)options withVersion:(NSString *)version {
-	[self execPortProc:@"mportactivate" withOptions:options withVersion:version];
+- (void)activateWithOptions:(NSArray *)options withVersion:(NSString *)version error:(NSError **)mError {
+	[self execPortProc:@"mportactivate" withOptions:options withVersion:version error:mError];
 }
 
-- (void)deactivateWithOptions:(NSArray *)options withVersion:(NSString *)version {
-	[self execPortProc:@"mportdeactivate" withOptions:options withVersion:version];
+- (void)deactivateWithOptions:(NSArray *)options withVersion:(NSString *)version error:(NSError **)mError {
+	[self execPortProc:@"mportdeactivate" withOptions:options withVersion:version error:mError];
 }
 
--(void)configureWithOptions:(NSArray *)options withVariants:(NSArray *)variants{
-	[self exec:@"configure" withOptions:options withVariants:variants];
+-(void)configureWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError **)mError {
+	[self exec:@"configure" withOptions:options withVariants:variants error:mError];
 }
 
--(void)buildWithOptions:(NSArray *)options withVariants:(NSArray *)variants {
-	[self exec:@"build" withOptions:options withVariants:variants];
+-(void)buildWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError **)mError {
+	[self exec:@"build" withOptions:options withVariants:variants error:mError];
 }
 
--(void)testWithOptions:(NSArray *)options withVariants:(NSArray *)variants {
-	[self exec:@"test" withOptions:options withVariants:variants];	
+-(void)testWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError **)mError {
+	[self exec:@"test" withOptions:options withVariants:variants error:mError];	
 }
 
--(void)destrootWithOptions:(NSArray *)options withVariants:(NSArray *)variants {
-	[self exec:@"destroot" withOptions:options withVariants:variants];
+-(void)destrootWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError **)mError {
+	[self exec:@"destroot" withOptions:options withVariants:variants error:mError];
 }
 
--(void)installWithOptions:(NSArray *)options withVariants:(NSArray *)variants {
-	[self exec:@"install" withOptions:options withVariants:variants];
+-(void)installWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError **)mError {
+	[self exec:@"install" withOptions:options withVariants:variants error:mError];
 }
 
--(void)archiveWithOptions:(NSArray *)options withVariants:(NSArray *)variants {
-	[self exec:@"archive" withOptions:options withVariants:variants];
+-(void)archiveWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError **)mError {
+	[self exec:@"archive" withOptions:options withVariants:variants error:mError];
 }
 
--(void)createDmgWithOptions:(NSArray *)options withVariants:(NSArray *)variants {
-	[self exec:@"dmg" withOptions:options withVariants:variants];
+-(void)createDmgWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError **)mError {
+	[self exec:@"dmg" withOptions:options withVariants:variants error:mError];
 }
 
--(void)createMdmgWithOptions:(NSArray *)options withVariants:(NSArray *)variants {
-	[self exec:@"mdmg" withOptions:options withVariants:variants];
+-(void)createMdmgWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError **)mError {
+	[self exec:@"mdmg" withOptions:options withVariants:variants error:mError];
 }
 
--(void)createPkgWithOptions:(NSArray *)options withVariants:(NSArray *)variants {
-	[self exec:@"pkg" withOptions:options withVariants:variants];
+-(void)createPkgWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError **)mError {
+	[self exec:@"pkg" withOptions:options withVariants:variants error:mError];
 }
 
--(void)createMpkgWithOptions:(NSArray *)options withVariants:(NSArray *)variants {
-	[self exec:@"mpkg" withOptions:options withVariants:variants];
+-(void)createMpkgWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError **)mError {
+	[self exec:@"mpkg" withOptions:options withVariants:variants error:mError];
 }
 
--(void)createRpmWithOptions:(NSArray *)options withVariants:(NSArray *)variants {
-	[self exec:@"rpm" withOptions:options withVariants:variants];
+-(void)createRpmWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError **)mError{
+	[self exec:@"rpm" withOptions:options withVariants:variants error:mError];
 }
 
--(void)createDpkgWithOptions:(NSArray *)options withVariants:(NSArray *)variants {
-	[self exec:@"dpkg" withOptions:options withVariants:variants];
+-(void)createDpkgWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError **)mError{
+	[self exec:@"dpkg" withOptions:options withVariants:variants error:mError];
 }
 
--(void)createSrpmWithOptions:(NSArray *)options withVariants:(NSArray *)variants {
-	[self exec:@"srpm" withOptions:options withVariants:variants];
+-(void)createSrpmWithOptions:(NSArray *)options withVariants:(NSArray *)variants error:(NSError **)mError{
+	[self exec:@"srpm" withOptions:options withVariants:variants error:mError];
 }
 
 # pragma mark -

Modified: branches/gsoc08-framework/MacPorts_Framework/MPRegistry.m
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPRegistry.m	2008-07-25 22:07:08 UTC (rev 38610)
+++ branches/gsoc08-framework/MacPorts_Framework/MPRegistry.m	2008-07-25 22:59:26 UTC (rev 38611)
@@ -125,12 +125,26 @@
 	 @"]",
 	 nil
 	 ]] objectForKey:TCL_RETURN_STRING]];
-	 */
 	
 	return [interpreter arrayFromTclListAsString:
 			[[interpreter evaluateStringAsString:
 			  [NSString stringWithFormat:@"return [registry::installed %@ %@]", name, version]] 
 			 objectForKey:TCL_RETURN_STRING]];
+	*/
+	
+	NSError *anError;
+	NSString * result = [interpreter evaluateStringAsString:
+						 [NSString stringWithFormat:@"return [registry::installed %@ %@]", name, version]
+													  error:&anError];
+	if (result == nil && anError) {
+		//Recover from error here
+		return nil;
+	}
+	
+	return [interpreter arrayFromTclListAsString:result];
+	
+	
+	
 }
 
 - (NSArray *)filesForPort:(NSString *)name {
@@ -142,12 +156,23 @@
 												 @"]",
 												 nil]] 
 			 objectForKey:TCL_RETURN_STRING] ];
-	 */
-	
+	 
 	return [interpreter arrayFromTclListAsString:
 			[[interpreter evaluateStringAsString:
 			   [NSString stringWithFormat:@"return [registry::port_registered %@]", name]] 
 			 objectForKey:TCL_RETURN_STRING]];
+	*/
+	
+	NSError * anError;
+	NSString * result = [interpreter evaluateStringAsString:
+						 [NSString stringWithFormat:@"return [registry::port_registered %@]", name]
+													  error:&anError];
+	if (result == nil && anError) {
+		//Recover from error here
+		return nil;
+	}
+	
+	return [interpreter arrayFromTclListAsString:result];
 }
 
 @end

Modified: branches/gsoc08-framework/MacPorts_Framework/ToDo.txt
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/ToDo.txt	2008-07-25 22:07:08 UTC (rev 38610)
+++ branches/gsoc08-framework/MacPorts_Framework/ToDo.txt	2008-07-25 22:59:26 UTC (rev 38611)
@@ -5,7 +5,6 @@
 Get feedback on Notifications idea and implementation
 
 
-
 Test Notifications Library ... how? ... use the Tester ...
 and see if the rest of the tests build
 
@@ -23,3 +22,6 @@
 Rearrange methods orderings in both .h and .m files
 and add appropriate pragma marks for more readablity
 
+
+ASK FOR HOW TO TURN ON / OFF VARIOUS MODES FOR UI_$PRIORITY I.E.
+DEBUG, INFO ETC.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080725/2d42f118/attachment-0001.html 


More information about the macports-changes mailing list