Unverified Commit 7b2cb2b4 authored by Dominik Charousset's avatar Dominik Charousset Committed by GitHub

Merge pull request #1295

Remove deprecated APIs and legacy workarounds
parents abd89335 e6567b42
......@@ -160,7 +160,6 @@ caf_add_component(
src/logger.cpp
src/mailbox_element.cpp
src/make_config_option.cpp
src/memory_managed.cpp
src/message.cpp
src/message_builder.cpp
src/message_handler.cpp
......
......@@ -298,10 +298,6 @@ public:
/// Returns the system-wide actor registry.
actor_registry& registry();
/// Returns a string representation for `err`.
[[deprecated("please use to_string() on the error")]] std::string
render(const error& x) const;
/// Returns the system-wide group manager.
group_manager& groups();
......@@ -574,10 +570,9 @@ public:
infer_handle_from_class_t<C> spawn_impl(actor_config& cfg, Ts&&... xs) {
static_assert(is_unbound(Os),
"top-level spawns cannot have monitor or link flag");
// TODO: use `if constexpr` when switching to C++17
if (has_detach_flag(Os) || std::is_base_of<blocking_actor, C>::value)
if constexpr (has_detach_flag(Os) || std::is_base_of_v<blocking_actor, C>)
cfg.flags |= abstract_actor::is_detached_flag;
if (has_hide_flag(Os))
if constexpr (has_hide_flag(Os))
cfg.flags |= abstract_actor::is_hidden_flag;
if (cfg.host == nullptr)
cfg.host = dummy_execution_unit();
......
......@@ -99,9 +99,6 @@ public:
/// provides a config file path on the command line.
error parse(string_list args);
[[deprecated("set the config_file_path member instead")]] error
parse(string_list args, const char* config_file_cstr);
/// Parses the CLI options `{argc, argv}` and `config` as configuration file.
error parse(int argc, char** argv, std::istream& config);
......@@ -110,9 +107,6 @@ public:
/// provides a config file path on the command line.
error parse(int argc, char** argv);
[[deprecated("set the config_file_path member instead")]] error
parse(int argc, char** argv, const char* config_file_cstr);
/// Allows other nodes to spawn actors created by `fun`
/// dynamically by using `name` as identifier.
/// @experimental
......@@ -252,11 +246,6 @@ public:
int (*slave_mode_fun)(actor_system&, const actor_system_config&);
// -- default error rendering functions --------------------------------------
[[deprecated("please use to_string() on the error")]] static std::string
render(const error& err);
// -- config file parsing ----------------------------------------------------
/// Tries to open `filename` and parses its content as CAF config file.
......
......@@ -59,7 +59,6 @@
#include "caf/logger.hpp"
#include "caf/make_config_option.hpp"
#include "caf/may_have_timeout.hpp"
#include "caf/memory_managed.hpp"
#include "caf/message.hpp"
#include "caf/message_builder.hpp"
#include "caf/message_handler.hpp"
......@@ -105,12 +104,6 @@
#include "caf/decorator/sequencer.hpp"
#include "caf/meta/annotation.hpp"
#include "caf/meta/load_callback.hpp"
#include "caf/meta/omittable_if_empty.hpp"
#include "caf/meta/save_callback.hpp"
#include "caf/meta/type_name.hpp"
#include "caf/scheduler/abstract_coordinator.hpp"
#include "caf/scheduler/test_coordinator.hpp"
......
......@@ -264,8 +264,7 @@ private:
// Don't enqueue new data into a closing path.
if (!x.second->closing) {
// Push data from the global buffer to path buffers.
// TODO: replace with `if constexpr` when switching to C++17
if (std::is_same<select_type, detail::select_all>::value) {
if constexpr (std::is_same_v<select_type, detail::select_all>) {
st.buf.insert(st.buf.end(), chunk.begin(), chunk.end());
} else {
for (auto& piece : chunk)
......
......@@ -81,11 +81,6 @@ public:
/// - Store the converted value unless this option is stateless.
error sync(config_value& x) const;
[[deprecated("use sync instead")]] error store(const config_value& x) const;
[[deprecated("use sync instead")]] expected<config_value>
parse(string_view input) const;
/// Returns a human-readable representation of this option's expected type.
string_view type_name() const noexcept;
......@@ -95,10 +90,6 @@ public:
/// Returns whether the category is optional for CLI options.
bool has_flat_cli_name() const noexcept;
/// @private
// TODO: remove with CAF 0.17
optional<config_value> get() const;
private:
string_view buf_slice(size_t from, size_t to) const noexcept;
......
......@@ -38,12 +38,6 @@ public:
config_option_adder&
add_neg(bool& ref, string_view name, string_view description);
[[deprecated("use timespan options instead")]] config_option_adder&
add_us(size_t& ref, string_view name, string_view description);
[[deprecated("use timespan options instead")]] config_option_adder&
add_ms(size_t& ref, string_view name, string_view description);
private:
// -- properties -------------------------------------------------------------
......
......@@ -560,76 +560,29 @@ auto get_or(const config_value& x, Fallback&& fallback) {
// -- SumType-like access ------------------------------------------------------
template <class T>
[[deprecated("use get_as or get_or instead")]] optional<T>
legacy_get_if(const config_value* x) {
if (auto val = get_as<T>(*x))
return {std::move(*val)};
else
return {};
}
template <class T>
template <class T, class = std::enable_if_t<detail::is_config_value_type_v<T>>>
auto get_if(const config_value* x) {
if constexpr (detail::is_config_value_type_v<T>) {
return get_if<T>(x->get_data_ptr());
} else {
return legacy_get_if<T>(x);
}
return get_if<T>(x->get_data_ptr());
}
template <class T>
template <class T, class = std::enable_if_t<detail::is_config_value_type_v<T>>>
auto get_if(config_value* x) {
if constexpr (detail::is_config_value_type_v<T>) {
return get_if<T>(x->get_data_ptr());
} else {
return legacy_get_if<T>(x);
}
}
template <class T>
[[deprecated("use get_as or get_or instead")]] T
legacy_get(const config_value& x) {
auto val = get_as<T>(x);
if (!val)
CAF_RAISE_ERROR("legacy_get: conversion failed");
return std::move(*val);
return get_if<T>(x->get_data_ptr());
}
template <class T>
template <class T, class = std::enable_if_t<detail::is_config_value_type_v<T>>>
decltype(auto) get(const config_value& x) {
if constexpr (detail::is_config_value_type_v<T>) {
return get<T>(x.get_data());
} else {
return legacy_get<T>(x);
}
return get<T>(x.get_data());
}
template <class T>
template <class T, class = std::enable_if_t<detail::is_config_value_type_v<T>>>
decltype(auto) get(config_value& x) {
if constexpr (detail::is_config_value_type_v<T>) {
return get<T>(x.get_data());
} else {
return legacy_get<T>(x);
}
return get<T>(x.get_data());
}
template <class T>
[[deprecated("use get_as or get_or instead")]] bool
legacy_holds_alternative(const config_value& x) {
if (auto val = get_as<T>(x))
return true;
else
return false;
}
template <class T>
template <class T, class = std::enable_if_t<detail::is_config_value_type_v<T>>>
auto holds_alternative(const config_value& x) {
if constexpr (detail::is_config_value_type_v<T>) {
return holds_alternative<T>(x.get_data());
} else {
return legacy_holds_alternative<T>(x);
}
return holds_alternative<T>(x.get_data());
}
// -- comparison operator overloads --------------------------------------------
......
......@@ -31,10 +31,6 @@ constexpr auto max_batch_delay = timespan{1'000'000};
/// This strategy makes no dynamic adjustment or sampling.
constexpr auto credit_policy = string_view{"size-based"};
[[deprecated("this parameter no longer has any effect")]] //
constexpr auto credit_round_interval
= max_batch_delay;
} // namespace caf::defaults::stream
namespace caf::defaults::stream::size_policy {
......
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include "caf/byte_span.hpp"
#include "caf/detail/base64.hpp"
#include "caf/string_view.hpp"
#include <string>
namespace caf::detail {
[[deprecated("use base64::encode instead")]] inline std::string
encode_base64(string_view str) {
return base64::encode(str);
}
[[deprecated("use base64::encode instead")]] inline std::string
encode_base64(const_byte_span bytes) {
return base64::encode(bytes);
}
} // namespace caf::detail
......@@ -164,9 +164,7 @@ public:
iterator insert(const_iterator hint, value_type x) {
auto i = find(x.first);
return i == end()
? xs_.insert(gcc48_iterator_workaround(hint), std::move(x))
: i;
return i == end() ? xs_.insert(hint, std::move(x)) : i;
}
template <class InputIterator>
......@@ -188,12 +186,11 @@ public:
// -- removal ----------------------------------------------------------------
iterator erase(const_iterator i) {
return xs_.erase(gcc48_iterator_workaround(i));
return xs_.erase(i);
}
iterator erase(const_iterator first, const_iterator last) {
return xs_.erase(gcc48_iterator_workaround(first),
gcc48_iterator_workaround(last));
return xs_.erase(first, last);
}
size_type erase(const key_type& x) {
......@@ -249,33 +246,6 @@ public:
}
private:
// GCC < 4.9 has a broken STL: vector::erase accepts iterator instead of
// const_iterator.
// TODO: remove when dropping support for GCC 4.8.
template <class Iter>
struct is_valid_erase_iter {
template <class U>
static auto sfinae(U* x)
-> decltype(std::declval<vector_type&>().erase(*x), std::true_type{});
template <class U>
static auto sfinae(...) -> std::false_type;
static constexpr bool value = decltype(sfinae<Iter>(nullptr))::value;
};
template <class I, class E = enable_if_t<!is_valid_erase_iter<I>::value>>
iterator gcc48_iterator_workaround(I i) {
auto j = begin();
std::advance(j, std::distance(cbegin(), i));
return j;
}
template <class I, class E = enable_if_t<is_valid_erase_iter<I>::value>>
const_iterator gcc48_iterator_workaround(I i) {
return i;
}
vector_type xs_;
};
......
......@@ -55,8 +55,7 @@ void exec_main_load_module(actor_system_config& cfg) {
}
template <class... Ts, class F = void (*)(actor_system&)>
[[deprecated("override config_file_path in the config class instead")]] int
exec_main(F fun, int argc, char** argv, const char* config_file_name) {
int exec_main(F fun, int argc, char** argv) {
using trait = typename detail::get_callable_trait<F>::type;
using arg_types = typename trait::arg_types;
static_assert(detail::tl_size<arg_types>::value == 1
......@@ -77,13 +76,11 @@ exec_main(F fun, int argc, char** argv, const char* config_file_name) {
using helper = exec_main_helper<typename trait::arg_types>;
// Pass CLI options to config.
typename helper::config cfg;
CAF_PUSH_DEPRECATED_WARNING
if (auto err = cfg.parse(argc, argv, config_file_name)) {
if (auto err = cfg.parse(argc, argv)) {
std::cerr << "error while parsing CLI and file options: " << to_string(err)
<< std::endl;
return EXIT_FAILURE;
}
CAF_POP_WARNINGS
// Return immediately if a help text was printed.
if (cfg.cli_helptext_printed)
return EXIT_SUCCESS;
......@@ -108,13 +105,6 @@ exec_main(F fun, int argc, char** argv, const char* config_file_name) {
}
}
template <class... Ts, class F = void (*)(actor_system&)>
int exec_main(F fun, int argc, char** argv) {
CAF_PUSH_DEPRECATED_WARNING
return exec_main<Ts...>(std::move(fun), argc, argv, nullptr);
CAF_POP_WARNINGS
}
} // namespace caf
#define CAF_MAIN(...) \
......
......@@ -24,8 +24,6 @@ namespace caf {
enum class exit_reason : uint8_t {
/// Indicates that an actor finished execution without error.
normal = 0,
/// Indicates that an actor died because of an unhandled exception.
unhandled_exception [[deprecated("superseded by sec::runtime_error")]],
/// Indicates that the exit reason for this actor is unknown, i.e.,
/// the actor has been terminated and no longer exists.
unknown,
......
......@@ -127,18 +127,12 @@ public:
template <class U>
U& get() {
static constexpr auto i = detail::tl_index_of<param_list, U>::value;
return std::get<i>(nested_);
// TODO: replace with this line when switching to C++14
// return std::get<U>(substreams_);
return std::get<U>(nested_);
}
template <class U>
const U& get() const {
static constexpr auto i = detail::tl_index_of<param_list, U>::value;
return std::get<i>(nested_);
// TODO: replace with this line when switching to C++14
// return std::get<U>(substreams_);
return std::get<U>(nested_);
}
/// Requires a previous call to `add_path` for given slot.
......
......@@ -57,26 +57,6 @@ constexpr auto always_true = always_true_t{};
template <class>
constexpr bool assertion_failed_v = false;
// TODO: remove with CAF 0.19
template <class T, class Inspector, class Obj>
class has_static_apply {
private:
template <class U>
static auto sfinae(Inspector* f, Obj* x) -> decltype(U::apply(*f, *x));
template <class U>
static auto sfinae(...) -> std::false_type;
using sfinae_type = decltype(sfinae<T>(nullptr, nullptr));
public:
static constexpr bool value
= !std::is_same<sfinae_type, std::false_type>::value;
};
template <class T, class Inspector, class Obj>
constexpr bool has_static_apply_v = has_static_apply<T, Inspector, Obj>::value;
// -- loading ------------------------------------------------------------------
// Converts a setter that returns void, error or bool to a sync function object
......@@ -105,17 +85,8 @@ auto bind_setter(Inspector& f, Set& set, ValueType& tmp) {
}
}
// TODO: remove with CAF 0.19
template <class Inspector, class T>
[[deprecated("please provide apply instead of apply_object/apply_value")]] //
std::enable_if_t<!has_static_apply_v<inspector_access<T>, Inspector, T>, bool>
load(Inspector& f, T& x, inspector_access_type::specialization) {
return inspector_access<T>::apply_value(f, x);
}
template <class Inspector, class T>
std::enable_if_t<has_static_apply_v<inspector_access<T>, Inspector, T>, bool>
load(Inspector& f, T& x, inspector_access_type::specialization) {
bool load(Inspector& f, T& x, inspector_access_type::specialization) {
return inspector_access<T>::apply(f, x);
}
......@@ -206,17 +177,8 @@ bool load_field(Inspector& f, string_view field_name, T& x, IsValid& is_valid,
// -- saving -------------------------------------------------------------------
// TODO: remove with CAF 0.19
template <class Inspector, class T>
[[deprecated("please provide apply instead of apply_object/apply_value")]] //
std::enable_if_t<!has_static_apply_v<inspector_access<T>, Inspector, T>, bool>
save(Inspector& f, T& x, inspector_access_type::specialization) {
return inspector_access<T>::apply_value(f, x);
}
template <class Inspector, class T>
std::enable_if_t<has_static_apply_v<inspector_access<T>, Inspector, T>, bool>
save(Inspector& f, T& x, inspector_access_type::specialization) {
bool save(Inspector& f, T& x, inspector_access_type::specialization) {
return inspector_access<T>::apply(f, x);
}
......@@ -394,18 +356,6 @@ struct optional_inspector_access {
return f.object(x).fields(f.field("value", x));
}
template <class Inspector>
[[deprecated("use apply instead")]] static bool
apply_object(Inspector& f, container_type& x) {
return apply(f, x);
}
template <class Inspector>
[[deprecated("use apply instead")]] static bool
apply_value(Inspector& f, container_type& x) {
return apply(f, x);
}
template <class Inspector>
static bool
save_field(Inspector& f, string_view field_name, container_type& x) {
......@@ -554,18 +504,6 @@ struct variant_inspector_access {
return f.object(x).fields(f.field("value", x));
}
template <class Inspector>
[[deprecated("use apply instead")]] static bool
apply_object(Inspector& f, T& x) {
return apply(f, x);
}
template <class Inspector>
[[deprecated("use apply instead")]] static bool
apply_value(Inspector& f, T& x) {
return apply(f, x);
}
template <class Inspector>
static bool save_field(Inspector& f, string_view field_name, value_type& x) {
auto g = [&f](auto& y) { return detail::save(f, y); };
......@@ -760,18 +698,6 @@ struct inspector_access<std::chrono::duration<Rep, Period>>
return f.apply(get, set);
}
}
template <class Inspector>
[[deprecated("use apply instead")]] static bool
apply_object(Inspector& f, value_type& x) {
return apply(f, x);
}
template <class Inspector>
[[deprecated("use apply instead")]] static bool
apply_value(Inspector& f, value_type& x) {
return apply(f, x);
}
};
template <class Duration>
......@@ -802,35 +728,6 @@ struct inspector_access<
return f.apply(get, set);
}
}
template <class Inspector>
[[deprecated("use apply instead")]] static bool
apply_object(Inspector& f, value_type& x) {
return apply(f, x);
}
template <class Inspector>
[[deprecated("use apply instead")]] static bool
apply_value(Inspector& f, value_type& x) {
return apply(f, x);
}
};
// -- deprecated API -----------------------------------------------------------
template <class T>
struct default_inspector_access : inspector_access_base<T> {
template <class Inspector>
[[deprecated("call f.apply(x) instead")]] static bool
apply_object(Inspector& f, T& x) {
return f.apply(x);
}
template <class Inspector>
[[deprecated("call f.apply(x) instead")]] static bool
apply_value(Inspector& f, T& x) {
return f.apply(x);
}
};
} // namespace caf
......@@ -21,26 +21,10 @@ constexpr bool is_error_code_enum_v = is_error_code_enum<T>::value;
} // namespace caf
// TODO: the overload with two arguments exists only for backwards compatibility
// with CAF 0.17. Remove with CAF 0.19.
#define CAF_ERROR_CODE_ENUM_1(type_name) \
#define CAF_ERROR_CODE_ENUM(type_name) \
namespace caf { \
template <> \
struct is_error_code_enum<type_name> { \
static constexpr bool value = true; \
}; \
}
#define CAF_ERROR_CODE_ENUM_2(type_name, unused) \
CAF_ERROR_CODE_ENUM_1(type_name)
#ifdef CAF_MSVC
# define CAF_ERROR_CODE_ENUM(...) \
CAF_PP_CAT(CAF_PP_OVERLOAD(CAF_ERROR_CODE_ENUM_, \
__VA_ARGS__)(__VA_ARGS__), \
CAF_PP_EMPTY())
#else
# define CAF_ERROR_CODE_ENUM(...) \
CAF_PP_OVERLOAD(CAF_ERROR_CODE_ENUM_, __VA_ARGS__)(__VA_ARGS__)
#endif
......@@ -21,10 +21,6 @@ namespace caf {
/// for the DSL.
class CAF_CORE_EXPORT load_inspector {
public:
// -- member types -----------------------------------------------------------
using result_type [[deprecated("inspectors always return bool")]] = bool;
// -- constants --------------------------------------------------------------
/// Enables dispatching on the inspector type.
......
......@@ -144,36 +144,6 @@ public:
}
}
// -- deprecated API: remove with CAF 0.19 -----------------------------------
template <class T>
[[deprecated("auto-conversion to underlying type is unsafe, add inspect")]] //
std::enable_if_t<std::is_enum<T>::value, bool>
opaque_value(T& val) {
auto tmp = std::underlying_type_t<T>{0};
if (dref().value(tmp)) {
val = static_cast<T>(tmp);
return true;
} else {
return false;
}
}
template <class T>
[[deprecated("use apply instead")]] bool apply_object(T& x) {
return detail::save(dref(), x);
}
template <class... Ts>
[[deprecated("use apply instead")]] bool apply_objects(Ts&... xs) {
return (apply(xs) && ...);
}
template <class T>
[[deprecated("use apply instead")]] bool apply_value(T& x) {
return detail::save(dref(), x);
}
private:
Subtype* dptr() {
return static_cast<Subtype*>(this);
......
......@@ -357,17 +357,6 @@ public:
return make_response_promise<response_promise>();
}
template <class... Ts>
[[deprecated("simply return the result from the message handler")]] //
detail::response_promise_t<std::decay_t<Ts>...>
response(Ts&&... xs) {
if (current_element_) {
response_promise::respond_to(this, current_element_,
make_message(std::forward<Ts>(xs)...));
}
return {};
}
const char* name() const override;
/// Serializes the state of this actor to `sink`. This function is
......
......@@ -73,14 +73,4 @@ CAF_CORE_EXPORT config_option
make_negated_config_option(bool& storage, string_view category,
string_view name, string_view description);
// Reads timespans, but stores an integer representing microsecond resolution.
[[deprecated("use timespan options instead")]] CAF_CORE_EXPORT config_option
make_us_resolution_config_option(size_t& storage, string_view category,
string_view name, string_view description);
// Reads timespans, but stores an integer representing millisecond resolution.
[[deprecated("use timespan options instead")]] CAF_CORE_EXPORT config_option
make_ms_resolution_config_option(size_t& storage, string_view category,
string_view name, string_view description);
} // namespace caf
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include "caf/detail/core_export.hpp"
namespace caf {
class [[deprecated]] memory_managed;
class CAF_CORE_EXPORT memory_managed {
public:
virtual void request_deletion(bool decremented_rc) const noexcept;
protected:
virtual ~memory_managed();
};
} // namespace caf
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include <type_traits>
namespace caf::meta {
struct annotation {
constexpr annotation() {
// nop
}
};
template <class T>
struct is_annotation {
static constexpr bool value = std::is_base_of<annotation, T>::value;
};
template <class T>
struct is_annotation<T&> : is_annotation<T> {};
template <class T>
struct is_annotation<const T&> : is_annotation<T> {};
template <class T>
struct is_annotation<T&&> : is_annotation<T> {};
template <class T>
[[deprecated]] constexpr bool is_annotation_v = is_annotation<T>::value;
} // namespace caf::meta
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include "caf/meta/annotation.hpp"
namespace caf::meta {
struct hex_formatted_t : annotation {
constexpr hex_formatted_t() {
// nop
}
};
[[deprecated]] constexpr hex_formatted_t hex_formatted() {
return {};
}
} // namespace caf::meta
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include <type_traits>
#include <utility>
#include "caf/meta/annotation.hpp"
namespace caf::meta {
template <class F>
struct load_callback_t : annotation {
load_callback_t(F&& f) : fun(f) {
// nop
}
load_callback_t(load_callback_t&&) = default;
load_callback_t(const load_callback_t&) = default;
F fun;
};
template <class T>
struct is_load_callback : std::false_type {};
template <class F>
struct is_load_callback<load_callback_t<F>> : std::true_type {};
template <class F>
constexpr bool is_load_callback_v = is_load_callback<F>::value;
template <class F>
[[deprecated]] load_callback_t<F> load_callback(F fun) {
return {std::move(fun)};
}
} // namespace caf::meta
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include "caf/meta/annotation.hpp"
namespace caf::meta {
struct omittable_t : annotation {
constexpr omittable_t() {
// nop
}
};
[[deprecated]] constexpr omittable_t omittable() {
return {};
}
} // namespace caf::meta
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include "caf/meta/annotation.hpp"
namespace caf::meta {
struct omittable_if_empty_t : annotation {
constexpr omittable_if_empty_t() {
// nop
}
};
[[deprecated]] constexpr omittable_if_empty_t omittable_if_empty() {
return {};
}
} // namespace caf::meta
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include "caf/meta/annotation.hpp"
namespace caf::meta {
struct omittable_if_none_t : annotation {
constexpr omittable_if_none_t() {
// nop
}
};
[[deprecated]] constexpr omittable_if_none_t omittable_if_none() {
return {};
}
} // namespace caf::meta
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include <type_traits>
#include "caf/meta/annotation.hpp"
namespace caf::meta {
template <class F>
struct save_callback_t : annotation {
save_callback_t(F&& f) : fun(f) {
// nop
}
save_callback_t(save_callback_t&&) = default;
save_callback_t(const save_callback_t&) = default;
F fun;
};
template <class T>
struct is_save_callback : std::false_type {};
template <class F>
struct is_save_callback<save_callback_t<F>> : std::true_type {};
template <class F>
constexpr bool is_save_callback_v = is_save_callback<F>::value;
template <class F>
[[deprecated]] save_callback_t<F> save_callback(F fun) {
return {std::move(fun)};
}
} // namespace caf::meta
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include "caf/meta/annotation.hpp"
namespace caf::meta {
struct type_name_t : annotation {
constexpr type_name_t(const char* cstr) : value(cstr) {
// nop
}
const char* value;
};
[[deprecated]] type_name_t constexpr type_name(const char* cstr) {
return {cstr};
}
} // namespace caf::meta
......@@ -48,11 +48,6 @@ public:
response_promise& operator=(const response_promise&) = default;
[[deprecated("use the default constructor instead")]] response_promise(none_t)
: response_promise() {
// nop
}
// -- properties -------------------------------------------------------------
/// Returns whether this response promise replies to an asynchronous message.
......
......@@ -21,10 +21,6 @@ namespace caf {
/// for the DSL.
class CAF_CORE_EXPORT save_inspector {
public:
// -- member types -----------------------------------------------------------
using result_type [[deprecated("inspectors always return bool")]] = bool;
// -- constants --------------------------------------------------------------
/// Enables dispatching on the inspector type.
......
......@@ -97,30 +97,6 @@ public:
return detail::save(dref(), get());
}
// -- deprecated API: remove with CAF 0.19 -----------------------------------
template <class T>
[[deprecated("auto-conversion to underlying type is unsafe, add inspect")]] //
std::enable_if_t<std::is_enum<T>::value, bool>
opaque_value(T val) {
return dref().value(static_cast<std::underlying_type_t<T>>(val));
}
template <class T>
[[deprecated("use apply instead")]] bool apply_object(const T& x) {
return apply(x);
}
template <class... Ts>
[[deprecated("use apply instead")]] bool apply_objects(const Ts&... xs) {
return (apply(xs) && ...);
}
template <class T>
[[deprecated("use apply instead")]] bool apply_value(const T& x) {
return apply(x);
}
private:
Subtype* dptr() {
return static_cast<Subtype*>(this);
......
......@@ -71,8 +71,6 @@ public:
const char*>::value) {
return State::name;
}
} else {
non_static_name_member(state.name);
}
}
return Base::name();
......@@ -84,14 +82,6 @@ public:
/// its reference count drops to zero.
State state;
};
template <class T>
[[deprecated("non-static 'State::name' members have no effect since 0.18")]]
// This function only exists to raise a deprecated warning.
static void
non_static_name_member(const T&) {
// nop
}
};
} // namespace caf
......
......@@ -78,12 +78,6 @@ constexpr type_id_t first_custom_type_id = 200;
template <class T>
constexpr bool has_type_id_v = detail::is_complete<type_id<T>>;
// TODO: remove with CAF 0.19 (this exists for compatibility with CAF 0.17).
template <class T>
struct has_type_id {
static constexpr bool value = detail::is_complete<type_id<T>>;
};
/// Returns `type_name_v<T>` if available, "anonymous" otherwise.
template <class T>
string_view type_name_or_anonymous() {
......
......@@ -89,10 +89,6 @@ public:
template <class State>
using stateful_impl = stateful_actor<State, impl>;
template <class State>
using stateful_base [[deprecated("use stateful_impl instead")]]
= stateful_actor<State, base>;
/// Convenience alias for `stateful_impl<State>*`.
template <class State>
using stateful_pointer = stateful_impl<State>*;
......
......@@ -238,13 +238,6 @@ public:
return self_->make_response_promise();
}
template <class... Ts,
class R = typename detail::make_response_promise_helper<
typename std::decay<Ts>::type...>::type>
R response(Ts&&... xs) {
return self_->response(std::forward<Ts>(xs)...);
}
template <class... Ts>
void eq_impl(Ts&&... xs) {
self_->eq_impl(std::forward<Ts>(xs)...);
......
......@@ -39,12 +39,6 @@ public:
typed_response_promise& operator=(const typed_response_promise&) = default;
[[deprecated("use the default constructor instead")]] //
typed_response_promise(none_t x)
: promise_(x) {
// nop
}
// -- properties -------------------------------------------------------------
/// @copydoc response_promise::async
......@@ -77,11 +71,6 @@ public:
return promise_.id();
}
[[deprecated("use the typed_response_promise directly")]]
operator response_promise&() {
return promise_;
}
// -- delivery ---------------------------------------------------------------
/// Satisfies the promise by sending a non-error response message.
......
......@@ -419,10 +419,6 @@ actor_registry& actor_system::registry() {
return registry_;
}
std::string actor_system::render(const error& x) const {
return to_string(x);
}
group_manager& actor_system::groups() {
return groups_;
}
......
......@@ -183,23 +183,6 @@ error actor_system_config::parse(int argc, char** argv) {
return parse(std::move(args));
}
error actor_system_config::parse(int argc, char** argv,
const char* config_file_cstr) {
if (config_file_cstr == nullptr) {
return parse(argc, argv);
} else {
string_list args;
if (argc > 0) {
program_name = argv[0];
if (argc > 1)
args.assign(argv + 1, argv + argc);
}
CAF_PUSH_DEPRECATED_WARNING
return parse(std::move(args), config_file_cstr);
CAF_POP_WARNINGS
}
}
error actor_system_config::parse(int argc, char** argv, std::istream& conf) {
string_list args;
if (argc > 0) {
......@@ -376,25 +359,6 @@ error actor_system_config::parse(string_list args) {
}
}
error actor_system_config::parse(string_list args,
const char* config_file_cstr) {
if (config_file_cstr == nullptr) {
return parse(std::move(args));
} else if (auto&& [err, path] = extract_config_file_path(args); !err) {
std::ifstream conf;
if (!path.empty()) {
conf.open(path);
} else {
conf.open(config_file_cstr);
if (conf.is_open())
set("global.config-file", config_file_cstr);
}
return parse(std::move(args), conf);
} else {
return err;
}
}
actor_system_config& actor_system_config::add_actor_factory(std::string name,
actor_factory fun) {
actor_factories.emplace(std::move(name), std::move(fun));
......@@ -420,10 +384,6 @@ actor_system_config& actor_system_config::set_impl(string_view name,
return *this;
}
std::string actor_system_config::render(const error& x) {
return to_string(x);
}
expected<settings>
actor_system_config::parse_config_file(const char* filename) {
config_option_set dummy;
......
......@@ -118,11 +118,6 @@ error config_option::sync(config_value& x) const {
return meta_->sync(value_, x);
}
error config_option::store(const config_value& x) const {
auto cpy = x;
return sync(cpy);
}
string_view config_option::type_name() const noexcept {
return meta_->type_name;
}
......@@ -135,20 +130,6 @@ bool config_option::has_flat_cli_name() const noexcept {
return buf_[0] == '?' || category() == "global";
}
expected<config_value> config_option::parse(string_view input) const {
config_value val{input};
if (auto err = sync(val))
return {std::move(err)};
else
return {std::move(val)};
}
optional<config_value> config_option::get() const {
if (value_ != nullptr && meta_->get != nullptr)
return meta_->get(value_);
return none;
}
string_view config_option::buf_slice(size_t from, size_t to) const noexcept {
CAF_ASSERT(from <= to);
return {buf_.get() + from, to - from};
......
......@@ -24,18 +24,6 @@ config_option_adder& config_option_adder::add_neg(bool& ref, string_view name,
name, description));
}
config_option_adder& config_option_adder::add_us(size_t& ref, string_view name,
string_view description) {
return add_impl(make_us_resolution_config_option(ref, category_,
name, description));
}
config_option_adder& config_option_adder::add_ms(size_t& ref, string_view name,
string_view description) {
return add_impl(make_ms_resolution_config_option(ref, category_,
name, description));
}
config_option_adder& config_option_adder::add_impl(config_option&& opt) {
xs_.add(std::move(opt));
return *this;
......
......@@ -52,11 +52,6 @@ config_value get_timespan(const void* ptr) {
return config_value{val};
}
meta_state us_res_meta{sync_timespan<1000>, get_timespan<1000>, "timespan"};
meta_state ms_res_meta{sync_timespan<1000000>, get_timespan<1000000>,
"timespan"};
} // namespace
config_option make_negated_config_option(bool& storage, string_view category,
......@@ -65,16 +60,4 @@ config_option make_negated_config_option(bool& storage, string_view category,
return {category, name, description, &bool_neg_meta, &storage};
}
config_option
make_us_resolution_config_option(size_t& storage, string_view category,
string_view name, string_view description) {
return {category, name, description, &us_res_meta, &storage};
}
config_option
make_ms_resolution_config_option(size_t& storage, string_view category,
string_view name, string_view description) {
return {category, name, description, &ms_res_meta, &storage};
}
} // namespace caf
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#include "caf/memory_managed.hpp"
namespace caf {
memory_managed::~memory_managed() {
// nop
}
void memory_managed::request_deletion(bool) const noexcept {
delete this;
}
} // namespace caf
......@@ -218,8 +218,7 @@ bool save(const detail::meta_object& meta, caf::binary_serializer& sink,
}
template <class Serializer>
typename Serializer::result_type
save_data(Serializer& sink, const message::data_ptr& data) {
bool save_data(Serializer& sink, const message::data_ptr& data) {
auto gmos = detail::global_meta_objects();
// For machine-to-machine data formats, we prefix the type information.
if (!sink.has_human_readable_format()) {
......
......@@ -158,7 +158,6 @@ CAF_TEST(sub ascii) {
}
CAF_TEST(binary numbers) {
/* TODO: use this implementation when switching to C++14
CHECK_NUMBER(0b0);
CHECK_NUMBER(0b10);
CHECK_NUMBER(0b101);
......@@ -166,14 +165,6 @@ CAF_TEST(binary numbers) {
CHECK_NUMBER(-0b0);
CHECK_NUMBER(-0b101);
CHECK_NUMBER(-0B1001);
*/
CAF_CHECK_EQUAL(p("0b0"), res(0));
CAF_CHECK_EQUAL(p("0b10"), res(2));
CAF_CHECK_EQUAL(p("0b101"), res(5));
CAF_CHECK_EQUAL(p("0B1001"), res(9));
CAF_CHECK_EQUAL(p("-0b0"), res(0));
CAF_CHECK_EQUAL(p("-0b101"), res(-5));
CAF_CHECK_EQUAL(p("-0B1001"), res(-9));
}
CAF_TEST(octal numbers) {
......
......@@ -16,6 +16,7 @@
#include "caf/variant.hpp"
using namespace caf;
using namespace std::literals;
namespace {
......@@ -41,58 +42,51 @@ struct fixture {
string_parser p;
};
// TODO: remove and use "..."s from the STL when switching to C++14
std::string operator"" _s(const char* str, size_t str_len) {
std::string result;
result.assign(str, str_len);
return result;
}
} // namespace
CAF_TEST_FIXTURE_SCOPE(read_string_tests, fixture)
CAF_TEST(empty string) {
CAF_CHECK_EQUAL(p(R"("")"), ""_s);
CAF_CHECK_EQUAL(p(R"( "")"), ""_s);
CAF_CHECK_EQUAL(p(R"( "")"), ""_s);
CAF_CHECK_EQUAL(p(R"("" )"), ""_s);
CAF_CHECK_EQUAL(p(R"("" )"), ""_s);
CAF_CHECK_EQUAL(p(R"( "" )"), ""_s);
CAF_CHECK_EQUAL(p("\t \"\" \t\t\t "), ""_s);
CAF_CHECK_EQUAL(p(R"('')"), ""_s);
CAF_CHECK_EQUAL(p(R"( '')"), ""_s);
CAF_CHECK_EQUAL(p(R"( '')"), ""_s);
CAF_CHECK_EQUAL(p(R"('' )"), ""_s);
CAF_CHECK_EQUAL(p(R"('' )"), ""_s);
CAF_CHECK_EQUAL(p(R"( '' )"), ""_s);
CAF_CHECK_EQUAL(p("\t '' \t\t\t "), ""_s);
CAF_CHECK_EQUAL(p(R"("")"), ""s);
CAF_CHECK_EQUAL(p(R"( "")"), ""s);
CAF_CHECK_EQUAL(p(R"( "")"), ""s);
CAF_CHECK_EQUAL(p(R"("" )"), ""s);
CAF_CHECK_EQUAL(p(R"("" )"), ""s);
CAF_CHECK_EQUAL(p(R"( "" )"), ""s);
CAF_CHECK_EQUAL(p("\t \"\" \t\t\t "), ""s);
CAF_CHECK_EQUAL(p(R"('')"), ""s);
CAF_CHECK_EQUAL(p(R"( '')"), ""s);
CAF_CHECK_EQUAL(p(R"( '')"), ""s);
CAF_CHECK_EQUAL(p(R"('' )"), ""s);
CAF_CHECK_EQUAL(p(R"('' )"), ""s);
CAF_CHECK_EQUAL(p(R"( '' )"), ""s);
CAF_CHECK_EQUAL(p("\t '' \t\t\t "), ""s);
}
CAF_TEST(nonempty quoted string) {
CAF_CHECK_EQUAL(p(R"("abc")"), "abc"_s);
CAF_CHECK_EQUAL(p(R"("a b c")"), "a b c"_s);
CAF_CHECK_EQUAL(p(R"( "abcdefABCDEF" )"), "abcdefABCDEF"_s);
CAF_CHECK_EQUAL(p(R"('abc')"), "abc"_s);
CAF_CHECK_EQUAL(p(R"('a b c')"), "a b c"_s);
CAF_CHECK_EQUAL(p(R"( 'abcdefABCDEF' )"), "abcdefABCDEF"_s);
CAF_CHECK_EQUAL(p(R"("abc")"), "abc"s);
CAF_CHECK_EQUAL(p(R"("a b c")"), "a b c"s);
CAF_CHECK_EQUAL(p(R"( "abcdefABCDEF" )"), "abcdefABCDEF"s);
CAF_CHECK_EQUAL(p(R"('abc')"), "abc"s);
CAF_CHECK_EQUAL(p(R"('a b c')"), "a b c"s);
CAF_CHECK_EQUAL(p(R"( 'abcdefABCDEF' )"), "abcdefABCDEF"s);
}
CAF_TEST(quoted string with escaped characters) {
CAF_CHECK_EQUAL(p(R"("a\tb\tc")"), "a\tb\tc"_s);
CAF_CHECK_EQUAL(p(R"("a\nb\r\nc")"), "a\nb\r\nc"_s);
CAF_CHECK_EQUAL(p(R"("a\\b")"), "a\\b"_s);
CAF_CHECK_EQUAL(p("\"'hello' \\\"world\\\"\""), "'hello' \"world\""_s);
CAF_CHECK_EQUAL(p(R"('a\tb\tc')"), "a\tb\tc"_s);
CAF_CHECK_EQUAL(p(R"('a\nb\r\nc')"), "a\nb\r\nc"_s);
CAF_CHECK_EQUAL(p(R"('a\\b')"), "a\\b"_s);
CAF_CHECK_EQUAL(p(R"('\'hello\' "world"')"), "'hello' \"world\""_s);
CAF_CHECK_EQUAL(p(R"("a\tb\tc")"), "a\tb\tc"s);
CAF_CHECK_EQUAL(p(R"("a\nb\r\nc")"), "a\nb\r\nc"s);
CAF_CHECK_EQUAL(p(R"("a\\b")"), "a\\b"s);
CAF_CHECK_EQUAL(p("\"'hello' \\\"world\\\"\""), "'hello' \"world\""s);
CAF_CHECK_EQUAL(p(R"('a\tb\tc')"), "a\tb\tc"s);
CAF_CHECK_EQUAL(p(R"('a\nb\r\nc')"), "a\nb\r\nc"s);
CAF_CHECK_EQUAL(p(R"('a\\b')"), "a\\b"s);
CAF_CHECK_EQUAL(p(R"('\'hello\' "world"')"), "'hello' \"world\""s);
}
CAF_TEST(unquoted strings) {
CAF_CHECK_EQUAL(p(R"(foo)"), "foo"_s);
CAF_CHECK_EQUAL(p(R"( foo )"), "foo"_s);
CAF_CHECK_EQUAL(p(R"( 123 )"), "123"_s);
CAF_CHECK_EQUAL(p(R"(foo)"), "foo"s);
CAF_CHECK_EQUAL(p(R"( foo )"), "foo"s);
CAF_CHECK_EQUAL(p(R"( 123 )"), "123"s);
}
CAF_TEST(invalid strings) {
......
......@@ -97,8 +97,6 @@ void stream::force_empty_write(const manager_ptr& mgr) {
void stream::prepare_next_read() {
collected_ = 0;
// This cast does nothing, but prevents a weird compiler error on GCC <= 4.9.
// TODO: remove cast when dropping support for GCC 4.9.
switch (static_cast<receive_policy_flag>(state_.rd_flag)) {
case receive_policy_flag::exactly:
if (rd_buf_.size() != max_)
......
......@@ -111,14 +111,7 @@ private:
}
template <size_t X, class T, class... Ts>
typename std::enable_if<caf::meta::is_annotation<T>::value, bool>::type
iterate(pos<X> pos, const T&, const Ts&... ys) {
return iterate(pos, ys...);
}
template <size_t X, class T, class... Ts>
typename std::enable_if<!caf::meta::is_annotation<T>::value, bool>::type
iterate(pos<X>, const T& y, const Ts&... ys) {
bool iterate(pos<X>, const T& y, const Ts&... ys) {
std::integral_constant<size_t, X + 1> next;
check(y, get<X>(xs_));
return iterate(next, ys...);
......@@ -330,12 +323,7 @@ public:
template <class... Us>
void with(Us&&... xs) {
// TODO: replace this workaround with the make_tuple() line when dropping
// support for GCC 4.8.
std::tuple<typename std::decay<Us>::type...> tmp{std::forward<Us>(xs)...};
// auto tmp = std::make_tuple(std::forward<Us>(xs)...);
// TODO: move tmp into lambda when switching to C++14
peek_ = [=] {
peek_ = [this, tmp = std::make_tuple(std::forward<Us>(xs)...)] {
using namespace caf::detail;
elementwise_compare_inspector<decltype(tmp)> inspector{tmp};
auto ys = extract<Ts...>(dest_);
......@@ -516,11 +504,7 @@ public:
template <class... Us>
void with(Us&&... xs) {
// TODO: replace this workaround with make_tuple() when dropping support
// for GCC 4.8.
std::tuple<typename std::decay<Us>::type...> tmp{std::forward<Us>(xs)...};
// TODO: move tmp into lambda when switching to C++14
peek_ = [=] {
peek_ = [this, tmp = std::make_tuple(std::forward<Us>(xs)...)] {
using namespace caf::detail;
elementwise_compare_inspector<decltype(tmp)> inspector{tmp};
auto ys = try_extract<Ts...>(dest_);
......@@ -596,11 +580,7 @@ public:
template <class... Us>
void with(Us&&... xs) {
// TODO: replace this workaround with make_tuple() when dropping support
// for GCC 4.8.
std::tuple<typename std::decay<Us>::type...> tmp{std::forward<Us>(xs)...};
// TODO: move tmp into lambda when switching to C++14
check_ = [=] {
check_ = [this, tmp = std::make_tuple(std::forward<Us>(xs)...)] {
auto ptr = dest_->peek_at_next_mailbox_element();
if (ptr == nullptr)
return;
......
......@@ -12,7 +12,7 @@
#include <vector>
#include "caf/all.hpp"
#include "caf/detail/encode_base64.hpp"
#include "caf/detail/base64.hpp"
#include "caf/io/all.hpp"
using namespace caf;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment