| 154 | wrapper.teardown(); |
| 155 | } |
| 156 | |
| 157 | TSNMode getTSNMode() const { |
| 158 | return isWithTSN() ? TSNMode::Enabled : TSNMode::Disabled; |
| 159 | } |
| 160 | |
| 161 | RuntimeWrapper wrapper; |
| 162 | }; |
| 163 | |
| 164 | static Result<Value> getJsModuleWithSchema( |
| 165 | Runtime* runtime, |
| 166 | const std::shared_ptr<snap::valdi_core::JSRuntimeNativeObjectsManager>& nativeObjectsManager, |
| 167 | ValueSchemaRegistry* registry, |
| 168 | std::string_view moduleName, |
| 169 | const ValueSchema& schema) { |
| 170 | auto resolvedSchema = schema; |
| 171 | if (registry != nullptr) { |
| 172 | ValueSchemaTypeResolver typeResolver(registry); |
| 173 | auto schemaResult = typeResolver.resolveTypeReferences(schema); |
| 174 | if (!schemaResult) { |
| 175 | return schemaResult.moveError(); |
| 176 | } |
| 177 | resolvedSchema = schemaResult.moveValue(); |
| 178 | } |
| 179 | |
| 180 | Valdi::SimpleExceptionTracker exceptionTracker; |
| 181 | Valdi::Marshaller marshaller(exceptionTracker); |
| 182 | |
| 183 | marshaller.setCurrentSchema(resolvedSchema); |
| 184 | |
| 185 | auto moduleIndex = runtime->getJavaScriptRuntime()->pushModuleToMarshaller( |
| 186 | nativeObjectsManager, StringCache::getGlobal().makeString(moduleName), marshaller); |
| 187 | if (!exceptionTracker) { |
no test coverage detected