| 1568 | } |
| 1569 | |
| 1570 | FORY_NOINLINE uint16_t read_compatible_uint16(ReadContext &ctx, |
| 1571 | uint32_t remote_type_id, |
| 1572 | std::string_view field) { |
| 1573 | uint64_t value = 0; |
| 1574 | if (read_uint_target(ctx, remote_type_id, |
| 1575 | static_cast<uint32_t>(TypeId::UINT16), field, |
| 1576 | std::numeric_limits<uint16_t>::max(), value)) { |
| 1577 | return static_cast<uint16_t>(value); |
| 1578 | } |
| 1579 | if (FORY_PREDICT_FALSE(ctx.has_error())) { |
| 1580 | return 0; |
| 1581 | } |
| 1582 | return read_converted<uint16_t>( |
| 1583 | ctx, remote_type_id, static_cast<uint32_t>(TypeId::UINT16), field, |
| 1584 | [](const ScalarValue &value, uint16_t &out) { |
| 1585 | uint64_t tmp = 0; |
| 1586 | if (!scalar_to_uint64(value, std::numeric_limits<uint16_t>::max(), |
| 1587 | tmp)) { |
| 1588 | return false; |
| 1589 | } |
| 1590 | out = static_cast<uint16_t>(tmp); |
| 1591 | return true; |
| 1592 | }); |
| 1593 | } |
| 1594 | |
| 1595 | FORY_NOINLINE int32_t read_compatible_int32(ReadContext &ctx, |
| 1596 | uint32_t remote_type_id, |
no test coverage detected