1/* 2 * Helper classes for test_clinmeth 3 */ 4#include "Python.h" 5#include "pyobjc-api.h" 6#include <stdarg.h> 7 8#import <Foundation/Foundation.h> 9 10@interface PyObjC_ClsInst1 : NSObject 11{ 12} 13-(int)instance; 14-(int)both; 15+(int)both; 16+(int)clsmeth; 17@end 18 19@implementation PyObjC_ClsInst1 20 21-(int)instance 22{ 23 return 1; 24} 25 26-(int)both 27{ 28 return 2; 29} 30 31+(int)both 32{ 33 return 3; 34} 35 36+(int)clsmeth 37{ 38 return 4; 39} 40@end 41 42 43@interface PyObjC_ClsInst2 : PyObjC_ClsInst1 44{ 45} 46-(int)instance; 47-(int)both; 48+(int)both; 49+(int)clsmeth; 50@end 51 52@implementation PyObjC_ClsInst2 53 54-(int)instance 55{ 56 return 10; 57} 58 59-(int)both 60{ 61 return 20; 62} 63 64+(int)both 65{ 66 return 30; 67} 68 69+(int)clsmeth 70{ 71 return 40; 72} 73@end 74 75 76 77static PyMethodDef mod_methods[] = { 78 { 0, 0, 0, 0 } 79}; 80 81#if PY_VERSION_HEX >= 0x03000000 82 83static struct PyModuleDef mod_module = { 84 PyModuleDef_HEAD_INIT, 85 "clinmeth", 86 NULL, 87 0, 88 mod_methods, 89 NULL, 90 NULL, 91 NULL, 92 NULL 93}; 94 95#define INITERROR() return NULL 96#define INITDONE() return m 97 98PyObject* PyInit_clinmeth(void); 99 100PyObject* 101PyInit_clinmeth(void) 102 103#else 104 105#define INITERROR() return 106#define INITDONE() return 107 108void initclinmeth(void); 109 110void 111initclinmeth(void) 112#endif 113{ 114 PyObject* m; 115 116#if PY_VERSION_HEX >= 0x03000000 117 m = PyModule_Create(&mod_module); 118#else 119 m = Py_InitModule4("clinmeth", mod_methods, 120 NULL, NULL, PYTHON_API_VERSION); 121#endif 122 if (!m) { 123 INITERROR(); 124 } 125 126 if (PyObjC_ImportAPI(m) < 0) { 127 INITERROR(); 128 } 129 130 if (PyModule_AddObject(m, "PyObjC_ClsInst1", 131 PyObjCClass_New([PyObjC_ClsInst1 class])) < 0) { 132 INITERROR(); 133 } 134 if (PyModule_AddObject(m, "PyObjC_ClsInst2", 135 PyObjCClass_New([PyObjC_ClsInst2 class])) < 0) { 136 INITERROR(); 137 } 138 139 INITDONE(); 140} 141