Give HTTPRequest a __tostring

This commit is contained in:
Mm2PL 2024-10-08 22:20:15 +02:00
parent 90bcdc8bf5
commit 7b5ed5297e
No known key found for this signature in database
GPG key ID: 94AC9B80EFA15ED9
2 changed files with 17 additions and 3 deletions

View file

@ -31,8 +31,9 @@ namespace chatterino::lua::api {
void HTTPRequest::createUserType(sol::table &c2)
{
c2.new_usertype<HTTPRequest>( //
"HTTPRequest", sol::no_constructor, //
c2.new_usertype<HTTPRequest>( //
"HTTPRequest", sol::no_constructor, //
sol::meta_method::to_string, &HTTPRequest::to_string, //
"on_success", &HTTPRequest::on_success, //
"on_error", &HTTPRequest::on_error, //
@ -172,5 +173,10 @@ HTTPRequest::~HTTPRequest()
// but that's better than accessing a possibly invalid lua_State pointer.
}
QString HTTPRequest::to_string()
{
return "<HTTPRequest>";
}
} // namespace chatterino::lua::api
#endif

View file

@ -2,13 +2,16 @@
#ifdef CHATTERINO_HAVE_PLUGINS
# include "common/network/NetworkRequest.hpp"
# include "controllers/plugins/LuaUtilities.hpp"
# include "controllers/plugins/PluginController.hpp"
# include <sol/forward.hpp>
# include <sol/types.hpp>
# include <memory>
namespace chatterino {
class PluginController;
} // namespace chatterino
namespace chatterino::lua::api {
// NOLINTBEGIN(readability-identifier-naming)
@ -110,6 +113,11 @@ public:
* @exposed HTTPRequest:execute
*/
void execute(sol::this_state L);
/**
* @lua@return string
* @exposed HTTPRequest:__tostring
*/
QString to_string();
/**
* Static functions