Changes between Version 6 and Version 7 of MPFramworkGSocWk


Ignore:
Timestamp:
Jul 13, 2008, 9:48:41 PM (16 years ago)
Author:
armahg@…
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • MPFramworkGSocWk

    v6 v7  
    6161
    6262
     63= Weeks 6 & 7 =
     64So things took a somewhat different (and I think positive) turn these past
     65two weeks. I added some more routines for port activation, deactivation
     66and uninstallation to MPMacPorts class.
    6367
    6468
     69In addition Randall suggested the following method to be used for
     70evaluating strings as tcl commands instead of the original NSArray parsing
     71we were doing. This meant that code that originally looked like:
     72
     73{{{
     74-(NSURL *)pathToPortIndex:(NSString *)source {
     75   return [NSURL fileURLWithPath:
     76                 [interpreter evaluateArrayAsString:
     77                            [NSArray arrayWithObjects:
     78                               @"return [macports::getindex",
     79                               source,
     80                               @"]",
     81                               nil]]];
     82}
     83}}}
     84
     85to code that looked like:
     86
     87{{{
     88-(NSURL *)pathToPortIndex:(NSString *)source {
     89  return [NSURL fileURLWithPath:
     90           [interpreter evaluateStringAsString:
     91        [NSString stringWithFormat:@"return [macports::getindex %@ ]", source]]];
     92}
     93
     94}}}
     95
     96This definitely made for much more cleaner code. In fact it led to my writing a
     97generic function for evaluating a given Tcl command with an array of arguments.
     98Each element in this array can be either an NSString or NSArray for flexilbility.
     99Also, there's no limit to the size of the argument array. The method looks
     100like:
     101
     102{{{
     103- (void)execPortProc:(NSString *)procedure withParams:(NSArray *)params {
     104        //params can contain either NSStrings or NSArrays
     105        NSString * sparams = [NSString stringWithString:@" "];
     106        NSEnumerator * penums = [params objectEnumerator];
     107        MPInterpreter *interpreter = [MPInterpreter sharedInterpreter];
     108       
     109        id elem;
     110       
     111        while (elem = [penums nextObject]) {
     112                if ([elem isMemberOfClass:[NSString class]]) {
     113                        sparams = [sparams stringByAppendingString:elem];
     114                        sparams = [sparams stringByAppendingString:@" "];
     115                }
     116               
     117                else if ([elem isKindOfClass:[NSArray class]]) {
     118                        //Maybe I should be more careful in the above if statement and
     119                        //explicitly check for the classes i'm interested in?
     120                        sparams = [sparams stringByAppendingString:[elem componentsJoinedByString:@" "]];
     121                        sparams = [sparams stringByAppendingString:@" "];
     122                }
     123        }
     124       
     125        [interpreter evaluateStringAsString:
     126         [NSString stringWithFormat:@"[%@ %@]" , procedure, sparams]];
     127}
     128}}}
     129thanks Randall.
     130
     131Second thing worth mentioning I think I have found a solution to Notifications
     132in the framework. I won't give too many details but basically it involves
     133having a "bridge" singleton instance class between the Tcl API and Framework.
     134When a ui_$priority procedure is calls, it in turn calls a notifications procedure
     135which calls a method (and this can be any method) of the "bridge"
     136class. This method can be a notification, message to a Framework class, delegate
     137triggering method ... the important thing is the Framework is notified of the
     138change without having to do a system-wide broadcast (e.g. NSDistributedNotification
     139center notification). More details after this has been refined. The
     140current code for it has been checked into svn.
     141
     142Finally, I'll be releasing a MidTerm Evaluation version of the Framework today.
     143IT HAS NOT BEEN TESTED. The main purpose is for feedback on the current
     144functionality as is being advertised by the Docmentation. The main things it
     145is currently lacking are incorporation of Authorization, finished Notifications
     146and thorough Testing. Any and all feedback is welcome.
     147The .dmg and .zip files can be downloaded from svn by doing
     148
     149svn co http://svn.macosforge.org/repository/macports/users/armahg/MacPorts_Framework/MPFMidtermRelease.dmg for the dmg
     150
     151svn co http://svn.macosforge.org/repository/macports/users/armahg/MacPorts_Framework/MPFMidtermRelease.zip for the .zip file
     152
     153and svn co http://svn.macosforge.org/repository/macports/users/armahg/MacPorts_Framework/MPFMidtermRelease/ for the whole folder
    65154
    66155