From 89083c4b50af8e48e70b25b63cc62aca21ab706c Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 10 Aug 2022 01:58:41 -0700 Subject: 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 --- source/core/slang-platform.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'source/core/slang-platform.cpp') 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); } -- cgit v1.2.3