Skip to content

Commit

Permalink
Merge pull request cyclus#1671 from bennibbelink/cyclus-warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
gonuke authored Feb 18, 2024
2 parents db40a20 + db01a0c commit eee2828
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 72 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:**

Expand Down
1 change: 0 additions & 1 deletion cyclus/cpp_cyclus.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
8 changes: 0 additions & 8 deletions cyclus/lib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
Expand Down
29 changes: 15 additions & 14 deletions src/any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,7 @@ namespace boost { namespace spirit
basic_hold_any(T const& x)
: table(spirit::detail::get_table<T>::template get<Char>()), object(0)
{
if (spirit::detail::get_table<T>::is_small::value)
new (&object) T(x);
else
object = new T(x);
new_object(object, x, typename spirit::detail::get_table<T>::is_small());
}

basic_hold_any(const char* x)
Expand All @@ -228,6 +225,17 @@ namespace boost { namespace spirit
table->static_delete(&object);
}

template <typename T>
static void new_object(void*& object, T const& x, mpl::true_)
{
new (&object) T(x);
}

template <typename T>
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)
{
Expand Down Expand Up @@ -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<T>::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<T>::is_small());
}
else {
if (spirit::detail::get_table<T>::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<T>::is_small());
}
else {
reset(); // first delete the old content
object = new T(x);
new_object(object, x, typename spirit::detail::get_table<T>::is_small());
}
table = x_table; // update table pointer
}
Expand Down
9 changes: 5 additions & 4 deletions src/cyc_std.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
namespace cyclus {

/// @brief a less-than comparison for pairs
template<class T> struct SecondLT : std::binary_function<T, T, bool> {
bool operator()(const T& x, const T& y) const {
return x.second < y.second;
}
template <class T>
struct SecondLT {
bool operator()(const T& x, const T& y) const {
return x.second < y.second;
}
};

// taken from
Expand Down
6 changes: 3 additions & 3 deletions src/discovery.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ std::set<std::string> 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;
Expand All @@ -100,8 +100,8 @@ std::set<std::string> 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;
Expand Down
21 changes: 12 additions & 9 deletions src/greedy_solver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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_;
Expand Down
23 changes: 0 additions & 23 deletions src/pyhooks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -128,8 +107,6 @@ void PyAppendInitTab(void) {};

void PyImportInit(void) {};

void PyImportCallInit(void) {};

void PyStart(void) {};

void PyStop(void) {};
Expand Down
3 changes: 0 additions & 3 deletions src/pyhooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
17 changes: 10 additions & 7 deletions src/resource_exchange.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ class ResourceExchange {
std::for_each(
traders_.begin(),
traders_.end(),
std::bind1st(std::mem_fun(&cyclus::ResourceExchange<T>::AddRequests_),
this));
std::bind(&cyclus::ResourceExchange<T>::AddRequests_,
this,
std::placeholders::_1));
}

/// @brief queries traders and collects all responses to requests for bids
Expand All @@ -87,8 +88,9 @@ class ResourceExchange {
std::for_each(
traders_.begin(),
traders_.end(),
std::bind1st(std::mem_fun(&cyclus::ResourceExchange<T>::AddBids_),
this));
std::bind(&cyclus::ResourceExchange<T>::AddBids_,
this,
std::placeholders::_1));
}

/// @brief adjust preferences for requests given bid responses
Expand All @@ -98,9 +100,10 @@ class ResourceExchange {
std::for_each(
traders.begin(),
traders.end(),
std::bind1st(
std::mem_fun(&cyclus::ResourceExchange<T>::AdjustPrefs_),
this));
std::bind(
&cyclus::ResourceExchange<T>::AdjustPrefs_,
this,
std::placeholders::_1));
}

/// return true if this is an empty exchange (i.e., no requests exist,
Expand Down

0 comments on commit eee2828

Please sign in to comment.