Fix HarmonyOS Next platform interface for calling arkts using JavaScript (#18062)

* Fix HarmonyOS Next platform interface for calling arkts using JavaScript

* Optimized interface implementation

* Improve annotations

* Improve the annotation.

---------

Co-authored-by: qiuguohua <guohua.qiu@cocos.com>
This commit is contained in:
qiuguohua
2024-12-20 14:51:25 +08:00
committed by GitHub
parent eb949c6022
commit 40e0769ec8
4 changed files with 59 additions and 33 deletions
@@ -203,24 +203,27 @@ static bool JavaScriptArkTsBridge_callStaticMethod(se::State& s) {
const auto& args = s.args();
int argc = (int)args.size();
if (argc == 4) {
if (argc == 3 || argc == 4) {
bool ok = false;
bool isSyn;
bool isSync = true;
std::string clsPath, methodName, paramStr;
isSyn = seval_to_type<bool>(args[0], ok);
SE_PRECONDITION2(ok, false, "Converting isSyn failed!");
clsPath = seval_to_type<std::string>(args[1], ok);
clsPath = seval_to_type<std::string>(args[0], ok);
SE_PRECONDITION2(ok, false, "Converting clsPath failed!");
methodName = seval_to_type<std::string>(args[2], ok);
methodName = seval_to_type<std::string>(args[1], ok);
SE_PRECONDITION2(ok, false, "Converting methodName failed!");
paramStr = seval_to_type<std::string>(args[3], ok);
paramStr = seval_to_type<std::string>(args[2], ok);
SE_PRECONDITION2(ok, false, "Converting paramStr failed!");
if(argc == 4) {
ok = args[3].isBoolean();
SE_PRECONDITION2(ok, false, "isSync must be boolean type");
isSync = args[3].toBoolean();
}
JavaScriptArkTsBridge::CallInfo call(isSyn, clsPath.c_str(), methodName.c_str(), paramStr.c_str());
JavaScriptArkTsBridge::CallInfo call(isSync, clsPath.c_str(), methodName.c_str(), paramStr.c_str());
ok = call.execute(s.rval());
if (!ok) {
s.rval().setUndefined();