Граф коммитов

196 Коммитов

Автор SHA1 Сообщение Дата
Mike Hommey 2e9a3adec2 Bug 1567739 - Stop using deprecated rust libc integer types in xpidl. r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D38942

--HG--
extra : moz-landing-system : lando
2019-07-23 13:42:44 +00:00
Andrew McCreight 20b03783b4 Bug 1550770 - Error instead of implicitly converting XPCOM interfaces to builtinclass. r=nika
XPIDL has the requirement that [scriptable] interfaces with [notxpcom]
methods or attributes are [builtinclass]. Currently, if you don't
explicitly mark something builtinclass when it should be, then the
XPIDL compiler will just silently treat it like builtinclass. This
means that you can cause the JS implementation of an XPCOM to start
failing without any warning by marking a method notxpcom.

This patch instead makes it an error. A prior patch fixed the existing
instances in the tree that relied on the implicit behavior.

I also added a test that we reject such classes missing builtinclass
at compile time, as well as classes that inherit from builtinclass
interfaces without themselves being builtinclass. I left behind a part
of the runtime test for this behavior, but now this test just ensures
that you can't implement a [builtinclass] interface in JS.

Differential Revision: https://phabricator.services.mozilla.com/D30984

--HG--
extra : moz-landing-system : lando
2019-05-14 17:39:14 +00:00
Brindusan Cristian faf9a5d054 Bug 1550545 - Fix linting failure. r=nbeleuzu CLOSED TREE 2019-05-10 02:06:27 +03:00
Andrew McCreight e42a542e28 Bug 1550545, part 4 - Don't generate the scriptable flag in XPT files. r=nika
We never emit an XPT for an interface that is not scriptable, so this
flag is never used.

Differential Revision: https://phabricator.services.mozilla.com/D30529

--HG--
extra : moz-landing-system : lando
2019-05-09 22:07:52 +00:00
Andrew McCreight a6aec75bcd Bug 1550545, part 3 - Move the logic for notxpcom implying hidden into jsonxpt. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D30528

--HG--
extra : moz-landing-system : lando
2019-05-09 22:07:12 +00:00
Andrew McCreight 051fb7307e Bug 1550545, part 2 - Pass arguments to mk_method bundled up. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D30527

--HG--
extra : moz-landing-system : lando
2019-05-09 22:07:25 +00:00
Andrew McCreight 083d1d97f4 Bug 1550545, part 1 - Remove the unused isScriptable methods. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D30526

--HG--
extra : moz-landing-system : lando
2019-05-09 22:07:07 +00:00
Nika Layzell e71ae1642c Bug 1535486 - Handle the element type correctly with rust XPCOM types, r=mccr8
Before the Array<T> type, the calltype argument could be in, out, or inout,
however with Array<T> the element type was added.

When I added Array<T>, I changed the checks in files which check calltype !=
'in' to instead check 'out' in calltype, such that element would act more like
in in most cases (not adding the outparam *).

However, I never made that change for rust code, as it didn't support Array<T>
at the time. When I turned on Array<T> support for rust code, I forgot to go
through and change the conditions, which lead to this bug.

Differential Revision: https://phabricator.services.mozilla.com/D24283

--HG--
extra : moz-landing-system : lando
2019-03-22 21:32:59 +00:00
Boris Zbarsky 30c26603e0 Bug 1533617 part 3. Add a [can_run_script] xpidl annotation. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D22837

--HG--
extra : moz-landing-system : lando
2019-03-11 15:16:57 +00:00
Nika Layzell 2a718d2775 Bug 1530467 - Add Array<T> support to xpcom rust bindings, r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D21046

--HG--
extra : moz-landing-system : lando
2019-02-26 20:51:19 +00:00
Nika Layzell f2d9e32b48 Bug 1530028 - Remove now-unnecessary NsresultExt trait, r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D20880

--HG--
extra : moz-landing-system : lando
2019-02-25 15:50:14 +00:00
Gurzau Raul fbe889dd73 Backed out changeset f18666cc5793 (bug 1530028) for build bustages on a CLOSED TREE. 2019-02-25 16:55:00 +02:00
Nika Layzell f4b66e3031 Bug 1530028 - Remove now-unnecessary NsresultExt trait, r=froydnj
Differential Revision: https://phabricator.services.mozilla.com/D20880

