mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Clean up CGDOMJSClass
This commit is contained in:
parent
144e215548
commit
96e28086e3
1 changed files with 24 additions and 25 deletions
|
@ -1766,25 +1766,29 @@ class CGDOMJSClass(CGThing):
|
||||||
self.descriptor = descriptor
|
self.descriptor = descriptor
|
||||||
|
|
||||||
def define(self):
|
def define(self):
|
||||||
traceHook = 'Some(%s)' % TRACE_HOOK_NAME
|
args = {
|
||||||
|
"domClass": DOMClass(self.descriptor),
|
||||||
|
"finalizeHook": FINALIZE_HOOK_NAME,
|
||||||
|
"flags": "0",
|
||||||
|
"name": str_to_const_array(self.descriptor.interface.identifier.name),
|
||||||
|
"outerObjectHook": self.descriptor.outerObjectHook,
|
||||||
|
"slots": "1",
|
||||||
|
"traceHook": TRACE_HOOK_NAME,
|
||||||
|
}
|
||||||
if self.descriptor.isGlobal():
|
if self.descriptor.isGlobal():
|
||||||
assert not self.descriptor.weakReferenceable
|
assert not self.descriptor.weakReferenceable
|
||||||
traceHook = "Some(js::jsapi::JS_GlobalObjectTraceHook)"
|
args["flags"] = "JSCLASS_IS_GLOBAL | JSCLASS_DOM_GLOBAL"
|
||||||
flags = "JSCLASS_IS_GLOBAL | JSCLASS_DOM_GLOBAL"
|
args["slots"] = "JSCLASS_GLOBAL_SLOT_COUNT + 1"
|
||||||
slots = "JSCLASS_GLOBAL_SLOT_COUNT + 1"
|
args["traceHook"] = "js::jsapi::JS_GlobalObjectTraceHook"
|
||||||
else:
|
elif self.descriptor.weakReferenceable:
|
||||||
flags = "0"
|
args["slots"] = "2"
|
||||||
if self.descriptor.weakReferenceable:
|
|
||||||
slots = "2"
|
|
||||||
else:
|
|
||||||
slots = "1"
|
|
||||||
return """\
|
return """\
|
||||||
static Class: DOMJSClass = DOMJSClass {
|
static Class: DOMJSClass = DOMJSClass {
|
||||||
base: js::jsapi::Class {
|
base: js::jsapi::Class {
|
||||||
name: %s as *const u8 as *const libc::c_char,
|
name: %(name)s as *const u8 as *const libc::c_char,
|
||||||
flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_IMPLEMENTS_BARRIERS | %s |
|
flags: JSCLASS_IS_DOMJSCLASS | JSCLASS_IMPLEMENTS_BARRIERS | %(flags)s |
|
||||||
(((%s) & JSCLASS_RESERVED_SLOTS_MASK) <<
|
(((%(slots)s) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
|
||||||
JSCLASS_RESERVED_SLOTS_SHIFT), //JSCLASS_HAS_RESERVED_SLOTS(%s),
|
/* JSCLASS_HAS_RESERVED_SLOTS(%(slots)s) */,
|
||||||
addProperty: None,
|
addProperty: None,
|
||||||
delProperty: None,
|
delProperty: None,
|
||||||
getProperty: None,
|
getProperty: None,
|
||||||
|
@ -1792,11 +1796,11 @@ static Class: DOMJSClass = DOMJSClass {
|
||||||
enumerate: None,
|
enumerate: None,
|
||||||
resolve: None,
|
resolve: None,
|
||||||
convert: None,
|
convert: None,
|
||||||
finalize: Some(%s),
|
finalize: Some(%(finalizeHook)s),
|
||||||
call: None,
|
call: None,
|
||||||
hasInstance: None,
|
hasInstance: None,
|
||||||
construct: None,
|
construct: None,
|
||||||
trace: %s,
|
trace: Some(%(traceHook)s),
|
||||||
|
|
||||||
spec: js::jsapi::ClassSpec {
|
spec: js::jsapi::ClassSpec {
|
||||||
createConstructor: None,
|
createConstructor: None,
|
||||||
|
@ -1810,7 +1814,7 @@ static Class: DOMJSClass = DOMJSClass {
|
||||||
},
|
},
|
||||||
|
|
||||||
ext: js::jsapi::ClassExtension {
|
ext: js::jsapi::ClassExtension {
|
||||||
outerObject: %s,
|
outerObject: %(outerObjectHook)s,
|
||||||
innerObject: None,
|
innerObject: None,
|
||||||
isWrappedNative: false,
|
isWrappedNative: false,
|
||||||
weakmapKeyDelegateOp: None,
|
weakmapKeyDelegateOp: None,
|
||||||
|
@ -1829,17 +1833,12 @@ static Class: DOMJSClass = DOMJSClass {
|
||||||
unwatch: None,
|
unwatch: None,
|
||||||
getElements: None,
|
getElements: None,
|
||||||
enumerate: None,
|
enumerate: None,
|
||||||
thisObject: %s,
|
thisObject: %(outerObjectHook)s,
|
||||||
funToString: None,
|
funToString: None,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
dom_class: %s
|
dom_class: %(domClass)s
|
||||||
};""" % (str_to_const_array(self.descriptor.interface.identifier.name),
|
};""" % args
|
||||||
flags, slots, slots,
|
|
||||||
FINALIZE_HOOK_NAME, traceHook,
|
|
||||||
self.descriptor.outerObjectHook,
|
|
||||||
self.descriptor.outerObjectHook,
|
|
||||||
CGGeneric(DOMClass(self.descriptor)).define())
|
|
||||||
|
|
||||||
|
|
||||||
def str_to_const_array(s):
|
def str_to_const_array(s):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue