blob: 519d9e52e6226c1b7ec6dc09905df54d3fdc6d4e [file] [log] [blame]
Jack Jansen31000dd1999-01-18 09:34:50 +00001# Scan an Apple header file, generating a Python file of generator calls.
2
3import sys
4import os
Jack Jansenaaebdd62002-08-05 15:39:30 +00005from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansen31000dd1999-01-18 09:34:50 +00006sys.path.append(BGENDIR)
7from scantools import Scanner
Jack Jansen31000dd1999-01-18 09:34:50 +00008
9LONG = "Icons"
10SHORT = "icn"
11OBJECT = "NOTUSED"
12
13def main():
14 input = LONG + ".h"
15 output = SHORT + "gen.py"
16 defsoutput = TOOLBOXDIR + LONG + ".py"
17 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 if arglist:
30 t, n, m = arglist[0]
31 # This is non-functional today
32 if t == OBJECT and m == "InMode":
33 classname = "Method"
34 listname = "methods"
35 return classname, listname
36
37 def makeblacklistnames(self):
38 return [
39 "GetIconCacheData",
40 "SetIconCacheData",
Jack Jansenb1b78d81999-12-14 15:47:01 +000041 # Constants with funny definitions
42 "kSelectorAllHugeData",
43 "kSelectorAllAvailableData",
44 "svAllAvailableData",
Jack Jansenb55e5f12001-01-03 16:44:27 +000045 # Something in a comment accidentally seen as a const definition
46 "err",
Jack Jansen31000dd1999-01-18 09:34:50 +000047 ]
48
Jack Jansen8d929ae2000-06-21 22:07:06 +000049 def makegreylist(self):
50 return [
Jack Jansen74a1e632000-07-14 22:37:27 +000051 ('#if !TARGET_API_MAC_CARBON', [
Jack Jansen8d929ae2000-06-21 22:07:06 +000052 'IconServicesTerminate',
Jack Jansenf7d5aa62000-12-10 23:43:49 +000053 ]),
54 ('#if TARGET_API_MAC_CARBON', [
55 'WriteIconFile',
56 'ReadIconFile',
57 'RegisterIconRefFromIconFile',
58 'GetIconRefVariant',
Jack Jansen8d929ae2000-06-21 22:07:06 +000059 ])]
60
Jack Jansen31000dd1999-01-18 09:34:50 +000061 def makeblacklisttypes(self):
62 return [
63 "IconActionUPP",
64 "IconGetterUPP",
Jack Jansena05ac601999-12-12 21:41:51 +000065 "CFragInitBlockPtr",
Jack Jansen31000dd1999-01-18 09:34:50 +000066 ]
67
68 def makerepairinstructions(self):
69 return [
70 ]
Jack Jansenb1b78d81999-12-14 15:47:01 +000071
72 def writeinitialdefs(self):
73 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
Jack Jansen31000dd1999-01-18 09:34:50 +000074
75if __name__ == "__main__":
76 main()