/Mac/Modules/folder/folderscan.py

http://unladen-swallow.googlecode.com/ · Python · 67 lines · 53 code · 12 blank · 2 comment · 4 complexity · 3036ce974d18955fc04b6455a0a669b2 MD5 · raw file

  1. # Scan an Apple header file, generating a Python file of generator calls.
  2. import sys
  3. from bgenlocations import TOOLBOXDIR, BGENDIR
  4. sys.path.append(BGENDIR)
  5. from scantools import Scanner_OSX
  6. LONG = "Folders"
  7. SHORT = "folder"
  8. OBJECT = "NOTUSED"
  9. def main():
  10. input = LONG + ".h"
  11. output = SHORT + "gen.py"
  12. defsoutput = TOOLBOXDIR + LONG + ".py"
  13. scanner = MyScanner(input, output, defsoutput)
  14. scanner.scan()
  15. scanner.close()
  16. scanner.gentypetest(SHORT+"typetest.py")
  17. print "=== Testing definitions output code ==="
  18. execfile(defsoutput, {}, {})
  19. print "=== Done scanning and generating, now importing the generated code... ==="
  20. exec "import " + SHORT + "support"
  21. print "=== Done. It's up to you to compile it now! ==="
  22. class MyScanner(Scanner_OSX):
  23. def destination(self, type, name, arglist):
  24. classname = "Function"
  25. listname = "functions"
  26. if arglist:
  27. t, n, m = arglist[0]
  28. # This is non-functional today
  29. if t == OBJECT and m == "InMode":
  30. classname = "Method"
  31. listname = "methods"
  32. return classname, listname
  33. def makeblacklistnames(self):
  34. return [
  35. "FindFolderExtended", # Has funny void* argument
  36. "FSFindFolderExtended", # ditto
  37. "FolderManagerRegisterCallNotificationProcs", # ditto
  38. "FindFolderEx", # Non-MacOS routine
  39. ]
  40. def makeblacklisttypes(self):
  41. return [
  42. "FolderManagerNotificationProcPtr",
  43. "FolderManagerNotificationUPP",
  44. "FolderRouting", # To be done, not difficult
  45. "FolderDesc", # To be done, not difficult
  46. ]
  47. def makerepairinstructions(self):
  48. return [
  49. ]
  50. def writeinitialdefs(self):
  51. self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
  52. self.defsfile.write("true = True\n")
  53. self.defsfile.write("false = False\n")
  54. if __name__ == "__main__":
  55. main()