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     /**
89 Params:
90 name = UTF-8 encoded string
91 */
92     version(Python_3_7_Or_Later) {
93         /// Availability: 3.*
94         PyObject* _PyImport_FindBuiltin(
95                 char* name,
96                 PyObject* modules
97                 );
98     }else{
99         /// Availability: 3.*
100         PyObject* _PyImport_FindBuiltin(
101                 char* name
102                 );
103     }
104     /// Availability: 3.*
105     PyObject* _PyImport_FindExtensionUnicode(char*, PyObject*);
106     /**
107 Params:
108 mod =
109 name = UTF-8 encoded string
110 */
111     version(Python_3_7_Or_Later) {
112         /// Availability: 3.*
113         int _PyImport_FixupBuiltin(
114             PyObject* mod,
115             char* name,
116             PyObject* modules
117             );
118     }else{
119         /// Availability: 3.*
120         int _PyImport_FixupBuiltin(
121             PyObject* mod,
122             char* name
123             );
124     }
125     /// Availability: 3.*
126     int _PyImport_FixupExtensionUnicode(PyObject*, char*, PyObject*);
127 }else {
128     struct filedescr; // TODO: what the heck is this?
129     /// Availability: 2.*
130     filedescr* _PyImport_FindModule(
131             const(char)*, PyObject*, char*, size_t, FILE**, PyObject**);
132     /// Availability: 2.*
133     int _PyImport_IsScript(filedescr*);
134 }
135 /// _
136 void _PyImport_ReInitLock();
137 
138 /// _
139 PyObject* _PyImport_FindExtension(char* , char* );
140 /// _
141 PyObject* _PyImport_FixupExtension(char* , char* );
142 
143 /// _
144 struct _inittab {
145     /// _
146     char* name;
147     version(Python_3_0_Or_Later) {
148         /// Availability: 3.*
149         PyObject* function() initfunc;
150     }else{
151         /// Availability: 2.*
152         void function() initfunc;
153     }
154 }
155 
156 /// _
157 mixin(PyAPI_DATA!"PyTypeObject PyNullImporter_Type");
158 /// _
159 mixin(PyAPI_DATA!"_inittab* PyImport_Inittab");
160 
161 version(Python_3_0_Or_Later) {
162     /// Availability: 3.*
163     int PyImport_AppendInittab(const(char)* name, PyObject* function() initfunc);
164 }else {
165     /// Availability: 2.*
166     int PyImport_AppendInittab(const(char)* name, void function() initfunc);
167 }
168 /// _
169 int PyImport_ExtendInittab(_inittab *newtab);
170 
171 /// _
172 struct _frozen {
173     /// _
174     char* name;
175     /// _
176     ubyte *code;
177     /// _
178     int size;
179 }
180 
181 /** Embedding apps may change this pointer to point to their favorite
182    collection of frozen modules: */
183 mixin(PyAPI_DATA!"_frozen* PyImport_FrozenModules");
184