<p dir="ltr">One way may be to make 'size' an attribute, cachable and returning a JSFunction wrapping a C++ function returning 1. Not sure this will pass signature tests though.<br>
This can be done as a custom 'size' function also but I guess you need to return the same JS object all the time.</p>
<p dir="ltr">A second approach might be to return the 'size' method bound to the count queuing strategy object. That is easy in JS but I do not know how easy it is within JSC.</p>
<p dir="ltr">IIUC, 'size' is somehow similar to a C++ static class method. A third approach could be to add a 'static' IDL keyword to the binding generator to enable calling static methods of the DOM class. No custom code in that case.<br>
</p>
<p dir="ltr"><br>
</p>
<p dir="ltr">Hope this helps<br>
Y<br>
</p>
<p dir="ltr"><br>
Le mer. 1 juil. 2015 20:07, Geoffrey Garen <<a href="mailto:ggaren@apple.com">ggaren@apple.com</a>> a écrit :</p>
<blockquote><p dir="ltr">Hi Xabier.</p>
<p dir="ltr">Our bindings assume, by default, that the ‘this’ parameter passed to any DOM interface is an object of the interface’s type. This is how most DOM bindings work.</p>
<p dir="ltr">Our bindings also assume that a requested property can be read from the ‘this’ object, which represents the DOM interface.</p>
<p dir="ltr">If you’re going to pass undefined into the size function, you’ve violated both assumptions. (It would be meaningless to remove the type check — the call to size later would just crash anyway.)</p>
<p dir="ltr">The easiest way to make this work is to make the function custom. What exactly did you do when you tried that, and why exactly didn’t it work?</p>
<p dir="ltr">Side note: Shouldn’t this function bear the name “strategySize” rather than “size”?</p>
<p dir="ltr">Geoff</p>
<p dir="ltr">> On Jul 1, 2015, at 10:59 AM, Xabier Rodríguez Calvar <<a href="mailto:calvaris@igalia.com">calvaris@igalia.com</a>> wrote:<br>
><br>
> Hello,<br>
><br>
> I need some help with some JS bindings code. I am implementing<br>
> CountQueuingStrategy [1], which is an object containing two properties,<br>
> one of them a function. That strategy is passed to another<br>
> ReadableStream object [2] and as you can see at step 8, the size method<br>
> is extracted from the strategy and kept inside the stream for later<br>
> use. That use happens at [3], step 5.b.i, when the spec says that we<br>
> have to pass undefined as this (and we do).<br>
><br>
> [1] <a href="https://streams.spec.whatwg.org/#cqs-class">https://streams.spec.whatwg.org/#cqs-class</a><br>
> [2] <a href="https://streams.spec.whatwg.org/#rs-constructor">https://streams.spec.whatwg.org/#rs-constructor</a><br>
> [3] <a href="https://streams.spec.whatwg.org/#enqueue-in-readable-stream">https://streams.spec.whatwg.org/#enqueue-in-readable-stream</a><br>
><br>
> The problem comes when invoking that method at the generated bindings:<br>
><br>
> EncodedJSValue JSC_HOST_CALL<br>
> jsCountQueuingStrategyPrototypeFunctionSize(ExecState* exec)<br>
> {<br>
> JSValue thisValue = exec->thisValue();<br>
> JSCountQueuingStrategy* castedThis =<br>
> jsDynamicCast<JSCountQueuingStrategy*>(thisValue);<br>
> if (UNLIKELY(!castedThis))<br>
> return throwThisTypeError(*exec, "CountQueuingStrategy",<br>
> "size");<br>
> ASSERT_GC_OBJECT_INHERITS(castedThis,<br>
> JSCountQueuingStrategy::info());<br>
> return JSValue::encode(castedThis->size(exec));<br>
> }<br>
><br>
> The problem is that it checks that "this" casts to the class and of<br>
> course it fails because the spec says it has to be undefined. I haven't<br>
> found any way to overcome this, even making the method custom.<br>
><br>
> Any ideas here?<br>
><br>
> Thanks in advance and best regards.<br>
> _______________________________________________<br>
> webkit-dev mailing list<br>
> <a href="mailto:webkit-dev@lists.webkit.org">webkit-dev@lists.webkit.org</a><br>
> <a href="https://lists.webkit.org/mailman/listinfo/webkit-dev">https://lists.webkit.org/mailman/listinfo/webkit-dev</a></p>
<p dir="ltr">_______________________________________________<br>
webkit-dev mailing list<br>
<a href="mailto:webkit-dev@lists.webkit.org">webkit-dev@lists.webkit.org</a><br>
<a href="https://lists.webkit.org/mailman/listinfo/webkit-dev">https://lists.webkit.org/mailman/listinfo/webkit-dev</a><br>
</p>
</blockquote>
<p dir="ltr"><br>
</p>