Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

methodobject.h 4.4 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
  1. /* Method object interface */
  2. #ifndef Py_METHODOBJECT_H
  3. #define Py_METHODOBJECT_H
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. /* This is about the type 'builtin_function_or_method',
  8. not Python methods in user-defined classes. See classobject.h
  9. for the latter. */
  10. PyAPI_DATA(PyTypeObject) PyCFunction_Type;
  11. #define PyCFunction_Check(op) (Py_TYPE(op) == &PyCFunction_Type)
  12. typedef PyObject *(*PyCFunction)(PyObject *, PyObject *);
  13. typedef PyObject *(*_PyCFunctionFast) (PyObject *, PyObject *const *, Py_ssize_t);
  14. typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *,
  15. PyObject *);
  16. typedef PyObject *(*_PyCFunctionFastWithKeywords) (PyObject *,
  17. PyObject *const *, Py_ssize_t,
  18. PyObject *);
  19. typedef PyObject *(*PyNoArgsFunction)(PyObject *);
  20. PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *);
  21. PyAPI_FUNC(PyObject *) PyCFunction_GetSelf(PyObject *);
  22. PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *);
  23. /* Macros for direct access to these values. Type checks are *not*
  24. done, so use with care. */
  25. #ifndef Py_LIMITED_API
  26. #define PyCFunction_GET_FUNCTION(func) \
  27. (((PyCFunctionObject *)func) -> m_ml -> ml_meth)
  28. #define PyCFunction_GET_SELF(func) \
  29. (((PyCFunctionObject *)func) -> m_ml -> ml_flags & METH_STATIC ? \
  30. NULL : ((PyCFunctionObject *)func) -> m_self)
  31. #define PyCFunction_GET_FLAGS(func) \
  32. (((PyCFunctionObject *)func) -> m_ml -> ml_flags)
  33. #endif
  34. PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *);
  35. #ifndef Py_LIMITED_API
  36. PyAPI_FUNC(PyObject *) _PyCFunction_FastCallDict(PyObject *func,
  37. PyObject *const *args,
  38. Py_ssize_t nargs,
  39. PyObject *kwargs);
  40. PyAPI_FUNC(PyObject *) _PyCFunction_FastCallKeywords(PyObject *func,
  41. PyObject *const *stack,
  42. Py_ssize_t nargs,
  43. PyObject *kwnames);
  44. #endif
  45. struct PyMethodDef {
  46. const char *ml_name; /* The name of the built-in function/method */
  47. PyCFunction ml_meth; /* The C function that implements it */
  48. int ml_flags; /* Combination of METH_xxx flags, which mostly
  49. describe the args expected by the C func */
  50. const char *ml_doc; /* The __doc__ attribute, or NULL */
  51. };
  52. typedef struct PyMethodDef PyMethodDef;
  53. #define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL)
  54. PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *,
  55. PyObject *);
  56. /* Flag passed to newmethodobject */
  57. /* #define METH_OLDARGS 0x0000 -- unsupported now */
  58. #define METH_VARARGS 0x0001
  59. #define METH_KEYWORDS 0x0002
  60. /* METH_NOARGS and METH_O must not be combined with the flags above. */
  61. #define METH_NOARGS 0x0004
  62. #define METH_O 0x0008
  63. /* METH_CLASS and METH_STATIC are a little different; these control
  64. the construction of methods for a class. These cannot be used for
  65. functions in modules. */
  66. #define METH_CLASS 0x0010
  67. #define METH_STATIC 0x0020
  68. /* METH_COEXIST allows a method to be entered even though a slot has
  69. already filled the entry. When defined, the flag allows a separate
  70. method, "__contains__" for example, to coexist with a defined
  71. slot like sq_contains. */
  72. #define METH_COEXIST 0x0040
  73. #ifndef Py_LIMITED_API
  74. #define METH_FASTCALL 0x0080
  75. #endif
  76. /* This bit is preserved for Stackless Python */
  77. #ifdef STACKLESS
  78. #define METH_STACKLESS 0x0100
  79. #else
  80. #define METH_STACKLESS 0x0000
  81. #endif
  82. #ifndef Py_LIMITED_API
  83. typedef struct {
  84. PyObject_HEAD
  85. PyMethodDef *m_ml; /* Description of the C function to call */
  86. PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */
  87. PyObject *m_module; /* The __module__ attribute, can be anything */
  88. PyObject *m_weakreflist; /* List of weak references */
  89. } PyCFunctionObject;
  90. PyAPI_FUNC(PyObject *) _PyMethodDef_RawFastCallDict(
  91. PyMethodDef *method,
  92. PyObject *self,
  93. PyObject *const *args,
  94. Py_ssize_t nargs,
  95. PyObject *kwargs);
  96. PyAPI_FUNC(PyObject *) _PyMethodDef_RawFastCallKeywords(
  97. PyMethodDef *method,
  98. PyObject *self,
  99. PyObject *const *args,
  100. Py_ssize_t nargs,
  101. PyObject *kwnames);
  102. #endif
  103. PyAPI_FUNC(int) PyCFunction_ClearFreeList(void);
  104. #ifndef Py_LIMITED_API
  105. PyAPI_FUNC(void) _PyCFunction_DebugMallocStats(FILE *out);
  106. PyAPI_FUNC(void) _PyMethod_DebugMallocStats(FILE *out);
  107. #endif
  108. #ifdef __cplusplus
  109. }
  110. #endif
  111. #endif /* !Py_METHODOBJECT_H */
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...