Procházet zdrojové kódy

examples: Improve stack example

Ole Krüger před 10 roky
rodič
revize
5143a2e4d7
1 změnil soubory, kde provedl 6 přidání a 6 odebrání
  1. 6 6
      examples/stack.cpp

+ 6 - 6
examples/stack.cpp

@@ -6,8 +6,8 @@
 using namespace luwra;
 
 static
-lua_Integer sum3(lua_Integer a, lua_Integer b, lua_Integer c) {
-	return a + b + c;
+double sum3(int a, int b, double c) {
+	return (a + b) * c;
 }
 
 int main() {
@@ -17,12 +17,12 @@ int main() {
 	// Build stack
 	lua_pushinteger(state, 13);
 	lua_pushinteger(state, 37);
-	lua_pushinteger(state, 42);
+	lua_pushnumber(state, 42);
 
 	// Each value can be retrieved individually.
-	std::cout << "a = " << Value<lua_Integer>::read(state, 1) << std::endl;
-	std::cout << "b = " << Value<lua_Integer>::read(state, 2) << std::endl;
-	std::cout << "c = " << Value<lua_Integer>::read(state, 3) << std::endl;
+	std::cout << "a = " << Value<int>::read(state, 1) << std::endl;
+	std::cout << "b = " << Value<int>::read(state, 2) << std::endl;
+	std::cout << "c = " << Value<double>::read(state, 3) << std::endl;
 
 	// ... which is a little cumbersome. Instead we might apply a fitting function to our stack.
 	std::cout << "a + b + c = "