Add the ability for lua libraries to define sublibraries

This commit is contained in:
Alexander Bock
2021-11-01 22:44:32 +01:00
parent 24ce66aad4
commit fb6807b1e0
3 changed files with 163 additions and 98 deletions
+9 -4
View File
@@ -33,9 +33,9 @@
namespace openspace::scripting {
/**
* This structure represents a Lua library, itself consisting of a unique #name and
* an arbitrary number of #functions
*/
* This structure represents a Lua library, itself consisting of a unique #name and
* an arbitrary number of #functions
*/
struct LuaLibrary {
/**
* This structure represents a Lua function with its #name, #function pointer
@@ -49,7 +49,7 @@ struct LuaLibrary {
lua_CFunction function;
/// A vector of light userdata to be passed into the function
std::vector<void*> userdata;
/// A text describing the arugments to this function
/// A text describing the arguments to this function
std::string argumentText;
/// A help text describing what the function does/
std::string helpText;
@@ -58,6 +58,8 @@ struct LuaLibrary {
std::string name;
/// The list of all C-based callback functions for this library
std::vector<Function> functions;
/// A list of all libraries that are children for this library
std::vector<LuaLibrary> subLibraries;
/// A list of script files that are executed for each Lua state
std::vector<std::filesystem::path> scripts = std::vector<std::filesystem::path>();
@@ -77,6 +79,9 @@ struct LuaLibrary {
/// Comparison function that compares two LuaLibrary%s name
bool operator<(const LuaLibrary& rhs) const;
/// Merges the contents of a second LuaLibrary into this LuaLibrary
void merge(LuaLibrary rhs);
};
} // namespace openspace::scripting