[Pkg-javascript-commits] [node-leveldown] 275/492: add 'name' argument back to LD_STRING_OR_BUFFER_TO_SLICE
Andrew Kelley
andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:14:08 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 bc9f56334123a1de897681531546e1df838691fc
Author: Rod Vagg <rod at vagg.org>
Date: Sun Mar 17 16:43:20 2013 +1100
add 'name' argument back to LD_STRING_OR_BUFFER_TO_SLICE
---
src/batch.cc | 6 +++---
src/database.cc | 18 +++++++++---------
src/iterator.cc | 4 ++--
src/leveldown.h | 6 +++---
test/put-get-del-test.js | 12 ++++++------
5 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/src/batch.cc b/src/batch.cc
index 086abec..fa10f14 100644
--- a/src/batch.cc
+++ b/src/batch.cc
@@ -103,8 +103,8 @@ v8::Handle<v8::Value> Batch::Put (const v8::Arguments& args) {
v8::Local<v8::Value> keyBuffer = args[0];
v8::Local<v8::Value> valueBuffer = args[1];
- LD_STRING_OR_BUFFER_TO_SLICE(key, keyBuffer)
- LD_STRING_OR_BUFFER_TO_SLICE(value, valueBuffer)
+ LD_STRING_OR_BUFFER_TO_SLICE(key, keyBuffer, key)
+ LD_STRING_OR_BUFFER_TO_SLICE(value, valueBuffer, value)
if (node::Buffer::HasInstance(keyBuffer->ToObject()))
batch->references->push_back(v8::Persistent<v8::Value>::New(keyBuffer));
@@ -125,7 +125,7 @@ v8::Handle<v8::Value> Batch::Del (const v8::Arguments& args) {
LD_CB_ERR_IF_NULL_OR_UNDEFINED(args[0], key)
v8::Local<v8::Value> keyBuffer = args[0];
- LD_STRING_OR_BUFFER_TO_SLICE(key, keyBuffer)
+ LD_STRING_OR_BUFFER_TO_SLICE(key, keyBuffer, key)
if (node::Buffer::HasInstance(keyBuffer->ToObject()))
batch->references->push_back(v8::Persistent<v8::Value>::New(keyBuffer));
diff --git a/src/database.cc b/src/database.cc
index 0ddaa71..79dd17d 100644
--- a/src/database.cc
+++ b/src/database.cc
@@ -219,8 +219,8 @@ v8::Handle<v8::Value> Database::Put (const v8::Arguments& args) {
v8::Local<v8::Value> keyBufferV = args[0];
v8::Local<v8::Value> valueBufferV = args[1];
- LD_STRING_OR_BUFFER_TO_SLICE(key, keyBufferV)
- LD_STRING_OR_BUFFER_TO_SLICE(value, valueBufferV)
+ LD_STRING_OR_BUFFER_TO_SLICE(key, keyBufferV, key)
+ LD_STRING_OR_BUFFER_TO_SLICE(value, valueBufferV, value)
v8::Persistent<v8::Value> keyBuffer =
v8::Persistent<v8::Value>::New(keyBufferV);
@@ -251,7 +251,7 @@ v8::Handle<v8::Value> Database::Get (const v8::Arguments& args) {
LD_CB_ERR_IF_NULL_OR_UNDEFINED(args[0], key)
v8::Local<v8::Value> keyBufferV = args[0];
- LD_STRING_OR_BUFFER_TO_SLICE(key, keyBufferV)
+ LD_STRING_OR_BUFFER_TO_SLICE(key, keyBufferV, key)
v8::Persistent<v8::Value> keyBuffer = v8::Persistent<v8::Value>::New(keyBufferV);
@@ -279,7 +279,7 @@ v8::Handle<v8::Value> Database::Delete (const v8::Arguments& args) {
LD_CB_ERR_IF_NULL_OR_UNDEFINED(args[0], key)
v8::Local<v8::Value> keyBufferV = args[0];
- LD_STRING_OR_BUFFER_TO_SLICE(key, keyBufferV)
+ LD_STRING_OR_BUFFER_TO_SLICE(key, keyBufferV, key)
v8::Persistent<v8::Value> keyBuffer =
v8::Persistent<v8::Value>::New(keyBufferV);
@@ -338,7 +338,7 @@ v8::Handle<v8::Value> Database::Batch (const v8::Arguments& args) {
LD_CB_ERR_IF_NULL_OR_UNDEFINED(keyBuffer, key)
if (obj->Get(str_type)->StrictEquals(str_del)) {
- LD_STRING_OR_BUFFER_TO_SLICE(key, keyBuffer)
+ LD_STRING_OR_BUFFER_TO_SLICE(key, keyBuffer, key)
batch->Delete(key);
if (node::Buffer::HasInstance(keyBuffer->ToObject()))
@@ -347,8 +347,8 @@ v8::Handle<v8::Value> Database::Batch (const v8::Arguments& args) {
v8::Local<v8::Value> valueBuffer = obj->Get(str_value);
LD_CB_ERR_IF_NULL_OR_UNDEFINED(valueBuffer, value)
- LD_STRING_OR_BUFFER_TO_SLICE(key, keyBuffer)
- LD_STRING_OR_BUFFER_TO_SLICE(value, valueBuffer)
+ LD_STRING_OR_BUFFER_TO_SLICE(key, keyBuffer, key)
+ LD_STRING_OR_BUFFER_TO_SLICE(value, valueBuffer, value)
batch->Put(key, value);
if (node::Buffer::HasInstance(keyBuffer->ToObject()))
@@ -390,8 +390,8 @@ v8::Handle<v8::Value> Database::ApproximateSize (const v8::Arguments& args) {
LD_CB_ERR_IF_NULL_OR_UNDEFINED(args[0], start)
LD_CB_ERR_IF_NULL_OR_UNDEFINED(args[1], end)
- LD_STRING_OR_BUFFER_TO_SLICE(start, startBufferV)
- LD_STRING_OR_BUFFER_TO_SLICE(end, endBufferV)
+ LD_STRING_OR_BUFFER_TO_SLICE(start, startBufferV, start)
+ LD_STRING_OR_BUFFER_TO_SLICE(end, endBufferV, end)
v8::Persistent<v8::Value> startBuffer =
v8::Persistent<v8::Value>::New(startBufferV);
diff --git a/src/iterator.cc b/src/iterator.cc
index dc875e0..002a747 100644
--- a/src/iterator.cc
+++ b/src/iterator.cc
@@ -233,7 +233,7 @@ v8::Handle<v8::Value> Iterator::New (const v8::Arguments& args) {
|| optionsObj->Get(option_start)->IsString())) {
startBuffer = v8::Local<v8::Value>::New(optionsObj->Get(option_start));
- LD_STRING_OR_BUFFER_TO_SLICE(_start, startBuffer)
+ LD_STRING_OR_BUFFER_TO_SLICE(_start, startBuffer, start)
start = new leveldb::Slice(_start.data(), _start.size());
}
@@ -243,7 +243,7 @@ v8::Handle<v8::Value> Iterator::New (const v8::Arguments& args) {
v8::Local<v8::Value> endBuffer =
v8::Local<v8::Value>::New(optionsObj->Get(option_end));
- LD_STRING_OR_BUFFER_TO_SLICE(_end, endBuffer)
+ LD_STRING_OR_BUFFER_TO_SLICE(_end, endBuffer, end)
end = new std::string(_end.data(), _end.size());
}
diff --git a/src/leveldown.h b/src/leveldown.h
index 2de0dfa..e18634f 100644
--- a/src/leveldown.h
+++ b/src/leveldown.h
@@ -25,20 +25,20 @@
to = new char[to ## Sz_ + 1]; \
to ## Str->WriteUtf8(to, -1, NULL, v8::String::NO_OPTIONS);
-#define LD_STRING_OR_BUFFER_TO_SLICE(to, from) \
+#define LD_STRING_OR_BUFFER_TO_SLICE(to, from, name) \
size_t to ## Sz_; \
char* to ## Ch_; \
if (node::Buffer::HasInstance(from->ToObject())) { \
to ## Sz_ = node::Buffer::Length(from->ToObject()); \
if (to ## Sz_ == 0) { \
- LD_RETURN_CALLBACK_OR_ERROR(callback, #to " argument cannot be an empty Buffer") \
+ LD_RETURN_CALLBACK_OR_ERROR(callback, #name " cannot be an empty Buffer") \
} \
to ## Ch_ = node::Buffer::Data(from->ToObject()); \
} else { \
v8::Local<v8::String> to ## Str = from->ToString(); \
to ## Sz_ = to ## Str->Utf8Length(); \
if (to ## Sz_ == 0) { \
- LD_RETURN_CALLBACK_OR_ERROR(callback, #to " argument cannot be an empty String") \
+ LD_RETURN_CALLBACK_OR_ERROR(callback, #name " cannot be an empty String") \
} \
to ## Ch_ = new char[to ## Sz_]; \
to ## Str->WriteUtf8( \
diff --git a/test/put-get-del-test.js b/test/put-get-del-test.js
index b060a90..1612a1f 100644
--- a/test/put-get-del-test.js
+++ b/test/put-get-del-test.js
@@ -78,9 +78,9 @@ test('setUp db', function (t) {
makeErrorKeyTest('null key', null, /key cannot be `null` or `undefined`/)
makeErrorKeyTest('undefined key', undefined, /key cannot be `null` or `undefined`/)
-makeErrorKeyTest('empty String key', '', /key argument cannot be an empty String/)
-makeErrorKeyTest('empty Buffer key', new Buffer(0), /key argument cannot be an empty Buffer/)
-makeErrorKeyTest('empty Array key', [], /key argument cannot be an empty String/)
+makeErrorKeyTest('empty String key', '', /key cannot be an empty String/)
+makeErrorKeyTest('empty Buffer key', new Buffer(0), /key cannot be an empty Buffer/)
+makeErrorKeyTest('empty Array key', [], /key cannot be an empty String/)
/**** TEST NON-ERROR KEYS ****/
@@ -106,9 +106,9 @@ makePutGetDelSuccessfulTest('Array value', 'foo', [1,2,3,4])
makePutErrorTest('null value', 'foo', null, /value cannot be `null` or `undefined`/)
makePutErrorTest('undefined value', 'foo', undefined, /value cannot be `null` or `undefined`/)
-makePutErrorTest('empty String value', 'foo', '', /value argument cannot be an empty String/)
-makePutErrorTest('empty Buffer value', 'foo', new Buffer(0), /value argument cannot be an empty Buffer/)
-makePutErrorTest('empty Array value', 'foo', [], /value argument cannot be an empty String/)
+makePutErrorTest('empty String value', 'foo', '', /value cannot be an empty String/)
+makePutErrorTest('empty Buffer value', 'foo', new Buffer(0), /value cannot be an empty Buffer/)
+makePutErrorTest('empty Array value', 'foo', [], /value cannot be an empty String/)
// valid falsey values
makePutGetDelSuccessfulTest('`false` value', 'foo false', false)
--
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