| 290 | |
| 291 | template <typename T> |
| 292 | Result BinaryReader::ReadT(T* out_value, |
| 293 | const char* type_name, |
| 294 | const char* desc) { |
| 295 | if (state_.offset + sizeof(T) > read_end_) { |
| 296 | PrintError("unable to read %s: %s", type_name, desc); |
| 297 | return Result::Error; |
| 298 | } |
| 299 | #if WABT_BIG_ENDIAN |
| 300 | uint8_t tmp[sizeof(T)]; |
| 301 | memcpy(tmp, state_.data + state_.offset, sizeof(tmp)); |
| 302 | SwapBytesSized(tmp, sizeof(tmp)); |
| 303 | memcpy(out_value, tmp, sizeof(T)); |
| 304 | #else |
| 305 | memcpy(out_value, state_.data + state_.offset, sizeof(T)); |
| 306 | #endif |
| 307 | state_.offset += sizeof(T); |
| 308 | return Result::Ok; |
| 309 | } |
| 310 | |
| 311 | Result BinaryReader::ReadU8(uint8_t* out_value, const char* desc) { |
| 312 | return ReadT(out_value, "uint8_t", desc); |
nothing calls this directly
no test coverage detected