Issue #7117 (backport py3k float repr) continued:
[python.git] / Mac / Modules / icn / icnscan.py
blob6af3a4ea0fd2f67c6066dd9850a1b9f0aa86956e
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 = "Icons"
9 SHORT = "icn"
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 print "=== Testing definitions output code ==="
20 execfile(defsoutput, {}, {})
21 print "=== Done scanning and generating, now importing the generated code... ==="
22 exec "import " + SHORT + "support"
23 print "=== Done. It's up to you to compile it now! ==="
25 class MyScanner(Scanner):
27 def destination(self, type, name, arglist):
28 classname = "Function"
29 listname = "functions"
30 if arglist:
31 t, n, m = arglist[0]
32 # This is non-functional today
33 if t == OBJECT and m == "InMode":
34 classname = "Method"
35 listname = "methods"
36 return classname, listname
38 def makeblacklistnames(self):
39 return [
40 "GetIconCacheData",
41 "SetIconCacheData",
42 # Constants with funny definitions
43 "kSelectorAllHugeData",
44 "kSelectorAllAvailableData",
45 "svAllAvailableData",
46 # Something in a comment accidentally seen as a const definition
47 "err",
48 # OS8 only
49 'IconServicesTerminate',
50 # Lazy, right now.
51 "GetIconRefFromFileInfo"
54 def makeblacklisttypes(self):
55 return [
56 "IconActionUPP",
57 "IconGetterUPP",
58 "CFragInitBlockPtr",
59 "CGRect_ptr",
62 def makerepairinstructions(self):
63 return [
66 def writeinitialdefs(self):
67 self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
68 self.defsfile.write("from Carbon.Files import *\n")
70 if __name__ == "__main__":
71 main()