mirror of
https://github.com/servo/servo.git
synced 2025-09-29 16:19:14 +01:00
script_bindings: Assert that serializable/transferable types have accurate WebIDL annotations (#38615)
These changes add compile-time assertions that: * any type that implements the Serializable/Transferable trait has a `[Serializable]` or `[Transferable]` annotation in the interface WebIDL * any WebIDL interface with the `[Serializable]` or `[Transferable]` annotation implements the corresponding trait This is useful because it means that WebIDL definitions will be less confusing if you're trying to figure out whether Servo supports serializing/transferring a particular interface type. It also makes fixing #21715 in the future a little bit easier, because the annotations will remain up to date. Testing: compile-time only; no point in writing tests for this since it involves webidl codegen. --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
0d6d434e59
commit
bd9bb77295
18 changed files with 84 additions and 27 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
// https://w3c.github.io/FileAPI/#blob
|
||||
|
||||
[Exposed=(Window,Worker)]
|
||||
[Exposed=(Window,Worker), Serializable]
|
||||
interface Blob {
|
||||
[Throws] constructor(optional sequence<BlobPart> blobParts,
|
||||
optional BlobPropertyBag options = {});
|
||||
|
|
|
@ -269,7 +269,7 @@ dictionary ImageDataSettings {
|
|||
};
|
||||
|
||||
[Exposed=(Window,Worker),
|
||||
Serializable]
|
||||
/*Serializable*/]
|
||||
interface ImageData {
|
||||
[Throws] constructor(unsigned long sw, unsigned long sh, optional ImageDataSettings settings = {});
|
||||
[Throws] constructor(ImageDataArray data, unsigned long sw,
|
||||
|
|
|
@ -8,7 +8,7 @@ enum KeyType { "public", "private", "secret" };
|
|||
|
||||
enum KeyUsage { "encrypt", "decrypt", "sign", "verify", "deriveKey", "deriveBits", "wrapKey", "unwrapKey" };
|
||||
|
||||
[SecureContext, Exposed=(Window,Worker), Serializable, Pref="dom_crypto_subtle_enabled"]
|
||||
[SecureContext, Exposed=(Window,Worker), /*Serializable,*/ Pref="dom_crypto_subtle_enabled"]
|
||||
interface CryptoKey {
|
||||
readonly attribute KeyType type;
|
||||
readonly attribute boolean extractable;
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
|
||||
[
|
||||
ExceptionClass,
|
||||
Exposed=(Window,Worker,Worklet,DissimilarOriginWindow)
|
||||
Exposed=(Window,Worker,Worklet,DissimilarOriginWindow),
|
||||
Serializable,
|
||||
]
|
||||
interface DOMException {
|
||||
[Throws] constructor(optional DOMString message="", optional DOMString name="Error");
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
*/
|
||||
|
||||
// http://dev.w3.org/fxtf/geometry/Overview.html#dompoint
|
||||
[Exposed=(Window,Worker,PaintWorklet)]
|
||||
[Exposed=(Window,Worker,PaintWorklet),
|
||||
Serializable]
|
||||
interface DOMPoint : DOMPointReadOnly {
|
||||
[Throws] constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
|
||||
optional unrestricted double z = 0, optional unrestricted double w = 1);
|
||||
|
|
|
@ -10,7 +10,8 @@
|
|||
*/
|
||||
|
||||
// http://dev.w3.org/fxtf/geometry/Overview.html#dompointreadonly
|
||||
[Exposed=(Window,Worker,PaintWorklet)]
|
||||
[Exposed=(Window,Worker,PaintWorklet),
|
||||
Serializable]
|
||||
interface DOMPointReadOnly {
|
||||
[Throws] constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
|
||||
optional unrestricted double z = 0, optional unrestricted double w = 1);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// https://drafts.fxtf.org/geometry/#domrect
|
||||
|
||||
[Exposed=(Window,Worker),
|
||||
Serializable,
|
||||
/*Serializable,*/
|
||||
LegacyWindowAlias=SVGRect]
|
||||
interface DOMRect : DOMRectReadOnly {
|
||||
[Throws] constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
// https://drafts.fxtf.org/geometry/#domrect
|
||||
|
||||
[Exposed=(Window,Worker),
|
||||
Serializable]
|
||||
/*Serializable*/]
|
||||
interface DOMRectReadOnly {
|
||||
[Throws] constructor(optional unrestricted double x = 0, optional unrestricted double y = 0,
|
||||
optional unrestricted double width = 0, optional unrestricted double height = 0);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* https://html.spec.whatwg.org/multipage/#messageport
|
||||
*/
|
||||
|
||||
[Exposed=(Window,Worker)]
|
||||
[Exposed=(Window,Worker), Transferable]
|
||||
interface MessagePort : EventTarget {
|
||||
[Throws] undefined postMessage(any message, sequence<object> transfer);
|
||||
[Throws] undefined postMessage(any message, optional StructuredSerializeOptions options = {});
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// https://streams.spec.whatwg.org/#readablestream
|
||||
|
||||
[Exposed=*] // [Transferable] - See Bug 1562065
|
||||
[Exposed=*, Transferable]
|
||||
interface _ReadableStream {
|
||||
[Throws]
|
||||
constructor(optional object underlyingSource, optional QueuingStrategy strategy = {});
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* https://streams.spec.whatwg.org/#ts-class-definition
|
||||
*/
|
||||
|
||||
[Exposed=*] // [Transferable] - See Bug 1562065
|
||||
[Exposed=*, Transferable]
|
||||
interface TransformStream {
|
||||
[Throws]
|
||||
constructor(optional object transformer,
|
||||
|
|
|
@ -170,7 +170,7 @@ interface GPUDevice: EventTarget {
|
|||
};
|
||||
GPUDevice includes GPUObjectBase;
|
||||
|
||||
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom_webgpu_enabled"]
|
||||
[Exposed=(Window, DedicatedWorker), /*Serializable,*/ Pref="dom_webgpu_enabled"]
|
||||
interface GPUBuffer {
|
||||
readonly attribute GPUSize64Out size;
|
||||
readonly attribute GPUFlagsConstant usage;
|
||||
|
@ -222,7 +222,7 @@ namespace GPUMapMode {
|
|||
const GPUFlagsConstant WRITE = 0x0002;
|
||||
};
|
||||
|
||||
[Exposed=(Window, DedicatedWorker), Serializable , Pref="dom_webgpu_enabled"]
|
||||
[Exposed=(Window, DedicatedWorker), /*Serializable,*/ Pref="dom_webgpu_enabled"]
|
||||
interface GPUTexture {
|
||||
[Throws, NewObject]
|
||||
GPUTextureView createView(optional GPUTextureViewDescriptor descriptor = {});
|
||||
|
@ -458,7 +458,7 @@ enum GPUCompareFunction {
|
|||
"always"
|
||||
};
|
||||
|
||||
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom_webgpu_enabled"]
|
||||
[Exposed=(Window, DedicatedWorker), /*Serializable,*/ Pref="dom_webgpu_enabled"]
|
||||
interface GPUBindGroupLayout {
|
||||
};
|
||||
GPUBindGroupLayout includes GPUObjectBase;
|
||||
|
@ -479,7 +479,7 @@ dictionary GPUBindGroupLayoutEntry {
|
|||
};
|
||||
|
||||
typedef [EnforceRange] unsigned long GPUShaderStageFlags;
|
||||
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom_webgpu_enabled"]
|
||||
[Exposed=(Window, DedicatedWorker), /*Serializable,*/ Pref="dom_webgpu_enabled"]
|
||||
interface GPUShaderStage {
|
||||
const GPUShaderStageFlags VERTEX = 1;
|
||||
const GPUShaderStageFlags FRAGMENT = 2;
|
||||
|
@ -560,7 +560,7 @@ dictionary GPUBufferBinding {
|
|||
GPUSize64 size;
|
||||
};
|
||||
|
||||
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom_webgpu_enabled"]
|
||||
[Exposed=(Window, DedicatedWorker), /*Serializable,*/ Pref="dom_webgpu_enabled"]
|
||||
interface GPUPipelineLayout {
|
||||
};
|
||||
GPUPipelineLayout includes GPUObjectBase;
|
||||
|
@ -569,7 +569,7 @@ dictionary GPUPipelineLayoutDescriptor : GPUObjectDescriptorBase {
|
|||
required sequence<GPUBindGroupLayout> bindGroupLayouts;
|
||||
};
|
||||
|
||||
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom_webgpu_enabled"]
|
||||
[Exposed=(Window, DedicatedWorker), /*Serializable,*/ Pref="dom_webgpu_enabled"]
|
||||
interface GPUShaderModule {
|
||||
Promise<GPUCompilationInfo> getCompilationInfo();
|
||||
};
|
||||
|
@ -638,7 +638,7 @@ dictionary GPUProgrammableStage {
|
|||
|
||||
typedef double GPUPipelineConstantValue; // May represent WGSL's bool, f32, i32, u32, and f16 if enabled.
|
||||
|
||||
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom_webgpu_enabled"]
|
||||
[Exposed=(Window, DedicatedWorker), /*Serializable,*/ Pref="dom_webgpu_enabled"]
|
||||
interface GPUComputePipeline {
|
||||
};
|
||||
GPUComputePipeline includes GPUObjectBase;
|
||||
|
@ -648,7 +648,7 @@ dictionary GPUComputePipelineDescriptor : GPUPipelineDescriptorBase {
|
|||
required GPUProgrammableStage compute;
|
||||
};
|
||||
|
||||
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom_webgpu_enabled"]
|
||||
[Exposed=(Window, DedicatedWorker), /*Serializable,*/ Pref="dom_webgpu_enabled"]
|
||||
interface GPURenderPipeline {
|
||||
};
|
||||
GPURenderPipeline includes GPUObjectBase;
|
||||
|
@ -873,7 +873,7 @@ dictionary GPUImageCopyExternalImage {
|
|||
boolean flipY = false;
|
||||
};
|
||||
|
||||
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom_webgpu_enabled"]
|
||||
[Exposed=(Window, DedicatedWorker), /*Serializable,*/ Pref="dom_webgpu_enabled"]
|
||||
interface GPUCommandBuffer {
|
||||
};
|
||||
GPUCommandBuffer includes GPUObjectBase;
|
||||
|
@ -881,7 +881,7 @@ GPUCommandBuffer includes GPUObjectBase;
|
|||
dictionary GPUCommandBufferDescriptor : GPUObjectDescriptorBase {
|
||||
};
|
||||
|
||||
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom_webgpu_enabled"]
|
||||
[Exposed=(Window, DedicatedWorker), /*Serializable,*/ Pref="dom_webgpu_enabled"]
|
||||
interface GPUCommandEncoder {
|
||||
[NewObject]
|
||||
GPUComputePassEncoder beginComputePass(optional GPUComputePassDescriptor descriptor = {});
|
||||
|
@ -939,7 +939,7 @@ dictionary GPUCommandEncoderDescriptor : GPUObjectDescriptorBase {
|
|||
boolean measureExecutionTime = false;
|
||||
};
|
||||
|
||||
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom_webgpu_enabled"]
|
||||
[Exposed=(Window, DedicatedWorker), /*Serializable,*/ Pref="dom_webgpu_enabled"]
|
||||
interface GPUComputePassEncoder {
|
||||
undefined setPipeline(GPUComputePipeline pipeline);
|
||||
undefined dispatchWorkgroups(GPUSize32 x, optional GPUSize32 y = 1, optional GPUSize32 z = 1);
|
||||
|
@ -1090,7 +1090,7 @@ dictionary GPURenderBundleEncoderDescriptor : GPURenderPassLayout {
|
|||
boolean stencilReadOnly = false;
|
||||
};
|
||||
|
||||
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom_webgpu_enabled"]
|
||||
[Exposed=(Window, DedicatedWorker), /*Serializable,*/ Pref="dom_webgpu_enabled"]
|
||||
interface GPUQueue {
|
||||
undefined submit(sequence<GPUCommandBuffer> buffers);
|
||||
|
||||
|
@ -1119,7 +1119,7 @@ interface GPUQueue {
|
|||
};
|
||||
GPUQueue includes GPUObjectBase;
|
||||
|
||||
[Exposed=(Window, DedicatedWorker), Serializable, Pref="dom_webgpu_enabled"]
|
||||
[Exposed=(Window, DedicatedWorker), /*Serializable,*/ Pref="dom_webgpu_enabled"]
|
||||
interface GPUQuerySet {
|
||||
undefined destroy();
|
||||
};
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
// https://streams.spec.whatwg.org/#writablestream
|
||||
|
||||
[Exposed=*] // [Transferable] - See Bug 1562065
|
||||
[Exposed=*, Transferable]
|
||||
interface WritableStream {
|
||||
[Throws]
|
||||
constructor(optional object underlyingSink, optional QueuingStrategy strategy = {});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue