| 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 25 matching lines...) Expand all Loading... |
| 36 namespace WTF { | 36 namespace WTF { |
| 37 | 37 |
| 38 #if ENABLE(INSTANCE_COUNTER) || ENABLE(GC_PROFILING) | 38 #if ENABLE(INSTANCE_COUNTER) || ENABLE(GC_PROFILING) |
| 39 | 39 |
| 40 #if COMPILER(CLANG) | 40 #if COMPILER(CLANG) |
| 41 const size_t extractNameFunctionPrefixLength = sizeof("const char *WTF::extractN
ameFunction() [T = ") - 1; | 41 const size_t extractNameFunctionPrefixLength = sizeof("const char *WTF::extractN
ameFunction() [T = ") - 1; |
| 42 const size_t extractNameFunctionPostfixLength = sizeof("]") - 1; | 42 const size_t extractNameFunctionPostfixLength = sizeof("]") - 1; |
| 43 #elif COMPILER(GCC) | 43 #elif COMPILER(GCC) |
| 44 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; |
| 45 const size_t extractNameFunctionPostfixLength = sizeof("]") - 1; | 45 const size_t extractNameFunctionPostfixLength = sizeof("]") - 1; |
| 46 #elif COMPILER(MSVC) | |
| 47 const size_t extractNameFunctionPrefixLength = sizeof("const char *__cdecl WTF::
extractNameFunction<class ") - 1; | |
| 48 const size_t extractNameFunctionPostfixLength = sizeof(">(void)") - 1; | |
| 49 #else | 46 #else |
| 50 #warning "Extracting typename is supported only in compiler GCC, CLANG and MSVC
at this moment" | 47 #warning "Extracting typename is supported only in compiler GCC, CLANG and MSVC
at this moment" |
| 51 #endif | 48 #endif |
| 52 | 49 |
| 53 // 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. |
| 54 // 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|. |
| 55 String extractTypeNameFromFunctionName(const char* funcName) | 52 String extractTypeNameFromFunctionName(const char* funcName) |
| 56 { | 53 { |
| 57 #if COMPILER(CLANG) || COMPILER(GCC) || COMPILER(MSVC) | 54 #if COMPILER(CLANG) || COMPILER(GCC) |
| 58 size_t funcNameLength = strlen(funcName); | 55 size_t funcNameLength = strlen(funcName); |
| 59 ASSERT(funcNameLength > extractNameFunctionPrefixLength + extractNameFunctio
nPostfixLength); | 56 ASSERT(funcNameLength > extractNameFunctionPrefixLength + extractNameFunctio
nPostfixLength); |
| 60 | 57 |
| 61 const char* funcNameWithoutPrefix = funcName + extractNameFunctionPrefixLeng
th; | 58 const char* funcNameWithoutPrefix = funcName + extractNameFunctionPrefixLeng
th; |
| 62 return String(funcNameWithoutPrefix, funcNameLength - extractNameFunctionPre
fixLength - extractNameFunctionPostfixLength); | 59 return String(funcNameWithoutPrefix, funcNameLength - extractNameFunctionPre
fixLength - extractNameFunctionPostfixLength); |
| 63 #else | 60 #else |
| 64 return String("unknown"); | 61 return String("unknown"); |
| 65 #endif | 62 #endif |
| 66 } | 63 } |
| 67 | 64 |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 #else | 142 #else |
| 146 | 143 |
| 147 String dumpRefCountedInstanceCounts() | 144 String dumpRefCountedInstanceCounts() |
| 148 { | 145 { |
| 149 return String("{}"); | 146 return String("{}"); |
| 150 } | 147 } |
| 151 | 148 |
| 152 #endif // ENABLE(INSTANCE_COUNTER) || ENABLE(GC_PROFILING) | 149 #endif // ENABLE(INSTANCE_COUNTER) || ENABLE(GC_PROFILING) |
| 153 | 150 |
| 154 } // namespace WTF | 151 } // namespace WTF |
| OLD | NEW |