Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c3345040
Commit
c3345040
authored
Dec 13, 2005
by
Fredrik Lundh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added cobject-based expat dispatch mechanism to pyexpat
parent
e2f8e3c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
0 deletions
+76
-0
Include/pyexpat.h
Include/pyexpat.h
+45
-0
Modules/pyexpat.c
Modules/pyexpat.c
+31
-0
No files found.
Include/pyexpat.h
0 → 100644
View file @
c3345040
/* Stuff to export relevant 'expat' entry points from pyexpat to other
* parser modules, such as cElementTree. */
/* note: you must import expat.h before importing this module! */
#define PyExpat_DISPATCH_MAGIC "pyexpat.dispatch 1.0"
struct
PyExpat_Dispatch
{
int
size
;
/* set to sizeof(struct PyExpat_Dispatch) */
int
MAJOR_VERSION
;
/* XXX: use the ExpatVersionInfo instead? */
int
MINOR_VERSION
;
int
MICRO_VERSION
;
/* pointers to selected expat functions. add new functions at
the end, if needed */
const
XML_LChar
*
(
*
ErrorString
)(
enum
XML_Error
code
);
int
(
*
GetCurrentColumnNumber
)(
XML_Parser
parser
);
int
(
*
GetCurrentLineNumber
)(
XML_Parser
parser
);
enum
XML_Status
(
*
Parse
)(
XML_Parser
parser
,
const
char
*
s
,
int
len
,
int
isFinal
);
XML_Parser
(
*
ParserCreate_MM
)(
const
XML_Char
*
encoding
,
const
XML_Memory_Handling_Suite
*
memsuite
,
const
XML_Char
*
namespaceSeparator
);
void
(
*
ParserFree
)(
XML_Parser
parser
);
void
(
*
SetCharacterDataHandler
)(
XML_Parser
parser
,
XML_CharacterDataHandler
handler
);
void
(
*
SetCommentHandler
)(
XML_Parser
parser
,
XML_CommentHandler
handler
);
void
(
*
SetDefaultHandlerExpand
)(
XML_Parser
parser
,
XML_DefaultHandler
handler
);
void
(
*
SetElementHandler
)(
XML_Parser
parser
,
XML_StartElementHandler
start
,
XML_EndElementHandler
end
);
void
(
*
SetNamespaceDeclHandler
)(
XML_Parser
parser
,
XML_StartNamespaceDeclHandler
start
,
XML_EndNamespaceDeclHandler
end
);
void
(
*
SetProcessingInstructionHandler
)(
XML_Parser
parser
,
XML_ProcessingInstructionHandler
handler
);
void
(
*
SetUnknownEncodingHandler
)(
XML_Parser
parser
,
XML_UnknownEncodingHandler
handler
,
void
*
encodingHandlerData
);
void
(
*
SetUserData
)(
XML_Parser
parser
,
void
*
userData
);
/* always add new stuff to the end! */
};
Modules/pyexpat.c
View file @
c3345040
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
#include "frameobject.h"
#include "frameobject.h"
#include "expat.h"
#include "expat.h"
#include "pyexpat.h"
#define XML_COMBINED_VERSION (10000*XML_MAJOR_VERSION+100*XML_MINOR_VERSION+XML_MICRO_VERSION)
#define XML_COMBINED_VERSION (10000*XML_MAJOR_VERSION+100*XML_MINOR_VERSION+XML_MICRO_VERSION)
#ifndef PyDoc_STRVAR
#ifndef PyDoc_STRVAR
...
@@ -1838,6 +1840,8 @@ MODULE_INITFUNC(void)
...
@@ -1838,6 +1840,8 @@ MODULE_INITFUNC(void)
PyObject
*
modelmod_name
;
PyObject
*
modelmod_name
;
PyObject
*
model_module
;
PyObject
*
model_module
;
PyObject
*
sys_modules
;
PyObject
*
sys_modules
;
static
struct
PyExpat_Dispatch
dispatch
;
PyObject
*
dispatch_object
;
if
(
errmod_name
==
NULL
)
if
(
errmod_name
==
NULL
)
return
;
return
;
...
@@ -2011,6 +2015,33 @@ MODULE_INITFUNC(void)
...
@@ -2011,6 +2015,33 @@ MODULE_INITFUNC(void)
MYCONST
(
XML_CQUANT_REP
);
MYCONST
(
XML_CQUANT_REP
);
MYCONST
(
XML_CQUANT_PLUS
);
MYCONST
(
XML_CQUANT_PLUS
);
#undef MYCONST
#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
static
void
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment