From e3da9066c48b1e2fb72a2b3a1113d1dd57f6bdbe Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Mon, 23 Jan 2017 16:36:40 +0300 Subject: [PATCH] JS: replace `noImpl` with `definedExternally` in IDL2K --- libraries/tools/idl2k/src/main/kotlin/gen.kt | 4 ++-- libraries/tools/idl2k/src/main/kotlin/idl.kt | 2 +- libraries/tools/idl2k/src/main/kotlin/render.kt | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/tools/idl2k/src/main/kotlin/gen.kt b/libraries/tools/idl2k/src/main/kotlin/gen.kt index 43fb64f9105..74b96bd440a 100644 --- a/libraries/tools/idl2k/src/main/kotlin/gen.kt +++ b/libraries/tools/idl2k/src/main/kotlin/gen.kt @@ -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 diff --git a/libraries/tools/idl2k/src/main/kotlin/idl.kt b/libraries/tools/idl2k/src/main/kotlin/idl.kt index 7e368009d47..a74d9db069c 100644 --- a/libraries/tools/idl2k/src/main/kotlin/idl.kt +++ b/libraries/tools/idl2k/src/main/kotlin/idl.kt @@ -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 diff --git a/libraries/tools/idl2k/src/main/kotlin/render.kt b/libraries/tools/idl2k/src/main/kotlin/render.kt index 8632d2f528e..94875ceca9e 100644 --- a/libraries/tools/idl2k/src/main/kotlin/render.kt +++ b/libraries/tools/idl2k/src/main/kotlin/render.kt @@ -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 }