[43764] users/toby/objcports

toby at macports.org toby at macports.org
Sun Dec 14 01:06:11 PST 2008


Revision: 43764
          http://trac.macports.org/changeset/43764
Author:   toby at macports.org
Date:     2008-12-14 01:06:10 -0800 (Sun, 14 Dec 2008)
Log Message:
-----------
emulate 'port info'

Modified Paths:
--------------
    users/toby/objcports/MPParser.h
    users/toby/objcports/MPParser.m
    users/toby/objcports/main.m

Modified: users/toby/objcports/MPParser.h
===================================================================
--- users/toby/objcports/MPParser.h	2008-12-14 08:52:00 UTC (rev 43763)
+++ users/toby/objcports/MPParser.h	2008-12-14 09:06:10 UTC (rev 43764)
@@ -1,9 +1,24 @@
 @interface MPParser : NSObject
 {
 	Tcl_Interp *_interp;
+
+	// set before parsing (list obtained elsewhere...)
+	// actual values are stored inside the interpreter for now
 	NSMutableArray *_options;
+
+	// also set before parsing, from external list
+	// remember that not every subcommand should be a target :)
+	NSMutableArray *_targets;
+
+	// information gathered during parsing, not stored in interpreter
+	NSMutableDictionary *_variants;
+	NSMutableArray *_platforms; // just a list, for dupe checking
 }
 
 - (id)initWithPortfile:(NSString *)portfile;
 
+- (NSString *)option:(NSString *)option;
+- (NSArray *)variants;
+- (NSArray *)platforms;
+
 @end

Modified: users/toby/objcports/MPParser.m
===================================================================
--- users/toby/objcports/MPParser.m	2008-12-14 08:52:00 UTC (rev 43763)
+++ users/toby/objcports/MPParser.m	2008-12-14 09:06:10 UTC (rev 43764)
@@ -14,6 +14,8 @@
 {
 	self = [super init];
 	_interp = Tcl_CreateInterp();
+	_variants = [[NSMutableDictionary alloc] initWithCapacity:0];
+	_platforms = [[NSMutableArray alloc] initWithCapacity:0];
 
 	// XXX: should probably remove even more functionality
 	//Tcl_MakeSafe(_interp);
@@ -47,10 +49,27 @@
 
 - (void)dealloc
 {
+	[_variants release];
+	[_platforms release];
 	Tcl_DeleteInterp(_interp);
 	[super dealloc];
 }
 
+- (NSString *)option:(NSString *)option
+{
+	return [NSString stringWithUTF8String:Tcl_GetVar(_interp, [option UTF8String], 0)];
+}
+
+- (NSArray *)variants
+{
+	return [_variants allKeys];
+}
+
+- (NSArray *)platforms
+{
+	return _platforms;
+}
+
 - (void)performCommand:(NSString *)command arguments:(NSArray *)args
 {
 	if ([command isEqualToString:@"PortSystem"]) {
@@ -83,6 +102,7 @@
 			arch ? [NSString stringWithFormat:@"_%@", arch] : @""];
 
 		// XXX: dupe check
+		[_platforms addObject:platformFull];
 		// XXX: check match, right now pretend all platforms are true
 		if (YES) {
 			NSLog(@"eval'ing target %@", platformFull);
@@ -102,6 +122,7 @@
 
 		// XXX: actually pull in its properties.. need to provide externally
 		// also check for dupes (w/ platforms too)
+		[_variants setObject:[NSDictionary dictionary] forKey:name];
 
 		// XXX: make sure it's set, like platforms just pretend
 		if (YES) {

Modified: users/toby/objcports/main.m
===================================================================
--- users/toby/objcports/main.m	2008-12-14 08:52:00 UTC (rev 43763)
+++ users/toby/objcports/main.m	2008-12-14 09:06:10 UTC (rev 43764)
@@ -9,6 +9,14 @@
 	NSAutoreleasePool *pool = [NSAutoreleasePool new];
 
 	MPParser *port = [[MPParser alloc] initWithPortfile:[NSString stringWithUTF8String:argv[1]]];
+	NSLog(@"%@ @%@ (%@)", [port option:@"name"], [port option:@"version"], [port option:@"categories"]);
+	NSLog(@"Variants:     %@", [[port variants] componentsJoinedByString:@", "]);
+	NSLog(@"PlatVariants: %@", [[port platforms] componentsJoinedByString:@", "]);
+	NSLog(@"%@", [port option:@"long_description"]);
+	NSLog(@"Homepage:             %@", [port option:@"homepage"]);
+	NSLog(@"Platforms:            %@", [port option:@"platforms"]);
+	NSLog(@"Maintainers:          %@", [port option:@"maintainers"]);
+
 	[port release];
 
 	[pool release];
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20081214/dcb403cf/attachment.html>


More information about the macports-changes mailing list