Replace autotools with CMake at the toplevel, backend now compiles with newer GCC
This commit is contained in:
parent
d50ec337d1
commit
616aef27a8
124 changed files with 1242 additions and 6315 deletions
|
@ -26,12 +26,12 @@
|
|||
using namespace sgpem;
|
||||
|
||||
// Is this OK? If not, we must use a function with a local static variable...
|
||||
PythonCPUPolicyManager* _policy_manager = NULL;
|
||||
PythonCPUPolicyManager* _policy_manager = nullptr;
|
||||
|
||||
void
|
||||
sgpem__Plugin__on_init()
|
||||
{
|
||||
if (_policy_manager == NULL)
|
||||
if (_policy_manager == nullptr)
|
||||
_policy_manager = new sgpem::PythonCPUPolicyManager();
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ void
|
|||
sgpem__Plugin__on_exit()
|
||||
{
|
||||
delete _policy_manager;
|
||||
_policy_manager = NULL;
|
||||
_policy_manager = nullptr;
|
||||
}
|
||||
|
||||
const char*
|
||||
|
|
|
@ -63,14 +63,14 @@ namespace sgpem
|
|||
// WARNING : this class needs extensive and above all
|
||||
// *strong* exception checking / handling!
|
||||
|
||||
PythonCPUPolicy::PythonCPUPolicy(const char* name) throw(MalformedPolicyException)
|
||||
PythonCPUPolicy::PythonCPUPolicy(const char* name)
|
||||
: _upolicy_dict(NULL), _adapter(NULL), _name(name), _description()
|
||||
{
|
||||
PyObject* pLoadmeStr = PyUnicode_FromString (name);
|
||||
PyObject* pUserCPUPolicyModule = PyImport_Import(pLoadmeStr);
|
||||
Py_DECREF(pLoadmeStr);
|
||||
|
||||
if (pUserCPUPolicyModule == NULL)
|
||||
if (pUserCPUPolicyModule == nullptr)
|
||||
throw MalformedPolicyException(get_exception_information());
|
||||
|
||||
// Dictionary with defined ``symbols'' for .pyc file
|
||||
|
@ -87,7 +87,7 @@ PythonCPUPolicy::PythonCPUPolicy(const char* name) throw(MalformedPolicyExceptio
|
|||
|
||||
// Now takes the user-defined policy class from pUserCPUPolicyDict
|
||||
PyObject* pCPUPolicyClass = PyDict_GetItemString(_upolicy_dict, name);
|
||||
if (pCPUPolicyClass == NULL)
|
||||
if (pCPUPolicyClass == nullptr)
|
||||
throw new MalformedPolicyException (Glib::ustring::compose (
|
||||
_("Cannot find a class named %1 into the corresponding .py file."),
|
||||
name));
|
||||
|
@ -109,7 +109,7 @@ PythonCPUPolicy::PythonCPUPolicy(const char* name) throw(MalformedPolicyExceptio
|
|||
|
||||
Py_DECREF(pScriptAdapterModule);
|
||||
|
||||
if (_adapter == NULL)
|
||||
if (_adapter == nullptr)
|
||||
throw MalformedPolicyException(get_exception_information());
|
||||
|
||||
// And now, who's your daddy, huh?
|
||||
|
@ -127,7 +127,7 @@ PythonCPUPolicy::~PythonCPUPolicy()
|
|||
}
|
||||
|
||||
void
|
||||
PythonCPUPolicy::activate() throw(UserInterruptException, MalformedPolicyException)
|
||||
PythonCPUPolicy::activate()
|
||||
{
|
||||
Glib::RecMutex::Lock lock(_mtx);;
|
||||
set_callback_policy(const_cast<PythonCPUPolicy*>(this));
|
||||
|
@ -157,12 +157,12 @@ PythonCPUPolicy::deactivate()
|
|||
|
||||
|
||||
void
|
||||
PythonCPUPolicy::configure() throw(UserInterruptException, MalformedPolicyException)
|
||||
PythonCPUPolicy::configure()
|
||||
{
|
||||
Glib::RecMutex::Lock lock(_mtx);;
|
||||
set_callback_policy(const_cast<PythonCPUPolicy*>(this));
|
||||
|
||||
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_configure"), NULL);
|
||||
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_configure"), nullptr);
|
||||
Py_DECREF(retval);
|
||||
|
||||
wait_unlock();
|
||||
|
@ -172,12 +172,12 @@ PythonCPUPolicy::configure() throw(UserInterruptException, MalformedPolicyExcept
|
|||
|
||||
|
||||
void
|
||||
PythonCPUPolicy::sort_queue() const throw(UserInterruptException, MalformedPolicyException)
|
||||
PythonCPUPolicy::sort_queue() const
|
||||
{
|
||||
Glib::RecMutex::Lock lock(_mtx);;
|
||||
set_callback_policy(const_cast<PythonCPUPolicy*>(this));
|
||||
|
||||
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_sort_queue"), NULL);
|
||||
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_sort_queue"), nullptr);
|
||||
|
||||
// Do minimal debugging
|
||||
if (!retval) PyErr_Print();
|
||||
|
@ -203,18 +203,18 @@ PythonCPUPolicy::get_name() const
|
|||
}
|
||||
|
||||
bool
|
||||
PythonCPUPolicy::is_pre_emptive() const throw(UserInterruptException, MalformedPolicyException)
|
||||
PythonCPUPolicy::is_pre_emptive() const
|
||||
{
|
||||
Glib::RecMutex::Lock lock(_mtx);;
|
||||
set_callback_policy(const_cast<PythonCPUPolicy*>(this));
|
||||
|
||||
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_is_preemptive"), NULL);
|
||||
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_is_preemptive"), nullptr);
|
||||
Py_DECREF(retval);
|
||||
|
||||
wait_unlock();
|
||||
|
||||
// Parse return value stored in global Python object
|
||||
retval = PyObject_CallMethod(_adapter, const_cast<char*>("get_return_value"), NULL);
|
||||
retval = PyObject_CallMethod(_adapter, const_cast<char*>("get_return_value"), nullptr);
|
||||
assert(retval);
|
||||
bool ret = PyObject_IsTrue(retval);
|
||||
Py_DECREF(retval);
|
||||
|
@ -225,12 +225,12 @@ PythonCPUPolicy::is_pre_emptive() const throw(UserInterruptException, MalformedP
|
|||
|
||||
|
||||
int
|
||||
PythonCPUPolicy::get_time_slice() const throw(UserInterruptException, MalformedPolicyException)
|
||||
PythonCPUPolicy::get_time_slice() const
|
||||
{
|
||||
Glib::RecMutex::Lock lock(_mtx);;
|
||||
set_callback_policy(const_cast<PythonCPUPolicy*>(this));
|
||||
|
||||
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_get_time_slice"), NULL);
|
||||
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("async_get_time_slice"), nullptr);
|
||||
|
||||
// Do minimal debugging
|
||||
if (!retval) PyErr_Print();
|
||||
|
@ -239,7 +239,7 @@ PythonCPUPolicy::get_time_slice() const throw(UserInterruptException, MalformedP
|
|||
wait_unlock();
|
||||
|
||||
// Parse return value stored in global Python object
|
||||
retval = PyObject_CallMethod(_adapter, const_cast<char*>("get_return_value"), NULL);
|
||||
retval = PyObject_CallMethod(_adapter, const_cast<char*>("get_return_value"), nullptr);
|
||||
assert(retval);
|
||||
long tmp = PyLong_AsLong(retval);
|
||||
Py_DECREF(retval);
|
||||
|
@ -250,7 +250,7 @@ PythonCPUPolicy::get_time_slice() const throw(UserInterruptException, MalformedP
|
|||
|
||||
|
||||
void
|
||||
PythonCPUPolicy::wait_unlock() const throw(UserInterruptException, MalformedPolicyException)
|
||||
PythonCPUPolicy::wait_unlock() const
|
||||
{
|
||||
// Polling time
|
||||
static const int wait_for = 150000;
|
||||
|
@ -266,7 +266,7 @@ PythonCPUPolicy::wait_unlock() const throw(UserInterruptException, MalformedPoli
|
|||
Glib::usleep(wait_for); // hack'a'ton! magggggiccc nummmbeeerrrrrs!!
|
||||
Py_BLOCK_THREADS;
|
||||
|
||||
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("mutex_test_lock"), NULL);
|
||||
PyObject* retval = PyObject_CallMethod(_adapter, const_cast<char*>("mutex_test_lock"), nullptr);
|
||||
assert(retval);
|
||||
still_locked = PyObject_IsTrue(retval);
|
||||
Py_DECREF(retval);
|
||||
|
@ -279,7 +279,7 @@ PythonCPUPolicy::wait_unlock() const throw(UserInterruptException, MalformedPoli
|
|||
Py_UNBLOCK_THREADS;
|
||||
PyEval_RestoreThread(_save);
|
||||
|
||||
if(PyErr_Occurred() != NULL)
|
||||
if(PyErr_Occurred() != nullptr)
|
||||
abort();
|
||||
|
||||
throw UserInterruptException(_("User-defined policy is "
|
||||
|
@ -290,9 +290,9 @@ PythonCPUPolicy::wait_unlock() const throw(UserInterruptException, MalformedPoli
|
|||
|
||||
// check if there were unhandled exception in the user-defined code
|
||||
|
||||
PyObject* pException = PyObject_CallMethod(_adapter, const_cast<char*>("get_last_exception"), NULL);
|
||||
PyObject* pException = PyObject_CallMethod(_adapter, const_cast<char*>("get_last_exception"), nullptr);
|
||||
|
||||
if(pException != NULL)
|
||||
if(pException != nullptr)
|
||||
{
|
||||
if(pException != Py_None)
|
||||
{
|
||||
|
@ -326,18 +326,18 @@ PythonCPUPolicy::wait_unlock() const throw(UserInterruptException, MalformedPoli
|
|||
string
|
||||
PythonCPUPolicy::get_exception_information()
|
||||
{
|
||||
if (PyErr_Occurred() == NULL)
|
||||
if (PyErr_Occurred() == nullptr)
|
||||
return _("no error");
|
||||
|
||||
PyObject* pType = NULL;
|
||||
PyObject* pValue = NULL;
|
||||
PyObject* pTraceback = NULL;
|
||||
PyObject* pType = nullptr;
|
||||
PyObject* pValue = nullptr;
|
||||
PyObject* pTraceback = nullptr;
|
||||
|
||||
PyErr_Fetch(&pType, &pValue, &pTraceback);
|
||||
|
||||
string msg;
|
||||
|
||||
if (pValue != NULL)
|
||||
if (pValue != nullptr)
|
||||
{
|
||||
msg = sgpem::PyString_AsString(pValue) + "\n";
|
||||
PyErr_PrintEx (false);
|
||||
|
@ -345,9 +345,9 @@ PythonCPUPolicy::get_exception_information()
|
|||
else
|
||||
msg = string(_("no available information for this error"));
|
||||
|
||||
if (pType != NULL) { Py_DECREF(pType); }
|
||||
if (pValue != NULL) { Py_DECREF(pValue); }
|
||||
if (pTraceback != NULL) { Py_DECREF(pTraceback); }
|
||||
if (pType != nullptr) { Py_DECREF(pType); }
|
||||
if (pValue != nullptr) { Py_DECREF(pValue); }
|
||||
if (pTraceback != nullptr) { Py_DECREF(pTraceback); }
|
||||
|
||||
PyErr_Clear();
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace sgpem
|
|||
/// @see activate().
|
||||
/// @throw an exception when the policy is malformed and therefore not usable.
|
||||
/// @param name the name of the policy
|
||||
PythonCPUPolicy(const char* name) throw(MalformedPolicyException);
|
||||
PythonCPUPolicy(const char* name);
|
||||
|
||||
/// \brief Standard virtual destructor
|
||||
///
|
||||
|
@ -89,7 +89,7 @@ namespace sgpem
|
|||
/// @throw an exception when the policy is malformed and therefore not usable,
|
||||
/// or when the policy is taking too long to terminate its work.
|
||||
/// @see ::CPUPolicy::configure().
|
||||
void configure() throw(UserInterruptException, MalformedPolicyException);
|
||||
void configure();
|
||||
|
||||
/// \brief Sorts the queue, asynchronously.
|
||||
///
|
||||
|
@ -97,7 +97,7 @@ namespace sgpem
|
|||
/// @throw an exception when the policy is malformed and therefore not usable,
|
||||
/// or when the policy is taking too long to terminate its work.
|
||||
/// @see ::CPUPolicy::sort_queue().
|
||||
void sort_queue() const throw(UserInterruptException, MalformedPolicyException);
|
||||
void sort_queue() const;
|
||||
|
||||
/// \brief Returns a textual description of the policy.
|
||||
///
|
||||
|
@ -126,7 +126,7 @@ namespace sgpem
|
|||
/// @return \c TRUE if the policy is preemptive.
|
||||
/// @return \c FALSE if the policy is not preemptive.
|
||||
/// @see ::CPUPolicy::is_pre_emptive().
|
||||
bool is_pre_emptive() const throw(UserInterruptException, MalformedPolicyException);
|
||||
bool is_pre_emptive() const;
|
||||
|
||||
/// \brief Returns the lenght of the time slice, asynchronously.
|
||||
///
|
||||
|
@ -136,7 +136,7 @@ namespace sgpem
|
|||
/// or when the policy is taking too long to terminate its work.
|
||||
/// @return the lenght of the time slice.
|
||||
/// @see ::CPUPolicy::get_time_slice().
|
||||
int get_time_slice() const throw(UserInterruptException, MalformedPolicyException);
|
||||
int get_time_slice() const;
|
||||
|
||||
/// \brief Load the corresponding Python module and initialize a new Policy object (in Python).
|
||||
///
|
||||
|
@ -144,7 +144,7 @@ namespace sgpem
|
|||
/// @throw an exception when the policy is malformed and therefore not usable,
|
||||
/// or when the policy is taking too long to terminate its work.
|
||||
/// @see ::CPUPolicy::activate().
|
||||
void activate() throw(UserInterruptException, MalformedPolicyException);
|
||||
void activate();
|
||||
|
||||
/// \brief Activates the policy.
|
||||
///
|
||||
|
@ -168,7 +168,7 @@ namespace sgpem
|
|||
/// the lock is taken again, and we check if the thread has finished via
|
||||
/// the mutex present in ::ScriptAdapter. If so, wait_unlock() terminates
|
||||
/// successfully. Else it stays in its main loop.
|
||||
void wait_unlock() const throw(UserInterruptException, MalformedPolicyException);
|
||||
void wait_unlock() const;
|
||||
|
||||
/// \brief Returns a brief description of a thrown exception.
|
||||
/// Returns the description of the exception occurred.
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
#include <sgpemv2/global_preferences.hh>
|
||||
#include <sgpemv2/cpu_policies_gatekeeper.hh>
|
||||
|
||||
#include <sgpemv2/templates/deletor.tcc>
|
||||
|
||||
#include <glibmm/ustring.h>
|
||||
#include <glibmm/timer.h>
|
||||
#include <glibmm/fileutils.h>
|
||||
|
@ -104,7 +102,7 @@ PythonCPUPolicyManager::PythonCPUPolicyManager()
|
|||
|
||||
PythonCPUPolicyManager::~PythonCPUPolicyManager()
|
||||
{
|
||||
for_each(_policies.begin(), _policies.end(), memory::deletor<CPUPolicy>());
|
||||
for_each(_policies.begin(), _policies.end(), [] (auto *p) { delete p; });
|
||||
}
|
||||
|
||||
|
||||
|
@ -124,7 +122,7 @@ PythonCPUPolicyManager::collect_policies()
|
|||
for (; dir_it != dir_end; ++dir_it)
|
||||
{
|
||||
Glib::Dir dir(*dir_it);
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
std::clog << "Opening directory " << *dir_it << " looking for python policies..." << endl;
|
||||
#endif
|
||||
|
@ -137,7 +135,7 @@ PythonCPUPolicyManager::collect_policies()
|
|||
if (dot_py.match(*file_it))
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
std::clog << *file_it << " appears to be a Python script. Attempting to load..." << std::endl;
|
||||
std::clog << *file_it << " appears to be a Python script. Attempting to load..." << std::endl;
|
||||
#endif
|
||||
//strip extension
|
||||
std::string policy_name = (*file_it).substr(0, (*file_it).size() - 3);
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace sgpem {
|
|||
virtual ~CPUPolicy() = 0;
|
||||
sgpem::PolicyParameters& get_parameters();
|
||||
|
||||
static CPUPolicy* callback_get_policy() throw(std::runtime_error);
|
||||
static CPUPolicy* callback_get_policy();
|
||||
};
|
||||
|
||||
// --------------------------------------------
|
||||
|
@ -237,8 +237,8 @@ namespace sgpem {
|
|||
|
||||
sgpem::Thread& get_item_at(position index);
|
||||
|
||||
void swap(position a, position b) throw(std::out_of_range);
|
||||
void bubble_to_front(position x) throw(std::out_of_range);
|
||||
void swap(position a, position b);
|
||||
void bubble_to_front(position x);
|
||||
|
||||
private:
|
||||
// Avoid instantiation and copy
|
||||
|
|
|
@ -49,7 +49,7 @@ find_pol_by_name(const vector<CPUPolicy*>& pols, const Glib::ustring& name)
|
|||
for ( ; it != pols.end(); it++)
|
||||
if ((*it)->get_name() == name)
|
||||
return *it;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
@ -89,7 +89,7 @@ main(int argc, char** argv)
|
|||
try
|
||||
{
|
||||
CPUPolicy* pol = find_pol_by_name(policies, "python_loader_configure");
|
||||
assert(pol != NULL);
|
||||
assert(pol != nullptr);
|
||||
|
||||
// activate_policy will also configure the policy
|
||||
pgk.activate_policy(&his, pol);
|
||||
|
@ -104,7 +104,7 @@ main(int argc, char** argv)
|
|||
try
|
||||
{
|
||||
CPUPolicy* pol = find_pol_by_name(policies, "python_loader_is_preemptive");
|
||||
assert(pol != NULL);
|
||||
assert(pol != nullptr);
|
||||
pgk.activate_policy(&his, pol);
|
||||
pol->is_pre_emptive();
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ main(int argc, char** argv)
|
|||
try
|
||||
{
|
||||
CPUPolicy* pol = find_pol_by_name(policies, "python_loader_get_time_slice");
|
||||
assert(pol != NULL);
|
||||
assert(pol != nullptr);
|
||||
pgk.activate_policy(&his, pol);
|
||||
pol->get_time_slice();
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ main(int argc, char** argv)
|
|||
try
|
||||
{
|
||||
CPUPolicy* pol = find_pol_by_name(policies, "python_loader_get_time_slice");
|
||||
assert(pol != NULL);
|
||||
assert(pol != nullptr);
|
||||
pgk.activate_policy(&his, pol);
|
||||
pol->sort_queue();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue