Skip to content

Commit

Permalink
adapt to V8 7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fivdi committed Sep 29, 2018
1 parent 95e91f2 commit 92af5c2
Show file tree
Hide file tree
Showing 16 changed files with 75 additions and 67 deletions.
8 changes: 8 additions & 0 deletions History.md
@@ -1,3 +1,11 @@
Unpublished
===========

* update dependencies (nan v2.11.1, async v2.6.1, lodash v4.17.11)
* adapt to V8 7.0: replace v8Value->Int32Value() with Nan::To<int32_t>(v8Value).FromJust()
* adapt to V8 7.0: replace v8Value->Uint32Value() with Nan::To<uint32_t>(v8Value).FromJust()
* adapt to V8 7.0: replace v8Value->BooleanValue() with Nan::To<bool>(v8Value).FromJust()

4.0.1 / Jul 28 2018
===================

Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -20,11 +20,11 @@
},
"dependencies": {
"bindings": "^1.3.0",
"nan": "^2.10.0"
"nan": "^2.11.1"
},
"devDependencies": {
"async": "^2.6.0",
"lodash": "^4.17.5"
"async": "^2.6.1",
"lodash": "^4.17.11"
},
"keywords": [
"i2c",
Expand Down
8 changes: 4 additions & 4 deletions src/deviceid.cc
Expand Up @@ -46,8 +46,8 @@ NAN_METHOD(DeviceIdAsync) {
"incorrect arguments passed to deviceId(int fd, int address, function cb)"));
}

int fd = info[0]->Int32Value();
__u16 address = info[1]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u16 address = Nan::To<int32_t>(info[1]).FromJust();
Nan::Callback *callback = new Nan::Callback(info[2].As<v8::Function>());

Nan::AsyncQueueWorker(new DeviceIdWorker(callback, fd, address));
Expand All @@ -59,8 +59,8 @@ NAN_METHOD(DeviceIdSync) {
"incorrect arguments passed to deviceIdSync(int fd, int address)"));
}

int fd = info[0]->Int32Value();
__u16 address = info[1]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u16 address = Nan::To<int32_t>(info[1]).FromJust();

__s32 ret = DeviceId(fd, address);
if (ret == -1) {
Expand Down
4 changes: 2 additions & 2 deletions src/i2cfuncs.cc
Expand Up @@ -45,7 +45,7 @@ NAN_METHOD(I2cFuncsAsync) {
"incorrect arguments passed to i2cFuncs(int fd, function cb)"));
}

int fd = info[0]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
Nan::Callback *callback = new Nan::Callback(info[1].As<v8::Function>());

Nan::AsyncQueueWorker(new I2cFuncsWorker(callback, fd));
Expand All @@ -57,7 +57,7 @@ NAN_METHOD(I2cFuncsSync) {
"incorrect arguments passed to i2cFuncsSync(int fd)"));
}

int fd = info[0]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();

unsigned long i2cfuncs;
__s32 ret = I2cFuncs(fd, &i2cfuncs);
Expand Down
8 changes: 4 additions & 4 deletions src/readblock.cc
Expand Up @@ -63,8 +63,8 @@ NAN_METHOD(ReadBlockAsync) {
"(int fd, int cmd, Buffer buffer, function cb)"));
}

int fd = info[0]->Int32Value();
__u8 cmd = info[1]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
v8::Local<v8::Object> bufferHandle = info[2].As<v8::Object>();
Nan::Callback *callback = new Nan::Callback(info[3].As<v8::Function>());

Expand Down Expand Up @@ -95,8 +95,8 @@ NAN_METHOD(ReadBlockSync) {
"(int fd, int cmd, Buffer buffer)"));
}

int fd = info[0]->Int32Value();
__u8 cmd = info[1]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
v8::Local<v8::Object> bufferHandle = info[2].As<v8::Object>();

