Update rust

This commit is contained in:
Brian Anderson 2013-09-06 15:04:18 -07:00
parent da4cede500
commit 13a3865e4e
12 changed files with 47 additions and 23 deletions

@ -1 +1 @@
Subproject commit 0ac3e023d86fa84ed38bca3d34003b494fd28acf
Subproject commit d39cec65b025ad4c6de50e778ffd1177279b5b3d

View file

@ -13,6 +13,7 @@ use servo_util::range::Range;
use text::util::{float_to_fixed, fixed_to_float, fixed_to_rounded_int};
use std::cast::transmute;
use std::char;
use std::libc::{c_uint, c_int, c_void, c_char};
use std::ptr;
use std::ptr::null;
@ -493,7 +494,7 @@ extern fn glyph_func(_: *hb_font_t,
assert!(font.is_not_null());
unsafe {
match (*font).glyph_index(unicode as char) {
match (*font).glyph_index(char::from_u32(unicode).unwrap()) {
Some(g) => {
*glyph = g as hb_codepoint_t;
true as hb_bool_t

View file

@ -114,6 +114,10 @@ pub fn fixed_to_rounded_int(before: int, f: i32) -> int {
/* Generate a 32-bit TrueType tag from its 4 characters */
pub fn true_type_tag(a: char, b: char, c: char, d: char) -> u32 {
let a = a as u32;
let b = b as u32;
let c = c as u32;
let d = d as u32;
(a << 24 | b << 16 | c << 8 | d) as u32
}

View file

@ -655,7 +655,7 @@ impl Constellation {
// Find the pending frame change whose new pipeline id is pipeline_id.
// If it is not found, it simply means that this pipeline will not receive
// permission to paint.
let pending_index = do self.pending_frames.rposition |frame_change| {
let pending_index = do self.pending_frames.iter().rposition |frame_change| {
frame_change.after.pipeline.id == pipeline_id
};
for &pending_index in pending_index.iter() {

View file

@ -12,6 +12,7 @@ use windowing::{Forward, Back};
use alert::{Alert, AlertMethods};
use std::libc::c_int;
use std::local_data;
use geom::point::Point2D;
use geom::size::Size2D;
use servo_msg::compositor_msg::{IdleRenderState, RenderState, RenderingRenderState};
@ -34,6 +35,7 @@ impl ApplicationMethods for Application {
impl Drop for Application {
fn drop(&self) {
glfw::terminate();
drop_local_window();
}
}
@ -76,15 +78,15 @@ impl WindowMethods<Application> for Window {
throbber_frame: 0,
};
let event_queue = window.event_queue;
install_local_window(window);
// Register event handlers.
do window.glfw_window.set_framebuffer_size_callback |_win, width, height| {
event_queue.push(ResizeWindowEvent(width as uint, height as uint))
local_window().event_queue.push(ResizeWindowEvent(width as uint, height as uint))
}
do window.glfw_window.set_key_callback |_win, key, _scancode, action, mods| {
if action == glfw::PRESS {
window.handle_key(key, mods)
local_window().handle_key(key, mods)
}
}
do window.glfw_window.set_mouse_button_callback |win, button, action, _mods| {
@ -96,7 +98,7 @@ impl WindowMethods<Application> for Window {
let x = x as f32 * hidpi;
let y = y as f32 * hidpi;
if button < 3 {
window.handle_mouse(button, action, x as i32, y as i32);
local_window().handle_mouse(button, action, x as i32, y as i32);
}
}
do window.glfw_window.set_scroll_callback |win, x_offset, y_offset| {
@ -111,7 +113,7 @@ impl WindowMethods<Application> for Window {
let x = x as f32 * hidpi;
let y = y as f32 * hidpi;
event_queue.push(ScrollWindowEvent(Point2D(dx, dy), Point2D(x as i32, y as i32)));
local_window().event_queue.push(ScrollWindowEvent(Point2D(dx, dy), Point2D(x as i32, y as i32)));
}
window
@ -196,7 +198,8 @@ impl Window {
}
/// Helper function to handle keyboard events.
fn handle_key(&self, key: c_int, mods: c_int) {
fn handle_key(&self, key: c_int, mods: glfw::KeyMods) {
let mods = *mods;
match key {
glfw::KEY_ESCAPE => self.glfw_window.set_should_close(true),
glfw::KEY_L if mods & glfw::MOD_CONTROL != 0 => self.load_url(), // Ctrl+L
@ -258,3 +261,16 @@ impl Window {
}
}
static TLS_KEY: local_data::Key<@mut Window> = &local_data::Key;
fn install_local_window(window: @mut Window) {
local_data::set(TLS_KEY, window);
}
fn drop_local_window() {
local_data::pop(TLS_KEY);
}
fn local_window() -> @mut Window {
local_data::get(TLS_KEY, |v| *v.unwrap())
}

View file

@ -1068,7 +1068,7 @@ for (uint32_t i = 0; i < length; ++i) {
return handleDefault(
conversionCode,
("static data: [u8, ..%s] = [ %s ];\n"
"%s = str(str::from_bytes(data));" %
"%s = str(str::from_utf8(data));" %
(len(defaultValue.value) + 1,
", ".join(["'" + char + "' as u8" for char in defaultValue.value] + ["0"]),
varName)))
@ -1268,7 +1268,10 @@ for (uint32_t i = 0; i < length; ++i) {
" %s = %s;\n"
"}" % (dataLoc, defaultStr))).define()
if typeName != "bool":
return (template, declType, None, isOptional, "0 as %s" % typeName)
else:
return (template, declType, None, isOptional, "false")
def instantiateJSToNativeConversionTemplate(templateTuple, replacements,
argcAndIndex=None):
@ -1458,7 +1461,7 @@ def getWrapTemplateForType(type, descriptorProvider, result, successCode,
if not haveSuccessCode:
return wrapCall + ";\n" + "return if (*vp).v != 0 { 1 } else { 0 };"
failureCode = "return 0;"
str = ("if !(%s as bool) {\n" +
str = ("if !(%s != 0) {\n" +
CGIndenter(CGGeneric(failureCode)).define() + "\n" +
"}\n" +
successCode) % (wrapCall)
@ -1550,7 +1553,7 @@ for (uint32_t i = 0; i < length; ++i) {
else:
#wrap = "WrapObject(cx, ${obj}, %s, %s${jsvalPtr})" % (result, getIID)
if descriptor.pointerType == '':
wrap = "(%s.wrap(cx, ${obj}, ${jsvalPtr}) as bool)" % result
wrap = "(%s.wrap(cx, ${obj}, ${jsvalPtr}) != 0)" % result
else:
wrap = "if WrapNewBindingObject(cx, ${obj}, %s as @mut CacheableWrapper, ${jsvalPtr}) { 1 } else { 0 };" % result
wrappingCode += wrapAndSetPtr(wrap)
@ -4477,7 +4480,7 @@ class CGDictionary(CGThing):
if dealWithOptional:
replacements["declName"] = "(" + replacements["declName"] + ".Value())"
if member.defaultValue:
replacements["haveValue"] = "found as bool"
replacements["haveValue"] = "found != 0"
# NOTE: jsids are per-runtime, so don't use them in workers
if True or self.workers: #XXXjdm hack until 'static mut' exists for global jsids

View file

@ -603,24 +603,24 @@ impl WrapperCache {
#[fixed_stack_segment]
pub fn WrapNewBindingObject(cx: *JSContext, scope: *JSObject,
value: @mut CacheableWrapper,
vp: *mut JSVal) -> bool {
vp: *mut JSVal) -> JSBool {
unsafe {
let cache = value.get_wrappercache();
let obj = cache.get_wrapper();
if obj.is_not_null() /*&& js::GetObjectCompartment(obj) == js::GetObjectCompartment(scope)*/ {
*vp = RUST_OBJECT_TO_JSVAL(obj);
return true;
return 1; // JS_TRUE
}
let obj = value.wrap_object_shared(cx, scope);
if obj.is_null() {
return false;
return 0; // JS_FALSE
}
// MOZ_ASSERT(js::IsObjectInContextCompartment(scope, cx));
cache.set_wrapper(obj);
*vp = RUST_OBJECT_TO_JSVAL(obj);
return JS_WrapValue(cx, cast::transmute(vp)) != 0;
return JS_WrapValue(cx, cast::transmute(vp));
}
}

@ -1 +1 @@
Subproject commit 38d1caae638b28bbfbbbc988b0b841e973345243
Subproject commit a41aec5f184a9e587ad675d34b5da518d58c083d

@ -1 +1 @@
Subproject commit 49ae834012a9875dfbc6c42206aa083b69a2aade
Subproject commit a459a4491340f33bec7b09e33750106bfab864c9

@ -1 +1 @@
Subproject commit 908adf0241bb56aa28289c3e9faaaad79cc6def6
Subproject commit a391c127b00128b81127621720d2e361c8d9070e

@ -1 +1 @@
Subproject commit 6286216e162319c049e3aa7c8435478668bb06d2
Subproject commit 2079b5f8da888eca65ef0e61d0a9438c794f2d98

View file

@ -83,7 +83,7 @@ fn make_test(file: ~str) -> TestDescAndFn {
fn run_test(file: ~str) {
let infile = ~"file://" + os::make_absolute(&Path(file)).to_str();
let res = run::process_output("./servo", [infile]);
let out = str::from_bytes(res.output);
let out = str::from_utf8(res.output);
io::print(out);
let lines: ~[&str] = out.split_iter('\n').collect();
for &line in lines.iter() {