blob: 8deee504dd6cb0c419c0cecde8bd3880a3f9fb90 [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()
19 print "=== Done scanning and generating, now importing the generated code... ==="
20 exec "import " + SHORT + "support"
21 print "=== Done. It's up to you to compile it now! ==="
22
23class MyScanner(Scanner):
24
25 def destination(self, type, name, arglist):
26 classname = "Function"
27 listname = "functions"
28 return classname, listname
29
30 def makeblacklistnames(self):
31 return [
32 "OutlineMetrics", # Too complicated
Jack Jansen21f96871998-02-20 16:02:09 +000033 "AntiTextIsAntiAliased", # XXXX Missing from library...
34 "AntiTextGetEnabled",
35 "AntiTextSetEnabled",
36 "AntiTextGetApplicationAware",
37 "AntiTextSetApplicationAware",
Jack Jansen82bcbd02001-06-20 21:29:19 +000038 # These are tricky: they're not Carbon dependent or anything, but they
39 # exist only on 8.6 or later (both in Carbon and Classic).
40 # Disabling them is the easiest path.
41 'SetAntiAliasedTextEnabled',
42 'IsAntiAliasedTextEnabled',
Jack Jansen6259af91996-01-09 17:15:16 +000043 ]
44
Jack Jansen8d929ae2000-06-21 22:07:06 +000045 def makegreylist(self):
46 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000047 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansen8d929ae2000-06-21 22:07:06 +000048 'InitFonts',
49 'SetFontLock',
50 'FlushFonts',
51 ])]
Jack Jansen6259af91996-01-09 17:15:16 +000052 def makeblacklisttypes(self):
53 return [
54 "FMInput_ptr", # Not needed for now
55 "FMOutPtr", # Ditto
Just van Rossumca3b2ff2002-01-07 14:15:02 +000056## "void_ptr", # Don't know how to do this right now
Jack Jansena05ac601999-12-12 21:41:51 +000057 "FontInfo", # Ditto
Jack Jansen6259af91996-01-09 17:15:16 +000058 ]
59
60 def makerepairinstructions(self):
61 return [
62 ([('Str255', '*', 'InMode')], [('Str255', '*', 'OutMode')]),
63 ([('FMetricRecPtr', 'theMetrics', 'InMode')], [('FMetricRecPtr', 'theMetrics', 'OutMode')]),
Just van Rossumca3b2ff2002-01-07 14:15:02 +000064 ([('short', 'byteCount', 'InMode'), ('void_ptr', 'textAddr', 'InMode'),],
65 [('TextBuffer', 'inText', 'InMode')]),
Jack Jansen6259af91996-01-09 17:15:16 +000066 ]
67
Jack Jansenb55e5f12001-01-03 16:44:27 +000068 def writeinitialdefs(self):
69 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
70 self.defsfile.write("kNilOptions = 0\n")
71
Jack Jansen6259af91996-01-09 17:15:16 +000072if __name__ == "__main__":
73 main()