blob: 02f8ec226a31bef4db246529e84896469cc58d1b [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
5BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
6sys.path.append(BGENDIR)
Jack Jansen6259af91996-01-09 17:15:16 +00007from scantools import Scanner
Jack Jansen46d9e791996-04-12 16:29:23 +00008from bgenlocations import TOOLBOXDIR
Jack Jansen6259af91996-01-09 17:15:16 +00009
10LONG = "Fonts"
Jack Jansen21f96871998-02-20 16:02:09 +000011SHORT = "fm"
Jack Jansen6259af91996-01-09 17:15:16 +000012
13def main():
14 input = "Fonts.h"
15 output = SHORT + "gen.py"
Jack Jansen46d9e791996-04-12 16:29:23 +000016 defsoutput = TOOLBOXDIR + LONG + ".py"
Jack Jansen6259af91996-01-09 17:15:16 +000017 scanner = MyScanner(input, output, defsoutput)
18 scanner.scan()
19 scanner.close()
20 print "=== Done scanning and generating, now importing the generated code... ==="
21 exec "import " + SHORT + "support"
22 print "=== Done. It's up to you to compile it now! ==="
23
24class MyScanner(Scanner):
25
26 def destination(self, type, name, arglist):
27 classname = "Function"
28 listname = "functions"
29 return classname, listname
30
31 def makeblacklistnames(self):
32 return [
33 "OutlineMetrics", # Too complicated
Jack Jansen21f96871998-02-20 16:02:09 +000034 "AntiTextIsAntiAliased", # XXXX Missing from library...
35 "AntiTextGetEnabled",
36 "AntiTextSetEnabled",
37 "AntiTextGetApplicationAware",
38 "AntiTextSetApplicationAware",
Jack Jansen6259af91996-01-09 17:15:16 +000039 ]
40
Jack Jansen8d929ae2000-06-21 22:07:06 +000041 def makegreylist(self):
42 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000043 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansen8d929ae2000-06-21 22:07:06 +000044 'InitFonts',
45 'SetFontLock',
46 'FlushFonts',
47 ])]
Jack Jansen6259af91996-01-09 17:15:16 +000048 def makeblacklisttypes(self):
49 return [
50 "FMInput_ptr", # Not needed for now
51 "FMOutPtr", # Ditto
Jack Jansena05ac601999-12-12 21:41:51 +000052 "void_ptr", # Don't know how to do this right now
53 "FontInfo", # Ditto
Jack Jansen6259af91996-01-09 17:15:16 +000054 ]
55
56 def makerepairinstructions(self):
57 return [
58 ([('Str255', '*', 'InMode')], [('Str255', '*', 'OutMode')]),
59 ([('FMetricRecPtr', 'theMetrics', 'InMode')], [('FMetricRecPtr', 'theMetrics', 'OutMode')]),
60 ]
61
Jack Jansenb55e5f12001-01-03 16:44:27 +000062 def writeinitialdefs(self):
63 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
64 self.defsfile.write("kNilOptions = 0\n")
65
Jack Jansen6259af91996-01-09 17:15:16 +000066if __name__ == "__main__":
67 main()