typo: use one instead instead of two
[python.git] / Mac / Modules / launch / launchscan.py
blob3e07238431d968a0057a4eb2eabd77d0585e251d
1 # Scan an Apple header file, generating a Python file of generator calls.
3 import sys
4 from bgenlocations import TOOLBOXDIR, BGENDIR
5 sys.path.append(BGENDIR)
6 from scantools import Scanner
8 LONG = "LaunchServices"
9 SHORT = "launch"
10 OBJECT = "NOTUSED"
12 def main():
13 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! ==="
26 class MyScanner(Scanner):
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
39 def writeinitialdefs(self):
40 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
41 self.defsfile.write("from Carbon.Files import *\n")
42 self.defsfile.write("kLSRequestAllInfo = -1\n")
43 self.defsfile.write("kLSRolesAll = -1\n")
44 self.defsfile.write("kLSUnknownType = FOUR_CHAR_CODE('\\0\\0\\0\\0')\n")
45 self.defsfile.write("kLSUnknownCreator = FOUR_CHAR_CODE('\\0\\0\\0\\0')\n")
46 self.defsfile.write("kLSInvalidExtensionIndex = -1\n")
48 def makeblacklistnames(self):
49 return [
50 "LSInit",
51 "LSTerm",
52 "kLSRequestAllInfo",
53 "kLSRolesAll",
54 "kLSInvalidExtensionIndex",
55 "kLSUnknownType",
56 "kLSUnknownCreator"
59 def makeblacklisttypes(self):
60 return [
61 "LSLaunchFSRefSpec_ptr",
62 "LSLaunchURLSpec_ptr",
65 def makerepairinstructions(self):
66 return [
67 # LSGetApplicationForInfo
68 ([('CFStringRef', 'inExtension', 'InMode')],
69 [('OptCFStringRef', 'inExtension', 'InMode')]),
71 # LSFindApplicationForInfo
72 ([('CFStringRef', 'inBundleID', 'InMode')],
73 [('OptCFStringRef', 'inBundleID', 'InMode')]),
74 ([('CFStringRef', 'inName', 'InMode')],
75 [('OptCFStringRef', 'inName', 'InMode')]),
77 # Unicode filenames passed as length, buffer. LSGetExtensionInfo
78 ([('UniCharCount', '*', 'InMode'),
79 ('UniChar_ptr', '*', 'InMode')],
80 [('UnicodeReverseInBuffer', '*', 'InMode')]
84 if __name__ == "__main__":
85 main()