[57187] branches/gsoc09-gui/MacPorts_Framework

juanger at macports.org juanger at macports.org
Sun Sep 6 22:30:57 PDT 2009


Revision: 57187
          http://trac.macports.org/changeset/57187
Author:   juanger at macports.org
Date:     2009-09-06 22:30:55 -0700 (Sun, 06 Sep 2009)
Log Message:
-----------
Fixing some issues with Tcl initialize code and MacPorts 1.8

Modified Paths:
--------------
    branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m
    branches/gsoc09-gui/MacPorts_Framework/SimpleLog.m
    branches/gsoc09-gui/MacPorts_Framework/init.tcl
    branches/gsoc09-gui/MacPorts_Framework/interpInit.tcl
    branches/gsoc09-gui/MacPorts_Framework/portProcessInit.tcl

Modified: branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m	2009-09-07 04:53:37 UTC (rev 57186)
+++ branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m	2009-09-07 05:30:55 UTC (rev 57187)
@@ -26,18 +26,16 @@
 - (oneway void)evaluateString:(bycopy id)statement {
     // TODO Handle the posible errors and notifications
     int retCode = Tcl_Eval(interpreter, [statement UTF8String]);
-//   	OSStatus retval = noErr;
-//	if(  retCode == TCL_ERROR ) {
-//		//Do some error handling
-//		retval = coreFoundationUnknownErr;
-//	}
-//	else {
-//		retval = noErr;
-//	}
-//    NSLog(@"%i", retCode);
-    const char *result = Tcl_GetStringResult(interpreter);
-    NSLog(@"- %s - %i", result, retCode);
+    if (retCode != TCL_OK) {
+        Tcl_Obj * interpObj = Tcl_GetObjResult(interpreter);
+        int length, errCode;
+        NSString * errString = [NSString stringWithUTF8String:Tcl_GetStringFromObj(interpObj, &length)];
+        errCode = Tcl_GetErrno();
     
+        NSLog(@"- %@ - %i", errString, errCode);
+        exit(errCode);
+    }
+    
     exit(retCode);
 }
 

Modified: branches/gsoc09-gui/MacPorts_Framework/SimpleLog.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/SimpleLog.m	2009-09-07 04:53:37 UTC (rev 57186)
+++ branches/gsoc09-gui/MacPorts_Framework/SimpleLog.m	2009-09-07 05:30:55 UTC (rev 57187)
@@ -12,38 +12,26 @@
 #define MPSEPARATOR @"_&MP&_"
 
 int SimpleLog_Command(ClientData clientData, Tcl_Interp *interpreter, int objc, Tcl_Obj *CONST objv[]) {
-//    int returnCode = TCL_OK;
-    
-//    NSArray *msgType = [[NSString stringWithUTF8String:Tcl_GetString(*(++objv))] componentsSeparatedByString:@" "];
-//    NSString *msg = [NSString stringWithUTF8String:Tcl_GetString(*(++objv))];
-//    
-//    NSLog(@"%@ : %@",[msgType objectAtIndex:0], msg);
-    
-    //[[NSDistributedNotificationCenter defaultCenter] postNotificationName:[msgType objectAtIndex:0] object:msg];
-    //[[NSDistributedNotificationCenter defaultCenter] postNotificationName: object:msg];
-    
-//    NSLog(@"SIIIIIIIIIIIIIIIIIIIIIIIIII");
-//    
-    int returnCode = TCL_ERROR;
+    int tclResult = TCL_ERROR;
 	NSMutableString * data;
 	
 	++objv, --objc;
 	
 	if (objc) {
 		int tclCount;
-		int tclResult;
 		const char **tclElements;
 		
-		
 		tclResult = Tcl_SplitList(interpreter, Tcl_GetString(*objv), &tclCount, &tclElements);
 		
 		
 		if (tclResult == TCL_OK) {
 			if (tclCount > 0) {
+                NSLog([NSString stringWithUTF8String:tclElements[0]]);
 				data = [NSMutableString stringWithUTF8String:tclElements[0]];
 				[data appendString:MPSEPARATOR];
 				
 				if(tclCount > 1 && tclElements[1]) {
+                    NSLog([NSString stringWithUTF8String:tclElements[1]]);
 					[data appendString:[NSString stringWithUTF8String:tclElements[1]]];
 					[data appendString:MPSEPARATOR];
 				}
@@ -53,6 +41,7 @@
 				}
 				
 				if(tclCount > 2 && tclElements[2]) {
+                    NSLog([NSString stringWithUTF8String:tclElements[2]]);
 					[data appendString:[NSString stringWithUTF8String:tclElements[2]]];
 					[data appendString:MPSEPARATOR];
 				}
@@ -77,11 +66,11 @@
     }
     
     id theProxy = [NSConnection
-                rootProxyForConnectionWithRegisteredName:@"MPNotifications"
-                host:nil];
+                   rootProxyForConnectionWithRegisteredName:@"MPNotifications"
+                   host:nil];
     [theProxy sendIPCNotification:data];
     
     NSLog(@"-----%@", data);
     
-	return returnCode;
+	return tclResult;
 }
