annotate Mac/Modules/folder/folderscan.py @ 79675:c0a2294de787 2.7

Issue #16199: Backport 2to3 typo fix from 3.2.
author Chris Jerdonek <chris.jerdonek@gmail.com>
date Thu, 11 Oct 2012 16:15:46 -0700
parents 1d84bf5f9478
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26350
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
1 # Scan an Apple header file, generating a Python file of generator calls.
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
2
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
3 import sys
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
4 from bgenlocations import TOOLBOXDIR, BGENDIR
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
5 sys.path.append(BGENDIR)
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
6 from scantools import Scanner_OSX
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
7
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
8 LONG = "Folders"
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
9 SHORT = "folder"
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
10 OBJECT = "NOTUSED"
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
11
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
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: 26350
diff changeset
13 input = LONG + ".h"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
14 output = SHORT + "gen.py"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
15 defsoutput = TOOLBOXDIR + LONG + ".py"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
16 scanner = MyScanner(input, output, defsoutput)
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
17 scanner.scan()
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
18 scanner.close()
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
19 scanner.gentypetest(SHORT+"typetest.py")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
20 print "=== Testing definitions output code ==="
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
21 execfile(defsoutput, {}, {})
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
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: 26350
diff changeset
23 exec "import " + SHORT + "support"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
24 print "=== Done. It's up to you to compile it now! ==="
26350
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
25
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
26 class MyScanner(Scanner_OSX):
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
27
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
28 def destination(self, type, name, arglist):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
29 classname = "Function"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
30 listname = "functions"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
31 if arglist:
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
32 t, n, m = arglist[0]
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
33 # This is non-functional today
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
34 if t == OBJECT and m == "InMode":
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
35 classname = "Method"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
36 listname = "methods"
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
37 return classname, listname
26350
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
38
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
39 def makeblacklistnames(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
40 return [
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
41 "FindFolderExtended", # Has funny void* argument
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
42 "FSFindFolderExtended", # ditto
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
43 "FolderManagerRegisterCallNotificationProcs", # ditto
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
44
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
45 "FindFolderEx", # Non-MacOS routine
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
46 ]
26350
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
47
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
48 def makeblacklisttypes(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
49 return [
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
50 "FolderManagerNotificationProcPtr",
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
51 "FolderManagerNotificationUPP",
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
52 "FolderRouting", # To be done, not difficult
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
53 "FolderDesc", # To be done, not difficult
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
54
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
55 ]
26350
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
56
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
57 def makerepairinstructions(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
58 return [
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
59 ]
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
60
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
61 def writeinitialdefs(self):
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
62 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
63 self.defsfile.write("true = True\n")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
64 self.defsfile.write("false = False\n")
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
65
26350
abf565cf5b54 Got angry and added support for pretty much the whole file and folder
Jack Jansen <jack.jansen@cwi.nl>
parents:
diff changeset
66 if __name__ == "__main__":
32736
c3a096bfbd6b Whitespace normalization, via reindent.py.
Tim Peters <tim.peters@gmail.com>
parents: 26350
diff changeset
67 main()