Skip to content

Commit 87aa0bc

Browse files
committed
Support additionalType
1 parent 411df57 commit 87aa0bc

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

inputfiles/overridingTypes.jsonc

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,6 @@
3030
}
3131
}
3232
},
33-
"WebGLRenderingContextBase": {
34-
"methods": {
35-
"method": {
36-
"pixelStorei": {
37-
"name": "pixelStorei",
38-
"signature": {
39-
"0": {
40-
"param": [
41-
{
42-
"name": "param",
43-
"additionalTypes": ["GLboolean"]
44-
}
45-
]
46-
}
47-
}
48-
}
49-
}
50-
}
51-
},
5233
"Body": {
5334
"properties": {
5435
"property": {

inputfiles/patches/webgl.kdl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,10 @@ interface-mixin WebGLRenderingContextBase {
170170
param extensionName overrideType="\"WEBGL_multi_draw\""
171171
type WEBGL_multi_draw nullable=#true
172172
}
173+
174+
method pixelStorei signatureIndex=0 {
175+
param param {
176+
additionalType GLboolean
177+
}
178+
}
173179
}

src/build/patches.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,21 @@ function handleTyped(type: Node): Typed {
6363
};
6464
}
6565

66+
function handleAdditionalTypes(node:Node){
67+
const additionalTypes = []
68+
for (const child of node.children) {
69+
if (child.name === "additionalType") {
70+
additionalTypes.push(string(child.values[0]));
71+
}
72+
73+
}
74+
// Check if additionalTypes has elements and return array if so, otherwise undefined/empty.
75+
if (additionalTypes.length > 0) {
76+
return {additionalTypes};
77+
}
78+
return undefined;
79+
}
80+
6681
function handleTypeParameters(value: Value | Node) {
6782
if (!value) {
6883
return {};
@@ -290,6 +305,7 @@ function handleMethod(child: Node): DeepPartial<OverridableMethod> {
290305
"string",
291306
c.properties?.overrideType,
292307
),
308+
...handleAdditionalTypes(c)
293309
});
294310
break;
295311

@@ -308,12 +324,9 @@ function handleMethod(child: Node): DeepPartial<OverridableMethod> {
308324
: null;
309325

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

315328
let signature: OverridableMethod["signature"] = [];
316-
if (type) {
329+
if (type || params.length > 0) {
317330
// Determine the actual signature object
318331
const signatureObj: DeepPartial<Signature> = {
319332
param: params,

0 commit comments

Comments
 (0)