diff --git a/atom.gyp b/atom.gyp index cabb43d4f7..440eceee62 100644 --- a/atom.gyp +++ b/atom.gyp @@ -224,8 +224,6 @@ # Defined in Chromium but not exposed in its gyp file. 'V8_USE_EXTERNAL_STARTUP_DATA', 'ENABLE_PLUGINS', - # Needed by Node. - 'NODE_WANT_INTERNALS=1', ], 'sources': [ '<@(lib_sources)', diff --git a/atom/common/native_mate_converters/v8_value_converter.cc b/atom/common/native_mate_converters/v8_value_converter.cc index 0d5a257654..2270f0e0fd 100644 --- a/atom/common/native_mate_converters/v8_value_converter.cc +++ b/atom/common/native_mate_converters/v8_value_converter.cc @@ -11,6 +11,7 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/values.h" +#include "vendor/node/src/node_buffer.h" namespace atom { @@ -258,6 +259,10 @@ base::Value* V8ValueConverter::FromV8ValueImpl( return FromV8Object(val->ToObject(), state, isolate); } + if (node::Buffer::HasInstance(val)) { + return FromNodeBuffer(val, state, isolate); + } + if (val->IsObject()) { return FromV8Object(val->ToObject(), state, isolate); } @@ -305,6 +310,14 @@ base::Value* V8ValueConverter::FromV8Array( return result; } +base::Value* V8ValueConverter::FromNodeBuffer( + v8::Local value, + FromV8ValueState* state, + v8::Isolate* isolate) const { + return base::BinaryValue::CreateWithCopiedBuffer( + node::Buffer::Data(value), node::Buffer::Length(value)); +} + base::Value* V8ValueConverter::FromV8Object( v8::Local val, FromV8ValueState* state, diff --git a/atom/common/native_mate_converters/v8_value_converter.h b/atom/common/native_mate_converters/v8_value_converter.h index 3a0f6374cc..db108ad9b0 100644 --- a/atom/common/native_mate_converters/v8_value_converter.h +++ b/atom/common/native_mate_converters/v8_value_converter.h @@ -48,7 +48,9 @@ class V8ValueConverter { base::Value* FromV8Array(v8::Local array, FromV8ValueState* state, v8::Isolate* isolate) const; - + base::Value* FromNodeBuffer(v8::Local value, + FromV8ValueState* state, + v8::Isolate* isolate) const; base::Value* FromV8Object(v8::Local object, FromV8ValueState* state, v8::Isolate* isolate) const;