소스 검색

Add 'new_table' helper which allows you to create new table easily

Ole 10 년 전
부모
커밋
739bcef171
1개의 변경된 파일9개의 추가작업 그리고 0개의 파일을 삭제
  1. 9 0
      lib/luwra/stack.hpp

+ 9 - 0
lib/luwra/stack.hpp

@@ -151,6 +151,15 @@ void set_fields(State* state, int index, R&&... args) {
 	internal::EntryPusher<R...>::push(state, index, std::forward<R>(args)...);
 }
 
+/**
+ * Create a new table and set its fields.
+ */
+template <typename... R> static inline
+void new_table(State* state, R&&... args) {
+	lua_newtable(state);
+	set_fields(state, lua_gettop(state), std::forward<R>(args)...);
+}
+
 LUWRA_NS_END
 
 #endif