ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 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 | |
ethannicholas | f789b38 | 2016-08-03 12:43:36 -0700 | [diff] [blame] | 11 | #include <iomanip> |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 12 | #include <string> |
| 13 | #include <sstream> |
| 14 | #include "stdlib.h" |
| 15 | #include "assert.h" |
| 16 | #include "SkTypes.h" |
| 17 | |
| 18 | namespace SkSL { |
| 19 | |
| 20 | // our own definitions of certain std:: functions, because they are not always present on Android |
| 21 | |
ethannicholas | dcfe6db | 2016-10-10 10:09:00 -0700 | [diff] [blame^] | 22 | std::string to_string(double value); |
| 23 | |
| 24 | std::string to_string(int32_t value); |
| 25 | |
| 26 | std::string to_string(uint32_t value); |
| 27 | |
| 28 | std::string to_string(int64_t value); |
| 29 | |
| 30 | std::string to_string(uint64_t value); |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 31 | |
| 32 | #if _MSC_VER |
| 33 | #define NORETURN __declspec(noreturn) |
| 34 | #else |
| 35 | #define NORETURN __attribute__((__noreturn__)) |
| 36 | #endif |
| 37 | int stoi(std::string s); |
| 38 | |
| 39 | double stod(std::string s); |
| 40 | |
| 41 | long stol(std::string s); |
| 42 | |
| 43 | NORETURN void sksl_abort(); |
| 44 | |
| 45 | } // namespace |
| 46 | |
| 47 | #ifdef DEBUG |
| 48 | #define ASSERT(x) assert(x) |
| 49 | #define ASSERT_RESULT(x) ASSERT(x); |
| 50 | #else |
| 51 | #define ASSERT(x) |
| 52 | #define ASSERT_RESULT(x) x |
| 53 | #endif |
| 54 | |
| 55 | #ifdef SKIA |
| 56 | #define ABORT(...) { SkDebugf(__VA_ARGS__); sksl_abort(); } |
| 57 | #else |
| 58 | #define ABORT(...) { sksl_abort(); } |
| 59 | #endif |
| 60 | |
| 61 | #endif |