Skip to content

Commit 14d1735

Browse files
committed
Merge upstream changes by newyankeecodeshop
2 parents d096197 + 9ef8ad7 commit 14d1735

2 files changed

Lines changed: 21 additions & 8 deletions

File tree

Classes/GAScriptEngine.m

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
2929
#import "GAScriptEngine.h"
3030
#import "GAScriptObject.h"
3131
#import "GAScriptBlockObject.h"
32+
#import "GADebugMacros.h"
3233
#import "NSObject+GAJavaScript.h"
3334

3435
static NSNumberFormatter* kNumFormatter = nil;
@@ -335,12 +336,14 @@ - (void)makeLotsaCalls
335336
//
336337
GAScriptBlock theBlock = [m_blocks objectForKey:invName];
337338

338-
if (theBlock)
339-
{
340-
theBlock(arguments);
339+
if (!theBlock) {
340+
GADebugStr(@"No GAScriptBlock found for %@", invName);
341+
continue;
341342
}
343+
344+
theBlock(arguments);
342345
}
343-
}
346+
}
344347
}
345348

346349
- (void)callReceiversForSelector:(SEL)theSelector withArguments:(NSArray *)arguments

Classes/GAScriptObject.m

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,24 @@ - (id)callFunction:(NSString *)functionName
139139
}
140140

141141
- (id)callFunction:(NSString *)functionName withObject:(id)argument
142-
{
143-
return [m_engine evalWithFormat:@"GAJavaScript.callFunction(%@.%@, %@, [%@])",
142+
{
143+
if ([argument isKindOfClass:[GAScriptBlockObject class]]) {
144+
[m_engine addBlockCallback:argument];
145+
}
146+
147+
return [m_engine evalWithFormat:@"GAJavaScript.callFunction(%@.%@, %@, [%@])",
144148
m_objReference, functionName, m_objReference, [argument stringForJavaScript]];
145149
}
146150

147151
- (id)callFunction:(NSString *)functionName withArguments:(NSArray *)arguments
148-
{
149-
return [m_engine evalWithFormat:@"GAJavaScript.callFunction(%@.%@, %@, %@)",
152+
{
153+
for (id arg in arguments) {
154+
if ([arg isKindOfClass:[GAScriptBlockObject class]]) {
155+
[m_engine addBlockCallback:arg];
156+
}
157+
}
158+
159+
return [m_engine evalWithFormat:@"GAJavaScript.callFunction(%@.%@, %@, %@)",
150160
m_objReference, functionName, m_objReference, [arguments stringForJavaScript]];
151161
}
152162

0 commit comments

Comments
 (0)