jpayne@69: #ifndef Py_COMPILE_H jpayne@69: #define Py_COMPILE_H jpayne@69: jpayne@69: #ifndef Py_LIMITED_API jpayne@69: #include "code.h" jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: #endif jpayne@69: jpayne@69: /* Public interface */ jpayne@69: struct _node; /* Declare the existence of this type */ jpayne@69: PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *); jpayne@69: /* XXX (ncoghlan): Unprefixed type name in a public API! */ jpayne@69: jpayne@69: #define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \ jpayne@69: CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \ jpayne@69: CO_FUTURE_UNICODE_LITERALS | CO_FUTURE_BARRY_AS_BDFL | \ jpayne@69: CO_FUTURE_GENERATOR_STOP | CO_FUTURE_ANNOTATIONS) jpayne@69: #define PyCF_MASK_OBSOLETE (CO_NESTED) jpayne@69: #define PyCF_SOURCE_IS_UTF8 0x0100 jpayne@69: #define PyCF_DONT_IMPLY_DEDENT 0x0200 jpayne@69: #define PyCF_ONLY_AST 0x0400 jpayne@69: #define PyCF_IGNORE_COOKIE 0x0800 jpayne@69: #define PyCF_TYPE_COMMENTS 0x1000 jpayne@69: #define PyCF_ALLOW_TOP_LEVEL_AWAIT 0x2000 jpayne@69: jpayne@69: #ifndef Py_LIMITED_API jpayne@69: typedef struct { jpayne@69: int cf_flags; /* bitmask of CO_xxx flags relevant to future */ jpayne@69: int cf_feature_version; /* minor Python version (PyCF_ONLY_AST) */ jpayne@69: } PyCompilerFlags; jpayne@69: jpayne@69: #define _PyCompilerFlags_INIT \ jpayne@69: (PyCompilerFlags){.cf_flags = 0, .cf_feature_version = PY_MINOR_VERSION} jpayne@69: #endif jpayne@69: jpayne@69: /* Future feature support */ jpayne@69: jpayne@69: typedef struct { jpayne@69: int ff_features; /* flags set by future statements */ jpayne@69: int ff_lineno; /* line number of last future statement */ jpayne@69: } PyFutureFeatures; jpayne@69: jpayne@69: #define FUTURE_NESTED_SCOPES "nested_scopes" jpayne@69: #define FUTURE_GENERATORS "generators" jpayne@69: #define FUTURE_DIVISION "division" jpayne@69: #define FUTURE_ABSOLUTE_IMPORT "absolute_import" jpayne@69: #define FUTURE_WITH_STATEMENT "with_statement" jpayne@69: #define FUTURE_PRINT_FUNCTION "print_function" jpayne@69: #define FUTURE_UNICODE_LITERALS "unicode_literals" jpayne@69: #define FUTURE_BARRY_AS_BDFL "barry_as_FLUFL" jpayne@69: #define FUTURE_GENERATOR_STOP "generator_stop" jpayne@69: #define FUTURE_ANNOTATIONS "annotations" jpayne@69: jpayne@69: struct _mod; /* Declare the existence of this type */ jpayne@69: #define PyAST_Compile(mod, s, f, ar) PyAST_CompileEx(mod, s, f, -1, ar) jpayne@69: PyAPI_FUNC(PyCodeObject *) PyAST_CompileEx( jpayne@69: struct _mod *mod, jpayne@69: const char *filename, /* decoded from the filesystem encoding */ jpayne@69: PyCompilerFlags *flags, jpayne@69: int optimize, jpayne@69: PyArena *arena); jpayne@69: PyAPI_FUNC(PyCodeObject *) PyAST_CompileObject( jpayne@69: struct _mod *mod, jpayne@69: PyObject *filename, jpayne@69: PyCompilerFlags *flags, jpayne@69: int optimize, jpayne@69: PyArena *arena); jpayne@69: PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST( jpayne@69: struct _mod * mod, jpayne@69: const char *filename /* decoded from the filesystem encoding */ jpayne@69: ); jpayne@69: PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromASTObject( jpayne@69: struct _mod * mod, jpayne@69: PyObject *filename jpayne@69: ); jpayne@69: jpayne@69: /* _Py_Mangle is defined in compile.c */ jpayne@69: PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name); jpayne@69: jpayne@69: #define PY_INVALID_STACK_EFFECT INT_MAX jpayne@69: PyAPI_FUNC(int) PyCompile_OpcodeStackEffect(int opcode, int oparg); jpayne@69: PyAPI_FUNC(int) PyCompile_OpcodeStackEffectWithJump(int opcode, int oparg, int jump); jpayne@69: jpayne@69: PyAPI_FUNC(int) _PyAST_Optimize(struct _mod *, PyArena *arena, int optimize); jpayne@69: jpayne@69: #ifdef __cplusplus jpayne@69: } jpayne@69: #endif jpayne@69: jpayne@69: #endif /* !Py_LIMITED_API */ jpayne@69: jpayne@69: /* These definitions must match corresponding definitions in graminit.h. */ jpayne@69: #define Py_single_input 256 jpayne@69: #define Py_file_input 257 jpayne@69: #define Py_eval_input 258 jpayne@69: #define Py_func_type_input 345 jpayne@69: jpayne@69: #endif /* !Py_COMPILE_H */