Skip to content

Commit cc117db

Browse files
author
Fredrik Lundh
committed
moved magic into structure (mainly to simplify the client code)
added missing API hooks
1 parent d7a4288 commit cc117db

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

Include/pyexpat.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,17 @@
77

88
struct PyExpat_CAPI
99
{
10+
char* magic; /* set to PyExpat_CAPI_MAGIC */
1011
int size; /* set to sizeof(struct PyExpat_CAPI) */
11-
int MAJOR_VERSION; /* XXX: use the ExpatVersionInfo instead? */
12+
int MAJOR_VERSION;
1213
int MINOR_VERSION;
1314
int MICRO_VERSION;
1415
/* pointers to selected expat functions. add new functions at
1516
the end, if needed */
1617
const XML_LChar * (*ErrorString)(enum XML_Error code);
17-
int (*GetCurrentColumnNumber)(XML_Parser parser);
18-
int (*GetCurrentLineNumber)(XML_Parser parser);
18+
enum XML_Error (*GetErrorCode)(XML_Parser parser);
19+
int (*GetErrorColumnNumber)(XML_Parser parser);
20+
int (*GetErrorLineNumber)(XML_Parser parser);
1921
enum XML_Status (*Parse)(
2022
XML_Parser parser, const char *s, int len, int isFinal);
2123
XML_Parser (*ParserCreate_MM)(

Modules/pyexpat.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,12 +2018,14 @@ MODULE_INITFUNC(void)
20182018

20192019
/* initialize pyexpat dispatch table */
20202020
capi.size = sizeof(capi);
2021+
capi.magic = PyExpat_CAPI_MAGIC;
20212022
capi.MAJOR_VERSION = XML_MAJOR_VERSION;
20222023
capi.MINOR_VERSION = XML_MINOR_VERSION;
20232024
capi.MICRO_VERSION = XML_MICRO_VERSION;
20242025
capi.ErrorString = XML_ErrorString;
2025-
capi.GetCurrentColumnNumber = XML_GetCurrentColumnNumber;
2026-
capi.GetCurrentLineNumber = XML_GetCurrentLineNumber;
2026+
capi.GetErrorCode = XML_GetErrorCode;
2027+
capi.GetErrorColumnNumber = XML_GetErrorColumnNumber;
2028+
capi.GetErrorLineNumber = XML_GetErrorLineNumber;
20272029
capi.Parse = XML_Parse;
20282030
capi.ParserCreate_MM = XML_ParserCreate_MM;
20292031
capi.ParserFree = XML_ParserFree;
@@ -2037,9 +2039,7 @@ MODULE_INITFUNC(void)
20372039
capi.SetUserData = XML_SetUserData;
20382040

20392041
/* export as cobject */
2040-
capi_object = PyCObject_FromVoidPtrAndDesc(
2041-
&capi, PyExpat_CAPI_MAGIC, NULL
2042-
);
2042+
capi_object = PyCObject_FromVoidPtr(&capi, NULL);
20432043
if (capi_object)
20442044
PyModule_AddObject(m, "expat_CAPI", capi_object);
20452045
}

0 commit comments

Comments
 (0)