📄 ambulantinterface.cpp
字号:
PySys_WriteStderr("Python exception during timer_control::start() callback:\n"); PyErr_Print(); } Py_XDECREF(py_rv); Py_XDECREF(py_t); PyGILState_Release(_GILState);}void timer_control::stop(){ PyGILState_STATE _GILState = PyGILState_Ensure(); PyObject *py_rv = PyObject_CallMethod(py_timer_control, "stop", "()"); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during timer_control::stop() callback:\n"); PyErr_Print(); } Py_XDECREF(py_rv); PyGILState_Release(_GILState);}void timer_control::pause(){ PyGILState_STATE _GILState = PyGILState_Ensure(); PyObject *py_rv = PyObject_CallMethod(py_timer_control, "pause", "()"); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during timer_control::pause() callback:\n"); PyErr_Print(); } Py_XDECREF(py_rv); PyGILState_Release(_GILState);}void timer_control::resume(){ PyGILState_STATE _GILState = PyGILState_Ensure(); PyObject *py_rv = PyObject_CallMethod(py_timer_control, "resume", "()"); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during timer_control::resume() callback:\n"); PyErr_Print(); } Py_XDECREF(py_rv); PyGILState_Release(_GILState);}void timer_control::set_speed(double speed){ PyGILState_STATE _GILState = PyGILState_Ensure(); PyObject *py_speed = Py_BuildValue("d", speed); PyObject *py_rv = PyObject_CallMethod(py_timer_control, "set_speed", "(O)", py_speed); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during timer_control::set_speed() callback:\n"); PyErr_Print(); } Py_XDECREF(py_rv); Py_XDECREF(py_speed); PyGILState_Release(_GILState);}void timer_control::set_time(ambulant::lib::timer::time_type t){ PyGILState_STATE _GILState = PyGILState_Ensure(); PyObject *py_t = Py_BuildValue("l", t); PyObject *py_rv = PyObject_CallMethod(py_timer_control, "set_time", "(O)", py_t); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during timer_control::set_time() callback:\n"); PyErr_Print(); } Py_XDECREF(py_rv); Py_XDECREF(py_t); PyGILState_Release(_GILState);}double timer_control::get_speed() const{ PyGILState_STATE _GILState = PyGILState_Ensure(); double _rv; PyObject *py_rv = PyObject_CallMethod(py_timer_control, "get_speed", "()"); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during timer_control::get_speed() callback:\n"); PyErr_Print(); } if (py_rv && !PyArg_Parse(py_rv, "d", &_rv)) { PySys_WriteStderr("Python exception during timer_control::get_speed() return:\n"); PyErr_Print(); } Py_XDECREF(py_rv); PyGILState_Release(_GILState); return _rv;}bool timer_control::running() const{ PyGILState_STATE _GILState = PyGILState_Ensure(); bool _rv; PyObject *py_rv = PyObject_CallMethod(py_timer_control, "running", "()"); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during timer_control::running() callback:\n"); PyErr_Print(); } if (py_rv && !PyArg_Parse(py_rv, "O&", bool_Convert, &_rv)) { PySys_WriteStderr("Python exception during timer_control::running() return:\n"); PyErr_Print(); } Py_XDECREF(py_rv); PyGILState_Release(_GILState); return _rv;}double timer_control::get_realtime_speed() const{ PyGILState_STATE _GILState = PyGILState_Ensure(); double _rv; PyObject *py_rv = PyObject_CallMethod(py_timer_control, "get_realtime_speed", "()"); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during timer_control::get_realtime_speed() callback:\n"); PyErr_Print(); } if (py_rv && !PyArg_Parse(py_rv, "d", &_rv)) { PySys_WriteStderr("Python exception during timer_control::get_realtime_speed() return:\n"); PyErr_Print(); } Py_XDECREF(py_rv); PyGILState_Release(_GILState); return _rv;}/* ------------------------- Class embedder ------------------------- */embedder::embedder(PyObject *itself): ::system_embedder(itself){ PyGILState_STATE _GILState = PyGILState_Ensure(); if (itself) { if (!PyObject_HasAttrString(itself, "close")) PyErr_Warn(PyExc_Warning, "embedder: missing attribute: close"); if (!PyObject_HasAttrString(itself, "open")) PyErr_Warn(PyExc_Warning, "embedder: missing attribute: open"); if (!PyObject_HasAttrString(itself, "done")) PyErr_Warn(PyExc_Warning, "embedder: missing attribute: done"); if (!PyObject_HasAttrString(itself, "starting")) PyErr_Warn(PyExc_Warning, "embedder: missing attribute: starting"); if (!PyObject_HasAttrString(itself, "aux_open")) PyErr_Warn(PyExc_Warning, "embedder: missing attribute: aux_open"); } if (itself == NULL) itself = Py_None; py_embedder = itself; Py_XINCREF(itself); PyGILState_Release(_GILState);}embedder::~embedder(){ PyGILState_STATE _GILState = PyGILState_Ensure(); Py_XDECREF(py_embedder); py_embedder = NULL; PyGILState_Release(_GILState);}void embedder::close(ambulant::common::player* p){ PyGILState_STATE _GILState = PyGILState_Ensure(); PyObject *py_p = Py_BuildValue("O&", playerObj_New, p); PyObject *py_rv = PyObject_CallMethod(py_embedder, "close", "(O)", py_p); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during embedder::close() callback:\n"); PyErr_Print(); } Py_XDECREF(py_rv); Py_XDECREF(py_p); PyGILState_Release(_GILState);}void embedder::open(ambulant::net::url newdoc, bool start, ambulant::common::player* old){ PyGILState_STATE _GILState = PyGILState_Ensure(); PyObject *py_newdoc = Py_BuildValue("O", ambulant_url_New(newdoc)); PyObject *py_start = Py_BuildValue("O&", bool_New, start); PyObject *py_old = Py_BuildValue("O&", playerObj_New, old); PyObject *py_rv = PyObject_CallMethod(py_embedder, "open", "(OOO)", py_newdoc, py_start, py_old); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during embedder::open() callback:\n"); PyErr_Print(); } Py_XDECREF(py_rv); Py_XDECREF(py_newdoc); Py_XDECREF(py_start); Py_XDECREF(py_old); PyGILState_Release(_GILState);}void embedder::done(ambulant::common::player* p){ PyGILState_STATE _GILState = PyGILState_Ensure(); PyObject *py_p = Py_BuildValue("O&", playerObj_New, p); PyObject *py_rv = PyObject_CallMethod(py_embedder, "done", "(O)", py_p); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during embedder::done() callback:\n"); PyErr_Print(); } Py_XDECREF(py_rv); Py_XDECREF(py_p); PyGILState_Release(_GILState);}void embedder::starting(ambulant::common::player* p){ PyGILState_STATE _GILState = PyGILState_Ensure(); PyObject *py_p = Py_BuildValue("O&", playerObj_New, p); PyObject *py_rv = PyObject_CallMethod(py_embedder, "starting", "(O)", py_p); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during embedder::starting() callback:\n"); PyErr_Print(); } Py_XDECREF(py_rv); Py_XDECREF(py_p); PyGILState_Release(_GILState);}bool embedder::aux_open(const ambulant::net::url& href){ PyGILState_STATE _GILState = PyGILState_Ensure(); bool _rv; PyObject *py_href = Py_BuildValue("O", ambulant_url_New(href)); PyObject *py_rv = PyObject_CallMethod(py_embedder, "aux_open", "(O)", py_href); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during embedder::aux_open() callback:\n"); PyErr_Print(); } if (py_rv && !PyArg_Parse(py_rv, "O&", bool_Convert, &_rv)) { PySys_WriteStderr("Python exception during embedder::aux_open() return:\n"); PyErr_Print(); } Py_XDECREF(py_rv); Py_XDECREF(py_href); PyGILState_Release(_GILState); return _rv;}/* ------------------------ Class factories ------------------------- */factories::factories(PyObject *itself){ PyGILState_STATE _GILState = PyGILState_Ensure(); if (itself) { if (!PyObject_HasAttrString(itself, "init_factories")) PyErr_Warn(PyExc_Warning, "factories: missing attribute: init_factories"); if (!PyObject_HasAttrString(itself, "init_playable_factory")) PyErr_Warn(PyExc_Warning, "factories: missing attribute: init_playable_factory"); if (!PyObject_HasAttrString(itself, "init_window_factory")) PyErr_Warn(PyExc_Warning, "factories: missing attribute: init_window_factory"); if (!PyObject_HasAttrString(itself, "init_datasource_factory")) PyErr_Warn(PyExc_Warning, "factories: missing attribute: init_datasource_factory"); if (!PyObject_HasAttrString(itself, "init_parser_factory")) PyErr_Warn(PyExc_Warning, "factories: missing attribute: init_parser_factory"); if (!PyObject_HasAttrString(itself, "init_node_factory")) PyErr_Warn(PyExc_Warning, "factories: missing attribute: init_node_factory"); if (!PyObject_HasAttrString(itself, "get_playable_factory")) PyErr_Warn(PyExc_Warning, "factories: missing attribute: get_playable_factory"); if (!PyObject_HasAttrString(itself, "get_window_factory")) PyErr_Warn(PyExc_Warning, "factories: missing attribute: get_window_factory"); if (!PyObject_HasAttrString(itself, "get_datasource_factory")) PyErr_Warn(PyExc_Warning, "factories: missing attribute: get_datasource_factory"); if (!PyObject_HasAttrString(itself, "get_parser_factory")) PyErr_Warn(PyExc_Warning, "factories: missing attribute: get_parser_factory"); if (!PyObject_HasAttrString(itself, "get_node_factory")) PyErr_Warn(PyExc_Warning, "factories: missing attribute: get_node_factory"); if (!PyObject_HasAttrString(itself, "set_playable_factory")) PyErr_Warn(PyExc_Warning, "factories: missing attribute: set_playable_factory"); if (!PyObject_HasAttrString(itself, "set_window_factory")) PyErr_Warn(PyExc_Warning, "factories: missing attribute: set_window_factory"); if (!PyObject_HasAttrString(itself, "set_datasource_factory")) PyErr_Warn(PyExc_Warning, "factories: missing attribute: set_datasource_factory"); if (!PyObject_HasAttrString(itself, "set_parser_factory")) PyErr_Warn(PyExc_Warning, "factories: missing attribute: set_parser_factory"); if (!PyObject_HasAttrString(itself, "set_node_factory")) PyErr_Warn(PyExc_Warning, "factories: missing attribute: set_node_factory"); } if (itself == NULL) itself = Py_None; py_factories = itself; Py_XINCREF(itself); PyGILState_Release(_GILState);}factories::~factories(){ PyGILState_STATE _GILState = PyGILState_Ensure(); Py_XDECREF(py_factories); py_factories = NULL; PyGILState_Release(_GILState);}void factories::init_factories(){ PyGILState_STATE _GILState = PyGILState_Ensure(); PyObject *py_rv = PyObject_CallMethod(py_factories, "init_factories", "()"); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during factories::init_factories() callback:\n"); PyErr_Print(); } Py_XDECREF(py_rv); PyGILState_Release(_GILState);}void factories::init_playable_factory(){ PyGILState_STATE _GILState = PyGILState_Ensure(); PyObject *py_rv = PyObject_CallMethod(py_factories, "init_playable_factory", "()"); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during factories::init_playable_factory() callback:\n"); PyErr_Print(); } Py_XDECREF(py_rv); PyGILState_Release(_GILState);}void factories::init_window_factory(){ PyGILState_STATE _GILState = PyGILState_Ensure(); PyObject *py_rv = PyObject_CallMethod(py_factories, "init_window_factory", "()"); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during factories::init_window_factory() callback:\n"); PyErr_Print(); } Py_XDECREF(py_rv); PyGILState_Release(_GILState);}void factories::init_datasource_factory(){ PyGILState_STATE _GILState = PyGILState_Ensure(); PyObject *py_rv = PyObject_CallMethod(py_factories, "init_datasource_factory", "()"); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during factories::init_datasource_factory() callback:\n"); PyErr_Print(); } Py_XDECREF(py_rv); PyGILState_Release(_GILState);}void factories::init_parser_factory(){ PyGILState_STATE _GILState = PyGILState_Ensure(); PyObject *py_rv = PyObject_CallMethod(py_factories, "init_parser_factory", "()"); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during factories::init_parser_factory() callback:\n"); PyErr_Print(); } Py_XDECREF(py_rv); PyGILState_Release(_GILState);}void factories::init_node_factory(){ PyGILState_STATE _GILState = PyGILState_Ensure(); PyObject *py_rv = PyObject_CallMethod(py_factories, "init_node_factory", "()"); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during factories::init_node_factory() callback:\n"); PyErr_Print(); } Py_XDECREF(py_rv); PyGILState_Release(_GILState);}ambulant::common::global_playable_factory* factories::get_playable_factory() const{ PyGILState_STATE _GILState = PyGILState_Ensure(); ambulant::common::global_playable_factory* _rv; PyObject *py_rv = PyObject_CallMethod(py_factories, "get_playable_factory", "()"); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during factories::get_playable_factory() callback:\n"); PyErr_Print(); } if (py_rv && !PyArg_Parse(py_rv, "O&", global_playable_factoryObj_Convert, &_rv)) { PySys_WriteStderr("Python exception during factories::get_playable_factory() return:\n"); PyErr_Print(); } Py_XDECREF(py_rv); PyGILState_Release(_GILState); return _rv;}ambulant::common::window_factory* factories::get_window_factory() const{ PyGILState_STATE _GILState = PyGILState_Ensure(); ambulant::common::window_factory* _rv; PyObject *py_rv = PyObject_CallMethod(py_factories, "get_window_factory", "()"); if (PyErr_Occurred()) { PySys_WriteStderr("Python exception during factories::get_window_factory() callback
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -