Jack Jansen | ebd0106 | 2000-05-14 22:05:36 +0000 | [diff] [blame] | 1 | # Scan an Apple header file, generating a Python file of generator calls. |
| 2 | |
| 3 | import sys |
| 4 | import os |
Jack Jansen | aaebdd6 | 2002-08-05 15:39:30 +0000 | [diff] [blame] | 5 | from bgenlocations import TOOLBOXDIR, BGENDIR |
Jack Jansen | ebd0106 | 2000-05-14 22:05:36 +0000 | [diff] [blame] | 6 | sys.path.append(BGENDIR) |
| 7 | |
| 8 | from scantools import Scanner |
Jack Jansen | ebd0106 | 2000-05-14 22:05:36 +0000 | [diff] [blame] | 9 | |
| 10 | LONG = "HtmlRendering" |
| 11 | SHORT = "html" |
| 12 | OBJECT = "HRReference" |
| 13 | |
| 14 | def main(): |
| 15 | ## input = LONG + ".h" |
Jack Jansen | d9c01a5 | 2000-05-15 15:36:52 +0000 | [diff] [blame] | 16 | input = "Macintosh HD:ufs:jack:SWdev:Universal:Interfaces:CIncludes:HTMLRendering.h" |
Jack Jansen | ebd0106 | 2000-05-14 22:05:36 +0000 | [diff] [blame] | 17 | output = SHORT + "gen.py" |
| 18 | defsoutput = TOOLBOXDIR + LONG + ".py" |
| 19 | scanner = MyScanner(input, output, defsoutput) |
| 20 | scanner.scan() |
| 21 | scanner.close() |
Jack Jansen | 87eea88 | 2002-08-15 21:48:16 +0000 | [diff] [blame] | 22 | print "=== Testing definitions output code ===" |
| 23 | execfile(defsoutput, {}, {}) |
Jack Jansen | ebd0106 | 2000-05-14 22:05:36 +0000 | [diff] [blame] | 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 == OBJECT and m == "InMode": |
| 36 | classname = "Method" |
| 37 | listname = "methods" |
| 38 | return classname, listname |
| 39 | |
| 40 | def makeblacklistnames(self): |
| 41 | return [ |
Jack Jansen | d9c01a5 | 2000-05-15 15:36:52 +0000 | [diff] [blame] | 42 | "HRDisposeReference", |
Jack Jansen | ebd0106 | 2000-05-14 22:05:36 +0000 | [diff] [blame] | 43 | ] |
| 44 | |
| 45 | def makeblacklisttypes(self): |
| 46 | return [ |
| 47 | "HRNewURLUPP", |
| 48 | "HRURLToFSSpecUPP", |
| 49 | "HRWasURLVisitedUPP", |
| 50 | ] |
| 51 | |
| 52 | def makerepairinstructions(self): |
| 53 | return [ |
| 54 | ([('char', '*', 'OutMode'), ('UInt32', '*', 'InMode')], |
| 55 | [('InBuffer', '*', 'InMode')]), |
| 56 | ] |
| 57 | |
| 58 | def writeinitialdefs(self): |
| 59 | self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") |
| 60 | |
| 61 | |
| 62 | if __name__ == "__main__": |
| 63 | main() |