Skip to content

build with node 0.5.5 error #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tojocky opened this issue Sep 5, 2011 · 5 comments
Closed

build with node 0.5.5 error #39

tojocky opened this issue Sep 5, 2011 · 5 comments

Comments

@tojocky
Copy link

tojocky commented Sep 5, 2011

Hello,

When I tried to compile sqlite3 module with node 0.5.5 i get error around eio_custom.
I resolved this by change return type of calback in database and statement files (h and cc).

The problem remain when i try to use the compiled module.

found steps which should be done.
https://groups.google.com/group/nodejs/browse_thread/thread/ae6bc0e37e2edc39

Who will done this?
I can do this and test.
Please keep me about this.
It is important to have sqlite3 module in the latest node.

@kkaefer
Copy link
Contributor

kkaefer commented Sep 5, 2011

node 0.5 is still in beta and changing rapidly. I'll update node-sqlite3 once a 0.6 release is on the horizon. (Odd node versions are unstable/beta). However, I highly encourage you to update the library yourself before that, and send a pull request, if you want to use it with node 0.5.x.

@tojocky
Copy link
Author

tojocky commented Sep 6, 2011

OK, I'll do.

@tojocky
Copy link
Author

tojocky commented Sep 6, 2011

OK, here is a patch:
but seems something is wrong :(. it build correctly, load library correctly, but in test get error.


--- /tmp/rabbitvcs-1-4e181-database.cc
+++ /tmp/rabbitvcs-2-0e92a-database.cc
@@ -1,7 +1,7 @@
 #include <string.h>
 #include <v8.h>
 #include <node.h>
-#include <node_events.h>
+#include <node_object_wrap.h>

 #include "macros.h"
 #include "database.h"
@@ -17,7 +17,6 @@
     Local<FunctionTemplate> t = FunctionTemplate::New(New);

     constructor_template = Persistent<FunctionTemplate>::New(t);
-    constructor_template->Inherit(EventEmitter::constructor_template);
     constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
     constructor_template->SetClassName(String::NewSymbol("Database"));

@@ -141,7 +140,7 @@
     eio_custom(EIO_Open, EIO_PRI_DEFAULT, EIO_AfterOpen, baton);
 }

-int Database::EIO_Open(eio_req *req) {
+void Database::EIO_Open(eio_req *req) {
     OpenBaton* baton = static_cast<OpenBaton*>(req->data);
     Database* db = baton->db;

@@ -161,8 +160,6 @@
         // Set default database handle values.
         sqlite3_busy_timeout(db->handle, 1000);
     }
-
-    return 0;
 }

 int Database::EIO_AfterOpen(eio_req *req) {
@@ -225,7 +222,7 @@
     eio_custom(EIO_Close, EIO_PRI_DEFAULT, EIO_AfterClose, baton);
 }

-int Database::EIO_Close(eio_req *req) {
+void Database::EIO_Close(eio_req *req) {
     Baton* baton = static_cast<Baton*>(req->data);
     Database* db = baton->db;

@@ -237,7 +234,6 @@
     else {
         db->handle = NULL;
     }
-    return 0;
 }

 int Database::EIO_AfterClose(eio_req *req) {
@@ -504,7 +500,7 @@
     eio_custom(EIO_Exec, EIO_PRI_DEFAULT, EIO_AfterExec, baton);
 }

-int Database::EIO_Exec(eio_req *req) {
+void Database::EIO_Exec(eio_req *req) {
     ExecBaton* baton = static_cast<ExecBaton*>(req->data);

     char* message = NULL;
@@ -520,8 +516,6 @@
         baton->message = std::string(message);
         sqlite3_free(message);
     }
-
-    return 0;
 }

 int Database::EIO_AfterExec(eio_req *req) {
@@ -574,7 +568,7 @@
     eio_custom(EIO_LoadExtension, EIO_PRI_DEFAULT, EIO_AfterLoadExtension, baton);
 }

-int Database::EIO_LoadExtension(eio_req *req) {
+void Database::EIO_LoadExtension(eio_req *req) {
     LoadExtensionBaton* baton = static_cast<LoadExtensionBaton*>(req->data);

     sqlite3_enable_load_extension(baton->db->handle, 1);
@@ -593,8 +587,6 @@
         baton->message = std::string(message);
         sqlite3_free(message);
     }
-
-    return 0;
 }

 int Database::EIO_AfterLoadExtension(eio_req *req) {
@@ -673,13 +665,11 @@
     }
 }

