Hi everyone,
I’ve been putting some types definitions around the WebGL API and I’ve hit a snag with @as
and @int
.
Functions such as gl.disable take an int parameter selected from a number of object constants. I’ve been able to get this working with a code such as this:
send external disable: (t, @int [
| @as(3042) #Blend
| @as(2884) #CullFace
| @as(2929) #DepthTest
| @as(3024) #Dither
| @as(32823) #PolygonOffsetFill
| @as(32926) #SampleAlphaToCoverage
| @as(32928) #SampleCoverage
| @as(3089) #ScissorTest
| @as(2960) #StencilTest
]) => unit = "disable"
However, the values in this enum are used multiple times. Ideally I would define this enum as a type and then reference the type multiple times:
type capability = @int [
| @as(3042) #Blend
| @as(2884) #CullFace
| @as(2929) #DepthTest
| @as(3024) #Dither
| @as(32823) #PolygonOffsetFill
| @as(32926) #SampleAlphaToCoverage
| @as(32928) #SampleCoverage
| @as(3089) #ScissorTest
| @as(2960) #StencilTest
]
@send external disable: (t, capability) => unit = "disable"
@send external enable: (t, capability) => unit = "enable"
But this doesn’t work. Am I doing something wrong? Is this an oversight in the current implementation? Or is this use-case not really planned for? Is there an alternative way to approach this?
Thanks,
Sam