annotate Modules/xxsubtype.c @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents fd25030223b0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
1 #include "Python.h"
19281
be85f686ad97 Add 'state' as a read-only attribute to spamdict. This serves as an
Guido van Rossum <guido@python.org>
parents: 19040
diff changeset
2 #include "structmember.h"
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
3
23832
ed1ba37a46b7 Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents: 22617
diff changeset
4 PyDoc_STRVAR(xxsubtype__doc__,
21338
68040db084b6 Give xxsubtype a module docstring, so its oddball purpose is discoverable
Tim Peters <tim.peters@gmail.com>
parents: 20594
diff changeset
5 "xxsubtype is an example module showing how to subtype builtin types from C.\n"
68040db084b6 Give xxsubtype a module docstring, so its oddball purpose is discoverable
Tim Peters <tim.peters@gmail.com>
parents: 20594
diff changeset
6 "test_descr.py in the standard test suite requires it in order to complete.\n"
68040db084b6 Give xxsubtype a module docstring, so its oddball purpose is discoverable
Tim Peters <tim.peters@gmail.com>
parents: 20594
diff changeset
7 "If you don't care about the examples, and don't intend to run the Python\n"
23832
ed1ba37a46b7 Patch #568124: Add doc string macros.
Martin v. Löwis <martin@v.loewis.de>
parents: 22617
diff changeset
8 "test suite, you can recompile Python without Modules/xxsubtype.c.");
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
9
21443
4f621bac7526 David Abrahams tried to compile this as a separate DLL under MSVC, and
Tim Peters <tim.peters@gmail.com>
parents: 21338
diff changeset
10 /* We link this module statically for convenience. If compiled as a shared
4f621bac7526 David Abrahams tried to compile this as a separate DLL under MSVC, and
Tim Peters <tim.peters@gmail.com>
parents: 21338
diff changeset
11 library instead, some compilers don't allow addresses of Python objects
4f621bac7526 David Abrahams tried to compile this as a separate DLL under MSVC, and
Tim Peters <tim.peters@gmail.com>
parents: 21338
diff changeset
12 defined in other libraries to be used in static initializers here. The
4f621bac7526 David Abrahams tried to compile this as a separate DLL under MSVC, and
Tim Peters <tim.peters@gmail.com>
parents: 21338
diff changeset
13 DEFERRED_ADDRESS macro is used to tag the slots where such addresses
4f621bac7526 David Abrahams tried to compile this as a separate DLL under MSVC, and
Tim Peters <tim.peters@gmail.com>
parents: 21338
diff changeset
14 appear; the module init function must fill in the tagged slots at runtime.
4f621bac7526 David Abrahams tried to compile this as a separate DLL under MSVC, and
Tim Peters <tim.peters@gmail.com>
parents: 21338
diff changeset
15 The argument is for documentation -- the macro ignores it.
4f621bac7526 David Abrahams tried to compile this as a separate DLL under MSVC, and
Tim Peters <tim.peters@gmail.com>
parents: 21338
diff changeset
16 */
4f621bac7526 David Abrahams tried to compile this as a separate DLL under MSVC, and
Tim Peters <tim.peters@gmail.com>
parents: 21338
diff changeset
17 #define DEFERRED_ADDRESS(ADDR) 0
4f621bac7526 David Abrahams tried to compile this as a separate DLL under MSVC, and
Tim Peters <tim.peters@gmail.com>
parents: 21338
diff changeset
18
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
19 /* spamlist -- a list subtype */
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
20
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
21 typedef struct {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
22 PyListObject list;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
23 int state;
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
24 } spamlistobject;
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
25
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
26 static PyObject *
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
27 spamlist_getstate(spamlistobject *self, PyObject *args)
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
28 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
29 if (!PyArg_ParseTuple(args, ":getstate"))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
30 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
31 return PyInt_FromLong(self->state);
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
32 }
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
33
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
34 static PyObject *
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
35 spamlist_setstate(spamlistobject *self, PyObject *args)
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
36 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
37 int state;
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
38
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
39 if (!PyArg_ParseTuple(args, "i:setstate", &state))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
40 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
41 self->state = state;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
42 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
43 return Py_None;
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
44 }
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
45
22617
6796dd30a602 Add a simple test of the METH_CLASS and METH_STATIC flags for type methods.
Fred Drake <fdrake@acm.org>
parents: 22257
diff changeset
46 static PyObject *
6796dd30a602 Add a simple test of the METH_CLASS and METH_STATIC flags for type methods.
Fred Drake <fdrake@acm.org>
parents: 22257
diff changeset
47 spamlist_specialmeth(PyObject *self, PyObject *args, PyObject *kw)
6796dd30a602 Add a simple test of the METH_CLASS and METH_STATIC flags for type methods.
Fred Drake <fdrake@acm.org>
parents: 22257
diff changeset
48 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
49 PyObject *result = PyTuple_New(3);
22617
6796dd30a602 Add a simple test of the METH_CLASS and METH_STATIC flags for type methods.
Fred Drake <fdrake@acm.org>
parents: 22257
diff changeset
50
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
51 if (result != NULL) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
52 if (self == NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
53 self = Py_None;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
54 if (kw == NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
55 kw = Py_None;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
56 Py_INCREF(self);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
57 PyTuple_SET_ITEM(result, 0, self);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
58 Py_INCREF(args);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
59 PyTuple_SET_ITEM(result, 1, args);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
60 Py_INCREF(kw);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
61 PyTuple_SET_ITEM(result, 2, kw);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
62 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
63 return result;
22617
6796dd30a602 Add a simple test of the METH_CLASS and METH_STATIC flags for type methods.
Fred Drake <fdrake@acm.org>
parents: 22257
diff changeset
64 }
6796dd30a602 Add a simple test of the METH_CLASS and METH_STATIC flags for type methods.
Fred Drake <fdrake@acm.org>
parents: 22257
diff changeset
65
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
66 static PyMethodDef spamlist_methods[] = {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
67 {"getstate", (PyCFunction)spamlist_getstate, METH_VARARGS,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
68 PyDoc_STR("getstate() -> state")},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
69 {"setstate", (PyCFunction)spamlist_setstate, METH_VARARGS,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
70 PyDoc_STR("setstate(state)")},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
71 /* These entries differ only in the flags; they are used by the tests
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
72 in test.test_descr. */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
73 {"classmeth", (PyCFunction)spamlist_specialmeth,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
74 METH_VARARGS | METH_KEYWORDS | METH_CLASS,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
75 PyDoc_STR("classmeth(*args, **kw)")},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
76 {"staticmeth", (PyCFunction)spamlist_specialmeth,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
77 METH_VARARGS | METH_KEYWORDS | METH_STATIC,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
78 PyDoc_STR("staticmeth(*args, **kw)")},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
79 {NULL, NULL},
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
80 };
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
81
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
82 static int
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
83 spamlist_init(spamlistobject *self, PyObject *args, PyObject *kwds)
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
84 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
85 if (PyList_Type.tp_init((PyObject *)self, args, kwds) < 0)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
86 return -1;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
87 self->state = 0;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
88 return 0;
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
89 }
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
90
19282
6f6acbf78939 Add 'state' as a get/set attribute to spamlist. This serves as an
Guido van Rossum <guido@python.org>
parents: 19281
diff changeset
91 static PyObject *
6f6acbf78939 Add 'state' as a get/set attribute to spamlist. This serves as an
Guido van Rossum <guido@python.org>
parents: 19281
diff changeset
92 spamlist_state_get(spamlistobject *self)
6f6acbf78939 Add 'state' as a get/set attribute to spamlist. This serves as an
Guido van Rossum <guido@python.org>
parents: 19281
diff changeset
93 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
94 return PyInt_FromLong(self->state);
19282
6f6acbf78939 Add 'state' as a get/set attribute to spamlist. This serves as an
Guido van Rossum <guido@python.org>
parents: 19281
diff changeset
95 }
6f6acbf78939 Add 'state' as a get/set attribute to spamlist. This serves as an
Guido van Rossum <guido@python.org>
parents: 19281
diff changeset
96
20015
ca7af2a5d915 Add optional docstrings to getset descriptors. Fortunately, there's
Guido van Rossum <guido@python.org>
parents: 20012
diff changeset
97 static PyGetSetDef spamlist_getsets[] = {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
98 {"state", (getter)spamlist_state_get, NULL,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
99 PyDoc_STR("an int variable for demonstration purposes")},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
100 {0}
19282
6f6acbf78939 Add 'state' as a get/set attribute to spamlist. This serves as an
Guido van Rossum <guido@python.org>
parents: 19281
diff changeset
101 };
6f6acbf78939 Add 'state' as a get/set attribute to spamlist. This serves as an
Guido van Rossum <guido@python.org>
parents: 19281
diff changeset
102
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
103 static PyTypeObject spamlist_type = {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
104 PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
105 "xxsubtype.spamlist",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
106 sizeof(spamlistobject),
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
107 0,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
108 0, /* tp_dealloc */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
109 0, /* tp_print */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
110 0, /* tp_getattr */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
111 0, /* tp_setattr */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
112 0, /* tp_compare */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
113 0, /* tp_repr */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
114 0, /* tp_as_number */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
115 0, /* tp_as_sequence */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
116 0, /* tp_as_mapping */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
117 0, /* tp_hash */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
118 0, /* tp_call */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
119 0, /* tp_str */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
120 0, /* tp_getattro */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
121 0, /* tp_setattro */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
122 0, /* tp_as_buffer */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
123 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
124 0, /* tp_doc */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
125 0, /* tp_traverse */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
126 0, /* tp_clear */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
127 0, /* tp_richcompare */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
128 0, /* tp_weaklistoffset */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
129 0, /* tp_iter */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
130 0, /* tp_iternext */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
131 spamlist_methods, /* tp_methods */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
132 0, /* tp_members */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
133 spamlist_getsets, /* tp_getset */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
134 DEFERRED_ADDRESS(&PyList_Type), /* tp_base */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
135 0, /* tp_dict */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
136 0, /* tp_descr_get */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
137 0, /* tp_descr_set */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
138 0, /* tp_dictoffset */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
139 (initproc)spamlist_init, /* tp_init */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
140 0, /* tp_alloc */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
141 0, /* tp_new */
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
142 };
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
143
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
144 /* spamdict -- a dict subtype */
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
145
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
146 typedef struct {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
147 PyDictObject dict;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
148 int state;
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
149 } spamdictobject;
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
150
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
151 static PyObject *
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
152 spamdict_getstate(spamdictobject *self, PyObject *args)
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
153 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
154 if (!PyArg_ParseTuple(args, ":getstate"))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
155 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
156 return PyInt_FromLong(self->state);
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
157 }
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
158
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
159 static PyObject *
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
160 spamdict_setstate(spamdictobject *self, PyObject *args)
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
161 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
162 int state;
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
163
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
164 if (!PyArg_ParseTuple(args, "i:setstate", &state))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
165 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
166 self->state = state;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
167 Py_INCREF(Py_None);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
168 return Py_None;
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
169 }
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
170
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
171 static PyMethodDef spamdict_methods[] = {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
172 {"getstate", (PyCFunction)spamdict_getstate, METH_VARARGS,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
173 PyDoc_STR("getstate() -> state")},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
174 {"setstate", (PyCFunction)spamdict_setstate, METH_VARARGS,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
175 PyDoc_STR("setstate(state)")},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
176 {NULL, NULL},
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
177 };
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
178
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
179 static int
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
180 spamdict_init(spamdictobject *self, PyObject *args, PyObject *kwds)
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
181 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
182 if (PyDict_Type.tp_init((PyObject *)self, args, kwds) < 0)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
183 return -1;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
184 self->state = 0;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
185 return 0;
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
186 }
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
187
20012
3faabf54b8b8 Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents: 19299
diff changeset
188 static PyMemberDef spamdict_members[] = {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
189 {"state", T_INT, offsetof(spamdictobject, state), READONLY,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
190 PyDoc_STR("an int variable for demonstration purposes")},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
191 {0}
19281
be85f686ad97 Add 'state' as a read-only attribute to spamdict. This serves as an
Guido van Rossum <guido@python.org>
parents: 19040
diff changeset
192 };
be85f686ad97 Add 'state' as a read-only attribute to spamdict. This serves as an
Guido van Rossum <guido@python.org>
parents: 19040
diff changeset
193
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
194 static PyTypeObject spamdict_type = {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
195 PyVarObject_HEAD_INIT(DEFERRED_ADDRESS(&PyType_Type), 0)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
196 "xxsubtype.spamdict",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
197 sizeof(spamdictobject),
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
198 0,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
199 0, /* tp_dealloc */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
200 0, /* tp_print */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
201 0, /* tp_getattr */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
202 0, /* tp_setattr */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
203 0, /* tp_compare */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
204 0, /* tp_repr */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
205 0, /* tp_as_number */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
206 0, /* tp_as_sequence */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
207 0, /* tp_as_mapping */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
208 0, /* tp_hash */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
209 0, /* tp_call */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
210 0, /* tp_str */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
211 0, /* tp_getattro */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
212 0, /* tp_setattro */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
213 0, /* tp_as_buffer */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
214 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
215 0, /* tp_doc */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
216 0, /* tp_traverse */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
217 0, /* tp_clear */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
218 0, /* tp_richcompare */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
219 0, /* tp_weaklistoffset */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
220 0, /* tp_iter */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
221 0, /* tp_iternext */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
222 spamdict_methods, /* tp_methods */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
223 spamdict_members, /* tp_members */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
224 0, /* tp_getset */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
225 DEFERRED_ADDRESS(&PyDict_Type), /* tp_base */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
226 0, /* tp_dict */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
227 0, /* tp_descr_get */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
228 0, /* tp_descr_set */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
229 0, /* tp_dictoffset */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
230 (initproc)spamdict_init, /* tp_init */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
231 0, /* tp_alloc */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
232 0, /* tp_new */
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
233 };
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
234
20594
0d5e6fc0481d Adding missing "static" declarations (found by "make smelly").
Neil Schemenauer <nascheme@enme.ucalgary.ca>
parents: 20015
diff changeset
235 static PyObject *
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
236 spam_bench(PyObject *self, PyObject *args)
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
237 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
238 PyObject *obj, *name, *res;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
239 int n = 1000;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
240 time_t t0, t1;
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
241
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
242 if (!PyArg_ParseTuple(args, "OS|i", &obj, &name, &n))
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
243 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
244 t0 = clock();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
245 while (--n >= 0) {
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
246 res = PyObject_GetAttr(obj, name);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
247 if (res == NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
248 return NULL;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
249 Py_DECREF(res);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
250 }
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
251 t1 = clock();
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
252 return PyFloat_FromDouble((double)(t1-t0) / CLOCKS_PER_SEC);
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
253 }
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
254
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
255 static PyMethodDef xxsubtype_functions[] = {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
256 {"bench", spam_bench, METH_VARARGS},
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
257 {NULL, NULL} /* sentinel */
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
258 };
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
259
24471
f66b3a3509c7 Excise DL_EXPORT/DL_IMPORT from Modules/*. Required adding a prototype
Mark Hammond <mhammond@skippinet.com.au>
parents: 24280
diff changeset
260 PyMODINIT_FUNC
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
261 initxxsubtype(void)
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
262 {
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
263 PyObject *m;
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
264
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
265 /* Fill in deferred data addresses. This must be done before
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
266 PyType_Ready() is called. Note that PyType_Ready() automatically
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
267 initializes the ob.ob_type field to &PyType_Type if it's NULL,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
268 so it's not necessary to fill in ob_type first. */
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
269 spamdict_type.tp_base = &PyDict_Type;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
270 if (PyType_Ready(&spamdict_type) < 0)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
271 return;
21443
4f621bac7526 David Abrahams tried to compile this as a separate DLL under MSVC, and
Tim Peters <tim.peters@gmail.com>
parents: 21338
diff changeset
272
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
273 spamlist_type.tp_base = &PyList_Type;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
274 if (PyType_Ready(&spamlist_type) < 0)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
275 return;
21443
4f621bac7526 David Abrahams tried to compile this as a separate DLL under MSVC, and
Tim Peters <tim.peters@gmail.com>
parents: 21338
diff changeset
276
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
277 m = Py_InitModule3("xxsubtype",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
278 xxsubtype_functions,
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
279 xxsubtype__doc__);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
280 if (m == NULL)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
281 return;
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
282
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
283 if (PyType_Ready(&spamlist_type) < 0)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
284 return;
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
285 if (PyType_Ready(&spamdict_type) < 0)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
286 return;
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
287
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
288 Py_INCREF(&spamlist_type);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
289 if (PyModule_AddObject(m, "spamlist",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
290 (PyObject *) &spamlist_type) < 0)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
291 return;
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
292
61463
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
293 Py_INCREF(&spamdict_type);
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
294 if (PyModule_AddObject(m, "spamdict",
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
295 (PyObject *) &spamdict_type) < 0)
fd25030223b0 Untabify C files. Will watch buildbots.
Antoine Pitrou <solipsis@pitrou.net>
parents: 42334
diff changeset
296 return;
18933
09df3254b49d Merge of descr-branch back into trunk.
Tim Peters <tim.peters@gmail.com>
parents:
diff changeset
297 }