Vector2i.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * This source file is part of libRocket, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://www.librocket.com
  5. *
  6. * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. *
  26. */
  27. #ifndef ROCKETCORELUAVECTOR2I_H
  28. #define ROCKETCORELUAVECTOR2I_H
  29. /*
  30. Declares Vector2i in the Lua global namespace. It implements the below (examples using Lua syntax) :
  31. Vector2i(int,int) creates a new Vector2i, and gets deleted when Lua garbage collects
  32. everything after this will assume that you have a local variable named 'vect', declared something similar to
  33. local vect = Vector2i.new(50,90)
  34. operators (the types that it can operate on are on the right):
  35. vect * int
  36. vect / int
  37. vect + Vector2i
  38. vect - Vector2i
  39. vect == Vector2i
  40. no methods
  41. get and set attributes:
  42. vect.x
  43. vect.y
  44. */
  45. #include <Rocket/Core/Lua/lua.hpp>
  46. #include <Rocket/Core/Lua/LuaType.h>
  47. #include <Rocket/Core/Types.h>
  48. using Rocket::Core::Vector2i;
  49. namespace Rocket {
  50. namespace Core {
  51. namespace Lua {
  52. template<> void ExtraInit<Vector2i>(lua_State* L, int metatable_index);
  53. int Vector2inew(lua_State* L);
  54. int Vector2i__mul(lua_State* L);
  55. int Vector2i__div(lua_State* L);
  56. int Vector2i__add(lua_State* L);
  57. int Vector2i__sub(lua_State* L);
  58. int Vector2i__eq(lua_State* L);
  59. //getters
  60. int Vector2iGetAttrx(lua_State*L);
  61. int Vector2iGetAttry(lua_State*L);
  62. int Vector2iGetAttrmagnitude(lua_State*L);
  63. //setters
  64. int Vector2iSetAttrx(lua_State*L);
  65. int Vector2iSetAttry(lua_State*L);
  66. RegType<Vector2i> Vector2iMethods[];
  67. luaL_reg Vector2iGetters[];
  68. luaL_reg Vector2iSetters[];
  69. LUATYPEDECLARE(Vector2i)
  70. }
  71. }
  72. }
  73. #endif