ยปCore Development>Code coverage>Mac/Modules/ah/ahsupport.py

Python code coverage for Mac/Modules/ah/ahsupport.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 = 'AppleHelp.h' # The Apple header file
10n/aMODNAME = '_AH' # The name of the module
11n/a
12n/a# The following is *usually* unchanged but may still require tuning
13n/aMODPREFIX = 'Ah' # 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/aAHTOCType = Type("AHTOCType", "h")
21n/a
22n/aincludestuff = includestuff + """
23n/a#include <Carbon/Carbon.h>
24n/a
25n/a"""
26n/a
27n/a# From here on it's basically all boiler plate...
28n/a
29n/a# Create the generator groups and link them
30n/amodule = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
31n/a
32n/a# Create the generator classes used to populate the lists
33n/aFunction = OSErrFunctionGenerator
34n/a
35n/a# Create and populate the lists
36n/afunctions = []
37n/aexecfile(INPUTFILE)
38n/a
39n/a# add the populated lists to the generator groups
40n/a# (in a different wordl the scan program would generate this)
41n/afor f in functions: module.add(f)
42n/a
43n/a# generate output (open the output file as late as possible)
44n/aSetOutputFileName(OUTPUTFILE)
45n/amodule.generate()