blob: 138cc628990920ca2a65bdd6e8b1aa8a29dc6d1c [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 Jansen31000dd1999-01-18 09:34:50 +000051 ]
52
53 def makeblacklisttypes(self):
54 return [
55 "IconActionUPP",
56 "IconGetterUPP",
Jack Jansena05ac601999-12-12 21:41:51 +000057 "CFragInitBlockPtr",
Jack Jansen31000dd1999-01-18 09:34:50 +000058 ]
59
60 def makerepairinstructions(self):
61 return [
62 ]
Jack Jansenb1b78d81999-12-14 15:47:01 +000063
64 def writeinitialdefs(self):
65 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
Jack Jansen31000dd1999-01-18 09:34:50 +000066
67if __name__ == "__main__":
68 main()