main.c 445 B

12345678910111213141516171819202122232425262728
  1. #include "luashim.h"
  2. static int example_test(lua_State* L)
  3. {
  4. lua_pushstring(L, "hello ");
  5. lua_pushvalue(L, 1);
  6. lua_concat(L, 2);
  7. return 1;
  8. }
  9. static const luaL_Reg example_functions[] = {
  10. { "test", example_test },
  11. { NULL, NULL }
  12. };
  13. #ifdef _WIN32
  14. __declspec(dllexport) int luaopen_example(lua_State *L)
  15. #else
  16. int luaopen_example(lua_State *L)
  17. #endif
  18. {
  19. shimInitialize(L);
  20. luaL_register(L, "example", example_functions);
  21. return 0;
  22. }