Merge pull request #11501 from samuele3hu/v3_studio2

Add Lua bindings for WebView and related test case
This commit is contained in:
minggo 2015-04-20 13:36:08 +08:00
commit fc16bc6154
16 changed files with 1242 additions and 18 deletions

View File

@ -42,6 +42,8 @@
1502702E1AD3BDC90089CD03 /* TerrainTest in Resources */ = {isa = PBXBuildFile; fileRef = B603F1B31AC8FBFB00A9579C /* TerrainTest */; };
150F918819DA409E00B89F57 /* lua_test_bindings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 150F918619DA409E00B89F57 /* lua_test_bindings.cpp */; };
150F918919DA409F00B89F57 /* lua_test_bindings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 150F918619DA409E00B89F57 /* lua_test_bindings.cpp */; };
1531B2501AE013DE0075DB94 /* Test.html in Resources */ = {isa = PBXBuildFile; fileRef = 29AFEF6619ACCAA000F6B10A /* Test.html */; };
1531B2511AE013F00075DB94 /* Test.html in Resources */ = {isa = PBXBuildFile; fileRef = 29AFEF6619ACCAA000F6B10A /* Test.html */; };
15427B79198B879900DC375D /* libluacocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 15EFA665198B33EE000C57D3 /* libluacocos2d iOS.a */; };
15427B7A198B87AA00DC375D /* libcocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FBE1807A4F9005B8026 /* libcocos2d iOS.a */; };
15427B7D198B880100DC375D /* lua_cocos2dx_controller_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15427B7B198B880100DC375D /* lua_cocos2dx_controller_manual.cpp */; };
@ -4378,6 +4380,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1531B2501AE013DE0075DB94 /* Test.html in Resources */,
1502702E1AD3BDC90089CD03 /* TerrainTest in Resources */,
157B08EC1A90864100B7BEA4 /* Particle3D in Resources */,
15B13E5219F0FD4D008A1ADC /* Manifests in Resources */,
@ -4424,6 +4427,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
1531B2511AE013F00075DB94 /* Test.html in Resources */,
1502702D1AD3BDBC0089CD03 /* TerrainTest in Resources */,
157B08ED1A90865600B7BEA4 /* Particle3D in Resources */,
15B3709A19EE5EED00ABE682 /* Manifests in Resources */,

View File

