Removing std::cout debugging statements
This commit is contained in:
parent
c9d5251c71
commit
8f060dc87b
|
@ -69,17 +69,14 @@ void GameEngine::run()
|
||||||
|
|
||||||
void GameEngine::manageTimer(std::string name, PyObject* target, int interval)
|
void GameEngine::manageTimer(std::string name, PyObject* target, int interval)
|
||||||
{
|
{
|
||||||
//std::cout << "Manage timer called. " << name << " " << interval << std::endl;
|
|
||||||
auto it = timers.find(name);
|
auto it = timers.find(name);
|
||||||
if (it != timers.end()) // overwrite existing
|
if (it != timers.end()) // overwrite existing
|
||||||
{
|
{
|
||||||
if (target == NULL || target == Py_None) // delete
|
if (target == NULL || target == Py_None)
|
||||||
{
|
{
|
||||||
//Py_DECREF(timers[name].target);
|
// Delete: Overwrite existing timer with one that calls None. This will be deleted in the next timer check
|
||||||
std::cout << "Erasing a timer" << std::endl;
|
// see gitea issue #4: this allows for a timer to be deleted during its own call to itself
|
||||||
//timers.erase(it);
|
|
||||||
timers[name] = std::make_shared<PyTimerCallable>(Py_None, 1000, runtime.getElapsedTime().asMilliseconds());
|
timers[name] = std::make_shared<PyTimerCallable>(Py_None, 1000, runtime.getElapsedTime().asMilliseconds());
|
||||||
std::cout << "It was erased" << std::endl;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,13 +86,11 @@ void GameEngine::manageTimer(std::string name, PyObject* target, int interval)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
timers[name] = std::make_shared<PyTimerCallable>(target, interval, runtime.getElapsedTime().asMilliseconds());
|
timers[name] = std::make_shared<PyTimerCallable>(target, interval, runtime.getElapsedTime().asMilliseconds());
|
||||||
//Py_INCREF(target);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameEngine::testTimers()
|
void GameEngine::testTimers()
|
||||||
{
|
{
|
||||||
int now = runtime.getElapsedTime().asMilliseconds();
|
int now = runtime.getElapsedTime().asMilliseconds();
|
||||||
//for (auto& [name, timer]: timers)
|
|
||||||
auto it = timers.begin();
|
auto it = timers.begin();
|
||||||
while (it != timers.end())
|
while (it != timers.end())
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,10 +3,6 @@
|
||||||
PyCallable::PyCallable(PyObject* _target)
|
PyCallable::PyCallable(PyObject* _target)
|
||||||
{
|
{
|
||||||
target = Py_XNewRef(_target);
|
target = Py_XNewRef(_target);
|
||||||
if (target)
|
|
||||||
{
|
|
||||||
//std::cout << PyUnicode_AsUTF8(PyObject_Repr(target)) << std::endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PyCallable::~PyCallable()
|
PyCallable::~PyCallable()
|
||||||
|
@ -17,9 +13,6 @@ PyCallable::~PyCallable()
|
||||||
|
|
||||||
PyObject* PyCallable::call(PyObject* args, PyObject* kwargs)
|
PyObject* PyCallable::call(PyObject* args, PyObject* kwargs)
|
||||||
{
|
{
|
||||||
std::cout << "Calling object with args: ";
|
|
||||||
std::cout << PyUnicode_AsUTF8(PyObject_Repr(target)) << " <- ";
|
|
||||||
std::cout << PyUnicode_AsUTF8(PyObject_Repr(args)) << std::endl;
|
|
||||||
return PyObject_Call(target, args, kwargs);
|
return PyObject_Call(target, args, kwargs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,12 +36,10 @@ bool PyTimerCallable::hasElapsed(int now)
|
||||||
|
|
||||||
void PyTimerCallable::call(int now)
|
void PyTimerCallable::call(int now)
|
||||||
{
|
{
|
||||||
std::cout << "PyTimerCallable called. (" << (target == NULL) << ")" << std::endl;
|
|
||||||
PyObject* args = Py_BuildValue("(i)", now);
|
PyObject* args = Py_BuildValue("(i)", now);
|
||||||
PyObject* retval = PyCallable::call(args, NULL);
|
PyObject* retval = PyCallable::call(args, NULL);
|
||||||
if (!retval)
|
if (!retval)
|
||||||
{
|
{
|
||||||
std::cout << "timer has raised an exception. It's going to STDERR and being dropped:" << std::endl;
|
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
} else if (retval != Py_None)
|
} else if (retval != Py_None)
|
||||||
|
@ -60,7 +51,6 @@ void PyTimerCallable::call(int now)
|
||||||
|
|
||||||
bool PyTimerCallable::test(int now)
|
bool PyTimerCallable::test(int now)
|
||||||
{
|
{
|
||||||
std::cout << "PyTimerCallable tested. (" << (target == NULL) << ")" << interval << " " << last_ran << std::endl;
|
|
||||||
if(hasElapsed(now))
|
if(hasElapsed(now))
|
||||||
{
|
{
|
||||||
call(now);
|
call(now);
|
||||||
|
@ -109,6 +99,7 @@ PyKeyCallable::PyKeyCallable()
|
||||||
|
|
||||||
void PyKeyCallable::call(std::string key, std::string action)
|
void PyKeyCallable::call(std::string key, std::string action)
|
||||||
{
|
{
|
||||||
|
if (target == Py_None || target == NULL) return;
|
||||||
PyObject* args = Py_BuildValue("(ss)", key.c_str(), action.c_str());
|
PyObject* args = Py_BuildValue("(ss)", key.c_str(), action.c_str());
|
||||||
PyObject* retval = PyCallable::call(args, NULL);
|
PyObject* retval = PyCallable::call(args, NULL);
|
||||||
if (!retval)
|
if (!retval)
|
||||||
|
|
Loading…
Reference in New Issue