Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

More preprocessor additions / fixes.

  • Loading branch information...
commit 1896bc58dbf72e9dc44426e06c1012b7b3a7b382 1 parent 3370e9d
@ccgus authored
View
33 experimental/src/JSTPreprocessor.m
@@ -357,6 +357,8 @@ - (NSString*)description {
[msgSendArgs removeAllObjects];
}
+ BOOL pastSelector = NO;
+
NSMutableString *buf = [NSMutableString stringWithString:@"jst_msgSend("];
[buf appendFormat:@"%@, \"%@\"", target, selector];
@@ -365,29 +367,20 @@ - (NSString*)description {
id arg = [msgSendArgs objectAtIndex:i];
- if ([arg isKindOfClass:[TDToken class]] && ([arg isComment] || [arg isWhitespace])) {
- /*
- if ([arg isComment]) {
- [buf appendString:[arg stringValue]];
- }
- */
- }
- else {
+ if ([arg isKindOfClass:[TDToken class]] && [[arg stringValue] isEqualToString:@","]) {
- if ([arg isKindOfClass:[TDToken class]] && [[arg stringValue] isEqualToString:@","]) {
-
- if (![selector length]) { // looks like it's an array: print([3+4, 5]);
- return [NSString stringWithFormat:@"[%@]", [argsCopy componentsJoinedByString:@""]];
- }
- }
-
- if (arg == selectorWasHere) {
- [buf appendString:@", "];
- }
- else {
- [buf appendString:[arg description]];
+ if (![selector length]) { // looks like it's an array: print([3+4, 5]);
+ return [NSString stringWithFormat:@"[%@]", [argsCopy componentsJoinedByString:@""]];
}
}
+
+ if (arg == selectorWasHere) {
+ [buf appendString:@", "];
+ pastSelector = YES;
+ }
+ else if (pastSelector) {
+ [buf appendString:[arg description]];
+ }
}
[buf appendString:@")"];
View
4 experimental/src/jstalkmain.m
@@ -114,8 +114,8 @@ void testPreprocessAtPath(NSString *pathToScript) {
NSString *r = [JSTPreprocessor preprocessCode:a];
- b = [b stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
- r = [r stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+ b = [[b stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] stringByAppendingString:@"\n"];
+ r = [[r stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] stringByAppendingString:@"\n"];
if (![b isEqualToString:r]) {
NSLog(@"Bad preprocess for %@", pathToScript);
View
2  experimental/tests/preprocess/testPreprocess01.jstpc
@@ -6,4 +6,4 @@ jst_msgSend(NSFullUserName(), "lowercaseString");
print(jst_msgSend(NSString, "stringWithString:", JSTNSString("a")+"b"))
-jst_msgSend(fo, "doSomething:in:", " a "+jst_msgSend(b, "fun")+" c ", null);
+jst_msgSend(fo, "doSomething:in:", " a " + jst_msgSend(b, "fun") + " c " , null);
View
13 experimental/tests/preprocess/testPreprocess02.jstalk
@@ -1,3 +1,14 @@
print([4 - 5, b]);
print([a, b]);
-[NSString string];
+[NSString string];
+
+{
+ var s = @"Hello";
+
+ var f = someFunction([s lowerCaseString], @"Hi");
+}
+
+var s = [NSString stringWithFormat:"%@, %@, %@"
+ newlineVar, /*inline comment*/, fakeVar
+ "test another newline"
+ ];
View
12 experimental/tests/preprocess/testPreprocess02.jstpc
@@ -1,3 +1,15 @@
print([4 - 5, b]);
print([a, b]);
jst_msgSend(NSString, "string");
+
+{
+ var s = JSTNSString("Hello");
+
+ var f = someFunction(jst_msgSend(s, "lowerCaseString"), JSTNSString("Hi"));
+}
+
+var s = jst_msgSend(NSString, "stringWithFormat:", "%@, %@, %@"
+ newlineVar, /*inline comment*/, fakeVar
+ "test another newline"
+ );
+
Please sign in to comment.
Something went wrong with that request. Please try again.