Skip to content
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

Node 12.x Support #564

Merged
merged 9 commits into from
Aug 15, 2019
Merged
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
203 changes: 107 additions & 96 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
"test": "cd test && node run-tests.js"
},
"dependencies": {
"bindings": "^1.3.0",
"fs-extra": "^8.0.1",
"bindings": "^1.5.0",
"fs-extra": "^8.1.0",
"fstream": "^1.0.12",
"nan": "^2.11.0",
"nan": "^2.14.0",
"q": "^1.5.1",
"request": "^2.88.0",
"targz": "^1.0.1",
Expand Down
185 changes: 84 additions & 101 deletions src/odbc.cpp

Large diffs are not rendered by default.

53 changes: 36 additions & 17 deletions src/odbc.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@ class ODBC : public Nan::ObjectWrap {
static uv_mutex_t g_odbcMutex;
static uv_async_t g_async;

static void Init(v8::Handle<Object> exports);
static NAN_MODULE_INIT(Init);
static Column* GetColumns(SQLHSTMT hStmt, short* colCount);
static void FreeColumns(Column* columns, short* colCount);
static Handle<Value> GetColumnValue(SQLHSTMT hStmt, Column column, uint16_t* buffer, int bufferLength);
static Handle<Value> GetOutputParameter(Parameter prm);
static v8::Local<Value> GetColumnValue(SQLHSTMT hStmt, Column column, uint16_t* buffer, int bufferLength);
static Local<Value> GetOutputParameter(Parameter prm);
static Local<Object> GetRecordTuple (SQLHSTMT hStmt, Column* columns, short* colCount, uint16_t* buffer, int bufferLength);
static Local<Value> GetRecordArray (SQLHSTMT hStmt, Column* columns, short* colCount, uint16_t* buffer, int bufferLength);
static Handle<Value> CallbackSQLError(SQLSMALLINT handleType, SQLHANDLE handle, Nan::Callback* cb);
static Local<Value> CallbackSQLError(SQLSMALLINT handleType, SQLHANDLE handle, Nan::Callback* cb);
static Local<Value> CallbackSQLError (SQLSMALLINT handleType, SQLHANDLE handle, char* message, Nan::Callback* cb);
static Local<Value> GetSQLError (SQLSMALLINT handleType, SQLHANDLE handle);
static Local<Value> GetSQLError (SQLSMALLINT handleType, SQLHANDLE handle, char* message);
Expand Down Expand Up @@ -216,19 +216,19 @@ struct query_request {
#define REQ_STR_ARG(I, VAR) \
if (info.Length() <= (I) || !info[I]->IsString()) \
return Nan::ThrowTypeError("Argument " #I " must be a string"); \
String::Utf8Value VAR(info[I]->ToString());
Nan::Utf8String VAR(info[I]);

//Require String Argument; Save String as Wide String (UCS2)
#define REQ_WSTR_ARG(I, VAR) \
if (info.Length() <= (I) || !info[I]->IsString()) \
return Nan::ThrowTypeError("Argument " #I " must be a string"); \
String::Value VAR(info[I]->ToString());
if (info.Length() <= (I) || !info[I]->IsString()) \
return Nan::ThrowTypeError("Argument " #I " must be a string"); \
Nan::Utf8String VAR(info[I]);

//Require String Argument; Save String as Object
#define REQ_STRO_ARG(I, VAR) \
if (info.Length() <= (I) || !info[I]->IsString()) \
return Nan::ThrowTypeError("Argument " #I " must be a string"); \
Local<String> VAR(info[I]->ToString());
if (info.Length() <= (I) || !info[I]->IsString()) \
return Nan::ThrowTypeError("Argument " #I " must be a string"); \
Nan::Utf8String VAR(info[I]);

//Require String or Null Argument; Save String as Utf8
#define REQ_STR_OR_NULL_ARG(I, VAR) \
Expand All @@ -247,8 +247,8 @@ struct query_request {
if ( info.Length() <= (I) || (!info[I]->IsString() && !info[I]->IsNull()) ) { \
Nan::ThrowTypeError("Argument " #I " must be a string or null"); \
return; \
} \
Local<String> VAR(info[I]->ToString());
} \
Nan::Utf8String VAR(info[I]);

#define REQ_FUN_ARG(I, VAR) \
if (info.Length() <= (I) || !info[I]->IsFunction()) \
Expand All @@ -258,7 +258,7 @@ struct query_request {
#define REQ_BOOL_ARG(I, VAR) \
if (info.Length() <= (I) || !info[I]->IsBoolean()) \
return Nan::ThrowTypeError("Argument " #I " must be a boolean"); \
Local<Boolean> VAR = (info[I]->ToBoolean());
Local<Boolean> VAR = Nan::To<v8::Boolean>(info[I]).ToLocalChecked();

#define REQ_EXT_ARG(I, VAR) \
if (info.Length() <= (I) || !info[I]->IsExternal()) \
Expand All @@ -268,18 +268,37 @@ struct query_request {
#define REQ_INT_ARG(I, VAR) \
if (info.Length() <= (I) || !info[I]->IsInt32()) \
return Nan::ThrowTypeError("Argument " #I " invalid"); \
SQLUSMALLINT VAR = (info[I]->Int32Value());
SQLUSMALLINT VAR = (Nan::To<v8::Int32>(info[I]).ToLocalChecked()->Value());

#define OPT_INT_ARG(I, VAR, DEFAULT) \
SQLUSMALLINT VAR; \
if (info.Length() <= (I)) { \
VAR = (DEFAULT); \
} else if (info[I]->IsInt32()) { \
VAR = info[I]->Int32Value(); \
VAR = Nan::To<v8::Int32>(info[I]).ToLocalChecked()->Value(); \
} else { \
return Nan::ThrowTypeError("Argument " #I " must be an integer"); \
return Nan::ThrowTypeError("Argument " #I " must be an integer"); \
}

// Macro to get c++ string from Utf8String(JS string)
#ifdef UNICODE
#define GETCPPSTR(to, from, len) \
if(len > 0 && strcmp(*from, "null")) { \
to = (uint16_t *) malloc((len + 1) * sizeof(uint16_t)); \
MEMCHECK( to ) ; \
/*std::copy(*from, *from + len, (uint16_t*)to); */ \
memcpy(to, *from, len); \
((uint16_t*)to)[len] = '\0'; \
} else { len = 0; }
#else
#define GETCPPSTR(to, from, len) \
if(len > 0 && strcmp(*from, "null")) { \
to = (char *)malloc(len + 1); \
MEMCHECK( to ) ; \
memcpy(to, *from, len); \
((char*)to)[len] = '\0'; \
} else { len = 0; }
#endif

// From node v10 NODE_DEFINE_CONSTANT
#define NODE_ODBC_DEFINE_CONSTANT(constructor_template, constant) \
Expand Down
Loading