JS IDL2K move Event, EventListener and EventTarget to org.w3c.events

This commit is contained in:
Sergey Mashkov
2015-05-14 14:01:48 +03:00
parent f20e76c185
commit 425efa3ae1
5 changed files with 113 additions and 82 deletions
@@ -60,6 +60,59 @@ native public open class MouseEvent(typeArg: String, mouseEventInitDict: MouseEv
fun initMouseEvent(typeArg: String, bubblesArg: Boolean, cancelableArg: Boolean, viewArg: Window?, detailArg: Int, screenXArg: Int, screenYArg: Int, clientXArg: Int, clientYArg: Int, ctrlKeyArg: Boolean, altKeyArg: Boolean, shiftKeyArg: Boolean, metaKeyArg: Boolean, buttonArg: Short, relatedTargetArg: EventTarget?): Unit = noImpl
}
native public open class Event(type: String, eventInitDict: EventInit = noImpl) {
var type: String
get() = noImpl
set(value) = noImpl
var target: EventTarget?
get() = noImpl
set(value) = noImpl
var currentTarget: EventTarget?
get() = noImpl
set(value) = noImpl
var eventPhase: Short
get() = noImpl
set(value) = noImpl
var bubbles: Boolean
get() = noImpl
set(value) = noImpl
var cancelable: Boolean
get() = noImpl
set(value) = noImpl
var defaultPrevented: Boolean
get() = noImpl
set(value) = noImpl
var isTrusted: Boolean
get() = noImpl
set(value) = noImpl
var timeStamp: Number
get() = noImpl
set(value) = noImpl
fun stopPropagation(): Unit = noImpl
fun stopImmediatePropagation(): Unit = noImpl
fun preventDefault(): Unit = noImpl
fun initEvent(type: String, bubbles: Boolean, cancelable: Boolean): Unit = noImpl
companion object {
val NONE: Short = 0
val CAPTURING_PHASE: Short = 1
val AT_TARGET: Short = 2
val BUBBLING_PHASE: Short = 3
}
}
native public trait EventTarget {
fun addEventListener(type: String, callback: EventListener?, capture: Boolean = false): Unit = noImpl
fun addEventListener(type: String, callback: ((Event) -> Unit)?, capture: Boolean = false): Unit = noImpl
fun removeEventListener(type: String, callback: EventListener?, capture: Boolean = false): Unit = noImpl
fun removeEventListener(type: String, callback: ((Event) -> Unit)?, capture: Boolean = false): Unit = noImpl
fun dispatchEvent(event: Event): Boolean = noImpl
}
native public trait EventListener {
fun handleEvent(event: Event): Unit = noImpl
}
native public open class UIEvent(type: String, eventInitDict: UIEventInit = noImpl) : Event(type, eventInitDict) {
var view: Window?
get() = noImpl
@@ -4192,47 +4192,6 @@ native public trait HTMLImageElement : HTMLElement, CanvasImageSource, ImageBitm
native public trait HTMLPictureElement : HTMLElement {
}
native public open class Event(type: String, eventInitDict: EventInit = noImpl) {
var type: String
get() = noImpl
set(value) = noImpl
var target: EventTarget?
get() = noImpl
set(value) = noImpl
var currentTarget: EventTarget?
get() = noImpl
set(value) = noImpl
var eventPhase: Short
get() = noImpl
set(value) = noImpl
var bubbles: Boolean
get() = noImpl
set(value) = noImpl
var cancelable: Boolean
get() = noImpl
set(value) = noImpl
var defaultPrevented: Boolean
get() = noImpl
set(value) = noImpl
var isTrusted: Boolean
get() = noImpl
set(value) = noImpl
var timeStamp: Number
get() = noImpl
set(value) = noImpl
fun stopPropagation(): Unit = noImpl
fun stopImmediatePropagation(): Unit = noImpl
fun preventDefault(): Unit = noImpl
fun initEvent(type: String, bubbles: Boolean, cancelable: Boolean): Unit = noImpl
companion object {
val NONE: Short = 0
val CAPTURING_PHASE: Short = 1
val AT_TARGET: Short = 2
val BUBBLING_PHASE: Short = 3
}
}
native public open class EventInit {
var bubbles: Boolean = false
var cancelable: Boolean = false
@@ -4249,18 +4208,6 @@ native public open class CustomEventInit : EventInit() {
var detail: Any? = null
}
native public trait EventTarget {
fun addEventListener(type: String, callback: EventListener?, capture: Boolean = false): Unit = noImpl
fun addEventListener(type: String, callback: ((Event) -> Unit)?, capture: Boolean = false): Unit = noImpl
fun removeEventListener(type: String, callback: EventListener?, capture: Boolean = false): Unit = noImpl
fun removeEventListener(type: String, callback: ((Event) -> Unit)?, capture: Boolean = false): Unit = noImpl
fun dispatchEvent(event: Event): Boolean = noImpl
}
native public trait EventListener {
fun handleEvent(event: Event): Unit = noImpl
}
native public trait NodeList {
var length: Int
get() = noImpl
@@ -0,0 +1,50 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.idl2k
val urls = listOf(
"https://raw.githubusercontent.com/whatwg/html-mirror/master/source" to "org.w3c.dom",
"https://html.spec.whatwg.org/" to "org.w3c.dom",
"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/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",
"http://web.archive.org/web/20150317051602/http://www.w3.org/TR/SVG11/single-page.html" to "org.w3c.dom.svg",
"https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl" to "org.khronos.webgl",
"https://www.khronos.org/registry/typedarray/specs/latest/typedarray.idl" to "org.khronos.webgl",
"https://raw.githubusercontent.com/whatwg/xhr/master/Overview.src.html" to "org.w3c.xhr",
"https://raw.githubusercontent.com/whatwg/fetch/master/Overview.src.html" to "org.w3c.fetch",
"https://raw.githubusercontent.com/w3c/FileAPI/gh-pages/index.html" to "org.w3c.files",
"https://raw.githubusercontent.com/whatwg/notifications/master/notifications.html" to "org.w3c.notifications",
"https://raw.githubusercontent.com/whatwg/fullscreen/master/Overview.src.html" to "org.w3c.fullscreen",
"http://www.w3.org/TR/vibration/" to "org.w3c.vibration",
"http://www.w3.org/TR/hr-time/" to "org.w3c.performance",
"http://www.w3.org/TR/2012/REC-navigation-timing-20121217/" to "org.w3c.performance",
"http://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html" to "org.w3c.workers"
)
val relocations = mapOf(
"Event" to "org.w3c.dom.events",
"EventTarget" to "org.w3c.dom.events",
"EventListener" to "org.w3c.dom.events"
)
@@ -16,40 +16,13 @@
package org.jetbrains.idl2k.dl
import org.jetbrains.idl2k.urls
import org.jsoup.Jsoup
import org.jsoup.nodes.Element
import org.jsoup.parser.Tag
import java.io.File
import java.net.URL
val urls = listOf(
"https://raw.githubusercontent.com/whatwg/html-mirror/master/source" to "org.w3c.dom",
"https://html.spec.whatwg.org/" to "org.w3c.dom",
"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/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",
"http://web.archive.org/web/20150317051602/http://www.w3.org/TR/SVG11/single-page.html" to "org.w3c.dom.svg",
"https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl" to "org.khronos.webgl",
"https://www.khronos.org/registry/typedarray/specs/latest/typedarray.idl" to "org.khronos.webgl",
"https://raw.githubusercontent.com/whatwg/xhr/master/Overview.src.html" to "org.w3c.xhr",
"https://raw.githubusercontent.com/whatwg/fetch/master/Overview.src.html" to "org.w3c.fetch",
"https://raw.githubusercontent.com/w3c/FileAPI/gh-pages/index.html" to "org.w3c.files",
"https://raw.githubusercontent.com/whatwg/notifications/master/notifications.html" to "org.w3c.notifications",
"https://raw.githubusercontent.com/whatwg/fullscreen/master/Overview.src.html" to "org.w3c.fullscreen",
"http://www.w3.org/TR/vibration/" to "org.w3c.vibration",
"http://www.w3.org/TR/hr-time/" to "org.w3c.performance",
"http://www.w3.org/TR/2012/REC-navigation-timing-20121217/" to "org.w3c.performance",
"http://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html" to "org.w3c.workers"
)
fun main(args: Array<String>) {
val dir = File("../../idl")
dir.mkdirs()
@@ -25,7 +25,15 @@ fun main(args: Array<String>) {
)
}
val definitions = mapDefinitions(repository, repository.interfaces.values())
val definitions = mapDefinitions(repository, repository.interfaces.values()).map {
if (it.name in relocations) {
// we need this to get interfaces listed in the relocations in valid package
// to keep compatibility with DOM Java API
it.copy(namespace = relocations[it.name]!!)
} else {
it
}
}
val unions = generateUnions(definitions, repository.typeDefs.values())
val allPackages = definitions.map { it.namespace }.distinct().sort()