--HG--
extra : moz-landing-system : lando
2019-02-25 00:23:17 +00:00
Nika Layzell 1c2a9c2b07 Bug 1526382 - Part 1: Split nsID& and nsID* in xpconnect, r=mccr8
Currently the [ref] and [ptr] types share the same underlying
implementation. This is unfortunate, and can cause correctness problems
with outparam refs (as an example).

By using the same tools used to allow other larger objects (such as
jsid, nsTArray, and nsString) to be stored directly in the nsXPTCVariant
object, this patch directly stores the nsID in the nsXPTCVariant object
when calling from JS into C++.

Using this new strategy avoids an nsID* allocation every time we pass
one over XPConnect, and should also allow us to simplify callers.

In addition, some special casing is added to xpidl to make it possible
to use the nsid reference type objects directly inside of Array<T>,
which will allow us to remove `[array] nsIIDPtr` callers.

Differential Revision: https://phabricator.services.mozilla.com/D19175

--HG--
extra : moz-landing-system : lando
2019-02-13 21:42:00 +00:00
Kirk Steuber 0b61416f21 Bug 1525158 - Allow nsresults as outparams r=myk,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D18612

--HG--
extra : moz-landing-system : lando
2019-02-05 02:14:06 +00:00
Boris Zbarsky ce1e741264 Bug 662341. Add support for [notxpcom] annotations on xpidl attributes. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D11796

--HG--
extra : moz-landing-system : lando
2018-11-15 05:07:20 +00:00
Andreea Pavel b9b20a60f7 Backed out changeset 5beaad8a185b (bug 662341) for linting failure on a CLOSED TREE 2018-11-15 06:49:53 +02:00
Boris Zbarsky 1a4cbc3c61 Bug 662341. Add support for [notxpcom] annotations on xpidl attributes. r=nika
Differential Revision: https://phabricator.services.mozilla.com/D11796

--HG--
extra : moz-landing-system : lando
2018-11-15 04:13:36 +00:00
Kyle Machulis b1d077a87a Bug 1505891 - Allow XPIDL CEnums to be infallible; r=froydnj
They're just integers, so there's no reason they need to be fallible
since they're basically a built-in anyways.

Differential Revision: https://phabricator.services.mozilla.com/D11363

--HG--
extra : moz-landing-system : lando
2018-11-08 20:46:27 +00:00
Kyle Machulis cd6f797161 Bug 1498059 - Add CEnum types to XPIDL; r=nika,froydnj
Add CEnum types to XPIDL, allowing for typed enums in C++ instead of
using uintXX_t types. Javascript will still reflect CEnums as
interface level consts.

Depends on D8593

Differential Revision: https://phabricator.services.mozilla.com/D8594

--HG--
extra : moz-landing-system : lando
2018-11-06 00:05:37 +00:00
Kyle Machulis 911d1c3784 Bug 1498059 - Allow 8-bit unsigned consts in XPIDL; , r=nika,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D8593

--HG--
extra : moz-landing-system : lando
2018-11-06 00:05:35 +00:00
Myk Melez 9b692b9cbd Bug 1503031 - use ::nserror::nsresult everywhere in IDL-generated Rust files r=froydnj
After bug 1496622, the IDL parser converts some references to `nsresult` in IDL files to `::nserror::nsresult` in IDL-generated Rust files.  But it doesn't convert others.  It should convert them all consistently, and this patch makes it do so by adding conversion of the return type of attribute getters/setters and references generated by the IDL parser's Typedef class.

MozReview-Commit-ID: 838K8XGjvTx

Differential Revision: https://phabricator.services.mozilla.com/D10121

--HG--
extra : moz-landing-system : lando
2018-10-29 21:23:21 +00:00
Myk Melez 75ccec036c Bug 1496622 - convert Rust nsresult type alias to newtype w/#[repr(transparent)] r=froydnj
MozReview-Commit-ID: AkzSS587MvC

Differential Revision: https://phabricator.services.mozilla.com/D7832

--HG--
extra : moz-landing-system : lando
2018-10-09 16:02:32 +00:00
Nicholas Nethercote c039cd96a7 Bug 1489047 - Remove support for DOMString from the XPIDL compiler. r=nika
--HG--
extra : rebase_source : 933e39a1cd73f17accf7608e0c1a6bffa4835107
2018-09-11 15:14:28 +10:00
Nicholas Nethercote 9d2cf12ce4 Bug 1489010 - Remove XPIDL support for `Null` and `Undefined` value-taking properties on `DOMString` parameters and attributes. r=jorendorff
These properties were added in bug 478251 back when XPIDL was sort of emulating
WebIDL. They are not needed any more, and none of our XPIDL files use them.

