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 
5 #ifndef INCLUDE_V8_DATA_H_
6 #define INCLUDE_V8_DATA_H_
7 
8 #include "v8-local-handle.h"  // NOLINT(build/include_directory)
9 #include "v8config.h"         // NOLINT(build/include_directory)
10 
11 namespace v8 {
12 
13 class Context;
14 
15 /**
16  * The superclass of objects that can reside on V8's heap.
17  */
18 class V8_EXPORT Data {
19  public:
20   /**
21    * Returns true if this data is a |v8::Value|.
22    */
23   bool IsValue() const;
24 
25   /**
26    * Returns true if this data is a |v8::Module|.
27    */
28   bool IsModule() const;
29 
30   /**
31    * Returns true if this data is a |v8::Private|.
32    */
33   bool IsPrivate() const;
34 
35   /**
36    * Returns true if this data is a |v8::ObjectTemplate|.
37    */
38   bool IsObjectTemplate() const;
39 
40   /**
41    * Returns true if this data is a |v8::FunctionTemplate|.
42    */
43   bool IsFunctionTemplate() const;
44 
45   /**
46    * Returns true if this data is a |v8::Context|.
47    */
48   bool IsContext() const;
49 
50  private:
51   Data();
52 };
53 
54 /**
55  * A fixed-sized array with elements of type Data.
56  */
57 class V8_EXPORT FixedArray : public Data {
58  public:
59   int Length() const;
60   Local<Data> Get(Local<Context> context, int i) const;
61 };
62 
63 }  // namespace v8
64 
65 #endif  // INCLUDE_V8_DATA_H_
66