mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Read-only Git mirror of the Mercurial gecko repositories at https://hg.mozilla.org. How to contribute: https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html
8ed5b13669
This patch adds a static assert to enforce that do_QueryInterface is not used to go from a class to a base class, because that can be done more efficiently via a static_cast. This is done by putting the type of the source into the nsQueryInterface type. Once that is done, it is easy to check the source and destination type. This has to be done carefully so that in non-DEBUG builds, where NSCAP_FEATURE_USE_BASE is defined, we don't generate any additional code. The first step is to rename nsQueryInterface to nsQueryInterfaceISupports. In DEBUG builds, I then add a new subtype nsQueryInterface<T>, where T is the type of the object we are going to QI. This class is a thin wrapper around nsQueryInterfaceISupports that only forwards operations to the base class. The main bit of trickery here is PointedToType<T>, which is needed to get the type parameter for nsQueryInterface. This dereferences the type, gets the address of it, then does RemovePointer. This is needed because a wide variety of pointer types are passed in to do_QueryInterface, including RefPtr<>, nsCOMPtr<>, raw pointers, and OwningNonNull<>. PointedToType<RefPtr<T>> is equal to T, PointedToType<T*> is equal to T, and so on. In NSCAP_FEATURE_USE_BASE builds (opt), we only use nsQueryInterfaceISupports, but in debug builds we use nsQueryInterface<> where possible. The latter is also used for the nsCOMPtr<nsISupports> overload, because we can always QI to nsISupports, because that is sometimes used for canonicalization. Another gross bit is that Assert_NoQueryNeeded can no longer use nsCOMPtr<>, because it works by QIing T to T, which is banned by the static analysis. Instead I had to reimplement it by hand. Depends on D7527 Differential Revision: https://phabricator.services.mozilla.com/D7553 --HG-- extra : moz-landing-system : lando |
||
---|---|---|
.cargo | ||
.vscode | ||
accessible | ||
browser | ||
build | ||
caps | ||
chrome | ||
config | ||
db | ||
devtools | ||
docshell | ||
dom | ||
editor | ||
embedding | ||
extensions | ||
gfx | ||
gradle/wrapper | ||
hal | ||
image | ||
intl | ||
ipc | ||
js | ||
layout | ||
media | ||
memory | ||
mfbt | ||
mobile | ||
modules | ||
mozglue | ||
netwerk | ||
nsprpub | ||
other-licenses | ||
parser | ||
python | ||
security | ||
services | ||
servo | ||
startupcache | ||
storage | ||
taskcluster | ||
testing | ||
third_party | ||
toolkit | ||
tools | ||
uriloader | ||
view | ||
widget | ||
xpcom | ||
xpfe/appshell | ||
.arcconfig | ||
.clang-format | ||
.clang-format-ignore | ||
.cron.yml | ||
.eslintignore | ||
.eslintrc.js | ||
.flake8 | ||
.gdbinit | ||
.gdbinit_python | ||
.gitignore | ||
.hgignore | ||
.hgtags | ||
.lldbinit | ||
.mailmap | ||
.taskcluster.yml | ||
.trackerignore | ||
.yamllint | ||
.ycm_extra_conf.py | ||
aclocal.m4 | ||
AUTHORS | ||
build.gradle | ||
Cargo.lock | ||
Cargo.toml | ||
client.mk | ||
client.py | ||
CLOBBER | ||
configure.in | ||
configure.py | ||
GNUmakefile | ||
gradle.properties | ||
gradlew | ||
LEGAL | ||
LICENSE | ||
mach | ||
Makefile.in | ||
moz.build | ||
moz.configure | ||
mozilla-config.h.in | ||
old-configure.in | ||
package-lock.json | ||
package.json | ||
Pipfile | ||
Pipfile.lock | ||
README.txt | ||
settings.gradle | ||
test.mozbuild |
An explanation of the Mozilla Source Code Directory Structure and links to project pages with documentation can be found at: https://developer.mozilla.org/en/Mozilla_Source_Code_Directory_Structure For information on how to build Mozilla from the source code, see: https://developer.mozilla.org/en/docs/Build_Documentation To have your bug fix / feature added to Mozilla, you should create a patch and submit it to Bugzilla (https://bugzilla.mozilla.org). Instructions are at: https://developer.mozilla.org/en/docs/Creating_a_patch https://developer.mozilla.org/en/docs/Getting_your_patch_in_the_tree If you have a question about developing Mozilla, and can't find the solution on https://developer.mozilla.org, you can try asking your question in a mozilla.* Usenet group, or on IRC at irc.mozilla.org. [The Mozilla news groups are accessible on Google Groups, or news.mozilla.org with a NNTP reader.] You can download nightly development builds from the Mozilla FTP server. Keep in mind that nightly builds, which are used by Mozilla developers for testing, may be buggy. Firefox nightlies, for example, can be found at: https://archive.mozilla.org/pub/firefox/nightly/latest-mozilla-central/ - or - https://www.mozilla.org/firefox/channel/desktop/#nightly