--HG--
extra : rebase_source : f2f2c54ae787ad90704074eb114f00c3741d5f88
2018-09-06 13:42:05 +10:00
Kris Maglione 83db11134f Bug 1484496: Part 1 - Add support for symbol properties to XPIDL. r=nika
This patch allows us to define methods or getters/setters for any of the
current set of well-known symbols. Those are defined by adding the [symbol]
attribute to a method:

  [symbol]
  Iterator iterator();

which causes the method to define a property with the well-known symbol which
matches its method name (Symbol.iterator, in this case).

Due to the implementation details of the XPIDL parser, this currently does not
support defining a non-symbol function with the same name as a symbol
function:

  [symbol]
  Iterator iterator();

  [binaryname(OtherIterator)]
  Thing iterator(in nsIDRef aIID);

throws for a duplicate method name, even though there is no actual conflict.

Differential Revision: https://phabricator.services.mozilla.com/D3724

--HG--
extra : rebase_source : 1385e2da93113306730f7c087fe7385dbe668e91
extra : histedit_source : 3afd9fe38e7cbddc5576c2bd1673496dd623e489
2018-08-21 14:08:35 -07:00
Nika Layzell 3869445efd Bug 1474739 - Part 3: Linting fixes on a CLOSED TREE, a=bustage 2018-08-01 18:23:21 -04:00
Nika Layzell 540b4e5eb7 Bug 1474739 - Part 2: Remove all code for XPT shims, r=bzbarsky
Summary: Depends On D2624

Reviewers: bzbarsky!

Tags: #secure-revision

Bug #: 1474739

Differential Revision: https://phabricator.services.mozilla.com/D2625
2018-08-01 18:07:44 -04:00
Nika Layzell 7fa88ded1b Bug 1474369 - Part 8: Rename from Sequence to Array in xpidl, r=mccr8
Summary:
This more closely matches the C++ names, and reflects the fact that the
reflected type is not WebIDL's mozilla::dom::Sequence. The reasoning behind this
type difference is for ergonomics, due to xpidl only being exposed to internal
JS code.

Depends On D2335

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2337
2018-07-31 17:53:03 -04:00
Nika Layzell cb71d3b003 Bug 1474369 - Part 7: Rename [array] to LegacyArray within xpt and xpidl, r=mccr8
Summary:
This is done so we can use Array as the name for the new nsTArray-based
type, rather than having to come up with a new name.

LegacyArray was chosen as the [array] attribute is now effectively deprecated,
and we'd like to remove it ASAP.

Depends On D2334

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2335
2018-07-31 17:53:03 -04:00
Nika Layzell f900f5239d Bug 1474369 - Part 6: Use RefPtr for Array<T> of interface and WebIDL types, r=mccr8
Summary:
This means that using these types involves many fewer footguns, while not
requiring any changes to the actual XPConnect implementation!

Depends on D2111

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2334
2018-07-31 17:53:03 -04:00
Nika Layzell d4c9b9edf4 Bug 1474369 - Part 4: Add support for Sequence<T> types to xpidl and XPConnect, r=mccr8
Summary:
This patch adds support for the `Sequence<T>` type. This is largely a
straightforward type propagation patch, but there are a few notable things:

 1. We allow `[iid_is(x)] Sequence<nsQIResult>`, so Sequence can be Dependent.

 2. `Sequence<T>` is reflected into C++ as a `nsTArray<T>`, which is different
    than WebIDL's `mozilla::dom::Sequence<T>` type. This decision was made for
    general ergonomics reasons, as `nsTArray<T>` is more prevailent throughout
    the codebase, and lengths in this case cannot be controlled by content, as
    XPConnect is only exposed to Chrome JS.

 3. Owned pointers in `Sequence<T>` are not reflected as their owned
    counterparts. For example, `Sequence<nsISupports>` is reflected as
    `nsTArray<nsISupports*>` rather than `nsTArray<RefPtr<nsISupports>>`. This
    was done to avoid depending on `RefPtr<T>` and `T*` having the same
    in-memory representation, however if that is considered an acceptable
    dependency, it would be nice to support that.

 4. We also don't reflect singly-owned pointers as their owned counterparts. For
    example, `nsTArray<nsIIDPtr>` would be reflected as `nsTArray<nsIID*>`
    rather than `nsTArray<mozilla::UniquePtr<nsIID>>`. If we are willing to
    depend on `mozilla::UniquePtr<T>`'s in-memory representation, we could also
    do this, however.

 5. There are no restrictions on what types can appear inside of a `Sequence<T>`
    or what can appear inside an `[array] T`. We may want to add restrictions
    either at the xpidl level or in XPConnect.

