v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
name-trait.cc
Go to the documentation of this file.
1// Copyright 2020 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
6
7#include <stdio.h>
8
9#include "src/base/logging.h"
10#include "src/base/macros.h"
11
12namespace cppgc {
13
14// static
15constexpr const char NameProvider::kHiddenName[];
16
17// static
18constexpr const char NameProvider::kNoNameDeducible[];
19
20namespace internal {
21
22// static
24 // Parsing string of structure:
25 // static HeapObjectName NameTrait<int>::GetNameFor(...) [T = int]
26 if (!signature) return {NameProvider::kNoNameDeducible, false};
27
28 const std::string raw(signature);
29 const auto start_pos = raw.rfind("T = ") + 4;
30 DCHECK_NE(std::string::npos, start_pos);
31 const auto len = raw.length() - start_pos - 1;
32 const std::string name = raw.substr(start_pos, len).c_str();
33 char* name_buffer = new char[name.length() + 1];
34 int written = snprintf(name_buffer, name.length() + 1, "%s", name.c_str());
35 DCHECK_EQ(static_cast<size_t>(written), name.length());
36 USE(written);
37 return {name_buffer, false};
38}
39
40} // namespace internal
41} // namespace cppgc
static constexpr const char kHiddenName[]
static constexpr const char kNoNameDeducible[]
static HeapObjectName GetNameFromTypeSignature(const char *)
Definition name-trait.cc:23
#define DCHECK_NE(v1, v2)
Definition logging.h:486
#define DCHECK_EQ(v1, v2)
Definition logging.h:485
#define USE(...)
Definition macros.h:293