blob: 6f91da87318f11f4d38ed4094e0b8731519f0f10 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
#ifndef SLANG_CORE_COMMON_H
#define SLANG_CORE_COMMON_H
#include "../../slang.h"
#include <assert.h>
#include <stdint.h>
#include "slang-signal.h"
#define VARIADIC_TEMPLATE
namespace Slang
{
typedef int32_t Int32;
typedef uint32_t UInt32;
typedef int64_t Int64;
typedef uint64_t UInt64;
// Define
typedef SlangUInt UInt;
typedef SlangInt Int;
static const UInt kMaxUInt = ~UInt(0);
static const Int kMaxInt = Int(kMaxUInt >> 1);
// typedef unsigned short Word;
typedef intptr_t PtrInt;
// TODO(JS): It looks like Index is actually 64 bit on 64 bit targets(!)
// Previous discussions landed on Index being int32_t.
// Type used for indexing, in arrays/views etc. Signed.
typedef Int Index;
typedef UInt UIndex;
static const Index kMaxIndex = kMaxInt;
typedef uint8_t Byte;
// TODO(JS):
// Perhaps these should be named Utf8, Utf16 and UnicodePoint/Rune/etc? For now, just keep it simple
//
typedef char Char8;
// 16 bit character. Note much like in utf8, a character may or may not represent a code point (it can be part of a code point).
typedef uint16_t Char16;
// Can always hold a unicode code point.
typedef uint32_t Char32;
template <typename T>
inline T&& _Move(T & obj)
{
return static_cast<T&&>(obj);
}
template <typename T>
inline void Swap(T & v0, T & v1)
{
T tmp = _Move(v0);
v0 = _Move(v1);
v1 = _Move(tmp);
}
// TODO: Shouldn't these be SLANG_ prefixed?
#ifdef _MSC_VER
#define UNREACHABLE_RETURN(x)
#define UNREACHABLE(x)
#else
#define UNREACHABLE_RETURN(x) return x;
#define UNREACHABLE(x) x;
#endif
}
#ifdef _DEBUG
#define SLANG_EXPECT(VALUE, MSG) if(VALUE) {} else SLANG_ASSERT_FAILURE(MSG)
#define SLANG_ASSERT(VALUE) SLANG_EXPECT(VALUE, #VALUE)
#else
#define SLANG_EXPECT(VALUE, MSG) do {} while(0)
#define SLANG_ASSERT(VALUE) do {} while(0)
#endif
#define SLANG_RELEASE_ASSERT(VALUE) if(VALUE) {} else SLANG_ASSERT_FAILURE(#VALUE)
#define SLANG_RELEASE_EXPECT(VALUE, WHAT) if(VALUE) {} else SLANG_UNEXPECTED(WHAT)
template<typename T> void slang_use_obj(T&) {}
#define SLANG_UNREFERENCED_PARAMETER(P) slang_use_obj(P)
#define SLANG_UNREFERENCED_VARIABLE(P) slang_use_obj(P)
#endif
|