JS: replace noImpl with definedExternally in IDL2K
This commit is contained in:
@@ -35,7 +35,7 @@ fun generateFunction(repository: Repository, function: Operation, functionName:
|
||||
GenerateAttribute(
|
||||
name = it.name,
|
||||
type = mappedType,
|
||||
initializer = if (it.defaultValue != null) "noImpl" else null,
|
||||
initializer = if (it.defaultValue != null) "definedExternally" else null,
|
||||
getterSetterNoImpl = false,
|
||||
override = false,
|
||||
kind = AttributeKind.ARGUMENT,
|
||||
@@ -92,7 +92,7 @@ fun generateAttribute(putNoImpl: Boolean, repository: Repository, attribute: Att
|
||||
mapLiteral(attribute.defaultValue, mapType(repository, attribute.type))
|
||||
}
|
||||
else if (attribute.defaultValue != null) {
|
||||
"noImpl"
|
||||
"definedExternally"
|
||||
}
|
||||
else {
|
||||
null
|
||||
|
||||
@@ -213,7 +213,7 @@ class AttributeVisitor(private val readOnly: Boolean = false, private val static
|
||||
|
||||
override fun visitOptionalOrRequiredArgument(ctx: WebIDLParser.OptionalOrRequiredArgumentContext): Attribute {
|
||||
if (ctx.children?.any { it is TerminalNode && it.text == "optional" } ?: false) {
|
||||
defaultValue = "noImpl"
|
||||
defaultValue = "definedExternally"
|
||||
}
|
||||
if (ctx.children?.any { it is TerminalNode && it.text == "required" } ?: false) {
|
||||
required = true
|
||||
|
||||
@@ -74,11 +74,11 @@ private fun Appendable.renderAttributeDeclarationAsProperty(arg: GenerateAttribu
|
||||
appendln()
|
||||
if (arg.getterNoImpl) {
|
||||
indent(commented, level + 1)
|
||||
appendln("get() = noImpl")
|
||||
appendln("get() = definedExternally")
|
||||
}
|
||||
if (arg.setterNoImpl) {
|
||||
indent(commented, level + 1)
|
||||
appendln("set(value) = noImpl")
|
||||
appendln("set(value) = definedExternally")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ private val keywords = setOf("interface", "is", "as")
|
||||
private fun String.parse() = if (this.startsWith("0x")) BigInteger(this.substring(2), 16) else BigInteger(this)
|
||||
private fun String.replaceWrongConstants(type: Type) = when {
|
||||
this == "null" && type.nullable -> "null"
|
||||
this == "noImpl" || type is SimpleType && type.type == "Int" && parse() > BigInteger.valueOf(Int.MAX_VALUE.toLong()) -> "noImpl"
|
||||
this == "definedExternally" || type is SimpleType && type.type == "Int" && parse() > BigInteger.valueOf(Int.MAX_VALUE.toLong()) -> "definedExternally"
|
||||
type is SimpleType && type.type == "Double" && this.matches("[0-9]+".toRegex()) -> "${this}.0"
|
||||
else -> this
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user