Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 1 | /*********************************************************** |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 2 | Copyright (c) 2000, BeOpen.com. |
| 3 | Copyright (c) 1995-2000, Corporation for National Research Initiatives. |
| 4 | Copyright (c) 1990-1995, Stichting Mathematisch Centrum. |
| 5 | All rights reserved. |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 6 | |
Guido van Rossum | fd71b9e | 2000-06-30 23:50:40 +0000 | [diff] [blame] | 7 | See the file "Misc/COPYRIGHT" for information on usage and |
| 8 | redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
Guido van Rossum | f70e43a | 1991-02-19 12:39:46 +0000 | [diff] [blame] | 9 | ******************************************************************/ |
| 10 | |
Guido van Rossum | 85a5fbb | 1990-10-14 12:07:46 +0000 | [diff] [blame] | 11 | /* Method object interface */ |
| 12 | |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 13 | #ifndef Py_METHODOBJECT_H |
| 14 | #define Py_METHODOBJECT_H |
| 15 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif |
| 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 | |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 27 | extern DL_IMPORT(PyCFunction) PyCFunction_GetFunction(PyObject *); |
| 28 | extern DL_IMPORT(PyObject *) PyCFunction_GetSelf(PyObject *); |
| 29 | extern DL_IMPORT(int) PyCFunction_GetFlags(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 { |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 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 | |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 48 | extern DL_IMPORT(PyObject *) Py_FindMethod(PyMethodDef[], PyObject *, char *); |
Guido van Rossum | 9dc8d0e | 1995-01-07 10:32:29 +0000 | [diff] [blame] | 49 | |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 50 | extern DL_IMPORT(PyObject *) PyCFunction_New(PyMethodDef *, PyObject *); |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 51 | |
Guido van Rossum | 5799b52 | 1995-01-04 19:06:22 +0000 | [diff] [blame] | 52 | /* Flag passed to newmethodobject */ |
| 53 | #define METH_VARARGS 0x0001 |
Guido van Rossum | bebdc37 | 1995-07-26 17:58:29 +0000 | [diff] [blame] | 54 | #define METH_KEYWORDS 0x0002 |
Guido van Rossum | 5799b52 | 1995-01-04 19:06:22 +0000 | [diff] [blame] | 55 | |
Guido van Rossum | 6978503 | 1995-01-26 22:58:48 +0000 | [diff] [blame] | 56 | typedef struct PyMethodChain { |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 57 | PyMethodDef *methods; /* Methods of this type */ |
| 58 | struct PyMethodChain *link; /* NULL or base type */ |
Guido van Rossum | 6978503 | 1995-01-26 22:58:48 +0000 | [diff] [blame] | 59 | } PyMethodChain; |
| 60 | |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 61 | extern DL_IMPORT(PyObject *) Py_FindMethodInChain(PyMethodChain *, PyObject *, |
| 62 | char *); |
Guido van Rossum | 6978503 | 1995-01-26 22:58:48 +0000 | [diff] [blame] | 63 | |
Guido van Rossum | 9223351 | 1998-07-10 15:21:55 +0000 | [diff] [blame] | 64 | typedef struct { |
Fred Drake | ea9cb5a | 2000-07-09 00:20:36 +0000 | [diff] [blame] | 65 | PyObject_HEAD |
| 66 | PyMethodDef *m_ml; |
| 67 | PyObject *m_self; |
Guido van Rossum | 9223351 | 1998-07-10 15:21:55 +0000 | [diff] [blame] | 68 | } PyCFunctionObject; |
| 69 | |
Guido van Rossum | a330996 | 1993-07-28 09:05:47 +0000 | [diff] [blame] | 70 | #ifdef __cplusplus |
| 71 | } |
| 72 | #endif |
| 73 | #endif /* !Py_METHODOBJECT_H */ |