Skip to content

Commit

Permalink
Cleanup dynamic freeze scope artificially extended warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jjjjw committed May 25, 2013
1 parent 3503cb3 commit c6c9533
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 17 deletions.
28 changes: 16 additions & 12 deletions src/components/servo-gfx/text/shaping/harfbuzz.rs
Expand Up @@ -133,8 +133,8 @@ impl ShapedGlyphData {
};

ShapedGlyphEntry {
cluster: (*glyph_info_i).cluster as uint,
codepoint: (*glyph_info_i).codepoint as GlyphIndex,
cluster: (*glyph_info_i).cluster as uint,
codepoint: (*glyph_info_i).codepoint as GlyphIndex,
advance: x_advance,
offset: offset,
}
Expand Down Expand Up @@ -165,7 +165,11 @@ impl Drop for Shaper {

impl Shaper {
pub fn new(font: @mut Font) -> Shaper {
let font_ptr: *mut Font = &mut *font;
// Indirection for Rust Issue #6248, dynamic freeze scope artifically extended
let font_ptr = {
let borrowed_font= &mut *font;
borrowed_font as *mut Font
};
let hb_face: *hb_face_t = hb_face_create_for_tables(get_font_table_func,
font_ptr as *c_void,
null());
Expand All @@ -176,7 +180,7 @@ impl Shaper {
hb_font_set_ppem(hb_font, pt_size as c_uint, pt_size as c_uint);

// Set scaling. Note that this takes 16.16 fixed point.
hb_font_set_scale(hb_font,
hb_font_set_scale(hb_font,
Shaper::float_to_fixed(pt_size) as c_int,
Shaper::float_to_fixed(pt_size) as c_int);

Expand All @@ -187,7 +191,7 @@ impl Shaper {
hb_font_funcs_set_glyph_h_advance_func(hb_funcs, glyph_h_advance_func, null(), null());
hb_font_set_funcs(hb_font, hb_funcs, font_ptr as *c_void, null());

Shaper {
Shaper {
font: font,
hb_face: hb_face,
hb_font: hb_font,
Expand All @@ -208,7 +212,7 @@ impl Shaper {
}
}

impl ShaperMethods for Shaper {
impl ShaperMethods for Shaper {
/// Calculate the layout metrics associated with the given text when rendered in a specific
/// font.
fn shape_text(&self, text: &str, glyphs: &mut GlyphStore) {
Expand All @@ -217,7 +221,7 @@ impl ShaperMethods for Shaper {

// Using as_buf because it never does a copy - we don't need the trailing null
do str::as_buf(text) |ctext: *u8, _: uint| {
hb_buffer_add_utf8(hb_buffer,
hb_buffer_add_utf8(hb_buffer,
ctext as *c_char,
text.len() as c_int,
0,
Expand Down Expand Up @@ -268,7 +272,7 @@ impl Shaper {
i = range.next;
}
}

debug!("(glyph idx) -> (text byte offset)");
for uint::range(0, glyph_data.len()) |i| {
// loc refers to a *byte* offset within the utf8 string.
Expand Down Expand Up @@ -346,7 +350,7 @@ impl Shaper {
glyph_span.begin(), glyph_span.length());
}


// if there's just one glyph, then we don't need further checks.
if glyph_span.length() == 1 { break; }

Expand Down Expand Up @@ -389,7 +393,7 @@ impl Shaper {
//and set glyph info for those and empty infos for the chars that are continuations.

// a simple example:
// chars: 'f' 't' 't'
// chars: 'f' 't' 't'
// glyphs: 'ftt' '' ''
// cgmap: t f f
// gspan: [-]
Expand All @@ -398,7 +402,7 @@ impl Shaper {

let mut covered_byte_span = copy char_byte_span;
// extend, clipping at end of text range.
while covered_byte_span.end() < byte_max
while covered_byte_span.end() < byte_max
&& byteToGlyph[covered_byte_span.end()] == NO_GLYPH {
let range = str::char_range_at(text, covered_byte_span.end());
ignore(range.ch);
Expand Down Expand Up @@ -449,7 +453,7 @@ impl Shaper {

// now add the detailed glyph entry.
glyphs.add_glyphs_for_char_index(char_idx, datas);

// set the other chars, who have no glyphs
let mut i = covered_byte_span.begin();
loop {
Expand Down
5 changes: 3 additions & 2 deletions src/components/servo-net/local_image_cache.rs
Expand Up @@ -135,15 +135,16 @@ pub impl LocalImageCache {
}

priv fn get_state(&self, url: &Url) -> @mut ImageState {
*do self.state_map.find_or_insert_with(url.clone()) |_| {
let state = do self.state_map.find_or_insert_with(url.clone()) |_| {
let new_state = @mut ImageState {
prefetched: false,
decoded: false,
last_request_round: 0,
last_response: ImageNotReady
};
new_state
}
};
*state // Unborrowing the state
}
}

9 changes: 6 additions & 3 deletions src/components/servo/scripting/script_task.rs
Expand Up @@ -163,7 +163,7 @@ impl Drop for ScriptContext {

impl ScriptContext {
/// Creates a new script context.
pub fn new(layout_task: LayoutTask,
pub fn new(layout_task: LayoutTask,
script_port: Port<ScriptMsg>,
script_chan: SharedChan<ScriptMsg>,
resource_task: ResourceTask,
Expand Down Expand Up @@ -201,8 +201,11 @@ impl ScriptContext {
window_size: Size2D(800, 600),
damage: MatchSelectorsDamage,
};

let script_context_ptr: *ScriptContext = &*script_context;
// Indirection for Rust Issue #6248, dynamic freeze scope artifically extended
let script_context_ptr = {
let borrowed_ctx= &mut *script_context;
borrowed_ctx as *mut ScriptContext
};
js_context.set_cx_private(script_context_ptr as *());

unsafe {
Expand Down

0 comments on commit c6c9533

Please sign in to comment.