LuaEnvironment.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. Copyright (c) 2013 Daniele Bartolini, Michele Rossi
  3. Copyright (c) 2012 Daniele Bartolini, Simone Boscaratto
  4. Permission is hereby granted, free of charge, to any person
  5. obtaining a copy of this software and associated documentation
  6. files (the "Software"), to deal in the Software without
  7. restriction, including without limitation the rights to use,
  8. copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the
  10. Software is furnished to do so, subject to the following
  11. conditions:
  12. The above copyright notice and this permission notice shall be
  13. included in all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  16. OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  18. HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  19. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  21. OTHER DEALINGS IN THE SOFTWARE.
  22. */
  23. #pragma once
  24. #include "lua.hpp"
  25. #include "Types.h"
  26. #include "Config.h"
  27. namespace crown
  28. {
  29. class LuaEnvironment
  30. {
  31. public:
  32. /// Constructor
  33. LuaEnvironment(lua_State* L);
  34. /// Load a function to proper module
  35. void load_module_function(const char* module, const char* name, const lua_CFunction func);
  36. void load_module_enum(const char* module, const char* name, uint32_t value);
  37. /// Create library based on each module which will be opened by luaopen_*
  38. void create_module_library();
  39. private:
  40. lua_State* m_state;
  41. };
  42. void load_int_setting(LuaEnvironment& env);
  43. void load_float_setting(LuaEnvironment& env);
  44. void load_string_setting(LuaEnvironment& env);
  45. void load_vec2(LuaEnvironment& env);
  46. void load_vec3(LuaEnvironment& env);
  47. void load_mat4(LuaEnvironment& env);
  48. void load_quat(LuaEnvironment& env);
  49. void load_math(LuaEnvironment& env);
  50. void load_mouse(LuaEnvironment& env);
  51. void load_keyboard(LuaEnvironment& env);
  52. void load_touch(LuaEnvironment& env);
  53. void load_accelerometer(LuaEnvironment& env);
  54. void load_camera(LuaEnvironment& env);
  55. void load_device(LuaEnvironment& env);
  56. void load_window(LuaEnvironment& env);
  57. CE_EXPORT int32_t luaopen_libcrown(lua_State* L);
  58. } // namespace crown