New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 701410 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
OoO until Feb 4th
Closed: Mar 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug

Blocking:
issue 700370



Sign in to add a comment

bindings: Container types inside unions do not include/forward-declare all their dependencies

Project Member Reported by raphael....@intel.com, Mar 14 2017

Issue description

Spun off https://bugs.chromium.org/p/chromium/issues/detail?id=700225#c8.

If one has an IDL construct like this:
  void func((boolean or sequence<Element>) arg);

in an interface, the IDL compiler will generate two union files, BooleanOrElementSequence.cpp and BooleanOrElementSequence.h.

BooleanOrElementSequence.h contains declarations such as:
  const HeapVector<Member<Element>>& getAsElementSequence() const;
  HeapVector<Member<Element>> m_elementSequence;

However, BooleanOrElementSequence.h does not forward-declare Element, neither does it include Element.h (or V8Element.h), which leads to build failures. V8Element.h is only included by BooleanOrElementSequence.cpp.

This applies to unions which have a sequence<T> and/or a record<K, T>, and T is another union, an IDL interface and any types that will generate custom header files.
 
Status: Started (was: Assigned)
Project Member

Comment 2 by bugdroid1@chromium.org, Mar 16 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8552274ebe052e07472a852e37f6cbbe73bbecda

commit 8552274ebe052e07472a852e37f6cbbe73bbecda
Author: raphael.kubo.da.costa <raphael.kubo.da.costa@intel.com>
Date: Thu Mar 16 09:08:51 2017

bindings: Correctly expand all class/header dependencies in unions.

Prior to this CL, an IDL construct like this:

    void func((boolean or sequence<Element>) arg);

would generate two union files, BooleanOrElementSequence.cpp and
BooleanOrElementSequence.h. BooleanOrElementSequence.h contains declarations
such as:

    const HeapVector<Member<Element>>& getAsElementSequence() const;
    HeapVector<Member<Element>> m_elementSequence;

However, it does not forward-declare Element, nor does it include
Element.h (or V8Element.h). Only BooleanOrElementSequence.cpp includes
V8Element.h, leading to build failures.

This affected any types inside unions that require forward declarations
and additional headers to be included which were inside a container type,
such as a record or a sequence. For instance, the constructs below were all
problematic:
* (boolean or sequence<Element>)
* (float or sequence<(boolean or long)>)
* (double or record<ByteString, Element>)

Solve this by expanding v8_union._update_includes_and_forward_decls() and
making it more similar to code_generator_v8's depending_union_type() and
TypedefResolver:
* If we're parsing a container type (ie. a record or a sequence), we call
  the function recursively to make sure all headers/forward declarations are
  taken care of.
* If we're parsing a union type, the union was inside a container type (as
  otherwise it would have been broken up by us looping through flattened
  union members), in which case we forward-declare the union and include its
  header in the outer union's .cpp file.

BUG= 701410 
R=bashi@chromium.org,haraken@chromium.org,yukishiino@chromium.org

Review-Url: https://codereview.chromium.org/2750003003
Cr-Commit-Position: refs/heads/master@{#457381}

[modify] https://crrev.com/8552274ebe052e07472a852e37f6cbbe73bbecda/third_party/WebKit/Source/bindings/scripts/code_generator_v8.py
[modify] https://crrev.com/8552274ebe052e07472a852e37f6cbbe73bbecda/third_party/WebKit/Source/bindings/scripts/v8_union.py
[modify] https://crrev.com/8552274ebe052e07472a852e37f6cbbe73bbecda/third_party/WebKit/Source/bindings/tests/idls/core/TestObject.idl
[add] https://crrev.com/8552274ebe052e07472a852e37f6cbbe73bbecda/third_party/WebKit/Source/bindings/tests/results/core/BooleanOrElementSequence.cpp
[add] https://crrev.com/8552274ebe052e07472a852e37f6cbbe73bbecda/third_party/WebKit/Source/bindings/tests/results/core/BooleanOrElementSequence.h
[modify] https://crrev.com/8552274ebe052e07472a852e37f6cbbe73bbecda/third_party/WebKit/Source/bindings/tests/results/core/ByteStringSequenceSequenceOrByteStringByteStringRecord.h
[add] https://crrev.com/8552274ebe052e07472a852e37f6cbbe73bbecda/third_party/WebKit/Source/bindings/tests/results/core/DoubleOrLongOrBooleanSequence.cpp
[add] https://crrev.com/8552274ebe052e07472a852e37f6cbbe73bbecda/third_party/WebKit/Source/bindings/tests/results/core/DoubleOrLongOrBooleanSequence.h
[modify] https://crrev.com/8552274ebe052e07472a852e37f6cbbe73bbecda/third_party/WebKit/Source/bindings/tests/results/core/DoubleOrStringOrDoubleOrStringSequence.cpp
[modify] https://crrev.com/8552274ebe052e07472a852e37f6cbbe73bbecda/third_party/WebKit/Source/bindings/tests/results/core/DoubleOrStringOrDoubleOrStringSequence.h
[add] https://crrev.com/8552274ebe052e07472a852e37f6cbbe73bbecda/third_party/WebKit/Source/bindings/tests/results/core/ElementSequenceOrByteStringDoubleOrStringRecord.cpp
[add] https://crrev.com/8552274ebe052e07472a852e37f6cbbe73bbecda/third_party/WebKit/Source/bindings/tests/results/core/ElementSequenceOrByteStringDoubleOrStringRecord.h
[add] https://crrev.com/8552274ebe052e07472a852e37f6cbbe73bbecda/third_party/WebKit/Source/bindings/tests/results/core/LongOrBoolean.cpp
[add] https://crrev.com/8552274ebe052e07472a852e37f6cbbe73bbecda/third_party/WebKit/Source/bindings/tests/results/core/LongOrBoolean.h
[modify] https://crrev.com/8552274ebe052e07472a852e37f6cbbe73bbecda/third_party/WebKit/Source/bindings/tests/results/core/NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord.cpp
[modify] https://crrev.com/8552274ebe052e07472a852e37f6cbbe73bbecda/third_party/WebKit/Source/bindings/tests/results/core/NodeOrLongSequenceOrEventOrXMLHttpRequestOrStringOrStringByteStringOrNodeListRecord.h
[modify] https://crrev.com/8552274ebe052e07472a852e37f6cbbe73bbecda/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.cpp
[modify] https://crrev.com/8552274ebe052e07472a852e37f6cbbe73bbecda/third_party/WebKit/Source/bindings/tests/results/core/V8TestObject.h

Status: Fixed (was: Started)

Sign in to add a comment