[Pkg-javascript-commits] [node-leveldown] 431/492: use MakeCallback() instead of Call(), closes #62

Andrew Kelley andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:14:26 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 0fee1d961fbd92981a6759e6afbc8b6193f21500
Author: Rod Vagg <rod at vagg.org>
Date:   Tue Nov 12 17:06:29 2013 +1100

    use MakeCallback() instead of Call(), closes #62
---
 src/batch.cc    |  2 +-
 src/database.cc | 13 +++++++------
 src/leveldown.h | 11 ++++-------
 3 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/src/batch.cc b/src/batch.cc
index 695dcb1..971868b 100644
--- a/src/batch.cc
+++ b/src/batch.cc
@@ -167,7 +167,7 @@ NAN_METHOD(Batch::Write) {
     BatchWriteWorker* worker  = new BatchWriteWorker(batch, callback);
     NanAsyncQueueWorker(worker);
   } else {
-    LD_RUN_CALLBACK(v8::Local<v8::Function>::Cast(args[0]), NULL, 0);
+    LD_RUN_CALLBACK(v8::Local<v8::Function>::Cast(args[0]), 0, NULL);
   }
 
   NanReturnUndefined();
diff --git a/src/database.cc b/src/database.cc
index 89b201e..b48caea 100644
--- a/src/database.cc
+++ b/src/database.cc
@@ -280,11 +280,12 @@ NAN_METHOD(Database::Close) {
           v8::Local<v8::Value> argv[] = {
               v8::FunctionTemplate::New()->GetFunction() // empty callback
           };
-          v8::TryCatch try_catch;
-          end->Call(NanObjectWrapHandle(iterator), 1, argv);
-          if (try_catch.HasCaught()) {
-            node::FatalException(try_catch);
-          }
+          node::MakeCallback(
+              NanObjectWrapHandle(iterator)
+            , end
+            , 1
+            , argv
+          );
         }
     }
   } else {
@@ -440,7 +441,7 @@ NAN_METHOD(Database::Batch) {
     ));
   } else {
     ClearReferences(references);
-    LD_RUN_CALLBACK(callback, NULL, 0);
+    LD_RUN_CALLBACK(callback, 0, NULL);
   }
 
   NanReturnUndefined();
diff --git a/src/leveldown.h b/src/leveldown.h
index b4e06ec..3d82795 100644
--- a/src/leveldown.h
+++ b/src/leveldown.h
@@ -73,17 +73,14 @@ static inline void DisposeStringOrBufferFromSlice(
         v8::String::New(msg))                                                  \
       )                                                                        \
     };                                                                         \
-    LD_RUN_CALLBACK(callback, argv, 1)                                         \
+    LD_RUN_CALLBACK(callback, 1, argv)                                         \
     NanReturnUndefined();                                                      \
   }                                                                            \
   return NanThrowError(msg);
 
-#define LD_RUN_CALLBACK(callback, argv, length)                                \
-  v8::TryCatch try_catch;                                                      \
-  callback->Call(v8::Context::GetCurrent()->Global(), length, argv);           \
-  if (try_catch.HasCaught()) {                                                 \
-    node::FatalException(try_catch);                                           \
-  }
+#define LD_RUN_CALLBACK(callback, argc, argv)                                  \
+  node::MakeCallback(                                                          \
+      v8::Context::GetCurrent()->Global(), callback, argc, argv);
 
 /* LD_METHOD_SETUP_COMMON setup the following objects:
  *  - Database* database

-- 
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