source: trunk/essentials/dev-lang/python/Mac/Modules/fm/fmscan.py

Last change on this file was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 2.5 KB
Line 
1# Scan an Apple header file, generating a Python file of generator calls.
2
3import sys
4import os
5from bgenlocations import TOOLBOXDIR, BGENDIR
6sys.path.append(BGENDIR)
7from scantools import Scanner
8
9LONG = "Fonts"
10SHORT = "fm"
11
12def main():
13 input = "Fonts.h"
14 output = SHORT + "gen.py"
15 defsoutput = TOOLBOXDIR + LONG + ".py"
16 scanner = MyScanner(input, output, defsoutput)
17 scanner.scan()
18 scanner.close()
19 print "=== Testing definitions output code ==="
20 execfile(defsoutput, {}, {})
21 print "=== Done scanning and generating, now importing the generated code... ==="
22 exec "import " + SHORT + "support"
23 print "=== Done. It's up to you to compile it now! ==="
24
25class MyScanner(Scanner):
26
27 def destination(self, type, name, arglist):
28 classname = "Function"
29 listname = "functions"
30 return classname, listname
31
32 def makeblacklistnames(self):
33 return [
34 "OutlineMetrics", # Too complicated
35 "AntiTextIsAntiAliased", # XXXX Missing from library...
36 "AntiTextGetEnabled",
37 "AntiTextSetEnabled",
38 "AntiTextGetApplicationAware",
39 "AntiTextSetApplicationAware",
40 # These are tricky: they're not Carbon dependent or anything, but they
41 # exist only on 8.6 or later (both in Carbon and Classic).
42 # Disabling them is the easiest path.
43 'SetAntiAliasedTextEnabled',
44 'IsAntiAliasedTextEnabled',
45 # OS8-only
46 'InitFonts',
47 'SetFontLock',
48 'FlushFonts',
49 ]
50
51 def makeblacklisttypes(self):
52 return [
53 "FMInput_ptr", # Not needed for now
54 "FMOutPtr", # Ditto
55## "void_ptr", # Don't know how to do this right now
56 "FontInfo", # Ditto
57 ]
58
59 def makerepairinstructions(self):
60 return [
61 ([('Str255', '*', 'InMode')], [('Str255', '*', 'OutMode')]),
62 ([('FMetricRecPtr', 'theMetrics', 'InMode')], [('FMetricRecPtr', 'theMetrics', 'OutMode')]),
63 ([('short', 'byteCount', 'InMode'), ('void_ptr', 'textAddr', 'InMode'),],
64 [('TextBuffer', 'inText', 'InMode')]),
65 ]
66
67 def writeinitialdefs(self):
68 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
69 self.defsfile.write("kNilOptions = 0\n")
70
71if __name__ == "__main__":
72 main()
Note: See TracBrowser for help on using the repository browser.