From f229f60dc607e4d35a28c2a004a1175e65a32278 Mon Sep 17 00:00:00 2001 From: bennibbelink <79653949+bennibbelink@users.noreply.github.com> Date: Sat, 17 Feb 2024 17:43:39 -0600 Subject: [PATCH 1/5] resolve warnings from any.hpp --- src/any.hpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/any.hpp b/src/any.hpp index 573e12f1a1..2e41859997 100644 --- a/src/any.hpp +++ b/src/any.hpp @@ -198,10 +198,7 @@ namespace boost { namespace spirit basic_hold_any(T const& x) : table(spirit::detail::get_table::template get()), object(0) { - if (spirit::detail::get_table::is_small::value) - new (&object) T(x); - else - object = new T(x); + new_object(object, x, typename spirit::detail::get_table::is_small()); } basic_hold_any(const char* x) @@ -228,6 +225,17 @@ namespace boost { namespace spirit table->static_delete(&object); } + template + static void new_object(void*& object, T const& x, mpl::true_) + { + new (&object) T(x); + } + + template + static void new_object(void*& object, T const& x, mpl::false_) + { + object = new T(x); + } // assignment basic_hold_any& assign(basic_hold_any const& x) { @@ -255,24 +263,17 @@ namespace boost { namespace spirit if (table == x_table) { // if so, we can avoid deallocating and re-use memory table->destruct(&object); // first destruct the old content - if (spirit::detail::get_table::is_small::value) { - // create copy on-top of object pointer itself - new (&object) T(x); - } - else { - // create copy on-top of old version - new (object) T(x); - } + new_object(object, x, typename spirit::detail::get_table::is_small()); } else { if (spirit::detail::get_table::is_small::value) { // create copy on-top of object pointer itself table->destruct(&object); // first destruct the old content - new (&object) T(x); + new_object(object, x, typename spirit::detail::get_table::is_small()); } else { reset(); // first delete the old content - object = new T(x); + new_object(object, x, typename spirit::detail::get_table::is_small()); } table = x_table; // update table pointer } From 52fa2e750ef909d97825ee6afb82a23e202fd4f0 Mon Sep 17 00:00:00 2001 From: bennibbelink <79653949+bennibbelink@users.noreply.github.com> Date: Sat, 17 Feb 2024 18:00:04 -0600 Subject: [PATCH 2/5] resolve binary_function deprecation --- src/cyc_std.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/cyc_std.h b/src/cyc_std.h index 0727e671b9..eae669f13e 100644 --- a/src/cyc_std.h +++ b/src/cyc_std.h @@ -8,10 +8,11 @@ namespace cyclus { /// @brief a less-than comparison for pairs -template struct SecondLT : std::binary_function { - bool operator()(const T& x, const T& y) const { - return x.second < y.second; - } +template +struct SecondLT { + bool operator()(const T& x, const T& y) const { + return x.second < y.second; + } }; // taken from From 7b1b495dae54b79cbd3c560a3421ed86ab1ce3ed Mon Sep 17 00:00:00 2001 From: bennibbelink <79653949+bennibbelink@users.noreply.github.com> Date: Sat, 17 Feb 2024 18:19:38 -0600 Subject: [PATCH 3/5] fix more deprecation warnings --- src/discovery.cc | 6 +++--- src/greedy_solver.cc | 21 ++++++++++++--------- src/resource_exchange.h | 17 ++++++++++------- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/discovery.cc b/src/discovery.cc index 92db4541c6..182e0f3e9c 100644 --- a/src/discovery.cc +++ b/src/discovery.cc @@ -91,7 +91,7 @@ std::set DiscoverSpecsInDir(std::string d) { fs::recursive_directory_iterator last; for (; it != last; it.increment(errc)) { if (errc != no_err) { - if (it.level() > 0) { + if (it.depth() > 0) { it.pop(); } continue; @@ -100,8 +100,8 @@ std::set DiscoverSpecsInDir(std::string d) { string pthstr = pth.string(); bool irf = fs::is_regular_file(pth, errc); if (errc != no_err || !irf) { - it.no_push(); - if (it.level() > 0) { + it.disable_recursion_pending(); + if (it.depth() > 0) { it.pop(); } continue; diff --git a/src/greedy_solver.cc b/src/greedy_solver.cc index c95c7f1266..ebf97e1321 100644 --- a/src/greedy_solver.cc +++ b/src/greedy_solver.cc @@ -46,15 +46,17 @@ void GreedySolver::Condition() { void GreedySolver::Init() { std::for_each(graph_->request_groups().begin(), graph_->request_groups().end(), - std::bind1st( - std::mem_fun(&GreedySolver::GetCaps), - this)); + std::bind( + &GreedySolver::GetCaps, + this, + std::placeholders::_1)); std::for_each(graph_->supply_groups().begin(), graph_->supply_groups().end(), - std::bind1st( - std::mem_fun(&GreedySolver::GetCaps), - this)); + std::bind( + &GreedySolver::GetCaps, + this, + std::placeholders::_1)); } double GreedySolver::SolveGraph() { @@ -68,9 +70,10 @@ double GreedySolver::SolveGraph() { std::for_each(graph_->request_groups().begin(), graph_->request_groups().end(), - std::bind1st( - std::mem_fun(&GreedySolver::GreedilySatisfySet), - this)); + std::bind( + &GreedySolver::GreedilySatisfySet, + this, + std::placeholders::_1)); obj_ += unmatched_ * pseudo_cost; return obj_; diff --git a/src/resource_exchange.h b/src/resource_exchange.h index 4c37405b7e..7495bedcc9 100644 --- a/src/resource_exchange.h +++ b/src/resource_exchange.h @@ -77,8 +77,9 @@ class ResourceExchange { std::for_each( traders_.begin(), traders_.end(), - std::bind1st(std::mem_fun(&cyclus::ResourceExchange::AddRequests_), - this)); + std::bind(&cyclus::ResourceExchange::AddRequests_, + this, + std::placeholders::_1)); } /// @brief queries traders and collects all responses to requests for bids @@ -87,8 +88,9 @@ class ResourceExchange { std::for_each( traders_.begin(), traders_.end(), - std::bind1st(std::mem_fun(&cyclus::ResourceExchange::AddBids_), - this)); + std::bind(&cyclus::ResourceExchange::AddBids_, + this, + std::placeholders::_1)); } /// @brief adjust preferences for requests given bid responses @@ -98,9 +100,10 @@ class ResourceExchange { std::for_each( traders.begin(), traders.end(), - std::bind1st( - std::mem_fun(&cyclus::ResourceExchange::AdjustPrefs_), - this)); + std::bind( + &cyclus::ResourceExchange::AdjustPrefs_, + this, + std::placeholders::_1)); } /// return true if this is an empty exchange (i.e., no requests exist, From 21870af4ad3273cc230396d0ca6ce568e4fdeb21 Mon Sep 17 00:00:00 2001 From: bennibbelink <79653949+bennibbelink@users.noreply.github.com> Date: Sat, 17 Feb 2024 18:48:28 -0600 Subject: [PATCH 4/5] remove unneccessary pyhooks function --- cyclus/cpp_cyclus.pxd | 1 - cyclus/lib.pyx | 8 -------- src/pyhooks.cc | 23 ----------------------- src/pyhooks.h | 3 --- 4 files changed, 35 deletions(-) diff --git a/cyclus/cpp_cyclus.pxd b/cyclus/cpp_cyclus.pxd index a37ed96c23..aa79b9251a 100644 --- a/cyclus/cpp_cyclus.pxd +++ b/cyclus/cpp_cyclus.pxd @@ -276,7 +276,6 @@ cdef extern from "pyhooks.h" namespace "cyclus": cdef void PyAppendInitTab() except + cdef void PyImportInit() except + - cdef void PyImportCallInit() except + cdef extern from "pyhooks.h" namespace "cyclus::toolkit": diff --git a/cyclus/lib.pyx b/cyclus/lib.pyx index 217c8d0f18..0435b62e59 100644 --- a/cyclus/lib.pyx +++ b/cyclus/lib.pyx @@ -816,14 +816,6 @@ def py_import_init(): """ cpp_cyclus.PyImportInit() - -def py_import_call_init(): - """Calls Cyclus-internal Python imports. This is called - automatically when cyclus is imported. Users should not need to call - this function. - """ - cpp_cyclus.PyImportCallInit() - # # XML # diff --git a/src/pyhooks.cc b/src/pyhooks.cc index 5bd154c92a..f187f55dc9 100644 --- a/src/pyhooks.cc +++ b/src/pyhooks.cc @@ -49,27 +49,6 @@ void PyImportInit(void) { } } -void PyImportCallInit(void) { - PyObject* init_eventhooks = PyInit_eventhooks(); - if (init_eventhooks == NULL) { - PyErr_Print(); - fprintf(stderr, "Error calling PyInit_eventhooks()\n"); - } - - PyObject* init_pyinfile = PyInit_pyinfile(); - if (init_pyinfile == NULL) { - PyErr_Print(); - fprintf(stderr, "Error calling PyInit_pyinfile()\n"); - } - - PyObject* init_pymodule = PyInit_pymodule(); - if (init_pymodule == NULL) { - PyErr_Print(); - fprintf(stderr, "Error calling PyInit_pymodule()\n"); - } -} - - void PyStart(void) { if (!PY_INTERP_INIT) { PyAppendInitTab(); @@ -128,8 +107,6 @@ void PyAppendInitTab(void) {}; void PyImportInit(void) {}; -void PyImportCallInit(void) {}; - void PyStart(void) {}; void PyStop(void) {}; diff --git a/src/pyhooks.h b/src/pyhooks.h index ee08a33f21..f9531c8207 100644 --- a/src/pyhooks.h +++ b/src/pyhooks.h @@ -22,9 +22,6 @@ void PyAppendInitTab(void); /// Convience function for import initialization void PyImportInit(void); -/// Convience function for imports when Python has already been started -void PyImportCallInit(void); - /// Initialize Python functionality, this is a no-op if Python was not /// installed along with Cyclus. This may be called many times and safely /// initializes the Python interpreter only once. From db01a0c70fcc97e991e819b12d33f303582bfa57 Mon Sep 17 00:00:00 2001 From: bennibbelink <79653949+bennibbelink@users.noreply.github.com> Date: Sat, 17 Feb 2024 18:56:29 -0600 Subject: [PATCH 5/5] update CHANGELOG --- CHANGELOG.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index e2115d2412..5c21bbf276 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -34,6 +34,7 @@ Since last release * Major update and modernization of build (#1587, #1632) * Changed Json formatting for compatibility with current python standards (#1587) * Changed README.rst installation instructions, tested on fresh Ubuntu-22.04 system with Python 3.11 (#1617, #1644) +* Resolved various compilation warnings due to use of deprecated APIs (#1671) **Removed:**