Update Rust

This commit is contained in:
Brian Anderson 2013-08-28 15:43:47 -07:00
parent 79956abb38
commit 1026556477
43 changed files with 252 additions and 150 deletions

@ -1 +1 @@
Subproject commit 0a677bcf6e359f6f013a7e580ef467b5f389e5b7 Subproject commit c822d1070ac39871165df30ac8d09e733a6e7fb9

View file

@ -363,6 +363,7 @@ impl Font {
impl Font { impl Font {
#[fixed_stack_segment]
pub fn draw_text_into_context(&mut self, pub fn draw_text_into_context(&mut self,
rctx: &RenderContext, rctx: &RenderContext,
run: &TextRun, run: &TextRun,

View file

@ -62,6 +62,7 @@ pub struct FontHandle {
#[unsafe_destructor] #[unsafe_destructor]
impl Drop for FontHandle { impl Drop for FontHandle {
#[fixed_stack_segment]
fn drop(&self) { fn drop(&self) {
assert!(self.face.is_not_null()); assert!(self.face.is_not_null());
unsafe { unsafe {
@ -99,6 +100,7 @@ impl FontHandleMethods for FontHandle {
Err(()) => Err(()) Err(()) => Err(())
}; };
#[fixed_stack_segment]
fn create_face_from_buffer(lib: FT_Library, fn create_face_from_buffer(lib: FT_Library,
cbuf: *u8, cbuflen: uint, pt_size: float) cbuf: *u8, cbuflen: uint, pt_size: float)
-> Result<FT_Face, ()> { -> Result<FT_Face, ()> {
@ -130,12 +132,14 @@ impl FontHandleMethods for FontHandle {
fn family_name(&self) -> ~str { fn family_name(&self) -> ~str {
unsafe { str::raw::from_c_str((*self.face).family_name) } unsafe { str::raw::from_c_str((*self.face).family_name) }
} }
#[fixed_stack_segment]
fn face_name(&self) -> ~str { fn face_name(&self) -> ~str {
unsafe { str::raw::from_c_str(FT_Get_Postscript_Name(self.face)) } unsafe { str::raw::from_c_str(FT_Get_Postscript_Name(self.face)) }
} }
fn is_italic(&self) -> bool { fn is_italic(&self) -> bool {
unsafe { (*self.face).style_flags & FT_STYLE_FLAG_ITALIC != 0 } unsafe { (*self.face).style_flags & FT_STYLE_FLAG_ITALIC != 0 }
} }
#[fixed_stack_segment]
fn boldness(&self) -> CSSFontWeight { fn boldness(&self) -> CSSFontWeight {
let default_weight = FontWeight400; let default_weight = FontWeight400;
if unsafe { (*self.face).style_flags & FT_STYLE_FLAG_BOLD == 0 } { if unsafe { (*self.face).style_flags & FT_STYLE_FLAG_BOLD == 0 } {
@ -178,6 +182,7 @@ impl FontHandleMethods for FontHandle {
} }
} }
#[fixed_stack_segment]
fn glyph_index(&self, fn glyph_index(&self,
codepoint: char) -> Option<GlyphIndex> { codepoint: char) -> Option<GlyphIndex> {
assert!(self.face.is_not_null()); assert!(self.face.is_not_null());
@ -192,6 +197,7 @@ impl FontHandleMethods for FontHandle {
} }
} }
#[fixed_stack_segment]
fn glyph_h_advance(&self, fn glyph_h_advance(&self,
glyph: GlyphIndex) -> Option<FractionalPixel> { glyph: GlyphIndex) -> Option<FractionalPixel> {
assert!(self.face.is_not_null()); assert!(self.face.is_not_null());
@ -242,6 +248,7 @@ impl FontHandleMethods for FontHandle {
} }
impl<'self> FontHandle { impl<'self> FontHandle {
#[fixed_stack_segment]
fn set_char_size(face: FT_Face, pt_size: float) -> Result<(), ()>{ fn set_char_size(face: FT_Face, pt_size: float) -> Result<(), ()>{
let char_width = float_to_fixed_ft(pt_size) as FT_F26Dot6; let char_width = float_to_fixed_ft(pt_size) as FT_F26Dot6;
let char_height = float_to_fixed_ft(pt_size) as FT_F26Dot6; let char_height = float_to_fixed_ft(pt_size) as FT_F26Dot6;
@ -254,6 +261,7 @@ impl<'self> FontHandle {
} }
} }
#[fixed_stack_segment]
pub fn new_from_file(fctx: &FontContextHandle, file: ~str, pub fn new_from_file(fctx: &FontContextHandle, file: ~str,
style: &SpecifiedFontStyle) -> Result<FontHandle, ()> { style: &SpecifiedFontStyle) -> Result<FontHandle, ()> {
unsafe { unsafe {
@ -281,6 +289,7 @@ impl<'self> FontHandle {
} }
} }
#[fixed_stack_segment]
pub fn new_from_file_unstyled(fctx: &FontContextHandle, file: ~str) pub fn new_from_file_unstyled(fctx: &FontContextHandle, file: ~str)
-> Result<FontHandle, ()> { -> Result<FontHandle, ()> {
unsafe { unsafe {

View file

@ -17,6 +17,7 @@ struct FreeTypeLibraryHandle {
} }
impl Drop for FreeTypeLibraryHandle { impl Drop for FreeTypeLibraryHandle {
#[fixed_stack_segment]
fn drop(&self) { fn drop(&self) {
assert!(self.ctx.is_not_null()); assert!(self.ctx.is_not_null());
unsafe { unsafe {
@ -30,6 +31,7 @@ pub struct FontContextHandle {
} }
impl FontContextHandle { impl FontContextHandle {
#[fixed_stack_segment]
pub fn new() -> FontContextHandle { pub fn new() -> FontContextHandle {
unsafe { unsafe {
let ctx: FT_Library = ptr::null(); let ctx: FT_Library = ptr::null();

View file

@ -39,6 +39,7 @@ impl FontListHandle {
FontListHandle { fctx: fctx.clone() } FontListHandle { fctx: fctx.clone() }
} }
#[fixed_stack_segment]
pub fn get_available_families(&self) -> FontFamilyMap { pub fn get_available_families(&self) -> FontFamilyMap {
let mut family_map : FontFamilyMap = HashMap::new(); let mut family_map : FontFamilyMap = HashMap::new();
unsafe { unsafe {
@ -62,6 +63,7 @@ impl FontListHandle {
return family_map; return family_map;
} }
#[fixed_stack_segment]
pub fn load_variations_for_family(&self, family: @mut FontFamily) { pub fn load_variations_for_family(&self, family: @mut FontFamily) {
debug!("getting variations for %?", family); debug!("getting variations for %?", family);
unsafe { unsafe {
@ -138,6 +140,7 @@ struct AutoPattern {
} }
impl Drop for AutoPattern { impl Drop for AutoPattern {
#[fixed_stack_segment]
fn drop(&self) { fn drop(&self) {
unsafe { unsafe {
FcPatternDestroy(self.pattern); FcPatternDestroy(self.pattern);
@ -145,6 +148,7 @@ impl Drop for AutoPattern {
} }
} }
#[fixed_stack_segment]
pub fn path_from_identifier(name: ~str, style: &UsedFontStyle) -> Result<~str, ()> { pub fn path_from_identifier(name: ~str, style: &UsedFontStyle) -> Result<~str, ()> {
unsafe { unsafe {
let config = FcConfigGetCurrent(); let config = FcConfigGetCurrent();

View file

@ -62,6 +62,7 @@ pub struct ShapedGlyphEntry {
} }
impl ShapedGlyphData { impl ShapedGlyphData {
#[fixed_stack_segment]
pub fn new(buffer: *hb_buffer_t) -> ShapedGlyphData { pub fn new(buffer: *hb_buffer_t) -> ShapedGlyphData {
unsafe { unsafe {
let glyph_count = 0; let glyph_count = 0;
@ -142,6 +143,7 @@ pub struct Shaper {
#[unsafe_destructor] #[unsafe_destructor]
impl Drop for Shaper { impl Drop for Shaper {
#[fixed_stack_segment]
fn drop(&self) { fn drop(&self) {
unsafe { unsafe {
assert!(self.hb_face.is_not_null()); assert!(self.hb_face.is_not_null());
@ -157,6 +159,7 @@ impl Drop for Shaper {
} }
impl Shaper { impl Shaper {
#[fixed_stack_segment]
pub fn new(font: @mut Font) -> Shaper { pub fn new(font: @mut Font) -> Shaper {
unsafe { unsafe {
// Indirection for Rust Issue #6248, dynamic freeze scope artifically extended // Indirection for Rust Issue #6248, dynamic freeze scope artifically extended
@ -166,7 +169,7 @@ impl Shaper {
}; };
let hb_face: *hb_face_t = hb_face_create_for_tables(get_font_table_func, let hb_face: *hb_face_t = hb_face_create_for_tables(get_font_table_func,
font_ptr as *c_void, font_ptr as *c_void,
null()); None);
let hb_font: *hb_font_t = hb_font_create(hb_face); let hb_font: *hb_font_t = hb_font_create(hb_face);
// Set points-per-em. if zero, performs no hinting in that direction. // Set points-per-em. if zero, performs no hinting in that direction.
@ -181,9 +184,9 @@ impl Shaper {
// configure static function callbacks. // configure static function callbacks.
// NB. This funcs structure could be reused globally, as it never changes. // NB. This funcs structure could be reused globally, as it never changes.
let hb_funcs: *hb_font_funcs_t = hb_font_funcs_create(); let hb_funcs: *hb_font_funcs_t = hb_font_funcs_create();
hb_font_funcs_set_glyph_func(hb_funcs, glyph_func, null(), null()); hb_font_funcs_set_glyph_func(hb_funcs, glyph_func, null(), None);
hb_font_funcs_set_glyph_h_advance_func(hb_funcs, glyph_h_advance_func, null(), null()); hb_font_funcs_set_glyph_h_advance_func(hb_funcs, glyph_h_advance_func, null(), None);
hb_font_set_funcs(hb_font, hb_funcs, font_ptr as *c_void, null()); hb_font_set_funcs(hb_font, hb_funcs, font_ptr as *c_void, None);
Shaper { Shaper {
font: font, font: font,
@ -210,6 +213,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 /// Calculate the layout metrics associated with the given text when rendered in a specific
/// font. /// font.
#[fixed_stack_segment]
fn shape_text(&self, text: &str, glyphs: &mut GlyphStore) { fn shape_text(&self, text: &str, glyphs: &mut GlyphStore) {
unsafe { unsafe {
let hb_buffer: *hb_buffer_t = hb_buffer_create(); let hb_buffer: *hb_buffer_t = hb_buffer_create();

View file

@ -517,7 +517,7 @@ impl CompositorTask {
}; };
// Enter the main event loop. // Enter the main event loop.
let tm = Timer::new().unwrap(); let mut tm = Timer::new().unwrap();
while !done { while !done {
// Check for new messages coming from the rendering task. // Check for new messages coming from the rendering task.
check_for_messages(&self.port); check_for_messages(&self.port);

View file

@ -136,7 +136,7 @@ fn run(opts: Opts) {
let profiler_chan = profiler_chan.clone(); let profiler_chan = profiler_chan.clone();
let period = (period * 1000f) as u64; let period = (period * 1000f) as u64;
do spawn { do spawn {
let tm = Timer::new().unwrap(); let mut tm = Timer::new().unwrap();
loop { loop {
tm.sleep(period); tm.sleep(period);
profiler_chan.send(PrintMsg); profiler_chan.send(PrintMsg);

View file

@ -1947,8 +1947,8 @@ class MethodDefiner(PropertyDefiner):
decls = ''.join([stringDecl(m) for m in array]) decls = ''.join([stringDecl(m) for m in array])
return decls + self.generatePrefableArray( return decls + self.generatePrefableArray(
array, name, array, name,
' JSFunctionSpec {name: &%s_name as *u8 as *libc::c_char, call: JSNativeWrapper {op: %s, info: %s}, nargs: %s, flags: %s as u16, selfHostedName: 0 as *libc::c_char }', ' JSFunctionSpec {name: &%s_name as *u8 as *libc::c_char, call: JSNativeWrapper {op: Some(%s), info: %s}, nargs: %s, flags: %s as u16, selfHostedName: 0 as *libc::c_char }',
' JSFunctionSpec {name: 0 as *libc::c_char, call: JSNativeWrapper {op: 0 as *u8, info: 0 as *JSJitInfo}, nargs: 0, flags: 0, selfHostedName: 0 as *libc::c_char }', ' JSFunctionSpec {name: 0 as *libc::c_char, call: JSNativeWrapper {op: None, info: 0 as *JSJitInfo}, nargs: 0, flags: 0, selfHostedName: 0 as *libc::c_char }',
'JSFunctionSpec', 'JSFunctionSpec',
pref, specData, doIdArrays) pref, specData, doIdArrays)
@ -1969,16 +1969,16 @@ class AttrDefiner(PropertyDefiner):
def getter(attr): def getter(attr):
native = ("genericLenientGetter" if attr.hasLenientThis() native = ("genericLenientGetter" if attr.hasLenientThis()
else "genericGetter") else "genericGetter")
return ("JSPropertyOpWrapper {op: %(native)s, info: &%(name)s_getterinfo as *JSJitInfo}" return ("JSPropertyOpWrapper {op: Some(%(native)s), info: &%(name)s_getterinfo as *JSJitInfo}"
% {"name" : attr.identifier.name, % {"name" : attr.identifier.name,
"native" : native}) "native" : native})
def setter(attr): def setter(attr):
if attr.readonly: if attr.readonly:
return "JSStrictPropertyOpWrapper {op: 0 as *u8, info: 0 as *JSJitInfo}" return "JSStrictPropertyOpWrapper {op: None, info: 0 as *JSJitInfo}"
native = ("genericLenientSetter" if attr.hasLenientThis() native = ("genericLenientSetter" if attr.hasLenientThis()
else "genericSetter") else "genericSetter")
return ("JSStrictPropertyOpWrapper {op: %(native)s, info: &%(name)s_setterinfo as *JSJitInfo}" return ("JSStrictPropertyOpWrapper {op: Some(%(native)s), info: &%(name)s_setterinfo as *JSJitInfo}"
% {"name" : attr.identifier.name, % {"name" : attr.identifier.name,
"native" : native}) "native" : native})
@ -1996,7 +1996,7 @@ class AttrDefiner(PropertyDefiner):
return decls + self.generatePrefableArray( return decls + self.generatePrefableArray(
array, name, array, name,
' JSPropertySpec { name: &%s_name as *u8 as *libc::c_char, tinyid: 0, flags: ((%s) & 0xFF) as u8, getter: %s, setter: %s }', ' JSPropertySpec { name: &%s_name as *u8 as *libc::c_char, tinyid: 0, flags: ((%s) & 0xFF) as u8, getter: %s, setter: %s }',
' JSPropertySpec { name: 0 as *libc::c_char, tinyid: 0, flags: 0, getter: JSPropertyOpWrapper {op: 0 as *u8, info: 0 as *JSJitInfo}, setter: JSStrictPropertyOpWrapper {op: 0 as *u8, info: 0 as *JSJitInfo} }', ' JSPropertySpec { name: 0 as *libc::c_char, tinyid: 0, flags: 0, getter: JSPropertyOpWrapper {op: None, info: 0 as *JSJitInfo}, setter: JSStrictPropertyOpWrapper {op: None, info: 0 as *JSJitInfo} }',
'JSPropertySpec', 'JSPropertySpec',
PropertyDefiner.getControllingPref, specData, doIdArrays) PropertyDefiner.getControllingPref, specData, doIdArrays)
@ -2201,7 +2201,7 @@ class CGDOMJSClass(CGThing):
#return "extern DOMJSClass Class;\n" #return "extern DOMJSClass Class;\n"
return "" return ""
def define(self): def define(self):
traceHook = TRACE_HOOK_NAME if self.descriptor.customTrace else '0 as *u8' traceHook = "Some(%s)" % TRACE_HOOK_NAME if self.descriptor.customTrace else 'None'
return """ return """
static Class_name: [u8, ..%i] = %s; static Class_name: [u8, ..%i] = %s;
static Class: DOMJSClass = DOMJSClass { static Class: DOMJSClass = DOMJSClass {
@ -2214,11 +2214,11 @@ static Class: DOMJSClass = DOMJSClass {
enumerate: crust::JS_EnumerateStub, enumerate: crust::JS_EnumerateStub,
resolve: crust::JS_ResolveStub, resolve: crust::JS_ResolveStub,
convert: crust::JS_ConvertStub, convert: crust::JS_ConvertStub,
finalize: %s, /* finalize */ finalize: Some(%s), /* finalize */
checkAccess: 0 as *u8, /* checkAccess */ checkAccess: None, /* checkAccess */
call: 0 as *u8, /* call */ call: None, /* call */
hasInstance: 0 as *u8, /* hasInstance */ hasInstance: None, /* hasInstance */
construct: 0 as *u8, /* construct */ construct: None, /* construct */
trace: %s, /* trace */ trace: %s, /* trace */
reserved: (0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 05 reserved: (0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 05
0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 10 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 10
@ -2261,12 +2261,12 @@ static PrototypeClass: JSClass = JSClass {
enumerate: crust::JS_EnumerateStub, enumerate: crust::JS_EnumerateStub,
resolve: crust::JS_ResolveStub, resolve: crust::JS_ResolveStub,
convert: crust::JS_ConvertStub, convert: crust::JS_ConvertStub,
finalize: 0 as *u8, /* finalize */ finalize: None, /* finalize */
checkAccess: 0 as *u8, /* checkAccess */ checkAccess: None, /* checkAccess */
call: 0 as *u8, /* call */ call: None, /* call */
hasInstance: 0 as *u8, /* hasInstance */ hasInstance: None, /* hasInstance */
construct: 0 as *u8, /* construct */ construct: None, /* construct */
trace: 0 as *u8, /* trace */ trace: None, /* trace */
reserved: (0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 05 reserved: (0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 05
0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 10 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 10
0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 15 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, 0 as *libc::c_void, // 15
@ -2402,12 +2402,16 @@ class CGAbstractMethod(CGThing):
def _decorators(self): def _decorators(self):
decorators = [] decorators = []
if self.alwaysInline: if self.alwaysInline:
decorators.append('#[inline(always)]') # FIXME Rust #8801 #[inline(always)] and #[fixed_stack_segment] not compatible
# decorators.append('#[inline(always)]')
pass
elif self.inline: elif self.inline:
#decorators.append('inline') #decorators.append('inline')
pass pass
if self.extern: if self.extern:
decorators.append('extern') decorators.append('extern')
if not self.extern:
decorators.append('#[fixed_stack_segment]')
if self.static: if self.static:
#decorators.append('static') #decorators.append('static')
pass pass
@ -2696,7 +2700,7 @@ class CGCreateInterfaceObjectsMethod(CGAbstractMethod):
%s);""" % ( %s);""" % (
"&PrototypeClass" if needInterfacePrototypeObject else "ptr::null()", "&PrototypeClass" if needInterfacePrototypeObject else "ptr::null()",
"&InterfaceObjectClass" if needInterfaceObjectClass else "ptr::null()", "&InterfaceObjectClass" if needInterfaceObjectClass else "ptr::null()",
constructHook if needConstructor else "ptr::null()", "Some(%s)" % constructHook if needConstructor else "None",
constructArgs, constructArgs,
domClass, domClass,
arrayPtr("methods"), arrayPtr("attrs"), arrayPtr("methods"), arrayPtr("attrs"),
@ -3171,13 +3175,13 @@ class CGGenericMethod(CGAbstractBindingMethod):
""" """
def __init__(self, descriptor): def __init__(self, descriptor):
args = [Argument('*JSContext', 'cx'), Argument('libc::c_uint', 'argc'), args = [Argument('*JSContext', 'cx'), Argument('libc::c_uint', 'argc'),
Argument('*JSVal', 'vp')] Argument('*mut JSVal', 'vp')]
CGAbstractBindingMethod.__init__(self, descriptor, 'genericMethod', args) CGAbstractBindingMethod.__init__(self, descriptor, 'genericMethod', args)
def generate_code(self): def generate_code(self):
return CGIndenter(CGGeneric( return CGIndenter(CGGeneric(
"let _info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, vp));\n" "let _info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, &*vp));\n"
"return CallJitMethodOp(_info, cx, obj, this as *libc::c_void, argc, vp);")) "return CallJitMethodOp(_info, cx, obj, this as *libc::c_void, argc, &*vp);"))
class CGAbstractStaticMethod(CGAbstractMethod): class CGAbstractStaticMethod(CGAbstractMethod):
""" """
@ -3224,8 +3228,8 @@ class CGGenericGetter(CGAbstractBindingMethod):
A class for generating the C++ code for an IDL attribute getter. A class for generating the C++ code for an IDL attribute getter.
""" """
def __init__(self, descriptor, lenientThis=False): def __init__(self, descriptor, lenientThis=False):
args = [Argument('*JSContext', 'cx'), Argument('uint', 'argc'), args = [Argument('*JSContext', 'cx'), Argument('libc::c_uint', 'argc'),
Argument('*JSVal', 'vp')] Argument('*mut JSVal', 'vp')]
if lenientThis: if lenientThis:
name = "genericLenientGetter" name = "genericLenientGetter"
unwrapFailureCode = ( unwrapFailureCode = (
@ -3240,8 +3244,8 @@ class CGGenericGetter(CGAbstractBindingMethod):
def generate_code(self): def generate_code(self):
return CGIndenter(CGGeneric( return CGIndenter(CGGeneric(
"let info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, vp));\n" "let info: *JSJitInfo = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, &*vp));\n"
"return CallJitPropertyOp(info, cx, obj, this as *libc::c_void, vp);")) "return CallJitPropertyOp(info, cx, obj, this as *libc::c_void, &*vp);"))
class CGSpecializedGetter(CGAbstractExternMethod): class CGSpecializedGetter(CGAbstractExternMethod):
""" """
@ -3279,7 +3283,7 @@ class CGGenericSetter(CGAbstractBindingMethod):
A class for generating the Rust code for an IDL attribute setter. A class for generating the Rust code for an IDL attribute setter.
""" """
def __init__(self, descriptor, lenientThis=False): def __init__(self, descriptor, lenientThis=False):
args = [Argument('*JSContext', 'cx'), Argument('uint', 'argc'), args = [Argument('*JSContext', 'cx'), Argument('libc::c_uint', 'argc'),
Argument('*mut JSVal', 'vp')] Argument('*mut JSVal', 'vp')]
if lenientThis: if lenientThis:
name = "genericLenientSetter" name = "genericLenientSetter"
@ -3357,7 +3361,7 @@ class CGMemberJITInfo(CGThing):
failstr = "true" if infallible else "false" failstr = "true" if infallible else "false"
return ("\n" return ("\n"
"static %s: JSJitInfo = JSJitInfo {\n" "static %s: JSJitInfo = JSJitInfo {\n"
" op: %s,\n" " op: %s as *u8,\n"
" protoID: %s,\n" " protoID: %s,\n"
" depth: %s,\n" " depth: %s,\n"
" isInfallible: %s, /* False in setters. */\n" " isInfallible: %s, /* False in setters. */\n"
@ -4388,6 +4392,7 @@ class CGDictionary(CGThing):
" return true;\n" " return true;\n"
" }\n" " }\n"
"\n" if not self.workers else "") + "\n" if not self.workers else "") +
" #[fixed_stack_segment]\n" +
" pub fn Init(&mut self, cx: *JSContext, val: JSVal) -> JSBool {\n" " pub fn Init(&mut self, cx: *JSContext, val: JSVal) -> JSBool {\n"
" unsafe {\n" + " unsafe {\n" +
# NOTE: jsids are per-runtime, so don't use them in workers # NOTE: jsids are per-runtime, so don't use them in workers

View file

@ -12,12 +12,14 @@ pub trait JSValConvertible {
} }
impl JSValConvertible for u32 { impl JSValConvertible for u32 {
#[fixed_stack_segment]
fn to_jsval(&self) -> JSVal { fn to_jsval(&self) -> JSVal {
unsafe { unsafe {
RUST_UINT_TO_JSVAL(*self) RUST_UINT_TO_JSVAL(*self)
} }
} }
#[fixed_stack_segment]
fn from_jsval(val: JSVal) -> Option<u32> { fn from_jsval(val: JSVal) -> Option<u32> {
unsafe { unsafe {
Some(RUST_JSVAL_TO_INT(val) as u32) Some(RUST_JSVAL_TO_INT(val) as u32)
@ -26,12 +28,14 @@ impl JSValConvertible for u32 {
} }
impl JSValConvertible for i32 { impl JSValConvertible for i32 {
#[fixed_stack_segment]
fn to_jsval(&self) -> JSVal { fn to_jsval(&self) -> JSVal {
unsafe { unsafe {
RUST_UINT_TO_JSVAL(*self as u32) RUST_UINT_TO_JSVAL(*self as u32)
} }
} }
#[fixed_stack_segment]
fn from_jsval(val: JSVal) -> Option<i32> { fn from_jsval(val: JSVal) -> Option<i32> {
unsafe { unsafe {
Some(RUST_JSVAL_TO_INT(val) as i32) Some(RUST_JSVAL_TO_INT(val) as i32)
@ -40,12 +44,14 @@ impl JSValConvertible for i32 {
} }
impl JSValConvertible for u16 { impl JSValConvertible for u16 {
#[fixed_stack_segment]
fn to_jsval(&self) -> JSVal { fn to_jsval(&self) -> JSVal {
unsafe { unsafe {
RUST_UINT_TO_JSVAL(*self as u32) RUST_UINT_TO_JSVAL(*self as u32)
} }
} }
#[fixed_stack_segment]
fn from_jsval(val: JSVal) -> Option<u16> { fn from_jsval(val: JSVal) -> Option<u16> {
unsafe { unsafe {
Some(RUST_JSVAL_TO_INT(val) as u16) Some(RUST_JSVAL_TO_INT(val) as u16)
@ -74,12 +80,14 @@ impl JSValConvertible for bool {
} }
impl JSValConvertible for f32 { impl JSValConvertible for f32 {
#[fixed_stack_segment]
fn to_jsval(&self) -> JSVal { fn to_jsval(&self) -> JSVal {
unsafe { unsafe {
RUST_DOUBLE_TO_JSVAL(*self as f64) RUST_DOUBLE_TO_JSVAL(*self as f64)
} }
} }
#[fixed_stack_segment]
fn from_jsval(val: JSVal) -> Option<f32> { fn from_jsval(val: JSVal) -> Option<f32> {
unsafe { unsafe {
Some(RUST_JSVAL_TO_DOUBLE(val) as f32) Some(RUST_JSVAL_TO_DOUBLE(val) as f32)
@ -88,12 +96,14 @@ impl JSValConvertible for f32 {
} }
impl JSValConvertible for f64 { impl JSValConvertible for f64 {
#[fixed_stack_segment]
fn to_jsval(&self) -> JSVal { fn to_jsval(&self) -> JSVal {
unsafe { unsafe {
RUST_DOUBLE_TO_JSVAL(*self as f64) RUST_DOUBLE_TO_JSVAL(*self as f64)
} }
} }
#[fixed_stack_segment]
fn from_jsval(val: JSVal) -> Option<f64> { fn from_jsval(val: JSVal) -> Option<f64> {
unsafe { unsafe {
Some(RUST_JSVAL_TO_DOUBLE(val) as f64) Some(RUST_JSVAL_TO_DOUBLE(val) as f64)

View file

@ -34,6 +34,7 @@ impl DerivedWrapper for DOMParser {
fail!(~"nyi") fail!(~"nyi")
} }
#[fixed_stack_segment]
fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 { fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 {
let obj = self.wrap_object_shared(cx, scope); let obj = self.wrap_object_shared(cx, scope);
if obj.is_null() { if obj.is_null() {

View file

@ -42,6 +42,7 @@ extern fn finalize(_fop: *JSFreeOp, obj: *JSObject) {
pub extern fn trace(tracer: *mut JSTracer, obj: *JSObject) { pub extern fn trace(tracer: *mut JSTracer, obj: *JSObject) {
let node = unsafe { unwrap(obj) }; let node = unsafe { unwrap(obj) };
#[fixed_stack_segment]
fn trace_node(tracer: *mut JSTracer, node: Option<AbstractNode<ScriptView>>, name: &str) { fn trace_node(tracer: *mut JSTracer, node: Option<AbstractNode<ScriptView>>, name: &str) {
if node.is_none() { if node.is_none() {
return; return;
@ -68,6 +69,7 @@ pub extern fn trace(tracer: *mut JSTracer, obj: *JSObject) {
trace_node(tracer, node.prev_sibling(), "prev sibling"); trace_node(tracer, node.prev_sibling(), "prev sibling");
} }
#[fixed_stack_segment]
pub fn init(compartment: @mut Compartment) { pub fn init(compartment: @mut Compartment) {
let obj = utils::define_empty_prototype(~"Element", Some(~"Node"), compartment); let obj = utils::define_empty_prototype(~"Element", Some(~"Node"), compartment);
let attrs = @~[ let attrs = @~[
@ -75,14 +77,14 @@ pub fn init(compartment: @mut Compartment) {
name: compartment.add_name(~"tagName"), name: compartment.add_name(~"tagName"),
tinyid: 0, tinyid: 0,
flags: (JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_ENUMERATE | JSPROP_SHARED | JSPROP_NATIVE_ACCESSORS) as u8,
getter: JSPropertyOpWrapper {op: getTagName, info: null()}, getter: JSPropertyOpWrapper {op: Some(getTagName), info: null()},
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}, setter: JSStrictPropertyOpWrapper {op: None, info: null()}},
JSPropertySpec { JSPropertySpec {
name: null(), name: null(),
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: JSPropertyOpWrapper {op: null(), info: null()}, getter: JSPropertyOpWrapper {op: None, info: null()},
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}]; setter: JSStrictPropertyOpWrapper {op: None, info: null()}}];
compartment.global_props.push(attrs); compartment.global_props.push(attrs);
do attrs.as_imm_buf |specs, _len| { do attrs.as_imm_buf |specs, _len| {
unsafe { unsafe {
@ -91,22 +93,22 @@ pub fn init(compartment: @mut Compartment) {
} }
let methods = @~[JSFunctionSpec {name: compartment.add_name(~"getClientRects"), let methods = @~[JSFunctionSpec {name: compartment.add_name(~"getClientRects"),
call: JSNativeWrapper {op: getClientRects, info: null()}, call: JSNativeWrapper {op: Some(getClientRects), info: null()},
nargs: 0, nargs: 0,
flags: 0, flags: 0,
selfHostedName: null()}, selfHostedName: null()},
JSFunctionSpec {name: compartment.add_name(~"getBoundingClientRect"), JSFunctionSpec {name: compartment.add_name(~"getBoundingClientRect"),
call: JSNativeWrapper {op: getBoundingClientRect, info: null()}, call: JSNativeWrapper {op: Some(getBoundingClientRect), info: null()},
nargs: 0, nargs: 0,
flags: 0, flags: 0,
selfHostedName: null()}, selfHostedName: null()},
JSFunctionSpec {name: compartment.add_name(~"setAttribute"), JSFunctionSpec {name: compartment.add_name(~"setAttribute"),
call: JSNativeWrapper {op: setAttribute, info: null()}, call: JSNativeWrapper {op: Some(setAttribute), info: null()},
nargs: 0, nargs: 0,
flags: 0, flags: 0,
selfHostedName: null()}, selfHostedName: null()},
JSFunctionSpec {name: null(), JSFunctionSpec {name: null(),
call: JSNativeWrapper {op: null(), info: null()}, call: JSNativeWrapper {op: None, info: null()},
nargs: 0, nargs: 0,
flags: 0, flags: 0,
selfHostedName: null()}]; selfHostedName: null()}];
@ -129,13 +131,13 @@ pub fn init(compartment: @mut Compartment) {
JSPropertySpec {name: compartment.add_name(~"width"), JSPropertySpec {name: compartment.add_name(~"width"),
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: JSPropertyOpWrapper {op: HTMLImageElement_getWidth, info: null()}, getter: JSPropertyOpWrapper {op: Some(HTMLImageElement_getWidth), info: null()},
setter: JSStrictPropertyOpWrapper {op: HTMLImageElement_setWidth, info: null()}}, setter: JSStrictPropertyOpWrapper {op: Some(HTMLImageElement_setWidth), info: null()}},
JSPropertySpec {name: null(), JSPropertySpec {name: null(),
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: JSPropertyOpWrapper {op: null(), info: null()}, getter: JSPropertyOpWrapper {op: None, info: null()},
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}]; setter: JSStrictPropertyOpWrapper {op: None, info: null()}}];
compartment.global_props.push(attrs); compartment.global_props.push(attrs);
do attrs.as_imm_buf |specs, _len| { do attrs.as_imm_buf |specs, _len| {
unsafe { unsafe {
@ -144,7 +146,7 @@ pub fn init(compartment: @mut Compartment) {
} }
} }
extern fn getClientRects(cx: *JSContext, _argc: c_uint, vp: *JSVal) -> JSBool { extern fn getClientRects(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBool {
unsafe { unsafe {
let obj = JS_THIS_OBJECT(cx, vp); let obj = JS_THIS_OBJECT(cx, vp);
let mut node = unwrap(obj); let mut node = unwrap(obj);
@ -160,7 +162,7 @@ extern fn getClientRects(cx: *JSContext, _argc: c_uint, vp: *JSVal) -> JSBool {
} }
} }
extern fn getBoundingClientRect(cx: *JSContext, _argc: c_uint, vp: *JSVal) -> JSBool { extern fn getBoundingClientRect(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBool {
unsafe { unsafe {
let obj = JS_THIS_OBJECT(cx, vp); let obj = JS_THIS_OBJECT(cx, vp);
let mut node = unwrap(obj); let mut node = unwrap(obj);
@ -176,7 +178,7 @@ extern fn getBoundingClientRect(cx: *JSContext, _argc: c_uint, vp: *JSVal) -> JS
} }
} }
extern fn setAttribute(cx: *JSContext, argc: c_uint, vp: *JSVal) -> JSBool { extern fn setAttribute(cx: *JSContext, argc: c_uint, vp: *mut JSVal) -> JSBool {
unsafe { unsafe {
let obj = JS_THIS_OBJECT(cx, vp); let obj = JS_THIS_OBJECT(cx, vp);
let node = unwrap(obj); let node = unwrap(obj);
@ -278,6 +280,7 @@ extern fn getTagName(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBool {
return 1; return 1;
} }
#[fixed_stack_segment]
pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> jsobj { pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> jsobj {
let proto = match node.type_id() { let proto = match node.type_id() {
ElementNodeTypeId(HTMLDivElementTypeId) => ~"HTMLDivElement", ElementNodeTypeId(HTMLDivElementTypeId) => ~"HTMLDivElement",

View file

@ -85,6 +85,7 @@ use js::{JSPROP_ENUMERATE, JSPROP_SHARED, JSVAL_NULL};
use js::{JS_THIS_OBJECT, JSPROP_NATIVE_ACCESSORS}; use js::{JS_THIS_OBJECT, JSPROP_NATIVE_ACCESSORS};
use servo_util::tree::TreeNodeRef; use servo_util::tree::TreeNodeRef;
#[fixed_stack_segment]
pub fn init(compartment: @mut Compartment) { pub fn init(compartment: @mut Compartment) {
let obj = utils::define_empty_prototype(~"Node", None, compartment); let obj = utils::define_empty_prototype(~"Node", None, compartment);
@ -93,29 +94,29 @@ pub fn init(compartment: @mut Compartment) {
name: compartment.add_name(~"firstChild"), name: compartment.add_name(~"firstChild"),
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: JSPropertyOpWrapper {op: getFirstChild, info: null()}, getter: JSPropertyOpWrapper {op: Some(getFirstChild), info: null()},
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}, setter: JSStrictPropertyOpWrapper {op: None, info: null()}},
JSPropertySpec { JSPropertySpec {
name: compartment.add_name(~"nextSibling"), name: compartment.add_name(~"nextSibling"),
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: JSPropertyOpWrapper {op: getNextSibling, info: null()}, getter: JSPropertyOpWrapper {op: Some(getNextSibling), info: null()},
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}, setter: JSStrictPropertyOpWrapper {op: None, info: null()}},
JSPropertySpec { JSPropertySpec {
name: compartment.add_name(~"nodeType"), name: compartment.add_name(~"nodeType"),
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: JSPropertyOpWrapper {op: getNodeType, info: null()}, getter: JSPropertyOpWrapper {op: Some(getNodeType), info: null()},
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}, setter: JSStrictPropertyOpWrapper {op: None, info: null()}},
JSPropertySpec { JSPropertySpec {
name: null(), name: null(),
tinyid: 0, tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8, flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: JSPropertyOpWrapper {op: null(), info: null()}, getter: JSPropertyOpWrapper {op: None, info: null()},
setter: JSStrictPropertyOpWrapper {op: null(), info: null()}}]; setter: JSStrictPropertyOpWrapper {op: None, info: null()}}];
compartment.global_props.push(attrs); compartment.global_props.push(attrs);
do attrs.as_imm_buf |specs, _len| { do attrs.as_imm_buf |specs, _len| {
unsafe { unsafe {

View file

@ -47,7 +47,7 @@ pub extern fn getPropertyDescriptor(cx: *JSContext, proxy: *JSObject, id: jsid,
pub extern fn defineProperty(cx: *JSContext, proxy: *JSObject, id: jsid, pub extern fn defineProperty(cx: *JSContext, proxy: *JSObject, id: jsid,
desc: *JSPropertyDescriptor) -> JSBool { desc: *JSPropertyDescriptor) -> JSBool {
unsafe { unsafe {
if ((*desc).attrs & JSPROP_GETTER) != 0 && (*desc).setter == JS_StrictPropertyStub { if ((*desc).attrs & JSPROP_GETTER) != 0 && (*desc).setter == Some(JS_StrictPropertyStub) {
/*return JS_ReportErrorFlagsAndNumber(cx, /*return JS_ReportErrorFlagsAndNumber(cx,
JSREPORT_WARNING | JSREPORT_STRICT | JSREPORT_WARNING | JSREPORT_STRICT |
JSREPORT_STRICT_MODE_ERROR, JSREPORT_STRICT_MODE_ERROR,
@ -66,6 +66,7 @@ pub extern fn defineProperty(cx: *JSContext, proxy: *JSObject, id: jsid,
} }
} }
#[fixed_stack_segment]
pub fn _obj_toString(cx: *JSContext, className: *libc::c_char) -> *JSString { pub fn _obj_toString(cx: *JSContext, className: *libc::c_char) -> *JSString {
unsafe { unsafe {
let name = str::raw::from_c_str(className); let name = str::raw::from_c_str(className);
@ -88,6 +89,7 @@ pub fn _obj_toString(cx: *JSContext, className: *libc::c_char) -> *JSString {
} }
} }
#[fixed_stack_segment]
pub fn GetExpandoObject(obj: *JSObject) -> *JSObject { pub fn GetExpandoObject(obj: *JSObject) -> *JSObject {
unsafe { unsafe {
assert!(is_dom_proxy(obj)); assert!(is_dom_proxy(obj));
@ -100,6 +102,7 @@ pub fn GetExpandoObject(obj: *JSObject) -> *JSObject {
} }
} }
#[fixed_stack_segment]
pub fn EnsureExpandoObject(cx: *JSContext, obj: *JSObject) -> *JSObject { pub fn EnsureExpandoObject(cx: *JSContext, obj: *JSObject) -> *JSObject {
unsafe { unsafe {
assert!(is_dom_proxy(obj)); assert!(is_dom_proxy(obj));
@ -120,7 +123,7 @@ pub fn EnsureExpandoObject(cx: *JSContext, obj: *JSObject) -> *JSObject {
pub fn FillPropertyDescriptor(desc: &mut JSPropertyDescriptor, obj: *JSObject, readonly: bool) { pub fn FillPropertyDescriptor(desc: &mut JSPropertyDescriptor, obj: *JSObject, readonly: bool) {
desc.obj = obj; desc.obj = obj;
desc.attrs = if readonly { JSPROP_READONLY } else { 0 } | JSPROP_ENUMERATE; desc.attrs = if readonly { JSPROP_READONLY } else { 0 } | JSPROP_ENUMERATE;
desc.getter = ptr::null(); desc.getter = None;
desc.setter = ptr::null(); desc.setter = None;
desc.shortid = 0; desc.shortid = 0;
} }

View file

@ -67,6 +67,7 @@ pub fn init(compartment: @mut Compartment) {
} }
#[fixed_stack_segment]
pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> jsobj { pub fn create(cx: *JSContext, node: &mut AbstractNode<ScriptView>) -> jsobj {
let (proto, instance) = match node.type_id() { let (proto, instance) = match node.type_id() {
TextNodeTypeId => (~"TextPrototype", ~"Text"), TextNodeTypeId => (~"TextPrototype", ~"Text"),

View file

@ -8,7 +8,9 @@ use dom::bindings::node;
use dom::node::{AbstractNode, ScriptView}; use dom::node::{AbstractNode, ScriptView};
use script_task::page_from_context; use script_task::page_from_context;
use std::libc::c_uint;
use std::cast; use std::cast;
use std::cell::Cell;
use std::hashmap::HashMap; use std::hashmap::HashMap;
use std::libc; use std::libc;
use std::ptr; use std::ptr;
@ -29,6 +31,8 @@ use js::jsapi::{JS_NewStringCopyN, JS_DefineFunctions, JS_DefineProperty};
use js::jsapi::{JS_ValueToString, JS_GetReservedSlot, JS_SetReservedSlot}; use js::jsapi::{JS_ValueToString, JS_GetReservedSlot, JS_SetReservedSlot};
use js::jsapi::{JSContext, JSObject, JSBool, jsid, JSClass, JSNative}; use js::jsapi::{JSContext, JSObject, JSBool, jsid, JSClass, JSNative};
use js::jsapi::{JSFunctionSpec, JSPropertySpec, JSVal, JSPropertyDescriptor}; use js::jsapi::{JSFunctionSpec, JSPropertySpec, JSVal, JSPropertyDescriptor};
use js::jsapi::{JSFreeOp, JSTracer};
use js::jsapi::{JSPropertyOp, JSStrictPropertyOp, JSEnumerateOp, JSResolveOp, JSConvertOp};
use js::jsfriendapi::bindgen::JS_NewObjectWithUniqueType; use js::jsfriendapi::bindgen::JS_NewObjectWithUniqueType;
use js::rust::Compartment; use js::rust::Compartment;
use js::{JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSVAL_NULL}; use js::{JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSVAL_NULL};
@ -56,7 +60,7 @@ pub fn GlobalStaticData() -> GlobalStaticData {
} }
} }
extern fn InterfaceObjectToString(cx: *JSContext, _argc: uint, vp: *mut JSVal) -> JSBool { extern fn InterfaceObjectToString(cx: *JSContext, _argc: c_uint, vp: *mut JSVal) -> JSBool {
unsafe { unsafe {
let callee = RUST_JSVAL_TO_OBJECT(*JS_CALLEE(cx, cast::transmute(&vp))); let callee = RUST_JSVAL_TO_OBJECT(*JS_CALLEE(cx, cast::transmute(&vp)));
let obj = JS_THIS_OBJECT(cx, cast::transmute(&vp)); let obj = JS_THIS_OBJECT(cx, cast::transmute(&vp));
@ -126,6 +130,7 @@ fn is_dom_class(clasp: *JSClass) -> bool {
} }
} }
#[fixed_stack_segment]
pub fn is_dom_proxy(obj: *JSObject) -> bool { pub fn is_dom_proxy(obj: *JSObject) -> bool {
unsafe { unsafe {
(js_IsObjectProxyClass(obj) || js_IsFunctionProxyClass(obj)) && (js_IsObjectProxyClass(obj) || js_IsFunctionProxyClass(obj)) &&
@ -133,6 +138,7 @@ pub fn is_dom_proxy(obj: *JSObject) -> bool {
} }
} }
#[fixed_stack_segment]
pub unsafe fn unwrap<T>(obj: *JSObject) -> T { pub unsafe fn unwrap<T>(obj: *JSObject) -> T {
let clasp = JS_GetClass(obj); let clasp = JS_GetClass(obj);
let slot = if is_dom_class(clasp) { let slot = if is_dom_class(clasp) {
@ -145,6 +151,7 @@ pub unsafe fn unwrap<T>(obj: *JSObject) -> T {
cast::transmute(RUST_JSVAL_TO_PRIVATE(val)) cast::transmute(RUST_JSVAL_TO_PRIVATE(val))
} }
#[fixed_stack_segment]
pub unsafe fn get_dom_class(obj: *JSObject) -> Result<DOMClass, ()> { pub unsafe fn get_dom_class(obj: *JSObject) -> Result<DOMClass, ()> {
let clasp = JS_GetClass(obj); let clasp = JS_GetClass(obj);
if is_dom_class(clasp) { if is_dom_class(clasp) {
@ -175,6 +182,7 @@ pub fn unwrap_object<T>(obj: *JSObject, proto_id: PrototypeList::id::ID, proto_d
} }
} }
#[fixed_stack_segment]
pub fn unwrap_value<T>(val: *JSVal, proto_id: PrototypeList::id::ID, proto_depth: uint) -> Result<T, ()> { pub fn unwrap_value<T>(val: *JSVal, proto_id: PrototypeList::id::ID, proto_depth: uint) -> Result<T, ()> {
unsafe { unsafe {
let obj = RUST_JSVAL_TO_OBJECT(*val); let obj = RUST_JSVAL_TO_OBJECT(*val);
@ -189,6 +197,7 @@ pub unsafe fn squirrel_away<T>(x: @mut T) -> *rust_box<T> {
} }
//XXX very incomplete //XXX very incomplete
#[fixed_stack_segment]
pub fn jsval_to_str(cx: *JSContext, v: JSVal) -> Result<~str, ()> { pub fn jsval_to_str(cx: *JSContext, v: JSVal) -> Result<~str, ()> {
unsafe { unsafe {
let jsstr; let jsstr;
@ -208,6 +217,7 @@ pub fn jsval_to_str(cx: *JSContext, v: JSVal) -> Result<~str, ()> {
} }
} }
#[fixed_stack_segment]
pub unsafe fn domstring_to_jsval(cx: *JSContext, string: &DOMString) -> JSVal { pub unsafe fn domstring_to_jsval(cx: *JSContext, string: &DOMString) -> JSVal {
match string { match string {
&null_string => { &null_string => {
@ -249,24 +259,28 @@ extern fn has_instance(_cx: *JSContext, obj: **JSObject, v: *JSVal, bp: *mut JSB
} }
pub fn prototype_jsclass(name: ~str) -> @fn(compartment: @mut Compartment) -> JSClass { pub fn prototype_jsclass(name: ~str) -> @fn(compartment: @mut Compartment) -> JSClass {
let name = Cell::new(name);
let f: @fn(@mut Compartment) -> JSClass = |compartment: @mut Compartment| { let f: @fn(@mut Compartment) -> JSClass = |compartment: @mut Compartment| {
let name = name.take();
#[fixed_stack_segment]
fn just_effin_do_it(name: ~str, compartment: @mut Compartment) -> JSClass {
unsafe { unsafe {
JSClass { JSClass {
name: compartment.add_name(name.to_owned()), name: compartment.add_name(name.to_owned()),
flags: 0, flags: 0,
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp,
delProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, delProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp,
getProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, getProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp,
setProperty: GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as *u8, setProperty: GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as JSStrictPropertyOp,
enumerate: GetJSClassHookStubPointer(ENUMERATE_STUB) as *u8, enumerate: GetJSClassHookStubPointer(ENUMERATE_STUB) as JSEnumerateOp,
resolve: GetJSClassHookStubPointer(RESOLVE_STUB) as *u8, resolve: GetJSClassHookStubPointer(RESOLVE_STUB) as JSResolveOp,
convert: GetJSClassHookStubPointer(CONVERT_STUB) as *u8, convert: GetJSClassHookStubPointer(CONVERT_STUB) as JSConvertOp,
finalize: null(), finalize: None,
checkAccess: null(), checkAccess: None,
call: null(), call: None,
hasInstance: has_instance, hasInstance: Some(has_instance),
construct: null(), construct: None,
trace: null(), trace: None,
reserved: (null(), null(), null(), null(), null(), // 05 reserved: (null(), null(), null(), null(), null(), // 05
null(), null(), null(), null(), null(), // 10 null(), null(), null(), null(), null(), // 10
null(), null(), null(), null(), null(), // 15 null(), null(), null(), null(), null(), // 15
@ -277,30 +291,40 @@ pub fn prototype_jsclass(name: ~str) -> @fn(compartment: @mut Compartment) -> JS
null(), null(), null(), null(), null()) // 40 null(), null(), null(), null(), null()) // 40
} }
} }
}
just_effin_do_it(name, compartment)
}; };
return f; return f;
} }
pub fn instance_jsclass(name: ~str, finalize: *u8, trace: *u8) pub fn instance_jsclass(name: ~str, finalize: extern "C" fn(*JSFreeOp, *JSObject),
trace: extern "C" fn(*mut JSTracer, *JSObject))
-> @fn(compartment: @mut Compartment) -> JSClass { -> @fn(compartment: @mut Compartment) -> JSClass {
let name = Cell::new(name);
let f: @fn(@mut Compartment) -> JSClass = |compartment: @mut Compartment| { let f: @fn(@mut Compartment) -> JSClass = |compartment: @mut Compartment| {
let name = name.take();
#[fixed_stack_segment]
fn just_effin_do_it(name: ~str, finalize: extern "C" fn(*JSFreeOp, *JSObject),
trace: extern "C" fn(*mut JSTracer, *JSObject),
compartment: @mut Compartment) -> JSClass {
unsafe { unsafe {
JSClass { JSClass {
name: compartment.add_name(name.to_owned()), name: compartment.add_name(name.to_owned()),
flags: JSCLASS_HAS_RESERVED_SLOTS(1) | js::JSCLASS_IS_DOMJSCLASS, flags: JSCLASS_HAS_RESERVED_SLOTS(1) | js::JSCLASS_IS_DOMJSCLASS,
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp,
delProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, delProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp,
getProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, getProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp,
setProperty: GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as *u8, setProperty: GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as JSStrictPropertyOp,
enumerate: GetJSClassHookStubPointer(ENUMERATE_STUB) as *u8, enumerate: GetJSClassHookStubPointer(ENUMERATE_STUB) as JSEnumerateOp,
resolve: GetJSClassHookStubPointer(RESOLVE_STUB) as *u8, resolve: GetJSClassHookStubPointer(RESOLVE_STUB) as JSResolveOp,
convert: GetJSClassHookStubPointer(CONVERT_STUB) as *u8, convert: GetJSClassHookStubPointer(CONVERT_STUB) as JSConvertOp,
finalize: finalize, finalize: Some(finalize),
checkAccess: null(), checkAccess: None,
call: null(), call: None,
hasInstance: has_instance, hasInstance: Some(has_instance),
construct: null(), construct: None,
trace: trace, trace: Some(trace),
reserved: (null(), null(), null(), null(), null(), // 05 reserved: (null(), null(), null(), null(), null(), // 05
null(), null(), null(), null(), null(), // 10 null(), null(), null(), null(), null(), // 10
null(), null(), null(), null(), null(), // 15 null(), null(), null(), null(), null(), // 15
@ -311,10 +335,14 @@ pub fn instance_jsclass(name: ~str, finalize: *u8, trace: *u8)
null(), null(), null(), null(), null()) // 40 null(), null(), null(), null(), null()) // 40
} }
} }
}
just_effin_do_it(name, finalize, trace, compartment)
}; };
return f; return f;
} }
#[fixed_stack_segment]
pub fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: @mut Compartment) pub fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: @mut Compartment)
-> js::rust::jsobj { -> js::rust::jsobj {
compartment.register_class(prototype_jsclass(name.to_owned())); compartment.register_class(prototype_jsclass(name.to_owned()));
@ -330,8 +358,8 @@ pub fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: @mut
unsafe { unsafe {
compartment.define_property(name.to_owned(), RUST_OBJECT_TO_JSVAL(obj.ptr), compartment.define_property(name.to_owned(), RUST_OBJECT_TO_JSVAL(obj.ptr),
GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp,
GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as *u8, GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as JSStrictPropertyOp,
JSPROP_ENUMERATE); JSPROP_ENUMERATE);
compartment.stash_global_proto(name, obj); compartment.stash_global_proto(name, obj);
return obj; return obj;
@ -379,7 +407,7 @@ pub struct NativeProperties {
pub struct NativePropertyHooks { pub struct NativePropertyHooks {
resolve_own_property: *u8, resolve_own_property: *u8,
resolve_property: *u8, resolve_property: extern "C" fn(*JSContext, *JSObject, jsid, bool, *mut JSPropertyDescriptor) -> bool,
enumerate_own_properties: *u8, enumerate_own_properties: *u8,
enumerate_properties: *u8, enumerate_properties: *u8,
proto_hooks: *NativePropertyHooks proto_hooks: *NativePropertyHooks
@ -420,6 +448,7 @@ pub struct DOMJSClass {
dom_class: DOMClass dom_class: DOMClass
} }
#[fixed_stack_segment]
pub fn GetProtoOrIfaceArray(global: *JSObject) -> **JSObject { pub fn GetProtoOrIfaceArray(global: *JSObject) -> **JSObject {
unsafe { unsafe {
/*assert ((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0;*/ /*assert ((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0;*/
@ -427,9 +456,10 @@ pub fn GetProtoOrIfaceArray(global: *JSObject) -> **JSObject {
} }
} }
#[fixed_stack_segment]
pub fn CreateInterfaceObjects2(cx: *JSContext, global: *JSObject, receiver: *JSObject, pub fn CreateInterfaceObjects2(cx: *JSContext, global: *JSObject, receiver: *JSObject,
protoProto: *JSObject, protoClass: *JSClass, protoProto: *JSObject, protoClass: *JSClass,
constructorClass: *JSClass, constructor: JSNative, constructorClass: *JSClass, constructor: Option<JSNative>,
ctorNargs: u32, ctorNargs: u32,
domClass: *DOMClass, domClass: *DOMClass,
methods: *JSFunctionSpec, methods: *JSFunctionSpec,
@ -453,7 +483,7 @@ pub fn CreateInterfaceObjects2(cx: *JSContext, global: *JSObject, receiver: *JSO
} }
let mut interface = ptr::null(); let mut interface = ptr::null();
if constructorClass.is_not_null() || constructor.is_not_null() { if constructorClass.is_not_null() || constructor.is_some() {
interface = do name.to_c_str().with_ref |s| { interface = do name.to_c_str().with_ref |s| {
CreateInterfaceObject(cx, global, receiver, constructorClass, CreateInterfaceObject(cx, global, receiver, constructorClass,
constructor, ctorNargs, proto, constructor, ctorNargs, proto,
@ -471,8 +501,9 @@ pub fn CreateInterfaceObjects2(cx: *JSContext, global: *JSObject, receiver: *JSO
} }
} }
#[fixed_stack_segment]
fn CreateInterfaceObject(cx: *JSContext, global: *JSObject, receiver: *JSObject, fn CreateInterfaceObject(cx: *JSContext, global: *JSObject, receiver: *JSObject,
constructorClass: *JSClass, constructorNative: JSNative, constructorClass: *JSClass, constructorNative: Option<JSNative>,
ctorNargs: u32, proto: *JSObject, ctorNargs: u32, proto: *JSObject,
staticMethods: *JSFunctionSpec, staticMethods: *JSFunctionSpec,
constants: *ConstantSpec, constants: *ConstantSpec,
@ -486,7 +517,6 @@ fn CreateInterfaceObject(cx: *JSContext, global: *JSObject, receiver: *JSObject,
JS_NewObject(cx, constructorClass, functionProto, global) JS_NewObject(cx, constructorClass, functionProto, global)
} }
} else { } else {
assert!(constructorNative.is_not_null());
let fun = JS_NewFunction(cx, constructorNative, ctorNargs, let fun = JS_NewFunction(cx, constructorNative, ctorNargs,
JSFUN_CONSTRUCTOR, global, name); JSFUN_CONSTRUCTOR, global, name);
if fun.is_null() { if fun.is_null() {
@ -542,7 +572,7 @@ fn CreateInterfaceObject(cx: *JSContext, global: *JSObject, receiver: *JSObject,
if alreadyDefined == 0 && if alreadyDefined == 0 &&
JS_DefineProperty(cx, receiver, name, RUST_OBJECT_TO_JSVAL(constructor), JS_DefineProperty(cx, receiver, name, RUST_OBJECT_TO_JSVAL(constructor),
ptr::null(), ptr::null(), 0) == 0 { None, None, 0) == 0 {
return ptr::null(); return ptr::null();
} }
@ -550,6 +580,7 @@ fn CreateInterfaceObject(cx: *JSContext, global: *JSObject, receiver: *JSObject,
} }
} }
#[fixed_stack_segment]
fn DefineConstants(cx: *JSContext, obj: *JSObject, constants: *ConstantSpec) -> bool { fn DefineConstants(cx: *JSContext, obj: *JSObject, constants: *ConstantSpec) -> bool {
let mut i = 0; let mut i = 0;
loop { loop {
@ -568,8 +599,8 @@ fn DefineConstants(cx: *JSContext, obj: *JSObject, constants: *ConstantSpec) ->
VoidVal => JSVAL_VOID VoidVal => JSVAL_VOID
}; };
if JS_DefineProperty(cx, obj, spec.name, if JS_DefineProperty(cx, obj, spec.name,
jsval, ptr::null(), jsval, None,
ptr::null(), None,
JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_ENUMERATE | JSPROP_READONLY |
JSPROP_PERMANENT) == 0 { JSPROP_PERMANENT) == 0 {
return false; return false;
@ -579,18 +610,21 @@ fn DefineConstants(cx: *JSContext, obj: *JSObject, constants: *ConstantSpec) ->
} }
} }
#[fixed_stack_segment]
fn DefineMethods(cx: *JSContext, obj: *JSObject, methods: *JSFunctionSpec) -> bool { fn DefineMethods(cx: *JSContext, obj: *JSObject, methods: *JSFunctionSpec) -> bool {
unsafe { unsafe {
JS_DefineFunctions(cx, obj, methods) != 0 JS_DefineFunctions(cx, obj, methods) != 0
} }
} }
#[fixed_stack_segment]
fn DefineProperties(cx: *JSContext, obj: *JSObject, properties: *JSPropertySpec) -> bool { fn DefineProperties(cx: *JSContext, obj: *JSObject, properties: *JSPropertySpec) -> bool {
unsafe { unsafe {
JS_DefineProperties(cx, obj, properties) != 0 JS_DefineProperties(cx, obj, properties) != 0
} }
} }
#[fixed_stack_segment]
fn CreateInterfacePrototypeObject(cx: *JSContext, global: *JSObject, fn CreateInterfacePrototypeObject(cx: *JSContext, global: *JSObject,
parentProto: *JSObject, protoClass: *JSClass, parentProto: *JSObject, protoClass: *JSClass,
methods: *JSFunctionSpec, methods: *JSFunctionSpec,
@ -618,11 +652,12 @@ fn CreateInterfacePrototypeObject(cx: *JSContext, global: *JSObject,
} }
} }
pub extern fn ThrowingConstructor(_cx: *JSContext, _argc: uint, _vp: *JSVal) -> JSBool { pub extern fn ThrowingConstructor(_cx: *JSContext, _argc: c_uint, _vp: *mut JSVal) -> JSBool {
//XXX should trigger exception here //XXX should trigger exception here
return 0; return 0;
} }
#[fixed_stack_segment]
pub fn initialize_global(global: *JSObject) { pub fn initialize_global(global: *JSObject) {
let protoArray = @mut ([0 as *JSObject, ..PrototypeList::id::_ID_Count as uint]); let protoArray = @mut ([0 as *JSObject, ..PrototypeList::id::_ID_Count as uint]);
unsafe { unsafe {
@ -664,6 +699,7 @@ impl WrapperCache {
} }
} }
#[fixed_stack_segment]
pub fn WrapNewBindingObject(cx: *JSContext, scope: *JSObject, pub fn WrapNewBindingObject(cx: *JSContext, scope: *JSObject,
value: @mut CacheableWrapper, value: @mut CacheableWrapper,
vp: *mut JSVal) -> bool { vp: *mut JSVal) -> bool {
@ -687,6 +723,7 @@ pub fn WrapNewBindingObject(cx: *JSContext, scope: *JSObject,
} }
} }
#[fixed_stack_segment]
pub fn WrapNativeParent(cx: *JSContext, scope: *JSObject, mut p: Option<@mut CacheableWrapper>) -> *JSObject { pub fn WrapNativeParent(cx: *JSContext, scope: *JSObject, mut p: Option<@mut CacheableWrapper>) -> *JSObject {
match p { match p {
Some(ref mut p) => { Some(ref mut p) => {
@ -707,6 +744,7 @@ pub trait BindingObject {
fn GetParentObject(&self, cx: *JSContext) -> Option<@mut CacheableWrapper>; fn GetParentObject(&self, cx: *JSContext) -> Option<@mut CacheableWrapper>;
} }
#[fixed_stack_segment]
pub fn GetPropertyOnPrototype(cx: *JSContext, proxy: *JSObject, id: jsid, found: *mut bool, pub fn GetPropertyOnPrototype(cx: *JSContext, proxy: *JSObject, id: jsid, found: *mut bool,
vp: *JSVal) -> bool { vp: *JSVal) -> bool {
unsafe { unsafe {
@ -730,6 +768,7 @@ pub fn GetPropertyOnPrototype(cx: *JSContext, proxy: *JSObject, id: jsid, found:
} }
} }
#[fixed_stack_segment]
pub fn GetArrayIndexFromId(_cx: *JSContext, id: jsid) -> Option<u32> { pub fn GetArrayIndexFromId(_cx: *JSContext, id: jsid) -> Option<u32> {
unsafe { unsafe {
if RUST_JSID_IS_INT(id) != 0 { if RUST_JSID_IS_INT(id) != 0 {
@ -753,6 +792,7 @@ pub fn GetArrayIndexFromId(_cx: *JSContext, id: jsid) -> Option<u32> {
}*/ }*/
} }
#[fixed_stack_segment]
pub fn XrayResolveProperty(cx: *JSContext, pub fn XrayResolveProperty(cx: *JSContext,
wrapper: *JSObject, wrapper: *JSObject,
id: jsid, id: jsid,
@ -779,9 +819,9 @@ pub fn XrayResolveProperty(cx: *JSContext,
RUST_SET_JITINFO(fun, attr.getter.info); RUST_SET_JITINFO(fun, attr.getter.info);
let funobj = JS_GetFunctionObject(fun); let funobj = JS_GetFunctionObject(fun);
(*desc).getter = funobj as *u8; (*desc).getter = Some(funobj as JSPropertyOp);
(*desc).attrs |= JSPROP_GETTER; (*desc).attrs |= JSPROP_GETTER;
if attr.setter.op.is_not_null() { if attr.setter.op.is_some() {
let fun = JS_NewFunction(cx, attr.setter.op, 1, 0, global, ptr::null()); let fun = JS_NewFunction(cx, attr.setter.op, 1, 0, global, ptr::null());
if fun.is_null() { if fun.is_null() {
return false return false
@ -789,10 +829,10 @@ pub fn XrayResolveProperty(cx: *JSContext,
RUST_SET_JITINFO(fun, attr.setter.info); RUST_SET_JITINFO(fun, attr.setter.info);
let funobj = JS_GetFunctionObject(fun); let funobj = JS_GetFunctionObject(fun);
(*desc).setter = funobj as *u8; (*desc).setter = Some(funobj as JSStrictPropertyOp);
(*desc).attrs |= JSPROP_SETTER; (*desc).attrs |= JSPROP_SETTER;
} else { } else {
(*desc).setter = ptr::null(); (*desc).setter = None;
} }
} }
} }
@ -802,6 +842,7 @@ pub fn XrayResolveProperty(cx: *JSContext,
} }
} }
#[fixed_stack_segment]
fn InternJSString(cx: *JSContext, chars: *libc::c_char) -> Option<jsid> { fn InternJSString(cx: *JSContext, chars: *libc::c_char) -> Option<jsid> {
unsafe { unsafe {
let s = JS_InternString(cx, chars); let s = JS_InternString(cx, chars);
@ -834,6 +875,7 @@ pub trait DerivedWrapper {
} }
impl DerivedWrapper for AbstractNode<ScriptView> { impl DerivedWrapper for AbstractNode<ScriptView> {
#[fixed_stack_segment]
fn wrap(&mut self, cx: *JSContext, _scope: *JSObject, vp: *mut JSVal) -> i32 { fn wrap(&mut self, cx: *JSContext, _scope: *JSObject, vp: *mut JSVal) -> i32 {
let cache = self.get_wrappercache(); let cache = self.get_wrappercache();
let wrapper = cache.get_wrapper(); let wrapper = cache.get_wrapper();
@ -862,6 +904,7 @@ pub struct EnumEntry {
length: uint length: uint
} }
#[fixed_stack_segment]
pub fn FindEnumStringIndex(cx: *JSContext, pub fn FindEnumStringIndex(cx: *JSContext,
v: JSVal, v: JSVal,
values: &[EnumEntry]) -> Result<uint, ()> { values: &[EnumEntry]) -> Result<uint, ()> {

View file

@ -88,6 +88,7 @@ impl DerivedWrapper for ClientRect {
fail!(~"nyi") fail!(~"nyi")
} }
#[fixed_stack_segment]
fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 { fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 {
let obj = self.wrap_object_shared(cx, scope); let obj = self.wrap_object_shared(cx, scope);
if obj.is_null() { if obj.is_null() {

View file

@ -85,6 +85,7 @@ pub struct Document {
} }
impl Document { impl Document {
#[fixed_stack_segment]
pub fn new(root: AbstractNode<ScriptView>, window: Option<@mut Window>, doctype: DocumentType) -> Document { pub fn new(root: AbstractNode<ScriptView>, window: Option<@mut Window>, doctype: DocumentType) -> Document {
let compartment = unsafe {(*window.get_ref().page).js_info.get_ref().js_compartment }; let compartment = unsafe {(*window.get_ref().page).js_info.get_ref().js_compartment };
do root.with_base |base| { do root.with_base |base| {
@ -149,6 +150,7 @@ impl BindingObject for AbstractDocument {
} }
impl DerivedWrapper for AbstractDocument { impl DerivedWrapper for AbstractDocument {
#[fixed_stack_segment]
fn wrap(&mut self, _cx: *JSContext, _scope: *JSObject, vp: *mut JSVal) -> i32 { fn wrap(&mut self, _cx: *JSContext, _scope: *JSObject, vp: *mut JSVal) -> i32 {
let cache = self.get_wrappercache(); let cache = self.get_wrappercache();
let wrapper = cache.get_wrapper(); let wrapper = cache.get_wrapper();
@ -446,6 +448,7 @@ impl Document {
} }
} }
#[fixed_stack_segment]
pub fn teardown(&self) { pub fn teardown(&self) {
unsafe { unsafe {
let compartment = (*self.window.get_ref().page).js_info.get_ref().js_compartment; let compartment = (*self.window.get_ref().page).js_info.get_ref().js_compartment;

View file

@ -139,6 +139,7 @@ impl DerivedWrapper for Event {
fail!(~"nyi") fail!(~"nyi")
} }
#[fixed_stack_segment]
fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 { fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 {
let obj = self.wrap_object_shared(cx, scope); let obj = self.wrap_object_shared(cx, scope);
if obj.is_null() { if obj.is_null() {

View file

@ -53,6 +53,7 @@ impl DerivedWrapper for EventTarget {
fail!(~"nyi") fail!(~"nyi")
} }
#[fixed_stack_segment]
fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 { fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 {
let obj = self.wrap_object_shared(cx, scope); let obj = self.wrap_object_shared(cx, scope);
if obj.is_null() { if obj.is_null() {

View file

@ -76,6 +76,7 @@ impl DerivedWrapper for FormData {
fail!(~"nyi") fail!(~"nyi")
} }
#[fixed_stack_segment]
fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 { fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 {
let obj = self.wrap_object_shared(cx, scope); let obj = self.wrap_object_shared(cx, scope);
if obj.is_null() { if obj.is_null() {

View file

@ -165,6 +165,7 @@ impl DerivedWrapper for MouseEvent {
fail!(~"nyi") fail!(~"nyi")
} }
#[fixed_stack_segment]
fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 { fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 {
let obj = self.wrap_object_shared(cx, scope); let obj = self.wrap_object_shared(cx, scope);
if obj.is_null() { if obj.is_null() {

View file

@ -139,6 +139,7 @@ impl DerivedWrapper for UIEvent {
fail!(~"nyi") fail!(~"nyi")
} }
#[fixed_stack_segment]
fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 { fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 {
let obj = self.wrap_object_shared(cx, scope); let obj = self.wrap_object_shared(cx, scope);
if obj.is_null() { if obj.is_null() {

View file

@ -14,9 +14,11 @@ use servo_msg::compositor_msg::ScriptListener;
use js::glue::*; use js::glue::*;
use js::jsapi::{JSObject, JSContext}; use js::jsapi::{JSObject, JSContext};
use js::jsapi::{JSPropertyOp, JSStrictPropertyOp};
use js::{JSVAL_NULL, JSPROP_ENUMERATE}; use js::{JSVAL_NULL, JSPROP_ENUMERATE};
use std::cast; use std::cast;
use std::cell::Cell;
use std::comm; use std::comm;
use std::comm::SharedChan; use std::comm::SharedChan;
use std::io; use std::io;
@ -146,9 +148,10 @@ impl Window {
// Post a delayed message to the per-window timer task; it will dispatch it // Post a delayed message to the per-window timer task; it will dispatch it
// to the relevant script handler that will deal with it. // to the relevant script handler that will deal with it.
let tm = Timer::new().unwrap(); let tm = Cell::new(Timer::new().unwrap());
let chan = self.timer_chan.clone(); let chan = self.timer_chan.clone();
do spawn { do spawn {
let mut tm = tm.take();
tm.sleep(timeout); tm.sleep(timeout);
chan.send(TimerMessage_Fire(~TimerData { chan.send(TimerMessage_Fire(~TimerData {
funval: callback, funval: callback,
@ -164,6 +167,7 @@ impl Window {
} }
} }
#[fixed_stack_segment]
pub fn new(page: *mut Page, script_chan: ScriptChan, compositor: @ScriptListener) pub fn new(page: *mut Page, script_chan: ScriptChan, compositor: @ScriptListener)
-> @mut Window { -> @mut Window {
let script_chan_clone = script_chan.clone(); let script_chan_clone = script_chan.clone();
@ -194,8 +198,8 @@ impl Window {
win.wrap_object_shared(compartment.cx.ptr, ptr::null()); //XXXjdm proper scope win.wrap_object_shared(compartment.cx.ptr, ptr::null()); //XXXjdm proper scope
compartment.define_property(~"window", compartment.define_property(~"window",
RUST_OBJECT_TO_JSVAL((*cache).wrapper), RUST_OBJECT_TO_JSVAL((*cache).wrapper),
GetJSClassHookStubPointer(PROPERTY_STUB) as *u8, GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp,
GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as *u8, GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as JSStrictPropertyOp,
JSPROP_ENUMERATE); JSPROP_ENUMERATE);
} }
win win

View file

@ -368,6 +368,7 @@ pub struct ScriptTask {
} }
/// Returns the relevant page from the associated JS Context. /// Returns the relevant page from the associated JS Context.
#[fixed_stack_segment]
pub fn page_from_context(js_context: *JSContext) -> *mut Page { pub fn page_from_context(js_context: *JSContext) -> *mut Page {
unsafe { unsafe {
JS_GetContextPrivate(js_context) as *mut Page JS_GetContextPrivate(js_context) as *mut Page
@ -503,6 +504,7 @@ impl ScriptTask {
} }
/// Handles a timer that fired. /// Handles a timer that fired.
#[fixed_stack_segment]
fn handle_fire_timer_msg(&mut self, id: PipelineId, timer_data: ~TimerData) { fn handle_fire_timer_msg(&mut self, id: PipelineId, timer_data: ~TimerData) {
let page = self.page_tree.find(id).expect("ScriptTask: received fire timer msg for a let page = self.page_tree.find(id).expect("ScriptTask: received fire timer msg for a
pipeline ID not associated with this script task. This is a bug.").page; pipeline ID not associated with this script task. This is a bug.").page;

@ -1 +1 @@
Subproject commit 25495d9a80f11fdde4fa3cc6bcb3c0ea7462e0bb Subproject commit fcc8d5865e0002d8d75f1098e956c120d8131c8d

@ -1 +1 @@
Subproject commit c5dafee99adea0a31acea07dce09d4f81271a14a Subproject commit 9755a007a0294294740d728ba14de30b45b769e5

@ -1 +1 @@
Subproject commit 479bccc6f323bc698856f3dc5a9ab93f4ffc8958 Subproject commit 4c4662a5d6077b547466d33c9a00cb33df9f6f26

@ -1 +1 @@
Subproject commit d0c3681561eb83b85773207e44bd2c22aa8445d2 Subproject commit 36b060d0aef4b3d3f644ef221a0aaca4cd31bcdb

@ -1 +1 @@
Subproject commit 0679efa35b682863d25ac19fdb520c35f9a364a5 Subproject commit e775ce635a063bf1d5d6b5b0c5339cbb818116ab

@ -1 +1 @@
Subproject commit 3f4841a48534b167284ea04b0c2b5952fef936e7 Subproject commit 6fbd1581ae7baede892c543c05f3509ded1ce8ed

@ -1 +1 @@
Subproject commit cb2c8b0e28b9e5bd957217109709f2603d7a5e78 Subproject commit f564836fb59e3a37b7cd9c903bd6282b61a2fea4

@ -1 +1 @@
Subproject commit 77921ee3f243ab90944ec44131ec98d20bc9551f Subproject commit 8700565717e8c94f6615761f074dafe8e6283d9f

@ -1 +1 @@
Subproject commit 16fe7a91f0cb201a461b8d05340b859e8f578a8f Subproject commit e8377820c6ae53973202f19aa2988bd8bef07dff

@ -1 +1 @@
Subproject commit ca00f10d255757d4f112a68b17f37afdc5462147 Subproject commit 1ed1ed819a90fc6c559282d3a5c02fc8cf3fba09

@ -1 +1 @@
Subproject commit b99f72ccde8ca973add1246426540849ffc50792 Subproject commit df7d4e1467a2341a4b4186d848df1d1d0adf9b7c

@ -1 +1 @@
Subproject commit a55ab9e2834b1cc898e68a02795ab68861f95f73 Subproject commit 5f144e1c22ca6d944333ff854a3b0a88d3aa04d7

@ -1 +1 @@
Subproject commit ec61bd34561ec6dd22d792713d385f7480863d38 Subproject commit 6286216e162319c049e3aa7c8435478668bb06d2

@ -1 +1 @@
Subproject commit d01eb726c0dcd46d71611e524ede00d28f382f29 Subproject commit 698124d5994d99183cbc51d07d15d1c16b0f75a4

@ -1 +1 @@
Subproject commit e677e2586128acfbae7517a4916e7ea826ab3206 Subproject commit 8dc1939cdf37dda742d4910e3265cf03c0fc9609

@ -1 +1 @@
Subproject commit 9278870fc5b79678a04ebd2d9eca305ac1706892 Subproject commit df9286ea88a2552690cc80e3232f854412deb3dc

@ -1 +1 @@
Subproject commit 2fdf1f166a7e8d0930b9e55a91601a4fcb35357f Subproject commit 095ca819d5edd7ba1f63cc4279c261d74138b5d5

@ -1 +1 @@
Subproject commit 89029c798d3b4a95a41c695e565d13b47b4a5b90 Subproject commit 881bdb753b3a51023d54b653cd88b7e266788476