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 
11 extern(C):
12 // Python-header-file: Include/compile.h:
13 
14 /// _
15 PyCodeObject* PyNode_Compile(node*, const(char)*);
16 
17 /// _
18 struct PyFutureFeatures {
19     version(Python_2_5_Or_Later){
20         /** flags set by future statements */
21         /// Availability: >= 2.5
22         int ff_features;
23         /** line number of last future statement */
24         /// Availability: >= 2.5
25         int ff_lineno;
26     }else{
27         /// Availability: <= 2.4
28         int ff_found_docstring;
29         /// Availability: <= 2.4
30         int ff_last_linno;
31         /// Availability: <= 2.4
32         int ff_features;
33     }
34 }
35 
36 version(Python_2_5_Or_Later){
37 }else{
38     /// Availability: <= 2.4
39     PyFutureFeatures *PyNode_Future(node*, const(char)*);
40     /// Availability: <= 2.4
41     PyCodeObject *PyNode_CompileFlags(node*, const(char)*, PyCompilerFlags*);
42 }
43 
44 /// _
45 enum FUTURE_NESTED_SCOPES = "nested_scopes";
46 /// _
47 enum FUTURE_GENERATORS = "generators";
48 /// _
49 enum FUTURE_DIVISION = "division";
50 version(Python_2_5_Or_Later){
51     /// Availability: >= 2.5
52     enum FUTURE_ABSOLUTE_IMPORT = "absolute_import";
53     /// Availability: >= 2.5
54     enum FUTURE_WITH_STATEMENT = "with_statement";
55     version(Python_2_6_Or_Later){
56         /// Availability: >= 2.6
57         enum FUTURE_PRINT_FUNCTION = "print_function";
58         /// Availability: >= 2.6
59         enum FUTURE_UNICODE_LITERALS = "unicode_literals";
60     }
61     version(Python_3_0_Or_Later) {
62         /// Availability: >= 3.2
63         enum FUTURE_BARRY_AS_BDFL = "barry_as_FLUFL";
64     }
65 
66     /// _
67     struct _mod; /* Declare the existence of this type */
68     version(Python_3_2_Or_Later) {
69         /// Availability: >= 3.2
70         PyCodeObject* PyAST_Compile()(_mod* mod, const(char)* s,
71                 PyCompilerFlags* f, PyArena* ar) {
72             return PyAST_CompileEx(mod, s, f, -1, ar);
73         }
74         /**
75 Params:
76 filename = decoded from the filesystem encoding
77 */
78         /// Availability: >= 3.2
79         PyCodeObject* PyAST_CompileEx(
80                 _mod* mod,
81                 const(char)* filename,
82                 PyCompilerFlags* flags,
83                 int optimize,
84                 PyArena* arena);
85     }else {
86         /// Availability: 2.*
87         PyCodeObject* PyAST_Compile(
88                 _mod*, const(char)*, PyCompilerFlags*, PyArena*);
89     }
90     /// Availability: >= 2.5
91     PyFutureFeatures* PyFuture_FromAST(_mod*, const(char)*);
92 }
93 
94 version(Python_3_5_Or_Later) {
95     enum FUTURE_GENERATOR_STOP = "generator_stop";
96 }