#pragma once #include #include #include "utils/str_cat.hpp" namespace devilution { inline std::string LuaSignatureKey(std::string_view key) { return StrCat("__sig_", key); } inline std::string LuaDocstringKey(std::string_view key) { return StrCat("__doc_", key); } template void SetDocumented(sol::table &table, std::string_view key, std::string_view signature, std::string_view doc, T &&value) { table[key] = std::forward(value); table[LuaSignatureKey(key)] = signature; table[LuaDocstringKey(key)] = doc; } template void SetWithSignature(sol::table &table, std::string_view key, std::string_view signature, T &&value) { table[key] = std::forward(value); table[LuaSignatureKey(key)] = signature; } inline std::optional GetSignature(const sol::table &table, std::string_view key) { return table.get>(LuaSignatureKey(key)); } inline std::optional GetDocstring(const sol::table &table, std::string_view key) { return table.get>(LuaDocstringKey(key)); } } // namespace devilution