/Mac/Modules/help/helpscan.py

http://unladen-swallow.googlecode.com/ · Python · 66 lines · 48 code · 10 blank · 8 comment · 4 complexity · 1e6cc7ddd40254d5193b92972951a258 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
  6. LONG = "MacHelp"
  7. SHORT = "help"
  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. print "=== Testing definitions output code ==="
  17. execfile(defsoutput, {}, {})
  18. print "=== Done scanning and generating, now importing the generated code... ==="
  19. exec "import " + SHORT + "support"
  20. print "=== Done. It's up to you to compile it now! ==="
  21. class MyScanner(Scanner):
  22. def destination(self, type, name, arglist):
  23. classname = "Function"
  24. listname = "functions"
  25. if arglist:
  26. t, n, m = arglist[0]
  27. # This is non-functional today
  28. if t == OBJECT and m == "InMode":
  29. classname = "Method"
  30. listname = "methods"
  31. return classname, listname
  32. def writeinitialdefs(self):
  33. self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
  34. def makeblacklistnames(self):
  35. return [
  36. ]
  37. def makeblacklisttypes(self):
  38. return [
  39. ## "TipFunctionUPP",
  40. ## "HMMessageRecord",
  41. ## "HMMessageRecord_ptr",
  42. "HMWindowContentUPP",
  43. "HMMenuTitleContentUPP",
  44. "HMControlContentUPP",
  45. "HMMenuItemContentUPP",
  46. # For the moment
  47. "HMHelpContentRec",
  48. "HMHelpContentRec_ptr",
  49. ]
  50. def makerepairinstructions(self):
  51. return [
  52. ## ([("WindowPtr", "*", "OutMode")],
  53. ## [("ExistingWindowPtr", "*", "*")]),
  54. ]
  55. if __name__ == "__main__":
  56. main()