Skip to content

Commit cc7aaff

Browse files
committed
refactor: remove more macro
1 parent b599bec commit cc7aaff

File tree

2 files changed

+15
-92
lines changed

2 files changed

+15
-92
lines changed

src/legacy/main/Configs.h

Lines changed: 14 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,41 @@
11
#pragma once
22

3-
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_LUA
4-
5-
#define LLSE_BACKEND_LUA
6-
7-
#endif
8-
9-
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_QUICKJS
10-
11-
#define LLSE_BACKEND_QUICKJS
12-
13-
#endif
14-
15-
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON
16-
17-
#define LLSE_BACKEND_PYTHON
18-
19-
#endif
20-
21-
#ifdef LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS
22-
23-
#define LLSE_BACKEND_NODEJS
24-
25-
#endif
26-
273
///////////////////////// Configs /////////////////////////
284

29-
// Plugins & Base libs path
30-
#define LLSE_DEPENDS_DIR "./plugins/lib"
31-
#define LLSE_PLUGINS_LOAD_DIR "./plugins"
32-
33-
// Plugin package information
34-
#define LLSE_PLUGIN_PACKAGE_EXTENSION ".llplugin"
35-
#define LLSE_PLUGIN_PACKAGE_UNCOMPRESS_TIMEOUT 30000
36-
37-
// Current language information
38-
#define LLSE_BACKEND_NODEJS_NAME "NodeJs"
39-
#define LLSE_BACKEND_JS_NAME "Js"
40-
#define LLSE_BACKEND_LUA_NAME "Lua"
41-
#define LLSE_BACKEND_PYTHON_NAME "Python"
42-
43-
#if defined(LLSE_BACKEND_QUICKJS)
5+
#if defined(LEGACY_SCRIPT_ENGINE_BACKEND_QUICKJS)
446
// QuickJs
45-
#define LLSE_BACKEND_TYPE LLSE_BACKEND_JS_NAME
46-
#define LLSE_SOURCE_FILE_EXTENSION ".js"
47-
#define LLSE_PLUGINS_ROOT_DIR "plugins"
48-
#define LLSE_IS_PLUGIN_PACKAGE 0
7+
#define LLSE_BACKEND_TYPE "Js"
498

50-
#elif defined(LLSE_BACKEND_LUA)
9+
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_LUA)
5110
// Lua
52-
#define LLSE_BACKEND_TYPE LLSE_BACKEND_LUA_NAME
53-
#define LLSE_SOURCE_FILE_EXTENSION ".lua"
54-
#define LLSE_PLUGINS_ROOT_DIR "plugins"
55-
#define LLSE_IS_PLUGIN_PACKAGE 0
11+
#define LLSE_BACKEND_TYPE "Lua"
5612

57-
#elif defined(LLSE_BACKEND_NODEJS)
13+
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS)
5814
// NodeJs
59-
#define LLSE_BACKEND_TYPE LLSE_BACKEND_NODEJS_NAME
60-
#define LLSE_SOURCE_FILE_EXTENSION ".js"
61-
#define LLSE_PLUGINS_ROOT_DIR "plugins/nodejs"
62-
#define LLSE_IS_PLUGIN_PACKAGE 1
15+
#define LLSE_BACKEND_TYPE "NodeJs"
6316

64-
#elif defined(LLSE_BACKEND_PYTHON)
17+
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON)
6518
// Python
66-
#define LLSE_BACKEND_TYPE LLSE_BACKEND_PYTHON_NAME
67-
#define LLSE_SOURCE_FILE_EXTENSION ".py"
68-
#define LLSE_PLUGINS_ROOT_DIR "plugins/python"
69-
#define LLSE_IS_PLUGIN_PACKAGE 1
19+
#define LLSE_BACKEND_TYPE "Python"
7020
#endif
7121

