servo: Merge #3946 - Embedding fixups (from zmike:embedding-fixups); r=jdm

adds a missing string api function and renames an existing string_list function

r+ @larsbergstrom @jdm ?

Source-Repo: https://github.com/servo/servo
Source-Revision: 1773198e8d4c5ebe82b4780ebf0828833aa61846
This commit is contained in:
Mike Blumenkrantz 2014-11-13 16:00:40 -07:00
Родитель 3925345206
Коммит 90169aef41
2 изменённых файлов: 21 добавлений и 6 удалений

Просмотреть файл

@ -93,6 +93,21 @@ pub extern "C" fn cef_string_utf8_set(src: *const u8, src_len: size_t, output: *
return 1;
}
#[no_mangle]
pub extern "C" fn cef_string_utf8_cmp(a: *const cef_string_utf8_t, b: *const cef_string_utf8_t) -> c_int {
unsafe {
slice::raw::buf_as_slice((*a).str as *const u8, (*a).length as uint, |astr:&[u8]| {
slice::raw::buf_as_slice((*b).str as *const u8, (*b).length as uint, |bstr:&[u8]| {
match astr.cmp(bstr) {
Less => -1,
Equal => 0,
Greater => 1
}
})
})
}
}
#[no_mangle]
pub extern "C" fn cef_string_utf8_to_utf16(src: *const u8, src_len: size_t, output: *mut cef_string_utf16_t) -> c_int {
unsafe {

Просмотреть файл

@ -9,7 +9,7 @@ use string::{cef_string_userfree_utf8_alloc,cef_string_userfree_utf8_free,cef_st
use types::{cef_string_list_t,cef_string_t};
fn string_map_to_vec(lt: *mut cef_string_list_t) -> *mut Vec<*mut cef_string_t> {
fn string_list_to_vec(lt: *mut cef_string_list_t) -> *mut Vec<*mut cef_string_t> {
lt as *mut Vec<*mut cef_string_t>
}
@ -27,7 +27,7 @@ pub extern "C" fn cef_string_list_alloc() -> *mut cef_string_list_t {
pub extern "C" fn cef_string_list_size(lt: *mut cef_string_list_t) -> c_int {
unsafe {
if fptr_is_null(mem::transmute(lt)) { return 0; }
let v = string_map_to_vec(lt);
let v = string_list_to_vec(lt);
(*v).len() as c_int
}
}
@ -36,7 +36,7 @@ pub extern "C" fn cef_string_list_size(lt: *mut cef_string_list_t) -> c_int {
pub extern "C" fn cef_string_list_append(lt: *mut cef_string_list_t, value: *const cef_string_t) {
unsafe {
if fptr_is_null(mem::transmute(lt)) { return; }
let v = string_map_to_vec(lt);
let v = string_list_to_vec(lt);
let cs = cef_string_userfree_utf8_alloc();
cef_string_utf8_set(mem::transmute((*value).str), (*value).length, cs, 1);
(*v).push(cs);
@ -47,7 +47,7 @@ pub extern "C" fn cef_string_list_append(lt: *mut cef_string_list_t, value: *con
pub extern "C" fn cef_string_list_value(lt: *mut cef_string_list_t, index: c_int, value: *mut cef_string_t) -> c_int {
unsafe {
if index < 0 || fptr_is_null(mem::transmute(lt)) { return 0; }
let v = string_map_to_vec(lt);
let v = string_list_to_vec(lt);
if index as uint > (*v).len() - 1 { return 0; }
let cs = (*v)[index as uint];
cef_string_utf8_set(mem::transmute((*cs).str), (*cs).length, value, 1)
@ -58,7 +58,7 @@ pub extern "C" fn cef_string_list_value(lt: *mut cef_string_list_t, index: c_int
pub extern "C" fn cef_string_list_clear(lt: *mut cef_string_list_t) {
unsafe {
if fptr_is_null(mem::transmute(lt)) { return; }
let v = string_map_to_vec(lt);
let v = string_list_to_vec(lt);
if (*v).len() == 0 { return; }
let mut cs;
while (*v).len() != 0 {
@ -82,7 +82,7 @@ pub extern "C" fn cef_string_list_free(lt: *mut cef_string_list_t) {
pub extern "C" fn cef_string_list_copy(lt: *mut cef_string_list_t) -> *mut cef_string_list_t {
unsafe {
if fptr_is_null(mem::transmute(lt)) { return 0 as *mut cef_string_list_t; }
let v = string_map_to_vec(lt);
let v = string_list_to_vec(lt);
let lt2 = cef_string_list_alloc();
for cs in (*v).iter() {
cef_string_list_append(lt2, mem::transmute((*cs)));