embedding: change Option<> unwrapping for fptrs to use match

This commit is contained in:
Mike Blumenkrantz 2014-11-14 15:34:54 -05:00
parent d33f74f499
commit 11e30731ef
2 changed files with 33 additions and 19 deletions

View file

@ -23,13 +23,21 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t,
}
unsafe {
command_line_init((*args).argc, (*args).argv);
if !(*application).get_browser_process_handler.is_some() { return 1; }
let cb = (*application).get_browser_process_handler.unwrap();
let handler = cb(application);
if handler.is_not_null() {
if !(*handler).on_context_initialized.is_some() { return 1; }
let hcb = (*handler).on_context_initialized.unwrap();
hcb(handler);
match (*application).get_browser_process_handler {
Some(cb) => {
let handler = cb(application);
if handler.is_not_null() {
match (*handler).on_context_initialized {
Some(hcb) => {
hcb(handler);
return 1;
},
None => { return 1; }
}
}
return 1;
},
None => { return 1; }
}
}
return 1

View file

@ -52,10 +52,12 @@ pub extern "C" fn cef_string_userfree_utf16_free(cs: *mut cef_string_userfree_ut
#[no_mangle]
pub extern "C" fn cef_string_utf8_clear(cs: *mut cef_string_utf8_t) {
unsafe {
if (*cs).dtor.is_some() {
let dtor = (*cs).dtor.unwrap();
dtor((*cs).str);
}
match (*cs).dtor {
Some(dtor) => {
dtor((*cs).str);
},
None => ()
};
(*cs).length = 0;
(*cs).str = 0 as *mut u8;
(*cs).dtor = mem::transmute(0 as *const u8);
@ -134,10 +136,12 @@ pub extern "C" fn cef_string_utf16_to_utf8(src: *const u16, src_len: size_t, out
#[no_mangle]
pub extern "C" fn cef_string_utf16_clear(cs: *mut cef_string_utf16_t) {
unsafe {
if (*cs).dtor.is_some() {
let dtor = (*cs).dtor.unwrap();
dtor((*cs).str);
}
match (*cs).dtor {
Some(dtor) => {
dtor((*cs).str);
},
None => ()
};
(*cs).length = 0;
(*cs).str = 0 as *mut c_ushort;
(*cs).dtor = mem::transmute(0 as *const u8);
@ -192,10 +196,12 @@ pub extern "C" fn cef_string_utf16_cmp(a: *const cef_string_utf16_t, b: *const c
#[no_mangle]
pub extern "C" fn cef_string_wide_clear(cs: *mut cef_string_wide_t) {
unsafe {
if (*cs).dtor.is_some() {
let dtor = (*cs).dtor.unwrap();
dtor((*cs).str);
}
match (*cs).dtor {
Some(dtor) => {
dtor((*cs).str);
},
None => ()
};
(*cs).length = 0;
(*cs).str = 0 as *mut wchar_t;
(*cs).dtor = mem::transmute(0 as *const u8);