JS Union type members should have inherit corresponding marker interface
This commit is contained in:
committed by
Sergey Mashkov
parent
002b26e4ed
commit
42f1f9df03
@@ -3022,7 +3022,7 @@ native public open class DragEventInit : MouseEventInit() {
|
|||||||
var dataTransfer: DataTransfer?
|
var dataTransfer: DataTransfer?
|
||||||
}
|
}
|
||||||
|
|
||||||
native public trait Window : EventTarget {
|
native public trait Window : EventTarget, UnionMessagePortOrWindow {
|
||||||
var caches: CacheStorage
|
var caches: CacheStorage
|
||||||
get() = noImpl
|
get() = noImpl
|
||||||
set(value) = noImpl
|
set(value) = noImpl
|
||||||
@@ -3638,20 +3638,20 @@ native public open class MessageEvent(type: String, eventInitDict: MessageEventI
|
|||||||
var lastEventId: String
|
var lastEventId: String
|
||||||
get() = noImpl
|
get() = noImpl
|
||||||
set(value) = noImpl
|
set(value) = noImpl
|
||||||
var source: dynamic
|
var source: UnionMessagePortOrWindow?
|
||||||
get() = noImpl
|
get() = noImpl
|
||||||
set(value) = noImpl
|
set(value) = noImpl
|
||||||
var ports: Array<dynamic>
|
var ports: Array<dynamic>
|
||||||
get() = noImpl
|
get() = noImpl
|
||||||
set(value) = noImpl
|
set(value) = noImpl
|
||||||
fun initMessageEvent(typeArg: String, canBubbleArg: Boolean, cancelableArg: Boolean, dataArg: dynamic, originArg: String, lastEventIdArg: String, sourceArg: dynamic, portsArg: Array<dynamic>): Unit = noImpl
|
fun initMessageEvent(typeArg: String, canBubbleArg: Boolean, cancelableArg: Boolean, dataArg: dynamic, originArg: String, lastEventIdArg: String, sourceArg: UnionMessagePortOrWindow, portsArg: Array<dynamic>): Unit = noImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
native public open class MessageEventInit : EventInit() {
|
native public open class MessageEventInit : EventInit() {
|
||||||
var data: dynamic
|
var data: dynamic
|
||||||
var origin: String
|
var origin: String
|
||||||
var lastEventId: String
|
var lastEventId: String
|
||||||
var source: dynamic
|
var source: UnionMessagePortOrWindow?
|
||||||
var ports: Array<MessagePort>
|
var ports: Array<MessagePort>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3759,7 +3759,7 @@ native public open class MessageChannel {
|
|||||||
set(value) = noImpl
|
set(value) = noImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
native public trait MessagePort : EventTarget, Transferable {
|
native public trait MessagePort : EventTarget, UnionMessagePortOrWindow, UnionMessagePortOrServiceWorker, UnionClientOrMessagePortOrServiceWorker, Transferable {
|
||||||
var onmessage: ((Event) -> dynamic)?
|
var onmessage: ((Event) -> dynamic)?
|
||||||
get() = noImpl
|
get() = noImpl
|
||||||
set(value) = noImpl
|
set(value) = noImpl
|
||||||
@@ -4836,6 +4836,9 @@ native public marker trait UnionAudioTrackOrTextTrackOrVideoTrack {
|
|||||||
native public marker trait UnionElementOrMouseEvent {
|
native public marker trait UnionElementOrMouseEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
native public marker trait UnionMessagePortOrWindow {
|
||||||
|
}
|
||||||
|
|
||||||
native public marker trait UnionElementOrProcessingInstruction {
|
native public marker trait UnionElementOrProcessingInstruction {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ fun generateUnions(ifaces: List<GenerateTraitOrClass>, typedefs: Iterable<Typede
|
|||||||
.filter { it.value.memberTypes.all { type -> type in declaredTypes } }
|
.filter { it.value.memberTypes.all { type -> type in declaredTypes } }
|
||||||
val typedefsMarkersMap = typedefsToBeGenerated.groupBy { it.name }.mapValues { mapUnionType(it.value.first().value).copy(name = it.key) }
|
val typedefsMarkersMap = typedefsToBeGenerated.groupBy { it.name }.mapValues { mapUnionType(it.value.first().value).copy(name = it.key) }
|
||||||
|
|
||||||
val typeNamesToUnions = anonymousUnionTypes.flatMap { unionType -> unionType.memberTypes.map { unionMember -> unionMember to unionType.name } }.toMultiMap() +
|
val typeNamesToUnions = anonymousUnionTypes.flatMap { unionType -> unionType.memberTypes.map { unionMember -> unionMember to unionType.name } }.toMultiMap() merge
|
||||||
typedefsToBeGenerated.flatMap { typedef -> typedef.value.memberTypes.map { unionMember -> unionMember to typedef.name } }.toMultiMap()
|
typedefsToBeGenerated.flatMap { typedef -> typedef.value.memberTypes.map { unionMember -> unionMember to typedef.name } }.toMultiMap()
|
||||||
|
|
||||||
return GenerateUnionTypes(
|
return GenerateUnionTypes(
|
||||||
|
|||||||
@@ -13,8 +13,6 @@ fun main(args: Array<String>) {
|
|||||||
System.exit(1)
|
System.exit(1)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
outDir.deleteRecursively()
|
|
||||||
outDir.mkdirs()
|
|
||||||
|
|
||||||
val repository = srcDir.walkTopDown().filter { it.isDirectory() || it.extension == "idl" }.asSequence().filter { it.isFile() }.fold(Repository(emptyMap(), emptyMap(), emptyMap(), emptyMap())) { acc, e ->
|
val repository = srcDir.walkTopDown().filter { it.isDirectory() || it.extension == "idl" }.asSequence().filter { it.isFile() }.fold(Repository(emptyMap(), emptyMap(), emptyMap(), emptyMap())) { acc, e ->
|
||||||
val fileRepository = parseIDL(ANTLRFileStream(e.getAbsolutePath(), "UTF-8"))
|
val fileRepository = parseIDL(ANTLRFileStream(e.getAbsolutePath(), "UTF-8"))
|
||||||
@@ -31,6 +29,9 @@ fun main(args: Array<String>) {
|
|||||||
val unions = generateUnions(definitions, repository.typeDefs.values())
|
val unions = generateUnions(definitions, repository.typeDefs.values())
|
||||||
val allPackages = definitions.map { it.namespace }.distinct().sort()
|
val allPackages = definitions.map { it.namespace }.distinct().sort()
|
||||||
|
|
||||||
|
outDir.deleteRecursively()
|
||||||
|
outDir.mkdirs()
|
||||||
|
|
||||||
allPackages.forEach { pkg ->
|
allPackages.forEach { pkg ->
|
||||||
File(outDir, pkg + ".kt").bufferedWriter().use { w ->
|
File(outDir, pkg + ".kt").bufferedWriter().use { w ->
|
||||||
w.appendln("/*")
|
w.appendln("/*")
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ private fun mapType(repository: Repository, type: String): String =
|
|||||||
type.startsWith("unrestricted") -> mapType(repository, type.substring(12))
|
type.startsWith("unrestricted") -> mapType(repository, type.substring(12))
|
||||||
type.startsWith("sequence<") -> "Array<${mapType(repository, type.removePrefix("sequence<").removeSuffix(">").trim())}>"
|
type.startsWith("sequence<") -> "Array<${mapType(repository, type.removePrefix("sequence<").removeSuffix(">").trim())}>"
|
||||||
type.startsWith("sequence") -> "Array<dynamic>"
|
type.startsWith("sequence") -> "Array<dynamic>"
|
||||||
|
type.startsWith("Union<") -> "Union<" + splitUnionType(type).map { mapType(repository, it) }.join(",") + ">"
|
||||||
type in repository.typeDefs -> mapTypedef(repository, type)
|
type in repository.typeDefs -> mapTypedef(repository, type)
|
||||||
type in repository.enums -> "String"
|
type in repository.enums -> "String"
|
||||||
type.contains("->") -> {
|
type.contains("->") -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user