forked from pygame-community/pygame-ce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeometry.c
67 lines (55 loc) · 1.52 KB
/
geometry.c
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
61
62
63
64
65
66
67
#include "circle.c"
#include "line.c"
#include "geometry_common.c"
static PyMethodDef geometry_methods[] = {{NULL, NULL, 0, NULL}};
MODINIT_DEFINE(geometry)
{
PyObject *module, *apiobj;
static void *c_api[PYGAMEAPI_GEOMETRY_NUMSLOTS];
static struct PyModuleDef _module = {
.m_base = PyModuleDef_HEAD_INIT,
.m_name = "geometry",
.m_doc = "Module for the Line, Circle and Polygon objects\n",
.m_size = -1,
.m_methods = geometry_methods,
};
import_pygame_base();
if (PyErr_Occurred()) {
return NULL;
}
import_pygame_rect();
if (PyErr_Occurred()) {
return NULL;
}
if (PyType_Ready(&pgCircle_Type) < 0) {
return NULL;
}
if (PyType_Ready(&pgLine_Type) < 0) {
return NULL;
}
module = PyModule_Create(&_module);
if (!module) {
return NULL;
}
Py_INCREF(&pgCircle_Type);
if (PyModule_AddObject(module, "Circle", (PyObject *)&pgCircle_Type)) {
Py_DECREF(&pgCircle_Type);
Py_DECREF(module);
return NULL;
}
Py_INCREF(&pgLine_Type);
if (PyModule_AddObject(module, "Line", (PyObject *)&pgLine_Type)) {
Py_DECREF(&pgLine_Type);
Py_DECREF(module);
return NULL;
}
c_api[0] = &pgCircle_Type;
c_api[1] = &pgLine_Type;
apiobj = encapsulate_api(c_api, "geometry");
if (PyModule_AddObject(module, PYGAMEAPI_LOCAL_ENTRY, apiobj)) {
Py_XDECREF(apiobj);
Py_DECREF(module);
return NULL;
}
return module;
}