Skip to content

Commit de923b5

Browse files
committed
[fix] Openzwave 16 deprecated errors #355
1 parent 7eaa12a commit de923b5

File tree

9 files changed

+38
-34
lines changed

9 files changed

+38
-34
lines changed

README-deprecated-16.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ There are numerous changes in the upcoming 1.6 release. This document describes
44

55
## SetNodeOn/Off, SetLevel
66

7-
Just define `OPENZWAVE_DEPRECATED` preprocessor symbol to have these included in the build:
7+
Just define `OPENZWAVE16_DEPRECATED` preprocessor symbol to have these included in the build:
88

99
```js
1010
/*

src/openzwave-management.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ namespace OZW {
357357
OZWManager( CancelControllerCommand, homeid);
358358
}
359359

360-
#if OPENZWAVE_DEPRECATED16
360+
#ifdef OPENZWAVE16_DEPRECATED
361361
// =================================================================
362362
NAN_METHOD(OZW::WriteConfig)
363363
// =================================================================

src/openzwave-nodes.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace OZW {
4444
info.GetReturnValue().Set( o_neighbors );
4545
}
4646

47-
#ifdef OPENZWAVE_DEPRECATED16
47+
#ifdef OPENZWAVE16_DEPRECATED
4848
// =================================================================
4949
NAN_METHOD(OZW::SetNodeOn)
5050
// =================================================================

src/openzwave-scenes.cc

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ using namespace node;
2222

2323
namespace OZW {
2424

25-
#ifdef OPENZWAVE_DEPRECATED16
26-
OPENZWAVE_DEPRECATED_WARNINGS_OFF
25+
#ifdef OPENZWAVE16_DEPRECATED
26+
//OPENZWAVE_DEPRECATED_WARNINGS_OFF
2727
/* OpenZWave scene management functions */
2828
// ===================================================================
2929
NAN_METHOD(OZW::CreateScene)
@@ -34,7 +34,7 @@ OPENZWAVE_DEPRECATED_WARNINGS_OFF
3434
::std::string label(*Nan::Utf8String( info[0] ));
3535
SceneInfo *scene;
3636

37-
uint8 sceneid = OZWManager( CreateScene();
37+
uint8 sceneid = OZWManager(CreateScene);
3838

3939
if (sceneid > 0) {
4040
OZWManager( SetSceneLabel, sceneid, label);
@@ -45,7 +45,7 @@ OPENZWAVE_DEPRECATED_WARNINGS_OFF
4545
zscenes.push_back, scene);
4646
}
4747

48-
info.GetReturnValue().Set(Nan::New< Integer >, sceneid));
48+
info.GetReturnValue().Set(Nan::New<Integer>, sceneid);
4949
}
5050

5151
// ===================================================================
@@ -57,10 +57,10 @@ OPENZWAVE_DEPRECATED_WARNINGS_OFF
5757
uint8 sceneid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
5858
SceneInfo *scene;
5959

60-
if (scene = get_scene_info, sceneid))) {
61-
OZWManager( RemoveScene, sceneid);
60+
if ((scene = get_scene_info(sceneid))) {
61+
OZWManager(RemoveScene, sceneid);
6262
mutex::scoped_lock sl(zscenes_mutex);
63-
zscenes.remove, scene);
63+
zscenes.remove(scene);
6464
}
6565
}
6666

@@ -69,7 +69,7 @@ OPENZWAVE_DEPRECATED_WARNINGS_OFF
6969
// ===================================================================
7070
{
7171
Nan::HandleScope scope;
72-
uint8 numscenes = OZWManager( GetNumScenes();
72+
uint8 numscenes = OZWManager(GetNumScenes);
7373
SceneInfo *scene;
7474

7575
if (numscenes != zscenes.size()) {
@@ -80,14 +80,14 @@ OPENZWAVE_DEPRECATED_WARNINGS_OFF
8080
uint8 *sceneids;
8181
sceneids = new uint8[numscenes];
8282

83-
OZWManager( GetAllScenes(&sceneids);
83+
OZWManager(GetAllScenes, &sceneids);
8484

8585
for (unsigned i = 0; i < numscenes; i++) {
8686
scene = new SceneInfo();
8787
scene->sceneid = sceneids[i];
8888
scene->label = OZWManager( GetSceneLabel, sceneids[i]);
8989
mutex::scoped_lock sl(zscenes_mutex);
90-
zscenes.push_back, scene);
90+
zscenes.push_back(scene);
9191
}
9292
}
9393

@@ -101,17 +101,17 @@ OPENZWAVE_DEPRECATED_WARNINGS_OFF
101101
Local <Object> info = Nan::New<Object>();
102102
info->Set(
103103
Nan::New<String>("sceneid").ToLocalChecked(),
104-
Nan::New<Integer>, scene->sceneid)
104+
Nan::New<Integer>(scene->sceneid)
105105
);
106106
info->Set(
107107
Nan::New<String>("label").ToLocalChecked(),
108-
Nan::New<String>, scene->label.c_str()).ToLocalChecked()
108+
Nan::New<String>(scene->label.c_str()).ToLocalChecked()
109109
);
110110

111111
scenes->Set(Nan::New<Integer>(j++), info);
112112
}
113113

114-
info.GetReturnValue().Set, scenes);
114+
info.GetReturnValue().Set(scenes);
115115
}
116116

117117
// ===================================================================
@@ -188,7 +188,7 @@ OPENZWAVE_DEPRECATED_WARNINGS_OFF
188188
CheckMinArgs(2, "sceneid, value");
189189
uint8 sceneid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
190190
SceneInfo *scene;
191-
if (, scene = get_scene_info, sceneid))) {
191+
if ((scene = get_scene_info(sceneid))) {
192192
OpenZWave::ValueID* vit = populateValueId(info, 1);
193193
if (vit) {
194194
OZWManager( RemoveSceneValue, sceneid, *vit);
@@ -212,7 +212,7 @@ OPENZWAVE_DEPRECATED_WARNINGS_OFF
212212

213213
SceneInfo *scene;
214214

215-
if (, scene = get_scene_info, sceneid))) {
215+
if ((scene = get_scene_info(sceneid)))) {
216216
scene->values.clear();
217217

218218
Local<Array> v8values = Nan::New<Array>, scene->values.size());
@@ -236,10 +236,10 @@ OPENZWAVE_DEPRECATED_WARNINGS_OFF
236236
uint8 sceneid = Nan::To<Number>(info[0]).ToLocalChecked()->Value();
237237
SceneInfo *scene;
238238

239-
if (, scene = get_scene_info, sceneid))) {
239+
if ((scene = get_scene_info(sceneid))) {
240240
OZWManager( ActivateScene, sceneid);
241241
}
242242
}
243-
OPENZWAVE_DEPRECATED_WARNINGS_ON
243+
// OPENZWAVE_DEPRECATED_WARNINGS_ON
244244
#endif
245245
}

src/openzwave.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ namespace OZW {
108108
Nan::SetPrototypeMethod(t, "beginControllerCommand", OZW::BeginControllerCommand);
109109
#endif
110110
Nan::SetPrototypeMethod(t, "cancelControllerCommand", OZW::CancelControllerCommand);
111-
#ifdef OPENZWAVE_DEPRECATED16
111+
#ifdef OPENZWAVE16_DEPRECATED
112112
Nan::SetPrototypeMethod(t, "writeConfig", OZW::WriteConfig);
113113
#endif
114114
Nan::SetPrototypeMethod(t, "getDriverStatistics", OZW::GetDriverStatistics);
@@ -119,7 +119,7 @@ namespace OZW {
119119
Nan::SetPrototypeMethod(t, "healNetworkNode", OZW::HealNetworkNode);
120120
Nan::SetPrototypeMethod(t, "healNetwork", OZW::HealNetwork);
121121
// openzwave-nodes.cc
122-
#ifdef OPENZWAVE_DEPRECATED16
122+
#ifdef OPENZWAVE16_DEPRECATED
123123
Nan::SetPrototypeMethod(t, "setNodeOn", OZW::SetNodeOn);
124124
Nan::SetPrototypeMethod(t, "setNodeOff", OZW::SetNodeOff);
125125
Nan::SetPrototypeMethod(t, "setNodeLevel", OZW::SetNodeLevel);
@@ -196,7 +196,7 @@ namespace OZW {
196196
Nan::SetPrototypeMethod(t, "getPollIntensity", OZW::GetPollIntensity); // ** new
197197
Nan::SetPrototypeMethod(t, "setPollIntensity", OZW::SetPollIntensity); // ** new
198198
// openzwave-scenes.cc
199-
#ifdef OPENZWAVE_DEPRECATED16
199+
#ifdef OPENZWAVE16_DEPRECATED
200200
Nan::SetPrototypeMethod(t, "createScene", OZW::CreateScene);
201201
Nan::SetPrototypeMethod(t, "removeScene", OZW::RemoveScene);
202202
Nan::SetPrototypeMethod(t, "getScenes", OZW::GetScenes);

src/openzwave.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ namespace OZW {
102102
static NAN_METHOD(BeginControllerCommand);
103103
#endif
104104
static NAN_METHOD(CancelControllerCommand);
105-
#ifndef OPENZWAVE_DEPRECATED16
105+
#ifdef OPENZWAVE16_DEPRECATED
106106
static NAN_METHOD(WriteConfig);
107107
#endif
108108
static NAN_METHOD(GetDriverStatistics);
@@ -113,7 +113,7 @@ namespace OZW {
113113
static NAN_METHOD(HealNetworkNode);
114114
static NAN_METHOD(HealNetwork);
115115
// openzwave-nodes.cc
116-
#ifndef OPENZWAVE_DEPRECATED16
116+
#ifdef OPENZWAVE16_DEPRECATED
117117
static NAN_METHOD(SetNodeOn);
118118
static NAN_METHOD(SetNodeOff);
119119
static NAN_METHOD(SetNodeLevel);
@@ -191,16 +191,16 @@ namespace OZW {
191191
static NAN_METHOD(SetPollIntensity);
192192
static NAN_METHOD(GetPollIntensity);
193193
// openzwave-scenes.cc
194-
#ifdef OPENZWAVE_DEPRECATED16
195-
OPENZWAVE_DEPRECATED_WARNINGS_OFF
194+
#ifdef OPENZWAVE16_DEPRECATED
195+
//OPENZWAVE_DEPRECATED_WARNINGS_OFF
196196
static NAN_METHOD(CreateScene);
197197
static NAN_METHOD(RemoveScene);
198198
static NAN_METHOD(GetScenes);
199199
static NAN_METHOD(AddSceneValue);
200200
static NAN_METHOD(RemoveSceneValue);
201201
static NAN_METHOD(SceneGetValues);
202202
static NAN_METHOD(ActivateScene);
203-
OPENZWAVE_DEPRECATED_WARNINGS_ON
203+
//OPENZWAVE_DEPRECATED_WARNINGS_ON
204204
#endif
205205
// Passing configuration around
206206
::std::string userpath;

src/utils.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ Local<Object> zwaveValue2v8Value(OpenZWave::ValueID value)
360360
return handle_scope.Escape(valobj);
361361
}
362362

363-
#ifdef OPENZWAVE_DEPRECATED16
363+
#ifdef OPENZWAVE16_DEPRECATED
364364
// create a V8 object from a ZWave scene value
365365
Local<Object> zwaveSceneValue2v8Value(uint8 sceneId, OpenZWave::ValueID value)
366366
{

src/utils.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121
#define stringify_literal( x ) # x
2222

2323
#if OPENZWAVE_EXCEPTIONS
24-
#define OZWManager(METHOD,...) \
25-
try { \
24+
#define OZWManager(METHOD,...) \
25+
try { \
2626
OpenZWave::Manager::Get() -> METHOD ( __VA_ARGS__ ); \
2727
} catch ( OpenZWave::OZWException& e ) { \
2828
char buffer [200]; \
2929
snprintf(buffer, 200, "Exception calling OpenZWave::Manager::%s in %s(%d): %s", \
3030
stringify(METHOD), e.GetFile().c_str(), e.GetLine(), e.GetMsg().c_str()); \
3131
Nan::ThrowError( buffer ); \
32-
}
32+
}
3333

34-
#define OZWManagerAssign(VALUE,METHOD,...) \
34+
#define OZWManagerAssign(VALUE,METHOD,...) \
3535
try { \
3636
VALUE = OpenZWave::Manager::Get() -> METHOD ( __VA_ARGS__ ); \
3737
} catch ( OpenZWave::OZWException& e ) { \
@@ -133,7 +133,7 @@ namespace OZW {
133133
NodeInfo *get_node_info(uint8 nodeid);
134134
void delete_node(uint8 nodeid);
135135

136-
#ifdef OPENZWAVE_DEPRECATED16
136+
#ifdef OPENZWAVE16_DEPRECATED
137137
v8::Local<v8::Object> zwaveSceneValue2v8Value(uint8 sceneId, OpenZWave::ValueID value);
138138
SceneInfo *get_scene_info(uint8 sceneid);
139139
#endif

test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
var OpenZWave = require('./lib/openzwave-shared.js');
66
var os = require('os');
77

8+
89
// this test assumes no actual ZWave controller exists on the system
910
// and is just a rudimentary check that the driver can initialise itself.
1011
var zwave = new OpenZWave();
1112

13+
//console.log("WriteConfig:", typeof zwave.writeConfig === 'function');
14+
15+
1216
zwave.on('ping', function() {
1317
console.log('driver is emitting events properly');
1418
process.exit();

0 commit comments

Comments
 (0)