aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/codegen
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2015-10-11 11:50:38 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2015-10-14 21:52:16 +0200
commitda676309318a7069650ca2cd571de7fa9b9e516a (patch)
treec4f1646796e0d192358f70ea323e230693514177 /components/script/dom/bindings/codegen
parent32daa17d5cbcad02db0713e21e52410cdc60480e (diff)
downloadservo-da676309318a7069650ca2cd571de7fa9b9e516a.tar.gz
servo-da676309318a7069650ca2cd571de7fa9b9e516a.zip
Introduce DOMClass::heap_size_of
It holds a function pointer to the HeapSizeOf::heap_size_of_children() implementation corresponding to that IDL interface. This removes the need for a clumsly TypeId-based match expression in the former heap_size_of_eventtarget() function.
Diffstat (limited to 'components/script/dom/bindings/codegen')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 00df29230c3..16663692ed7 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -1748,12 +1748,14 @@ def DOMClass(descriptor):
# padding.
protoList.extend(['PrototypeList::ID::Count'] * (descriptor.config.maxProtoChainLength - len(protoList)))
prototypeChainString = ', '.join(protoList)
+ heapSizeOf = 'heap_size_of_raw_self_and_children::<%s>' % descriptor.interface.identifier.name
return """\
DOMClass {
interface_chain: [ %s ],
native_hooks: &sNativePropertyHooks,
type_id: %s,
-}""" % (prototypeChainString, DOMClassTypeId(descriptor))
+ heap_size_of: %s as unsafe fn(_) -> _,
+}""" % (prototypeChainString, DOMClassTypeId(descriptor), heapSizeOf)
class CGDOMJSClass(CGThing):
@@ -5139,6 +5141,7 @@ class CGBindingRoot(CGThing):
'dom::bindings::num::Finite',
'dom::bindings::str::ByteString',
'dom::bindings::str::USVString',
+ 'mem::heap_size_of_raw_self_and_children',
'libc',
'util::str::DOMString',
'std::borrow::ToOwned',