Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sqlite3
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
node-sqlite3
Commits
cacde384
Commit
cacde384
authored
Mar 23, 2014
by
King Koopa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updates
parent
5174aaae
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
19 deletions
+19
-19
database.cc
src/database.cc
+7
-7
database.h
src/database.h
+1
-1
statement.cc
src/statement.cc
+11
-11
No files found.
src/database.cc
View file @
cacde384
...
@@ -42,7 +42,7 @@ void Database::Process() {
...
@@ -42,7 +42,7 @@ void Database::Process() {
// Call all callbacks with the error object.
// Call all callbacks with the error object.
while
(
!
queue
.
empty
())
{
while
(
!
queue
.
empty
())
{
Call
*
call
=
queue
.
front
();
Call
*
call
=
queue
.
front
();
Local
<
Function
>
cb
=
Nan
PersistentToLocal
(
call
->
baton
->
callback
);
Local
<
Function
>
cb
=
Nan
New
(
call
->
baton
->
callback
);
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
TRY_CATCH_CALL
(
NanObjectWrapHandle
(
this
),
cb
,
1
,
argv
);
TRY_CATCH_CALL
(
NanObjectWrapHandle
(
this
),
cb
,
1
,
argv
);
called
=
true
;
called
=
true
;
...
@@ -82,7 +82,7 @@ void Database::Process() {
...
@@ -82,7 +82,7 @@ void Database::Process() {
void
Database
::
Schedule
(
Work_Callback
callback
,
Baton
*
baton
,
bool
exclusive
)
{
void
Database
::
Schedule
(
Work_Callback
callback
,
Baton
*
baton
,
bool
exclusive
)
{
if
(
!
open
&&
locked
)
{
if
(
!
open
&&
locked
)
{
EXCEPTION
(
NanNew
<
String
>
(
"Database is closed"
),
SQLITE_MISUSE
,
exception
);
EXCEPTION
(
NanNew
<
String
>
(
"Database is closed"
),
SQLITE_MISUSE
,
exception
);
Local
<
Function
>
cb
=
Nan
PersistentToLocal
(
baton
->
callback
);
Local
<
Function
>
cb
=
Nan
New
(
baton
->
callback
);
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
Local
<
Value
>
argv
[]
=
{
exception
};
Local
<
Value
>
argv
[]
=
{
exception
};
TRY_CATCH_CALL
(
NanObjectWrapHandle
(
this
),
cb
,
1
,
argv
);
TRY_CATCH_CALL
(
NanObjectWrapHandle
(
this
),
cb
,
1
,
argv
);
...
@@ -181,7 +181,7 @@ void Database::Work_AfterOpen(uv_work_t* req) {
...
@@ -181,7 +181,7 @@ void Database::Work_AfterOpen(uv_work_t* req) {
argv
[
0
]
=
NanNew
(
NanNull
());
argv
[
0
]
=
NanNew
(
NanNull
());
}
}
Local
<
Function
>
cb
=
Nan
PersistentToLocal
(
baton
->
callback
);
Local
<
Function
>
cb
=
Nan
New
(
baton
->
callback
);
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
TRY_CATCH_CALL
(
NanObjectWrapHandle
(
db
),
cb
,
1
,
argv
);
TRY_CATCH_CALL
(
NanObjectWrapHandle
(
db
),
cb
,
1
,
argv
);
...
@@ -260,7 +260,7 @@ void Database::Work_AfterClose(uv_work_t* req) {
...
@@ -260,7 +260,7 @@ void Database::Work_AfterClose(uv_work_t* req) {
argv
[
0
]
=
NanNew
(
NanNull
());
argv
[
0
]
=
NanNew
(
NanNull
());
}
}
Local
<
Function
>
cb
=
Nan
PersistentToLocal
(
baton
->
callback
);
Local
<
Function
>
cb
=
Nan
New
(
baton
->
callback
);
// Fire callbacks.
// Fire callbacks.
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
...
@@ -531,7 +531,7 @@ void Database::Work_AfterExec(uv_work_t* req) {
...
@@ -531,7 +531,7 @@ void Database::Work_AfterExec(uv_work_t* req) {
ExecBaton
*
baton
=
static_cast
<
ExecBaton
*>
(
req
->
data
);
ExecBaton
*
baton
=
static_cast
<
ExecBaton
*>
(
req
->
data
);
Database
*
db
=
baton
->
db
;
Database
*
db
=
baton
->
db
;
Local
<
Function
>
cb
=
Nan
PersistentToLocal
(
baton
->
callback
);
Local
<
Function
>
cb
=
Nan
New
(
baton
->
callback
);
if
(
baton
->
status
!=
SQLITE_OK
)
{
if
(
baton
->
status
!=
SQLITE_OK
)
{
EXCEPTION
(
NanNew
<
String
>
(
baton
->
message
.
c_str
()),
baton
->
status
,
exception
);
EXCEPTION
(
NanNew
<
String
>
(
baton
->
message
.
c_str
()),
baton
->
status
,
exception
);
...
@@ -575,7 +575,7 @@ void Database::Work_Wait(Baton* baton) {
...
@@ -575,7 +575,7 @@ void Database::Work_Wait(Baton* baton) {
assert
(
baton
->
db
->
_handle
);
assert
(
baton
->
db
->
_handle
);
assert
(
baton
->
db
->
pending
==
0
);
assert
(
baton
->
db
->
pending
==
0
);
Local
<
Function
>
cb
=
Nan
PersistentToLocal
(
baton
->
callback
);
Local
<
Function
>
cb
=
Nan
New
(
baton
->
callback
);
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
Local
<
Value
>
argv
[]
=
{
NanNew
(
NanNull
())
};
Local
<
Value
>
argv
[]
=
{
NanNew
(
NanNull
())
};
TRY_CATCH_CALL
(
NanObjectWrapHandle
(
baton
->
db
),
cb
,
1
,
argv
);
TRY_CATCH_CALL
(
NanObjectWrapHandle
(
baton
->
db
),
cb
,
1
,
argv
);
...
@@ -634,7 +634,7 @@ void Database::Work_AfterLoadExtension(uv_work_t* req) {
...
@@ -634,7 +634,7 @@ void Database::Work_AfterLoadExtension(uv_work_t* req) {
NanScope
();
NanScope
();
LoadExtensionBaton
*
baton
=
static_cast
<
LoadExtensionBaton
*>
(
req
->
data
);
LoadExtensionBaton
*
baton
=
static_cast
<
LoadExtensionBaton
*>
(
req
->
data
);
Database
*
db
=
baton
->
db
;
Database
*
db
=
baton
->
db
;
Local
<
Function
>
cb
=
Nan
PersistentToLocal
(
baton
->
callback
);
Local
<
Function
>
cb
=
Nan
New
(
baton
->
callback
);
if
(
baton
->
status
!=
SQLITE_OK
)
{
if
(
baton
->
status
!=
SQLITE_OK
)
{
EXCEPTION
(
NanNew
<
String
>
(
baton
->
message
.
c_str
()),
baton
->
status
,
exception
);
EXCEPTION
(
NanNew
<
String
>
(
baton
->
message
.
c_str
()),
baton
->
status
,
exception
);
...
...
src/database.h
View file @
cacde384
...
@@ -26,7 +26,7 @@ public:
...
@@ -26,7 +26,7 @@ public:
static
inline
bool
HasInstance
(
Handle
<
Value
>
val
)
{
static
inline
bool
HasInstance
(
Handle
<
Value
>
val
)
{
if
(
!
val
->
IsObject
())
return
false
;
if
(
!
val
->
IsObject
())
return
false
;
Local
<
Object
>
obj
=
val
->
ToObject
();
Local
<
Object
>
obj
=
val
->
ToObject
();
return
Nan
PersistentToLocal
(
constructor_template
)
->
HasInstance
(
obj
);
return
Nan
New
(
constructor_template
)
->
HasInstance
(
obj
);
}
}
struct
Baton
{
struct
Baton
{
...
...
src/statement.cc
View file @
cacde384
...
@@ -65,7 +65,7 @@ template <class T> void Statement::Error(T* baton) {
...
@@ -65,7 +65,7 @@ template <class T> void Statement::Error(T* baton) {
assert
(
stmt
->
status
!=
0
);
assert
(
stmt
->
status
!=
0
);
EXCEPTION
(
NanNew
<
String
>
(
stmt
->
message
.
c_str
()),
stmt
->
status
,
exception
);
EXCEPTION
(
NanNew
<
String
>
(
stmt
->
message
.
c_str
()),
stmt
->
status
,
exception
);
Local
<
Function
>
cb
=
Nan
PersistentToLocal
(
baton
->
callback
);
Local
<
Function
>
cb
=
Nan
New
(
baton
->
callback
);
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
Local
<
Value
>
argv
[]
=
{
exception
};
Local
<
Value
>
argv
[]
=
{
exception
};
...
@@ -154,7 +154,7 @@ void Statement::Work_AfterPrepare(uv_work_t* req) {
...
@@ -154,7 +154,7 @@ void Statement::Work_AfterPrepare(uv_work_t* req) {
}
}
else
{
else
{
stmt
->
prepared
=
true
;
stmt
->
prepared
=
true
;
Local
<
Function
>
cb
=
Nan
PersistentToLocal
(
baton
->
callback
);
Local
<
Function
>
cb
=
Nan
New
(
baton
->
callback
);
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
Local
<
Value
>
argv
[]
=
{
NanNew
(
NanNull
())
};
Local
<
Value
>
argv
[]
=
{
NanNew
(
NanNull
())
};
TRY_CATCH_CALL
(
NanObjectWrapHandle
(
stmt
),
cb
,
1
,
argv
);
TRY_CATCH_CALL
(
NanObjectWrapHandle
(
stmt
),
cb
,
1
,
argv
);
...
@@ -338,7 +338,7 @@ void Statement::Work_AfterBind(uv_work_t* req) {
...
@@ -338,7 +338,7 @@ void Statement::Work_AfterBind(uv_work_t* req) {
}
}
else
{
else
{
// Fire callbacks.
// Fire callbacks.
Local
<
Function
>
cb
=
Nan
PersistentToLocal
(
baton
->
callback
);
Local
<
Function
>
cb
=
Nan
New
(
baton
->
callback
);
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
Local
<
Value
>
argv
[]
=
{
NanNew
(
NanNull
())
};
Local
<
Value
>
argv
[]
=
{
NanNew
(
NanNull
())
};
TRY_CATCH_CALL
(
NanObjectWrapHandle
(
stmt
),
cb
,
1
,
argv
);
TRY_CATCH_CALL
(
NanObjectWrapHandle
(
stmt
),
cb
,
1
,
argv
);
...
@@ -401,7 +401,7 @@ void Statement::Work_AfterGet(uv_work_t* req) {
...
@@ -401,7 +401,7 @@ void Statement::Work_AfterGet(uv_work_t* req) {
}
}
else
{
else
{
// Fire callbacks.
// Fire callbacks.
Local
<
Function
>
cb
=
Nan
PersistentToLocal
(
baton
->
callback
);
Local
<
Function
>
cb
=
Nan
New
(
baton
->
callback
);
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
if
(
stmt
->
status
==
SQLITE_ROW
)
{
if
(
stmt
->
status
==
SQLITE_ROW
)
{
// Create the result array from the data we acquired.
// Create the result array from the data we acquired.
...
@@ -471,7 +471,7 @@ void Statement::Work_AfterRun(uv_work_t* req) {
...
@@ -471,7 +471,7 @@ void Statement::Work_AfterRun(uv_work_t* req) {
}
}
else
{
else
{
// Fire callbacks.
// Fire callbacks.
Local
<
Function
>
cb
=
Nan
PersistentToLocal
(
baton
->
callback
);
Local
<
Function
>
cb
=
Nan
New
(
baton
->
callback
);
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
NanObjectWrapHandle
(
stmt
)
->
Set
(
NanSymbol
(
"lastID"
),
NanNew
<
Integer
>
(
baton
->
inserted_id
));
NanObjectWrapHandle
(
stmt
)
->
Set
(
NanSymbol
(
"lastID"
),
NanNew
<
Integer
>
(
baton
->
inserted_id
));
NanObjectWrapHandle
(
stmt
)
->
Set
(
NanSymbol
(
"changes"
),
NanNew
<
Integer
>
(
baton
->
changes
));
NanObjectWrapHandle
(
stmt
)
->
Set
(
NanSymbol
(
"changes"
),
NanNew
<
Integer
>
(
baton
->
changes
));
...
@@ -537,7 +537,7 @@ void Statement::Work_AfterAll(uv_work_t* req) {
...
@@ -537,7 +537,7 @@ void Statement::Work_AfterAll(uv_work_t* req) {
}
}
else
{
else
{
// Fire callbacks.
// Fire callbacks.
Local
<
Function
>
cb
=
Nan
PersistentToLocal
(
baton
->
callback
);
Local
<
Function
>
cb
=
Nan
New
(
baton
->
callback
);
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
if
(
baton
->
rows
.
size
())
{
if
(
baton
->
rows
.
size
())
{
// Create the result array from the data we acquired.
// Create the result array from the data we acquired.
...
@@ -664,7 +664,7 @@ void Statement::AsyncEach(uv_async_t* handle, int status) {
...
@@ -664,7 +664,7 @@ void Statement::AsyncEach(uv_async_t* handle, int status) {
break
;
break
;
}
}
Local
<
Function
>
cb
=
Nan
PersistentToLocal
(
async
->
item_cb
);
Local
<
Function
>
cb
=
Nan
New
(
async
->
item_cb
);
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
Local
<
Value
>
argv
[
2
];
Local
<
Value
>
argv
[
2
];
argv
[
0
]
=
NanNew
(
NanNull
());
argv
[
0
]
=
NanNew
(
NanNull
());
...
@@ -680,7 +680,7 @@ void Statement::AsyncEach(uv_async_t* handle, int status) {
...
@@ -680,7 +680,7 @@ void Statement::AsyncEach(uv_async_t* handle, int status) {
}
}
}
}
Local
<
Function
>
cb
=
Nan
PersistentToLocal
(
async
->
completed_cb
);
Local
<
Function
>
cb
=
Nan
New
(
async
->
completed_cb
);
if
(
async
->
completed
)
{
if
(
async
->
completed
)
{
if
(
!
cb
.
IsEmpty
()
&&
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
cb
->
IsFunction
())
{
...
@@ -733,7 +733,7 @@ void Statement::Work_AfterReset(uv_work_t* req) {
...
@@ -733,7 +733,7 @@ void Statement::Work_AfterReset(uv_work_t* req) {
STATEMENT_INIT
(
Baton
);
STATEMENT_INIT
(
Baton
);
// Fire callbacks.
// Fire callbacks.
Local
<
Function
>
cb
=
Nan
PersistentToLocal
(
baton
->
callback
);
Local
<
Function
>
cb
=
Nan
New
(
baton
->
callback
);
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
Local
<
Value
>
argv
[]
=
{
NanNew
(
NanNull
())
};
Local
<
Value
>
argv
[]
=
{
NanNew
(
NanNull
())
};
TRY_CATCH_CALL
(
NanObjectWrapHandle
(
stmt
),
cb
,
1
,
argv
);
TRY_CATCH_CALL
(
NanObjectWrapHandle
(
stmt
),
cb
,
1
,
argv
);
...
@@ -825,7 +825,7 @@ void Statement::Finalize(Baton* baton) {
...
@@ -825,7 +825,7 @@ void Statement::Finalize(Baton* baton) {
baton
->
stmt
->
Finalize
();
baton
->
stmt
->
Finalize
();
// Fire callback in case there was one.
// Fire callback in case there was one.
Local
<
Function
>
cb
=
Nan
PersistentToLocal
(
baton
->
callback
);
Local
<
Function
>
cb
=
Nan
New
(
baton
->
callback
);
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
if
(
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
TRY_CATCH_CALL
(
NanObjectWrapHandle
(
baton
->
stmt
),
cb
,
0
,
NULL
);
TRY_CATCH_CALL
(
NanObjectWrapHandle
(
baton
->
stmt
),
cb
,
0
,
NULL
);
}
}
...
@@ -857,7 +857,7 @@ void Statement::CleanQueue() {
...
@@ -857,7 +857,7 @@ void Statement::CleanQueue() {
Call
*
call
=
queue
.
front
();
Call
*
call
=
queue
.
front
();
queue
.
pop
();
queue
.
pop
();
Local
<
Function
>
cb
=
Nan
PersistentToLocal
(
call
->
baton
->
callback
);
Local
<
Function
>
cb
=
Nan
New
(
call
->
baton
->
callback
);
if
(
prepared
&&
!
cb
.
IsEmpty
()
&&
if
(
prepared
&&
!
cb
.
IsEmpty
()
&&
cb
->
IsFunction
())
{
cb
->
IsFunction
())
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment