| 370 | return ValueSchemaParser::parse(str); |
| 371 | } |
| 372 | |
| 373 | size_t ValueSchema::hash() const { |
| 374 | auto baseHash = static_cast<size_t>(_type); |
| 375 | |
| 376 | visitNestedType( |
| 377 | *this, |
| 378 | [&](const ValueSchemaTypeReference& typeReference) { boost::hash_combine(baseHash, typeReference.hash()); }, |
| 379 | [&](const GenericValueSchemaTypeReference& genericTypeReference) { |
| 380 | boost::hash_combine(baseHash, genericTypeReference.getType().hash()); |
| 381 | for (size_t i = 0; i < genericTypeReference.getTypeArgumentsSize(); i++) { |
| 382 | boost::hash_combine(baseHash, genericTypeReference.getTypeArgument(i).hash()); |
| 383 | } |
| 384 | }, |
| 385 | [&](const ClassSchema& classSchema) { boost::hash_combine(baseHash, classSchema.hash()); }, |
| 386 | [&](const EnumSchema& enumSchema) { |
| 387 | boost::hash_combine(baseHash, enumSchema.getName().hash()); |
| 388 | boost::hash_combine(baseHash, enumSchema.getCaseSchema().hash()); |
| 389 | for (size_t i = 0; i < enumSchema.getCasesSize(); i++) { |
| 390 | const auto& enumCase = enumSchema.getCase(i); |
| 391 | boost::hash_combine(baseHash, enumCase.name.hash()); |
| 392 | boost::hash_combine(baseHash, enumCase.value.hash()); |
| 393 | } |
| 394 | }, |
| 395 | [&](const ValueFunctionSchema& functionSchema) { |
| 396 | const auto& attributes = functionSchema.getAttributes(); |
| 397 | boost::hash_combine(baseHash, attributes.isMethod()); |
| 398 | boost::hash_combine(baseHash, attributes.isSingleCall()); |
| 399 | boost::hash_combine(baseHash, attributes.shouldDispatchToWorkerThread()); |
| 400 | boost::hash_combine(baseHash, attributes.allowSyncCall()); |
| 401 | boost::hash_combine(baseHash, functionSchema.getReturnValue().hash()); |
| 402 | for (size_t i = 0; i < functionSchema.getParametersSize(); i++) { |
| 403 | boost::hash_combine(baseHash, functionSchema.getParameter(i).hash()); |
| 404 | } |
| 405 | }, |
| 406 | [&](const ArraySchema& arraySchema) { boost::hash_combine(baseHash, arraySchema.getElementSchema().hash()); }, |
| 407 | [&](const MapSchema& mapSchema) { |
| 408 | boost::hash_combine(baseHash, mapSchema.getKey().hash()); |
| 409 | boost::hash_combine(baseHash, mapSchema.getValue().hash()); |
| 410 | }, |
| 411 | [&](const ES6MapSchema& es6mapSchema) { |
| 412 | boost::hash_combine(baseHash, es6mapSchema.getKey().hash()); |
| 413 | boost::hash_combine(baseHash, es6mapSchema.getValue().hash()); |
| 414 | }, |
| 415 | [&](const ES6SetSchema& es6setSchema) { boost::hash_combine(baseHash, es6setSchema.getKey().hash()); }, |
| 416 | [&](const OutcomeSchema& outcomeSchema) { |
| 417 | boost::hash_combine(baseHash, outcomeSchema.getValue().hash()); |
| 418 | boost::hash_combine(baseHash, outcomeSchema.getError().hash()); |
| 419 | }, |
| 420 | [&](const ProtoSchema& protoSchema) { boost::hash_combine(baseHash, protoSchema.hash()); }, |
| 421 | [&](const PromiseSchema& promiseSchema) { |
| 422 | boost::hash_combine(baseHash, promiseSchema.getValueSchema().hash()); |
| 423 | }, |
| 424 | [&](const ValueSchemaReference& schemaReference) { |
| 425 | boost::hash_combine(baseHash, schemaReference.getKey().hash()); |
| 426 | }); |
| 427 | |
| 428 | boost::hash_combine(baseHash, _flags); |
| 429 | return baseHash; |
no test coverage detected