<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Bindings generator: Improve support for sharing enums between idl files"
   href="https://bugs.webkit.org/show_bug.cgi?id=158254">158254</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Bindings generator: Improve support for sharing enums between idl files
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>WebKit
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>WebKit Nightly Build
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Unspecified
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Unspecified
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>Normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P2
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Bindings
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>webkit-unassigned&#64;lists.webkit.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>adam.bergkvist&#64;ericsson.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>cdumez&#64;apple.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This can be done in two steps:

1. Define the enum in each idl file, but support sharing the underlying C++ enum. This does not currently work due to duplication of generated enum conversion functions.

2. Allow &quot;importing&quot; an idl enum in an other idl file. This would probably require some work, but would minimize the need for mirrored enums that needs to be synced.

Example where this could be useful:

RTCPeerConnection.idl:

    [StrictTypeChecking, RaisesException] RTCRtpTransceiver addTransceiver(MediaStreamTrack track, optional RTCRtpTransceiverInit init);
    [StrictTypeChecking, RaisesException] RTCRtpTransceiver addTransceiver(DOMString kind, optional RTCRtpTransceiverInit init);

    enum RTCRtpTransceiverDirection { &quot;sendrecv&quot;, &quot;sendonly&quot;, &quot;recvonly&quot;, &quot;inactive&quot; };

    dictionary RTCRtpTransceiverInit {
        RTCRtpTransceiverDirection direction = &quot;sendrecv&quot;;
    };

RTCRtpTransceiver.idl:

    readonly attribute RTCRtpTransceiverDirection direction;
    void setDirection(RTCRtpTransceiverDirection direction);

    enum RTCRtpTransceiverDirection { &quot;sendrecv&quot;, &quot;sendonly&quot;, &quot;recvonly&quot;, &quot;inactive&quot; };</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>