mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
address review comments
This commit is contained in:
parent
8a4d2949e8
commit
4ae5c88acc
2 changed files with 14 additions and 25 deletions
|
@ -5,6 +5,7 @@
|
||||||
use eutil::slice_to_str;
|
use eutil::slice_to_str;
|
||||||
use libc::{c_int};
|
use libc::{c_int};
|
||||||
use std::collections::TreeMap;
|
use std::collections::TreeMap;
|
||||||
|
use std::iter::AdditiveIterator;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::string::String;
|
use std::string::String;
|
||||||
use string::{cef_string_userfree_utf8_alloc,cef_string_userfree_utf8_free,cef_string_utf8_set};
|
use string::{cef_string_userfree_utf8_alloc,cef_string_userfree_utf8_free,cef_string_utf8_set};
|
||||||
|
@ -28,12 +29,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 {
|
pub extern "C" fn cef_string_multimap_size(smm: *mut cef_string_multimap_t) -> c_int {
|
||||||
unsafe {
|
unsafe {
|
||||||
if smm.is_null() { return 0; }
|
if smm.is_null() { return 0; }
|
||||||
let mut c: c_int = 0;
|
|
||||||
let v = string_multimap_to_treemap(smm);
|
let v = string_multimap_to_treemap(smm);
|
||||||
for (_, val) in (*v).iter() {
|
(*v).values().map(|val| (*val).len()).sum() as c_int
|
||||||
c = c + (*val).len() as c_int;
|
|
||||||
}
|
|
||||||
c
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,9 +41,7 @@ pub extern "C" fn cef_string_multimap_find_count(smm: *mut cef_string_multimap_t
|
||||||
let v = string_multimap_to_treemap(smm);
|
let v = string_multimap_to_treemap(smm);
|
||||||
slice_to_str((*key).str as *const u8, (*key).length as uint, |result| {
|
slice_to_str((*key).str as *const u8, (*key).length as uint, |result| {
|
||||||
match (*v).get(&String::from_str(result)) {
|
match (*v).get(&String::from_str(result)) {
|
||||||
Some(s) => {
|
Some(s) => s.len() as c_int,
|
||||||
s.len() as c_int
|
|
||||||
}
|
|
||||||
None => 0
|
None => 0
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -63,16 +58,10 @@ pub extern "C" fn cef_string_multimap_append(smm: *mut cef_string_multimap_t, ke
|
||||||
let csv = cef_string_userfree_utf8_alloc();
|
let csv = cef_string_userfree_utf8_alloc();
|
||||||
cef_string_utf8_set((*value).str as *const u8, (*value).length, csv, 1);
|
cef_string_utf8_set((*value).str as *const u8, (*value).length, csv, 1);
|
||||||
match (*v).get_mut(&s) {
|
match (*v).get_mut(&s) {
|
||||||
Some(vc) => {
|
Some(vc) => (*vc).push(csv),
|
||||||
(*vc).push(csv);
|
None => { (*v).insert(s, vec!(csv)); }
|
||||||
1
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
let vc = vec!(csv);
|
|
||||||
(*v).insert(s, vc);
|
|
||||||
1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
1
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +97,7 @@ pub extern "C" fn cef_string_multimap_key(smm: *mut cef_string_multimap_t, index
|
||||||
if rem < (*val).len() {
|
if rem < (*val).len() {
|
||||||
return cef_string_utf8_set((*key).as_bytes().as_ptr(), (*key).len() as u64, value, 1);
|
return cef_string_utf8_set((*key).as_bytes().as_ptr(), (*key).len() as u64, value, 1);
|
||||||
} else {
|
} else {
|
||||||
rem = rem - (*val).len();
|
rem -= (*val).len();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,12 +111,12 @@ pub extern "C" fn cef_string_multimap_value(smm: *mut cef_string_multimap_t, ind
|
||||||
let v = string_multimap_to_treemap(smm);
|
let v = string_multimap_to_treemap(smm);
|
||||||
let mut rem = index as uint;
|
let mut rem = index as uint;
|
||||||
|
|
||||||
for (_, val) in (*v).values().enumerate() {
|
for val in (*v).values() {
|
||||||
if rem < (*val).len() {
|
if rem < (*val).len() {
|
||||||
let cs = (*val)[rem as uint];
|
let cs = (*val)[rem as uint];
|
||||||
return cef_string_utf8_set((*cs).str as *const u8, (*cs).length, value, 1);
|
return cef_string_utf8_set((*cs).str as *const u8, (*cs).length, value, 1);
|
||||||
} else {
|
} else {
|
||||||
rem = rem - (*val).len();
|
rem -= (*val).len();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
use libc::{c_uint, c_ushort, c_int, c_double, size_t, c_void, c_longlong};
|
use libc::{c_uint, c_ushort, c_int, c_double, size_t, c_void, c_longlong};
|
||||||
use libc::types::os::arch::c95::wchar_t;
|
use libc::types::os::arch::c95::wchar_t;
|
||||||
|
|
||||||
pub type cef_string_map_t = c_void;
|
pub enum cef_string_map_t {}
|
||||||
pub type cef_string_multimap_t = c_void;
|
pub enum cef_string_multimap_t {}
|
||||||
pub type cef_string_list_t = c_void;
|
pub enum cef_string_list_t {}
|
||||||
pub type cef_text_input_context_t = c_void;
|
pub enum cef_text_input_context_t {}
|
||||||
pub type cef_event_handle_t = c_void;
|
pub enum cef_event_handle_t {}
|
||||||
|
|
||||||
//these all need to be done...
|
//these all need to be done...
|
||||||
pub enum cef_binary_value_val {}
|
pub enum cef_binary_value_val {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue