Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.5 KiB

  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. /* An array of memberlist structures defines the name, type and offset
  17. of selected members of a C structure. These can be read by
  18. PyMember_Get() and set by PyMember_Set() (except if their READONLY flag
  19. is set). The array must be terminated with an entry whose name
  20. pointer is NULL. */
  21. struct memberlist {
  22. /* Obsolete version, for binary backwards compatibility */
  23. char *name;
  24. int type;
  25. int offset;
  26. int flags;
  27. };
  28. typedef struct PyMemberDef {
  29. /* Current version, use this */
  30. char *name;
  31. int type;
  32. Py_ssize_t offset;
  33. int flags;
  34. char *doc;
  35. } PyMemberDef;
  36. /* Types */
  37. #define T_SHORT 0
  38. #define T_INT 1
  39. #define T_LONG 2
  40. #define T_FLOAT 3
  41. #define T_DOUBLE 4
  42. #define T_STRING 5
  43. #define T_OBJECT 6
  44. /* XXX the ordering here is weird for binary compatibility */
  45. #define T_CHAR 7 /* 1-character string */
  46. #define T_BYTE 8 /* 8-bit signed int */
  47. /* unsigned variants: */
  48. #define T_UBYTE 9
  49. #define T_USHORT 10
  50. #define T_UINT 11
  51. #define T_ULONG 12
  52. /* Added by Jack: strings contained in the structure */
  53. #define T_STRING_INPLACE 13
  54. #define T_OBJECT_EX 16 /* Like T_OBJECT, but raises AttributeError
  55. when the value is NULL, instead of
  56. converting to None. */
  57. #ifdef HAVE_LONG_LONG
  58. #define T_LONGLONG 17
  59. #define T_ULONGLONG 18
  60. #endif /* HAVE_LONG_LONG */
  61. /* Flags */
  62. #define READONLY 1
  63. #define RO READONLY /* Shorthand */
  64. #define READ_RESTRICTED 2
  65. #define WRITE_RESTRICTED 4
  66. #define RESTRICTED (READ_RESTRICTED | WRITE_RESTRICTED)
  67. /* Obsolete API, for binary backwards compatibility */
  68. PyAPI_FUNC(PyObject *) PyMember_Get(const char *, struct memberlist *, const char *);
  69. PyAPI_FUNC(int) PyMember_Set(char *, struct memberlist *, const char *, PyObject *);
  70. /* Current API, use this */
  71. PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, struct PyMemberDef *);
  72. PyAPI_FUNC(int) PyMember_SetOne(char *, struct PyMemberDef *, PyObject *);
  73. #ifdef __cplusplus
  74. }
  75. #endif
  76. #endif /* !Py_STRUCTMEMBER_H */