IDL2K: properly handle clash or val and var attributes

This commit is contained in:
Sergey Mashkov
2016-12-05 23:17:23 +03:00
parent 0d99801783
commit e7d6711db3
2 changed files with 17 additions and 3 deletions
+4 -2
View File
@@ -33,12 +33,14 @@ import org.w3c.xhr.*
set(value) = noImpl
open val rootElement: SVGSVGElement?
get() = noImpl
open val title: String
var title: String
get() = noImpl
set(value) = noImpl
open val referrer: String
get() = noImpl
open val domain: String
var domain: String
get() = noImpl
set(value) = noImpl
open val activeElement: Element?
get() = noImpl
open val location: Location?
@@ -274,6 +274,18 @@ private fun <F, T> Pair<F, F>.map(block: (F) -> T) = block(first) to block(secon
private fun Pair<Type, Type>.betterType() = if (first is DynamicType || first is AnyType) first else second
private fun Pair<String, String>.betterName() = if (((0..9).map(Int::toString) + listOf("arg")).none { first.toLowerCase().contains(it) }) first else second
private fun merge(a: AttributeKind, b: AttributeKind): AttributeKind {
if (a == b) {
return a
}
if (a == AttributeKind.VAR || b == AttributeKind.VAR) {
return AttributeKind.VAR
}
return a
}
private fun merge(a: GenerateAttribute, b: GenerateAttribute): GenerateAttribute {
require(a.name == b.name)
@@ -287,7 +299,7 @@ private fun merge(a: GenerateAttribute, b: GenerateAttribute): GenerateAttribute
type,
a.initializer ?: b.initializer,
a.getterSetterNoImpl || b.getterSetterNoImpl,
a.kind,
merge(a.kind, b.kind),
a.override,
a.vararg,
a.static