From cf296c598f01b0f3bbc8b02e41eb971ba9ecdfad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=C3=B3in=20Martin?= Date: Thu, 9 Jul 2015 16:34:59 +0100 Subject: [PATCH 1/5] Remove excess logging. --- usb-detection.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/usb-detection.js b/usb-detection.js index 69dec6f..5684b3c 100644 --- a/usb-detection.js +++ b/usb-detection.js @@ -18,8 +18,6 @@ else detector.find = detection.find; detection.registerAdded(function(device) { - //console.log("registerAdded:", device, device.vendorId, device.productId); - console.log("registerAdded"); detector.emit('add', device); detector.emit('add:' + device.vendorId + ':' + device.productId, device); @@ -32,7 +30,6 @@ else }); detection.registerRemoved(function(device) { - console.log("registerRemoved"); detector.emit('remove', device); detector.emit('remove:' + device.vendorId + ':' + device.productId, device); @@ -63,4 +60,4 @@ else global[index.name] = detector; module.exports = detector; -} \ No newline at end of file +} From f050819c0f684d00d48b58e72de1b9c9fd2962a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?E=C3=B3in=20Martin?= Date: Thu, 9 Jul 2015 16:35:24 +0100 Subject: [PATCH 2/5] Remove excess logging. --- t.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/t.js b/t.js index 83aed15..5eca537 100644 --- a/t.js +++ b/t.js @@ -1,7 +1,6 @@ var monitor = require('./usb-detection'); monitor.find(function(err, devices) { - console.log("find: some devices"); }); monitor.find(vid, function(err, devices) { @@ -12,7 +11,6 @@ monitor.find(vid, pid, function(err, devices) { }); monitor.on('add', function(devices) { - console.log("add USB:", devices); }); @@ -25,7 +23,6 @@ monitor.on('add:vid:pid', function(devices) { }); monitor.on('remove', function(err, devices) { - console.log("remove USB "); }); @@ -38,7 +35,6 @@ monitor.on('remove:vid:pid', function(err, devices) { }); monitor.on('change', function(err, devices) { - console.log("change USB"); }); monitor.on('change:vid', function(err, devices) { @@ -47,4 +43,4 @@ monitor.on('change:vid', function(err, devices) { monitor.on('change:vid:pid', function(err, devices) { -}); \ No newline at end of file +}); From b6385f464cf38b060e24ab579d719a9dd1bd254d Mon Sep 17 00:00:00 2001 From: Eoin Martin Date: Tue, 22 Dec 2015 11:31:41 +0000 Subject: [PATCH 3/5] Nan 2.0 --- package.json | 2 +- src/detection.cpp | 34 +++++++++++++++++----------------- src/detection.h | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 0957413..8a3ddf3 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "dependencies": { "bindings": "1.1.0", "eventemitter2": ">=0.4.11", - "nan": "^1.8.4" + "nan": "^2.0.9" }, "gypfile": true, "scripts": { diff --git a/src/detection.cpp b/src/detection.cpp index 89bdc36..01ddf3e 100644 --- a/src/detection.cpp +++ b/src/detection.cpp @@ -11,10 +11,10 @@ #define OBJECT_ITEM_MOUNT_PATH "mountPath" -NanCallback* addedCallback; +Nan::Callback* addedCallback; bool isAddedRegistered = false; -NanCallback* removedCallback; +Nan::Callback* removedCallback; bool isRemovedRegistered = false; void RegisterAdded(const v8::FunctionCallbackInfo& args) @@ -26,7 +26,7 @@ void RegisterAdded(const v8::FunctionCallbackInfo& args) if (args.Length() == 0) { - return NanThrowTypeError("First argument must be a function"); + return Nan::ThrowTypeError("First argument must be a function"); } if (args.Length() == 1) @@ -34,7 +34,7 @@ void RegisterAdded(const v8::FunctionCallbackInfo& args) // callback if (!args[0]->IsFunction()) { - return NanThrowTypeError("First argument must be a function"); + return Nan::ThrowTypeError("First argument must be a function"); } callback = args[0].As(); @@ -51,7 +51,7 @@ void NotifyAdded(ListResultItem_t* it) if (isAddedRegistered) { - v8::Handle argv[1]; + v8::Local argv[1]; v8::Local item = v8::Object::New(isolate); @@ -101,7 +101,7 @@ void RegisterRemoved(const v8::FunctionCallbackInfo& args) if (args.Length() == 0) { - return NanThrowTypeError("First argument must be a function"); + return Nan::ThrowTypeError("First argument must be a function"); } if (args.Length() == 1) @@ -109,13 +109,13 @@ void RegisterRemoved(const v8::FunctionCallbackInfo& args) // callback if (!args[0]->IsFunction()) { - return NanThrowTypeError("First argument must be a function"); + return Nan::ThrowTypeError("First argument must be a function"); } callback = args[0].As(); } - removedCallback = new NanCallback(callback); + removedCallback = new Nan::Callback(callback); isRemovedRegistered = true; } @@ -126,7 +126,7 @@ void NotifyRemoved(ListResultItem_t* it) if (isRemovedRegistered) { - v8::Handle argv[1]; + v8::Local argv[1]; v8::Local item = v8::Object::New(isolate); @@ -176,7 +176,7 @@ void Find(const v8::FunctionCallbackInfo& args) if (args.Length() == 0) { - return NanThrowTypeError("First argument must be a function"); + return Nan::ThrowTypeError("First argument must be a function"); } if (args.Length() == 3) @@ -190,7 +190,7 @@ void Find(const v8::FunctionCallbackInfo& args) // callback if (!args[2]->IsFunction()) { - return NanThrowTypeError("Third argument must be a function"); + return Nan::ThrowTypeError("Third argument must be a function"); } callback = args[2].As(); @@ -206,7 +206,7 @@ void Find(const v8::FunctionCallbackInfo& args) // callback if (!args[1]->IsFunction()) { - return NanThrowTypeError("Second argument must be a function"); + return Nan::ThrowTypeError("Second argument must be a function"); } callback = args[1].As(); @@ -217,7 +217,7 @@ void Find(const v8::FunctionCallbackInfo& args) // callback if (!args[0]->IsFunction()) { - return NanThrowTypeError("First argument must be a function"); + return Nan::ThrowTypeError("First argument must be a function"); } callback = args[0].As(); @@ -225,7 +225,7 @@ void Find(const v8::FunctionCallbackInfo& args) ListBaton* baton = new ListBaton(); strcpy(baton->errorString, ""); - baton->callback = new NanCallback(callback); + baton->callback = new Nan::Callback(callback); //baton->callback = v8::Persistent::New(isolate, callback); //NanAssignPersistent(baton->callback, new NanCallback(callback)); @@ -246,12 +246,12 @@ void EIO_AfterFind(uv_work_t* req) ListBaton* data = static_cast(req->data); - v8::Handle argv[2]; + v8::Local argv[2]; if (data->errorString[0]) { argv[0] = v8::Exception::Error(v8::String::NewFromUtf8(isolate, data->errorString)); - argv[1] = NanUndefined(); + argv[1] = Nan::Undefined(); } else @@ -291,7 +291,7 @@ void EIO_AfterFind(uv_work_t* req) results->Set(i, item); } - argv[0] = NanUndefined(); + argv[0] = Nan::Undefined(); argv[1] = results; } diff --git a/src/detection.h b/src/detection.h index eb64f48..bfa9918 100644 --- a/src/detection.h +++ b/src/detection.h @@ -29,7 +29,7 @@ struct ListBaton public: //v8::Persistent callback; - NanCallback* callback; + Nan::Callback* callback; std::list results; char errorString[1024]; int vid; From e9d8374db77e2f2b6bb2fba78627522dd40775e9 Mon Sep 17 00:00:00 2001 From: Eoin Martin Date: Tue, 22 Dec 2015 11:32:42 +0000 Subject: [PATCH 4/5] Missed one --- src/detection.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection.cpp b/src/detection.cpp index 01ddf3e..969a5ad 100644 --- a/src/detection.cpp +++ b/src/detection.cpp @@ -40,7 +40,7 @@ void RegisterAdded(const v8::FunctionCallbackInfo& args) callback = args[0].As(); } - addedCallback = new NanCallback(callback); + addedCallback = new Nan::Callback(callback); isAddedRegistered = true; } From d15cd848a2243646a5ef9cdde6cb607a271ea031 Mon Sep 17 00:00:00 2001 From: Eoin Martin Date: Tue, 22 Dec 2015 11:37:24 +0000 Subject: [PATCH 5/5] Use handle just to test for now --- src/detection.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detection.cpp b/src/detection.cpp index 969a5ad..b158169 100644 --- a/src/detection.cpp +++ b/src/detection.cpp @@ -51,7 +51,7 @@ void NotifyAdded(ListResultItem_t* it) if (isAddedRegistered) { - v8::Local argv[1]; + v8::Handle argv[1]; v8::Local item = v8::Object::New(isolate); @@ -126,7 +126,7 @@ void NotifyRemoved(ListResultItem_t* it) if (isRemovedRegistered) { - v8::Local argv[1]; + v8::Handle argv[1]; v8::Local item = v8::Object::New(isolate);