MCPcopy Create free account
hub / github.com/c3d/tao3D / importModule

Method importModule

tao/module_manager.cpp:132–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

130
131
132XL::Tree_p ModuleManager::importModule(XL::Context_p context,
133 XL::Tree_p self,
134 XL::Tree_p what,
135 XL::phase_t phase)
136// ----------------------------------------------------------------------------
137// The primitive to import a module, for example: import ModuleName "1.10"
138// ----------------------------------------------------------------------------
139{
140 XL::Name *name = NULL;
141 double m_v = 1.0;
142 XL::Prefix *prefix = what->AsPrefix();
143
144 if (prefix)
145 {
146 m_v = parseVersion(prefix->right);
147 name = prefix->left->AsName();
148 }
149 else
150 {
151 name = what->AsName();
152 }
153
154 if (name && m_v > 0.0)
155 {
156 text m_n = name->value;
157 bool found = false, name_found = false, version_found = false;
158 bool enabled_found = false;
159 double inst_v = 0.0;
160 foreach (ModuleInfoPrivate m, modules)
161 {
162 if (m_n == m.importName)
163 {
164 name_found = true;
165 inst_v = m.ver;
166 if (versionMatches(m.ver, m_v))
167 {
168 version_found = true;
169 if (!m.enabled)
170 continue;
171 enabled_found = true;
172 if (m.hasNative && phase != XL::PARSING_PHASE)
173 {
174 if (!m.native && !m.inError)
175 {
176 bool ok = loadNative(context, m);
177 m = *moduleById(m.id);
178 if (!ok)
179 break;
180 }
181 if (!m.native)
182 continue;
183 }
184 found = true;
185 QString xlPath = m.xlPath();
186
187 if (phase == XL::DECLARATION_PHASE)
188 {
189 IFTRACE(modules)

Callers 1

importMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected