Fix test failure

This commit is contained in:
Rapptz 2014-04-27 01:29:37 -04:00
parent b6c2f1c6d5
commit 8cd3b18f7b
2 changed files with 10 additions and 6 deletions

View File

@ -111,13 +111,13 @@ private:
public:
template<typename... Args>
userdata(Args&&... args) : userdata(classname, default_constructor, std::forward<Args>(args)...) {}
userdata(Args&&... args): userdata(classname, default_constructor, std::forward<Args>(args)...) {}
template<typename... Args, typename... CArgs>
userdata(constructors<CArgs...> c, Args&&... args) : userdata(classname, std::move(c), std::forward<Args>(args)...) {}
userdata(constructors<CArgs...> c, Args&&... args): userdata(classname, std::move(c), std::forward<Args>(args)...) {}
template<typename... Args, typename... CArgs>
userdata(std::string name, constructors<CArgs...>, Args&&... args) : luaname(std::move(name)) {
userdata(std::string name, constructors<CArgs...>, 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<typename... Args, typename... CArgs>
userdata(const char* name, constructors<CArgs...> c, Args&&... args) :
userdata(std::string(name), std::move(c), std::forward<Args>(args)...) {}
void register_into(const table& s) {}
};
@ -140,6 +144,6 @@ const std::string userdata<T>::classname = detail::demangle(typeid(T));
template<typename T>
const std::string userdata<T>::meta = std::string("sol.stateful.").append(classname);
}
} // sol
#endif // SOL_USERDATA_HPP

View File

@ -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<int>, sol::types<int, int>> con;
sol::userdata<crapola::fuser> lc(con, &crapola::fuser::add, "add", &crapola::fuser::add2, "add2");
sol::userdata<crapola::fuser> lc("crapola_fuser", con, &crapola::fuser::add, "add", &crapola::fuser::add2, "add2");
lua.set_class(lc);
lua.script(