StringPrototype.cs 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using System;
  2. using Jint.Runtime.Interop;
  3. namespace Jint.Native.String
  4. {
  5. /// <summary>
  6. /// http://www.ecma-international.org/ecma-262/5.1/#sec-15.5.4
  7. /// </summary>
  8. public sealed class StringPrototype : StringInstance
  9. {
  10. private StringPrototype(Engine engine)
  11. : base(engine)
  12. {
  13. }
  14. public static StringPrototype CreatePrototypeObject(Engine engine, StringConstructor stringConstructor)
  15. {
  16. var obj = new StringPrototype(engine);
  17. obj.Prototype = engine.Object.PrototypeObject;
  18. obj.PrimitiveValue = "";
  19. obj.FastAddProperty("constructor", stringConstructor, false, false, false);
  20. return obj;
  21. }
  22. public void Configure()
  23. {
  24. FastAddProperty("toString", new ClrFunctionInstance<object, object>(Engine, ToStringString), false, false, false);
  25. FastAddProperty("valueOf", new ClrFunctionInstance<object, object>(Engine, ValueOf), false, false, false);
  26. FastAddProperty("charAt", new ClrFunctionInstance<object, object>(Engine, CharAt), false, false, false);
  27. FastAddProperty("charCodeAt", new ClrFunctionInstance<object, object>(Engine, CharCodeAt), false, false, false);
  28. FastAddProperty("concat", new ClrFunctionInstance<object, object>(Engine, Concat), false, false, false);
  29. FastAddProperty("indexOf", new ClrFunctionInstance<object, object>(Engine, IndexOf), false, false, false);
  30. FastAddProperty("lastIndexOf", new ClrFunctionInstance<object, object>(Engine, LastIndexOf), false, false, false);
  31. FastAddProperty("localeCompare", new ClrFunctionInstance<object, object>(Engine, LocaleCompare), false, false, false);
  32. FastAddProperty("match", new ClrFunctionInstance<object, object>(Engine, Match), false, false, false);
  33. FastAddProperty("replace", new ClrFunctionInstance<object, object>(Engine, Replace), false, false, false);
  34. FastAddProperty("search", new ClrFunctionInstance<object, object>(Engine, Search), false, false, false);
  35. FastAddProperty("slice", new ClrFunctionInstance<object, object>(Engine, Slice), false, false, false);
  36. FastAddProperty("split", new ClrFunctionInstance<object, object>(Engine, Split), false, false, false);
  37. FastAddProperty("substring", new ClrFunctionInstance<object, object>(Engine, Substring), false, false, false);
  38. FastAddProperty("toLowerCase", new ClrFunctionInstance<object, object>(Engine, ToLowerCase), false, false, false);
  39. FastAddProperty("toLocaleLowerCase", new ClrFunctionInstance<object, object>(Engine, ToLocaleLowerCase), false, false, false);
  40. FastAddProperty("toUpperCase", new ClrFunctionInstance<object, object>(Engine, ToUpperCase), false, false, false);
  41. FastAddProperty("toLocaleUpperCase", new ClrFunctionInstance<object, object>(Engine, ToLocaleUpperCase), false, false, false);
  42. FastAddProperty("trim", new ClrFunctionInstance<object, object>(Engine, Trim), false, false, false);
  43. }
  44. private object Trim(object arg1, object[] arg2)
  45. {
  46. throw new NotImplementedException();
  47. }
  48. private object ToLocaleUpperCase(object arg1, object[] arg2)
  49. {
  50. throw new NotImplementedException();
  51. }
  52. private object ToUpperCase(object arg1, object[] arg2)
  53. {
  54. throw new NotImplementedException();
  55. }
  56. private object ToLocaleLowerCase(object arg1, object[] arg2)
  57. {
  58. throw new NotImplementedException();
  59. }
  60. private object ToLowerCase(object arg1, object[] arg2)
  61. {
  62. throw new NotImplementedException();
  63. }
  64. private object Substring(object arg1, object[] arg2)
  65. {
  66. throw new NotImplementedException();
  67. }
  68. private object Split(object arg1, object[] arg2)
  69. {
  70. throw new NotImplementedException();
  71. }
  72. private object Slice(object arg1, object[] arg2)
  73. {
  74. throw new NotImplementedException();
  75. }
  76. private object Search(object arg1, object[] arg2)
  77. {
  78. throw new NotImplementedException();
  79. }
  80. private object Replace(object arg1, object[] arg2)
  81. {
  82. throw new NotImplementedException();
  83. }
  84. private object Match(object arg1, object[] arg2)
  85. {
  86. throw new NotImplementedException();
  87. }
  88. private object LocaleCompare(object arg1, object[] arg2)
  89. {
  90. throw new NotImplementedException();
  91. }
  92. private object LastIndexOf(object arg1, object[] arg2)
  93. {
  94. throw new NotImplementedException();
  95. }
  96. private object IndexOf(object arg1, object[] arg2)
  97. {
  98. throw new NotImplementedException();
  99. }
  100. private object Concat(object arg1, object[] arg2)
  101. {
  102. throw new NotImplementedException();
  103. }
  104. private object CharCodeAt(object arg1, object[] arg2)
  105. {
  106. throw new NotImplementedException();
  107. }
  108. private object CharAt(object arg1, object[] arg2)
  109. {
  110. throw new NotImplementedException();
  111. }
  112. private object ValueOf(object arg1, object[] arg2)
  113. {
  114. throw new NotImplementedException();
  115. }
  116. private object ToStringString(object arg1, object[] arg2)
  117. {
  118. throw new NotImplementedException();
  119. }
  120. }
  121. }