Vector2f.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #pragma once
  2. /*
  3. Declares Vector2f in the Lua global namespace. It implements the below (examples using Lua syntax) :
  4. Vector2f(float,float) creates a new Vector2f, and gets deleted when Lua garbage collects
  5. everything after this will assume that you have a local variable named 'vect', declared something similar to
  6. local vect = Vector2f(3.5,2.3)
  7. operators (the types that it can operate on are on the right):
  8. vect * float
  9. vect / float
  10. vect + Vector2f
  11. vect - Vector2f
  12. vect == Vector2f
  13. methods:
  14. float var = vect:DotProduct(Vector2f)
  15. Vector2f var = vect:Normalise()
  16. Vector2f var = vect:Rotate(float)
  17. get and set attributes:
  18. vect.x
  19. vect.y
  20. get attributes:
  21. vect.magnitude
  22. */
  23. #include "lua.hpp"
  24. #include "LuaType.h"
  25. #include <Rocket/Core/Types.h>
  26. namespace Rocket {
  27. namespace Core {
  28. namespace Lua {
  29. template<> void LuaType<Vector2f>::extra_init(lua_State* L, int metatable_index);
  30. int Vector2f__call(lua_State* L);
  31. int Vector2f__mul(lua_State* L);
  32. int Vector2f__div(lua_State* L);
  33. int Vector2f__add(lua_State* L);
  34. int Vector2f__sub(lua_State* L);
  35. int Vector2f__eq(lua_State* L);
  36. int Vector2fDotProduct(lua_State* L, Vector2f* obj);
  37. int Vector2fNormalise(lua_State* L, Vector2f* obj);
  38. int Vector2fRotate(lua_State* L, Vector2f* obj);
  39. int Vector2fGetAttrx(lua_State*L);
  40. int Vector2fGetAttry(lua_State*L);
  41. int Vector2fGetAttrmagnitude(lua_State*L);
  42. int Vector2fSetAttrx(lua_State*L);
  43. int Vector2fSetAttry(lua_State*L);
  44. RegType<Vector2f> Vector2fMethods[];
  45. luaL_reg Vector2fGetters[];
  46. luaL_reg Vector2fSetters[];
  47. template<> const char* GetTClassName<Vector2f>();
  48. template<> RegType<Vector2f>* GetMethodTable<Vector2f>();
  49. template<> luaL_reg* GetAttrTable<Vector2f>();
  50. template<> luaL_reg* SetAttrTable<Vector2f>();
  51. }
  52. }
  53. }