tools: pass custom template for js2c (#12593)

* Update node v9.7.0 ref

* tools: pass custom template to node/tools/js2c.py
This commit is contained in:
Robo 2018-04-13 17:50:04 +05:30 committed by Shelley Vohr
parent 9e5c264012
commit ad2baccefa
5 changed files with 31 additions and 31 deletions

View file

@ -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<v8::Function>::Cast(
script->Run(context).ToLocalChecked());

View file

@ -4,8 +4,6 @@
#include "atom/renderer/atom_sandboxed_renderer_client.h"
#include <string>
#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<v8::Function>::Cast(
script->Run(context).ToLocalChecked());
// Create and initialize the binding object