1 /** 2 Mirror _compile.h 3 */ 4 module deimos.python.compile; 5 6 import deimos.python.code; 7 import deimos.python.node; 8 import deimos.python.pythonrun; 9 import deimos.python.pyarena; 10 import deimos.python.code; 11 12 extern(C): 13 // Python-header-file: Include/compile.h: 14 15 /// _ 16 PyCodeObject* PyNode_Compile(node*, const(char)*); 17 18 version(Python_3_7_Or_Later) { 19 enum PyCF_MASK = 20 CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | 21 CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | 22 CO_FUTURE_UNICODE_LITERALS | CO_FUTURE_BARRY_AS_BDFL | 23 CO_FUTURE_GENERATOR_STOP | CO_FUTURE_ANNOTATIONS; 24 enum PyCF_MASK_OBSOLETE = CO_NESTED; 25 enum PyCF_SOURCE_IS_UTF8 = 0x100; 26 enum PyCF_DONT_IMPLY_DEDENT = 0x200; 27 enum PyCF_ONLY_AST = 0x400; 28 enum PyCF_IGNORE_COOKIE = 0x800; 29 enum PyCF_TYPE_COMMENTS = 0x1000; 30 enum PyCF_ALLOW_TOP_LEVEL_AWAIT = 0x2000; 31 32 struct PyCompilerFlags { 33 int cf_flags; 34 } 35 } 36 37 38 /// _ 39 struct PyFutureFeatures { 40 version(Python_2_5_Or_Later){ 41 /** flags set by future statements */ 42 /// Availability: >= 2.5 43 int ff_features; 44 /** line number of last future statement */ 45 /// Availability: >= 2.5 46 int ff_lineno; 47 }else{ 48 /// Availability: <= 2.4 49 int ff_found_docstring; 50 /// Availability: <= 2.4 51 int ff_last_linno; 52 /// Availability: <= 2.4 53 int ff_features; 54 } 55 } 56 57 version(Python_2_5_Or_Later){ 58 }else{ 59 /// Availability: <= 2.4 60 PyFutureFeatures *PyNode_Future(node*, const(char)*); 61 /// Availability: <= 2.4 62 PyCodeObject *PyNode_CompileFlags(node*, const(char)*, PyCompilerFlags*); 63 } 64 65 /// _ 66 enum FUTURE_NESTED_SCOPES = "nested_scopes"; 67 /// _ 68 enum FUTURE_GENERATORS = "generators"; 69 /// _ 70 enum FUTURE_DIVISION = "division"; 71 version(Python_2_5_Or_Later){ 72 /// Availability: >= 2.5 73 enum FUTURE_ABSOLUTE_IMPORT = "absolute_import"; 74 /// Availability: >= 2.5 75 enum FUTURE_WITH_STATEMENT = "with_statement"; 76 version(Python_2_6_Or_Later){ 77 /// Availability: >= 2.6 78 enum FUTURE_PRINT_FUNCTION = "print_function"; 79 /// Availability: >= 2.6 80 enum FUTURE_UNICODE_LITERALS = "unicode_literals"; 81 } 82 version(Python_3_0_Or_Later) { 83 /// Availability: >= 3.2 84 enum FUTURE_BARRY_AS_BDFL = "barry_as_FLUFL"; 85 } 86 87 /// _ 88 struct _mod; /* Declare the existence of this type */ 89 version(Python_3_2_Or_Later) { 90 /// Availability: >= 3.2 91 PyCodeObject* PyAST_Compile()(_mod* mod, const(char)* s, 92 PyCompilerFlags* f, PyArena* ar) { 93 return PyAST_CompileEx(mod, s, f, -1, ar); 94 } 95 /** 96 Params: 97 mod = 98 filename = decoded from the filesystem encoding 99 flags = 100 optimize = 101 arena = 102 */ 103 /// Availability: >= 3.2 104 PyCodeObject* PyAST_CompileEx( 105 _mod* mod, 106 const(char)* filename, 107 PyCompilerFlags* flags, 108 int optimize, 109 PyArena* arena); 110 }else { 111 /// Availability: 2.* 112 PyCodeObject* PyAST_Compile( 113 _mod*, const(char)*, PyCompilerFlags*, PyArena*); 114 } 115 /// Availability: >= 2.5 116 PyFutureFeatures* PyFuture_FromAST(_mod*, const(char)*); 117 } 118 119 version(Python_3_5_Or_Later) { 120 enum FUTURE_GENERATOR_STOP = "generator_stop"; 121 } 122 123 version(Python_3_7_Or_Later) { 124 enum FUTURE_ANNOTATIONS = "annotations"; 125 }