11cb0ef41Sopenharmony_ci 21cb0ef41Sopenharmony_ci// Copyright 2021 the V8 project authors. All rights reserved. 31cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 41cb0ef41Sopenharmony_ci// found in the LICENSE file. 51cb0ef41Sopenharmony_ci 61cb0ef41Sopenharmony_ci#ifndef INCLUDE_V8_PROXY_H_ 71cb0ef41Sopenharmony_ci#define INCLUDE_V8_PROXY_H_ 81cb0ef41Sopenharmony_ci 91cb0ef41Sopenharmony_ci#include "v8-context.h" // NOLINT(build/include_directory) 101cb0ef41Sopenharmony_ci#include "v8-local-handle.h" // NOLINT(build/include_directory) 111cb0ef41Sopenharmony_ci#include "v8-object.h" // NOLINT(build/include_directory) 121cb0ef41Sopenharmony_ci#include "v8config.h" // NOLINT(build/include_directory) 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_cinamespace v8 { 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciclass Context; 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_ci/** 191cb0ef41Sopenharmony_ci * An instance of the built-in Proxy constructor (ECMA-262, 6th Edition, 201cb0ef41Sopenharmony_ci * 26.2.1). 211cb0ef41Sopenharmony_ci */ 221cb0ef41Sopenharmony_ciclass V8_EXPORT Proxy : public Object { 231cb0ef41Sopenharmony_ci public: 241cb0ef41Sopenharmony_ci Local<Value> GetTarget(); 251cb0ef41Sopenharmony_ci Local<Value> GetHandler(); 261cb0ef41Sopenharmony_ci bool IsRevoked() const; 271cb0ef41Sopenharmony_ci void Revoke(); 281cb0ef41Sopenharmony_ci 291cb0ef41Sopenharmony_ci /** 301cb0ef41Sopenharmony_ci * Creates a new Proxy for the target object. 311cb0ef41Sopenharmony_ci */ 321cb0ef41Sopenharmony_ci static MaybeLocal<Proxy> New(Local<Context> context, 331cb0ef41Sopenharmony_ci Local<Object> local_target, 341cb0ef41Sopenharmony_ci Local<Object> local_handler); 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci V8_INLINE static Proxy* Cast(Value* value) { 371cb0ef41Sopenharmony_ci#ifdef V8_ENABLE_CHECKS 381cb0ef41Sopenharmony_ci CheckCast(value); 391cb0ef41Sopenharmony_ci#endif 401cb0ef41Sopenharmony_ci return static_cast<Proxy*>(value); 411cb0ef41Sopenharmony_ci } 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci private: 441cb0ef41Sopenharmony_ci Proxy(); 451cb0ef41Sopenharmony_ci static void CheckCast(Value* obj); 461cb0ef41Sopenharmony_ci}; 471cb0ef41Sopenharmony_ci 481cb0ef41Sopenharmony_ci} // namespace v8 491cb0ef41Sopenharmony_ci 501cb0ef41Sopenharmony_ci#endif // INCLUDE_V8_PROXY_H_ 51