blob: 73aad3ef7933725361967d2d52336fcc2af0109d [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():
13 input = "Fonts.h"
14 output = SHORT + "gen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000015 defsoutput = TOOLBOXDIR + LONG + ".py"
Jack Jansen6259af91996-01-09 17:15:16 +000016 scanner = MyScanner(input, output, defsoutput)
17 scanner.scan()
18 scanner.close()
Jack Jansen87eea882002-08-15 21:48:16 +000019 print "=== Testing definitions output code ==="
20 execfile(defsoutput, {}, {})
Jack Jansen6259af91996-01-09 17:15:16 +000021 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
Jack Jansen21f96871998-02-20 16:02:09 +000035 "AntiTextIsAntiAliased", # XXXX Missing from library...
36 "AntiTextGetEnabled",
37 "AntiTextSetEnabled",
38 "AntiTextGetApplicationAware",
39 "AntiTextSetApplicationAware",
Jack Jansen82bcbd02001-06-20 21:29:19 +000040 # 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',
Jack Jansen6c7e3262002-12-12 10:31:54 +000045 # OS8-only
46 'InitFonts',
47 'SetFontLock',
48 'FlushFonts',
Jack Jansen6259af91996-01-09 17:15:16 +000049 ]
50
51 def makeblacklisttypes(self):
52 return [
53 "FMInput_ptr", # Not needed for now
54 "FMOutPtr", # Ditto
Just van Rossumca3b2ff2002-01-07 14:15:02 +000055## "void_ptr", # Don't know how to do this right now
Jack Jansena05ac601999-12-12 21:41:51 +000056 "FontInfo", # Ditto
Jack Jansen6259af91996-01-09 17:15:16 +000057 ]
58
59 def makerepairinstructions(self):
60 return [
61 ([('Str255', '*', 'InMode')], [('Str255', '*', 'OutMode')]),
62 ([('FMetricRecPtr', 'theMetrics', 'InMode')], [('FMetricRecPtr', 'theMetrics', 'OutMode')]),
Just van Rossumca3b2ff2002-01-07 14:15:02 +000063 ([('short', 'byteCount', 'InMode'), ('void_ptr', 'textAddr', 'InMode'),],
64 [('TextBuffer', 'inText', 'InMode')]),
Jack Jansen6259af91996-01-09 17:15:16 +000065 ]
66
Jack Jansenb55e5f12001-01-03 16:44:27 +000067 def writeinitialdefs(self):
68 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
69 self.defsfile.write("kNilOptions = 0\n")
70
Jack Jansen6259af91996-01-09 17:15:16 +000071if __name__ == "__main__":
72 main()