blob: 6227446c80daea8e18e8f657d4b114c117fa8131 [file] [log] [blame]
Jack Jansenda6a9711996-04-12 16:25:30 +00001# Scan an Apple header file, generating a Python file of generator calls.
2#
3# Note that the scrap-manager include file is so weird that this
4# generates a boilerplate to be edited by hand.
5
Jack Jansen0c4d9471998-04-17 14:07:56 +00006import sys
7import os
Jack Jansen420ed402001-12-31 14:52:03 +00008if os.sep == ':':
9 BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
10else:
11 BGENDIR="../../../Tools/bgen/bgen"
Jack Jansen0c4d9471998-04-17 14:07:56 +000012sys.path.append(BGENDIR)
Jack Jansenda6a9711996-04-12 16:25:30 +000013from scantools import Scanner
14from bgenlocations import TOOLBOXDIR
15
16LONG = "Scrap"
Jack Jansena05ac601999-12-12 21:41:51 +000017SHORT = "scrap"
Jack Jansenda6a9711996-04-12 16:25:30 +000018
19def 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! ==="
29
30class MyScanner(Scanner):
31
32 def destination(self, type, name, arglist):
33 classname = "Function"
34 listname = "functions"
Jack Jansen420ed402001-12-31 14:52:03 +000035 if arglist:
36 t, n, m = arglist[0]
37 if t == 'ScrapRef' and m == "InMode":
38 classname = "Method"
39 listname = "methods"
Jack Jansenda6a9711996-04-12 16:25:30 +000040 return classname, listname
41
42 def makeblacklistnames(self):
43 return [
Jack Jansen420ed402001-12-31 14:52:03 +000044 "GetScrapFlavorInfoList",
Jack Jansenda6a9711996-04-12 16:25:30 +000045 ]
46
Jack Jansen7b3cc1f2001-01-24 16:04:01 +000047 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 ])]
59
Jack Jansenda6a9711996-04-12 16:25:30 +000060 def makeblacklisttypes(self):
61 return [
Jack Jansen420ed402001-12-31 14:52:03 +000062 'ScrapPromiseKeeperUPP',
Jack Jansenda6a9711996-04-12 16:25:30 +000063 ]
64
65 def makerepairinstructions(self):
66 return [
67 ([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]),
Jack Jansen7b3cc1f2001-01-24 16:04:01 +000068 ([('void_ptr', '*', 'InMode')], [('putscrapbuffer', '*', 'InMode')]),
Jack Jansenda6a9711996-04-12 16:25:30 +000069 ]
70
71if __name__ == "__main__":
72 main()