Cherry pick changes from wip-scritchui which should be mainline.
[SquirrelJME.git] / nanocoat / include / sjme / dylib.h
blob2b1349aa980121c62162fb6b741b1cf19d704c95
1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
10 /**
11 * Dynamic Library loading.
13 * @since 2024/03/27
16 #ifndef SQUIRRELJME_DYLIB_H
17 #define SQUIRRELJME_DYLIB_H
19 #include "sjme/nvm.h"
21 /* Anti-C++. */
22 #ifdef __cplusplus
23 #ifndef SJME_CXX_IS_EXTERNED
24 #define SJME_CXX_IS_EXTERNED
25 #define SJME_CXX_SQUIRRELJME_DYLIB_H
26 extern "C" {
27 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
28 #endif /* #ifdef __cplusplus */
30 /*--------------------------------------------------------------------------*/
32 /**
33 * Opaque dynamic library type.
35 * @since 2024/03/27
37 typedef void* sjme_dylib;
39 /**
40 * Closes the given dynamic library.
42 * @param inLib The library to close.
43 * @return Any error if it occurs.
44 * @since 2024/03/27
46 sjme_errorCode sjme_dylib_close(
47 sjme_attrInNotNull sjme_dylib inLib);
49 /**
50 * Looks up the given symbol in the library.
52 * @param inLib The library to look within.
53 * @param inSymbol The symbol to obtain from the library.
54 * @param outPtr The resultant pointer of the symbol.
55 * @return Any error if it occurs.
56 * @since 2024/03/27
58 sjme_errorCode sjme_dylib_lookup(
59 sjme_attrInNotNull sjme_dylib inLib,
60 sjme_attrInNotNull sjme_lpcstr inSymbol,
61 void* outPtr);
63 /**
64 * Opens a dynamic library.
66 * @param libPath The path to the library to open.
67 * @param outLib The resultant opened library.
68 * @return Any error if it occurs.
69 * @since 2024/03/27
71 sjme_errorCode sjme_dylib_open(
72 sjme_attrInNotNull sjme_lpcstr libPath,
73 sjme_attrInOutNotNull sjme_dylib* outLib);
75 /*--------------------------------------------------------------------------*/
77 /* Anti-C++. */
78 #ifdef __cplusplus
79 #ifdef SJME_CXX_SQUIRRELJME_DYLIB_H
81 #undef SJME_CXX_SQUIRRELJME_DYLIB_H
82 #undef SJME_CXX_IS_EXTERNED
83 #endif /* #ifdef SJME_CXX_SQUIRRELJME_DYLIB_H */
84 #endif /* #ifdef __cplusplus */
86 #endif /* SQUIRRELJME_DYLIB_H */