summaryrefslogtreecommitdiffstats
path: root/source/core
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2022-08-10 01:58:41 -0700
committerGitHub <noreply@github.com>2022-08-10 01:58:41 -0700
commit89083c4b50af8e48e70b25b63cc62aca21ab706c (patch)
tree38e9544cd218dbeea0a2f26f267ac16f275c0291 /source/core
parent9df7fcb023bd5a22f35ecd609b7a50cc6634976c (diff)
Language server pointer type support + add `DLLImport` test (#2350)
* Language server pointer type support. + Natvis for AST. * Add completion suggestion for GUID. * Make executable test able to use slang-rt. * Fix gcc argument for rpath. * Fix DLLImport on linux. * Fix windows. * Fix. Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/core')
-rw-r--r--source/core/slang-platform.cpp19
-rw-r--r--source/core/slang-shared-library.cpp2
2 files changed, 14 insertions, 7 deletions
diff --git a/source/core/slang-platform.cpp b/source/core/slang-platform.cpp
index 5185d5d23..921c85612 100644
--- a/source/core/slang-platform.cpp
+++ b/source/core/slang-platform.cpp
@@ -43,7 +43,7 @@ namespace Slang
Path::combineIntoBuilder(parent.getUnownedSlice(), platformFileNameBuilder.getUnownedSlice(), outPath);
}
- else
+ else if (filename.getLength() > 0)
{
appendPlatformFileName(filename.getUnownedSlice(), outPath);
}
@@ -107,6 +107,13 @@ SLANG_COMPILE_TIME_ASSERT(E_OUTOFMEMORY == SLANG_E_OUT_OF_MEMORY);
/* static */SlangResult SharedLibrary::loadWithPlatformPath(char const* platformFileName, SharedLibrary::Handle& handleOut)
{
handleOut = nullptr;
+ if (!platformFileName || strlen(platformFileName) == 0)
+ {
+ if (!GetModuleHandleExA(0, nullptr, (HMODULE*)&handleOut))
+ return SLANG_FAIL;
+ return SLANG_OK;
+ }
+
// https://docs.microsoft.com/en-us/windows/desktop/api/libloaderapi/nf-libloaderapi-loadlibrarya
const HMODULE h = LoadLibraryA(platformFileName);
if (!h)
@@ -170,10 +177,11 @@ SLANG_COMPILE_TIME_ASSERT(E_OUTOFMEMORY == SLANG_E_OUT_OF_MEMORY);
/* static */SlangResult SharedLibrary::loadWithPlatformPath(char const* platformFileName, Handle& handleOut)
{
handleOut = nullptr;
-
- void* h = dlopen(platformFileName, RTLD_NOW | RTLD_GLOBAL);
- if(!h)
- {
+ if (strlen(platformFileName) == 0)
+ platformFileName = nullptr;
+ void *h = dlopen(platformFileName, RTLD_NOW | RTLD_GLOBAL);
+ if (!h)
+ {
#if 0
// We can't output the error message here, because it will cause output when testing what code gen is available
if(auto msg = dlerror())
@@ -195,7 +203,6 @@ SLANG_COMPILE_TIME_ASSERT(E_OUTOFMEMORY == SLANG_E_OUT_OF_MEMORY);
/* static */void* SharedLibrary::findSymbolAddressByName(Handle handle, char const* name)
{
- SLANG_ASSERT(handle);
return dlsym((void*)handle, name);
}
diff --git a/source/core/slang-shared-library.cpp b/source/core/slang-shared-library.cpp
index f31c7d689..6ce10ad9e 100644
--- a/source/core/slang-shared-library.cpp
+++ b/source/core/slang-shared-library.cpp
@@ -33,7 +33,7 @@ SlangResult DefaultSharedLibraryLoader::loadSharedLibrary(const char* path, ISla
{
*outSharedLibrary = nullptr;
// Try loading
- SharedLibrary::Handle handle;
+ SharedLibrary::Handle handle = nullptr;
SLANG_RETURN_ON_FAIL(SharedLibrary::load(path, handle));
*outSharedLibrary = ComPtr<ISlangSharedLibrary>(new DefaultSharedLibrary(handle)).detach();
return SLANG_OK;