diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-08 01:57:30 -0500 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-08 01:57:30 -0500 |
| commit | 2ddaf86857828500235e8b8a65c11bb2dd91b8be (patch) | |
| tree | 46899c14955bf356be2331e63c181afd4089d982 /include/CompilerKit/Utilities/DLL.h | |
| parent | 9f7c44f1577f194cb76b03ac45a2af542a86c8b9 (diff) | |
chore! breaking API changes and new APIs introduced.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'include/CompilerKit/Utilities/DLL.h')
| -rw-r--r-- | include/CompilerKit/Utilities/DLL.h | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/include/CompilerKit/Utilities/DLL.h b/include/CompilerKit/Utilities/DLL.h index 5bfe032..490017e 100644 --- a/include/CompilerKit/Utilities/DLL.h +++ b/include/CompilerKit/Utilities/DLL.h @@ -10,21 +10,18 @@ #include <dlfcn.h> #include <mutex> -struct CompilerKitDylibTraits; +namespace CompilerKit { +struct DLLTraits final { + typedef Int32 (*Entrypoint)(Int32 argc, Char const* argv[]); + using DLL = VoidPtr; -typedef Int32 (*CompilerKitEntrypoint)(Int32 argc, Char const* argv[]); -typedef VoidPtr CompilerKitDylib; + DLL fDylib{nullptr}; + Entrypoint fEntrypoint{nullptr}; + std::mutex fMutex; -struct CompilerKitDylibTraits final { - CompilerKitDylib fDylib{nullptr}; - CompilerKitEntrypoint fEntrypoint{nullptr}; - std::mutex fMutex; + explicit operator bool() { return fDylib && fEntrypoint; } - explicit operator bool() { - return fDylib && fEntrypoint; - } - - CompilerKitDylibTraits& operator()(const Char* path, const Char* fEntrypoint) { + DLLTraits& operator()(const Char* path, const Char* fEntrypoint) { std::lock_guard<std::mutex> lock(this->fMutex); if (!path || !fEntrypoint) return *this; @@ -40,7 +37,7 @@ struct CompilerKitDylibTraits final { return *this; } - this->fEntrypoint = (CompilerKitEntrypoint) dlsym(this->fDylib, fEntrypoint); + this->fEntrypoint = (Entrypoint) dlsym(this->fDylib, fEntrypoint); if (!this->fEntrypoint) { dlclose(this->fDylib); @@ -52,11 +49,11 @@ struct CompilerKitDylibTraits final { return *this; } - NECTI_COPY_DELETE(CompilerKitDylibTraits); + NECTI_COPY_DELETE(DLLTraits) - CompilerKitDylibTraits() = default; + explicit DLLTraits() = default; - ~CompilerKitDylibTraits() { + ~DLLTraits() { if (this->fDylib) { dlclose(this->fDylib); this->fDylib = nullptr; @@ -65,3 +62,4 @@ struct CompilerKitDylibTraits final { this->fEntrypoint = nullptr; } }; +} // namespace CompilerKit
\ No newline at end of file |
