blob: 32a759ab56f5cc7b021a92704cc919c62d178fa2 [file] [log] [blame]
Jack Jansenbf2f6021997-09-09 13:52:47 +00001# Scan an Apple header file, generating a Python file of generator calls.
2
Jack Jansen0c4d9471998-04-17 14:07:56 +00003import sys
4import os
Jack Jansenaaebdd62002-08-05 15:39:30 +00005from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansen0c4d9471998-04-17 14:07:56 +00006sys.path.append(BGENDIR)
Jack Jansenbf2f6021997-09-09 13:52:47 +00007from scantools import Scanner
Jack Jansenbf2f6021997-09-09 13:52:47 +00008
Jack Jansen983258e2002-08-29 21:09:00 +00009LONG = "MacHelp"
Jack Jansenbf2f6021997-09-09 13:52:47 +000010SHORT = "help"
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 Jansenbf2f6021997-09-09 13:52:47 +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
Jack Jansen21f96871998-02-20 16:02:09 +000039 def writeinitialdefs(self):
40 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
41
Jack Jansenbf2f6021997-09-09 13:52:47 +000042 def makeblacklistnames(self):
43 return [
44 ]
45
46 def makeblacklisttypes(self):
47 return [
Jack Jansen983258e2002-08-29 21:09:00 +000048## "TipFunctionUPP",
49## "HMMessageRecord",
50## "HMMessageRecord_ptr",
51 "HMWindowContentUPP",
52 "HMMenuTitleContentUPP",
53 "HMControlContentUPP",
54 "HMMenuItemContentUPP",
55 # For the moment
56 "HMHelpContentRec",
57 "HMHelpContentRec_ptr",
Jack Jansenbf2f6021997-09-09 13:52:47 +000058 ]
59
60 def makerepairinstructions(self):
61 return [
Jack Jansen983258e2002-08-29 21:09:00 +000062## ([("WindowPtr", "*", "OutMode")],
63## [("ExistingWindowPtr", "*", "*")]),
Jack Jansenbf2f6021997-09-09 13:52:47 +000064 ]
65
66if __name__ == "__main__":
67 main()