added jslib changes

This commit is contained in:
Pavel Talanov
2012-02-03 16:20:55 +04:00
parent 566eb09139
commit f285d55d09
9 changed files with 56 additions and 58 deletions
+2 -4
View File
@@ -1,6 +1,4 @@
package js.annotations;
annotation class Native(name : String = "")
annotation class LibraryClass() {}
annotation class LibraryFun(name : String = "") {}
annotation class native(name : String = "")
annotation class library(name : String = "") {}
+12 -12
View File
@@ -1,26 +1,26 @@
package js;
import js.annotations.LibraryFun
import js.annotations.LibraryClass
import js.annotations.Native
import js.annotations.library
import js.annotations.library
import js.annotations.native
LibraryFun("println")
library("println")
fun println() {}
LibraryFun("println")
library("println")
fun println(s : Any?) {}
LibraryFun("print")
library("print")
fun print(s : Any?) {}
LibraryFun("parseInt")
library("parseInt")
fun parseInt(s : String) : Int = 0
LibraryClass
library
open class Exception() {}
LibraryClass
library
class NumberFormatException() : Exception() {}
Native
native
fun setTimeout(callback : ()-> Unit) {}
Native
native
fun setInterval(callback : ()-> Unit, ms : Int) {}
Native
native
fun setInterval(callback : ()-> Unit) {}
+2 -2
View File
@@ -1,9 +1,9 @@
package java.lang
import java.util.Iterator;
import js.annotations.LibraryClass
import js.annotations.library
LibraryClass
library
trait Iterable<T> {
fun iterator() : java.util.Iterator<T> {}
}
+11 -11
View File
@@ -2,22 +2,22 @@ package java.util
import js.annotations.*;
LibraryClass
library
public trait Comparator<T> {
fun compare(obj1 : T, obj2 : T) : Int;
}
LibraryFun("comparator")
library("comparator")
public fun comparator<T>(f : (T, T) -> Int) : Comparator<T> {}
LibraryClass
library
public open class Iterator<T>() {
open fun next() : T {}
open fun hasNext() : Boolean {}
}
LibraryClass
library
public open class ArrayList<erased E>() : java.util.List<E> {
override public fun size() : Int {}
override public fun isEmpty() : Boolean {}
@@ -38,7 +38,7 @@ public open class ArrayList<erased E>() : java.util.List<E> {
// override public fun addAll(index : Int, c : java.util.Collection<out E>) : Boolean {}
}
LibraryClass
library
public trait Collection<erased E> : java.lang.Iterable<E> {
open fun size() : Int
open fun isEmpty() : Boolean
@@ -55,7 +55,7 @@ public trait Collection<erased E> : java.lang.Iterable<E> {
open fun clear() : Unit
}
LibraryClass
library
public trait List<erased E> : java.util.Collection<E> {
override fun size() : Int
override fun isEmpty() : Boolean
@@ -80,7 +80,7 @@ public trait List<erased E> : java.util.Collection<E> {
// open fun lastIndexOf(o : Any?) : Int
}
LibraryClass
library
public trait Set<erased E> : java.util.Collection<E> {
override fun size() : Int
override fun isEmpty() : Boolean
@@ -97,7 +97,7 @@ public trait Set<erased E> : java.util.Collection<E> {
override fun clear() : Unit
}
LibraryClass
library
public open class HashSet<erased E>() : java.util.Set<E> {
override public fun iterator() : java.util.Iterator<E> {}
override public fun size() : Int {}
@@ -109,7 +109,7 @@ public open class HashSet<erased E>() : java.util.Set<E> {
override fun addAll(c : java.util.Collection<out E>) : Boolean
}
LibraryClass
library
public trait Map<erased K, erased V> {
open fun size() : Int
open fun isEmpty() : Boolean
@@ -124,7 +124,7 @@ public trait Map<erased K, erased V> {
open fun values() : java.util.Collection<V>
}
LibraryClass
library
public open class HashMap<erased K, erased V>() : java.util.Map<K, V> {
override public fun size() : Int {}
override public fun isEmpty() : Boolean {}
@@ -139,7 +139,7 @@ public open class HashMap<erased K, erased V>() : java.util.Map<K, V> {
override public fun values() : java.util.Collection<V> {}
}
LibraryClass
library
public class StringBuilder() {
public fun append(obj : Any) : StringBuilder
public fun toString() : String
+2 -2
View File
@@ -1,8 +1,8 @@
package java.util.Collections;
import js.annotations.LibraryFun
import js.annotations.library
import java.util.Collection
import java.util.Comparator
LibraryFun("collectionsMax")
library("collectionsMax")
public fun max<T>(col : Collection<T>, comp : Comparator<T>) {}
+4 -4
View File
@@ -1,17 +1,17 @@
package js
import java.util.*;
import js.annotations.LibraryFun
import js.annotations.library
class Json() {
}
LibraryFun("jsonSet")
library("jsonSet")
fun Json.set(paramName : String, value : Any?) : Unit {}
LibraryFun("jsonGet")
library("jsonGet")
fun Json.get(paramName : String) : Any? = null
fun <K, V> Map<K, V>.toJson() : Json = Json()
LibraryFun("jsonFromTuples")
library("jsonFromTuples")
fun json(vararg pairs : Tuple2<String, Any?>) = Json()
+7 -7
View File
@@ -1,8 +1,8 @@
package html5
import js.annotations.Native
import js.annotations.native
Native
native
class Context() {
fun save() {}
fun restore() {}
@@ -46,18 +46,18 @@ class Context() {
fun measureText(text : String) : TextMetrics = TextMetrics();
}
Native
native
class TextMetrics() {
val width : Int = 0
}
Native
native
fun getContext() : Context = Context();
Native
native
fun random() : Double = 0.0
Native
native
fun getCanvasWidth() : Double = 0.0
Native
native
fun getCanvasHeight() : Double = 0.0
+7 -7
View File
@@ -2,7 +2,7 @@ package jquery;
import js.annotations.*;
Native
native
class JQuery() {
fun addClass(className : String) : JQuery = this;
fun addClass(f : DomElement.(Int, String)->String) = this;
@@ -35,15 +35,15 @@ open class DomElement() {
//val document = object : DomElement() {}
Native("$")
native("$")
fun jq(selector : String) = JQuery();
Native("$")
native("$")
fun jq(selector : String, context : DomElement) = JQuery();
Native("$")
native("$")
fun jq(callback : () -> Unit) = JQuery();
Native("$")
native("$")
fun jq(obj : JQuery) = JQuery();
Native("$")
native("$")
fun jq(el : DomElement) = JQuery();
Native("$")
native("$")
fun jq() = JQuery();
+9 -9
View File
@@ -3,7 +3,7 @@ package raphael
import js.annotations.*;
import js.*;
Native
native
open class Element() {
fun attr(name : String, value : Any?) : Element = this
@@ -24,12 +24,12 @@ open class Element() {
//fun mouse
}
Native
native
class Set() : Element() {
fun push(el : Element) {}
}
Native
native
class Paper() {
fun path(pathString : String) : Element = Element();
fun path() : Element = Element();
@@ -41,20 +41,20 @@ class Paper() {
val customAttributes : Json = Json();
}
Native("Raphael")
native("Raphael")
fun Raphael(elementId : String, width : Int, height : Int) : Paper = Paper();
Native("Raphael")
native("Raphael")
fun Raphael(elementId : String, width : Int, height : Int, initFun : Paper.() -> Unit) : Unit {}
Native
native
fun getColor() : Color {}
Native
native
fun resetColors() {}
Native
native
class Color() {}
Native
native
class Point() {
val x = 0
val y = 0