From d836ea04cb5efe0b8dfac9cd50038c61d0bd2f3e Mon Sep 17 00:00:00 2001 From: Pavel Talanov Date: Mon, 6 Feb 2012 14:19:58 +0400 Subject: [PATCH] added native math object --- jslib/src/core/math.kt | 26 +++++++++++++++++++ jslib/src/html5/core.kt | 7 +++-- .../src/org/jetbrains/k2js/config/Config.java | 3 ++- 3 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 jslib/src/core/math.kt diff --git a/jslib/src/core/math.kt b/jslib/src/core/math.kt new file mode 100644 index 00000000000..394758fe9b0 --- /dev/null +++ b/jslib/src/core/math.kt @@ -0,0 +1,26 @@ +package js; + +import js.annotations.native + +native +val Math = object { + native + fun random() : Double = 0.0; + fun abs(value : Double) = 0.0 + fun acos(value : Double) = 0.0 + fun asin(value : Double) = 0.0 + fun atan(value : Double) = 0.0 + fun atan2(x : Double, y : Double) = 0.0 + fun cos(value : Double) = 0.0 + fun sin(value : Double) = 0.0 + fun exp(value : Double) = 0.0 + fun max(vararg values : Double) = 0.0 + fun min(vararg values : Double) = 0.0 + fun sqrt(value : Double) = 0.0 + fun tan(value : Double) = 0.0 + fun log(value : Double) = 0.0 + fun pow(base : Double, exp : Double) = 0.0 + fun round(value : Double) = 0.0 + fun floor(value : Double) = 0.0 + fun ceil(value : Double) = 0.0 +} \ No newline at end of file diff --git a/jslib/src/html5/core.kt b/jslib/src/html5/core.kt index 356eba24015..9e2c5611e34 100644 --- a/jslib/src/html5/core.kt +++ b/jslib/src/html5/core.kt @@ -51,12 +51,11 @@ class TextMetrics() { val width : Int = 0 } +/*custom helpers*/ native fun getContext() : Context = Context(); - -native -fun random() : Double = 0.0 - +//native +//fun random() : Double = 0.0 native fun getCanvasWidth() : Double = 0.0 native diff --git a/translator/src/org/jetbrains/k2js/config/Config.java b/translator/src/org/jetbrains/k2js/config/Config.java index b36f22126c8..ae39f2dd735 100644 --- a/translator/src/org/jetbrains/k2js/config/Config.java +++ b/translator/src/org/jetbrains/k2js/config/Config.java @@ -31,8 +31,9 @@ public abstract class Config { PATH_TO_JS_LIB_SRC + "\\core\\javautil.kt", PATH_TO_JS_LIB_SRC + "\\core\\javalang.kt", PATH_TO_JS_LIB_SRC + "\\core\\core.kt", - PATH_TO_JS_LIB_SRC + "\\raphael\\raphael.kt", + PATH_TO_JS_LIB_SRC + "\\core\\math.kt", PATH_TO_JS_LIB_SRC + "\\core\\json.kt", + PATH_TO_JS_LIB_SRC + "\\raphael\\raphael.kt", PATH_TO_JS_LIB_SRC + "\\html5\\core.kt" );