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;
//
@ -91,13 +92,13 @@ pub struct _cef_process_message_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_process_message_t = _cef_process_message_t;
@ -112,7 +113,8 @@ pub struct CefProcessMessage {
impl Clone for CefProcessMessage {
fn clone(&self) -> CefProcessMessage{
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);
}
CefProcessMessage {
@ -125,7 +127,8 @@ impl Clone for CefProcessMessage {
impl Drop for CefProcessMessage {
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);
}
}
@ -140,7 +143,8 @@ impl CefProcessMessage {
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_process_message_t) -> CefProcessMessage {
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);
}
CefProcessMessage {
@ -154,7 +158,8 @@ impl CefProcessMessage {
pub fn c_object_addrefed(&self) -> *mut cef_process_message_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
@ -162,10 +167,10 @@ impl CefProcessMessage {
}
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
}
//
@ -173,7 +178,8 @@ impl CefProcessMessage {
// if this function returns false (0).
//
pub fn is_valid(&self) -> 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 {
@ -188,7 +194,8 @@ impl CefProcessMessage {
// expose read-only objects.
//
pub fn is_read_only(&self) -> 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 {
@ -202,7 +209,8 @@ impl CefProcessMessage {
// Returns a writable copy of this object.
//
pub fn copy(&self) -> interfaces::CefProcessMessage {
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 {
@ -217,7 +225,8 @@ impl CefProcessMessage {
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_name(&self) -> String {
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 {
@ -231,7 +240,8 @@ impl CefProcessMessage {
// Returns the list of arguments.
//
pub fn get_argument_list(&self) -> interfaces::CefListValue {
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 {
@ -269,7 +279,8 @@ impl CefWrap<*mut cef_process_message_t> for Option<CefProcessMessage> {
}
}
unsafe fn to_rust(c_object: *mut cef_process_message_t) -> Option<CefProcessMessage> {
if c_object.is_null() {
if c_object.is_null() &&
c_object as usize != mem::POST_DROP_USIZE {
None
} else {
Some(CefProcessMessage::from_c_object_addref(c_object))