mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Replace uint/int by usize/isize in various places.
This commit is contained in:
parent
9c863a6bd4
commit
6d30ec77c8
14 changed files with 36 additions and 34 deletions
|
@ -1014,7 +1014,7 @@ class CGArgumentConverter(CGThing):
|
|||
seqType = CGTemplatedType("Vec", declType)
|
||||
|
||||
variadicConversion = string.Template(
|
||||
"let mut vector: ${seqType} = Vec::with_capacity((${argc} - ${index}) as uint);\n"
|
||||
"let mut vector: ${seqType} = Vec::with_capacity((${argc} - ${index}) as usize);\n"
|
||||
"for variadicArg in range(${index}, ${argc}) {\n"
|
||||
"${inner}\n"
|
||||
" vector.push(slot);\n"
|
||||
|
@ -1835,7 +1835,7 @@ def CreateBindingJSObject(descriptor, parent=None):
|
|||
if descriptor.proxy:
|
||||
assert not descriptor.isGlobal()
|
||||
create += """
|
||||
let handler = RegisterBindings::proxy_handlers[PrototypeList::Proxies::%s as uint];
|
||||
let handler = RegisterBindings::proxy_handlers[PrototypeList::Proxies::%s as usize];
|
||||
let mut private = PrivateValue(boxed::into_raw(object) as *const libc::c_void);
|
||||
let obj = with_compartment(cx, proto, || {
|
||||
NewProxyObject(cx, handler,
|
||||
|
@ -2800,7 +2800,7 @@ class CGEnum(CGThing):
|
|||
CGThing.__init__(self)
|
||||
|
||||
decl = """\
|
||||
#[repr(uint)]
|
||||
#[repr(usize)]
|
||||
#[derive(PartialEq, Copy)]
|
||||
#[jstraceable]
|
||||
pub enum %s {
|
||||
|
@ -2819,7 +2819,7 @@ pub const strings: &'static [&'static str] = &[
|
|||
|
||||
impl ToJSValConvertible for super::%s {
|
||||
fn to_jsval(&self, cx: *mut JSContext) -> JSVal {
|
||||
strings[*self as uint].to_jsval(cx)
|
||||
strings[*self as usize].to_jsval(cx)
|
||||
}
|
||||
}
|
||||
""" % (",\n ".join(['"%s"' % val for val in enum.values()]), enum.identifier.name)
|
||||
|
@ -4496,7 +4496,7 @@ class CGRegisterProxyHandlersMethod(CGAbstractMethod):
|
|||
|
||||
def definition_body(self):
|
||||
return CGList([
|
||||
CGGeneric("proxy_handlers[Proxies::%s as uint] = codegen::Bindings::%sBinding::DefineProxyHandler();" % (desc.name, desc.name))
|
||||
CGGeneric("proxy_handlers[Proxies::%s as usize] = codegen::Bindings::%sBinding::DefineProxyHandler();" % (desc.name, desc.name))
|
||||
for desc in self.descriptors
|
||||
], "\n")
|
||||
|
||||
|
@ -5225,7 +5225,7 @@ class GlobalGenRoots():
|
|||
|
||||
return CGList([
|
||||
CGGeneric(AUTOGENERATED_WARNING_COMMENT),
|
||||
CGGeneric("pub const MAX_PROTO_CHAIN_LENGTH: uint = %d;\n\n" % config.maxProtoChainLength),
|
||||
CGGeneric("pub const MAX_PROTO_CHAIN_LENGTH: usize = %d;\n\n" % config.maxProtoChainLength),
|
||||
CGNonNamespacedEnum('ID', protos, [0], deriving="PartialEq, Copy"),
|
||||
CGNonNamespacedEnum('Proxies', proxies, [0], deriving="PartialEq, Copy"),
|
||||
])
|
||||
|
|
|
@ -306,7 +306,7 @@ pub fn jsstring_to_str(cx: *mut JSContext, s: *mut JSString) -> DOMString {
|
|||
unsafe {
|
||||
let mut length = 0;
|
||||
let chars = JS_GetStringCharsAndLength(cx, s, &mut length);
|
||||
let char_vec = slice::from_raw_parts(chars, length as uint);
|
||||
let char_vec = slice::from_raw_parts(chars, length as usize);
|
||||
String::from_utf16(char_vec).unwrap()
|
||||
}
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ impl FromJSValConvertible for ByteString {
|
|||
|
||||
let mut length = 0;
|
||||
let chars = JS_GetStringCharsAndLength(cx, string, &mut length);
|
||||
let char_vec = slice::from_raw_parts(chars, length as uint);
|
||||
let char_vec = slice::from_raw_parts(chars, length as usize);
|
||||
|
||||
if char_vec.iter().any(|&c| c > 0xFF) {
|
||||
// XXX Throw
|
||||
|
|
|
@ -585,7 +585,7 @@ pub trait TemporaryPushable<T> {
|
|||
/// Push a new value onto this container.
|
||||
fn push_unrooted(&mut self, val: &T);
|
||||
/// Insert a new value into this container.
|
||||
fn insert_unrooted(&mut self, index: uint, val: &T);
|
||||
fn insert_unrooted(&mut self, index: usize, val: &T);
|
||||
}
|
||||
|
||||
impl<T: Assignable<U>, U: Reflectable> TemporaryPushable<T> for Vec<JS<U>> {
|
||||
|
@ -593,7 +593,7 @@ impl<T: Assignable<U>, U: Reflectable> TemporaryPushable<T> for Vec<JS<U>> {
|
|||
self.push(unsafe { val.get_js() });
|
||||
}
|
||||
|
||||
fn insert_unrooted(&mut self, index: uint, val: &T) {
|
||||
fn insert_unrooted(&mut self, index: usize, val: &T) {
|
||||
self.insert(index, unsafe { val.get_js() });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ pub struct Trusted<T> {
|
|||
/// A pointer to the Rust DOM object of type T, but void to allow
|
||||
/// sending `Trusted<T>` between tasks, regardless of T's sendability.
|
||||
ptr: *const libc::c_void,
|
||||
refcount: Arc<Mutex<uint>>,
|
||||
refcount: Arc<Mutex<usize>>,
|
||||
script_chan: Box<ScriptChan + Send>,
|
||||
owner_thread: *const libc::c_void,
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ impl<T: Reflectable> Drop for Trusted<T> {
|
|||
/// from being garbage collected due to outstanding references.
|
||||
pub struct LiveDOMReferences {
|
||||
// keyed on pointer to Rust DOM object
|
||||
table: RefCell<HashMap<*const libc::c_void, Arc<Mutex<uint>>>>
|
||||
table: RefCell<HashMap<*const libc::c_void, Arc<Mutex<usize>>>>
|
||||
}
|
||||
|
||||
impl LiveDOMReferences {
|
||||
|
@ -136,7 +136,7 @@ impl LiveDOMReferences {
|
|||
});
|
||||
}
|
||||
|
||||
fn addref<T: Reflectable>(&self, cx: *mut JSContext, ptr: *const T) -> Arc<Mutex<uint>> {
|
||||
fn addref<T: Reflectable>(&self, cx: *mut JSContext, ptr: *const T) -> Arc<Mutex<usize>> {
|
||||
let mut table = self.table.borrow_mut();
|
||||
match table.entry(ptr as *const libc::c_void) {
|
||||
Occupied(mut entry) => {
|
||||
|
|
|
@ -34,7 +34,7 @@ impl ByteString {
|
|||
}
|
||||
|
||||
/// Returns the length.
|
||||
pub fn len(&self) -> uint {
|
||||
pub fn len(&self) -> usize {
|
||||
let ByteString(ref vector) = *self;
|
||||
vector.len()
|
||||
}
|
||||
|
|
|
@ -204,8 +204,8 @@ impl<A: JSTraceable, B: JSTraceable> JSTraceable for (A, B) {
|
|||
|
||||
|
||||
no_jsmanaged_fields!(bool, f32, f64, String, Url);
|
||||
no_jsmanaged_fields!(uint, u8, u16, u32, u64);
|
||||
no_jsmanaged_fields!(int, i8, i16, i32, i64);
|
||||
no_jsmanaged_fields!(usize, u8, u16, u32, u64);
|
||||
no_jsmanaged_fields!(isize, i8, i16, i32, i64);
|
||||
no_jsmanaged_fields!(Sender<T>);
|
||||
no_jsmanaged_fields!(Receiver<T>);
|
||||
no_jsmanaged_fields!(Rect<T>);
|
||||
|
|
|
@ -335,7 +335,7 @@ pub unsafe extern fn throwing_constructor(cx: *mut JSContext, _argc: c_uint,
|
|||
/// Fails if the argument is not a DOM global.
|
||||
pub fn initialize_global(global: *mut JSObject) {
|
||||
let proto_array = box ()
|
||||
([0 as *mut JSObject; PrototypeList::ID::Count as uint]);
|
||||
([0 as *mut JSObject; PrototypeList::ID::Count as usize]);
|
||||
unsafe {
|
||||
assert!(((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0);
|
||||
let box_ = boxed::into_raw(proto_array);
|
||||
|
@ -460,7 +460,7 @@ pub fn get_array_index_from_id(_cx: *mut JSContext, id: jsid) -> Option<u32> {
|
|||
pub fn find_enum_string_index(cx: *mut JSContext,
|
||||
v: JSVal,
|
||||
values: &[&'static str])
|
||||
-> Result<Option<uint>, ()> {
|
||||
-> Result<Option<usize>, ()> {
|
||||
unsafe {
|
||||
let jsstr = JS_ValueToString(cx, v);
|
||||
if jsstr.is_null() {
|
||||
|
@ -474,9 +474,9 @@ pub fn find_enum_string_index(cx: *mut JSContext,
|
|||
}
|
||||
|
||||
Ok(values.iter().position(|value| {
|
||||
value.len() == length as uint &&
|
||||
range(0, length as uint).all(|j| {
|
||||
value.as_bytes()[j] as u16 == *chars.offset(j as int)
|
||||
value.len() == length as usize &&
|
||||
range(0, length as usize).all(|j| {
|
||||
value.as_bytes()[j] as u16 == *chars.offset(j as isize)
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
|
|||
}
|
||||
|
||||
fn SubstringData(self, offset: u32, count: u32) -> Fallible<DOMString> {
|
||||
Ok(self.data.borrow()[offset as uint .. count as uint].to_owned())
|
||||
Ok(self.data.borrow()[offset as usize .. count as usize].to_owned())
|
||||
}
|
||||
|
||||
fn AppendData(self, arg: DOMString) -> ErrorResult {
|
||||
|
@ -107,9 +107,9 @@ impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
|
|||
} else {
|
||||
count
|
||||
};
|
||||
let mut data = self.data.borrow()[..offset as uint].to_owned();
|
||||
let mut data = self.data.borrow()[..offset as usize].to_owned();
|
||||
data.push_str(arg.as_slice());
|
||||
data.push_str(&self.data.borrow()[(offset + count) as uint..]);
|
||||
data.push_str(&self.data.borrow()[(offset + count) as usize..]);
|
||||
*self.data.borrow_mut() = data;
|
||||
// FIXME: Once we have `Range`, we should implement step7 to step11
|
||||
Ok(())
|
||||
|
|
|
@ -109,17 +109,18 @@ impl<'a> CSSStyleDeclarationMethods for JSRef<'a, CSSStyleDeclaration> {
|
|||
}
|
||||
|
||||
fn Item(self, index: u32) -> DOMString {
|
||||
let index = index as usize;
|
||||
let owner = self.owner.root();
|
||||
let elem: JSRef<Element> = ElementCast::from_ref(owner.r());
|
||||
let style_attribute = elem.style_attribute().borrow();
|
||||
let result = style_attribute.as_ref().and_then(|declarations| {
|
||||
if index as uint > declarations.normal.len() {
|
||||
if index > declarations.normal.len() {
|
||||
declarations.important
|
||||
.get(index as uint - declarations.normal.len())
|
||||
.get(index - declarations.normal.len())
|
||||
.map(|decl| format!("{:?} !important", decl))
|
||||
} else {
|
||||
declarations.normal
|
||||
.get(index as uint)
|
||||
.get(index)
|
||||
.map(|decl| format!("{:?}", decl))
|
||||
}
|
||||
});
|
||||
|
|
|
@ -51,7 +51,7 @@ impl<'a> DOMParserMethods for JSRef<'a, DOMParser> {
|
|||
-> Fallible<Temporary<Document>> {
|
||||
let window = self.window.root();
|
||||
let url = window.r().get_url();
|
||||
let content_type = DOMParserBinding::SupportedTypeValues::strings[ty as uint].to_owned();
|
||||
let content_type = DOMParserBinding::SupportedTypeValues::strings[ty as usize].to_owned();
|
||||
match ty {
|
||||
Text_html => {
|
||||
let document = Document::new(window.r(), Some(url.clone()),
|
||||
|
|
|
@ -43,7 +43,7 @@ impl<'a> DOMRectListMethods for JSRef<'a, DOMRectList> {
|
|||
fn Item(self, index: u32) -> Option<Temporary<DOMRect>> {
|
||||
let rects = &self.rects;
|
||||
if index < rects.len() as u32 {
|
||||
Some(Temporary::new(rects[index as uint].clone()))
|
||||
Some(Temporary::new(rects[index as usize].clone()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ impl<'a> DOMTokenListMethods for JSRef<'a, DOMTokenList> {
|
|||
// http://dom.spec.whatwg.org/#dom-domtokenlist-item
|
||||
fn Item(self, index: u32) -> Option<DOMString> {
|
||||
self.attribute().root().and_then(|attr| attr.r().value().tokens().and_then(|tokens| {
|
||||
tokens.get(index as uint).map(|token| token.as_slice().to_owned())
|
||||
tokens.get(index as usize).map(|token| token.as_slice().to_owned())
|
||||
}))
|
||||
}
|
||||
|
||||
|
|
|
@ -189,16 +189,17 @@ impl<'a> HTMLCollectionMethods for JSRef<'a, HTMLCollection> {
|
|||
|
||||
// http://dom.spec.whatwg.org/#dom-htmlcollection-item
|
||||
fn Item(self, index: u32) -> Option<Temporary<Element>> {
|
||||
let index = index as usize;
|
||||
match self.collection {
|
||||
CollectionTypeId::Static(ref elems) => elems
|
||||
.as_slice()
|
||||
.get(index as uint)
|
||||
.get(index)
|
||||
.map(|elem| Temporary::new(elem.clone())),
|
||||
CollectionTypeId::Live(ref root, ref filter) => {
|
||||
let root = root.root();
|
||||
HTMLCollection::traverse(root.r())
|
||||
.filter(|element| filter.filter(*element, root.r()))
|
||||
.nth(index as uint)
|
||||
.nth(index)
|
||||
.clone()
|
||||
.map(Temporary::from_rooted)
|
||||
}
|
||||
|
|
|
@ -60,10 +60,10 @@ impl<'a> NodeListMethods for JSRef<'a, NodeList> {
|
|||
fn Item(self, index: u32) -> Option<Temporary<Node>> {
|
||||
match self.list_type {
|
||||
_ if index >= self.Length() => None,
|
||||
NodeListType::Simple(ref elems) => Some(Temporary::new(elems[index as uint].clone())),
|
||||
NodeListType::Simple(ref elems) => Some(Temporary::new(elems[index as usize].clone())),
|
||||
NodeListType::Children(ref node) => {
|
||||
let node = node.root();
|
||||
node.r().children().nth(index as uint)
|
||||
node.r().children().nth(index as usize)
|
||||
.map(|child| Temporary::from_rooted(child))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue