version.h 1.62 KB
Newer Older
1
// Copyright 2009 the V8 project authors. All rights reserved.
2 3
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
4

5 6
#ifndef V8_UTILS_VERSION_H_
#define V8_UTILS_VERSION_H_
7

8 9
#include <cstdint>

10 11
#include "src/base/functional.h"

12 13
namespace v8 {
namespace internal {
14

15 16 17
template <typename T>
class Vector;

18
class V8_EXPORT Version {
19 20 21 22 23 24
 public:
  // Return the various version components.
  static int GetMajor() { return major_; }
  static int GetMinor() { return minor_; }
  static int GetBuild() { return build_; }
  static int GetPatch() { return patch_; }
25
  static const char* GetEmbedder() { return embedder_; }
26
  static bool IsCandidate() { return candidate_; }
27 28 29
  static uint32_t Hash() {
    return static_cast<uint32_t>(
        base::hash_combine(major_, minor_, build_, patch_));
30
  }
31 32 33 34 35 36 37

  // Calculate the V8 version string.
  static void GetString(Vector<char> str);

  // Calculate the SONAME for the V8 shared library.
  static void GetSONAME(Vector<char> str);

38 39
  static const char* GetVersion() { return version_string_; }

40
 private:
41
  // NOTE: can't make these really const because of test-version.cc.
42 43 44 45
  static int major_;
  static int minor_;
  static int build_;
  static int patch_;
46
  static const char* embedder_;
47 48
  static bool candidate_;
  static const char* soname_;
49
  static const char* version_string_;
50 51 52

  // In test-version.cc.
  friend void SetVersion(int major, int minor, int build, int patch,
53 54
                         const char* embedder, bool candidate,
                         const char* soname);
55 56
};

57 58
}  // namespace internal
}  // namespace v8
59

60
#endif  // V8_UTILS_VERSION_H_