Permalink
Browse files

Allowing db-oracle to be used in node 0.4.x and 0.5.x

  • Loading branch information...
1 parent 1d7d4df commit 9eedee982ed00e9c07c3c921f53442c9251974ae @mariano committed Oct 22, 2011
Showing with 21 additions and 7 deletions.
  1. +18 −3 db-oracle.js
  2. +1 −1 lib/node-db
  3. +0 −1 src/oracle.cc
  4. +1 −0 src/oracle_bindings.cc
  5. +0 −1 src/query.cc
  6. +1 −1 wscript
View
@@ -9,6 +9,21 @@
*
* @ignore
*/
-var binding = require("./build/default/oracle_bindings");
-exports.Database = binding.Oracle;
-exports.Query = binding.Query;
+var EventEmitter = require('events').EventEmitter,
+ binding;
+
+try {
+ binding = require("./build/default/oracle_bindings");
+} catch(error) {
+ binding = require("./build/Release/oracle_bindings");
+}
+
+function extend(target, source) {
+ for (var k in source.prototype) {
+ target.prototype[k] = source.prototype[k];
+ }
+ return target;
+}
+
+exports.Query = extend(binding.Query, EventEmitter);
+exports.Database = extend(binding.Oracle, EventEmitter);
Submodule node-db updated 7 files
+11 −11 binding.cc
+10 −5 binding.h
+53 −0 events.cc
+25 −0 events.h
+0 −1 node_defs.h
+18 −18 query.cc
+10 −6 query.h
View
@@ -20,7 +20,6 @@ void node_db_oracle::Oracle::Init(v8::Handle<v8::Object> target) {
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
constructorTemplate = v8::Persistent<v8::FunctionTemplate>::New(t);
- constructorTemplate->Inherit(node::EventEmitter::constructor_template);
constructorTemplate->InstanceTemplate()->SetInternalFieldCount(1);
node_db::Binding::Init(target, constructorTemplate);
View
@@ -5,6 +5,7 @@
extern "C" {
void init(v8::Handle<v8::Object> target) {
+ node_db::EventEmitter::Init();
node_db_oracle::Oracle::Init(target);
node_db_oracle::Query::Init(target);
}
View
@@ -9,7 +9,6 @@ void node_db_oracle::Query::Init(v8::Handle<v8::Object> target) {
v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(New);
constructorTemplate = v8::Persistent<v8::FunctionTemplate>::New(t);
- constructorTemplate->Inherit(node::EventEmitter::constructor_template);
constructorTemplate->InstanceTemplate()->SetInternalFieldCount(1);
node_db::Query::Init(target, constructorTemplate);
View
@@ -45,7 +45,7 @@ def configure(conf):
def build(bld):
obj = bld.new_task_gen("cxx", "shlib", "node_addon")
obj.target = "oracle_bindings"
- obj.source = "lib/node-db/binding.cc lib/node-db/connection.cc lib/node-db/exception.cc lib/node-db/query.cc lib/node-db/result.cc src/connection.cc src/oracle.cc src/query.cc src/result.cc src/oracle_bindings.cc"
+ obj.source = "lib/node-db/binding.cc lib/node-db/connection.cc lib/node-db/events.cc lib/node-db/exception.cc lib/node-db/query.cc lib/node-db/result.cc src/connection.cc src/oracle.cc src/query.cc src/result.cc src/oracle_bindings.cc"
obj.includes = "lib/"
def test(tst):

0 comments on commit 9eedee9

Please sign in to comment.