This commit was manufactured by cvs2svn to create tag 'r222'.
[python/dscho.git] / Mac / Modules / scrap / scrapscan.py
blob6227446c80daea8e18e8f657d4b114c117fa8131
1 # Scan an Apple header file, generating a Python file of generator calls.
3 # Note that the scrap-manager include file is so weird that this
4 # generates a boilerplate to be edited by hand.
6 import sys
7 import os
8 if os.sep == ':':
9 BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
10 else:
11 BGENDIR="../../../Tools/bgen/bgen"
12 sys.path.append(BGENDIR)
13 from scantools import Scanner
14 from bgenlocations import TOOLBOXDIR
16 LONG = "Scrap"
17 SHORT = "scrap"
19 def main():
20 input = "Scrap.h"
21 output = SHORT + "gen.py"
22 defsoutput = "@Scrap.py"
23 scanner = MyScanner(input, output, defsoutput)
24 scanner.scan()
25 scanner.close()
26 print "=== Done scanning and generating, now importing the generated code... ==="
27 exec "import " + SHORT + "support"
28 print "=== Done. It's up to you to compile it now! ==="
30 class MyScanner(Scanner):
32 def destination(self, type, name, arglist):
33 classname = "Function"
34 listname = "functions"
35 if arglist:
36 t, n, m = arglist[0]
37 if t == 'ScrapRef' and m == "InMode":
38 classname = "Method"
39 listname = "methods"
40 return classname, listname
42 def makeblacklistnames(self):
43 return [
44 "GetScrapFlavorInfoList",
47 def makegreylist(self):
48 return [
49 ('#if !TARGET_API_MAC_CARBON', [
50 'InfoScrap',
51 'GetScrap',
52 'ZeroScrap',
53 'PutScrap',
54 ]),
55 ('#if TARGET_API_MAC_CARBON', [
56 'CallInScrapPromises',
57 'ClearCurrentScrap',
58 ])]
60 def makeblacklisttypes(self):
61 return [
62 'ScrapPromiseKeeperUPP',
65 def makerepairinstructions(self):
66 return [
67 ([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]),
68 ([('void_ptr', '*', 'InMode')], [('putscrapbuffer', '*', 'InMode')]),
71 if __name__ == "__main__":
72 main()