| 38 | } |
| 39 | |
| 40 | Result<Ref<ModuleLoadStrategy>> ModuleLoadStrategy::parse(const Byte* data, size_t length) { |
| 41 | auto result = jsonToValue(data, length); |
| 42 | if (!result) { |
| 43 | return result.moveError(); |
| 44 | } |
| 45 | |
| 46 | SimpleExceptionTracker exceptionTracker; |
| 47 | auto map = result.value().checkedTo<Ref<ValueMap>>(exceptionTracker); |
| 48 | if (!exceptionTracker) { |
| 49 | return exceptionTracker.extractError(); |
| 50 | } |
| 51 | |
| 52 | FlatMap<StringBox, ComponentLoadStrategy> strategies; |
| 53 | |
| 54 | for (const auto& it : *map) { |
| 55 | auto& strategy = strategies[it.first]; |
| 56 | |
| 57 | auto moduleNamesValue = it.second.getMapValue("valdi_modules"); |
| 58 | auto moduleNamesArray = moduleNamesValue.checkedTo<Ref<ValueArray>>(exceptionTracker); |
| 59 | if (!exceptionTracker) { |
| 60 | return exceptionTracker.extractError(); |
| 61 | } |
| 62 | |
| 63 | for (const auto& moduleName : *moduleNamesArray) { |
| 64 | strategy.valdiModules.emplace_back(moduleName.toStringBox()); |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | return makeShared<ModuleLoadStrategy>(std::move(strategies)); |
| 69 | } |
| 70 | |
| 71 | BundleInitializer::BundleInitializer(Bundle* bundle) : _bundle(strongSmallRef(bundle)), _lock(bundle->_mutex) {} |
| 72 | BundleInitializer::~BundleInitializer() { |
nothing calls this directly
no test coverage detected