blob: 0d4661f9c713a1f811c97e6be7120a281de3bdbe [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
8BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
9sys.path.append(BGENDIR)
Jack Jansenda6a9711996-04-12 16:25:30 +000010from scantools import Scanner
11from bgenlocations import TOOLBOXDIR
12
13LONG = "Scrap"
Jack Jansena05ac601999-12-12 21:41:51 +000014SHORT = "scrap"
Jack Jansenda6a9711996-04-12 16:25:30 +000015
16def main():
17 input = "Scrap.h"
18 output = SHORT + "gen.py"
19 defsoutput = "@Scrap.py"
20 scanner = MyScanner(input, output, defsoutput)
21 scanner.scan()
22 scanner.close()
23 print "=== Done scanning and generating, now importing the generated code... ==="
24 exec "import " + SHORT + "support"
25 print "=== Done. It's up to you to compile it now! ==="
26
27class MyScanner(Scanner):
28
29 def destination(self, type, name, arglist):
30 classname = "Function"
31 listname = "functions"
32 return classname, listname
33
34 def makeblacklistnames(self):
35 return [
36 ]
37
Jack Jansen7b3cc1f2001-01-24 16:04:01 +000038 def makegreylist(self):
39 return [
40 ('#if !TARGET_API_MAC_CARBON', [
41 'InfoScrap',
42 'GetScrap',
43 'ZeroScrap',
44 'PutScrap',
45 ]),
46 ('#if TARGET_API_MAC_CARBON', [
47 'CallInScrapPromises',
48 'ClearCurrentScrap',
49 ])]
50
Jack Jansenda6a9711996-04-12 16:25:30 +000051 def makeblacklisttypes(self):
52 return [
Jack Jansen7b3cc1f2001-01-24 16:04:01 +000053 "ScrapRef", # For now -- This is the Carbon scrap main object
Jack Jansenda6a9711996-04-12 16:25:30 +000054 ]
55
56 def makerepairinstructions(self):
57 return [
58 ([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]),
Jack Jansen7b3cc1f2001-01-24 16:04:01 +000059 ([('void_ptr', '*', 'InMode')], [('putscrapbuffer', '*', 'InMode')]),
Jack Jansenda6a9711996-04-12 16:25:30 +000060 ]
61
62if __name__ == "__main__":
63 main()