Skip to content

Commit

Permalink
Use shorter nan syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
KimNyholm committed Sep 24, 2019
1 parent 2347f8f commit 52af4f8
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/functions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ class ReceiveMessageWorker : public AsyncWorker {
};

NAN_METHOD(GetMessageQueue) {
key_t key = (key_t) info[0]->Int32Value(Nan::GetCurrentContext()).FromJust();
int flags = info[1]->Int32Value(Nan::GetCurrentContext()).FromJust();
key_t key = (key_t) Nan::To<int32_t>(info[0]).FromJust();
int flags = Nan::To<int32_t>(info[1]).FromJust();

int queue = msgget(key, flags);

Expand All @@ -133,8 +133,8 @@ NAN_METHOD(GetMessageQueue) {
}

NAN_METHOD(ControlMessageQueue) {
int id = info[0]->Int32Value(Nan::GetCurrentContext()).FromJust();
int cmd = info[1]->Int32Value(Nan::GetCurrentContext()).FromJust();
int id = Nan::To<int32_t>(info[0]).FromJust();
int cmd = Nan::To<int32_t>(info[1]).FromJust();

msqid_ds *buf;

Expand Down Expand Up @@ -164,7 +164,7 @@ NAN_METHOD(ControlMessageQueue) {
}

NAN_METHOD(CloseMessageQueue) {
int id = info[0]->Int32Value(Nan::GetCurrentContext()).FromJust();
int id = Nan::To<int32_t>(info[0]).FromJust();

int ret = msgctl(id, IPC_RMID, nullptr);

Expand All @@ -176,21 +176,21 @@ NAN_METHOD(CloseMessageQueue) {
}

NAN_METHOD(SendMessage) {
int id = info[0]->Int32Value(Nan::GetCurrentContext()).FromJust();
int id = Nan::To<int32_t>(info[0]).FromJust();
char* bufferData = node::Buffer::Data(info[1]);
size_t bufferLength = (size_t) node::Buffer::Length(info[1]);
long type = (long) info[2]->Int32Value(Nan::GetCurrentContext()).FromJust();
int flags = info[3]->Int32Value(Nan::GetCurrentContext()).FromJust();
long type = (long) Nan::To<int32_t>(info[2]).FromJust();
int flags = Nan::To<int32_t>(info[3]).FromJust();
Callback *callback = new Callback(info[4].As<Function>());

AsyncQueueWorker(new SendMessageWorker(callback, id, bufferData, bufferLength, type, flags));
}

NAN_METHOD(ReceiveMessage) {
int id = info[0]->Int32Value(Nan::GetCurrentContext()).FromJust();
size_t bufferLength = (size_t) info[1]->Int32Value(Nan::GetCurrentContext()).FromJust();
long type = (long) info[2]->Int32Value(Nan::GetCurrentContext()).FromJust();
int flags = info[3]->Int32Value(Nan::GetCurrentContext()).FromJust();
int id = Nan::To<int32_t>(info[0]).FromJust();
size_t bufferLength = (size_t) Nan::To<int32_t>(info[1]).FromJust();
long type = (long) Nan::To<int32_t>(info[2]).FromJust();
int flags = Nan::To<int32_t>(info[3]).FromJust();
Callback *callback = new Callback(info[4].As<Function>());

AsyncQueueWorker(new ReceiveMessageWorker(callback, id, bufferLength, type, flags));
Expand Down

0 comments on commit 52af4f8

Please sign in to comment.