1 /* 2 DSDL 3 Copyright (C) 2025 Inochi2D Project <luna@foxgirls.gay> 4 5 This software is provided 'as-is', without any express or implied 6 warranty. In no event will the authors be held liable for any damages 7 arising from the use of this software. 8 9 Permission is granted to anyone to use this software for any purpose, 10 including commercial applications, and to alter it and redistribute it 11 freely, subject to the following restrictions: 12 13 1. The origin of this software must not be misrepresented; you must not 14 claim that you wrote the original software. If you use this software 15 in a product, an acknowledgment in the product documentation would be 16 appreciated but is not required. 17 2. Altered source versions must be plainly marked as such, and must not be 18 misrepresented as being the original software. 19 3. This notice may not be removed or altered from any source distribution. 20 21 ========================================================================== 22 23 Simple DirectMedia Layer 24 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> 25 26 This software is provided 'as-is', without any express or implied 27 warranty. In no event will the authors be held liable for any damages 28 arising from the use of this software. 29 30 Permission is granted to anyone to use this software for any purpose, 31 including commercial applications, and to alter it and redistribute it 32 freely, subject to the following restrictions: 33 34 1. The origin of this software must not be misrepresented; you must not 35 claim that you wrote the original software. If you use this software 36 in a product, an acknowledgment in the product documentation would be 37 appreciated but is not required. 38 2. Altered source versions must be plainly marked as such, and must not be 39 misrepresented as being the original software. 40 3. This notice may not be removed or altered from any source distribution. 41 */ 42 43 /** 44 SDL System-dependent library loading routines. 45 46 See_Also: 47 $(LINK2 https://wiki.libsdl.org/SDL3/CategorySharedObject, SDL3 Shared Object Documentation) 48 49 Copyright: © 2025 Inochi2D Project, © 1997-2025 Sam Lantinga 50 License: Subject to the terms of the Zlib License, as written in the LICENSE file. 51 Authors: 52 Luna Nielsen 53 */ 54 module sdl.loadso; 55 import sdl.stdc; 56 import sdl.error; 57 58 extern (C) nothrow @nogc: 59 60 /** 61 An opaque datatype that represents a loaded shared object. 62 63 See_Also: 64 $(D SDL_LoadObject) 65 $(D SDL_LoadFunction) 66 $(D SDL_UnloadObject) 67 */ 68 struct SDL_SharedObject; 69 70 /** 71 Dynamically load a shared object. 72 73 Params: 74 sofile = A system-dependent name of the object file. 75 76 Returns: 77 An opaque pointer to the object handle or $(D null) on failure; 78 call SDL_GetError() for more information. 79 80 Threadsafety: 81 It is safe to call this function from any thread. 82 83 See_Also: 84 $(D SDL_LoadFunction) 85 $(D SDL_UnloadObject) 86 */ 87 extern SDL_SharedObject* SDL_LoadObject(const(char)* sofile); 88 89 /** 90 Look up the address of the named function in a shared object. 91 92 This function pointer is no longer valid after calling $(D SDL_UnloadObject). 93 94 This function can only look up C function names. Other languages may have 95 name mangling and intrinsic language support that varies from compiler to 96 compiler. 97 98 Make sure you declare your function pointers with the same calling 99 convention as the actual library function. Your code will crash 100 mysteriously if you do not do this. 101 102 If the requested function doesn't exist, NULL is returned. 103 104 Params: 105 handle = A valid shared object handle returned by $(D SDL_LoadObject). 106 name = The name of the function to look up. 107 108 Returns: 109 A pointer to the function or NULL on failure; call SDL_GetError() 110 for more information. 111 112 Threadsafety: 113 It is safe to call this function from any thread. 114 115 See_Also: 116 $(D SDL_LoadObject) 117 */ 118 extern SDL_FunctionPointer SDL_LoadFunction(SDL_SharedObject* handle, const(char)* name); 119 120 /** 121 Unload a shared object from memory. 122 123 Note that any pointers from this object looked up through 124 ($D SDL_LoadFunction) will no longer be valid. 125 126 Params: 127 handle = A valid shared object handle returned by $(D SDL_LoadObject). 128 129 Threadsafety: 130 It is safe to call this function from any thread. 131 132 See_Also: 133 $(D SDL_LoadObject) 134 */ 135 extern void SDL_UnloadObject(SDL_SharedObject* handle);