| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
import string |
| 7 |
|
| 8 |
|
| 9 |
MACHEADERFILE = 'OSA.h' |
| 10 |
MODNAME = '_OSA' |
| 11 |
|
| 12 |
|
| 13 |
MODPREFIX = 'OSA' |
| 14 |
OBJECTPREFIX = 'OSAObj' |
| 15 |
INPUTFILE = string.lower(MODPREFIX) + 'gen.py' |
| 16 |
OUTPUTFILE = MODNAME + "module.c" |
| 17 |
|
| 18 |
from macsupport import * |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
includestuff = includestuff + """ |
| 23 |
#if PY_VERSION_HEX < 0x02040000 |
| 24 |
PyObject *PyMac_GetOSErrException(void); |
| 25 |
#endif |
| 26 |
#include <Carbon/Carbon.h> |
| 27 |
|
| 28 |
#ifdef USE_TOOLBOX_OBJECT_GLUE |
| 29 |
extern PyObject *_OSAObj_New(ComponentInstance); |
| 30 |
extern int _OSAObj_Convert(PyObject *, ComponentInstance *); |
| 31 |
|
| 32 |
#define OSAObj_New _OSAObj_New |
| 33 |
#define OSAObj_Convert _OSAObj_Convert |
| 34 |
#endif |
| 35 |
""" |
| 36 |
|
| 37 |
initstuff = initstuff + """ |
| 38 |
/* |
| 39 |
PyMac_INIT_TOOLBOX_OBJECT_NEW(ComponentInstance, OSAObj_New); |
| 40 |
PyMac_INIT_TOOLBOX_OBJECT_CONVERT(ComponentInstance, OSAObj_Convert); |
| 41 |
*/ |
| 42 |
""" |
| 43 |
|
| 44 |
ComponentInstance = OpaqueByValueType('ComponentInstance', OBJECTPREFIX) |
| 45 |
OSAError = OSErrType("OSAError", "l") |
| 46 |
|
| 47 |
OSAID = Type("OSAID", "l") |
| 48 |
OSADebugCallFrameRef = Type("OSADebugCallFrameRef", "l") |
| 49 |
OSADebugSessionRef = Type("OSADebugSessionRef", "l") |
| 50 |
OSADebugStepKind = Type("OSADebugStepKind", "l") |
| 51 |
DescType = OSTypeType("DescType") |
| 52 |
AEDesc = OpaqueType('AEDesc') |
| 53 |
AEDesc_ptr = OpaqueType('AEDesc') |
| 54 |
AEAddressDesc = OpaqueType('AEAddressDesc', 'AEDesc') |
| 55 |
AEAddressDesc_ptr = OpaqueType('AEAddressDesc', 'AEDesc') |
| 56 |
AEDescList = OpaqueType('AEDescList', 'AEDesc') |
| 57 |
AEDescList_ptr = OpaqueType('AEDescList', 'AEDesc') |
| 58 |
AERecord = OpaqueType('AERecord', 'AEDesc') |
| 59 |
AERecord_ptr = OpaqueType('AERecord', 'AEDesc') |
| 60 |
AppleEvent = OpaqueType('AppleEvent', 'AEDesc') |
| 61 |
AppleEvent_ptr = OpaqueType('AppleEvent', 'AEDesc') |
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition): |
| 66 |
def outputCheckNewArg(self): |
| 67 |
Output("""if (itself == NULL) { |
| 68 |
PyErr_SetString(OSA_Error,"NULL ComponentInstance"); |
| 69 |
return NULL; |
| 70 |
}""") |
| 71 |
|
| 72 |
def outputCheckConvertArg(self): |
| 73 |
Output(""" |
| 74 |
if (CmpInstObj_Convert(v, p_itself)) |
| 75 |
return 1; |
| 76 |
PyErr_Clear(); |
| 77 |
""") |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) |
| 82 |
object = MyObjectDefinition('OSAComponentInstance', OBJECTPREFIX, |
| 83 |
'ComponentInstance') |
| 84 |
module.addobject(object) |
| 85 |
|
| 86 |
|
| 87 |
Function = OSErrWeakLinkFunctionGenerator |
| 88 |
Method = OSErrWeakLinkMethodGenerator |
| 89 |
|
| 90 |
|
| 91 |
execfile(string.lower(MODPREFIX) + 'typetest.py') |
| 92 |
|
| 93 |
|
| 94 |
functions = [] |
| 95 |
methods = [] |
| 96 |
execfile(INPUTFILE) |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
for f in functions: module.add(f) |
| 101 |
for f in methods: object.add(f) |
| 102 |
|
| 103 |
|
| 104 |
SetOutputFileName(OUTPUTFILE) |
| 105 |
module.generate() |