From 745e3bd49f7d496779b5e67ac7a6c478c64a2a0f Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Wed, 6 May 2015 12:27:58 -0400 Subject: [PATCH] update embedding interfaces again to use filling_drop feature ...and remove trailing whitespaces --- ports/cef/interfaces/cef_app.rs | 39 +- ports/cef/interfaces/cef_auth_callback.rs | 30 +- ports/cef/interfaces/cef_browser.rs | 294 ++++++++----- .../interfaces/cef_browser_process_handler.rs | 36 +- ports/cef/interfaces/cef_callback.rs | 56 ++- ports/cef/interfaces/cef_client.rs | 69 ++-- ports/cef/interfaces/cef_command_line.rs | 84 ++-- .../interfaces/cef_context_menu_handler.rs | 110 +++-- ports/cef/interfaces/cef_cookie.rs | 123 +++--- ports/cef/interfaces/cef_dialog_handler.rs | 56 ++- ports/cef/interfaces/cef_display_handler.rs | 42 +- ports/cef/interfaces/cef_dom.rs | 190 ++++++--- ports/cef/interfaces/cef_download_handler.rs | 88 ++-- ports/cef/interfaces/cef_download_item.rs | 75 ++-- ports/cef/interfaces/cef_drag_data.rs | 90 ++-- ports/cef/interfaces/cef_drag_handler.rs | 27 +- ports/cef/interfaces/cef_find_handler.rs | 27 +- ports/cef/interfaces/cef_focus_handler.rs | 33 +- ports/cef/interfaces/cef_frame.rs | 96 +++-- ports/cef/interfaces/cef_geolocation.rs | 27 +- .../cef/interfaces/cef_geolocation_handler.rs | 56 ++- ports/cef/interfaces/cef_jsdialog_handler.rs | 62 +-- ports/cef/interfaces/cef_keyboard_handler.rs | 30 +- ports/cef/interfaces/cef_life_span_handler.rs | 39 +- ports/cef/interfaces/cef_load_handler.rs | 36 +- ports/cef/interfaces/cef_menu_model.rs | 171 +++++--- ports/cef/interfaces/cef_navigation_entry.rs | 54 ++- ports/cef/interfaces/cef_origin_whitelist.rs | 1 + ports/cef/interfaces/cef_parser.rs | 1 + ports/cef/interfaces/cef_path_util.rs | 1 + ports/cef/interfaces/cef_print_handler.rs | 91 ++-- ports/cef/interfaces/cef_print_settings.rs | 93 +++-- ports/cef/interfaces/cef_process_message.rs | 39 +- ports/cef/interfaces/cef_process_util.rs | 1 + ports/cef/interfaces/cef_render_handler.rs | 63 ++- .../interfaces/cef_render_process_handler.rs | 57 ++- ports/cef/interfaces/cef_request.rs | 163 +++++--- ports/cef/interfaces/cef_request_context.rs | 48 ++- .../interfaces/cef_request_context_handler.rs | 27 +- ports/cef/interfaces/cef_request_handler.rs | 95 +++-- .../interfaces/cef_resource_bundle_handler.rs | 30 +- ports/cef/interfaces/cef_resource_handler.rs | 42 +- ports/cef/interfaces/cef_response.rs | 54 ++- ports/cef/interfaces/cef_scheme.rs | 53 ++- ports/cef/interfaces/cef_ssl_info.rs | 95 +++-- ports/cef/interfaces/cef_stream.rs | 153 ++++--- ports/cef/interfaces/cef_string_visitor.rs | 27 +- ports/cef/interfaces/cef_task.rs | 65 +-- ports/cef/interfaces/cef_trace.rs | 27 +- ports/cef/interfaces/cef_urlrequest.rs | 80 ++-- ports/cef/interfaces/cef_v8.rs | 387 +++++++++++------- ports/cef/interfaces/cef_values.rs | 351 ++++++++++------ ports/cef/interfaces/cef_web_plugin.rs | 88 ++-- ports/cef/interfaces/cef_xml_reader.rs | 111 +++-- ports/cef/interfaces/cef_zip_reader.rs | 60 ++- ports/cef/lib.rs | 2 +- ports/cef/macros.rs | 2 +- 57 files changed, 2797 insertions(+), 1550 deletions(-) diff --git a/ports/cef/interfaces/cef_app.rs b/ports/cef/interfaces/cef_app.rs index 287cf5097b4..bdd74b11ae8 100644 --- a/ports/cef/interfaces/cef_app.rs +++ b/ports/cef/interfaces/cef_app.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -106,13 +107,13 @@ pub struct _cef_app_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_app_t = _cef_app_t; @@ -128,7 +129,8 @@ pub struct CefApp { impl Clone for CefApp { fn clone(&self) -> CefApp{ 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); } CefApp { @@ -141,7 +143,8 @@ impl Clone for CefApp { impl Drop for CefApp { 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); } } @@ -156,7 +159,8 @@ impl CefApp { } pub unsafe fn from_c_object_addref(c_object: *mut cef_app_t) -> CefApp { - 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); } CefApp { @@ -170,7 +174,8 @@ impl CefApp { pub fn c_object_addrefed(&self) -> *mut cef_app_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 @@ -178,10 +183,10 @@ impl CefApp { } 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 } // @@ -197,7 +202,8 @@ impl CefApp { // pub fn on_before_command_line_processing(&self, process_type: &[u16], command_line: interfaces::CefCommandLine) -> () { - 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 +223,8 @@ impl CefApp { // pub fn on_register_custom_schemes(&self, registrar: interfaces::CefSchemeRegistrar) -> () { - 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 { @@ -236,7 +243,8 @@ impl CefApp { // pub fn get_resource_bundle_handler( &self) -> interfaces::CefResourceBundleHandler { - 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 { @@ -252,7 +260,8 @@ impl CefApp { // pub fn get_browser_process_handler( &self) -> interfaces::CefBrowserProcessHandler { - 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 { @@ -268,7 +277,8 @@ impl CefApp { // pub fn get_render_process_handler( &self) -> interfaces::CefRenderProcessHandler { - 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 { @@ -295,7 +305,8 @@ impl CefWrap<*mut cef_app_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_app_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefApp::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_auth_callback.rs b/ports/cef/interfaces/cef_auth_callback.rs index 94681070a64..f93fb47956f 100644 --- a/ports/cef/interfaces/cef_auth_callback.rs +++ b/ports/cef/interfaces/cef_auth_callback.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -71,13 +72,13 @@ pub struct _cef_auth_callback_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_auth_callback_t = _cef_auth_callback_t; @@ -93,7 +94,8 @@ pub struct CefAuthCallback { impl Clone for CefAuthCallback { fn clone(&self) -> CefAuthCallback{ 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); } CefAuthCallback { @@ -106,7 +108,8 @@ impl Clone for CefAuthCallback { impl Drop for CefAuthCallback { 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); } } @@ -121,7 +124,8 @@ impl CefAuthCallback { } pub unsafe fn from_c_object_addref(c_object: *mut cef_auth_callback_t) -> CefAuthCallback { - 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); } CefAuthCallback { @@ -135,7 +139,8 @@ impl CefAuthCallback { pub fn c_object_addrefed(&self) -> *mut cef_auth_callback_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 @@ -143,17 +148,18 @@ impl CefAuthCallback { } 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 } // // Continue the authentication request. // pub fn cont(&self, username: &[u16], password: &[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 { @@ -169,7 +175,8 @@ impl CefAuthCallback { // Cancel the authentication request. // pub fn cancel(&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 { @@ -196,7 +203,8 @@ impl CefWrap<*mut cef_auth_callback_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_auth_callback_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefAuthCallback::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_browser.rs b/ports/cef/interfaces/cef_browser.rs index 30a580b6d13..46c9fcaf100 100644 --- a/ports/cef/interfaces/cef_browser.rs +++ b/ports/cef/interfaces/cef_browser.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -186,13 +187,13 @@ pub struct _cef_browser_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_browser_t = _cef_browser_t; @@ -210,7 +211,8 @@ pub struct CefBrowser { impl Clone for CefBrowser { fn clone(&self) -> CefBrowser{ 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); } CefBrowser { @@ -223,7 +225,8 @@ impl Clone for CefBrowser { impl Drop for CefBrowser { 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); } } @@ -238,7 +241,8 @@ impl CefBrowser { } pub unsafe fn from_c_object_addref(c_object: *mut cef_browser_t) -> CefBrowser { - 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); } CefBrowser { @@ -252,7 +256,8 @@ impl CefBrowser { pub fn c_object_addrefed(&self) -> *mut cef_browser_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 @@ -260,10 +265,10 @@ impl CefBrowser { } 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 } // @@ -271,7 +276,8 @@ impl CefBrowser { // browser process. // pub fn get_host(&self) -> interfaces::CefBrowserHost { - 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 +291,8 @@ impl CefBrowser { // Returns true (1) if the browser can navigate backwards. // pub fn can_go_back(&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 { @@ -299,7 +306,8 @@ impl CefBrowser { // Navigate backwards. // pub fn go_back(&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 { @@ -313,7 +321,8 @@ impl CefBrowser { // Returns true (1) if the browser can navigate forwards. // pub fn can_go_forward(&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 { @@ -327,7 +336,8 @@ impl CefBrowser { // Navigate forwards. // pub fn go_forward(&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 { @@ -341,7 +351,8 @@ impl CefBrowser { // Returns true (1) if the browser is currently loading. // pub fn is_loading(&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 { @@ -355,7 +366,8 @@ impl CefBrowser { // Reload the current page. // pub fn reload(&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 { @@ -369,7 +381,8 @@ impl CefBrowser { // Reload the current page ignoring any cached data. // pub fn reload_ignore_cache(&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 { @@ -383,7 +396,8 @@ impl CefBrowser { // Stop loading the page. // pub fn stop_load(&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 { @@ -397,7 +411,8 @@ impl CefBrowser { // Returns the globally unique identifier for this browser. // pub fn get_identifier(&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 { @@ -412,7 +427,8 @@ impl CefBrowser { // object. // pub fn is_same(&self, that: interfaces::CefBrowser) -> 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 { @@ -427,7 +443,8 @@ impl CefBrowser { // Returns true (1) if the window is a popup window. // pub fn is_popup(&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 { @@ -441,7 +458,8 @@ impl CefBrowser { // Returns true (1) if a document has been loaded in the browser. // pub fn has_document(&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 { @@ -455,7 +473,8 @@ impl CefBrowser { // Returns the main (top-level) frame for the browser window. // pub fn get_main_frame(&self) -> 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 { @@ -469,7 +488,8 @@ impl CefBrowser { // Returns the focused frame for the browser window. // pub fn get_focused_frame(&self) -> 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 { @@ -483,7 +503,8 @@ impl CefBrowser { // Returns the frame with the specified identifier, or NULL if not found. // pub fn get_frame_byident(&self, identifier: i64) -> 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 { @@ -498,7 +519,8 @@ impl CefBrowser { // Returns the frame with the specified name, or NULL if not found. // pub fn get_frame(&self, name: &[u16]) -> 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 { @@ -513,7 +535,8 @@ impl CefBrowser { // Returns the number of frames that currently exist. // pub fn get_frame_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 { @@ -528,7 +551,8 @@ impl CefBrowser { // pub fn get_frame_identifiers(&self, identifiers_count: *mut libc::size_t, identifiers: *mut i64) -> () { - 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 +568,8 @@ impl CefBrowser { // Returns the names of all existing frames. // pub fn get_frame_names(&self, names: Vec) -> () { - 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 { @@ -561,7 +586,8 @@ impl CefBrowser { // pub fn send_process_message(&self, target_process: interfaces::CefProcessId, message: interfaces::CefProcessMessage) -> 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 { @@ -590,7 +616,8 @@ impl CefWrap<*mut cef_browser_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_browser_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefBrowser::from_c_object_addref(c_object)) @@ -625,13 +652,13 @@ pub struct _cef_run_file_dialog_callback_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_run_file_dialog_callback_t = _cef_run_file_dialog_callback_t; @@ -647,7 +674,8 @@ pub struct CefRunFileDialogCallback { impl Clone for CefRunFileDialogCallback { fn clone(&self) -> CefRunFileDialogCallback{ 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); } CefRunFileDialogCallback { @@ -660,7 +688,8 @@ impl Clone for CefRunFileDialogCallback { impl Drop for CefRunFileDialogCallback { 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); } } @@ -675,7 +704,8 @@ impl CefRunFileDialogCallback { } pub unsafe fn from_c_object_addref(c_object: *mut cef_run_file_dialog_callback_t) -> CefRunFileDialogCallback { - 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); } CefRunFileDialogCallback { @@ -689,7 +719,8 @@ impl CefRunFileDialogCallback { pub fn c_object_addrefed(&self) -> *mut cef_run_file_dialog_callback_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 @@ -697,10 +728,10 @@ impl CefRunFileDialogCallback { } 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 } // @@ -712,7 +743,8 @@ impl CefRunFileDialogCallback { // pub fn on_file_dialog_dismissed(&self, selected_accept_filter: libc::c_int, file_paths: Vec) -> () { - 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 { @@ -741,7 +773,8 @@ impl CefWrap<*mut cef_run_file_dialog_callback_t> for Option Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefRunFileDialogCallback::from_c_object_addref(c_object)) @@ -775,13 +808,13 @@ pub struct _cef_navigation_entry_visitor_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_navigation_entry_visitor_t = _cef_navigation_entry_visitor_t; @@ -797,7 +830,8 @@ pub struct CefNavigationEntryVisitor { impl Clone for CefNavigationEntryVisitor { fn clone(&self) -> CefNavigationEntryVisitor{ 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); } CefNavigationEntryVisitor { @@ -810,7 +844,8 @@ impl Clone for CefNavigationEntryVisitor { impl Drop for CefNavigationEntryVisitor { 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); } } @@ -825,7 +860,8 @@ impl CefNavigationEntryVisitor { } pub unsafe fn from_c_object_addref(c_object: *mut cef_navigation_entry_visitor_t) -> CefNavigationEntryVisitor { - 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); } CefNavigationEntryVisitor { @@ -839,7 +875,8 @@ impl CefNavigationEntryVisitor { pub fn c_object_addrefed(&self) -> *mut cef_navigation_entry_visitor_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 @@ -847,10 +884,10 @@ impl CefNavigationEntryVisitor { } 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 } // @@ -863,7 +900,8 @@ impl CefNavigationEntryVisitor { pub fn visit(&self, entry: interfaces::CefNavigationEntry, current: libc::c_int, index: libc::c_int, total: libc::c_int) -> 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 { @@ -894,7 +932,8 @@ impl CefWrap<*mut cef_navigation_entry_visitor_t> for Option Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefNavigationEntryVisitor::from_c_object_addref(c_object)) @@ -1292,13 +1331,13 @@ pub struct _cef_browser_host_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_browser_host_t = _cef_browser_host_t; @@ -1316,7 +1355,8 @@ pub struct CefBrowserHost { impl Clone for CefBrowserHost { fn clone(&self) -> CefBrowserHost{ 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); } CefBrowserHost { @@ -1329,7 +1369,8 @@ impl Clone for CefBrowserHost { impl Drop for CefBrowserHost { 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); } } @@ -1344,7 +1385,8 @@ impl CefBrowserHost { } pub unsafe fn from_c_object_addref(c_object: *mut cef_browser_host_t) -> CefBrowserHost { - 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); } CefBrowserHost { @@ -1358,7 +1400,8 @@ impl CefBrowserHost { pub fn c_object_addrefed(&self) -> *mut cef_browser_host_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 @@ -1366,17 +1409,18 @@ impl CefBrowserHost { } 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 the hosted browser object. // pub fn get_browser(&self) -> interfaces::CefBrowser { - 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 { @@ -1397,7 +1441,8 @@ impl CefBrowserHost { // information. // pub fn close_browser(&self, force_close: 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 { @@ -1412,7 +1457,8 @@ impl CefBrowserHost { // Set whether the browser is focused. // pub fn set_focus(&self, focus: 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 { @@ -1428,7 +1474,8 @@ impl CefBrowserHost { // (minimized/unminimized, app hidden/unhidden, etc). Only used on Mac OS X. // pub fn set_window_visibility(&self, visible: 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 { @@ -1443,7 +1490,8 @@ impl CefBrowserHost { // Retrieve the window handle for this browser. // pub fn get_window_handle(&self) -> types::cef_window_handle_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 { @@ -1459,7 +1507,8 @@ impl CefBrowserHost { // with custom handling of modal windows. // pub fn get_opener_window_handle(&self) -> types::cef_window_handle_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 { @@ -1473,7 +1522,8 @@ impl CefBrowserHost { // Returns the client for this browser. // pub fn get_client(&self) -> interfaces::CefClient { - 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 { @@ -1487,7 +1537,8 @@ impl CefBrowserHost { // Returns the request context for this browser. // pub fn get_request_context(&self) -> interfaces::CefRequestContext { - 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 { @@ -1502,7 +1553,8 @@ impl CefBrowserHost { // can only be called on the UI thread. // pub fn get_zoom_level(&self) -> libc::c_double { - 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 { @@ -1518,7 +1570,8 @@ impl CefBrowserHost { // Otherwise, the change will be applied asynchronously on the UI thread. // pub fn set_zoom_level(&self, zoomLevel: libc::c_double) -> () { - 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 { @@ -1549,7 +1602,8 @@ impl CefBrowserHost { title: &[u16], default_file_path: &[u16], accept_filters: Vec, selected_accept_filter: libc::c_int, callback: interfaces::CefRunFileDialogCallback) -> () { - 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 { @@ -1569,7 +1623,8 @@ impl CefBrowserHost { // Download the file at |url| using cef_download_handler_t. // pub fn start_download(&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 { @@ -1584,7 +1639,8 @@ impl CefBrowserHost { // Print the current browser contents. // pub fn print(&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 { @@ -1605,7 +1661,8 @@ impl CefBrowserHost { pub fn find(&self, identifier: libc::c_int, searchText: &[u16], forward: libc::c_int, matchCase: libc::c_int, findNext: 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 { @@ -1624,7 +1681,8 @@ impl CefBrowserHost { // Cancel all searches that are currently going on. // pub fn stop_finding(&self, clearSelection: 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 { @@ -1642,7 +1700,8 @@ impl CefBrowserHost { pub fn show_dev_tools(&self, windowInfo: &interfaces::CefWindowInfo, client: interfaces::CefClient, settings: &interfaces::CefBrowserSettings, inspect_element_at: &types::cef_point_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 { @@ -1661,7 +1720,8 @@ impl CefBrowserHost { // instance. // pub fn close_dev_tools(&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 { @@ -1681,7 +1741,8 @@ impl CefBrowserHost { pub fn get_navigation_entries(&self, visitor: interfaces::CefNavigationEntryVisitor, current_only: 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 { @@ -1697,7 +1758,8 @@ impl CefBrowserHost { // Set whether mouse cursor change is disabled. // pub fn set_mouse_cursor_change_disabled(&self, disabled: 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 { @@ -1712,7 +1774,8 @@ impl CefBrowserHost { // Returns true (1) if mouse cursor change is disabled. // pub fn is_mouse_cursor_change_disabled(&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 { @@ -1727,7 +1790,8 @@ impl CefBrowserHost { // function will replace it with the specified |word|. // pub fn replace_misspelling(&self, word: &[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 { @@ -1742,7 +1806,8 @@ impl CefBrowserHost { // Add the specified |word| to the spelling dictionary. // pub fn add_word_to_dictionary(&self, word: &[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 { @@ -1757,7 +1822,8 @@ impl CefBrowserHost { // Returns true (1) if window rendering is disabled. // pub fn is_window_rendering_disabled(&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 { @@ -1774,7 +1840,8 @@ impl CefBrowserHost { // function is only used when window rendering is disabled. // pub fn was_resized(&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 { @@ -1790,7 +1857,8 @@ impl CefBrowserHost { // hidden. This function is only used when window rendering is disabled. // pub fn was_hidden(&self, hidden: 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 { @@ -1810,7 +1878,8 @@ impl CefBrowserHost { // disabled. // pub fn notify_screen_info_changed(&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 { @@ -1826,7 +1895,8 @@ impl CefBrowserHost { // disabled. // pub fn invalidate(&self, ty: types::cef_paint_element_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 { @@ -1841,7 +1911,8 @@ impl CefBrowserHost { // Send a key event to the browser. // pub fn send_key_event(&self, event: &interfaces::CefKeyEvent) -> () { - 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 { @@ -1859,7 +1930,8 @@ impl CefBrowserHost { pub fn send_mouse_click_event(&self, event: &interfaces::CefMouseEvent, ty: types::cef_mouse_button_type_t, mouseUp: libc::c_int, clickCount: 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 { @@ -1879,7 +1951,8 @@ impl CefBrowserHost { // pub fn send_mouse_move_event(&self, event: &interfaces::CefMouseEvent, mouseLeave: 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 { @@ -1900,7 +1973,8 @@ impl CefBrowserHost { // pub fn send_mouse_wheel_event(&self, event: &interfaces::CefMouseEvent, deltaX: libc::c_int, deltaY: 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 { @@ -1917,7 +1991,8 @@ impl CefBrowserHost { // Send a focus event to the browser. // pub fn send_focus_event(&self, setFocus: 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 { @@ -1932,7 +2007,8 @@ impl CefBrowserHost { // Send a capture lost event to the browser. // pub fn send_capture_lost_event(&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 { @@ -1947,7 +2023,8 @@ impl CefBrowserHost { // resized. This function is only used on Windows and Linux. // pub fn notify_move_or_resize_started(&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 { @@ -1962,7 +2039,8 @@ impl CefBrowserHost { // window rendering is disabled. // pub fn get_nstext_input_context(&self) -> types::cef_text_input_context_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 { @@ -1978,7 +2056,8 @@ impl CefBrowserHost { // pub fn handle_key_event_before_text_input_client(&self, keyEvent: types::cef_event_handle_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 { @@ -1994,7 +2073,8 @@ impl CefBrowserHost { // pub fn handle_key_event_after_text_input_client(&self, keyEvent: types::cef_event_handle_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 { @@ -2017,7 +2097,8 @@ impl CefBrowserHost { pub fn drag_target_drag_enter(&self, drag_data: interfaces::CefDragData, event: &interfaces::CefMouseEvent, allowed_ops: types::cef_drag_operations_mask_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 { @@ -2038,7 +2119,8 @@ impl CefBrowserHost { // pub fn drag_target_drag_over(&self, event: &interfaces::CefMouseEvent, allowed_ops: types::cef_drag_operations_mask_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 { @@ -2056,7 +2138,8 @@ impl CefBrowserHost { // rendering is disabled. // pub fn drag_target_drag_leave(&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 { @@ -2074,7 +2157,8 @@ impl CefBrowserHost { // is disabled. // pub fn drag_target_drop(&self, event: &interfaces::CefMouseEvent) -> () { - 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 { @@ -2096,7 +2180,8 @@ impl CefBrowserHost { // pub fn drag_source_ended_at(&self, x: libc::c_int, y: libc::c_int, op: types::cef_drag_operations_mask_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 { @@ -2118,7 +2203,8 @@ impl CefBrowserHost { // This function is only used when window rendering is disabled. // pub fn drag_source_system_drag_ended(&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 { @@ -2134,7 +2220,8 @@ impl CefBrowserHost { // this function. // pub fn initialize_compositing(&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 { @@ -2203,7 +2290,8 @@ impl CefWrap<*mut cef_browser_host_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_browser_host_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefBrowserHost::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_browser_process_handler.rs b/ports/cef/interfaces/cef_browser_process_handler.rs index fe287c545a1..672247169fd 100644 --- a/ports/cef/interfaces/cef_browser_process_handler.rs +++ b/ports/cef/interfaces/cef_browser_process_handler.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -96,13 +97,13 @@ pub struct _cef_browser_process_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_browser_process_handler_t = _cef_browser_process_handler_t; @@ -119,7 +120,8 @@ pub struct CefBrowserProcessHandler { impl Clone for CefBrowserProcessHandler { fn clone(&self) -> CefBrowserProcessHandler{ 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); } CefBrowserProcessHandler { @@ -132,7 +134,8 @@ impl Clone for CefBrowserProcessHandler { impl Drop for CefBrowserProcessHandler { 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); } } @@ -147,7 +150,8 @@ impl CefBrowserProcessHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_browser_process_handler_t) -> CefBrowserProcessHandler { - 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); } CefBrowserProcessHandler { @@ -161,7 +165,8 @@ impl CefBrowserProcessHandler { pub fn c_object_addrefed(&self) -> *mut cef_browser_process_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 @@ -169,10 +174,10 @@ impl CefBrowserProcessHandler { } 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 } // @@ -180,7 +185,8 @@ impl CefBrowserProcessHandler { // has been initialized. // pub fn on_context_initialized(&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 { @@ -199,7 +205,8 @@ impl CefBrowserProcessHandler { // pub fn on_before_child_process_launch(&self, command_line: interfaces::CefCommandLine) -> () { - 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 { @@ -219,7 +226,8 @@ impl CefBrowserProcessHandler { // pub fn on_render_process_thread_created(&self, extra_info: 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 { @@ -235,7 +243,8 @@ impl CefBrowserProcessHandler { // provided then printing will not be supported on the Linux platform. // pub fn get_print_handler(&self) -> interfaces::CefPrintHandler { - 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 { @@ -262,7 +271,8 @@ impl CefWrap<*mut cef_browser_process_handler_t> for Option Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefBrowserProcessHandler::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_callback.rs b/ports/cef/interfaces/cef_callback.rs index fdf78a191b6..ef2452ff71d 100644 --- a/ports/cef/interfaces/cef_callback.rs +++ b/ports/cef/interfaces/cef_callback.rs @@ -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_callback_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_callback_t = _cef_callback_t; @@ -89,7 +90,8 @@ pub struct CefCallback { impl Clone for CefCallback { fn clone(&self) -> CefCallback{ 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); } CefCallback { @@ -102,7 +104,8 @@ impl Clone for CefCallback { impl Drop for CefCallback { 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); } } @@ -117,7 +120,8 @@ impl CefCallback { } pub unsafe fn from_c_object_addref(c_object: *mut cef_callback_t) -> CefCallback { - 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); } CefCallback { @@ -131,7 +135,8 @@ impl CefCallback { pub fn c_object_addrefed(&self) -> *mut cef_callback_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 @@ -139,17 +144,18 @@ impl CefCallback { } 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 } // // Continue processing. // pub fn cont(&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 { @@ -163,7 +169,8 @@ impl CefCallback { // Cancel processing. // pub fn cancel(&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 { @@ -190,7 +197,8 @@ impl CefWrap<*mut cef_callback_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_callback_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefCallback::from_c_object_addref(c_object)) @@ -218,13 +226,13 @@ pub struct _cef_completion_callback_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_completion_callback_t = _cef_completion_callback_t; @@ -239,7 +247,8 @@ pub struct CefCompletionCallback { impl Clone for CefCompletionCallback { fn clone(&self) -> CefCompletionCallback{ 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); } CefCompletionCallback { @@ -252,7 +261,8 @@ impl Clone for CefCompletionCallback { impl Drop for CefCompletionCallback { 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); } } @@ -267,7 +277,8 @@ impl CefCompletionCallback { } pub unsafe fn from_c_object_addref(c_object: *mut cef_completion_callback_t) -> CefCompletionCallback { - 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); } CefCompletionCallback { @@ -281,7 +292,8 @@ impl CefCompletionCallback { pub fn c_object_addrefed(&self) -> *mut cef_completion_callback_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 @@ -289,17 +301,18 @@ impl CefCompletionCallback { } 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 called once the task is complete. // pub fn on_complete(&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 { @@ -326,7 +339,8 @@ impl CefWrap<*mut cef_completion_callback_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_completion_callback_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefCompletionCallback::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_client.rs b/ports/cef/interfaces/cef_client.rs index 66f099a4d37..e49632d5f96 100644 --- a/ports/cef/interfaces/cef_client.rs +++ b/ports/cef/interfaces/cef_client.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -157,13 +158,13 @@ pub struct _cef_client_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_client_t = _cef_client_t; @@ -178,7 +179,8 @@ pub struct CefClient { impl Clone for CefClient { fn clone(&self) -> CefClient{ 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); } CefClient { @@ -191,7 +193,8 @@ impl Clone for CefClient { impl Drop for CefClient { 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); } } @@ -206,7 +209,8 @@ impl CefClient { } pub unsafe fn from_c_object_addref(c_object: *mut cef_client_t) -> CefClient { - 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); } CefClient { @@ -220,7 +224,8 @@ impl CefClient { pub fn c_object_addrefed(&self) -> *mut cef_client_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 @@ -228,10 +233,10 @@ impl CefClient { } 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 } // @@ -239,7 +244,8 @@ impl CefClient { // implementation will be used. // pub fn get_context_menu_handler(&self) -> interfaces::CefContextMenuHandler { - 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 { @@ -254,7 +260,8 @@ impl CefClient { // implementation will be used. // pub fn get_dialog_handler(&self) -> interfaces::CefDialogHandler { - 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 { @@ -268,7 +275,8 @@ impl CefClient { // Return the handler for browser display state events. // pub fn get_display_handler(&self) -> interfaces::CefDisplayHandler { - 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 { @@ -283,7 +291,8 @@ impl CefClient { // will not be allowed. // pub fn get_download_handler(&self) -> interfaces::CefDownloadHandler { - 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 CefClient { // Return the handler for drag events. // pub fn get_drag_handler(&self) -> interfaces::CefDragHandler { - 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 { @@ -311,7 +321,8 @@ impl CefClient { // Return the handler for find result events. // pub fn get_find_handler(&self) -> interfaces::CefFindHandler { - 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 { @@ -325,7 +336,8 @@ impl CefClient { // Return the handler for focus events. // pub fn get_focus_handler(&self) -> interfaces::CefFocusHandler { - 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 { @@ -340,7 +352,8 @@ impl CefClient { // provided geolocation access will be denied by default. // pub fn get_geolocation_handler(&self) -> interfaces::CefGeolocationHandler { - 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 { @@ -355,7 +368,8 @@ impl CefClient { // default implementation will be used. // pub fn get_jsdialog_handler(&self) -> interfaces::CefJSDialogHandler { - 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 { @@ -369,7 +383,8 @@ impl CefClient { // Return the handler for keyboard events. // pub fn get_keyboard_handler(&self) -> interfaces::CefKeyboardHandler { - 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 { @@ -383,7 +398,8 @@ impl CefClient { // Return the handler for browser life span events. // pub fn get_life_span_handler(&self) -> interfaces::CefLifeSpanHandler { - 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 +413,8 @@ impl CefClient { // Return the handler for browser load status events. // pub fn get_load_handler(&self) -> interfaces::CefLoadHandler { - 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 +428,8 @@ impl CefClient { // Return the handler for off-screen rendering events. // pub fn get_render_handler(&self) -> interfaces::CefRenderHandler { - 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 { @@ -425,7 +443,8 @@ impl CefClient { // Return the handler for browser request events. // pub fn get_request_handler(&self) -> interfaces::CefRequestHandler { - 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 +462,8 @@ impl CefClient { pub fn on_process_message_received(&self, browser: interfaces::CefBrowser, source_process: interfaces::CefProcessId, message: interfaces::CefProcessMessage) -> 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 { @@ -473,7 +493,8 @@ impl CefWrap<*mut cef_client_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_client_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefClient::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_command_line.rs b/ports/cef/interfaces/cef_command_line.rs index f46d4f1044c..53674ef25ba 100644 --- a/ports/cef/interfaces/cef_command_line.rs +++ b/ports/cef/interfaces/cef_command_line.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -200,13 +201,13 @@ pub struct _cef_command_line_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_command_line_t = _cef_command_line_t; @@ -228,7 +229,8 @@ pub struct CefCommandLine { impl Clone for CefCommandLine { fn clone(&self) -> CefCommandLine{ 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); } CefCommandLine { @@ -241,7 +243,8 @@ impl Clone for CefCommandLine { impl Drop for CefCommandLine { 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); } } @@ -256,7 +259,8 @@ impl CefCommandLine { } pub unsafe fn from_c_object_addref(c_object: *mut cef_command_line_t) -> CefCommandLine { - 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); } CefCommandLine { @@ -270,7 +274,8 @@ impl CefCommandLine { pub fn c_object_addrefed(&self) -> *mut cef_command_line_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 @@ -278,10 +283,10 @@ impl CefCommandLine { } 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 } // @@ -289,7 +294,8 @@ impl CefCommandLine { // 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 { @@ -304,7 +310,8 @@ impl CefCommandLine { // 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 { @@ -318,7 +325,8 @@ impl CefCommandLine { // Returns a writable copy of this object. // pub fn copy(&self) -> interfaces::CefCommandLine { - 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 { @@ -334,7 +342,8 @@ impl CefCommandLine { // supported on non-Windows platforms. // pub fn init_from_argv(&self, argc: libc::c_int, argv: &&str) -> () { - 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 { @@ -351,7 +360,8 @@ impl CefCommandLine { // GetCommandLineW(). This function is only supported on Windows. // pub fn init_from_string(&self, command_line: &[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 { @@ -367,7 +377,8 @@ impl CefCommandLine { // component unchanged. // pub fn reset(&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 { @@ -382,7 +393,8 @@ impl CefCommandLine { // array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* } // pub fn get_argv(&self, argv: Vec) -> () { - 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 { @@ -399,7 +411,8 @@ impl CefCommandLine { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_command_line_string(&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 { @@ -414,7 +427,8 @@ impl CefCommandLine { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_program(&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 { @@ -428,7 +442,8 @@ impl CefCommandLine { // Set the program part of the command line string (the first item). // pub fn set_program(&self, program: &[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 { @@ -443,7 +458,8 @@ impl CefCommandLine { // Returns true (1) if the command line has switches. // pub fn has_switches(&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 { @@ -457,7 +473,8 @@ impl CefCommandLine { // Returns true (1) if the command line contains the given switch. // pub fn has_switch(&self, name: &[u16]) -> 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 { @@ -474,7 +491,8 @@ impl CefCommandLine { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_switch_value(&self, name: &[u16]) -> 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 { @@ -490,7 +508,8 @@ impl CefCommandLine { // NULL string is returned. // pub fn get_switches(&self, switches: HashMap) -> () { - 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 +525,8 @@ impl CefCommandLine { // pass an NULL value string. // pub fn append_switch(&self, name: &[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 { @@ -521,7 +541,8 @@ impl CefCommandLine { // Add a switch with the specified value to the end of the command line. // pub fn append_switch_with_value(&self, name: &[u16], value: &[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 { @@ -537,7 +558,8 @@ impl CefCommandLine { // True if there are remaining command line arguments. // pub fn has_arguments(&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 { @@ -551,7 +573,8 @@ impl CefCommandLine { // Get the remaining command line arguments. // pub fn get_arguments(&self, arguments: Vec) -> () { - 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 { @@ -566,7 +589,8 @@ impl CefCommandLine { // Add an argument to the end of the command line. // pub fn append_argument(&self, argument: &[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 { @@ -582,7 +606,8 @@ impl CefCommandLine { // "valgrind" or "gdb --args". // pub fn prepend_wrapper(&self, wrapper: &[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 { @@ -633,7 +658,8 @@ impl CefWrap<*mut cef_command_line_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_command_line_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefCommandLine::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_context_menu_handler.rs b/ports/cef/interfaces/cef_context_menu_handler.rs index 3441b775be5..dedb9fd5c64 100644 --- a/ports/cef/interfaces/cef_context_menu_handler.rs +++ b/ports/cef/interfaces/cef_context_menu_handler.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -99,13 +100,13 @@ pub struct _cef_context_menu_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_context_menu_handler_t = _cef_context_menu_handler_t; @@ -121,7 +122,8 @@ pub struct CefContextMenuHandler { impl Clone for CefContextMenuHandler { fn clone(&self) -> CefContextMenuHandler{ 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); } CefContextMenuHandler { @@ -134,7 +136,8 @@ impl Clone for CefContextMenuHandler { impl Drop for CefContextMenuHandler { 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); } } @@ -149,7 +152,8 @@ impl CefContextMenuHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_context_menu_handler_t) -> CefContextMenuHandler { - 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); } CefContextMenuHandler { @@ -163,7 +167,8 @@ impl CefContextMenuHandler { pub fn c_object_addrefed(&self) -> *mut cef_context_menu_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 @@ -171,10 +176,10 @@ impl CefContextMenuHandler { } 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 } // @@ -187,7 +192,8 @@ impl CefContextMenuHandler { pub fn on_before_context_menu(&self, browser: interfaces::CefBrowser, frame: interfaces::CefFrame, params: interfaces::CefContextMenuParams, model: interfaces::CefMenuModel) -> () { - 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 { @@ -214,7 +220,8 @@ impl CefContextMenuHandler { frame: interfaces::CefFrame, params: interfaces::CefContextMenuParams, command_id: libc::c_int, event_flags: types::cef_event_flags_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 { @@ -235,7 +242,8 @@ impl CefContextMenuHandler { // pub fn on_context_menu_dismissed(&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 { @@ -264,7 +272,8 @@ impl CefWrap<*mut cef_context_menu_handler_t> for Option } } unsafe fn to_rust(c_object: *mut cef_context_menu_handler_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefContextMenuHandler::from_c_object_addref(c_object)) @@ -419,13 +428,13 @@ pub struct _cef_context_menu_params_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_context_menu_params_t = _cef_context_menu_params_t; @@ -441,7 +450,8 @@ pub struct CefContextMenuParams { impl Clone for CefContextMenuParams { fn clone(&self) -> CefContextMenuParams{ 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); } CefContextMenuParams { @@ -454,7 +464,8 @@ impl Clone for CefContextMenuParams { impl Drop for CefContextMenuParams { 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); } } @@ -469,7 +480,8 @@ impl CefContextMenuParams { } pub unsafe fn from_c_object_addref(c_object: *mut cef_context_menu_params_t) -> CefContextMenuParams { - 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); } CefContextMenuParams { @@ -483,7 +495,8 @@ impl CefContextMenuParams { pub fn c_object_addrefed(&self) -> *mut cef_context_menu_params_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 @@ -491,10 +504,10 @@ impl CefContextMenuParams { } 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 } // @@ -502,7 +515,8 @@ impl CefContextMenuParams { // Coords are relative to the associated RenderView's origin. // pub fn get_xcoord(&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 { @@ -517,7 +531,8 @@ impl CefContextMenuParams { // Coords are relative to the associated RenderView's origin. // pub fn get_ycoord(&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 { @@ -532,7 +547,8 @@ impl CefContextMenuParams { // invoked on. // pub fn get_type_flags(&self) -> types::cef_context_menu_type_flags_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 { @@ -548,7 +564,8 @@ impl CefContextMenuParams { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_link_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 { @@ -564,7 +581,8 @@ impl CefContextMenuParams { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_unfiltered_link_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 { @@ -580,7 +598,8 @@ impl CefContextMenuParams { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_source_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 { @@ -595,7 +614,8 @@ impl CefContextMenuParams { // NULL contents. // pub fn has_image_contents(&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 { @@ -610,7 +630,8 @@ impl CefContextMenuParams { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_page_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 { @@ -625,7 +646,8 @@ impl CefContextMenuParams { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_frame_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 { @@ -641,7 +663,8 @@ impl CefContextMenuParams { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_frame_charset(&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 { @@ -655,7 +678,8 @@ impl CefContextMenuParams { // Returns the type of context node that the context menu was invoked on. // pub fn get_media_type(&self) -> types::cef_context_menu_media_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 { @@ -671,7 +695,8 @@ impl CefContextMenuParams { // pub fn get_media_state_flags( &self) -> types::cef_context_menu_media_state_flags_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 { @@ -687,7 +712,8 @@ impl CefContextMenuParams { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_selection_text(&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 { @@ -703,7 +729,8 @@ impl CefContextMenuParams { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_misspelled_word(&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 { @@ -720,7 +747,8 @@ impl CefContextMenuParams { // pub fn get_dictionary_suggestions(&self, suggestions: Vec) -> 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 { @@ -735,7 +763,8 @@ impl CefContextMenuParams { // Returns true (1) if the context menu was invoked on an editable node. // pub fn is_editable(&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 { @@ -750,7 +779,8 @@ impl CefContextMenuParams { // spell-check is enabled. // pub fn is_spell_check_enabled(&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 { @@ -766,7 +796,8 @@ impl CefContextMenuParams { // pub fn get_edit_state_flags( &self) -> types::cef_context_menu_edit_state_flags_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 { @@ -793,7 +824,8 @@ impl CefWrap<*mut cef_context_menu_params_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_context_menu_params_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefContextMenuParams::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_cookie.rs b/ports/cef/interfaces/cef_cookie.rs index 38291a8b7c9..1b1090e9499 100644 --- a/ports/cef/interfaces/cef_cookie.rs +++ b/ports/cef/interfaces/cef_cookie.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -138,13 +139,13 @@ pub struct _cef_cookie_manager_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_cookie_manager_t = _cef_cookie_manager_t; @@ -160,7 +161,8 @@ pub struct CefCookieManager { impl Clone for CefCookieManager { fn clone(&self) -> CefCookieManager{ 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); } CefCookieManager { @@ -173,7 +175,8 @@ impl Clone for CefCookieManager { impl Drop for CefCookieManager { 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); } } @@ -188,7 +191,8 @@ impl CefCookieManager { } pub unsafe fn from_c_object_addref(c_object: *mut cef_cookie_manager_t) -> CefCookieManager { - 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); } CefCookieManager { @@ -202,7 +206,8 @@ impl CefCookieManager { pub fn c_object_addrefed(&self) -> *mut cef_cookie_manager_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 @@ -210,10 +215,10 @@ impl CefCookieManager { } 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 } // @@ -224,7 +229,8 @@ impl CefCookieManager { // pub fn set_supported_schemes(&self, schemes: Vec, callback: interfaces::CefCompletionCallback) -> () { - 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 +249,8 @@ impl CefCookieManager { // pub fn visit_all_cookies(&self, visitor: interfaces::CefCookieVisitor) -> 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 { @@ -263,7 +270,8 @@ impl CefCookieManager { // pub fn visit_url_cookies(&self, url: &[u16], includeHttpOnly: libc::c_int, visitor: interfaces::CefCookieVisitor) -> 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 { @@ -287,7 +295,8 @@ impl CefCookieManager { // pub fn set_cookie(&self, url: &[u16], cookie: &interfaces::CefCookie, callback: interfaces::CefSetCookieCallback) -> 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 { @@ -313,7 +322,8 @@ impl CefCookieManager { // pub fn delete_cookies(&self, url: &[u16], cookie_name: &[u16], callback: interfaces::CefDeleteCookiesCallback) -> 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 { @@ -339,7 +349,8 @@ impl CefCookieManager { pub fn set_storage_path(&self, path: &[u16], persist_session_cookies: libc::c_int, callback: interfaces::CefCompletionCallback) -> 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 { @@ -359,7 +370,8 @@ impl CefCookieManager { // pub fn flush_store(&self, callback: interfaces::CefCompletionCallback) -> 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 { @@ -424,7 +436,8 @@ impl CefWrap<*mut cef_cookie_manager_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_cookie_manager_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefCookieManager::from_c_object_addref(c_object)) @@ -458,13 +471,13 @@ pub struct _cef_cookie_visitor_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_cookie_visitor_t = _cef_cookie_visitor_t; @@ -480,7 +493,8 @@ pub struct CefCookieVisitor { impl Clone for CefCookieVisitor { fn clone(&self) -> CefCookieVisitor{ 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); } CefCookieVisitor { @@ -493,7 +507,8 @@ impl Clone for CefCookieVisitor { impl Drop for CefCookieVisitor { 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); } } @@ -508,7 +523,8 @@ impl CefCookieVisitor { } pub unsafe fn from_c_object_addref(c_object: *mut cef_cookie_visitor_t) -> CefCookieVisitor { - 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); } CefCookieVisitor { @@ -522,7 +538,8 @@ impl CefCookieVisitor { pub fn c_object_addrefed(&self) -> *mut cef_cookie_visitor_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 @@ -530,10 +547,10 @@ impl CefCookieVisitor { } 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 } // @@ -545,7 +562,8 @@ impl CefCookieVisitor { // pub fn visit(&self, cookie: &interfaces::CefCookie, count: libc::c_int, total: libc::c_int, deleteCookie: &mut libc::c_int) -> 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 { @@ -576,7 +594,8 @@ impl CefWrap<*mut cef_cookie_visitor_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_cookie_visitor_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefCookieVisitor::from_c_object_addref(c_object)) @@ -606,13 +625,13 @@ pub struct _cef_set_cookie_callback_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_set_cookie_callback_t = _cef_set_cookie_callback_t; @@ -628,7 +647,8 @@ pub struct CefSetCookieCallback { impl Clone for CefSetCookieCallback { fn clone(&self) -> CefSetCookieCallback{ 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); } CefSetCookieCallback { @@ -641,7 +661,8 @@ impl Clone for CefSetCookieCallback { impl Drop for CefSetCookieCallback { 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); } } @@ -656,7 +677,8 @@ impl CefSetCookieCallback { } pub unsafe fn from_c_object_addref(c_object: *mut cef_set_cookie_callback_t) -> CefSetCookieCallback { - 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); } CefSetCookieCallback { @@ -670,7 +692,8 @@ impl CefSetCookieCallback { pub fn c_object_addrefed(&self) -> *mut cef_set_cookie_callback_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 @@ -678,10 +701,10 @@ impl CefSetCookieCallback { } 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 } // @@ -689,7 +712,8 @@ impl CefSetCookieCallback { // the cookie was set successfully. // pub fn on_complete(&self, success: 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 { @@ -717,7 +741,8 @@ impl CefWrap<*mut cef_set_cookie_callback_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_set_cookie_callback_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefSetCookieCallback::from_c_object_addref(c_object)) @@ -748,13 +773,13 @@ pub struct _cef_delete_cookies_callback_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_delete_cookies_callback_t = _cef_delete_cookies_callback_t; @@ -770,7 +795,8 @@ pub struct CefDeleteCookiesCallback { impl Clone for CefDeleteCookiesCallback { fn clone(&self) -> CefDeleteCookiesCallback{ 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); } CefDeleteCookiesCallback { @@ -783,7 +809,8 @@ impl Clone for CefDeleteCookiesCallback { impl Drop for CefDeleteCookiesCallback { 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); } } @@ -798,7 +825,8 @@ impl CefDeleteCookiesCallback { } pub unsafe fn from_c_object_addref(c_object: *mut cef_delete_cookies_callback_t) -> CefDeleteCookiesCallback { - 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); } CefDeleteCookiesCallback { @@ -812,7 +840,8 @@ impl CefDeleteCookiesCallback { pub fn c_object_addrefed(&self) -> *mut cef_delete_cookies_callback_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 @@ -820,10 +849,10 @@ impl CefDeleteCookiesCallback { } 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 } // @@ -831,7 +860,8 @@ impl CefDeleteCookiesCallback { // number of cookies that were deleted or -1 if unknown. // pub fn on_complete(&self, num_deleted: 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 { @@ -859,7 +889,8 @@ impl CefWrap<*mut cef_delete_cookies_callback_t> for Option Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefDeleteCookiesCallback::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_dialog_handler.rs b/ports/cef/interfaces/cef_dialog_handler.rs index d6db8bfd7f6..c64634e061e 100644 --- a/ports/cef/interfaces/cef_dialog_handler.rs +++ b/ports/cef/interfaces/cef_dialog_handler.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -75,13 +76,13 @@ pub struct _cef_file_dialog_callback_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_file_dialog_callback_t = _cef_file_dialog_callback_t; @@ -96,7 +97,8 @@ pub struct CefFileDialogCallback { impl Clone for CefFileDialogCallback { fn clone(&self) -> CefFileDialogCallback{ 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); } CefFileDialogCallback { @@ -109,7 +111,8 @@ impl Clone for CefFileDialogCallback { impl Drop for CefFileDialogCallback { 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); } } @@ -124,7 +127,8 @@ impl CefFileDialogCallback { } pub unsafe fn from_c_object_addref(c_object: *mut cef_file_dialog_callback_t) -> CefFileDialogCallback { - 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); } CefFileDialogCallback { @@ -138,7 +142,8 @@ impl CefFileDialogCallback { pub fn c_object_addrefed(&self) -> *mut cef_file_dialog_callback_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 @@ -146,10 +151,10 @@ impl CefFileDialogCallback { } 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 } // @@ -161,7 +166,8 @@ impl CefFileDialogCallback { // pub fn cont(&self, selected_accept_filter: libc::c_int, file_paths: Vec) -> () { - 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 { @@ -177,7 +183,8 @@ impl CefFileDialogCallback { // Cancel the file selection. // pub fn cancel(&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 { @@ -204,7 +211,8 @@ impl CefWrap<*mut cef_file_dialog_callback_t> for Option } } unsafe fn to_rust(c_object: *mut cef_file_dialog_callback_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefFileDialogCallback::from_c_object_addref(c_object)) @@ -250,13 +258,13 @@ pub struct _cef_dialog_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_dialog_handler_t = _cef_dialog_handler_t; @@ -272,7 +280,8 @@ pub struct CefDialogHandler { impl Clone for CefDialogHandler { fn clone(&self) -> CefDialogHandler{ 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); } CefDialogHandler { @@ -285,7 +294,8 @@ impl Clone for CefDialogHandler { impl Drop for CefDialogHandler { 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); } } @@ -300,7 +310,8 @@ impl CefDialogHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_dialog_handler_t) -> CefDialogHandler { - 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); } CefDialogHandler { @@ -314,7 +325,8 @@ impl CefDialogHandler { pub fn c_object_addrefed(&self) -> *mut cef_dialog_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 @@ -322,10 +334,10 @@ impl CefDialogHandler { } 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 } // @@ -348,7 +360,8 @@ impl CefDialogHandler { default_file_path: &[u16], accept_filters: Vec, selected_accept_filter: libc::c_int, callback: interfaces::CefFileDialogCallback) -> 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 { @@ -382,7 +395,8 @@ impl CefWrap<*mut cef_dialog_handler_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_dialog_handler_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefDialogHandler::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_display_handler.rs b/ports/cef/interfaces/cef_display_handler.rs index 6bfc68d1ca4..1221e0e3889 100644 --- a/ports/cef/interfaces/cef_display_handler.rs +++ b/ports/cef/interfaces/cef_display_handler.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -110,13 +111,13 @@ pub struct _cef_display_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_display_handler_t = _cef_display_handler_t; @@ -132,7 +133,8 @@ pub struct CefDisplayHandler { impl Clone for CefDisplayHandler { fn clone(&self) -> CefDisplayHandler{ 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); } CefDisplayHandler { @@ -145,7 +147,8 @@ impl Clone for CefDisplayHandler { impl Drop for CefDisplayHandler { 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); } } @@ -160,7 +163,8 @@ impl CefDisplayHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_display_handler_t) -> CefDisplayHandler { - 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); } CefDisplayHandler { @@ -174,7 +178,8 @@ impl CefDisplayHandler { pub fn c_object_addrefed(&self) -> *mut cef_display_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 @@ -182,10 +187,10 @@ impl CefDisplayHandler { } 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 } // @@ -193,7 +198,8 @@ impl CefDisplayHandler { // pub fn on_address_change(&self, browser: interfaces::CefBrowser, frame: interfaces::CefFrame, 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 { @@ -211,7 +217,8 @@ impl CefDisplayHandler { // pub fn on_title_change(&self, browser: interfaces::CefBrowser, title: &[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 { @@ -228,7 +235,8 @@ impl CefDisplayHandler { // pub fn on_favicon_urlchange(&self, browser: interfaces::CefBrowser, icon_urls: Vec) -> () { - 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 { @@ -250,7 +258,8 @@ impl CefDisplayHandler { // pub fn on_tooltip(&self, browser: interfaces::CefBrowser, text: *mut types::cef_string_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 { @@ -268,7 +277,8 @@ impl CefDisplayHandler { // pub fn on_status_message(&self, browser: interfaces::CefBrowser, value: &[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 { @@ -286,7 +296,8 @@ impl CefDisplayHandler { // pub fn on_console_message(&self, browser: interfaces::CefBrowser, message: &[u16], source: &[u16], line: libc::c_int) -> 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 { @@ -317,7 +328,8 @@ impl CefWrap<*mut cef_display_handler_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_display_handler_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefDisplayHandler::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_dom.rs b/ports/cef/interfaces/cef_dom.rs index c12fde98f47..6fc2f880675 100644 --- a/ports/cef/interfaces/cef_dom.rs +++ b/ports/cef/interfaces/cef_dom.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -69,13 +70,13 @@ pub struct _cef_domvisitor_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_domvisitor_t = _cef_domvisitor_t; @@ -91,7 +92,8 @@ pub struct CefDOMVisitor { impl Clone for CefDOMVisitor { fn clone(&self) -> CefDOMVisitor{ 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); } CefDOMVisitor { @@ -104,7 +106,8 @@ impl Clone for CefDOMVisitor { impl Drop for CefDOMVisitor { 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); } } @@ -119,7 +122,8 @@ impl CefDOMVisitor { } pub unsafe fn from_c_object_addref(c_object: *mut cef_domvisitor_t) -> CefDOMVisitor { - 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); } CefDOMVisitor { @@ -133,7 +137,8 @@ impl CefDOMVisitor { pub fn c_object_addrefed(&self) -> *mut cef_domvisitor_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 @@ -141,10 +146,10 @@ impl CefDOMVisitor { } 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 } // @@ -155,7 +160,8 @@ impl CefDOMVisitor { // of this function. // pub fn visit(&self, document: interfaces::CefDOMDocument) -> () { - 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 { @@ -183,7 +189,8 @@ impl CefWrap<*mut cef_domvisitor_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_domvisitor_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefDOMVisitor::from_c_object_addref(c_object)) @@ -296,13 +303,13 @@ pub struct _cef_domdocument_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_domdocument_t = _cef_domdocument_t; @@ -318,7 +325,8 @@ pub struct CefDOMDocument { impl Clone for CefDOMDocument { fn clone(&self) -> CefDOMDocument{ 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); } CefDOMDocument { @@ -331,7 +339,8 @@ impl Clone for CefDOMDocument { impl Drop for CefDOMDocument { 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); } } @@ -346,7 +355,8 @@ impl CefDOMDocument { } pub unsafe fn from_c_object_addref(c_object: *mut cef_domdocument_t) -> CefDOMDocument { - 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); } CefDOMDocument { @@ -360,7 +370,8 @@ impl CefDOMDocument { pub fn c_object_addrefed(&self) -> *mut cef_domdocument_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 @@ -368,17 +379,18 @@ impl CefDOMDocument { } 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 the document type. // pub fn get_type(&self) -> types::cef_dom_document_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 { @@ -392,7 +404,8 @@ impl CefDOMDocument { // Returns the root document node. // pub fn get_document(&self) -> interfaces::CefDOMNode { - 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 { @@ -406,7 +419,8 @@ impl CefDOMDocument { // Returns the BODY node of an HTML document. // pub fn get_body(&self) -> interfaces::CefDOMNode { - 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 { @@ -420,7 +434,8 @@ impl CefDOMDocument { // Returns the HEAD node of an HTML document. // pub fn get_head(&self) -> interfaces::CefDOMNode { - 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 { @@ -435,7 +450,8 @@ impl CefDOMDocument { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_title(&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 { @@ -449,7 +465,8 @@ impl CefDOMDocument { // Returns the document element with the specified ID value. // pub fn get_element_by_id(&self, id: &[u16]) -> interfaces::CefDOMNode { - 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 { @@ -464,7 +481,8 @@ impl CefDOMDocument { // Returns the node that currently has keyboard focus. // pub fn get_focused_node(&self) -> interfaces::CefDOMNode { - 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 { @@ -478,7 +496,8 @@ impl CefDOMDocument { // Returns true (1) if a portion of the document is selected. // pub fn has_selection(&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 { @@ -492,7 +511,8 @@ impl CefDOMDocument { // Returns the selection offset within the start node. // pub fn get_selection_start_offset(&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 { @@ -506,7 +526,8 @@ impl CefDOMDocument { // Returns the selection offset within the end node. // pub fn get_selection_end_offset(&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 { @@ -521,7 +542,8 @@ impl CefDOMDocument { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_selection_as_markup(&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 { @@ -536,7 +558,8 @@ impl CefDOMDocument { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_selection_as_text(&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 { @@ -551,7 +574,8 @@ impl CefDOMDocument { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_base_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 { @@ -567,7 +591,8 @@ impl CefDOMDocument { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_complete_url(&self, partialURL: &[u16]) -> 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 { @@ -595,7 +620,8 @@ impl CefWrap<*mut cef_domdocument_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_domdocument_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefDOMDocument::from_c_object_addref(c_object)) @@ -780,13 +806,13 @@ pub struct _cef_domnode_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_domnode_t = _cef_domnode_t; @@ -802,7 +828,8 @@ pub struct CefDOMNode { impl Clone for CefDOMNode { fn clone(&self) -> CefDOMNode{ 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); } CefDOMNode { @@ -815,7 +842,8 @@ impl Clone for CefDOMNode { impl Drop for CefDOMNode { 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); } } @@ -830,7 +858,8 @@ impl CefDOMNode { } pub unsafe fn from_c_object_addref(c_object: *mut cef_domnode_t) -> CefDOMNode { - 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); } CefDOMNode { @@ -844,7 +873,8 @@ impl CefDOMNode { pub fn c_object_addrefed(&self) -> *mut cef_domnode_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 @@ -852,17 +882,18 @@ impl CefDOMNode { } 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 the type for this node. // pub fn get_type(&self) -> types::cef_dom_node_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 { @@ -876,7 +907,8 @@ impl CefDOMNode { // Returns true (1) if this is a text node. // pub fn is_text(&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 { @@ -890,7 +922,8 @@ impl CefDOMNode { // Returns true (1) if this is an element node. // pub fn is_element(&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 { @@ -904,7 +937,8 @@ impl CefDOMNode { // Returns true (1) if this is an editable node. // pub fn is_editable(&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 { @@ -918,7 +952,8 @@ impl CefDOMNode { // Returns true (1) if this is a form control element node. // pub fn is_form_control_element(&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 { @@ -933,7 +968,8 @@ impl CefDOMNode { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_form_control_element_type(&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 { @@ -948,7 +984,8 @@ impl CefDOMNode { // object. // pub fn is_same(&self, that: interfaces::CefDOMNode) -> 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 { @@ -964,7 +1001,8 @@ impl CefDOMNode { // // 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 { @@ -979,7 +1017,8 @@ impl CefDOMNode { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_value(&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 { @@ -993,7 +1032,8 @@ impl CefDOMNode { // Set the value of this node. Returns true (1) on success. // pub fn set_value(&self, value: &[u16]) -> 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 { @@ -1009,7 +1049,8 @@ impl CefDOMNode { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_as_markup(&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 { @@ -1023,7 +1064,8 @@ impl CefDOMNode { // Returns the document associated with this node. // pub fn get_document(&self) -> interfaces::CefDOMDocument { - 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 { @@ -1037,7 +1079,8 @@ impl CefDOMNode { // Returns the parent node. // pub fn get_parent(&self) -> interfaces::CefDOMNode { - 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 { @@ -1051,7 +1094,8 @@ impl CefDOMNode { // Returns the previous sibling node. // pub fn get_previous_sibling(&self) -> interfaces::CefDOMNode { - 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 { @@ -1065,7 +1109,8 @@ impl CefDOMNode { // Returns the next sibling node. // pub fn get_next_sibling(&self) -> interfaces::CefDOMNode { - 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 { @@ -1079,7 +1124,8 @@ impl CefDOMNode { // Returns true (1) if this node has child nodes. // pub fn has_children(&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 { @@ -1093,7 +1139,8 @@ impl CefDOMNode { // Return the first child node. // pub fn get_first_child(&self) -> interfaces::CefDOMNode { - 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 { @@ -1107,7 +1154,8 @@ impl CefDOMNode { // Returns the last child node. // pub fn get_last_child(&self) -> interfaces::CefDOMNode { - 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 { @@ -1125,7 +1173,8 @@ impl CefDOMNode { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_element_tag_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 { @@ -1139,7 +1188,8 @@ impl CefDOMNode { // Returns true (1) if this element has attributes. // pub fn has_element_attributes(&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 { @@ -1153,7 +1203,8 @@ impl CefDOMNode { // Returns true (1) if this element has an attribute named |attrName|. // pub fn has_element_attribute(&self, attrName: &[u16]) -> 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 { @@ -1169,7 +1220,8 @@ impl CefDOMNode { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_element_attribute(&self, attrName: &[u16]) -> 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 { @@ -1184,7 +1236,8 @@ impl CefDOMNode { // Returns a map of all element attributes. // pub fn get_element_attributes(&self, attrMap: HashMap) -> () { - 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 { @@ -1201,7 +1254,8 @@ impl CefDOMNode { // pub fn set_element_attribute(&self, attrName: &[u16], value: &[u16]) -> 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 { @@ -1218,7 +1272,8 @@ impl CefDOMNode { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_element_inner_text(&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 { @@ -1245,7 +1300,8 @@ impl CefWrap<*mut cef_domnode_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_domnode_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefDOMNode::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_download_handler.rs b/ports/cef/interfaces/cef_download_handler.rs index 8555f0435a4..7dce76b2ae0 100644 --- a/ports/cef/interfaces/cef_download_handler.rs +++ b/ports/cef/interfaces/cef_download_handler.rs @@ -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_before_download_callback_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_before_download_callback_t = _cef_before_download_callback_t; @@ -89,7 +90,8 @@ pub struct CefBeforeDownloadCallback { impl Clone for CefBeforeDownloadCallback { fn clone(&self) -> CefBeforeDownloadCallback{ 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); } CefBeforeDownloadCallback { @@ -102,7 +104,8 @@ impl Clone for CefBeforeDownloadCallback { impl Drop for CefBeforeDownloadCallback { 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); } } @@ -117,7 +120,8 @@ impl CefBeforeDownloadCallback { } pub unsafe fn from_c_object_addref(c_object: *mut cef_before_download_callback_t) -> CefBeforeDownloadCallback { - 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); } CefBeforeDownloadCallback { @@ -131,7 +135,8 @@ impl CefBeforeDownloadCallback { pub fn c_object_addrefed(&self) -> *mut cef_before_download_callback_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 @@ -139,10 +144,10 @@ impl CefBeforeDownloadCallback { } 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 } // @@ -152,7 +157,8 @@ impl CefBeforeDownloadCallback { // (1) if you do wish to show the default "Save As" dialog. // pub fn cont(&self, download_path: &[u16], show_dialog: 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 { @@ -181,7 +187,8 @@ impl CefWrap<*mut cef_before_download_callback_t> for Option Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefBeforeDownloadCallback::from_c_object_addref(c_object)) @@ -221,13 +228,13 @@ pub struct _cef_download_item_callback_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_download_item_callback_t = _cef_download_item_callback_t; @@ -242,7 +249,8 @@ pub struct CefDownloadItemCallback { impl Clone for CefDownloadItemCallback { fn clone(&self) -> CefDownloadItemCallback{ 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); } CefDownloadItemCallback { @@ -255,7 +263,8 @@ impl Clone for CefDownloadItemCallback { impl Drop for CefDownloadItemCallback { 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); } } @@ -270,7 +279,8 @@ impl CefDownloadItemCallback { } pub unsafe fn from_c_object_addref(c_object: *mut cef_download_item_callback_t) -> CefDownloadItemCallback { - 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); } CefDownloadItemCallback { @@ -284,7 +294,8 @@ impl CefDownloadItemCallback { pub fn c_object_addrefed(&self) -> *mut cef_download_item_callback_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 @@ -292,17 +303,18 @@ impl CefDownloadItemCallback { } 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 } // // Call to cancel the download. // pub fn cancel(&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 { @@ -316,7 +328,8 @@ impl CefDownloadItemCallback { // Call to pause the download. // pub fn pause(&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 { @@ -330,7 +343,8 @@ impl CefDownloadItemCallback { // Call to resume the download. // pub fn resume(&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 { @@ -357,7 +371,8 @@ impl CefWrap<*mut cef_download_item_callback_t> for Option Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefDownloadItemCallback::from_c_object_addref(c_object)) @@ -407,13 +422,13 @@ pub struct _cef_download_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_download_handler_t = _cef_download_handler_t; @@ -429,7 +444,8 @@ pub struct CefDownloadHandler { impl Clone for CefDownloadHandler { fn clone(&self) -> CefDownloadHandler{ 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); } CefDownloadHandler { @@ -442,7 +458,8 @@ impl Clone for CefDownloadHandler { impl Drop for CefDownloadHandler { 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); } } @@ -457,7 +474,8 @@ impl CefDownloadHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_download_handler_t) -> CefDownloadHandler { - 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); } CefDownloadHandler { @@ -471,7 +489,8 @@ impl CefDownloadHandler { pub fn c_object_addrefed(&self) -> *mut cef_download_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 @@ -479,10 +498,10 @@ impl CefDownloadHandler { } 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 } // @@ -495,7 +514,8 @@ impl CefDownloadHandler { pub fn on_before_download(&self, browser: interfaces::CefBrowser, download_item: interfaces::CefDownloadItem, suggested_name: &[u16], callback: interfaces::CefBeforeDownloadCallback) -> () { - 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 { @@ -519,7 +539,8 @@ impl CefDownloadHandler { pub fn on_download_updated(&self, browser: interfaces::CefBrowser, download_item: interfaces::CefDownloadItem, callback: interfaces::CefDownloadItemCallback) -> () { - 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 { @@ -549,7 +570,8 @@ impl CefWrap<*mut cef_download_handler_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_download_handler_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefDownloadHandler::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_download_item.rs b/ports/cef/interfaces/cef_download_item.rs index 55513327f74..88ca0fc16d9 100644 --- a/ports/cef/interfaces/cef_download_item.rs +++ b/ports/cef/interfaces/cef_download_item.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -167,13 +168,13 @@ pub struct _cef_download_item_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_download_item_t = _cef_download_item_t; @@ -188,7 +189,8 @@ pub struct CefDownloadItem { impl Clone for CefDownloadItem { fn clone(&self) -> CefDownloadItem{ 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); } CefDownloadItem { @@ -201,7 +203,8 @@ impl Clone for CefDownloadItem { impl Drop for CefDownloadItem { 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); } } @@ -216,7 +219,8 @@ impl CefDownloadItem { } pub unsafe fn from_c_object_addref(c_object: *mut cef_download_item_t) -> CefDownloadItem { - 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); } CefDownloadItem { @@ -230,7 +234,8 @@ impl CefDownloadItem { pub fn c_object_addrefed(&self) -> *mut cef_download_item_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 @@ -238,10 +243,10 @@ impl CefDownloadItem { } 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 } // @@ -249,7 +254,8 @@ impl CefDownloadItem { // 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 { @@ -263,7 +269,8 @@ impl CefDownloadItem { // Returns true (1) if the download is in progress. // pub fn is_in_progress(&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 { @@ -277,7 +284,8 @@ impl CefDownloadItem { // Returns true (1) if the download is complete. // pub fn is_complete(&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 { @@ -291,7 +299,8 @@ impl CefDownloadItem { // Returns true (1) if the download has been canceled or interrupted. // pub fn is_canceled(&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 { @@ -305,7 +314,8 @@ impl CefDownloadItem { // Returns a simple speed estimate in bytes/s. // pub fn get_current_speed(&self) -> i64 { - 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 { @@ -320,7 +330,8 @@ impl CefDownloadItem { // unknown. // pub fn get_percent_complete(&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 { @@ -334,7 +345,8 @@ impl CefDownloadItem { // Returns the total number of bytes. // pub fn get_total_bytes(&self) -> i64 { - 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 { @@ -348,7 +360,8 @@ impl CefDownloadItem { // Returns the number of received bytes. // pub fn get_received_bytes(&self) -> i64 { - 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 CefDownloadItem { // Returns the time that the download started. // pub fn get_start_time(&self) -> types::cef_time_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 { @@ -376,7 +390,8 @@ impl CefDownloadItem { // Returns the time that the download ended. // pub fn get_end_time(&self) -> types::cef_time_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 { @@ -391,7 +406,8 @@ impl CefDownloadItem { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_full_path(&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 { @@ -405,7 +421,8 @@ impl CefDownloadItem { // Returns the unique identifier for this download. // pub fn get_id(&self) -> u32 { - 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 { @@ -420,7 +437,8 @@ impl CefDownloadItem { // // 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 { @@ -435,7 +453,8 @@ impl CefDownloadItem { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_original_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 { @@ -450,7 +469,8 @@ impl CefDownloadItem { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_suggested_file_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 { @@ -465,7 +485,8 @@ impl CefDownloadItem { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_content_disposition(&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 { @@ -480,7 +501,8 @@ impl CefDownloadItem { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_mime_type(&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 { @@ -507,7 +529,8 @@ impl CefWrap<*mut cef_download_item_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_download_item_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefDownloadItem::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_drag_data.rs b/ports/cef/interfaces/cef_drag_data.rs index 5983a7a7098..2c4d3ec1349 100644 --- a/ports/cef/interfaces/cef_drag_data.rs +++ b/ports/cef/interfaces/cef_drag_data.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -204,13 +205,13 @@ pub struct _cef_drag_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_drag_data_t = _cef_drag_data_t; @@ -226,7 +227,8 @@ pub struct CefDragData { impl Clone for CefDragData { fn clone(&self) -> CefDragData{ 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); } CefDragData { @@ -239,7 +241,8 @@ impl Clone for CefDragData { impl Drop for CefDragData { 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); } } @@ -254,7 +257,8 @@ impl CefDragData { } pub unsafe fn from_c_object_addref(c_object: *mut cef_drag_data_t) -> CefDragData { - 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); } CefDragData { @@ -268,7 +272,8 @@ impl CefDragData { pub fn c_object_addrefed(&self) -> *mut cef_drag_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 @@ -276,17 +281,18 @@ impl CefDragData { } 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 a copy of the current object. // pub fn clone(&self) -> interfaces::CefDragData { - 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 { @@ -300,7 +306,8 @@ impl CefDragData { // 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 { @@ -314,7 +321,8 @@ impl CefDragData { // Returns true (1) if the drag data is a link. // pub fn is_link(&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 { @@ -328,7 +336,8 @@ impl CefDragData { // Returns true (1) if the drag data is a text or html fragment. // pub fn is_fragment(&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 { @@ -342,7 +351,8 @@ impl CefDragData { // Returns true (1) if the drag data is a file. // pub fn is_file(&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 { @@ -357,7 +367,8 @@ impl CefDragData { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_link_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 { @@ -372,7 +383,8 @@ impl CefDragData { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_link_title(&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 { @@ -387,7 +399,8 @@ impl CefDragData { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_link_metadata(&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 { @@ -402,7 +415,8 @@ impl CefDragData { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_fragment_text(&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 { @@ -417,7 +431,8 @@ impl CefDragData { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_fragment_html(&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 { @@ -433,7 +448,8 @@ impl CefDragData { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_fragment_base_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 { @@ -448,7 +464,8 @@ impl CefDragData { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_file_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 { @@ -466,7 +483,8 @@ impl CefDragData { // pub fn get_file_contents(&self, writer: interfaces::CefStreamWriter) -> 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 { @@ -482,7 +500,8 @@ impl CefDragData { // window. // pub fn get_file_names(&self, names: Vec) -> 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 { @@ -497,7 +516,8 @@ impl CefDragData { // Set the link URL that is being dragged. // pub fn set_link_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 { @@ -512,7 +532,8 @@ impl CefDragData { // Set the title associated with the link being dragged. // pub fn set_link_title(&self, title: &[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 { @@ -527,7 +548,8 @@ impl CefDragData { // Set the metadata associated with the link being dragged. // pub fn set_link_metadata(&self, data: &[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 { @@ -542,7 +564,8 @@ impl CefDragData { // Set the plain text fragment that is being dragged. // pub fn set_fragment_text(&self, text: &[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 { @@ -557,7 +580,8 @@ impl CefDragData { // Set the text/html fragment that is being dragged. // pub fn set_fragment_html(&self, html: &[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 { @@ -572,7 +596,8 @@ impl CefDragData { // Set the base URL that the fragment came from. // pub fn set_fragment_base_url(&self, base_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 { @@ -589,7 +614,8 @@ impl CefDragData { // to drag in this kind of data. // pub fn reset_file_contents(&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 { @@ -603,7 +629,8 @@ impl CefDragData { // Add a file that is being dragged into the webview. // pub fn add_file(&self, path: &[u16], display_name: &[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 { @@ -643,7 +670,8 @@ impl CefWrap<*mut cef_drag_data_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_drag_data_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefDragData::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_drag_handler.rs b/ports/cef/interfaces/cef_drag_handler.rs index 6236a11056b..15fd7f37d8f 100644 --- a/ports/cef/interfaces/cef_drag_handler.rs +++ b/ports/cef/interfaces/cef_drag_handler.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -70,13 +71,13 @@ pub struct _cef_drag_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_drag_handler_t = _cef_drag_handler_t; @@ -92,7 +93,8 @@ pub struct CefDragHandler { impl Clone for CefDragHandler { fn clone(&self) -> CefDragHandler{ 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); } CefDragHandler { @@ -105,7 +107,8 @@ impl Clone for CefDragHandler { impl Drop for CefDragHandler { 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); } } @@ -120,7 +123,8 @@ impl CefDragHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_drag_handler_t) -> CefDragHandler { - 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); } CefDragHandler { @@ -134,7 +138,8 @@ impl CefDragHandler { pub fn c_object_addrefed(&self) -> *mut cef_drag_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 @@ -142,10 +147,10 @@ impl CefDragHandler { } 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 } // @@ -157,7 +162,8 @@ impl CefDragHandler { pub fn on_drag_enter(&self, browser: interfaces::CefBrowser, dragData: interfaces::CefDragData, mask: types::cef_drag_operations_mask_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 { @@ -187,7 +193,8 @@ impl CefWrap<*mut cef_drag_handler_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_drag_handler_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefDragHandler::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_find_handler.rs b/ports/cef/interfaces/cef_find_handler.rs index b1afd79ff11..05155095451 100644 --- a/ports/cef/interfaces/cef_find_handler.rs +++ b/ports/cef/interfaces/cef_find_handler.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -72,13 +73,13 @@ pub struct _cef_find_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_find_handler_t = _cef_find_handler_t; @@ -94,7 +95,8 @@ pub struct CefFindHandler { impl Clone for CefFindHandler { fn clone(&self) -> CefFindHandler{ 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); } CefFindHandler { @@ -107,7 +109,8 @@ impl Clone for CefFindHandler { impl Drop for CefFindHandler { 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 CefFindHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_find_handler_t) -> CefFindHandler { - 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); } CefFindHandler { @@ -136,7 +140,8 @@ impl CefFindHandler { pub fn c_object_addrefed(&self) -> *mut cef_find_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 @@ -144,10 +149,10 @@ impl CefFindHandler { } 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 } // @@ -162,7 +167,8 @@ impl CefFindHandler { identifier: libc::c_int, count: libc::c_int, selectionRect: &types::cef_rect_t, activeMatchOrdinal: libc::c_int, finalUpdate: 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 { @@ -195,7 +201,8 @@ impl CefWrap<*mut cef_find_handler_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_find_handler_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefFindHandler::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_focus_handler.rs b/ports/cef/interfaces/cef_focus_handler.rs index 6695253dbb4..b5d1d6072b0 100644 --- a/ports/cef/interfaces/cef_focus_handler.rs +++ b/ports/cef/interfaces/cef_focus_handler.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -83,13 +84,13 @@ pub struct _cef_focus_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_focus_handler_t = _cef_focus_handler_t; @@ -105,7 +106,8 @@ pub struct CefFocusHandler { impl Clone for CefFocusHandler { fn clone(&self) -> CefFocusHandler{ 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); } CefFocusHandler { @@ -118,7 +120,8 @@ impl Clone for CefFocusHandler { impl Drop for CefFocusHandler { 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); } } @@ -133,7 +136,8 @@ impl CefFocusHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_focus_handler_t) -> CefFocusHandler { - 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); } CefFocusHandler { @@ -147,7 +151,8 @@ impl CefFocusHandler { pub fn c_object_addrefed(&self) -> *mut cef_focus_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 @@ -155,10 +160,10 @@ impl CefFocusHandler { } 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 } // @@ -169,7 +174,8 @@ impl CefFocusHandler { // pub fn on_take_focus(&self, browser: interfaces::CefBrowser, next: 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 CefFocusHandler { // pub fn on_set_focus(&self, browser: interfaces::CefBrowser, source: types::cef_focus_source_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 { @@ -204,7 +211,8 @@ impl CefFocusHandler { // Called when the browser component has received focus. // pub fn on_got_focus(&self, browser: interfaces::CefBrowser) -> () { - 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 { @@ -232,7 +240,8 @@ impl CefWrap<*mut cef_focus_handler_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_focus_handler_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefFocusHandler::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_frame.rs b/ports/cef/interfaces/cef_frame.rs index 0ba77018d20..62fa1bb8d0e 100644 --- a/ports/cef/interfaces/cef_frame.rs +++ b/ports/cef/interfaces/cef_frame.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -214,13 +215,13 @@ pub struct _cef_frame_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_frame_t = _cef_frame_t; @@ -238,7 +239,8 @@ pub struct CefFrame { impl Clone for CefFrame { fn clone(&self) -> CefFrame{ 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); } CefFrame { @@ -251,7 +253,8 @@ impl Clone for CefFrame { impl Drop for CefFrame { 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); } } @@ -266,7 +269,8 @@ impl CefFrame { } pub unsafe fn from_c_object_addref(c_object: *mut cef_frame_t) -> CefFrame { - 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); } CefFrame { @@ -280,7 +284,8 @@ impl CefFrame { pub fn c_object_addrefed(&self) -> *mut cef_frame_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 @@ -288,17 +293,18 @@ impl CefFrame { } 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 } // // True if this object is currently attached to a valid frame. // 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 { @@ -312,7 +318,8 @@ impl CefFrame { // Execute undo in this frame. // pub fn undo(&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 { @@ -326,7 +333,8 @@ impl CefFrame { // Execute redo in this frame. // pub fn redo(&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 { @@ -340,7 +348,8 @@ impl CefFrame { // Execute cut in this frame. // pub fn cut(&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 { @@ -354,7 +363,8 @@ impl CefFrame { // Execute copy in this frame. // pub fn copy(&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 { @@ -368,7 +378,8 @@ impl CefFrame { // Execute paste in this frame. // pub fn paste(&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 { @@ -382,7 +393,8 @@ impl CefFrame { // Execute delete in this frame. // pub fn del(&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 { @@ -396,7 +408,8 @@ impl CefFrame { // Execute select all in this frame. // pub fn select_all(&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 { @@ -412,7 +425,8 @@ impl CefFrame { // browser process. // pub fn view_source(&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 { @@ -427,7 +441,8 @@ impl CefFrame { // visitor. // pub fn get_source(&self, visitor: interfaces::CefStringVisitor) -> () { - 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 +458,8 @@ impl CefFrame { // visitor. // pub fn get_text(&self, visitor: interfaces::CefStringVisitor) -> () { - 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 +474,8 @@ impl CefFrame { // Load the request represented by the |request| object. // pub fn load_request(&self, request: interfaces::CefRequest) -> () { - 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 { @@ -473,7 +490,8 @@ impl CefFrame { // Load the specified |url|. // pub fn load_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 { @@ -490,7 +508,8 @@ impl CefFrame { // link clicks and web security restrictions may not behave as expected. // pub fn load_string(&self, string_val: &[u16], 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 { @@ -511,7 +530,8 @@ impl CefFrame { // pub fn execute_java_script(&self, code: &[u16], script_url: &[u16], start_line: 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 { @@ -528,7 +548,8 @@ impl CefFrame { // Returns true (1) if this is the main (top-level) frame. // pub fn is_main(&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 { @@ -542,7 +563,8 @@ impl CefFrame { // Returns true (1) if this is the focused frame. // pub fn is_focused(&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 { @@ -561,7 +583,8 @@ impl CefFrame { // // 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 { @@ -575,7 +598,8 @@ impl CefFrame { // Returns the globally unique identifier for this frame. // pub fn get_identifier(&self) -> i64 { - 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 { @@ -590,7 +614,8 @@ impl CefFrame { // frame. // pub fn get_parent(&self) -> 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 { @@ -605,7 +630,8 @@ impl CefFrame { // // 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 { @@ -619,7 +645,8 @@ impl CefFrame { // Returns the browser that this frame belongs to. // pub fn get_browser(&self) -> interfaces::CefBrowser { - 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 { @@ -634,7 +661,8 @@ impl CefFrame { // called from the render process. // pub fn get_v8context(&self) -> interfaces::CefV8Context { - 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 { @@ -649,7 +677,8 @@ impl CefFrame { // process. // pub fn visit_dom(&self, visitor: interfaces::CefDOMVisitor) -> () { - 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 { @@ -677,7 +706,8 @@ impl CefWrap<*mut cef_frame_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_frame_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefFrame::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_geolocation.rs b/ports/cef/interfaces/cef_geolocation.rs index 8ef1072a103..0b4b54a3daa 100644 --- a/ports/cef/interfaces/cef_geolocation.rs +++ b/ports/cef/interfaces/cef_geolocation.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -67,13 +68,13 @@ pub struct _cef_get_geolocation_callback_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_get_geolocation_callback_t = _cef_get_geolocation_callback_t; @@ -89,7 +90,8 @@ pub struct CefGetGeolocationCallback { impl Clone for CefGetGeolocationCallback { fn clone(&self) -> CefGetGeolocationCallback{ 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); } CefGetGeolocationCallback { @@ -102,7 +104,8 @@ impl Clone for CefGetGeolocationCallback { impl Drop for CefGetGeolocationCallback { 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); } } @@ -117,7 +120,8 @@ impl CefGetGeolocationCallback { } pub unsafe fn from_c_object_addref(c_object: *mut cef_get_geolocation_callback_t) -> CefGetGeolocationCallback { - 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); } CefGetGeolocationCallback { @@ -131,7 +135,8 @@ impl CefGetGeolocationCallback { pub fn c_object_addrefed(&self) -> *mut cef_get_geolocation_callback_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 @@ -139,10 +144,10 @@ impl CefGetGeolocationCallback { } 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 } // @@ -151,7 +156,8 @@ impl CefGetGeolocationCallback { // pub fn on_location_update(&self, position: &interfaces::CefGeoposition) -> ( ) { - 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 { @@ -179,7 +185,8 @@ impl CefWrap<*mut cef_get_geolocation_callback_t> for Option Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefGetGeolocationCallback::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_geolocation_handler.rs b/ports/cef/interfaces/cef_geolocation_handler.rs index a342fd274ac..5214a245c51 100644 --- a/ports/cef/interfaces/cef_geolocation_handler.rs +++ b/ports/cef/interfaces/cef_geolocation_handler.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -65,13 +66,13 @@ pub struct _cef_geolocation_callback_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_geolocation_callback_t = _cef_geolocation_callback_t; @@ -87,7 +88,8 @@ pub struct CefGeolocationCallback { impl Clone for CefGeolocationCallback { fn clone(&self) -> CefGeolocationCallback{ 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); } CefGeolocationCallback { @@ -100,7 +102,8 @@ impl Clone for CefGeolocationCallback { impl Drop for CefGeolocationCallback { 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); } } @@ -115,7 +118,8 @@ impl CefGeolocationCallback { } pub unsafe fn from_c_object_addref(c_object: *mut cef_geolocation_callback_t) -> CefGeolocationCallback { - 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); } CefGeolocationCallback { @@ -129,7 +133,8 @@ impl CefGeolocationCallback { pub fn c_object_addrefed(&self) -> *mut cef_geolocation_callback_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 @@ -137,17 +142,18 @@ impl CefGeolocationCallback { } 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 } // // Call to allow or deny geolocation access. // pub fn cont(&self, allow: 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 { @@ -175,7 +181,8 @@ impl CefWrap<*mut cef_geolocation_callback_t> for Option } } unsafe fn to_rust(c_object: *mut cef_geolocation_callback_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefGeolocationCallback::from_c_object_addref(c_object)) @@ -224,13 +231,13 @@ pub struct _cef_geolocation_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_geolocation_handler_t = _cef_geolocation_handler_t; @@ -247,7 +254,8 @@ pub struct CefGeolocationHandler { impl Clone for CefGeolocationHandler { fn clone(&self) -> CefGeolocationHandler{ 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); } CefGeolocationHandler { @@ -260,7 +268,8 @@ impl Clone for CefGeolocationHandler { impl Drop for CefGeolocationHandler { 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); } } @@ -275,7 +284,8 @@ impl CefGeolocationHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_geolocation_handler_t) -> CefGeolocationHandler { - 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); } CefGeolocationHandler { @@ -289,7 +299,8 @@ impl CefGeolocationHandler { pub fn c_object_addrefed(&self) -> *mut cef_geolocation_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 @@ -297,10 +308,10 @@ impl CefGeolocationHandler { } 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 } // @@ -315,7 +326,8 @@ impl CefGeolocationHandler { browser: interfaces::CefBrowser, requesting_url: &[u16], request_id: libc::c_int, callback: interfaces::CefGeolocationCallback) -> 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 { @@ -337,7 +349,8 @@ impl CefGeolocationHandler { pub fn on_cancel_geolocation_permission(&self, browser: interfaces::CefBrowser, requesting_url: &[u16], request_id: 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 { @@ -367,7 +380,8 @@ impl CefWrap<*mut cef_geolocation_handler_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_geolocation_handler_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefGeolocationHandler::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_jsdialog_handler.rs b/ports/cef/interfaces/cef_jsdialog_handler.rs index 6519ca2302b..bdb24eb6abb 100644 --- a/ports/cef/interfaces/cef_jsdialog_handler.rs +++ b/ports/cef/interfaces/cef_jsdialog_handler.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -66,13 +67,13 @@ pub struct _cef_jsdialog_callback_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_jsdialog_callback_t = _cef_jsdialog_callback_t; @@ -88,7 +89,8 @@ pub struct CefJSDialogCallback { impl Clone for CefJSDialogCallback { fn clone(&self) -> CefJSDialogCallback{ 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); } CefJSDialogCallback { @@ -101,7 +103,8 @@ impl Clone for CefJSDialogCallback { impl Drop for CefJSDialogCallback { 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); } } @@ -116,7 +119,8 @@ impl CefJSDialogCallback { } pub unsafe fn from_c_object_addref(c_object: *mut cef_jsdialog_callback_t) -> CefJSDialogCallback { - 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); } CefJSDialogCallback { @@ -130,7 +134,8 @@ impl CefJSDialogCallback { pub fn c_object_addrefed(&self) -> *mut cef_jsdialog_callback_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 @@ -138,10 +143,10 @@ impl CefJSDialogCallback { } 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 } // @@ -149,7 +154,8 @@ impl CefJSDialogCallback { // was pressed. The |user_input| value should be specified for prompt dialogs. // pub fn cont(&self, success: libc::c_int, user_input: &[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 { @@ -178,7 +184,8 @@ impl CefWrap<*mut cef_jsdialog_callback_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_jsdialog_callback_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefJSDialogCallback::from_c_object_addref(c_object)) @@ -255,13 +262,13 @@ pub struct _cef_jsdialog_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_jsdialog_handler_t = _cef_jsdialog_handler_t; @@ -277,7 +284,8 @@ pub struct CefJSDialogHandler { impl Clone for CefJSDialogHandler { fn clone(&self) -> CefJSDialogHandler{ 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); } CefJSDialogHandler { @@ -290,7 +298,8 @@ impl Clone for CefJSDialogHandler { impl Drop for CefJSDialogHandler { 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); } } @@ -305,7 +314,8 @@ impl CefJSDialogHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_jsdialog_handler_t) -> CefJSDialogHandler { - 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); } CefJSDialogHandler { @@ -319,7 +329,8 @@ impl CefJSDialogHandler { pub fn c_object_addrefed(&self) -> *mut cef_jsdialog_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 @@ -327,10 +338,10 @@ impl CefJSDialogHandler { } 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 } // @@ -353,7 +364,8 @@ impl CefJSDialogHandler { message_text: &[u16], default_prompt_text: &[u16], callback: interfaces::CefJSDialogCallback, suppress_message: &mut libc::c_int) -> 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 { @@ -382,7 +394,8 @@ impl CefJSDialogHandler { pub fn on_before_unload_dialog(&self, browser: interfaces::CefBrowser, message_text: &[u16], is_reload: libc::c_int, callback: interfaces::CefJSDialogCallback) -> 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 { @@ -402,7 +415,8 @@ impl CefJSDialogHandler { // dialogs are currently pending. // pub fn on_reset_dialog_state(&self, browser: interfaces::CefBrowser) -> () { - 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 { @@ -417,7 +431,8 @@ impl CefJSDialogHandler { // Called when the default implementation dialog is closed. // pub fn on_dialog_closed(&self, browser: interfaces::CefBrowser) -> () { - 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 { @@ -445,7 +460,8 @@ impl CefWrap<*mut cef_jsdialog_handler_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_jsdialog_handler_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefJSDialogHandler::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_keyboard_handler.rs b/ports/cef/interfaces/cef_keyboard_handler.rs index 898afec3832..88cf4f2a02b 100644 --- a/ports/cef/interfaces/cef_keyboard_handler.rs +++ b/ports/cef/interfaces/cef_keyboard_handler.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -81,13 +82,13 @@ pub struct _cef_keyboard_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_keyboard_handler_t = _cef_keyboard_handler_t; @@ -103,7 +104,8 @@ pub struct CefKeyboardHandler { impl Clone for CefKeyboardHandler { fn clone(&self) -> CefKeyboardHandler{ 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); } CefKeyboardHandler { @@ -116,7 +118,8 @@ impl Clone for CefKeyboardHandler { impl Drop for CefKeyboardHandler { 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); } } @@ -131,7 +134,8 @@ impl CefKeyboardHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_keyboard_handler_t) -> CefKeyboardHandler { - 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); } CefKeyboardHandler { @@ -145,7 +149,8 @@ impl CefKeyboardHandler { pub fn c_object_addrefed(&self) -> *mut cef_keyboard_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 @@ -153,10 +158,10 @@ impl CefKeyboardHandler { } 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 } // Called before a keyboard event is sent to the renderer. |event| contains @@ -167,7 +172,8 @@ impl CefKeyboardHandler { pub fn on_pre_key_event(&self, browser: interfaces::CefBrowser, event: &interfaces::CefKeyEvent, os_event: types::cef_event_handle_t, is_keyboard_shortcut: &mut libc::c_int) -> 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 { @@ -190,7 +196,8 @@ impl CefKeyboardHandler { pub fn on_key_event(&self, browser: interfaces::CefBrowser, event: &interfaces::CefKeyEvent, os_event: types::cef_event_handle_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 { @@ -220,7 +227,8 @@ impl CefWrap<*mut cef_keyboard_handler_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_keyboard_handler_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefKeyboardHandler::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_life_span_handler.rs b/ports/cef/interfaces/cef_life_span_handler.rs index 92b19e06415..cf2da948869 100644 --- a/ports/cef/interfaces/cef_life_span_handler.rs +++ b/ports/cef/interfaces/cef_life_span_handler.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -175,13 +176,13 @@ pub struct _cef_life_span_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_life_span_handler_t = _cef_life_span_handler_t; @@ -198,7 +199,8 @@ pub struct CefLifeSpanHandler { impl Clone for CefLifeSpanHandler { fn clone(&self) -> CefLifeSpanHandler{ 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); } CefLifeSpanHandler { @@ -211,7 +213,8 @@ impl Clone for CefLifeSpanHandler { impl Drop for CefLifeSpanHandler { 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); } } @@ -226,7 +229,8 @@ impl CefLifeSpanHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_life_span_handler_t) -> CefLifeSpanHandler { - 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); } CefLifeSpanHandler { @@ -240,7 +244,8 @@ impl CefLifeSpanHandler { pub fn c_object_addrefed(&self) -> *mut cef_life_span_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 @@ -248,10 +253,10 @@ impl CefLifeSpanHandler { } 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 } // @@ -280,7 +285,8 @@ impl CefLifeSpanHandler { client: interfaces::CefClient, settings: &mut interfaces::CefBrowserSettings, no_javascript_access: &mut libc::c_int) -> 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 { @@ -305,7 +311,8 @@ impl CefLifeSpanHandler { // Called after a new browser is created. // pub fn on_after_created(&self, browser: interfaces::CefBrowser) -> () { - 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 { @@ -322,7 +329,8 @@ impl CefLifeSpanHandler { // implementation or true (1) to use a custom implementation. // pub fn run_modal(&self, browser: interfaces::CefBrowser) -> 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 { @@ -391,7 +399,8 @@ impl CefLifeSpanHandler { // exist. // pub fn do_close(&self, browser: interfaces::CefBrowser) -> 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 { @@ -411,7 +420,8 @@ impl CefLifeSpanHandler { // additional usage information. // pub fn on_before_close(&self, browser: interfaces::CefBrowser) -> () { - 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 { @@ -439,7 +449,8 @@ impl CefWrap<*mut cef_life_span_handler_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_life_span_handler_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefLifeSpanHandler::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_load_handler.rs b/ports/cef/interfaces/cef_load_handler.rs index 074e07f77f1..d18a0ec3930 100644 --- a/ports/cef/interfaces/cef_load_handler.rs +++ b/ports/cef/interfaces/cef_load_handler.rs @@ -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 { } } unsafe fn to_rust(c_object: *mut cef_load_handler_t) -> Option { - 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)) diff --git a/ports/cef/interfaces/cef_menu_model.rs b/ports/cef/interfaces/cef_menu_model.rs index 367137e04a7..2c686f47576 100644 --- a/ports/cef/interfaces/cef_menu_model.rs +++ b/ports/cef/interfaces/cef_menu_model.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -401,13 +402,13 @@ pub struct _cef_menu_model_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_menu_model_t = _cef_menu_model_t; @@ -425,7 +426,8 @@ pub struct CefMenuModel { impl Clone for CefMenuModel { fn clone(&self) -> CefMenuModel{ 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); } CefMenuModel { @@ -438,7 +440,8 @@ impl Clone for CefMenuModel { impl Drop for CefMenuModel { 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); } } @@ -453,7 +456,8 @@ impl CefMenuModel { } pub unsafe fn from_c_object_addref(c_object: *mut cef_menu_model_t) -> CefMenuModel { - 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); } CefMenuModel { @@ -467,7 +471,8 @@ impl CefMenuModel { pub fn c_object_addrefed(&self) -> *mut cef_menu_model_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 @@ -475,17 +480,18 @@ impl CefMenuModel { } 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 } // // Clears the menu. Returns true (1) on success. // pub fn clear(&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 { @@ -499,7 +505,8 @@ impl CefMenuModel { // Returns the number of items in this menu. // pub fn get_count(&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 { @@ -513,7 +520,8 @@ impl CefMenuModel { // Add a separator to the menu. Returns true (1) on success. // pub fn add_separator(&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 { @@ -528,7 +536,8 @@ impl CefMenuModel { // pub fn add_item(&self, command_id: libc::c_int, label: &[u16]) -> 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 { @@ -545,7 +554,8 @@ impl CefMenuModel { // pub fn add_check_item(&self, command_id: libc::c_int, label: &[u16]) -> 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 { @@ -563,7 +573,8 @@ impl CefMenuModel { // pub fn add_radio_item(&self, command_id: libc::c_int, label: &[u16], group_id: libc::c_int) -> 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 { @@ -581,7 +592,8 @@ impl CefMenuModel { // pub fn add_sub_menu(&self, command_id: libc::c_int, label: &[u16]) -> interfaces::CefMenuModel { - 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 { @@ -598,7 +610,8 @@ impl CefMenuModel { // on success. // pub fn insert_separator_at(&self, index: libc::c_int) -> 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 { @@ -615,7 +628,8 @@ impl CefMenuModel { // pub fn insert_item_at(&self, index: libc::c_int, command_id: libc::c_int, label: &[u16]) -> 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 { @@ -634,7 +648,8 @@ impl CefMenuModel { // pub fn insert_check_item_at(&self, index: libc::c_int, command_id: libc::c_int, label: &[u16]) -> 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 { @@ -655,7 +670,8 @@ impl CefMenuModel { pub fn insert_radio_item_at(&self, index: libc::c_int, command_id: libc::c_int, label: &[u16], group_id: libc::c_int) -> 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 { @@ -675,7 +691,8 @@ impl CefMenuModel { // pub fn insert_sub_menu_at(&self, index: libc::c_int, command_id: libc::c_int, label: &[u16]) -> interfaces::CefMenuModel { - 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 { @@ -693,7 +710,8 @@ impl CefMenuModel { // success. // pub fn remove(&self, command_id: libc::c_int) -> 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 { @@ -708,7 +726,8 @@ impl CefMenuModel { // Removes the item at the specified |index|. Returns true (1) on success. // pub fn remove_at(&self, index: libc::c_int) -> 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 { @@ -724,7 +743,8 @@ impl CefMenuModel { // found due to the command id not existing in the menu. // pub fn get_index_of(&self, command_id: libc::c_int) -> 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 { @@ -740,7 +760,8 @@ impl CefMenuModel { // invalid range or the index being a separator. // pub fn get_command_id_at(&self, index: libc::c_int) -> 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 { @@ -756,7 +777,8 @@ impl CefMenuModel { // pub fn set_command_id_at(&self, index: libc::c_int, command_id: libc::c_int) -> 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 { @@ -773,7 +795,8 @@ impl CefMenuModel { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_label(&self, command_id: libc::c_int) -> 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 { @@ -790,7 +813,8 @@ impl CefMenuModel { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_label_at(&self, index: libc::c_int) -> 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 { @@ -806,7 +830,8 @@ impl CefMenuModel { // pub fn set_label(&self, command_id: libc::c_int, label: &[u16]) -> 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 { @@ -822,7 +847,8 @@ impl CefMenuModel { // Set the label at the specified |index|. Returns true (1) on success. // pub fn set_label_at(&self, index: libc::c_int, label: &[u16]) -> 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 { @@ -839,7 +865,8 @@ impl CefMenuModel { // pub fn get_type(&self, command_id: libc::c_int) -> types::cef_menu_item_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 { @@ -854,7 +881,8 @@ impl CefMenuModel { // Returns the item type at the specified |index|. // pub fn get_type_at(&self, index: libc::c_int) -> types::cef_menu_item_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 { @@ -869,7 +897,8 @@ impl CefMenuModel { // Returns the group id for the specified |command_id| or -1 if invalid. // pub fn get_group_id(&self, command_id: libc::c_int) -> 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 { @@ -884,7 +913,8 @@ impl CefMenuModel { // Returns the group id at the specified |index| or -1 if invalid. // pub fn get_group_id_at(&self, index: libc::c_int) -> 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 { @@ -901,7 +931,8 @@ impl CefMenuModel { // pub fn set_group_id(&self, command_id: libc::c_int, group_id: libc::c_int) -> 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 { @@ -918,7 +949,8 @@ impl CefMenuModel { // pub fn set_group_id_at(&self, index: libc::c_int, group_id: libc::c_int) -> 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 { @@ -935,7 +967,8 @@ impl CefMenuModel { // pub fn get_sub_menu(&self, command_id: libc::c_int) -> interfaces::CefMenuModel { - 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 { @@ -951,7 +984,8 @@ impl CefMenuModel { // pub fn get_sub_menu_at(&self, index: libc::c_int) -> interfaces::CefMenuModel { - 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 { @@ -966,7 +1000,8 @@ impl CefMenuModel { // Returns true (1) if the specified |command_id| is visible. // pub fn is_visible(&self, command_id: libc::c_int) -> 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 { @@ -981,7 +1016,8 @@ impl CefMenuModel { // Returns true (1) if the specified |index| is visible. // pub fn is_visible_at(&self, index: libc::c_int) -> 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 { @@ -998,7 +1034,8 @@ impl CefMenuModel { // pub fn set_visible(&self, command_id: libc::c_int, visible: libc::c_int) -> 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 { @@ -1016,7 +1053,8 @@ impl CefMenuModel { // pub fn set_visible_at(&self, index: libc::c_int, visible: libc::c_int) -> 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 { @@ -1032,7 +1070,8 @@ impl CefMenuModel { // Returns true (1) if the specified |command_id| is enabled. // pub fn is_enabled(&self, command_id: libc::c_int) -> 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 { @@ -1047,7 +1086,8 @@ impl CefMenuModel { // Returns true (1) if the specified |index| is enabled. // pub fn is_enabled_at(&self, index: libc::c_int) -> 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 { @@ -1064,7 +1104,8 @@ impl CefMenuModel { // pub fn set_enabled(&self, command_id: libc::c_int, enabled: libc::c_int) -> 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 { @@ -1082,7 +1123,8 @@ impl CefMenuModel { // pub fn set_enabled_at(&self, index: libc::c_int, enabled: libc::c_int) -> 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 { @@ -1099,7 +1141,8 @@ impl CefMenuModel { // check and radio items. // pub fn is_checked(&self, command_id: libc::c_int) -> 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 { @@ -1115,7 +1158,8 @@ impl CefMenuModel { // and radio items. // pub fn is_checked_at(&self, index: libc::c_int) -> 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 { @@ -1132,7 +1176,8 @@ impl CefMenuModel { // pub fn set_checked(&self, command_id: libc::c_int, checked: libc::c_int) -> 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 { @@ -1150,7 +1195,8 @@ impl CefMenuModel { // pub fn set_checked_at(&self, index: libc::c_int, checked: libc::c_int) -> 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 { @@ -1167,7 +1213,8 @@ impl CefMenuModel { // assigned. // pub fn has_accelerator(&self, command_id: libc::c_int) -> 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 { @@ -1183,7 +1230,8 @@ impl CefMenuModel { // assigned. // pub fn has_accelerator_at(&self, index: libc::c_int) -> 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 { @@ -1201,7 +1249,8 @@ impl CefMenuModel { pub fn set_accelerator(&self, command_id: libc::c_int, key_code: libc::c_int, shift_pressed: libc::c_int, ctrl_pressed: libc::c_int, alt_pressed: libc::c_int) -> 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 { @@ -1223,7 +1272,8 @@ impl CefMenuModel { pub fn set_accelerator_at(&self, index: libc::c_int, key_code: libc::c_int, shift_pressed: libc::c_int, ctrl_pressed: libc::c_int, alt_pressed: libc::c_int) -> 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 { @@ -1243,7 +1293,8 @@ impl CefMenuModel { // true (1) on success. // pub fn remove_accelerator(&self, command_id: libc::c_int) -> 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 { @@ -1259,7 +1310,8 @@ impl CefMenuModel { // on success. // pub fn remove_accelerator_at(&self, index: libc::c_int) -> 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 { @@ -1278,7 +1330,8 @@ impl CefMenuModel { key_code: &mut libc::c_int, shift_pressed: &mut libc::c_int, ctrl_pressed: &mut libc::c_int, alt_pressed: &mut libc::c_int) -> 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 { @@ -1301,7 +1354,8 @@ impl CefMenuModel { key_code: &mut libc::c_int, shift_pressed: &mut libc::c_int, ctrl_pressed: &mut libc::c_int, alt_pressed: &mut libc::c_int) -> 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 { @@ -1333,7 +1387,8 @@ impl CefWrap<*mut cef_menu_model_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_menu_model_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefMenuModel::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_navigation_entry.rs b/ports/cef/interfaces/cef_navigation_entry.rs index 464f6139b29..6654b72cccb 100644 --- a/ports/cef/interfaces/cef_navigation_entry.rs +++ b/ports/cef/interfaces/cef_navigation_entry.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -131,13 +132,13 @@ pub struct _cef_navigation_entry_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_navigation_entry_t = _cef_navigation_entry_t; @@ -152,7 +153,8 @@ pub struct CefNavigationEntry { impl Clone for CefNavigationEntry { fn clone(&self) -> CefNavigationEntry{ 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); } CefNavigationEntry { @@ -165,7 +167,8 @@ impl Clone for CefNavigationEntry { impl Drop for CefNavigationEntry { 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); } } @@ -180,7 +183,8 @@ impl CefNavigationEntry { } pub unsafe fn from_c_object_addref(c_object: *mut cef_navigation_entry_t) -> CefNavigationEntry { - 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); } CefNavigationEntry { @@ -194,7 +198,8 @@ impl CefNavigationEntry { pub fn c_object_addrefed(&self) -> *mut cef_navigation_entry_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 @@ -202,10 +207,10 @@ impl CefNavigationEntry { } 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 } // @@ -213,7 +218,8 @@ impl CefNavigationEntry { // 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 { @@ -229,7 +235,8 @@ impl CefNavigationEntry { // // 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 { @@ -244,7 +251,8 @@ impl CefNavigationEntry { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_display_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 { @@ -259,7 +267,8 @@ impl CefNavigationEntry { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_original_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 { @@ -274,7 +283,8 @@ impl CefNavigationEntry { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_title(&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 { @@ -289,7 +299,8 @@ impl CefNavigationEntry { // this page from the previous page. // 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 { @@ -303,7 +314,8 @@ impl CefNavigationEntry { // Returns true (1) if this navigation includes post data. // pub fn has_post_data(&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 { @@ -319,7 +331,8 @@ impl CefNavigationEntry { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_frame_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 { @@ -335,7 +348,8 @@ impl CefNavigationEntry { // 0 if the navigation has not yet completed. // pub fn get_completion_time(&self) -> types::cef_time_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 { @@ -351,7 +365,8 @@ impl CefNavigationEntry { // navigation has not yet completed. // pub fn get_http_status_code(&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 { @@ -378,7 +393,8 @@ impl CefWrap<*mut cef_navigation_entry_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_navigation_entry_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefNavigationEntry::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_origin_whitelist.rs b/ports/cef/interfaces/cef_origin_whitelist.rs index 061f2797a3e..c396bf66e02 100644 --- a/ports/cef/interfaces/cef_origin_whitelist.rs +++ b/ports/cef/interfaces/cef_origin_whitelist.rs @@ -43,4 +43,5 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; diff --git a/ports/cef/interfaces/cef_parser.rs b/ports/cef/interfaces/cef_parser.rs index 061f2797a3e..c396bf66e02 100644 --- a/ports/cef/interfaces/cef_parser.rs +++ b/ports/cef/interfaces/cef_parser.rs @@ -43,4 +43,5 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; diff --git a/ports/cef/interfaces/cef_path_util.rs b/ports/cef/interfaces/cef_path_util.rs index 061f2797a3e..c396bf66e02 100644 --- a/ports/cef/interfaces/cef_path_util.rs +++ b/ports/cef/interfaces/cef_path_util.rs @@ -43,4 +43,5 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; diff --git a/ports/cef/interfaces/cef_print_handler.rs b/ports/cef/interfaces/cef_print_handler.rs index c00717c88e0..9737d87a9a3 100644 --- a/ports/cef/interfaces/cef_print_handler.rs +++ b/ports/cef/interfaces/cef_print_handler.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -70,13 +71,13 @@ pub struct _cef_print_dialog_callback_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_print_dialog_callback_t = _cef_print_dialog_callback_t; @@ -91,7 +92,8 @@ pub struct CefPrintDialogCallback { impl Clone for CefPrintDialogCallback { fn clone(&self) -> CefPrintDialogCallback{ 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); } CefPrintDialogCallback { @@ -104,7 +106,8 @@ impl Clone for CefPrintDialogCallback { impl Drop for CefPrintDialogCallback { 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); } } @@ -119,7 +122,8 @@ impl CefPrintDialogCallback { } pub unsafe fn from_c_object_addref(c_object: *mut cef_print_dialog_callback_t) -> CefPrintDialogCallback { - 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); } CefPrintDialogCallback { @@ -133,7 +137,8 @@ impl CefPrintDialogCallback { pub fn c_object_addrefed(&self) -> *mut cef_print_dialog_callback_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 @@ -141,17 +146,18 @@ impl CefPrintDialogCallback { } 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 } // // Continue printing with the specified |settings|. // pub fn cont(&self, settings: interfaces::CefPrintSettings) -> () { - 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 { @@ -166,7 +172,8 @@ impl CefPrintDialogCallback { // Cancel the printing. // pub fn cancel(&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 { @@ -193,7 +200,8 @@ impl CefWrap<*mut cef_print_dialog_callback_t> for Option Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefPrintDialogCallback::from_c_object_addref(c_object)) @@ -220,13 +228,13 @@ pub struct _cef_print_job_callback_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_print_job_callback_t = _cef_print_job_callback_t; @@ -241,7 +249,8 @@ pub struct CefPrintJobCallback { impl Clone for CefPrintJobCallback { fn clone(&self) -> CefPrintJobCallback{ 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); } CefPrintJobCallback { @@ -254,7 +263,8 @@ impl Clone for CefPrintJobCallback { impl Drop for CefPrintJobCallback { 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); } } @@ -269,7 +279,8 @@ impl CefPrintJobCallback { } pub unsafe fn from_c_object_addref(c_object: *mut cef_print_job_callback_t) -> CefPrintJobCallback { - 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); } CefPrintJobCallback { @@ -283,7 +294,8 @@ impl CefPrintJobCallback { pub fn c_object_addrefed(&self) -> *mut cef_print_job_callback_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 @@ -291,17 +303,18 @@ impl CefPrintJobCallback { } 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 } // // Indicate completion of the print job. // pub fn cont(&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 { @@ -328,7 +341,8 @@ impl CefWrap<*mut cef_print_job_callback_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_print_job_callback_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefPrintJobCallback::from_c_object_addref(c_object)) @@ -385,13 +399,13 @@ pub struct _cef_print_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_print_handler_t = _cef_print_handler_t; @@ -407,7 +421,8 @@ pub struct CefPrintHandler { impl Clone for CefPrintHandler { fn clone(&self) -> CefPrintHandler{ 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); } CefPrintHandler { @@ -420,7 +435,8 @@ impl Clone for CefPrintHandler { impl Drop for CefPrintHandler { 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); } } @@ -435,7 +451,8 @@ impl CefPrintHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_print_handler_t) -> CefPrintHandler { - 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); } CefPrintHandler { @@ -449,7 +466,8 @@ impl CefPrintHandler { pub fn c_object_addrefed(&self) -> *mut cef_print_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 @@ -457,10 +475,10 @@ impl CefPrintHandler { } 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 } // @@ -470,7 +488,8 @@ impl CefPrintHandler { // pub fn on_print_settings(&self, settings: interfaces::CefPrintSettings, get_defaults: 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 { @@ -489,7 +508,8 @@ impl CefPrintHandler { // pub fn on_print_dialog(&self, has_selection: libc::c_int, callback: interfaces::CefPrintDialogCallback) -> 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 { @@ -508,7 +528,8 @@ impl CefPrintHandler { // pub fn on_print_job(&self, document_name: &[u16], pdf_file_path: &[u16], callback: interfaces::CefPrintJobCallback) -> 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 { @@ -525,7 +546,8 @@ impl CefPrintHandler { // Reset client state related to printing. // pub fn on_print_reset(&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 { @@ -552,7 +574,8 @@ impl CefWrap<*mut cef_print_handler_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_print_handler_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefPrintHandler::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_print_settings.rs b/ports/cef/interfaces/cef_print_settings.rs index 6af6381f506..2c22df782ad 100644 --- a/ports/cef/interfaces/cef_print_settings.rs +++ b/ports/cef/interfaces/cef_print_settings.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -206,13 +207,13 @@ pub struct _cef_print_settings_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_print_settings_t = _cef_print_settings_t; @@ -227,7 +228,8 @@ pub struct CefPrintSettings { impl Clone for CefPrintSettings { fn clone(&self) -> CefPrintSettings{ 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); } CefPrintSettings { @@ -240,7 +242,8 @@ impl Clone for CefPrintSettings { impl Drop for CefPrintSettings { 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); } } @@ -255,7 +258,8 @@ impl CefPrintSettings { } pub unsafe fn from_c_object_addref(c_object: *mut cef_print_settings_t) -> CefPrintSettings { - 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); } CefPrintSettings { @@ -269,7 +273,8 @@ impl CefPrintSettings { pub fn c_object_addrefed(&self) -> *mut cef_print_settings_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 @@ -277,10 +282,10 @@ impl CefPrintSettings { } 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 } // @@ -288,7 +293,8 @@ impl CefPrintSettings { // 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 { @@ -303,7 +309,8 @@ impl CefPrintSettings { // 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 { @@ -317,7 +324,8 @@ impl CefPrintSettings { // Returns a writable copy of this object. // pub fn copy(&self) -> interfaces::CefPrintSettings { - 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 +339,8 @@ impl CefPrintSettings { // Set the page orientation. // pub fn set_orientation(&self, landscape: 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 { @@ -346,7 +355,8 @@ impl CefPrintSettings { // Returns true (1) if the orientation is landscape. // pub fn is_landscape(&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 { @@ -365,7 +375,8 @@ impl CefPrintSettings { physical_size_device_units: &types::cef_size_t, printable_area_device_units: &types::cef_rect_t, landscape_needs_flip: 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 { @@ -382,7 +393,8 @@ impl CefPrintSettings { // Set the device name. // pub fn set_device_name(&self, name: &[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 { @@ -398,7 +410,8 @@ impl CefPrintSettings { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_device_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 { @@ -412,7 +425,8 @@ impl CefPrintSettings { // Set the DPI (dots per inch). // pub fn set_dpi(&self, dpi: 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 { @@ -427,7 +441,8 @@ impl CefPrintSettings { // Get the DPI (dots per inch). // pub fn get_dpi(&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 { @@ -442,7 +457,8 @@ impl CefPrintSettings { // pub fn set_page_ranges(&self, ranges_count: libc::size_t, ranges: *const types::cef_page_range_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 { @@ -458,7 +474,8 @@ impl CefPrintSettings { // Returns the number of page ranges that currently exist. // pub fn get_page_ranges_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 { @@ -473,7 +490,8 @@ impl CefPrintSettings { // pub fn get_page_ranges(&self, ranges_count: *mut libc::size_t, ranges: *mut types::cef_page_range_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 { @@ -489,7 +507,8 @@ impl CefPrintSettings { // Set whether only the selection will be printed. // pub fn set_selection_only(&self, selection_only: 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 { @@ -504,7 +523,8 @@ impl CefPrintSettings { // Returns true (1) if only the selection will be printed. // pub fn is_selection_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 { @@ -518,7 +538,8 @@ impl CefPrintSettings { // Set whether pages will be collated. // pub fn set_collate(&self, collate: 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 { @@ -533,7 +554,8 @@ impl CefPrintSettings { // Returns true (1) if pages will be collated. // pub fn will_collate(&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 { @@ -547,7 +569,8 @@ impl CefPrintSettings { // Set the color model. // pub fn set_color_model(&self, model: types::cef_color_model_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 { @@ -562,7 +585,8 @@ impl CefPrintSettings { // Get the color model. // pub fn get_color_model(&self) -> types::cef_color_model_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 { @@ -576,7 +600,8 @@ impl CefPrintSettings { // Set the number of copies. // pub fn set_copies(&self, copies: 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 { @@ -591,7 +616,8 @@ impl CefPrintSettings { // Get the number of copies. // pub fn get_copies(&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 { @@ -605,7 +631,8 @@ impl CefPrintSettings { // Set the duplex mode. // pub fn set_duplex_mode(&self, mode: types::cef_duplex_mode_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 { @@ -620,7 +647,8 @@ impl CefPrintSettings { // Get the duplex mode. // pub fn get_duplex_mode(&self) -> types::cef_duplex_mode_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 { @@ -658,7 +686,8 @@ impl CefWrap<*mut cef_print_settings_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_print_settings_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefPrintSettings::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_process_message.rs b/ports/cef/interfaces/cef_process_message.rs index da6e840e78c..e09b4b1ee15 100644 --- a/ports/cef/interfaces/cef_process_message.rs +++ b/ports/cef/interfaces/cef_process_message.rs @@ -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 { } } unsafe fn to_rust(c_object: *mut cef_process_message_t) -> Option { - 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)) diff --git a/ports/cef/interfaces/cef_process_util.rs b/ports/cef/interfaces/cef_process_util.rs index 061f2797a3e..c396bf66e02 100644 --- a/ports/cef/interfaces/cef_process_util.rs +++ b/ports/cef/interfaces/cef_process_util.rs @@ -43,4 +43,5 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; diff --git a/ports/cef/interfaces/cef_render_handler.rs b/ports/cef/interfaces/cef_render_handler.rs index 384a2b14b40..68beac427ab 100644 --- a/ports/cef/interfaces/cef_render_handler.rs +++ b/ports/cef/interfaces/cef_render_handler.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -190,13 +191,13 @@ pub struct _cef_render_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_render_handler_t = _cef_render_handler_t; @@ -212,7 +213,8 @@ pub struct CefRenderHandler { impl Clone for CefRenderHandler { fn clone(&self) -> CefRenderHandler{ 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); } CefRenderHandler { @@ -225,7 +227,8 @@ impl Clone for CefRenderHandler { impl Drop for CefRenderHandler { 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); } } @@ -240,7 +243,8 @@ impl CefRenderHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_render_handler_t) -> CefRenderHandler { - 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); } CefRenderHandler { @@ -254,7 +258,8 @@ impl CefRenderHandler { pub fn c_object_addrefed(&self) -> *mut cef_render_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 @@ -262,10 +267,10 @@ impl CefRenderHandler { } 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 } // @@ -274,7 +279,8 @@ impl CefRenderHandler { // pub fn get_root_screen_rect(&self, browser: interfaces::CefBrowser, rect: &mut types::cef_rect_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 { @@ -292,7 +298,8 @@ impl CefRenderHandler { // pub fn get_view_rect(&self, browser: interfaces::CefBrowser, rect: &mut types::cef_rect_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 { @@ -311,7 +318,8 @@ impl CefRenderHandler { pub fn get_screen_point(&self, browser: interfaces::CefBrowser, viewX: libc::c_int, viewY: libc::c_int, screenX: &mut libc::c_int, screenY: &mut libc::c_int) -> 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 { @@ -337,7 +345,8 @@ impl CefRenderHandler { // pub fn get_screen_info(&self, browser: interfaces::CefBrowser, screen_info: &mut interfaces::CefScreenInfo) -> 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 { @@ -355,7 +364,8 @@ impl CefRenderHandler { // pub fn on_popup_show(&self, browser: interfaces::CefBrowser, show: 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 { @@ -373,7 +383,8 @@ impl CefRenderHandler { // pub fn on_popup_size(&self, browser: interfaces::CefBrowser, rect: &types::cef_rect_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 { @@ -399,7 +410,8 @@ impl CefRenderHandler { ty: types::cef_paint_element_type_t, dirtyRects_count: libc::size_t, dirtyRects: *const types::cef_rect_t, buffer: &(), width: libc::c_int, height: 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 { @@ -423,7 +435,8 @@ impl CefRenderHandler { pub fn on_cursor_change(&self, browser: interfaces::CefBrowser, cursor: types::cef_cursor_handle_t, ty: types::cef_cursor_type_t, custom_cursor_info: &interfaces::CefCursorInfo) -> () { - 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 { @@ -455,7 +468,8 @@ impl CefRenderHandler { drag_data: interfaces::CefDragData, allowed_ops: types::cef_drag_operations_mask_t, x: libc::c_int, y: libc::c_int) -> 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 { @@ -477,7 +491,8 @@ impl CefRenderHandler { // pub fn update_drag_cursor(&self, browser: interfaces::CefBrowser, operation: types::cef_drag_operations_mask_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 { @@ -494,7 +509,8 @@ impl CefRenderHandler { // pub fn on_scroll_offset_changed(&self, browser: interfaces::CefBrowser, x: libc::c_double, y: libc::c_double) -> () { - 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 { @@ -515,7 +531,8 @@ impl CefRenderHandler { // pub fn get_backing_rect(&self, browser: interfaces::CefBrowser, rect: &mut types::cef_rect_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 { @@ -532,7 +549,8 @@ impl CefRenderHandler { // flip). This is called only during accelerated compositing. // pub fn on_present(&self, browser: interfaces::CefBrowser) -> () { - 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 { @@ -560,7 +578,8 @@ impl CefWrap<*mut cef_render_handler_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_render_handler_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefRenderHandler::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_render_process_handler.rs b/ports/cef/interfaces/cef_render_process_handler.rs index 4c9bbc67dc6..c334c9520e8 100644 --- a/ports/cef/interfaces/cef_render_process_handler.rs +++ b/ports/cef/interfaces/cef_render_process_handler.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -173,13 +174,13 @@ pub struct _cef_render_process_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_render_process_handler_t = _cef_render_process_handler_t; @@ -196,7 +197,8 @@ pub struct CefRenderProcessHandler { impl Clone for CefRenderProcessHandler { fn clone(&self) -> CefRenderProcessHandler{ 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); } CefRenderProcessHandler { @@ -209,7 +211,8 @@ impl Clone for CefRenderProcessHandler { impl Drop for CefRenderProcessHandler { 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 CefRenderProcessHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_render_process_handler_t) -> CefRenderProcessHandler { - 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); } CefRenderProcessHandler { @@ -238,7 +242,8 @@ impl CefRenderProcessHandler { pub fn c_object_addrefed(&self) -> *mut cef_render_process_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 @@ -246,10 +251,10 @@ impl CefRenderProcessHandler { } 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 } // @@ -260,7 +265,8 @@ impl CefRenderProcessHandler { // pub fn on_render_thread_created(&self, extra_info: 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 { @@ -275,7 +281,8 @@ impl CefRenderProcessHandler { // Called after WebKit has been initialized. // pub fn on_web_kit_initialized(&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 { @@ -291,7 +298,8 @@ impl CefRenderProcessHandler { // destroyed. // pub fn on_browser_created(&self, browser: interfaces::CefBrowser) -> () { - 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 { @@ -306,7 +314,8 @@ impl CefRenderProcessHandler { // Called before a browser is destroyed. // pub fn on_browser_destroyed(&self, browser: interfaces::CefBrowser) -> () { - 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 { @@ -321,7 +330,8 @@ impl CefRenderProcessHandler { // Return the handler for browser load status events. // pub fn get_load_handler(&self) -> interfaces::CefLoadHandler { - 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 { @@ -340,7 +350,8 @@ impl CefRenderProcessHandler { frame: interfaces::CefFrame, request: interfaces::CefRequest, navigation_type: types::cef_navigation_type_t, is_redirect: libc::c_int) -> 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 { @@ -365,7 +376,8 @@ impl CefRenderProcessHandler { // pub fn on_context_created(&self, browser: interfaces::CefBrowser, frame: interfaces::CefFrame, context: interfaces::CefV8Context) -> () { - 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 { @@ -384,7 +396,8 @@ impl CefRenderProcessHandler { // pub fn on_context_released(&self, browser: interfaces::CefBrowser, frame: interfaces::CefFrame, context: interfaces::CefV8Context) -> () { - 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 { @@ -406,7 +419,8 @@ impl CefRenderProcessHandler { frame: interfaces::CefFrame, context: interfaces::CefV8Context, exception: interfaces::CefV8Exception, stackTrace: interfaces::CefV8StackTrace) -> () { - 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 { @@ -431,7 +445,8 @@ impl CefRenderProcessHandler { // pub fn on_focused_node_changed(&self, browser: interfaces::CefBrowser, frame: interfaces::CefFrame, node: interfaces::CefDOMNode) -> () { - 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 { @@ -452,7 +467,8 @@ impl CefRenderProcessHandler { pub fn on_process_message_received(&self, browser: interfaces::CefBrowser, source_process: interfaces::CefProcessId, message: interfaces::CefProcessMessage) -> 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 { @@ -482,7 +498,8 @@ impl CefWrap<*mut cef_render_process_handler_t> for Option Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefRenderProcessHandler::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_request.rs b/ports/cef/interfaces/cef_request.rs index 574f59bb3db..171d3c30314 100644 --- a/ports/cef/interfaces/cef_request.rs +++ b/ports/cef/interfaces/cef_request.rs @@ -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>) -> () { - 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>) -> () { - 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>) -> () { - 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 { } } unsafe fn to_rust(c_object: *mut cef_request_t) -> Option { - 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 { } } unsafe fn to_rust(c_object: *mut cef_post_data_t) -> Option { - 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 { } } unsafe fn to_rust(c_object: *mut cef_post_data_element_t) -> Option { - 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)) diff --git a/ports/cef/interfaces/cef_request_context.rs b/ports/cef/interfaces/cef_request_context.rs index 29bfa3a52c0..7f4f4fc975b 100644 --- a/ports/cef/interfaces/cef_request_context.rs +++ b/ports/cef/interfaces/cef_request_context.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -144,13 +145,13 @@ pub struct _cef_request_context_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_context_t = _cef_request_context_t; @@ -178,7 +179,8 @@ pub struct CefRequestContext { impl Clone for CefRequestContext { fn clone(&self) -> CefRequestContext{ 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); } CefRequestContext { @@ -191,7 +193,8 @@ impl Clone for CefRequestContext { impl Drop for CefRequestContext { 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); } } @@ -206,7 +209,8 @@ impl CefRequestContext { } pub unsafe fn from_c_object_addref(c_object: *mut cef_request_context_t) -> CefRequestContext { - 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); } CefRequestContext { @@ -220,7 +224,8 @@ impl CefRequestContext { pub fn c_object_addrefed(&self) -> *mut cef_request_context_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 @@ -228,10 +233,10 @@ impl CefRequestContext { } 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 } // @@ -239,7 +244,8 @@ impl CefRequestContext { // object. // pub fn is_same(&self, other: interfaces::CefRequestContext) -> 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 { @@ -256,7 +262,8 @@ impl CefRequestContext { // pub fn is_sharing_with(&self, other: interfaces::CefRequestContext) -> 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 { @@ -273,7 +280,8 @@ impl CefRequestContext { // context argument. // pub fn is_global(&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 { @@ -287,7 +295,8 @@ impl CefRequestContext { // Returns the handler for this context if any. // pub fn get_handler(&self) -> interfaces::CefRequestContextHandler { - 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 { @@ -303,7 +312,8 @@ impl CefRequestContext { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_cache_path(&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 { @@ -323,7 +333,8 @@ impl CefRequestContext { // pub fn get_default_cookie_manager(&self, callback: interfaces::CefCompletionCallback) -> interfaces::CefCookieManager { - 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 { @@ -350,7 +361,8 @@ impl CefRequestContext { pub fn register_scheme_handler_factory(&self, scheme_name: &[u16], domain_name: &[u16], factory: interfaces::CefSchemeHandlerFactory) -> 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 { @@ -368,7 +380,8 @@ impl CefRequestContext { // This function may be called on any thread in the browser process. // pub fn clear_scheme_handler_factories(&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 { @@ -434,7 +447,8 @@ impl CefWrap<*mut cef_request_context_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_request_context_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefRequestContext::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_request_context_handler.rs b/ports/cef/interfaces/cef_request_context_handler.rs index 30a325bfe9d..91e41a1b91e 100644 --- a/ports/cef/interfaces/cef_request_context_handler.rs +++ b/ports/cef/interfaces/cef_request_context_handler.rs @@ -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_request_context_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_request_context_handler_t = _cef_request_context_handler_t; @@ -91,7 +92,8 @@ pub struct CefRequestContextHandler { impl Clone for CefRequestContextHandler { fn clone(&self) -> CefRequestContextHandler{ 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); } CefRequestContextHandler { @@ -104,7 +106,8 @@ impl Clone for CefRequestContextHandler { impl Drop for CefRequestContextHandler { 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); } } @@ -119,7 +122,8 @@ impl CefRequestContextHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_request_context_handler_t) -> CefRequestContextHandler { - 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); } CefRequestContextHandler { @@ -133,7 +137,8 @@ impl CefRequestContextHandler { pub fn c_object_addrefed(&self) -> *mut cef_request_context_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 @@ -141,10 +146,10 @@ impl CefRequestContextHandler { } 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 } // @@ -153,7 +158,8 @@ impl CefRequestContextHandler { // cef_request_tContext::get_default_cookie_manager() will be used. // pub fn get_cookie_manager(&self) -> interfaces::CefCookieManager { - 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 { @@ -180,7 +186,8 @@ impl CefWrap<*mut cef_request_context_handler_t> for Option Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefRequestContextHandler::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_request_handler.rs b/ports/cef/interfaces/cef_request_handler.rs index c17a9015181..483d26adb9b 100644 --- a/ports/cef/interfaces/cef_request_handler.rs +++ b/ports/cef/interfaces/cef_request_handler.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -70,13 +71,13 @@ pub struct _cef_request_callback_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_callback_t = _cef_request_callback_t; @@ -91,7 +92,8 @@ pub struct CefRequestCallback { impl Clone for CefRequestCallback { fn clone(&self) -> CefRequestCallback{ 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); } CefRequestCallback { @@ -104,7 +106,8 @@ impl Clone for CefRequestCallback { impl Drop for CefRequestCallback { 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); } } @@ -119,7 +122,8 @@ impl CefRequestCallback { } pub unsafe fn from_c_object_addref(c_object: *mut cef_request_callback_t) -> CefRequestCallback { - 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); } CefRequestCallback { @@ -133,7 +137,8 @@ impl CefRequestCallback { pub fn c_object_addrefed(&self) -> *mut cef_request_callback_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 @@ -141,10 +146,10 @@ impl CefRequestCallback { } 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 } // @@ -152,7 +157,8 @@ impl CefRequestCallback { // continued. Otherwise, the request will be canceled. // pub fn cont(&self, allow: 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 { @@ -167,7 +173,8 @@ impl CefRequestCallback { // Cancel the url request. // pub fn cancel(&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 { @@ -194,7 +201,8 @@ impl CefWrap<*mut cef_request_callback_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_request_callback_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefRequestCallback::from_c_object_addref(c_object)) @@ -396,13 +404,13 @@ pub struct _cef_request_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_request_handler_t = _cef_request_handler_t; @@ -418,7 +426,8 @@ pub struct CefRequestHandler { impl Clone for CefRequestHandler { fn clone(&self) -> CefRequestHandler{ 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); } CefRequestHandler { @@ -431,7 +440,8 @@ impl Clone for CefRequestHandler { impl Drop for CefRequestHandler { 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); } } @@ -446,7 +456,8 @@ impl CefRequestHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_request_handler_t) -> CefRequestHandler { - 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); } CefRequestHandler { @@ -460,7 +471,8 @@ impl CefRequestHandler { pub fn c_object_addrefed(&self) -> *mut cef_request_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 @@ -468,10 +480,10 @@ impl CefRequestHandler { } 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 } // @@ -487,7 +499,8 @@ impl CefRequestHandler { pub fn on_before_browse(&self, browser: interfaces::CefBrowser, frame: interfaces::CefFrame, request: interfaces::CefRequest, is_redirect: libc::c_int) -> 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 { @@ -521,7 +534,8 @@ impl CefRequestHandler { frame: interfaces::CefFrame, target_url: &[u16], target_disposition: types::cef_window_open_disposition_t, user_gesture: libc::c_int) -> 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 { @@ -547,7 +561,8 @@ impl CefRequestHandler { pub fn on_before_resource_load(&self, browser: interfaces::CefBrowser, frame: interfaces::CefFrame, request: interfaces::CefRequest, callback: interfaces::CefRequestCallback) -> types::cef_return_value_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 { @@ -570,7 +585,8 @@ impl CefRequestHandler { pub fn get_resource_handler(&self, browser: interfaces::CefBrowser, frame: interfaces::CefFrame, request: interfaces::CefRequest) -> interfaces::CefResourceHandler { - 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 { @@ -592,7 +608,8 @@ impl CefRequestHandler { pub fn on_resource_redirect(&self, browser: interfaces::CefBrowser, frame: interfaces::CefFrame, request: interfaces::CefRequest, new_url: *mut types::cef_string_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 { @@ -615,7 +632,8 @@ impl CefRequestHandler { pub fn on_resource_response(&self, browser: interfaces::CefBrowser, frame: interfaces::CefFrame, request: interfaces::CefRequest, response: interfaces::CefResponse) -> 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 { @@ -641,7 +659,8 @@ impl CefRequestHandler { frame: interfaces::CefFrame, isProxy: libc::c_int, host: &[u16], port: libc::c_int, realm: &[u16], scheme: &[u16], callback: interfaces::CefAuthCallback) -> 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 { @@ -671,7 +690,8 @@ impl CefRequestHandler { pub fn on_quota_request(&self, browser: interfaces::CefBrowser, origin_url: &[u16], new_size: i64, callback: interfaces::CefRequestCallback) -> 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 { @@ -694,7 +714,8 @@ impl CefRequestHandler { // pub fn on_protocol_execution(&self, browser: interfaces::CefBrowser, url: &[u16], allow_os_execution: &mut 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 { @@ -720,7 +741,8 @@ impl CefRequestHandler { cert_error: types::cef_errorcode_t, request_url: &[u16], ssl_info: interfaces::CefSSLInfo, callback: interfaces::CefRequestCallback) -> 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 { @@ -742,7 +764,8 @@ impl CefRequestHandler { pub fn on_before_plugin_load(&self, browser: interfaces::CefBrowser, url: &[u16], policy_url: &[u16], info: interfaces::CefWebPluginInfo) -> 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 { @@ -762,7 +785,8 @@ impl CefRequestHandler { // pub fn on_plugin_crashed(&self, browser: interfaces::CefBrowser, plugin_path: &[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 { @@ -780,7 +804,8 @@ impl CefRequestHandler { // process. // pub fn on_render_view_ready(&self, browser: interfaces::CefBrowser) -> () { - 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 { @@ -797,7 +822,8 @@ impl CefRequestHandler { // pub fn on_render_process_terminated(&self, browser: interfaces::CefBrowser, status: types::cef_termination_status_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 { @@ -826,7 +852,8 @@ impl CefWrap<*mut cef_request_handler_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_request_handler_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefRequestHandler::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_resource_bundle_handler.rs b/ports/cef/interfaces/cef_resource_bundle_handler.rs index a99c1946d9e..d6501c0ea56 100644 --- a/ports/cef/interfaces/cef_resource_bundle_handler.rs +++ b/ports/cef/interfaces/cef_resource_bundle_handler.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -82,13 +83,13 @@ pub struct _cef_resource_bundle_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_resource_bundle_handler_t = _cef_resource_bundle_handler_t; @@ -104,7 +105,8 @@ pub struct CefResourceBundleHandler { impl Clone for CefResourceBundleHandler { fn clone(&self) -> CefResourceBundleHandler{ 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); } CefResourceBundleHandler { @@ -117,7 +119,8 @@ impl Clone for CefResourceBundleHandler { impl Drop for CefResourceBundleHandler { 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); } } @@ -132,7 +135,8 @@ impl CefResourceBundleHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_resource_bundle_handler_t) -> CefResourceBundleHandler { - 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); } CefResourceBundleHandler { @@ -146,7 +150,8 @@ impl CefResourceBundleHandler { pub fn c_object_addrefed(&self) -> *mut cef_resource_bundle_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 @@ -154,10 +159,10 @@ impl CefResourceBundleHandler { } 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 } // @@ -168,7 +173,8 @@ impl CefResourceBundleHandler { // pub fn get_localized_string(&self, message_id: libc::c_int, string: *mut types::cef_string_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 { @@ -191,7 +197,8 @@ impl CefResourceBundleHandler { pub fn get_data_resource(&self, resource_id: libc::c_int, data: &mut *mut libc::c_void, data_size: &mut libc::size_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 { @@ -221,7 +228,8 @@ impl CefWrap<*mut cef_resource_bundle_handler_t> for Option Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefResourceBundleHandler::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_resource_handler.rs b/ports/cef/interfaces/cef_resource_handler.rs index a374210b591..a6ecd42bc2e 100644 --- a/ports/cef/interfaces/cef_resource_handler.rs +++ b/ports/cef/interfaces/cef_resource_handler.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -117,13 +118,13 @@ pub struct _cef_resource_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_resource_handler_t = _cef_resource_handler_t; @@ -139,7 +140,8 @@ pub struct CefResourceHandler { impl Clone for CefResourceHandler { fn clone(&self) -> CefResourceHandler{ 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); } CefResourceHandler { @@ -152,7 +154,8 @@ impl Clone for CefResourceHandler { impl Drop for CefResourceHandler { 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); } } @@ -167,7 +170,8 @@ impl CefResourceHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_resource_handler_t) -> CefResourceHandler { - 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); } CefResourceHandler { @@ -181,7 +185,8 @@ impl CefResourceHandler { pub fn c_object_addrefed(&self) -> *mut cef_resource_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 @@ -189,10 +194,10 @@ impl CefResourceHandler { } 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 } // @@ -204,7 +209,8 @@ impl CefResourceHandler { // pub fn process_request(&self, request: interfaces::CefRequest, callback: interfaces::CefCallback) -> 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 { @@ -229,7 +235,8 @@ impl CefResourceHandler { pub fn get_response_headers(&self, response: interfaces::CefResponse, response_length: &mut i64, redirectUrl: *mut types::cef_string_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 { @@ -252,7 +259,8 @@ impl CefResourceHandler { pub fn read_response(&self, data_out: &mut (), bytes_to_read: libc::c_int, bytes_read: &mut libc::c_int, callback: interfaces::CefCallback) -> 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 { @@ -272,7 +280,8 @@ impl CefResourceHandler { // cookies will be sent with the request. // pub fn can_get_cookie(&self, cookie: &interfaces::CefCookie) -> 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 { @@ -288,7 +297,8 @@ impl CefResourceHandler { // set or false (0) otherwise. // pub fn can_set_cookie(&self, cookie: &interfaces::CefCookie) -> 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 { @@ -303,7 +313,8 @@ impl CefResourceHandler { // Request processing has been canceled. // pub fn cancel(&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 { @@ -330,7 +341,8 @@ impl CefWrap<*mut cef_resource_handler_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_resource_handler_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefResourceHandler::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_response.rs b/ports/cef/interfaces/cef_response.rs index 6c97d22c3c0..54b45593991 100644 --- a/ports/cef/interfaces/cef_response.rs +++ b/ports/cef/interfaces/cef_response.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -122,13 +123,13 @@ pub struct _cef_response_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_response_t = _cef_response_t; @@ -144,7 +145,8 @@ pub struct CefResponse { impl Clone for CefResponse { fn clone(&self) -> CefResponse{ 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); } CefResponse { @@ -157,7 +159,8 @@ impl Clone for CefResponse { impl Drop for CefResponse { 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); } } @@ -172,7 +175,8 @@ impl CefResponse { } pub unsafe fn from_c_object_addref(c_object: *mut cef_response_t) -> CefResponse { - 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); } CefResponse { @@ -186,7 +190,8 @@ impl CefResponse { pub fn c_object_addrefed(&self) -> *mut cef_response_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 @@ -194,17 +199,18 @@ impl CefResponse { } 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 { @@ -218,7 +224,8 @@ impl CefResponse { // Get the response status code. // pub fn get_status(&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 { @@ -232,7 +239,8 @@ impl CefResponse { // Set the response status code. // pub fn set_status(&self, status: 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 { @@ -248,7 +256,8 @@ impl CefResponse { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_status_text(&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 { @@ -262,7 +271,8 @@ impl CefResponse { // Set the response status text. // pub fn set_status_text(&self, statusText: &[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 { @@ -278,7 +288,8 @@ impl CefResponse { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_mime_type(&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 { @@ -292,7 +303,8 @@ impl CefResponse { // Set the response mime type. // pub fn set_mime_type(&self, mimeType: &[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 { @@ -308,7 +320,8 @@ impl CefResponse { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_header(&self, name: &[u16]) -> 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 { @@ -323,7 +336,8 @@ impl CefResponse { // Get all response header fields. // pub fn get_header_map(&self, headerMap: HashMap>) -> () { - 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 { @@ -338,7 +352,8 @@ impl CefResponse { // Set all response header fields. // pub fn set_header_map(&self, headerMap: HashMap>) -> () { - 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 { @@ -377,7 +392,8 @@ impl CefWrap<*mut cef_response_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_response_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefResponse::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_scheme.rs b/ports/cef/interfaces/cef_scheme.rs index 871173b083e..2bf8a0030e3 100644 --- a/ports/cef/interfaces/cef_scheme.rs +++ b/ports/cef/interfaces/cef_scheme.rs @@ -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_scheme_registrar_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_scheme_registrar_t = _cef_scheme_registrar_t; @@ -129,7 +130,8 @@ pub struct CefSchemeRegistrar { impl Clone for CefSchemeRegistrar { fn clone(&self) -> CefSchemeRegistrar{ 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); } CefSchemeRegistrar { @@ -142,7 +144,8 @@ impl Clone for CefSchemeRegistrar { impl Drop for CefSchemeRegistrar { 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); } } @@ -157,7 +160,8 @@ impl CefSchemeRegistrar { } pub unsafe fn from_c_object_addref(c_object: *mut cef_scheme_registrar_t) -> CefSchemeRegistrar { - 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); } CefSchemeRegistrar { @@ -171,7 +175,8 @@ impl CefSchemeRegistrar { pub fn c_object_addrefed(&self) -> *mut cef_scheme_registrar_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 @@ -179,10 +184,10 @@ impl CefSchemeRegistrar { } 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 } // @@ -234,7 +239,8 @@ impl CefSchemeRegistrar { pub fn add_custom_scheme(&self, scheme_name: &[u16], is_standard: libc::c_int, is_local: libc::c_int, is_display_isolated: libc::c_int) -> 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 +271,8 @@ impl CefWrap<*mut cef_scheme_registrar_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_scheme_registrar_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefSchemeRegistrar::from_c_object_addref(c_object)) @@ -303,13 +310,13 @@ pub struct _cef_scheme_handler_factory_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_scheme_handler_factory_t = _cef_scheme_handler_factory_t; @@ -326,7 +333,8 @@ pub struct CefSchemeHandlerFactory { impl Clone for CefSchemeHandlerFactory { fn clone(&self) -> CefSchemeHandlerFactory{ 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); } CefSchemeHandlerFactory { @@ -339,7 +347,8 @@ impl Clone for CefSchemeHandlerFactory { impl Drop for CefSchemeHandlerFactory { 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); } } @@ -354,7 +363,8 @@ impl CefSchemeHandlerFactory { } pub unsafe fn from_c_object_addref(c_object: *mut cef_scheme_handler_factory_t) -> CefSchemeHandlerFactory { - 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); } CefSchemeHandlerFactory { @@ -368,7 +378,8 @@ impl CefSchemeHandlerFactory { pub fn c_object_addrefed(&self) -> *mut cef_scheme_handler_factory_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 @@ -376,10 +387,10 @@ impl CefSchemeHandlerFactory { } 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 } // @@ -393,7 +404,8 @@ impl CefSchemeHandlerFactory { pub fn create(&self, browser: interfaces::CefBrowser, frame: interfaces::CefFrame, scheme_name: &[u16], request: interfaces::CefRequest) -> interfaces::CefResourceHandler { - 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 { @@ -424,7 +436,8 @@ impl CefWrap<*mut cef_scheme_handler_factory_t> for Option Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefSchemeHandlerFactory::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_ssl_info.rs b/ports/cef/interfaces/cef_ssl_info.rs index 77b434eb5dc..d2cfcba7c59 100644 --- a/ports/cef/interfaces/cef_ssl_info.rs +++ b/ports/cef/interfaces/cef_ssl_info.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -122,13 +123,13 @@ pub struct _cef_sslcert_principal_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_sslcert_principal_t = _cef_sslcert_principal_t; @@ -143,7 +144,8 @@ pub struct CefSSLCertPrincipal { impl Clone for CefSSLCertPrincipal { fn clone(&self) -> CefSSLCertPrincipal{ 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); } CefSSLCertPrincipal { @@ -156,7 +158,8 @@ impl Clone for CefSSLCertPrincipal { impl Drop for CefSSLCertPrincipal { 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); } } @@ -171,7 +174,8 @@ impl CefSSLCertPrincipal { } pub unsafe fn from_c_object_addref(c_object: *mut cef_sslcert_principal_t) -> CefSSLCertPrincipal { - 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); } CefSSLCertPrincipal { @@ -185,7 +189,8 @@ impl CefSSLCertPrincipal { pub fn c_object_addrefed(&self) -> *mut cef_sslcert_principal_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 @@ -193,10 +198,10 @@ impl CefSSLCertPrincipal { } 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 } // @@ -205,7 +210,8 @@ impl CefSSLCertPrincipal { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_display_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 { @@ -220,7 +226,8 @@ impl CefSSLCertPrincipal { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_common_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 { @@ -235,7 +242,8 @@ impl CefSSLCertPrincipal { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_locality_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 { @@ -250,7 +258,8 @@ impl CefSSLCertPrincipal { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_state_or_province_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 { @@ -265,7 +274,8 @@ impl CefSSLCertPrincipal { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_country_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 { @@ -279,7 +289,8 @@ impl CefSSLCertPrincipal { // Retrieve the list of street addresses. // pub fn get_street_addresses(&self, addresses: Vec) -> () { - 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 { @@ -294,7 +305,8 @@ impl CefSSLCertPrincipal { // Retrieve the list of organization names. // pub fn get_organization_names(&self, names: Vec) -> () { - 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 { @@ -309,7 +321,8 @@ impl CefSSLCertPrincipal { // Retrieve the list of organization unit names. // pub fn get_organization_unit_names(&self, names: Vec) -> () { - 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 { @@ -324,7 +337,8 @@ impl CefSSLCertPrincipal { // Retrieve the list of domain components. // pub fn get_domain_components(&self, components: Vec) -> () { - 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 { @@ -352,7 +366,8 @@ impl CefWrap<*mut cef_sslcert_principal_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_sslcert_principal_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefSSLCertPrincipal::from_c_object_addref(c_object)) @@ -421,13 +436,13 @@ pub struct _cef_sslinfo_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_sslinfo_t = _cef_sslinfo_t; @@ -442,7 +457,8 @@ pub struct CefSSLInfo { impl Clone for CefSSLInfo { fn clone(&self) -> CefSSLInfo{ 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); } CefSSLInfo { @@ -455,7 +471,8 @@ impl Clone for CefSSLInfo { impl Drop for CefSSLInfo { 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); } } @@ -470,7 +487,8 @@ impl CefSSLInfo { } pub unsafe fn from_c_object_addref(c_object: *mut cef_sslinfo_t) -> CefSSLInfo { - 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); } CefSSLInfo { @@ -484,7 +502,8 @@ impl CefSSLInfo { pub fn c_object_addrefed(&self) -> *mut cef_sslinfo_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 @@ -492,10 +511,10 @@ impl CefSSLInfo { } 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 } // @@ -504,7 +523,8 @@ impl CefSSLInfo { // match the host name of the web server. // pub fn get_subject(&self) -> interfaces::CefSSLCertPrincipal { - 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 { @@ -518,7 +538,8 @@ impl CefSSLInfo { // Returns the issuer of the X.509 certificate. // pub fn get_issuer(&self) -> interfaces::CefSSLCertPrincipal { - 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 { @@ -533,7 +554,8 @@ impl CefSSLInfo { // possibly includes a leading 00 byte. // pub fn get_serial_number(&self) -> interfaces::CefBinaryValue { - 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 { @@ -548,7 +570,8 @@ impl CefSSLInfo { // CefTime.GetTimeT() will return 0 if no date was specified. // pub fn get_valid_start(&self) -> types::cef_time_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 { @@ -563,7 +586,8 @@ impl CefSSLInfo { // CefTime.GetTimeT() will return 0 if no date was specified. // pub fn get_valid_expiry(&self) -> types::cef_time_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 { @@ -577,7 +601,8 @@ impl CefSSLInfo { // Returns the DER encoded data for the X.509 certificate. // pub fn get_derencoded(&self) -> interfaces::CefBinaryValue { - 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 { @@ -591,7 +616,8 @@ impl CefSSLInfo { // Returns the PEM encoded data for the X.509 certificate. // pub fn get_pemencoded(&self) -> interfaces::CefBinaryValue { - 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 { @@ -618,7 +644,8 @@ impl CefWrap<*mut cef_sslinfo_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_sslinfo_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefSSLInfo::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_stream.rs b/ports/cef/interfaces/cef_stream.rs index 598436523ca..8489931a283 100644 --- a/ports/cef/interfaces/cef_stream.rs +++ b/ports/cef/interfaces/cef_stream.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -90,13 +91,13 @@ pub struct _cef_read_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_read_handler_t = _cef_read_handler_t; @@ -112,7 +113,8 @@ pub struct CefReadHandler { impl Clone for CefReadHandler { fn clone(&self) -> CefReadHandler{ 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); } CefReadHandler { @@ -125,7 +127,8 @@ impl Clone for CefReadHandler { impl Drop for CefReadHandler { 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 CefReadHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_read_handler_t) -> CefReadHandler { - 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); } CefReadHandler { @@ -154,7 +158,8 @@ impl CefReadHandler { pub fn c_object_addrefed(&self) -> *mut cef_read_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 @@ -162,10 +167,10 @@ impl CefReadHandler { } 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 CefReadHandler { // pub fn read(&self, ptr: &mut (), size: libc::size_t, n: libc::size_t) -> 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 { @@ -191,7 +197,8 @@ impl CefReadHandler { // SEEK_END or SEEK_SET. Return zero on success and non-zero on failure. // pub fn seek(&self, offset: i64, whence: libc::c_int) -> 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 { @@ -207,7 +214,8 @@ impl CefReadHandler { // Return the current offset position. // pub fn tell(&self) -> i64 { - 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 +229,8 @@ impl CefReadHandler { // Return non-zero if at end of file. // pub fn eof(&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 { @@ -237,7 +246,8 @@ impl CefReadHandler { // the handler from. // pub fn may_block(&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 { @@ -264,7 +274,8 @@ impl CefWrap<*mut cef_read_handler_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_read_handler_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefReadHandler::from_c_object_addref(c_object)) @@ -318,13 +329,13 @@ pub struct _cef_stream_reader_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_stream_reader_t = _cef_stream_reader_t; @@ -340,7 +351,8 @@ pub struct CefStreamReader { impl Clone for CefStreamReader { fn clone(&self) -> CefStreamReader{ 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); } CefStreamReader { @@ -353,7 +365,8 @@ impl Clone for CefStreamReader { impl Drop for CefStreamReader { 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); } } @@ -368,7 +381,8 @@ impl CefStreamReader { } pub unsafe fn from_c_object_addref(c_object: *mut cef_stream_reader_t) -> CefStreamReader { - 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); } CefStreamReader { @@ -382,7 +396,8 @@ impl CefStreamReader { pub fn c_object_addrefed(&self) -> *mut cef_stream_reader_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 @@ -390,10 +405,10 @@ impl CefStreamReader { } 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 } // @@ -401,7 +416,8 @@ impl CefStreamReader { // pub fn read(&self, ptr: &mut (), size: libc::size_t, n: libc::size_t) -> 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 { @@ -419,7 +435,8 @@ impl CefStreamReader { // SEEK_END or SEEK_SET. Returns zero on success and non-zero on failure. // pub fn seek(&self, offset: i64, whence: libc::c_int) -> 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 { @@ -435,7 +452,8 @@ impl CefStreamReader { // Return the current offset position. // pub fn tell(&self) -> i64 { - 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 { @@ -449,7 +467,8 @@ impl CefStreamReader { // Return non-zero if at end of file. // pub fn eof(&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 { @@ -465,7 +484,8 @@ impl CefStreamReader { // the reader from. // pub fn may_block(&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 { @@ -528,7 +548,8 @@ impl CefWrap<*mut cef_stream_reader_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_stream_reader_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefStreamReader::from_c_object_addref(c_object)) @@ -583,13 +604,13 @@ pub struct _cef_write_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_write_handler_t = _cef_write_handler_t; @@ -605,7 +626,8 @@ pub struct CefWriteHandler { impl Clone for CefWriteHandler { fn clone(&self) -> CefWriteHandler{ 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); } CefWriteHandler { @@ -618,7 +640,8 @@ impl Clone for CefWriteHandler { impl Drop for CefWriteHandler { 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); } } @@ -633,7 +656,8 @@ impl CefWriteHandler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_write_handler_t) -> CefWriteHandler { - 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); } CefWriteHandler { @@ -647,7 +671,8 @@ impl CefWriteHandler { pub fn c_object_addrefed(&self) -> *mut cef_write_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 @@ -655,10 +680,10 @@ impl CefWriteHandler { } 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 } // @@ -666,7 +691,8 @@ impl CefWriteHandler { // pub fn write(&self, ptr: &(), size: libc::size_t, n: libc::size_t) -> 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 { @@ -684,7 +710,8 @@ impl CefWriteHandler { // SEEK_END or SEEK_SET. Return zero on success and non-zero on failure. // pub fn seek(&self, offset: i64, whence: libc::c_int) -> 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 +727,8 @@ impl CefWriteHandler { // Return the current offset position. // pub fn tell(&self) -> i64 { - 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 { @@ -714,7 +742,8 @@ impl CefWriteHandler { // Flush the stream. // pub fn flush(&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 { @@ -730,7 +759,8 @@ impl CefWriteHandler { // the handler from. // pub fn may_block(&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 { @@ -757,7 +787,8 @@ impl CefWrap<*mut cef_write_handler_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_write_handler_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefWriteHandler::from_c_object_addref(c_object)) @@ -812,13 +843,13 @@ pub struct _cef_stream_writer_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_stream_writer_t = _cef_stream_writer_t; @@ -834,7 +865,8 @@ pub struct CefStreamWriter { impl Clone for CefStreamWriter { fn clone(&self) -> CefStreamWriter{ 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); } CefStreamWriter { @@ -847,7 +879,8 @@ impl Clone for CefStreamWriter { impl Drop for CefStreamWriter { 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); } } @@ -862,7 +895,8 @@ impl CefStreamWriter { } pub unsafe fn from_c_object_addref(c_object: *mut cef_stream_writer_t) -> CefStreamWriter { - 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); } CefStreamWriter { @@ -876,7 +910,8 @@ impl CefStreamWriter { pub fn c_object_addrefed(&self) -> *mut cef_stream_writer_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 @@ -884,10 +919,10 @@ impl CefStreamWriter { } 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 } // @@ -895,7 +930,8 @@ impl CefStreamWriter { // pub fn write(&self, ptr: &(), size: libc::size_t, n: libc::size_t) -> 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 { @@ -913,7 +949,8 @@ impl CefStreamWriter { // SEEK_END or SEEK_SET. Returns zero on success and non-zero on failure. // pub fn seek(&self, offset: i64, whence: libc::c_int) -> 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 { @@ -929,7 +966,8 @@ impl CefStreamWriter { // Return the current offset position. // pub fn tell(&self) -> i64 { - 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 { @@ -943,7 +981,8 @@ impl CefStreamWriter { // Flush the stream. // pub fn flush(&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 { @@ -959,7 +998,8 @@ impl CefStreamWriter { // the writer from. // pub fn may_block(&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 { @@ -1009,7 +1049,8 @@ impl CefWrap<*mut cef_stream_writer_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_stream_writer_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefStreamWriter::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_string_visitor.rs b/ports/cef/interfaces/cef_string_visitor.rs index e28c3f016d6..f895aa70643 100644 --- a/ports/cef/interfaces/cef_string_visitor.rs +++ b/ports/cef/interfaces/cef_string_visitor.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -64,13 +65,13 @@ pub struct _cef_string_visitor_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_string_visitor_t = _cef_string_visitor_t; @@ -85,7 +86,8 @@ pub struct CefStringVisitor { impl Clone for CefStringVisitor { fn clone(&self) -> CefStringVisitor{ 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); } CefStringVisitor { @@ -98,7 +100,8 @@ impl Clone for CefStringVisitor { impl Drop for CefStringVisitor { 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); } } @@ -113,7 +116,8 @@ impl CefStringVisitor { } pub unsafe fn from_c_object_addref(c_object: *mut cef_string_visitor_t) -> CefStringVisitor { - 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); } CefStringVisitor { @@ -127,7 +131,8 @@ impl CefStringVisitor { pub fn c_object_addrefed(&self) -> *mut cef_string_visitor_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 @@ -135,17 +140,18 @@ impl CefStringVisitor { } 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. // pub fn visit(&self, string: &[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 { @@ -173,7 +179,8 @@ impl CefWrap<*mut cef_string_visitor_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_string_visitor_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefStringVisitor::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_task.rs b/ports/cef/interfaces/cef_task.rs index aa94aebd23f..762bcf65362 100644 --- a/ports/cef/interfaces/cef_task.rs +++ b/ports/cef/interfaces/cef_task.rs @@ -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 { } } unsafe fn to_rust(c_object: *mut cef_task_t) -> Option { - 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 { } } unsafe fn to_rust(c_object: *mut cef_task_runner_t) -> Option { - 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)) diff --git a/ports/cef/interfaces/cef_trace.rs b/ports/cef/interfaces/cef_trace.rs index b954cef0e50..2a1793864bb 100644 --- a/ports/cef/interfaces/cef_trace.rs +++ b/ports/cef/interfaces/cef_trace.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -69,13 +70,13 @@ pub struct _cef_end_tracing_callback_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_end_tracing_callback_t = _cef_end_tracing_callback_t; @@ -92,7 +93,8 @@ pub struct CefEndTracingCallback { impl Clone for CefEndTracingCallback { fn clone(&self) -> CefEndTracingCallback{ 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); } CefEndTracingCallback { @@ -105,7 +107,8 @@ impl Clone for CefEndTracingCallback { impl Drop for CefEndTracingCallback { 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); } } @@ -120,7 +123,8 @@ impl CefEndTracingCallback { } pub unsafe fn from_c_object_addref(c_object: *mut cef_end_tracing_callback_t) -> CefEndTracingCallback { - 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); } CefEndTracingCallback { @@ -134,7 +138,8 @@ impl CefEndTracingCallback { pub fn c_object_addrefed(&self) -> *mut cef_end_tracing_callback_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 @@ -142,10 +147,10 @@ impl CefEndTracingCallback { } 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 } // @@ -154,7 +159,8 @@ impl CefEndTracingCallback { // deleting |tracing_file|. // pub fn on_end_tracing_complete(&self, tracing_file: &[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 { @@ -182,7 +188,8 @@ impl CefWrap<*mut cef_end_tracing_callback_t> for Option } } unsafe fn to_rust(c_object: *mut cef_end_tracing_callback_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefEndTracingCallback::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_urlrequest.rs b/ports/cef/interfaces/cef_urlrequest.rs index 7bbd7f84e2f..deec0bcdd6b 100644 --- a/ports/cef/interfaces/cef_urlrequest.rs +++ b/ports/cef/interfaces/cef_urlrequest.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -101,13 +102,13 @@ pub struct _cef_urlrequest_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_urlrequest_t = _cef_urlrequest_t; @@ -126,7 +127,8 @@ pub struct CefURLRequest { impl Clone for CefURLRequest { fn clone(&self) -> CefURLRequest{ 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); } CefURLRequest { @@ -139,7 +141,8 @@ impl Clone for CefURLRequest { impl Drop for CefURLRequest { 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); } } @@ -154,7 +157,8 @@ impl CefURLRequest { } pub unsafe fn from_c_object_addref(c_object: *mut cef_urlrequest_t) -> CefURLRequest { - 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); } CefURLRequest { @@ -168,7 +172,8 @@ impl CefURLRequest { pub fn c_object_addrefed(&self) -> *mut cef_urlrequest_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 @@ -176,10 +181,10 @@ impl CefURLRequest { } 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 } // @@ -187,7 +192,8 @@ impl CefURLRequest { // object is read-only and should not be modified. // pub fn get_request(&self) -> interfaces::CefRequest { - 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 { @@ -201,7 +207,8 @@ impl CefURLRequest { // Returns the client. // pub fn get_client(&self) -> interfaces::CefURLRequestClient { - 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 { @@ -215,7 +222,8 @@ impl CefURLRequest { // Returns the request status. // pub fn get_request_status(&self) -> types::cef_urlrequest_status_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 { @@ -230,7 +238,8 @@ impl CefURLRequest { // otherwise. // pub fn get_request_error(&self) -> types::cef_errorcode_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 { @@ -246,7 +255,8 @@ impl CefURLRequest { // The returned object is read-only and should not be modified. // pub fn get_response(&self) -> interfaces::CefResponse { - 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 { @@ -260,7 +270,8 @@ impl CefURLRequest { // Cancel the request. // pub fn cancel(&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 { @@ -314,7 +325,8 @@ impl CefWrap<*mut cef_urlrequest_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_urlrequest_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefURLRequest::from_c_object_addref(c_object)) @@ -392,13 +404,13 @@ pub struct _cef_urlrequest_client_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_urlrequest_client_t = _cef_urlrequest_client_t; @@ -415,7 +427,8 @@ pub struct CefURLRequestClient { impl Clone for CefURLRequestClient { fn clone(&self) -> CefURLRequestClient{ 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); } CefURLRequestClient { @@ -428,7 +441,8 @@ impl Clone for CefURLRequestClient { impl Drop for CefURLRequestClient { 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); } } @@ -443,7 +457,8 @@ impl CefURLRequestClient { } pub unsafe fn from_c_object_addref(c_object: *mut cef_urlrequest_client_t) -> CefURLRequestClient { - 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); } CefURLRequestClient { @@ -457,7 +472,8 @@ impl CefURLRequestClient { pub fn c_object_addrefed(&self) -> *mut cef_urlrequest_client_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 @@ -465,10 +481,10 @@ impl CefURLRequestClient { } 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 } // @@ -477,7 +493,8 @@ impl CefURLRequestClient { // successful or not. // pub fn on_request_complete(&self, request: interfaces::CefURLRequest) -> () { - 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 { @@ -496,7 +513,8 @@ impl CefURLRequestClient { // pub fn on_upload_progress(&self, request: interfaces::CefURLRequest, current: i64, total: i64) -> () { - 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 { @@ -516,7 +534,8 @@ impl CefURLRequestClient { // pub fn on_download_progress(&self, request: interfaces::CefURLRequest, current: i64, total: i64) -> () { - 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 { @@ -536,7 +555,8 @@ impl CefURLRequestClient { // pub fn on_download_data(&self, request: interfaces::CefURLRequest, data: &(), data_length: 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 { @@ -561,7 +581,8 @@ impl CefURLRequestClient { pub fn get_auth_credentials(&self, isProxy: libc::c_int, host: &[u16], port: libc::c_int, realm: &[u16], scheme: &[u16], callback: interfaces::CefAuthCallback) -> 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 { @@ -594,7 +615,8 @@ impl CefWrap<*mut cef_urlrequest_client_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_urlrequest_client_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefURLRequestClient::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_v8.rs b/ports/cef/interfaces/cef_v8.rs index 8f8db1ae171..efe234b92a3 100644 --- a/ports/cef/interfaces/cef_v8.rs +++ b/ports/cef/interfaces/cef_v8.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -131,13 +132,13 @@ pub struct _cef_v8context_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_v8context_t = _cef_v8context_t; @@ -156,7 +157,8 @@ pub struct CefV8Context { impl Clone for CefV8Context { fn clone(&self) -> CefV8Context{ 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); } CefV8Context { @@ -169,7 +171,8 @@ impl Clone for CefV8Context { impl Drop for CefV8Context { 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); } } @@ -184,7 +187,8 @@ impl CefV8Context { } pub unsafe fn from_c_object_addref(c_object: *mut cef_v8context_t) -> CefV8Context { - 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); } CefV8Context { @@ -198,7 +202,8 @@ impl CefV8Context { pub fn c_object_addrefed(&self) -> *mut cef_v8context_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 @@ -206,10 +211,10 @@ impl CefV8Context { } 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 } // @@ -218,7 +223,8 @@ impl CefV8Context { // called on any render process thread. // pub fn get_task_runner(&self) -> interfaces::CefTaskRunner { - 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 { @@ -234,7 +240,8 @@ impl CefV8Context { // 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 { @@ -249,7 +256,8 @@ impl CefV8Context { // reference for WebWorker contexts. // pub fn get_browser(&self) -> interfaces::CefBrowser { - 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 { @@ -264,7 +272,8 @@ impl CefV8Context { // reference for WebWorker contexts. // pub fn get_frame(&self) -> 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 { @@ -279,7 +288,8 @@ impl CefV8Context { // before calling this function. // pub fn get_global(&self) -> interfaces::CefV8Value { - 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 +307,8 @@ impl CefV8Context { // if the scope was entered successfully. // pub fn enter(&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 { @@ -312,7 +323,8 @@ impl CefV8Context { // true (1) if the scope was exited successfully. // pub fn exit(&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 { @@ -327,7 +339,8 @@ impl CefV8Context { // object. // pub fn is_same(&self, that: interfaces::CefV8Context) -> 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 { @@ -346,7 +359,8 @@ impl CefV8Context { // pub fn eval(&self, code: &[u16], retval: interfaces::CefV8Value, exception: interfaces::CefV8Exception) -> 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 { @@ -409,7 +423,8 @@ impl CefWrap<*mut cef_v8context_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_v8context_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefV8Context::from_c_object_addref(c_object)) @@ -447,13 +462,13 @@ pub struct _cef_v8handler_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_v8handler_t = _cef_v8handler_t; @@ -470,7 +485,8 @@ pub struct CefV8Handler { impl Clone for CefV8Handler { fn clone(&self) -> CefV8Handler{ 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); } CefV8Handler { @@ -483,7 +499,8 @@ impl Clone for CefV8Handler { impl Drop for CefV8Handler { 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); } } @@ -498,7 +515,8 @@ impl CefV8Handler { } pub unsafe fn from_c_object_addref(c_object: *mut cef_v8handler_t) -> CefV8Handler { - 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); } CefV8Handler { @@ -512,7 +530,8 @@ impl CefV8Handler { pub fn c_object_addrefed(&self) -> *mut cef_v8handler_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 @@ -520,10 +539,10 @@ impl CefV8Handler { } 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 } // @@ -537,7 +556,8 @@ impl CefV8Handler { arguments_count: libc::size_t, arguments: *const interfaces::CefV8Value, retval: interfaces::CefV8Value, exception: *mut types::cef_string_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 { @@ -570,7 +590,8 @@ impl CefWrap<*mut cef_v8handler_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_v8handler_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefV8Handler::from_c_object_addref(c_object)) @@ -619,13 +640,13 @@ pub struct _cef_v8accessor_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_v8accessor_t = _cef_v8accessor_t; @@ -643,7 +664,8 @@ pub struct CefV8Accessor { impl Clone for CefV8Accessor { fn clone(&self) -> CefV8Accessor{ 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); } CefV8Accessor { @@ -656,7 +678,8 @@ impl Clone for CefV8Accessor { impl Drop for CefV8Accessor { 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); } } @@ -671,7 +694,8 @@ impl CefV8Accessor { } pub unsafe fn from_c_object_addref(c_object: *mut cef_v8accessor_t) -> CefV8Accessor { - 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); } CefV8Accessor { @@ -685,7 +709,8 @@ impl CefV8Accessor { pub fn c_object_addrefed(&self) -> *mut cef_v8accessor_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 @@ -693,10 +718,10 @@ impl CefV8Accessor { } 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 } // @@ -709,7 +734,8 @@ impl CefV8Accessor { pub fn get(&self, name: &[u16], object: interfaces::CefV8Value, retval: interfaces::CefV8Value, exception: *mut types::cef_string_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 { @@ -733,7 +759,8 @@ impl CefV8Accessor { pub fn set(&self, name: &[u16], object: interfaces::CefV8Value, value: interfaces::CefV8Value, exception: *mut types::cef_string_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 { @@ -764,7 +791,8 @@ impl CefWrap<*mut cef_v8accessor_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_v8accessor_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefV8Accessor::from_c_object_addref(c_object)) @@ -844,13 +872,13 @@ pub struct _cef_v8exception_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_v8exception_t = _cef_v8exception_t; @@ -866,7 +894,8 @@ pub struct CefV8Exception { impl Clone for CefV8Exception { fn clone(&self) -> CefV8Exception{ 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); } CefV8Exception { @@ -879,7 +908,8 @@ impl Clone for CefV8Exception { impl Drop for CefV8Exception { 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); } } @@ -894,7 +924,8 @@ impl CefV8Exception { } pub unsafe fn from_c_object_addref(c_object: *mut cef_v8exception_t) -> CefV8Exception { - 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); } CefV8Exception { @@ -908,7 +939,8 @@ impl CefV8Exception { pub fn c_object_addrefed(&self) -> *mut cef_v8exception_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 @@ -916,10 +948,10 @@ impl CefV8Exception { } 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 } // @@ -927,7 +959,8 @@ impl CefV8Exception { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_message(&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 { @@ -942,7 +975,8 @@ impl CefV8Exception { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_source_line(&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 { @@ -958,7 +992,8 @@ impl CefV8Exception { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_script_resource_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 { @@ -973,7 +1008,8 @@ impl CefV8Exception { // line number is unknown. // pub fn get_line_number(&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 { @@ -988,7 +1024,8 @@ impl CefV8Exception { // occurred. // pub fn get_start_position(&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 { @@ -1003,7 +1040,8 @@ impl CefV8Exception { // occurred. // pub fn get_end_position(&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 { @@ -1018,7 +1056,8 @@ impl CefV8Exception { // occurred. // pub fn get_start_column(&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 { @@ -1033,7 +1072,8 @@ impl CefV8Exception { // occurred. // pub fn get_end_column(&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 { @@ -1060,7 +1100,8 @@ impl CefWrap<*mut cef_v8exception_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_v8exception_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefV8Exception::from_c_object_addref(c_object)) @@ -1416,13 +1457,13 @@ pub struct _cef_v8value_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_v8value_t = _cef_v8value_t; @@ -1441,7 +1482,8 @@ pub struct CefV8Value { impl Clone for CefV8Value { fn clone(&self) -> CefV8Value{ 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); } CefV8Value { @@ -1454,7 +1496,8 @@ impl Clone for CefV8Value { impl Drop for CefV8Value { 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); } } @@ -1469,7 +1512,8 @@ impl CefV8Value { } pub unsafe fn from_c_object_addref(c_object: *mut cef_v8value_t) -> CefV8Value { - 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); } CefV8Value { @@ -1483,7 +1527,8 @@ impl CefV8Value { pub fn c_object_addrefed(&self) -> *mut cef_v8value_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 @@ -1491,10 +1536,10 @@ impl CefV8Value { } 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 } // @@ -1503,7 +1548,8 @@ impl CefV8Value { // 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 { @@ -1517,7 +1563,8 @@ impl CefV8Value { // True if the value type is undefined. // pub fn is_undefined(&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 { @@ -1531,7 +1578,8 @@ impl CefV8Value { // True if the value type is null. // pub fn is_null(&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 { @@ -1545,7 +1593,8 @@ impl CefV8Value { // True if the value type is bool. // pub fn is_bool(&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 { @@ -1559,7 +1608,8 @@ impl CefV8Value { // True if the value type is int. // pub fn is_int(&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 { @@ -1573,7 +1623,8 @@ impl CefV8Value { // True if the value type is unsigned int. // pub fn is_uint(&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 { @@ -1587,7 +1638,8 @@ impl CefV8Value { // True if the value type is double. // pub fn is_double(&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 { @@ -1601,7 +1653,8 @@ impl CefV8Value { // True if the value type is Date. // pub fn is_date(&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 { @@ -1615,7 +1668,8 @@ impl CefV8Value { // True if the value type is string. // pub fn is_string(&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 { @@ -1629,7 +1683,8 @@ impl CefV8Value { // True if the value type is object. // pub fn is_object(&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 { @@ -1643,7 +1698,8 @@ impl CefV8Value { // True if the value type is array. // pub fn is_array(&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 { @@ -1657,7 +1713,8 @@ impl CefV8Value { // True if the value type is function. // pub fn is_function(&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 { @@ -1672,7 +1729,8 @@ impl CefV8Value { // object. // pub fn is_same(&self, that: interfaces::CefV8Value) -> 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 { @@ -1688,7 +1746,8 @@ impl CefV8Value { // necessary. // pub fn get_bool_value(&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 { @@ -1703,7 +1762,8 @@ impl CefV8Value { // necessary. // pub fn get_int_value(&self) -> i32 { - 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 { @@ -1718,7 +1778,8 @@ impl CefV8Value { // necessary. // pub fn get_uint_value(&self) -> u32 { - 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 { @@ -1733,7 +1794,8 @@ impl CefV8Value { // necessary. // pub fn get_double_value(&self) -> libc::c_double { - 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 { @@ -1748,7 +1810,8 @@ impl CefV8Value { // necessary. // pub fn get_date_value(&self) -> types::cef_time_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 { @@ -1764,7 +1827,8 @@ impl CefV8Value { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_string_value(&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 { @@ -1783,7 +1847,8 @@ impl CefV8Value { // Returns true (1) if this is a user created object. // pub fn is_user_created(&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 { @@ -1798,7 +1863,8 @@ impl CefV8Value { // attribute exists only in the scope of the current CEF value object. // pub fn has_exception(&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 { @@ -1813,7 +1879,8 @@ impl CefV8Value { // exists only in the scope of the current CEF value object. // pub fn get_exception(&self) -> interfaces::CefV8Exception { - 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 { @@ -1827,7 +1894,8 @@ impl CefV8Value { // Clears the last exception and returns true (1) on success. // pub fn clear_exception(&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 { @@ -1842,7 +1910,8 @@ impl CefV8Value { // attribute exists only in the scope of the current CEF value object. // pub fn will_rethrow_exceptions(&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 { @@ -1860,7 +1929,8 @@ impl CefV8Value { // exists only in the scope of the current CEF value object. // pub fn set_rethrow_exceptions(&self, rethrow: libc::c_int) -> 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 { @@ -1875,7 +1945,8 @@ impl CefV8Value { // Returns true (1) if the object has a value with the specified identifier. // pub fn has_value_bykey(&self, key: &[u16]) -> 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 { @@ -1890,7 +1961,8 @@ impl CefV8Value { // Returns true (1) if the object has a value with the specified identifier. // pub fn has_value_byindex(&self, index: libc::c_int) -> 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 { @@ -1908,7 +1980,8 @@ impl CefV8Value { // will return true (1) even though deletion failed. // pub fn delete_value_bykey(&self, key: &[u16]) -> 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 { @@ -1926,7 +1999,8 @@ impl CefV8Value { // function will return true (1) even though deletion failed. // pub fn delete_value_byindex(&self, index: libc::c_int) -> 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 { @@ -1942,7 +2016,8 @@ impl CefV8Value { // this function is called incorrectly or an exception is thrown. // pub fn get_value_bykey(&self, key: &[u16]) -> interfaces::CefV8Value { - 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 { @@ -1959,7 +2034,8 @@ impl CefV8Value { // pub fn get_value_byindex(&self, index: libc::c_int) -> interfaces::CefV8Value { - 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 { @@ -1978,7 +2054,8 @@ impl CefV8Value { // pub fn set_value_bykey(&self, key: &[u16], value: interfaces::CefV8Value, attribute: types::cef_v8_propertyattribute_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 { @@ -1999,7 +2076,8 @@ impl CefV8Value { // pub fn set_value_byindex(&self, index: libc::c_int, value: interfaces::CefV8Value) -> 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 { @@ -2021,7 +2099,8 @@ impl CefV8Value { pub fn set_value_byaccessor(&self, key: &[u16], settings: types::cef_v8_accesscontrol_t, attribute: types::cef_v8_propertyattribute_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 { @@ -2039,7 +2118,8 @@ impl CefV8Value { // based keys will also be returned as strings. // pub fn get_keys(&self, keys: Vec) -> 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 { @@ -2056,7 +2136,8 @@ impl CefV8Value { // called on user created objects. // pub fn set_user_data(&self, user_data: interfaces::CefBase) -> 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 { @@ -2071,7 +2152,8 @@ impl CefV8Value { // Returns the user data, if any, assigned to this object. // pub fn get_user_data(&self) -> interfaces::CefBase { - 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 { @@ -2086,7 +2168,8 @@ impl CefV8Value { // object. // pub fn get_externally_allocated_memory(&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 { @@ -2109,7 +2192,8 @@ impl CefV8Value { // pub fn adjust_externally_allocated_memory(&self, change_in_bytes: libc::c_int) -> 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 { @@ -2127,7 +2211,8 @@ impl CefV8Value { // Returns the number of elements in the array. // pub fn get_array_length(&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 { @@ -2145,7 +2230,8 @@ impl CefV8Value { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_function_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 { @@ -2159,7 +2245,8 @@ impl CefV8Value { // Returns the function handler or NULL if not a CEF-created function. // pub fn get_function_handler(&self) -> interfaces::CefV8Handler { - 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 { @@ -2183,7 +2270,8 @@ impl CefV8Value { pub fn execute_function(&self, object: interfaces::CefV8Value, arguments_count: libc::size_t, arguments: *const interfaces::CefV8Value) -> interfaces::CefV8Value { - 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 { @@ -2207,7 +2295,8 @@ impl CefV8Value { pub fn execute_function_with_context(&self, context: interfaces::CefV8Context, object: interfaces::CefV8Value, arguments_count: libc::size_t, arguments: *const interfaces::CefV8Value) -> interfaces::CefV8Value { - 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 { @@ -2377,7 +2466,8 @@ impl CefWrap<*mut cef_v8value_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_v8value_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefV8Value::from_c_object_addref(c_object)) @@ -2423,13 +2513,13 @@ pub struct _cef_v8stack_trace_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_v8stack_trace_t = _cef_v8stack_trace_t; @@ -2448,7 +2538,8 @@ pub struct CefV8StackTrace { impl Clone for CefV8StackTrace { fn clone(&self) -> CefV8StackTrace{ 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); } CefV8StackTrace { @@ -2461,7 +2552,8 @@ impl Clone for CefV8StackTrace { impl Drop for CefV8StackTrace { 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); } } @@ -2476,7 +2568,8 @@ impl CefV8StackTrace { } pub unsafe fn from_c_object_addref(c_object: *mut cef_v8stack_trace_t) -> CefV8StackTrace { - 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); } CefV8StackTrace { @@ -2490,7 +2583,8 @@ impl CefV8StackTrace { pub fn c_object_addrefed(&self) -> *mut cef_v8stack_trace_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 @@ -2498,10 +2592,10 @@ impl CefV8StackTrace { } 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 } // @@ -2510,7 +2604,8 @@ impl CefV8StackTrace { // 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 { @@ -2524,7 +2619,8 @@ impl CefV8StackTrace { // Returns the number of stack frames. // pub fn get_frame_count(&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 { @@ -2538,7 +2634,8 @@ impl CefV8StackTrace { // Returns the stack frame at the specified 0-based index. // pub fn get_frame(&self, index: libc::c_int) -> interfaces::CefV8StackFrame { - 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 { @@ -2578,7 +2675,8 @@ impl CefWrap<*mut cef_v8stack_trace_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_v8stack_trace_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefV8StackTrace::from_c_object_addref(c_object)) @@ -2660,13 +2758,13 @@ pub struct _cef_v8stack_frame_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_v8stack_frame_t = _cef_v8stack_frame_t; @@ -2685,7 +2783,8 @@ pub struct CefV8StackFrame { impl Clone for CefV8StackFrame { fn clone(&self) -> CefV8StackFrame{ 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); } CefV8StackFrame { @@ -2698,7 +2797,8 @@ impl Clone for CefV8StackFrame { impl Drop for CefV8StackFrame { 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); } } @@ -2713,7 +2813,8 @@ impl CefV8StackFrame { } pub unsafe fn from_c_object_addref(c_object: *mut cef_v8stack_frame_t) -> CefV8StackFrame { - 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); } CefV8StackFrame { @@ -2727,7 +2828,8 @@ impl CefV8StackFrame { pub fn c_object_addrefed(&self) -> *mut cef_v8stack_frame_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 @@ -2735,10 +2837,10 @@ impl CefV8StackFrame { } 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 } // @@ -2747,7 +2849,8 @@ impl CefV8StackFrame { // 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 { @@ -2762,7 +2865,8 @@ impl CefV8StackFrame { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_script_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 { @@ -2779,7 +2883,8 @@ impl CefV8StackFrame { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_script_name_or_source_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 { @@ -2794,7 +2899,8 @@ impl CefV8StackFrame { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_function_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 { @@ -2808,7 +2914,8 @@ impl CefV8StackFrame { // Returns the 1-based line number for the function call or 0 if unknown. // pub fn get_line_number(&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 { @@ -2823,7 +2930,8 @@ impl CefV8StackFrame { // unknown. // pub fn get_column(&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 { @@ -2837,7 +2945,8 @@ impl CefV8StackFrame { // Returns true (1) if the function was compiled using eval(). // pub fn is_eval(&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 { @@ -2851,7 +2960,8 @@ impl CefV8StackFrame { // Returns true (1) if the function was called as a constructor via "new". // pub fn is_constructor(&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 { @@ -2878,7 +2988,8 @@ impl CefWrap<*mut cef_v8stack_frame_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_v8stack_frame_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefV8StackFrame::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_values.rs b/ports/cef/interfaces/cef_values.rs index 84e38403b5f..398ae37b782 100644 --- a/ports/cef/interfaces/cef_values.rs +++ b/ports/cef/interfaces/cef_values.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -223,13 +224,13 @@ pub struct _cef_value_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_value_t = _cef_value_t; @@ -246,7 +247,8 @@ pub struct CefValue { impl Clone for CefValue { fn clone(&self) -> CefValue{ 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); } CefValue { @@ -259,7 +261,8 @@ impl Clone for CefValue { impl Drop for CefValue { 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); } } @@ -274,7 +277,8 @@ impl CefValue { } pub unsafe fn from_c_object_addref(c_object: *mut cef_value_t) -> CefValue { - 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); } CefValue { @@ -288,7 +292,8 @@ impl CefValue { pub fn c_object_addrefed(&self) -> *mut cef_value_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 @@ -296,10 +301,10 @@ impl CefValue { } 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 } // @@ -311,7 +316,8 @@ impl CefValue { // invalid. // 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 { @@ -325,7 +331,8 @@ impl CefValue { // Returns true (1) if the underlying data is owned by another object. // pub fn is_owned(&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 { @@ -340,7 +347,8 @@ impl CefValue { // 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 { @@ -356,7 +364,8 @@ impl CefValue { // object and vice-versa. // pub fn is_same(&self, that: interfaces::CefValue) -> 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 { @@ -372,7 +381,8 @@ impl CefValue { // underlying value but are not necessarily the same object. // pub fn is_equal(&self, that: interfaces::CefValue) -> 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 { @@ -387,7 +397,8 @@ impl CefValue { // Returns a copy of this object. The underlying data will also be copied. // pub fn copy(&self) -> interfaces::CefValue { - 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 { @@ -401,7 +412,8 @@ impl CefValue { // Returns the underlying value type. // pub fn get_type(&self) -> interfaces::CefValueType { - 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 { @@ -415,7 +427,8 @@ impl CefValue { // Returns the underlying value as type bool. // pub fn get_bool(&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 { @@ -429,7 +442,8 @@ impl CefValue { // Returns the underlying value as type int. // pub fn get_int(&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 { @@ -443,7 +457,8 @@ impl CefValue { // Returns the underlying value as type double. // pub fn get_double(&self) -> libc::c_double { - 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 +473,8 @@ impl CefValue { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_string(&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 { @@ -477,7 +493,8 @@ impl CefValue { // set_binary(). // pub fn get_binary(&self) -> interfaces::CefBinaryValue { - 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 { @@ -496,7 +513,8 @@ impl CefValue { // set_dictionary(). // pub fn get_dictionary(&self) -> interfaces::CefDictionaryValue { - 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 { @@ -515,7 +533,8 @@ impl CefValue { // set_list(). // pub fn get_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 { @@ -530,7 +549,8 @@ impl CefValue { // set successfully. // pub fn set_null(&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 { @@ -545,7 +565,8 @@ impl CefValue { // set successfully. // pub fn set_bool(&self, value: libc::c_int) -> 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 { @@ -561,7 +582,8 @@ impl CefValue { // set successfully. // pub fn set_int(&self, value: libc::c_int) -> 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 { @@ -577,7 +599,8 @@ impl CefValue { // set successfully. // pub fn set_double(&self, value: libc::c_double) -> 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 { @@ -593,7 +616,8 @@ impl CefValue { // set successfully. // pub fn set_string(&self, value: &[u16]) -> 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 { @@ -610,7 +634,8 @@ impl CefValue { // the underlying data remains unchanged. // pub fn set_binary(&self, value: interfaces::CefBinaryValue) -> 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 { @@ -628,7 +653,8 @@ impl CefValue { // pub fn set_dictionary(&self, value: interfaces::CefDictionaryValue) -> 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 { @@ -645,7 +671,8 @@ impl CefValue { // the underlying data remains unchanged. // pub fn set_list(&self, value: interfaces::CefListValue) -> 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 { @@ -684,7 +711,8 @@ impl CefWrap<*mut cef_value_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_value_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefValue::from_c_object_addref(c_object)) @@ -755,13 +783,13 @@ pub struct _cef_binary_value_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_binary_value_t = _cef_binary_value_t; @@ -776,7 +804,8 @@ pub struct CefBinaryValue { impl Clone for CefBinaryValue { fn clone(&self) -> CefBinaryValue{ 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); } CefBinaryValue { @@ -789,7 +818,8 @@ impl Clone for CefBinaryValue { impl Drop for CefBinaryValue { 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); } } @@ -804,7 +834,8 @@ impl CefBinaryValue { } pub unsafe fn from_c_object_addref(c_object: *mut cef_binary_value_t) -> CefBinaryValue { - 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); } CefBinaryValue { @@ -818,7 +849,8 @@ impl CefBinaryValue { pub fn c_object_addrefed(&self) -> *mut cef_binary_value_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 @@ -826,10 +858,10 @@ impl CefBinaryValue { } 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 } // @@ -839,7 +871,8 @@ impl CefBinaryValue { // functions 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 { @@ -853,7 +886,8 @@ impl CefBinaryValue { // Returns true (1) if this object is currently owned by another object. // pub fn is_owned(&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 { @@ -868,7 +902,8 @@ impl CefBinaryValue { // data. // pub fn is_same(&self, that: interfaces::CefBinaryValue) -> 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 { @@ -884,7 +919,8 @@ impl CefBinaryValue { // underlying value but are not necessarily the same object. // pub fn is_equal(&self, that: interfaces::CefBinaryValue) -> 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 { @@ -899,7 +935,8 @@ impl CefBinaryValue { // Returns a copy of this object. The data in this object will also be copied. // pub fn copy(&self) -> interfaces::CefBinaryValue { - 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 { @@ -913,7 +950,8 @@ impl CefBinaryValue { // Returns the data size. // pub fn get_size(&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 { @@ -929,7 +967,8 @@ impl CefBinaryValue { // pub fn get_data(&self, buffer: &mut (), buffer_size: libc::size_t, data_offset: libc::size_t) -> 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 { @@ -973,7 +1012,8 @@ impl CefWrap<*mut cef_binary_value_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_binary_value_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefBinaryValue::from_c_object_addref(c_object)) @@ -1216,13 +1256,13 @@ pub struct _cef_dictionary_value_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_dictionary_value_t = _cef_dictionary_value_t; @@ -1238,7 +1278,8 @@ pub struct CefDictionaryValue { impl Clone for CefDictionaryValue { fn clone(&self) -> CefDictionaryValue{ 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); } CefDictionaryValue { @@ -1251,7 +1292,8 @@ impl Clone for CefDictionaryValue { impl Drop for CefDictionaryValue { 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); } } @@ -1266,7 +1308,8 @@ impl CefDictionaryValue { } pub unsafe fn from_c_object_addref(c_object: *mut cef_dictionary_value_t) -> CefDictionaryValue { - 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); } CefDictionaryValue { @@ -1280,7 +1323,8 @@ impl CefDictionaryValue { pub fn c_object_addrefed(&self) -> *mut cef_dictionary_value_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 @@ -1288,10 +1332,10 @@ impl CefDictionaryValue { } 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 } // @@ -1301,7 +1345,8 @@ impl CefDictionaryValue { // functions 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 { @@ -1315,7 +1360,8 @@ impl CefDictionaryValue { // Returns true (1) if this object is currently owned by another object. // pub fn is_owned(&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 { @@ -1330,7 +1376,8 @@ impl CefDictionaryValue { // 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 { @@ -1346,7 +1393,8 @@ impl CefDictionaryValue { // object and vice-versa. // pub fn is_same(&self, that: interfaces::CefDictionaryValue) -> 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 { @@ -1362,7 +1410,8 @@ impl CefDictionaryValue { // underlying value but are not necessarily the same object. // pub fn is_equal(&self, that: interfaces::CefDictionaryValue) -> 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 { @@ -1379,7 +1428,8 @@ impl CefDictionaryValue { // pub fn copy(&self, exclude_empty_children: libc::c_int) -> interfaces::CefDictionaryValue { - 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 { @@ -1394,7 +1444,8 @@ impl CefDictionaryValue { // Returns the number of values. // pub fn get_size(&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 { @@ -1408,7 +1459,8 @@ impl CefDictionaryValue { // Removes all values. Returns true (1) on success. // pub fn clear(&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 { @@ -1422,7 +1474,8 @@ impl CefDictionaryValue { // Returns true (1) if the current dictionary has a value for the given key. // pub fn has_key(&self, key: &[u16]) -> 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 { @@ -1437,7 +1490,8 @@ impl CefDictionaryValue { // Reads all keys for this dictionary into the specified vector. // pub fn get_keys(&self, keys: Vec) -> 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 { @@ -1453,7 +1507,8 @@ impl CefDictionaryValue { // removed successfully. // pub fn remove(&self, key: &[u16]) -> 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 { @@ -1468,7 +1523,8 @@ impl CefDictionaryValue { // Returns the value type for the specified key. // pub fn get_type(&self, key: &[u16]) -> interfaces::CefValueType { - 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 { @@ -1487,7 +1543,8 @@ impl CefDictionaryValue { // this object. // pub fn get_value(&self, key: &[u16]) -> interfaces::CefValue { - 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 { @@ -1502,7 +1559,8 @@ impl CefDictionaryValue { // Returns the value at the specified key as type bool. // pub fn get_bool(&self, key: &[u16]) -> 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 { @@ -1517,7 +1575,8 @@ impl CefDictionaryValue { // Returns the value at the specified key as type int. // pub fn get_int(&self, key: &[u16]) -> 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 { @@ -1532,7 +1591,8 @@ impl CefDictionaryValue { // Returns the value at the specified key as type double. // pub fn get_double(&self, key: &[u16]) -> libc::c_double { - 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 { @@ -1548,7 +1608,8 @@ impl CefDictionaryValue { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_string(&self, key: &[u16]) -> 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 { @@ -1564,7 +1625,8 @@ impl CefDictionaryValue { // will reference existing data. // pub fn get_binary(&self, key: &[u16]) -> interfaces::CefBinaryValue { - 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 { @@ -1581,7 +1643,8 @@ impl CefDictionaryValue { // modify this object. // pub fn get_dictionary(&self, key: &[u16]) -> interfaces::CefDictionaryValue { - 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 { @@ -1598,7 +1661,8 @@ impl CefDictionaryValue { // this object. // pub fn get_list(&self, key: &[u16]) -> 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 { @@ -1619,7 +1683,8 @@ impl CefDictionaryValue { // pub fn set_value(&self, key: &[u16], value: interfaces::CefValue) -> 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 { @@ -1636,7 +1701,8 @@ impl CefDictionaryValue { // value was set successfully. // pub fn set_null(&self, key: &[u16]) -> 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 { @@ -1652,7 +1718,8 @@ impl CefDictionaryValue { // value was set successfully. // pub fn set_bool(&self, key: &[u16], value: libc::c_int) -> 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 { @@ -1669,7 +1736,8 @@ impl CefDictionaryValue { // value was set successfully. // pub fn set_int(&self, key: &[u16], value: libc::c_int) -> 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 { @@ -1686,7 +1754,8 @@ impl CefDictionaryValue { // value was set successfully. // pub fn set_double(&self, key: &[u16], value: libc::c_double) -> 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 { @@ -1703,7 +1772,8 @@ impl CefDictionaryValue { // value was set successfully. // pub fn set_string(&self, key: &[u16], value: &[u16]) -> 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 { @@ -1724,7 +1794,8 @@ impl CefDictionaryValue { // pub fn set_binary(&self, key: &[u16], value: interfaces::CefBinaryValue) -> 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 { @@ -1745,7 +1816,8 @@ impl CefDictionaryValue { // pub fn set_dictionary(&self, key: &[u16], value: interfaces::CefDictionaryValue) -> 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 { @@ -1766,7 +1838,8 @@ impl CefDictionaryValue { // pub fn set_list(&self, key: &[u16], value: interfaces::CefListValue) -> 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 { @@ -1806,7 +1879,8 @@ impl CefWrap<*mut cef_dictionary_value_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_dictionary_value_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefDictionaryValue::from_c_object_addref(c_object)) @@ -2038,13 +2112,13 @@ pub struct _cef_list_value_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_list_value_t = _cef_list_value_t; @@ -2059,7 +2133,8 @@ pub struct CefListValue { impl Clone for CefListValue { fn clone(&self) -> CefListValue{ 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); } CefListValue { @@ -2072,7 +2147,8 @@ impl Clone for CefListValue { impl Drop for CefListValue { 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); } } @@ -2087,7 +2163,8 @@ impl CefListValue { } pub unsafe fn from_c_object_addref(c_object: *mut cef_list_value_t) -> CefListValue { - 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); } CefListValue { @@ -2101,7 +2178,8 @@ impl CefListValue { pub fn c_object_addrefed(&self) -> *mut cef_list_value_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 @@ -2109,10 +2187,10 @@ impl CefListValue { } 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 } // @@ -2122,7 +2200,8 @@ impl CefListValue { // functions 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 { @@ -2136,7 +2215,8 @@ impl CefListValue { // Returns true (1) if this object is currently owned by another object. // pub fn is_owned(&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 { @@ -2151,7 +2231,8 @@ impl CefListValue { // 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 { @@ -2167,7 +2248,8 @@ impl CefListValue { // object and vice-versa. // pub fn is_same(&self, that: interfaces::CefListValue) -> 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 { @@ -2183,7 +2265,8 @@ impl CefListValue { // underlying value but are not necessarily the same object. // pub fn is_equal(&self, that: interfaces::CefListValue) -> 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 { @@ -2198,7 +2281,8 @@ impl CefListValue { // Returns a writable copy of this object. // pub fn copy(&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 { @@ -2213,7 +2297,8 @@ impl CefListValue { // value slots will default to type null. Returns true (1) on success. // pub fn set_size(&self, size: libc::size_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 { @@ -2228,7 +2313,8 @@ impl CefListValue { // Returns the number of values. // pub fn get_size(&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 { @@ -2242,7 +2328,8 @@ impl CefListValue { // Removes all values. Returns true (1) on success. // pub fn clear(&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 { @@ -2256,7 +2343,8 @@ impl CefListValue { // Removes the value at the specified index. // pub fn remove(&self, index: libc::c_int) -> 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 { @@ -2271,7 +2359,8 @@ impl CefListValue { // Returns the value type at the specified index. // pub fn get_type(&self, index: libc::c_int) -> interfaces::CefValueType { - 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 { @@ -2290,7 +2379,8 @@ impl CefListValue { // will modify this object. // pub fn get_value(&self, index: libc::c_int) -> interfaces::CefValue { - 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 { @@ -2305,7 +2395,8 @@ impl CefListValue { // Returns the value at the specified index as type bool. // pub fn get_bool(&self, index: libc::c_int) -> 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 { @@ -2320,7 +2411,8 @@ impl CefListValue { // Returns the value at the specified index as type int. // pub fn get_int(&self, index: libc::c_int) -> 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 { @@ -2335,7 +2427,8 @@ impl CefListValue { // Returns the value at the specified index as type double. // pub fn get_double(&self, index: libc::c_int) -> libc::c_double { - 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 { @@ -2351,7 +2444,8 @@ impl CefListValue { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_string(&self, index: libc::c_int) -> 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 { @@ -2367,7 +2461,8 @@ impl CefListValue { // will reference existing data. // pub fn get_binary(&self, index: libc::c_int) -> interfaces::CefBinaryValue { - 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 { @@ -2385,7 +2480,8 @@ impl CefListValue { // pub fn get_dictionary(&self, index: libc::c_int) -> interfaces::CefDictionaryValue { - 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 { @@ -2402,7 +2498,8 @@ impl CefListValue { // this object. // pub fn get_list(&self, index: libc::c_int) -> 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 { @@ -2423,7 +2520,8 @@ impl CefListValue { // pub fn set_value(&self, index: libc::c_int, value: interfaces::CefValue) -> 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 { @@ -2440,7 +2538,8 @@ impl CefListValue { // value was set successfully. // pub fn set_null(&self, index: libc::c_int) -> 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 { @@ -2457,7 +2556,8 @@ impl CefListValue { // pub fn set_bool(&self, index: libc::c_int, value: libc::c_int) -> 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 { @@ -2474,7 +2574,8 @@ impl CefListValue { // value was set successfully. // pub fn set_int(&self, index: libc::c_int, value: libc::c_int) -> 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 { @@ -2492,7 +2593,8 @@ impl CefListValue { // pub fn set_double(&self, index: libc::c_int, value: libc::c_double) -> 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 { @@ -2509,7 +2611,8 @@ impl CefListValue { // the value was set successfully. // pub fn set_string(&self, index: libc::c_int, value: &[u16]) -> 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 { @@ -2530,7 +2633,8 @@ impl CefListValue { // pub fn set_binary(&self, index: libc::c_int, value: interfaces::CefBinaryValue) -> 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 { @@ -2551,7 +2655,8 @@ impl CefListValue { // pub fn set_dictionary(&self, index: libc::c_int, value: interfaces::CefDictionaryValue) -> 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 { @@ -2572,7 +2677,8 @@ impl CefListValue { // pub fn set_list(&self, index: libc::c_int, value: interfaces::CefListValue) -> 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 { @@ -2612,7 +2718,8 @@ impl CefWrap<*mut cef_list_value_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_list_value_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefListValue::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_web_plugin.rs b/ports/cef/interfaces/cef_web_plugin.rs index 6d6bd805246..94019e77ef5 100644 --- a/ports/cef/interfaces/cef_web_plugin.rs +++ b/ports/cef/interfaces/cef_web_plugin.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -86,13 +87,13 @@ pub struct _cef_web_plugin_info_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_web_plugin_info_t = _cef_web_plugin_info_t; @@ -107,7 +108,8 @@ pub struct CefWebPluginInfo { impl Clone for CefWebPluginInfo { fn clone(&self) -> CefWebPluginInfo{ 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); } CefWebPluginInfo { @@ -120,7 +122,8 @@ impl Clone for CefWebPluginInfo { impl Drop for CefWebPluginInfo { 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); } } @@ -135,7 +138,8 @@ impl CefWebPluginInfo { } pub unsafe fn from_c_object_addref(c_object: *mut cef_web_plugin_info_t) -> CefWebPluginInfo { - 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); } CefWebPluginInfo { @@ -149,7 +153,8 @@ impl CefWebPluginInfo { pub fn c_object_addrefed(&self) -> *mut cef_web_plugin_info_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 @@ -157,10 +162,10 @@ impl CefWebPluginInfo { } 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 } // @@ -168,7 +173,8 @@ impl CefWebPluginInfo { // // 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 { @@ -183,7 +189,8 @@ impl CefWebPluginInfo { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_path(&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 { @@ -198,7 +205,8 @@ impl CefWebPluginInfo { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_version(&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 { @@ -213,7 +221,8 @@ impl CefWebPluginInfo { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_description(&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 { @@ -240,7 +249,8 @@ impl CefWrap<*mut cef_web_plugin_info_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_web_plugin_info_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefWebPluginInfo::from_c_object_addref(c_object)) @@ -273,13 +283,13 @@ pub struct _cef_web_plugin_info_visitor_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_web_plugin_info_visitor_t = _cef_web_plugin_info_visitor_t; @@ -295,7 +305,8 @@ pub struct CefWebPluginInfoVisitor { impl Clone for CefWebPluginInfoVisitor { fn clone(&self) -> CefWebPluginInfoVisitor{ 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); } CefWebPluginInfoVisitor { @@ -308,7 +319,8 @@ impl Clone for CefWebPluginInfoVisitor { impl Drop for CefWebPluginInfoVisitor { 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); } } @@ -323,7 +335,8 @@ impl CefWebPluginInfoVisitor { } pub unsafe fn from_c_object_addref(c_object: *mut cef_web_plugin_info_visitor_t) -> CefWebPluginInfoVisitor { - 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); } CefWebPluginInfoVisitor { @@ -337,7 +350,8 @@ impl CefWebPluginInfoVisitor { pub fn c_object_addrefed(&self) -> *mut cef_web_plugin_info_visitor_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 @@ -345,10 +359,10 @@ impl CefWebPluginInfoVisitor { } 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 } // @@ -359,7 +373,8 @@ impl CefWebPluginInfoVisitor { // pub fn visit(&self, info: interfaces::CefWebPluginInfo, count: libc::c_int, total: libc::c_int) -> 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 { @@ -389,7 +404,8 @@ impl CefWrap<*mut cef_web_plugin_info_visitor_t> for Option Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefWebPluginInfoVisitor::from_c_object_addref(c_object)) @@ -421,13 +437,13 @@ pub struct _cef_web_plugin_unstable_callback_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_web_plugin_unstable_callback_t = _cef_web_plugin_unstable_callback_t; @@ -443,7 +459,8 @@ pub struct CefWebPluginUnstableCallback { impl Clone for CefWebPluginUnstableCallback { fn clone(&self) -> CefWebPluginUnstableCallback{ 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); } CefWebPluginUnstableCallback { @@ -456,7 +473,8 @@ impl Clone for CefWebPluginUnstableCallback { impl Drop for CefWebPluginUnstableCallback { 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); } } @@ -471,7 +489,8 @@ impl CefWebPluginUnstableCallback { } pub unsafe fn from_c_object_addref(c_object: *mut cef_web_plugin_unstable_callback_t) -> CefWebPluginUnstableCallback { - 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); } CefWebPluginUnstableCallback { @@ -485,7 +504,8 @@ impl CefWebPluginUnstableCallback { pub fn c_object_addrefed(&self) -> *mut cef_web_plugin_unstable_callback_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 @@ -493,10 +513,10 @@ impl CefWebPluginUnstableCallback { } 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 } // @@ -505,7 +525,8 @@ impl CefWebPluginUnstableCallback { // 120 seconds. // pub fn is_unstable(&self, path: &[u16], unstable: 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 { @@ -534,7 +555,8 @@ impl CefWrap<*mut cef_web_plugin_unstable_callback_t> for Option Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefWebPluginUnstableCallback::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_xml_reader.rs b/ports/cef/interfaces/cef_xml_reader.rs index 02c85f408e3..485ef4c2ee7 100644 --- a/ports/cef/interfaces/cef_xml_reader.rs +++ b/ports/cef/interfaces/cef_xml_reader.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -277,13 +278,13 @@ pub struct _cef_xml_reader_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_xml_reader_t = _cef_xml_reader_t; @@ -300,7 +301,8 @@ pub struct CefXmlReader { impl Clone for CefXmlReader { fn clone(&self) -> CefXmlReader{ 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); } CefXmlReader { @@ -313,7 +315,8 @@ impl Clone for CefXmlReader { impl Drop for CefXmlReader { 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); } } @@ -328,7 +331,8 @@ impl CefXmlReader { } pub unsafe fn from_c_object_addref(c_object: *mut cef_xml_reader_t) -> CefXmlReader { - 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); } CefXmlReader { @@ -342,7 +346,8 @@ impl CefXmlReader { pub fn c_object_addrefed(&self) -> *mut cef_xml_reader_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 @@ -350,10 +355,10 @@ impl CefXmlReader { } 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 } // @@ -362,7 +367,8 @@ impl CefXmlReader { // if the cursor position was set successfully. // pub fn move_to_next_node(&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 { @@ -377,7 +383,8 @@ impl CefXmlReader { // occurs on the correct thread. // pub fn close(&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 { @@ -391,7 +398,8 @@ impl CefXmlReader { // Returns true (1) if an error has been reported by the XML parser. // pub fn has_error(&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 { @@ -406,7 +414,8 @@ impl CefXmlReader { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_error(&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 { @@ -424,7 +433,8 @@ impl CefXmlReader { // Returns the node type. // pub fn get_type(&self) -> types::cef_xml_node_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 { @@ -438,7 +448,8 @@ impl CefXmlReader { // Returns the node depth. Depth starts at 0 for the root node. // pub fn get_depth(&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 { @@ -454,7 +465,8 @@ impl CefXmlReader { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_local_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 { @@ -470,7 +482,8 @@ impl CefXmlReader { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_prefix(&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 { @@ -486,7 +499,8 @@ impl CefXmlReader { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_qualified_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 { @@ -502,7 +516,8 @@ impl CefXmlReader { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_namespace_uri(&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 { @@ -518,7 +533,8 @@ impl CefXmlReader { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_base_uri(&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 { @@ -534,7 +550,8 @@ impl CefXmlReader { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_xml_lang(&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 { @@ -549,7 +566,8 @@ impl CefXmlReader { // NULL but is not. // pub fn is_empty_element(&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 { @@ -563,7 +581,8 @@ impl CefXmlReader { // Returns true (1) if the node has a text value. // pub fn has_value(&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 { @@ -578,7 +597,8 @@ impl CefXmlReader { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_value(&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 { @@ -592,7 +612,8 @@ impl CefXmlReader { // Returns true (1) if the node has attributes. // pub fn has_attributes(&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 { @@ -606,7 +627,8 @@ impl CefXmlReader { // Returns the number of attributes. // pub fn get_attribute_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 { @@ -621,7 +643,8 @@ impl CefXmlReader { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_attribute_byindex(&self, index: libc::c_int) -> 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 { @@ -637,7 +660,8 @@ impl CefXmlReader { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_attribute_byqname(&self, qualifiedName: &[u16]) -> 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 { @@ -655,7 +679,8 @@ impl CefXmlReader { // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_attribute_bylname(&self, localName: &[u16], namespaceURI: &[u16]) -> 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 { @@ -672,7 +697,8 @@ impl CefXmlReader { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_inner_xml(&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 { @@ -687,7 +713,8 @@ impl CefXmlReader { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_outer_xml(&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 { @@ -701,7 +728,8 @@ impl CefXmlReader { // Returns the line number for the current node. // pub fn get_line_number(&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 { @@ -722,7 +750,8 @@ impl CefXmlReader { // true (1) if the cursor position was set successfully. // pub fn move_to_attribute_byindex(&self, index: libc::c_int) -> 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 { @@ -739,7 +768,8 @@ impl CefXmlReader { // pub fn move_to_attribute_byqname(&self, qualifiedName: &[u16]) -> 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 { @@ -757,7 +787,8 @@ impl CefXmlReader { // pub fn move_to_attribute_bylname(&self, localName: &[u16], namespaceURI: &[u16]) -> 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 { @@ -774,7 +805,8 @@ impl CefXmlReader { // true (1) if the cursor position was set successfully. // pub fn move_to_first_attribute(&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 { @@ -789,7 +821,8 @@ impl CefXmlReader { // (1) if the cursor position was set successfully. // pub fn move_to_next_attribute(&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 { @@ -804,7 +837,8 @@ impl CefXmlReader { // cursor position was set successfully. // pub fn move_to_carrying_element(&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 { @@ -847,7 +881,8 @@ impl CefWrap<*mut cef_xml_reader_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_xml_reader_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefXmlReader::from_c_object_addref(c_object)) diff --git a/ports/cef/interfaces/cef_zip_reader.rs b/ports/cef/interfaces/cef_zip_reader.rs index 6eb4cd45d8b..39b104ae8cf 100644 --- a/ports/cef/interfaces/cef_zip_reader.rs +++ b/ports/cef/interfaces/cef_zip_reader.rs @@ -43,6 +43,7 @@ use wrappers::CefWrap; use libc; use std::collections::HashMap; +use std::mem; use std::ptr; // @@ -140,13 +141,13 @@ pub struct _cef_zip_reader_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_zip_reader_t = _cef_zip_reader_t; @@ -163,7 +164,8 @@ pub struct CefZipReader { impl Clone for CefZipReader { fn clone(&self) -> CefZipReader{ 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); } CefZipReader { @@ -176,7 +178,8 @@ impl Clone for CefZipReader { impl Drop for CefZipReader { 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); } } @@ -191,7 +194,8 @@ impl CefZipReader { } pub unsafe fn from_c_object_addref(c_object: *mut cef_zip_reader_t) -> CefZipReader { - 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); } CefZipReader { @@ -205,7 +209,8 @@ impl CefZipReader { pub fn c_object_addrefed(&self) -> *mut cef_zip_reader_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 @@ -213,10 +218,10 @@ impl CefZipReader { } 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 } // @@ -224,7 +229,8 @@ impl CefZipReader { // cursor position was set successfully. // pub fn move_to_first_file(&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 { @@ -239,7 +245,8 @@ impl CefZipReader { // cursor position was set successfully. // pub fn move_to_next_file(&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 { @@ -256,7 +263,8 @@ impl CefZipReader { // pub fn move_to_file(&self, fileName: &[u16], caseSensitive: libc::c_int) -> 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 { @@ -273,7 +281,8 @@ impl CefZipReader { // occurs on the correct thread. // pub fn close(&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 { @@ -291,7 +300,8 @@ impl CefZipReader { // // The resulting string must be freed by calling cef_string_userfree_free(). pub fn get_file_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 { @@ -305,7 +315,8 @@ impl CefZipReader { // Returns the uncompressed size of the file. // pub fn get_file_size(&self) -> i64 { - 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 { @@ -319,7 +330,8 @@ impl CefZipReader { // Returns the last modified timestamp for the file. // pub fn get_file_last_modified(&self) -> libc::time_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 { @@ -334,7 +346,8 @@ impl CefZipReader { // optionally be specified. // pub fn open_file(&self, password: &[u16]) -> 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 { @@ -349,7 +362,8 @@ impl CefZipReader { // Closes the file. // pub fn close_file(&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 { @@ -365,7 +379,8 @@ impl CefZipReader { // pub fn read_file(&self, buffer: &mut (), bufferSize: libc::size_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 { @@ -381,7 +396,8 @@ impl CefZipReader { // Returns the current offset in the uncompressed file contents. // pub fn tell(&self) -> i64 { - 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 { @@ -395,7 +411,8 @@ impl CefZipReader { // Returns true (1) if at end of the file contents. // pub fn eof(&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 { @@ -435,7 +452,8 @@ impl CefWrap<*mut cef_zip_reader_t> for Option { } } unsafe fn to_rust(c_object: *mut cef_zip_reader_t) -> Option { - if c_object.is_null() { + if c_object.is_null() && + c_object as usize != mem::POST_DROP_USIZE { None } else { Some(CefZipReader::from_c_object_addref(c_object)) diff --git a/ports/cef/lib.rs b/ports/cef/lib.rs index 2f6718a1dea..ae9209022ef 100644 --- a/ports/cef/lib.rs +++ b/ports/cef/lib.rs @@ -13,7 +13,7 @@ #![feature(collections)] #![feature(negate_unsigned)] #![feature(unicode)] - +#![feature(unsafe_no_drop_flag, filling_drop)] #![allow(non_camel_case_types)] #![plugin(plugins)] diff --git a/ports/cef/macros.rs b/ports/cef/macros.rs index 605b92da672..f498769e6c9 100644 --- a/ports/cef/macros.rs +++ b/ports/cef/macros.rs @@ -66,7 +66,7 @@ macro_rules! full_cef_class_impl( // Calculate the offset of the reference count. This is the size of the // structure. let null: *const $c_interface_name = ::std::ptr::null(); - let offset: *const usize = &(*null).ref_count; + let offset: *const u32 = &(*null).ref_count; let size = (offset as ::libc::size_t) - (null as ::libc::size_t); $interface_name::from_c_object_addref( ::eutil::create_cef_object::<$c_interface_name,$class_name>(size))