diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2018-11-06 14:28:25 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-06 14:28:25 -0500 |
| commit | 1185bd464092f372430cbfaa15a7be4dcaa90752 (patch) | |
| tree | b3b68f2d9de00c0845f4912a797f10b27741031f /source/core/platform.h | |
| parent | 453331951b0df2a612f9bc0d68eab2ad786ec5bf (diff) | |
Feature/shared library refactor (#712)
* * Added ISlangSharedLibraryLoader and ISlangSharedLibrary
* Implemented default implementations
* Added slang API function to get/set the ISlangSharedLibraryLoader on the session
* Put function caching onto the Session - so that if the loader is chaged, its easy to reset the shared libraries, and functions
* Run premake.
* Fix problem with setting null, would cause an unnecessary function/shared lib flush.
* * Unload SharedLibrary when DefaultSharedLibrary is deleted.
* Make SharedLibrary handle unload safely if already unloaded.
* Refactor SharedLibrary, such that it becomes a utility class - simplifying it's semantics.
* Simplified ISlangSharedLibrary such that doesn't have unload and isLoaded so easier to implement.
Use updated SharedLibrary impl.
* Disable aarch64 on windows
* Premake windows files without aarch64 build.
* Moved slang-shared-library to core (so can be used in code outside of main slang)
Fixed problem in premake5 where on windows projects were incorrectly constructed
* Allowed RefObject to base class of com types
Added ConfigurableSharedLibraryLoader
Added -dxc-path -fxc-path -glslang-path
Fix problem with dxc-path not honoring it's path when loading dxil
* Added documentation for command line control of dll loading paths.
* Remove some tabbing issues.
* Change name of include guard.
Diffstat (limited to 'source/core/platform.h')
| -rw-r--r-- | source/core/platform.h | 56 |
1 files changed, 38 insertions, 18 deletions
diff --git a/source/core/platform.h b/source/core/platform.h index fef698e6f..a545d139d 100644 --- a/source/core/platform.h +++ b/source/core/platform.h @@ -2,30 +2,50 @@ #ifndef SLANG_CORE_PLATFORM_H_INCLUDED #define SLANG_CORE_PLATFORM_H_INCLUDED +#include "../../slang.h" +#include "../core/slang-string.h" + namespace Slang { // Interface for working with shared libraries - // in a platfomr-independent fashion. + // in a platform-independent fashion. struct SharedLibrary { typedef struct SharedLibraryImpl* Handle; - Handle handle; - - // Attempt to load a shared library for - // the current platform. - static SharedLibrary load(char const* name); - - // If this refers to a valid loaded library, - // then attempt to unload it - void unload(); - - typedef void (*FuncPtr)(void); - - FuncPtr findFuncByName(char const* name); - - - operator Handle() { return handle; } - }; + + typedef void(*FuncPtr)(void); + + /// Load via an unadorned filename + /// + /// @param the unadorned filename + /// @return Returns a non null handle for the shared library on success. nullptr indicated failure + static SlangResult load(const char* filename, Handle& handleOut); + + /// Attempt to load a shared library for + /// the current platform. Returns null handle on failure + /// The platform specific filename can be generated from a call to appendPlatformFileName + /// + /// @param platformFileName the platform specific file name. + /// @return Returns a non null handle for the shared library on success. nullptr indicated failure + static SlangResult loadWithPlatformFilename(char const* platformFileName, Handle& handleOut); + + /// Unload the library that was returned from load as handle + /// @param The valid handle returned from load + static void unload(Handle handle); + + /// Given a shared library handle and a name, return the associated function + /// Return nullptr if function is not found + /// @param The shared library handle as returned by loadPlatformLibrary + static FuncPtr findFuncByName(Handle handle, char const* name); + + /// Append to the end of dst, the name, with any platform specific additions + /// The input name should be unadorned with any 'lib' prefix or extension + static void appendPlatformFileName(const UnownedStringSlice& name, StringBuilder& dst); + + private: + /// Not constructible! + SharedLibrary(); + }; #ifndef _MSC_VER #define _fileno fileno |
