mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01: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)
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue