Ver código fonte

implement lightdata temp methods for testing, maybe they will be removed

mikymod 12 anos atrás
pai
commit
3f205d6a27
2 arquivos alterados com 20 adições e 0 exclusões
  1. 16 0
      src/lua/LuaStack.cpp
  2. 4 0
      src/lua/LuaStack.h

+ 16 - 0
src/lua/LuaStack.cpp

@@ -100,6 +100,12 @@ void LuaStack::push_string(const char* str, size_t len)
 	lua_pushlstring(m_state, str, len);
 	lua_pushlstring(m_state, str, len);
 }
 }
 
 
+//-----------------------------------------------------------------------------
+void LuaStack::push_lightdata(void* data, size_t len)
+{
+	lua_pushlightuserdata(m_state, data);
+}
+
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 void LuaStack::push_vec2(Vec2* v)
 void LuaStack::push_vec2(Vec2* v)
 {
 {
@@ -156,6 +162,16 @@ const char* LuaStack::get_string(int32_t index)
 	return luaL_checkstring(m_state, index);
 	return luaL_checkstring(m_state, index);
 }
 }
 
 
+//-----------------------------------------------------------------------------
+void* LuaStack::get_lightdata(int32_t index)
+{
+	CE_ASSERT(lua_islightuserdata(m_state, index), "Not a lightuserdata object");
+
+	void* data = lua_touserdata(m_state, index);
+
+	return data;	
+}
+
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
 Vec2* LuaStack::get_vec2(int32_t index)
 Vec2* LuaStack::get_vec2(int32_t index)
 {
 {

+ 4 - 0
src/lua/LuaStack.h

@@ -36,6 +36,8 @@ public:
 
 
 	void 					push_string(const char* str, size_t len);
 	void 					push_string(const char* str, size_t len);
 
 
+	void					push_lightdata(void* data, size_t len);
+
 	void					push_vec2(Vec2* v);
 	void					push_vec2(Vec2* v);
 
 
 	void					push_vec3(Vec3* v);
 	void					push_vec3(Vec3* v);
@@ -52,6 +54,8 @@ public:
 
 
 	const char*				get_string(int32_t index);
 	const char*				get_string(int32_t index);
 
 
+	void*					get_lightdata(int32_t index);
+
 	Vec2*					get_vec2(int32_t index);
 	Vec2*					get_vec2(int32_t index);
 
 
 	Vec3*					get_vec3(int32_t index);
 	Vec3*					get_vec3(int32_t index);