mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-23 00:39:20 +08:00
Merge pull request #52 from jgallagher/gwenn-bindgen
Fix generated bindings
This commit is contained in:
commit
17cfbd9422
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,7 @@ extern crate libc;
|
|||||||
pub use self::bindgen::*;
|
pub use self::bindgen::*;
|
||||||
|
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use libc::{c_int, c_void};
|
use libc::c_int;
|
||||||
|
|
||||||
mod bindgen;
|
mod bindgen;
|
||||||
|
|
||||||
@ -48,10 +48,12 @@ pub const SQLITE_TEXT : c_int = 3;
|
|||||||
pub const SQLITE_BLOB : c_int = 4;
|
pub const SQLITE_BLOB : c_int = 4;
|
||||||
pub const SQLITE_NULL : c_int = 5;
|
pub const SQLITE_NULL : c_int = 5;
|
||||||
|
|
||||||
pub type SqliteDestructor = extern "C" fn(*mut c_void);
|
pub fn SQLITE_STATIC() -> sqlite3_destructor_type {
|
||||||
|
Some(unsafe { mem::transmute(0isize) })
|
||||||
|
}
|
||||||
|
|
||||||
pub fn SQLITE_TRANSIENT() -> SqliteDestructor {
|
pub fn SQLITE_TRANSIENT() -> sqlite3_destructor_type {
|
||||||
unsafe { mem::transmute(-1isize) }
|
Some(unsafe { mem::transmute(-1isize) })
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn code_to_str(code: c_int) -> &'static str {
|
pub fn code_to_str(code: c_int) -> &'static str {
|
||||||
|
@ -104,7 +104,7 @@ impl<'a> ToSql for &'a str {
|
|||||||
unsafe fn bind_parameter(&self, stmt: *mut sqlite3_stmt, col: c_int) -> c_int {
|
unsafe fn bind_parameter(&self, stmt: *mut sqlite3_stmt, col: c_int) -> c_int {
|
||||||
match str_to_cstring(self) {
|
match str_to_cstring(self) {
|
||||||
Ok(c_str) => ffi::sqlite3_bind_text(stmt, col, c_str.as_ptr(), -1,
|
Ok(c_str) => ffi::sqlite3_bind_text(stmt, col, c_str.as_ptr(), -1,
|
||||||
Some(ffi::SQLITE_TRANSIENT())),
|
ffi::SQLITE_TRANSIENT()),
|
||||||
Err(_) => ffi::SQLITE_MISUSE,
|
Err(_) => ffi::SQLITE_MISUSE,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,8 +119,7 @@ impl ToSql for String {
|
|||||||
impl<'a> ToSql for &'a [u8] {
|
impl<'a> ToSql for &'a [u8] {
|
||||||
unsafe fn bind_parameter(&self, stmt: *mut sqlite3_stmt, col: c_int) -> c_int {
|
unsafe fn bind_parameter(&self, stmt: *mut sqlite3_stmt, col: c_int) -> c_int {
|
||||||
ffi::sqlite3_bind_blob(
|
ffi::sqlite3_bind_blob(
|
||||||
stmt, col, mem::transmute(self.as_ptr()), self.len() as c_int,
|
stmt, col, mem::transmute(self.as_ptr()), self.len() as c_int, ffi::SQLITE_TRANSIENT())
|
||||||
Some(ffi::SQLITE_TRANSIENT()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user