📄 ambulantmodule.cpp
字号:
static PyObject *node_factoryObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds){ PyObject *_self; if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; ((node_factoryObject *)_self)->ob_itself = NULL; return _self;}#define node_factoryObj_tp_free PyObject_DelPyTypeObject node_factory_Type = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "ambulant.node_factory", /*tp_name*/ sizeof(node_factoryObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor) node_factoryObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc)0, /*tp_getattr*/ (setattrfunc)0, /*tp_setattr*/ (cmpfunc) node_factoryObj_compare, /*tp_compare*/ (reprfunc) node_factoryObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) node_factoryObj_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_factoryObj_methods, /* tp_methods */ 0, /*tp_members*/ node_factoryObj_getsetlist, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ node_factoryObj_tp_init, /* tp_init */ node_factoryObj_tp_alloc, /* tp_alloc */ node_factoryObj_tp_new, /* tp_new */ node_factoryObj_tp_free, /* tp_free */};/* ------------------ End object type node_factory ------------------ *//* ---------------------- Object type document ---------------------- */extern PyTypeObject document_Type;inline bool documentObj_Check(PyObject *x){ return ((x)->ob_type == &document_Type);}typedef struct documentObject { PyObject_HEAD void *ob_dummy_wrapper; // Overlays bridge object storage ambulant::lib::document* ob_itself;} documentObject;PyObject *documentObj_New(ambulant::lib::document* itself){ documentObject *it; if (itself == NULL) { Py_INCREF(Py_None); return Py_None; }#ifdef BGEN_BACK_SUPPORT_document document *encaps_itself = dynamic_cast<document *>(itself); if (encaps_itself && encaps_itself->py_document) { Py_INCREF(encaps_itself->py_document); return encaps_itself->py_document; }#endif it = PyObject_NEW(documentObject, &document_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 documentObj_Convert(PyObject *v, ambulant::lib::document* *p_itself){ if (v == Py_None) { *p_itself = NULL; return 1; }#ifdef BGEN_BACK_SUPPORT_document if (!documentObj_Check(v)) { *p_itself = Py_WrapAs_document(v); if (*p_itself) return 1; }#endif if (!documentObj_Check(v)) { PyErr_SetString(PyExc_TypeError, "document required"); return 0; } *p_itself = ((documentObject *)v)->ob_itself; return 1;}static void documentObj_dealloc(documentObject *self){ node_context_Type.tp_dealloc((PyObject *)self);}static PyObject *documentObj_get_root_1(documentObject *_self, PyObject *_args){ PyObject *_res = NULL; bool detach; if (!PyArg_ParseTuple(_args, "O&", bool_Convert, &detach)) return NULL; PyThreadState *_save = PyEval_SaveThread(); ambulant::lib::node* _rv = _self->ob_itself->get_root(detach); PyEval_RestoreThread(_save); _res = Py_BuildValue("O&", nodeObj_New, _rv); return _res;}static PyObject *documentObj_get_root_2(documentObject *_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 *documentObj_tree_changed(documentObject *_self, PyObject *_args){ PyObject *_res = NULL; if (!PyArg_ParseTuple(_args, "")) return NULL; PyThreadState *_save = PyEval_SaveThread(); _self->ob_itself->tree_changed(); PyEval_RestoreThread(_save); Py_INCREF(Py_None); _res = Py_None; return _res;}static PyObject *documentObj_locate_node_1(documentObject *_self, PyObject *_args){ PyObject *_res = NULL; char* path; if (!PyArg_ParseTuple(_args, "s", &path)) return NULL; PyThreadState *_save = PyEval_SaveThread(); ambulant::lib::node* _rv = _self->ob_itself->locate_node(path); PyEval_RestoreThread(_save); _res = Py_BuildValue("O&", nodeObj_New, _rv); return _res;}static PyObject *documentObj_locate_node_2(documentObject *_self, PyObject *_args){ PyObject *_res = NULL; char* path; if (!PyArg_ParseTuple(_args, "s", &path)) return NULL; PyThreadState *_save = PyEval_SaveThread(); const ambulant::lib::node* _rv = _self->ob_itself->locate_node(path); PyEval_RestoreThread(_save); _res = Py_BuildValue("O&", nodeObj_New, _rv); return _res;}static PyObject *documentObj_get_src_url(documentObject *_self, PyObject *_args){ PyObject *_res = NULL; if (!PyArg_ParseTuple(_args, "")) return NULL; PyThreadState *_save = PyEval_SaveThread(); ambulant::net::url _rv = _self->ob_itself->get_src_url(); PyEval_RestoreThread(_save); _res = Py_BuildValue("O", ambulant_url_New(_rv)); return _res;}static PyObject *documentObj_set_prefix_mapping(documentObject *_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 *documentObj_get_namespace_prefix(documentObject *_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 *documentObj_resolve_url(documentObject *_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 *documentObj_get_node(documentObject *_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 PyObject *documentObj_set_src_url(documentObject *_self, PyObject *_args){ PyObject *_res = NULL; ambulant::net::url u; if (!PyArg_ParseTuple(_args, "O&", ambulant_url_Convert, &u)) return NULL; PyThreadState *_save = PyEval_SaveThread(); _self->ob_itself->set_src_url(u); PyEval_RestoreThread(_save); Py_INCREF(Py_None); _res = Py_None; return _res;}static PyMethodDef documentObj_methods[] = { {"get_root_1", (PyCFunction)documentObj_get_root_1, 1, PyDoc_STR("(bool detach) -> (ambulant::lib::node* _rv)")}, {"get_root_2", (PyCFunction)documentObj_get_root_2, 1, PyDoc_STR("() -> (const ambulant::lib::node* _rv)")}, {"tree_changed", (PyCFunction)documentObj_tree_changed, 1, PyDoc_STR("() -> None")}, {"locate_node_1", (PyCFunction)documentObj_locate_node_1, 1, PyDoc_STR("(char* path) -> (ambulant::lib::node* _rv)")}, {"locate_node_2", (PyCFunction)documentObj_locate_node_2, 1, PyDoc_STR("(char* path) -> (const ambulant::lib::node* _rv)")}, {"get_src_url", (PyCFunction)documentObj_get_src_url, 1, PyDoc_STR("() -> (ambulant::net::url _rv)")}, {"set_prefix_mapping", (PyCFunction)documentObj_set_prefix_mapping, 1, PyDoc_STR("(std::string prefix, std::string uri) -> None")}, {"get_namespace_prefix", (PyCFunction)documentObj_get_namespace_prefix, 1, PyDoc_STR("(ambulant::lib::xml_string uri) -> (const char * _rv)")}, {"resolve_url", (PyCFunction)documentObj_resolve_url, 1, PyDoc_STR("(ambulant::net::url rurl) -> (ambulant::net::url _rv)")}, {"get_node", (PyCFunction)documentObj_get_node, 1, PyDoc_STR("(std::string idd) -> (const ambulant::lib::node* _rv)")}, {"set_src_url", (PyCFunction)documentObj_set_src_url, 1, PyDoc_STR("(ambulant::net::url u) -> None")}, {NULL, NULL, 0}};#define documentObj_getsetlist NULLstatic int documentObj_compare(documentObject *self, documentObject *other){ if ( self->ob_itself > other->ob_itself ) return 1; if ( self->ob_itself < other->ob_itself ) return -1; return 0;}#define documentObj_repr NULLstatic int documentObj_hash(documentObject *self){ return (int)self->ob_itself;}static int documentObj_tp_init(PyObject *_self, PyObject *_args, PyObject *_kwds){ ambulant::lib::document* itself; Py_KEYWORDS_STRING_TYPE *kw[] = {"itself", 0}; if (PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, documentObj_Convert, &itself)) { ((documentObject *)_self)->ob_itself = itself; return 0; } return -1;}#define documentObj_tp_alloc PyType_GenericAllocstatic PyObject *documentObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds){ PyObject *_self; if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; ((documentObject *)_self)->ob_itself = NULL; return _self;}#define documentObj_tp_free PyObject_DelPyTypeObject document_Type = { PyObject_HEAD_INIT(NULL) 0, /*ob_size*/ "ambulant.document", /*tp_name*/ sizeof(documentObject), /*tp_basicsize*/ 0, /*tp_itemsize*/ /* methods */ (destructor) documentObj_dealloc, /*tp_dealloc*/ 0, /*tp_print*/ (getattrfunc)0, /*tp_getattr*/ (setattrfunc)0, /*tp_setattr*/ (cmpfunc) documentObj_compare, /*tp_compare*/ (reprfunc) documentObj_repr, /*tp_repr*/ (PyNumberMethods *)0, /* tp_as_number */ (PySequenceMethods *)0, /* tp_as_sequence */ (PyMappingMethods *)0, /* tp_as_mapping */ (hashfunc) documentObj_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*/ documentObj_methods, /* tp_methods */ 0, /*tp_members*/ documentObj_getsetlist, /*tp_getset*/ 0, /*tp_base*/ 0, /*tp_dict*/ 0, /*tp_descr_get*/ 0, /*tp_descr_set*/ 0, /*tp_dictoffset*/ documentObj_tp_init, /* tp_init */ documentObj_tp_alloc, /* tp_alloc */ documentObj_tp_new, /* tp_new */ documentObj_tp_free, /* tp_free */};/* -------------------- End object type document -------------------- *//* ----------------------- Object type event ------------------------ */extern PyTypeObject event_Type;inline bool eventObj_Check(PyObject *x){ return ((x)->ob_type == &event_Type);}typedef struct eventObject { PyObject_HEAD void *ob_dummy_wrapper; // Overlays bridge object storage ambulant::lib::event* ob_itself;} eventObject;PyObject *eventObj_New(ambulant::lib::event* itself){ eventObject *it; if (itself == NULL) { Py_INCREF(Py_None); return Py_None; }#ifdef BGEN_BACK_SUPPORT_event event *encaps_itself = dynamic_cast<event *>(itself); if (encaps_itself && encaps_itself->py_event) { Py_INCREF(encaps_itself->py_event); return encaps_itself->py_event; }#endif it = PyObject_NEW(eventObject, &event_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 eventObj_Convert(PyObject *v, ambulant::lib::event* *p_itself){ if (v == Py_None) { *p_itself = NULL; return 1; }#ifdef BGEN_BACK_SUPPORT_event if (!eventObj_Check(v)) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -