Skip to content

Commit

Permalink
Upgrade Rust.
Browse files Browse the repository at this point in the history
  • Loading branch information
metajack committed Aug 9, 2014
1 parent 62c9a77 commit 7a4321d
Show file tree
Hide file tree
Showing 81 changed files with 265 additions and 236 deletions.
4 changes: 4 additions & 0 deletions Makefile.in
Expand Up @@ -45,6 +45,10 @@ ifdef CFG_ENABLE_DEBUG
CFG_RUSTC_SELF_FLAGS += -g
endif

# FIXME: Remove once we’re on a Rust version without the old url crate
# https://github.com/rust-lang/rust/issues/16140
CFG_RUSTC_FLAGS += --extern url=$(B)/src/support/url/rust-url/liburl.rlib

export CFG_RUSTC
export CFG_RUSTC_FLAGS
export CFG_LOCAL_RUSTC
Expand Down
5 changes: 1 addition & 4 deletions configure
Expand Up @@ -409,10 +409,7 @@ CFG_BUILD_DIR="${CFG_BUILD_HOME}${CFG_TARGET}/"
make_dir "${CFG_BUILD_DIR}"
SNAPSHOT_VERSION=$(cat ${CFG_SRC_DIR}/src/compiler/rust-snapshot-hash | rev | cut -d/ -f1 | rev)
SNAPSHOT_HASH=$(cat ${CFG_SRC_DIR}/src/compiler/rust-snapshot-hash | cut -d/ -f1)
if [ $CFG_OSTYPE = "linux-androideabi" ]
then
CFG_ENABLE_TREE_RUST=1 # We don't yet have Android snapshots
fi

if [ -z "$CFG_ENABLE_TREE_RUST" -a -z "$CFG_LOCAL_RUST_ROOT" ]
then
if ! [ -f ${CFG_BUILD_DIR}/rust_snapshot/${SNAPSHOT_VERSION}-${DEFAULT_TARGET}/bin/rustc -a -f ${CFG_BUILD_DIR}/src/compiler/rust-snapshot-hash-stamp -a -z "$(diff ${CFG_BUILD_DIR}/src/compiler/rust-snapshot-hash-stamp ${CFG_SRC_DIR}/src/compiler/rust-snapshot-hash)" ]
Expand Down
2 changes: 1 addition & 1 deletion mk/check.mk
Expand Up @@ -20,7 +20,7 @@ $(eval $(call DEF_SUBMODULE_TEST_RULES,$(submodule))))
define DEF_LIB_CRATE_TEST_RULES
servo-test-$(1): $$(DEPS_$(1))
@$$(call E, compile: servo-test-$(1))
$$(Q)$$(RUSTC) $$(RFLAGS_$(1)) --test -o $$@ $$<
$$(Q)$$(RUSTC) $(strip $(CFG_RUSTC_FLAGS)) $$(RFLAGS_$(1)) --test -o $$@ $$<

.PHONY: check-servo-$(1)
check-servo-$(1): servo-test-$(1)
Expand Down
13 changes: 11 additions & 2 deletions mk/doc.mk
Expand Up @@ -4,7 +4,7 @@


RUSTDOC_HTML_IN_HEADER = $(S)/src/etc/rustdoc-style.html
RUSTDOC_FLAGS = --html-in-header $(RUSTDOC_HTML_IN_HEADER)
RUSTDOC_FLAGS = --extern url=$(B)/src/support/url/rust-url/liburl.rlib --html-in-header $(RUSTDOC_HTML_IN_HEADER)
RUSTDOC_DEPS = $(RUSTDOC_HTML_IN_HEADER)

# FIXME(#2924) These crates make rustdoc fail for undetermined reasons.
Expand Down Expand Up @@ -36,15 +36,24 @@ $(eval $(call DEF_SERVO_DOC_RULES,$(lib_crate))))

define DEF_SUBMODULES_DOC_RULES

ifeq (,$(filter $(1),$(DOC_BLACKLISTED)))

