增加一个在native运行js代码的方法

This commit is contained in:
cebgcontract 2022-06-29 11:58:13 +08:00
parent 595fd39e30
commit 5ae506a817
2 changed files with 6 additions and 0 deletions

View File

@ -435,6 +435,11 @@ bool jsb_run_script(const std::string& filePath, se::Value* rval/* = nullptr */)
return se::ScriptEngine::getInstance()->runScript(filePath, rval);
}
bool jsb_run_code(const std::string& coder, se::Value* rval/* = nullptr */) {
se::AutoHandleScope hs;
return se::ScriptEngine::getInstance()->evalString(coder.c_str(), coder.size(), rval);
}
bool jsb_run_script_module(const std::string& filePath, se::Value* rval/* = nullptr */)
{
return doModuleRequire(filePath, rval, "");

View File

@ -42,6 +42,7 @@ void jsb_init_file_operation_delegate();
bool jsb_enable_debugger(const std::string& debuggerServerAddr, uint32_t port, bool isWaitForConnect = false);
bool jsb_set_extend_property(const char* ns, const char* clsName);
bool jsb_run_script(const std::string& filePath, se::Value* rval = nullptr);
bool jsb_run_code(const std::string& coder, se::Value* rval = nullptr);
bool jsb_run_script_module(const std::string& filePath, se::Value* rval = nullptr);
void jsb_set_xxtea_key(const std::string& key);