blob: 0b173a4c88e0f63977c6299cbb1770f82843fc26 [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()
Jack Jansen7ca993e2002-08-15 22:05:58 +000022## print "=== Testing definitions output code ==="
23## execfile(defsoutput, {}, {})
Jack Jansenda6a9711996-04-12 16:25:30 +000024 print "=== Done scanning and generating, now importing the generated code... ==="
25 exec "import " + SHORT + "support"
26 print "=== Done. It's up to you to compile it now! ==="
27
28class MyScanner(Scanner):
29
30 def destination(self, type, name, arglist):
31 classname = "Function"
32 listname = "functions"
Jack Jansen420ed402001-12-31 14:52:03 +000033 if arglist:
34 t, n, m = arglist[0]
35 if t == 'ScrapRef' and m == "InMode":
36 classname = "Method"
37 listname = "methods"
Jack Jansenda6a9711996-04-12 16:25:30 +000038 return classname, listname
39
40 def makeblacklistnames(self):
41 return [
Jack Jansen420ed402001-12-31 14:52:03 +000042 "GetScrapFlavorInfoList",
Jack Jansen6c7e3262002-12-12 10:31:54 +000043 'InfoScrap',
44 'GetScrap',
45 'ZeroScrap',
46 'PutScrap',
Jack Jansenda6a9711996-04-12 16:25:30 +000047 ]
48
49 def makeblacklisttypes(self):
50 return [
Jack Jansen420ed402001-12-31 14:52:03 +000051 'ScrapPromiseKeeperUPP',
Jack Jansenda6a9711996-04-12 16:25:30 +000052 ]
53
54 def makerepairinstructions(self):
55 return [
56 ([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]),
Jack Jansen7b3cc1f2001-01-24 16:04:01 +000057 ([('void_ptr', '*', 'InMode')], [('putscrapbuffer', '*', 'InMode')]),
Jack Jansenda6a9711996-04-12 16:25:30 +000058 ]
59
60if __name__ == "__main__":
61 main()