__u8* bufferData = (__u8*) node::Buffer::Data(bufferHandle);
Expand Down
8 changes: 4 additions & 4 deletions src/readbyte.cc
Expand Up @@ -46,8 +46,8 @@ NAN_METHOD(ReadByteAsync) {
"incorrect arguments passed to readByte(int fd, int cmd, function cb)"));
}

int fd = info[0]->Int32Value();
__u8 cmd = info[1]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
Nan::Callback *callback = new Nan::Callback(info[2].As<v8::Function>());

Nan::AsyncQueueWorker(new ReadByteWorker(callback, fd, cmd));
Expand All @@ -59,8 +59,8 @@ NAN_METHOD(ReadByteSync) {
"incorrect arguments passed to readByteSync(int fd, int cmd)"));
}

int fd = info[0]->Int32Value();
__u8 cmd = info[1]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();

__s32 byte = ReadByte(fd, cmd);
if (byte == -1) {
Expand Down
12 changes: 6 additions & 6 deletions src/readi2cblock.cc
Expand Up @@ -66,9 +66,9 @@ NAN_METHOD(ReadI2cBlockAsync) {
"(int fd, int cmd, int length, Buffer buffer, function cb)"));
}

int fd = info[0]->Int32Value();
__u8 cmd = info[1]->Int32Value();
__u32 length = info[2]->Uint32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
__u32 length = Nan::To<uint32_t>(info[2]).FromJust();
v8::Local<v8::Object> bufferHandle = info[3].As<v8::Object>();
Nan::Callback *callback = new Nan::Callback(info[4].As<v8::Function>());

Expand Down Expand Up @@ -106,9 +106,9 @@ NAN_METHOD(ReadI2cBlockSync) {
"(int fd, int cmd, int length, Buffer buffer)"));
}

int fd = info[0]->Int32Value();
__u8 cmd = info[1]->Int32Value();
__u32 length = info[2]->Uint32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
__u32 length = Nan::To<uint32_t>(info[2]).FromJust();
v8::Local<v8::Object> bufferHandle = info[3].As<v8::Object>();

__u8* bufferData = (__u8*) node::Buffer::Data(bufferHandle);
Expand Down
8 changes: 4 additions & 4 deletions src/readword.cc
Expand Up @@ -46,8 +46,8 @@ NAN_METHOD(ReadWordAsync) {
"incorrect arguments passed to readWord(int fd, int cmd, function cb)"));
}

int fd = info[0]->Int32Value();
__u8 cmd = info[1]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
Nan::Callback *callback = new Nan::Callback(info[2].As<v8::Function>());

Nan::AsyncQueueWorker(new ReadWordWorker(callback, fd, cmd));
Expand All @@ -59,8 +59,8 @@ NAN_METHOD(ReadWordSync) {
"incorrect arguments passed to readWordSync(int fd, int cmd)"));
}

int fd = info[0]->Int32Value();
__u8 cmd = info[1]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();

__s32 word = ReadWord(fd, cmd);
if (word == -1) {
Expand Down
4 changes: 2 additions & 2 deletions src/receivebyte.cc
Expand Up @@ -45,7 +45,7 @@ NAN_METHOD(ReceiveByteAsync) {
"incorrect arguments passed to receiveByte(int fd, function cb)"));
}

int fd = info[0]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
Nan::Callback *callback = new Nan::Callback(info[1].As<v8::Function>());

Nan::AsyncQueueWorker(new ReceiveByteWorker(callback, fd));
Expand All @@ -57,7 +57,7 @@ NAN_METHOD(ReceiveByteSync) {
"incorrect arguments passed to receiveByteSync(int fd)"));
}

int fd = info[0]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();

__s32 byte = ReceiveByte(fd);
if (byte == -1) {
Expand Down
8 changes: 4 additions & 4 deletions src/sendbyte.cc
Expand Up @@ -44,8 +44,8 @@ NAN_METHOD(SendByteAsync) {
"incorrect arguments passed to sendByte(int fd, int byte, function cb)"));
}

