| 1 | n/a | # Scan an Apple header file, generating a Python file of generator calls. |
|---|
| 2 | n/a | # |
|---|
| 3 | n/a | # Note that the scrap-manager include file is so weird that this |
|---|
| 4 | n/a | # generates a boilerplate to be edited by hand. |
|---|
| 5 | n/a | |
|---|
| 6 | n/a | import sys |
|---|
| 7 | n/a | from bgenlocations import TOOLBOXDIR, BGENDIR |
|---|
| 8 | n/a | sys.path.append(BGENDIR) |
|---|
| 9 | n/a | from scantools import Scanner |
|---|
| 10 | n/a | |
|---|
| 11 | n/a | LONG = "Scrap" |
|---|
| 12 | n/a | SHORT = "scrap" |
|---|
| 13 | n/a | |
|---|
| 14 | n/a | def main(): |
|---|
| 15 | n/a | input = "Scrap.h" |
|---|
| 16 | n/a | output = SHORT + "gen.py" |
|---|
| 17 | n/a | defsoutput = "@Scrap.py" |
|---|
| 18 | n/a | scanner = MyScanner(input, output, defsoutput) |
|---|
| 19 | n/a | scanner.scan() |
|---|
| 20 | n/a | scanner.close() |
|---|
| 21 | n/a | ## print "=== Testing definitions output code ===" |
|---|
| 22 | n/a | ## execfile(defsoutput, {}, {}) |
|---|
| 23 | n/a | print "=== Done scanning and generating, now importing the generated code... ===" |
|---|
| 24 | n/a | exec "import " + SHORT + "support" |
|---|
| 25 | n/a | print "=== Done. It's up to you to compile it now! ===" |
|---|
| 26 | n/a | |
|---|
| 27 | n/a | class MyScanner(Scanner): |
|---|
| 28 | n/a | |
|---|
| 29 | n/a | def destination(self, type, name, arglist): |
|---|
| 30 | n/a | classname = "Function" |
|---|
| 31 | n/a | listname = "functions" |
|---|
| 32 | n/a | if arglist: |
|---|
| 33 | n/a | t, n, m = arglist[0] |
|---|
| 34 | n/a | if t == 'ScrapRef' and m == "InMode": |
|---|
| 35 | n/a | classname = "Method" |
|---|
| 36 | n/a | listname = "methods" |
|---|
| 37 | n/a | return classname, listname |
|---|
| 38 | n/a | |
|---|
| 39 | n/a | def makeblacklistnames(self): |
|---|
| 40 | n/a | return [ |
|---|
| 41 | n/a | "GetScrapFlavorInfoList", |
|---|
| 42 | n/a | 'InfoScrap', |
|---|
| 43 | n/a | 'GetScrap', |
|---|
| 44 | n/a | 'ZeroScrap', |
|---|
| 45 | n/a | 'PutScrap', |
|---|
| 46 | n/a | ] |
|---|
| 47 | n/a | |
|---|
| 48 | n/a | def makeblacklisttypes(self): |
|---|
| 49 | n/a | return [ |
|---|
| 50 | n/a | 'ScrapPromiseKeeperUPP', |
|---|
| 51 | n/a | ] |
|---|
| 52 | n/a | |
|---|
| 53 | n/a | def makerepairinstructions(self): |
|---|
| 54 | n/a | return [ |
|---|
| 55 | n/a | ([('void', '*', 'OutMode')], [('putscrapbuffer', '*', 'InMode')]), |
|---|
| 56 | n/a | ([('void_ptr', '*', 'InMode')], [('putscrapbuffer', '*', 'InMode')]), |
|---|
| 57 | n/a | ] |
|---|
| 58 | n/a | |
|---|
| 59 | n/a | if __name__ == "__main__": |
|---|
| 60 | n/a | main() |
|---|