summaryrefslogtreecommitdiffstats
path: root/source/compiler-core/slang-artifact-handler-impl.h
blob: 675dcd5f2e914785b77efe5e97e07b155d8d6b1e (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
// slang-artifact-handler-impl.h
#ifndef SLANG_ARTIFACT_HANDLER_IMPL_H
#define SLANG_ARTIFACT_HANDLER_IMPL_H

#include "../core/slang-com-object.h"
#include "slang-artifact-representation.h"
#include "slang-artifact.h"

namespace Slang
{

class DefaultArtifactHandler : public ComBaseObject, public IArtifactHandler
{
public:
    SLANG_NO_THROW uint32_t SLANG_MCALL addRef() SLANG_OVERRIDE { return 1; }
    SLANG_NO_THROW uint32_t SLANG_MCALL release() SLANG_OVERRIDE { return 1; }
    SLANG_NO_THROW SlangResult SLANG_MCALL queryInterface(SlangUUID const& uuid, void** outObject)
        SLANG_OVERRIDE;

    // ICastable
    SLANG_NO_THROW void* SLANG_MCALL castAs(const Guid& guid) SLANG_OVERRIDE;

    // IArtifactHandler
    SLANG_NO_THROW SlangResult SLANG_MCALL expandChildren(IArtifact* container) SLANG_OVERRIDE;
    SLANG_NO_THROW SlangResult SLANG_MCALL getOrCreateRepresentation(
        IArtifact* artifact,
        const Guid& guid,
        ArtifactKeep keep,
        ICastable** outCastable) SLANG_OVERRIDE;

    static IArtifactHandler* getSingleton() { return &g_singleton; }

protected:
    SlangResult _loadSharedLibrary(IArtifact* artifact, ISlangSharedLibrary** outSharedLibrary);
    SlangResult _createOSFile(
        IArtifact* artifact,
        ArtifactKeep intermediateKeep,
        IOSFileArtifactRepresentation** outFileRep);

    void* getInterface(const Guid& uuid);
    void* getObject(const Guid& uuid);

    SlangResult _addRepresentation(
        IArtifact* artifact,
        ArtifactKeep keep,
        ISlangUnknown* rep,
        ICastable** outCastable);
    SlangResult _addRepresentation(
        IArtifact* artifact,
        ArtifactKeep keep,
        ICastable* castable,
        ICastable** outCastable);

    static DefaultArtifactHandler g_singleton;
};

} // namespace Slang

#endif