Skip to content
Browse files

More 10.8 BridgeSupport parsing fix

  • Loading branch information...
1 parent 6935da6 commit 9ed345d2d7db5371f5f2ca643762bbe5e6143b3b @parmanoir committed Jul 1, 2012
View
61 JSCocoa/BridgeSupportController.m
@@ -6,6 +6,7 @@
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
+
#import "BridgeSupportController.h"
@@ -88,27 +89,41 @@ - (BOOL)loadBridgeSupport:(NSString*)path
if ((c[1] == 'c' && (c[2] == 'o' || c[2] == 'l')) || c[1] == 'e' || (c[1] == 'f' && c[2] == 'u') || (c[1] == 's' && c[2] == 't'))
{
char* tagStart;
- char* c0;
+ char* cN; // cN = char starting attribute's name, cV = char starting attribute's value
+ char* cV;
+ BOOL hasName = NO;
+ id name = nil;
tagStart = c;
-parsename:
- // Extract name
- for (; *c && *c != '\''; c++);
+
+ // Skip XML tag name by skipping until the first space
+ for (; *c && *c != ' '; c++);
+ // Skip space
c++;
- c0 = c;
- for (; *c && *c != '\''; c++);
- // 10.8 : 'name' might not be the first attribute in structures. Go back up to find it.
- if (*c0 == '{') {
- // Skip '
+ // Scour attributes until we find the name
+ while (!hasName && *c) {
+ // Skip spaces to attribute name
+ for (; *c && *c == ' '; c++);
+ cN = c;
+ // Skip attribute name until '
+ for (; *c && *c != '\''; c++);
c++;
- if (!*c)
- return NSLog(@"No name in bridgesupport"), NO;
- goto parsename;
+ cV = c;
+ // Skip to the end of the attribute value
+ for (; *c && *c != '\''; c++);
+
+ if (cN[0] == 'n' && cN[1] == 'a') {
+ hasName = YES;
+ name = [[NSString alloc] initWithBytes:cV length:c-cV encoding:NSUTF8StringEncoding];
+ }
+ else
+ // Skip attribute closing '
+ c++;
}
-
- id name = [[NSString alloc] initWithBytes:c0 length:c-c0 encoding:NSUTF8StringEncoding];
-
+ if (!hasName)
+ return NSLog(@"(loadBridgeSupport) Parsing failed to get name in file %@", path), NO;
+
// Move to tag end
BOOL foundEndTag = NO;
BOOL foundOpenTag = NO;
@@ -140,14 +155,14 @@ - (BOOL)loadBridgeSupport:(NSString*)path
if (strncmp(c, "variadic", 8) == 0)
{
// Skip back to tag start
- c0 = c;
- for (; *c0 != '<'; c0--);
+ cV = c;
+ for (; *cV != '<'; cV--);
// Tag name starts with 'm' : variadic method
// <method variadic='true' selector='alertWithMessageText:defaultButton:alternateButton:otherButton:informativeTextWithFormat:' class_method='true'>
- if (c0[1] == 'm')
+ if (cV[1] == 'm')
{
- c = c0;
+ c = cV;
id variadicMethodName = nil;
// Extract selector name
for (; *c != '>'; c++)
@@ -156,9 +171,9 @@ - (BOOL)loadBridgeSupport:(NSString*)path
{
for (; *c && *c != '\''; c++);
c++;
- c0 = c;
+ cV = c;
for (; *c && *c != '\''; c++);
- variadicMethodName = [[[NSString alloc] initWithBytes:c0 length:c-c0 encoding:NSUTF8StringEncoding] autorelease];
+ variadicMethodName = [[[NSString alloc] initWithBytes:cV length:c-cV encoding:NSUTF8StringEncoding] autorelease];
}
}
[variadicSelectors setValue:@"true" forKey:variadicMethodName];
@@ -175,8 +190,8 @@ - (BOOL)loadBridgeSupport:(NSString*)path
}
}
- c0 = tagStart;
- id value = [[NSString alloc] initWithBytes:c0 length:c-c0 encoding:NSUTF8StringEncoding];
+ cV = tagStart;
+ id value = [[NSString alloc] initWithBytes:cV length:c-cV encoding:NSUTF8StringEncoding];
[hash setValue:value forKey:name];
[value release];
View
5 Tests/58 manual BridgeSupport.js
@@ -12,3 +12,8 @@
if (Math.round(c.b) != 3) throw 'Manual bridgesupport failed (3)'
if (Math.round(c.a) != 4) throw 'Manual bridgesupport failed (4)'
+ if (NSCompositeCopy1 != 123) throw 'Manual bridgesupport failed (5)'
+ if (NSCompositeCopy2 != 456) throw 'Manual bridgesupport failed (6)'
+
+ if (NSToolbarPrintItemIdentifier1 != 'printItemIdentifier1') throw 'Manual bridgesupport failed (7)'
+ if (NSToolbarPrintItemIdentifier2 != 'printItemIdentifier2') throw 'Manual bridgesupport failed (8)'
View
4 Tests/Resources/58 manual BridgeSupport.bridgesupport
@@ -14,4 +14,8 @@
<field name='b' declared_type='GLfloat' type='f'/>
<field name='a' declared_type='GLfloat' type='f'/>
</struct>
+<enum name='NSCompositeCopy1' value='123'/>
+<enum value='456' var1='1' var2='2' var3='3' var4='4' name='NSCompositeCopy2' var5='5' />
+<constant name='NSToolbarPrintItemIdentifier1' type='@'/>
+<constant type='@' name='NSToolbarPrintItemIdentifier2'/>
</signatures>
View
8 TestsRunner/ApplicationController.h
@@ -93,3 +93,11 @@ struct ccColor4F {
typedef struct ccColor4F ccColor4F;
__declspec(export) extern ccColor4F ccc4f(const GLfloat r, const GLfloat g, const GLfloat b, const GLfloat a);
+
+#define EXPORT __attribute__((visibility("default")))
+EXPORT NSString* NSToolbarPrintItemIdentifier1;
+EXPORT NSString* NSToolbarPrintItemIdentifier2;
+
+
+
+
View
8 TestsRunner/ApplicationController.m
@@ -39,6 +39,11 @@ - (void)applicationDidFinishLaunching:(NSNotification *)notification
NSLog(@"*** Running %@ ***", [JSCocoa runningArchitecture]);
+ // Test 58
+ // Test custom symbols, immediate NSStrings exported via BridgeSupport
+ NSToolbarPrintItemIdentifier1 = @"printItemIdentifier1";
+ NSToolbarPrintItemIdentifier2 = @"printItemIdentifier2";
+
/*
[self cycleContext];
NSLog(@"%d", [jsc retainCount]);
@@ -1179,7 +1184,6 @@ + (void)testFunction:(void (^)(NSError *))theBlock {
//
//
-#define EXPORT __attribute__((visibility("default")))
EXPORT ccColor4F ccc4f(const GLfloat r, const GLfloat g, const GLfloat b, const GLfloat a)
{
@@ -1188,3 +1192,5 @@ EXPORT ccColor4F ccc4f(const GLfloat r, const GLfloat g, const GLfloat b, const
}
+
+
View
BIN ....xcodeproj/project.xcworkspace/xcuserdata/mini.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.

0 comments on commit 9ed345d

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