7222
// All backends information
7323
#define LLSE_MODULE_TYPE LLSE_BACKEND_TYPE
74-
#define LLSE_VALID_BACKENDS std::vector<std::string>({"Js", "Lua", "NodeJs", "Python"})
75-
#define LLSE_VALID_BACKENDS_COUNT LLSE_VALID_BACKENDS.size()
76-
77-
// Loader information
78-
#if defined(LLSE_BACKEND_NODEJS)
79-
#define LLSE_LOADER_NAME "ScriptEngine-NodeJs"
80-
#define LLSE_LOADER_DESCRIPTION "Node.js ScriptEngine for LeviLamina"
81-
#elif defined(LLSE_BACKEND_QUICKJS)
82-
#define LLSE_LOADER_NAME "ScriptEngine-QuickJs"
83-
#define LLSE_LOADER_DESCRIPTION "Javascript ScriptEngine for LeviLamina"
84-
#elif defined(LLSE_BACKEND_LUA)
85-
#define LLSE_LOADER_NAME "ScriptEngine-Lua"
86-
#define LLSE_LOADER_DESCRIPTION "Lua ScriptEngine for LeviLamina"
87-
#elif defined(LLSE_BACKEND_PYTHON)
88-
#define LLSE_LOADER_NAME "ScriptEngine-Python"
89-
#define LLSE_LOADER_DESCRIPTION "Python ScriptEngine for LeviLamina"
90-
#endif
24+
#define LLSE_VALID_BACKENDS_COUNT 4
9125

9226
// Debug engine information
93-
#if defined(LLSE_BACKEND_NODEJS)
27+
#if defined(LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS)
9428
#define LLSE_DEBUG_CMD "nodejsdebug"
95-
#elif defined(LLSE_BACKEND_QUICKJS)
29+
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_QUICKJS)
9630
#define LLSE_DEBUG_CMD "jsdebug"
97-
#elif defined(LLSE_BACKEND_LUA)
31+
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_LUA)
9832
#define LLSE_DEBUG_CMD "luadebug"
99-
#elif defined(LLSE_BACKEND_PYTHON)
33+
#elif defined(LEGACY_SCRIPT_ENGINE_BACKEND_PYTHON)
10034
#define LLSE_DEBUG_CMD "pydebug"
10135
#endif
102-
#define LLSE_DEBUG_ENGINE_NAME "__LLSE_DEBUG_ENGINE__"
103-
10436
// Global communication
10537
#define LLSE_GLOBAL_DATA_NAME L"LLSE_GLOBAL_DATA_SECTION"
106-
#define LLSE_REMOTE_CALL_EVENT_NAME L"LLSE_REMOTE_CALL_EVENT"
10738
#define LLSE_MESSAGE_SYSTEM_WAIT_CHECK_INTERVAL 5
10839

109-
// Timeout
110-
#define LLSE_MAXWAIT_REMOTE_LOAD 10 * 1000
111-
#define LLSE_MAXWAIT_REMOTE_CALL 30 * 1000
112-
11340
// Thread pool parameter
114-
#define LLSE_POOL_THREAD_COUNT 4
115-
116-
// Others
117-
#define LLSE_7Z_PATH "./plugins/LeviLamina/bin/7za.exe"
41+
#define LLSE_POOL_THREAD_COUNT 4

src/legacy/main/NodeJsHelper.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22
#if defined(LEGACY_SCRIPT_ENGINE_BACKEND_NODEJS)
33
#pragma warning(disable : 4251)
4-
#include "main/Configs.h"
54

65
#include <ScriptX/ScriptX.h>
76
#include <map>
@@ -26,7 +25,7 @@ std::string getPluginPackageName(const std::string& dirPath);
2625
bool doesPluginPackHasDependency(const std::string& dirPath);
2726

2827
bool processConsoleNpmCmd(const std::string& cmd);
29-
int executeNpmCommand(std::string cmd, std::string workingDir = LLSE_PLUGINS_ROOT_DIR);
28+
int executeNpmCommand(std::string cmd, std::string workingDir = "plugins/legacy-script-engine-nodejs");
3029

3130
} // namespace NodeJsHelper
3231

0 commit comments

Comments
 (0)