Added news on recent changes to logging
[python.git] / Mac / Modules / fm / fmsupport.py
blobe69205316c707778a11c440fdf4e8dd2d75402e7
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).
6 import string
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 = 'Fm' # 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 class RevVarInputBufferType(VarInputBufferType):
22 def passInput(self, name):
23 return "%s__len__, %s__in__" % (name, name)
25 TextBuffer = RevVarInputBufferType()
28 includestuff = includestuff + """
29 #include <Carbon/Carbon.h>
33 ** Parse/generate ComponentDescriptor records
35 static PyObject *
36 FMRec_New(FMetricRec *itself)
39 return Py_BuildValue("O&O&O&O&O&",
40 PyMac_BuildFixed, itself->ascent,
41 PyMac_BuildFixed, itself->descent,
42 PyMac_BuildFixed, itself->leading,
43 PyMac_BuildFixed, itself->widMax,
44 ResObj_New, itself->wTabHandle);
47 #if 0
48 /* Not needed... */
49 static int
50 FMRec_Convert(PyObject *v, FMetricRec *p_itself)
52 return PyArg_ParseTuple(v, "O&O&O&O&O&",
53 PyMac_GetFixed, &itself->ascent,
54 PyMac_GetFixed, &itself->descent,
55 PyMac_GetFixed, &itself->leading,
56 PyMac_GetFixed, &itself->widMax,
57 ResObj_Convert, &itself->wTabHandle);
59 #endif
61 """
63 FMetricRecPtr = OpaqueType('FMetricRec', 'FMRec')
65 # Create the generator groups and link them
66 module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
68 # Create the generator classes used to populate the lists
69 Function = OSErrWeakLinkFunctionGenerator
71 # Create and populate the lists
72 functions = []
73 execfile(INPUTFILE)
75 # add the populated lists to the generator groups
76 # (in a different wordl the scan program would generate this)
77 for f in functions: module.add(f)
79 # generate output (open the output file as late as possible)
80 SetOutputFileName(OUTPUTFILE)
81 module.generate()