diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2023-04-18 12:36:06 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-18 12:36:06 -0400 |
| commit | 181fd1f3c9c4b047c1947096e7b3f8e5bc2314c3 (patch) | |
| tree | 308cbadae2f68d43ca20f92755b08db08e8b2283 /source/core/slang-castable.cpp | |
| parent | 90a9f43573ec0777c2ae4fa20c8fdc51a4ae7b3a (diff) | |
On demand SourceMap JSON serialization (#2811)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Moved JSON source map writing logic to JSONSourceMapUtil.
* Use ArtifactHandler to read/write SourceMaps.
Use ObjectCastableAdapter to hold SourceMap
Only serialize SourceMap <-> JSON on demand.
Diffstat (limited to 'source/core/slang-castable.cpp')
| -rw-r--r-- | source/core/slang-castable.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/source/core/slang-castable.cpp b/source/core/slang-castable.cpp index f3c6541dd..6b7644bf2 100644 --- a/source/core/slang-castable.cpp +++ b/source/core/slang-castable.cpp @@ -20,6 +20,37 @@ namespace Slang { return castable; } +/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ObjectCastableAdapter !!!!!!!!!!!!!!!!!!!!!!!!!!! */ + +void* ObjectCastableAdapter::castAs(const Guid& guid) +{ + if (auto intf = getInterface(guid)) + { + return intf; + } + return getObject(guid); +} + +void* ObjectCastableAdapter::getInterface(const Guid& guid) +{ + if (guid == ISlangUnknown::getTypeGuid() || + guid == ICastable::getTypeGuid() || + guid == IObjectCastableAdapter::getTypeGuid()) + { + return static_cast<IObjectCastableAdapter*>(this); + } + return nullptr; +} + +void* ObjectCastableAdapter::getObject(const Guid& guid) +{ + if (guid == m_containedGuid) + { + return m_contained; + } + return nullptr; +} + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! UnknownCastableAdapter !!!!!!!!!!!!!!!!!!!!!!!!!!! */ void* UnknownCastableAdapter::castAs(const Guid& guid) |
