source: python/trunk/Mac/Modules/ah/ahsupport.py

Last change on this file was 2, checked in by Yuri Dario, 15 years ago

Initial import for vendor code.

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
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).
5
6import string
7
8# Declarations that change for each manager
9MACHEADERFILE = 'AppleHelp.h' # The Apple header file
10MODNAME = '_AH' # The name of the module
11
12# The following is *usually* unchanged but may still require tuning
13MODPREFIX = 'Ah' # The prefix for module-wide routines
14INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
15OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
16
17from macsupport import *
18
19# Create the type objects
20AHTOCType = Type("AHTOCType", "h")
21
22includestuff = includestuff + """
23#include <Carbon/Carbon.h>
24
25"""
26
27# From here on it's basically all boiler plate...
28
29# Create the generator groups and link them
30module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
31
32# Create the generator classes used to populate the lists
33Function = OSErrFunctionGenerator
34
35# Create and populate the lists
36functions = []
37execfile(INPUTFILE)
38
39# add the populated lists to the generator groups
40# (in a different wordl the scan program would generate this)
41for f in functions: module.add(f)
42
43# generate output (open the output file as late as possible)
44SetOutputFileName(OUTPUTFILE)
45module.generate()
Note: See TracBrowser for help on using the repository browser.