.PHONY: doc-$(1)
doc-$(1): $$(DONE_DEPS_$(1)) $$(ROUGH_DEPS_$(1)) $$(RUSTC_DEP_$(1))
@$$(call E, rustdoc: $(1))
$$(Q) \
RUSTDOC_FLAGS="$$(ENV_RLDFLAGS_$(1))" \
RUSTDOC_FLAGS="$$(ENV_RLDFLAGS_$(1)) $$(RUSTDOC_FLAGS)" \
RUSTDOC_TARGET="$$(CFG_BUILD_HOME)/doc" \
$$(ENV_EXT_DEPS_$(1)) \
$$(MAKE) -C $$(B)src/$$(PATH_$(1)) doc

else

.PHONY: doc-$(1)
doc-$(1): $$(DONE_DEPS_$(1)) $$(ROUGH_DEPS_$(1)) $$(RUSTC_DEP_$(1))
@echo SKIPPED: blacklisted rustdoc: $$@

endif
endef

# Only Rust submodules
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/rust-snapshot-hash
@@ -1 +1 @@
5e4a171bd551433e8d58114744c4efbc4bc90ae4/rust-0.12.0-pre
9de20198aedb3c3419ee503755e04bcc198d3a94/rust-0.12.0-pre
2 changes: 1 addition & 1 deletion src/components/compositing/compositing.rs
Expand Up @@ -35,7 +35,7 @@ extern crate servo_util = "util";

extern crate libc;
extern crate time;
extern crate url = "url_";
extern crate url;

