| 114 | }; |
| 115 | |
| 116 | bool SpirvTools::Parse(const std::vector<uint32_t>& binary, |
| 117 | const HeaderParser& header_parser, |
| 118 | const InstructionParser& instruction_parser, |
| 119 | spv_diagnostic* diagnostic) { |
| 120 | CxxParserContext parser_context = {header_parser, instruction_parser}; |
| 121 | |
| 122 | spv_parsed_header_fn_t header_fn_wrapper = |
| 123 | [](void* user_data, spv_endianness_t endianness, uint32_t magic, |
| 124 | uint32_t version, uint32_t generator, uint32_t id_bound, |
| 125 | uint32_t reserved) { |
| 126 | CxxParserContext* ctx = reinterpret_cast<CxxParserContext*>(user_data); |
| 127 | spv_parsed_header_t header = {magic, version, generator, id_bound, |
| 128 | reserved}; |
| 129 | |
| 130 | return ctx->header_parser(endianness, header); |
| 131 | }; |
| 132 | |
| 133 | spv_parsed_instruction_fn_t instruction_fn_wrapper = |
| 134 | [](void* user_data, const spv_parsed_instruction_t* instruction) { |
| 135 | CxxParserContext* ctx = reinterpret_cast<CxxParserContext*>(user_data); |
| 136 | return ctx->instruction_parser(*instruction); |
| 137 | }; |
| 138 | |
| 139 | spv_result_t status = spvBinaryParse( |
| 140 | impl_->context, &parser_context, binary.data(), binary.size(), |
| 141 | header_fn_wrapper, instruction_fn_wrapper, diagnostic); |
| 142 | return status == SPV_SUCCESS; |
| 143 | } |
| 144 | |
| 145 | bool SpirvTools::Validate(const std::vector<uint32_t>& binary) const { |
| 146 | return Validate(binary.data(), binary.size()); |
no test coverage detected