ยปCore Development>Code coverage>Mac/Modules/fm/fmsupport.py

Python code coverage for Mac/Modules/fm/fmsupport.py

#countcontent
1n/a# This script generates a Python interface for an Apple Macintosh Manager.
2n/a# It uses the "bgen" package to generate C code.
3n/a# The function specifications are generated by scanning the mamager's header file,
4n/a# using the "scantools" package (customized for this particular manager).
5n/a
6n/aimport string
7n/a
8n/a# Declarations that change for each manager
9n/aMACHEADERFILE = 'Fonts.h' # The Apple header file
10n/aMODNAME = '_Fm' # The name of the module
11n/a
12n/a# The following is *usually* unchanged but may still require tuning
13n/aMODPREFIX = 'Fm' # The prefix for module-wide routines
14n/aINPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
15n/aOUTPUTFILE = MODNAME + "module.c" # The file generated by this program
16n/a
17n/afrom macsupport import *
18n/a
19n/a# Create the type objects
20n/a
21n/aclass RevVarInputBufferType(VarInputBufferType):
22n/a def passInput(self, name):
23n/a return "%s__len__, %s__in__" % (name, name)
24n/a
25n/aTextBuffer = RevVarInputBufferType()
26n/a
27n/a
28n/aincludestuff = includestuff + """
29n/a#include <Carbon/Carbon.h>
30n/a
31n/a
32n/a/*
33n/a** Parse/generate ComponentDescriptor records
34n/a*/
35n/astatic PyObject *
36n/aFMRec_New(FMetricRec *itself)
37n/a{
38n/a
39n/a return Py_BuildValue("O&O&O&O&O&",
40n/a PyMac_BuildFixed, itself->ascent,
41n/a PyMac_BuildFixed, itself->descent,
42n/a PyMac_BuildFixed, itself->leading,
43n/a PyMac_BuildFixed, itself->widMax,
44n/a ResObj_New, itself->wTabHandle);
45n/a}
46n/a
47n/a#if 0
48n/a/* Not needed... */
49n/astatic int
50n/aFMRec_Convert(PyObject *v, FMetricRec *p_itself)
51n/a{
52n/a return PyArg_ParseTuple(v, "O&O&O&O&O&",
53n/a PyMac_GetFixed, &itself->ascent,
54n/a PyMac_GetFixed, &itself->descent,
55n/a PyMac_GetFixed, &itself->leading,
56n/a PyMac_GetFixed, &itself->widMax,
57n/a ResObj_Convert, &itself->wTabHandle);
58n/a}
59n/a#endif
60n/a
61n/a"""
62n/a
63n/aFMetricRecPtr = OpaqueType('FMetricRec', 'FMRec')
64n/a
65n/a# Create the generator groups and link them
66n/amodule = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
67n/a
68n/a# Create the generator classes used to populate the lists
69n/aFunction = OSErrWeakLinkFunctionGenerator
70n/a
71n/a# Create and populate the lists
72n/afunctions = []
73n/aexecfile(INPUTFILE)
74n/a
75n/a# add the populated lists to the generator groups
76n/a# (in a different wordl the scan program would generate this)
77n/afor f in functions: module.add(f)
78n/a
79n/a# generate output (open the output file as late as possible)
80n/aSetOutputFileName(OUTPUTFILE)
81n/amodule.generate()