Vector2i.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef ROCKETCORELUAVECTOR2I_H
  2. #define ROCKETCORELUAVECTOR2I_H
  3. /*
  4. Declares Vector2i in the Lua global namespace. It implements the below (examples using Lua syntax) :
  5. Vector2i(int,int) creates a new Vector2i, and gets deleted when Lua garbage collects
  6. everything after this will assume that you have a local variable named 'vect', declared something similar to
  7. local vect = Vector2i.new(50,90)
  8. operators (the types that it can operate on are on the right):
  9. vect * int
  10. vect / int
  11. vect + Vector2i
  12. vect - Vector2i
  13. vect == Vector2i
  14. no methods
  15. get and set attributes:
  16. vect.x
  17. vect.y
  18. */
  19. #include <Rocket/Core/Lua/lua.hpp>
  20. #include <Rocket/Core/Lua/LuaType.h>
  21. #include <Rocket/Core/Types.h>
  22. using Rocket::Core::Vector2i;
  23. namespace Rocket {
  24. namespace Core {
  25. namespace Lua {
  26. template<> void LuaType<Vector2i>::extra_init(lua_State* L, int metatable_index);
  27. int Vector2inew(lua_State* L);
  28. int Vector2i__mul(lua_State* L);
  29. int Vector2i__div(lua_State* L);
  30. int Vector2i__add(lua_State* L);
  31. int Vector2i__sub(lua_State* L);
  32. int Vector2i__eq(lua_State* L);
  33. //getters
  34. int Vector2iGetAttrx(lua_State*L);
  35. int Vector2iGetAttry(lua_State*L);
  36. int Vector2iGetAttrmagnitude(lua_State*L);
  37. //setters
  38. int Vector2iSetAttrx(lua_State*L);
  39. int Vector2iSetAttry(lua_State*L);
  40. RegType<Vector2i> Vector2iMethods[];
  41. luaL_reg Vector2iGetters[];
  42. luaL_reg Vector2iSetters[];
  43. /*
  44. template<> const char* GetTClassName<Vector2i>() { return "Vector2i"; }
  45. template<> RegType<Vector2i>* GetMethodTable<Vector2i>() { return Vector2iMethods; }
  46. template<> luaL_reg* GetAttrTable<Vector2i>() { return Vector2iGetters; }
  47. template<> luaL_reg* SetAttrTable<Vector2i>() { return Vector2iSetters; }
  48. */
  49. }
  50. }
  51. }
  52. #endif