summaryrefslogtreecommitdiff
path: root/source/compiler-core/slang-artifact-representation-impl.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-08-09 11:23:40 -0400
committerGitHub <noreply@github.com>2022-08-09 11:23:40 -0400
commit9df7fcb023bd5a22f35ecd609b7a50cc6634976c (patch)
tree69692c36e664eafa2a37b5fa13ca7142f62b1844 /source/compiler-core/slang-artifact-representation-impl.h
parentc0733be56dc24ef0eb67b26fe0c49d3419e75773 (diff)
Artifact split interface and implementation (#2349)
* #include an absolute path didn't work - because paths were taken to always be relative. * WIP with hierarchical enums. * Some small fixes and improvements around artifact desc related types. * Improvements around hierarchical enum. * Fixes to get Artifact types refactor to be able to execute tests. * Attempt to better categorize PTX. * Work around for potentially unused function warning. * Typo fix. * Simplify Artifact header. * Small improvements around Artifact kind/payload/style. * Added IDestroyable/ICastable * Add IArtifactList. * First impl of IArtifactUtil. * Use the ICastable interface for IArtifactRepresentation. * Added IArtifactRepresentation & IArtifactAssociated. * Add SLANG_OVERRIDE to avoid gcc/clang warning. * Fix calling convention issue on win32. * Fix missing SLANG_OVERRIDE. * First attempt at file abstraction around Artifact. * Added creation of lock file. * Move functionality for determining file paths to the IArtifactUtil. Add casting to ICastable. * Added some casting/finding mechanisms. * Simplify IArtifact interface, and use Items for file reps. * Fix problem with libraries on DXIL. * Split out ArtifactRepresentation. * Move ArtifactDesc functionality to ArtifactDescUtil. ArtifactInfoUtil becomes ArtifactDescUtil. * Split implementations from the interfaces for Artifact. * Use TypeTextUtil for target name outputting. * Add artifact impls.
Diffstat (limited to 'source/compiler-core/slang-artifact-representation-impl.h')
-rw-r--r--source/compiler-core/slang-artifact-representation-impl.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/source/compiler-core/slang-artifact-representation-impl.h b/source/compiler-core/slang-artifact-representation-impl.h
new file mode 100644
index 000000000..9c2066e55
--- /dev/null
+++ b/source/compiler-core/slang-artifact-representation-impl.h
@@ -0,0 +1,94 @@
+// slang-artifact-representation-impl.h
+#ifndef SLANG_ARTIFACT_REPRESENTATION_IMPL_H
+#define SLANG_ARTIFACT_REPRESENTATION_IMPL_H
+
+#include "slang-artifact-representation.h"
+
+#include "../../slang-com-helper.h"
+#include "../../slang-com-ptr.h"
+
+#include "../core/slang-com-object.h"
+
+namespace Slang
+{
+
+/* An implementation of ILockFile */
+class LockFile : public ComBaseObject, public ILockFile
+{
+public:
+ SLANG_COM_BASE_IUNKNOWN_ALL
+
+ // ICastable
+ SLANG_NO_THROW void* SLANG_MCALL castAs(const Guid& guid) SLANG_OVERRIDE;
+
+ // ILockFile
+ SLANG_NO_THROW const char* SLANG_MCALL getPath() SLANG_OVERRIDE;
+ SLANG_NO_THROW ISlangMutableFileSystem* SLANG_MCALL getFileSystem() SLANG_OVERRIDE;
+ SLANG_NO_THROW void SLANG_MCALL disown() SLANG_OVERRIDE;
+
+ /// Ctor
+ LockFile(String path, ISlangMutableFileSystem* fileSystem) :
+ m_path(path),
+ m_fileSystem(fileSystem)
+ {
+ }
+
+ ~LockFile();
+
+protected:
+ void* getInterface(const Guid& uuid);
+ void* getObject(const Guid& uuid);
+
+ ISlangMutableFileSystem* _getFileSystem();
+
+ String m_path;
+ ComPtr<ISlangMutableFileSystem> m_fileSystem;
+};
+
+/*
+A representation of an artifact that is held in a file */
+class FileArtifactRepresentation : public ComBaseObject, public IFileArtifactRepresentation
+{
+public:
+ typedef IFileArtifactRepresentation::Kind Kind;
+
+ SLANG_COM_BASE_IUNKNOWN_ALL
+
+ // ICastable
+ SLANG_NO_THROW void* SLANG_MCALL castAs(const Guid& guid) SLANG_OVERRIDE;
+
+ // IArtifactRepresentation
+ SLANG_NO_THROW SlangResult SLANG_MCALL writeToBlob(ISlangBlob** blob) SLANG_OVERRIDE;
+ SLANG_NO_THROW bool SLANG_MCALL exists() SLANG_OVERRIDE;
+
+ // IFileArtifactRepresentation
+ virtual SLANG_NO_THROW Kind SLANG_MCALL getKind() SLANG_OVERRIDE { return m_kind; }
+ virtual SLANG_NO_THROW const char* SLANG_MCALL getPath() SLANG_OVERRIDE { return m_path.getBuffer(); }
+ virtual SLANG_NO_THROW ILockFile* SLANG_MCALL getLockFile() SLANG_OVERRIDE { return m_lockFile; }
+ virtual SLANG_NO_THROW ISlangMutableFileSystem* SLANG_MCALL getFileSystem() SLANG_OVERRIDE { return m_fileSystem; }
+
+ FileArtifactRepresentation(Kind kind, String path, ILockFile* lockFile, ISlangMutableFileSystem* fileSystem):
+ m_kind(kind),
+ m_path(path),
+ m_lockFile(lockFile),
+ m_fileSystem(fileSystem)
+ {
+ }
+
+ ~FileArtifactRepresentation();
+
+protected:
+ void* getInterface(const Guid& uuid);
+ void* getObject(const Guid& uuid);
+
+ ISlangMutableFileSystem* _getFileSystem();
+
+ Kind m_kind;
+ String m_path;
+ ComPtr<ILockFile> m_lockFile;
+ ComPtr<ISlangMutableFileSystem> m_fileSystem;
+};
+
+} // namespace Slang
+
+#endif