Skip to content

Commit 826c5ad

Browse files
committed
Work on fixing build
1 parent e778348 commit 826c5ad

File tree

1 file changed

+19
-55
lines changed

1 file changed

+19
-55
lines changed

src/binding.cc

Lines changed: 19 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,6 @@
1818
using namespace v8;
1919
using namespace node;
2020

21-
static Persistent<String> severity_symbol;
22-
static Persistent<String> code_symbol;
23-
static Persistent<String> detail_symbol;
24-
static Persistent<String> hint_symbol;
25-
static Persistent<String> position_symbol;
26-
static Persistent<String> internalPosition_symbol;
27-
static Persistent<String> internalQuery_symbol;
28-
static Persistent<String> where_symbol;
29-
static Persistent<String> file_symbol;
30-
static Persistent<String> line_symbol;
31-
static Persistent<String> routine_symbol;
32-
static Persistent<String> name_symbol;
33-
static Persistent<String> value_symbol;
34-
static Persistent<String> type_symbol;
35-
static Persistent<String> channel_symbol;
36-
static Persistent<String> payload_symbol;
37-
static Persistent<String> emit_symbol;
38-
static Persistent<String> command_symbol;
3921

4022
class Connection : public ObjectWrap {
4123

@@ -51,24 +33,6 @@ class Connection : public ObjectWrap {
5133
t->InstanceTemplate()->SetInternalFieldCount(1);
5234
t->SetClassName(String::NewSymbol("Connection"));
5335

54-
emit_symbol = NODE_PSYMBOL("emit");
55-
severity_symbol = NODE_PSYMBOL("severity");
56-
code_symbol = NODE_PSYMBOL("code");
57-
detail_symbol = NODE_PSYMBOL("detail");
58-
hint_symbol = NODE_PSYMBOL("hint");
59-
position_symbol = NODE_PSYMBOL("position");
60-
internalPosition_symbol = NODE_PSYMBOL("internalPosition");
61-
internalQuery_symbol = NODE_PSYMBOL("internalQuery");
62-
where_symbol = NODE_PSYMBOL("where");
63-
file_symbol = NODE_PSYMBOL("file");
64-
line_symbol = NODE_PSYMBOL("line");
65-
routine_symbol = NODE_PSYMBOL("routine");
66-
name_symbol = NODE_PSYMBOL("name");
67-
value_symbol = NODE_PSYMBOL("value");
68-
type_symbol = NODE_PSYMBOL("dataTypeID");
69-
channel_symbol = NODE_PSYMBOL("channel");
70-
payload_symbol = NODE_PSYMBOL("payload");
71-
command_symbol = NODE_PSYMBOL("command");
7236

7337
NODE_SET_PROTOTYPE_METHOD(t, "connect", Connect);
7438
#ifdef ESCAPE_SUPPORTED
@@ -556,8 +520,8 @@ class Connection : public ObjectWrap {
556520
TRACE("PQnotifies");
557521
while ((notify = PQnotifies(connection_))) {
558522
Local<Object> result = Object::New();
559-
result->Set(channel_symbol, String::New(notify->relname));
560-
result->Set(payload_symbol, String::New(notify->extra));
523+
result->Set(String::New("channel"), String::New(notify->relname));
524+
result->Set(String::New("payload"), String::New(notify->extra));
561525
Handle<Value> res = (Handle<Value>)result;
562526
Emit("notification", &res);
563527
PQfreemem(notify);
@@ -612,11 +576,11 @@ class Connection : public ObjectWrap {
612576
Local<Object> field = Object::New();
613577
//name of field
614578
char* fieldName = PQfname(result, fieldNumber);
615-
field->Set(name_symbol, String::New(fieldName));
579+
field->Set(String::New("name"), String::New(fieldName));
616580

617581
//oid of type of field
618582
int fieldType = PQftype(result, fieldNumber);
619-
field->Set(type_symbol, Integer::New(fieldType));
583+
field->Set(String::New("dataTypeID"), Integer::New(fieldType));
620584

621585
row->Set(Integer::New(fieldNumber), field);
622586
}
@@ -677,8 +641,8 @@ class Connection : public ObjectWrap {
677641
{
678642
HandleScope scope;
679643
Local<Object> info = Object::New();
680-
info->Set(command_symbol, String::New(PQcmdStatus(result)));
681-
info->Set(value_symbol, String::New(PQcmdTuples(result)));
644+
info->Set(String::New("command"), String::New(PQcmdStatus(result)));
645+
info->Set(String::New("value"), String::New(PQcmdTuples(result)));
682646
Handle<Value> e = (Handle<Value>)info;
683647
Emit("_cmdStatus", &e);
684648
}
@@ -725,23 +689,23 @@ class Connection : public ObjectWrap {
725689
Local<Object> msg = Local<Object>::Cast(Exception::Error(String::New(errorMessage)));
726690
TRACE("AttachErrorFields");
727691
//add the other information returned by Postgres to the error object
728-
AttachErrorField(result, msg, severity_symbol, PG_DIAG_SEVERITY);
729-
AttachErrorField(result, msg, code_symbol, PG_DIAG_SQLSTATE);
730-
AttachErrorField(result, msg, detail_symbol, PG_DIAG_MESSAGE_DETAIL);
731-
AttachErrorField(result, msg, hint_symbol, PG_DIAG_MESSAGE_HINT);
732-
AttachErrorField(result, msg, position_symbol, PG_DIAG_STATEMENT_POSITION);
733-
AttachErrorField(result, msg, internalPosition_symbol, PG_DIAG_INTERNAL_POSITION);
734-
AttachErrorField(result, msg, internalQuery_symbol, PG_DIAG_INTERNAL_QUERY);
735-
AttachErrorField(result, msg, where_symbol, PG_DIAG_CONTEXT);
736-
AttachErrorField(result, msg, file_symbol, PG_DIAG_SOURCE_FILE);
737-
AttachErrorField(result, msg, line_symbol, PG_DIAG_SOURCE_LINE);
738-
AttachErrorField(result, msg, routine_symbol, PG_DIAG_SOURCE_FUNCTION);
692+
AttachErrorField(result, msg, String::New("severity"), PG_DIAG_SEVERITY);
693+
AttachErrorField(result, msg, String::New("code"), PG_DIAG_SQLSTATE);
694+
AttachErrorField(result, msg, String::New("detail"), PG_DIAG_MESSAGE_DETAIL);
695+
AttachErrorField(result, msg, String::New("hint"), PG_DIAG_MESSAGE_HINT);
696+
AttachErrorField(result, msg, String::New("position"), PG_DIAG_STATEMENT_POSITION);
697+
AttachErrorField(result, msg, String::New("internalPosition"), PG_DIAG_INTERNAL_POSITION);
698+
AttachErrorField(result, msg, String::New("internalQuery"), PG_DIAG_INTERNAL_QUERY);
699+
AttachErrorField(result, msg, String::New("where"), PG_DIAG_CONTEXT);
700+
AttachErrorField(result, msg, String::New("file"), PG_DIAG_SOURCE_FILE);
701+
AttachErrorField(result, msg, String::New("line"), PG_DIAG_SOURCE_LINE);
702+
AttachErrorField(result, msg, String::New("routine"), PG_DIAG_SOURCE_FUNCTION);
739703
Handle<Value> m = msg;
740704
TRACE("EmitError");
741705
Emit("_error", &m);
742706
}
743707

744-
void AttachErrorField(const PGresult *result, const Local<Object> msg, const Persistent<String> symbol, int fieldcode)
708+
void AttachErrorField(const PGresult *result, const Local<Object> msg, const Local<String> symbol, int fieldcode)
745709
{
746710
char *val = PQresultErrorField(result, fieldcode);
747711
if(val) {
@@ -776,7 +740,7 @@ class Connection : public ObjectWrap {
776740
void Emit(int length, Handle<Value> *args) {
777741
HandleScope scope;
778742

779-
Local<Value> emit_v = this->handle_->Get(emit_symbol);
743+
Local<Value> emit_v = this->handle_->Get(String::New("emit"));
780744
assert(emit_v->IsFunction());
781745
Local<Function> emit_f = emit_v.As<Function>();
782746

0 commit comments

Comments
 (0)