Skip to content

Commit

Permalink
embedding: convert callback Option<> matching to map()
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Blumenkrantz committed Nov 14, 2014
1 parent 11e3073 commit 5f10092
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 31 deletions.
16 changes: 3 additions & 13 deletions ports/cef/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,12 @@ pub extern "C" fn cef_initialize(args: *const cef_main_args_t,
}
unsafe {
command_line_init((*args).argc, (*args).argv);
match (*application).get_browser_process_handler {
Some(cb) => {
(*application).get_browser_process_handler.map(|cb| {
let handler = cb(application);
if handler.is_not_null() {
match (*handler).on_context_initialized {
Some(hcb) => {
hcb(handler);
return 1;
},
None => { return 1; }
}
(*handler).on_context_initialized.map(|hcb| hcb(handler));
}
return 1;
},
None => { return 1; }
}
});
}
return 1
}
Expand Down
21 changes: 3 additions & 18 deletions ports/cef/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,7 @@ 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 {
match (*cs).dtor {
Some(dtor) => {
dtor((*cs).str);
},
None => ()
};
(*cs).dtor.map(|dtor| dtor((*cs).str));
(*cs).length = 0;
(*cs).str = 0 as *mut u8;
(*cs).dtor = mem::transmute(0 as *const u8);
Expand Down Expand Up @@ -136,12 +131,7 @@ 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 {
match (*cs).dtor {
Some(dtor) => {
dtor((*cs).str);
},
None => ()
};
(*cs).dtor.map(|dtor| dtor((*cs).str));
(*cs).length = 0;
(*cs).str = 0 as *mut c_ushort;
(*cs).dtor = mem::transmute(0 as *const u8);
Expand Down Expand Up @@ -196,12 +186,7 @@ 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 {
match (*cs).dtor {
Some(dtor) => {
dtor((*cs).str);
},
None => ()
};
(*cs).dtor.map(|dtor| dtor((*cs).str));
(*cs).length = 0;
(*cs).str = 0 as *mut wchar_t;
(*cs).dtor = mem::transmute(0 as *const u8);
Expand Down

5 comments on commit 5f10092

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at zmike@5f10092

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging zmike/servo/embedding-option_callbacks = 5f10092 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zmike/servo/embedding-option_callbacks = 5f10092 merged ok, testing candidate = 443b1b9

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 443b1b9

Please sign in to comment.