Depends On D2109

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2110
2018-07-31 17:53:01 -04:00
Nika Layzell 4d1911e395 Bug 1474369 - Part 3: Add generic type parsing support to xpidl, r=mccr8
Summary:
This patch allows parsing generic types, such as Sequence<T>, in XPIDL. It does
this by introducing a new type, TypeId, which contains both the name string and
an optional list of generic parameters.

Various places which use the xpidl.py library had to be updated to construct one
of these TypeId objects, as TypeId and `str` are not compatible types.

Depends On D2106

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2109
2018-07-31 17:53:00 -04:00
Nika Layzell 345a0af828 Bug 1471726 - Part 1: Correct codegen for XPIDL arrays of JSVals, r=mccr8 2018-07-31 17:52:58 -04:00
Cosmin Sabou e748fd8968 Backed out 15 changesets (bug 1475409, bug 1461450, bug 1474369, bug 1471726) for causing rooting hazards and browser chrome failures. CLOSED TREE
Backed out changeset 7ce27aa3ce68 (bug 1474369)
Backed out changeset a8a4e2414daa (bug 1474369)
Backed out changeset 13c9626970e2 (bug 1474369)
Backed out changeset 9817819b7765 (bug 1475409)
Backed out changeset 39fcebfe6529 (bug 1475409)
Backed out changeset c19ca740d3d1 (bug 1475409)
Backed out changeset b26c90518fca (bug 1474369)
Backed out changeset cbdde0474521 (bug 1474369)
Backed out changeset ccea3049fe0f (bug 1474369)
Backed out changeset e9f6d2544a82 (bug 1474369)
Backed out changeset 99c4d07d4b88 (bug 1474369)
Backed out changeset c721ada8a6d6 (bug 1461450)
Backed out changeset 961379be0f5e (bug 1461450)
Backed out changeset cf2448b2635f (bug 1471726)
Backed out changeset 408961783c95 (bug 1471726)
2018-07-30 20:31:24 +03:00
Boris Zbarsky 27c2e2863d Bug 1347999. Annotate xpidl methods/attributes that can be implemented in script as JS_HAZ_CAN_RUN_SCRIPT. r=froydnj 2018-07-30 11:51:44 -04:00
Nika Layzell 72ed07e711 Bug 1474369 - Part 8: Rename from Sequence to Array in xpidl, r=mccr8
Summary:
This more closely matches the C++ names, and reflects the fact that the
reflected type is not WebIDL's mozilla::dom::Sequence. The reasoning behind this
type difference is for ergonomics, due to xpidl only being exposed to internal
JS code.

Depends On D2335

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2337
2018-07-30 11:31:41 -04:00
Nika Layzell 28fd912fa1 Bug 1474369 - Part 7: Rename [array] to LegacyArray within xpt and xpidl, r=mccr8
Summary:
This is done so we can use Array as the name for the new nsTArray-based
type, rather than having to come up with a new name.

LegacyArray was chosen as the [array] attribute is now effectively deprecated,
and we'd like to remove it ASAP.

Depends On D2334

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2335
2018-07-30 11:31:29 -04:00
Nika Layzell 4bde66e24f Bug 1474369 - Part 6: Use RefPtr for Array<T> of interface and WebIDL types, r=mccr8
Summary:
This means that using these types involves many fewer footguns, while not
requiring any changes to the actual XPConnect implementation!

