Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade libsol2 v2.20.6 #5887

Merged
merged 17 commits into from
Dec 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 9 additions & 9 deletions features/testbot/nil.feature
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
@routing @testbot @nil
Feature: Testbot - Check assigning nil values
Scenario: Assign nil values to all way strings
Feature: Testbot - Check assigning empty values
Scenario: Assign empty values to all way strings
Given the profile file
"""
functions = require('testbot')

function way_function(profile, way, result)
result.name = nil
result.ref = nil
result.destinations = nil
result.exits = nil
result.pronunciation = nil
result.turn_lanes_forward = nil
result.turn_lanes_backward = nil
result.name = ""
result.ref = ""
result.destinations = ""
result.exits = ""
result.pronunciation = ""
result.turn_lanes_forward = ""
result.turn_lanes_backward = ""

result.forward_speed = 10
result.backward_speed = 10
Expand Down
2 changes: 1 addition & 1 deletion include/engine/datafacade_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ template <template <typename A> class FacadeT, typename AlgorithmT> class DataFa
"The exclude prefix needs to be a valid data path.");
std::size_t index =
std::stoi(exclude_prefix.substr(index_begin + 1, exclude_prefix.size()));
BOOST_ASSERT(index >= 0 && index < facades.size());
BOOST_ASSERT(index < facades.size());
facades[index] = std::make_shared<const Facade>(allocator, metric_name, index);
}

Expand Down
20 changes: 10 additions & 10 deletions include/extractor/extraction_turn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ struct ExtractionTurnLeg
{
}

const bool is_restricted;
const bool is_motorway;
const bool is_link;
const int number_of_lanes;
const int highway_turn_classification;
const int access_turn_classification;
const int speed;
const RoadPriorityClass::Enum priority_class;
const bool is_incoming;
const bool is_outgoing;
bool is_restricted;
bool is_motorway;
bool is_link;
int number_of_lanes;
int highway_turn_classification;
int access_turn_classification;
int speed;
RoadPriorityClass::Enum priority_class;
bool is_incoming;
bool is_outgoing;
};

struct ExtractionTurn
Expand Down
2 changes: 1 addition & 1 deletion include/extractor/scripting_environment_lua.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <mutex>
#include <string>

#include <sol2/sol.hpp>
#include <sol.hpp>

namespace osrm
{
Expand Down
2 changes: 1 addition & 1 deletion profiles/lib/measure.lua
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function Measure.get_max_height(raw_value, element)
if raw_value then
if height_non_numerical_values[raw_value] then
if element then
return element:get_location_tag('maxheight') or default_maxheight
return tonumber(element:get_location_tag('maxheight')) or default_maxheight
else
return default_maxheight
end
Expand Down
16 changes: 12 additions & 4 deletions src/extractor/scripting_environment_lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct to_lua_object : public boost::static_visitor<sol::object>
{
to_lua_object(sol::state &state) : state(state) {}
template <typename T> auto operator()(T &v) const { return sol::make_object(state, v); }
auto operator()(boost::blank &) const { return sol::nil; }
auto operator()(boost::blank &) const { return sol::lua_nil; }
sol::state &state;
};
} // namespace
Expand Down Expand Up @@ -236,7 +236,7 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)

auto get_location_tag = [](auto &context, const auto &location, const char *key) {
if (context.location_dependent_data.empty())
return sol::object(sol::nil);
return sol::object(context.state);

const LocationDependentData::point_t point{location.lon(), location.lat()};
if (!boost::geometry::equals(context.last_location_point, point))
Expand All @@ -259,7 +259,7 @@ void Sol2ScriptingEnvironment::InitContext(LuaScriptingContext &context)
"version",
&osmium::Way::version,
"get_nodes",
[](const osmium::Way &way) { return sol::as_table(way.nodes()); },
[](const osmium::Way &way) { return sol::as_table(&way.nodes()); },
"get_location_tag",
[&context, &get_location_tag](const osmium::Way &way, const char *key) {
// HEURISTIC: use a single node (last) of the way to localize the way
Expand Down Expand Up @@ -927,7 +927,7 @@ std::vector<std::string>
Sol2ScriptingEnvironment::GetStringListFromFunction(const std::string &function_name)
{
auto &context = GetSol2Context();
BOOST_ASSERT(context.state.lua_state() != nullptr);
BOOST_ASSERT(context.state.lua_state());
std::vector<std::string> strings;
sol::function function = context.state[function_name];
if (function.valid())
Expand All @@ -943,6 +943,10 @@ Sol2ScriptingEnvironment::GetStringListFromTable(const std::string &table_name)
auto &context = GetSol2Context();
BOOST_ASSERT(context.state.lua_state() != nullptr);
std::vector<std::string> strings;
if (!context.profile_table[table_name])
{
return strings;
}
sol::table table = context.profile_table[table_name];
if (table.valid())
{
Expand All @@ -961,6 +965,10 @@ Sol2ScriptingEnvironment::GetStringListsFromTable(const std::string &table_name)

auto &context = GetSol2Context();
BOOST_ASSERT(context.state.lua_state() != nullptr);
if (!context.profile_table[table_name])
{
return string_lists;
}
sol::table table = context.profile_table[table_name];
if (!table.valid())
{
Expand Down
110 changes: 110 additions & 0 deletions third_party/sol2/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# # # # sol2
# The MIT License (MIT)
#
# Copyright (c) 2013-2018 Rapptz, ThePhD, and contributors
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---
BasedOnStyle: WebKit
IndentWidth: 5
TabWidth: 5
ContinuationIndentWidth: 5
UseTab: Always

# Namespaces
NamespaceIndentation: All
CompactNamespaces: true
FixNamespaceComments: true

# Overall Alignment
ColumnLimit: 0
AlignAfterOpenBracket: DontAlign # uses ContinuationIndentWidth for this instead
AccessModifierOffset: -5 # do not push public: or private: around
#AlignConsecutiveAssignments: true # affects more than what's expected: do not use
#AlignConsecutiveDeclarations: true # affects more than what's expected: do not use

# Type Alignment
DerivePointerAlignment: false
PointerAlignment: Left
AlwaysBreakTemplateDeclarations: true
AlwaysBreakBeforeMultilineStrings: true

# Comments
AlignTrailingComments: true
ReflowComments: true

# Macros
AlignEscapedNewlines: Left
#IndentPPDirectives: None

# Functions
AllowShortFunctionsOnASingleLine: None
AlwaysBreakAfterReturnType: None
BreakConstructorInitializers: BeforeComma
ConstructorInitializerIndentWidth: 0
ConstructorInitializerAllOnOneLineOrOnePerLine: true
BinPackArguments: true
BinPackParameters: true

# Classes
BreakBeforeInheritanceComma: false

# Braces
Cpp11BracedListStyle: false
BreakBeforeBraces: Custom
BraceWrapping:
AfterEnum: false
AfterStruct: false
AfterControlStatement: false
AfterClass: false
AfterNamespace: false
AfterStruct: false
AfterUnion: false
BeforeElse: true
BeforeCatch: true
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: true

# Control Statements
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
IndentCaseLabels: false

# Spaces
SpaceAfterCStyleCast: false
SpacesInCStyleCastParentheses: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
MaxEmptyLinesToKeep: 3

# OCD
SortUsingDeclarations: true
SortIncludes: false

---
Language: Cpp
Standard: Cpp11
27 changes: 27 additions & 0 deletions third_party/sol2/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# # # # sol2
# The MIT License (MIT)
#
# Copyright (c) 2013-2018 Rapptz, ThePhD, and contributors
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

# Ignore literally everything
**

# Except the script directory
!scripts/preparation*
14 changes: 14 additions & 0 deletions third_party/sol2/.github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Read these guidelines. They are relatively simple and will allow me to help you better:

1. Produce a simple, short, compilable test case that reproduces your problem.
2. Make a descriptive title that summarises the bug as a whole.
3. Explain the bug in as much detail as you can in the body of the issue.
4. Include Compiler/IDE (Visual Studio, XCode...), Build and Deployment System, Language (C++, Objective-C++), and any special defines you have set.

If you want to request a feature:

1. Produce any relevant imaginary code that illustrates what you would like or desired behavior.
2. Include a description and title of what you would like.
3. Annotate and describe the behavior through comments, asserts or just a small write up.

Thanks for helping sol grow!
Loading