Skip to content

Commit ba0d061

Browse files
committed
Add macros for direct access to the members of CFunction objects.
1 parent d4ba73c commit ba0d061

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Include/funcobject.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ extern PyObject *PyFunction_GetGlobals Py_PROTO((PyObject *));
5656
extern PyObject *PyFunction_GetDefaults Py_PROTO((PyObject *));
5757
extern int PyFunction_SetDefaults Py_PROTO((PyObject *, PyObject *));
5858

59+
/* Macros for direct access to these values. Type checks are *not*
60+
done, so use with care. */
61+
#define PyFunction_GET_CODE(func) \
62+
(((PyFunctionObject *)func) -> func_code)
63+
#define PyFunction_GET_GLOBALS(func) \
64+
(((PyFunctionObject *)func) -> func_globals)
65+
#define PyFunction_GET_DEFAULTS(func) \
66+
(((PyFunctionObject *)func) -> func_defaults)
67+
5968
#ifdef __cplusplus
6069
}
6170
#endif

0 commit comments

Comments
 (0)