From c3bf763f8d01fb226a47481648e72124130f0b5c Mon Sep 17 00:00:00 2001 From: finscn Date: Thu, 22 Sep 2016 15:45:54 +0800 Subject: [PATCH] Return Error localizedDescription , not boolean. Return Error localizedDescription , not boolean. It's more useful then true or false. And if no error , return null (like Node Callback Style) --- Source/Ejecta/EJUtils/EJBindingGameCenter.m | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Source/Ejecta/EJUtils/EJBindingGameCenter.m b/Source/Ejecta/EJUtils/EJBindingGameCenter.m index 8c862096..6d2be280 100644 --- a/Source/Ejecta/EJUtils/EJBindingGameCenter.m +++ b/Source/Ejecta/EJUtils/EJBindingGameCenter.m @@ -232,13 +232,14 @@ - (void)reportAchievementWithIdentifier:(NSString *)identifier #define InvokeAndUnprotectCallback(callback, error, object) \ + JSContextRef _gctx = scriptView.jsGlobalContext; \ [scriptView invokeCallback:callback thisObject:NULL argc:2 argv: \ (JSValueRef[]){ \ - JSValueMakeBoolean(scriptView.jsGlobalContext, error), \ - (object ? NSObjectToJSValue(scriptView.jsGlobalContext, object) : scriptView->jsUndefined) \ + error ? NSStringToJSValue(_gctx, error.localizedDescription) : JSValueMakeNull(_gctx), \ + (object ? NSObjectToJSValue(_gctx, object) : scriptView->jsUndefined) \ } \ ]; \ - JSValueUnprotect(scriptView.jsGlobalContext, callback); + JSValueUnprotect(_gctx, callback); #define ExitWithCallbackOnError(callback, error) \ if( error ) { \