Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
19 changes: 0 additions & 19 deletions inputfiles/overridingTypes.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,6 @@
}
}
},
"WebGLRenderingContextBase": {
"methods": {
"method": {
"pixelStorei": {
"name": "pixelStorei",
"signature": {
"0": {
"param": [
{
"name": "param",
"additionalTypes": ["GLboolean"]
}
]
}
}
}
}
}
},
"Body": {
"properties": {
"property": {
Expand Down
6 changes: 6 additions & 0 deletions inputfiles/patches/webgl.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,10 @@ interface-mixin WebGLRenderingContextBase {
param extensionName overrideType="\"WEBGL_multi_draw\""
type WEBGL_multi_draw nullable=#true
}

method pixelStorei signatureIndex=0 {
param param {
additionalType GLboolean
}
}
}
20 changes: 16 additions & 4 deletions src/build/patches.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ function handleTyped(type: Node): Typed {
};
}

function handleAdditionalTypes(node: Node) {
const additionalTypes = [];
for (const child of node.children) {
if (child.name === "additionalType") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is assuming to repeat like

additionalType foo
additionalType bar

right? But maybe just additionalTypes foo bar, because it's always just a simple string?

additionalTypes.push(string(child.values[0]));
}
}
// Check if additionalTypes has elements and return array if so, otherwise undefined/empty.
if (additionalTypes.length > 0) {
return { additionalTypes };
}
return undefined;
}

function handleTypeParameters(value: Value | Node) {
if (!value) {
return {};
Expand Down Expand Up @@ -290,6 +304,7 @@ function handleMethod(child: Node): DeepPartial<OverridableMethod> {
"string",
c.properties?.overrideType,
),
...handleAdditionalTypes(c),
});
break;

Expand All @@ -308,12 +323,9 @@ function handleMethod(child: Node): DeepPartial<OverridableMethod> {
: null;

const signatureIndex = child.properties?.signatureIndex;
if ((params.length || signatureIndex) && !type) {
throw new Error("A method signature requires a type");
}

let signature: OverridableMethod["signature"] = [];
if (type) {
if (type || params.length > 0) {
// Determine the actual signature object
const signatureObj: DeepPartial<Signature> = {
param: params,
Expand Down