+ PyObject *arglist;
+ PyObject *result;
+
+ assert(action >= 0 && action < OBActions::NUM_ACTIONS);
+
+ if (d4 != LONG_MIN)
+ arglist = Py_BuildValue("iliillll", action, window, type, state,
+ d1, d2, d3, d4);
+ else if (d3 != LONG_MIN)
+ arglist = Py_BuildValue("iliilll", action, window, type, state,
+ d1, d2, d3);
+ else if (d2 != LONG_MIN)
+ arglist = Py_BuildValue("iliill", action, window, type, state, d1, d2);
+ else if (d1 != LONG_MIN)
+ arglist = Py_BuildValue("iliil", action, window, type, state, d1);
+ else
+ arglist = Py_BuildValue("ilii", action, window, type, state);
+
+ FunctionList::iterator it, end = callbacks[action].end();
+ for (it = callbacks[action].begin(); it != end; ++it) {
+ // call the callback
+ result = PyEval_CallObject(*it, arglist);
+ if (result) {
+ Py_DECREF(result);
+ } else {
+ // an exception occured in the script, display it
+ PyErr_Print();
+ }
+ }
+
+ Py_DECREF(arglist);