Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add [LegacyNamespace] to allow defining an interface in a namespace #425

Merged
merged 5 commits into from
Aug 30, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add [InNamespace] to allow defining an interface in a namespace
This is necessary to specify certain APIs such as WebAssembly,
which includes several constructors as properties of the root
WebAssembly object. See a WebAssembly draft specification where
this is in use at https://github.com/littledan/spec/blob/new-js.bs/document/JS.bs
littledan committed Aug 25, 2017
commit b79d96063edbc95755811fd568d3ef45a5593021
48 changes: 47 additions & 1 deletion index.bs
Original file line number Diff line number Diff line change
@@ -8449,6 +8449,48 @@ corresponding to [=interface members=].
</div>


<h4 id="InNamespace" extended-attribute lt="InNamespace">[InNamespace]</h4>

If the [{{InNamespace}}] [=extended attribute=] appears on an [=interface=], it indicates that
the [=interface object=] for this interface will not be created as a property of the global
object, but rather the namespace which is the argument to the extended attribute.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"but rather as a property of" is clearer, I think

"namespace identified by the argument", I think

[=namespace=]

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


The [{{InNamespace}}] extended attribute [=takes an identifier|take an identifier=].
This identifier must be the identifier of a namespace.

The [{{InNamespace}}] and [{{NoInterfaceObject}}]
extended attributes must not be specified on the same interface.

The [{{InNamespace}}] extended attribute
must not be used on a [=callback interface=].

The [=class string=] of an interface with the [{{InNamespace}}] extended
attribute is the concatenation of the class string of the namespace, <code>"."</code>,
and the class string that the interface would otherwise have without this
extended attribute.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should not be located here but instead be a modification to

The class string of a platform object that implements one or more interfaces must be the identifier of the primary interface of the platform object.

Also, no <code> around strings in Web IDL, it appears.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


See [[#namespace-object]] for details on how an interface is exposed on a namespace.


<div class="example">
The following [=IDL fragment=] defines a [=namespace=] and an [=interface=] which
uses [{{InNamespace}}] to be defined inside of it.

<pre highlight="webidl">
namespace Foo { };

[InNamespace=Foo, Constructor]
interface Bar { };
</pre>

In an ECMAScript implementation of the above namespace and interface, the
constructor Bar can be accessed as follows:

<pre highlight="js">
var instance = new Foo.Bar();
</pre>
</div>

<h4 id="LegacyArrayClass" extended-attribute lt="LegacyArrayClass">[LegacyArrayClass]</h4>

<div class="advisement">
@@ -10135,7 +10177,7 @@ Note: The HTML Standard defines how a security check is performed. [[!HTML]]

For every non-callback [=interface=] that is [=exposed=] in
a given ECMAScript global environment and that is not declared with
the [{{NoInterfaceObject}}] [=extended attribute=],
the [{{NoInterfaceObject}}] or [{{InNamespace}}] [=extended attribute|extended attributes=],
a corresponding property must exist on the ECMAScript environment's global object.
The name of the property is the [=identifier=] of the interface,
and its value is an object called the <dfn id="dfn-interface-object" export>interface object</dfn>.
@@ -12651,6 +12693,10 @@ The characteristics of a namespace object are described in [[#namespace-object]]
1. Let |F| be the result of [=creating an operation function|creating an operation function=]
given |op|, |namespace|, and |realm|.
1. Perform [=!=] [=CreateDataProperty=](|namespaceObject|, |op|'s [=identifier=], |F|).
1. For each [=exposed=] [=interface=] |intr| which has the [{{InNamespace}}] extended attribute, with the identifier of this namespace as its argument,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrap to 100 chars here too

[=identifier=]

Just interface instead of intr is nicer, I think.

No comma before "with", I think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

1. Let |I| be the [=interface object=] for |intr|.
1. Let |newDesc| be the PropertyDescriptor{ \[[Writable]]: <emu-val>true</emu-val>, \[[Enumerable]]: <emu-val>false</emu-val>, \[[Configurable]]: <emu-val>true</emu-val>, \[[Value]]: |I| }.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like at this point we don't put spaces after { and before } in Web IDL.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

1. Perform [=!=] [=DefinePropertyOrThrow=](|namespaceObject|, |intr|'s [=identifier=], |newDesc|).
</div>