Web API package for use when compling Go to WASM
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

47 lines
1.3 KiB

package main
type IDLType struct {
BaseName string `json:"baseName"`
ExtraAttributes *ExtraAttributes `json:"extAttrs"`
Generic interface{} `json:"generic"`
IDLType interface{} `json:"idlType"`
Nullable interface{} `json:"nullable"`
Postfix interface{} `json:"postfix"`
Prefix interface{} `json:"prefix"`
Separator interface{} `json:"separator"`
Trivia interface{} `json:"trivia"`
Type string `json:"type"`
Union bool `json:"union"`
}
func convertIDLType(idlType interface{}) string {
switch t := idlType.(type) {
case IDLType:
return convertIDLType(t.IDLType)
case map[string]interface{}:
return convertIDLType(t["idlType"])
case string:
switch t {
case "USVString", "DOMString", "CSSOMString":
t = "string"
case "unsigned long", "unsigned long long",
"long", "long long",
"unsigned short", "short":
t = "int"
case "double", "unrestricted double":
t = "float64"
case "boolean":
t = "bool"
case "any", "object":
t = "Value"
case "null", "void":
t = ""
case "ByteString":
t = "[]byte"
case "ReadableStream", "WritableStream":
t = "Value"
}
return t
}
return ""
}