Kaynağa Gözat

push functions implemented in LuaStack

mikymod 12 yıl önce
ebeveyn
işleme
df88501132

+ 3 - 4
src/lua/DeviceBinds.cpp

@@ -12,9 +12,7 @@ CE_EXPORT int32_t device_frame_count(lua_State* L)
 
 	uint64_t frame = device()->frame_count();
 
-	// FIXME: push_int use int32_t, so we need a push_int64,
-	// but i don't know if lua 5.1 supports 64 bit integer
-	stack.push_int(frame);
+	stack.push_uint64(frame);
 
 	return 1;
 }
@@ -50,9 +48,10 @@ CE_EXPORT int32_t device_stop(lua_State* L)
 //-----------------------------------------------------------------------------
 void load_device(LuaEnvironment& env)
 {
+	env.load_module_function("Device", "frame_count", device_frame_count);
+	env.load_module_function("Device", "last_delta_time", device_last_delta_time);
 	env.load_module_function("Device", "start", device_start);
 	env.load_module_function("Device", "stop", device_stop);
-	env.load_module_function("Device", "last_delta_time", device_last_delta_time);
 }
 
 } // namespace crown

+ 19 - 1
src/lua/LuaStack.cpp

@@ -65,7 +65,25 @@ void LuaStack::push_bool(bool value)
 }
 
 //-----------------------------------------------------------------------------
-void LuaStack::push_int(int32_t value)
+void LuaStack::push_int32(int32_t value)
+{
+	lua_pushinteger(m_state, value);
+}
+
+//-----------------------------------------------------------------------------
+void LuaStack::push_uint32(uint32_t value)
+{
+	lua_pushinteger(m_state, value);
+}
+
+//-----------------------------------------------------------------------------
+void LuaStack::push_int64(int64_t value)
+{
+	lua_pushinteger(m_state, value);
+}
+
+//-----------------------------------------------------------------------------
+void LuaStack::push_uint64(uint64_t value)
 {
 	lua_pushinteger(m_state, value);
 }

+ 7 - 1
src/lua/LuaStack.h

@@ -24,7 +24,13 @@ public:
 
 	void					push_bool(bool value);
 
-	void					push_int(int32_t value);
+	void					push_int32(int32_t value);
+
+	void					push_uint32(uint32_t value);
+
+	void					push_int64(int64_t value);
+
+	void					push_uint64(uint64_t value);
 
 	void 					push_float(float value);
 

+ 1 - 1
src/lua/MathBinds.cpp

@@ -36,7 +36,7 @@ CE_EXPORT int32_t math_next_pow_2(lua_State* L)
 
 	uint32_t x = stack.get_int(1);
 
-	stack.push_int(math::next_pow_2(x));
+	stack.push_uint32(math::next_pow_2(x));
 
 	return 1;
 }

+ 0 - 1
src/lua/Vec2Binds.cpp

@@ -2,7 +2,6 @@
 #include "LuaStack.h"
 #include "LuaEnvironment.h"
 
-
 namespace crown
 {