gecko-dev/xpcom/reflect/xptinfo/moz.build

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

22 строки
474 B
Plaintext
Исходник Обычный вид История

# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
UNIFIED_SOURCES += [
Bug 1444745 - Part 4: Rewrite xptinfo, and write a new xptcodegen.py to generate the required datastructures, r=mccr8 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.
2018-04-05 01:44:45 +03:00
"xptinfo.cpp",
]
Bug 1444745 - Part 4: Rewrite xptinfo, and write a new xptcodegen.py to generate the required datastructures, r=mccr8 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.
2018-04-05 01:44:45 +03:00
SOURCES += [
"!xptdata.cpp",
]
EXPORTS += [
"xptinfo.h",
]
include("/ipc/chromium/chromium-config.mozbuild")
FINAL_LIBRARY = "xul"