Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ab0a10

Browse files
committed
The new files included by \verbatiminput in newtypes.tex.
1 parent 81b750d commit 2ab0a10

2 files changed

Lines changed: 134 additions & 0 deletions

File tree

Doc/ext/noddy.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
#include <Python.h>
2+
3+
staticforward PyTypeObject noddy_NoddyType;
4+
5+
typedef struct {
6+
PyObject_HEAD
7+
} noddy_NoddyObject;
8+
9+
static PyObject*
10+
noddy_new_noddy(PyObject* self, PyObject* args)
11+
{
12+
noddy_NoddyObject* noddy;
13+
14+
if (!PyArg_ParseTuple(args,":new_noddy"))
15+
return NULL;
16+
17+
noddy = PyObject_New(noddy_NoddyObject, &noddy_NoddyType);
18+
19+
return (PyObject*)noddy;
20+
}
21+
22+
static void
23+
noddy_noddy_dealloc(PyObject* self)
24+
{
25+
PyObject_Del(self);
26+
}
27+
28+
static PyTypeObject noddy_NoddyType = {
29+
PyObject_HEAD_INIT(NULL)
30+
0,
31+
"Noddy",
32+
sizeof(noddy_NoddyObject),
33+
0,
34+
noddy_noddy_dealloc, /*tp_dealloc*/
35+
0, /*tp_print*/
36+
0, /*tp_getattr*/
37+
0, /*tp_setattr*/
38+
0, /*tp_compare*/
39+
0, /*tp_repr*/
40+
0, /*tp_as_number*/
41+
0, /*tp_as_sequence*/
42+
0, /*tp_as_mapping*/
43+
0, /*tp_hash */
44+
};
45+
46+
static PyMethodDef noddy_methods[] = {
47+
{"new_noddy", noddy_new_noddy, METH_VARARGS,
48+
"Create a new Noddy object."},
49+
{NULL, NULL, 0, NULL}
50+
};
51+
52+
DL_EXPORT(void)
53+
initnoddy(void)
54+
{
55+
noddy_NoddyType.ob_type = &PyType_Type;
56+
57+
Py_InitModule("noddy", noddy_methods);
58+
}

Doc/ext/typestruct.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
typedef struct _typeobject {
2+
PyObject_VAR_HEAD
3+
char *tp_name; /* For printing, in format "<module>.<name>" */
4+
int tp_basicsize, tp_itemsize; /* For allocation */
5+
6+
/* Methods to implement standard operations */
7+
8+
destructor tp_dealloc;
9+
printfunc tp_print;
10+
getattrfunc tp_getattr;
11+
setattrfunc tp_setattr;
12+
cmpfunc tp_compare;
13+
reprfunc tp_repr;
14+
15+
/* Method suites for standard classes */
16+
17+
PyNumberMethods *tp_as_number;
18+
PySequenceMethods *tp_as_sequence;
19+
PyMappingMethods *tp_as_mapping;
20+
21+
/* More standard operations (here for binary compatibility) */
22+
23+
hashfunc tp_hash;
24+
ternaryfunc tp_call;
25+
reprfunc tp_str;
26+
getattrofunc tp_getattro;
27+
setattrofunc tp_setattro;
28+
29+
/* Functions to access object as input/output buffer */
30+
PyBufferProcs *tp_as_buffer;
31+
32+
/* Flags to define presence of optional/expanded features */
33+
long tp_flags;
34+
35+
char *tp_doc; /* Documentation string */
36+
37+
/* Assigned meaning in release 2.0 */
38+
/* call function for all accessible objects */
39+
traverseproc tp_traverse;
40+
41+
/* delete references to contained objects */
42+
inquiry tp_clear;
43+
44+
/* Assigned meaning in release 2.1 */
45+
/* rich comparisons */
46+
richcmpfunc tp_richcompare;
47+
48+
/* weak reference enabler */
49+
long tp_weaklistoffset;
50+
51+
/* Added in release 2.2 */
52+
/* Iterators */
53+
getiterfunc tp_iter;
54+
iternextfunc tp_iternext;
55+
56+
/* Attribute descriptor and subclassing stuff */
57+
struct PyMethodDef *tp_methods;
58+
struct memberlist *tp_members;
59+
struct getsetlist *tp_getset;
60+
struct _typeobject *tp_base;
61+
PyObject *tp_dict;
62+
descrgetfunc tp_descr_get;
63+
descrsetfunc tp_descr_set;
64+
long tp_dictoffset;
65+
initproc tp_init;
66+
allocfunc tp_alloc;
67+
newfunc tp_new;
68+
destructor tp_free; /* Low-level free-memory routine */
69+
inquiry tp_is_gc; /* For PyObject_IS_GC */
70+
PyObject *tp_bases;
71+
PyObject *tp_mro; /* method resolution order */
72+
PyObject *tp_cache;
73+
PyObject *tp_subclasses;
74+
PyObject *tp_weaklist;
75+
76+
} PyTypeObject;

0 commit comments

Comments
 (0)