mirror of
https://github.com/isar/rusqlite.git
synced 2024-11-27 03:51:38 +08:00
Merge pull request #100 from jgallagher/bindgen-update
Update bindings with bindgen 0.15.0/sqlite3 3.8.10
This commit is contained in:
commit
19abb53e97
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,5 @@
|
|||||||
|
// bindgen.rs was created with bindgen 0.15.0 against sqlite3 3.8.10
|
||||||
|
|
||||||
#![allow(non_snake_case)]
|
#![allow(non_snake_case)]
|
||||||
|
|
||||||
extern crate libc;
|
extern crate libc;
|
||||||
|
@ -407,13 +407,12 @@ impl InnerConnection {
|
|||||||
where F: FnMut(&Context) -> Result<T>,
|
where F: FnMut(&Context) -> Result<T>,
|
||||||
T: ToResult
|
T: ToResult
|
||||||
{
|
{
|
||||||
extern "C" fn call_boxed_closure<F, T>(ctx: *mut sqlite3_context,
|
unsafe extern "C" fn call_boxed_closure<F, T>(ctx: *mut sqlite3_context,
|
||||||
argc: c_int,
|
argc: c_int,
|
||||||
argv: *mut *mut sqlite3_value)
|
argv: *mut *mut sqlite3_value)
|
||||||
where F: FnMut(&Context) -> Result<T>,
|
where F: FnMut(&Context) -> Result<T>,
|
||||||
T: ToResult
|
T: ToResult
|
||||||
{
|
{
|
||||||
unsafe {
|
|
||||||
let ctx = Context {
|
let ctx = Context {
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
args: slice::from_raw_parts(argv, argc as usize),
|
args: slice::from_raw_parts(argv, argc as usize),
|
||||||
@ -430,7 +429,6 @@ impl InnerConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let boxed_f: *mut F = Box::into_raw(Box::new(x_func));
|
let boxed_f: *mut F = Box::into_raw(Box::new(x_func));
|
||||||
let c_name = try!(str_to_cstring(fn_name));
|
let c_name = try!(str_to_cstring(fn_name));
|
||||||
|
29
src/lib.rs
29
src/lib.rs
@ -70,7 +70,7 @@ use std::cell::{RefCell, Cell};
|
|||||||
use std::ffi::{CStr, CString};
|
use std::ffi::{CStr, CString};
|
||||||
use std::result;
|
use std::result;
|
||||||
use std::str;
|
use std::str;
|
||||||
use libc::{c_int, c_void, c_char};
|
use libc::{c_int, c_char};
|
||||||
|
|
||||||
use types::{ToSql, FromSql};
|
use types::{ToSql, FromSql};
|
||||||
|
|
||||||
@ -631,22 +631,6 @@ impl InnerConnection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn decode_result_with_errmsg(&self,
|
|
||||||
code: c_int,
|
|
||||||
errmsg: *mut c_char)
|
|
||||||
-> Result<()> {
|
|
||||||
if code == ffi::SQLITE_OK {
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
let message = errmsg_to_string(&*errmsg);
|
|
||||||
ffi::sqlite3_free(errmsg as *mut c_void);
|
|
||||||
Err(Error {
|
|
||||||
code: code,
|
|
||||||
message: message,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn close(&mut self) -> Result<()> {
|
fn close(&mut self) -> Result<()> {
|
||||||
unsafe {
|
unsafe {
|
||||||
let r = ffi::sqlite3_close(self.db());
|
let r = ffi::sqlite3_close(self.db());
|
||||||
@ -687,7 +671,16 @@ impl InnerConnection {
|
|||||||
} else {
|
} else {
|
||||||
ffi::sqlite3_load_extension(self.db, dylib_str.as_ptr(), ptr::null(), &mut errmsg)
|
ffi::sqlite3_load_extension(self.db, dylib_str.as_ptr(), ptr::null(), &mut errmsg)
|
||||||
};
|
};
|
||||||
self.decode_result_with_errmsg(r, errmsg)
|
if r == ffi::SQLITE_OK {
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
let message = errmsg_to_string(&*errmsg);
|
||||||
|
ffi::sqlite3_free(errmsg as *mut libc::c_void);
|
||||||
|
Err(Error {
|
||||||
|
code: r,
|
||||||
|
message: message,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
12
src/trace.rs
12
src/trace.rs
@ -67,9 +67,9 @@ impl Connection {
|
|||||||
/// There can only be a single tracer defined for each database connection.
|
/// There can only be a single tracer defined for each database connection.
|
||||||
/// Setting a new tracer clears the old one.
|
/// Setting a new tracer clears the old one.
|
||||||
pub fn trace(&mut self, trace_fn: Option<fn(&str)>) {
|
pub fn trace(&mut self, trace_fn: Option<fn(&str)>) {
|
||||||
extern "C" fn trace_callback(p_arg: *mut c_void, z_sql: *const c_char) {
|
unsafe extern "C" fn trace_callback(p_arg: *mut c_void, z_sql: *const c_char) {
|
||||||
let trace_fn: fn(&str) = unsafe { mem::transmute(p_arg) };
|
let trace_fn: fn(&str) = mem::transmute(p_arg);
|
||||||
let c_slice = unsafe { CStr::from_ptr(z_sql).to_bytes() };
|
let c_slice = CStr::from_ptr(z_sql).to_bytes();
|
||||||
if let Ok(s) = str::from_utf8(c_slice) {
|
if let Ok(s) = str::from_utf8(c_slice) {
|
||||||
trace_fn(s);
|
trace_fn(s);
|
||||||
}
|
}
|
||||||
@ -91,11 +91,11 @@ impl Connection {
|
|||||||
/// There can only be a single profiler defined for each database connection.
|
/// There can only be a single profiler defined for each database connection.
|
||||||
/// Setting a new profiler clears the old one.
|
/// Setting a new profiler clears the old one.
|
||||||
pub fn profile(&mut self, profile_fn: Option<fn(&str, Duration)>) {
|
pub fn profile(&mut self, profile_fn: Option<fn(&str, Duration)>) {
|
||||||
extern "C" fn profile_callback(p_arg: *mut c_void,
|
unsafe extern "C" fn profile_callback(p_arg: *mut c_void,
|
||||||
z_sql: *const c_char,
|
z_sql: *const c_char,
|
||||||
nanoseconds: u64) {
|
nanoseconds: u64) {
|
||||||
let profile_fn: fn(&str, Duration) = unsafe { mem::transmute(p_arg) };
|
let profile_fn: fn(&str, Duration) = mem::transmute(p_arg);
|
||||||
let c_slice = unsafe { CStr::from_ptr(z_sql).to_bytes() };
|
let c_slice = CStr::from_ptr(z_sql).to_bytes();
|
||||||
if let Ok(s) = str::from_utf8(c_slice) {
|
if let Ok(s) = str::from_utf8(c_slice) {
|
||||||
const NANOS_PER_SEC: u64 = 1_000_000_000;
|
const NANOS_PER_SEC: u64 = 1_000_000_000;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user