Sfoglia il codice sorgente

Make methods parameter optional when registering user types

Ole 10 anni fa
parent
commit
741cac9220
2 ha cambiato i file con 5 aggiunte e 5 eliminazioni
  1. 1 1
      lib/luwra/usertypes.hpp
  2. 4 4
      tests/usertypes.cpp

+ 1 - 1
lib/luwra/usertypes.hpp

@@ -325,7 +325,7 @@ constexpr CFunction wrap_field =
 template <typename U> static inline
 void register_user_type(
 	State* state,
-	const std::map<const char*, CFunction>& methods,
+	const std::map<const char*, CFunction>& methods = std::map<const char*, CFunction>(),
 	const std::map<const char*, CFunction>& meta_methods = std::map<const char*, CFunction>()
 ) {
 	using T = internal::StripUserType<U>;

+ 4 - 4
tests/usertypes.cpp

@@ -15,7 +15,7 @@ TEST_CASE("usertypes_registration") {
 	lua_State* state = luaL_newstate();
 
 	// Registration
-	luwra::register_user_type<A>(state, {});
+	luwra::register_user_type<A>(state);
 
 	// Reference
 	A* instance = new A;
@@ -33,7 +33,7 @@ TEST_CASE("usertypes_ctor") {
 	lua_State* state = luaL_newstate();
 
 	// Registration
-	luwra::register_user_type<A>(state, {});
+	luwra::register_user_type<A>(state);
 	luwra::register_global(state, "A", luwra::wrap_constructor<A, int>);
 
 	// Construction
@@ -183,7 +183,7 @@ TEST_CASE("usertypes_gchook_tref") {
 	lua_State* state = luaL_newstate();
 
 	// Registration
-	luwra::register_user_type<std::shared_ptr<int>>(state, {});
+	luwra::register_user_type<std::shared_ptr<int>>(state);
 
 	// Instantiation
 	std::shared_ptr<int> shared_var = std::make_shared<int>(1337);
@@ -202,7 +202,7 @@ TEST_CASE("usertypes_gchook_tptr") {
 	lua_State* state = luaL_newstate();
 
 	// Registration
-	luwra::register_user_type<std::shared_ptr<int>>(state, {});
+	luwra::register_user_type<std::shared_ptr<int>>(state);
 
 	// Instantiation
 	std::shared_ptr<int> shared_var = std::make_shared<int>(1337);