In preparation for autogenerating Node and all our Element descendents, I've got a PR open replacing the manual Document bindings with autogenerated ones (minus Node), and uncommitted code locally that generates HTMLDocument as well. This has allowed me to come to grips with our hand-rolled inheritance scheme and how it interacts with manual DOM code and the bindings, and here are my conclusions:

* For interfaces FooA and FooB, with FooA as the root of the chain, we create equivalent Rust structs where the first inline field is the parent class * We create an AbstractFoo containing a single pointer which will be transmuted to the appropriate descendent class when downcasting
* All DOM code holds on to AbstractFoo members, never the concrete classes
* For any DOM interfaces returning FooA or FooB, the concrete methods will return AbstractFoo * For any DOM interfaces taking FooA or FooB as arguments, the concrete methods will take AbstractFoo * Any generated bindings code for getters/setters/methods/finalizers for FooA and FooB will be unwrapped directly to pointers to the concrete types. There is no need to go through our safe downcasting, which is only for manual DOM client code, since we have our prototype checks in place already.

Cheers,
Josh
_______________________________________________
dev-servo mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-servo

Reply via email to