On Fri, Jan 11, 2019 at 7:21 AM Nathan Froyd <nfr...@mozilla.com> wrote:
> > - Removal of [noscript] methods in interfaces in favor of direct calls > via > > Cast() where possible. > > - Direct getters through Cast() where possible, infallible (also where > > possible) otherwise. > > For avoidance of doubt, since I don't think we have a global Cast() > function, this is meant to refer to idioms like: > > > https://searchfox.org/mozilla-central/rev/b4ebbe90ae4d0468fe6232bb4ce90699738c8125/caps/BasePrincipal.h#136-142 > > and we'd prefer the explicit downcast from an interface pointer > (assuming the interface is [builtinclass]) and a C++-side getter, > rather than declaring the getter in the interface definition? > Yeah, this is why I sent this email. I'm finding unwritten rules about XPCOM cleanup that I'd like to formalize more. I've been fixing up docshell accesses using the Cast() idiom where I can. This has sometimes been to avoid having to cast the same docshell to 2-3 different interfaces over the course of the same method. It also makes it easier to whittle away at XPCOM interfaces that we may no longer need, but that we can't tell as such due to not knowing what's used where. When making some changes to nsIPrincipal and BasePrincipal, bholley also mentioned he preferred that style, wanting C++ ergonomics to live in C++. I'm not sure if there was more reasoning for that, I'll let him respond on that. _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform