| 48 | }; |
| 49 | |
| 50 | class StringName |
| 51 | { |
| 52 | enum |
| 53 | { |
| 54 | STRING_TABLE_BITS = 16, |
| 55 | STRING_TABLE_LEN = 1 << STRING_TABLE_BITS, |
| 56 | STRING_TABLE_MASK = STRING_TABLE_LEN - 1 |
| 57 | }; |
| 58 | |
| 59 | struct _Data { |
| 60 | SafeRefCount refcount; |
| 61 | SafeNumeric<uint32_t> static_count; |
| 62 | const char* cname = nullptr; |
| 63 | String name; |
| 64 | #ifdef DEBUG_ENABLED |
| 65 | uint32_t debug_references = 0; |
| 66 | #endif |
| 67 | String get_name() const |
| 68 | { |
| 69 | return cname ? String(cname) : name; |
| 70 | } |
| 71 | int idx = 0; |
| 72 | uint32_t hash = 0; |
| 73 | _Data* prev = nullptr; |
| 74 | _Data* next = nullptr; |
| 75 | _Data() {} |
| 76 | }; |
| 77 | |
| 78 | static _Data* _table[STRING_TABLE_LEN]; |
| 79 | |
| 80 | _Data* _data = nullptr; |
| 81 | |
| 82 | union _HashUnion |
| 83 | { |
| 84 | _Data* ptr = nullptr; |
| 85 | uint32_t hash; |
| 86 | }; |
| 87 | |
| 88 | void unref(); |
| 89 | friend void register_core_types(); |
| 90 | friend void unregister_core_types(); |
| 91 | friend class Main; |
| 92 | static Mutex mutex; |
| 93 | static void setup(); |
| 94 | static void cleanup(); |
| 95 | static bool configured; |
| 96 | #ifdef DEBUG_ENABLED |
| 97 | struct DebugSortReferences { |
| 98 | bool operator()(const _Data* p_left, const _Data* p_right) const |
| 99 | { |
| 100 | return p_left->debug_references > p_right->debug_references; |
| 101 | } |
| 102 | }; |
| 103 | |
| 104 | static bool debug_stringname; |
| 105 | #endif |
| 106 | |
| 107 | StringName(_Data* p_data) |
no test coverage detected