IDL2K introduce required parameters list to avoid possible ambiguous calls
This commit is contained in:
@@ -4578,7 +4578,7 @@ native public open class DOMPointReadOnly(x: Double, y: Double, z: Double, w: Do
|
|||||||
}
|
}
|
||||||
|
|
||||||
native public open class DOMPoint : DOMPointReadOnly {
|
native public open class DOMPoint : DOMPointReadOnly {
|
||||||
constructor(point: DOMPointInit = noImpl) : super(noImpl, noImpl, noImpl, noImpl)
|
constructor(point: DOMPointInit) : super(noImpl, noImpl, noImpl, noImpl)
|
||||||
constructor(x: Double = 0.0, y: Double = 0.0, z: Double = 0.0, w: Double = 1.0) : super(x, y, z, w)
|
constructor(x: Double = 0.0, y: Double = 0.0, z: Double = 0.0, w: Double = 1.0) : super(x, y, z, w)
|
||||||
override var x: Double
|
override var x: Double
|
||||||
get() = noImpl
|
get() = noImpl
|
||||||
@@ -4644,7 +4644,7 @@ native public open class DOMRectInit {
|
|||||||
|
|
||||||
native public open class DOMQuad {
|
native public open class DOMQuad {
|
||||||
constructor(p1: DOMPointInit = noImpl, p2: DOMPointInit = noImpl, p3: DOMPointInit = noImpl, p4: DOMPointInit = noImpl)
|
constructor(p1: DOMPointInit = noImpl, p2: DOMPointInit = noImpl, p3: DOMPointInit = noImpl, p4: DOMPointInit = noImpl)
|
||||||
constructor(rect: DOMRectInit = noImpl)
|
constructor(rect: DOMRectInit)
|
||||||
open val p1: DOMPoint
|
open val p1: DOMPoint
|
||||||
get() = noImpl
|
get() = noImpl
|
||||||
open val p2: DOMPoint
|
open val p2: DOMPoint
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ val relocations = mapOf(
|
|||||||
"EventListener" to "org.w3c.dom.events"
|
"EventListener" to "org.w3c.dom.events"
|
||||||
)
|
)
|
||||||
|
|
||||||
val commentOutDeclarations = listOf(
|
val commentOutDeclarations = setOf(
|
||||||
"MouseEvent.screenX: Double", "MouseEvent.screenY: Double",
|
"MouseEvent.screenX: Double", "MouseEvent.screenY: Double",
|
||||||
"MouseEvent.clientX: Double", "MouseEvent.clientY: Double",
|
"MouseEvent.clientX: Double", "MouseEvent.clientY: Double",
|
||||||
"MouseEvent.x: Double", "MouseEvent.y: Double",
|
"MouseEvent.x: Double", "MouseEvent.y: Double",
|
||||||
@@ -67,4 +67,9 @@ val commentOutDeclarations = listOf(
|
|||||||
"HTMLPropertiesCollection.get",
|
"HTMLPropertiesCollection.get",
|
||||||
|
|
||||||
"SVGElement.id"
|
"SVGElement.id"
|
||||||
).toSet()
|
)
|
||||||
|
|
||||||
|
val requiredArguments = setOf(
|
||||||
|
"DOMPoint.constructor.point",
|
||||||
|
"DOMQuad.constructor.rect"
|
||||||
|
)
|
||||||
|
|||||||
@@ -138,8 +138,8 @@ fun generateTrait(repository: Repository, iface: InterfaceDefinition): GenerateT
|
|||||||
|
|
||||||
fun generateConstructorAsFunction(repository: Repository, constructor: ExtendedAttribute) = generateFunction(
|
fun generateConstructorAsFunction(repository: Repository, constructor: ExtendedAttribute) = generateFunction(
|
||||||
repository,
|
repository,
|
||||||
Operation("", UnitType, constructor.arguments, emptyList(), false),
|
Operation("constructor", UnitType, constructor.arguments, emptyList(), false),
|
||||||
functionName = "",
|
functionName = "constructor",
|
||||||
nativeGetterOrSetter = NativeGetterOrSetter.NONE)
|
nativeGetterOrSetter = NativeGetterOrSetter.NONE)
|
||||||
|
|
||||||
fun superOrPrimaryConstructorCall(constructorAsFunction: GenerateFunction, superClassName: String, superOrPrimaryConstructor: ExtendedAttribute): GenerateFunctionCall {
|
fun superOrPrimaryConstructorCall(constructorAsFunction: GenerateFunction, superClassName: String, superOrPrimaryConstructor: ExtendedAttribute): GenerateFunctionCall {
|
||||||
|
|||||||
@@ -98,6 +98,8 @@ private val GenerateAttribute.isVar: Boolean
|
|||||||
private fun GenerateAttribute.isCommented(parent: String) = "$parent.$name" in commentOutDeclarations || "$parent.$name: ${type.render()}" in commentOutDeclarations
|
private fun GenerateAttribute.isCommented(parent: String) = "$parent.$name" in commentOutDeclarations || "$parent.$name: ${type.render()}" in commentOutDeclarations
|
||||||
private fun GenerateFunction.isCommented(parent: String) =
|
private fun GenerateFunction.isCommented(parent: String) =
|
||||||
"$parent.$name" in commentOutDeclarations || "$parent.$name(${arguments.size()})" in commentOutDeclarations
|
"$parent.$name" in commentOutDeclarations || "$parent.$name(${arguments.size()})" in commentOutDeclarations
|
||||||
|
private fun GenerateAttribute.isRequiredFunctionArgument(owner: String, functionName: String) = "$owner.$functionName.$name" in requiredArguments
|
||||||
|
private fun GenerateFunction.fixRequiredArguments(parent: String) = copy(arguments = arguments.map { arg -> arg.copy(initializer = if (arg.isRequiredFunctionArgument(parent, name)) null else arg.initializer) })
|
||||||
|
|
||||||
fun Appendable.render(allTypes: Map<String, GenerateTraitOrClass>, typeNamesToUnions: Map<String, List<String>>, iface: GenerateTraitOrClass, markerAnnotation: Boolean = false) {
|
fun Appendable.render(allTypes: Map<String, GenerateTraitOrClass>, typeNamesToUnions: Map<String, List<String>>, iface: GenerateTraitOrClass, markerAnnotation: Boolean = false) {
|
||||||
append("native public ")
|
append("native public ")
|
||||||
@@ -115,7 +117,7 @@ fun Appendable.render(allTypes: Map<String, GenerateTraitOrClass>, typeNamesToUn
|
|||||||
append(iface.name)
|
append(iface.name)
|
||||||
val primary = iface.primaryConstructor
|
val primary = iface.primaryConstructor
|
||||||
if (primary != null && (primary.constructor.arguments.isNotEmpty() || iface.secondaryConstructors.isNotEmpty())) {
|
if (primary != null && (primary.constructor.arguments.isNotEmpty() || iface.secondaryConstructors.isNotEmpty())) {
|
||||||
renderArgumentsDeclaration(primary.constructor.arguments.dynamicIfUnknownType(allTypes.keySet()), false)
|
renderArgumentsDeclaration(primary.constructor.fixRequiredArguments(iface.name).arguments.dynamicIfUnknownType(allTypes.keySet()), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
val superCallName = primary?.initTypeCall?.name
|
val superCallName = primary?.initTypeCall?.name
|
||||||
@@ -133,7 +135,7 @@ fun Appendable.render(allTypes: Map<String, GenerateTraitOrClass>, typeNamesToUn
|
|||||||
iface.secondaryConstructors.forEach { secondary ->
|
iface.secondaryConstructors.forEach { secondary ->
|
||||||
indent(false, 1)
|
indent(false, 1)
|
||||||
append("constructor")
|
append("constructor")
|
||||||
renderArgumentsDeclaration(secondary.constructor.arguments.dynamicIfUnknownType(allTypes.keySet()), false)
|
renderArgumentsDeclaration(secondary.constructor.fixRequiredArguments(iface.name).arguments.dynamicIfUnknownType(allTypes.keySet()), false)
|
||||||
|
|
||||||
if (secondary.initTypeCall != null) {
|
if (secondary.initTypeCall != null) {
|
||||||
append(" : ")
|
append(" : ")
|
||||||
@@ -155,7 +157,7 @@ fun Appendable.render(allTypes: Map<String, GenerateTraitOrClass>, typeNamesToUn
|
|||||||
renderAttributeDeclaration(arg, override = arg.signature in superSignatures, open = iface.kind == GenerateDefinitionKind.CLASS && arg.readOnly, commented = arg.isCommented(iface.name))
|
renderAttributeDeclaration(arg, override = arg.signature in superSignatures, open = iface.kind == GenerateDefinitionKind.CLASS && arg.readOnly, commented = arg.isCommented(iface.name))
|
||||||
}
|
}
|
||||||
iface.memberFunctions.filter { it !in superFunctions && !it.static }.map { it.dynamicIfUnknownType(allTypes.keySet()) }.groupBy { it.signature }.reduceValues(::betterFunction).values().forEach {
|
iface.memberFunctions.filter { it !in superFunctions && !it.static }.map { it.dynamicIfUnknownType(allTypes.keySet()) }.groupBy { it.signature }.reduceValues(::betterFunction).values().forEach {
|
||||||
renderFunctionDeclaration(it, it.signature in superSignatures, commented = it.isCommented(iface.name))
|
renderFunctionDeclaration(it.fixRequiredArguments(iface.name), it.signature in superSignatures, commented = it.isCommented(iface.name))
|
||||||
}
|
}
|
||||||
|
|
||||||
val staticAttributes = iface.memberAttributes.filter { it.static }
|
val staticAttributes = iface.memberAttributes.filter { it.static }
|
||||||
@@ -172,7 +174,7 @@ fun Appendable.render(allTypes: Map<String, GenerateTraitOrClass>, typeNamesToUn
|
|||||||
renderAttributeDeclaration(it, override = false, open = false, level = 2, commented = it.isCommented(iface.name))
|
renderAttributeDeclaration(it, override = false, open = false, level = 2, commented = it.isCommented(iface.name))
|
||||||
}
|
}
|
||||||
staticFunctions.forEach {
|
staticFunctions.forEach {
|
||||||
renderFunctionDeclaration(it, override = false, level = 2, commented = it.isCommented(iface.name))
|
renderFunctionDeclaration(it.fixRequiredArguments(iface.name), override = false, level = 2, commented = it.isCommented(iface.name))
|
||||||
}
|
}
|
||||||
indent(false, 1)
|
indent(false, 1)
|
||||||
appendln("}")
|
appendln("}")
|
||||||
|
|||||||
Reference in New Issue
Block a user