moved magic into structure (mainly to simplify the client code)
added missing API hooks
This commit is contained in:
parent
d7a42881db
commit
cc117dbb9d
|
@ -7,15 +7,17 @@
|
||||||
|
|
||||||
struct PyExpat_CAPI
|
struct PyExpat_CAPI
|
||||||
{
|
{
|
||||||
|
char* magic; /* set to PyExpat_CAPI_MAGIC */
|
||||||
int size; /* set to sizeof(struct PyExpat_CAPI) */
|
int size; /* set to sizeof(struct PyExpat_CAPI) */
|
||||||
int MAJOR_VERSION; /* XXX: use the ExpatVersionInfo instead? */
|
int MAJOR_VERSION;
|
||||||
int MINOR_VERSION;
|
int MINOR_VERSION;
|
||||||
int MICRO_VERSION;
|
int MICRO_VERSION;
|
||||||
/* pointers to selected expat functions. add new functions at
|
/* pointers to selected expat functions. add new functions at
|
||||||
the end, if needed */
|
the end, if needed */
|
||||||
const XML_LChar * (*ErrorString)(enum XML_Error code);
|
const XML_LChar * (*ErrorString)(enum XML_Error code);
|
||||||
int (*GetCurrentColumnNumber)(XML_Parser parser);
|
enum XML_Error (*GetErrorCode)(XML_Parser parser);
|
||||||
int (*GetCurrentLineNumber)(XML_Parser parser);
|
int (*GetErrorColumnNumber)(XML_Parser parser);
|
||||||
|
int (*GetErrorLineNumber)(XML_Parser parser);
|
||||||
enum XML_Status (*Parse)(
|
enum XML_Status (*Parse)(
|
||||||
XML_Parser parser, const char *s, int len, int isFinal);
|
XML_Parser parser, const char *s, int len, int isFinal);
|
||||||
XML_Parser (*ParserCreate_MM)(
|
XML_Parser (*ParserCreate_MM)(
|
||||||
|
|
|
@ -2018,12 +2018,14 @@ MODULE_INITFUNC(void)
|
||||||
|
|
||||||
/* initialize pyexpat dispatch table */
|
/* initialize pyexpat dispatch table */
|
||||||
capi.size = sizeof(capi);
|
capi.size = sizeof(capi);
|
||||||
|
capi.magic = PyExpat_CAPI_MAGIC;
|
||||||
capi.MAJOR_VERSION = XML_MAJOR_VERSION;
|
capi.MAJOR_VERSION = XML_MAJOR_VERSION;
|
||||||
capi.MINOR_VERSION = XML_MINOR_VERSION;
|
capi.MINOR_VERSION = XML_MINOR_VERSION;
|
||||||
capi.MICRO_VERSION = XML_MICRO_VERSION;
|
capi.MICRO_VERSION = XML_MICRO_VERSION;
|
||||||
capi.ErrorString = XML_ErrorString;
|
capi.ErrorString = XML_ErrorString;
|
||||||
capi.GetCurrentColumnNumber = XML_GetCurrentColumnNumber;
|
capi.GetErrorCode = XML_GetErrorCode;
|
||||||
capi.GetCurrentLineNumber = XML_GetCurrentLineNumber;
|
capi.GetErrorColumnNumber = XML_GetErrorColumnNumber;
|
||||||
|
capi.GetErrorLineNumber = XML_GetErrorLineNumber;
|
||||||
capi.Parse = XML_Parse;
|
capi.Parse = XML_Parse;
|
||||||
capi.ParserCreate_MM = XML_ParserCreate_MM;
|
capi.ParserCreate_MM = XML_ParserCreate_MM;
|
||||||
capi.ParserFree = XML_ParserFree;
|
capi.ParserFree = XML_ParserFree;
|
||||||
|
@ -2037,9 +2039,7 @@ MODULE_INITFUNC(void)
|
||||||
capi.SetUserData = XML_SetUserData;
|
capi.SetUserData = XML_SetUserData;
|
||||||
|
|
||||||
/* export as cobject */
|
/* export as cobject */
|
||||||
capi_object = PyCObject_FromVoidPtrAndDesc(
|
capi_object = PyCObject_FromVoidPtr(&capi, NULL);
|
||||||
&capi, PyExpat_CAPI_MAGIC, NULL
|
|
||||||
);
|
|
||||||
if (capi_object)
|
if (capi_object)
|
||||||
PyModule_AddObject(m, "expat_CAPI", capi_object);
|
PyModule_AddObject(m, "expat_CAPI", capi_object);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue