Skip to content

Compile on node 11.14 using nan v1.3.0 #223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"link_settings": {"libraries": [ '<(oci_lib_dir)\oraocci<(oci_version).lib'] }
}]
],
"include_dirs": [ "<(oci_include_dir)" ],
"include_dirs": [ "<(oci_include_dir)", '<!(node -e "require(\'nan\')")' ],
"cflags!": [ "-fno-exceptions" ],
"cflags_cc!": [ "-fno-exceptions" ]
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"url": "git://github.com/joeferner/node-oracle.git"
},
"dependencies": {
"nan": "1.3.0"
},
"devDependencies": {
"nodeunit": "~>0.8.0"
Expand Down
2 changes: 1 addition & 1 deletion src/commitBaton.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class CommitBaton {
uni::Reset(this->callback, *callback);
}
~CommitBaton() {
callback.Dispose();
NanDisposePersistent(callback);
}

Connection *connection;
Expand Down
116 changes: 58 additions & 58 deletions src/connection.cpp

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions src/connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ namespace uni {
typedef v8::FunctionCallbackInfo<v8::Value> FunctionCallbackInfo;
typedef v8::Local<Value> BufferType;
# define UNI_RETURN(scope, args, res) { args.GetReturnValue().Set(res); return; }
# define UNI_THROW(ex) { ThrowException(ex); return; }
# define UNI_THROW(ex) { NanThrowError(ex); return; }
# define UNI_SCOPE(scope) HandleScope scope(Isolate::GetCurrent())
template <class T>
void Reset(Persistent<T>& persistent, Handle<T> handle) {
persistent.Reset(Isolate::GetCurrent(), handle);
}
template <class T>
Handle<T> Deref(Persistent<T>& handle) {
return Handle<T>::New(Isolate::GetCurrent(), handle);
return Local<T>::New(Isolate::GetCurrent(), handle);
}
template <class T>
Local<T> HandleToLocal(Handle<T> handle) {
Expand All @@ -51,7 +51,7 @@ namespace uni {
typedef Arguments FunctionCallbackInfo;
typedef node::Buffer* BufferType;
# define UNI_RETURN(scope, args, res) return scope.Close(res)
# define UNI_THROW(ex) return ThrowException(ex)
# define UNI_THROW(ex) return NanThrowError(ex)
# define UNI_SCOPE(scope) HandleScope scope
template <class T>
void Reset(Persistent<T>& persistent, Handle<T> handle) {
Expand Down
6 changes: 3 additions & 3 deletions src/executeBaton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ExecuteBaton::ExecuteBaton(Connection* connection, const char* sql, v8::Local<v8
}

ExecuteBaton::~ExecuteBaton() {
callback.Dispose();
NanDisposePersistent(callback);

for (std::vector<column_t*>::iterator iterator = columns.begin(), end = columns.end(); iterator != end; ++iterator) {
column_t* col = *iterator;
Expand Down Expand Up @@ -97,7 +97,7 @@ void ExecuteBaton::ResetError() {

double CallDateMethod(v8::Local<v8::Date> date, const char* methodName) {
Handle<Value> args[1]; // should be zero but on windows the compiler will not allow a zero length array
Local<Value> result = Local<Function>::Cast(date->Get(String::New(methodName)))->Call(date, 0, args);
Local<Value> result = Local<Function>::Cast(date->Get(NanNew<String>(methodName)))->Call(date, 0, args);
return Local<Number>::Cast(result)->Value();
}

Expand Down Expand Up @@ -160,7 +160,7 @@ void ExecuteBaton::CopyValuesToBaton(ExecuteBaton* baton, v8::Local<v8::Array>*
}

// output
else if(val->IsObject() && val->ToObject()->FindInstanceInPrototypeChain(uni::Deref(OutParam::constructorTemplate)) != v8::Null()) {
else if(val->IsObject() && val->ToObject()->FindInstanceInPrototypeChain(uni::Deref(OutParam::constructorTemplate)) != NanNull()) {
OutParam* op = node::ObjectWrap::Unwrap<OutParam>(val->ToObject());

// [rfeng] The OutParam object will be destructed. We need to create a new copy.
Expand Down
22 changes: 11 additions & 11 deletions src/oracle_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ConnectBaton::ConnectBaton(OracleClient* client, oracle::occi::Environment* envi
}

ConnectBaton::~ConnectBaton() {
callback.Dispose();
NanDisposePersistent(callback);
if(error) {
delete error;
}
Expand All @@ -35,15 +35,15 @@ ConnectBaton::~ConnectBaton() {
void OracleClient::Init(Handle<Object> target) {
UNI_SCOPE(scope);

Local<FunctionTemplate> t = FunctionTemplate::New(New);
Local<FunctionTemplate> t = NanNew<FunctionTemplate>(New);
uni::Reset(s_ct, t);
uni::Deref(s_ct)->InstanceTemplate()->SetInternalFieldCount(1);
uni::Deref(s_ct)->SetClassName(String::NewSymbol("OracleClient"));
uni::Deref(s_ct)->SetClassName(NanNew<String>("OracleClient"));

NODE_SET_PROTOTYPE_METHOD(uni::Deref(s_ct), "connect", Connect);
NODE_SET_PROTOTYPE_METHOD(uni::Deref(s_ct), "connectSync", ConnectSync);

target->Set(String::NewSymbol("OracleClient"), uni::Deref(s_ct)->GetFunction());
target->Set(NanNew<String>("OracleClient"), uni::Deref(s_ct)->GetFunction());
}

uni::CallbackType OracleClient::New(const uni::FunctionCallbackInfo& args) {
Expand Down Expand Up @@ -109,7 +109,7 @@ uni::CallbackType OracleClient::Connect(const uni::FunctionCallbackInfo& args) {
req->data = baton;
uv_queue_work(uv_default_loop(), req, EIO_Connect, (uv_after_work_cb)EIO_AfterConnect);

UNI_RETURN(scope, args, Undefined());
UNI_RETURN(scope, args, NanUndefined());
}

void OracleClient::EIO_Connect(uv_work_t* req) {
Expand Down Expand Up @@ -140,16 +140,16 @@ void OracleClient::EIO_AfterConnect(uv_work_t* req, int status) {

Handle<Value> argv[2];
if(baton->error) {
argv[0] = Exception::Error(String::New(baton->error->c_str()));
argv[1] = Undefined();
argv[0] = Exception::Error(NanNew<String>(baton->error->c_str()));
argv[1] = NanUndefined();
} else {
argv[0] = Undefined();
argv[0] = NanUndefined();
Handle<Object> connection = uni::Deref(Connection::constructorTemplate)->GetFunction()->NewInstance();
(node::ObjectWrap::Unwrap<Connection>(connection))->setConnection(baton->client->m_environment, baton->connection);
argv[1] = connection;
}

node::MakeCallback(Context::GetCurrent()->Global(), uni::Deref(baton->callback), 2, argv);
NanMakeCallback(NanGetCurrentContext()->Global(), uni::Deref(baton->callback), 2, argv);

delete baton;
delete req;
Expand All @@ -174,9 +174,9 @@ uni::CallbackType OracleClient::ConnectSync(const uni::FunctionCallbackInfo& arg
baton.connection = baton.environment->createConnection(baton.user, baton.password, connectionStr.str());
} catch(oracle::occi::SQLException &ex) {
baton.error = new std::string(ex.getMessage());
UNI_THROW(Exception::Error(String::New(baton.error->c_str())));
UNI_THROW(Exception::Error(NanNew<String>(baton.error->c_str())));
} catch (const std::exception& ex) {
UNI_THROW(Exception::Error(String::New(ex.what())));
UNI_THROW(Exception::Error(NanNew<String>(ex.what())));
}

Handle<Object> connection = uni::Deref(Connection::constructorTemplate)->GetFunction()->NewInstance();
Expand Down
10 changes: 5 additions & 5 deletions src/outParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ Persistent<FunctionTemplate> OutParam::constructorTemplate;
void OutParam::Init(Handle<Object> target) {
UNI_SCOPE(scope);

Local<FunctionTemplate> t = FunctionTemplate::New(New);
Local<FunctionTemplate> t = NanNew<FunctionTemplate>(New);
uni::Reset(constructorTemplate, t);
uni::Deref(constructorTemplate)->InstanceTemplate()->SetInternalFieldCount(1);
uni::Deref(constructorTemplate)->SetClassName(String::NewSymbol("OutParam"));
target->Set(String::NewSymbol("OutParam"), uni::Deref(constructorTemplate)->GetFunction());
uni::Deref(constructorTemplate)->SetClassName(NanNew<String>("OutParam"));
target->Set(NanNew<String>("OutParam"), uni::Deref(constructorTemplate)->GetFunction());
}

uni::CallbackType OutParam::New(const uni::FunctionCallbackInfo& args) {
Expand All @@ -37,7 +37,7 @@ uni::CallbackType OutParam::New(const uni::FunctionCallbackInfo& args) {
OBJ_GET_NUMBER(opts, "size", outParam->_size, 200);

// check if there's an 'in' param
if (opts->Has(String::New("in"))) {
if (opts->Has(NanNew<String>("in"))) {
outParam->_inOut.hasInParam = true;
switch(outParam->_type) {
case OutParam::OCCIINT: {
Expand All @@ -61,7 +61,7 @@ uni::CallbackType OutParam::New(const uni::FunctionCallbackInfo& args) {
break;
}
default:
UNI_THROW(Exception::Error(String::New("Unhandled OutPram type!")));
UNI_THROW(Exception::Error(NanNew<String>("Unhandled OutPram type!")));
}
}
}
Expand Down
17 changes: 8 additions & 9 deletions src/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ Persistent<FunctionTemplate> Reader::constructorTemplate;
void Reader::Init(Handle<Object> target) {
UNI_SCOPE(scope);

Local<FunctionTemplate> t = FunctionTemplate::New(New);
Local<FunctionTemplate> t = NanNew<FunctionTemplate>(New);
uni::Reset(constructorTemplate, t);
uni::Deref(constructorTemplate)->InstanceTemplate()->SetInternalFieldCount(1);
uni::Deref(constructorTemplate)->SetClassName(String::NewSymbol("Reader"));
uni::Deref(constructorTemplate)->SetClassName(NanNew<String>("Reader"));

NODE_SET_PROTOTYPE_METHOD(uni::Deref(constructorTemplate), "nextRows", NextRows);
target->Set(String::NewSymbol("Reader"), uni::Deref(constructorTemplate)->GetFunction());
target->Set(NanNew<String>("Reader"), uni::Deref(constructorTemplate)->GetFunction());
}

Reader::Reader(): ObjectWrap() {
Expand Down Expand Up @@ -45,11 +45,11 @@ uni::CallbackType Reader::NextRows(const uni::FunctionCallbackInfo& args) {
Reader* reader = ObjectWrap::Unwrap<Reader>(args.This());
ReaderBaton* baton = reader->m_baton;
if (baton->error) {
Local<String> message = String::New(baton->error->c_str());
Local<String> message = NanNew<String>(baton->error->c_str());
UNI_THROW(Exception::Error(message));
}
if (baton->busy) {
UNI_THROW(Exception::Error(String::New("invalid state: reader is busy with another nextRows call")));
UNI_THROW(Exception::Error(NanNew<String>("invalid state: reader is busy with another nextRows call")));
}
baton->busy = true;

Expand All @@ -70,7 +70,7 @@ uni::CallbackType Reader::NextRows(const uni::FunctionCallbackInfo& args) {
uv_queue_work(uv_default_loop(), req, EIO_NextRows, (uv_after_work_cb)EIO_AfterNextRows);
baton->connection->Ref();

UNI_RETURN(scope, args, Undefined());
UNI_RETURN(scope, args, NanUndefined());
}

void Reader::EIO_NextRows(uv_work_t* req) {
Expand Down Expand Up @@ -120,8 +120,7 @@ void Reader::EIO_AfterNextRows(uv_work_t* req, int status) {
baton->connection->Unref();
// transfer callback to local and dispose persistent handle
Local<Function> cb = uni::HandleToLocal(uni::Deref(baton->callback));
baton->callback.Dispose();
baton->callback.Clear();
NanDisposePersistent(baton->callback);

Handle<Value> argv[2];
Connection::handleResult(baton, argv);
Expand All @@ -135,6 +134,6 @@ void Reader::EIO_AfterNextRows(uv_work_t* req, int status) {
delete req;

// invoke callback at the very end because callback may re-enter nextRows.
node::MakeCallback(Context::GetCurrent()->Global(), cb, 2, argv);
NanMakeCallback(NanGetCurrentContext()->Global(), cb, 2, argv);
}

3 changes: 2 additions & 1 deletion src/rollbackBaton.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define _rollback_baton_h_

#include "connection.h"
#include "nan.h"

class RollbackBaton {
public:
Expand All @@ -11,7 +12,7 @@ class RollbackBaton {
uni::Reset(this->callback, *callback);
}
~RollbackBaton() {
callback.Dispose();
NanDisposePersistent(callback);
}

Connection *connection;
Expand Down
17 changes: 8 additions & 9 deletions src/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ Persistent<FunctionTemplate> Statement::constructorTemplate;
void Statement::Init(Handle<Object> target) {
UNI_SCOPE(scope);

Local<FunctionTemplate> t = FunctionTemplate::New(New);
Local<FunctionTemplate> t = NanNew<FunctionTemplate>(New);
uni::Reset(constructorTemplate, t);
uni::Deref(constructorTemplate)->InstanceTemplate()->SetInternalFieldCount(1);
uni::Deref(constructorTemplate)->SetClassName(String::NewSymbol("Statement"));
uni::Deref(constructorTemplate)->SetClassName(NanNew<String>("Statement"));

NODE_SET_PROTOTYPE_METHOD(uni::Deref(constructorTemplate), "execute", Execute);
target->Set(String::NewSymbol("Statement"), uni::Deref(constructorTemplate)->GetFunction());
target->Set(NanNew<String>("Statement"), uni::Deref(constructorTemplate)->GetFunction());
}

Statement::Statement(): ObjectWrap() {
Expand Down Expand Up @@ -51,12 +51,12 @@ uni::CallbackType Statement::Execute(const uni::FunctionCallbackInfo& args) {

ExecuteBaton::CopyValuesToBaton(baton, &values);
if (baton->error) {
Local<String> message = String::New(baton->error->c_str());
Local<String> message = NanNew<String>(baton->error->c_str());
UNI_THROW(Exception::Error(message));
}

if (baton->busy) {
UNI_THROW(Exception::Error(String::New("invalid state: statement is busy with another execute call")));
UNI_THROW(Exception::Error(NanNew<String>("invalid state: statement is busy with another execute call")));
}
baton->busy = true;

Expand All @@ -65,7 +65,7 @@ uni::CallbackType Statement::Execute(const uni::FunctionCallbackInfo& args) {
uv_queue_work(uv_default_loop(), req, EIO_Execute, (uv_after_work_cb)EIO_AfterExecute);
baton->connection->Ref();

UNI_RETURN(scope, args, Undefined());
UNI_RETURN(scope, args, NanUndefined());
}

void Statement::EIO_Execute(uv_work_t* req) {
Expand All @@ -90,8 +90,7 @@ void Statement::EIO_AfterExecute(uv_work_t* req, int status) {
baton->connection->Unref();
// transfer callback to local and dispose persistent handle
Local<Function> cb = uni::HandleToLocal(uni::Deref(baton->callback));
baton->callback.Dispose();
baton->callback.Clear();
NanDisposePersistent(baton->callback);

Handle<Value> argv[2];
Connection::handleResult(baton, argv);
Expand All @@ -103,6 +102,6 @@ void Statement::EIO_AfterExecute(uv_work_t* req, int status) {
delete req;

// invoke callback at the very end because callback may re-enter execute.
node::MakeCallback(Context::GetCurrent()->Global(), cb, 2, argv);
NanMakeCallback(NanGetCurrentContext()->Global(), cb, 2, argv);
}

17 changes: 9 additions & 8 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,41 @@
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include "nan.h"

#define REQ_BOOL_ARG(I, VAR) \
if (args.Length() <= (I) || !args[I]->IsBoolean()) \
UNI_THROW(Exception::TypeError(String::New("Argument " #I " must be a bool"))); \
UNI_THROW(Exception::TypeError(NanNew<String>("Argument " #I " must be a bool"))); \
bool VAR = args[I]->IsTrue();

#define REQ_INT_ARG(I, VAR) \
if (args.Length() <= (I) || !args[I]->IsNumber()) \
UNI_THROW(Exception::TypeError(String::New("Argument " #I " must be an integer"))); \
UNI_THROW(Exception::TypeError(NanNew<String>("Argument " #I " must be an integer"))); \
int VAR = args[I]->NumberValue();

#define REQ_STRING_ARG(I, VAR) \
if (args.Length() <= (I) || !args[I]->IsString()) \
UNI_THROW(Exception::TypeError(String::New("Argument " #I " must be a string"))); \
UNI_THROW(Exception::TypeError(NanNew<String>("Argument " #I " must be a string"))); \
Local<String> VAR = Local<String>::Cast(args[I]);

#define REQ_ARRAY_ARG(I, VAR) \
if (args.Length() <= (I) || !args[I]->IsArray()) \
UNI_THROW(Exception::TypeError(String::New("Argument " #I " must be an array"))); \
UNI_THROW(Exception::TypeError(NanNew<String>("Argument " #I " must be an array"))); \
Local<Array> VAR = Local<Array>::Cast(args[I]);

#define REQ_FUN_ARG(I, VAR) \
if (args.Length() <= (I) || !args[I]->IsFunction()) \
UNI_THROW(Exception::TypeError(String::New("Argument " #I " must be a function"))); \
UNI_THROW(Exception::TypeError(NanNew<String>("Argument " #I " must be a function"))); \
Local<Function> VAR = Local<Function>::Cast(args[I]);

#define REQ_OBJECT_ARG(I, VAR) \
if (args.Length() <= (I) || !args[I]->IsObject()) \
UNI_THROW(Exception::TypeError(String::New("Argument " #I " must be an object"))); \
UNI_THROW(Exception::TypeError(NanNew<String>("Argument " #I " must be an object"))); \
Local<Object> VAR = Local<Object>::Cast(args[I]);

#define OBJ_GET_STRING(OBJ, KEY, VAR) \
{ \
Local<Value> __val = OBJ->Get(String::New(KEY)); \
Local<Value> __val = OBJ->Get(NanNew<String>(KEY)); \
if(__val->IsString()) { \
String::Utf8Value __utf8Val(__val); \
VAR = *__utf8Val; \
Expand All @@ -48,7 +49,7 @@

#define OBJ_GET_NUMBER(OBJ, KEY, VAR, DEFAULT) \
{ \
Local<Value> __val = OBJ->Get(String::New(KEY)); \
Local<Value> __val = OBJ->Get(NanNew<String>(KEY)); \
if(__val->IsNumber()) { \
VAR = __val->ToNumber()->Value(); \
} \
Expand Down