Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用luaoc.callStaticMethod调用Objective-C方法时报错not support return type #547

Open
1901 opened this issue Nov 2, 2015 · 0 comments

Comments

@1901
Copy link

1901 commented Nov 2, 2015

使用luaoc.callStaticMethod调用Objective-C方法时,如果Objective-C方法的返回值是BOOL类型,会报not support return type

可将文件CCLuaObjcBridge.mm做出如下修改修复这个问题:

From 0efe9a4d03308499d3b26aa40460539fa1619ba8 Mon Sep 17 00:00:00 2001
From: kaixuan <[email protected]>
Date: Mon, 26 Oct 2015 22:05:03 +0800
Subject: [PATCH] =?UTF-8?q?[ios]=20=E4=BF=AE=E5=A4=8D=E8=B0=83=E7=94=A8OC?=
 =?UTF-8?q?=E6=96=B9=E6=B3=95=E6=97=B6=E8=8E=B7=E5=8F=96BOOL=E7=B1=BB?=
 =?UTF-8?q?=E5=9E=8B=E8=BF=94=E5=9B=9E=E5=80=BC=E5=87=BA=E9=94=99=E7=9A=84?=
 =?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../scripting/lua/cocos2dx_support/platform/ios/CCLuaObjcBridge.mm  | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/cocos2d-x/scripting/lua/cocos2dx_support/platform/ios/CCLuaObjcBridge.mm b/lib/cocos2d-x/scripting/lua/cocos2dx_support/platform/ios/CCLuaObjcBridge.mm
index cd3457d..885d21f 100755
--- a/lib/cocos2d-x/scripting/lua/cocos2dx_support/platform/ios/CCLuaObjcBridge.mm
+++ b/lib/cocos2d-x/scripting/lua/cocos2dx_support/platform/ios/CCLuaObjcBridge.mm
@@ -205,19 +205,19 @@ int CCLuaObjcBridge::callObjcStaticMethod(lua_State *L)
                 [invocation getReturnValue:&ret];
                 pushValue(L, ret);
             }
-            else if (strcmp(returnType, "c") == 0) // BOOL
+            else if (strcmp(returnType, @encode(BOOL)) == 0 || strcmp(returnType, @encode(bool)) == 0) // BOOL
             {
                 char ret;
                 [invocation getReturnValue:&ret];
                 lua_pushboolean(L, ret);
             }
-            else if (strcmp(returnType, "i") == 0) // int
+            else if (strcmp(returnType, @encode(int)) == 0) // int
             {
                 int ret;
                 [invocation getReturnValue:&ret];
                 lua_pushinteger(L, ret);
             }
-            else if (strcmp(returnType, "f") == 0) // float
+            else if (strcmp(returnType, @encode(float)) == 0) // float
             {
                 float ret;
                 [invocation getReturnValue:&ret];
-- 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant