Browse code

Make it work on iOS again (?). Added "filter" function, for formatting needs. Fixed comparisons with nil

Nat! authored on 08-11-2013 11:40:13
Showing 15 changed files
... ...
@@ -161,6 +161,9 @@
161 161
 		415DA593182BA36D00F654F7 /* NSFileHandle+MulleOutputFileHandle.m in Sources */ = {isa = PBXBuildFile; fileRef = 41F0CDD418296756000057D5 /* NSFileHandle+MulleOutputFileHandle.m */; };
162 162
 		415DA59A182BBB0000F654F7 /* GTMNSString+HTML.m in Sources */ = {isa = PBXBuildFile; fileRef = 415DA599182BBB0000F654F7 /* GTMNSString+HTML.m */; };
163 163
 		415DA59C182BBB3B00F654F7 /* GTMDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = 415DA59B182BBB3B00F654F7 /* GTMDefines.h */; };
164
+		415DA5D5182BED2100F654F7 /* NSObject+iOS_KVC_Compatibility.h in Headers */ = {isa = PBXBuildFile; fileRef = 415DA5D3182BED2100F654F7 /* NSObject+iOS_KVC_Compatibility.h */; settings = {ATTRIBUTES = (Private, ); }; };
165
+		415DA5D6182BED2100F654F7 /* NSObject+iOS_KVC_Compatibility.m in Sources */ = {isa = PBXBuildFile; fileRef = 415DA5D4182BED2100F654F7 /* NSObject+iOS_KVC_Compatibility.m */; };
166
+		415DA5D7182BED2100F654F7 /* NSObject+iOS_KVC_Compatibility.m in Sources */ = {isa = PBXBuildFile; fileRef = 415DA5D4182BED2100F654F7 /* NSObject+iOS_KVC_Compatibility.m */; };
164 167
 		41764B9016DA511200560FCF /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 41764B8F16DA511200560FCF /* Foundation.framework */; };
165 168
 		41764B9316DA511200560FCF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 41764B9216DA511200560FCF /* main.m */; };
166 169
 		41764B9716DA511200560FCF /* mulle-scion.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = 41764B9616DA511200560FCF /* mulle-scion.1 */; };
... ...
@@ -586,6 +589,8 @@
586 589
 		415DA598182BBB0000F654F7 /* GTMNSString+HTML.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "GTMNSString+HTML.h"; path = "../google-toolbox-for-mac/Foundation/GTMNSString+HTML.h"; sourceTree = "<group>"; };
587 590
 		415DA599182BBB0000F654F7 /* GTMNSString+HTML.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "GTMNSString+HTML.m"; path = "../google-toolbox-for-mac/Foundation/GTMNSString+HTML.m"; sourceTree = "<group>"; };
588 591
 		415DA59B182BBB3B00F654F7 /* GTMDefines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GTMDefines.h; path = "../google-toolbox-for-mac/GTMDefines.h"; sourceTree = "<group>"; };
592
+		415DA5D3182BED2100F654F7 /* NSObject+iOS_KVC_Compatibility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+iOS_KVC_Compatibility.h"; sourceTree = "<group>"; };
593
+		415DA5D4182BED2100F654F7 /* NSObject+iOS_KVC_Compatibility.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSObject+iOS_KVC_Compatibility.m"; sourceTree = "<group>"; };
589 594
 		41764B8C16DA511200560FCF /* mulle-scion */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "mulle-scion"; sourceTree = BUILT_PRODUCTS_DIR; };
590 595
 		41764B8F16DA511200560FCF /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
591 596
 		41764B9216DA511200560FCF /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
... ...
@@ -909,6 +914,8 @@
909 914
 				41F0CDD418296756000057D5 /* NSFileHandle+MulleOutputFileHandle.m */,
910 915
 				410B32E516DB7732005D0EAD /* MulleScionObjectModel+TraceDescription.h */,
911 916
 				410B32E616DB7732005D0EAD /* MulleScionObjectModel+TraceDescription.m */,
917
+				415DA5D3182BED2100F654F7 /* NSObject+iOS_KVC_Compatibility.h */,
918
+				415DA5D4182BED2100F654F7 /* NSObject+iOS_KVC_Compatibility.m */,
912 919
 			);
913 920
 			name = MulleScionFoundation;
914 921
 			sourceTree = "<group>";
... ...
@@ -978,6 +985,7 @@
978 985
 				41188244181E848C003F06CD /* MulleScionObjectModel+MacroExpansion.h in Headers */,
979 986
 				41188243181E848C003F06CD /* MulleScionObjectModel+BlockExpansion.h in Headers */,
