Re: [webkit-dev] Invocation with undefined this on JS binding object
O Mér, 01-07-2015 ás 18:48 +, youenn fablet escribiu: 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. I was thinking of trying this, yes. 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. I thought of this too. I will probably go to the first case and then using that as a use case to extend the bindings with a [StaticNonObjectMethod] idl attribute. Br. signature.asc Description: This is a digitally signed message part ___ webkit-dev mailing list webkit-dev@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-dev
Re: [webkit-dev] Invocation with undefined this on JS binding object
Hi, O Mér, 01-07-2015 ás 11:07 -0700, Geoffrey Garen escribiu: What exactly did you do when you tried that, and why exactly didn’t it work? What I tried was running the tests, concretely streams/reference -implementation/count-queuing-strategy.html and subtest Correctly governs the return value of a ReadableStream\'s enqueue function (HWM = 0) which causes enqueue to be called and therefore the readableStream@strategySize function to be run with undefined this, that was previously assigned from the size method of a newly created CountQueuingStrategy. Side note: Shouldn’t this function bear the name “strategySize” rather than “size”? No, the spec says that our internal slot at ReadableStream should be called strategySize [1], but it clearly states that the method at CountQueuingStrategy should be called size [2]. Besides this, the reference implementation tests also operate on this assumption. [1] https://streams.spec.whatwg.org/#rs-internal-slots [2] https://streams.spec.whatwg.org/#cqs-class-definition Thanks and best regards. signature.asc Description: This is a digitally signed message part ___ webkit-dev mailing list webkit-dev@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-dev
[webkit-dev] Invocation with undefined this on JS binding object
Hello, I need some help with some JS bindings code. I am implementing CountQueuingStrategy [1], which is an object containing two properties, one of them a function. That strategy is passed to another ReadableStream object [2] and as you can see at step 8, the size method is extracted from the strategy and kept inside the stream for later use. That use happens at [3], step 5.b.i, when the spec says that we have to pass undefined as this (and we do). [1] https://streams.spec.whatwg.org/#cqs-class [2] https://streams.spec.whatwg.org/#rs-constructor [3] https://streams.spec.whatwg.org/#enqueue-in-readable-stream The problem comes when invoking that method at the generated bindings: EncodedJSValue JSC_HOST_CALL jsCountQueuingStrategyPrototypeFunctionSize(ExecState* exec) { JSValue thisValue = exec-thisValue(); JSCountQueuingStrategy* castedThis = jsDynamicCastJSCountQueuingStrategy*(thisValue); if (UNLIKELY(!castedThis)) return throwThisTypeError(*exec, CountQueuingStrategy, size); ASSERT_GC_OBJECT_INHERITS(castedThis, JSCountQueuingStrategy::info()); return JSValue::encode(castedThis-size(exec)); } The problem is that it checks that this casts to the class and of course it fails because the spec says it has to be undefined. I haven't found any way to overcome this, even making the method custom. Any ideas here? Thanks in advance and best regards. signature.asc Description: This is a digitally signed message part ___ webkit-dev mailing list webkit-dev@lists.webkit.org https://lists.webkit.org/mailman/listinfo/webkit-dev