Browse Source

lightweight userdata methods implemented

mikymod 12 years ago
parent
commit
02c305ab7d
2 changed files with 14 additions and 0 deletions
  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 "LuaStack.h"
+#include <cassert>
 
 
 namespace crown
 namespace crown
 {
 {
@@ -63,4 +64,15 @@ const char* LuaStack::get_string(int32_t index)
 	return luaL_checkstring(m_state, 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
 } // namespace crown

+ 2 - 0
src/script/LuaStack.h

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