From 68e326922b24c57986601d8c42e25e265c78b371 Mon Sep 17 00:00:00 2001 From: Pavel Talanov Date: Fri, 24 Feb 2012 14:40:13 +0400 Subject: [PATCH] changes to jslib and TestConfig --- jslib/src/core/annotations.kt | 1 + jslib/src/core/date.kt | 6 + jslib/src/core/javalang.kt | 5 +- jslib/src/core/javautil.kt | 114 +++++++++--------- jslib/src/helper/ip.kt | 7 -- jslib/src/html5/canvas.kt | 21 +++- jslib/src/jquery/ui.kt | 5 + jslib/src/pixastic/pixastic.kt | 11 -- jslib/src/raphael/raphael.kt | 25 ++-- .../org/jetbrains/k2js/config/TestConfig.java | 3 +- 10 files changed, 102 insertions(+), 96 deletions(-) create mode 100644 jslib/src/core/date.kt delete mode 100644 jslib/src/helper/ip.kt delete mode 100644 jslib/src/pixastic/pixastic.kt diff --git a/jslib/src/core/annotations.kt b/jslib/src/core/annotations.kt index f63aff178ae..adafe8c4aa9 100644 --- a/jslib/src/core/annotations.kt +++ b/jslib/src/core/annotations.kt @@ -1,4 +1,5 @@ package js; + native annotation class native(name : String = "") {} native diff --git a/jslib/src/core/date.kt b/jslib/src/core/date.kt new file mode 100644 index 00000000000..cf551097b6a --- /dev/null +++ b/jslib/src/core/date.kt @@ -0,0 +1,6 @@ +package js + +native +class Date() { + fun getTime() : Int = js.noImpl +} \ No newline at end of file diff --git a/jslib/src/core/javalang.kt b/jslib/src/core/javalang.kt index 1cb140116f0..abd3beca109 100644 --- a/jslib/src/core/javalang.kt +++ b/jslib/src/core/javalang.kt @@ -5,10 +5,9 @@ import js.library library trait Iterable { - fun iterator() : java.util.Iterator {} + fun iterator() : java.util.Iterator = js.noImpl } library("splitString") -public fun String.split(regex : String) : Array { -} +public fun String.split(regex : String) : Array = js.noImpl diff --git a/jslib/src/core/javautil.kt b/jslib/src/core/javautil.kt index 64a5101bc46..954801cbcd6 100644 --- a/jslib/src/core/javautil.kt +++ b/jslib/src/core/javautil.kt @@ -4,7 +4,7 @@ import js.*; library("collectionsMax") -public fun max(col : Collection, comp : Comparator) : T {} +public fun max(col : Collection, comp : Comparator) : T = js.noImpl library public trait Comparator { @@ -12,13 +12,13 @@ public trait Comparator { } library("comparator") -public fun comparator(f : (T, T) -> Int) : Comparator {} +public fun comparator(f : (T, T) -> Int) : Comparator = js.noImpl library public open class Iterator() { - open fun next() : T {} - open fun hasNext() : Boolean {} + open fun next() : T = js.noImpl + open fun hasNext() : Boolean = js.noImpl } library @@ -29,23 +29,23 @@ val Collections = object { library public open class ArrayList() : java.util.List { - override public fun size() : Int {} - override public fun isEmpty() : Boolean {} - override public fun contains(o : Any?) : Boolean {} - override public fun iterator() : Iterator {} - // override public fun indexOf(o : Any?) : Int {} - // override public fun lastIndexOf(o : Any?) : Int {} - // override public fun toArray() : Array {} - // override public fun toArray(a : Array) : Array {} - override public fun get(index : Int) : E {} - override public fun set(index : Int, element : E) : E {} - override public fun add(e : E) : Boolean {} - override public fun add(index : Int, element : E) : Unit {} - override public fun remove(index : Int) : E {} - override public fun remove(o : Any?) : Boolean {} - override public fun clear() : Unit {} - override public fun addAll(c : java.util.Collection) : Boolean {} - // override public fun addAll(index : Int, c : java.util.Collection) : Boolean {} + override public fun size() : Int = js.noImpl + override public fun isEmpty() : Boolean = js.noImpl + override public fun contains(o : Any?) : Boolean = js.noImpl + override public fun iterator() : Iterator = js.noImpl + // override public fun indexOf(o : Any?) : Int = js.noImpl + // override public fun lastIndexOf(o : Any?) : Int = js.noImpl + // override public fun toArray() : Array = js.noImpl + // override public fun toArray(a : Array) : Array = js.noImpl + override public fun get(index : Int) : E = js.noImpl + override public fun set(index : Int, element : E) : E = js.noImpl + override public fun add(e : E) : Boolean = js.noImpl + override public fun add(index : Int, element : E) : Unit = js.noImpl + override public fun remove(index : Int) : E = js.noImpl + override public fun remove(o : Any?) : Boolean = js.noImpl + override public fun clear() : Unit = js.noImpl + override public fun addAll(c : java.util.Collection) : Boolean = js.noImpl + // override public fun addAll(index : Int, c : java.util.Collection) : Boolean = js.noImpl } library @@ -109,14 +109,14 @@ public trait Set : Collection { library public open class HashSet() : java.util.Set { - override public fun iterator() : java.util.Iterator {} - override public fun size() : Int {} - override public fun isEmpty() : Boolean {} - override public fun contains(o : Any?) : Boolean {} - override public fun add(e : E) : Boolean {} - override public fun remove(o : Any?) : Boolean {} - override public fun clear() : Unit {} - override fun addAll(c : java.util.Collection) : Boolean + override public fun iterator() : java.util.Iterator = js.noImpl + override public fun size() : Int = js.noImpl + override public fun isEmpty() : Boolean = js.noImpl + override public fun contains(o : Any?) : Boolean = js.noImpl + override public fun add(e : E) : Boolean = js.noImpl + override public fun remove(o : Any?) : Boolean = js.noImpl + override public fun clear() : Unit = js.noImpl + override fun addAll(c : java.util.Collection) : Boolean = js.noImpl } library @@ -136,40 +136,40 @@ public trait Map { library public open class HashMap() : java.util.Map { - override public fun size() : Int {} - override public fun isEmpty() : Boolean {} - override public fun get(key : Any?) : V {} - override public fun containsKey(key : Any?) : Boolean {} - override public fun put(key : K, value : V) : V {} - override public fun putAll(m : java.util.Map) : Unit {} - override public fun remove(key : Any?) : V? {} - override public fun clear() : Unit {} - override public fun containsValue(value : Any?) : Boolean {} - override public fun keySet() : java.util.Set {} - override public fun values() : java.util.Collection {} + override public fun size() : Int = js.noImpl + override public fun isEmpty() : Boolean = js.noImpl + override public fun get(key : Any?) : V = js.noImpl + override public fun containsKey(key : Any?) : Boolean = js.noImpl + override public fun put(key : K, value : V) : V = js.noImpl + override public fun putAll(m : java.util.Map) : Unit = js.noImpl + override public fun remove(key : Any?) : V? = js.noImpl + override public fun clear() : Unit = js.noImpl + override public fun containsValue(value : Any?) : Boolean = js.noImpl + override public fun keySet() : java.util.Set = js.noImpl + override public fun values() : java.util.Collection = js.noImpl } library public open class LinkedList() : List { - override public fun iterator() : java.util.Iterator {} - override public fun isEmpty() : Boolean {} - override public fun contains(o : Any?) : Boolean {} - override public fun size() : Int {} - override public fun add(e : E) : Boolean {} - override public fun remove(o : Any?) : Boolean {} - override public fun addAll(c : java.util.Collection) : Boolean {} - override public fun clear() : Unit {} - override public fun get(index : Int) : E {} - override public fun set(index : Int, element : E) : E {} - override public fun add(index : Int, element : E) : Unit {} - override public fun remove(index : Int) : E {} - public fun poll() : E? {} - public fun peek() : E? {} - public fun offer(e : E) : Boolean {} + override public fun iterator() : java.util.Iterator = js.noImpl + override public fun isEmpty() : Boolean = js.noImpl + override public fun contains(o : Any?) : Boolean = js.noImpl + override public fun size() : Int = js.noImpl + override public fun add(e : E) : Boolean = js.noImpl + override public fun remove(o : Any?) : Boolean = js.noImpl + override public fun addAll(c : java.util.Collection) : Boolean = js.noImpl + override public fun clear() : Unit = js.noImpl + override public fun get(index : Int) : E = js.noImpl + override public fun set(index : Int, element : E) : E = js.noImpl + override public fun add(index : Int, element : E) : Unit = js.noImpl + override public fun remove(index : Int) : E = js.noImpl + public fun poll() : E? = js.noImpl + public fun peek() : E? = js.noImpl + public fun offer(e : E) : Boolean = js.noImpl } library public class StringBuilder() { - public fun append(obj : Any) : StringBuilder - public fun toString() : String + public fun append(obj : Any) : StringBuilder = js.noImpl + public fun toString() : String = js.noImpl } \ No newline at end of file diff --git a/jslib/src/helper/ip.kt b/jslib/src/helper/ip.kt deleted file mode 100644 index d6f47cc8296..00000000000 --- a/jslib/src/helper/ip.kt +++ /dev/null @@ -1,7 +0,0 @@ -package ip.helper - -import html5.HTMLInputElement -import js.native - -native -fun getInputElement() : HTMLInputElement = js.noImpl \ No newline at end of file diff --git a/jslib/src/html5/canvas.kt b/jslib/src/html5/canvas.kt index 6caa62ab6d4..014de6b0cb2 100644 --- a/jslib/src/html5/canvas.kt +++ b/jslib/src/html5/canvas.kt @@ -75,12 +75,14 @@ class Context() { fun drawImage(image : HTMLImageElement, dx: Double, dy: Double, dw: Double, dh: Double) { } fun drawImage(image : HTMLImageElement, sx: Double, sy: Double, - sw: Double, sh: Double, dx: Double, dy: Double, dw: Double, dh: Double) { + sw: Double, sh: Double, dx: Double, dy: Double, dw: Double, dh: Double) { } fun createLinearGradient(x0 : Double, y0 : Double, x1 : Double, y1 : Double) : CanvasGradient = CanvasGradient() fun createRadialGradient(x0 : Double, y0 : Double, r0 : Double, x1 : Double, y1 : Double, r1 : Double) : CanvasGradient = CanvasGradient(); + fun getImageData(sx : Int, sy : Int, sw : Int, sh : Int) : ImageData = js.noImpl + fun putImageData(data : ImageData, dx : Int, dy : Int) : Unit = js.noImpl } native @@ -89,14 +91,25 @@ open class HTMLImageElement() : DomElement() { native class CanvasGradient() { - fun addColorStop(offset : Double, color : String) {} + fun addColorStop(offset : Double, color : String) { + } +} + +native +class ImageData() { + // readonly attribute unsigned long width; + // readonly attribute unsigned long height; + // readonly attribute Uint8ClampedArray data; + val width : Int = js.noImpl + val height : Int = js.noImpl + val data : Array = js.noImpl } native class Canvas() : DomElement() { - var width = 0.0; - var height = 0.0; + var width : Int = js.noImpl; + var height : Int = js.noImpl; //DOMString toDataURL(in optional DOMString type, in any... args); fun toDataURL() : String = js.noImpl diff --git a/jslib/src/jquery/ui.kt b/jslib/src/jquery/ui.kt index e9ca87be43a..ffccbe1f983 100644 --- a/jslib/src/jquery/ui.kt +++ b/jslib/src/jquery/ui.kt @@ -4,6 +4,7 @@ package jquery.ui //jquery UI import jquery.JQuery import js.native +import js.Json native fun JQuery.buttonset() : JQuery = js.noImpl; @@ -13,3 +14,7 @@ native fun JQuery.button() : JQuery = js.noImpl; native fun JQuery.accordion() : JQuery = js.noImpl +native +fun JQuery.draggable(params : Json) : JQuery = js.noImpl +native +fun JQuery.selectable() : JQuery = js.noImpl diff --git a/jslib/src/pixastic/pixastic.kt b/jslib/src/pixastic/pixastic.kt deleted file mode 100644 index 66bcf91bf97..00000000000 --- a/jslib/src/pixastic/pixastic.kt +++ /dev/null @@ -1,11 +0,0 @@ -package jquery.pixastic - -import jquery.JQuery -import js.native - -native -fun JQuery.pixastic(actionName : String) = js.noImpl - -native -fun addAction(actionName : String, - process : (oldData : Array, newData : Array, width : Int, height : Int)->Unit) = js.noImpl \ No newline at end of file diff --git a/jslib/src/raphael/raphael.kt b/jslib/src/raphael/raphael.kt index e30b63b15c1..ef74659206b 100644 --- a/jslib/src/raphael/raphael.kt +++ b/jslib/src/raphael/raphael.kt @@ -16,17 +16,17 @@ open class Element() { fun getTotalLength() : Double = 0.0 - fun getPointAtLength(length : Double) : Point {} + fun getPointAtLength(length : Double) : Point = js.noImpl - fun animate(params : Json, ms : Int, callback : ()-> Unit) : Element {} - fun animate(params : Json, ms : Int, s : String) : Element {} - fun animate(params : Json, ms : Int) : Element {} + fun animate(params : Json, ms : Int, callback : ()-> Unit) : Element = js.noImpl + fun animate(params : Json, ms : Int, s : String) : Element = js.noImpl + fun animate(params : Json, ms : Int) : Element = js.noImpl //fun mouse } native class Set() : Element() { - fun push(el : Element) {} + fun push(el : Element) = js.noImpl } native @@ -34,9 +34,9 @@ class Paper() { fun path(pathString : String) : Element = Element(); fun path() : Element = Element(); - fun ellipse(x : Int, y : Int, rx : Int, ry : Int) : Element {} - fun circle(x : Int, y : Int, r : Int) : Element {} - fun set() : Set {} + fun ellipse(x : Int, y : Int, rx : Int, ry : Int) : Element = js.noImpl + fun circle(x : Int, y : Int, r : Int) : Element = js.noImpl + fun set() : Set = js.noImpl val customAttributes : Json = Json(); } @@ -44,15 +44,16 @@ class Paper() { native("Raphael") fun Raphael(elementId : String, width : Int, height : Int) : Paper = Paper(); native("Raphael") -fun Raphael(elementId : String, width : Int, height : Int, initFun : Paper.() -> Unit) : Unit {} +fun Raphael(elementId : String, width : Int, height : Int, initFun : Paper.() -> Unit) : Unit = js.noImpl native -fun getColor() : Color {} +fun getColor() : Color = js.noImpl native -fun resetColors() {} +fun resetColors() = js.noImpl native -class Color() {} +class Color() { +} native class Point() { diff --git a/translator/src/org/jetbrains/k2js/config/TestConfig.java b/translator/src/org/jetbrains/k2js/config/TestConfig.java index e51961ff224..68a91518455 100644 --- a/translator/src/org/jetbrains/k2js/config/TestConfig.java +++ b/translator/src/org/jetbrains/k2js/config/TestConfig.java @@ -53,8 +53,7 @@ public final class TestConfig extends Config { "/raphael/raphael.kt", "/html5/canvas.kt", "/html5/files.kt", - "/html5/image.kt", - "/helper/ip.kt" + "/html5/image.kt" ); @NotNull