int fd = info[0]->Int32Value();
__u8 byte = info[1]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 byte = Nan::To<int32_t>(info[1]).FromJust();
Nan::Callback *callback = new Nan::Callback(info[2].As<v8::Function>());

Nan::AsyncQueueWorker(new SendByteWorker(callback, fd, byte));
Expand All @@ -57,8 +57,8 @@ NAN_METHOD(SendByteSync) {
"incorrect arguments passed to sendByteSync(int fd, int byte)"));
}

int fd = info[0]->Int32Value();
__u8 byte = info[1]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 byte = Nan::To<int32_t>(info[1]).FromJust();

__s32 ret = SendByte(fd, byte);
if (ret == -1) {
Expand Down
12 changes: 6 additions & 6 deletions src/setaddr.cc
Expand Up @@ -44,9 +44,9 @@ NAN_METHOD(SetAddrAsync) {
"incorrect arguments passed to setAddr(int fd, int addr, bool forceAccess, function cb)"));
}

int fd = info[0]->Int32Value();
int addr = info[1]->Int32Value();
bool forceAccess = info[2]->BooleanValue();
int fd = Nan::To<int32_t>(info[0]).FromJust();
int addr = Nan::To<int32_t>(info[1]).FromJust();
bool forceAccess = Nan::To<bool>(info[2]).FromJust();
Nan::Callback *callback = new Nan::Callback(info[3].As<v8::Function>());

Nan::AsyncQueueWorker(new SetAddrWorker(callback, fd, addr, forceAccess));
Expand All @@ -58,9 +58,9 @@ NAN_METHOD(SetAddrSync) {
"incorrect arguments passed to setAddrSync(int fd, int addr, bool forceAccess)"));
}

int fd = info[0]->Int32Value();
int addr = info[1]->Int32Value();
bool forceAccess = info[2]->BooleanValue();
int fd = Nan::To<int32_t>(info[0]).FromJust();
int addr = Nan::To<int32_t>(info[1]).FromJust();
bool forceAccess = Nan::To<bool>(info[2]).FromJust();

if (SetAddr(fd, addr, forceAccess) != 0) {
return Nan::ThrowError(Nan::ErrnoException(errno, "setAddrSync", ""));
Expand Down
12 changes: 6 additions & 6 deletions src/writeblock.cc
Expand Up @@ -67,9 +67,9 @@ NAN_METHOD(WriteBlockAsync) {
"(int fd, int cmd, int length, Buffer buffer, function cb)"));
}

int fd = info[0]->Int32Value();
__u8 cmd = info[1]->Int32Value();
__u32 length = info[2]->Uint32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
__u32 length = Nan::To<uint32_t>(info[2]).FromJust();
v8::Local<v8::Object> bufferHandle = info[3].As<v8::Object>();
Nan::Callback *callback = new Nan::Callback(info[4].As<v8::Function>());

Expand Down Expand Up @@ -107,9 +107,9 @@ NAN_METHOD(WriteBlockSync) {
"(int fd, int cmd, int length, Buffer buffer)"));
}

int fd = info[0]->Int32Value();
__u8 cmd = info[1]->Int32Value();
__u32 length = info[2]->Uint32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
__u32 length = Nan::To<uint32_t>(info[2]).FromJust();
v8::Local<v8::Object> bufferHandle = info[3].As<v8::Object>();

const __u8* bufferData = (const __u8*) node::Buffer::Data(bufferHandle);
Expand Down
12 changes: 6 additions & 6 deletions src/writebyte.cc
Expand Up @@ -46,9 +46,9 @@ NAN_METHOD(WriteByteAsync) {
"(int fd, int cmd, int byte, function cb)"));
}

int fd = info[0]->Int32Value();
__u8 cmd = info[1]->Int32Value();
__u8 byte = info[2]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
__u8 byte = Nan::To<int32_t>(info[2]).FromJust();
Nan::Callback *callback = new Nan::Callback(info[3].As<v8::Function>());

