浏览代码

[cs] use @:readOnly static vars for Math constants instead of __init__ method, so they're not generated if not used.

Dan Korostelev 10 年之前
父节点
当前提交
5da8881c53
共有 1 个文件被更改,包括 11 次插入17 次删除
  1. 11 17
      std/cs/_std/Math.hx

+ 11 - 17
std/cs/_std/Math.hx

@@ -19,25 +19,19 @@
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
  */
-package;
-import cs.system.Random;
-
 @:coreApi @:nativeGen class Math
 {
-	public static inline function __init__():Void
-	{
-		PI = cs.system.Math.PI;
-		NaN = cs.system.Double.NaN;
-		NEGATIVE_INFINITY = cs.system.Double.NegativeInfinity;
-		POSITIVE_INFINITY = cs.system.Double.PositiveInfinity;
-		rand = new Random();
-	}
-
-	private static var rand:Random;
-	public static var PI(default, null) : Float;
-	public static var NaN(default,null) : Float;
-	public static var NEGATIVE_INFINITY(default,null) : Float;
-	public static var POSITIVE_INFINITY(default,null) : Float;
+	@:readOnly
+	private static var rand = new cs.system.Random();
+
+	@:readOnly
+	public static var PI(default,null) = cs.system.Math.PI;
+	@:readOnly
+	public static var NaN(default,null) = cs.system.Double.NaN;
+	@:readOnly
+	public static var NEGATIVE_INFINITY(default,null) = cs.system.Double.NegativeInfinity;
+	@:readOnly
+	public static var POSITIVE_INFINITY(default,null) = cs.system.Double.PositiveInfinity;
 
 	public static inline function abs(v:Float):Float
 	{