<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[185464] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/185464">185464</a></dd>
<dt>Author</dt> <dd>youenn.fablet@crf.canon.fr</dd>
<dt>Date</dt> <dd>2015-06-11 12:26:47 -0700 (Thu, 11 Jun 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Bindings generator should generate code for Promise-based APIs
https://bugs.webkit.org/show_bug.cgi?id=145833

Reviewed by Darin Adler.

Covered by existing tests.

* Modules/webaudio/AudioContext.idl: Removing custom binding for resume, suspend and close.
* bindings/js/JSAudioContextCustom.cpp: Ditto.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateHeader): Refactoring to use IsReturningPromise.
(GenerateImplementation): Disabling include for return type if it is a promise.
(GenerateParametersCheck): Adding DeferredWrapper() as argument to the DOM method if JS method returns a promise.
(GenerateImplementationFunctionCall): Added support for promise-returning API.
(IsReturningPromise): Checking whether function is returning a promise.
* bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
(webkit_dom_test_obj_test_promise_function):
* bindings/scripts/test/GObject/WebKitDOMTestObj.h:
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjPrototypeFunctionTestPromiseFunction):
* bindings/scripts/test/ObjC/DOMTestObj.h:
* bindings/scripts/test/ObjC/DOMTestObj.mm:
(-[DOMTestObj testPromiseFunction]):
* bindings/scripts/test/TestObj.idl: Adding promise returning function.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreModuleswebaudioAudioContextidl">trunk/Source/WebCore/Modules/webaudio/AudioContext.idl</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSAudioContextCustomcpp">trunk/Source/WebCore/bindings/js/JSAudioContextCustom.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm">trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestGObjectWebKitDOMTestObjcpp">trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestGObjectWebKitDOMTestObjh">trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp">trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestObjCDOMTestObjh">trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestObjCDOMTestObjmm">trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm</a></li>
<li><a href="#trunkSourceWebCorebindingsscriptstestTestObjidl">trunk/Source/WebCore/bindings/scripts/test/TestObj.idl</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (185463 => 185464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-06-11 18:33:51 UTC (rev 185463)
+++ trunk/Source/WebCore/ChangeLog        2015-06-11 19:26:47 UTC (rev 185464)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2015-06-11  Youenn Fablet  &lt;youenn.fablet@crf.canon.fr&gt;
+
+        Bindings generator should generate code for Promise-based APIs
+        https://bugs.webkit.org/show_bug.cgi?id=145833
+
+        Reviewed by Darin Adler.
+
+        Covered by existing tests.
+
+        * Modules/webaudio/AudioContext.idl: Removing custom binding for resume, suspend and close.
+        * bindings/js/JSAudioContextCustom.cpp: Ditto.
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateHeader): Refactoring to use IsReturningPromise.
+        (GenerateImplementation): Disabling include for return type if it is a promise.
+        (GenerateParametersCheck): Adding DeferredWrapper() as argument to the DOM method if JS method returns a promise.
+        (GenerateImplementationFunctionCall): Added support for promise-returning API.
+        (IsReturningPromise): Checking whether function is returning a promise.
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp:
+        (webkit_dom_test_obj_test_promise_function):
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.h:
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::jsTestObjPrototypeFunctionTestPromiseFunction):
+        * bindings/scripts/test/ObjC/DOMTestObj.h:
+        * bindings/scripts/test/ObjC/DOMTestObj.mm:
+        (-[DOMTestObj testPromiseFunction]):
+        * bindings/scripts/test/TestObj.idl: Adding promise returning function.
+
+
</ins><span class="cx"> 2015-06-08  Simon Fraser  &lt;simon.fraser@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Missing content in UIWebView snapshots sometimes
</span></span></pre></div>
<a id="trunkSourceWebCoreModuleswebaudioAudioContextidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/Modules/webaudio/AudioContext.idl (185463 => 185464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/Modules/webaudio/AudioContext.idl        2015-06-11 18:33:51 UTC (rev 185463)
+++ trunk/Source/WebCore/Modules/webaudio/AudioContext.idl        2015-06-11 19:26:47 UTC (rev 185464)
</span><span class="lines">@@ -50,9 +50,9 @@
</span><span class="cx">     // All panning is relative to this listener.
</span><span class="cx">     readonly attribute AudioListener listener;
</span><span class="cx"> 
</span><del>-    [Custom] Promise suspend();
-    [Custom] Promise resume();
-    [Custom] Promise close();
</del><ins>+    Promise suspend();
+    Promise resume();
+    Promise close();
</ins><span class="cx"> 
</span><span class="cx">     readonly attribute AudioContextState state;
</span><span class="cx">     attribute EventHandler onstatechange;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSAudioContextCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSAudioContextCustom.cpp (185463 => 185464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSAudioContextCustom.cpp        2015-06-11 18:33:51 UTC (rev 185463)
+++ trunk/Source/WebCore/bindings/js/JSAudioContextCustom.cpp        2015-06-11 19:26:47 UTC (rev 185464)
</span><span class="lines">@@ -111,33 +111,6 @@
</span><span class="cx">     return JSValue::encode(CREATE_DOM_WRAPPER(jsConstructor-&gt;globalObject(), AudioContext, audioContext.get()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-JSValue JSAudioContext::suspend(ExecState* state)
-{
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(state, globalObject());
-
-    impl().suspend(DeferredWrapper(state, globalObject(), promiseDeferred));
-
-    return promiseDeferred-&gt;promise();
-}
-
-JSValue JSAudioContext::resume(ExecState* state)
-{
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(state, globalObject());
-
-    impl().resume(DeferredWrapper(state, globalObject(), promiseDeferred));
-
-    return promiseDeferred-&gt;promise();
-}
-
-JSValue JSAudioContext::close(ExecState* state)
-{
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(state, globalObject());
-
-    impl().close(DeferredWrapper(state, globalObject(), promiseDeferred));
-
-    return promiseDeferred-&gt;promise();
-}
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(WEB_AUDIO)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptsCodeGeneratorJSpm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (185463 => 185464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2015-06-11 18:33:51 UTC (rev 185463)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm        2015-06-11 19:26:47 UTC (rev 185464)
</span><span class="lines">@@ -1047,7 +1047,7 @@
</span><span class="cx">                 $needsVisitChildren = 1;
</span><span class="cx">                 push(@headerContent, &quot;#endif\n&quot;) if $conditionalString;
</span><span class="cx">             }
</span><del>-            elsif ($attribute-&gt;signature-&gt;type eq &quot;Promise&quot;) {
</del><ins>+            elsif (IsReturningPromise($attribute)) {
</ins><span class="cx">                 $headerIncludes{&quot;JSDOMPromise.h&quot;} = 1;
</span><span class="cx"> 
</span><span class="cx">                 my $conditionalString = $codeGenerator-&gt;GenerateConditionalString($attribute-&gt;signature);
</span><span class="lines">@@ -2759,7 +2759,7 @@
</span><span class="cx"> 
</span><span class="cx">             next if $isCustom &amp;&amp; $isOverloaded &amp;&amp; $function-&gt;{overloadIndex} &gt; 1;
</span><span class="cx"> 
</span><del>-            AddIncludesForTypeInImpl($function-&gt;signature-&gt;type) unless $isCustom;
</del><ins>+            AddIncludesForTypeInImpl($function-&gt;signature-&gt;type) unless $isCustom or IsReturningPromise($function);
</ins><span class="cx"> 
</span><span class="cx">             my $functionName = GetFunctionName($className, $function);
</span><span class="cx"> 
</span><span class="lines">@@ -3386,6 +3386,8 @@
</span><span class="cx">         $argsIndex++;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    push(@arguments, &quot;DeferredWrapper(exec, castedThis-&gt;globalObject(), promiseDeferred)&quot;) if IsReturningPromise($function);
+
</ins><span class="cx">     push(@arguments, &quot;ec&quot;) if $raisesException;
</span><span class="cx"> 
</span><span class="cx">     return (&quot;$functionName(&quot; . join(&quot;, &quot;, @arguments) . &quot;)&quot;, scalar @arguments);
</span><span class="lines">@@ -3654,9 +3656,17 @@
</span><span class="cx">             push(@implContent, &quot;#else\n&quot;);
</span><span class="cx">             push(@implContent, $indent . &quot;result = &quot; . NativeToJSValue($function-&gt;signature, 1, $interfaceName, $functionString, $thisObject) . &quot;;\n&quot;);
</span><span class="cx">             push(@implContent, &quot;#endif\n&quot;);
</span><ins>+        } elsif (IsReturningPromise($function)) {
+            AddToImplIncludes(&quot;JSDOMPromise.h&quot;);
+
+            push(@implContent, $indent . &quot;auto* promiseDeferred = JSPromiseDeferred::create(exec, castedThis-&gt;globalObject());\n&quot;);
+            push(@implContent, $indent . $functionString . &quot;;\n&quot;);
+            push(@implContent, $indent . &quot;JSValue result = promiseDeferred-&gt;promise();\n&quot;);
+
</ins><span class="cx">         } else {
</span><span class="cx">             push(@implContent, $indent . &quot;JSValue result = &quot; . NativeToJSValue($function-&gt;signature, 1, $interfaceName, $functionString, $thisObject) . &quot;;\n&quot;);
</span><span class="cx">         }
</span><ins>+        # FIXME: In case of IsReturningPromise($function), the function should not throw. Exception should be used to reject the promise callback.
</ins><span class="cx">         push(@implContent, &quot;\n&quot; . $indent . &quot;setDOMException(exec, ec);\n&quot;) if $raisesException;
</span><span class="cx"> 
</span><span class="cx">         if ($codeGenerator-&gt;ExtendedAttributeContains($function-&gt;signature-&gt;extendedAttributes-&gt;{&quot;CallWith&quot;}, &quot;ScriptState&quot;)) {
</span><span class="lines">@@ -4774,6 +4784,13 @@
</span><span class="cx">     return !$interface-&gt;extendedAttributes-&gt;{&quot;NoInterfaceObject&quot;} || $interface-&gt;extendedAttributes-&gt;{&quot;CustomConstructor&quot;};
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+sub IsReturningPromise
+{
+    my $function = shift;
+
+    return $function-&gt;signature-&gt;type eq &quot;Promise&quot;;
+}
+
</ins><span class="cx"> sub IsConstructable
</span><span class="cx"> {
</span><span class="cx">     my $interface = shift;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestGObjectWebKitDOMTestObjcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp (185463 => 185464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp        2015-06-11 18:33:51 UTC (rev 185463)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp        2015-06-11 19:26:47 UTC (rev 185464)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> #include &quot;WebKitDOMDocumentPrivate.h&quot;
</span><span class="cx"> #include &quot;WebKitDOMNodePrivate.h&quot;
</span><span class="cx"> #include &quot;WebKitDOMPrivate.h&quot;
</span><ins>+#include &quot;WebKitDOMPromisePrivate.h&quot;
</ins><span class="cx"> #include &quot;WebKitDOMSVGPointPrivate.h&quot;
</span><span class="cx"> #include &quot;WebKitDOMTestEnumTypePrivate.h&quot;
</span><span class="cx"> #include &quot;WebKitDOMTestNodePrivate.h&quot;
</span><span class="lines">@@ -1551,6 +1552,15 @@
</span><span class="cx">     item-&gt;any(a, b);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+WebKitDOMPromise* webkit_dom_test_obj_test_promise_function(WebKitDOMTestObj* self)
+{
+    WebCore::JSMainThreadNullState state;
+    g_return_val_if_fail(WEBKIT_DOM_IS_TEST_OBJ(self), 0);
+    WebCore::TestObj* item = WebKit::core(self);
+    RefPtr&lt;WebCore::Promise&gt; gobjectResult = WTF::getPtr(item-&gt;testPromiseFunction());
+    return WebKit::kit(gobjectResult.get());
+}
+
</ins><span class="cx"> glong webkit_dom_test_obj_get_read_only_long_attr(WebKitDOMTestObj* self)
</span><span class="cx"> {
</span><span class="cx">     WebCore::JSMainThreadNullState state;
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestGObjectWebKitDOMTestObjh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h (185463 => 185464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h        2015-06-11 18:33:51 UTC (rev 185463)
+++ trunk/Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h        2015-06-11 19:26:47 UTC (rev 185464)
</span><span class="lines">@@ -651,6 +651,17 @@
</span><span class="cx"> webkit_dom_test_obj_any(WebKitDOMTestObj* self, gfloat a, glong b);
</span><span class="cx"> 
</span><span class="cx"> /**
</span><ins>+ * webkit_dom_test_obj_test_promise_function:
+ * @self: A #WebKitDOMTestObj
+ *
+ * Returns: (transfer none): A #WebKitDOMPromise
+ *
+ * Stability: Unstable
+**/
+WEBKIT_API WebKitDOMPromise*
+webkit_dom_test_obj_test_promise_function(WebKitDOMTestObj* self);
+
+/**
</ins><span class="cx">  * webkit_dom_test_obj_get_read_only_long_attr:
</span><span class="cx">  * @self: A #WebKitDOMTestObj
</span><span class="cx">  *
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestJSJSTestObjcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (185463 => 185464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp        2015-06-11 18:33:51 UTC (rev 185463)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp        2015-06-11 19:26:47 UTC (rev 185464)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include &quot;Frame.h&quot;
</span><span class="cx"> #include &quot;HTMLNames.h&quot;
</span><span class="cx"> #include &quot;JSDOMBinding.h&quot;
</span><ins>+#include &quot;JSDOMPromise.h&quot;
</ins><span class="cx"> #include &quot;JSDOMStringList.h&quot;
</span><span class="cx"> #include &quot;JSDocument.h&quot;
</span><span class="cx"> #include &quot;JSEventListener.h&quot;
</span><span class="lines">@@ -154,6 +155,7 @@
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVariadicDoubleMethod(JSC::ExecState*);
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionVariadicNodeMethod(JSC::ExecState*);
</span><span class="cx"> JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAny(JSC::ExecState*);
</span><ins>+JSC::EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestPromiseFunction(JSC::ExecState*);
</ins><span class="cx"> 
</span><span class="cx"> // Attributes
</span><span class="cx"> 
</span><span class="lines">@@ -648,6 +650,7 @@
</span><span class="cx">     { &quot;variadicDoubleMethod&quot;, JSC::Function, NoIntrinsic, (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionVariadicDoubleMethod), (intptr_t) (2) },
</span><span class="cx">     { &quot;variadicNodeMethod&quot;, JSC::Function, NoIntrinsic, (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionVariadicNodeMethod), (intptr_t) (2) },
</span><span class="cx">     { &quot;any&quot;, JSC::Function, NoIntrinsic, (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionAny), (intptr_t) (2) },
</span><ins>+    { &quot;testPromiseFunction&quot;, JSC::Function, NoIntrinsic, (intptr_t)static_cast&lt;NativeFunction&gt;(jsTestObjPrototypeFunctionTestPromiseFunction), (intptr_t) (0) },
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> const ClassInfo JSTestObjPrototype::s_info = { &quot;TestObjectPrototype&quot;, &amp;Base::s_info, 0, CREATE_METHOD_TABLE(JSTestObjPrototype) };
</span><span class="lines">@@ -4423,6 +4426,20 @@
</span><span class="cx">     return JSValue::encode(jsUndefined());
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestPromiseFunction(ExecState* exec)
+{
+    JSValue thisValue = exec-&gt;thisValue();
+    JSTestObj* castedThis = jsDynamicCast&lt;JSTestObj*&gt;(thisValue);
+    if (UNLIKELY(!castedThis))
+        return throwThisTypeError(*exec, &quot;TestObj&quot;, &quot;testPromiseFunction&quot;);
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
+    auto&amp; impl = castedThis-&gt;impl();
+    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(exec, castedThis-&gt;globalObject());
+    impl.testPromiseFunction(DeferredWrapper(exec, castedThis-&gt;globalObject(), promiseDeferred));
+    JSValue result = promiseDeferred-&gt;promise();
+    return JSValue::encode(result);
+}
+
</ins><span class="cx"> void JSTestObj::visitChildren(JSCell* cell, SlotVisitor&amp; visitor)
</span><span class="cx"> {
</span><span class="cx">     auto* thisObject = jsCast&lt;JSTestObj*&gt;(cell);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestObjCDOMTestObjh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h (185463 => 185464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h        2015-06-11 18:33:51 UTC (rev 185463)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.h        2015-06-11 19:26:47 UTC (rev 185464)
</span><span class="lines">@@ -173,4 +173,5 @@
</span><span class="cx"> - (void)variadicDoubleMethod:(double)head tail:(double)tail;
</span><span class="cx"> - (void)variadicNodeMethod:(DOMNode *)head tail:(DOMNode *)tail;
</span><span class="cx"> - (void)any:(float)a b:(int)b;
</span><ins>+- (DOMPromise *)testPromiseFunction;
</ins><span class="cx"> @end
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestObjCDOMTestObjmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm (185463 => 185464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm        2015-06-11 18:33:51 UTC (rev 185463)
+++ trunk/Source/WebCore/bindings/scripts/test/ObjC/DOMTestObj.mm        2015-06-11 19:26:47 UTC (rev 185464)
</span><span class="lines">@@ -1183,6 +1183,12 @@
</span><span class="cx">     IMPL-&gt;any(a, b);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+- (DOMPromise *)testPromiseFunction
+{
+    WebCore::JSMainThreadNullState state;
+    return kit(WTF::getPtr(IMPL-&gt;testPromiseFunction()));
+}
+
</ins><span class="cx"> @end
</span><span class="cx"> 
</span><span class="cx"> WebCore::TestObj* core(DOMTestObj *wrapper)
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsscriptstestTestObjidl"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (185463 => 185464)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl        2015-06-11 18:33:51 UTC (rev 185463)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl        2015-06-11 19:26:47 UTC (rev 185464)
</span><span class="lines">@@ -274,6 +274,8 @@
</span><span class="cx">     // Promise attributes
</span><span class="cx">     [CustomGetter] readonly attribute Promise testPromiseAttr;
</span><span class="cx"> 
</span><ins>+    // Promise function
+    Promise testPromiseFunction();
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> // The following comment should not generate any code.
</span></span></pre>
</div>
</div>

</body>
</html>