Skip to content

Commit

Permalink
refactor: load electron builtin modules with process._linkedBinding (#…
Browse files Browse the repository at this point in the history
…17247)

* refactor: load electron builtin modules with process._linkedBinding

NODE_BUILTING_MODULE_CONTEXT_AWARE and process.binding are
removed in nodejs/node#25829. This changes
uses the alternative available without any functionality change.

* chore: roll node
  • Loading branch information
deepak1556 authored and nitsakh committed Mar 28, 2019
1 parent 0d7e655 commit b321bfe
Show file tree
Hide file tree
Showing 49 changed files with 55 additions and 49 deletions.
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_app.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1413,4 +1413,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_app, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_app, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_auto_updater.cc
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_auto_updater, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_auto_updater, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_browser_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_browser_view, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_browser_view, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_browser_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -481,4 +481,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_window, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_window, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_content_tracing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_content_tracing, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_content_tracing, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_debugger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,4 +205,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_debugger, Initialize);
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_debugger, Initialize);
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_desktop_capturer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_desktop_capturer, Initialize);
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_desktop_capturer, Initialize);
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_dialog, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_dialog, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_download_item.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_download_item, Initialize);
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_download_item, Initialize);
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_event.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_event, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_event, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_global_shortcut.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_global_shortcut, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_global_shortcut, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_in_app_purchase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_in_app_purchase, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_in_app_purchase, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_menu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_menu, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_menu, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_net.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_net, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_net, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_notification.cc
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_notification, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_common_notification, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_power_monitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,4 +148,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_power_monitor, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_power_monitor, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_power_save_blocker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_power_save_blocker, Initialize);
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_power_save_blocker, Initialize);
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_protocol.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,4 +317,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_protocol, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_protocol, Initialize)
4 changes: 2 additions & 2 deletions atom/browser/api/atom_api_render_process_preferences.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_render_process_preferences,
Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_render_process_preferences,
Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_screen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_screen, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_common_screen, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -819,4 +819,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_session, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_session, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_system_preferences.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_system_preferences, Initialize);
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_system_preferences, Initialize);
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_top_level_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1199,4 +1199,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_top_level_window, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_top_level_window, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_tray.cc
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_tray, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_tray, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_view, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_view, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_web_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2299,4 +2299,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_contents, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_web_contents, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_web_contents_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_contents_view, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_web_contents_view, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/atom_api_web_view_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_web_view_manager, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_web_view_manager, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/views/atom_api_box_layout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_box_layout, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_box_layout, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/views/atom_api_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_button, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_button, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/views/atom_api_label_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_label_button, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_label_button, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/views/atom_api_layout_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_layout_manager, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_layout_manager, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/views/atom_api_md_text_button.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_md_text_button, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_md_text_button, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/views/atom_api_resize_area.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_resize_area, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_resize_area, Initialize)
2 changes: 1 addition & 1 deletion atom/browser/api/views/atom_api_text_field.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_browser_text_field, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_browser_text_field, Initialize)
2 changes: 1 addition & 1 deletion atom/common/api/atom_api_asar.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_asar, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_common_asar, Initialize)
2 changes: 1 addition & 1 deletion atom/common/api/atom_api_clipboard.cc
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_clipboard, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_common_clipboard, Initialize)
2 changes: 1 addition & 1 deletion atom/common/api/atom_api_command_line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_command_line, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_common_command_line, Initialize)
2 changes: 1 addition & 1 deletion atom/common/api/atom_api_crash_reporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_crash_reporter, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_common_crash_reporter, Initialize)
2 changes: 1 addition & 1 deletion atom/common/api/atom_api_native_image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -652,4 +652,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_native_image, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_common_native_image, Initialize)
2 changes: 1 addition & 1 deletion atom/common/api/atom_api_shell.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_shell, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_common_shell, Initialize)
2 changes: 1 addition & 1 deletion atom/common/api/atom_api_v8_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_v8_util, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_common_v8_util, Initialize)
2 changes: 1 addition & 1 deletion atom/common/api/features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_common_features, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_common_features, Initialize)
2 changes: 1 addition & 1 deletion atom/common/node_bindings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
// __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_BUILTIN_MODULE_CONTEXT_AWARE.
// implementation when calling the NODE_LINKED_MODULE_CONTEXT_AWARE.
#define V(modname) void _register_##modname();
ELECTRON_BUILTIN_MODULES(V)
#if BUILDFLAG(ENABLE_VIEW_API)
Expand Down
6 changes: 6 additions & 0 deletions atom/common/node_includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@
#include "node_options.h"
#include "node_platform.h"

// Alternative to NODE_MODULE_CONTEXT_AWARE_X.
// Allows to explicitly register builtin modules instead of using
// __attribute__((constructor)).
#define NODE_LINKED_MODULE_CONTEXT_AWARE(modname, regfunc) \
NODE_MODULE_CONTEXT_AWARE_CPP(modname, regfunc, nullptr, NM_F_LINKED)

#pragma pop_macro("ASSERT")
#pragma pop_macro("CHECK")
#pragma pop_macro("CHECK_EQ")
Expand Down
2 changes: 1 addition & 1 deletion atom/renderer/api/atom_api_renderer_ipc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_renderer_ipc, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_renderer_ipc, Initialize)
2 changes: 1 addition & 1 deletion atom/renderer/api/atom_api_web_frame.cc
Original file line number Diff line number Diff line change
Expand Up @@ -548,4 +548,4 @@ void Initialize(v8::Local<v8::Object> exports,

} // namespace

NODE_BUILTIN_MODULE_CONTEXT_AWARE(atom_renderer_web_frame, Initialize)
NODE_LINKED_MODULE_CONTEXT_AWARE(atom_renderer_web_frame, Initialize)
2 changes: 1 addition & 1 deletion atom/renderer/atom_sandboxed_renderer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ v8::Local<v8::Value> GetBinding(v8::Isolate* isolate,
return exports;
}

auto* mod = node::binding::get_builtin_module(module_key.c_str());
auto* mod = node::binding::get_linked_module(module_key.c_str());

if (!mod) {
char errmsg[1024];
Expand Down
2 changes: 1 addition & 1 deletion lib/common/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const timers = require('timers')
const util = require('util')

process.atomBinding = require('@electron/internal/common/atom-binding-setup')(process.binding, process.type)
process.atomBinding = require('@electron/internal/common/atom-binding-setup')(process._linkedBinding, process.type)

// setImmediate and process.nextTick makes use of uv_check and uv_prepare to
// run the callbacks, however since we only run uv loop on requests, the
Expand Down

0 comments on commit b321bfe

Please sign in to comment.