1 # This script generates a Python interface for an Apple Macintosh Manager.
2 # It uses the "bgen" package to generate C code.
3 # The function specifications are generated by scanning the mamager's header file,
4 # using the "scantools" package (customized for this particular manager).
8 # Declarations that change for each manager
9 MACHEADERFILE
= 'Fonts.h' # The Apple header file
10 MODNAME
= 'Fm' # The name of the module
12 # The following is *usually* unchanged but may still require tuning
13 MODPREFIX
= MODNAME
# The prefix for module-wide routines
14 INPUTFILE
= string
.lower(MODPREFIX
) + 'gen.py' # The file generated by the scanner
15 OUTPUTFILE
= MODNAME
+ "module.c" # The file generated by this program
17 from macsupport
import *
19 # Create the type objects
21 includestuff
= includestuff
+ """
22 #include <%s>""" % MACHEADERFILE
+ """
25 ** Parse/generate ComponentDescriptor records
27 PyObject *FMRec_New(itself)
31 return Py_BuildValue("O&O&O&O&O&",
32 PyMac_BuildFixed, itself->ascent,
33 PyMac_BuildFixed, itself->descent,
34 PyMac_BuildFixed, itself->leading,
35 PyMac_BuildFixed, itself->widMax,
36 ResObj_New, itself->wTabHandle);
41 FMRec_Convert(v, p_itself)
45 return PyArg_ParseTuple(v, "O&O&O&O&O&",
46 PyMac_GetFixed, &itself->ascent,
47 PyMac_GetFixed, &itself->descent,
48 PyMac_GetFixed, &itself->leading,
49 PyMac_GetFixed, &itself->widMax,
50 ResObj_Convert, &itself->wTabHandle);
56 FMetricRecPtr
= OpaqueType('FMetricRec', 'FMRec')
58 # Create the generator groups and link them
59 module
= MacModule(MODNAME
, MODPREFIX
, includestuff
, finalstuff
, initstuff
)
61 # Create the generator classes used to populate the lists
62 Function
= OSErrFunctionGenerator
64 # Create and populate the lists
68 # add the populated lists to the generator groups
69 # (in a different wordl the scan program would generate this)
70 for f
in functions
: module
.add(f
)
72 # generate output (open the output file as late as possible)
73 SetOutputFileName(OUTPUTFILE
)