Nan::AsyncQueueWorker(new WriteByteWorker(callback, fd, cmd, byte));
Expand All @@ -60,9 +60,9 @@ NAN_METHOD(WriteByteSync) {
"incorrect arguments passed to writeByteSync(int fd, int cmd, int byte)"));
}

int fd = info[0]->Int32Value();
__u8 cmd = info[1]->Int32Value();
__u8 byte = info[2]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
__u8 byte = Nan::To<int32_t>(info[2]).FromJust();

__s32 ret = WriteByte(fd, cmd, byte);
if (ret == -1) {
Expand Down
12 changes: 6 additions & 6 deletions src/writei2cblock.cc
Expand Up @@ -65,9 +65,9 @@ NAN_METHOD(WriteI2cBlockAsync) {
"(int fd, int cmd, int length, Buffer buffer, function cb)"));
}

int fd = info[0]->Int32Value();
__u8 cmd = info[1]->Int32Value();
__u32 length = info[2]->Uint32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
__u32 length = Nan::To<uint32_t>(info[2]).FromJust();
v8::Local<v8::Object> bufferHandle = info[3].As<v8::Object>();
Nan::Callback *callback = new Nan::Callback(info[4].As<v8::Function>());

Expand Down Expand Up @@ -105,9 +105,9 @@ NAN_METHOD(WriteI2cBlockSync) {
"(int fd, int cmd, int length, Buffer buffer)"));
}

int fd = info[0]->Int32Value();
__u8 cmd = info[1]->Int32Value();
__u32 length = info[2]->Uint32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
__u32 length = Nan::To<uint32_t>(info[2]).FromJust();
v8::Local<v8::Object> bufferHandle = info[3].As<v8::Object>();

const __u8* bufferData = (const __u8*) node::Buffer::Data(bufferHandle);
Expand Down
8 changes: 4 additions & 4 deletions src/writequick.cc
Expand Up @@ -44,8 +44,8 @@ NAN_METHOD(WriteQuickAsync) {
"incorrect arguments passed to writeQuick(int fd, int bit, function cb)"));
}

int fd = info[0]->Int32Value();
__u8 bit = info[1]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 bit = Nan::To<int32_t>(info[1]).FromJust();
Nan::Callback *callback = new Nan::Callback(info[2].As<v8::Function>());

Nan::AsyncQueueWorker(new WriteQuickWorker(callback, fd, bit));
Expand All @@ -57,8 +57,8 @@ NAN_METHOD(WriteQuickSync) {
"incorrect arguments passed to writeQuickSync(int fd, int bit)"));
}

int fd = info[0]->Int32Value();
__u8 bit = info[1]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 bit = Nan::To<int32_t>(info[1]).FromJust();

__s32 ret = WriteQuick(fd, bit);
if (ret == -1) {
Expand Down
12 changes: 6 additions & 6 deletions src/writeword.cc
Expand Up @@ -46,9 +46,9 @@ NAN_METHOD(WriteWordAsync) {
"(int fd, int cmd, int word, function cb)"));
}

int fd = info[0]->Int32Value();
__u8 cmd = info[1]->Int32Value();
__u16 word = info[2]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
__u16 word = Nan::To<int32_t>(info[2]).FromJust();
Nan::Callback *callback = new Nan::Callback(info[3].As<v8::Function>());

Nan::AsyncQueueWorker(new WriteWordWorker(callback, fd, cmd, word));
Expand All @@ -61,9 +61,9 @@ NAN_METHOD(WriteWordSync) {
"(int fd, int cmd, int word)"));
}

int fd = info[0]->Int32Value();
__u8 cmd = info[1]->Int32Value();
__u16 word = info[2]->Int32Value();
int fd = Nan::To<int32_t>(info[0]).FromJust();
__u8 cmd = Nan::To<int32_t>(info[1]).FromJust();
__u16 word = Nan::To<int32_t>(info[2]).FromJust();

__s32 ret = WriteWord(fd, cmd, word);
if (ret == -1) {
Expand Down

0 comments on commit 92af5c2

Please sign in to comment.