JS: replace noImpl with definedExternally in IDL2K

This commit is contained in:
Alexey Andreev
2017-01-23 16:36:40 +03:00
parent 26abc19aa6
commit e3da9066c4
3 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -35,7 +35,7 @@ fun generateFunction(repository: Repository, function: Operation, functionName:
GenerateAttribute( GenerateAttribute(
name = it.name, name = it.name,
type = mappedType, type = mappedType,
initializer = if (it.defaultValue != null) "noImpl" else null, initializer = if (it.defaultValue != null) "definedExternally" else null,
getterSetterNoImpl = false, getterSetterNoImpl = false,
override = false, override = false,
kind = AttributeKind.ARGUMENT, kind = AttributeKind.ARGUMENT,
@@ -92,7 +92,7 @@ fun generateAttribute(putNoImpl: Boolean, repository: Repository, attribute: Att
mapLiteral(attribute.defaultValue, mapType(repository, attribute.type)) mapLiteral(attribute.defaultValue, mapType(repository, attribute.type))
} }
else if (attribute.defaultValue != null) { else if (attribute.defaultValue != null) {
"noImpl" "definedExternally"
} }
else { else {
null null
+1 -1
View File
@@ -213,7 +213,7 @@ class AttributeVisitor(private val readOnly: Boolean = false, private val static
override fun visitOptionalOrRequiredArgument(ctx: WebIDLParser.OptionalOrRequiredArgumentContext): Attribute { override fun visitOptionalOrRequiredArgument(ctx: WebIDLParser.OptionalOrRequiredArgumentContext): Attribute {
if (ctx.children?.any { it is TerminalNode && it.text == "optional" } ?: false) { 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) { if (ctx.children?.any { it is TerminalNode && it.text == "required" } ?: false) {
required = true required = true
@@ -74,11 +74,11 @@ private fun Appendable.renderAttributeDeclarationAsProperty(arg: GenerateAttribu
appendln() appendln()
if (arg.getterNoImpl) { if (arg.getterNoImpl) {
indent(commented, level + 1) indent(commented, level + 1)
appendln("get() = noImpl") appendln("get() = definedExternally")
} }
if (arg.setterNoImpl) { if (arg.setterNoImpl) {
indent(commented, level + 1) 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.parse() = if (this.startsWith("0x")) BigInteger(this.substring(2), 16) else BigInteger(this)
private fun String.replaceWrongConstants(type: Type) = when { private fun String.replaceWrongConstants(type: Type) = when {
this == "null" && type.nullable -> "null" 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" type is SimpleType && type.type == "Double" && this.matches("[0-9]+".toRegex()) -> "${this}.0"
else -> this else -> this
} }