From ef4a35bca5ca5596e04af367a8052959081a655e Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 22 Oct 2013 15:17:45 -0700 Subject: [PATCH] src: update after v8 api changes --- src/env-inl.h | 7 +++---- src/env.h | 2 +- src/node.cc | 12 ++++++++++-- test/common.js | 1 + 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/env-inl.h b/src/env-inl.h index 6fd6494..0c5d272 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -55,8 +55,7 @@ inline Environment::IsolateData::IsolateData(v8::Isolate* isolate) : event_loop_(uv_default_loop()), isolate_(isolate), #define V(PropertyName, StringValue) \ - PropertyName ## _index_( \ - FIXED_ONE_BYTE_STRING(isolate, StringValue).Eternalize(isolate)), + PropertyName ## _(isolate, FIXED_ONE_BYTE_STRING(isolate, StringValue)), PER_ISOLATE_STRING_PROPERTIES(V) #undef V ref_count_(0) { @@ -276,8 +275,8 @@ inline Environment::IsolateData* Environment::isolate_data() const { #define V(PropertyName, StringValue) \ inline \ v8::Local Environment::IsolateData::PropertyName() const { \ - return v8::Local::GetEternal(isolate(), \ - PropertyName ## _index_); \ + /* Strings are immutable so casting away const-ness here is okay. */ \ + return const_cast(this)->PropertyName ## _.Get(isolate()); \ } PER_ISOLATE_STRING_PROPERTIES(V) #undef V diff --git a/src/env.h b/src/env.h index 082e3d6..415e3dd 100644 --- a/src/env.h +++ b/src/env.h @@ -316,7 +316,7 @@ class Environment { v8::Isolate* const isolate_; #define V(PropertyName, StringValue) \ - const int PropertyName ## _index_; + v8::Eternal PropertyName ## _; PER_ISOLATE_STRING_PROPERTIES(V) #undef V diff --git a/src/node.cc b/src/node.cc index 696a942..dc3d4da 100644 --- a/src/node.cc +++ b/src/node.cc @@ -153,7 +153,8 @@ class ArrayBufferAllocator : public ArrayBuffer::Allocator { static ArrayBufferAllocator the_singleton; virtual ~ArrayBufferAllocator() {} virtual void* Allocate(size_t length); - virtual void Free(void* data); + virtual void* AllocateUninitialized(size_t length); + virtual void Free(void* data, size_t length); private: ArrayBufferAllocator() {} ArrayBufferAllocator(const ArrayBufferAllocator&); @@ -170,7 +171,14 @@ void* ArrayBufferAllocator::Allocate(size_t length) { } -void ArrayBufferAllocator::Free(void* data) { +void* ArrayBufferAllocator::AllocateUninitialized(size_t length) { + if (length > kMaxLength) + return NULL; + return new char[length]; +} + + +void ArrayBufferAllocator::Free(void* data, size_t length) { delete[] static_cast(data); } diff --git a/test/common.js b/test/common.js index 28faaf9..4ec99bb 100644 --- a/test/common.js +++ b/test/common.js @@ -97,6 +97,7 @@ process.on('exit', function() { clearInterval, clearImmediate, console, + constructor, // Enumerable in V8 3.21. Buffer, process, global]; -- 2.7.4