Explorar el Código

Let NativeFunction check if the parameter is a table, userdata or function

Ole hace 9 años
padre
commit
72055a0af6
Se han modificado 1 ficheros con 5 adiciones y 1 borrados
  1. 5 1
      lib/luwra/functions.hpp

+ 5 - 1
lib/luwra/functions.hpp

@@ -77,7 +77,11 @@ struct NativeFunction<void> {
 	inline
 	NativeFunction(State* state, int index):
 		ref(state, index)
-	{}
+	{
+		int type = lua_type(state, index);
+		if (type != LUA_TTABLE && type != LUA_TUSERDATA && type != LUA_TFUNCTION)
+			luaL_argerror(state, index, "Expected table, userdata or function");
+	}
 
 	inline
 	void operator ()() const {