Actually add nodeType getter.

This commit is contained in:
Josh Matthews 2012-08-24 12:12:20 -07:00
parent 04d18d128a
commit 780469e26a
4 changed files with 27 additions and 19 deletions

@ -1 +1 @@
Subproject commit 1dbbc2ee587634bda13d4c32957c2b1a0ce167cc Subproject commit 71078d8f423474991ff441647dd101a7e690535b

View file

@ -28,6 +28,12 @@ fn init(compartment: bare_compartment) {
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: {op: getNextSibling, info: null()}, getter: {op: getNextSibling, info: null()},
setter: {op: null(), info: null()}},
{name: compartment.add_name(~"nodeType"),
tinyid: 0,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
getter: {op: getNodeType, info: null()},
setter: {op: null(), info: null()}}]; setter: {op: null(), info: null()}}];
vec::push(compartment.global_props, attrs); vec::push(compartment.global_props, attrs);
vec::as_buf(*attrs, |specs, _len| { vec::as_buf(*attrs, |specs, _len| {

View file

@ -6,8 +6,8 @@ import js::jsapi::bindgen::{JS_ValueToString, JS_GetStringCharsZAndLength, JS_Re
JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN, JS_GetReservedSlot, JS_SetReservedSlot, JS_NewStringCopyN,
JS_DefineFunctions, JS_DefineProperty, JS_GetContextPrivate, JS_DefineFunctions, JS_DefineProperty, JS_GetContextPrivate,
JS_GetClass, JS_GetPrototype}; JS_GetClass, JS_GetPrototype};
import js::crust::{JS_ConvertStub, JS_PropertyStub, JS_StrictPropertyStub, import js::glue::{PROPERTY_STUB, STRICT_PROPERTY_STUB, ENUMERATE_STUB, CONVERT_STUB,
JS_EnumerateStub, JS_ConvertStub, JS_ResolveStub}; RESOLVE_STUB};
import js::glue::bindgen::*; import js::glue::bindgen::*;
import ptr::null; import ptr::null;
import result::{result, ok, err}; import result::{result, ok, err};
@ -99,13 +99,13 @@ fn prototype_jsclass(name: ~str) -> fn(bare_compartment) -> JSClass {
return fn@(compartment: bare_compartment) -> JSClass { return fn@(compartment: bare_compartment) -> JSClass {
{name: compartment.add_name(name), {name: compartment.add_name(name),
flags: 0, flags: 0,
addProperty: JS_PropertyStub, addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
delProperty: JS_PropertyStub, delProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
getProperty: JS_PropertyStub, getProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
setProperty: JS_StrictPropertyStub, setProperty: GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as *u8,
enumerate: JS_EnumerateStub, enumerate: GetJSClassHookStubPointer(ENUMERATE_STUB) as *u8,
resolve: JS_PropertyStub, resolve: GetJSClassHookStubPointer(RESOLVE_STUB) as *u8,
convert: JS_ConvertStub, convert: GetJSClassHookStubPointer(CONVERT_STUB) as *u8,
finalize: null(), finalize: null(),
checkAccess: null(), checkAccess: null(),
call: null(), call: null(),
@ -128,13 +128,13 @@ fn instance_jsclass(name: ~str, finalize: *u8)
return fn@(compartment: bare_compartment) -> JSClass { return fn@(compartment: bare_compartment) -> JSClass {
{name: compartment.add_name(name), {name: compartment.add_name(name),
flags: JSCLASS_HAS_RESERVED_SLOTS(1), flags: JSCLASS_HAS_RESERVED_SLOTS(1),
addProperty: JS_PropertyStub, addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
delProperty: JS_PropertyStub, delProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
getProperty: JS_PropertyStub, getProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
setProperty: JS_StrictPropertyStub, setProperty: GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as *u8,
enumerate: JS_EnumerateStub, enumerate: GetJSClassHookStubPointer(ENUMERATE_STUB) as *u8,
resolve: JS_ResolveStub, resolve: GetJSClassHookStubPointer(RESOLVE_STUB) as *u8,
convert: JS_ConvertStub, convert: GetJSClassHookStubPointer(CONVERT_STUB) as *u8,
finalize: finalize, finalize: finalize,
checkAccess: null(), checkAccess: null(),
call: null(), call: null(),
@ -165,7 +165,8 @@ fn define_empty_prototype(name: ~str, proto: option<~str>, compartment: bare_com
}); });
compartment.define_property(name, RUST_OBJECT_TO_JSVAL(obj.ptr), compartment.define_property(name, RUST_OBJECT_TO_JSVAL(obj.ptr),
JS_PropertyStub, JS_StrictPropertyStub, GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as *u8,
JSPROP_ENUMERATE); JSPROP_ENUMERATE);
compartment.stash_global_proto(name, obj); compartment.stash_global_proto(name, obj);
return obj; return obj;

View file

@ -1,8 +1,9 @@
var elem = document.documentElement.firstChild; var elem = document.documentElement.firstChild;
var start = (new Date()).getTime(); var start = (new Date()).getTime();
for (var i = 0; i < 100000; i++) for (var i = 0; i < 100000; i++) {
var a = elem.nodeType; var a = elem.nodeType;
}
window.alert((new Date()).getTime() - start); window.alert((new Date()).getTime() - start);
/*start = new Date().getTime(); /*start = new Date().getTime();