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

📄 ambulantmodule.cpp

📁 彩信浏览器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/* ======================== Module ambulant ========================= */#include "Python.h"#define WITH_EXTERNAL_DOM 1#include "ambulant/config/config.h"#include "ambulant/version.h"#include "ambulant/lib/node.h"#include "ambulant/lib/document.h"#include "ambulant/lib/event.h"#include "ambulant/lib/event_processor.h"#include "ambulant/lib/parser_factory.h"#include "ambulant/lib/sax_handler.h"#include "ambulant/lib/system.h"#include "ambulant/lib/timer.h"#include "ambulant/lib/transition_info.h"#include "ambulant/common/embedder.h"#include "ambulant/common/factory.h"#include "ambulant/common/gui_player.h"#include "ambulant/common/layout.h"#include "ambulant/common/playable.h"#include "ambulant/common/player.h"#include "ambulant/common/region_dim.h"#include "ambulant/common/region_info.h"#include "ambulant/gui/none/none_gui.h"#include "ambulant/net/datasource.h"#include "ambulant/net/stdio_datasource.h"#include "ambulant/net/posix_datasource.h"#include "ambulant/gui/qt/qt_factory.h"#include "ambulant/gui/SDL/sdl_factory.h"#include "ambulant/net/ffmpeg_factory.h"#include "ambulantinterface.h"#include "ambulantutilities.h"#include "ambulantmodule.h"extern PyObject *audio_format_choicesObj_New(ambulant::net::audio_format_choices *itself);extern int audio_format_choicesObj_Convert(PyObject *v, ambulant::net::audio_format_choices *p_itself);extern int cobject_Convert(PyObject *v, void **p_itself);/* Workaround for "const" added in Python 2.5. But removed before 2.5a1? */#if PY_VERSION_HEX >= 0x02050000 && PY_VERSION_HEX < 0x020500a1# define Py_KEYWORDS_STRING_TYPE const char#else# define Py_KEYWORDS_STRING_TYPE char#endifstatic PyObject *PyAm_Error;/* -------------------- Object type pycppbridge --------------------- */typedef struct pycppbridgeObject {	PyObject_HEAD	cpppybridge *ob_wrapper;} pycppbridgeObject;static void pycppbridge_dealloc(pycppbridgeObject *self){	delete self->ob_wrapper;	self->ob_wrapper = NULL;	self->ob_type->tp_free((PyObject *)self);}static PyMethodDef pycppbridge_methods[] = {	{NULL, NULL, 0}};#define pycppbridge_getsetlist NULL#define pycppbridge_compare NULL#define pycppbridge_repr NULL#define pycppbridge_hash NULL#define pycppbridge_tp_init 0#define pycppbridge_tp_alloc PyType_GenericAlloc#define pycppbridge_tp_new PyType_GenericNew#define pycppbridge_tp_free PyObject_DelPyTypeObject pycppbridge_Type = {	PyObject_HEAD_INIT(NULL)	0, /*ob_size*/	"ambulant.pycppbridge", /*tp_name*/	sizeof(pycppbridgeObject), /*tp_basicsize*/	0, /*tp_itemsize*/	/* methods */	(destructor) pycppbridge_dealloc, /*tp_dealloc*/	0, /*tp_print*/	(getattrfunc)0, /*tp_getattr*/	(setattrfunc)0, /*tp_setattr*/	(cmpfunc) pycppbridge_compare, /*tp_compare*/	(reprfunc) pycppbridge_repr, /*tp_repr*/	(PyNumberMethods *)0, /* tp_as_number */	(PySequenceMethods *)0, /* tp_as_sequence */	(PyMappingMethods *)0, /* tp_as_mapping */	(hashfunc) pycppbridge_hash, /*tp_hash*/	0, /*tp_call*/	0, /*tp_str*/	PyObject_GenericGetAttr, /*tp_getattro*/	PyObject_GenericSetAttr, /*tp_setattro */	0, /*tp_as_buffer*/	Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */	0, /*tp_doc*/	0, /*tp_traverse*/	0, /*tp_clear*/	0, /*tp_richcompare*/	0, /*tp_weaklistoffset*/	0, /*tp_iter*/	0, /*tp_iternext*/	pycppbridge_methods, /* tp_methods */	0, /*tp_members*/	pycppbridge_getsetlist, /*tp_getset*/	0, /*tp_base*/	0, /*tp_dict*/	0, /*tp_descr_get*/	0, /*tp_descr_set*/	0, /*tp_dictoffset*/	pycppbridge_tp_init, /* tp_init */	pycppbridge_tp_alloc, /* tp_alloc */	pycppbridge_tp_new, /* tp_new */	pycppbridge_tp_free, /* tp_free */};/* ------------------ End object type pycppbridge ------------------- *//* -------------------- Object type node_context -------------------- */extern PyTypeObject node_context_Type;inline bool node_contextObj_Check(PyObject *x){	return ((x)->ob_type == &node_context_Type);}typedef struct node_contextObject {	PyObject_HEAD	void *ob_dummy_wrapper; // Overlays bridge object storage	ambulant::lib::node_context* ob_itself;} node_contextObject;PyObject *node_contextObj_New(ambulant::lib::node_context* itself){	node_contextObject *it;	if (itself == NULL)	{		Py_INCREF(Py_None);		return Py_None;	}#ifdef BGEN_BACK_SUPPORT_node_context	node_context *encaps_itself = dynamic_cast<node_context *>(itself);	if (encaps_itself && encaps_itself->py_node_context)	{		Py_INCREF(encaps_itself->py_node_context);		return encaps_itself->py_node_context;	}#endif	it = PyObject_NEW(node_contextObject, &node_context_Type);	if (it == NULL) return NULL;	/* XXXX Should we tp_init or tp_new our basetype? */	it->ob_dummy_wrapper = NULL; // XXXX Should be done in base class	it->ob_itself = itself;	return (PyObject *)it;}int node_contextObj_Convert(PyObject *v, ambulant::lib::node_context* *p_itself){	if (v == Py_None)	{		*p_itself = NULL;		return 1;	}#ifdef BGEN_BACK_SUPPORT_node_context	if (!node_contextObj_Check(v))	{		*p_itself = Py_WrapAs_node_context(v);		if (*p_itself) return 1;	}#endif	if (!node_contextObj_Check(v))	{		PyErr_SetString(PyExc_TypeError, "node_context required");		return 0;	}	*p_itself = ((node_contextObject *)v)->ob_itself;	return 1;}static void node_contextObj_dealloc(node_contextObject *self){	pycppbridge_Type.tp_dealloc((PyObject *)self);}static PyObject *node_contextObj_set_prefix_mapping(node_contextObject *_self, PyObject *_args){	PyObject *_res = NULL;	std::string prefix;	std::string uri;	char *prefix_cstr;	char *uri_cstr;	if (!PyArg_ParseTuple(_args, "ss",	                      &prefix_cstr,	                      &uri_cstr))		return NULL;	prefix = prefix_cstr;	uri = uri_cstr;	PyThreadState *_save = PyEval_SaveThread();	_self->ob_itself->set_prefix_mapping(prefix,	                                     uri);	PyEval_RestoreThread(_save);	Py_INCREF(Py_None);	_res = Py_None;	return _res;}static PyObject *node_contextObj_get_namespace_prefix(node_contextObject *_self, PyObject *_args){	PyObject *_res = NULL;	ambulant::lib::xml_string uri;	char *uri_cstr;	if (!PyArg_ParseTuple(_args, "s",	                      &uri_cstr))		return NULL;	uri = uri_cstr;	PyThreadState *_save = PyEval_SaveThread();	const char * _rv = _self->ob_itself->get_namespace_prefix(uri);	PyEval_RestoreThread(_save);	_res = Py_BuildValue("z",	                     _rv);	return _res;}static PyObject *node_contextObj_resolve_url(node_contextObject *_self, PyObject *_args){	PyObject *_res = NULL;	ambulant::net::url rurl;	if (!PyArg_ParseTuple(_args, "O&",	                      ambulant_url_Convert, &rurl))		return NULL;	PyThreadState *_save = PyEval_SaveThread();	ambulant::net::url _rv = _self->ob_itself->resolve_url(rurl);	PyEval_RestoreThread(_save);	_res = Py_BuildValue("O",	                     ambulant_url_New(_rv));	return _res;}static PyObject *node_contextObj_get_root(node_contextObject *_self, PyObject *_args){	PyObject *_res = NULL;	if (!PyArg_ParseTuple(_args, ""))		return NULL;	PyThreadState *_save = PyEval_SaveThread();	const ambulant::lib::node* _rv = _self->ob_itself->get_root();	PyEval_RestoreThread(_save);	_res = Py_BuildValue("O&",	                     nodeObj_New, _rv);	return _res;}static PyObject *node_contextObj_get_node(node_contextObject *_self, PyObject *_args){	PyObject *_res = NULL;	std::string idd;	char *idd_cstr;	if (!PyArg_ParseTuple(_args, "s",	                      &idd_cstr))		return NULL;	idd = idd_cstr;	PyThreadState *_save = PyEval_SaveThread();	const ambulant::lib::node* _rv = _self->ob_itself->get_node(idd);	PyEval_RestoreThread(_save);	_res = Py_BuildValue("O&",	                     nodeObj_New, _rv);	return _res;}static PyMethodDef node_contextObj_methods[] = {	{"set_prefix_mapping", (PyCFunction)node_contextObj_set_prefix_mapping, 1,	 PyDoc_STR("(std::string prefix, std::string uri) -> None")},	{"get_namespace_prefix", (PyCFunction)node_contextObj_get_namespace_prefix, 1,	 PyDoc_STR("(ambulant::lib::xml_string uri) -> (const char * _rv)")},	{"resolve_url", (PyCFunction)node_contextObj_resolve_url, 1,	 PyDoc_STR("(ambulant::net::url rurl) -> (ambulant::net::url _rv)")},	{"get_root", (PyCFunction)node_contextObj_get_root, 1,	 PyDoc_STR("() -> (const ambulant::lib::node* _rv)")},	{"get_node", (PyCFunction)node_contextObj_get_node, 1,	 PyDoc_STR("(std::string idd) -> (const ambulant::lib::node* _rv)")},	{NULL, NULL, 0}};#define node_contextObj_getsetlist NULLstatic int node_contextObj_compare(node_contextObject *self, node_contextObject *other){	if ( self->ob_itself > other->ob_itself ) return 1;	if ( self->ob_itself < other->ob_itself ) return -1;	return 0;}#define node_contextObj_repr NULLstatic int node_contextObj_hash(node_contextObject *self){	return (int)self->ob_itself;}static int node_contextObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds){	ambulant::lib::node_context* itself;	Py_KEYWORDS_STRING_TYPE *kw[] = {"itself", 0};	if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, node_contextObj_Convert, &itself))	{		((node_contextObject *)_self)->ob_itself = itself;		return 0;	}	return -1;}#define node_contextObj_tp_alloc PyType_GenericAllocstatic PyObject *node_contextObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds){	PyObject *_self;	if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;	((node_contextObject *)_self)->ob_itself = NULL;	return _self;}#define node_contextObj_tp_free PyObject_DelPyTypeObject node_context_Type = {	PyObject_HEAD_INIT(NULL)	0, /*ob_size*/	"ambulant.node_context", /*tp_name*/	sizeof(node_contextObject), /*tp_basicsize*/	0, /*tp_itemsize*/	/* methods */	(destructor) node_contextObj_dealloc, /*tp_dealloc*/	0, /*tp_print*/	(getattrfunc)0, /*tp_getattr*/	(setattrfunc)0, /*tp_setattr*/	(cmpfunc) node_contextObj_compare, /*tp_compare*/	(reprfunc) node_contextObj_repr, /*tp_repr*/	(PyNumberMethods *)0, /* tp_as_number */	(PySequenceMethods *)0, /* tp_as_sequence */	(PyMappingMethods *)0, /* tp_as_mapping */	(hashfunc) node_contextObj_hash, /*tp_hash*/	0, /*tp_call*/	0, /*tp_str*/	PyObject_GenericGetAttr, /*tp_getattro*/	PyObject_GenericSetAttr, /*tp_setattro */	0, /*tp_as_buffer*/	Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */	0, /*tp_doc*/	0, /*tp_traverse*/	0, /*tp_clear*/	0, /*tp_richcompare*/	0, /*tp_weaklistoffset*/	0, /*tp_iter*/	0, /*tp_iternext*/	node_contextObj_methods, /* tp_methods */	0, /*tp_members*/	node_contextObj_getsetlist, /*tp_getset*/	0, /*tp_base*/	0, /*tp_dict*/	0, /*tp_descr_get*/	0, /*tp_descr_set*/	0, /*tp_dictoffset*/	node_contextObj_tp_init, /* tp_init */	node_contextObj_tp_alloc, /* tp_alloc */	node_contextObj_tp_new, /* tp_new */	node_contextObj_tp_free, /* tp_free */};/* ------------------ End object type node_context ------------------ *//* ------------------------ Object type node ------------------------ */extern PyTypeObject node_Type;inline bool nodeObj_Check(PyObject *x){	return ((x)->ob_type == &node_Type);}typedef struct nodeObject {	PyObject_HEAD	void *ob_dummy_wrapper; // Overlays bridge object storage	ambulant::lib::node* ob_itself;} nodeObject;PyObject *nodeObj_New(ambulant::lib::node* itself){	nodeObject *it;	if (itself == NULL)	{		Py_INCREF(Py_None);		return Py_None;	}#ifdef BGEN_BACK_SUPPORT_node	node *encaps_itself = dynamic_cast<node *>(itself);	if (encaps_itself && encaps_itself->py_node)	{		Py_INCREF(encaps_itself->py_node);		return encaps_itself->py_node;	}#endif	it = PyObject_NEW(nodeObject, &node_Type);	if (it == NULL) return NULL;	/* XXXX Should we tp_init or tp_new our basetype? */	it->ob_dummy_wrapper = NULL; // XXXX Should be done in base class	it->ob_itself = itself;	return (PyObject *)it;}int nodeObj_Convert(PyObject *v, ambulant::lib::node* *p_itself){	if (v == Py_None)	{		*p_itself = NULL;		return 1;	}#ifdef BGEN_BACK_SUPPORT_node	if (!nodeObj_Check(v))	{		*p_itself = Py_WrapAs_node(v);		if (*p_itself) return 1;	}#endif	if (!nodeObj_Check(v))	{		PyErr_SetString(PyExc_TypeError, "node required");		return 0;	}	*p_itself = ((nodeObject *)v)->ob_itself;	return 1;}static void nodeObj_dealloc(nodeObject *self){	pycppbridge_Type.tp_dealloc((PyObject *)self);}static PyObject *nodeObj_down_1(nodeObject *_self, PyObject *_args){	PyObject *_res = NULL;	if (!PyArg_ParseTuple(_args, ""))		return NULL;

⌨️ 快捷键说明

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