abetomo
null+****@clear*****
Fri Sep 22 16:25:24 JST 2017
abetomo 2017-09-22 16:25:24 +0900 (Fri, 22 Sep 2017) New Revision: f60cee3c60821b32255123f492ff1e87f5a1f6cb https://github.com/nroonga/nroonga/commit/f60cee3c60821b32255123f492ff1e87f5a1f6cb Merged b325def: Merge pull request #31 from abetomo/fix_to_handle_on_addon Message: Fix to call addon's method directly Modified files: lib/nroonga.js src/nroonga.cc src/nroonga.h Modified: lib/nroonga.js (+1 -33) =================================================================== --- lib/nroonga.js 2017-09-22 16:22:43 +0900 (b9e8656) +++ lib/nroonga.js 2017-09-22 16:25:24 +0900 (526b89b) @@ -1,34 +1,2 @@ 'use strict' - -const nroonga = module.exports = require('../build/Release/nroonga_bindings.node') - -const optionsToCommandString = (command, options) => { - const args = [command] - - if (options) { - for (let key in options) { - if (options[key] != null) { - args.push('--' + key) - args.push(JSON.stringify(options[key])) - } - } - } - return args.join(' ') -} - -nroonga.Database.prototype.commandSync = function (command, options) { - const commandString = optionsToCommandString(command, options) - - return this.commandSyncString(commandString) -} - -nroonga.Database.prototype.command = function (command, options, callback) { - if (arguments.length === 2) { - callback = options - options = {} - } - - const commandString = optionsToCommandString(command, options) - - return this.commandString(commandString, callback) -} +module.exports = require('../build/Release/nroonga_bindings.node') Modified: src/nroonga.cc (+4 -5) =================================================================== --- src/nroonga.cc 2017-09-22 16:22:43 +0900 (5974d7c) +++ src/nroonga.cc 2017-09-22 16:25:24 +0900 (27ce4be) @@ -48,8 +48,8 @@ void Database::Initialize(v8::Local<v8::Object> exports) { tpl->SetClassName(Nan::New("Database").ToLocalChecked()); tpl->InstanceTemplate()->SetInternalFieldCount(1); - Nan::SetPrototypeMethod(tpl, "commandString", Database::CommandString); - Nan::SetPrototypeMethod(tpl, "commandSyncString", Database::CommandSyncString); + Nan::SetPrototypeMethod(tpl, "command", Database::Command); + Nan::SetPrototypeMethod(tpl, "commandSync", Database::CommandSync); Nan::SetPrototypeMethod(tpl, "close", Database::Close); groonga_context_constructor.Reset(tpl->GetFunction()); @@ -174,7 +174,7 @@ void Database::CommandAfter(uv_work_t* req) { delete baton; } -void Database::CommandString(const Nan::FunctionCallbackInfo<v8::Value>& info) { +void Database::Command(const Nan::FunctionCallbackInfo<v8::Value>& info) { Database *db = ObjectWrap::Unwrap<Database>(info.Holder()); if (info.Length() < 1 || !info[0]->IsString()) { Nan::ThrowTypeError("Bad parameter"); @@ -223,8 +223,7 @@ void Database::CommandString(const Nan::FunctionCallbackInfo<v8::Value>& info) { info.GetReturnValue().Set(Nan::Undefined()); } -void Database::CommandSyncString( - const Nan::FunctionCallbackInfo<v8::Value>& info) { +void Database::CommandSync(const Nan::FunctionCallbackInfo<v8::Value>& info) { Database *db = ObjectWrap::Unwrap<Database>(info.Holder()); if (info.Length() < 1 || !info[0]->IsString()) { Nan::ThrowTypeError("Bad parameter"); Modified: src/nroonga.h (+2 -2) =================================================================== --- src/nroonga.h 2017-09-22 16:22:43 +0900 (eb7c5ee) +++ src/nroonga.h 2017-09-22 16:25:24 +0900 (26c648e) @@ -27,8 +27,8 @@ class Database : public Nan::ObjectWrap { private: static void New(const Nan::FunctionCallbackInfo<v8::Value>& info); - static void CommandString(const Nan::FunctionCallbackInfo<v8::Value>& info); - static void CommandSyncString(const Nan::FunctionCallbackInfo<v8::Value>& info); + static void Command(const Nan::FunctionCallbackInfo<v8::Value>& info); + static void CommandSync(const Nan::FunctionCallbackInfo<v8::Value>& info); static void Close(const Nan::FunctionCallbackInfo<v8::Value>& info); static v8::Local<v8::String> optionsToCommandString( const Nan::FunctionCallbackInfo<v8::Value>& info); -------------- next part -------------- HTML����������������������������... URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20170922/1d00dd4f/attachment-0001.htm