OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2016 Google Inc. | |
3 * | |
4 * Use of this source code is governed by a BSD-style license that can be | |
5 * found in the LICENSE file. | |
6 */ | |
7 | |
8 #ifndef SKSL_UTIL | |
9 #define SKSL_UTIL | |
10 | |
11 #include <string> | |
12 #include <sstream> | |
13 #include "stdlib.h" | |
14 #include "SkTypes.h" | |
15 | |
16 namespace SkSL { | |
17 | |
18 // our own definitions of certain std:: functions, because they are not always p resent on Android | |
19 | |
20 template <typename T> std::string to_string(T value) { | |
21 #ifdef SK_BUILD_FOR_ANDROID | |
22 std::stringstream buffer; | |
23 buffer << value; | |
24 return buffer.str(); | |
25 #else | |
26 return std::to_string(value); | |
27 #endif | |
28 } | |
29 | |
30 #if _MSC_VER | |
31 #define NORETURN __declspec(noreturn) | |
32 #else | |
33 #define NORETURN __attribute__((__noreturn__)) | |
34 #endif | |
35 int stoi(std::string s); | |
36 | |
37 double stod(std::string s); | |
38 | |
39 long stol(std::string s); | |
40 | |
41 NORETURN void sksl_abort(); | |
42 | |
43 } // namespace | |
44 | |
45 #ifdef DEBUG | |
46 #define ASSERT(x) assert(x) | |
47 #define ASSERT_RESULT(x) { bool result = x; ASSERT(x); } | |
dogben
2016/06/20 18:26:26
How is this different from ASSERT? Why does it eva
ethannicholas
2016/06/20 20:17:10
Because I'm a moron, that's why.
dogben
2016/06/21 17:53:45
For non-DEBUG, I see how these are different. I'm
| |
48 #else | |
49 #define ASSERT(x) | |
50 #define ASSERT_RESULT(x) x | |
51 #endif | |
52 | |
53 #ifdef SKIA | |
54 #define ABORT(...) { SkDebugf(__VA_ARGS__); sksl_abort(); } | |
55 #else | |
56 #define ABORT(...) { sksl_abort(); } | |
57 #endif | |
58 | |
59 #endif | |
OLD | NEW |