JS Fix marker interface filtering

This commit is contained in:
Sergey Mashkov
2015-05-07 20:32:15 +03:00
committed by Sergey Mashkov
parent 2e687fde6b
commit a6bed4f623
13 changed files with 13 additions and 247 deletions
@@ -552,27 +552,3 @@ native public open class WebGLContextEventInit : EventInit() {
var statusMessage: String var statusMessage: String
} }
native public marker trait UnionElementOrHTMLCollection {
}
native public marker trait UnionElementOrRadioNodeList {
}
native public marker trait UnionHTMLOptGroupElementOrHTMLOptionElement {
}
native public marker trait UnionAudioTrackOrTextTrackOrVideoTrack {
}
native public marker trait UnionElementOrMouseEvent {
}
native public marker trait UnionElementOrProcessingInstruction {
}
native public marker trait UnionMessagePortOrServiceWorker {
}
native public marker trait UnionClientOrMessagePortOrServiceWorker {
}
@@ -216,27 +216,3 @@ native public trait PseudoElement {
native public trait CSS { native public trait CSS {
} }
native public marker trait UnionElementOrHTMLCollection {
}
native public marker trait UnionElementOrRadioNodeList {
}
native public marker trait UnionHTMLOptGroupElementOrHTMLOptionElement {
}
native public marker trait UnionAudioTrackOrTextTrackOrVideoTrack {
}
native public marker trait UnionElementOrMouseEvent {
}
native public marker trait UnionElementOrProcessingInstruction {
}
native public marker trait UnionMessagePortOrServiceWorker {
}
native public marker trait UnionClientOrMessagePortOrServiceWorker {
}
@@ -233,27 +233,3 @@ native public open class MutationEvent : Event(noImpl, noImpl) {
} }
} }
native public marker trait UnionElementOrHTMLCollection {
}
native public marker trait UnionElementOrRadioNodeList {
}
native public marker trait UnionHTMLOptGroupElementOrHTMLOptionElement {
}
native public marker trait UnionAudioTrackOrTextTrackOrVideoTrack {
}
native public marker trait UnionElementOrMouseEvent {
}
native public marker trait UnionElementOrProcessingInstruction {
}
native public marker trait UnionMessagePortOrServiceWorker {
}
native public marker trait UnionClientOrMessagePortOrServiceWorker {
}
@@ -4854,12 +4854,6 @@ native public marker trait UnionElementOrMouseEvent {
native public marker trait UnionElementOrProcessingInstruction { native public marker trait UnionElementOrProcessingInstruction {
} }
native public marker trait UnionMessagePortOrServiceWorker {
}
native public marker trait UnionClientOrMessagePortOrServiceWorker {
}
native public marker trait RenderingContext { native public marker trait RenderingContext {
} }
@@ -25,27 +25,3 @@ native public open class XMLSerializer {
fun serializeToString(root: Node): String = noImpl fun serializeToString(root: Node): String = noImpl
} }
native public marker trait UnionElementOrHTMLCollection {
}
native public marker trait UnionElementOrRadioNodeList {
}
native public marker trait UnionHTMLOptGroupElementOrHTMLOptionElement {
}
native public marker trait UnionAudioTrackOrTextTrackOrVideoTrack {
}
native public marker trait UnionElementOrMouseEvent {
}
native public marker trait UnionElementOrProcessingInstruction {
}
native public marker trait UnionMessagePortOrServiceWorker {
}
native public marker trait UnionClientOrMessagePortOrServiceWorker {
}
@@ -111,27 +111,3 @@ native public open class ResponseInit {
var headers: dynamic var headers: dynamic
} }
native public marker trait UnionElementOrHTMLCollection {
}
native public marker trait UnionElementOrRadioNodeList {
}
native public marker trait UnionHTMLOptGroupElementOrHTMLOptionElement {
}
native public marker trait UnionAudioTrackOrTextTrackOrVideoTrack {
}
native public marker trait UnionElementOrMouseEvent {
}
native public marker trait UnionElementOrProcessingInstruction {
}
native public marker trait UnionMessagePortOrServiceWorker {
}
native public marker trait UnionClientOrMessagePortOrServiceWorker {
}
@@ -106,27 +106,3 @@ native public open class FileReaderSync {
native public trait URL { native public trait URL {
} }
native public marker trait UnionElementOrHTMLCollection {
}
native public marker trait UnionElementOrRadioNodeList {
}
native public marker trait UnionHTMLOptGroupElementOrHTMLOptionElement {
}
native public marker trait UnionAudioTrackOrTextTrackOrVideoTrack {
}
native public marker trait UnionElementOrMouseEvent {
}
native public marker trait UnionElementOrProcessingInstruction {
}
native public marker trait UnionMessagePortOrServiceWorker {
}
native public marker trait UnionClientOrMessagePortOrServiceWorker {
}
@@ -98,27 +98,3 @@ native public open class NotificationEventInit : ExtendableEventInit() {
var notification: Notification var notification: Notification
} }
native public marker trait UnionElementOrHTMLCollection {
}
native public marker trait UnionElementOrRadioNodeList {
}
native public marker trait UnionHTMLOptGroupElementOrHTMLOptionElement {
}
native public marker trait UnionAudioTrackOrTextTrackOrVideoTrack {
}
native public marker trait UnionElementOrMouseEvent {
}
native public marker trait UnionElementOrProcessingInstruction {
}
native public marker trait UnionMessagePortOrServiceWorker {
}
native public marker trait UnionClientOrMessagePortOrServiceWorker {
}
@@ -264,24 +264,6 @@ native public trait CacheStorage {
native public open class FunctionalEvent : ExtendableEvent(noImpl, noImpl) { native public open class FunctionalEvent : ExtendableEvent(noImpl, noImpl) {
} }
native public marker trait UnionElementOrHTMLCollection {
}
native public marker trait UnionElementOrRadioNodeList {
}
native public marker trait UnionHTMLOptGroupElementOrHTMLOptionElement {
}
native public marker trait UnionAudioTrackOrTextTrackOrVideoTrack {
}
native public marker trait UnionElementOrMouseEvent {
}
native public marker trait UnionElementOrProcessingInstruction {
}
native public marker trait UnionMessagePortOrServiceWorker { native public marker trait UnionMessagePortOrServiceWorker {
} }
@@ -128,27 +128,3 @@ native public open class ProgressEventInit : EventInit() {
var total: Long = 0 var total: Long = 0
} }
native public marker trait UnionElementOrHTMLCollection {
}
native public marker trait UnionElementOrRadioNodeList {
}
native public marker trait UnionHTMLOptGroupElementOrHTMLOptionElement {
}
native public marker trait UnionAudioTrackOrTextTrackOrVideoTrack {
}
native public marker trait UnionElementOrMouseEvent {
}
native public marker trait UnionElementOrProcessingInstruction {
}
native public marker trait UnionMessagePortOrServiceWorker {
}
native public marker trait UnionClientOrMessagePortOrServiceWorker {
}
@@ -1,25 +0,0 @@
grammar test;
testme
: namespace? declarations EOF
;
declarations
: declaration*
;
namespace
: 'namespace' IDENTIFIER ';'
;
declaration
: 'interface' IDENTIFIER
;
IDENTIFIER
: [A-Za-z_][A-Za-z_0-9]*
;
WHITESPACE_WEBIDL
: [\t\n\r ]+ -> channel(HIDDEN)
;
@@ -8,7 +8,7 @@ private fun <O : Appendable> O.indent(level: Int) {
} }
} }
private fun Appendable.renderAttributeDeclaration(allTypes: Set<String>, arg: GenerateAttribute, override: Boolean, level: Int = 1) { private fun Appendable.renderAttributeDeclaration(arg: GenerateAttribute, override: Boolean, level: Int = 1) {
indent(level) indent(level)
if (override) { if (override) {
@@ -117,7 +117,7 @@ fun Appendable.render(allTypes: Map<String, GenerateTraitOrClass>, typeNamesToUn
val superSignatures = superAttributes.map { it.signature } merge superFunctions.map { it.signature } val superSignatures = superAttributes.map { it.signature } merge superFunctions.map { it.signature }
iface.memberAttributes.filter { it !in superAttributes }.map { it.dynamicIfUnknownType(allTypes.keySet()) }.groupBy { it.signature }.reduceValues().values().forEach { arg -> iface.memberAttributes.filter { it !in superAttributes }.map { it.dynamicIfUnknownType(allTypes.keySet()) }.groupBy { it.signature }.reduceValues().values().forEach { arg ->
renderAttributeDeclaration(allTypes.keySet(), arg, arg.signature in superSignatures) renderAttributeDeclaration(arg, arg.signature in superSignatures)
} }
iface.memberFunctions.filter { it !in superFunctions }.map { it.dynamicIfUnknownType(allTypes.keySet()) }.groupBy { it.signature }.reduceValues(::betterFunction).values().forEach { iface.memberFunctions.filter { it !in superFunctions }.map { it.dynamicIfUnknownType(allTypes.keySet()) }.groupBy { it.signature }.reduceValues(::betterFunction).values().forEach {
renderFunctionDeclaration(allTypes.keySet(), it, it.signature in superSignatures) renderFunctionDeclaration(allTypes.keySet(), it, it.signature in superSignatures)
@@ -127,7 +127,7 @@ fun Appendable.render(allTypes: Map<String, GenerateTraitOrClass>, typeNamesToUn
indent(1) indent(1)
appendln("companion object {") appendln("companion object {")
iface.constants.forEach { iface.constants.forEach {
renderAttributeDeclaration(allTypes.keySet(), it, override = false, level = 2) renderAttributeDeclaration(it, override = false, level = 2)
} }
indent(1) indent(1)
appendln("}") appendln("}")
@@ -172,11 +172,11 @@ fun Appendable.render(namespace: String, ifaces: List<GenerateTraitOrClass>, typ
render(allTypes, typeNamesToUnions, it) render(allTypes, typeNamesToUnions, it)
} }
anonymousUnionTypeTraits.forEach { anonymousUnionTypeTraits.filter { it.namespace == "" || it.namespace == namespace }.forEach {
render(allTypes, emptyMap(), it, markerAnnotation = true) render(allTypes, emptyMap(), it, markerAnnotation = true)
} }
typedefsMarkerTraits.values().forEach { typedefsMarkerTraits.values().filter { it.namespace == "" || it.namespace == namespace }.forEach {
render(allTypes, emptyMap(), it, markerAnnotation = true) render(allTypes, emptyMap(), it, markerAnnotation = true)
} }
} }
@@ -112,5 +112,12 @@ private fun collectUnionTypes(allTypes: Map<String, GenerateTraitOrClass>) =
.map { splitUnionType(it) } .map { splitUnionType(it) }
.filter { it.all { unionMember -> unionMember in allTypes } } .filter { it.all { unionMember -> unionMember in allTypes } }
.toSet() .toSet()
.map { UnionType("", it) } .map { UnionType(guessPackage(it, allTypes), it) }
private fun guessPackage(types : List<String>, allTypes: Map<String, GenerateTraitOrClass>) =
types.map { allTypes[it] }
.map { it?.namespace }
.filterNotNull()
.filter { it != "" }
.distinct()
.minBy { it.split('.').size() } ?: ""