#[cfg(target_os="macos")]
extern crate core_graphics;
Expand Down
2 changes: 1 addition & 1 deletion src/components/compositing/constellation.rs
Expand Up @@ -434,7 +434,7 @@ impl<LTF: LayoutTaskFactory, STF: ScriptTaskFactory> Constellation<LTF, STF> {
});
idx.map(|idx| {
debug!("removing pending frame change for failed pipeline");
force_pipeline_exit(&self.pending_frames.get(idx).after.pipeline);
force_pipeline_exit(&self.pending_frames[idx].after.pipeline);
self.pending_frames.remove(idx)
});
if idx.is_none() {
Expand Down
4 changes: 2 additions & 2 deletions src/components/compositing/platform/common/glfw_windowing.rs
Expand Up @@ -162,7 +162,7 @@ impl WindowMethods<Application> for Window {
{
let mut event_queue = self.event_queue.borrow_mut();
if !event_queue.is_empty() {
return event_queue.shift().unwrap();
return event_queue.remove(0).unwrap();
}
}

Expand All @@ -174,7 +174,7 @@ impl WindowMethods<Application> for Window {
if self.glfw_window.should_close() {
QuitWindowEvent
} else {
self.event_queue.borrow_mut().shift().unwrap_or(IdleWindowEvent)
self.event_queue.borrow_mut().remove(0).unwrap_or(IdleWindowEvent)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/compositing/platform/common/glut_windowing.rs
Expand Up @@ -161,12 +161,12 @@ impl WindowMethods<Application> for Window {

fn recv(&self) -> WindowEvent {
if !self.event_queue.borrow_mut().is_empty() {
return self.event_queue.borrow_mut().shift().unwrap();
return self.event_queue.borrow_mut().remove(0).unwrap();
}

glut::check_loop();

self.event_queue.borrow_mut().shift().unwrap_or(IdleWindowEvent)
self.event_queue.borrow_mut().remove(0).unwrap_or(IdleWindowEvent)
}

/// Sets the ready state.
Expand Down
4 changes: 2 additions & 2 deletions src/components/embedding/command_line.rs
Expand Up @@ -4,7 +4,7 @@

use libc::{calloc, c_int, size_t};
use std::mem;
use std::str;
use std::string;
use std::c_vec::CVec;
use string::{cef_string_userfree_utf16_alloc, cef_string_utf16_set};
use types::{cef_command_line_t, cef_string_t, cef_string_userfree_t, cef_string_utf16_t};
Expand All @@ -30,7 +30,7 @@ pub fn command_line_init(argc: c_int, argv: *const *const u8) {
unsafe {
let mut a: Vec<String> = vec!();
for i in range(0u, argc as uint) {
a.push(str::raw::from_c_str(*argv.offset(i as int) as *const i8));
a.push(string::raw::from_buf(*argv.offset(i as int) as *const u8));
}
let cl = command_line_new();
(*cl).argc = argc;
Expand Down
5 changes: 2 additions & 3 deletions src/components/gfx/display_list/mod.rs
Expand Up @@ -19,7 +19,6 @@ use render_context::RenderContext;
use text::glyph::CharIndex;
use text::TextRun;

use std::collections::Deque;
use collections::dlist::DList;
use collections::dlist;
use geom::{Point2D, Rect, SideOffsets2D, Size2D};
Expand Down Expand Up @@ -222,7 +221,7 @@ impl StackingContext {
}

let mut new_list = DisplayList::new();
new_list.list.push_back(item);
new_list.list.push(item);
stacking_context.positioned_descendants.push((z_index, new_list))
}
}
Expand Down Expand Up @@ -320,7 +319,7 @@ impl DisplayList {

/// Appends the given item to the display list.
pub fn push(&mut self, item: DisplayItem) {
self.list.push_back(item)
self.list.push(item)
}

/// Appends the given display list to this display list, consuming the other display list in
Expand Down
3 changes: 1 addition & 2 deletions src/components/gfx/display_list/optimizer.rs
Expand Up @@ -6,7 +6,6 @@ use display_list::{BorderDisplayItemClass, ClipDisplayItem, ClipDisplayItemClass
use display_list::{DisplayList, ImageDisplayItemClass, LineDisplayItemClass};
use display_list::{PseudoDisplayItemClass, SolidColorDisplayItemClass, TextDisplayItemClass};

use std::collections::Deque;
use collections::dlist::DList;
use geom::rect::Rect;
use servo_util::geometry::Au;
Expand Down Expand Up @@ -36,7 +35,7 @@ impl DisplayListOptimizer {
for item in display_list.iter() {
match self.process_display_item(item) {
None => {}
Some(display_item) => result.push_back(display_item),
Some(display_item) => result.push(display_item),
}
}
DisplayList {
Expand Down
6 changes: 3 additions & 3 deletions src/components/gfx/font.rs
Expand Up @@ -4,7 +4,7 @@

use geom::{Point2D, Rect, Size2D};
use std::mem;
use std::str;
use std::string;
use std::rc::Rc;
use std::cell::RefCell;
use servo_util::cache::{Cache, HashCache};
Expand Down Expand Up @@ -53,7 +53,7 @@ pub trait FontTableTagConversions {
impl FontTableTagConversions for FontTableTag {
fn tag_to_str(&self) -> String {
unsafe {
let reversed = str::raw::from_buf_len(mem::transmute(self), 4);
let reversed = string::raw::from_buf_len(mem::transmute(self), 4);
return String::from_chars([reversed.as_slice().char_at(3),
reversed.as_slice().char_at(2),
reversed.as_slice().char_at(1),
Expand Down Expand Up @@ -179,7 +179,7 @@ impl FontGroup {
assert!(self.fonts.len() > 0);

// TODO(Issue #177): Actually fall back through the FontGroup when a font is unsuitable.
TextRun::new(&mut *self.fonts.get(0).borrow_mut(), text.clone())
TextRun::new(&mut *self.fonts[0].borrow_mut(), text.clone())
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/gfx/gfx.rs
Expand Up @@ -29,7 +29,7 @@ extern crate servo_util = "util";
extern crate servo_msg = "msg";
extern crate style;
extern crate sync;
extern crate url = "url_";
extern crate url;

// Eventually we would like the shaper to be pluggable, as many operating systems have their own
// shapers. For now, however, this is a hard dependency.
Expand Down
6 changes: 3 additions & 3 deletions src/components/gfx/platform/freetype/font.rs
Expand Up @@ -27,7 +27,7 @@ use freetype::tt_os2::TT_OS2;

use std::mem;
use std::ptr;
use std::str;
use std::string;

use sync::Arc;

Expand Down Expand Up @@ -120,10 +120,10 @@ impl FontHandleMethods for FontHandle {
self.font_data.clone()
}
fn family_name(&self) -> String {
unsafe { str::raw::from_c_str(&*(*self.face).family_name) }
unsafe { string::raw::from_buf(&*(*self.face).family_name as *const i8 as *const u8) }
}
fn face_name(&self) -> String {
unsafe { str::raw::from_c_str(&*FT_Get_Postscript_Name(self.face)) }
unsafe { string::raw::from_buf(&*FT_Get_Postscript_Name(self.face) as *const i8 as *const u8) }
}
fn is_italic(&self) -> bool {
unsafe { (*self.face).style_flags & FT_STYLE_FLAG_ITALIC != 0 }
Expand Down
8 changes: 4 additions & 4 deletions src/components/gfx/platform/freetype/font_list.rs
Expand Up @@ -17,9 +17,9 @@ use fontconfig::fontconfig::{
};

use libc;
use libc::{c_int, c_char};
use libc::c_int;
use std::ptr;
use std::str;
use std::string;

pub fn get_available_families(callback: |String|) {
unsafe {
Expand All @@ -32,7 +32,7 @@ pub fn get_available_families(callback: |String|) {
let mut FC_FAMILY_C = "family".to_c_str();
let FC_FAMILY = FC_FAMILY_C.as_mut_ptr();
while FcPatternGetString(*font, FC_FAMILY, v, &mut family) == FcResultMatch {
let family_name = str::raw::from_c_str(family as *const c_char);
let family_name = string::raw::from_buf(family as *const i8 as *const u8);
callback(family_name);
v += 1;
}
Expand Down Expand Up @@ -75,7 +75,7 @@ pub fn get_variations_for_family(family_name: &str, callback: |String|) {
let FC_FILE = FC_FILE_C.as_mut_ptr();
let mut file: *mut FcChar8 = ptr::mut_null();
let file = if FcPatternGetString(*font, FC_FILE, 0, &mut file) == FcResultMatch {
str::raw::from_c_str(file as *const libc::c_char)
string::raw::from_buf(file as *const i8 as *const u8)
} else {
fail!();
};
Expand Down
34 changes: 17 additions & 17 deletions src/components/gfx/text/glyph.rs
Expand Up @@ -379,7 +379,7 @@ impl<'a> DetailedGlyphStore {
.expect("Invalid index not found in detailed glyph lookup table!");

assert!(i + (detail_offset as uint) < self.detail_buffer.len());
self.detail_buffer.get(i + (detail_offset as uint))
&self.detail_buffer[i + (detail_offset as uint)]
}

fn ensure_sorted(&mut self) {
Expand Down Expand Up @@ -451,7 +451,7 @@ pub enum GlyphInfo<'a> {
impl<'a> GlyphInfo<'a> {
pub fn id(self) -> GlyphId {
match self {
SimpleGlyphInfo(store, entry_i) => store.entry_buffer.get(entry_i.to_uint()).id(),
SimpleGlyphInfo(store, entry_i) => store.entry_buffer[entry_i.to_uint()].id(),
DetailGlyphInfo(store, entry_i, detail_j) => {
store.detail_store.get_detailed_glyph_with_index(entry_i, detail_j).id
}
Expand All @@ -462,7 +462,7 @@ impl<'a> GlyphInfo<'a> {
// FIXME: Resolution conflicts with IteratorUtil trait so adding trailing _
pub fn advance(self) -> Au {
match self {
SimpleGlyphInfo(store, entry_i) => store.entry_buffer.get(entry_i.to_uint()).advance(),
SimpleGlyphInfo(store, entry_i) => store.entry_buffer[entry_i.to_uint()].advance(),
DetailGlyphInfo(store, entry_i, detail_j) => {
store.detail_store.get_detailed_glyph_with_index(entry_i, detail_j).advance
}
Expand Down Expand Up @@ -560,7 +560,7 @@ impl<'a> GlyphStore {
self.detail_store.add_detailed_glyphs_for_entry(i, glyph);
GlyphEntry::complex(data.cluster_start, data.ligature_start, 1)
}
}.adapt_character_flags_of_entry(*self.entry_buffer.get(i.to_uint()));
}.adapt_character_flags_of_entry(self.entry_buffer[i.to_uint()]);

*self.entry_buffer.get_mut(i.to_uint()) = entry;
}
Expand All @@ -586,7 +586,7 @@ impl<'a> GlyphStore {
first_glyph_data.ligature_start,
glyph_count)
}
}.adapt_character_flags_of_entry(*self.entry_buffer.get(i.to_uint()));
}.adapt_character_flags_of_entry(self.entry_buffer[i.to_uint()]);

debug!("Adding multiple glyphs[idx={}, count={}]: {:?}", i, glyph_count, entry);

Expand Down Expand Up @@ -633,56 +633,56 @@ impl<'a> GlyphStore {
// getter methods
pub fn char_is_space(&self, i: CharIndex) -> bool {
assert!(i < self.char_len());
self.entry_buffer.get(i.to_uint()).char_is_space()
self.entry_buffer[i.to_uint()].char_is_space()
}

pub fn char_is_tab(&self, i: CharIndex) -> bool {
assert!(i < self.char_len());
self.entry_buffer.get(i.to_uint()).char_is_tab()
self.entry_buffer[i.to_uint()].char_is_tab()
}

pub fn char_is_newline(&self, i: CharIndex) -> bool {
assert!(i < self.char_len());
self.entry_buffer.get(i.to_uint()).char_is_newline()
self.entry_buffer[i.to_uint()].char_is_newline()
}

pub fn is_ligature_start(&self, i: CharIndex) -> bool {
assert!(i < self.char_len());
self.entry_buffer.get(i.to_uint()).is_ligature_start()
self.entry_buffer[i.to_uint()].is_ligature_start()
}

pub fn is_cluster_start(&self, i: CharIndex) -> bool {
assert!(i < self.char_len());
self.entry_buffer.get(i.to_uint()).is_cluster_start()
self.entry_buffer[i.to_uint()].is_cluster_start()
}

pub fn can_break_before(&self, i: CharIndex) -> BreakType {
assert!(i < self.char_len());
self.entry_buffer.get(i.to_uint()).can_break_before()
self.entry_buffer[i.to_uint()].can_break_before()
}

// setter methods
pub fn set_char_is_space(&mut self, i: CharIndex) {
assert!(i < self.char_len());
let entry = *self.entry_buffer.get(i.to_uint());
let entry = self.entry_buffer[i.to_uint()];
*self.entry_buffer.get_mut(i.to_uint()) = entry.set_char_is_space();
}

pub fn set_char_is_tab(&mut self, i: CharIndex) {
assert!(i < self.char_len());
let entry = *self.entry_buffer.get(i.to_uint());
let entry = self.entry_buffer[i.to_uint()];
*self.entry_buffer.get_mut(i.to_uint()) = entry.set_char_is_tab();
}

pub fn set_char_is_newline(&mut self, i: CharIndex) {
assert!(i < self.char_len());
let entry = *self.entry_buffer.get(i.to_uint());
let entry = self.entry_buffer[i.to_uint()];
*self.entry_buffer.get_mut(i.to_uint()) = entry.set_char_is_newline();
}

pub fn set_can_break_before(&mut self, i: CharIndex, t: BreakType) {
assert!(i < self.char_len());
let entry = *self.entry_buffer.get(i.to_uint());
let entry = self.entry_buffer[i.to_uint()];
*self.entry_buffer.get_mut(i.to_uint()) = entry.set_can_break_before(t);
}
}
Expand Down Expand Up @@ -738,12 +738,12 @@ impl<'a> Iterator<(CharIndex, GlyphInfo<'a>)> for GlyphIterator<'a> {
self.char_range.next().and_then(|i| {
self.char_index = i;
assert!(i < self.store.char_len());
let entry = self.store.entry_buffer.get(i.to_uint());
let entry = self.store.entry_buffer[i.to_uint()];
if entry.is_simple() {
Some((self.char_index, SimpleGlyphInfo(self.store, i)))
} else {
// Fall back to the slow path.
self.next_complex_glyph(entry, i)
self.next_complex_glyph(&entry, i)
}
})
}
Expand Down

0 comments on commit 7a4321d

Please sign in to comment.