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,
flags: (JSPROP_SHARED | JSPROP_ENUMERATE | JSPROP_NATIVE_ACCESSORS) as u8,
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()}}];
vec::push(compartment.global_props, attrs);
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_DefineFunctions, JS_DefineProperty, JS_GetContextPrivate,
JS_GetClass, JS_GetPrototype};
import js::crust::{JS_ConvertStub, JS_PropertyStub, JS_StrictPropertyStub,
JS_EnumerateStub, JS_ConvertStub, JS_ResolveStub};
import js::glue::{PROPERTY_STUB, STRICT_PROPERTY_STUB, ENUMERATE_STUB, CONVERT_STUB,
RESOLVE_STUB};
import js::glue::bindgen::*;
import ptr::null;
import result::{result, ok, err};
@ -99,13 +99,13 @@ fn prototype_jsclass(name: ~str) -> fn(bare_compartment) -> JSClass {
return fn@(compartment: bare_compartment) -> JSClass {
{name: compartment.add_name(name),
flags: 0,
addProperty: JS_PropertyStub,
delProperty: JS_PropertyStub,
getProperty: JS_PropertyStub,
setProperty: JS_StrictPropertyStub,
enumerate: JS_EnumerateStub,
resolve: JS_PropertyStub,
convert: JS_ConvertStub,
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
delProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
getProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
setProperty: GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as *u8,
enumerate: GetJSClassHookStubPointer(ENUMERATE_STUB) as *u8,
resolve: GetJSClassHookStubPointer(RESOLVE_STUB) as *u8,
convert: GetJSClassHookStubPointer(CONVERT_STUB) as *u8,
finalize: null(),
checkAccess: null(),
call: null(),
@ -128,13 +128,13 @@ fn instance_jsclass(name: ~str, finalize: *u8)
return fn@(compartment: bare_compartment) -> JSClass {
{name: compartment.add_name(name),
flags: JSCLASS_HAS_RESERVED_SLOTS(1),
addProperty: JS_PropertyStub,
delProperty: JS_PropertyStub,
getProperty: JS_PropertyStub,
setProperty: JS_StrictPropertyStub,
enumerate: JS_EnumerateStub,
resolve: JS_ResolveStub,
convert: JS_ConvertStub,
addProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
delProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
getProperty: GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
setProperty: GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as *u8,
enumerate: GetJSClassHookStubPointer(ENUMERATE_STUB) as *u8,
resolve: GetJSClassHookStubPointer(RESOLVE_STUB) as *u8,
convert: GetJSClassHookStubPointer(CONVERT_STUB) as *u8,
finalize: finalize,
checkAccess: 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),
JS_PropertyStub, JS_StrictPropertyStub,
GetJSClassHookStubPointer(PROPERTY_STUB) as *u8,
GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as *u8,
JSPROP_ENUMERATE);
compartment.stash_global_proto(name, obj);
return obj;

View file

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