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
Represent objects with both specified and unspecified members #568
Comments
I don't understand why they don't use the types you suggest instead; can you elaborate? |
The WebRTC spec defines RTCStatsReport as:
The RTCStats-derived dictionaries are defined in a separate spec by dictionary inheritance. // The base dictionary in WebRTC
dictionary RTCStats {
required DOMHighResTimeStamp timestamp;
required RTCStatsType type;
required DOMString id;
};
// The "Identifiers for WebRTC's Statistics API" spec shows several subdictionaries
dictionary RTCRtpStreamStats : RTCStats {
unsigned long ssrc;
DOMString kind;
DOMString transportId;
DOMString codecId;
unsigned long firCount;
unsigned long pliCount;
unsigned long nackCount;
unsigned long sliCount;
unsigned long long qpSum;
};
dictionary RTCCodecStats : RTCStats: {
// ...
};
// ... So the RTCStatsReport is expected to include those dictionaries as it is, not reduced as RTCStats. const rtcStatsReport = await receiver.getStats();
rtcStatsReport.get(key).ssrc // not in base RTCStats but should exist when appropriate Edit: The keyframes case is different that it even has no subdictionaries; Any CSS property names should be able to be represented as dictionary field names. |
Looking at https://heycam.github.io/webidl/#es-map-get-has, I think the WebRTC spec could be written in a way that would preserve the sub-dictionaries' properties. (Unfortunately, the spec has so much hand-waving that there's no way to tell what's supposed to be going on.) It wouldn't work for read-write maplikes with derived dictionaries, but I guess that problem is not specific to maplikes. I don't know what's going on with the keyframes case; too much prose. |
dictionary Keyframe {
// ... property-value pairs ...
// i.e. DOMString propertyName
double? offset = null;
DOMString easing = "linear";
CompositeOperation composite;
}; // This constructor receives `sequence<Keyframe>`, but specced as `object`
new SharedKeyframeList([
{ transform: 'translateY(0px)' }, // a key-value pair not specced in Keyframe, but has a meaning
{ transform: 'translateY(-300px)' }
]); The spec's algorithm gets the ES object, run the ES-to-dictionary conversion explicitly, and then again extracts remaining fields from the original object. |
Wow, who came up with that? |
Web IDL is meant to represent patterns that are:
People can define arbitrarily complex processing of input, of course; that's what the In this case, we have two specs that both use |
IMO the issue there is that the ES-to-dictionary algorithm ignores any unspecified fields. If we have some way to get the unspecified fields without using |
Above we have two use cases described:
This could be addressed by something which acts like a dictionary but also snapshots the set of property names and values on the object or something. But we have exactly one use case so far, and it's not clear that anyone else will want to do this, and if so whether they would want it to work the way the keyframe case does (e.g. ignoring prototype properties). |
Adding WebCrypto case which also uses [SecureContext,Exposed=(Window,Worker)]
interface CryptoKey {
readonly attribute KeyType type;
readonly attribute boolean extractable;
readonly attribute object algorithm; // union of subdictionaries of KeyAlgorithm
readonly attribute object usages; // just returns a sequence.
}; |
Right, for the "union of dictionaries" case as a return value, |
My point is for automation and tooling rather than spec authoring itself, but probably yes. Today I saw that Permissions API also uses
|
Note that the union of dictionaries case is also filed in #57. |
I've seen specs that use
object
to represent partially specified types:https://www.w3.org/TR/web-animations/#the-sharedkeyframelist-interface
http://w3c.github.io/webrtc-pc/#rtcstatsreport-object
Tools e.g. TSJS-lib-generator have to manually override those
object
s.Can we get a better way to spec those types in IDL?
The text was updated successfully, but these errors were encountered: