PageRenderTime 345ms CodeModel.GetById 131ms app.highlight 5ms RepoModel.GetById 136ms app.codeStats 0ms

/Mac/Modules/scrap/scrapscan.py

http://unladen-swallow.googlecode.com/
Python | 60 lines | 45 code | 9 blank | 6 comment | 4 complexity | 28e08ff0e680899ff815b3f2ecfa8146 MD5 | raw file
 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()