Changeset 54272


Ignore:
Timestamp:
Jul 24, 2009, 7:27:37 AM (10 years ago)
Author:
juanger@…
Message:

Adding SimpleLog tcl extension.

Location:
branches/gsoc09-gui/MacPorts_Framework
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.h

    r53719 r54272  
    1414}
    1515
    16 - (oneway void)evaluateString:(bycopy id)statement;
     16
     17- (oneway void)evaluateString:(bycopy id)statement delegate:(byref id)newDelegate;
    1718
    1819@end
  • branches/gsoc09-gui/MacPorts_Framework/MPPortProcess.m

    r54152 r54272  
    1616@end
    1717
    18 
    1918@implementation MPPortProcess
    2019
     
    2928}
    3029
    31 - (oneway void)evaluateString:(bycopy id)statement {
     30- (oneway void)evaluateString:(bycopy id)statement delegate:(byref id)newDelegate {
    3231    // TODO Handle the posible errors and notifications
     32    delegate = newDelegate;
    3333    Tcl_Eval(interpreter, [statement UTF8String]);
    3434    exit(0);
    3535}
     36
    3637
    3738#pragma mark Private Methods
     
    5657        }
    5758    // Load notifications methods
    58     Tcl_CreateObjCommand(interpreter, "simplelog", Notify_Command, NULL, NULL);
     59    Tcl_CreateObjCommand(interpreter, "simplelog", SimpleLog_Command, NULL, NULL);
    5960        if (Tcl_PkgProvide(interpreter, "simplelog", "1.0") != TCL_OK) {
    6061                NSLog(@"Error in Tcl_PkgProvide: %s", Tcl_GetStringResult(interpreter));
  • branches/gsoc09-gui/MacPorts_Framework/MacPorts.Framework.xcodeproj/project.pbxproj

    r54152 r54272  
    2323/* Begin PBXBuildFile section */
    2424                218DEE2610162091003B5A3B /* SimpleLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 218DED83101612F1003B5A3B /* SimpleLog.m */; };
    25                 218DEE3E10162157003B5A3B /* SimpleLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 218DED82101612F1003B5A3B /* SimpleLog.h */; };
    2625                21D95442100940FF00DEF58A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EB6FC900E45DEA80057962C /* Foundation.framework */; };
    2726                21D954431009411400DEF58A /* Tcl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6EA0F56E0DFEB55E00C15082 /* Tcl.framework */; };
     
    2928                21D954721009475200DEF58A /* portProcessInit.tcl in Resources */ = {isa = PBXBuildFile; fileRef = 21D954711009475200DEF58A /* portProcessInit.tcl */; };
    3029                21D9548C1009522100DEF58A /* MPPortProcess in Resources */ = {isa = PBXBuildFile; fileRef = 21D9543E100940EE00DEF58A /* MPPortProcess */; };
     30                21F6DD701017E38E00FC43DE /* SimpleLog.h in Headers */ = {isa = PBXBuildFile; fileRef = 218DED82101612F1003B5A3B /* SimpleLog.h */; };
    3131                481D04A20CDAAAFD00D4A550 /* MPMutableDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 481D04A00CDAAAFC00D4A550 /* MPMutableDictionary.h */; settings = {ATTRIBUTES = (Public, ); }; };
    3232                481D04A30CDAAAFD00D4A550 /* MPMutableDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 481D04A10CDAAAFD00D4A550 /* MPMutableDictionary.m */; };
     
    444444                        buildActionMask = 2147483647;
    445445                        files = (
    446                                 218DEE3E10162157003B5A3B /* SimpleLog.h in Headers */,
     446                                21F6DD701017E38E00FC43DE /* SimpleLog.h in Headers */,
    447447                        );
    448448                        runOnlyForDeploymentPostprocessing = 0;
  • branches/gsoc09-gui/MacPorts_Framework/SimpleLog.h

    r54152 r54272  
    1212id delegate;
    1313
    14 int Notify_Command(ClientData clientData, Tcl_Interp *interpreter, int objc, Tcl_Obj *CONST objv[]);
     14int SimpleLog_Command(ClientData clientData, Tcl_Interp *interpreter, int objc, Tcl_Obj *CONST objv[]);
  • branches/gsoc09-gui/MacPorts_Framework/SimpleLog.m

    r54152 r54272  
    1010#include "SimpleLog.h"
    1111
     12#define MPSEPARATOR @"_&MP&_"
     13
    1214@interface NSObject (SimpleLogDelegate)
    1315-(void)processDidBeginRunning;
     
    1517@end
    1618
    17 int Notify_Command(ClientData clientData, Tcl_Interp *interpreter, int objc, Tcl_Obj *CONST objv[]){
    18     int returnCode = TCL_ERROR;
    19        
    20     //NSLog();
     19int SimpleLog_Command(ClientData clientData, Tcl_Interp *interpreter, int objc, Tcl_Obj *CONST objv[]){
     20    int returnCode = TCL_OK;
    2121   
    22     if(delegate && [delegate respondsToSelector:@selector(reactToNotification)]) {
    23         // send messages to delegate
    24         [delegate processDidBeginRunning];
    25     }
     22    NSArray *msgType = [[NSString stringWithUTF8String:Tcl_GetString(*(++objv))] componentsSeparatedByString:@" "];
     23    NSString *msg = [NSString stringWithUTF8String:Tcl_GetString(*(++objv))];
     24   
     25    [delegate doSomething];
     26   
     27    NSLog(@"%@ : %@",[msgType objectAtIndex:0], msg);
    2628   
    2729        return returnCode;
  • branches/gsoc09-gui/MacPorts_Framework/portProcessInit.tcl

    r54152 r54272  
    11package require macports
    2 package require simplelog #Require My new notifications extension
     2package require simplelog
     3
     4
    35
    46#Set ui_options to log all messages to stdout and notify system
     
    7779proc ui_init {priority prefix channels message} {
    7880        #puts "INSIDE ui_init priority with prefix $prefix and message $message"
     81       
     82        switch $priority {
     83                msg {
     84                        set nottype "MPMsgNotification"
     85                }
     86                debug {
     87                        set "MPDebugNotification"
     88                        puts "Recieved Debug"
     89                }
     90                warn {
     91                        set nottype "MPWarnNotification"
     92                }
     93                error {
     94                        set nottype "MPErrorNotification"
     95                        puts "Recieved Error"
     96                }
     97                info {
     98                        set nottype "MPInfoNotification"
     99                        puts "Recieved Info"
     100                }
     101                default {
     102                        set nottype "MPDefaultNotification"
     103                }       
     104        }
    79105       
    80106    # Get the list of channels.
     
    107133          proc ::ui_$priority {args} [subst {
    108134            if {\[lindex \$args 0\] == "-nonewline"} {
    109               puts $chan "$prefix\[lindex \$args 1\]"
     135              #puts $chan "$prefix\[lindex \$args 1\]"
    110136              simplelog "$nottype $chan $prefix" "\[lindex \$args 1\]"
    111137            } else {
    112               puts -nonewline $chan "$prefix\[lindex \$args 1\]"
     138              #puts -nonewline $chan "$prefix\[lindex \$args 1\]"
    113139              simplelog "$nottype $chan $prefix" "\[lindex \$args 0\]"
    114140            }
     
    118144            foreach chan \$channels {
    119145              if {\[lindex \$args 0\] == "-nonewline"} {
    120                 puts $chan "$prefix\[lindex \$args 1\]"
     146                #puts $chan "$prefix\[lindex \$args 1\]"
    121147                simplelog "$nottype $chan $prefix" "\[lindex \$args 1\]"
    122148              } else {
    123                 puts -nonewline $chan "$prefix\[lindex \$args 1\]"
     149                #puts -nonewline $chan "$prefix\[lindex \$args 1\]"
    124150                simplelog "$nottype $chan $prefix" "\[lindex \$args 0\]"
    125151              }
     
    133159}
    134160
     161
    135162#Wrapping the following API routines to catch errors
    136163#and log error Information in a similar fashion to code
    137 #in macports.tcl.
    138 proc mportuninstall {portname {v ""} {optionslist ""}} {
    139         if {[catch {portuninstall::uninstall $portname $v $optionslist} result]} {
     164#in macports.tcl. Note optionslist is not being used for now
     165set mp_empty_list [list]
     166proc mportuninstall {portname {v ""} {optionslist ""} } {
     167        if {[catch {portuninstall::uninstall $portname $v [array get options]} result]} {
    140168               
    141169                        global errorInfo
     
    146174}
    147175
    148 proc mportactivate {portname v optionslist} {
     176proc mportactivate {portname {v ""} {optionslist ""}} {
    149177        if {[catch {portimage::activate $portname $v $optionslist} result]} {
    150178                       
     
    156184}
    157185
    158 proc mportdeactivate {portname v optionslist} {
     186proc mportdeactivate {portname {v ""} {optionslist ""} } {
    159187        if {[catch {portimage::deactivate $portname $v $optionslist} result]} {
    160188                       
     
    176204        }
    177205}
    178 
    179206
    180207# Initialize dport
Note: See TracChangeset for help on using the changeset viewer.