| 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 = "Fonts" |
|---|
| 9 | n/a | SHORT = "fm" |
|---|
| 10 | n/a | |
|---|
| 11 | n/a | def main(): |
|---|
| 12 | n/a | input = "Fonts.h" |
|---|
| 13 | n/a | output = SHORT + "gen.py" |
|---|
| 14 | n/a | defsoutput = TOOLBOXDIR + LONG + ".py" |
|---|
| 15 | n/a | scanner = MyScanner(input, output, defsoutput) |
|---|
| 16 | n/a | scanner.scan() |
|---|
| 17 | n/a | scanner.close() |
|---|
| 18 | n/a | print "=== Testing definitions output code ===" |
|---|
| 19 | n/a | execfile(defsoutput, {}, {}) |
|---|
| 20 | n/a | print "=== Done scanning and generating, now importing the generated code... ===" |
|---|
| 21 | n/a | exec "import " + SHORT + "support" |
|---|
| 22 | n/a | print "=== Done. It's up to you to compile it now! ===" |
|---|
| 23 | n/a | |
|---|
| 24 | n/a | class MyScanner(Scanner): |
|---|
| 25 | n/a | |
|---|
| 26 | n/a | def destination(self, type, name, arglist): |
|---|
| 27 | n/a | classname = "Function" |
|---|
| 28 | n/a | listname = "functions" |
|---|
| 29 | n/a | return classname, listname |
|---|
| 30 | n/a | |
|---|
| 31 | n/a | def makeblacklistnames(self): |
|---|
| 32 | n/a | return [ |
|---|
| 33 | n/a | "OutlineMetrics", # Too complicated |
|---|
| 34 | n/a | "AntiTextIsAntiAliased", # XXXX Missing from library... |
|---|
| 35 | n/a | "AntiTextGetEnabled", |
|---|
| 36 | n/a | "AntiTextSetEnabled", |
|---|
| 37 | n/a | "AntiTextGetApplicationAware", |
|---|
| 38 | n/a | "AntiTextSetApplicationAware", |
|---|
| 39 | n/a | # These are tricky: they're not Carbon dependent or anything, but they |
|---|
| 40 | n/a | # exist only on 8.6 or later (both in Carbon and Classic). |
|---|
| 41 | n/a | # Disabling them is the easiest path. |
|---|
| 42 | n/a | 'SetAntiAliasedTextEnabled', |
|---|
| 43 | n/a | 'IsAntiAliasedTextEnabled', |
|---|
| 44 | n/a | # OS8-only |
|---|
| 45 | n/a | 'InitFonts', |
|---|
| 46 | n/a | 'SetFontLock', |
|---|
| 47 | n/a | 'FlushFonts', |
|---|
| 48 | n/a | ] |
|---|
| 49 | n/a | |
|---|
| 50 | n/a | def makeblacklisttypes(self): |
|---|
| 51 | n/a | return [ |
|---|
| 52 | n/a | "FMInput_ptr", # Not needed for now |
|---|
| 53 | n/a | "FMOutPtr", # Ditto |
|---|
| 54 | n/a | ## "void_ptr", # Don't know how to do this right now |
|---|
| 55 | n/a | "FontInfo", # Ditto |
|---|
| 56 | n/a | ] |
|---|
| 57 | n/a | |
|---|
| 58 | n/a | def makerepairinstructions(self): |
|---|
| 59 | n/a | return [ |
|---|
| 60 | n/a | ([('Str255', '*', 'InMode')], [('Str255', '*', 'OutMode')]), |
|---|
| 61 | n/a | ([('FMetricRecPtr', 'theMetrics', 'InMode')], [('FMetricRecPtr', 'theMetrics', 'OutMode')]), |
|---|
| 62 | n/a | ([('short', 'byteCount', 'InMode'), ('void_ptr', 'textAddr', 'InMode'),], |
|---|
| 63 | n/a | [('TextBuffer', 'inText', 'InMode')]), |
|---|
| 64 | n/a | ] |
|---|
| 65 | n/a | |
|---|
| 66 | n/a | def writeinitialdefs(self): |
|---|
| 67 | n/a | self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n") |
|---|
| 68 | n/a | self.defsfile.write("kNilOptions = 0\n") |
|---|
| 69 | n/a | |
|---|
| 70 | n/a | if __name__ == "__main__": |
|---|
| 71 | n/a | main() |
|---|