OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "wtf/StdLibExtras.h" | 30 #include "wtf/StdLibExtras.h" |
31 #include "wtf/ThreadingPrimitives.h" | 31 #include "wtf/ThreadingPrimitives.h" |
32 #include "wtf/text/StringBuilder.h" | 32 #include "wtf/text/StringBuilder.h" |
33 #include "wtf/text/StringHash.h" | 33 #include "wtf/text/StringHash.h" |
34 #include "wtf/text/WTFString.h" | 34 #include "wtf/text/WTFString.h" |
35 | 35 |
36 namespace WTF { | 36 namespace WTF { |
37 | 37 |
38 #if ENABLE(INSTANCE_COUNTER) || ENABLE(GC_TRACING) | 38 #if ENABLE(INSTANCE_COUNTER) || ENABLE(GC_TRACING) |
39 | 39 |
40 #if COMPILER(GCC) | 40 #if COMPILER(CLANG) |
| 41 const size_t extractNameFunctionPrefixLength = sizeof("const char *WTF::extractN
ameFunction() [T = ") - 1; |
| 42 const size_t extractNameFunctionPostfixLength = 1; |
| 43 #elif COMPILER(GCC) |
41 const size_t extractNameFunctionPrefixLength = sizeof("const char* WTF::extractN
ameFunction() [with T = ") - 1; | 44 const size_t extractNameFunctionPrefixLength = sizeof("const char* WTF::extractN
ameFunction() [with T = ") - 1; |
42 const size_t extractNameFunctionPostfixLength = 1; | 45 const size_t extractNameFunctionPostfixLength = 1; |
43 #else | 46 #else |
44 #warning "Extracting typename in a compiler other than GCC isn't supported atm" | 47 #warning "Extracting typename in a compiler other than GCC isn't supported atm" |
45 #endif | 48 #endif |
46 | 49 |
47 // This function is used to stringify a typename T without using RTTI. | 50 // This function is used to stringify a typename T without using RTTI. |
48 // The result of extractNameFunction<T>() is given as |funcName|. |extractTypeNa
meFromFunctionName| then extracts a typename string from |funcName|. | 51 // The result of extractNameFunction<T>() is given as |funcName|. |extractTypeNa
meFromFunctionName| then extracts a typename string from |funcName|. |
49 String extractTypeNameFromFunctionName(const char* funcName) | 52 String extractTypeNameFromFunctionName(const char* funcName) |
50 { | 53 { |
51 #if COMPILER(GCC) | 54 #if COMPILER(CLANG) || COMPILER(GCC) |
52 size_t funcNameLength = strlen(funcName); | 55 size_t funcNameLength = strlen(funcName); |
53 ASSERT(funcNameLength > extractNameFunctionPrefixLength + 1); | 56 ASSERT(funcNameLength > extractNameFunctionPrefixLength + 1); |
54 | 57 |
55 const char* funcNameWithoutPrefix = funcName + extractNameFunctionPrefixLeng
th; | 58 const char* funcNameWithoutPrefix = funcName + extractNameFunctionPrefixLeng
th; |
56 return String(funcNameWithoutPrefix, funcNameLength - extractNameFunctionPre
fixLength - extractNameFunctionPostfixLength /* last ] */); | 59 return String(funcNameWithoutPrefix, funcNameLength - extractNameFunctionPre
fixLength - extractNameFunctionPostfixLength /* last ] */); |
57 #else | 60 #else |
58 return String(); | 61 return String(); |
59 #endif | 62 #endif |
60 } | 63 } |
61 | 64 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 #else | 142 #else |
140 | 143 |
141 String dumpRefCountedInstanceCounts() | 144 String dumpRefCountedInstanceCounts() |
142 { | 145 { |
143 return String("{}"); | 146 return String("{}"); |
144 } | 147 } |
145 | 148 |
146 #endif // ENABLE(INSTANCE_COUNTER) || ENABLE(GC_TRACING) | 149 #endif // ENABLE(INSTANCE_COUNTER) || ENABLE(GC_TRACING) |
147 | 150 |
148 } // namespace WTF | 151 } // namespace WTF |
OLD | NEW |