-int Database::EIO_Destruct(eio_req *req) {
+void Database::EIO_Destruct(eio_req *req) {
     Database* db = static_cast<Database*>(req->data);

     sqlite3_close(db->handle);
     db->handle = NULL;
-
-    return 0;
 }

 int Database::EIO_AfterDestruct(eio_req *req) {

--- /tmp/rabbitvcs-1-4e181-database.h
+++ /tmp/rabbitvcs-2-0e92a-database.h
@@ -3,7 +3,7 @@

 #include <v8.h>
 #include <node.h>
-#include <node_events.h>
+#include <node_object_wrap.h>

 #include <string>
 #include <queue>
@@ -19,7 +19,7 @@
 class Database;


-class Database : public EventEmitter {
+class Database : public ObjectWrap {
 public:
     static Persistent<FunctionTemplate> constructor_template;
     static void Init(Handle<Object> target);
@@ -100,7 +100,7 @@
     friend class Statement;

 protected:
-    Database() : EventEmitter(),
+    Database() : ObjectWrap(),
         handle(NULL),
         open(false),
         locked(false),
@@ -121,7 +121,7 @@

     static Handle<Value> New(const Arguments& args);
     static void EIO_BeginOpen(Baton* baton);
-    static int EIO_Open(eio_req *req);
+    static void EIO_Open(eio_req *req);
     static int EIO_AfterOpen(eio_req *req);

     static Handle<Value> OpenGetter(Local<String> str, const AccessorInfo& accessor);
@@ -131,17 +131,17 @@

     static Handle<Value> Exec(const Arguments& args);
     static void EIO_BeginExec(Baton* baton);
-    static int EIO_Exec(eio_req *req);
+    static void EIO_Exec(eio_req *req);
     static int EIO_AfterExec(eio_req *req);

     static Handle<Value> Close(const Arguments& args);
     static void EIO_BeginClose(Baton* baton);
-    static int EIO_Close(eio_req *req);
+    static void EIO_Close(eio_req *req);
     static int EIO_AfterClose(eio_req *req);

     static Handle<Value> LoadExtension(const Arguments& args);
     static void EIO_BeginLoadExtension(Baton* baton);
-    static int EIO_LoadExtension(eio_req *req);
+    static void EIO_LoadExtension(eio_req *req);
     static int EIO_AfterLoadExtension(eio_req *req);

     static Handle<Value> Serialize(const Arguments& args);
@@ -168,7 +168,7 @@
     inline void MakeWeak();
     virtual void Unref();
     static void Destruct (Persistent<Value> value, void *data);
-    static int EIO_Destruct(eio_req *req);
+    static void EIO_Destruct(eio_req *req);
     static int EIO_AfterDestruct(eio_req *req);

 protected:
--- /tmp/rabbitvcs-1-4e181-macros.h
+++ /tmp/rabbitvcs-2-0e92a-macros.h
@@ -109,10 +109,14 @@


 #define EMIT_EVENT(obj, argc, argv)                                            \
-    TRY_CATCH_CALL((obj),                                                      \
-        Local<Function>::Cast((obj)->Get(String::NewSymbol("emit"))),          \
-        argc, argv                                                             \
-    );
+   Local<Value> emit_v = obj->Get(NODE_PSYMBOL("emit"));          \
+    if (emit_v->IsFunction()){                                            \
+       Local<Function> emit = Local<Function>::Cast(emit_v);          \         
+       TRY_CATCH_CALL((obj),                                          \
+           emit,                              \
+           argc, argv                                             \
+           );                                 \
+   };

 #define TRY_CATCH_CALL(context, callback, argc, argv)                          \
 {   TryCatch try_catch;                                                        \
@@ -124,7 +128,7 @@
 #define EIO_DEFINITION(name)                                                   \
     static Handle<Value> name(const Arguments& args);                          \
     static void EIO_Begin##name(Baton* baton);                                 \
-    static int EIO_##name(eio_req *req);                                       \
+    static void EIO_##name(eio_req *req);                                       \
     static int EIO_After##name(eio_req *req);

 #define STATEMENT_BEGIN(type)                                                  \
--- /tmp/rabbitvcs-1-4e181-sqlite3.cc
+++ /tmp/rabbitvcs-2-0e92a-sqlite3.cc
@@ -1,6 +1,6 @@
 #include <v8.h>
 #include <node.h>
-#include <node_events.h>
+#include <node_object_wrap.h>

 #include <sqlite3.h>

--- /tmp/rabbitvcs-1-4e181-statement.cc
+++ /tmp/rabbitvcs-2-0e92a-statement.cc
@@ -1,7 +1,7 @@
 #include <string.h>
 #include <v8.h>
 #include <node.h>
-#include <node_events.h>
+#include <node_object_wrap.h>
 #include <node_buffer.h>
 #include <node_version.h>

@@ -19,7 +19,6 @@
     Local<FunctionTemplate> t = FunctionTemplate::New(New);

     constructor_template = Persistent<FunctionTemplate>::New(t);
-    constructor_template->Inherit(EventEmitter::constructor_template);
     constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
     constructor_template->SetClassName(String::NewSymbol("Statement"));

@@ -118,7 +117,7 @@
     eio_custom(EIO_Prepare, EIO_PRI_DEFAULT, EIO_AfterPrepare, baton);
 }

-int Statement::EIO_Prepare(eio_req *req) {
+void Statement::EIO_Prepare(eio_req *req) {
     STATEMENT_INIT(PrepareBaton);

     // In case preparing fails, we use a mutex to make sure we get the associated
@@ -140,8 +139,6 @@
     }

     sqlite3_mutex_leave(mtx);
-
-    return 0;
 }

 int Statement::EIO_AfterPrepare(eio_req *req) {
@@ -328,15 +325,13 @@
     STATEMENT_BEGIN(Bind);
 }

-int Statement::EIO_Bind(eio_req *req) {
+void Statement::EIO_Bind(eio_req *req) {
     STATEMENT_INIT(Baton);

     sqlite3_mutex* mtx = sqlite3_db_mutex(stmt->db->handle);
     sqlite3_mutex_enter(mtx);
     stmt->Bind(baton->parameters);
     sqlite3_mutex_leave(mtx);
-
-    return 0;
 }

 int Statement::EIO_AfterBind(eio_req *req) {
@@ -378,7 +373,7 @@
     STATEMENT_BEGIN(Get);
 }

-int Statement::EIO_Get(eio_req *req) {
+void Statement::EIO_Get(eio_req *req) {
     STATEMENT_INIT(RowBaton);

     if (stmt->status != SQLITE_DONE || baton->parameters.size()) {
@@ -400,8 +395,6 @@
             GetRow(&baton->row, stmt->handle);
         }
     }
-
-    return 0;
 }

 int Statement::EIO_AfterGet(eio_req *req) {
@@ -448,7 +441,7 @@
     STATEMENT_BEGIN(Run);
 }

-int Statement::EIO_Run(eio_req *req) {
+void Statement::EIO_Run(eio_req *req) {
     STATEMENT_INIT(RunBaton);

     sqlite3_mutex* mtx = sqlite3_db_mutex(stmt->db->handle);
@@ -472,8 +465,6 @@
     }

     sqlite3_mutex_leave(mtx);
-
-    return 0;
 }

 int Statement::EIO_AfterRun(eio_req *req) {
@@ -516,7 +507,7 @@
     STATEMENT_BEGIN(All);
 }

-int Statement::EIO_All(eio_req *req) {
+void Statement::EIO_All(eio_req *req) {
     STATEMENT_INIT(RowsBaton);

     sqlite3_mutex* mtx = sqlite3_db_mutex(stmt->db->handle);
@@ -540,8 +531,6 @@
     }

     sqlite3_mutex_leave(mtx);
-
-    return 0;
 }

 int Statement::EIO_AfterAll(eio_req *req) {
@@ -608,7 +597,7 @@
     STATEMENT_BEGIN(Each);
 }

-int Statement::EIO_Each(eio_req *req) {
+void Statement::EIO_Each(eio_req *req) {
     STATEMENT_INIT(EachBaton);

     Async* async = new Async(stmt, baton->callback, baton->completed, AsyncEach);
@@ -650,8 +639,6 @@

     async->completed = true;
     ev_async_send(EV_DEFAULT_ &async->watcher);
-
-    return 0;
 }

 void Statement::AsyncEach(EV_P_ ev_async *w, int revents) {
@@ -726,13 +713,11 @@
     STATEMENT_BEGIN(Reset);
 }

-int Statement::EIO_Reset(eio_req *req) {
+void Statement::EIO_Reset(eio_req *req) {
     STATEMENT_INIT(Baton);

     sqlite3_reset(stmt->handle);
     stmt->status = SQLITE_OK;
-
-    return 0;
 }

 int Statement::EIO_AfterReset(eio_req *req) {

--- /tmp/rabbitvcs-1-4e181-statement.h
+++ /tmp/rabbitvcs-2-0e92a-statement.h
@@ -3,7 +3,7 @@

 #include <v8.h>
 #include <node.h>
-#include <node_events.h>
+#include <node_object_wrap.h>

 #include "database.h"

@@ -72,7 +72,7 @@



-class Statement : public EventEmitter {
+class Statement : public ObjectWrap {
 public:
     static Persistent<FunctionTemplate> constructor_template;

@@ -183,7 +183,7 @@
         }
     };

-    Statement(Database* db_) : EventEmitter(),
+    Statement(Database* db_) : ObjectWrap(),
             db(db_),
             handle(NULL),
             status(SQLITE_OK),
@@ -199,7 +199,7 @@

 protected:
     static void EIO_BeginPrepare(Database::Baton* baton);
-    static int EIO_Prepare(eio_req *req);
+    static void EIO_Prepare(eio_req *req);
     static int EIO_AfterPrepare(eio_req *req);

     EIO_DEFINITION(Bind);

--- /tmp/rabbitvcs-1-4e181-wscript
+++ /tmp/rabbitvcs-2-0e92a-wscript
@@ -63,7 +63,7 @@

       os.chdir('deps')
       if not os.path.exists(BUNDLED_SQLITE3):
-          os.system('tar xvf %s' % BUNDLED_SQLITE3_TAR)
+          os.system('tar xvfz %s' % BUNDLED_SQLITE3_TAR)
       os.chdir(BUNDLED_SQLITE3)
       cxxflags = ''
       if os.environ.has_key('CFLAGS'):

@tojocky tojocky closed this as completed Sep 6, 2011
@tojocky tojocky reopened this Sep 6, 2011
@tojocky
Copy link
Author

tojocky commented Sep 6, 2011

Can anybody help me. I think I should update site3.js file too.

Open for any hint.

@springmeyer
Copy link
Contributor

closing this as dupe of #47 - since we're targeting node 0.6.x not 0.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants