chore: rename built-in modules to bindings to match naming update in node (#37182)
This commit is contained in:
parent
8b380ee2f2
commit
35a9e67dba
56 changed files with 103 additions and 100 deletions
|
@ -138,7 +138,7 @@ interface Process {
|
|||
At the very bottom of your `api_name.cc` file:
|
||||
|
||||
```cpp title='api_name.cc'
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_{api_name},Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_{api_name},Initialize)
|
||||
```
|
||||
|
||||
In your [`shell/common/node_bindings.cc`](https://github.com/electron/electron/blob/main/shell/common/node_bindings.cc) file, add your node binding name to Electron's built-in modules.
|
||||
|
|
|
@ -146,8 +146,8 @@ int NodeMain(int argc, char* argv[]) {
|
|||
feature_list->InitializeFromCommandLine("", "");
|
||||
base::FeatureList::SetInstance(std::move(feature_list));
|
||||
|
||||
// Explicitly register electron's builtin modules.
|
||||
NodeBindings::RegisterBuiltinModules();
|
||||
// Explicitly register electron's builtin bindings.
|
||||
NodeBindings::RegisterBuiltinBindings();
|
||||
|
||||
// Parse and set Node.js cli flags.
|
||||
int flags_exit_code = SetNodeCliFlags();
|
||||
|
|
|
@ -1865,4 +1865,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_app, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_app, Initialize)
|
||||
|
|
|
@ -149,4 +149,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_auto_updater, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_auto_updater, Initialize)
|
||||
|
|
|
@ -1359,4 +1359,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_base_window, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_base_window, Initialize)
|
||||
|
|
|
@ -221,4 +221,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_browser_view, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_browser_view, Initialize)
|
||||
|
|
|
@ -488,4 +488,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_window, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_window, Initialize)
|
||||
|
|
|
@ -178,4 +178,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_content_tracing, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_content_tracing, Initialize)
|
||||
|
|
|
@ -279,4 +279,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_crash_reporter, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_crash_reporter, Initialize)
|
||||
|
|
|
@ -356,4 +356,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_desktop_capturer, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_desktop_capturer, Initialize)
|
||||
|
|
|
@ -105,4 +105,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_dialog, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_dialog, Initialize)
|
||||
|
|
|
@ -25,4 +25,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_event, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_event, Initialize)
|
||||
|
|
|
@ -46,4 +46,4 @@ v8::Local<v8::Object> GetEventEmitterPrototype(v8::Isolate* isolate) {
|
|||
|
||||
} // namespace electron
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_event_emitter, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_event_emitter, Initialize)
|
||||
|
|
|
@ -195,4 +195,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_global_shortcut, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_global_shortcut, Initialize)
|
||||
|
|
|
@ -230,4 +230,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_in_app_purchase, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_in_app_purchase, Initialize)
|
||||
|
|
|
@ -321,4 +321,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_menu, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_menu, Initialize)
|
||||
|
|
|
@ -170,4 +170,4 @@ bool Converter<ui::NativeTheme::ThemeSource>::FromV8(
|
|||
|
||||
} // namespace gin
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_native_theme, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_native_theme, Initialize)
|
||||
|
|
|
@ -58,4 +58,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_net, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_net, Initialize)
|
||||
|
|
|
@ -299,4 +299,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_notification, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_notification, Initialize)
|
||||
|
|
|
@ -154,4 +154,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_power_monitor, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_power_monitor, Initialize)
|
||||
|
|
|
@ -139,5 +139,5 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_power_save_blocker,
|
||||
Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_power_save_blocker,
|
||||
Initialize)
|
||||
|
|
|
@ -111,4 +111,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_printing, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_printing, Initialize)
|
||||
|
|
|
@ -339,4 +339,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_protocol, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_protocol, Initialize)
|
||||
|
|
|
@ -73,5 +73,5 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_push_notifications,
|
||||
Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_push_notifications,
|
||||
Initialize)
|
||||
|
|
|
@ -131,4 +131,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
dict.SetMethod("decryptString", &electron::safestorage::DecryptString);
|
||||
}
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_safe_storage, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_safe_storage, Initialize)
|
||||
|
|
|
@ -196,4 +196,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_screen, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_screen, Initialize)
|
||||
|
|
|
@ -1313,4 +1313,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_session, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_session, Initialize)
|
||||
|
|
|
@ -132,5 +132,5 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_system_preferences,
|
||||
Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_system_preferences,
|
||||
Initialize)
|
||||
|
|
|
@ -436,4 +436,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_tray, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_tray, Initialize)
|
||||
|
|
|
@ -417,4 +417,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_utility_process, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_utility_process, Initialize)
|
||||
|
|
|
@ -76,4 +76,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_view, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_view, Initialize)
|
||||
|
|
|
@ -4244,4 +4244,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_web_contents, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_web_contents, Initialize)
|
||||
|
|
|
@ -131,4 +131,5 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_web_contents_view, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_web_contents_view,
|
||||
Initialize)
|
||||
|
|
|
@ -459,4 +459,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_web_frame_main, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_web_frame_main, Initialize)
|
||||
|
|
|
@ -47,4 +47,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_web_view_manager, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_web_view_manager, Initialize)
|
||||
|
|
|
@ -293,4 +293,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_message_port, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_message_port, Initialize)
|
||||
|
|
|
@ -56,4 +56,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_image_view, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_browser_image_view, Initialize)
|
||||
|
|
|
@ -36,4 +36,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_crashpad_support, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_crashpad_support, Initialize)
|
||||
|
|
|
@ -246,4 +246,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_asar, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_asar, Initialize)
|
||||
|
|
|
@ -291,4 +291,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_clipboard, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_clipboard, Initialize)
|
||||
|
|
|
@ -67,4 +67,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_command_line, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_command_line, Initialize)
|
||||
|
|
|
@ -42,4 +42,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_environment, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_environment, Initialize)
|
||||
|
|
|
@ -641,4 +641,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_native_image, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_native_image, Initialize)
|
||||
|
|
|
@ -186,4 +186,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_shell, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_shell, Initialize)
|
||||
|
|
|
@ -44,5 +44,5 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_testing, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_testing, Initialize)
|
||||
#endif
|
||||
|
|
|
@ -138,4 +138,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_v8_util, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_v8_util, Initialize)
|
||||
|
|
|
@ -84,4 +84,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_common_features, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_common_features, Initialize)
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
#include "shell/common/crash_keys.h"
|
||||
#endif
|
||||
|
||||
#define ELECTRON_BROWSER_MODULES(V) \
|
||||
#define ELECTRON_BROWSER_BINDINGS(V) \
|
||||
V(electron_browser_app) \
|
||||
V(electron_browser_auto_updater) \
|
||||
V(electron_browser_browser_view) \
|
||||
|
@ -78,7 +78,7 @@
|
|||
V(electron_browser_web_view_manager) \
|
||||
V(electron_browser_window)
|
||||
|
||||
#define ELECTRON_COMMON_MODULES(V) \
|
||||
#define ELECTRON_COMMON_BINDINGS(V) \
|
||||
V(electron_common_asar) \
|
||||
V(electron_common_clipboard) \
|
||||
V(electron_common_command_line) \
|
||||
|
@ -89,38 +89,39 @@
|
|||
V(electron_common_shell) \
|
||||
V(electron_common_v8_util)
|
||||
|
||||
#define ELECTRON_RENDERER_MODULES(V) \
|
||||
#define ELECTRON_RENDERER_BINDINGS(V) \
|
||||
V(electron_renderer_context_bridge) \
|
||||
V(electron_renderer_crash_reporter) \
|
||||
V(electron_renderer_ipc) \
|
||||
V(electron_renderer_web_frame)
|
||||
|
||||
#define ELECTRON_UTILITY_MODULES(V) V(electron_utility_parent_port)
|
||||
#define ELECTRON_UTILITY_BINDINGS(V) V(electron_utility_parent_port)
|
||||
|
||||
#define ELECTRON_VIEWS_MODULES(V) V(electron_browser_image_view)
|
||||
#define ELECTRON_VIEWS_BINDINGS(V) V(electron_browser_image_view)
|
||||
|
||||
#define ELECTRON_DESKTOP_CAPTURER_MODULE(V) V(electron_browser_desktop_capturer)
|
||||
#define ELECTRON_DESKTOP_CAPTURER_BINDINGS(V) \
|
||||
V(electron_browser_desktop_capturer)
|
||||
|
||||
#define ELECTRON_TESTING_MODULE(V) V(electron_common_testing)
|
||||
#define ELECTRON_TESTING_BINDINGS(V) V(electron_common_testing)
|
||||
|
||||
// This is used to load built-in modules. Instead of using
|
||||
// This is used to load built-in bindings. Instead of using
|
||||
// __attribute__((constructor)), we call the _register_<modname>
|
||||
// function for each built-in modules explicitly. This is only
|
||||
// forward declaration. The definitions are in each module's
|
||||
// implementation when calling the NODE_LINKED_MODULE_CONTEXT_AWARE.
|
||||
// function for each built-in bindings explicitly. This is only
|
||||
// forward declaration. The definitions are in each binding's
|
||||
// implementation when calling the NODE_LINKED_BINDING_CONTEXT_AWARE.
|
||||
#define V(modname) void _register_##modname();
|
||||
ELECTRON_BROWSER_MODULES(V)
|
||||
ELECTRON_COMMON_MODULES(V)
|
||||
ELECTRON_RENDERER_MODULES(V)
|
||||
ELECTRON_UTILITY_MODULES(V)
|
||||
ELECTRON_BROWSER_BINDINGS(V)
|
||||
ELECTRON_COMMON_BINDINGS(V)
|
||||
ELECTRON_RENDERER_BINDINGS(V)
|
||||
ELECTRON_UTILITY_BINDINGS(V)
|
||||
#if BUILDFLAG(ENABLE_VIEWS_API)
|
||||
ELECTRON_VIEWS_MODULES(V)
|
||||
ELECTRON_VIEWS_BINDINGS(V)
|
||||
#endif
|
||||
#if BUILDFLAG(ENABLE_DESKTOP_CAPTURER)
|
||||
ELECTRON_DESKTOP_CAPTURER_MODULE(V)
|
||||
ELECTRON_DESKTOP_CAPTURER_BINDINGS(V)
|
||||
#endif
|
||||
#if DCHECK_IS_ON()
|
||||
ELECTRON_TESTING_MODULE(V)
|
||||
ELECTRON_TESTING_BINDINGS(V)
|
||||
#endif
|
||||
#undef V
|
||||
|
||||
|
@ -336,29 +337,29 @@ NodeBindings::~NodeBindings() {
|
|||
stop_and_close_uv_loop(uv_loop_);
|
||||
}
|
||||
|
||||
void NodeBindings::RegisterBuiltinModules() {
|
||||
void NodeBindings::RegisterBuiltinBindings() {
|
||||
#define V(modname) _register_##modname();
|
||||
auto* command_line = base::CommandLine::ForCurrentProcess();
|
||||
std::string process_type =
|
||||
command_line->GetSwitchValueASCII(::switches::kProcessType);
|
||||
if (process_type.empty()) {
|
||||
ELECTRON_BROWSER_MODULES(V)
|
||||
ELECTRON_BROWSER_BINDINGS(V)
|
||||
#if BUILDFLAG(ENABLE_VIEWS_API)
|
||||
ELECTRON_VIEWS_MODULES(V)
|
||||
ELECTRON_VIEWS_BINDINGS(V)
|
||||
#endif
|
||||
#if BUILDFLAG(ENABLE_DESKTOP_CAPTURER)
|
||||
ELECTRON_DESKTOP_CAPTURER_MODULE(V)
|
||||
ELECTRON_DESKTOP_CAPTURER_BINDINGS(V)
|
||||
#endif
|
||||
}
|
||||
ELECTRON_COMMON_MODULES(V)
|
||||
ELECTRON_COMMON_BINDINGS(V)
|
||||
if (process_type == ::switches::kRendererProcess) {
|
||||
ELECTRON_RENDERER_MODULES(V)
|
||||
ELECTRON_RENDERER_BINDINGS(V)
|
||||
}
|
||||
if (process_type == ::switches::kUtilityProcess) {
|
||||
ELECTRON_UTILITY_MODULES(V)
|
||||
ELECTRON_UTILITY_BINDINGS(V)
|
||||
}
|
||||
#if DCHECK_IS_ON()
|
||||
ELECTRON_TESTING_MODULE(V)
|
||||
ELECTRON_TESTING_BINDINGS(V)
|
||||
#endif
|
||||
#undef V
|
||||
}
|
||||
|
@ -424,8 +425,8 @@ void NodeBindings::Initialize() {
|
|||
ElectronCommandLine::InitializeFromCommandLine();
|
||||
#endif
|
||||
|
||||
// Explicitly register electron's builtin modules.
|
||||
RegisterBuiltinModules();
|
||||
// Explicitly register electron's builtin bindings.
|
||||
RegisterBuiltinBindings();
|
||||
|
||||
// Parse and set Node.js cli flags.
|
||||
SetNodeCliFlags();
|
||||
|
|
|
@ -79,7 +79,7 @@ class NodeBindings {
|
|||
enum class BrowserEnvironment { kBrowser, kRenderer, kUtility, kWorker };
|
||||
|
||||
static NodeBindings* Create(BrowserEnvironment browser_env);
|
||||
static void RegisterBuiltinModules();
|
||||
static void RegisterBuiltinBindings();
|
||||
static bool IsInitialized();
|
||||
|
||||
virtual ~NodeBindings();
|
||||
|
|
|
@ -31,10 +31,10 @@
|
|||
|
||||
#include "electron/pop_node_defines.h"
|
||||
|
||||
// Alternative to NODE_MODULE_CONTEXT_AWARE_X.
|
||||
// Allows to explicitly register builtin modules instead of using
|
||||
// Alternative to NODE_BINDING_CONTEXT_AWARE_X.
|
||||
// Allows to explicitly register builtin bindings instead of using
|
||||
// __attribute__((constructor)).
|
||||
#define NODE_LINKED_MODULE_CONTEXT_AWARE(modname, regfunc) \
|
||||
#define NODE_LINKED_BINDING_CONTEXT_AWARE(modname, regfunc) \
|
||||
NODE_BINDING_CONTEXT_AWARE_CPP(modname, regfunc, nullptr, NM_F_LINKED)
|
||||
|
||||
#endif // ELECTRON_SHELL_COMMON_NODE_INCLUDES_H_
|
||||
|
|
|
@ -740,4 +740,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_renderer_context_bridge, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_renderer_context_bridge, Initialize)
|
||||
|
|
|
@ -42,4 +42,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_renderer_crash_reporter, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_renderer_crash_reporter, Initialize)
|
||||
|
|
|
@ -237,4 +237,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_renderer_ipc, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_renderer_ipc, Initialize)
|
||||
|
|
|
@ -916,4 +916,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_renderer_web_frame, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_renderer_web_frame, Initialize)
|
||||
|
|
|
@ -36,16 +36,16 @@ namespace electron {
|
|||
namespace {
|
||||
|
||||
const char kEmitProcessEventKey[] = "emit-process-event";
|
||||
const char kModuleCacheKey[] = "native-module-cache";
|
||||
const char kBindingCacheKey[] = "native-binding-cache";
|
||||
|
||||
v8::Local<v8::Object> GetModuleCache(v8::Isolate* isolate) {
|
||||
v8::Local<v8::Object> GetBindingCache(v8::Isolate* isolate) {
|
||||
auto context = isolate->GetCurrentContext();
|
||||
gin_helper::Dictionary global(isolate, context->Global());
|
||||
v8::Local<v8::Value> cache;
|
||||
|
||||
if (!global.GetHidden(kModuleCacheKey, &cache)) {
|
||||
if (!global.GetHidden(kBindingCacheKey, &cache)) {
|
||||
cache = v8::Object::New(isolate);
|
||||
global.SetHidden(kModuleCacheKey, cache);
|
||||
global.SetHidden(kBindingCacheKey, cache);
|
||||
}
|
||||
|
||||
return cache->ToObject(context).ToLocalChecked();
|
||||
|
@ -56,18 +56,19 @@ v8::Local<v8::Value> GetBinding(v8::Isolate* isolate,
|
|||
v8::Local<v8::String> key,
|
||||
gin_helper::Arguments* margs) {
|
||||
v8::Local<v8::Object> exports;
|
||||
std::string module_key = gin::V8ToString(isolate, key);
|
||||
gin_helper::Dictionary cache(isolate, GetModuleCache(isolate));
|
||||
std::string binding_key = gin::V8ToString(isolate, key);
|
||||
gin_helper::Dictionary cache(isolate, GetBindingCache(isolate));
|
||||
|
||||
if (cache.Get(module_key.c_str(), &exports)) {
|
||||
if (cache.Get(binding_key.c_str(), &exports)) {
|
||||
return exports;
|
||||
}
|
||||
|
||||
auto* mod = node::binding::get_linked_module(module_key.c_str());
|
||||
auto* mod = node::binding::get_linked_module(binding_key.c_str());
|
||||
|
||||
if (!mod) {
|
||||
char errmsg[1024];
|
||||
snprintf(errmsg, sizeof(errmsg), "No such module: %s", module_key.c_str());
|
||||
snprintf(errmsg, sizeof(errmsg), "No such binding: %s",
|
||||
binding_key.c_str());
|
||||
margs->ThrowError(errmsg);
|
||||
return exports;
|
||||
}
|
||||
|
@ -77,7 +78,7 @@ v8::Local<v8::Value> GetBinding(v8::Isolate* isolate,
|
|||
DCHECK_NE(mod->nm_context_register_func, nullptr);
|
||||
mod->nm_context_register_func(exports, v8::Null(isolate),
|
||||
isolate->GetCurrentContext(), mod->nm_priv);
|
||||
cache.Set(module_key.c_str(), exports);
|
||||
cache.Set(binding_key.c_str(), exports);
|
||||
return exports;
|
||||
}
|
||||
|
||||
|
@ -120,8 +121,8 @@ void InvokeEmitProcessEvent(v8::Handle<v8::Context> context,
|
|||
} // namespace
|
||||
|
||||
ElectronSandboxedRendererClient::ElectronSandboxedRendererClient() {
|
||||
// Explicitly register electron's builtin modules.
|
||||
NodeBindings::RegisterBuiltinModules();
|
||||
// Explicitly register electron's builtin bindings.
|
||||
NodeBindings::RegisterBuiltinBindings();
|
||||
metrics_ = base::ProcessMetrics::CreateCurrentProcessMetrics();
|
||||
}
|
||||
|
||||
|
|
|
@ -130,4 +130,4 @@ void Initialize(v8::Local<v8::Object> exports,
|
|||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_utility_parent_port, Initialize)
|
||||
NODE_LINKED_BINDING_CONTEXT_AWARE(electron_utility_parent_port, Initialize)
|
||||
|
|
Loading…
Reference in a new issue