blob: 17ede975ed903e59927147aa757ac486af2cd2f3 (
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
|
// slang-artifact-associated-impl.cpp
#include "slang-artifact-associated-impl.h"
#include "../core/slang-file-system.h"
#include "../core/slang-type-text-util.h"
#include "../core/slang-io.h"
#include "../core/slang-array-view.h"
#include "slang-artifact-util.h"
namespace Slang {
/* !!!!!!!!!!!!!!!!!!!!!!!!!!! ArtifactDiagnostics !!!!!!!!!!!!!!!!!!!!!!!!!!! */
void* ArtifactDiagnostics::getInterface(const Guid& guid)
{
if (guid == ISlangUnknown::getTypeGuid() ||
guid == ICastable::getTypeGuid() ||
guid == IDiagnostics::getTypeGuid())
{
return static_cast<IDiagnostics*>(this);
}
return nullptr;
}
void* ArtifactDiagnostics::getObject(const Guid& guid)
{
SLANG_UNUSED(guid);
return nullptr;
}
void* ArtifactDiagnostics::castAs(const Guid& guid)
{
if (auto intf = getInterface(guid))
{
return intf;
}
return getObject(guid);
}
ZeroTerminatedCharSlice ArtifactDiagnostics::_allocateSlice(const Slice<char>& in)
{
if (in.count == 0)
{
return ZeroTerminatedCharSlice("", 0);
}
const char* dst = m_arena.allocateString(in.data, in.count);
return ZeroTerminatedCharSlice(dst, in.count);
}
void ArtifactDiagnostics::add(const Diagnostic& inDiagnostic)
{
Diagnostic diagnostic(inDiagnostic);
diagnostic.text = _allocateSlice(inDiagnostic.text);
diagnostic.code = _allocateSlice(inDiagnostic.code);
diagnostic.filePath = _allocateSlice(inDiagnostic.filePath);
m_diagnostics.add(diagnostic);
}
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! PostEmitMetadata !!!!!!!!!!!!!!!!!!!!!!!!!!! */
void* PostEmitMetadata::getInterface(const Guid& guid)
{
if (guid == ISlangUnknown::getTypeGuid() ||
guid == ICastable::getTypeGuid() ||
guid == IPostEmitMetadata::getTypeGuid())
{
return static_cast<IPostEmitMetadata*>(this);
}
return nullptr;
}
void* PostEmitMetadata::getObject(const Guid& uuid)
{
if (uuid == getTypeGuid())
{
return this;
}
return nullptr;
}
void* PostEmitMetadata::castAs(const Guid& guid)
{
if (auto ptr = getInterface(guid))
{
return ptr;
}
return getObject(guid);
}
Slice<ShaderBindingRange> PostEmitMetadata::getBindingRanges()
{
return Slice<ShaderBindingRange>(m_usedBindings.getBuffer(), m_usedBindings.getCount());
}
} // namespace Slang
|