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 |
| 5 | BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen') |
| 6 | sys.path.append(BGENDIR) |
| 7 | |
| 8 | from scantools import Scanner |
| 9 | from bgenlocations import TOOLBOXDIR |
| 10 | |
| 11 | LONG = "HtmlRendering" |
| 12 | SHORT = "html" |
| 13 | OBJECT = "HRReference" |
| 14 | |
| 15 | def main(): |
| 16 | ## input = LONG + ".h" |
Jack Jansen | d9c01a5 | 2000-05-15 15:36:52 +0000 | [diff] [blame^] | 17 | input = "Macintosh HD:ufs:jack:SWdev:Universal:Interfaces:CIncludes:HTMLRendering.h" |
Jack Jansen | ebd0106 | 2000-05-14 22:05:36 +0000 | [diff] [blame] | 18 | output = SHORT + "gen.py" |
| 19 | defsoutput = TOOLBOXDIR + LONG + ".py" |
| 20 | scanner = MyScanner(input, output, defsoutput) |
| 21 | scanner.scan() |
| 22 | scanner.close() |
| 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 | |
| 27 | class 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 == OBJECT and m == "InMode": |
| 35 | classname = "Method" |
| 36 | listname = "methods" |
| 37 | return classname, listname |
| 38 | |
| 39 | def makeblacklistnames(self): |
| 40 | return [ |
Jack Jansen | d9c01a5 | 2000-05-15 15:36:52 +0000 | [diff] [blame^] | 41 | "HRDisposeReference", |
Jack Jansen | ebd0106 | 2000-05-14 22:05:36 +0000 | [diff] [blame] | 42 | ] |
| 43 | |
| 44 | def makeblacklisttypes(self): |
| 45 | return [ |
| 46 | "HRNewURLUPP", |
| 47 | "HRURLToFSSpecUPP", |
| 48 | "HRWasURLVisitedUPP", |
| 49 | ] |
| 50 | |
| 51 | def makerepairinstructions(self): |
| 52 | return [ |
| 53 | ([('char', '*', 'OutMode'), ('UInt32', '*', 'InMode')], |
| 54 | [('InBuffer', '*', 'InMode')]), |
| 55 | ] |
| 56 | |
| 57 | def writeinitialdefs(self): |
| 58 | self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") |
| 59 | |
| 60 | |
| 61 | if __name__ == "__main__": |
| 62 | main() |