blob: 8d0f3e913fd447ef2af5bd5c082ebd0015db07e0 [file] [log] [blame]
Jack Jansen7d0a6092003-12-02 23:01:43 +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
8
9LONG = "LaunchServices"
10SHORT = "launch"
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()
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! ==="
26
27class MyScanner(Scanner):
28
29 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
39
40 def writeinitialdefs(self):
41 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
42 self.defsfile.write("kLSRequestAllInfo = -1\n")
43 self.defsfile.write("kLSRolesAll = -1\n")
44
45 def makeblacklistnames(self):
46 return [
Jack Jansen07f1dfa2003-12-03 20:52:07 +000047 "LSInit",
48 "LSTerm",
Jack Jansen7d0a6092003-12-02 23:01:43 +000049 "kLSRequestAllInfo",
50 "kLSRolesAll",
51 ]
52
53 def makeblacklisttypes(self):
54 return [
55 "LSLaunchFSRefSpec_ptr",
56 "LSLaunchURLSpec_ptr",
57 ]
58
59 def makerepairinstructions(self):
60 return [
61 # LSGetApplicationForInfo
62 ([('CFStringRef', 'inExtension', 'InMode')],
63 [('OptCFStringRef', 'inExtension', 'InMode')]),
64
65 # LSFindApplicationForInfo
66 ([('CFStringRef', 'inBundleID', 'InMode')],
67 [('OptCFStringRef', 'inBundleID', 'InMode')]),
68 ([('CFStringRef', 'inName', 'InMode')],
69 [('OptCFStringRef', 'inName', 'InMode')]),
70 ]
71
72if __name__ == "__main__":
73 main()