| 1312 | } |
| 1313 | |
| 1314 | bool CPluginManager::RunSecondPass(CPlugin *pPlugin) |
| 1315 | { |
| 1316 | // Make sure external dependencies are around. |
| 1317 | if (!RequireExtensions(pPlugin)) |
| 1318 | return false; |
| 1319 | if (!FindOrRequirePluginDeps(pPlugin)) |
| 1320 | return false; |
| 1321 | |
| 1322 | // Run another binding pass. |
| 1323 | g_ShareSys.BindNativesToPlugin(pPlugin, false); |
| 1324 | |
| 1325 | // Find any unbound natives. Right now, these are not allowed. |
| 1326 | uint32_t num = pPlugin->runtime()->GetNativesNum(); |
| 1327 | for (unsigned int i=0; i<num; i++) |
| 1328 | { |
| 1329 | const sp_native_t *native = pPlugin->runtime()->GetNative(i); |
| 1330 | if (!native) |
| 1331 | break; |
| 1332 | if (native->status == SP_NATIVE_UNBOUND && |
| 1333 | native->name[0] != '@' && |
| 1334 | !(native->flags & SP_NTVFLAG_OPTIONAL)) |
| 1335 | { |
| 1336 | pPlugin->EvictWithError(Plugin_Failed, "Native \"%s\" was not found", native->name); |
| 1337 | return false; |
| 1338 | } |
| 1339 | } |
| 1340 | |
| 1341 | // Finish by telling all listeners. |
| 1342 | for (ListenerIter iter(m_listeners); !iter.done(); iter.next()) |
| 1343 | (*iter)->OnPluginLoaded(pPlugin); |
| 1344 | |
| 1345 | // Tell this plugin to finish initializing itself. |
| 1346 | if (!pPlugin->OnPluginStart()) |
| 1347 | return false; |
| 1348 | |
| 1349 | // Now, if we have fake natives, go through all plugins that might need rebinding. |
| 1350 | if (pPlugin->HasFakeNatives()) { |
| 1351 | for (PluginIter iter(m_plugins); !iter.done(); iter.next()) { |
| 1352 | CPlugin *pOther = (*iter); |
| 1353 | if ((pOther->GetStatus() == Plugin_Error |
| 1354 | && (pOther->HasMissingFakeNatives() || pOther->HasMissingLibrary())) |
| 1355 | || pOther->HasMissingFakeNatives()) |
| 1356 | { |
| 1357 | TryRefreshDependencies(pOther); |
| 1358 | } |
| 1359 | else if ((pOther->GetStatus() == Plugin_Running |
| 1360 | || pOther->GetStatus() == Plugin_Paused) |
| 1361 | && pOther != pPlugin) |
| 1362 | { |
| 1363 | g_ShareSys.BeginBindingFor(pPlugin); |
| 1364 | pPlugin->BindFakeNativesTo(pOther); |
| 1365 | } |
| 1366 | } |
| 1367 | } |
| 1368 | |
| 1369 | // Go through our libraries and tell other plugins they're added. |
| 1370 | pPlugin->LibraryActions(LibraryAction_Added); |
| 1371 |
nothing calls this directly
no test coverage detected