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}
185
186static Result<Value> getJsModulePropertyWithSchema(
187 Runtime* runtime,
188 const std::shared_ptr<snap::valdi_core::JSRuntimeNativeObjectsManager>& nativeObjectsManager,
189 ValueSchemaRegistry* registry,
190 std::string_view moduleName,
191 std::string_view propertyName,
192 std::string_view propertySchema) {
193 auto propertySchemaResult = ValueSchema::parse(propertySchema);
194 if (!propertySchemaResult) {
195 return propertySchemaResult.moveError();
196 }
197
198 auto schema = ValueSchema::cls(
199 STRING_LITERAL("JSModule"),
200 false,
201 {ClassPropertySchema(StringCache::getGlobal().makeString(propertyName), propertySchemaResult.value())});
202
203 auto unmarshalledJsModule = getJsModuleWithSchema(runtime, nativeObjectsManager, registry, moduleName, schema);
204 if (!unmarshalledJsModule) {
205 return unmarshalledJsModule.moveError();
206 }
207
208 return unmarshalledJsModule.value().getTypedObject()->getProperty(0);
209}
210
211static Result<Value> getJsModulePropertyWithSchema(Runtime* runtime,
212 std::string_view moduleName,

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