| 1 | n/a | # Scan an Apple header file, generating a Python file of generator calls. |
|---|
| 2 | n/a | |
|---|
| 3 | n/a | import sys |
|---|
| 4 | n/a | from bgenlocations import TOOLBOXDIR, BGENDIR |
|---|
| 5 | n/a | sys.path.append(BGENDIR) |
|---|
| 6 | n/a | from scantools import Scanner |
|---|
| 7 | n/a | |
|---|
| 8 | n/a | LONG = "MacHelp" |
|---|
| 9 | n/a | SHORT = "help" |
|---|
| 10 | n/a | OBJECT = "NOTUSED" |
|---|
| 11 | n/a | |
|---|
| 12 | n/a | def main(): |
|---|
| 13 | n/a | input = LONG + ".h" |
|---|
| 14 | n/a | output = SHORT + "gen.py" |
|---|
| 15 | n/a | defsoutput = TOOLBOXDIR + LONG + ".py" |
|---|
| 16 | n/a | scanner = MyScanner(input, output, defsoutput) |
|---|
| 17 | n/a | scanner.scan() |
|---|
| 18 | n/a | scanner.close() |
|---|
| 19 | n/a | print "=== Testing definitions output code ===" |
|---|
| 20 | n/a | execfile(defsoutput, {}, {}) |
|---|
| 21 | n/a | print "=== Done scanning and generating, now importing the generated code... ===" |
|---|
| 22 | n/a | exec "import " + SHORT + "support" |
|---|
| 23 | n/a | print "=== Done. It's up to you to compile it now! ===" |
|---|
| 24 | n/a | |
|---|
| 25 | n/a | class MyScanner(Scanner): |
|---|
| 26 | n/a | |
|---|
| 27 | n/a | def destination(self, type, name, arglist): |
|---|
| 28 | n/a | classname = "Function" |
|---|
| 29 | n/a | listname = "functions" |
|---|
| 30 | n/a | if arglist: |
|---|
| 31 | n/a | t, n, m = arglist[0] |
|---|
| 32 | n/a | # This is non-functional today |
|---|
| 33 | n/a | if t == OBJECT and m == "InMode": |
|---|
| 34 | n/a | classname = "Method" |
|---|
| 35 | n/a | listname = "methods" |
|---|
| 36 | n/a | return classname, listname |
|---|
| 37 | n/a | |
|---|
| 38 | n/a | def writeinitialdefs(self): |
|---|
| 39 | n/a | self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") |
|---|
| 40 | n/a | |
|---|
| 41 | n/a | def makeblacklistnames(self): |
|---|
| 42 | n/a | return [ |
|---|
| 43 | n/a | ] |
|---|
| 44 | n/a | |
|---|
| 45 | n/a | def makeblacklisttypes(self): |
|---|
| 46 | n/a | return [ |
|---|
| 47 | n/a | ## "TipFunctionUPP", |
|---|
| 48 | n/a | ## "HMMessageRecord", |
|---|
| 49 | n/a | ## "HMMessageRecord_ptr", |
|---|
| 50 | n/a | "HMWindowContentUPP", |
|---|
| 51 | n/a | "HMMenuTitleContentUPP", |
|---|
| 52 | n/a | "HMControlContentUPP", |
|---|
| 53 | n/a | "HMMenuItemContentUPP", |
|---|
| 54 | n/a | # For the moment |
|---|
| 55 | n/a | "HMHelpContentRec", |
|---|
| 56 | n/a | "HMHelpContentRec_ptr", |
|---|
| 57 | n/a | ] |
|---|
| 58 | n/a | |
|---|
| 59 | n/a | def makerepairinstructions(self): |
|---|
| 60 | n/a | return [ |
|---|
| 61 | n/a | ## ([("WindowPtr", "*", "OutMode")], |
|---|
| 62 | n/a | ## [("ExistingWindowPtr", "*", "*")]), |
|---|
| 63 | n/a | ] |
|---|
| 64 | n/a | |
|---|
| 65 | n/a | if __name__ == "__main__": |
|---|
| 66 | n/a | main() |
|---|