From 8cd3b18f7bcb5a325621a043ac63ec980952167a Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sun, 27 Apr 2014 01:29:37 -0400 Subject: [PATCH] Fix test failure --- sol/userdata.hpp | 12 ++++++++---- tests.cpp | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sol/userdata.hpp b/sol/userdata.hpp index 3f5edce3..5ffc7d19 100644 --- a/sol/userdata.hpp +++ b/sol/userdata.hpp @@ -111,13 +111,13 @@ private: public: template - userdata(Args&&... args) : userdata(classname, default_constructor, std::forward(args)...) {} + userdata(Args&&... args): userdata(classname, default_constructor, std::forward(args)...) {} template - userdata(constructors c, Args&&... args) : userdata(classname, std::move(c), std::forward(args)...) {} + userdata(constructors c, Args&&... args): userdata(classname, std::move(c), std::forward(args)...) {} template - userdata(std::string name, constructors, Args&&... args) : luaname(std::move(name)) { + userdata(std::string name, constructors, Args&&... args): luaname(std::move(name)) { functionnames.reserve(sizeof...(args) + 2); functiontable.reserve(sizeof...(args) + 3); functions.reserve(sizeof...(args) + 2); @@ -131,6 +131,10 @@ public: functiontable.push_back({ nullptr, nullptr }); } + template + userdata(const char* name, constructors c, Args&&... args) : + userdata(std::string(name), std::move(c), std::forward(args)...) {} + void register_into(const table& s) {} }; @@ -140,6 +144,6 @@ const std::string userdata::classname = detail::demangle(typeid(T)); template const std::string userdata::meta = std::string("sol.stateful.").append(classname); -} +} // sol #endif // SOL_USERDATA_HPP diff --git a/tests.cpp b/tests.cpp index dc456075..c12cdf6d 100644 --- a/tests.cpp +++ b/tests.cpp @@ -43,7 +43,7 @@ struct fuser { return x + y + 2; } }; -} +} // crapola int plop_xyz(int x, int y, std::string z) { std::cout << x << " " << y << " " << z << std::endl; @@ -386,7 +386,7 @@ TEST_CASE("tables/userdata constructors", "Show that we can create classes from sol::state lua; sol::constructors, sol::types, sol::types> con; - sol::userdata lc(con, &crapola::fuser::add, "add", &crapola::fuser::add2, "add2"); + sol::userdata lc("crapola_fuser", con, &crapola::fuser::add, "add", &crapola::fuser::add2, "add2"); lua.set_class(lc); lua.script(