blob: dbb083b3643d72d1d27d12a40d9b1eaa0b846cff [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 Jansenaaebdd62002-08-05 15:39:30 +00008from bgenlocations import TOOLBOXDIR, BGENDIR
Jack Jansen0c4d9471998-04-17 14:07:56 +00009sys.path.append(BGENDIR)
Jack Jansenda6a9711996-04-12 16:25:30 +000010from scantools import Scanner
Jack Jansenda6a9711996-04-12 16:25:30 +000011
12LONG = "Scrap"
Jack Jansena05ac601999-12-12 21:41:51 +000013SHORT = "scrap"
Jack Jansenda6a9711996-04-12 16:25:30 +000014
15def main():
16 input = "Scrap.h"
17 output = SHORT + "gen.py"
18 defsoutput = "@Scrap.py"
19 scanner = MyScanner(input, output, defsoutput)
20 scanner.scan()
21 scanner.close()
22 print "=== Done scanning and generating, now importing the generated code... ==="
23 exec "import " + SHORT + "support"
24 print "=== Done. It's up to you to compile it now! ==="
25
26class MyScanner(Scanner):
27
28 def destination(self, type, name, arglist):
29 classname = "Function"
30 listname = "functions"
Jack Jansen420ed402001-12-31 14:52:03 +000031 if arglist:
32 t, n, m = arglist[0]
33 if t == 'ScrapRef' and m == "InMode":
34 classname = "Method"
35 listname = "methods"
Jack Jansenda6a9711996-04-12 16:25:30 +000036 return classname, listname
37
38 def makeblacklistnames(self):
39 return [
Jack Jansen420ed402001-12-31 14:52:03 +000040 "GetScrapFlavorInfoList",
Jack Jansenda6a9711996-04-12 16:25:30 +000041 ]
42
Jack Jansen7b3cc1f2001-01-24 16:04:01 +000043 def makegreylist(self):
44 return [
45 ('#if !TARGET_API_MAC_CARBON', [
46 'InfoScrap',
47 'GetScrap',
48 'ZeroScrap',
49 'PutScrap',
50 ]),
51 ('#if TARGET_API_MAC_CARBON', [
52 'CallInScrapPromises',
53 'ClearCurrentScrap',
54 ])]
55
Jack Jansenda6a9711996-04-12 16:25:30 +000056 def makeblacklisttypes(self):
57 return [
Jack Jansen420ed402001-12-31 14:52:03 +000058 'ScrapPromiseKeeperUPP',
Jack Jansenda6a9711996-04-12 16:25:30 +000059 ]
60
61 def makerepairinstructions(self):
62 return [
63 ([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]),
Jack Jansen7b3cc1f2001-01-24 16:04:01 +000064 ([('void_ptr', '*', 'InMode')], [('putscrapbuffer', '*', 'InMode')]),
Jack Jansenda6a9711996-04-12 16:25:30 +000065 ]
66
67if __name__ == "__main__":
68 main()