From d4dbc7a4424992d5bb308ea4ae08691e635a5ad1 Mon Sep 17 00:00:00 2001 From: samuele3 Date: Sun, 10 Nov 2013 09:21:33 +0800 Subject: [PATCH 1/2] Add conversion config for long type --- .../lua/bindings/LuaBasicConversions.cpp | 24 +++++++++++++++++++ .../lua/bindings/LuaBasicConversions.h | 1 + tools/bindings-generator | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp index 1914d3a930..4c91daa42b 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.cpp +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.cpp @@ -283,6 +283,30 @@ bool luaval_to_point(lua_State* L,int lo,Point* outValue) return ok; } +bool luaval_to_long(lua_State* L,int lo, long* outValue) +{ + if (NULL == L || NULL == outValue) + return false; + + bool ok = true; + + tolua_Error tolua_err; + if (!tolua_isnumber(L,lo,0,&tolua_err)) + { +#if COCOS2D_DEBUG >=1 + luaval_to_native_err(L,"#ferror:",&tolua_err); +#endif + ok = false; + } + + if (ok) + { + *outValue = (long)tolua_tonumber(L, lo, 0); + } + + return ok; +} + bool luaval_to_size(lua_State* L,int lo,Size* outValue) { if (NULL == L || NULL == outValue) diff --git a/cocos/scripting/lua/bindings/LuaBasicConversions.h b/cocos/scripting/lua/bindings/LuaBasicConversions.h index 20167170df..2e2e525993 100644 --- a/cocos/scripting/lua/bindings/LuaBasicConversions.h +++ b/cocos/scripting/lua/bindings/LuaBasicConversions.h @@ -30,6 +30,7 @@ extern bool luaval_to_boolean(lua_State* L,int lo,bool* outValue); extern bool luaval_to_number(lua_State* L,int lo,double* outValue); extern bool luaval_to_long_long(lua_State* L,int lo,long long* outValue); extern bool luaval_to_std_string(lua_State* L, int lo, std::string* outValue); +extern bool luaval_to_long(lua_State* L,int lo, long* outValue); extern bool luaval_to_point(lua_State* L,int lo,Point* outValue); extern bool luaval_to_size(lua_State* L,int lo,Size* outValue); diff --git a/tools/bindings-generator b/tools/bindings-generator index d41959ab0b..bf34fb73c4 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit d41959ab0b15c20aa0802ab5c9ef92be7b742bd4 +Subproject commit bf34fb73c4adece7b0c8194aa8ab57c5ce60fc58 From fa1a5c3735b122b145d08e3563e234257421c741 Mon Sep 17 00:00:00 2001 From: samuele3 Date: Sun, 10 Nov 2013 11:03:27 +0800 Subject: [PATCH 2/2] Add conversion config for long type --- tools/bindings-generator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/bindings-generator b/tools/bindings-generator index bf34fb73c4..7ccbabbaa6 160000 --- a/tools/bindings-generator +++ b/tools/bindings-generator @@ -1 +1 @@ -Subproject commit bf34fb73c4adece7b0c8194aa8ab57c5ce60fc58 +Subproject commit 7ccbabbaa677607048c511b33cb6d83b2081220e