-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_prime.h
More file actions
60 lines (51 loc) · 1.41 KB
/
_prime.h
File metadata and controls
60 lines (51 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <Python.h>
/*
Basic implementation of a PyObject in C
Placeholder for an n-bit integer sieve type in Python3.x
struct PrimeSieveObject {
HEAD_INIT *PrimeSieve;
int ExitCode;
}
*/
typedef struct {
PyObject_HEAD
/* Type-specific fields go here. */
} PrimeSieveObject;
static PyTypeObject PrimeSieveObject = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"primetype.Sieve", /* tp_name */
sizeof(PrimeSieveObject), /* tp_basicsize */
0, /* tp_itemsize */
0, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
">%20DOC%20<", /* tp_doc */
};
PyMODINIT_FUNC
initprimetype(void)
{
PyObject* m;
PrimeSieveObject.tp_new = PyType_GenericNew;
if (PyType_Ready(&PrimeSieveObject) < 0)
return;
m = Py_InitModule3("primetype", NULL,
"Extension module that creates an prime sieve type.");
if (m == NULL)
return;
Py_INCREF(&PrimeSieveObject);
PyModule_AddObject(m, "Prime", (PyObject *)&PrimeSieveObject);
}