Permalink
Browse files

Cleanup availability macros mess

  • Loading branch information...
1 parent 9862285 commit eee34030681b204a71a22b471b0eb441c70b0b15 @groue committed Feb 22, 2012
@@ -39,21 +39,17 @@
/*
- * If min GRMustacheVersion not specified, assume 1.0
+ * If max GRMustacheVersion not specified, assume 1.10
*/
-#ifndef GRMUSTACHE_VERSION_MIN_REQUIRED
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_0
+#ifndef GRMUSTACHE_VERSION_MAX_ALLOWED
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_10
#endif
/*
- * if max GRMustacheVersion not specified, assume largerof(1.10, min)
+ * if min GRMustacheVersion not specified, assume max
*/
-#ifndef GRMUSTACHE_VERSION_MAX_ALLOWED
-#if GRMUSTACHE_VERSION_MIN_REQUIRED > GRMUSTACHE_VERSION_1_10
-#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_MIN_REQUIRED
-#else
-#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_10
-#endif
+#ifndef GRMUSTACHE_VERSION_MIN_REQUIRED
+#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_MAX_ALLOWED
#endif
@@ -76,13 +72,6 @@
#define AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER
/*
- * TYPE_AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER
- *
- * Used on functions introduced in GRMustache 1.0
- */
-#define TYPE_AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER
-
-/*
* AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER_BUT_DEPRECATED
*
* Used on functions introduced in GRMustache 1.0,
@@ -287,17 +276,6 @@
#endif
/*
- * TYPE_AVAILABLE_GRMUSTACHE_VERSION_1_3_AND_LATER
- *
- * Used on declarations introduced in GRMustache 1.3
- */
-#if GRMUSTACHE_VERSION_MAX_ALLOWED < GRMUSTACHE_VERSION_1_3
-#define TYPE_AVAILABLE_GRMUSTACHE_VERSION_1_3_AND_LATER UNAVAILABLE_ATTRIBUTE
-#else
-#define TYPE_AVAILABLE_GRMUSTACHE_VERSION_1_3_AND_LATER
-#endif
-
-/*
* AVAILABLE_GRMUSTACHE_VERSION_1_3_AND_LATER_BUT_DEPRECATED
*
* Used on declarations introduced in GRMustache 1.3,
@@ -322,18 +300,6 @@
#endif
/*
- * TYPE_AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_3
- *
- * Used on declarations introduced in GRMustache 1.0,
- * but later deprecated in GRMustache 1.3
- */
-#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_1_3
-#define TYPE_AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_3 DEPRECATED_ATTRIBUTE
-#else
-#define TYPE_AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_3 TYPE_AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER
-#endif
-
-/*
* AVAILABLE_GRMUSTACHE_VERSION_1_1_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_3
*
* Used on declarations introduced in GRMustache 1.1,
@@ -536,18 +502,6 @@
#endif
/*
- * TYPE_AVAILABLE_GRMUSTACHE_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_5
- *
- * Used on declarations introduced in GRMustache 1.3,
- * but later deprecated in GRMustache 1.5
- */
-#if GRMUSTACHE_VERSION_MIN_REQUIRED >= GRMUSTACHE_VERSION_1_5
-#define TYPE_AVAILABLE_GRMUSTACHE_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_5 DEPRECATED_ATTRIBUTE
-#else
-#define TYPE_AVAILABLE_GRMUSTACHE_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_5 TYPE_AVAILABLE_GRMUSTACHE_VERSION_1_3_AND_LATER
-#endif
-
-/*
* AVAILABLE_GRMUSTACHE_VERSION_1_4_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_5
*
* Used on declarations introduced in GRMustache 1.4,
@@ -31,7 +31,7 @@
@since v1.3
@deprecated v1.5
*/
-TYPE_AVAILABLE_GRMUSTACHE_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_5 @interface GRMustacheContext: NSObject {
+DEPRECATED_IN_GRMUSTACHE_VERSION_1_5_AND_LATER @interface GRMustacheContext: NSObject {
@private
id _object;
GRMustacheContext *_parent;
@@ -39,10 +39,10 @@
+ (id)helperWithBlock:(NSString *(^)(GRMustacheSection* section, id context))block AVAILABLE_GRMUSTACHE_VERSION_1_5_AND_LATER;
@end
-typedef NSString *(^GRMustacheRenderingBlock)(GRMustacheSection*, GRMustacheContext*) TYPE_AVAILABLE_GRMUSTACHE_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_5;
+typedef NSString *(^GRMustacheRenderingBlock)(GRMustacheSection*, GRMustacheContext*) DEPRECATED_IN_GRMUSTACHE_VERSION_1_5_AND_LATER;
id GRMustacheLambdaBlockMake(GRMustacheRenderingBlock block) AVAILABLE_GRMUSTACHE_VERSION_1_3_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_5;
-typedef NSString *(^GRMustacheRenderer)(id object) TYPE_AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_3;
-typedef id GRMustacheLambda TYPE_AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_3;
+typedef NSString *(^GRMustacheRenderer)(id object) DEPRECATED_IN_GRMUSTACHE_VERSION_1_3_AND_LATER;
+typedef id GRMustacheLambda DEPRECATED_IN_GRMUSTACHE_VERSION_1_3_AND_LATER;
GRMustacheLambda GRMustacheLambdaMake(NSString *(^block)(NSString *(^)(id object), id, NSString *)) AVAILABLE_GRMUSTACHE_VERSION_1_0_AND_LATER_BUT_DEPRECATED_IN_GRMUSTACHE_VERSION_1_3;
#endif
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_0
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_0
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_0
#import "GRMustachePublicAPITest.h"
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_0
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_0
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_0
#import "GRMustachePublicAPITest.h"
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_0
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_0
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_0
#import "GRMustachePublicAPITest.h"
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_0
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_0
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_0
#import "GRMustachePublicAPITest.h"
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_0
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_0
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_0
#import "GRMustachePublicAPITest.h"
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_0
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_0
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_0
#import "GRMustachePrivateAPITest.h"
@interface GRMustacheTemplate_v1_0_Test : GRMustachePrivateAPITest
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_0
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_0
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_0
#import "GRMustachePublicAPITest.h"
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_0
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_0
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_0
#import "GRMustachePublicAPITest.h"
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_1
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_1
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_1
#import "GRMustachePublicAPITest.h"
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_3
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_3
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_3
#import "GRMustachePublicAPITest.h"
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_3
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_3
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_3
#import "GRMustachePublicAPITest.h"
@@ -28,14 +28,24 @@ @interface GRMustacheSelectorHelper_v1_3_TestContext: NSObject
@implementation GRMustacheSelectorHelper_v1_3_TestContext
-- (NSString*)boldSection:(GRMustacheSection *)section withContext:(GRMustacheContext *)context {
- return [NSString stringWithFormat:@"<b>%@</b>", [section renderObject:context]];
+- (NSString*)linkSection:(GRMustacheSection *)section withContext:(GRMustacheContext *)context {
+ return [NSString stringWithFormat:
+ @"<a href=\"/people/%@\">%@</a>",
+ [context valueForKey:@"id"],
+ [section renderObject:context]];
+}
+
+- (NSString *)id {
+ return @"1";
+}
+
+- (NSString *)name {
+ return @"foo";
}
+ (NSString*)linkSection:(GRMustacheSection *)section withContext:(GRMustacheContext *)context {
return [NSString stringWithFormat:
- @"<a href=\"/people/%@\">%@</a>",
- [context valueForKey:@"id"],
+ @"<a href=\"/people\">%@</a>",
[section renderObject:context]];
}
@@ -44,24 +54,17 @@ + (NSString*)linkSection:(GRMustacheSection *)section withContext:(GRMustacheCon
@implementation GRMustacheSelectorHelper_v1_3_Test
- (void)testHelperInstanceMethod {
- NSString *templateString = @"{{#bold}}text{{/bold}}";
+ NSString *templateString = @"{{#link}}{{name}}{{/link}}";
id context = [[[GRMustacheSelectorHelper_v1_3_TestContext alloc] init] autorelease];
NSString *result = [GRMustacheTemplate renderObject:context fromString:templateString error:nil];
- STAssertEqualObjects(result, @"<b>text</b>", nil);
+ STAssertEqualObjects(result, @"<a href=\"/people/1\">foo</a>", nil);
}
- (void)testHelperClassMethod {
- NSString *templateString = @"<ul>{{#people}}<li>{{#link}}{{name}}{{/link}}</li>{{/people}}</ul>";
- NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSArray arrayWithObjects:
- [NSDictionary dictionaryWithObjectsAndKeys:@"Alan", @"name", @"1", @"id", nil],
- [NSDictionary dictionaryWithObjectsAndKeys:@"Roger", @"name", @"2", @"id", nil],
- nil], @"people",
- nil
- ];
+ NSString *templateString = @"{{#link}}{{name}}{{/link}}";
GRMustacheTemplate *template = [GRMustacheTemplate parseString:templateString error:nil];;
- NSString *result = [template renderObjects:[GRMustacheSelectorHelper_v1_3_TestContext class], data, nil];
- STAssertEqualObjects(result, @"<ul><li><a href=\"/people/1\">Alan</a></li><li><a href=\"/people/2\">Roger</a></li></ul>", nil);
+ NSString *result = [template renderObject:[GRMustacheSelectorHelper_v1_3_TestContext class]];
+ STAssertEqualObjects(result, @"<a href=\"/people\"></a>", nil);
}
@end
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_4
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_4
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_4
#import "GRMustachePublicAPITest.h"
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_4
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_4
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_4
#import "GRMustachePublicAPITest.h"
@@ -123,7 +123,7 @@ - (void)testSuiteTest:(NSDictionary *)suiteTest inSuiteNamed:(NSString *)suiteNa
[fm createDirectoryAtPath:[templatePath stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil error:&error];
[fm createFileAtPath:templatePath contents:[templateString dataUsingEncoding:NSUTF8StringEncoding] attributes:nil];
}
- loader = [GRMustacheTemplateLoader templateLoaderWithDirectory:templatesDirectoryPath extension:[baseTemplatePath pathExtension]];
+ loader = [GRMustacheTemplateLoader templateLoaderWithBasePath:templatesDirectoryPath extension:[baseTemplatePath pathExtension]];
template = [loader parseTemplateNamed:[baseTemplatePath stringByDeletingPathExtension] error:&error];
} else {
loader = [GRMustacheTestSuiteTemplateLoader_v1_4 loaderWithDictionary:partials];
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_5
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_5
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_5
#import "GRMustachePublicAPITest.h"
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_5
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_5
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_5
#import "GRMustachePublicAPITest.h"
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_7
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_7
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_7
#import "GRMustachePublicAPITest.h"
#import <CoreData/CoreData.h>
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_7
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_7
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_7
#import "GRMustachePublicAPITest.h"
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_8
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_8
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_8
#import "GRMustachePublicAPITest.h"
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_8
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_8
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_8
#import "GRMustachePublicAPITest.h"
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_9
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_9
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_9
#import "GRMustachePublicAPITest.h"
@interface GRMustacheDateFormatterHelperTest : GRMustachePublicAPITest
@@ -20,8 +20,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-#define GRMUSTACHE_VERSION_MIN_REQUIRED GRMUSTACHE_VERSION_1_9
-#define GRMUSTACHE_VERSION_MAX_REQUIRED GRMUSTACHE_VERSION_1_9
+#define GRMUSTACHE_VERSION_MAX_ALLOWED GRMUSTACHE_VERSION_1_9
#import "GRMustachePublicAPITest.h"
@interface GRMustacheHelperTest : GRMustachePublicAPITest
Oops, something went wrong.

0 comments on commit eee3403

Please sign in to comment.