[44840] users/toby/objcports
toby at macports.org
toby at macports.org
Sat Jan 3 07:04:56 PST 2009
Revision: 44840
http://trac.macports.org/changeset/44840
Author: toby at macports.org
Date: 2009-01-03 07:04:56 -0800 (Sat, 03 Jan 2009)
Log Message:
-----------
default handling, more abstraction
Modified Paths:
--------------
users/toby/objcports/MPParser.h
users/toby/objcports/MPParser.m
Added Paths:
-----------
users/toby/objcports/MPPort.h
users/toby/objcports/MPPort.m
users/toby/objcports/objcports.xcodeproj/
users/toby/objcports/objcports.xcodeproj/project.pbxproj
users/toby/objcports/port.m
Removed Paths:
-------------
users/toby/objcports/main.m
Modified: users/toby/objcports/MPParser.h
===================================================================
--- users/toby/objcports/MPParser.h 2009-01-03 14:53:07 UTC (rev 44839)
+++ users/toby/objcports/MPParser.h 2009-01-03 15:04:56 UTC (rev 44840)
@@ -1,3 +1,5 @@
+ at class MPPort;
+
@interface MPParser : NSObject
{
Tcl_Interp *_interp;
@@ -15,7 +17,7 @@
NSMutableArray *_platforms; // just a list, for dupe checking
}
-- (id)initWithPortfile:(NSString *)portfile;
+- (id)initWithPort:(MPPort *)port;
- (NSString *)option:(NSString *)option;
- (NSArray *)variants;
Modified: users/toby/objcports/MPParser.m
===================================================================
--- users/toby/objcports/MPParser.m 2009-01-03 14:53:07 UTC (rev 44839)
+++ users/toby/objcports/MPParser.m 2009-01-03 15:04:56 UTC (rev 44840)
@@ -2,15 +2,17 @@
#include <tcl.h>
#include "MPParser.h"
+#include "MPPort.h"
#include "MPArrayAdditions.h"
#include "MPStringAdditions.h"
static int _unknown(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
+static char *_default(ClientData clientData, Tcl_Interp *interp, const char *name1, const char *name2, int flags);
static void info(Tcl_Interp *interp, const char *command); // debugging
@implementation MPParser
-- (id)initWithPortfile:(NSString *)portfile
+- (id)initWithPort:(MPPort *)port
{
self = [super init];
_interp = Tcl_CreateInterp();
@@ -23,13 +25,14 @@
@try {
Tcl_Preserve(_interp);
- // XXX: need to do all setup here
- Tcl_SetVar(_interp, "prefix", "/opt/local", 0);
- Tcl_SetVar(_interp, "worksrcpath", "/tmp/", 0);
+ /* Handle defaults (ask parent port instance). */
+ for (NSString *def in [port defaults]) {
+ Tcl_TraceVar(_interp, [def UTF8String], TCL_TRACE_READS, _default, port);
+ }
Tcl_CreateObjCommand(_interp, "unknown", _unknown, self, NULL);
- if (Tcl_EvalFile(_interp, [portfile UTF8String]) != TCL_OK) {
- NSLog(@"Tcl_EvalFile(%@): %s", portfile, Tcl_GetStringResult(_interp));
+ if (Tcl_EvalFile(_interp, [[port portfile] UTF8String]) != TCL_OK) {
+ NSLog(@"Tcl_EvalFile(%@): %s", [port portfile], Tcl_GetStringResult(_interp));
}
Tcl_Release(_interp);
@@ -78,6 +81,8 @@
assert([[args objectAtIndex:0] isEqualToString:@"1.0"]);
} else if ([command isEqualToString:@"PortGroup"]) {
NSLog(@"ignoring %@, grps r hard m'kay", command);
+ // XXX: this should probably set some state in parent port instance
+ // (ugh, more tcl parsing)
} else if ([command isEqualToString:@"platform"]) {
NSUInteger count = [args count];
NSString *os, *arch;
@@ -208,6 +213,15 @@
return TCL_OK;
}
+static char *
+_default(ClientData clientData, Tcl_Interp *interp, const char *name1, const char *name2, int flags)
+{
+ assert(flags == TCL_TRACE_READS);
+ assert(name2 == NULL);
+ Tcl_SetVar(interp, name1, [[(id)clientData default:[NSString stringWithUTF8String:name1]] UTF8String], 0);
+ return NULL;
+}
+
// debugging
static void
info(Tcl_Interp *interp, const char *command)
Added: users/toby/objcports/MPPort.h
===================================================================
--- users/toby/objcports/MPPort.h (rev 0)
+++ users/toby/objcports/MPPort.h 2009-01-03 15:04:56 UTC (rev 44840)
@@ -0,0 +1,20 @@
+ at class MPParser;
+
+ at interface MPPort : NSObject
+{
+ NSString *_portfile;
+ MPParser *_parser;
+}
+
+- (id)initWithPortfile:(NSString *)port options:(NSDictionary *)options;
+
+- (NSString *)portfile;
+
+- (NSArray *)defaults;
+- (NSString *)default:(NSString *)def;
+
+- (NSString *)option:(NSString *)option;
+- (NSArray *)variants;
+- (NSArray *)platforms;
+
+ at end
Added: users/toby/objcports/MPPort.m
===================================================================
--- users/toby/objcports/MPPort.m (rev 0)
+++ users/toby/objcports/MPPort.m 2009-01-03 15:04:56 UTC (rev 44840)
@@ -0,0 +1,56 @@
+#include <Foundation/Foundation.h>
+#include <tcl.h>
+
+#include "MPPort.h"
+#include "MPParser.h"
+
+ at implementation MPPort
+
+- (id)initWithPortfile:(NSString *)portfile options:(NSDictionary *)options
+{
+ self = [super init];
+ _portfile = [portfile retain];
+ _parser = [[MPParser alloc] initWithPort:self];
+ return self;
+}
+
+- (void)dealloc
+{
+ [_parser release];
+ [_portfile release];
+ [super dealloc];
+}
+
+- (NSString *)portfile
+{
+ return _portfile;
+}
+
+- (NSArray *)defaults
+{
+ return [NSArray arrayWithObjects:@"prefix", @"worksrcpath", nil];
+}
+
+- (NSString *)default:(NSString *)def
+{
+ // XXX: selector (NSInvocation?) or constant NSString...
+ NSLog(@"requesting default value of '%@'", def);
+ return def;
+}
+
+- (NSString *)option:(NSString *)option
+{
+ return [_parser option:option];
+}
+
+- (NSArray *)variants
+{
+ return [_parser variants];
+}
+
+- (NSArray *)platforms
+{
+ return [_parser platforms];
+}
+
+ at end
Deleted: users/toby/objcports/main.m
===================================================================
--- users/toby/objcports/main.m 2009-01-03 14:53:07 UTC (rev 44839)
+++ users/toby/objcports/main.m 2009-01-03 15:04:56 UTC (rev 44840)
@@ -1,24 +0,0 @@
-#include <Foundation/Foundation.h>
-#include <tcl.h>
-
-#include "MPParser.h"
-
-int
-main(int argc, char *argv[])
-{
- 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];
- return 0;
-}
Added: users/toby/objcports/objcports.xcodeproj/project.pbxproj
===================================================================
--- users/toby/objcports/objcports.xcodeproj/project.pbxproj (rev 0)
+++ users/toby/objcports/objcports.xcodeproj/project.pbxproj 2009-01-03 15:04:56 UTC (rev 44840)
@@ -0,0 +1,241 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 45;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ 8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08FB779EFE84155DC02AAC07 /* Foundation.framework */; };
+ DAD371710F0280EF0064AFF4 /* port.m in Sources */ = {isa = PBXBuildFile; fileRef = DAD371680F0280EF0064AFF4 /* port.m */; };
+ DAD371720F0280EF0064AFF4 /* MPArrayAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = DAD3716A0F0280EF0064AFF4 /* MPArrayAdditions.m */; };
+ DAD371730F0280EF0064AFF4 /* MPParser.m in Sources */ = {isa = PBXBuildFile; fileRef = DAD3716C0F0280EF0064AFF4 /* MPParser.m */; };
+ DAD371740F0280EF0064AFF4 /* MPPort.m in Sources */ = {isa = PBXBuildFile; fileRef = DAD3716E0F0280EF0064AFF4 /* MPPort.m */; };
+ DAD371750F0280EF0064AFF4 /* MPStringAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = DAD371700F0280EF0064AFF4 /* MPStringAdditions.m */; };
+ DAD371950F0281940064AFF4 /* libtcl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = DAD371940F0281940064AFF4 /* libtcl.dylib */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXCopyFilesBuildPhase section */
+ 8DD76F9E0486AA7600D96B5E /* CopyFiles */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 8;
+ dstPath = /usr/share/man/man1/;
+ dstSubfolderSpec = 0;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 1;
+ };
+/* End PBXCopyFilesBuildPhase section */
+
+/* Begin PBXFileReference section */
+ 08FB779EFE84155DC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
+ 8DD76FA10486AA7600D96B5E /* objcports */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = objcports; sourceTree = BUILT_PRODUCTS_DIR; };
+ DAD371680F0280EF0064AFF4 /* port.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = port.m; sourceTree = "<group>"; };
+ DAD371690F0280EF0064AFF4 /* MPArrayAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPArrayAdditions.h; sourceTree = "<group>"; };
+ DAD3716A0F0280EF0064AFF4 /* MPArrayAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPArrayAdditions.m; sourceTree = "<group>"; };
+ DAD3716B0F0280EF0064AFF4 /* MPParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPParser.h; sourceTree = "<group>"; };
+ DAD3716C0F0280EF0064AFF4 /* MPParser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPParser.m; sourceTree = "<group>"; };
+ DAD3716D0F0280EF0064AFF4 /* MPPort.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPPort.h; sourceTree = "<group>"; };
+ DAD3716E0F0280EF0064AFF4 /* MPPort.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPPort.m; sourceTree = "<group>"; };
+ DAD3716F0F0280EF0064AFF4 /* MPStringAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MPStringAdditions.h; sourceTree = "<group>"; };
+ DAD371700F0280EF0064AFF4 /* MPStringAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MPStringAdditions.m; sourceTree = "<group>"; };
+ DAD371940F0281940064AFF4 /* libtcl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libtcl.dylib; path = /usr/lib/libtcl.dylib; sourceTree = "<absolute>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ 8DD76F9B0486AA7600D96B5E /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ 8DD76F9C0486AA7600D96B5E /* Foundation.framework in Frameworks */,
+ DAD371950F0281940064AFF4 /* libtcl.dylib in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ 08FB7794FE84155DC02AAC07 /* objcports */ = {
+ isa = PBXGroup;
+ children = (
+ 08FB7795FE84155DC02AAC07 /* Source */,
+ C6859EA2029092E104C91782 /* Documentation */,
+ 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */,
+ 1AB674ADFE9D54B511CA2CBB /* Products */,
+ );
+ name = objcports;
+ sourceTree = "<group>";
+ };
+ 08FB7795FE84155DC02AAC07 /* Source */ = {
+ isa = PBXGroup;
+ children = (
+ DAD371680F0280EF0064AFF4 /* port.m */,
+ DAD371690F0280EF0064AFF4 /* MPArrayAdditions.h */,
+ DAD3716A0F0280EF0064AFF4 /* MPArrayAdditions.m */,
+ DAD3716B0F0280EF0064AFF4 /* MPParser.h */,
+ DAD3716C0F0280EF0064AFF4 /* MPParser.m */,
+ DAD3716D0F0280EF0064AFF4 /* MPPort.h */,
+ DAD3716E0F0280EF0064AFF4 /* MPPort.m */,
+ DAD3716F0F0280EF0064AFF4 /* MPStringAdditions.h */,
+ DAD371700F0280EF0064AFF4 /* MPStringAdditions.m */,
+ );
+ name = Source;
+ sourceTree = "<group>";
+ };
+ 08FB779DFE84155DC02AAC07 /* External Frameworks and Libraries */ = {
+ isa = PBXGroup;
+ children = (
+ DAD371940F0281940064AFF4 /* libtcl.dylib */,
+ 08FB779EFE84155DC02AAC07 /* Foundation.framework */,
+ );
+ name = "External Frameworks and Libraries";
+ sourceTree = "<group>";
+ };
+ 1AB674ADFE9D54B511CA2CBB /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ 8DD76FA10486AA7600D96B5E /* objcports */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ C6859EA2029092E104C91782 /* Documentation */ = {
+ isa = PBXGroup;
+ children = (
+ );
+ name = Documentation;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ 8DD76F960486AA7600D96B5E /* port */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = 1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "port" */;
+ buildPhases = (
+ 8DD76F990486AA7600D96B5E /* Sources */,
+ 8DD76F9B0486AA7600D96B5E /* Frameworks */,
+ 8DD76F9E0486AA7600D96B5E /* CopyFiles */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = port;
+ productInstallPath = "$(HOME)/bin";
+ productName = objcports;
+ productReference = 8DD76FA10486AA7600D96B5E /* objcports */;
+ productType = "com.apple.product-type.tool";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ 08FB7793FE84155DC02AAC07 /* Project object */ = {
+ isa = PBXProject;
+ buildConfigurationList = 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "objcports" */;
+ compatibilityVersion = "Xcode 3.1";
+ hasScannedForEncodings = 1;
+ mainGroup = 08FB7794FE84155DC02AAC07 /* objcports */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ 8DD76F960486AA7600D96B5E /* port */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXSourcesBuildPhase section */
+ 8DD76F990486AA7600D96B5E /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ DAD371710F0280EF0064AFF4 /* port.m in Sources */,
+ DAD371720F0280EF0064AFF4 /* MPArrayAdditions.m in Sources */,
+ DAD371730F0280EF0064AFF4 /* MPParser.m in Sources */,
+ DAD371740F0280EF0064AFF4 /* MPPort.m in Sources */,
+ DAD371750F0280EF0064AFF4 /* MPStringAdditions.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin XCBuildConfiguration section */
+ 1DEB927508733DD40010E9CD /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ COPY_PHASE_STRIP = NO;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_FIX_AND_CONTINUE = YES;
+ GCC_MODEL_TUNING = G5;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ INSTALL_PATH = /usr/local/bin;
+ PRODUCT_NAME = objcports;
+ };
+ name = Debug;
+ };
+ 1DEB927608733DD40010E9CD /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+ GCC_MODEL_TUNING = G5;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = objcports_Prefix.pch;
+ INSTALL_PATH = /usr/local/bin;
+ PRODUCT_NAME = objcports;
+ };
+ name = Release;
+ };
+ 1DEB927908733DD40010E9CD /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ ONLY_ACTIVE_ARCH = YES;
+ PREBINDING = NO;
+ SDKROOT = macosx10.5;
+ };
+ name = Debug;
+ };
+ 1DEB927A08733DD40010E9CD /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ PREBINDING = NO;
+ SDKROOT = macosx10.5;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ 1DEB927408733DD40010E9CD /* Build configuration list for PBXNativeTarget "port" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1DEB927508733DD40010E9CD /* Debug */,
+ 1DEB927608733DD40010E9CD /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ 1DEB927808733DD40010E9CD /* Build configuration list for PBXProject "objcports" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ 1DEB927908733DD40010E9CD /* Debug */,
+ 1DEB927A08733DD40010E9CD /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = 08FB7793FE84155DC02AAC07 /* Project object */;
+}
Copied: users/toby/objcports/port.m (from rev 43852, users/toby/objcports/main.m)
===================================================================
--- users/toby/objcports/port.m (rev 0)
+++ users/toby/objcports/port.m 2009-01-03 15:04:56 UTC (rev 44840)
@@ -0,0 +1,24 @@
+#include <Foundation/Foundation.h>
+#include <tcl.h>
+
+#include "MPPort.h"
+
+int
+main(int argc, char *argv[])
+{
+ NSAutoreleasePool *pool = [NSAutoreleasePool new];
+
+ MPPort *port = [[MPPort alloc] initWithPortfile:[NSString stringWithUTF8String:argv[1]] options:nil];
+ 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];
+ return 0;
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-changes/attachments/20090103/edab6999/attachment.html>
More information about the macports-changes
mailing list