[Pkg-javascript-commits] [node-leveldown] 248/492: use lower case names for properties in error messages
Andrew Kelley
andrewrk-guest at moszumanska.debian.org
Sun Jul 6 17:14:05 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 0dac784fa90a47270237619365524d06600287aa
Author: Lars-Magnus Skog <lars.magnus.skog at gmail.com>
Date: Sat Mar 9 09:16:32 2013 +0100
use lower case names for properties in error messages
removed last parameter in LD_STRING_OR_BUFFER_TO_SLICE() and used
the first parameter in the error message instead
---
src/database.cc | 31 +++++++++++++++----------------
src/iterator.cc | 4 ++--
src/leveldown.h | 6 +++---
test/put-get-del-test.js | 20 ++++++++++----------
4 files changed, 30 insertions(+), 31 deletions(-)
diff --git a/src/database.cc b/src/database.cc
index 8f1b3e3..c5df710 100644
--- a/src/database.cc
+++ b/src/database.cc
@@ -214,13 +214,13 @@ v8::Handle<v8::Value> Database::Put (const v8::Arguments& args) {
LD_METHOD_SETUP_COMMON(put, 2, 3)
- LD_CB_ERR_IF_NULL_OR_UNDEFINED(args[0], Key)
- LD_CB_ERR_IF_NULL_OR_UNDEFINED(args[1], Value)
+ LD_CB_ERR_IF_NULL_OR_UNDEFINED(args[0], key)
+ LD_CB_ERR_IF_NULL_OR_UNDEFINED(args[1], value)
v8::Local<v8::Value> keyBufferV = args[0];
v8::Local<v8::Value> valueBufferV = args[1];
- LD_STRING_OR_BUFFER_TO_SLICE(key, keyBufferV, Key)
- LD_STRING_OR_BUFFER_TO_SLICE(value, valueBufferV, Value)
+ LD_STRING_OR_BUFFER_TO_SLICE(key, keyBufferV)
+ LD_STRING_OR_BUFFER_TO_SLICE(value, valueBufferV)
v8::Persistent<v8::Value> keyBuffer =
v8::Persistent<v8::Value>::New(keyBufferV);
@@ -248,10 +248,10 @@ v8::Handle<v8::Value> Database::Get (const v8::Arguments& args) {
LD_METHOD_SETUP_COMMON(put, 1, 2)
- LD_CB_ERR_IF_NULL_OR_UNDEFINED(args[0], Key)
+ 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, Key)
+ LD_STRING_OR_BUFFER_TO_SLICE(key, keyBufferV)
v8::Persistent<v8::Value> keyBuffer = v8::Persistent<v8::Value>::New(keyBufferV);
@@ -276,10 +276,9 @@ v8::Handle<v8::Value> Database::Delete (const v8::Arguments& args) {
LD_METHOD_SETUP_COMMON(put, 1, 2)
- LD_CB_ERR_IF_NULL_OR_UNDEFINED(args[0], Key)
-
+ 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, Key)
+ LD_STRING_OR_BUFFER_TO_SLICE(key, keyBufferV)
v8::Persistent<v8::Value> keyBuffer =
v8::Persistent<v8::Value>::New(keyBufferV);
@@ -327,7 +326,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, Key)
+ LD_STRING_OR_BUFFER_TO_SLICE(key, keyBuffer)
operations->push_back(new BatchDelete(
key
@@ -337,8 +336,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, Key)
- LD_STRING_OR_BUFFER_TO_SLICE(value, valueBuffer, Value)
+ LD_STRING_OR_BUFFER_TO_SLICE(key, keyBuffer)
+ LD_STRING_OR_BUFFER_TO_SLICE(value, valueBuffer)
operations->push_back(new BatchWrite(
key
@@ -379,11 +378,11 @@ v8::Handle<v8::Value> Database::ApproximateSize (const v8::Arguments& args) {
LD_METHOD_SETUP_COMMON(approximateSize, -1, 2)
- LD_CB_ERR_IF_NULL_OR_UNDEFINED(args[0], Start)
- LD_CB_ERR_IF_NULL_OR_UNDEFINED(args[1], End)
+ 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, Start)
- LD_STRING_OR_BUFFER_TO_SLICE(end, endBufferV, End)
+ LD_STRING_OR_BUFFER_TO_SLICE(start, startBufferV)
+ LD_STRING_OR_BUFFER_TO_SLICE(end, endBufferV)
v8::Persistent<v8::Value> startBuffer =
v8::Persistent<v8::Value>::New(startBufferV);
diff --git a/src/iterator.cc b/src/iterator.cc
index 924e65d..69ff152 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, Start)
+ LD_STRING_OR_BUFFER_TO_SLICE(_start, startBuffer)
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, End)
+ LD_STRING_OR_BUFFER_TO_SLICE(_end, endBuffer)
end = new std::string(_end.data(), _end.size());
}
diff --git a/src/leveldown.h b/src/leveldown.h
index 056a52e..d291d6b 100644
--- a/src/leveldown.h
+++ b/src/leveldown.h
@@ -31,20 +31,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, name) \
+#define LD_STRING_OR_BUFFER_TO_SLICE(to, from) \
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, #name " argument cannot be an empty Buffer") \
+ LD_RETURN_CALLBACK_OR_ERROR(callback, #to " argument 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, #name " argument cannot be an empty String") \
+ LD_RETURN_CALLBACK_OR_ERROR(callback, #to " argument 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 63b66d0..e5cddb0 100644
--- a/test/put-get-del-test.js
+++ b/test/put-get-del-test.js
@@ -75,11 +75,11 @@ test('setUp', function (t) {
/**** TEST ERROR KEYS ****/
-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('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/)
/**** TEST NON-ERROR KEYS ****/
@@ -103,11 +103,11 @@ makePutGetDelSuccessfulTest('Array value', 'foo', [1,2,3,4])
/**** TEST ERROR VALUES ****/
-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('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/)
// 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