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;
//
@ -174,13 +175,13 @@ pub struct _cef_request_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_request_t = _cef_request_t;
@ -196,7 +197,8 @@ pub struct CefRequest {
impl Clone for CefRequest {
fn clone(&self) -> CefRequest{
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);
}
CefRequest {
@ -209,7 +211,8 @@ impl Clone for CefRequest {
impl Drop for CefRequest {
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);
}
}
@ -224,7 +227,8 @@ impl CefRequest {
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_request_t) -> CefRequest {
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);
}
CefRequest {
@ -238,7 +242,8 @@ impl CefRequest {
pub fn c_object_addrefed(&self) -> *mut cef_request_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
@ -246,17 +251,18 @@ impl CefRequest {
}
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
}
//
// Returns true (1) if this object is read-only.
//
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 {
@ -271,7 +277,8 @@ impl CefRequest {
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_url(&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 {
@ -285,7 +292,8 @@ impl CefRequest {
// Set the fully qualified URL.
//
pub fn set_url(&self, url: &[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 {
@ -302,7 +310,8 @@ impl CefRequest {
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_method(&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 {
@ -316,7 +325,8 @@ impl CefRequest {
// Set the request function type.
//
pub fn set_method(&self, method: &[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 {
@ -331,7 +341,8 @@ impl CefRequest {
// Get the post data.
//
pub fn get_post_data(&self) -> interfaces::CefPostData {
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 {
@ -345,7 +356,8 @@ impl CefRequest {
// Set the post data.
//
pub fn set_post_data(&self, postData: interfaces::CefPostData) -> () {
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 {
@ -360,7 +372,8 @@ impl CefRequest {
// Get the header values.
//
pub fn get_header_map(&self, headerMap: HashMap<String,Vec<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 {
@ -375,7 +388,8 @@ impl CefRequest {
// Set the header values.
//
pub fn set_header_map(&self, headerMap: HashMap<String,Vec<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 {
@ -392,7 +406,8 @@ impl CefRequest {
pub fn set(&self, url: &[u16], method: &[u16],
postData: interfaces::CefPostData, headerMap: HashMap<String,
Vec<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 {
@ -411,7 +426,8 @@ impl CefRequest {
// cef_urlrequest_flags_t for supported values.
//
pub fn get_flags(&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 {
@ -426,7 +442,8 @@ impl CefRequest {
// cef_urlrequest_flags_t for supported values.
//
pub fn set_flags(&self, flags: 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 {
@ -443,7 +460,8 @@ impl CefRequest {
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_first_party_for_cookies(&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 {
@ -458,7 +476,8 @@ impl CefRequest {
// cef_urlrequest_t.
//
pub fn set_first_party_for_cookies(&self, url: &[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 {
@ -474,7 +493,8 @@ impl CefRequest {
// process.
//
pub fn get_resource_type(&self) -> types::cef_resource_type_t {
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 {
@ -490,7 +510,8 @@ impl CefRequest {
// frame navigation.
//
pub fn get_transition_type(&self) -> types::cef_transition_type_t {
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 {
@ -506,7 +527,8 @@ impl CefRequest {
// browser process to track a single request across multiple callbacks.
//
pub fn get_identifier(&self) -> u64 {
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 {
@ -544,7 +566,8 @@ impl CefWrap<*mut cef_request_t> for Option<CefRequest> {
}
}
unsafe fn to_rust(c_object: *mut cef_request_t) -> Option<CefRequest> {
if c_object.is_null() {
if c_object.is_null() &&
c_object as usize != mem::POST_DROP_USIZE {
None
} else {
Some(CefRequest::from_c_object_addref(c_object))
@ -604,13 +627,13 @@ pub struct _cef_post_data_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_post_data_t = _cef_post_data_t;
@ -626,7 +649,8 @@ pub struct CefPostData {
impl Clone for CefPostData {
fn clone(&self) -> CefPostData{
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);
}
CefPostData {
@ -639,7 +663,8 @@ impl Clone for CefPostData {
impl Drop for CefPostData {
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);
}
}
@ -654,7 +679,8 @@ impl CefPostData {
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_post_data_t) -> CefPostData {
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);
}
CefPostData {
@ -668,7 +694,8 @@ impl CefPostData {
pub fn c_object_addrefed(&self) -> *mut cef_post_data_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
@ -676,17 +703,18 @@ impl CefPostData {
}
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
}
//
// Returns true (1) if this object is read-only.
//
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 {
@ -700,7 +728,8 @@ impl CefPostData {
// Returns the number of existing post data elements.
//
pub fn get_element_count(&self) -> libc::size_t {
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 {
@ -715,7 +744,8 @@ impl CefPostData {
//
pub fn get_elements(&self, elements_count: *mut libc::size_t,
elements: *mut interfaces::CefPostDataElement) -> () {
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 {
@ -733,7 +763,8 @@ impl CefPostData {
//
pub fn remove_element(&self,
element: interfaces::CefPostDataElement) -> 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 {
@ -749,7 +780,8 @@ impl CefPostData {
//
pub fn add_element(&self,
element: interfaces::CefPostDataElement) -> 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 {
@ -764,7 +796,8 @@ impl CefPostData {
// Remove all existing post data elements.
//
pub fn remove_elements(&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 {
@ -802,7 +835,8 @@ impl CefWrap<*mut cef_post_data_t> for Option<CefPostData> {
}
}
unsafe fn to_rust(c_object: *mut cef_post_data_t) -> Option<CefPostData> {
if c_object.is_null() {
if c_object.is_null() &&
c_object as usize != mem::POST_DROP_USIZE {
None
} else {
Some(CefPostData::from_c_object_addref(c_object))
@ -876,13 +910,13 @@ pub struct _cef_post_data_element_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_post_data_element_t = _cef_post_data_element_t;
@ -898,7 +932,8 @@ pub struct CefPostDataElement {
impl Clone for CefPostDataElement {
fn clone(&self) -> CefPostDataElement{
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);
}
CefPostDataElement {
@ -911,7 +946,8 @@ impl Clone for CefPostDataElement {
impl Drop for CefPostDataElement {
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);
}
}
@ -926,7 +962,8 @@ impl CefPostDataElement {
}
pub unsafe fn from_c_object_addref(c_object: *mut cef_post_data_element_t) -> CefPostDataElement {
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);
}
CefPostDataElement {
@ -940,7 +977,8 @@ impl CefPostDataElement {
pub fn c_object_addrefed(&self) -> *mut cef_post_data_element_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
@ -948,17 +986,18 @@ impl CefPostDataElement {
}
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
}
//
// Returns true (1) if this object is read-only.
//
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 {
@ -972,7 +1011,8 @@ impl CefPostDataElement {
// Remove all contents from the post data element.
//
pub fn set_to_empty(&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 {
@ -986,7 +1026,8 @@ impl CefPostDataElement {
// The post data element will represent a file.
//
pub fn set_to_file(&self, fileName: &[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 {
@ -1002,7 +1043,8 @@ impl CefPostDataElement {
// copied.
//
pub fn set_to_bytes(&self, size: libc::size_t, bytes: &()) -> () {
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 {
@ -1018,7 +1060,8 @@ impl CefPostDataElement {
// Return the type of this post data element.
//
pub fn get_type(&self) -> types::cef_postdataelement_type_t {
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 {
@ -1033,7 +1076,8 @@ impl CefPostDataElement {
//
// The resulting string must be freed by calling cef_string_userfree_free().
pub fn get_file(&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 {
@ -1047,7 +1091,8 @@ impl CefPostDataElement {
// Return the number of bytes.
//
pub fn get_bytes_count(&self) -> libc::size_t {
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 {
@ -1062,7 +1107,8 @@ impl CefPostDataElement {
// actually read.
//
pub fn get_bytes(&self, size: libc::size_t, bytes: &mut ()) -> libc::size_t {
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 {
@ -1102,7 +1148,8 @@ impl CefWrap<*mut cef_post_data_element_t> for Option<CefPostDataElement> {
}
}
unsafe fn to_rust(c_object: *mut cef_post_data_element_t) -> Option<CefPostDataElement> {
if c_object.is_null() {
if c_object.is_null() &&
c_object as usize != mem::POST_DROP_USIZE {
None
} else {
Some(CefPostDataElement::from_c_object_addref(c_object))