diff --git a/atom/common/api/atom_api_asar.cc b/atom/common/api/atom_api_asar.cc index c9c355e42350..815940aae43a 100644 --- a/atom/common/api/atom_api_asar.cc +++ b/atom/common/api/atom_api_asar.cc @@ -131,24 +131,14 @@ void InitAsarSupport(v8::Isolate* isolate, v8::Local process, v8::Local require) { // Evaluate asar_init.js. - const char* asar_init_native = reinterpret_cast( - static_cast(node::asar_init_data)); - v8::Local asar_init = v8::Script::Compile(v8::String::NewFromUtf8( - isolate, - asar_init_native, - v8::String::kNormalString, - sizeof(node::asar_init_data) -1)); + v8::Local asar_init = + v8::Script::Compile(node::asar_init_value.ToStringChecked(isolate)); v8::Local result = asar_init->Run(); // Initialize asar support. if (result->IsFunction()) { - const char* asar_native = reinterpret_cast( - static_cast(node::asar_data)); - base::StringPiece asar_data(asar_native, sizeof(node::asar_data) - 1); v8::Local args[] = { - process, - require, - mate::ConvertToV8(isolate, asar_data), + process, require, node::asar_value.ToStringChecked(isolate), }; result.As()->Call(result, 3, args); } diff --git a/atom/renderer/atom_renderer_client.cc b/atom/renderer/atom_renderer_client.cc index 476bc5a4572b..40bcd4726064 100644 --- a/atom/renderer/atom_renderer_client.cc +++ b/atom/renderer/atom_renderer_client.cc @@ -181,11 +181,12 @@ void AtomRendererClient::SetupMainWorldOverrides( // Wrap the bundle into a function that receives the binding object as // an argument. - std::string bundle(node::isolated_bundle_data, - node::isolated_bundle_data + sizeof(node::isolated_bundle_data)); - std::string wrapper = "(function (binding, require) {\n" + bundle + "\n})"; - auto script = v8::Script::Compile( - mate::ConvertToV8(isolate, wrapper)->ToString()); + std::string left = "(function (binding, require) {\n"; + std::string right = "\n})"; + auto script = v8::Script::Compile(v8::String::Concat( + mate::ConvertToV8(isolate, left)->ToString(), + v8::String::Concat(node::isolated_bundle_value.ToStringChecked(isolate), + mate::ConvertToV8(isolate, right)->ToString()))); auto func = v8::Handle::Cast( script->Run(context).ToLocalChecked()); diff --git a/atom/renderer/atom_sandboxed_renderer_client.cc b/atom/renderer/atom_sandboxed_renderer_client.cc index 88d6b179bc9e..35f3f7dfd2c9 100644 --- a/atom/renderer/atom_sandboxed_renderer_client.cc +++ b/atom/renderer/atom_sandboxed_renderer_client.cc @@ -4,8 +4,6 @@ #include "atom/renderer/atom_sandboxed_renderer_client.h" -#include - #include "atom/common/api/api_messages.h" #include "atom/common/api/atom_bindings.h" #include "atom/common/native_mate_converters/string16_converter.h" @@ -171,16 +169,13 @@ void AtomSandboxedRendererClient::DidCreateScriptContext( v8::Context::Scope context_scope(context); // Wrap the bundle into a function that receives the binding object and the // preload script path as arguments. - std::string preload_bundle_native(node::preload_bundle_data, - node::preload_bundle_data + sizeof(node::preload_bundle_data)); - std::stringstream ss; - ss << "(function(binding, preloadPath, require) {\n"; - ss << preload_bundle_native << "\n"; - ss << "})"; - std::string preload_wrapper = ss.str(); + std::string left = "(function(binding, preloadPath, require) {\n"; + std::string right = "\n})"; // Compile the wrapper and run it to get the function object - auto script = v8::Script::Compile( - mate::ConvertToV8(isolate, preload_wrapper)->ToString()); + auto script = v8::Script::Compile(v8::String::Concat( + mate::ConvertToV8(isolate, left)->ToString(), + v8::String::Concat(node::preload_bundle_value.ToStringChecked(isolate), + mate::ConvertToV8(isolate, right)->ToString()))); auto func = v8::Handle::Cast( script->Run(context).ToLocalChecked()); // Create and initialize the binding object diff --git a/tools/js2c.py b/tools/js2c.py index ce4081077021..61f490067fe8 100755 --- a/tools/js2c.py +++ b/tools/js2c.py @@ -9,6 +9,19 @@ import sys SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) +TEMPLATE = """ +#ifndef ATOM_NATIVES_H_ +#define ATOM_NATIVES_H_ + +namespace node {{ + +{definitions} + +}} // namespace node + +#endif // ATOM_NATIVES_H_ +""" + def main(): natives = os.path.abspath(sys.argv[1]) @@ -23,7 +36,8 @@ def call_js2c(natives, js_source_files): with scoped_cwd(src_dir): subprocess.check_call( [sys.executable, js2c, natives] + - [os.path.basename(source) for source in js_source_files]) + [os.path.basename(source) for source in js_source_files] + + ['-t', TEMPLATE]) @contextlib.contextmanager diff --git a/vendor/node b/vendor/node index 584e6370849a..538a5023af0a 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit 584e6370849aa73025e6206109f25f441cb6cf9f +Subproject commit 538a5023af0a92ba19de2420a0eada6ad4cd18f6