Vector2f.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 <Rocket/Core/Lua/lua.hpp>
  24. #include <Rocket/Core/Lua/LuaType.h>
  25. #include <Rocket/Core/Types.h>
  26. using Rocket::Core::Vector2f;
  27. namespace Rocket {
  28. namespace Core {
  29. namespace Lua {
  30. template<> void LuaType<Vector2f>::extra_init(lua_State* L, int metatable_index);
  31. int Vector2fnew(lua_State* L);
  32. int Vector2f__mul(lua_State* L);
  33. int Vector2f__div(lua_State* L);
  34. int Vector2f__add(lua_State* L);
  35. int Vector2f__sub(lua_State* L);
  36. int Vector2f__eq(lua_State* L);
  37. int Vector2fDotProduct(lua_State* L, Vector2f* obj);
  38. int Vector2fNormalise(lua_State* L, Vector2f* obj);
  39. int Vector2fRotate(lua_State* L, Vector2f* obj);
  40. int Vector2fGetAttrx(lua_State*L);
  41. int Vector2fGetAttry(lua_State*L);
  42. int Vector2fGetAttrmagnitude(lua_State*L);
  43. int Vector2fSetAttrx(lua_State*L);
  44. int Vector2fSetAttry(lua_State*L);
  45. RegType<Vector2f> Vector2fMethods[];
  46. luaL_reg Vector2fGetters[];
  47. luaL_reg Vector2fSetters[];
  48. /*
  49. template<> const char* GetTClassName<Vector2f>() { return "Vector2f"; }
  50. template<> RegType<Vector2f>* GetMethodTable<Vector2f>() { return Vector2fMethods; }
  51. template<> luaL_reg* GetAttrTable<Vector2f>() { return Vector2fGetters; }
  52. template<> luaL_reg* SetAttrTable<Vector2f>() { return Vector2fSetters; }
  53. */
  54. }
  55. }
  56. }