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) 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
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:
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 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.
****************************************************************************/
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.
****************************************************************************/
#pragma once
#include <string>

View File

@ -262,7 +262,7 @@ bool jsb_enable_debugger(const std::string& debuggerServerAddr, uint32_t port, b
se::ScriptEngine::getInstance()->mainLoopUpdate();
}
};
// static SimpleRunLoop runLoop;
// static SimpleRunLoop runLoop;
//cjh IDEA: Director::getInstance()->getScheduler()->scheduleUpdate(&runLoop, 0, false);
return true;
}
@ -296,20 +296,20 @@ bool jsb_set_extend_property(const char* ns, const char* clsName)
namespace {
std::unordered_map<std::string, se::Value> __moduleCache;
static bool require(se::State& s)
{
std::unordered_map<std::string, se::Value> __moduleCache;
static bool require(se::State& s)
{
const auto& args = s.args();
int argc = (int)args.size();
assert(argc >= 1);
assert(args[0].isString());
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;
assert(!path.empty());
@ -358,7 +358,7 @@ namespace {
if (iter != __moduleCache.end())
{
*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;
}
std::string currentScriptFileDir = FileUtils::getInstance()->getFileDir(fullPath);
@ -371,17 +371,17 @@ namespace {
// 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;
// FILE* fp = fopen("/Users/james/Downloads/test.txt", "wb");
// fwrite(scriptBuffer.c_str(), scriptBuffer.length(), 1, fp);
// fclose(fp);
// FILE* fp = fopen("/Users/james/Downloads/test.txt", "wb");
// fwrite(scriptBuffer.c_str(), scriptBuffer.length(), 1, fp);
// fclose(fp);
std::string reletivePath = fullPath;
#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";
#else
#else
const std::string reletivePathKey = ".app";
#endif
#endif
size_t pos = reletivePath.find(reletivePathKey);
if (pos != std::string::npos)
@ -391,7 +391,7 @@ namespace {
#endif
// RENDERER_LOGD("Evaluate: %s", fullPath.c_str());
// RENDERER_LOGD("Evaluate: %s", fullPath.c_str());
auto se = se::ScriptEngine::getInstance();
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());
assert(false);
return false;
}
}
static bool moduleRequire(se::State& s)
{
static bool moduleRequire(se::State& s)
{
const auto& args = s.args();
int argc = (int)args.size();
assert(argc >= 2);
@ -435,8 +435,8 @@ namespace {
assert(args[1].isString());
return doModuleRequire(args[0].toString(), &s.rval(), args[1].toString());
}
SE_BIND_FUNC(moduleRequire)
}
SE_BIND_FUNC(moduleRequire)
} // namespace {
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)
{
//cjh char version[256];
// snprintf(version, sizeof(version)-1, "%s", cocos2dVersion());
//
// s.rval().setString(version);
//cjh char version[256];
// snprintf(version, sizeof(version)-1, "%s", cocos2dVersion());
//
// s.rval().setString(version);
return true;
}
SE_BIND_FUNC(JSBCore_version)
@ -827,7 +827,7 @@ static bool JSB_scanQRCode(se::State& s)
std::string text;
ok = seval_to_std_string(args[1], &text);
SE_PRECONDITION2(ok, false, "title is invalid!");
// Application::getInstance()->scanQRCode(funid, text);
// Application::getInstance()->scanQRCode(funid, text);
scanQRCodeJNI(funid, text);
return true;
}
@ -955,7 +955,7 @@ static bool JSB_signOutGoogle(se::State& s)
std::string funid;
ok = seval_to_std_string(args[0], &funid);
SE_PRECONDITION2(ok, false, "funid is invalid!");
// Application::getInstance()->signOutGoogle(funid);
// Application::getInstance()->signOutGoogle(funid);
signOutGoogleJNI(funid);
return true;
}
@ -1037,7 +1037,7 @@ static bool JSB_generateWallet(se::State& s)
address.c_str()
);
s.rval().setString(result);
// free_cwallet(wallet);
// free_cwallet(wallet);
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 localSKey;
Application::getInstance()->loadKeyLocal(storageSKey, &localSKey);
// localStorageGetItem(storageSKey, &localSKey);
std::string localBKey;
Application::getInstance()->loadKeyLocal(storageBKey, &localBKey);
// localStorageGetItem(storageBKey, &localBKey);
Application::getInstance()->setKeyMaster(keyMaster.c_str());
Application::getInstance()->setKeySecond(localSKey.c_str());
@ -1085,7 +1083,7 @@ static bool JSB_prepareWallet(se::State& s)
address.c_str()
);
s.rval().setString(result);
// free_cwallet(wallet);
// free_cwallet(wallet);
return true;
}
@ -1132,7 +1130,7 @@ static bool JSB_restoreWallet(se::State& s)
address.c_str()
);
s.rval().setString(result);
// free_cwallet(wallet);
// free_cwallet(wallet);
return true;
}
@ -1227,7 +1225,7 @@ static bool JSB_walletSignTran(se::State& s)
Application::getInstance()->getKeyBackup(),
msg.c_str());
s.rval().setString(sign_str);
// free_cwallet(wallet);
// free_cwallet(wallet);
return true;
}