structmember.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #ifndef Py_STRUCTMEMBER_H
  2. #define Py_STRUCTMEMBER_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. /* Interface to map C struct members to Python object attributes */
  7. #include <stddef.h> /* For offsetof */
  8. /* The offsetof() macro calculates the offset of a structure member
  9. in its structure. Unfortunately this cannot be written down
  10. portably, hence it is provided by a Standard C header file.
  11. For pre-Standard C compilers, here is a version that usually works
  12. (but watch out!): */
  13. #ifndef offsetof
  14. #define offsetof(type, member) ( (int) & ((type*)0) -> member )
  15. #endif
  16. /* Types */
  17. #define T_SHORT 0
  18. #define T_INT 1
  19. #define T_LONG 2
  20. #define T_FLOAT 3
  21. #define T_DOUBLE 4
  22. #define T_STRING 5
  23. #define T_OBJECT 6
  24. /* XXX the ordering here is weird for binary compatibility */
  25. #define T_CHAR 7 /* 1-character string */
  26. #define T_BYTE 8 /* 8-bit signed int */
  27. /* unsigned variants: */
  28. #define T_UBYTE 9
  29. #define T_USHORT 10
  30. #define T_UINT 11
  31. #define T_ULONG 12
  32. /* Added by Jack: strings contained in the structure */
  33. #define T_STRING_INPLACE 13
  34. /* Added by Lillo: bools contained in the structure (assumed char) */
  35. #define T_BOOL 14
  36. #define T_OBJECT_EX 16 /* Like T_OBJECT, but raises AttributeError
  37. when the value is NULL, instead of
  38. converting to None. */
  39. #ifdef HAVE_LONG_LONG
  40. #define T_LONGLONG 17
  41. #define T_ULONGLONG 18
  42. #endif /* HAVE_LONG_LONG */
  43. #define T_PYSSIZET 19 /* Py_ssize_t */
  44. /* Flags. These constants are also in structmemberdefs.py. */
  45. #define READONLY 1
  46. #define RO READONLY /* Shorthand */
  47. #define READ_RESTRICTED 2
  48. #define PY_WRITE_RESTRICTED 4
  49. #define RESTRICTED (READ_RESTRICTED | PY_WRITE_RESTRICTED)
  50. /* API functions. */
  51. /* Don't include them while building PyPy, RPython also generated signatures
  52. * which are similar but not identical. */
  53. #ifndef PYPY_STANDALONE
  54. #include "pypy_structmember_decl.h"
  55. #endif
  56. #ifdef __cplusplus
  57. }
  58. #endif
  59. #endif /* !Py_STRUCTMEMBER_H */