Skip to content
Browse files

MGTemplateEngine will now build for iPhone; thanks to Phil Larson.

git-svn-id: http://svn.cocoasourcecode.com/MGTemplateEngine@18 fad7f400-0e54-0410-bf1d-e368f886e4d4
  • Loading branch information...
1 parent 5b213bb commit fa877d62c70127daf3c5cae682d86882436029e1 mattgemmell committed
View
1 AppController.h
@@ -6,7 +6,6 @@
// Copyright 2008 Instinctive Code. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
#import "MGTemplateEngine.h"
@interface AppController : NSObject <MGTemplateEngineDelegate> {
View
1 ICUTemplateMatcher.h
@@ -5,7 +5,6 @@
// Copyright 2008 Instinctive Code. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
#import "MGTemplateEngine.h"
/*
View
2 MGTemplateEngine.h
@@ -5,8 +5,6 @@
// Copyright 2008 Instinctive Code. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
-
// Keys in blockInfo dictionaries passed to delegate methods.
#define BLOCK_NAME_KEY @"name" // NSString containing block name (first word of marker)
#define BLOCK_END_NAMES_KEY @"endNames" // NSArray containing names of possible ending-markers for block
View
1 MGTemplateStandardFilters.h
@@ -5,7 +5,6 @@
// Copyright 2008 Instinctive Code. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
#import "MGTemplateFilter.h"
View
20 MGTemplateStandardFilters.m
@@ -51,10 +51,29 @@ - (NSObject *)filterInvoked:(NSString *)filter withArguments:(NSArray *)args onV
}
} else if ([filter isEqualToString:COLOR_FORMAT]) {
+#if TARGET_OS_IPHONE
+ if ([value isKindOfClass:[UIColor class]] && [args count] == 1) {
+#else
if ([value isKindOfClass:[NSColor class]] && [args count] == 1) {
+#endif
NSString *format = [[args objectAtIndex:0] lowercaseString];
if ([format isEqualToString:@"hex"]) {
// Output color in hex format RRGGBB (without leading # character).
+#if TARGET_OS_IPHONE
+ CGColorRef color = [(UIColor *)value CGColor];
+ CGColorSpaceRef colorSpace = CGColorGetColorSpace(color);
+ CGColorSpaceModel colorSpaceModel = CGColorSpaceGetModel(colorSpace);
+
+ if (colorSpaceModel != kCGColorSpaceModelRGB)
+ return @"000000";
+
+ const CGFloat *components = CGColorGetComponents(color);
+ NSString *colorHex = [NSString stringWithFormat:@"%02x%02x%02x",
+ (int)(components[0] * 255),
+ (int)(components[1] * 255),
+ (int)(components[2] * 255)];
+ return colorHex;
+#else
NSColor *color = [(NSColor *)value colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
if (!color) { // happens if the colorspace couldn't be converted
return @"000000"; // black
@@ -65,6 +84,7 @@ - (NSObject *)filterInvoked:(NSString *)filter withArguments:(NSArray *)args onV
(int)([color blueComponent] * 255)];
return colorHex;
}
+#endif
}
}
View
1 MGTemplateStandardMarkers.h
@@ -5,7 +5,6 @@
// Copyright 2008 Instinctive Code. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
#import "MGTemplateEngine.h"
#import "MGTemplateMarker.h"
View
3 NSArray_DeepMutableCopy.h
@@ -5,9 +5,6 @@
// Copyright 2008 Instinctive Code. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
-
-
@interface NSArray (DeepMutableCopy)
- (NSMutableArray *)deepMutableCopy;
View
3 NSDictionary_DeepMutableCopy.h
@@ -5,9 +5,6 @@
// Copyright 2008 Instinctive Code. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
-
-
@interface NSDictionary (DeepMutableCopy)
- (NSMutableDictionary *)deepMutableCopy;
View
1 RegexKitTemplateMatcher.h
@@ -5,7 +5,6 @@
// Copyright 2008 Instinctive Code. All rights reserved.
//
-#import <Cocoa/Cocoa.h>
#import "MGTemplateEngine.h"
#import <RegexKit/RegexKit.h>

0 comments on commit fa877d6

Please sign in to comment.
Something went wrong with that request. Please try again.