Commit f89fa7e3 by Orlando Vazquez

Rename the Sqlite3Db class to Database, and move it to its own file

parent f7cb2ad2
...@@ -131,8 +131,8 @@ Ryan Dahl [ry@tinyclouds.org] ...@@ -131,8 +131,8 @@ Ryan Dahl [ry@tinyclouds.org]
THANKS THANKS
------ ------
Many thanks to Eric Fredricksen for his synchronous driver on which this was Many thanks to Eric Fredricksen for his synchronous driver on which this
based. driver was originally based.
* http://github.com/grumdrig/node-sqlite/ * http://github.com/grumdrig/node-sqlite/
* http://grumdrig.com/node-sqlite/ * http://grumdrig.com/node-sqlite/
...@@ -142,6 +142,4 @@ LICENSE ...@@ -142,6 +142,4 @@ LICENSE
node-sqlite is BSD licensed. node-sqlite is BSD licensed.
(c) 2010 Eric Fredricksen
(c) 2010 Orlando Vazquez (c) 2010 Orlando Vazquez
...@@ -58,12 +58,4 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -58,12 +58,4 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
return ThrowException(Exception::TypeError( \ return ThrowException(Exception::TypeError( \
String::New("Argument " #I " must be an integer"))); \ String::New("Argument " #I " must be an integer"))); \
} }
enum ExecMode
{
EXEC_EMPTY = 0,
EXEC_LAST_INSERT_ID = 1,
EXEC_AFFECTED_ROWS = 2
};
#endif #endif
...@@ -25,62 +25,61 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ...@@ -25,62 +25,61 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
using namespace v8; using namespace v8;
using namespace node; using namespace node;
class Statement : public EventEmitter { class Statement : public EventEmitter {
public: public:
static Persistent<FunctionTemplate> constructor_template; static Persistent<FunctionTemplate> constructor_template;
static void Init(v8::Handle<Object> target); static void Init(v8::Handle<Object> target);
static Handle<Value> New(const Arguments& args); static Handle<Value> New(const Arguments& args);
protected: protected:
Statement(sqlite3_stmt* stmt, int first_rc = -1) Statement(sqlite3_stmt* stmt, int first_rc = -1)
: EventEmitter(), first_rc_(first_rc), stmt_(stmt) { : EventEmitter(), first_rc_(first_rc), stmt_(stmt) {
column_count_ = -1; column_count_ = -1;
column_types_ = NULL; column_types_ = NULL;
column_names_ = NULL; column_names_ = NULL;
column_data_ = NULL; column_data_ = NULL;
} }
~Statement() { ~Statement() {
if (stmt_) sqlite3_finalize(stmt_); if (stmt_) sqlite3_finalize(stmt_);
if (column_types_) free(column_types_); if (column_types_) free(column_types_);
if (column_names_) free(column_names_); if (column_names_) free(column_names_);
if (column_data_) FreeColumnData(); if (column_data_) FreeColumnData();
} }
static int EIO_AfterBind(eio_req *req);
static int EIO_AfterBind(eio_req *req); static int EIO_Bind(eio_req *req);
static int EIO_Bind(eio_req *req); static Handle<Value> Bind(const Arguments& args);
static Handle<Value> Bind(const Arguments& args);
static int EIO_AfterFinalize(eio_req *req);
static int EIO_AfterFinalize(eio_req *req); static int EIO_Finalize(eio_req *req);
static int EIO_Finalize(eio_req *req); static Handle<Value> Finalize(const Arguments& args);
static Handle<Value> Finalize(const Arguments& args);
static Handle<Value> Reset(const Arguments& args);
static Handle<Value> Reset(const Arguments& args);
static int EIO_AfterStep(eio_req *req);
static int EIO_AfterStep(eio_req *req); static int EIO_Step(eio_req *req);
static int EIO_Step(eio_req *req); static Handle<Value> Step(const Arguments& args);
static Handle<Value> Step(const Arguments& args); void FreeColumnData(void);
void FreeColumnData(void);
bool HasCallback();
bool HasCallback(); void SetCallback(Local<Function> cb);
void SetCallback(Local<Function> cb);
Local<Function> GetCallback();
Local<Function> GetCallback();
private: private:
int column_count_;
int *column_types_; int column_count_;
char **column_names_; int *column_types_;
void **column_data_; char **column_names_;
bool error_; void **column_data_;
bool error_;
int first_rc_;
sqlite3_stmt* stmt_; int first_rc_;
sqlite3_stmt* stmt_;
}; };
// indicates the key type (integer index or name string) // indicates the key type (integer index or name string)
......
...@@ -24,7 +24,7 @@ def build(bld): ...@@ -24,7 +24,7 @@ def build(bld):
obj = bld.new_task_gen("cxx", "shlib", "node_addon") obj = bld.new_task_gen("cxx", "shlib", "node_addon")
obj.cxxflags = ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE", "-Wall"] obj.cxxflags = ["-g", "-D_FILE_OFFSET_BITS=64", "-D_LARGEFILE_SOURCE", "-Wall"]
obj.target = "sqlite3_bindings" obj.target = "sqlite3_bindings"
obj.source = "src/sqlite3_bindings.cc src/statement.cc" obj.source = "src/sqlite3_bindings.cc src/database.cc src/statement.cc"
obj.uselib = "SQLITE3 PROFILER" obj.uselib = "SQLITE3 PROFILER"
t = 'sqlite3_bindings.node' t = 'sqlite3_bindings.node'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment