diff --git a/.travis.yml b/.travis.yml index 73ae414..23fd9d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,44 +1,73 @@ -language: node_js -node_js: -- '0.10' -- '0.11' -- '0.12' -compiler: clang +os: +- linux +- osx +# turn on new container-based infrastructure +sudo: false +language: cpp +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.8 + - g++-4.8-multilib + - gcc-multilib env: + matrix: + - TRAVIS_NODE_VERSION="0.10" + - TRAVIS_NODE_VERSION="0.12" + - TRAVIS_NODE_VERSION="4" + - TRAVIS_NODE_VERSION="0.10" ARCH="x86" + - TRAVIS_NODE_VERSION="0.12" ARCH="x86" + - TRAVIS_NODE_VERSION="4" ARCH="x86" global: - - secure: "Zg7w8hTpgVfm6JeTScsMhaexFcVS5N2oI9O/6MLtsm3CUhb0Txq65y4y/a5DU3re6Pl1ryE21anVLdg4RGDeykCauQtg8nFzuGXBfNn9bRTnsIfkiS9LNkbSZ8h3c7EsyX0NJ7LVgnkPh/XXMqMj4Nh0ovbBCwZJ6k2ZvccvDvU=" - - secure: "VS7JTJYfcCDOiWZH6g+Lm4y+QFuCB++4GnYvWqqaUljebuB2l8gZhDrmQtWKFPBEZP21ptjtpNWJC6hCUf07qJ81vVpb6wMUikfOOLN0nulED+AC5HtCxYnfwIu1i0z00YxaSfvozMXKk9TCLabE0ognoDV+XV1bQoYm8668z7E=" + - secure: "Zg7w8hTpgVfm6JeTScsMhaexFcVS5N2oI9O/6MLtsm3CUhb0Txq65y4y/a5DU3re6Pl1ryE21anVLdg4RGDeykCauQtg8nFzuGXBfNn9bRTnsIfkiS9LNkbSZ8h3c7EsyX0NJ7LVgnkPh/XXMqMj4Nh0ovbBCwZJ6k2ZvccvDvU=" + - secure: "VS7JTJYfcCDOiWZH6g+Lm4y+QFuCB++4GnYvWqqaUljebuB2l8gZhDrmQtWKFPBEZP21ptjtpNWJC6hCUf07qJ81vVpb6wMUikfOOLN0nulED+AC5HtCxYnfwIu1i0z00YxaSfvozMXKk9TCLabE0ognoDV+XV1bQoYm8668z7E=" +matrix: + exclude: + - os: osx + env: TRAVIS_NODE_VERSION="0.10" ARCH="x86" + - os: osx + env: TRAVIS_NODE_VERSION="0.12" ARCH="x86" + - os: osx + env: TRAVIS_NODE_VERSION="4" ARCH="x86" before_install: +# reinstall latest nvm +- rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $TRAVIS_NODE_VERSION +- BASE_URL=$(node -p "v=parseInt(process.versions.node),(v>=1&&v<4?'https://iojs.org/dist/':'https://nodejs.org/dist/')+process.version") +- X86_FILE=$(node -p "v=parseInt(process.versions.node),(v>=1&&v<4?'iojs':'node')+'-'+process.version+'-'+process.platform+'-x86'") +# download node if testing x86 architecture +- if [[ "$ARCH" == "x86" ]]; then wget $BASE_URL/$X86_FILE.tar.gz; tar -xf $X86_FILE.tar.gz; export PATH=$X86_FILE/bin:$PATH; fi +# reinstall npm and node-pre-gyp +- npm install -g node-gyp node-pre-gyp +# print versions +- npm --version +- node-gyp --version +- node-pre-gyp --version +# use g++-4.8 on Linux +- if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CXX=g++-4.8; fi +- $CXX --version # get commit message - COMMIT_MESSAGE=$(git show -s --format=%B $TRAVIS_COMMIT | tr -d '\n') -# put local node-pre-gyp on PATH -- export PATH=./node_modules/.bin/:$PATH -# put global node-gyp on PATH -- npm install node-gyp -g -# install aws-sdk so it is available for publishing -- npm install aws-sdk # figure out if we should publish - PUBLISH_BINARY=false # if we are building a tag then publish - if [[ $TRAVIS_BRANCH == `git describe --tags --always HEAD` ]]; then PUBLISH_BINARY=true; fi; # or if we put [publish binary] in the commit message - if test "${COMMIT_MESSAGE#*'[publish binary]'}" != "$COMMIT_MESSAGE"; then PUBLISH_BINARY=true; fi; -- platform=$(uname -s | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/") # If version is 0.9 do not publish to avoid duplicated binary error, caused by 0.9 and 0.10 # returning same v number in node.js. - if [[ "$TRAVIS_NODE_VERSION" == '0.9' ]]; then PUBLISH_BINARY=false; fi; -# Fix a problem with apt-get failing later, see http://docs.travis-ci.com/user/installing-dependencies/#Installing-Ubuntu-packages -- sudo apt-get update -qq - install: # ensure source install works - npm install --build-from-source + +script: # test our module - node serialport.js - -before_script: +- npm test - echo "Publishing native platform Binary Package? ->" $PUBLISH_BINARY # if publishing, do it - if [[ $PUBLISH_BINARY == true ]]; then node-pre-gyp package publish; fi; @@ -46,30 +75,6 @@ before_script: - node-pre-gyp clean - node-gyp clean -script: -# if publishing, test installing from remote -- INSTALL_RESULT=0 -- if [[ $PUBLISH_BINARY == true ]]; then INSTALL_RESULT=$(npm install --fallback-to-build=false > /dev/null)$? || true; fi; -# if install returned non zero (errored) then we first unpublish and then call false so travis will bail at this line -- if [[ $INSTALL_RESULT != 0 ]]; then echo "returned $INSTALL_RESULT";node-pre-gyp unpublish;false; fi -# If success then we arrive here so lets clean up -- node-pre-gyp clean -# node v0.8 and above provide pre-built 32 bit and 64 bit binaries -# so here we use the 32 bit ones to also test 32 bit builds -- NVER=`node -v` -- wget http://nodejs.org/dist/${NVER}/node-${NVER}-${platform}-x86.tar.gz -- tar xf node-${NVER}-${platform}-x86.tar.gz -# enable 32 bit node -- export PATH=$(pwd)/node-${NVER}-${platform}-x86/bin:$PATH -# install 32 bit compiler toolchain and X11 -- if [[ "$platform" == 'linux' ]]; then sudo apt-get -y install gcc-multilib g++-multilib; fi -# test source compile in 32 bit mode with internal libsqlite3 -- if [[ "$platform" == 'linux' ]]; then CC=gcc-4.6 CXX=g++-4.6 npm install --build-from-source; else npm install --build-from-source; fi -- npm test -# publish 32 bit build -- echo "Publishing x86 32bit Binary Package? ->" $PUBLISH_BINARY -- if [[ $PUBLISH_BINARY == true ]]; then node-pre-gyp package publish; fi; - after_success: # if success then query and display all published binaries - node-pre-gyp info diff --git a/package.json b/package.json index 218e4f6..44e657d 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,7 @@ "async": "0.9.0", "bindings": "1.2.1", "debug": "^2.1.1", - "nan": "~1.8.4", + "nan": "~2.0.0", "node-pre-gyp": "0.6.x", "optimist": "~0.6.1", "sf": "0.1.7" @@ -54,6 +54,7 @@ "node-pre-gyp" ], "devDependencies": { + "aws-sdk": "*", "mocha": "*", "chai": "*", "sinon-chai": "*", diff --git a/src/serialport.cpp b/src/serialport.cpp index f27275b..27c5bb8 100644 --- a/src/serialport.cpp +++ b/src/serialport.cpp @@ -87,75 +87,74 @@ static void deleteQForFD(const int fd) { NAN_METHOD(Open) { - NanScope(); // path - if(!args[0]->IsString()) { - NanThrowTypeError("First argument must be a string"); - NanReturnUndefined(); + if(!info[0]->IsString()) { + Nan::ThrowTypeError("First argument must be a string"); + return; } - v8::String::Utf8Value path(args[0]->ToString()); + v8::String::Utf8Value path(info[0]->ToString()); // options - if(!args[1]->IsObject()) { - NanThrowTypeError("Second argument must be an object"); - NanReturnUndefined(); + if(!info[1]->IsObject()) { + Nan::ThrowTypeError("Second argument must be an object"); + return; } - v8::Local options = args[1]->ToObject(); + v8::Local options = info[1]->ToObject(); // callback - if(!args[2]->IsFunction()) { - NanThrowTypeError("Third argument must be a function"); - NanReturnUndefined(); + if(!info[2]->IsFunction()) { + Nan::ThrowTypeError("Third argument must be a function"); + return; } - v8::Local callback = args[2].As(); + v8::Local callback = info[2].As(); OpenBaton* baton = new OpenBaton(); memset(baton, 0, sizeof(OpenBaton)); strcpy(baton->path, *path); - baton->baudRate = options->Get(NanNew("baudRate"))->ToInt32()->Int32Value(); - baton->dataBits = options->Get(NanNew("dataBits"))->ToInt32()->Int32Value(); - baton->bufferSize = options->Get(NanNew("bufferSize"))->ToInt32()->Int32Value(); - baton->parity = ToParityEnum(options->Get(NanNew("parity"))->ToString()); - baton->stopBits = ToStopBitEnum(options->Get(NanNew("stopBits"))->ToNumber()->NumberValue()); - baton->rtscts = options->Get(NanNew("rtscts"))->ToBoolean()->BooleanValue(); - baton->xon = options->Get(NanNew("xon"))->ToBoolean()->BooleanValue(); - baton->xoff = options->Get(NanNew("xoff"))->ToBoolean()->BooleanValue(); - baton->xany = options->Get(NanNew("xany"))->ToBoolean()->BooleanValue(); - baton->hupcl = options->Get(NanNew("hupcl"))->ToBoolean()->BooleanValue(); + baton->baudRate = Nan::Get(options, Nan::New("baudRate").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value(); + baton->dataBits = Nan::Get(options, Nan::New("dataBits").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value(); + baton->bufferSize = Nan::Get(options, Nan::New("bufferSize").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value(); + baton->parity = ToParityEnum(Nan::Get(options, Nan::New("parity").ToLocalChecked()).ToLocalChecked()->ToString()); + baton->stopBits = ToStopBitEnum(Nan::Get(options, Nan::New("stopBits").ToLocalChecked()).ToLocalChecked()->ToNumber()->NumberValue()); + baton->rtscts = Nan::Get(options, Nan::New("rtscts").ToLocalChecked()).ToLocalChecked()->ToBoolean()->BooleanValue(); + baton->xon = Nan::Get(options, Nan::New("xon").ToLocalChecked()).ToLocalChecked()->ToBoolean()->BooleanValue(); + baton->xoff = Nan::Get(options, Nan::New("xoff").ToLocalChecked()).ToLocalChecked()->ToBoolean()->BooleanValue(); + baton->xany = Nan::Get(options, Nan::New("xany").ToLocalChecked()).ToLocalChecked()->ToBoolean()->BooleanValue(); + baton->hupcl = Nan::Get(options, Nan::New("hupcl").ToLocalChecked()).ToLocalChecked()->ToBoolean()->BooleanValue(); - v8::Local platformOptions = options->Get(NanNew("platformOptions"))->ToObject(); + v8::Local platformOptions = Nan::Get(options, Nan::New("platformOptions").ToLocalChecked()).ToLocalChecked()->ToObject(); baton->platformOptions = ParsePlatformOptions(platformOptions); - baton->callback = new NanCallback(callback); - baton->dataCallback = new NanCallback(options->Get(NanNew("dataCallback")).As()); - baton->disconnectedCallback = new NanCallback(options->Get(NanNew("disconnectedCallback")).As()); - baton->errorCallback = new NanCallback(options->Get(NanNew("errorCallback")).As()); + baton->callback = new Nan::Callback(callback); + baton->dataCallback = new Nan::Callback(Nan::Get(options, Nan::New("dataCallback").ToLocalChecked()).ToLocalChecked().As()); + baton->disconnectedCallback = new Nan::Callback(Nan::Get(options, Nan::New("disconnectedCallback").ToLocalChecked()).ToLocalChecked().As()); + baton->errorCallback = new Nan::Callback(Nan::Get(options, Nan::New("errorCallback").ToLocalChecked()).ToLocalChecked().As()); uv_work_t* req = new uv_work_t(); req->data = baton; uv_queue_work(uv_default_loop(), req, EIO_Open, (uv_after_work_cb)EIO_AfterOpen); - NanReturnUndefined(); + return; } void EIO_AfterOpen(uv_work_t* req) { - NanScope(); + Nan::HandleScope scope; OpenBaton* data = static_cast(req->data); - v8::Handle argv[2]; + v8::Local argv[2]; if(data->errorString[0]) { - argv[0] = v8::Exception::Error(NanNew(data->errorString)); - argv[1] = NanUndefined(); + argv[0] = v8::Exception::Error(Nan::New(data->errorString).ToLocalChecked()); + argv[1] = Nan::Undefined(); // not needed for AfterOpenSuccess delete data->dataCallback; delete data->errorCallback; delete data->disconnectedCallback; } else { - argv[0] = NanUndefined(); - argv[1] = NanNew(data->result); + argv[0] = Nan::Undefined(); + argv[1] = Nan::New(data->result); int fd = argv[1]->ToInt32()->Int32Value(); newQForFD(fd); @@ -172,74 +171,73 @@ void EIO_AfterOpen(uv_work_t* req) { } NAN_METHOD(Update) { - NanScope(); // file descriptor - if(!args[0]->IsInt32()) { - NanThrowTypeError("First argument must be an int"); - NanReturnUndefined(); + if(!info[0]->IsInt32()) { + Nan::ThrowTypeError("First argument must be an int"); + return; } - int fd = args[0]->ToInt32()->Int32Value(); + int fd = info[0]->ToInt32()->Int32Value(); // options - if(!args[1]->IsObject()) { - NanThrowTypeError("Second argument must be an object"); - NanReturnUndefined(); + if(!info[1]->IsObject()) { + Nan::ThrowTypeError("Second argument must be an object"); + return; } - v8::Local options = args[1]->ToObject(); + v8::Local options = info[1]->ToObject(); // callback - if(!args[2]->IsFunction()) { - NanThrowTypeError("Third argument must be a function"); - NanReturnUndefined(); + if(!info[2]->IsFunction()) { + Nan::ThrowTypeError("Third argument must be a function"); + return; } - v8::Local callback = args[2].As(); + v8::Local callback = info[2].As(); OpenBaton* baton = new OpenBaton(); memset(baton, 0, sizeof(OpenBaton)); baton->fd = fd; - baton->baudRate = options->Get(NanNew("baudRate"))->ToInt32()->Int32Value(); - baton->dataBits = options->Get(NanNew("dataBits"))->ToInt32()->Int32Value(); - baton->bufferSize = options->Get(NanNew("bufferSize"))->ToInt32()->Int32Value(); - baton->parity = ToParityEnum(options->Get(NanNew("parity"))->ToString()); - baton->stopBits = ToStopBitEnum(options->Get(NanNew("stopBits"))->ToNumber()->NumberValue()); - baton->rtscts = options->Get(NanNew("rtscts"))->ToBoolean()->BooleanValue(); - baton->xon = options->Get(NanNew("xon"))->ToBoolean()->BooleanValue(); - baton->xoff = options->Get(NanNew("xoff"))->ToBoolean()->BooleanValue(); - baton->xany = options->Get(NanNew("xany"))->ToBoolean()->BooleanValue(); + baton->baudRate = Nan::Get(options, Nan::New("baudRate").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value(); + baton->dataBits = Nan::Get(options, Nan::New("dataBits").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value(); + baton->bufferSize = Nan::Get(options, Nan::New("bufferSize").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value(); + baton->parity = ToParityEnum(Nan::Get(options, Nan::New("parity").ToLocalChecked()).ToLocalChecked()->ToString()); + baton->stopBits = ToStopBitEnum(Nan::Get(options, Nan::New("stopBits").ToLocalChecked()).ToLocalChecked()->ToNumber()->NumberValue()); + baton->rtscts = Nan::Get(options, Nan::New("rtscts").ToLocalChecked()).ToLocalChecked()->ToBoolean()->BooleanValue(); + baton->xon = Nan::Get(options, Nan::New("xon").ToLocalChecked()).ToLocalChecked()->ToBoolean()->BooleanValue(); + baton->xoff = Nan::Get(options, Nan::New("xoff").ToLocalChecked()).ToLocalChecked()->ToBoolean()->BooleanValue(); + baton->xany = Nan::Get(options, Nan::New("xany").ToLocalChecked()).ToLocalChecked()->ToBoolean()->BooleanValue(); - v8::Local platformOptions = options->Get(NanNew("platformOptions"))->ToObject(); + v8::Local platformOptions = Nan::Get(options, Nan::New("platformOptions").ToLocalChecked()).ToLocalChecked()->ToObject(); baton->platformOptions = ParsePlatformOptions(platformOptions); - baton->callback = new NanCallback(callback); - baton->dataCallback = new NanCallback(options->Get(NanNew("dataCallback")).As()); - baton->disconnectedCallback = new NanCallback(options->Get(NanNew("disconnectedCallback")).As()); - baton->errorCallback = new NanCallback(options->Get(NanNew("errorCallback")).As()); + baton->callback = new Nan::Callback(callback); + baton->dataCallback = new Nan::Callback(Nan::Get(options, Nan::New("dataCallback").ToLocalChecked()).ToLocalChecked().As()); + baton->disconnectedCallback = new Nan::Callback(Nan::Get(options, Nan::New("disconnectedCallback").ToLocalChecked()).ToLocalChecked().As()); + baton->errorCallback = new Nan::Callback(Nan::Get(options, Nan::New("errorCallback").ToLocalChecked()).ToLocalChecked().As()); uv_work_t* req = new uv_work_t(); req->data = baton; uv_queue_work(uv_default_loop(), req, EIO_Update, (uv_after_work_cb)EIO_AfterUpdate); - NanReturnUndefined(); + return; } void EIO_AfterUpdate(uv_work_t* req) { - NanScope(); + Nan::HandleScope scope; OpenBaton* data = static_cast(req->data); - v8::Handle argv[2]; + v8::Local argv[2]; if(data->errorString[0]) { - argv[0] = v8::Exception::Error(NanNew(data->errorString)); - argv[1] = NanUndefined(); + argv[0] = v8::Exception::Error(Nan::New(data->errorString).ToLocalChecked()); + argv[1] = Nan::Undefined(); // not needed for AfterOpenSuccess delete data->dataCallback; delete data->errorCallback; delete data->disconnectedCallback; } else { - argv[0] = NanUndefined(); - argv[1] = NanNew(data->result); + argv[0] = Nan::Undefined(); + argv[1] = Nan::New(data->result); int fd = argv[1]->ToInt32()->Int32Value(); newQForFD(fd); @@ -256,39 +254,38 @@ void EIO_AfterUpdate(uv_work_t* req) { } NAN_METHOD(Write) { - NanScope(); // file descriptor - if(!args[0]->IsInt32()) { - NanThrowTypeError("First argument must be an int"); - NanReturnUndefined(); + if(!info[0]->IsInt32()) { + Nan::ThrowTypeError("First argument must be an int"); + return; } - int fd = args[0]->ToInt32()->Int32Value(); + int fd = info[0]->ToInt32()->Int32Value(); // buffer - if(!args[1]->IsObject() || !node::Buffer::HasInstance(args[1])) { - NanThrowTypeError("Second argument must be a buffer"); - NanReturnUndefined(); + if(!info[1]->IsObject() || !node::Buffer::HasInstance(info[1])) { + Nan::ThrowTypeError("Second argument must be a buffer"); + return; } - v8::Local buffer = args[1]->ToObject(); + v8::Local buffer = info[1]->ToObject(); char* bufferData = node::Buffer::Data(buffer); size_t bufferLength = node::Buffer::Length(buffer); // callback - if(!args[2]->IsFunction()) { - NanThrowTypeError("Third argument must be a function"); - NanReturnUndefined(); + if(!info[2]->IsFunction()) { + Nan::ThrowTypeError("Third argument must be a function"); + return; } - v8::Local callback = args[2].As(); + v8::Local callback = info[2].As(); WriteBaton* baton = new WriteBaton(); memset(baton, 0, sizeof(WriteBaton)); baton->fd = fd; - NanAssignPersistent(baton->buffer, buffer); + baton->buffer.Reset(buffer); baton->bufferData = bufferData; baton->bufferLength = bufferLength; baton->offset = 0; - baton->callback = new NanCallback(callback); + baton->callback = new Nan::Callback(callback); QueuedWrite* queuedWrite = new QueuedWrite(); memset(queuedWrite, 0, sizeof(QueuedWrite)); @@ -297,8 +294,8 @@ NAN_METHOD(Write) { _WriteQueue *q = qForFD(fd); if(!q) { - NanThrowTypeError("There's no write queue for that file descriptor (write)!"); - NanReturnUndefined(); + Nan::ThrowTypeError("There's no write queue for that file descriptor (write)!"); + return; } q->lock(); @@ -312,22 +309,22 @@ NAN_METHOD(Write) { } q->unlock(); - NanReturnUndefined(); + return; } void EIO_AfterWrite(uv_work_t* req) { - NanScope(); + Nan::HandleScope scope; QueuedWrite* queuedWrite = static_cast(req->data); WriteBaton* data = static_cast(queuedWrite->baton); - v8::Handle argv[2]; + v8::Local argv[2]; if(data->errorString[0]) { - argv[0] = v8::Exception::Error(NanNew(data->errorString)); - argv[1] = NanUndefined(); + argv[0] = v8::Exception::Error(Nan::New(data->errorString).ToLocalChecked()); + argv[1] = Nan::Undefined(); } else { - argv[0] = NanUndefined(); - argv[1] = NanNew(data->result); + argv[0] = Nan::Undefined(); + argv[1] = Nan::New(data->result); } data->callback->Call(2, argv); @@ -343,7 +340,7 @@ void EIO_AfterWrite(uv_work_t* req) { int fd = data->fd; _WriteQueue *q = qForFD(fd); if(!q) { - NanThrowTypeError("There's no write queue for that file descriptor (after write)!"); + Nan::ThrowTypeError("There's no write queue for that file descriptor (after write)!"); return; } @@ -361,51 +358,50 @@ void EIO_AfterWrite(uv_work_t* req) { } q->unlock(); - NanDisposePersistent(data->buffer); + data->buffer.Reset(); delete data->callback; delete data; delete queuedWrite; } NAN_METHOD(Close) { - NanScope(); // file descriptor - if(!args[0]->IsInt32()) { - NanThrowTypeError("First argument must be an int"); - NanReturnUndefined(); + if(!info[0]->IsInt32()) { + Nan::ThrowTypeError("First argument must be an int"); + return; } - int fd = args[0]->ToInt32()->Int32Value(); + int fd = info[0]->ToInt32()->Int32Value(); // callback - if(!args[1]->IsFunction()) { - NanThrowTypeError("Second argument must be a function"); - NanReturnUndefined(); + if(!info[1]->IsFunction()) { + Nan::ThrowTypeError("Second argument must be a function"); + return; } - v8::Local callback = args[1].As(); + v8::Local callback = info[1].As(); CloseBaton* baton = new CloseBaton(); memset(baton, 0, sizeof(CloseBaton)); baton->fd = fd; - baton->callback = new NanCallback(callback); + baton->callback = new Nan::Callback(callback); uv_work_t* req = new uv_work_t(); req->data = baton; uv_queue_work(uv_default_loop(), req, EIO_Close, (uv_after_work_cb)EIO_AfterClose); - NanReturnUndefined(); + return; } void EIO_AfterClose(uv_work_t* req) { - NanScope(); + Nan::HandleScope scope; CloseBaton* data = static_cast(req->data); - v8::Handle argv[1]; + v8::Local argv[1]; if(data->errorString[0]) { - argv[0] = v8::Exception::Error(NanNew(data->errorString)); + argv[0] = v8::Exception::Error(Nan::New(data->errorString).ToLocalChecked()); } else { - argv[0] = NanUndefined(); + argv[0] = Nan::Undefined(); // We don't have an error, so clean up the write queue for that fd @@ -415,7 +411,7 @@ void EIO_AfterClose(uv_work_t* req) { QueuedWrite &write_queue = q->get(); while (!write_queue.empty()) { QueuedWrite *del_q = write_queue.next; - NanDisposePersistent(del_q->baton->buffer); + del_q->baton->buffer.Reset(); del_q->remove(); } q->unlock(); @@ -432,50 +428,49 @@ void EIO_AfterClose(uv_work_t* req) { } NAN_METHOD(List) { - NanScope(); // callback - if(!args[0]->IsFunction()) { - NanThrowTypeError("First argument must be a function"); - NanReturnUndefined(); + if(!info[0]->IsFunction()) { + Nan::ThrowTypeError("First argument must be a function"); + return; } - v8::Local callback = args[0].As(); + v8::Local callback = info[0].As(); ListBaton* baton = new ListBaton(); strcpy(baton->errorString, ""); - baton->callback = new NanCallback(callback); + baton->callback = new Nan::Callback(callback); uv_work_t* req = new uv_work_t(); req->data = baton; uv_queue_work(uv_default_loop(), req, EIO_List, (uv_after_work_cb)EIO_AfterList); - NanReturnUndefined(); + return; } void EIO_AfterList(uv_work_t* req) { - NanScope(); + Nan::HandleScope scope; ListBaton* data = static_cast(req->data); - v8::Handle argv[2]; + v8::Local argv[2]; if(data->errorString[0]) { - argv[0] = v8::Exception::Error(NanNew(data->errorString)); - argv[1] = NanUndefined(); + argv[0] = v8::Exception::Error(Nan::New(data->errorString).ToLocalChecked()); + argv[1] = Nan::Undefined(); } else { - v8::Local results = NanNew(); + v8::Local results = Nan::New(); int i = 0; for(std::list::iterator it = data->results.begin(); it != data->results.end(); ++it, i++) { - v8::Local item = NanNew(); - item->Set(NanNew("comName"), NanNew((*it)->comName.c_str())); - item->Set(NanNew("manufacturer"), NanNew((*it)->manufacturer.c_str())); - item->Set(NanNew("serialNumber"), NanNew((*it)->serialNumber.c_str())); - item->Set(NanNew("pnpId"), NanNew((*it)->pnpId.c_str())); - item->Set(NanNew("locationId"), NanNew((*it)->locationId.c_str())); - item->Set(NanNew("vendorId"), NanNew((*it)->vendorId.c_str())); - item->Set(NanNew("productId"), NanNew((*it)->productId.c_str())); - results->Set(i, item); + v8::Local item = Nan::New(); + Nan::Set(item, Nan::New("comName").ToLocalChecked(), Nan::New((*it)->comName.c_str()).ToLocalChecked()); + Nan::Set(item, Nan::New("manufacturer").ToLocalChecked(), Nan::New((*it)->manufacturer.c_str()).ToLocalChecked()); + Nan::Set(item, Nan::New("serialNumber").ToLocalChecked(), Nan::New((*it)->serialNumber.c_str()).ToLocalChecked()); + Nan::Set(item, Nan::New("pnpId").ToLocalChecked(), Nan::New((*it)->pnpId.c_str()).ToLocalChecked()); + Nan::Set(item, Nan::New("locationId").ToLocalChecked(), Nan::New((*it)->locationId.c_str()).ToLocalChecked()); + Nan::Set(item, Nan::New("vendorId").ToLocalChecked(), Nan::New((*it)->vendorId.c_str()).ToLocalChecked()); + Nan::Set(item, Nan::New("productId").ToLocalChecked(), Nan::New((*it)->productId.c_str()).ToLocalChecked()); + Nan::Set(results, i, item); } - argv[0] = NanUndefined(); + argv[0] = Nan::Undefined(); argv[1] = results; } data->callback->Call(2, argv); @@ -489,47 +484,46 @@ void EIO_AfterList(uv_work_t* req) { } NAN_METHOD(Flush) { - NanScope(); // file descriptor - if(!args[0]->IsInt32()) { - NanThrowTypeError("First argument must be an int"); - NanReturnUndefined(); + if(!info[0]->IsInt32()) { + Nan::ThrowTypeError("First argument must be an int"); + return; } - int fd = args[0]->ToInt32()->Int32Value(); + int fd = info[0]->ToInt32()->Int32Value(); // callback - if(!args[1]->IsFunction()) { - NanThrowTypeError("Second argument must be a function"); - NanReturnUndefined(); + if(!info[1]->IsFunction()) { + Nan::ThrowTypeError("Second argument must be a function"); + return; } - v8::Local callback = args[1].As(); + v8::Local callback = info[1].As(); FlushBaton* baton = new FlushBaton(); memset(baton, 0, sizeof(FlushBaton)); baton->fd = fd; - baton->callback = new NanCallback(callback); + baton->callback = new Nan::Callback(callback); uv_work_t* req = new uv_work_t(); req->data = baton; uv_queue_work(uv_default_loop(), req, EIO_Flush, (uv_after_work_cb)EIO_AfterFlush); - NanReturnUndefined(); + return; } void EIO_AfterFlush(uv_work_t* req) { - NanScope(); + Nan::HandleScope scope; FlushBaton* data = static_cast(req->data); - v8::Handle argv[2]; + v8::Local argv[2]; if(data->errorString[0]) { - argv[0] = v8::Exception::Error(NanNew(data->errorString)); - argv[1] = NanUndefined(); + argv[0] = v8::Exception::Error(Nan::New(data->errorString).ToLocalChecked()); + argv[1] = Nan::Undefined(); } else { - argv[0] = NanUndefined(); - argv[1] = NanNew(data->result); + argv[0] = Nan::Undefined(); + argv[1] = Nan::New(data->result); } data->callback->Call(2, argv); @@ -539,59 +533,58 @@ void EIO_AfterFlush(uv_work_t* req) { } NAN_METHOD(Set) { - NanScope(); // file descriptor - if(!args[0]->IsInt32()) { - NanThrowTypeError("First argument must be an int"); - NanReturnUndefined(); + if(!info[0]->IsInt32()) { + Nan::ThrowTypeError("First argument must be an int"); + return; } - int fd = args[0]->ToInt32()->Int32Value(); + int fd = info[0]->ToInt32()->Int32Value(); // options - if(!args[1]->IsObject()) { - NanThrowTypeError("Second argument must be an object"); - NanReturnUndefined(); + if(!info[1]->IsObject()) { + Nan::ThrowTypeError("Second argument must be an object"); + return; } - v8::Local options = args[1]->ToObject(); + v8::Local options = info[1]->ToObject(); // callback - if(!args[2]->IsFunction()) { - NanThrowTypeError("Third argument must be a function"); - NanReturnUndefined(); + if(!info[2]->IsFunction()) { + Nan::ThrowTypeError("Third argument must be a function"); + return; } - v8::Local callback = args[2].As(); + v8::Local callback = info[2].As(); SetBaton* baton = new SetBaton(); memset(baton, 0, sizeof(SetBaton)); baton->fd = fd; - baton->callback = new NanCallback(callback); - baton->brk = options->Get(NanNew("brk"))->ToBoolean()->BooleanValue(); - baton->rts = options->Get(NanNew("rts"))->ToBoolean()->BooleanValue(); - baton->cts = options->Get(NanNew("cts"))->ToBoolean()->BooleanValue(); - baton->dtr = options->Get(NanNew("dtr"))->ToBoolean()->BooleanValue(); - baton->dsr = options->Get(NanNew("dsr"))->ToBoolean()->BooleanValue(); + baton->callback = new Nan::Callback(callback); + baton->brk = Nan::Get(options, Nan::New("brk").ToLocalChecked()).ToLocalChecked()->ToBoolean()->BooleanValue(); + baton->rts = Nan::Get(options, Nan::New("rts").ToLocalChecked()).ToLocalChecked()->ToBoolean()->BooleanValue(); + baton->cts = Nan::Get(options, Nan::New("cts").ToLocalChecked()).ToLocalChecked()->ToBoolean()->BooleanValue(); + baton->dtr = Nan::Get(options, Nan::New("dtr").ToLocalChecked()).ToLocalChecked()->ToBoolean()->BooleanValue(); + baton->dsr = Nan::Get(options, Nan::New("dsr").ToLocalChecked()).ToLocalChecked()->ToBoolean()->BooleanValue(); uv_work_t* req = new uv_work_t(); req->data = baton; uv_queue_work(uv_default_loop(), req, EIO_Set, (uv_after_work_cb)EIO_AfterSet); - NanReturnUndefined(); + return; } void EIO_AfterSet(uv_work_t* req) { - NanScope(); + Nan::HandleScope scope; SetBaton* data = static_cast(req->data); - v8::Handle argv[2]; + v8::Local argv[2]; if(data->errorString[0]) { - argv[0] = v8::Exception::Error(NanNew(data->errorString)); - argv[1] = NanUndefined(); + argv[0] = v8::Exception::Error(Nan::New(data->errorString).ToLocalChecked()); + argv[1] = Nan::Undefined(); } else { - argv[0] = NanUndefined(); - argv[1] = NanNew(data->result); + argv[0] = Nan::Undefined(); + argv[1] = Nan::New(data->result); } data->callback->Call(2, argv); @@ -601,47 +594,46 @@ void EIO_AfterSet(uv_work_t* req) { } NAN_METHOD(Drain) { - NanScope(); // file descriptor - if(!args[0]->IsInt32()) { - NanThrowTypeError("First argument must be an int"); - NanReturnUndefined(); + if(!info[0]->IsInt32()) { + Nan::ThrowTypeError("First argument must be an int"); + return; } - int fd = args[0]->ToInt32()->Int32Value(); + int fd = info[0]->ToInt32()->Int32Value(); // callback - if(!args[1]->IsFunction()) { - NanThrowTypeError("Second argument must be a function"); - NanReturnUndefined(); + if(!info[1]->IsFunction()) { + Nan::ThrowTypeError("Second argument must be a function"); + return; } - v8::Local callback = args[1].As(); + v8::Local callback = info[1].As(); DrainBaton* baton = new DrainBaton(); memset(baton, 0, sizeof(DrainBaton)); baton->fd = fd; - baton->callback = new NanCallback(callback); + baton->callback = new Nan::Callback(callback); uv_work_t* req = new uv_work_t(); req->data = baton; uv_queue_work(uv_default_loop(), req, EIO_Drain, (uv_after_work_cb)EIO_AfterDrain); - NanReturnUndefined(); + return; } void EIO_AfterDrain(uv_work_t* req) { - NanScope(); + Nan::HandleScope scope; DrainBaton* data = static_cast(req->data); - v8::Handle argv[2]; + v8::Local argv[2]; if(data->errorString[0]) { - argv[0] = v8::Exception::Error(NanNew(data->errorString)); - argv[1] = NanUndefined(); + argv[0] = v8::Exception::Error(Nan::New(data->errorString).ToLocalChecked()); + argv[1] = Nan::Undefined(); } else { - argv[0] = NanUndefined(); - argv[1] = NanNew(data->result); + argv[0] = Nan::Undefined(); + argv[1] = Nan::New(data->result); } data->callback->Call(2, argv); @@ -651,9 +643,9 @@ void EIO_AfterDrain(uv_work_t* req) { } // Change request for ticket #401 - credit to @sguilly -SerialPortParity NAN_INLINE(ToParityEnum(const v8::Handle& v8str)) { - NanScope(); - NanUtf8String *str = new NanUtf8String(v8str); +SerialPortParity NAN_INLINE(ToParityEnum(const v8::Local& v8str)) { + Nan::HandleScope scope; + Nan::Utf8String *str = new Nan::Utf8String(v8str); size_t count = strlen(**str); SerialPortParity parity = SERIALPORT_PARITY_NONE; if(!strncasecmp(**str, "none", count)) { @@ -685,15 +677,15 @@ SerialPortStopBits NAN_INLINE(ToStopBitEnum(double stopBits)) { extern "C" { void init (v8::Handle target) { - NanScope(); - NODE_SET_METHOD(target, "set", Set); - NODE_SET_METHOD(target, "open", Open); - NODE_SET_METHOD(target, "update", Update); - NODE_SET_METHOD(target, "write", Write); - NODE_SET_METHOD(target, "close", Close); - NODE_SET_METHOD(target, "list", List); - NODE_SET_METHOD(target, "flush", Flush); - NODE_SET_METHOD(target, "drain", Drain); + Nan::HandleScope scope; + Nan::SetMethod(target, "set", Set); + Nan::SetMethod(target, "open", Open); + Nan::SetMethod(target, "update", Update); + Nan::SetMethod(target, "write", Write); + Nan::SetMethod(target, "close", Close); + Nan::SetMethod(target, "list", List); + Nan::SetMethod(target, "flush", Flush); + Nan::SetMethod(target, "drain", Drain); #ifndef WIN32 SerialportPoller::Init(target); diff --git a/src/serialport.h b/src/serialport.h index 85ffe3b..86fce76 100644 --- a/src/serialport.h +++ b/src/serialport.h @@ -32,7 +32,7 @@ void EIO_AfterList(uv_work_t* req); NAN_METHOD(Open); void EIO_Open(uv_work_t* req); void EIO_AfterOpen(uv_work_t* req); -void AfterOpenSuccess(int fd, NanCallback* dataCallback, NanCallback* disconnectedCallback, NanCallback* errorCallback); +void AfterOpenSuccess(int fd, Nan::Callback* dataCallback, Nan::Callback* disconnectedCallback, Nan::Callback* errorCallback); NAN_METHOD(Update); void EIO_Update(uv_work_t* req); @@ -58,7 +58,7 @@ NAN_METHOD(Drain); void EIO_Drain(uv_work_t* req); void EIO_AfterDrain(uv_work_t* req); -SerialPortParity ToParityEnum(const v8::Handle& str); +SerialPortParity ToParityEnum(const v8::Local& str); SerialPortStopBits ToStopBitEnum(double stopBits); struct OpenBatonPlatformOptions @@ -69,10 +69,10 @@ OpenBatonPlatformOptions* ParsePlatformOptions(const v8::Local& opti struct OpenBaton { public: char path[1024]; - NanCallback* callback; - NanCallback* dataCallback; - NanCallback* disconnectedCallback; - NanCallback* errorCallback; + Nan::Callback* callback; + Nan::Callback* dataCallback; + Nan::Callback* disconnectedCallback; + Nan::Callback* errorCallback; int fd; int result; int baudRate; @@ -96,8 +96,8 @@ public: char* bufferData; size_t bufferLength; size_t offset; - v8::Persistent buffer; - NanCallback* callback; + Nan::Persistent buffer; + Nan::Callback* callback; int result; char errorString[ERROR_STRING_SIZE]; }; @@ -144,7 +144,7 @@ public: struct CloseBaton { public: int fd; - NanCallback* callback; + Nan::Callback* callback; char errorString[ERROR_STRING_SIZE]; }; @@ -161,7 +161,7 @@ public: struct ListBaton { public: - NanCallback* callback; + Nan::Callback* callback; std::list results; char errorString[ERROR_STRING_SIZE]; }; @@ -169,7 +169,7 @@ public: struct FlushBaton { public: int fd; - NanCallback* callback; + Nan::Callback* callback; int result; char errorString[ERROR_STRING_SIZE]; }; @@ -177,7 +177,7 @@ public: struct SetBaton { public: int fd; - NanCallback* callback; + Nan::Callback* callback; int result; char errorString[ERROR_STRING_SIZE]; bool rts; @@ -191,7 +191,7 @@ public: struct DrainBaton { public: int fd; - NanCallback* callback; + Nan::Callback* callback; int result; char errorString[ERROR_STRING_SIZE]; }; diff --git a/src/serialport_poller.cpp b/src/serialport_poller.cpp index 51c9316..ef10b36 100644 --- a/src/serialport_poller.cpp +++ b/src/serialport_poller.cpp @@ -7,9 +7,9 @@ using namespace v8; -static v8::Persistent serialportpoller_constructor; +static Nan::Persistent serialportpoller_constructor; -SerialportPoller::SerialportPoller() : ObjectWrap() {}; +SerialportPoller::SerialportPoller() : Nan::ObjectWrap() {}; SerialportPoller::~SerialportPoller() { // printf("~SerialportPoller\n"); delete callback_; @@ -23,12 +23,12 @@ void _serialportReadable(uv_poll_t *req, int status, int events) { } void SerialportPoller::callCallback(int status) { - NanScope(); + Nan::HandleScope scope; // uv_work_t* req = new uv_work_t; // Call the callback to go read more data... - v8::Handle argv[1]; + v8::Local argv[1]; if(status != 0) { // error handling changed in libuv, see: // https://github.com/joyent/libuv/commit/3ee4d3f183331 @@ -39,9 +39,9 @@ void SerialportPoller::callCallback(int status) { const char* err_string = uv_strerror(errno); #endif snprintf(this->errorString, sizeof(this->errorString), "Error %s on polling", err_string); - argv[0] = v8::Exception::Error(NanNew(this->errorString)); + argv[0] = v8::Exception::Error(Nan::New(this->errorString).ToLocalChecked()); } else { - argv[0] = NanUndefined(); + argv[0] = Nan::Undefined(); } callback_->Call(1, argv); @@ -50,55 +50,54 @@ void SerialportPoller::callCallback(int status) { void SerialportPoller::Init(Handle target) { - NanScope(); + Nan::HandleScope scope; // Prepare constructor template - Local tpl = NanNew(New); - tpl->SetClassName(NanNew("SerialportPoller")); + Local tpl = Nan::New(New); + tpl->SetClassName(Nan::New("SerialportPoller").ToLocalChecked()); tpl->InstanceTemplate()->SetInternalFieldCount(1); // Prototype // SerialportPoller.close() - tpl->PrototypeTemplate()->Set(NanNew("close"), - NanNew(Close)->GetFunction()); + Nan::SetPrototypeTemplate(tpl, "close", + Nan::GetFunction(Nan::New(Close)).ToLocalChecked()); // SerialportPoller.start() - tpl->PrototypeTemplate()->Set(NanNew("start"), - NanNew(Start)->GetFunction()); + Nan::SetPrototypeTemplate(tpl, "start", + Nan::GetFunction(Nan::New(Start)).ToLocalChecked()); - NanAssignPersistent(serialportpoller_constructor, tpl); + serialportpoller_constructor.Reset(tpl); - target->Set(NanNew("SerialportPoller"), tpl->GetFunction()); + Nan::Set(target, Nan::New("SerialportPoller").ToLocalChecked(), Nan::GetFunction(tpl).ToLocalChecked()); } NAN_METHOD(SerialportPoller::New) { - NanScope(); - if(!args[0]->IsInt32()) { - NanThrowTypeError("First argument must be an fd"); - NanReturnUndefined(); + if(!info[0]->IsInt32()) { + Nan::ThrowTypeError("First argument must be an fd"); + return; } - if(!args[1]->IsFunction()) { - NanThrowTypeError("Third argument must be a function"); - NanReturnUndefined(); + if(!info[1]->IsFunction()) { + Nan::ThrowTypeError("Third argument must be a function"); + return; } SerialportPoller* obj = new SerialportPoller(); - obj->fd_ = args[0]->ToInt32()->Int32Value(); - obj->callback_ = new NanCallback(args[1].As()); + obj->fd_ = info[0]->ToInt32()->Int32Value(); + obj->callback_ = new Nan::Callback(info[1].As()); // obj->callCallback(); - obj->Wrap(args.This()); + obj->Wrap(info.This()); obj->poll_handle_.data = obj; /*int r = */uv_poll_init(uv_default_loop(), &obj->poll_handle_, obj->fd_); uv_poll_start(&obj->poll_handle_, UV_READABLE, _serialportReadable); - NanReturnValue(args.This()); + info.GetReturnValue().Set(info.This()); } void SerialportPoller::_start() { @@ -111,20 +110,18 @@ void SerialportPoller::_stop() { NAN_METHOD(SerialportPoller::Start) { - NanScope(); - SerialportPoller* obj = ObjectWrap::Unwrap(args.This()); + SerialportPoller* obj = Nan::ObjectWrap::Unwrap(info.This()); obj->_start(); - NanReturnUndefined(); + return; } NAN_METHOD(SerialportPoller::Close) { - NanScope(); - SerialportPoller* obj = ObjectWrap::Unwrap(args.This()); + SerialportPoller* obj = Nan::ObjectWrap::Unwrap(info.This()); obj->_stop(); // DO SOMETHING! - NanReturnUndefined(); + return; } diff --git a/src/serialport_poller.h b/src/serialport_poller.h index 664afd4..2095cf2 100644 --- a/src/serialport_poller.h +++ b/src/serialport_poller.h @@ -8,7 +8,7 @@ #include #include "serialport.h" -class SerialportPoller : public node::ObjectWrap { +class SerialportPoller : public Nan::ObjectWrap { public: static void Init(v8::Handle target); @@ -29,7 +29,7 @@ class SerialportPoller : public node::ObjectWrap { int fd_; char errorString[ERROR_STRING_SIZE]; - NanCallback* callback_; + Nan::Callback* callback_; }; #endif \ No newline at end of file diff --git a/src/serialport_unix.cpp b/src/serialport_unix.cpp index b80c57b..22e157f 100644 --- a/src/serialport_unix.cpp +++ b/src/serialport_unix.cpp @@ -40,11 +40,11 @@ public: }; OpenBatonPlatformOptions* ParsePlatformOptions(const v8::Local& options) { - NanScope(); + Nan::HandleScope scope; UnixPlatformOptions* result = new UnixPlatformOptions(); - result->vmin = options->Get(NanNew("vmin"))->ToInt32()->Int32Value(); - result->vtime = options->Get(NanNew("vtime"))->ToInt32()->Int32Value(); + result->vmin = Nan::Get(options, Nan::New("vmin").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value(); + result->vtime = Nan::Get(options, Nan::New("vtime").ToLocalChecked()).ToLocalChecked()->ToInt32()->Int32Value(); return result; } @@ -53,7 +53,7 @@ int ToBaudConstant(int baudRate); int ToDataBitsConstant(int dataBits); int ToStopBitsConstant(SerialPortStopBits stopBits); -void AfterOpenSuccess(int fd, NanCallback* dataCallback, NanCallback* disconnectedCallback, NanCallback* errorCallback) { +void AfterOpenSuccess(int fd, Nan::Callback* dataCallback, Nan::Callback* disconnectedCallback, Nan::Callback* errorCallback) { delete dataCallback; delete errorCallback; delete disconnectedCallback; diff --git a/src/serialport_win.cpp b/src/serialport_win.cpp index 1f38a10..0d65af1 100644 --- a/src/serialport_win.cpp +++ b/src/serialport_win.cpp @@ -160,9 +160,9 @@ public: char errorString[ERROR_STRING_SIZE]; DWORD errorCode; bool disconnected; - NanCallback* dataCallback; - NanCallback* errorCallback; - NanCallback* disconnectedCallback; + Nan::Callback* dataCallback; + Nan::Callback* errorCallback; + Nan::Callback* disconnectedCallback; }; void EIO_Update(uv_work_t* req) { @@ -291,7 +291,7 @@ void DisposeWatchPortCallbacks(WatchPortBaton* data) { } void EIO_AfterWatchPort(uv_work_t* req) { - NanScope(); + Nan::HandleScope scope; WatchPortBaton* data = static_cast(req->data); if(data->disconnected) { @@ -301,16 +301,16 @@ void EIO_AfterWatchPort(uv_work_t* req) { } if(data->bytesRead > 0) { - v8::Handle argv[1]; - argv[0] = NanNewBufferHandle(data->buffer, data->bytesRead); + v8::Local argv[1]; + argv[0] = Nan::NewBuffer(data->buffer, data->bytesRead).ToLocalChecked(); data->dataCallback->Call(1, argv); } else if(data->errorCode > 0) { if(data->errorCode == ERROR_INVALID_HANDLE && IsClosingHandle((int)data->fd)) { DisposeWatchPortCallbacks(data); goto cleanup; } else { - v8::Handle argv[1]; - argv[0] = NanError(data->errorString); + v8::Local argv[1]; + argv[0] = Nan::Error(data->errorString); data->errorCallback->Call(1, argv); Sleep(100); // prevent the errors from occurring too fast } @@ -322,7 +322,7 @@ cleanup: delete req; } -void AfterOpenSuccess(int fd, NanCallback* dataCallback, NanCallback* disconnectedCallback, NanCallback* errorCallback) { +void AfterOpenSuccess(int fd, Nan::Callback* dataCallback, Nan::Callback* disconnectedCallback, Nan::Callback* errorCallback) { WatchPortBaton* baton = new WatchPortBaton(); memset(baton, 0, sizeof(WatchPortBaton)); baton->fd = (HANDLE)fd; diff --git a/src/win/enumser.cpp b/src/win/enumser.cpp index cde5ef0..f0e0587 100644 --- a/src/win/enumser.cpp +++ b/src/win/enumser.cpp @@ -8,7 +8,7 @@ History: PJN / 23-02-1999 Code now uses QueryDosDevice if running on NT to deter the ports at all. It should operate a lot faster in addition. PJN / 12-12-1999 Fixed a problem in the Win9x code path when trying to detect deactivated IRDA-ports. When trying to open those, you will - get the error-code ERROR_GEN_FAILURE.  + get the error-code ERROR_GEN_FAILURE.� PJN / 17-05-2000 Code now uses GetDefaultCommConfig in all cases to detect the ports. PJN / 29-03-2001 1. Reverted code to use CreateFile or QueryDosDevice as it is @@ -963,7 +963,7 @@ BOOL CEnumerateSerial::UsingWMI(CSimpleArray& ports, CSimpleArray for (ULONG n=0; nGet(L"DeviceID", 0, &varProperty1, NULL, NULL); + HRESULT hrGet = Nan::Get(apObj[n], L"DeviceID", 0, &varProperty1, NULL, NULL); if (SUCCEEDED(hrGet) && (varProperty1.vt == VT_BSTR) && (wcslen(varProperty1.bstrVal) > 3)) { //If it looks like "COMX" then add it to the array which will be returned @@ -979,7 +979,7 @@ BOOL CEnumerateSerial::UsingWMI(CSimpleArray& ports, CSimpleArray //Also get the friendly name of the port ATL::CComVariant varProperty2; - if (SUCCEEDED(apObj[n]->Get(L"Name", 0, &varProperty2, NULL, NULL)) && (varProperty2.vt == VT_BSTR)) + if Nan::Get((SUCCEEDED(apObj[n], L"Name", 0, &varProperty2, NULL, NULL)) && (varProperty2.vt == VT_BSTR)) { #if defined CENUMERATESERIAL_USE_STL #if defined _UNICODE diff --git a/src/win/stdstring.h b/src/win/stdstring.h index 2dd0bd8..4ee36c5 100644 --- a/src/win/stdstring.h +++ b/src/win/stdstring.h @@ -63,7 +63,7 @@ // - Jim Cline // - Jeff Kohn // - Todd Heckel -// - Ullrich Pollähne +// - Ullrich Pollähne // - Joe Vitaterna // - Joe Woodbury // - Aaron (no last name) @@ -217,7 +217,7 @@ // 2000-APR-17 - Thanks to Joe Vitaterna for pointing out that ReverseFind // is supposed to be a const function. // -// 2000-MAR-07 - Thanks to Ullrich Pollähne for catching a range bug in one +// 2000-MAR-07 - Thanks to Ullrich Pollähne for catching a range bug in one // of the overloads of assign. // // 2000-FEB-01 - You can now use CStdString on the Mac with CodeWarrior! @@ -253,7 +253,7 @@ // - Added missing overloads of TrimLeft() and TrimRight(). // Thanks to Karim Ratib for pointing them out // -// 1999-JUL-21 - Made all calls to GetBuf() with no args check length first. +// 1999-JUL-21 - Made all calls to GetBuf() with no info check length first. // // 1999-JUL-10 - Improved MFC/ATL independence of conversion macros // - Added SS_NO_REFCOUNT macro to allow you to disable any @@ -2284,7 +2284,7 @@ public: // or the NULL terminator, whichever comes first. Since we // are about to call a less forgiving overload (in which // must be a valid length), we must adjust the length here to a safe - // value. Thanks to Ullrich Pollähne for catching this bug + // value. Thanks to Ullrich Pollähne for catching this bug nChars = SSMIN(nChars, str.length() - nStart); MYTYPE strTemp(str.c_str()+nStart, nChars); @@ -2305,7 +2305,7 @@ public: // or the NULL terminator, whichever comes first. Since we // are about to call a less forgiving overload (in which // must be a valid length), we must adjust the length here to a safe - // value. Thanks to Ullrich Pollähne for catching this bug + // value. Thanks to Ullrich Pollähne for catching this bug nChars = SSMIN(nChars, str.length() - nStart);