[37925] branches/gsoc08-framework/MacPorts.Framework
Revision: 37925 http://trac.macosforge.org/projects/macports/changeset/37925 Author: armahg@macports.org Date: 2008-06-29 13:45:37 -0700 (Sun, 29 Jun 2008) Log Message: ----------- Added more Documentation. Added Makefile for Tcl notifications package. Added MPNotificationsListener class. Modified Paths: -------------- branches/gsoc08-framework/MacPorts.Framework/MPInterpreter.h branches/gsoc08-framework/MacPorts.Framework/MPInterpreterTest.m branches/gsoc08-framework/MacPorts.Framework/MPMacPorts.h branches/gsoc08-framework/MacPorts.Framework/MPMacPorts.m branches/gsoc08-framework/MacPorts.Framework/MPMacPortsTest.h branches/gsoc08-framework/MacPorts.Framework/MPMacPortsTest.m branches/gsoc08-framework/MacPorts.Framework/MPMutableDictionary.h branches/gsoc08-framework/MacPorts.Framework/MPPort.h branches/gsoc08-framework/MacPorts.Framework/MPPort.m branches/gsoc08-framework/MacPorts.Framework/MPRegistry.h branches/gsoc08-framework/MacPorts.Framework/MacPorts.Framework.xcodeproj/project.pbxproj branches/gsoc08-framework/MacPorts.Framework/MacPorts.h branches/gsoc08-framework/MacPorts.Framework/init.tcl branches/gsoc08-framework/MacPorts.Framework/notifications.m Added Paths: ----------- branches/gsoc08-framework/MacPorts.Framework/MPNotificationsListener.h branches/gsoc08-framework/MacPorts.Framework/MPNotificationsListener.m branches/gsoc08-framework/MacPorts.Framework/Makefile Modified: branches/gsoc08-framework/MacPorts.Framework/MPInterpreter.h =================================================================== --- branches/gsoc08-framework/MacPorts.Framework/MPInterpreter.h 2008-06-29 19:45:49 UTC (rev 37924) +++ branches/gsoc08-framework/MacPorts.Framework/MPInterpreter.h 2008-06-29 20:45:37 UTC (rev 37925) @@ -45,7 +45,7 @@ #define MPPackage @"macports" #define MPPackageVersion @"1.0" -/* +/*! @class MPInterpreter @abstract Tcl interpreter object @discussion Contains a shared per-thread instance of a Tcl interpreter. The MPInterpreter class @@ -70,24 +70,24 @@ #pragma Utilities -/* +/*! @brief Returns the NSstring result of evaluating a Tcl expression @param statement An NSArray containing the Tcl expression */ - (NSString *)evaluateArrayAsString:(NSArray *)statement; -/* +/*! @brief Returns the NSString result of evaluating a Tcl expression @param statement An NSString containing the Tcl expression */ - (NSString *)evaluateStringAsString:(NSString *)statement; -/* +/*! @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 */ - (NSArray *)arrayFromTclListAsString:(NSString *)list; -/* +/*! @brief Returns an NSDictionary whose elements are the the elements of a Tcl list in the form of an NSString @discussion The returned NSDictionary is of the form {k1, v1, k2, v2, ...} with ki being the keys and vi the values in the dictionary. These keys and values are obtained from an NSString Tcl list of the @@ -95,19 +95,19 @@ @param list A Tcl list in the form of an NSString */ - (NSDictionary *)dictionaryFromTclListAsString:(NSString *)list; -/* +/*! @brief Same as dictionaryFromTclListAsString method. Returns an NSMutableDictionary rather than NSDictionary. */ - (NSMutableDictionary *)mutableDictionaryFromTclListAsString:(NSString *)list; -/* +/*! @brief Returns an NSArray whose elements are the contents of a Tcl variable @param variable An NSString representation of a Tcl variable */ - (NSArray *)getVariableAsArray:(NSString *)variable; -/* +/*! @brief Returns an NSString representation of a Tcl variable @param variable An NSString representtion of a Tcl variable */ Modified: branches/gsoc08-framework/MacPorts.Framework/MPInterpreterTest.m =================================================================== --- branches/gsoc08-framework/MacPorts.Framework/MPInterpreterTest.m 2008-06-29 19:45:49 UTC (rev 37924) +++ branches/gsoc08-framework/MacPorts.Framework/MPInterpreterTest.m 2008-06-29 20:45:37 UTC (rev 37925) @@ -61,13 +61,13 @@ /* Having trouble coming up with test cases for the methods below. Speak to Randall about that. - */ + * - (void)testMutableDictionaryFromTclListAsString { } - (void)testEvaluateStringAsString { } +*/ - @end Modified: branches/gsoc08-framework/MacPorts.Framework/MPMacPorts.h =================================================================== --- branches/gsoc08-framework/MacPorts.Framework/MPMacPorts.h 2008-06-29 19:45:49 UTC (rev 37924) +++ branches/gsoc08-framework/MacPorts.Framework/MPMacPorts.h 2008-06-29 20:45:37 UTC (rev 37925) @@ -33,6 +33,11 @@ * POSSIBILITY OF SUCH DAMAGE. */ +/*! + @header + MPMacPorts represents an installation of the MacPorts on a user's system. A user can have + multiple MacPorts installations in different locations. + */ #import <Cocoa/Cocoa.h> #import "MPInterpreter.h" @@ -125,6 +130,29 @@ */ - (void)exec:(MPPort *)port withTarget:(NSString *)target; +/*Convenience methods based on the exec: withTarget: method + I DON'T KNOW IF SOME OF OF THESE METHODS REQUIRE EXTRA ARGUMENTS + CHECK THAT WITH RANDALL + */ +-(void)configure:(MPPort *)port; +-(void)build:(MPPort *)port; +-(void)test:(MPPort *)port; +-(void)destroot:(MPPort *)port; +-(void)install:(MPPort *)port; +-(void)archive:(MPPort *)port; +-(void)createDmg:(MPPort *)port; +-(void)createMdmg:(MPPort *)port; +-(void)createPkg:(MPPort *)port; +-(void)createMpkg:(MPPort *)port; +-(void)createRpm:(MPPort *)port; +-(void)createDpkg:(MPPort *)port; +-(void)createSrpm:(MPPort *)port; + + + + + + /*! @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-06-29 19:45:49 UTC (rev 37924) +++ branches/gsoc08-framework/MacPorts.Framework/MPMacPorts.m 2008-06-29 20:45:37 UTC (rev 37925) @@ -137,7 +137,48 @@ - (void)exec:(MPPort *)port withTarget:(NSString *)target { return [port exec:target]; } +-(void)configure:(MPPort *)port { + [port configure]; +} +-(void)build:(MPPort *)port { + [port build]; +} +-(void)test:(MPPort *)port { + [port test]; +} +-(void)destroot:(MPPort *)port { + [port destroot]; +} +-(void)install:(MPPort *)port { + [port install]; +} +-(void)archive:(MPPort *)port { + [port archive]; +} +-(void)createDmg:(MPPort *)port { + [port createDmg]; +} +-(void)createMdmg:(MPPort *)port { + [port createMdmg]; +} +-(void)createPkg:(MPPort *)port { + [port createPkg]; +} +-(void)createMpkg:(MPPort *)port { + [port createMpkg]; +} +-(void)createRpm:(MPPort *)port { + [port createRpm]; +} +-(void)createDpkg:(MPPort *)port { + [port createDpkg]; +} +-(void)createSrpm:(MPPort *)port { + [port createSrpm]; +} + + #pragma settings - (NSString *)prefix { Modified: branches/gsoc08-framework/MacPorts.Framework/MPMacPortsTest.h =================================================================== --- branches/gsoc08-framework/MacPorts.Framework/MPMacPortsTest.h 2008-06-29 19:45:49 UTC (rev 37924) +++ branches/gsoc08-framework/MacPorts.Framework/MPMacPortsTest.h 2008-06-29 20:45:37 UTC (rev 37925) @@ -35,10 +35,24 @@ #import <SenTestingKit/SenTestingKit.h> #import "MPMacPorts.h" +#import "MPNotificationsListener.h" @interface MPMacPortsTest : SenTestCase { MPMacPorts *testPort; + + //Create a Notifications Listener run tests then destroy it afterwards + MPNotificationsListener *testListener; } +-(void) listenForPortSync; +-(void) actOnPortSync:(NSNotification *)notificiation; +-(void) testPortCreation; +-(void) testPrefix; +-(void) testSources; +-(void) testPathToPortIndex; +//-(void) testDepends; +-(void) testSearch; +-(void) testSync; +-(void) testVersion; @end Modified: branches/gsoc08-framework/MacPorts.Framework/MPMacPortsTest.m =================================================================== --- branches/gsoc08-framework/MacPorts.Framework/MPMacPortsTest.m 2008-06-29 19:45:49 UTC (rev 37924) +++ branches/gsoc08-framework/MacPorts.Framework/MPMacPortsTest.m 2008-06-29 20:45:37 UTC (rev 37925) @@ -1,21 +1,51 @@ -// -// MPMacPortsTest.m -// MacPorts.Framework -// -// Created by George Armah on 6/2/08. -// Copyright 2008 __MyCompanyName__. All rights reserved. -// +/* + * $Id:$ + * MacPorts.Framework + * + * Authors: + * George Armah <armahg@macports.org> + * + * Copyright (c) 2008 George Armah <armahg@macports.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright owner nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ #import "MPMacPortsTest.h" @implementation MPMacPortsTest - (void) setUp { - testPort = [[MPMacPorts alloc] init]; + testPort = [MPMacPorts sharedInstance]; + testListener = [[MPNotificationsListener alloc] init]; + [self listenForPortSync]; } - (void) tearDown { [testPort release]; + [testListener release]; } @@ -26,9 +56,61 @@ - (void) testPrefix { NSString *prefix = [testPort prefix]; - STAssertNil(prefix, @" %@ should not be nil", prefix); - [prefix release]; + //Find out why prefix returns nil + STAssertNotNil(prefix, @" %@ should not be nil", prefix); } - + +-(void) testSources{ + NSArray *sourcesArray = [testPort sources]; + STAssertNotNil(sourcesArray, @"Sources array should not be nil"); + //NSLog(@"STUFF IS %@, %d",[sourcesArray objectAtIndex:0], [sourcesArray count]); +} + +//Ask Randall about what exactly port tree path is +-(void) testPathToPortIndex { + NSURL *pindex = [testPort pathToPortIndex:@"file:///Users/Armahg/macportsbuild/build1/"]; + //NSLog(@"%@ MORE STUFF IS!", [pindex path]); + STAssertNotNil(pindex, @"URL for port index should not be nil"); +} + +-(void) testSearch { + NSDictionary *searchResults = [testPort search:@"Notification"]; + STAssertNotNil(searchResults, @"This dictionary should have at least %d key value pairs", [searchResults count]); +} + +-(void) testSync { + //The only way to test this that I know of is to listen for the posted notifications + //and take actions as appropriate + [testPort sync]; + +} + + +-(void) listenForPortSync { + [[NSDistributedNotificationCenter defaultCenter] addObserver:self + selector:@selector(actOnPortSync:) + name:@"MacPortsSyncStarted" + object:nil]; + + [[NSDistributedNotificationCenter defaultCenter] addObserver:self + selector:@selector(actOnPortSync:) + name:@"MacPortsSyncFinished" + object:nil]; +} + +-(void) actOnPortSync:(NSNotification *)notification { + if ([[notification name] isEqualToString:@"MacPortsSyncStarted"]) + NSLog(@"MacPortsSyncStarted"); + else + NSLog(@"MacPortsSyncFinished"); + NSLog(@"I WAZ HERE"); +} + + +-(void) testVersion { + NSString * version = [testPort version]; + STAssertNotNil(version, @"%@ should not be nil", version); +} + @end Modified: branches/gsoc08-framework/MacPorts.Framework/MPMutableDictionary.h =================================================================== --- branches/gsoc08-framework/MacPorts.Framework/MPMutableDictionary.h 2008-06-29 19:45:49 UTC (rev 37924) +++ branches/gsoc08-framework/MacPorts.Framework/MPMutableDictionary.h 2008-06-29 20:45:37 UTC (rev 37925) @@ -8,6 +8,17 @@ #import <Cocoa/Cocoa.h> +/*! + @class MPMutableDictionary + @abstract A subclass of NSMutableDictionary that is the base of most MacPort API objects + @discussion The dictionary data structure is appropriate for representing various aspects + of the MacPorts system such as port objects, receipt objects etc. Clients of this framework + can treat subclasses of MPMutableDictionary objects as NSMutableDictionaries which can + be useful for some GUI programming tasks like displaying information in a table. In order + to properly subclass an NSMutableDictionary, this class also contains an internal NSMutableDictionary + object. See http://www.smackie.org/Notes/2007/07/11/subclassing-nsmutabledictionary/ for some more + information on subclassing NSMutableDictionary. + */ @interface MPMutableDictionary : NSMutableDictionary { @@ -15,18 +26,71 @@ } +/*! + @brief Calls [initWithCapacity:15] + */ - (id)init; +/*! + @brief Initializes this object with a specified number of key, value pairs. + @param numItems The initial size of this MPMutableDictionary object. + */ - (id)initWithCapacity:(unsigned)numItems; +/*! + @brief Returns the size of this mutable dictionary + */ - (unsigned)count; + +/*! + @brief Returns an NSEnumerator object for accessing keys in the mutable dictionary + */ - (NSEnumerator *)keyEnumerator; + +/*! + @brief Returns the object associated with a given key + @param aKey The key for which to return the corresponding object + */ - (id)objectForKey:(id)aKey; + +/*! + @brief Removes a given key and its associated object from the mutable dictionary + @param aKey The key to be removed + */ - (void)removeObjectForKey:(id)aKey; +/*! + @brief Adds a given key and its associated object to the mutable dictionary. + @param anObject The value for the key to be added. + @param aKey The key for the value to be added. + @discussion This class uses an embedded NSMutableDictionary for implementing these + primitive methods. Hence restrictions to setObject: forKey: for NSMutableDictionary + apply here also; for example, anObject cannot be nil. + */ - (void)setObject:(id)anObject forKey:(id)aKey; + +/*! + @brief Sets the contents of the mutable dictionary to entries in a given dictionary + @param otherDictionary A dictionary containing the new entries + */ - (void)setDictionary:(NSDictionary *)otherDictionary; + +/*! +@brief Returns an NSString representation of the contents of this mubtable dictioanry, formatted as a property list. + */ - (NSString *)description; +/* + @brief Returns an MPMutableDictionary class object for keyed unarchiving + @discussion This method has to be overriden to prevent the decoding of instances + of this class as NSMutableDictionary objects during unarchiving. See hyperlink + in class description notes for more information on this. + */ + (Class)classForKeyedUnarchiver; -- (Class)classForKeyedArchiver; +/* + @brief Returns an MPMutableDictioanry class object for keyed archiving + @discussion Implementing this method ensures that instances of this class are + archived as MPMutableDictionary objects rather than NSMutableDictionary objects. + See link in class description notes for more details. + */ + - (Class)classForKeyedArchiver; @end Added: branches/gsoc08-framework/MacPorts.Framework/MPNotificationsListener.h =================================================================== --- branches/gsoc08-framework/MacPorts.Framework/MPNotificationsListener.h (rev 0) +++ branches/gsoc08-framework/MacPorts.Framework/MPNotificationsListener.h 2008-06-29 20:45:37 UTC (rev 37925) @@ -0,0 +1,54 @@ +/* + * $Id:$ + * MacPorts.Framework + * + * Authors: + * George Armah <armahg@macports.org> + * + * Copyright (c) 2008 George Armah <armahg@macports.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright owner nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#import <Cocoa/Cocoa.h> + +#define GLOBAL_MESSAGE @"Received global notification" +#define LOCAL_MESSAGE @"Received local notification" + +/*This class's main purpose is to test the implementation of + NSNotifications from within the MacPorts Tcl API + */ + +@interface MPNotificationsListener : NSObject { + +} + +-(void)registerForGlobalNotification; +-(void)registerForLocalNotification; +-(void)respondToGlobalNotification:(NSNotification*) notification; +-(void)respondToLocalNotification:(NSNotification *) notification; + +@end Property changes on: branches/gsoc08-framework/MacPorts.Framework/MPNotificationsListener.h ___________________________________________________________________ Name: svn:keywords + Id Name: svn:eol-style + native Added: branches/gsoc08-framework/MacPorts.Framework/MPNotificationsListener.m =================================================================== --- branches/gsoc08-framework/MacPorts.Framework/MPNotificationsListener.m (rev 0) +++ branches/gsoc08-framework/MacPorts.Framework/MPNotificationsListener.m 2008-06-29 20:45:37 UTC (rev 37925) @@ -0,0 +1,88 @@ +/* + * $Id:$ + * MacPorts.Framework + * + * Authors: + * George Armah <armahg@macports.org> + * + * Copyright (c) 2008 George Armah <armahg@macports.org> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the copyright owner nor the names of contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + + +#import "MPNotificationsListener.h" + + +@implementation MPNotificationsListener + +- (id)init { + self = [super init]; + if (self != nil) { + [self registerForLocalNotification]; + [self registerForGlobalNotification]; + } + return self; +} + +- (void)dealloc { + [super dealloc]; +} + +-(void) registerForLocalNotification { + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(respondToLocalNotification:) + name:@"testMacPortsNotification" + object:nil]; +} + +-(void) registerForGlobalNotification { + [[NSDistributedNotificationCenter defaultCenter] addObserver:self + selector:@selector(respondToGlobalNotification:) + name:@"testMacPortsNotification" + object:nil]; +} + +-(void) respondToLocalNotification:(NSNotification *)notification { + id sentObject = [notification object]; + + //Just NSLog it for now + if(sentObject == nil) + NSLog(@"%@", LOCAL_MESSAGE); + else + NSLog(@"%@" , NSStringFromClass([sentObject class])); +} + +-(void) respondToGlobalNotification:(NSNotification *)notification { + id sentObject = [notification object]; + + //Just NSLog it for now + if(sentObject == nil) + NSLog(@"%@", GLOBAL_MESSAGE); + else + NSLog(@"%@", NSStringFromClass([sentObject class])); +} +@end Property changes on: branches/gsoc08-framework/MacPorts.Framework/MPNotificationsListener.m ___________________________________________________________________ Name: svn:keywords + Id Name: svn:eol-style + native Modified: branches/gsoc08-framework/MacPorts.Framework/MPPort.h =================================================================== --- branches/gsoc08-framework/MacPorts.Framework/MPPort.h 2008-06-29 19:45:49 UTC (rev 37924) +++ branches/gsoc08-framework/MacPorts.Framework/MPPort.h 2008-06-29 20:45:37 UTC (rev 37925) @@ -33,6 +33,10 @@ * POSSIBILITY OF SUCH DAMAGE. */ +/*! + @header + The MPPort class is an object representation of a port + */ #import <Cocoa/Cocoa.h> #import "MPInterpreter.h" @@ -75,6 +79,7 @@ @param string The NSString object used to initialize this MPPort object @discussion The Tcl list is usually obtained from doing a search query for some particular port. + IS THIS METHOD JUST FOR INTERNAL USE? IT LOOKS LIKE IT ... ASK RANDALL ABOUT THAT */ - (id)initWithTclListAsString:(NSString *)string; @@ -89,9 +94,14 @@ - (NSString *)version; /*! - @brief Returns an array of the dependencies of this port - @discussion This includes, libraries, build dependencies and run time dependencies - ASK RANDALL FOR MORE DETAILS + @brief Returns an array of NSString port names of dependencies of this port + @discussion The MPPort object has internal dictionary lists of MPPort names for + the following dependency types: depend_libs, depend_run and depend_build. The + NSArray returned contains all of these dependencies in a single Array. + + ISN'T INFORMATION LOST BY JUST CREATING A SINGLE ARAY WITH ALL OF THESE DEPENDENCIES? + PERHAPS A DIFFERENT DATA STRUCTURE CAN BE USED THAT LETS US REMEMBER WHAT TYPE OF + DEPENDENCY EACH DEPENDENCY IS? */ - (NSArray *)depends; /*! @@ -101,15 +111,77 @@ */ - (void)exec:(NSString *)target; +/*Convenience methods based on the exec: withTarget: method + I DON'T KNOW IF SOME OF OF THESE METHODS REQUIRE EXTRA ARGUMENTS + CHECK THAT WITH RANDALL + */ /*! + @brief + */ +-(void)configure; +/*! + @brief + */ +-(void)build; +/*! + @brief + */ +-(void)test; +/*! + @brief + */ +-(void)destroot; +/*! + @brief + */ +-(void)install; +/*! + @brief + */ +-(void)archive; +/*! + @brief + */ +-(void)createDmg; +/*! + @brief + */ +-(void)createMdmg; +/*! + @brief + */ +-(void)createPkg; +/*! + @brief + */ +-(void)createMpkg; +/*! + @brief + */ +-(void)createRpm; +/*! + @brief + */ +-(void)createDpkg; +/*! + @brief + */ +-(void)createSrpm; + +/*! @brief Sets the attributes of this MPPort using the given string @param string An NSString object derived from a Tcl list containing this port's attributes - @discussion AGAIN I NEED TO EXPERIMENT WITH SOME MORE EXAMPLES + @discussion The Tcl list is obtained from the PortIndex which contains a list of serialized + Tcl key-value lists, one list per line. This list is then broken up into a dictionary of attributes + for the MPPort. */ - (void) setPortWithTclListAsString:(NSString *)string; /*! - @brief ASK RANDALL ABOUT THIS METHOD + @brief Adds the name of an MPPort to the list of this MPPort's dependencies + @param dependency The NSString name of the MPPort to be added + @discussion This MPPort object contains an internal list of port names for MPPorts which + it depends on. This list is returned by the depends method and is populated by this method. */ - (void) addDependencyAsPortName:(NSString *)dependency; @@ -119,10 +191,19 @@ MPPortStateOutdated, MPPortStateNotInstalled. */ - (void)setState:(int)state; +/*! + @brief Sets the state of this MPPort object from its receipts + @param receipts An NSArray of receipts for this port + @discussion + + AGAIN NEED TO ASK RANDALL ABOUT THIS METHOD. I THINK A PORT CAN HAVE MORE THAN ONE RECEIPT + THAT REPRESENT ITS VARIOUS VERSIONS / VARIANTS THAT HAVE BEEN INSTALLED SINCE EACH + INSTALLATION HAS ITS OWN RECEIPT. + */ + - (void)setStateFromReceipts:(NSArray *)receipts; -- (void)setStateFromReceipts:(NSArray *)receipts; + - (void)setDictionary:(NSDictionary *)otherDictionary; - + (Class)classForKeyedUnarchiver; - (Class)classForKeyedArchiver; Modified: branches/gsoc08-framework/MacPorts.Framework/MPPort.m =================================================================== --- branches/gsoc08-framework/MacPorts.Framework/MPPort.m 2008-06-29 19:45:49 UTC (rev 37924) +++ branches/gsoc08-framework/MacPorts.Framework/MPPort.m 2008-06-29 20:45:37 UTC (rev 37925) @@ -1,5 +1,5 @@ /* - * $Id:$ + * $Id$ * MacPorts.Framework * * Authors: @@ -155,6 +155,47 @@ nil]]; } +-(void)configure { + [self exec:@"configure"]; +} +-(void)build { + [self exec:@"build"]; +} +-(void)test { + [self exec:@"test"]; +} +-(void)destroot { + [self exec:@"destroot"]; +} +-(void)install { + [self exec:@"install"]; +} +-(void)archive { + [self exec:@"archive"]; +} +-(void)createDmg { + [self exec:@"dmg"]; +} +-(void)createMdmg { + [self exec:@"mdmg"]; +} +-(void)createPkg { + [self exec:@"pkg"]; +} +-(void)createMpkg { + [self exec:@"mpkg"]; +} +-(void)createRpm { + [self exec:@"rpm"]; +} +-(void)createDpkg { + [self exec:@"dpkg"]; +} +-(void)createSrpm { + [self exec:@"srpm"]; +} + + #pragma MPMutableDictionary Protocal - (id)objectForKey:(id)aKey { Modified: branches/gsoc08-framework/MacPorts.Framework/MPRegistry.h =================================================================== --- branches/gsoc08-framework/MacPorts.Framework/MPRegistry.h 2008-06-29 19:45:49 UTC (rev 37924) +++ branches/gsoc08-framework/MacPorts.Framework/MPRegistry.h 2008-06-29 20:45:37 UTC (rev 37925) @@ -47,7 +47,7 @@ /*! @class MPRegistry @abstract The registry of installed ports. - */ + */ @interface MPRegistry : NSObject { MPInterpreter *interpreter; Modified: branches/gsoc08-framework/MacPorts.Framework/MacPorts.Framework.xcodeproj/project.pbxproj =================================================================== --- branches/gsoc08-framework/MacPorts.Framework/MacPorts.Framework.xcodeproj/project.pbxproj 2008-06-29 19:45:49 UTC (rev 37924) +++ branches/gsoc08-framework/MacPorts.Framework/MacPorts.Framework.xcodeproj/project.pbxproj 2008-06-29 20:45:37 UTC (rev 37925) @@ -37,11 +37,12 @@ 48E992980C82C98C00219DDF /* Tcl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 48E992970C82C98C00219DDF /* Tcl.framework */; }; 48E993940C82CAAE00219DDF /* MPMacPorts.h in Headers */ = {isa = PBXBuildFile; fileRef = 48E993920C82CAAE00219DDF /* MPMacPorts.h */; settings = {ATTRIBUTES = (Public, ); }; }; 48E993950C82CAAE00219DDF /* MPMacPorts.m in Sources */ = {isa = PBXBuildFile; fileRef = 48E993930C82CAAE00219DDF /* MPMacPorts.m */; }; - 48E9939F0C82CEB000219DDF /* init.tcl in Resources */ = {isa = PBXBuildFile; fileRef = 48E9939E0C82CEB000219DDF /* init.tcl */; }; - 6E270BE10E1458DE00BAE687 /* init.tcl.original in Resources */ = {isa = PBXBuildFile; fileRef = 6E270BE00E1458DE00BAE687 /* init.tcl.original */; }; + 48E9939F0C82CEB000219DDF /* init.tcl.mod in Resources */ = {isa = PBXBuildFile; fileRef = 48E9939E0C82CEB000219DDF /* init.tcl.mod */; }; + 6E270BE10E1458DE00BAE687 /* init.tcl in Resources */ = {isa = PBXBuildFile; fileRef = 6E270BE00E1458DE00BAE687 /* init.tcl */; }; + 6E270D090E158CED00BAE687 /* MPNotificationsListener.h in Headers */ = {isa = PBXBuildFile; fileRef = 6E270D070E158CED00BAE687 /* MPNotificationsListener.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 6E270D0A0E158CED00BAE687 /* MPNotificationsListener.m in Sources */ = {isa = PBXBuildFile; fileRef = 6E270D080E158CED00BAE687 /* MPNotificationsListener.m */; }; 6E49F37B0DFFAB0B0030C3AF /* MPInterpreterTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 489DD92E0C94674B00595506 /* MPInterpreterTest.m */; }; 6E49F37F0DFFAFF80030C3AF /* MacPorts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8DC2EF5B0486A6940098B216 /* MacPorts.framework */; }; - 6EA293580E05C8FC00902D12 /* notifications.m in Sources */ = {isa = PBXBuildFile; fileRef = 6EA293570E05C8FC00902D12 /* notifications.m */; }; 6EA294590E080DEB00902D12 /* MPMacPortsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 6E88D1CB0DF4B90B00684E9F /* MPMacPortsTest.m */; }; 8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C1666FE841158C02AAC07 /* InfoPlist.strings */; }; 8DC2EF570486A6940098B216 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7B1FEA5585E11CA2CBB /* Cocoa.framework */; }; @@ -83,10 +84,13 @@ 48E992970C82C98C00219DDF /* Tcl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Tcl.framework; path = /System/Library/Frameworks/Tcl.framework; sourceTree = "<absolute>"; }; 48E993920C82CAAE00219DDF /* MPMacPorts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPMacPorts.h; sourceTree = "<group>"; }; 48E993930C82CAAE00219DDF /* MPMacPorts.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPMacPorts.m; sourceTree = "<group>"; }; - 48E9939E0C82CEB000219DDF /* init.tcl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = init.tcl; sourceTree = "<group>"; }; + 48E9939E0C82CEB000219DDF /* init.tcl.mod */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = init.tcl.mod; sourceTree = "<group>"; }; 48F811BE0CE4636A009630DE /* MPRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPRegistry.h; sourceTree = "<group>"; }; 48F811BF0CE4638C009630DE /* MPRegistry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPRegistry.m; sourceTree = "<group>"; }; - 6E270BE00E1458DE00BAE687 /* init.tcl.original */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = init.tcl.original; sourceTree = "<group>"; }; + 6E270BE00E1458DE00BAE687 /* init.tcl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = init.tcl; sourceTree = "<group>"; }; + 6E270C080E148F4E00BAE687 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; }; + 6E270D070E158CED00BAE687 /* MPNotificationsListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPNotificationsListener.h; sourceTree = "<group>"; }; + 6E270D080E158CED00BAE687 /* MPNotificationsListener.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPNotificationsListener.m; sourceTree = "<group>"; }; 6E88D1CA0DF4B90B00684E9F /* MPMacPortsTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPMacPortsTest.h; sourceTree = "<group>"; }; 6E88D1CB0DF4B90B00684E9F /* MPMacPortsTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPMacPortsTest.m; sourceTree = "<group>"; }; 6EA0F56E0DFEB55E00C15082 /* Tcl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Tcl.framework; path = System/Library/Frameworks/Tcl.framework; sourceTree = SDKROOT; }; @@ -154,12 +158,12 @@ 089C1665FE841158C02AAC07 /* Resources */ = { isa = PBXGroup; children = ( - 48E9939E0C82CEB000219DDF /* init.tcl */, + 48E9939E0C82CEB000219DDF /* init.tcl.mod */, 8DC2EF5A0486A6940098B216 /* Info.plist */, 089C1666FE841158C02AAC07 /* InfoPlist.strings */, 489DD8F50C94365F00595506 /* Test-Info.plist */, 6EAFD8B70DEC614E00E97270 /* dummycommit.test */, - 6E270BE00E1458DE00BAE687 /* init.tcl.original */, + 6E270BE00E1458DE00BAE687 /* init.tcl */, ); name = Resources; sourceTree = "<group>"; @@ -235,7 +239,10 @@ 6EA293540E05C8C600902D12 /* Tcl Notifications */ = { isa = PBXGroup; children = ( + 6E270C080E148F4E00BAE687 /* Makefile */, 6EA293570E05C8FC00902D12 /* notifications.m */, + 6E270D070E158CED00BAE687 /* MPNotificationsListener.h */, + 6E270D080E158CED00BAE687 /* MPNotificationsListener.m */, ); name = "Tcl Notifications "; sourceTree = "<group>"; @@ -255,6 +262,7 @@ 487679690C98C55E00577C59 /* MPPort.h in Headers */, 48A866AA0CD364F700B521BC /* MPReceipt.h in Headers */, 481D04A20CDAAAFD00D4A550 /* MPMutableDictionary.h in Headers */, + 6E270D090E158CED00BAE687 /* MPNotificationsListener.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -284,6 +292,7 @@ isa = PBXNativeTarget; buildConfigurationList = 1DEB91AD08733DA50010E9CD /* Build configuration list for PBXNativeTarget "MacPorts" */; buildPhases = ( + 6E270C870E14DF5C00BAE687 /* ShellScript */, 8DC2EF500486A6940098B216 /* Headers */, 8DC2EF520486A6940098B216 /* Resources */, 8DC2EF540486A6940098B216 /* Sources */, @@ -336,8 +345,8 @@ buildActionMask = 2147483647; files = ( 8DC2EF530486A6940098B216 /* InfoPlist.strings in Resources */, - 48E9939F0C82CEB000219DDF /* init.tcl in Resources */, - 6E270BE10E1458DE00BAE687 /* init.tcl.original in Resources */, + 48E9939F0C82CEB000219DDF /* init.tcl.mod in Resources */, + 6E270BE10E1458DE00BAE687 /* init.tcl in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -357,6 +366,19 @@ shellPath = /bin/sh; shellScript = "# Run the unit tests in this test bundle.\n\"${SYSTEM_DEVELOPER_DIR}/Tools/RunUnitTests\"\n"; }; + 6E270C870E14DF5C00BAE687 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "#sudo make install"; + }; 6E49F4F40E00DD520030C3AF /* ShellScript */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -406,7 +428,7 @@ 48A866AB0CD364F700B521BC /* MPReceipt.m in Sources */, 481D04A30CDAAAFD00D4A550 /* MPMutableDictionary.m in Sources */, 4825ECC40CE61468006B0385 /* MPRegistry.m in Sources */, - 6EA293580E05C8FC00902D12 /* notifications.m in Sources */, + 6E270D0A0E158CED00BAE687 /* MPNotificationsListener.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; Modified: branches/gsoc08-framework/MacPorts.Framework/MacPorts.h =================================================================== --- branches/gsoc08-framework/MacPorts.Framework/MacPorts.h 2008-06-29 19:45:49 UTC (rev 37924) +++ branches/gsoc08-framework/MacPorts.Framework/MacPorts.h 2008-06-29 20:45:37 UTC (rev 37925) @@ -1,5 +1,5 @@ /* - * $Id:$ + * $Id$ * MacPorts.Framework * * Authors: @@ -39,3 +39,6 @@ #import <MacPorts/MPPort.h>; #import <MacPorts/MPReceipt.h>; #import <MacPorts/MPRegistry.h>; + +//Including this file for testing the Notifications listener +#import <MacPorts/MPNotificationsListener.h>; Added: branches/gsoc08-framework/MacPorts.Framework/Makefile =================================================================== --- branches/gsoc08-framework/MacPorts.Framework/Makefile (rev 0) +++ branches/gsoc08-framework/MacPorts.Framework/Makefile 2008-06-29 20:45:37 UTC (rev 37925) @@ -0,0 +1,32 @@ +MKDIR = /bin/mkdir -p -m 0755 +RM = /bin/rm -f +RMDIR = /bin/rm -fr +INSTALL = /usr/bin/install -m 0644 +TCLSH = /usr/bin/tclsh + +DESTDIR = +PREFIX = /Library/Tcl/notifications1.0 + +OBJS = notifications.o +TARGET = notifications.dylib + +CC = gcc +CFLAGS = -Wall -DUSE_TCL_STUBS +FRAMEWORKS = -framework Cocoa -framework Tcl -ltclstub8.4 +LDFLAGS = -dynamiclib -install_name $(PREFIX)/$(TARGET) + +all: $(TARGET) + +$(TARGET): $(OBJS) + $(CC) $(LDFLAGS) $(FRAMEWORKS) $(OBJS) -o $@ + +clean: + $(RM) $(OBJS) $(TARGET) + +install: all + $(MKDIR) "$(DESTDIR)$(PREFIX)" + $(INSTALL) "$(TARGET)" "$(DESTDIR)$(PREFIX)" + echo pkg_mkIndex "$(DESTDIR)$(PREFIX)" | $(TCLSH) + +uninstall: + $(RMDIR) "$(DESTDIR)$(PREFIX)" Modified: branches/gsoc08-framework/MacPorts.Framework/init.tcl =================================================================== --- branches/gsoc08-framework/MacPorts.Framework/init.tcl 2008-06-29 19:45:49 UTC (rev 37924) +++ branches/gsoc08-framework/MacPorts.Framework/init.tcl 2008-06-29 20:45:37 UTC (rev 37925) @@ -1,13 +1,8 @@ -#catch {source \ -# [file join "/Library/Tcl" macports1.0 macports_fastload.tcl]} - -#Trying my own MacPorts build rather than default one on the system catch {source \ - [file join "/Users/Armahg/macportsbuild/build1/Library/Tcl" macports1.0 macports_fastload.tcl]} + [file join "/Library/Tcl" macports1.0 macports_fastload.tcl]} package require macports -package require notifications # ui_options accessor proc ui_isset {val} { @@ -72,64 +67,6 @@ } -#Modifying UI initialization to enable notifications -proc ui_init {priority prefix channels message} { - # Get the list of channels. - try { - set channels [ui_channels $priority] - } catch * { - set channels [ui_channels_default $priority] - } - - # Simplify ui_$priority. - set nbchans [llength $channels] - if {$nbchans == 0} { - proc ::ui_$priority {str} { - notifications send global testMacPortstNotification "$prefix\$str" - } - } else { - try { - set prefix [ui_prefix $priority] - } catch * { - set prefix [ui_prefix_default $priority] - } - - if {$nbchans == 1} { - set chan [lindex $channels 0] - - #Redefine ui_$priority here to also throw notifications of some sort - proc ::ui_$priority {str} { - #[subst { puts $chan "$prefix\$str" }] - subst { puts $chan "$prefix\$str" } - - #Send notifications using NSDistributedNotificationCenter for now - #We need a way to name notifications based on given input, using - #testMacPortsNotification for now - notifications send global testMacPortstNotification "$prefix\$str" - } - - - } else { - - - proc ::ui_$priority {str} { - subst { - foreach chan \$channels { - puts $chan "$prefix\$str" - } - } - #Should we discriminate based on channel? - notifications send global testMacPortsNotification "$prefix\$str" - } - } - - # Call ui_$priority - ::ui_$priority $message - } -} - - - # Initialize dport # This must be done following parse of global options, as some options are # evaluated by dportinit. @@ -137,4 +74,6 @@ global errorInfo puts "$errorInfo" fatal "Failed to initialize ports system, $result" -} \ No newline at end of file +} + + Modified: branches/gsoc08-framework/MacPorts.Framework/notifications.m =================================================================== --- branches/gsoc08-framework/MacPorts.Framework/notifications.m 2008-06-29 19:45:49 UTC (rev 37924) +++ branches/gsoc08-framework/MacPorts.Framework/notifications.m 2008-06-29 20:45:37 UTC (rev 37925) @@ -1,5 +1,5 @@ /* - * $Id:$ + * $Id$ * Authors: * Randall H. Wood <rhwood@macports.org> *
participants (1)
-
armahg@macports.org