Merge remote-tracking branch 'origin/master'

Conflicts:
	src/components/script/dom/bindings/element.rs
	src/components/script/dom/bindings/node.rs
	src/components/script/dom/bindings/utils.rs
This commit is contained in:
Brian Anderson 2013-08-30 13:44:44 -07:00
commit 4487b1c29a
10 changed files with 25 additions and 546 deletions

View file

@ -20,7 +20,6 @@ use std::unstable::intrinsics;
use js::glue::*;
use js::glue::{DefineFunctionWithReserved, GetObjectJSClass, RUST_OBJECT_TO_JSVAL};
use js::glue::{js_IsObjectProxyClass, js_IsFunctionProxyClass, IsProxyHandlerFamily};
use js::glue::{PROPERTY_STUB, STRICT_PROPERTY_STUB, ENUMERATE_STUB, CONVERT_STUB, RESOLVE_STUB};
use js::jsapi::{JS_AlreadyHasOwnProperty, JS_NewObject, JS_NewFunction, JS_GetGlobalObject};
use js::jsapi::{JS_DefineProperties, JS_WrapValue, JS_ForwardGetPropertyTo};
use js::jsapi::{JS_EncodeString, JS_free, JS_GetStringCharsAndLength};
@ -35,7 +34,7 @@ use js::jsapi::{JSFreeOp, JSTracer};
use js::jsapi::{JSPropertyOp, JSStrictPropertyOp, JSEnumerateOp, JSResolveOp, JSConvertOp};
use js::jsfriendapi::bindgen::JS_NewObjectWithUniqueType;
use js::rust::Compartment;
use js::{JSCLASS_HAS_RESERVED_SLOTS, JSPROP_ENUMERATE, JSVAL_NULL};
use js::{JSPROP_ENUMERATE, JSVAL_NULL};
use js::{JSPROP_PERMANENT, JSID_VOID, JSPROP_NATIVE_ACCESSORS, JSPROP_GETTER};
use js::{JSPROP_SETTER, JSVAL_VOID, JSVAL_TRUE, JSVAL_FALSE};
use js::{JS_THIS_OBJECT, JSFUN_CONSTRUCTOR, JS_CALLEE, JSPROP_READONLY};
@ -258,114 +257,6 @@ extern fn has_instance(_cx: *JSContext, obj: **JSObject, v: *JSVal, bp: *mut JSB
}
}
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 name = name.take();
#[fixed_stack_segment]
fn just_effin_do_it(name: ~str, compartment: @mut Compartment) -> JSClass {
unsafe {
JSClass {
name: compartment.add_name(name.to_owned()),
flags: 0,
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp,
delProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp,
getProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp,
setProperty: GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as JSStrictPropertyOp,
enumerate: GetJSClassHookStubPointer(ENUMERATE_STUB) as JSEnumerateOp,
resolve: GetJSClassHookStubPointer(RESOLVE_STUB) as JSResolveOp,
convert: GetJSClassHookStubPointer(CONVERT_STUB) as JSConvertOp,
finalize: None,
checkAccess: None,
call: None,
hasInstance: Some(has_instance),
construct: None,
trace: None,
reserved: (null(), null(), null(), null(), null(), // 05
null(), null(), null(), null(), null(), // 10
null(), null(), null(), null(), null(), // 15
null(), null(), null(), null(), null(), // 20
null(), null(), null(), null(), null(), // 25
null(), null(), null(), null(), null(), // 30
null(), null(), null(), null(), null(), // 35
null(), null(), null(), null(), null()) // 40
}
}
}
just_effin_do_it(name, compartment)
};
return f;
}
pub fn instance_jsclass(name: ~str, finalize: extern "C" fn(*JSFreeOp, *JSObject),
trace: extern "C" fn(*mut JSTracer, *JSObject))
-> @fn(compartment: @mut Compartment) -> JSClass {
let name = Cell::new(name);
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 {
JSClass {
name: compartment.add_name(name.to_owned()),
flags: JSCLASS_HAS_RESERVED_SLOTS(1) | js::JSCLASS_IS_DOMJSCLASS,
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp,
delProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp,
getProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp,
setProperty: GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as JSStrictPropertyOp,
enumerate: GetJSClassHookStubPointer(ENUMERATE_STUB) as JSEnumerateOp,
resolve: GetJSClassHookStubPointer(RESOLVE_STUB) as JSResolveOp,
convert: GetJSClassHookStubPointer(CONVERT_STUB) as JSConvertOp,
finalize: Some(finalize),
checkAccess: None,
call: None,
hasInstance: Some(has_instance),
construct: None,
trace: Some(trace),
reserved: (null(), null(), null(), null(), null(), // 05
null(), null(), null(), null(), null(), // 10
null(), null(), null(), null(), null(), // 15
null(), null(), null(), null(), null(), // 20
null(), null(), null(), null(), null(), // 25
null(), null(), null(), null(), null(), // 30
null(), null(), null(), null(), null(), // 35
null(), null(), null(), null(), null()) // 40
}
}
}
just_effin_do_it(name, finalize, trace, compartment)
};
return f;
}
#[fixed_stack_segment]
pub fn define_empty_prototype(name: ~str, proto: Option<~str>, compartment: @mut Compartment)
-> js::rust::jsobj {
compartment.register_class(prototype_jsclass(name.to_owned()));
//TODO error checking
let obj = (
match proto {
Some(s) => compartment.new_object_with_proto(name.to_owned(),
s,
compartment.global_obj.ptr),
None => compartment.new_object(name.to_owned(), null(), compartment.global_obj.ptr)
}).unwrap();
unsafe {
compartment.define_property(name.to_owned(), RUST_OBJECT_TO_JSVAL(obj.ptr),
GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp,
GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as JSStrictPropertyOp,
JSPROP_ENUMERATE);
compartment.stash_global_proto(name, obj);
return obj;
}
}
// We use slot 0 for holding the raw object. This is safe for both
// globals and non-globals.
pub static DOM_OBJECT_SLOT: uint = 0;