You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

55 lines
1.6 KiB

  1. /*
  2. Minetest
  3. Copyright (C) 2018 nerzhul, Loic Blot <loic.blot@unix-experience.fr>
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU Lesser General Public License as published by
  6. the Free Software Foundation; either version 2.1 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public License along
  13. with this program; if not, write to the Free Software Foundation, Inc.,
  14. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. */
  16. #pragma once
  17. extern "C" {
  18. #include <lua.h>
  19. #include <lauxlib.h>
  20. }
  21. class LuaHelper
  22. {
  23. protected:
  24. static bool isNaN(lua_State *L, int idx);
  25. /**
  26. * Read a value using a template type T from Lua State L and index
  27. *
  28. *
  29. * @tparam T type to read from Lua
  30. * @param L Lua state
  31. * @param index Lua Index to read
  32. * @return read value from Lua
  33. */
  34. template <typename T> static T readParam(lua_State *L, int index);
  35. /**
  36. * Read a value using a template type T from Lua State L and index
  37. *
  38. * @tparam T type to read from Lua
  39. * @param L Lua state
  40. * @param index Lua Index to read
  41. * @param default_value default value to apply if nil
  42. * @return read value from Lua or default value if nil
  43. */
  44. template <typename T>
  45. static T readParam(lua_State *L, int index, const T &default_value);
  46. };