jperkin / node-openzwave

node.js interface to libopenzwave
Other
110 stars 55 forks source link

updated openzwave.cc for nodejs 0.12 #48

Open simon-jentzsch opened 9 years ago

simon-jentzsch commented 9 years ago

Here I applied only the changes needed in order to run the addon in nodejs 0.12

jperkin commented 9 years ago

Thanks for this! Unfortunately you seem to have included whitespace changes which makes it very difficult to see exactly what is required to support 0.12.

My plan is to move to using https://github.com/tjfontaine/node-addon-layer as I did recently with https://github.com/jperkin/node-rpio which will isolate the addon from further API changes but I'd be happy to pull in a fix for 0.12 in the meantime as long as it didn't break older releases.

ghost commented 9 years ago

Hi, unfortunately, the setValue method cant be called from javascript with this patch in node 0.12:

TypeError: Illegal invocation at zwave.setValue (/home/node_modules/openzwave/test.js:128:1) at Object. (/home/node_modules/openzwave/test.js:131:7) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:501:10) at startup (node.js:129:16) at node.js:814:3 br

ekarak commented 9 years ago

Yes. I stumbled upon the same issue yesterday. Seems node js 0.12 is a mess. Root cause is:

There is an inherit() function in lib/openzwave.js which copies the functions exposed by openzwave.CC from one prototype to another. This is b0rken in 0.12. So the following works perfectly: zwave.addon.setValue()

hmmt the inherit method tries to copy setValue to the wrapper object but gets an incomplete copy perhaps?

Note: I recompiled for 0.10.36 and I went back to normal. Node JS IS SUCH A MESS! Στις 5 Απρ 2015 2:21 π.μ., ο χρήστης "Markus Schweitzer" < notifications@github.com> έγραψε:

Hi, unfortunately, the setValue method cant be called from javascript with this patch in node 0.12:

TypeError: Illegal invocation at zwave.setValue (/home/node_modules/openzwave/test.js:128:1) at Object. (/home/node_modules/openzwave/test.js:131:7) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:501:10) at startup (node.js:129:16) at node.js:814:3 br

— Reply to this email directly or view it on GitHub https://github.com/jperkin/node-openzwave/pull/48#issuecomment-89683202.

ekarak commented 9 years ago

Hi all, I've just committed a 'nan' branch of my 'node-openzwave-shared' project where all the Node.JS API is wrapped in NaN (Node.JS is A Nightmare) - please check out a copy of the code and give it a try.