summaryrefslogtreecommitdiffstats
path: root/Modules/pyexpat.c
diff options
context:
space:
mode:
authorFredrik Lundh <fredrik@pythonware.com>2005-12-13 19:49:55 (GMT)
committerFredrik Lundh <fredrik@pythonware.com>2005-12-13 19:49:55 (GMT)
commitc3345040df1adb502f5b62e9b3efc6f4232a952f (patch)
tree7b5a4b66d37dc7d931c2859e84ac30cd41bb7390 /Modules/pyexpat.c
parente2f8e3c14f6f17fe6541c926e69a5f01f1a91b9b (diff)
downloadcpython-c3345040df1adb502f5b62e9b3efc6f4232a952f.zip
cpython-c3345040df1adb502f5b62e9b3efc6f4232a952f.tar.gz
cpython-c3345040df1adb502f5b62e9b3efc6f4232a952f.tar.bz2
added cobject-based expat dispatch mechanism to pyexpat
Diffstat (limited to 'Modules/pyexpat.c')
-rw-r--r--Modules/pyexpat.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index d1def24..b59a51d 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -4,6 +4,8 @@
#include "frameobject.h"
#include "expat.h"
+#include "pyexpat.h"
+
#define XML_COMBINED_VERSION (10000*XML_MAJOR_VERSION+100*XML_MINOR_VERSION+XML_MICRO_VERSION)
#ifndef PyDoc_STRVAR
@@ -1838,6 +1840,8 @@ MODULE_INITFUNC(void)
PyObject *modelmod_name;
PyObject *model_module;
PyObject *sys_modules;
+ static struct PyExpat_Dispatch dispatch;
+ PyObject* dispatch_object;
if (errmod_name == NULL)
return;
@@ -2011,6 +2015,33 @@ MODULE_INITFUNC(void)
MYCONST(XML_CQUANT_REP);
MYCONST(XML_CQUANT_PLUS);
#undef MYCONST
+
+ /* initialize pyexpat dispatch table */
+ dispatch.size = sizeof(dispatch);
+ dispatch.MAJOR_VERSION = XML_MAJOR_VERSION;
+ dispatch.MINOR_VERSION = XML_MINOR_VERSION;
+ dispatch.MICRO_VERSION = XML_MICRO_VERSION;
+ dispatch.ErrorString = XML_ErrorString;
+ dispatch.GetCurrentColumnNumber = XML_GetCurrentColumnNumber;
+ dispatch.GetCurrentLineNumber = XML_GetCurrentLineNumber;
+ dispatch.Parse = XML_Parse;
+ dispatch.ParserCreate_MM = XML_ParserCreate_MM;
+ dispatch.ParserFree = XML_ParserFree;
+ dispatch.SetCharacterDataHandler = XML_SetCharacterDataHandler;
+ dispatch.SetCommentHandler = XML_SetCommentHandler;
+ dispatch.SetDefaultHandlerExpand = XML_SetDefaultHandlerExpand;
+ dispatch.SetElementHandler = XML_SetElementHandler;
+ dispatch.SetNamespaceDeclHandler = XML_SetNamespaceDeclHandler;
+ dispatch.SetProcessingInstructionHandler = XML_SetProcessingInstructionHandler;
+ dispatch.SetUnknownEncodingHandler = XML_SetUnknownEncodingHandler;
+ dispatch.SetUserData = XML_SetUserData;
+
+ /* export as cobject */
+ dispatch_object = PyCObject_FromVoidPtrAndDesc(
+ &dispatch, PyExpat_DISPATCH_MAGIC, NULL
+ );
+ if (dispatch_object)
+ PyModule_AddObject(m, "dispatch", dispatch_object);
}
static void