\ No newline at end of file

Modified: branches/gsoc09-gui/MacPorts_Framework/init.tcl
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/init.tcl	2009-09-07 04:53:37 UTC (rev 57186)
+++ branches/gsoc09-gui/MacPorts_Framework/init.tcl	2009-09-07 05:30:55 UTC (rev 57187)
@@ -4,7 +4,7 @@
 
 #Set ui_options to log all messages to stdout and notify system
 #filtering is done on the Obj-C side of things
-set ui_options(ports_debug) "yes"
+# set ui_options(ports_debug) "yes"
 set ui_options(ports_verbose) "yes"
 
 # ui_options accessor
@@ -51,15 +51,15 @@
                 return {stdout}
             } else {
                 return {}
-			}
-		}
+            }
+        }
         msg {
             if {[ui_isset ports_quiet]} {
-                return {}
-			} else {
-				return {stdout}
-			}
-		}
+              return {}
+            } else {
+              return {stdout}
+            }
+        }
         error {
         	return {stderr}
         }
@@ -76,83 +76,82 @@
 #Redefine ui_$pritority to throw global notifications
 #This is currently under works ... a reasonable solution
 #should be coming up soon
-proc ui_init {priority prefix channels message} {
-	switch $priority {
-		msg {
-			set nottype "MPMsgNotification" 
-		}
-		debug {
-			set nottype "MPDebugNotification"
-			puts "Recieved Debug"
-		}
-		warn {
-			set nottype "MPWarnNotification"
-		}
-		error {
-			set nottype "MPErrorNotification"
-			puts "Recieved Error"
-		}
-		info {
-			set nottype "MPInfoNotification"
-			puts "Recieved Info"
-		}
-		default {
-			set nottype "MPDefaultNotification"
-		}	
-	}
-	
+proc macports::ui_init {priority args} {
+    switch $priority {
+  		msg {
+  			set nottype "MPMsgNotification" 
+  		}
+  		debug {
+  			set nottype "MPDebugNotification"
+  			puts "Recieved Debug"
+  		}
+  		warn {
+  			set nottype "MPWarnNotification"
+  		}
+  		error {
+  			set nottype "MPErrorNotification"
+  			puts "Recieved Error"
+  		}
+  		info {
+  			set nottype "MPInfoNotification"
+  			puts "Recieved Info"
+  		}
+  		default {
+  			set nottype "MPDefaultNotification"
+  		}	
+  	}
+  
     # Get the list of channels.
-    try {
+    if {[llength [info commands ui_channels]] > 0} {
         set channels [ui_channels $priority]
-    } catch * {
+    } else {
         set channels [ui_channels_default $priority]
     }
-    
-    #set channels [ui_channels $priority]
-    
+
     # Simplify ui_$priority.
     set nbchans [llength $channels]
     if {$nbchans == 0} {
-        proc ::ui_$priority {str} [subst {
-        	notifications send $nottype "$chan $prefix" "\$str"
+        proc ::ui_$priority {args} [subst {
+          notifications send $nottype "$chan $prefix" "\$str"
         }]
     } else {
-        try {
+        if {[llength [info commands ui_prefix]] > 0} {
             set prefix [ui_prefix $priority]
-        } catch * {
+        } else {
             set prefix [ui_prefix_default $priority]
         }
-        
-        #set prefix [ui_prefix $priority]
-        
-        if {$nbchans == 1} {
-          set chan [lindex $channels 0]
 
-          proc ::ui_$priority {args} [subst {
-            if {\[lindex \$args 0\] == "-nonewline"} {
-              puts $chan "$prefix\[lindex \$args 1\]"
-              notifications send $nottype "$chan $prefix" "\[lindex \$args 1\]"
+        if {[llength [info commands ::ui_init]] > 0} {
+            eval ::ui_init $priority $prefix $channels $args
+        } else {
+            if {$nbchans == 1} {
+                set chan [lindex $channels 0]
+                proc ::ui_$priority {args} [subst {
+                  if {\[lindex \$args 0\] == "-nonewline"} {
+                    puts $chan "$prefix\[lindex \$args 1\]"
+                    notifications send $nottype "$chan $prefix" "\[lindex \$args 1\]"
+                  } else {
+                    puts -nonewline $chan "$prefix\[lindex \$args 1\]"
+                    notifications send $nottype "$chan $prefix" "\[lindex \$args 0\]"
+                  }
+                }]
             } else {
-              puts -nonewline $chan "$prefix\[lindex \$args 1\]"
-              notifications send $nottype "$chan $prefix" "\[lindex \$args 0\]"
+                proc ::ui_$priority {args} [subst {
+                    foreach chan \$channels {
+                      if {\[lindex \$args 0\] == "-nonewline"} {
+                        puts $chan "$prefix\[lindex \$args 1\]"
+                        notifications send $nottype "$chan $prefix" "\[lindex \$args 1\]"
+                      } else {
+                        puts -nonewline $chan "$prefix\[lindex \$args 1\]"
+                        notifications send $nottype "$chan $prefix" "\[lindex \$args 0\]"
+                      }
+                    }
+                }]
             }
-          }]
-        } else {
-          proc ::ui_$priority {args} [subst {
-            foreach chan \$channels {
-              if {\[lindex \$args 0\] == "-nonewline"} {
-                puts $chan "$prefix\[lindex \$args 1\]"
-                notifications send $nottype "$chan $prefix" "\[lindex \$args 1\]"
-              } else {
-                puts -nonewline $chan "$prefix\[lindex \$args 1\]"
-                notifications send $nottype "$chan $prefix" "\[lindex \$args 0\]"
-              }
-            }
-          }]
         }
 
-    # Call ui_$priority - Is this step necessary? Consult with Randall
-    #::ui_$priority $message
+        # Call ui_$priority
+        eval ::ui_$priority $args
     }
 }
 

Modified: branches/gsoc09-gui/MacPorts_Framework/interpInit.tcl
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/interpInit.tcl	2009-09-07 04:53:37 UTC (rev 57186)
+++ branches/gsoc09-gui/MacPorts_Framework/interpInit.tcl	2009-09-07 05:30:55 UTC (rev 57187)
@@ -52,15 +52,15 @@
                 return {stdout}
             } else {
                 return {}
-			}
-		}
+            }
+        }
         msg {
             if {[ui_isset ports_quiet]} {
-                return {}
-			} else {
-				return {stdout}
-			}
-		}
+              return {}
+            } else {
+              return {stdout}
+            }
+        }
         error {
         	return {stderr}
         }
@@ -76,37 +76,35 @@
 #Redefine ui_$pritority to throw global notifications
 #This is currently under works ... a reasonable solution
 #should be coming up soon
-proc ui_init {priority prefix channels message} {
-	#puts "INSIDE ui_init priority with prefix $prefix and message $message"
-	
-	switch $priority {
-		msg {
-			set nottype "MPMsgNotification" 
-		}
-		debug {
-			set nottype "MPDebugNotification"
-			puts "Recieved Debug"
-		}
-		warn {
-			set nottype "MPWarnNotification"
-		}
-		error {
-			set nottype "MPErrorNotification"
-			puts "Recieved Error"
-		}
-		info {
-			set nottype "MPInfoNotification"
-			puts "Recieved Info"
-		}
-		default {
-			set nottype "MPDefaultNotification"
-		}	
-	}
-	
+proc macports::ui_init {priority args} {
+    switch $priority {
+      msg {
+        set nottype "MPMsgNotification" 
+      }
+      debug {
+        set nottype "MPDebugNotification"
+        puts "Recieved Debug"
+      }
+      warn {
+        set nottype "MPWarnNotification"
+      }
+      error {
+        set nottype "MPErrorNotification"
+        puts "Recieved Error"
+      }
+      info {
+        set nottype "MPInfoNotification"
+        puts "Recieved Info"
+      }
+      default {
+        set nottype "MPDefaultNotification"
+      }
+    }
+
     # Get the list of channels.
-    try {
+    if {[llength [info commands ui_channels]] > 0} {
         set channels [ui_channels $priority]
-    } catch * {
+    } else {
         set channels [ui_channels_default $priority]
     }
     
@@ -116,17 +114,18 @@
     set nbchans [llength $channels]
     if {$nbchans == 0} {
         proc ::ui_$priority {str} [subst {
-        	simplelog "$nottype $chan $prefix" "\$str" 
+          simplelog "$nottype $chan $prefix" "\$str" 
         }]
     } else {
-        try {
-            set prefix [ui_prefix $priority]
-        } catch * {
-            set prefix [ui_prefix_default $priority]
-        }
-        
-        #set prefix [ui_prefix $priority]
-        
+      if {[llength [info commands ui_prefix]] > 0} {
+          set prefix [ui_prefix $priority]
+      } else {
+          set prefix [ui_prefix_default $priority]
+      }
+
+      if {[llength [info commands ::ui_init]] > 0} {
+          eval ::ui_init $priority $prefix $channels $args
+      } else {
         if {$nbchans == 1} {
           set chan [lindex $channels 0]
 
@@ -152,9 +151,10 @@
             }
           }]
         }
+      }
 
-    # Call ui_$priority - Is this step necessary? Consult with Randall
-    #::ui_$priority $message
+      # Call ui_$priority
+      eval ::ui_$priority $args
     }
 }
 

