blob: c6a39f36486addfc25326ac4e730e4b3d8ca1bbb [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()
Jack Jansen87eea882002-08-15 21:48:16 +000020 print "=== Testing definitions output code ==="
21 execfile(defsoutput, {}, {})
Jack Jansen31000dd1999-01-18 09:34:50 +000022 print "=== Done scanning and generating, now importing the generated code... ==="
23 exec "import " + SHORT + "support"
24 print "=== Done. It's up to you to compile it now! ==="
25
26class MyScanner(Scanner):
27
28 def destination(self, type, name, arglist):
29 classname = "Function"
30 listname = "functions"
31 if arglist:
32 t, n, m = arglist[0]
33 # This is non-functional today
34 if t == OBJECT and m == "InMode":
35 classname = "Method"
36 listname = "methods"
37 return classname, listname
38
39 def makeblacklistnames(self):
40 return [
41 "GetIconCacheData",
42 "SetIconCacheData",
Jack Jansenb1b78d81999-12-14 15:47:01 +000043 # Constants with funny definitions
44 "kSelectorAllHugeData",
45 "kSelectorAllAvailableData",
46 "svAllAvailableData",
Jack Jansenb55e5f12001-01-03 16:44:27 +000047 # Something in a comment accidentally seen as a const definition
48 "err",
Jack Jansen6c7e3262002-12-12 10:31:54 +000049 # OS8 only
50 'IconServicesTerminate',
Jack Jansenda6081f2003-12-03 23:20:13 +000051 # Lazy, right now.
52 "GetIconRefFromFileInfo"
Jack Jansen31000dd1999-01-18 09:34:50 +000053 ]
54
55 def makeblacklisttypes(self):
56 return [
57 "IconActionUPP",
58 "IconGetterUPP",
Jack Jansena05ac601999-12-12 21:41:51 +000059 "CFragInitBlockPtr",
Jack Jansenda6081f2003-12-03 23:20:13 +000060 "CGRect_ptr",
Jack Jansen31000dd1999-01-18 09:34:50 +000061 ]
62
63 def makerepairinstructions(self):
64 return [
65 ]
Jack Jansenb1b78d81999-12-14 15:47:01 +000066
67 def writeinitialdefs(self):
68 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
Jack Jansenda6081f2003-12-03 23:20:13 +000069 self.defsfile.write("from Carbon.Files import *\n")
Jack Jansen31000dd1999-01-18 09:34:50 +000070
71if __name__ == "__main__":
72 main()