Răsfoiți Sursa

Defining properties

Sebastien Ros 12 ani în urmă
părinte
comite
d88dd9569b

+ 5 - 1
Jint/Native/Number/NumberConstructor.cs

@@ -33,7 +33,11 @@ namespace Jint.Native.Number
 
         public void Configure()
         {
-
+            FastAddProperty("MAX_VALUE", double.MaxValue, false, false, false);
+            FastAddProperty("MIN_VALUE", double.Epsilon, false, false, false);
+            FastAddProperty("NaN", double.NaN, false, false, false);
+            FastAddProperty("NEGATIVE_INFINITY", double.NegativeInfinity, false, false, false);
+            FastAddProperty("POSITIVE_INFINITY", double.PositiveInfinity, false, false, false);
         }
 
         public override object Call(object thisObject, object[] arguments)

+ 28 - 6
Jint/Native/Number/NumberPrototype.cs

@@ -26,15 +26,37 @@ namespace Jint.Native.Number
 
         public void Configure()
         {
+            FastAddProperty("toString", new ClrFunctionInstance<object, object>(Engine, ToNumberString), false, false, false);
+            FastAddProperty("toLocaleString", new ClrFunctionInstance<object, object>(Engine, ToLocaleString), false, false, false);
+            FastAddProperty("valueOf", new ClrFunctionInstance<object, object>(Engine, ValueOf), false, false, false);
+            FastAddProperty("toFixed", new ClrFunctionInstance<object, object>(Engine, ToFixed), false, false, false);
+            FastAddProperty("toExponential", new ClrFunctionInstance<object, object>(Engine, ToExponential), false, false, false);
+            FastAddProperty("toPrecision", new ClrFunctionInstance<object, object>(Engine, ToPrecision), false, false, false);
+        }
 
+        private object ToLocaleString(object arg1, object[] arg2)
+        {
+            throw new System.NotImplementedException();
+        }
 
-            FastAddProperty("NaN", double.NaN, false, false, false);
-            FastAddProperty("MAX_VALUE", double.MaxValue, false, false, false);
-            FastAddProperty("MIN_VALUE", double.MinValue, false, false, false);
-            FastAddProperty("POSITIVE_INFINITY", double.PositiveInfinity, false, false, false);
-            FastAddProperty("NEGATIVE_INFINITY", double.NegativeInfinity, false, false, false);
+        private object ValueOf(object arg1, object[] arg2)
+        {
+            throw new System.NotImplementedException();
+        }
 
-            FastAddProperty("toString", new ClrFunctionInstance<object, object>(Engine, ToNumberString), false, false, false);
+        private object ToFixed(object arg1, object[] arg2)
+        {
+            throw new System.NotImplementedException();
+        }
+
+        private object ToExponential(object arg1, object[] arg2)
+        {
+            throw new System.NotImplementedException();
+        }
+
+        private object ToPrecision(object arg1, object[] arg2)
+        {
+            throw new System.NotImplementedException();
         }
 
         private static object ToNumberString(object thisObject, object[] arguments)

+ 6 - 0
Jint/Native/String/StringConstructor.cs

@@ -1,6 +1,7 @@
 using Jint.Native.Function;
 using Jint.Native.Object;
 using Jint.Runtime;
+using Jint.Runtime.Interop;
 
 namespace Jint.Native.String
 {
@@ -30,7 +31,12 @@ namespace Jint.Native.String
 
         public void Configure()
         {
+            FastAddProperty("fromCharCode", new ClrFunctionInstance<object, object>(Engine, FromCharCode), false, false, false);
+        }
 
+        private object FromCharCode(object arg1, object[] arg2)
+        {
+            throw new System.NotImplementedException();
         }
 
         public override object Call(object thisObject, object[] arguments)