Bug 1227987: Simplify CGDOMJSClass::define. r=bz.

--HG--
extra : rebase_source : aaf309c651b97ec750c56c2fbdf635529718fa14
This commit is contained in:
Peter Van der Beken 2015-11-25 16:31:42 +01:00
Родитель f72f6601ec
Коммит 426b1b699a
1 изменённых файлов: 8 добавлений и 37 удалений

Просмотреть файл

@ -410,51 +410,17 @@ class CGDOMJSClass(CGThing):
return "" return ""
def define(self): def define(self):
traceHook = 'nullptr'
callHook = LEGACYCALLER_HOOK_NAME if self.descriptor.operations["LegacyCaller"] else 'nullptr' callHook = LEGACYCALLER_HOOK_NAME if self.descriptor.operations["LegacyCaller"] else 'nullptr'
objectMovedHook = OBJECT_MOVED_HOOK_NAME if self.descriptor.wrapperCache else 'nullptr' objectMovedHook = OBJECT_MOVED_HOOK_NAME if self.descriptor.wrapperCache else 'nullptr'
slotCount = INSTANCE_RESERVED_SLOTS + self.descriptor.interface.totalMembersInSlots slotCount = INSTANCE_RESERVED_SLOTS + self.descriptor.interface.totalMembersInSlots
classFlags = "JSCLASS_IS_DOMJSCLASS | " classFlags = "JSCLASS_IS_DOMJSCLASS | "
classExtensionAndObjectOps = fill(
"""
{
false, /* isWrappedNative */
nullptr, /* weakmapKeyDelegateOp */
${objectMoved} /* objectMovedOp */
},
JS_NULL_OBJECT_OPS
""",
objectMoved=objectMovedHook)
if self.descriptor.isGlobal(): if self.descriptor.isGlobal():
classFlags += "JSCLASS_DOM_GLOBAL | JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(DOM_GLOBAL_SLOTS)" classFlags += "JSCLASS_DOM_GLOBAL | JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(DOM_GLOBAL_SLOTS)"
traceHook = "JS_GlobalObjectTraceHook" traceHook = "JS_GlobalObjectTraceHook"
reservedSlots = "JSCLASS_GLOBAL_APPLICATION_SLOTS" reservedSlots = "JSCLASS_GLOBAL_APPLICATION_SLOTS"
if self.descriptor.interface.identifier.name == "Window":
classExtensionAndObjectOps = fill(
"""
{
false, /* isWrappedNative */
nullptr, /* weakmapKeyDelegateOp */
${objectMoved} /* objectMovedOp */
},
{
nullptr, /* lookupProperty */
nullptr, /* defineProperty */
nullptr, /* hasProperty */
nullptr, /* getProperty */
nullptr, /* setProperty */
nullptr, /* getOwnPropertyDescriptor */
nullptr, /* deleteProperty */
nullptr, /* watch */
nullptr, /* unwatch */
nullptr, /* getElements */
nullptr, /* enumerate */
nullptr, /* funToString */
}
""",
objectMoved=objectMovedHook)
else: else:
classFlags += "JSCLASS_HAS_RESERVED_SLOTS(%d)" % slotCount classFlags += "JSCLASS_HAS_RESERVED_SLOTS(%d)" % slotCount
traceHook = 'nullptr'
reservedSlots = slotCount reservedSlots = slotCount
if self.descriptor.interface.getExtendedAttribute("NeedResolve"): if self.descriptor.interface.getExtendedAttribute("NeedResolve"):
resolveHook = RESOLVE_HOOK_NAME resolveHook = RESOLVE_HOOK_NAME
@ -487,7 +453,12 @@ class CGDOMJSClass(CGThing):
nullptr, /* construct */ nullptr, /* construct */
${trace}, /* trace */ ${trace}, /* trace */
JS_NULL_CLASS_SPEC, JS_NULL_CLASS_SPEC,
$*{classExtensionAndObjectOps} {
false, /* isWrappedNative */
nullptr, /* weakmapKeyDelegateOp */
${objectMoved} /* objectMovedOp */
},
JS_NULL_OBJECT_OPS
}, },
$*{descriptor} $*{descriptor}
}; };
@ -505,7 +476,7 @@ class CGDOMJSClass(CGThing):
finalize=FINALIZE_HOOK_NAME, finalize=FINALIZE_HOOK_NAME,
call=callHook, call=callHook,
trace=traceHook, trace=traceHook,
classExtensionAndObjectOps=classExtensionAndObjectOps, objectMoved=objectMovedHook,
descriptor=DOMClass(self.descriptor), descriptor=DOMClass(self.descriptor),
instanceReservedSlots=INSTANCE_RESERVED_SLOTS, instanceReservedSlots=INSTANCE_RESERVED_SLOTS,
reservedSlots=reservedSlots, reservedSlots=reservedSlots,