This type is fairly simple on the idl parsing side of things. I handle it in the
same way that special types such as ns[C]String, nsid, and jsval are handled, by
using a special native type.
The logic for converting the value between C++ and JS follows the existing logic
from the nsISupports <=> JS Promise conversions.
They are parsed into a WebIDL object, and lowered into C++, Rust, and XPT.
For C++ code, we generate a correctly namespaced forward declaration. In Rust,
the types are exposed as `*const c_void`, as we don't have WebIDL type
information there.
The XPT code generator needs to know the header filename in order to perform
correct codegen, so we also get that information.
This patch contains the meat of the changes here. The following summarize the changes:
1. xptinfo.h is rewritten to expose the new interface for reading the XPT data,
The nsXPTInterfaceInfo object exposes methods with the same signatures as
the methods on nsIInterfaceInfo, to make converting code which used
nsIInterfaceInfo as easy as possible, even when those methods don't have
signatures which make a ton of sense anymore. There are also a few methods
which are unnecessary (they return `true` or similar), which should be
removed over time.
Members of the data structures are made private in order to prevent reading
them directly. Code should instead call the getter methods. This should make
it easier to change their memory representation in the future. Constructing
these structs is made possible by making the structs `friend class` with the
XPTConstruct class, which is implemented by the code generator, and is able
to access the private fields.
In addition, rather than using integers with flag constants, I opted for
using C++ bitfields to store individual flags, as I found it made it easier
to both write the code generator, and reason about the layouts of the types.
I was able to shave a byte off of each nsXPTParamInfo (4 bytes -> 3 bytes)
by shoving the flags into spare bits in the nsXPTType. Unfortunately there
was not enough room for the retval flag. Fortunately, we already depend in
our code on the retval parameter being the last parameter, so I worked
around this by removing the retval flag and instead having a `hasretval`
flag on the method itself.
2. An xptinfo.cpp file is added for out-of-line definitions of more complex
methods, and the internal implementation details of the perfect hash.
Notable is the handling of xptshim interfaces. As the type is uniform, a
flag is checked when trying to read constant information, and a different
table with pointers into webidl data structures is checked when the type is
determined to be a shim.
Ideally we could remove this once we remove the remaining consumers of the
existing shim interfaces.
3. A python code generator which takes in the json XPT files generated in the
previous part, and emits a xptdata.cpp file with the data structures. I did
my best to heavily comment the code.
This code uses the friend class trick to construct the private fields of the
structs, and avoid a dependency on the ordering of fields in xptinfo.h.
The sInterfaces array's order is determined by a generated perfect hash
which is also written into the binary. This should allow for fast lookups by
IID or name of interfaces in memory. The hash function used for the perfect
hash is a simple FNV hash, as they're pretty fast.
For perfect hashing of names, another table is created which contains
indexes into the sInterfaces table. Lookup by name is less common, and this
form of lookup should still be very fast.
4. The necessary Makefiles are updated to use the new code generator, and
generate the file correctly.
This patch adds a python script based on the old typelib.py script which takes
in a parsed XPIDL file, and generates a json-based XPT file to use as a build
intermediate. I did my best to keep the generated format simple.
In the previous patch, one of the files which was deleted is ShimInterfaceInfo.
This is an implementor of nsIInterfaceInfo which exists for legacy reasons, in
order to allow Components.interfaces.nsIDOM* to have the correct constants and
IIDs associated with them.
As that file was deleted, this information now has to be stored in the typelib.
To do this, the information is moved to the xptshim and xptshimfile attributes
on the relevant xpcom interfaces.
xptshim(...) means that this xpcom interface is a shim for the WebIDL interface
with the specified name.
xptshimfile(...) is for use when the webidl interface is declared in another
interface's .webidl file, (in our case, MessageManager.webidl). It contains the
name of the parent binding, such that we can #include the correct file in our
generated code.
This patch does not add the code which uses these changes, only the parsing
logic.
Unfortunately, I wasn't able to figure out a way to make firefox build & run in
the intermediate stages of these commits. Because of this, I am going to just
delete most of the code which I am deleting in the first patch, as I figure that
those are somewhat uninteresting changes, and then make the other changes in the
following patches.
In total, the following things are deleted:
1. All of xpcom/typelib, except for `xpt/tools` - this directory is being
subsumed entirely into xpcom/reflect/xptinfo.
2. Most of the code in xpcom/reflect/xptinfo, it is being rewritten to avoid
allocating and contain all of the necessary data structures.
3. idl-parser's typelib.py XPT generator, as it will be replaced.
4. Most includes of files which have been deleted.
NOTE: xpcom/typelib/xpt/tools/xpt.py was not removed, as it is used by bundling
code & bundling tests, which we don't want to remove yet.
This switches most tests over to use pytest as the runner instead of unittest (taking
advantage of the fact that pytest can run unittest based tests).
There were a couple tests that had failures when swithing to pytest:
config/tests/unit-expandlibs.py
xpcom/idl-parser/xpidl/runtests.py
For these tests, I added a runwith='unittest' argument so that they still run the
same way as before. Once we fix them to use pytest, the unittest logic in mozunit.py
can be deleted.
MozReview-Commit-ID: Gcsz6z8MeOi
--HG--
extra : rebase_source : 3c762422ce0af54cbbe7d9fc20085a2d1ebe7057
XPIDL generated header files contain a |#if 0| block for every interface,
providing the skeleton of the class as it must be implemented in C++. This is
potentially useful, but also very verbose.
This patch removes this code. In a Linux64 debug build, this reduces the total
size of the $OBJDIR/dist/include/nsI*.h files from 11,023,499 bytes to
8,442,350 bytes, a 23.5% reduction. It didn't speed up compilation, though.
--HG--
extra : rebase_source : 65e1e46cffe7c831d83c3308d7ce58c801618dda
Bug 1295053 removed most uses of NS_METHOD and NS_CALLBACK, but one use was
unintentionally left behind (in the XPIDL parser) and another has since crept
in (in MediaDrmCDMProxy.h).
So this patch removes NS_METHOD and NS_CALLBACK. NS_METHOD_(nsresult) and
NS_CALLBACK_(nsresult, T) can still be used for the same purpose, but those
alternatives are less likely to be used unintentionally.
--HG--
extra : rebase_source : a50fc7b2a64a36d1ca9beda81bc0edb8f2ec1934
This deprecates PYTHON_UNIT_TESTS and replaces it with PYTHON_UNITTEST_MANIFESTS.
In the build system, this means python unittests will be treated the same as all
other test suites that use manifestparser. New manifests called 'python.ini' have
been created for all test directories containing python unittests.
MozReview-Commit-ID: IBHG7Thif2D
--HG--
extra : rebase_source : 11a92a2bc544d067946bbd774975140147458caa
Since xpidllex.py and xpidlyacc.py are created deep in the
other-licenses/ply code, we can't easily pass in our FileAvoidWrite
handle from the mozbuild action. As a result, when ply writes out
xpidllex.py, the mozbuild action overwrites the contents of the file
with a new 0-length xpidllex.py. This causes future xpidl invocations to
write out a new xpidllex.py rather than using the pre-built one.
MozReview-Commit-ID: NOC1Wr3MZO
--HG--
extra : rebase_source : a364a0f6f47e1c652bd41c90548fe7cbaf516374
For XPIDL methods, this causes MOZ_MUST_USE to be prepended to the generated
C++ function declaration.
For XPIDL attributes, this causes MOZ_MUST_USE to be prepended to the generated
C++ getter declaration and (if present) setter declaration.
--HG--
extra : rebase_source : e0b2c43235bfbc02db609076e82ca6325e4b0bff
This removes the unnecessary setting of c-basic-offset from all
python-mode files.
This was automatically generated using
perl -pi -e 's/; *c-basic-offset: *[0-9]+//'
... on the affected files.
The bulk of these files are moz.build files but there a few others as
well.
MozReview-Commit-ID: 2pPf3DEiZqx
--HG--
extra : rebase_source : 0a7dcac80b924174a2c429b093791148ea6ac204
We are currently generating typelib data for all interfaces. Apparently
typelib data is only needed for scriptable interfaces. So let's stop
generating typelib data for interfaces that aren't scriptable.
The impact of this is that some typelibs are dropped from
interfaces.xpt, resulting in ~10kb smaller interfaces.xpt:
* nsIDOMCSSValue
* nsIDOMDOMImplementation
* nsIDOMDOMCursor
* nsIProfilerStartParams
* nsIStreamingProtocolMetaData
* nsIDOMCharacterData
* nsIPrintSession
* nsIDOMDocumentFragment
* nsIDOMProcessingInstruction
* nsIDOMElement
* nsIDOMText
* nsIDOMXULElement
* nsIDOMAttr
* nsIDOMGeoPositionError
* nsIXMLHttpRequestEventTarget
* nsIDOMCSSStyleDeclaration
* nsIDOMCSSStyleSheet
* nsIDOMDocument
* nsIDOMClientRect
* nsIDOMMozNamedAttrMap
* nsIDOMNode
* nsIThreadObserver
* nsIDOMDocumentType
* nsIXMLHttpRequestUpload
* nsISelection
* nsIDOMCDATASection
* nsIDOMDOMRequest
* nsIDOMComment
* nsIDOMEvent
MozReview-Commit-ID: 3LYdNYs7Tum
--HG--
extra : rebase_source : 4ed0e6ef761b165108b8581077f2bf7eddd02274
We only ever execute this in one place, so we can just have the main
action do the --regen --cachedir=. mode of operation.
MozReview-Commit-ID: Fis4YBPFjMl
--HG--
extra : rebase_source : f19ac1ad688115c0aee4bf307b72d6207512f702
We can just generate xpidllex.py/xpidlyacc.py in the current directory
rather than one directory higher, and specify this directory as an
include path to xpidl-process.py
MozReview-Commit-ID: KLoGjudc4Y8
--HG--
extra : rebase_source : 8dda268c6490cdfb8b896de9da5b789208584193
This allows us to have a shared superclass that implements the guts of a shared
superinterface, without having the superclass actually inherit the superinterface
(which leads to annoying and unnecessary diamond-inheritance).