blob: 334d5eca1565a2dd130508049a8c5da9e57a5b0c [file] [log] [blame]
Jack Jansen6259af91996-01-09 17:15:16 +00001# Scan an Apple header file, generating a Python file of generator calls.
2
Jack Jansen0c4d9471998-04-17 14:07:56 +00003import sys
4import os
Jack Jansenaaebdd62002-08-05 15:39:30 +00005from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansen0c4d9471998-04-17 14:07:56 +00006sys.path.append(BGENDIR)
Jack Jansen6259af91996-01-09 17:15:16 +00007from scantools import Scanner
8
9LONG = "Fonts"
Jack Jansen21f96871998-02-20 16:02:09 +000010SHORT = "fm"
Jack Jansen6259af91996-01-09 17:15:16 +000011
12def main():
Tim Peters182b5ac2004-07-18 06:16:08 +000013 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! ==="
Jack Jansen6259af91996-01-09 17:15:16 +000024
25class MyScanner(Scanner):
26
Tim Peters182b5ac2004-07-18 06:16:08 +000027 def destination(self, type, name, arglist):
28 classname = "Function"
29 listname = "functions"
30 return classname, listname
Jack Jansen6259af91996-01-09 17:15:16 +000031
Tim Peters182b5ac2004-07-18 06:16:08 +000032 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 ]
Jack Jansen6259af91996-01-09 17:15:16 +000050
Tim Peters182b5ac2004-07-18 06:16:08 +000051 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 ]
Jack Jansen6259af91996-01-09 17:15:16 +000058
Tim Peters182b5ac2004-07-18 06:16:08 +000059 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")
Jack Jansenb55e5f12001-01-03 16:44:27 +000070
Jack Jansen6259af91996-01-09 17:15:16 +000071if __name__ == "__main__":
Tim Peters182b5ac2004-07-18 06:16:08 +000072 main()