Skip to content

Commit c83c195

Browse files
committed
fix all deprecated v8 calls for node12 compatibility
1 parent ee80492 commit c83c195

File tree

10 files changed

+82
-67
lines changed

10 files changed

+82
-67
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Fix scene values type 'list' (Partially fix #266) #267
3434
add support for SmartOS #272
3535

3636
# 1.6.0
37+
Fix broken Node 12 builds (v8 7.4.xxx)
3738
Initial support for OpenZWave 1.6
3839
- implement exception macros
3940
- [deprecate several legacy OpenZWave calls](https://github.com/OpenZWave/open-zwave/wiki/OpenZWave-1.6-Release-Notes#deprecated-featuresmethods)

src/openzwave-config.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace OZW {
2929
{
3030
Nan::HandleScope scope;
3131
CheckMinArgs(3, "nodeid, param, value");
32-
uint8 nodeid = info[0]->Uint32Value();
32+
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
3333
uint8 param = Nan::To<Number>(info[1]).ToLocalChecked()->Value();
3434
int32 value = Nan::To<Number>(info[2]).ToLocalChecked()->Value();
3535
if (info.Length() < 4) {

src/openzwave-driver.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,18 +77,20 @@ namespace OZW {
7777
Local < Object > opts = Nan::To<Object>(info[0]).ToLocalChecked();
7878
Local < Array > props = Nan::GetOwnPropertyNames(opts).ToLocalChecked();
7979
for (unsigned int i = 0; i < props->Length(); ++i) {
80-
Local<Value> key = props->Get(i);
81-
::std::string keyname = *Nan::Utf8String(key);
82-
Local<Value> argval = Nan::Get(opts, key).ToLocalChecked();
83-
::std::string argvalstr = *Nan::Utf8String(argval);
80+
Nan::MaybeLocal<Value> keymaybe = Nan::Get(props, i);
81+
if(keymaybe.IsEmpty()) continue;
82+
Local<Value> key = keymaybe.ToLocalChecked();
83+
::std::string keyname = *Nan::Utf8String(key);
84+
Local<Value> argval = Nan::Get(opts, key).ToLocalChecked();
85+
::std::string argvalstr = *Nan::Utf8String(argval);
8486
// UserPath is directly passed to Manager->Connect()
8587
// scan for OpenZWave options.xml in the nodeJS module's '/config' subdirectory
8688
if (keyname == "UserPath") {
8789
ozw_userpath.assign(argvalstr);
8890
} else if (keyname == "ConfigPath") {
8991
ozw_config_path.assign(argvalstr);
9092
} else if (keyname == "LogInitialisation") {
91-
log_initialisation = argval->BooleanValue();
93+
log_initialisation = (Nan::To<bool>(argval) == Nan::Just(true));
9294
} else {
9395
option_overrides += " --" + keyname + " " + argvalstr;
9496
}

src/openzwave-groups.cc

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ namespace OZW {
3333
{
3434
Nan::HandleScope scope;
3535
CheckMinArgs(1, "nodeid");
36-
uint8 nodeid = info[0]->Uint32Value();
36+
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
3737
uint8 numGroups = 0;
3838
OZWManagerAssign(numGroups, GetNumGroups, homeid, nodeid);
3939
info.GetReturnValue().Set(Nan::New<Integer>(numGroups));
@@ -49,8 +49,8 @@ namespace OZW {
4949
Nan::HandleScope scope;
5050
CheckMinArgs(2, "nodeid, groupidx");
5151
uint8* associations;
52-
uint8 nodeid = info[0]->Uint32Value();
53-
uint8 groupidx = info[1]->Uint32Value();
52+
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
53+
uint8 groupidx = Nan::To<Number>(info[1]).ToLocalChecked()->Value();
5454

5555
uint32 numNodes = 0;
5656
OZWManagerAssign(numNodes, GetAssociations,
@@ -60,7 +60,7 @@ namespace OZW {
6060
Local<Array> o_assocs = Nan::New<Array>(numNodes);
6161

6262
for (uint8 nr = 0; nr < numNodes; nr++) {
63-
o_assocs->Set(Nan::New<Integer>(nr), Nan::New<Integer>(associations[nr]));
63+
Nan::Set(o_assocs, nr, Nan::New<Integer>(associations[nr]));
6464
}
6565
if (numNodes > 0) {
6666
// The caller is responsible for freeing the array memory with a call to delete [].
@@ -79,8 +79,8 @@ namespace OZW {
7979
{
8080
Nan::HandleScope scope;
8181
CheckMinArgs(2, "nodeid, groupidx");
82-
uint8 nodeid = info[0]->Uint32Value();
83-
uint8 groupidx = info[1]->Uint32Value();
82+
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
83+
uint8 groupidx = Nan::To<Number>(info[1]).ToLocalChecked()->Value();
8484

8585
uint8 numMaxAssoc = 0;
8686
OZWManagerAssign(numMaxAssoc, GetMaxAssociations,
@@ -99,8 +99,8 @@ namespace OZW {
9999
{
100100
Nan::HandleScope scope;
101101
CheckMinArgs(2, "nodeid, groupidx");
102-
uint8 nodeid = info[0]->Uint32Value();
103-
uint8 groupidx = info[1]->Uint32Value();
102+
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
103+
uint8 groupidx = Nan::To<Number>(info[1]).ToLocalChecked()->Value();
104104

105105
::std::string groupLabel("");
106106
OZWManagerAssign(groupLabel, GetGroupLabel,
@@ -122,12 +122,12 @@ namespace OZW {
122122
{
123123
Nan::HandleScope scope;
124124
CheckMinArgs(3, "nodeid, groupidx, tgtnodeid");
125-
uint8 nodeid = info[0]->Uint32Value();
126-
uint8 groupidx = info[1]->Uint32Value();
127-
uint8 tgtnodeid = info[2]->Uint32Value();
125+
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
126+
uint8 groupidx = Nan::To<Number>(info[1]).ToLocalChecked()->Value();
127+
uint8 tgtnodeid = Nan::To<Number>(info[2]).ToLocalChecked()->Value();
128128
uint8 instanceid = 0;
129129
if(info.Length() > 3) {
130-
instanceid = info[3]->Uint32Value();
130+
instanceid = Nan::To<Number>(info[3]).ToLocalChecked()->Value();
131131
}
132132

133133
OZWManager( AddAssociation,
@@ -144,12 +144,12 @@ namespace OZW {
144144
{
145145
Nan::HandleScope scope;
146146
CheckMinArgs(3, "nodeid, groupidx, tgtnodeid");
147-
uint8 nodeid = info[0]->Uint32Value();
148-
uint8 groupidx = info[1]->Uint32Value();
149-
uint8 tgtnodeid = info[2]->Uint32Value();
147+
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
148+
uint8 groupidx = Nan::To<Number>(info[1]).ToLocalChecked()->Value();
149+
uint8 tgtnodeid = Nan::To<Number>(info[2]).ToLocalChecked()->Value();
150150
uint8 instanceid = 0;
151151
if(info.Length() > 3) {
152-
instanceid = info[3]->Uint32Value();
152+
instanceid = Nan::To<Number>(info[3]).ToLocalChecked()->Value();
153153
}
154154

155155
OZWManager( RemoveAssociation,

src/openzwave-network.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ namespace OZW {
3131
{
3232
Nan::HandleScope scope;
3333
CheckMinArgs(1, "nodeid");
34-
uint8 nodeid = info[0]->Uint32Value();
35-
uint8 nummsg = (info.Length() > 1) ? info[1]->Uint32Value() : 1;
34+
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
35+
uint8 nummsg = (info.Length() > 1) ?
36+
Nan::To<Number>(info[1]).ToLocalChecked()->Value() : 1;
3637
OZWManager( TestNetworkNode, homeid, nodeid, nummsg);
3738
}
3839

@@ -45,7 +46,8 @@ namespace OZW {
4546
// ===================================================================
4647
{
4748
Nan::HandleScope scope;
48-
uint8 nummsg = (info.Length() > 0) ? info[0]->Uint32Value() : 1;
49+
uint8 nummsg = (info.Length() > 0) ?
50+
Nan::To<Number>(info[0]).ToLocalChecked()->Value() : 1;
4951
OZWManager( TestNetwork, homeid, nummsg);
5052
}
5153

@@ -58,8 +60,9 @@ namespace OZW {
5860
{
5961
Nan::HandleScope scope;
6062
CheckMinArgs(1, "nodeid");
61-
uint8 nodeid = info[0]->Uint32Value();
62-
uint8 doRR = (info.Length() > 1) ? Nan::To<Boolean>(info[1]).ToLocalChecked()->Value() : false;
63+
uint8 nodeid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
64+
uint8 doRR = (info.Length() > 1) ?
65+
Nan::To<Boolean>(info[1]).ToLocalChecked()->Value() : false;
6366
OZWManager( HealNetworkNode, homeid, nodeid, doRR);
6467
}
6568

@@ -73,7 +76,8 @@ namespace OZW {
7376
// ===================================================================
7477
{
7578
Nan::HandleScope scope;
76-
bool doRR = (info.Length() > 0) ? Nan::To<Boolean>(info[0]).ToLocalChecked()->Value() : false;
79+
bool doRR = (info.Length() > 0) ?
80+
Nan::To<Boolean>(info[0]).ToLocalChecked()->Value() : false;
7781
OZWManager( HealNetwork, homeid, doRR);
7882
}
7983
}

0 commit comments

Comments
 (0)