Skip to content

Commit 9cbf0b0

Browse files
committed
chore: add file version info
1 parent c60ee60 commit 9cbf0b0

File tree

15 files changed

+171
-78
lines changed

15 files changed

+171
-78
lines changed

src/legacy/api/EventAPI.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@
5656
#include "mc/world/item/VanillaItemNames.h"
5757
#include "mc/world/level/dimension/Dimension.h"
5858

59-
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS
59+
#ifdef LSE_BACKEND_NODEJS
6060
#include "legacy/main/NodeJsHelper.h"
6161
#endif
6262

63-
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON
63+
#ifdef LSE_BACKEND_PYTHON
6464
#include "legacy/main/PythonHelper.h"
6565
#endif
6666

@@ -764,18 +764,18 @@ void InitBasicEventListeners() {
764764
if (cmd.starts_with("/")) {
765765
cmd.erase(0, 1);
766766
}
767-
#ifndef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS
767+
#ifndef LSE_BACKEND_NODEJS
768768
if (!ProcessDebugEngine(cmd)) {
769769
ev.cancel();
770770
return;
771771
}
772772
#endif
773-
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS
773+
#ifdef LSE_BACKEND_NODEJS
774774
if (!NodeJsHelper::processConsoleNpmCmd(cmd)) {
775775
ev.cancel();
776776
return;
777777
}
778-
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON)
778+
#elif defined(LSE_BACKEND_PYTHON)
779779
if (!PythonHelper::processConsolePipCmd(cmd)) {
780780
ev.cancel();
781781
return;
@@ -890,7 +890,7 @@ void InitBasicEventListeners() {
890890
}
891891
}
892892
}
893-
#ifndef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS
893+
#ifndef LSE_BACKEND_NODEJS
894894
try {
895895
std::list<ScriptEngine*> tmpList;
896896
{

src/legacy/engine/EngineManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "engine/GlobalShareData.h"
55
#include "ll/api/utils/StringUtils.h"
66

7-
#if defined(LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS)
7+
#if defined(LSE_BACKEND_NODEJS)
88
#include "legacy/main/NodeJsHelper.h"
99
#endif
1010

@@ -36,7 +36,7 @@ bool EngineManager::registerEngine(ScriptEngine* engine) {
3636
ScriptEngine* EngineManager::newEngine(std::string pluginName) {
3737
ScriptEngine* engine = nullptr;
3838

39-
#if defined(LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS)
39+
#if defined(LSE_BACKEND_NODEJS)
4040
engine = NodeJsHelper::newEngine();
4141
#elif !defined(SCRIPTX_BACKEND_WEBASSEMBLY)
4242
engine = new ScriptEngineImpl();

src/legacy/legacyapi/db/Session.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "legacyapi/db/Session.h"
22

33
#include "lse/Entry.h"
4-
#ifndef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS
4+
#ifndef LSE_BACKEND_NODEJS
55
#include "legacyapi/db/impl/mysql/Session.h"
66
#endif
77
#include "legacyapi/db/impl/sqlite/Session.h"
@@ -110,7 +110,7 @@ SharedPointer<Session> Session::_Create(DBType type, const ConnParams& params) {
110110
session = params.empty() ? new SQLiteSession() : new SQLiteSession(params);
111111
break;
112112
case DBType::MySQL:
113-
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS
113+
#ifdef LSE_BACKEND_NODEJS
114114
lse::LegacyScriptEngine::getInstance().getSelf().getLogger().error(
115115
"Session::_Create: MySQL is disabled in NodeJS backend because its OpenSSL has conflicts with libnode"
116116
);

src/legacy/main/BindAPIs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void BindAPIs(ScriptEngine* engine) {
3838
engine->set("colorLog", Function::newFunction(ColorLog));
3939
engine->set("fastLog", Function::newFunction(FastLog));
4040

41-
#ifndef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS // NodeJs has its own functions below
41+
#ifndef LSE_BACKEND_NODEJS // NodeJs has its own functions below
4242
engine->set("setTimeout", Function::newFunction(SetTimeout));
4343
engine->set("setInterval", Function::newFunction(SetInterval));
4444
engine->set("clearInterval", Function::newFunction(ClearInterval));

src/legacy/main/BuiltinCommands.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#include <string>
1414

15-
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON
15+
#ifdef LSE_BACKEND_PYTHON
1616
#include "PythonHelper.h"
1717
#endif
1818

@@ -23,7 +23,7 @@ std::shared_ptr<ll::io::Logger> DebugCmdLogger = ll::io::LoggerRegistry::getInst
2323
inline void PrintDebugSign() { DebugCmdLogger->info("> "); }
2424

2525
bool ProcessDebugEngine(const std::string& cmd) {
26-
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON
26+
#ifdef LSE_BACKEND_PYTHON
2727
// process python debug seperately
2828
return PythonHelper::processPythonDebugEngine(cmd);
2929
#endif
@@ -56,7 +56,7 @@ struct EngineDebugCommand {
5656
void RegisterDebugCommand() {
5757
DebugCmdLogger->setFormatter(ll::makePolymorphic<lse::io::DirectFormatter>());
5858
// Node.js engine doesn't support debug engine, Python engine don't need to register command.
59-
#if (!defined LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS) && (!defined LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON)
59+
#if (!defined LSE_BACKEND_NODEJS) && (!defined LSE_BACKEND_PYTHON)
6060
auto& command = ll::command::CommandRegistrar::getInstance()
6161
.getOrCreateCommand(LLSE_DEBUG_CMD, "Debug LegacyScriptEngine", CommandPermissionLevel::Owner);
6262
command.overload<EngineDebugCommand>().optional("eval").execute(

src/legacy/main/Global.h

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,25 @@
55
#include "mc/world/level/BlockPos.h"
66

77
#include <string>
8-
#include <vector>
98

109
class IntVec4 {
1110
public:
1211
int x, y, z;
1312
int dim;
1413

15-
inline BlockPos getBlockPos() { return {x, y, z}; }
14+
[[nodiscard]] inline BlockPos getBlockPos() const { return {x, y, z}; }
1615

17-
inline int getDimensionId() { return dim; }
16+
[[nodiscard]] inline int getDimensionId() const { return dim; }
1817
};
1918

2019
class FloatVec4 {
2120
public:
2221
float x, y, z;
2322
int dim;
2423

25-
inline Vec3 getVec3() { return {x, y, z}; }
24+
[[nodiscard]] inline Vec3 getVec3() const { return {x, y, z}; }
2625

27-
inline int getDimensionId() { return dim; }
26+
[[nodiscard]] inline int getDimensionId() const { return dim; }
2827

2928
inline IntVec4 toIntVec4() {
3029
auto px = (int)x;
@@ -61,35 +60,35 @@ inline std::string DimId2Name(int dimid) {
6160
// 全局变量
6261
extern bool isCmdRegisterEnabled;
6362

64-
#if defined(LEGACY_SCRIPT_ENGINE_BACKEND_QUICKJS)
63+
#if defined(LSE_BACKEND_QUICKJS)
6564
// QuickJs
66-
constexpr std::string LLSE_BACKEND_TYPE = "Js";
65+
inline constexpr std::string LLSE_BACKEND_TYPE = "Js";
6766

68-
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_LUA)
67+
#elif defined(LSE_BACKEND_LUA)
6968
// Lua
70-
constexpr std::string LLSE_BACKEND_TYPE = "Lua";
69+
inline constexpr std::string LLSE_BACKEND_TYPE = "Lua";
7170

72-
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS)
71+
#elif defined(LSE_BACKEND_NODEJS)
7372
// NodeJs
74-
const std::string LLSE_BACKEND_TYPE = "NodeJs";
73+
inline constexpr std::string LLSE_BACKEND_TYPE = "NodeJs";
7574

76-
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON)
75+
#elif defined(LSE_BACKEND_PYTHON)
7776
// Python
78-
const std::string LLSE_BACKEND_TYPE = "Python";
77+
inline constexpr std::string LLSE_BACKEND_TYPE = "Python";
7978
#endif
8079

8180
// Debug engine information
82-
#if defined(LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS)
83-
constexpr std::string LLSE_DEBUG_CMD = "nodejsdebug";
84-
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_QUICKJS)
85-
constexpr std::string LLSE_DEBUG_CMD = "jsdebug";
86-
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_LUA)
87-
constexpr std::string LLSE_DEBUG_CMD = "luadebug";
88-
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON)
89-
constexpr std::string LLSE_DEBUG_CMD = "pydebug";
81+
#if defined(LSE_BACKEND_NODEJS)
82+
inline constexpr std::string LLSE_DEBUG_CMD = "nodejsdebug";
83+
#elif defined(LSE_BACKEND_QUICKJS)
84+
inline constexpr std::string LLSE_DEBUG_CMD = "jsdebug";
85+
#elif defined(LSE_BACKEND_LUA)
86+
inline constexpr std::string LLSE_DEBUG_CMD = "luadebug";
87+
#elif defined(LSE_BACKEND_PYTHON)
88+
inline constexpr std::string LLSE_DEBUG_CMD = "pydebug";
9089
#endif
9190

92-
constexpr wchar_t LLSE_GLOBAL_DATA_NAME[] = L"LLSE_GLOBAL_DATA_SECTION";
93-
constexpr unsigned long LLSE_MESSAGE_SYSTEM_WAIT_CHECK_INTERVAL = 5;
94-
constexpr size_t LLSE_POOL_THREAD_COUNT = 4;
95-
constexpr int LLSE_VALID_BACKENDS_COUNT = 4;
91+
inline constexpr wchar_t LLSE_GLOBAL_DATA_NAME[] = L"LLSE_GLOBAL_DATA_SECTION";
92+
inline constexpr unsigned long LLSE_MESSAGE_SYSTEM_WAIT_CHECK_INTERVAL = 5;
93+
inline constexpr size_t LLSE_POOL_THREAD_COUNT = 4;
94+
inline constexpr int LLSE_VALID_BACKENDS_COUNT = 4;

src/legacy/main/NodeJsHelper.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ bool initNodeJs() {
122122
#if defined(LSE_DEBUG) || defined(LSE_TEST)
123123
full_args.insert(
124124
full_args.end(),
125-
{"--experimental-strip-types", "--enable-source-maps", "--disable-warning=ExperimentalWarning"}
125+
{"--experimental-strip-types",
126+
"--experimental-transform-types",
127+
"--enable-source-maps",
128+
"--disable-warning=ExperimentalWarning"}
126129
);
127130
#endif
128131
auto result = node::InitializeOncePerProcess(
@@ -143,7 +146,7 @@ bool initNodeJs() {
143146

144147
// Init V8
145148
using namespace v8;
146-
platform = node::MultiIsolatePlatform::Create(std::thread::hardware_concurrency());
149+
platform = node::MultiIsolatePlatform::Create((int)std::thread::hardware_concurrency());
147150
V8::InitializePlatform(platform.get());
148151
V8::Initialize();
149152

@@ -497,7 +500,7 @@ bool isESModulesSystem(const std::string& dirPath) {
497500
}
498501

499502
bool processConsoleNpmCmd(const std::string& cmd) {
500-
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS
503+
#ifdef LSE_BACKEND_NODEJS
501504
if (cmd.starts_with("npm ") || cmd.starts_with("npx ")) {
502505
executeNpmCommand(SplitCmdLine(cmd));
503506
return false;

src/legacy/main/PythonHelper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ bool processPythonDebugEngine(const std::string& cmd) {
222222
}
223223

224224
bool processConsolePipCmd(const std::string& cmd) {
225-
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON
225+
#ifdef LSE_BACKEND_PYTHON
226226
if (cmd == "pip" || cmd.starts_with("pip ")) {
227227
PythonHelper::executePipCommand(cmd);
228228
return false;

src/lse/Config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace lse {
77
struct Config {
88
int version = 1;
99
bool migratePlugins = true;
10-
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS
10+
#ifdef LSE_BACKEND_NODEJS
1111
std::optional<bool> fixOldAddon{std::nullopt};
1212
#endif
1313
};

src/lse/Entry.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,26 @@
2020
#include <memory>
2121
#include <stdexcept>
2222

23-
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_LUA
23+
#ifdef LSE_BACKEND_LUA
2424

2525
constexpr auto BaseLibFileName = "BaseLib.lua";
2626

2727
#endif
2828

29-
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_QUICKJS
29+
#ifdef LSE_BACKEND_QUICKJS
3030

3131
constexpr auto BaseLibFileName = "BaseLib.js";
3232

3333
#endif
3434

35-
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON
35+
#ifdef LSE_BACKEND_PYTHON
3636

3737
#include "legacy/main/PythonHelper.h"
3838
constexpr auto BaseLibFileName = "BaseLib.py";
3939

4040
#endif
4141

42-
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS
42+
#ifdef LSE_BACKEND_NODEJS
4343

4444
#include "legacy/main/NodeJsHelper.h"
4545

@@ -90,7 +90,7 @@ void initializeLegacyStuff() {
9090
InitGlobalShareData();
9191
InitSafeGuardRecord();
9292
EconomySystem::init();
93-
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON
93+
#ifdef LSE_BACKEND_PYTHON
9494
PythonHelper::initPythonRuntime();
9595
#endif
9696

@@ -150,7 +150,7 @@ void loadConfig(const ll::mod::NativeMod& self, Config& cfg) {
150150
}
151151

152152
void loadDebugEngine(const ll::mod::NativeMod& self) {
153-
#ifndef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS // NodeJs backend didn't enable debug engine now
153+
#ifndef LSE_BACKEND_NODEJS // NodeJs backend didn't enable debug engine now
154154
auto scriptEngine = EngineManager::newEngine();
155155

156156
script::EngineScope engineScope(scriptEngine);

0 commit comments

Comments
 (0)