Sfoglia il codice sorgente

examples: Use Push to push (duh)

Ole Krüger 10 anni fa
parent
commit
24d1d711b3
3 ha cambiato i file con 7 aggiunte e 8 eliminazioni
  1. 3 3
      examples/functions.cpp
  2. 3 3
      examples/stack.cpp
  3. 1 2
      examples/usertypes.cpp

+ 3 - 3
examples/functions.cpp

@@ -26,17 +26,17 @@ int main() {
 
 	// Register 'my_function_1'
 	auto wrapped_1 = WrapFunction<void(float, const char*), my_function_1>;
-	lua_pushcfunction(state, wrapped_1);
+	Push(state, wrapped_1);
 	lua_setglobal(state, "my_function_1");
 
 	// Register 'my_function_2'
 	auto wrapped_2 = WrapFunction<std::string(), my_function_2>;
-	lua_pushcfunction(state, wrapped_2);
+	Push(state, wrapped_2);
 	lua_setglobal(state, "my_function_2");
 
 	// Register 'my_function_3'
 	auto wrapped_3 = WrapFunction<int(int, int), my_function_3>;
-	lua_pushcfunction(state, wrapped_3);
+	Push(state, wrapped_3);
 	lua_setglobal(state, "my_function_3");
 
 	// Invoke the attached script

+ 3 - 3
examples/stack.cpp

@@ -15,9 +15,9 @@ int main() {
 	luaL_openlibs(state);
 
 	// Build stack
-	lua_pushinteger(state, 13);
-	lua_pushinteger(state, 37);
-	lua_pushnumber(state, 42);
+	Push(state, 13);
+	Push(state, 37);
+	Push(state, 42.2);
 
 	// Each value can be retrieved individually.
 	std::cout << "a = " << Value<int>::Read(state, 1) << std::endl;

+ 1 - 2
examples/usertypes.cpp

@@ -52,8 +52,7 @@ int main() {
 	// What's left, is registering a constructor for our type.
 	// We have to specify which parameters our constructor takes, because there might be more than
 	// one constructor to deal with.
-	auto wrapped_ctor = WrapConstructor<Point, double, double>;
-	lua_pushcfunction(state, wrapped_ctor);
+	Push(state, WrapConstructor<Point, double, double>);
 	lua_setglobal(state, "Point");
 
 	// Invoke the attached script