[Pkg-javascript-commits] [node-leveldown] 359/492: remove node_isolate, unavailable from Node 0.11.3+
Andrew Kelley
andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:14:17 UTC 2014
This is an automated email from the git hooks/post-receive script.
andrewrk-guest pushed a commit to annotated tag rocksdb-0.10.1
in repository node-leveldown.
commit bb3ab761242686647f8ef102f418695f6dbea4e6
Author: Rod Vagg <rod at vagg.org>
Date: Sun Jun 16 19:19:15 2013 +1000
remove node_isolate, unavailable from Node 0.11.3+
also fixed up a bunch of other isolate related things,
sadly introducing more defines.. needed while we still
want Node 0.8/0.10 support
---
bench/write-random-plot.sh | 10 ++++++----
bench/write-random.js | 6 +++---
src/async.cc | 8 ++++++--
src/batch.cc | 20 ++++++++++++++------
src/database.cc | 38 ++++++++++++++++++++++++++------------
src/database_async.cc | 12 +++++++++---
src/iterator.cc | 15 +++++++++++----
src/iterator_async.cc | 3 ++-
src/leveldown.cc | 6 ++++--
src/leveldown.h | 32 ++++++++++++++++++++++----------
10 files changed, 103 insertions(+), 47 deletions(-)
diff --git a/bench/write-random-plot.sh b/bench/write-random-plot.sh
index 6180456..f9294ae 100755
--- a/bench/write-random-plot.sh
+++ b/bench/write-random-plot.sh
@@ -7,6 +7,7 @@ gnuplot <<EOF
set datafile separator ','
#set yrange [0:0.6]
+ set logscale y
set xlabel "Seconds"
set ylabel "Milliseconds per write"
@@ -15,8 +16,9 @@ gnuplot <<EOF
set key below
set grid
- plot "write_random_times_g.csv" using (\$1/1000):(\$2/1000000) title "Google LevelDB" lc rgb "red" lt 7 ps 0.3, \
- "write_random_times_h.csv" using (\$1/1000):(\$2/1000000) title "HyperDex LevelDB" lc rgb "green" lt 7 ps 0.3, \
- "write_random_times_b.csv" using (\$1/1000):(\$2/1000000) title "Basho LevelDB" lc rgb "blue" lt 7 ps 0.3
+ plot "write_random_times_g32.csv" using (\$1/1000):(\$2/1000000) title "Google LevelDB" lc rgb "red" lt 7 ps 0.3, \
+ "write_random_times_h32.csv" using (\$1/1000):(\$2/1000000) title "HyperDex LevelDB" lc rgb "green" lt 7 ps 0.3, \
+ "write_random_times_b32.csv" using (\$1/1000):(\$2/1000000) title "Basho LevelDB" lc rgb "blue" lt 7 ps 0.3, \
+ "write_random_times.csv" using (\$1/1000):(\$2/1000000) title "LMDB" lc rgb "black" lt 7 ps 0.3
-EOF
\ No newline at end of file
+EOF
diff --git a/bench/write-random.js b/bench/write-random.js
index ff32025..a8d419f 100644
--- a/bench/write-random.js
+++ b/bench/write-random.js
@@ -1,4 +1,4 @@
-const leveldown = require('../')
+const leveldown = require('../../lmdb/')
, crypto = require('crypto')
, fs = require('fs')
, du = require('du')
@@ -24,7 +24,7 @@ function report (ms) {
console.log('Wrote times to ', timesFile)
}
-db.open({ errorIfExists: true, createIfMissing: true }, function (err) {
+db.open(function (err) {
if (err)
throw err
@@ -66,4 +66,4 @@ db.open({ errorIfExists: true, createIfMissing: true }, function (err) {
}
write()
-})
\ No newline at end of file
+})
diff --git a/src/async.cc b/src/async.cc
index c24bb11..45c90c5 100644
--- a/src/async.cc
+++ b/src/async.cc
@@ -25,7 +25,9 @@ AsyncWorker::AsyncWorker (
AsyncWorker::~AsyncWorker () {}
void AsyncWorker::WorkComplete () {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
+
if (status.ok())
HandleOKCallback();
else
@@ -38,7 +40,9 @@ void AsyncWorker::HandleOKCallback () {
}
void AsyncWorker::HandleErrorCallback () {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
+
v8::Local<v8::Value> argv[] = {
v8::Local<v8::Value>::New(
v8::Exception::Error(v8::String::New(status.ToString().c_str()))
diff --git a/src/batch.cc b/src/batch.cc
index 9e15a4e..3e68a52 100644
--- a/src/batch.cc
+++ b/src/batch.cc
@@ -29,6 +29,7 @@ leveldb::Status Batch::Write () {
}
void Batch::Init () {
+ LD_NODE_ISOLATE_DECL
v8::Local<v8::FunctionTemplate> tpl = v8::FunctionTemplate::New(Batch::New);
tpl->SetClassName(v8::String::NewSymbol("Batch"));
tpl->InstanceTemplate()->SetInternalFieldCount(1);
@@ -54,7 +55,8 @@ void Batch::Init () {
}
v8::Handle<v8::Value> Batch::New (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
Database* database = node::ObjectWrap::Unwrap<Database>(args[0]->ToObject());
v8::Local<v8::Object> optionsObj;
@@ -76,7 +78,9 @@ v8::Handle<v8::Value> Batch::NewInstance (
, v8::Handle<v8::Object> optionsObj
) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
+
v8::Local<v8::Object> instance;
if (optionsObj.IsEmpty()) {
@@ -91,7 +95,8 @@ v8::Handle<v8::Value> Batch::NewInstance (
}
v8::Handle<v8::Value> Batch::Put (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
Batch* batch = ObjectWrap::Unwrap<Batch>(args.Holder());
@@ -126,7 +131,8 @@ v8::Handle<v8::Value> Batch::Put (const v8::Arguments& args) {
}
v8::Handle<v8::Value> Batch::Del (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
Batch* batch = ObjectWrap::Unwrap<Batch>(args.Holder());
@@ -154,7 +160,8 @@ v8::Handle<v8::Value> Batch::Del (const v8::Arguments& args) {
}
v8::Handle<v8::Value> Batch::Clear (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
Batch* batch = ObjectWrap::Unwrap<Batch>(args.Holder());
@@ -169,7 +176,8 @@ v8::Handle<v8::Value> Batch::Clear (const v8::Arguments& args) {
}
v8::Handle<v8::Value> Batch::Write (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
Batch* batch = ObjectWrap::Unwrap<Batch>(args.Holder());
diff --git a/src/database.cc b/src/database.cc
index 07b6f9b..9eba91b 100644
--- a/src/database.cc
+++ b/src/database.cc
@@ -120,11 +120,14 @@ void Database::CloseDatabase () {
v8::Persistent<v8::Function> Database::constructor;
v8::Handle<v8::Value> LevelDOWN (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
+
return scope.Close(Database::NewInstance(args));
}
void Database::Init () {
+ LD_NODE_ISOLATE_DECL
v8::Local<v8::FunctionTemplate> tpl = v8::FunctionTemplate::New(New);
tpl->SetClassName(v8::String::NewSymbol("Database"));
tpl->InstanceTemplate()->SetInternalFieldCount(1);
@@ -170,7 +173,8 @@ void Database::Init () {
}
v8::Handle<v8::Value> Database::New (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
if (args.Length() == 0) {
LD_THROW_RETURN(constructor requires at least a location argument)
@@ -189,7 +193,8 @@ v8::Handle<v8::Value> Database::New (const v8::Arguments& args) {
}
v8::Handle<v8::Value> Database::NewInstance (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
v8::Local<v8::Object> instance;
@@ -204,7 +209,8 @@ v8::Handle<v8::Value> Database::NewInstance (const v8::Arguments& args) {
}
v8::Handle<v8::Value> Database::Open (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
LD_METHOD_SETUP_COMMON(open, 0, 1)
@@ -260,7 +266,8 @@ v8::Handle<v8::Value> Database::Open (const v8::Arguments& args) {
}
v8::Handle<v8::Value> Database::Close (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
LD_METHOD_SETUP_COMMON_ONEARG(close)
@@ -312,7 +319,8 @@ v8::Handle<v8::Value> Database::Close (const v8::Arguments& args) {
}
v8::Handle<v8::Value> Database::Put (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
LD_METHOD_SETUP_COMMON(put, 2, 3)
@@ -346,7 +354,8 @@ v8::Handle<v8::Value> Database::Put (const v8::Arguments& args) {
}
v8::Handle<v8::Value> Database::Get (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
LD_METHOD_SETUP_COMMON(get, 1, 2)
@@ -376,7 +385,8 @@ v8::Handle<v8::Value> Database::Get (const v8::Arguments& args) {
}
v8::Handle<v8::Value> Database::Delete (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
LD_METHOD_SETUP_COMMON(del, 1, 2)
@@ -410,7 +420,8 @@ LD_SYMBOL ( str_del , del );
LD_SYMBOL ( str_put , put );
v8::Handle<v8::Value> Database::Batch (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
if ((args.Length() == 0 || args.Length() == 1) && !args[0]->IsArray()) {
v8::Local<v8::Object> optionsObj;
@@ -492,7 +503,8 @@ v8::Handle<v8::Value> Database::Batch (const v8::Arguments& args) {
}
v8::Handle<v8::Value> Database::ApproximateSize (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
v8::Local<v8::Value> startBufferV = args[0];
v8::Local<v8::Value> endBufferV = args[1];
@@ -534,7 +546,8 @@ v8::Handle<v8::Value> Database::ApproximateSize (const v8::Arguments& args) {
}
v8::Handle<v8::Value> Database::GetProperty (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
v8::Local<v8::Value> propertyV = args[0];
v8::Local<v8::Function> callback; // for LD_CB_ERR_IF_NULL_OR_UNDEFINED
@@ -561,7 +574,8 @@ v8::Handle<v8::Value> Database::GetProperty (const v8::Arguments& args) {
}
v8::Handle<v8::Value> Database::Iterator (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
Database* database = node::ObjectWrap::Unwrap<Database>(args.This());
diff --git a/src/database_async.cc b/src/database_async.cc
index bff1c2b..d9f83a5 100644
--- a/src/database_async.cc
+++ b/src/database_async.cc
@@ -64,7 +64,9 @@ void CloseWorker::Execute () {
}
void CloseWorker::WorkComplete () {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
+
HandleOKCallback();
callback.Dispose(LD_NODE_ISOLATE);
}
@@ -113,7 +115,9 @@ void ReadWorker::Execute () {
}
void ReadWorker::HandleOKCallback () {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
+
v8::Local<v8::Value> returnValue;
if (asBuffer)
returnValue = v8::Local<v8::Value>::New(
@@ -229,7 +233,9 @@ void ApproximateSizeWorker::WorkComplete() {
}
void ApproximateSizeWorker::HandleOKCallback () {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
+
v8::Local<v8::Value> returnValue = v8::Number::New((double) size);
v8::Local<v8::Value> argv[] = {
v8::Local<v8::Value>::New(v8::Null())
diff --git a/src/iterator.cc b/src/iterator.cc
index 076d886..52a2493 100644
--- a/src/iterator.cc
+++ b/src/iterator.cc
@@ -48,6 +48,7 @@ Iterator::Iterator (
Iterator::~Iterator () {
+ LD_NODE_ISOLATE_DECL
delete options;
startPtr.Dispose(LD_NODE_ISOLATE);
if (start != NULL)
@@ -127,7 +128,8 @@ void checkEndCallback (Iterator* iterator) {
//void *ctx, void (*callback)(void *ctx, leveldb::Slice key, leveldb::Slice value)
v8::Handle<v8::Value> Iterator::Next (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
Iterator* iterator = node::ObjectWrap::Unwrap<Iterator>(args.This());
@@ -157,7 +159,8 @@ v8::Handle<v8::Value> Iterator::Next (const v8::Arguments& args) {
}
v8::Handle<v8::Value> Iterator::End (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
Iterator* iterator = node::ObjectWrap::Unwrap<Iterator>(args.This());
@@ -190,6 +193,7 @@ v8::Handle<v8::Value> Iterator::End (const v8::Arguments& args) {
v8::Persistent<v8::Function> Iterator::constructor;
void Iterator::Init () {
+ LD_NODE_ISOLATE_DECL
v8::Local<v8::FunctionTemplate> tpl = v8::FunctionTemplate::New(New);
tpl->SetClassName(v8::String::NewSymbol("Iterator"));
tpl->InstanceTemplate()->SetInternalFieldCount(1);
@@ -212,7 +216,9 @@ v8::Handle<v8::Object> Iterator::NewInstance (
, v8::Handle<v8::Object> optionsObj
) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
+
v8::Local<v8::Object> instance;
if (optionsObj.IsEmpty()) {
@@ -227,7 +233,8 @@ v8::Handle<v8::Object> Iterator::NewInstance (
}
v8::Handle<v8::Value> Iterator::New (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
Database* database = node::ObjectWrap::Unwrap<Database>(args[0]->ToObject());
diff --git a/src/iterator_async.cc b/src/iterator_async.cc
index 5f6d886..55740af 100644
--- a/src/iterator_async.cc
+++ b/src/iterator_async.cc
@@ -33,7 +33,8 @@ void NextWorker::Execute () {
}
void NextWorker::HandleOKCallback () {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
v8::Local<v8::Value> returnKey;
if (iterator->keyAsBuffer) {
diff --git a/src/leveldown.cc b/src/leveldown.cc
index 3d9887f..5a3fc47 100644
--- a/src/leveldown.cc
+++ b/src/leveldown.cc
@@ -14,7 +14,8 @@
namespace leveldown {
v8::Handle<v8::Value> DestroyDB (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
if (args.Length() < 2) {
LD_THROW_RETURN(destroy() requires `location` and `callback` arguments)
@@ -46,7 +47,8 @@ v8::Handle<v8::Value> DestroyDB (const v8::Arguments& args) {
}
v8::Handle<v8::Value> RepairDB (const v8::Arguments& args) {
- v8::HandleScope scope;
+ LD_NODE_ISOLATE_DECL
+ LD_HANDLESCOPE
if (args.Length() < 2) {
LD_THROW_RETURN(repair() requires `location` and `callback` arguments)
diff --git a/src/leveldown.h b/src/leveldown.h
index 6578f80..bb4c544 100644
--- a/src/leveldown.h
+++ b/src/leveldown.h
@@ -55,22 +55,33 @@ static inline uint32_t UInt32OptionValue(
: def;
}
-// node_isolate stuff introduced with V8 upgrade, see https://github.com/joyent/node/pull/5077
-#if NODE_MODULE_VERSION > 0x000B
-# define LD_NODE_ISOLATE node::node_isolate
-# define LD_NODE_ISOLATE_PRE node::node_isolate,
-# define LD_NODE_ISOLATE_POST , node::node_isolate
+// V8 Isolate stuff introduced with V8 upgrade, see https://github.com/joyent/node/pull/5077
+#if (NODE_MODULE_VERSION > 0x000B)
+# define LD_NODE_ISOLATE_GET v8::Isolate::GetCurrent()
+# define LD_NODE_ISOLATE_DECL v8::Isolate* isolate = LD_NODE_ISOLATE_GET;
+# define LD_NODE_ISOLATE isolate
+# define LD_NODE_ISOLATE_PRE isolate,
+# define LD_NODE_ISOLATE_POST , isolate
#else
+# define LD_NODE_ISOLATE_GET
+# define LD_NODE_ISOLATE_DECL
# define LD_NODE_ISOLATE
# define LD_NODE_ISOLATE_PRE
# define LD_NODE_ISOLATE_POST
#endif
-#define LD_SYMBOL(var, key) \
- static const v8::Persistent<v8::String> var = \
- v8::Persistent<v8::String>::New( \
- LD_NODE_ISOLATE_PRE v8::String::NewSymbol(#key) \
- );
+#if (NODE_MODULE_VERSION > 0x000B)
+# define LD_SYMBOL(var, key) \
+ static const v8::Persistent<v8::String> var = \
+ v8::Persistent<v8::String>::New( \
+ LD_NODE_ISOLATE_GET, v8::String::NewSymbol(#key));
+# define LD_HANDLESCOPE v8::HandleScope scope(LD_NODE_ISOLATE);
+#else
+# define LD_SYMBOL(var, key) \
+ static const v8::Persistent<v8::String> var = \
+ v8::Persistent<v8::String>::New(v8::String::NewSymbol(#key));
+# define LD_HANDLESCOPE v8::HandleScope scope;
+#endif
#define LD_V8_METHOD(name) \
static v8::Handle<v8::Value> name (const v8::Arguments& args);
@@ -85,6 +96,7 @@ static inline uint32_t UInt32OptionValue(
static inline void DisposeStringOrBufferFromSlice(v8::Persistent<v8::Value> ptr
, leveldb::Slice slice) {
+ LD_NODE_ISOLATE_DECL
if (!node::Buffer::HasInstance(ptr))
delete[] slice.data();
ptr.Dispose(LD_NODE_ISOLATE);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-leveldown.git
More information about the Pkg-javascript-commits
mailing list