/Tools/framer/framer/slots.py

http://unladen-swallow.googlecode.com/ · Python · 64 lines · 64 code · 0 blank · 0 comment · 0 complexity · ad13eb05c7d295ce2038b07dd629cff6 MD5 · raw file

  1. """Descriptions of all the slots in Python's type objects."""
  2. class Slot(object):
  3. def __init__(self, name, cast=None, special=None, default="0"):
  4. self.name = name
  5. self.cast = cast
  6. self.special = special
  7. self.default = default
  8. Slots = (Slot("ob_size"),
  9. Slot("tp_name"),
  10. Slot("tp_basicsize"),
  11. Slot("tp_itemsize"),
  12. Slot("tp_dealloc", "destructor"),
  13. Slot("tp_print", "printfunc"),
  14. Slot("tp_getattr", "getattrfunc"),
  15. Slot("tp_setattr", "setattrfunc"),
  16. Slot("tp_compare", "cmpfunc", "__cmp__"),
  17. Slot("tp_repr", "reprfunc", "__repr__"),
  18. Slot("tp_as_number"),
  19. Slot("tp_as_sequence"),
  20. Slot("tp_as_mapping"),
  21. Slot("tp_hash", "hashfunc", "__hash__"),
  22. Slot("tp_call", "ternaryfunc", "__call__"),
  23. Slot("tp_str", "reprfunc", "__str__"),
  24. Slot("tp_getattro", "getattrofunc", "__getattr__", # XXX
  25. "PyObject_GenericGetAttr"),
  26. Slot("tp_setattro", "setattrofunc", "__setattr__"),
  27. Slot("tp_as_buffer"),
  28. Slot("tp_flags", default="Py_TPFLAGS_DEFAULT"),
  29. Slot("tp_doc"),
  30. Slot("tp_traverse", "traverseprox"),
  31. Slot("tp_clear", "inquiry"),
  32. Slot("tp_richcompare", "richcmpfunc"),
  33. Slot("tp_weaklistoffset"),
  34. Slot("tp_iter", "getiterfunc", "__iter__"),
  35. Slot("tp_iternext", "iternextfunc", "__next__"), # XXX
  36. Slot("tp_methods"),
  37. Slot("tp_members"),
  38. Slot("tp_getset"),
  39. Slot("tp_base"),
  40. Slot("tp_dict"),
  41. Slot("tp_descr_get", "descrgetfunc"),
  42. Slot("tp_descr_set", "descrsetfunc"),
  43. Slot("tp_dictoffset"),
  44. Slot("tp_init", "initproc", "__init__"),
  45. Slot("tp_alloc", "allocfunc"),
  46. Slot("tp_new", "newfunc"),
  47. Slot("tp_free", "freefunc"),
  48. Slot("tp_is_gc", "inquiry"),
  49. Slot("tp_bases"),
  50. Slot("tp_mro"),
  51. Slot("tp_cache"),
  52. Slot("tp_subclasses"),
  53. Slot("tp_weaklist"),
  54. )
  55. # give some slots symbolic names
  56. TP_NAME = Slots[1]
  57. TP_BASICSIZE = Slots[2]
  58. TP_DEALLOC = Slots[4]
  59. TP_DOC = Slots[20]
  60. TP_METHODS = Slots[27]
  61. TP_MEMBERS = Slots[28]