MCPcopy Create free account
hub / github.com/Snapchat/Valdi / getJsModuleWithSchema

Function getJsModuleWithSchema

valdi/test/integration/Runtime_tests.cpp:156–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154 wrapper.teardown();
155 }
156
157 TSNMode getTSNMode() const {
158 return isWithTSN() ? TSNMode::Enabled : TSNMode::Disabled;
159 }
160
161 RuntimeWrapper wrapper;
162};
163
164static 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) {

Callers 2

TEST_PFunction · 0.85

Calls 8

getGlobalFunction · 0.85
setCurrentSchemaMethod · 0.80
getJavaScriptRuntimeMethod · 0.80
makeStringMethod · 0.80
getMethod · 0.65
ErrorInterface · 0.50
resolveTypeReferencesMethod · 0.45

Tested by

no test coverage detected