1 // Copyright 2009 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 V8_UTILS_VERSION_H_
6 #define V8_UTILS_VERSION_H_
7 
8 #include <cstdint>
9 
10 #include "src/base/functional.h"
11 
12 namespace v8 {
13 namespace internal {
14 
15 template <typename T>
16 class Vector;
17 
18 class V8_EXPORT Version {
19  public:
20   // Return the various version components.
GetMajor()21   static int GetMajor() { return major_; }
GetMinor()22   static int GetMinor() { return minor_; }
GetBuild()23   static int GetBuild() { return build_; }
GetPatch()24   static int GetPatch() { return patch_; }
GetEmbedder()25   static const char* GetEmbedder() { return embedder_; }
IsCandidate()26   static bool IsCandidate() { return candidate_; }
Hash()27   static uint32_t Hash() {
28     return static_cast<uint32_t>(
29         base::hash_combine(major_, minor_, build_, patch_));
30   }
31 
32   // Calculate the V8 version string.
33   static void GetString(Vector<char> str);
34 
35   // Calculate the SONAME for the V8 shared library.
36   static void GetSONAME(Vector<char> str);
37 
GetVersion()38   static const char* GetVersion() { return version_string_; }
39 
40  private:
41   // NOTE: can't make these really const because of test-version.cc.
42   static int major_;
43   static int minor_;
44   static int build_;
45   static int patch_;
46   static const char* embedder_;
47   static bool candidate_;
48   static const char* soname_;
49   static const char* version_string_;
50 
51   // In test-version.cc.
52   friend void SetVersion(int major, int minor, int build, int patch,
53                          const char* embedder, bool candidate,
54                          const char* soname);
55 };
56 
57 }  // namespace internal
58 }  // namespace v8
59 
60 #endif  // V8_UTILS_VERSION_H_
61