980 987
 				41188242181E848C003F06CD /* MulleScionObjectModel+Parsing.h in Headers */,
988
+				415DA5D5182BED2100F654F7 /* NSObject+iOS_KVC_Compatibility.h in Headers */,
981 989
 				41188241181E848C003F06CD /* MulleScionParser+Parsing.h in Headers */,
982 990
 			);
983 991
 			runOnlyForDeploymentPostprocessing = 0;
... ...
@@ -1165,12 +1173,12 @@
1165 1173
 				415DA5B9182BCAB500F654F7 /* iOS */,
1166 1174
 				41764B8B16DA511200560FCF /* mulle-scion */,
1167 1175
 				41D6DF2316DE523D004833D6 /* MulleScion (OSX Library) */,
1176
+				41D6DF5B16DE53AE004833D6 /* MulleScion (OSX Framework) */,
1168 1177
 				410300711701DBE200197713 /* MulleScion (iOS Library) */,
1178
+				41DCF5D6181E824A00A98EDB /* MulleScion (iOS Framework) */,
1169 1179
 				41D6DEEF16DE513F004833D6 /* MulleScionFoundation */,
1170 1180
 				41D6DF0316DE51C9004833D6 /* MulleScionParser */,
1171 1181
 				41D6DED816DE509E004833D6 /* MulleScionPrinter */,
1172
-				41D6DF5B16DE53AE004833D6 /* MulleScion (OSX Framework) */,
1173
-				41DCF5D6181E824A00A98EDB /* MulleScion (iOS Framework) */,
1174 1182
 				415DA59D182BBC8200F654F7 /* grab google-toolbox-for-mac from code.google.com */,
1175 1183
 			);
1176 1184
 		};
... ...
@@ -1255,6 +1263,7 @@
1255 1263
 				4103008C1701DC5C00197713 /* MulleScionParser+Parsing.m in Sources */,
1256 1264
 				410300811701DC3A00197713 /* MulleScionTemplate+CompressedArchive.m in Sources */,
1257 1265
 				415DA591182BA17600F654F7 /* NSFileHandle+MulleOutputFileHandle.m in Sources */,
1266
+				415DA5D6182BED2100F654F7 /* NSObject+iOS_KVC_Compatibility.m in Sources */,
1258 1267
 			);
1259 1268
 			runOnlyForDeploymentPostprocessing = 0;
1260 1269
 		};
... ...
@@ -1343,6 +1352,7 @@
1343 1352
 				41DCF5F0181E82C300A98EDB /* MulleMutableLineNumber.m in Sources */,
1344 1353
 				41DCF5F1181E82C300A98EDB /* MulleScionNull.m in Sources */,
1345 1354
 				41DCF5F2181E82C300A98EDB /* MulleScionParser.m in Sources */,
1355
+				415DA5D7182BED2100F654F7 /* NSObject+iOS_KVC_Compatibility.m in Sources */,
1346 1356
 				41DCF5F3181E82C300A98EDB /* MulleScionParser+Parsing.m in Sources */,
1347 1357
 				41DCF5F4181E82C300A98EDB /* MulleScionObjectModel+Parsing.m in Sources */,
1348 1358
 				41DCF5F5181E82C300A98EDB /* MulleScionObjectModel+BlockExpansion.m in Sources */,
... ...
@@ -112,6 +112,17 @@ projects. See https://github.com/kstenerud/iOS-Universal-Framework for more
112 112
 details about using "real frameworks" with Xcode.
113 113
 
114 114
 
115
+SITES
116
+=============
117
+The main development site is Mulle kybernetiK. 
118
+
119
+http://www.mulle-kybernetik.com/software/git/MulleScionTemplates/
120
+
121
+releases are pushed to github
122
+
123
+github: https://github.com/mulle-nat/MulleScionTemplates/
124
+
125
+
115 126
 TODO
116 127
 =============
117 128
 It would be nice to have delayed evaluation for render results.
... ...
@@ -28,6 +28,24 @@ __FILTER_STACK__                The previous filter chains
28 28
 __SELF_REPLACEMENT__            The object that the identifier 'self' gets 
29 29
                                 replaced with
30 30
 
31
+Predefined Variables
32
+====================
33
+
34
+A small selection of Foundation constants is predefined for convenience.
35
+
36
+NSNotFound
37
+
38
+NSOrderedAscending
39
+NSOrderedDescending
40
+NSOrderedSame
41
+
42
+NSASCIIStringEncoding
43
+NSISOLatin1StringEncoding
44
+NSMacOSRomanStringEncoding
45
+NSUTF32StringEncoding
46
+NSUTF8StringEncoding
47
+NSUnicodeStringEncoding
48
+
31 49
 