@ -0,0 +1,734 @@
#include "lua_cocos2dx_experimental_webview_auto.hpp"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
#include "UIWebView.h"
#include "tolua_fix.h"
#include "LuaBasicConversions.h"
int lua_cocos2dx_experimental_webview_WebView_loadURL(lua_State* tolua_S)
{
int argc = 0;
cocos2d::experimental::ui::WebView* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_loadURL'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.WebView:loadURL");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_loadURL'", nullptr);
return 0;
}
cobj->loadURL(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:loadURL",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_loadURL'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_experimental_webview_WebView_canGoBack(lua_State* tolua_S)
{
int argc = 0;
cocos2d::experimental::ui::WebView* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_canGoBack'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_canGoBack'", nullptr);
return 0;
}
bool ret = cobj->canGoBack();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:canGoBack",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_canGoBack'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_experimental_webview_WebView_loadHTMLString(lua_State* tolua_S)
{
int argc = 0;
cocos2d::experimental::ui::WebView* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_loadHTMLString'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.WebView:loadHTMLString");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_loadHTMLString'", nullptr);
return 0;
}
cobj->loadHTMLString(arg0);
lua_settop(tolua_S, 1);
return 1;
}
if (argc == 2)
{
std::string arg0;
std::string arg1;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.WebView:loadHTMLString");
ok &= luaval_to_std_string(tolua_S, 3,&arg1, "ccexp.WebView:loadHTMLString");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_loadHTMLString'", nullptr);
return 0;
}
cobj->loadHTMLString(arg0, arg1);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:loadHTMLString",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_loadHTMLString'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_experimental_webview_WebView_goForward(lua_State* tolua_S)
{
int argc = 0;
cocos2d::experimental::ui::WebView* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_goForward'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_goForward'", nullptr);
return 0;
}
cobj->goForward();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:goForward",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_goForward'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_experimental_webview_WebView_goBack(lua_State* tolua_S)
{
int argc = 0;
cocos2d::experimental::ui::WebView* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_goBack'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_goBack'", nullptr);
return 0;
}
cobj->goBack();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:goBack",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_goBack'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_experimental_webview_WebView_setJavascriptInterfaceScheme(lua_State* tolua_S)
{
int argc = 0;
cocos2d::experimental::ui::WebView* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_setJavascriptInterfaceScheme'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.WebView:setJavascriptInterfaceScheme");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_setJavascriptInterfaceScheme'", nullptr);
return 0;
}
cobj->setJavascriptInterfaceScheme(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:setJavascriptInterfaceScheme",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_setJavascriptInterfaceScheme'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_experimental_webview_WebView_evaluateJS(lua_State* tolua_S)
{
int argc = 0;
cocos2d::experimental::ui::WebView* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_evaluateJS'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.WebView:evaluateJS");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_evaluateJS'", nullptr);
return 0;
}
cobj->evaluateJS(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:evaluateJS",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_evaluateJS'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_experimental_webview_WebView_getOnJSCallback(lua_State* tolua_S)
{
int argc = 0;
cocos2d::experimental::ui::WebView* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_getOnJSCallback'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_getOnJSCallback'", nullptr);
return 0;
}
cocos2d::experimental::ui::WebView::ccWebViewCallback ret = cobj->getOnJSCallback();
#pragma warning NO CONVERSION FROM NATIVE FOR std::function;
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:getOnJSCallback",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_getOnJSCallback'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_experimental_webview_WebView_reload(lua_State* tolua_S)
{
int argc = 0;
cocos2d::experimental::ui::WebView* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_reload'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_reload'", nullptr);
return 0;
}
cobj->reload();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:reload",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_reload'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_experimental_webview_WebView_setScalesPageToFit(lua_State* tolua_S)
{
int argc = 0;
cocos2d::experimental::ui::WebView* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_setScalesPageToFit'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
bool arg0;
ok &= luaval_to_boolean(tolua_S, 2,&arg0, "ccexp.WebView:setScalesPageToFit");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_setScalesPageToFit'", nullptr);
return 0;
}
cobj->setScalesPageToFit(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:setScalesPageToFit",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_setScalesPageToFit'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_experimental_webview_WebView_canGoForward(lua_State* tolua_S)
{
int argc = 0;
cocos2d::experimental::ui::WebView* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_canGoForward'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_canGoForward'", nullptr);
return 0;
}
bool ret = cobj->canGoForward();
tolua_pushboolean(tolua_S,(bool)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:canGoForward",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_canGoForward'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_experimental_webview_WebView_loadFile(lua_State* tolua_S)
{
int argc = 0;
cocos2d::experimental::ui::WebView* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_loadFile'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 1)
{
std::string arg0;
ok &= luaval_to_std_string(tolua_S, 2,&arg0, "ccexp.WebView:loadFile");
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_loadFile'", nullptr);
return 0;
}
cobj->loadFile(arg0);
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:loadFile",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_loadFile'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_experimental_webview_WebView_stopLoading(lua_State* tolua_S)
{
int argc = 0;
cocos2d::experimental::ui::WebView* cobj = nullptr;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertype(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror;
#endif
cobj = (cocos2d::experimental::ui::WebView*)tolua_tousertype(tolua_S,1,0);
#if COCOS2D_DEBUG >= 1
if (!cobj)
{
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_experimental_webview_WebView_stopLoading'", nullptr);
return 0;
}
#endif
argc = lua_gettop(tolua_S)-1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_stopLoading'", nullptr);
return 0;
}
cobj->stopLoading();
lua_settop(tolua_S, 1);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d \n", "ccexp.WebView:stopLoading",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_stopLoading'.",&tolua_err);
#endif
return 0;
}
int lua_cocos2dx_experimental_webview_WebView_create(lua_State* tolua_S)
{
int argc = 0;
bool ok = true;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
#endif
#if COCOS2D_DEBUG >= 1
if (!tolua_isusertable(tolua_S,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror;
#endif
argc = lua_gettop(tolua_S) - 1;
if (argc == 0)
{
if(!ok)
{
tolua_error(tolua_S,"invalid arguments in function 'lua_cocos2dx_experimental_webview_WebView_create'", nullptr);
return 0;
}
cocos2d::experimental::ui::WebView* ret = cocos2d::experimental::ui::WebView::create();
object_to_luaval<cocos2d::experimental::ui::WebView>(tolua_S, "ccexp.WebView",(cocos2d::experimental::ui::WebView*)ret);
return 1;
}
luaL_error(tolua_S, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.WebView:create",argc, 0);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_experimental_webview_WebView_create'.",&tolua_err);
#endif
return 0;
}
static int lua_cocos2dx_experimental_webview_WebView_finalize(lua_State* tolua_S)
{
printf("luabindings: finalizing LUA object (WebView)");
return 0;
}
int lua_register_cocos2dx_experimental_webview_WebView(lua_State* tolua_S)
{
tolua_usertype(tolua_S,"ccexp.WebView");
tolua_cclass(tolua_S,"WebView","ccexp.WebView","ccui.Widget",nullptr);
tolua_beginmodule(tolua_S,"WebView");
tolua_function(tolua_S,"loadURL",lua_cocos2dx_experimental_webview_WebView_loadURL);
tolua_function(tolua_S,"canGoBack",lua_cocos2dx_experimental_webview_WebView_canGoBack);
tolua_function(tolua_S,"loadHTMLString",lua_cocos2dx_experimental_webview_WebView_loadHTMLString);
tolua_function(tolua_S,"goForward",lua_cocos2dx_experimental_webview_WebView_goForward);
tolua_function(tolua_S,"goBack",lua_cocos2dx_experimental_webview_WebView_goBack);
tolua_function(tolua_S,"setJavascriptInterfaceScheme",lua_cocos2dx_experimental_webview_WebView_setJavascriptInterfaceScheme);
tolua_function(tolua_S,"evaluateJS",lua_cocos2dx_experimental_webview_WebView_evaluateJS);
tolua_function(tolua_S,"getOnJSCallback",lua_cocos2dx_experimental_webview_WebView_getOnJSCallback);
tolua_function(tolua_S,"reload",lua_cocos2dx_experimental_webview_WebView_reload);
tolua_function(tolua_S,"setScalesPageToFit",lua_cocos2dx_experimental_webview_WebView_setScalesPageToFit);
tolua_function(tolua_S,"canGoForward",lua_cocos2dx_experimental_webview_WebView_canGoForward);
tolua_function(tolua_S,"loadFile",lua_cocos2dx_experimental_webview_WebView_loadFile);
tolua_function(tolua_S,"stopLoading",lua_cocos2dx_experimental_webview_WebView_stopLoading);
tolua_function(tolua_S,"create", lua_cocos2dx_experimental_webview_WebView_create);
tolua_endmodule(tolua_S);
std::string typeName = typeid(cocos2d::experimental::ui::WebView).name();
g_luaType[typeName] = "ccexp.WebView";
g_typeCast["WebView"] = "ccexp.WebView";
return 1;
}
TOLUA_API int register_all_cocos2dx_experimental_webview(lua_State* tolua_S)
{
tolua_open(tolua_S);
tolua_module(tolua_S,"ccexp",0);
tolua_beginmodule(tolua_S,"ccexp");
lua_register_cocos2dx_experimental_webview_WebView(tolua_S);
tolua_endmodule(tolua_S);
return 1;
}
#endif

View File

@ -0,0 +1,32 @@
#include "base/ccConfig.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
#ifndef __cocos2dx_experimental_webview_h__
#define __cocos2dx_experimental_webview_h__
#ifdef __cplusplus
extern "C" {
#endif
#include "tolua++.h"
#ifdef __cplusplus
}
#endif
int register_all_cocos2dx_experimental_webview(lua_State* tolua_S);
#endif // __cocos2dx_experimental_webview_h__
#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)

View File

@ -0,0 +1,190 @@
#include "lua_cocos2dx_experimental_video_manual.hpp"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#include "UIWebView.h"
#include "tolua_fix.h"
#include "LuaBasicConversions.h"
#include "CCLuaValue.h"
#include "CCLuaEngine.h"
static int lua_cocos2dx_experimental_WebView_setOnShouldStartLoading(lua_State* L)
{
int argc = 0;
cocos2d::experimental::ui::WebView* self = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(L,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror;
#endif
self = static_cast<cocos2d::experimental::ui::WebView*>(tolua_tousertype(L,1,0));
#if COCOS2D_DEBUG >= 1
if (nullptr == self) {
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_experimental_WebView_setOnShouldStartLoading'\n", nullptr);
return 0;
}
#endif
argc = lua_gettop(L) - 1;
if (argc == 1)
{
#if COCOS2D_DEBUG >= 1
if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err))
{
goto tolua_lerror;
}
#endif
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
std::function<bool(experimental::ui::WebView *sender, const std::string &url)> callback = [L,handler](experimental::ui::WebView *sender, const std::string &url)->bool{
toluafix_pushusertype_ccobject(L, sender->_ID, &(sender->_luaID), (void*)sender,"ccexp.WebView");
tolua_pushcppstring(L, url);
return LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
};
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
self->setOnShouldStartLoading(callback);
return 0;
}
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.WebView:setOnShouldStartLoading",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(L, "#ferror in function 'lua_cocos2dx_experimental_WebView_setOnShouldStartLoading'.", &tolua_err);
#endif
return 0;
}
static int lua_cocos2dx_experimental_WebView_setOnDidFinishLoading(lua_State* L)
{
int argc = 0;
cocos2d::experimental::ui::WebView* self = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(L,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror;
#endif
self = static_cast<cocos2d::experimental::ui::WebView*>(tolua_tousertype(L,1,0));
#if COCOS2D_DEBUG >= 1
if (nullptr == self) {
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_experimental_WebView_setOnDidFinishLoading'\n", nullptr);
return 0;
}
#endif
argc = lua_gettop(L) - 1;
if (argc == 1)
{
#if COCOS2D_DEBUG >= 1
if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err))
{
goto tolua_lerror;
}
#endif
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
std::function<void(experimental::ui::WebView *sender, const std::string &url)> callback = [L,handler](experimental::ui::WebView *sender, const std::string &url){
toluafix_pushusertype_ccobject(L, sender->_ID, &(sender->_luaID), (void*)sender,"ccexp.WebView");
tolua_pushcppstring(L, url);
LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
};
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
self->setOnDidFinishLoading(callback);
return 0;
}
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.WebView:setOnDidFinishLoading",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(L, "#ferror in function 'lua_cocos2dx_experimental_WebView_setOnDidFinishLoading'.", &tolua_err);
#endif
return 0;
}
static int lua_cocos2dx_experimental_WebView_setOnDidFailLoading(lua_State* L)
{
int argc = 0;
cocos2d::experimental::ui::WebView* self = nullptr;
#if COCOS2D_DEBUG >= 1
tolua_Error tolua_err;
if (!tolua_isusertype(L,1,"ccexp.WebView",0,&tolua_err)) goto tolua_lerror;
#endif
self = static_cast<cocos2d::experimental::ui::WebView*>(tolua_tousertype(L,1,0));
#if COCOS2D_DEBUG >= 1
if (nullptr == self) {
tolua_error(L,"invalid 'self' in function 'lua_cocos2dx_experimental_WebView_setOnDidFailLoading'\n", nullptr);
return 0;
}
#endif
argc = lua_gettop(L) - 1;
if (argc == 1)
{
#if COCOS2D_DEBUG >= 1
if (!toluafix_isfunction(L,2,"LUA_FUNCTION",0,&tolua_err))
{
goto tolua_lerror;
}
#endif
LUA_FUNCTION handler = ( toluafix_ref_function(L,2,0));
std::function<void(experimental::ui::WebView *sender, const std::string &url)> callback = [L,handler](experimental::ui::WebView *sender, const std::string &url){
toluafix_pushusertype_ccobject(L, sender->_ID, &(sender->_luaID), (void*)sender,"ccexp.WebView");
tolua_pushcppstring(L, url);
LuaEngine::getInstance()->getLuaStack()->executeFunctionByHandler(handler, 2);
};
ScriptHandlerMgr::getInstance()->addCustomHandler((void*)self, handler);
self->setOnDidFinishLoading(callback);
return 0;
}
luaL_error(L, "%s has wrong number of arguments: %d, was expecting %d\n ", "ccexp.WebView:setOnDidFailLoading",argc, 1);
return 0;
#if COCOS2D_DEBUG >= 1
tolua_lerror:
tolua_error(L, "#ferror in function 'lua_cocos2dx_experimental_WebView_setOnDidFailLoading'.", &tolua_err);
#endif
return 0;
}
static void extendWebView(lua_State* L)
{
lua_pushstring(L, "ccexp.WebView");
lua_rawget(L, LUA_REGISTRYINDEX);
if (lua_istable(L,-1))
{
tolua_function(L, "setOnShouldStartLoading", lua_cocos2dx_experimental_WebView_setOnShouldStartLoading);
tolua_function(L, "setOnDidFinishLoading", lua_cocos2dx_experimental_WebView_setOnDidFinishLoading);
tolua_function(L, "setOnDidFailLoading", lua_cocos2dx_experimental_WebView_setOnDidFailLoading);
}
lua_pop(L, 1);
}
int register_all_cocos2dx_experimental_webview_manual(lua_State* L)
{
if (nullptr == L)
return 0;
extendWebView(L);
return 0;
}
#endif

View File

@ -0,0 +1,41 @@
/****************************************************************************
Copyright (c) 2013-2014 Chukong Technologies Inc.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "base/ccConfig.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_EXPERIMENTAL_WEBVIEW_MANUAL_H
#define COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_EXPERIMENTAL_WEBVIEW_MANUAL_H
#ifdef __cplusplus
extern "C" {
#endif
#include "tolua++.h"
#ifdef __cplusplus
}
#endif
TOLUA_API int register_all_cocos2dx_experimental_webview_manual(lua_State* L);
#endif //#ifndef COCOS_SCRIPTING_LUA_BINDINGS_LUA_COCOS2DX_EXPERIMENTAL_WEBVIEW_MANUAL_H
#endif //#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)

View File

@ -26,6 +26,8 @@
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#include "lua_cocos2dx_experimental_video_auto.hpp"
#include "lua_cocos2dx_experimental_video_manual.hpp"
#include "lua_cocos2dx_experimental_webview_auto.hpp"
#include "lua_cocos2dx_experimental_webview_manual.hpp"
#endif
#include "cocos2d.h"
#include "tolua_fix.h"
@ -1045,6 +1047,8 @@ int register_ui_moudle(lua_State* L)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
register_all_cocos2dx_experimental_video(L);
register_all_cocos2dx_experimental_video_manual(L);
register_all_cocos2dx_experimental_webview(L);
register_all_cocos2dx_experimental_webview_manual(L);
#endif
extendEventListenerFocusEvent(L);
}

View File

@ -105,10 +105,12 @@ LOCAL_SRC_FILES += ../manual/spine/lua_cocos2dx_spine_manual.cpp \
../auto/lua_cocos2dx_spine_auto.cpp
#ui
LOCAL_SRC_FILES += ../manual/ui/lua_cocos2dx_experimental_video_manual.cpp \
LOCAL_SRC_FILES += ../manual/ui/lua_cocos2dx_experimental_webview_manual.cpp \
../manual/ui/lua_cocos2dx_experimental_video_manual.cpp \
../manual/ui/lua_cocos2dx_ui_manual.cpp \
../auto/lua_cocos2dx_experimental_video_auto.cpp \
../auto/lua_cocos2dx_ui_auto.cpp
../auto/lua_cocos2dx_ui_auto.cpp \
../auto/lua_cocos2dx_experimental_webview_auto.cpp
#extension
LOCAL_SRC_FILES += ../manual/extension/lua_cocos2dx_extension_manual.cpp \

View File

@ -201,6 +201,10 @@
15C1C2EC19874CBE00A46ACC /* LuaBasicConversions.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AACE77F18BC45C200215002 /* LuaBasicConversions.h */; };
15C1C2ED19874CBE00A46ACC /* CCLuaObjcBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AACE78E18BC45C200215002 /* CCLuaObjcBridge.h */; };
15C1C2EE19874CBE00A46ACC /* tolua_fix.h in Headers */ = {isa = PBXBuildFile; fileRef = 1AACE7B418BC45C200215002 /* tolua_fix.h */; };
15C9A10E1AE4972500C15443 /* lua_cocos2dx_experimental_webview_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15C9A10C1AE4972500C15443 /* lua_cocos2dx_experimental_webview_auto.cpp */; };
15C9A10F1AE4972500C15443 /* lua_cocos2dx_experimental_webview_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 15C9A10D1AE4972500C15443 /* lua_cocos2dx_experimental_webview_auto.hpp */; };
15C9A1121AE4973400C15443 /* lua_cocos2dx_experimental_webview_manual.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15C9A1101AE4973400C15443 /* lua_cocos2dx_experimental_webview_manual.cpp */; };
15C9A1131AE4973400C15443 /* lua_cocos2dx_experimental_webview_manual.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 15C9A1111AE4973400C15443 /* lua_cocos2dx_experimental_webview_manual.hpp */; };
15EFA1F61989E528000C57D3 /* lua_cocos2dx_experimental_auto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 15622967197780DE009C9067 /* lua_cocos2dx_experimental_auto.cpp */; };
15EFA1F71989E582000C57D3 /* lua_cocos2dx_experimental_auto.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 15622968197780DE009C9067 /* lua_cocos2dx_experimental_auto.hpp */; };
15EFA5D9198B2DAA000C57D3 /* libluajit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1ABCA1F318CD8F540087CE3A /* libluajit.a */; };
@ -351,6 +355,10 @@
15C1C24F198747E400A46ACC /* LuaOpengl.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LuaOpengl.cpp; sourceTree = "<group>"; };
15C1C250198747E400A46ACC /* LuaOpengl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LuaOpengl.h; sourceTree = "<group>"; };
15C1C2CC198748D200A46ACC /* libluacocos2d Mac.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libluacocos2d Mac.a"; sourceTree = BUILT_PRODUCTS_DIR; };
15C9A10C1AE4972500C15443 /* lua_cocos2dx_experimental_webview_auto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_experimental_webview_auto.cpp; sourceTree = "<group>"; };
15C9A10D1AE4972500C15443 /* lua_cocos2dx_experimental_webview_auto.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_experimental_webview_auto.hpp; sourceTree = "<group>"; };
15C9A1101AE4973400C15443 /* lua_cocos2dx_experimental_webview_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_experimental_webview_manual.cpp; sourceTree = "<group>"; };
15C9A1111AE4973400C15443 /* lua_cocos2dx_experimental_webview_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_experimental_webview_manual.hpp; sourceTree = "<group>"; };
15EFA401198B2AB2000C57D3 /* lua_cocos2dx_coco_studio_manual.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = lua_cocos2dx_coco_studio_manual.cpp; sourceTree = "<group>"; };
15EFA402198B2AB2000C57D3 /* lua_cocos2dx_coco_studio_manual.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = lua_cocos2dx_coco_studio_manual.hpp; sourceTree = "<group>"; };
15EFA616198B2DAA000C57D3 /* libluacocos2d iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libluacocos2d iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
@ -536,6 +544,8 @@
15C1BD191986526C00A46ACC /* ui */ = {
isa = PBXGroup;
children = (
15C9A1101AE4973400C15443 /* lua_cocos2dx_experimental_webview_manual.cpp */,
15C9A1111AE4973400C15443 /* lua_cocos2dx_experimental_webview_manual.hpp */,
15C1C24B1987473200A46ACC /* lua_cocos2dx_experimental_video_manual.cpp */,
15C1C24C1987473200A46ACC /* lua_cocos2dx_experimental_video_manual.hpp */,
15C1BD1A1986526C00A46ACC /* lua_cocos2dx_ui_manual.cpp */,
@ -562,6 +572,8 @@
1AACE74818BC45C200215002 /* auto */ = {
isa = PBXGroup;
children = (
15C9A10C1AE4972500C15443 /* lua_cocos2dx_experimental_webview_auto.cpp */,
15C9A10D1AE4972500C15443 /* lua_cocos2dx_experimental_webview_auto.hpp */,
159552381A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.cpp */,
159552391A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.hpp */,
3E2BDB0319C5E5FE0055CDCD /* lua_cocos2dx_audioengine_auto.cpp */,
@ -877,7 +889,9 @@
15EFA62C198B3220000C57D3 /* lua_cocos2dx_deprecated.h in Headers */,
155C7E2919A71CE800F08B25 /* lua_cocos2dx_ui_manual.hpp in Headers */,
15EFA62D198B3220000C57D3 /* lua_cocos2dx_experimental_manual.hpp in Headers */,
15C9A1131AE4973400C15443 /* lua_cocos2dx_experimental_webview_manual.hpp in Headers */,
15EFA62E198B3220000C57D3 /* lua_cocos2dx_manual.hpp in Headers */,
15C9A10F1AE4972500C15443 /* lua_cocos2dx_experimental_webview_auto.hpp in Headers */,
15EFA62F198B3220000C57D3 /* lua_cocos2dx_physics_manual.hpp in Headers */,
155C7E0919A71C8500F08B25 /* lua_cocos2dx_extension_manual.h in Headers */,
155C7E1919A71CB500F08B25 /* lua_xml_http_request.h in Headers */,
@ -1064,6 +1078,7 @@
15EFA639198B328B000C57D3 /* tolua_fix.cpp in Sources */,
155C7DFF19A71C5C00F08B25 /* CCBProxy.cpp in Sources */,
1595523B1A25E1C5001E9FC9 /* lua_cocos2dx_csloader_auto.cpp in Sources */,
15C9A1121AE4973400C15443 /* lua_cocos2dx_experimental_webview_manual.cpp in Sources */,
155C7DF019A71C1E00F08B25 /* lua_cocos2dx_spine_auto.cpp in Sources */,
155C7E0719A71C7800F08B25 /* lua_cocos2dx_extension_manual.cpp in Sources */,
15EFA625198B31FB000C57D3 /* LuaOpengl.cpp in Sources */,
@ -1087,6 +1102,7 @@
3E2BDB0519C5E5FE0055CDCD /* lua_cocos2dx_audioengine_auto.cpp in Sources */,
155C7E0B19A71C8D00F08B25 /* lua_cocos2dx_network_manual.cpp in Sources */,
15415AAE19A71A53004F1E71 /* except.c in Sources */,
15C9A10E1AE4972500C15443 /* lua_cocos2dx_experimental_webview_auto.cpp in Sources */,
15415AAA19A71A53004F1E71 /* buffer.c in Sources */,
155C7E2319A71CD500F08B25 /* lua_cocos2dx_experimental_video_manual.cpp in Sources */,
155C7DFB19A71C4E00F08B25 /* lua_cocos2dx_coco_studio_manual.cpp in Sources */,

View File

@ -39,6 +39,7 @@
<ClCompile Include="..\auto\lua_cocos2dx_csloader_auto.cpp" />
<ClCompile Include="..\auto\lua_cocos2dx_experimental_auto.cpp" />
<ClCompile Include="..\auto\lua_cocos2dx_experimental_video_auto.cpp" />
<ClCompile Include="..\auto\lua_cocos2dx_experimental_webview_auto.cpp" />
<ClCompile Include="..\auto\lua_cocos2dx_extension_auto.cpp" />
<ClCompile Include="..\auto\lua_cocos2dx_physics_auto.cpp" />
<ClCompile Include="..\auto\lua_cocos2dx_spine_auto.cpp" />
@ -74,6 +75,7 @@
<ClCompile Include="..\manual\spine\lua_cocos2dx_spine_manual.cpp" />
<ClCompile Include="..\manual\tolua_fix.cpp" />
<ClCompile Include="..\manual\ui\lua_cocos2dx_experimental_video_manual.cpp" />
<ClCompile Include="..\manual\ui\lua_cocos2dx_experimental_webview_manual.cpp" />
<ClCompile Include="..\manual\ui\lua_cocos2dx_ui_manual.cpp" />
</ItemGroup>
<ItemGroup>
@ -107,6 +109,7 @@
<ClInclude Include="..\auto\lua_cocos2dx_csloader_auto.hpp" />
<ClInclude Include="..\auto\lua_cocos2dx_experimental_auto.hpp" />
<ClInclude Include="..\auto\lua_cocos2dx_experimental_video_auto.hpp" />
<ClInclude Include="..\auto\lua_cocos2dx_experimental_webview_auto.hpp" />
<ClInclude Include="..\auto\lua_cocos2dx_extension_auto.hpp" />
<ClInclude Include="..\auto\lua_cocos2dx_physics_auto.hpp" />
<ClInclude Include="..\auto\lua_cocos2dx_spine_auto.hpp" />
@ -142,6 +145,7 @@
<ClInclude Include="..\manual\spine\lua_cocos2dx_spine_manual.hpp" />
<ClInclude Include="..\manual\tolua_fix.h" />
<ClInclude Include="..\manual\ui\lua_cocos2dx_experimental_video_manual.hpp" />
<ClInclude Include="..\manual\ui\lua_cocos2dx_experimental_webview_manual.hpp" />
<ClInclude Include="..\manual\ui\lua_cocos2dx_ui_manual.hpp" />
</ItemGroup>
<ItemGroup>

View File

@ -267,6 +267,12 @@
<ClCompile Include="..\manual\cocostudio\lua-cocos-studio-conversions.cpp">
<Filter>manual\cocostudio</Filter>
</ClCompile>
<ClCompile Include="..\auto\lua_cocos2dx_experimental_webview_auto.cpp">
<Filter>auto</Filter>
</ClCompile>
<ClCompile Include="..\manual\ui\lua_cocos2dx_experimental_webview_manual.cpp">
<Filter>manual\ui</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\auto\lua_cocos2dx_auto.hpp">
@ -467,6 +473,12 @@
<ClInclude Include="..\manual\cocostudio\lua-cocos-studio-conversions.h">
<Filter>manual\cocostudio</Filter>
</ClInclude>
<ClInclude Include="..\auto\lua_cocos2dx_experimental_webview_auto.hpp">
<Filter>auto</Filter>
</ClInclude>
<ClInclude Include="..\manual\ui\lua_cocos2dx_experimental_webview_manual.hpp">
<Filter>manual\ui</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\script\CCBReaderLoad.lua">

View File

@ -27,7 +27,7 @@
#include "platform/CCPlatformConfig.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS )
#include "ui/UIWidget.h"

View File

@ -29,9 +29,6 @@ function UIScene:init()
self._sceneTitle = root:getChildByName("UItest")
local back_label = root:getChildByName("back")--getWidgetByName
back_label:setVisible(false)
local function previousCallback(sender, eventType)
if eventType == ccui.TouchEventType.ended then
cc.Director:getInstance():replaceScene(guiSceneManager.previousUIScene())
@ -711,9 +708,6 @@ function UILoadingBarLeftTest:initExtend()
local root = self._uiLayer:getChildByTag(81)
self._sceneTitle = root:getChildByName("UItest")
local back_label = root:getChildByName("back")
back_label:setVisible(false)
local widgetSize = self._widget:getContentSize()
local alert = ccui.Text:create()
@ -837,9 +831,6 @@ function UILoadingBarRightTest:initExtend()
local root = self._uiLayer:getChildByTag(81)
self._sceneTitle = root:getChildByName("UItest")
local back_label = root:getChildByName("back")
back_label:setVisible(false)
local widgetSize = self._widget:getContentSize()
local alert = ccui.Text:create()
@ -964,9 +955,6 @@ function UILoadingBarLeftScale9Test:initExtend()
local root = self._uiLayer:getChildByTag(81)
self._sceneTitle = root:getChildByName("UItest")
local back_label = root:getChildByName("back")
back_label:setVisible(false)
local widgetSize = self._widget:getContentSize()
local alert = ccui.Text:create()
@ -1093,9 +1081,6 @@ function UILoadingBarRightScale9Test:initExtend()
local root = self._uiLayer:getChildByTag(81)
self._sceneTitle = root:getChildByName("UItest")
local back_label = root:getChildByName("back")
back_label:setVisible(false)
local widgetSize = self._widget:getContentSize()
local alert = ccui.Text:create()

View File

@ -0,0 +1,129 @@
----------------------------------------
----WebViewTest
----------------------------------------
local WebViewTest = class("WebViewTest", function ()
local layer = cc.Layer:create()
return layer
end)
function WebViewTest:ctor()
self:init()
end
function WebViewTest:init()
Helper.initWithLayer(self)
Helper.titleLabel:setString(self:title())
Helper.subtitleLabel:setString(self:subtitle())
local winSize = cc.Director:getInstance():getVisibleSize()
self._webView = ccexp.WebView:create()
self._webView:setPosition(winSize.width / 2, winSize.height / 2 - 40)
self._webView:setContentSize(winSize.width / 2, winSize.height / 2)
self._webView:loadURL("http://www.baidu.com")
self._webView:setScalesPageToFit(true)
self._webView:setOnShouldStartLoading(function(sender, url)
print("onWebViewShouldStartLoading, url is ", url)
return true
end)
self._webView:setOnDidFinishLoading(function(sender, url)
print("onWebViewDidFinishLoading, url is ", url)
end)
self._webView:setOnDidFailLoading(function(sender, url)
print("onWebViewDidFinishLoading, url is ", url)
end)
self:addChild(self._webView)
local urlTextField = ccui.TextField:create("Input a URL here", "Arial", 20)
urlTextField:setPlaceHolderColor(cc.c4b(255, 0, 0, 255))
urlTextField:setPosition(winSize.width/2 - 80, winSize.height/2 + self._webView:getContentSize().height/2 + urlTextField:getContentSize().height/2 + 10)
self:addChild(urlTextField)
local httpLabel = ccui.Text:create("http:// ", "Arial", 20)
httpLabel:setTextColor(cc.c4b(0, 255, 0, 255))
httpLabel:setAnchorPoint(cc.p(1.0,0.5))
local x,y = urlTextField:getPosition()
httpLabel:setPosition( x - urlTextField:getContentSize().width / 2, y)
self:addChild(httpLabel)
local resetBtn = ccui.Button:create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png")
resetBtn:setTitleText("Visit URL")
resetBtn:setPosition(winSize.width / 2 + 80 , winSize.height / 2 + self._webView:getContentSize().height / 2 + resetBtn:getContentSize().height / 2 + 10)
resetBtn:addClickEventListener(function(sender)
if urlTextField:getString() ~= nil then
self._webView:loadURL("http://" .. urlTextField:getString())
end
end)
self:addChild(resetBtn)
local reloadBtn = ccui.Button:create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png")
reloadBtn:setTitleText("Reload")
reloadBtn:setPosition(winSize.width / 2 + self._webView:getContentSize().width / 2 + reloadBtn:getContentSize().width / 2 + 10, winSize.height / 2 + 50)
reloadBtn:addClickEventListener(function(sender)
self._webView:reload()
end)
self:addChild(reloadBtn)
local forwardBtn = ccui.Button:create("cocosui/animationbuttonnormal.png","cocosui/animationbuttonpressed.png")
forwardBtn:setTitleText("Forward")
forwardBtn:setPosition(winSize.width / 2 + self._webView:getContentSize().width / 2 + forwardBtn:getContentSize().width / 2 + 10,winSize.height / 2)
forwardBtn:addClickEventListener(function(sender)
self._webView:goForward()
end)
self:addChild(forwardBtn)
local backBtn = ccui.Button:create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png")
backBtn:setTitleText("Back")
backBtn:setPosition(winSize.width / 2 + self._webView:getContentSize().width/2 + backBtn:getContentSize().width/2 + 10, winSize.height - 50)
backBtn:addClickEventListener(function(sender)
self._webView:goBack()
end)
self:addChild(backBtn)
local loadFileBtn = ccui.Button:create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png")
loadFileBtn:setTitleText("Load FILE")
loadFileBtn:setPosition(winSize.width / 2 - self._webView:getContentSize().width/2 - loadFileBtn:getContentSize().width/2 - 30, winSize.height / 2 + 50)
loadFileBtn:addClickEventListener(function(sender)
self._webView:loadFile("Test.html")
end)
self:addChild(loadFileBtn)
local loadHTMLBtn = ccui.Button:create("cocosui/animationbuttonnormal.png","cocosui/animationbuttonpressed.png")
loadHTMLBtn:setTitleText("Load Data")
loadHTMLBtn:setPosition(winSize.width / 2 - self._webView:getContentSize().width/2 - loadHTMLBtn:getContentSize().width/2 - 30, winSize.height / 2)
loadHTMLBtn:addClickEventListener(function(sender)
self._webView:loadHTMLString("<body style=\"font-size:50px\">Hello World <img src=\"Icon.png\"/> </body>","Images/")
end)
self:addChild(loadHTMLBtn)
local evalJsBtn = ccui.Button:create("cocosui/animationbuttonnormal.png", "cocosui/animationbuttonpressed.png")
evalJsBtn:setTitleText("Evaluate JS")
evalJsBtn:setPosition(winSize.width / 2 - self._webView:getContentSize().width/2 - evalJsBtn:getContentSize().width/2 - 30, winSize.height / 2 - 50)
evalJsBtn:addClickEventListener(function(sender)
self._webView:evaluateJS("alert(\"hello\")")
end)
self:addChild(evalJsBtn)
end
function WebViewTest:title()
return ""
end
function WebViewTest:subtitle()
return ""
end
function WebViewTestMain()
Helper.createFunctionTable =
{
WebViewTest.create,
}
local scene = cc.Scene:create()
scene:addChild(WebViewTest.create())
scene:addChild(CreateBackMenuItem())
return scene
end

View File

@ -58,6 +58,7 @@ require "VideoPlayerTest/VideoPlayerTest"
require "FastTiledMapTest/FastTiledMapTest"
require "NewAudioEngineTest/NewAudioEngineTest"
require "CocosStudio3DTest/CocosStudio3DTest"
require "WebViewTest/WebViewTest"
local LINE_SPACE = 40
@ -134,6 +135,7 @@ local _allTests = {
{ isSupported = true, name = "TransitionsTest" , create_func = TransitionsTest },
{ isSupported = true, name = "UserDefaultTest" , create_func= UserDefaultTestMain },
{ isSupported = true, name = "VideoPlayerTest" , create_func= VideoPlayerTestMain },
{ isSupported = true, name = "WebViewTest" , create_func= WebViewTestMain },
{ isSupported = true, name = "XMLHttpRequestTest" , create_func = XMLHttpRequestTestMain },
{ isSupported = true, name = "ZwoptexTest" , create_func = ZwoptexTestMain }
}
@ -196,6 +198,12 @@ function CreateTestMenu()
end
end
if obj.name == "WebViewTest" then
if cc.PLATFORM_OS_IPHONE ~= targetPlatform and cc.PLATFORM_OS_ANDROID ~= targetPlatform then
testMenuItem:setEnabled(false)
end
end
testMenuItem:registerScriptTapHandler(menuCallback)
testMenuItem:setPosition(cc.p(s.width / 2, (s.height - (index) * LINE_SPACE)))
MainMenu:addChild(testMenuItem, index + 10000, index + 10000)

View File

@ -0,0 +1,62 @@
[cocos2dx_experimental_webview]
# the prefix to be added to the generated functions. You might or might not use this in your own
# templates
prefix = cocos2dx_experimental_webview
# create a target namespace (in javascript, this would create some code like the equiv. to `ns = ns || {}`)
# all classes will be embedded in that namespace
target_namespace = ccexp
macro_judgement = #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
android_headers = -I%(androidndkdir)s/platforms/android-14/arch-arm/usr/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.7/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include -I%(androidndkdir)s/sources/cxx-stl/gnu-libstdc++/4.8/include
android_flags = -D_SIZE_T_DEFINED_
clang_headers = -I%(clangllvmdir)s/lib/clang/3.3/include
clang_flags = -nostdinc -x c++ -std=c++11 -U __SSE__
cocos_headers = -I%(cocosdir)s/cocos -I%(cocosdir)s/cocos/editor-support -I%(cocosdir)s/cocos/platform/android
cocos_flags = -DANDROID
cxxgenerator_headers =
# extra arguments for clang
extra_arguments = %(android_headers)s %(clang_headers)s %(cxxgenerator_headers)s %(cocos_headers)s %(android_flags)s %(clang_flags)s %(cocos_flags)s %(extra_flags)s
# what headers to parse
headers = %(cocosdir)s/cocos/ui/UIWebView.h
# what classes to produce code for. You can use regular expressions here. When testing the regular
# expression, it will be enclosed in "^$", like this: "^Menu*$".
classes = WebView
# what should we skip? in the format ClassName::[function function]
# ClassName is a regular expression, but will be used like this: "^ClassName$" functions are also
# regular expressions, they will not be surrounded by "^$". If you want to skip a whole class, just
# add a single "*" as functions. See bellow for several examples. A special class name is "*", which
# will apply to all class names. This is a convenience wildcard to be able to skip similar named
# functions from all classes.
skip = WebView::[(s|g)etOnShouldStartLoading (s|g)etOnDidFinishLoading (s|g)etOnDidFailLoading setOnJSCallback draw loadData]
rename_functions =
rename_classes =
# for all class names, should we remove something when registering in the target VM?
remove_prefix =
# classes for which there will be no "parent" lookup
classes_have_no_parents =
# base classes which will be skipped when their sub-classes found them.
base_classes_to_skip =
# classes that create no constructor
# Set is special and we will use a hand-written constructor
abstract_classes =
# Determining whether to use script object(js object) to control the lifecycle of native(cpp) object or the other way around. Supported values are 'yes' or 'no'.
script_control_cpp = no

View File

@ -147,6 +147,7 @@ def main():
'cocos2dx_3d.ini': ('cocos2dx_3d', 'lua_cocos2dx_3d_auto'), \
'cocos2dx_audioengine.ini': ('cocos2dx_audioengine', 'lua_cocos2dx_audioengine_auto'), \
'cocos2dx_csloader.ini' : ('cocos2dx_csloader', 'lua_cocos2dx_csloader_auto'), \
'cocos2dx_experimental_webview.ini' : ('cocos2dx_experimental_webview', 'lua_cocos2dx_experimental_webview_auto'), \
}
target = 'lua'
generator_py = '%s/generator.py' % cxx_generator_root