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 30 struct PyCompilerFlags { 31 int cf_flags; 32 } 33 } 34 35 /// _ 36 struct PyFutureFeatures { 37 version(Python_2_5_Or_Later){ 38 /** flags set by future statements */ 39 /// Availability: >= 2.5 40 int ff_features; 41 /** line number of last future statement */ 42 /// Availability: >= 2.5 43 int ff_lineno; 44 }else{ 45 /// Availability: <= 2.4 46 int ff_found_docstring; 47 /// Availability: <= 2.4 48 int ff_last_linno; 49 /// Availability: <= 2.4 50 int ff_features; 51 } 52 } 53 54 version(Python_2_5_Or_Later){ 55 }else{ 56 /// Availability: <= 2.4 57 PyFutureFeatures *PyNode_Future(node*, const(char)*); 58 /// Availability: <= 2.4 59 PyCodeObject *PyNode_CompileFlags(node*, const(char)*, PyCompilerFlags*); 60 } 61 62 /// _ 63 enum FUTURE_NESTED_SCOPES = "nested_scopes"; 64 /// _ 65 enum FUTURE_GENERATORS = "generators"; 66 /// _ 67 enum FUTURE_DIVISION = "division"; 68 version(Python_2_5_Or_Later){ 69 /// Availability: >= 2.5 70 enum FUTURE_ABSOLUTE_IMPORT = "absolute_import"; 71 /// Availability: >= 2.5 72 enum FUTURE_WITH_STATEMENT = "with_statement"; 73 version(Python_2_6_Or_Later){ 74 /// Availability: >= 2.6 75 enum FUTURE_PRINT_FUNCTION = "print_function"; 76 /// Availability: >= 2.6 77 enum FUTURE_UNICODE_LITERALS = "unicode_literals"; 78 } 79 version(Python_3_0_Or_Later) { 80 /// Availability: >= 3.2 81 enum FUTURE_BARRY_AS_BDFL = "barry_as_FLUFL"; 82 } 83 84 /// _ 85 struct _mod; /* Declare the existence of this type */ 86 version(Python_3_2_Or_Later) { 87 /// Availability: >= 3.2 88 PyCodeObject* PyAST_Compile()(_mod* mod, const(char)* s, 89 PyCompilerFlags* f, PyArena* ar) { 90 return PyAST_CompileEx(mod, s, f, -1, ar); 91 } 92 /** 93 Params: 94 filename = decoded from the filesystem encoding 95 */ 96 /// Availability: >= 3.2 97 PyCodeObject* PyAST_CompileEx( 98 _mod* mod, 99 const(char)* filename, 100 PyCompilerFlags* flags, 101 int optimize, 102 PyArena* arena); 103 }else { 104 /// Availability: 2.* 105 PyCodeObject* PyAST_Compile( 106 _mod*, const(char)*, PyCompilerFlags*, PyArena*); 107 } 108 /// Availability: >= 2.5 109 PyFutureFeatures* PyFuture_FromAST(_mod*, const(char)*); 110 } 111 112 version(Python_3_5_Or_Later) { 113 enum FUTURE_GENERATOR_STOP = "generator_stop"; 114 } 115 116 version(Python_3_7_Or_Later) { 117 enum FUTURE_ANNOTATIONS = "annotations"; 118 }