Skip to content

Commit

Permalink
fix parse error
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongfq committed Aug 31, 2024
1 parent 40c9b6d commit 5c18b68
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
5 changes: 2 additions & 3 deletions addons/cclua/cocos2d/library/ccui/WebView.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
---@field onDidFailLoading ccui.WebView.ccWebViewCallback Get the callback when WebView has failed loading.
---@field onDidFinishLoading ccui.WebView.ccWebViewCallback Get the callback when WebView has finished loading.
---@field onJSCallback ccui.WebView.ccWebViewCallback Get the Javascript callback.
---@field onShouldStartLoading fun(arg1: ccui.WebView, arg2: string): boolean Get the callback when WebView is about to start.
---@field opacityWebView number getOpacity of webview.
local WebView = {}

Expand Down Expand Up @@ -46,10 +47,8 @@ function WebView:getOnDidFinishLoading() end
function WebView:getOnJSCallback() end

---Get the callback when WebView is about to start.
---@param sender ccui.WebView
---@param url string
---@return fun(arg1: ccui.WebView, arg2: string): boolean
function WebView:getOnShouldStartLoading(sender, url) end
function WebView:getOnShouldStartLoading() end

---getOpacity of webview.
---@return number
Expand Down
9 changes: 3 additions & 6 deletions frameworks/cclua/src/lua-bindings/lua_cocos2d_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6785,19 +6785,15 @@ static int _cocos2d_ui_WebView_getOnShouldStartLoading(lua_State *L)
olua_startinvoke(L);

cocos2d::ui::WebView *self = nullptr;
cocos2d::ui::WebView *arg1 = nullptr; /** sender */
std::string arg2; /** url */

olua_to_object(L, 1, &self, "ccui.WebView");
olua_check_object(L, 2, &arg1, "ccui.WebView");
olua_check_string(L, 3, &arg2);

void *cb_store = (void *)self;
std::string cb_tag = "OnShouldStartLoading";
olua_getcallback(L, cb_store, cb_tag.c_str(), OLUA_TAG_EQUAL);

// std::function<bool (cocos2d::ui::WebView *, const std::string &)> getOnShouldStartLoading(cocos2d::ui::WebView *sender, const std::string &url)
std::function<bool (cocos2d::ui::WebView *, const std::string &)> ret = self->getOnShouldStartLoading(arg1, arg2);
// std::function<bool (cocos2d::ui::WebView *, const std::string &)> getOnShouldStartLoading()
std::function<bool (cocos2d::ui::WebView *, const std::string &)> ret = self->getOnShouldStartLoading();
int num_ret = olua_push_callback(L, &ret, "std.function");

olua_endinvoke(L);
Expand Down Expand Up @@ -7370,6 +7366,7 @@ static int _ccui_WebView(lua_State *L)
oluacls_prop(L, "onDidFailLoading", _cocos2d_ui_WebView_getOnDidFailLoading, _cocos2d_ui_WebView_setOnDidFailLoading);
oluacls_prop(L, "onDidFinishLoading", _cocos2d_ui_WebView_getOnDidFinishLoading, _cocos2d_ui_WebView_setOnDidFinishLoading);
oluacls_prop(L, "onJSCallback", _cocos2d_ui_WebView_getOnJSCallback, _cocos2d_ui_WebView_setOnJSCallback);
oluacls_prop(L, "onShouldStartLoading", _cocos2d_ui_WebView_getOnShouldStartLoading, _cocos2d_ui_WebView_setOnShouldStartLoading);
oluacls_prop(L, "opacityWebView", _cocos2d_ui_WebView_getOpacityWebView, _cocos2d_ui_WebView_setOpacityWebView);

return 1;
Expand Down
2 changes: 1 addition & 1 deletion tools/lua-bindings/olua

0 comments on commit 5c18b68

Please sign in to comment.