| 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 |
|
|---|
| 6 | import sys
|
|---|
| 7 | import os
|
|---|
| 8 | from bgenlocations import TOOLBOXDIR, BGENDIR
|
|---|
| 9 | sys.path.append(BGENDIR)
|
|---|
| 10 | from scantools import Scanner
|
|---|
| 11 |
|
|---|
| 12 | LONG = "Scrap"
|
|---|
| 13 | SHORT = "scrap"
|
|---|
| 14 |
|
|---|
| 15 | def 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 "=== Testing definitions output code ==="
|
|---|
| 23 | ## execfile(defsoutput, {}, {})
|
|---|
| 24 | 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 |
|
|---|
| 28 | class MyScanner(Scanner):
|
|---|
| 29 |
|
|---|
| 30 | def destination(self, type, name, arglist):
|
|---|
| 31 | classname = "Function"
|
|---|
| 32 | listname = "functions"
|
|---|
| 33 | if arglist:
|
|---|
| 34 | t, n, m = arglist[0]
|
|---|
| 35 | if t == 'ScrapRef' and m == "InMode":
|
|---|
| 36 | classname = "Method"
|
|---|
| 37 | listname = "methods"
|
|---|
| 38 | return classname, listname
|
|---|
| 39 |
|
|---|
| 40 | def makeblacklistnames(self):
|
|---|
| 41 | return [
|
|---|
| 42 | "GetScrapFlavorInfoList",
|
|---|
| 43 | 'InfoScrap',
|
|---|
| 44 | 'GetScrap',
|
|---|
| 45 | 'ZeroScrap',
|
|---|
| 46 | 'PutScrap',
|
|---|
| 47 | ]
|
|---|
| 48 |
|
|---|
| 49 | def makeblacklisttypes(self):
|
|---|
| 50 | return [
|
|---|
| 51 | 'ScrapPromiseKeeperUPP',
|
|---|
| 52 | ]
|
|---|
| 53 |
|
|---|
| 54 | def makerepairinstructions(self):
|
|---|
| 55 | return [
|
|---|
| 56 | ([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]),
|
|---|
| 57 | ([('void_ptr', '*', 'InMode')], [('putscrapbuffer', '*', 'InMode')]),
|
|---|
| 58 | ]
|
|---|
| 59 |
|
|---|
| 60 | if __name__ == "__main__":
|
|---|
| 61 | main()
|
|---|