Tomasz Krakowiak
11/26/2020, 3:16 PMenum DOMParserSupportedType {
"text/html",
"text/xml",
"application/xml",
"application/xhtml+xml",
"image/svg+xml"
};
😅Big Chungus
11/26/2020, 3:28 PMMarc Knaup
11/26/2020, 3:40 PMexternal interface DOMParserSupportedType
object DOMParserSupportedTypeStatic {
inline val text_html get() = "text/html".unsafeCast<DOMParserSupportedType>()
inline val text_xml get() = "text/xml".unsafeCast<DOMParserSupportedType>()
inline val application_xml get() = "application/xml".unsafeCast<DOMParserSupportedType>()
inline val application_xhtml_xml get() = "application/xhtml+xml".unsafeCast<DOMParserSupportedType>()
inline val image_svg_xml get() = "image/svg+xml".unsafeCast<DOMParserSupportedType>()
}
And nicer usage but quite unsafe:
external interface DOMParserSupportedType {
@Suppress(
"INLINE_EXTERNAL_DECLARATION",
"NAME_CONTAINS_ILLEGAL_CHARS",
"NESTED_CLASS_IN_EXTERNAL_INTERFACE",
"ObjectPropertyName",
"WRONG_BODY_OF_EXTERNAL_DECLARATION",
)
companion object {
inline val `text/html` get() = "text/html".unsafeCast<DOMParserSupportedType>()
inline val `text/xml` get() = "text/xml".unsafeCast<DOMParserSupportedType>()
inline val `application/xml` get() = "application/xml".unsafeCast<DOMParserSupportedType>()
inline val `application/xhtml+xml` get() = "application/xhtml+xml".unsafeCast<DOMParserSupportedType>()
inline val `image/svg+xml` get() = "image/svg+xml".unsafeCast<DOMParserSupportedType>()
}
}
Big Chungus
11/26/2020, 3:42 PMtypealias DOMParserSupportedType = String
inline val DOMParserSupportedType.text_html: DOMParserSupportedType get() = "text/html"
// others
Marc Knaup
11/26/2020, 3:43 PMtypealias
drops type safetyMarc Knaup
11/26/2020, 3:44 PMval x: DOMParserSupportedType = "foo"
Big Chungus
11/26/2020, 3:44 PMMarc Knaup
11/26/2020, 3:44 PMTomasz Krakowiak
11/26/2020, 3:44 PMBig Chungus
11/26/2020, 3:44 PMBig Chungus
11/26/2020, 3:46 PMexternal interface DOMParserSupportedType {
companion object
}
inline val DOMParserSupportedType.Companion.text_html get() = "text/html".unsafeCast<DOMParserSupportedType>()
// others
Tomasz Krakowiak
11/26/2020, 3:46 PMMarc Knaup
11/26/2020, 3:47 PMcompanion object
within an external interface
is not legit. At least not in IR.Marc Knaup
11/26/2020, 3:48 PMBig Chungus
11/26/2020, 3:49 PMexternal interface DOMParserSupportedType
inline val DOMParserSupportedType.Companion.text_html get() = "text/html".unsafeCast<DOMParserSupportedType>()
// others
Marc Knaup
11/26/2020, 3:50 PMMarc Knaup
11/26/2020, 3:50 PMDOMParser
definitions and simply uses dynamic
for DOMParserSupportedType
😮Tomasz Krakowiak
11/26/2020, 3:50 PMMarc Knaup
11/26/2020, 3:51 PMturansky
11/27/2020, 6:17 AMturansky
11/27/2020, 6:59 AMturansky
11/27/2020, 7:00 AMturansky
11/27/2020, 7:02 AMTomasz Krakowiak
11/27/2020, 9:25 AM