Modified: branches/gsoc09-gui/MacPorts_Framework/portProcessInit.tcl
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/portProcessInit.tcl	2009-09-07 04:53:37 UTC (rev 57186)
+++ branches/gsoc09-gui/MacPorts_Framework/portProcessInit.tcl	2009-09-07 05:30:55 UTC (rev 57187)
@@ -76,85 +76,82 @@
 #Redefine ui_$pritority to throw global notifications
 #This is currently under works ... a reasonable solution
 #should be coming up soon
-proc ui_init {priority prefix channels message} {
-	#puts "INSIDE ui_init priority with prefix $prefix and message $message"
-	
-	switch $priority {
-		msg {
-			set nottype "MPMsgNotification" 
-		}
-		debug {
-			set nottype "MPDebugNotification"
-			puts "Recieved Debug"
-		}
-		warn {
-			set nottype "MPWarnNotification"
-		}
-		error {
-			set nottype "MPErrorNotification"
-			puts "Recieved Error"
-		}
-		info {
-			set nottype "MPInfoNotification"
-			puts "Recieved Info"
-		}
-		default {
-			set nottype "MPDefaultNotification"
-		}	
-	}
-	
+proc macports::ui_init {priority args} {
+    switch $priority {
+  		msg {
+  			set nottype "MPMsgNotification" 
+  		}
+  		debug {
+  			set nottype "MPDebugNotification"
+  			puts "Recieved Debug"
+  		}
+  		warn {
+  			set nottype "MPWarnNotification"
+  		}
+  		error {
+  			set nottype "MPErrorNotification"
+  			puts "Recieved Error"
+  		}
+  		info {
+  			set nottype "MPInfoNotification"
+  			puts "Recieved Info"
+  		}
+  		default {
+  			set nottype "MPDefaultNotification"
+  		}	
+  	}
+  
     # Get the list of channels.
-    try {
+    if {[llength [info commands ui_channels]] > 0} {
         set channels [ui_channels $priority]
-    } catch * {
+    } else {
         set channels [ui_channels_default $priority]
     }
-    
-    #set channels [ui_channels $priority]
-    
+
     # Simplify ui_$priority.
     set nbchans [llength $channels]
     if {$nbchans == 0} {
-        proc ::ui_$priority {str} [subst {
-        	simplelog "$nottype $chan $prefix" "\$str" 
+        proc ::ui_$priority {args} [subst {
+          simplelog "$nottype $chan $prefix" "\$str"
         }]
     } else {
-        try {
+        if {[llength [info commands ui_prefix]] > 0} {
             set prefix [ui_prefix $priority]
-        } catch * {
+        } else {
             set prefix [ui_prefix_default $priority]
         }
-        
-        #set prefix [ui_prefix $priority]
-        
-        if {$nbchans == 1} {
-          set chan [lindex $channels 0]
 
-          proc ::ui_$priority {args} [subst {
-            if {\[lindex \$args 0\] == "-nonewline"} {
-              #puts $chan "$prefix\[lindex \$args 1\]"
-              simplelog "$nottype $chan $prefix" "\[lindex \$args 1\]"
+        if {[llength [info commands ::ui_init]] > 0} {
+            eval ::ui_init $priority $prefix $channels $args
+        } else {
+            if {$nbchans == 1} {
+                set chan [lindex $channels 0]
+                proc ::ui_$priority {args} [subst {
+                  if {\[lindex \$args 0\] == "-nonewline"} {
+                    puts $chan "$prefix\[lindex \$args 1\]"
+                    simplelog "$nottype $chan $prefix" "\[lindex \$args 1\]"
+                  } else {
+                    puts -nonewline $chan "$prefix\[lindex \$args 1\]"
+                    simplelog "$nottype $chan $prefix" "\[lindex \$args 0\]"
+                  }
+                }]
             } else {
-              #puts -nonewline $chan "$prefix\[lindex \$args 1\]"
-              simplelog "$nottype $chan $prefix" "\[lindex \$args 0\]"
+                proc ::ui_$priority {args} [subst {
+                    foreach chan \$channels {
+                      if {\[lindex \$args 0\] == "-nonewline"} {
+                        puts $chan "$prefix\[lindex \$args 1\]"
+                        simplelog "$nottype $chan $prefix" "\[lindex \$args 1\]"
+                      } else {
+                        puts -nonewline $chan "$prefix\[lindex \$args 1\]"
+                        simplelog "$nottype $chan $prefix" "\[lindex \$args 0\]"
+                      }
+                    }
+                }]
             }
-          }]
-        } else {
-          proc ::ui_$priority {args} [subst {
-            foreach chan \$channels {
-              if {\[lindex \$args 0\] == "-nonewline"} {
-                #puts $chan "$prefix\[lindex \$args 1\]"
-                simplelog "$nottype $chan $prefix" "\[lindex \$args 1\]"
-              } else {
-                #puts -nonewline $chan "$prefix\[lindex \$args 1\]"
-                simplelog "$nottype $chan $prefix" "\[lindex \$args 0\]"
-              }
-            }
-          }]
         }
 
-    # Call ui_$priority - Is this step necessary? Consult with Randall
-    #::ui_$priority $message
+        # Call ui_$priority
+        eval ::ui_$priority $args
     }
 }
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090906/9d2aab4d/attachment.html>


More information about the macports-changes mailing list