Преглед изворни кода

lightweight userdata methods implemented

mikymod пре 12 година
родитељ
комит
02c305ab7d
2 измењених фајлова са 14 додато и 0 уклоњено
  1. 12 0
      src/script/LuaStack.cpp
  2. 2 0
      src/script/LuaStack.h

+ 12 - 0
src/script/LuaStack.cpp

@@ -1,4 +1,5 @@
 #include "LuaStack.h"
+#include <cassert>
 
 namespace crown
 {
@@ -63,4 +64,15 @@ const char* LuaStack::get_string(int32_t index)
 	return luaL_checkstring(m_state, index);
 }
 
+const void* LuaStack::get_lightudata(int32_t index)
+{
+	if (!lua_islightuserdata(m_state, index))
+	{
+		assert(0);
+	}
+
+	return lua_touserdata(m_state, index);
+}	
+
+
 } // namespace crown

+ 2 - 0
src/script/LuaStack.h

@@ -30,6 +30,8 @@ public:
 
 	const char*				get_string(int32_t index);
 
+	const void*				get_lightudata(int32_t index);
+
 private:
 
 	lua_State* 				m_state;