home *** CD-ROM | disk | FTP | other *** search
/ Freelog 33 / Freelog033.iso / Progr / Python-2.2.1.exe / FUNCOBJECT.H < prev    next >
Encoding:
C/C++ Source or Header  |  2001-08-02  |  1.8 KB  |  56 lines

  1.  
  2. /* Function object interface */
  3.  
  4. #ifndef Py_FUNCOBJECT_H
  5. #define Py_FUNCOBJECT_H
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9.  
  10. typedef struct {
  11.     PyObject_HEAD
  12.     PyObject *func_code;
  13.     PyObject *func_globals;
  14.     PyObject *func_defaults;
  15.     PyObject *func_closure;
  16.     PyObject *func_doc;
  17.     PyObject *func_name;
  18.     PyObject *func_dict;
  19.     PyObject *func_weakreflist;
  20. } PyFunctionObject;
  21.  
  22. extern DL_IMPORT(PyTypeObject) PyFunction_Type;
  23.  
  24. #define PyFunction_Check(op) ((op)->ob_type == &PyFunction_Type)
  25.  
  26. extern DL_IMPORT(PyObject *) PyFunction_New(PyObject *, PyObject *);
  27. extern DL_IMPORT(PyObject *) PyFunction_GetCode(PyObject *);
  28. extern DL_IMPORT(PyObject *) PyFunction_GetGlobals(PyObject *);
  29. extern DL_IMPORT(PyObject *) PyFunction_GetDefaults(PyObject *);
  30. extern DL_IMPORT(int) PyFunction_SetDefaults(PyObject *, PyObject *);
  31. extern DL_IMPORT(PyObject *) PyFunction_GetClosure(PyObject *);
  32. extern DL_IMPORT(int) PyFunction_SetClosure(PyObject *, PyObject *);
  33.  
  34. /* Macros for direct access to these values. Type checks are *not*
  35.    done, so use with care. */
  36. #define PyFunction_GET_CODE(func) \
  37.         (((PyFunctionObject *)func) -> func_code)
  38. #define PyFunction_GET_GLOBALS(func) \
  39.     (((PyFunctionObject *)func) -> func_globals)
  40. #define PyFunction_GET_DEFAULTS(func) \
  41.     (((PyFunctionObject *)func) -> func_defaults)
  42. #define PyFunction_GET_CLOSURE(func) \
  43.     (((PyFunctionObject *)func) -> func_closure)
  44.  
  45. /* The classmethod and staticmethod types lives here, too */
  46. extern DL_IMPORT(PyTypeObject) PyClassMethod_Type;
  47. extern DL_IMPORT(PyTypeObject) PyStaticMethod_Type;
  48.  
  49. extern DL_IMPORT(PyObject *) PyClassMethod_New(PyObject *);
  50. extern DL_IMPORT(PyObject *) PyStaticMethod_New(PyObject *);
  51.  
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif /* !Py_FUNCOBJECT_H */
  56.