1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-03 17:27:47 +00:00
sapphire/src/world/Script/ScriptInfo.h

70 lines
1.8 KiB
C
Raw Normal View History

2018-03-02 07:39:38 -03:00
#ifndef CORE_SCRIPTINFO_H
#define CORE_SCRIPTINFO_H
#include <vector>
#include "NativeScriptApi.h"
#ifdef _WIN32
2018-03-02 08:13:45 -03:00
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
2018-10-28 21:53:21 +01:00
using ModuleHandle = HMODULE;
#else
2018-10-28 21:53:21 +01:00
using ModuleHandle = void*;
#endif
namespace Sapphire::Scripting
{
/*!
2018-10-28 21:53:21 +01:00
* @brief An internal class used to track information about loaded modules and their scripts.
*
2018-10-28 21:53:21 +01:00
* The main purpose of this is to maintain easy access to the module handle and the pointers to scripts that are loaded.
* Furthermore, allows for quick and easy cross platform access to the module paths associated with the runtime module cache and its original path.
*/
2018-10-28 21:53:21 +01:00
class ScriptInfo
{
public:
ScriptInfo() = default;
2018-07-24 22:48:42 +10:00
2018-10-28 21:53:21 +01:00
/*!
* @brief The file name of the loaded library.
*
* On all platforms, this will be the full filename of the module, eg:
* - script_instances.dll on Windows
* - libscript_instances.so on Linux
*/
std::string library_name;
2018-07-24 22:48:42 +10:00
2018-10-28 21:53:21 +01:00
/*!
* @brief The path to the module currently loaded in memory from the cached location.
*/
std::string cache_path;
2018-10-28 21:53:21 +01:00
/*!
* @brief The original path of the module before it was copied to the cache location.
*/
std::string library_path;
/*!
* @brief A handle to the module.
*
* The underlying type for this depends on platform. On Windows it's some stupid shit, on everything else it's a void*.
*/
ModuleHandle handle;
/*!
* @brief An internal list of all the pointers to each ScriptObject
*
* This is tracked so when we unload this module we can call delete on each ScriptObject and correctly free it from memory.
*/
std::vector< Sapphire::ScriptAPI::ScriptObject* > scripts;
2018-10-28 21:53:21 +01:00
};
2018-07-24 22:48:42 +10:00
}
#endif //SAPPHIRE_SCRIPTINFO_H