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;
//
@ -68,13 +69,13 @@ pub struct _cef_task_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_task_t = _cef_task_t;
@ -94,7 +95,8 @@ pub struct CefTask {
impl Clone for CefTask {
fn clone(&self) -> CefTask{
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);
}
CefTask {
@ -107,7 +109,8 @@ impl Clone for CefTask {
impl Drop for CefTask {
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);
}
}
@ -122,7 +125,8 @@ impl CefTask {
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_task_t) -> CefTask {
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);
}
CefTask {
@ -136,7 +140,8 @@ impl CefTask {
pub fn c_object_addrefed(&self) -> *mut cef_task_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
@ -144,17 +149,18 @@ impl CefTask {
}
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
}
//
// Method that will be executed on the target thread.
//
pub fn execute(&self) -> () {
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 {
@ -181,7 +187,8 @@ impl CefWrap<*mut cef_task_t> for Option<CefTask> {
}
}
unsafe fn to_rust(c_object: *mut cef_task_t) -> Option<CefTask> {
if c_object.is_null() {
if c_object.is_null() &&
c_object as usize != mem::POST_DROP_USIZE {
None
} else {
Some(CefTask::from_c_object_addref(c_object))
@ -244,13 +251,13 @@ pub struct _cef_task_runner_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_task_runner_t = _cef_task_runner_t;
@ -271,7 +278,8 @@ pub struct CefTaskRunner {
impl Clone for CefTaskRunner {
fn clone(&self) -> CefTaskRunner{
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);
}
CefTaskRunner {
@ -284,7 +292,8 @@ impl Clone for CefTaskRunner {
impl Drop for CefTaskRunner {
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);
}
}
@ -299,7 +308,8 @@ impl CefTaskRunner {
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_task_runner_t) -> CefTaskRunner {
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);
}
CefTaskRunner {
@ -313,7 +323,8 @@ impl CefTaskRunner {
pub fn c_object_addrefed(&self) -> *mut cef_task_runner_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
@ -321,10 +332,10 @@ impl CefTaskRunner {
}
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
}
//
@ -332,7 +343,8 @@ impl CefTaskRunner {
// |that| object.
//
pub fn is_same(&self, that: interfaces::CefTaskRunner) -> 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 {
@ -347,7 +359,8 @@ impl CefTaskRunner {
// Returns true (1) if this task runner belongs to the current thread.
//
pub fn belongs_to_current_thread(&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 {
@ -362,7 +375,8 @@ impl CefTaskRunner {
//
pub fn belongs_to_thread(&self,
threadId: types::cef_thread_id_t) -> 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 {
@ -378,7 +392,8 @@ impl CefTaskRunner {
// Execution will occur asynchronously.
//
pub fn post_task(&self, task: interfaces::CefTask) -> 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 {
@ -397,7 +412,8 @@ impl CefTaskRunner {
//
pub fn post_delayed_task(&self, task: interfaces::CefTask,
delay_ms: i64) -> 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 {
@ -451,7 +467,8 @@ impl CefWrap<*mut cef_task_runner_t> for Option<CefTaskRunner> {
}
}
unsafe fn to_rust(c_object: *mut cef_task_runner_t) -> Option<CefTaskRunner> {
if c_object.is_null() {
if c_object.is_null() &&
c_object as usize != mem::POST_DROP_USIZE {
None
} else {
Some(CefTaskRunner::from_c_object_addref(c_object))