[54272] branches/gsoc09-gui/MacPorts_Framework
juanger at macports.org
juanger at macports.org
Fri Jul 24 00:27:37 PDT 2009
Revision: 54272
http://trac.macports.org/changeset/54272
Author: juanger at macports.org
Date: 2009-07-24 00:27:37 -0700 (Fri, 24 Jul 2009)
Log Message:
-----------
Adding SimpleLog tcl extension.
Modified Paths:
--------------
branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.h
branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m
branches/gsoc09-gui/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj
branches/gsoc09-gui/MacPorts_Framework/SimpleLog.h
branches/gsoc09-gui/MacPorts_Framework/SimpleLog.m
branches/gsoc09-gui/MacPorts_Framework/portProcessInit.tcl
Modified: branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.h
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.h 2009-07-24 07:22:31 UTC (rev 54271)
+++ branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.h 2009-07-24 07:27:37 UTC (rev 54272)
@@ -13,6 +13,7 @@
NSString *PKGPath;
}
-- (oneway void)evaluateString:(bycopy id)statement;
+- (oneway void)evaluateString:(bycopy id)statement delegate:(byref id)newDelegate;
+
@end
Modified: branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m 2009-07-24 07:22:31 UTC (rev 54271)
+++ branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m 2009-07-24 07:27:37 UTC (rev 54272)
@@ -15,7 +15,6 @@
@end
-
@implementation MPPortProcess
- (id)initWithPKGPath:(NSString*)pkgPath {
@@ -28,12 +27,14 @@
delegate = newDelegate;
}
-- (oneway void)evaluateString:(bycopy id)statement {
+- (oneway void)evaluateString:(bycopy id)statement delegate:(byref id)newDelegate {
// TODO Handle the posible errors and notifications
+ delegate = newDelegate;
Tcl_Eval(interpreter, [statement UTF8String]);
exit(0);
}
+
#pragma mark Private Methods
- (void)initializeInterpreter {
@@ -55,7 +56,7 @@
Tcl_DeleteInterp(interpreter);
}
// Load notifications methods
- Tcl_CreateObjCommand(interpreter, "simplelog", Notify_Command, NULL, NULL);
+ Tcl_CreateObjCommand(interpreter, "simplelog", SimpleLog_Command, NULL, NULL);
if (Tcl_PkgProvide(interpreter, "simplelog", "1.0") != TCL_OK) {
NSLog(@"Error in Tcl_PkgProvide: %s", Tcl_GetStringResult(interpreter));
}
Modified: branches/gsoc09-gui/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj 2009-07-24 07:22:31 UTC (rev 54271)
+++ branches/gsoc09-gui/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj 2009-07-24 07:27:37 UTC (rev 54272)
@@ -22,12 +22,12 @@
/* Begin PBXBuildFile section */
218DEE2610162091003B5A3B /* SimpleLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 218DED83101612F1003B5A3B /* SimpleLog.m */; };
- 218DEE3E10162157003B5A3B /* SimpleLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 218DED82101612F1003B5A3B /* SimpleLog.h */; };
21D95442100940FF00DEF58A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EB6FC900E45DEA80057962C /* Foundation.framework */; };
21D954431009411400DEF58A /* Tcl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EA0F56E0DFEB55E00C15082 /* Tcl.framework */; };
21D954471009412F00DEF58A /* MPPortProcess.m in Sources */ = {isa = PBXBuildFile; fileRef = 21D954461009412F00DEF58A /* MPPortProcess.m */; };
21D954721009475200DEF58A /* portProcessInit.tcl in Resources */ = {isa = PBXBuildFile; fileRef = 21D954711009475200DEF58A /* portProcessInit.tcl */; };
21D9548C1009522100DEF58A /* MPPortProcess in Resources */ = {isa = PBXBuildFile; fileRef = 21D9543E100940EE00DEF58A /* MPPortProcess */; };
+ 21F6DD701017E38E00FC43DE /* SimpleLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 218DED82101612F1003B5A3B /* SimpleLog.h */; };
481D04A20CDAAAFD00D4A550 /* MPMutableDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 481D04A00CDAAAFC00D4A550 /* MPMutableDictionary.h */; settings = {ATTRIBUTES = (Public, ); }; };
481D04A30CDAAAFD00D4A550 /* MPMutableDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 481D04A10CDAAAFD00D4A550 /* MPMutableDictionary.m */; };
4825ECC30CE6145B006B0385 /* MPRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 48F811BE0CE4636A009630DE /* MPRegistry.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -443,7 +443,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
- 218DEE3E10162157003B5A3B /* SimpleLog.h in Headers */,
+ 21F6DD701017E38E00FC43DE /* SimpleLog.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: branches/gsoc09-gui/MacPorts_Framework/SimpleLog.h
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/SimpleLog.h 2009-07-24 07:22:31 UTC (rev 54271)
+++ branches/gsoc09-gui/MacPorts_Framework/SimpleLog.h 2009-07-24 07:27:37 UTC (rev 54272)
@@ -11,4 +11,4 @@
id delegate;
-int Notify_Command(ClientData clientData, Tcl_Interp *interpreter, int objc, Tcl_Obj *CONST objv[]);
\ No newline at end of file
+int SimpleLog_Command(ClientData clientData, Tcl_Interp *interpreter, int objc, Tcl_Obj *CONST objv[]);
\ No newline at end of file
Modified: branches/gsoc09-gui/MacPorts_Framework/SimpleLog.m
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/SimpleLog.m 2009-07-24 07:22:31 UTC (rev 54271)
+++ branches/gsoc09-gui/MacPorts_Framework/SimpleLog.m 2009-07-24 07:27:37 UTC (rev 54272)
@@ -9,20 +9,22 @@
#include "SimpleLog.h"
+#define MPSEPARATOR @"_&MP&_"
+
@interface NSObject (SimpleLogDelegate)
-(void)processDidBeginRunning;
-(void)processDidEndRunning;
@end
-int Notify_Command(ClientData clientData, Tcl_Interp *interpreter, int objc, Tcl_Obj *CONST objv[]){
- int returnCode = TCL_ERROR;
-
- //NSLog();
+int SimpleLog_Command(ClientData clientData, Tcl_Interp *interpreter, int objc, Tcl_Obj *CONST objv[]){
+ int returnCode = TCL_OK;
- if(delegate && [delegate respondsToSelector:@selector(reactToNotification)]) {
- // send messages to delegate
- [delegate processDidBeginRunning];
- }
+ NSArray *msgType = [[NSString stringWithUTF8String:Tcl_GetString(*(++objv))] componentsSeparatedByString:@" "];
+ NSString *msg = [NSString stringWithUTF8String:Tcl_GetString(*(++objv))];
+ [delegate doSomething];
+
+ NSLog(@"%@ : %@",[msgType objectAtIndex:0], msg);
+
return returnCode;
}
\ No newline at end of file
Modified: branches/gsoc09-gui/MacPorts_Framework/portProcessInit.tcl
===================================================================
--- branches/gsoc09-gui/MacPorts_Framework/portProcessInit.tcl 2009-07-24 07:22:31 UTC (rev 54271)
+++ branches/gsoc09-gui/MacPorts_Framework/portProcessInit.tcl 2009-07-24 07:27:37 UTC (rev 54272)
@@ -1,6 +1,8 @@
package require macports
-package require simplelog #Require My new notifications extension
+package require simplelog
+
+
#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"
@@ -77,6 +79,30 @@
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 "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 {
set channels [ui_channels $priority]
@@ -106,10 +132,10 @@
proc ::ui_$priority {args} [subst {
if {\[lindex \$args 0\] == "-nonewline"} {
- puts $chan "$prefix\[lindex \$args 1\]"
+ #puts $chan "$prefix\[lindex \$args 1\]"
simplelog "$nottype $chan $prefix" "\[lindex \$args 1\]"
} else {
- puts -nonewline $chan "$prefix\[lindex \$args 1\]"
+ #puts -nonewline $chan "$prefix\[lindex \$args 1\]"
simplelog "$nottype $chan $prefix" "\[lindex \$args 0\]"
}
}]
@@ -117,10 +143,10 @@
proc ::ui_$priority {args} [subst {
foreach chan \$channels {
if {\[lindex \$args 0\] == "-nonewline"} {
- puts $chan "$prefix\[lindex \$args 1\]"
+ #puts $chan "$prefix\[lindex \$args 1\]"
simplelog "$nottype $chan $prefix" "\[lindex \$args 1\]"
} else {
- puts -nonewline $chan "$prefix\[lindex \$args 1\]"
+ #puts -nonewline $chan "$prefix\[lindex \$args 1\]"
simplelog "$nottype $chan $prefix" "\[lindex \$args 0\]"
}
}
@@ -132,11 +158,13 @@
}
}
+
#Wrapping the following API routines to catch errors
#and log error Information in a similar fashion to code
-#in macports.tcl.
-proc mportuninstall {portname {v ""} {optionslist ""}} {
- if {[catch {portuninstall::uninstall $portname $v $optionslist} result]} {
+#in macports.tcl. Note optionslist is not being used for now
+set mp_empty_list [list]
+proc mportuninstall {portname {v ""} {optionslist ""} } {
+ if {[catch {portuninstall::uninstall $portname $v [array get options]} result]} {
global errorInfo
ui_debug "$errorInfo"
@@ -145,7 +173,7 @@
}
}
-proc mportactivate {portname v optionslist} {
+proc mportactivate {portname {v ""} {optionslist ""}} {
if {[catch {portimage::activate $portname $v $optionslist} result]} {
global errorInfo
@@ -155,7 +183,7 @@
}
}
-proc mportdeactivate {portname v optionslist} {
+proc mportdeactivate {portname {v ""} {optionslist ""} } {
if {[catch {portimage::deactivate $portname $v $optionslist} result]} {
global errorInfo
@@ -176,7 +204,6 @@
}
}
-
# Initialize dport
# This must be done following parse of global options, as some options are
# evaluated by dportinit.
@@ -184,4 +211,4 @@
global errorInfo
puts "$errorInfo"
fatal "Failed to initialize ports system, $result"
-}
+}
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090724/cf30fc2d/attachment-0001.html>
More information about the macports-changes
mailing list