Skip to content
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
src: update to [email protected]
- It builds in 0.8, 0.10. and 0.11.13 without warnings.
  • Loading branch information
santigimeno committed Sep 3, 2014
commit 7a8940f4a0434860a003ec8dd5cea9d3feb0fd2d
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"generic-pool": "2.1.1",
"buffer-writer": "1.0.0",
"pgpass": "0.0.3",
"nan": "~1.2.0",
"nan": "~1.3.0",
"packet-reader": "0.2.0",
"pg-connection-string": "0.1.1",
"pg-types": "1.4.0"
Expand Down
96 changes: 48 additions & 48 deletions src/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@ class Connection : public ObjectWrap {
Init (Handle<Object> target)
{
NanScope();
Local<FunctionTemplate> t = FunctionTemplate::New(New);
Local<FunctionTemplate> t = NanNew<FunctionTemplate>(New);

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
NODE_SET_PROTOTYPE_METHOD(t, "escapeIdentifier", EscapeIdentifier);
NODE_SET_PROTOTYPE_METHOD(t, "escapeLiteral", EscapeLiteral);
NanSetPrototypeTemplate(t, "escapeIdentifier", NanNew<FunctionTemplate>(EscapeIdentifier));
NanSetPrototypeTemplate(t, "escapeLiteral", NanNew<FunctionTemplate>(EscapeLiteral));
#endif
NODE_SET_PROTOTYPE_METHOD(t, "_sendQuery", SendQuery);
NODE_SET_PROTOTYPE_METHOD(t, "_sendQueryWithParams", SendQueryWithParams);
NODE_SET_PROTOTYPE_METHOD(t, "_sendPrepare", SendPrepare);
NODE_SET_PROTOTYPE_METHOD(t, "_sendQueryPrepared", SendQueryPrepared);
NODE_SET_PROTOTYPE_METHOD(t, "cancel", Cancel);
NODE_SET_PROTOTYPE_METHOD(t, "end", End);
NODE_SET_PROTOTYPE_METHOD(t, "_sendCopyFromChunk", SendCopyFromChunk);
NODE_SET_PROTOTYPE_METHOD(t, "_endCopyFrom", EndCopyFrom);
target->Set(String::NewSymbol("Connection"), t->GetFunction());
NanSetPrototypeTemplate(t, "_sendQuery", NanNew<FunctionTemplate>(SendQuery));
NanSetPrototypeTemplate(t, "_sendQueryWithParams", NanNew<FunctionTemplate>(SendQueryWithParams));
NanSetPrototypeTemplate(t, "_sendPrepare", NanNew<FunctionTemplate>(SendPrepare));
NanSetPrototypeTemplate(t, "_sendQueryPrepared", NanNew<FunctionTemplate>(SendQueryPrepared));
NanSetPrototypeTemplate(t, "cancel", NanNew<FunctionTemplate>(Cancel));
NanSetPrototypeTemplate(t, "end", NanNew<FunctionTemplate>(End));
NanSetPrototypeTemplate(t, "_sendCopyFromChunk", NanNew<FunctionTemplate>(SendCopyFromChunk));
NanSetPrototypeTemplate(t, "_endCopyFrom", NanNew<FunctionTemplate>(EndCopyFrom));
target->Set(NanNew("Connection"), t->GetFunction());
TRACE("created class");
}

Expand Down Expand Up @@ -121,7 +121,7 @@ class Connection : public ObjectWrap {
THROW(self->GetLastError());
}

Local<Value> jsStr = String::New(escapedStr, strlen(escapedStr));
Local<Value> jsStr = NanNew<String>(escapedStr, strlen(escapedStr));
PQfreemem(escapedStr);

NanReturnValue(jsStr);
Expand All @@ -146,7 +146,7 @@ class Connection : public ObjectWrap {
THROW(self->GetLastError());
}

Local<Value> jsStr = String::New(escapedStr, strlen(escapedStr));
Local<Value> jsStr = NanNew<String>(escapedStr, strlen(escapedStr));
PQfreemem(escapedStr);

NanReturnValue(jsStr);
Expand Down Expand Up @@ -477,7 +477,7 @@ class Connection : public ObjectWrap {
void HandleNotice(const char *message)
{
NanScope();
Handle<Value> notice = String::New(message);
Handle<Value> notice = NanNew<String>(message);
Emit("notice", &notice);
}

Expand Down Expand Up @@ -536,9 +536,9 @@ class Connection : public ObjectWrap {
PGnotify *notify;
TRACE("PQnotifies");
while ((notify = PQnotifies(connection_))) {
Local<Object> result = Object::New();
result->Set(NanSymbol("channel"), String::New(notify->relname));
result->Set(NanSymbol("payload"), String::New(notify->extra));
Local<Object> result = NanNew<Object>();
result->Set(NanNew("channel"), NanNew(notify->relname));
result->Set(NanNew("payload"), NanNew(notify->extra));
Handle<Value> res = (Handle<Value>)result;
Emit("notification", &res);
PQfreemem(notify);
Expand Down Expand Up @@ -585,19 +585,19 @@ class Connection : public ObjectWrap {
void EmitRowDescription(const PGresult* result)
{
NanScope();
Local<Array> row = Array::New();
Local<Array> row = NanNew<Array>();
int fieldCount = PQnfields(result);
for(int fieldNumber = 0; fieldNumber < fieldCount; fieldNumber++) {
Local<Object> field = Object::New();
Local<Object> field = NanNew<Object>();
//name of field
char* fieldName = PQfname(result, fieldNumber);
field->Set(NanSymbol("name"), String::New(fieldName));
field->Set(NanNew("name"), NanNew(fieldName));

//oid of type of field
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;
Expand Down Expand Up @@ -658,9 +658,9 @@ class Connection : public ObjectWrap {
void EmitCommandMetaData(PGresult* result)
{
NanScope();
Local<Object> info = Object::New();
info->Set(NanSymbol("command"), String::New(PQcmdStatus(result)));
info->Set(NanSymbol("value"), String::New(PQcmdTuples(result)));
Local<Object> info = NanNew<Object>();
info->Set(NanNew("command"), NanNew(PQcmdStatus(result)));
info->Set(NanNew("value"), NanNew(PQcmdTuples(result)));
Handle<Value> e = (Handle<Value>)info;
Emit("_cmdStatus", &e);
}
Expand All @@ -675,16 +675,16 @@ class Connection : public ObjectWrap {
int rowCount = PQntuples(result);
for(int rowNumber = 0; rowNumber < rowCount; rowNumber++) {
//create result object for this row
Local<Array> row = Array::New();
Local<Array> row = NanNew<Array>();
int fieldCount = PQnfields(result);
for(int fieldNumber = 0; fieldNumber < fieldCount; fieldNumber++) {

//value of field
if(PQgetisnull(result, rowNumber, fieldNumber)) {
row->Set(Integer::New(fieldNumber), Null());
row->Set(NanNew(fieldNumber), NanNull());
} else {
char* fieldValue = PQgetvalue(result, rowNumber, fieldNumber);
row->Set(Integer::New(fieldNumber), String::New(fieldValue));
row->Set(NanNew(fieldNumber), NanNew(fieldValue));
}
}

Expand All @@ -704,20 +704,20 @@ class Connection : public ObjectWrap {
//read-loop callback
return;
}
Local<Object> msg = Local<Object>::Cast(Exception::Error(String::New(errorMessage)));
Local<Object> msg = Local<Object>::Cast(NanError(errorMessage));
TRACE("AttachErrorFields");
//add the other information returned by Postgres to the error object
AttachErrorField(result, msg, NanSymbol("severity"), PG_DIAG_SEVERITY);
AttachErrorField(result, msg, NanSymbol("code"), PG_DIAG_SQLSTATE);
AttachErrorField(result, msg, NanSymbol("detail"), PG_DIAG_MESSAGE_DETAIL);
AttachErrorField(result, msg, NanSymbol("hint"), PG_DIAG_MESSAGE_HINT);
AttachErrorField(result, msg, NanSymbol("position"), PG_DIAG_STATEMENT_POSITION);
AttachErrorField(result, msg, NanSymbol("internalPosition"), PG_DIAG_INTERNAL_POSITION);
AttachErrorField(result, msg, NanSymbol("internalQuery"), PG_DIAG_INTERNAL_QUERY);
AttachErrorField(result, msg, NanSymbol("where"), PG_DIAG_CONTEXT);
AttachErrorField(result, msg, NanSymbol("file"), PG_DIAG_SOURCE_FILE);
AttachErrorField(result, msg, NanSymbol("line"), PG_DIAG_SOURCE_LINE);
AttachErrorField(result, msg, NanSymbol("routine"), PG_DIAG_SOURCE_FUNCTION);
AttachErrorField(result, msg, NanNew("severity"), PG_DIAG_SEVERITY);
AttachErrorField(result, msg, NanNew("code"), PG_DIAG_SQLSTATE);
AttachErrorField(result, msg, NanNew("detail"), PG_DIAG_MESSAGE_DETAIL);
AttachErrorField(result, msg, NanNew("hint"), PG_DIAG_MESSAGE_HINT);
AttachErrorField(result, msg, NanNew("position"), PG_DIAG_STATEMENT_POSITION);
AttachErrorField(result, msg, NanNew("internalPosition"), PG_DIAG_INTERNAL_POSITION);
AttachErrorField(result, msg, NanNew("internalQuery"), PG_DIAG_INTERNAL_QUERY);
AttachErrorField(result, msg, NanNew("where"), PG_DIAG_CONTEXT);
AttachErrorField(result, msg, NanNew("file"), PG_DIAG_SOURCE_FILE);
AttachErrorField(result, msg, NanNew("line"), PG_DIAG_SOURCE_LINE);
AttachErrorField(result, msg, NanNew("routine"), PG_DIAG_SOURCE_FUNCTION);
Handle<Value> m = msg;
TRACE("EmitError");
Emit("_error", &m);
Expand All @@ -728,7 +728,7 @@ class Connection : public ObjectWrap {
NanScope();
char *val = PQresultErrorField(result, fieldcode);
if(val) {
msg->Set(symbol, String::New(val));
msg->Set(symbol, NanNew(val));
}
}

Expand All @@ -746,20 +746,20 @@ class Connection : public ObjectWrap {
//EventEmitter was removed from c++ in node v0.5.x
void Emit(const char* message) {
NanScope();
Handle<Value> args[1] = { String::New(message) };
Handle<Value> args[1] = { NanNew(message) };
Emit(1, args);
}

void Emit(const char* message, Handle<Value>* arg) {
NanScope();
Handle<Value> args[2] = { String::New(message), *arg };
Handle<Value> args[2] = { NanNew(message), *arg };
Emit(2, args);
}

void Emit(int length, Handle<Value> *args) {
NanScope();

Local<Value> emit_v = NanObjectWrapHandle(this)->Get(NanSymbol("emit"));
Local<Value> emit_v = NanObjectWrapHandle(this)->Get(NanNew("emit"));
assert(emit_v->IsFunction());
Local<Function> emit_f = emit_v.As<Function>();

Expand Down Expand Up @@ -802,7 +802,7 @@ class Connection : public ObjectWrap {
void EmitError(const char *message)
{
NanScope();
Local<Value> exception = Exception::Error(String::New(message));
Local<Value> exception = NanError(message);
Emit("_error", &exception);
}

Expand Down