Permalink
Browse files

weee works

  • Loading branch information...
Marcus
Marcus committed Apr 6, 2012
0 parents commit b3aa877c2275a77ebd11a728a84de32959d51454
Showing with 88 additions and 0 deletions.
  1. +1 −0 readme.md
  2. +48 −0 telldus.cc
  3. +3 −0 test.js
  4. +36 −0 wscript
@@ -0,0 +1 @@
+Node bindings for telldus-core
@@ -0,0 +1,48 @@
+#define BUILDING_NODE_EXTENSION
+#include <node.h>
+#include <v8.h>
+#include <unistd.h>
+#include <stdio.h>
+
+#include <telldus-core.h>
+
+using namespace v8;
+using namespace node;
+
+#ifdef _WINDOWS
+#define strcasecmp _stricmp
+#define DEGREE " "
+#else
+#define DEGREE "°"
+#endif
+
+const int SUPPORTED_METHODS =
+ TELLSTICK_TURNON |
+ TELLSTICK_TURNOFF |
+ TELLSTICK_BELL |
+ TELLSTICK_DIM;
+
+const int DATA_LENGTH = 20;
+
+namespace telldus_v8 {
+
+ Handle<Value> TdGetNumberOfDevices( const Arguments& args ) {
+ HandleScope scope;
+ //tdInit();
+ Local<Number> num = Number::New(tdGetNumberOfDevices());
+ return scope.Close(num);
+ }
+}
+
+extern "C"
+void init(Handle<Object> target) {
+
+ HandleScope scope;
+ //Local<FunctionTemplate> t = FunctionTemplate::New(telldus_v8::tdGetNumberOfDevices);
+
+ //target->Set( String::NewSymbol( "tdGetNumberOfDevices" ), t->GetFunction() );
+ target->Set(String::NewSymbol("TdGetNumberOfDevices"),
+ FunctionTemplate::New(telldus_v8::TdGetNumberOfDevices)->GetFunction());
+}
+
+NODE_MODULE(telldus, init)
@@ -0,0 +1,3 @@
+var addon = require('./build/Release/telldus');
+
+console.log(addon.TdGetNumberOfDevices());
36 wscript
@@ -0,0 +1,36 @@
+import Options
+from os import unlink, symlink, popen
+from os.path import exists
+
+srcdir = '.'
+blddir = 'build'
+VERSION = '0.0.1'
+
+def set_options(opt):
+ opt.tool_options('compiler_cxx')
+ opt.tool_options('osx')
+
+def configure(conf):
+ conf.check_tool('compiler_cxx')
+ conf.check_tool('node_addon')
+ conf.check_tool('osx')
+
+
+ tc_framework = 'TelldusCore'
+ conf.env.append_value("FRAMEWORK_TC", tc_framework)
+ tc_frameworkpath = '/Library/Frameworks/TelldusCore.framework/'
+ conf.env.append_value("FRAMEWORKPATH_TC", tc_frameworkpath)
+ tc_libdir = '/Library/Frameworks/TelldusCore.framework/Versions/Current/'
+ conf.env.append_value("LIBPATH_TC", tc_libdir)
+ tc_includedir = '/Library/Frameworks/TelldusCore.framework/Versions/2.1.1/Headers/'
+ conf.env.append_value("CPPPATH_TC", tc_includedir)
+ #conf.env.append_value("LIB_TC", 'TelldusCore')
+ #conf.env.append_value("CFLAGS_TC", '-o TelldusCore')
+
+
+
+def build(bld):
+ obj = bld.new_task_gen('cxx', 'shlib', 'node_addon')
+ obj.target = 'telldus'
+ obj.source = 'telldus.cc'
+ obj.uselib = "TC"

0 comments on commit b3aa877

Please sign in to comment.