1 /**
2   Mirror import.h
3 
4   Module definition and import interface
5   */
6 module deimos.python.import_;
7 
8 import deimos.python.pyport;
9 import deimos.python.object;
10 import core.stdc.stdio;
11 
12 extern(C):
13 // Python-header-file: Include/import.h:
14 
15 /// _
16 C_long PyImport_GetMagicNumber();
17 version(Python_3_0_Or_Later) {
18     /// Availability: 3.*
19     const(char)* PyImport_GetMagicTag();
20 }
21 /// _
22 PyObject* PyImport_ExecCodeModule(char* name, PyObject* co);
23 /// _
24 PyObject* PyImport_ExecCodeModuleEx(char* name, PyObject* co, char* pathname);
25 version(Python_3_0_Or_Later) {
26     /**
27 Params:
28 name = UTF-8 encoded string
29 co =
30 pathname = decoded from the filesystem encoding
31 cpathname = decoded from the filesystem encoding
32      */
33     /// Availability: 3.*
34     PyObject* PyImport_ExecCodeModuleWithPathnames(
35             char* name,
36             PyObject* co,
37             char* pathname,
38             char* cpathname
39             );
40 }
41 /// _
42 PyObject* PyImport_GetModuleDict();
43 
44 version(Python_3_7_Or_Later) {
45     PyObject* PyImport_GetModule(PyObject* name);
46 }
47 
48 /// _
49 PyObject* PyImport_AddModule(const(char)* name);
50 /// _
51 PyObject* PyImport_ImportModule(const(char)* name);
52 
53 version(Python_2_5_Or_Later){
54     /// Availability: >= 2.5
55     PyObject* PyImport_ImportModuleLevel(char* name,
56             PyObject* globals, PyObject* locals, PyObject* fromlist,
57             int level);
58 }
59 version(Python_2_6_Or_Later){
60     /// Availability: >= 2.6
61     PyObject*  PyImport_ImportModuleNoBlock(const(char)* name);
62 }
63 version(Python_2_5_Or_Later){
64     /// _
65     PyObject* PyImport_ImportModuleEx()(char* n, PyObject* g, PyObject* l,
66             PyObject* f) {
67         return PyImport_ImportModuleLevel(n, g, l, f, -1);
68     }
69 }else{
70     /// _
71     PyObject* PyImport_ImportModuleEx(char* , PyObject* , PyObject* , PyObject* );
72 }
73 
74 version(Python_2_6_Or_Later){
75     /// Availability: >= 2.6
76     PyObject* PyImport_GetImporter(PyObject* path);
77 }
78 /// _
79 PyObject* PyImport_Import(PyObject* name);
80 /// _
81 PyObject* PyImport_ReloadModule(PyObject* m);
82 /// _
83 void PyImport_Cleanup();
84 /// _
85 int PyImport_ImportFrozenModule(char* );
86 
87 version(Python_3_0_Or_Later) {
88     version(Python_3_7_Or_Later) {
89         /**
90         Params:
91         name = UTF-8 encoded string
92         modules =
93         */
94         /// Availability: 3.*
95         PyObject* _PyImport_FindBuiltin(
96                 char* name,
97                 PyObject* modules
98                 );
99     }else{
100         /// Availability: 3.*
101         PyObject* _PyImport_FindBuiltin(
102                 char* name
103                 );
104     }
105     /// Availability: 3.*
106     PyObject* _PyImport_FindExtensionUnicode(char*, PyObject*);
107     version(Python_3_7_Or_Later) {
108         /**
109             Params:
110             mod =
111             name = UTF-8 encoded string
112             modules =
113             */
114         /// Availability: 3.*
115         int _PyImport_FixupBuiltin(
116             PyObject* mod,
117             char* name,
118             PyObject* modules
119             );
120     }else{
121         /// Availability: 3.*
122         int _PyImport_FixupBuiltin(
123             PyObject* mod,
124             char* name
125             );
126     }
127     /// Availability: 3.*
128     int _PyImport_FixupExtensionUnicode(PyObject*, char*, PyObject*);
129 }else {
130     struct filedescr; // TODO: what the heck is this?
131     /// Availability: 2.*
132     filedescr* _PyImport_FindModule(
133             const(char)*, PyObject*, char*, size_t, FILE**, PyObject**);
134     /// Availability: 2.*
135     int _PyImport_IsScript(filedescr*);
136 }
137 /// _
138 void _PyImport_ReInitLock();
139 
140 /// _
141 PyObject* _PyImport_FindExtension(char* , char* );
142 /// _
143 PyObject* _PyImport_FixupExtension(char* , char* );
144 
145 /// _
146 struct _inittab {
147     /// _
148     char* name;
149     version(Python_3_0_Or_Later) {
150         /// Availability: 3.*
151         PyObject* function() initfunc;
152     }else{
153         /// Availability: 2.*
154         void function() initfunc;
155     }
156 }
157 
158 /// _
159 mixin(PyAPI_DATA!"PyTypeObject PyNullImporter_Type");
160 /// _
161 mixin(PyAPI_DATA!"_inittab* PyImport_Inittab");
162 
163 version(Python_3_0_Or_Later) {
164     /// Availability: 3.*
165     int PyImport_AppendInittab(const(char)* name, PyObject* function() initfunc);
166 }else {
167     /// Availability: 2.*
168     int PyImport_AppendInittab(const(char)* name, void function() initfunc);
169 }
170 /// _
171 int PyImport_ExtendInittab(_inittab *newtab);
172 
173 /// _
174 struct _frozen {
175     /// _
176     char* name;
177     /// _
178     ubyte *code;
179     /// _
180     int size;
181 }
182 
183 /** Embedding apps may change this pointer to point to their favorite
184    collection of frozen modules: */
185 mixin(PyAPI_DATA!"_frozen* PyImport_FrozenModules");
186