2
0

TypedArrayPrototype.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. using Jint.Collections;
  2. using Jint.Runtime.Descriptors;
  3. namespace Jint.Native.TypedArray
  4. {
  5. /// <summary>
  6. /// https://tc39.es/ecma262/#sec-properties-of-typedarray-prototype-objects
  7. /// </summary>
  8. internal sealed class TypedArrayPrototype : Prototype
  9. {
  10. private readonly TypedArrayConstructor _constructor;
  11. private readonly TypedArrayElementType _arrayElementType;
  12. internal TypedArrayPrototype(
  13. Engine engine,
  14. IntrinsicTypedArrayPrototype objectPrototype,
  15. TypedArrayConstructor constructor,
  16. TypedArrayElementType type) : base(engine, engine.Realm)
  17. {
  18. _prototype = objectPrototype;
  19. _constructor = constructor;
  20. _arrayElementType = type;
  21. }
  22. protected override void Initialize()
  23. {
  24. var properties = new PropertyDictionary(2, false)
  25. {
  26. ["BYTES_PER_ELEMENT"] = new(JsNumber.Create(_arrayElementType.GetElementSize()), PropertyFlag.AllForbidden),
  27. ["constructor"] = new(_constructor, PropertyFlag.NonEnumerable)
  28. };
  29. SetProperties(properties);
  30. }
  31. }
  32. }