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

Function getJsModulePropertyWithSchema

valdi/test/integration/Runtime_tests.cpp:186–209  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184 auto moduleIndex = runtime->getJavaScriptRuntime()->pushModuleToMarshaller(
185 nativeObjectsManager, StringCache::getGlobal().makeString(moduleName), marshaller);
186 if (!exceptionTracker) {
187 return Error(STRING_FORMAT("Couldn't resolve module '{}'", moduleName));
188 }
189
190 return marshaller.get(moduleIndex);
191}
192
193static Result<Value> getJsModulePropertyWithSchema(
194 Runtime* runtime,
195 const std::shared_ptr<snap::valdi_core::JSRuntimeNativeObjectsManager>& nativeObjectsManager,
196 ValueSchemaRegistry* registry,
197 std::string_view moduleName,
198 std::string_view propertyName,
199 std::string_view propertySchema) {
200 auto propertySchemaResult = ValueSchema::parse(propertySchema);
201 if (!propertySchemaResult) {
202 return propertySchemaResult.moveError();
203 }
204
205 auto schema = ValueSchema::cls(
206 STRING_LITERAL("JSModule"),
207 false,
208 {ClassPropertySchema(StringCache::getGlobal().makeString(propertyName), propertySchemaResult.value())});
209
210 auto unmarshalledJsModule = getJsModuleWithSchema(runtime, nativeObjectsManager, registry, moduleName, schema);
211 if (!unmarshalledJsModule) {
212 return unmarshalledJsModule.moveError();

Callers 3

TEST_PFunction · 0.85
TEST_PMethod · 0.85

Calls 8

getGlobalFunction · 0.85
getJsModuleWithSchemaFunction · 0.85
makeStringMethod · 0.80
valueMethod · 0.65
parseFunction · 0.50
ClassPropertySchemaClass · 0.50
getPropertyMethod · 0.45
getTypedObjectMethod · 0.45

Tested by

no test coverage detected