Skip to content

Commit

Permalink
Rust upgrade for new master rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
larsbergstrom committed Mar 19, 2014
1 parent fe22598 commit a610056
Show file tree
Hide file tree
Showing 39 changed files with 115 additions and 165 deletions.
2 changes: 1 addition & 1 deletion src/components/gfx/platform/android/font.rs
Expand Up @@ -103,7 +103,7 @@ impl FontHandleMethods for FontHandle {
let face_index = 0 as FT_Long;
let result = FT_New_Memory_Face(lib, cbuf, cbuflen as FT_Long,
face_index, &mut face);

if !result.succeeded() || face.is_null() {
return Err(());
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/gfx/platform/linux/font.rs
Expand Up @@ -103,7 +103,7 @@ impl FontHandleMethods for FontHandle {
let face_index = 0 as FT_Long;
let result = FT_New_Memory_Face(lib, cbuf, cbuflen as FT_Long,
face_index, &mut face);

if !result.succeeded() || face.is_null() {
return Err(());
}
Expand Down
8 changes: 3 additions & 5 deletions src/components/gfx/render_task.rs
Expand Up @@ -191,11 +191,9 @@ impl<C: RenderListener + Send,T:Send+Freeze> RenderTask<C,T> {
render_task.start();

// Destroy all the buffers.
{
match render_task.native_graphics_context.as_ref() {
Some(ctx) => render_task.buffer_map.clear(ctx),
None => (),
}
match render_task.native_graphics_context.as_ref() {
Some(ctx) => render_task.buffer_map.clear(ctx),
None => (),
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/components/gfx/text/glyph.rs
Expand Up @@ -10,7 +10,7 @@ use servo_util::geometry;
use std::cmp::{Ord, Eq};
use std::num::NumCast;
use std::mem;
use std::uint;
use std::u16;
use std::vec;
use std::iter;
use geom::point::Point2D;
Expand Down Expand Up @@ -54,7 +54,7 @@ impl GlyphEntry {
// Create a GlyphEntry for uncommon case; should be accompanied by
// initialization of the actual DetailedGlyph data in DetailedGlyphStore
fn complex(starts_cluster: bool, starts_ligature: bool, glyph_count: uint) -> GlyphEntry {
assert!(glyph_count <= uint::MAX);
assert!(glyph_count <= u16::MAX as uint);

debug!("creating complex glyph entry: starts_cluster={}, starts_ligature={}, \
glyph_count={}",
Expand All @@ -78,7 +78,7 @@ impl GlyphEntry {
/// Create a GlyphEntry for the case where glyphs couldn't be found for the specified
/// character.
fn missing(glyph_count: uint) -> GlyphEntry {
assert!(glyph_count <= uint::MAX);
assert!(glyph_count <= u16::MAX as uint);

GlyphEntry::new((glyph_count as u32) << GLYPH_COUNT_SHIFT)
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/main/compositing/compositor.rs
Expand Up @@ -228,7 +228,7 @@ impl IOCompositor {
loop {
match (self.port.try_recv(), self.shutting_down) {
(Empty, _) => break,

(Disconnected, _) => break,

(Data(Exit(chan)), _) => {
Expand Down
3 changes: 1 addition & 2 deletions src/components/main/constellation.rs
Expand Up @@ -540,8 +540,7 @@ impl Constellation {
already_sent.insert(pipeline.id);
}
};



// If the subframe is in the current frame tree, the compositor needs the new size
for current_frame in self.current_frame().iter() {
debug!("Constellation: Sending size for frame in current frame tree.");
Expand Down
2 changes: 1 addition & 1 deletion src/components/main/css/matching.rs
Expand Up @@ -122,7 +122,7 @@ impl<'a> Hash for ApplicableDeclarationsCacheQuery<'a> {
for declaration in self.declarations.iter() {
let ptr: uint = unsafe {
cast::transmute_copy(declaration)
};
};
ptr.hash(state);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/main/platform/common/glfw_windowing.rs
Expand Up @@ -147,7 +147,7 @@ impl WindowMethods<Application> for Window {
if !self.event_queue.with_mut(|queue| queue.is_empty()) {
return self.event_queue.with_mut(|queue| queue.shift().unwrap())
}

glfw::poll_events();
for (_, event) in self.glfw_window.flush_events() {
self.handle_window_event(&self.glfw_window, event);
Expand Down
3 changes: 0 additions & 3 deletions src/components/main/servo.rs
Expand Up @@ -113,9 +113,6 @@ pub mod windowing;
#[path="platform/mod.rs"]
pub mod platform;

#[path = "util/mod.rs"]
pub mod util;

#[cfg(not(test), target_os="linux")]
#[cfg(not(test), target_os="macos")]
#[start]
Expand Down
8 changes: 0 additions & 8 deletions src/components/main/util/mod.rs

This file was deleted.

24 changes: 0 additions & 24 deletions src/components/main/util/task.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/net/image/base.rs
Expand Up @@ -61,7 +61,7 @@ pub fn load_from_memory(buffer: &[u8]) -> Option<Image> {
Some(Image(image.width as u32, image.height as u32, png::RGBA8, image.data))
}
stb_image::ImageF32(_image) => fail!(~"HDR images not implemented"),
stb_image::Error => None
stb_image::Error(_) => None
}
}
}
2 changes: 1 addition & 1 deletion src/components/net/image/holder.rs
Expand Up @@ -74,7 +74,7 @@ impl ImageHolder {
// If this is the first time we've called this function, load
// the image and store it for the future
if self.image.is_none() {
let port =
let port =
self.local_image_cache.access(|local_image_cache| {
local_image_cache.get_image(&self.url)
});
Expand Down
35 changes: 28 additions & 7 deletions src/components/net/image_cache_task.rs
Expand Up @@ -481,18 +481,30 @@ fn load_image_data(url: Url, resource_task: ResourceTask) -> Result<~[u8], ()> {
}


pub fn spawn_listener<A: Send>(f: proc(Port<A>)) -> Chan<A> {
let (setup_port, setup_chan) = Chan::new();

spawn(proc() {
let (port, chan) = Chan::new();
setup_chan.send(chan);
f(port);
});
setup_port.recv()
}


#[cfg(test)]
mod tests {
use super::*;

use resource_task;
use resource_task::{ResourceTask, Metadata, start_sending};
use image::base::test_image_bin;
use util::spawn_listener;
use servo_util::url::parse_url;
use std::comm::{Empty, Data, Disconnected};

fn mock_resource_task(on_load: proc(resource: Chan<resource_task::ProgressMsg>)) -> ResourceTask {
spawn_listener("mock_resource_task", proc(port: Port<resource_task::ControlMsg>) {
spawn_listener(proc(port: Port<resource_task::ControlMsg>) {
loop {
match port.recv() {
resource_task::Load(_, response) => {
Expand Down Expand Up @@ -564,7 +576,10 @@ mod tests {
url_requested.recv();
image_cache_task.exit();
mock_resource_task.send(resource_task::Exit);
assert!(url_requested.try_recv().is_none())
match url_requested.try_recv() {
Empty | Disconnected => (),
Data(_) => assert!(false),
};
}

#[test]
Expand Down Expand Up @@ -658,7 +673,7 @@ mod tests {

let (resource_task_exited, resource_task_exited_chan) = Chan::new();

let mock_resource_task = spawn_listener("should_not...already_available", proc(port: Port<resource_task::ControlMsg>) {
let mock_resource_task = spawn_listener(proc(port: Port<resource_task::ControlMsg>) {
loop {
match port.recv() {
resource_task::Load(_, response) => {
Expand Down Expand Up @@ -692,7 +707,10 @@ mod tests {

// Our resource task should not have received another request for the image
// because it's already cached
assert!(image_bin_sent.try_recv().is_none());
match image_bin_sent.try_recv() {
Empty | Disconnected => (),
Data(_) => assert!(false),
}
}

#[test]
Expand All @@ -701,7 +719,7 @@ mod tests {

let (resource_task_exited, resource_task_exited_chan) = Chan::new();

let mock_resource_task = spawn_listener("should_not...already_failed", proc(port: Port<resource_task::ControlMsg>) {
let mock_resource_task = spawn_listener(proc(port: Port<resource_task::ControlMsg>) {
loop {
match port.recv() {
resource_task::Load(_, response) => {
Expand Down Expand Up @@ -737,7 +755,10 @@ mod tests {

// Our resource task should not have received another request for the image
// because it's already cached
assert!(image_bin_sent.try_recv().is_none());
match image_bin_sent.try_recv() {
Empty | Disconnected => (),
Data(_) => assert!(false),
}
}

#[test]
Expand Down
1 change: 0 additions & 1 deletion src/components/net/net.rs
Expand Up @@ -33,5 +33,4 @@ pub mod data_loader;
pub mod image_cache_task;
pub mod local_image_cache;
pub mod resource_task;
pub mod util;

12 changes: 0 additions & 12 deletions src/components/net/resource_task.rs
Expand Up @@ -143,18 +143,6 @@ fn create_resource_task_with_loaders(loaders: ~[(~str, LoaderTaskFactory)]) -> R
ResourceManager(port, loaders).start();
});
setup_port.recv()

// FIXME: code cloned from spawn_listener due to:
// error: internal compiler error: cannot relate bound region: ReLateBound(6270, BrNamed(syntax::ast::DefId{krate: 0u32, node: 6294u32}, a)) <= ReInfer(1)
//This message reflects a bug in the Rust compiler.

/*
let chan = spawn_listener("ResourceManager", proc(from_client) {
// TODO: change copy to move once we can move out of closures
ResourceManager(from_client, loaders).start()
});
chan
*/
}

pub struct ResourceManager {
Expand Down
23 changes: 0 additions & 23 deletions src/components/net/util.rs

This file was deleted.

6 changes: 3 additions & 3 deletions src/components/script/dom/bindings/codegen/CodegenRust.py
Expand Up @@ -370,7 +370,7 @@ def pickFirstSignature(condition, filterLambda):

overloadCGThings = []
overloadCGThings.append(
CGGeneric("let argcount = cmp::min(argc,%d);" %
CGGeneric("let argcount = cmp::min(argc, %d);" %
maxArgCount))
overloadCGThings.append(
CGSwitch("argcount",
Expand Down Expand Up @@ -3894,7 +3894,7 @@ def definition_body(self):
}*/
//MOZ_ASSERT(IsProxy(obj));
let box_: *%s = cast::transmute(GetProxyPrivate(obj).to_private());
return cast::transmute(&*box_);""" % (self.descriptor.concreteType)
return box_;""" % (self.descriptor.concreteType)

class CGDOMJSProxyHandler_getOwnPropertyDescriptor(CGAbstractExternMethod):
def __init__(self, descriptor):
Expand Down Expand Up @@ -4203,7 +4203,7 @@ def __init__(self, descriptor, name, returnType, args):

def definition_body_prologue(self):
return """
let this: *%s = &*unwrap::<*%s>(obj);
let this: *%s = unwrap::<*%s>(obj);
""" % (self.descriptor.concreteType, self.descriptor.concreteType)

def definition_body(self):
Expand Down
30 changes: 15 additions & 15 deletions src/components/script/dom/node.rs
Expand Up @@ -732,6 +732,8 @@ enum CloneChildrenFlag {
DoNotCloneChildren
}

fn as_uintptr<T>(t: &T) -> uintptr_t { t as *T as uintptr_t }

impl Node {
pub fn ancestors(&self) -> AncestorIterator {
AncestorIterator {
Expand Down Expand Up @@ -1564,7 +1566,7 @@ impl Node {
match prev_text {
Some(ref text_node) => {
let mut prev_characterdata: JS<CharacterData> = CharacterDataCast::to(text_node);
prev_characterdata.get_mut().AppendData(characterdata.get().Data());
let _ = prev_characterdata.get_mut().AppendData(characterdata.get().Data());
abstract_self.remove_child(&mut child);
},
None => prev_text = Some(child)
Expand Down Expand Up @@ -1685,20 +1687,18 @@ impl Node {
}

if lastself != lastother {
unsafe {
let abstract_uint: uintptr_t = cast::transmute(abstract_self.get());
let other_uint: uintptr_t = cast::transmute(other.get());

let random = if abstract_uint < other_uint {
NodeConstants::DOCUMENT_POSITION_FOLLOWING
} else {
NodeConstants::DOCUMENT_POSITION_PRECEDING
};
// step 3.
return random +
NodeConstants::DOCUMENT_POSITION_DISCONNECTED +
NodeConstants::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
}
let abstract_uint: uintptr_t = as_uintptr(&abstract_self.get());
let other_uint: uintptr_t = as_uintptr(&other.get());

let random = if abstract_uint < other_uint {
NodeConstants::DOCUMENT_POSITION_FOLLOWING
} else {
NodeConstants::DOCUMENT_POSITION_PRECEDING
};
// step 3.
return random +
NodeConstants::DOCUMENT_POSITION_DISCONNECTED +
NodeConstants::DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
}

for child in lastself.traverse_preorder() {
Expand Down
4 changes: 2 additions & 2 deletions src/components/script/script_task.rs
Expand Up @@ -893,7 +893,7 @@ impl ScriptTask {
// "load" event as soon as we've finished executing all scripts parsed during
// the initial load.
let mut event = Event::new(&window);
let _ = event.get_mut().InitEvent(~"load", false, false);
event.get_mut().InitEvent(~"load", false, false);
let doctarget = EventTargetCast::from(&document);
let mut wintarget: JS<EventTarget> = EventTargetCast::from(&window);
let winclone = wintarget.clone();
Expand Down Expand Up @@ -1131,7 +1131,7 @@ impl ScriptTask {
} else {
let ConstellationChan(ref chan) = self.constellation_chan;
chan.send(LoadUrlMsg(page.id, url));
}
}
}
}
}
Expand Down

22 comments on commit a610056

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at larsbergstrom@a610056

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging larsbergstrom/servo/rust_20140224_squashed = a610056 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

larsbergstrom/servo/rust_20140224_squashed = a610056 merged ok, testing candidate = dc67767

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jdm
Copy link
Member

@jdm jdm commented on a610056 Mar 19, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0:28:31 INFO - fatal: reference is not a tree: 5b67991531bd98376948d9a3b395e39113107b49
20:28:31 INFO - Unable to checkout '5b67991531bd98376948d9a3b395e39113107b49' in submodule path 'src/support/encoding/rust-encoding'
20:28:31 INFO - configure: error: git

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at larsbergstrom@a610056

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging larsbergstrom/servo/rust_20140224_squashed = a610056 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

larsbergstrom/servo/rust_20140224_squashed = a610056 merged ok, testing candidate = 1df8d28

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at larsbergstrom@a610056

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging larsbergstrom/servo/rust_20140224_squashed = a610056 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

larsbergstrom/servo/rust_20140224_squashed = a610056 merged ok, testing candidate = 6b10d1b

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at larsbergstrom@a610056

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging larsbergstrom/servo/rust_20140224_squashed = a610056 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

larsbergstrom/servo/rust_20140224_squashed = a610056 merged ok, testing candidate = 76df12d

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from jdm
at larsbergstrom@a610056

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging larsbergstrom/servo/rust_20140224_squashed = a610056 into auto

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

larsbergstrom/servo/rust_20140224_squashed = a610056 merged ok, testing candidate = f7aa6e3

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors-servo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = f7aa6e3

Please sign in to comment.