mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Make cef_string_multimap_t an alias for its real type.
This commit is contained in:
parent
91cae11931
commit
cb2f7c7496
2 changed files with 13 additions and 22 deletions
|
@ -11,10 +11,6 @@ use string::{cef_string_userfree_utf16_alloc, cef_string_userfree_utf16_free};
|
|||
use string::{cef_string_utf16_set};
|
||||
use types::{cef_string_multimap_t,cef_string_t};
|
||||
|
||||
fn string_multimap_to_treemap(smm: *mut cef_string_multimap_t) -> *mut BTreeMap<String, Vec<*mut cef_string_t>> {
|
||||
smm as *mut BTreeMap<String, Vec<*mut cef_string_t>>
|
||||
}
|
||||
|
||||
//cef_string_multimap
|
||||
|
||||
#[no_mangle]
|
||||
|
@ -29,9 +25,8 @@ pub extern "C" fn cef_string_multimap_alloc() -> *mut cef_string_multimap_t {
|
|||
pub extern "C" fn cef_string_multimap_size(smm: *mut cef_string_multimap_t) -> c_int {
|
||||
unsafe {
|
||||
if smm.is_null() { return 0; }
|
||||
let v = string_multimap_to_treemap(smm);
|
||||
// t1 : collections::btree::map::Values<'_, collections::string::String, collections::vec::Vec<*mut types::cef_string_utf16>>`
|
||||
let t1 = (*v).values();
|
||||
let t1 = (*smm).values();
|
||||
// t2 : collections::btree::map::BTreeMap<collections::string::String, collections::vec::Vec<*mut types::cef_string_utf16>>
|
||||
let t2 : usize = t1.map(|val| (*val).len()).sum();
|
||||
t2 as c_int
|
||||
|
@ -42,9 +37,8 @@ pub extern "C" fn cef_string_multimap_size(smm: *mut cef_string_multimap_t) -> c
|
|||
pub extern "C" fn cef_string_multimap_find_count(smm: *mut cef_string_multimap_t, key: *const cef_string_t) -> c_int {
|
||||
unsafe {
|
||||
if smm.is_null() { return 0; }
|
||||
let v = string_multimap_to_treemap(smm);
|
||||
slice_to_str((*key).str as *const u8, (*key).length as usize, |result| {
|
||||
match (*v).get(result) {
|
||||
match (*smm).get(result) {
|
||||
Some(s) => s.len() as c_int,
|
||||
None => 0
|
||||
}
|
||||
|
@ -56,13 +50,12 @@ pub extern "C" fn cef_string_multimap_find_count(smm: *mut cef_string_multimap_t
|
|||
pub extern "C" fn cef_string_multimap_append(smm: *mut cef_string_multimap_t, key: *const cef_string_t, value: *const cef_string_t) -> c_int {
|
||||
unsafe {
|
||||
if smm.is_null() { return 0; }
|
||||
let v = string_multimap_to_treemap(smm);
|
||||
slice_to_str((*key).str as *const u8, (*key).length as usize, |result| {
|
||||
let csv = cef_string_userfree_utf16_alloc();
|
||||
cef_string_utf16_set((*value).str as *const u16, (*value).length, csv, 1);
|
||||
match (*v).get_mut(result) {
|
||||
match (*smm).get_mut(result) {
|
||||
Some(vc) => (*vc).push(csv),
|
||||
None => { (*v).insert(result.to_owned(), vec!(csv)); }
|
||||
None => { (*smm).insert(result.to_owned(), vec!(csv)); }
|
||||
}
|
||||
1
|
||||
})
|
||||
|
@ -73,9 +66,8 @@ pub extern "C" fn cef_string_multimap_append(smm: *mut cef_string_multimap_t, ke
|
|||
pub extern "C" fn cef_string_multimap_enumerate(smm: *mut cef_string_multimap_t, key: *const cef_string_t, index: c_int, value: *mut cef_string_t) -> c_int {
|
||||
unsafe {
|
||||
if smm.is_null() { return 0; }
|
||||
let v = string_multimap_to_treemap(smm);
|
||||
slice_to_str((*key).str as *const u8, (*key).length as usize, |result| {
|
||||
match (*v).get(result) {
|
||||
match (*smm).get(result) {
|
||||
Some(s) => {
|
||||
if (*s).len() <= index as usize {
|
||||
return 0;
|
||||
|
@ -93,10 +85,9 @@ pub extern "C" fn cef_string_multimap_enumerate(smm: *mut cef_string_multimap_t,
|
|||
pub extern "C" fn cef_string_multimap_key(smm: *mut cef_string_multimap_t, index: c_int, value: *mut cef_string_t) -> c_int {
|
||||
unsafe {
|
||||
if index < 0 || smm.is_null() { return 0; }
|
||||
let v = string_multimap_to_treemap(smm);
|
||||
let mut rem = index as usize;
|
||||
|
||||
for (key, val) in (*v).iter() {
|
||||
for (key, val) in (*smm).iter() {
|
||||
if rem < (*val).len() {
|
||||
return cef_string_utf16_set((*key).as_bytes().as_ptr() as *const u16,
|
||||
(*key).len() as u64,
|
||||
|
@ -114,10 +105,9 @@ pub extern "C" fn cef_string_multimap_key(smm: *mut cef_string_multimap_t, index
|
|||
pub extern "C" fn cef_string_multimap_value(smm: *mut cef_string_multimap_t, index: c_int, value: *mut cef_string_t) -> c_int {
|
||||
unsafe {
|
||||
if index < 0 || smm.is_null() { return 0; }
|
||||
let v = string_multimap_to_treemap(smm);
|
||||
let mut rem = index as usize;
|
||||
|
||||
for val in (*v).values() {
|
||||
for val in (*smm).values() {
|
||||
if rem < (*val).len() {
|
||||
let cs = (*val)[rem as usize];
|
||||
return cef_string_utf16_set((*cs).str as *const u16, (*cs).length, value, 1);
|
||||
|
@ -133,15 +123,14 @@ pub extern "C" fn cef_string_multimap_value(smm: *mut cef_string_multimap_t, ind
|
|||
pub extern "C" fn cef_string_multimap_clear(smm: *mut cef_string_multimap_t) {
|
||||
unsafe {
|
||||
if smm.is_null() { return; }
|
||||
let v = string_multimap_to_treemap(smm);
|
||||
if (*v).len() == 0 { return; }
|
||||
for (_, val) in (*v).iter_mut() {
|
||||
if (*smm).len() == 0 { return; }
|
||||
for (_, val) in (*smm).iter_mut() {
|
||||
while (*val).len() != 0 {
|
||||
let cs = (*val).pop();
|
||||
cef_string_userfree_utf16_free(cs.unwrap());
|
||||
}
|
||||
}
|
||||
(*v).clear();
|
||||
(*smm).clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,8 +13,10 @@ use net::net_error_list::NetError;
|
|||
|
||||
pub use self::cef_rect as cef_rect_t;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
pub enum cef_string_map_t {}
|
||||
pub enum cef_string_multimap_t {}
|
||||
pub type cef_string_multimap_t = BTreeMap<String, Vec<*mut cef_string_t>>;
|
||||
pub type cef_string_list_t = Vec<String>;
|
||||
pub enum cef_text_input_context_t {}
|
||||
pub enum cef_event_handle_t {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue