@@ -30,25 +30,25 @@ class Connection : public ObjectWrap {
30
30
Init (Handle <Object> target)
31
31
{
32
32
NanScope ();
33
- Local<FunctionTemplate> t = FunctionTemplate::New (New);
33
+ Local<FunctionTemplate> t = NanNew< FunctionTemplate> (New);
34
34
35
35
t->InstanceTemplate ()->SetInternalFieldCount (1 );
36
- t->SetClassName (NanSymbol (" Connection" ));
36
+ t->SetClassName (NanNew (" Connection" ));
37
37
38
- NODE_SET_PROTOTYPE_METHOD (t, " connect" , Connect);
38
+ NanSetPrototypeTemplate (t, " connect" , NanNew<FunctionTemplate>( Connect) );
39
39
#ifdef ESCAPE_SUPPORTED
40
- NODE_SET_PROTOTYPE_METHOD (t, " escapeIdentifier" , EscapeIdentifier);
41
- NODE_SET_PROTOTYPE_METHOD (t, " escapeLiteral" , EscapeLiteral);
40
+ NanSetPrototypeTemplate (t, " escapeIdentifier" , NanNew<FunctionTemplate>( EscapeIdentifier) );
41
+ NanSetPrototypeTemplate (t, " escapeLiteral" , NanNew<FunctionTemplate>( EscapeLiteral) );
42
42
#endif
43
- NODE_SET_PROTOTYPE_METHOD (t, " _sendQuery" , SendQuery);
44
- NODE_SET_PROTOTYPE_METHOD (t, " _sendQueryWithParams" , SendQueryWithParams);
45
- NODE_SET_PROTOTYPE_METHOD (t, " _sendPrepare" , SendPrepare);
46
- NODE_SET_PROTOTYPE_METHOD (t, " _sendQueryPrepared" , SendQueryPrepared);
47
- NODE_SET_PROTOTYPE_METHOD (t, " cancel" , Cancel);
48
- NODE_SET_PROTOTYPE_METHOD (t, " end" , End);
49
- NODE_SET_PROTOTYPE_METHOD (t, " _sendCopyFromChunk" , SendCopyFromChunk);
50
- NODE_SET_PROTOTYPE_METHOD (t, " _endCopyFrom" , EndCopyFrom);
51
- target->Set (String::NewSymbol (" Connection" ), t->GetFunction ());
43
+ NanSetPrototypeTemplate (t, " _sendQuery" , NanNew<FunctionTemplate>( SendQuery) );
44
+ NanSetPrototypeTemplate (t, " _sendQueryWithParams" , NanNew<FunctionTemplate>( SendQueryWithParams) );
45
+ NanSetPrototypeTemplate (t, " _sendPrepare" , NanNew<FunctionTemplate>( SendPrepare) );
46
+ NanSetPrototypeTemplate (t, " _sendQueryPrepared" , NanNew<FunctionTemplate>( SendQueryPrepared) );
47
+ NanSetPrototypeTemplate (t, " cancel" , NanNew<FunctionTemplate>( Cancel) );
48
+ NanSetPrototypeTemplate (t, " end" , NanNew<FunctionTemplate>( End) );
49
+ NanSetPrototypeTemplate (t, " _sendCopyFromChunk" , NanNew<FunctionTemplate>( SendCopyFromChunk) );
50
+ NanSetPrototypeTemplate (t, " _endCopyFrom" , NanNew<FunctionTemplate>( EndCopyFrom) );
51
+ target->Set (NanNew (" Connection" ), t->GetFunction ());
52
52
TRACE (" created class" );
53
53
}
54
54
@@ -121,7 +121,7 @@ class Connection : public ObjectWrap {
121
121
THROW (self->GetLastError ());
122
122
}
123
123
124
- Local<Value> jsStr = String::New (escapedStr, strlen (escapedStr));
124
+ Local<Value> jsStr = NanNew< String> (escapedStr, strlen (escapedStr));
125
125
PQfreemem (escapedStr);
126
126
127
127
NanReturnValue (jsStr);
@@ -146,7 +146,7 @@ class Connection : public ObjectWrap {
146
146
THROW (self->GetLastError ());
147
147
}
148
148
149
- Local<Value> jsStr = String::New (escapedStr, strlen (escapedStr));
149
+ Local<Value> jsStr = NanNew< String> (escapedStr, strlen (escapedStr));
150
150
PQfreemem (escapedStr);
151
151
152
152
NanReturnValue (jsStr);
@@ -477,7 +477,7 @@ class Connection : public ObjectWrap {
477
477
void HandleNotice (const char *message)
478
478
{
479
479
NanScope ();
480
- Handle <Value> notice = String::New (message);
480
+ Handle <Value> notice = NanNew< String> (message);
481
481
Emit (" notice" , ¬ice);
482
482
}
483
483
@@ -536,9 +536,9 @@ class Connection : public ObjectWrap {
536
536
PGnotify *notify;
537
537
TRACE (" PQnotifies" );
538
538
while ((notify = PQnotifies (connection_))) {
539
- Local<Object> result = Object::New ();
540
- result->Set (NanSymbol (" channel" ), String::New (notify->relname ));
541
- result->Set (NanSymbol (" payload" ), String::New (notify->extra ));
539
+ Local<Object> result = NanNew< Object> ();
540
+ result->Set (NanNew (" channel" ), NanNew (notify->relname ));
541
+ result->Set (NanNew (" payload" ), NanNew (notify->extra ));
542
542
Handle <Value> res = (Handle <Value>)result;
543
543
Emit (" notification" , &res);
544
544
PQfreemem (notify);
@@ -585,19 +585,19 @@ class Connection : public ObjectWrap {
585
585
void EmitRowDescription (const PGresult* result)
586
586
{
587
587
NanScope ();
588
- Local<Array> row = Array::New ();
588
+ Local<Array> row = NanNew< Array> ();
589
589
int fieldCount = PQnfields (result);
590
590
for (int fieldNumber = 0 ; fieldNumber < fieldCount; fieldNumber++) {
591
- Local<Object> field = Object::New ();
591
+ Local<Object> field = NanNew< Object> ();
592
592
// name of field
593
593
char * fieldName = PQfname (result, fieldNumber);
594
- field->Set (NanSymbol (" name" ), String::New (fieldName));
594
+ field->Set (NanNew (" name" ), NanNew (fieldName));
595
595
596
596
// oid of type of field
597
597
int fieldType = PQftype (result, fieldNumber);
598
- field->Set (NanSymbol (" dataTypeID" ), Integer::New (fieldType));
598
+ field->Set (NanNew (" dataTypeID" ), NanNew (fieldType));
599
599
600
- row->Set (Integer::New (fieldNumber), field);
600
+ row->Set (NanNew (fieldNumber), field);
601
601
}
602
602
603
603
Handle <Value> e = (Handle <Value>)row;
@@ -658,9 +658,9 @@ class Connection : public ObjectWrap {
658
658
void EmitCommandMetaData (PGresult* result)
659
659
{
660
660
NanScope ();
661
- Local<Object> info = Object::New ();
662
- info->Set (NanSymbol (" command" ), String::New (PQcmdStatus (result)));
663
- info->Set (NanSymbol (" value" ), String::New (PQcmdTuples (result)));
661
+ Local<Object> info = NanNew< Object> ();
662
+ info->Set (NanNew (" command" ), NanNew (PQcmdStatus (result)));
663
+ info->Set (NanNew (" value" ), NanNew (PQcmdTuples (result)));
664
664
Handle <Value> e = (Handle <Value>)info;
665
665
Emit (" _cmdStatus" , &e);
666
666
}
@@ -675,16 +675,16 @@ class Connection : public ObjectWrap {
675
675
int rowCount = PQntuples (result);
676
676
for (int rowNumber = 0 ; rowNumber < rowCount; rowNumber++) {
677
677
// create result object for this row
678
- Local<Array> row = Array::New ();
678
+ Local<Array> row = NanNew< Array> ();
679
679
int fieldCount = PQnfields (result);
680
680
for (int fieldNumber = 0 ; fieldNumber < fieldCount; fieldNumber++) {
681
681
682
682
// value of field
683
683
if (PQgetisnull (result, rowNumber, fieldNumber)) {
684
- row->Set (Integer::New (fieldNumber), Null ());
684
+ row->Set (NanNew (fieldNumber), NanNull ());
685
685
} else {
686
686
char * fieldValue = PQgetvalue (result, rowNumber, fieldNumber);
687
- row->Set (Integer::New (fieldNumber), String::New (fieldValue));
687
+ row->Set (NanNew (fieldNumber), NanNew (fieldValue));
688
688
}
689
689
}
690
690
@@ -704,20 +704,20 @@ class Connection : public ObjectWrap {
704
704
// read-loop callback
705
705
return ;
706
706
}
707
- Local<Object> msg = Local<Object>::Cast (Exception::Error ( String::New ( errorMessage) ));
707
+ Local<Object> msg = Local<Object>::Cast (NanError ( errorMessage));
708
708
TRACE (" AttachErrorFields" );
709
709
// add the other information returned by Postgres to the error object
710
- AttachErrorField (result, msg, NanSymbol (" severity" ), PG_DIAG_SEVERITY);
711
- AttachErrorField (result, msg, NanSymbol (" code" ), PG_DIAG_SQLSTATE);
712
- AttachErrorField (result, msg, NanSymbol (" detail" ), PG_DIAG_MESSAGE_DETAIL);
713
- AttachErrorField (result, msg, NanSymbol (" hint" ), PG_DIAG_MESSAGE_HINT);
714
- AttachErrorField (result, msg, NanSymbol (" position" ), PG_DIAG_STATEMENT_POSITION);
715
- AttachErrorField (result, msg, NanSymbol (" internalPosition" ), PG_DIAG_INTERNAL_POSITION);
716
- AttachErrorField (result, msg, NanSymbol (" internalQuery" ), PG_DIAG_INTERNAL_QUERY);
717
- AttachErrorField (result, msg, NanSymbol (" where" ), PG_DIAG_CONTEXT);
718
- AttachErrorField (result, msg, NanSymbol (" file" ), PG_DIAG_SOURCE_FILE);
719
- AttachErrorField (result, msg, NanSymbol (" line" ), PG_DIAG_SOURCE_LINE);
720
- AttachErrorField (result, msg, NanSymbol (" routine" ), PG_DIAG_SOURCE_FUNCTION);
710
+ AttachErrorField (result, msg, NanNew (" severity" ), PG_DIAG_SEVERITY);
711
+ AttachErrorField (result, msg, NanNew (" code" ), PG_DIAG_SQLSTATE);
712
+ AttachErrorField (result, msg, NanNew (" detail" ), PG_DIAG_MESSAGE_DETAIL);
713
+ AttachErrorField (result, msg, NanNew (" hint" ), PG_DIAG_MESSAGE_HINT);
714
+ AttachErrorField (result, msg, NanNew (" position" ), PG_DIAG_STATEMENT_POSITION);
715
+ AttachErrorField (result, msg, NanNew (" internalPosition" ), PG_DIAG_INTERNAL_POSITION);
716
+ AttachErrorField (result, msg, NanNew (" internalQuery" ), PG_DIAG_INTERNAL_QUERY);
717
+ AttachErrorField (result, msg, NanNew (" where" ), PG_DIAG_CONTEXT);
718
+ AttachErrorField (result, msg, NanNew (" file" ), PG_DIAG_SOURCE_FILE);
719
+ AttachErrorField (result, msg, NanNew (" line" ), PG_DIAG_SOURCE_LINE);
720
+ AttachErrorField (result, msg, NanNew (" routine" ), PG_DIAG_SOURCE_FUNCTION);
721
721
Handle <Value> m = msg;
722
722
TRACE (" EmitError" );
723
723
Emit (" _error" , &m);
@@ -728,7 +728,7 @@ class Connection : public ObjectWrap {
728
728
NanScope ();
729
729
char *val = PQresultErrorField (result, fieldcode);
730
730
if (val) {
731
- msg->Set (symbol, String::New (val));
731
+ msg->Set (symbol, NanNew (val));
732
732
}
733
733
}
734
734
@@ -746,20 +746,20 @@ class Connection : public ObjectWrap {
746
746
// EventEmitter was removed from c++ in node v0.5.x
747
747
void Emit (const char * message) {
748
748
NanScope ();
749
- Handle <Value> args[1 ] = { String::New (message) };
749
+ Handle <Value> args[1 ] = { NanNew (message) };
750
750
Emit (1 , args);
751
751
}
752
752
753
753
void Emit (const char * message, Handle <Value>* arg) {
754
754
NanScope ();
755
- Handle <Value> args[2 ] = { String::New (message), *arg };
755
+ Handle <Value> args[2 ] = { NanNew (message), *arg };
756
756
Emit (2 , args);
757
757
}
758
758
759
759
void Emit (int length, Handle <Value> *args) {
760
760
NanScope ();
761
761
762
- Local<Value> emit_v = NanObjectWrapHandle (this )->Get (NanSymbol (" emit" ));
762
+ Local<Value> emit_v = NanObjectWrapHandle (this )->Get (NanNew (" emit" ));
763
763
assert (emit_v->IsFunction ());
764
764
Local<Function> emit_f = emit_v.As <Function>();
765
765
@@ -802,7 +802,7 @@ class Connection : public ObjectWrap {
802
802
void EmitError (const char *message)
803
803
{
804
804
NanScope ();
805
- Local<Value> exception = Exception::Error ( String::New ( message) );
805
+ Local<Value> exception = NanError ( message);
806
806
Emit (" _error" , &exception );
807
807
}
808
808
0 commit comments