mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Various fixes related to explicit copying and reinterpret_cast use.
This commit is contained in:
parent
aea47f6b99
commit
3f2d253a71
10 changed files with 18 additions and 18 deletions
|
@ -138,7 +138,7 @@ struct Content<C:Compositor> {
|
||||||
fn handle_control_msg(control_msg: ControlMsg) -> bool {
|
fn handle_control_msg(control_msg: ControlMsg) -> bool {
|
||||||
match control_msg {
|
match control_msg {
|
||||||
ParseMsg(url) => {
|
ParseMsg(url) => {
|
||||||
#debug["content: Received url `%s` to parse", url_to_str(url)];
|
#debug["content: Received url `%s` to parse", url_to_str(copy url)];
|
||||||
|
|
||||||
// Note: we can parse the next document in parallel
|
// Note: we can parse the next document in parallel
|
||||||
// with any previous documents.
|
// with any previous documents.
|
||||||
|
@ -199,11 +199,11 @@ struct Content<C:Compositor> {
|
||||||
|
|
||||||
|
|
||||||
ExecuteMsg(url) => {
|
ExecuteMsg(url) => {
|
||||||
#debug["content: Received url `%s` to execute", url_to_str(url)];
|
#debug["content: Received url `%s` to execute", url_to_str(copy url)];
|
||||||
|
|
||||||
match read_whole_file(&Path(url.path)) {
|
match read_whole_file(&Path(url.path)) {
|
||||||
Err(msg) => {
|
Err(msg) => {
|
||||||
println(#fmt["Error opening %s: %s", url_to_str(url), msg]);
|
println(#fmt["Error opening %s: %s", url_to_str(copy url), msg]);
|
||||||
}
|
}
|
||||||
Ok(bytes) => {
|
Ok(bytes) => {
|
||||||
let compartment = option::expect(self.compartment, ~"TODO error checking");
|
let compartment = option::expect(self.compartment, ~"TODO error checking");
|
||||||
|
|
|
@ -33,7 +33,7 @@ struct Window {
|
||||||
match timer_port.recv() {
|
match timer_port.recv() {
|
||||||
Close => break,
|
Close => break,
|
||||||
Fire(td) => {
|
Fire(td) => {
|
||||||
content_chan.send(Timer(td));
|
content_chan.send(Timer(copy td));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ enum DOMString {
|
||||||
type rust_box<T> = {rc: uint, td: *sys::TypeDesc, next: *(), prev: *(), payload: T};
|
type rust_box<T> = {rc: uint, td: *sys::TypeDesc, next: *(), prev: *(), payload: T};
|
||||||
|
|
||||||
unsafe fn squirrel_away<T>(+x: @T) -> *rust_box<T> {
|
unsafe fn squirrel_away<T>(+x: @T) -> *rust_box<T> {
|
||||||
let y: *rust_box<T> = unsafe::reinterpret_cast(x);
|
let y: *rust_box<T> = unsafe::reinterpret_cast(&x);
|
||||||
unsafe::forget(x);
|
unsafe::forget(x);
|
||||||
y
|
y
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ unsafe fn squirrel_away<T>(+x: @T) -> *rust_box<T> {
|
||||||
type rust_unique<T> = {payload: T};
|
type rust_unique<T> = {payload: T};
|
||||||
|
|
||||||
unsafe fn squirrel_away_unique<T>(+x: ~T) -> *rust_box<T> {
|
unsafe fn squirrel_away_unique<T>(+x: ~T) -> *rust_box<T> {
|
||||||
let y: *rust_box<T> = unsafe::reinterpret_cast(x);
|
let y: *rust_box<T> = unsafe::reinterpret_cast(&x);
|
||||||
unsafe::forget(x);
|
unsafe::forget(x);
|
||||||
y
|
y
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ impl StyleDeclaration: cmp::Eq {
|
||||||
|
|
||||||
impl Attr: cmp::Eq {
|
impl Attr: cmp::Eq {
|
||||||
pure fn eq(&&other: Attr) -> bool {
|
pure fn eq(&&other: Attr) -> bool {
|
||||||
match (self, other) {
|
match (copy self, copy other) {
|
||||||
(Exists(a), Exists(b)) => a == b,
|
(Exists(a), Exists(b)) => a == b,
|
||||||
|
|
||||||
(Exact(a, aa), Exact(b, bb))
|
(Exact(a, aa), Exact(b, bb))
|
||||||
|
@ -126,7 +126,7 @@ impl Attr: cmp::Eq {
|
||||||
impl Selector: cmp::Eq {
|
impl Selector: cmp::Eq {
|
||||||
pure fn eq(&&other: Selector) -> bool {
|
pure fn eq(&&other: Selector) -> bool {
|
||||||
// FIXME: Lots of copying here
|
// FIXME: Lots of copying here
|
||||||
match (self, other) {
|
match (copy self, copy other) {
|
||||||
(Element(s_a, attrs_a), Element(s_b, attrs_b)) => s_a == s_b && attrs_a == attrs_b,
|
(Element(s_a, attrs_a), Element(s_b, attrs_b)) => s_a == s_b && attrs_a == attrs_b,
|
||||||
|
|
||||||
(Child(s1a, s2a), Child(s1b, s2b))
|
(Child(s1a, s2a), Child(s1b, s2b))
|
||||||
|
|
|
@ -27,7 +27,7 @@ fn from_cmdline_args(args: ~[~str]) -> Opts {
|
||||||
|
|
||||||
let opt_match = match getopts::getopts(args, opts) {
|
let opt_match = match getopts::getopts(args, opts) {
|
||||||
result::Ok(m) => { copy m }
|
result::Ok(m) => { copy m }
|
||||||
result::Err(f) => { fail getopts::fail_str(f) }
|
result::Err(f) => { fail getopts::fail_str(copy f) }
|
||||||
};
|
};
|
||||||
|
|
||||||
let urls = if opt_match.free.is_empty() {
|
let urls = if opt_match.free.is_empty() {
|
||||||
|
|
|
@ -108,7 +108,7 @@ fn SyncImageCacheTask(resource_task: ResourceTask) -> ImageCacheTask {
|
||||||
let msg = from_client.recv();
|
let msg = from_client.recv();
|
||||||
|
|
||||||
match msg {
|
match msg {
|
||||||
GetImage(url, response) => inner_cache.send(WaitForImage(url, response)),
|
GetImage(url, response) => inner_cache.send(WaitForImage(copy url, response)),
|
||||||
Exit(response) => {
|
Exit(response) => {
|
||||||
inner_cache.send(Exit(response));
|
inner_cache.send(Exit(response));
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -28,7 +28,7 @@ enum ProgressMsg {
|
||||||
|
|
||||||
impl ProgressMsg: cmp::Eq {
|
impl ProgressMsg: cmp::Eq {
|
||||||
pure fn eq(&&other: ProgressMsg) -> bool {
|
pure fn eq(&&other: ProgressMsg) -> bool {
|
||||||
match (self, other) {
|
match (copy self, copy other) {
|
||||||
(Payload(a), Payload(b)) => a == b,
|
(Payload(a), Payload(b)) => a == b,
|
||||||
(Done(a), Done(b)) => a == b,
|
(Done(a), Done(b)) => a == b,
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ struct ResourceManager {
|
||||||
|
|
||||||
match self.get_loader_factory(url) {
|
match self.get_loader_factory(url) {
|
||||||
Some(loader_factory) => {
|
Some(loader_factory) => {
|
||||||
#debug("resource_task: loading url: %s", to_str(url));
|
#debug("resource_task: loading url: %s", to_str(copy url));
|
||||||
loader_factory(url, progress_chan);
|
loader_factory(url, progress_chan);
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
|
|
@ -42,7 +42,7 @@ fn run_pipeline_screen(urls: ~[~str]) {
|
||||||
|
|
||||||
for urls.each |filename| {
|
for urls.each |filename| {
|
||||||
let url = make_url(filename, None);
|
let url = make_url(filename, None);
|
||||||
#debug["master: Sending url `%s`", url_to_str(url)];
|
#debug["master: Sending url `%s`", url_to_str(copy url)];
|
||||||
engine_task =
|
engine_task =
|
||||||
Some(EngineProto::client::LoadURL(swap_unwrap(&mut engine_task),
|
Some(EngineProto::client::LoadURL(swap_unwrap(&mut engine_task),
|
||||||
url));
|
url));
|
||||||
|
|
|
@ -54,7 +54,7 @@ fn create(buf: &~[u8]) -> Result<QuartzNativeFont, ()> {
|
||||||
let fontprov = vec::as_buf(*buf, |cbuf, len| {
|
let fontprov = vec::as_buf(*buf, |cbuf, len| {
|
||||||
CGDataProviderCreateWithData(
|
CGDataProviderCreateWithData(
|
||||||
null(),
|
null(),
|
||||||
unsafe { reinterpret_cast(cbuf) },
|
unsafe { reinterpret_cast(&cbuf) },
|
||||||
len as size_t,
|
len as size_t,
|
||||||
null())
|
null())
|
||||||
});
|
});
|
||||||
|
|
|
@ -40,7 +40,7 @@ fn shape_text(font: &Font, text: ~str) -> ~[Glyph] unsafe {
|
||||||
#debug("shaping text '%s'", text);
|
#debug("shaping text '%s'", text);
|
||||||
|
|
||||||
let face_blob = vec::as_buf(*(*font).buf(), |buf, len| {
|
let face_blob = vec::as_buf(*(*font).buf(), |buf, len| {
|
||||||
hb_blob_create(reinterpret_cast(buf),
|
hb_blob_create(reinterpret_cast(&buf),
|
||||||
len as c_uint,
|
len as c_uint,
|
||||||
HB_MEMORY_MODE_READONLY,
|
HB_MEMORY_MODE_READONLY,
|
||||||
null(),
|
null(),
|
||||||
|
@ -56,7 +56,7 @@ fn shape_text(font: &Font, text: ~str) -> ~[Glyph] unsafe {
|
||||||
let funcs = hb_font_funcs_create();
|
let funcs = hb_font_funcs_create();
|
||||||
hb_font_funcs_set_glyph_func(funcs, glyph_func, null(), null());
|
hb_font_funcs_set_glyph_func(funcs, glyph_func, null(), null());
|
||||||
hb_font_funcs_set_glyph_h_advance_func(funcs, glyph_h_advance_func, null(), null());
|
hb_font_funcs_set_glyph_h_advance_func(funcs, glyph_h_advance_func, null(), null());
|
||||||
hb_font_set_funcs(hbfont, funcs, reinterpret_cast(addr_of(*font)), null());
|
hb_font_set_funcs(hbfont, funcs, reinterpret_cast(&addr_of(*font)), null());
|
||||||
|
|
||||||
let buffer = hb_buffer_create();
|
let buffer = hb_buffer_create();
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ extern fn glyph_func(_font: *hb_font_t,
|
||||||
glyph: *mut hb_codepoint_t,
|
glyph: *mut hb_codepoint_t,
|
||||||
_user_data: *c_void) -> hb_bool_t unsafe {
|
_user_data: *c_void) -> hb_bool_t unsafe {
|
||||||
|
|
||||||
let font: *Font = reinterpret_cast(font_data);
|
let font: *Font = reinterpret_cast(&font_data);
|
||||||
assert font.is_not_null();
|
assert font.is_not_null();
|
||||||
|
|
||||||
return match (*font).glyph_index(unicode as char) {
|
return match (*font).glyph_index(unicode as char) {
|
||||||
|
@ -127,7 +127,7 @@ extern fn glyph_h_advance_func(_font: *hb_font_t,
|
||||||
font_data: *c_void,
|
font_data: *c_void,
|
||||||
glyph: hb_codepoint_t,
|
glyph: hb_codepoint_t,
|
||||||
_user_data: *c_void) -> hb_position_t unsafe {
|
_user_data: *c_void) -> hb_position_t unsafe {
|
||||||
let font: *Font = reinterpret_cast(font_data);
|
let font: *Font = reinterpret_cast(&font_data);
|
||||||
assert font.is_not_null();
|
assert font.is_not_null();
|
||||||
|
|
||||||
let h_advance = (*font).glyph_h_advance(glyph as uint);
|
let h_advance = (*font).glyph_h_advance(glyph as uint);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue