Colourf.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #pragma once
  2. /*
  3. Declares Colourf in the Lua global namespace. It implements the below (examples using Lua syntax) :
  4. Colourf(float red,float green,float blue,float alpha) creates a new Colourf (values must be bounded between 0 and 1 inclusive),
  5. and gets deleted when Lua garbage collects
  6. everything after this will assume that you have a local variable named 'col', declared something similar to
  7. local col = Colourf(0.1,0.5,0.25,1.0)
  8. operators (the types that it can operate on are on the right):
  9. col == Colourf
  10. no methods
  11. get and set attributes:
  12. col.red
  13. col.green
  14. col.blue
  15. col.alpha
  16. get attributes:
  17. local red,green,blue,alpha = col.rgba
  18. */
  19. #include "lua.hpp"
  20. #include "LuaType.h"
  21. #include <Rocket/Core/Types.h>
  22. using Rocket::Core::Colourf;
  23. namespace Rocket {
  24. namespace Core {
  25. namespace Lua {
  26. template<> void LuaType<Colourf>::extra_init(lua_State* L, int metatable_index);
  27. //metamethods
  28. int Colourfnew(lua_State* L);
  29. int Colourf__eq(lua_State* L);
  30. //getters
  31. int ColourfGetAttrred(lua_State* L);
  32. int ColourfGetAttrgreen(lua_State* L);
  33. int ColourfGetAttrblue(lua_State* L);
  34. int ColourfGetAttralpha(lua_State* L);
  35. int ColourfGetAttrrgba(lua_State* L);
  36. //setters
  37. int ColourfSetAttrred(lua_State* L);
  38. int ColourfSetAttrgreen(lua_State* L);
  39. int ColourfSetAttrblue(lua_State* L);
  40. int ColourfSetAttralpha(lua_State* L);
  41. RegType<Colourf> ColourfMethods[];
  42. luaL_reg ColourfGetters[];
  43. luaL_reg ColourfSetters[];
  44. /*
  45. template<> const char* GetTClassName<Colourf>() { return "Colourf"; }
  46. template<> RegType<Colourf>* GetMethodTable<Colourf>() { return ColourfMethods; }
  47. template<> luaL_reg* GetAttrTable<Colourf>() { return ColourfGetters; }
  48. template<> luaL_reg* SetAttrTable<Colourf>() { return ColourfSetters; }
  49. */
  50. }
  51. }
  52. }