| 147 | } |
| 148 | } |
| 149 | } |
| 150 | eventLoop = nullptr; |
| 151 | preserveFirstError(registry.close()); |
| 152 | return result; |
| 153 | } |
| 154 | |
| 155 | Result syncRegistry() |
| 156 | { |
| 157 | PluginDefinition definitions[16]; |
| 158 | Span<PluginDefinition> definitionSpan; |
| 159 | Buffer fileBuffer; |
| 160 | SC_TRY(PluginScanner::scanDirectory(state.examplesPath.view(), definitions, fileBuffer, definitionSpan)) |
| 161 | SC_TRY(registry.replaceDefinitions(move(definitionSpan))); |
| 162 | return Result(true); |
| 163 | } |
| 164 | |
| 165 | Result load(StringView identifier) |
| 166 | { |
| 167 | const PluginDynamicLibrary* exampleLibrary = registry.findPlugin(identifier); |
| 168 | |
| 169 | Buffer serializedModelState, serializedViewState; |
| 170 | if (exampleLibrary) |
| 171 | { |
| 172 | ISCExample* example = nullptr; |
| 173 | if (exampleLibrary->queryInterface(example) and example->serialize.isValid()) |
| 174 | { |
| 175 | SC_TRY(example->serialize(serializedModelState, serializedViewState)); |
| 176 | } |
| 177 | if (example and example->closeAsync.isValid()) |
| 178 | { |
| 179 | SC_TRY(example->closeAsync(*eventLoop)); |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | SC_TRY(registry.loadPlugin(identifier, compiler, sysroot, state.executablePath.view(), |
| 184 | PluginRegistry::LoadMode::Reload)); |
| 185 | |
| 186 | ISCExample* example = nullptr; |
| 187 | SC_TRY(exampleLibrary->queryInterface(example)); |
no test coverage detected