PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/Include/methodobject.h

https://gitlab.com/areema/jirancomms_project
C Header | 94 lines | 59 code | 18 blank | 17 comment | 1 complexity | dd5afa78570a3b86fa0dbaa553e7f92a MD5 | raw file
  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 *(*PyCFunctionWithKeywords)(PyObject *, PyObject *,
  14. PyObject *);
  15. typedef PyObject *(*PyNoArgsFunction)(PyObject *);
  16. PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *);
  17. PyAPI_FUNC(PyObject *) PyCFunction_GetSelf(PyObject *);
  18. PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *);
  19. /* Macros for direct access to these values. Type checks are *not*
  20. done, so use with care. */
  21. #ifndef Py_LIMITED_API
  22. #define PyCFunction_GET_FUNCTION(func) \
  23. (((PyCFunctionObject *)func) -> m_ml -> ml_meth)
  24. #define PyCFunction_GET_SELF(func) \
  25. (((PyCFunctionObject *)func) -> m_ml -> ml_flags & METH_STATIC ? \
  26. NULL : ((PyCFunctionObject *)func) -> m_self)
  27. #define PyCFunction_GET_FLAGS(func) \
  28. (((PyCFunctionObject *)func) -> m_ml -> ml_flags)
  29. #endif
  30. PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *);
  31. struct PyMethodDef {
  32. const char *ml_name; /* The name of the built-in function/method */
  33. PyCFunction ml_meth; /* The C function that implements it */
  34. int ml_flags; /* Combination of METH_xxx flags, which mostly
  35. describe the args expected by the C func */
  36. const char *ml_doc; /* The __doc__ attribute, or NULL */
  37. };
  38. typedef struct PyMethodDef PyMethodDef;
  39. #define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL)
  40. PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *,
  41. PyObject *);
  42. /* Flag passed to newmethodobject */
  43. /* #define METH_OLDARGS 0x0000 -- unsupported now */
  44. #define METH_VARARGS 0x0001
  45. #define METH_KEYWORDS 0x0002
  46. /* METH_NOARGS and METH_O must not be combined with the flags above. */
  47. #define METH_NOARGS 0x0004
  48. #define METH_O 0x0008
  49. /* METH_CLASS and METH_STATIC are a little different; these control
  50. the construction of methods for a class. These cannot be used for
  51. functions in modules. */
  52. #define METH_CLASS 0x0010
  53. #define METH_STATIC 0x0020
  54. /* METH_COEXIST allows a method to be entered even though a slot has
  55. already filled the entry. When defined, the flag allows a separate
  56. method, "__contains__" for example, to coexist with a defined
  57. slot like sq_contains. */
  58. #define METH_COEXIST 0x0040
  59. #ifndef Py_LIMITED_API
  60. typedef struct {
  61. PyObject_HEAD
  62. PyMethodDef *m_ml; /* Description of the C function to call */
  63. PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */
  64. PyObject *m_module; /* The __module__ attribute, can be anything */
  65. PyObject *m_weakreflist; /* List of weak references */
  66. } PyCFunctionObject;
  67. #endif
  68. PyAPI_FUNC(int) PyCFunction_ClearFreeList(void);
  69. #ifndef Py_LIMITED_API
  70. PyAPI_FUNC(void) _PyCFunction_DebugMallocStats(FILE *out);
  71. PyAPI_FUNC(void) _PyMethod_DebugMallocStats(FILE *out);
  72. #endif
  73. #ifdef __cplusplus
  74. }
  75. #endif
  76. #endif /* !Py_METHODOBJECT_H */