v8-external.h 924 B

12345678910111213141516171819202122232425262728293031323334353637
  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_EXTERNAL_H_
  5. #define INCLUDE_V8_EXTERNAL_H_
  6. #include "v8-value.h" // NOLINT(build/include_directory)
  7. #include "v8config.h" // NOLINT(build/include_directory)
  8. namespace v8 {
  9. class Isolate;
  10. /**
  11. * A JavaScript value that wraps a C++ void*. This type of value is mainly used
  12. * to associate C++ data structures with JavaScript objects.
  13. */
  14. class V8_EXPORT External : public Value {
  15. public:
  16. static Local<External> New(Isolate* isolate, void* value);
  17. V8_INLINE static External* Cast(Value* value) {
  18. #ifdef V8_ENABLE_CHECKS
  19. CheckCast(value);
  20. #endif
  21. return static_cast<External*>(value);
  22. }
  23. void* Value() const;
  24. private:
  25. static void CheckCast(v8::Value* obj);
  26. };
  27. } // namespace v8
  28. #endif // INCLUDE_V8_EXTERNAL_H_