Depends on D2111

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2334
2018-07-30 11:28:22 -04:00
Nika Layzell 0f6863aece Bug 1474369 - Part 4: Add support for Sequence<T> types to xpidl and XPConnect, r=mccr8
Summary:
This patch adds support for the `Sequence<T>` type. This is largely a
straightforward type propagation patch, but there are a few notable things:

 1. We allow `[iid_is(x)] Sequence<nsQIResult>`, so Sequence can be Dependent.

 2. `Sequence<T>` is reflected into C++ as a `nsTArray<T>`, which is different
    than WebIDL's `mozilla::dom::Sequence<T>` type. This decision was made for
    general ergonomics reasons, as `nsTArray<T>` is more prevailent throughout
    the codebase, and lengths in this case cannot be controlled by content, as
    XPConnect is only exposed to Chrome JS.

 3. Owned pointers in `Sequence<T>` are not reflected as their owned
    counterparts. For example, `Sequence<nsISupports>` is reflected as
    `nsTArray<nsISupports*>` rather than `nsTArray<RefPtr<nsISupports>>`. This
    was done to avoid depending on `RefPtr<T>` and `T*` having the same
    in-memory representation, however if that is considered an acceptable
    dependency, it would be nice to support that.

 4. We also don't reflect singly-owned pointers as their owned counterparts. For
    example, `nsTArray<nsIIDPtr>` would be reflected as `nsTArray<nsIID*>`
    rather than `nsTArray<mozilla::UniquePtr<nsIID>>`. If we are willing to
    depend on `mozilla::UniquePtr<T>`'s in-memory representation, we could also
    do this, however.

 5. There are no restrictions on what types can appear inside of a `Sequence<T>`
    or what can appear inside an `[array] T`. We may want to add restrictions
    either at the xpidl level or in XPConnect.

Depends On D2109

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2110
2018-07-30 11:28:08 -04:00
Nika Layzell 5e6f9e81ab Bug 1474369 - Part 3: Add generic type parsing support to xpidl, r=mccr8
Summary:
This patch allows parsing generic types, such as Sequence<T>, in XPIDL. It does
this by introducing a new type, TypeId, which contains both the name string and
an optional list of generic parameters.

Various places which use the xpidl.py library had to be updated to construct one
of these TypeId objects, as TypeId and `str` are not compatible types.

Depends On D2106

Reviewers: mccr8!

Tags: #secure-revision

Bug #: 1474369

Differential Revision: https://phabricator.services.mozilla.com/D2109
2018-07-30 11:28:06 -04:00
Nika Layzell 3bb3fd9a2a Bug 1471726 - Part 1: Correct codegen for XPIDL arrays of JSVals, r=mccr8 2018-07-30 11:27:49 -04:00
Andrew Halberstadt 9435736ade Bug 1471620 - Skip python-tests locally that don't run with python 3 in CI r=davehunt
This will make sure that when running |mach python-test --python 3| locally,
we only run the tests that also run in CI with python 3 (and therefore pass
presumably).

MozReview-Commit-ID: 3OBr9yLSlSq

--HG--
extra : rebase_source : 456340d0ecdddf1078f2b5b4ebb1eddf3813b26a
2018-06-27 11:10:02 -04:00
Sylvestre Ledru 6d84fa8c1b Bug 1464869 - Fix flake8/pep8 issue by hand in xpcom/ r=Nika
MozReview-Commit-ID: KOzQnlWwVuR

--HG--
extra : rebase_source : e14c57fe3bf7f238399f8860b6a05184b4d65163
2018-05-25 22:17:28 -07:00
Sylvestre Ledru 34a5216fe7 Bug 1464869 - Run autopep8 on xpcom/ r=Nika
MozReview-Commit-ID: JDdoIvkmOIx

--HG--
extra : rebase_source : c23ee8d3da399dd837eccf6a63a50cd50f5e81c6
2018-05-25 21:29:52 -07:00
Nika Layzell c9d0fe3dd2 Bug 1455217 - Part 1: Add an explicit Promise type to xpidl, r=mccr8
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.
2018-05-14 17:55:53 -04:00
Nika Layzell e5e1512c1e Bug 1454568 - Support [infallible] on interfaces and domobjects in xpidl, r=froydnj 2018-05-14 17:55:53 -04:00
Nika Layzell 6969209b41 Bug 1444991 - Part 2: Parse webidl productions in xpidl, r=mccr8
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.
2018-04-17 19:21:00 -04:00
Nika Layzell be8b24333a Bug 1444991 - Part 1: Read webidl's Bindings.conf, and pass it into xpidl, r=mccr8
This information is read in order to handle correctly selecting the native
type and header files for WebIDL types.
2018-04-17 19:20:58 -04:00
Nika Layzell 04547a4a00 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-17 19:20:55 -04:00