Skip to content

Commit

Permalink
Migrate to C++17. Update sol2 to 3.3.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
SiarheiFedartsou committed Jul 9, 2022
1 parent 19d2ec5 commit 7be8e4d
Show file tree
Hide file tree
Showing 413 changed files with 30,280 additions and 386,659 deletions.
1 change: 0 additions & 1 deletion .github/workflows/osrm-backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ jobs:
- name: Run checks
run: |
./scripts/check_taginfo.py taginfo.json profiles/car.lua
./scripts/format.sh && ./scripts/error_on_dirty.sh
node ./scripts/validate_changelog.js
npm run docs && ./scripts/error_on_dirty.sh
Expand Down
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
cmake_minimum_required(VERSION 3.2)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR AND NOT MSVC_IDE)
message(FATAL_ERROR "In-source builds are not allowed.
Please create a directory and run cmake from there, passing the path to this source directory as the last argument.
Expand Down Expand Up @@ -145,7 +148,7 @@ endif()

include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/include/)
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/include/)
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/third_party/sol2/)
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/third_party/sol2-3.3.0/include)
include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/third_party/variant/include)

set(BOOST_COMPONENTS date_time chrono filesystem iostreams program_options regex system thread unit_test_framework)
Expand Down Expand Up @@ -413,8 +416,8 @@ set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${LINKER_FLAGS}")

# Activate C++1y
if(NOT CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set(OSRM_CXXFLAGS "${OSRM_CXXFLAGS} -std=c++14")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(OSRM_CXXFLAGS "${OSRM_CXXFLAGS} -std=c++17")
endif()

# Configuring other platform dependencies
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 <sol.hpp>
#include <sol/sol.hpp>

namespace osrm
{
Expand Down
20 changes: 6 additions & 14 deletions src/extractor/scripting_environment_lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,10 +945,6 @@ 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 @@ -967,10 +963,6 @@ 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 Expand Up @@ -1171,14 +1163,14 @@ void LuaScriptingContext::ProcessNode(const osmium::Node &node,
{
case 4:
case 3:
node_function(profile_table, node, result, relations);
node_function(profile_table, std::cref(node), result, relations);
break;
case 2:
node_function(profile_table, node, result);
node_function(profile_table, std::cref(node), result);
break;
case 1:
case 0:
node_function(node, result);
node_function(std::cref(node), result);
break;
}
}
Expand All @@ -1193,14 +1185,14 @@ void LuaScriptingContext::ProcessWay(const osmium::Way &way,
{
case 4:
case 3:
way_function(profile_table, way, result, relations);
way_function(profile_table, std::cref(way), std::ref(result), std::cref(relations));
break;
case 2:
way_function(profile_table, way, result);
way_function(profile_table, std::cref(way), std::ref(result));
break;
case 1:
case 0:
way_function(way, result);
way_function(std::cref(way), std::ref(result));
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// sol2

// The MIT License (MIT)

// Copyright (c) 2013-2018 Rapptz, ThePhD and contributors
// Copyright (c) 2013-2020 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
Expand All @@ -21,34 +19,35 @@
// 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.

#ifndef SOL_PROTECT_HPP
#define SOL_PROTECT_HPP
// This file was generated with a script.
// Generated 2022-06-25 08:14:19.336233 UTC
// This header was generated with sol v3.3.0 (revision eba86625)
// https://github.com/ThePhD/sol2

#ifndef SOL_SINGLE_CONFIG_HPP
#define SOL_SINGLE_CONFIG_HPP

// beginning of sol/config.hpp

/* Base, empty configuration file!
#include "traits.hpp"
#include <utility>
To override, place a file in your include paths of the form:
namespace sol {
. (your include path here)
| sol (directory, or equivalent)
| config.hpp (your config.hpp file)
template <typename T>
struct protect_t {
T value;
So that when sol2 includes the file
template <typename Arg, typename... Args, meta::disable<std::is_same<protect_t, meta::unqualified_t<Arg>>> = meta::enabler>
protect_t(Arg&& arg, Args&&... args)
: value(std::forward<Arg>(arg), std::forward<Args>(args)...) {
}
#include <sol/config.hpp>
protect_t(const protect_t&) = default;
protect_t(protect_t&&) = default;
protect_t& operator=(const protect_t&) = default;
protect_t& operator=(protect_t&&) = default;
};
it gives you the configuration values you desire. Configuration values can be
seen in the safety.rst of the doc/src, or at
https://sol2.readthedocs.io/en/latest/safety.html ! You can also pass them through
the build system, or the command line options of your compiler.
template <typename T>
auto protect(T&& value) {
return protect_t<std::decay_t<T>>(std::forward<T>(value));
}
*/

} // namespace sol
// end of sol/config.hpp

#endif // SOL_PROTECT_HPP
#endif // SOL_SINGLE_CONFIG_HPP
Loading

0 comments on commit 7be8e4d

Please sign in to comment.