blob: bdc3b84413e7c7fa8709d34878ff63ce25bb946d [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():
Tim Peters182b5ac2004-07-18 06:16:08 +000014 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 "=== Testing definitions output code ==="
21 execfile(defsoutput, {}, {})
22 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! ==="
Jack Jansen31000dd1999-01-18 09:34:50 +000025
26class MyScanner(Scanner):
27
Tim Peters182b5ac2004-07-18 06:16:08 +000028 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
Jack Jansen31000dd1999-01-18 09:34:50 +000038
Tim Peters182b5ac2004-07-18 06:16:08 +000039 def makeblacklistnames(self):
40 return [
41 "GetIconCacheData",
42 "SetIconCacheData",
43 # Constants with funny definitions
44 "kSelectorAllHugeData",
45 "kSelectorAllAvailableData",
46 "svAllAvailableData",
47 # Something in a comment accidentally seen as a const definition
48 "err",
49 # OS8 only
50 'IconServicesTerminate',
51 # Lazy, right now.
52 "GetIconRefFromFileInfo"
53 ]
Jack Jansen31000dd1999-01-18 09:34:50 +000054
Tim Peters182b5ac2004-07-18 06:16:08 +000055 def makeblacklisttypes(self):
56 return [
57 "IconActionUPP",
58 "IconGetterUPP",
59 "CFragInitBlockPtr",
60 "CGRect_ptr",
61 ]
Jack Jansen31000dd1999-01-18 09:34:50 +000062
Tim Peters182b5ac2004-07-18 06:16:08 +000063 def makerepairinstructions(self):
64 return [
65 ]
Jack Jansenb1b78d81999-12-14 15:47:01 +000066
Tim Peters182b5ac2004-07-18 06:16:08 +000067 def writeinitialdefs(self):
68 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
69 self.defsfile.write("from Carbon.Files import *\n")
70
Jack Jansen31000dd1999-01-18 09:34:50 +000071if __name__ == "__main__":
Tim Peters182b5ac2004-07-18 06:16:08 +000072 main()