[29865] users/rhwood/MacPorts.Framework

source_changes at macosforge.org source_changes at macosforge.org
Sat Oct 13 18:37:21 PDT 2007


Revision: 29865
          http://trac.macosforge.org/projects/macports/changeset/29865
Author:   rhwood at macports.org
Date:     2007-10-13 18:37:21 -0700 (Sat, 13 Oct 2007)

Log Message:
-----------
Add new class MPRegistery, which will, when complete, be a Cocoa wrapper for the MacPorts Tcl Registery class.

Modified Paths:
--------------
    users/rhwood/MacPorts.Framework/MacPorts.Framework.xcodeproj/project.pbxproj
    users/rhwood/MacPorts.Framework/MacPorts.h

Added Paths:
-----------
    users/rhwood/MacPorts.Framework/MPRegistery.h
    users/rhwood/MacPorts.Framework/MPRegistery.m

Added: users/rhwood/MacPorts.Framework/MPRegistery.h
===================================================================
--- users/rhwood/MacPorts.Framework/MPRegistery.h	                        (rev 0)
+++ users/rhwood/MacPorts.Framework/MPRegistery.h	2007-10-14 01:37:21 UTC (rev 29865)
@@ -0,0 +1,53 @@
+/*
+ *	$Id:$
+ *	MacPorts.Framework
+ *
+ *	Authors:
+ * 	Randall H. Wood <rhwood at macports.org>
+ *
+ *	Copyright (c) 2007 Randall H. Wood <rhwood at 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>
+#import "MPConstants.h"
+#import "MPInterpreter.h"
+#import "MPPort.h"
+
+ at interface MPRegistery : NSObject {
+
+	MPInterpreter *interpreter;
+
+}
+
++ (MPRegistery *)sharedRegistery;
+
+- (NSDictionary *)installed;
+- (NSDictionary *)installed:(MPPort *)port;
+- (NSDictionary *)installed:(NSString *)name withVersion:(NSString *)version;
+
+ at end

Added: users/rhwood/MacPorts.Framework/MPRegistery.m
===================================================================
--- users/rhwood/MacPorts.Framework/MPRegistery.m	                        (rev 0)
+++ users/rhwood/MacPorts.Framework/MPRegistery.m	2007-10-14 01:37:21 UTC (rev 29865)
@@ -0,0 +1,124 @@
+/*
+ *	$Id:$
+ *	MacPorts.Framework
+ *
+ *	Authors:
+ * 	Randall H. Wood <rhwood at macports.org>
+ *
+ *	Copyright (c) 2007 Randall H. Wood <rhwood at 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 "MPRegistery.h"
+
+
+ at implementation MPRegistery
+
+- (id) init {
+	if (self = [super init]) {
+		interpreter = [MPInterpreter sharedInterpreter];
+	}
+	return self;
+}
+
++ (MPRegistery *)sharedRegistery {
+	@synchronized(self) {
+		if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPRegistery"] == nil) {
+			[[self alloc] init]; // assignment not done here
+		}
+	}
+	return [[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPRegistery"];
+}
+
++ (id)allocWithZone:(NSZone*)zone {
+	@synchronized(self) {
+		if ([[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPRegistery"] == nil) {
+			[[[NSThread currentThread] threadDictionary] setObject:[super allocWithZone:zone] forKey:@"sharedMPRegistery"];
+			return [[[NSThread currentThread] threadDictionary] objectForKey:@"sharedMPRegistery"];	// assignment and return on first allocation
+		}
+	}
+	return nil;	// subsequent allocation attempts return nil
+}
+
+- (id)copyWithZone:(NSZone*)zone {
+    return self;
+}
+
+- (id)retain {
+    return self;
+}
+
+- (unsigned)retainCount {
+    return UINT_MAX;  //denotes an object that cannot be released
+}
+
+- (void)release {
+    //do nothing
+}
+
+- (id)autorelease {
+    return self;
+}
+
+- (NSDictionary *)installed {
+	return [self installed:@"" withVersion:@""];
+}
+
+- (NSDictionary *)installed:(MPPort *)port {
+	return [self installed:[port valueForKey:@"name"] withVersion:@""];
+}
+
+- (NSDictionary *)installed:(NSString *)name withVersion:(NSString *)version {
+	NSArray *raw;
+	NSDictionary *properties;
+	NSMutableDictionary *result;
+	NSEnumerator *rawEnumerator;
+	NSArray *versions;
+	id item;
+	raw = [interpreter arrayFromTclListAsString:[interpreter evaluateArrayAsString:[NSArray arrayWithObjects:
+		@"return [registry::installed",
+		name,
+		version,
+		@"]",
+		nil
+		]]];
+	result = [[NSMutableDictionary alloc] initWithCapacity:[raw count]];
+	rawEnumerator = [raw objectEnumerator];
+	while (item = [rawEnumerator nextObject]) {
+		versions = [interpreter arrayFromTclListAsString:item];
+		properties = [NSDictionary dictionaryWithObjects:
+			[versions objectsAtIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(1,[versions count] - 1)]] 
+												 forKeys:[NSArray arrayWithObjects:@"version", @"revision", @"variants", @"active", @"whatIsThis", nil]];
+		if ([result objectForKey:[versions objectAtIndex:0]]) {
+			[result setObject:[[result objectForKey:[versions objectAtIndex:0]] arrayByAddingObject:properties] forKey:[versions objectAtIndex:0]];
+		} else {
+			[result setObject:[NSArray arrayWithObject:properties] forKey:[versions objectAtIndex:0]];
+		}
+	}
+	return result;
+}
+ at end

Modified: users/rhwood/MacPorts.Framework/MacPorts.Framework.xcodeproj/project.pbxproj
===================================================================
--- users/rhwood/MacPorts.Framework/MacPorts.Framework.xcodeproj/project.pbxproj	2007-10-14 01:34:06 UTC (rev 29864)
+++ users/rhwood/MacPorts.Framework/MacPorts.Framework.xcodeproj/project.pbxproj	2007-10-14 01:37:21 UTC (rev 29865)
@@ -11,6 +11,8 @@
 		487679560C98C2EB00577C59 /* MPIndex.m in Sources */ = {isa = PBXBuildFile; fileRef = 487679540C98C2EB00577C59 /* MPIndex.m */; };
 		487679690C98C55E00577C59 /* MPPort.h in Headers */ = {isa = PBXBuildFile; fileRef = 487679670C98C55E00577C59 /* MPPort.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		4876796A0C98C55E00577C59 /* MPPort.m in Sources */ = {isa = PBXBuildFile; fileRef = 487679680C98C55E00577C59 /* MPPort.m */; };
+		4881825A0CC04EB300489B37 /* MPRegistery.h in Headers */ = {isa = PBXBuildFile; fileRef = 488182580CC04EB300489B37 /* MPRegistery.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		4881825B0CC04EB300489B37 /* MPRegistery.m in Sources */ = {isa = PBXBuildFile; fileRef = 488182590CC04EB300489B37 /* MPRegistery.m */; };
 		48906AFD0C4230B700A3ED8A /* MPInterpreter.h in Headers */ = {isa = PBXBuildFile; fileRef = 48906AFB0C4230B700A3ED8A /* MPInterpreter.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		48906AFE0C4230B700A3ED8A /* MPInterpreter.m in Sources */ = {isa = PBXBuildFile; fileRef = 48906AFC0C4230B700A3ED8A /* MPInterpreter.m */; };
 		48906B100C42364200A3ED8A /* MPConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 48906B0F0C42364200A3ED8A /* MPConstants.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -43,6 +45,8 @@
 		487679540C98C2EB00577C59 /* MPIndex.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPIndex.m; sourceTree = "<group>"; };
 		487679670C98C55E00577C59 /* MPPort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPort.h; sourceTree = "<group>"; };
 		487679680C98C55E00577C59 /* MPPort.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPort.m; sourceTree = "<group>"; };
+		488182580CC04EB300489B37 /* MPRegistery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPRegistery.h; sourceTree = "<group>"; };
+		488182590CC04EB300489B37 /* MPRegistery.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPRegistery.m; sourceTree = "<group>"; };
 		48906AFB0C4230B700A3ED8A /* MPInterpreter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPInterpreter.h; sourceTree = "<group>"; };
 		48906AFC0C4230B700A3ED8A /* MPInterpreter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPInterpreter.m; sourceTree = "<group>"; };
 		48906B0F0C42364200A3ED8A /* MPConstants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPConstants.h; sourceTree = "<group>"; };
@@ -133,6 +137,8 @@
 				48E993930C82CAAE00219DDF /* MPMacPorts.m */,
 				487679670C98C55E00577C59 /* MPPort.h */,
 				487679680C98C55E00577C59 /* MPPort.m */,
+				488182580CC04EB300489B37 /* MPRegistery.h */,
+				488182590CC04EB300489B37 /* MPRegistery.m */,
 			);
 			name = Classes;
 			sourceTree = "<group>";
@@ -177,6 +183,7 @@
 				48E993940C82CAAE00219DDF /* MPMacPorts.h in Headers */,
 				487679550C98C2EB00577C59 /* MPIndex.h in Headers */,
 				487679690C98C55E00577C59 /* MPPort.h in Headers */,
+				4881825A0CC04EB300489B37 /* MPRegistery.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -290,6 +297,7 @@
 				48E993950C82CAAE00219DDF /* MPMacPorts.m in Sources */,
 				487679560C98C2EB00577C59 /* MPIndex.m in Sources */,
 				4876796A0C98C55E00577C59 /* MPPort.m in Sources */,
+				4881825B0CC04EB300489B37 /* MPRegistery.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Modified: users/rhwood/MacPorts.Framework/MacPorts.h
===================================================================
--- users/rhwood/MacPorts.Framework/MacPorts.h	2007-10-14 01:34:06 UTC (rev 29864)
+++ users/rhwood/MacPorts.Framework/MacPorts.h	2007-10-14 01:37:21 UTC (rev 29865)
@@ -12,3 +12,4 @@
 #import <MacPorts/MPInterpreter.h>;
 #import <MacPorts/MPMacPorts.h>;
 #import <MacPorts/MPPort.h>;
+#import <MacPorts/MPRegistery.h>;

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20071013/c1fc36a1/attachment-0001.html


More information about the macports-changes mailing list