| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
import string |
| 7 |
|
| 8 |
|
| 9 |
MODNAME = '_Launch' |
| 10 |
OBJECTNAME = 'UNUSED' |
| 11 |
KIND = 'Record' |
| 12 |
|
| 13 |
|
| 14 |
MODPREFIX = 'Launch' |
| 15 |
OBJECTTYPE = OBJECTNAME + KIND |
| 16 |
OBJECTPREFIX = MODPREFIX + 'Obj' |
| 17 |
INPUTFILE = string.lower(MODPREFIX) + 'gen.py' |
| 18 |
OUTPUTFILE = MODNAME + "module.c" |
| 19 |
|
| 20 |
from macsupport import * |
| 21 |
|
| 22 |
|
| 23 |
LSAcceptanceFlags = Type("LSAcceptanceFlags", "l") |
| 24 |
LSInitializeFlags = Type("LSInitializeFlags", "l") |
| 25 |
LSRequestedInfo = Type("LSRequestedInfo", "l") |
| 26 |
LSRolesMask = Type("LSRolesMask", "l") |
| 27 |
UniCharCount = Type("UniCharCount", "l") |
| 28 |
OptCFStringRef = OpaqueByValueType("CFStringRef", "OptCFStringRefObj") |
| 29 |
LSItemInfoRecord = OpaqueType("LSItemInfoRecord", "LSItemInfoRecord") |
| 30 |
|
| 31 |
includestuff = includestuff + """ |
| 32 |
#if PY_VERSION_HEX < 0x02040000 |
| 33 |
PyObject *PyMac_GetOSErrException(void); |
| 34 |
#endif |
| 35 |
|
| 36 |
#include <ApplicationServices/ApplicationServices.h> |
| 37 |
|
| 38 |
/* |
| 39 |
** Optional CFStringRef. None will pass NULL |
| 40 |
*/ |
| 41 |
static int |
| 42 |
OptCFStringRefObj_Convert(PyObject *v, CFStringRef *spec) |
| 43 |
{ |
| 44 |
if (v == Py_None) { |
| 45 |
*spec = NULL; |
| 46 |
return 1; |
| 47 |
} |
| 48 |
return CFStringRefObj_Convert(v, spec); |
| 49 |
} |
| 50 |
|
| 51 |
PyObject * |
| 52 |
OptCFStringRefObj_New(CFStringRef it) |
| 53 |
{ |
| 54 |
if (it == NULL) { |
| 55 |
Py_INCREF(Py_None); |
| 56 |
return Py_None; |
| 57 |
} |
| 58 |
return CFStringRefObj_New(it); |
| 59 |
} |
| 60 |
|
| 61 |
/* |
| 62 |
** Convert LSItemInfoRecord to Python. |
| 63 |
*/ |
| 64 |
PyObject * |
| 65 |
LSItemInfoRecord_New(LSItemInfoRecord *it) |
| 66 |
{ |
| 67 |
return Py_BuildValue("{s:is:O&s:O&s:O&s:O&s:i}", |
| 68 |
"flags", it->flags, |
| 69 |
"filetype", PyMac_BuildOSType, it->filetype, |
| 70 |
"creator", PyMac_BuildOSType, it->creator, |
| 71 |
"extension", OptCFStringRefObj_New, it->extension, |
| 72 |
"iconFileName", OptCFStringRefObj_New, it->iconFileName, |
| 73 |
"kindID", it->kindID); |
| 74 |
} |
| 75 |
""" |
| 76 |
|
| 77 |
|
| 78 |
execfile(string.lower(MODPREFIX) + 'typetest.py') |
| 79 |
|
| 80 |
|
| 81 |
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
Function = OSErrFunctionGenerator |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
functions = [] |
| 91 |
|
| 92 |
execfile(INPUTFILE) |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
for f in functions: module.add(f) |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
SetOutputFileName(OUTPUTFILE) |
| 101 |
module.generate() |