Closed Bug 909639 Opened 12 years ago Closed 12 years ago

Include fewer headers in binding implementation files

Categories

(Core :: DOM: Core & HTML, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla26

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

(Blocks 1 open bug)

Details

Attachments

(4 files)

Even near-empty binding files include lots of stuff. We should stop doing that.
Blocks: includehell
Comment on attachment 795830 [details] [diff] [review] part 1. Refactor callForEachType to return a generator so we can use it more easily, and rename it to getAllTypes. Review of attachment 795830 [details] [diff] [review]: ----------------------------------------------------------------- ::: dom/bindings/Codegen.py @@ +609,5 @@ > # Now find all the things we'll need as arguments because we > # need to wrap or unwrap them. > bindingHeaders = set() > declareIncludes = set(declareIncludes) > + def addHeadersForType(typeInfo): Could be def addHeadersForType((t, descriptor, dictionary)):
Comment on attachment 795830 [details] [diff] [review] part 1. Refactor callForEachType to return a generator so we can use it more easily, and rename it to getAllTypes. Not a fan of generators, but ok. And Ms2ger's suggestion is good.
Attachment #795830 - Flags: review?(bugs) → review+
Comment on attachment 795831 [details] [diff] [review] part 2. Refactor our computation of whether we need the nsDOMQS header to make it easier to do similar other things. >@@ -852,16 +852,19 @@ def UnionConversions(descriptors, dictio > for f in t.flatMemberTypes: > f = f.unroll() > if f.isInterface(): > if f.isSpiderMonkeyInterface(): > headers.add("jsfriendapi.h") > headers.add("mozilla/dom/TypedArray.h") > elif not f.inner.isExternal(): > headers.add(CGHeaders.getDeclarationFilename(f.inner)) >+ if (f.isGeckoInterface() and >+ providers[0].getDescriptor(f.inner.identifier.name).hasXPConnectImpls): >+ headers.add("nsDOMQS.h") [0] could use some comment. It is rather magical and one needs to look at getRelevantProviders to understand what it means. > > # Add header includes. >+ bindingHeaders = [header for (header, include) in >+ bindingHeaders.iteritems() if include] Not exactly easy to parse. This syntax nicely splits the important parts aside; header in the beginning and 'if include' at the end... But given this is python, I don't expect anything better :)
Attachment #795831 - Flags: review?(bugs) → review+
Comment on attachment 795832 [details] [diff] [review] part 3. Move our various conditional headers to the new bindingHeaders setup. nice
Attachment #795832 - Flags: review?(bugs) → review+
Comment on attachment 795833 [details] [diff] [review] part 4. Make previously-unconditional headers conditional. > curr = CGList([CGForwardDeclarations(config, descriptors, > mainCallbacks, workerCallbacks, > dictionaries, > callbackDescriptors + jsImplemented), >- CGWrapper(CGGeneric("using namespace mozilla::dom;"), >- defineOnly=True), Surprising, but if it compiles...
Attachment #795833 - Flags: review?(bugs) → review+
> def addHeadersForType((t, descriptor, dictionary)): Oh, spiffy. > [0] could use some comment. Will do. > Surprising, but if it compiles... It does, because everything after this point is wrapped in "namespace mozilla { namespace dom {".
Blocks: 909971
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: