| 1 | # Scan an Apple header file, generating a Python file of generator calls.
|
|---|
| 2 |
|
|---|
| 3 | import sys
|
|---|
| 4 | import os
|
|---|
| 5 | from bgenlocations import TOOLBOXDIR, BGENDIR
|
|---|
| 6 | sys.path.append(BGENDIR)
|
|---|
| 7 | from scantools import Scanner_OSX
|
|---|
| 8 |
|
|---|
| 9 | LONG = "Folders"
|
|---|
| 10 | SHORT = "folder"
|
|---|
| 11 | OBJECT = "NOTUSED"
|
|---|
| 12 |
|
|---|
| 13 | def main():
|
|---|
| 14 | input = LONG + ".h"
|
|---|
| 15 | output = SHORT + "gen.py"
|
|---|
| 16 | defsoutput = TOOLBOXDIR + LONG + ".py"
|
|---|
| 17 | scanner = MyScanner(input, output, defsoutput)
|
|---|
| 18 | scanner.scan()
|
|---|
| 19 | scanner.close()
|
|---|
| 20 | scanner.gentypetest(SHORT+"typetest.py")
|
|---|
| 21 | print "=== Testing definitions output code ==="
|
|---|
| 22 | execfile(defsoutput, {}, {})
|
|---|
| 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_OSX):
|
|---|
| 28 |
|
|---|
| 29 | def destination(self, type, name, arglist):
|
|---|
| 30 | classname = "Function"
|
|---|
| 31 | listname = "functions"
|
|---|
| 32 | if arglist:
|
|---|
| 33 | t, n, m = arglist[0]
|
|---|
| 34 | # This is non-functional today
|
|---|
| 35 | if t == OBJECT and m == "InMode":
|
|---|
| 36 | classname = "Method"
|
|---|
| 37 | listname = "methods"
|
|---|
| 38 | return classname, listname
|
|---|
| 39 |
|
|---|
| 40 | def makeblacklistnames(self):
|
|---|
| 41 | return [
|
|---|
| 42 | "FindFolderExtended", # Has funny void* argument
|
|---|
| 43 | "FSFindFolderExtended", # ditto
|
|---|
| 44 | "FolderManagerRegisterCallNotificationProcs", # ditto
|
|---|
| 45 |
|
|---|
| 46 | "FindFolderEx", # Non-MacOS routine
|
|---|
| 47 | ]
|
|---|
| 48 |
|
|---|
| 49 | def makeblacklisttypes(self):
|
|---|
| 50 | return [
|
|---|
| 51 | "FolderManagerNotificationProcPtr",
|
|---|
| 52 | "FolderManagerNotificationUPP",
|
|---|
| 53 | "FolderRouting", # To be done, not difficult
|
|---|
| 54 | "FolderDesc", # To be done, not difficult
|
|---|
| 55 |
|
|---|
| 56 | ]
|
|---|
| 57 |
|
|---|
| 58 | def makerepairinstructions(self):
|
|---|
| 59 | return [
|
|---|
| 60 | ]
|
|---|
| 61 |
|
|---|
| 62 | def writeinitialdefs(self):
|
|---|
| 63 | self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
|
|---|
| 64 | self.defsfile.write("true = True\n")
|
|---|
| 65 | self.defsfile.write("false = False\n")
|
|---|
| 66 |
|
|---|
| 67 | if __name__ == "__main__":
|
|---|
| 68 | main()
|
|---|