blob: 9be2d876af2c6c4b0dd75185a950882f98330481 (
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
#ifndef PARAMETER_ENCODER_H
#define PARAMETER_ENCODER_H
#include "../util/record-format.h"
#include "output-stream.h"
#include <cinttypes>
#include <cstdint>
#include <cstdio>
namespace SlangRecord
{
class ParameterRecorder
{
public:
ParameterRecorder(OutputStream* stream)
: m_stream(stream){};
void recordInt8(int8_t value) { recordValue(value); }
void recordUint8(uint8_t value) { recordValue(value); }
void recordInt16(int16_t value) { recordValue(value); }
void recordUint16(uint16_t value) { recordValue(value); }
void recordInt32(int32_t value) { recordValue(value); }
void recordUint32(uint32_t value) { recordValue(value); }
void recordInt64(int64_t value) { recordValue(value); }
void recordUint64(uint64_t value) { recordValue(value); }
void recordFloat(float value) { recordValue(value); }
void recordDouble(double value) { recordValue(value); }
void recordBool(bool value) { recordValue(value); }
template<typename T>
void recordEnumValue(T value)
{
recordValue(static_cast<uint32_t>(value));
}
void recordString(const char* value);
void recordPointer(const void* value, bool omitData = false, size_t size = 0);
void recordPointer(ISlangBlob* blob);
void recordAddress(const void* value)
{
recordValue(reinterpret_cast<SlangRecord::AddressFormat>(value));
}
void recordGuid(const SlangUUID& guid)
{
recordValue(guid.data1);
recordValue(guid.data2);
recordValue(guid.data3);
for (int i = 0; i < 8; i++)
{
recordValue(guid.data4[i]);
}
}
void recordStruct(SlangGlobalSessionDesc const& desc);
void recordStruct(slang::SessionDesc const& desc);
void recordStruct(slang::PreprocessorMacroDesc const& desc);
void recordStruct(slang::CompilerOptionEntry const& entry);
void recordStruct(slang::CompilerOptionValue const& value);
void recordStruct(slang::TargetDesc const& targetDesc);
void recordStruct(slang::SpecializationArg const& specializationArg);
template<typename T>
void recordValueArray(const T* array, size_t count)
{
recordUint32((uint32_t)count);
for (size_t i = 0; i < count; ++i)
{
recordValue(array[i]);
}
}
void recordStringArray(const char* const* array, size_t count)
{
recordUint32((uint32_t)count);
for (size_t i = 0; i < count; ++i)
{
recordString(array[i]);
}
}
template<typename T>
void recordStructArray(T const* array, size_t count)
{
recordUint32((uint32_t)count);
for (size_t i = 0; i < count; ++i)
{
recordStruct(array[i]);
}
}
template<typename T>
void recordAddressArray(T* const* array, size_t count)
{
recordUint32((uint32_t)count);
for (size_t i = 0; i < count; ++i)
{
recordAddress(array[i]);
}
}
private:
template<typename T>
void recordValue(T value)
{
m_stream->write(&value, sizeof(T));
}
OutputStream* m_stream;
};
} // namespace SlangRecord
#endif // PARAMETER_ENCODER_H
|