| 26 | } |
| 27 | |
| 28 | int main(int, char*[]) { |
| 29 | std::cout << "=== calling lua functions ===" << std::endl; |
| 30 | |
| 31 | sol::state lua; |
| 32 | lua.open_libraries(); |
| 33 | |
| 34 | sol::table mLuaPackets |
| 35 | = lua.create_named_table("mLuaPackets"); |
| 36 | mLuaPackets[1] = lua.create_table_with("timestamp", 0LL); |
| 37 | mLuaPackets[2] = lua.create_table_with("timestamp", 3LL); |
| 38 | mLuaPackets[3] = lua.create_table_with("timestamp", 1LL); |
| 39 | |
| 40 | lua.script("print('--- pre sort ---')"); |
| 41 | lua.script( |
| 42 | "for i=1,#mLuaPackets do print(i, " |
| 43 | "mLuaPackets[i].timestamp) end"); |
| 44 | |
| 45 | lua["table"]["sort"](mLuaPackets, |
| 46 | sol::as_function([](sol::table l, sol::table r) { |
| 47 | std::uint64_t tl = l["timestamp"]; |
| 48 | std::uint64_t tr = r["timestamp"]; |
| 49 | return tl < tr; |
| 50 | })); |
| 51 | |
| 52 | lua.script("print('--- post sort ---')"); |
| 53 | lua.script( |
| 54 | "for i=1,#mLuaPackets do print(i, " |
| 55 | "mLuaPackets[i].timestamp) end"); |
| 56 | |
| 57 | return 0; |
| 58 | } |
nothing calls this directly
no test coverage detected