update embedding interfaces again to use filling_drop feature

...and remove trailing whitespaces
This commit is contained in:
Mike Blumenkrantz 2015-05-06 12:27:58 -04:00
parent efb2b37185
commit 745e3bd49f
57 changed files with 2797 additions and 1550 deletions

View file

@ -43,6 +43,7 @@ use wrappers::CefWrap;
use libc;
use std::collections::HashMap;
use std::mem;
use std::ptr;
//
@ -108,13 +109,13 @@ pub struct _cef_load_handler_t {
//
// The reference count. This will only be present for Rust instances!
//
pub ref_count: usize,
pub ref_count: u32,
//
// Extra data. This will only be present for Rust instances!
//
pub extra: u8,
}
}
pub type cef_load_handler_t = _cef_load_handler_t;
@ -131,7 +132,8 @@ pub struct CefLoadHandler {
impl Clone for CefLoadHandler {
fn clone(&self) -> CefLoadHandler{
unsafe {
if !self.c_object.is_null() {
if !self.c_object.is_null() &&
self.c_object as usize != mem::POST_DROP_USIZE {
((*self.c_object).base.add_ref.unwrap())(&mut (*self.c_object).base);
}
CefLoadHandler {
@ -144,7 +146,8 @@ impl Clone for CefLoadHandler {
impl Drop for CefLoadHandler {
fn drop(&mut self) {
unsafe {
if !self.c_object.is_null() {
if !self.c_object.is_null() &&
self.c_object as usize != mem::POST_DROP_USIZE {
((*self.c_object).base.release.unwrap())(&mut (*self.c_object).base);
}
}
@ -159,7 +162,8 @@ impl CefLoadHandler {
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_load_handler_t) -> CefLoadHandler {
if !c_object.is_null() {
if !c_object.is_null() &&
c_object as usize != mem::POST_DROP_USIZE {
((*c_object).base.add_ref.unwrap())(&mut (*c_object).base);
}
CefLoadHandler {
@ -173,7 +177,8 @@ impl CefLoadHandler {
pub fn c_object_addrefed(&self) -> *mut cef_load_handler_t {
unsafe {
if !self.c_object.is_null() {
if !self.c_object.is_null() &&
self.c_object as usize != mem::POST_DROP_USIZE {
eutil::add_ref(self.c_object as *mut types::cef_base_t);
}
self.c_object
@ -181,10 +186,10 @@ impl CefLoadHandler {
}
pub fn is_null_cef_object(&self) -> bool {
self.c_object.is_null()
self.c_object.is_null() || self.c_object as usize == mem::POST_DROP_USIZE
}
pub fn is_not_null_cef_object(&self) -> bool {
!self.c_object.is_null()
!self.c_object.is_null() && self.c_object as usize != mem::POST_DROP_USIZE
}
//
@ -196,7 +201,8 @@ impl CefLoadHandler {
pub fn on_loading_state_change(&self, browser: interfaces::CefBrowser,
isLoading: libc::c_int, canGoBack: libc::c_int,
canGoForward: libc::c_int) -> () {
if self.c_object.is_null() {
if self.c_object.is_null() ||
self.c_object as usize == mem::POST_DROP_USIZE {
panic!("called a CEF method on a null object")
}
unsafe {
@ -221,7 +227,8 @@ impl CefLoadHandler {
//
pub fn on_load_start(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame) -> () {
if self.c_object.is_null() {
if self.c_object.is_null() ||
self.c_object as usize == mem::POST_DROP_USIZE {
panic!("called a CEF method on a null object")
}
unsafe {
@ -243,7 +250,8 @@ impl CefLoadHandler {
//
pub fn on_load_end(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, httpStatusCode: libc::c_int) -> () {
if self.c_object.is_null() {
if self.c_object.is_null() ||
self.c_object as usize == mem::POST_DROP_USIZE {
panic!("called a CEF method on a null object")
}
unsafe {
@ -265,7 +273,8 @@ impl CefLoadHandler {
pub fn on_load_error(&self, browser: interfaces::CefBrowser,
frame: interfaces::CefFrame, errorCode: types::cef_errorcode_t,
errorText: &[u16], failedUrl: &[u16]) -> () {
if self.c_object.is_null() {
if self.c_object.is_null() ||
self.c_object as usize == mem::POST_DROP_USIZE {
panic!("called a CEF method on a null object")
}
unsafe {
@ -297,7 +306,8 @@ impl CefWrap<*mut cef_load_handler_t> for Option<CefLoadHandler> {
}
}
unsafe fn to_rust(c_object: *mut cef_load_handler_t) -> Option<CefLoadHandler> {
if c_object.is_null() {
if c_object.is_null() &&
c_object as usize != mem::POST_DROP_USIZE {
None
} else {
Some(CefLoadHandler::from_c_object_addref(c_object))