1/*
2 * This module is used in the unittests for object initialize.
3 */
4#include "Python.h"
5#include "pyobjc-api.h"
6
7#import <Foundation/Foundation.h>
8
9struct TestStructPointerStruct {
10	int i1;
11};
12
13static struct TestStructPointerStruct myGlobal = { 1 };
14
15@interface OC_TestStructPointer : NSObject
16{
17}
18+(struct TestStructPointerStruct*)returnPointerToStruct;
19@end
20
21@implementation OC_TestStructPointer
22+(struct TestStructPointerStruct*)returnPointerToStruct
23{
24	return &myGlobal;
25}
26@end
27
28
29static PyMethodDef mod_methods[] = {
30	{ 0, 0, 0, 0 }
31};
32
33#if PY_VERSION_HEX >= 0x03000000
34
35static struct PyModuleDef mod_module = {
36	PyModuleDef_HEAD_INIT,
37	"structpointer1",
38	NULL,
39	0,
40	mod_methods,
41	NULL,
42	NULL,
43	NULL,
44	NULL
45};
46
47#define INITERROR() return NULL
48#define INITDONE() return m
49
50PyObject* PyInit_structpointer1(void);
51
52PyObject*
53PyInit_structpointer1(void)
54
55#else
56
57#define INITERROR() return
58#define INITDONE() return
59
60void initstructpointer1(void);
61
62void
63initstructpointer1(void)
64#endif
65{
66	PyObject* m;
67
68#if PY_VERSION_HEX >= 0x03000000
69	m = PyModule_Create(&mod_module);
70#else
71	m = Py_InitModule4("structpointer1", mod_methods,
72		NULL, NULL, PYTHON_API_VERSION);
73#endif
74	if (!m) {
75		INITERROR();
76	}
77
78	if (PyObjC_ImportAPI(m) < 0) {
79		INITERROR();
80	}
81	if (PyModule_AddObject(m, "OC_TestStructPointer",
82		PyObjCClass_New([OC_TestStructPointer class])) < 0) {
83		INITERROR();
84	}
85
86	INITDONE();
87}
88