blob: efffaaec01730ffd8abb2291fab7d8e6d66d6da4 [file] [log] [blame]
ethannicholasb3058bd2016-07-01 08:22:01 -07001/*
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
ethannicholasf789b382016-08-03 12:43:36 -070011#include <iomanip>
ethannicholasb3058bd2016-07-01 08:22:01 -070012#include <string>
13#include <sstream>
14#include "stdlib.h"
15#include "assert.h"
16#include "SkTypes.h"
17
18namespace SkSL {
19
20// our own definitions of certain std:: functions, because they are not always present on Android
21
ethannicholasccb1dd82016-10-11 08:47:04 -070022std::string to_string(double value);
23
24std::string to_string(int32_t value);
25
26std::string to_string(uint32_t value);
27
28std::string to_string(int64_t value);
29
30std::string to_string(uint64_t value);
ethannicholasb3058bd2016-07-01 08:22:01 -070031
32#if _MSC_VER
33#define NORETURN __declspec(noreturn)
34#else
35#define NORETURN __attribute__((__noreturn__))
36#endif
37int stoi(std::string s);
38
39double stod(std::string s);
40
41long stol(std::string s);
42
43NORETURN 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