Re: [heycam/webidl] Define "implements" checks using internal slots (#595)

littledan commented on this pull request.



> @@ -12337,18 +12336,73 @@ The value of the [=function object=]’s <code class="idl">name</code> property
 
 <h3 id="es-platform-objects">Platform objects implementing interfaces</h3>
 
+<div algorithm>
+    An ECMAScript value |value| <dfn id="es-is-platform-object">is a platform object</dfn>
+    if [$Type$](|value|) is Object and if |value| has a \[[PrimaryInterface]] internal slot.
+</div>
+
+<div algorithm>
+    An ECMAScript value |value| <dfn export>implements</dfn> an [=interface=] |interface|
+    if |value| [=is a platform object=] and one of the following is true:
+    <ul>
+        <li>|value|.\[[PrimaryInterface]] is |interface|.</li>
+        <li>The set of [=inherited interfaces=] of |value|.\[[PrimaryInterface]] contains |interface|.</li>

What V8 does, if I understand the code correctly, is that hidden classes have a "constructor" slot, which has a reference to the "function template" used to make the platform object. That same function template is instantiated on each realm, so it's 1:1 with an interface declaration. The function template has a "parent", which is iterated up through during the brand check. The bindings generator creates a "signature" which is just a wrapper around a function template, and passes it to the function constructor, to produce a function which will include the check on the receiver.

I was going to write the spec using the `[[PlatformBrand]]` internal slot, but when I saw that Chrome implements this in a way that corresponds in an even more straightforward way to existing IDL concepts, I went with that.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/pull/595#discussion_r240174265

Received on Monday, 10 December 2018 11:27:46 UTC