• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 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
6import sys
7from bgenlocations import TOOLBOXDIR, BGENDIR
8sys.path.append(BGENDIR)
9from scantools import Scanner
10
11LONG = "Scrap"
12SHORT = "scrap"
13
14def main():
15    input = "Scrap.h"
16    output = SHORT + "gen.py"
17    defsoutput = "@Scrap.py"
18    scanner = MyScanner(input, output, defsoutput)
19    scanner.scan()
20    scanner.close()
21##      print "=== Testing definitions output code ==="
22##      execfile(defsoutput, {}, {})
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        if arglist:
33            t, n, m = arglist[0]
34            if t == 'ScrapRef' and m == "InMode":
35                classname = "Method"
36                listname = "methods"
37        return classname, listname
38
39    def makeblacklistnames(self):
40        return [
41                "GetScrapFlavorInfoList",
42                'InfoScrap',
43                'GetScrap',
44                'ZeroScrap',
45                'PutScrap',
46                ]
47
48    def makeblacklisttypes(self):
49        return [
50                'ScrapPromiseKeeperUPP',
51                ]
52
53    def makerepairinstructions(self):
54        return [
55                ([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]),
56                ([('void_ptr', '*', 'InMode')], [('putscrapbuffer', '*', 'InMode')]),
57                ]
58
59if __name__ == "__main__":
60    main()
61