소스 검색

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

Ole 9 년 전
부모
커밋
72055a0af6
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  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 {