LuaStack.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. namespace crown
  27. {
  28. class Vec2;
  29. class Vec3;
  30. class Mat4;
  31. class Quat;
  32. class LuaStack
  33. {
  34. public:
  35. LuaStack(lua_State* L);
  36. lua_State* state();
  37. void push_bool(bool value);
  38. void push_int32(int32_t value);
  39. void push_uint32(uint32_t value);
  40. void push_int64(int64_t value);
  41. void push_uint64(uint64_t value);
  42. void push_float(float value);
  43. void push_string(const char* str, size_t len);
  44. void push_lightdata(void* data);
  45. void push_vec2(const Vec2& v);
  46. void push_vec3(const Vec3& v);
  47. void push_mat4(const Mat4& m);
  48. void push_quat(const Quat& q);
  49. bool get_bool(int32_t index);
  50. int32_t get_int(int32_t index);
  51. float get_float(int32_t index);
  52. const char* get_string(int32_t index);
  53. void* get_lightdata(int32_t index);
  54. Vec2& get_vec2(int32_t index);
  55. Vec3& get_vec3(int32_t index);
  56. Mat4& get_mat4(int32_t index);
  57. Quat& get_quat(int32_t index);
  58. private:
  59. lua_State* m_state;
  60. };
  61. } // namespace crown