v8-proxy.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2021 the V8 project authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef INCLUDE_V8_PROXY_H_
  5. #define INCLUDE_V8_PROXY_H_
  6. #include "v8-context.h" // NOLINT(build/include_directory)
  7. #include "v8-local-handle.h" // NOLINT(build/include_directory)
  8. #include "v8-object.h" // NOLINT(build/include_directory)
  9. #include "v8config.h" // NOLINT(build/include_directory)
  10. namespace v8 {
  11. class Context;
  12. /**
  13. * An instance of the built-in Proxy constructor (ECMA-262, 6th Edition,
  14. * 26.2.1).
  15. */
  16. class V8_EXPORT Proxy : public Object {
  17. public:
  18. Local<Value> GetTarget();
  19. Local<Value> GetHandler();
  20. bool IsRevoked() const;
  21. void Revoke();
  22. /**
  23. * Creates a new Proxy for the target object.
  24. */
  25. static MaybeLocal<Proxy> New(Local<Context> context,
  26. Local<Object> local_target,
  27. Local<Object> local_handler);
  28. V8_INLINE static Proxy* Cast(Value* value) {
  29. #ifdef V8_ENABLE_CHECKS
  30. CheckCast(value);
  31. #endif
  32. return static_cast<Proxy*>(value);
  33. }
  34. private:
  35. Proxy();
  36. static void CheckCast(Value* obj);
  37. };
  38. } // namespace v8
  39. #endif // INCLUDE_V8_PROXY_H_