⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ambulantinterface.cpp

📁 彩信浏览器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
	return _rv;}const ambulant::lib::xml_string& node::get_data() const{	PyGILState_STATE _GILState = PyGILState_Ensure();	ambulant::lib::xml_string get_data;	PyObject *py_rv = PyObject_CallMethod(py_node, "get_data", "()");	if (PyErr_Occurred())	{		PySys_WriteStderr("Python exception during node::get_data() callback:\n");		PyErr_Print();	}	char *get_data_cstr;	if (py_rv && !PyArg_Parse(py_rv, "s", &get_data_cstr))	{		PySys_WriteStderr("Python exception during node::get_data() return:\n");		PyErr_Print();	}	get_data = get_data_cstr;	Py_XDECREF(py_rv);	PyGILState_Release(_GILState);	const_cast<node *>(this)->get_data_rvkeepref = get_data;	return get_data_rvkeepref;}ambulant::lib::xml_string node::get_trimmed_data() const{	PyGILState_STATE _GILState = PyGILState_Ensure();	ambulant::lib::xml_string _rv;	PyObject *py_rv = PyObject_CallMethod(py_node, "get_trimmed_data", "()");	if (PyErr_Occurred())	{		PySys_WriteStderr("Python exception during node::get_trimmed_data() callback:\n");		PyErr_Print();	}	char *_rv_cstr;	if (py_rv && !PyArg_Parse(py_rv, "s", &_rv_cstr))	{		PySys_WriteStderr("Python exception during node::get_trimmed_data() return:\n");		PyErr_Print();	}	_rv = _rv_cstr;	Py_XDECREF(py_rv);	PyGILState_Release(_GILState);	return _rv;}const char * node::get_attribute(const char* name) const{	PyGILState_STATE _GILState = PyGILState_Ensure();	const char * _rv;	PyObject *py_name = Py_BuildValue("s", name);	PyObject *py_rv = PyObject_CallMethod(py_node, "get_attribute", "(O)", py_name);	if (PyErr_Occurred())	{		PySys_WriteStderr("Python exception during node::get_attribute() callback:\n");		PyErr_Print();	}	if (py_rv && !PyArg_Parse(py_rv, "z", &_rv))	{		PySys_WriteStderr("Python exception during node::get_attribute() return:\n");		PyErr_Print();	}	Py_XDECREF(py_rv);	Py_XDECREF(py_name);	PyGILState_Release(_GILState);	return _rv;}const char * node::get_attribute(const std::string& name) const{	PyGILState_STATE _GILState = PyGILState_Ensure();	const char * _rv;	PyObject *py_name = Py_BuildValue("s", name.c_str());	PyObject *py_rv = PyObject_CallMethod(py_node, "get_attribute", "(O)", py_name);	if (PyErr_Occurred())	{		PySys_WriteStderr("Python exception during node::get_attribute() callback:\n");		PyErr_Print();	}	if (py_rv && !PyArg_Parse(py_rv, "z", &_rv))	{		PySys_WriteStderr("Python exception during node::get_attribute() return:\n");		PyErr_Print();	}	Py_XDECREF(py_rv);	Py_XDECREF(py_name);	PyGILState_Release(_GILState);	return _rv;}void node::del_attribute(const char* name){	PyGILState_STATE _GILState = PyGILState_Ensure();	PyObject *py_name = Py_BuildValue("s", name);	PyObject *py_rv = PyObject_CallMethod(py_node, "del_attribute", "(O)", py_name);	if (PyErr_Occurred())	{		PySys_WriteStderr("Python exception during node::del_attribute() callback:\n");		PyErr_Print();	}	Py_XDECREF(py_rv);	Py_XDECREF(py_name);	PyGILState_Release(_GILState);}ambulant::net::url node::get_url(const char* attrname) const{	PyGILState_STATE _GILState = PyGILState_Ensure();	ambulant::net::url _rv;	PyObject *py_attrname = Py_BuildValue("s", attrname);	PyObject *py_rv = PyObject_CallMethod(py_node, "get_url", "(O)", py_attrname);	if (PyErr_Occurred())	{		PySys_WriteStderr("Python exception during node::get_url() callback:\n");		PyErr_Print();	}	if (py_rv && !PyArg_Parse(py_rv, "O&", ambulant_url_Convert, &_rv))	{		PySys_WriteStderr("Python exception during node::get_url() return:\n");		PyErr_Print();	}	Py_XDECREF(py_rv);	Py_XDECREF(py_attrname);	PyGILState_Release(_GILState);	return _rv;}unsigned int node::size() const{	PyGILState_STATE _GILState = PyGILState_Ensure();	unsigned int _rv;	PyObject *py_rv = PyObject_CallMethod(py_node, "size", "()");	if (PyErr_Occurred())	{		PySys_WriteStderr("Python exception during node::size() callback:\n");		PyErr_Print();	}	if (py_rv && !PyArg_Parse(py_rv, "l", &_rv))	{		PySys_WriteStderr("Python exception during node::size() return:\n");		PyErr_Print();	}	Py_XDECREF(py_rv);	PyGILState_Release(_GILState);	return _rv;}std::string node::get_path_display_desc() const{	PyGILState_STATE _GILState = PyGILState_Ensure();	std::string _rv;	PyObject *py_rv = PyObject_CallMethod(py_node, "get_path_display_desc", "()");	if (PyErr_Occurred())	{		PySys_WriteStderr("Python exception during node::get_path_display_desc() callback:\n");		PyErr_Print();	}	char *_rv_cstr;	if (py_rv && !PyArg_Parse(py_rv, "s", &_rv_cstr))	{		PySys_WriteStderr("Python exception during node::get_path_display_desc() return:\n");		PyErr_Print();	}	_rv = _rv_cstr;	Py_XDECREF(py_rv);	PyGILState_Release(_GILState);	return _rv;}std::string node::get_sig() const{	PyGILState_STATE _GILState = PyGILState_Ensure();	std::string _rv;	PyObject *py_rv = PyObject_CallMethod(py_node, "get_sig", "()");	if (PyErr_Occurred())	{		PySys_WriteStderr("Python exception during node::get_sig() callback:\n");		PyErr_Print();	}	char *_rv_cstr;	if (py_rv && !PyArg_Parse(py_rv, "s", &_rv_cstr))	{		PySys_WriteStderr("Python exception during node::get_sig() return:\n");		PyErr_Print();	}	_rv = _rv_cstr;	Py_XDECREF(py_rv);	PyGILState_Release(_GILState);	return _rv;}ambulant::lib::xml_string node::xmlrepr() const{	PyGILState_STATE _GILState = PyGILState_Ensure();	ambulant::lib::xml_string _rv;	PyObject *py_rv = PyObject_CallMethod(py_node, "xmlrepr", "()");	if (PyErr_Occurred())	{		PySys_WriteStderr("Python exception during node::xmlrepr() callback:\n");		PyErr_Print();	}	char *_rv_cstr;	if (py_rv && !PyArg_Parse(py_rv, "s", &_rv_cstr))	{		PySys_WriteStderr("Python exception during node::xmlrepr() return:\n");		PyErr_Print();	}	_rv = _rv_cstr;	Py_XDECREF(py_rv);	PyGILState_Release(_GILState);	return _rv;}const ambulant::lib::node_context* node::get_context() const{	PyGILState_STATE _GILState = PyGILState_Ensure();	const ambulant::lib::node_context* _rv;	PyObject *py_rv = PyObject_CallMethod(py_node, "get_context", "()");	if (PyErr_Occurred())	{		PySys_WriteStderr("Python exception during node::get_context() callback:\n");		PyErr_Print();	}	if (py_rv && !PyArg_Parse(py_rv, "O&", node_contextObj_Convert, &_rv))	{		PySys_WriteStderr("Python exception during node::get_context() return:\n");		PyErr_Print();	}	Py_XDECREF(py_rv);	PyGILState_Release(_GILState);	return _rv;}void node::set_context(ambulant::lib::node_context* c){	PyGILState_STATE _GILState = PyGILState_Ensure();	PyObject *py_c = Py_BuildValue("O&", node_contextObj_New, c);	PyObject *py_rv = PyObject_CallMethod(py_node, "set_context", "(O)", py_c);	if (PyErr_Occurred())	{		PySys_WriteStderr("Python exception during node::set_context() callback:\n");		PyErr_Print();	}	Py_XDECREF(py_rv);	Py_XDECREF(py_c);	PyGILState_Release(_GILState);}/* ----------------------- Class node_factory ----------------------- */node_factory::node_factory(PyObject *itself){	PyGILState_STATE _GILState = PyGILState_Ensure();	if (itself)	{		if (!PyObject_HasAttrString(itself, "new_node")) PyErr_Warn(PyExc_Warning, "node_factory: missing attribute: new_node");		if (!PyObject_HasAttrString(itself, "new_node")) PyErr_Warn(PyExc_Warning, "node_factory: missing attribute: new_node");	}	if (itself == NULL) itself = Py_None;	py_node_factory = itself;	Py_XINCREF(itself);	PyGILState_Release(_GILState);}node_factory::~node_factory(){	PyGILState_STATE _GILState = PyGILState_Ensure();	Py_XDECREF(py_node_factory);	py_node_factory = NULL;	PyGILState_Release(_GILState);}ambulant::lib::node* node_factory::new_node(const ambulant::lib::q_name_pair& qn, const ambulant::lib::q_attributes_list& qattrs, const ambulant::lib::node_context* ctx){	PyGILState_STATE _GILState = PyGILState_Ensure();	ambulant::lib::node* _rv;	PyObject *py_qn = Py_BuildValue("(ss)", qn.first.c_str(), qn.second.c_str());	PyObject *py_qattrs = Py_BuildValue("O", ambulant_attributes_list_New(qattrs));	PyObject *py_ctx = Py_BuildValue("O&", node_contextObj_New, ctx);	PyObject *py_rv = PyObject_CallMethod(py_node_factory, "new_node", "(OOO)", py_qn, py_qattrs, py_ctx);	if (PyErr_Occurred())	{		PySys_WriteStderr("Python exception during node_factory::new_node() callback:\n");		PyErr_Print();	}	if (py_rv && !PyArg_Parse(py_rv, "O&", nodeObj_Convert, &_rv))	{		PySys_WriteStderr("Python exception during node_factory::new_node() return:\n");		PyErr_Print();	}	Py_XDECREF(py_rv);	Py_XDECREF(py_qn);	Py_XDECREF(py_qattrs);	Py_XDECREF(py_ctx);	PyGILState_Release(_GILState);	return _rv;}ambulant::lib::node* node_factory::new_node(const ambulant::lib::node* other){	PyGILState_STATE _GILState = PyGILState_Ensure();	ambulant::lib::node* _rv;	PyObject *py_other = Py_BuildValue("O&", nodeObj_New, other);	PyObject *py_rv = PyObject_CallMethod(py_node_factory, "new_node", "(O)", py_other);	if (PyErr_Occurred())	{		PySys_WriteStderr("Python exception during node_factory::new_node() callback:\n");		PyErr_Print();	}	if (py_rv && !PyArg_Parse(py_rv, "O&", nodeObj_Convert, &_rv))	{		PySys_WriteStderr("Python exception during node_factory::new_node() return:\n");		PyErr_Print();	}	Py_XDECREF(py_rv);	Py_XDECREF(py_other);	PyGILState_Release(_GILState);	return _rv;}/* -------------------------- Class event --------------------------- */event::event(PyObject *itself){	PyGILState_STATE _GILState = PyGILState_Ensure();	if (itself)	{		if (!PyObject_HasAttrString(itself, "fire")) PyErr_Warn(PyExc_Warning, "event: missing attribute: fire");	}	if (itself == NULL) itself = Py_None;	py_event = itself;	Py_XINCREF(itself);	PyGILState_Release(_GILState);}event::~event(){	PyGILState_STATE _GILState = PyGILState_Ensure();	Py_XDECREF(py_event);	py_event = NULL;	PyGILState_Release(_GILState);}void event::fire(){	PyGILState_STATE _GILState = PyGILState_Ensure();	PyObject *py_rv = PyObject_CallMethod(py_event, "fire", "()");	if (PyErr_Occurred())	{		PySys_WriteStderr("Python exception during event::fire() callback:\n");		PyErr_Print();	}	Py_XDECREF(py_rv);	PyGILState_Release(_GILState);}/* --------------------- Class event_processor ---------------------- */event_processor::event_processor(PyObject *itself){	PyGILState_STATE _GILState = PyGILState_Ensure();	if (itself)	{		if (!PyObject_HasAttrString(itself, "add_event")) PyErr_Warn(PyExc_Warning, "event_processor: missing attribute: add_event");		if (!PyObject_HasAttrString(itself, "cancel_all_events")) PyErr_Warn(PyExc_Warning, "event_processor: missing attribute: cancel_all_events");		if (!PyObject_HasAttrString(itself, "cancel_event")) PyErr_Warn(PyExc_Warning, "event_processor: missing attribute: cancel_event");		if (!PyObject_HasAttrString(itself, "serve_events")) PyErr_Warn(PyExc_Warning, "event_processor: missing attribute: serve_events");		if (!PyObject_HasAttrString(itself, "get_timer")) PyErr_Warn(PyExc_Warning, "event_processor: missing attribute: get_timer");		if (!PyObject_HasAttrString(itself, "stop_processor_thread")) PyErr_Warn(PyExc_Warning, "event_processor: missing attribute: stop_processor_thread");	}	if (itself == NULL) itself = Py_None;	py_event_processor = itself;	Py_XINCREF(itself);	PyGILState_Release(_GILState);}event_processor::~event_processor(){	PyGILState_STATE _GILState = PyGILState_Ensure();	Py_XDECREF(py_event_processor);	py_event_processor = NULL;	PyGILState_Release(_GILState);}void event_processor::add_event(ambulant::lib::event* pe, ambulant::lib::timer::time_type t, ambulant::lib::event_priority priority){	PyGILState_STATE _GILState = PyGILState_Ensure();	PyObject *py_pe = Py_BuildValue("O&", eventObj_New, pe);	PyObject *py_t = Py_BuildValue("l", t);	PyObject *py_priority = Py_BuildValue("l", priority);	PyObject *py_rv = PyObject_CallMethod(py_event_processor, "add_event", "(OOO)", py_pe, py_t, py_priority);	if (PyErr_Occurred())	{		PySys_WriteStderr("Python exception during event_processor::add_event() callback:\n");		PyErr_Print();	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -