From 9fe95fc77e996ce185ef163c3b22a595d11cd858 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 13 Oct 2014 06:32:50 -0400 Subject: [PATCH] embedding: implement cef_string_utf16_cmp() --- ports/cef/string.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ports/cef/string.rs b/ports/cef/string.rs index 855fa1226ec..d8cf7d97531 100644 --- a/ports/cef/string.rs +++ b/ports/cef/string.rs @@ -167,6 +167,21 @@ pub extern "C" fn cef_string_utf16_set(src: *const c_ushort, src_len: size_t, ou return 1; } +#[no_mangle] +pub extern "C" fn cef_string_utf16_cmp(a: *const cef_string_utf16_t, b: *const cef_string_utf16_t) -> c_int { + unsafe { + slice::raw::buf_as_slice(mem::transmute((*a).str), (*a).length as uint, |astr:&[u16]| { + slice::raw::buf_as_slice(mem::transmute((*b).str), (*b).length as uint, |bstr:&[u16]| { + match astr.cmp(&bstr) { + Less => -1, + Equal => 0, + Greater => 1 + } + }) + }) + } +} + #[no_mangle] pub extern "C" fn cef_string_wide_clear(cs: *mut cef_string_wide_t) { unsafe {