@@ -30,25 +30,25 @@ class Connection : public ObjectWrap {
3030 Init (Handle<Object> target)
3131 {
3232 NanScope ();
33- Local<FunctionTemplate> t = FunctionTemplate::New (New);
33+ Local<FunctionTemplate> t = NanNew< FunctionTemplate> (New);
3434
3535 t->InstanceTemplate ()->SetInternalFieldCount (1 );
36- t->SetClassName (NanSymbol (" Connection" ));
36+ t->SetClassName (NanNew (" Connection" ));
3737
38- NODE_SET_PROTOTYPE_METHOD (t, " connect" , Connect);
38+ NanSetPrototypeTemplate (t, " connect" , NanNew<FunctionTemplate>( Connect) );
3939#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) );
4242#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 ());
5252 TRACE (" created class" );
5353 }
5454
@@ -121,7 +121,7 @@ class Connection : public ObjectWrap {
121121 THROW (self->GetLastError ());
122122 }
123123
124- Local<Value> jsStr = String::New (escapedStr, strlen (escapedStr));
124+ Local<Value> jsStr = NanNew< String> (escapedStr, strlen (escapedStr));
125125 PQfreemem (escapedStr);
126126
127127 NanReturnValue (jsStr);
@@ -146,7 +146,7 @@ class Connection : public ObjectWrap {
146146 THROW (self->GetLastError ());
147147 }
148148
149- Local<Value> jsStr = String::New (escapedStr, strlen (escapedStr));
149+ Local<Value> jsStr = NanNew< String> (escapedStr, strlen (escapedStr));
150150 PQfreemem (escapedStr);
151151
152152 NanReturnValue (jsStr);
@@ -477,7 +477,7 @@ class Connection : public ObjectWrap {
477477 void HandleNotice (const char *message)
478478 {
479479 NanScope ();
480- Handle<Value> notice = String::New (message);
480+ Handle<Value> notice = NanNew< String> (message);
481481 Emit (" notice" , ¬ice);
482482 }
483483
@@ -536,9 +536,9 @@ class Connection : public ObjectWrap {
536536 PGnotify *notify;
537537 TRACE (" PQnotifies" );
538538 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 ));
542542 Handle<Value> res = (Handle<Value>)result;
543543 Emit (" notification" , &res);
544544 PQfreemem (notify);
@@ -585,19 +585,19 @@ class Connection : public ObjectWrap {
585585 void EmitRowDescription (const PGresult* result)
586586 {
587587 NanScope ();
588- Local<Array> row = Array::New ();
588+ Local<Array> row = NanNew< Array> ();
589589 int fieldCount = PQnfields (result);
590590 for (int fieldNumber = 0 ; fieldNumber < fieldCount; fieldNumber++) {
591- Local<Object> field = Object::New ();
591+ Local<Object> field = NanNew< Object> ();
592592 // name of field
593593 char * fieldName = PQfname (result, fieldNumber);
594- field->Set (NanSymbol (" name" ), String::New (fieldName));
594+ field->Set (NanNew (" name" ), NanNew (fieldName));
595595
596596 // oid of type of field
597597 int fieldType = PQftype (result, fieldNumber);
598- field->Set (NanSymbol (" dataTypeID" ), Integer::New (fieldType));
598+ field->Set (NanNew (" dataTypeID" ), NanNew (fieldType));
599599
600- row->Set (Integer::New (fieldNumber), field);
600+ row->Set (NanNew (fieldNumber), field);
601601 }
602602
603603 Handle<Value> e = (Handle<Value>)row;
@@ -658,9 +658,9 @@ class Connection : public ObjectWrap {
658658 void EmitCommandMetaData (PGresult* result)
659659 {
660660 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)));
664664 Handle<Value> e = (Handle<Value>)info;
665665 Emit (" _cmdStatus" , &e);
666666 }
@@ -675,16 +675,16 @@ class Connection : public ObjectWrap {
675675 int rowCount = PQntuples (result);
676676 for (int rowNumber = 0 ; rowNumber < rowCount; rowNumber++) {
677677 // create result object for this row
678- Local<Array> row = Array::New ();
678+ Local<Array> row = NanNew< Array> ();
679679 int fieldCount = PQnfields (result);
680680 for (int fieldNumber = 0 ; fieldNumber < fieldCount; fieldNumber++) {
681681
682682 // value of field
683683 if (PQgetisnull (result, rowNumber, fieldNumber)) {
684- row->Set (Integer::New (fieldNumber), Null ());
684+ row->Set (NanNew (fieldNumber), NanNull ());
685685 } else {
686686 char * fieldValue = PQgetvalue (result, rowNumber, fieldNumber);
687- row->Set (Integer::New (fieldNumber), String::New (fieldValue));
687+ row->Set (NanNew (fieldNumber), NanNew (fieldValue));
688688 }
689689 }
690690
@@ -704,20 +704,20 @@ class Connection : public ObjectWrap {
704704 // read-loop callback
705705 return ;
706706 }
707- Local<Object> msg = Local<Object>::Cast (Exception::Error ( String::New ( errorMessage) ));
707+ Local<Object> msg = Local<Object>::Cast (NanError ( errorMessage));
708708 TRACE (" AttachErrorFields" );
709709 // 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);
721721 Handle<Value> m = msg;
722722 TRACE (" EmitError" );
723723 Emit (" _error" , &m);
@@ -728,7 +728,7 @@ class Connection : public ObjectWrap {
728728 NanScope ();
729729 char *val = PQresultErrorField (result, fieldcode);
730730 if (val) {
731- msg->Set (symbol, String::New (val));
731+ msg->Set (symbol, NanNew (val));
732732 }
733733 }
734734
@@ -746,20 +746,20 @@ class Connection : public ObjectWrap {
746746 // EventEmitter was removed from c++ in node v0.5.x
747747 void Emit (const char * message) {
748748 NanScope ();
749- Handle<Value> args[1 ] = { String::New (message) };
749+ Handle<Value> args[1 ] = { NanNew (message) };
750750 Emit (1 , args);
751751 }
752752
753753 void Emit (const char * message, Handle<Value>* arg) {
754754 NanScope ();
755- Handle<Value> args[2 ] = { String::New (message), *arg };
755+ Handle<Value> args[2 ] = { NanNew (message), *arg };
756756 Emit (2 , args);
757757 }
758758
759759 void Emit (int length, Handle<Value> *args) {
760760 NanScope ();
761761
762- Local<Value> emit_v = NanObjectWrapHandle (this )->Get (NanSymbol (" emit" ));
762+ Local<Value> emit_v = NanObjectWrapHandle (this )->Get (NanNew (" emit" ));
763763 assert (emit_v->IsFunction ());
764764 Local<Function> emit_f = emit_v.As <Function>();
765765
@@ -802,7 +802,7 @@ class Connection : public ObjectWrap {
802802 void EmitError (const char *message)
803803 {
804804 NanScope ();
805- Local<Value> exception = Exception::Error ( String::New ( message) );
805+ Local<Value> exception = NanError ( message);
806806 Emit (" _error" , &exception);
807807 }
808808
0 commit comments