home *** CD-ROM | disk | FTP | other *** search
- public class JScriptMathObject extends JSbxObject implements JSbxPropertyInterface {
- private static final int MATH_ID_ABS = 1;
- private static final int MATH_ID_ACOS = 2;
- private static final int MATH_ID_ASIN = 3;
- private static final int MATH_ID_ATAN = 4;
- private static final int MATH_ID_CEIL = 5;
- private static final int MATH_ID_COS = 6;
- private static final int MATH_ID_EXP = 7;
- private static final int MATH_ID_FLOOR = 8;
- private static final int MATH_ID_LOG = 9;
- private static final int MATH_ID_MAX = 10;
- private static final int MATH_ID_MIN = 11;
- private static final int MATH_ID_POW = 12;
- private static final int MATH_ID_RANDOM = 13;
- private static final int MATH_ID_ROUND = 14;
- private static final int MATH_ID_SIN = 15;
- private static final int MATH_ID_SQRT = 16;
- private static final int MATH_ID_TAN = 17;
- private static final int MATH_ID_ATAN2 = 18;
-
- public JScriptMathObject() {
- try {
- ((JSbxObject)this).Put(new JSbxValueProperty("E", this, new JSbxValue(Math.E), true, true));
- ((JSbxObject)this).Put(new JSbxValueProperty("LN2", this, new JSbxValue(0.6931471805599453), true, true));
- ((JSbxObject)this).Put(new JSbxValueProperty("LN10", this, new JSbxValue(2.302585092994046), true, true));
- ((JSbxObject)this).Put(new JSbxValueProperty("LOG2E", this, new JSbxValue(1.4426950408889634), true, true));
- ((JSbxObject)this).Put(new JSbxValueProperty("LOG10E", this, new JSbxValue(0.4342944819032518), true, true));
- ((JSbxObject)this).Put(new JSbxValueProperty("PI", this, new JSbxValue(Math.PI), true, true));
- ((JSbxObject)this).Put(new JSbxValueProperty("SQRT1_2", this, new JSbxValue(0.7071067811865476), true, true));
- ((JSbxObject)this).Put(new JSbxValueProperty("SQRT2", this, new JSbxValue(1.4142135623730951), true, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("abs", this, this, 1, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("acos", this, this, 2, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("asin", this, this, 3, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("atan", this, this, 4, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("ceil", this, this, 5, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("cos", this, this, 6, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("exp", this, this, 7, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("floor", this, this, 8, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("log", this, this, 9, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("max", this, this, 10, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("min", this, this, 11, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("pow", this, this, 12, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("random", this, this, 13, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("round", this, this, 14, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("sin", this, this, 15, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("sqrt", this, this, 16, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("tan", this, this, 17, false, true));
- ((JSbxObject)this).Put(new JSbxObjectProperty("atan2", this, this, 18, false, true));
- } catch (JSbxException var1) {
- }
- }
-
- public JSbxValue PropertyCallFunction(JSbxObjectProperty var1, JScriptCallParam var2) throws JSbxExceptionBase {
- JSbxVector var3 = var2.GetParamVector();
- int var4 = var1.GetID();
- double var5 = (double)0.0F;
- double var7 = (double)0.0F;
- if (var4 != 13) {
- var7 = JScriptWindowObject.GetDoubleParam(var3, 0);
- }
-
- switch (var4) {
- case 1:
- var5 = Math.abs(var7);
- break;
- case 2:
- var5 = Math.acos(var7);
- break;
- case 3:
- var5 = Math.asin(var7);
- break;
- case 4:
- var5 = Math.atan(var7);
- break;
- case 5:
- var5 = Math.ceil(var7);
- break;
- case 6:
- var5 = Math.cos(var7);
- break;
- case 7:
- var5 = Math.exp(var7);
- break;
- case 8:
- var5 = Math.floor(var7);
- break;
- case 9:
- var5 = Math.log(var7);
- break;
- case 10:
- var5 = Math.max(var7, JScriptWindowObject.GetDoubleParam(var3, 1));
- break;
- case 11:
- var5 = Math.min(var7, JScriptWindowObject.GetDoubleParam(var3, 1));
- break;
- case 12:
- var5 = Math.pow(var7, JScriptWindowObject.GetDoubleParam(var3, 1));
- break;
- case 13:
- var5 = Math.random();
- break;
- case 14:
- var5 = (double)Math.round(var7);
- break;
- case 15:
- var5 = Math.sin(var7);
- break;
- case 16:
- var5 = Math.sqrt(var7);
- break;
- case 17:
- var5 = Math.tan(var7);
- break;
- case 18:
- var5 = Math.atan2(var7, JScriptWindowObject.GetDoubleParam(var3, 1));
- }
-
- JSbxValue var9 = new JSbxValue(var5);
- var2.GetRuntimeParam().SetReturnValue(var9);
- return var9;
- }
-
- public void PropertyGet(JSbxObjectProperty var1, JSbxValue var2) throws JSbxException {
- }
-
- public void PropertyPut(JSbxObjectProperty var1, JSbxValue var2) throws JSbxException {
- }
-
- public String Property_GetJScript_typeofString(JSbxObjectProperty var1) {
- return "function";
- }
-
- public String GetJScriptString(boolean var1) {
- return "function Math() { [native code] }";
- }
- }
-