annotate Mac/Modules/launch/launchscan.py @ 80661:94de77bd0b4b 2.7

Issue #16194: document imp.load_dynamic problems when read several extension modules from the same binary object file.
author Andrew Svetlov <andrew.svetlov@gmail.com>
date Thu, 29 Nov 2012 19:51:28 +0200
parents 1d84bf5f9478
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
31075
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
1 # Scan an Apple header file, generating a Python file of generator calls.
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
2
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
3 import sys
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
4 from bgenlocations import TOOLBOXDIR, BGENDIR
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
5 sys.path.append(BGENDIR)
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
6 from scantools import Scanner
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
7
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
8 LONG = "LaunchServices"
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
9 SHORT = "launch"
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
10 OBJECT = "NOTUSED"
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
11
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
12 def main():
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
13 input = LONG + ".h"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
14 output = SHORT + "gen.py"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
15 defsoutput = TOOLBOXDIR + LONG + ".py"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
16 scanner = MyScanner(input, output, defsoutput)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
17 scanner.scan()
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
18 scanner.close()
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
19 scanner.gentypetest(SHORT+"typetest.py")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
20 print "=== Testing definitions output code ==="
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
21 execfile(defsoutput, {}, {})
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
22 print "=== Done scanning and generating, now importing the generated code... ==="
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
23 exec "import " + SHORT + "support"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
24 print "=== Done. It's up to you to compile it now! ==="
31075
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
25
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
26 class MyScanner(Scanner):
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
27
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
28 def destination(self, type, name, arglist):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
29 classname = "Function"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
30 listname = "functions"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
31 if arglist:
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
32 t, n, m = arglist[0]
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
33 # This is non-functional today
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
34 if t == OBJECT and m == "InMode":
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
35 classname = "Method"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
36 listname = "methods"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
37 return classname, listname
31075
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
38
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
39 def writeinitialdefs(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
40 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
41 self.defsfile.write("from Carbon.Files import *\n")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
42 self.defsfile.write("kLSRequestAllInfo = -1\n")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
43 self.defsfile.write("kLSRolesAll = -1\n")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
44 self.defsfile.write("kLSUnknownType = FOUR_CHAR_CODE('\\0\\0\\0\\0')\n")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
45 self.defsfile.write("kLSUnknownCreator = FOUR_CHAR_CODE('\\0\\0\\0\\0')\n")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
46 self.defsfile.write("kLSInvalidExtensionIndex = -1\n")
31075
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
47
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
48 def makeblacklistnames(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
49 return [
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
50 "LSInit",
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
51 "LSTerm",
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
52 "kLSRequestAllInfo",
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
53 "kLSRolesAll",
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
54 "kLSInvalidExtensionIndex",
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
55 "kLSUnknownType",
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
56 "kLSUnknownCreator"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
57 ]
31075
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
58
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
59 def makeblacklisttypes(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
60 return [
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
61 "LSLaunchFSRefSpec_ptr",
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
62 "LSLaunchURLSpec_ptr",
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
63 ]
31075
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
64
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
65 def makerepairinstructions(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
66 return [
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
67 # LSGetApplicationForInfo
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
68 ([('CFStringRef', 'inExtension', 'InMode')],
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
69 [('OptCFStringRef', 'inExtension', 'InMode')]),
31091
3861eb467c29 Ported to Universal Headers 3.4.2. Qd and Qt remain to be done.
Jack Jansen <jack.jansen@cwi.nl>
parents: 31086
diff changeset
70
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
71 # LSFindApplicationForInfo
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
72 ([('CFStringRef', 'inBundleID', 'InMode')],
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
73 [('OptCFStringRef', 'inBundleID', 'InMode')]),
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
74 ([('CFStringRef', 'inName', 'InMode')],
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
75 [('OptCFStringRef', 'inName', 'InMode')]),
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
76
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
77 # Unicode filenames passed as length, buffer. LSGetExtensionInfo
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
78 ([('UniCharCount', '*', 'InMode'),
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
79 ('UniChar_ptr', '*', 'InMode')],
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
80 [('UnicodeReverseInBuffer', '*', 'InMode')]
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
81 ),
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
82 ]
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
83
31075
5b515cc90b5a An interface to the LaunchServices API.
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
84 if __name__ == "__main__":
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 31585
diff changeset
85 main()