| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkTypes_DEFINED | 8 #ifndef SkTypes_DEFINED |
| 9 #define SkTypes_DEFINED | 9 #define SkTypes_DEFINED |
| 10 | 10 |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 #else | 147 #else |
| 148 class SkString; | 148 class SkString; |
| 149 // the 'toString' helper functions convert Sk* objects to human-readable | 149 // the 'toString' helper functions convert Sk* objects to human-readable |
| 150 // form in developer mode | 150 // form in developer mode |
| 151 #define SK_TO_STRING_NONVIRT() void toString(SkString* str) const; | 151 #define SK_TO_STRING_NONVIRT() void toString(SkString* str) const; |
| 152 #define SK_TO_STRING_VIRT() virtual void toString(SkString* str) const; | 152 #define SK_TO_STRING_VIRT() virtual void toString(SkString* str) const; |
| 153 #define SK_TO_STRING_PUREVIRT() virtual void toString(SkString* str) const =
0; | 153 #define SK_TO_STRING_PUREVIRT() virtual void toString(SkString* str) const =
0; |
| 154 #define SK_TO_STRING_OVERRIDE() void toString(SkString* str) const override; | 154 #define SK_TO_STRING_OVERRIDE() void toString(SkString* str) const override; |
| 155 #endif | 155 #endif |
| 156 | 156 |
| 157 template <bool> | |
| 158 struct SkCompileAssert { | |
| 159 }; | |
| 160 | |
| 161 // Uses static_cast<bool>(expr) instead of bool(expr) due to | |
| 162 // https://connect.microsoft.com/VisualStudio/feedback/details/832915 | |
| 163 | |
| 164 // The extra parentheses in SkCompileAssert<(...)> are a work around for | |
| 165 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57771 | |
| 166 // which was fixed in gcc 4.8.2. | |
| 167 #define SK_COMPILE_ASSERT(expr, msg) \ | |
| 168 typedef SkCompileAssert<(static_cast<bool>(expr))> \ | |
| 169 msg[static_cast<bool>(expr) ? 1 : -1] SK_UNUSED | |
| 170 | |
| 171 /* | 157 /* |
| 172 * Usage: SK_MACRO_CONCAT(a, b) to construct the symbol ab | 158 * Usage: SK_MACRO_CONCAT(a, b) to construct the symbol ab |
| 173 * | 159 * |
| 174 * SK_MACRO_CONCAT_IMPL_PRIV just exists to make this work. Do not use directly | 160 * SK_MACRO_CONCAT_IMPL_PRIV just exists to make this work. Do not use directly |
| 175 * | 161 * |
| 176 */ | 162 */ |
| 177 #define SK_MACRO_CONCAT(X, Y) SK_MACRO_CONCAT_IMPL_PRIV(X, Y) | 163 #define SK_MACRO_CONCAT(X, Y) SK_MACRO_CONCAT_IMPL_PRIV(X, Y) |
| 178 #define SK_MACRO_CONCAT_IMPL_PRIV(X, Y) X ## Y | 164 #define SK_MACRO_CONCAT_IMPL_PRIV(X, Y) X ## Y |
| 179 | 165 |
| 180 /* | 166 /* |
| (...skipping 21 matching lines...) Expand all Loading... |
| 202 * like this: | 188 * like this: |
| 203 * class classname { | 189 * class classname { |
| 204 * <your class> | 190 * <your class> |
| 205 * }; | 191 * }; |
| 206 * #define classname(...) SK_REQUIRE_LOCAL_VAR(classname) | 192 * #define classname(...) SK_REQUIRE_LOCAL_VAR(classname) |
| 207 * | 193 * |
| 208 * This won't work with templates, and you must inline the class' constructors a
nd destructors. | 194 * This won't work with templates, and you must inline the class' constructors a
nd destructors. |
| 209 * Take a look at SkAutoFree and SkAutoMalloc in this file for examples. | 195 * Take a look at SkAutoFree and SkAutoMalloc in this file for examples. |
| 210 */ | 196 */ |
| 211 #define SK_REQUIRE_LOCAL_VAR(classname) \ | 197 #define SK_REQUIRE_LOCAL_VAR(classname) \ |
| 212 SK_COMPILE_ASSERT(false, missing_name_for_##classname) | 198 static_assert(false, "missing name for " #classname) |
| 213 | 199 |
| 214 /////////////////////////////////////////////////////////////////////// | 200 /////////////////////////////////////////////////////////////////////// |
| 215 | 201 |
| 216 /** | 202 /** |
| 217 * Fast type for signed 8 bits. Use for parameter passing and local variables, | 203 * Fast type for signed 8 bits. Use for parameter passing and local variables, |
| 218 * not for storage. | 204 * not for storage. |
| 219 */ | 205 */ |
| 220 typedef int S8CPU; | 206 typedef int S8CPU; |
| 221 | 207 |
| 222 /** | 208 /** |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 private: | 668 private: |
| 683 void* fPtr; | 669 void* fPtr; |
| 684 size_t fSize; // can be larger than the requested size (see kReuse) | 670 size_t fSize; // can be larger than the requested size (see kReuse) |
| 685 uint32_t fStorage[(kSize + 3) >> 2]; | 671 uint32_t fStorage[(kSize + 3) >> 2]; |
| 686 }; | 672 }; |
| 687 // Can't guard the constructor because it's a template class. | 673 // Can't guard the constructor because it's a template class. |
| 688 | 674 |
| 689 #endif /* C++ */ | 675 #endif /* C++ */ |
| 690 | 676 |
| 691 #endif | 677 #endif |
| OLD | NEW |