As of bug 1778211 (https://bugzilla.mozilla.org/show_bug.cgi?id=1778211), a 
new check is being added to the XPIDL compiler to reject `%{C++` blocks 
which contain the keyword `virtual`. This is done to hopefully avoid future 
cases where people introduce new virtual methods to XPIDL classes directly, 
without declaring the methods in XPIDL.

The XPIDL compiler generates bindings for multiple languages, including 
Rust and JS through XPConnect. In order to do these cross-language 
bindings, it needs to know the actual layout of the VTable, including 
offsets and signatures of each method. Additional virtual methods 
implemented using CDATA blocks can potentially throw this off.

The lint was implemented in a fairly simple way (searching for the 
`virtual` keyword in the text of the CDATA block) so can have both false 
positives and false negatives, however the false-positive rate was low and 
easly worked around in practice. In the future we may introduce a custom 
clang lint to double-check vtable and struct layouts which will be more 
accurate (https://bugzilla.mozilla.org/show_bug.cgi?id=1778339).

If you are reaching to manually add a virtual method in an XPIDL header, 
consider instead declaring a `[notxpcom, nostdcall]` method, and using 
`native` type declarations to get the signature you're looking for. Using 
that approach we can get better checks and enforce other requirements like 
`[builtinclass]` more effectively.

-nika

-- 
You received this message because you are subscribed to the Google Groups 
"[email protected]" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/a/mozilla.org/d/msgid/dev-platform/7a112401-b650-4705-b700-6b2024e76aa5n%40mozilla.org.

Reply via email to