[38525] branches/gsoc08-framework/MacPorts_Framework
armahg at macports.org
armahg at macports.org
Wed Jul 23 20:33:34 PDT 2008
Revision: 38525
http://trac.macosforge.org/projects/macports/changeset/38525
Author: armahg at macports.org
Date: 2008-07-23 20:33:34 -0700 (Wed, 23 Jul 2008)
Log Message:
-----------
Made changes to init and sharedInstance methods for MPMacPorts and MPInterpreter base on Bryan's suggestions. Removes code duplication and makes code cleaner
Modified Paths:
--------------
branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.h
branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m
branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.h
branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.m
Modified: branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.h
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.h 2008-07-23 23:14:32 UTC (rev 38524)
+++ branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.h 2008-07-24 03:33:34 UTC (rev 38525)
@@ -45,6 +45,7 @@
#define MPPackage @"macports"
#define MPPackageVersion @"1.0"
+#define MP_DEFAULT_PKG_PATH @"/Users/Armahg/macportsbuild/build1/Library/Tcl"
/*!
@class MPInterpreter
Modified: branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m 2008-07-23 23:14:32 UTC (rev 38524)
+++ branches/gsoc08-framework/MacPorts_Framework/MPInterpreter.m 2008-07-24 03:33:34 UTC (rev 38525)
@@ -140,12 +140,12 @@
#pragma mark -
#pragma mark MPInterpreter Code
-/*
+
- (id) init {
- return [self initWithPkgPath:@"/Users/Armahg/macportsbuild/build1/Library/Tcl"];
+ return [self initWithPkgPath:MP_DEFAULT_PKG_PATH];
}
-*/
+
- (id) initWithPkgPath:(NSString *)path {
if (self = [super init]) {
_interpreter = Tcl_CreateInterp();
@@ -183,12 +183,7 @@
+ (MPInterpreter*)sharedInterpreter {
- @synchronized(self) {
- if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"] == nil) {
- [[self alloc] initWithPkgPath:@"/Users/Armahg/macportsbuild/build1/Library/Tcl"]; // assignment not done here
- }
- }
- return [[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPInterpreter"];
+ return [self sharedInterpreterWithPkgPath:MP_DEFAULT_PKG_PATH];
}
+ (MPInterpreter*)sharedInterpreterWithPkgPath:(NSString *)path {
Modified: branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.h
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.h 2008-07-23 23:14:32 UTC (rev 38524)
+++ branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.h 2008-07-24 03:33:34 UTC (rev 38525)
@@ -47,6 +47,7 @@
#define MPPortsAll @".+"
+
/*!
@class MPMacPorts
@abstract Object representation of the MacPorts system
Modified: branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.m
===================================================================
--- branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.m 2008-07-23 23:14:32 UTC (rev 38524)
+++ branches/gsoc08-framework/MacPorts_Framework/MPMacPorts.m 2008-07-24 03:33:34 UTC (rev 38525)
@@ -39,16 +39,12 @@
@implementation MPMacPorts
-/*
+
- (id) init {
- if (self = [super init]) {
- interpreter = [MPInterpreter sharedInterpreter];
- [self registerForLocalNotifications];
- }
- return self;
+ return [self initWithPkgPath:MP_DEFAULT_PKG_PATH];
}
- */
+
- (id) initWithPkgPath:(NSString *)path {
if (self = [super init]) {
interpreter = [MPInterpreter sharedInterpreterWithPkgPath:path];
@@ -58,12 +54,7 @@
}
+ (MPMacPorts *)sharedInstance {
- @synchronized(self) {
- if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"] == nil) {
- [[self alloc] initWithPkgPath:@"/Users/Armahg/macportsbuild/build1/Library/Tcl"]; // assignment not done here
- }
- }
- return [[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPMacPorts"];
+ return [self sharedInstanceWithPkgPath:MP_DEFAULT_PKG_PATH];
}
+ (MPMacPorts *)sharedInstanceWithPkgPath:(NSString *)path {
@@ -192,7 +183,7 @@
#pragma settings
- (NSString *)prefix {
- if (prefix == Nil) {
+ if (prefix == NULL) {
prefix = [interpreter getVariableAsString:@"macports::prefix_frozen"];
}
return prefix;
@@ -206,7 +197,7 @@
}
- (NSArray *)sources {
- if (sources == Nil) {
+ if (sources == nil) {
sources = [interpreter getVariableAsArray:@"macports::sources"];
}
return sources;
@@ -221,7 +212,7 @@
- (NSString *)version {
- if (version == Nil) {
+ if (version == nil) {
version = [interpreter evaluateStringAsString:@"return [macports::version]"];
}
return version;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080723/b2856bb3/attachment.html
More information about the macports-changes
mailing list