blob: 8c94893011ff07fe2131e8c3a58ca2e09aaefdc2 [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
4import os
5from bgenlocations import TOOLBOXDIR, BGENDIR
6sys.path.append(BGENDIR)
7from scantools import Scanner_OSX
8
9LONG = "Folders"
10SHORT = "folder"
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 scanner.gentypetest(SHORT+"typetest.py")
21 print "=== Testing definitions output code ==="
22 execfile(defsoutput, {}, {})
23 print "=== Done scanning and generating, now importing the generated code... ==="
24 exec "import " + SHORT + "support"
25 print "=== Done. It's up to you to compile it now! ==="
Jack Jansene2ba8732002-11-22 14:58:35 +000026
27class MyScanner(Scanner_OSX):
28
Tim Peters182b5ac2004-07-18 06:16:08 +000029 def destination(self, type, name, arglist):
30 classname = "Function"
31 listname = "functions"
32 if arglist:
33 t, n, m = arglist[0]
34 # This is non-functional today
35 if t == OBJECT and m == "InMode":
36 classname = "Method"
37 listname = "methods"
38 return classname, listname
Jack Jansene2ba8732002-11-22 14:58:35 +000039
Tim Peters182b5ac2004-07-18 06:16:08 +000040 def makeblacklistnames(self):
41 return [
42 "FindFolderExtended", # Has funny void* argument
43 "FSFindFolderExtended", # ditto
44 "FolderManagerRegisterCallNotificationProcs", # ditto
Jack Jansene2ba8732002-11-22 14:58:35 +000045
Tim Peters182b5ac2004-07-18 06:16:08 +000046 "FindFolderEx", # Non-MacOS routine
47 ]
Jack Jansene2ba8732002-11-22 14:58:35 +000048
Tim Peters182b5ac2004-07-18 06:16:08 +000049 def makeblacklisttypes(self):
50 return [
51 "FolderManagerNotificationProcPtr",
52 "FolderManagerNotificationUPP",
53 "FolderRouting", # To be done, not difficult
54 "FolderDesc", # To be done, not difficult
55
56 ]
57
58 def makerepairinstructions(self):
59 return [
60 ]
61
62 def writeinitialdefs(self):
63 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
64 self.defsfile.write("true = True\n")
65 self.defsfile.write("false = False\n")
66
Jack Jansene2ba8732002-11-22 14:58:35 +000067if __name__ == "__main__":
Tim Peters182b5ac2004-07-18 06:16:08 +000068 main()