Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade SpiderMonkey #2455

Closed
wants to merge 7 commits into from

Make DOM proxies and event listeners work.

  • Loading branch information
jdm committed May 15, 2014
commit 6182a30fabbf39dac31c486aab3042c1ab4c4e54

Large diffs are not rendered by default.

@@ -24,11 +24,11 @@ static JSPROXYSLOT_EXPANDO: u32 = 0;
pub extern fn getPropertyDescriptor(cx: *mut JSContext, proxy: JSHandleObject, id: JSHandleId,
desc: JSMutableHandle<JSPropertyDescriptor>, flags: u32) -> libc::c_int {
unsafe {
let handler = GetProxyHandler(proxy);
let handler = GetProxyHandler(*proxy.unnamed_field1);
if InvokeGetOwnPropertyDescriptor(handler, cx, proxy, id, desc, flags) == 0 {
return 0;
}
if (*desc.unnamed_field1).is_not_null() {
if desc.unnamed_field1.is_not_null() {
return 1;
}

@@ -38,7 +38,7 @@ pub extern fn getPropertyDescriptor(cx: *mut JSContext, proxy: JSHandleObject, i
};
assert!(GetObjectProto(cx, proxy, proto) != 0);
if (*proto.unnamed_field1).is_null() {
*desc.unnamed_field1 = ptr::mut_null();
(*desc.unnamed_field1).obj = ptr::mut_null();
return 1;
}

@@ -50,9 +50,9 @@ pub fn defineProperty_(cx: *mut JSContext, proxy: JSHandleObject, id: JSHandleId
desc: JSMutableHandle<JSPropertyDescriptor>) -> JSBool {
unsafe {
//FIXME: Workaround for https://github.com/mozilla/rust/issues/13385
let setter: *libc::c_void = cast::transmute((**desc.unnamed_field1).setter);
let setter: *libc::c_void = cast::transmute((*desc.unnamed_field1).setter);
let setter_stub: *libc::c_void = cast::transmute(JS_StrictPropertyStub);
if ((**desc.unnamed_field1).attrs & JSPROP_GETTER) != 0 && setter == setter_stub {
if ((*desc.unnamed_field1).attrs & JSPROP_GETTER) != 0 && setter == setter_stub {
/*return JS_ReportErrorFlagsAndNumber(cx,
JSREPORT_WARNING | JSREPORT_STRICT |
JSREPORT_STRICT_MODE_ERROR,
@@ -61,16 +61,16 @@ pub fn defineProperty_(cx: *mut JSContext, proxy: JSHandleObject, id: JSHandleId
return 0;
}

let expando = EnsureExpandoObject(cx, proxy);
let expando = EnsureExpandoObject(cx, *proxy.unnamed_field1);
if expando.is_null() {
return 0;
}

return JS_DefinePropertyById(cx, expando, *id.unnamed_field1,
(**desc.unnamed_field1).value,
(**desc.unnamed_field1).getter,
(**desc.unnamed_field1).setter,
(**desc.unnamed_field1).attrs);
(*desc.unnamed_field1).value,
(*desc.unnamed_field1).getter,
(*desc.unnamed_field1).setter,
(*desc.unnamed_field1).attrs);
}
}

@@ -101,7 +101,7 @@ pub fn _obj_toString(cx: *mut JSContext, className: *libc::c_char) -> *mut JSStr
}
}

pub fn GetExpandoObject(obj: JSHandleObject) -> *mut JSObject {
pub fn GetExpandoObject(obj: *mut JSObject) -> *mut JSObject {
unsafe {
//XXXjdm it would be nice to assert that obj's class is a proxy class
let val = GetProxyExtra(obj, JSPROXYSLOT_EXPANDO);
@@ -113,13 +113,13 @@ pub fn GetExpandoObject(obj: JSHandleObject) -> *mut JSObject {
}
}

pub fn EnsureExpandoObject(cx: *mut JSContext, obj: JSHandleObject) -> *mut JSObject {
pub fn EnsureExpandoObject(cx: *mut JSContext, obj: *mut JSObject) -> *mut JSObject {
unsafe {
//XXXjdm it would be nice to assert that obj's class is a proxy class
let mut expando = GetExpandoObject(obj);
if expando.is_null() {
expando = JS_NewObjectWithGivenProto(cx, ptr::null(), object_handle(&ptr::mut_null()),
object_handle(&GetObjectParent(*obj.unnamed_field1)));
object_handle(&GetObjectParent(obj)));
if expando.is_null() {
return ptr::mut_null();
}
@@ -144,7 +144,7 @@ pub fn jsstring_to_str(cx: *mut JSContext, s: *mut JSString) -> DOMString {
}
}

pub fn jsid_to_str(cx: *mut JSContext, id: JSHandleId) -> DOMString {
pub fn jsid_to_str(cx: *mut JSContext, id: jsid) -> DOMString {
unsafe {
assert!(RUST_JSID_IS_STRING(id) != 0);
jsstring_to_str(cx, RUST_JSID_TO_STRING(id))
@@ -233,7 +233,7 @@ pub fn CreateInterfaceObjects2(cx: *mut JSContext, global: JSHandleObject, recei
let mut interface = ptr::mut_null();
if constructor.is_some() {
interface = name.to_c_str().with_ref(|s| {
CreateInterfaceObject(cx, unsafe { *global.unnamed_field1 }, receiver,
CreateInterfaceObject(cx, global, receiver,
constructor, ctorNargs, proto,
staticMethods, constants, s)
});
@@ -249,18 +249,15 @@ pub fn CreateInterfaceObjects2(cx: *mut JSContext, global: JSHandleObject, recei
}
}

fn CreateInterfaceObject(cx: *mut JSContext, global: *mut JSObject, receiver: *mut JSObject,
fn CreateInterfaceObject(cx: *mut JSContext, global: JSHandleObject, receiver: *mut JSObject,
constructorNative: JSNative,
ctorNargs: u32, proto: *mut JSObject,
staticMethods: *JSFunctionSpec,
constants: *ConstantSpec,
name: *libc::c_char) -> *mut JSObject {
unsafe {
let globalhandle = JSHandleObject {
unnamed_field1: &global,
};
let fun = JS_NewFunction(cx, constructorNative, ctorNargs,
JSFUN_CONSTRUCTOR, globalhandle, name);
JSFUN_CONSTRUCTOR, global, name);
if fun.is_null() {
return ptr::mut_null();
}
@@ -470,7 +467,7 @@ pub fn GetPropertyOnPrototype(cx: *mut JSContext, proxy: JSHandleObject, id: JSH
}
}

pub fn GetArrayIndexFromId(_cx: *mut JSContext, id: JSHandleId) -> Option<u32> {
pub fn GetArrayIndexFromId(_cx: *mut JSContext, id: jsid) -> Option<u32> {
unsafe {
if RUST_JSID_IS_INT(id) != 0 {
return Some(RUST_JSID_TO_INT(id) as u32);
@@ -11,7 +11,8 @@ use dom::window::Window;
use js;
use js::jsapi::{JSObject, JS_PropertyStub, JS_DeletePropertyStub, JS_StrictPropertyStub};
use js::jsapi::{JS_EnumerateStub, JS_ResolveStub, JSFunctionSpec};
use js::glue::{WrapperNew, CreateWrapperProxyHandler, ProxyTraps};
use js::jsval::PrivateValue;
use js::glue::{WrapperNew, CreateWrapperProxyHandler, ProxyTraps, SetProxyExtra};
use js::glue::{proxy_LookupGeneric, proxy_LookupProperty, proxy_LookupElement};
use js::glue::{proxy_DefineGeneric, proxy_DefineProperty, proxy_DefineElement};
use js::glue::{proxy_GetGeneric, proxy_SetGeneric, proxy_SetProperty, proxy_SetElement};
@@ -72,6 +73,9 @@ impl BrowserContext {
&ProxyClass, true)
});
assert!(wrapper.is_not_null());
unsafe {
SetProxyExtra(wrapper, 0, PrivateValue(obj as *libc::c_void));
}
wrapper
}
}
@@ -59,6 +59,7 @@ use std::cell::{Cell, RefCell, Ref, RefMut};
use std::comm::{channel, Sender, Receiver, Empty, Disconnected, Data};
use std::local_data;
use std::mem::replace;
use std::ptr;
use std::rc::Rc;
use std::str::Slice;
use std::task;
@@ -831,7 +832,7 @@ impl ScriptTask {
unsafe {
CallFunctionValue(cx, object_handle(&this_value),
value_handle(&*timer_handle.data.funval),
rval);
0, ptr::null(), rval);
}
});

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.