1+ #include " lpoplib.hpp"
2+ #include " math/rect.hpp"
3+
4+ using namespace PopLib ;
5+
6+ void open_rect (sol::state_view lua)
7+ {
8+ sol::table poplib;
9+ if (lua[" PopLib" ].valid () && lua[" PopLib" ].get_type () == sol::type::table)
10+ {
11+ poplib = lua[" PopLib" ];
12+ }
13+ else
14+ {
15+ poplib = lua.create_table ();
16+ lua[" PopLib" ] = poplib;
17+ }
18+
19+ poplib.new_usertype <PopLib::Rect>(
20+ " Rect" ,
21+ sol::constructors<PopLib::Rect (), PopLib::Rect (int , int , int , int ), PopLib::Rect (const PopLib::Rect &)>(), " mX" ,
22+ &PopLib::Rect::mX , " mY" , &PopLib::Rect::mY , " mWidth" , &PopLib::Rect::mWidth , " mHeight" , &PopLib::Rect::mHeight ,
23+
24+ " Intersects" , &PopLib::Rect::Intersects, " Intersection" , &PopLib::Rect::Intersection, " Union" ,
25+ static_cast <PopLib::Rect (PopLib::Rect::*)(const PopLib::Rect &)>(&PopLib::Rect::Union), " Contains" ,
26+ sol::overload (static_cast <bool (PopLib::Rect::*)(int , int ) const >(&PopLib::Rect::Contains),
27+ static_cast <bool (PopLib::Rect::*)(const PopLib::TPoint<int > &) const >(&PopLib::Rect::Contains)),
28+ " Offset" ,
29+ sol::overload (static_cast <void (PopLib::Rect::*)(int , int )>(&PopLib::Rect::Offset),
30+ static_cast <void (PopLib::Rect::*)(const PopLib::TPoint<int > &)>(&PopLib::Rect::Offset)),
31+ " Inflate" , &PopLib::Rect::Inflate, sol::meta_function::to_string,
32+ [](const PopLib::Rect &r) {
33+ return " Rect(" + std::to_string (r.mX ) + " ," + std::to_string (r.mY ) + " ," + std::to_string (r.mWidth ) + " ," +
34+ std::to_string (r.mHeight ) + " )" ;
35+ },
36+ sol::meta_function::equal_to, &PopLib::Rect::operator ==);
37+
38+ poplib.new_usertype <PopLib::FRect>(
39+ " FRect" ,
40+ sol::constructors<PopLib::FRect (), PopLib::FRect (double , double , double , double ),
41+ PopLib::FRect (const PopLib::FRect &)>(),
42+ " mX" , &PopLib::FRect::mX , " mY" , &PopLib::FRect::mY , " mWidth" , &PopLib::FRect::mWidth , " mHeight" ,
43+ &PopLib::FRect::mHeight ,
44+
45+ " Intersects" , &PopLib::FRect::Intersects, " Intersection" , &PopLib::FRect::Intersection, " Union" ,
46+ static_cast <PopLib::FRect (PopLib::FRect::*)(const PopLib::FRect &)>(&PopLib::FRect::Union), " Contains" ,
47+ sol::overload (
48+ static_cast <bool (PopLib::FRect::*)(double , double ) const >(&PopLib::FRect::Contains),
49+ static_cast <bool (PopLib::FRect::*)(const PopLib::TPoint<double > &) const >(&PopLib::FRect::Contains)),
50+ " Offset" ,
51+ sol::overload (static_cast <void (PopLib::FRect::*)(double , double )>(&PopLib::FRect::Offset),
52+ static_cast <void (PopLib::FRect::*)(const PopLib::TPoint<double > &)>(&PopLib::FRect::Offset)),
53+ " Inflate" , &PopLib::FRect::Inflate, sol::meta_function::to_string,
54+ [](const PopLib::FRect &r) {
55+ return " FRect(" + std::to_string (r.mX ) + " ," + std::to_string (r.mY ) + " ," + std::to_string (r.mWidth ) + " ," +
56+ std::to_string (r.mHeight ) + " )" ;
57+ },
58+ sol::meta_function::equal_to, &PopLib::FRect::operator ==);
59+ }
0 commit comments