• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 = 'Folders.h'             # The Apple header file
10MODNAME = '_Folder'                             # The name of the module
11
12# The following is *usually* unchanged but may still require tuning
13MODPREFIX = 'Folder'                    # 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
20ConstStrFileNameParam = ConstStr255Param
21StrFileName = Str255
22FolderClass = OSTypeType("FolderClass")
23# FolderDesc
24FolderDescFlags = Type("FolderDescFlags", "l")
25FolderLocation = OSTypeType("FolderLocation")
26# FolderRouting
27FolderType = OSTypeType("FolderType")
28RoutingFlags = Type("RoutingFlags", "l")
29
30
31includestuff = includestuff + """
32#include <Carbon/Carbon.h>
33
34"""
35
36execfile(string.lower(MODPREFIX) + 'typetest.py')
37
38# From here on it's basically all boiler plate...
39
40# Create the generator groups and link them
41module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
42
43# Create the generator classes used to populate the lists
44Function = OSErrFunctionGenerator
45
46# Create and populate the lists
47functions = []
48execfile(INPUTFILE)
49
50# add the populated lists to the generator groups
51# (in a different wordl the scan program would generate this)
52for f in functions: module.add(f)
53
54# generate output (open the output file as late as possible)
55SetOutputFileName(OUTPUTFILE)
56module.generate()
57