GetterFunctionInstance.cs 744 B

12345678910111213141516171819202122232425
  1. using Jint.Native;
  2. using Jint.Native.Function;
  3. namespace Jint.Runtime.Interop
  4. {
  5. /// <summary>
  6. /// Represents a FunctionInstance wrapping a Clr getter.
  7. /// </summary>
  8. public sealed class GetterFunctionInstance: FunctionInstance
  9. {
  10. private static readonly JsString _name = new JsString("get");
  11. private readonly Func<JsValue, JsValue> _getter;
  12. public GetterFunctionInstance(Engine engine, Func<JsValue, JsValue> getter)
  13. : base(engine, engine.Realm, _name, FunctionThisMode.Global)
  14. {
  15. _getter = getter;
  16. }
  17. protected internal override JsValue Call(JsValue thisObject, JsValue[] arguments)
  18. {
  19. return _getter(thisObject);
  20. }
  21. }
  22. }