Skip to content

Commit

Permalink
Translate "?" from "| null" into "null | undefined" (#163)
Browse files Browse the repository at this point in the history
* Translate "?" from "| null" into "null | undefined"

* apply to nullable arguments as well

---------

Co-authored-by: Kai Ninomiya <[email protected]>
  • Loading branch information
Jiawei-Shao and kainino0x authored Dec 17, 2024
1 parent 8a75a9d commit a6aaca5
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Most or all of these should be fixed in the generator over time.
- `Array` changed to `Iterable` for WebIDL `sequence`s in argument positions (but not in return positions).
- `any` changed to `object` for WebIDL `object`.
- `| SharedArrayBuffer` added for `[AllowShared] BufferSource`.
- `| null` changed to `| null | undefined` for WebIDL nullable items (`T?`).

The following differences are TODO: should be changed in the final result.

Expand Down
47 changes: 39 additions & 8 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,7 @@ interface GPUCanvasConfiguration {
/**
* The tone mapping determines how the content of textures returned by
* {@link GPUCanvasContext#getCurrentTexture} are to be displayed.
* Note: If an implementation doesn't support HDR WebGPU canvases, it should also not expose this member, to allow for feature detection. See {@link GPUCanvasContext#getConfiguration}.
*/
toneMapping?: GPUCanvasToneMapping;
/**
Expand Down Expand Up @@ -927,7 +928,11 @@ interface GPUFragmentState
* A list of {@link GPUColorTargetState} defining the formats and behaviors of the color targets
* this pipeline writes to.
*/
targets: Iterable<GPUColorTargetState | null>;
targets: Iterable<
| GPUColorTargetState
| null
| undefined
>;
}

interface GPUMultisampleState {
Expand Down Expand Up @@ -991,7 +996,11 @@ interface GPUPipelineLayoutDescriptor
* to a @group attribute in the {@link GPUShaderModule}, with the `N`th element corresponding
* with `@group(N)`.
*/
bindGroupLayouts: Iterable<GPUBindGroupLayout | null>;
bindGroupLayouts: Iterable<
| GPUBindGroupLayout
| null
| undefined
>;
}

interface GPUPrimitiveState {
Expand Down Expand Up @@ -1202,7 +1211,11 @@ interface GPURenderPassDescriptor
* Due to compatible usage list|usage compatibility, no color attachment
* may alias another attachment or any resource used inside the render pass.
*/
colorAttachments: Iterable<GPURenderPassColorAttachment | null>;
colorAttachments: Iterable<
| GPURenderPassColorAttachment
| null
| undefined
>;
/**
* The {@link GPURenderPassDepthStencilAttachment} value that defines the depth/stencil
* attachment that will be output to and tested against when executing this render pass.
Expand Down Expand Up @@ -1231,7 +1244,11 @@ interface GPURenderPassLayout
/**
* A list of the {@link GPUTextureFormat}s of the color attachments for this pass or bundle.
*/
colorFormats: Iterable<GPUTextureFormat | null>;
colorFormats: Iterable<
| GPUTextureFormat
| null
| undefined
>;
/**
* The {@link GPUTextureFormat} of the depth/stencil attachment for this pass or bundle.
*/
Expand Down Expand Up @@ -1329,6 +1346,7 @@ interface GPURequestAdapterOptions {
* attribute prior to requesting a {@link GPUDevice}.
*/
forceFallbackAdapter?: boolean;
xrCompatible?: boolean;
}

interface GPUSamplerBindingLayout {
Expand Down Expand Up @@ -1690,7 +1708,11 @@ interface GPUVertexState
* A list of {@link GPUVertexBufferLayout}s, each defining the layout of vertex attribute data in a
* vertex buffer used by this pipeline.
*/
buffers?: Iterable<GPUVertexBufferLayout | null>;
buffers?: Iterable<
| GPUVertexBufferLayout
| null
| undefined
>;
}

interface GPUBindingCommandsMixin {
Expand All @@ -1708,7 +1730,10 @@ interface GPUBindingCommandsMixin {
*/
setBindGroup(
index: GPUIndex32,
bindGroup: GPUBindGroup | null,
bindGroup:
| GPUBindGroup
| null
| undefined,
dynamicOffsets?: Iterable<GPUBufferDynamicOffset>
): undefined;
/**
Expand All @@ -1724,7 +1749,10 @@ interface GPUBindingCommandsMixin {
*/
setBindGroup(
index: GPUIndex32,
bindGroup: GPUBindGroup | null,
bindGroup:
| GPUBindGroup
| null
| undefined,
dynamicOffsetsData: Uint32Array,
dynamicOffsetsDataStart: GPUSize64,
dynamicOffsetsDataLength: GPUSize32
Expand Down Expand Up @@ -1802,7 +1830,10 @@ interface GPURenderCommandsMixin {
*/
setVertexBuffer(
slot: GPUIndex32,
buffer: GPUBuffer | null,
buffer:
| GPUBuffer
| null
| undefined,
offset?: GPUSize64,
size?: GPUSize64
): undefined;
Expand Down
2 changes: 2 additions & 0 deletions generated/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,7 @@ interface GPUCanvasConfiguration {
/**
* The tone mapping determines how the content of textures returned by
* {@link GPUCanvasContext#getCurrentTexture} are to be displayed.
* Note: If an implementation doesn't support HDR WebGPU canvases, it should also not expose this member, to allow for feature detection. See {@link GPUCanvasContext#getConfiguration}.
*/
toneMapping?: GPUCanvasToneMapping;
/**
Expand Down Expand Up @@ -1274,6 +1275,7 @@ interface GPURequestAdapterOptions {
featureLevel?: string;
powerPreference?: GPUPowerPreference;
forceFallbackAdapter?: boolean;
xrCompatible?: boolean;
}

interface GPUSamplerBindingLayout {
Expand Down

0 comments on commit a6aaca5

Please sign in to comment.