Add JSCLASS_DOM_GLOBAL to DOM global classes, and assert it is used.

It seems unlikely that this will ever be hit, but potentially hard to
figure out if it ever is hit.
This commit is contained in:
Ms2ger 2014-05-03 10:37:46 +02:00
parent a6f235e285
commit 599d76fa6e
2 changed files with 5 additions and 7 deletions

View file

@ -1455,7 +1455,7 @@ class CGDOMJSClass(CGThing):
def define(self):
traceHook = "Some(%s)" % TRACE_HOOK_NAME
if self.descriptor.createGlobal:
flags = "JSCLASS_IS_GLOBAL"
flags = "JSCLASS_IS_GLOBAL | JSCLASS_DOM_GLOBAL"
slots = "JSCLASS_GLOBAL_SLOT_COUNT + 1"
else:
flags = "0"
@ -2035,10 +2035,8 @@ class CGGetPerInterfaceObject(CGAbstractMethod):
wrapper and aGlobal is the sandbox's global.
*/
/* Make sure our global is sane. Hopefully we can remove this sometime */
/*if ((*JS_GetClass(aGlobal)).flags & JSCLASS_DOM_GLOBAL) == 0 {
return ptr::null();
}*/
assert!(((*JS_GetClass(aGlobal)).flags & JSCLASS_DOM_GLOBAL) != 0);
/* Check to see whether the interface objects are already installed */
let protoOrIfaceArray: *mut *JSObject = GetProtoOrIfaceArray(aGlobal) as *mut *JSObject;
let cachedObject: *JSObject = *protoOrIfaceArray.offset(%s as int);
@ -4282,7 +4280,7 @@ class CGBindingRoot(CGThing):
'dom::bindings::utils::{CreateDOMGlobal, CreateInterfaceObjects2}',
'dom::bindings::utils::{ConstantSpec, cx_for_dom_object, Default}',
'dom::bindings::utils::{dom_object_slot, DOM_OBJECT_SLOT, DOMClass}',
'dom::bindings::utils::{DOMJSClass}',
'dom::bindings::utils::{DOMJSClass, JSCLASS_DOM_GLOBAL}',
'dom::bindings::utils::{FindEnumStringIndex, GetArrayIndexFromId}',
'dom::bindings::utils::{GetPropertyOnPrototype, GetProtoOrIfaceArray}',
'dom::bindings::utils::{HasPropertyOnPrototype, IntVal}',

View file

@ -207,7 +207,7 @@ pub struct DOMJSClass {
pub fn GetProtoOrIfaceArray(global: *JSObject) -> **JSObject {
unsafe {
/*assert ((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0;*/
assert!(((*JS_GetClass(global)).flags & JSCLASS_DOM_GLOBAL) != 0);
JS_GetReservedSlot(global, DOM_PROTOTYPE_SLOT).to_private() as **JSObject
}
}