| 1 |
|
| 2 |
|
| 3 |
#ifndef Py_CODE_H |
| 4 |
#define Py_CODE_H |
| 5 |
#ifdef __cplusplus |
| 6 |
extern "C" { |
| 7 |
#endif |
| 8 |
|
| 9 |
|
| 10 |
typedef struct { |
| 11 |
PyObject_HEAD |
| 12 |
int co_argcount; |
| 13 |
int co_nlocals; |
| 14 |
int co_stacksize; |
| 15 |
int co_flags; |
| 16 |
PyObject *co_code; |
| 17 |
PyObject *co_consts; |
| 18 |
PyObject *co_names; |
| 19 |
PyObject *co_varnames; |
| 20 |
PyObject *co_freevars; |
| 21 |
PyObject *co_cellvars; |
| 22 |
|
| 23 |
PyObject *co_filename; |
| 24 |
PyObject *co_name; |
| 25 |
int co_firstlineno; |
| 26 |
PyObject *co_lnotab; |
| 27 |
|
| 28 |
void *co_zombieframe; |
| 29 |
PyObject *co_weakreflist; |
| 30 |
} PyCodeObject; |
| 31 |
|
| 32 |
|
| 33 |
#define CO_OPTIMIZED 0x0001 |
| 34 |
#define CO_NEWLOCALS 0x0002 |
| 35 |
#define CO_VARARGS 0x0004 |
| 36 |
#define CO_VARKEYWORDS 0x0008 |
| 37 |
#define CO_NESTED 0x0010 |
| 38 |
#define CO_GENERATOR 0x0020 |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
#define CO_NOFREE 0x0040 |
| 45 |
|
| 46 |
#if 0 |
| 47 |
|
| 48 |
#define CO_GENERATOR_ALLOWED 0x1000 |
| 49 |
#endif |
| 50 |
#define CO_FUTURE_DIVISION 0x2000 |
| 51 |
#define CO_FUTURE_ABSOLUTE_IMPORT 0x4000 |
| 52 |
#define CO_FUTURE_WITH_STATEMENT 0x8000 |
| 53 |
#define CO_FUTURE_PRINT_FUNCTION 0x10000 |
| 54 |
#define CO_FUTURE_UNICODE_LITERALS 0x20000 |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
#if 1 |
| 60 |
#define PY_PARSER_REQUIRES_FUTURE_KEYWORD |
| 61 |
#endif |
| 62 |
|
| 63 |
#define CO_MAXBLOCKS 20 |
| 64 |
|
| 65 |
PyAPI_DATA(PyTypeObject) PyCode_Type; |
| 66 |
|
| 67 |
#define PyCode_Check(op) (Py_TYPE(op) == &PyCode_Type) |
| 68 |
#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars)) |
| 69 |
|
| 70 |
|
| 71 |
PyAPI_FUNC(PyCodeObject *) PyCode_New( |
| 72 |
int, int, int, int, PyObject *, PyObject *, PyObject *, PyObject *, |
| 73 |
PyObject *, PyObject *, PyObject *, PyObject *, int, PyObject *); |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
PyAPI_FUNC(PyCodeObject *) |
| 78 |
PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno); |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int); |
| 84 |
|
| 85 |
|
| 86 |
#define _PyCode_GETCODEPTR(co, pp) \ |
| 87 |
((*Py_TYPE((co)->co_code)->tp_as_buffer->bf_getreadbuffer) \ |
| 88 |
((co)->co_code, 0, (void **)(pp))) |
| 89 |
|
| 90 |
typedef struct _addr_pair { |
| 91 |
int ap_lower; |
| 92 |
int ap_upper; |
| 93 |
} PyAddrPair; |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
PyAPI_FUNC(int) _PyCode_CheckLineNumber(PyCodeObject* co, |
| 99 |
int lasti, PyAddrPair *bounds); |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
PyAPI_FUNC(PyObject*) _PyCode_ConstantKey(PyObject *obj); |
| 109 |
|
| 110 |
PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts, |
| 111 |
PyObject *names, PyObject *lineno_obj); |
| 112 |
|
| 113 |
#ifdef __cplusplus |
| 114 |
} |
| 115 |
#endif |
| 116 |
#endif |