Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(74)

Side by Side Diff: Modules/celementtree.h

Issue 207048: merge upstream ElementTree 1.3 and cElementTree 1.0.6 in /python/trunk/ (Closed) Base URL: http://svn.python.org/view/*checkout*/python/trunk/
Patch Set: Add tests for the C API. Drop unused "element_(get|set)slice". Created 15 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« Modules/_testcapimodule.c ('K') | « Modules/_testcapimodule.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* Stuff to export relevant entry points from cElementTree */
2
3 /* To use this API, do
4
5 struct cElementTree_CAPI *capi;
6 capi = PyCObject_Import("cElementTree", "CAPI");
7
8 Also check that capi->magic and capi->size matches the values from
9 this header, e.g:
10
11 if (strcmp(capi->magic, cElementTree_CAPI_MAGIC) != 0 ||
12 capi->size < sizeof(struct cElementTree_CAPI) ||
13 capi->version < cElementTree_CAPI_VERSION)
14 ... cannot use this version ...
15
16 See below for a summary of the available API functions.
17
18 */
19
20 /* major version */
21 #define cElementTree_CAPI_MAGIC "cElementTree.CAPI 1.0"
22
23 /* minor version. new minor versions should always be backwards compatible */
24 #define cElementTree_CAPI_VERSION 1
25
26 /* struct to store a snapshot of a given Element */
27 struct cElementTree_Snapshot
28 {
29 /* filled in by snapshot method. members may be Py_None if not present
30 in the internal structure. all references are new; use DECREF to clean
31 up */
32 PyObject* tag;
33 PyObject* attrib;
34 PyObject* text;
35 PyObject* tail;
36 PyObject* children; /* only filled in if mode > 0 */
37
38 /* always add new stuff to the end! */
39 };
40
41 struct cElementTree_CAPI·
42 {
43 char* magic; /* set to cElementTree_CAPI_MAGIC */
44 int size; /* set to sizeof(struct cElementTree_CAPI) */
45 int version; /* set to cElementTree_CAPI_VERSION (API version) */
46
47 /* pointers to selected cElementTree helpers. add new functions at
48 the end, if needed */
49
50 /* Element type (to be used for exact type comparisions) */
51 PyObject* type;
Antoine Pitrou 2010/02/15 15:06:56 The doc/comments should state whether this referen
flox 2010/02/15 16:42:32 Added a statement "borrowed reference".
52
53 /* Check if object is a cElementTree Element, and raises a TypeError
54 if not. Use this before calling other methods. */
55 /* Returns 0 if ok, -1 if error. */
56 int (*assert)(PyObject* elem);
Antoine Pitrou 2010/02/15 15:06:56 I'm not sure calling this "assert" is a good idea.
flox 2010/02/15 16:42:32 Agreed.
57
58 /* Get Element snapshot. Use mode=1 to get children too. */
59 /* The 'elem' argument must point to a cElementTree Element. Use
60 'assert' first when in doubt. */
61 /* All references are new, and point to stable versions (that is,·
62 changing the original Element won't affect the snapshot). */
63 /* Py_None may be used for non-existent/empty fields. */
64 /* Returns 0 if ok, -1 if error. */
65 int (*snapshot)(
66 PyObject* elem, struct cElementTree_Snapshot* snapshot, int mode
67 );
68
69 /* Get subelement. */
70 /* The 'elem' argument must point to a cElementTree Element. Use
71 'assert' first when in doubt. */
72 /* Returns a borrowed reference, or Py_None if the element does not
Antoine Pitrou 2010/02/15 15:06:56 The doc is wrong, because the implementation retur
flox 2010/02/15 16:42:32 Fixed the implementation.
73 exist. */
74 PyObject* (*getitem)(PyObject* elem, int index);
Antoine Pitrou 2010/02/15 15:06:56 The index should probably be a Py_ssize_t instead.
flox 2010/02/15 16:42:32 Ok.
75
76 /* always add new stuff to the end! */
77 };
OLDNEW
« Modules/_testcapimodule.c ('K') | « Modules/_testcapimodule.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b