From 58d96ab75bac152f9e7acde3aa20cf54d156712e Mon Sep 17 00:00:00 2001 From: Pavel Talanov Date: Thu, 2 Feb 2012 15:05:11 +0400 Subject: [PATCH] added html5 api files --- jslib/src/html5/core.kt | 63 +++++++++++++++++++ .../translate/operation/OperatorTable.java | 2 +- translator/testFiles/kotlin_lib.js | 4 ++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 jslib/src/html5/core.kt diff --git a/jslib/src/html5/core.kt b/jslib/src/html5/core.kt new file mode 100644 index 00000000000..7cadb690977 --- /dev/null +++ b/jslib/src/html5/core.kt @@ -0,0 +1,63 @@ +package html5 + +import js.annotations.Native + +Native +class Context() { + fun save() {} + fun restore() {} + + fun scale(x : Double, y : Double) {} + fun rotate(angle : Double) {} + fun translate(x : Double, y : Double) {} + + fun fillRect(x : Double, y : Double, w : Double, h : Double) {} + fun strokeRect(x : Double, y : Double, w : Double, h : Double) {} + + var globalAlpha : Double = 1.0; + var strokeStyle : String = "" + var fillStyle : String = "" + var lineWidth : Double = 1.0 + var shadowOffsetX : Double = 0.0 + var shadowOffsetY : Double = 0.0 + var shadowBlur : Double = 0.0 + var shadowColor : String = "" + var font : String = "" + + fun beginPath() {} + fun moveTo(x : Double, y : Double) {} + fun closePath() {} + + fun lineTo(x : Double, y : Double) {} + fun quadraticCurveTo(cpx : Double, cpy : Double, x : Double, y : Double) {} + fun bezierCurveTo(cp1x : Double, cp1y : Double, cp2x : Double, cp2y : Double, x : Double, y : Double) {} + fun arcTo(x1 : Double, y1 : Double, x2 : Double, y2 : Double, radius : Double) {} + fun arc(x : Double, y : Double, radius : Double, startAngle : Double, endAngle : Double, anticlockwise : Boolean= false) {} + + fun rect(x : Double, y : Double, w : Double, h : Double) {} + fun fill() {} + fun stroke() {} + + fun fillText(text : String, x : Double, y : Double) {} + fun fillText(text : String, x : Double, y : Double, maxWidth : Double) {} + fun strokeText(text : String, x : Double, y : Double) {} + fun strokeText(text : String, x : Double, y : Double, maxWidth : Double) {} + + fun measureText(text : String) : TextMetrics = TextMetrics(); +} + +Native +class TextMetrics() { + val width : Int = 0 +} + +Native +fun getContext() : Context = Context(); + +Native +fun random() : Double = 0.0 + +Native +fun getCanvasWidth() : Double = 0.0 +Native +fun getCanvasHeight() : Double = 0.0 \ No newline at end of file diff --git a/translator/src/org/jetbrains/k2js/translate/operation/OperatorTable.java b/translator/src/org/jetbrains/k2js/translate/operation/OperatorTable.java index bcc4d882721..29796ce9483 100644 --- a/translator/src/org/jetbrains/k2js/translate/operation/OperatorTable.java +++ b/translator/src/org/jetbrains/k2js/translate/operation/OperatorTable.java @@ -13,7 +13,7 @@ import java.util.Map; * @author Pavel Talanov */ -//TODO: change using guava builders +//TODO: refactor using guava builders public final class OperatorTable { private static final Map binaryOperatorsMap = new HashMap(); diff --git a/translator/testFiles/kotlin_lib.js b/translator/testFiles/kotlin_lib.js index fab347c438f..ba7106ec77d 100644 --- a/translator/testFiles/kotlin_lib.js +++ b/translator/testFiles/kotlin_lib.js @@ -460,6 +460,10 @@ } ); + Kotlin.collectionsMax = function(col, comp) { + + }; + Kotlin.StringBuilder = Kotlin.Class.create( { initialize:function () {