/** @file lsup_rdf_mod.c * * @brief LSUP_RDF package. * * This "package" module includes all RDF modules in a monolithic compiled * object, in order to resolve internal symbol dependencies. Individual modules * are extracted and exposed by the package __init__.py . */ #define PY_SSIZE_T_CLEAN #include #include "py_graph.h" static PyModuleDef _lsup_rdf_pkg = { PyModuleDef_HEAD_INIT, .m_name = "_lsup_rdf", .m_doc = "Lakesuperior RDF package.", .m_size = -1, }; PyMODINIT_FUNC PyInit__lsup_rdf (void) { return PyModule_Create (&_lsup_rdf_pkg); } static PyModuleDef term_mod = { PyModuleDef_HEAD_INIT, .m_name = "term", .m_doc = "RDF term module.", .m_size = -1, }; PyMODINIT_FUNC PyInit_term() { if (PyType_Ready (&TermType) < 0) return NULL; PyObject *m = PyModule_Create(&term_mod); if (m == NULL) return NULL; #define ENTRY(a, b) \ if (PyModule_AddIntConstant (m, "TERM_" #a, b) < 0) return NULL; TTYPE_TBL #undef ENTRY Py_INCREF(&TermType); if (PyModule_AddObject(m, "Term", (PyObject *) &TermType) < 0) { Py_DECREF(&TermType); Py_DECREF(m); return NULL; } return m; } static PyModuleDef triple_mod = { PyModuleDef_HEAD_INIT, .m_name = "triple", .m_doc = "RDF triple module.", .m_size = -1, }; PyMODINIT_FUNC PyInit_triple() { if (PyType_Ready (&TripleType) < 0) return NULL; PyObject *m = PyModule_Create(&triple_mod); if (m == NULL) return NULL; Py_INCREF(&TripleType); if (PyModule_AddObject(m, "Triple", (PyObject *) &TripleType) < 0) { Py_DECREF(&TripleType); Py_DECREF(m); return NULL; } return m; } static PyModuleDef graph_mod = { PyModuleDef_HEAD_INIT, .m_name = "graph", .m_doc = "RDF graph module.", .m_size = -1, }; PyMODINIT_FUNC PyInit_graph() { if (PyType_Ready (&GraphType) < 0) return NULL; PyObject *m = PyModule_Create(&graph_mod); if (!m) return NULL; #define ENTRY(a, b) \ if (PyModule_AddIntConstant (m, "STORE_" #a, b) < 0) return NULL; BACKEND_TBL #undef ENTRY Py_INCREF(&GraphType); if (PyModule_AddObject(m, "Graph", (PyObject *) &GraphType) < 0) { Py_DECREF(&GraphType); Py_DECREF(m); return NULL; } return m; }