32 50
 Variables available through mulle-scion
33 51
 =======================================
... ...
@@ -14,3 +14,12 @@ back to original.
14 14
 {% filter lowercaseString| [[self componentsSeparatedByString:@"/"] componentsJoinedByString:@"-"] %}
15 15
 THIS/IS/POSSIBLE
16 16
 {% endfilter %}
17
+
18
+There is also function filter available. This will push a string argument 
19
+through the currently active filter.
20
+
21
+{% low=@"low" %}
22
+{% filter uppercaseString %}
23
+{% high = filter( low) %}
24
+{% endfilter %}
25
+{{ low }} -> {{ high }}
... ...
@@ -39,6 +39,7 @@
39 39
 
40 40
 #import "MulleScionObjectModel+Printing.h"
41 41
 #import "MulleScionPrintingException.h"
42
+#import "NSObject+MulleScionDescription.h"
42 43
 
43 44
 
44 45
 @interface NSObject ( OldMethods)
... ...
@@ -175,6 +176,19 @@
175 176
       return( [NSValue valueWithRange:range]);
176 177
    }
177 178
    
179
+   // same as {{}} but returns length of output string
180
+   
181
+   if( [identifier isEqualToString:@"filter"])
182
+   {
183
+      NSString   *string;
184
+      id         value;
185
+      
186
+      MulleScionPrintingValidateArgumentCount( arguments, 1, locals);
187
+      value  = MulleScionPrintingValidatedArgument( arguments, 0, Nil, locals);
188
+      string = [value mulleScionDescriptionWithLocalVariables:locals];
189
+      string = MulleScionFilteredString( string, locals, self);
190
+      return( string);
191
+   }
178 192
    [NSException raise:NSInvalidArgumentException
179 193
                format:@"\"%@\" %@: unknown function \"%@\"",
180 194
     [locals valueForKey:MulleScionCurrentFileKey],
... ...
@@ -47,4 +47,27 @@ id   MulleScionNull;
47 47
    MulleScionNull = self;
48 48
 }
49 49
 
50
+
51
++ (id) allocWithZone:(NSZone *) zone
52
+{
53
+#ifdef DEBUG
54
+   abort();
55
+#endif
56
+   return( [MulleScionNull retain]);
57
+}
58
+
59
+
60
+- (BOOL) isEqual:(id) other
61
+{
62
+   return( self == other);
63
+}
64
+
65
+
66
+- (BOOL) compare:(id) other
67
+{
68
+   if( self == other)
69
+      return( NSOrderedSame);
70
+   return( self < other ? NSOrderedAscending : NSOrderedDescending);
71
+}
72
+
50 73
 @end
... ...
@@ -67,3 +67,11 @@ extern NSString   *MulleScionOddKey;
67 67
 
68 68
 @end
69 69
 
70
+NSString  *MulleScionFilteredString( NSString *value,
71
+                                    NSMutableDictionary *locals,
72
+                                    id <MulleScionDataSource> dataSource);
73
+
74
+void   MulleScionRenderString( NSString *value,
75
+                               id <MulleScionOutput> output,
76
+                               NSMutableDictionary *locals,
77
+                               id <MulleScionDataSource> dataSource);
... ...
@@ -48,6 +48,7 @@
48 48
 # import <objc/objc-class.h>
49 49
 #else
50 50
 # import <objc/runtime.h>
51
+# import "NSObject+iOS_KVC_Compatibility.h"
51 52
 #endif
52 53
 
53 54
 #ifndef NO_TRACE
... ...
@@ -173,10 +174,9 @@ static void   popFileName( NSMutableDictionary *locals)
173 174
 }
174 175
 
175 176
 
176
-static void   MulleScionRenderString( NSString *value,
177
-                                      id <MulleScionOutput> output,
178
-                                      NSMutableDictionary *locals,
179
-                                      id <MulleScionDataSource> dataSource)
177
+NSString  *MulleScionFilteredString( NSString *value,
178
+                                     NSMutableDictionary *locals,
179
+                                     id <MulleScionDataSource> dataSource)
180 180
 {
181 181
    MulleScionExpression  *filter;
182 182
    
... ...
@@ -199,11 +199,24 @@ static void   MulleScionRenderString( NSString *value,
199 199
       }
200 200
    }
201 201
    
202
-   if( value)
203
-   {
204
-      NSCParameterAssert( [value isKindOfClass:[NSString class]]);
205
-      [output appendString:value];
206
-   }
202
+   return( value);
203
+}
204
+
205
+
206
+void   MulleScionRenderString( NSString *value,
207
+                               id <MulleScionOutput> output,
208
+                               NSMutableDictionary *locals,
209
+                               id <MulleScionDataSource> dataSource)
210
+{
211
+   NSString     *s;
212
+   NSUInteger   len;
213
+
214
+   s   = MulleScionFilteredString( value, locals, dataSource);
215
+   if( ! s)
216
+      return;
217
+
218
+   NSCParameterAssert( [s isKindOfClass:[NSString class]]);
219
+   [output appendString:s];
207 220
 }
208 221
 
209 222
 @end
... ...
@@ -1433,16 +1446,27 @@ static BOOL  isTrue( id value)
1433 1446
 
1434 1447
    TRACE_EVAL_BEGIN( self, value);
1435 1448
    
1436
-   if( value == MulleScionNull)
1437
-      value = nil;
1438
-   
1449
+   if( ! value)
1450
+   {
1451
+#if DEBUG
1452
+      abort();
1453
+#endif
1454
+      value = MulleScionNull;
1455
+   }
1456
+
1439 1457
    otherValue = [self->right_ valueWithLocalVariables:locals
1440 1458
                                            dataSource:dataSource];
1441
-   if( otherValue == MulleScionNull)
1442
-      otherValue = nil;
1459
+   if( ! otherValue)
1460
+   {
1461
+#if DEBUG
1462
+      abort();
1463
+#endif
1464
+      otherValue = MulleScionNull;
1465
+   }
1466
+   
1443 1467
    switch( comparison_)
1444 1468
    {
1445
-      case MulleScionEqual    : flag =   [value isEqual:otherValue]; break;
1469
+      case MulleScionEqual    : flag = [value isEqual:otherValue]; break;
1446 1470
       case MulleScionNotEqual : flag = ! [value isEqual:otherValue]; break;
1447 1471
 
1448 1472
       default                 :
... ...
@@ -2460,6 +2460,8 @@ static MulleScionObject * NS_RETURNS_RETAINED  parser_do_command( parser *p)
2460 2460
       {
2461 2461
          if( p->wasMacroCall)
2462 2462
             return( expr);
2463
+         //if( [expr isFunction])  // not that great an idea, produces surprising
2464
+         //   return( expr);       // output as a side effect
2463 2465
          return( parser_do_implicit_set( p, expr, line));
2464 2466
       }
2465 2467
       return( nil);
2466 2468
new file mode 100644
... ...
@@ -0,0 +1,17 @@
1
+//
2
+//  NSObject+KVC_Compatibility.h
3
+//  MulleScion
4
+//
5
+//  Created by Nat! on 07.11.13.
6
+//  Copyright (c) 2013 Mulle kybernetiK. All rights reserved.
7
+//
8
+
9
+#import <Foundation/Foundation.h>
10
+
11
+
12
+@interface NSObject (iOS_KVC_Compatibility)
13
+
14
+- (void) takeValue:(id) value
15
+        forKeyPath:(NSString *) keyPath;
16
+
17
+@end
0 18
new file mode 100644
... ...
@@ -0,0 +1,22 @@
1
+//
2
+//  NSObject+KVC_Compatibility.m
3
+//  MulleScion
4
+//
5
+//  Created by Nat! on 07.11.13.
6
+//  Copyright (c) 2013 Mulle kybernetiK. All rights reserved.
7
+//
8
+
9
+#import "NSObject+iOS_KVC_Compatibility.h"
10
+
11
+
12
+@implementation NSObject (KVC_Compatibility)
13
+
14
+- (void) takeValue:(id) value
15
+        forKeyPath:(NSString *) keyPath
16
+{
17
+   [self setValue:value
18
+       forKeyPath:keyPath];
19
+}
20
+
21
+
22
+@end
0 23
new file mode 100644
... ...
@@ -0,0 +1,6 @@
1
+{%
2
+   dict = @{ 1, @"key" };
3
+   if dict[ @"other" ] == nil
4
+      {{ 1 }}
5
+   endif
6
+%}
0 7
new file mode 100644
... ...
@@ -0,0 +1,4 @@
1
+{% filter htmlEscapedString %}
2
+{% x=filter( @"&"); %}
3
+{% endfilter %}
4
+{{ x = @"&amp;" }}
0 5
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+&amp;
0 2
new file mode 100644
... ...
@@ -0,0 +1 @@
1
+{{ nil == nil }}