blob: 8dd6dfd45f9780f9db775f591a82978e15a372cd [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 [
47 "kLSRequestAllInfo",
48 "kLSRolesAll",
49 ]
50
51 def makeblacklisttypes(self):
52 return [
53 "LSLaunchFSRefSpec_ptr",
54 "LSLaunchURLSpec_ptr",
55 ]
56
57 def makerepairinstructions(self):
58 return [
59 # LSGetApplicationForInfo
60 ([('CFStringRef', 'inExtension', 'InMode')],
61 [('OptCFStringRef', 'inExtension', 'InMode')]),
62
63 # LSFindApplicationForInfo
64 ([('CFStringRef', 'inBundleID', 'InMode')],
65 [('OptCFStringRef', 'inBundleID', 'InMode')]),
66 ([('CFStringRef', 'inName', 'InMode')],
67 [('OptCFStringRef', 'inName', 'InMode')]),
68 ]
69
70if __name__ == "__main__":
71 main()