blob: 746a333e0ff0e294a2db1e6b6a06a9384d7d654a [file] [log] [blame]
Jack Jansene2ba8732002-11-22 14:58:35 +00001# Scan an Apple header file, generating a Python file of generator calls.
2
3import sys
Jack Jansene2ba8732002-11-22 14:58:35 +00004from bgenlocations import TOOLBOXDIR, BGENDIR
5sys.path.append(BGENDIR)
6from scantools import Scanner_OSX
7
8LONG = "Folders"
9SHORT = "folder"
10OBJECT = "NOTUSED"
11
12def main():
Tim Peters182b5ac2004-07-18 06:16:08 +000013 input = LONG + ".h"
14 output = SHORT + "gen.py"
15 defsoutput = TOOLBOXDIR + LONG + ".py"
16 scanner = MyScanner(input, output, defsoutput)
17 scanner.scan()
18 scanner.close()
19 scanner.gentypetest(SHORT+"typetest.py")
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 Jansene2ba8732002-11-22 14:58:35 +000025
26class MyScanner(Scanner_OSX):
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 Jansene2ba8732002-11-22 14:58:35 +000038
Tim Peters182b5ac2004-07-18 06:16:08 +000039 def makeblacklistnames(self):
40 return [
41 "FindFolderExtended", # Has funny void* argument
42 "FSFindFolderExtended", # ditto
43 "FolderManagerRegisterCallNotificationProcs", # ditto
Jack Jansene2ba8732002-11-22 14:58:35 +000044
Tim Peters182b5ac2004-07-18 06:16:08 +000045 "FindFolderEx", # Non-MacOS routine
46 ]
Jack Jansene2ba8732002-11-22 14:58:35 +000047
Tim Peters182b5ac2004-07-18 06:16:08 +000048 def makeblacklisttypes(self):
49 return [
50 "FolderManagerNotificationProcPtr",
51 "FolderManagerNotificationUPP",
52 "FolderRouting", # To be done, not difficult
53 "FolderDesc", # To be done, not difficult
54
55 ]
56
57 def makerepairinstructions(self):
58 return [
59 ]
60
61 def writeinitialdefs(self):
62 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
63 self.defsfile.write("true = True\n")
64 self.defsfile.write("false = False\n")
65
Jack Jansene2ba8732002-11-22 14:58:35 +000066if __name__ == "__main__":
Tim Peters182b5ac2004-07-18 06:16:08 +000067 main()