| 13 | }; |
| 14 | |
| 15 | int main() { |
| 16 | sol::state lua; |
| 17 | lua.open_libraries(sol::lib::base); |
| 18 | |
| 19 | lua.new_usertype<Vector>("Vector", |
| 20 | sol::constructors<Vector(), Vector(int, int)>(), |
| 21 | "x", |
| 22 | sol::property(&Vector::x, &Vector::x), |
| 23 | "y", |
| 24 | sol::property(&Vector::y, &Vector::y)); |
| 25 | |
| 26 | lua.script( |
| 27 | "vectors = { Vector.new(3, 6), Vector.new(6, 3) }"); |
| 28 | auto vectors = lua["vectors"].get<std::vector<Vector>>(); |
| 29 | |
| 30 | SOL_ASSERT(vectors[0].x == 3); |
| 31 | SOL_ASSERT(vectors[0].y == 6); |
| 32 | |
| 33 | SOL_ASSERT(vectors[1].x == 6); |
| 34 | SOL_ASSERT(vectors[1].y == 3); |
| 35 | |
| 36 | return 0; |
| 37 | } |
nothing calls this directly
no test coverage detected