]> granicus.if.org Git - python/commitdiff
Marc-Andre Lemburg's patch to move the typedef for PyCFunctionObject
authorGuido van Rossum <guido@python.org>
Fri, 10 Jul 1998 15:21:55 +0000 (15:21 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 10 Jul 1998 15:21:55 +0000 (15:21 +0000)
to the .h file and add macros there for inlined access to the fields.

Include/methodobject.h
Objects/methodobject.c

index 2d557c51a5c14d40f1e06eafc1ce47c1c28be5eb..2b4819f184f33241f4e990d048f11bec244a813f 100644 (file)
@@ -49,6 +49,15 @@ extern PyCFunction PyCFunction_GetFunction Py_PROTO((PyObject *));
 extern PyObject *PyCFunction_GetSelf Py_PROTO((PyObject *));
 extern int PyCFunction_GetFlags Py_PROTO((PyObject *));
 
+/* Macros for direct access to these values. Type checks are *not*
+   done, so use with care. */
+#define PyCFunction_GET_FUNCTION(func) \
+        (((PyCFunctionObject *)func) -> m_ml -> ml_meth)
+#define PyCFunction_GET_SELF(func) \
+       (((PyCFunctionObject *)func) -> m_self)
+#define PyCFunction_GET_FLAGS(func) \
+       (((PyCFunctionObject *)func) -> m_ml -> ml_flags)
+
 struct PyMethodDef {
        char            *ml_name;
        PyCFunction     ml_meth;
@@ -75,6 +84,12 @@ typedef struct PyMethodChain {
 extern PyObject *Py_FindMethodInChain
        Py_PROTO((PyMethodChain *, PyObject *, char *));
 
+typedef struct {
+       PyObject_HEAD
+       PyMethodDef *m_ml;
+       PyObject    *m_self;
+} PyCFunctionObject;
+
 #ifdef __cplusplus
 }
 #endif
index 529e2a187015ddf1d5e3c29ed4cf4a91f42f4cd7..672981fb7880e50984f66ad79f86b86202e679d1 100644 (file)
@@ -35,12 +35,6 @@ PERFORMANCE OF THIS SOFTWARE.
 
 #include "token.h"
 
-typedef struct {
-       PyObject_HEAD
-       PyMethodDef *m_ml;
-       PyObject    *m_self;
-} PyCFunctionObject;
-
 static PyCFunctionObject *free_list = NULL;
 
 PyObject *