<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>156946</bug_id>
          
          <creation_ts>2016-04-22 21:33:16 -0700</creation_ts>
          <short_desc>[WebIDL] Make ExceptionCode the first parameter instead of the last when using [RaisesException]</short_desc>
          <delta_ts>2016-11-08 09:04:20 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Bindings</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=156939</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Chris Dumez">cdumez</reporter>
          <assigned_to name="Chris Dumez">cdumez</assigned_to>
          <cc>darin</cc>
    
    <cc>sam</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1186572</commentid>
    <comment_count>0</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2016-04-22 21:33:16 -0700</bug_when>
    <thetext>Make ExceptionCode the first parameter instead of the last when using [RaisesException].

Whenever a method is marked as [RaisesException], we currently pass an extra ExceptionCode&amp; as last parameter to the implementation method. The issue with it being last is when we have optional parameters. This forces people to add overloads instead of using inline default parameter values in the C++.

E.g.
IDL:
[RaisesException] ScriptProcessorNode createScriptProcessor(unsigned long bufferSize, optional unsigned long numberOfInputChannels, optional unsigned long numberOfOutputChannels);
    
C++:
RefPtr&lt;ScriptProcessorNode&gt; createScriptProcessor(size_t bufferSize, ExceptionCode&amp;);
RefPtr&lt;ScriptProcessorNode&gt; createScriptProcessor(size_t bufferSize, size_t numberOfInputChannels, ExceptionCode&amp;);
RefPtr&lt;ScriptProcessorNode&gt; createScriptProcessor(size_t bufferSize, size_t numberOfInputChannels, size_t numberOfOutputChannels, ExceptionCode&amp;);

Would become:
RefPtr&lt;ScriptProcessorNode&gt; createScriptProcessor(ExceptionCode&amp;, size_t bufferSize, size_t numberOfInputChannels = 2, size_t numberOfOutputChannels = 2);</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1186573</commentid>
    <comment_count>1</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2016-04-22 21:33:31 -0700</bug_when>
    <thetext>Any objections?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1186682</commentid>
    <comment_count>2</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2016-04-23 17:00:54 -0700</bug_when>
    <thetext>A better approach would be to come up with a way for the return value to be a union of the other return value type and an ExceptionCode. We could make a class template that is a bit like Optional&lt;&gt; that allows a value either of type T or an ExceptionCode. This would be more elegant than an out argument, regardless of argument ordering.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1186684</commentid>
    <comment_count>3</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2016-04-23 17:32:31 -0700</bug_when>
    <thetext>(In reply to comment #2)
&gt; A better approach would be to come up with a way for the return value to be
&gt; a union of the other return value type and an ExceptionCode. We could make a
&gt; class template that is a bit like Optional&lt;&gt; that allows a value either of
&gt; type T or an ExceptionCode. This would be more elegant than an out argument,
&gt; regardless of argument ordering.

Ok, that sound worth exploring indeed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1186732</commentid>
    <comment_count>4</comment_count>
    <who name="youenn fablet">youennf</who>
    <bug_when>2016-04-24 05:00:06 -0700</bug_when>
    <thetext>Sounds good to me.
I am not sure whether we would like to remove RaisesException keyword, but it seems like this may help doing  meta programming.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1186753</commentid>
    <comment_count>5</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2016-04-24 10:00:51 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; I am not sure whether we would like to remove RaisesException keyword, but
&gt; it seems like this may help doing  meta programming.

I would very much like to remove those keywords about raising exceptions if we can get the code generated in a way that’s still just as efficient. And I agree there’s a good chance we can with overloading and various meta-programming techniques.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1249049</commentid>
    <comment_count>6</comment_count>
    <who name="Darin Adler">darin</who>
    <bug_when>2016-11-08 09:04:20 -0800</bug_when>
    <thetext>I did the ExceptionOr thing, so we won’t have to do this.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>