src: update to nan@1.3.0
- It builds in 0.8, 0.10. and 0.11.13 without warnings.
This commit is contained in:
parent
7d05eb7368
commit
7a8940f4a0
@ -21,7 +21,7 @@
|
|||||||
"generic-pool": "2.1.1",
|
"generic-pool": "2.1.1",
|
||||||
"buffer-writer": "1.0.0",
|
"buffer-writer": "1.0.0",
|
||||||
"pgpass": "0.0.3",
|
"pgpass": "0.0.3",
|
||||||
"nan": "~1.2.0",
|
"nan": "~1.3.0",
|
||||||
"packet-reader": "0.2.0",
|
"packet-reader": "0.2.0",
|
||||||
"pg-connection-string": "0.1.1",
|
"pg-connection-string": "0.1.1",
|
||||||
"pg-types": "1.4.0"
|
"pg-types": "1.4.0"
|
||||||
|
@ -30,25 +30,25 @@ public:
|
|||||||
Init (Handle<Object> target)
|
Init (Handle<Object> target)
|
||||||
{
|
{
|
||||||
NanScope();
|
NanScope();
|
||||||
Local<FunctionTemplate> t = FunctionTemplate::New(New);
|
Local<FunctionTemplate> t = NanNew<FunctionTemplate>(New);
|
||||||
|
|
||||||
t->InstanceTemplate()->SetInternalFieldCount(1);
|
t->InstanceTemplate()->SetInternalFieldCount(1);
|
||||||
t->SetClassName(NanSymbol("Connection"));
|
t->SetClassName(NanNew("Connection"));
|
||||||
|
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "connect", Connect);
|
NanSetPrototypeTemplate(t, "connect", NanNew<FunctionTemplate>(Connect));
|
||||||
#ifdef ESCAPE_SUPPORTED
|
#ifdef ESCAPE_SUPPORTED
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "escapeIdentifier", EscapeIdentifier);
|
NanSetPrototypeTemplate(t, "escapeIdentifier", NanNew<FunctionTemplate>(EscapeIdentifier));
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "escapeLiteral", EscapeLiteral);
|
NanSetPrototypeTemplate(t, "escapeLiteral", NanNew<FunctionTemplate>(EscapeLiteral));
|
||||||
#endif
|
#endif
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "_sendQuery", SendQuery);
|
NanSetPrototypeTemplate(t, "_sendQuery", NanNew<FunctionTemplate>(SendQuery));
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "_sendQueryWithParams", SendQueryWithParams);
|
NanSetPrototypeTemplate(t, "_sendQueryWithParams", NanNew<FunctionTemplate>(SendQueryWithParams));
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "_sendPrepare", SendPrepare);
|
NanSetPrototypeTemplate(t, "_sendPrepare", NanNew<FunctionTemplate>(SendPrepare));
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "_sendQueryPrepared", SendQueryPrepared);
|
NanSetPrototypeTemplate(t, "_sendQueryPrepared", NanNew<FunctionTemplate>(SendQueryPrepared));
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "cancel", Cancel);
|
NanSetPrototypeTemplate(t, "cancel", NanNew<FunctionTemplate>(Cancel));
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "end", End);
|
NanSetPrototypeTemplate(t, "end", NanNew<FunctionTemplate>(End));
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "_sendCopyFromChunk", SendCopyFromChunk);
|
NanSetPrototypeTemplate(t, "_sendCopyFromChunk", NanNew<FunctionTemplate>(SendCopyFromChunk));
|
||||||
NODE_SET_PROTOTYPE_METHOD(t, "_endCopyFrom", EndCopyFrom);
|
NanSetPrototypeTemplate(t, "_endCopyFrom", NanNew<FunctionTemplate>(EndCopyFrom));
|
||||||
target->Set(String::NewSymbol("Connection"), t->GetFunction());
|
target->Set(NanNew("Connection"), t->GetFunction());
|
||||||
TRACE("created class");
|
TRACE("created class");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ public:
|
|||||||
THROW(self->GetLastError());
|
THROW(self->GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
Local<Value> jsStr = String::New(escapedStr, strlen(escapedStr));
|
Local<Value> jsStr = NanNew<String>(escapedStr, strlen(escapedStr));
|
||||||
PQfreemem(escapedStr);
|
PQfreemem(escapedStr);
|
||||||
|
|
||||||
NanReturnValue(jsStr);
|
NanReturnValue(jsStr);
|
||||||
@ -146,7 +146,7 @@ public:
|
|||||||
THROW(self->GetLastError());
|
THROW(self->GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
Local<Value> jsStr = String::New(escapedStr, strlen(escapedStr));
|
Local<Value> jsStr = NanNew<String>(escapedStr, strlen(escapedStr));
|
||||||
PQfreemem(escapedStr);
|
PQfreemem(escapedStr);
|
||||||
|
|
||||||
NanReturnValue(jsStr);
|
NanReturnValue(jsStr);
|
||||||
@ -477,7 +477,7 @@ protected:
|
|||||||
void HandleNotice(const char *message)
|
void HandleNotice(const char *message)
|
||||||
{
|
{
|
||||||
NanScope();
|
NanScope();
|
||||||
Handle<Value> notice = String::New(message);
|
Handle<Value> notice = NanNew<String>(message);
|
||||||
Emit("notice", ¬ice);
|
Emit("notice", ¬ice);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,9 +536,9 @@ protected:
|
|||||||
PGnotify *notify;
|
PGnotify *notify;
|
||||||
TRACE("PQnotifies");
|
TRACE("PQnotifies");
|
||||||
while ((notify = PQnotifies(connection_))) {
|
while ((notify = PQnotifies(connection_))) {
|
||||||
Local<Object> result = Object::New();
|
Local<Object> result = NanNew<Object>();
|
||||||
result->Set(NanSymbol("channel"), String::New(notify->relname));
|
result->Set(NanNew("channel"), NanNew(notify->relname));
|
||||||
result->Set(NanSymbol("payload"), String::New(notify->extra));
|
result->Set(NanNew("payload"), NanNew(notify->extra));
|
||||||
Handle<Value> res = (Handle<Value>)result;
|
Handle<Value> res = (Handle<Value>)result;
|
||||||
Emit("notification", &res);
|
Emit("notification", &res);
|
||||||
PQfreemem(notify);
|
PQfreemem(notify);
|
||||||
@ -585,19 +585,19 @@ protected:
|
|||||||
void EmitRowDescription(const PGresult* result)
|
void EmitRowDescription(const PGresult* result)
|
||||||
{
|
{
|
||||||
NanScope();
|
NanScope();
|
||||||
Local<Array> row = Array::New();
|
Local<Array> row = NanNew<Array>();
|
||||||
int fieldCount = PQnfields(result);
|
int fieldCount = PQnfields(result);
|
||||||
for(int fieldNumber = 0; fieldNumber < fieldCount; fieldNumber++) {
|
for(int fieldNumber = 0; fieldNumber < fieldCount; fieldNumber++) {
|
||||||
Local<Object> field = Object::New();
|
Local<Object> field = NanNew<Object>();
|
||||||
//name of field
|
//name of field
|
||||||
char* fieldName = PQfname(result, fieldNumber);
|
char* fieldName = PQfname(result, fieldNumber);
|
||||||
field->Set(NanSymbol("name"), String::New(fieldName));
|
field->Set(NanNew("name"), NanNew(fieldName));
|
||||||
|
|
||||||
//oid of type of field
|
//oid of type of field
|
||||||
int fieldType = PQftype(result, fieldNumber);
|
int fieldType = PQftype(result, fieldNumber);
|
||||||
field->Set(NanSymbol("dataTypeID"), Integer::New(fieldType));
|
field->Set(NanNew("dataTypeID"), NanNew(fieldType));
|
||||||
|
|
||||||
row->Set(Integer::New(fieldNumber), field);
|
row->Set(NanNew(fieldNumber), field);
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle<Value> e = (Handle<Value>)row;
|
Handle<Value> e = (Handle<Value>)row;
|
||||||
@ -658,9 +658,9 @@ protected:
|
|||||||
void EmitCommandMetaData(PGresult* result)
|
void EmitCommandMetaData(PGresult* result)
|
||||||
{
|
{
|
||||||
NanScope();
|
NanScope();
|
||||||
Local<Object> info = Object::New();
|
Local<Object> info = NanNew<Object>();
|
||||||
info->Set(NanSymbol("command"), String::New(PQcmdStatus(result)));
|
info->Set(NanNew("command"), NanNew(PQcmdStatus(result)));
|
||||||
info->Set(NanSymbol("value"), String::New(PQcmdTuples(result)));
|
info->Set(NanNew("value"), NanNew(PQcmdTuples(result)));
|
||||||
Handle<Value> e = (Handle<Value>)info;
|
Handle<Value> e = (Handle<Value>)info;
|
||||||
Emit("_cmdStatus", &e);
|
Emit("_cmdStatus", &e);
|
||||||
}
|
}
|
||||||
@ -675,16 +675,16 @@ protected:
|
|||||||
int rowCount = PQntuples(result);
|
int rowCount = PQntuples(result);
|
||||||
for(int rowNumber = 0; rowNumber < rowCount; rowNumber++) {
|
for(int rowNumber = 0; rowNumber < rowCount; rowNumber++) {
|
||||||
//create result object for this row
|
//create result object for this row
|
||||||
Local<Array> row = Array::New();
|
Local<Array> row = NanNew<Array>();
|
||||||
int fieldCount = PQnfields(result);
|
int fieldCount = PQnfields(result);
|
||||||
for(int fieldNumber = 0; fieldNumber < fieldCount; fieldNumber++) {
|
for(int fieldNumber = 0; fieldNumber < fieldCount; fieldNumber++) {
|
||||||
|
|
||||||
//value of field
|
//value of field
|
||||||
if(PQgetisnull(result, rowNumber, fieldNumber)) {
|
if(PQgetisnull(result, rowNumber, fieldNumber)) {
|
||||||
row->Set(Integer::New(fieldNumber), Null());
|
row->Set(NanNew(fieldNumber), NanNull());
|
||||||
} else {
|
} else {
|
||||||
char* fieldValue = PQgetvalue(result, rowNumber, fieldNumber);
|
char* fieldValue = PQgetvalue(result, rowNumber, fieldNumber);
|
||||||
row->Set(Integer::New(fieldNumber), String::New(fieldValue));
|
row->Set(NanNew(fieldNumber), NanNew(fieldValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -704,20 +704,20 @@ protected:
|
|||||||
//read-loop callback
|
//read-loop callback
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Local<Object> msg = Local<Object>::Cast(Exception::Error(String::New(errorMessage)));
|
Local<Object> msg = Local<Object>::Cast(NanError(errorMessage));
|
||||||
TRACE("AttachErrorFields");
|
TRACE("AttachErrorFields");
|
||||||
//add the other information returned by Postgres to the error object
|
//add the other information returned by Postgres to the error object
|
||||||
AttachErrorField(result, msg, NanSymbol("severity"), PG_DIAG_SEVERITY);
|
AttachErrorField(result, msg, NanNew("severity"), PG_DIAG_SEVERITY);
|
||||||
AttachErrorField(result, msg, NanSymbol("code"), PG_DIAG_SQLSTATE);
|
AttachErrorField(result, msg, NanNew("code"), PG_DIAG_SQLSTATE);
|
||||||
AttachErrorField(result, msg, NanSymbol("detail"), PG_DIAG_MESSAGE_DETAIL);
|
AttachErrorField(result, msg, NanNew("detail"), PG_DIAG_MESSAGE_DETAIL);
|
||||||
AttachErrorField(result, msg, NanSymbol("hint"), PG_DIAG_MESSAGE_HINT);
|
AttachErrorField(result, msg, NanNew("hint"), PG_DIAG_MESSAGE_HINT);
|
||||||
AttachErrorField(result, msg, NanSymbol("position"), PG_DIAG_STATEMENT_POSITION);
|
AttachErrorField(result, msg, NanNew("position"), PG_DIAG_STATEMENT_POSITION);
|
||||||
AttachErrorField(result, msg, NanSymbol("internalPosition"), PG_DIAG_INTERNAL_POSITION);
|
AttachErrorField(result, msg, NanNew("internalPosition"), PG_DIAG_INTERNAL_POSITION);
|
||||||
AttachErrorField(result, msg, NanSymbol("internalQuery"), PG_DIAG_INTERNAL_QUERY);
|
AttachErrorField(result, msg, NanNew("internalQuery"), PG_DIAG_INTERNAL_QUERY);
|
||||||
AttachErrorField(result, msg, NanSymbol("where"), PG_DIAG_CONTEXT);
|
AttachErrorField(result, msg, NanNew("where"), PG_DIAG_CONTEXT);
|
||||||
AttachErrorField(result, msg, NanSymbol("file"), PG_DIAG_SOURCE_FILE);
|
AttachErrorField(result, msg, NanNew("file"), PG_DIAG_SOURCE_FILE);
|
||||||
AttachErrorField(result, msg, NanSymbol("line"), PG_DIAG_SOURCE_LINE);
|
AttachErrorField(result, msg, NanNew("line"), PG_DIAG_SOURCE_LINE);
|
||||||
AttachErrorField(result, msg, NanSymbol("routine"), PG_DIAG_SOURCE_FUNCTION);
|
AttachErrorField(result, msg, NanNew("routine"), PG_DIAG_SOURCE_FUNCTION);
|
||||||
Handle<Value> m = msg;
|
Handle<Value> m = msg;
|
||||||
TRACE("EmitError");
|
TRACE("EmitError");
|
||||||
Emit("_error", &m);
|
Emit("_error", &m);
|
||||||
@ -728,7 +728,7 @@ protected:
|
|||||||
NanScope();
|
NanScope();
|
||||||
char *val = PQresultErrorField(result, fieldcode);
|
char *val = PQresultErrorField(result, fieldcode);
|
||||||
if(val) {
|
if(val) {
|
||||||
msg->Set(symbol, String::New(val));
|
msg->Set(symbol, NanNew(val));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -746,20 +746,20 @@ private:
|
|||||||
//EventEmitter was removed from c++ in node v0.5.x
|
//EventEmitter was removed from c++ in node v0.5.x
|
||||||
void Emit(const char* message) {
|
void Emit(const char* message) {
|
||||||
NanScope();
|
NanScope();
|
||||||
Handle<Value> args[1] = { String::New(message) };
|
Handle<Value> args[1] = { NanNew(message) };
|
||||||
Emit(1, args);
|
Emit(1, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Emit(const char* message, Handle<Value>* arg) {
|
void Emit(const char* message, Handle<Value>* arg) {
|
||||||
NanScope();
|
NanScope();
|
||||||
Handle<Value> args[2] = { String::New(message), *arg };
|
Handle<Value> args[2] = { NanNew(message), *arg };
|
||||||
Emit(2, args);
|
Emit(2, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Emit(int length, Handle<Value> *args) {
|
void Emit(int length, Handle<Value> *args) {
|
||||||
NanScope();
|
NanScope();
|
||||||
|
|
||||||
Local<Value> emit_v = NanObjectWrapHandle(this)->Get(NanSymbol("emit"));
|
Local<Value> emit_v = NanObjectWrapHandle(this)->Get(NanNew("emit"));
|
||||||
assert(emit_v->IsFunction());
|
assert(emit_v->IsFunction());
|
||||||
Local<Function> emit_f = emit_v.As<Function>();
|
Local<Function> emit_f = emit_v.As<Function>();
|
||||||
|
|
||||||
@ -802,7 +802,7 @@ private:
|
|||||||
void EmitError(const char *message)
|
void EmitError(const char *message)
|
||||||
{
|
{
|
||||||
NanScope();
|
NanScope();
|
||||||
Local<Value> exception = Exception::Error(String::New(message));
|
Local<Value> exception = NanError(message);
|
||||||
Emit("_error", &exception);
|
Emit("_error", &exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user