reformat code

This commit is contained in:
zhl 2023-03-14 15:42:16 +08:00
parent f48f321c77
commit 18d7863282
2 changed files with 1327 additions and 1329 deletions

View File

@ -2,26 +2,26 @@
Copyright (c) 2013-2016 Chukong Technologies Inc. Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.org http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 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 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. THE SOFTWARE.
****************************************************************************/ ****************************************************************************/
#pragma once #pragma once
#include <string> #include <string>

View File

@ -262,7 +262,7 @@ bool jsb_enable_debugger(const std::string& debuggerServerAddr, uint32_t port, b
se::ScriptEngine::getInstance()->mainLoopUpdate(); se::ScriptEngine::getInstance()->mainLoopUpdate();
} }
}; };
// static SimpleRunLoop runLoop; // static SimpleRunLoop runLoop;
//cjh IDEA: Director::getInstance()->getScheduler()->scheduleUpdate(&runLoop, 0, false); //cjh IDEA: Director::getInstance()->getScheduler()->scheduleUpdate(&runLoop, 0, false);
return true; return true;
} }
@ -296,20 +296,20 @@ bool jsb_set_extend_property(const char* ns, const char* clsName)
namespace { namespace {
std::unordered_map<std::string, se::Value> __moduleCache; std::unordered_map<std::string, se::Value> __moduleCache;
static bool require(se::State& s) static bool require(se::State& s)
{ {
const auto& args = s.args(); const auto& args = s.args();
int argc = (int)args.size(); int argc = (int)args.size();
assert(argc >= 1); assert(argc >= 1);
assert(args[0].isString()); assert(args[0].isString());
return jsb_run_script(args[0].toString(), &s.rval()); return jsb_run_script(args[0].toString(), &s.rval());
} }
SE_BIND_FUNC(require) SE_BIND_FUNC(require)
static bool doModuleRequire(const std::string& path, se::Value* ret, const std::string& prevScriptFileDir) static bool doModuleRequire(const std::string& path, se::Value* ret, const std::string& prevScriptFileDir)
{ {
se::AutoHandleScope hs; se::AutoHandleScope hs;
assert(!path.empty()); assert(!path.empty());
@ -358,7 +358,7 @@ namespace {
if (iter != __moduleCache.end()) if (iter != __moduleCache.end())
{ {
*ret = iter->second; *ret = iter->second;
// printf("Found cache: %s, value: %d\n", fullPath.c_str(), (int)ret->getType()); // printf("Found cache: %s, value: %d\n", fullPath.c_str(), (int)ret->getType());
return true; return true;
} }
std::string currentScriptFileDir = FileUtils::getInstance()->getFileDir(fullPath); std::string currentScriptFileDir = FileUtils::getInstance()->getFileDir(fullPath);
@ -371,17 +371,17 @@ namespace {
// Add current script path to require function invocation // Add current script path to require function invocation
scriptBuffer = prefix + std::regex_replace(scriptBuffer, std::regex("([^A-Za-z0-9]|^)requireModule\\((.*?)\\)"), "$1requireModule($2, currentScriptDir)") + suffix; scriptBuffer = prefix + std::regex_replace(scriptBuffer, std::regex("([^A-Za-z0-9]|^)requireModule\\((.*?)\\)"), "$1requireModule($2, currentScriptDir)") + suffix;
// FILE* fp = fopen("/Users/james/Downloads/test.txt", "wb"); // FILE* fp = fopen("/Users/james/Downloads/test.txt", "wb");
// fwrite(scriptBuffer.c_str(), scriptBuffer.length(), 1, fp); // fwrite(scriptBuffer.c_str(), scriptBuffer.length(), 1, fp);
// fclose(fp); // fclose(fp);
std::string reletivePath = fullPath; std::string reletivePath = fullPath;
#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_IOS #if CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_IOS
#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC #if CC_TARGET_PLATFORM == CC_PLATFORM_MAC
const std::string reletivePathKey = "/Contents/Resources"; const std::string reletivePathKey = "/Contents/Resources";
#else #else
const std::string reletivePathKey = ".app"; const std::string reletivePathKey = ".app";
#endif #endif
size_t pos = reletivePath.find(reletivePathKey); size_t pos = reletivePath.find(reletivePathKey);
if (pos != std::string::npos) if (pos != std::string::npos)
@ -391,7 +391,7 @@ namespace {
#endif #endif
// RENDERER_LOGD("Evaluate: %s", fullPath.c_str()); // RENDERER_LOGD("Evaluate: %s", fullPath.c_str());
auto se = se::ScriptEngine::getInstance(); auto se = se::ScriptEngine::getInstance();
bool succeed = se->evalString(scriptBuffer.c_str(), scriptBuffer.length(), nullptr, reletivePath.c_str()); bool succeed = se->evalString(scriptBuffer.c_str(), scriptBuffer.length(), nullptr, reletivePath.c_str());
@ -424,10 +424,10 @@ namespace {
SE_LOGE("doModuleRequire %s, buffer is empty!\n", path.c_str()); SE_LOGE("doModuleRequire %s, buffer is empty!\n", path.c_str());
assert(false); assert(false);
return false; return false;
} }
static bool moduleRequire(se::State& s) static bool moduleRequire(se::State& s)
{ {
const auto& args = s.args(); const auto& args = s.args();
int argc = (int)args.size(); int argc = (int)args.size();
assert(argc >= 2); assert(argc >= 2);
@ -435,8 +435,8 @@ namespace {
assert(args[1].isString()); assert(args[1].isString());
return doModuleRequire(args[0].toString(), &s.rval(), args[1].toString()); return doModuleRequire(args[0].toString(), &s.rval(), args[1].toString());
} }
SE_BIND_FUNC(moduleRequire) SE_BIND_FUNC(moduleRequire)
} // namespace { } // namespace {
bool jsb_run_script(const std::string& filePath, se::Value* rval/* = nullptr */) bool jsb_run_script(const std::string& filePath, se::Value* rval/* = nullptr */)
@ -523,10 +523,10 @@ SE_BIND_FUNC(JSBCore_platform)
static bool JSBCore_version(se::State& s) static bool JSBCore_version(se::State& s)
{ {
//cjh char version[256]; //cjh char version[256];
// snprintf(version, sizeof(version)-1, "%s", cocos2dVersion()); // snprintf(version, sizeof(version)-1, "%s", cocos2dVersion());
// //
// s.rval().setString(version); // s.rval().setString(version);
return true; return true;
} }
SE_BIND_FUNC(JSBCore_version) SE_BIND_FUNC(JSBCore_version)
@ -827,7 +827,7 @@ static bool JSB_scanQRCode(se::State& s)
std::string text; std::string text;
ok = seval_to_std_string(args[1], &text); ok = seval_to_std_string(args[1], &text);
SE_PRECONDITION2(ok, false, "title is invalid!"); SE_PRECONDITION2(ok, false, "title is invalid!");
// Application::getInstance()->scanQRCode(funid, text); // Application::getInstance()->scanQRCode(funid, text);
scanQRCodeJNI(funid, text); scanQRCodeJNI(funid, text);
return true; return true;
} }
@ -955,7 +955,7 @@ static bool JSB_signOutGoogle(se::State& s)
std::string funid; std::string funid;
ok = seval_to_std_string(args[0], &funid); ok = seval_to_std_string(args[0], &funid);
SE_PRECONDITION2(ok, false, "funid is invalid!"); SE_PRECONDITION2(ok, false, "funid is invalid!");
// Application::getInstance()->signOutGoogle(funid); // Application::getInstance()->signOutGoogle(funid);
signOutGoogleJNI(funid); signOutGoogleJNI(funid);
return true; return true;
} }
@ -1037,7 +1037,7 @@ static bool JSB_generateWallet(se::State& s)
address.c_str() address.c_str()
); );
s.rval().setString(result); s.rval().setString(result);
// free_cwallet(wallet); // free_cwallet(wallet);
return true; return true;
} }
@ -1065,10 +1065,8 @@ static bool JSB_prepareWallet(se::State& s)
std::string storageBKey = StringUtils::format("cebg_wallet_b_%s", id.c_str()); std::string storageBKey = StringUtils::format("cebg_wallet_b_%s", id.c_str());
std::string localSKey; std::string localSKey;
Application::getInstance()->loadKeyLocal(storageSKey, &localSKey); Application::getInstance()->loadKeyLocal(storageSKey, &localSKey);
// localStorageGetItem(storageSKey, &localSKey);
std::string localBKey; std::string localBKey;
Application::getInstance()->loadKeyLocal(storageBKey, &localBKey); Application::getInstance()->loadKeyLocal(storageBKey, &localBKey);
// localStorageGetItem(storageBKey, &localBKey);
Application::getInstance()->setKeyMaster(keyMaster.c_str()); Application::getInstance()->setKeyMaster(keyMaster.c_str());
Application::getInstance()->setKeySecond(localSKey.c_str()); Application::getInstance()->setKeySecond(localSKey.c_str());
@ -1085,7 +1083,7 @@ static bool JSB_prepareWallet(se::State& s)
address.c_str() address.c_str()
); );
s.rval().setString(result); s.rval().setString(result);
// free_cwallet(wallet); // free_cwallet(wallet);
return true; return true;
} }
@ -1132,7 +1130,7 @@ static bool JSB_restoreWallet(se::State& s)
address.c_str() address.c_str()
); );
s.rval().setString(result); s.rval().setString(result);
// free_cwallet(wallet); // free_cwallet(wallet);
return true; return true;
} }
@ -1227,7 +1225,7 @@ static bool JSB_walletSignTran(se::State& s)
Application::getInstance()->getKeyBackup(), Application::getInstance()->getKeyBackup(),
msg.c_str()); msg.c_str());
s.rval().setString(sign_str); s.rval().setString(sign_str);
// free_cwallet(wallet); // free_cwallet(wallet);
return true; return true;
} }