Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 10:08:51

0001 // Copyright 2020 the V8 project authors. All rights reserved.
0002 // Use of this source code is governed by a BSD-style license that can be
0003 // found in the LICENSE file.
0004 
0005 #ifndef INCLUDE_CPPGC_NAME_PROVIDER_H_
0006 #define INCLUDE_CPPGC_NAME_PROVIDER_H_
0007 
0008 #include "v8config.h"  // NOLINT(build/include_directory)
0009 
0010 namespace cppgc {
0011 
0012 /**
0013  * NameProvider allows for providing a human-readable name for garbage-collected
0014  * objects.
0015  *
0016  * There's two cases of names to distinguish:
0017  * a. Explicitly specified names via using NameProvider. Such names are always
0018  *    preserved in the system.
0019  * b. Internal names that Oilpan infers from a C++ type on the class hierarchy
0020  *    of the object. This is not necessarily the type of the actually
0021  *    instantiated object.
0022  *
0023  * Depending on the build configuration, Oilpan may hide names, i.e., represent
0024  * them with kHiddenName, of case b. to avoid exposing internal details.
0025  */
0026 class V8_EXPORT NameProvider {
0027  public:
0028   /**
0029    * Name that is used when hiding internals.
0030    */
0031   static constexpr const char kHiddenName[] = "InternalNode";
0032 
0033   /**
0034    * Name that is used in case compiler support is missing for composing a name
0035    * from C++ types.
0036    */
0037   static constexpr const char kNoNameDeducible[] = "<No name>";
0038 
0039   /**
0040    * Indicating whether the build supports extracting C++ names as object names.
0041    *
0042    * @returns true if C++ names should be hidden and represented by kHiddenName.
0043    */
0044   static constexpr bool SupportsCppClassNamesAsObjectNames() {
0045 #if CPPGC_SUPPORTS_OBJECT_NAMES
0046     return true;
0047 #else   // !CPPGC_SUPPORTS_OBJECT_NAMES
0048     return false;
0049 #endif  // !CPPGC_SUPPORTS_OBJECT_NAMES
0050   }
0051 
0052   virtual ~NameProvider() = default;
0053 
0054   /**
0055    * Specifies a name for the garbage-collected object. Such names will never
0056    * be hidden, as they are explicitly specified by the user of this API.
0057    *
0058    * @returns a human readable name for the object.
0059    */
0060   virtual const char* GetHumanReadableName() const = 0;
0061 };
0062 
0063 }  // namespace cppgc
0064 
0065 #endif  // INCLUDE_CPPGC_NAME_PROVIDER_H_