JS stubs: add CSSOM view specification and GEOMETRY spec

This commit is contained in:
Sergey Mashkov
2015-05-25 12:19:23 +03:00
parent 4fd1b46e91
commit 07a3233569
8 changed files with 996 additions and 14 deletions
@@ -21,6 +21,8 @@ val urls = listOf(
"https://raw.githubusercontent.com/whatwg/dom/master/dom.html" to "org.w3c.dom",
"https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html" to "org.w3c.dom",
"http://www.w3.org/TR/animation-timing/" to "org.w3c.dom",
"http://www.w3.org/TR/geometry-1/" to "org.w3c.dom",
"http://www.w3.org/TR/cssom-view/" to "org.w3c.dom",
"http://www.w3.org/TR/uievents/" to "org.w3c.dom.events",
"http://dev.w3.org/csswg/cssom/" to "org.w3c.dom.css",
"http://www.w3.org/TR/DOM-Parsing/" to "org.w3c.dom.parsing",
@@ -27,7 +27,18 @@ fun main(args: Array<String>) {
val dir = File("../../idl")
dir.mkdirs()
val urlsPerFiles = urls.groupBy { it.second + ".idl" }
var packageFilter: String? = null
val argsIterator = args.iterator()
while (argsIterator.hasNext()) {
val arg = argsIterator.next()
when (arg) {
"-package", "-pkg", "--package" -> if (argsIterator.hasNext()) packageFilter = argsIterator.next() else throw IllegalArgumentException("argument $arg requires argument")
else -> throw IllegalArgumentException("Argument $arg is unknown")
}
}
val urlsPerFiles = urls.filter { packageFilter == null || it.second == packageFilter }.groupBy { it.second + ".idl" }
urlsPerFiles.forEach { e ->
val fileName = e.key
@@ -39,7 +39,11 @@ private fun Appendable.renderAttributeDeclaration(arg: GenerateAttribute, overri
private val keywords = setOf("interface")
private fun String.parse() = if (this.startsWith("0x")) BigInteger(this.substring(2), 16) else BigInteger(this)
private fun String.replaceWrongConstants(type: String) = if (this == "noImpl" || type == "Int" && parse() > BigInteger.valueOf(Int.MAX_VALUE.toLong())) "noImpl" else this
private fun String.replaceWrongConstants(type: String) = when {
this == "noImpl" || type == "Int" && parse() > BigInteger.valueOf(Int.MAX_VALUE.toLong()) -> "noImpl"
type == "Double" && this.matches("[0-9]+".toRegex()) -> "${this}.0"
else -> this
}
private fun String.replaceKeywords() = if (this in keywords) this + "_" else this
private fun Appendable.renderArgumentsDeclaration(args: List<GenerateAttribute>, omitDefaults: Boolean) =