Skip to content

Commit b6a21c2

Browse files
Fix bug with reading Set values from Lua scripts.
1 parent 3d2db20 commit b6a21c2

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
- API:
44
- FIXED: Fix inefficient osrm-routed connection handling [#6113](https://github.com/Project-OSRM/osrm-backend/pull/6113)
55
- Build:
6-
- CHANGED: Enable more clang-tidy checks. [#6262](https://github.com/Project-OSRM/osrm-backend/pull/6270)
6+
- CHANGED: Fix bug with reading Set values from Lua scripts. [#6279](https://github.com/Project-OSRM/osrm-backend/pull/6279)
7+
- CHANGED: Enable even more clang-tidy checks. [#6273](https://github.com/Project-OSRM/osrm-backend/pull/6273)
8+
- CHANGED: Configure CMake to not build flatbuffers tests and samples. [#6274](https://github.com/Project-OSRM/osrm-backend/pull/6274)
9+
- CHANGED: Enable more clang-tidy checks. [#6270](https://github.com/Project-OSRM/osrm-backend/pull/6270)
710
- CHANGED: Configure clang-tidy job on CI. [#6261](https://github.com/Project-OSRM/osrm-backend/pull/6261)
811
- CHANGED: Use Github Actions for building container images [#6138](https://github.com/Project-OSRM/osrm-backend/pull/6138)
912
- CHANGED: Upgrade Boost dependency to 1.70 [#6113](https://github.com/Project-OSRM/osrm-backend/pull/6113)

features/foot/restrictions.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Feature: Foot - Turn restrictions
2929
When I route I should get
3030
| from | to | route |
3131
| s | w | sj,wj,wj |
32-
| s | n | sj,nj,nj |
32+
| s | n | sj,nj |
3333
| s | e | sj,ej,ej |
3434

3535
@only_turning
@@ -55,7 +55,7 @@ Feature: Foot - Turn restrictions
5555
When I route I should get
5656
| from | to | route |
5757
| s | w | sj,wj,wj |
58-
| s | n | sj,nj,nj |
58+
| s | n | sj,nj |
5959
| s | e | sj,ej,ej |
6060

6161
@except

src/extractor/scripting_environment_lua.cpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,26 @@ Sol2ScriptingEnvironment::GetStringListFromFunction(const std::string &function_
939939
return strings;
940940
}
941941

942+
namespace
943+
{
944+
945+
// string list can be defined either as a Set(see profiles/lua/set.lua) or as a Sequence (see
946+
// profiles/lua/sequence.lua) `Set` is a table with keys that are actual values we are looking for
947+
// and values that always `true`. `Sequence` is a table with keys that are indices and values that
948+
// are actual values we are looking for.
949+
950+
std::string GetSetOrSequenceValue(const std::pair<sol::object, sol::object> &pair)
951+
{
952+
if (pair.second.is<std::string>())
953+
{
954+
return pair.second.as<std::string>();
955+
}
956+
BOOST_ASSERT(pair.first.is<std::string>());
957+
return pair.first.as<std::string>();
958+
}
959+
960+
} // namespace
961+
942962
std::vector<std::string>
943963
Sol2ScriptingEnvironment::GetStringListFromTable(const std::string &table_name)
944964
{
@@ -954,7 +974,7 @@ Sol2ScriptingEnvironment::GetStringListFromTable(const std::string &table_name)
954974
{
955975
for (auto &&pair : table)
956976
{
957-
strings.push_back(pair.second.as<std::string>());
977+
strings.emplace_back(GetSetOrSequenceValue(pair));
958978
}
959979
}
960980
return strings;
@@ -989,7 +1009,7 @@ Sol2ScriptingEnvironment::GetStringListsFromTable(const std::string &table_name)
9891009
std::vector<std::string> inner_vector;
9901010
for (const auto &inner_pair : inner_table)
9911011
{
992-
inner_vector.push_back(inner_pair.first.as<std::string>());
1012+
inner_vector.emplace_back(GetSetOrSequenceValue(inner_pair));
9931013
}
9941014
string_lists.push_back(std::move(inner_vector));
9951015
}

0 commit comments

Comments
 (0)