11cb0ef41Sopenharmony_ci// Copyright 2021 the V8 project authors. All rights reserved.
21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be
31cb0ef41Sopenharmony_ci// found in the LICENSE file.
41cb0ef41Sopenharmony_ci
51cb0ef41Sopenharmony_ci#ifndef INCLUDE_V8_EXTERNAL_H_
61cb0ef41Sopenharmony_ci#define INCLUDE_V8_EXTERNAL_H_
71cb0ef41Sopenharmony_ci
81cb0ef41Sopenharmony_ci#include "v8-value.h"  // NOLINT(build/include_directory)
91cb0ef41Sopenharmony_ci#include "v8config.h"  // NOLINT(build/include_directory)
101cb0ef41Sopenharmony_ci
111cb0ef41Sopenharmony_cinamespace v8 {
121cb0ef41Sopenharmony_ci
131cb0ef41Sopenharmony_ciclass Isolate;
141cb0ef41Sopenharmony_ci
151cb0ef41Sopenharmony_ci/**
161cb0ef41Sopenharmony_ci * A JavaScript value that wraps a C++ void*. This type of value is mainly used
171cb0ef41Sopenharmony_ci * to associate C++ data structures with JavaScript objects.
181cb0ef41Sopenharmony_ci */
191cb0ef41Sopenharmony_ciclass V8_EXPORT External : public Value {
201cb0ef41Sopenharmony_ci public:
211cb0ef41Sopenharmony_ci  static Local<External> New(Isolate* isolate, void* value);
221cb0ef41Sopenharmony_ci  V8_INLINE static External* Cast(Value* value) {
231cb0ef41Sopenharmony_ci#ifdef V8_ENABLE_CHECKS
241cb0ef41Sopenharmony_ci    CheckCast(value);
251cb0ef41Sopenharmony_ci#endif
261cb0ef41Sopenharmony_ci    return static_cast<External*>(value);
271cb0ef41Sopenharmony_ci  }
281cb0ef41Sopenharmony_ci
291cb0ef41Sopenharmony_ci  void* Value() const;
301cb0ef41Sopenharmony_ci
311cb0ef41Sopenharmony_ci private:
321cb0ef41Sopenharmony_ci  static void CheckCast(v8::Value* obj);
331cb0ef41Sopenharmony_ci};
341cb0ef41Sopenharmony_ci
351cb0ef41Sopenharmony_ci}  // namespace v8
361cb0ef41Sopenharmony_ci
371cb0ef41Sopenharmony_ci#endif  // INCLUDE_V8_EXTERNAL_H_
38