Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 1 | #ifndef Py_METHODOBJECT_H |
| 2 | #define Py_METHODOBJECT_H |
| 3 | #ifdef __cplusplus |
| 4 | extern "C" { |
| 5 | #endif |
| 6 | |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 7 | /*********************************************************** |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 8 | Copyright (c) 2000, BeOpen.com. |
| 9 | Copyright (c) 1995-2000, Corporation for National Research Initiatives. |
| 10 | Copyright (c) 1990-1995, Stichting Mathematisch Centrum. |
| 11 | All rights reserved. |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 12 | |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 13 | See the file "Misc/COPYRIGHT" for information on usage and |
| 14 | redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 15 | ******************************************************************/ |
| 16 | |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 17 | /* Method object interface */ |
| 18 | |
Guido van Rossum | 051ab12 | 1995-02-27 10:17:52 +0000 | [diff] [blame] | 19 | extern DL_IMPORT(PyTypeObject) PyCFunction_Type; |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 20 | |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 21 | #define PyCFunction_Check(op) ((op)->ob_type == &PyCFunction_Type) |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 22 | |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 23 | typedef PyObject *(*PyCFunction) Py_FPROTO((PyObject *, PyObject *)); |
Guido van Rossum | bebdc37 | 1995-07-26 17:58:29 +0000 | [diff] [blame] | 24 | typedef PyObject *(*PyCFunctionWithKeywords) |
| 25 | Py_FPROTO((PyObject *, PyObject *, PyObject *)); |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 26 | |
Guido van Rossum | 43466ec | 1998-12-04 18:48:25 +0000 | [diff] [blame] | 27 | extern DL_IMPORT(PyCFunction) PyCFunction_GetFunction Py_PROTO((PyObject *)); |
| 28 | extern DL_IMPORT(PyObject *) PyCFunction_GetSelf Py_PROTO((PyObject *)); |
| 29 | extern DL_IMPORT(int) PyCFunction_GetFlags Py_PROTO((PyObject *)); |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 30 | |
Guido van Rossum | 9223351 | 1998-07-10 15:21:55 +0000 | [diff] [blame] | 31 | /* Macros for direct access to these values. Type checks are *not* |
| 32 | done, so use with care. */ |
| 33 | #define PyCFunction_GET_FUNCTION(func) \ |
| 34 | (((PyCFunctionObject *)func) -> m_ml -> ml_meth) |
| 35 | #define PyCFunction_GET_SELF(func) \ |
| 36 | (((PyCFunctionObject *)func) -> m_self) |
| 37 | #define PyCFunction_GET_FLAGS(func) \ |
| 38 | (((PyCFunctionObject *)func) -> m_ml -> ml_flags) |
| 39 | |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 40 | struct PyMethodDef { |
| 41 | char *ml_name; |
| 42 | PyCFunction ml_meth; |
| 43 | int ml_flags; |
| 44 | char *ml_doc; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 45 | }; |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 46 | typedef struct PyMethodDef PyMethodDef; |
Guido van Rossum | 3f5da24 | 1990-12-20 15:06:42 +0000 | [diff] [blame] | 47 | |
Guido van Rossum | 43466ec | 1998-12-04 18:48:25 +0000 | [diff] [blame] | 48 | extern DL_IMPORT(PyObject *) Py_FindMethod |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 49 | Py_PROTO((PyMethodDef[], PyObject *, char *)); |
Guido van Rossum | 9dc8d0e | 1995-01-07 10:32:29 +0000 | [diff] [blame] | 50 | |
Guido van Rossum | 43466ec | 1998-12-04 18:48:25 +0000 | [diff] [blame] | 51 | extern DL_IMPORT(PyObject *) PyCFunction_New |
Guido van Rossum | caa6380 | 1995-01-12 11:45:45 +0000 | [diff] [blame] | 52 | Py_PROTO((PyMethodDef *, PyObject *)); |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 53 | |
Guido van Rossum | 5799b52 | 1995-01-04 19:06:22 +0000 | [diff] [blame] | 54 | /* Flag passed to newmethodobject */ |
| 55 | #define METH_VARARGS 0x0001 |
Guido van Rossum | bebdc37 | 1995-07-26 17:58:29 +0000 | [diff] [blame] | 56 | #define METH_KEYWORDS 0x0002 |
Guido van Rossum | 5799b52 | 1995-01-04 19:06:22 +0000 | [diff] [blame] | 57 | |
Guido van Rossum | 6978503 | 1995-01-26 22:58:48 +0000 | [diff] [blame] | 58 | typedef struct PyMethodChain { |
| 59 | PyMethodDef *methods; /* Methods of this type */ |
| 60 | struct PyMethodChain *link; /* NULL or base type */ |
| 61 | } PyMethodChain; |
| 62 | |
Guido van Rossum | 43466ec | 1998-12-04 18:48:25 +0000 | [diff] [blame] | 63 | extern DL_IMPORT(PyObject *) Py_FindMethodInChain |
Guido van Rossum | 6978503 | 1995-01-26 22:58:48 +0000 | [diff] [blame] | 64 | Py_PROTO((PyMethodChain *, PyObject *, char *)); |
| 65 | |
Guido van Rossum | 9223351 | 1998-07-10 15:21:55 +0000 | [diff] [blame] | 66 | typedef struct { |
| 67 | PyObject_HEAD |
| 68 | PyMethodDef *m_ml; |
| 69 | PyObject *m_self; |
| 70 | } PyCFunctionObject; |
| 71 | |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 72 | #ifdef __cplusplus |
| 73 | } |
| 74 | #endif |
| 75 | #endif /* !Py_METHODOBJECT_H */ |