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 PyObject* PyImport_AddModule(const(char)* name);
45 /// _
46 PyObject* PyImport_ImportModule(const(char)* name);
47 
48 version(Python_2_5_Or_Later){
49     /// Availability: >= 2.5
50     PyObject* PyImport_ImportModuleLevel(char* name,
51             PyObject* globals, PyObject* locals, PyObject* fromlist,
52             int level);
53 }
54 version(Python_2_6_Or_Later){
55     /// Availability: >= 2.6
56     PyObject*  PyImport_ImportModuleNoBlock(const(char)* name);
57 }
58 version(Python_2_5_Or_Later){
59     /// _
60     PyObject* PyImport_ImportModuleEx()(char* n, PyObject* g, PyObject* l,
61             PyObject* f) {
62         return PyImport_ImportModuleLevel(n, g, l, f, -1);
63     }
64 }else{
65     /// _
66     PyObject* PyImport_ImportModuleEx(char* , PyObject* , PyObject* , PyObject* );
67 }
68 
69 version(Python_2_6_Or_Later){
70     /// Availability: >= 2.6
71     PyObject* PyImport_GetImporter(PyObject* path);
72 }
73 /// _
74 PyObject* PyImport_Import(PyObject* name);
75 /// _
76 PyObject* PyImport_ReloadModule(PyObject* m);
77 /// _
78 void PyImport_Cleanup();
79 /// _
80 int PyImport_ImportFrozenModule(char* );
81 
82 version(Python_3_0_Or_Later) {
83     /**
84 Params:
85 name = UTF-8 encoded string
86 */
87     /// Availability: 3.*
88     PyObject* _PyImport_FindBuiltin(
89             char* name
90             );
91     /// Availability: 3.*
92     PyObject* _PyImport_FindExtensionUnicode(char*, PyObject*);
93     /**
94 Params:
95 mod =
96 name = UTF-8 encoded string
97 */
98     /// Availability: 3.*
99     int _PyImport_FixupBuiltin(
100             PyObject* mod,
101             char* name
102             );
103     /// Availability: 3.*
104     int _PyImport_FixupExtensionUnicode(PyObject*, char*, PyObject*);
105 }else {
106     struct filedescr; // TODO: what the heck is this?
107     /// Availability: 2.*
108     filedescr* _PyImport_FindModule(
109             const(char)*, PyObject*, char*, size_t, FILE**, PyObject**);
110     /// Availability: 2.*
111     int _PyImport_IsScript(filedescr*);
112 }
113 /// _
114 void _PyImport_ReInitLock();
115 
116 /// _
117 PyObject* _PyImport_FindExtension(char* , char* );
118 /// _
119 PyObject* _PyImport_FixupExtension(char* , char* );
120 
121 /// _
122 struct _inittab {
123     /// _
124     char* name;
125     version(Python_3_0_Or_Later) {
126         /// Availability: 3.*
127         PyObject* function() initfunc;
128     }else{
129         /// Availability: 2.*
130         void function() initfunc;
131     }
132 }
133 
134 /// _
135 mixin(PyAPI_DATA!"PyTypeObject PyNullImporter_Type");
136 /// _
137 mixin(PyAPI_DATA!"_inittab* PyImport_Inittab");
138 
139 version(Python_3_0_Or_Later) {
140     /// Availability: 3.*
141     int PyImport_AppendInittab(const(char)* name, PyObject* function() initfunc);
142 }else {
143     /// Availability: 2.*
144     int PyImport_AppendInittab(const(char)* name, void function() initfunc);
145 }
146 /// _
147 int PyImport_ExtendInittab(_inittab *newtab);
148 
149 /// _
150 struct _frozen {
151     /// _
152     char* name;
153     /// _
154     ubyte *code;
155     /// _
156     int size;
157 }
158 
159 /** Embedding apps may change this pointer to point to their favorite
160    collection of frozen modules: */
161 mixin(PyAPI_DATA!"_frozen* PyImport_FrozenModules");
162